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
|
|---|---|---|---|---|---|---|---|---|
dlazz/ansible
|
lib/ansible/module_utils/network/cnos/cnos.py
|
5
|
19569
|
# This code is part of Ansible, but is an independent component.
# This particular file snippet, and this file snippet only, is BSD licensed.
# Modules you write using this snippet, which is embedded dynamically by
# Ansible still belong to the author of the module, and may assign their own
# license to the complete work.
#
# Copyright (C) 2017 Lenovo, 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.
#
# 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.
#
# Contains utility methods
# Lenovo Networking
import time
import socket
import re
try:
from ansible.module_utils.network.cnos import cnos_errorcodes
from ansible.module_utils.network.cnos import cnos_devicerules
HAS_LIB = True
except Exception:
HAS_LIB = False
from distutils.cmd import Command
from ansible.module_utils._text import to_text
from ansible.module_utils.basic import env_fallback, return_values
from ansible.module_utils.network.common.utils import to_list, EntityCollection
from ansible.module_utils.connection import Connection, exec_command
from ansible.module_utils.connection import ConnectionError
_DEVICE_CONFIGS = {}
_CONNECTION = None
cnos_provider_spec = {
'host': dict(),
'port': dict(type='int'),
'username': dict(fallback=(env_fallback, ['ANSIBLE_NET_USERNAME'])),
'password': dict(fallback=(env_fallback, ['ANSIBLE_NET_PASSWORD']),
no_log=True),
'ssh_keyfile': dict(fallback=(env_fallback, ['ANSIBLE_NET_SSH_KEYFILE']),
type='path'),
'authorize': dict(fallback=(env_fallback, ['ANSIBLE_NET_AUTHORIZE']),
type='bool'),
'auth_pass': dict(fallback=(env_fallback, ['ANSIBLE_NET_AUTH_PASS']),
no_log=True),
'timeout': dict(type='int'),
'context': dict(),
'passwords': dict()
}
cnos_argument_spec = {
'provider': dict(type='dict', options=cnos_provider_spec),
}
command_spec = {
'command': dict(key=True),
'prompt': dict(),
'answer': dict(),
'check_all': dict()
}
def get_provider_argspec():
return cnos_provider_spec
def check_args(module, warnings):
pass
def get_connection(module):
global _CONNECTION
if _CONNECTION:
return _CONNECTION
_CONNECTION = Connection(module._socket_path)
context = None
try:
context = module.params['context']
except KeyError:
context = None
if context:
if context == 'system':
command = 'changeto system'
else:
command = 'changeto context %s' % context
_CONNECTION.get(command)
return _CONNECTION
def get_config(module, flags=None):
flags = [] if flags is None else flags
passwords = None
try:
passwords = module.params['passwords']
except KeyError:
passwords = None
if passwords:
cmd = 'more system:running-config'
else:
cmd = 'display running-config '
cmd += ' '.join(flags)
cmd = cmd.strip()
try:
return _DEVICE_CONFIGS[cmd]
except KeyError:
conn = get_connection(module)
out = conn.get(cmd)
cfg = to_text(out, errors='surrogate_then_replace').strip()
_DEVICE_CONFIGS[cmd] = cfg
return cfg
def to_commands(module, commands):
if not isinstance(commands, list):
raise AssertionError('argument must be of type <list>')
transform = EntityCollection(module, command_spec)
commands = transform(commands)
for index, item in enumerate(commands):
if module.check_mode and not item['command'].startswith('show'):
module.warn('only show commands are supported when using check '
'mode, not executing `%s`' % item['command'])
return commands
def run_commands(module, commands, check_rc=True):
connection = get_connection(module)
connection.get('enable')
commands = to_commands(module, to_list(commands))
responses = list()
for cmd in commands:
out = connection.get(**cmd)
responses.append(to_text(out, errors='surrogate_then_replace'))
return responses
def run_cnos_commands(module, commands, check_rc=True):
retVal = ''
enter_config = {'command': 'configure terminal', 'prompt': None,
'answer': None}
exit_config = {'command': 'end', 'prompt': None, 'answer': None}
commands.insert(0, enter_config)
commands.append(exit_config)
for cmd in commands:
retVal = retVal + '>> ' + cmd['command'] + '\n'
try:
responses = run_commands(module, commands, check_rc)
for response in responses:
retVal = retVal + '<< ' + response + '\n'
except Exception as e:
errMsg = ''
if hasattr(e, 'message'):
errMsg = e.message
else:
errMsg = str(e)
# Exception in Exceptions
if 'VLAN_ACCESS_MAP' in errMsg:
return retVal + '<<' + errMsg + '\n'
if 'confederation identifier' in errMsg:
return retVal + '<<' + errMsg + '\n'
# Add more here if required
retVal = retVal + '<< ' + 'Error-101 ' + errMsg + '\n'
return str(retVal)
def load_config(module, config):
try:
conn = get_connection(module)
conn.get('enable')
conn.edit_config(config)
except ConnectionError as exc:
module.fail_json(msg=to_text(exc))
def get_defaults_flag(module):
rc, out, err = exec_command(module, 'display running-config ?')
out = to_text(out, errors='surrogate_then_replace')
commands = set()
for line in out.splitlines():
if line:
commands.add(line.strip().split()[0])
if 'all' in commands:
return 'all'
else:
return 'full'
def enterEnableModeForDevice(enablePassword, timeout, obj):
command = "enable\n"
pwdPrompt = "password:"
# debugOutput(enablePassword)
# debugOutput('\n')
obj.settimeout(int(timeout))
# Executing enable
obj.send(command)
flag = False
retVal = ""
count = 5
while not flag:
# If wait time is execeeded.
if(count == 0):
flag = True
else:
count = count - 1
# A delay of one second
time.sleep(1)
try:
buffByte = obj.recv(9999)
buff = buffByte.decode()
retVal = retVal + buff
# debugOutput(buff)
gotit = buff.find(pwdPrompt)
if(gotit != -1):
time.sleep(1)
if(enablePassword is None or enablePassword == ""):
return "\n Error-106"
obj.send(enablePassword)
obj.send("\r")
obj.send("\n")
time.sleep(1)
innerBuffByte = obj.recv(9999)
innerBuff = innerBuffByte.decode()
retVal = retVal + innerBuff
# debugOutput(innerBuff)
innerGotit = innerBuff.find("#")
if(innerGotit != -1):
return retVal
else:
gotit = buff.find("#")
if(gotit != -1):
return retVal
except Exception:
retVal = retVal + "\n Error-101"
flag = True
if(retVal == ""):
retVal = "\n Error-101"
return retVal
# EOM
def waitForDeviceResponse(command, prompt, timeout, obj):
obj.settimeout(int(timeout))
obj.send(command)
flag = False
retVal = ""
while not flag:
time.sleep(1)
try:
buffByte = obj.recv(9999)
buff = buffByte.decode()
retVal = retVal + buff
# debugOutput(retVal)
gotit = buff.find(prompt)
if(gotit != -1):
flag = True
except Exception:
# debugOutput(prompt)
if prompt == "(yes/no)?":
retVal = retVal
elif prompt == "Password:":
retVal = retVal
else:
retVal = retVal + "\n Error-101"
flag = True
return retVal
# EOM
def checkOutputForError(output):
retVal = ""
index = output.lower().find('error')
startIndex = index + 6
if(index == -1):
index = output.lower().find('invalid')
startIndex = index + 8
if(index == -1):
index = output.lower().find('cannot be enabled in l2 interface')
startIndex = index + 34
if(index == -1):
index = output.lower().find('incorrect')
startIndex = index + 10
if(index == -1):
index = output.lower().find('failure')
startIndex = index + 8
if(index == -1):
return None
endIndex = startIndex + 3
errorCode = output[startIndex:endIndex]
result = errorCode.isdigit()
if(result is not True):
return "Device returned an Error. Please check Results for more \
information"
errorFile = "dictionary/ErrorCodes.lvo"
try:
# with open(errorFile, 'r') as f:
f = open(errorFile, 'r')
for line in f:
if('=' in line):
data = line.split('=')
if(data[0].strip() == errorCode):
errorString = data[1].strip()
return errorString
except Exception:
errorString = cnos_errorcodes.getErrorString(errorCode)
errorString = errorString.strip()
return errorString
return "Error Code Not Found"
# EOM
def checkSanityofVariable(deviceType, variableId, variableValue):
retVal = ""
ruleFile = "dictionary/" + deviceType + "_rules.lvo"
ruleString = getRuleStringForVariable(deviceType, ruleFile, variableId)
retVal = validateValueAgainstRule(ruleString, variableValue)
return retVal
# EOM
def getRuleStringForVariable(deviceType, ruleFile, variableId):
retVal = ""
try:
# with open(ruleFile, 'r') as f:
f = open(ruleFile, 'r')
for line in f:
# debugOutput(line)
if(':' in line):
data = line.split(':')
# debugOutput(data[0])
if(data[0].strip() == variableId):
retVal = line
except Exception:
ruleString = cnos_devicerules.getRuleString(deviceType, variableId)
retVal = ruleString.strip()
return retVal
# EOM
def validateValueAgainstRule(ruleString, variableValue):
retVal = ""
if(ruleString == ""):
return 1
rules = ruleString.split(':')
variableType = rules[1].strip()
varRange = rules[2].strip()
if(variableType == "INTEGER"):
result = checkInteger(variableValue)
if(result is True):
return "ok"
else:
return "Error-111"
elif(variableType == "FLOAT"):
result = checkFloat(variableValue)
if(result is True):
return "ok"
else:
return "Error-112"
elif(variableType == "INTEGER_VALUE"):
int_range = varRange.split('-')
r = range(int(int_range[0].strip()), int(int_range[1].strip()))
if(checkInteger(variableValue) is not True):
return "Error-111"
result = int(variableValue) in r
if(result is True):
return "ok"
else:
return "Error-113"
elif(variableType == "INTEGER_VALUE_RANGE"):
int_range = varRange.split('-')
varLower = int_range[0].strip()
varHigher = int_range[1].strip()
r = range(int(varLower), int(varHigher))
val_range = variableValue.split('-')
try:
valLower = val_range[0].strip()
valHigher = val_range[1].strip()
except Exception:
return "Error-113"
if((checkInteger(valLower) is not True) or
(checkInteger(valHigher) is not True)):
# debugOutput("Error-114")
return "Error-114"
result = (int(valLower) in r) and (int(valHigher)in r) \
and (int(valLower) < int(valHigher))
if(result is True):
return "ok"
else:
# debugOutput("Error-113")
return "Error-113"
elif(variableType == "INTEGER_OPTIONS"):
int_options = varRange.split(',')
if(checkInteger(variableValue) is not True):
return "Error-111"
for opt in int_options:
if(opt.strip() is variableValue):
result = True
break
if(result is True):
return "ok"
else:
return "Error-115"
elif(variableType == "LONG"):
result = checkLong(variableValue)
if(result is True):
return "ok"
else:
return "Error-116"
elif(variableType == "LONG_VALUE"):
long_range = varRange.split('-')
r = range(int(long_range[0].strip()), int(long_range[1].strip()))
if(checkLong(variableValue) is not True):
# debugOutput(variableValue)
return "Error-116"
result = int(variableValue) in r
if(result is True):
return "ok"
else:
return "Error-113"
elif(variableType == "LONG_VALUE_RANGE"):
long_range = varRange.split('-')
r = range(int(long_range[0].strip()), int(long_range[1].strip()))
val_range = variableValue.split('-')
if((checkLong(val_range[0]) is not True) or
(checkLong(val_range[1]) is not True)):
return "Error-117"
result = (val_range[0] in r) and (
val_range[1] in r) and (val_range[0] < val_range[1])
if(result is True):
return "ok"
else:
return "Error-113"
elif(variableType == "LONG_OPTIONS"):
long_options = varRange.split(',')
if(checkLong(variableValue) is not True):
return "Error-116"
for opt in long_options:
if(opt.strip() == variableValue):
result = True
break
if(result is True):
return "ok"
else:
return "Error-115"
elif(variableType == "TEXT"):
if(variableValue == ""):
return "Error-118"
if(True is isinstance(variableValue, str)):
return "ok"
else:
return "Error-119"
elif(variableType == "NO_VALIDATION"):
if(variableValue == ""):
return "Error-118"
else:
return "ok"
elif(variableType == "TEXT_OR_EMPTY"):
if(variableValue is None or variableValue == ""):
return "ok"
if(result == isinstance(variableValue, str)):
return "ok"
else:
return "Error-119"
elif(variableType == "MATCH_TEXT"):
if(variableValue == ""):
return "Error-118"
if(isinstance(variableValue, str)):
if(varRange == variableValue):
return "ok"
else:
return "Error-120"
else:
return "Error-119"
elif(variableType == "MATCH_TEXT_OR_EMPTY"):
if(variableValue is None or variableValue == ""):
return "ok"
if(isinstance(variableValue, str)):
if(varRange == variableValue):
return "ok"
else:
return "Error-120"
else:
return "Error-119"
elif(variableType == "TEXT_OPTIONS"):
str_options = varRange.split(',')
if(isinstance(variableValue, str) is not True):
return "Error-119"
result = False
for opt in str_options:
if(opt.strip() == variableValue):
result = True
break
if(result is True):
return "ok"
else:
return "Error-115"
elif(variableType == "TEXT_OPTIONS_OR_EMPTY"):
if(variableValue is None or variableValue == ""):
return "ok"
str_options = varRange.split(',')
if(isinstance(variableValue, str) is not True):
return "Error-119"
for opt in str_options:
if(opt.strip() == variableValue):
result = True
break
if(result is True):
return "ok"
else:
return "Error-115"
elif(variableType == "IPV4Address"):
try:
socket.inet_pton(socket.AF_INET, variableValue)
result = True
except socket.error:
result = False
if(result is True):
return "ok"
else:
return "Error-121"
elif(variableType == "IPV4AddressWithMask"):
if(variableValue is None or variableValue == ""):
return "Error-119"
str_options = variableValue.split('/')
ipaddr = str_options[0]
mask = str_options[1]
try:
socket.inet_pton(socket.AF_INET, ipaddr)
if(checkInteger(mask) is True):
result = True
else:
result = False
except socket.error:
result = False
if(result is True):
return "ok"
else:
return "Error-121"
elif(variableType == "IPV6Address"):
try:
socket.inet_pton(socket.AF_INET6, variableValue)
result = True
except socket.error:
result = False
if(result is True):
return "ok"
else:
return "Error-122"
return retVal
# EOM
def disablePaging(remote_conn):
remote_conn.send("terminal length 0\n")
time.sleep(1)
# Clear the buffer on the screen
outputByte = remote_conn.recv(1000)
output = outputByte.decode()
return output
# EOM
def checkInteger(s):
try:
int(s)
return True
except ValueError:
return False
# EOM
def checkFloat(s):
try:
float(s)
return True
except ValueError:
return False
# EOM
def checkLong(s):
try:
int(s)
return True
except ValueError:
return False
def debugOutput(command):
f = open('debugOutput.txt', 'a')
f.write(str(command)) # python will convert \n to os.linesep
f.close() # you can omit in most cases as the destructor will call it
# EOM
|
gpl-3.0
|
[
3,
961,
1233,
365,
1777,
402,
2622,
12,
1325,
365,
376,
12717,
3931,
14,
199,
3,
961,
6770,
570,
17440,
12,
436,
642,
570,
17440,
1454,
12,
365,
6289,
18233,
14,
199,
3,
18167,
1265,
2218,
1808,
642,
17440,
12,
1314,
365,
12169,
18774,
701,
199,
3,
2622,
5139,
13511,
370,
314,
4132,
402,
314,
859,
12,
436,
1443,
5090,
3932,
5705,
199,
3,
4190,
370,
314,
4890,
1736,
14,
199,
3,
199,
3,
1898,
334,
35,
9,
9708,
15757,
31445,
12,
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,
7647,
26,
199,
3,
199,
3,
221,
627,
6823,
402,
1350,
1233,
1471,
8074,
314,
3432,
4248,
199,
3,
259,
4245,
12,
642,
769,
402,
3704,
436,
314,
2569,
6450,
14,
199,
3,
221,
627,
6823,
315,
3366,
1824,
1471,
9172,
314,
3432,
4248,
4245,
12,
199,
3,
259,
642,
769,
402,
3704,
436,
314,
2569,
6450,
315,
314,
3794,
199,
3,
259,
436,
15,
269,
1163,
8418,
2741,
543,
314,
4084,
14,
199,
3,
199,
3,
5749,
4141,
2281,
7049,
6515,
2334,
5877,
8164,
2401,
6483,
298,
1179,
2281,
2,
199,
3,
2401,
1821,
7168,
1549,
5292,
2990,
12,
6931,
12,
5400,
2845,
5471,
2296,
12,
2334,
199,
3,
5292,
2990,
1634,
3169,
2401,
3092,
2381,
437,
3115,
3104,
199,
3,
9315,
9706,
14,
1621,
4825,
6461,
7000,
2334,
5877,
29785,
1549,
6483,
6262,
199,
3,
7024,
2381,
1821,
8703,
12,
9168,
12,
9716,
12,
8820,
12,
9836,
12,
1549,
199,
3,
9110,
6736,
334,
6446,
12,
5400,
2845,
5471,
2296,
12,
9838,
1634,
199,
3,
9103,
9764,
1549,
9714,
27,
9102,
1634,
4815,
12,
7126,
12,
1549,
9206,
27,
1549,
9748,
199,
3,
9831,
9,
9802,
9817,
2401,
5258,
1821,
9815,
1634,
5603,
12,
7061,
1621,
199,
3,
7066,
12,
9644,
5603,
12,
1549,
7056,
334,
6446,
9254,
1549,
7334,
9,
199,
3,
7043,
1621,
1821,
9683,
5738,
1634,
2334,
4815,
1634,
5749,
4141,
12,
9704,
8036,
9691,
1634,
2334,
199,
3,
9726,
1634,
9712,
9784,
14,
199,
3,
199,
3,
22493,
11420,
3102,
199,
3,
15757,
31445,
7220,
316,
199,
199,
646,
900,
199,
646,
2838,
199,
646,
295,
199,
893,
26,
272,
687,
3242,
14,
578,
63,
1208,
14,
1200,
14,
6413,
736,
492,
32535,
63,
705,
6021,
272,
687,
3242,
14,
578,
63,
1208,
14,
1200,
14,
6413,
736,
492,
32535,
63,
271,
30150,
443,
83,
272,
7509,
63,
5617,
275,
715,
199,
2590,
2186,
26,
272,
7509,
63,
5617,
275,
756,
199,
504,
7065,
14,
1760,
492,
5817,
199,
504,
3242,
14,
578,
63,
1208,
423,
505,
492,
370,
63,
505,
199,
504,
3242,
14,
578,
63,
1208,
14,
4316,
492,
2589,
63,
10538,
12,
372,
63,
1459,
199,
504,
3242,
14,
578,
63,
1208,
14,
1200,
14,
2330,
14,
1208,
492,
370,
63,
513,
12,
17680,
7768,
199,
504,
3242,
14,
578,
63,
1208,
14,
2105,
492,
8113,
12,
2146,
63,
1531,
199,
504,
3242,
14,
578,
63,
1208,
14,
2105,
492,
25417,
199,
199,
63,
10555,
63,
5569,
51,
275,
1052,
199,
63,
18389,
275,
488,
199,
199,
6413,
736,
63,
3780,
63,
1650,
275,
469,
272,
283,
1102,
356,
1211,
1062,
272,
283,
719,
356,
1211,
8,
466,
534,
442,
659,
272,
283,
2473,
356,
1211,
8,
10538,
2687,
1813,
63,
10538,
12,
788,
8490,
63,
7278,
63,
11958,
16607,
272,
283,
2060,
356,
1211,
8,
10538,
2687,
1813,
63,
10538,
12,
788,
8490,
63,
7278,
63,
9032,
3815,
2151,
949,
63,
793,
29,
549,
395,
272,
283,
5510,
63,
21856,
356,
1211,
8,
10538,
2687,
1813,
63,
10538,
12,
788,
8490,
63,
7278,
63,
13716,
63,
3078,
3817,
3815,
717,
730,
534,
515,
659,
272,
283,
14204,
356,
1211,
8,
10538,
2687,
1813,
63,
10538,
12,
788,
8490,
63,
7278,
63,
27938,
11025,
3815,
1993,
730,
534,
2245,
659,
272,
283,
1178,
63,
1529,
356,
1211,
8,
10538,
2687,
1813,
63,
10538,
12,
788,
8490,
63,
7278,
63,
5580,
63,
6909,
3815,
1993,
949,
63,
793,
29,
549,
395,
272,
283,
2593,
356,
1211,
8,
466,
534,
442,
659,
272,
283,
1100,
356,
1211,
1062,
272,
283,
28608,
356,
1211,
342,
199,
93,
199,
199,
6413,
736,
63,
2094,
63,
1650,
275,
469,
272,
283,
3780,
356,
1211,
8,
466,
534,
807,
297,
1511,
29,
6413,
736,
63,
3780,
63,
1650,
395,
199,
93,
199,
199,
1531,
63,
1650,
275,
469,
272,
283,
1531,
356,
1211,
8,
498,
29,
549,
395,
272,
283,
7650,
356,
1211,
1062,
272,
283,
5934,
356,
1211,
1062,
272,
283,
1074,
63,
452,
356,
1211,
342,
199,
93,
421,
199,
318,
664,
63,
3780,
63,
15644,
837,
272,
372,
32535,
63,
3780,
63,
1650,
421,
199,
318,
1104,
63,
589,
8,
578,
12,
3598,
304,
272,
986,
421,
199,
318,
664,
63,
2105,
8,
578,
304,
272,
2288,
485,
18389,
272,
340,
485,
18389,
26,
267,
372,
485,
18389,
272,
485,
18389,
275,
8113,
8,
578,
423,
3450,
63,
515,
9,
339,
1067,
275,
488,
272,
862,
26,
267,
1067,
275,
859,
14,
1162,
459,
1100,
418,
272,
871,
4067,
26,
267,
1067,
275,
488,
339,
340,
1067,
26,
267,
340,
1067,
508,
283,
2253,
356,
288,
1414,
275,
283,
11984,
362,
79,
2656,
7,
267,
587,
26,
288,
1414,
275,
283,
11984,
362,
79,
1067,
450,
83,
7,
450,
1067,
267,
485,
18389,
14,
362,
8,
1531,
9,
339,
372,
485,
18389,
421,
199,
318,
664,
63,
888,
8,
578,
12,
3285,
29,
403,
304,
272,
3285,
275,
942,
340,
3285,
365,
488,
587,
3285,
339,
19572,
275,
488,
272,
862,
26,
267,
19572,
275,
859,
14,
1162,
459,
28608,
418,
272,
871,
4067,
26,
267,
19572,
275,
488,
272,
340,
19572,
26,
267,
2088,
275,
283,
6878,
2656,
26,
5720,
13,
888,
7,
272,
587,
26,
267,
2088,
275,
283,
2918,
3879,
13,
888,
283,
267,
2088,
847,
283,
1987,
904,
8,
2469,
9,
267,
2088,
275,
2088,
14,
1913,
342,
339,
862,
26,
267,
372,
485,
10555,
63,
5569,
51,
59,
1760,
61,
272,
871,
4067,
26,
267
] |
[
961,
1233,
365,
1777,
402,
2622,
12,
1325,
365,
376,
12717,
3931,
14,
199,
3,
961,
6770,
570,
17440,
12,
436,
642,
570,
17440,
1454,
12,
365,
6289,
18233,
14,
199,
3,
18167,
1265,
2218,
1808,
642,
17440,
12,
1314,
365,
12169,
18774,
701,
199,
3,
2622,
5139,
13511,
370,
314,
4132,
402,
314,
859,
12,
436,
1443,
5090,
3932,
5705,
199,
3,
4190,
370,
314,
4890,
1736,
14,
199,
3,
199,
3,
1898,
334,
35,
9,
9708,
15757,
31445,
12,
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,
7647,
26,
199,
3,
199,
3,
221,
627,
6823,
402,
1350,
1233,
1471,
8074,
314,
3432,
4248,
199,
3,
259,
4245,
12,
642,
769,
402,
3704,
436,
314,
2569,
6450,
14,
199,
3,
221,
627,
6823,
315,
3366,
1824,
1471,
9172,
314,
3432,
4248,
4245,
12,
199,
3,
259,
642,
769,
402,
3704,
436,
314,
2569,
6450,
315,
314,
3794,
199,
3,
259,
436,
15,
269,
1163,
8418,
2741,
543,
314,
4084,
14,
199,
3,
199,
3,
5749,
4141,
2281,
7049,
6515,
2334,
5877,
8164,
2401,
6483,
298,
1179,
2281,
2,
199,
3,
2401,
1821,
7168,
1549,
5292,
2990,
12,
6931,
12,
5400,
2845,
5471,
2296,
12,
2334,
199,
3,
5292,
2990,
1634,
3169,
2401,
3092,
2381,
437,
3115,
3104,
199,
3,
9315,
9706,
14,
1621,
4825,
6461,
7000,
2334,
5877,
29785,
1549,
6483,
6262,
199,
3,
7024,
2381,
1821,
8703,
12,
9168,
12,
9716,
12,
8820,
12,
9836,
12,
1549,
199,
3,
9110,
6736,
334,
6446,
12,
5400,
2845,
5471,
2296,
12,
9838,
1634,
199,
3,
9103,
9764,
1549,
9714,
27,
9102,
1634,
4815,
12,
7126,
12,
1549,
9206,
27,
1549,
9748,
199,
3,
9831,
9,
9802,
9817,
2401,
5258,
1821,
9815,
1634,
5603,
12,
7061,
1621,
199,
3,
7066,
12,
9644,
5603,
12,
1549,
7056,
334,
6446,
9254,
1549,
7334,
9,
199,
3,
7043,
1621,
1821,
9683,
5738,
1634,
2334,
4815,
1634,
5749,
4141,
12,
9704,
8036,
9691,
1634,
2334,
199,
3,
9726,
1634,
9712,
9784,
14,
199,
3,
199,
3,
22493,
11420,
3102,
199,
3,
15757,
31445,
7220,
316,
199,
199,
646,
900,
199,
646,
2838,
199,
646,
295,
199,
893,
26,
272,
687,
3242,
14,
578,
63,
1208,
14,
1200,
14,
6413,
736,
492,
32535,
63,
705,
6021,
272,
687,
3242,
14,
578,
63,
1208,
14,
1200,
14,
6413,
736,
492,
32535,
63,
271,
30150,
443,
83,
272,
7509,
63,
5617,
275,
715,
199,
2590,
2186,
26,
272,
7509,
63,
5617,
275,
756,
199,
504,
7065,
14,
1760,
492,
5817,
199,
504,
3242,
14,
578,
63,
1208,
423,
505,
492,
370,
63,
505,
199,
504,
3242,
14,
578,
63,
1208,
14,
4316,
492,
2589,
63,
10538,
12,
372,
63,
1459,
199,
504,
3242,
14,
578,
63,
1208,
14,
1200,
14,
2330,
14,
1208,
492,
370,
63,
513,
12,
17680,
7768,
199,
504,
3242,
14,
578,
63,
1208,
14,
2105,
492,
8113,
12,
2146,
63,
1531,
199,
504,
3242,
14,
578,
63,
1208,
14,
2105,
492,
25417,
199,
199,
63,
10555,
63,
5569,
51,
275,
1052,
199,
63,
18389,
275,
488,
199,
199,
6413,
736,
63,
3780,
63,
1650,
275,
469,
272,
283,
1102,
356,
1211,
1062,
272,
283,
719,
356,
1211,
8,
466,
534,
442,
659,
272,
283,
2473,
356,
1211,
8,
10538,
2687,
1813,
63,
10538,
12,
788,
8490,
63,
7278,
63,
11958,
16607,
272,
283,
2060,
356,
1211,
8,
10538,
2687,
1813,
63,
10538,
12,
788,
8490,
63,
7278,
63,
9032,
3815,
2151,
949,
63,
793,
29,
549,
395,
272,
283,
5510,
63,
21856,
356,
1211,
8,
10538,
2687,
1813,
63,
10538,
12,
788,
8490,
63,
7278,
63,
13716,
63,
3078,
3817,
3815,
717,
730,
534,
515,
659,
272,
283,
14204,
356,
1211,
8,
10538,
2687,
1813,
63,
10538,
12,
788,
8490,
63,
7278,
63,
27938,
11025,
3815,
1993,
730,
534,
2245,
659,
272,
283,
1178,
63,
1529,
356,
1211,
8,
10538,
2687,
1813,
63,
10538,
12,
788,
8490,
63,
7278,
63,
5580,
63,
6909,
3815,
1993,
949,
63,
793,
29,
549,
395,
272,
283,
2593,
356,
1211,
8,
466,
534,
442,
659,
272,
283,
1100,
356,
1211,
1062,
272,
283,
28608,
356,
1211,
342,
199,
93,
199,
199,
6413,
736,
63,
2094,
63,
1650,
275,
469,
272,
283,
3780,
356,
1211,
8,
466,
534,
807,
297,
1511,
29,
6413,
736,
63,
3780,
63,
1650,
395,
199,
93,
199,
199,
1531,
63,
1650,
275,
469,
272,
283,
1531,
356,
1211,
8,
498,
29,
549,
395,
272,
283,
7650,
356,
1211,
1062,
272,
283,
5934,
356,
1211,
1062,
272,
283,
1074,
63,
452,
356,
1211,
342,
199,
93,
421,
199,
318,
664,
63,
3780,
63,
15644,
837,
272,
372,
32535,
63,
3780,
63,
1650,
421,
199,
318,
1104,
63,
589,
8,
578,
12,
3598,
304,
272,
986,
421,
199,
318,
664,
63,
2105,
8,
578,
304,
272,
2288,
485,
18389,
272,
340,
485,
18389,
26,
267,
372,
485,
18389,
272,
485,
18389,
275,
8113,
8,
578,
423,
3450,
63,
515,
9,
339,
1067,
275,
488,
272,
862,
26,
267,
1067,
275,
859,
14,
1162,
459,
1100,
418,
272,
871,
4067,
26,
267,
1067,
275,
488,
339,
340,
1067,
26,
267,
340,
1067,
508,
283,
2253,
356,
288,
1414,
275,
283,
11984,
362,
79,
2656,
7,
267,
587,
26,
288,
1414,
275,
283,
11984,
362,
79,
1067,
450,
83,
7,
450,
1067,
267,
485,
18389,
14,
362,
8,
1531,
9,
339,
372,
485,
18389,
421,
199,
318,
664,
63,
888,
8,
578,
12,
3285,
29,
403,
304,
272,
3285,
275,
942,
340,
3285,
365,
488,
587,
3285,
339,
19572,
275,
488,
272,
862,
26,
267,
19572,
275,
859,
14,
1162,
459,
28608,
418,
272,
871,
4067,
26,
267,
19572,
275,
488,
272,
340,
19572,
26,
267,
2088,
275,
283,
6878,
2656,
26,
5720,
13,
888,
7,
272,
587,
26,
267,
2088,
275,
283,
2918,
3879,
13,
888,
283,
267,
2088,
847,
283,
1987,
904,
8,
2469,
9,
267,
2088,
275,
2088,
14,
1913,
342,
339,
862,
26,
267,
372,
485,
10555,
63,
5569,
51,
59,
1760,
61,
272,
871,
4067,
26,
267,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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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
] |
kailIII/emaresa
|
trunk.pe/account_modifier/__openerp__.py
|
3
|
1923
|
# -*- coding: utf-8 -*-
##############################################################################
#
# Author: OpenDrive Ltda
# Copyright (c) 2014 Opendrive Ltda
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsibility of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# guarantees and support are strongly advised to contract a Free Software
# Service Company
#
# 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
{
'name': 'Account Modifier',
'version': '0.2',
'author': '[OpenDrive Ltda]',
'website': '[http://www.opendrive.cl]',
'category': 'Localization',
'description':
"""
v0.1 -> Agrega el campo centro costo facturacion y centro costo facturacion nota de credito.
v0.2 -> Se eliminan los campos para nota de credito y factura y se unifican en 'cost_center'
Created By David Acevedo Toledo (Fedoro)
""",
'depends': ['base', 'account'],
'data' : [
# 'account_invoice_view.xml',
],
'installable': True,
'application': True,
}
|
agpl-3.0
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
4605,
199,
3,
199,
3,
6529,
26,
3232,
24276,
491,
84,
983,
199,
3,
1898,
334,
67,
9,
6927,
593,
6643,
6053,
491,
84,
983,
199,
3,
199,
3,
14750,
26,
961,
2240,
465,
4066,
365,
11619,
370,
506,
1202,
701,
22398,
28661,
199,
3,
2240,
16465,
3963,
5452,
314,
8852,
9163,
4783,
402,
465,
5480,
316,
1006,
12330,
199,
3,
406,
13436,
9183,
687,
2399,
1566,
1061,
315,
9587,
27164,
2578,
436,
18227,
199,
3,
9599,
4390,
3963,
787,
10023,
367,
282,
10144,
13,
475,
13,
1180,
8744,
543,
2414,
23012,
199,
3,
12072,
397,
436,
2291,
787,
30390,
1503,
17311,
370,
16077,
282,
2868,
2290,
199,
3,
7591,
15878,
199,
3,
199,
3,
961,
2240,
365,
2868,
2290,
27,
1265,
883,
3604,
652,
436,
15,
269,
199,
3,
2811,
652,
1334,
314,
2895,
402,
314,
1664,
1696,
1684,
844,
199,
3,
465,
3267,
701,
314,
2868,
2290,
2752,
27,
1902,
1015,
499,
199,
3,
402,
314,
844,
12,
503,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
961,
2240,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
199,
3,
1664,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
1696,
1684,
844,
199,
3,
3180,
543,
642,
2240,
27,
340,
440,
12,
2218,
370,
314,
2868,
2290,
199,
3,
2752,
12,
3277,
2020,
8155,
15630,
10902,
446,
14453,
13540,
12,
8226,
12,
4828,
221,
15673,
13,
13421,
12,
8217,
14,
199,
3,
199,
4605,
199,
199,
91,
267,
283,
354,
356,
283,
6009,
12972,
3895,
297,
267,
283,
1023,
356,
283,
16,
14,
18,
297,
267,
283,
2502,
356,
6730,
4299,
24276,
491,
84,
983,
4300,
267,
283,
7360,
356,
6730,
1014,
921,
1544,
14,
411,
500,
6053,
14,
429,
4300,
267,
283,
3710,
356,
283,
5339,
2072,
297,
267,
283,
1802,
356,
199,
624,
199,
86,
16,
14,
17,
1035,
437,
3939,
65,
579,
1704,
9613,
13345,
293,
7918,
79,
10572,
12417,
9718,
612,
13345,
293,
7918,
79,
10572,
12417,
9718,
440,
65,
477,
2837,
328,
475,
14,
199,
86,
16,
14,
18,
1035,
3240,
20714,
290,
16406,
1704,
311,
736,
12665,
440,
65,
477,
2837,
328,
475,
612,
10572,
12417,
612,
542,
625,
12061,
290,
655,
283,
6336,
63,
4218,
7,
421,
199,
10502,
4885,
20232,
437,
301,
1354,
79,
4005,
274,
1117,
334,
38,
379,
269,
79,
9,
199,
7208,
267,
283,
8912,
356,
788,
1095,
297,
283,
2048,
995,
267,
283,
576,
7,
520,
359,
199,
3,
198,
198,
7,
2048,
63,
5404,
63,
1345,
14,
1652,
297,
199,
198,
467,
267,
283,
21762,
356,
715,
12,
199,
198,
7,
3578,
356,
715,
12,
199,
93,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,
6529,
26,
3232,
24276,
491,
84,
983,
199,
3,
1898,
334,
67,
9,
6927,
593,
6643,
6053,
491,
84,
983,
199,
3,
199,
3,
14750,
26,
961,
2240,
465,
4066,
365,
11619,
370,
506,
1202,
701,
22398,
28661,
199,
3,
2240,
16465,
3963,
5452,
314,
8852,
9163,
4783,
402,
465,
5480,
316,
1006,
12330,
199,
3,
406,
13436,
9183,
687,
2399,
1566,
1061,
315,
9587,
27164,
2578,
436,
18227,
199,
3,
9599,
4390,
3963,
787,
10023,
367,
282,
10144,
13,
475,
13,
1180,
8744,
543,
2414,
23012,
199,
3,
12072,
397,
436,
2291,
787,
30390,
1503,
17311,
370,
16077,
282,
2868,
2290,
199,
3,
7591,
15878,
199,
3,
199,
3,
961,
2240,
365,
2868,
2290,
27,
1265,
883,
3604,
652,
436,
15,
269,
199,
3,
2811,
652,
1334,
314,
2895,
402,
314,
1664,
1696,
1684,
844,
199,
3,
465,
3267,
701,
314,
2868,
2290,
2752,
27,
1902,
1015,
499,
199,
3,
402,
314,
844,
12,
503,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
961,
2240,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
199,
3,
1664,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
1696,
1684,
844,
199,
3,
3180,
543,
642,
2240,
27,
340,
440,
12,
2218,
370,
314,
2868,
2290,
199,
3,
2752,
12,
3277,
2020,
8155,
15630,
10902,
446,
14453,
13540,
12,
8226,
12,
4828,
221,
15673,
13,
13421,
12,
8217,
14,
199,
3,
199,
4605,
199,
199,
91,
267,
283,
354,
356,
283,
6009,
12972,
3895,
297,
267,
283,
1023,
356,
283,
16,
14,
18,
297,
267,
283,
2502,
356,
6730,
4299,
24276,
491,
84,
983,
4300,
267,
283,
7360,
356,
6730,
1014,
921,
1544,
14,
411,
500,
6053,
14,
429,
4300,
267,
283,
3710,
356,
283,
5339,
2072,
297,
267,
283,
1802,
356,
199,
624,
199,
86,
16,
14,
17,
1035,
437,
3939,
65,
579,
1704,
9613,
13345,
293,
7918,
79,
10572,
12417,
9718,
612,
13345,
293,
7918,
79,
10572,
12417,
9718,
440,
65,
477,
2837,
328,
475,
14,
199,
86,
16,
14,
18,
1035,
3240,
20714,
290,
16406,
1704,
311,
736,
12665,
440,
65,
477,
2837,
328,
475,
612,
10572,
12417,
612,
542,
625,
12061,
290,
655,
283,
6336,
63,
4218,
7,
421,
199,
10502,
4885,
20232,
437,
301,
1354,
79,
4005,
274,
1117,
334,
38,
379,
269,
79,
9,
199,
7208,
267,
283,
8912,
356,
788,
1095,
297,
283,
2048,
995,
267,
283,
576,
7,
520,
359,
199,
3,
198,
198,
7,
2048,
63,
5404,
63,
1345,
14,
1652,
297,
199,
198,
467,
267,
283,
21762,
356,
715,
12,
199,
198,
7,
3578,
356,
715,
12,
199,
93,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,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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
] |
yanheven/nova
|
nova/api/openstack/compute/plugins/v3/tenant_networks.py
|
8
|
7904
|
# Copyright 2013 OpenStack Foundation
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import netaddr
import netaddr.core as netexc
from oslo_config import cfg
from oslo_log import log as logging
import six
from webob import exc
from nova.api.openstack.compute.schemas.v3 import tenant_networks as schema
from nova.api.openstack import extensions
from nova.api.openstack import wsgi
from nova.api import validation
from nova import context as nova_context
from nova import exception
from nova.i18n import _
from nova.i18n import _LE
import nova.network
from nova import quota
CONF = cfg.CONF
CONF.import_opt('enable_network_quota',
'nova.api.openstack.compute.contrib.os_tenant_networks')
CONF.import_opt('use_neutron_default_nets',
'nova.api.openstack.compute.contrib.os_tenant_networks')
CONF.import_opt('neutron_default_tenant_id',
'nova.api.openstack.compute.contrib.os_tenant_networks')
CONF.import_opt('quota_networks',
'nova.api.openstack.compute.contrib.os_tenant_networks')
ALIAS = 'os-tenant-networks'
QUOTAS = quota.QUOTAS
LOG = logging.getLogger(__name__)
authorize = extensions.os_compute_authorizer(ALIAS)
def network_dict(network):
# NOTE(danms): Here, network should be an object, which could have come
# from neutron and thus be missing most of the attributes. Providing a
# default to get() avoids trying to lazy-load missing attributes.
return {"id": network.get("uuid", None) or network.get("id", None),
"cidr": str(network.get("cidr", None)),
"label": network.get("label", None)}
class TenantNetworkController(wsgi.Controller):
def __init__(self, network_api=None):
self.network_api = nova.network.API(skip_policy_check=True)
self._default_networks = []
def _refresh_default_networks(self):
self._default_networks = []
if CONF.use_neutron_default_nets == "True":
try:
self._default_networks = self._get_default_networks()
except Exception:
LOG.exception(_LE("Failed to get default networks"))
def _get_default_networks(self):
project_id = CONF.neutron_default_tenant_id
ctx = nova_context.RequestContext(user_id=None,
project_id=project_id)
networks = {}
for n in self.network_api.get_all(ctx):
networks[n['id']] = n['label']
return [{'id': k, 'label': v} for k, v in networks.iteritems()]
@extensions.expected_errors(())
def index(self, req):
context = req.environ['nova.context']
authorize(context)
networks = list(self.network_api.get_all(context))
if not self._default_networks:
self._refresh_default_networks()
networks.extend(self._default_networks)
return {'networks': [network_dict(n) for n in networks]}
@extensions.expected_errors(404)
def show(self, req, id):
context = req.environ['nova.context']
authorize(context)
try:
network = self.network_api.get(context, id)
except exception.NetworkNotFound:
msg = _("Network not found")
raise exc.HTTPNotFound(explanation=msg)
return {'network': network_dict(network)}
@extensions.expected_errors((403, 404, 409))
@wsgi.response(202)
def delete(self, req, id):
context = req.environ['nova.context']
authorize(context)
reservation = None
try:
if CONF.enable_network_quota:
reservation = QUOTAS.reserve(context, networks=-1)
except Exception:
reservation = None
LOG.exception(_LE("Failed to update usages deallocating "
"network."))
def _rollback_quota(reservation):
if CONF.enable_network_quota and reservation:
QUOTAS.rollback(context, reservation)
try:
self.network_api.delete(context, id)
except exception.PolicyNotAuthorized as e:
_rollback_quota(reservation)
raise exc.HTTPForbidden(explanation=six.text_type(e))
except exception.NetworkInUse as e:
_rollback_quota(reservation)
raise exc.HTTPConflict(explanation=e.format_message())
except exception.NetworkNotFound:
_rollback_quota(reservation)
msg = _("Network not found")
raise exc.HTTPNotFound(explanation=msg)
if CONF.enable_network_quota and reservation:
QUOTAS.commit(context, reservation)
@extensions.expected_errors((400, 403, 503))
@validation.schema(schema.create)
def create(self, req, body):
context = req.environ["nova.context"]
authorize(context)
network = body["network"]
keys = ["cidr", "cidr_v6", "ipam", "vlan_start", "network_size",
"num_networks"]
kwargs = {k: network.get(k) for k in keys}
label = network["label"]
if kwargs["cidr"]:
try:
net = netaddr.IPNetwork(kwargs["cidr"])
if net.size < 4:
msg = _("Requested network does not contain "
"enough (2+) usable hosts")
raise exc.HTTPBadRequest(explanation=msg)
except netexc.AddrConversionError:
msg = _("Address could not be converted.")
raise exc.HTTPBadRequest(explanation=msg)
networks = []
try:
if CONF.enable_network_quota:
reservation = QUOTAS.reserve(context, networks=1)
except exception.OverQuota:
msg = _("Quota exceeded, too many networks.")
raise exc.HTTPBadRequest(explanation=msg)
try:
networks = self.network_api.create(context,
label=label, **kwargs)
if CONF.enable_network_quota:
QUOTAS.commit(context, reservation)
except exception.PolicyNotAuthorized as e:
raise exc.HTTPForbidden(explanation=six.text_type(e))
except Exception:
if CONF.enable_network_quota:
QUOTAS.rollback(context, reservation)
msg = _("Create networks failed")
LOG.exception(msg, extra=network)
raise exc.HTTPServiceUnavailable(explanation=msg)
return {"network": network_dict(networks[0])}
class TenantNetworks(extensions.V3APIExtensionBase):
"""Tenant-based Network Management Extension."""
name = "OSTenantNetworks"
alias = ALIAS
version = 1
def get_resources(self):
ext = extensions.ResourceExtension(ALIAS, TenantNetworkController())
return [ext]
def get_controller_extensions(self):
return []
def _sync_networks(context, project_id, session):
ctx = nova_context.RequestContext(user_id=None, project_id=project_id)
ctx = ctx.elevated()
networks = nova.network.api.API().get_all(ctx)
return dict(networks=len(networks))
if CONF.enable_network_quota:
QUOTAS.register_resource(quota.ReservableResource('networks',
_sync_networks,
'quota_networks'))
|
apache-2.0
|
[
3,
1898,
6171,
14260,
2752,
199,
3,
2900,
5924,
5702,
14,
199,
3,
199,
3,
259,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
1265,
1443,
199,
3,
259,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
2047,
1443,
3332,
199,
3,
259,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
260,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
259,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
259,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
2428,
199,
3,
259,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
1666,
314,
199,
3,
259,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
4204,
199,
3,
259,
1334,
314,
844,
14,
421,
199,
646,
25798,
199,
646,
25798,
14,
1018,
465,
1279,
266,
1812,
199,
504,
11258,
63,
888,
492,
4810,
199,
504,
11258,
63,
793,
492,
943,
465,
2050,
199,
646,
3816,
199,
504,
14568,
492,
3178,
199,
199,
504,
5913,
14,
1246,
14,
8512,
14,
3357,
14,
9482,
14,
86,
19,
492,
8261,
63,
7642,
465,
4177,
199,
504,
5913,
14,
1246,
14,
8512,
492,
5478,
199,
504,
5913,
14,
1246,
14,
8512,
492,
12464,
199,
504,
5913,
14,
1246,
492,
6411,
199,
504,
5913,
492,
1067,
465,
5913,
63,
1100,
199,
504,
5913,
492,
1919,
199,
504,
5913,
14,
73,
1085,
78,
492,
485,
199,
504,
5913,
14,
73,
1085,
78,
492,
485,
906,
199,
646,
5913,
14,
1200,
199,
504,
5913,
492,
12132,
421,
199,
3103,
275,
4810,
14,
3103,
199,
3103,
14,
646,
63,
2992,
360,
4296,
63,
1200,
63,
8848,
297,
355,
283,
6765,
14,
1246,
14,
8512,
14,
3357,
14,
2828,
14,
736,
63,
4647,
63,
7642,
358,
199,
3103,
14,
646,
63,
2992,
360,
1180,
63,
10271,
63,
885,
63,
20490,
297,
355,
283,
6765,
14,
1246,
14,
8512,
14,
3357,
14,
2828,
14,
736,
63,
4647,
63,
7642,
358,
199,
3103,
14,
646,
63,
2992,
360,
10271,
63,
885,
63,
4647,
63,
344,
297,
355,
283,
6765,
14,
1246,
14,
8512,
14,
3357,
14,
2828,
14,
736,
63,
4647,
63,
7642,
358,
199,
3103,
14,
646,
63,
2992,
360,
8848,
63,
7642,
297,
355,
283,
6765,
14,
1246,
14,
8512,
14,
3357,
14,
2828,
14,
736,
63,
4647,
63,
7642,
358,
421,
199,
12644,
275,
283,
736,
13,
4647,
13,
7642,
7,
199,
199,
18654,
1179,
275,
12132,
14,
18654,
1179,
199,
4947,
275,
2050,
14,
5572,
3460,
354,
3368,
199,
14204,
275,
5478,
14,
736,
63,
3357,
63,
2502,
1793,
8,
12644,
9,
421,
199,
318,
2784,
63,
807,
8,
1200,
304,
272,
327,
6944,
8,
24863,
706,
304,
11842,
12,
2784,
1077,
506,
376,
909,
12,
1314,
4293,
1172,
11492,
272,
327,
687,
8224,
436,
12850,
506,
4124,
4750,
402,
314,
3004,
14,
2165,
11604,
282,
272,
327,
849,
370,
664,
342,
23674,
9936,
370,
9617,
13,
912,
4124,
3004,
14,
272,
372,
2420,
344,
582,
2784,
14,
362,
480,
2580,
401,
488,
9,
503,
2784,
14,
362,
480,
344,
401,
488,
395,
717,
298,
10509,
582,
620,
8,
1200,
14,
362,
480,
10509,
401,
488,
1826,
717,
298,
1302,
582,
2784,
14,
362,
480,
1302,
401,
488,
6769,
421,
199,
533,
377,
287,
867,
4491,
7506,
8,
6508,
14,
7506,
304,
272,
347,
636,
826,
721,
277,
12,
2784,
63,
1246,
29,
403,
304,
267,
291,
14,
1200,
63,
1246,
275,
5913,
14,
1200,
14,
3735,
8,
2759,
63,
3185,
63,
1074,
29,
549,
9,
267,
291,
423,
885,
63,
7642,
275,
942,
339,
347,
485,
6635,
63,
885,
63,
7642,
8,
277,
304,
267,
291,
423,
885,
63,
7642,
275,
942,
267,
340,
6392,
14,
1180,
63,
10271,
63,
885,
63,
20490,
508,
298,
549,
582,
288,
862,
26,
355,
291,
423,
885,
63,
7642,
275,
291,
423,
362,
63,
885,
63,
7642,
342,
288,
871,
2186,
26,
355,
5051,
14,
1971,
1547,
906,
480,
4276,
370,
664,
849,
11759,
2237,
339,
347,
485,
362,
63,
885,
63,
7642,
8,
277,
304,
267,
2199,
63,
344,
275,
6392,
14,
10271,
63,
885,
63,
4647,
63,
344,
267,
4027,
275,
5913,
63,
1100,
14,
17679,
8,
751,
63,
344,
29,
403,
12,
5101,
2199,
63,
344,
29,
1715,
63,
344,
9,
267,
11759,
275,
1052,
267,
367,
302,
315,
291,
14,
1200,
63,
1246,
14,
362,
63,
452,
8,
3799,
304,
288,
11759,
59,
78,
459,
344,
6538,
275,
302,
459,
1302,
418,
267,
372,
9016,
344,
356,
1022,
12,
283,
1302,
356,
373,
93,
367,
1022,
12,
373,
315,
11759,
14,
4611,
5106,
339,
768,
5359,
14,
2062,
63,
2550,
30812,
272,
347,
1478,
8,
277,
12,
2648,
304,
267,
1067,
275,
2648,
14,
2314,
459,
6765,
14,
1100,
418,
267,
20210,
8,
1100,
9,
267,
11759,
275,
769,
8,
277,
14,
1200,
63,
1246,
14,
362,
63,
452,
8,
1100,
430,
267,
340,
440,
291,
423,
885,
63,
7642,
26,
288,
291,
423,
6635,
63,
885,
63,
7642,
342,
267,
11759,
14,
2880,
8,
277,
423,
885,
63,
7642,
9,
267,
372,
791,
7642,
356,
359,
1200,
63,
807,
8,
78,
9,
367,
302,
315,
11759,
9420,
339,
768,
5359,
14,
2062,
63,
2550,
8,
5188,
9,
272,
347,
2498,
8,
277,
12,
2648,
12,
1305,
304,
267,
1067,
275,
2648,
14,
2314,
459,
6765,
14,
1100,
418,
267,
20210,
8,
1100,
9,
267,
862,
26,
288,
2784,
275,
291,
14,
1200,
63,
1246,
14,
362,
8,
1100,
12,
1305,
9,
267,
871,
1919,
14,
4491,
4667,
26,
288,
1499,
275,
3824,
4491,
440,
1911,
531,
288,
746,
3178,
14,
26553,
8,
15228,
29,
1328,
9,
267,
372,
791,
1200,
356,
2784,
63,
807,
8,
1200,
6769,
339,
768,
5359,
14,
2062,
63,
2550,
1332,
13353,
12,
7901,
12,
21292,
430,
272,
768,
6508,
14,
1310,
8,
4999,
9,
272,
347,
3145,
8,
277,
12,
2648,
12,
1305,
304,
267,
1067,
275,
2648,
14,
2314,
459,
6765,
14,
1100,
418,
267,
20210,
8,
1100,
9,
267,
25476,
275,
488,
267,
862
] |
[
1898,
6171,
14260,
2752,
199,
3,
2900,
5924,
5702,
14,
199,
3,
199,
3,
259,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
1265,
1443,
199,
3,
259,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
2047,
1443,
3332,
199,
3,
259,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
260,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
259,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
259,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
2428,
199,
3,
259,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
1666,
314,
199,
3,
259,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
4204,
199,
3,
259,
1334,
314,
844,
14,
421,
199,
646,
25798,
199,
646,
25798,
14,
1018,
465,
1279,
266,
1812,
199,
504,
11258,
63,
888,
492,
4810,
199,
504,
11258,
63,
793,
492,
943,
465,
2050,
199,
646,
3816,
199,
504,
14568,
492,
3178,
199,
199,
504,
5913,
14,
1246,
14,
8512,
14,
3357,
14,
9482,
14,
86,
19,
492,
8261,
63,
7642,
465,
4177,
199,
504,
5913,
14,
1246,
14,
8512,
492,
5478,
199,
504,
5913,
14,
1246,
14,
8512,
492,
12464,
199,
504,
5913,
14,
1246,
492,
6411,
199,
504,
5913,
492,
1067,
465,
5913,
63,
1100,
199,
504,
5913,
492,
1919,
199,
504,
5913,
14,
73,
1085,
78,
492,
485,
199,
504,
5913,
14,
73,
1085,
78,
492,
485,
906,
199,
646,
5913,
14,
1200,
199,
504,
5913,
492,
12132,
421,
199,
3103,
275,
4810,
14,
3103,
199,
3103,
14,
646,
63,
2992,
360,
4296,
63,
1200,
63,
8848,
297,
355,
283,
6765,
14,
1246,
14,
8512,
14,
3357,
14,
2828,
14,
736,
63,
4647,
63,
7642,
358,
199,
3103,
14,
646,
63,
2992,
360,
1180,
63,
10271,
63,
885,
63,
20490,
297,
355,
283,
6765,
14,
1246,
14,
8512,
14,
3357,
14,
2828,
14,
736,
63,
4647,
63,
7642,
358,
199,
3103,
14,
646,
63,
2992,
360,
10271,
63,
885,
63,
4647,
63,
344,
297,
355,
283,
6765,
14,
1246,
14,
8512,
14,
3357,
14,
2828,
14,
736,
63,
4647,
63,
7642,
358,
199,
3103,
14,
646,
63,
2992,
360,
8848,
63,
7642,
297,
355,
283,
6765,
14,
1246,
14,
8512,
14,
3357,
14,
2828,
14,
736,
63,
4647,
63,
7642,
358,
421,
199,
12644,
275,
283,
736,
13,
4647,
13,
7642,
7,
199,
199,
18654,
1179,
275,
12132,
14,
18654,
1179,
199,
4947,
275,
2050,
14,
5572,
3460,
354,
3368,
199,
14204,
275,
5478,
14,
736,
63,
3357,
63,
2502,
1793,
8,
12644,
9,
421,
199,
318,
2784,
63,
807,
8,
1200,
304,
272,
327,
6944,
8,
24863,
706,
304,
11842,
12,
2784,
1077,
506,
376,
909,
12,
1314,
4293,
1172,
11492,
272,
327,
687,
8224,
436,
12850,
506,
4124,
4750,
402,
314,
3004,
14,
2165,
11604,
282,
272,
327,
849,
370,
664,
342,
23674,
9936,
370,
9617,
13,
912,
4124,
3004,
14,
272,
372,
2420,
344,
582,
2784,
14,
362,
480,
2580,
401,
488,
9,
503,
2784,
14,
362,
480,
344,
401,
488,
395,
717,
298,
10509,
582,
620,
8,
1200,
14,
362,
480,
10509,
401,
488,
1826,
717,
298,
1302,
582,
2784,
14,
362,
480,
1302,
401,
488,
6769,
421,
199,
533,
377,
287,
867,
4491,
7506,
8,
6508,
14,
7506,
304,
272,
347,
636,
826,
721,
277,
12,
2784,
63,
1246,
29,
403,
304,
267,
291,
14,
1200,
63,
1246,
275,
5913,
14,
1200,
14,
3735,
8,
2759,
63,
3185,
63,
1074,
29,
549,
9,
267,
291,
423,
885,
63,
7642,
275,
942,
339,
347,
485,
6635,
63,
885,
63,
7642,
8,
277,
304,
267,
291,
423,
885,
63,
7642,
275,
942,
267,
340,
6392,
14,
1180,
63,
10271,
63,
885,
63,
20490,
508,
298,
549,
582,
288,
862,
26,
355,
291,
423,
885,
63,
7642,
275,
291,
423,
362,
63,
885,
63,
7642,
342,
288,
871,
2186,
26,
355,
5051,
14,
1971,
1547,
906,
480,
4276,
370,
664,
849,
11759,
2237,
339,
347,
485,
362,
63,
885,
63,
7642,
8,
277,
304,
267,
2199,
63,
344,
275,
6392,
14,
10271,
63,
885,
63,
4647,
63,
344,
267,
4027,
275,
5913,
63,
1100,
14,
17679,
8,
751,
63,
344,
29,
403,
12,
5101,
2199,
63,
344,
29,
1715,
63,
344,
9,
267,
11759,
275,
1052,
267,
367,
302,
315,
291,
14,
1200,
63,
1246,
14,
362,
63,
452,
8,
3799,
304,
288,
11759,
59,
78,
459,
344,
6538,
275,
302,
459,
1302,
418,
267,
372,
9016,
344,
356,
1022,
12,
283,
1302,
356,
373,
93,
367,
1022,
12,
373,
315,
11759,
14,
4611,
5106,
339,
768,
5359,
14,
2062,
63,
2550,
30812,
272,
347,
1478,
8,
277,
12,
2648,
304,
267,
1067,
275,
2648,
14,
2314,
459,
6765,
14,
1100,
418,
267,
20210,
8,
1100,
9,
267,
11759,
275,
769,
8,
277,
14,
1200,
63,
1246,
14,
362,
63,
452,
8,
1100,
430,
267,
340,
440,
291,
423,
885,
63,
7642,
26,
288,
291,
423,
6635,
63,
885,
63,
7642,
342,
267,
11759,
14,
2880,
8,
277,
423,
885,
63,
7642,
9,
267,
372,
791,
7642,
356,
359,
1200,
63,
807,
8,
78,
9,
367,
302,
315,
11759,
9420,
339,
768,
5359,
14,
2062,
63,
2550,
8,
5188,
9,
272,
347,
2498,
8,
277,
12,
2648,
12,
1305,
304,
267,
1067,
275,
2648,
14,
2314,
459,
6765,
14,
1100,
418,
267,
20210,
8,
1100,
9,
267,
862,
26,
288,
2784,
275,
291,
14,
1200,
63,
1246,
14,
362,
8,
1100,
12,
1305,
9,
267,
871,
1919,
14,
4491,
4667,
26,
288,
1499,
275,
3824,
4491,
440,
1911,
531,
288,
746,
3178,
14,
26553,
8,
15228,
29,
1328,
9,
267,
372,
791,
1200,
356,
2784,
63,
807,
8,
1200,
6769,
339,
768,
5359,
14,
2062,
63,
2550,
1332,
13353,
12,
7901,
12,
21292,
430,
272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,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
diego-d5000/MisValesMd
|
env/lib/python2.7/site-packages/django/db/backends/postgresql_psycopg2/schema.py
|
1
|
3635
|
import psycopg2
from django.db.backends.base.schema import BaseDatabaseSchemaEditor
class DatabaseSchemaEditor(BaseDatabaseSchemaEditor):
sql_create_sequence = "CREATE SEQUENCE %(sequence)s"
sql_delete_sequence = "DROP SEQUENCE IF EXISTS %(sequence)s CASCADE"
sql_set_sequence_max = "SELECT setval('%(sequence)s', MAX(%(column)s)) FROM %(table)s"
sql_create_varchar_index = "CREATE INDEX %(name)s ON %(table)s (%(columns)s varchar_pattern_ops)%(extra)s"
sql_create_text_index = "CREATE INDEX %(name)s ON %(table)s (%(columns)s text_pattern_ops)%(extra)s"
def quote_value(self, value):
return psycopg2.extensions.adapt(value)
def _model_indexes_sql(self, model):
output = super(DatabaseSchemaEditor, self)._model_indexes_sql(model)
if not model._meta.managed or model._meta.proxy or model._meta.swapped:
return output
for field in model._meta.local_fields:
db_type = field.db_type(connection=self.connection)
if db_type is not None and (field.db_index or field.unique):
# Fields with database column types of `varchar` and `text` need
# a second index that specifies their operator class, which is
# needed when performing correct LIKE queries outside the
# C locale. See #12234.
if db_type.startswith('varchar'):
output.append(self._create_index_sql(
model, [field], suffix='_like', sql=self.sql_create_varchar_index))
elif db_type.startswith('text'):
output.append(self._create_index_sql(
model, [field], suffix='_like', sql=self.sql_create_text_index))
return output
def _alter_column_type_sql(self, table, column, type):
"""
Makes ALTER TYPE with SERIAL make sense.
"""
if type.lower() == "serial":
sequence_name = "%s_%s_seq" % (table, column)
return (
(
self.sql_alter_column_type % {
"column": self.quote_name(column),
"type": "integer",
},
[],
),
[
(
self.sql_delete_sequence % {
"sequence": sequence_name,
},
[],
),
(
self.sql_create_sequence % {
"sequence": sequence_name,
},
[],
),
(
self.sql_alter_column % {
"table": table,
"changes": self.sql_alter_column_default % {
"column": column,
"default": "nextval('%s')" % sequence_name,
}
},
[],
),
(
self.sql_set_sequence_max % {
"table": table,
"column": column,
"sequence": sequence_name,
},
[],
),
],
)
else:
return super(DatabaseSchemaEditor, self)._alter_column_type_sql(table, column, type)
|
mit
|
[
646,
15492,
18,
2999,
199,
504,
1639,
14,
697,
14,
7765,
14,
1095,
14,
3629,
492,
29103,
6700,
10423,
8065,
199,
533,
8692,
6700,
10423,
8,
1563,
7243,
6700,
10423,
304,
2958,
3875,
63,
981,
63,
4041,
275,
298,
8366,
31042,
2818,
4041,
9,
83,
2,
1128,
3875,
63,
1807,
63,
4041,
275,
298,
14764,
31042,
8036,
23875,
2818,
4041,
9,
83,
27751,
9947,
2,
1128,
3875,
63,
409,
63,
4041,
63,
988,
275,
298,
4859,
663,
637,
24713,
4041,
9,
83,
297,
9141,
12473,
2301,
9,
83,
430,
4442,
2818,
1224,
9,
83,
2,
1128,
3875,
63,
981,
63,
25545,
63,
1080,
275,
298,
8366,
17055,
2818,
354,
9,
83,
5258,
2818,
1224,
9,
83,
17753,
3406,
9,
83,
31044,
63,
3401,
63,
1483,
9,
2840,
2911,
9,
83,
2,
1128,
3875,
63,
981,
63,
505,
63,
1080,
275,
298,
8366,
17055,
2818,
354,
9,
83,
5258,
2818,
1224,
9,
83,
17753,
3406,
9,
83,
1318,
63,
3401,
63,
1483,
9,
2840,
2911,
9,
83,
2,
2958,
347,
6313,
63,
585,
8,
277,
12,
574,
304,
1039,
372,
15492,
18,
14,
5359,
14,
19609,
8,
585,
9,
2958,
347,
485,
1238,
63,
10116,
63,
3009,
8,
277,
12,
1402,
304,
1039,
1072,
275,
1613,
8,
7243,
6700,
10423,
12,
291,
10445,
1238,
63,
10116,
63,
3009,
8,
1238,
9,
1039,
340,
440,
1402,
423,
2024,
14,
11122,
503,
1402,
423,
2024,
14,
3280,
503,
1402,
423,
2024,
14,
28989,
26,
1675,
372,
1072,
4341,
367,
901,
315,
1402,
423,
2024,
14,
1832,
63,
955,
26,
1675,
1592,
63,
466,
275,
901,
14,
697,
63,
466,
8,
2105,
29,
277,
14,
2105,
9,
1675,
340,
1592,
63,
466,
365,
440,
488,
436,
334,
698,
14,
697,
63,
1080,
503,
901,
14,
3235,
304,
2628,
327,
16424,
543,
3050,
2763,
2943,
402,
658,
25545,
64,
436,
658,
505,
64,
1929,
2628,
327,
282,
3499,
1478,
626,
9314,
3932,
4182,
1021,
12,
1314,
365,
2628,
327,
4346,
1380,
19203,
3211,
29369,
9212,
9682,
314,
2628,
327,
445,
5867,
14,
1666,
327,
713,
5533,
14,
2628,
340,
1592,
63,
466,
14,
2460,
360,
25545,
735,
4906,
1072,
14,
740,
8,
277,
423,
981,
63,
1080,
63,
3009,
8,
8282,
1402,
12,
359,
698,
467,
4739,
17574,
2930,
297,
3875,
29,
277,
14,
3009,
63,
981,
63,
25545,
63,
1080,
430,
2628,
916,
1592,
63,
466,
14,
2460,
360,
505,
735,
4906,
1072,
14,
740,
8,
277,
423,
981,
63,
1080,
63,
3009,
8,
8282,
1402,
12,
359,
698,
467,
4739,
17574,
2930,
297,
3875,
29,
277,
14,
3009,
63,
981,
63,
505,
63,
1080,
430,
1039,
372,
1072,
2958,
347,
485,
11858,
63,
2301,
63,
466,
63,
3009,
8,
277,
12,
1817,
12,
2763,
12,
730,
304,
1039,
408,
1039,
23365,
12112,
1157,
11511,
543,
7017,
4938,
1852,
12249,
14,
1039,
408,
1039,
340,
730,
14,
2325,
342,
508,
298,
2171,
582,
1675,
3414,
63,
354,
275,
2071,
83,
4970,
83,
63,
3610,
2,
450,
334,
1224,
12,
2763,
9,
1675,
372,
334,
2628,
334,
4906,
291,
14,
3009,
63,
11858,
63,
2301,
63,
466,
450,
469,
8282,
298,
2301,
582,
291,
14,
3513,
63,
354,
8,
2301,
395,
8282,
298,
466,
582,
298,
4115,
401,
4906,
1660,
4906,
990,
2628,
2318,
2628,
359,
4906,
334,
8282,
291,
14,
3009,
63,
1807,
63,
4041,
450,
469,
15372,
298,
4041,
582,
3414,
63,
354,
12,
8282,
1660,
8282,
990,
4906,
2318,
4906,
334,
8282,
291,
14,
3009,
63,
981,
63,
4041,
450,
469,
15372,
298,
4041,
582,
3414,
63,
354,
12,
8282,
1660,
8282,
990,
4906,
2318,
4906,
334,
8282,
291,
14,
3009,
63,
11858,
63,
2301,
450,
469,
15372,
298,
1224,
582,
1817,
12,
15372,
298,
6627,
582,
291,
14,
3009,
63,
11858,
63,
2301,
63,
885,
450,
469,
23606,
298,
2301,
582,
2763,
12,
23606,
298,
885,
582,
298,
2184,
637,
3508,
83,
19124,
450,
3414,
63,
354,
12,
15372,
789,
8282,
1660,
8282,
990,
4906,
2318,
4906,
334,
8282,
291,
14,
3009,
63,
409,
63,
4041,
63,
988,
450,
469,
15372,
298,
1224,
582,
1817,
12,
15372,
298,
2301,
582,
2763,
12,
15372,
298,
4041,
582,
3414,
63,
354,
12,
8282,
1660,
8282,
990,
4906,
2318,
2628,
2156,
1675,
776,
1039,
587,
26,
1675,
372,
1613,
8,
7243,
6700,
10423,
12,
291,
10445,
11858,
63,
2301,
63,
466,
63,
3009,
8,
1224,
12,
2763,
12,
730,
9,
1223,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
15492,
18,
2999,
199,
504,
1639,
14,
697,
14,
7765,
14,
1095,
14,
3629,
492,
29103,
6700,
10423,
8065,
199,
533,
8692,
6700,
10423,
8,
1563,
7243,
6700,
10423,
304,
2958,
3875,
63,
981,
63,
4041,
275,
298,
8366,
31042,
2818,
4041,
9,
83,
2,
1128,
3875,
63,
1807,
63,
4041,
275,
298,
14764,
31042,
8036,
23875,
2818,
4041,
9,
83,
27751,
9947,
2,
1128,
3875,
63,
409,
63,
4041,
63,
988,
275,
298,
4859,
663,
637,
24713,
4041,
9,
83,
297,
9141,
12473,
2301,
9,
83,
430,
4442,
2818,
1224,
9,
83,
2,
1128,
3875,
63,
981,
63,
25545,
63,
1080,
275,
298,
8366,
17055,
2818,
354,
9,
83,
5258,
2818,
1224,
9,
83,
17753,
3406,
9,
83,
31044,
63,
3401,
63,
1483,
9,
2840,
2911,
9,
83,
2,
1128,
3875,
63,
981,
63,
505,
63,
1080,
275,
298,
8366,
17055,
2818,
354,
9,
83,
5258,
2818,
1224,
9,
83,
17753,
3406,
9,
83,
1318,
63,
3401,
63,
1483,
9,
2840,
2911,
9,
83,
2,
2958,
347,
6313,
63,
585,
8,
277,
12,
574,
304,
1039,
372,
15492,
18,
14,
5359,
14,
19609,
8,
585,
9,
2958,
347,
485,
1238,
63,
10116,
63,
3009,
8,
277,
12,
1402,
304,
1039,
1072,
275,
1613,
8,
7243,
6700,
10423,
12,
291,
10445,
1238,
63,
10116,
63,
3009,
8,
1238,
9,
1039,
340,
440,
1402,
423,
2024,
14,
11122,
503,
1402,
423,
2024,
14,
3280,
503,
1402,
423,
2024,
14,
28989,
26,
1675,
372,
1072,
4341,
367,
901,
315,
1402,
423,
2024,
14,
1832,
63,
955,
26,
1675,
1592,
63,
466,
275,
901,
14,
697,
63,
466,
8,
2105,
29,
277,
14,
2105,
9,
1675,
340,
1592,
63,
466,
365,
440,
488,
436,
334,
698,
14,
697,
63,
1080,
503,
901,
14,
3235,
304,
2628,
327,
16424,
543,
3050,
2763,
2943,
402,
658,
25545,
64,
436,
658,
505,
64,
1929,
2628,
327,
282,
3499,
1478,
626,
9314,
3932,
4182,
1021,
12,
1314,
365,
2628,
327,
4346,
1380,
19203,
3211,
29369,
9212,
9682,
314,
2628,
327,
445,
5867,
14,
1666,
327,
713,
5533,
14,
2628,
340,
1592,
63,
466,
14,
2460,
360,
25545,
735,
4906,
1072,
14,
740,
8,
277,
423,
981,
63,
1080,
63,
3009,
8,
8282,
1402,
12,
359,
698,
467,
4739,
17574,
2930,
297,
3875,
29,
277,
14,
3009,
63,
981,
63,
25545,
63,
1080,
430,
2628,
916,
1592,
63,
466,
14,
2460,
360,
505,
735,
4906,
1072,
14,
740,
8,
277,
423,
981,
63,
1080,
63,
3009,
8,
8282,
1402,
12,
359,
698,
467,
4739,
17574,
2930,
297,
3875,
29,
277,
14,
3009,
63,
981,
63,
505,
63,
1080,
430,
1039,
372,
1072,
2958,
347,
485,
11858,
63,
2301,
63,
466,
63,
3009,
8,
277,
12,
1817,
12,
2763,
12,
730,
304,
1039,
408,
1039,
23365,
12112,
1157,
11511,
543,
7017,
4938,
1852,
12249,
14,
1039,
408,
1039,
340,
730,
14,
2325,
342,
508,
298,
2171,
582,
1675,
3414,
63,
354,
275,
2071,
83,
4970,
83,
63,
3610,
2,
450,
334,
1224,
12,
2763,
9,
1675,
372,
334,
2628,
334,
4906,
291,
14,
3009,
63,
11858,
63,
2301,
63,
466,
450,
469,
8282,
298,
2301,
582,
291,
14,
3513,
63,
354,
8,
2301,
395,
8282,
298,
466,
582,
298,
4115,
401,
4906,
1660,
4906,
990,
2628,
2318,
2628,
359,
4906,
334,
8282,
291,
14,
3009,
63,
1807,
63,
4041,
450,
469,
15372,
298,
4041,
582,
3414,
63,
354,
12,
8282,
1660,
8282,
990,
4906,
2318,
4906,
334,
8282,
291,
14,
3009,
63,
981,
63,
4041,
450,
469,
15372,
298,
4041,
582,
3414,
63,
354,
12,
8282,
1660,
8282,
990,
4906,
2318,
4906,
334,
8282,
291,
14,
3009,
63,
11858,
63,
2301,
450,
469,
15372,
298,
1224,
582,
1817,
12,
15372,
298,
6627,
582,
291,
14,
3009,
63,
11858,
63,
2301,
63,
885,
450,
469,
23606,
298,
2301,
582,
2763,
12,
23606,
298,
885,
582,
298,
2184,
637,
3508,
83,
19124,
450,
3414,
63,
354,
12,
15372,
789,
8282,
1660,
8282,
990,
4906,
2318,
4906,
334,
8282,
291,
14,
3009,
63,
409,
63,
4041,
63,
988,
450,
469,
15372,
298,
1224,
582,
1817,
12,
15372,
298,
2301,
582,
2763,
12,
15372,
298,
4041,
582,
3414,
63,
354,
12,
8282,
1660,
8282,
990,
4906,
2318,
2628,
2156,
1675,
776,
1039,
587,
26,
1675,
372,
1613,
8,
7243,
6700,
10423,
12,
291,
10445,
11858,
63,
2301,
63,
466,
63,
3009,
8,
1224,
12,
2763,
12,
730,
9,
1223,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
espadrine/opera
|
chromium/src/third_party/python_26/Lib/copy_reg.py
|
442
|
6800
|
"""Helper to provide extensibility for pickle/cPickle.
This is only useful to add pickle support for extension types defined in
C, not for instances of user-defined classes.
"""
from types import ClassType as _ClassType
__all__ = ["pickle", "constructor",
"add_extension", "remove_extension", "clear_extension_cache"]
dispatch_table = {}
def pickle(ob_type, pickle_function, constructor_ob=None):
if type(ob_type) is _ClassType:
raise TypeError("copy_reg is not intended for use with classes")
if not hasattr(pickle_function, '__call__'):
raise TypeError("reduction functions must be callable")
dispatch_table[ob_type] = pickle_function
# The constructor_ob function is a vestige of safe for unpickling.
# There is no reason for the caller to pass it anymore.
if constructor_ob is not None:
constructor(constructor_ob)
def constructor(object):
if not hasattr(object, '__call__'):
raise TypeError("constructors must be callable")
# Example: provide pickling support for complex numbers.
try:
complex
except NameError:
pass
else:
def pickle_complex(c):
return complex, (c.real, c.imag)
pickle(complex, pickle_complex, complex)
# Support for pickling new-style objects
def _reconstructor(cls, base, state):
if base is object:
obj = object.__new__(cls)
else:
obj = base.__new__(cls, state)
if base.__init__ != object.__init__:
base.__init__(obj, state)
return obj
_HEAPTYPE = 1<<9
# Python code for object.__reduce_ex__ for protocols 0 and 1
def _reduce_ex(self, proto):
assert proto < 2
for base in self.__class__.__mro__:
if hasattr(base, '__flags__') and not base.__flags__ & _HEAPTYPE:
break
else:
base = object # not really reachable
if base is object:
state = None
else:
if base is self.__class__:
raise TypeError, "can't pickle %s objects" % base.__name__
state = base(self)
args = (self.__class__, base, state)
try:
getstate = self.__getstate__
except AttributeError:
if getattr(self, "__slots__", None):
raise TypeError("a class that defines __slots__ without "
"defining __getstate__ cannot be pickled")
try:
dict = self.__dict__
except AttributeError:
dict = None
else:
dict = getstate()
if dict:
return _reconstructor, args, dict
else:
return _reconstructor, args
# Helper for __reduce_ex__ protocol 2
def __newobj__(cls, *args):
return cls.__new__(cls, *args)
def _slotnames(cls):
"""Return a list of slot names for a given class.
This needs to find slots defined by the class and its bases, so we
can't simply return the __slots__ attribute. We must walk down
the Method Resolution Order and concatenate the __slots__ of each
class found there. (This assumes classes don't modify their
__slots__ attribute to misrepresent their slots after the class is
defined.)
"""
# Get the value from a cache in the class if possible
names = cls.__dict__.get("__slotnames__")
if names is not None:
return names
# Not cached -- calculate the value
names = []
if not hasattr(cls, "__slots__"):
# This class has no slots
pass
else:
# Slots found -- gather slot names from all base classes
for c in cls.__mro__:
if "__slots__" in c.__dict__:
slots = c.__dict__['__slots__']
# if class has a single slot, it can be given as a string
if isinstance(slots, basestring):
slots = (slots,)
for name in slots:
# special descriptors
if name in ("__dict__", "__weakref__"):
continue
# mangled names
elif name.startswith('__') and not name.endswith('__'):
names.append('_%s%s' % (c.__name__, name))
else:
names.append(name)
# Cache the outcome in the class if at all possible
try:
cls.__slotnames__ = names
except:
pass # But don't die if we can't
return names
# A registry of extension codes. This is an ad-hoc compression
# mechanism. Whenever a global reference to <module>, <name> is about
# to be pickled, the (<module>, <name>) tuple is looked up here to see
# if it is a registered extension code for it. Extension codes are
# universal, so that the meaning of a pickle does not depend on
# context. (There are also some codes reserved for local use that
# don't have this restriction.) Codes are positive ints; 0 is
# reserved.
_extension_registry = {} # key -> code
_inverted_registry = {} # code -> key
_extension_cache = {} # code -> object
# Don't ever rebind those names: cPickle grabs a reference to them when
# it's initialized, and won't see a rebinding.
def add_extension(module, name, code):
"""Register an extension code."""
code = int(code)
if not 1 <= code <= 0x7fffffff:
raise ValueError, "code out of range"
key = (module, name)
if (_extension_registry.get(key) == code and
_inverted_registry.get(code) == key):
return # Redundant registrations are benign
if key in _extension_registry:
raise ValueError("key %s is already registered with code %s" %
(key, _extension_registry[key]))
if code in _inverted_registry:
raise ValueError("code %s is already in use for key %s" %
(code, _inverted_registry[code]))
_extension_registry[key] = code
_inverted_registry[code] = key
def remove_extension(module, name, code):
"""Unregister an extension code. For testing only."""
key = (module, name)
if (_extension_registry.get(key) != code or
_inverted_registry.get(code) != key):
raise ValueError("key %s is not registered with code %s" %
(key, code))
del _extension_registry[key]
del _inverted_registry[code]
if code in _extension_cache:
del _extension_cache[code]
def clear_extension_cache():
_extension_cache.clear()
# Standard extension code assignments
# Reserved ranges
# First Last Count Purpose
# 1 127 127 Reserved for Python standard library
# 128 191 64 Reserved for Zope
# 192 239 48 Reserved for 3rd parties
# 240 255 16 Reserved for private use (will never be assigned)
# 256 Inf Inf Reserved for future assignment
# Extension codes are assigned by the Python Software Foundation.
|
bsd-3-clause
|
[
624,
4433,
370,
5647,
2178,
4783,
367,
5927,
15,
67,
12755,
14,
199,
199,
2765,
365,
1454,
2997,
370,
1050,
5927,
2291,
367,
3329,
2943,
3247,
315,
199,
35,
12,
440,
367,
4454,
402,
922,
13,
4037,
3992,
14,
199,
624,
199,
199,
504,
2943,
492,
8089,
804,
465,
485,
31165,
199,
199,
363,
452,
363,
275,
2097,
8092,
401,
298,
1880,
401,
1779,
298,
525,
63,
3435,
401,
298,
2168,
63,
3435,
401,
298,
3584,
63,
3435,
63,
1637,
937,
199,
199,
6052,
63,
1224,
275,
1052,
199,
199,
318,
5927,
8,
2873,
63,
466,
12,
5927,
63,
1593,
12,
3787,
63,
2873,
29,
403,
304,
272,
340,
730,
8,
2873,
63,
466,
9,
365,
485,
31165,
26,
267,
746,
3146,
480,
1574,
63,
1135,
365,
440,
11619,
367,
675,
543,
3992,
531,
339,
340,
440,
2688,
8,
8092,
63,
1593,
12,
2560,
1250,
12168,
267,
746,
3146,
480,
22508,
3423,
1471,
506,
4550,
531,
272,
7634,
63,
1224,
59,
2873,
63,
466,
61,
275,
5927,
63,
1593,
339,
327,
710,
3787,
63,
2873,
805,
365,
282,
373,
597,
73,
303,
402,
5048,
367,
625,
24773,
14,
272,
327,
6006,
365,
949,
4499,
367,
314,
8025,
370,
986,
652,
20827,
14,
272,
340,
3787,
63,
2873,
365,
440,
488,
26,
267,
3787,
8,
1880,
63,
2873,
9,
199,
199,
318,
3787,
8,
785,
304,
272,
340,
440,
2688,
8,
785,
12,
2560,
1250,
12168,
267,
746,
3146,
480,
1880,
83,
1471,
506,
4550,
531,
199,
199,
3,
5679,
26,
5647,
24394,
2291,
367,
6114,
5579,
14,
199,
199,
893,
26,
272,
6114,
199,
2590,
12746,
26,
272,
986,
199,
2836,
26,
339,
347,
5927,
63,
5254,
8,
67,
304,
267,
372,
6114,
12,
334,
67,
14,
3093,
12,
286,
14,
14688,
9,
339,
5927,
8,
5254,
12,
5927,
63,
5254,
12,
6114,
9,
199,
199,
3,
12502,
367,
24394,
892,
13,
2487,
2251,
199,
199,
318,
485,
264,
1880,
8,
1886,
12,
1300,
12,
1174,
304,
272,
340,
1300,
365,
909,
26,
267,
1559,
275,
909,
855,
1222,
721,
1886,
9,
272,
587,
26,
267,
1559,
275,
1300,
855,
1222,
721,
1886,
12,
1174,
9,
267,
340,
1300,
855,
826,
363,
1137,
909,
855,
826,
10651,
288,
1300,
855,
826,
721,
1113,
12,
1174,
9,
272,
372,
1559,
199,
199,
63,
23707,
2711,
275,
413,
8999,
25,
199,
199,
3,
2018,
1233,
367,
909,
855,
5270,
63,
476,
363,
367,
19230,
378,
436,
413,
199,
199,
318,
485,
5270,
63,
476,
8,
277,
12,
4104,
304,
272,
702,
4104,
665,
499,
272,
367,
1300,
315,
291,
855,
533,
4914,
17335,
10651,
267,
340,
2688,
8,
1095,
12,
2560,
2469,
13766,
436,
440,
1300,
855,
2469,
363,
1253,
485,
23707,
2711,
26,
288,
2059,
272,
587,
26,
267,
1300,
275,
909,
327,
440,
7710,
29542,
272,
340,
1300,
365,
909,
26,
267,
1174,
275,
488,
272,
587,
26,
267,
340,
1300,
365,
291,
855,
533,
10651,
288,
746,
3146,
12,
298,
2425,
1133,
5927,
450,
83,
2251,
2,
450,
1300,
855,
354,
363,
267,
1174,
275,
1300,
8,
277,
9,
272,
1249,
275,
334,
277,
855,
533,
3108,
1300,
12,
1174,
9,
272,
862,
26,
267,
664,
929,
275,
291,
855,
16011,
363,
272,
871,
4281,
26,
267,
340,
2519,
8,
277,
12,
4396,
7257,
13915,
488,
304,
288,
746,
3146,
480,
65,
1021,
626,
7890,
636,
7257,
363,
1928,
298,
1169,
298,
318,
7969,
636,
16011,
363,
3913,
506,
18731,
531,
267,
862,
26,
288,
1211,
275,
291,
855,
807,
363,
267,
871,
4281,
26,
288,
1211,
275,
488,
272,
587,
26,
267,
1211,
275,
664,
929,
342,
272,
340,
1211,
26,
267,
372,
485,
264,
1880,
12,
1249,
12,
1211,
272,
587,
26,
267,
372,
485,
264,
1880,
12,
1249,
199,
199,
3,
11642,
367,
636,
5270,
63,
476,
363,
4113,
499,
199,
199,
318,
636,
1222,
1113,
721,
1886,
12,
627,
589,
304,
272,
372,
843,
855,
1222,
721,
1886,
12,
627,
589,
9,
199,
199,
318,
485,
7998,
1247,
8,
1886,
304,
272,
408,
1767,
282,
769,
402,
9348,
1561,
367,
282,
1627,
1021,
14,
339,
961,
4839,
370,
2342,
14319,
3247,
701,
314,
1021,
436,
2399,
9768,
12,
880,
781,
272,
883,
1133,
9329,
372,
314,
636,
7257,
363,
2225,
14,
221,
2136,
1471,
12778,
3224,
272,
314,
9075,
3591,
3347,
9240,
436,
24788,
314,
636,
7257,
363,
402,
1924,
272,
1021,
1911,
2337,
14,
221,
334,
2765,
15194,
3992,
2793,
1133,
2811,
3932,
272,
636,
7257,
363,
2225,
370,
3201,
13063,
3932,
14319,
2410,
314,
1021,
365,
272,
3247,
4959,
272,
408,
339,
327,
2372,
314,
574,
687,
282,
2581,
315,
314,
1021,
340,
3962,
272,
1561,
275,
843,
855,
807,
4343,
362,
16232,
7998,
1247,
18617,
272,
340,
1561,
365,
440,
488,
26,
267,
372,
1561,
339,
327,
2832,
6328,
1553,
8671,
314,
574,
272,
1561,
275,
942,
272,
340,
440,
2688,
8,
1886,
12,
4396,
7257,
363,
2349,
267,
327,
961,
1021,
965,
949,
14319,
267,
986,
272,
587,
26,
267,
327,
428,
4555,
1911,
1553,
13082,
9348,
1561,
687,
1006,
1300,
3992,
267,
367,
286,
315,
843,
855,
17335,
10651,
288,
340,
4396,
7257,
16526,
315,
286,
855,
807,
10651,
355,
14319,
275,
286,
855,
807,
363,
13742,
7257,
17501,
355,
327,
340,
1021,
965,
282,
2849,
9348,
12,
652,
883,
506,
1627,
465,
282,
1059,
355,
340,
1228,
8,
7257,
12,
7116,
304,
490,
14319,
275,
334,
7257,
4258,
355,
367,
536,
315,
14319,
26,
490,
327,
4539,
15428,
490,
340,
536,
315,
1689,
363,
807,
13915,
4396,
21330,
363,
2349,
717,
1980,
490,
327,
333,
22183,
1561,
490,
916,
536,
14,
2460,
10714,
358,
436,
440,
536,
14,
4130,
10714,
735,
717,
1561,
14,
740,
360,
4970,
83,
5,
83,
7,
450,
334,
67,
855,
354,
3108,
536,
430,
490,
587,
26,
717,
1561,
14,
740,
8,
354,
9,
339,
327,
11977,
314,
15955,
315,
314,
1021,
340,
737,
1006,
3962,
272,
862,
26,
267,
843,
855,
7998,
1247,
363,
275,
1561,
272,
871,
26,
267,
986,
327,
11017,
2793,
1133,
18833,
340,
781,
883,
1133,
339,
372,
1561,
199,
199,
3,
437,
7086,
402,
3329,
9479,
14,
221,
961,
365,
376,
1503
] |
[
4433,
370,
5647,
2178,
4783,
367,
5927,
15,
67,
12755,
14,
199,
199,
2765,
365,
1454,
2997,
370,
1050,
5927,
2291,
367,
3329,
2943,
3247,
315,
199,
35,
12,
440,
367,
4454,
402,
922,
13,
4037,
3992,
14,
199,
624,
199,
199,
504,
2943,
492,
8089,
804,
465,
485,
31165,
199,
199,
363,
452,
363,
275,
2097,
8092,
401,
298,
1880,
401,
1779,
298,
525,
63,
3435,
401,
298,
2168,
63,
3435,
401,
298,
3584,
63,
3435,
63,
1637,
937,
199,
199,
6052,
63,
1224,
275,
1052,
199,
199,
318,
5927,
8,
2873,
63,
466,
12,
5927,
63,
1593,
12,
3787,
63,
2873,
29,
403,
304,
272,
340,
730,
8,
2873,
63,
466,
9,
365,
485,
31165,
26,
267,
746,
3146,
480,
1574,
63,
1135,
365,
440,
11619,
367,
675,
543,
3992,
531,
339,
340,
440,
2688,
8,
8092,
63,
1593,
12,
2560,
1250,
12168,
267,
746,
3146,
480,
22508,
3423,
1471,
506,
4550,
531,
272,
7634,
63,
1224,
59,
2873,
63,
466,
61,
275,
5927,
63,
1593,
339,
327,
710,
3787,
63,
2873,
805,
365,
282,
373,
597,
73,
303,
402,
5048,
367,
625,
24773,
14,
272,
327,
6006,
365,
949,
4499,
367,
314,
8025,
370,
986,
652,
20827,
14,
272,
340,
3787,
63,
2873,
365,
440,
488,
26,
267,
3787,
8,
1880,
63,
2873,
9,
199,
199,
318,
3787,
8,
785,
304,
272,
340,
440,
2688,
8,
785,
12,
2560,
1250,
12168,
267,
746,
3146,
480,
1880,
83,
1471,
506,
4550,
531,
199,
199,
3,
5679,
26,
5647,
24394,
2291,
367,
6114,
5579,
14,
199,
199,
893,
26,
272,
6114,
199,
2590,
12746,
26,
272,
986,
199,
2836,
26,
339,
347,
5927,
63,
5254,
8,
67,
304,
267,
372,
6114,
12,
334,
67,
14,
3093,
12,
286,
14,
14688,
9,
339,
5927,
8,
5254,
12,
5927,
63,
5254,
12,
6114,
9,
199,
199,
3,
12502,
367,
24394,
892,
13,
2487,
2251,
199,
199,
318,
485,
264,
1880,
8,
1886,
12,
1300,
12,
1174,
304,
272,
340,
1300,
365,
909,
26,
267,
1559,
275,
909,
855,
1222,
721,
1886,
9,
272,
587,
26,
267,
1559,
275,
1300,
855,
1222,
721,
1886,
12,
1174,
9,
267,
340,
1300,
855,
826,
363,
1137,
909,
855,
826,
10651,
288,
1300,
855,
826,
721,
1113,
12,
1174,
9,
272,
372,
1559,
199,
199,
63,
23707,
2711,
275,
413,
8999,
25,
199,
199,
3,
2018,
1233,
367,
909,
855,
5270,
63,
476,
363,
367,
19230,
378,
436,
413,
199,
199,
318,
485,
5270,
63,
476,
8,
277,
12,
4104,
304,
272,
702,
4104,
665,
499,
272,
367,
1300,
315,
291,
855,
533,
4914,
17335,
10651,
267,
340,
2688,
8,
1095,
12,
2560,
2469,
13766,
436,
440,
1300,
855,
2469,
363,
1253,
485,
23707,
2711,
26,
288,
2059,
272,
587,
26,
267,
1300,
275,
909,
327,
440,
7710,
29542,
272,
340,
1300,
365,
909,
26,
267,
1174,
275,
488,
272,
587,
26,
267,
340,
1300,
365,
291,
855,
533,
10651,
288,
746,
3146,
12,
298,
2425,
1133,
5927,
450,
83,
2251,
2,
450,
1300,
855,
354,
363,
267,
1174,
275,
1300,
8,
277,
9,
272,
1249,
275,
334,
277,
855,
533,
3108,
1300,
12,
1174,
9,
272,
862,
26,
267,
664,
929,
275,
291,
855,
16011,
363,
272,
871,
4281,
26,
267,
340,
2519,
8,
277,
12,
4396,
7257,
13915,
488,
304,
288,
746,
3146,
480,
65,
1021,
626,
7890,
636,
7257,
363,
1928,
298,
1169,
298,
318,
7969,
636,
16011,
363,
3913,
506,
18731,
531,
267,
862,
26,
288,
1211,
275,
291,
855,
807,
363,
267,
871,
4281,
26,
288,
1211,
275,
488,
272,
587,
26,
267,
1211,
275,
664,
929,
342,
272,
340,
1211,
26,
267,
372,
485,
264,
1880,
12,
1249,
12,
1211,
272,
587,
26,
267,
372,
485,
264,
1880,
12,
1249,
199,
199,
3,
11642,
367,
636,
5270,
63,
476,
363,
4113,
499,
199,
199,
318,
636,
1222,
1113,
721,
1886,
12,
627,
589,
304,
272,
372,
843,
855,
1222,
721,
1886,
12,
627,
589,
9,
199,
199,
318,
485,
7998,
1247,
8,
1886,
304,
272,
408,
1767,
282,
769,
402,
9348,
1561,
367,
282,
1627,
1021,
14,
339,
961,
4839,
370,
2342,
14319,
3247,
701,
314,
1021,
436,
2399,
9768,
12,
880,
781,
272,
883,
1133,
9329,
372,
314,
636,
7257,
363,
2225,
14,
221,
2136,
1471,
12778,
3224,
272,
314,
9075,
3591,
3347,
9240,
436,
24788,
314,
636,
7257,
363,
402,
1924,
272,
1021,
1911,
2337,
14,
221,
334,
2765,
15194,
3992,
2793,
1133,
2811,
3932,
272,
636,
7257,
363,
2225,
370,
3201,
13063,
3932,
14319,
2410,
314,
1021,
365,
272,
3247,
4959,
272,
408,
339,
327,
2372,
314,
574,
687,
282,
2581,
315,
314,
1021,
340,
3962,
272,
1561,
275,
843,
855,
807,
4343,
362,
16232,
7998,
1247,
18617,
272,
340,
1561,
365,
440,
488,
26,
267,
372,
1561,
339,
327,
2832,
6328,
1553,
8671,
314,
574,
272,
1561,
275,
942,
272,
340,
440,
2688,
8,
1886,
12,
4396,
7257,
363,
2349,
267,
327,
961,
1021,
965,
949,
14319,
267,
986,
272,
587,
26,
267,
327,
428,
4555,
1911,
1553,
13082,
9348,
1561,
687,
1006,
1300,
3992,
267,
367,
286,
315,
843,
855,
17335,
10651,
288,
340,
4396,
7257,
16526,
315,
286,
855,
807,
10651,
355,
14319,
275,
286,
855,
807,
363,
13742,
7257,
17501,
355,
327,
340,
1021,
965,
282,
2849,
9348,
12,
652,
883,
506,
1627,
465,
282,
1059,
355,
340,
1228,
8,
7257,
12,
7116,
304,
490,
14319,
275,
334,
7257,
4258,
355,
367,
536,
315,
14319,
26,
490,
327,
4539,
15428,
490,
340,
536,
315,
1689,
363,
807,
13915,
4396,
21330,
363,
2349,
717,
1980,
490,
327,
333,
22183,
1561,
490,
916,
536,
14,
2460,
10714,
358,
436,
440,
536,
14,
4130,
10714,
735,
717,
1561,
14,
740,
360,
4970,
83,
5,
83,
7,
450,
334,
67,
855,
354,
3108,
536,
430,
490,
587,
26,
717,
1561,
14,
740,
8,
354,
9,
339,
327,
11977,
314,
15955,
315,
314,
1021,
340,
737,
1006,
3962,
272,
862,
26,
267,
843,
855,
7998,
1247,
363,
275,
1561,
272,
871,
26,
267,
986,
327,
11017,
2793,
1133,
18833,
340,
781,
883,
1133,
339,
372,
1561,
199,
199,
3,
437,
7086,
402,
3329,
9479,
14,
221,
961,
365,
376,
1503,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
woshilapin/cjdns
|
node_build/dependencies/libuv/build/gyp/test/lib/TestGyp.py
|
46
|
50586
|
# Copyright (c) 2012 Google Inc. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""
TestGyp.py: a testing framework for GYP integration tests.
"""
import collections
from contextlib import contextmanager
import itertools
import os
import random
import re
import shutil
import stat
import subprocess
import sys
import tempfile
import time
import TestCmd
import TestCommon
from TestCommon import __all__
__all__.extend([
'TestGyp',
])
def remove_debug_line_numbers(contents):
"""Function to remove the line numbers from the debug output
of gyp and thus reduce the extreme fragility of the stdout
comparison tests.
"""
lines = contents.splitlines()
# split each line on ":"
lines = [l.split(":", 3) for l in lines]
# join each line back together while ignoring the
# 3rd column which is the line number
lines = [len(l) > 3 and ":".join(l[3:]) or l for l in lines]
return "\n".join(lines)
def match_modulo_line_numbers(contents_a, contents_b):
"""File contents matcher that ignores line numbers."""
contents_a = remove_debug_line_numbers(contents_a)
contents_b = remove_debug_line_numbers(contents_b)
return TestCommon.match_exact(contents_a, contents_b)
@contextmanager
def LocalEnv(local_env):
"""Context manager to provide a local OS environment."""
old_env = os.environ.copy()
os.environ.update(local_env)
try:
yield
finally:
os.environ.clear()
os.environ.update(old_env)
class TestGypBase(TestCommon.TestCommon):
"""
Class for controlling end-to-end tests of gyp generators.
Instantiating this class will create a temporary directory and
arrange for its destruction (via the TestCmd superclass) and
copy all of the non-gyptest files in the directory hierarchy of the
executing script.
The default behavior is to test the 'gyp' or 'gyp.bat' file in the
current directory. An alternative may be specified explicitly on
instantiation, or by setting the TESTGYP_GYP environment variable.
This class should be subclassed for each supported gyp generator
(format). Various abstract methods below define calling signatures
used by the test scripts to invoke builds on the generated build
configuration and to run executables generated by those builds.
"""
formats = []
build_tool = None
build_tool_list = []
_exe = TestCommon.exe_suffix
_obj = TestCommon.obj_suffix
shobj_ = TestCommon.shobj_prefix
_shobj = TestCommon.shobj_suffix
lib_ = TestCommon.lib_prefix
_lib = TestCommon.lib_suffix
dll_ = TestCommon.dll_prefix
_dll = TestCommon.dll_suffix
# Constants to represent different targets.
ALL = '__all__'
DEFAULT = '__default__'
# Constants for different target types.
EXECUTABLE = '__executable__'
STATIC_LIB = '__static_lib__'
SHARED_LIB = '__shared_lib__'
def __init__(self, gyp=None, *args, **kw):
self.origin_cwd = os.path.abspath(os.path.dirname(sys.argv[0]))
self.extra_args = sys.argv[1:]
if not gyp:
gyp = os.environ.get('TESTGYP_GYP')
if not gyp:
if sys.platform == 'win32':
gyp = 'gyp.bat'
else:
gyp = 'gyp'
self.gyp = os.path.abspath(gyp)
self.no_parallel = False
self.formats = [self.format]
self.initialize_build_tool()
kw.setdefault('match', TestCommon.match_exact)
# Put test output in out/testworkarea by default.
# Use temporary names so there are no collisions.
workdir = os.path.join('out', kw.get('workdir', 'testworkarea'))
# Create work area if it doesn't already exist.
if not os.path.isdir(workdir):
os.makedirs(workdir)
kw['workdir'] = tempfile.mktemp(prefix='testgyp.', dir=workdir)
formats = kw.pop('formats', [])
super(TestGypBase, self).__init__(*args, **kw)
real_format = self.format.split('-')[-1]
excluded_formats = set([f for f in formats if f[0] == '!'])
included_formats = set(formats) - excluded_formats
if ('!'+real_format in excluded_formats or
included_formats and real_format not in included_formats):
msg = 'Invalid test for %r format; skipping test.\n'
self.skip_test(msg % self.format)
self.copy_test_configuration(self.origin_cwd, self.workdir)
self.set_configuration(None)
# Set $HOME so that gyp doesn't read the user's actual
# ~/.gyp/include.gypi file, which may contain variables
# and other settings that would change the output.
os.environ['HOME'] = self.workpath()
# Clear $GYP_DEFINES for the same reason.
if 'GYP_DEFINES' in os.environ:
del os.environ['GYP_DEFINES']
# Override the user's language settings, which could
# otherwise make the output vary from what is expected.
os.environ['LC_ALL'] = 'C'
def built_file_must_exist(self, name, type=None, **kw):
"""
Fails the test if the specified built file name does not exist.
"""
return self.must_exist(self.built_file_path(name, type, **kw))
def built_file_must_not_exist(self, name, type=None, **kw):
"""
Fails the test if the specified built file name exists.
"""
return self.must_not_exist(self.built_file_path(name, type, **kw))
def built_file_must_match(self, name, contents, **kw):
"""
Fails the test if the contents of the specified built file name
do not match the specified contents.
"""
return self.must_match(self.built_file_path(name, **kw), contents)
def built_file_must_not_match(self, name, contents, **kw):
"""
Fails the test if the contents of the specified built file name
match the specified contents.
"""
return self.must_not_match(self.built_file_path(name, **kw), contents)
def built_file_must_not_contain(self, name, contents, **kw):
"""
Fails the test if the specified built file name contains the specified
contents.
"""
return self.must_not_contain(self.built_file_path(name, **kw), contents)
def copy_test_configuration(self, source_dir, dest_dir):
"""
Copies the test configuration from the specified source_dir
(the directory in which the test script lives) to the
specified dest_dir (a temporary working directory).
This ignores all files and directories that begin with
the string 'gyptest', and all '.svn' subdirectories.
"""
for root, dirs, files in os.walk(source_dir):
if '.svn' in dirs:
dirs.remove('.svn')
dirs = [ d for d in dirs if not d.startswith('gyptest') ]
files = [ f for f in files if not f.startswith('gyptest') ]
for dirname in dirs:
source = os.path.join(root, dirname)
destination = source.replace(source_dir, dest_dir)
os.mkdir(destination)
if sys.platform != 'win32':
shutil.copystat(source, destination)
for filename in files:
source = os.path.join(root, filename)
destination = source.replace(source_dir, dest_dir)
shutil.copy2(source, destination)
def initialize_build_tool(self):
"""
Initializes the .build_tool attribute.
Searches the .build_tool_list for an executable name on the user's
$PATH. The first tool on the list is used as-is if nothing is found
on the current $PATH.
"""
for build_tool in self.build_tool_list:
if not build_tool:
continue
if os.path.isabs(build_tool):
self.build_tool = build_tool
return
build_tool = self.where_is(build_tool)
if build_tool:
self.build_tool = build_tool
return
if self.build_tool_list:
self.build_tool = self.build_tool_list[0]
def relocate(self, source, destination):
"""
Renames (relocates) the specified source (usually a directory)
to the specified destination, creating the destination directory
first if necessary.
Note: Don't use this as a generic "rename" operation. In the
future, "relocating" parts of a GYP tree may affect the state of
the test to modify the behavior of later method calls.
"""
destination_dir = os.path.dirname(destination)
if not os.path.exists(destination_dir):
self.subdir(destination_dir)
os.rename(source, destination)
def report_not_up_to_date(self):
"""
Reports that a build is not up-to-date.
This provides common reporting for formats that have complicated
conditions for checking whether a build is up-to-date. Formats
that expect exact output from the command (make) can
just set stdout= when they call the run_build() method.
"""
print "Build is not up-to-date:"
print self.banner('STDOUT ')
print self.stdout()
stderr = self.stderr()
if stderr:
print self.banner('STDERR ')
print stderr
def run_gyp(self, gyp_file, *args, **kw):
"""
Runs gyp against the specified gyp_file with the specified args.
"""
# When running gyp, and comparing its output we use a comparitor
# that ignores the line numbers that gyp logs in its debug output.
if kw.pop('ignore_line_numbers', False):
kw.setdefault('match', match_modulo_line_numbers)
# TODO: --depth=. works around Chromium-specific tree climbing.
depth = kw.pop('depth', '.')
run_args = ['--depth='+depth]
run_args.extend(['--format='+f for f in self.formats]);
run_args.append(gyp_file)
if self.no_parallel:
run_args += ['--no-parallel']
# TODO: if extra_args contains a '--build' flag
# we really want that to only apply to the last format (self.format).
run_args.extend(self.extra_args)
# Default xcode_ninja_target_pattern to ^.*$ to fix xcode-ninja tests
xcode_ninja_target_pattern = kw.pop('xcode_ninja_target_pattern', '.*')
run_args.extend(
['-G', 'xcode_ninja_target_pattern=%s' % xcode_ninja_target_pattern])
run_args.extend(args)
return self.run(program=self.gyp, arguments=run_args, **kw)
def run(self, *args, **kw):
"""
Executes a program by calling the superclass .run() method.
This exists to provide a common place to filter out keyword
arguments implemented in this layer, without having to update
the tool-specific subclasses or clutter the tests themselves
with platform-specific code.
"""
if kw.has_key('SYMROOT'):
del kw['SYMROOT']
super(TestGypBase, self).run(*args, **kw)
def set_configuration(self, configuration):
"""
Sets the configuration, to be used for invoking the build
tool and testing potential built output.
"""
self.configuration = configuration
def configuration_dirname(self):
if self.configuration:
return self.configuration.split('|')[0]
else:
return 'Default'
def configuration_buildname(self):
if self.configuration:
return self.configuration
else:
return 'Default'
#
# Abstract methods to be defined by format-specific subclasses.
#
def build(self, gyp_file, target=None, **kw):
"""
Runs a build of the specified target against the configuration
generated from the specified gyp_file.
A 'target' argument of None or the special value TestGyp.DEFAULT
specifies the default argument for the underlying build tool.
A 'target' argument of TestGyp.ALL specifies the 'all' target
(if any) of the underlying build tool.
"""
raise NotImplementedError
def built_file_path(self, name, type=None, **kw):
"""
Returns a path to the specified file name, of the specified type.
"""
raise NotImplementedError
def built_file_basename(self, name, type=None, **kw):
"""
Returns the base name of the specified file name, of the specified type.
A bare=True keyword argument specifies that prefixes and suffixes shouldn't
be applied.
"""
if not kw.get('bare'):
if type == self.EXECUTABLE:
name = name + self._exe
elif type == self.STATIC_LIB:
name = self.lib_ + name + self._lib
elif type == self.SHARED_LIB:
name = self.dll_ + name + self._dll
return name
def run_built_executable(self, name, *args, **kw):
"""
Runs an executable program built from a gyp-generated configuration.
The specified name should be independent of any particular generator.
Subclasses should find the output executable in the appropriate
output build directory, tack on any necessary executable suffix, etc.
"""
raise NotImplementedError
def up_to_date(self, gyp_file, target=None, **kw):
"""
Verifies that a build of the specified target is up to date.
The subclass should implement this by calling build()
(or a reasonable equivalent), checking whatever conditions
will tell it the build was an "up to date" null build, and
failing if it isn't.
"""
raise NotImplementedError
class TestGypGypd(TestGypBase):
"""
Subclass for testing the GYP 'gypd' generator (spit out the
internal data structure as pretty-printed Python).
"""
format = 'gypd'
def __init__(self, gyp=None, *args, **kw):
super(TestGypGypd, self).__init__(*args, **kw)
# gypd implies the use of 'golden' files, so parallelizing conflicts as it
# causes ordering changes.
self.no_parallel = True
class TestGypCustom(TestGypBase):
"""
Subclass for testing the GYP with custom generator
"""
def __init__(self, gyp=None, *args, **kw):
self.format = kw.pop("format")
super(TestGypCustom, self).__init__(*args, **kw)
class TestGypAndroid(TestGypBase):
"""
Subclass for testing the GYP Android makefile generator. Note that
build/envsetup.sh and lunch must have been run before running tests.
"""
format = 'android'
# Note that we can't use mmm as the build tool because ...
# - it builds all targets, whereas we need to pass a target
# - it is a function, whereas the test runner assumes the build tool is a file
# Instead we use make and duplicate the logic from mmm.
build_tool_list = ['make']
# We use our custom target 'gyp_all_modules', as opposed to the 'all_modules'
# target used by mmm, to build only those targets which are part of the gyp
# target 'all'.
ALL = 'gyp_all_modules'
def __init__(self, gyp=None, *args, **kw):
# Android requires build and test output to be inside its source tree.
# We use the following working directory for the test's source, but the
# test's build output still goes to $ANDROID_PRODUCT_OUT.
# Note that some tests explicitly set format='gypd' to invoke the gypd
# backend. This writes to the source tree, but there's no way around this.
kw['workdir'] = os.path.join('/tmp', 'gyptest',
kw.get('workdir', 'testworkarea'))
# We need to remove all gyp outputs from out/. Ths is because some tests
# don't have rules to regenerate output, so they will simply re-use stale
# output if present. Since the test working directory gets regenerated for
# each test run, this can confuse things.
# We don't have a list of build outputs because we don't know which
# dependent targets were built. Instead we delete all gyp-generated output.
# This may be excessive, but should be safe.
out_dir = os.environ['ANDROID_PRODUCT_OUT']
obj_dir = os.path.join(out_dir, 'obj')
shutil.rmtree(os.path.join(obj_dir, 'GYP'), ignore_errors = True)
for x in ['EXECUTABLES', 'STATIC_LIBRARIES', 'SHARED_LIBRARIES']:
for d in os.listdir(os.path.join(obj_dir, x)):
if d.endswith('_gyp_intermediates'):
shutil.rmtree(os.path.join(obj_dir, x, d), ignore_errors = True)
for x in [os.path.join('obj', 'lib'), os.path.join('system', 'lib')]:
for d in os.listdir(os.path.join(out_dir, x)):
if d.endswith('_gyp.so'):
os.remove(os.path.join(out_dir, x, d))
super(TestGypAndroid, self).__init__(*args, **kw)
self._adb_path = os.path.join(os.environ['ANDROID_HOST_OUT'], 'bin', 'adb')
self._device_serial = None
adb_devices_out = self._call_adb(['devices'])
devices = [l.split()[0] for l in adb_devices_out.splitlines()[1:-1]
if l.split()[1] == 'device']
if len(devices) == 0:
self._device_serial = None
else:
if len(devices) > 1:
self._device_serial = random.choice(devices)
else:
self._device_serial = devices[0]
self._call_adb(['root'])
self._to_install = set()
def target_name(self, target):
if target == self.ALL:
return self.ALL
# The default target is 'droid'. However, we want to use our special target
# to build only the gyp target 'all'.
if target in (None, self.DEFAULT):
return self.ALL
return target
_INSTALLABLE_PREFIX = 'Install: '
def build(self, gyp_file, target=None, **kw):
"""
Runs a build using the Android makefiles generated from the specified
gyp_file. This logic is taken from Android's mmm.
"""
arguments = kw.get('arguments', [])[:]
arguments.append(self.target_name(target))
arguments.append('-C')
arguments.append(os.environ['ANDROID_BUILD_TOP'])
kw['arguments'] = arguments
chdir = kw.get('chdir', '')
makefile = os.path.join(self.workdir, chdir, 'GypAndroid.mk')
os.environ['ONE_SHOT_MAKEFILE'] = makefile
result = self.run(program=self.build_tool, **kw)
for l in self.stdout().splitlines():
if l.startswith(TestGypAndroid._INSTALLABLE_PREFIX):
self._to_install.add(os.path.abspath(os.path.join(
os.environ['ANDROID_BUILD_TOP'],
l[len(TestGypAndroid._INSTALLABLE_PREFIX):])))
del os.environ['ONE_SHOT_MAKEFILE']
return result
def android_module(self, group, name, subdir):
if subdir:
name = '%s_%s' % (subdir, name)
if group == 'SHARED_LIBRARIES':
name = 'lib_%s' % name
return '%s_gyp' % name
def intermediates_dir(self, group, module_name):
return os.path.join(os.environ['ANDROID_PRODUCT_OUT'], 'obj', group,
'%s_intermediates' % module_name)
def built_file_path(self, name, type=None, **kw):
"""
Returns a path to the specified file name, of the specified type,
as built by Android. Note that we don't support the configuration
parameter.
"""
# Built files are in $ANDROID_PRODUCT_OUT. This requires copying logic from
# the Android build system.
if type == None or type == self.EXECUTABLE:
return os.path.join(os.environ['ANDROID_PRODUCT_OUT'], 'obj', 'GYP',
'shared_intermediates', name)
subdir = kw.get('subdir')
if type == self.STATIC_LIB:
group = 'STATIC_LIBRARIES'
module_name = self.android_module(group, name, subdir)
return os.path.join(self.intermediates_dir(group, module_name),
'%s.a' % module_name)
if type == self.SHARED_LIB:
group = 'SHARED_LIBRARIES'
module_name = self.android_module(group, name, subdir)
return os.path.join(self.intermediates_dir(group, module_name), 'LINKED',
'%s.so' % module_name)
assert False, 'Unhandled type'
def _adb_failure(self, command, msg, stdout, stderr):
""" Reports a failed adb command and fails the containing test.
Args:
command: The adb command that failed.
msg: The error description.
stdout: The standard output.
stderr: The standard error.
"""
print '%s failed%s' % (' '.join(command), ': %s' % msg if msg else '')
print self.banner('STDOUT ')
stdout.seek(0)
print stdout.read()
print self.banner('STDERR ')
stderr.seek(0)
print stderr.read()
self.fail_test()
def _call_adb(self, command, timeout=15, retry=3):
""" Calls the provided adb command.
If the command fails, the test fails.
Args:
command: The adb command to call.
Returns:
The command's output.
"""
with tempfile.TemporaryFile(bufsize=0) as adb_out:
with tempfile.TemporaryFile(bufsize=0) as adb_err:
adb_command = [self._adb_path]
if self._device_serial:
adb_command += ['-s', self._device_serial]
is_shell = (command[0] == 'shell')
if is_shell:
command = [command[0], '%s; echo "\n$?";' % ' '.join(command[1:])]
adb_command += command
for attempt in xrange(1, retry + 1):
adb_out.seek(0)
adb_out.truncate(0)
adb_err.seek(0)
adb_err.truncate(0)
proc = subprocess.Popen(adb_command, stdout=adb_out, stderr=adb_err)
deadline = time.time() + timeout
timed_out = False
while proc.poll() is None and not timed_out:
time.sleep(1)
timed_out = time.time() > deadline
if timed_out:
print 'Timeout for command %s (attempt %d of %s)' % (
adb_command, attempt, retry)
try:
proc.kill()
except:
pass
else:
break
if proc.returncode != 0: # returncode is None in the case of a timeout.
self._adb_failure(
adb_command, 'retcode=%s' % proc.returncode, adb_out, adb_err)
return
adb_out.seek(0)
output = adb_out.read()
if is_shell:
output = output.splitlines(True)
try:
output[-2] = output[-2].rstrip('\r\n')
output, rc = (''.join(output[:-1]), int(output[-1]))
except ValueError:
self._adb_failure(adb_command, 'unexpected output format',
adb_out, adb_err)
if rc != 0:
self._adb_failure(adb_command, 'exited with %d' % rc, adb_out,
adb_err)
return output
def run_built_executable(self, name, *args, **kw):
"""
Runs an executable program built from a gyp-generated configuration.
"""
match = kw.pop('match', self.match)
executable_file = self.built_file_path(name, type=self.EXECUTABLE, **kw)
if executable_file not in self._to_install:
self.fail_test()
if not self._device_serial:
self.skip_test(message='No devices attached.\n')
storage = self._call_adb(['shell', 'echo', '$ANDROID_DATA']).strip()
if not len(storage):
self.fail_test()
installed = set()
try:
for i in self._to_install:
a = os.path.abspath(
os.path.join(os.environ['ANDROID_BUILD_TOP'], i))
dest = '%s/%s' % (storage, os.path.basename(a))
self._call_adb(['push', os.path.abspath(a), dest])
installed.add(dest)
if i == executable_file:
device_executable = dest
self._call_adb(['shell', 'chmod', '755', device_executable])
out = self._call_adb(
['shell', 'LD_LIBRARY_PATH=$LD_LIBRARY_PATH:%s' % storage,
device_executable],
timeout=60,
retry=1)
out = out.replace('\r\n', '\n')
self._complete(out, kw.pop('stdout', None), None, None, None, match)
finally:
if len(installed):
self._call_adb(['shell', 'rm'] + list(installed))
def match_single_line(self, lines = None, expected_line = None):
"""
Checks that specified line appears in the text.
"""
for line in lines.split('\n'):
if line == expected_line:
return 1
return
def up_to_date(self, gyp_file, target=None, **kw):
"""
Verifies that a build of the specified target is up to date.
"""
kw['stdout'] = ("make: Nothing to be done for `%s'." %
self.target_name(target))
# We need to supply a custom matcher, since we don't want to depend on the
# exact stdout string.
kw['match'] = self.match_single_line
return self.build(gyp_file, target, **kw)
class TestGypCMake(TestGypBase):
"""
Subclass for testing the GYP CMake generator, using cmake's ninja backend.
"""
format = 'cmake'
build_tool_list = ['cmake']
ALL = 'all'
def cmake_build(self, gyp_file, target=None, **kw):
arguments = kw.get('arguments', [])[:]
self.build_tool_list = ['cmake']
self.initialize_build_tool()
chdir = os.path.join(kw.get('chdir', '.'),
'out',
self.configuration_dirname())
kw['chdir'] = chdir
arguments.append('-G')
arguments.append('Ninja')
kw['arguments'] = arguments
stderr = kw.get('stderr', None)
if stderr:
kw['stderr'] = stderr.split('$$$')[0]
self.run(program=self.build_tool, **kw)
def ninja_build(self, gyp_file, target=None, **kw):
arguments = kw.get('arguments', [])[:]
self.build_tool_list = ['ninja']
self.initialize_build_tool()
# Add a -C output/path to the command line.
arguments.append('-C')
arguments.append(os.path.join('out', self.configuration_dirname()))
if target not in (None, self.DEFAULT):
arguments.append(target)
kw['arguments'] = arguments
stderr = kw.get('stderr', None)
if stderr:
stderrs = stderr.split('$$$')
kw['stderr'] = stderrs[1] if len(stderrs) > 1 else ''
return self.run(program=self.build_tool, **kw)
def build(self, gyp_file, target=None, status=0, **kw):
# Two tools must be run to build, cmake and the ninja.
# Allow cmake to succeed when the overall expectation is to fail.
if status is None:
kw['status'] = None
else:
if not isinstance(status, collections.Iterable): status = (status,)
kw['status'] = list(itertools.chain((0,), status))
self.cmake_build(gyp_file, target, **kw)
kw['status'] = status
self.ninja_build(gyp_file, target, **kw)
def run_built_executable(self, name, *args, **kw):
# Enclosing the name in a list avoids prepending the original dir.
program = [self.built_file_path(name, type=self.EXECUTABLE, **kw)]
if sys.platform == 'darwin':
configuration = self.configuration_dirname()
os.environ['DYLD_LIBRARY_PATH'] = os.path.join('out', configuration)
return self.run(program=program, *args, **kw)
def built_file_path(self, name, type=None, **kw):
result = []
chdir = kw.get('chdir')
if chdir:
result.append(chdir)
result.append('out')
result.append(self.configuration_dirname())
if type == self.STATIC_LIB:
if sys.platform != 'darwin':
result.append('obj.target')
elif type == self.SHARED_LIB:
if sys.platform != 'darwin' and sys.platform != 'win32':
result.append('lib.target')
subdir = kw.get('subdir')
if subdir and type != self.SHARED_LIB:
result.append(subdir)
result.append(self.built_file_basename(name, type, **kw))
return self.workpath(*result)
def up_to_date(self, gyp_file, target=None, **kw):
result = self.ninja_build(gyp_file, target, **kw)
if not result:
stdout = self.stdout()
if 'ninja: no work to do' not in stdout:
self.report_not_up_to_date()
self.fail_test()
return result
class TestGypMake(TestGypBase):
"""
Subclass for testing the GYP Make generator.
"""
format = 'make'
build_tool_list = ['make']
ALL = 'all'
def build(self, gyp_file, target=None, **kw):
"""
Runs a Make build using the Makefiles generated from the specified
gyp_file.
"""
arguments = kw.get('arguments', [])[:]
if self.configuration:
arguments.append('BUILDTYPE=' + self.configuration)
if target not in (None, self.DEFAULT):
arguments.append(target)
# Sub-directory builds provide per-gyp Makefiles (i.e.
# Makefile.gyp_filename), so use that if there is no Makefile.
chdir = kw.get('chdir', '')
if not os.path.exists(os.path.join(chdir, 'Makefile')):
print "NO Makefile in " + os.path.join(chdir, 'Makefile')
arguments.insert(0, '-f')
arguments.insert(1, os.path.splitext(gyp_file)[0] + '.Makefile')
kw['arguments'] = arguments
return self.run(program=self.build_tool, **kw)
def up_to_date(self, gyp_file, target=None, **kw):
"""
Verifies that a build of the specified Make target is up to date.
"""
if target in (None, self.DEFAULT):
message_target = 'all'
else:
message_target = target
kw['stdout'] = "make: Nothing to be done for `%s'.\n" % message_target
return self.build(gyp_file, target, **kw)
def run_built_executable(self, name, *args, **kw):
"""
Runs an executable built by Make.
"""
configuration = self.configuration_dirname()
libdir = os.path.join('out', configuration, 'lib')
# TODO(piman): when everything is cross-compile safe, remove lib.target
if sys.platform == 'darwin':
# Mac puts target shared libraries right in the product directory.
configuration = self.configuration_dirname()
os.environ['DYLD_LIBRARY_PATH'] = (
libdir + '.host:' + os.path.join('out', configuration))
else:
os.environ['LD_LIBRARY_PATH'] = libdir + '.host:' + libdir + '.target'
# Enclosing the name in a list avoids prepending the original dir.
program = [self.built_file_path(name, type=self.EXECUTABLE, **kw)]
return self.run(program=program, *args, **kw)
def built_file_path(self, name, type=None, **kw):
"""
Returns a path to the specified file name, of the specified type,
as built by Make.
Built files are in the subdirectory 'out/{configuration}'.
The default is 'out/Default'.
A chdir= keyword argument specifies the source directory
relative to which the output subdirectory can be found.
"type" values of STATIC_LIB or SHARED_LIB append the necessary
prefixes and suffixes to a platform-independent library base name.
A subdir= keyword argument specifies a library subdirectory within
the default 'obj.target'.
"""
result = []
chdir = kw.get('chdir')
if chdir:
result.append(chdir)
configuration = self.configuration_dirname()
result.extend(['out', configuration])
if type == self.STATIC_LIB and sys.platform != 'darwin':
result.append('obj.target')
elif type == self.SHARED_LIB and sys.platform != 'darwin':
result.append('lib.target')
subdir = kw.get('subdir')
if subdir and type != self.SHARED_LIB:
result.append(subdir)
result.append(self.built_file_basename(name, type, **kw))
return self.workpath(*result)
def ConvertToCygpath(path):
"""Convert to cygwin path if we are using cygwin."""
if sys.platform == 'cygwin':
p = subprocess.Popen(['cygpath', path], stdout=subprocess.PIPE)
path = p.communicate()[0].strip()
return path
def FindMSBuildInstallation(msvs_version = 'auto'):
"""Returns path to MSBuild for msvs_version or latest available.
Looks in the registry to find install location of MSBuild.
MSBuild before v4.0 will not build c++ projects, so only use newer versions.
"""
import TestWin
registry = TestWin.Registry()
msvs_to_msbuild = {
'2013': r'12.0',
'2012': r'4.0', # Really v4.0.30319 which comes with .NET 4.5.
'2010': r'4.0'}
msbuild_basekey = r'HKLM\SOFTWARE\Microsoft\MSBuild\ToolsVersions'
if not registry.KeyExists(msbuild_basekey):
print 'Error: could not find MSBuild base registry entry'
return None
msbuild_version = None
if msvs_version in msvs_to_msbuild:
msbuild_test_version = msvs_to_msbuild[msvs_version]
if registry.KeyExists(msbuild_basekey + '\\' + msbuild_test_version):
msbuild_version = msbuild_test_version
else:
print ('Warning: Environment variable GYP_MSVS_VERSION specifies "%s" '
'but corresponding MSBuild "%s" was not found.' %
(msvs_version, msbuild_version))
if not msbuild_version:
for msvs_version in sorted(msvs_to_msbuild, reverse=True):
msbuild_test_version = msvs_to_msbuild[msvs_version]
if registry.KeyExists(msbuild_basekey + '\\' + msbuild_test_version):
msbuild_version = msbuild_test_version
break
if not msbuild_version:
print 'Error: could not find MSBuild registry entry'
return None
msbuild_path = registry.GetValue(msbuild_basekey + '\\' + msbuild_version,
'MSBuildToolsPath')
if not msbuild_path:
print 'Error: could not get MSBuild registry entry value'
return None
return os.path.join(msbuild_path, 'MSBuild.exe')
def FindVisualStudioInstallation():
"""Returns appropriate values for .build_tool and .uses_msbuild fields
of TestGypBase for Visual Studio.
We use the value specified by GYP_MSVS_VERSION. If not specified, we
search %PATH% and %PATHEXT% for a devenv.{exe,bat,...} executable.
Failing that, we search for likely deployment paths.
"""
possible_roots = ['%s:\\Program Files%s' % (chr(drive), suffix)
for drive in range(ord('C'), ord('Z') + 1)
for suffix in ['', ' (x86)']]
possible_paths = {
'2013': r'Microsoft Visual Studio 12.0\Common7\IDE\devenv.com',
'2012': r'Microsoft Visual Studio 11.0\Common7\IDE\devenv.com',
'2010': r'Microsoft Visual Studio 10.0\Common7\IDE\devenv.com',
'2008': r'Microsoft Visual Studio 9.0\Common7\IDE\devenv.com',
'2005': r'Microsoft Visual Studio 8\Common7\IDE\devenv.com'}
possible_roots = [ConvertToCygpath(r) for r in possible_roots]
msvs_version = 'auto'
for flag in (f for f in sys.argv if f.startswith('msvs_version=')):
msvs_version = flag.split('=')[-1]
msvs_version = os.environ.get('GYP_MSVS_VERSION', msvs_version)
if msvs_version in possible_paths:
# Check that the path to the specified GYP_MSVS_VERSION exists.
path = possible_paths[msvs_version]
for r in possible_roots:
build_tool = os.path.join(r, path)
if os.path.exists(build_tool):
uses_msbuild = msvs_version >= '2010'
msbuild_path = FindMSBuildInstallation(msvs_version)
return build_tool, uses_msbuild, msbuild_path
else:
print ('Warning: Environment variable GYP_MSVS_VERSION specifies "%s" '
'but corresponding "%s" was not found.' % (msvs_version, path))
# Neither GYP_MSVS_VERSION nor the path help us out. Iterate through
# the choices looking for a match.
for version in sorted(possible_paths, reverse=True):
path = possible_paths[version]
for r in possible_roots:
build_tool = os.path.join(r, path)
if os.path.exists(build_tool):
uses_msbuild = msvs_version >= '2010'
msbuild_path = FindMSBuildInstallation(msvs_version)
return build_tool, uses_msbuild, msbuild_path
print 'Error: could not find devenv'
sys.exit(1)
class TestGypOnMSToolchain(TestGypBase):
"""
Common subclass for testing generators that target the Microsoft Visual
Studio toolchain (cl, link, dumpbin, etc.)
"""
@staticmethod
def _ComputeVsvarsPath(devenv_path):
devenv_dir = os.path.split(devenv_path)[0]
vsvars_path = os.path.join(devenv_path, '../../Tools/vsvars32.bat')
return vsvars_path
def initialize_build_tool(self):
super(TestGypOnMSToolchain, self).initialize_build_tool()
if sys.platform in ('win32', 'cygwin'):
build_tools = FindVisualStudioInstallation()
self.devenv_path, self.uses_msbuild, self.msbuild_path = build_tools
self.vsvars_path = TestGypOnMSToolchain._ComputeVsvarsPath(
self.devenv_path)
def run_dumpbin(self, *dumpbin_args):
"""Run the dumpbin tool with the specified arguments, and capturing and
returning stdout."""
assert sys.platform in ('win32', 'cygwin')
cmd = os.environ.get('COMSPEC', 'cmd.exe')
arguments = [cmd, '/c', self.vsvars_path, '&&', 'dumpbin']
arguments.extend(dumpbin_args)
proc = subprocess.Popen(arguments, stdout=subprocess.PIPE)
output = proc.communicate()[0]
assert not proc.returncode
return output
class TestGypNinja(TestGypOnMSToolchain):
"""
Subclass for testing the GYP Ninja generator.
"""
format = 'ninja'
build_tool_list = ['ninja']
ALL = 'all'
DEFAULT = 'all'
def run_gyp(self, gyp_file, *args, **kw):
TestGypBase.run_gyp(self, gyp_file, *args, **kw)
def build(self, gyp_file, target=None, **kw):
arguments = kw.get('arguments', [])[:]
# Add a -C output/path to the command line.
arguments.append('-C')
arguments.append(os.path.join('out', self.configuration_dirname()))
if target is None:
target = 'all'
arguments.append(target)
kw['arguments'] = arguments
return self.run(program=self.build_tool, **kw)
def run_built_executable(self, name, *args, **kw):
# Enclosing the name in a list avoids prepending the original dir.
program = [self.built_file_path(name, type=self.EXECUTABLE, **kw)]
if sys.platform == 'darwin':
configuration = self.configuration_dirname()
os.environ['DYLD_LIBRARY_PATH'] = os.path.join('out', configuration)
return self.run(program=program, *args, **kw)
def built_file_path(self, name, type=None, **kw):
result = []
chdir = kw.get('chdir')
if chdir:
result.append(chdir)
result.append('out')
result.append(self.configuration_dirname())
if type == self.STATIC_LIB:
if sys.platform != 'darwin':
result.append('obj')
elif type == self.SHARED_LIB:
if sys.platform != 'darwin' and sys.platform != 'win32':
result.append('lib')
subdir = kw.get('subdir')
if subdir and type != self.SHARED_LIB:
result.append(subdir)
result.append(self.built_file_basename(name, type, **kw))
return self.workpath(*result)
def up_to_date(self, gyp_file, target=None, **kw):
result = self.build(gyp_file, target, **kw)
if not result:
stdout = self.stdout()
if 'ninja: no work to do' not in stdout:
self.report_not_up_to_date()
self.fail_test()
return result
class TestGypMSVS(TestGypOnMSToolchain):
"""
Subclass for testing the GYP Visual Studio generator.
"""
format = 'msvs'
u = r'=== Build: 0 succeeded, 0 failed, (\d+) up-to-date, 0 skipped ==='
up_to_date_re = re.compile(u, re.M)
# Initial None element will indicate to our .initialize_build_tool()
# method below that 'devenv' was not found on %PATH%.
#
# Note: we must use devenv.com to be able to capture build output.
# Directly executing devenv.exe only sends output to BuildLog.htm.
build_tool_list = [None, 'devenv.com']
def initialize_build_tool(self):
super(TestGypMSVS, self).initialize_build_tool()
self.build_tool = self.devenv_path
def build(self, gyp_file, target=None, rebuild=False, clean=False, **kw):
"""
Runs a Visual Studio build using the configuration generated
from the specified gyp_file.
"""
configuration = self.configuration_buildname()
if clean:
build = '/Clean'
elif rebuild:
build = '/Rebuild'
else:
build = '/Build'
arguments = kw.get('arguments', [])[:]
arguments.extend([gyp_file.replace('.gyp', '.sln'),
build, configuration])
# Note: the Visual Studio generator doesn't add an explicit 'all'
# target, so we just treat it the same as the default.
if target not in (None, self.ALL, self.DEFAULT):
arguments.extend(['/Project', target])
if self.configuration:
arguments.extend(['/ProjectConfig', self.configuration])
kw['arguments'] = arguments
return self.run(program=self.build_tool, **kw)
def up_to_date(self, gyp_file, target=None, **kw):
"""
Verifies that a build of the specified Visual Studio target is up to date.
Beware that VS2010 will behave strangely if you build under
C:\USERS\yourname\AppData\Local. It will cause needless work. The ouptut
will be "1 succeeded and 0 up to date". MSBuild tracing reveals that:
"Project 'C:\Users\...\AppData\Local\...vcxproj' not up to date because
'C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO 10.0\VC\BIN\1033\CLUI.DLL'
was modified at 02/21/2011 17:03:30, which is newer than '' which was
modified at 01/01/0001 00:00:00.
The workaround is to specify a workdir when instantiating the test, e.g.
test = TestGyp.TestGyp(workdir='workarea')
"""
result = self.build(gyp_file, target, **kw)
if not result:
stdout = self.stdout()
m = self.up_to_date_re.search(stdout)
up_to_date = m and int(m.group(1)) > 0
if not up_to_date:
self.report_not_up_to_date()
self.fail_test()
return result
def run_built_executable(self, name, *args, **kw):
"""
Runs an executable built by Visual Studio.
"""
configuration = self.configuration_dirname()
# Enclosing the name in a list avoids prepending the original dir.
program = [self.built_file_path(name, type=self.EXECUTABLE, **kw)]
return self.run(program=program, *args, **kw)
def built_file_path(self, name, type=None, **kw):
"""
Returns a path to the specified file name, of the specified type,
as built by Visual Studio.
Built files are in a subdirectory that matches the configuration
name. The default is 'Default'.
A chdir= keyword argument specifies the source directory
relative to which the output subdirectory can be found.
"type" values of STATIC_LIB or SHARED_LIB append the necessary
prefixes and suffixes to a platform-independent library base name.
"""
result = []
chdir = kw.get('chdir')
if chdir:
result.append(chdir)
result.append(self.configuration_dirname())
if type == self.STATIC_LIB:
result.append('lib')
result.append(self.built_file_basename(name, type, **kw))
return self.workpath(*result)
class TestGypMSVSNinja(TestGypNinja):
"""
Subclass for testing the GYP Visual Studio Ninja generator.
"""
format = 'msvs-ninja'
def initialize_build_tool(self):
super(TestGypMSVSNinja, self).initialize_build_tool()
# When using '--build', make sure ninja is first in the format list.
self.formats.insert(0, 'ninja')
def build(self, gyp_file, target=None, rebuild=False, clean=False, **kw):
"""
Runs a Visual Studio build using the configuration generated
from the specified gyp_file.
"""
arguments = kw.get('arguments', [])[:]
if target in (None, self.ALL, self.DEFAULT):
# Note: the Visual Studio generator doesn't add an explicit 'all' target.
# This will build each project. This will work if projects are hermetic,
# but may fail if they are not (a project may run more than once).
# It would be nice to supply an all.metaproj for MSBuild.
arguments.extend([gyp_file.replace('.gyp', '.sln')])
else:
# MSBuild documentation claims that one can specify a sln but then build a
# project target like 'msbuild a.sln /t:proj:target' but this format only
# supports 'Clean', 'Rebuild', and 'Publish' (with none meaning Default).
# This limitation is due to the .sln -> .sln.metaproj conversion.
# The ':' is not special, 'proj:target' is a target in the metaproj.
arguments.extend([target+'.vcxproj'])
if clean:
build = 'Clean'
elif rebuild:
build = 'Rebuild'
else:
build = 'Build'
arguments.extend(['/target:'+build])
configuration = self.configuration_buildname()
config = configuration.split('|')
arguments.extend(['/property:Configuration='+config[0]])
if len(config) > 1:
arguments.extend(['/property:Platform='+config[1]])
arguments.extend(['/property:BuildInParallel=false'])
arguments.extend(['/verbosity:minimal'])
kw['arguments'] = arguments
return self.run(program=self.msbuild_path, **kw)
class TestGypXcode(TestGypBase):
"""
Subclass for testing the GYP Xcode generator.
"""
format = 'xcode'
build_tool_list = ['xcodebuild']
phase_script_execution = ("\n"
"PhaseScriptExecution /\\S+/Script-[0-9A-F]+\\.sh\n"
" cd /\\S+\n"
" /bin/sh -c /\\S+/Script-[0-9A-F]+\\.sh\n"
"(make: Nothing to be done for `all'\\.\n)?")
strip_up_to_date_expressions = [
# Various actions or rules can run even when the overall build target
# is up to date. Strip those phases' GYP-generated output.
re.compile(phase_script_execution, re.S),
# The message from distcc_pump can trail the "BUILD SUCCEEDED"
# message, so strip that, too.
re.compile('__________Shutting down distcc-pump include server\n', re.S),
]
up_to_date_endings = (
'Checking Dependencies...\n** BUILD SUCCEEDED **\n', # Xcode 3.0/3.1
'Check dependencies\n** BUILD SUCCEEDED **\n\n', # Xcode 3.2
'Check dependencies\n\n\n** BUILD SUCCEEDED **\n\n', # Xcode 4.2
'Check dependencies\n\n** BUILD SUCCEEDED **\n\n', # Xcode 5.0
)
def build(self, gyp_file, target=None, **kw):
"""
Runs an xcodebuild using the .xcodeproj generated from the specified
gyp_file.
"""
# Be sure we're working with a copy of 'arguments' since we modify it.
# The caller may not be expecting it to be modified.
arguments = kw.get('arguments', [])[:]
arguments.extend(['-project', gyp_file.replace('.gyp', '.xcodeproj')])
if target == self.ALL:
arguments.append('-alltargets',)
elif target not in (None, self.DEFAULT):
arguments.extend(['-target', target])
if self.configuration:
arguments.extend(['-configuration', self.configuration])
symroot = kw.get('SYMROOT', '$SRCROOT/build')
if symroot:
arguments.append('SYMROOT='+symroot)
kw['arguments'] = arguments
# Work around spurious stderr output from Xcode 4, http://crbug.com/181012
match = kw.pop('match', self.match)
def match_filter_xcode(actual, expected):
if actual:
if not TestCmd.is_List(actual):
actual = actual.split('\n')
if not TestCmd.is_List(expected):
expected = expected.split('\n')
actual = [a for a in actual
if 'No recorder, buildTask: <Xcode3BuildTask:' not in a]
return match(actual, expected)
kw['match'] = match_filter_xcode
return self.run(program=self.build_tool, **kw)
def up_to_date(self, gyp_file, target=None, **kw):
"""
Verifies that a build of the specified Xcode target is up to date.
"""
result = self.build(gyp_file, target, **kw)
if not result:
output = self.stdout()
for expression in self.strip_up_to_date_expressions:
output = expression.sub('', output)
if not output.endswith(self.up_to_date_endings):
self.report_not_up_to_date()
self.fail_test()
return result
def run_built_executable(self, name, *args, **kw):
"""
Runs an executable built by xcodebuild.
"""
configuration = self.configuration_dirname()
os.environ['DYLD_LIBRARY_PATH'] = os.path.join('build', configuration)
# Enclosing the name in a list avoids prepending the original dir.
program = [self.built_file_path(name, type=self.EXECUTABLE, **kw)]
return self.run(program=program, *args, **kw)
def built_file_path(self, name, type=None, **kw):
"""
Returns a path to the specified file name, of the specified type,
as built by Xcode.
Built files are in the subdirectory 'build/{configuration}'.
The default is 'build/Default'.
A chdir= keyword argument specifies the source directory
relative to which the output subdirectory can be found.
"type" values of STATIC_LIB or SHARED_LIB append the necessary
prefixes and suffixes to a platform-independent library base name.
"""
result = []
chdir = kw.get('chdir')
if chdir:
result.append(chdir)
configuration = self.configuration_dirname()
result.extend(['build', configuration])
result.append(self.built_file_basename(name, type, **kw))
return self.workpath(*result)
class TestGypXcodeNinja(TestGypXcode):
"""
Subclass for testing the GYP Xcode Ninja generator.
"""
format = 'xcode-ninja'
def initialize_build_tool(self):
super(TestGypXcodeNinja, self).initialize_build_tool()
# When using '--build', make sure ninja is first in the format list.
self.formats.insert(0, 'ninja')
def build(self, gyp_file, target=None, **kw):
"""
Runs an xcodebuild using the .xcodeproj generated from the specified
gyp_file.
"""
build_config = self.configuration
if build_config and build_config.endswith(('-iphoneos',
'-iphonesimulator')):
build_config, sdk = self.configuration.split('-')
kw['arguments'] = kw.get('arguments', []) + ['-sdk', sdk]
with self._build_configuration(build_config):
return super(TestGypXcodeNinja, self).build(
gyp_file.replace('.gyp', '.ninja.gyp'), target, **kw)
@contextmanager
def _build_configuration(self, build_config):
config = self.configuration
self.configuration = build_config
try:
yield
finally:
self.configuration = config
def built_file_path(self, name, type=None, **kw):
result = []
chdir = kw.get('chdir')
if chdir:
result.append(chdir)
result.append('out')
result.append(self.configuration_dirname())
subdir = kw.get('subdir')
if subdir and type != self.SHARED_LIB:
result.append(subdir)
result.append(self.built_file_basename(name, type, **kw))
return self.workpath(*result)
def up_to_date(self, gyp_file, target=None, **kw):
result = self.build(gyp_file, target, **kw)
if not result:
stdout = self.stdout()
if 'ninja: no work to do' not in stdout:
self.report_not_up_to_date()
self.fail_test()
return result
def run_built_executable(self, name, *args, **kw):
"""
Runs an executable built by xcodebuild + ninja.
"""
configuration = self.configuration_dirname()
os.environ['DYLD_LIBRARY_PATH'] = os.path.join('out', configuration)
# Enclosing the name in a list avoids prepending the original dir.
program = [self.built_file_path(name, type=self.EXECUTABLE, **kw)]
return self.run(program=program, *args, **kw)
format_class_list = [
TestGypGypd,
TestGypAndroid,
TestGypCMake,
TestGypMake,
TestGypMSVS,
TestGypMSVSNinja,
TestGypNinja,
TestGypXcode,
TestGypXcodeNinja,
]
def TestGyp(*args, **kw):
"""
Returns an appropriate TestGyp* instance for a specified GYP format.
"""
format = kw.pop('format', os.environ.get('TESTGYP_FORMAT'))
for format_class in format_class_list:
if format == format_class.format:
return format_class(*args, **kw)
raise Exception, "unknown format %r" % format
|
gpl-3.0
|
[
3,
1898,
334,
67,
9,
6029,
4475,
3277,
14,
2900,
4481,
4644,
14,
199,
3,
3645,
402,
642,
1350,
1233,
365,
10413,
701,
282,
6289,
13,
2487,
4190,
626,
883,
506,
199,
3,
1911,
315,
314,
5113,
570,
14,
199,
199,
624,
199,
774,
13899,
14,
647,
26,
221,
282,
5343,
10059,
367,
25686,
13150,
2295,
14,
199,
624,
199,
199,
646,
5055,
199,
504,
15502,
492,
27608,
199,
646,
7975,
199,
646,
747,
199,
646,
2196,
199,
646,
295,
199,
646,
5145,
199,
646,
5672,
199,
646,
3873,
199,
646,
984,
199,
646,
5549,
199,
646,
900,
199,
199,
646,
1379,
7874,
199,
646,
1379,
7844,
199,
504,
1379,
7844,
492,
636,
452,
363,
199,
199,
363,
452,
4343,
2880,
779,
523,
283,
774,
13899,
297,
199,
566,
421,
199,
318,
2813,
63,
1757,
63,
604,
63,
10548,
8,
4407,
304,
523,
408,
3481,
370,
2813,
314,
1004,
5579,
687,
314,
3105,
1072,
523,
402,
4902,
436,
12850,
7114,
314,
30503,
11101,
2012,
402,
314,
3839,
523,
9132,
2295,
14,
523,
408,
523,
2385,
275,
4072,
14,
7644,
342,
523,
327,
3715,
1924,
1004,
641,
14725,
523,
2385,
275,
359,
76,
14,
1294,
480,
6783,
650,
9,
367,
634,
315,
2385,
61,
523,
327,
4263,
1924,
1004,
1771,
10451,
1830,
17289,
314,
523,
327,
650,
6883,
2763,
1314,
365,
314,
1004,
1329,
523,
2385,
275,
359,
552,
8,
76,
9,
690,
650,
436,
7244,
1674,
904,
8,
76,
59,
19,
5728,
503,
634,
367,
634,
315,
2385,
61,
523,
372,
1867,
78,
1674,
904,
8,
1278,
9,
421,
199,
318,
1336,
63,
1494,
13957,
63,
604,
63,
10548,
8,
4407,
63,
65,
12,
4072,
63,
66,
304,
523,
408,
1173,
4072,
15990,
626,
24010,
1004,
5579,
1041,
523,
4072,
63,
65,
275,
2813,
63,
1757,
63,
604,
63,
10548,
8,
4407,
63,
65,
9,
523,
4072,
63,
66,
275,
2813,
63,
1757,
63,
604,
63,
10548,
8,
4407,
63,
66,
9,
523,
372,
1379,
7844,
14,
1431,
63,
7327,
8,
4407,
63,
65,
12,
4072,
63,
66,
9,
421,
199,
32,
14237,
199,
318,
10111,
7744,
8,
1832,
63,
1813,
304,
523,
408,
2998,
5256,
370,
5647,
282,
2257,
4403,
3734,
1041,
523,
2269,
63,
1813,
275,
747,
14,
2314,
14,
1574,
342,
523,
747,
14,
2314,
14,
873,
8,
1832,
63,
1813,
9,
523,
862,
26,
272,
1995,
523,
3753,
26,
272,
747,
14,
2314,
14,
3584,
342,
272,
747,
14,
2314,
14,
873,
8,
1753,
63,
1813,
9,
421,
199,
533,
25688,
1563,
8,
774,
7844,
14,
774,
7844,
304,
523,
408,
523,
8089,
367,
30350,
1284,
13,
475,
13,
500,
2295,
402,
4902,
16952,
14,
819,
14089,
4466,
1958,
642,
1021,
911,
1218,
282,
7937,
2082,
436,
523,
601,
1842,
367,
2399,
477,
4742,
334,
12897,
314,
1379,
7874,
17035,
9,
436,
523,
1331,
1006,
402,
314,
2222,
13,
6179,
396,
1584,
315,
314,
2082,
14446,
402,
314,
523,
14043,
2884,
14,
819,
710,
849,
5953,
365,
370,
511,
314,
283,
6179,
7,
503,
283,
6179,
14,
13475,
7,
570,
315,
314,
523,
1453,
2082,
14,
221,
1626,
13943,
1443,
506,
2013,
7662,
641,
523,
26621,
12,
503,
701,
4260,
314,
7393,
14884,
63,
14884,
3734,
1750,
14,
819,
961,
1021,
1077,
506,
1007,
28271,
367,
1924,
3748,
4902,
4306,
523,
334,
908,
680,
221,
21107,
1785,
9006,
3102,
5084,
5627,
6358,
17597,
523,
1202,
701,
314,
511,
10554,
370,
12677,
14723,
641,
314,
4046,
1900,
523,
2897,
436,
370,
1255,
31172,
4046,
701,
5204,
14723,
14,
523,
408,
819,
6752,
275,
942,
523,
1900,
63,
3557,
275,
488,
523,
1900,
63,
3557,
63,
513,
275,
942,
819,
485,
5803,
275,
1379,
7844,
14,
5803,
63,
4511,
523,
485,
1113,
275,
1379,
7844,
14,
1113,
63,
4511,
523,
930,
468,
63,
275,
1379,
7844,
14,
13927,
468,
63,
1861,
523,
485,
13927,
468,
275,
1379,
7844,
14,
13927,
468,
63,
4511,
523,
1973,
63,
275,
1379,
7844,
14,
773,
63,
1861,
523,
485,
773,
275,
1379,
7844,
14,
773,
63,
4511,
523,
17112,
63,
275,
1379,
7844,
14,
9259,
63,
1861,
523,
485,
9259,
275,
1379,
7844,
14,
9259,
63,
4511,
819,
327,
22296,
370,
2954,
3365,
4545,
14,
523,
11727,
275,
2560,
452,
12217,
523,
6186,
275,
2560,
885,
12217,
819,
327,
22296,
367,
3365,
1347,
2943,
14,
523,
3651,
4220,
934,
2617,
275,
2560,
5904,
12217,
523,
27815,
63,
5617,
275,
2560,
1986,
63,
773,
12217,
523,
4410,
689,
1149,
63,
5617,
275,
2560,
5555,
63,
773,
12217,
819,
347,
636,
826,
721,
277,
12,
4902,
29,
403,
12,
627,
589,
12,
1011,
829,
304,
272,
291,
14,
6493,
63,
6525,
275,
747,
14,
515,
14,
4832,
8,
736,
14,
515,
14,
3475,
8,
1274,
14,
3020,
59,
16,
2459,
272,
291,
14,
2911,
63,
589,
275,
984,
14,
3020,
59,
17,
2938,
339,
340,
440,
4902,
26,
489,
4902,
275,
747,
14,
2314,
14,
362,
360,
2864,
14884,
63,
14884,
358,
489,
340,
440,
4902,
26,
267,
340,
984,
14,
3246,
508,
283,
2676,
708,
356,
881,
4902,
275,
283,
6179,
14,
13475,
7,
267,
587,
26,
881,
4902,
275,
283,
6179,
7,
272,
291,
14,
6179,
275,
747,
14,
515,
14,
4832,
8,
6179,
9,
272,
291,
14,
889,
63,
11887,
275,
756,
339,
291,
14,
6321,
275,
359,
277,
14,
908,
61,
339,
291,
14,
8489,
63,
1506,
63,
3557,
342,
339,
4775,
14,
5486,
360,
1431,
297,
1379,
7844,
14,
1431,
63,
7327,
9,
339,
327,
16280,
511,
1072,
315,
734,
15,
396,
800,
6789,
701,
849,
14,
272,
327,
3645,
7937,
1561,
880,
2337,
787,
949,
30063,
14,
272,
1736,
694,
275,
747,
14,
515,
14,
904,
360,
548,
297,
4775,
14,
362,
360,
19132,
297,
283,
396,
800,
6789,
1333,
272,
327,
2790,
1736,
9150,
340,
652,
3181,
1133,
2575,
2187,
14,
272,
340,
440,
747,
14,
515,
14,
6027,
8,
19132,
304,
489,
747,
14,
8347,
8,
19132,
9,
339,
4775,
459,
19132,
418,
275,
5549,
14,
22136,
8,
1861,
534,
396,
6179,
3130,
2935,
29,
19132,
9,
339,
6752,
275,
4775,
14,
1935,
360,
6321,
297,
3073,
339,
1613,
8,
774,
13899,
1563,
12,
291,
2843,
826,
9308,
589,
12
] |
[
1898,
334,
67,
9,
6029,
4475,
3277,
14,
2900,
4481,
4644,
14,
199,
3,
3645,
402,
642,
1350,
1233,
365,
10413,
701,
282,
6289,
13,
2487,
4190,
626,
883,
506,
199,
3,
1911,
315,
314,
5113,
570,
14,
199,
199,
624,
199,
774,
13899,
14,
647,
26,
221,
282,
5343,
10059,
367,
25686,
13150,
2295,
14,
199,
624,
199,
199,
646,
5055,
199,
504,
15502,
492,
27608,
199,
646,
7975,
199,
646,
747,
199,
646,
2196,
199,
646,
295,
199,
646,
5145,
199,
646,
5672,
199,
646,
3873,
199,
646,
984,
199,
646,
5549,
199,
646,
900,
199,
199,
646,
1379,
7874,
199,
646,
1379,
7844,
199,
504,
1379,
7844,
492,
636,
452,
363,
199,
199,
363,
452,
4343,
2880,
779,
523,
283,
774,
13899,
297,
199,
566,
421,
199,
318,
2813,
63,
1757,
63,
604,
63,
10548,
8,
4407,
304,
523,
408,
3481,
370,
2813,
314,
1004,
5579,
687,
314,
3105,
1072,
523,
402,
4902,
436,
12850,
7114,
314,
30503,
11101,
2012,
402,
314,
3839,
523,
9132,
2295,
14,
523,
408,
523,
2385,
275,
4072,
14,
7644,
342,
523,
327,
3715,
1924,
1004,
641,
14725,
523,
2385,
275,
359,
76,
14,
1294,
480,
6783,
650,
9,
367,
634,
315,
2385,
61,
523,
327,
4263,
1924,
1004,
1771,
10451,
1830,
17289,
314,
523,
327,
650,
6883,
2763,
1314,
365,
314,
1004,
1329,
523,
2385,
275,
359,
552,
8,
76,
9,
690,
650,
436,
7244,
1674,
904,
8,
76,
59,
19,
5728,
503,
634,
367,
634,
315,
2385,
61,
523,
372,
1867,
78,
1674,
904,
8,
1278,
9,
421,
199,
318,
1336,
63,
1494,
13957,
63,
604,
63,
10548,
8,
4407,
63,
65,
12,
4072,
63,
66,
304,
523,
408,
1173,
4072,
15990,
626,
24010,
1004,
5579,
1041,
523,
4072,
63,
65,
275,
2813,
63,
1757,
63,
604,
63,
10548,
8,
4407,
63,
65,
9,
523,
4072,
63,
66,
275,
2813,
63,
1757,
63,
604,
63,
10548,
8,
4407,
63,
66,
9,
523,
372,
1379,
7844,
14,
1431,
63,
7327,
8,
4407,
63,
65,
12,
4072,
63,
66,
9,
421,
199,
32,
14237,
199,
318,
10111,
7744,
8,
1832,
63,
1813,
304,
523,
408,
2998,
5256,
370,
5647,
282,
2257,
4403,
3734,
1041,
523,
2269,
63,
1813,
275,
747,
14,
2314,
14,
1574,
342,
523,
747,
14,
2314,
14,
873,
8,
1832,
63,
1813,
9,
523,
862,
26,
272,
1995,
523,
3753,
26,
272,
747,
14,
2314,
14,
3584,
342,
272,
747,
14,
2314,
14,
873,
8,
1753,
63,
1813,
9,
421,
199,
533,
25688,
1563,
8,
774,
7844,
14,
774,
7844,
304,
523,
408,
523,
8089,
367,
30350,
1284,
13,
475,
13,
500,
2295,
402,
4902,
16952,
14,
819,
14089,
4466,
1958,
642,
1021,
911,
1218,
282,
7937,
2082,
436,
523,
601,
1842,
367,
2399,
477,
4742,
334,
12897,
314,
1379,
7874,
17035,
9,
436,
523,
1331,
1006,
402,
314,
2222,
13,
6179,
396,
1584,
315,
314,
2082,
14446,
402,
314,
523,
14043,
2884,
14,
819,
710,
849,
5953,
365,
370,
511,
314,
283,
6179,
7,
503,
283,
6179,
14,
13475,
7,
570,
315,
314,
523,
1453,
2082,
14,
221,
1626,
13943,
1443,
506,
2013,
7662,
641,
523,
26621,
12,
503,
701,
4260,
314,
7393,
14884,
63,
14884,
3734,
1750,
14,
819,
961,
1021,
1077,
506,
1007,
28271,
367,
1924,
3748,
4902,
4306,
523,
334,
908,
680,
221,
21107,
1785,
9006,
3102,
5084,
5627,
6358,
17597,
523,
1202,
701,
314,
511,
10554,
370,
12677,
14723,
641,
314,
4046,
1900,
523,
2897,
436,
370,
1255,
31172,
4046,
701,
5204,
14723,
14,
523,
408,
819,
6752,
275,
942,
523,
1900,
63,
3557,
275,
488,
523,
1900,
63,
3557,
63,
513,
275,
942,
819,
485,
5803,
275,
1379,
7844,
14,
5803,
63,
4511,
523,
485,
1113,
275,
1379,
7844,
14,
1113,
63,
4511,
523,
930,
468,
63,
275,
1379,
7844,
14,
13927,
468,
63,
1861,
523,
485,
13927,
468,
275,
1379,
7844,
14,
13927,
468,
63,
4511,
523,
1973,
63,
275,
1379,
7844,
14,
773,
63,
1861,
523,
485,
773,
275,
1379,
7844,
14,
773,
63,
4511,
523,
17112,
63,
275,
1379,
7844,
14,
9259,
63,
1861,
523,
485,
9259,
275,
1379,
7844,
14,
9259,
63,
4511,
819,
327,
22296,
370,
2954,
3365,
4545,
14,
523,
11727,
275,
2560,
452,
12217,
523,
6186,
275,
2560,
885,
12217,
819,
327,
22296,
367,
3365,
1347,
2943,
14,
523,
3651,
4220,
934,
2617,
275,
2560,
5904,
12217,
523,
27815,
63,
5617,
275,
2560,
1986,
63,
773,
12217,
523,
4410,
689,
1149,
63,
5617,
275,
2560,
5555,
63,
773,
12217,
819,
347,
636,
826,
721,
277,
12,
4902,
29,
403,
12,
627,
589,
12,
1011,
829,
304,
272,
291,
14,
6493,
63,
6525,
275,
747,
14,
515,
14,
4832,
8,
736,
14,
515,
14,
3475,
8,
1274,
14,
3020,
59,
16,
2459,
272,
291,
14,
2911,
63,
589,
275,
984,
14,
3020,
59,
17,
2938,
339,
340,
440,
4902,
26,
489,
4902,
275,
747,
14,
2314,
14,
362,
360,
2864,
14884,
63,
14884,
358,
489,
340,
440,
4902,
26,
267,
340,
984,
14,
3246,
508,
283,
2676,
708,
356,
881,
4902,
275,
283,
6179,
14,
13475,
7,
267,
587,
26,
881,
4902,
275,
283,
6179,
7,
272,
291,
14,
6179,
275,
747,
14,
515,
14,
4832,
8,
6179,
9,
272,
291,
14,
889,
63,
11887,
275,
756,
339,
291,
14,
6321,
275,
359,
277,
14,
908,
61,
339,
291,
14,
8489,
63,
1506,
63,
3557,
342,
339,
4775,
14,
5486,
360,
1431,
297,
1379,
7844,
14,
1431,
63,
7327,
9,
339,
327,
16280,
511,
1072,
315,
734,
15,
396,
800,
6789,
701,
849,
14,
272,
327,
3645,
7937,
1561,
880,
2337,
787,
949,
30063,
14,
272,
1736,
694,
275,
747,
14,
515,
14,
904,
360,
548,
297,
4775,
14,
362,
360,
19132,
297,
283,
396,
800,
6789,
1333,
272,
327,
2790,
1736,
9150,
340,
652,
3181,
1133,
2575,
2187,
14,
272,
340,
440,
747,
14,
515,
14,
6027,
8,
19132,
304,
489,
747,
14,
8347,
8,
19132,
9,
339,
4775,
459,
19132,
418,
275,
5549,
14,
22136,
8,
1861,
534,
396,
6179,
3130,
2935,
29,
19132,
9,
339,
6752,
275,
4775,
14,
1935,
360,
6321,
297,
3073,
339,
1613,
8,
774,
13899,
1563,
12,
291,
2843,
826,
9308,
589,
12,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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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
] |
VirtusLab/ansible-modules-extras
|
monitoring/newrelic_deployment.py
|
131
|
4675
|
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Copyright 2013 Matt Coddington <coddington@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/>.
DOCUMENTATION = '''
---
module: newrelic_deployment
version_added: "1.2"
author: "Matt Coddington (@mcodd)"
short_description: Notify newrelic about app deployments
description:
- Notify newrelic about app deployments (see https://docs.newrelic.com/docs/apm/new-relic-apm/maintenance/deployment-notifications#api)
options:
token:
description:
- API token, to place in the x-api-key header.
required: true
app_name:
description:
- (one of app_name or application_id are required) The value of app_name in the newrelic.yml file used by the application
required: false
application_id:
description:
- (one of app_name or application_id are required) The application id, found in the URL when viewing the application in RPM
required: false
changelog:
description:
- A list of changes for this deployment
required: false
description:
description:
- Text annotation for the deployment - notes for you
required: false
revision:
description:
- A revision number (e.g., git commit SHA)
required: false
user:
description:
- The name of the user/process that triggered this deployment
required: false
appname:
description:
- Name of the application
required: false
environment:
description:
- The environment for this deployment
required: false
validate_certs:
description:
- If C(no), SSL certificates will not be validated. This should only be used
on personally controlled sites using self-signed certificates.
required: false
default: 'yes'
choices: ['yes', 'no']
version_added: 1.5.1
requirements: []
'''
EXAMPLES = '''
- newrelic_deployment: token=AAAAAA
app_name=myapp
user='ansible deployment'
revision=1.0
'''
import urllib
# ===========================================
# Module execution.
#
def main():
module = AnsibleModule(
argument_spec=dict(
token=dict(required=True),
app_name=dict(required=False),
application_id=dict(required=False),
changelog=dict(required=False),
description=dict(required=False),
revision=dict(required=False),
user=dict(required=False),
appname=dict(required=False),
environment=dict(required=False),
validate_certs = dict(default='yes', type='bool'),
),
required_one_of=[['app_name', 'application_id']],
supports_check_mode=True
)
# build list of params
params = {}
if module.params["app_name"] and module.params["application_id"]:
module.fail_json(msg="only one of 'app_name' or 'application_id' can be set")
if module.params["app_name"]:
params["app_name"] = module.params["app_name"]
elif module.params["application_id"]:
params["application_id"] = module.params["application_id"]
else:
module.fail_json(msg="you must set one of 'app_name' or 'application_id'")
for item in [ "changelog", "description", "revision", "user", "appname", "environment" ]:
if module.params[item]:
params[item] = module.params[item]
# If we're in check mode, just exit pretending like we succeeded
if module.check_mode:
module.exit_json(changed=True)
# Send the data to NewRelic
url = "https://rpm.newrelic.com/deployments.xml"
data = urllib.urlencode(params)
headers = {
'x-api-key': module.params["token"],
}
response, info = fetch_url(module, url, data=data, headers=headers)
if info['status'] in (200, 201):
module.exit_json(changed=True)
else:
module.fail_json(msg="unable to update newrelic: %s" % info['msg'])
# import module snippets
from ansible.module_utils.basic import *
from ansible.module_utils.urls import *
main()
|
gpl-3.0
|
[
3381,
2647,
15,
1393,
15,
1548,
199,
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
199,
3,
1898,
6171,
31653,
445,
364,
1098,
1860,
665,
331,
617,
31673,
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,
8948,
275,
1449,
199,
2595,
199,
578,
26,
892,
264,
606,
63,
13605,
199,
1023,
63,
3270,
26,
298,
17,
14,
18,
2,
199,
2502,
26,
298,
45,
6796,
445,
364,
1098,
1860,
8593,
77,
331,
617,
2924,
199,
3612,
63,
1802,
26,
31949,
892,
264,
606,
3595,
1145,
12287,
1470,
199,
1802,
26,
2043,
446,
31949,
892,
264,
606,
3595,
1145,
12287,
1470,
334,
3239,
4178,
921,
4757,
14,
1222,
264,
606,
14,
957,
15,
4757,
15,
439,
77,
15,
1222,
13,
264,
606,
13,
439,
77,
15,
19725,
15,
13605,
13,
12782,
3,
1246,
9,
199,
1419,
26,
523,
1526,
26,
272,
1369,
26,
489,
446,
3261,
1526,
12,
370,
4192,
315,
314,
671,
13,
1246,
13,
498,
1406,
14,
272,
1415,
26,
2549,
523,
1145,
63,
354,
26,
272,
1369,
26,
489,
446,
334,
368,
402,
1145,
63,
354,
503,
4223,
63,
344,
787,
1415,
9,
710,
574,
402,
1145,
63,
354,
315,
314,
892,
264,
606,
14,
11714,
570,
1202,
701,
314,
4223,
272,
1415,
26,
3055,
523,
4223,
63,
344,
26,
272,
1369,
26,
489,
446,
334,
368,
402,
1145,
63,
354,
503,
4223,
63,
344,
787,
1415,
9,
710,
4223,
1305,
12,
1911,
315,
314,
2851,
1380,
2455,
316,
314,
4223,
315,
820,
10793,
272,
1415,
26,
3055,
523,
1570,
793,
26,
272,
1369,
26,
489,
446,
437,
769,
402,
4493,
367,
642,
14295,
272,
1415,
26,
3055,
523,
1369,
26,
272,
1369,
26,
489,
446,
4516,
11262,
367,
314,
14295,
446,
12681,
367,
1265,
272,
1415,
26,
3055,
523,
6974,
26,
272,
1369,
26,
489,
446,
437,
6974,
1329,
334,
69,
14,
71,
2020,
6135,
5532,
12002,
9,
272,
1415,
26,
3055,
523,
922,
26,
272,
1369,
26,
489,
446,
710,
536,
402,
314,
922,
15,
1412,
626,
15572,
642,
14295,
272,
1415,
26,
3055,
523,
20268,
26,
272,
1369,
26,
489,
446,
2812,
402,
314,
4223,
272,
1415,
26,
3055,
523,
3734,
26,
272,
1369,
26,
489,
446,
710,
3734,
367,
642,
14295,
272,
1415,
26,
3055,
523,
4107,
63,
8356,
26,
272,
1369,
26,
489,
446,
982,
445,
8,
889,
395,
7799,
14512,
911,
440,
506,
16468,
14,
961,
1077,
1454,
506,
1202,
267,
641,
4954,
1183,
22284,
15424,
1808,
291,
13,
1737,
14512,
14,
272,
1415,
26,
3055,
272,
849,
26,
283,
5066,
7,
272,
3415,
26,
788,
5066,
297,
283,
889,
418,
272,
1015,
63,
3270,
26,
413,
14,
21,
14,
17,
199,
199,
7538,
26,
942,
199,
2344,
199,
199,
8918,
275,
1449,
199,
13,
892,
264,
606,
63,
13605,
26,
1526,
29,
6151,
2276,
2432,
1145,
63,
354,
29,
1662,
571,
2432,
922,
534,
4853,
14295,
7,
2432,
6974,
29,
17,
14,
16,
199,
2344,
199,
199,
646,
4011,
199,
199,
3,
19469,
17575,
199,
3,
5673,
6451,
14,
199,
3,
199,
199,
318,
2446,
837,
339,
859,
275,
6953,
8,
267,
1423,
63,
1650,
29,
807,
8,
288,
1526,
29,
807,
8,
2427,
29,
549,
395,
288,
1145,
63,
354,
29,
807,
8,
2427,
29,
797,
395,
288,
4223,
63,
344,
29,
807,
8,
2427,
29,
797,
395,
288,
1570,
793,
29,
807,
8,
2427,
29,
797,
395,
288,
1369,
29,
807,
8,
2427,
29,
797,
395,
288,
6974,
29,
807,
8,
2427,
29,
797,
395,
288,
922,
29,
807,
8,
2427,
29,
797,
395,
288,
20268,
29,
807,
8,
2427,
29,
797,
395,
288,
3734,
29,
807,
8,
2427,
29,
797,
395,
288,
4107,
63,
8356,
275,
1211,
8,
885,
534,
5066,
297,
730,
534,
2245,
659,
267,
2318,
267,
1415,
63,
368,
63,
1618,
1524,
459,
571,
63,
354,
297,
283,
3578,
63,
344,
2157,
267,
5171,
63,
1074,
63,
632,
29,
549,
272,
776,
339,
327,
1900,
769,
402,
1862,
272,
1862,
275,
1052,
272,
340,
859,
14,
1162,
905,
571,
63,
354,
937,
436,
859,
14,
1162,
905,
3578,
63,
344,
6229,
267,
859,
14,
1633,
63,
1001,
8,
1328,
628,
2118,
1373,
402,
283,
571,
63,
354,
7,
503,
283,
3578,
63,
344,
7,
883,
506,
663,
531,
339,
340,
859,
14,
1162,
905,
571,
63,
354,
6229,
267,
1862,
905,
571,
63,
354,
937,
275,
859,
14,
1162,
905,
571,
63,
354,
937,
272,
916,
859,
14,
1162,
905,
3578,
63,
344,
6229,
267,
1862,
905,
3578,
63,
344,
937,
275,
859,
14,
1162,
905,
3578,
63,
344,
937,
272,
587,
26,
267,
859,
14,
1633,
63,
1001,
8,
1328,
628,
13297,
1471,
663,
1373,
402,
283,
571,
63,
354,
7,
503,
283,
3578,
63,
344,
9859,
2286,
367,
1242,
315,
359,
298,
23436,
401,
298,
1802,
401,
298,
5792,
401,
298,
751,
401,
298,
21653,
401,
298,
5418,
2,
16246,
267,
340,
859,
14,
1162,
59,
1053,
2189,
288,
1862,
59,
1053,
61,
275,
859,
14,
1162,
59,
1053,
61,
339,
327,
982,
781,
3984,
315,
1104,
818,
12,
2951,
4458,
876,
724,
1098,
2839,
781,
19268,
272,
340,
859,
14,
1074,
63,
632,
26,
267,
859,
14,
2224,
63,
1001,
8,
2489,
29,
549,
9,
339,
327,
10217
] |
[
2647,
15,
1393,
15,
1548,
199,
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
199,
3,
1898,
6171,
31653,
445,
364,
1098,
1860,
665,
331,
617,
31673,
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,
8948,
275,
1449,
199,
2595,
199,
578,
26,
892,
264,
606,
63,
13605,
199,
1023,
63,
3270,
26,
298,
17,
14,
18,
2,
199,
2502,
26,
298,
45,
6796,
445,
364,
1098,
1860,
8593,
77,
331,
617,
2924,
199,
3612,
63,
1802,
26,
31949,
892,
264,
606,
3595,
1145,
12287,
1470,
199,
1802,
26,
2043,
446,
31949,
892,
264,
606,
3595,
1145,
12287,
1470,
334,
3239,
4178,
921,
4757,
14,
1222,
264,
606,
14,
957,
15,
4757,
15,
439,
77,
15,
1222,
13,
264,
606,
13,
439,
77,
15,
19725,
15,
13605,
13,
12782,
3,
1246,
9,
199,
1419,
26,
523,
1526,
26,
272,
1369,
26,
489,
446,
3261,
1526,
12,
370,
4192,
315,
314,
671,
13,
1246,
13,
498,
1406,
14,
272,
1415,
26,
2549,
523,
1145,
63,
354,
26,
272,
1369,
26,
489,
446,
334,
368,
402,
1145,
63,
354,
503,
4223,
63,
344,
787,
1415,
9,
710,
574,
402,
1145,
63,
354,
315,
314,
892,
264,
606,
14,
11714,
570,
1202,
701,
314,
4223,
272,
1415,
26,
3055,
523,
4223,
63,
344,
26,
272,
1369,
26,
489,
446,
334,
368,
402,
1145,
63,
354,
503,
4223,
63,
344,
787,
1415,
9,
710,
4223,
1305,
12,
1911,
315,
314,
2851,
1380,
2455,
316,
314,
4223,
315,
820,
10793,
272,
1415,
26,
3055,
523,
1570,
793,
26,
272,
1369,
26,
489,
446,
437,
769,
402,
4493,
367,
642,
14295,
272,
1415,
26,
3055,
523,
1369,
26,
272,
1369,
26,
489,
446,
4516,
11262,
367,
314,
14295,
446,
12681,
367,
1265,
272,
1415,
26,
3055,
523,
6974,
26,
272,
1369,
26,
489,
446,
437,
6974,
1329,
334,
69,
14,
71,
2020,
6135,
5532,
12002,
9,
272,
1415,
26,
3055,
523,
922,
26,
272,
1369,
26,
489,
446,
710,
536,
402,
314,
922,
15,
1412,
626,
15572,
642,
14295,
272,
1415,
26,
3055,
523,
20268,
26,
272,
1369,
26,
489,
446,
2812,
402,
314,
4223,
272,
1415,
26,
3055,
523,
3734,
26,
272,
1369,
26,
489,
446,
710,
3734,
367,
642,
14295,
272,
1415,
26,
3055,
523,
4107,
63,
8356,
26,
272,
1369,
26,
489,
446,
982,
445,
8,
889,
395,
7799,
14512,
911,
440,
506,
16468,
14,
961,
1077,
1454,
506,
1202,
267,
641,
4954,
1183,
22284,
15424,
1808,
291,
13,
1737,
14512,
14,
272,
1415,
26,
3055,
272,
849,
26,
283,
5066,
7,
272,
3415,
26,
788,
5066,
297,
283,
889,
418,
272,
1015,
63,
3270,
26,
413,
14,
21,
14,
17,
199,
199,
7538,
26,
942,
199,
2344,
199,
199,
8918,
275,
1449,
199,
13,
892,
264,
606,
63,
13605,
26,
1526,
29,
6151,
2276,
2432,
1145,
63,
354,
29,
1662,
571,
2432,
922,
534,
4853,
14295,
7,
2432,
6974,
29,
17,
14,
16,
199,
2344,
199,
199,
646,
4011,
199,
199,
3,
19469,
17575,
199,
3,
5673,
6451,
14,
199,
3,
199,
199,
318,
2446,
837,
339,
859,
275,
6953,
8,
267,
1423,
63,
1650,
29,
807,
8,
288,
1526,
29,
807,
8,
2427,
29,
549,
395,
288,
1145,
63,
354,
29,
807,
8,
2427,
29,
797,
395,
288,
4223,
63,
344,
29,
807,
8,
2427,
29,
797,
395,
288,
1570,
793,
29,
807,
8,
2427,
29,
797,
395,
288,
1369,
29,
807,
8,
2427,
29,
797,
395,
288,
6974,
29,
807,
8,
2427,
29,
797,
395,
288,
922,
29,
807,
8,
2427,
29,
797,
395,
288,
20268,
29,
807,
8,
2427,
29,
797,
395,
288,
3734,
29,
807,
8,
2427,
29,
797,
395,
288,
4107,
63,
8356,
275,
1211,
8,
885,
534,
5066,
297,
730,
534,
2245,
659,
267,
2318,
267,
1415,
63,
368,
63,
1618,
1524,
459,
571,
63,
354,
297,
283,
3578,
63,
344,
2157,
267,
5171,
63,
1074,
63,
632,
29,
549,
272,
776,
339,
327,
1900,
769,
402,
1862,
272,
1862,
275,
1052,
272,
340,
859,
14,
1162,
905,
571,
63,
354,
937,
436,
859,
14,
1162,
905,
3578,
63,
344,
6229,
267,
859,
14,
1633,
63,
1001,
8,
1328,
628,
2118,
1373,
402,
283,
571,
63,
354,
7,
503,
283,
3578,
63,
344,
7,
883,
506,
663,
531,
339,
340,
859,
14,
1162,
905,
571,
63,
354,
6229,
267,
1862,
905,
571,
63,
354,
937,
275,
859,
14,
1162,
905,
571,
63,
354,
937,
272,
916,
859,
14,
1162,
905,
3578,
63,
344,
6229,
267,
1862,
905,
3578,
63,
344,
937,
275,
859,
14,
1162,
905,
3578,
63,
344,
937,
272,
587,
26,
267,
859,
14,
1633,
63,
1001,
8,
1328,
628,
13297,
1471,
663,
1373,
402,
283,
571,
63,
354,
7,
503,
283,
3578,
63,
344,
9859,
2286,
367,
1242,
315,
359,
298,
23436,
401,
298,
1802,
401,
298,
5792,
401,
298,
751,
401,
298,
21653,
401,
298,
5418,
2,
16246,
267,
340,
859,
14,
1162,
59,
1053,
2189,
288,
1862,
59,
1053,
61,
275,
859,
14,
1162,
59,
1053,
61,
339,
327,
982,
781,
3984,
315,
1104,
818,
12,
2951,
4458,
876,
724,
1098,
2839,
781,
19268,
272,
340,
859,
14,
1074,
63,
632,
26,
267,
859,
14,
2224,
63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1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
cjellick/rancher
|
tests/validation/tests/v3_api/test_gke_cluster.py
|
4
|
3791
|
from .common import * # NOQA
import requests
import pytest
CREDENTIALS = os.environ.get('RANCHER_GKE_CREDENTIAL', "")
GKE_MASTER_VERSION = os.environ.get('RANCHER_GKE_MASTER_VERSION', "")
gkecredential = pytest.mark.skipif(not CREDENTIALS, reason='GKE Credentials '
'not provided, cannot create cluster')
@gkecredential
def test_create_gke_cluster():
# Obtain GKE config data
gke_version, credential_data = get_gke_version_credentials()
client, cluster = create_and_validate_gke_cluster("test-auto-gke",
gke_version,
credential_data)
cluster_cleanup(client, cluster)
def create_and_validate_gke_cluster(name, version, credential_data):
gke_config = get_gke_config(name, version, credential_data)
client = get_user_client()
print("Cluster creation")
cluster = client.create_cluster(gke_config)
print(cluster)
cluster = validate_cluster(client, cluster, check_intermediate_state=True,
skipIngresscheck=True)
return client, cluster
def get_gke_version_credentials(multiple_versions=False):
credfilename = "credential.txt"
PATH = os.path.dirname(os.path.realpath(__file__))
credfilepath = PATH + "/" + credfilename
# The json GKE credentials file is being written to a file and then re-read
f = open(credfilepath, "w")
f.write(CREDENTIALS)
f.close()
credentialdata = readDataFile(os.path.dirname(os.path.realpath(__file__)) +
"/", credfilename)
print(credentialdata)
if not GKE_MASTER_VERSION:
data_test = {
"credentials": credentialdata,
"zone": "us-central1-f",
"projectId": "rancher-qa"
}
headers = {"Content-Type": "application/json",
"Accept": "application/json",
"Authorization": "Bearer " + USER_TOKEN}
gke_version_url = CATTLE_TEST_URL + "/meta/gkeVersions"
print(gke_version_url)
response = requests.post(gke_version_url, json=data_test,
verify=False, headers=headers)
assert response.status_code == 200
assert response.content is not None
print(response.content)
json_response = json.loads(response.content)
validMasterVersions = json_response["validMasterVersions"]
if multiple_versions and len(validMasterVersions) > 1:
gkemasterversion = [validMasterVersions[0],
validMasterVersions[-1]]
else:
gkemasterversion = validMasterVersions[0]
else:
gkemasterversion = GKE_MASTER_VERSION
print(gkemasterversion)
return gkemasterversion, credentialdata
def get_gke_config(name, version, credential_data):
# Get GKE configuration
gke_config = {
"googleKubernetesEngineConfig": {
"diskSizeGb": 100,
"enableAlphaFeature": False,
"enableHorizontalPodAutoscaling": True,
"enableHttpLoadBalancing": True,
"enableKubernetesDashboard": False,
"enableLegacyAbac": False,
"enableNetworkPolicyConfig": True,
"enableStackdriverLogging": True,
"enableStackdriverMonitoring": True,
"masterVersion": version,
"machineType": "g1-small",
"type": "googleKubernetesEngineConfig",
"nodeCount": 3,
"zone": "us-central1-f",
"clusterIpv4Cidr": " ",
"credential": credential_data,
"projectId": "rancher-qa",
},
"name": name,
"type": "cluster"
}
return gke_config
|
apache-2.0
|
[
504,
1275,
2330,
492,
627,
257,
327,
20432,
199,
646,
4145,
199,
646,
4613,
199,
199,
30553,
8246,
51,
275,
747,
14,
2314,
14,
362,
360,
50,
20139,
540,
63,
39,
2430,
63,
30553,
8246,
297,
6899,
199,
39,
2430,
63,
25050,
63,
4612,
275,
747,
14,
2314,
14,
362,
360,
50,
20139,
540,
63,
39,
2430,
63,
25050,
63,
4612,
297,
6899,
199,
199,
71,
415,
15591,
275,
4613,
14,
1657,
14,
22696,
8,
1397,
445,
7387,
8246,
51,
12,
4499,
534,
39,
2430,
23934,
283,
3521,
283,
1397,
2741,
12,
3913,
1218,
4350,
358,
421,
199,
32,
71,
415,
15591,
199,
318,
511,
63,
981,
63,
71,
415,
63,
4201,
837,
272,
327,
17985,
877,
598,
2430,
1101,
666,
272,
486,
415,
63,
1023,
12,
16338,
63,
576,
275,
664,
63,
71,
415,
63,
1023,
63,
6942,
342,
272,
1890,
12,
4350,
275,
1218,
63,
460,
63,
3502,
63,
71,
415,
63,
4201,
480,
396,
13,
2495,
13,
71,
415,
401,
10028,
486,
415,
63,
1023,
12,
10028,
16338,
63,
576,
9,
272,
4350,
63,
7661,
8,
1258,
12,
4350,
9,
421,
199,
318,
1218,
63,
460,
63,
3502,
63,
71,
415,
63,
4201,
8,
354,
12,
1015,
12,
16338,
63,
576,
304,
272,
486,
415,
63,
888,
275,
664,
63,
71,
415,
63,
888,
8,
354,
12,
1015,
12,
16338,
63,
576,
9,
272,
1890,
275,
664,
63,
751,
63,
1258,
342,
272,
870,
480,
9581,
7143,
531,
272,
4350,
275,
1890,
14,
981,
63,
4201,
8,
71,
415,
63,
888,
9,
272,
870,
8,
4201,
9,
272,
4350,
275,
4107,
63,
4201,
8,
1258,
12,
4350,
12,
1104,
63,
15940,
63,
929,
29,
549,
12,
3044,
3372,
607,
3313,
1074,
29,
549,
9,
272,
372,
1890,
12,
4350,
421,
199,
318,
664,
63,
71,
415,
63,
1023,
63,
6942,
8,
6048,
63,
6234,
29,
797,
304,
272,
22314,
1501,
275,
298,
15591,
14,
2424,
2,
272,
15097,
275,
747,
14,
515,
14,
3475,
8,
736,
14,
515,
14,
11091,
3460,
493,
8964,
272,
22314,
7218,
275,
15097,
435,
10609,
435,
22314,
1501,
339,
327,
710,
2022,
598,
2430,
6235,
570,
365,
3769,
5313,
370,
282,
570,
436,
2066,
295,
13,
739,
339,
289,
275,
1551,
8,
18639,
7218,
12,
298,
87,
531,
272,
289,
14,
952,
8,
30553,
8246,
51,
9,
272,
289,
14,
1600,
342,
339,
16338,
576,
275,
1586,
1451,
1173,
8,
736,
14,
515,
14,
3475,
8,
736,
14,
515,
14,
11091,
3460,
493,
8964,
435,
3303,
3286,
401,
22314,
1501,
9,
272,
870,
8,
15591,
576,
9,
339,
340,
440,
598,
2430,
63,
25050,
63,
4612,
26,
267,
666,
63,
396,
275,
469,
288,
298,
6942,
582,
16338,
576,
12,
288,
298,
2619,
582,
298,
527,
13,
16067,
17,
13,
70,
401,
288,
298,
1715,
1304,
582,
298,
2965,
281,
13,
7096,
2,
267,
789,
267,
2323,
275,
2420,
2714,
13,
804,
582,
298,
3578,
15,
1001,
401,
673,
298,
8422,
582,
298,
3578,
15,
1001,
401,
673,
298,
11626,
582,
298,
3655,
21462,
298,
435,
13044,
63,
8803,
93,
398,
486,
415,
63,
1023,
63,
633,
275,
445,
11712,
906,
63,
2864,
63,
2632,
435,
3286,
2024,
15,
71,
415,
21167,
2,
267,
870,
8,
71,
415,
63,
1023,
63,
633,
9,
267,
1177,
275,
4145,
14,
1932,
8,
71,
415,
63,
1023,
63,
633,
12,
2022,
29,
576,
63,
396,
12,
639,
4911,
29,
797,
12,
2323,
29,
2139,
9,
398,
702,
1177,
14,
1205,
63,
600,
508,
1926,
267,
702,
1177,
14,
1317,
365,
440,
488,
267,
870,
8,
1310,
14,
1317,
9,
267,
2022,
63,
1310,
275,
2022,
14,
3640,
8,
1310,
14,
1317,
9,
267,
1686,
12288,
21167,
275,
2022,
63,
1310,
905,
1078,
12288,
21167,
937,
267,
340,
3663,
63,
6234,
436,
822,
8,
1078,
12288,
21167,
9,
690,
413,
26,
288,
486,
415,
4133,
1023,
275,
359,
1078,
12288,
21167,
59,
16,
467,
1816,
1686,
12288,
21167,
1988,
17,
2677,
267,
587,
26,
288,
486,
415,
4133,
1023,
275,
1686,
12288,
21167,
59,
16,
61,
272,
587,
26,
267,
486,
415,
4133,
1023,
275,
598,
2430,
63,
25050,
63,
4612,
272,
870,
8,
71,
415,
4133,
1023,
9,
272,
372,
486,
415,
4133,
1023,
12,
16338,
576,
421,
199,
318,
664,
63,
71,
415,
63,
888,
8,
354,
12,
1015,
12,
16338,
63,
576,
304,
339,
327,
2372,
598,
2430,
2897,
272,
486,
415,
63,
888,
275,
469,
267,
298,
3098,
43,
12183,
8524,
2028,
582,
469,
288,
298,
4032,
2320,
30271,
582,
2948,
12,
288,
298,
4296,
16192,
5968,
582,
756,
12,
288,
298,
4296,
19918,
25928,
3358,
12153,
582,
715,
12,
288,
298,
4296,
5779,
6200,
13129,
15763,
582,
715,
12,
288,
298,
4296,
43,
12183,
30122,
582,
756,
12,
288,
298,
4296,
22628,
5583,
645,
582,
756,
12,
288,
298,
4296,
4491,
4845,
2028,
582,
715,
12,
288,
298,
4296,
4851,
3090,
14054,
582,
715,
12,
288,
298,
4296,
4851,
3090,
13189,
316,
582,
715,
12,
288,
298,
4133,
3353,
582,
1015,
12,
288,
298,
6744,
804,
582,
298,
71,
17,
13,
7241,
401,
288,
298,
466,
582,
298,
3098,
43,
12183,
8524,
2028,
401,
288,
298,
932,
2353,
582,
650,
12,
288,
298,
2619,
582,
298,
527,
13,
16067,
17,
13,
70,
401,
288,
298,
4201,
1762,
20,
21456,
82,
582,
298,
3872,
288,
298,
15591,
582,
16338,
63,
576,
12,
288,
298,
1715,
1304,
582,
298,
2965,
281,
13,
7096,
401,
398,
1660,
267,
298,
354,
582,
536,
12,
267,
298,
466,
582,
298,
4201,
2,
272,
789,
339,
372,
486,
415,
63,
888,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
1275,
2330,
492,
627,
257,
327,
20432,
199,
646,
4145,
199,
646,
4613,
199,
199,
30553,
8246,
51,
275,
747,
14,
2314,
14,
362,
360,
50,
20139,
540,
63,
39,
2430,
63,
30553,
8246,
297,
6899,
199,
39,
2430,
63,
25050,
63,
4612,
275,
747,
14,
2314,
14,
362,
360,
50,
20139,
540,
63,
39,
2430,
63,
25050,
63,
4612,
297,
6899,
199,
199,
71,
415,
15591,
275,
4613,
14,
1657,
14,
22696,
8,
1397,
445,
7387,
8246,
51,
12,
4499,
534,
39,
2430,
23934,
283,
3521,
283,
1397,
2741,
12,
3913,
1218,
4350,
358,
421,
199,
32,
71,
415,
15591,
199,
318,
511,
63,
981,
63,
71,
415,
63,
4201,
837,
272,
327,
17985,
877,
598,
2430,
1101,
666,
272,
486,
415,
63,
1023,
12,
16338,
63,
576,
275,
664,
63,
71,
415,
63,
1023,
63,
6942,
342,
272,
1890,
12,
4350,
275,
1218,
63,
460,
63,
3502,
63,
71,
415,
63,
4201,
480,
396,
13,
2495,
13,
71,
415,
401,
10028,
486,
415,
63,
1023,
12,
10028,
16338,
63,
576,
9,
272,
4350,
63,
7661,
8,
1258,
12,
4350,
9,
421,
199,
318,
1218,
63,
460,
63,
3502,
63,
71,
415,
63,
4201,
8,
354,
12,
1015,
12,
16338,
63,
576,
304,
272,
486,
415,
63,
888,
275,
664,
63,
71,
415,
63,
888,
8,
354,
12,
1015,
12,
16338,
63,
576,
9,
272,
1890,
275,
664,
63,
751,
63,
1258,
342,
272,
870,
480,
9581,
7143,
531,
272,
4350,
275,
1890,
14,
981,
63,
4201,
8,
71,
415,
63,
888,
9,
272,
870,
8,
4201,
9,
272,
4350,
275,
4107,
63,
4201,
8,
1258,
12,
4350,
12,
1104,
63,
15940,
63,
929,
29,
549,
12,
3044,
3372,
607,
3313,
1074,
29,
549,
9,
272,
372,
1890,
12,
4350,
421,
199,
318,
664,
63,
71,
415,
63,
1023,
63,
6942,
8,
6048,
63,
6234,
29,
797,
304,
272,
22314,
1501,
275,
298,
15591,
14,
2424,
2,
272,
15097,
275,
747,
14,
515,
14,
3475,
8,
736,
14,
515,
14,
11091,
3460,
493,
8964,
272,
22314,
7218,
275,
15097,
435,
10609,
435,
22314,
1501,
339,
327,
710,
2022,
598,
2430,
6235,
570,
365,
3769,
5313,
370,
282,
570,
436,
2066,
295,
13,
739,
339,
289,
275,
1551,
8,
18639,
7218,
12,
298,
87,
531,
272,
289,
14,
952,
8,
30553,
8246,
51,
9,
272,
289,
14,
1600,
342,
339,
16338,
576,
275,
1586,
1451,
1173,
8,
736,
14,
515,
14,
3475,
8,
736,
14,
515,
14,
11091,
3460,
493,
8964,
435,
3303,
3286,
401,
22314,
1501,
9,
272,
870,
8,
15591,
576,
9,
339,
340,
440,
598,
2430,
63,
25050,
63,
4612,
26,
267,
666,
63,
396,
275,
469,
288,
298,
6942,
582,
16338,
576,
12,
288,
298,
2619,
582,
298,
527,
13,
16067,
17,
13,
70,
401,
288,
298,
1715,
1304,
582,
298,
2965,
281,
13,
7096,
2,
267,
789,
267,
2323,
275,
2420,
2714,
13,
804,
582,
298,
3578,
15,
1001,
401,
673,
298,
8422,
582,
298,
3578,
15,
1001,
401,
673,
298,
11626,
582,
298,
3655,
21462,
298,
435,
13044,
63,
8803,
93,
398,
486,
415,
63,
1023,
63,
633,
275,
445,
11712,
906,
63,
2864,
63,
2632,
435,
3286,
2024,
15,
71,
415,
21167,
2,
267,
870,
8,
71,
415,
63,
1023,
63,
633,
9,
267,
1177,
275,
4145,
14,
1932,
8,
71,
415,
63,
1023,
63,
633,
12,
2022,
29,
576,
63,
396,
12,
639,
4911,
29,
797,
12,
2323,
29,
2139,
9,
398,
702,
1177,
14,
1205,
63,
600,
508,
1926,
267,
702,
1177,
14,
1317,
365,
440,
488,
267,
870,
8,
1310,
14,
1317,
9,
267,
2022,
63,
1310,
275,
2022,
14,
3640,
8,
1310,
14,
1317,
9,
267,
1686,
12288,
21167,
275,
2022,
63,
1310,
905,
1078,
12288,
21167,
937,
267,
340,
3663,
63,
6234,
436,
822,
8,
1078,
12288,
21167,
9,
690,
413,
26,
288,
486,
415,
4133,
1023,
275,
359,
1078,
12288,
21167,
59,
16,
467,
1816,
1686,
12288,
21167,
1988,
17,
2677,
267,
587,
26,
288,
486,
415,
4133,
1023,
275,
1686,
12288,
21167,
59,
16,
61,
272,
587,
26,
267,
486,
415,
4133,
1023,
275,
598,
2430,
63,
25050,
63,
4612,
272,
870,
8,
71,
415,
4133,
1023,
9,
272,
372,
486,
415,
4133,
1023,
12,
16338,
576,
421,
199,
318,
664,
63,
71,
415,
63,
888,
8,
354,
12,
1015,
12,
16338,
63,
576,
304,
339,
327,
2372,
598,
2430,
2897,
272,
486,
415,
63,
888,
275,
469,
267,
298,
3098,
43,
12183,
8524,
2028,
582,
469,
288,
298,
4032,
2320,
30271,
582,
2948,
12,
288,
298,
4296,
16192,
5968,
582,
756,
12,
288,
298,
4296,
19918,
25928,
3358,
12153,
582,
715,
12,
288,
298,
4296,
5779,
6200,
13129,
15763,
582,
715,
12,
288,
298,
4296,
43,
12183,
30122,
582,
756,
12,
288,
298,
4296,
22628,
5583,
645,
582,
756,
12,
288,
298,
4296,
4491,
4845,
2028,
582,
715,
12,
288,
298,
4296,
4851,
3090,
14054,
582,
715,
12,
288,
298,
4296,
4851,
3090,
13189,
316,
582,
715,
12,
288,
298,
4133,
3353,
582,
1015,
12,
288,
298,
6744,
804,
582,
298,
71,
17,
13,
7241,
401,
288,
298,
466,
582,
298,
3098,
43,
12183,
8524,
2028,
401,
288,
298,
932,
2353,
582,
650,
12,
288,
298,
2619,
582,
298,
527,
13,
16067,
17,
13,
70,
401,
288,
298,
4201,
1762,
20,
21456,
82,
582,
298,
3872,
288,
298,
15591,
582,
16338,
63,
576,
12,
288,
298,
1715,
1304,
582,
298,
2965,
281,
13,
7096,
401,
398,
1660,
267,
298,
354,
582,
536,
12,
267,
298,
466,
582,
298,
4201,
2,
272,
789,
339,
372,
486,
415,
63,
888,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
arjoly/scikit-learn
|
sklearn/covariance/tests/test_covariance.py
|
34
|
11120
|
# Author: Alexandre Gramfort <alexandre.gramfort@inria.fr>
# Gael Varoquaux <gael.varoquaux@normalesup.org>
# Virgile Fritsch <virgile.fritsch@inria.fr>
#
# License: BSD 3 clause
import numpy as np
from sklearn.utils.testing import assert_almost_equal
from sklearn.utils.testing import assert_array_almost_equal
from sklearn.utils.testing import assert_array_equal
from sklearn.utils.testing import assert_raises
from sklearn.utils.testing import assert_warns
from sklearn.utils.testing import assert_greater
from sklearn import datasets
from sklearn.covariance import empirical_covariance, EmpiricalCovariance, \
ShrunkCovariance, shrunk_covariance, \
LedoitWolf, ledoit_wolf, ledoit_wolf_shrinkage, OAS, oas
X = datasets.load_diabetes().data
X_1d = X[:, 0]
n_samples, n_features = X.shape
def test_covariance():
# Tests Covariance module on a simple dataset.
# test covariance fit from data
cov = EmpiricalCovariance()
cov.fit(X)
emp_cov = empirical_covariance(X)
assert_array_almost_equal(emp_cov, cov.covariance_, 4)
assert_almost_equal(cov.error_norm(emp_cov), 0)
assert_almost_equal(
cov.error_norm(emp_cov, norm='spectral'), 0)
assert_almost_equal(
cov.error_norm(emp_cov, norm='frobenius'), 0)
assert_almost_equal(
cov.error_norm(emp_cov, scaling=False), 0)
assert_almost_equal(
cov.error_norm(emp_cov, squared=False), 0)
assert_raises(NotImplementedError,
cov.error_norm, emp_cov, norm='foo')
# Mahalanobis distances computation test
mahal_dist = cov.mahalanobis(X)
assert_greater(np.amin(mahal_dist), 0)
# test with n_features = 1
X_1d = X[:, 0].reshape((-1, 1))
cov = EmpiricalCovariance()
cov.fit(X_1d)
assert_array_almost_equal(empirical_covariance(X_1d), cov.covariance_, 4)
assert_almost_equal(cov.error_norm(empirical_covariance(X_1d)), 0)
assert_almost_equal(
cov.error_norm(empirical_covariance(X_1d), norm='spectral'), 0)
# test with one sample
# Create X with 1 sample and 5 features
X_1sample = np.arange(5).reshape(1, 5)
cov = EmpiricalCovariance()
assert_warns(UserWarning, cov.fit, X_1sample)
assert_array_almost_equal(cov.covariance_,
np.zeros(shape=(5, 5), dtype=np.float64))
# test integer type
X_integer = np.asarray([[0, 1], [1, 0]])
result = np.asarray([[0.25, -0.25], [-0.25, 0.25]])
assert_array_almost_equal(empirical_covariance(X_integer), result)
# test centered case
cov = EmpiricalCovariance(assume_centered=True)
cov.fit(X)
assert_array_equal(cov.location_, np.zeros(X.shape[1]))
def test_shrunk_covariance():
# Tests ShrunkCovariance module on a simple dataset.
# compare shrunk covariance obtained from data and from MLE estimate
cov = ShrunkCovariance(shrinkage=0.5)
cov.fit(X)
assert_array_almost_equal(
shrunk_covariance(empirical_covariance(X), shrinkage=0.5),
cov.covariance_, 4)
# same test with shrinkage not provided
cov = ShrunkCovariance()
cov.fit(X)
assert_array_almost_equal(
shrunk_covariance(empirical_covariance(X)), cov.covariance_, 4)
# same test with shrinkage = 0 (<==> empirical_covariance)
cov = ShrunkCovariance(shrinkage=0.)
cov.fit(X)
assert_array_almost_equal(empirical_covariance(X), cov.covariance_, 4)
# test with n_features = 1
X_1d = X[:, 0].reshape((-1, 1))
cov = ShrunkCovariance(shrinkage=0.3)
cov.fit(X_1d)
assert_array_almost_equal(empirical_covariance(X_1d), cov.covariance_, 4)
# test shrinkage coeff on a simple data set (without saving precision)
cov = ShrunkCovariance(shrinkage=0.5, store_precision=False)
cov.fit(X)
assert(cov.precision_ is None)
def test_ledoit_wolf():
# Tests LedoitWolf module on a simple dataset.
# test shrinkage coeff on a simple data set
X_centered = X - X.mean(axis=0)
lw = LedoitWolf(assume_centered=True)
lw.fit(X_centered)
shrinkage_ = lw.shrinkage_
score_ = lw.score(X_centered)
assert_almost_equal(ledoit_wolf_shrinkage(X_centered,
assume_centered=True),
shrinkage_)
assert_almost_equal(ledoit_wolf_shrinkage(X_centered, assume_centered=True,
block_size=6),
shrinkage_)
# compare shrunk covariance obtained from data and from MLE estimate
lw_cov_from_mle, lw_shinkrage_from_mle = ledoit_wolf(X_centered,
assume_centered=True)
assert_array_almost_equal(lw_cov_from_mle, lw.covariance_, 4)
assert_almost_equal(lw_shinkrage_from_mle, lw.shrinkage_)
# compare estimates given by LW and ShrunkCovariance
scov = ShrunkCovariance(shrinkage=lw.shrinkage_, assume_centered=True)
scov.fit(X_centered)
assert_array_almost_equal(scov.covariance_, lw.covariance_, 4)
# test with n_features = 1
X_1d = X[:, 0].reshape((-1, 1))
lw = LedoitWolf(assume_centered=True)
lw.fit(X_1d)
lw_cov_from_mle, lw_shinkrage_from_mle = ledoit_wolf(X_1d,
assume_centered=True)
assert_array_almost_equal(lw_cov_from_mle, lw.covariance_, 4)
assert_almost_equal(lw_shinkrage_from_mle, lw.shrinkage_)
assert_array_almost_equal((X_1d ** 2).sum() / n_samples, lw.covariance_, 4)
# test shrinkage coeff on a simple data set (without saving precision)
lw = LedoitWolf(store_precision=False, assume_centered=True)
lw.fit(X_centered)
assert_almost_equal(lw.score(X_centered), score_, 4)
assert(lw.precision_ is None)
# Same tests without assuming centered data
# test shrinkage coeff on a simple data set
lw = LedoitWolf()
lw.fit(X)
assert_almost_equal(lw.shrinkage_, shrinkage_, 4)
assert_almost_equal(lw.shrinkage_, ledoit_wolf_shrinkage(X))
assert_almost_equal(lw.shrinkage_, ledoit_wolf(X)[1])
assert_almost_equal(lw.score(X), score_, 4)
# compare shrunk covariance obtained from data and from MLE estimate
lw_cov_from_mle, lw_shinkrage_from_mle = ledoit_wolf(X)
assert_array_almost_equal(lw_cov_from_mle, lw.covariance_, 4)
assert_almost_equal(lw_shinkrage_from_mle, lw.shrinkage_)
# compare estimates given by LW and ShrunkCovariance
scov = ShrunkCovariance(shrinkage=lw.shrinkage_)
scov.fit(X)
assert_array_almost_equal(scov.covariance_, lw.covariance_, 4)
# test with n_features = 1
X_1d = X[:, 0].reshape((-1, 1))
lw = LedoitWolf()
lw.fit(X_1d)
lw_cov_from_mle, lw_shinkrage_from_mle = ledoit_wolf(X_1d)
assert_array_almost_equal(lw_cov_from_mle, lw.covariance_, 4)
assert_almost_equal(lw_shinkrage_from_mle, lw.shrinkage_)
assert_array_almost_equal(empirical_covariance(X_1d), lw.covariance_, 4)
# test with one sample
# warning should be raised when using only 1 sample
X_1sample = np.arange(5).reshape(1, 5)
lw = LedoitWolf()
assert_warns(UserWarning, lw.fit, X_1sample)
assert_array_almost_equal(lw.covariance_,
np.zeros(shape=(5, 5), dtype=np.float64))
# test shrinkage coeff on a simple data set (without saving precision)
lw = LedoitWolf(store_precision=False)
lw.fit(X)
assert_almost_equal(lw.score(X), score_, 4)
assert(lw.precision_ is None)
def test_ledoit_wolf_large():
# test that ledoit_wolf doesn't error on data that is wider than block_size
rng = np.random.RandomState(0)
# use a number of features that is larger than the block-size
X = rng.normal(size=(10, 20))
lw = LedoitWolf(block_size=10).fit(X)
# check that covariance is about diagonal (random normal noise)
assert_almost_equal(lw.covariance_, np.eye(20), 0)
cov = lw.covariance_
# check that the result is consistent with not splitting data into blocks.
lw = LedoitWolf(block_size=25).fit(X)
assert_almost_equal(lw.covariance_, cov)
def test_oas():
# Tests OAS module on a simple dataset.
# test shrinkage coeff on a simple data set
X_centered = X - X.mean(axis=0)
oa = OAS(assume_centered=True)
oa.fit(X_centered)
shrinkage_ = oa.shrinkage_
score_ = oa.score(X_centered)
# compare shrunk covariance obtained from data and from MLE estimate
oa_cov_from_mle, oa_shinkrage_from_mle = oas(X_centered,
assume_centered=True)
assert_array_almost_equal(oa_cov_from_mle, oa.covariance_, 4)
assert_almost_equal(oa_shinkrage_from_mle, oa.shrinkage_)
# compare estimates given by OAS and ShrunkCovariance
scov = ShrunkCovariance(shrinkage=oa.shrinkage_, assume_centered=True)
scov.fit(X_centered)
assert_array_almost_equal(scov.covariance_, oa.covariance_, 4)
# test with n_features = 1
X_1d = X[:, 0:1]
oa = OAS(assume_centered=True)
oa.fit(X_1d)
oa_cov_from_mle, oa_shinkrage_from_mle = oas(X_1d, assume_centered=True)
assert_array_almost_equal(oa_cov_from_mle, oa.covariance_, 4)
assert_almost_equal(oa_shinkrage_from_mle, oa.shrinkage_)
assert_array_almost_equal((X_1d ** 2).sum() / n_samples, oa.covariance_, 4)
# test shrinkage coeff on a simple data set (without saving precision)
oa = OAS(store_precision=False, assume_centered=True)
oa.fit(X_centered)
assert_almost_equal(oa.score(X_centered), score_, 4)
assert(oa.precision_ is None)
# Same tests without assuming centered data--------------------------------
# test shrinkage coeff on a simple data set
oa = OAS()
oa.fit(X)
assert_almost_equal(oa.shrinkage_, shrinkage_, 4)
assert_almost_equal(oa.score(X), score_, 4)
# compare shrunk covariance obtained from data and from MLE estimate
oa_cov_from_mle, oa_shinkrage_from_mle = oas(X)
assert_array_almost_equal(oa_cov_from_mle, oa.covariance_, 4)
assert_almost_equal(oa_shinkrage_from_mle, oa.shrinkage_)
# compare estimates given by OAS and ShrunkCovariance
scov = ShrunkCovariance(shrinkage=oa.shrinkage_)
scov.fit(X)
assert_array_almost_equal(scov.covariance_, oa.covariance_, 4)
# test with n_features = 1
X_1d = X[:, 0].reshape((-1, 1))
oa = OAS()
oa.fit(X_1d)
oa_cov_from_mle, oa_shinkrage_from_mle = oas(X_1d)
assert_array_almost_equal(oa_cov_from_mle, oa.covariance_, 4)
assert_almost_equal(oa_shinkrage_from_mle, oa.shrinkage_)
assert_array_almost_equal(empirical_covariance(X_1d), oa.covariance_, 4)
# test with one sample
# warning should be raised when using only 1 sample
X_1sample = np.arange(5).reshape(1, 5)
oa = OAS()
assert_warns(UserWarning, oa.fit, X_1sample)
assert_array_almost_equal(oa.covariance_,
np.zeros(shape=(5, 5), dtype=np.float64))
# test shrinkage coeff on a simple data set (without saving precision)
oa = OAS(store_precision=False)
oa.fit(X)
assert_almost_equal(oa.score(X), score_, 4)
assert(oa.precision_ is None)
|
bsd-3-clause
|
[
3,
6529,
26,
22986,
28547,
27211,
10279,
665,
24421,
28547,
14,
1679,
10279,
32,
262,
23714,
14,
4391,
30,
199,
3,
260,
9647,
352,
21084,
79,
392,
10962,
665,
5294,
352,
14,
1391,
79,
392,
10962,
32,
6505,
17667,
1961,
14,
1308,
30,
199,
3,
260,
812,
723,
71,
441,
31712,
1086,
335,
665,
1042,
71,
441,
14,
25876,
1086,
335,
32,
262,
23714,
14,
4391,
30,
199,
3,
199,
3,
844,
26,
6289,
650,
8502,
199,
199,
646,
2680,
465,
980,
199,
199,
504,
6357,
14,
1208,
14,
4776,
492,
702,
63,
4398,
63,
1452,
199,
504,
6357,
14,
1208,
14,
4776,
492,
702,
63,
1144,
63,
4398,
63,
1452,
199,
504,
6357,
14,
1208,
14,
4776,
492,
702,
63,
1144,
63,
1452,
199,
504,
6357,
14,
1208,
14,
4776,
492,
702,
63,
3536,
199,
504,
6357,
14,
1208,
14,
4776,
492,
702,
63,
19811,
199,
504,
6357,
14,
1208,
14,
4776,
492,
702,
63,
13154,
199,
199,
504,
6357,
492,
13148,
199,
504,
6357,
14,
15024,
492,
9052,
73,
8825,
63,
15024,
12,
662,
22575,
967,
6221,
12,
971,
272,
5244,
1065,
75,
967,
6221,
12,
1033,
1065,
75,
63,
15024,
12,
971,
272,
491,
379,
79,
390,
26724,
276,
12,
1026,
19014,
63,
28070,
12,
1026,
19014,
63,
28070,
63,
23733,
474,
12,
593,
1179,
12,
312,
305,
199,
199,
56,
275,
13148,
14,
912,
63,
328,
26290,
1252,
576,
199,
56,
63,
17,
68,
275,
1323,
3981,
378,
61,
199,
78,
63,
3356,
12,
302,
63,
3179,
275,
1323,
14,
1392,
421,
199,
318,
511,
63,
15024,
837,
272,
327,
6496,
1849,
6221,
859,
641,
282,
3486,
4789,
14,
272,
327,
511,
13263,
5542,
687,
666,
272,
13786,
275,
662,
22575,
967,
6221,
342,
272,
13786,
14,
3269,
8,
56,
9,
272,
9052,
63,
8695,
275,
9052,
73,
8825,
63,
15024,
8,
56,
9,
272,
702,
63,
1144,
63,
4398,
63,
1452,
8,
2109,
63,
8695,
12,
13786,
14,
15024,
3131,
841,
9,
272,
702,
63,
4398,
63,
1452,
8,
8695,
14,
705,
63,
4791,
8,
2109,
63,
8695,
395,
378,
9,
272,
702,
63,
4398,
63,
1452,
8,
267,
13786,
14,
705,
63,
4791,
8,
2109,
63,
8695,
12,
6316,
534,
31738,
659,
378,
9,
272,
702,
63,
4398,
63,
1452,
8,
267,
13786,
14,
705,
63,
4791,
8,
2109,
63,
8695,
12,
6316,
534,
21775,
18486,
73,
527,
659,
378,
9,
272,
702,
63,
4398,
63,
1452,
8,
267,
13786,
14,
705,
63,
4791,
8,
2109,
63,
8695,
12,
13690,
29,
797,
395,
378,
9,
272,
702,
63,
4398,
63,
1452,
8,
267,
13786,
14,
705,
63,
4791,
8,
2109,
63,
8695,
12,
20478,
29,
797,
395,
378,
9,
272,
702,
63,
3536,
8,
18097,
12,
2116,
13786,
14,
705,
63,
4791,
12,
9052,
63,
8695,
12,
6316,
534,
1421,
358,
272,
327,
603,
11326,
279,
290,
2873,
374,
15108,
14009,
511,
272,
610,
19785,
63,
2686,
275,
13786,
14,
391,
19785,
290,
2873,
374,
8,
56,
9,
272,
702,
63,
13154,
8,
1590,
14,
32374,
8,
391,
19785,
63,
2686,
395,
378,
9,
339,
327,
511,
543,
302,
63,
3179,
275,
413,
272,
1323,
63,
17,
68,
275,
1323,
3981,
378,
1055,
5217,
18138,
17,
12,
413,
430,
272,
13786,
275,
662,
22575,
967,
6221,
342,
272,
13786,
14,
3269,
8,
56,
63,
17,
68,
9,
272,
702,
63,
1144,
63,
4398,
63,
1452,
8,
2109,
73,
8825,
63,
15024,
8,
56,
63,
17,
68,
395,
13786,
14,
15024,
3131,
841,
9,
272,
702,
63,
4398,
63,
1452,
8,
8695,
14,
705,
63,
4791,
8,
2109,
73,
8825,
63,
15024,
8,
56,
63,
17,
68,
1826,
378,
9,
272,
702,
63,
4398,
63,
1452,
8,
267,
13786,
14,
705,
63,
4791,
8,
2109,
73,
8825,
63,
15024,
8,
56,
63,
17,
68,
395,
6316,
534,
31738,
659,
378,
9,
339,
327,
511,
543,
1373,
2690,
272,
327,
2790,
1323,
543,
413,
2690,
436,
959,
4534,
272,
1323,
63,
17,
3271,
275,
980,
14,
5605,
8,
21,
680,
5217,
8,
17,
12,
959,
9,
272,
13786,
275,
662,
22575,
967,
6221,
342,
272,
702,
63,
19811,
8,
32114,
12,
13786,
14,
3269,
12,
1323,
63,
17,
3271,
9,
272,
702,
63,
1144,
63,
4398,
63,
1452,
8,
8695,
14,
15024,
3131,
2892,
980,
14,
4250,
8,
1392,
2687,
21,
12,
959,
395,
2152,
29,
1590,
14,
1609,
772,
430,
339,
327,
511,
3000,
730,
272,
1323,
63,
4115,
275,
980,
14,
8748,
4038,
16,
12,
413,
467,
359,
17,
12,
378,
3934,
272,
754,
275,
980,
14,
8748,
4038,
16,
14,
821,
12,
446,
16,
14,
821,
467,
5243,
16,
14,
821,
12,
378,
14,
821,
3934,
272,
702,
63,
1144,
63,
4398,
63,
1452,
8,
2109,
73,
8825,
63,
15024,
8,
56,
63,
4115,
395,
754,
9,
339,
327,
511,
23903,
1930,
272,
13786,
275,
662,
22575,
967,
6221,
8,
21946,
63,
20080,
29,
549,
9,
272,
13786,
14,
3269,
8,
56,
9,
272,
702,
63,
1144,
63,
1452,
8,
8695,
14,
1985,
3131,
980,
14,
4250,
8,
56,
14,
1392,
59,
17,
2459,
421,
199,
318,
511,
63,
609,
1065,
75,
63,
15024,
837,
272,
327,
6496,
5244,
1065,
75,
967,
6221,
859,
641,
282,
3486,
4789,
14,
272,
327,
6540,
1033,
1065,
75,
13263,
15884,
687,
666,
436,
687,
603,
906,
14497,
272,
13786,
275,
5244,
1065,
75,
967,
6221,
8,
23733,
474,
29,
16,
14,
21,
9,
272,
13786,
14,
3269,
8,
56,
9,
272,
702,
63,
1144,
63,
4398,
63,
1452,
8,
267,
1033,
1065,
75,
63,
15024,
8,
2109,
73,
8825,
63,
15024,
8,
56,
395,
19790,
474,
29,
16,
14,
21,
395,
267,
13786,
14,
15024,
3131,
841,
9,
339,
327,
2011,
511,
543,
19790,
474,
440,
2741,
272,
13786,
275,
5244,
1065,
75,
967,
6221,
342,
272,
13786,
14,
3269,
8,
56,
9,
272,
702,
63,
1144,
63,
4398,
63,
1452,
8,
267,
1033,
1065,
75,
63,
15024,
8,
2109,
73,
8825,
63,
15024,
8,
56,
1826,
13786,
14,
15024,
3131,
841,
9,
339,
327,
2011,
511,
543,
19790,
474,
275,
378,
8642,
19833,
9052,
73,
8825,
63,
15024,
9,
272,
13786,
275,
5244,
1065,
75,
967,
6221,
8,
23733
] |
[
6529,
26,
22986,
28547,
27211,
10279,
665,
24421,
28547,
14,
1679,
10279,
32,
262,
23714,
14,
4391,
30,
199,
3,
260,
9647,
352,
21084,
79,
392,
10962,
665,
5294,
352,
14,
1391,
79,
392,
10962,
32,
6505,
17667,
1961,
14,
1308,
30,
199,
3,
260,
812,
723,
71,
441,
31712,
1086,
335,
665,
1042,
71,
441,
14,
25876,
1086,
335,
32,
262,
23714,
14,
4391,
30,
199,
3,
199,
3,
844,
26,
6289,
650,
8502,
199,
199,
646,
2680,
465,
980,
199,
199,
504,
6357,
14,
1208,
14,
4776,
492,
702,
63,
4398,
63,
1452,
199,
504,
6357,
14,
1208,
14,
4776,
492,
702,
63,
1144,
63,
4398,
63,
1452,
199,
504,
6357,
14,
1208,
14,
4776,
492,
702,
63,
1144,
63,
1452,
199,
504,
6357,
14,
1208,
14,
4776,
492,
702,
63,
3536,
199,
504,
6357,
14,
1208,
14,
4776,
492,
702,
63,
19811,
199,
504,
6357,
14,
1208,
14,
4776,
492,
702,
63,
13154,
199,
199,
504,
6357,
492,
13148,
199,
504,
6357,
14,
15024,
492,
9052,
73,
8825,
63,
15024,
12,
662,
22575,
967,
6221,
12,
971,
272,
5244,
1065,
75,
967,
6221,
12,
1033,
1065,
75,
63,
15024,
12,
971,
272,
491,
379,
79,
390,
26724,
276,
12,
1026,
19014,
63,
28070,
12,
1026,
19014,
63,
28070,
63,
23733,
474,
12,
593,
1179,
12,
312,
305,
199,
199,
56,
275,
13148,
14,
912,
63,
328,
26290,
1252,
576,
199,
56,
63,
17,
68,
275,
1323,
3981,
378,
61,
199,
78,
63,
3356,
12,
302,
63,
3179,
275,
1323,
14,
1392,
421,
199,
318,
511,
63,
15024,
837,
272,
327,
6496,
1849,
6221,
859,
641,
282,
3486,
4789,
14,
272,
327,
511,
13263,
5542,
687,
666,
272,
13786,
275,
662,
22575,
967,
6221,
342,
272,
13786,
14,
3269,
8,
56,
9,
272,
9052,
63,
8695,
275,
9052,
73,
8825,
63,
15024,
8,
56,
9,
272,
702,
63,
1144,
63,
4398,
63,
1452,
8,
2109,
63,
8695,
12,
13786,
14,
15024,
3131,
841,
9,
272,
702,
63,
4398,
63,
1452,
8,
8695,
14,
705,
63,
4791,
8,
2109,
63,
8695,
395,
378,
9,
272,
702,
63,
4398,
63,
1452,
8,
267,
13786,
14,
705,
63,
4791,
8,
2109,
63,
8695,
12,
6316,
534,
31738,
659,
378,
9,
272,
702,
63,
4398,
63,
1452,
8,
267,
13786,
14,
705,
63,
4791,
8,
2109,
63,
8695,
12,
6316,
534,
21775,
18486,
73,
527,
659,
378,
9,
272,
702,
63,
4398,
63,
1452,
8,
267,
13786,
14,
705,
63,
4791,
8,
2109,
63,
8695,
12,
13690,
29,
797,
395,
378,
9,
272,
702,
63,
4398,
63,
1452,
8,
267,
13786,
14,
705,
63,
4791,
8,
2109,
63,
8695,
12,
20478,
29,
797,
395,
378,
9,
272,
702,
63,
3536,
8,
18097,
12,
2116,
13786,
14,
705,
63,
4791,
12,
9052,
63,
8695,
12,
6316,
534,
1421,
358,
272,
327,
603,
11326,
279,
290,
2873,
374,
15108,
14009,
511,
272,
610,
19785,
63,
2686,
275,
13786,
14,
391,
19785,
290,
2873,
374,
8,
56,
9,
272,
702,
63,
13154,
8,
1590,
14,
32374,
8,
391,
19785,
63,
2686,
395,
378,
9,
339,
327,
511,
543,
302,
63,
3179,
275,
413,
272,
1323,
63,
17,
68,
275,
1323,
3981,
378,
1055,
5217,
18138,
17,
12,
413,
430,
272,
13786,
275,
662,
22575,
967,
6221,
342,
272,
13786,
14,
3269,
8,
56,
63,
17,
68,
9,
272,
702,
63,
1144,
63,
4398,
63,
1452,
8,
2109,
73,
8825,
63,
15024,
8,
56,
63,
17,
68,
395,
13786,
14,
15024,
3131,
841,
9,
272,
702,
63,
4398,
63,
1452,
8,
8695,
14,
705,
63,
4791,
8,
2109,
73,
8825,
63,
15024,
8,
56,
63,
17,
68,
1826,
378,
9,
272,
702,
63,
4398,
63,
1452,
8,
267,
13786,
14,
705,
63,
4791,
8,
2109,
73,
8825,
63,
15024,
8,
56,
63,
17,
68,
395,
6316,
534,
31738,
659,
378,
9,
339,
327,
511,
543,
1373,
2690,
272,
327,
2790,
1323,
543,
413,
2690,
436,
959,
4534,
272,
1323,
63,
17,
3271,
275,
980,
14,
5605,
8,
21,
680,
5217,
8,
17,
12,
959,
9,
272,
13786,
275,
662,
22575,
967,
6221,
342,
272,
702,
63,
19811,
8,
32114,
12,
13786,
14,
3269,
12,
1323,
63,
17,
3271,
9,
272,
702,
63,
1144,
63,
4398,
63,
1452,
8,
8695,
14,
15024,
3131,
2892,
980,
14,
4250,
8,
1392,
2687,
21,
12,
959,
395,
2152,
29,
1590,
14,
1609,
772,
430,
339,
327,
511,
3000,
730,
272,
1323,
63,
4115,
275,
980,
14,
8748,
4038,
16,
12,
413,
467,
359,
17,
12,
378,
3934,
272,
754,
275,
980,
14,
8748,
4038,
16,
14,
821,
12,
446,
16,
14,
821,
467,
5243,
16,
14,
821,
12,
378,
14,
821,
3934,
272,
702,
63,
1144,
63,
4398,
63,
1452,
8,
2109,
73,
8825,
63,
15024,
8,
56,
63,
4115,
395,
754,
9,
339,
327,
511,
23903,
1930,
272,
13786,
275,
662,
22575,
967,
6221,
8,
21946,
63,
20080,
29,
549,
9,
272,
13786,
14,
3269,
8,
56,
9,
272,
702,
63,
1144,
63,
1452,
8,
8695,
14,
1985,
3131,
980,
14,
4250,
8,
56,
14,
1392,
59,
17,
2459,
421,
199,
318,
511,
63,
609,
1065,
75,
63,
15024,
837,
272,
327,
6496,
5244,
1065,
75,
967,
6221,
859,
641,
282,
3486,
4789,
14,
272,
327,
6540,
1033,
1065,
75,
13263,
15884,
687,
666,
436,
687,
603,
906,
14497,
272,
13786,
275,
5244,
1065,
75,
967,
6221,
8,
23733,
474,
29,
16,
14,
21,
9,
272,
13786,
14,
3269,
8,
56,
9,
272,
702,
63,
1144,
63,
4398,
63,
1452,
8,
267,
1033,
1065,
75,
63,
15024,
8,
2109,
73,
8825,
63,
15024,
8,
56,
395,
19790,
474,
29,
16,
14,
21,
395,
267,
13786,
14,
15024,
3131,
841,
9,
339,
327,
2011,
511,
543,
19790,
474,
440,
2741,
272,
13786,
275,
5244,
1065,
75,
967,
6221,
342,
272,
13786,
14,
3269,
8,
56,
9,
272,
702,
63,
1144,
63,
4398,
63,
1452,
8,
267,
1033,
1065,
75,
63,
15024,
8,
2109,
73,
8825,
63,
15024,
8,
56,
1826,
13786,
14,
15024,
3131,
841,
9,
339,
327,
2011,
511,
543,
19790,
474,
275,
378,
8642,
19833,
9052,
73,
8825,
63,
15024,
9,
272,
13786,
275,
5244,
1065,
75,
967,
6221,
8,
23733,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
jacquev6/MockMockMock
|
MockMockMock/tests/expectation_sequence.py
|
1
|
1736
|
# coding: utf8
# Copyright 2013-2015 Vincent Jacques <vincent@vincent-jacques.net>
import unittest
import MockMockMock
class ExpectationSequenceTestCase(unittest.TestCase):
def setUp(self):
super(ExpectationSequenceTestCase, self).setUp()
self.mocks = MockMockMock.Engine()
self.mock = self.mocks.create("mock")
def test_two_calls(self):
self.mock.expect.foobar()
self.mock.expect.barbaz()
self.mock.object.foobar()
self.mock.object.barbaz()
self.mocks.tearDown()
def test_call_not_expected_first(self):
self.mock.expect.foobar()
self.mock.expect.barbaz()
with self.assertRaises(MockMockMock.MockException) as cm:
self.mock.object.barbaz()
self.assertEqual(str(cm.exception), "mock.barbaz called instead of mock.foobar")
def test_call_with_arguments_not_expected_first(self):
self.mock.expect.foobar(42)
self.mock.expect.foobar(43)
with self.assertRaises(MockMockMock.MockException) as cm:
self.mock.object.foobar(43)
self.assertEqual(str(cm.exception), "mock.foobar called with bad arguments (43,) {}") # @todo Ask the argument checker for a description of expected arguments
def test_many_calls(self):
self.mock.expect.foobar(1)
self.mock.expect.foobar(2)
self.mock.expect.foobar(3)
self.mock.expect.foobar(4)
self.mock.expect.foobar(5)
self.mock.expect.foobar(6)
self.mock.object.foobar(1)
self.mock.object.foobar(2)
self.mock.object.foobar(3)
self.mock.object.foobar(4)
self.mock.object.foobar(5)
self.mock.object.foobar(6)
self.mocks.tearDown()
|
mit
|
[
3,
2803,
26,
2774,
24,
199,
199,
3,
1898,
6171,
13,
7806,
28882,
2946,
1603,
645,
19658,
665,
11908,
2946,
32,
11908,
2946,
13,
9299,
19658,
14,
846,
30,
199,
199,
646,
2882,
199,
199,
646,
4420,
3346,
3346,
421,
199,
533,
15100,
425,
5826,
1746,
8,
2796,
14,
1746,
304,
272,
347,
3613,
8,
277,
304,
267,
1613,
8,
13495,
425,
5826,
1746,
12,
291,
680,
5996,
342,
267,
291,
14,
25191,
275,
4420,
3346,
3346,
14,
8524,
342,
267,
291,
14,
1805,
275,
291,
14,
25191,
14,
981,
480,
1805,
531,
339,
347,
511,
63,
5601,
63,
5352,
8,
277,
304,
267,
291,
14,
1805,
14,
4921,
14,
9664,
342,
267,
291,
14,
1805,
14,
4921,
14,
1700,
6185,
342,
267,
291,
14,
1805,
14,
785,
14,
9664,
342,
267,
291,
14,
1805,
14,
785,
14,
1700,
6185,
342,
267,
291,
14,
25191,
14,
12336,
342,
339,
347,
511,
63,
1250,
63,
1397,
63,
2062,
63,
2246,
8,
277,
304,
267,
291,
14,
1805,
14,
4921,
14,
9664,
342,
267,
291,
14,
1805,
14,
4921,
14,
1700,
6185,
342,
267,
543,
291,
14,
1855,
8,
3346,
3346,
3346,
14,
3346,
1726,
9,
465,
6904,
26,
288,
291,
14,
1805,
14,
785,
14,
1700,
6185,
342,
267,
291,
14,
629,
8,
495,
8,
4400,
14,
1971,
395,
298,
1805,
14,
1700,
6185,
2797,
3140,
402,
1683,
14,
9664,
531,
339,
347,
511,
63,
1250,
63,
1045,
63,
4958,
63,
1397,
63,
2062,
63,
2246,
8,
277,
304,
267,
291,
14,
1805,
14,
4921,
14,
9664,
8,
2260,
9,
267,
291,
14,
1805,
14,
4921,
14,
9664,
8,
2824,
9,
267,
543,
291,
14,
1855,
8,
3346,
3346,
3346,
14,
3346,
1726,
9,
465,
6904,
26,
288,
291,
14,
1805,
14,
785,
14,
9664,
8,
2824,
9,
267,
291,
14,
629,
8,
495,
8,
4400,
14,
1971,
395,
298,
1805,
14,
9664,
2797,
543,
4875,
2368,
334,
2824,
4258,
1052,
531,
221,
327,
768,
11396,
30481,
314,
1423,
7739,
367,
282,
1369,
402,
1420,
2368,
339,
347,
511,
63,
3479,
63,
5352,
8,
277,
304,
267,
291,
14,
1805,
14,
4921,
14,
9664,
8,
17,
9,
267,
291,
14,
1805,
14,
4921,
14,
9664,
8,
18,
9,
267,
291,
14,
1805,
14,
4921,
14,
9664,
8,
19,
9,
267,
291,
14,
1805,
14,
4921,
14,
9664,
8,
20,
9,
267,
291,
14,
1805,
14,
4921,
14,
9664,
8,
21,
9,
267,
291,
14,
1805,
14,
4921,
14,
9664,
8,
22,
9,
267,
291,
14,
1805,
14,
785,
14,
9664,
8,
17,
9,
267,
291,
14,
1805,
14,
785,
14,
9664,
8,
18,
9,
267,
291,
14,
1805,
14,
785,
14,
9664,
8,
19,
9,
267,
291,
14,
1805,
14,
785,
14,
9664,
8,
20,
9,
267,
291,
14,
1805,
14,
785,
14,
9664,
8,
21,
9,
267,
291,
14,
1805,
14,
785,
14,
9664,
8,
22,
9,
267,
291,
14,
25191,
14,
12336,
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
] |
[
2803,
26,
2774,
24,
199,
199,
3,
1898,
6171,
13,
7806,
28882,
2946,
1603,
645,
19658,
665,
11908,
2946,
32,
11908,
2946,
13,
9299,
19658,
14,
846,
30,
199,
199,
646,
2882,
199,
199,
646,
4420,
3346,
3346,
421,
199,
533,
15100,
425,
5826,
1746,
8,
2796,
14,
1746,
304,
272,
347,
3613,
8,
277,
304,
267,
1613,
8,
13495,
425,
5826,
1746,
12,
291,
680,
5996,
342,
267,
291,
14,
25191,
275,
4420,
3346,
3346,
14,
8524,
342,
267,
291,
14,
1805,
275,
291,
14,
25191,
14,
981,
480,
1805,
531,
339,
347,
511,
63,
5601,
63,
5352,
8,
277,
304,
267,
291,
14,
1805,
14,
4921,
14,
9664,
342,
267,
291,
14,
1805,
14,
4921,
14,
1700,
6185,
342,
267,
291,
14,
1805,
14,
785,
14,
9664,
342,
267,
291,
14,
1805,
14,
785,
14,
1700,
6185,
342,
267,
291,
14,
25191,
14,
12336,
342,
339,
347,
511,
63,
1250,
63,
1397,
63,
2062,
63,
2246,
8,
277,
304,
267,
291,
14,
1805,
14,
4921,
14,
9664,
342,
267,
291,
14,
1805,
14,
4921,
14,
1700,
6185,
342,
267,
543,
291,
14,
1855,
8,
3346,
3346,
3346,
14,
3346,
1726,
9,
465,
6904,
26,
288,
291,
14,
1805,
14,
785,
14,
1700,
6185,
342,
267,
291,
14,
629,
8,
495,
8,
4400,
14,
1971,
395,
298,
1805,
14,
1700,
6185,
2797,
3140,
402,
1683,
14,
9664,
531,
339,
347,
511,
63,
1250,
63,
1045,
63,
4958,
63,
1397,
63,
2062,
63,
2246,
8,
277,
304,
267,
291,
14,
1805,
14,
4921,
14,
9664,
8,
2260,
9,
267,
291,
14,
1805,
14,
4921,
14,
9664,
8,
2824,
9,
267,
543,
291,
14,
1855,
8,
3346,
3346,
3346,
14,
3346,
1726,
9,
465,
6904,
26,
288,
291,
14,
1805,
14,
785,
14,
9664,
8,
2824,
9,
267,
291,
14,
629,
8,
495,
8,
4400,
14,
1971,
395,
298,
1805,
14,
9664,
2797,
543,
4875,
2368,
334,
2824,
4258,
1052,
531,
221,
327,
768,
11396,
30481,
314,
1423,
7739,
367,
282,
1369,
402,
1420,
2368,
339,
347,
511,
63,
3479,
63,
5352,
8,
277,
304,
267,
291,
14,
1805,
14,
4921,
14,
9664,
8,
17,
9,
267,
291,
14,
1805,
14,
4921,
14,
9664,
8,
18,
9,
267,
291,
14,
1805,
14,
4921,
14,
9664,
8,
19,
9,
267,
291,
14,
1805,
14,
4921,
14,
9664,
8,
20,
9,
267,
291,
14,
1805,
14,
4921,
14,
9664,
8,
21,
9,
267,
291,
14,
1805,
14,
4921,
14,
9664,
8,
22,
9,
267,
291,
14,
1805,
14,
785,
14,
9664,
8,
17,
9,
267,
291,
14,
1805,
14,
785,
14,
9664,
8,
18,
9,
267,
291,
14,
1805,
14,
785,
14,
9664,
8,
19,
9,
267,
291,
14,
1805,
14,
785,
14,
9664,
8,
20,
9,
267,
291,
14,
1805,
14,
785,
14,
9664,
8,
21,
9,
267,
291,
14,
1805,
14,
785,
14,
9664,
8,
22,
9,
267,
291,
14,
25191,
14,
12336,
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,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
vitaly4uk/django
|
django/templatetags/future.py
|
129
|
2039
|
import warnings
from django.template import Library, defaulttags
from django.utils.deprecation import RemovedInDjango110Warning
register = Library()
@register.tag
def cycle(parser, token):
"""
This is the future version of `cycle` with auto-escaping.
The deprecation is now complete and this version is no different
from the non-future version so this is deprecated.
By default all strings are escaped.
If you want to disable auto-escaping of variables you can use::
{% autoescape off %}
{% cycle var1 var2 var3 as somecycle %}
{% autoescape %}
Or if only some variables should be escaped, you can use::
{% cycle var1 var2|safe var3|safe as somecycle %}
"""
warnings.warn(
"Loading the `cycle` tag from the `future` library is deprecated and "
"will be removed in Django 1.10. Use the default `cycle` tag instead.",
RemovedInDjango110Warning)
return defaulttags.cycle(parser, token)
@register.tag
def firstof(parser, token):
"""
This is the future version of `firstof` with auto-escaping.
The deprecation is now complete and this version is no different
from the non-future version so this is deprecated.
This is equivalent to::
{% if var1 %}
{{ var1 }}
{% elif var2 %}
{{ var2 }}
{% elif var3 %}
{{ var3 }}
{% endif %}
If you want to disable auto-escaping of variables you can use::
{% autoescape off %}
{% firstof var1 var2 var3 "<strong>fallback value</strong>" %}
{% autoescape %}
Or if only some variables should be escaped, you can use::
{% firstof var1 var2|safe var3 "<strong>fallback value</strong>"|safe %}
"""
warnings.warn(
"Loading the `firstof` tag from the `future` library is deprecated and "
"will be removed in Django 1.10. Use the default `firstof` tag instead.",
RemovedInDjango110Warning)
return defaulttags.firstof(parser, token)
|
bsd-3-clause
|
[
646,
3598,
199,
199,
504,
1639,
14,
1160,
492,
11243,
12,
849,
2969,
199,
504,
1639,
14,
1208,
14,
15383,
492,
23687,
6019,
3849,
199,
199,
2683,
275,
11243,
342,
421,
199,
32,
2683,
14,
1450,
199,
318,
8643,
8,
2087,
12,
1526,
304,
272,
408,
272,
961,
365,
314,
6466,
1015,
402,
658,
7612,
64,
543,
2599,
13,
26306,
14,
272,
710,
17831,
365,
3063,
4890,
436,
642,
1015,
365,
949,
3365,
272,
687,
314,
2222,
13,
2443,
1015,
880,
642,
365,
5906,
14,
339,
4885,
849,
1006,
3326,
787,
11077,
14,
339,
982,
1265,
2934,
370,
3507,
2599,
13,
26306,
402,
2860,
1265,
883,
675,
447,
398,
7749,
19102,
2331,
3674,
288,
7749,
8643,
2729,
17,
2729,
18,
2729,
19,
465,
2005,
7612,
3674,
267,
7749,
19102,
3674,
339,
4236,
340,
1454,
2005,
2860,
1077,
506,
11077,
12,
1265,
883,
675,
447,
398,
7749,
8643,
2729,
17,
2729,
18,
92,
3489,
2729,
19,
92,
3489,
221,
465,
2005,
7612,
3674,
272,
408,
272,
3598,
14,
4050,
8,
267,
298,
19236,
314,
658,
7612,
64,
1947,
687,
314,
658,
2443,
64,
3555,
365,
5906,
436,
298,
267,
298,
14117,
506,
4829,
315,
5634,
413,
14,
709,
14,
3645,
314,
849,
658,
7612,
64,
1947,
3140,
4765,
267,
23687,
6019,
3849,
9,
272,
372,
849,
2969,
14,
7612,
8,
2087,
12,
1526,
9,
421,
199,
32,
2683,
14,
1450,
199,
318,
1642,
1618,
8,
2087,
12,
1526,
304,
272,
408,
272,
961,
365,
314,
6466,
1015,
402,
658,
2246,
1618,
64,
543,
2599,
13,
26306,
14,
272,
710,
17831,
365,
3063,
4890,
436,
642,
1015,
365,
949,
3365,
272,
687,
314,
2222,
13,
2443,
1015,
880,
642,
365,
5906,
14,
339,
961,
365,
7353,
370,
447,
398,
7749,
340,
2729,
17,
3674,
288,
8448,
2729,
17,
3586,
267,
7749,
916,
2729,
18,
3674,
288,
8448,
2729,
18,
3586,
267,
7749,
916,
2729,
19,
3674,
288,
8448,
2729,
19,
3586,
267,
7749,
14454,
3674,
339,
982,
1265,
2934,
370,
3507,
2599,
13,
26306,
402,
2860,
1265,
883,
675,
447,
398,
7749,
19102,
2331,
3674,
288,
7749,
1642,
1618,
2729,
17,
2729,
18,
2729,
19,
3886,
9370,
30,
10538,
574,
1108,
9370,
4335,
3674,
267,
7749,
19102,
3674,
339,
4236,
340,
1454,
2005,
2860,
1077,
506,
11077,
12,
1265,
883,
675,
447,
398,
7749,
1642,
1618,
2729,
17,
2729,
18,
92,
3489,
2729,
19,
3886,
9370,
30,
10538,
574,
1108,
9370,
4335,
92,
3489,
3674,
339,
408,
272,
3598,
14,
4050,
8,
267,
298,
19236,
314,
658,
2246,
1618,
64,
1947,
687,
314,
658,
2443,
64,
3555,
365,
5906,
436,
298,
267,
298,
14117,
506,
4829,
315,
5634,
413,
14,
709,
14,
3645,
314,
849,
658,
2246,
1618,
64,
1947,
3140,
4765,
267,
23687,
6019,
3849,
9,
272,
372,
849,
2969,
14,
2246,
1618,
8,
2087,
12,
1526,
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
] |
[
3598,
199,
199,
504,
1639,
14,
1160,
492,
11243,
12,
849,
2969,
199,
504,
1639,
14,
1208,
14,
15383,
492,
23687,
6019,
3849,
199,
199,
2683,
275,
11243,
342,
421,
199,
32,
2683,
14,
1450,
199,
318,
8643,
8,
2087,
12,
1526,
304,
272,
408,
272,
961,
365,
314,
6466,
1015,
402,
658,
7612,
64,
543,
2599,
13,
26306,
14,
272,
710,
17831,
365,
3063,
4890,
436,
642,
1015,
365,
949,
3365,
272,
687,
314,
2222,
13,
2443,
1015,
880,
642,
365,
5906,
14,
339,
4885,
849,
1006,
3326,
787,
11077,
14,
339,
982,
1265,
2934,
370,
3507,
2599,
13,
26306,
402,
2860,
1265,
883,
675,
447,
398,
7749,
19102,
2331,
3674,
288,
7749,
8643,
2729,
17,
2729,
18,
2729,
19,
465,
2005,
7612,
3674,
267,
7749,
19102,
3674,
339,
4236,
340,
1454,
2005,
2860,
1077,
506,
11077,
12,
1265,
883,
675,
447,
398,
7749,
8643,
2729,
17,
2729,
18,
92,
3489,
2729,
19,
92,
3489,
221,
465,
2005,
7612,
3674,
272,
408,
272,
3598,
14,
4050,
8,
267,
298,
19236,
314,
658,
7612,
64,
1947,
687,
314,
658,
2443,
64,
3555,
365,
5906,
436,
298,
267,
298,
14117,
506,
4829,
315,
5634,
413,
14,
709,
14,
3645,
314,
849,
658,
7612,
64,
1947,
3140,
4765,
267,
23687,
6019,
3849,
9,
272,
372,
849,
2969,
14,
7612,
8,
2087,
12,
1526,
9,
421,
199,
32,
2683,
14,
1450,
199,
318,
1642,
1618,
8,
2087,
12,
1526,
304,
272,
408,
272,
961,
365,
314,
6466,
1015,
402,
658,
2246,
1618,
64,
543,
2599,
13,
26306,
14,
272,
710,
17831,
365,
3063,
4890,
436,
642,
1015,
365,
949,
3365,
272,
687,
314,
2222,
13,
2443,
1015,
880,
642,
365,
5906,
14,
339,
961,
365,
7353,
370,
447,
398,
7749,
340,
2729,
17,
3674,
288,
8448,
2729,
17,
3586,
267,
7749,
916,
2729,
18,
3674,
288,
8448,
2729,
18,
3586,
267,
7749,
916,
2729,
19,
3674,
288,
8448,
2729,
19,
3586,
267,
7749,
14454,
3674,
339,
982,
1265,
2934,
370,
3507,
2599,
13,
26306,
402,
2860,
1265,
883,
675,
447,
398,
7749,
19102,
2331,
3674,
288,
7749,
1642,
1618,
2729,
17,
2729,
18,
2729,
19,
3886,
9370,
30,
10538,
574,
1108,
9370,
4335,
3674,
267,
7749,
19102,
3674,
339,
4236,
340,
1454,
2005,
2860,
1077,
506,
11077,
12,
1265,
883,
675,
447,
398,
7749,
1642,
1618,
2729,
17,
2729,
18,
92,
3489,
2729,
19,
3886,
9370,
30,
10538,
574,
1108,
9370,
4335,
92,
3489,
3674,
339,
408,
272,
3598,
14,
4050,
8,
267,
298,
19236,
314,
658,
2246,
1618,
64,
1947,
687,
314,
658,
2443,
64,
3555,
365,
5906,
436,
298,
267,
298,
14117,
506,
4829,
315,
5634,
413,
14,
709,
14,
3645,
314,
849,
658,
2246,
1618,
64,
1947,
3140,
4765,
267,
23687,
6019,
3849,
9,
272,
372,
849,
2969,
14,
2246,
1618,
8,
2087,
12,
1526,
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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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
sylarcp/anita
|
venv/lib/python2.7/site-packages/jinja2/meta.py
|
659
|
4190
|
# -*- coding: utf-8 -*-
"""
jinja2.meta
~~~~~~~~~~~
This module implements various functions that exposes information about
templates that might be interesting for various kinds of applications.
:copyright: (c) 2010 by the Jinja Team, see AUTHORS for more details.
:license: BSD, see LICENSE for more details.
"""
from jinja2 import nodes
from jinja2.compiler import CodeGenerator
from jinja2._compat import string_types
class TrackingCodeGenerator(CodeGenerator):
"""We abuse the code generator for introspection."""
def __init__(self, environment):
CodeGenerator.__init__(self, environment, '<introspection>',
'<introspection>')
self.undeclared_identifiers = set()
def write(self, x):
"""Don't write."""
def pull_locals(self, frame):
"""Remember all undeclared identifiers."""
self.undeclared_identifiers.update(frame.identifiers.undeclared)
def find_undeclared_variables(ast):
"""Returns a set of all variables in the AST that will be looked up from
the context at runtime. Because at compile time it's not known which
variables will be used depending on the path the execution takes at
runtime, all variables are returned.
>>> from jinja2 import Environment, meta
>>> env = Environment()
>>> ast = env.parse('{% set foo = 42 %}{{ bar + foo }}')
>>> meta.find_undeclared_variables(ast)
set(['bar'])
.. admonition:: Implementation
Internally the code generator is used for finding undeclared variables.
This is good to know because the code generator might raise a
:exc:`TemplateAssertionError` during compilation and as a matter of
fact this function can currently raise that exception as well.
"""
codegen = TrackingCodeGenerator(ast.environment)
codegen.visit(ast)
return codegen.undeclared_identifiers
def find_referenced_templates(ast):
"""Finds all the referenced templates from the AST. This will return an
iterator over all the hardcoded template extensions, inclusions and
imports. If dynamic inheritance or inclusion is used, `None` will be
yielded.
>>> from jinja2 import Environment, meta
>>> env = Environment()
>>> ast = env.parse('{% extends "layout.html" %}{% include helper %}')
>>> list(meta.find_referenced_templates(ast))
['layout.html', None]
This function is useful for dependency tracking. For example if you want
to rebuild parts of the website after a layout template has changed.
"""
for node in ast.find_all((nodes.Extends, nodes.FromImport, nodes.Import,
nodes.Include)):
if not isinstance(node.template, nodes.Const):
# a tuple with some non consts in there
if isinstance(node.template, (nodes.Tuple, nodes.List)):
for template_name in node.template.items:
# something const, only yield the strings and ignore
# non-string consts that really just make no sense
if isinstance(template_name, nodes.Const):
if isinstance(template_name.value, string_types):
yield template_name.value
# something dynamic in there
else:
yield None
# something dynamic we don't know about here
else:
yield None
continue
# constant is a basestring, direct template name
if isinstance(node.template.value, string_types):
yield node.template.value
# a tuple or list (latter *should* not happen) made of consts,
# yield the consts that are strings. We could warn here for
# non string values
elif isinstance(node, nodes.Include) and \
isinstance(node.template.value, (tuple, list)):
for template_name in node.template.value:
if isinstance(template_name, string_types):
yield template_name
# something else we don't care about, we could warn here
else:
yield None
|
mit
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
624,
272,
10321,
18,
14,
2024,
272,
221,
4919,
23597,
339,
961,
859,
9031,
7750,
3423,
626,
444,
10553,
2556,
3595,
272,
7009,
626,
5594,
506,
19604,
367,
7750,
24241,
402,
13103,
14,
339,
520,
7307,
26,
334,
67,
9,
7129,
701,
314,
17300,
11682,
12,
1937,
10610,
367,
1655,
2436,
14,
272,
520,
1682,
26,
6289,
12,
1937,
5113,
367,
1655,
2436,
14,
199,
624,
199,
504,
10321,
18,
492,
3380,
199,
504,
10321,
18,
14,
5772,
492,
5495,
7599,
199,
504,
10321,
18,
423,
5819,
492,
1059,
63,
1313,
421,
199,
533,
17507,
316,
3034,
7599,
8,
3034,
7599,
304,
272,
408,
6004,
282,
464,
261,
314,
1233,
4306,
367,
1109,
14254,
1041,
339,
347,
636,
826,
721,
277,
12,
3734,
304,
267,
5495,
7599,
855,
826,
721,
277,
12,
3734,
12,
2650,
21627,
4206,
3044,
2650,
21627,
5971,
267,
291,
14,
31531,
63,
14227,
275,
663,
342,
339,
347,
2218,
8,
277,
12,
671,
304,
267,
408,
16932,
1133,
2218,
1041,
339,
347,
10299,
63,
9350,
8,
277,
12,
2787,
304,
267,
408,
497,
1114,
1006,
625,
13545,
14154,
1041,
267,
291,
14,
31531,
63,
14227,
14,
873,
8,
1943,
14,
14227,
14,
31531,
9,
421,
199,
318,
2342,
63,
31531,
63,
3669,
8,
1810,
304,
272,
408,
3407,
282,
663,
402,
1006,
2860,
315,
314,
20788,
626,
911,
506,
21182,
1536,
687,
272,
314,
1067,
737,
8836,
14,
221,
13821,
737,
6555,
900,
652,
1159,
440,
6040,
1314,
272,
2860,
911,
506,
1202,
10298,
641,
314,
931,
314,
6451,
6181,
737,
272,
8836,
12,
1006,
2860,
787,
2138,
14,
339,
1306,
687,
10321,
18,
492,
9711,
12,
3404,
272,
1306,
2589,
275,
9711,
342,
272,
1306,
6073,
275,
2589,
14,
1122,
24103,
663,
3925,
275,
5685,
17337,
4681,
435,
3925,
28404,
272,
1306,
3404,
14,
1623,
63,
31531,
63,
3669,
8,
1810,
9,
272,
663,
2941,
1700,
1105,
339,
2508,
1503,
31722,
447,
24425,
10817,
1010,
1203,
1183,
314,
1233,
4306,
365,
1202,
367,
17196,
625,
13545,
2860,
14,
2126,
961,
365,
6954,
370,
5715,
2952,
314,
1233,
4306,
5594,
746,
282,
2126,
520,
2804,
1705,
4231,
14844,
64,
5309,
18653,
436,
465,
282,
17247,
402,
2126,
10572,
642,
805,
883,
5544,
746,
626,
1919,
465,
5521,
14,
272,
408,
272,
1233,
2268,
275,
17507,
316,
3034,
7599,
8,
1810,
14,
5418,
9,
272,
1233,
2268,
14,
5427,
8,
1810,
9,
272,
372,
1233,
2268,
14,
31531,
63,
14227,
421,
199,
318,
2342,
63,
22355,
63,
5876,
8,
1810,
304,
272,
408,
30344,
1006,
314,
11812,
7009,
687,
314,
20788,
14,
221,
961,
911,
372,
376,
272,
6122,
1806,
1006,
314,
7508,
15282,
1978,
5478,
12,
315,
18540,
436,
272,
8925,
14,
221,
982,
8336,
15433,
503,
20396,
365,
1202,
12,
658,
403,
64,
911,
506,
272,
28653,
14,
339,
1306,
687,
10321,
18,
492,
9711,
12,
3404,
272,
1306,
2589,
275,
9711,
342,
272,
1306,
6073,
275,
2589,
14,
1122,
24103,
16879,
298,
4209,
14,
1360,
2,
12760,
2387,
5922,
31246,
272,
1306,
769,
8,
2024,
14,
1623,
63,
22355,
63,
5876,
8,
1810,
430,
272,
788,
4209,
14,
1360,
297,
488,
61,
339,
961,
805,
365,
2997,
367,
5936,
15161,
14,
221,
2104,
2893,
340,
1265,
2934,
272,
370,
22110,
4184,
402,
314,
10691,
2410,
282,
7054,
1978,
965,
2896,
14,
272,
408,
272,
367,
1031,
315,
6073,
14,
1623,
63,
452,
1332,
2415,
14,
4377,
795,
12,
3380,
14,
2532,
6295,
12,
3380,
14,
6295,
12,
2892,
3380,
14,
7826,
2298,
267,
340,
440,
1228,
8,
932,
14,
1160,
12,
3380,
14,
6361,
304,
288,
327,
282,
2008,
543,
2005,
2222,
950,
83,
315,
2337,
288,
340,
1228,
8,
932,
14,
1160,
12,
334,
2415,
14,
7075,
12,
3380,
14,
1296,
2298,
355,
367,
1978,
63,
354,
315,
1031,
14,
1160,
14,
1744,
26,
490,
327,
6020,
950,
12,
1454,
1995,
314,
3326,
436,
3686,
490,
327,
2222,
13,
875,
950,
83,
626,
7710,
2951,
1852,
949,
12249,
490,
340,
1228,
8,
1160,
63,
354,
12,
3380,
14,
6361,
304,
717,
340,
1228,
8,
1160,
63,
354,
14,
585,
12,
1059,
63,
1313,
304,
1169,
1995,
1978,
63,
354,
14,
585,
490,
327,
6020,
8336,
315,
2337,
490,
587,
26,
717,
1995,
488,
288,
327,
6020,
8336,
781,
2793,
1133,
5715,
3595,
2348,
288,
587,
26,
355,
1995,
488,
288,
1980,
267,
327,
4413,
365,
282,
7116,
12,
4125,
1978,
536,
267,
340,
1228,
8,
932,
14,
1160,
14,
585,
12,
1059,
63,
1313,
304,
288,
1995,
1031,
14,
1160,
14,
585,
267,
327,
282,
2008,
503,
769,
334,
76,
3760,
627,
5626,
10,
440,
5992,
9,
6326,
402,
950,
83,
12,
267,
327,
1995,
314,
950,
83,
626,
787,
3326,
14,
221,
2136,
4293,
7987,
2348,
367,
267,
327,
2222,
1059,
1338,
267,
916,
1228,
8,
932,
12,
3380,
14,
7826,
9,
436,
971,
1467,
1228,
8,
932,
14,
1160,
14,
585,
12,
334,
2960,
12,
769,
2298,
288,
367,
1978,
63,
354,
315,
1031,
14,
1160,
14,
585,
26,
355,
340,
1228,
8,
1160,
63,
354,
12,
1059,
63,
1313,
304,
490,
1995,
1978,
63,
354,
267,
327,
6020,
587,
781,
2793,
1133,
10296,
3595,
12,
781,
4293,
7987,
2348,
267,
587,
26,
288,
1995,
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
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
624,
272,
10321,
18,
14,
2024,
272,
221,
4919,
23597,
339,
961,
859,
9031,
7750,
3423,
626,
444,
10553,
2556,
3595,
272,
7009,
626,
5594,
506,
19604,
367,
7750,
24241,
402,
13103,
14,
339,
520,
7307,
26,
334,
67,
9,
7129,
701,
314,
17300,
11682,
12,
1937,
10610,
367,
1655,
2436,
14,
272,
520,
1682,
26,
6289,
12,
1937,
5113,
367,
1655,
2436,
14,
199,
624,
199,
504,
10321,
18,
492,
3380,
199,
504,
10321,
18,
14,
5772,
492,
5495,
7599,
199,
504,
10321,
18,
423,
5819,
492,
1059,
63,
1313,
421,
199,
533,
17507,
316,
3034,
7599,
8,
3034,
7599,
304,
272,
408,
6004,
282,
464,
261,
314,
1233,
4306,
367,
1109,
14254,
1041,
339,
347,
636,
826,
721,
277,
12,
3734,
304,
267,
5495,
7599,
855,
826,
721,
277,
12,
3734,
12,
2650,
21627,
4206,
3044,
2650,
21627,
5971,
267,
291,
14,
31531,
63,
14227,
275,
663,
342,
339,
347,
2218,
8,
277,
12,
671,
304,
267,
408,
16932,
1133,
2218,
1041,
339,
347,
10299,
63,
9350,
8,
277,
12,
2787,
304,
267,
408,
497,
1114,
1006,
625,
13545,
14154,
1041,
267,
291,
14,
31531,
63,
14227,
14,
873,
8,
1943,
14,
14227,
14,
31531,
9,
421,
199,
318,
2342,
63,
31531,
63,
3669,
8,
1810,
304,
272,
408,
3407,
282,
663,
402,
1006,
2860,
315,
314,
20788,
626,
911,
506,
21182,
1536,
687,
272,
314,
1067,
737,
8836,
14,
221,
13821,
737,
6555,
900,
652,
1159,
440,
6040,
1314,
272,
2860,
911,
506,
1202,
10298,
641,
314,
931,
314,
6451,
6181,
737,
272,
8836,
12,
1006,
2860,
787,
2138,
14,
339,
1306,
687,
10321,
18,
492,
9711,
12,
3404,
272,
1306,
2589,
275,
9711,
342,
272,
1306,
6073,
275,
2589,
14,
1122,
24103,
663,
3925,
275,
5685,
17337,
4681,
435,
3925,
28404,
272,
1306,
3404,
14,
1623,
63,
31531,
63,
3669,
8,
1810,
9,
272,
663,
2941,
1700,
1105,
339,
2508,
1503,
31722,
447,
24425,
10817,
1010,
1203,
1183,
314,
1233,
4306,
365,
1202,
367,
17196,
625,
13545,
2860,
14,
2126,
961,
365,
6954,
370,
5715,
2952,
314,
1233,
4306,
5594,
746,
282,
2126,
520,
2804,
1705,
4231,
14844,
64,
5309,
18653,
436,
465,
282,
17247,
402,
2126,
10572,
642,
805,
883,
5544,
746,
626,
1919,
465,
5521,
14,
272,
408,
272,
1233,
2268,
275,
17507,
316,
3034,
7599,
8,
1810,
14,
5418,
9,
272,
1233,
2268,
14,
5427,
8,
1810,
9,
272,
372,
1233,
2268,
14,
31531,
63,
14227,
421,
199,
318,
2342,
63,
22355,
63,
5876,
8,
1810,
304,
272,
408,
30344,
1006,
314,
11812,
7009,
687,
314,
20788,
14,
221,
961,
911,
372,
376,
272,
6122,
1806,
1006,
314,
7508,
15282,
1978,
5478,
12,
315,
18540,
436,
272,
8925,
14,
221,
982,
8336,
15433,
503,
20396,
365,
1202,
12,
658,
403,
64,
911,
506,
272,
28653,
14,
339,
1306,
687,
10321,
18,
492,
9711,
12,
3404,
272,
1306,
2589,
275,
9711,
342,
272,
1306,
6073,
275,
2589,
14,
1122,
24103,
16879,
298,
4209,
14,
1360,
2,
12760,
2387,
5922,
31246,
272,
1306,
769,
8,
2024,
14,
1623,
63,
22355,
63,
5876,
8,
1810,
430,
272,
788,
4209,
14,
1360,
297,
488,
61,
339,
961,
805,
365,
2997,
367,
5936,
15161,
14,
221,
2104,
2893,
340,
1265,
2934,
272,
370,
22110,
4184,
402,
314,
10691,
2410,
282,
7054,
1978,
965,
2896,
14,
272,
408,
272,
367,
1031,
315,
6073,
14,
1623,
63,
452,
1332,
2415,
14,
4377,
795,
12,
3380,
14,
2532,
6295,
12,
3380,
14,
6295,
12,
2892,
3380,
14,
7826,
2298,
267,
340,
440,
1228,
8,
932,
14,
1160,
12,
3380,
14,
6361,
304,
288,
327,
282,
2008,
543,
2005,
2222,
950,
83,
315,
2337,
288,
340,
1228,
8,
932,
14,
1160,
12,
334,
2415,
14,
7075,
12,
3380,
14,
1296,
2298,
355,
367,
1978,
63,
354,
315,
1031,
14,
1160,
14,
1744,
26,
490,
327,
6020,
950,
12,
1454,
1995,
314,
3326,
436,
3686,
490,
327,
2222,
13,
875,
950,
83,
626,
7710,
2951,
1852,
949,
12249,
490,
340,
1228,
8,
1160,
63,
354,
12,
3380,
14,
6361,
304,
717,
340,
1228,
8,
1160,
63,
354,
14,
585,
12,
1059,
63,
1313,
304,
1169,
1995,
1978,
63,
354,
14,
585,
490,
327,
6020,
8336,
315,
2337,
490,
587,
26,
717,
1995,
488,
288,
327,
6020,
8336,
781,
2793,
1133,
5715,
3595,
2348,
288,
587,
26,
355,
1995,
488,
288,
1980,
267,
327,
4413,
365,
282,
7116,
12,
4125,
1978,
536,
267,
340,
1228,
8,
932,
14,
1160,
14,
585,
12,
1059,
63,
1313,
304,
288,
1995,
1031,
14,
1160,
14,
585,
267,
327,
282,
2008,
503,
769,
334,
76,
3760,
627,
5626,
10,
440,
5992,
9,
6326,
402,
950,
83,
12,
267,
327,
1995,
314,
950,
83,
626,
787,
3326,
14,
221,
2136,
4293,
7987,
2348,
367,
267,
327,
2222,
1059,
1338,
267,
916,
1228,
8,
932,
12,
3380,
14,
7826,
9,
436,
971,
1467,
1228,
8,
932,
14,
1160,
14,
585,
12,
334,
2960,
12,
769,
2298,
288,
367,
1978,
63,
354,
315,
1031,
14,
1160,
14,
585,
26,
355,
340,
1228,
8,
1160,
63,
354,
12,
1059,
63,
1313,
304,
490,
1995,
1978,
63,
354,
267,
327,
6020,
587,
781,
2793,
1133,
10296,
3595,
12,
781,
4293,
7987,
2348,
267,
587,
26,
288,
1995,
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,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
linked67/p2pool-phicoin
|
nattraverso/pynupnp/upnpxml.py
|
288
|
3026
|
"""
This module parse an UPnP device's XML definition in an Object.
@author: Raphael Slinckx
@copyright: Copyright 2005
@license: LGPL
@contact: U{raphael@slinckx.net<mailto:raphael@slinckx.net>}
@version: 0.1.0
"""
__revision__ = "$id"
from xml.dom import minidom
import logging
# Allowed UPnP services to use when mapping ports/external addresses
WANSERVICES = ['urn:schemas-upnp-org:service:WANIPConnection:1',
'urn:schemas-upnp-org:service:WANPPPConnection:1']
class UPnPXml:
"""
This objects parses the XML definition, and stores the useful
results in attributes.
The device infos dictionnary may contain the following keys:
- friendlyname: A friendly name to call the device.
- manufacturer: A manufacturer name for the device.
Here are the different attributes:
- deviceinfos: A dictionnary of device infos as defined above.
- controlurl: The control url, this is the url to use when sending SOAP
requests to the device, relative to the base url.
- wanservice: The WAN service to be used, one of the L{WANSERVICES}
- urlbase: The base url to use when talking in SOAP to the device.
The full url to use is obtained by urljoin(urlbase, controlurl)
"""
def __init__(self, xml):
"""
Parse the given XML string for UPnP infos. This creates the attributes
when they are found, or None if no value was found.
@param xml: a xml string to parse
"""
logging.debug("Got UPNP Xml description:\n%s", xml)
doc = minidom.parseString(xml)
# Fetch various device info
self.deviceinfos = {}
try:
attributes = {
'friendlyname':'friendlyName',
'manufacturer' : 'manufacturer'
}
device = doc.getElementsByTagName('device')[0]
for name, tag in attributes.iteritems():
try:
self.deviceinfos[name] = device.getElementsByTagName(
tag)[0].firstChild.datas.encode('utf-8')
except:
pass
except:
pass
# Fetch device control url
self.controlurl = None
self.wanservice = None
for service in doc.getElementsByTagName('service'):
try:
stype = service.getElementsByTagName(
'serviceType')[0].firstChild.data.encode('utf-8')
if stype in WANSERVICES:
self.controlurl = service.getElementsByTagName(
'controlURL')[0].firstChild.data.encode('utf-8')
self.wanservice = stype
break
except:
pass
# Find base url
self.urlbase = None
try:
self.urlbase = doc.getElementsByTagName(
'URLBase')[0].firstChild.data.encode('utf-8')
except:
pass
|
gpl-3.0
|
[
624,
199,
2765,
859,
2198,
376,
7215,
30035,
2243,
1159,
4692,
5492,
315,
376,
6935,
14,
199,
199,
32,
2502,
26,
820,
439,
2411,
352,
428,
472,
346,
88,
199,
32,
7307,
26,
1898,
11811,
199,
32,
1682,
26,
32426,
199,
32,
7811,
26,
738,
91,
345,
2914,
352,
32,
83,
472,
346,
88,
14,
846,
28,
26206,
26,
345,
2914,
352,
32,
83,
472,
346,
88,
14,
846,
23307,
199,
32,
1023,
26,
378,
14,
17,
14,
16,
199,
624,
199,
199,
363,
5792,
363,
275,
7880,
344,
2,
199,
199,
504,
2748,
14,
4556,
492,
19165,
199,
646,
2050,
199,
199,
3,
27301,
7215,
30035,
8500,
370,
675,
1380,
4412,
8873,
15,
5159,
7149,
199,
55,
879,
3279,
8670,
275,
788,
349,
26,
9482,
13,
384,
1590,
13,
1308,
26,
1364,
26,
55,
879,
1772,
3225,
26,
17,
297,
272,
283,
349,
26,
9482,
13,
384,
1590,
13,
1308,
26,
1364,
26,
55,
879,
7701,
48,
3225,
26,
17,
418,
199,
199,
533,
7215,
30035,
8672,
26,
272,
408,
272,
961,
2251,
19953,
314,
4692,
5492,
12,
436,
14086,
314,
2997,
272,
2058,
315,
3004,
14,
2286,
710,
2243,
24485,
487,
414,
78,
695,
1443,
1395,
314,
2569,
2883,
26,
267,
446,
21428,
354,
26,
437,
21428,
536,
370,
1240,
314,
2243,
14,
267,
446,
2169,
21087,
26,
437,
2169,
21087,
536,
367,
314,
2243,
14,
2286,
11842,
787,
314,
3365,
3004,
26,
267,
446,
2243,
14195,
26,
437,
487,
414,
78,
695,
402,
2243,
24485,
465,
3247,
3432,
14,
267,
446,
3304,
633,
26,
710,
3304,
1166,
12,
642,
365,
314,
1166,
370,
675,
1380,
10209,
26805,
288,
4145,
370,
314,
2243,
12,
3847,
370,
314,
1300,
1166,
14,
267,
446,
336,
290,
1364,
26,
710,
644,
879,
2435,
370,
506,
1202,
12,
1373,
402,
314,
491,
91,
55,
879,
3279,
8670,
93,
267,
446,
1166,
1095,
26,
710,
1300,
1166,
370,
675,
1380,
22811,
316,
315,
26805,
370,
314,
2243,
14,
2286,
710,
2615,
1166,
370,
675,
365,
15884,
701,
20818,
8,
633,
1095,
12,
3304,
633,
9,
272,
408,
2286,
347,
636,
826,
721,
277,
12,
2748,
304,
267,
408,
267,
6077,
314,
1627,
4692,
1059,
367,
7215,
30035,
24485,
14,
961,
8491,
314,
3004,
267,
1380,
2985,
787,
1911,
12,
503,
488,
340,
949,
574,
1990,
1911,
14,
2728,
768,
635,
2748,
26,
282,
2748,
1059,
370,
2198,
267,
408,
267,
2050,
14,
1757,
480,
13662,
7215,
14970,
24881,
1369,
3427,
78,
5,
83,
401,
2748,
9,
267,
1382,
275,
19165,
14,
14934,
8,
1652,
9,
2728,
327,
16347,
7750,
2243,
2256,
267,
291,
14,
1782,
14195,
275,
1052,
267,
862,
26,
288,
3004,
275,
469,
355,
283,
17317,
354,
5242,
17317,
985,
297,
355,
283,
32214,
7,
520,
283,
32214,
7,
288,
789,
288,
2243,
275,
1382,
14,
15045,
360,
1782,
5832,
16,
61,
288,
367,
536,
12,
1947,
315,
3004,
14,
4611,
837,
355,
862,
26,
490,
291,
14,
1782,
14195,
59,
354,
61,
275,
2243,
14,
15045,
8,
717,
1947,
2788,
16,
1055,
22262,
14,
11563,
14,
2143,
360,
1624,
13,
24,
358,
355,
871,
26,
490,
986,
267,
871,
26,
288,
986,
2728,
327,
16347,
2243,
3304,
1166,
267,
291,
14,
2785,
633,
275,
488,
267,
291,
14,
20444,
1364,
275,
488,
2728,
367,
2435,
315,
1382,
14,
15045,
360,
1364,
735,
288,
862,
26,
355,
410,
514,
275,
2435,
14,
15045,
8,
490,
283,
1364,
804,
5832,
16,
1055,
22262,
14,
576,
14,
2143,
360,
1624,
13,
24,
358,
355,
340,
410,
514,
315,
644,
879,
3279,
8670,
26,
490,
291,
14,
2785,
633,
275,
2435,
14,
15045,
8,
717,
283,
2785,
2632,
5832,
16,
1055,
22262,
14,
576,
14,
2143,
360,
1624,
13,
24,
358,
490,
291,
14,
20444,
1364,
275,
410,
514,
490,
2059,
288,
871,
26,
355,
986,
2728,
327,
6668,
1300,
1166,
267,
291,
14,
633,
1095,
275,
488,
267,
862,
26,
288,
291,
14,
633,
1095,
275,
1382,
14,
15045,
8,
355,
283,
2632,
1563,
5832,
16,
1055,
22262,
14,
576,
14,
2143,
360,
1624,
13,
24,
358,
267,
871,
26,
288,
986,
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
] |
[
199,
2765,
859,
2198,
376,
7215,
30035,
2243,
1159,
4692,
5492,
315,
376,
6935,
14,
199,
199,
32,
2502,
26,
820,
439,
2411,
352,
428,
472,
346,
88,
199,
32,
7307,
26,
1898,
11811,
199,
32,
1682,
26,
32426,
199,
32,
7811,
26,
738,
91,
345,
2914,
352,
32,
83,
472,
346,
88,
14,
846,
28,
26206,
26,
345,
2914,
352,
32,
83,
472,
346,
88,
14,
846,
23307,
199,
32,
1023,
26,
378,
14,
17,
14,
16,
199,
624,
199,
199,
363,
5792,
363,
275,
7880,
344,
2,
199,
199,
504,
2748,
14,
4556,
492,
19165,
199,
646,
2050,
199,
199,
3,
27301,
7215,
30035,
8500,
370,
675,
1380,
4412,
8873,
15,
5159,
7149,
199,
55,
879,
3279,
8670,
275,
788,
349,
26,
9482,
13,
384,
1590,
13,
1308,
26,
1364,
26,
55,
879,
1772,
3225,
26,
17,
297,
272,
283,
349,
26,
9482,
13,
384,
1590,
13,
1308,
26,
1364,
26,
55,
879,
7701,
48,
3225,
26,
17,
418,
199,
199,
533,
7215,
30035,
8672,
26,
272,
408,
272,
961,
2251,
19953,
314,
4692,
5492,
12,
436,
14086,
314,
2997,
272,
2058,
315,
3004,
14,
2286,
710,
2243,
24485,
487,
414,
78,
695,
1443,
1395,
314,
2569,
2883,
26,
267,
446,
21428,
354,
26,
437,
21428,
536,
370,
1240,
314,
2243,
14,
267,
446,
2169,
21087,
26,
437,
2169,
21087,
536,
367,
314,
2243,
14,
2286,
11842,
787,
314,
3365,
3004,
26,
267,
446,
2243,
14195,
26,
437,
487,
414,
78,
695,
402,
2243,
24485,
465,
3247,
3432,
14,
267,
446,
3304,
633,
26,
710,
3304,
1166,
12,
642,
365,
314,
1166,
370,
675,
1380,
10209,
26805,
288,
4145,
370,
314,
2243,
12,
3847,
370,
314,
1300,
1166,
14,
267,
446,
336,
290,
1364,
26,
710,
644,
879,
2435,
370,
506,
1202,
12,
1373,
402,
314,
491,
91,
55,
879,
3279,
8670,
93,
267,
446,
1166,
1095,
26,
710,
1300,
1166,
370,
675,
1380,
22811,
316,
315,
26805,
370,
314,
2243,
14,
2286,
710,
2615,
1166,
370,
675,
365,
15884,
701,
20818,
8,
633,
1095,
12,
3304,
633,
9,
272,
408,
2286,
347,
636,
826,
721,
277,
12,
2748,
304,
267,
408,
267,
6077,
314,
1627,
4692,
1059,
367,
7215,
30035,
24485,
14,
961,
8491,
314,
3004,
267,
1380,
2985,
787,
1911,
12,
503,
488,
340,
949,
574,
1990,
1911,
14,
2728,
768,
635,
2748,
26,
282,
2748,
1059,
370,
2198,
267,
408,
267,
2050,
14,
1757,
480,
13662,
7215,
14970,
24881,
1369,
3427,
78,
5,
83,
401,
2748,
9,
267,
1382,
275,
19165,
14,
14934,
8,
1652,
9,
2728,
327,
16347,
7750,
2243,
2256,
267,
291,
14,
1782,
14195,
275,
1052,
267,
862,
26,
288,
3004,
275,
469,
355,
283,
17317,
354,
5242,
17317,
985,
297,
355,
283,
32214,
7,
520,
283,
32214,
7,
288,
789,
288,
2243,
275,
1382,
14,
15045,
360,
1782,
5832,
16,
61,
288,
367,
536,
12,
1947,
315,
3004,
14,
4611,
837,
355,
862,
26,
490,
291,
14,
1782,
14195,
59,
354,
61,
275,
2243,
14,
15045,
8,
717,
1947,
2788,
16,
1055,
22262,
14,
11563,
14,
2143,
360,
1624,
13,
24,
358,
355,
871,
26,
490,
986,
267,
871,
26,
288,
986,
2728,
327,
16347,
2243,
3304,
1166,
267,
291,
14,
2785,
633,
275,
488,
267,
291,
14,
20444,
1364,
275,
488,
2728,
367,
2435,
315,
1382,
14,
15045,
360,
1364,
735,
288,
862,
26,
355,
410,
514,
275,
2435,
14,
15045,
8,
490,
283,
1364,
804,
5832,
16,
1055,
22262,
14,
576,
14,
2143,
360,
1624,
13,
24,
358,
355,
340,
410,
514,
315,
644,
879,
3279,
8670,
26,
490,
291,
14,
2785,
633,
275,
2435,
14,
15045,
8,
717,
283,
2785,
2632,
5832,
16,
1055,
22262,
14,
576,
14,
2143,
360,
1624,
13,
24,
358,
490,
291,
14,
20444,
1364,
275,
410,
514,
490,
2059,
288,
871,
26,
355,
986,
2728,
327,
6668,
1300,
1166,
267,
291,
14,
633,
1095,
275,
488,
267,
862,
26,
288,
291,
14,
633,
1095,
275,
1382,
14,
15045,
8,
355,
283,
2632,
1563,
5832,
16,
1055,
22262,
14,
576,
14,
2143,
360,
1624,
13,
24,
358,
267,
871,
26,
288,
986,
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,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
devclone/enigma2-9f38fd6
|
lib/python/Tools/CopyFiles.py
|
66
|
2220
|
from Components.Task import PythonTask, Task, Job, job_manager as JobManager
from Tools.Directories import fileExists
from enigma import eTimer
from os import path
from shutil import rmtree, copy2, move
class DeleteFolderTask(PythonTask):
def openFiles(self, fileList):
self.fileList = fileList
def work(self):
print "[DeleteFolderTask] files ", self.fileList
errors = []
try:
rmtree(self.fileList)
except Exception, e:
errors.append(e)
if errors:
raise errors[0]
class CopyFileJob(Job):
def __init__(self, srcfile, destfile, name):
Job.__init__(self, _("Copying files"))
cmdline = 'cp -Rf "%s" "%s"' % (srcfile,destfile)
AddFileProcessTask(self, cmdline, srcfile, destfile, name)
class MoveFileJob(Job):
def __init__(self, srcfile, destfile, name):
Job.__init__(self, _("Moving files"))
cmdline = 'mv -f "%s" "%s"' % (srcfile,destfile)
AddFileProcessTask(self, cmdline, srcfile, destfile, name)
class AddFileProcessTask(Task):
def __init__(self, job, cmdline, srcfile, destfile, name):
Task.__init__(self, job, name)
self.setCmdline(cmdline)
self.srcfile = srcfile
self.destfile = destfile
self.ProgressTimer = eTimer()
self.ProgressTimer.callback.append(self.ProgressUpdate)
def ProgressUpdate(self):
if self.srcsize <= 0 or not fileExists(self.destfile, 'r'):
return
self.setProgress(int((path.getsize(self.destfile)/float(self.srcsize))*100))
self.ProgressTimer.start(5000, True)
def prepare(self):
if fileExists(self.srcfile, 'r'):
self.srcsize = path.getsize(self.srcfile)
self.ProgressTimer.start(5000, True)
def afterRun(self):
self.setProgress(100)
self.ProgressTimer.stop()
def copyFiles(fileList, name):
for src, dst in fileList:
if path.isdir(src) or int(path.getsize(src))/1000/1000 > 100:
JobManager.AddJob(CopyFileJob(src, dst, name))
else:
copy2(src, dst)
def moveFiles(fileList, name):
for src, dst in fileList:
if path.isdir(src) or int(path.getsize(src))/1000/1000 > 100:
JobManager.AddJob(MoveFileJob(src, dst, name))
else:
move(src, dst)
def deleteFiles(fileList, name):
job = Job(_("Deleting files"))
task = DeleteFolderTask(job, name)
task.openFiles(fileList)
JobManager.AddJob(job)
|
gpl-2.0
|
[
504,
17823,
14,
4476,
492,
2018,
4476,
12,
8495,
12,
15057,
12,
3906,
63,
2609,
465,
15057,
2988,
199,
504,
23228,
14,
13752,
492,
570,
7965,
199,
504,
655,
27021,
492,
325,
7929,
199,
504,
747,
492,
931,
199,
504,
5145,
492,
20978,
12,
1331,
18,
12,
4057,
199,
199,
533,
8496,
7850,
4476,
8,
4718,
4476,
304,
199,
198,
318,
1551,
5535,
8,
277,
12,
570,
1296,
304,
507,
198,
277,
14,
493,
1296,
275,
570,
1296,
421,
198,
318,
1736,
8,
277,
304,
507,
198,
1361,
7369,
5392,
7850,
4476,
61,
1584,
3872,
291,
14,
493,
1296,
507,
198,
2550,
275,
942,
507,
198,
893,
26,
686,
198,
9242,
8,
277,
14,
493,
1296,
9,
507,
198,
2590,
2186,
12,
325,
26,
686,
198,
2550,
14,
740,
8,
69,
9,
507,
198,
692,
2552,
26,
686,
198,
3730,
2552,
59,
16,
61,
199,
199,
533,
11247,
1173,
6694,
8,
6694,
304,
199,
198,
318,
636,
826,
721,
277,
12,
2928,
493,
12,
2053,
493,
12,
536,
304,
507,
198,
6694,
855,
826,
721,
277,
12,
3824,
32596,
1584,
2237,
507,
198,
15612,
275,
283,
1850,
446,
28115,
2071,
83,
2,
2071,
83,
4507,
450,
334,
29903,
12,
2614,
493,
9,
507,
198,
1123,
1173,
3498,
4476,
8,
277,
12,
21206,
12,
2928,
493,
12,
2053,
493,
12,
536,
9,
199,
199,
533,
14171,
1173,
6694,
8,
6694,
304,
199,
198,
318,
636,
826,
721,
277,
12,
2928,
493,
12,
2053,
493,
12,
536,
304,
507,
198,
6694,
855,
826,
721,
277,
12,
3824,
29783,
1584,
2237,
507,
198,
15612,
275,
283,
12393,
446,
70,
2071,
83,
2,
2071,
83,
4507,
450,
334,
29903,
12,
2614,
493,
9,
507,
198,
1123,
1173,
3498,
4476,
8,
277,
12,
21206,
12,
2928,
493,
12,
2053,
493,
12,
536,
9,
199,
199,
533,
2654,
1173,
3498,
4476,
8,
4476,
304,
199,
198,
318,
636,
826,
721,
277,
12,
3906,
12,
21206,
12,
2928,
493,
12,
2053,
493,
12,
536,
304,
507,
198,
4476,
855,
826,
721,
277,
12,
3906,
12,
536,
9,
507,
198,
277,
14,
409,
7874,
604,
8,
15612,
9,
507,
198,
277,
14,
29903,
275,
2928,
493,
507,
198,
277,
14,
2614,
493,
275,
2053,
493,
2742,
198,
277,
14,
11504,
7929,
275,
325,
7929,
342,
507,
198,
277,
14,
11504,
7929,
14,
3058,
14,
740,
8,
277,
14,
11504,
4152,
9,
421,
198,
318,
21211,
4152,
8,
277,
304,
507,
198,
692,
291,
14,
2164,
890,
2695,
378,
503,
440,
570,
7965,
8,
277,
14,
2614,
493,
12,
283,
82,
735,
686,
198,
1107,
2742,
198,
277,
14,
409,
11504,
8,
442,
1332,
515,
14,
20733,
8,
277,
14,
2614,
493,
2447,
1609,
8,
277,
14,
2164,
890,
19198,
1960,
430,
507,
198,
277,
14,
11504,
7929,
14,
928,
8,
13128,
12,
715,
9,
421,
198,
318,
9275,
8,
277,
304,
507,
198,
692,
570,
7965,
8,
277,
14,
29903,
12,
283,
82,
735,
686,
198,
277,
14,
2164,
890,
275,
931,
14,
20733,
8,
277,
14,
29903,
9,
686,
198,
277,
14,
11504,
7929,
14,
928,
8,
13128,
12,
715,
9,
421,
198,
318,
2410,
2540,
8,
277,
304,
507,
198,
277,
14,
409,
11504,
8,
1960,
9,
507,
198,
277,
14,
11504,
7929,
14,
2379,
342,
421,
199,
318,
1331,
5535,
8,
493,
1296,
12,
536,
304,
199,
198,
509,
2928,
12,
5042,
315,
570,
1296,
26,
507,
198,
692,
931,
14,
6027,
8,
2164,
9,
503,
1109,
8,
515,
14,
20733,
8,
2164,
13342,
5279,
15,
5279,
690,
2948,
26,
686,
198,
6694,
2988,
14,
1123,
6694,
8,
5116,
1173,
6694,
8,
2164,
12,
5042,
12,
536,
430,
507,
198,
2836,
26,
686,
198,
1574,
18,
8,
2164,
12,
5042,
9,
199,
199,
318,
4057,
5535,
8,
493,
1296,
12,
536,
304,
199,
198,
509,
2928,
12,
5042,
315,
570,
1296,
26,
507,
198,
692,
931,
14,
6027,
8,
2164,
9,
503,
1109,
8,
515,
14,
20733,
8,
2164,
13342,
5279,
15,
5279,
690,
2948,
26,
686,
198,
6694,
2988,
14,
1123,
6694,
8,
10370,
1173,
6694,
8,
2164,
12,
5042,
12,
536,
430,
507,
198,
2836,
26,
686,
198,
1185,
8,
2164,
12,
5042,
9,
199,
199,
318,
3145,
5535,
8,
493,
1296,
12,
536,
304,
199,
198,
2423,
275,
15057,
6115,
22001,
1584,
2237,
199,
198,
1765,
275,
8496,
7850,
4476,
8,
2423,
12,
536,
9,
199,
198,
1765,
14,
1490,
5535,
8,
493,
1296,
9,
199,
198,
6694,
2988,
14,
1123,
6694,
8,
2423,
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
] |
[
17823,
14,
4476,
492,
2018,
4476,
12,
8495,
12,
15057,
12,
3906,
63,
2609,
465,
15057,
2988,
199,
504,
23228,
14,
13752,
492,
570,
7965,
199,
504,
655,
27021,
492,
325,
7929,
199,
504,
747,
492,
931,
199,
504,
5145,
492,
20978,
12,
1331,
18,
12,
4057,
199,
199,
533,
8496,
7850,
4476,
8,
4718,
4476,
304,
199,
198,
318,
1551,
5535,
8,
277,
12,
570,
1296,
304,
507,
198,
277,
14,
493,
1296,
275,
570,
1296,
421,
198,
318,
1736,
8,
277,
304,
507,
198,
1361,
7369,
5392,
7850,
4476,
61,
1584,
3872,
291,
14,
493,
1296,
507,
198,
2550,
275,
942,
507,
198,
893,
26,
686,
198,
9242,
8,
277,
14,
493,
1296,
9,
507,
198,
2590,
2186,
12,
325,
26,
686,
198,
2550,
14,
740,
8,
69,
9,
507,
198,
692,
2552,
26,
686,
198,
3730,
2552,
59,
16,
61,
199,
199,
533,
11247,
1173,
6694,
8,
6694,
304,
199,
198,
318,
636,
826,
721,
277,
12,
2928,
493,
12,
2053,
493,
12,
536,
304,
507,
198,
6694,
855,
826,
721,
277,
12,
3824,
32596,
1584,
2237,
507,
198,
15612,
275,
283,
1850,
446,
28115,
2071,
83,
2,
2071,
83,
4507,
450,
334,
29903,
12,
2614,
493,
9,
507,
198,
1123,
1173,
3498,
4476,
8,
277,
12,
21206,
12,
2928,
493,
12,
2053,
493,
12,
536,
9,
199,
199,
533,
14171,
1173,
6694,
8,
6694,
304,
199,
198,
318,
636,
826,
721,
277,
12,
2928,
493,
12,
2053,
493,
12,
536,
304,
507,
198,
6694,
855,
826,
721,
277,
12,
3824,
29783,
1584,
2237,
507,
198,
15612,
275,
283,
12393,
446,
70,
2071,
83,
2,
2071,
83,
4507,
450,
334,
29903,
12,
2614,
493,
9,
507,
198,
1123,
1173,
3498,
4476,
8,
277,
12,
21206,
12,
2928,
493,
12,
2053,
493,
12,
536,
9,
199,
199,
533,
2654,
1173,
3498,
4476,
8,
4476,
304,
199,
198,
318,
636,
826,
721,
277,
12,
3906,
12,
21206,
12,
2928,
493,
12,
2053,
493,
12,
536,
304,
507,
198,
4476,
855,
826,
721,
277,
12,
3906,
12,
536,
9,
507,
198,
277,
14,
409,
7874,
604,
8,
15612,
9,
507,
198,
277,
14,
29903,
275,
2928,
493,
507,
198,
277,
14,
2614,
493,
275,
2053,
493,
2742,
198,
277,
14,
11504,
7929,
275,
325,
7929,
342,
507,
198,
277,
14,
11504,
7929,
14,
3058,
14,
740,
8,
277,
14,
11504,
4152,
9,
421,
198,
318,
21211,
4152,
8,
277,
304,
507,
198,
692,
291,
14,
2164,
890,
2695,
378,
503,
440,
570,
7965,
8,
277,
14,
2614,
493,
12,
283,
82,
735,
686,
198,
1107,
2742,
198,
277,
14,
409,
11504,
8,
442,
1332,
515,
14,
20733,
8,
277,
14,
2614,
493,
2447,
1609,
8,
277,
14,
2164,
890,
19198,
1960,
430,
507,
198,
277,
14,
11504,
7929,
14,
928,
8,
13128,
12,
715,
9,
421,
198,
318,
9275,
8,
277,
304,
507,
198,
692,
570,
7965,
8,
277,
14,
29903,
12,
283,
82,
735,
686,
198,
277,
14,
2164,
890,
275,
931,
14,
20733,
8,
277,
14,
29903,
9,
686,
198,
277,
14,
11504,
7929,
14,
928,
8,
13128,
12,
715,
9,
421,
198,
318,
2410,
2540,
8,
277,
304,
507,
198,
277,
14,
409,
11504,
8,
1960,
9,
507,
198,
277,
14,
11504,
7929,
14,
2379,
342,
421,
199,
318,
1331,
5535,
8,
493,
1296,
12,
536,
304,
199,
198,
509,
2928,
12,
5042,
315,
570,
1296,
26,
507,
198,
692,
931,
14,
6027,
8,
2164,
9,
503,
1109,
8,
515,
14,
20733,
8,
2164,
13342,
5279,
15,
5279,
690,
2948,
26,
686,
198,
6694,
2988,
14,
1123,
6694,
8,
5116,
1173,
6694,
8,
2164,
12,
5042,
12,
536,
430,
507,
198,
2836,
26,
686,
198,
1574,
18,
8,
2164,
12,
5042,
9,
199,
199,
318,
4057,
5535,
8,
493,
1296,
12,
536,
304,
199,
198,
509,
2928,
12,
5042,
315,
570,
1296,
26,
507,
198,
692,
931,
14,
6027,
8,
2164,
9,
503,
1109,
8,
515,
14,
20733,
8,
2164,
13342,
5279,
15,
5279,
690,
2948,
26,
686,
198,
6694,
2988,
14,
1123,
6694,
8,
10370,
1173,
6694,
8,
2164,
12,
5042,
12,
536,
430,
507,
198,
2836,
26,
686,
198,
1185,
8,
2164,
12,
5042,
9,
199,
199,
318,
3145,
5535,
8,
493,
1296,
12,
536,
304,
199,
198,
2423,
275,
15057,
6115,
22001,
1584,
2237,
199,
198,
1765,
275,
8496,
7850,
4476,
8,
2423,
12,
536,
9,
199,
198,
1765,
14,
1490,
5535,
8,
493,
1296,
9,
199,
198,
6694,
2988,
14,
1123,
6694,
8,
2423,
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,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
Glorf/servo
|
tests/wpt/web-platform-tests/tools/pytest/testing/test_parseopt.py
|
171
|
12294
|
from __future__ import with_statement
import sys
import os
import py, pytest
from _pytest import config as parseopt
@pytest.fixture
def parser():
return parseopt.Parser()
class TestParser:
def test_no_help_by_default(self, capsys):
parser = parseopt.Parser(usage="xyz")
pytest.raises(SystemExit, lambda: parser.parse(["-h"]))
out, err = capsys.readouterr()
assert err.find("error: unrecognized arguments") != -1
def test_argument(self):
with pytest.raises(parseopt.ArgumentError):
# need a short or long option
argument = parseopt.Argument()
argument = parseopt.Argument('-t')
assert argument._short_opts == ['-t']
assert argument._long_opts == []
assert argument.dest == 't'
argument = parseopt.Argument('-t', '--test')
assert argument._short_opts == ['-t']
assert argument._long_opts == ['--test']
assert argument.dest == 'test'
argument = parseopt.Argument('-t', '--test', dest='abc')
assert argument.dest == 'abc'
def test_argument_type(self):
argument = parseopt.Argument('-t', dest='abc', type='int')
assert argument.type is int
argument = parseopt.Argument('-t', dest='abc', type='string')
assert argument.type is str
argument = parseopt.Argument('-t', dest='abc', type=float)
assert argument.type is float
with pytest.raises(KeyError):
argument = parseopt.Argument('-t', dest='abc', type='choice')
argument = parseopt.Argument('-t', dest='abc', type='choice',
choices=['red', 'blue'])
assert argument.type is str
def test_argument_processopt(self):
argument = parseopt.Argument('-t', type=int)
argument.default = 42
argument.dest = 'abc'
res = argument.attrs()
assert res['default'] == 42
assert res['dest'] == 'abc'
def test_group_add_and_get(self, parser):
group = parser.getgroup("hello", description="desc")
assert group.name == "hello"
assert group.description == "desc"
def test_getgroup_simple(self, parser):
group = parser.getgroup("hello", description="desc")
assert group.name == "hello"
assert group.description == "desc"
group2 = parser.getgroup("hello")
assert group2 is group
def test_group_ordering(self, parser):
parser.getgroup("1")
parser.getgroup("2")
parser.getgroup("3", after="1")
groups = parser._groups
groups_names = [x.name for x in groups]
assert groups_names == list("132")
def test_group_addoption(self):
group = parseopt.OptionGroup("hello")
group.addoption("--option1", action="store_true")
assert len(group.options) == 1
assert isinstance(group.options[0], parseopt.Argument)
def test_group_shortopt_lowercase(self, parser):
group = parser.getgroup("hello")
pytest.raises(ValueError, """
group.addoption("-x", action="store_true")
""")
assert len(group.options) == 0
group._addoption("-x", action="store_true")
assert len(group.options) == 1
def test_parser_addoption(self, parser):
group = parser.getgroup("custom options")
assert len(group.options) == 0
group.addoption("--option1", action="store_true")
assert len(group.options) == 1
def test_parse(self, parser):
parser.addoption("--hello", dest="hello", action="store")
args = parser.parse(['--hello', 'world'])
assert args.hello == "world"
assert not getattr(args, parseopt.FILE_OR_DIR)
def test_parse2(self, parser):
args = parser.parse([py.path.local()])
assert getattr(args, parseopt.FILE_OR_DIR)[0] == py.path.local()
def test_parse_known_args(self, parser):
parser.parse_known_args([py.path.local()])
parser.addoption("--hello", action="store_true")
ns = parser.parse_known_args(["x", "--y", "--hello", "this"])
assert ns.hello
assert ns.file_or_dir == ['x']
def test_parse_known_and_unknown_args(self, parser):
parser.addoption("--hello", action="store_true")
ns, unknown = parser.parse_known_and_unknown_args(["x", "--y",
"--hello", "this"])
assert ns.hello
assert ns.file_or_dir == ['x']
assert unknown == ['--y', 'this']
def test_parse_will_set_default(self, parser):
parser.addoption("--hello", dest="hello", default="x", action="store")
option = parser.parse([])
assert option.hello == "x"
del option.hello
parser.parse_setoption([], option)
assert option.hello == "x"
def test_parse_setoption(self, parser):
parser.addoption("--hello", dest="hello", action="store")
parser.addoption("--world", dest="world", default=42)
class A: pass
option = A()
args = parser.parse_setoption(['--hello', 'world'], option)
assert option.hello == "world"
assert option.world == 42
assert not args
def test_parse_special_destination(self, parser):
parser.addoption("--ultimate-answer", type=int)
args = parser.parse(['--ultimate-answer', '42'])
assert args.ultimate_answer == 42
def test_parse_split_positional_arguments(self, parser):
parser.addoption("-R", action='store_true')
parser.addoption("-S", action='store_false')
args = parser.parse(['-R', '4', '2', '-S'])
assert getattr(args, parseopt.FILE_OR_DIR) == ['4', '2']
args = parser.parse(['-R', '-S', '4', '2', '-R'])
assert getattr(args, parseopt.FILE_OR_DIR) == ['4', '2']
assert args.R == True
assert args.S == False
args = parser.parse(['-R', '4', '-S', '2'])
assert getattr(args, parseopt.FILE_OR_DIR) == ['4', '2']
assert args.R == True
assert args.S == False
def test_parse_defaultgetter(self):
def defaultget(option):
if not hasattr(option, 'type'):
return
if option.type is int:
option.default = 42
elif option.type is str:
option.default = "world"
parser = parseopt.Parser(processopt=defaultget)
parser.addoption("--this", dest="this", type="int", action="store")
parser.addoption("--hello", dest="hello", type="string", action="store")
parser.addoption("--no", dest="no", action="store_true")
option = parser.parse([])
assert option.hello == "world"
assert option.this == 42
assert option.no is False
def test_drop_short_helper(self):
parser = py.std.argparse.ArgumentParser(formatter_class=parseopt.DropShorterLongHelpFormatter)
parser.add_argument('-t', '--twoword', '--duo', '--two-word', '--two',
help='foo').map_long_option = {'two': 'two-word'}
# throws error on --deux only!
parser.add_argument('-d', '--deuxmots', '--deux-mots',
action='store_true', help='foo').map_long_option = {'deux': 'deux-mots'}
parser.add_argument('-s', action='store_true', help='single short')
parser.add_argument('--abc', '-a',
action='store_true', help='bar')
parser.add_argument('--klm', '-k', '--kl-m',
action='store_true', help='bar')
parser.add_argument('-P', '--pq-r', '-p', '--pqr',
action='store_true', help='bar')
parser.add_argument('--zwei-wort', '--zweiwort', '--zweiwort',
action='store_true', help='bar')
parser.add_argument('-x', '--exit-on-first', '--exitfirst',
action='store_true', help='spam').map_long_option = {'exitfirst': 'exit-on-first'}
parser.add_argument('files_and_dirs', nargs='*')
args = parser.parse_args(['-k', '--duo', 'hallo', '--exitfirst'])
assert args.twoword == 'hallo'
assert args.klm is True
assert args.zwei_wort is False
assert args.exit_on_first is True
assert args.s is False
args = parser.parse_args(['--deux-mots'])
with pytest.raises(AttributeError):
assert args.deux_mots is True
assert args.deuxmots is True
args = parser.parse_args(['file', 'dir'])
assert '|'.join(args.files_and_dirs) == 'file|dir'
def test_drop_short_0(self, parser):
parser.addoption('--funcarg', '--func-arg', action='store_true')
parser.addoption('--abc-def', '--abc-def', action='store_true')
parser.addoption('--klm-hij', action='store_true')
args = parser.parse(['--funcarg', '--k'])
assert args.funcarg is True
assert args.abc_def is False
assert args.klm_hij is True
def test_drop_short_2(self, parser):
parser.addoption('--func-arg', '--doit', action='store_true')
args = parser.parse(['--doit'])
assert args.func_arg is True
def test_drop_short_3(self, parser):
parser.addoption('--func-arg', '--funcarg', '--doit', action='store_true')
args = parser.parse(['abcd'])
assert args.func_arg is False
assert args.file_or_dir == ['abcd']
def test_drop_short_help0(self, parser, capsys):
parser.addoption('--func-args', '--doit', help = 'foo',
action='store_true')
parser.parse([])
help = parser.optparser.format_help()
assert '--func-args, --doit foo' in help
# testing would be more helpful with all help generated
def test_drop_short_help1(self, parser, capsys):
group = parser.getgroup("general")
group.addoption('--doit', '--func-args', action='store_true', help='foo')
group._addoption("-h", "--help", action="store_true", dest="help",
help="show help message and configuration info")
parser.parse(['-h'])
help = parser.optparser.format_help()
assert '-doit, --func-args foo' in help
def test_argcomplete(testdir, monkeypatch):
if not py.path.local.sysfind('bash'):
pytest.skip("bash not available")
script = str(testdir.tmpdir.join("test_argcomplete"))
pytest_bin = sys.argv[0]
if "py.test" not in os.path.basename(pytest_bin):
pytest.skip("need to be run with py.test executable, not %s" %(pytest_bin,))
with open(str(script), 'w') as fp:
# redirect output from argcomplete to stdin and stderr is not trivial
# http://stackoverflow.com/q/12589419/1307905
# so we use bash
fp.write('COMP_WORDBREAKS="$COMP_WORDBREAKS" %s 8>&1 9>&2' % pytest_bin)
# alternative would be exteneded Testdir.{run(),_run(),popen()} to be able
# to handle a keyword argument env that replaces os.environ in popen or
# extends the copy, advantage: could not forget to restore
monkeypatch.setenv('_ARGCOMPLETE', "1")
monkeypatch.setenv('_ARGCOMPLETE_IFS',"\x0b")
monkeypatch.setenv('COMP_WORDBREAKS', ' \\t\\n"\\\'><=;|&(:')
arg = '--fu'
monkeypatch.setenv('COMP_LINE', "py.test " + arg)
monkeypatch.setenv('COMP_POINT', str(len("py.test " + arg)))
result = testdir.run('bash', str(script), arg)
if result.ret == 255:
# argcomplete not found
pytest.skip("argcomplete not available")
elif not result.stdout.str():
pytest.skip("bash provided no output, argcomplete not available?")
else:
if py.std.sys.version_info < (2,7):
result.stdout.lines = result.stdout.lines[0].split('\x0b')
result.stdout.fnmatch_lines(["--funcargs", "--fulltrace"])
else:
result.stdout.fnmatch_lines(["--funcargs", "--fulltrace"])
if py.std.sys.version_info < (2,7):
return
os.mkdir('test_argcomplete.d')
arg = 'test_argc'
monkeypatch.setenv('COMP_LINE', "py.test " + arg)
monkeypatch.setenv('COMP_POINT', str(len('py.test ' + arg)))
result = testdir.run('bash', str(script), arg)
result.stdout.fnmatch_lines(["test_argcomplete", "test_argcomplete.d/"])
|
mpl-2.0
|
[
504,
636,
2443,
363,
492,
543,
63,
6242,
199,
646,
984,
199,
646,
747,
199,
646,
1134,
12,
4613,
199,
504,
485,
4462,
492,
1101,
465,
2198,
2992,
199,
199,
32,
4462,
14,
5997,
199,
318,
1798,
837,
272,
372,
2198,
2992,
14,
2842,
342,
199,
199,
533,
1379,
2842,
26,
272,
347,
511,
63,
889,
63,
3437,
63,
991,
63,
885,
8,
277,
12,
4021,
1274,
304,
267,
1798,
275,
2198,
2992,
14,
2842,
8,
3807,
628,
8568,
531,
267,
4613,
14,
3536,
8,
24738,
12,
2400,
26,
1798,
14,
1122,
5234,
13,
72,
13045,
267,
734,
12,
2329,
275,
4021,
1274,
14,
739,
7837,
82,
342,
267,
702,
2329,
14,
1623,
480,
705,
26,
24718,
2368,
531,
1137,
446,
17,
339,
347,
511,
63,
2094,
8,
277,
304,
267,
543,
4613,
14,
3536,
8,
1122,
2992,
14,
17042,
304,
288,
327,
1929,
282,
3974,
503,
1846,
945,
288,
1423,
275,
2198,
2992,
14,
5201,
342,
267,
1423,
275,
2198,
2992,
14,
5201,
3654,
84,
358,
267,
702,
1423,
423,
3612,
63,
3291,
508,
11573,
84,
418,
267,
702,
1423,
423,
2809,
63,
3291,
508,
942,
267,
702,
1423,
14,
2614,
508,
283,
84,
7,
267,
1423,
275,
2198,
2992,
14,
5201,
3654,
84,
297,
2850,
396,
358,
267,
702,
1423,
423,
3612,
63,
3291,
508,
11573,
84,
418,
267,
702,
1423,
423,
2809,
63,
3291,
508,
14574,
396,
418,
267,
702,
1423,
14,
2614,
508,
283,
396,
7,
267,
1423,
275,
2198,
2992,
14,
5201,
3654,
84,
297,
2850,
396,
297,
2053,
534,
3175,
358,
267,
702,
1423,
14,
2614,
508,
283,
3175,
7,
339,
347,
511,
63,
2094,
63,
466,
8,
277,
304,
267,
1423,
275,
2198,
2992,
14,
5201,
3654,
84,
297,
2053,
534,
3175,
297,
730,
534,
442,
358,
267,
702,
1423,
14,
466,
365,
1109,
267,
1423,
275,
2198,
2992,
14,
5201,
3654,
84,
297,
2053,
534,
3175,
297,
730,
534,
875,
358,
267,
702,
1423,
14,
466,
365,
620,
267,
1423,
275,
2198,
2992,
14,
5201,
3654,
84,
297,
2053,
534,
3175,
297,
730,
29,
1609,
9,
267,
702,
1423,
14,
466,
365,
2069,
267,
543,
4613,
14,
3536,
8,
10230,
304,
288,
1423,
275,
2198,
2992,
14,
5201,
3654,
84,
297,
2053,
534,
3175,
297,
730,
534,
5095,
358,
267,
1423,
275,
2198,
2992,
14,
5201,
3654,
84,
297,
2053,
534,
3175,
297,
730,
534,
5095,
297,
3660,
3415,
2968,
581,
297,
283,
6304,
1105,
267,
702,
1423,
14,
466,
365,
620,
339,
347,
511,
63,
2094,
63,
1412,
2992,
8,
277,
304,
267,
1423,
275,
2198,
2992,
14,
5201,
3654,
84,
297,
730,
29,
442,
9,
267,
1423,
14,
885,
275,
5685,
267,
1423,
14,
2614,
275,
283,
3175,
7,
267,
522,
275,
1423,
14,
3288,
342,
267,
702,
522,
459,
885,
418,
508,
5685,
267,
702,
522,
459,
2614,
418,
508,
283,
3175,
7,
339,
347,
511,
63,
923,
63,
525,
63,
460,
63,
362,
8,
277,
12,
1798,
304,
267,
1572,
275,
1798,
14,
362,
923,
480,
5006,
401,
1369,
628,
3257,
531,
267,
702,
1572,
14,
354,
508,
298,
5006,
2,
267,
702,
1572,
14,
1802,
508,
298,
3257,
2,
339,
347,
511,
63,
362,
923,
63,
4129,
8,
277,
12,
1798,
304,
267,
1572,
275,
1798,
14,
362,
923,
480,
5006,
401,
1369,
628,
3257,
531,
267,
702,
1572,
14,
354,
508,
298,
5006,
2,
267,
702,
1572,
14,
1802,
508,
298,
3257,
2,
267,
1572,
18,
275,
1798,
14,
362,
923,
480,
5006,
531,
267,
702,
1572,
18,
365,
1572,
339,
347,
511,
63,
923,
63,
7128,
8,
277,
12,
1798,
304,
267,
1798,
14,
362,
923,
480,
17,
531,
267,
1798,
14,
362,
923,
480,
18,
531,
267,
1798,
14,
362,
923,
480,
19,
401,
2410,
628,
17,
531,
267,
4652,
275,
1798,
423,
2634,
267,
4652,
63,
1247,
275,
359,
88,
14,
354,
367,
671,
315,
4652,
61,
267,
702,
4652,
63,
1247,
508,
769,
480,
6557,
531,
339,
347,
511,
63,
923,
63,
525,
1422,
8,
277,
304,
267,
1572,
275,
2198,
2992,
14,
2602,
2448,
480,
5006,
531,
267,
1572,
14,
525,
1422,
6739,
1422,
17,
401,
1595,
628,
1617,
63,
2052,
531,
267,
702,
822,
8,
923,
14,
1419,
9,
508,
413,
267,
702,
1228,
8,
923,
14,
1419,
59,
16,
467,
2198,
2992,
14,
5201,
9,
339,
347,
511,
63,
923,
63,
3612,
2992,
63,
21636,
8,
277,
12,
1798,
304,
267,
1572,
275,
1798,
14,
362,
923,
480,
5006,
531,
267,
4613,
14,
3536,
8,
3393,
12,
408,
288,
1572,
14,
525,
1422,
6096,
88,
401,
1595,
628,
1617,
63,
2052,
531,
267,
7857,
267,
702,
822,
8,
923,
14,
1419,
9,
508,
378,
267,
1572,
423,
525,
1422,
6096,
88,
401,
1595,
628,
1617,
63,
2052,
531,
267,
702,
822,
8,
923,
14,
1419,
9,
508,
413,
339,
347,
511,
63,
2087,
63,
525,
1422,
8,
277,
12,
1798,
304,
267,
1572,
275,
1798,
14,
362,
923,
480,
4229,
1511,
531,
267,
702,
822,
8,
923,
14,
1419,
9,
508,
378,
267,
1572,
14,
525,
1422,
6739,
1422,
17,
401,
1595,
628,
1617,
63,
2052,
531,
267,
702,
822,
8,
923,
14,
1419,
9,
508,
413,
339,
347,
511,
63,
1122,
8,
277,
12,
1798,
304,
267,
1798,
14,
525,
1422,
6739,
5006,
401,
2053,
628,
5006,
401,
1595,
628,
1617,
531,
267,
1249,
275,
1798,
14,
1122,
18510,
5006,
297,
283,
7617,
1105,
267,
702,
1249,
14,
5006,
508,
298,
7617,
2,
267,
702,
440,
2519,
8,
589,
12,
2198,
2992,
14,
3817,
63,
726,
63,
3022,
9,
339,
347,
511,
63,
1122,
18,
8,
277,
12,
1798,
304,
267,
1249,
275,
1798,
14,
1122,
779,
647,
14,
515,
14,
1832,
9383,
267,
702,
2519,
8,
589,
12,
2198,
2992,
14,
3817,
63,
726,
63,
3022,
2788,
16,
61,
508,
1134,
14,
515,
14,
1832,
342,
339,
347,
511,
63,
1122,
63,
3159,
63,
589,
8,
277,
12,
1798,
304,
267,
1798,
14,
1122,
63,
3159,
63,
589,
779,
647,
14,
515,
14,
1832,
9383,
267,
1798,
14,
525,
1422,
6739,
5006,
401,
1595,
628,
1617,
63,
2052,
531,
267,
700,
275,
1798,
14,
1122,
63,
3159,
63,
589,
5234,
88
] |
[
636,
2443,
363,
492,
543,
63,
6242,
199,
646,
984,
199,
646,
747,
199,
646,
1134,
12,
4613,
199,
504,
485,
4462,
492,
1101,
465,
2198,
2992,
199,
199,
32,
4462,
14,
5997,
199,
318,
1798,
837,
272,
372,
2198,
2992,
14,
2842,
342,
199,
199,
533,
1379,
2842,
26,
272,
347,
511,
63,
889,
63,
3437,
63,
991,
63,
885,
8,
277,
12,
4021,
1274,
304,
267,
1798,
275,
2198,
2992,
14,
2842,
8,
3807,
628,
8568,
531,
267,
4613,
14,
3536,
8,
24738,
12,
2400,
26,
1798,
14,
1122,
5234,
13,
72,
13045,
267,
734,
12,
2329,
275,
4021,
1274,
14,
739,
7837,
82,
342,
267,
702,
2329,
14,
1623,
480,
705,
26,
24718,
2368,
531,
1137,
446,
17,
339,
347,
511,
63,
2094,
8,
277,
304,
267,
543,
4613,
14,
3536,
8,
1122,
2992,
14,
17042,
304,
288,
327,
1929,
282,
3974,
503,
1846,
945,
288,
1423,
275,
2198,
2992,
14,
5201,
342,
267,
1423,
275,
2198,
2992,
14,
5201,
3654,
84,
358,
267,
702,
1423,
423,
3612,
63,
3291,
508,
11573,
84,
418,
267,
702,
1423,
423,
2809,
63,
3291,
508,
942,
267,
702,
1423,
14,
2614,
508,
283,
84,
7,
267,
1423,
275,
2198,
2992,
14,
5201,
3654,
84,
297,
2850,
396,
358,
267,
702,
1423,
423,
3612,
63,
3291,
508,
11573,
84,
418,
267,
702,
1423,
423,
2809,
63,
3291,
508,
14574,
396,
418,
267,
702,
1423,
14,
2614,
508,
283,
396,
7,
267,
1423,
275,
2198,
2992,
14,
5201,
3654,
84,
297,
2850,
396,
297,
2053,
534,
3175,
358,
267,
702,
1423,
14,
2614,
508,
283,
3175,
7,
339,
347,
511,
63,
2094,
63,
466,
8,
277,
304,
267,
1423,
275,
2198,
2992,
14,
5201,
3654,
84,
297,
2053,
534,
3175,
297,
730,
534,
442,
358,
267,
702,
1423,
14,
466,
365,
1109,
267,
1423,
275,
2198,
2992,
14,
5201,
3654,
84,
297,
2053,
534,
3175,
297,
730,
534,
875,
358,
267,
702,
1423,
14,
466,
365,
620,
267,
1423,
275,
2198,
2992,
14,
5201,
3654,
84,
297,
2053,
534,
3175,
297,
730,
29,
1609,
9,
267,
702,
1423,
14,
466,
365,
2069,
267,
543,
4613,
14,
3536,
8,
10230,
304,
288,
1423,
275,
2198,
2992,
14,
5201,
3654,
84,
297,
2053,
534,
3175,
297,
730,
534,
5095,
358,
267,
1423,
275,
2198,
2992,
14,
5201,
3654,
84,
297,
2053,
534,
3175,
297,
730,
534,
5095,
297,
3660,
3415,
2968,
581,
297,
283,
6304,
1105,
267,
702,
1423,
14,
466,
365,
620,
339,
347,
511,
63,
2094,
63,
1412,
2992,
8,
277,
304,
267,
1423,
275,
2198,
2992,
14,
5201,
3654,
84,
297,
730,
29,
442,
9,
267,
1423,
14,
885,
275,
5685,
267,
1423,
14,
2614,
275,
283,
3175,
7,
267,
522,
275,
1423,
14,
3288,
342,
267,
702,
522,
459,
885,
418,
508,
5685,
267,
702,
522,
459,
2614,
418,
508,
283,
3175,
7,
339,
347,
511,
63,
923,
63,
525,
63,
460,
63,
362,
8,
277,
12,
1798,
304,
267,
1572,
275,
1798,
14,
362,
923,
480,
5006,
401,
1369,
628,
3257,
531,
267,
702,
1572,
14,
354,
508,
298,
5006,
2,
267,
702,
1572,
14,
1802,
508,
298,
3257,
2,
339,
347,
511,
63,
362,
923,
63,
4129,
8,
277,
12,
1798,
304,
267,
1572,
275,
1798,
14,
362,
923,
480,
5006,
401,
1369,
628,
3257,
531,
267,
702,
1572,
14,
354,
508,
298,
5006,
2,
267,
702,
1572,
14,
1802,
508,
298,
3257,
2,
267,
1572,
18,
275,
1798,
14,
362,
923,
480,
5006,
531,
267,
702,
1572,
18,
365,
1572,
339,
347,
511,
63,
923,
63,
7128,
8,
277,
12,
1798,
304,
267,
1798,
14,
362,
923,
480,
17,
531,
267,
1798,
14,
362,
923,
480,
18,
531,
267,
1798,
14,
362,
923,
480,
19,
401,
2410,
628,
17,
531,
267,
4652,
275,
1798,
423,
2634,
267,
4652,
63,
1247,
275,
359,
88,
14,
354,
367,
671,
315,
4652,
61,
267,
702,
4652,
63,
1247,
508,
769,
480,
6557,
531,
339,
347,
511,
63,
923,
63,
525,
1422,
8,
277,
304,
267,
1572,
275,
2198,
2992,
14,
2602,
2448,
480,
5006,
531,
267,
1572,
14,
525,
1422,
6739,
1422,
17,
401,
1595,
628,
1617,
63,
2052,
531,
267,
702,
822,
8,
923,
14,
1419,
9,
508,
413,
267,
702,
1228,
8,
923,
14,
1419,
59,
16,
467,
2198,
2992,
14,
5201,
9,
339,
347,
511,
63,
923,
63,
3612,
2992,
63,
21636,
8,
277,
12,
1798,
304,
267,
1572,
275,
1798,
14,
362,
923,
480,
5006,
531,
267,
4613,
14,
3536,
8,
3393,
12,
408,
288,
1572,
14,
525,
1422,
6096,
88,
401,
1595,
628,
1617,
63,
2052,
531,
267,
7857,
267,
702,
822,
8,
923,
14,
1419,
9,
508,
378,
267,
1572,
423,
525,
1422,
6096,
88,
401,
1595,
628,
1617,
63,
2052,
531,
267,
702,
822,
8,
923,
14,
1419,
9,
508,
413,
339,
347,
511,
63,
2087,
63,
525,
1422,
8,
277,
12,
1798,
304,
267,
1572,
275,
1798,
14,
362,
923,
480,
4229,
1511,
531,
267,
702,
822,
8,
923,
14,
1419,
9,
508,
378,
267,
1572,
14,
525,
1422,
6739,
1422,
17,
401,
1595,
628,
1617,
63,
2052,
531,
267,
702,
822,
8,
923,
14,
1419,
9,
508,
413,
339,
347,
511,
63,
1122,
8,
277,
12,
1798,
304,
267,
1798,
14,
525,
1422,
6739,
5006,
401,
2053,
628,
5006,
401,
1595,
628,
1617,
531,
267,
1249,
275,
1798,
14,
1122,
18510,
5006,
297,
283,
7617,
1105,
267,
702,
1249,
14,
5006,
508,
298,
7617,
2,
267,
702,
440,
2519,
8,
589,
12,
2198,
2992,
14,
3817,
63,
726,
63,
3022,
9,
339,
347,
511,
63,
1122,
18,
8,
277,
12,
1798,
304,
267,
1249,
275,
1798,
14,
1122,
779,
647,
14,
515,
14,
1832,
9383,
267,
702,
2519,
8,
589,
12,
2198,
2992,
14,
3817,
63,
726,
63,
3022,
2788,
16,
61,
508,
1134,
14,
515,
14,
1832,
342,
339,
347,
511,
63,
1122,
63,
3159,
63,
589,
8,
277,
12,
1798,
304,
267,
1798,
14,
1122,
63,
3159,
63,
589,
779,
647,
14,
515,
14,
1832,
9383,
267,
1798,
14,
525,
1422,
6739,
5006,
401,
1595,
628,
1617,
63,
2052,
531,
267,
700,
275,
1798,
14,
1122,
63,
3159,
63,
589,
5234,
88,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
snowyu/libtorrent
|
docs/gen_stats_doc.py
|
11
|
2401
|
counter_types = {}
f = open('../include/libtorrent/performance_counters.hpp')
counter_type = ''
for l in f:
l = l.strip()
if l.startswith('//'): continue
if l.startswith('#'): continue
if l == '': continue
if 'enum stats_counter_t' in l:
counter_type = 'counter'
continue
if 'enum stats_gauges_t' in l:
counter_type = 'gauge'
continue
if '{' in l or '}' in l or 'struct' in l or 'namespace' in l: continue
if counter_type == '': continue
if not l.endswith(','): continue
# strip off trailing comma
l = l[:-1]
if '=' in l: l = l[:l.index('=')].strip()
counter_types[l] = counter_type
f.close()
f = open('../src/session_stats.cpp')
out = open('stats_counters.rst', 'w+')
def print_field(str, width):
return '%s%s' % (str, ' ' * (width - len(str)))
def render_section(names, description, types):
max_name_len = max(len(max(names, key=len)), len('name'))
max_type_len = max(len(max(types, key=len)), len('type'))
if description == '':
for n in names:
print 'WARNING: no description for "%s"' % n
# add link targets for the rest of the manual to reference
for n in names:
print >>out, '.. _%s:\n' % n
if len(names) > 0:
print >>out, '.. raw:: html\n'
for n in names:
print >>out, '\t<a name="%s"></a>' % n
print >>out, ''
separator = '+-' + ('-' * max_name_len) + '-+-' + ('-' * max_type_len) + '-+'
# build a table for the settings, their type and default value
print >>out, separator
print >>out, '| %s | %s |' % (print_field('name', max_name_len), print_field('type', max_type_len))
print >>out, separator.replace('-', '=')
for i in range(len(names)):
print >>out, '| %s | %s |' % (print_field(names[i], max_name_len), print_field(types[i], max_type_len))
print >>out, separator
print >>out
print >>out, description
print >>out, ''
mode = ''
description = ''
names = []
types = []
for l in f:
l = l.strip()
if l.startswith('// '):
if len(names) > 0:
render_section(names, description, types)
description = ''
names = []
types = []
description += '\n' + l[3:]
if '#define' in l: continue
if 'METRIC(' in l:
args = l.split('(')[1].split(')')[0].split(',')
# args: category, name, type
args[1] = args[1].strip()
names.append(args[0].strip() + '.' + args[1].strip())
types.append(counter_types[args[1]])
if len(names) > 0:
render_section(names, description, types)
out.close()
f.close()
|
bsd-3-clause
|
[
5337,
63,
1313,
275,
1052,
199,
199,
70,
275,
1551,
24592,
2613,
15,
773,
14101,
15,
20576,
63,
16558,
14,
72,
802,
358,
199,
199,
5337,
63,
466,
275,
2125,
199,
199,
509,
634,
315,
289,
26,
199,
198,
76,
275,
634,
14,
1913,
342,
421,
198,
692,
634,
14,
2460,
15079,
735,
1980,
199,
198,
692,
634,
14,
2460,
7863,
735,
1980,
199,
198,
692,
634,
508,
8061,
1980,
421,
198,
692,
283,
4869,
5020,
63,
5337,
63,
84,
7,
315,
634,
26,
507,
198,
5337,
63,
466,
275,
283,
5337,
7,
507,
198,
6958,
421,
198,
692,
283,
4869,
5020,
63,
16750,
3389,
63,
84,
7,
315,
634,
26,
507,
198,
5337,
63,
466,
275,
283,
26775,
7,
507,
198,
6958,
421,
198,
692,
26109,
315,
634,
503,
23618,
315,
634,
503,
283,
1820,
7,
315,
634,
503,
283,
3251,
7,
315,
634,
26,
1980,
199,
198,
692,
7055,
63,
466,
508,
8061,
1980,
199,
198,
692,
440,
634,
14,
4130,
25908,
1980,
421,
198,
3,
6202,
2331,
8520,
10029,
199,
198,
76,
275,
634,
4439,
17,
61,
199,
198,
692,
14051,
315,
634,
26,
634,
275,
634,
1491,
76,
14,
1080,
23917,
1055,
1913,
342,
421,
198,
5337,
63,
1313,
59,
76,
61,
275,
7055,
63,
466,
507,
199,
70,
14,
1600,
342,
199,
199,
70,
275,
1551,
24592,
2164,
15,
1730,
63,
3200,
14,
5910,
358,
199,
199,
548,
275,
1551,
360,
3200,
63,
16558,
14,
8332,
297,
283,
87,
13854,
199,
199,
318,
870,
63,
698,
8,
495,
12,
3462,
304,
199,
198,
1107,
1543,
83,
5,
83,
7,
450,
334,
495,
12,
283,
283,
627,
334,
2063,
446,
822,
8,
495,
1724,
199,
199,
318,
3795,
63,
2792,
8,
1247,
12,
1369,
12,
2943,
304,
199,
198,
988,
63,
354,
63,
552,
275,
1390,
8,
552,
8,
988,
8,
1247,
12,
790,
29,
552,
1826,
822,
360,
354,
1333,
199,
198,
988,
63,
466,
63,
552,
275,
1390,
8,
552,
8,
988,
8,
1313,
12,
790,
29,
552,
1826,
822,
360,
466,
1333,
421,
198,
692,
1369,
508,
8061,
507,
198,
509,
302,
315,
1561,
26,
686,
198,
1361,
283,
9171,
26,
949,
1369,
367,
2071,
83,
4507,
450,
302,
421,
198,
3,
1050,
2142,
4545,
367,
314,
4618,
402,
314,
8722,
370,
3659,
199,
198,
509,
302,
315,
1561,
26,
507,
198,
1361,
4331,
548,
12,
11541,
485,
5,
83,
3427,
78,
7,
450,
302,
421,
198,
692,
822,
8,
1247,
9,
690,
378,
26,
507,
198,
1361,
4331,
548,
12,
11541,
3066,
447,
3517,
60,
78,
7,
507,
198,
509,
302,
315,
1561,
26,
686,
198,
1361,
4331,
548,
12,
1557,
84,
28,
65,
536,
5961,
83,
10070,
65,
3524,
450,
302,
507,
198,
1361,
4331,
548,
12,
2125,
421,
198,
9896,
275,
6681,
15668,
435,
12291,
7,
627,
1390,
63,
354,
63,
552,
9,
435,
2475,
11,
15668,
435,
12291,
7,
627,
1390,
63,
466,
63,
552,
9,
435,
2475,
4786,
421,
198,
3,
1900,
282,
1817,
367,
314,
2202,
12,
3932,
730,
436,
849,
574,
199,
198,
1361,
4331,
548,
12,
9432,
199,
198,
1361,
4331,
548,
12,
11280,
450,
83,
1204,
450,
83,
1204,
7,
450,
334,
1361,
63,
698,
360,
354,
297,
1390,
63,
354,
63,
552,
395,
870,
63,
698,
360,
466,
297,
1390,
63,
466,
63,
552,
430,
199,
198,
1361,
4331,
548,
12,
9432,
14,
1814,
13858,
283,
14619,
199,
198,
509,
284,
315,
1425,
8,
552,
8,
1247,
2298,
507,
198,
1361,
4331,
548,
12,
11280,
450,
83,
1204,
450,
83,
1204,
7,
450,
334,
1361,
63,
698,
8,
1247,
59,
73,
467,
1390,
63,
354,
63,
552,
395,
870,
63,
698,
8,
1313,
59,
73,
467,
1390,
63,
466,
63,
552,
430,
507,
198,
1361,
4331,
548,
12,
9432,
199,
198,
1361,
4331,
548,
199,
198,
1361,
4331,
548,
12,
1369,
199,
198,
1361,
4331,
548,
12,
2125,
199,
199,
632,
275,
2125,
199,
199,
1802,
275,
2125,
199,
1247,
275,
942,
199,
1313,
275,
942,
199,
199,
509,
634,
315,
289,
26,
199,
198,
76,
275,
634,
14,
1913,
342,
421,
198,
692,
634,
14,
2460,
15079,
18927,
507,
198,
692,
822,
8,
1247,
9,
690,
378,
26,
686,
198,
3352,
63,
2792,
8,
1247,
12,
1369,
12,
2943,
9,
686,
198,
1802,
275,
2125,
686,
198,
1247,
275,
942,
686,
198,
1313,
275,
942,
2742,
198,
1802,
847,
1557,
78,
7,
435,
634,
59,
19,
2938,
421,
198,
692,
3943,
4640,
7,
315,
634,
26,
1980,
421,
198,
692,
283,
20141,
360,
315,
634,
26,
507,
198,
589,
275,
634,
14,
1294,
14097,
5832,
17,
1055,
1294,
15938,
5832,
16,
1055,
1294,
11917,
2742,
198,
3,
1249,
26,
4637,
12,
536,
12,
730,
2742,
198,
589,
59,
17,
61,
275,
1249,
59,
17,
1055,
1913,
342,
507,
198,
1247,
14,
740,
8,
589,
59,
16,
1055,
1913,
342,
435,
7815,
435,
1249,
59,
17,
1055,
1913,
1012,
507,
198,
1313,
14,
740,
8,
5337,
63,
1313,
59,
589,
59,
17,
3934,
199,
199,
692,
822,
8,
1247,
9,
690,
378,
26,
199,
198,
3352,
63,
2792,
8,
1247,
12,
1369,
12,
2943,
9,
199,
199,
548,
14,
1600,
342,
199,
70,
14,
1600,
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
] |
[
63,
1313,
275,
1052,
199,
199,
70,
275,
1551,
24592,
2613,
15,
773,
14101,
15,
20576,
63,
16558,
14,
72,
802,
358,
199,
199,
5337,
63,
466,
275,
2125,
199,
199,
509,
634,
315,
289,
26,
199,
198,
76,
275,
634,
14,
1913,
342,
421,
198,
692,
634,
14,
2460,
15079,
735,
1980,
199,
198,
692,
634,
14,
2460,
7863,
735,
1980,
199,
198,
692,
634,
508,
8061,
1980,
421,
198,
692,
283,
4869,
5020,
63,
5337,
63,
84,
7,
315,
634,
26,
507,
198,
5337,
63,
466,
275,
283,
5337,
7,
507,
198,
6958,
421,
198,
692,
283,
4869,
5020,
63,
16750,
3389,
63,
84,
7,
315,
634,
26,
507,
198,
5337,
63,
466,
275,
283,
26775,
7,
507,
198,
6958,
421,
198,
692,
26109,
315,
634,
503,
23618,
315,
634,
503,
283,
1820,
7,
315,
634,
503,
283,
3251,
7,
315,
634,
26,
1980,
199,
198,
692,
7055,
63,
466,
508,
8061,
1980,
199,
198,
692,
440,
634,
14,
4130,
25908,
1980,
421,
198,
3,
6202,
2331,
8520,
10029,
199,
198,
76,
275,
634,
4439,
17,
61,
199,
198,
692,
14051,
315,
634,
26,
634,
275,
634,
1491,
76,
14,
1080,
23917,
1055,
1913,
342,
421,
198,
5337,
63,
1313,
59,
76,
61,
275,
7055,
63,
466,
507,
199,
70,
14,
1600,
342,
199,
199,
70,
275,
1551,
24592,
2164,
15,
1730,
63,
3200,
14,
5910,
358,
199,
199,
548,
275,
1551,
360,
3200,
63,
16558,
14,
8332,
297,
283,
87,
13854,
199,
199,
318,
870,
63,
698,
8,
495,
12,
3462,
304,
199,
198,
1107,
1543,
83,
5,
83,
7,
450,
334,
495,
12,
283,
283,
627,
334,
2063,
446,
822,
8,
495,
1724,
199,
199,
318,
3795,
63,
2792,
8,
1247,
12,
1369,
12,
2943,
304,
199,
198,
988,
63,
354,
63,
552,
275,
1390,
8,
552,
8,
988,
8,
1247,
12,
790,
29,
552,
1826,
822,
360,
354,
1333,
199,
198,
988,
63,
466,
63,
552,
275,
1390,
8,
552,
8,
988,
8,
1313,
12,
790,
29,
552,
1826,
822,
360,
466,
1333,
421,
198,
692,
1369,
508,
8061,
507,
198,
509,
302,
315,
1561,
26,
686,
198,
1361,
283,
9171,
26,
949,
1369,
367,
2071,
83,
4507,
450,
302,
421,
198,
3,
1050,
2142,
4545,
367,
314,
4618,
402,
314,
8722,
370,
3659,
199,
198,
509,
302,
315,
1561,
26,
507,
198,
1361,
4331,
548,
12,
11541,
485,
5,
83,
3427,
78,
7,
450,
302,
421,
198,
692,
822,
8,
1247,
9,
690,
378,
26,
507,
198,
1361,
4331,
548,
12,
11541,
3066,
447,
3517,
60,
78,
7,
507,
198,
509,
302,
315,
1561,
26,
686,
198,
1361,
4331,
548,
12,
1557,
84,
28,
65,
536,
5961,
83,
10070,
65,
3524,
450,
302,
507,
198,
1361,
4331,
548,
12,
2125,
421,
198,
9896,
275,
6681,
15668,
435,
12291,
7,
627,
1390,
63,
354,
63,
552,
9,
435,
2475,
11,
15668,
435,
12291,
7,
627,
1390,
63,
466,
63,
552,
9,
435,
2475,
4786,
421,
198,
3,
1900,
282,
1817,
367,
314,
2202,
12,
3932,
730,
436,
849,
574,
199,
198,
1361,
4331,
548,
12,
9432,
199,
198,
1361,
4331,
548,
12,
11280,
450,
83,
1204,
450,
83,
1204,
7,
450,
334,
1361,
63,
698,
360,
354,
297,
1390,
63,
354,
63,
552,
395,
870,
63,
698,
360,
466,
297,
1390,
63,
466,
63,
552,
430,
199,
198,
1361,
4331,
548,
12,
9432,
14,
1814,
13858,
283,
14619,
199,
198,
509,
284,
315,
1425,
8,
552,
8,
1247,
2298,
507,
198,
1361,
4331,
548,
12,
11280,
450,
83,
1204,
450,
83,
1204,
7,
450,
334,
1361,
63,
698,
8,
1247,
59,
73,
467,
1390,
63,
354,
63,
552,
395,
870,
63,
698,
8,
1313,
59,
73,
467,
1390,
63,
466,
63,
552,
430,
507,
198,
1361,
4331,
548,
12,
9432,
199,
198,
1361,
4331,
548,
199,
198,
1361,
4331,
548,
12,
1369,
199,
198,
1361,
4331,
548,
12,
2125,
199,
199,
632,
275,
2125,
199,
199,
1802,
275,
2125,
199,
1247,
275,
942,
199,
1313,
275,
942,
199,
199,
509,
634,
315,
289,
26,
199,
198,
76,
275,
634,
14,
1913,
342,
421,
198,
692,
634,
14,
2460,
15079,
18927,
507,
198,
692,
822,
8,
1247,
9,
690,
378,
26,
686,
198,
3352,
63,
2792,
8,
1247,
12,
1369,
12,
2943,
9,
686,
198,
1802,
275,
2125,
686,
198,
1247,
275,
942,
686,
198,
1313,
275,
942,
2742,
198,
1802,
847,
1557,
78,
7,
435,
634,
59,
19,
2938,
421,
198,
692,
3943,
4640,
7,
315,
634,
26,
1980,
421,
198,
692,
283,
20141,
360,
315,
634,
26,
507,
198,
589,
275,
634,
14,
1294,
14097,
5832,
17,
1055,
1294,
15938,
5832,
16,
1055,
1294,
11917,
2742,
198,
3,
1249,
26,
4637,
12,
536,
12,
730,
2742,
198,
589,
59,
17,
61,
275,
1249,
59,
17,
1055,
1913,
342,
507,
198,
1247,
14,
740,
8,
589,
59,
16,
1055,
1913,
342,
435,
7815,
435,
1249,
59,
17,
1055,
1913,
1012,
507,
198,
1313,
14,
740,
8,
5337,
63,
1313,
59,
589,
59,
17,
3934,
199,
199,
692,
822,
8,
1247,
9,
690,
378,
26,
199,
198,
3352,
63,
2792,
8,
1247,
12,
1369,
12,
2943,
9,
199,
199,
548,
14,
1600,
342,
199,
70,
14,
1600,
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,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
dattasaurabh82/internetarchive
|
tests/iacli/test_ia_upload.py
|
2
|
1694
|
import os, sys
from subprocess import Popen, PIPE
from time import time
import pytest
inc_path = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.insert(0, inc_path)
import internetarchive.config
@pytest.mark.skipif('internetarchive.config.get_config().get("s3") is None',
reason='requires authorization.')
def test_ia_upload():
# upload from stdin.
cmd = ('echo "Hello World!" |'
'ia upload iacli-test-item - --remote-name="stdin.txt" --size-hint=8')
proc = Popen(cmd, shell=True, stdout=PIPE, stderr=PIPE)
stdout, stderr = proc.communicate()
assert proc.returncode == 0
cmd = ('echo "Hello World!" |'
'ia upload iacli-test-item -')
proc = Popen(cmd, shell=True, stdout=PIPE, stderr=PIPE)
stdout, stderr = proc.communicate()
assert proc.returncode == 1
assert stderr == '--remote-name is required when uploading from stdin.\n'
# upload file.
cmd = 'ia upload iacli-test-item setup.py'
proc = Popen(cmd, shell=True, stdout=PIPE, stderr=PIPE)
stdout, stderr = proc.communicate()
assert proc.returncode == 0
# upload debug.
cmd = 'ia upload iacli-test-item setup.py --debug'
proc = Popen(cmd, shell=True, stdout=PIPE, stderr=PIPE)
stdout, stderr = proc.communicate()
assert proc.returncode == 0
# upload non-200 status_code.
cmd = ('echo "Hello World!" |'
'ia upload iacli-test-item - --remote-name="iacli-test-item_meta.xml"')
proc = Popen(cmd, shell=True, stdout=PIPE, stderr=PIPE)
stdout, stderr = proc.communicate()
assert stderr == 'error "AccessDenied" (403): Access Denied\n'
assert proc.returncode == 1
|
agpl-3.0
|
[
646,
747,
12,
984,
199,
504,
3873,
492,
13995,
12,
22773,
199,
504,
900,
492,
900,
199,
199,
646,
4613,
199,
199,
6559,
63,
515,
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,
3176,
8,
16,
12,
12864,
63,
515,
9,
199,
646,
21408,
6404,
14,
888,
421,
199,
32,
4462,
14,
1657,
14,
22696,
360,
4901,
6404,
14,
888,
14,
362,
63,
888,
1252,
362,
480,
83,
19,
531,
365,
488,
297,
490,
4499,
534,
6537,
13448,
2659,
199,
318,
511,
63,
4674,
63,
5064,
837,
272,
327,
5802,
687,
9009,
14,
272,
2088,
275,
661,
7878,
298,
6257,
13064,
9539,
1204,
7,
1779,
283,
4674,
5802,
284,
645,
317,
13,
396,
13,
1053,
446,
1553,
3846,
13,
354,
628,
6626,
14,
2424,
2,
1553,
890,
13,
6479,
29,
24,
358,
272,
6499,
275,
13995,
8,
1760,
12,
5218,
29,
549,
12,
3839,
29,
6089,
12,
4635,
29,
6089,
9,
272,
3839,
12,
4635,
275,
6499,
14,
10664,
342,
272,
702,
6499,
14,
9913,
508,
378,
339,
2088,
275,
661,
7878,
298,
6257,
13064,
9539,
1204,
7,
1779,
283,
4674,
5802,
284,
645,
317,
13,
396,
13,
1053,
446,
358,
272,
6499,
275,
13995,
8,
1760,
12,
5218,
29,
549,
12,
3839,
29,
6089,
12,
4635,
29,
6089,
9,
272,
3839,
12,
4635,
275,
6499,
14,
10664,
342,
272,
702,
6499,
14,
9913,
508,
413,
272,
702,
4635,
508,
2850,
3846,
13,
354,
365,
1415,
1380,
24349,
687,
9009,
3134,
78,
7,
339,
327,
5802,
570,
14,
272,
2088,
275,
283,
4674,
5802,
284,
645,
317,
13,
396,
13,
1053,
3272,
14,
647,
7,
272,
6499,
275,
13995,
8,
1760,
12,
5218,
29,
549,
12,
3839,
29,
6089,
12,
4635,
29,
6089,
9,
272,
3839,
12,
4635,
275,
6499,
14,
10664,
342,
272,
702,
6499,
14,
9913,
508,
378,
339,
327,
5802,
3105,
14,
272,
2088,
275,
283,
4674,
5802,
284,
645,
317,
13,
396,
13,
1053,
3272,
14,
647,
1553,
1757,
7,
272,
6499,
275,
13995,
8,
1760,
12,
5218,
29,
549,
12,
3839,
29,
6089,
12,
4635,
29,
6089,
9,
272,
3839,
12,
4635,
275,
6499,
14,
10664,
342,
272,
702,
6499,
14,
9913,
508,
378,
339,
327,
5802,
2222,
13,
1840,
2004,
63,
600,
14,
272,
2088,
275,
661,
7878,
298,
6257,
13064,
9539,
1204,
7,
1779,
283,
4674,
5802,
284,
645,
317,
13,
396,
13,
1053,
446,
1553,
3846,
13,
354,
628,
73,
645,
317,
13,
396,
13,
1053,
63,
2024,
14,
1652,
9008,
272,
6499,
275,
13995,
8,
1760,
12,
5218,
29,
549,
12,
3839,
29,
6089,
12,
4635,
29,
6089,
9,
272,
3839,
12,
4635,
275,
6499,
14,
10664,
342,
272,
702,
4635,
508,
283,
705,
298,
3946,
15729,
2,
334,
13353,
304,
11003,
25187,
5299,
60,
78,
7,
272,
702,
6499,
14,
9913,
508,
413,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,
12,
984,
199,
504,
3873,
492,
13995,
12,
22773,
199,
504,
900,
492,
900,
199,
199,
646,
4613,
199,
199,
6559,
63,
515,
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,
3176,
8,
16,
12,
12864,
63,
515,
9,
199,
646,
21408,
6404,
14,
888,
421,
199,
32,
4462,
14,
1657,
14,
22696,
360,
4901,
6404,
14,
888,
14,
362,
63,
888,
1252,
362,
480,
83,
19,
531,
365,
488,
297,
490,
4499,
534,
6537,
13448,
2659,
199,
318,
511,
63,
4674,
63,
5064,
837,
272,
327,
5802,
687,
9009,
14,
272,
2088,
275,
661,
7878,
298,
6257,
13064,
9539,
1204,
7,
1779,
283,
4674,
5802,
284,
645,
317,
13,
396,
13,
1053,
446,
1553,
3846,
13,
354,
628,
6626,
14,
2424,
2,
1553,
890,
13,
6479,
29,
24,
358,
272,
6499,
275,
13995,
8,
1760,
12,
5218,
29,
549,
12,
3839,
29,
6089,
12,
4635,
29,
6089,
9,
272,
3839,
12,
4635,
275,
6499,
14,
10664,
342,
272,
702,
6499,
14,
9913,
508,
378,
339,
2088,
275,
661,
7878,
298,
6257,
13064,
9539,
1204,
7,
1779,
283,
4674,
5802,
284,
645,
317,
13,
396,
13,
1053,
446,
358,
272,
6499,
275,
13995,
8,
1760,
12,
5218,
29,
549,
12,
3839,
29,
6089,
12,
4635,
29,
6089,
9,
272,
3839,
12,
4635,
275,
6499,
14,
10664,
342,
272,
702,
6499,
14,
9913,
508,
413,
272,
702,
4635,
508,
2850,
3846,
13,
354,
365,
1415,
1380,
24349,
687,
9009,
3134,
78,
7,
339,
327,
5802,
570,
14,
272,
2088,
275,
283,
4674,
5802,
284,
645,
317,
13,
396,
13,
1053,
3272,
14,
647,
7,
272,
6499,
275,
13995,
8,
1760,
12,
5218,
29,
549,
12,
3839,
29,
6089,
12,
4635,
29,
6089,
9,
272,
3839,
12,
4635,
275,
6499,
14,
10664,
342,
272,
702,
6499,
14,
9913,
508,
378,
339,
327,
5802,
3105,
14,
272,
2088,
275,
283,
4674,
5802,
284,
645,
317,
13,
396,
13,
1053,
3272,
14,
647,
1553,
1757,
7,
272,
6499,
275,
13995,
8,
1760,
12,
5218,
29,
549,
12,
3839,
29,
6089,
12,
4635,
29,
6089,
9,
272,
3839,
12,
4635,
275,
6499,
14,
10664,
342,
272,
702,
6499,
14,
9913,
508,
378,
339,
327,
5802,
2222,
13,
1840,
2004,
63,
600,
14,
272,
2088,
275,
661,
7878,
298,
6257,
13064,
9539,
1204,
7,
1779,
283,
4674,
5802,
284,
645,
317,
13,
396,
13,
1053,
446,
1553,
3846,
13,
354,
628,
73,
645,
317,
13,
396,
13,
1053,
63,
2024,
14,
1652,
9008,
272,
6499,
275,
13995,
8,
1760,
12,
5218,
29,
549,
12,
3839,
29,
6089,
12,
4635,
29,
6089,
9,
272,
3839,
12,
4635,
275,
6499,
14,
10664,
342,
272,
702,
4635,
508,
283,
705,
298,
3946,
15729,
2,
334,
13353,
304,
11003,
25187,
5299,
60,
78,
7,
272,
702,
6499,
14,
9913,
508,
413,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
npiganeau/odoo
|
addons/web_tip/web_tip.py
|
2
|
2524
|
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2009-Today OpenERP SA (<http://www.openerp.com>)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU 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 models, fields, api
class tip(models.Model):
_name = 'web.tip'
_description = 'Tips'
@api.one
@api.depends('user_ids')
def _is_consumed(self):
if self.env.uid in self.user_ids:
self.is_consumed = True
else:
self.is_consumed = False
title = fields.Char('Tip title')
description = fields.Html('Tip Description', required=True)
action_id = fields.Many2one('ir.actions.act_window', string="Action",
help="The action that will trigger the tip")
model = fields.Char("Model", help="Model name on which to trigger the tip, e.g. 'res.partner'.")
type = fields.Char("Type", help="Model type, e.g. lead or opportunity for crm.lead")
mode = fields.Char("Mode", help="Mode, e.g. kanban, form")
trigger_selector = fields.Char('Trigger selector', help='CSS selectors used to trigger the tip, separated by a comma (ANDed).')
highlight_selector = fields.Char('Highlight selector', help='CSS selector for the element to highlight')
end_selector = fields.Char('End selector', help='CSS selector used to end the tip')
end_event = fields.Char('End event', help='Event to end the tip', default='click')
placement = fields.Char('Placement', help='Popover placement, bottom, top, left or right', default='auto')
user_ids = fields.Many2many('res.users', string='Consumed by')
is_consumed = fields.Boolean(string='Tip consumed', compute='_is_consumed')
@api.multi
def consume(self):
self.write({'user_ids': [(4, self.env.uid)]})
|
agpl-3.0
|
[
4605,
199,
3,
199,
3,
259,
7653,
12,
3232,
5800,
8259,
9274,
199,
3,
259,
1898,
334,
35,
9,
8937,
13,
31982,
7653,
13950,
8642,
1014,
921,
1544,
14,
11267,
14,
957,
18956,
199,
3,
199,
3,
259,
961,
2240,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
259,
652,
1334,
314,
2895,
402,
314,
1664,
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,
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,
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,
3133,
199,
3,
199,
4605,
199,
199,
504,
5166,
492,
1709,
12,
1504,
12,
2986,
421,
199,
533,
19201,
8,
992,
14,
1685,
304,
272,
485,
354,
275,
283,
2520,
14,
8996,
7,
272,
485,
1802,
275,
283,
52,
6142,
7,
339,
768,
1246,
14,
368,
272,
768,
1246,
14,
8912,
360,
751,
63,
1580,
358,
272,
347,
485,
374,
63,
20688,
8,
277,
304,
267,
340,
291,
14,
1813,
14,
1535,
315,
291,
14,
751,
63,
1580,
26,
288,
291,
14,
374,
63,
20688,
275,
715,
267,
587,
26,
288,
291,
14,
374,
63,
20688,
275,
756,
339,
2538,
275,
1504,
14,
1610,
360,
15915,
2538,
358,
272,
1369,
275,
1504,
14,
12957,
360,
15915,
11994,
297,
1415,
29,
549,
9,
272,
1595,
63,
344,
275,
1504,
14,
4089,
18,
368,
360,
723,
14,
3723,
14,
2442,
63,
3806,
297,
1059,
628,
3310,
401,
267,
1720,
628,
1918,
1595,
626,
911,
6804,
314,
19201,
531,
272,
1402,
275,
1504,
14,
1610,
480,
1685,
401,
1720,
628,
1685,
536,
641,
1314,
370,
6804,
314,
19201,
12,
325,
14,
71,
14,
283,
470,
14,
3899,
29435,
272,
730,
275,
1504,
14,
1610,
480,
804,
401,
1720,
628,
1685,
730,
12,
325,
14,
71,
14,
12690,
503,
30914,
367,
2467,
77,
14,
13799,
531,
272,
818,
275,
1504,
14,
1610,
480,
1385,
401,
1720,
628,
1385,
12,
325,
14,
71,
14,
1022,
290,
13206,
12,
1824,
531,
272,
6804,
63,
6662,
275,
1504,
14,
1610,
360,
16276,
9759,
297,
1720,
534,
14391,
9759,
83,
1202,
370,
6804,
314,
19201,
12,
11673,
701,
282,
10029,
334,
3649,
379,
28583,
272,
11850,
63,
6662,
275,
1504,
14,
1610,
360,
11688,
4040,
9759,
297,
1720,
534,
14391,
9759,
367,
314,
1819,
370,
11850,
358,
272,
1284,
63,
6662,
275,
1504,
14,
1610,
360,
3005,
9759,
297,
1720,
534,
14391,
9759,
1202,
370,
1284,
314,
19201,
358,
272,
1284,
63,
1430,
275,
1504,
14,
1610,
360,
3005,
1566,
297,
1720,
534,
2390,
370,
1284,
314,
19201,
297,
849,
534,
4891,
358,
272,
22286,
275,
1504,
14,
1610,
360,
32360,
297,
1720,
534,
9606,
1883,
22286,
12,
9048,
12,
2746,
12,
3602,
503,
2451,
297,
849,
534,
2495,
358,
272,
922,
63,
1580,
275,
1504,
14,
4089,
18,
3479,
360,
470,
14,
3707,
297,
1059,
534,
21042,
68,
701,
358,
272,
365,
63,
20688,
275,
1504,
14,
4082,
8,
875,
534,
15915,
16949,
297,
4526,
17574,
374,
63,
20688,
358,
339,
768,
1246,
14,
3029,
272,
347,
9451,
8,
277,
304,
2126,
291,
14,
952,
3252,
751,
63,
1580,
356,
3842,
20,
12,
291,
14,
1813,
14,
1535,
1874,
1552,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
199,
3,
199,
3,
259,
7653,
12,
3232,
5800,
8259,
9274,
199,
3,
259,
1898,
334,
35,
9,
8937,
13,
31982,
7653,
13950,
8642,
1014,
921,
1544,
14,
11267,
14,
957,
18956,
199,
3,
199,
3,
259,
961,
2240,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
259,
652,
1334,
314,
2895,
402,
314,
1664,
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,
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,
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,
3133,
199,
3,
199,
4605,
199,
199,
504,
5166,
492,
1709,
12,
1504,
12,
2986,
421,
199,
533,
19201,
8,
992,
14,
1685,
304,
272,
485,
354,
275,
283,
2520,
14,
8996,
7,
272,
485,
1802,
275,
283,
52,
6142,
7,
339,
768,
1246,
14,
368,
272,
768,
1246,
14,
8912,
360,
751,
63,
1580,
358,
272,
347,
485,
374,
63,
20688,
8,
277,
304,
267,
340,
291,
14,
1813,
14,
1535,
315,
291,
14,
751,
63,
1580,
26,
288,
291,
14,
374,
63,
20688,
275,
715,
267,
587,
26,
288,
291,
14,
374,
63,
20688,
275,
756,
339,
2538,
275,
1504,
14,
1610,
360,
15915,
2538,
358,
272,
1369,
275,
1504,
14,
12957,
360,
15915,
11994,
297,
1415,
29,
549,
9,
272,
1595,
63,
344,
275,
1504,
14,
4089,
18,
368,
360,
723,
14,
3723,
14,
2442,
63,
3806,
297,
1059,
628,
3310,
401,
267,
1720,
628,
1918,
1595,
626,
911,
6804,
314,
19201,
531,
272,
1402,
275,
1504,
14,
1610,
480,
1685,
401,
1720,
628,
1685,
536,
641,
1314,
370,
6804,
314,
19201,
12,
325,
14,
71,
14,
283,
470,
14,
3899,
29435,
272,
730,
275,
1504,
14,
1610,
480,
804,
401,
1720,
628,
1685,
730,
12,
325,
14,
71,
14,
12690,
503,
30914,
367,
2467,
77,
14,
13799,
531,
272,
818,
275,
1504,
14,
1610,
480,
1385,
401,
1720,
628,
1385,
12,
325,
14,
71,
14,
1022,
290,
13206,
12,
1824,
531,
272,
6804,
63,
6662,
275,
1504,
14,
1610,
360,
16276,
9759,
297,
1720,
534,
14391,
9759,
83,
1202,
370,
6804,
314,
19201,
12,
11673,
701,
282,
10029,
334,
3649,
379,
28583,
272,
11850,
63,
6662,
275,
1504,
14,
1610,
360,
11688,
4040,
9759,
297,
1720,
534,
14391,
9759,
367,
314,
1819,
370,
11850,
358,
272,
1284,
63,
6662,
275,
1504,
14,
1610,
360,
3005,
9759,
297,
1720,
534,
14391,
9759,
1202,
370,
1284,
314,
19201,
358,
272,
1284,
63,
1430,
275,
1504,
14,
1610,
360,
3005,
1566,
297,
1720,
534,
2390,
370,
1284,
314,
19201,
297,
849,
534,
4891,
358,
272,
22286,
275,
1504,
14,
1610,
360,
32360,
297,
1720,
534,
9606,
1883,
22286,
12,
9048,
12,
2746,
12,
3602,
503,
2451,
297,
849,
534,
2495,
358,
272,
922,
63,
1580,
275,
1504,
14,
4089,
18,
3479,
360,
470,
14,
3707,
297,
1059,
534,
21042,
68,
701,
358,
272,
365,
63,
20688,
275,
1504,
14,
4082,
8,
875,
534,
15915,
16949,
297,
4526,
17574,
374,
63,
20688,
358,
339,
768,
1246,
14,
3029,
272,
347,
9451,
8,
277,
304,
2126,
291,
14,
952,
3252,
751,
63,
1580,
356,
3842,
20,
12,
291,
14,
1813,
14,
1535,
1874,
1552,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
TeslaProject/external_chromium_org
|
tools/memory_inspector/memory_inspector/classification/native_heap_classifier_unittest.py
|
89
|
5824
|
# Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import unittest
from memory_inspector.classification import native_heap_classifier
from memory_inspector.core import native_heap
from memory_inspector.core import stacktrace
from memory_inspector.core import symbol
_TEST_RULES = """
[
{
'name': 'content',
'source_path': r'content/',
'children': [
{
'name': 'browser',
'stacktrace': r'content::browser',
'source_path': r'content/browser',
},
{
'name': 'renderer',
'stacktrace': r'content::renderer',
},
],
},
{
'name': 'ashmem_in_skia',
'stacktrace': [r'sk::', r'ashmem::'],
},
]
"""
_TEST_STACK_TRACES = [
(3, [('stack_frame_0::foo()', '/ignored.c'),
('this_goes_under_totals_other', '/ignored.c')]),
(5, [('foo', '/ignored.c'),
('content::browser::something()', '/content/browser/something.cc'),
('bar', '/ignored.c')]),
(7, [('content::browser::something_else()', '/content/browser/else.cc')]),
(11, [('content::browser::not_really()', '/content/subtle/something.cc'),
('foo', '/ignored.c')]),
(13, [('foo', '/ignored.c'),
('content::renderer::something()', '/content/renderer/foo.c'),
('bar', '/ignored.c')]),
(17, [('content::renderer::something_else()', '/content/renderer/foo.c')]),
(19, [('content::renderer::something_else_2()', '/content/renderer/bar.c'),
('foo', '/ignored.c')]),
(23, [('content::something_different', '/content/foo.c')]),
(29, [('foo', '/ignored.c'),
('sk::something', '/skia/something.c'),
('not_ashsmem_goes_into_totals_other', '/ignored.c')]),
(31, [('foo', '/ignored.c'),
('sk::something', '/skia/something.c'),
('foo::bar', '/ignored.c'),
('sk::foo::ashmem::alloc()', '/skia/ashmem.c')]),
(37, [('foo', '/ignored.c'),
('sk::something', '/ignored.c'),
('sk::foo::ashmem::alloc()', '/ignored.c')]),
(43, [('foo::ashmem::alloc()', '/ignored.c'),
('sk::foo', '/ignored.c'),
('wrong_order_goes_into_totals', '/ignored.c')])
]
_EXPECTED_RESULTS = {
'Total': [238, 0],
'Total::content': [95, 0],
'Total::content::browser': [12, 0], # 5 + 7.
'Total::content::renderer': [49, 0], # 13 + 17 + 19.
'Total::content::content-other': [34, 0],
'Total::ashmem_in_skia': [68, 0], # 31 + 37.
'Total::Total-other': [75, 0], # 3 + 29 + 43.
}
_HEURISTIC_TEST_STACK_TRACES = [
(10, '/root/base1/foo/bar/file.cc'), # Contrib: 0.13
(20, '/root/base1/foo/baz/file.cc'), # Contrib: 0.26
(1, '/root/base1/foo/nah/file.cc'), # Contrib: 0.01
(3, '/root/base2/file.cc'), # Contrib: 0.03
(22, '/root/base2/subpath/file.cc'), # Contrib: 0.28
(18, '/root/base2/subpath2/file.cc'), # Contrib: 0.23
(2, '/root/whatever/file.cc'), # Contrib: 0.02
]
_HEURISTIC_EXPECTED_RESULTS = {
'Total': [76, 0],
'Total::/root/': [76, 0],
'Total::/root/::base1/foo/': [31, 0], # 10 + 20 +1
'Total::/root/::base1/foo/::bar/': [10, 0],
'Total::/root/::base1/foo/::baz/': [20, 0],
'Total::/root/::base1/foo/::base1/foo/-other': [1, 0],
'Total::/root/::base2/': [43, 0], # 3 + 22 + 18
'Total::/root/::base2/::subpath/': [22, 0],
'Total::/root/::base2/::subpath2/': [18, 0],
'Total::/root/::base2/::base2/-other': [3, 0],
'Total::/root/::/root/-other': [2, 0],
'Total::Total-other': [0, 0],
}
class NativeHeapClassifierTest(unittest.TestCase):
def testStandardRuleParsingAndProcessing(self):
rule_tree = native_heap_classifier.LoadRules(_TEST_RULES)
nheap = native_heap.NativeHeap()
mock_addr = 0
for test_entry in _TEST_STACK_TRACES:
mock_strace = stacktrace.Stacktrace()
for (mock_btstr, mock_source_path) in test_entry[1]:
mock_addr += 4 # Addr is irrelevant, just keep it distinct.
mock_frame = stacktrace.Frame(mock_addr)
mock_frame.SetSymbolInfo(symbol.Symbol(mock_btstr, mock_source_path))
mock_strace.Add(mock_frame)
nheap.Add(native_heap.Allocation(
size=test_entry[0], stack_trace=mock_strace))
res = native_heap_classifier.Classify(nheap, rule_tree)
self._CheckResult(res.total, '', _EXPECTED_RESULTS)
def testInferHeuristicRules(self):
nheap = native_heap.NativeHeap()
mock_addr = 0
for (mock_alloc_size, mock_source_path) in _HEURISTIC_TEST_STACK_TRACES:
mock_strace = stacktrace.Stacktrace()
mock_addr += 4 # Addr is irrelevant, just keep it distinct.
mock_frame = stacktrace.Frame(mock_addr)
mock_frame.SetSymbolInfo(symbol.Symbol(str(mock_addr), mock_source_path))
for _ in xrange(10): # Just repeat the same stack frame 10 times
mock_strace.Add(mock_frame)
nheap.Add(native_heap.Allocation(
size=mock_alloc_size, stack_trace=mock_strace))
rule_tree = native_heap_classifier.InferHeuristicRulesFromHeap(
nheap, threshold=0.05)
res = native_heap_classifier.Classify(nheap, rule_tree)
self._CheckResult(res.total, '', _HEURISTIC_EXPECTED_RESULTS)
def _CheckResult(self, node, prefix, expected_results):
node_name = prefix + node.name
self.assertIn(node_name, expected_results)
self.assertEqual(node.values, expected_results[node_name])
for child in node.children:
self._CheckResult(child, node_name + '::', expected_results)
|
bsd-3-clause
|
[
3,
1898,
6927,
710,
12051,
6642,
14,
2900,
4481,
4644,
14,
199,
3,
3645,
402,
642,
1350,
1233,
365,
10413,
701,
282,
6289,
13,
2487,
4190,
626,
883,
506,
199,
3,
1911,
315,
314,
5113,
570,
14,
199,
199,
646,
2882,
199,
199,
504,
4402,
63,
26047,
14,
14368,
492,
5438,
63,
12492,
63,
14720,
199,
504,
4402,
63,
26047,
14,
1018,
492,
5438,
63,
12492,
199,
504,
4402,
63,
26047,
14,
1018,
492,
3464,
3446,
199,
504,
4402,
63,
26047,
14,
1018,
492,
5272,
421,
199,
63,
2864,
63,
31490,
275,
408,
199,
59,
199,
91,
523,
283,
354,
356,
283,
1317,
297,
523,
283,
1365,
63,
515,
356,
519,
7,
1317,
3678,
523,
283,
3223,
356,
359,
272,
469,
489,
283,
354,
356,
283,
5750,
297,
489,
283,
32274,
356,
519,
7,
1317,
447,
5750,
297,
489,
283,
1365,
63,
515,
356,
519,
7,
1317,
15,
5750,
297,
272,
1660,
272,
469,
489,
283,
354,
356,
283,
12471,
297,
489,
283,
32274,
356,
519,
7,
1317,
447,
12471,
297,
272,
1660,
523,
2156,
199,
1386,
199,
91,
523,
283,
354,
356,
283,
1119,
5286,
63,
262,
63,
1339,
4674,
297,
523,
283,
32274,
356,
359,
82,
1159,
75,
447,
297,
519,
7,
1119,
5286,
447,
995,
199,
1386,
199,
61,
199,
624,
199,
199,
63,
2864,
63,
17014,
63,
1766,
21287,
275,
359,
272,
334,
19,
12,
4274,
2340,
63,
1943,
63,
16,
447,
1421,
19633,
1994,
11996,
14,
67,
659,
268,
661,
3749,
63,
1939,
397,
63,
7138,
63,
17552,
63,
1848,
297,
1994,
11996,
14,
67,
22864,
272,
334,
21,
12,
4274,
1421,
297,
1994,
11996,
14,
67,
659,
268,
661,
1317,
447,
5750,
447,
10297,
19633,
1994,
1317,
15,
5750,
15,
10297,
14,
2055,
659,
268,
661,
1700,
297,
1994,
11996,
14,
67,
22864,
272,
334,
23,
12,
4274,
1317,
447,
5750,
447,
10297,
63,
2836,
19633,
1994,
1317,
15,
5750,
15,
2836,
14,
2055,
22864,
272,
334,
845,
12,
4274,
1317,
447,
5750,
447,
1397,
63,
29428,
19633,
1994,
1317,
15,
954,
1118,
15,
10297,
14,
2055,
659,
881,
661,
1421,
297,
1994,
11996,
14,
67,
22864,
272,
334,
969,
12,
4274,
1421,
297,
1994,
11996,
14,
67,
659,
881,
661,
1317,
447,
12471,
447,
10297,
19633,
1994,
1317,
15,
12471,
15,
1421,
14,
67,
659,
881,
661,
1700,
297,
1994,
11996,
14,
67,
22864,
272,
334,
1196,
12,
4274,
1317,
447,
12471,
447,
10297,
63,
2836,
19633,
1994,
1317,
15,
12471,
15,
1421,
14,
67,
22864,
272,
334,
1167,
12,
4274,
1317,
447,
12471,
447,
10297,
63,
2836,
63,
18,
19633,
1994,
1317,
15,
12471,
15,
1700,
14,
67,
659,
881,
661,
1421,
297,
1994,
11996,
14,
67,
22864,
272,
334,
1789,
12,
4274,
1317,
447,
10297,
63,
14020,
297,
1994,
1317,
15,
1421,
14,
67,
22864,
272,
334,
1398,
12,
4274,
1421,
297,
1994,
11996,
14,
67,
659,
881,
661,
1339,
447,
10297,
297,
1994,
1339,
4674,
15,
10297,
14,
67,
659,
881,
661,
1397,
63,
1119,
83,
5286,
63,
1939,
397,
63,
9924,
63,
17552,
63,
1848,
297,
1994,
11996,
14,
67,
22864,
272,
334,
2192,
12,
4274,
1421,
297,
1994,
11996,
14,
67,
659,
881,
661,
1339,
447,
10297,
297,
1994,
1339,
4674,
15,
10297,
14,
67,
659,
881,
661,
1421,
447,
1700,
297,
1994,
11996,
14,
67,
659,
881,
661,
1339,
447,
1421,
447,
1119,
5286,
447,
9373,
19633,
1994,
1339,
4674,
15,
1119,
5286,
14,
67,
22864,
272,
334,
1401,
12,
4274,
1421,
297,
1994,
11996,
14,
67,
659,
881,
661,
1339,
447,
10297,
297,
1994,
11996,
14,
67,
659,
881,
661,
1339,
447,
1421,
447,
1119,
5286,
447,
9373,
19633,
1994,
11996,
14,
67,
22864,
272,
334,
2824,
12,
4274,
1421,
447,
1119,
5286,
447,
9373,
19633,
1994,
11996,
14,
67,
659,
881,
661,
1339,
447,
1421,
297,
1994,
11996,
14,
67,
659,
881,
661,
10603,
63,
1648,
63,
1939,
397,
63,
9924,
63,
17552,
297,
1994,
11996,
14,
67,
2023,
199,
61,
199,
199,
63,
22358,
63,
23545,
275,
469,
272,
283,
7316,
356,
12793,
359,
12332,
12,
378,
467,
272,
283,
7316,
447,
1317,
356,
4483,
359,
2720,
12,
378,
467,
272,
283,
7316,
447,
1317,
447,
5750,
356,
755,
359,
713,
12,
378,
467,
221,
327,
959,
435,
1520,
14,
272,
283,
7316,
447,
1317,
447,
12471,
356,
420,
359,
1887,
12,
378,
467,
221,
327,
4944,
435,
5557,
435,
5851,
14,
272,
283,
7316,
447,
1317,
447,
1317,
13,
1848,
356,
359,
1082,
12,
378,
467,
272,
283,
7316,
447,
1119,
5286,
63,
262,
63,
1339,
4674,
356,
260,
359,
2333,
12,
378,
467,
221,
327,
7105,
435,
6877,
14,
272,
283,
7316,
447,
7316,
13,
1848,
356,
3322,
359,
2194,
12,
378,
467,
221,
327,
650,
435,
7349,
435,
11851,
14,
199,
93,
199,
199,
63,
1645,
1230,
6225,
948,
63,
2864,
63,
17014,
63,
1766,
21287,
275,
359,
272,
334,
709,
12,
1994,
1231,
15,
1095,
17,
15,
1421,
15,
1700,
15,
493,
14,
2055,
659,
221,
327,
13370,
26,
378,
14,
969,
272,
334,
1165,
12,
1994,
1231,
15,
1095,
17,
15,
1421,
15,
6185,
15,
493,
14,
2055,
659,
221,
327,
13370,
26,
378,
14,
1479,
272,
334,
17,
12,
1994,
1231,
15,
1095,
17,
15,
1421,
15,
3540,
72,
15,
493,
14,
2055,
659,
257,
327,
13370,
26,
378,
14,
614,
272,
334,
19,
12,
1994,
1231,
15,
1095,
18,
15,
493,
14,
2055,
659,
3698,
327,
13370,
26,
378,
14,
1644,
272,
334,
1081,
12,
1994,
1231,
15,
1095,
18,
15,
954,
515,
15,
493,
14,
2055,
659,
221,
327,
13370,
26,
378,
14,
1651,
272,
334,
1085,
12,
1994,
1231,
15,
1095,
18,
15,
954,
515,
18,
15,
493,
14,
2055,
659,
327,
13370,
26,
378,
14,
1789,
272,
334,
18,
12,
1994,
1231,
15,
26517,
15,
493,
14,
2055,
659,
263,
327,
13370,
26,
378,
14,
996,
199,
61,
199,
199,
63,
1645,
1230,
6225,
948,
63,
22358,
63,
23545,
275,
469,
272,
283,
7316,
356,
2476,
263,
359,
2114,
12,
378,
467,
272,
283,
7316,
26346,
1231,
25772,
13293,
359,
2114,
12,
378,
467,
272,
283,
7316,
26346,
1231,
15,
447,
1095,
17,
15,
1421,
25772,
8540,
359
] |
[
1898,
6927,
710,
12051,
6642,
14,
2900,
4481,
4644,
14,
199,
3,
3645,
402,
642,
1350,
1233,
365,
10413,
701,
282,
6289,
13,
2487,
4190,
626,
883,
506,
199,
3,
1911,
315,
314,
5113,
570,
14,
199,
199,
646,
2882,
199,
199,
504,
4402,
63,
26047,
14,
14368,
492,
5438,
63,
12492,
63,
14720,
199,
504,
4402,
63,
26047,
14,
1018,
492,
5438,
63,
12492,
199,
504,
4402,
63,
26047,
14,
1018,
492,
3464,
3446,
199,
504,
4402,
63,
26047,
14,
1018,
492,
5272,
421,
199,
63,
2864,
63,
31490,
275,
408,
199,
59,
199,
91,
523,
283,
354,
356,
283,
1317,
297,
523,
283,
1365,
63,
515,
356,
519,
7,
1317,
3678,
523,
283,
3223,
356,
359,
272,
469,
489,
283,
354,
356,
283,
5750,
297,
489,
283,
32274,
356,
519,
7,
1317,
447,
5750,
297,
489,
283,
1365,
63,
515,
356,
519,
7,
1317,
15,
5750,
297,
272,
1660,
272,
469,
489,
283,
354,
356,
283,
12471,
297,
489,
283,
32274,
356,
519,
7,
1317,
447,
12471,
297,
272,
1660,
523,
2156,
199,
1386,
199,
91,
523,
283,
354,
356,
283,
1119,
5286,
63,
262,
63,
1339,
4674,
297,
523,
283,
32274,
356,
359,
82,
1159,
75,
447,
297,
519,
7,
1119,
5286,
447,
995,
199,
1386,
199,
61,
199,
624,
199,
199,
63,
2864,
63,
17014,
63,
1766,
21287,
275,
359,
272,
334,
19,
12,
4274,
2340,
63,
1943,
63,
16,
447,
1421,
19633,
1994,
11996,
14,
67,
659,
268,
661,
3749,
63,
1939,
397,
63,
7138,
63,
17552,
63,
1848,
297,
1994,
11996,
14,
67,
22864,
272,
334,
21,
12,
4274,
1421,
297,
1994,
11996,
14,
67,
659,
268,
661,
1317,
447,
5750,
447,
10297,
19633,
1994,
1317,
15,
5750,
15,
10297,
14,
2055,
659,
268,
661,
1700,
297,
1994,
11996,
14,
67,
22864,
272,
334,
23,
12,
4274,
1317,
447,
5750,
447,
10297,
63,
2836,
19633,
1994,
1317,
15,
5750,
15,
2836,
14,
2055,
22864,
272,
334,
845,
12,
4274,
1317,
447,
5750,
447,
1397,
63,
29428,
19633,
1994,
1317,
15,
954,
1118,
15,
10297,
14,
2055,
659,
881,
661,
1421,
297,
1994,
11996,
14,
67,
22864,
272,
334,
969,
12,
4274,
1421,
297,
1994,
11996,
14,
67,
659,
881,
661,
1317,
447,
12471,
447,
10297,
19633,
1994,
1317,
15,
12471,
15,
1421,
14,
67,
659,
881,
661,
1700,
297,
1994,
11996,
14,
67,
22864,
272,
334,
1196,
12,
4274,
1317,
447,
12471,
447,
10297,
63,
2836,
19633,
1994,
1317,
15,
12471,
15,
1421,
14,
67,
22864,
272,
334,
1167,
12,
4274,
1317,
447,
12471,
447,
10297,
63,
2836,
63,
18,
19633,
1994,
1317,
15,
12471,
15,
1700,
14,
67,
659,
881,
661,
1421,
297,
1994,
11996,
14,
67,
22864,
272,
334,
1789,
12,
4274,
1317,
447,
10297,
63,
14020,
297,
1994,
1317,
15,
1421,
14,
67,
22864,
272,
334,
1398,
12,
4274,
1421,
297,
1994,
11996,
14,
67,
659,
881,
661,
1339,
447,
10297,
297,
1994,
1339,
4674,
15,
10297,
14,
67,
659,
881,
661,
1397,
63,
1119,
83,
5286,
63,
1939,
397,
63,
9924,
63,
17552,
63,
1848,
297,
1994,
11996,
14,
67,
22864,
272,
334,
2192,
12,
4274,
1421,
297,
1994,
11996,
14,
67,
659,
881,
661,
1339,
447,
10297,
297,
1994,
1339,
4674,
15,
10297,
14,
67,
659,
881,
661,
1421,
447,
1700,
297,
1994,
11996,
14,
67,
659,
881,
661,
1339,
447,
1421,
447,
1119,
5286,
447,
9373,
19633,
1994,
1339,
4674,
15,
1119,
5286,
14,
67,
22864,
272,
334,
1401,
12,
4274,
1421,
297,
1994,
11996,
14,
67,
659,
881,
661,
1339,
447,
10297,
297,
1994,
11996,
14,
67,
659,
881,
661,
1339,
447,
1421,
447,
1119,
5286,
447,
9373,
19633,
1994,
11996,
14,
67,
22864,
272,
334,
2824,
12,
4274,
1421,
447,
1119,
5286,
447,
9373,
19633,
1994,
11996,
14,
67,
659,
881,
661,
1339,
447,
1421,
297,
1994,
11996,
14,
67,
659,
881,
661,
10603,
63,
1648,
63,
1939,
397,
63,
9924,
63,
17552,
297,
1994,
11996,
14,
67,
2023,
199,
61,
199,
199,
63,
22358,
63,
23545,
275,
469,
272,
283,
7316,
356,
12793,
359,
12332,
12,
378,
467,
272,
283,
7316,
447,
1317,
356,
4483,
359,
2720,
12,
378,
467,
272,
283,
7316,
447,
1317,
447,
5750,
356,
755,
359,
713,
12,
378,
467,
221,
327,
959,
435,
1520,
14,
272,
283,
7316,
447,
1317,
447,
12471,
356,
420,
359,
1887,
12,
378,
467,
221,
327,
4944,
435,
5557,
435,
5851,
14,
272,
283,
7316,
447,
1317,
447,
1317,
13,
1848,
356,
359,
1082,
12,
378,
467,
272,
283,
7316,
447,
1119,
5286,
63,
262,
63,
1339,
4674,
356,
260,
359,
2333,
12,
378,
467,
221,
327,
7105,
435,
6877,
14,
272,
283,
7316,
447,
7316,
13,
1848,
356,
3322,
359,
2194,
12,
378,
467,
221,
327,
650,
435,
7349,
435,
11851,
14,
199,
93,
199,
199,
63,
1645,
1230,
6225,
948,
63,
2864,
63,
17014,
63,
1766,
21287,
275,
359,
272,
334,
709,
12,
1994,
1231,
15,
1095,
17,
15,
1421,
15,
1700,
15,
493,
14,
2055,
659,
221,
327,
13370,
26,
378,
14,
969,
272,
334,
1165,
12,
1994,
1231,
15,
1095,
17,
15,
1421,
15,
6185,
15,
493,
14,
2055,
659,
221,
327,
13370,
26,
378,
14,
1479,
272,
334,
17,
12,
1994,
1231,
15,
1095,
17,
15,
1421,
15,
3540,
72,
15,
493,
14,
2055,
659,
257,
327,
13370,
26,
378,
14,
614,
272,
334,
19,
12,
1994,
1231,
15,
1095,
18,
15,
493,
14,
2055,
659,
3698,
327,
13370,
26,
378,
14,
1644,
272,
334,
1081,
12,
1994,
1231,
15,
1095,
18,
15,
954,
515,
15,
493,
14,
2055,
659,
221,
327,
13370,
26,
378,
14,
1651,
272,
334,
1085,
12,
1994,
1231,
15,
1095,
18,
15,
954,
515,
18,
15,
493,
14,
2055,
659,
327,
13370,
26,
378,
14,
1789,
272,
334,
18,
12,
1994,
1231,
15,
26517,
15,
493,
14,
2055,
659,
263,
327,
13370,
26,
378,
14,
996,
199,
61,
199,
199,
63,
1645,
1230,
6225,
948,
63,
22358,
63,
23545,
275,
469,
272,
283,
7316,
356,
2476,
263,
359,
2114,
12,
378,
467,
272,
283,
7316,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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
] |
ScreamingUdder/mantid
|
qt/widgets/sliceviewer/test/suite_ColorBarWidget/tst_min_makes_max_increase/test.py
|
3
|
1623
|
def main():
startApplication("ColorBarWidgetDemo")
spinDown(waitForObject(":valMax_QScienceSpinBox"))
spinDown(waitForObject(":valMax_QScienceSpinBox"))
waitFor("object.exists(':valMax_QScienceSpinBox')", 20000)
test.compare(findObject(":valMax_QScienceSpinBox").value, 98)
doubleClick(waitForObject(":qt_spinbox_lineedit_QLineEdit"), 22, 11, 0, Qt.LeftButton)
type(waitForObject(":valMax_QScienceSpinBox"), "<Ctrl+A>")
type(waitForObject(":valMax_QScienceSpinBox"), "1")
type(waitForObject(":valMax_QScienceSpinBox"), "2")
waitFor("object.exists(':valMax_QScienceSpinBox')", 20000)
test.compare(findObject(":valMax_QScienceSpinBox").value, 12)
spinUp(waitForObject(":valMin_QScienceSpinBox"))
spinUp(waitForObject(":valMin_QScienceSpinBox"))
spinUp(waitForObject(":valMin_QScienceSpinBox"))
spinUp(waitForObject(":valMin_QScienceSpinBox"))
spinUp(waitForObject(":valMin_QScienceSpinBox"))
spinUp(waitForObject(":valMin_QScienceSpinBox"))
spinUp(waitForObject(":valMin_QScienceSpinBox"))
spinUp(waitForObject(":valMin_QScienceSpinBox"))
spinUp(waitForObject(":valMin_QScienceSpinBox"))
spinUp(waitForObject(":valMin_QScienceSpinBox"))
spinUp(waitForObject(":valMin_QScienceSpinBox"))
spinUp(waitForObject(":valMin_QScienceSpinBox"))
spinUp(waitForObject(":valMin_QScienceSpinBox"))
spinUp(waitForObject(":valMin_QScienceSpinBox"))
waitFor("object.exists(':valMax_QScienceSpinBox')", 20000)
test.verify(findObject(":valMax_QScienceSpinBox").value > 14)
sendEvent("QCloseEvent", waitForObject(":_QMainWindow"))
|
gpl-3.0
|
[
199,
318,
2446,
837,
272,
1343,
5039,
480,
4117,
5281,
3339,
21493,
531,
272,
20749,
3514,
8,
2573,
1858,
1692,
20308,
637,
4261,
63,
23298,
559,
4894,
27806,
2237,
272,
20749,
3514,
8,
2573,
1858,
1692,
20308,
637,
4261,
63,
23298,
559,
4894,
27806,
2237,
272,
3618,
1858,
480,
785,
14,
2444,
6176,
637,
4261,
63,
23298,
559,
4894,
27806,
18106,
499,
993,
9,
272,
511,
14,
5785,
8,
1623,
1692,
20308,
637,
4261,
63,
23298,
559,
4894,
27806,
3471,
585,
12,
16096,
9,
272,
4270,
12040,
8,
2573,
1858,
1692,
20308,
8440,
63,
14809,
1977,
63,
604,
3773,
63,
32141,
4685,
1288,
6928,
12,
4119,
12,
378,
12,
3959,
14,
8185,
4259,
9,
272,
730,
8,
2573,
1858,
1692,
20308,
637,
4261,
63,
23298,
559,
4894,
27806,
1288,
3886,
9778,
11,
33,
9579,
272,
730,
8,
2573,
1858,
1692,
20308,
637,
4261,
63,
23298,
559,
4894,
27806,
1288,
298,
17,
531,
272,
730,
8,
2573,
1858,
1692,
20308,
637,
4261,
63,
23298,
559,
4894,
27806,
1288,
298,
18,
531,
272,
3618,
1858,
480,
785,
14,
2444,
6176,
637,
4261,
63,
23298,
559,
4894,
27806,
18106,
499,
993,
9,
272,
511,
14,
5785,
8,
1623,
1692,
20308,
637,
4261,
63,
23298,
559,
4894,
27806,
3471,
585,
12,
3144,
9,
272,
20749,
1721,
8,
2573,
1858,
1692,
20308,
637,
4649,
63,
23298,
559,
4894,
27806,
2237,
272,
20749,
1721,
8,
2573,
1858,
1692,
20308,
637,
4649,
63,
23298,
559,
4894,
27806,
2237,
272,
20749,
1721,
8,
2573,
1858,
1692,
20308,
637,
4649,
63,
23298,
559,
4894,
27806,
2237,
272,
20749,
1721,
8,
2573,
1858,
1692,
20308,
637,
4649,
63,
23298,
559,
4894,
27806,
2237,
272,
20749,
1721,
8,
2573,
1858,
1692,
20308,
637,
4649,
63,
23298,
559,
4894,
27806,
2237,
272,
20749,
1721,
8,
2573,
1858,
1692,
20308,
637,
4649,
63,
23298,
559,
4894,
27806,
2237,
272,
20749,
1721,
8,
2573,
1858,
1692,
20308,
637,
4649,
63,
23298,
559,
4894,
27806,
2237,
272,
20749,
1721,
8,
2573,
1858,
1692,
20308,
637,
4649,
63,
23298,
559,
4894,
27806,
2237,
272,
20749,
1721,
8,
2573,
1858,
1692,
20308,
637,
4649,
63,
23298,
559,
4894,
27806,
2237,
272,
20749,
1721,
8,
2573,
1858,
1692,
20308,
637,
4649,
63,
23298,
559,
4894,
27806,
2237,
272,
20749,
1721,
8,
2573,
1858,
1692,
20308,
637,
4649,
63,
23298,
559,
4894,
27806,
2237,
272,
20749,
1721,
8,
2573,
1858,
1692,
20308,
637,
4649,
63,
23298,
559,
4894,
27806,
2237,
272,
20749,
1721,
8,
2573,
1858,
1692,
20308,
637,
4649,
63,
23298,
559,
4894,
27806,
2237,
272,
20749,
1721,
8,
2573,
1858,
1692,
20308,
637,
4649,
63,
23298,
559,
4894,
27806,
2237,
272,
3618,
1858,
480,
785,
14,
2444,
6176,
637,
4261,
63,
23298,
559,
4894,
27806,
18106,
499,
993,
9,
272,
511,
14,
4712,
8,
1623,
1692,
20308,
637,
4261,
63,
23298,
559,
4894,
27806,
3471,
585,
690,
4329,
9,
272,
3222,
2390,
480,
49,
4724,
2390,
401,
3618,
1858,
1692,
20308,
63,
49,
16031,
2237,
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
] |
[
318,
2446,
837,
272,
1343,
5039,
480,
4117,
5281,
3339,
21493,
531,
272,
20749,
3514,
8,
2573,
1858,
1692,
20308,
637,
4261,
63,
23298,
559,
4894,
27806,
2237,
272,
20749,
3514,
8,
2573,
1858,
1692,
20308,
637,
4261,
63,
23298,
559,
4894,
27806,
2237,
272,
3618,
1858,
480,
785,
14,
2444,
6176,
637,
4261,
63,
23298,
559,
4894,
27806,
18106,
499,
993,
9,
272,
511,
14,
5785,
8,
1623,
1692,
20308,
637,
4261,
63,
23298,
559,
4894,
27806,
3471,
585,
12,
16096,
9,
272,
4270,
12040,
8,
2573,
1858,
1692,
20308,
8440,
63,
14809,
1977,
63,
604,
3773,
63,
32141,
4685,
1288,
6928,
12,
4119,
12,
378,
12,
3959,
14,
8185,
4259,
9,
272,
730,
8,
2573,
1858,
1692,
20308,
637,
4261,
63,
23298,
559,
4894,
27806,
1288,
3886,
9778,
11,
33,
9579,
272,
730,
8,
2573,
1858,
1692,
20308,
637,
4261,
63,
23298,
559,
4894,
27806,
1288,
298,
17,
531,
272,
730,
8,
2573,
1858,
1692,
20308,
637,
4261,
63,
23298,
559,
4894,
27806,
1288,
298,
18,
531,
272,
3618,
1858,
480,
785,
14,
2444,
6176,
637,
4261,
63,
23298,
559,
4894,
27806,
18106,
499,
993,
9,
272,
511,
14,
5785,
8,
1623,
1692,
20308,
637,
4261,
63,
23298,
559,
4894,
27806,
3471,
585,
12,
3144,
9,
272,
20749,
1721,
8,
2573,
1858,
1692,
20308,
637,
4649,
63,
23298,
559,
4894,
27806,
2237,
272,
20749,
1721,
8,
2573,
1858,
1692,
20308,
637,
4649,
63,
23298,
559,
4894,
27806,
2237,
272,
20749,
1721,
8,
2573,
1858,
1692,
20308,
637,
4649,
63,
23298,
559,
4894,
27806,
2237,
272,
20749,
1721,
8,
2573,
1858,
1692,
20308,
637,
4649,
63,
23298,
559,
4894,
27806,
2237,
272,
20749,
1721,
8,
2573,
1858,
1692,
20308,
637,
4649,
63,
23298,
559,
4894,
27806,
2237,
272,
20749,
1721,
8,
2573,
1858,
1692,
20308,
637,
4649,
63,
23298,
559,
4894,
27806,
2237,
272,
20749,
1721,
8,
2573,
1858,
1692,
20308,
637,
4649,
63,
23298,
559,
4894,
27806,
2237,
272,
20749,
1721,
8,
2573,
1858,
1692,
20308,
637,
4649,
63,
23298,
559,
4894,
27806,
2237,
272,
20749,
1721,
8,
2573,
1858,
1692,
20308,
637,
4649,
63,
23298,
559,
4894,
27806,
2237,
272,
20749,
1721,
8,
2573,
1858,
1692,
20308,
637,
4649,
63,
23298,
559,
4894,
27806,
2237,
272,
20749,
1721,
8,
2573,
1858,
1692,
20308,
637,
4649,
63,
23298,
559,
4894,
27806,
2237,
272,
20749,
1721,
8,
2573,
1858,
1692,
20308,
637,
4649,
63,
23298,
559,
4894,
27806,
2237,
272,
20749,
1721,
8,
2573,
1858,
1692,
20308,
637,
4649,
63,
23298,
559,
4894,
27806,
2237,
272,
20749,
1721,
8,
2573,
1858,
1692,
20308,
637,
4649,
63,
23298,
559,
4894,
27806,
2237,
272,
3618,
1858,
480,
785,
14,
2444,
6176,
637,
4261,
63,
23298,
559,
4894,
27806,
18106,
499,
993,
9,
272,
511,
14,
4712,
8,
1623,
1692,
20308,
637,
4261,
63,
23298,
559,
4894,
27806,
3471,
585,
690,
4329,
9,
272,
3222,
2390,
480,
49,
4724,
2390,
401,
3618,
1858,
1692,
20308,
63,
49,
16031,
2237,
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,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
djw8605/condor
|
nmi_tools/glue/build/email_on_failure.py
|
6
|
7280
|
#!/usr/bin/python
# The purpose of this script is to email users when an automated build breaks.
# Caveats:
# - it has a few hardcoded spots that require the build user to be cndrauto.
# - it only works for builds. I think tests are too flaky and would generate too much mail
#
# Written by Scot Kronenfeld 2011-06
# The current list of wranglers:
# - All failures will go to them, even if they are not in the author list.
# - Error emails will go to them and nobody else.
#WRANGLERS = ["kronenfe@cs.wisc.edu", "gthain@cs.wisc.edu", "johnkn@cs.wisc.edu"]
WRANGLERS = ["kronenfe@cs.wisc.edu", "johnkn@cs.wisc.edu"]
EMAIL_FROM_ADDRESS = 'noreply@cs.wisc.edu'
###############
import re
import os
import sys
import time
import socket
# For connecting to the DB
import MySQLdb
# For sending email
import smtplib
from email.MIMEText import MIMEText
#################################################
# Helper functions that implement all the logic #
#################################################
def validate_input():
""" Validate the input """
if len(sys.argv) != 2:
die_nice("Must pass in exactly one argument, the NMI Run ID that failed")
if re.search("\D", sys.argv[1]):
die_nice("Argument supplied does not look like an NMI Run ID. It contains a non-digit: %s" % sys.argv[1])
return sys.argv[1]
def load_config(file):
""" Load a config file of the format key=value. """
config = {}
f = open(file, 'r')
for line in f.readlines():
if re.match("\s*$", line) or re.match("\s*\#", line):
continue
m = re.match("\s*(\S+)\s*=\s*(.+)$", line)
if m:
config[m.group(1)] = m.group(2).strip()
return config
def check_runid(config, runid):
""" Connect to MySQL and determine the SHA1 value for the run and the previous run """
# Connect to MySQL using credentials from config file
conn = MySQLdb.connect(host = config["WEB_DB_HOST"], user = config["DB_READER_USER"], passwd = config["DB_READER_PASS"], db = "nmi_history")
cursor = conn.cursor()
# To get the last two runs we will first get details about the RunID that we know, then use that info to constrain the second query
cursor.execute("SELECT description FROM Run WHERE runid = " + runid + ";")
description = cursor.fetchone()[0]
# If this is a continuous build then we can leave the description alone.
# But if it is a branch build we need to strip the date off the end of it.
if re.search("-2\d\d\d-\d\d?-\d\d?$", description):
description = re.sub("-2\d\d\d-\d\d?-\d\d?$", "", description)
cursor.execute("SELECT result,project_version FROM Run WHERE user = \"cndrauto\" AND runid <= " + runid + " AND description LIKE \"" + description + "%\" ORDER BY runid DESC LIMIT 2;")
(this_result, this_sha1) = cursor.fetchone()
(prev_result, prev_sha1) = cursor.fetchone()
cursor.close()
conn.close()
print "Current result: %s - Current SHA1: %s" % (this_result, this_sha1)
print "Previous result: %s - Previous SHA1: %s" % (prev_result, prev_sha1)
# Check the status of the previous run. NMI status reference:
# Pass - 0
# Fail - >0
# Pending - NULL
if this_result == 0:
die_nice("This script was called for a run that succeeded", runid)
elif prev_result == None:
die_nice("The previous run is not complete yet", runid)
elif prev_result == 0:
# We have a failure and the previous run succeeded. Now is our time to shine!
authors = get_authors(this_sha1, prev_sha1)
msg = create_email(this_sha1, prev_sha1, description, runid, authors)
send_mail(authors.values(), msg, runid, description)
else:
# We don't need to do anything if there are two failures in a row.
# Maybe someday we will change this behavior.
print "Previous run failed - no need to send email"
return
def get_authors(new_sha1, old_sha1):
""" Given two sha1 hashes, get the list of Git authors and emails in between """
cmd = 'cd /space/git/CONDOR_SRC.git && git log --pretty=format:\'%an || %ae\' ' + old_sha1 + '..' + new_sha1 + ' 2>&1 | sort | uniq -c | sort -nr'
authors = {}
for line in os.popen(cmd).read().split("\n"):
m = re.match("\s*(.+) \|\| (.+)$", line)
if m:
authors[m.group(1)] = m.group(2).strip()
return authors
def create_email(this_sha1, prev_sha1, description, runid, authors):
""" Create the email to send out """
# Form a detailed message
msg = "A build of type '%s' failed. The previous build of this type succeeded.\n\n" % description
msg += "Build SHA1 - %s\n" % this_sha1
msg += "Previous SHA1 - %s\n\n\n" % prev_sha1
msg += "Committers in between:\n"
for author in authors.keys():
msg += "%s <%s>\n" % (author, authors[author])
msg += "\n"
msg += "Link to dashboard:\n"
msg += "http://nmi-s006.cs.wisc.edu/results/Run-condor-details.php?runid=%s&type=build&user=cndrauto\n\n" % runid
msg += "Log of commits between these two builds:\n"
msg += "http://condor-git.cs.wisc.edu/?p=condor.git;a=log;h=%s;hp=%s\n\n" % (this_sha1, prev_sha1)
msg += message_footer()
return msg
def message_footer():
""" Add some information at the bottom of the message """
footer = "\n\n---------- Script Info -------------\n"
footer += "Script that sent this mail: %s\n" % sys.argv[0]
footer += "CWD: %s\n" % os.getcwd()
footer += "Current host: %s\n" % socket.gethostname()
footer += "Current time: %s\n" % time.strftime("%X %x %Z")
return footer
def send_mail(emails, msg, runid, description):
""" Send the email to the supplied people """
msg = MIMEText(msg)
msg['Subject'] = "Build error - Run ID %s - Description '%s'" % (runid, description)
msg['From'] = EMAIL_FROM_ADDRESS
msg['To'] = str.join(",", WRANGLERS)
# Uncomment this line to go live. During testing we will just send to wranglers
#msg['To'] = str.join(",", emails) + "," + str.join(",", WRANGLERS)
s = smtplib.SMTP()
s.connect()
s.sendmail(EMAIL_FROM_ADDRESS, msg['To'], msg.as_string())
s.quit()
def die_nice(msg, runid="?"):
""" Email out an error message to peeps """
# We will send email with no extra addresses. This will just go to the wranglers.
send_mail({}, msg, runid, "Error occurred")
# Also print this to the screen so it shows up in the NMI build output
print msg
print "Exiting with error from %s" % sys.argv[0]
sys.exit(1)
################
# Control flow #
################
print "Beginning %s" % sys.argv[0]
try:
# Validate input RunID
nmi_runid = validate_input()
# Get the DB connection info from the config file
config = load_config("/nmi/etc/nmi.conf")
# Get the last runs
check_runid(config, nmi_runid)
except:
import traceback
# TODO: it would be nice to email this error message, but traceback.format_exc is missing in Python 2.3 :(
# So for now I'll just print it and then figure out a workaround at some unspecified point in the future.
traceback.print_exc()
print "Exiting successfully from %s" % sys.argv[0]
sys.exit(0)
|
apache-2.0
|
[
3381,
2647,
15,
1393,
15,
1548,
199,
199,
3,
710,
12016,
402,
642,
2884,
365,
370,
3031,
4390,
1380,
376,
6384,
23513,
1900,
18277,
14,
199,
3,
445,
811,
1956,
26,
199,
3,
221,
446,
652,
965,
282,
9284,
7508,
15282,
2249,
16673,
626,
4409,
314,
1900,
922,
370,
506,
286,
977,
345,
1283,
14,
199,
3,
221,
446,
652,
1454,
5419,
367,
14723,
14,
221,
473,
13516,
2295,
787,
4634,
17566,
10562,
436,
3955,
3550,
4634,
8298,
6016,
199,
3,
199,
3,
27694,
701,
428,
331,
84,
1804,
2641,
287,
70,
457,
7760,
13,
1690,
421,
199,
3,
710,
1453,
769,
402,
19865,
621,
29099,
26,
199,
3,
221,
446,
2900,
9081,
911,
2621,
370,
3062,
12,
2755,
340,
2985,
787,
440,
315,
314,
4132,
769,
14,
199,
3,
221,
446,
4520,
14931,
911,
2621,
370,
3062,
436,
949,
2030,
587,
14,
199,
3,
6524,
879,
2226,
3960,
275,
2097,
75,
2641,
287,
771,
32,
1259,
14,
87,
10840,
14,
8654,
401,
298,
997,
1581,
32,
1259,
14,
87,
10840,
14,
8654,
401,
298,
20216,
18974,
32,
1259,
14,
87,
10840,
14,
8654,
937,
199,
6524,
879,
2226,
3960,
275,
2097,
75,
2641,
287,
771,
32,
1259,
14,
87,
10840,
14,
8654,
401,
298,
20216,
18974,
32,
1259,
14,
87,
10840,
14,
8654,
937,
199,
199,
10089,
63,
12491,
63,
12368,
275,
283,
27400,
19786,
32,
1259,
14,
87,
10840,
14,
8654,
7,
199,
199,
516,
14776,
199,
199,
646,
295,
199,
646,
747,
199,
646,
984,
199,
646,
900,
199,
646,
2838,
199,
199,
3,
2104,
18170,
370,
314,
6249,
199,
646,
25709,
199,
199,
3,
2104,
10209,
3031,
199,
646,
30475,
199,
504,
3031,
14,
45,
26567,
492,
603,
26567,
199,
199,
22529,
3,
199,
3,
11642,
3423,
626,
5669,
1006,
314,
9661,
327,
199,
22529,
3,
199,
199,
318,
4107,
63,
1210,
837,
272,
408,
12134,
314,
1324,
408,
272,
340,
822,
8,
1274,
14,
3020,
9,
1137,
499,
26,
267,
18833,
63,
22746,
480,
13757,
986,
315,
8840,
1373,
1423,
12,
314,
653,
10709,
3378,
2870,
626,
3405,
531,
339,
340,
295,
14,
1733,
4582,
36,
401,
984,
14,
3020,
59,
17,
4682,
267,
18833,
63,
22746,
480,
5201,
6841,
1630,
440,
3648,
2839,
376,
653,
10709,
3378,
2870,
14,
221,
2779,
3509,
282,
2222,
13,
8573,
26,
450,
83,
2,
450,
984,
14,
3020,
59,
17,
566,
339,
372,
984,
14,
3020,
59,
17,
61,
421,
199,
318,
2248,
63,
888,
8,
493,
304,
272,
408,
7190,
282,
1101,
570,
402,
314,
1475,
790,
29,
585,
14,
408,
2286,
1101,
275,
1052,
339,
289,
275,
1551,
8,
493,
12,
283,
82,
358,
272,
367,
1004,
315,
289,
14,
9684,
837,
267,
340,
295,
14,
1431,
4582,
83,
10,
11918,
1004,
9,
503,
295,
14,
1431,
4582,
83,
7590,
3,
401,
1004,
304,
288,
1980,
398,
333,
275,
295,
14,
1431,
4582,
83,
22588,
51,
13439,
83,
23440,
83,
5830,
6977,
9,
11918,
1004,
9,
267,
340,
333,
26,
288,
1101,
59,
77,
14,
923,
8,
17,
1874,
275,
333,
14,
923,
8,
18,
680,
1913,
342,
339,
372,
1101,
199,
199,
318,
1104,
63,
1065,
344,
8,
888,
12,
1255,
344,
304,
272,
408,
15175,
370,
11200,
436,
6705,
314,
12002,
17,
574,
367,
314,
1255,
436,
314,
4136,
1255,
408,
339,
327,
15175,
370,
11200,
1808,
6235,
687,
1101,
570,
272,
2557,
275,
25709,
14,
2242,
8,
1102,
275,
1101,
905,
13166,
63,
2846,
63,
5449,
2255,
922,
275,
1101,
905,
2846,
63,
5670,
540,
63,
3791,
2255,
15081,
275,
1101,
905,
2846,
63,
5670,
540,
63,
6909,
2255,
1592,
275,
298,
78,
2664,
63,
5570,
531,
272,
3920,
275,
2557,
14,
3937,
342,
339,
327,
4005,
664,
314,
2061,
2877,
7858,
781,
911,
1642,
664,
2436,
3595,
314,
3378,
998,
626,
781,
5715,
12,
2066,
675,
626,
2256,
370,
950,
6322,
314,
3499,
1827,
272,
3920,
14,
2526,
480,
4859,
1369,
4442,
3378,
6038,
1255,
344,
275,
298,
435,
1255,
344,
435,
298,
15027,
272,
1369,
275,
3920,
14,
11591,
3430,
16,
61,
339,
327,
982,
642,
365,
282,
19922,
1900,
2066,
781,
883,
10137,
314,
1369,
23016,
14,
272,
327,
11017,
340,
652,
365,
282,
5246,
1900,
781,
1929,
370,
6202,
314,
1434,
2331,
314,
1284,
402,
652,
14,
272,
340,
295,
14,
1733,
6096,
18,
60,
68,
60,
68,
60,
68,
2696,
68,
60,
68,
31,
2696,
68,
60,
68,
31,
11918,
1369,
304,
267,
1369,
275,
295,
14,
954,
6096,
18,
60,
68,
60,
68,
60,
68,
2696,
68,
60,
68,
31,
2696,
68,
60,
68,
31,
11918,
4873,
1369,
9,
339,
3920,
14,
2526,
480,
4859,
754,
12,
1715,
63,
1023,
4442,
3378,
6038,
922,
275,
8441,
67,
977,
345,
1283,
4451,
2401,
1255,
344,
2695,
298,
435,
1255,
344,
435,
298,
2401,
1369,
29369,
19669,
435,
1369,
435,
2071,
4451,
16044,
6515,
1255,
344,
23915,
5138,
499,
15027,
272,
334,
3749,
63,
1099,
12,
642,
63,
4835,
17,
9,
275,
3920,
14,
11591,
342,
272,
334,
5701,
63,
1099,
12,
5071,
63,
4835,
17,
9,
275,
3920,
14,
11591,
342,
272,
3920,
14,
1600,
342,
272,
2557,
14,
1600,
342,
339,
870,
298,
5639,
754,
26,
450,
83,
446,
9338,
12002,
17,
26,
450,
83,
2,
450,
334,
3749,
63,
1099,
12,
642,
63,
4835,
17,
9,
272,
870,
298,
18021,
754,
26,
450,
83,
446,
26902,
12002,
17,
26,
450,
83,
2,
450,
334,
5701,
63,
1099,
12,
5071,
63,
4835,
17,
9,
339,
327,
2670,
314,
2004,
402,
314,
4136,
1255,
14,
221,
653,
10709,
2004,
3659,
26,
272,
327,
258,
8325,
446,
378,
272,
327,
258,
12176,
446,
690,
16,
272,
327,
258,
29216,
446,
5962,
272,
340,
642,
63,
1099,
508,
378,
26,
267,
18833,
63,
22746,
480,
2765,
2884,
1990,
2797,
367,
282,
1255,
626,
19268,
401,
1255,
344,
9,
272,
916,
5071,
63,
1099,
508,
488,
26,
267,
18833,
63,
22746,
480,
1918,
4136,
1255,
365,
440,
4890,
5966,
401,
1255,
344,
9,
272,
916,
5071,
63,
1099,
508,
378,
26,
267,
327,
2136,
1172,
282,
5988,
436,
314,
4136,
1255,
19268,
14,
221,
7356,
365,
4154,
900,
370,
1033,
1132,
1,
267,
11462,
275
] |
[
2647,
15,
1393,
15,
1548,
199,
199,
3,
710,
12016,
402,
642,
2884,
365,
370,
3031,
4390,
1380,
376,
6384,
23513,
1900,
18277,
14,
199,
3,
445,
811,
1956,
26,
199,
3,
221,
446,
652,
965,
282,
9284,
7508,
15282,
2249,
16673,
626,
4409,
314,
1900,
922,
370,
506,
286,
977,
345,
1283,
14,
199,
3,
221,
446,
652,
1454,
5419,
367,
14723,
14,
221,
473,
13516,
2295,
787,
4634,
17566,
10562,
436,
3955,
3550,
4634,
8298,
6016,
199,
3,
199,
3,
27694,
701,
428,
331,
84,
1804,
2641,
287,
70,
457,
7760,
13,
1690,
421,
199,
3,
710,
1453,
769,
402,
19865,
621,
29099,
26,
199,
3,
221,
446,
2900,
9081,
911,
2621,
370,
3062,
12,
2755,
340,
2985,
787,
440,
315,
314,
4132,
769,
14,
199,
3,
221,
446,
4520,
14931,
911,
2621,
370,
3062,
436,
949,
2030,
587,
14,
199,
3,
6524,
879,
2226,
3960,
275,
2097,
75,
2641,
287,
771,
32,
1259,
14,
87,
10840,
14,
8654,
401,
298,
997,
1581,
32,
1259,
14,
87,
10840,
14,
8654,
401,
298,
20216,
18974,
32,
1259,
14,
87,
10840,
14,
8654,
937,
199,
6524,
879,
2226,
3960,
275,
2097,
75,
2641,
287,
771,
32,
1259,
14,
87,
10840,
14,
8654,
401,
298,
20216,
18974,
32,
1259,
14,
87,
10840,
14,
8654,
937,
199,
199,
10089,
63,
12491,
63,
12368,
275,
283,
27400,
19786,
32,
1259,
14,
87,
10840,
14,
8654,
7,
199,
199,
516,
14776,
199,
199,
646,
295,
199,
646,
747,
199,
646,
984,
199,
646,
900,
199,
646,
2838,
199,
199,
3,
2104,
18170,
370,
314,
6249,
199,
646,
25709,
199,
199,
3,
2104,
10209,
3031,
199,
646,
30475,
199,
504,
3031,
14,
45,
26567,
492,
603,
26567,
199,
199,
22529,
3,
199,
3,
11642,
3423,
626,
5669,
1006,
314,
9661,
327,
199,
22529,
3,
199,
199,
318,
4107,
63,
1210,
837,
272,
408,
12134,
314,
1324,
408,
272,
340,
822,
8,
1274,
14,
3020,
9,
1137,
499,
26,
267,
18833,
63,
22746,
480,
13757,
986,
315,
8840,
1373,
1423,
12,
314,
653,
10709,
3378,
2870,
626,
3405,
531,
339,
340,
295,
14,
1733,
4582,
36,
401,
984,
14,
3020,
59,
17,
4682,
267,
18833,
63,
22746,
480,
5201,
6841,
1630,
440,
3648,
2839,
376,
653,
10709,
3378,
2870,
14,
221,
2779,
3509,
282,
2222,
13,
8573,
26,
450,
83,
2,
450,
984,
14,
3020,
59,
17,
566,
339,
372,
984,
14,
3020,
59,
17,
61,
421,
199,
318,
2248,
63,
888,
8,
493,
304,
272,
408,
7190,
282,
1101,
570,
402,
314,
1475,
790,
29,
585,
14,
408,
2286,
1101,
275,
1052,
339,
289,
275,
1551,
8,
493,
12,
283,
82,
358,
272,
367,
1004,
315,
289,
14,
9684,
837,
267,
340,
295,
14,
1431,
4582,
83,
10,
11918,
1004,
9,
503,
295,
14,
1431,
4582,
83,
7590,
3,
401,
1004,
304,
288,
1980,
398,
333,
275,
295,
14,
1431,
4582,
83,
22588,
51,
13439,
83,
23440,
83,
5830,
6977,
9,
11918,
1004,
9,
267,
340,
333,
26,
288,
1101,
59,
77,
14,
923,
8,
17,
1874,
275,
333,
14,
923,
8,
18,
680,
1913,
342,
339,
372,
1101,
199,
199,
318,
1104,
63,
1065,
344,
8,
888,
12,
1255,
344,
304,
272,
408,
15175,
370,
11200,
436,
6705,
314,
12002,
17,
574,
367,
314,
1255,
436,
314,
4136,
1255,
408,
339,
327,
15175,
370,
11200,
1808,
6235,
687,
1101,
570,
272,
2557,
275,
25709,
14,
2242,
8,
1102,
275,
1101,
905,
13166,
63,
2846,
63,
5449,
2255,
922,
275,
1101,
905,
2846,
63,
5670,
540,
63,
3791,
2255,
15081,
275,
1101,
905,
2846,
63,
5670,
540,
63,
6909,
2255,
1592,
275,
298,
78,
2664,
63,
5570,
531,
272,
3920,
275,
2557,
14,
3937,
342,
339,
327,
4005,
664,
314,
2061,
2877,
7858,
781,
911,
1642,
664,
2436,
3595,
314,
3378,
998,
626,
781,
5715,
12,
2066,
675,
626,
2256,
370,
950,
6322,
314,
3499,
1827,
272,
3920,
14,
2526,
480,
4859,
1369,
4442,
3378,
6038,
1255,
344,
275,
298,
435,
1255,
344,
435,
298,
15027,
272,
1369,
275,
3920,
14,
11591,
3430,
16,
61,
339,
327,
982,
642,
365,
282,
19922,
1900,
2066,
781,
883,
10137,
314,
1369,
23016,
14,
272,
327,
11017,
340,
652,
365,
282,
5246,
1900,
781,
1929,
370,
6202,
314,
1434,
2331,
314,
1284,
402,
652,
14,
272,
340,
295,
14,
1733,
6096,
18,
60,
68,
60,
68,
60,
68,
2696,
68,
60,
68,
31,
2696,
68,
60,
68,
31,
11918,
1369,
304,
267,
1369,
275,
295,
14,
954,
6096,
18,
60,
68,
60,
68,
60,
68,
2696,
68,
60,
68,
31,
2696,
68,
60,
68,
31,
11918,
4873,
1369,
9,
339,
3920,
14,
2526,
480,
4859,
754,
12,
1715,
63,
1023,
4442,
3378,
6038,
922,
275,
8441,
67,
977,
345,
1283,
4451,
2401,
1255,
344,
2695,
298,
435,
1255,
344,
435,
298,
2401,
1369,
29369,
19669,
435,
1369,
435,
2071,
4451,
16044,
6515,
1255,
344,
23915,
5138,
499,
15027,
272,
334,
3749,
63,
1099,
12,
642,
63,
4835,
17,
9,
275,
3920,
14,
11591,
342,
272,
334,
5701,
63,
1099,
12,
5071,
63,
4835,
17,
9,
275,
3920,
14,
11591,
342,
272,
3920,
14,
1600,
342,
272,
2557,
14,
1600,
342,
339,
870,
298,
5639,
754,
26,
450,
83,
446,
9338,
12002,
17,
26,
450,
83,
2,
450,
334,
3749,
63,
1099,
12,
642,
63,
4835,
17,
9,
272,
870,
298,
18021,
754,
26,
450,
83,
446,
26902,
12002,
17,
26,
450,
83,
2,
450,
334,
5701,
63,
1099,
12,
5071,
63,
4835,
17,
9,
339,
327,
2670,
314,
2004,
402,
314,
4136,
1255,
14,
221,
653,
10709,
2004,
3659,
26,
272,
327,
258,
8325,
446,
378,
272,
327,
258,
12176,
446,
690,
16,
272,
327,
258,
29216,
446,
5962,
272,
340,
642,
63,
1099,
508,
378,
26,
267,
18833,
63,
22746,
480,
2765,
2884,
1990,
2797,
367,
282,
1255,
626,
19268,
401,
1255,
344,
9,
272,
916,
5071,
63,
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,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
aparo/django-nonrel
|
django/utils/cache.py
|
22
|
8766
|
"""
This module contains helper functions for controlling caching. It does so by
managing the "Vary" header of responses. It includes functions to patch the
header of response objects directly and decorators that change functions to do
that header-patching themselves.
For information on the Vary header, see:
http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.44
Essentially, the "Vary" HTTP header defines which headers a cache should take
into account when building its cache key. Requests with the same path but
different header content for headers named in "Vary" need to get different
cache keys to prevent delivery of wrong content.
An example: i18n middleware would need to distinguish caches by the
"Accept-language" header.
"""
import re
import time
from django.conf import settings
from django.core.cache import cache
from django.utils.encoding import smart_str, iri_to_uri
from django.utils.http import http_date
from django.utils.hashcompat import md5_constructor
from django.utils.translation import get_language
from django.http import HttpRequest
cc_delim_re = re.compile(r'\s*,\s*')
def patch_cache_control(response, **kwargs):
"""
This function patches the Cache-Control header by adding all
keyword arguments to it. The transformation is as follows:
* All keyword parameter names are turned to lowercase, and underscores
are converted to hyphens.
* If the value of a parameter is True (exactly True, not just a
true value), only the parameter name is added to the header.
* All other parameters are added with their value, after applying
str() to it.
"""
def dictitem(s):
t = s.split('=', 1)
if len(t) > 1:
return (t[0].lower(), t[1])
else:
return (t[0].lower(), True)
def dictvalue(t):
if t[1] is True:
return t[0]
else:
return t[0] + '=' + smart_str(t[1])
if response.has_header('Cache-Control'):
cc = cc_delim_re.split(response['Cache-Control'])
cc = dict([dictitem(el) for el in cc])
else:
cc = {}
# If there's already a max-age header but we're being asked to set a new
# max-age, use the minimum of the two ages. In practice this happens when
# a decorator and a piece of middleware both operate on a given view.
if 'max-age' in cc and 'max_age' in kwargs:
kwargs['max_age'] = min(cc['max-age'], kwargs['max_age'])
for (k, v) in kwargs.items():
cc[k.replace('_', '-')] = v
cc = ', '.join([dictvalue(el) for el in cc.items()])
response['Cache-Control'] = cc
def get_max_age(response):
"""
Returns the max-age from the response Cache-Control header as an integer
(or ``None`` if it wasn't found or wasn't an integer.
"""
if not response.has_header('Cache-Control'):
return
cc = dict([_to_tuple(el) for el in
cc_delim_re.split(response['Cache-Control'])])
if 'max-age' in cc:
try:
return int(cc['max-age'])
except (ValueError, TypeError):
pass
def patch_response_headers(response, cache_timeout=None):
"""
Adds some useful headers to the given HttpResponse object:
ETag, Last-Modified, Expires and Cache-Control
Each header is only added if it isn't already set.
cache_timeout is in seconds. The CACHE_MIDDLEWARE_SECONDS setting is used
by default.
"""
if cache_timeout is None:
cache_timeout = settings.CACHE_MIDDLEWARE_SECONDS
if cache_timeout < 0:
cache_timeout = 0 # Can't have max-age negative
if not response.has_header('ETag'):
response['ETag'] = '"%s"' % md5_constructor(response.content).hexdigest()
if not response.has_header('Last-Modified'):
response['Last-Modified'] = http_date()
if not response.has_header('Expires'):
response['Expires'] = http_date(time.time() + cache_timeout)
patch_cache_control(response, max_age=cache_timeout)
def add_never_cache_headers(response):
"""
Adds headers to a response to indicate that a page should never be cached.
"""
patch_response_headers(response, cache_timeout=-1)
def patch_vary_headers(response, newheaders):
"""
Adds (or updates) the "Vary" header in the given HttpResponse object.
newheaders is a list of header names that should be in "Vary". Existing
headers in "Vary" aren't removed.
"""
# Note that we need to keep the original order intact, because cache
# implementations may rely on the order of the Vary contents in, say,
# computing an MD5 hash.
if response.has_header('Vary'):
vary_headers = cc_delim_re.split(response['Vary'])
else:
vary_headers = []
# Use .lower() here so we treat headers as case-insensitive.
existing_headers = set([header.lower() for header in vary_headers])
additional_headers = [newheader for newheader in newheaders
if newheader.lower() not in existing_headers]
response['Vary'] = ', '.join(vary_headers + additional_headers)
def _i18n_cache_key_suffix(request, cache_key):
"""If enabled, returns the cache key ending with a locale."""
if settings.USE_I18N:
# first check if LocaleMiddleware or another middleware added
# LANGUAGE_CODE to request, then fall back to the active language
# which in turn can also fall back to settings.LANGUAGE_CODE
cache_key += '.%s' % getattr(request, 'LANGUAGE_CODE', get_language())
return cache_key
def _generate_cache_key(request, headerlist, key_prefix):
"""Returns a cache key from the headers given in the header list."""
ctx = md5_constructor()
for header in headerlist:
value = request.META.get(header, None)
if value is not None:
ctx.update(value)
path = md5_constructor(iri_to_uri(request.path))
cache_key = 'views.decorators.cache.cache_page.%s.%s.%s' % (
key_prefix, path.hexdigest(), ctx.hexdigest())
return _i18n_cache_key_suffix(request, cache_key)
def _generate_cache_header_key(key_prefix, request):
"""Returns a cache key for the header cache."""
path = md5_constructor(iri_to_uri(request.path))
cache_key = 'views.decorators.cache.cache_header.%s.%s' % (
key_prefix, path.hexdigest())
return _i18n_cache_key_suffix(request, cache_key)
def get_cache_key(request, key_prefix=None):
"""
Returns a cache key based on the request path. It can be used in the
request phase because it pulls the list of headers to take into account
from the global path registry and uses those to build a cache key to check
against.
If there is no headerlist stored, the page needs to be rebuilt, so this
function returns None.
"""
if key_prefix is None:
key_prefix = settings.CACHE_MIDDLEWARE_KEY_PREFIX
cache_key = _generate_cache_header_key(key_prefix, request)
headerlist = cache.get(cache_key, None)
if headerlist is not None:
return _generate_cache_key(request, headerlist, key_prefix)
else:
return None
def learn_cache_key(request, response, cache_timeout=None, key_prefix=None):
"""
Learns what headers to take into account for some request path from the
response object. It stores those headers in a global path registry so that
later access to that path will know what headers to take into account
without building the response object itself. The headers are named in the
Vary header of the response, but we want to prevent response generation.
The list of headers to use for cache key generation is stored in the same
cache as the pages themselves. If the cache ages some data out of the
cache, this just means that we have to build the response once to get at
the Vary header and so at the list of headers to use for the cache key.
"""
if key_prefix is None:
key_prefix = settings.CACHE_MIDDLEWARE_KEY_PREFIX
if cache_timeout is None:
cache_timeout = settings.CACHE_MIDDLEWARE_SECONDS
cache_key = _generate_cache_header_key(key_prefix, request)
if response.has_header('Vary'):
headerlist = ['HTTP_'+header.upper().replace('-', '_')
for header in cc_delim_re.split(response['Vary'])]
cache.set(cache_key, headerlist, cache_timeout)
return _generate_cache_key(request, headerlist, key_prefix)
else:
# if there is no Vary header, we still need a cache key
# for the request.path
cache.set(cache_key, [], cache_timeout)
return _generate_cache_key(request, [], key_prefix)
def _to_tuple(s):
t = s.split('=',1)
if len(t) == 2:
return t[0].lower(), t[1]
return t[0].lower(), True
|
bsd-3-clause
|
[
624,
199,
2765,
859,
3509,
5922,
3423,
367,
30350,
13627,
14,
2779,
1630,
880,
701,
199,
1237,
7407,
314,
298,
54,
695,
2,
1406,
402,
9320,
14,
2779,
6952,
3423,
370,
3371,
314,
199,
1291,
402,
1177,
2251,
5370,
436,
20419,
626,
1570,
3423,
370,
886,
199,
9099,
1406,
13,
2068,
316,
17279,
14,
199,
199,
1858,
2556,
641,
314,
812,
695,
1406,
12,
1937,
26,
339,
1455,
921,
1544,
14,
87,
19,
14,
1308,
15,
8548,
4574,
15,
8973,
25807,
15,
8973,
25807,
13,
3321,
1079,
14,
1360,
3,
3321,
1079,
14,
1602,
199,
199,
21658,
2464,
9406,
12,
314,
298,
54,
695,
2,
3101,
1406,
7890,
1314,
2323,
282,
2581,
1077,
5452,
199,
9924,
2933,
1380,
10015,
2399,
2581,
790,
14,
20260,
543,
314,
2011,
931,
1325,
199,
14020,
1406,
1564,
367,
2323,
4310,
315,
298,
54,
695,
2,
1929,
370,
664,
3365,
199,
1637,
2883,
370,
7981,
18719,
402,
6835,
1564,
14,
199,
199,
2493,
2893,
26,
284,
1085,
78,
10816,
3955,
1929,
370,
22237,
18014,
701,
314,
199,
2,
8422,
13,
3671,
2,
1406,
14,
199,
624,
199,
199,
646,
295,
199,
646,
900,
199,
199,
504,
1639,
14,
2190,
492,
2202,
199,
504,
1639,
14,
1018,
14,
1637,
492,
2581,
199,
504,
1639,
14,
1208,
14,
2991,
492,
11179,
63,
495,
12,
24086,
63,
475,
63,
2302,
199,
504,
1639,
14,
1208,
14,
1014,
492,
1455,
63,
602,
199,
504,
1639,
14,
1208,
14,
2227,
5819,
492,
6128,
21,
63,
1880,
199,
504,
1639,
14,
1208,
14,
6893,
492,
664,
63,
3671,
199,
504,
1639,
14,
1014,
492,
20730,
199,
199,
2055,
63,
15966,
63,
264,
275,
295,
14,
2014,
8,
82,
1154,
83,
10,
4202,
83,
13418,
199,
199,
318,
3371,
63,
1637,
63,
2785,
8,
1310,
12,
1011,
958,
304,
272,
408,
272,
961,
805,
12385,
314,
11977,
13,
3717,
1406,
701,
7791,
1006,
272,
4252,
2368,
370,
652,
14,
710,
13315,
365,
465,
11924,
26,
339,
627,
2900,
4252,
2725,
1561,
787,
19136,
370,
12141,
12,
436,
23998,
489,
787,
6702,
370,
7188,
27920,
14,
272,
627,
982,
314,
574,
402,
282,
2725,
365,
715,
334,
7327,
590,
715,
12,
440,
2951,
282,
489,
2549,
574,
395,
1454,
314,
2725,
536,
365,
3483,
370,
314,
1406,
14,
272,
627,
2900,
1163,
2633,
787,
3483,
543,
3932,
574,
12,
2410,
18876,
489,
620,
342,
370,
652,
14,
272,
408,
272,
347,
12219,
4484,
8,
83,
304,
267,
307,
275,
308,
14,
1294,
25283,
413,
9,
267,
340,
822,
8,
84,
9,
690,
413,
26,
288,
372,
334,
84,
59,
16,
1055,
2325,
1062,
307,
59,
17,
566,
267,
587,
26,
288,
372,
334,
84,
59,
16,
1055,
2325,
1062,
715,
9,
339,
347,
1211,
585,
8,
84,
304,
267,
340,
307,
59,
17,
61,
365,
715,
26,
288,
372,
307,
59,
16,
61,
267,
587,
26,
288,
372,
307,
59,
16,
61,
435,
14051,
435,
11179,
63,
495,
8,
84,
59,
17,
566,
339,
340,
1177,
14,
1989,
63,
1291,
360,
4437,
13,
3717,
735,
267,
7429,
275,
7429,
63,
15966,
63,
264,
14,
1294,
8,
1310,
459,
4437,
13,
3717,
1105,
267,
7429,
275,
1211,
779,
5000,
4484,
8,
352,
9,
367,
579,
315,
7429,
566,
272,
587,
26,
267,
7429,
275,
1052,
339,
327,
982,
2337,
1159,
2575,
282,
1390,
13,
474,
1406,
1325,
781,
3984,
3769,
20864,
370,
663,
282,
892,
272,
327,
1390,
13,
474,
12,
675,
314,
7481,
402,
314,
2877,
282,
3389,
14,
1010,
24471,
642,
10986,
1380,
272,
327,
282,
7531,
436,
282,
14854,
402,
10816,
3865,
19218,
641,
282,
1627,
2455,
14,
272,
340,
283,
988,
13,
474,
7,
315,
7429,
436,
283,
988,
63,
474,
7,
315,
2074,
26,
267,
2074,
459,
988,
63,
474,
418,
275,
1748,
8,
2055,
459,
988,
13,
474,
995,
2074,
459,
988,
63,
474,
1105,
339,
367,
334,
75,
12,
373,
9,
315,
2074,
14,
1744,
837,
267,
7429,
59,
75,
14,
1814,
20928,
2475,
5440,
275,
373,
272,
7429,
275,
1656,
1987,
904,
779,
807,
585,
8,
352,
9,
367,
579,
315,
7429,
14,
1744,
9383,
272,
1177,
459,
4437,
13,
3717,
418,
275,
7429,
199,
199,
318,
664,
63,
988,
63,
474,
8,
1310,
304,
272,
408,
272,
1803,
314,
1390,
13,
474,
687,
314,
1177,
11977,
13,
3717,
1406,
465,
376,
3000,
272,
334,
269,
1124,
403,
1040,
340,
652,
17373,
1133,
1911,
503,
17373,
1133,
376,
3000,
14,
272,
408,
272,
340,
440,
1177,
14,
1989,
63,
1291,
360,
4437,
13,
3717,
735,
267,
372,
272,
7429,
275,
1211,
779,
63,
475,
63,
2960,
8,
352,
9,
367,
579,
315,
267,
7429,
63,
15966,
63,
264,
14,
1294,
8,
1310,
459,
4437,
13,
3717,
31161,
272,
340,
283,
988,
13,
474,
7,
315,
7429,
26,
267,
862,
26,
288,
372,
1109,
8,
2055,
459,
988,
13,
474,
1105,
267,
871,
334,
3393,
12,
3146,
304,
288,
986,
199,
199,
318,
3371,
63,
1310,
63,
2139,
8,
1310,
12,
2581,
63,
2593,
29,
403,
304,
272,
408,
272,
15747,
2005,
2997,
2323,
370,
314,
1627,
6183,
909,
26,
267,
662,
1931,
12,
15237,
13,
11911,
12,
1316,
1038,
470,
436,
11977,
13,
3717,
339,
7048,
1406,
365,
1454,
3483,
340,
652,
5712,
1133,
2575,
663,
14,
339,
2581,
63,
2593,
365,
315,
4696,
14,
710,
7240,
4576,
63,
19987,
63,
23319,
4260,
365,
1202,
272,
701,
849,
14,
272,
408,
272,
340,
2581,
63,
2593,
365,
488,
26,
267,
2581,
63,
2593,
275,
2202,
14,
8677,
63,
19987,
63,
23319,
272,
340,
2581,
63,
2593,
665,
378,
26,
267,
2581,
63,
2593,
275,
378,
327,
6855,
1133,
1172,
1390,
13,
474,
6946,
272,
340,
440,
1177,
14,
1989,
63,
1291,
360,
30206,
735,
267,
1177,
459,
30206,
418,
275,
18253,
83,
4507,
450,
6128,
21,
63,
1880,
8,
1310,
14,
1317,
680,
11453,
342,
272,
340,
440,
1177,
14,
1989,
63,
1291,
360,
6090,
13,
11911,
735,
267,
1177,
459,
6090,
13,
11911,
418,
275,
1455,
63,
602,
342,
272,
340,
440,
1177,
14,
1989,
63,
1291,
360,
14000,
470,
735,
267,
1177,
459,
14000,
470,
418,
275,
1455,
63,
602,
8,
521,
14,
521,
342,
435,
2581,
63
] |
[
199,
2765,
859,
3509,
5922,
3423,
367,
30350,
13627,
14,
2779,
1630,
880,
701,
199,
1237,
7407,
314,
298,
54,
695,
2,
1406,
402,
9320,
14,
2779,
6952,
3423,
370,
3371,
314,
199,
1291,
402,
1177,
2251,
5370,
436,
20419,
626,
1570,
3423,
370,
886,
199,
9099,
1406,
13,
2068,
316,
17279,
14,
199,
199,
1858,
2556,
641,
314,
812,
695,
1406,
12,
1937,
26,
339,
1455,
921,
1544,
14,
87,
19,
14,
1308,
15,
8548,
4574,
15,
8973,
25807,
15,
8973,
25807,
13,
3321,
1079,
14,
1360,
3,
3321,
1079,
14,
1602,
199,
199,
21658,
2464,
9406,
12,
314,
298,
54,
695,
2,
3101,
1406,
7890,
1314,
2323,
282,
2581,
1077,
5452,
199,
9924,
2933,
1380,
10015,
2399,
2581,
790,
14,
20260,
543,
314,
2011,
931,
1325,
199,
14020,
1406,
1564,
367,
2323,
4310,
315,
298,
54,
695,
2,
1929,
370,
664,
3365,
199,
1637,
2883,
370,
7981,
18719,
402,
6835,
1564,
14,
199,
199,
2493,
2893,
26,
284,
1085,
78,
10816,
3955,
1929,
370,
22237,
18014,
701,
314,
199,
2,
8422,
13,
3671,
2,
1406,
14,
199,
624,
199,
199,
646,
295,
199,
646,
900,
199,
199,
504,
1639,
14,
2190,
492,
2202,
199,
504,
1639,
14,
1018,
14,
1637,
492,
2581,
199,
504,
1639,
14,
1208,
14,
2991,
492,
11179,
63,
495,
12,
24086,
63,
475,
63,
2302,
199,
504,
1639,
14,
1208,
14,
1014,
492,
1455,
63,
602,
199,
504,
1639,
14,
1208,
14,
2227,
5819,
492,
6128,
21,
63,
1880,
199,
504,
1639,
14,
1208,
14,
6893,
492,
664,
63,
3671,
199,
504,
1639,
14,
1014,
492,
20730,
199,
199,
2055,
63,
15966,
63,
264,
275,
295,
14,
2014,
8,
82,
1154,
83,
10,
4202,
83,
13418,
199,
199,
318,
3371,
63,
1637,
63,
2785,
8,
1310,
12,
1011,
958,
304,
272,
408,
272,
961,
805,
12385,
314,
11977,
13,
3717,
1406,
701,
7791,
1006,
272,
4252,
2368,
370,
652,
14,
710,
13315,
365,
465,
11924,
26,
339,
627,
2900,
4252,
2725,
1561,
787,
19136,
370,
12141,
12,
436,
23998,
489,
787,
6702,
370,
7188,
27920,
14,
272,
627,
982,
314,
574,
402,
282,
2725,
365,
715,
334,
7327,
590,
715,
12,
440,
2951,
282,
489,
2549,
574,
395,
1454,
314,
2725,
536,
365,
3483,
370,
314,
1406,
14,
272,
627,
2900,
1163,
2633,
787,
3483,
543,
3932,
574,
12,
2410,
18876,
489,
620,
342,
370,
652,
14,
272,
408,
272,
347,
12219,
4484,
8,
83,
304,
267,
307,
275,
308,
14,
1294,
25283,
413,
9,
267,
340,
822,
8,
84,
9,
690,
413,
26,
288,
372,
334,
84,
59,
16,
1055,
2325,
1062,
307,
59,
17,
566,
267,
587,
26,
288,
372,
334,
84,
59,
16,
1055,
2325,
1062,
715,
9,
339,
347,
1211,
585,
8,
84,
304,
267,
340,
307,
59,
17,
61,
365,
715,
26,
288,
372,
307,
59,
16,
61,
267,
587,
26,
288,
372,
307,
59,
16,
61,
435,
14051,
435,
11179,
63,
495,
8,
84,
59,
17,
566,
339,
340,
1177,
14,
1989,
63,
1291,
360,
4437,
13,
3717,
735,
267,
7429,
275,
7429,
63,
15966,
63,
264,
14,
1294,
8,
1310,
459,
4437,
13,
3717,
1105,
267,
7429,
275,
1211,
779,
5000,
4484,
8,
352,
9,
367,
579,
315,
7429,
566,
272,
587,
26,
267,
7429,
275,
1052,
339,
327,
982,
2337,
1159,
2575,
282,
1390,
13,
474,
1406,
1325,
781,
3984,
3769,
20864,
370,
663,
282,
892,
272,
327,
1390,
13,
474,
12,
675,
314,
7481,
402,
314,
2877,
282,
3389,
14,
1010,
24471,
642,
10986,
1380,
272,
327,
282,
7531,
436,
282,
14854,
402,
10816,
3865,
19218,
641,
282,
1627,
2455,
14,
272,
340,
283,
988,
13,
474,
7,
315,
7429,
436,
283,
988,
63,
474,
7,
315,
2074,
26,
267,
2074,
459,
988,
63,
474,
418,
275,
1748,
8,
2055,
459,
988,
13,
474,
995,
2074,
459,
988,
63,
474,
1105,
339,
367,
334,
75,
12,
373,
9,
315,
2074,
14,
1744,
837,
267,
7429,
59,
75,
14,
1814,
20928,
2475,
5440,
275,
373,
272,
7429,
275,
1656,
1987,
904,
779,
807,
585,
8,
352,
9,
367,
579,
315,
7429,
14,
1744,
9383,
272,
1177,
459,
4437,
13,
3717,
418,
275,
7429,
199,
199,
318,
664,
63,
988,
63,
474,
8,
1310,
304,
272,
408,
272,
1803,
314,
1390,
13,
474,
687,
314,
1177,
11977,
13,
3717,
1406,
465,
376,
3000,
272,
334,
269,
1124,
403,
1040,
340,
652,
17373,
1133,
1911,
503,
17373,
1133,
376,
3000,
14,
272,
408,
272,
340,
440,
1177,
14,
1989,
63,
1291,
360,
4437,
13,
3717,
735,
267,
372,
272,
7429,
275,
1211,
779,
63,
475,
63,
2960,
8,
352,
9,
367,
579,
315,
267,
7429,
63,
15966,
63,
264,
14,
1294,
8,
1310,
459,
4437,
13,
3717,
31161,
272,
340,
283,
988,
13,
474,
7,
315,
7429,
26,
267,
862,
26,
288,
372,
1109,
8,
2055,
459,
988,
13,
474,
1105,
267,
871,
334,
3393,
12,
3146,
304,
288,
986,
199,
199,
318,
3371,
63,
1310,
63,
2139,
8,
1310,
12,
2581,
63,
2593,
29,
403,
304,
272,
408,
272,
15747,
2005,
2997,
2323,
370,
314,
1627,
6183,
909,
26,
267,
662,
1931,
12,
15237,
13,
11911,
12,
1316,
1038,
470,
436,
11977,
13,
3717,
339,
7048,
1406,
365,
1454,
3483,
340,
652,
5712,
1133,
2575,
663,
14,
339,
2581,
63,
2593,
365,
315,
4696,
14,
710,
7240,
4576,
63,
19987,
63,
23319,
4260,
365,
1202,
272,
701,
849,
14,
272,
408,
272,
340,
2581,
63,
2593,
365,
488,
26,
267,
2581,
63,
2593,
275,
2202,
14,
8677,
63,
19987,
63,
23319,
272,
340,
2581,
63,
2593,
665,
378,
26,
267,
2581,
63,
2593,
275,
378,
327,
6855,
1133,
1172,
1390,
13,
474,
6946,
272,
340,
440,
1177,
14,
1989,
63,
1291,
360,
30206,
735,
267,
1177,
459,
30206,
418,
275,
18253,
83,
4507,
450,
6128,
21,
63,
1880,
8,
1310,
14,
1317,
680,
11453,
342,
272,
340,
440,
1177,
14,
1989,
63,
1291,
360,
6090,
13,
11911,
735,
267,
1177,
459,
6090,
13,
11911,
418,
275,
1455,
63,
602,
342,
272,
340,
440,
1177,
14,
1989,
63,
1291,
360,
14000,
470,
735,
267,
1177,
459,
14000,
470,
418,
275,
1455,
63,
602,
8,
521,
14,
521,
342,
435,
2581,
63,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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serList import UserList
# We do a bit of trickery here to be able to test both the C implementation
# and the Python implementation of the module.
# Make it impossible to import the C implementation anymore.
sys.modules['_bisect'] = 0
# We must also handle the case that bisect was imported before.
if 'bisect' in sys.modules:
del sys.modules['bisect']
# Now we can import the module and get the pure Python implementation.
import bisect as py_bisect
# Restore everything to normal.
del sys.modules['_bisect']
del sys.modules['bisect']
# This is now the module with the C implementation.
import bisect as c_bisect
class TestBisect(unittest.TestCase):
module = None
def setUp(self):
self.precomputedCases = [
(self.module.bisect_right, [], 1, 0),
(self.module.bisect_right, [1], 0, 0),
(self.module.bisect_right, [1], 1, 1),
(self.module.bisect_right, [1], 2, 1),
(self.module.bisect_right, [1, 1], 0, 0),
(self.module.bisect_right, [1, 1], 1, 2),
(self.module.bisect_right, [1, 1], 2, 2),
(self.module.bisect_right, [1, 1, 1], 0, 0),
(self.module.bisect_right, [1, 1, 1], 1, 3),
(self.module.bisect_right, [1, 1, 1], 2, 3),
(self.module.bisect_right, [1, 1, 1, 1], 0, 0),
(self.module.bisect_right, [1, 1, 1, 1], 1, 4),
(self.module.bisect_right, [1, 1, 1, 1], 2, 4),
(self.module.bisect_right, [1, 2], 0, 0),
(self.module.bisect_right, [1, 2], 1, 1),
(self.module.bisect_right, [1, 2], 1.5, 1),
(self.module.bisect_right, [1, 2], 2, 2),
(self.module.bisect_right, [1, 2], 3, 2),
(self.module.bisect_right, [1, 1, 2, 2], 0, 0),
(self.module.bisect_right, [1, 1, 2, 2], 1, 2),
(self.module.bisect_right, [1, 1, 2, 2], 1.5, 2),
(self.module.bisect_right, [1, 1, 2, 2], 2, 4),
(self.module.bisect_right, [1, 1, 2, 2], 3, 4),
(self.module.bisect_right, [1, 2, 3], 0, 0),
(self.module.bisect_right, [1, 2, 3], 1, 1),
(self.module.bisect_right, [1, 2, 3], 1.5, 1),
(self.module.bisect_right, [1, 2, 3], 2, 2),
(self.module.bisect_right, [1, 2, 3], 2.5, 2),
(self.module.bisect_right, [1, 2, 3], 3, 3),
(self.module.bisect_right, [1, 2, 3], 4, 3),
(self.module.bisect_right, [1, 2, 2, 3, 3, 3, 4, 4, 4, 4], 0, 0),
(self.module.bisect_right, [1, 2, 2, 3, 3, 3, 4, 4, 4, 4], 1, 1),
(self.module.bisect_right, [1, 2, 2, 3, 3, 3, 4, 4, 4, 4], 1.5, 1),
(self.module.bisect_right, [1, 2, 2, 3, 3, 3, 4, 4, 4, 4], 2, 3),
(self.module.bisect_right, [1, 2, 2, 3, 3, 3, 4, 4, 4, 4], 2.5, 3),
(self.module.bisect_right, [1, 2, 2, 3, 3, 3, 4, 4, 4, 4], 3, 6),
(self.module.bisect_right, [1, 2, 2, 3, 3, 3, 4, 4, 4, 4], 3.5, 6),
(self.module.bisect_right, [1, 2, 2, 3, 3, 3, 4, 4, 4, 4], 4, 10),
(self.module.bisect_right, [1, 2, 2, 3, 3, 3, 4, 4, 4, 4], 5, 10),
(self.module.bisect_left, [], 1, 0),
(self.module.bisect_left, [1], 0, 0),
(self.module.bisect_left, [1], 1, 0),
(self.module.bisect_left, [1], 2, 1),
(self.module.bisect_left, [1, 1], 0, 0),
(self.module.bisect_left, [1, 1], 1, 0),
(self.module.bisect_left, [1, 1], 2, 2),
(self.module.bisect_left, [1, 1, 1], 0, 0),
(self.module.bisect_left, [1, 1, 1], 1, 0),
(self.module.bisect_left, [1, 1, 1], 2, 3),
(self.module.bisect_left, [1, 1, 1, 1], 0, 0),
(self.module.bisect_left, [1, 1, 1, 1], 1, 0),
(self.module.bisect_left, [1, 1, 1, 1], 2, 4),
(self.module.bisect_left, [1, 2], 0, 0),
(self.module.bisect_left, [1, 2], 1, 0),
(self.module.bisect_left, [1, 2], 1.5, 1),
(self.module.bisect_left, [1, 2], 2, 1),
(self.module.bisect_left, [1, 2], 3, 2),
(self.module.bisect_left, [1, 1, 2, 2], 0, 0),
(self.module.bisect_left, [1, 1, 2, 2], 1, 0),
(self.module.bisect_left, [1, 1, 2, 2], 1.5, 2),
(self.module.bisect_left, [1, 1, 2, 2], 2, 2),
(self.module.bisect_left, [1, 1, 2, 2], 3, 4),
(self.module.bisect_left, [1, 2, 3], 0, 0),
(self.module.bisect_left, [1, 2, 3], 1, 0),
(self.module.bisect_left, [1, 2, 3], 1.5, 1),
(self.module.bisect_left, [1, 2, 3], 2, 1),
(self.module.bisect_left, [1, 2, 3], 2.5, 2),
(self.module.bisect_left, [1, 2, 3], 3, 2),
(self.module.bisect_left, [1, 2, 3], 4, 3),
(self.module.bisect_left, [1, 2, 2, 3, 3, 3, 4, 4, 4, 4], 0, 0),
(self.module.bisect_left, [1, 2, 2, 3, 3, 3, 4, 4, 4, 4], 1, 0),
(self.module.bisect_left, [1, 2, 2, 3, 3, 3, 4, 4, 4, 4], 1.5, 1),
(self.module.bisect_left, [1, 2, 2, 3, 3, 3, 4, 4, 4, 4], 2, 1),
(self.module.bisect_left, [1, 2, 2, 3, 3, 3, 4, 4, 4, 4], 2.5, 3),
(self.module.bisect_left, [1, 2, 2, 3, 3, 3, 4, 4, 4, 4], 3, 3),
(self.module.bisect_left, [1, 2, 2, 3, 3, 3, 4, 4, 4, 4], 3.5, 6),
(self.module.bisect_left, [1, 2, 2, 3, 3, 3, 4, 4, 4, 4], 4, 6),
(self.module.bisect_left, [1, 2, 2, 3, 3, 3, 4, 4, 4, 4], 5, 10)
]
def test_precomputed(self):
for func, data, elem, expected in self.precomputedCases:
self.assertEqual(func(data, elem), expected)
self.assertEqual(func(UserList(data), elem), expected)
def test_negative_lo(self):
# Issue 3301
mod = self.module
self.assertRaises(ValueError, mod.bisect_left, [1, 2, 3], 5, -1, 3),
self.assertRaises(ValueError, mod.bisect_right, [1, 2, 3], 5, -1, 3),
self.assertRaises(ValueError, mod.insort_left, [1, 2, 3], 5, -1, 3),
self.assertRaises(ValueError, mod.insort_right, [1, 2, 3], 5, -1, 3),
def test_random(self, n=25):
from random import randrange
for i in xrange(n):
data = [randrange(0, n, 2) for j in xrange(i)]
data.sort()
elem = randrange(-1, n+1)
ip = self.module.bisect_left(data, elem)
if ip < len(data):
self.assertTrue(elem <= data[ip])
if ip > 0:
self.assertTrue(data[ip-1] < elem)
ip = self.module.bisect_right(data, elem)
if ip < len(data):
self.assertTrue(elem < data[ip])
if ip > 0:
self.assertTrue(data[ip-1] <= elem)
def test_optionalSlicing(self):
for func, data, elem, expected in self.precomputedCases:
for lo in xrange(4):
lo = min(len(data), lo)
for hi in xrange(3,8):
hi = min(len(data), hi)
ip = func(data, elem, lo, hi)
self.assertTrue(lo <= ip <= hi)
if func is self.module.bisect_left and ip < hi:
self.assertTrue(elem <= data[ip])
if func is self.module.bisect_left and ip > lo:
self.assertTrue(data[ip-1] < elem)
if func is self.module.bisect_right and ip < hi:
self.assertTrue(elem < data[ip])
if func is self.module.bisect_right and ip > lo:
self.assertTrue(data[ip-1] <= elem)
self.assertEqual(ip, max(lo, min(hi, expected)))
def test_backcompatibility(self):
self.assertEqual(self.module.bisect, self.module.bisect_right)
def test_keyword_args(self):
data = [10, 20, 30, 40, 50]
self.assertEqual(self.module.bisect_left(a=data, x=25, lo=1, hi=3), 2)
self.assertEqual(self.module.bisect_right(a=data, x=25, lo=1, hi=3), 2)
self.assertEqual(self.module.bisect(a=data, x=25, lo=1, hi=3), 2)
self.module.insort_left(a=data, x=25, lo=1, hi=3)
self.module.insort_right(a=data, x=25, lo=1, hi=3)
self.module.insort(a=data, x=25, lo=1, hi=3)
self.assertEqual(data, [10, 20, 25, 25, 25, 30, 40, 50])
class TestBisectPython(TestBisect):
module = py_bisect
class TestBisectC(TestBisect):
module = c_bisect
#==============================================================================
class TestInsort(unittest.TestCase):
module = None
def test_vsBuiltinSort(self, n=500):
from random import choice
for insorted in (list(), UserList()):
for i in xrange(n):
digit = choice("0123456789")
if digit in "02468":
f = self.module.insort_left
else:
f = self.module.insort_right
f(insorted, digit)
self.assertEqual(sorted(insorted), insorted)
def test_backcompatibility(self):
self.assertEqual(self.module.insort, self.module.insort_right)
def test_listDerived(self):
class List(list):
data = []
def insert(self, index, item):
self.data.insert(index, item)
lst = List()
self.module.insort_left(lst, 10)
self.module.insort_right(lst, 5)
self.assertEqual([5, 10], lst.data)
class TestInsortPython(TestInsort):
module = py_bisect
class TestInsortC(TestInsort):
module = c_bisect
#==============================================================================
class LenOnly:
"Dummy sequence class defining __len__ but not __getitem__."
def __len__(self):
return 10
class GetOnly:
"Dummy sequence class defining __getitem__ but not __len__."
def __getitem__(self, ndx):
return 10
class CmpErr:
"Dummy element that always raises an error during comparison"
def __cmp__(self, other):
raise ZeroDivisionError
class TestErrorHandling(unittest.TestCase):
module = None
def test_non_sequence(self):
for f in (self.module.bisect_left, self.module.bisect_right,
self.module.insort_left, self.module.insort_right):
self.assertRaises(TypeError, f, 10, 10)
def test_len_only(self):
for f in (self.module.bisect_left, self.module.bisect_right,
self.module.insort_left, self.module.insort_right):
self.assertRaises(AttributeError, f, LenOnly(), 10)
def test_get_only(self):
for f in (self.module.bisect_left, self.module.bisect_right,
self.module.insort_left, self.module.insort_right):
self.assertRaises(AttributeError, f, GetOnly(), 10)
def test_cmp_err(self):
seq = [CmpErr(), CmpErr(), CmpErr()]
for f in (self.module.bisect_left, self.module.bisect_right,
self.module.insort_left, self.module.insort_right):
self.assertRaises(ZeroDivisionError, f, seq, 10)
def test_arg_parsing(self):
for f in (self.module.bisect_left, self.module.bisect_right,
self.module.insort_left, self.module.insort_right):
self.assertRaises(TypeError, f, 10)
class TestErrorHandlingPython(TestErrorHandling):
module = py_bisect
class TestErrorHandlingC(TestErrorHandling):
module = c_bisect
#==============================================================================
libreftest = """
Example from the Library Reference: Doc/library/bisect.rst
The bisect() function is generally useful for categorizing numeric data.
This example uses bisect() to look up a letter grade for an exam total
(say) based on a set of ordered numeric breakpoints: 85 and up is an `A',
75..84 is a `B', etc.
>>> grades = "FEDCBA"
>>> breakpoints = [30, 44, 66, 75, 85]
>>> from bisect import bisect
>>> def grade(total):
... return grades[bisect(breakpoints, total)]
...
>>> grade(66)
'C'
>>> map(grade, [33, 99, 77, 44, 12, 88])
['E', 'A', 'B', 'D', 'F', 'A']
"""
#------------------------------------------------------------------------------
__test__ = {'libreftest' : libreftest}
def test_main(verbose=None):
from test import test_bisect
test_classes = [TestBisectPython, TestBisectC,
TestInsortPython, TestInsortC,
TestErrorHandlingPython, TestErrorHandlingC]
test_support.run_unittest(*test_classes)
test_support.run_doctest(test_bisect, verbose)
# verify reference counting
if verbose and hasattr(sys, "gettotalrefcount"):
import gc
counts = [None] * 5
for i in xrange(len(counts)):
test_support.run_unittest(*test_classes)
gc.collect()
counts[i] = sys.gettotalrefcount()
print counts
if __name__ == "__main__":
test_main(verbose=True)
|
mit
|
[
646,
984,
199,
646,
2882,
199,
504,
511,
492,
511,
63,
4058,
199,
504,
28639,
492,
28639,
199,
199,
3,
2136,
886,
282,
4546,
402,
20907,
994,
2348,
370,
506,
7688,
370,
511,
3865,
314,
445,
4514,
199,
3,
436,
314,
2018,
4514,
402,
314,
859,
14,
199,
199,
3,
4155,
652,
26847,
370,
492,
314,
445,
4514,
20827,
14,
199,
1274,
14,
3112,
8680,
23247,
418,
275,
378,
199,
3,
2136,
1471,
2597,
2429,
314,
1930,
626,
19063,
1990,
8439,
2544,
14,
199,
692,
283,
23247,
7,
315,
984,
14,
3112,
26,
272,
2150,
984,
14,
3112,
459,
23247,
418,
199,
199,
3,
7356,
781,
883,
492,
314,
859,
436,
664,
314,
15111,
2018,
4514,
14,
199,
646,
19063,
465,
1134,
63,
23247,
199,
199,
3,
22379,
8137,
370,
3293,
14,
199,
2264,
984,
14,
3112,
8680,
23247,
418,
199,
2264,
984,
14,
3112,
459,
23247,
418,
199,
199,
3,
961,
365,
3063,
314,
859,
543,
314,
445,
4514,
14,
199,
646,
19063,
465,
286,
63,
23247,
421,
199,
533,
1379,
34,
13133,
8,
2796,
14,
1746,
304,
272,
859,
275,
488,
339,
347,
3613,
8,
277,
304,
267,
291,
14,
26596,
1538,
83,
275,
359,
288,
334,
277,
14,
578,
14,
23247,
63,
1019,
12,
990,
413,
12,
378,
395,
288,
334,
277,
14,
578,
14,
23247,
63,
1019,
12,
359,
17,
467,
378,
12,
378,
395,
288,
334,
277,
14,
578,
14,
23247,
63,
1019,
12,
359,
17,
467,
413,
12,
413,
395,
288,
334,
277,
14,
578,
14,
23247,
63,
1019,
12,
359,
17,
467,
499,
12,
413,
395,
288,
334,
277,
14,
578,
14,
23247,
63,
1019,
12,
359,
17,
12,
413,
467,
378,
12,
378,
395,
288,
334,
277,
14,
578,
14,
23247,
63,
1019,
12,
359,
17,
12,
413,
467,
413,
12,
499,
395,
288,
334,
277,
14,
578,
14,
23247,
63,
1019,
12,
359,
17,
12,
413,
467,
499,
12,
499,
395,
288,
334,
277,
14,
578,
14,
23247,
63,
1019,
12,
359,
17,
12,
413,
12,
413,
467,
378,
12,
378,
395,
288,
334,
277,
14,
578,
14,
23247,
63,
1019,
12,
359,
17,
12,
413,
12,
413,
467,
413,
12,
650,
395,
288,
334,
277,
14,
578,
14,
23247,
63,
1019,
12,
359,
17,
12,
413,
12,
413,
467,
499,
12,
650,
395,
288,
334,
277,
14,
578,
14,
23247,
63,
1019,
12,
359,
17,
12,
413,
12,
413,
12,
413,
467,
378,
12,
378,
395,
288,
334,
277,
14,
578,
14,
23247,
63,
1019,
12,
359,
17,
12,
413,
12,
413,
12,
413,
467,
413,
12,
841,
395,
288,
334,
277,
14,
578,
14,
23247,
63,
1019,
12,
359,
17,
12,
413,
12,
413,
12,
413,
467,
499,
12,
841,
395,
288,
334,
277,
14,
578,
14,
23247,
63,
1019,
12,
359,
17,
12,
499,
467,
378,
12,
378,
395,
288,
334,
277,
14,
578,
14,
23247,
63,
1019,
12,
359,
17,
12,
499,
467,
413,
12,
413,
395,
288,
334,
277,
14,
578,
14,
23247,
63,
1019,
12,
359,
17,
12,
499,
467,
413,
14,
21,
12,
413,
395,
288,
334,
277,
14,
578,
14,
23247,
63,
1019,
12,
359,
17,
12,
499,
467,
499,
12,
499,
395,
288,
334,
277,
14,
578,
14,
23247,
63,
1019,
12,
359,
17,
12,
499,
467,
650,
12,
499,
395,
288,
334,
277,
14,
578,
14,
23247,
63,
1019,
12,
359,
17,
12,
413,
12,
499,
12,
499,
467,
378,
12,
378,
395,
288,
334,
277,
14,
578,
14,
23247,
63,
1019,
12,
359,
17,
12,
413,
12,
499,
12,
499,
467,
413,
12,
499,
395,
288,
334,
277,
14,
578,
14,
23247,
63,
1019,
12,
359,
17,
12,
413,
12,
499,
12,
499,
467,
413,
14,
21,
12,
499,
395,
288,
334,
277,
14,
578,
14,
23247,
63,
1019,
12,
359,
17,
12,
413,
12,
499,
12,
499,
467,
499,
12,
841,
395,
288,
334,
277,
14,
578,
14,
23247,
63,
1019,
12,
359,
17,
12,
413,
12,
499,
12,
499,
467,
650,
12,
841,
395,
288,
334,
277,
14,
578,
14,
23247,
63,
1019,
12,
359,
17,
12,
499,
12,
650,
467,
378,
12,
378,
395,
288,
334,
277,
14,
578,
14,
23247,
63,
1019,
12,
359,
17,
12,
499,
12,
650,
467,
413,
12,
413,
395,
288,
334,
277,
14,
578,
14,
23247,
63,
1019,
12,
359,
17,
12,
499,
12,
650,
467,
413,
14,
21,
12,
413,
395,
288,
334,
277,
14,
578,
14,
23247,
63,
1019,
12,
359,
17,
12,
499,
12,
650,
467,
499,
12,
499,
395,
288,
334,
277,
14,
578,
14,
23247,
63,
1019,
12,
359,
17,
12,
499,
12,
650,
467,
499,
14,
21,
12,
499,
395,
288,
334,
277,
14,
578,
14,
23247,
63,
1019,
12,
359,
17,
12,
499,
12,
650,
467,
650,
12,
650,
395,
288,
334,
277,
14,
578,
14,
23247,
63,
1019,
12,
359,
17,
12,
499,
12,
650,
467,
841,
12,
650,
395,
288,
334,
277,
14,
578,
14,
23247,
63,
1019,
12,
359,
17,
12,
499,
12,
499,
12,
650,
12,
650,
12,
650,
12,
841,
12,
841,
12,
841,
12,
841,
467,
378,
12,
378,
395,
288,
334,
277,
14,
578,
14,
23247,
63,
1019,
12,
359,
17,
12,
499,
12,
499,
12,
650,
12,
650,
12,
650,
12,
841,
12,
841,
12,
841,
12,
841,
467,
413,
12,
413,
395,
288,
334,
277,
14,
578,
14,
23247,
63,
1019,
12,
359,
17,
12,
499,
12,
499,
12,
650,
12,
650,
12,
650,
12,
841,
12,
841,
12,
841,
12,
841,
467,
413,
14,
21,
12,
413,
395,
288,
334,
277,
14,
578,
14,
23247,
63,
1019,
12,
359,
17,
12,
499,
12,
499,
12,
650,
12,
650,
12,
650,
12,
841,
12,
841,
12,
841,
12,
841,
467,
499,
12,
650,
395,
288,
334,
277,
14,
578,
14,
23247,
63,
1019,
12,
359,
17,
12,
499,
12,
499,
12,
650,
12,
650,
12,
650,
12,
841,
12,
841,
12,
841,
12,
841,
467,
499,
14,
21,
12,
650,
395,
288,
334,
277,
14,
578,
14,
23247,
63,
1019,
12,
359,
17,
12,
499,
12,
499,
12,
650,
12,
650,
12,
650,
12,
841,
12,
841,
12,
841
] |
[
984,
199,
646,
2882,
199,
504,
511,
492,
511,
63,
4058,
199,
504,
28639,
492,
28639,
199,
199,
3,
2136,
886,
282,
4546,
402,
20907,
994,
2348,
370,
506,
7688,
370,
511,
3865,
314,
445,
4514,
199,
3,
436,
314,
2018,
4514,
402,
314,
859,
14,
199,
199,
3,
4155,
652,
26847,
370,
492,
314,
445,
4514,
20827,
14,
199,
1274,
14,
3112,
8680,
23247,
418,
275,
378,
199,
3,
2136,
1471,
2597,
2429,
314,
1930,
626,
19063,
1990,
8439,
2544,
14,
199,
692,
283,
23247,
7,
315,
984,
14,
3112,
26,
272,
2150,
984,
14,
3112,
459,
23247,
418,
199,
199,
3,
7356,
781,
883,
492,
314,
859,
436,
664,
314,
15111,
2018,
4514,
14,
199,
646,
19063,
465,
1134,
63,
23247,
199,
199,
3,
22379,
8137,
370,
3293,
14,
199,
2264,
984,
14,
3112,
8680,
23247,
418,
199,
2264,
984,
14,
3112,
459,
23247,
418,
199,
199,
3,
961,
365,
3063,
314,
859,
543,
314,
445,
4514,
14,
199,
646,
19063,
465,
286,
63,
23247,
421,
199,
533,
1379,
34,
13133,
8,
2796,
14,
1746,
304,
272,
859,
275,
488,
339,
347,
3613,
8,
277,
304,
267,
291,
14,
26596,
1538,
83,
275,
359,
288,
334,
277,
14,
578,
14,
23247,
63,
1019,
12,
990,
413,
12,
378,
395,
288,
334,
277,
14,
578,
14,
23247,
63,
1019,
12,
359,
17,
467,
378,
12,
378,
395,
288,
334,
277,
14,
578,
14,
23247,
63,
1019,
12,
359,
17,
467,
413,
12,
413,
395,
288,
334,
277,
14,
578,
14,
23247,
63,
1019,
12,
359,
17,
467,
499,
12,
413,
395,
288,
334,
277,
14,
578,
14,
23247,
63,
1019,
12,
359,
17,
12,
413,
467,
378,
12,
378,
395,
288,
334,
277,
14,
578,
14,
23247,
63,
1019,
12,
359,
17,
12,
413,
467,
413,
12,
499,
395,
288,
334,
277,
14,
578,
14,
23247,
63,
1019,
12,
359,
17,
12,
413,
467,
499,
12,
499,
395,
288,
334,
277,
14,
578,
14,
23247,
63,
1019,
12,
359,
17,
12,
413,
12,
413,
467,
378,
12,
378,
395,
288,
334,
277,
14,
578,
14,
23247,
63,
1019,
12,
359,
17,
12,
413,
12,
413,
467,
413,
12,
650,
395,
288,
334,
277,
14,
578,
14,
23247,
63,
1019,
12,
359,
17,
12,
413,
12,
413,
467,
499,
12,
650,
395,
288,
334,
277,
14,
578,
14,
23247,
63,
1019,
12,
359,
17,
12,
413,
12,
413,
12,
413,
467,
378,
12,
378,
395,
288,
334,
277,
14,
578,
14,
23247,
63,
1019,
12,
359,
17,
12,
413,
12,
413,
12,
413,
467,
413,
12,
841,
395,
288,
334,
277,
14,
578,
14,
23247,
63,
1019,
12,
359,
17,
12,
413,
12,
413,
12,
413,
467,
499,
12,
841,
395,
288,
334,
277,
14,
578,
14,
23247,
63,
1019,
12,
359,
17,
12,
499,
467,
378,
12,
378,
395,
288,
334,
277,
14,
578,
14,
23247,
63,
1019,
12,
359,
17,
12,
499,
467,
413,
12,
413,
395,
288,
334,
277,
14,
578,
14,
23247,
63,
1019,
12,
359,
17,
12,
499,
467,
413,
14,
21,
12,
413,
395,
288,
334,
277,
14,
578,
14,
23247,
63,
1019,
12,
359,
17,
12,
499,
467,
499,
12,
499,
395,
288,
334,
277,
14,
578,
14,
23247,
63,
1019,
12,
359,
17,
12,
499,
467,
650,
12,
499,
395,
288,
334,
277,
14,
578,
14,
23247,
63,
1019,
12,
359,
17,
12,
413,
12,
499,
12,
499,
467,
378,
12,
378,
395,
288,
334,
277,
14,
578,
14,
23247,
63,
1019,
12,
359,
17,
12,
413,
12,
499,
12,
499,
467,
413,
12,
499,
395,
288,
334,
277,
14,
578,
14,
23247,
63,
1019,
12,
359,
17,
12,
413,
12,
499,
12,
499,
467,
413,
14,
21,
12,
499,
395,
288,
334,
277,
14,
578,
14,
23247,
63,
1019,
12,
359,
17,
12,
413,
12,
499,
12,
499,
467,
499,
12,
841,
395,
288,
334,
277,
14,
578,
14,
23247,
63,
1019,
12,
359,
17,
12,
413,
12,
499,
12,
499,
467,
650,
12,
841,
395,
288,
334,
277,
14,
578,
14,
23247,
63,
1019,
12,
359,
17,
12,
499,
12,
650,
467,
378,
12,
378,
395,
288,
334,
277,
14,
578,
14,
23247,
63,
1019,
12,
359,
17,
12,
499,
12,
650,
467,
413,
12,
413,
395,
288,
334,
277,
14,
578,
14,
23247,
63,
1019,
12,
359,
17,
12,
499,
12,
650,
467,
413,
14,
21,
12,
413,
395,
288,
334,
277,
14,
578,
14,
23247,
63,
1019,
12,
359,
17,
12,
499,
12,
650,
467,
499,
12,
499,
395,
288,
334,
277,
14,
578,
14,
23247,
63,
1019,
12,
359,
17,
12,
499,
12,
650,
467,
499,
14,
21,
12,
499,
395,
288,
334,
277,
14,
578,
14,
23247,
63,
1019,
12,
359,
17,
12,
499,
12,
650,
467,
650,
12,
650,
395,
288,
334,
277,
14,
578,
14,
23247,
63,
1019,
12,
359,
17,
12,
499,
12,
650,
467,
841,
12,
650,
395,
288,
334,
277,
14,
578,
14,
23247,
63,
1019,
12,
359,
17,
12,
499,
12,
499,
12,
650,
12,
650,
12,
650,
12,
841,
12,
841,
12,
841,
12,
841,
467,
378,
12,
378,
395,
288,
334,
277,
14,
578,
14,
23247,
63,
1019,
12,
359,
17,
12,
499,
12,
499,
12,
650,
12,
650,
12,
650,
12,
841,
12,
841,
12,
841,
12,
841,
467,
413,
12,
413,
395,
288,
334,
277,
14,
578,
14,
23247,
63,
1019,
12,
359,
17,
12,
499,
12,
499,
12,
650,
12,
650,
12,
650,
12,
841,
12,
841,
12,
841,
12,
841,
467,
413,
14,
21,
12,
413,
395,
288,
334,
277,
14,
578,
14,
23247,
63,
1019,
12,
359,
17,
12,
499,
12,
499,
12,
650,
12,
650,
12,
650,
12,
841,
12,
841,
12,
841,
12,
841,
467,
499,
12,
650,
395,
288,
334,
277,
14,
578,
14,
23247,
63,
1019,
12,
359,
17,
12,
499,
12,
499,
12,
650,
12,
650,
12,
650,
12,
841,
12,
841,
12,
841,
12,
841,
467,
499,
14,
21,
12,
650,
395,
288,
334,
277,
14,
578,
14,
23247,
63,
1019,
12,
359,
17,
12,
499,
12,
499,
12,
650,
12,
650,
12,
650,
12,
841,
12,
841,
12,
841,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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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
] |
sauloal/PiCastPy
|
sqlalchemy/dialects/sybase/pysybase.py
|
18
|
3228
|
# sybase/pysybase.py
# Copyright (C) 2010-2013 the SQLAlchemy authors and contributors <see AUTHORS file>
#
# This module is part of SQLAlchemy and is released under
# the MIT License: http://www.opensource.org/licenses/mit-license.php
"""
.. dialect:: sybase+pysybase
:name: Python-Sybase
:dbapi: Sybase
:connectstring: sybase+pysybase://<username>:<password>@<dsn>/[database name]
:url: http://python-sybase.sourceforge.net/
Unicode Support
---------------
The python-sybase driver does not appear to support non-ASCII strings of any
kind at this time.
"""
from sqlalchemy import types as sqltypes, processors
from sqlalchemy.dialects.sybase.base import SybaseDialect, \
SybaseExecutionContext, SybaseSQLCompiler
class _SybNumeric(sqltypes.Numeric):
def result_processor(self, dialect, type_):
if not self.asdecimal:
return processors.to_float
else:
return sqltypes.Numeric.result_processor(self, dialect, type_)
class SybaseExecutionContext_pysybase(SybaseExecutionContext):
def set_ddl_autocommit(self, dbapi_connection, value):
if value:
# call commit() on the Sybase connection directly,
# to avoid any side effects of calling a Connection
# transactional method inside of pre_exec()
dbapi_connection.commit()
def pre_exec(self):
SybaseExecutionContext.pre_exec(self)
for param in self.parameters:
for key in list(param):
param["@" + key] = param[key]
del param[key]
class SybaseSQLCompiler_pysybase(SybaseSQLCompiler):
def bindparam_string(self, name, **kw):
return "@" + name
class SybaseDialect_pysybase(SybaseDialect):
driver = 'pysybase'
execution_ctx_cls = SybaseExecutionContext_pysybase
statement_compiler = SybaseSQLCompiler_pysybase
colspecs = {
sqltypes.Numeric: _SybNumeric,
sqltypes.Float: sqltypes.Float
}
@classmethod
def dbapi(cls):
import Sybase
return Sybase
def create_connect_args(self, url):
opts = url.translate_connect_args(username='user', password='passwd')
return ([opts.pop('host')], opts)
def do_executemany(self, cursor, statement, parameters, context=None):
# calling python-sybase executemany yields:
# TypeError: string too long for buffer
for param in parameters:
cursor.execute(statement, param)
def _get_server_version_info(self, connection):
vers = connection.scalar("select @@version_number")
# i.e. 15500, 15000, 12500 == (15, 5, 0, 0), (15, 0, 0, 0),
# (12, 5, 0, 0)
return (vers / 1000, vers % 1000 / 100, vers % 100 / 10, vers % 10)
def is_disconnect(self, e, connection, cursor):
if isinstance(e, (self.dbapi.OperationalError,
self.dbapi.ProgrammingError)):
msg = str(e)
return ('Unable to complete network request to host' in msg or
'Invalid connection state' in msg or
'Invalid cursor state' in msg)
else:
return False
dialect = SybaseDialect_pysybase
|
mit
|
[
3,
1847,
1095,
15,
15983,
89,
1095,
14,
647,
199,
3,
1898,
334,
35,
9,
7129,
13,
6965,
314,
14303,
11462,
436,
8417,
665,
3239,
10610,
570,
30,
199,
3,
199,
3,
961,
859,
365,
1777,
402,
14303,
436,
365,
14286,
1334,
199,
3,
314,
10697,
844,
26,
1455,
921,
1544,
14,
16374,
14,
1308,
15,
2383,
15,
1147,
13,
1682,
14,
8624,
199,
199,
624,
199,
703,
10982,
447,
1847,
1095,
11,
15983,
89,
1095,
272,
520,
354,
26,
2018,
13,
4323,
1095,
272,
520,
22103,
26,
5515,
1095,
272,
520,
2242,
875,
26,
1847,
1095,
11,
15983,
89,
1095,
921,
28,
2473,
30,
16875,
2060,
30,
32,
28,
32510,
12202,
59,
4659,
536,
61,
272,
520,
633,
26,
1455,
921,
1548,
13,
1786,
1095,
14,
22943,
14,
846,
15,
199,
199,
7087,
12502,
199,
18964,
199,
199,
1918,
2366,
13,
1786,
1095,
5253,
1630,
440,
7468,
370,
2291,
2222,
13,
12292,
3326,
402,
1263,
199,
5091,
737,
642,
900,
14,
199,
199,
624,
199,
199,
504,
8335,
492,
2943,
465,
23111,
12,
21620,
199,
504,
8335,
14,
11072,
83,
14,
1786,
1095,
14,
1095,
492,
5515,
1095,
22080,
12,
971,
1169,
5515,
1095,
11310,
2998,
12,
5515,
1095,
4657,
9131,
421,
199,
533,
485,
4323,
66,
14687,
8,
3009,
1313,
14,
14687,
304,
272,
347,
754,
63,
6459,
8,
277,
12,
10982,
12,
730,
7822,
267,
340,
440,
291,
14,
305,
6355,
26,
288,
372,
21620,
14,
475,
63,
1609,
267,
587,
26,
288,
372,
23111,
14,
14687,
14,
1099,
63,
6459,
8,
277,
12,
10982,
12,
730,
4602,
421,
199,
533,
5515,
1095,
11310,
2998,
63,
15983,
89,
1095,
8,
4323,
1095,
11310,
2998,
304,
339,
347,
663,
63,
17102,
63,
17881,
8,
277,
12,
29333,
63,
2105,
12,
574,
304,
267,
340,
574,
26,
288,
327,
1240,
5532,
342,
641,
314,
5515,
1095,
1950,
5370,
12,
288,
327,
370,
5126,
1263,
5366,
22414,
402,
6358,
282,
8113,
288,
327,
6008,
279,
1083,
6272,
402,
876,
63,
1628,
342,
288,
29333,
63,
2105,
14,
3543,
342,
339,
347,
876,
63,
1628,
8,
277,
304,
267,
5515,
1095,
11310,
2998,
14,
657,
63,
1628,
8,
277,
9,
398,
367,
1215,
315,
291,
14,
3214,
26,
288,
367,
790,
315,
769,
8,
635,
304,
355,
1215,
905,
32,
2,
435,
790,
61,
275,
1215,
59,
498,
61,
355,
2150,
1215,
59,
498,
61,
421,
199,
533,
5515,
1095,
4657,
9131,
63,
15983,
89,
1095,
8,
4323,
1095,
4657,
9131,
304,
272,
347,
5398,
635,
63,
875,
8,
277,
12,
536,
12,
1011,
829,
304,
267,
372,
9244,
2,
435,
536,
421,
199,
533,
5515,
1095,
22080,
63,
15983,
89,
1095,
8,
4323,
1095,
22080,
304,
272,
5253,
275,
283,
15983,
89,
1095,
7,
272,
6451,
63,
3799,
63,
1886,
275,
5515,
1095,
11310,
2998,
63,
15983,
89,
1095,
272,
5164,
63,
5772,
275,
5515,
1095,
4657,
9131,
63,
15983,
89,
1095,
339,
1048,
7273,
275,
469,
2126,
23111,
14,
14687,
26,
485,
4323,
66,
14687,
12,
2126,
23111,
14,
5136,
26,
23111,
14,
5136,
272,
789,
339,
768,
3744,
272,
347,
29333,
8,
1886,
304,
267,
492,
5515,
1095,
267,
372,
5515,
1095,
339,
347,
1218,
63,
2242,
63,
589,
8,
277,
12,
1166,
304,
267,
3999,
275,
1166,
14,
5275,
63,
2242,
63,
589,
8,
2473,
534,
751,
297,
2505,
534,
12671,
358,
398,
372,
7287,
3291,
14,
1935,
360,
1102,
2665,
3999,
9,
339,
347,
886,
63,
31162,
8,
277,
12,
3920,
12,
5164,
12,
2633,
12,
1067,
29,
403,
304,
267,
327,
6358,
2366,
13,
1786,
1095,
2146,
25450,
14801,
26,
267,
327,
3146,
26,
1059,
4634,
1846,
367,
3335,
267,
367,
1215,
315,
2633,
26,
288,
3920,
14,
2526,
8,
6242,
12,
1215,
9,
339,
347,
485,
362,
63,
1000,
63,
1023,
63,
815,
8,
277,
12,
1950,
304,
267,
809,
83,
275,
1950,
14,
7033,
480,
2416,
13365,
1023,
63,
1955,
531,
267,
327,
284,
14,
69,
14,
29710,
383,
12,
4114,
1493,
12,
19163,
383,
508,
334,
1046,
12,
959,
12,
378,
12,
378,
395,
334,
1046,
12,
378,
12,
378,
12,
378,
395,
267,
327,
334,
713,
12,
959,
12,
378,
12,
378,
9,
267,
372,
334,
14895,
1182,
5198,
12,
809,
83,
450,
5198,
1182,
2948,
12,
809,
83,
450,
2948,
1182,
1616,
12,
809,
83,
450,
1616,
9,
339,
347,
365,
63,
10673,
8,
277,
12,
325,
12,
1950,
12,
3920,
304,
267,
340,
1228,
8,
69,
12,
334,
277,
14,
22103,
14,
31998,
547,
12,
1169,
291,
14,
22103,
14,
11411,
547,
2298,
288,
1499,
275,
620,
8,
69,
9,
288,
372,
661,
6005,
370,
4890,
2784,
1056,
370,
1591,
7,
315,
1499,
503,
490,
283,
3364,
1950,
1174,
7,
315,
1499,
503,
490,
283,
3364,
3920,
1174,
7,
315,
1499,
9,
267,
587,
26,
288,
372,
756,
199,
199,
11072,
275,
5515,
1095,
22080,
63,
15983,
89,
1095,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
1847,
1095,
15,
15983,
89,
1095,
14,
647,
199,
3,
1898,
334,
35,
9,
7129,
13,
6965,
314,
14303,
11462,
436,
8417,
665,
3239,
10610,
570,
30,
199,
3,
199,
3,
961,
859,
365,
1777,
402,
14303,
436,
365,
14286,
1334,
199,
3,
314,
10697,
844,
26,
1455,
921,
1544,
14,
16374,
14,
1308,
15,
2383,
15,
1147,
13,
1682,
14,
8624,
199,
199,
624,
199,
703,
10982,
447,
1847,
1095,
11,
15983,
89,
1095,
272,
520,
354,
26,
2018,
13,
4323,
1095,
272,
520,
22103,
26,
5515,
1095,
272,
520,
2242,
875,
26,
1847,
1095,
11,
15983,
89,
1095,
921,
28,
2473,
30,
16875,
2060,
30,
32,
28,
32510,
12202,
59,
4659,
536,
61,
272,
520,
633,
26,
1455,
921,
1548,
13,
1786,
1095,
14,
22943,
14,
846,
15,
199,
199,
7087,
12502,
199,
18964,
199,
199,
1918,
2366,
13,
1786,
1095,
5253,
1630,
440,
7468,
370,
2291,
2222,
13,
12292,
3326,
402,
1263,
199,
5091,
737,
642,
900,
14,
199,
199,
624,
199,
199,
504,
8335,
492,
2943,
465,
23111,
12,
21620,
199,
504,
8335,
14,
11072,
83,
14,
1786,
1095,
14,
1095,
492,
5515,
1095,
22080,
12,
971,
1169,
5515,
1095,
11310,
2998,
12,
5515,
1095,
4657,
9131,
421,
199,
533,
485,
4323,
66,
14687,
8,
3009,
1313,
14,
14687,
304,
272,
347,
754,
63,
6459,
8,
277,
12,
10982,
12,
730,
7822,
267,
340,
440,
291,
14,
305,
6355,
26,
288,
372,
21620,
14,
475,
63,
1609,
267,
587,
26,
288,
372,
23111,
14,
14687,
14,
1099,
63,
6459,
8,
277,
12,
10982,
12,
730,
4602,
421,
199,
533,
5515,
1095,
11310,
2998,
63,
15983,
89,
1095,
8,
4323,
1095,
11310,
2998,
304,
339,
347,
663,
63,
17102,
63,
17881,
8,
277,
12,
29333,
63,
2105,
12,
574,
304,
267,
340,
574,
26,
288,
327,
1240,
5532,
342,
641,
314,
5515,
1095,
1950,
5370,
12,
288,
327,
370,
5126,
1263,
5366,
22414,
402,
6358,
282,
8113,
288,
327,
6008,
279,
1083,
6272,
402,
876,
63,
1628,
342,
288,
29333,
63,
2105,
14,
3543,
342,
339,
347,
876,
63,
1628,
8,
277,
304,
267,
5515,
1095,
11310,
2998,
14,
657,
63,
1628,
8,
277,
9,
398,
367,
1215,
315,
291,
14,
3214,
26,
288,
367,
790,
315,
769,
8,
635,
304,
355,
1215,
905,
32,
2,
435,
790,
61,
275,
1215,
59,
498,
61,
355,
2150,
1215,
59,
498,
61,
421,
199,
533,
5515,
1095,
4657,
9131,
63,
15983,
89,
1095,
8,
4323,
1095,
4657,
9131,
304,
272,
347,
5398,
635,
63,
875,
8,
277,
12,
536,
12,
1011,
829,
304,
267,
372,
9244,
2,
435,
536,
421,
199,
533,
5515,
1095,
22080,
63,
15983,
89,
1095,
8,
4323,
1095,
22080,
304,
272,
5253,
275,
283,
15983,
89,
1095,
7,
272,
6451,
63,
3799,
63,
1886,
275,
5515,
1095,
11310,
2998,
63,
15983,
89,
1095,
272,
5164,
63,
5772,
275,
5515,
1095,
4657,
9131,
63,
15983,
89,
1095,
339,
1048,
7273,
275,
469,
2126,
23111,
14,
14687,
26,
485,
4323,
66,
14687,
12,
2126,
23111,
14,
5136,
26,
23111,
14,
5136,
272,
789,
339,
768,
3744,
272,
347,
29333,
8,
1886,
304,
267,
492,
5515,
1095,
267,
372,
5515,
1095,
339,
347,
1218,
63,
2242,
63,
589,
8,
277,
12,
1166,
304,
267,
3999,
275,
1166,
14,
5275,
63,
2242,
63,
589,
8,
2473,
534,
751,
297,
2505,
534,
12671,
358,
398,
372,
7287,
3291,
14,
1935,
360,
1102,
2665,
3999,
9,
339,
347,
886,
63,
31162,
8,
277,
12,
3920,
12,
5164,
12,
2633,
12,
1067,
29,
403,
304,
267,
327,
6358,
2366,
13,
1786,
1095,
2146,
25450,
14801,
26,
267,
327,
3146,
26,
1059,
4634,
1846,
367,
3335,
267,
367,
1215,
315,
2633,
26,
288,
3920,
14,
2526,
8,
6242,
12,
1215,
9,
339,
347,
485,
362,
63,
1000,
63,
1023,
63,
815,
8,
277,
12,
1950,
304,
267,
809,
83,
275,
1950,
14,
7033,
480,
2416,
13365,
1023,
63,
1955,
531,
267,
327,
284,
14,
69,
14,
29710,
383,
12,
4114,
1493,
12,
19163,
383,
508,
334,
1046,
12,
959,
12,
378,
12,
378,
395,
334,
1046,
12,
378,
12,
378,
12,
378,
395,
267,
327,
334,
713,
12,
959,
12,
378,
12,
378,
9,
267,
372,
334,
14895,
1182,
5198,
12,
809,
83,
450,
5198,
1182,
2948,
12,
809,
83,
450,
2948,
1182,
1616,
12,
809,
83,
450,
1616,
9,
339,
347,
365,
63,
10673,
8,
277,
12,
325,
12,
1950,
12,
3920,
304,
267,
340,
1228,
8,
69,
12,
334,
277,
14,
22103,
14,
31998,
547,
12,
1169,
291,
14,
22103,
14,
11411,
547,
2298,
288,
1499,
275,
620,
8,
69,
9,
288,
372,
661,
6005,
370,
4890,
2784,
1056,
370,
1591,
7,
315,
1499,
503,
490,
283,
3364,
1950,
1174,
7,
315,
1499,
503,
490,
283,
3364,
3920,
1174,
7,
315,
1499,
9,
267,
587,
26,
288,
372,
756,
199,
199,
11072,
275,
5515,
1095,
22080,
63,
15983,
89,
1095,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,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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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
FrankNagel/qlc
|
src/webapp/quanthistling/scripts/annotations/annotations_for_shell1987.py
|
1
|
7100
|
# -*- coding: utf8 -*-
import sys, os
sys.path.append(os.path.abspath('.'))
import re
from operator import attrgetter
import difflib
# Pylons model init sequence
import pylons.test
import logging
from quanthistling.config.environment import load_environment
from quanthistling.model.meta import Session, metadata
from quanthistling import model
import quanthistling.dictdata.books
from paste.deploy import appconfig
import functions
def annotate_crossrefs(entry):
# delete head annotations
crossreference_annotations = [ a for a in entry.annotations if a.value=='crossreference']
for a in crossreference_annotations:
Session.delete(a)
crossreference_match = re.search(u"Vea ([^.]*)(?:\.|$)", entry.fullentry)
if crossreference_match:
entry.append_annotation(crossreference_match.start(1), crossreference_match.end(1), u'crossreference', u'dictinterpretation')
def annotate_head(entry):
# delete head annotations
head_annotations = [ a for a in entry.annotations if a.value=='head' or a.value=="iso-639-3" or a.value=="doculect"]
for a in head_annotations:
Session.delete(a)
heads = []
head_end_pos = functions.get_last_bold_pos_at_start(entry)
head_start_pos = 0
substr = entry.fullentry[head_start_pos:head_end_pos]
start = head_start_pos
for match in re.finditer(r'(?:, ?|$)', substr):
end = match.start(0)
inserted_head = functions.insert_head(entry, start, end)
heads.append(inserted_head)
start = match.end(0)
return heads
def annotate_pos(entry):
# delete pos annotations
pos_annotations = [ a for a in entry.annotations if a.value=='pos']
for a in pos_annotations:
Session.delete(a)
head_end_pos = functions.get_last_bold_pos_at_start(entry)
re_bracket = re.compile(u"\(.*?\)")
match_bracket = re_bracket.search(entry.fullentry, head_end_pos)
if match_bracket and match_bracket.start(0) < (head_end_pos + 2):
entry.append_annotation(match_bracket.start(0)+1, match_bracket.end(0)-1, u'pos', u'dictinterpretation')
def annotate_translations(entry):
# delete pos annotations
trans_annotations = [ a for a in entry.annotations if a.value=='translation']
for a in trans_annotations:
Session.delete(a)
translations_start = functions.get_pos_or_head_end(entry) + 1
translations_end = len(entry.fullentry)
if re.match(u"\.? ?Vea ", entry.fullentry[translations_start:]):
return
first_bold_after_pos = functions.get_first_bold_start_in_range(entry, translations_start, translations_end)
if first_bold_after_pos != -1:
translations_end = first_bold_after_pos
start = translations_start
for match in re.finditer(u"(?:[,;] ?|$)", entry.fullentry[translations_start:translations_end]):
mybreak = False
# are we in a bracket?
for m in re.finditer(r'\(.*?\)', entry.fullentry[translations_start:translations_end]):
if match.start(0) >= m.start(0) and match.end(0) <= m.end(0):
mybreak = True
if not mybreak:
end = match.start(0) + translations_start
subsubstr = entry.fullentry[start:end]
if not(re.match(r"\s*$", subsubstr)):
functions.insert_translation(entry, start, end)
start = match.end(0) + translations_start
def annotate_examples(entry):
# delete example annotations
ex_annotations = [ a for a in entry.annotations if a.value=='example-src' or a.value=='example-tgt']
for a in ex_annotations:
Session.delete(a)
after_head_or_pos = functions.get_pos_or_head_end(entry) + 1
if re.match(u"\.? ?Vea ", entry.fullentry[after_head_or_pos:]):
return
first_bold_after_pos = functions.get_first_bold_start_in_range(entry, after_head_or_pos, len(entry.fullentry))
if first_bold_after_pos == -1:
return
sorted_annotations = [ a for a in entry.annotations if a.value=='bold' and a.start > after_head_or_pos ]
sorted_annotations = sorted(sorted_annotations, key=attrgetter('start'))
i = 0
start_annotation = i
end_annotation = i
while i < len(sorted_annotations):
# concat successive annotations
next = False
if ( i < (len(sorted_annotations))-1 ):
if ((sorted_annotations[i].end == sorted_annotations[i+1].start) or (sorted_annotations[i].end == (sorted_annotations[i+1].start-1))):
end_annotation = i + 1
next = True
if not next:
# is there another bold annotation after this one?
if end_annotation < (len(sorted_annotations)-1):
entry.append_annotation(sorted_annotations[start_annotation].start, sorted_annotations[end_annotation].end, u'example-src', u'dictinterpretation')
entry.append_annotation(sorted_annotations[end_annotation].end, sorted_annotations[end_annotation+1].start, u'example-tgt', u'dictinterpretation')
else:
entry.append_annotation(sorted_annotations[start_annotation].start, sorted_annotations[end_annotation].end, u'example-src', u'dictinterpretation')
entry.append_annotation(sorted_annotations[end_annotation].end, len(entry.fullentry), u'example-tgt', u'dictinterpretation')
start_annotation = i + 1
end_annotation = i + 1
i = i + 1
def main(argv):
bibtex_key = u"shell1987"
if len(argv) < 2:
print "call: annotations_for%s.py ini_file" % bibtex_key
exit(1)
ini_file = argv[1]
conf = appconfig('config:' + ini_file, relative_to='.')
if not pylons.test.pylonsapp:
load_environment(conf.global_conf, conf.local_conf)
# Create the tables if they don't already exist
metadata.create_all(bind=Session.bind)
dictdatas = Session.query(model.Dictdata).join(
(model.Book, model.Dictdata.book_id==model.Book.id)
).filter(model.Book.bibtex_key==bibtex_key).all()
for dictdata in dictdatas:
entries = Session.query(model.Entry).filter_by(dictdata_id=dictdata.id).all()
#entries = Session.query(model.Entry).filter_by(dictdata_id=dictdata.id,startpage=40,pos_on_page=9).all()
#entries = []
startletters = set()
for e in entries:
heads = annotate_head(e)
if not e.is_subentry:
for h in heads:
if len(h) > 0:
startletters.add(h[0].lower())
annotate_pos(e)
annotate_translations(e)
annotate_examples(e)
annotate_crossrefs(e)
dictdata.startletters = unicode(repr(sorted(list(startletters))))
Session.commit()
if __name__ == "__main__":
main(sys.argv)
|
gpl-3.0
|
[
3,
1882,
2803,
26,
2774,
24,
1882,
2999,
199,
646,
984,
12,
747,
202,
199,
1274,
14,
515,
14,
740,
8,
736,
14,
515,
14,
4832,
24535,
2999,
199,
646,
295,
2999,
199,
504,
4182,
492,
21829,
202,
199,
646,
27070,
2999,
199,
3,
1611,
76,
4654,
1402,
4205,
3414,
202,
199,
646,
1134,
76,
4654,
14,
396,
202,
199,
646,
2050,
2999,
199,
504,
2173,
290,
273,
631,
2983,
14,
888,
14,
5418,
492,
2248,
63,
5418,
202,
199,
504,
2173,
290,
273,
631,
2983,
14,
1238,
14,
2024,
492,
8596,
12,
3341,
202,
199,
504,
2173,
290,
273,
631,
2983,
492,
1402,
2999,
199,
646,
2173,
290,
273,
631,
2983,
14,
807,
576,
14,
8858,
2999,
199,
504,
20901,
14,
11060,
492,
1145,
888,
2999,
199,
646,
3423,
2999,
199,
318,
28987,
63,
7925,
7655,
8,
2373,
304,
1128,
327,
3145,
4854,
15538,
1128,
8059,
4443,
63,
11270,
275,
359,
282,
367,
282,
315,
2397,
14,
11270,
340,
282,
14,
585,
6803,
7925,
4443,
418,
1128,
367,
282,
315,
8059,
4443,
63,
11270,
26,
1039,
8596,
14,
1807,
8,
65,
9,
11787,
8059,
4443,
63,
1431,
275,
295,
14,
1733,
8,
85,
2,
54,
4489,
334,
4735,
14,
23849,
15840,
14,
92,
4,
4186,
2397,
14,
1893,
274,
3410,
9,
1128,
340,
8059,
4443,
63,
1431,
26,
1039,
2397,
14,
740,
63,
9340,
8,
7925,
4443,
63,
1431,
14,
928,
8,
17,
395,
8059,
4443,
63,
1431,
14,
500,
8,
17,
395,
399,
7,
7925,
4443,
297,
399,
5121,
73,
319,
21533,
425,
358,
8065,
199,
318,
28987,
63,
2993,
8,
2373,
304,
1128,
327,
3145,
4854,
15538,
1128,
4854,
63,
11270,
275,
359,
282,
367,
282,
315,
2397,
14,
11270,
340,
282,
14,
585,
6803,
2993,
7,
503,
282,
14,
585,
11800,
4595,
13,
26723,
13,
19,
2,
503,
282,
14,
585,
11800,
1301,
443,
319,
937,
1128,
367,
282,
315,
4854,
63,
11270,
26,
1039,
8596,
14,
1807,
8,
65,
9,
26016,
25362,
275,
942,
2958,
4854,
63,
500,
63,
1712,
275,
3423,
14,
362,
63,
2019,
63,
9771,
63,
1712,
63,
292,
63,
928,
8,
2373,
9,
1128,
4854,
63,
928,
63,
1712,
275,
378,
11787,
1007,
495,
275,
2397,
14,
1893,
274,
3410,
59,
2993,
63,
928,
63,
1712,
26,
2993,
63,
500,
63,
1712,
61,
1128,
1343,
275,
4854,
63,
928,
63,
1712,
1128,
367,
1336,
315,
295,
14,
19373,
8,
82,
20459,
12,
5805,
92,
4,
3196,
1007,
495,
304,
1039,
1284,
275,
1336,
14,
928,
8,
16,
9,
1039,
11788,
63,
2993,
275,
3423,
14,
3176,
63,
2993,
8,
2373,
12,
1343,
12,
1284,
9,
1039,
25362,
14,
740,
8,
28565,
63,
2993,
9,
1039,
1343,
275,
1336,
14,
500,
8,
16,
9,
11787,
372,
25362,
2999,
199,
318,
28987,
63,
1712,
8,
2373,
304,
1128,
327,
3145,
2086,
15538,
1128,
2086,
63,
11270,
275,
359,
282,
367,
282,
315,
2397,
14,
11270,
340,
282,
14,
585,
6803,
1712,
418,
1128,
367,
282,
315,
2086,
63,
11270,
26,
1039,
8596,
14,
1807,
8,
65,
9,
2958,
4854,
63,
500,
63,
1712,
275,
3423,
14,
362,
63,
2019,
63,
9771,
63,
1712,
63,
292,
63,
928,
8,
2373,
9,
1128,
295,
63,
14594,
275,
295,
14,
2014,
8,
85,
3212,
17140,
60,
6320,
1128,
1336,
63,
14594,
275,
295,
63,
14594,
14,
1733,
8,
2373,
14,
1893,
274,
3410,
12,
4854,
63,
500,
63,
1712,
9,
1128,
340,
1336,
63,
14594,
436,
1336,
63,
14594,
14,
928,
8,
16,
9,
665,
334,
2993,
63,
500,
63,
1712,
435,
499,
304,
1039,
2397,
14,
740,
63,
9340,
8,
1431,
63,
14594,
14,
928,
8,
16,
6393,
17,
12,
1336,
63,
14594,
14,
500,
8,
16,
7216,
17,
12,
399,
7,
1712,
297,
399,
5121,
73,
319,
21533,
425,
358,
8065,
199,
318,
28987,
63,
13982,
8,
2373,
304,
1128,
327,
3145,
2086,
15538,
1128,
1752,
63,
11270,
275,
359,
282,
367,
282,
315,
2397,
14,
11270,
340,
282,
14,
585,
6803,
6893,
418,
1128,
367,
282,
315,
1752,
63,
11270,
26,
1039,
8596,
14,
1807,
8,
65,
9,
26016,
15547,
63,
928,
275,
3423,
14,
362,
63,
1712,
63,
269,
63,
2993,
63,
500,
8,
2373,
9,
435,
413,
1128,
15547,
63,
500,
275,
822,
8,
2373,
14,
1893,
274,
3410,
9,
11787,
340,
295,
14,
1431,
8,
85,
3212,
14,
31,
5805,
54,
4489,
3872,
2397,
14,
1893,
274,
3410,
59,
13982,
63,
928,
28847,
1039,
372,
11787,
1642,
63,
9771,
63,
4399,
63,
1712,
275,
3423,
14,
362,
63,
2246,
63,
9771,
63,
928,
63,
262,
63,
1842,
8,
2373,
12,
15547,
63,
928,
12,
15547,
63,
500,
9,
1128,
340,
1642,
63,
9771,
63,
4399,
63,
1712,
1137,
446,
17,
26,
1039,
15547,
63,
500,
275,
1642,
63,
9771,
63,
4399,
63,
1712,
2958,
1343,
275,
15547,
63,
928,
1128,
367,
1336,
315,
295,
14,
19373,
8,
85,
2,
5169,
14675,
27,
61,
5805,
92,
4,
4186,
2397,
14,
1893,
274,
3410,
59,
13982,
63,
928,
26,
13982,
63,
500,
4682,
1039,
3002,
4785,
275,
756,
1039,
327,
787,
781,
315,
282,
14540,
31,
1039,
367,
333,
315,
295,
14,
19373,
8,
82,
1154,
17140,
60,
3196,
2397,
14,
1893,
274,
3410,
59,
13982,
63,
928,
26,
13982,
63,
500,
4682,
1675,
340,
1336,
14,
928,
8,
16,
9,
2356,
333,
14,
928,
8,
16,
9,
436,
1336,
14,
500,
8,
16,
9,
2695,
333,
14,
500,
8,
16,
304,
2628,
3002,
4785,
275,
715,
17554,
1039,
340,
440,
3002,
4785,
26,
1675,
1284,
275,
1336,
14,
928,
8,
16,
9,
435,
15547,
63,
928,
1675,
1007,
22668,
275,
2397,
14,
1893,
274,
3410,
59,
928,
26,
500,
61,
1675,
340,
440,
8,
264,
14,
1431,
8,
82,
3212,
83,
10,
11918,
1007,
22668,
2298,
2628,
3423,
14,
3176,
63,
6893,
8,
2373,
12,
1343,
12,
1284,
9,
20085,
1675,
1343,
275,
1336,
14,
500,
8,
16,
9,
435,
15547,
63,
928,
259,
2999,
199,
318,
28987,
63,
8589,
8,
2373,
304,
1128,
327,
3145,
2893,
15538,
1128,
444,
63,
11270,
275,
359,
282,
367,
282,
315,
2397,
14,
11270,
340,
282,
14,
585,
6803,
2694,
13,
2164,
7,
503,
282,
14,
585,
6803
] |
[
1882,
2803,
26,
2774,
24,
1882,
2999,
199,
646,
984,
12,
747,
202,
199,
1274,
14,
515,
14,
740,
8,
736,
14,
515,
14,
4832,
24535,
2999,
199,
646,
295,
2999,
199,
504,
4182,
492,
21829,
202,
199,
646,
27070,
2999,
199,
3,
1611,
76,
4654,
1402,
4205,
3414,
202,
199,
646,
1134,
76,
4654,
14,
396,
202,
199,
646,
2050,
2999,
199,
504,
2173,
290,
273,
631,
2983,
14,
888,
14,
5418,
492,
2248,
63,
5418,
202,
199,
504,
2173,
290,
273,
631,
2983,
14,
1238,
14,
2024,
492,
8596,
12,
3341,
202,
199,
504,
2173,
290,
273,
631,
2983,
492,
1402,
2999,
199,
646,
2173,
290,
273,
631,
2983,
14,
807,
576,
14,
8858,
2999,
199,
504,
20901,
14,
11060,
492,
1145,
888,
2999,
199,
646,
3423,
2999,
199,
318,
28987,
63,
7925,
7655,
8,
2373,
304,
1128,
327,
3145,
4854,
15538,
1128,
8059,
4443,
63,
11270,
275,
359,
282,
367,
282,
315,
2397,
14,
11270,
340,
282,
14,
585,
6803,
7925,
4443,
418,
1128,
367,
282,
315,
8059,
4443,
63,
11270,
26,
1039,
8596,
14,
1807,
8,
65,
9,
11787,
8059,
4443,
63,
1431,
275,
295,
14,
1733,
8,
85,
2,
54,
4489,
334,
4735,
14,
23849,
15840,
14,
92,
4,
4186,
2397,
14,
1893,
274,
3410,
9,
1128,
340,
8059,
4443,
63,
1431,
26,
1039,
2397,
14,
740,
63,
9340,
8,
7925,
4443,
63,
1431,
14,
928,
8,
17,
395,
8059,
4443,
63,
1431,
14,
500,
8,
17,
395,
399,
7,
7925,
4443,
297,
399,
5121,
73,
319,
21533,
425,
358,
8065,
199,
318,
28987,
63,
2993,
8,
2373,
304,
1128,
327,
3145,
4854,
15538,
1128,
4854,
63,
11270,
275,
359,
282,
367,
282,
315,
2397,
14,
11270,
340,
282,
14,
585,
6803,
2993,
7,
503,
282,
14,
585,
11800,
4595,
13,
26723,
13,
19,
2,
503,
282,
14,
585,
11800,
1301,
443,
319,
937,
1128,
367,
282,
315,
4854,
63,
11270,
26,
1039,
8596,
14,
1807,
8,
65,
9,
26016,
25362,
275,
942,
2958,
4854,
63,
500,
63,
1712,
275,
3423,
14,
362,
63,
2019,
63,
9771,
63,
1712,
63,
292,
63,
928,
8,
2373,
9,
1128,
4854,
63,
928,
63,
1712,
275,
378,
11787,
1007,
495,
275,
2397,
14,
1893,
274,
3410,
59,
2993,
63,
928,
63,
1712,
26,
2993,
63,
500,
63,
1712,
61,
1128,
1343,
275,
4854,
63,
928,
63,
1712,
1128,
367,
1336,
315,
295,
14,
19373,
8,
82,
20459,
12,
5805,
92,
4,
3196,
1007,
495,
304,
1039,
1284,
275,
1336,
14,
928,
8,
16,
9,
1039,
11788,
63,
2993,
275,
3423,
14,
3176,
63,
2993,
8,
2373,
12,
1343,
12,
1284,
9,
1039,
25362,
14,
740,
8,
28565,
63,
2993,
9,
1039,
1343,
275,
1336,
14,
500,
8,
16,
9,
11787,
372,
25362,
2999,
199,
318,
28987,
63,
1712,
8,
2373,
304,
1128,
327,
3145,
2086,
15538,
1128,
2086,
63,
11270,
275,
359,
282,
367,
282,
315,
2397,
14,
11270,
340,
282,
14,
585,
6803,
1712,
418,
1128,
367,
282,
315,
2086,
63,
11270,
26,
1039,
8596,
14,
1807,
8,
65,
9,
2958,
4854,
63,
500,
63,
1712,
275,
3423,
14,
362,
63,
2019,
63,
9771,
63,
1712,
63,
292,
63,
928,
8,
2373,
9,
1128,
295,
63,
14594,
275,
295,
14,
2014,
8,
85,
3212,
17140,
60,
6320,
1128,
1336,
63,
14594,
275,
295,
63,
14594,
14,
1733,
8,
2373,
14,
1893,
274,
3410,
12,
4854,
63,
500,
63,
1712,
9,
1128,
340,
1336,
63,
14594,
436,
1336,
63,
14594,
14,
928,
8,
16,
9,
665,
334,
2993,
63,
500,
63,
1712,
435,
499,
304,
1039,
2397,
14,
740,
63,
9340,
8,
1431,
63,
14594,
14,
928,
8,
16,
6393,
17,
12,
1336,
63,
14594,
14,
500,
8,
16,
7216,
17,
12,
399,
7,
1712,
297,
399,
5121,
73,
319,
21533,
425,
358,
8065,
199,
318,
28987,
63,
13982,
8,
2373,
304,
1128,
327,
3145,
2086,
15538,
1128,
1752,
63,
11270,
275,
359,
282,
367,
282,
315,
2397,
14,
11270,
340,
282,
14,
585,
6803,
6893,
418,
1128,
367,
282,
315,
1752,
63,
11270,
26,
1039,
8596,
14,
1807,
8,
65,
9,
26016,
15547,
63,
928,
275,
3423,
14,
362,
63,
1712,
63,
269,
63,
2993,
63,
500,
8,
2373,
9,
435,
413,
1128,
15547,
63,
500,
275,
822,
8,
2373,
14,
1893,
274,
3410,
9,
11787,
340,
295,
14,
1431,
8,
85,
3212,
14,
31,
5805,
54,
4489,
3872,
2397,
14,
1893,
274,
3410,
59,
13982,
63,
928,
28847,
1039,
372,
11787,
1642,
63,
9771,
63,
4399,
63,
1712,
275,
3423,
14,
362,
63,
2246,
63,
9771,
63,
928,
63,
262,
63,
1842,
8,
2373,
12,
15547,
63,
928,
12,
15547,
63,
500,
9,
1128,
340,
1642,
63,
9771,
63,
4399,
63,
1712,
1137,
446,
17,
26,
1039,
15547,
63,
500,
275,
1642,
63,
9771,
63,
4399,
63,
1712,
2958,
1343,
275,
15547,
63,
928,
1128,
367,
1336,
315,
295,
14,
19373,
8,
85,
2,
5169,
14675,
27,
61,
5805,
92,
4,
4186,
2397,
14,
1893,
274,
3410,
59,
13982,
63,
928,
26,
13982,
63,
500,
4682,
1039,
3002,
4785,
275,
756,
1039,
327,
787,
781,
315,
282,
14540,
31,
1039,
367,
333,
315,
295,
14,
19373,
8,
82,
1154,
17140,
60,
3196,
2397,
14,
1893,
274,
3410,
59,
13982,
63,
928,
26,
13982,
63,
500,
4682,
1675,
340,
1336,
14,
928,
8,
16,
9,
2356,
333,
14,
928,
8,
16,
9,
436,
1336,
14,
500,
8,
16,
9,
2695,
333,
14,
500,
8,
16,
304,
2628,
3002,
4785,
275,
715,
17554,
1039,
340,
440,
3002,
4785,
26,
1675,
1284,
275,
1336,
14,
928,
8,
16,
9,
435,
15547,
63,
928,
1675,
1007,
22668,
275,
2397,
14,
1893,
274,
3410,
59,
928,
26,
500,
61,
1675,
340,
440,
8,
264,
14,
1431,
8,
82,
3212,
83,
10,
11918,
1007,
22668,
2298,
2628,
3423,
14,
3176,
63,
6893,
8,
2373,
12,
1343,
12,
1284,
9,
20085,
1675,
1343,
275,
1336,
14,
500,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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
] |
sikmir/QGIS
|
tests/src/python/test_provider_ogr_sqlite.py
|
30
|
20246
|
# -*- coding: utf-8 -*-
"""QGIS Unit tests for the OGR/GPKG provider.
.. 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__ = 'Even Rouault'
__date__ = '2016-06-01'
__copyright__ = 'Copyright 2016, Even Rouault'
import qgis # NOQA
import os
import tempfile
import shutil
import hashlib
from osgeo import gdal, ogr
from qgis.core import (QgsVectorLayer,
QgsFeature,
QgsFeatureRequest,
QgsFieldConstraints,
QgsPointXY,
NULL,
QgsRectangle)
from qgis.testing import start_app, unittest
from qgis.PyQt.QtCore import QDate, QTime, QDateTime, QVariant, QByteArray
start_app()
def GDAL_COMPUTE_VERSION(maj, min, rev):
return ((maj) * 1000000 + (min) * 10000 + (rev) * 100)
class TestPyQgsOGRProviderSqlite(unittest.TestCase):
@classmethod
def setUpClass(cls):
"""Run before all tests"""
# Create test layer
cls.basetestpath = tempfile.mkdtemp()
@classmethod
def tearDownClass(cls):
"""Run after all tests"""
shutil.rmtree(cls.basetestpath, True)
def testFidSupport(self):
# We do not use @unittest.expectedFailure since the test might actually succeed
# on Linux 64bit with GDAL 1.11, where "long" is 64 bit...
# GDAL 2.0 is guaranteed to properly support it on all platforms
version_num = int(gdal.VersionInfo('VERSION_NUM'))
if version_num < GDAL_COMPUTE_VERSION(2, 0, 0):
return
tmpfile = os.path.join(self.basetestpath, 'testFidSupport.sqlite')
ds = ogr.GetDriverByName('SQLite').CreateDataSource(tmpfile)
lyr = ds.CreateLayer('test', geom_type=ogr.wkbPoint, options=['FID=fid'])
lyr.CreateField(ogr.FieldDefn('strfield', ogr.OFTString))
lyr.CreateField(ogr.FieldDefn('intfield', ogr.OFTInteger))
f = ogr.Feature(lyr.GetLayerDefn())
f.SetFID(12)
f.SetField(0, 'foo')
f.SetField(1, 123)
lyr.CreateFeature(f)
f = None
ds = None
vl = QgsVectorLayer('{}'.format(tmpfile), 'test', 'ogr')
self.assertEqual(len(vl.fields()), 3)
got = [(f.attribute('fid'), f.attribute('strfield'), f.attribute('intfield')) for f in vl.getFeatures()]
self.assertEqual(got, [(12, 'foo', 123)])
got = [(f.attribute('fid'), f.attribute('strfield')) for f in vl.getFeatures(QgsFeatureRequest().setFilterExpression("strfield = 'foo'"))]
self.assertEqual(got, [(12, 'foo')])
got = [(f.attribute('fid'), f.attribute('strfield')) for f in vl.getFeatures(QgsFeatureRequest().setFilterExpression("fid = 12"))]
self.assertEqual(got, [(12, 'foo')])
result = [f['strfield'] for f in vl.dataProvider().getFeatures(QgsFeatureRequest().setSubsetOfAttributes(['strfield'], vl.dataProvider().fields()))]
self.assertEqual(result, ['foo'])
result = [f['fid'] for f in vl.dataProvider().getFeatures(QgsFeatureRequest().setSubsetOfAttributes(['fid'], vl.dataProvider().fields()))]
self.assertEqual(result, [12])
# Test that when the 'fid' field is not set, regular insertion is done
f = QgsFeature()
f.setFields(vl.fields())
f.setAttributes([None, 'automatic_id'])
(res, out_f) = vl.dataProvider().addFeatures([f])
self.assertEqual(out_f[0].id(), 13)
self.assertEqual(out_f[0].attribute('fid'), 13)
self.assertEqual(out_f[0].attribute('strfield'), 'automatic_id')
# Test that when the 'fid' field is set, it is really used to set the id
f = QgsFeature()
f.setFields(vl.fields())
f.setAttributes([9876543210, 'bar'])
(res, out_f) = vl.dataProvider().addFeatures([f])
self.assertEqual(out_f[0].id(), 9876543210)
self.assertEqual(out_f[0].attribute('fid'), 9876543210)
self.assertEqual(out_f[0].attribute('strfield'), 'bar')
got = [(f.attribute('fid'), f.attribute('strfield')) for f in vl.getFeatures(QgsFeatureRequest().setFilterExpression("fid = 9876543210"))]
self.assertEqual(got, [(9876543210, 'bar')])
self.assertTrue(vl.dataProvider().changeAttributeValues({9876543210: {1: 'baz'}}))
got = [(f.attribute('fid'), f.attribute('strfield')) for f in vl.getFeatures(QgsFeatureRequest().setFilterExpression("fid = 9876543210"))]
self.assertEqual(got, [(9876543210, 'baz')])
self.assertTrue(vl.dataProvider().changeAttributeValues({9876543210: {0: 9876543210, 1: 'baw'}}))
got = [(f.attribute('fid'), f.attribute('strfield')) for f in vl.getFeatures(QgsFeatureRequest().setFilterExpression("fid = 9876543210"))]
self.assertEqual(got, [(9876543210, 'baw')])
# Not allowed: changing the fid regular field
self.assertTrue(vl.dataProvider().changeAttributeValues({9876543210: {0: 12, 1: 'baw'}}))
got = [(f.attribute('fid'), f.attribute('strfield')) for f in vl.getFeatures(QgsFeatureRequest().setFilterExpression("fid = 9876543210"))]
self.assertEqual(got, [(9876543210, 'baw')])
# Cannot delete fid
self.assertFalse(vl.dataProvider().deleteAttributes([0]))
# Delete first "genuine" attribute
self.assertTrue(vl.dataProvider().deleteAttributes([1]))
got = [(f.attribute('fid'), f.attribute('intfield')) for f in vl.dataProvider().getFeatures(QgsFeatureRequest().setFilterExpression("fid = 12"))]
self.assertEqual(got, [(12, 123)])
def testNotNullConstraint(self):
""" test detection of not null constraint on OGR layer """
tmpfile = os.path.join(self.basetestpath, 'testNotNullConstraint.sqlite')
ds = ogr.GetDriverByName('SQLite').CreateDataSource(tmpfile)
lyr = ds.CreateLayer('test', geom_type=ogr.wkbPoint, options=['FID=fid'])
lyr.CreateField(ogr.FieldDefn('field1', ogr.OFTInteger))
fld2 = ogr.FieldDefn('field2', ogr.OFTInteger)
fld2.SetNullable(False)
lyr.CreateField(fld2)
ds = None
vl = QgsVectorLayer('{}'.format(tmpfile), 'test', 'ogr')
self.assertTrue(vl.isValid())
# test some bad indexes
self.assertEqual(vl.dataProvider().fieldConstraints(-1), QgsFieldConstraints.Constraints())
self.assertEqual(vl.dataProvider().fieldConstraints(1001), QgsFieldConstraints.Constraints())
self.assertTrue(vl.dataProvider().fieldConstraints(0) & QgsFieldConstraints.ConstraintNotNull)
self.assertFalse(vl.dataProvider().fieldConstraints(1) & QgsFieldConstraints.ConstraintNotNull)
self.assertTrue(vl.dataProvider().fieldConstraints(2) & QgsFieldConstraints.ConstraintNotNull)
# test that constraints have been saved to fields correctly
fields = vl.fields()
self.assertTrue(fields.at(0).constraints().constraints() & QgsFieldConstraints.ConstraintNotNull)
self.assertFalse(fields.at(1).constraints().constraints() & QgsFieldConstraints.ConstraintNotNull)
self.assertTrue(fields.at(2).constraints().constraints() & QgsFieldConstraints.ConstraintNotNull)
self.assertEqual(fields.at(2).constraints().constraintOrigin(QgsFieldConstraints.ConstraintNotNull), QgsFieldConstraints.ConstraintOriginProvider)
def testDefaultValues(self):
""" test detection of defaults on OGR layer """
tmpfile = os.path.join(self.basetestpath, 'testDefaults.sqlite')
ds = ogr.GetDriverByName('SQLite').CreateDataSource(tmpfile)
lyr = ds.CreateLayer('test', geom_type=ogr.wkbPoint, options=['FID=fid'])
lyr.CreateField(ogr.FieldDefn('field1', ogr.OFTInteger))
fld2 = ogr.FieldDefn('field2', ogr.OFTInteger)
fld2.SetDefault('5')
lyr.CreateField(fld2)
fld3 = ogr.FieldDefn('field3', ogr.OFTString)
fld3.SetDefault("'some ''default'")
lyr.CreateField(fld3)
fld4 = ogr.FieldDefn('field4', ogr.OFTDate)
fld4.SetDefault("CURRENT_DATE")
lyr.CreateField(fld4)
fld5 = ogr.FieldDefn('field5', ogr.OFTTime)
fld5.SetDefault("CURRENT_TIME")
lyr.CreateField(fld5)
fld6 = ogr.FieldDefn('field6', ogr.OFTDateTime)
fld6.SetDefault("CURRENT_TIMESTAMP")
lyr.CreateField(fld6)
ds = None
vl = QgsVectorLayer('{}'.format(tmpfile), 'test', 'ogr')
self.assertTrue(vl.isValid())
# test some bad indexes
self.assertFalse(vl.dataProvider().defaultValue(-1))
self.assertFalse(vl.dataProvider().defaultValue(1001))
# test default
self.assertEqual(vl.dataProvider().defaultValue(1), NULL)
self.assertEqual(vl.dataProvider().defaultValue(2), 5)
self.assertEqual(vl.dataProvider().defaultValue(3), "some 'default")
self.assertEqual(vl.dataProvider().defaultValue(4), QDate.currentDate())
# time may pass, so we allow 1 second difference here
self.assertTrue(vl.dataProvider().defaultValue(5).secsTo(QTime.currentTime()) < 1)
self.assertTrue(vl.dataProvider().defaultValue(6).secsTo(QDateTime.currentDateTime()) < 1)
def testSubsetStringFids(self):
"""
- tests that feature ids are stable even if a subset string is set
- tests that the subset string is correctly set on the ogr layer event when reloading the data source (issue #17122)
"""
tmpfile = os.path.join(self.basetestpath, 'subsetStringFids.sqlite')
ds = ogr.GetDriverByName('SQLite').CreateDataSource(tmpfile)
lyr = ds.CreateLayer('test', geom_type=ogr.wkbPoint, options=['FID=fid'])
lyr.CreateField(ogr.FieldDefn('type', ogr.OFTInteger))
lyr.CreateField(ogr.FieldDefn('value', ogr.OFTInteger))
f = ogr.Feature(lyr.GetLayerDefn())
f.SetFID(0)
f.SetField(0, 1)
f.SetField(1, 11)
f.SetGeometry(ogr.CreateGeometryFromWkt('Point (0 0)'))
lyr.CreateFeature(f)
f = ogr.Feature(lyr.GetLayerDefn())
f.SetFID(1)
f.SetField(0, 1)
f.SetField(1, 12)
f.SetGeometry(ogr.CreateGeometryFromWkt('Point (1 1)'))
lyr.CreateFeature(f)
f = ogr.Feature(lyr.GetLayerDefn())
f.SetFID(2)
f.SetField(0, 1)
f.SetField(1, 13)
f.SetGeometry(ogr.CreateGeometryFromWkt('Point (2 2)'))
lyr.CreateFeature(f)
f = ogr.Feature(lyr.GetLayerDefn())
f.SetFID(3)
f.SetField(0, 2)
f.SetField(1, 14)
f.SetGeometry(ogr.CreateGeometryFromWkt('Point (3 3)'))
lyr.CreateFeature(f)
f = ogr.Feature(lyr.GetLayerDefn())
f.SetFID(4)
f.SetField(0, 2)
f.SetField(1, 15)
f.SetGeometry(ogr.CreateGeometryFromWkt('Point (4 4)'))
lyr.CreateFeature(f)
f = ogr.Feature(lyr.GetLayerDefn())
f.SetFID(5)
f.SetField(0, 2)
f.SetField(1, 16)
f.SetGeometry(ogr.CreateGeometryFromWkt('Point (5 5)'))
lyr.CreateFeature(f)
f = None
ds = None
vl = QgsVectorLayer(tmpfile, 'test', 'ogr')
self.assertTrue(vl.isValid())
self.assertEqual([f.name() for f in vl.fields()], ['fid', 'type', 'value'])
original_fields = vl.fields()
vl = QgsVectorLayer(tmpfile + "|subset=type=2", 'test', 'ogr')
self.assertTrue(vl.isValid())
def run_checks():
self.assertEqual([f.name() for f in vl.fields()], ['fid', 'type', 'value'])
# expression
req = QgsFeatureRequest()
req.setFilterExpression("value=16")
it = vl.getFeatures(req)
f = QgsFeature()
self.assertTrue(it.nextFeature(f))
self.assertEqual(f.id(), 5)
self.assertEqual(f.attributes(), [5, 2, 16])
self.assertEqual([field.name() for field in f.fields()], ['fid', 'type', 'value'])
self.assertEqual(f.geometry().asWkt(), 'Point (5 5)')
# filter fid
req = QgsFeatureRequest()
req.setFilterFid(5)
it = vl.getFeatures(req)
f = QgsFeature()
self.assertTrue(it.nextFeature(f))
self.assertEqual(f.id(), 5)
self.assertEqual(f.attributes(), [5, 2, 16])
self.assertEqual([field.name() for field in f.fields()], ['fid', 'type', 'value'])
self.assertEqual(f.geometry().asWkt(), 'Point (5 5)')
# filter fids
req = QgsFeatureRequest()
req.setFilterFids([5])
it = vl.getFeatures(req)
f = QgsFeature()
self.assertTrue(it.nextFeature(f))
self.assertEqual(f.id(), 5)
self.assertEqual(f.attributes(), [5, 2, 16])
self.assertEqual([field.name() for field in f.fields()], ['fid', 'type', 'value'])
self.assertEqual(f.geometry().asWkt(), 'Point (5 5)')
# check with subset of attributes
req = QgsFeatureRequest()
req.setFilterFids([5])
req.setSubsetOfAttributes([2])
it = vl.getFeatures(req)
f = QgsFeature()
self.assertTrue(it.nextFeature(f))
self.assertEqual(f.id(), 5)
self.assertEqual(f.attributes()[2], 16)
self.assertEqual([field.name() for field in f.fields()], ['fid', 'type', 'value'])
self.assertEqual(f.geometry().asWkt(), 'Point (5 5)')
# filter rect and expression
req = QgsFeatureRequest()
req.setFilterExpression("value=16 or value=14")
req.setFilterRect(QgsRectangle(4.5, 4.5, 5.5, 5.5))
it = vl.getFeatures(req)
f = QgsFeature()
self.assertTrue(it.nextFeature(f))
self.assertEqual(f.id(), 5)
self.assertEqual(f.attributes(), [5, 2, 16])
self.assertEqual([field.name() for field in f.fields()], ['fid', 'type', 'value'])
self.assertEqual(f.geometry().asWkt(), 'Point (5 5)')
# filter rect and fids
req = QgsFeatureRequest()
req.setFilterFids([3, 5])
req.setFilterRect(QgsRectangle(4.5, 4.5, 5.5, 5.5))
it = vl.getFeatures(req)
f = QgsFeature()
self.assertTrue(it.nextFeature(f))
self.assertEqual(f.id(), 5)
self.assertEqual(f.attributes(), [5, 2, 16])
self.assertEqual([field.name() for field in f.fields()], ['fid', 'type', 'value'])
self.assertEqual(f.geometry().asWkt(), 'Point (5 5)')
# Ensure that orig_ogc_fid is still retrieved even if attribute subset is passed
req = QgsFeatureRequest()
req.setSubsetOfAttributes([])
it = vl.getFeatures(req)
ids = []
geoms = {}
while it.nextFeature(f):
ids.append(f.id())
geoms[f.id()] = f.geometry().asWkt()
self.assertCountEqual(ids, [3, 4, 5])
self.assertEqual(geoms, {3: 'Point (3 3)', 4: 'Point (4 4)', 5: 'Point (5 5)'})
run_checks()
# Check that subset string is correctly set on reload
vl.reload()
run_checks()
def test_SplitFeature(self):
"""Test sqlite feature can be split"""
tmpfile = os.path.join(self.basetestpath, 'testGeopackageSplitFeatures.sqlite')
ds = ogr.GetDriverByName('SQlite').CreateDataSource(tmpfile)
lyr = ds.CreateLayer('test', geom_type=ogr.wkbPolygon)
lyr.CreateField(ogr.FieldDefn('str_field', ogr.OFTString))
f = ogr.Feature(lyr.GetLayerDefn())
f.SetGeometry(ogr.CreateGeometryFromWkt('POLYGON ((0 0,0 1,1 1,1 0,0 0))'))
lyr.CreateFeature(f)
f = None
ds = None
layer = QgsVectorLayer(u'{}'.format(tmpfile) + "|layername=" + "test", 'test', u'ogr')
# Check that pk field has unique constraint
fields = layer.fields()
pkfield = fields.at(0)
self.assertTrue(pkfield.constraints().constraints() & QgsFieldConstraints.ConstraintUnique)
self.assertTrue(layer.isValid())
self.assertTrue(layer.isSpatial())
self.assertEqual([f for f in layer.getFeatures()][0].geometry().asWkt(), 'Polygon ((0 0, 0 1, 1 1, 1 0, 0 0))')
layer.startEditing()
self.assertEqual(layer.splitFeatures([QgsPointXY(0.5, 0), QgsPointXY(0.5, 1)], 0), 0)
self.assertTrue(layer.commitChanges())
self.assertEqual(layer.featureCount(), 2)
layer = QgsVectorLayer(u'{}'.format(tmpfile) + "|layername=" + "test", 'test', u'ogr')
self.assertEqual(layer.featureCount(), 2)
self.assertEqual([f for f in layer.getFeatures()][0].geometry().asWkt(), 'Polygon ((0.5 0, 0.5 1, 1 1, 1 0, 0.5 0))')
self.assertEqual([f for f in layer.getFeatures()][1].geometry().asWkt(), 'Polygon ((0.5 1, 0.5 0, 0 0, 0 1, 0.5 1))')
def testBlob(self):
"""
Test binary blob field
"""
tmpfile = os.path.join(self.basetestpath, 'binaryfield.sqlite')
ds = ogr.GetDriverByName('SQLite').CreateDataSource(tmpfile)
lyr = ds.CreateLayer('test', geom_type=ogr.wkbPoint, options=['FID=fid'])
lyr.CreateField(ogr.FieldDefn('strfield', ogr.OFTString))
lyr.CreateField(ogr.FieldDefn('intfield', ogr.OFTInteger))
lyr.CreateField(ogr.FieldDefn('binfield', ogr.OFTBinary))
lyr.CreateField(ogr.FieldDefn('binfield2', ogr.OFTBinary))
f = None
ds = None
vl = QgsVectorLayer(tmpfile)
self.assertTrue(vl.isValid())
fields = vl.fields()
bin1_field = fields[fields.lookupField('binfield')]
self.assertEqual(bin1_field.type(), QVariant.ByteArray)
self.assertEqual(bin1_field.typeName(), 'Binary')
bin2_field = fields[fields.lookupField('binfield2')]
self.assertEqual(bin2_field.type(), QVariant.ByteArray)
self.assertEqual(bin2_field.typeName(), 'Binary')
dp = vl.dataProvider()
f = QgsFeature(fields)
bin_1 = b'xxx'
bin_2 = b'yyy'
bin_val1 = QByteArray(bin_1)
bin_val2 = QByteArray(bin_2)
f.setAttributes([1, 'str', 100, bin_val1, bin_val2])
self.assertTrue(dp.addFeature(f))
f2 = next(dp.getFeatures())
self.assertEqual(f2.attributes(), [1, 'str', 100, QByteArray(bin_1), QByteArray(bin_2)])
bin_3 = b'zzz'
bin_4 = b'aaa'
bin_val3 = QByteArray(bin_3)
bin_val4 = QByteArray(bin_4)
self.assertTrue(dp.changeAttributeValues({f2.id(): {fields.lookupField('intfield'): 200,
fields.lookupField('binfield'): bin_val4,
fields.lookupField('binfield2'): bin_val3}}))
f5 = next(dp.getFeatures())
self.assertEqual(f5.attributes(), [1, 'str', 200, QByteArray(bin_4), QByteArray(bin_3)])
def testUniqueValuesOnFidColumn(self):
"""Test regression #21311 OGR provider returns an empty set for sqlite uniqueValues"""
tmpfile = os.path.join(self.basetestpath, 'testSQLiteUniqueValuesOnFidColumn.db')
ds = ogr.GetDriverByName('SQLite').CreateDataSource(tmpfile)
lyr = ds.CreateLayer('test', geom_type=ogr.wkbPolygon)
lyr.CreateField(ogr.FieldDefn('str_field', ogr.OFTString))
f = ogr.Feature(lyr.GetLayerDefn())
f.SetGeometry(ogr.CreateGeometryFromWkt('POLYGON ((0 0,0 1,1 1,1 0,0 0))'))
f.SetField('str_field', 'one')
lyr.CreateFeature(f)
f = ogr.Feature(lyr.GetLayerDefn())
f.SetGeometry(ogr.CreateGeometryFromWkt('POLYGON ((0 0,0 2,2 2,2 0,0 0))'))
f.SetField('str_field', 'two')
lyr.CreateFeature(f)
f = None
ds = None
vl1 = QgsVectorLayer(tmpfile)
self.assertTrue(vl1.isValid())
self.assertEqual(vl1.uniqueValues(0), {1, 2})
self.assertEqual(vl1.uniqueValues(1), {'one', 'two'})
if __name__ == '__main__':
unittest.main()
|
gpl-2.0
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
624,
31329,
12008,
2295,
367,
314,
10904,
15,
8225,
14634,
5022,
14,
199,
199,
703,
5317,
447,
961,
2240,
365,
2867,
2032,
27,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
390,
1334,
314,
2895,
402,
314,
1664,
1696,
1684,
844,
465,
3267,
701,
199,
1589,
2868,
2290,
2752,
27,
1902,
1015,
499,
402,
314,
844,
12,
503,
199,
8,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
624,
199,
363,
2502,
363,
275,
283,
29704,
19776,
558,
7,
199,
363,
602,
363,
275,
283,
9261,
13,
1690,
13,
614,
7,
199,
363,
7307,
363,
275,
283,
7384,
7800,
12,
22207,
19776,
558,
7,
199,
199,
646,
15640,
221,
327,
20432,
199,
199,
646,
747,
199,
646,
5549,
199,
646,
5145,
199,
646,
8337,
199,
504,
747,
6721,
492,
15834,
12,
20713,
199,
199,
504,
15640,
14,
1018,
492,
334,
7350,
18602,
12,
2432,
26833,
12,
2432,
26833,
2017,
12,
2432,
4888,
792,
21007,
12,
2432,
4888,
30466,
12,
2432,
5962,
12,
2432,
4888,
18127,
9,
199,
504,
15640,
14,
4776,
492,
1343,
63,
571,
12,
2882,
199,
504,
15640,
14,
24107,
14,
10901,
492,
1413,
2506,
12,
1413,
1366,
12,
1413,
3926,
12,
27875,
12,
1413,
4861,
3836,
199,
199,
928,
63,
571,
342,
421,
199,
318,
15801,
63,
6790,
4586,
63,
4612,
8,
31611,
12,
1748,
12,
6822,
304,
272,
372,
3666,
31611,
9,
627,
19492,
435,
334,
827,
9,
627,
11630,
435,
334,
4964,
9,
627,
2948,
9,
421,
199,
533,
1379,
2713,
7350,
17275,
6663,
24614,
5333,
8,
2796,
14,
1746,
304,
339,
768,
3744,
272,
347,
18561,
8,
1886,
304,
267,
408,
2540,
2544,
1006,
2295,
624,
267,
327,
2790,
511,
4045,
267,
843,
14,
1095,
396,
515,
275,
5549,
14,
11983,
342,
339,
768,
3744,
272,
347,
24468,
8,
1886,
304,
267,
408,
2540,
2410,
1006,
2295,
624,
267,
5145,
14,
9242,
8,
1886,
14,
1095,
396,
515,
12,
715,
9,
339,
347,
511,
38,
344,
11532,
8,
277,
304,
398,
327,
2136,
886,
440,
675,
768,
2796,
14,
2062,
6782,
3967,
314,
511,
5594,
5965,
17961,
267,
327,
641,
10130,
5049,
2075,
543,
15801,
413,
14,
845,
12,
2382,
298,
2809,
2,
365,
5049,
4546,
1396,
267,
327,
15801,
499,
14,
16,
365,
17334,
370,
7684,
2291,
652,
641,
1006,
10677,
267,
1015,
63,
1507,
275,
1109,
8,
11600,
14,
3353,
2354,
360,
4612,
63,
7125,
1333,
267,
340,
1015,
63,
1507,
665,
15801,
63,
6790,
4586,
63,
4612,
8,
18,
12,
378,
12,
378,
304,
288,
372,
398,
25137,
275,
747,
14,
515,
14,
904,
8,
277,
14,
1095,
396,
515,
12,
283,
396,
38,
344,
11532,
14,
10659,
358,
267,
6364,
275,
20713,
14,
1002,
6158,
11190,
360,
4657,
1175,
1959,
2499,
16693,
8,
21930,
9,
267,
21559,
82,
275,
6364,
14,
2499,
5003,
360,
396,
297,
9671,
63,
466,
29,
14945,
14,
18914,
3428,
12,
1511,
2968,
38,
998,
29,
9430,
1105,
267,
21559,
82,
14,
2499,
792,
8,
14945,
14,
792,
872,
2324,
360,
495,
698,
297,
20713,
14,
47,
2161,
1558,
430,
267,
21559,
82,
14,
2499,
792,
8,
14945,
14,
792,
872,
2324,
360,
442,
698,
297,
20713,
14,
47,
2161,
2674,
430,
267,
289,
275,
20713,
14,
5968,
8,
590,
82,
14,
1002,
5003,
872,
2324,
1012,
267,
289,
14,
1084,
38,
998,
8,
713,
9,
267,
289,
14,
1084,
792,
8,
16,
12,
283,
1421,
358,
267,
289,
14,
1084,
792,
8,
17,
12,
11869,
9,
267,
21559,
82,
14,
2499,
5968,
8,
70,
9,
267,
289,
275,
488,
267,
6364,
275,
488,
398,
17876,
275,
22507,
360,
11123,
908,
8,
21930,
395,
283,
396,
297,
283,
14945,
358,
267,
291,
14,
629,
8,
552,
8,
7300,
14,
955,
4000,
650,
9,
267,
4788,
275,
3842,
70,
14,
3215,
360,
9430,
659,
289,
14,
3215,
360,
495,
698,
659,
289,
14,
3215,
360,
442,
698,
1333,
367,
289,
315,
17876,
14,
362,
10807,
5106,
267,
291,
14,
629,
8,
7808,
12,
3842,
713,
12,
283,
1421,
297,
11869,
3948,
398,
4788,
275,
3842,
70,
14,
3215,
360,
9430,
659,
289,
14,
3215,
360,
495,
698,
1333,
367,
289,
315,
17876,
14,
362,
10807,
8,
7350,
5968,
2017,
1252,
409,
4131,
9093,
480,
495,
698,
275,
283,
1421,
7,
2237,
61,
267,
291,
14,
629,
8,
7808,
12,
3842,
713,
12,
283,
1421,
2023,
398,
4788,
275,
3842,
70,
14,
3215,
360,
9430,
659,
289,
14,
3215,
360,
495,
698,
1333,
367,
289,
315,
17876,
14,
362,
10807,
8,
7350,
5968,
2017,
1252,
409,
4131,
9093,
480,
9430,
275,
3144,
2237,
61,
267,
291,
14,
629,
8,
7808,
12,
3842,
713,
12,
283,
1421,
2023,
398,
754,
275,
359,
70,
459,
495,
698,
418,
367,
289,
315,
17876,
14,
27735,
1252,
362,
10807,
8,
7350,
5968,
2017,
1252,
409,
20113,
3466,
5379,
2941,
495,
698,
995,
17876,
14,
27735,
1252,
955,
4059,
61,
267,
291,
14,
629,
8,
1099,
12,
788,
1421,
1105,
398,
754,
275,
359,
70,
459,
9430,
418,
367,
289,
315,
17876,
14,
27735,
1252,
362,
10807,
8,
7350,
5968,
2017,
1252,
409,
20113,
3466,
5379,
2941,
9430,
995,
17876,
14,
27735,
1252,
955,
4059,
61,
267,
291,
14,
629,
8,
1099,
12,
359,
713,
566,
398,
327,
1379,
626,
1380,
314,
283,
9430,
7,
901,
365,
440,
663,
12,
5578,
22470,
365,
4224,
267,
289,
275,
26833,
342,
267,
289,
14,
409,
7304,
8,
7300,
14,
955,
1012,
267,
289,
14,
31674,
779,
403,
12,
283,
23292,
63,
344,
1105,
267,
334,
470,
12,
734,
63,
70,
9,
275,
17876,
14,
27735,
1252,
525,
10807,
779,
70,
566,
267,
291,
14,
629,
8,
548,
63,
70,
59,
16,
1055,
344,
1062,
4944,
9,
267,
291,
14,
629,
8,
548,
63,
70,
59,
16,
1055,
3215,
360,
9430,
659,
4944,
9,
267,
291,
14,
629,
8,
548,
63,
70,
59,
16,
1055,
3215,
360,
495,
698,
659,
283,
23292,
63,
344,
358,
398,
327,
1379,
626,
1380,
314,
283,
9430,
7,
901,
365,
663,
12,
652,
365,
7710,
1202,
370,
663,
314,
1305,
267,
289,
275,
26833,
342,
267,
289,
14,
409,
7304,
8,
7300,
14
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
624,
31329,
12008,
2295,
367,
314,
10904,
15,
8225,
14634,
5022,
14,
199,
199,
703,
5317,
447,
961,
2240,
365,
2867,
2032,
27,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
390,
1334,
314,
2895,
402,
314,
1664,
1696,
1684,
844,
465,
3267,
701,
199,
1589,
2868,
2290,
2752,
27,
1902,
1015,
499,
402,
314,
844,
12,
503,
199,
8,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
624,
199,
363,
2502,
363,
275,
283,
29704,
19776,
558,
7,
199,
363,
602,
363,
275,
283,
9261,
13,
1690,
13,
614,
7,
199,
363,
7307,
363,
275,
283,
7384,
7800,
12,
22207,
19776,
558,
7,
199,
199,
646,
15640,
221,
327,
20432,
199,
199,
646,
747,
199,
646,
5549,
199,
646,
5145,
199,
646,
8337,
199,
504,
747,
6721,
492,
15834,
12,
20713,
199,
199,
504,
15640,
14,
1018,
492,
334,
7350,
18602,
12,
2432,
26833,
12,
2432,
26833,
2017,
12,
2432,
4888,
792,
21007,
12,
2432,
4888,
30466,
12,
2432,
5962,
12,
2432,
4888,
18127,
9,
199,
504,
15640,
14,
4776,
492,
1343,
63,
571,
12,
2882,
199,
504,
15640,
14,
24107,
14,
10901,
492,
1413,
2506,
12,
1413,
1366,
12,
1413,
3926,
12,
27875,
12,
1413,
4861,
3836,
199,
199,
928,
63,
571,
342,
421,
199,
318,
15801,
63,
6790,
4586,
63,
4612,
8,
31611,
12,
1748,
12,
6822,
304,
272,
372,
3666,
31611,
9,
627,
19492,
435,
334,
827,
9,
627,
11630,
435,
334,
4964,
9,
627,
2948,
9,
421,
199,
533,
1379,
2713,
7350,
17275,
6663,
24614,
5333,
8,
2796,
14,
1746,
304,
339,
768,
3744,
272,
347,
18561,
8,
1886,
304,
267,
408,
2540,
2544,
1006,
2295,
624,
267,
327,
2790,
511,
4045,
267,
843,
14,
1095,
396,
515,
275,
5549,
14,
11983,
342,
339,
768,
3744,
272,
347,
24468,
8,
1886,
304,
267,
408,
2540,
2410,
1006,
2295,
624,
267,
5145,
14,
9242,
8,
1886,
14,
1095,
396,
515,
12,
715,
9,
339,
347,
511,
38,
344,
11532,
8,
277,
304,
398,
327,
2136,
886,
440,
675,
768,
2796,
14,
2062,
6782,
3967,
314,
511,
5594,
5965,
17961,
267,
327,
641,
10130,
5049,
2075,
543,
15801,
413,
14,
845,
12,
2382,
298,
2809,
2,
365,
5049,
4546,
1396,
267,
327,
15801,
499,
14,
16,
365,
17334,
370,
7684,
2291,
652,
641,
1006,
10677,
267,
1015,
63,
1507,
275,
1109,
8,
11600,
14,
3353,
2354,
360,
4612,
63,
7125,
1333,
267,
340,
1015,
63,
1507,
665,
15801,
63,
6790,
4586,
63,
4612,
8,
18,
12,
378,
12,
378,
304,
288,
372,
398,
25137,
275,
747,
14,
515,
14,
904,
8,
277,
14,
1095,
396,
515,
12,
283,
396,
38,
344,
11532,
14,
10659,
358,
267,
6364,
275,
20713,
14,
1002,
6158,
11190,
360,
4657,
1175,
1959,
2499,
16693,
8,
21930,
9,
267,
21559,
82,
275,
6364,
14,
2499,
5003,
360,
396,
297,
9671,
63,
466,
29,
14945,
14,
18914,
3428,
12,
1511,
2968,
38,
998,
29,
9430,
1105,
267,
21559,
82,
14,
2499,
792,
8,
14945,
14,
792,
872,
2324,
360,
495,
698,
297,
20713,
14,
47,
2161,
1558,
430,
267,
21559,
82,
14,
2499,
792,
8,
14945,
14,
792,
872,
2324,
360,
442,
698,
297,
20713,
14,
47,
2161,
2674,
430,
267,
289,
275,
20713,
14,
5968,
8,
590,
82,
14,
1002,
5003,
872,
2324,
1012,
267,
289,
14,
1084,
38,
998,
8,
713,
9,
267,
289,
14,
1084,
792,
8,
16,
12,
283,
1421,
358,
267,
289,
14,
1084,
792,
8,
17,
12,
11869,
9,
267,
21559,
82,
14,
2499,
5968,
8,
70,
9,
267,
289,
275,
488,
267,
6364,
275,
488,
398,
17876,
275,
22507,
360,
11123,
908,
8,
21930,
395,
283,
396,
297,
283,
14945,
358,
267,
291,
14,
629,
8,
552,
8,
7300,
14,
955,
4000,
650,
9,
267,
4788,
275,
3842,
70,
14,
3215,
360,
9430,
659,
289,
14,
3215,
360,
495,
698,
659,
289,
14,
3215,
360,
442,
698,
1333,
367,
289,
315,
17876,
14,
362,
10807,
5106,
267,
291,
14,
629,
8,
7808,
12,
3842,
713,
12,
283,
1421,
297,
11869,
3948,
398,
4788,
275,
3842,
70,
14,
3215,
360,
9430,
659,
289,
14,
3215,
360,
495,
698,
1333,
367,
289,
315,
17876,
14,
362,
10807,
8,
7350,
5968,
2017,
1252,
409,
4131,
9093,
480,
495,
698,
275,
283,
1421,
7,
2237,
61,
267,
291,
14,
629,
8,
7808,
12,
3842,
713,
12,
283,
1421,
2023,
398,
4788,
275,
3842,
70,
14,
3215,
360,
9430,
659,
289,
14,
3215,
360,
495,
698,
1333,
367,
289,
315,
17876,
14,
362,
10807,
8,
7350,
5968,
2017,
1252,
409,
4131,
9093,
480,
9430,
275,
3144,
2237,
61,
267,
291,
14,
629,
8,
7808,
12,
3842,
713,
12,
283,
1421,
2023,
398,
754,
275,
359,
70,
459,
495,
698,
418,
367,
289,
315,
17876,
14,
27735,
1252,
362,
10807,
8,
7350,
5968,
2017,
1252,
409,
20113,
3466,
5379,
2941,
495,
698,
995,
17876,
14,
27735,
1252,
955,
4059,
61,
267,
291,
14,
629,
8,
1099,
12,
788,
1421,
1105,
398,
754,
275,
359,
70,
459,
9430,
418,
367,
289,
315,
17876,
14,
27735,
1252,
362,
10807,
8,
7350,
5968,
2017,
1252,
409,
20113,
3466,
5379,
2941,
9430,
995,
17876,
14,
27735,
1252,
955,
4059,
61,
267,
291,
14,
629,
8,
1099,
12,
359,
713,
566,
398,
327,
1379,
626,
1380,
314,
283,
9430,
7,
901,
365,
440,
663,
12,
5578,
22470,
365,
4224,
267,
289,
275,
26833,
342,
267,
289,
14,
409,
7304,
8,
7300,
14,
955,
1012,
267,
289,
14,
31674,
779,
403,
12,
283,
23292,
63,
344,
1105,
267,
334,
470,
12,
734,
63,
70,
9,
275,
17876,
14,
27735,
1252,
525,
10807,
779,
70,
566,
267,
291,
14,
629,
8,
548,
63,
70,
59,
16,
1055,
344,
1062,
4944,
9,
267,
291,
14,
629,
8,
548,
63,
70,
59,
16,
1055,
3215,
360,
9430,
659,
4944,
9,
267,
291,
14,
629,
8,
548,
63,
70,
59,
16,
1055,
3215,
360,
495,
698,
659,
283,
23292,
63,
344,
358,
398,
327,
1379,
626,
1380,
314,
283,
9430,
7,
901,
365,
663,
12,
652,
365,
7710,
1202,
370,
663,
314,
1305,
267,
289,
275,
26833,
342,
267,
289,
14,
409,
7304,
8,
7300,
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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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
] |
Sakiut/FalltoSkyBot
|
cogs/vote.py
|
1
|
4199
|
# -*- coding: utf-8 -*-
import asyncio
import discord
from discord.ext import commands
from libraries.library import *
class Vote:
def __init__(self,bot):
self.bot = bot
self.VoteState = None
self.Mess = None
self.Requester = None
self.subject = None
self.Voters = []
self.oui = None
self.non = None
@commands.group(pass_context=True)
async def vote(self, ctx):
"""Commandes de vote.
Utilisation :
.vote start <sujet du vote>
.vote stop"""
if ctx.invoked_subcommand is None:
await self.bot.delete_message(ctx.message)
await self.bot.say("```md\nSyntaxe invalide. Voir .help vote pour plus d'informations sur comment utiliser cette commande.\n```")
@vote.command(pass_context=True, no_pm=True)
async def start(self, ctx, *, subject : str):
"""Démarrer un vote"""
await self.bot.delete_message(ctx.message)
if self.VoteState == None:
self.subject = subject
self.Requester = ctx.message.author
self.VoteState = True
self.Voters = []
self.oui = 0
self.non = 0
self.VoteEmbed = discord.Embed()
self.VoteEmbed.title = "Vote : " + self.subject
self.VoteEmbed.colour = 0x3498db
self.VoteEmbed.set_footer(text = "Requested by {0}".format(self.Requester.name), icon_url = self.Requester.avatar_url)
self.VoteEmbed.add_field(name = "✅", value = self.oui)
self.VoteEmbed.add_field(name = "❎", value = self.non)
mess = await self.bot.say(embed=self.VoteEmbed)
self.Mess = mess
await self.bot.add_reaction(mess, "✅")
await self.bot.add_reaction(mess, "❎")
await asyncio.sleep(1)
while self.VoteState == True:
res = await self.bot.wait_for_reaction(["✅","❎"], message = self.Mess)
user = res.user
reaction = res.reaction
if user not in self.Voters:
if reaction.emoji == "✅":
await self.bot.remove_reaction(reaction.message, "✅", user)
self.Voters.append(user)
self.oui += 1
self.VoteEmbed.set_field_at(0, name = "✅", value = self.oui)
await self.bot.edit_message(self.Mess, embed=self.VoteEmbed)
elif reaction.emoji == "❎":
await self.bot.remove_reaction(reaction.message, "❎", user)
self.Voters.append(user)
self.non += 1
self.VoteEmbed.set_field_at(1, name = "❎", value = self.non)
await self.bot.edit_message(self.Mess, embed=self.VoteEmbed)
else:
await self.bot.remove_reaction(reaction.message, reaction.emoji, user)
else:
await self.bot.remove_reaction(reaction.message, reaction.emoji, user)
tmp = await self.bot.send_message(self.Mess.channel, "{0.mention} Vous avez déjà voté".format(user))
await asyncio.sleep(5)
await self.bot.delete_message(tmp)
else:
tmp = await self.bot.say('Vote déjà en cours')
await asyncio.sleep(5)
await self.bot.delete_message(tmp)
@vote.command(pass_context=True, no_pm=True)
async def stop(self, ctx):
"""Arrêter le vote en cours
Utilisable uniquement par le demandeur du vote déjà en cours."""
await self.bot.delete_message(ctx.message)
if self.VoteState == True:
self.VoteEmbed.title = "Vote : " + self.subject + " [TERMINÉ]"
await self.bot.edit_message(self.Mess, embed=self.VoteEmbed)
await self.bot.clear_reactions(self.Mess)
self.VoteState = None
else:
tmp = await self.bot.say('Aucun vote en cours')
await asyncio.sleep(5)
await self.bot.delete_message(tmp)
|
agpl-3.0
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
199,
646,
16195,
199,
646,
4339,
2181,
199,
504,
4339,
2181,
14,
832,
492,
3718,
199,
199,
504,
8363,
14,
4342,
492,
627,
199,
199,
533,
812,
1583,
26,
339,
347,
636,
826,
721,
277,
12,
3018,
304,
267,
291,
14,
3018,
275,
5888,
267,
291,
14,
54,
1583,
2223,
275,
488,
267,
291,
14,
1352,
385,
275,
488,
267,
291,
14,
497,
18246,
275,
488,
267,
291,
14,
5875,
275,
488,
267,
291,
14,
23956,
878,
275,
942,
267,
291,
14,
810,
73,
275,
488,
267,
291,
14,
2865,
275,
488,
339,
768,
4405,
14,
923,
8,
1529,
63,
1100,
29,
549,
9,
272,
5316,
347,
24337,
8,
277,
12,
4027,
304,
267,
408,
5150,
290,
3424,
477,
24337,
14,
398,
738,
280,
14392,
425,
520,
288,
1275,
14317,
1343,
665,
9648,
74,
386,
15776,
24337,
30,
288,
1275,
14317,
3631,
624,
398,
340,
4027,
14,
5350,
7620,
63,
954,
1531,
365,
488,
26,
288,
5517,
291,
14,
3018,
14,
1807,
63,
1188,
8,
3799,
14,
1188,
9,
288,
5517,
291,
14,
3018,
14,
19787,
480,
32323,
1064,
60,
78,
16626,
69,
315,
637,
2655,
14,
812,
19142,
1275,
3437,
24337,
299,
567,
12254,
366,
7,
262,
17308,
6296,
3721,
7678,
317,
332,
286,
386,
266,
1923,
290,
271,
3134,
78,
1040,
22446,
339,
768,
14317,
14,
1531,
8,
1529,
63,
1100,
29,
549,
12,
949,
63,
7073,
29,
549,
9,
272,
5316,
347,
1343,
8,
277,
12,
4027,
12,
9889,
5420,
520,
620,
304,
267,
408,
36,
5741,
4584,
3859,
625,
24337,
624,
398,
5517,
291,
14,
3018,
14,
1807,
63,
1188,
8,
3799,
14,
1188,
9,
267,
340,
291,
14,
54,
1583,
2223,
508,
488,
26,
953,
291,
14,
5875,
275,
5420,
288,
291,
14,
497,
18246,
275,
4027,
14,
1188,
14,
2502,
288,
291,
14,
54,
1583,
2223,
275,
715,
288,
291,
14,
23956,
878,
275,
942,
288,
291,
14,
810,
73,
275,
378,
288,
291,
14,
2865,
275,
378,
953,
291,
14,
54,
1583,
13200,
275,
4339,
2181,
14,
13200,
342,
288,
291,
14,
54,
1583,
13200,
14,
1213,
275,
298,
54,
1583,
520,
298,
435,
291,
14,
5875,
288,
291,
14,
54,
1583,
13200,
14,
14476,
275,
378,
88,
1082,
2905,
697,
288,
291,
14,
54,
1583,
13200,
14,
409,
63,
12781,
8,
505,
275,
298,
17935,
701,
469,
16,
5469,
908,
8,
277,
14,
497,
18246,
14,
354,
395,
7016,
63,
633,
275,
291,
14,
497,
18246,
14,
14584,
63,
633,
9,
288,
291,
14,
54,
1583,
13200,
14,
525,
63,
698,
8,
354,
275,
298,
159,
251,
228,
401,
574,
275,
291,
14,
810,
73,
9,
288,
291,
14,
54,
1583,
13200,
14,
525,
63,
698,
8,
354,
275,
298,
159,
252,
237,
401,
574,
275,
291,
14,
2865,
9,
953,
15634,
275,
5517,
291,
14,
3018,
14,
19787,
8,
6427,
29,
277,
14,
54,
1583,
13200,
9,
288,
291,
14,
1352,
385,
275,
15634,
953,
5517,
291,
14,
3018,
14,
525,
63,
29834,
8,
17091,
12,
298,
159,
251,
228,
531,
288,
5517,
291,
14,
3018,
14,
525,
63,
29834,
8,
17091,
12,
298,
159,
252,
237,
531,
288,
5517,
16195,
14,
4532,
8,
17,
9,
953,
1830,
291,
14,
54,
1583,
2223,
508,
715,
26,
355,
522,
275,
5517,
291,
14,
3018,
14,
2573,
63,
509,
63,
29834,
5234,
159,
251,
228,
2266,
159,
252,
237,
2255,
1245,
275,
291,
14,
1352,
385,
9,
355,
922,
275,
522,
14,
751,
355,
26909,
275,
522,
14,
29834,
2234,
340,
922,
440,
315,
291,
14,
23956,
878,
26,
490,
340,
26909,
14,
26445,
508,
298,
159,
251,
228,
582,
717,
5517,
291,
14,
3018,
14,
2168,
63,
29834,
8,
29834,
14,
1188,
12,
298,
159,
251,
228,
401,
922,
9,
717,
291,
14,
23956,
878,
14,
740,
8,
751,
9,
717,
291,
14,
810,
73,
847,
413,
717,
291,
14,
54,
1583,
13200,
14,
409,
63,
698,
63,
292,
8,
16,
12,
536,
275,
298,
159,
251,
228,
401,
574,
275,
291,
14,
810,
73,
9,
9453,
5517,
291,
14,
3018,
14,
3773,
63,
1188,
8,
277,
14,
1352,
385,
12,
6441,
29,
277,
14,
54,
1583,
13200,
9,
4951,
916,
26909,
14,
26445,
508,
298,
159,
252,
237,
582,
717,
5517,
291,
14,
3018,
14,
2168,
63,
29834,
8,
29834,
14,
1188,
12,
298,
159,
252,
237,
401,
922,
9,
717,
291,
14,
23956,
878,
14,
740,
8,
751,
9,
717,
291,
14,
2865,
847,
413,
717,
291,
14,
54,
1583,
13200,
14,
409,
63,
698,
63,
292,
8,
17,
12,
536,
275,
298,
159,
252,
237,
401,
574,
275,
291,
14,
2865,
9,
9453,
5517,
291,
14,
3018,
14,
3773,
63,
1188,
8,
277,
14,
1352,
385,
12,
6441,
29,
277,
14,
54,
1583,
13200,
9,
490,
587,
26,
717,
5517,
291,
14,
3018,
14,
2168,
63,
29834,
8,
29834,
14,
1188,
12,
26909,
14,
26445,
12,
922,
9,
355,
587,
26,
490,
5517,
291,
14,
3018,
14,
2168,
63,
29834,
8,
29834,
14,
1188,
12,
26909,
14,
26445,
12,
922,
9,
490,
3529,
275,
5517,
291,
14,
3018,
14,
2254,
63,
1188,
8,
277,
14,
1352,
385,
14,
2775,
12,
5310,
16,
14,
32016,
93,
812,
1785,
282,
432,
90,
366,
5741,
74,
26482,
373,
357,
5741,
1674,
908,
8,
751,
430,
490,
5517,
16195,
14,
4532,
8,
21,
9,
490,
5517,
291,
14,
3018,
14,
1807,
63,
1188,
8,
2791,
9,
398,
587,
26,
288,
3529,
275,
5517,
291,
14,
3018,
14,
19787,
360,
54,
1583,
366,
5741,
74,
26482,
655,
512,
21050,
358,
288,
5517,
16195,
14,
4532,
8,
21,
9,
288,
5517,
291,
14,
3018,
14,
1807,
63,
1188,
8,
2791,
9,
339,
768,
14317,
14,
1531,
8,
1529,
63,
1100,
29,
549,
12,
949,
63,
7073,
29,
549,
9,
272,
5316,
347,
3631,
8,
277,
12,
4027,
304,
267,
408,
22011,
28413,
351,
1026,
24337,
655,
512,
21050,
267,
738,
280,
14392,
461,
3747,
434,
623,
1026,
477,
1237,
271,
300,
15776,
24337,
366,
5741,
74,
26482,
655,
512,
21050,
1041,
398,
5517,
291,
14,
3018,
14,
1807,
63,
1188,
8,
3799,
14,
1188,
9,
267,
340,
291,
14,
54
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
199,
646,
16195,
199,
646,
4339,
2181,
199,
504,
4339,
2181,
14,
832,
492,
3718,
199,
199,
504,
8363,
14,
4342,
492,
627,
199,
199,
533,
812,
1583,
26,
339,
347,
636,
826,
721,
277,
12,
3018,
304,
267,
291,
14,
3018,
275,
5888,
267,
291,
14,
54,
1583,
2223,
275,
488,
267,
291,
14,
1352,
385,
275,
488,
267,
291,
14,
497,
18246,
275,
488,
267,
291,
14,
5875,
275,
488,
267,
291,
14,
23956,
878,
275,
942,
267,
291,
14,
810,
73,
275,
488,
267,
291,
14,
2865,
275,
488,
339,
768,
4405,
14,
923,
8,
1529,
63,
1100,
29,
549,
9,
272,
5316,
347,
24337,
8,
277,
12,
4027,
304,
267,
408,
5150,
290,
3424,
477,
24337,
14,
398,
738,
280,
14392,
425,
520,
288,
1275,
14317,
1343,
665,
9648,
74,
386,
15776,
24337,
30,
288,
1275,
14317,
3631,
624,
398,
340,
4027,
14,
5350,
7620,
63,
954,
1531,
365,
488,
26,
288,
5517,
291,
14,
3018,
14,
1807,
63,
1188,
8,
3799,
14,
1188,
9,
288,
5517,
291,
14,
3018,
14,
19787,
480,
32323,
1064,
60,
78,
16626,
69,
315,
637,
2655,
14,
812,
19142,
1275,
3437,
24337,
299,
567,
12254,
366,
7,
262,
17308,
6296,
3721,
7678,
317,
332,
286,
386,
266,
1923,
290,
271,
3134,
78,
1040,
22446,
339,
768,
14317,
14,
1531,
8,
1529,
63,
1100,
29,
549,
12,
949,
63,
7073,
29,
549,
9,
272,
5316,
347,
1343,
8,
277,
12,
4027,
12,
9889,
5420,
520,
620,
304,
267,
408,
36,
5741,
4584,
3859,
625,
24337,
624,
398,
5517,
291,
14,
3018,
14,
1807,
63,
1188,
8,
3799,
14,
1188,
9,
267,
340,
291,
14,
54,
1583,
2223,
508,
488,
26,
953,
291,
14,
5875,
275,
5420,
288,
291,
14,
497,
18246,
275,
4027,
14,
1188,
14,
2502,
288,
291,
14,
54,
1583,
2223,
275,
715,
288,
291,
14,
23956,
878,
275,
942,
288,
291,
14,
810,
73,
275,
378,
288,
291,
14,
2865,
275,
378,
953,
291,
14,
54,
1583,
13200,
275,
4339,
2181,
14,
13200,
342,
288,
291,
14,
54,
1583,
13200,
14,
1213,
275,
298,
54,
1583,
520,
298,
435,
291,
14,
5875,
288,
291,
14,
54,
1583,
13200,
14,
14476,
275,
378,
88,
1082,
2905,
697,
288,
291,
14,
54,
1583,
13200,
14,
409,
63,
12781,
8,
505,
275,
298,
17935,
701,
469,
16,
5469,
908,
8,
277,
14,
497,
18246,
14,
354,
395,
7016,
63,
633,
275,
291,
14,
497,
18246,
14,
14584,
63,
633,
9,
288,
291,
14,
54,
1583,
13200,
14,
525,
63,
698,
8,
354,
275,
298,
159,
251,
228,
401,
574,
275,
291,
14,
810,
73,
9,
288,
291,
14,
54,
1583,
13200,
14,
525,
63,
698,
8,
354,
275,
298,
159,
252,
237,
401,
574,
275,
291,
14,
2865,
9,
953,
15634,
275,
5517,
291,
14,
3018,
14,
19787,
8,
6427,
29,
277,
14,
54,
1583,
13200,
9,
288,
291,
14,
1352,
385,
275,
15634,
953,
5517,
291,
14,
3018,
14,
525,
63,
29834,
8,
17091,
12,
298,
159,
251,
228,
531,
288,
5517,
291,
14,
3018,
14,
525,
63,
29834,
8,
17091,
12,
298,
159,
252,
237,
531,
288,
5517,
16195,
14,
4532,
8,
17,
9,
953,
1830,
291,
14,
54,
1583,
2223,
508,
715,
26,
355,
522,
275,
5517,
291,
14,
3018,
14,
2573,
63,
509,
63,
29834,
5234,
159,
251,
228,
2266,
159,
252,
237,
2255,
1245,
275,
291,
14,
1352,
385,
9,
355,
922,
275,
522,
14,
751,
355,
26909,
275,
522,
14,
29834,
2234,
340,
922,
440,
315,
291,
14,
23956,
878,
26,
490,
340,
26909,
14,
26445,
508,
298,
159,
251,
228,
582,
717,
5517,
291,
14,
3018,
14,
2168,
63,
29834,
8,
29834,
14,
1188,
12,
298,
159,
251,
228,
401,
922,
9,
717,
291,
14,
23956,
878,
14,
740,
8,
751,
9,
717,
291,
14,
810,
73,
847,
413,
717,
291,
14,
54,
1583,
13200,
14,
409,
63,
698,
63,
292,
8,
16,
12,
536,
275,
298,
159,
251,
228,
401,
574,
275,
291,
14,
810,
73,
9,
9453,
5517,
291,
14,
3018,
14,
3773,
63,
1188,
8,
277,
14,
1352,
385,
12,
6441,
29,
277,
14,
54,
1583,
13200,
9,
4951,
916,
26909,
14,
26445,
508,
298,
159,
252,
237,
582,
717,
5517,
291,
14,
3018,
14,
2168,
63,
29834,
8,
29834,
14,
1188,
12,
298,
159,
252,
237,
401,
922,
9,
717,
291,
14,
23956,
878,
14,
740,
8,
751,
9,
717,
291,
14,
2865,
847,
413,
717,
291,
14,
54,
1583,
13200,
14,
409,
63,
698,
63,
292,
8,
17,
12,
536,
275,
298,
159,
252,
237,
401,
574,
275,
291,
14,
2865,
9,
9453,
5517,
291,
14,
3018,
14,
3773,
63,
1188,
8,
277,
14,
1352,
385,
12,
6441,
29,
277,
14,
54,
1583,
13200,
9,
490,
587,
26,
717,
5517,
291,
14,
3018,
14,
2168,
63,
29834,
8,
29834,
14,
1188,
12,
26909,
14,
26445,
12,
922,
9,
355,
587,
26,
490,
5517,
291,
14,
3018,
14,
2168,
63,
29834,
8,
29834,
14,
1188,
12,
26909,
14,
26445,
12,
922,
9,
490,
3529,
275,
5517,
291,
14,
3018,
14,
2254,
63,
1188,
8,
277,
14,
1352,
385,
14,
2775,
12,
5310,
16,
14,
32016,
93,
812,
1785,
282,
432,
90,
366,
5741,
74,
26482,
373,
357,
5741,
1674,
908,
8,
751,
430,
490,
5517,
16195,
14,
4532,
8,
21,
9,
490,
5517,
291,
14,
3018,
14,
1807,
63,
1188,
8,
2791,
9,
398,
587,
26,
288,
3529,
275,
5517,
291,
14,
3018,
14,
19787,
360,
54,
1583,
366,
5741,
74,
26482,
655,
512,
21050,
358,
288,
5517,
16195,
14,
4532,
8,
21,
9,
288,
5517,
291,
14,
3018,
14,
1807,
63,
1188,
8,
2791,
9,
339,
768,
14317,
14,
1531,
8,
1529,
63,
1100,
29,
549,
12,
949,
63,
7073,
29,
549,
9,
272,
5316,
347,
3631,
8,
277,
12,
4027,
304,
267,
408,
22011,
28413,
351,
1026,
24337,
655,
512,
21050,
267,
738,
280,
14392,
461,
3747,
434,
623,
1026,
477,
1237,
271,
300,
15776,
24337,
366,
5741,
74,
26482,
655,
512,
21050,
1041,
398,
5517,
291,
14,
3018,
14,
1807,
63,
1188,
8,
3799,
14,
1188,
9,
267,
340,
291,
14,
54,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
isandlaTech/cohorte-demos
|
led/dump/led-demo-raspberry/cohorte/dist/cohorte-1.0.0-1.0.0-20141201.234602-19-python-distribution/repo/requests/packages/urllib3/connectionpool.py
|
155
|
29526
|
import errno
import logging
import sys
import warnings
from socket import error as SocketError, timeout as SocketTimeout
import socket
try: # Python 3
from queue import LifoQueue, Empty, Full
except ImportError:
from Queue import LifoQueue, Empty, Full
import Queue as _ # Platform-specific: Windows
from .exceptions import (
ClosedPoolError,
ProtocolError,
EmptyPoolError,
HostChangedError,
LocationValueError,
MaxRetryError,
ProxyError,
ReadTimeoutError,
SSLError,
TimeoutError,
InsecureRequestWarning,
)
from .packages.ssl_match_hostname import CertificateError
from .packages import six
from .connection import (
port_by_scheme,
DummyConnection,
HTTPConnection, HTTPSConnection, VerifiedHTTPSConnection,
HTTPException, BaseSSLError, ConnectionError
)
from .request import RequestMethods
from .response import HTTPResponse
from .util.connection import is_connection_dropped
from .util.retry import Retry
from .util.timeout import Timeout
from .util.url import get_host
xrange = six.moves.xrange
log = logging.getLogger(__name__)
_Default = object()
## Pool objects
class ConnectionPool(object):
"""
Base class for all connection pools, such as
:class:`.HTTPConnectionPool` and :class:`.HTTPSConnectionPool`.
"""
scheme = None
QueueCls = LifoQueue
def __init__(self, host, port=None):
if not host:
raise LocationValueError("No host specified.")
# httplib doesn't like it when we include brackets in ipv6 addresses
self.host = host.strip('[]')
self.port = port
def __str__(self):
return '%s(host=%r, port=%r)' % (type(self).__name__,
self.host, self.port)
# This is taken from http://hg.python.org/cpython/file/7aaba721ebc0/Lib/socket.py#l252
_blocking_errnos = set([errno.EAGAIN, errno.EWOULDBLOCK])
class HTTPConnectionPool(ConnectionPool, RequestMethods):
"""
Thread-safe connection pool for one host.
:param host:
Host used for this HTTP Connection (e.g. "localhost"), passed into
:class:`httplib.HTTPConnection`.
:param port:
Port used for this HTTP Connection (None is equivalent to 80), passed
into :class:`httplib.HTTPConnection`.
:param strict:
Causes BadStatusLine to be raised if the status line can't be parsed
as a valid HTTP/1.0 or 1.1 status line, passed into
:class:`httplib.HTTPConnection`.
.. note::
Only works in Python 2. This parameter is ignored in Python 3.
:param timeout:
Socket timeout in seconds for each individual connection. This can
be a float or integer, which sets the timeout for the HTTP request,
or an instance of :class:`urllib3.util.Timeout` which gives you more
fine-grained control over request timeouts. After the constructor has
been parsed, this is always a `urllib3.util.Timeout` object.
:param maxsize:
Number of connections to save that can be reused. More than 1 is useful
in multithreaded situations. If ``block`` is set to false, more
connections will be created but they will not be saved once they've
been used.
:param block:
If set to True, no more than ``maxsize`` connections will be used at
a time. When no free connections are available, the call will block
until a connection has been released. This is a useful side effect for
particular multithreaded situations where one does not want to use more
than maxsize connections per host to prevent flooding.
:param headers:
Headers to include with all requests, unless other headers are given
explicitly.
:param retries:
Retry configuration to use by default with requests in this pool.
:param _proxy:
Parsed proxy URL, should not be used directly, instead, see
:class:`urllib3.connectionpool.ProxyManager`"
:param _proxy_headers:
A dictionary with proxy headers, should not be used directly,
instead, see :class:`urllib3.connectionpool.ProxyManager`"
:param \**conn_kw:
Additional parameters are used to create fresh :class:`urllib3.connection.HTTPConnection`,
:class:`urllib3.connection.HTTPSConnection` instances.
"""
scheme = 'http'
ConnectionCls = HTTPConnection
def __init__(self, host, port=None, strict=False,
timeout=Timeout.DEFAULT_TIMEOUT, maxsize=1, block=False,
headers=None, retries=None,
_proxy=None, _proxy_headers=None,
**conn_kw):
ConnectionPool.__init__(self, host, port)
RequestMethods.__init__(self, headers)
self.strict = strict
if not isinstance(timeout, Timeout):
timeout = Timeout.from_float(timeout)
if retries is None:
retries = Retry.DEFAULT
self.timeout = timeout
self.retries = retries
self.pool = self.QueueCls(maxsize)
self.block = block
self.proxy = _proxy
self.proxy_headers = _proxy_headers or {}
# Fill the queue up so that doing get() on it will block properly
for _ in xrange(maxsize):
self.pool.put(None)
# These are mostly for testing and debugging purposes.
self.num_connections = 0
self.num_requests = 0
self.conn_kw = conn_kw
if self.proxy:
# Enable Nagle's algorithm for proxies, to avoid packet fragmentation.
# We cannot know if the user has added default socket options, so we cannot replace the
# list.
self.conn_kw.setdefault('socket_options', [])
def _new_conn(self):
"""
Return a fresh :class:`HTTPConnection`.
"""
self.num_connections += 1
log.info("Starting new HTTP connection (%d): %s" %
(self.num_connections, self.host))
conn = self.ConnectionCls(host=self.host, port=self.port,
timeout=self.timeout.connect_timeout,
strict=self.strict, **self.conn_kw)
return conn
def _get_conn(self, timeout=None):
"""
Get a connection. Will return a pooled connection if one is available.
If no connections are available and :prop:`.block` is ``False``, then a
fresh connection is returned.
:param timeout:
Seconds to wait before giving up and raising
:class:`urllib3.exceptions.EmptyPoolError` if the pool is empty and
:prop:`.block` is ``True``.
"""
conn = None
try:
conn = self.pool.get(block=self.block, timeout=timeout)
except AttributeError: # self.pool is None
raise ClosedPoolError(self, "Pool is closed.")
except Empty:
if self.block:
raise EmptyPoolError(self,
"Pool reached maximum size and no more "
"connections are allowed.")
pass # Oh well, we'll create a new connection then
# If this is a persistent connection, check if it got disconnected
if conn and is_connection_dropped(conn):
log.info("Resetting dropped connection: %s" % self.host)
conn.close()
if getattr(conn, 'auto_open', 1) == 0:
# This is a proxied connection that has been mutated by
# httplib._tunnel() and cannot be reused (since it would
# attempt to bypass the proxy)
conn = None
return conn or self._new_conn()
def _put_conn(self, conn):
"""
Put a connection back into the pool.
:param conn:
Connection object for the current host and port as returned by
:meth:`._new_conn` or :meth:`._get_conn`.
If the pool is already full, the connection is closed and discarded
because we exceeded maxsize. If connections are discarded frequently,
then maxsize should be increased.
If the pool is closed, then the connection will be closed and discarded.
"""
try:
self.pool.put(conn, block=False)
return # Everything is dandy, done.
except AttributeError:
# self.pool is None.
pass
except Full:
# This should never happen if self.block == True
log.warning(
"Connection pool is full, discarding connection: %s" %
self.host)
# Connection never got put back into the pool, close it.
if conn:
conn.close()
def _validate_conn(self, conn):
"""
Called right before a request is made, after the socket is created.
"""
pass
def _get_timeout(self, timeout):
""" Helper that always returns a :class:`urllib3.util.Timeout` """
if timeout is _Default:
return self.timeout.clone()
if isinstance(timeout, Timeout):
return timeout.clone()
else:
# User passed us an int/float. This is for backwards compatibility,
# can be removed later
return Timeout.from_float(timeout)
def _raise_timeout(self, err, url, timeout_value):
"""Is the error actually a timeout? Will raise a ReadTimeout or pass"""
if isinstance(err, SocketTimeout):
raise ReadTimeoutError(self, url, "Read timed out. (read timeout=%s)" % timeout_value)
# See the above comment about EAGAIN in Python 3. In Python 2 we have
# to specifically catch it and throw the timeout error
if hasattr(err, 'errno') and err.errno in _blocking_errnos:
raise ReadTimeoutError(self, url, "Read timed out. (read timeout=%s)" % timeout_value)
# Catch possible read timeouts thrown as SSL errors. If not the
# case, rethrow the original. We need to do this because of:
# http://bugs.python.org/issue10272
if 'timed out' in str(err) or 'did not complete (read)' in str(err): # Python 2.6
raise ReadTimeoutError(self, url, "Read timed out. (read timeout=%s)" % timeout_value)
def _make_request(self, conn, method, url, timeout=_Default,
**httplib_request_kw):
"""
Perform a request on a given urllib connection object taken from our
pool.
:param conn:
a connection from one of our connection pools
:param timeout:
Socket timeout in seconds for the request. This can be a
float or integer, which will set the same timeout value for
the socket connect and the socket read, or an instance of
:class:`urllib3.util.Timeout`, which gives you more fine-grained
control over your timeouts.
"""
self.num_requests += 1
timeout_obj = self._get_timeout(timeout)
timeout_obj.start_connect()
conn.timeout = timeout_obj.connect_timeout
# Trigger any extra validation we need to do.
try:
self._validate_conn(conn)
except (SocketTimeout, BaseSSLError) as e:
# Py2 raises this as a BaseSSLError, Py3 raises it as socket timeout.
self._raise_timeout(err=e, url=url, timeout_value=conn.timeout)
raise
# conn.request() calls httplib.*.request, not the method in
# urllib3.request. It also calls makefile (recv) on the socket.
conn.request(method, url, **httplib_request_kw)
# Reset the timeout for the recv() on the socket
read_timeout = timeout_obj.read_timeout
# App Engine doesn't have a sock attr
if getattr(conn, 'sock', None):
# In Python 3 socket.py will catch EAGAIN and return None when you
# try and read into the file pointer created by http.client, which
# instead raises a BadStatusLine exception. Instead of catching
# the exception and assuming all BadStatusLine exceptions are read
# timeouts, check for a zero timeout before making the request.
if read_timeout == 0:
raise ReadTimeoutError(
self, url, "Read timed out. (read timeout=%s)" % read_timeout)
if read_timeout is Timeout.DEFAULT_TIMEOUT:
conn.sock.settimeout(socket.getdefaulttimeout())
else: # None or a value
conn.sock.settimeout(read_timeout)
# Receive the response from the server
try:
try: # Python 2.7+, use buffering of HTTP responses
httplib_response = conn.getresponse(buffering=True)
except TypeError: # Python 2.6 and older
httplib_response = conn.getresponse()
except (SocketTimeout, BaseSSLError, SocketError) as e:
self._raise_timeout(err=e, url=url, timeout_value=read_timeout)
raise
# AppEngine doesn't have a version attr.
http_version = getattr(conn, '_http_vsn_str', 'HTTP/?')
log.debug("\"%s %s %s\" %s %s" % (method, url, http_version,
httplib_response.status,
httplib_response.length))
return httplib_response
def close(self):
"""
Close all pooled connections and disable the pool.
"""
# Disable access to the pool
old_pool, self.pool = self.pool, None
try:
while True:
conn = old_pool.get(block=False)
if conn:
conn.close()
except Empty:
pass # Done.
def is_same_host(self, url):
"""
Check if the given ``url`` is a member of the same host as this
connection pool.
"""
if url.startswith('/'):
return True
# TODO: Add optional support for socket.gethostbyname checking.
scheme, host, port = get_host(url)
# Use explicit default port for comparison when none is given
if self.port and not port:
port = port_by_scheme.get(scheme)
elif not self.port and port == port_by_scheme.get(scheme):
port = None
return (scheme, host, port) == (self.scheme, self.host, self.port)
def urlopen(self, method, url, body=None, headers=None, retries=None,
redirect=True, assert_same_host=True, timeout=_Default,
pool_timeout=None, release_conn=None, **response_kw):
"""
Get a connection from the pool and perform an HTTP request. This is the
lowest level call for making a request, so you'll need to specify all
the raw details.
.. note::
More commonly, it's appropriate to use a convenience method provided
by :class:`.RequestMethods`, such as :meth:`request`.
.. note::
`release_conn` will only behave as expected if
`preload_content=False` because we want to make
`preload_content=False` the default behaviour someday soon without
breaking backwards compatibility.
:param method:
HTTP request method (such as GET, POST, PUT, etc.)
:param body:
Data to send in the request body (useful for creating
POST requests, see HTTPConnectionPool.post_url for
more convenience).
:param headers:
Dictionary of custom headers to send, such as User-Agent,
If-None-Match, etc. If None, pool headers are used. If provided,
these headers completely replace any pool-specific headers.
:param retries:
Configure the number of retries to allow before raising a
:class:`~urllib3.exceptions.MaxRetryError` exception.
Pass ``None`` to retry until you receive a response. Pass a
:class:`~urllib3.util.retry.Retry` object for fine-grained control
over different types of retries.
Pass an integer number to retry connection errors that many times,
but no other types of errors. Pass zero to never retry.
If ``False``, then retries are disabled and any exception is raised
immediately. Also, instead of raising a MaxRetryError on redirects,
the redirect response will be returned.
:type retries: :class:`~urllib3.util.retry.Retry`, False, or an int.
:param redirect:
If True, automatically handle redirects (status codes 301, 302,
303, 307, 308). Each redirect counts as a retry. Disabling retries
will disable redirect, too.
:param assert_same_host:
If ``True``, will make sure that the host of the pool requests is
consistent else will raise HostChangedError. When False, you can
use the pool on an HTTP proxy and request foreign hosts.
:param timeout:
If specified, overrides the default timeout for this one
request. It may be a float (in seconds) or an instance of
:class:`urllib3.util.Timeout`.
:param pool_timeout:
If set and the pool is set to block=True, then this method will
block for ``pool_timeout`` seconds and raise EmptyPoolError if no
connection is available within the time period.
:param release_conn:
If False, then the urlopen call will not release the connection
back into the pool once a response is received (but will release if
you read the entire contents of the response such as when
`preload_content=True`). This is useful if you're not preloading
the response's content immediately. You will need to call
``r.release_conn()`` on the response ``r`` to return the connection
back into the pool. If None, it takes the value of
``response_kw.get('preload_content', True)``.
:param \**response_kw:
Additional parameters are passed to
:meth:`urllib3.response.HTTPResponse.from_httplib`
"""
if headers is None:
headers = self.headers
if not isinstance(retries, Retry):
retries = Retry.from_int(retries, redirect=redirect, default=self.retries)
if release_conn is None:
release_conn = response_kw.get('preload_content', True)
# Check host
if assert_same_host and not self.is_same_host(url):
raise HostChangedError(self, url, retries)
conn = None
# Merge the proxy headers. Only do this in HTTP. We have to copy the
# headers dict so we can safely change it without those changes being
# reflected in anyone else's copy.
if self.scheme == 'http':
headers = headers.copy()
headers.update(self.proxy_headers)
# Must keep the exception bound to a separate variable or else Python 3
# complains about UnboundLocalError.
err = None
try:
# Request a connection from the queue.
conn = self._get_conn(timeout=pool_timeout)
# Make the request on the httplib connection object.
httplib_response = self._make_request(conn, method, url,
timeout=timeout,
body=body, headers=headers)
# If we're going to release the connection in ``finally:``, then
# the request doesn't need to know about the connection. Otherwise
# it will also try to release it and we'll have a double-release
# mess.
response_conn = not release_conn and conn
# Import httplib's response into our own wrapper object
response = HTTPResponse.from_httplib(httplib_response,
pool=self,
connection=response_conn,
**response_kw)
# else:
# The connection will be put back into the pool when
# ``response.release_conn()`` is called (implicitly by
# ``response.read()``)
except Empty:
# Timed out by queue.
raise EmptyPoolError(self, "No pool connections are available.")
except (BaseSSLError, CertificateError) as e:
# Close the connection. If a connection is reused on which there
# was a Certificate error, the next request will certainly raise
# another Certificate error.
if conn:
conn.close()
conn = None
raise SSLError(e)
except (TimeoutError, HTTPException, SocketError, ConnectionError) as e:
if conn:
# Discard the connection for these exceptions. It will be
# be replaced during the next _get_conn() call.
conn.close()
conn = None
stacktrace = sys.exc_info()[2]
if isinstance(e, SocketError) and self.proxy:
e = ProxyError('Cannot connect to proxy.', e)
elif isinstance(e, (SocketError, HTTPException)):
e = ProtocolError('Connection aborted.', e)
retries = retries.increment(method, url, error=e,
_pool=self, _stacktrace=stacktrace)
retries.sleep()
# Keep track of the error for the retry warning.
err = e
finally:
if release_conn:
# Put the connection back to be reused. If the connection is
# expired then it will be None, which will get replaced with a
# fresh connection during _get_conn.
self._put_conn(conn)
if not conn:
# Try again
log.warning("Retrying (%r) after connection "
"broken by '%r': %s" % (retries, err, url))
return self.urlopen(method, url, body, headers, retries,
redirect, assert_same_host,
timeout=timeout, pool_timeout=pool_timeout,
release_conn=release_conn, **response_kw)
# Handle redirect?
redirect_location = redirect and response.get_redirect_location()
if redirect_location:
if response.status == 303:
method = 'GET'
try:
retries = retries.increment(method, url, response=response, _pool=self)
except MaxRetryError:
if retries.raise_on_redirect:
raise
return response
log.info("Redirecting %s -> %s" % (url, redirect_location))
return self.urlopen(method, redirect_location, body, headers,
retries=retries, redirect=redirect,
assert_same_host=assert_same_host,
timeout=timeout, pool_timeout=pool_timeout,
release_conn=release_conn, **response_kw)
# Check if we should retry the HTTP response.
if retries.is_forced_retry(method, status_code=response.status):
retries = retries.increment(method, url, response=response, _pool=self)
retries.sleep()
log.info("Forced retry: %s" % url)
return self.urlopen(method, url, body, headers,
retries=retries, redirect=redirect,
assert_same_host=assert_same_host,
timeout=timeout, pool_timeout=pool_timeout,
release_conn=release_conn, **response_kw)
return response
class HTTPSConnectionPool(HTTPConnectionPool):
"""
Same as :class:`.HTTPConnectionPool`, but HTTPS.
When Python is compiled with the :mod:`ssl` module, then
:class:`.VerifiedHTTPSConnection` is used, which *can* verify certificates,
instead of :class:`.HTTPSConnection`.
:class:`.VerifiedHTTPSConnection` uses one of ``assert_fingerprint``,
``assert_hostname`` and ``host`` in this order to verify connections.
If ``assert_hostname`` is False, no verification is done.
The ``key_file``, ``cert_file``, ``cert_reqs``, ``ca_certs`` and
``ssl_version`` are only used if :mod:`ssl` is available and are fed into
:meth:`urllib3.util.ssl_wrap_socket` to upgrade the connection socket
into an SSL socket.
"""
scheme = 'https'
ConnectionCls = HTTPSConnection
def __init__(self, host, port=None,
strict=False, timeout=Timeout.DEFAULT_TIMEOUT, maxsize=1,
block=False, headers=None, retries=None,
_proxy=None, _proxy_headers=None,
key_file=None, cert_file=None, cert_reqs=None,
ca_certs=None, ssl_version=None,
assert_hostname=None, assert_fingerprint=None,
**conn_kw):
HTTPConnectionPool.__init__(self, host, port, strict, timeout, maxsize,
block, headers, retries, _proxy, _proxy_headers,
**conn_kw)
self.key_file = key_file
self.cert_file = cert_file
self.cert_reqs = cert_reqs
self.ca_certs = ca_certs
self.ssl_version = ssl_version
self.assert_hostname = assert_hostname
self.assert_fingerprint = assert_fingerprint
def _prepare_conn(self, conn):
"""
Prepare the ``connection`` for :meth:`urllib3.util.ssl_wrap_socket`
and establish the tunnel if proxy is used.
"""
if isinstance(conn, VerifiedHTTPSConnection):
conn.set_cert(key_file=self.key_file,
cert_file=self.cert_file,
cert_reqs=self.cert_reqs,
ca_certs=self.ca_certs,
assert_hostname=self.assert_hostname,
assert_fingerprint=self.assert_fingerprint)
conn.ssl_version = self.ssl_version
if self.proxy is not None:
# Python 2.7+
try:
set_tunnel = conn.set_tunnel
except AttributeError: # Platform-specific: Python 2.6
set_tunnel = conn._set_tunnel
if sys.version_info <= (2, 6, 4) and not self.proxy_headers: # Python 2.6.4 and older
set_tunnel(self.host, self.port)
else:
set_tunnel(self.host, self.port, self.proxy_headers)
# Establish tunnel connection early, because otherwise httplib
# would improperly set Host: header to proxy's IP:port.
conn.connect()
return conn
def _new_conn(self):
"""
Return a fresh :class:`httplib.HTTPSConnection`.
"""
self.num_connections += 1
log.info("Starting new HTTPS connection (%d): %s"
% (self.num_connections, self.host))
if not self.ConnectionCls or self.ConnectionCls is DummyConnection:
# Platform-specific: Python without ssl
raise SSLError("Can't connect to HTTPS URL because the SSL "
"module is not available.")
actual_host = self.host
actual_port = self.port
if self.proxy is not None:
actual_host = self.proxy.host
actual_port = self.proxy.port
conn = self.ConnectionCls(host=actual_host, port=actual_port,
timeout=self.timeout.connect_timeout,
strict=self.strict, **self.conn_kw)
return self._prepare_conn(conn)
def _validate_conn(self, conn):
"""
Called right before a request is made, after the socket is created.
"""
super(HTTPSConnectionPool, self)._validate_conn(conn)
# Force connect early to allow us to validate the connection.
if not getattr(conn, 'sock', None): # AppEngine might not have `.sock`
conn.connect()
if not conn.is_verified:
warnings.warn((
'Unverified HTTPS request is being made. '
'Adding certificate verification is strongly advised. See: '
'https://urllib3.readthedocs.org/en/latest/security.html'),
InsecureRequestWarning)
def connection_from_url(url, **kw):
"""
Given a url, return an :class:`.ConnectionPool` instance of its host.
This is a shortcut for not having to parse out the scheme, host, and port
of the url before creating an :class:`.ConnectionPool` instance.
:param url:
Absolute URL string that must include the scheme. Port is optional.
:param \**kw:
Passes additional parameters to the constructor of the appropriate
:class:`.ConnectionPool`. Useful for specifying things like
timeout, maxsize, headers, etc.
Example::
>>> conn = connection_from_url('http://google.com/')
>>> r = conn.request('GET', '/')
"""
scheme, host, port = get_host(url)
if scheme == 'https':
return HTTPSConnectionPool(host, port=port, **kw)
else:
return HTTPConnectionPool(host, port=port, **kw)
|
apache-2.0
|
[
646,
7554,
199,
646,
2050,
199,
646,
984,
199,
646,
3598,
199,
199,
504,
2838,
492,
1125,
465,
17766,
547,
12,
2653,
465,
17766,
6372,
199,
646,
2838,
199,
199,
893,
26,
221,
327,
2018,
650,
272,
687,
4126,
492,
24157,
545,
3737,
12,
9630,
12,
16579,
199,
2590,
3545,
26,
272,
687,
10703,
492,
24157,
545,
3737,
12,
9630,
12,
16579,
272,
492,
10703,
465,
485,
221,
327,
16078,
13,
6100,
26,
5417,
421,
199,
504,
1275,
3924,
492,
334,
272,
5980,
939,
5453,
547,
12,
272,
30797,
12,
272,
9630,
5453,
547,
12,
272,
10891,
6970,
547,
12,
272,
12625,
3393,
12,
272,
8228,
12989,
547,
12,
272,
12373,
547,
12,
272,
5574,
19382,
12,
272,
7799,
547,
12,
272,
31886,
12,
272,
1010,
7817,
2017,
3849,
12,
199,
9,
199,
504,
1275,
5154,
14,
4266,
63,
1431,
63,
4269,
492,
31953,
199,
504,
1275,
5154,
492,
3816,
199,
504,
1275,
2105,
492,
334,
272,
1844,
63,
991,
63,
5512,
12,
272,
9762,
3225,
12,
272,
3101,
3225,
12,
14147,
3225,
12,
5444,
4541,
27945,
12,
272,
28185,
12,
3523,
27102,
12,
25417,
199,
9,
199,
504,
1275,
1069,
492,
4784,
10385,
199,
504,
1275,
1310,
492,
29034,
199,
199,
504,
1275,
1974,
14,
2105,
492,
365,
63,
2105,
63,
27557,
199,
504,
1275,
1974,
14,
7154,
492,
20506,
199,
504,
1275,
1974,
14,
2593,
492,
12878,
199,
504,
1275,
1974,
14,
633,
492,
664,
63,
1102,
421,
199,
21120,
275,
3816,
14,
4912,
14,
21120,
199,
199,
793,
275,
2050,
14,
5572,
3460,
354,
3368,
199,
199,
63,
2698,
275,
909,
342,
421,
199,
309,
15553,
2251,
199,
533,
8113,
5453,
8,
785,
304,
272,
408,
272,
3523,
1021,
367,
1006,
1950,
20092,
12,
4066,
465,
272,
520,
533,
5026,
19114,
5453,
64,
436,
520,
533,
5026,
14921,
23929,
2313,
272,
408,
339,
5687,
275,
488,
272,
10703,
24342,
275,
24157,
545,
3737,
339,
347,
636,
826,
721,
277,
12,
1591,
12,
1844,
29,
403,
304,
267,
340,
440,
1591,
26,
288,
746,
12625,
3393,
480,
1944,
1591,
2013,
2685,
398,
327,
8809,
3181,
1133,
2839,
652,
1380,
781,
2387,
21873,
315,
3278,
22,
7149,
267,
291,
14,
1102,
275,
1591,
14,
1913,
360,
8607,
358,
267,
291,
14,
719,
275,
1844,
339,
347,
636,
495,
721,
277,
304,
267,
372,
1543,
83,
8,
1102,
2458,
82,
12,
1844,
2458,
82,
3171,
450,
334,
466,
8,
277,
2843,
354,
3108,
1460,
291,
14,
1102,
12,
291,
14,
719,
9,
199,
199,
3,
961,
365,
9394,
687,
1455,
921,
9208,
14,
1548,
14,
1308,
15,
67,
1548,
15,
493,
15,
23,
65,
20338,
23,
2025,
26816,
16,
15,
4728,
15,
3450,
14,
647,
3,
76,
6390,
199,
63,
13091,
63,
1508,
12712,
275,
663,
779,
7931,
14,
37,
1254,
9021,
12,
7554,
14,
37,
11325,
1293,
2846,
4406,
566,
421,
199,
533,
3101,
23929,
8,
23929,
12,
4784,
10385,
304,
272,
408,
272,
11086,
13,
3489,
1950,
4203,
367,
1373,
1591,
14,
339,
520,
635,
1591,
26,
267,
10891,
1202,
367,
642,
3101,
8113,
334,
69,
14,
71,
14,
298,
5967,
1288,
3032,
1901,
267,
520,
533,
1705,
12942,
14,
19114,
2313,
339,
520,
635,
1844,
26,
267,
10977,
1202,
367,
642,
3101,
8113,
334,
403,
365,
7353,
370,
5939,
395,
3032,
267,
1901,
520,
533,
1705,
12942,
14,
19114,
2313,
339,
520,
635,
7478,
26,
267,
445,
3844,
874,
8857,
3694,
3049,
370,
506,
4915,
340,
314,
2004,
1004,
883,
1133,
506,
4565,
267,
465,
282,
1686,
3101,
15,
17,
14,
16,
503,
413,
14,
17,
2004,
1004,
12,
3032,
1901,
267,
520,
533,
1705,
12942,
14,
19114,
2313,
398,
2508,
5317,
447,
1779,
5972,
5419,
315,
2018,
499,
14,
961,
2725,
365,
5525,
315,
2018,
650,
14,
339,
520,
635,
2653,
26,
267,
17766,
2653,
315,
4696,
367,
1924,
8212,
1950,
14,
961,
883,
267,
506,
282,
2069,
503,
3000,
12,
1314,
5951,
314,
2653,
367,
314,
3101,
1056,
12,
267,
503,
376,
1256,
402,
520,
533,
1705,
4078,
19,
14,
1974,
14,
6372,
64,
1314,
10557,
1265,
1655,
267,
15701,
13,
926,
1942,
3304,
1806,
1056,
25870,
14,
12836,
314,
3787,
965,
267,
2757,
4565,
12,
642,
365,
3544,
282,
658,
4078,
19,
14,
1974,
14,
6372,
64,
909,
14,
339,
520,
635,
19791,
26,
267,
4860,
402,
6947,
370,
3354,
626,
883,
506,
24826,
14,
16917,
2419,
413,
365,
2997,
267,
315,
3510,
19710,
24325,
14,
982,
1124,
1457,
1040,
365,
663,
370,
3055,
12,
1655,
267,
6947,
911,
506,
2737,
1325,
2985,
911,
440,
506,
6290,
5403,
2985,
9064,
267,
2757,
1202,
14,
339,
520,
635,
1853,
26,
267,
982,
663,
370,
715,
12,
949,
1655,
2419,
1124,
13634,
1040,
6947,
911,
506,
1202,
737,
267,
282,
900,
14,
3979,
949,
2867,
6947,
787,
2808,
12,
314,
1240,
911,
1853,
267,
5133,
282,
1950,
965,
2757,
14286,
14,
961,
365,
282,
2997,
5366,
7763,
367,
267,
6770,
3510,
19710,
24325,
2382,
1373,
1630,
440,
2934,
370,
675,
1655,
267,
2419,
19791,
6947,
1126,
1591,
370,
7981,
289,
320,
2691,
14,
339,
520,
635,
2323,
26,
267,
21391,
370,
2387,
543,
1006,
4145,
12,
7444,
1163,
2323,
787,
1627,
267,
7662,
14,
339,
520,
635,
10086,
26,
267,
20506,
2897,
370,
675,
701,
849,
543,
4145,
315,
642,
4203,
14,
339,
520,
635,
485,
3280,
26,
267,
2235,
939,
4566,
2851,
12,
1077,
440,
506,
1202,
5370,
12,
3140,
12,
1937,
267,
520,
533,
1705,
4078,
19,
14,
2105,
2293,
14,
4936,
2988,
64,
2,
339,
520,
635,
485,
3280,
63,
2139,
26,
267,
437,
2600,
543,
4566,
2323,
12,
1077,
440,
506,
1202,
5370,
12,
267,
3140,
12,
1937,
520,
533,
1705,
4078,
19,
14,
2105,
2293,
14,
4936,
2988,
64,
2,
339,
520,
635,
971,
538,
1631,
63,
829,
26,
267,
10961,
2633,
787,
1202,
370,
1218,
17480,
520,
533,
1705,
4078,
19,
14,
2105,
14,
19114,
3559,
267,
520,
533,
1705,
4078,
19,
14,
2105,
14,
27945,
64,
4454,
14,
272,
408,
339,
5687,
275,
283,
1014,
7,
272,
8113,
24342,
275,
3101,
3225,
339,
347,
636,
826,
721,
277,
12,
1591,
12,
1844,
29,
403,
12,
7478,
29,
797,
12,
326,
2653,
29,
6372
] |
[
7554,
199,
646,
2050,
199,
646,
984,
199,
646,
3598,
199,
199,
504,
2838,
492,
1125,
465,
17766,
547,
12,
2653,
465,
17766,
6372,
199,
646,
2838,
199,
199,
893,
26,
221,
327,
2018,
650,
272,
687,
4126,
492,
24157,
545,
3737,
12,
9630,
12,
16579,
199,
2590,
3545,
26,
272,
687,
10703,
492,
24157,
545,
3737,
12,
9630,
12,
16579,
272,
492,
10703,
465,
485,
221,
327,
16078,
13,
6100,
26,
5417,
421,
199,
504,
1275,
3924,
492,
334,
272,
5980,
939,
5453,
547,
12,
272,
30797,
12,
272,
9630,
5453,
547,
12,
272,
10891,
6970,
547,
12,
272,
12625,
3393,
12,
272,
8228,
12989,
547,
12,
272,
12373,
547,
12,
272,
5574,
19382,
12,
272,
7799,
547,
12,
272,
31886,
12,
272,
1010,
7817,
2017,
3849,
12,
199,
9,
199,
504,
1275,
5154,
14,
4266,
63,
1431,
63,
4269,
492,
31953,
199,
504,
1275,
5154,
492,
3816,
199,
504,
1275,
2105,
492,
334,
272,
1844,
63,
991,
63,
5512,
12,
272,
9762,
3225,
12,
272,
3101,
3225,
12,
14147,
3225,
12,
5444,
4541,
27945,
12,
272,
28185,
12,
3523,
27102,
12,
25417,
199,
9,
199,
504,
1275,
1069,
492,
4784,
10385,
199,
504,
1275,
1310,
492,
29034,
199,
199,
504,
1275,
1974,
14,
2105,
492,
365,
63,
2105,
63,
27557,
199,
504,
1275,
1974,
14,
7154,
492,
20506,
199,
504,
1275,
1974,
14,
2593,
492,
12878,
199,
504,
1275,
1974,
14,
633,
492,
664,
63,
1102,
421,
199,
21120,
275,
3816,
14,
4912,
14,
21120,
199,
199,
793,
275,
2050,
14,
5572,
3460,
354,
3368,
199,
199,
63,
2698,
275,
909,
342,
421,
199,
309,
15553,
2251,
199,
533,
8113,
5453,
8,
785,
304,
272,
408,
272,
3523,
1021,
367,
1006,
1950,
20092,
12,
4066,
465,
272,
520,
533,
5026,
19114,
5453,
64,
436,
520,
533,
5026,
14921,
23929,
2313,
272,
408,
339,
5687,
275,
488,
272,
10703,
24342,
275,
24157,
545,
3737,
339,
347,
636,
826,
721,
277,
12,
1591,
12,
1844,
29,
403,
304,
267,
340,
440,
1591,
26,
288,
746,
12625,
3393,
480,
1944,
1591,
2013,
2685,
398,
327,
8809,
3181,
1133,
2839,
652,
1380,
781,
2387,
21873,
315,
3278,
22,
7149,
267,
291,
14,
1102,
275,
1591,
14,
1913,
360,
8607,
358,
267,
291,
14,
719,
275,
1844,
339,
347,
636,
495,
721,
277,
304,
267,
372,
1543,
83,
8,
1102,
2458,
82,
12,
1844,
2458,
82,
3171,
450,
334,
466,
8,
277,
2843,
354,
3108,
1460,
291,
14,
1102,
12,
291,
14,
719,
9,
199,
199,
3,
961,
365,
9394,
687,
1455,
921,
9208,
14,
1548,
14,
1308,
15,
67,
1548,
15,
493,
15,
23,
65,
20338,
23,
2025,
26816,
16,
15,
4728,
15,
3450,
14,
647,
3,
76,
6390,
199,
63,
13091,
63,
1508,
12712,
275,
663,
779,
7931,
14,
37,
1254,
9021,
12,
7554,
14,
37,
11325,
1293,
2846,
4406,
566,
421,
199,
533,
3101,
23929,
8,
23929,
12,
4784,
10385,
304,
272,
408,
272,
11086,
13,
3489,
1950,
4203,
367,
1373,
1591,
14,
339,
520,
635,
1591,
26,
267,
10891,
1202,
367,
642,
3101,
8113,
334,
69,
14,
71,
14,
298,
5967,
1288,
3032,
1901,
267,
520,
533,
1705,
12942,
14,
19114,
2313,
339,
520,
635,
1844,
26,
267,
10977,
1202,
367,
642,
3101,
8113,
334,
403,
365,
7353,
370,
5939,
395,
3032,
267,
1901,
520,
533,
1705,
12942,
14,
19114,
2313,
339,
520,
635,
7478,
26,
267,
445,
3844,
874,
8857,
3694,
3049,
370,
506,
4915,
340,
314,
2004,
1004,
883,
1133,
506,
4565,
267,
465,
282,
1686,
3101,
15,
17,
14,
16,
503,
413,
14,
17,
2004,
1004,
12,
3032,
1901,
267,
520,
533,
1705,
12942,
14,
19114,
2313,
398,
2508,
5317,
447,
1779,
5972,
5419,
315,
2018,
499,
14,
961,
2725,
365,
5525,
315,
2018,
650,
14,
339,
520,
635,
2653,
26,
267,
17766,
2653,
315,
4696,
367,
1924,
8212,
1950,
14,
961,
883,
267,
506,
282,
2069,
503,
3000,
12,
1314,
5951,
314,
2653,
367,
314,
3101,
1056,
12,
267,
503,
376,
1256,
402,
520,
533,
1705,
4078,
19,
14,
1974,
14,
6372,
64,
1314,
10557,
1265,
1655,
267,
15701,
13,
926,
1942,
3304,
1806,
1056,
25870,
14,
12836,
314,
3787,
965,
267,
2757,
4565,
12,
642,
365,
3544,
282,
658,
4078,
19,
14,
1974,
14,
6372,
64,
909,
14,
339,
520,
635,
19791,
26,
267,
4860,
402,
6947,
370,
3354,
626,
883,
506,
24826,
14,
16917,
2419,
413,
365,
2997,
267,
315,
3510,
19710,
24325,
14,
982,
1124,
1457,
1040,
365,
663,
370,
3055,
12,
1655,
267,
6947,
911,
506,
2737,
1325,
2985,
911,
440,
506,
6290,
5403,
2985,
9064,
267,
2757,
1202,
14,
339,
520,
635,
1853,
26,
267,
982,
663,
370,
715,
12,
949,
1655,
2419,
1124,
13634,
1040,
6947,
911,
506,
1202,
737,
267,
282,
900,
14,
3979,
949,
2867,
6947,
787,
2808,
12,
314,
1240,
911,
1853,
267,
5133,
282,
1950,
965,
2757,
14286,
14,
961,
365,
282,
2997,
5366,
7763,
367,
267,
6770,
3510,
19710,
24325,
2382,
1373,
1630,
440,
2934,
370,
675,
1655,
267,
2419,
19791,
6947,
1126,
1591,
370,
7981,
289,
320,
2691,
14,
339,
520,
635,
2323,
26,
267,
21391,
370,
2387,
543,
1006,
4145,
12,
7444,
1163,
2323,
787,
1627,
267,
7662,
14,
339,
520,
635,
10086,
26,
267,
20506,
2897,
370,
675,
701,
849,
543,
4145,
315,
642,
4203,
14,
339,
520,
635,
485,
3280,
26,
267,
2235,
939,
4566,
2851,
12,
1077,
440,
506,
1202,
5370,
12,
3140,
12,
1937,
267,
520,
533,
1705,
4078,
19,
14,
2105,
2293,
14,
4936,
2988,
64,
2,
339,
520,
635,
485,
3280,
63,
2139,
26,
267,
437,
2600,
543,
4566,
2323,
12,
1077,
440,
506,
1202,
5370,
12,
267,
3140,
12,
1937,
520,
533,
1705,
4078,
19,
14,
2105,
2293,
14,
4936,
2988,
64,
2,
339,
520,
635,
971,
538,
1631,
63,
829,
26,
267,
10961,
2633,
787,
1202,
370,
1218,
17480,
520,
533,
1705,
4078,
19,
14,
2105,
14,
19114,
3559,
267,
520,
533,
1705,
4078,
19,
14,
2105,
14,
27945,
64,
4454,
14,
272,
408,
339,
5687,
275,
283,
1014,
7,
272,
8113,
24342,
275,
3101,
3225,
339,
347,
636,
826,
721,
277,
12,
1591,
12,
1844,
29,
403,
12,
7478,
29,
797,
12,
326,
2653,
29,
6372,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
GuildMasterInfinite/OpenGL-Loader-Generator
|
Command.py
|
1
|
1314
|
from Parameter import Parameter
class Command:
def __init__(self, commandTag):
protoTag = commandTag.find("proto")
# First we need to extract the return type.
returnTag = protoTag.find("ptype")
if returnTag is None:
self.returnType = protoTag.text.strip()
else:
self.returnType = returnTag.text
# Now we extract the name
self.name = protoTag.find("name").text[2:]
# Now build the parameter list
parameters = commandTag.findall("param")
self.params = []
for param in parameters:
self.params.append(Parameter(param))
def getReturnType(self):
return self.returnType
def getName(self):
return self.name
def getParameters(self):
return self.params
def getParametersNames(self):
return ", ".join(map(Parameter.getName, self.params))
def getParametersString(self):
return ", ".join(map(Parameter.getDeclaration, self.params))
def toHeader(self):
return "{returnType} {name}({params}) noexcept".format(
returnType = self.returnType,
name = self.name,
params = self.getParametersString()
)
|
mit
|
[
504,
12009,
492,
12009,
2999,
199,
533,
5817,
26,
1128,
347,
636,
826,
721,
277,
12,
1414,
1931,
304,
1039,
4104,
1931,
275,
1414,
1931,
14,
1623,
480,
2625,
531,
13594,
327,
7758,
781,
1929,
370,
5536,
314,
372,
730,
14,
1039,
372,
1931,
275,
4104,
1931,
14,
1623,
480,
29707,
531,
4341,
340,
372,
1931,
365,
488,
26,
1675,
291,
14,
1107,
804,
275,
4104,
1931,
14,
505,
14,
1913,
342,
1039,
587,
26,
1675,
291,
14,
1107,
804,
275,
372,
1931,
14,
505,
4341,
327,
7356,
781,
5536,
314,
536,
1039,
291,
14,
354,
275,
4104,
1931,
14,
1623,
480,
354,
3471,
505,
59,
18,
2938,
4341,
327,
7356,
1900,
314,
2725,
769,
1039,
2633,
275,
1414,
1931,
14,
6452,
480,
635,
531,
1039,
291,
14,
1162,
275,
942,
4341,
367,
1215,
315,
2633,
26,
1675,
291,
14,
1162,
14,
740,
8,
4720,
8,
635,
430,
2958,
347,
664,
1767,
804,
8,
277,
304,
1039,
372,
291,
14,
1107,
804,
2958,
347,
664,
985,
8,
277,
304,
1039,
372,
291,
14,
354,
2958,
347,
664,
5976,
8,
277,
304,
1039,
372,
291,
14,
1162,
2958,
347,
664,
5976,
5866,
8,
277,
304,
1039,
372,
3872,
3680,
904,
8,
1130,
8,
4720,
14,
16405,
12,
291,
14,
1162,
430,
11787,
347,
664,
5976,
1558,
8,
277,
304,
1039,
372,
3872,
3680,
904,
8,
1130,
8,
4720,
14,
362,
17737,
12,
291,
14,
1162,
430,
11787,
347,
370,
2567,
8,
277,
304,
1039,
372,
5310,
1107,
804,
93,
469,
354,
93,
2561,
1162,
1552,
949,
2590,
1674,
908,
8,
2628,
372,
804,
275,
291,
14,
1107,
804,
12,
2628,
536,
275,
291,
14,
354,
12,
2628,
1862,
275,
291,
14,
362,
5976,
1558,
342,
1675,
776,
1223,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
12009,
492,
12009,
2999,
199,
533,
5817,
26,
1128,
347,
636,
826,
721,
277,
12,
1414,
1931,
304,
1039,
4104,
1931,
275,
1414,
1931,
14,
1623,
480,
2625,
531,
13594,
327,
7758,
781,
1929,
370,
5536,
314,
372,
730,
14,
1039,
372,
1931,
275,
4104,
1931,
14,
1623,
480,
29707,
531,
4341,
340,
372,
1931,
365,
488,
26,
1675,
291,
14,
1107,
804,
275,
4104,
1931,
14,
505,
14,
1913,
342,
1039,
587,
26,
1675,
291,
14,
1107,
804,
275,
372,
1931,
14,
505,
4341,
327,
7356,
781,
5536,
314,
536,
1039,
291,
14,
354,
275,
4104,
1931,
14,
1623,
480,
354,
3471,
505,
59,
18,
2938,
4341,
327,
7356,
1900,
314,
2725,
769,
1039,
2633,
275,
1414,
1931,
14,
6452,
480,
635,
531,
1039,
291,
14,
1162,
275,
942,
4341,
367,
1215,
315,
2633,
26,
1675,
291,
14,
1162,
14,
740,
8,
4720,
8,
635,
430,
2958,
347,
664,
1767,
804,
8,
277,
304,
1039,
372,
291,
14,
1107,
804,
2958,
347,
664,
985,
8,
277,
304,
1039,
372,
291,
14,
354,
2958,
347,
664,
5976,
8,
277,
304,
1039,
372,
291,
14,
1162,
2958,
347,
664,
5976,
5866,
8,
277,
304,
1039,
372,
3872,
3680,
904,
8,
1130,
8,
4720,
14,
16405,
12,
291,
14,
1162,
430,
11787,
347,
664,
5976,
1558,
8,
277,
304,
1039,
372,
3872,
3680,
904,
8,
1130,
8,
4720,
14,
362,
17737,
12,
291,
14,
1162,
430,
11787,
347,
370,
2567,
8,
277,
304,
1039,
372,
5310,
1107,
804,
93,
469,
354,
93,
2561,
1162,
1552,
949,
2590,
1674,
908,
8,
2628,
372,
804,
275,
291,
14,
1107,
804,
12,
2628,
536,
275,
291,
14,
354,
12,
2628,
1862,
275,
291,
14,
362,
5976,
1558,
342,
1675,
776,
1223,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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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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
] |
igor-toga/local-snat
|
neutron/tests/unit/plugins/ml2/drivers/openvswitch/agent/openflow/native/test_br_int.py
|
7
|
15264
|
# Copyright (C) 2014,2015 VA Linux Systems Japan K.K.
# Copyright (C) 2014,2015 YAMAMOTO Takashi <yamamoto at valinux co jp>
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import mock
from neutron.tests.unit.plugins.ml2.drivers.openvswitch.agent.openflow.native \
import ovs_bridge_test_base
call = mock.call # short hand
class OVSIntegrationBridgeTest(ovs_bridge_test_base.OVSBridgeTestBase):
def setUp(self):
super(OVSIntegrationBridgeTest, self).setUp()
self.setup_bridge_mock('br-int', self.br_int_cls)
self.stamp = self.br.default_cookie
def test_setup_default_table(self):
self.br.setup_default_table()
(dp, ofp, ofpp) = self._get_dp()
expected = [
call._send_msg(ofpp.OFPFlowMod(dp,
cookie=self.stamp,
instructions=[
ofpp.OFPInstructionActions(
ofp.OFPIT_APPLY_ACTIONS, [
ofpp.OFPActionOutput(ofp.OFPP_NORMAL, 0)
]),
],
match=ofpp.OFPMatch(),
priority=0,
table_id=0)),
call._send_msg(ofpp.OFPFlowMod(dp,
cookie=self.stamp,
instructions=[],
match=ofpp.OFPMatch(),
priority=0,
table_id=23)),
call._send_msg(ofpp.OFPFlowMod(dp,
cookie=self.stamp,
instructions=[],
match=ofpp.OFPMatch(),
priority=0,
table_id=24)),
]
self.assertEqual(expected, self.mock.mock_calls)
def test_provision_local_vlan(self):
port = 999
lvid = 888
segmentation_id = 777
self.br.provision_local_vlan(port=port, lvid=lvid,
segmentation_id=segmentation_id)
(dp, ofp, ofpp) = self._get_dp()
expected = [
call._send_msg(ofpp.OFPFlowMod(dp,
cookie=self.stamp,
instructions=[
ofpp.OFPInstructionActions(ofp.OFPIT_APPLY_ACTIONS, [
ofpp.OFPActionSetField(
vlan_vid=lvid | ofp.OFPVID_PRESENT),
ofpp.OFPActionOutput(ofp.OFPP_NORMAL, 0)
]),
],
match=ofpp.OFPMatch(
in_port=port,
vlan_vid=segmentation_id | ofp.OFPVID_PRESENT),
priority=3,
table_id=0)),
]
self.assertEqual(expected, self.mock.mock_calls)
def test_provision_local_vlan_novlan(self):
port = 999
lvid = 888
segmentation_id = None
self.br.provision_local_vlan(port=port, lvid=lvid,
segmentation_id=segmentation_id)
(dp, ofp, ofpp) = self._get_dp()
expected = [
call._send_msg(ofpp.OFPFlowMod(dp,
cookie=self.stamp,
instructions=[
ofpp.OFPInstructionActions(ofp.OFPIT_APPLY_ACTIONS, [
ofpp.OFPActionPushVlan(),
ofpp.OFPActionSetField(
vlan_vid=lvid | ofp.OFPVID_PRESENT),
ofpp.OFPActionOutput(ofp.OFPP_NORMAL, 0),
]),
],
match=ofpp.OFPMatch(
in_port=port,
vlan_vid=ofp.OFPVID_NONE),
priority=3,
table_id=0)),
]
self.assertEqual(expected, self.mock.mock_calls)
def test_reclaim_local_vlan(self):
port = 999
segmentation_id = 777
self.br.reclaim_local_vlan(port=port, segmentation_id=segmentation_id)
(dp, ofp, ofpp) = self._get_dp()
expected = [
call.delete_flows(
match=ofpp.OFPMatch(
in_port=port,
vlan_vid=segmentation_id | ofp.OFPVID_PRESENT)),
]
self.assertEqual(expected, self.mock.mock_calls)
def test_reclaim_local_vlan_novlan(self):
port = 999
segmentation_id = None
self.br.reclaim_local_vlan(port=port, segmentation_id=segmentation_id)
(dp, ofp, ofpp) = self._get_dp()
expected = [
call.delete_flows(
match=ofpp.OFPMatch(
in_port=port,
vlan_vid=ofp.OFPVID_NONE)),
]
self.assertEqual(expected, self.mock.mock_calls)
def test_install_dvr_to_src_mac(self):
network_type = 'vxlan'
vlan_tag = 1111
gateway_mac = '08:60:6e:7f:74:e7'
dst_mac = '00:02:b3:13:fe:3d'
dst_port = 6666
self.br.install_dvr_to_src_mac(network_type=network_type,
vlan_tag=vlan_tag,
gateway_mac=gateway_mac,
dst_mac=dst_mac,
dst_port=dst_port)
(dp, ofp, ofpp) = self._get_dp()
expected = [
call._send_msg(ofpp.OFPFlowMod(dp,
cookie=self.stamp,
instructions=[
ofpp.OFPInstructionActions(ofp.OFPIT_APPLY_ACTIONS, [
ofpp.OFPActionPopVlan(),
ofpp.OFPActionSetField(eth_src=gateway_mac),
ofpp.OFPActionOutput(6666, 0),
]),
],
match=ofpp.OFPMatch(
eth_dst=dst_mac,
vlan_vid=vlan_tag | ofp.OFPVID_PRESENT),
priority=4,
table_id=1)),
]
self.assertEqual(expected, self.mock.mock_calls)
def test_delete_dvr_to_src_mac(self):
network_type = 'vxlan'
vlan_tag = 1111
dst_mac = '00:02:b3:13:fe:3d'
self.br.delete_dvr_to_src_mac(network_type=network_type,
vlan_tag=vlan_tag,
dst_mac=dst_mac)
(dp, ofp, ofpp) = self._get_dp()
expected = [
call.delete_flows(table_id=1,
match=ofpp.OFPMatch(
eth_dst=dst_mac,
vlan_vid=vlan_tag | ofp.OFPVID_PRESENT)),
]
self.assertEqual(expected, self.mock.mock_calls)
def test_install_dvr_to_src_mac_vlan(self):
network_type = 'vlan'
vlan_tag = 1111
gateway_mac = '08:60:6e:7f:74:e7'
dst_mac = '00:02:b3:13:fe:3d'
dst_port = 6666
self.br.install_dvr_to_src_mac(network_type=network_type,
vlan_tag=vlan_tag,
gateway_mac=gateway_mac,
dst_mac=dst_mac,
dst_port=dst_port)
(dp, ofp, ofpp) = self._get_dp()
expected = [
call._send_msg(ofpp.OFPFlowMod(dp,
cookie=self.stamp,
instructions=[
ofpp.OFPInstructionActions(ofp.OFPIT_APPLY_ACTIONS, [
ofpp.OFPActionPopVlan(),
ofpp.OFPActionSetField(eth_src=gateway_mac),
ofpp.OFPActionOutput(dst_port, 0),
]),
],
match=ofpp.OFPMatch(
eth_dst=dst_mac,
vlan_vid=vlan_tag | ofp.OFPVID_PRESENT),
priority=4,
table_id=2)),
]
self.assertEqual(expected, self.mock.mock_calls)
def test_delete_dvr_to_src_mac_vlan(self):
network_type = 'vlan'
vlan_tag = 1111
dst_mac = '00:02:b3:13:fe:3d'
self.br.delete_dvr_to_src_mac(network_type=network_type,
vlan_tag=vlan_tag,
dst_mac=dst_mac)
(dp, ofp, ofpp) = self._get_dp()
expected = [
call.delete_flows(table_id=2,
match=ofpp.OFPMatch(
eth_dst=dst_mac,
vlan_vid=vlan_tag | ofp.OFPVID_PRESENT)),
]
self.assertEqual(expected, self.mock.mock_calls)
def test_add_dvr_mac_vlan(self):
mac = '00:02:b3:13:fe:3d'
port = 8888
self.br.add_dvr_mac_vlan(mac=mac, port=port)
(dp, ofp, ofpp) = self._get_dp()
expected = [
call._send_msg(ofpp.OFPFlowMod(dp,
cookie=self.stamp,
instructions=[
ofpp.OFPInstructionGotoTable(table_id=2),
],
match=ofpp.OFPMatch(
eth_src=mac,
in_port=port),
priority=4,
table_id=0))
]
self.assertEqual(expected, self.mock.mock_calls)
def test_remove_dvr_mac_vlan(self):
mac = '00:02:b3:13:fe:3d'
self.br.remove_dvr_mac_vlan(mac=mac)
(dp, ofp, ofpp) = self._get_dp()
expected = [
call.delete_flows(eth_src=mac, table_id=0),
]
self.assertEqual(expected, self.mock.mock_calls)
def test_add_dvr_mac_tun(self):
mac = '00:02:b3:13:fe:3d'
port = 8888
self.br.add_dvr_mac_tun(mac=mac, port=port)
(dp, ofp, ofpp) = self._get_dp()
expected = [
call._send_msg(ofpp.OFPFlowMod(dp,
cookie=self.stamp,
instructions=[
ofpp.OFPInstructionGotoTable(table_id=1),
],
match=ofpp.OFPMatch(
eth_src=mac,
in_port=port),
priority=2,
table_id=0))
]
self.assertEqual(expected, self.mock.mock_calls)
def test_remove_dvr_mac_tun(self):
mac = '00:02:b3:13:fe:3d'
port = 8888
self.br.remove_dvr_mac_tun(mac=mac, port=port)
expected = [
call.delete_flows(eth_src=mac, in_port=port, table_id=0),
]
self.assertEqual(expected, self.mock.mock_calls)
def test_install_icmpv6_na_spoofing_protection(self):
port = 8888
ip_addresses = ['2001:db8::1', 'fdf8:f53b:82e4::1/128']
self.br.install_icmpv6_na_spoofing_protection(port, ip_addresses)
(dp, ofp, ofpp) = self._get_dp()
expected = [
call._send_msg(ofpp.OFPFlowMod(dp,
cookie=self.stamp,
instructions=[
ofpp.OFPInstructionActions(ofp.OFPIT_APPLY_ACTIONS, [
ofpp.OFPActionOutput(ofp.OFPP_NORMAL, 0),
]),
],
match=ofpp.OFPMatch(
eth_type=self.ether_types.ETH_TYPE_IPV6,
icmpv6_type=self.icmpv6.ND_NEIGHBOR_ADVERT,
ip_proto=self.in_proto.IPPROTO_ICMPV6,
ipv6_nd_target='2001:db8::1',
in_port=8888,
),
priority=2,
table_id=24)),
call._send_msg(ofpp.OFPFlowMod(dp,
cookie=self.stamp,
instructions=[
ofpp.OFPInstructionActions(ofp.OFPIT_APPLY_ACTIONS, [
ofpp.OFPActionOutput(ofp.OFPP_NORMAL, 0),
]),
],
match=ofpp.OFPMatch(
eth_type=self.ether_types.ETH_TYPE_IPV6,
icmpv6_type=self.icmpv6.ND_NEIGHBOR_ADVERT,
ip_proto=self.in_proto.IPPROTO_ICMPV6,
ipv6_nd_target='fdf8:f53b:82e4::1',
in_port=8888,
),
priority=2,
table_id=24)),
call._send_msg(ofpp.OFPFlowMod(dp,
cookie=self.stamp,
instructions=[
ofpp.OFPInstructionGotoTable(table_id=24),
],
match=ofpp.OFPMatch(
eth_type=self.ether_types.ETH_TYPE_IPV6,
icmpv6_type=self.icmpv6.ND_NEIGHBOR_ADVERT,
ip_proto=self.in_proto.IPPROTO_ICMPV6,
in_port=8888,
),
priority=10,
table_id=0)),
]
self.assertEqual(expected, self.mock.mock_calls)
def test_install_arp_spoofing_protection(self):
port = 8888
ip_addresses = ['192.0.2.1', '192.0.2.2/32']
self.br.install_arp_spoofing_protection(port, ip_addresses)
(dp, ofp, ofpp) = self._get_dp()
expected = [
call._send_msg(ofpp.OFPFlowMod(dp,
cookie=self.stamp,
instructions=[
ofpp.OFPInstructionGotoTable(table_id=25),
],
match=ofpp.OFPMatch(
eth_type=self.ether_types.ETH_TYPE_ARP,
arp_spa='192.0.2.1',
in_port=8888,
),
priority=2,
table_id=24)),
call._send_msg(ofpp.OFPFlowMod(dp,
cookie=self.stamp,
instructions=[
ofpp.OFPInstructionGotoTable(table_id=25),
],
match=ofpp.OFPMatch(
eth_type=self.ether_types.ETH_TYPE_ARP,
arp_spa='192.0.2.2',
in_port=8888
),
priority=2,
table_id=24)),
call._send_msg(ofpp.OFPFlowMod(dp,
cookie=self.stamp,
instructions=[
ofpp.OFPInstructionGotoTable(table_id=24),
],
match=ofpp.OFPMatch(
eth_type=self.ether_types.ETH_TYPE_ARP,
in_port=8888,
),
priority=10,
table_id=0)),
]
self.assertEqual(expected, self.mock.mock_calls)
def test_delete_arp_spoofing_protection(self):
port = 8888
self.br.delete_arp_spoofing_protection(port)
(dp, ofp, ofpp) = self._get_dp()
expected = [
call.delete_flows(table_id=0, match=ofpp.OFPMatch(
eth_type=self.ether_types.ETH_TYPE_ARP,
in_port=8888)),
call.delete_flows(table_id=0, match=ofpp.OFPMatch(
eth_type=self.ether_types.ETH_TYPE_IPV6,
icmpv6_type=self.icmpv6.ND_NEIGHBOR_ADVERT,
in_port=8888,
ip_proto=self.in_proto.IPPROTO_ICMPV6)),
call.delete_flows(table_id=24, in_port=port),
]
self.assertEqual(expected, self.mock.mock_calls)
|
apache-2.0
|
[
3,
1898,
334,
35,
9,
6927,
12,
7806,
812,
33,
10130,
15285,
1603,
439,
290,
1804,
14,
43,
14,
199,
3,
1898,
334,
35,
9,
6927,
12,
7806,
1488,
1156,
1156,
31747,
377,
1151,
1119,
73,
665,
11552,
391,
77,
3459,
737,
1139,
7226,
512,
28921,
30,
199,
3,
2900,
5924,
5702,
14,
199,
3,
199,
3,
259,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
1265,
1443,
199,
3,
259,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
2047,
1443,
3332,
199,
3,
259,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
260,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
259,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
259,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
2428,
199,
3,
259,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
1666,
314,
199,
3,
259,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
4204,
199,
3,
259,
1334,
314,
844,
14,
199,
199,
646,
1683,
199,
199,
504,
8224,
14,
2219,
14,
3248,
14,
5265,
14,
757,
18,
14,
13337,
14,
1490,
23201,
14,
4054,
14,
1490,
1659,
14,
6106,
971,
272,
492,
23671,
63,
9528,
63,
396,
63,
1095,
421,
199,
1250,
275,
1683,
14,
1250,
221,
327,
3974,
4926,
421,
199,
533,
593,
7428,
20405,
14491,
774,
8,
22409,
63,
9528,
63,
396,
63,
1095,
14,
47,
7428,
14491,
14440,
304,
272,
347,
3613,
8,
277,
304,
267,
1613,
8,
47,
7428,
20405,
14491,
774,
12,
291,
680,
5996,
342,
267,
291,
14,
2758,
63,
9528,
63,
1805,
360,
3289,
13,
442,
297,
291,
14,
3289,
63,
442,
63,
1886,
9,
267,
291,
14,
2359,
275,
291,
14,
3289,
14,
885,
63,
5306,
339,
347,
511,
63,
2758,
63,
885,
63,
1224,
8,
277,
304,
267,
291,
14,
3289,
14,
2758,
63,
885,
63,
1224,
342,
267,
334,
5780,
12,
15643,
12,
402,
802,
9,
275,
291,
423,
362,
63,
5780,
342,
267,
1420,
275,
359,
288,
1240,
423,
2254,
63,
1328,
8,
1618,
802,
14,
6733,
5060,
9871,
8,
5780,
12,
355,
5494,
29,
277,
14,
2359,
12,
355,
15794,
1524,
490,
402,
802,
14,
6733,
17700,
9303,
8,
717,
15643,
14,
6733,
649,
63,
1282,
31370,
63,
25194,
12,
359,
1169,
402,
802,
14,
6733,
3310,
2959,
8,
20943,
14,
6733,
48,
63,
10765,
12,
378,
9,
717,
17318,
355,
2156,
355,
1336,
29,
1618,
802,
14,
6733,
4486,
1062,
355,
7464,
29,
16,
12,
355,
1817,
63,
344,
29,
16,
1826,
288,
1240,
423,
2254,
63,
1328,
8,
1618,
802,
14,
6733,
5060,
9871,
8,
5780,
12,
355,
5494,
29,
277,
14,
2359,
12,
355,
15794,
6034,
355,
1336,
29,
1618,
802,
14,
6733,
4486,
1062,
355,
7464,
29,
16,
12,
355,
1817,
63,
344,
29,
1789,
1826,
288,
1240,
423,
2254,
63,
1328,
8,
1618,
802,
14,
6733,
5060,
9871,
8,
5780,
12,
355,
5494,
29,
277,
14,
2359,
12,
355,
15794,
6034,
355,
1336,
29,
1618,
802,
14,
6733,
4486,
1062,
355,
7464,
29,
16,
12,
355,
1817,
63,
344,
29,
1194,
1826,
267,
1622,
267,
291,
14,
629,
8,
2062,
12,
291,
14,
1805,
14,
1805,
63,
5352,
9,
339,
347,
511,
63,
13717,
63,
1832,
63,
7175,
8,
277,
304,
267,
1844,
275,
22291,
267,
634,
5017,
275,
10523,
24,
267,
27315,
63,
344,
275,
8375,
23,
267,
291,
14,
3289,
14,
13717,
63,
1832,
63,
7175,
8,
719,
29,
719,
12,
634,
5017,
29,
76,
5017,
12,
3660,
27315,
63,
344,
29,
26926,
63,
344,
9,
267,
334,
5780,
12,
15643,
12,
402,
802,
9,
275,
291,
423,
362,
63,
5780,
342,
267,
1420,
275,
359,
288,
1240,
423,
2254,
63,
1328,
8,
1618,
802,
14,
6733,
5060,
9871,
8,
5780,
12,
355,
5494,
29,
277,
14,
2359,
12,
355,
15794,
1524,
490,
402,
802,
14,
6733,
17700,
9303,
8,
20943,
14,
6733,
649,
63,
1282,
31370,
63,
25194,
12,
359,
717,
402,
802,
14,
6733,
3310,
1084,
792,
8,
1169,
10119,
63,
5017,
29,
76,
5017,
1204,
15643,
14,
6733,
5437,
63,
19743,
395,
717,
402,
802,
14,
6733,
3310,
2959,
8,
20943,
14,
6733,
48,
63,
10765,
12,
378,
9,
490,
17318,
355,
2156,
355,
1336,
29,
1618,
802,
14,
6733,
4486,
8,
490,
315,
63,
719,
29,
719,
12,
490,
10119,
63,
5017,
29,
26926,
63,
344,
1204,
15643,
14,
6733,
5437,
63,
19743,
395,
355,
7464,
29,
19,
12,
355,
1817,
63,
344,
29,
16,
1826,
267,
1622,
267,
291,
14,
629,
8,
2062,
12,
291,
14,
1805,
14,
1805,
63,
5352,
9,
339,
347,
511,
63,
13717,
63,
1832,
63,
7175,
63,
889,
7175,
8,
277,
304,
267,
1844,
275,
22291,
267,
634,
5017,
275,
10523,
24,
267,
27315,
63,
344,
275,
488,
267,
291,
14,
3289,
14,
13717,
63,
1832,
63,
7175,
8,
719,
29,
719,
12,
634,
5017,
29,
76,
5017,
12,
3660,
27315,
63,
344,
29,
26926,
63,
344,
9,
267,
334,
5780,
12,
15643,
12,
402,
802,
9,
275,
291,
423,
362,
63,
5780,
342,
267,
1420,
275,
359,
288,
1240,
423,
2254,
63,
1328,
8,
1618,
802,
14,
6733,
5060,
9871,
8,
5780,
12,
355,
5494,
29,
277,
14,
2359,
12,
355,
15794,
1524,
490,
402,
802,
14,
6733,
17700,
9303,
8,
20943,
14,
6733,
649,
63,
1282,
31370,
63,
25194,
12,
359,
717,
402,
802,
14,
6733,
3310,
10731,
22657,
1062,
717,
402,
802,
14,
6733,
3310,
1084,
792,
8,
1169,
10119,
63,
5017,
29,
76,
5017,
1204,
15643,
14,
6733,
5437,
63,
19743,
395,
717,
402,
802,
14,
6733,
3310,
2959,
8,
20943,
14,
6733,
48,
63,
10765,
12,
378,
395,
490,
17318,
355,
2156,
355,
1336,
29,
1618,
802,
14,
6733,
4486,
8,
490,
315,
63,
719,
29,
719,
12,
490,
10119,
63,
5017,
29,
20943,
14,
6733,
5437,
63,
9185,
395,
355,
7464,
29,
19,
12,
355,
1817,
63,
344,
29,
16,
1826,
267,
1622,
267,
291,
14,
629,
8,
2062,
12,
291,
14,
1805,
14,
1805,
63,
5352
] |
[
1898,
334,
35,
9,
6927,
12,
7806,
812,
33,
10130,
15285,
1603,
439,
290,
1804,
14,
43,
14,
199,
3,
1898,
334,
35,
9,
6927,
12,
7806,
1488,
1156,
1156,
31747,
377,
1151,
1119,
73,
665,
11552,
391,
77,
3459,
737,
1139,
7226,
512,
28921,
30,
199,
3,
2900,
5924,
5702,
14,
199,
3,
199,
3,
259,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
1265,
1443,
199,
3,
259,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
2047,
1443,
3332,
199,
3,
259,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
260,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
259,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
259,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
2428,
199,
3,
259,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
1666,
314,
199,
3,
259,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
4204,
199,
3,
259,
1334,
314,
844,
14,
199,
199,
646,
1683,
199,
199,
504,
8224,
14,
2219,
14,
3248,
14,
5265,
14,
757,
18,
14,
13337,
14,
1490,
23201,
14,
4054,
14,
1490,
1659,
14,
6106,
971,
272,
492,
23671,
63,
9528,
63,
396,
63,
1095,
421,
199,
1250,
275,
1683,
14,
1250,
221,
327,
3974,
4926,
421,
199,
533,
593,
7428,
20405,
14491,
774,
8,
22409,
63,
9528,
63,
396,
63,
1095,
14,
47,
7428,
14491,
14440,
304,
272,
347,
3613,
8,
277,
304,
267,
1613,
8,
47,
7428,
20405,
14491,
774,
12,
291,
680,
5996,
342,
267,
291,
14,
2758,
63,
9528,
63,
1805,
360,
3289,
13,
442,
297,
291,
14,
3289,
63,
442,
63,
1886,
9,
267,
291,
14,
2359,
275,
291,
14,
3289,
14,
885,
63,
5306,
339,
347,
511,
63,
2758,
63,
885,
63,
1224,
8,
277,
304,
267,
291,
14,
3289,
14,
2758,
63,
885,
63,
1224,
342,
267,
334,
5780,
12,
15643,
12,
402,
802,
9,
275,
291,
423,
362,
63,
5780,
342,
267,
1420,
275,
359,
288,
1240,
423,
2254,
63,
1328,
8,
1618,
802,
14,
6733,
5060,
9871,
8,
5780,
12,
355,
5494,
29,
277,
14,
2359,
12,
355,
15794,
1524,
490,
402,
802,
14,
6733,
17700,
9303,
8,
717,
15643,
14,
6733,
649,
63,
1282,
31370,
63,
25194,
12,
359,
1169,
402,
802,
14,
6733,
3310,
2959,
8,
20943,
14,
6733,
48,
63,
10765,
12,
378,
9,
717,
17318,
355,
2156,
355,
1336,
29,
1618,
802,
14,
6733,
4486,
1062,
355,
7464,
29,
16,
12,
355,
1817,
63,
344,
29,
16,
1826,
288,
1240,
423,
2254,
63,
1328,
8,
1618,
802,
14,
6733,
5060,
9871,
8,
5780,
12,
355,
5494,
29,
277,
14,
2359,
12,
355,
15794,
6034,
355,
1336,
29,
1618,
802,
14,
6733,
4486,
1062,
355,
7464,
29,
16,
12,
355,
1817,
63,
344,
29,
1789,
1826,
288,
1240,
423,
2254,
63,
1328,
8,
1618,
802,
14,
6733,
5060,
9871,
8,
5780,
12,
355,
5494,
29,
277,
14,
2359,
12,
355,
15794,
6034,
355,
1336,
29,
1618,
802,
14,
6733,
4486,
1062,
355,
7464,
29,
16,
12,
355,
1817,
63,
344,
29,
1194,
1826,
267,
1622,
267,
291,
14,
629,
8,
2062,
12,
291,
14,
1805,
14,
1805,
63,
5352,
9,
339,
347,
511,
63,
13717,
63,
1832,
63,
7175,
8,
277,
304,
267,
1844,
275,
22291,
267,
634,
5017,
275,
10523,
24,
267,
27315,
63,
344,
275,
8375,
23,
267,
291,
14,
3289,
14,
13717,
63,
1832,
63,
7175,
8,
719,
29,
719,
12,
634,
5017,
29,
76,
5017,
12,
3660,
27315,
63,
344,
29,
26926,
63,
344,
9,
267,
334,
5780,
12,
15643,
12,
402,
802,
9,
275,
291,
423,
362,
63,
5780,
342,
267,
1420,
275,
359,
288,
1240,
423,
2254,
63,
1328,
8,
1618,
802,
14,
6733,
5060,
9871,
8,
5780,
12,
355,
5494,
29,
277,
14,
2359,
12,
355,
15794,
1524,
490,
402,
802,
14,
6733,
17700,
9303,
8,
20943,
14,
6733,
649,
63,
1282,
31370,
63,
25194,
12,
359,
717,
402,
802,
14,
6733,
3310,
1084,
792,
8,
1169,
10119,
63,
5017,
29,
76,
5017,
1204,
15643,
14,
6733,
5437,
63,
19743,
395,
717,
402,
802,
14,
6733,
3310,
2959,
8,
20943,
14,
6733,
48,
63,
10765,
12,
378,
9,
490,
17318,
355,
2156,
355,
1336,
29,
1618,
802,
14,
6733,
4486,
8,
490,
315,
63,
719,
29,
719,
12,
490,
10119,
63,
5017,
29,
26926,
63,
344,
1204,
15643,
14,
6733,
5437,
63,
19743,
395,
355,
7464,
29,
19,
12,
355,
1817,
63,
344,
29,
16,
1826,
267,
1622,
267,
291,
14,
629,
8,
2062,
12,
291,
14,
1805,
14,
1805,
63,
5352,
9,
339,
347,
511,
63,
13717,
63,
1832,
63,
7175,
63,
889,
7175,
8,
277,
304,
267,
1844,
275,
22291,
267,
634,
5017,
275,
10523,
24,
267,
27315,
63,
344,
275,
488,
267,
291,
14,
3289,
14,
13717,
63,
1832,
63,
7175,
8,
719,
29,
719,
12,
634,
5017,
29,
76,
5017,
12,
3660,
27315,
63,
344,
29,
26926,
63,
344,
9,
267,
334,
5780,
12,
15643,
12,
402,
802,
9,
275,
291,
423,
362,
63,
5780,
342,
267,
1420,
275,
359,
288,
1240,
423,
2254,
63,
1328,
8,
1618,
802,
14,
6733,
5060,
9871,
8,
5780,
12,
355,
5494,
29,
277,
14,
2359,
12,
355,
15794,
1524,
490,
402,
802,
14,
6733,
17700,
9303,
8,
20943,
14,
6733,
649,
63,
1282,
31370,
63,
25194,
12,
359,
717,
402,
802,
14,
6733,
3310,
10731,
22657,
1062,
717,
402,
802,
14,
6733,
3310,
1084,
792,
8,
1169,
10119,
63,
5017,
29,
76,
5017,
1204,
15643,
14,
6733,
5437,
63,
19743,
395,
717,
402,
802,
14,
6733,
3310,
2959,
8,
20943,
14,
6733,
48,
63,
10765,
12,
378,
395,
490,
17318,
355,
2156,
355,
1336,
29,
1618,
802,
14,
6733,
4486,
8,
490,
315,
63,
719,
29,
719,
12,
490,
10119,
63,
5017,
29,
20943,
14,
6733,
5437,
63,
9185,
395,
355,
7464,
29,
19,
12,
355,
1817,
63,
344,
29,
16,
1826,
267,
1622,
267,
291,
14,
629,
8,
2062,
12,
291,
14,
1805,
14,
1805,
63,
5352,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
impmihai/coala
|
coalib/settings/Setting.py
|
9
|
9567
|
import os
from collections import OrderedDict
from coala_utils.decorators import generate_repr
from coala_utils.string_processing.StringConverter import StringConverter
from coalib.parsing.Globbing import glob_escape
def path(obj, *args, **kwargs):
return obj.__path__(*args, **kwargs)
def path_list(obj, *args, **kwargs):
return obj.__path_list__(*args, **kwargs)
def url(obj, *args, **kwargs):
return obj.__url__(*args, **kwargs)
def glob(obj, *args, **kwargs):
"""
Creates a path in which all special glob characters in all the
parent directories in the given setting are properly escaped.
:param obj: The ``Setting`` object from which the key is obtained.
:return: Returns a path in which special glob characters are escaped.
"""
return obj.__glob__(*args, **kwargs)
def glob_list(obj, *args, **kwargs):
"""
Creates a list of paths in which all special glob characters in all the
parent directories of all paths in the given setting are properly escaped.
:param obj: The ``Setting`` object from which the key is obtained.
:return: Returns a list of paths in which special glob characters are
escaped.
"""
return obj.__glob_list__(*args, **kwargs)
def typed_list(conversion_func):
"""
Creates a function that converts a setting into a list of elements each
converted with the given conversion function.
:param conversion_func: The conversion function that converts a string into
your desired list item object.
:return: A conversion function.
"""
return lambda setting: [
conversion_func(StringConverter(elem)) for elem in setting]
def typed_dict(key_type, value_type, default):
"""
Creates a function that converts a setting into a dict with the given
types.
:param key_type: The type conversion function for the keys.
:param value_type: The type conversion function for the values.
:param default: The default value to use if no one is given by the user.
:return: A conversion function.
"""
return lambda setting: {
key_type(StringConverter(key)):
value_type(StringConverter(value)) if value != '' else default
for key, value in dict(setting).items()}
def typed_ordered_dict(key_type, value_type, default):
"""
Creates a function that converts a setting into an ordered dict with the
given types.
:param key_type: The type conversion function for the keys.
:param value_type: The type conversion function for the values.
:param default: The default value to use if no one is given by the user.
:return: A conversion function.
"""
return lambda setting: OrderedDict(
(key_type(StringConverter(key)),
value_type(StringConverter(value)) if value != '' else default)
for key, value in OrderedDict(setting).items())
@generate_repr('key', 'value', 'origin', 'from_cli', 'to_append')
class Setting(StringConverter):
"""
A Setting consists mainly of a key and a value. It mainly offers many
conversions into common data types.
"""
def __init__(self,
key,
value,
origin='',
strip_whitespaces=True,
list_delimiters=(',', ';'),
from_cli=False,
remove_empty_iter_elements=True,
to_append=False):
"""
Initializes a new Setting,
:param key: The key of the Setting.
:param value: The value, if you apply conversions
to this object these will be applied
to this value.
:param origin: The originating file. This will be
used for path conversions and the
last part will be stripped of. If
you want to specify a directory as
origin be sure to end it with a
directory separator.
:param strip_whitespaces: Whether to strip whitespaces from
the value or not
:param list_delimiters: Delimiters for list conversion
:param from_cli: True if this setting was read by the
CliParser.
:param remove_empty_iter_elements: Whether to remove empty elements in
iterable values.
:param to_append: The boolean value if setting value
needs to be appended to a setting in
the defaults of a section.
"""
if not isinstance(from_cli, bool):
raise TypeError('from_cli needs to be a boolean value.')
if not isinstance(to_append, bool):
raise TypeError('to_append needs to be a boolean value.')
self.to_append = to_append
StringConverter.__init__(
self,
value,
strip_whitespaces=strip_whitespaces,
list_delimiters=list_delimiters,
remove_empty_iter_elements=remove_empty_iter_elements)
self.from_cli = from_cli
self.key = key
self.origin = str(origin)
def __path__(self, origin=None, glob_escape_origin=False):
"""
Determines the path of this setting.
Note: You can also use this function on strings, in that case the
origin argument will be taken in every case.
:param origin: The origin file to take if no origin is
specified for the given setting. If you
want to provide a directory, make sure it
ends with a directory separator.
:param glob_escape_origin: When this is set to true, the origin of
this setting will be escaped with
``glob_escape``.
:return: An absolute path.
:raises ValueError: If no origin is specified in the setting
nor the given origin parameter.
"""
strrep = str(self).strip()
if os.path.isabs(strrep):
return strrep
if hasattr(self, 'origin') and self.origin != '':
origin = self.origin
if origin is None:
raise ValueError('Cannot determine path without origin.')
# We need to get full path before escaping since the full path
# may introduce unintended glob characters
origin = os.path.abspath(os.path.dirname(origin))
if glob_escape_origin:
origin = glob_escape(origin)
return os.path.normpath(os.path.join(origin, strrep))
def __glob__(self, origin=None):
"""
Determines the path of this setting with proper escaping of its
parent directories.
:param origin: The origin file to take if no origin is specified
for the given setting. If you want to provide a
directory, make sure it ends with a directory
separator.
:return: An absolute path in which the parent directories
are escaped.
:raises ValueError: If no origin is specified in the setting nor the
given origin parameter.
"""
return Setting.__path__(self, origin, glob_escape_origin=True)
def __path_list__(self):
"""
Splits the value into a list and creates a path out of each item taking
the origin of the setting into account.
:return: A list of absolute paths.
"""
return [Setting.__path__(elem, self.origin) for elem in self]
def __glob_list__(self):
"""
Splits the value into a list and creates a path out of each item in
which the special glob characters in origin are escaped.
:return: A list of absolute paths in which the special characters in
the parent directories of the setting are escaped.
"""
return [Setting.__glob__(elem, self.origin) for elem in self]
def __iter__(self, remove_backslashes=True):
if self.to_append:
raise ValueError('Iteration on this object is invalid because the '
'value is incomplete. Please access the value of '
'the setting in a section to iterate through it.')
return StringConverter.__iter__(self, remove_backslashes)
@property
def key(self):
return self._key
@key.setter
def key(self, key):
newkey = str(key)
if newkey == '':
raise ValueError('An empty key is not allowed for a setting.')
self._key = newkey
@StringConverter.value.getter
def value(self):
if self.to_append:
raise ValueError('This property is invalid because the value is '
'incomplete. Please access the value of the '
'setting in a section to get the complete value.')
return self._value
|
agpl-3.0
|
[
646,
747,
199,
504,
5055,
492,
8773,
199,
199,
504,
512,
14774,
63,
1208,
14,
11582,
492,
3550,
63,
2722,
199,
504,
512,
14774,
63,
1208,
14,
875,
63,
6338,
14,
1558,
11907,
492,
2624,
11907,
199,
504,
512,
25530,
14,
11059,
14,
25954,
10911,
492,
5739,
63,
3765,
421,
199,
318,
931,
8,
1113,
12,
627,
589,
12,
1011,
958,
304,
272,
372,
1559,
855,
515,
9308,
589,
12,
1011,
958,
9,
421,
199,
318,
931,
63,
513,
8,
1113,
12,
627,
589,
12,
1011,
958,
304,
272,
372,
1559,
855,
515,
63,
513,
9308,
589,
12,
1011,
958,
9,
421,
199,
318,
1166,
8,
1113,
12,
627,
589,
12,
1011,
958,
304,
272,
372,
1559,
855,
633,
9308,
589,
12,
1011,
958,
9,
421,
199,
318,
5739,
8,
1113,
12,
627,
589,
12,
1011,
958,
304,
272,
408,
272,
10560,
282,
931,
315,
1314,
1006,
4539,
5739,
4110,
315,
1006,
314,
272,
1676,
6602,
315,
314,
1627,
4260,
787,
7684,
11077,
14,
339,
520,
635,
1559,
26,
710,
1124,
7776,
1040,
909,
687,
1314,
314,
790,
365,
15884,
14,
272,
520,
1107,
26,
259,
1803,
282,
931,
315,
1314,
4539,
5739,
4110,
787,
11077,
14,
272,
408,
272,
372,
1559,
855,
6463,
9308,
589,
12,
1011,
958,
9,
421,
199,
318,
5739,
63,
513,
8,
1113,
12,
627,
589,
12,
1011,
958,
304,
272,
408,
272,
10560,
282,
769,
402,
3792,
315,
1314,
1006,
4539,
5739,
4110,
315,
1006,
314,
272,
1676,
6602,
402,
1006,
3792,
315,
314,
1627,
4260,
787,
7684,
11077,
14,
339,
520,
635,
1559,
26,
710,
1124,
7776,
1040,
909,
687,
1314,
314,
790,
365,
15884,
14,
272,
520,
1107,
26,
259,
1803,
282,
769,
402,
3792,
315,
1314,
4539,
5739,
4110,
787,
355,
11077,
14,
272,
408,
272,
372,
1559,
855,
6463,
63,
513,
9308,
589,
12,
1011,
958,
9,
421,
199,
318,
20041,
63,
513,
8,
15083,
63,
1532,
304,
272,
408,
272,
10560,
282,
805,
626,
15373,
282,
4260,
1901,
282,
769,
402,
4008,
1924,
272,
6702,
543,
314,
1627,
8603,
805,
14,
339,
520,
635,
8603,
63,
1532,
26,
710,
8603,
805,
626,
15373,
282,
1059,
1901,
1169,
2195,
6387,
769,
1242,
909,
14,
272,
520,
1107,
26,
4483,
437,
8603,
805,
14,
272,
408,
272,
372,
2400,
4260,
26,
359,
267,
8603,
63,
1532,
8,
1558,
11907,
8,
6086,
430,
367,
6193,
315,
4260,
61,
421,
199,
318,
20041,
63,
807,
8,
498,
63,
466,
12,
574,
63,
466,
12,
849,
304,
272,
408,
272,
10560,
282,
805,
626,
15373,
282,
4260,
1901,
282,
1211,
543,
314,
1627,
272,
2943,
14,
339,
520,
635,
790,
63,
466,
26,
257,
710,
730,
8603,
805,
367,
314,
2883,
14,
272,
520,
635,
574,
63,
466,
26,
710,
730,
8603,
805,
367,
314,
1338,
14,
272,
520,
635,
849,
26,
259,
710,
849,
574,
370,
675,
340,
949,
1373,
365,
1627,
701,
314,
922,
14,
272,
520,
1107,
26,
3698,
437,
8603,
805,
14,
272,
408,
272,
372,
2400,
4260,
26,
469,
267,
790,
63,
466,
8,
1558,
11907,
8,
498,
2298,
267,
574,
63,
466,
8,
1558,
11907,
8,
585,
430,
340,
574,
1137,
2125,
587,
849,
267,
367,
790,
12,
574,
315,
1211,
8,
6031,
680,
1744,
12737,
421,
199,
318,
20041,
63,
8235,
63,
807,
8,
498,
63,
466,
12,
574,
63,
466,
12,
849,
304,
272,
408,
272,
10560,
282,
805,
626,
15373,
282,
4260,
1901,
376,
7741,
1211,
543,
314,
272,
1627,
2943,
14,
339,
520,
635,
790,
63,
466,
26,
257,
710,
730,
8603,
805,
367,
314,
2883,
14,
272,
520,
635,
574,
63,
466,
26,
710,
730,
8603,
805,
367,
314,
1338,
14,
272,
520,
635,
849,
26,
259,
710,
849,
574,
370,
675,
340,
949,
1373,
365,
1627,
701,
314,
922,
14,
272,
520,
1107,
26,
3698,
437,
8603,
805,
14,
272,
408,
272,
372,
2400,
4260,
26,
8773,
8,
267,
334,
498,
63,
466,
8,
1558,
11907,
8,
498,
1826,
268,
574,
63,
466,
8,
1558,
11907,
8,
585,
430,
340,
574,
1137,
2125,
587,
849,
9,
267,
367,
790,
12,
574,
315,
8773,
8,
6031,
680,
1744,
1012,
421,
199,
32,
4208,
63,
2722,
360,
498,
297,
283,
585,
297,
283,
6493,
297,
283,
504,
63,
2764,
297,
283,
475,
63,
740,
358,
199,
533,
13510,
8,
1558,
11907,
304,
272,
408,
272,
437,
13510,
18581,
27580,
402,
282,
790,
436,
282,
574,
14,
2779,
27580,
32563,
5002,
272,
24796,
1901,
2863,
666,
2943,
14,
272,
408,
339,
347,
636,
826,
721,
277,
12,
326,
790,
12,
326,
574,
12,
326,
6330,
4581,
326,
6202,
63,
2191,
31926,
29,
549,
12,
326,
769,
63,
6933,
20378,
2687,
23324,
14289,
659,
326,
687,
63,
2764,
29,
797,
12,
326,
2813,
63,
1667,
63,
1661,
63,
5527,
29,
549,
12,
326,
370,
63,
740,
29,
797,
304,
267,
408,
267,
6026,
6491,
282,
892,
13510,
12,
398,
520,
635,
790,
26,
12788,
710,
790,
402,
314,
13510,
14,
267,
520,
635,
574,
26,
10473,
710,
574,
12,
340,
1265,
4838,
24796,
5644,
370,
642,
909,
3520,
911,
506,
6781,
5644,
370,
642,
574,
14,
267,
520,
635,
6330,
26,
9326,
710,
6330,
1958,
570,
14,
961,
911,
506,
5644,
1202,
367,
931,
24796,
436,
314,
5644,
2061,
1777,
911,
506,
14489,
402,
14,
982,
5644,
1265,
2934,
370,
4165,
282,
2082,
465,
5644,
6330,
506,
3238,
370,
1284,
652,
543,
282,
5644,
2082,
9432,
14,
267,
520,
635,
6202,
63,
2191,
31926,
26,
3515,
7480,
370,
6202,
704,
31926,
687,
5644,
314,
574,
503,
440,
267,
520,
635,
769,
63,
6933,
20378,
26,
3322,
1487,
317,
20378,
367,
769,
8603,
267,
520,
635,
687,
63,
2764,
26,
7861,
715,
340,
642,
4260,
1990,
1586,
701,
314,
5644,
445,
317,
2842,
14,
267,
520,
635,
2813,
63,
1667,
63,
1661,
63,
5527,
26,
7480,
370,
2813,
2701,
4008,
315,
5644,
6076,
1338,
14,
267,
520,
635,
370,
63,
740,
26,
8295,
710,
5046,
574,
340,
4260,
574,
5644,
4839,
370,
506,
11544,
370,
282,
4260,
315,
5644,
314,
4243,
402,
282,
3420,
14,
267,
408,
267,
340,
440,
1228,
8,
504,
63,
2764,
12,
2155,
304,
288,
746,
3146
] |
[
747,
199,
504,
5055,
492,
8773,
199,
199,
504,
512,
14774,
63,
1208,
14,
11582,
492,
3550,
63,
2722,
199,
504,
512,
14774,
63,
1208,
14,
875,
63,
6338,
14,
1558,
11907,
492,
2624,
11907,
199,
504,
512,
25530,
14,
11059,
14,
25954,
10911,
492,
5739,
63,
3765,
421,
199,
318,
931,
8,
1113,
12,
627,
589,
12,
1011,
958,
304,
272,
372,
1559,
855,
515,
9308,
589,
12,
1011,
958,
9,
421,
199,
318,
931,
63,
513,
8,
1113,
12,
627,
589,
12,
1011,
958,
304,
272,
372,
1559,
855,
515,
63,
513,
9308,
589,
12,
1011,
958,
9,
421,
199,
318,
1166,
8,
1113,
12,
627,
589,
12,
1011,
958,
304,
272,
372,
1559,
855,
633,
9308,
589,
12,
1011,
958,
9,
421,
199,
318,
5739,
8,
1113,
12,
627,
589,
12,
1011,
958,
304,
272,
408,
272,
10560,
282,
931,
315,
1314,
1006,
4539,
5739,
4110,
315,
1006,
314,
272,
1676,
6602,
315,
314,
1627,
4260,
787,
7684,
11077,
14,
339,
520,
635,
1559,
26,
710,
1124,
7776,
1040,
909,
687,
1314,
314,
790,
365,
15884,
14,
272,
520,
1107,
26,
259,
1803,
282,
931,
315,
1314,
4539,
5739,
4110,
787,
11077,
14,
272,
408,
272,
372,
1559,
855,
6463,
9308,
589,
12,
1011,
958,
9,
421,
199,
318,
5739,
63,
513,
8,
1113,
12,
627,
589,
12,
1011,
958,
304,
272,
408,
272,
10560,
282,
769,
402,
3792,
315,
1314,
1006,
4539,
5739,
4110,
315,
1006,
314,
272,
1676,
6602,
402,
1006,
3792,
315,
314,
1627,
4260,
787,
7684,
11077,
14,
339,
520,
635,
1559,
26,
710,
1124,
7776,
1040,
909,
687,
1314,
314,
790,
365,
15884,
14,
272,
520,
1107,
26,
259,
1803,
282,
769,
402,
3792,
315,
1314,
4539,
5739,
4110,
787,
355,
11077,
14,
272,
408,
272,
372,
1559,
855,
6463,
63,
513,
9308,
589,
12,
1011,
958,
9,
421,
199,
318,
20041,
63,
513,
8,
15083,
63,
1532,
304,
272,
408,
272,
10560,
282,
805,
626,
15373,
282,
4260,
1901,
282,
769,
402,
4008,
1924,
272,
6702,
543,
314,
1627,
8603,
805,
14,
339,
520,
635,
8603,
63,
1532,
26,
710,
8603,
805,
626,
15373,
282,
1059,
1901,
1169,
2195,
6387,
769,
1242,
909,
14,
272,
520,
1107,
26,
4483,
437,
8603,
805,
14,
272,
408,
272,
372,
2400,
4260,
26,
359,
267,
8603,
63,
1532,
8,
1558,
11907,
8,
6086,
430,
367,
6193,
315,
4260,
61,
421,
199,
318,
20041,
63,
807,
8,
498,
63,
466,
12,
574,
63,
466,
12,
849,
304,
272,
408,
272,
10560,
282,
805,
626,
15373,
282,
4260,
1901,
282,
1211,
543,
314,
1627,
272,
2943,
14,
339,
520,
635,
790,
63,
466,
26,
257,
710,
730,
8603,
805,
367,
314,
2883,
14,
272,
520,
635,
574,
63,
466,
26,
710,
730,
8603,
805,
367,
314,
1338,
14,
272,
520,
635,
849,
26,
259,
710,
849,
574,
370,
675,
340,
949,
1373,
365,
1627,
701,
314,
922,
14,
272,
520,
1107,
26,
3698,
437,
8603,
805,
14,
272,
408,
272,
372,
2400,
4260,
26,
469,
267,
790,
63,
466,
8,
1558,
11907,
8,
498,
2298,
267,
574,
63,
466,
8,
1558,
11907,
8,
585,
430,
340,
574,
1137,
2125,
587,
849,
267,
367,
790,
12,
574,
315,
1211,
8,
6031,
680,
1744,
12737,
421,
199,
318,
20041,
63,
8235,
63,
807,
8,
498,
63,
466,
12,
574,
63,
466,
12,
849,
304,
272,
408,
272,
10560,
282,
805,
626,
15373,
282,
4260,
1901,
376,
7741,
1211,
543,
314,
272,
1627,
2943,
14,
339,
520,
635,
790,
63,
466,
26,
257,
710,
730,
8603,
805,
367,
314,
2883,
14,
272,
520,
635,
574,
63,
466,
26,
710,
730,
8603,
805,
367,
314,
1338,
14,
272,
520,
635,
849,
26,
259,
710,
849,
574,
370,
675,
340,
949,
1373,
365,
1627,
701,
314,
922,
14,
272,
520,
1107,
26,
3698,
437,
8603,
805,
14,
272,
408,
272,
372,
2400,
4260,
26,
8773,
8,
267,
334,
498,
63,
466,
8,
1558,
11907,
8,
498,
1826,
268,
574,
63,
466,
8,
1558,
11907,
8,
585,
430,
340,
574,
1137,
2125,
587,
849,
9,
267,
367,
790,
12,
574,
315,
8773,
8,
6031,
680,
1744,
1012,
421,
199,
32,
4208,
63,
2722,
360,
498,
297,
283,
585,
297,
283,
6493,
297,
283,
504,
63,
2764,
297,
283,
475,
63,
740,
358,
199,
533,
13510,
8,
1558,
11907,
304,
272,
408,
272,
437,
13510,
18581,
27580,
402,
282,
790,
436,
282,
574,
14,
2779,
27580,
32563,
5002,
272,
24796,
1901,
2863,
666,
2943,
14,
272,
408,
339,
347,
636,
826,
721,
277,
12,
326,
790,
12,
326,
574,
12,
326,
6330,
4581,
326,
6202,
63,
2191,
31926,
29,
549,
12,
326,
769,
63,
6933,
20378,
2687,
23324,
14289,
659,
326,
687,
63,
2764,
29,
797,
12,
326,
2813,
63,
1667,
63,
1661,
63,
5527,
29,
549,
12,
326,
370,
63,
740,
29,
797,
304,
267,
408,
267,
6026,
6491,
282,
892,
13510,
12,
398,
520,
635,
790,
26,
12788,
710,
790,
402,
314,
13510,
14,
267,
520,
635,
574,
26,
10473,
710,
574,
12,
340,
1265,
4838,
24796,
5644,
370,
642,
909,
3520,
911,
506,
6781,
5644,
370,
642,
574,
14,
267,
520,
635,
6330,
26,
9326,
710,
6330,
1958,
570,
14,
961,
911,
506,
5644,
1202,
367,
931,
24796,
436,
314,
5644,
2061,
1777,
911,
506,
14489,
402,
14,
982,
5644,
1265,
2934,
370,
4165,
282,
2082,
465,
5644,
6330,
506,
3238,
370,
1284,
652,
543,
282,
5644,
2082,
9432,
14,
267,
520,
635,
6202,
63,
2191,
31926,
26,
3515,
7480,
370,
6202,
704,
31926,
687,
5644,
314,
574,
503,
440,
267,
520,
635,
769,
63,
6933,
20378,
26,
3322,
1487,
317,
20378,
367,
769,
8603,
267,
520,
635,
687,
63,
2764,
26,
7861,
715,
340,
642,
4260,
1990,
1586,
701,
314,
5644,
445,
317,
2842,
14,
267,
520,
635,
2813,
63,
1667,
63,
1661,
63,
5527,
26,
7480,
370,
2813,
2701,
4008,
315,
5644,
6076,
1338,
14,
267,
520,
635,
370,
63,
740,
26,
8295,
710,
5046,
574,
340,
4260,
574,
5644,
4839,
370,
506,
11544,
370,
282,
4260,
315,
5644,
314,
4243,
402,
282,
3420,
14,
267,
408,
267,
340,
440,
1228,
8,
504,
63,
2764,
12,
2155,
304,
288,
746,
3146,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
israeleriston/scientific-week
|
backend/venv/lib/python3.5/site-packages/sqlalchemy/dialects/mysql/gaerdbms.py
|
33
|
3387
|
# mysql/gaerdbms.py
# Copyright (C) 2005-2017 the SQLAlchemy authors and contributors
# <see AUTHORS file>
#
# This module is part of SQLAlchemy and is released under
# the MIT License: http://www.opensource.org/licenses/mit-license.php
"""
.. dialect:: mysql+gaerdbms
:name: Google Cloud SQL
:dbapi: rdbms
:connectstring: mysql+gaerdbms:///<dbname>?instance=<instancename>
:url: https://developers.google.com/appengine/docs/python/cloud-sql/\
developers-guide
This dialect is based primarily on the :mod:`.mysql.mysqldb` dialect with
minimal changes.
.. versionadded:: 0.7.8
.. deprecated:: 1.0 This dialect is **no longer necessary** for
Google Cloud SQL; the MySQLdb dialect can be used directly.
Cloud SQL now recommends creating connections via the
mysql dialect using the URL format
``mysql+mysqldb://root@/<dbname>?unix_socket=/cloudsql/<projectid>:<instancename>``
Pooling
-------
Google App Engine connections appear to be randomly recycled,
so the dialect does not pool connections. The :class:`.NullPool`
implementation is installed within the :class:`.Engine` by
default.
"""
import os
from .mysqldb import MySQLDialect_mysqldb
from ...pool import NullPool
import re
from sqlalchemy.util import warn_deprecated
def _is_dev_environment():
return os.environ.get('SERVER_SOFTWARE', '').startswith('Development/')
class MySQLDialect_gaerdbms(MySQLDialect_mysqldb):
@classmethod
def dbapi(cls):
warn_deprecated(
"Google Cloud SQL now recommends creating connections via the "
"MySQLdb dialect directly, using the URL format "
"mysql+mysqldb://root@/<dbname>?unix_socket=/cloudsql/"
"<projectid>:<instancename>"
)
# from django:
# http://code.google.com/p/googleappengine/source/
# browse/trunk/python/google/storage/speckle/
# python/django/backend/base.py#118
# see also [ticket:2649]
# see also http://stackoverflow.com/q/14224679/34549
from google.appengine.api import apiproxy_stub_map
if _is_dev_environment():
from google.appengine.api import rdbms_mysqldb
return rdbms_mysqldb
elif apiproxy_stub_map.apiproxy.GetStub('rdbms'):
from google.storage.speckle.python.api import rdbms_apiproxy
return rdbms_apiproxy
else:
from google.storage.speckle.python.api import rdbms_googleapi
return rdbms_googleapi
@classmethod
def get_pool_class(cls, url):
# Cloud SQL connections die at any moment
return NullPool
def create_connect_args(self, url):
opts = url.translate_connect_args()
if not _is_dev_environment():
# 'dsn' and 'instance' are because we are skipping
# the traditional google.api.rdbms wrapper
opts['dsn'] = ''
opts['instance'] = url.query['instance']
return [], opts
def _extract_error_code(self, exception):
match = re.compile(r"^(\d+)L?:|^\((\d+)L?,").match(str(exception))
# The rdbms api will wrap then re-raise some types of errors
# making this regex return no matches.
code = match.group(1) or match.group(2) if match else None
if code:
return int(code)
dialect = MySQLDialect_gaerdbms
|
mit
|
[
3,
12896,
15,
5294,
281,
697,
706,
14,
647,
199,
3,
1898,
334,
35,
9,
11811,
13,
10680,
314,
14303,
11462,
436,
8417,
199,
3,
665,
3239,
10610,
570,
30,
199,
3,
199,
3,
961,
859,
365,
1777,
402,
14303,
436,
365,
14286,
1334,
199,
3,
314,
10697,
844,
26,
1455,
921,
1544,
14,
16374,
14,
1308,
15,
2383,
15,
1147,
13,
1682,
14,
8624,
199,
624,
199,
703,
10982,
447,
12896,
11,
5294,
281,
697,
706,
272,
520,
354,
26,
4475,
8142,
5385,
272,
520,
22103,
26,
519,
697,
706,
272,
520,
2242,
875,
26,
12896,
11,
5294,
281,
697,
706,
921,
8316,
13238,
30,
31,
842,
18987,
3615,
290,
25869,
30,
272,
520,
633,
26,
4178,
921,
23826,
14,
3098,
14,
957,
15,
15358,
15,
4757,
15,
1548,
15,
4091,
13,
3009,
6307,
199,
23826,
13,
17348,
339,
961,
10982,
365,
4079,
1979,
30468,
641,
314,
520,
1494,
5026,
8644,
14,
8644,
697,
64,
10982,
543,
272,
13460,
4493,
14,
339,
2508,
7445,
447,
378,
14,
23,
14,
24,
339,
2508,
5906,
447,
413,
14,
16,
961,
10982,
365,
1011,
889,
8088,
5784,
538,
367,
267,
4475,
8142,
5385,
27,
314,
25709,
10982,
883,
506,
1202,
5370,
14,
267,
8142,
5385,
3063,
295,
9847,
795,
6425,
6947,
4799,
314,
267,
12896,
10982,
1808,
314,
2851,
1475,
398,
1124,
8644,
11,
8644,
697,
921,
1231,
32,
8316,
13238,
30,
31,
11864,
63,
3450,
13043,
29691,
1710,
8316,
5468,
31157,
30,
16875,
3615,
290,
25869,
28210,
421,
199,
22349,
199,
12797,
199,
199,
13266,
4693,
12580,
6947,
7468,
370,
506,
19311,
295,
1480,
67,
1146,
12,
199,
1152,
314,
10982,
1630,
440,
4203,
6947,
14,
221,
710,
520,
533,
5026,
8849,
5453,
64,
199,
12236,
365,
4903,
4453,
314,
520,
533,
5026,
8524,
64,
701,
199,
885,
14,
199,
199,
624,
199,
199,
646,
747,
199,
199,
504,
1275,
8644,
697,
492,
11200,
22080,
63,
8644,
697,
199,
504,
2263,
2293,
492,
12119,
5453,
199,
646,
295,
199,
504,
8335,
14,
1974,
492,
7987,
63,
6667,
421,
199,
318,
485,
374,
63,
2374,
63,
5418,
837,
272,
372,
747,
14,
2314,
14,
362,
360,
6613,
63,
26734,
297,
12548,
2460,
360,
23753,
6217,
421,
199,
533,
11200,
22080,
63,
5294,
281,
697,
706,
8,
20784,
22080,
63,
8644,
697,
304,
339,
768,
3744,
272,
347,
29333,
8,
1886,
304,
398,
7987,
63,
6667,
8,
288,
298,
13266,
8142,
5385,
3063,
295,
9847,
795,
6425,
6947,
4799,
314,
298,
288,
298,
20784,
697,
10982,
5370,
12,
1808,
314,
2851,
1475,
298,
288,
298,
8644,
11,
8644,
697,
921,
1231,
32,
8316,
13238,
30,
31,
11864,
63,
3450,
13043,
29691,
1710,
6687,
288,
3886,
5468,
31157,
30,
16875,
3615,
290,
25869,
4335,
267,
776,
398,
327,
687,
1639,
26,
267,
327,
1455,
921,
600,
14,
3098,
14,
957,
15,
80,
15,
3098,
15358,
15,
1365,
15,
267,
327,
258,
19249,
15,
13409,
15,
1548,
15,
3098,
15,
3494,
15,
12325,
346,
274,
15,
267,
327,
2366,
15,
1176,
15,
4620,
15,
1095,
14,
647,
3,
7906,
267,
327,
1937,
2597,
359,
9201,
26,
9408,
25,
61,
267,
327,
1937,
2597,
1455,
921,
23153,
14,
957,
15,
81,
15,
1079,
8731,
18450,
15,
1082,
15419,
267,
687,
6233,
14,
15358,
14,
1246,
492,
2986,
3280,
63,
5811,
63,
1130,
398,
340,
485,
374,
63,
2374,
63,
5418,
837,
288,
687,
6233,
14,
15358,
14,
1246,
492,
519,
697,
706,
63,
8644,
697,
288,
372,
519,
697,
706,
63,
8644,
697,
267,
916,
2986,
3280,
63,
5811,
63,
1130,
14,
1246,
3280,
14,
1002,
8067,
360,
82,
697,
706,
735,
288,
687,
6233,
14,
3494,
14,
12325,
346,
274,
14,
1548,
14,
1246,
492,
519,
697,
706,
63,
1246,
3280,
288,
372,
519,
697,
706,
63,
1246,
3280,
267,
587,
26,
288,
687,
6233,
14,
3494,
14,
12325,
346,
274,
14,
1548,
14,
1246,
492,
519,
697,
706,
63,
3098,
1246,
288,
372,
519,
697,
706,
63,
3098,
1246,
339,
768,
3744,
272,
347,
664,
63,
2293,
63,
533,
8,
1886,
12,
1166,
304,
267,
327,
8142,
5385,
6947,
18833,
737,
1263,
12427,
267,
372,
12119,
5453,
339,
347,
1218,
63,
2242,
63,
589,
8,
277,
12,
1166,
304,
267,
3999,
275,
1166,
14,
5275,
63,
2242,
63,
589,
342,
267,
340,
440,
485,
374,
63,
2374,
63,
5418,
837,
288,
327,
283,
32510,
7,
436,
283,
842,
7,
787,
2952,
781,
787,
16068,
288,
327,
314,
1468,
2603,
6233,
14,
1246,
14,
82,
697,
706,
4975,
288,
3999,
459,
32510,
418,
275,
2125,
288,
3999,
459,
842,
418,
275,
1166,
14,
1131,
459,
842,
418,
267,
372,
990,
3999,
339,
347,
485,
5005,
63,
705,
63,
600,
8,
277,
12,
1919,
304,
267,
1336,
275,
295,
14,
2014,
8,
82,
16136,
2961,
68,
8771,
44,
31,
26,
92,
12773,
1332,
60,
68,
8771,
44,
22556,
3471,
1431,
8,
495,
8,
1971,
430,
267,
327,
710,
519,
697,
706,
2986,
911,
4816,
2066,
295,
13,
3730,
2005,
2943,
402,
2552,
267,
327,
10663,
642,
5163,
372,
949,
4450,
14,
267,
1233,
275,
1336,
14,
923,
8,
17,
9,
503,
1336,
14,
923,
8,
18,
9,
340,
1336,
587,
488,
267,
340,
1233,
26,
288,
372,
1109,
8,
600,
9,
199,
199,
11072,
275,
11200,
22080,
63,
5294,
281,
697,
706,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
12896,
15,
5294,
281,
697,
706,
14,
647,
199,
3,
1898,
334,
35,
9,
11811,
13,
10680,
314,
14303,
11462,
436,
8417,
199,
3,
665,
3239,
10610,
570,
30,
199,
3,
199,
3,
961,
859,
365,
1777,
402,
14303,
436,
365,
14286,
1334,
199,
3,
314,
10697,
844,
26,
1455,
921,
1544,
14,
16374,
14,
1308,
15,
2383,
15,
1147,
13,
1682,
14,
8624,
199,
624,
199,
703,
10982,
447,
12896,
11,
5294,
281,
697,
706,
272,
520,
354,
26,
4475,
8142,
5385,
272,
520,
22103,
26,
519,
697,
706,
272,
520,
2242,
875,
26,
12896,
11,
5294,
281,
697,
706,
921,
8316,
13238,
30,
31,
842,
18987,
3615,
290,
25869,
30,
272,
520,
633,
26,
4178,
921,
23826,
14,
3098,
14,
957,
15,
15358,
15,
4757,
15,
1548,
15,
4091,
13,
3009,
6307,
199,
23826,
13,
17348,
339,
961,
10982,
365,
4079,
1979,
30468,
641,
314,
520,
1494,
5026,
8644,
14,
8644,
697,
64,
10982,
543,
272,
13460,
4493,
14,
339,
2508,
7445,
447,
378,
14,
23,
14,
24,
339,
2508,
5906,
447,
413,
14,
16,
961,
10982,
365,
1011,
889,
8088,
5784,
538,
367,
267,
4475,
8142,
5385,
27,
314,
25709,
10982,
883,
506,
1202,
5370,
14,
267,
8142,
5385,
3063,
295,
9847,
795,
6425,
6947,
4799,
314,
267,
12896,
10982,
1808,
314,
2851,
1475,
398,
1124,
8644,
11,
8644,
697,
921,
1231,
32,
8316,
13238,
30,
31,
11864,
63,
3450,
13043,
29691,
1710,
8316,
5468,
31157,
30,
16875,
3615,
290,
25869,
28210,
421,
199,
22349,
199,
12797,
199,
199,
13266,
4693,
12580,
6947,
7468,
370,
506,
19311,
295,
1480,
67,
1146,
12,
199,
1152,
314,
10982,
1630,
440,
4203,
6947,
14,
221,
710,
520,
533,
5026,
8849,
5453,
64,
199,
12236,
365,
4903,
4453,
314,
520,
533,
5026,
8524,
64,
701,
199,
885,
14,
199,
199,
624,
199,
199,
646,
747,
199,
199,
504,
1275,
8644,
697,
492,
11200,
22080,
63,
8644,
697,
199,
504,
2263,
2293,
492,
12119,
5453,
199,
646,
295,
199,
504,
8335,
14,
1974,
492,
7987,
63,
6667,
421,
199,
318,
485,
374,
63,
2374,
63,
5418,
837,
272,
372,
747,
14,
2314,
14,
362,
360,
6613,
63,
26734,
297,
12548,
2460,
360,
23753,
6217,
421,
199,
533,
11200,
22080,
63,
5294,
281,
697,
706,
8,
20784,
22080,
63,
8644,
697,
304,
339,
768,
3744,
272,
347,
29333,
8,
1886,
304,
398,
7987,
63,
6667,
8,
288,
298,
13266,
8142,
5385,
3063,
295,
9847,
795,
6425,
6947,
4799,
314,
298,
288,
298,
20784,
697,
10982,
5370,
12,
1808,
314,
2851,
1475,
298,
288,
298,
8644,
11,
8644,
697,
921,
1231,
32,
8316,
13238,
30,
31,
11864,
63,
3450,
13043,
29691,
1710,
6687,
288,
3886,
5468,
31157,
30,
16875,
3615,
290,
25869,
4335,
267,
776,
398,
327,
687,
1639,
26,
267,
327,
1455,
921,
600,
14,
3098,
14,
957,
15,
80,
15,
3098,
15358,
15,
1365,
15,
267,
327,
258,
19249,
15,
13409,
15,
1548,
15,
3098,
15,
3494,
15,
12325,
346,
274,
15,
267,
327,
2366,
15,
1176,
15,
4620,
15,
1095,
14,
647,
3,
7906,
267,
327,
1937,
2597,
359,
9201,
26,
9408,
25,
61,
267,
327,
1937,
2597,
1455,
921,
23153,
14,
957,
15,
81,
15,
1079,
8731,
18450,
15,
1082,
15419,
267,
687,
6233,
14,
15358,
14,
1246,
492,
2986,
3280,
63,
5811,
63,
1130,
398,
340,
485,
374,
63,
2374,
63,
5418,
837,
288,
687,
6233,
14,
15358,
14,
1246,
492,
519,
697,
706,
63,
8644,
697,
288,
372,
519,
697,
706,
63,
8644,
697,
267,
916,
2986,
3280,
63,
5811,
63,
1130,
14,
1246,
3280,
14,
1002,
8067,
360,
82,
697,
706,
735,
288,
687,
6233,
14,
3494,
14,
12325,
346,
274,
14,
1548,
14,
1246,
492,
519,
697,
706,
63,
1246,
3280,
288,
372,
519,
697,
706,
63,
1246,
3280,
267,
587,
26,
288,
687,
6233,
14,
3494,
14,
12325,
346,
274,
14,
1548,
14,
1246,
492,
519,
697,
706,
63,
3098,
1246,
288,
372,
519,
697,
706,
63,
3098,
1246,
339,
768,
3744,
272,
347,
664,
63,
2293,
63,
533,
8,
1886,
12,
1166,
304,
267,
327,
8142,
5385,
6947,
18833,
737,
1263,
12427,
267,
372,
12119,
5453,
339,
347,
1218,
63,
2242,
63,
589,
8,
277,
12,
1166,
304,
267,
3999,
275,
1166,
14,
5275,
63,
2242,
63,
589,
342,
267,
340,
440,
485,
374,
63,
2374,
63,
5418,
837,
288,
327,
283,
32510,
7,
436,
283,
842,
7,
787,
2952,
781,
787,
16068,
288,
327,
314,
1468,
2603,
6233,
14,
1246,
14,
82,
697,
706,
4975,
288,
3999,
459,
32510,
418,
275,
2125,
288,
3999,
459,
842,
418,
275,
1166,
14,
1131,
459,
842,
418,
267,
372,
990,
3999,
339,
347,
485,
5005,
63,
705,
63,
600,
8,
277,
12,
1919,
304,
267,
1336,
275,
295,
14,
2014,
8,
82,
16136,
2961,
68,
8771,
44,
31,
26,
92,
12773,
1332,
60,
68,
8771,
44,
22556,
3471,
1431,
8,
495,
8,
1971,
430,
267,
327,
710,
519,
697,
706,
2986,
911,
4816,
2066,
295,
13,
3730,
2005,
2943,
402,
2552,
267,
327,
10663,
642,
5163,
372,
949,
4450,
14,
267,
1233,
275,
1336,
14,
923,
8,
17,
9,
503,
1336,
14,
923,
8,
18,
9,
340,
1336,
587,
488,
267,
340,
1233,
26,
288,
372,
1109,
8,
600,
9,
199,
199,
11072,
275,
11200,
22080,
63,
5294,
281,
697,
706,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,
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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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
sti-lyneos/shop
|
softwarecenter/backend/oneconfhandler/__init__.py
|
7
|
1342
|
# -*- coding: utf-8 -*-
# Copyright (C) 2011 Canonical
#
# Authors:
# Didier Roche
#
# 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; version 3.
#
# 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
# singleton
oneconf_handler = None
def get_oneconf_handler(oneconfviewpickler=None):
global oneconf_handler
try:
from softwarecenter.backend.oneconfhandler.core import OneConfHandler
except ImportError:
return None
if oneconf_handler is None and oneconfviewpickler:
oneconf_handler = OneConfHandler(oneconfviewpickler)
return oneconf_handler
def is_oneconf_available():
try:
from softwarecenter.backend.oneconfhandler.core import OneConfHandler
OneConfHandler # pyflakes
return True
except ImportError:
pass
return False
|
lgpl-3.0
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
1898,
334,
35,
9,
7760,
6855,
7174,
199,
3,
199,
3,
6642,
26,
199,
3,
221,
3757,
328,
281,
6848,
595,
199,
3,
199,
3,
961,
2240,
365,
2867,
2032,
27,
1265,
883,
3604,
652,
436,
15,
269,
2811,
652,
1334,
199,
3,
314,
2895,
402,
314,
1664,
1696,
1684,
844,
465,
3267,
701,
314,
2868,
2290,
199,
3,
2752,
27,
1015,
650,
14,
199,
3,
199,
3,
961,
2240,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
1325,
2428,
199,
3,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
3169,
503,
3092,
199,
3,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
1664,
1696,
1684,
844,
367,
1655,
199,
3,
2436,
14,
199,
3,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
1696,
1684,
844,
3180,
543,
199,
3,
642,
2240,
27,
340,
440,
12,
2218,
370,
314,
2868,
2290,
2752,
12,
3277,
2020,
199,
3,
8026,
11236,
14259,
12,
12066,
11844,
12,
8226,
12,
4828,
11315,
13,
10067,
8217,
421,
199,
3,
19768,
199,
368,
2190,
63,
2232,
275,
488,
421,
199,
318,
664,
63,
368,
2190,
63,
2232,
8,
368,
2190,
1345,
23468,
29,
403,
304,
272,
2288,
1373,
2190,
63,
2232,
272,
862,
26,
267,
687,
2032,
4218,
14,
4620,
14,
368,
2190,
2232,
14,
1018,
492,
7309,
8930,
2461,
272,
871,
3545,
26,
267,
372,
488,
272,
340,
1373,
2190,
63,
2232,
365,
488,
436,
1373,
2190,
1345,
23468,
26,
267,
1373,
2190,
63,
2232,
275,
7309,
8930,
2461,
8,
368,
2190,
1345,
23468,
9,
272,
372,
1373,
2190,
63,
2232,
421,
199,
318,
365,
63,
368,
2190,
63,
4561,
837,
272,
862,
26,
267,
687,
2032,
4218,
14,
4620,
14,
368,
2190,
2232,
14,
1018,
492,
7309,
8930,
2461,
267,
7309,
8930,
2461,
221,
327,
1134,
29677,
267,
372,
715,
272,
871,
3545,
26,
267,
986,
272,
372,
756,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,
35,
9,
7760,
6855,
7174,
199,
3,
199,
3,
6642,
26,
199,
3,
221,
3757,
328,
281,
6848,
595,
199,
3,
199,
3,
961,
2240,
365,
2867,
2032,
27,
1265,
883,
3604,
652,
436,
15,
269,
2811,
652,
1334,
199,
3,
314,
2895,
402,
314,
1664,
1696,
1684,
844,
465,
3267,
701,
314,
2868,
2290,
199,
3,
2752,
27,
1015,
650,
14,
199,
3,
199,
3,
961,
2240,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
1325,
2428,
199,
3,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
3169,
503,
3092,
199,
3,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
1664,
1696,
1684,
844,
367,
1655,
199,
3,
2436,
14,
199,
3,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
1696,
1684,
844,
3180,
543,
199,
3,
642,
2240,
27,
340,
440,
12,
2218,
370,
314,
2868,
2290,
2752,
12,
3277,
2020,
199,
3,
8026,
11236,
14259,
12,
12066,
11844,
12,
8226,
12,
4828,
11315,
13,
10067,
8217,
421,
199,
3,
19768,
199,
368,
2190,
63,
2232,
275,
488,
421,
199,
318,
664,
63,
368,
2190,
63,
2232,
8,
368,
2190,
1345,
23468,
29,
403,
304,
272,
2288,
1373,
2190,
63,
2232,
272,
862,
26,
267,
687,
2032,
4218,
14,
4620,
14,
368,
2190,
2232,
14,
1018,
492,
7309,
8930,
2461,
272,
871,
3545,
26,
267,
372,
488,
272,
340,
1373,
2190,
63,
2232,
365,
488,
436,
1373,
2190,
1345,
23468,
26,
267,
1373,
2190,
63,
2232,
275,
7309,
8930,
2461,
8,
368,
2190,
1345,
23468,
9,
272,
372,
1373,
2190,
63,
2232,
421,
199,
318,
365,
63,
368,
2190,
63,
4561,
837,
272,
862,
26,
267,
687,
2032,
4218,
14,
4620,
14,
368,
2190,
2232,
14,
1018,
492,
7309,
8930,
2461,
267,
7309,
8930,
2461,
221,
327,
1134,
29677,
267,
372,
715,
272,
871,
3545,
26,
267,
986,
272,
372,
756,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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
] |
TNT-Samuel/Coding-Projects
|
DNS Server/Source - Copy/Lib/site-packages/pygments/lexers/sas.py
|
31
|
9449
|
# -*- coding: utf-8 -*-
"""
pygments.lexers.sas
~~~~~~~~~~~~~~~~~~~
Lexer for SAS.
:copyright: Copyright 2006-2017 by the Pygments team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
import re
from pygments.lexer import RegexLexer, include, words
from pygments.token import Comment, Keyword, Name, Number, String, Text, \
Other, Generic
__all__ = ['SASLexer']
class SASLexer(RegexLexer):
"""
For `SAS <http://www.sas.com/>`_ files.
.. versionadded:: 2.2
"""
# Syntax from syntax/sas.vim by James Kidd <james.kidd@covance.com>
name = 'SAS'
aliases = ['sas']
filenames = ['*.SAS', '*.sas']
mimetypes = ['text/x-sas', 'text/sas', 'application/x-sas']
flags = re.IGNORECASE | re.MULTILINE
builtins_macros = (
"bquote", "nrbquote", "cmpres", "qcmpres", "compstor", "datatyp",
"display", "do", "else", "end", "eval", "global", "goto", "if",
"index", "input", "keydef", "label", "left", "length", "let",
"local", "lowcase", "macro", "mend", "nrquote",
"nrstr", "put", "qleft", "qlowcase", "qscan",
"qsubstr", "qsysfunc", "qtrim", "quote", "qupcase", "scan",
"str", "substr", "superq", "syscall", "sysevalf", "sysexec",
"sysfunc", "sysget", "syslput", "sysprod", "sysrc", "sysrput",
"then", "to", "trim", "unquote", "until", "upcase", "verify",
"while", "window"
)
builtins_conditionals = (
"do", "if", "then", "else", "end", "until", "while"
)
builtins_statements = (
"abort", "array", "attrib", "by", "call", "cards", "cards4",
"catname", "continue", "datalines", "datalines4", "delete", "delim",
"delimiter", "display", "dm", "drop", "endsas", "error", "file",
"filename", "footnote", "format", "goto", "in", "infile", "informat",
"input", "keep", "label", "leave", "length", "libname", "link",
"list", "lostcard", "merge", "missing", "modify", "options", "output",
"out", "page", "put", "redirect", "remove", "rename", "replace",
"retain", "return", "select", "set", "skip", "startsas", "stop",
"title", "update", "waitsas", "where", "window", "x", "systask"
)
builtins_sql = (
"add", "and", "alter", "as", "cascade", "check", "create",
"delete", "describe", "distinct", "drop", "foreign", "from",
"group", "having", "index", "insert", "into", "in", "key", "like",
"message", "modify", "msgtype", "not", "null", "on", "or",
"order", "primary", "references", "reset", "restrict", "select",
"set", "table", "unique", "update", "validate", "view", "where"
)
builtins_functions = (
"abs", "addr", "airy", "arcos", "arsin", "atan", "attrc",
"attrn", "band", "betainv", "blshift", "bnot", "bor",
"brshift", "bxor", "byte", "cdf", "ceil", "cexist", "cinv",
"close", "cnonct", "collate", "compbl", "compound",
"compress", "cos", "cosh", "css", "curobs", "cv", "daccdb",
"daccdbsl", "daccsl", "daccsyd", "dacctab", "dairy", "date",
"datejul", "datepart", "datetime", "day", "dclose", "depdb",
"depdbsl", "depsl", "depsyd",
"deptab", "dequote", "dhms", "dif", "digamma",
"dim", "dinfo", "dnum", "dopen", "doptname", "doptnum",
"dread", "dropnote", "dsname", "erf", "erfc", "exist", "exp",
"fappend", "fclose", "fcol", "fdelete", "fetch", "fetchobs",
"fexist", "fget", "fileexist", "filename", "fileref",
"finfo", "finv", "fipname", "fipnamel", "fipstate", "floor",
"fnonct", "fnote", "fopen", "foptname", "foptnum", "fpoint",
"fpos", "fput", "fread", "frewind", "frlen", "fsep", "fuzz",
"fwrite", "gaminv", "gamma", "getoption", "getvarc", "getvarn",
"hbound", "hms", "hosthelp", "hour", "ibessel", "index",
"indexc", "indexw", "input", "inputc", "inputn", "int",
"intck", "intnx", "intrr", "irr", "jbessel", "juldate",
"kurtosis", "lag", "lbound", "left", "length", "lgamma",
"libname", "libref", "log", "log10", "log2", "logpdf", "logpmf",
"logsdf", "lowcase", "max", "mdy", "mean", "min", "minute",
"mod", "month", "mopen", "mort", "n", "netpv", "nmiss",
"normal", "note", "npv", "open", "ordinal", "pathname",
"pdf", "peek", "peekc", "pmf", "point", "poisson", "poke",
"probbeta", "probbnml", "probchi", "probf", "probgam",
"probhypr", "probit", "probnegb", "probnorm", "probt",
"put", "putc", "putn", "qtr", "quote", "ranbin", "rancau",
"ranexp", "rangam", "range", "rank", "rannor", "ranpoi",
"rantbl", "rantri", "ranuni", "repeat", "resolve", "reverse",
"rewind", "right", "round", "saving", "scan", "sdf", "second",
"sign", "sin", "sinh", "skewness", "soundex", "spedis",
"sqrt", "std", "stderr", "stfips", "stname", "stnamel",
"substr", "sum", "symget", "sysget", "sysmsg", "sysprod",
"sysrc", "system", "tan", "tanh", "time", "timepart", "tinv",
"tnonct", "today", "translate", "tranwrd", "trigamma",
"trim", "trimn", "trunc", "uniform", "upcase", "uss", "var",
"varfmt", "varinfmt", "varlabel", "varlen", "varname",
"varnum", "varray", "varrayx", "vartype", "verify", "vformat",
"vformatd", "vformatdx", "vformatn", "vformatnx", "vformatw",
"vformatwx", "vformatx", "vinarray", "vinarrayx", "vinformat",
"vinformatd", "vinformatdx", "vinformatn", "vinformatnx",
"vinformatw", "vinformatwx", "vinformatx", "vlabel",
"vlabelx", "vlength", "vlengthx", "vname", "vnamex", "vtype",
"vtypex", "weekday", "year", "yyq", "zipfips", "zipname",
"zipnamel", "zipstate"
)
tokens = {
'root': [
include('comments'),
include('proc-data'),
include('cards-datalines'),
include('logs'),
include('general'),
(r'.', Text),
],
# SAS is multi-line regardless, but * is ended by ;
'comments': [
(r'^\s*\*.*?;', Comment),
(r'/\*.*?\*/', Comment),
(r'^\s*\*(.|\n)*?;', Comment.Multiline),
(r'/[*](.|\n)*?[*]/', Comment.Multiline),
],
# Special highlight for proc, data, quit, run
'proc-data': [
(r'(^|;)\s*(proc \w+|data|run|quit)[\s;]',
Keyword.Reserved),
],
# Special highlight cards and datalines
'cards-datalines': [
(r'^\s*(datalines|cards)\s*;\s*$', Keyword, 'data'),
],
'data': [
(r'(.|\n)*^\s*;\s*$', Other, '#pop'),
],
# Special highlight for put NOTE|ERROR|WARNING (order matters)
'logs': [
(r'\n?^\s*%?put ', Keyword, 'log-messages'),
],
'log-messages': [
(r'NOTE(:|-).*', Generic, '#pop'),
(r'WARNING(:|-).*', Generic.Emph, '#pop'),
(r'ERROR(:|-).*', Generic.Error, '#pop'),
include('general'),
],
'general': [
include('keywords'),
include('vars-strings'),
include('special'),
include('numbers'),
],
# Keywords, statements, functions, macros
'keywords': [
(words(builtins_statements,
prefix = r'\b',
suffix = r'\b'),
Keyword),
(words(builtins_sql,
prefix = r'\b',
suffix = r'\b'),
Keyword),
(words(builtins_conditionals,
prefix = r'\b',
suffix = r'\b'),
Keyword),
(words(builtins_macros,
prefix = r'%',
suffix = r'\b'),
Name.Builtin),
(words(builtins_functions,
prefix = r'\b',
suffix = r'\('),
Name.Builtin),
],
# Strings and user-defined variables and macros (order matters)
'vars-strings': [
(r'&[a-z_]\w{0,31}\.?', Name.Variable),
(r'%[a-z_]\w{0,31}', Name.Function),
(r'\'', String, 'string_squote'),
(r'"', String, 'string_dquote'),
],
'string_squote': [
('\'', String, '#pop'),
(r'\\\\|\\"|\\\n', String.Escape),
# AFAIK, macro variables are not evaluated in single quotes
# (r'&', Name.Variable, 'validvar'),
(r'[^$\'\\]+', String),
(r'[$\'\\]', String),
],
'string_dquote': [
(r'"', String, '#pop'),
(r'\\\\|\\"|\\\n', String.Escape),
(r'&', Name.Variable, 'validvar'),
(r'[^$&"\\]+', String),
(r'[$"\\]', String),
],
'validvar': [
(r'[a-z_]\w{0,31}\.?', Name.Variable, '#pop'),
],
# SAS numbers and special variables
'numbers': [
(r'\b[+-]?([0-9]+(\.[0-9]+)?|\.[0-9]+|\.)(E[+-]?[0-9]+)?i?\b',
Number),
],
'special': [
(r'(null|missing|_all_|_automatic_|_character_|_n_|'
r'_infile_|_name_|_null_|_numeric_|_user_|_webout_)',
Keyword.Constant),
],
# 'operators': [
# (r'(-|=|<=|>=|<|>|<>|&|!=|'
# r'\||\*|\+|\^|/|!|~|~=)', Operator)
# ],
}
|
gpl-3.0
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
624,
272,
13277,
14,
12245,
14,
22601,
272,
18294,
23597,
339,
21125,
367,
26124,
14,
339,
520,
7307,
26,
1898,
8315,
13,
10680,
701,
314,
14493,
8099,
12,
1937,
10610,
14,
272,
520,
1682,
26,
6289,
12,
1937,
5113,
367,
2436,
14,
199,
624,
199,
199,
646,
295,
199,
504,
13277,
14,
11729,
492,
12939,
5838,
12,
2387,
12,
5932,
199,
504,
13277,
14,
1418,
492,
6819,
12,
6431,
12,
2812,
12,
4860,
12,
2624,
12,
4516,
12,
971,
272,
5439,
12,
8307,
199,
199,
363,
452,
363,
275,
788,
15319,
5838,
418,
421,
199,
533,
26124,
5838,
8,
19856,
304,
272,
408,
272,
2104,
658,
15319,
665,
1014,
921,
1544,
14,
22601,
14,
957,
3133,
18417,
1584,
14,
339,
2508,
7445,
447,
499,
14,
18,
272,
408,
272,
327,
18377,
687,
6302,
15,
22601,
14,
16361,
701,
1603,
14015,
1804,
344,
68,
665,
74,
14015,
14,
75,
344,
68,
32,
331,
6278,
14,
957,
30,
339,
536,
420,
275,
283,
15319,
7,
272,
5481,
257,
275,
788,
22601,
418,
272,
6203,
275,
17855,
15319,
297,
11937,
22601,
418,
272,
13290,
275,
788,
505,
15,
88,
13,
22601,
297,
283,
505,
15,
22601,
297,
283,
3578,
15,
88,
13,
22601,
418,
272,
3285,
258,
275,
295,
14,
15434,
1204,
295,
14,
16661,
339,
12963,
63,
16358,
275,
334,
267,
298,
66,
3513,
401,
298,
78,
4848,
3513,
401,
298,
5730,
470,
401,
298,
81,
5730,
470,
401,
298,
863,
8041,
401,
298,
4616,
292,
2279,
401,
267,
298,
2918,
401,
298,
1117,
401,
298,
2836,
401,
298,
500,
401,
298,
2579,
401,
298,
2966,
401,
298,
14867,
401,
298,
692,
401,
267,
298,
1080,
401,
298,
1210,
401,
298,
498,
318,
401,
298,
1302,
401,
298,
3039,
401,
298,
1267,
401,
298,
2723,
401,
267,
298,
1832,
401,
298,
674,
2546,
401,
298,
11300,
401,
298,
13419,
401,
298,
7865,
3513,
401,
267,
298,
7865,
495,
401,
298,
524,
401,
298,
81,
3039,
401,
298,
81,
674,
2546,
401,
298,
81,
6282,
401,
267,
298,
81,
22668,
401,
298,
81,
1274,
1532,
401,
298,
81,
12263,
401,
298,
3513,
401,
298,
81,
384,
2546,
401,
298,
6282,
401,
267,
298,
495,
401,
298,
22668,
401,
298,
4792,
81,
401,
298,
19444,
401,
298,
1786,
261,
3042,
276,
401,
298,
1786,
261,
9542,
401,
267,
298,
1274,
1532,
401,
298,
1274,
362,
401,
298,
1274,
76,
524,
401,
298,
1274,
8788,
401,
298,
1274,
1195,
401,
298,
1274,
82,
524,
401,
267,
298,
12726,
401,
298,
475,
401,
298,
12263,
401,
298,
12240,
401,
298,
8111,
401,
298,
384,
2546,
401,
298,
4712,
401,
267,
298,
6710,
401,
298,
3806,
2,
272,
776,
339,
12963,
63,
5394,
2551,
275,
334,
267,
298,
1117,
401,
298,
692,
401,
298,
12726,
401,
298,
2836,
401,
298,
500,
401,
298,
8111,
401,
298,
6710,
2,
272,
776,
339,
12963,
63,
15384,
275,
334,
267,
298,
13845,
401,
298,
1144,
401,
298,
6640,
401,
298,
991,
401,
298,
1250,
401,
298,
13761,
401,
298,
13761,
20,
401,
267,
298,
3385,
354,
401,
298,
6958,
401,
298,
4616,
279,
3746,
401,
298,
4616,
279,
3746,
20,
401,
298,
1807,
401,
298,
15966,
401,
267,
298,
15104,
401,
298,
2918,
401,
298,
6428,
401,
298,
4824,
401,
298,
3198,
305,
401,
298,
705,
401,
298,
493,
401,
267,
298,
1501,
401,
298,
19589,
401,
298,
908,
401,
298,
14867,
401,
298,
262,
401,
298,
13880,
401,
298,
262,
908,
401,
267,
298,
1210,
401,
298,
3250,
401,
298,
1302,
401,
298,
12422,
401,
298,
1267,
401,
298,
773,
354,
401,
298,
1073,
401,
267,
298,
513,
401,
298,
22031,
5841,
401,
298,
5628,
401,
298,
4752,
401,
298,
8951,
401,
298,
1419,
401,
298,
1199,
401,
267,
298,
548,
401,
298,
1606,
401,
298,
524,
401,
298,
4876,
401,
298,
2168,
401,
298,
8165,
401,
298,
1814,
401,
267,
298,
264,
877,
401,
298,
1107,
401,
298,
2416,
401,
298,
409,
401,
298,
2759,
401,
298,
17116,
305,
401,
298,
2379,
401,
267,
298,
1213,
401,
298,
873,
401,
298,
758,
1405,
305,
401,
298,
4509,
401,
298,
3806,
401,
298,
88,
401,
298,
1786,
270,
813,
2,
272,
776,
339,
12963,
63,
3009,
275,
334,
267,
298,
525,
401,
298,
460,
401,
298,
11858,
401,
298,
305,
401,
298,
15377,
401,
298,
1074,
401,
298,
981,
401,
267,
298,
1807,
401,
298,
11935,
401,
298,
12926,
401,
298,
4824,
401,
298,
6846,
401,
298,
504,
401,
267,
298,
923,
401,
298,
31569,
401,
298,
1080,
401,
298,
3176,
401,
298,
9924,
401,
298,
262,
401,
298,
498,
401,
298,
2930,
401,
267,
298,
1188,
401,
298,
8951,
401,
298,
1328,
466,
401,
298,
1397,
401,
298,
2307,
401,
298,
265,
401,
298,
269,
401,
267,
298,
1648,
401,
298,
3327,
401,
298,
12635,
401,
298,
3958,
401,
298,
22188,
401,
298,
2416,
401,
267,
298,
409,
401,
298,
1224,
401,
298,
3235,
401,
298,
873,
401,
298,
3502,
401,
298,
1345,
401,
298,
4509,
2,
272,
776,
339,
12963,
63,
5777,
275,
334,
267,
298,
2101,
401,
298,
2697,
401,
298,
5789,
651,
401,
298,
285,
5197,
401,
298,
4291,
262,
401,
298,
16080,
401,
298,
962,
67,
401,
267,
298,
962,
78,
401,
298,
7877,
401,
298,
9549,
1581,
86,
401,
298,
66,
23025,
2949,
401,
298,
66,
1397,
401,
298,
31938,
401,
267,
298,
3289,
4723,
401,
298,
13691,
269,
401,
298,
4414,
401,
298,
10790,
401,
298,
14085,
401,
298,
301,
88,
631,
401,
298,
67,
5350,
401,
267,
298,
1600,
401,
298,
67,
2865,
319,
401,
298,
761,
750,
401,
298,
863,
3345,
401,
298,
15278,
401,
267,
298,
6447,
401,
298,
5197,
401,
298,
15106,
401,
298,
3919,
401,
298,
67,
9129,
1533,
401,
298,
5107,
401,
298,
68,
5470,
697,
401,
267,
298,
68,
5470,
697,
2482,
401,
298,
31811,
1259,
76,
401,
298,
31811,
1259,
24503,
401,
298,
68,
23015,
371,
401,
298,
983,
73,
651,
401,
298,
602,
401,
267,
298,
602,
74,
348,
401,
298,
602,
2064,
401,
298,
2083,
401,
298,
2977,
401,
298,
68,
1600,
401,
298,
2601,
697,
401
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
624,
272,
13277,
14,
12245,
14,
22601,
272,
18294,
23597,
339,
21125,
367,
26124,
14,
339,
520,
7307,
26,
1898,
8315,
13,
10680,
701,
314,
14493,
8099,
12,
1937,
10610,
14,
272,
520,
1682,
26,
6289,
12,
1937,
5113,
367,
2436,
14,
199,
624,
199,
199,
646,
295,
199,
504,
13277,
14,
11729,
492,
12939,
5838,
12,
2387,
12,
5932,
199,
504,
13277,
14,
1418,
492,
6819,
12,
6431,
12,
2812,
12,
4860,
12,
2624,
12,
4516,
12,
971,
272,
5439,
12,
8307,
199,
199,
363,
452,
363,
275,
788,
15319,
5838,
418,
421,
199,
533,
26124,
5838,
8,
19856,
304,
272,
408,
272,
2104,
658,
15319,
665,
1014,
921,
1544,
14,
22601,
14,
957,
3133,
18417,
1584,
14,
339,
2508,
7445,
447,
499,
14,
18,
272,
408,
272,
327,
18377,
687,
6302,
15,
22601,
14,
16361,
701,
1603,
14015,
1804,
344,
68,
665,
74,
14015,
14,
75,
344,
68,
32,
331,
6278,
14,
957,
30,
339,
536,
420,
275,
283,
15319,
7,
272,
5481,
257,
275,
788,
22601,
418,
272,
6203,
275,
17855,
15319,
297,
11937,
22601,
418,
272,
13290,
275,
788,
505,
15,
88,
13,
22601,
297,
283,
505,
15,
22601,
297,
283,
3578,
15,
88,
13,
22601,
418,
272,
3285,
258,
275,
295,
14,
15434,
1204,
295,
14,
16661,
339,
12963,
63,
16358,
275,
334,
267,
298,
66,
3513,
401,
298,
78,
4848,
3513,
401,
298,
5730,
470,
401,
298,
81,
5730,
470,
401,
298,
863,
8041,
401,
298,
4616,
292,
2279,
401,
267,
298,
2918,
401,
298,
1117,
401,
298,
2836,
401,
298,
500,
401,
298,
2579,
401,
298,
2966,
401,
298,
14867,
401,
298,
692,
401,
267,
298,
1080,
401,
298,
1210,
401,
298,
498,
318,
401,
298,
1302,
401,
298,
3039,
401,
298,
1267,
401,
298,
2723,
401,
267,
298,
1832,
401,
298,
674,
2546,
401,
298,
11300,
401,
298,
13419,
401,
298,
7865,
3513,
401,
267,
298,
7865,
495,
401,
298,
524,
401,
298,
81,
3039,
401,
298,
81,
674,
2546,
401,
298,
81,
6282,
401,
267,
298,
81,
22668,
401,
298,
81,
1274,
1532,
401,
298,
81,
12263,
401,
298,
3513,
401,
298,
81,
384,
2546,
401,
298,
6282,
401,
267,
298,
495,
401,
298,
22668,
401,
298,
4792,
81,
401,
298,
19444,
401,
298,
1786,
261,
3042,
276,
401,
298,
1786,
261,
9542,
401,
267,
298,
1274,
1532,
401,
298,
1274,
362,
401,
298,
1274,
76,
524,
401,
298,
1274,
8788,
401,
298,
1274,
1195,
401,
298,
1274,
82,
524,
401,
267,
298,
12726,
401,
298,
475,
401,
298,
12263,
401,
298,
12240,
401,
298,
8111,
401,
298,
384,
2546,
401,
298,
4712,
401,
267,
298,
6710,
401,
298,
3806,
2,
272,
776,
339,
12963,
63,
5394,
2551,
275,
334,
267,
298,
1117,
401,
298,
692,
401,
298,
12726,
401,
298,
2836,
401,
298,
500,
401,
298,
8111,
401,
298,
6710,
2,
272,
776,
339,
12963,
63,
15384,
275,
334,
267,
298,
13845,
401,
298,
1144,
401,
298,
6640,
401,
298,
991,
401,
298,
1250,
401,
298,
13761,
401,
298,
13761,
20,
401,
267,
298,
3385,
354,
401,
298,
6958,
401,
298,
4616,
279,
3746,
401,
298,
4616,
279,
3746,
20,
401,
298,
1807,
401,
298,
15966,
401,
267,
298,
15104,
401,
298,
2918,
401,
298,
6428,
401,
298,
4824,
401,
298,
3198,
305,
401,
298,
705,
401,
298,
493,
401,
267,
298,
1501,
401,
298,
19589,
401,
298,
908,
401,
298,
14867,
401,
298,
262,
401,
298,
13880,
401,
298,
262,
908,
401,
267,
298,
1210,
401,
298,
3250,
401,
298,
1302,
401,
298,
12422,
401,
298,
1267,
401,
298,
773,
354,
401,
298,
1073,
401,
267,
298,
513,
401,
298,
22031,
5841,
401,
298,
5628,
401,
298,
4752,
401,
298,
8951,
401,
298,
1419,
401,
298,
1199,
401,
267,
298,
548,
401,
298,
1606,
401,
298,
524,
401,
298,
4876,
401,
298,
2168,
401,
298,
8165,
401,
298,
1814,
401,
267,
298,
264,
877,
401,
298,
1107,
401,
298,
2416,
401,
298,
409,
401,
298,
2759,
401,
298,
17116,
305,
401,
298,
2379,
401,
267,
298,
1213,
401,
298,
873,
401,
298,
758,
1405,
305,
401,
298,
4509,
401,
298,
3806,
401,
298,
88,
401,
298,
1786,
270,
813,
2,
272,
776,
339,
12963,
63,
3009,
275,
334,
267,
298,
525,
401,
298,
460,
401,
298,
11858,
401,
298,
305,
401,
298,
15377,
401,
298,
1074,
401,
298,
981,
401,
267,
298,
1807,
401,
298,
11935,
401,
298,
12926,
401,
298,
4824,
401,
298,
6846,
401,
298,
504,
401,
267,
298,
923,
401,
298,
31569,
401,
298,
1080,
401,
298,
3176,
401,
298,
9924,
401,
298,
262,
401,
298,
498,
401,
298,
2930,
401,
267,
298,
1188,
401,
298,
8951,
401,
298,
1328,
466,
401,
298,
1397,
401,
298,
2307,
401,
298,
265,
401,
298,
269,
401,
267,
298,
1648,
401,
298,
3327,
401,
298,
12635,
401,
298,
3958,
401,
298,
22188,
401,
298,
2416,
401,
267,
298,
409,
401,
298,
1224,
401,
298,
3235,
401,
298,
873,
401,
298,
3502,
401,
298,
1345,
401,
298,
4509,
2,
272,
776,
339,
12963,
63,
5777,
275,
334,
267,
298,
2101,
401,
298,
2697,
401,
298,
5789,
651,
401,
298,
285,
5197,
401,
298,
4291,
262,
401,
298,
16080,
401,
298,
962,
67,
401,
267,
298,
962,
78,
401,
298,
7877,
401,
298,
9549,
1581,
86,
401,
298,
66,
23025,
2949,
401,
298,
66,
1397,
401,
298,
31938,
401,
267,
298,
3289,
4723,
401,
298,
13691,
269,
401,
298,
4414,
401,
298,
10790,
401,
298,
14085,
401,
298,
301,
88,
631,
401,
298,
67,
5350,
401,
267,
298,
1600,
401,
298,
67,
2865,
319,
401,
298,
761,
750,
401,
298,
863,
3345,
401,
298,
15278,
401,
267,
298,
6447,
401,
298,
5197,
401,
298,
15106,
401,
298,
3919,
401,
298,
67,
9129,
1533,
401,
298,
5107,
401,
298,
68,
5470,
697,
401,
267,
298,
68,
5470,
697,
2482,
401,
298,
31811,
1259,
76,
401,
298,
31811,
1259,
24503,
401,
298,
68,
23015,
371,
401,
298,
983,
73,
651,
401,
298,
602,
401,
267,
298,
602,
74,
348,
401,
298,
602,
2064,
401,
298,
2083,
401,
298,
2977,
401,
298,
68,
1600,
401,
298,
2601,
697,
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,
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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
] |
wargio/radare2
|
test/unit/legacy_unit/syscall/openbsd-gen.py
|
75
|
1396
|
#!/usr/bin/env python
# Auto-generate radare syscall profile for OpenBSD from syscall.h
# (c) Edd Barrett 2011
import sys
import copy
f = open("/usr/include/sys/syscall.h", "r")
rec = { "name" : None, "args" : None }
recs = {}
for line in f:
if line.startswith("/* syscall:"):
# extract syscall name
openq = line.find('"')
closeq = line.find('"', openq + 1)
rec["name"] = line[openq+1:closeq]
# extract number of args
args = line.find("args:")
args = args + len("args: ")
rec["args"] = line[args:].count('"') / 2
elif line.startswith("#define"):
if "SYS_MAXSYSCALL" in line:
continue
# extract syscall number
sp = line.split("\t")
callnum = sp[2].rstrip()
# check required info is there
for i in rec:
if i == None:
print("missing info for %s" % str(rec))
sys.exit(1)
recs[int(callnum)] = (copy.copy(rec))
rec = { "name" : None, "args" : None }
f.close()
out = open("openbsd.c", "w")
out.write("#include \"r_syscall.h\"\n\n/* syscall-openbsd */\n")
out.write("RSyscallItem syscalls_openbsd_x86[] = {\n")
keys = recs.keys()
for call in keys:
out.write(" { \"%s\", 0x80, %d, %d },\n" %
(recs[call]["name"], call, recs[call]["args"]))
out.write("};\n")
out.close()
|
lgpl-3.0
|
[
3381,
2647,
15,
1393,
15,
1813,
2366,
199,
3,
9195,
13,
4208,
660,
983,
264,
18901,
4690,
367,
3232,
15400,
687,
18901,
14,
72,
199,
3,
334,
67,
9,
662,
617,
12377,
3292,
84,
7760,
199,
199,
646,
984,
199,
646,
1331,
199,
199,
70,
275,
1551,
4769,
2647,
15,
2613,
15,
1274,
15,
19444,
14,
72,
401,
298,
82,
531,
199,
199,
2761,
275,
469,
298,
354,
2,
520,
488,
12,
298,
589,
2,
520,
488,
789,
199,
23587,
275,
1052,
199,
199,
509,
1004,
315,
289,
26,
272,
340,
1004,
14,
2460,
4769,
10,
18901,
26,
2349,
267,
327,
5536,
18901,
536,
267,
1551,
81,
275,
1004,
14,
1623,
25441,
267,
2463,
3610,
275,
1004,
14,
1623,
20630,
1551,
81,
435,
413,
9,
267,
6488,
905,
354,
937,
275,
1004,
59,
1490,
81,
11,
17,
26,
1600,
81,
61,
398,
327,
5536,
1329,
402,
1249,
267,
1249,
275,
1004,
14,
1623,
480,
589,
9107,
267,
1249,
275,
1249,
435,
822,
480,
589,
26,
6099,
267,
6488,
905,
589,
937,
275,
1004,
59,
589,
11455,
835,
25441,
1182,
499,
272,
916,
1004,
14,
2460,
10064,
4640,
2349,
398,
340,
298,
13326,
63,
4283,
4669,
5153,
1761,
2,
315,
1004,
26,
288,
1980,
398,
327,
5536,
18901,
1329,
267,
2249,
275,
1004,
14,
1294,
4582,
84,
531,
267,
1240,
1507,
275,
2249,
59,
18,
1055,
6735,
342,
398,
327,
1104,
1415,
2256,
365,
2337,
267,
367,
284,
315,
6488,
26,
288,
340,
284,
508,
488,
26,
355,
870,
480,
4752,
2256,
367,
450,
83,
2,
450,
620,
8,
2761,
430,
355,
984,
14,
2224,
8,
17,
9,
10631,
26399,
59,
442,
8,
1250,
1507,
1874,
275,
334,
1574,
14,
1574,
8,
2761,
430,
267,
6488,
275,
469,
298,
354,
2,
520,
488,
12,
298,
589,
2,
520,
488,
789,
199,
70,
14,
1600,
342,
421,
199,
548,
275,
1551,
480,
1490,
15746,
14,
67,
401,
298,
87,
531,
199,
548,
14,
952,
10064,
2613,
8441,
82,
63,
19444,
14,
72,
13356,
78,
60,
78,
6331,
18901,
13,
1490,
15746,
9399,
78,
531,
199,
548,
14,
952,
480,
50,
4323,
7189,
2081,
19473,
63,
1490,
15746,
63,
88,
1184,
8607,
275,
9459,
78,
531,
199,
199,
1612,
275,
26399,
14,
1612,
342,
199,
509,
1240,
315,
2883,
26,
272,
734,
14,
952,
480,
221,
469,
18321,
83,
20756,
378,
88,
1257,
12,
450,
68,
12,
450,
68,
1660,
60,
78,
2,
450,
7205,
334,
23587,
59,
1250,
7541,
354,
2255,
1240,
12,
26399,
59,
1250,
7541,
589,
13045,
199,
199,
548,
14,
952,
480,
16055,
78,
531,
199,
548,
14,
1600,
342,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,
9195,
13,
4208,
660,
983,
264,
18901,
4690,
367,
3232,
15400,
687,
18901,
14,
72,
199,
3,
334,
67,
9,
662,
617,
12377,
3292,
84,
7760,
199,
199,
646,
984,
199,
646,
1331,
199,
199,
70,
275,
1551,
4769,
2647,
15,
2613,
15,
1274,
15,
19444,
14,
72,
401,
298,
82,
531,
199,
199,
2761,
275,
469,
298,
354,
2,
520,
488,
12,
298,
589,
2,
520,
488,
789,
199,
23587,
275,
1052,
199,
199,
509,
1004,
315,
289,
26,
272,
340,
1004,
14,
2460,
4769,
10,
18901,
26,
2349,
267,
327,
5536,
18901,
536,
267,
1551,
81,
275,
1004,
14,
1623,
25441,
267,
2463,
3610,
275,
1004,
14,
1623,
20630,
1551,
81,
435,
413,
9,
267,
6488,
905,
354,
937,
275,
1004,
59,
1490,
81,
11,
17,
26,
1600,
81,
61,
398,
327,
5536,
1329,
402,
1249,
267,
1249,
275,
1004,
14,
1623,
480,
589,
9107,
267,
1249,
275,
1249,
435,
822,
480,
589,
26,
6099,
267,
6488,
905,
589,
937,
275,
1004,
59,
589,
11455,
835,
25441,
1182,
499,
272,
916,
1004,
14,
2460,
10064,
4640,
2349,
398,
340,
298,
13326,
63,
4283,
4669,
5153,
1761,
2,
315,
1004,
26,
288,
1980,
398,
327,
5536,
18901,
1329,
267,
2249,
275,
1004,
14,
1294,
4582,
84,
531,
267,
1240,
1507,
275,
2249,
59,
18,
1055,
6735,
342,
398,
327,
1104,
1415,
2256,
365,
2337,
267,
367,
284,
315,
6488,
26,
288,
340,
284,
508,
488,
26,
355,
870,
480,
4752,
2256,
367,
450,
83,
2,
450,
620,
8,
2761,
430,
355,
984,
14,
2224,
8,
17,
9,
10631,
26399,
59,
442,
8,
1250,
1507,
1874,
275,
334,
1574,
14,
1574,
8,
2761,
430,
267,
6488,
275,
469,
298,
354,
2,
520,
488,
12,
298,
589,
2,
520,
488,
789,
199,
70,
14,
1600,
342,
421,
199,
548,
275,
1551,
480,
1490,
15746,
14,
67,
401,
298,
87,
531,
199,
548,
14,
952,
10064,
2613,
8441,
82,
63,
19444,
14,
72,
13356,
78,
60,
78,
6331,
18901,
13,
1490,
15746,
9399,
78,
531,
199,
548,
14,
952,
480,
50,
4323,
7189,
2081,
19473,
63,
1490,
15746,
63,
88,
1184,
8607,
275,
9459,
78,
531,
199,
199,
1612,
275,
26399,
14,
1612,
342,
199,
509,
1240,
315,
2883,
26,
272,
734,
14,
952,
480,
221,
469,
18321,
83,
20756,
378,
88,
1257,
12,
450,
68,
12,
450,
68,
1660,
60,
78,
2,
450,
7205,
334,
23587,
59,
1250,
7541,
354,
2255,
1240,
12,
26399,
59,
1250,
7541,
589,
13045,
199,
199,
548,
14,
952,
480,
16055,
78,
531,
199,
548,
14,
1600,
342,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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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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
] |
jeckersb/Proton
|
examples/python/reactor/scheduling.py
|
4
|
1876
|
#!/usr/bin/python
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
import time
from proton.reactor import Reactor
class Program:
def on_reactor_init(self, event):
self.start = time.time()
print "Hello, World!"
# We can schedule a task event for some point in the future.
# This will cause the reactor to stick around until it has a
# chance to process the event.
# The first argument is the delay. The second argument is the
# handler for the event. We are just using self for now, but
# we could pass in another object if we wanted.
task = event.reactor.schedule(1.0, self)
# We can ignore the task if we want to, but we can also use it
# to pass stuff to the handler.
task.something_to_say = "Yay"
def on_timer_task(self, event):
task = event.context # xxx: don't have a task property on event yet
print task.something_to_say, "my task is complete!"
def on_reactor_final(self, event):
print "Goodbye, World! (after %s long seconds)" % (time.time() - self.start)
r = Reactor(Program())
r.run()
|
apache-2.0
|
[
3381,
2647,
15,
1393,
15,
1548,
199,
3,
199,
3,
3909,
370,
314,
3668,
2290,
2752,
334,
14950,
9,
1334,
1373,
199,
3,
503,
1655,
11615,
4190,
14024,
14,
221,
1666,
314,
12840,
570,
199,
3,
1854,
543,
642,
1736,
367,
4722,
2556,
199,
3,
12602,
4248,
12715,
14,
221,
710,
14857,
12378,
642,
570,
199,
3,
370,
1265,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
199,
3,
298,
3761,
3547,
1265,
1443,
440,
675,
642,
570,
871,
315,
4151,
199,
3,
543,
314,
844,
14,
221,
2047,
1443,
3332,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
257,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
199,
3,
2032,
1854,
1334,
314,
844,
365,
1854,
641,
376,
199,
3,
298,
1179,
2281,
2,
4207,
12,
2428,
2990,
1549,
4217,
1634,
1821,
199,
3,
3826,
12,
1902,
4056,
503,
2478,
14,
221,
1666,
314,
844,
367,
314,
199,
3,
2488,
2637,
4210,
3443,
436,
4204,
199,
3,
1334,
314,
844,
14,
199,
3,
199,
199,
646,
900,
199,
504,
557,
1860,
14,
13544,
492,
799,
5021,
199,
199,
533,
18841,
26,
339,
347,
641,
63,
13544,
63,
826,
8,
277,
12,
1566,
304,
267,
291,
14,
928,
275,
900,
14,
521,
342,
267,
870,
298,
6257,
12,
13064,
9539,
398,
327,
2136,
883,
8732,
282,
2120,
1566,
367,
2005,
2376,
315,
314,
6466,
14,
267,
327,
961,
911,
7675,
314,
9655,
370,
29404,
6818,
5133,
652,
965,
282,
267,
327,
22044,
370,
2112,
314,
1566,
14,
398,
327,
710,
1642,
1423,
365,
314,
7339,
14,
710,
3499,
1423,
365,
314,
267,
327,
3016,
367,
314,
1566,
14,
2136,
787,
2951,
1808,
291,
367,
3063,
12,
1325,
267,
327,
781,
4293,
986,
315,
4573,
909,
340,
781,
13632,
14,
267,
2120,
275,
1566,
14,
13544,
14,
7211,
8,
17,
14,
16,
12,
291,
9,
398,
327,
2136,
883,
3686,
314,
2120,
340,
781,
2934,
370,
12,
1325,
781,
883,
2597,
675,
652,
267,
327,
370,
986,
8292,
370,
314,
3016,
14,
267,
2120,
14,
10297,
63,
475,
63,
19787,
275,
298,
57,
1187,
2,
339,
347,
641,
63,
7414,
63,
1765,
8,
277,
12,
1566,
304,
267,
2120,
275,
1566,
14,
1100,
327,
26571,
26,
2793,
1133,
1172,
282,
2120,
3324,
641,
1566,
5966,
267,
870,
2120,
14,
10297,
63,
475,
63,
19787,
12,
298,
1662,
2120,
365,
4890,
9539,
339,
347,
641,
63,
13544,
63,
5094,
8,
277,
12,
1566,
304,
267,
870,
298,
20652,
16481,
12,
13064,
1,
334,
4399,
450,
83,
1846,
4696,
2924,
450,
334,
521,
14,
521,
342,
446,
291,
14,
928,
9,
199,
199,
82,
275,
799,
5021,
8,
9184,
1012,
199,
82,
14,
1065,
342,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
2647,
15,
1393,
15,
1548,
199,
3,
199,
3,
3909,
370,
314,
3668,
2290,
2752,
334,
14950,
9,
1334,
1373,
199,
3,
503,
1655,
11615,
4190,
14024,
14,
221,
1666,
314,
12840,
570,
199,
3,
1854,
543,
642,
1736,
367,
4722,
2556,
199,
3,
12602,
4248,
12715,
14,
221,
710,
14857,
12378,
642,
570,
199,
3,
370,
1265,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
199,
3,
298,
3761,
3547,
1265,
1443,
440,
675,
642,
570,
871,
315,
4151,
199,
3,
543,
314,
844,
14,
221,
2047,
1443,
3332,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
257,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
199,
3,
2032,
1854,
1334,
314,
844,
365,
1854,
641,
376,
199,
3,
298,
1179,
2281,
2,
4207,
12,
2428,
2990,
1549,
4217,
1634,
1821,
199,
3,
3826,
12,
1902,
4056,
503,
2478,
14,
221,
1666,
314,
844,
367,
314,
199,
3,
2488,
2637,
4210,
3443,
436,
4204,
199,
3,
1334,
314,
844,
14,
199,
3,
199,
199,
646,
900,
199,
504,
557,
1860,
14,
13544,
492,
799,
5021,
199,
199,
533,
18841,
26,
339,
347,
641,
63,
13544,
63,
826,
8,
277,
12,
1566,
304,
267,
291,
14,
928,
275,
900,
14,
521,
342,
267,
870,
298,
6257,
12,
13064,
9539,
398,
327,
2136,
883,
8732,
282,
2120,
1566,
367,
2005,
2376,
315,
314,
6466,
14,
267,
327,
961,
911,
7675,
314,
9655,
370,
29404,
6818,
5133,
652,
965,
282,
267,
327,
22044,
370,
2112,
314,
1566,
14,
398,
327,
710,
1642,
1423,
365,
314,
7339,
14,
710,
3499,
1423,
365,
314,
267,
327,
3016,
367,
314,
1566,
14,
2136,
787,
2951,
1808,
291,
367,
3063,
12,
1325,
267,
327,
781,
4293,
986,
315,
4573,
909,
340,
781,
13632,
14,
267,
2120,
275,
1566,
14,
13544,
14,
7211,
8,
17,
14,
16,
12,
291,
9,
398,
327,
2136,
883,
3686,
314,
2120,
340,
781,
2934,
370,
12,
1325,
781,
883,
2597,
675,
652,
267,
327,
370,
986,
8292,
370,
314,
3016,
14,
267,
2120,
14,
10297,
63,
475,
63,
19787,
275,
298,
57,
1187,
2,
339,
347,
641,
63,
7414,
63,
1765,
8,
277,
12,
1566,
304,
267,
2120,
275,
1566,
14,
1100,
327,
26571,
26,
2793,
1133,
1172,
282,
2120,
3324,
641,
1566,
5966,
267,
870,
2120,
14,
10297,
63,
475,
63,
19787,
12,
298,
1662,
2120,
365,
4890,
9539,
339,
347,
641,
63,
13544,
63,
5094,
8,
277,
12,
1566,
304,
267,
870,
298,
20652,
16481,
12,
13064,
1,
334,
4399,
450,
83,
1846,
4696,
2924,
450,
334,
521,
14,
521,
342,
446,
291,
14,
928,
9,
199,
199,
82,
275,
799,
5021,
8,
9184,
1012,
199,
82,
14,
1065,
342,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,
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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
] |
colinligertwood/odoo
|
addons/account_payment/__openerp__.py
|
116
|
2997
|
# -*- 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/>.
#
##############################################################################
{
'name': 'Suppliers Payment Management',
'version': '1.1',
'author': 'OpenERP SA',
'category': 'Accounting & Finance',
'description': """
Module to manage the payment of your supplier invoices.
=======================================================
This module allows you to create and manage your payment orders, with purposes to
---------------------------------------------------------------------------------
* serve as base for an easy plug-in of various automated payment mechanisms.
* provide a more efficient way to manage invoice payment.
Warning:
~~~~~~~~
The confirmation of a payment order does _not_ create accounting entries, it just
records the fact that you gave your payment order to your bank. The booking of
your order must be encoded as usual through a bank statement. Indeed, it's only
when you get the confirmation from your bank that your order has been accepted
that you can book it in your accounting. To help you with that operation, you
have a new option to import payment orders as bank statement lines.
""",
'images': ['images/payment_mode.jpeg','images/payment_order.jpeg'],
'depends': ['account','account_voucher'],
'data': [
'security/account_payment_security.xml',
'security/ir.model.access.csv',
'wizard/account_payment_pay_view.xml',
'wizard/account_payment_populate_statement_view.xml',
'wizard/account_payment_create_order_view.xml',
'account_payment_view.xml',
'account_payment_workflow.xml',
'account_payment_sequence.xml',
'account_payment_report.xml',
'views/report_paymentorder.xml',
],
'demo': ['account_payment_demo.xml'],
'test': [
'test/account_payment_demo.yml',
'test/cancel_payment_order.yml',
'test/payment_order_process.yml',
'test/account_payment_report.yml',
],
'installable': True,
'auto_install': False,
}
# 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,
91,
272,
283,
354,
356,
283,
17127,
14035,
25523,
8259,
297,
272,
283,
1023,
356,
283,
17,
14,
17,
297,
272,
283,
2502,
356,
283,
25347,
13950,
297,
272,
283,
3710,
356,
283,
6009,
316,
1253,
11711,
554,
297,
272,
283,
1802,
356,
408,
199,
2377,
370,
9635,
314,
11628,
402,
2195,
23700,
26175,
14,
199,
12813,
18673,
199,
199,
2765,
859,
6127,
1265,
370,
1218,
436,
9635,
2195,
11628,
15460,
12,
543,
12901,
370,
199,
3606,
777,
13,
5591,
627,
14062,
465,
1300,
367,
376,
8837,
14202,
13,
262,
402,
7750,
6384,
23513,
11628,
562,
10832,
706,
14,
272,
627,
5647,
282,
1655,
13402,
4340,
370,
9635,
8485,
11628,
14,
199,
199,
3849,
26,
199,
4919,
199,
1918,
18791,
402,
282,
11628,
1865,
1630,
485,
1397,
63,
1218,
24772,
4811,
12,
652,
2951,
221,
199,
6502,
314,
10572,
626,
1265,
486,
811,
2195,
11628,
1865,
370,
2195,
16297,
14,
710,
6719,
316,
402,
221,
199,
12695,
1865,
1471,
506,
5737,
465,
20195,
4012,
282,
16297,
5164,
14,
1010,
271,
379,
12,
652,
1159,
1454,
221,
199,
6526,
1265,
664,
314,
18791,
687,
2195,
16297,
626,
2195,
1865,
965,
2757,
10226,
221,
199,
9099,
1265,
883,
6719,
652,
315,
2195,
24772,
14,
4005,
1720,
1265,
543,
626,
3439,
12,
1265,
221,
199,
7804,
282,
892,
945,
370,
492,
11628,
15460,
465,
16297,
5164,
2385,
14,
272,
10327,
272,
283,
4782,
356,
788,
4782,
15,
7948,
63,
632,
14,
14230,
1673,
4782,
15,
7948,
63,
1648,
14,
14230,
995,
272,
283,
8912,
356,
788,
2048,
1673,
2048,
63,
16637,
995,
272,
283,
576,
356,
359,
267,
283,
4416,
15,
2048,
63,
7948,
63,
4416,
14,
1652,
297,
267,
283,
4416,
15,
723,
14,
1238,
14,
2732,
14,
4737,
297,
267,
283,
9819,
15,
2048,
63,
7948,
63,
5989,
63,
1345,
14,
1652,
297,
267,
283,
9819,
15,
2048,
63,
7948,
63,
13817,
63,
6242,
63,
1345,
14,
1652,
297,
267,
283,
9819,
15,
2048,
63,
7948,
63,
981,
63,
1648,
63,
1345,
14,
1652,
297,
267,
283,
2048,
63,
7948,
63,
1345,
14,
1652,
297,
267,
283,
2048,
63,
7948,
63,
8856,
14,
1652,
297,
267,
283,
2048,
63,
7948,
63,
4041,
14,
1652,
297,
267,
283,
2048,
63,
7948,
63,
3070,
14,
1652,
297,
398,
283,
4196,
15,
3070,
63,
7948,
1648,
14,
1652,
297,
272,
2156,
272,
283,
8768,
356,
788,
2048,
63,
7948,
63,
8768,
14,
1652,
995,
272,
283,
396,
356,
359,
267,
283,
396,
15,
2048,
63,
7948,
63,
8768,
14,
11714,
297,
267,
283,
396,
15,
6406,
63,
7948,
63,
1648,
14,
11714,
297,
267,
283,
396,
15,
7948,
63,
1648,
63,
1412,
14,
11714,
297,
267,
283,
396,
15,
2048,
63,
7948,
63,
3070,
14,
11714,
297,
272,
2156,
272,
283,
21762,
356,
715,
12,
272,
283,
2495,
63,
3174,
356,
756,
12,
199,
93,
199,
3,
6695,
26,
10379,
26,
10558,
26,
6492,
29,
20,
26,
10503,
29,
20,
26,
10425,
29,
20,
26,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
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,
91,
272,
283,
354,
356,
283,
17127,
14035,
25523,
8259,
297,
272,
283,
1023,
356,
283,
17,
14,
17,
297,
272,
283,
2502,
356,
283,
25347,
13950,
297,
272,
283,
3710,
356,
283,
6009,
316,
1253,
11711,
554,
297,
272,
283,
1802,
356,
408,
199,
2377,
370,
9635,
314,
11628,
402,
2195,
23700,
26175,
14,
199,
12813,
18673,
199,
199,
2765,
859,
6127,
1265,
370,
1218,
436,
9635,
2195,
11628,
15460,
12,
543,
12901,
370,
199,
3606,
777,
13,
5591,
627,
14062,
465,
1300,
367,
376,
8837,
14202,
13,
262,
402,
7750,
6384,
23513,
11628,
562,
10832,
706,
14,
272,
627,
5647,
282,
1655,
13402,
4340,
370,
9635,
8485,
11628,
14,
199,
199,
3849,
26,
199,
4919,
199,
1918,
18791,
402,
282,
11628,
1865,
1630,
485,
1397,
63,
1218,
24772,
4811,
12,
652,
2951,
221,
199,
6502,
314,
10572,
626,
1265,
486,
811,
2195,
11628,
1865,
370,
2195,
16297,
14,
710,
6719,
316,
402,
221,
199,
12695,
1865,
1471,
506,
5737,
465,
20195,
4012,
282,
16297,
5164,
14,
1010,
271,
379,
12,
652,
1159,
1454,
221,
199,
6526,
1265,
664,
314,
18791,
687,
2195,
16297,
626,
2195,
1865,
965,
2757,
10226,
221,
199,
9099,
1265,
883,
6719,
652,
315,
2195,
24772,
14,
4005,
1720,
1265,
543,
626,
3439,
12,
1265,
221,
199,
7804,
282,
892,
945,
370,
492,
11628,
15460,
465,
16297,
5164,
2385,
14,
272,
10327,
272,
283,
4782,
356,
788,
4782,
15,
7948,
63,
632,
14,
14230,
1673,
4782,
15,
7948,
63,
1648,
14,
14230,
995,
272,
283,
8912,
356,
788,
2048,
1673,
2048,
63,
16637,
995,
272,
283,
576,
356,
359,
267,
283,
4416,
15,
2048,
63,
7948,
63,
4416,
14,
1652,
297,
267,
283,
4416,
15,
723,
14,
1238,
14,
2732,
14,
4737,
297,
267,
283,
9819,
15,
2048,
63,
7948,
63,
5989,
63,
1345,
14,
1652,
297,
267,
283,
9819,
15,
2048,
63,
7948,
63,
13817,
63,
6242,
63,
1345,
14,
1652,
297,
267,
283,
9819,
15,
2048,
63,
7948,
63,
981,
63,
1648,
63,
1345,
14,
1652,
297,
267,
283,
2048,
63,
7948,
63,
1345,
14,
1652,
297,
267,
283,
2048,
63,
7948,
63,
8856,
14,
1652,
297,
267,
283,
2048,
63,
7948,
63,
4041,
14,
1652,
297,
267,
283,
2048,
63,
7948,
63,
3070,
14,
1652,
297,
398,
283,
4196,
15,
3070,
63,
7948,
1648,
14,
1652,
297,
272,
2156,
272,
283,
8768,
356,
788,
2048,
63,
7948,
63,
8768,
14,
1652,
995,
272,
283,
396,
356,
359,
267,
283,
396,
15,
2048,
63,
7948,
63,
8768,
14,
11714,
297,
267,
283,
396,
15,
6406,
63,
7948,
63,
1648,
14,
11714,
297,
267,
283,
396,
15,
7948,
63,
1648,
63,
1412,
14,
11714,
297,
267,
283,
396,
15,
2048,
63,
7948,
63,
3070,
14,
11714,
297,
272,
2156,
272,
283,
21762,
356,
715,
12,
272,
283,
2495,
63,
3174,
356,
756,
12,
199,
93,
199,
3,
6695,
26,
10379,
26,
10558,
26,
6492,
29,
20,
26,
10503,
29,
20,
26,
10425,
29,
20,
26,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
woylaski/notebook
|
graphic/kivy-master/kivy/tools/packaging/factory.py
|
54
|
3457
|
from __future__ import print_function
__all__ = ('FactoryBuild', )
from distutils.cmd import Command
import fnmatch
import os
import kivy
import types
ignore_list = (
'kivy.lib',
'kivy.input.providers',
'kivy.input.postproc',
'kivy.modules',
'kivy.tools',
'kivy.parser',
'kivy.tests',
)
class FactoryBuild(Command):
description = 'Build the factory relation file (for factory.py)'
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
print('--------------------------------------------')
print('Building factory relation file')
print('--------------------------------------------')
root_dir = os.path.dirname(kivy.__file__)
filename = os.path.join(root_dir, 'factory_registers.py')
with open(filename, 'w') as fd:
fd.close()
# ensure we don't have any thing like doc running
symbols = []
for root, dirnames, filenames in os.walk(root_dir):
if not root.startswith(root_dir):
raise Exception('Directory should start with the kivy'
'directory')
root = 'kivy' + root[len(root_dir):].replace(os.path.sep, '.')
for filename in fnmatch.filter(filenames, '*.[ps][yo]'):
module = '%s.%s' % (root, filename[:-3])
# check ignore list first
ignore = False
for ignore in ignore_list:
if module.startswith(ignore):
ignore = True
break
if ignore is True:
#print('<<< ignored (ignore list)')
continue
# special case, core providers
if root.startswith('kivy.core.'):
if not root.endswith('__init__.py'):
#print('<<< ignored (not a __init__.py)')
continue
print('>>>', module, '::', end=' ')
try:
m = __import__(name=module, fromlist='.')
except Exception as e:
print()
print('ERROR:', e)
continue
if not hasattr(m, '__all__'):
print()
continue
for symbol in getattr(m, '__all__'):
if symbol.startswith('_'):
continue
attr = getattr(m, symbol)
if type(attr) not in (type, type):
continue
symbols.append((symbol, module))
print(symbol, end=' ')
print()
print()
print('--------------------------------------------')
print('Found %d symbols, generating file' % len(symbols))
print('--------------------------------------------')
filename = os.path.join(root_dir, 'factory_registers.py')
with open(filename, 'w') as fd:
fd.write('# Auto-generated file by setup.py build_factory\n')
fd.write('\n')
fd.write('from kivy.factory import Factory\n')
fd.write('\n')
fd.write('r = Factory.register\n')
for x in symbols:
fd.write("r('%s', module='%s')\n" % x)
print('File written at', filename)
|
gpl-3.0
|
[
504,
636,
2443,
363,
492,
870,
63,
1593,
199,
199,
363,
452,
363,
275,
661,
2927,
3425,
297,
776,
199,
199,
504,
7065,
14,
1760,
492,
5817,
199,
646,
15951,
199,
646,
747,
199,
646,
17227,
199,
646,
2943,
199,
199,
4247,
63,
513,
275,
334,
272,
283,
16941,
14,
773,
297,
272,
283,
16941,
14,
1210,
14,
9710,
297,
272,
283,
16941,
14,
1210,
14,
1932,
4687,
297,
272,
283,
16941,
14,
3112,
297,
272,
283,
16941,
14,
2537,
297,
272,
283,
16941,
14,
2087,
297,
272,
283,
16941,
14,
2219,
297,
199,
9,
421,
199,
533,
23616,
3425,
8,
3110,
304,
272,
1369,
275,
283,
3425,
314,
6434,
5850,
570,
334,
509,
6434,
14,
647,
3171,
272,
922,
63,
1419,
275,
942,
339,
347,
8265,
63,
1419,
8,
277,
304,
267,
986,
339,
347,
17284,
63,
1419,
8,
277,
304,
267,
986,
339,
347,
1255,
8,
277,
304,
267,
870,
360,
1444,
4559,
358,
267,
870,
360,
16461,
6434,
5850,
570,
358,
267,
870,
360,
1444,
4559,
358,
398,
1738,
63,
694,
275,
747,
14,
515,
14,
3475,
8,
16941,
855,
493,
3368,
267,
1788,
275,
747,
14,
515,
14,
904,
8,
1231,
63,
694,
12,
283,
3702,
63,
30792,
14,
647,
358,
267,
543,
1551,
8,
1501,
12,
283,
87,
358,
465,
6111,
26,
288,
6111,
14,
1600,
342,
398,
327,
4868,
781,
2793,
1133,
1172,
1263,
8377,
2839,
1382,
3879,
267,
6698,
275,
942,
267,
367,
1738,
12,
22310,
12,
6203,
315,
747,
14,
7757,
8,
1231,
63,
694,
304,
288,
340,
440,
1738,
14,
2460,
8,
1231,
63,
694,
304,
355,
746,
2186,
360,
6231,
1077,
1343,
543,
314,
17227,
7,
1816,
283,
3619,
358,
288,
1738,
275,
283,
16941,
7,
435,
1738,
59,
552,
8,
1231,
63,
694,
304,
1055,
1814,
8,
736,
14,
515,
14,
4127,
12,
20093,
288,
367,
1788,
315,
15951,
14,
1541,
8,
10309,
12,
11937,
59,
1190,
1527,
16540,
61,
735,
355,
859,
275,
1543,
83,
4111,
83,
7,
450,
334,
1231,
12,
1788,
4439,
19,
566,
2234,
327,
1104,
3686,
769,
1642,
355,
3686,
275,
756,
355,
367,
3686,
315,
3686,
63,
513,
26,
490,
340,
859,
14,
2460,
8,
4247,
304,
717,
3686,
275,
715,
717,
2059,
355,
340,
3686,
365,
715,
26,
490,
327,
1361,
4827,
8999,
5525,
334,
4247,
769,
5942,
490,
1980,
2234,
327,
4539,
1930,
12,
6170,
18032,
355,
340,
1738,
14,
2460,
360,
16941,
14,
1018,
30194,
490,
340,
440,
1738,
14,
4130,
10714,
826,
4343,
647,
735,
717,
327,
1361,
4827,
8999,
5525,
334,
1397,
282,
636,
826,
4343,
647,
5942,
717,
1980,
2234,
870,
360,
1140,
4206,
859,
12,
19069,
297,
1284,
534,
5320,
2234,
862,
26,
490,
333,
275,
636,
646,
721,
354,
29,
578,
12,
25321,
534,
2659,
355,
871,
2186,
465,
325,
26,
490,
870,
342,
490,
870,
360,
3170,
6536,
325,
9,
490,
1980,
355,
340,
440,
2688,
8,
77,
12,
2560,
452,
12168,
490,
870,
342,
490,
1980,
355,
367,
5272,
315,
2519,
8,
77,
12,
2560,
452,
12168,
490,
340,
5272,
14,
2460,
30018,
717,
1980,
490,
1921,
275,
2519,
8,
77,
12,
5272,
9,
490,
340,
730,
8,
962,
9,
440,
315,
334,
466,
12,
730,
304,
717,
1980,
490,
6698,
14,
740,
1332,
5155,
12,
859,
430,
490,
870,
8,
5155,
12,
1284,
534,
5320,
355,
870,
342,
398,
870,
342,
267,
870,
360,
1444,
4559,
358,
267,
870,
360,
3601,
450,
68,
6698,
12,
12999,
570,
7,
450,
822,
8,
7450,
430,
267,
870,
360,
1444,
4559,
358,
398,
1788,
275,
747,
14,
515,
14,
904,
8,
1231,
63,
694,
12,
283,
3702,
63,
30792,
14,
647,
358,
267,
543,
1551,
8,
1501,
12,
283,
87,
358,
465,
6111,
26,
288,
6111,
14,
952,
7863,
9195,
13,
10176,
570,
701,
3272,
14,
647,
1900,
63,
3702,
60,
78,
358,
288,
6111,
14,
952,
2258,
78,
358,
288,
6111,
14,
952,
360,
504,
17227,
14,
3702,
492,
23616,
60,
78,
358,
288,
6111,
14,
952,
2258,
78,
358,
288,
6111,
14,
952,
360,
82,
275,
23616,
14,
2683,
60,
78,
358,
288,
367,
671,
315,
6698,
26,
355,
6111,
14,
952,
480,
82,
3508,
83,
297,
859,
9569,
83,
24431,
78,
2,
450,
671,
9,
398,
870,
360,
1173,
5313,
737,
297,
1788,
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
] |
[
636,
2443,
363,
492,
870,
63,
1593,
199,
199,
363,
452,
363,
275,
661,
2927,
3425,
297,
776,
199,
199,
504,
7065,
14,
1760,
492,
5817,
199,
646,
15951,
199,
646,
747,
199,
646,
17227,
199,
646,
2943,
199,
199,
4247,
63,
513,
275,
334,
272,
283,
16941,
14,
773,
297,
272,
283,
16941,
14,
1210,
14,
9710,
297,
272,
283,
16941,
14,
1210,
14,
1932,
4687,
297,
272,
283,
16941,
14,
3112,
297,
272,
283,
16941,
14,
2537,
297,
272,
283,
16941,
14,
2087,
297,
272,
283,
16941,
14,
2219,
297,
199,
9,
421,
199,
533,
23616,
3425,
8,
3110,
304,
272,
1369,
275,
283,
3425,
314,
6434,
5850,
570,
334,
509,
6434,
14,
647,
3171,
272,
922,
63,
1419,
275,
942,
339,
347,
8265,
63,
1419,
8,
277,
304,
267,
986,
339,
347,
17284,
63,
1419,
8,
277,
304,
267,
986,
339,
347,
1255,
8,
277,
304,
267,
870,
360,
1444,
4559,
358,
267,
870,
360,
16461,
6434,
5850,
570,
358,
267,
870,
360,
1444,
4559,
358,
398,
1738,
63,
694,
275,
747,
14,
515,
14,
3475,
8,
16941,
855,
493,
3368,
267,
1788,
275,
747,
14,
515,
14,
904,
8,
1231,
63,
694,
12,
283,
3702,
63,
30792,
14,
647,
358,
267,
543,
1551,
8,
1501,
12,
283,
87,
358,
465,
6111,
26,
288,
6111,
14,
1600,
342,
398,
327,
4868,
781,
2793,
1133,
1172,
1263,
8377,
2839,
1382,
3879,
267,
6698,
275,
942,
267,
367,
1738,
12,
22310,
12,
6203,
315,
747,
14,
7757,
8,
1231,
63,
694,
304,
288,
340,
440,
1738,
14,
2460,
8,
1231,
63,
694,
304,
355,
746,
2186,
360,
6231,
1077,
1343,
543,
314,
17227,
7,
1816,
283,
3619,
358,
288,
1738,
275,
283,
16941,
7,
435,
1738,
59,
552,
8,
1231,
63,
694,
304,
1055,
1814,
8,
736,
14,
515,
14,
4127,
12,
20093,
288,
367,
1788,
315,
15951,
14,
1541,
8,
10309,
12,
11937,
59,
1190,
1527,
16540,
61,
735,
355,
859,
275,
1543,
83,
4111,
83,
7,
450,
334,
1231,
12,
1788,
4439,
19,
566,
2234,
327,
1104,
3686,
769,
1642,
355,
3686,
275,
756,
355,
367,
3686,
315,
3686,
63,
513,
26,
490,
340,
859,
14,
2460,
8,
4247,
304,
717,
3686,
275,
715,
717,
2059,
355,
340,
3686,
365,
715,
26,
490,
327,
1361,
4827,
8999,
5525,
334,
4247,
769,
5942,
490,
1980,
2234,
327,
4539,
1930,
12,
6170,
18032,
355,
340,
1738,
14,
2460,
360,
16941,
14,
1018,
30194,
490,
340,
440,
1738,
14,
4130,
10714,
826,
4343,
647,
735,
717,
327,
1361,
4827,
8999,
5525,
334,
1397,
282,
636,
826,
4343,
647,
5942,
717,
1980,
2234,
870,
360,
1140,
4206,
859,
12,
19069,
297,
1284,
534,
5320,
2234,
862,
26,
490,
333,
275,
636,
646,
721,
354,
29,
578,
12,
25321,
534,
2659,
355,
871,
2186,
465,
325,
26,
490,
870,
342,
490,
870,
360,
3170,
6536,
325,
9,
490,
1980,
355,
340,
440,
2688,
8,
77,
12,
2560,
452,
12168,
490,
870,
342,
490,
1980,
355,
367,
5272,
315,
2519,
8,
77,
12,
2560,
452,
12168,
490,
340,
5272,
14,
2460,
30018,
717,
1980,
490,
1921,
275,
2519,
8,
77,
12,
5272,
9,
490,
340,
730,
8,
962,
9,
440,
315,
334,
466,
12,
730,
304,
717,
1980,
490,
6698,
14,
740,
1332,
5155,
12,
859,
430,
490,
870,
8,
5155,
12,
1284,
534,
5320,
355,
870,
342,
398,
870,
342,
267,
870,
360,
1444,
4559,
358,
267,
870,
360,
3601,
450,
68,
6698,
12,
12999,
570,
7,
450,
822,
8,
7450,
430,
267,
870,
360,
1444,
4559,
358,
398,
1788,
275,
747,
14,
515,
14,
904,
8,
1231,
63,
694,
12,
283,
3702,
63,
30792,
14,
647,
358,
267,
543,
1551,
8,
1501,
12,
283,
87,
358,
465,
6111,
26,
288,
6111,
14,
952,
7863,
9195,
13,
10176,
570,
701,
3272,
14,
647,
1900,
63,
3702,
60,
78,
358,
288,
6111,
14,
952,
2258,
78,
358,
288,
6111,
14,
952,
360,
504,
17227,
14,
3702,
492,
23616,
60,
78,
358,
288,
6111,
14,
952,
2258,
78,
358,
288,
6111,
14,
952,
360,
82,
275,
23616,
14,
2683,
60,
78,
358,
288,
367,
671,
315,
6698,
26,
355,
6111,
14,
952,
480,
82,
3508,
83,
297,
859,
9569,
83,
24431,
78,
2,
450,
671,
9,
398,
870,
360,
1173,
5313,
737,
297,
1788,
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,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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..test_managercli import TestCliCommand
from subscription_manager import managercli
from mock import patch, Mock
class TestImportCertCommand(TestCliCommand):
command_class = managercli.ImportCertCommand
def setUp(self):
super(TestImportCertCommand, self).setUp()
argv_patcher = patch.object(sys, 'argv', ['subscription-manager', 'import'])
argv_patcher.start()
self.addCleanup(argv_patcher.stop)
def test_certificates(self):
self.cc.is_registered = Mock(return_value=False)
self.cc.main(["--certificate", "one", "--certificate", "two"])
self.cc._validate_options()
def test_registered(self):
self.cc.is_registered = Mock(return_value=True)
self.cc.main(["--certificate", "one", "--certificate", "two"])
with self.assertRaises(SystemExit) as e:
self.cc._validate_options()
self.assertEqual(os.EX_USAGE, e.exception.code)
def test_no_certificates(self):
try:
self.cc.main([])
except SystemExit as e:
self.assertEqual(e.code, 2)
try:
self.cc._validate_options()
self.fail("No exception raised")
except Exception as e:
pass
except SystemExit as e:
# there seems to be an optparse issue
# here that depends on version, on f14
# we get sysexit with return code 2 from main, on f15, we
# get os.EX_USAGE from validate_options
# i18n_optparse returns 2 on no args
self.assertEqual(e.code, os.EX_USAGE)
|
gpl-2.0
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
199,
646,
747,
199,
646,
984,
199,
199,
504,
2508,
396,
63,
2609,
2764,
492,
1379,
20653,
3110,
199,
504,
9966,
63,
2609,
492,
5256,
2764,
199,
199,
504,
1683,
492,
3371,
12,
4420,
421,
199,
533,
1379,
6295,
14768,
3110,
8,
774,
20653,
3110,
304,
272,
1414,
63,
533,
275,
5256,
2764,
14,
6295,
14768,
3110,
339,
347,
3613,
8,
277,
304,
267,
1613,
8,
774,
6295,
14768,
3110,
12,
291,
680,
5996,
342,
267,
9238,
63,
11238,
275,
3371,
14,
785,
8,
1274,
12,
283,
3020,
297,
788,
6645,
13,
2609,
297,
283,
646,
1105,
267,
9238,
63,
11238,
14,
928,
342,
267,
291,
14,
12808,
8,
3020,
63,
11238,
14,
2379,
9,
339,
347,
511,
63,
16159,
8,
277,
304,
267,
291,
14,
2055,
14,
374,
63,
11616,
275,
4420,
8,
1107,
63,
585,
29,
797,
9,
267,
291,
14,
2055,
14,
973,
5234,
306,
6999,
401,
298,
368,
401,
4320,
6999,
401,
298,
5601,
3135,
267,
291,
14,
2055,
423,
3502,
63,
1419,
342,
339,
347,
511,
63,
11616,
8,
277,
304,
267,
291,
14,
2055,
14,
374,
63,
11616,
275,
4420,
8,
1107,
63,
585,
29,
549,
9,
267,
291,
14,
2055,
14,
973,
5234,
306,
6999,
401,
298,
368,
401,
4320,
6999,
401,
298,
5601,
3135,
267,
543,
291,
14,
1855,
8,
24738,
9,
465,
325,
26,
288,
291,
14,
2055,
423,
3502,
63,
1419,
342,
267,
291,
14,
629,
8,
736,
14,
1438,
63,
20274,
12,
325,
14,
1971,
14,
600,
9,
339,
347,
511,
63,
889,
63,
16159,
8,
277,
304,
267,
862,
26,
288,
291,
14,
2055,
14,
973,
4157,
267,
871,
14838,
465,
325,
26,
288,
291,
14,
629,
8,
69,
14,
600,
12,
499,
9,
398,
862,
26,
288,
291,
14,
2055,
423,
3502,
63,
1419,
342,
288,
291,
14,
1633,
480,
1944,
1919,
4915,
531,
267,
871,
2186,
465,
325,
26,
288,
986,
267,
871,
14838,
465,
325,
26,
288,
327,
2337,
12237,
370,
506,
376,
8691,
4976,
288,
327,
2348,
626,
8350,
641,
1015,
12,
641,
289,
1079,
288,
327,
781,
664,
1847,
20160,
390,
543,
372,
1233,
499,
221,
687,
2446,
12,
641,
289,
1046,
12,
781,
288,
327,
664,
747,
14,
1438,
63,
20274,
687,
4107,
63,
1419,
288,
327,
284,
1085,
78,
63,
2992,
1122,
2529,
499,
641,
949,
1249,
288,
291,
14,
629,
8,
69,
14,
600,
12,
747,
14,
1438,
63,
20274,
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
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
199,
646,
747,
199,
646,
984,
199,
199,
504,
2508,
396,
63,
2609,
2764,
492,
1379,
20653,
3110,
199,
504,
9966,
63,
2609,
492,
5256,
2764,
199,
199,
504,
1683,
492,
3371,
12,
4420,
421,
199,
533,
1379,
6295,
14768,
3110,
8,
774,
20653,
3110,
304,
272,
1414,
63,
533,
275,
5256,
2764,
14,
6295,
14768,
3110,
339,
347,
3613,
8,
277,
304,
267,
1613,
8,
774,
6295,
14768,
3110,
12,
291,
680,
5996,
342,
267,
9238,
63,
11238,
275,
3371,
14,
785,
8,
1274,
12,
283,
3020,
297,
788,
6645,
13,
2609,
297,
283,
646,
1105,
267,
9238,
63,
11238,
14,
928,
342,
267,
291,
14,
12808,
8,
3020,
63,
11238,
14,
2379,
9,
339,
347,
511,
63,
16159,
8,
277,
304,
267,
291,
14,
2055,
14,
374,
63,
11616,
275,
4420,
8,
1107,
63,
585,
29,
797,
9,
267,
291,
14,
2055,
14,
973,
5234,
306,
6999,
401,
298,
368,
401,
4320,
6999,
401,
298,
5601,
3135,
267,
291,
14,
2055,
423,
3502,
63,
1419,
342,
339,
347,
511,
63,
11616,
8,
277,
304,
267,
291,
14,
2055,
14,
374,
63,
11616,
275,
4420,
8,
1107,
63,
585,
29,
549,
9,
267,
291,
14,
2055,
14,
973,
5234,
306,
6999,
401,
298,
368,
401,
4320,
6999,
401,
298,
5601,
3135,
267,
543,
291,
14,
1855,
8,
24738,
9,
465,
325,
26,
288,
291,
14,
2055,
423,
3502,
63,
1419,
342,
267,
291,
14,
629,
8,
736,
14,
1438,
63,
20274,
12,
325,
14,
1971,
14,
600,
9,
339,
347,
511,
63,
889,
63,
16159,
8,
277,
304,
267,
862,
26,
288,
291,
14,
2055,
14,
973,
4157,
267,
871,
14838,
465,
325,
26,
288,
291,
14,
629,
8,
69,
14,
600,
12,
499,
9,
398,
862,
26,
288,
291,
14,
2055,
423,
3502,
63,
1419,
342,
288,
291,
14,
1633,
480,
1944,
1919,
4915,
531,
267,
871,
2186,
465,
325,
26,
288,
986,
267,
871,
14838,
465,
325,
26,
288,
327,
2337,
12237,
370,
506,
376,
8691,
4976,
288,
327,
2348,
626,
8350,
641,
1015,
12,
641,
289,
1079,
288,
327,
781,
664,
1847,
20160,
390,
543,
372,
1233,
499,
221,
687,
2446,
12,
641,
289,
1046,
12,
781,
288,
327,
664,
747,
14,
1438,
63,
20274,
687,
4107,
63,
1419,
288,
327,
284,
1085,
78,
63,
2992,
1122,
2529,
499,
641,
949,
1249,
288,
291,
14,
629,
8,
69,
14,
600,
12,
747,
14,
1438,
63,
20274,
9,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
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W/gem5
|
src/arch/x86/isa/insts/simd64/integer/data_reordering/__init__.py
|
91
|
2421
|
# Copyright (c) 2007 The Hewlett-Packard Development Company
# All rights reserved.
#
# The license below extends only to copyright in the software and shall
# not be construed as granting a license to any other intellectual
# property including but not limited to intellectual property relating
# to a hardware implementation of the functionality of the software
# licensed hereunder. You may use the software subject to the license
# terms below provided that you ensure that this notice is replicated
# unmodified and in its entirety in all distributions of the software,
# modified or unmodified, in source code or in binary form.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met: redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer;
# redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution;
# neither the name of the copyright holders nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
# Authors: Gabe Black
categories = ["pack_with_saturation",
"unpack_and_interleave",
"extract_and_insert",
"shuffle_and_swap"]
microcode = '''
# 64 bit multimedia instructions
'''
for category in categories:
exec "import %s as cat" % category
microcode += cat.microcode
|
bsd-3-clause
|
[
3,
1898,
334,
67,
9,
10219,
710,
27849,
13,
29471,
15290,
15878,
199,
3,
2900,
4481,
4644,
14,
199,
3,
199,
3,
710,
4190,
5084,
16879,
1454,
370,
4248,
315,
314,
2032,
436,
10989,
199,
3,
440,
506,
950,
431,
68,
465,
16085,
316,
282,
4190,
370,
1263,
1163,
27925,
1264,
1061,
199,
3,
3324,
5893,
1325,
440,
13988,
370,
27925,
1264,
1061,
3324,
4668,
1958,
199,
3,
370,
282,
14991,
4514,
402,
314,
9330,
402,
314,
2032,
199,
3,
18233,
2348,
7138,
14,
221,
2047,
1443,
675,
314,
2032,
5420,
370,
314,
4190,
199,
3,
2895,
5084,
2741,
626,
1265,
4868,
626,
642,
4245,
365,
32436,
199,
3,
24214,
436,
315,
2399,
8039,
369,
315,
1006,
10208,
402,
314,
2032,
12,
199,
3,
6042,
503,
24214,
12,
315,
1350,
1233,
503,
315,
3366,
1824,
14,
199,
3,
199,
3,
10114,
436,
675,
315,
1350,
436,
3366,
4513,
12,
543,
503,
1928,
199,
3,
7100,
12,
787,
8211,
2741,
626,
314,
2569,
3704,
787,
199,
3,
7647,
26,
26771,
402,
1350,
1233,
1471,
8074,
314,
3432,
4248,
199,
3,
4245,
12,
642,
769,
402,
3704,
436,
314,
2569,
6450,
27,
199,
3,
26771,
315,
3366,
1824,
1471,
9172,
314,
3432,
4248,
199,
3,
4245,
12,
642,
769,
402,
3704,
436,
314,
2569,
6450,
315,
314,
199,
3,
3794,
436,
15,
269,
1163,
8418,
2741,
543,
314,
4084,
27,
199,
3,
15564,
314,
536,
402,
314,
4248,
31976,
6590,
314,
1561,
402,
2399,
199,
3,
8417,
1443,
506,
1202,
370,
10692,
503,
10016,
7585,
7131,
687,
199,
3,
642,
2032,
1928,
2488,
6791,
5313,
4983,
14,
199,
3,
199,
3,
5749,
4141,
2281,
7049,
6515,
2334,
5877,
8164,
2401,
6483,
199,
3,
298,
1179,
2281,
2,
2401,
1821,
7168,
1549,
5292,
2990,
12,
6931,
12,
5400,
2845,
199,
3,
5471,
2296,
12,
2334,
5292,
2990,
1634,
3169,
2401,
3092,
2381,
199,
3,
437,
3115,
3104,
9315,
9706,
14,
1621,
4825,
6461,
7000,
2334,
5877,
199,
3,
11489,
1549,
6483,
6262,
7024,
2381,
1821,
8703,
12,
9168,
12,
9716,
12,
199,
3,
8820,
12,
9836,
12,
1549,
9110,
6736,
334,
6446,
12,
5400,
2845,
199,
3,
5471,
2296,
12,
9838,
1634,
9103,
9764,
1549,
9714,
27,
9102,
1634,
4815,
12,
199,
3,
7126,
12,
1549,
9206,
27,
1549,
9748,
9831,
9,
9802,
9817,
2401,
5258,
1821,
199,
3,
9815,
1634,
5603,
12,
7061,
1621,
7066,
12,
9644,
5603,
12,
1549,
7056,
199,
3,
334,
6446,
9254,
1549,
7334,
9,
7043,
1621,
1821,
9683,
5738,
1634,
2334,
4815,
199,
3,
1634,
5749,
4141,
12,
9704,
8036,
9691,
1634,
2334,
9726,
1634,
9712,
9784,
14,
199,
3,
199,
3,
6642,
26,
598,
7570,
30593,
199,
199,
8906,
275,
2097,
1389,
63,
1045,
63,
14997,
1542,
401,
1598,
298,
5301,
63,
460,
63,
1058,
12422,
401,
1598,
298,
5005,
63,
460,
63,
3176,
401,
1598,
298,
11777,
63,
460,
63,
9286,
937,
199,
199,
6453,
600,
275,
1449,
199,
3,
5049,
4546,
19207,
521,
2391,
15794,
199,
2344,
199,
509,
4637,
315,
9695,
26,
272,
2146,
298,
646,
450,
83,
465,
6230,
2,
450,
4637,
272,
9967,
600,
847,
6230,
14,
6453,
600,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,
10219,
710,
27849,
13,
29471,
15290,
15878,
199,
3,
2900,
4481,
4644,
14,
199,
3,
199,
3,
710,
4190,
5084,
16879,
1454,
370,
4248,
315,
314,
2032,
436,
10989,
199,
3,
440,
506,
950,
431,
68,
465,
16085,
316,
282,
4190,
370,
1263,
1163,
27925,
1264,
1061,
199,
3,
3324,
5893,
1325,
440,
13988,
370,
27925,
1264,
1061,
3324,
4668,
1958,
199,
3,
370,
282,
14991,
4514,
402,
314,
9330,
402,
314,
2032,
199,
3,
18233,
2348,
7138,
14,
221,
2047,
1443,
675,
314,
2032,
5420,
370,
314,
4190,
199,
3,
2895,
5084,
2741,
626,
1265,
4868,
626,
642,
4245,
365,
32436,
199,
3,
24214,
436,
315,
2399,
8039,
369,
315,
1006,
10208,
402,
314,
2032,
12,
199,
3,
6042,
503,
24214,
12,
315,
1350,
1233,
503,
315,
3366,
1824,
14,
199,
3,
199,
3,
10114,
436,
675,
315,
1350,
436,
3366,
4513,
12,
543,
503,
1928,
199,
3,
7100,
12,
787,
8211,
2741,
626,
314,
2569,
3704,
787,
199,
3,
7647,
26,
26771,
402,
1350,
1233,
1471,
8074,
314,
3432,
4248,
199,
3,
4245,
12,
642,
769,
402,
3704,
436,
314,
2569,
6450,
27,
199,
3,
26771,
315,
3366,
1824,
1471,
9172,
314,
3432,
4248,
199,
3,
4245,
12,
642,
769,
402,
3704,
436,
314,
2569,
6450,
315,
314,
199,
3,
3794,
436,
15,
269,
1163,
8418,
2741,
543,
314,
4084,
27,
199,
3,
15564,
314,
536,
402,
314,
4248,
31976,
6590,
314,
1561,
402,
2399,
199,
3,
8417,
1443,
506,
1202,
370,
10692,
503,
10016,
7585,
7131,
687,
199,
3,
642,
2032,
1928,
2488,
6791,
5313,
4983,
14,
199,
3,
199,
3,
5749,
4141,
2281,
7049,
6515,
2334,
5877,
8164,
2401,
6483,
199,
3,
298,
1179,
2281,
2,
2401,
1821,
7168,
1549,
5292,
2990,
12,
6931,
12,
5400,
2845,
199,
3,
5471,
2296,
12,
2334,
5292,
2990,
1634,
3169,
2401,
3092,
2381,
199,
3,
437,
3115,
3104,
9315,
9706,
14,
1621,
4825,
6461,
7000,
2334,
5877,
199,
3,
11489,
1549,
6483,
6262,
7024,
2381,
1821,
8703,
12,
9168,
12,
9716,
12,
199,
3,
8820,
12,
9836,
12,
1549,
9110,
6736,
334,
6446,
12,
5400,
2845,
199,
3,
5471,
2296,
12,
9838,
1634,
9103,
9764,
1549,
9714,
27,
9102,
1634,
4815,
12,
199,
3,
7126,
12,
1549,
9206,
27,
1549,
9748,
9831,
9,
9802,
9817,
2401,
5258,
1821,
199,
3,
9815,
1634,
5603,
12,
7061,
1621,
7066,
12,
9644,
5603,
12,
1549,
7056,
199,
3,
334,
6446,
9254,
1549,
7334,
9,
7043,
1621,
1821,
9683,
5738,
1634,
2334,
4815,
199,
3,
1634,
5749,
4141,
12,
9704,
8036,
9691,
1634,
2334,
9726,
1634,
9712,
9784,
14,
199,
3,
199,
3,
6642,
26,
598,
7570,
30593,
199,
199,
8906,
275,
2097,
1389,
63,
1045,
63,
14997,
1542,
401,
1598,
298,
5301,
63,
460,
63,
1058,
12422,
401,
1598,
298,
5005,
63,
460,
63,
3176,
401,
1598,
298,
11777,
63,
460,
63,
9286,
937,
199,
199,
6453,
600,
275,
1449,
199,
3,
5049,
4546,
19207,
521,
2391,
15794,
199,
2344,
199,
509,
4637,
315,
9695,
26,
272,
2146,
298,
646,
450,
83,
465,
6230,
2,
450,
4637,
272,
9967,
600,
847,
6230,
14,
6453,
600,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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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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
] |
2gis/contesto
|
tests/utils_collect_metadata_tests.py
|
2
|
3411
|
# coding: utf-8
import unittest
try:
from StringIO import StringIO
except ImportError:
from io import StringIO
try:
from mock import Mock, patch
except ImportError:
from unittest.mock import Mock, patch
from nose.tools import nottest
from contesto import ContestoTestCase, config
@nottest
def fixture_test_case():
class MyTestCaseWithScreenshot(ContestoTestCase):
driver = Mock(page_source=Mock())
def test_method(self):
raise ValueError('123')
return MyTestCaseWithScreenshot('test_method')
@nottest
def test_case_will_fail():
class TestWithFailOnSetupTest(ContestoTestCase):
def _setup_test(self):
raise ValueError('123')
def test_method(self):
pass
return TestWithFailOnSetupTest('test_method')
class TestCaseUsingConfig(unittest.TestCase):
def setUp(self):
self._config_collect_metadata = config.utils["collect_metadata"]
def tearDown(self):
config.utils["collect_metadata"] = self._config_collect_metadata
config.utils['collect_page_source'] = True
class ContestoTestCaseCollectMetadata(TestCaseUsingConfig):
def test_should_collect_metadata(self):
config.utils['collect_metadata'] = True
test_case = fixture_test_case()
test_case.run()
self.assertIn('stack_trace', test_case._meta_info.keys())
self.assertIn('message', test_case._meta_info.keys())
attachments = [
item["name"] for item in test_case._meta_info['attachments']
]
self.assertIn("page_source", attachments)
def test_should_not_collect_metadata_if_not_collect_metadata(self):
config.utils['collect_metadata'] = False
test_case = fixture_test_case()
test_case.run()
self.assertNotIn('stack_trace', test_case._meta_info.keys())
self.assertNotIn('message', test_case._meta_info.keys())
self.assertListEqual([], test_case._meta_info['attachments'])
def test_should_collect_metadata_when_fails_on_setup(self):
config.utils['collect_metadata'] = True
test_case = test_case_will_fail()
test_case.run()
self.assertIn('stack_trace', test_case._meta_info.keys())
self.assertIn('message', test_case._meta_info.keys())
self.assertIn('attachments', test_case._meta_info.keys())
self.assertListEqual([], test_case._meta_info['attachments'])
def test_should_collect_using_specified_path(self):
config.utils['collect_metadata'] = True
config.utils['metadata_path'] = '/some/test/path'
test_case = fixture_test_case()
with patch('contesto.utils.collect.report_to_file') as m:
test_case.run()
self.assertTrue(m.called)
self.assertTrue(m.call_args[0][0].startswith('/some/test/path'))
def test_disable_page_source_collecting(self):
config.utils['collect_metadata'] = True
config.utils['collect_page_source'] = False
test_case = fixture_test_case()
test_case.run()
self.assertIn('stack_trace', test_case._meta_info.keys())
self.assertIn('message', test_case._meta_info.keys())
self.assertIn('attachments', test_case._meta_info.keys())
attachments = [
item["name"] for item in test_case._meta_info['attachments']
]
self.assertNotIn("page_source", attachments)
|
mit
|
[
3,
2803,
26,
2774,
13,
24,
199,
646,
2882,
199,
199,
893,
26,
272,
687,
5228,
492,
5228,
199,
2590,
3545,
26,
272,
687,
5890,
492,
5228,
199,
199,
893,
26,
272,
687,
1683,
492,
4420,
12,
3371,
199,
2590,
3545,
26,
272,
687,
2882,
14,
1805,
492,
4420,
12,
3371,
199,
199,
504,
11354,
14,
2537,
492,
440,
396,
199,
199,
504,
406,
396,
79,
492,
1448,
396,
79,
1746,
12,
1101,
421,
199,
32,
1397,
396,
199,
318,
10949,
63,
396,
63,
2546,
837,
272,
1021,
4932,
1746,
3007,
9616,
2782,
8,
714,
396,
79,
1746,
304,
267,
5253,
275,
4420,
8,
1606,
63,
1365,
29,
3346,
1012,
398,
347,
511,
63,
765,
8,
277,
304,
288,
746,
1722,
360,
4288,
358,
339,
372,
4932,
1746,
3007,
9616,
2782,
360,
396,
63,
765,
358,
421,
199,
32,
1397,
396,
199,
318,
511,
63,
2546,
63,
14117,
63,
1633,
837,
272,
1021,
1379,
3007,
4874,
3314,
8555,
774,
8,
714,
396,
79,
1746,
304,
267,
347,
485,
2758,
63,
396,
8,
277,
304,
288,
746,
1722,
360,
4288,
358,
398,
347,
511,
63,
765,
8,
277,
304,
288,
986,
339,
372,
1379,
3007,
4874,
3314,
8555,
774,
360,
396,
63,
765,
358,
421,
199,
533,
7640,
10369,
2028,
8,
2796,
14,
1746,
304,
272,
347,
3613,
8,
277,
304,
267,
291,
423,
888,
63,
7112,
63,
2343,
275,
1101,
14,
1208,
905,
7112,
63,
2343,
937,
339,
347,
6766,
8,
277,
304,
267,
1101,
14,
1208,
905,
7112,
63,
2343,
937,
275,
291,
423,
888,
63,
7112,
63,
2343,
267,
1101,
14,
1208,
459,
7112,
63,
1606,
63,
1365,
418,
275,
715,
421,
199,
533,
1448,
396,
79,
1746,
25023,
5142,
8,
1746,
10369,
2028,
304,
272,
347,
511,
63,
5626,
63,
7112,
63,
2343,
8,
277,
304,
267,
1101,
14,
1208,
459,
7112,
63,
2343,
418,
275,
715,
267,
511,
63,
2546,
275,
10949,
63,
396,
63,
2546,
342,
267,
511,
63,
2546,
14,
1065,
342,
267,
291,
14,
4080,
360,
2340,
63,
3446,
297,
511,
63,
2546,
423,
2024,
63,
815,
14,
1612,
1012,
267,
291,
14,
4080,
360,
1188,
297,
511,
63,
2546,
423,
2024,
63,
815,
14,
1612,
1012,
267,
18912,
275,
359,
288,
1242,
905,
354,
937,
367,
1242,
315,
511,
63,
2546,
423,
2024,
63,
815,
459,
15855,
418,
267,
1622,
267,
291,
14,
4080,
480,
1606,
63,
1365,
401,
18912,
9,
339,
347,
511,
63,
5626,
63,
1397,
63,
7112,
63,
2343,
63,
692,
63,
1397,
63,
7112,
63,
2343,
8,
277,
304,
267,
1101,
14,
1208,
459,
7112,
63,
2343,
418,
275,
756,
267,
511,
63,
2546,
275,
10949,
63,
396,
63,
2546,
342,
267,
511,
63,
2546,
14,
1065,
342,
267,
291,
14,
8795,
360,
2340,
63,
3446,
297,
511,
63,
2546,
423,
2024,
63,
815,
14,
1612,
1012,
267,
291,
14,
8795,
360,
1188,
297,
511,
63,
2546,
423,
2024,
63,
815,
14,
1612,
1012,
267,
291,
14,
16671,
8798,
511,
63,
2546,
423,
2024,
63,
815,
459,
15855,
1105,
339,
347,
511,
63,
5626,
63,
7112,
63,
2343,
63,
6526,
63,
15762,
63,
265,
63,
2758,
8,
277,
304,
267,
1101,
14,
1208,
459,
7112,
63,
2343,
418,
275,
715,
267,
511,
63,
2546,
275,
511,
63,
2546,
63,
14117,
63,
1633,
342,
267,
511,
63,
2546,
14,
1065,
342,
267,
291,
14,
4080,
360,
2340,
63,
3446,
297,
511,
63,
2546,
423,
2024,
63,
815,
14,
1612,
1012,
267,
291,
14,
4080,
360,
1188,
297,
511,
63,
2546,
423,
2024,
63,
815,
14,
1612,
1012,
267,
291,
14,
4080,
360,
15855,
297,
511,
63,
2546,
423,
2024,
63,
815,
14,
1612,
1012,
267,
291,
14,
16671,
8798,
511,
63,
2546,
423,
2024,
63,
815,
459,
15855,
1105,
339,
347,
511,
63,
5626,
63,
7112,
63,
4941,
63,
10085,
63,
515,
8,
277,
304,
267,
1101,
14,
1208,
459,
7112,
63,
2343,
418,
275,
715,
267,
1101,
14,
1208,
459,
2343,
63,
515,
418,
275,
1994,
3972,
15,
396,
15,
515,
7,
267,
511,
63,
2546,
275,
10949,
63,
396,
63,
2546,
342,
267,
543,
3371,
360,
388,
396,
79,
14,
1208,
14,
7112,
14,
3070,
63,
475,
63,
493,
358,
465,
333,
26,
288,
511,
63,
2546,
14,
1065,
342,
267,
291,
14,
1815,
8,
77,
14,
3527,
9,
267,
291,
14,
1815,
8,
77,
14,
1250,
63,
589,
59,
16,
1527,
16,
1055,
2460,
2336,
3972,
15,
396,
15,
515,
1333,
339,
347,
511,
63,
5993,
63,
1606,
63,
1365,
63,
7112,
316,
8,
277,
304,
267,
1101,
14,
1208,
459,
7112,
63,
2343,
418,
275,
715,
267,
1101,
14,
1208,
459,
7112,
63,
1606,
63,
1365,
418,
275,
756,
267,
511,
63,
2546,
275,
10949,
63,
396,
63,
2546,
342,
267,
511,
63,
2546,
14,
1065,
342,
267,
291,
14,
4080,
360,
2340,
63,
3446,
297,
511,
63,
2546,
423,
2024,
63,
815,
14,
1612,
1012,
267,
291,
14,
4080,
360,
1188,
297,
511,
63,
2546,
423,
2024,
63,
815,
14,
1612,
1012,
267,
291,
14,
4080,
360,
15855,
297,
511,
63,
2546,
423,
2024,
63,
815,
14,
1612,
1012,
267,
18912,
275,
359,
288,
1242,
905,
354,
937,
367,
1242,
315,
511,
63,
2546,
423,
2024,
63,
815,
459,
15855,
418,
267,
1622,
267,
291,
14,
8795,
480,
1606,
63,
1365,
401,
18912,
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
] |
[
2803,
26,
2774,
13,
24,
199,
646,
2882,
199,
199,
893,
26,
272,
687,
5228,
492,
5228,
199,
2590,
3545,
26,
272,
687,
5890,
492,
5228,
199,
199,
893,
26,
272,
687,
1683,
492,
4420,
12,
3371,
199,
2590,
3545,
26,
272,
687,
2882,
14,
1805,
492,
4420,
12,
3371,
199,
199,
504,
11354,
14,
2537,
492,
440,
396,
199,
199,
504,
406,
396,
79,
492,
1448,
396,
79,
1746,
12,
1101,
421,
199,
32,
1397,
396,
199,
318,
10949,
63,
396,
63,
2546,
837,
272,
1021,
4932,
1746,
3007,
9616,
2782,
8,
714,
396,
79,
1746,
304,
267,
5253,
275,
4420,
8,
1606,
63,
1365,
29,
3346,
1012,
398,
347,
511,
63,
765,
8,
277,
304,
288,
746,
1722,
360,
4288,
358,
339,
372,
4932,
1746,
3007,
9616,
2782,
360,
396,
63,
765,
358,
421,
199,
32,
1397,
396,
199,
318,
511,
63,
2546,
63,
14117,
63,
1633,
837,
272,
1021,
1379,
3007,
4874,
3314,
8555,
774,
8,
714,
396,
79,
1746,
304,
267,
347,
485,
2758,
63,
396,
8,
277,
304,
288,
746,
1722,
360,
4288,
358,
398,
347,
511,
63,
765,
8,
277,
304,
288,
986,
339,
372,
1379,
3007,
4874,
3314,
8555,
774,
360,
396,
63,
765,
358,
421,
199,
533,
7640,
10369,
2028,
8,
2796,
14,
1746,
304,
272,
347,
3613,
8,
277,
304,
267,
291,
423,
888,
63,
7112,
63,
2343,
275,
1101,
14,
1208,
905,
7112,
63,
2343,
937,
339,
347,
6766,
8,
277,
304,
267,
1101,
14,
1208,
905,
7112,
63,
2343,
937,
275,
291,
423,
888,
63,
7112,
63,
2343,
267,
1101,
14,
1208,
459,
7112,
63,
1606,
63,
1365,
418,
275,
715,
421,
199,
533,
1448,
396,
79,
1746,
25023,
5142,
8,
1746,
10369,
2028,
304,
272,
347,
511,
63,
5626,
63,
7112,
63,
2343,
8,
277,
304,
267,
1101,
14,
1208,
459,
7112,
63,
2343,
418,
275,
715,
267,
511,
63,
2546,
275,
10949,
63,
396,
63,
2546,
342,
267,
511,
63,
2546,
14,
1065,
342,
267,
291,
14,
4080,
360,
2340,
63,
3446,
297,
511,
63,
2546,
423,
2024,
63,
815,
14,
1612,
1012,
267,
291,
14,
4080,
360,
1188,
297,
511,
63,
2546,
423,
2024,
63,
815,
14,
1612,
1012,
267,
18912,
275,
359,
288,
1242,
905,
354,
937,
367,
1242,
315,
511,
63,
2546,
423,
2024,
63,
815,
459,
15855,
418,
267,
1622,
267,
291,
14,
4080,
480,
1606,
63,
1365,
401,
18912,
9,
339,
347,
511,
63,
5626,
63,
1397,
63,
7112,
63,
2343,
63,
692,
63,
1397,
63,
7112,
63,
2343,
8,
277,
304,
267,
1101,
14,
1208,
459,
7112,
63,
2343,
418,
275,
756,
267,
511,
63,
2546,
275,
10949,
63,
396,
63,
2546,
342,
267,
511,
63,
2546,
14,
1065,
342,
267,
291,
14,
8795,
360,
2340,
63,
3446,
297,
511,
63,
2546,
423,
2024,
63,
815,
14,
1612,
1012,
267,
291,
14,
8795,
360,
1188,
297,
511,
63,
2546,
423,
2024,
63,
815,
14,
1612,
1012,
267,
291,
14,
16671,
8798,
511,
63,
2546,
423,
2024,
63,
815,
459,
15855,
1105,
339,
347,
511,
63,
5626,
63,
7112,
63,
2343,
63,
6526,
63,
15762,
63,
265,
63,
2758,
8,
277,
304,
267,
1101,
14,
1208,
459,
7112,
63,
2343,
418,
275,
715,
267,
511,
63,
2546,
275,
511,
63,
2546,
63,
14117,
63,
1633,
342,
267,
511,
63,
2546,
14,
1065,
342,
267,
291,
14,
4080,
360,
2340,
63,
3446,
297,
511,
63,
2546,
423,
2024,
63,
815,
14,
1612,
1012,
267,
291,
14,
4080,
360,
1188,
297,
511,
63,
2546,
423,
2024,
63,
815,
14,
1612,
1012,
267,
291,
14,
4080,
360,
15855,
297,
511,
63,
2546,
423,
2024,
63,
815,
14,
1612,
1012,
267,
291,
14,
16671,
8798,
511,
63,
2546,
423,
2024,
63,
815,
459,
15855,
1105,
339,
347,
511,
63,
5626,
63,
7112,
63,
4941,
63,
10085,
63,
515,
8,
277,
304,
267,
1101,
14,
1208,
459,
7112,
63,
2343,
418,
275,
715,
267,
1101,
14,
1208,
459,
2343,
63,
515,
418,
275,
1994,
3972,
15,
396,
15,
515,
7,
267,
511,
63,
2546,
275,
10949,
63,
396,
63,
2546,
342,
267,
543,
3371,
360,
388,
396,
79,
14,
1208,
14,
7112,
14,
3070,
63,
475,
63,
493,
358,
465,
333,
26,
288,
511,
63,
2546,
14,
1065,
342,
267,
291,
14,
1815,
8,
77,
14,
3527,
9,
267,
291,
14,
1815,
8,
77,
14,
1250,
63,
589,
59,
16,
1527,
16,
1055,
2460,
2336,
3972,
15,
396,
15,
515,
1333,
339,
347,
511,
63,
5993,
63,
1606,
63,
1365,
63,
7112,
316,
8,
277,
304,
267,
1101,
14,
1208,
459,
7112,
63,
2343,
418,
275,
715,
267,
1101,
14,
1208,
459,
7112,
63,
1606,
63,
1365,
418,
275,
756,
267,
511,
63,
2546,
275,
10949,
63,
396,
63,
2546,
342,
267,
511,
63,
2546,
14,
1065,
342,
267,
291,
14,
4080,
360,
2340,
63,
3446,
297,
511,
63,
2546,
423,
2024,
63,
815,
14,
1612,
1012,
267,
291,
14,
4080,
360,
1188,
297,
511,
63,
2546,
423,
2024,
63,
815,
14,
1612,
1012,
267,
291,
14,
4080,
360,
15855,
297,
511,
63,
2546,
423,
2024,
63,
815,
14,
1612,
1012,
267,
18912,
275,
359,
288,
1242,
905,
354,
937,
367,
1242,
315,
511,
63,
2546,
423,
2024,
63,
815,
459,
15855,
418,
267,
1622,
267,
291,
14,
8795,
480,
1606,
63,
1365,
401,
18912,
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,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
CalSol/mbed
|
tools/export/simplicity/__init__.py
|
16
|
5885
|
"""
mbed SDK
Copyright (c) 2014-2016 ARM Limited
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""
from os.path import split,splitext, basename
from tools.export.exporters import Exporter, deprecated_exporter
class Folder:
def __init__(self, name):
self.name = name
self.children = []
def contains(self, folderName):
for child in self.children:
if child.name == folderName:
return True
return False
def __str__(self):
retval = self.name + " "
if len(self.children) > 0:
retval += "[ "
for child in self.children:
retval += child.__str__()
retval += " ]"
return retval
def findChild(self, folderName):
for child in self.children:
if child.name == folderName:
return child
return None
def addChild(self, folderName):
if folderName == '':
return None
if not self.contains(folderName):
self.children.append(Folder(folderName))
return self.findChild(folderName)
@deprecated_exporter
class SimplicityV3(Exporter):
NAME = 'SimplicityV3'
TOOLCHAIN = 'GCC_ARM'
TARGETS = [
'EFM32GG_STK3700',
'EFM32ZG_STK3200',
'EFM32LG_STK3600',
'EFM32WG_STK3800',
'EFM32HG_STK3400',
'EFM32PG_STK3401'
]
PARTS = {
'EFM32GG_STK3700': 'com.silabs.mcu.si32.efm32.efm32gg.efm32gg990f1024',
'EFM32ZG_STK3200': 'com.silabs.mcu.si32.efm32.efm32zg.efm32zg222f32',
'EFM32LG_STK3600': 'com.silabs.mcu.si32.efm32.efm32lg.efm32lg990f256',
'EFM32WG_STK3800': 'com.silabs.mcu.si32.efm32.efm32wg.efm32wg990f256',
'EFM32HG_STK3400': 'com.silabs.mcu.si32.efm32.efm32hg.efm32hg322f64',
'EFM32PG_STK3401': 'com.silabs.mcu.si32.efm32.efm32pg1b.efm32pg1b200f256gm48'
}
KITS = {
'EFM32GG_STK3700': 'com.silabs.kit.si32.efm32.efm32gg.stk3700',
'EFM32ZG_STK3200': 'com.silabs.kit.si32.efm32.efm32zg.stk3200',
'EFM32LG_STK3600': 'com.silabs.kit.si32.efm32.efm32lg.stk3600',
'EFM32WG_STK3800': 'com.silabs.kit.si32.efm32.efm32wg.stk3800',
'EFM32HG_STK3400': 'com.silabs.kit.si32.efm32.efm32hg.slstk3400a',
'EFM32PG_STK3401': 'com.silabs.kit.si32.efm32.efm32pg.slstk3401a'
}
FILE_TYPES = {
'c_sources':'1',
'cpp_sources':'1',
's_sources':'1'
}
EXCLUDED_LIBS = [
'm',
'c',
'gcc',
'nosys',
'supc++',
'stdc++'
]
DOT_IN_RELATIVE_PATH = False
MBED_CONFIG_HEADER_SUPPORTED = True
orderedPaths = Folder("Root")
def check_and_add_path(self, path):
levels = path.split('/')
base = self.orderedPaths
for level in levels:
if base.contains(level):
base = base.findChild(level)
else:
base.addChild(level)
base = base.findChild(level)
def generate(self):
# "make" wants Unix paths
self.resources.win_to_unix()
main_files = []
EXCLUDED_LIBS = [
'm',
'c',
'gcc',
'nosys',
'supc++',
'stdc++'
]
for r_type in ['s_sources', 'c_sources', 'cpp_sources']:
r = getattr(self.resources, r_type)
if r:
for source in r:
self.check_and_add_path(split(source)[0])
if not ('/' in source):
main_files.append(source)
libraries = []
for lib in self.resources.libraries:
l, _ = splitext(basename(lib))
if l[3:] not in EXCLUDED_LIBS:
libraries.append(l[3:])
defines = []
for define in self.toolchain.get_symbols():
if '=' in define:
keyval = define.split('=')
defines.append( (keyval[0], keyval[1]) )
else:
defines.append( (define, '') )
self.check_and_add_path(split(self.resources.linker_script)[0])
ctx = {
'name': self.project_name,
'main_files': main_files,
'recursiveFolders': self.orderedPaths,
'object_files': self.resources.objects,
'include_paths': self.resources.inc_dirs,
'library_paths': self.resources.lib_dirs,
'linker_script': self.resources.linker_script,
'libraries': libraries,
'defines': defines,
'part': self.PARTS[self.target],
'kit': self.KITS[self.target],
'loopcount': 0
}
ctx.update(self.flags)
## Strip main folder from include paths because ssproj is not capable of handling it
if '.' in ctx['include_paths']:
ctx['include_paths'].remove('.')
ctx['include_root'] = True
'''
Suppress print statements
print('\n')
print(self.target)
print('\n')
print(ctx)
print('\n')
print(self.orderedPaths)
for path in self.orderedPaths.children:
print(path.name + "\n")
for bpath in path.children:
print("\t" + bpath.name + "\n")
'''
self.gen_file('simplicity/slsproj.tmpl', ctx, '%s.slsproj' % self.project_name)
|
apache-2.0
|
[
624,
199,
3665,
15610,
199,
7384,
334,
67,
9,
6927,
13,
9261,
27155,
23954,
199,
199,
31661,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
199,
13297,
1443,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
199,
5556,
1443,
3332,
282,
1331,
402,
314,
844,
737,
339,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
199,
5524,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
16832,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
199,
29946,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
199,
9295,
314,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
199,
3097,
1298,
1334,
314,
844,
14,
199,
624,
199,
504,
747,
14,
515,
492,
3715,
12,
7973,
12,
9593,
199,
199,
504,
7249,
14,
3790,
14,
1474,
27568,
492,
7910,
3968,
12,
5906,
63,
30305,
199,
199,
533,
29121,
26,
272,
347,
636,
826,
721,
277,
12,
536,
304,
267,
291,
14,
354,
275,
536,
267,
291,
14,
3223,
275,
942,
339,
347,
3509,
8,
277,
12,
4922,
985,
304,
267,
367,
1982,
315,
291,
14,
3223,
26,
288,
340,
1982,
14,
354,
508,
4922,
985,
26,
355,
372,
715,
267,
372,
756,
339,
347,
636,
495,
721,
277,
304,
267,
9151,
275,
291,
14,
354,
435,
298,
298,
267,
340,
822,
8,
277,
14,
3223,
9,
690,
378,
26,
288,
9151,
847,
7369,
298,
288,
367,
1982,
315,
291,
14,
3223,
26,
355,
9151,
847,
1982,
855,
495,
4533,
288,
9151,
847,
298,
1622,
2,
398,
372,
9151,
339,
347,
2342,
3493,
8,
277,
12,
4922,
985,
304,
267,
367,
1982,
315,
291,
14,
3223,
26,
288,
340,
1982,
14,
354,
508,
4922,
985,
26,
355,
372,
1982,
267,
372,
488,
339,
347,
1050,
3493,
8,
277,
12,
4922,
985,
304,
267,
340,
4922,
985,
508,
8061,
288,
372,
488,
398,
340,
440,
291,
14,
6134,
8,
3741,
985,
304,
288,
291,
14,
3223,
14,
740,
8,
7850,
8,
3741,
985,
430,
398,
372,
291,
14,
1623,
3493,
8,
3741,
985,
9,
199,
199,
32,
6667,
63,
30305,
199,
533,
29094,
20976,
54,
19,
8,
30341,
304,
272,
13637,
275,
283,
51,
3236,
20976,
54,
19,
7,
272,
2296,
2228,
25256,
275,
283,
10566,
63,
12482,
7,
339,
26134,
51,
275,
359,
267,
283,
14153,
45,
708,
2916,
63,
840,
43,
1401,
383,
297,
267,
283,
14153,
45,
708,
26074,
63,
840,
43,
32079,
297,
267,
283,
14153,
45,
708,
44,
39,
63,
840,
43,
11035,
297,
267,
283,
14153,
45,
708,
55,
39,
63,
840,
43,
1703,
383,
297,
267,
283,
14153,
45,
708,
31442,
63,
840,
43,
1082,
383,
297,
267,
283,
14153,
45,
708,
11115,
63,
840,
43,
1082,
614,
7,
272,
1622,
339,
3076,
51,
275,
469,
267,
283,
14153,
45,
708,
2916,
63,
840,
43,
1401,
383,
356,
283,
957,
14,
20329,
2101,
14,
5466,
85,
14,
338,
708,
14,
2829,
77,
708,
14,
2829,
77,
708,
2721,
14,
2829,
77,
708,
2721,
16166,
70,
7727,
297,
267,
283,
14153,
45,
708,
26074,
63,
840,
43,
32079,
356,
283,
957,
14,
20329,
2101,
14,
5466,
85,
14,
338,
708,
14,
2829,
77,
708,
14,
2829,
77,
708,
90,
71,
14,
2829,
77,
708,
90,
71,
9485,
70,
708,
297,
267,
283,
14153,
45,
708,
44,
39,
63,
840,
43,
11035,
356,
283,
957,
14,
20329,
2101,
14,
5466,
85,
14,
338,
708,
14,
2829,
77,
708,
14,
2829,
77,
708,
9783,
14,
2829,
77,
708,
9783,
16166,
70,
3912,
297,
267,
283,
14153,
45,
708,
55,
39,
63,
840,
43,
1703,
383,
356,
283,
957,
14,
20329,
2101,
14,
5466,
85,
14,
338,
708,
14,
2829,
77,
708,
14,
2829,
77,
708,
23596,
14,
2829,
77,
708,
23596,
16166,
70,
3912,
297,
267,
283,
14153,
45,
708,
31442,
63,
840,
43,
1082,
383,
356,
283,
957,
14,
20329,
2101,
14,
5466,
85,
14,
338,
708,
14,
2829,
77,
708,
14,
2829,
77,
708,
9208,
14,
2829,
77,
708,
9208,
15858,
70,
772,
297,
267,
283,
14153,
45,
708,
11115,
63,
840,
43,
1082,
614,
356,
283,
957,
14,
20329,
2101,
14,
5466,
85,
14,
338,
708,
14,
2829,
77,
708,
14,
2829,
77,
708,
4198,
17,
66,
14,
2829,
77,
708,
4198,
17,
66,
1840,
70,
3912,
13844,
2006,
7,
272,
789,
339,
1804,
5930,
275,
469,
267,
283,
14153,
45,
708,
2916,
63,
840,
43,
1401,
383,
356,
283,
957,
14,
20329,
2101,
14,
6065,
14,
338,
708,
14,
2829,
77,
708,
14,
2829,
77,
708,
2721,
14,
270,
75,
1401,
383,
297,
267,
283,
14153,
45,
708,
26074,
63,
840,
43,
32079,
356,
283,
957,
14,
20329,
2101,
14,
6065,
14,
338,
708,
14,
2829,
77,
708,
14,
2829,
77,
708,
90,
71,
14,
270,
75,
32079,
297,
267,
283,
14153,
45,
708,
44,
39,
63,
840,
43,
11035,
356,
283,
957,
14,
20329,
2101,
14,
6065,
14,
338,
708,
14,
2829,
77,
708,
14,
2829,
77,
708,
9783,
14,
270,
75,
11035,
297,
267,
283,
14153,
45,
708,
55,
39,
63,
840,
43,
1703,
383,
356,
283,
957,
14,
20329,
2101,
14,
6065,
14,
338,
708,
14,
2829,
77,
708,
14,
2829,
77,
708,
23596,
14,
270,
75,
1703,
383,
297,
267,
283,
14153,
45,
708,
31442,
63,
840,
43,
1082,
383,
356,
283,
957,
14,
20329,
2101,
14,
6065,
14,
338,
708,
14,
2829,
77,
708,
14,
2829,
77,
708,
9208,
14,
2482,
270,
75,
1082,
383,
65,
297,
507,
198,
7,
14153,
45,
708,
11115,
63,
840,
43,
1082,
614,
356,
283,
957,
14,
20329,
2101,
14,
6065,
14,
338,
708,
14,
2829,
77,
708,
14,
2829,
77,
708,
4198,
14,
2482,
270,
75,
1082,
614,
65,
7,
272,
789,
339,
13024,
63,
7893,
275,
469,
267,
283,
67,
63,
4553,
5242,
17,
297,
267,
283,
5910,
63,
4553,
5242,
17,
297,
267,
283,
83,
63,
4553,
5242,
17,
7,
272,
789,
339,
3651,
1981,
53,
8280,
63,
25161,
275,
359,
267,
283,
77,
297,
267,
283,
67,
297,
267,
283,
13112,
297,
267,
283,
12712,
588
] |
[
199,
3665,
15610,
199,
7384,
334,
67,
9,
6927,
13,
9261,
27155,
23954,
199,
199,
31661,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
199,
13297,
1443,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
199,
5556,
1443,
3332,
282,
1331,
402,
314,
844,
737,
339,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
199,
5524,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
16832,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
199,
29946,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
199,
9295,
314,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
199,
3097,
1298,
1334,
314,
844,
14,
199,
624,
199,
504,
747,
14,
515,
492,
3715,
12,
7973,
12,
9593,
199,
199,
504,
7249,
14,
3790,
14,
1474,
27568,
492,
7910,
3968,
12,
5906,
63,
30305,
199,
199,
533,
29121,
26,
272,
347,
636,
826,
721,
277,
12,
536,
304,
267,
291,
14,
354,
275,
536,
267,
291,
14,
3223,
275,
942,
339,
347,
3509,
8,
277,
12,
4922,
985,
304,
267,
367,
1982,
315,
291,
14,
3223,
26,
288,
340,
1982,
14,
354,
508,
4922,
985,
26,
355,
372,
715,
267,
372,
756,
339,
347,
636,
495,
721,
277,
304,
267,
9151,
275,
291,
14,
354,
435,
298,
298,
267,
340,
822,
8,
277,
14,
3223,
9,
690,
378,
26,
288,
9151,
847,
7369,
298,
288,
367,
1982,
315,
291,
14,
3223,
26,
355,
9151,
847,
1982,
855,
495,
4533,
288,
9151,
847,
298,
1622,
2,
398,
372,
9151,
339,
347,
2342,
3493,
8,
277,
12,
4922,
985,
304,
267,
367,
1982,
315,
291,
14,
3223,
26,
288,
340,
1982,
14,
354,
508,
4922,
985,
26,
355,
372,
1982,
267,
372,
488,
339,
347,
1050,
3493,
8,
277,
12,
4922,
985,
304,
267,
340,
4922,
985,
508,
8061,
288,
372,
488,
398,
340,
440,
291,
14,
6134,
8,
3741,
985,
304,
288,
291,
14,
3223,
14,
740,
8,
7850,
8,
3741,
985,
430,
398,
372,
291,
14,
1623,
3493,
8,
3741,
985,
9,
199,
199,
32,
6667,
63,
30305,
199,
533,
29094,
20976,
54,
19,
8,
30341,
304,
272,
13637,
275,
283,
51,
3236,
20976,
54,
19,
7,
272,
2296,
2228,
25256,
275,
283,
10566,
63,
12482,
7,
339,
26134,
51,
275,
359,
267,
283,
14153,
45,
708,
2916,
63,
840,
43,
1401,
383,
297,
267,
283,
14153,
45,
708,
26074,
63,
840,
43,
32079,
297,
267,
283,
14153,
45,
708,
44,
39,
63,
840,
43,
11035,
297,
267,
283,
14153,
45,
708,
55,
39,
63,
840,
43,
1703,
383,
297,
267,
283,
14153,
45,
708,
31442,
63,
840,
43,
1082,
383,
297,
267,
283,
14153,
45,
708,
11115,
63,
840,
43,
1082,
614,
7,
272,
1622,
339,
3076,
51,
275,
469,
267,
283,
14153,
45,
708,
2916,
63,
840,
43,
1401,
383,
356,
283,
957,
14,
20329,
2101,
14,
5466,
85,
14,
338,
708,
14,
2829,
77,
708,
14,
2829,
77,
708,
2721,
14,
2829,
77,
708,
2721,
16166,
70,
7727,
297,
267,
283,
14153,
45,
708,
26074,
63,
840,
43,
32079,
356,
283,
957,
14,
20329,
2101,
14,
5466,
85,
14,
338,
708,
14,
2829,
77,
708,
14,
2829,
77,
708,
90,
71,
14,
2829,
77,
708,
90,
71,
9485,
70,
708,
297,
267,
283,
14153,
45,
708,
44,
39,
63,
840,
43,
11035,
356,
283,
957,
14,
20329,
2101,
14,
5466,
85,
14,
338,
708,
14,
2829,
77,
708,
14,
2829,
77,
708,
9783,
14,
2829,
77,
708,
9783,
16166,
70,
3912,
297,
267,
283,
14153,
45,
708,
55,
39,
63,
840,
43,
1703,
383,
356,
283,
957,
14,
20329,
2101,
14,
5466,
85,
14,
338,
708,
14,
2829,
77,
708,
14,
2829,
77,
708,
23596,
14,
2829,
77,
708,
23596,
16166,
70,
3912,
297,
267,
283,
14153,
45,
708,
31442,
63,
840,
43,
1082,
383,
356,
283,
957,
14,
20329,
2101,
14,
5466,
85,
14,
338,
708,
14,
2829,
77,
708,
14,
2829,
77,
708,
9208,
14,
2829,
77,
708,
9208,
15858,
70,
772,
297,
267,
283,
14153,
45,
708,
11115,
63,
840,
43,
1082,
614,
356,
283,
957,
14,
20329,
2101,
14,
5466,
85,
14,
338,
708,
14,
2829,
77,
708,
14,
2829,
77,
708,
4198,
17,
66,
14,
2829,
77,
708,
4198,
17,
66,
1840,
70,
3912,
13844,
2006,
7,
272,
789,
339,
1804,
5930,
275,
469,
267,
283,
14153,
45,
708,
2916,
63,
840,
43,
1401,
383,
356,
283,
957,
14,
20329,
2101,
14,
6065,
14,
338,
708,
14,
2829,
77,
708,
14,
2829,
77,
708,
2721,
14,
270,
75,
1401,
383,
297,
267,
283,
14153,
45,
708,
26074,
63,
840,
43,
32079,
356,
283,
957,
14,
20329,
2101,
14,
6065,
14,
338,
708,
14,
2829,
77,
708,
14,
2829,
77,
708,
90,
71,
14,
270,
75,
32079,
297,
267,
283,
14153,
45,
708,
44,
39,
63,
840,
43,
11035,
356,
283,
957,
14,
20329,
2101,
14,
6065,
14,
338,
708,
14,
2829,
77,
708,
14,
2829,
77,
708,
9783,
14,
270,
75,
11035,
297,
267,
283,
14153,
45,
708,
55,
39,
63,
840,
43,
1703,
383,
356,
283,
957,
14,
20329,
2101,
14,
6065,
14,
338,
708,
14,
2829,
77,
708,
14,
2829,
77,
708,
23596,
14,
270,
75,
1703,
383,
297,
267,
283,
14153,
45,
708,
31442,
63,
840,
43,
1082,
383,
356,
283,
957,
14,
20329,
2101,
14,
6065,
14,
338,
708,
14,
2829,
77,
708,
14,
2829,
77,
708,
9208,
14,
2482,
270,
75,
1082,
383,
65,
297,
507,
198,
7,
14153,
45,
708,
11115,
63,
840,
43,
1082,
614,
356,
283,
957,
14,
20329,
2101,
14,
6065,
14,
338,
708,
14,
2829,
77,
708,
14,
2829,
77,
708,
4198,
14,
2482,
270,
75,
1082,
614,
65,
7,
272,
789,
339,
13024,
63,
7893,
275,
469,
267,
283,
67,
63,
4553,
5242,
17,
297,
267,
283,
5910,
63,
4553,
5242,
17,
297,
267,
283,
83,
63,
4553,
5242,
17,
7,
272,
789,
339,
3651,
1981,
53,
8280,
63,
25161,
275,
359,
267,
283,
77,
297,
267,
283,
67,
297,
267,
283,
13112,
297,
267,
283,
12712,
588,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
ptomasroos/vitess
|
py/vtdb/update_stream.py
|
16
|
2847
|
# Copyright 2015, Google Inc. All rights reserved.
# Use of this source code is governed by a BSD-style license that can
# be found in the LICENSE file.
# mapping from protocol to python class. The protocol matches the string
# used by vttablet as a -binlog_player_protocol parameter.
update_stream_conn_classes = dict()
def register_conn_class(protocol, c):
"""Used by implementations to register themselves.
Args:
protocol: short string to document the protocol.
c: class to register.
"""
update_stream_conn_classes[protocol] = c
def connect(protocol, *pargs, **kargs):
"""Return a dialed UpdateStreamConnection to an update stream server.
Args:
protocol: The registered protocol to use.
*pargs: Passed to the registered protocol __init__ method.
**kargs: Passed to the registered protocol __init__ method.
Returns:
A dialed UpdateStreamConnection.
Raises:
ValueError: On bad protocol.
"""
if protocol not in update_stream_conn_classes:
raise ValueError('Unknown update stream protocol', protocol)
conn = update_stream_conn_classes[protocol](*pargs, **kargs)
conn.dial()
return conn
class StreamEvent(object):
"""StreamEvent describes a single event in the update stream.
Eventually we will use the proto3 definition object.
"""
ERR = 0
DML = 1
DDL = 2
POS = 3
def __init__(self, category, table_name, fields, rows, sql, timestamp,
transaction_id):
self.category = category
self.table_name = table_name
self.fields = fields
self.rows = rows
self.sql = sql
self.timestamp = timestamp
self.transaction_id = transaction_id
class UpdateStreamConnection(object):
"""The interface for the update stream client implementations.
All implementations must implement all these methods. If something
goes wrong with the connection, this object will be thrown out.
"""
def __init__(self, addr, timeout):
"""Initialize an update stream connection.
Args:
addr: server address. Can be protocol dependent.
timeout: connection timeout (float, in seconds).
"""
pass
def dial(self):
"""Dial to the server. If successful, call close() to close the connection.
"""
pass
def close(self):
"""Close the connection. This object may be re-used again by calling dial().
"""
pass
def is_closed(self):
"""Checks the connection status.
Returns:
True if this connection is closed.
"""
pass
def stream_update(self, position, timeout=3600.0):
"""Generator method to stream the updates from a given replication point.
Args:
position: Starting position to stream from.
timeout: Should stop streaming after we reach this timeout.
Returns:
This is a generator method that yields StreamEvent objects.
"""
pass
|
bsd-3-clause
|
[
3,
1898,
6900,
12,
4475,
3277,
14,
2900,
4481,
4644,
14,
199,
3,
3645,
402,
642,
1350,
1233,
365,
10413,
701,
282,
6289,
13,
2487,
4190,
626,
883,
199,
3,
506,
1911,
315,
314,
5113,
570,
14,
199,
199,
3,
4412,
687,
4113,
370,
2366,
1021,
14,
710,
4113,
4450,
314,
1059,
199,
3,
1202,
701,
18585,
23126,
465,
282,
446,
1393,
793,
63,
6147,
63,
3922,
2725,
14,
199,
873,
63,
1745,
63,
1631,
63,
2888,
275,
1211,
342,
421,
199,
318,
2274,
63,
1631,
63,
533,
8,
3922,
12,
286,
304,
523,
408,
9167,
701,
12591,
370,
2274,
17279,
14,
819,
3033,
26,
272,
4113,
26,
3974,
1059,
370,
2213,
314,
4113,
14,
272,
286,
26,
1021,
370,
2274,
14,
523,
408,
523,
1678,
63,
1745,
63,
1631,
63,
2888,
59,
3922,
61,
275,
286,
421,
199,
318,
4907,
8,
3922,
12,
627,
462,
458,
12,
1011,
24459,
304,
523,
408,
1767,
282,
487,
65,
1146,
6162,
3296,
3225,
370,
376,
1678,
2547,
1654,
14,
819,
3033,
26,
272,
4113,
26,
710,
7264,
4113,
370,
675,
14,
272,
627,
462,
458,
26,
510,
2744,
370,
314,
7264,
4113,
636,
826,
363,
1083,
14,
272,
1011,
24459,
26,
510,
2744,
370,
314,
7264,
4113,
636,
826,
363,
1083,
14,
819,
1803,
26,
272,
437,
487,
65,
1146,
6162,
3296,
3225,
14,
819,
6218,
26,
272,
1722,
26,
4068,
4875,
4113,
14,
523,
408,
523,
340,
4113,
440,
315,
1678,
63,
1745,
63,
1631,
63,
2888,
26,
272,
746,
1722,
360,
5912,
1678,
2547,
4113,
297,
4113,
9,
523,
2557,
275,
1678,
63,
1745,
63,
1631,
63,
2888,
59,
3922,
61,
2031,
462,
458,
12,
1011,
24459,
9,
523,
2557,
14,
328,
279,
342,
523,
372,
2557,
421,
199,
533,
8271,
2390,
8,
785,
304,
523,
408,
3296,
2390,
23369,
282,
2849,
1566,
315,
314,
1678,
2547,
14,
819,
6763,
3163,
781,
911,
675,
314,
4104,
19,
5492,
909,
14,
523,
408,
819,
21569,
275,
378,
523,
577,
1698,
275,
413,
523,
32078,
275,
499,
523,
510,
3100,
275,
650,
819,
347,
636,
826,
721,
277,
12,
4637,
12,
1817,
63,
354,
12,
1504,
12,
4730,
12,
3875,
12,
4913,
12,
2049,
6008,
63,
344,
304,
272,
291,
14,
3710,
275,
4637,
272,
291,
14,
1224,
63,
354,
275,
1817,
63,
354,
272,
291,
14,
955,
275,
1504,
272,
291,
14,
3838,
275,
4730,
272,
291,
14,
3009,
275,
3875,
272,
291,
14,
3954,
275,
4913,
272,
291,
14,
5945,
63,
344,
275,
6008,
63,
344,
421,
199,
533,
6162,
3296,
3225,
8,
785,
304,
523,
408,
1918,
3217,
367,
314,
1678,
2547,
1890,
12591,
14,
819,
2900,
12591,
1471,
5669,
1006,
3520,
3102,
14,
221,
982,
6020,
523,
13538,
6835,
543,
314,
1950,
12,
642,
909,
911,
506,
14031,
734,
14,
523,
408,
819,
347,
636,
826,
721,
277,
12,
5552,
12,
2653,
304,
272,
408,
9345,
376,
1678,
2547,
1950,
14,
339,
3033,
26,
489,
5552,
26,
1654,
2287,
14,
6855,
506,
4113,
11410,
14,
489,
2653,
26,
1950,
2653,
334,
1609,
12,
315,
4696,
680,
272,
408,
272,
986,
819,
347,
487,
279,
8,
277,
304,
272,
408,
1341,
279,
370,
314,
1654,
14,
982,
9512,
12,
1240,
4002,
342,
370,
4002,
314,
1950,
14,
272,
408,
272,
986,
819,
347,
4002,
8,
277,
304,
272,
408,
4724,
314,
1950,
14,
961,
909,
1443,
506,
295,
13,
2972,
4020,
701,
6358,
487,
279,
1252,
272,
408,
272,
986,
819,
347,
365,
63,
5938,
8,
277,
304,
272,
408,
11834,
314,
1950,
2004,
14,
339,
1803,
26,
489,
715,
340,
642,
1950,
365,
6876,
14,
272,
408,
272,
986,
819,
347,
2547,
63,
873,
8,
277,
12,
3421,
12,
2653,
29,
11035,
14,
16,
304,
272,
408,
7599,
1083,
370,
2547,
314,
7029,
687,
282,
1627,
20797,
2376,
14,
339,
3033,
26,
489,
3421,
26,
24175,
3421,
370,
2547,
687,
14,
489,
2653,
26,
7719,
3631,
18490,
2410,
781,
12276,
642,
2653,
14,
339,
1803,
26,
489,
961,
365,
282,
4306,
1083,
626,
14801,
8271,
2390,
2251,
14,
272,
408,
272,
986,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
1898,
6900,
12,
4475,
3277,
14,
2900,
4481,
4644,
14,
199,
3,
3645,
402,
642,
1350,
1233,
365,
10413,
701,
282,
6289,
13,
2487,
4190,
626,
883,
199,
3,
506,
1911,
315,
314,
5113,
570,
14,
199,
199,
3,
4412,
687,
4113,
370,
2366,
1021,
14,
710,
4113,
4450,
314,
1059,
199,
3,
1202,
701,
18585,
23126,
465,
282,
446,
1393,
793,
63,
6147,
63,
3922,
2725,
14,
199,
873,
63,
1745,
63,
1631,
63,
2888,
275,
1211,
342,
421,
199,
318,
2274,
63,
1631,
63,
533,
8,
3922,
12,
286,
304,
523,
408,
9167,
701,
12591,
370,
2274,
17279,
14,
819,
3033,
26,
272,
4113,
26,
3974,
1059,
370,
2213,
314,
4113,
14,
272,
286,
26,
1021,
370,
2274,
14,
523,
408,
523,
1678,
63,
1745,
63,
1631,
63,
2888,
59,
3922,
61,
275,
286,
421,
199,
318,
4907,
8,
3922,
12,
627,
462,
458,
12,
1011,
24459,
304,
523,
408,
1767,
282,
487,
65,
1146,
6162,
3296,
3225,
370,
376,
1678,
2547,
1654,
14,
819,
3033,
26,
272,
4113,
26,
710,
7264,
4113,
370,
675,
14,
272,
627,
462,
458,
26,
510,
2744,
370,
314,
7264,
4113,
636,
826,
363,
1083,
14,
272,
1011,
24459,
26,
510,
2744,
370,
314,
7264,
4113,
636,
826,
363,
1083,
14,
819,
1803,
26,
272,
437,
487,
65,
1146,
6162,
3296,
3225,
14,
819,
6218,
26,
272,
1722,
26,
4068,
4875,
4113,
14,
523,
408,
523,
340,
4113,
440,
315,
1678,
63,
1745,
63,
1631,
63,
2888,
26,
272,
746,
1722,
360,
5912,
1678,
2547,
4113,
297,
4113,
9,
523,
2557,
275,
1678,
63,
1745,
63,
1631,
63,
2888,
59,
3922,
61,
2031,
462,
458,
12,
1011,
24459,
9,
523,
2557,
14,
328,
279,
342,
523,
372,
2557,
421,
199,
533,
8271,
2390,
8,
785,
304,
523,
408,
3296,
2390,
23369,
282,
2849,
1566,
315,
314,
1678,
2547,
14,
819,
6763,
3163,
781,
911,
675,
314,
4104,
19,
5492,
909,
14,
523,
408,
819,
21569,
275,
378,
523,
577,
1698,
275,
413,
523,
32078,
275,
499,
523,
510,
3100,
275,
650,
819,
347,
636,
826,
721,
277,
12,
4637,
12,
1817,
63,
354,
12,
1504,
12,
4730,
12,
3875,
12,
4913,
12,
2049,
6008,
63,
344,
304,
272,
291,
14,
3710,
275,
4637,
272,
291,
14,
1224,
63,
354,
275,
1817,
63,
354,
272,
291,
14,
955,
275,
1504,
272,
291,
14,
3838,
275,
4730,
272,
291,
14,
3009,
275,
3875,
272,
291,
14,
3954,
275,
4913,
272,
291,
14,
5945,
63,
344,
275,
6008,
63,
344,
421,
199,
533,
6162,
3296,
3225,
8,
785,
304,
523,
408,
1918,
3217,
367,
314,
1678,
2547,
1890,
12591,
14,
819,
2900,
12591,
1471,
5669,
1006,
3520,
3102,
14,
221,
982,
6020,
523,
13538,
6835,
543,
314,
1950,
12,
642,
909,
911,
506,
14031,
734,
14,
523,
408,
819,
347,
636,
826,
721,
277,
12,
5552,
12,
2653,
304,
272,
408,
9345,
376,
1678,
2547,
1950,
14,
339,
3033,
26,
489,
5552,
26,
1654,
2287,
14,
6855,
506,
4113,
11410,
14,
489,
2653,
26,
1950,
2653,
334,
1609,
12,
315,
4696,
680,
272,
408,
272,
986,
819,
347,
487,
279,
8,
277,
304,
272,
408,
1341,
279,
370,
314,
1654,
14,
982,
9512,
12,
1240,
4002,
342,
370,
4002,
314,
1950,
14,
272,
408,
272,
986,
819,
347,
4002,
8,
277,
304,
272,
408,
4724,
314,
1950,
14,
961,
909,
1443,
506,
295,
13,
2972,
4020,
701,
6358,
487,
279,
1252,
272,
408,
272,
986,
819,
347,
365,
63,
5938,
8,
277,
304,
272,
408,
11834,
314,
1950,
2004,
14,
339,
1803,
26,
489,
715,
340,
642,
1950,
365,
6876,
14,
272,
408,
272,
986,
819,
347,
2547,
63,
873,
8,
277,
12,
3421,
12,
2653,
29,
11035,
14,
16,
304,
272,
408,
7599,
1083,
370,
2547,
314,
7029,
687,
282,
1627,
20797,
2376,
14,
339,
3033,
26,
489,
3421,
26,
24175,
3421,
370,
2547,
687,
14,
489,
2653,
26,
7719,
3631,
18490,
2410,
781,
12276,
642,
2653,
14,
339,
1803,
26,
489,
961,
365,
282,
4306,
1083,
626,
14801,
8271,
2390,
2251,
14,
272,
408,
272,
986,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
stackforge/refstack
|
refstack/db/api.py
|
2
|
9143
|
# Copyright (c) 2015 Mirantis, Inc.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
"""Defines interface for DB access.
Functions in this module are imported into the refstack.db namespace.
Call these functions from refstack.db namespace, not the refstack.db.api
namespace.
"""
from oslo_config import cfg
from oslo_db import api as db_api
db_opts = [
cfg.StrOpt('db_backend',
default='sqlalchemy',
help='The backend to use for database.'),
cfg.StrOpt('version_table',
default='alembic_version',
help='The alembic version table name to use within the ' +
'database. To allow RefStack to upload and store ' +
'the full set of subunit data, set this option to ' +
'refstack_alembic_version.'),
]
CONF = cfg.CONF
CONF.register_opts(db_opts)
_BACKEND_MAPPING = {'sqlalchemy': 'refstack.db.sqlalchemy.api'}
IMPL = db_api.DBAPI.from_config(cfg.CONF, backend_mapping=_BACKEND_MAPPING,
lazy=True)
NotFound = IMPL.NotFound
Duplication = IMPL.Duplication
def store_test_results(results):
"""Storing results into database.
:param results: Dict describes test results.
"""
return IMPL.store_test_results(results)
def get_test_result(test_id, allowed_keys=None):
"""Get test run information from the database.
:param test_id: The ID of the test.
"""
return IMPL.get_test_result(test_id, allowed_keys=allowed_keys)
def delete_test_result(test_id):
"""Delete test run information from the database.
:param test_id: The ID of the test.
"""
return IMPL.delete_test_result(test_id)
def update_test_result(test_info):
"""Update test from the given test_info dictionary.
:param test_info: The test
"""
return IMPL.update_test_result(test_info)
def get_test_results(test_id):
"""Get all passed tempest tests for a specified test run.
:param test_id: The ID of the test.
"""
return IMPL.get_test_results(test_id)
def get_test_result_meta_key(test_id, key, default=None):
"""Get metadata value related to specified test run.
:param test_id: The ID of the test.
:param key: Metadata key
:param default: Default value
"""
return IMPL.get_test_result_meta_key(test_id, key, default)
def save_test_result_meta_item(test_id, key, value):
"""Store or update item value related to specified test run.
:param test_id: The ID of the test.
:param key: Metadata key
"""
return IMPL.save_test_result_meta_item(test_id, key, value)
def delete_test_result_meta_item(test_id, key):
"""Delete metadata item related to specified test run.
:param test_id: The ID of the test.
:param key: Metadata key
:param default: Default value
:raise NotFound if default value is not set and no value found
"""
return IMPL.delete_test_result_meta_item(test_id, key)
def get_test_result_records(page_number, per_page, filters):
"""Get page with applied filters for uploaded test records.
:param page_number: The number of page.
:param per_page: The number of results for one page.
:param filters: (Dict) Filters that will be applied for records.
"""
return IMPL.get_test_result_records(page_number, per_page, filters)
def get_test_result_records_count(filters):
"""Get total pages number with applied filters for uploaded test records.
:param filters: (Dict) Filters that will be applied for records.
"""
return IMPL.get_test_result_records_count(filters)
def user_get(user_openid):
"""Get user info.
:param user_openid: User openid
"""
return IMPL.user_get(user_openid)
def user_save(user_info):
"""Create user DB record if it exists, otherwise record will be updated.
:param user_info: User record
"""
return IMPL.user_save(user_info)
def get_pubkey(key):
"""Get pubkey info for a given key.
:param key: public key
"""
return IMPL.get_pubkey(key)
def store_pubkey(pubkey_info):
"""Store public key in to DB."""
return IMPL.store_pubkey(pubkey_info)
def delete_pubkey(pubkey_id):
"""Delete public key from DB."""
return IMPL.delete_pubkey(pubkey_id)
def get_user_pubkeys(user_openid):
"""Get public pubkeys for specified user."""
return IMPL.get_user_pubkeys(user_openid)
def add_user_to_group(user_openid, group_id, created_by_user):
"""Add specified user to specified group."""
return IMPL.add_user_to_group(user_openid, group_id, created_by_user)
def remove_user_from_group(user_openid, group_id):
"""Remove specified user from specified group."""
return IMPL.remove_user_from_group(user_openid, group_id)
def add_organization(organization_info, creator):
"""Add organization."""
return IMPL.add_organization(organization_info, creator)
def update_organization(organization_info):
"""Update organization."""
return IMPL.update_organization(organization_info)
def get_organization(organization_id, allowed_keys=None):
"""Get organization by id."""
return IMPL.get_organization(organization_id, allowed_keys=allowed_keys)
def delete_organization(organization_id):
"""delete organization by id."""
return IMPL.delete_organization(organization_id)
def add_product(product_info, creator):
"""Add product from product_info dicionary with creator."""
return IMPL.add_product(product_info, creator)
def update_product(product_info):
"""Update product from prodict_info dicionary."""
return IMPL.update_product(product_info)
def get_product(id, allowed_keys=None):
"""Get product by id."""
return IMPL.get_product(id, allowed_keys=allowed_keys)
def delete_product(id):
"""delete product by id."""
return IMPL.delete_product(id)
def get_foundation_users():
"""Get users' openid-s that belong to group of foundation."""
return IMPL.get_foundation_users()
def get_organization_users(organization_id):
"""Get users with info that belong to group of organization."""
return IMPL.get_organization_users(organization_id)
def get_organizations(allowed_keys=None):
"""Get all organizations."""
return IMPL.get_organizations(allowed_keys=allowed_keys)
def get_organizations_by_types(types, allowed_keys=None):
"""Get organization by list of types."""
return IMPL.get_organizations_by_types(types, allowed_keys=allowed_keys)
def get_organizations_by_user(user_openid, allowed_keys=None):
"""Get organizations for specified user."""
return IMPL.get_organizations_by_user(user_openid,
allowed_keys=allowed_keys)
def get_products(allowed_keys=None, filters=None):
"""Get all products."""
return IMPL.get_products(allowed_keys=allowed_keys, filters=filters)
def get_products_by_user(user_openid, allowed_keys=None, filters=None):
"""Get all products that user can manage."""
return IMPL.get_products_by_user(user_openid, allowed_keys=allowed_keys,
filters=filters)
def get_product_by_version(product_version_id, allowed_keys=None):
"""Get product info from a product version ID."""
return IMPL.get_product_by_version(product_version_id,
allowed_keys=allowed_keys)
def get_product_version(product_version_id, allowed_keys=None):
"""Get details of a specific version given the id."""
return IMPL.get_product_version(product_version_id,
allowed_keys=allowed_keys)
def get_product_version_by_cpid(cpid, allowed_keys=None):
"""Get a product version given a cloud provider id."""
return IMPL.get_product_version_by_cpid(cpid, allowed_keys=allowed_keys)
def get_product_versions(product_id, allowed_keys=None):
"""Get all versions for a product."""
return IMPL.get_product_versions(product_id, allowed_keys=allowed_keys)
def add_product_version(product_id, version, creator, cpid=None,
allowed_keys=None):
"""Add a new product version."""
return IMPL.add_product_version(product_id, version, creator, cpid,
allowed_keys=allowed_keys)
def update_product_version(product_version_info):
"""Update product version from product_info_version dictionary."""
return IMPL.update_product_version(product_version_info)
def delete_product_version(product_version_id):
"""Delete a product version."""
return IMPL.delete_product_version(product_version_id)
|
apache-2.0
|
[
3,
1898,
334,
67,
9,
6900,
603,
723,
4466,
83,
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,
23891,
3217,
367,
6249,
2879,
14,
199,
199,
13967,
315,
642,
859,
787,
8439,
1901,
314,
2984,
2340,
14,
697,
3231,
14,
199,
2176,
3520,
3423,
687,
2984,
2340,
14,
697,
3231,
12,
440,
314,
2984,
2340,
14,
697,
14,
1246,
199,
3251,
14,
199,
624,
199,
504,
11258,
63,
888,
492,
4810,
199,
504,
11258,
63,
697,
492,
2986,
465,
1592,
63,
1246,
421,
199,
697,
63,
3291,
275,
359,
272,
4810,
14,
19340,
360,
697,
63,
4620,
297,
2049,
849,
534,
14536,
297,
2049,
1720,
534,
1918,
4865,
370,
675,
367,
3050,
8038,
272,
4810,
14,
19340,
360,
1023,
63,
1224,
297,
2049,
849,
534,
1895,
20596,
63,
1023,
297,
2049,
1720,
534,
1918,
30960,
20596,
1015,
1817,
536,
370,
675,
4453,
314,
283,
435,
490,
283,
4659,
14,
4005,
2040,
15397,
4851,
370,
5802,
436,
3877,
283,
435,
490,
283,
1589,
2615,
663,
402,
1007,
3248,
666,
12,
663,
642,
945,
370,
283,
435,
490,
283,
1121,
2340,
63,
1895,
20596,
63,
1023,
8038,
199,
61,
199,
199,
3103,
275,
4810,
14,
3103,
199,
3103,
14,
2683,
63,
3291,
8,
697,
63,
3291,
9,
199,
199,
63,
18145,
63,
20351,
275,
791,
14536,
356,
283,
1121,
2340,
14,
697,
14,
14536,
14,
1246,
936,
199,
26312,
275,
1592,
63,
1246,
14,
2846,
3735,
14,
504,
63,
888,
8,
4128,
14,
3103,
12,
4865,
63,
4745,
3699,
18145,
63,
20351,
12,
1816,
9617,
29,
549,
9,
199,
199,
4667,
275,
473,
3950,
14,
4667,
199,
36,
384,
1863,
275,
473,
3950,
14,
36,
384,
1863,
421,
199,
318,
3877,
63,
396,
63,
2604,
8,
2604,
304,
272,
408,
933,
6854,
2058,
1901,
3050,
14,
339,
520,
635,
2058,
26,
7448,
23369,
511,
2058,
14,
272,
408,
272,
372,
473,
3950,
14,
1617,
63,
396,
63,
2604,
8,
2604,
9,
421,
199,
318,
664,
63,
396,
63,
1099,
8,
396,
63,
344,
12,
4370,
63,
1612,
29,
403,
304,
272,
408,
1002,
511,
1255,
2556,
687,
314,
3050,
14,
339,
520,
635,
511,
63,
344,
26,
710,
2870,
402,
314,
511,
14,
272,
408,
272,
372,
473,
3950,
14,
362,
63,
396,
63,
1099,
8,
396,
63,
344,
12,
4370,
63,
1612,
29,
6541,
63,
1612,
9,
421,
199,
318,
3145,
63,
396,
63,
1099,
8,
396,
63,
344,
304,
272,
408,
5392,
511,
1255,
2556,
687,
314,
3050,
14,
339,
520,
635,
511,
63,
344,
26,
710,
2870,
402,
314,
511,
14,
272,
408,
272,
372,
473,
3950,
14,
1807,
63,
396,
63,
1099,
8,
396,
63,
344,
9,
421,
199,
318,
1678,
63,
396,
63,
1099,
8,
396,
63,
815,
304,
272,
408,
4152,
511,
687,
314,
1627,
511,
63,
815,
2600,
14,
339,
520,
635,
511,
63,
815,
26,
710,
511,
272,
408,
272,
372,
473,
3950,
14,
873,
63,
396,
63,
1099,
8,
396,
63,
815,
9,
421,
199,
318,
664,
63,
396,
63,
2604,
8,
396,
63,
344,
304,
272,
408,
1002,
1006,
3032,
24076,
2295,
367,
282,
2013,
511,
1255,
14,
339,
520,
635,
511,
63,
344,
26,
710,
2870,
402,
314,
511,
14,
272,
408,
272,
372,
473,
3950,
14,
362,
63,
396,
63,
2604,
8,
396,
63,
344,
9,
421,
199,
318,
664,
63,
396,
63,
1099,
63,
2024,
63,
498,
8,
396,
63,
344,
12,
790,
12,
849,
29,
403,
304,
272,
408,
1002,
3341,
574,
4048,
370,
2013,
511,
1255,
14,
339,
520,
635,
511,
63,
344,
26,
710,
2870,
402,
314,
511,
14,
272,
520,
635,
790,
26,
16160,
790,
272,
520,
635,
849,
26,
3758,
574,
339,
408,
272,
372,
473,
3950,
14,
362,
63,
396,
63,
1099,
63,
2024,
63,
498,
8,
396,
63,
344,
12,
790,
12,
849,
9,
421,
199,
318,
3354,
63,
396,
63,
1099,
63,
2024,
63,
1053,
8,
396,
63,
344,
12,
790,
12,
574,
304,
272,
408,
5502,
503,
1678,
1242,
574,
4048,
370,
2013,
511,
1255,
14,
339,
520,
635,
511,
63,
344,
26,
710,
2870,
402,
314,
511,
14,
272,
520,
635,
790,
26,
16160,
790,
339,
408,
272,
372,
473,
3950,
14,
2117,
63,
396,
63,
1099,
63,
2024,
63,
1053,
8,
396,
63,
344,
12,
790,
12,
574,
9,
421,
199,
318,
3145,
63,
396,
63,
1099,
63,
2024,
63,
1053,
8,
396,
63,
344,
12,
790,
304,
272,
408,
5392,
3341,
1242,
4048,
370,
2013,
511,
1255,
14,
339,
520,
635,
511,
63,
344,
26,
710,
2870,
402,
314,
511,
14,
272,
520,
635,
790,
26,
16160,
790,
272,
520,
635,
849,
26,
3758,
574,
339,
520,
3730,
21909,
340,
849,
574,
365,
440,
663,
436,
949,
574,
1911,
272,
408,
272,
372,
473,
3950,
14,
1807,
63,
396,
63,
1099,
63,
2024,
63,
1053,
8,
396,
63,
344,
12,
790,
9,
421,
199,
318,
664,
63,
396,
63,
1099,
63,
6502,
8,
1606,
63,
1955,
12,
1126,
63,
1606,
12,
4766,
304,
272,
408,
1002,
2034,
543,
6781,
4766,
367,
14238,
511,
5767,
14,
339,
520,
635,
2034,
63,
1955,
26,
710,
1329,
402,
2034,
14,
272,
520,
635,
1126,
63,
1606,
26,
710,
1329,
402,
2058,
367,
1373,
2034,
14,
272,
520,
635,
4766,
26,
334,
2141,
9,
21240,
626,
911,
506,
6781,
367,
5767,
14
] |
[
1898,
334,
67,
9,
6900,
603,
723,
4466,
83,
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,
23891,
3217,
367,
6249,
2879,
14,
199,
199,
13967,
315,
642,
859,
787,
8439,
1901,
314,
2984,
2340,
14,
697,
3231,
14,
199,
2176,
3520,
3423,
687,
2984,
2340,
14,
697,
3231,
12,
440,
314,
2984,
2340,
14,
697,
14,
1246,
199,
3251,
14,
199,
624,
199,
504,
11258,
63,
888,
492,
4810,
199,
504,
11258,
63,
697,
492,
2986,
465,
1592,
63,
1246,
421,
199,
697,
63,
3291,
275,
359,
272,
4810,
14,
19340,
360,
697,
63,
4620,
297,
2049,
849,
534,
14536,
297,
2049,
1720,
534,
1918,
4865,
370,
675,
367,
3050,
8038,
272,
4810,
14,
19340,
360,
1023,
63,
1224,
297,
2049,
849,
534,
1895,
20596,
63,
1023,
297,
2049,
1720,
534,
1918,
30960,
20596,
1015,
1817,
536,
370,
675,
4453,
314,
283,
435,
490,
283,
4659,
14,
4005,
2040,
15397,
4851,
370,
5802,
436,
3877,
283,
435,
490,
283,
1589,
2615,
663,
402,
1007,
3248,
666,
12,
663,
642,
945,
370,
283,
435,
490,
283,
1121,
2340,
63,
1895,
20596,
63,
1023,
8038,
199,
61,
199,
199,
3103,
275,
4810,
14,
3103,
199,
3103,
14,
2683,
63,
3291,
8,
697,
63,
3291,
9,
199,
199,
63,
18145,
63,
20351,
275,
791,
14536,
356,
283,
1121,
2340,
14,
697,
14,
14536,
14,
1246,
936,
199,
26312,
275,
1592,
63,
1246,
14,
2846,
3735,
14,
504,
63,
888,
8,
4128,
14,
3103,
12,
4865,
63,
4745,
3699,
18145,
63,
20351,
12,
1816,
9617,
29,
549,
9,
199,
199,
4667,
275,
473,
3950,
14,
4667,
199,
36,
384,
1863,
275,
473,
3950,
14,
36,
384,
1863,
421,
199,
318,
3877,
63,
396,
63,
2604,
8,
2604,
304,
272,
408,
933,
6854,
2058,
1901,
3050,
14,
339,
520,
635,
2058,
26,
7448,
23369,
511,
2058,
14,
272,
408,
272,
372,
473,
3950,
14,
1617,
63,
396,
63,
2604,
8,
2604,
9,
421,
199,
318,
664,
63,
396,
63,
1099,
8,
396,
63,
344,
12,
4370,
63,
1612,
29,
403,
304,
272,
408,
1002,
511,
1255,
2556,
687,
314,
3050,
14,
339,
520,
635,
511,
63,
344,
26,
710,
2870,
402,
314,
511,
14,
272,
408,
272,
372,
473,
3950,
14,
362,
63,
396,
63,
1099,
8,
396,
63,
344,
12,
4370,
63,
1612,
29,
6541,
63,
1612,
9,
421,
199,
318,
3145,
63,
396,
63,
1099,
8,
396,
63,
344,
304,
272,
408,
5392,
511,
1255,
2556,
687,
314,
3050,
14,
339,
520,
635,
511,
63,
344,
26,
710,
2870,
402,
314,
511,
14,
272,
408,
272,
372,
473,
3950,
14,
1807,
63,
396,
63,
1099,
8,
396,
63,
344,
9,
421,
199,
318,
1678,
63,
396,
63,
1099,
8,
396,
63,
815,
304,
272,
408,
4152,
511,
687,
314,
1627,
511,
63,
815,
2600,
14,
339,
520,
635,
511,
63,
815,
26,
710,
511,
272,
408,
272,
372,
473,
3950,
14,
873,
63,
396,
63,
1099,
8,
396,
63,
815,
9,
421,
199,
318,
664,
63,
396,
63,
2604,
8,
396,
63,
344,
304,
272,
408,
1002,
1006,
3032,
24076,
2295,
367,
282,
2013,
511,
1255,
14,
339,
520,
635,
511,
63,
344,
26,
710,
2870,
402,
314,
511,
14,
272,
408,
272,
372,
473,
3950,
14,
362,
63,
396,
63,
2604,
8,
396,
63,
344,
9,
421,
199,
318,
664,
63,
396,
63,
1099,
63,
2024,
63,
498,
8,
396,
63,
344,
12,
790,
12,
849,
29,
403,
304,
272,
408,
1002,
3341,
574,
4048,
370,
2013,
511,
1255,
14,
339,
520,
635,
511,
63,
344,
26,
710,
2870,
402,
314,
511,
14,
272,
520,
635,
790,
26,
16160,
790,
272,
520,
635,
849,
26,
3758,
574,
339,
408,
272,
372,
473,
3950,
14,
362,
63,
396,
63,
1099,
63,
2024,
63,
498,
8,
396,
63,
344,
12,
790,
12,
849,
9,
421,
199,
318,
3354,
63,
396,
63,
1099,
63,
2024,
63,
1053,
8,
396,
63,
344,
12,
790,
12,
574,
304,
272,
408,
5502,
503,
1678,
1242,
574,
4048,
370,
2013,
511,
1255,
14,
339,
520,
635,
511,
63,
344,
26,
710,
2870,
402,
314,
511,
14,
272,
520,
635,
790,
26,
16160,
790,
339,
408,
272,
372,
473,
3950,
14,
2117,
63,
396,
63,
1099,
63,
2024,
63,
1053,
8,
396,
63,
344,
12,
790,
12,
574,
9,
421,
199,
318,
3145,
63,
396,
63,
1099,
63,
2024,
63,
1053,
8,
396,
63,
344,
12,
790,
304,
272,
408,
5392,
3341,
1242,
4048,
370,
2013,
511,
1255,
14,
339,
520,
635,
511,
63,
344,
26,
710,
2870,
402,
314,
511,
14,
272,
520,
635,
790,
26,
16160,
790,
272,
520,
635,
849,
26,
3758,
574,
339,
520,
3730,
21909,
340,
849,
574,
365,
440,
663,
436,
949,
574,
1911,
272,
408,
272,
372,
473,
3950,
14,
1807,
63,
396,
63,
1099,
63,
2024,
63,
1053,
8,
396,
63,
344,
12,
790,
9,
421,
199,
318,
664,
63,
396,
63,
1099,
63,
6502,
8,
1606,
63,
1955,
12,
1126,
63,
1606,
12,
4766,
304,
272,
408,
1002,
2034,
543,
6781,
4766,
367,
14238,
511,
5767,
14,
339,
520,
635,
2034,
63,
1955,
26,
710,
1329,
402,
2034,
14,
272,
520,
635,
1126,
63,
1606,
26,
710,
1329,
402,
2058,
367,
1373,
2034,
14,
272,
520,
635,
4766,
26,
334,
2141,
9,
21240,
626,
911,
506,
6781,
367,
5767,
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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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
] |
ihmccreery/kubernetes
|
vendor/github.com/ugorji/go/codec/test.py
|
1516
|
4019
|
#!/usr/bin/env python
# This will create golden files in a directory passed to it.
# A Test calls this internally to create the golden files
# So it can process them (so we don't have to checkin the files).
# Ensure msgpack-python and cbor are installed first, using:
# sudo apt-get install python-dev
# sudo apt-get install python-pip
# pip install --user msgpack-python msgpack-rpc-python cbor
# Ensure all "string" keys are utf strings (else encoded as bytes)
import cbor, msgpack, msgpackrpc, sys, os, threading
def get_test_data_list():
# get list with all primitive types, and a combo type
l0 = [
-8,
-1616,
-32323232,
-6464646464646464,
192,
1616,
32323232,
6464646464646464,
192,
-3232.0,
-6464646464.0,
3232.0,
6464.0,
6464646464.0,
False,
True,
u"null",
None,
u"someday",
1328176922000002000,
u"",
-2206187877999998000,
u"bytestring",
270,
u"none",
-2013855847999995777,
#-6795364578871345152,
]
l1 = [
{ "true": True,
"false": False },
{ "true": u"True",
"false": False,
"uint16(1616)": 1616 },
{ "list": [1616, 32323232, True, -3232.0, {"TRUE":True, "FALSE":False}, [True, False] ],
"int32":32323232, "bool": True,
"LONG STRING": u"123456789012345678901234567890123456789012345678901234567890",
"SHORT STRING": u"1234567890" },
{ True: "true", 138: False, "false": 200 }
]
l = []
l.extend(l0)
l.append(l0)
l.append(1)
l.extend(l1)
return l
def build_test_data(destdir):
l = get_test_data_list()
for i in range(len(l)):
# packer = msgpack.Packer()
serialized = msgpack.dumps(l[i])
f = open(os.path.join(destdir, str(i) + '.msgpack.golden'), 'wb')
f.write(serialized)
f.close()
serialized = cbor.dumps(l[i])
f = open(os.path.join(destdir, str(i) + '.cbor.golden'), 'wb')
f.write(serialized)
f.close()
def doRpcServer(port, stopTimeSec):
class EchoHandler(object):
def Echo123(self, msg1, msg2, msg3):
return ("1:%s 2:%s 3:%s" % (msg1, msg2, msg3))
def EchoStruct(self, msg):
return ("%s" % msg)
addr = msgpackrpc.Address('localhost', port)
server = msgpackrpc.Server(EchoHandler())
server.listen(addr)
# run thread to stop it after stopTimeSec seconds if > 0
if stopTimeSec > 0:
def myStopRpcServer():
server.stop()
t = threading.Timer(stopTimeSec, myStopRpcServer)
t.start()
server.start()
def doRpcClientToPythonSvc(port):
address = msgpackrpc.Address('localhost', port)
client = msgpackrpc.Client(address, unpack_encoding='utf-8')
print client.call("Echo123", "A1", "B2", "C3")
print client.call("EchoStruct", {"A" :"Aa", "B":"Bb", "C":"Cc"})
def doRpcClientToGoSvc(port):
# print ">>>> port: ", port, " <<<<<"
address = msgpackrpc.Address('localhost', port)
client = msgpackrpc.Client(address, unpack_encoding='utf-8')
print client.call("TestRpcInt.Echo123", ["A1", "B2", "C3"])
print client.call("TestRpcInt.EchoStruct", {"A" :"Aa", "B":"Bb", "C":"Cc"})
def doMain(args):
if len(args) == 2 and args[0] == "testdata":
build_test_data(args[1])
elif len(args) == 3 and args[0] == "rpc-server":
doRpcServer(int(args[1]), int(args[2]))
elif len(args) == 2 and args[0] == "rpc-client-python-service":
doRpcClientToPythonSvc(int(args[1]))
elif len(args) == 2 and args[0] == "rpc-client-go-service":
doRpcClientToGoSvc(int(args[1]))
else:
print("Usage: test.py " +
"[testdata|rpc-server|rpc-client-python-service|rpc-client-go-service] ...")
if __name__ == "__main__":
doMain(sys.argv[1:])
|
apache-2.0
|
[
3381,
2647,
15,
1393,
15,
1813,
2366,
199,
199,
3,
961,
911,
1218,
17631,
1584,
315,
282,
2082,
3032,
370,
652,
14,
199,
3,
437,
1379,
4882,
642,
14448,
370,
1218,
314,
17631,
1584,
199,
3,
2002,
652,
883,
2112,
3062,
334,
1152,
781,
2793,
1133,
1172,
370,
1104,
262,
314,
1584,
680,
199,
199,
3,
7523,
26635,
13,
1548,
436,
7434,
269,
787,
4903,
1642,
12,
1808,
26,
199,
3,
257,
14682,
20932,
13,
362,
3907,
2366,
13,
2374,
199,
3,
257,
14682,
20932,
13,
362,
3907,
2366,
13,
9983,
199,
3,
257,
7305,
3907,
1553,
751,
26635,
13,
1548,
26635,
13,
4354,
13,
1548,
7434,
269,
199,
199,
3,
7523,
1006,
298,
875,
2,
2883,
787,
2774,
3326,
334,
2836,
5737,
465,
2783,
9,
199,
199,
646,
7434,
269,
12,
26635,
12,
26635,
4354,
12,
984,
12,
747,
12,
5796,
199,
199,
318,
664,
63,
396,
63,
576,
63,
513,
837,
272,
327,
664,
769,
543,
1006,
18944,
2943,
12,
436,
282,
20972,
730,
272,
634,
16,
275,
359,
4960,
446,
24,
12,
268,
446,
975,
975,
12,
268,
446,
24356,
24356,
12,
268,
446,
21336,
21336,
21336,
21336,
12,
268,
13567,
12,
268,
3193,
975,
12,
268,
4337,
24356,
708,
12,
268,
5049,
21336,
21336,
21336,
772,
12,
268,
13567,
12,
268,
446,
24356,
14,
16,
12,
268,
446,
21336,
21336,
772,
14,
16,
12,
268,
4337,
708,
14,
16,
12,
268,
5049,
772,
14,
16,
12,
268,
5049,
21336,
21336,
14,
16,
12,
268,
756,
12,
268,
715,
12,
268,
399,
2,
2307,
401,
268,
488,
12,
268,
399,
2,
3972,
2977,
401,
268,
413,
12870,
1196,
1876,
1081,
993,
996,
1493,
12,
268,
399,
5151,
268,
446,
1081,
1690,
1085,
2277,
1138,
5008,
2905,
1493,
12,
268,
399,
2,
991,
396,
5985,
401,
268,
27632,
12,
268,
399,
2,
3592,
401,
267,
446,
1797,
1703,
1229,
15883,
5008,
2720,
11956,
12,
268,
327,
13,
18450,
2481,
772,
1641,
15989,
969,
2322,
11024,
12,
268,
1622,
272,
634,
17,
275,
359,
267,
469,
298,
2052,
582,
715,
12,
881,
298,
3910,
582,
756,
1660,
267,
469,
298,
2052,
582,
399,
2,
549,
401,
881,
298,
3910,
582,
756,
12,
881,
298,
1635,
975,
8,
975,
975,
9,
582,
3193,
975,
1660,
267,
469,
298,
513,
582,
359,
975,
975,
12,
4337,
24356,
708,
12,
715,
12,
446,
24356,
14,
16,
12,
2420,
15064,
582,
549,
12,
298,
19823,
582,
797,
1386,
359,
549,
12,
756,
61,
2156,
881,
298,
442,
708,
582,
24356,
24356,
12,
298,
2245,
582,
715,
12,
23664,
298,
12375,
18661,
582,
399,
2,
11272,
25588,
25588,
11371,
16,
401,
881,
298,
13003,
18661,
582,
399,
2,
21515,
2,
1660,
267,
469,
715,
26,
298,
2052,
401,
26309,
26,
756,
12,
298,
3910,
582,
1926,
789,
267,
1622,
2286,
634,
275,
942,
272,
634,
14,
2880,
8,
76,
16,
9,
272,
634,
14,
740,
8,
76,
16,
9,
272,
634,
14,
740,
8,
17,
9,
272,
634,
14,
2880,
8,
76,
17,
9,
272,
372,
634,
199,
199,
318,
1900,
63,
396,
63,
576,
8,
32669,
304,
272,
634,
275,
664,
63,
396,
63,
576,
63,
513,
342,
272,
367,
284,
315,
1425,
8,
552,
8,
76,
2298,
267,
327,
1706,
281,
275,
26635,
14,
2305,
281,
342,
267,
6380,
275,
26635,
14,
4180,
8,
76,
59,
73,
566,
267,
289,
275,
1551,
8,
736,
14,
515,
14,
904,
8,
32669,
12,
620,
8,
73,
9,
435,
1987,
1328,
1389,
14,
19440,
659,
283,
6603,
358,
267,
289,
14,
952,
8,
8397,
9,
267,
289,
14,
1600,
342,
267,
6380,
275,
7434,
269,
14,
4180,
8,
76,
59,
73,
566,
267,
289,
275,
1551,
8,
736,
14,
515,
14,
904,
8,
32669,
12,
620,
8,
73,
9,
435,
1987,
2894,
269,
14,
19440,
659,
283,
6603,
358,
267,
289,
14,
952,
8,
8397,
9,
267,
289,
14,
1600,
342,
199,
199,
318,
886,
30980,
8,
719,
12,
3631,
1366,
4933,
304,
272,
1021,
24980,
2461,
8,
785,
304,
267,
347,
24980,
4288,
8,
277,
12,
1499,
17,
12,
1499,
18,
12,
1499,
19,
304,
288,
372,
1689,
17,
2689,
83,
499,
2689,
83,
650,
2689,
83,
2,
450,
334,
1328,
17,
12,
1499,
18,
12,
1499,
19,
430,
267,
347,
24980,
4836,
8,
277,
12,
1499,
304,
288,
372,
19426,
83,
2,
450,
1499,
9,
2286,
5552,
275,
26635,
4354,
14,
1476,
360,
5967,
297,
1844,
9,
272,
1654,
275,
26635,
4354,
14,
3120,
8,
18690,
2461,
1012,
272,
1654,
14,
5859,
8,
2697,
9,
272,
327,
1255,
2462,
370,
3631,
652,
2410,
3631,
1366,
4933,
4696,
340,
690,
378,
272,
340,
3631,
1366,
4933,
690,
378,
26,
267,
347,
3002,
6293,
30980,
837,
288,
1654,
14,
2379,
342,
267,
307,
275,
5796,
14,
7929,
8,
2379,
1366,
4933,
12,
3002,
6293,
30980,
9,
267,
307,
14,
928,
342,
272,
1654,
14,
928,
342,
199,
199,
318,
886,
15569,
3041,
1378,
4718,
51,
6737,
8,
719,
304,
272,
2287,
275,
26635,
4354,
14,
1476,
360,
5967,
297,
1844,
9,
272,
1890,
275,
26635,
4354,
14,
3041,
8,
1562,
12,
7787,
63,
2991,
534,
1624,
13,
24,
358,
272,
870,
1890,
14,
1250,
480,
18690,
4288,
401,
298,
33,
17,
401,
298,
34,
18,
401,
298,
35,
19,
531,
272,
870,
1890,
14,
1250,
480,
18690,
4836,
401,
2420,
33,
2,
26673,
33,
65,
401,
298,
34,
5122,
30814,
401,
298,
35,
5122,
21426,
5984,
272,
199,
318,
886,
15569,
3041,
1378,
7250,
51,
6737,
8,
719,
304,
272,
327,
870,
298,
28375,
1844,
26,
3872,
1844,
12,
298,
5213,
8999,
28,
2,
272,
2287,
275,
26635,
4354,
14,
1476,
360,
5967,
297,
1844,
9,
272,
1890,
275,
26635,
4354,
14,
3041,
8,
1562,
12,
7787,
63,
2991,
534,
1624,
13,
24,
358,
272,
870,
1890,
14,
1250,
480,
774,
15569,
3241,
14,
18690,
4288,
401,
2097,
33,
17,
401,
298,
34,
18,
401,
298,
35,
19,
3135,
272,
870,
1890,
14,
1250,
480,
774,
15569,
3241,
14,
18690,
4836,
401,
2420,
33,
2,
26673,
33,
65,
401,
298,
34,
5122,
30814,
401,
298,
35,
5122,
21426,
5984,
199,
199,
318,
886,
6756,
8,
589,
304,
272,
340
] |
[
2647,
15,
1393,
15,
1813,
2366,
199,
199,
3,
961,
911,
1218,
17631,
1584,
315,
282,
2082,
3032,
370,
652,
14,
199,
3,
437,
1379,
4882,
642,
14448,
370,
1218,
314,
17631,
1584,
199,
3,
2002,
652,
883,
2112,
3062,
334,
1152,
781,
2793,
1133,
1172,
370,
1104,
262,
314,
1584,
680,
199,
199,
3,
7523,
26635,
13,
1548,
436,
7434,
269,
787,
4903,
1642,
12,
1808,
26,
199,
3,
257,
14682,
20932,
13,
362,
3907,
2366,
13,
2374,
199,
3,
257,
14682,
20932,
13,
362,
3907,
2366,
13,
9983,
199,
3,
257,
7305,
3907,
1553,
751,
26635,
13,
1548,
26635,
13,
4354,
13,
1548,
7434,
269,
199,
199,
3,
7523,
1006,
298,
875,
2,
2883,
787,
2774,
3326,
334,
2836,
5737,
465,
2783,
9,
199,
199,
646,
7434,
269,
12,
26635,
12,
26635,
4354,
12,
984,
12,
747,
12,
5796,
199,
199,
318,
664,
63,
396,
63,
576,
63,
513,
837,
272,
327,
664,
769,
543,
1006,
18944,
2943,
12,
436,
282,
20972,
730,
272,
634,
16,
275,
359,
4960,
446,
24,
12,
268,
446,
975,
975,
12,
268,
446,
24356,
24356,
12,
268,
446,
21336,
21336,
21336,
21336,
12,
268,
13567,
12,
268,
3193,
975,
12,
268,
4337,
24356,
708,
12,
268,
5049,
21336,
21336,
21336,
772,
12,
268,
13567,
12,
268,
446,
24356,
14,
16,
12,
268,
446,
21336,
21336,
772,
14,
16,
12,
268,
4337,
708,
14,
16,
12,
268,
5049,
772,
14,
16,
12,
268,
5049,
21336,
21336,
14,
16,
12,
268,
756,
12,
268,
715,
12,
268,
399,
2,
2307,
401,
268,
488,
12,
268,
399,
2,
3972,
2977,
401,
268,
413,
12870,
1196,
1876,
1081,
993,
996,
1493,
12,
268,
399,
5151,
268,
446,
1081,
1690,
1085,
2277,
1138,
5008,
2905,
1493,
12,
268,
399,
2,
991,
396,
5985,
401,
268,
27632,
12,
268,
399,
2,
3592,
401,
267,
446,
1797,
1703,
1229,
15883,
5008,
2720,
11956,
12,
268,
327,
13,
18450,
2481,
772,
1641,
15989,
969,
2322,
11024,
12,
268,
1622,
272,
634,
17,
275,
359,
267,
469,
298,
2052,
582,
715,
12,
881,
298,
3910,
582,
756,
1660,
267,
469,
298,
2052,
582,
399,
2,
549,
401,
881,
298,
3910,
582,
756,
12,
881,
298,
1635,
975,
8,
975,
975,
9,
582,
3193,
975,
1660,
267,
469,
298,
513,
582,
359,
975,
975,
12,
4337,
24356,
708,
12,
715,
12,
446,
24356,
14,
16,
12,
2420,
15064,
582,
549,
12,
298,
19823,
582,
797,
1386,
359,
549,
12,
756,
61,
2156,
881,
298,
442,
708,
582,
24356,
24356,
12,
298,
2245,
582,
715,
12,
23664,
298,
12375,
18661,
582,
399,
2,
11272,
25588,
25588,
11371,
16,
401,
881,
298,
13003,
18661,
582,
399,
2,
21515,
2,
1660,
267,
469,
715,
26,
298,
2052,
401,
26309,
26,
756,
12,
298,
3910,
582,
1926,
789,
267,
1622,
2286,
634,
275,
942,
272,
634,
14,
2880,
8,
76,
16,
9,
272,
634,
14,
740,
8,
76,
16,
9,
272,
634,
14,
740,
8,
17,
9,
272,
634,
14,
2880,
8,
76,
17,
9,
272,
372,
634,
199,
199,
318,
1900,
63,
396,
63,
576,
8,
32669,
304,
272,
634,
275,
664,
63,
396,
63,
576,
63,
513,
342,
272,
367,
284,
315,
1425,
8,
552,
8,
76,
2298,
267,
327,
1706,
281,
275,
26635,
14,
2305,
281,
342,
267,
6380,
275,
26635,
14,
4180,
8,
76,
59,
73,
566,
267,
289,
275,
1551,
8,
736,
14,
515,
14,
904,
8,
32669,
12,
620,
8,
73,
9,
435,
1987,
1328,
1389,
14,
19440,
659,
283,
6603,
358,
267,
289,
14,
952,
8,
8397,
9,
267,
289,
14,
1600,
342,
267,
6380,
275,
7434,
269,
14,
4180,
8,
76,
59,
73,
566,
267,
289,
275,
1551,
8,
736,
14,
515,
14,
904,
8,
32669,
12,
620,
8,
73,
9,
435,
1987,
2894,
269,
14,
19440,
659,
283,
6603,
358,
267,
289,
14,
952,
8,
8397,
9,
267,
289,
14,
1600,
342,
199,
199,
318,
886,
30980,
8,
719,
12,
3631,
1366,
4933,
304,
272,
1021,
24980,
2461,
8,
785,
304,
267,
347,
24980,
4288,
8,
277,
12,
1499,
17,
12,
1499,
18,
12,
1499,
19,
304,
288,
372,
1689,
17,
2689,
83,
499,
2689,
83,
650,
2689,
83,
2,
450,
334,
1328,
17,
12,
1499,
18,
12,
1499,
19,
430,
267,
347,
24980,
4836,
8,
277,
12,
1499,
304,
288,
372,
19426,
83,
2,
450,
1499,
9,
2286,
5552,
275,
26635,
4354,
14,
1476,
360,
5967,
297,
1844,
9,
272,
1654,
275,
26635,
4354,
14,
3120,
8,
18690,
2461,
1012,
272,
1654,
14,
5859,
8,
2697,
9,
272,
327,
1255,
2462,
370,
3631,
652,
2410,
3631,
1366,
4933,
4696,
340,
690,
378,
272,
340,
3631,
1366,
4933,
690,
378,
26,
267,
347,
3002,
6293,
30980,
837,
288,
1654,
14,
2379,
342,
267,
307,
275,
5796,
14,
7929,
8,
2379,
1366,
4933,
12,
3002,
6293,
30980,
9,
267,
307,
14,
928,
342,
272,
1654,
14,
928,
342,
199,
199,
318,
886,
15569,
3041,
1378,
4718,
51,
6737,
8,
719,
304,
272,
2287,
275,
26635,
4354,
14,
1476,
360,
5967,
297,
1844,
9,
272,
1890,
275,
26635,
4354,
14,
3041,
8,
1562,
12,
7787,
63,
2991,
534,
1624,
13,
24,
358,
272,
870,
1890,
14,
1250,
480,
18690,
4288,
401,
298,
33,
17,
401,
298,
34,
18,
401,
298,
35,
19,
531,
272,
870,
1890,
14,
1250,
480,
18690,
4836,
401,
2420,
33,
2,
26673,
33,
65,
401,
298,
34,
5122,
30814,
401,
298,
35,
5122,
21426,
5984,
272,
199,
318,
886,
15569,
3041,
1378,
7250,
51,
6737,
8,
719,
304,
272,
327,
870,
298,
28375,
1844,
26,
3872,
1844,
12,
298,
5213,
8999,
28,
2,
272,
2287,
275,
26635,
4354,
14,
1476,
360,
5967,
297,
1844,
9,
272,
1890,
275,
26635,
4354,
14,
3041,
8,
1562,
12,
7787,
63,
2991,
534,
1624,
13,
24,
358,
272,
870,
1890,
14,
1250,
480,
774,
15569,
3241,
14,
18690,
4288,
401,
2097,
33,
17,
401,
298,
34,
18,
401,
298,
35,
19,
3135,
272,
870,
1890,
14,
1250,
480,
774,
15569,
3241,
14,
18690,
4836,
401,
2420,
33,
2,
26673,
33,
65,
401,
298,
34,
5122,
30814,
401,
298,
35,
5122,
21426,
5984,
199,
199,
318,
886,
6756,
8,
589,
304,
272,
340,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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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
] |
acbodine/koding
|
go/src/vendor/github.com/caglar10ur/lxc/config/yum/lxc-patch.py
|
64
|
1870
|
# Yum plugin to re-patch container rootfs after a yum update is done
#
# Copyright (C) 2012 Oracle
#
# Authors:
# Dwight Engen <dwight.engen@oracle.com>
#
# 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 Street, Fifth Floor, Boston, MA 02110-1301
# USA
#
import os
from fnmatch import fnmatch
from yum.plugins import TYPE_INTERACTIVE
from yum.plugins import PluginYumExit
requires_api_version = '2.0'
plugin_type = (TYPE_INTERACTIVE,)
def posttrans_hook(conduit):
pkgs = []
patch_required = False
# If we aren't root, we can't have updated anything
if os.geteuid():
return
# See what packages have files that were patched
confpkgs = conduit.confString('main', 'packages')
if not confpkgs:
return
tmp = confpkgs.split(",")
for confpkg in tmp:
pkgs.append(confpkg.strip())
conduit.info(2, "lxc-patch: checking if updated pkgs need patching...")
ts = conduit.getTsInfo()
for tsmem in ts.getMembers():
for pkg in pkgs:
if fnmatch(pkg, tsmem.po.name):
patch_required = True
if patch_required:
conduit.info(2, "lxc-patch: patching container...")
os.spawnlp(os.P_WAIT, "lxc-patch", "lxc-patch", "--patch", "/")
|
agpl-3.0
|
[
3,
1488,
453,
3589,
370,
295,
13,
2068,
3970,
1738,
2319,
2410,
282,
24717,
1678,
365,
4224,
199,
3,
199,
3,
1898,
334,
35,
9,
6029,
15309,
199,
3,
199,
3,
6642,
26,
199,
3,
577,
87,
1070,
3447,
2268,
665,
10772,
1070,
14,
287,
2268,
32,
16404,
14,
957,
30,
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,
14259,
12,
12066,
11844,
12,
8226,
12,
4828,
221,
11315,
13,
10067,
199,
3,
8217,
199,
3,
199,
199,
646,
747,
199,
504,
15951,
492,
15951,
199,
504,
24717,
14,
5265,
492,
11511,
63,
3843,
10401,
199,
504,
24717,
14,
5265,
492,
11349,
57,
453,
6699,
199,
199,
6537,
63,
1246,
63,
1023,
275,
283,
18,
14,
16,
7,
199,
2718,
63,
466,
275,
334,
2711,
63,
3843,
10401,
4258,
199,
199,
318,
2963,
1515,
63,
3664,
8,
388,
2033,
390,
304,
272,
24162,
275,
942,
272,
3371,
63,
2427,
275,
756,
339,
327,
982,
781,
10621,
1133,
1738,
12,
781,
883,
1133,
1172,
4588,
7003,
272,
340,
747,
14,
31508,
1535,
837,
267,
372,
339,
327,
1666,
4052,
6117,
1172,
1584,
626,
4898,
19483,
272,
3743,
16624,
275,
406,
2033,
390,
14,
2190,
1558,
360,
973,
297,
283,
5154,
358,
272,
340,
440,
3743,
16624,
26,
267,
372,
339,
3529,
275,
3743,
16624,
14,
1294,
20324,
272,
367,
3743,
4600,
315,
3529,
26,
267,
24162,
14,
740,
8,
2190,
4600,
14,
1913,
1012,
339,
406,
2033,
390,
14,
815,
8,
18,
12,
298,
29357,
13,
2068,
26,
7907,
340,
4588,
24162,
1929,
3371,
316,
12594,
272,
6714,
275,
406,
2033,
390,
14,
362,
23433,
2354,
342,
272,
367,
6714,
5286,
315,
6714,
14,
362,
23056,
837,
267,
367,
5496,
315,
24162,
26,
288,
340,
15951,
8,
4600,
12,
6714,
5286,
14,
555,
14,
354,
304,
355,
3371,
63,
2427,
275,
715,
272,
340,
3371,
63,
2427,
26,
267,
406,
2033,
390,
14,
815,
8,
18,
12,
298,
29357,
13,
2068,
26,
3371,
316,
3970,
12594,
267,
747,
14,
10212,
10343,
8,
736,
14,
48,
63,
12458,
12,
298,
29357,
13,
2068,
401,
298,
29357,
13,
2068,
401,
4320,
2068,
401,
3286,
531,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
1488,
453,
3589,
370,
295,
13,
2068,
3970,
1738,
2319,
2410,
282,
24717,
1678,
365,
4224,
199,
3,
199,
3,
1898,
334,
35,
9,
6029,
15309,
199,
3,
199,
3,
6642,
26,
199,
3,
577,
87,
1070,
3447,
2268,
665,
10772,
1070,
14,
287,
2268,
32,
16404,
14,
957,
30,
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,
14259,
12,
12066,
11844,
12,
8226,
12,
4828,
221,
11315,
13,
10067,
199,
3,
8217,
199,
3,
199,
199,
646,
747,
199,
504,
15951,
492,
15951,
199,
504,
24717,
14,
5265,
492,
11511,
63,
3843,
10401,
199,
504,
24717,
14,
5265,
492,
11349,
57,
453,
6699,
199,
199,
6537,
63,
1246,
63,
1023,
275,
283,
18,
14,
16,
7,
199,
2718,
63,
466,
275,
334,
2711,
63,
3843,
10401,
4258,
199,
199,
318,
2963,
1515,
63,
3664,
8,
388,
2033,
390,
304,
272,
24162,
275,
942,
272,
3371,
63,
2427,
275,
756,
339,
327,
982,
781,
10621,
1133,
1738,
12,
781,
883,
1133,
1172,
4588,
7003,
272,
340,
747,
14,
31508,
1535,
837,
267,
372,
339,
327,
1666,
4052,
6117,
1172,
1584,
626,
4898,
19483,
272,
3743,
16624,
275,
406,
2033,
390,
14,
2190,
1558,
360,
973,
297,
283,
5154,
358,
272,
340,
440,
3743,
16624,
26,
267,
372,
339,
3529,
275,
3743,
16624,
14,
1294,
20324,
272,
367,
3743,
4600,
315,
3529,
26,
267,
24162,
14,
740,
8,
2190,
4600,
14,
1913,
1012,
339,
406,
2033,
390,
14,
815,
8,
18,
12,
298,
29357,
13,
2068,
26,
7907,
340,
4588,
24162,
1929,
3371,
316,
12594,
272,
6714,
275,
406,
2033,
390,
14,
362,
23433,
2354,
342,
272,
367,
6714,
5286,
315,
6714,
14,
362,
23056,
837,
267,
367,
5496,
315,
24162,
26,
288,
340,
15951,
8,
4600,
12,
6714,
5286,
14,
555,
14,
354,
304,
355,
3371,
63,
2427,
275,
715,
272,
340,
3371,
63,
2427,
26,
267,
406,
2033,
390,
14,
815,
8,
18,
12,
298,
29357,
13,
2068,
26,
3371,
316,
3970,
12594,
267,
747,
14,
10212,
10343,
8,
736,
14,
48,
63,
12458,
12,
298,
29357,
13,
2068,
401,
298,
29357,
13,
2068,
401,
4320,
2068,
401,
3286,
531,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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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.
# ==============================================================================
"""Contains a factory for building various models."""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import tensorflow as tf
from preprocessing import cifarnet_preprocessing
from preprocessing import inception_preprocessing
from preprocessing import lenet_preprocessing
from preprocessing import vgg_preprocessing
slim = tf.contrib.slim
def get_preprocessing(name, is_training=False):
"""Returns preprocessing_fn(image, height, width, **kwargs).
Args:
name: The name of the preprocessing function.
is_training: `True` if the model is being used for training and `False`
otherwise.
Returns:
preprocessing_fn: A function that preprocessing a single image (pre-batch).
It has the following signature:
image = preprocessing_fn(image, output_height, output_width, ...).
Raises:
ValueError: If Preprocessing `name` is not recognized.
"""
preprocessing_fn_map = {
'cifarnet': cifarnet_preprocessing,
'inception': inception_preprocessing,
'inception_v1': inception_preprocessing,
'inception_v2': inception_preprocessing,
'inception_v3': inception_preprocessing,
'inception_v4': inception_preprocessing,
'inception_resnet_v2': inception_preprocessing,
'lenet': lenet_preprocessing,
'resnet_v1_50': vgg_preprocessing,
'resnet_v1_101': vgg_preprocessing,
'resnet_v1_152': vgg_preprocessing,
'resnet_v2_50': vgg_preprocessing,
'resnet_v2_101': vgg_preprocessing,
'resnet_v2_152': vgg_preprocessing,
'vgg': vgg_preprocessing,
'vgg_a': vgg_preprocessing,
'vgg_16': vgg_preprocessing,
'vgg_19': vgg_preprocessing,
}
if name not in preprocessing_fn_map:
raise ValueError('Preprocessing name [%s] was not recognized' % name)
def preprocessing_fn(image, output_height, output_width, **kwargs):
return preprocessing_fn_map[name].preprocess_image(
image, output_height, output_width, is_training=is_training, **kwargs)
return preprocessing_fn
|
apache-2.0
|
[
3,
1898,
7800,
710,
9134,
6642,
14,
2900,
5924,
5702,
14,
199,
3,
199,
3,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
199,
3,
1265,
1443,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
199,
3,
2047,
1443,
3332,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
199,
3,
2428,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
199,
3,
1666,
314,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
199,
3,
4204,
1334,
314,
844,
14,
199,
3,
11148,
199,
624,
6906,
282,
6434,
367,
10015,
7750,
1709,
1041,
199,
199,
504,
636,
2443,
363,
492,
3679,
63,
646,
199,
504,
636,
2443,
363,
492,
4629,
199,
504,
636,
2443,
363,
492,
870,
63,
1593,
199,
199,
646,
3228,
465,
2833,
199,
199,
504,
26471,
492,
286,
692,
285,
846,
63,
21402,
199,
504,
26471,
492,
315,
814,
63,
21402,
199,
504,
26471,
492,
822,
386,
63,
21402,
199,
504,
26471,
492,
373,
2721,
63,
21402,
199,
199,
30393,
275,
2833,
14,
2828,
14,
30393,
421,
199,
318,
664,
63,
21402,
8,
354,
12,
365,
63,
7588,
29,
797,
304,
523,
408,
3407,
26471,
63,
2324,
8,
1569,
12,
4569,
12,
3462,
12,
1011,
958,
680,
819,
3033,
26,
272,
536,
26,
710,
536,
402,
314,
26471,
805,
14,
272,
365,
63,
7588,
26,
658,
549,
64,
340,
314,
1402,
365,
3769,
1202,
367,
6093,
436,
658,
797,
64,
489,
4257,
14,
819,
1803,
26,
272,
26471,
63,
2324,
26,
437,
805,
626,
26471,
282,
2849,
1834,
334,
657,
13,
2912,
680,
489,
2779,
965,
314,
2569,
4955,
26,
267,
1834,
275,
26471,
63,
2324,
8,
1569,
12,
1072,
63,
3333,
12,
1072,
63,
2063,
12,
2263,
680,
819,
6218,
26,
272,
1722,
26,
982,
5543,
6338,
658,
354,
64,
365,
440,
18054,
14,
523,
408,
523,
26471,
63,
2324,
63,
1130,
275,
469,
489,
283,
559,
15315,
846,
356,
286,
692,
285,
846,
63,
21402,
12,
489,
283,
262,
814,
356,
315,
814,
63,
21402,
12,
489,
283,
262,
814,
63,
86,
17,
356,
315,
814,
63,
21402,
12,
489,
283,
262,
814,
63,
86,
18,
356,
315,
814,
63,
21402,
12,
489,
283,
262,
814,
63,
86,
19,
356,
315,
814,
63,
21402,
12,
489,
283,
262,
814,
63,
86,
20,
356,
315,
814,
63,
21402,
12,
489,
283,
262,
814,
63,
28998,
63,
86,
18,
356,
315,
814,
63,
21402,
12,
489,
283,
552,
386,
356,
822,
386,
63,
21402,
12,
489,
283,
28998,
63,
86,
17,
63,
1400,
356,
373,
2721,
63,
21402,
12,
489,
283,
28998,
63,
86,
17,
63,
4893,
356,
373,
2721,
63,
21402,
12,
489,
283,
28998,
63,
86,
17,
63,
11024,
356,
373,
2721,
63,
21402,
12,
489,
283,
28998,
63,
86,
18,
63,
1400,
356,
373,
2721,
63,
21402,
12,
489,
283,
28998,
63,
86,
18,
63,
4893,
356,
373,
2721,
63,
21402,
12,
489,
283,
28998,
63,
86,
18,
63,
11024,
356,
373,
2721,
63,
21402,
12,
489,
283,
27948,
356,
373,
2721,
63,
21402,
12,
489,
283,
27948,
63,
65,
356,
373,
2721,
63,
21402,
12,
489,
283,
27948,
63,
975,
356,
373,
2721,
63,
21402,
12,
489,
283,
27948,
63,
1167,
356,
373,
2721,
63,
21402,
12,
523,
789,
819,
340,
536,
440,
315,
26471,
63,
2324,
63,
1130,
26,
272,
746,
1722,
360,
2398,
6338,
536,
8978,
83,
61,
1990,
440,
18054,
7,
450,
536,
9,
819,
347,
26471,
63,
2324,
8,
1569,
12,
1072,
63,
3333,
12,
1072,
63,
2063,
12,
1011,
958,
304,
272,
372,
26471,
63,
2324,
63,
1130,
59,
354,
1055,
17677,
63,
1569,
8,
267,
1834,
12,
1072,
63,
3333,
12,
1072,
63,
2063,
12,
365,
63,
7588,
29,
374,
63,
7588,
12,
1011,
958,
9,
819,
372,
26471,
63,
2324,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
1898,
7800,
710,
9134,
6642,
14,
2900,
5924,
5702,
14,
199,
3,
199,
3,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
199,
3,
1265,
1443,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
199,
3,
2047,
1443,
3332,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
199,
3,
2428,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
199,
3,
1666,
314,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
199,
3,
4204,
1334,
314,
844,
14,
199,
3,
11148,
199,
624,
6906,
282,
6434,
367,
10015,
7750,
1709,
1041,
199,
199,
504,
636,
2443,
363,
492,
3679,
63,
646,
199,
504,
636,
2443,
363,
492,
4629,
199,
504,
636,
2443,
363,
492,
870,
63,
1593,
199,
199,
646,
3228,
465,
2833,
199,
199,
504,
26471,
492,
286,
692,
285,
846,
63,
21402,
199,
504,
26471,
492,
315,
814,
63,
21402,
199,
504,
26471,
492,
822,
386,
63,
21402,
199,
504,
26471,
492,
373,
2721,
63,
21402,
199,
199,
30393,
275,
2833,
14,
2828,
14,
30393,
421,
199,
318,
664,
63,
21402,
8,
354,
12,
365,
63,
7588,
29,
797,
304,
523,
408,
3407,
26471,
63,
2324,
8,
1569,
12,
4569,
12,
3462,
12,
1011,
958,
680,
819,
3033,
26,
272,
536,
26,
710,
536,
402,
314,
26471,
805,
14,
272,
365,
63,
7588,
26,
658,
549,
64,
340,
314,
1402,
365,
3769,
1202,
367,
6093,
436,
658,
797,
64,
489,
4257,
14,
819,
1803,
26,
272,
26471,
63,
2324,
26,
437,
805,
626,
26471,
282,
2849,
1834,
334,
657,
13,
2912,
680,
489,
2779,
965,
314,
2569,
4955,
26,
267,
1834,
275,
26471,
63,
2324,
8,
1569,
12,
1072,
63,
3333,
12,
1072,
63,
2063,
12,
2263,
680,
819,
6218,
26,
272,
1722,
26,
982,
5543,
6338,
658,
354,
64,
365,
440,
18054,
14,
523,
408,
523,
26471,
63,
2324,
63,
1130,
275,
469,
489,
283,
559,
15315,
846,
356,
286,
692,
285,
846,
63,
21402,
12,
489,
283,
262,
814,
356,
315,
814,
63,
21402,
12,
489,
283,
262,
814,
63,
86,
17,
356,
315,
814,
63,
21402,
12,
489,
283,
262,
814,
63,
86,
18,
356,
315,
814,
63,
21402,
12,
489,
283,
262,
814,
63,
86,
19,
356,
315,
814,
63,
21402,
12,
489,
283,
262,
814,
63,
86,
20,
356,
315,
814,
63,
21402,
12,
489,
283,
262,
814,
63,
28998,
63,
86,
18,
356,
315,
814,
63,
21402,
12,
489,
283,
552,
386,
356,
822,
386,
63,
21402,
12,
489,
283,
28998,
63,
86,
17,
63,
1400,
356,
373,
2721,
63,
21402,
12,
489,
283,
28998,
63,
86,
17,
63,
4893,
356,
373,
2721,
63,
21402,
12,
489,
283,
28998,
63,
86,
17,
63,
11024,
356,
373,
2721,
63,
21402,
12,
489,
283,
28998,
63,
86,
18,
63,
1400,
356,
373,
2721,
63,
21402,
12,
489,
283,
28998,
63,
86,
18,
63,
4893,
356,
373,
2721,
63,
21402,
12,
489,
283,
28998,
63,
86,
18,
63,
11024,
356,
373,
2721,
63,
21402,
12,
489,
283,
27948,
356,
373,
2721,
63,
21402,
12,
489,
283,
27948,
63,
65,
356,
373,
2721,
63,
21402,
12,
489,
283,
27948,
63,
975,
356,
373,
2721,
63,
21402,
12,
489,
283,
27948,
63,
1167,
356,
373,
2721,
63,
21402,
12,
523,
789,
819,
340,
536,
440,
315,
26471,
63,
2324,
63,
1130,
26,
272,
746,
1722,
360,
2398,
6338,
536,
8978,
83,
61,
1990,
440,
18054,
7,
450,
536,
9,
819,
347,
26471,
63,
2324,
8,
1569,
12,
1072,
63,
3333,
12,
1072,
63,
2063,
12,
1011,
958,
304,
272,
372,
26471,
63,
2324,
63,
1130,
59,
354,
1055,
17677,
63,
1569,
8,
267,
1834,
12,
1072,
63,
3333,
12,
1072,
63,
2063,
12,
365,
63,
7588,
29,
374,
63,
7588,
12,
1011,
958,
9,
819,
372,
26471,
63,
2324,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
jbaayen/sympy
|
sympy/logic/boolalg.py
|
1
|
7565
|
"""Boolean algebra module for SymPy"""
from sympy.core import Basic, Function, sympify, Symbol
from sympy.utilities import flatten
class BooleanFunction(Function):
"""Boolean function is a function that lives in a boolean space
It is used as base class for And, Or, Not, etc.
"""
pass
class And(BooleanFunction):
"""Logical AND function.
It evaluates its arguments in order, giving False immediately if any of them
are False, and True if they are all True.
Examples:
>>> from sympy import *
>>> x, y = symbols('xy')
>>> x & y
And(x, y)
"""
@classmethod
def eval(cls, *args):
out_args = []
for arg in args: # we iterate over a copy or args
if isinstance(arg, bool):
if not arg: return False
else: continue
out_args.append(arg)
if len(out_args) == 0: return True
if len(out_args) == 1: return out_args[0]
sargs = sorted(flatten(out_args, cls=cls))
return Basic.__new__(cls, *sargs)
class Or(BooleanFunction):
"""Logical OR function
It evaluates its arguments in order, giving True immediately if any of them are
True, and False if they are all False.
"""
@classmethod
def eval(cls, *args):
out_args = []
for arg in args: # we iterate over a copy or args
if isinstance(arg, bool):
if arg: return True
else: continue
out_args.append(arg)
if len(out_args) == 0: return False
if len(out_args) == 1: return out_args[0]
sargs = sorted(flatten(out_args, cls=cls))
return Basic.__new__(cls, *sargs)
class Xor(BooleanFunction):
"""Logical XOR (exclusive OR) function.
returns True if an odd number of the arguments are True, and the rest are False.
returns False if an even number of the arguments are True, and the rest are False.
"""
@classmethod
def eval(cls, *args):
if not args: return False
args = list(args)
A = args.pop()
while args:
B = args.pop()
A = Or(A & Not(B), (Not(A) & B))
return A
class Not(BooleanFunction):
"""Logical Not function (negation)
Note: De Morgan rules applied automatically"""
@classmethod
def eval(cls, *args):
if len(args) > 1:
return map(cls, args)
arg = args[0]
# apply De Morgan Rules
if type(arg) is And:
return Or(*[Not(a) for a in arg.args])
if type(arg) is Or:
return And(*[Not(a) for a in arg.args])
if type(arg) is bool: return not arg
if type(arg) is Not:
return arg.args[0]
class Nand(BooleanFunction):
"""Logical NAND function.
It evaluates its arguments in order, giving True immediately if any
of them are False, and False if they are all True.
"""
@classmethod
def eval(cls, *args):
if not args: return False
args = list(args)
A = Not(args.pop())
while args:
B = args.pop()
A = Or(A, Not(B))
return A
class Nor(BooleanFunction):
"""Logical NOR function.
It evaluates its arguments in order, giving False immediately if any
of them are True, and True if they are all False.
"""
@classmethod
def eval(cls, *args):
if not args: return False
args = list(args)
A = Not(args.pop())
while args:
B = args.pop()
A = And(A, Not(B))
return A
class Implies(BooleanFunction):
pass
class Equivalent(BooleanFunction):
"""Equivalence relation.
Equivalent(A, B) is True if and only if A and B are both True or both False
"""
@classmethod
def eval(cls, *args):
return Basic.__new__(cls, *sorted(args))
### end class definitions. Some useful methods
def fuzzy_not(arg):
"""
Not in fuzzy logic
will return Not if arg is a boolean value, and None if argument
is None
>>> from sympy import *
>>> fuzzy_not(True)
False
>>> fuzzy_not(None)
>>> fuzzy_not(False)
True
"""
if arg is None: return
return not arg
def conjuncts(expr):
"""Return a list of the conjuncts in the expr s.
>>> from sympy import symbols
>>> A, B = symbols('AB')
>>> conjuncts(A & B)
[A, B]
>>> conjuncts(A | B)
[Or(A, B)]
"""
if expr:
if type(expr) is And:
return list(expr.args)
return [expr]
return []
def disjuncts(expr):
"""Return a list of the disjuncts in the sentence s.
>>> from sympy import symbols
>>> A, B = symbols('AB')
>>> disjuncts(A | B)
[A, B]
>>> disjuncts(A & B)
[And(A, B)]
"""
if isinstance(expr, Or):
return list(expr.args)
else:
return [expr]
def distribute_and_over_or(expr):
"""
Given a sentence s consisting of conjunctions and disjunctions
of literals, return an equivalent sentence in CNF.
"""
if isinstance(expr, Or):
for arg in expr.args:
if isinstance(arg, And):
conj = arg
break
else: return type(expr)(*expr.args)
rest = Or(*[a for a in expr.args if a is not conj])
return And(*map(distribute_and_over_or,
[Or(c, rest) for c in conj.args]))
elif isinstance(expr, And):
return And(*map(distribute_and_over_or, expr.args))
else:
return expr
def to_cnf(expr):
"""Convert a propositional logical sentence s to conjunctive normal form.
That is, of the form ((A | ~B | ...) & (B | C | ...) & ...)
Examples:
>>> from sympy import symbols
>>> A, B, C = symbols('A B C')
>>> to_cnf(~(A | B) | C)
And(Or(C, Not(A)), Or(C, Not(B)))
"""
expr = sympify(expr)
expr = eliminate_implications(expr)
return distribute_and_over_or(expr)
def eliminate_implications(expr):
"""Change >>, <<, and Equivalent into &, |, and ~. That is, return an
expression that is equivalent to s, but has only &, |, and ~ as logical
operators.
"""
expr = sympify(expr)
if expr.is_Atom: return expr ## (Atoms are unchanged.)
args = map(eliminate_implications, expr.args)
a, b = args[0], args[-1]
if isinstance(expr, Implies):
return (~a) | b
elif isinstance(expr, Equivalent):
return (a | Not(b)) & (b | Not(a))
else:
return type(expr)(*args)
def compile_rule(s):
"""Transforms a rule into a sympy expression
A rule is a string of the form "symbol1 & symbol2 | ..."
See sympy.assumptions.known_facts for examples of rules
TODO: can this be replaced by sympify ?
"""
import re
return eval(re.sub(r'([a-zA-Z0-9_.]+)', r'Symbol("\1")', s), {'Symbol' : Symbol})
def to_int_repr(clauses, symbols):
"""
takes clauses in CNF puts them into integer representation
Examples:
>>> from sympy import symbols
>>> x, y = symbols('x y')
>>> to_int_repr([x | y, y], [x, y])
[[1, 2], [2]]
"""
def append_symbol(arg, symbols):
if type(arg) is Not: return -(symbols.index(arg.args[0])+1)
else: return symbols.index(arg)+1
output = []
for c in clauses:
if type(c) is Or:
t = []
for arg in c.args:
t.append(append_symbol(arg, symbols))
output.append(t)
else:
output.append([append_symbol(c, symbols)])
return output
|
bsd-3-clause
|
[
624,
4082,
741,
19355,
859,
367,
21478,
2713,
624,
199,
504,
5840,
14,
1018,
492,
10082,
12,
6801,
12,
25991,
12,
10080,
199,
504,
5840,
14,
16355,
492,
9378,
421,
199,
533,
9411,
3481,
8,
3481,
304,
272,
408,
4082,
805,
365,
282,
805,
626,
27576,
315,
282,
5046,
4601,
272,
2779,
365,
1202,
465,
1300,
1021,
367,
6061,
12,
4236,
12,
2832,
12,
5423,
14,
272,
408,
272,
986,
199,
199,
533,
6061,
8,
4082,
3481,
304,
272,
408,
22455,
2401,
805,
14,
272,
2779,
22014,
2399,
2368,
315,
1865,
12,
15131,
756,
9939,
340,
1263,
402,
3062,
272,
787,
756,
12,
436,
715,
340,
2985,
787,
1006,
715,
14,
339,
6058,
26,
267,
1306,
687,
5840,
492,
627,
267,
1306,
671,
12,
612,
275,
6698,
360,
1702,
358,
267,
1306,
671,
1253,
612,
267,
6061,
8,
88,
12,
612,
9,
272,
408,
272,
768,
3744,
272,
347,
3468,
8,
1886,
12,
627,
589,
304,
267,
734,
63,
589,
275,
942,
267,
367,
1680,
315,
1249,
26,
327,
781,
13974,
1806,
282,
1331,
503,
1249,
288,
340,
1228,
8,
1273,
12,
2155,
304,
355,
340,
440,
1680,
26,
372,
756,
355,
587,
26,
1980,
288,
734,
63,
589,
14,
740,
8,
1273,
9,
267,
340,
822,
8,
548,
63,
589,
9,
508,
378,
26,
372,
715,
267,
340,
822,
8,
548,
63,
589,
9,
508,
413,
26,
372,
734,
63,
589,
59,
16,
61,
267,
308,
589,
275,
3355,
8,
8487,
8,
548,
63,
589,
12,
843,
29,
1886,
430,
267,
372,
10082,
855,
1222,
721,
1886,
12,
627,
83,
589,
9,
199,
199,
533,
4236,
8,
4082,
3481,
304,
272,
408,
22455,
1549,
805,
1362,
2779,
22014,
2399,
2368,
315,
1865,
12,
15131,
715,
9939,
340,
1263,
402,
3062,
787,
1362,
715,
12,
436,
756,
340,
2985,
787,
1006,
756,
14,
1362,
408,
272,
768,
3744,
272,
347,
3468,
8,
1886,
12,
627,
589,
304,
267,
734,
63,
589,
275,
942,
267,
367,
1680,
315,
1249,
26,
327,
781,
13974,
1806,
282,
1331,
503,
1249,
288,
340,
1228,
8,
1273,
12,
2155,
304,
355,
340,
1680,
26,
372,
715,
355,
587,
26,
1980,
288,
734,
63,
589,
14,
740,
8,
1273,
9,
267,
340,
822,
8,
548,
63,
589,
9,
508,
378,
26,
372,
756,
267,
340,
822,
8,
548,
63,
589,
9,
508,
413,
26,
372,
734,
63,
589,
59,
16,
61,
267,
308,
589,
275,
3355,
8,
8487,
8,
548,
63,
589,
12,
843,
29,
1886,
430,
267,
372,
10082,
855,
1222,
721,
1886,
12,
627,
83,
589,
9,
199,
199,
533,
1323,
269,
8,
4082,
3481,
304,
272,
408,
22455,
1323,
726,
334,
12730,
1549,
9,
805,
14,
272,
2529,
715,
340,
376,
16699,
1329,
402,
314,
2368,
787,
715,
12,
436,
314,
4618,
787,
756,
14,
272,
2529,
756,
340,
376,
2755,
1329,
402,
314,
2368,
787,
715,
12,
436,
314,
4618,
787,
756,
14,
272,
408,
272,
768,
3744,
272,
347,
3468,
8,
1886,
12,
627,
589,
304,
267,
340,
440,
1249,
26,
372,
756,
267,
1249,
275,
769,
8,
589,
9,
267,
437,
275,
1249,
14,
1935,
342,
267,
1830,
1249,
26,
288,
699,
275,
1249,
14,
1935,
342,
288,
437,
275,
4236,
8,
33,
1253,
2832,
8,
34,
395,
334,
1763,
8,
33,
9,
1253,
699,
430,
267,
372,
437,
199,
199,
533,
2832,
8,
4082,
3481,
304,
272,
408,
22455,
2832,
805,
334,
685,
5360,
9,
339,
3390,
26,
1487,
603,
19916,
4713,
6781,
5847,
624,
272,
768,
3744,
272,
347,
3468,
8,
1886,
12,
627,
589,
304,
267,
340,
822,
8,
589,
9,
690,
413,
26,
288,
372,
2341,
8,
1886,
12,
1249,
9,
267,
1680,
275,
1249,
59,
16,
61,
267,
327,
4838,
1487,
603,
19916,
24259,
267,
340,
730,
8,
1273,
9,
365,
221,
6061,
26,
288,
372,
4236,
23151,
1763,
8,
65,
9,
367,
282,
315,
1680,
14,
589,
566,
267,
340,
730,
8,
1273,
9,
365,
4236,
26,
288,
372,
6061,
23151,
1763,
8,
65,
9,
367,
282,
315,
1680,
14,
589,
566,
267,
340,
730,
8,
1273,
9,
365,
2155,
26,
372,
440,
1680,
267,
340,
730,
8,
1273,
9,
365,
2832,
26,
288,
372,
1680,
14,
589,
59,
16,
61,
199,
199,
533,
653,
460,
8,
4082,
3481,
304,
272,
408,
22455,
653,
3649,
805,
14,
272,
2779,
22014,
2399,
2368,
315,
1865,
12,
15131,
715,
9939,
340,
1263,
272,
402,
3062,
787,
756,
12,
436,
756,
340,
2985,
787,
1006,
715,
14,
272,
408,
272,
768,
3744,
272,
347,
3468,
8,
1886,
12,
627,
589,
304,
267,
340,
440,
1249,
26,
372,
756,
267,
1249,
275,
769,
8,
589,
9,
267,
437,
275,
2832,
8,
589,
14,
1935,
1012,
267,
1830,
1249,
26,
288,
699,
275,
1249,
14,
1935,
342,
288,
437,
275,
4236,
8,
33,
12,
2832,
8,
34,
430,
267,
372,
437,
199,
199,
533,
653,
269,
8,
4082,
3481,
304,
272,
408,
22455,
653,
726,
805,
14,
272,
2779,
22014,
2399,
2368,
315,
1865,
12,
15131,
756,
9939,
340,
1263,
272,
402,
3062,
787,
715,
12,
436,
715,
340,
2985,
787,
1006,
756,
14,
272,
408,
272,
768,
3744,
272,
347,
3468,
8,
1886,
12,
627,
589,
304,
267,
340,
440,
1249,
26,
372,
756,
267,
1249,
275,
769,
8,
589,
9,
267,
437,
275,
2832,
8,
589,
14,
1935,
1012,
267,
1830,
1249,
26,
288,
699,
275,
1249,
14,
1935,
342,
288,
437,
275,
6061,
8,
33,
12,
2832,
8,
34,
430,
267,
372,
437,
199,
199,
533,
8362,
6528,
8,
4082,
3481,
304,
272,
986,
199,
199,
533,
24228,
8,
4082,
3481,
304,
272,
408,
37,
22810,
5850,
14,
272,
24228,
8,
33,
12,
699,
9,
365,
715,
340,
436,
1454,
340,
437,
436,
699,
787,
3865,
715,
503,
3865,
756,
272,
408,
272,
768,
3744,
272,
347,
3468,
8,
1886,
12,
627,
589,
304,
267,
372,
10082,
855,
1222,
721,
1886,
12,
627,
5917,
8,
589,
430,
199,
199,
5680,
1284,
1021,
10269,
14,
6601,
2997,
3102,
199,
199,
318,
24101,
63,
1397,
8,
1273,
304,
272,
408,
272,
2832,
315,
24101,
9661,
339,
911,
372,
2832,
340,
1680,
365,
282,
5046,
574,
12,
436,
488,
340,
1423,
272,
365
] |
[
4082,
741,
19355,
859,
367,
21478,
2713,
624,
199,
504,
5840,
14,
1018,
492,
10082,
12,
6801,
12,
25991,
12,
10080,
199,
504,
5840,
14,
16355,
492,
9378,
421,
199,
533,
9411,
3481,
8,
3481,
304,
272,
408,
4082,
805,
365,
282,
805,
626,
27576,
315,
282,
5046,
4601,
272,
2779,
365,
1202,
465,
1300,
1021,
367,
6061,
12,
4236,
12,
2832,
12,
5423,
14,
272,
408,
272,
986,
199,
199,
533,
6061,
8,
4082,
3481,
304,
272,
408,
22455,
2401,
805,
14,
272,
2779,
22014,
2399,
2368,
315,
1865,
12,
15131,
756,
9939,
340,
1263,
402,
3062,
272,
787,
756,
12,
436,
715,
340,
2985,
787,
1006,
715,
14,
339,
6058,
26,
267,
1306,
687,
5840,
492,
627,
267,
1306,
671,
12,
612,
275,
6698,
360,
1702,
358,
267,
1306,
671,
1253,
612,
267,
6061,
8,
88,
12,
612,
9,
272,
408,
272,
768,
3744,
272,
347,
3468,
8,
1886,
12,
627,
589,
304,
267,
734,
63,
589,
275,
942,
267,
367,
1680,
315,
1249,
26,
327,
781,
13974,
1806,
282,
1331,
503,
1249,
288,
340,
1228,
8,
1273,
12,
2155,
304,
355,
340,
440,
1680,
26,
372,
756,
355,
587,
26,
1980,
288,
734,
63,
589,
14,
740,
8,
1273,
9,
267,
340,
822,
8,
548,
63,
589,
9,
508,
378,
26,
372,
715,
267,
340,
822,
8,
548,
63,
589,
9,
508,
413,
26,
372,
734,
63,
589,
59,
16,
61,
267,
308,
589,
275,
3355,
8,
8487,
8,
548,
63,
589,
12,
843,
29,
1886,
430,
267,
372,
10082,
855,
1222,
721,
1886,
12,
627,
83,
589,
9,
199,
199,
533,
4236,
8,
4082,
3481,
304,
272,
408,
22455,
1549,
805,
1362,
2779,
22014,
2399,
2368,
315,
1865,
12,
15131,
715,
9939,
340,
1263,
402,
3062,
787,
1362,
715,
12,
436,
756,
340,
2985,
787,
1006,
756,
14,
1362,
408,
272,
768,
3744,
272,
347,
3468,
8,
1886,
12,
627,
589,
304,
267,
734,
63,
589,
275,
942,
267,
367,
1680,
315,
1249,
26,
327,
781,
13974,
1806,
282,
1331,
503,
1249,
288,
340,
1228,
8,
1273,
12,
2155,
304,
355,
340,
1680,
26,
372,
715,
355,
587,
26,
1980,
288,
734,
63,
589,
14,
740,
8,
1273,
9,
267,
340,
822,
8,
548,
63,
589,
9,
508,
378,
26,
372,
756,
267,
340,
822,
8,
548,
63,
589,
9,
508,
413,
26,
372,
734,
63,
589,
59,
16,
61,
267,
308,
589,
275,
3355,
8,
8487,
8,
548,
63,
589,
12,
843,
29,
1886,
430,
267,
372,
10082,
855,
1222,
721,
1886,
12,
627,
83,
589,
9,
199,
199,
533,
1323,
269,
8,
4082,
3481,
304,
272,
408,
22455,
1323,
726,
334,
12730,
1549,
9,
805,
14,
272,
2529,
715,
340,
376,
16699,
1329,
402,
314,
2368,
787,
715,
12,
436,
314,
4618,
787,
756,
14,
272,
2529,
756,
340,
376,
2755,
1329,
402,
314,
2368,
787,
715,
12,
436,
314,
4618,
787,
756,
14,
272,
408,
272,
768,
3744,
272,
347,
3468,
8,
1886,
12,
627,
589,
304,
267,
340,
440,
1249,
26,
372,
756,
267,
1249,
275,
769,
8,
589,
9,
267,
437,
275,
1249,
14,
1935,
342,
267,
1830,
1249,
26,
288,
699,
275,
1249,
14,
1935,
342,
288,
437,
275,
4236,
8,
33,
1253,
2832,
8,
34,
395,
334,
1763,
8,
33,
9,
1253,
699,
430,
267,
372,
437,
199,
199,
533,
2832,
8,
4082,
3481,
304,
272,
408,
22455,
2832,
805,
334,
685,
5360,
9,
339,
3390,
26,
1487,
603,
19916,
4713,
6781,
5847,
624,
272,
768,
3744,
272,
347,
3468,
8,
1886,
12,
627,
589,
304,
267,
340,
822,
8,
589,
9,
690,
413,
26,
288,
372,
2341,
8,
1886,
12,
1249,
9,
267,
1680,
275,
1249,
59,
16,
61,
267,
327,
4838,
1487,
603,
19916,
24259,
267,
340,
730,
8,
1273,
9,
365,
221,
6061,
26,
288,
372,
4236,
23151,
1763,
8,
65,
9,
367,
282,
315,
1680,
14,
589,
566,
267,
340,
730,
8,
1273,
9,
365,
4236,
26,
288,
372,
6061,
23151,
1763,
8,
65,
9,
367,
282,
315,
1680,
14,
589,
566,
267,
340,
730,
8,
1273,
9,
365,
2155,
26,
372,
440,
1680,
267,
340,
730,
8,
1273,
9,
365,
2832,
26,
288,
372,
1680,
14,
589,
59,
16,
61,
199,
199,
533,
653,
460,
8,
4082,
3481,
304,
272,
408,
22455,
653,
3649,
805,
14,
272,
2779,
22014,
2399,
2368,
315,
1865,
12,
15131,
715,
9939,
340,
1263,
272,
402,
3062,
787,
756,
12,
436,
756,
340,
2985,
787,
1006,
715,
14,
272,
408,
272,
768,
3744,
272,
347,
3468,
8,
1886,
12,
627,
589,
304,
267,
340,
440,
1249,
26,
372,
756,
267,
1249,
275,
769,
8,
589,
9,
267,
437,
275,
2832,
8,
589,
14,
1935,
1012,
267,
1830,
1249,
26,
288,
699,
275,
1249,
14,
1935,
342,
288,
437,
275,
4236,
8,
33,
12,
2832,
8,
34,
430,
267,
372,
437,
199,
199,
533,
653,
269,
8,
4082,
3481,
304,
272,
408,
22455,
653,
726,
805,
14,
272,
2779,
22014,
2399,
2368,
315,
1865,
12,
15131,
756,
9939,
340,
1263,
272,
402,
3062,
787,
715,
12,
436,
715,
340,
2985,
787,
1006,
756,
14,
272,
408,
272,
768,
3744,
272,
347,
3468,
8,
1886,
12,
627,
589,
304,
267,
340,
440,
1249,
26,
372,
756,
267,
1249,
275,
769,
8,
589,
9,
267,
437,
275,
2832,
8,
589,
14,
1935,
1012,
267,
1830,
1249,
26,
288,
699,
275,
1249,
14,
1935,
342,
288,
437,
275,
6061,
8,
33,
12,
2832,
8,
34,
430,
267,
372,
437,
199,
199,
533,
8362,
6528,
8,
4082,
3481,
304,
272,
986,
199,
199,
533,
24228,
8,
4082,
3481,
304,
272,
408,
37,
22810,
5850,
14,
272,
24228,
8,
33,
12,
699,
9,
365,
715,
340,
436,
1454,
340,
437,
436,
699,
787,
3865,
715,
503,
3865,
756,
272,
408,
272,
768,
3744,
272,
347,
3468,
8,
1886,
12,
627,
589,
304,
267,
372,
10082,
855,
1222,
721,
1886,
12,
627,
5917,
8,
589,
430,
199,
199,
5680,
1284,
1021,
10269,
14,
6601,
2997,
3102,
199,
199,
318,
24101,
63,
1397,
8,
1273,
304,
272,
408,
272,
2832,
315,
24101,
9661,
339,
911,
372,
2832,
340,
1680,
365,
282,
5046,
574,
12,
436,
488,
340,
1423,
272,
365,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
Altai-man/kataba-fork
|
wsgi/openshift/captcha/migrations/0001_initial.py
|
17
|
1523
|
# encoding: utf-8
import datetime
from south.db import db
from south.v2 import SchemaMigration
from django.db import models
class Migration(SchemaMigration):
def forwards(self, orm):
# Adding model 'CaptchaStore'
db.create_table('captcha_captchastore', (
('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
('challenge', self.gf('django.db.models.fields.CharField')(max_length=32)),
('response', self.gf('django.db.models.fields.CharField')(max_length=32)),
('hashkey', self.gf('django.db.models.fields.CharField')(unique=True, max_length=40)),
('expiration', self.gf('django.db.models.fields.DateTimeField')()),
))
db.send_create_signal('captcha', ['CaptchaStore'])
def backwards(self, orm):
# Deleting model 'CaptchaStore'
db.delete_table('captcha_captchastore')
models = {
'captcha.captchastore': {
'Meta': {'object_name': 'CaptchaStore'},
'challenge': ('django.db.models.fields.CharField', [], {'max_length': '32'}),
'expiration': ('django.db.models.fields.DateTimeField', [], {}),
'hashkey': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '40'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'response': ('django.db.models.fields.CharField', [], {'max_length': '32'})
}
}
complete_apps = ['captcha']
|
gpl-2.0
|
[
3,
2644,
26,
2774,
13,
24,
199,
646,
2197,
199,
504,
12919,
14,
697,
492,
1592,
199,
504,
12919,
14,
86,
18,
492,
24765,
199,
504,
1639,
14,
697,
492,
1709,
199,
199,
533,
12090,
8,
24822,
304,
339,
347,
17465,
8,
277,
12,
9813,
304,
2728,
327,
12934,
1402,
283,
13519,
9518,
5502,
7,
267,
1592,
14,
981,
63,
1224,
360,
20559,
63,
20559,
1617,
297,
334,
288,
661,
344,
297,
291,
14,
7102,
360,
1176,
14,
697,
14,
992,
14,
955,
14,
4378,
7533,
3327,
63,
498,
29,
549,
1826,
288,
661,
13911,
297,
291,
14,
7102,
360,
1176,
14,
697,
14,
992,
14,
955,
14,
2183,
7533,
988,
63,
1267,
29,
708,
1826,
288,
661,
1310,
297,
291,
14,
7102,
360,
1176,
14,
697,
14,
992,
14,
955,
14,
2183,
7533,
988,
63,
1267,
29,
708,
1826,
288,
661,
2227,
498,
297,
291,
14,
7102,
360,
1176,
14,
697,
14,
992,
14,
955,
14,
2183,
7533,
3235,
29,
549,
12,
1390,
63,
1267,
29,
2167,
1826,
288,
661,
15469,
297,
291,
14,
7102,
360,
1176,
14,
697,
14,
992,
14,
955,
14,
4626,
358,
4000,
267,
5082,
267,
1592,
14,
2254,
63,
981,
63,
4653,
360,
20559,
297,
788,
13519,
9518,
5502,
1105,
2378,
347,
8552,
8,
277,
12,
9813,
304,
2728,
327,
15920,
1402,
283,
13519,
9518,
5502,
7,
267,
1592,
14,
1807,
63,
1224,
360,
20559,
63,
20559,
1617,
358,
2378,
1709,
275,
469,
267,
283,
20559,
14,
20559,
1617,
356,
469,
288,
283,
3396,
356,
791,
785,
63,
354,
356,
283,
13519,
9518,
5502,
2267,
288,
283,
13911,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2183,
297,
990,
791,
988,
63,
1267,
356,
283,
708,
1604,
288,
283,
15469,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
4626,
297,
990,
8613,
288,
283,
2227,
498,
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,
2167,
1604,
288,
283,
344,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
4378,
297,
990,
791,
3327,
63,
498,
356,
283,
549,
1604,
288,
283,
1310,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2183,
297,
990,
791,
988,
63,
1267,
356,
283,
708,
3071,
267,
789,
272,
789,
339,
4890,
63,
5181,
275,
788,
20559,
418,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
2644,
26,
2774,
13,
24,
199,
646,
2197,
199,
504,
12919,
14,
697,
492,
1592,
199,
504,
12919,
14,
86,
18,
492,
24765,
199,
504,
1639,
14,
697,
492,
1709,
199,
199,
533,
12090,
8,
24822,
304,
339,
347,
17465,
8,
277,
12,
9813,
304,
2728,
327,
12934,
1402,
283,
13519,
9518,
5502,
7,
267,
1592,
14,
981,
63,
1224,
360,
20559,
63,
20559,
1617,
297,
334,
288,
661,
344,
297,
291,
14,
7102,
360,
1176,
14,
697,
14,
992,
14,
955,
14,
4378,
7533,
3327,
63,
498,
29,
549,
1826,
288,
661,
13911,
297,
291,
14,
7102,
360,
1176,
14,
697,
14,
992,
14,
955,
14,
2183,
7533,
988,
63,
1267,
29,
708,
1826,
288,
661,
1310,
297,
291,
14,
7102,
360,
1176,
14,
697,
14,
992,
14,
955,
14,
2183,
7533,
988,
63,
1267,
29,
708,
1826,
288,
661,
2227,
498,
297,
291,
14,
7102,
360,
1176,
14,
697,
14,
992,
14,
955,
14,
2183,
7533,
3235,
29,
549,
12,
1390,
63,
1267,
29,
2167,
1826,
288,
661,
15469,
297,
291,
14,
7102,
360,
1176,
14,
697,
14,
992,
14,
955,
14,
4626,
358,
4000,
267,
5082,
267,
1592,
14,
2254,
63,
981,
63,
4653,
360,
20559,
297,
788,
13519,
9518,
5502,
1105,
2378,
347,
8552,
8,
277,
12,
9813,
304,
2728,
327,
15920,
1402,
283,
13519,
9518,
5502,
7,
267,
1592,
14,
1807,
63,
1224,
360,
20559,
63,
20559,
1617,
358,
2378,
1709,
275,
469,
267,
283,
20559,
14,
20559,
1617,
356,
469,
288,
283,
3396,
356,
791,
785,
63,
354,
356,
283,
13519,
9518,
5502,
2267,
288,
283,
13911,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2183,
297,
990,
791,
988,
63,
1267,
356,
283,
708,
1604,
288,
283,
15469,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
4626,
297,
990,
8613,
288,
283,
2227,
498,
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,
2167,
1604,
288,
283,
344,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
4378,
297,
990,
791,
3327,
63,
498,
356,
283,
549,
1604,
288,
283,
1310,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2183,
297,
990,
791,
988,
63,
1267,
356,
283,
708,
3071,
267,
789,
272,
789,
339,
4890,
63,
5181,
275,
788,
20559,
418,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,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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
] |
pselle/calibre
|
src/calibre/devices/jetbook/driver.py
|
24
|
4184
|
# -*- coding: utf-8 -*-
__license__ = 'GPL v3'
__copyright__ = '2009, James Ralston <jralston at mindspring.com>'
__docformat__ = 'restructuredtext en'
'''
Device driver for Ectaco Jetbook firmware >= JL04_v030e
'''
import os
import re
import sys
from calibre.devices.usbms.driver import USBMS
from calibre.ebooks.metadata import string_to_authors
class JETBOOK(USBMS):
name = 'Ectaco JetBook Device Interface'
description = _('Communicate with the JetBook eBook reader.')
author = 'James Ralston'
supported_platforms = ['windows', 'osx', 'linux']
# Ordered list of supported formats
# Be sure these have an entry in calibre.devices.mime
FORMATS = ['epub', 'mobi', 'prc', 'fb2', 'txt', 'rtf', 'pdf']
VENDOR_ID = [0x0525]
PRODUCT_ID = [0xa4a5]
BCD = [0x314]
VENDOR_NAME = 'LINUX'
WINDOWS_MAIN_MEM = 'EBOOK'
WINDOWS_CARD_A_MEM = 'EBOOK'
OSX_MAIN_MEM = 'Linux ebook Media'
OSX_CARD_A_MEM = 'Linux ebook Media'
MAIN_MEMORY_VOLUME_LABEL = 'Jetbook Main Memory'
STORAGE_CARD_VOLUME_LABEL = 'Jetbook Storage Card'
EBOOK_DIR_MAIN = "Books"
EBOOK_DIR_CARD_A = "Books"
SUPPORTS_SUB_DIRS = True
JETBOOK_FILE_NAME_PATTERN = re.compile(
r'(?P<authors>.+)#(?P<title>.+)'
)
def filename_callback(self, fname, mi):
fileext = os.path.splitext(os.path.basename(fname))[1]
if fileext.lower() not in ('txt', 'pdf', 'fb2'):
return fname
title = mi.title if mi.title else 'Unknown'
title = title.replace(' ', '_')
au = mi.format_authors()
if not au:
au = 'Unknown'
return '%s#%s%s' % (au, title, fileext)
@classmethod
def metadata_from_path(cls, path):
def check_unicode(txt):
txt = txt.replace('_', ' ')
if not isinstance(txt, unicode):
return txt.decode(sys.getfilesystemencoding(), 'replace')
return txt
mi = cls.metadata_from_formats([path])
if (mi.title==_('Unknown') or mi.authors==[_('Unknown')]) \
and '#' in mi.title:
fn = os.path.splitext(os.path.basename(path))[0]
match = cls.JETBOOK_FILE_NAME_PATTERN.match(fn)
if match is not None:
mi.title = check_unicode(match.group('title'))
authors = string_to_authors(match.group('authors'))
mi.authors = map(check_unicode, authors)
return mi
class MIBUK(USBMS):
name = 'MiBuk Wolder Device Interface'
description = _('Communicate with the MiBuk Wolder reader.')
author = 'Kovid Goyal'
supported_platforms = ['windows']
FORMATS = ['epub', 'mobi', 'prc', 'fb2', 'txt', 'rtf', 'pdf']
VENDOR_ID = [0x0525]
PRODUCT_ID = [0xa4a5]
BCD = [0x314, 0x319]
SUPPORTS_SUB_DIRS = True
VENDOR_NAME = ['LINUX', 'FILE_BAC']
WINDOWS_MAIN_MEM = WINDOWS_CARD_A_MEM = ['WOLDERMIBUK', 'KED_STORAGE_GADG']
class JETBOOK_MINI(USBMS):
'''
['0x4b8',
'0x507',
'0x100',
'ECTACO',
'ECTACO ATA/ATAPI Bridge (Bulk-Only)',
'Rev.0.20']
'''
FORMATS = ['fb2', 'txt']
gui_name = 'JetBook Mini'
name = 'JetBook Mini Device Interface'
description = _('Communicate with the JetBook Mini reader.')
author = 'Kovid Goyal'
VENDOR_ID = [0x4b8]
PRODUCT_ID = [0x507]
BCD = [0x100]
VENDOR_NAME = 'ECTACO'
WINDOWS_MAIN_MEM = '' # Matches PROD_
MAIN_MEMORY_VOLUME_LABEL = 'Jetbook Mini'
SUPPORTS_SUB_DIRS = True
class JETBOOK_COLOR(USBMS):
'''
set([(u'0x951',
u'0x160b',
u'0x0',
u'Freescale',
u'Mass Storage Device',
u'0802270905553')])
'''
FORMATS = ['epub', 'mobi', 'prc', 'fb2', 'rtf', 'txt', 'pdf', 'djvu']
gui_name = 'JetBook Color'
name = 'JetBook Color Device Interface'
description = _('Communicate with the JetBook Color reader.')
author = 'Kovid Goyal'
VENDOR_ID = [0x951]
PRODUCT_ID = [0x160b]
BCD = [0x0]
EBOOK_DIR_MAIN = 'My Books'
SUPPORTS_SUB_DIRS = True
|
gpl-3.0
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
199,
363,
1682,
363,
257,
275,
283,
12006,
373,
19,
7,
199,
363,
7307,
363,
275,
283,
8664,
12,
1603,
14015,
820,
279,
17874,
665,
74,
13984,
17874,
737,
25169,
26008,
14,
957,
3524,
199,
363,
21841,
363,
275,
283,
26854,
655,
7,
199,
199,
2344,
199,
2510,
5253,
367,
662,
319,
13286,
1603,
386,
2706,
27969,
2356,
1603,
44,
966,
63,
86,
22739,
69,
199,
2344,
199,
199,
646,
747,
199,
646,
295,
199,
646,
984,
199,
199,
504,
19238,
14,
6410,
14,
17411,
706,
14,
3090,
492,
28655,
3053,
199,
504,
19238,
14,
69,
8858,
14,
2343,
492,
1059,
63,
475,
63,
8149,
199,
199,
533,
1603,
775,
21155,
8,
19919,
3053,
304,
272,
536,
3698,
275,
283,
37,
319,
13286,
1603,
386,
8696,
12272,
14816,
7,
272,
1369,
259,
275,
4018,
27258,
323,
543,
314,
1603,
386,
8696,
325,
8696,
7002,
2659,
272,
4132,
260,
275,
283,
42,
14015,
820,
279,
17874,
7,
272,
3748,
63,
19601,
275,
788,
8258,
297,
283,
28197,
297,
283,
5135,
418,
2378,
327,
17649,
769,
402,
3748,
6752,
272,
327,
6423,
3238,
3520,
1172,
376,
2397,
315,
19238,
14,
6410,
14,
7626,
272,
11295,
619,
51,
258,
275,
788,
19224,
297,
283,
573,
4492,
297,
283,
80,
1195,
297,
283,
4675,
18,
297,
283,
2424,
297,
283,
2591,
70,
297,
283,
5607,
418,
339,
812,
3902,
726,
63,
998,
257,
275,
359,
16,
88,
1717,
821,
61,
272,
3611,
13461,
63,
998,
221,
275,
359,
16,
1800,
20,
65,
21,
61,
272,
699,
7695,
260,
275,
359,
16,
88,
8988,
61,
339,
812,
3902,
726,
63,
2339,
420,
275,
283,
26030,
7,
272,
20896,
1649,
5035,
63,
5848,
63,
10293,
275,
283,
37,
21155,
7,
272,
20896,
1649,
5035,
63,
35,
7816,
63,
33,
63,
10293,
275,
283,
37,
21155,
7,
339,
32144,
63,
5848,
63,
10293,
275,
283,
14091,
325,
2706,
12300,
7,
272,
32144,
63,
35,
7816,
63,
33,
63,
10293,
275,
283,
14091,
325,
2706,
12300,
7,
339,
4828,
568,
63,
19495,
63,
16689,
63,
13837,
221,
275,
283,
42,
386,
2706,
11298,
15825,
7,
272,
4384,
726,
2962,
63,
35,
7816,
63,
16689,
63,
13837,
275,
283,
42,
386,
2706,
10533,
445,
1005,
7,
339,
662,
21155,
63,
3022,
63,
5848,
275,
298,
8696,
83,
2,
272,
662,
21155,
63,
3022,
63,
35,
7816,
63,
33,
275,
298,
8696,
83,
2,
272,
13756,
51,
63,
6348,
63,
14455,
275,
715,
339,
1603,
775,
21155,
63,
3817,
63,
2339,
63,
10764,
275,
295,
14,
2014,
8,
288,
519,
10120,
48,
28,
8149,
31411,
28017,
2229,
48,
28,
1213,
31411,
3171,
288,
776,
339,
347,
1788,
63,
3058,
8,
277,
12,
6748,
12,
10684,
304,
267,
570,
832,
275,
747,
14,
515,
14,
7973,
8,
736,
14,
515,
14,
4846,
8,
5252,
11515,
17,
61,
267,
340,
570,
832,
14,
2325,
342,
440,
315,
661,
2424,
297,
283,
5607,
297,
283,
4675,
18,
735,
288,
372,
6748,
267,
2538,
275,
10684,
14,
1213,
340,
10684,
14,
1213,
587,
283,
5912,
7,
267,
2538,
275,
2538,
14,
1814,
360,
1656,
18962,
267,
10576,
275,
10684,
14,
908,
63,
8149,
342,
267,
340,
440,
10576,
26,
288,
10576,
275,
283,
5912,
7,
267,
372,
1543,
83,
25745,
83,
5,
83,
7,
450,
334,
3844,
12,
2538,
12,
570,
832,
9,
339,
768,
3744,
272,
347,
3341,
63,
504,
63,
515,
8,
1886,
12,
931,
304,
398,
347,
1104,
63,
2975,
8,
2424,
304,
288,
9444,
275,
9444,
14,
1814,
20928,
283,
5320,
288,
340,
440,
1228,
8,
2424,
12,
2649,
304,
355,
372,
9444,
14,
2708,
8,
1274,
14,
23462,
32255,
1062,
283,
1814,
358,
953,
372,
9444,
398,
10684,
275,
843,
14,
2343,
63,
504,
63,
6321,
779,
515,
566,
398,
340,
334,
2664,
14,
1213,
389,
11252,
5912,
358,
503,
10684,
14,
8149,
389,
59,
11252,
5912,
2023,
971,
355,
436,
19619,
315,
10684,
14,
1213,
26,
288,
4325,
275,
747,
14,
515,
14,
7973,
8,
736,
14,
515,
14,
4846,
8,
515,
11515,
16,
61,
288,
1336,
275,
843,
14,
42,
775,
21155,
63,
3817,
63,
2339,
63,
10764,
14,
1431,
8,
2324,
9,
288,
340,
1336,
365,
440,
488,
26,
355,
10684,
14,
1213,
275,
1104,
63,
2975,
8,
1431,
14,
923,
360,
1213,
1333,
355,
11462,
275,
1059,
63,
475,
63,
8149,
8,
1431,
14,
923,
360,
8149,
1333,
355,
10684,
14,
8149,
275,
2341,
8,
1074,
63,
2975,
12,
11462,
9,
398,
372,
10684,
199,
199,
533,
603,
2100,
26667,
8,
19919,
3053,
304,
339,
536,
3698,
275,
283,
14738,
1713,
75,
644,
2149,
12272,
14816,
7,
272,
1369,
259,
275,
4018,
27258,
323,
543,
314,
603,
73,
1713,
75,
644,
2149,
7002,
2659,
272,
4132,
260,
275,
283,
31305,
5017,
3971,
31876,
7,
272,
3748,
63,
19601,
275,
788,
8258,
418,
339,
11295,
619,
51,
258,
275,
788,
19224,
297,
283,
573,
4492,
297,
283,
80,
1195,
297,
283,
4675,
18,
297,
283,
2424,
297,
283,
2591,
70,
297,
283,
5607,
418,
339,
812,
3902,
726,
63,
998,
257,
275,
359,
16,
88,
1717,
821,
61,
272,
3611,
13461,
63,
998,
221,
275,
359,
16,
1800,
20,
65,
21,
61,
272,
699,
7695,
260,
275,
359,
16,
88,
8988,
12,
378,
88,
23538,
61,
272,
13756,
51,
63,
6348,
63,
14455,
275,
715,
339,
812,
3902,
726,
63,
2339,
420,
275,
788,
26030,
297,
283,
3817,
63,
34,
1348,
418,
272,
20896,
1649,
5035,
63,
5848,
63,
10293,
275,
20896,
1649,
5035,
63,
35,
7816,
63,
33,
63,
10293,
275,
788,
55,
15744,
10535,
26667,
297,
283,
43,
1149,
63,
17467,
63,
39,
1554,
39,
418,
199,
199,
533,
1603,
775,
21155,
63,
4896,
41,
8,
19919,
3053,
304,
339,
1449,
272,
788,
16,
88,
20,
66,
24,
297,
523,
283,
16,
88,
13583,
297,
523,
283,
16,
88,
1960,
297,
523,
283,
3582,
1348,
47,
297,
523,
283,
3582,
1348,
47,
437,
6166,
15,
619,
3735,
699,
5562,
334,
26033,
13,
5903,
3196,
523,
283,
26176,
14,
16,
14,
1165,
418,
272,
1449,
272,
11295,
619,
51,
258,
275,
788,
4675,
18,
297,
283,
2424,
418,
339,
11621
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
199,
363,
1682,
363,
257,
275,
283,
12006,
373,
19,
7,
199,
363,
7307,
363,
275,
283,
8664,
12,
1603,
14015,
820,
279,
17874,
665,
74,
13984,
17874,
737,
25169,
26008,
14,
957,
3524,
199,
363,
21841,
363,
275,
283,
26854,
655,
7,
199,
199,
2344,
199,
2510,
5253,
367,
662,
319,
13286,
1603,
386,
2706,
27969,
2356,
1603,
44,
966,
63,
86,
22739,
69,
199,
2344,
199,
199,
646,
747,
199,
646,
295,
199,
646,
984,
199,
199,
504,
19238,
14,
6410,
14,
17411,
706,
14,
3090,
492,
28655,
3053,
199,
504,
19238,
14,
69,
8858,
14,
2343,
492,
1059,
63,
475,
63,
8149,
199,
199,
533,
1603,
775,
21155,
8,
19919,
3053,
304,
272,
536,
3698,
275,
283,
37,
319,
13286,
1603,
386,
8696,
12272,
14816,
7,
272,
1369,
259,
275,
4018,
27258,
323,
543,
314,
1603,
386,
8696,
325,
8696,
7002,
2659,
272,
4132,
260,
275,
283,
42,
14015,
820,
279,
17874,
7,
272,
3748,
63,
19601,
275,
788,
8258,
297,
283,
28197,
297,
283,
5135,
418,
2378,
327,
17649,
769,
402,
3748,
6752,
272,
327,
6423,
3238,
3520,
1172,
376,
2397,
315,
19238,
14,
6410,
14,
7626,
272,
11295,
619,
51,
258,
275,
788,
19224,
297,
283,
573,
4492,
297,
283,
80,
1195,
297,
283,
4675,
18,
297,
283,
2424,
297,
283,
2591,
70,
297,
283,
5607,
418,
339,
812,
3902,
726,
63,
998,
257,
275,
359,
16,
88,
1717,
821,
61,
272,
3611,
13461,
63,
998,
221,
275,
359,
16,
1800,
20,
65,
21,
61,
272,
699,
7695,
260,
275,
359,
16,
88,
8988,
61,
339,
812,
3902,
726,
63,
2339,
420,
275,
283,
26030,
7,
272,
20896,
1649,
5035,
63,
5848,
63,
10293,
275,
283,
37,
21155,
7,
272,
20896,
1649,
5035,
63,
35,
7816,
63,
33,
63,
10293,
275,
283,
37,
21155,
7,
339,
32144,
63,
5848,
63,
10293,
275,
283,
14091,
325,
2706,
12300,
7,
272,
32144,
63,
35,
7816,
63,
33,
63,
10293,
275,
283,
14091,
325,
2706,
12300,
7,
339,
4828,
568,
63,
19495,
63,
16689,
63,
13837,
221,
275,
283,
42,
386,
2706,
11298,
15825,
7,
272,
4384,
726,
2962,
63,
35,
7816,
63,
16689,
63,
13837,
275,
283,
42,
386,
2706,
10533,
445,
1005,
7,
339,
662,
21155,
63,
3022,
63,
5848,
275,
298,
8696,
83,
2,
272,
662,
21155,
63,
3022,
63,
35,
7816,
63,
33,
275,
298,
8696,
83,
2,
272,
13756,
51,
63,
6348,
63,
14455,
275,
715,
339,
1603,
775,
21155,
63,
3817,
63,
2339,
63,
10764,
275,
295,
14,
2014,
8,
288,
519,
10120,
48,
28,
8149,
31411,
28017,
2229,
48,
28,
1213,
31411,
3171,
288,
776,
339,
347,
1788,
63,
3058,
8,
277,
12,
6748,
12,
10684,
304,
267,
570,
832,
275,
747,
14,
515,
14,
7973,
8,
736,
14,
515,
14,
4846,
8,
5252,
11515,
17,
61,
267,
340,
570,
832,
14,
2325,
342,
440,
315,
661,
2424,
297,
283,
5607,
297,
283,
4675,
18,
735,
288,
372,
6748,
267,
2538,
275,
10684,
14,
1213,
340,
10684,
14,
1213,
587,
283,
5912,
7,
267,
2538,
275,
2538,
14,
1814,
360,
1656,
18962,
267,
10576,
275,
10684,
14,
908,
63,
8149,
342,
267,
340,
440,
10576,
26,
288,
10576,
275,
283,
5912,
7,
267,
372,
1543,
83,
25745,
83,
5,
83,
7,
450,
334,
3844,
12,
2538,
12,
570,
832,
9,
339,
768,
3744,
272,
347,
3341,
63,
504,
63,
515,
8,
1886,
12,
931,
304,
398,
347,
1104,
63,
2975,
8,
2424,
304,
288,
9444,
275,
9444,
14,
1814,
20928,
283,
5320,
288,
340,
440,
1228,
8,
2424,
12,
2649,
304,
355,
372,
9444,
14,
2708,
8,
1274,
14,
23462,
32255,
1062,
283,
1814,
358,
953,
372,
9444,
398,
10684,
275,
843,
14,
2343,
63,
504,
63,
6321,
779,
515,
566,
398,
340,
334,
2664,
14,
1213,
389,
11252,
5912,
358,
503,
10684,
14,
8149,
389,
59,
11252,
5912,
2023,
971,
355,
436,
19619,
315,
10684,
14,
1213,
26,
288,
4325,
275,
747,
14,
515,
14,
7973,
8,
736,
14,
515,
14,
4846,
8,
515,
11515,
16,
61,
288,
1336,
275,
843,
14,
42,
775,
21155,
63,
3817,
63,
2339,
63,
10764,
14,
1431,
8,
2324,
9,
288,
340,
1336,
365,
440,
488,
26,
355,
10684,
14,
1213,
275,
1104,
63,
2975,
8,
1431,
14,
923,
360,
1213,
1333,
355,
11462,
275,
1059,
63,
475,
63,
8149,
8,
1431,
14,
923,
360,
8149,
1333,
355,
10684,
14,
8149,
275,
2341,
8,
1074,
63,
2975,
12,
11462,
9,
398,
372,
10684,
199,
199,
533,
603,
2100,
26667,
8,
19919,
3053,
304,
339,
536,
3698,
275,
283,
14738,
1713,
75,
644,
2149,
12272,
14816,
7,
272,
1369,
259,
275,
4018,
27258,
323,
543,
314,
603,
73,
1713,
75,
644,
2149,
7002,
2659,
272,
4132,
260,
275,
283,
31305,
5017,
3971,
31876,
7,
272,
3748,
63,
19601,
275,
788,
8258,
418,
339,
11295,
619,
51,
258,
275,
788,
19224,
297,
283,
573,
4492,
297,
283,
80,
1195,
297,
283,
4675,
18,
297,
283,
2424,
297,
283,
2591,
70,
297,
283,
5607,
418,
339,
812,
3902,
726,
63,
998,
257,
275,
359,
16,
88,
1717,
821,
61,
272,
3611,
13461,
63,
998,
221,
275,
359,
16,
1800,
20,
65,
21,
61,
272,
699,
7695,
260,
275,
359,
16,
88,
8988,
12,
378,
88,
23538,
61,
272,
13756,
51,
63,
6348,
63,
14455,
275,
715,
339,
812,
3902,
726,
63,
2339,
420,
275,
788,
26030,
297,
283,
3817,
63,
34,
1348,
418,
272,
20896,
1649,
5035,
63,
5848,
63,
10293,
275,
20896,
1649,
5035,
63,
35,
7816,
63,
33,
63,
10293,
275,
788,
55,
15744,
10535,
26667,
297,
283,
43,
1149,
63,
17467,
63,
39,
1554,
39,
418,
199,
199,
533,
1603,
775,
21155,
63,
4896,
41,
8,
19919,
3053,
304,
339,
1449,
272,
788,
16,
88,
20,
66,
24,
297,
523,
283,
16,
88,
13583,
297,
523,
283,
16,
88,
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
] |
patriciolobos/desa8
|
openerp/addons/marketing_campaign/marketing_campaign.py
|
286
|
41776
|
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2013 OpenERP SA (<http://openerp.com>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import time
import base64
import itertools
from datetime import datetime
from dateutil.relativedelta import relativedelta
from operator import itemgetter
from traceback import format_exception
from sys import exc_info
from openerp.tools.safe_eval import safe_eval as eval
import re
from openerp.addons.decimal_precision import decimal_precision as dp
from openerp import api
from openerp.osv import fields, osv
from openerp.report import render_report
from openerp.tools.translate import _
_intervalTypes = {
'hours': lambda interval: relativedelta(hours=interval),
'days': lambda interval: relativedelta(days=interval),
'months': lambda interval: relativedelta(months=interval),
'years': lambda interval: relativedelta(years=interval),
}
DT_FMT = '%Y-%m-%d %H:%M:%S'
class marketing_campaign(osv.osv):
_name = "marketing.campaign"
_description = "Marketing Campaign"
def _count_segments(self, cr, uid, ids, field_name, arg, context=None):
res = {}
try:
for segments in self.browse(cr, uid, ids, context=context):
res[segments.id] = len(segments.segment_ids)
except:
pass
return res
_columns = {
'name': fields.char('Name', required=True),
'object_id': fields.many2one('ir.model', 'Resource', required=True,
help="Choose the resource on which you want \
this campaign to be run"),
'partner_field_id': fields.many2one('ir.model.fields', 'Partner Field',
domain="[('model_id', '=', object_id), ('ttype', '=', 'many2one'), ('relation', '=', 'res.partner')]",
help="The generated workitems will be linked to the partner related to the record. "\
"If the record is the partner itself leave this field empty. "\
"This is useful for reporting purposes, via the Campaign Analysis or Campaign Follow-up views."),
'unique_field_id': fields.many2one('ir.model.fields', 'Unique Field',
domain="[('model_id', '=', object_id), ('ttype', 'in', ['char','int','many2one','text','selection'])]",
help='If set, this field will help segments that work in "no duplicates" mode to avoid '\
'selecting similar records twice. Similar records are records that have the same value for '\
'this unique field. For example by choosing the "email_from" field for CRM Leads you would prevent '\
'sending the same campaign to the same email address again. If not set, the "no duplicates" segments '\
"will only avoid selecting the same record again if it entered the campaign previously. "\
"Only easily comparable fields like textfields, integers, selections or single relationships may be used."),
'mode': fields.selection([('test', 'Test Directly'),
('test_realtime', 'Test in Realtime'),
('manual', 'With Manual Confirmation'),
('active', 'Normal')],
'Mode', required=True, help= \
"""Test - It creates and process all the activities directly (without waiting for the delay on transitions) but does not send emails or produce reports.
Test in Realtime - It creates and processes all the activities directly but does not send emails or produce reports.
With Manual Confirmation - the campaigns runs normally, but the user has to validate all workitem manually.
Normal - the campaign runs normally and automatically sends all emails and reports (be very careful with this mode, you're live!)"""),
'state': fields.selection([('draft', 'New'),
('running', 'Running'),
('cancelled', 'Cancelled'),
('done', 'Done')],
'Status', copy=False),
'activity_ids': fields.one2many('marketing.campaign.activity',
'campaign_id', 'Activities'),
'fixed_cost': fields.float('Fixed Cost', help="Fixed cost for running this campaign. You may also specify variable cost and revenue on each campaign activity. Cost and Revenue statistics are included in Campaign Reporting.", digits_compute=dp.get_precision('Product Price')),
'segment_ids': fields.one2many('marketing.campaign.segment', 'campaign_id', 'Segments', readonly=False),
'segments_count': fields.function(_count_segments, type='integer', string='Segments')
}
_defaults = {
'state': lambda *a: 'draft',
'mode': lambda *a: 'test',
}
def state_running_set(self, cr, uid, ids, *args):
# TODO check that all subcampaigns are running
campaign = self.browse(cr, uid, ids[0])
if not campaign.activity_ids:
raise osv.except_osv(_("Error"), _("The campaign cannot be started. There are no activities in it."))
has_start = False
has_signal_without_from = False
for activity in campaign.activity_ids:
if activity.start:
has_start = True
if activity.signal and len(activity.from_ids) == 0:
has_signal_without_from = True
if not has_start and not has_signal_without_from:
raise osv.except_osv(_("Error"), _("The campaign cannot be started. It does not have any starting activity. Modify campaign's activities to mark one as the starting point."))
return self.write(cr, uid, ids, {'state': 'running'})
def state_done_set(self, cr, uid, ids, *args):
# TODO check that this campaign is not a subcampaign in running mode.
segment_ids = self.pool.get('marketing.campaign.segment').search(cr, uid,
[('campaign_id', 'in', ids),
('state', '=', 'running')])
if segment_ids :
raise osv.except_osv(_("Error"), _("The campaign cannot be marked as done before all segments are closed."))
self.write(cr, uid, ids, {'state': 'done'})
return True
def state_cancel_set(self, cr, uid, ids, *args):
# TODO check that this campaign is not a subcampaign in running mode.
self.write(cr, uid, ids, {'state': 'cancelled'})
return True
# dead code
def signal(self, cr, uid, model, res_id, signal, run_existing=True, context=None):
record = self.pool[model].browse(cr, uid, res_id, context)
return self._signal(cr, uid, record, signal, run_existing, context)
#dead code
def _signal(self, cr, uid, record, signal, run_existing=True, context=None):
if not signal:
raise ValueError('Signal cannot be False.')
Workitems = self.pool.get('marketing.campaign.workitem')
domain = [('object_id.model', '=', record._name),
('state', '=', 'running')]
campaign_ids = self.search(cr, uid, domain, context=context)
for campaign in self.browse(cr, uid, campaign_ids, context=context):
for activity in campaign.activity_ids:
if activity.signal != signal:
continue
data = dict(activity_id=activity.id,
res_id=record.id,
state='todo')
wi_domain = [(k, '=', v) for k, v in data.items()]
wi_ids = Workitems.search(cr, uid, wi_domain, context=context)
if wi_ids:
if not run_existing:
continue
else:
partner = self._get_partner_for(campaign, record)
if partner:
data['partner_id'] = partner.id
wi_id = Workitems.create(cr, uid, data, context=context)
wi_ids = [wi_id]
Workitems.process(cr, uid, wi_ids, context=context)
return True
def _get_partner_for(self, campaign, record):
partner_field = campaign.partner_field_id.name
if partner_field:
return getattr(record, partner_field)
elif campaign.object_id.model == 'res.partner':
return record
return None
# prevent duplication until the server properly duplicates several levels of nested o2m
def copy(self, cr, uid, id, default=None, context=None):
raise osv.except_osv(_("Operation not supported"), _("You cannot duplicate a campaign, Not supported yet."))
def _find_duplicate_workitems(self, cr, uid, record, campaign_rec, context=None):
"""Finds possible duplicates workitems for a record in this campaign, based on a uniqueness
field.
:param record: browse_record to find duplicates workitems for.
:param campaign_rec: browse_record of campaign
"""
Workitems = self.pool.get('marketing.campaign.workitem')
duplicate_workitem_domain = [('res_id','=', record.id),
('campaign_id','=', campaign_rec.id)]
unique_field = campaign_rec.unique_field_id
if unique_field:
unique_value = getattr(record, unique_field.name, None)
if unique_value:
if unique_field.ttype == 'many2one':
unique_value = unique_value.id
similar_res_ids = self.pool[campaign_rec.object_id.model].search(cr, uid,
[(unique_field.name, '=', unique_value)], context=context)
if similar_res_ids:
duplicate_workitem_domain = [('res_id','in', similar_res_ids),
('campaign_id','=', campaign_rec.id)]
return Workitems.search(cr, uid, duplicate_workitem_domain, context=context)
class marketing_campaign_segment(osv.osv):
_name = "marketing.campaign.segment"
_description = "Campaign Segment"
_order = "name"
def _get_next_sync(self, cr, uid, ids, fn, args, context=None):
# next auto sync date is same for all segments
sync_job = self.pool.get('ir.model.data').get_object(cr, uid, 'marketing_campaign', 'ir_cron_marketing_campaign_every_day', context=context)
next_sync = sync_job and sync_job.nextcall or False
return dict.fromkeys(ids, next_sync)
_columns = {
'name': fields.char('Name', required=True),
'campaign_id': fields.many2one('marketing.campaign', 'Campaign', required=True, select=1, ondelete="cascade"),
'object_id': fields.related('campaign_id','object_id', type='many2one', relation='ir.model', string='Resource'),
'ir_filter_id': fields.many2one('ir.filters', 'Filter', ondelete="restrict",
help="Filter to select the matching resource records that belong to this segment. "\
"New filters can be created and saved using the advanced search on the list view of the Resource. "\
"If no filter is set, all records are selected without filtering. "\
"The synchronization mode may also add a criterion to the filter."),
'sync_last_date': fields.datetime('Last Synchronization', help="Date on which this segment was synchronized last time (automatically or manually)"),
'sync_mode': fields.selection([('create_date', 'Only records created after last sync'),
('write_date', 'Only records modified after last sync (no duplicates)'),
('all', 'All records (no duplicates)')],
'Synchronization mode',
help="Determines an additional criterion to add to the filter when selecting new records to inject in the campaign. "\
'"No duplicates" prevents selecting records which have already entered the campaign previously.'\
'If the campaign has a "unique field" set, "no duplicates" will also prevent selecting records which have '\
'the same value for the unique field as other records that already entered the campaign.'),
'state': fields.selection([('draft', 'New'),
('cancelled', 'Cancelled'),
('running', 'Running'),
('done', 'Done')],
'Status', copy=False),
'date_run': fields.datetime('Launch Date', help="Initial start date of this segment."),
'date_done': fields.datetime('End Date', help="Date this segment was last closed or cancelled."),
'date_next_sync': fields.function(_get_next_sync, string='Next Synchronization', type='datetime', help="Next time the synchronization job is scheduled to run automatically"),
}
_defaults = {
'state': lambda *a: 'draft',
'sync_mode': lambda *a: 'create_date',
}
def _check_model(self, cr, uid, ids, context=None):
for obj in self.browse(cr, uid, ids, context=context):
if not obj.ir_filter_id:
return True
if obj.campaign_id.object_id.model != obj.ir_filter_id.model_id:
return False
return True
_constraints = [
(_check_model, 'Model of filter must be same as resource model of Campaign ', ['ir_filter_id,campaign_id']),
]
def onchange_campaign_id(self, cr, uid, ids, campaign_id):
res = {'domain':{'ir_filter_id':[]}}
campaign_pool = self.pool.get('marketing.campaign')
if campaign_id:
campaign = campaign_pool.browse(cr, uid, campaign_id)
model_name = self.pool.get('ir.model').read(cr, uid, [campaign.object_id.id], ['model'])
if model_name:
mod_name = model_name[0]['model']
res['domain'] = {'ir_filter_id': [('model_id', '=', mod_name)]}
else:
res['value'] = {'ir_filter_id': False}
return res
def state_running_set(self, cr, uid, ids, *args):
segment = self.browse(cr, uid, ids[0])
vals = {'state': 'running'}
if not segment.date_run:
vals['date_run'] = time.strftime('%Y-%m-%d %H:%M:%S')
self.write(cr, uid, ids, vals)
return True
def state_done_set(self, cr, uid, ids, *args):
wi_ids = self.pool.get("marketing.campaign.workitem").search(cr, uid,
[('state', '=', 'todo'), ('segment_id', 'in', ids)])
self.pool.get("marketing.campaign.workitem").write(cr, uid, wi_ids, {'state':'cancelled'})
self.write(cr, uid, ids, {'state': 'done','date_done': time.strftime('%Y-%m-%d %H:%M:%S')})
return True
def state_cancel_set(self, cr, uid, ids, *args):
wi_ids = self.pool.get("marketing.campaign.workitem").search(cr, uid,
[('state', '=', 'todo'), ('segment_id', 'in', ids)])
self.pool.get("marketing.campaign.workitem").write(cr, uid, wi_ids, {'state':'cancelled'})
self.write(cr, uid, ids, {'state': 'cancelled','date_done': time.strftime('%Y-%m-%d %H:%M:%S')})
return True
def synchroniz(self, cr, uid, ids, *args):
self.process_segment(cr, uid, ids)
return True
@api.cr_uid_ids_context
def process_segment(self, cr, uid, segment_ids=None, context=None):
Workitems = self.pool.get('marketing.campaign.workitem')
Campaigns = self.pool.get('marketing.campaign')
if not segment_ids:
segment_ids = self.search(cr, uid, [('state', '=', 'running')], context=context)
action_date = time.strftime('%Y-%m-%d %H:%M:%S')
campaigns = set()
for segment in self.browse(cr, uid, segment_ids, context=context):
if segment.campaign_id.state != 'running':
continue
campaigns.add(segment.campaign_id.id)
act_ids = self.pool.get('marketing.campaign.activity').search(cr,
uid, [('start', '=', True), ('campaign_id', '=', segment.campaign_id.id)], context=context)
model_obj = self.pool[segment.object_id.model]
criteria = []
if segment.sync_last_date and segment.sync_mode != 'all':
criteria += [(segment.sync_mode, '>', segment.sync_last_date)]
if segment.ir_filter_id:
criteria += eval(segment.ir_filter_id.domain)
object_ids = model_obj.search(cr, uid, criteria, context=context)
# XXX TODO: rewrite this loop more efficiently without doing 1 search per record!
for record in model_obj.browse(cr, uid, object_ids, context=context):
# avoid duplicate workitem for the same resource
if segment.sync_mode in ('write_date','all'):
if Campaigns._find_duplicate_workitems(cr, uid, record, segment.campaign_id, context=context):
continue
wi_vals = {
'segment_id': segment.id,
'date': action_date,
'state': 'todo',
'res_id': record.id
}
partner = self.pool.get('marketing.campaign')._get_partner_for(segment.campaign_id, record)
if partner:
wi_vals['partner_id'] = partner.id
for act_id in act_ids:
wi_vals['activity_id'] = act_id
Workitems.create(cr, uid, wi_vals, context=context)
self.write(cr, uid, segment.id, {'sync_last_date':action_date}, context=context)
Workitems.process_all(cr, uid, list(campaigns), context=context)
return True
class marketing_campaign_activity(osv.osv):
_name = "marketing.campaign.activity"
_order = "name"
_description = "Campaign Activity"
_action_types = [
('email', 'Email'),
('report', 'Report'),
('action', 'Custom Action'),
# TODO implement the subcampaigns.
# TODO implement the subcampaign out. disallow out transitions from
# subcampaign activities ?
#('subcampaign', 'Sub-Campaign'),
]
_columns = {
'name': fields.char('Name', required=True),
'campaign_id': fields.many2one('marketing.campaign', 'Campaign',
required = True, ondelete='cascade', select=1),
'object_id': fields.related('campaign_id','object_id',
type='many2one', relation='ir.model',
string='Object', readonly=True),
'start': fields.boolean('Start', help= "This activity is launched when the campaign starts.", select=True),
'condition': fields.text('Condition', size=256, required=True,
help="Python expression to decide whether the activity can be executed, otherwise it will be deleted or cancelled."
"The expression may use the following [browsable] variables:\n"
" - activity: the campaign activity\n"
" - workitem: the campaign workitem\n"
" - resource: the resource object this campaign item represents\n"
" - transitions: list of campaign transitions outgoing from this activity\n"
"...- re: Python regular expression module"),
'type': fields.selection(_action_types, 'Type', required=True,
help="""The type of action to execute when an item enters this activity, such as:
- Email: send an email using a predefined email template
- Report: print an existing Report defined on the resource item and save it into a specific directory
- Custom Action: execute a predefined action, e.g. to modify the fields of the resource record
"""),
'email_template_id': fields.many2one('email.template', "Email Template", help='The email to send when this activity is activated'),
'report_id': fields.many2one('ir.actions.report.xml', "Report", help='The report to generate when this activity is activated', ),
'report_directory_id': fields.many2one('document.directory','Directory',
help="This folder is used to store the generated reports"),
'server_action_id': fields.many2one('ir.actions.server', string='Action',
help= "The action to perform when this activity is activated"),
'to_ids': fields.one2many('marketing.campaign.transition',
'activity_from_id',
'Next Activities'),
'from_ids': fields.one2many('marketing.campaign.transition',
'activity_to_id',
'Previous Activities'),
'variable_cost': fields.float('Variable Cost', help="Set a variable cost if you consider that every campaign item that has reached this point has entailed a certain cost. You can get cost statistics in the Reporting section", digits_compute=dp.get_precision('Product Price')),
'revenue': fields.float('Revenue', help="Set an expected revenue if you consider that every campaign item that has reached this point has generated a certain revenue. You can get revenue statistics in the Reporting section", digits_compute=dp.get_precision('Account')),
'signal': fields.char('Signal',
help='An activity with a signal can be called programmatically. Be careful, the workitem is always created when a signal is sent'),
'keep_if_condition_not_met': fields.boolean("Don't Delete Workitems",
help="By activating this option, workitems that aren't executed because the condition is not met are marked as cancelled instead of being deleted.")
}
_defaults = {
'type': lambda *a: 'email',
'condition': lambda *a: 'True',
}
def search(self, cr, uid, args, offset=0, limit=None, order=None,
context=None, count=False):
if context == None:
context = {}
if 'segment_id' in context and context['segment_id']:
segment_obj = self.pool.get('marketing.campaign.segment').browse(cr,
uid, context['segment_id'])
act_ids = []
for activity in segment_obj.campaign_id.activity_ids:
act_ids.append(activity.id)
return act_ids
return super(marketing_campaign_activity, self).search(cr, uid, args,
offset, limit, order, context, count)
#dead code
def _process_wi_report(self, cr, uid, activity, workitem, context=None):
report_data, format = render_report(cr, uid, [], activity.report_id.report_name, {}, context=context)
attach_vals = {
'name': '%s_%s_%s'%(activity.report_id.report_name,
activity.name,workitem.partner_id.name),
'datas_fname': '%s.%s'%(activity.report_id.report_name,
activity.report_id.report_type),
'parent_id': activity.report_directory_id.id,
'datas': base64.encodestring(report_data),
'file_type': format
}
self.pool.get('ir.attachment').create(cr, uid, attach_vals)
return True
def _process_wi_email(self, cr, uid, activity, workitem, context=None):
return self.pool.get('email.template').send_mail(cr, uid,
activity.email_template_id.id,
workitem.res_id, context=context)
#dead code
def _process_wi_action(self, cr, uid, activity, workitem, context=None):
if context is None:
context = {}
server_obj = self.pool.get('ir.actions.server')
action_context = dict(context,
active_id=workitem.res_id,
active_ids=[workitem.res_id],
active_model=workitem.object_id.model,
workitem=workitem)
server_obj.run(cr, uid, [activity.server_action_id.id],
context=action_context)
return True
def process(self, cr, uid, act_id, wi_id, context=None):
activity = self.browse(cr, uid, act_id, context=context)
method = '_process_wi_%s' % (activity.type,)
action = getattr(self, method, None)
if not action:
raise NotImplementedError('Method %r is not implemented on %r object.' % (method, self))
workitem_obj = self.pool.get('marketing.campaign.workitem')
workitem = workitem_obj.browse(cr, uid, wi_id, context=context)
return action(cr, uid, activity, workitem, context=context)
class marketing_campaign_transition(osv.osv):
_name = "marketing.campaign.transition"
_description = "Campaign Transition"
_interval_units = [
('hours', 'Hour(s)'),
('days', 'Day(s)'),
('months', 'Month(s)'),
('years', 'Year(s)'),
]
def _get_name(self, cr, uid, ids, fn, args, context=None):
# name formatters that depend on trigger
formatters = {
'auto': _('Automatic transition'),
'time': _('After %(interval_nbr)d %(interval_type)s'),
'cosmetic': _('Cosmetic'),
}
# get the translations of the values of selection field 'interval_type'
fields = self.fields_get(cr, uid, ['interval_type'], context=context)
interval_type_selection = dict(fields['interval_type']['selection'])
result = dict.fromkeys(ids, False)
for trans in self.browse(cr, uid, ids, context=context):
values = {
'interval_nbr': trans.interval_nbr,
'interval_type': interval_type_selection.get(trans.interval_type, ''),
}
result[trans.id] = formatters[trans.trigger] % values
return result
def _delta(self, cr, uid, ids, context=None):
assert len(ids) == 1
transition = self.browse(cr, uid, ids[0], context=context)
if transition.trigger != 'time':
raise ValueError('Delta is only relevant for timed transition.')
return relativedelta(**{str(transition.interval_type): transition.interval_nbr})
_columns = {
'name': fields.function(_get_name, string='Name',
type='char', size=128),
'activity_from_id': fields.many2one('marketing.campaign.activity',
'Previous Activity', select=1,
required=True, ondelete="cascade"),
'activity_to_id': fields.many2one('marketing.campaign.activity',
'Next Activity',
required=True, ondelete="cascade"),
'interval_nbr': fields.integer('Interval Value', required=True),
'interval_type': fields.selection(_interval_units, 'Interval Unit',
required=True),
'trigger': fields.selection([('auto', 'Automatic'),
('time', 'Time'),
('cosmetic', 'Cosmetic'), # fake plastic transition
],
'Trigger', required=True,
help="How is the destination workitem triggered"),
}
_defaults = {
'interval_nbr': 1,
'interval_type': 'days',
'trigger': 'time',
}
def _check_campaign(self, cr, uid, ids, context=None):
for obj in self.browse(cr, uid, ids, context=context):
if obj.activity_from_id.campaign_id != obj.activity_to_id.campaign_id:
return False
return True
_constraints = [
(_check_campaign, 'The To/From Activity of transition must be of the same Campaign ', ['activity_from_id,activity_to_id']),
]
_sql_constraints = [
('interval_positive', 'CHECK(interval_nbr >= 0)', 'The interval must be positive or zero')
]
class marketing_campaign_workitem(osv.osv):
_name = "marketing.campaign.workitem"
_description = "Campaign Workitem"
def _res_name_get(self, cr, uid, ids, field_name, arg, context=None):
res = dict.fromkeys(ids, '/')
for wi in self.browse(cr, uid, ids, context=context):
if not wi.res_id:
continue
proxy = self.pool[wi.object_id.model]
if not proxy.exists(cr, uid, [wi.res_id]):
continue
ng = proxy.name_get(cr, uid, [wi.res_id], context=context)
if ng:
res[wi.id] = ng[0][1]
return res
def _resource_search(self, cr, uid, obj, name, args, domain=None, context=None):
"""Returns id of workitem whose resource_name matches with the given name"""
if not len(args):
return []
condition_name = None
for domain_item in args:
# we only use the first domain criterion and ignore all the rest including operators
if isinstance(domain_item, (list,tuple)) and len(domain_item) == 3 and domain_item[0] == 'res_name':
condition_name = [None, domain_item[1], domain_item[2]]
break
assert condition_name, "Invalid search domain for marketing_campaign_workitem.res_name. It should use 'res_name'"
cr.execute("""select w.id, w.res_id, m.model \
from marketing_campaign_workitem w \
left join marketing_campaign_activity a on (a.id=w.activity_id)\
left join marketing_campaign c on (c.id=a.campaign_id)\
left join ir_model m on (m.id=c.object_id)
""")
res = cr.fetchall()
workitem_map = {}
matching_workitems = []
for id, res_id, model in res:
workitem_map.setdefault(model,{}).setdefault(res_id,set()).add(id)
for model, id_map in workitem_map.iteritems():
model_pool = self.pool[model]
condition_name[0] = model_pool._rec_name
condition = [('id', 'in', id_map.keys()), condition_name]
for res_id in model_pool.search(cr, uid, condition, context=context):
matching_workitems.extend(id_map[res_id])
return [('id', 'in', list(set(matching_workitems)))]
_columns = {
'segment_id': fields.many2one('marketing.campaign.segment', 'Segment', readonly=True),
'activity_id': fields.many2one('marketing.campaign.activity','Activity',
required=True, readonly=True),
'campaign_id': fields.related('activity_id', 'campaign_id',
type='many2one', relation='marketing.campaign', string='Campaign', readonly=True, store=True),
'object_id': fields.related('activity_id', 'campaign_id', 'object_id',
type='many2one', relation='ir.model', string='Resource', select=1, readonly=True, store=True),
'res_id': fields.integer('Resource ID', select=1, readonly=True),
'res_name': fields.function(_res_name_get, string='Resource Name', fnct_search=_resource_search, type="char", size=64),
'date': fields.datetime('Execution Date', help='If date is not set, this workitem has to be run manually', readonly=True),
'partner_id': fields.many2one('res.partner', 'Partner', select=1, readonly=True),
'state': fields.selection([ ('todo', 'To Do'),
('cancelled', 'Cancelled'),
('exception', 'Exception'),
('done', 'Done'),
], 'Status', readonly=True, copy=False),
'error_msg' : fields.text('Error Message', readonly=True)
}
_defaults = {
'state': lambda *a: 'todo',
'date': False,
}
@api.cr_uid_ids_context
def button_draft(self, cr, uid, workitem_ids, context=None):
for wi in self.browse(cr, uid, workitem_ids, context=context):
if wi.state in ('exception', 'cancelled'):
self.write(cr, uid, [wi.id], {'state':'todo'}, context=context)
return True
@api.cr_uid_ids_context
def button_cancel(self, cr, uid, workitem_ids, context=None):
for wi in self.browse(cr, uid, workitem_ids, context=context):
if wi.state in ('todo','exception'):
self.write(cr, uid, [wi.id], {'state':'cancelled'}, context=context)
return True
def _process_one(self, cr, uid, workitem, context=None):
if workitem.state != 'todo':
return False
activity = workitem.activity_id
proxy = self.pool[workitem.object_id.model]
object_id = proxy.browse(cr, uid, workitem.res_id, context=context)
eval_context = {
'activity': activity,
'workitem': workitem,
'object': object_id,
'resource': object_id,
'transitions': activity.to_ids,
're': re,
}
try:
condition = activity.condition
campaign_mode = workitem.campaign_id.mode
if condition:
if not eval(condition, eval_context):
if activity.keep_if_condition_not_met:
workitem.write({'state': 'cancelled'})
else:
workitem.unlink()
return
result = True
if campaign_mode in ('manual', 'active'):
Activities = self.pool.get('marketing.campaign.activity')
result = Activities.process(cr, uid, activity.id, workitem.id,
context=context)
values = dict(state='done')
if not workitem.date:
values['date'] = datetime.now().strftime(DT_FMT)
workitem.write(values)
if result:
# process _chain
workitem.refresh() # reload
date = datetime.strptime(workitem.date, DT_FMT)
for transition in activity.to_ids:
if transition.trigger == 'cosmetic':
continue
launch_date = False
if transition.trigger == 'auto':
launch_date = date
elif transition.trigger == 'time':
launch_date = date + transition._delta()
if launch_date:
launch_date = launch_date.strftime(DT_FMT)
values = {
'date': launch_date,
'segment_id': workitem.segment_id.id,
'activity_id': transition.activity_to_id.id,
'partner_id': workitem.partner_id.id,
'res_id': workitem.res_id,
'state': 'todo',
}
wi_id = self.create(cr, uid, values, context=context)
# Now, depending on the trigger and the campaign mode
# we know whether we must run the newly created workitem.
#
# rows = transition trigger \ colums = campaign mode
#
# test test_realtime manual normal (active)
# time Y N N N
# cosmetic N N N N
# auto Y Y N Y
#
run = (transition.trigger == 'auto' \
and campaign_mode != 'manual') \
or (transition.trigger == 'time' \
and campaign_mode == 'test')
if run:
new_wi = self.browse(cr, uid, wi_id, context)
self._process_one(cr, uid, new_wi, context)
except Exception:
tb = "".join(format_exception(*exc_info()))
workitem.write({'state': 'exception', 'error_msg': tb})
@api.cr_uid_ids_context
def process(self, cr, uid, workitem_ids, context=None):
for wi in self.browse(cr, uid, workitem_ids, context=context):
self._process_one(cr, uid, wi, context=context)
return True
def process_all(self, cr, uid, camp_ids=None, context=None):
camp_obj = self.pool.get('marketing.campaign')
if camp_ids is None:
camp_ids = camp_obj.search(cr, uid, [('state','=','running')], context=context)
for camp in camp_obj.browse(cr, uid, camp_ids, context=context):
if camp.mode == 'manual':
# manual states are not processed automatically
continue
while True:
domain = [('campaign_id', '=', camp.id), ('state', '=', 'todo'), ('date', '!=', False)]
if camp.mode in ('test_realtime', 'active'):
domain += [('date','<=', time.strftime('%Y-%m-%d %H:%M:%S'))]
workitem_ids = self.search(cr, uid, domain, context=context)
if not workitem_ids:
break
self.process(cr, uid, workitem_ids, context=context)
return True
def preview(self, cr, uid, ids, context=None):
res = {}
wi_obj = self.browse(cr, uid, ids[0], context=context)
if wi_obj.activity_id.type == 'email':
view_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'email_template', 'email_template_preview_form')
res = {
'name': _('Email Preview'),
'view_type': 'form',
'view_mode': 'form,tree',
'res_model': 'email_template.preview',
'view_id': False,
'context': context,
'views': [(view_id and view_id[1] or 0, 'form')],
'type': 'ir.actions.act_window',
'target': 'new',
'nodestroy':True,
'context': "{'template_id':%d,'default_res_id':%d}"%
(wi_obj.activity_id.email_template_id.id,
wi_obj.res_id)
}
elif wi_obj.activity_id.type == 'report':
datas = {
'ids': [wi_obj.res_id],
'model': wi_obj.object_id.model
}
res = {
'type' : 'ir.actions.report.xml',
'report_name': wi_obj.activity_id.report_id.report_name,
'datas' : datas,
}
else:
raise osv.except_osv(_('No preview'),_('The current step for this item has no email or report to preview.'))
return res
class email_template(osv.osv):
_inherit = "email.template"
_defaults = {
'model_id': lambda obj, cr, uid, context: context.get('object_id',False),
}
# TODO: add constraint to prevent disabling / disapproving an email account used in a running campaign
class report_xml(osv.osv):
_inherit = 'ir.actions.report.xml'
def search(self, cr, uid, args, offset=0, limit=None, order=None, context=None, count=False):
if context is None:
context = {}
object_id = context.get('object_id')
if object_id:
model = self.pool.get('ir.model').browse(cr, uid, object_id, context=context).model
args.append(('model', '=', model))
return super(report_xml, self).search(cr, uid, args, offset, limit, order, context, count)
# 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,
6965,
7653,
13950,
8642,
1014,
921,
11267,
14,
957,
10121,
199,
3,
199,
3,
259,
961,
2240,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
259,
652,
1334,
314,
2895,
402,
314,
1664,
4265,
1696,
1684,
844,
465,
199,
3,
259,
3267,
701,
314,
2868,
2290,
2752,
12,
1902,
1015,
650,
402,
314,
199,
3,
259,
844,
12,
503,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
259,
961,
2240,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
259,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
259,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
199,
3,
259,
1664,
4265,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
259,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
4265,
1696,
1684,
844,
199,
3,
259,
3180,
543,
642,
2240,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
3,
199,
4605,
199,
199,
646,
900,
199,
646,
1300,
772,
199,
646,
7975,
199,
504,
2197,
492,
2197,
199,
504,
22208,
14,
32300,
492,
20599,
199,
504,
4182,
492,
1242,
7416,
199,
504,
5190,
492,
1475,
63,
1971,
199,
504,
984,
492,
3178,
63,
815,
199,
504,
5166,
14,
2537,
14,
3489,
63,
2579,
492,
5048,
63,
2579,
465,
3468,
199,
646,
295,
199,
504,
5166,
14,
10788,
14,
6355,
63,
6833,
492,
6107,
63,
6833,
465,
12392,
199,
199,
504,
5166,
492,
2986,
199,
504,
5166,
14,
4795,
492,
1504,
12,
9506,
199,
504,
5166,
14,
3070,
492,
3795,
63,
3070,
199,
504,
5166,
14,
2537,
14,
5275,
492,
485,
199,
199,
63,
4284,
4100,
275,
469,
272,
283,
8419,
356,
2400,
6252,
26,
20599,
8,
8419,
29,
4284,
395,
272,
283,
4899,
356,
2400,
6252,
26,
20599,
8,
4899,
29,
4284,
395,
272,
283,
16745,
356,
2400,
6252,
26,
20599,
8,
16745,
29,
4284,
395,
272,
283,
18431,
356,
2400,
6252,
26,
20599,
8,
18431,
29,
4284,
395,
199,
93,
199,
199,
7438,
63,
22831,
275,
1543,
57,
3295,
77,
3295,
68,
450,
40,
2689,
45,
2689,
51,
7,
421,
199,
533,
2216,
13800,
63,
17368,
8,
4795,
14,
4795,
304,
272,
485,
354,
275,
298,
1657,
13800,
14,
17368,
2,
272,
485,
1802,
275,
298,
6470,
13800,
24569,
65,
1030,
2,
2286,
347,
485,
835,
63,
13879,
8,
277,
12,
2467,
12,
1747,
12,
2762,
12,
901,
63,
354,
12,
1680,
12,
1067,
29,
403,
304,
267,
522,
275,
1052,
267,
862,
26,
288,
367,
11998,
315,
291,
14,
4570,
8,
1556,
12,
1747,
12,
2762,
12,
1067,
29,
1100,
304,
355,
522,
59,
13879,
14,
344,
61,
275,
822,
8,
13879,
14,
9255,
63,
1580,
9,
267,
871,
26,
7205,
986,
267,
372,
522,
339,
485,
3406,
275,
469,
267,
283,
354,
356,
1504,
14,
1560,
360,
985,
297,
1415,
29,
549,
395,
267,
283,
785,
63,
344,
356,
1504,
14,
3479,
18,
368,
360,
723,
14,
1238,
297,
283,
4031,
297,
1415,
29,
549,
12,
4228,
1720,
628,
23932,
314,
2073,
641,
1314,
1265,
2934,
971,
199,
3749,
22166,
370,
506,
1255,
1288,
267,
283,
3899,
63,
698,
63,
344,
356,
1504,
14,
3479,
18,
368,
360,
723,
14,
1238,
14,
955,
297,
283,
24120,
5024,
297,
4490,
2881,
628,
19412,
1238,
63,
344,
297,
6291,
909,
63,
344,
395,
661,
21002,
297,
6291,
283,
3479,
18,
368,
659,
661,
5690,
297,
6291,
283,
470,
14,
3899,
5440,
401,
4490,
1720,
628,
1918,
4046,
1736,
1744,
911,
506,
10632,
370,
314,
5854,
4048,
370,
314,
2777,
14,
1867,
8179,
298,
3917,
314,
2777,
365,
314,
5854,
6337,
10137,
642,
901,
2701,
14,
1867,
8179,
298,
2765,
365,
2997,
367,
17290,
12901,
12,
4799,
314,
24569,
65,
1030,
21916,
503,
24569,
65,
1030,
21876,
13,
384,
6858,
7651,
267,
283,
3235,
63,
698,
63,
344,
356,
1504,
14,
3479,
18,
368,
360,
723,
14,
1238,
14,
955,
297,
283,
11427,
5024,
297,
4490,
2881,
628,
19412,
1238,
63,
344,
297,
6291,
909,
63,
344,
395,
661,
21002,
297,
283,
262,
297,
788,
1560,
1673,
442,
1673,
3479,
18,
368,
1673,
505,
1673,
5592,
1105,
11472,
4490,
1720,
534,
3917,
663,
12,
642,
901,
911,
1720,
11998,
626,
1736,
315,
298,
889,
15755,
2,
818,
370,
5126,
1557,
1740,
283,
2416,
316,
8545,
5767,
13373,
14,
20046,
5767,
787,
5767,
626,
1172,
314,
2011,
574,
367,
1557,
1740,
283,
3749,
3747,
901,
14,
2104,
2893,
701,
2468,
26056,
314,
298,
2123,
63,
504,
2,
901,
367,
445,
11026,
7005,
9402,
1265,
3955,
7981,
1557,
1740,
283,
24450,
314,
2011,
22166,
370,
314,
2011,
3031,
2287,
4020,
14,
982,
440,
663,
12,
314,
298,
889,
15755,
2,
11998,
1557,
1740,
298,
14117,
1454,
5126,
30090,
314,
2011,
2777,
4020,
340,
652,
19138,
314,
22166,
10889,
14,
1867,
1740,
298,
5903,
16174,
1013,
19816,
1504,
2839,
1318,
955,
12,
9446,
12,
7267,
83,
503,
2849,
20045,
1443,
506,
1202,
7651,
267,
283,
632,
356,
1504,
14,
5592,
8318,
396,
297,
283,
774,
21128,
590,
659,
1816,
661,
396,
63,
3093,
521,
297,
283,
774,
315,
14849,
521,
659,
1816,
661,
9285,
297,
283,
3007,
30247,
1448,
11701,
659,
1816,
661,
2682,
297,
283,
6241,
2665,
639,
283,
1385,
297,
1415,
29,
549,
12,
1720,
29,
971,
199,
624,
774,
446,
2779,
8491,
436,
2112,
1006,
314,
30744,
5370,
334,
7395,
10923,
367,
314,
7339,
641,
19077,
9,
1325,
1630,
440,
3222,
14931,
503,
7389,
13924,
14,
199,
774,
315,
14849,
521,
446,
2779,
8491,
436,
10358,
1006,
314,
30744,
5370,
1325,
1630,
440,
3222,
14931,
503,
7389,
13924,
14,
199,
3007,
30247,
1448,
11701,
446,
314,
1704,
10402,
28530,
7858,
12252,
12,
1325,
314,
922,
965,
370,
4107,
1006,
1736,
1053,
10250,
14,
199,
6241,
446,
314,
22166,
7858,
12252,
436,
5847,
16178,
1006,
14931,
436,
13924,
334,
1235,
7437,
25082,
543,
642,
818,
12,
1265,
3984
] |
[
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,
6965,
7653,
13950,
8642,
1014,
921,
11267,
14,
957,
10121,
199,
3,
199,
3,
259,
961,
2240,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
259,
652,
1334,
314,
2895,
402,
314,
1664,
4265,
1696,
1684,
844,
465,
199,
3,
259,
3267,
701,
314,
2868,
2290,
2752,
12,
1902,
1015,
650,
402,
314,
199,
3,
259,
844,
12,
503,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
259,
961,
2240,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
259,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
259,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
199,
3,
259,
1664,
4265,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
259,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
4265,
1696,
1684,
844,
199,
3,
259,
3180,
543,
642,
2240,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
3,
199,
4605,
199,
199,
646,
900,
199,
646,
1300,
772,
199,
646,
7975,
199,
504,
2197,
492,
2197,
199,
504,
22208,
14,
32300,
492,
20599,
199,
504,
4182,
492,
1242,
7416,
199,
504,
5190,
492,
1475,
63,
1971,
199,
504,
984,
492,
3178,
63,
815,
199,
504,
5166,
14,
2537,
14,
3489,
63,
2579,
492,
5048,
63,
2579,
465,
3468,
199,
646,
295,
199,
504,
5166,
14,
10788,
14,
6355,
63,
6833,
492,
6107,
63,
6833,
465,
12392,
199,
199,
504,
5166,
492,
2986,
199,
504,
5166,
14,
4795,
492,
1504,
12,
9506,
199,
504,
5166,
14,
3070,
492,
3795,
63,
3070,
199,
504,
5166,
14,
2537,
14,
5275,
492,
485,
199,
199,
63,
4284,
4100,
275,
469,
272,
283,
8419,
356,
2400,
6252,
26,
20599,
8,
8419,
29,
4284,
395,
272,
283,
4899,
356,
2400,
6252,
26,
20599,
8,
4899,
29,
4284,
395,
272,
283,
16745,
356,
2400,
6252,
26,
20599,
8,
16745,
29,
4284,
395,
272,
283,
18431,
356,
2400,
6252,
26,
20599,
8,
18431,
29,
4284,
395,
199,
93,
199,
199,
7438,
63,
22831,
275,
1543,
57,
3295,
77,
3295,
68,
450,
40,
2689,
45,
2689,
51,
7,
421,
199,
533,
2216,
13800,
63,
17368,
8,
4795,
14,
4795,
304,
272,
485,
354,
275,
298,
1657,
13800,
14,
17368,
2,
272,
485,
1802,
275,
298,
6470,
13800,
24569,
65,
1030,
2,
2286,
347,
485,
835,
63,
13879,
8,
277,
12,
2467,
12,
1747,
12,
2762,
12,
901,
63,
354,
12,
1680,
12,
1067,
29,
403,
304,
267,
522,
275,
1052,
267,
862,
26,
288,
367,
11998,
315,
291,
14,
4570,
8,
1556,
12,
1747,
12,
2762,
12,
1067,
29,
1100,
304,
355,
522,
59,
13879,
14,
344,
61,
275,
822,
8,
13879,
14,
9255,
63,
1580,
9,
267,
871,
26,
7205,
986,
267,
372,
522,
339,
485,
3406,
275,
469,
267,
283,
354,
356,
1504,
14,
1560,
360,
985,
297,
1415,
29,
549,
395,
267,
283,
785,
63,
344,
356,
1504,
14,
3479,
18,
368,
360,
723,
14,
1238,
297,
283,
4031,
297,
1415,
29,
549,
12,
4228,
1720,
628,
23932,
314,
2073,
641,
1314,
1265,
2934,
971,
199,
3749,
22166,
370,
506,
1255,
1288,
267,
283,
3899,
63,
698,
63,
344,
356,
1504,
14,
3479,
18,
368,
360,
723,
14,
1238,
14,
955,
297,
283,
24120,
5024,
297,
4490,
2881,
628,
19412,
1238,
63,
344,
297,
6291,
909,
63,
344,
395,
661,
21002,
297,
6291,
283,
3479,
18,
368,
659,
661,
5690,
297,
6291,
283,
470,
14,
3899,
5440,
401,
4490,
1720,
628,
1918,
4046,
1736,
1744,
911,
506,
10632,
370,
314,
5854,
4048,
370,
314,
2777,
14,
1867,
8179,
298,
3917,
314,
2777,
365,
314,
5854,
6337,
10137,
642,
901,
2701,
14,
1867,
8179,
298,
2765,
365,
2997,
367,
17290,
12901,
12,
4799,
314,
24569,
65,
1030,
21916,
503,
24569,
65,
1030,
21876,
13,
384,
6858,
7651,
267,
283,
3235,
63,
698,
63,
344,
356,
1504,
14,
3479,
18,
368,
360,
723,
14,
1238,
14,
955,
297,
283,
11427,
5024,
297,
4490,
2881,
628,
19412,
1238,
63,
344,
297,
6291,
909,
63,
344,
395,
661,
21002,
297,
283,
262,
297,
788,
1560,
1673,
442,
1673,
3479,
18,
368,
1673,
505,
1673,
5592,
1105,
11472,
4490,
1720,
534,
3917,
663,
12,
642,
901,
911,
1720,
11998,
626,
1736,
315,
298,
889,
15755,
2,
818,
370,
5126,
1557,
1740,
283,
2416,
316,
8545,
5767,
13373,
14,
20046,
5767,
787,
5767,
626,
1172,
314,
2011,
574,
367,
1557,
1740,
283,
3749,
3747,
901,
14,
2104,
2893,
701,
2468,
26056,
314,
298,
2123,
63,
504,
2,
901,
367,
445,
11026,
7005,
9402,
1265,
3955,
7981,
1557,
1740,
283,
24450,
314,
2011,
22166,
370,
314,
2011,
3031,
2287,
4020,
14,
982,
440,
663,
12,
314,
298,
889,
15755,
2,
11998,
1557,
1740,
298,
14117,
1454,
5126,
30090,
314,
2011,
2777,
4020,
340,
652,
19138,
314,
22166,
10889,
14,
1867,
1740,
298,
5903,
16174,
1013,
19816,
1504,
2839,
1318,
955,
12,
9446,
12,
7267,
83,
503,
2849,
20045,
1443,
506,
1202,
7651,
267,
283,
632,
356,
1504,
14,
5592,
8318,
396,
297,
283,
774,
21128,
590,
659,
1816,
661,
396,
63,
3093,
521,
297,
283,
774,
315,
14849,
521,
659,
1816,
661,
9285,
297,
283,
3007,
30247,
1448,
11701,
659,
1816,
661,
2682,
297,
283,
6241,
2665,
639,
283,
1385,
297,
1415,
29,
549,
12,
1720,
29,
971,
199,
624,
774,
446,
2779,
8491,
436,
2112,
1006,
314,
30744,
5370,
334,
7395,
10923,
367,
314,
7339,
641,
19077,
9,
1325,
1630,
440,
3222,
14931,
503,
7389,
13924,
14,
199,
774,
315,
14849,
521,
446,
2779,
8491,
436,
10358,
1006,
314,
30744,
5370,
1325,
1630,
440,
3222,
14931,
503,
7389,
13924,
14,
199,
3007,
30247,
1448,
11701,
446,
314,
1704,
10402,
28530,
7858,
12252,
12,
1325,
314,
922,
965,
370,
4107,
1006,
1736,
1053,
10250,
14,
199,
6241,
446,
314,
22166,
7858,
12252,
436,
5847,
16178,
1006,
14931,
436,
13924,
334,
1235,
7437,
25082,
543,
642,
818,
12,
1265,
3984,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
tashaharrison/dress
|
sites/all/libraries/OpenLayers/tests/selenium/remotecontrol/selenium.py
|
254
|
69389
|
"""
Copyright 2006 ThoughtWorks, 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.
"""
__docformat__ = "restructuredtext en"
# This file has been automatically generated via XSL
import httplib
import urllib
import re
class selenium:
"""
Defines an object that runs Selenium commands.
Element Locators
~~~~~~~~~~~~~~~~
Element Locators tell Selenium which HTML element a command refers to.
The format of a locator is:
\ *locatorType*\ **=**\ \ *argument*
We support the following strategies for locating elements:
* \ **identifier**\ =\ *id*:
Select the element with the specified @id attribute. If no match is
found, select the first element whose @name attribute is \ *id*.
(This is normally the default; see below.)
* \ **id**\ =\ *id*:
Select the element with the specified @id attribute.
* \ **name**\ =\ *name*:
Select the first element with the specified @name attribute.
* username
* name=username
The name may optionally be followed by one or more \ *element-filters*, separated from the name by whitespace. If the \ *filterType* is not specified, \ **value**\ is assumed.
* name=flavour value=chocolate
* \ **dom**\ =\ *javascriptExpression*:
Find an element by evaluating the specified string. This allows you to traverse the HTML Document Object
Model using JavaScript. Note that you must not return a value in this string; simply make it the last expression in the block.
* dom=document.forms['myForm'].myDropdown
* dom=document.images[56]
* dom=function foo() { return document.links[1]; }; foo();
* \ **xpath**\ =\ *xpathExpression*:
Locate an element using an XPath expression.
* xpath=//img[@alt='The image alt text']
* xpath=//table[@id='table1']//tr[4]/td[2]
* xpath=//a[contains(@href,'#id1')]
* xpath=//a[contains(@href,'#id1')]/@class
* xpath=(//table[@class='stylee'])//th[text()='theHeaderText']/../td
* xpath=//input[@name='name2' and @value='yes']
* xpath=//\*[text()="right"]
* \ **link**\ =\ *textPattern*:
Select the link (anchor) element which contains text matching the
specified \ *pattern*.
* link=The link text
* \ **css**\ =\ *cssSelectorSyntax*:
Select the element using css selectors. Please refer to CSS2 selectors, CSS3 selectors for more information. You can also check the TestCssLocators test in the selenium test suite for an example of usage, which is included in the downloaded selenium core package.
* css=a[href="#id3"]
* css=span#firstChild + span
Currently the css selector locator supports all css1, css2 and css3 selectors except namespace in css3, some pseudo classes(:nth-of-type, :nth-last-of-type, :first-of-type, :last-of-type, :only-of-type, :visited, :hover, :active, :focus, :indeterminate) and pseudo elements(::first-line, ::first-letter, ::selection, ::before, ::after).
Without an explicit locator prefix, Selenium uses the following default
strategies:
* \ **dom**\ , for locators starting with "document."
* \ **xpath**\ , for locators starting with "//"
* \ **identifier**\ , otherwise
Element Filters
~~~~~~~~~~~~~~~
Element filters can be used with a locator to refine a list of candidate elements. They are currently used only in the 'name' element-locator.
Filters look much like locators, ie.
\ *filterType*\ **=**\ \ *argument*
Supported element-filters are:
\ **value=**\ \ *valuePattern*
Matches elements based on their values. This is particularly useful for refining a list of similarly-named toggle-buttons.
\ **index=**\ \ *index*
Selects a single element based on its position in the list (offset from zero).
String-match Patterns
~~~~~~~~~~~~~~~~~~~~~
Various Pattern syntaxes are available for matching string values:
* \ **glob:**\ \ *pattern*:
Match a string against a "glob" (aka "wildmat") pattern. "Glob" is a
kind of limited regular-expression syntax typically used in command-line
shells. In a glob pattern, "\*" represents any sequence of characters, and "?"
represents any single character. Glob patterns match against the entire
string.
* \ **regexp:**\ \ *regexp*:
Match a string using a regular-expression. The full power of JavaScript
regular-expressions is available.
* \ **regexpi:**\ \ *regexpi*:
Match a string using a case-insensitive regular-expression.
* \ **exact:**\ \ *string*:
Match a string exactly, verbatim, without any of that fancy wildcard
stuff.
If no pattern prefix is specified, Selenium assumes that it's a "glob"
pattern.
For commands that return multiple values (such as verifySelectOptions),
the string being matched is a comma-separated list of the return values,
where both commas and backslashes in the values are backslash-escaped.
When providing a pattern, the optional matching syntax (i.e. glob,
regexp, etc.) is specified once, as usual, at the beginning of the
pattern.
"""
### This part is hard-coded in the XSL
def __init__(self, host, port, browserStartCommand, browserURL):
self.host = host
self.port = port
self.browserStartCommand = browserStartCommand
self.browserURL = browserURL
self.sessionId = None
def start(self):
result = self.get_string("getNewBrowserSession", [self.browserStartCommand, self.browserURL])
try:
self.sessionId = result
except ValueError:
raise Exception, result
def stop(self):
self.do_command("testComplete", [])
self.sessionId = None
def do_command(self, verb, args):
conn = httplib.HTTPConnection(self.host, self.port)
commandString = u'/selenium-server/driver/?cmd=' + urllib.quote_plus(unicode(verb).encode('utf-8'))
for i in range(len(args)):
commandString = commandString + '&' + unicode(i+1) + '=' + urllib.quote_plus(unicode(args[i]).encode('utf-8'))
if (None != self.sessionId):
commandString = commandString + "&sessionId=" + unicode(self.sessionId)
conn.request("GET", commandString)
response = conn.getresponse()
#print response.status, response.reason
data = unicode(response.read(), "UTF-8")
result = response.reason
#print "Selenium Result: " + repr(data) + "\n\n"
if (not data.startswith('OK')):
raise Exception, data
return data
def get_string(self, verb, args):
result = self.do_command(verb, args)
return result[3:]
def get_string_array(self, verb, args):
csv = self.get_string(verb, args)
token = ""
tokens = []
escape = False
for i in range(len(csv)):
letter = csv[i]
if (escape):
token = token + letter
escape = False
continue
if (letter == '\\'):
escape = True
elif (letter == ','):
tokens.append(token)
token = ""
else:
token = token + letter
tokens.append(token)
return tokens
def get_number(self, verb, args):
# Is there something I need to do here?
return self.get_string(verb, args)
def get_number_array(self, verb, args):
# Is there something I need to do here?
return self.get_string_array(verb, args)
def get_boolean(self, verb, args):
boolstr = self.get_string(verb, args)
if ("true" == boolstr):
return True
if ("false" == boolstr):
return False
raise ValueError, "result is neither 'true' nor 'false': " + boolstr
def get_boolean_array(self, verb, args):
boolarr = self.get_string_array(verb, args)
for i in range(len(boolarr)):
if ("true" == boolstr):
boolarr[i] = True
continue
if ("false" == boolstr):
boolarr[i] = False
continue
raise ValueError, "result is neither 'true' nor 'false': " + boolarr[i]
return boolarr
### From here on, everything's auto-generated from XML
def click(self,locator):
"""
Clicks on a link, button, checkbox or radio button. If the click action
causes a new page to load (like a link usually does), call
waitForPageToLoad.
'locator' is an element locator
"""
self.do_command("click", [locator,])
def double_click(self,locator):
"""
Double clicks on a link, button, checkbox or radio button. If the double click action
causes a new page to load (like a link usually does), call
waitForPageToLoad.
'locator' is an element locator
"""
self.do_command("doubleClick", [locator,])
def context_menu(self,locator):
"""
Simulates opening the context menu for the specified element (as might happen if the user "right-clicked" on the element).
'locator' is an element locator
"""
self.do_command("contextMenu", [locator,])
def click_at(self,locator,coordString):
"""
Clicks on a link, button, checkbox or radio button. If the click action
causes a new page to load (like a link usually does), call
waitForPageToLoad.
'locator' is an element locator
'coordString' is specifies the x,y position (i.e. - 10,20) of the mouse event relative to the element returned by the locator.
"""
self.do_command("clickAt", [locator,coordString,])
def double_click_at(self,locator,coordString):
"""
Doubleclicks on a link, button, checkbox or radio button. If the action
causes a new page to load (like a link usually does), call
waitForPageToLoad.
'locator' is an element locator
'coordString' is specifies the x,y position (i.e. - 10,20) of the mouse event relative to the element returned by the locator.
"""
self.do_command("doubleClickAt", [locator,coordString,])
def context_menu_at(self,locator,coordString):
"""
Simulates opening the context menu for the specified element (as might happen if the user "right-clicked" on the element).
'locator' is an element locator
'coordString' is specifies the x,y position (i.e. - 10,20) of the mouse event relative to the element returned by the locator.
"""
self.do_command("contextMenuAt", [locator,coordString,])
def fire_event(self,locator,eventName):
"""
Explicitly simulate an event, to trigger the corresponding "on\ *event*"
handler.
'locator' is an element locator
'eventName' is the event name, e.g. "focus" or "blur"
"""
self.do_command("fireEvent", [locator,eventName,])
def focus(self,locator):
"""
Move the focus to the specified element; for example, if the element is an input field, move the cursor to that field.
'locator' is an element locator
"""
self.do_command("focus", [locator,])
def key_press(self,locator,keySequence):
"""
Simulates a user pressing and releasing a key.
'locator' is an element locator
'keySequence' is Either be a string("\" followed by the numeric keycode of the key to be pressed, normally the ASCII value of that key), or a single character. For example: "w", "\119".
"""
self.do_command("keyPress", [locator,keySequence,])
def shift_key_down(self):
"""
Press the shift key and hold it down until doShiftUp() is called or a new page is loaded.
"""
self.do_command("shiftKeyDown", [])
def shift_key_up(self):
"""
Release the shift key.
"""
self.do_command("shiftKeyUp", [])
def meta_key_down(self):
"""
Press the meta key and hold it down until doMetaUp() is called or a new page is loaded.
"""
self.do_command("metaKeyDown", [])
def meta_key_up(self):
"""
Release the meta key.
"""
self.do_command("metaKeyUp", [])
def alt_key_down(self):
"""
Press the alt key and hold it down until doAltUp() is called or a new page is loaded.
"""
self.do_command("altKeyDown", [])
def alt_key_up(self):
"""
Release the alt key.
"""
self.do_command("altKeyUp", [])
def control_key_down(self):
"""
Press the control key and hold it down until doControlUp() is called or a new page is loaded.
"""
self.do_command("controlKeyDown", [])
def control_key_up(self):
"""
Release the control key.
"""
self.do_command("controlKeyUp", [])
def key_down(self,locator,keySequence):
"""
Simulates a user pressing a key (without releasing it yet).
'locator' is an element locator
'keySequence' is Either be a string("\" followed by the numeric keycode of the key to be pressed, normally the ASCII value of that key), or a single character. For example: "w", "\119".
"""
self.do_command("keyDown", [locator,keySequence,])
def key_up(self,locator,keySequence):
"""
Simulates a user releasing a key.
'locator' is an element locator
'keySequence' is Either be a string("\" followed by the numeric keycode of the key to be pressed, normally the ASCII value of that key), or a single character. For example: "w", "\119".
"""
self.do_command("keyUp", [locator,keySequence,])
def mouse_over(self,locator):
"""
Simulates a user hovering a mouse over the specified element.
'locator' is an element locator
"""
self.do_command("mouseOver", [locator,])
def mouse_out(self,locator):
"""
Simulates a user moving the mouse pointer away from the specified element.
'locator' is an element locator
"""
self.do_command("mouseOut", [locator,])
def mouse_down(self,locator):
"""
Simulates a user pressing the mouse button (without releasing it yet) on
the specified element.
'locator' is an element locator
"""
self.do_command("mouseDown", [locator,])
def mouse_down_at(self,locator,coordString):
"""
Simulates a user pressing the mouse button (without releasing it yet) at
the specified location.
'locator' is an element locator
'coordString' is specifies the x,y position (i.e. - 10,20) of the mouse event relative to the element returned by the locator.
"""
self.do_command("mouseDownAt", [locator,coordString,])
def mouse_up(self,locator):
"""
Simulates the event that occurs when the user releases the mouse button (i.e., stops
holding the button down) on the specified element.
'locator' is an element locator
"""
self.do_command("mouseUp", [locator,])
def mouse_up_at(self,locator,coordString):
"""
Simulates the event that occurs when the user releases the mouse button (i.e., stops
holding the button down) at the specified location.
'locator' is an element locator
'coordString' is specifies the x,y position (i.e. - 10,20) of the mouse event relative to the element returned by the locator.
"""
self.do_command("mouseUpAt", [locator,coordString,])
def mouse_move(self,locator):
"""
Simulates a user pressing the mouse button (without releasing it yet) on
the specified element.
'locator' is an element locator
"""
self.do_command("mouseMove", [locator,])
def mouse_move_at(self,locator,coordString):
"""
Simulates a user pressing the mouse button (without releasing it yet) on
the specified element.
'locator' is an element locator
'coordString' is specifies the x,y position (i.e. - 10,20) of the mouse event relative to the element returned by the locator.
"""
self.do_command("mouseMoveAt", [locator,coordString,])
def type(self,locator,value):
"""
Sets the value of an input field, as though you typed it in.
Can also be used to set the value of combo boxes, check boxes, etc. In these cases,
value should be the value of the option selected, not the visible text.
'locator' is an element locator
'value' is the value to type
"""
self.do_command("type", [locator,value,])
def type_keys(self,locator,value):
"""
Simulates keystroke events on the specified element, as though you typed the value key-by-key.
This is a convenience method for calling keyDown, keyUp, keyPress for every character in the specified string;
this is useful for dynamic UI widgets (like auto-completing combo boxes) that require explicit key events.
Unlike the simple "type" command, which forces the specified value into the page directly, this command
may or may not have any visible effect, even in cases where typing keys would normally have a visible effect.
For example, if you use "typeKeys" on a form element, you may or may not see the results of what you typed in
the field.
In some cases, you may need to use the simple "type" command to set the value of the field and then the "typeKeys" command to
send the keystroke events corresponding to what you just typed.
'locator' is an element locator
'value' is the value to type
"""
self.do_command("typeKeys", [locator,value,])
def set_speed(self,value):
"""
Set execution speed (i.e., set the millisecond length of a delay which will follow each selenium operation). By default, there is no such delay, i.e.,
the delay is 0 milliseconds.
'value' is the number of milliseconds to pause after operation
"""
self.do_command("setSpeed", [value,])
def get_speed(self):
"""
Get execution speed (i.e., get the millisecond length of the delay following each selenium operation). By default, there is no such delay, i.e.,
the delay is 0 milliseconds.
See also setSpeed.
"""
return self.get_string("getSpeed", [])
def check(self,locator):
"""
Check a toggle-button (checkbox/radio)
'locator' is an element locator
"""
self.do_command("check", [locator,])
def uncheck(self,locator):
"""
Uncheck a toggle-button (checkbox/radio)
'locator' is an element locator
"""
self.do_command("uncheck", [locator,])
def select(self,selectLocator,optionLocator):
"""
Select an option from a drop-down using an option locator.
Option locators provide different ways of specifying options of an HTML
Select element (e.g. for selecting a specific option, or for asserting
that the selected option satisfies a specification). There are several
forms of Select Option Locator.
* \ **label**\ =\ *labelPattern*:
matches options based on their labels, i.e. the visible text. (This
is the default.)
* label=regexp:^[Oo]ther
* \ **value**\ =\ *valuePattern*:
matches options based on their values.
* value=other
* \ **id**\ =\ *id*:
matches options based on their ids.
* id=option1
* \ **index**\ =\ *index*:
matches an option based on its index (offset from zero).
* index=2
If no option locator prefix is provided, the default behaviour is to match on \ **label**\ .
'selectLocator' is an element locator identifying a drop-down menu
'optionLocator' is an option locator (a label by default)
"""
self.do_command("select", [selectLocator,optionLocator,])
def add_selection(self,locator,optionLocator):
"""
Add a selection to the set of selected options in a multi-select element using an option locator.
@see #doSelect for details of option locators
'locator' is an element locator identifying a multi-select box
'optionLocator' is an option locator (a label by default)
"""
self.do_command("addSelection", [locator,optionLocator,])
def remove_selection(self,locator,optionLocator):
"""
Remove a selection from the set of selected options in a multi-select element using an option locator.
@see #doSelect for details of option locators
'locator' is an element locator identifying a multi-select box
'optionLocator' is an option locator (a label by default)
"""
self.do_command("removeSelection", [locator,optionLocator,])
def remove_all_selections(self,locator):
"""
Unselects all of the selected options in a multi-select element.
'locator' is an element locator identifying a multi-select box
"""
self.do_command("removeAllSelections", [locator,])
def submit(self,formLocator):
"""
Submit the specified form. This is particularly useful for forms without
submit buttons, e.g. single-input "Search" forms.
'formLocator' is an element locator for the form you want to submit
"""
self.do_command("submit", [formLocator,])
def open(self,url):
"""
Opens an URL in the test frame. This accepts both relative and absolute
URLs.
The "open" command waits for the page to load before proceeding,
ie. the "AndWait" suffix is implicit.
\ *Note*: The URL must be on the same domain as the runner HTML
due to security restrictions in the browser (Same Origin Policy). If you
need to open an URL on another domain, use the Selenium Server to start a
new browser session on that domain.
'url' is the URL to open; may be relative or absolute
"""
self.do_command("open", [url,])
def open_window(self,url,windowID):
"""
Opens a popup window (if a window with that ID isn't already open).
After opening the window, you'll need to select it using the selectWindow
command.
This command can also be a useful workaround for bug SEL-339. In some cases, Selenium will be unable to intercept a call to window.open (if the call occurs during or before the "onLoad" event, for example).
In those cases, you can force Selenium to notice the open window's name by using the Selenium openWindow command, using
an empty (blank) url, like this: openWindow("", "myFunnyWindow").
'url' is the URL to open, which can be blank
'windowID' is the JavaScript window ID of the window to select
"""
self.do_command("openWindow", [url,windowID,])
def select_window(self,windowID):
"""
Selects a popup window using a window locator; once a popup window has been selected, all
commands go to that window. To select the main window again, use null
as the target.
Window locators provide different ways of specifying the window object:
by title, by internal JavaScript "name," or by JavaScript variable.
* \ **title**\ =\ *My Special Window*:
Finds the window using the text that appears in the title bar. Be careful;
two windows can share the same title. If that happens, this locator will
just pick one.
* \ **name**\ =\ *myWindow*:
Finds the window using its internal JavaScript "name" property. This is the second
parameter "windowName" passed to the JavaScript method window.open(url, windowName, windowFeatures, replaceFlag)
(which Selenium intercepts).
* \ **var**\ =\ *variableName*:
Some pop-up windows are unnamed (anonymous), but are associated with a JavaScript variable name in the current
application window, e.g. "window.foo = window.open(url);". In those cases, you can open the window using
"var=foo".
If no window locator prefix is provided, we'll try to guess what you mean like this:
1.) if windowID is null, (or the string "null") then it is assumed the user is referring to the original window instantiated by the browser).
2.) if the value of the "windowID" parameter is a JavaScript variable name in the current application window, then it is assumed
that this variable contains the return value from a call to the JavaScript window.open() method.
3.) Otherwise, selenium looks in a hash it maintains that maps string names to window "names".
4.) If \ *that* fails, we'll try looping over all of the known windows to try to find the appropriate "title".
Since "title" is not necessarily unique, this may have unexpected behavior.
If you're having trouble figuring out the name of a window that you want to manipulate, look at the Selenium log messages
which identify the names of windows created via window.open (and therefore intercepted by Selenium). You will see messages
like the following for each window as it is opened:
``debug: window.open call intercepted; window ID (which you can use with selectWindow()) is "myNewWindow"``
In some cases, Selenium will be unable to intercept a call to window.open (if the call occurs during or before the "onLoad" event, for example).
(This is bug SEL-339.) In those cases, you can force Selenium to notice the open window's name by using the Selenium openWindow command, using
an empty (blank) url, like this: openWindow("", "myFunnyWindow").
'windowID' is the JavaScript window ID of the window to select
"""
self.do_command("selectWindow", [windowID,])
def select_frame(self,locator):
"""
Selects a frame within the current window. (You may invoke this command
multiple times to select nested frames.) To select the parent frame, use
"relative=parent" as a locator; to select the top frame, use "relative=top".
You can also select a frame by its 0-based index number; select the first frame with
"index=0", or the third frame with "index=2".
You may also use a DOM expression to identify the frame you want directly,
like this: ``dom=frames["main"].frames["subframe"]``
'locator' is an element locator identifying a frame or iframe
"""
self.do_command("selectFrame", [locator,])
def get_whether_this_frame_match_frame_expression(self,currentFrameString,target):
"""
Determine whether current/locator identify the frame containing this running code.
This is useful in proxy injection mode, where this code runs in every
browser frame and window, and sometimes the selenium server needs to identify
the "current" frame. In this case, when the test calls selectFrame, this
routine is called for each frame to figure out which one has been selected.
The selected frame will return true, while all others will return false.
'currentFrameString' is starting frame
'target' is new frame (which might be relative to the current one)
"""
return self.get_boolean("getWhetherThisFrameMatchFrameExpression", [currentFrameString,target,])
def get_whether_this_window_match_window_expression(self,currentWindowString,target):
"""
Determine whether currentWindowString plus target identify the window containing this running code.
This is useful in proxy injection mode, where this code runs in every
browser frame and window, and sometimes the selenium server needs to identify
the "current" window. In this case, when the test calls selectWindow, this
routine is called for each window to figure out which one has been selected.
The selected window will return true, while all others will return false.
'currentWindowString' is starting window
'target' is new window (which might be relative to the current one, e.g., "_parent")
"""
return self.get_boolean("getWhetherThisWindowMatchWindowExpression", [currentWindowString,target,])
def wait_for_pop_up(self,windowID,timeout):
"""
Waits for a popup window to appear and load up.
'windowID' is the JavaScript window "name" of the window that will appear (not the text of the title bar)
'timeout' is a timeout in milliseconds, after which the action will return with an error
"""
self.do_command("waitForPopUp", [windowID,timeout,])
def choose_cancel_on_next_confirmation(self):
"""
By default, Selenium's overridden window.confirm() function will
return true, as if the user had manually clicked OK; after running
this command, the next call to confirm() will return false, as if
the user had clicked Cancel. Selenium will then resume using the
default behavior for future confirmations, automatically returning
true (OK) unless/until you explicitly call this command for each
confirmation.
"""
self.do_command("chooseCancelOnNextConfirmation", [])
def choose_ok_on_next_confirmation(self):
"""
Undo the effect of calling chooseCancelOnNextConfirmation. Note
that Selenium's overridden window.confirm() function will normally automatically
return true, as if the user had manually clicked OK, so you shouldn't
need to use this command unless for some reason you need to change
your mind prior to the next confirmation. After any confirmation, Selenium will resume using the
default behavior for future confirmations, automatically returning
true (OK) unless/until you explicitly call chooseCancelOnNextConfirmation for each
confirmation.
"""
self.do_command("chooseOkOnNextConfirmation", [])
def answer_on_next_prompt(self,answer):
"""
Instructs Selenium to return the specified answer string in response to
the next JavaScript prompt [window.prompt()].
'answer' is the answer to give in response to the prompt pop-up
"""
self.do_command("answerOnNextPrompt", [answer,])
def go_back(self):
"""
Simulates the user clicking the "back" button on their browser.
"""
self.do_command("goBack", [])
def refresh(self):
"""
Simulates the user clicking the "Refresh" button on their browser.
"""
self.do_command("refresh", [])
def close(self):
"""
Simulates the user clicking the "close" button in the titlebar of a popup
window or tab.
"""
self.do_command("close", [])
def is_alert_present(self):
"""
Has an alert occurred?
This function never throws an exception
"""
return self.get_boolean("isAlertPresent", [])
def is_prompt_present(self):
"""
Has a prompt occurred?
This function never throws an exception
"""
return self.get_boolean("isPromptPresent", [])
def is_confirmation_present(self):
"""
Has confirm() been called?
This function never throws an exception
"""
return self.get_boolean("isConfirmationPresent", [])
def get_alert(self):
"""
Retrieves the message of a JavaScript alert generated during the previous action, or fail if there were no alerts.
Getting an alert has the same effect as manually clicking OK. If an
alert is generated but you do not get/verify it, the next Selenium action
will fail.
NOTE: under Selenium, JavaScript alerts will NOT pop up a visible alert
dialog.
NOTE: Selenium does NOT support JavaScript alerts that are generated in a
page's onload() event handler. In this case a visible dialog WILL be
generated and Selenium will hang until someone manually clicks OK.
"""
return self.get_string("getAlert", [])
def get_confirmation(self):
"""
Retrieves the message of a JavaScript confirmation dialog generated during
the previous action.
By default, the confirm function will return true, having the same effect
as manually clicking OK. This can be changed by prior execution of the
chooseCancelOnNextConfirmation command. If an confirmation is generated
but you do not get/verify it, the next Selenium action will fail.
NOTE: under Selenium, JavaScript confirmations will NOT pop up a visible
dialog.
NOTE: Selenium does NOT support JavaScript confirmations that are
generated in a page's onload() event handler. In this case a visible
dialog WILL be generated and Selenium will hang until you manually click
OK.
"""
return self.get_string("getConfirmation", [])
def get_prompt(self):
"""
Retrieves the message of a JavaScript question prompt dialog generated during
the previous action.
Successful handling of the prompt requires prior execution of the
answerOnNextPrompt command. If a prompt is generated but you
do not get/verify it, the next Selenium action will fail.
NOTE: under Selenium, JavaScript prompts will NOT pop up a visible
dialog.
NOTE: Selenium does NOT support JavaScript prompts that are generated in a
page's onload() event handler. In this case a visible dialog WILL be
generated and Selenium will hang until someone manually clicks OK.
"""
return self.get_string("getPrompt", [])
def get_location(self):
"""
Gets the absolute URL of the current page.
"""
return self.get_string("getLocation", [])
def get_title(self):
"""
Gets the title of the current page.
"""
return self.get_string("getTitle", [])
def get_body_text(self):
"""
Gets the entire text of the page.
"""
return self.get_string("getBodyText", [])
def get_value(self,locator):
"""
Gets the (whitespace-trimmed) value of an input field (or anything else with a value parameter).
For checkbox/radio elements, the value will be "on" or "off" depending on
whether the element is checked or not.
'locator' is an element locator
"""
return self.get_string("getValue", [locator,])
def get_text(self,locator):
"""
Gets the text of an element. This works for any element that contains
text. This command uses either the textContent (Mozilla-like browsers) or
the innerText (IE-like browsers) of the element, which is the rendered
text shown to the user.
'locator' is an element locator
"""
return self.get_string("getText", [locator,])
def highlight(self,locator):
"""
Briefly changes the backgroundColor of the specified element yellow. Useful for debugging.
'locator' is an element locator
"""
self.do_command("highlight", [locator,])
def get_eval(self,script):
"""
Gets the result of evaluating the specified JavaScript snippet. The snippet may
have multiple lines, but only the result of the last line will be returned.
Note that, by default, the snippet will run in the context of the "selenium"
object itself, so ``this`` will refer to the Selenium object. Use ``window`` to
refer to the window of your application, e.g. ``window.document.getElementById('foo')``
If you need to use
a locator to refer to a single element in your application page, you can
use ``this.browserbot.findElement("id=foo")`` where "id=foo" is your locator.
'script' is the JavaScript snippet to run
"""
return self.get_string("getEval", [script,])
def is_checked(self,locator):
"""
Gets whether a toggle-button (checkbox/radio) is checked. Fails if the specified element doesn't exist or isn't a toggle-button.
'locator' is an element locator pointing to a checkbox or radio button
"""
return self.get_boolean("isChecked", [locator,])
def get_table(self,tableCellAddress):
"""
Gets the text from a cell of a table. The cellAddress syntax
tableLocator.row.column, where row and column start at 0.
'tableCellAddress' is a cell address, e.g. "foo.1.4"
"""
return self.get_string("getTable", [tableCellAddress,])
def get_selected_labels(self,selectLocator):
"""
Gets all option labels (visible text) for selected options in the specified select or multi-select element.
'selectLocator' is an element locator identifying a drop-down menu
"""
return self.get_string_array("getSelectedLabels", [selectLocator,])
def get_selected_label(self,selectLocator):
"""
Gets option label (visible text) for selected option in the specified select element.
'selectLocator' is an element locator identifying a drop-down menu
"""
return self.get_string("getSelectedLabel", [selectLocator,])
def get_selected_values(self,selectLocator):
"""
Gets all option values (value attributes) for selected options in the specified select or multi-select element.
'selectLocator' is an element locator identifying a drop-down menu
"""
return self.get_string_array("getSelectedValues", [selectLocator,])
def get_selected_value(self,selectLocator):
"""
Gets option value (value attribute) for selected option in the specified select element.
'selectLocator' is an element locator identifying a drop-down menu
"""
return self.get_string("getSelectedValue", [selectLocator,])
def get_selected_indexes(self,selectLocator):
"""
Gets all option indexes (option number, starting at 0) for selected options in the specified select or multi-select element.
'selectLocator' is an element locator identifying a drop-down menu
"""
return self.get_string_array("getSelectedIndexes", [selectLocator,])
def get_selected_index(self,selectLocator):
"""
Gets option index (option number, starting at 0) for selected option in the specified select element.
'selectLocator' is an element locator identifying a drop-down menu
"""
return self.get_string("getSelectedIndex", [selectLocator,])
def get_selected_ids(self,selectLocator):
"""
Gets all option element IDs for selected options in the specified select or multi-select element.
'selectLocator' is an element locator identifying a drop-down menu
"""
return self.get_string_array("getSelectedIds", [selectLocator,])
def get_selected_id(self,selectLocator):
"""
Gets option element ID for selected option in the specified select element.
'selectLocator' is an element locator identifying a drop-down menu
"""
return self.get_string("getSelectedId", [selectLocator,])
def is_something_selected(self,selectLocator):
"""
Determines whether some option in a drop-down menu is selected.
'selectLocator' is an element locator identifying a drop-down menu
"""
return self.get_boolean("isSomethingSelected", [selectLocator,])
def get_select_options(self,selectLocator):
"""
Gets all option labels in the specified select drop-down.
'selectLocator' is an element locator identifying a drop-down menu
"""
return self.get_string_array("getSelectOptions", [selectLocator,])
def get_attribute(self,attributeLocator):
"""
Gets the value of an element attribute. The value of the attribute may
differ across browsers (this is the case for the "style" attribute, for
example).
'attributeLocator' is an element locator followed by an @ sign and then the name of the attribute, e.g. "foo@bar"
"""
return self.get_string("getAttribute", [attributeLocator,])
def is_text_present(self,pattern):
"""
Verifies that the specified text pattern appears somewhere on the rendered page shown to the user.
'pattern' is a pattern to match with the text of the page
"""
return self.get_boolean("isTextPresent", [pattern,])
def is_element_present(self,locator):
"""
Verifies that the specified element is somewhere on the page.
'locator' is an element locator
"""
return self.get_boolean("isElementPresent", [locator,])
def is_visible(self,locator):
"""
Determines if the specified element is visible. An
element can be rendered invisible by setting the CSS "visibility"
property to "hidden", or the "display" property to "none", either for the
element itself or one if its ancestors. This method will fail if
the element is not present.
'locator' is an element locator
"""
return self.get_boolean("isVisible", [locator,])
def is_editable(self,locator):
"""
Determines whether the specified input element is editable, ie hasn't been disabled.
This method will fail if the specified element isn't an input element.
'locator' is an element locator
"""
return self.get_boolean("isEditable", [locator,])
def get_all_buttons(self):
"""
Returns the IDs of all buttons on the page.
If a given button has no ID, it will appear as "" in this array.
"""
return self.get_string_array("getAllButtons", [])
def get_all_links(self):
"""
Returns the IDs of all links on the page.
If a given link has no ID, it will appear as "" in this array.
"""
return self.get_string_array("getAllLinks", [])
def get_all_fields(self):
"""
Returns the IDs of all input fields on the page.
If a given field has no ID, it will appear as "" in this array.
"""
return self.get_string_array("getAllFields", [])
def get_attribute_from_all_windows(self,attributeName):
"""
Returns every instance of some attribute from all known windows.
'attributeName' is name of an attribute on the windows
"""
return self.get_string_array("getAttributeFromAllWindows", [attributeName,])
def dragdrop(self,locator,movementsString):
"""
deprecated - use dragAndDrop instead
'locator' is an element locator
'movementsString' is offset in pixels from the current location to which the element should be moved, e.g., "+70,-300"
"""
self.do_command("dragdrop", [locator,movementsString,])
def set_mouse_speed(self,pixels):
"""
Configure the number of pixels between "mousemove" events during dragAndDrop commands (default=10).
Setting this value to 0 means that we'll send a "mousemove" event to every single pixel
in between the start location and the end location; that can be very slow, and may
cause some browsers to force the JavaScript to timeout.
If the mouse speed is greater than the distance between the two dragged objects, we'll
just send one "mousemove" at the start location and then one final one at the end location.
'pixels' is the number of pixels between "mousemove" events
"""
self.do_command("setMouseSpeed", [pixels,])
def get_mouse_speed(self):
"""
Returns the number of pixels between "mousemove" events during dragAndDrop commands (default=10).
"""
return self.get_number("getMouseSpeed", [])
def drag_and_drop(self,locator,movementsString):
"""
Drags an element a certain distance and then drops it
'locator' is an element locator
'movementsString' is offset in pixels from the current location to which the element should be moved, e.g., "+70,-300"
"""
self.do_command("dragAndDrop", [locator,movementsString,])
def drag_and_drop_to_object(self,locatorOfObjectToBeDragged,locatorOfDragDestinationObject):
"""
Drags an element and drops it on another element
'locatorOfObjectToBeDragged' is an element to be dragged
'locatorOfDragDestinationObject' is an element whose location (i.e., whose center-most pixel) will be the point where locatorOfObjectToBeDragged is dropped
"""
self.do_command("dragAndDropToObject", [locatorOfObjectToBeDragged,locatorOfDragDestinationObject,])
def window_focus(self):
"""
Gives focus to the currently selected window
"""
self.do_command("windowFocus", [])
def window_maximize(self):
"""
Resize currently selected window to take up the entire screen
"""
self.do_command("windowMaximize", [])
def get_all_window_ids(self):
"""
Returns the IDs of all windows that the browser knows about.
"""
return self.get_string_array("getAllWindowIds", [])
def get_all_window_names(self):
"""
Returns the names of all windows that the browser knows about.
"""
return self.get_string_array("getAllWindowNames", [])
def get_all_window_titles(self):
"""
Returns the titles of all windows that the browser knows about.
"""
return self.get_string_array("getAllWindowTitles", [])
def get_html_source(self):
"""
Returns the entire HTML source between the opening and
closing "html" tags.
"""
return self.get_string("getHtmlSource", [])
def set_cursor_position(self,locator,position):
"""
Moves the text cursor to the specified position in the given input element or textarea.
This method will fail if the specified element isn't an input element or textarea.
'locator' is an element locator pointing to an input element or textarea
'position' is the numerical position of the cursor in the field; position should be 0 to move the position to the beginning of the field. You can also set the cursor to -1 to move it to the end of the field.
"""
self.do_command("setCursorPosition", [locator,position,])
def get_element_index(self,locator):
"""
Get the relative index of an element to its parent (starting from 0). The comment node and empty text node
will be ignored.
'locator' is an element locator pointing to an element
"""
return self.get_number("getElementIndex", [locator,])
def is_ordered(self,locator1,locator2):
"""
Check if these two elements have same parent and are ordered siblings in the DOM. Two same elements will
not be considered ordered.
'locator1' is an element locator pointing to the first element
'locator2' is an element locator pointing to the second element
"""
return self.get_boolean("isOrdered", [locator1,locator2,])
def get_element_position_left(self,locator):
"""
Retrieves the horizontal position of an element
'locator' is an element locator pointing to an element OR an element itself
"""
return self.get_number("getElementPositionLeft", [locator,])
def get_element_position_top(self,locator):
"""
Retrieves the vertical position of an element
'locator' is an element locator pointing to an element OR an element itself
"""
return self.get_number("getElementPositionTop", [locator,])
def get_element_width(self,locator):
"""
Retrieves the width of an element
'locator' is an element locator pointing to an element
"""
return self.get_number("getElementWidth", [locator,])
def get_element_height(self,locator):
"""
Retrieves the height of an element
'locator' is an element locator pointing to an element
"""
return self.get_number("getElementHeight", [locator,])
def get_cursor_position(self,locator):
"""
Retrieves the text cursor position in the given input element or textarea; beware, this may not work perfectly on all browsers.
Specifically, if the cursor/selection has been cleared by JavaScript, this command will tend to
return the position of the last location of the cursor, even though the cursor is now gone from the page. This is filed as SEL-243.
This method will fail if the specified element isn't an input element or textarea, or there is no cursor in the element.
'locator' is an element locator pointing to an input element or textarea
"""
return self.get_number("getCursorPosition", [locator,])
def get_expression(self,expression):
"""
Returns the specified expression.
This is useful because of JavaScript preprocessing.
It is used to generate commands like assertExpression and waitForExpression.
'expression' is the value to return
"""
return self.get_string("getExpression", [expression,])
def get_xpath_count(self,xpath):
"""
Returns the number of nodes that match the specified xpath, eg. "//table" would give
the number of tables.
'xpath' is the xpath expression to evaluate. do NOT wrap this expression in a 'count()' function; we will do that for you.
"""
return self.get_number("getXpathCount", [xpath,])
def assign_id(self,locator,identifier):
"""
Temporarily sets the "id" attribute of the specified element, so you can locate it in the future
using its ID rather than a slow/complicated XPath. This ID will disappear once the page is
reloaded.
'locator' is an element locator pointing to an element
'identifier' is a string to be used as the ID of the specified element
"""
self.do_command("assignId", [locator,identifier,])
def allow_native_xpath(self,allow):
"""
Specifies whether Selenium should use the native in-browser implementation
of XPath (if any native version is available); if you pass "false" to
this function, we will always use our pure-JavaScript xpath library.
Using the pure-JS xpath library can improve the consistency of xpath
element locators between different browser vendors, but the pure-JS
version is much slower than the native implementations.
'allow' is boolean, true means we'll prefer to use native XPath; false means we'll only use JS XPath
"""
self.do_command("allowNativeXpath", [allow,])
def ignore_attributes_without_value(self,ignore):
"""
Specifies whether Selenium will ignore xpath attributes that have no
value, i.e. are the empty string, when using the non-native xpath
evaluation engine. You'd want to do this for performance reasons in IE.
However, this could break certain xpaths, for example an xpath that looks
for an attribute whose value is NOT the empty string.
The hope is that such xpaths are relatively rare, but the user should
have the option of using them. Note that this only influences xpath
evaluation when using the ajaxslt engine (i.e. not "javascript-xpath").
'ignore' is boolean, true means we'll ignore attributes without value at the expense of xpath "correctness"; false means we'll sacrifice speed for correctness.
"""
self.do_command("ignoreAttributesWithoutValue", [ignore,])
def wait_for_condition(self,script,timeout):
"""
Runs the specified JavaScript snippet repeatedly until it evaluates to "true".
The snippet may have multiple lines, but only the result of the last line
will be considered.
Note that, by default, the snippet will be run in the runner's test window, not in the window
of your application. To get the window of your application, you can use
the JavaScript snippet ``selenium.browserbot.getCurrentWindow()``, and then
run your JavaScript in there
'script' is the JavaScript snippet to run
'timeout' is a timeout in milliseconds, after which this command will return with an error
"""
self.do_command("waitForCondition", [script,timeout,])
def set_timeout(self,timeout):
"""
Specifies the amount of time that Selenium will wait for actions to complete.
Actions that require waiting include "open" and the "waitFor\*" actions.
The default timeout is 30 seconds.
'timeout' is a timeout in milliseconds, after which the action will return with an error
"""
self.do_command("setTimeout", [timeout,])
def wait_for_page_to_load(self,timeout):
"""
Waits for a new page to load.
You can use this command instead of the "AndWait" suffixes, "clickAndWait", "selectAndWait", "typeAndWait" etc.
(which are only available in the JS API).
Selenium constantly keeps track of new pages loading, and sets a "newPageLoaded"
flag when it first notices a page load. Running any other Selenium command after
turns the flag to false. Hence, if you want to wait for a page to load, you must
wait immediately after a Selenium command that caused a page-load.
'timeout' is a timeout in milliseconds, after which this command will return with an error
"""
self.do_command("waitForPageToLoad", [timeout,])
def wait_for_frame_to_load(self,frameAddress,timeout):
"""
Waits for a new frame to load.
Selenium constantly keeps track of new pages and frames loading,
and sets a "newPageLoaded" flag when it first notices a page load.
See waitForPageToLoad for more information.
'frameAddress' is FrameAddress from the server side
'timeout' is a timeout in milliseconds, after which this command will return with an error
"""
self.do_command("waitForFrameToLoad", [frameAddress,timeout,])
def get_cookie(self):
"""
Return all cookies of the current page under test.
"""
return self.get_string("getCookie", [])
def get_cookie_by_name(self,name):
"""
Returns the value of the cookie with the specified name, or throws an error if the cookie is not present.
'name' is the name of the cookie
"""
return self.get_string("getCookieByName", [name,])
def is_cookie_present(self,name):
"""
Returns true if a cookie with the specified name is present, or false otherwise.
'name' is the name of the cookie
"""
return self.get_boolean("isCookiePresent", [name,])
def create_cookie(self,nameValuePair,optionsString):
"""
Create a new cookie whose path and domain are same with those of current page
under test, unless you specified a path for this cookie explicitly.
'nameValuePair' is name and value of the cookie in a format "name=value"
'optionsString' is options for the cookie. Currently supported options include 'path', 'max_age' and 'domain'. the optionsString's format is "path=/path/, max_age=60, domain=.foo.com". The order of options are irrelevant, the unit of the value of 'max_age' is second. Note that specifying a domain that isn't a subset of the current domain will usually fail.
"""
self.do_command("createCookie", [nameValuePair,optionsString,])
def delete_cookie(self,name,optionsString):
"""
Delete a named cookie with specified path and domain. Be careful; to delete a cookie, you
need to delete it using the exact same path and domain that were used to create the cookie.
If the path is wrong, or the domain is wrong, the cookie simply won't be deleted. Also
note that specifying a domain that isn't a subset of the current domain will usually fail.
Since there's no way to discover at runtime the original path and domain of a given cookie,
we've added an option called 'recurse' to try all sub-domains of the current domain with
all paths that are a subset of the current path. Beware; this option can be slow. In
big-O notation, it operates in O(n\*m) time, where n is the number of dots in the domain
name and m is the number of slashes in the path.
'name' is the name of the cookie to be deleted
'optionsString' is options for the cookie. Currently supported options include 'path', 'domain' and 'recurse.' The optionsString's format is "path=/path/, domain=.foo.com, recurse=true". The order of options are irrelevant. Note that specifying a domain that isn't a subset of the current domain will usually fail.
"""
self.do_command("deleteCookie", [name,optionsString,])
def delete_all_visible_cookies(self):
"""
Calls deleteCookie with recurse=true on all cookies visible to the current page.
As noted on the documentation for deleteCookie, recurse=true can be much slower
than simply deleting the cookies using a known domain/path.
"""
self.do_command("deleteAllVisibleCookies", [])
def set_browser_log_level(self,logLevel):
"""
Sets the threshold for browser-side logging messages; log messages beneath this threshold will be discarded.
Valid logLevel strings are: "debug", "info", "warn", "error" or "off".
To see the browser logs, you need to
either show the log window in GUI mode, or enable browser-side logging in Selenium RC.
'logLevel' is one of the following: "debug", "info", "warn", "error" or "off"
"""
self.do_command("setBrowserLogLevel", [logLevel,])
def run_script(self,script):
"""
Creates a new "script" tag in the body of the current test window, and
adds the specified text into the body of the command. Scripts run in
this way can often be debugged more easily than scripts executed using
Selenium's "getEval" command. Beware that JS exceptions thrown in these script
tags aren't managed by Selenium, so you should probably wrap your script
in try/catch blocks if there is any chance that the script will throw
an exception.
'script' is the JavaScript snippet to run
"""
self.do_command("runScript", [script,])
def add_location_strategy(self,strategyName,functionDefinition):
"""
Defines a new function for Selenium to locate elements on the page.
For example,
if you define the strategy "foo", and someone runs click("foo=blah"), we'll
run your function, passing you the string "blah", and click on the element
that your function
returns, or throw an "Element not found" error if your function returns null.
We'll pass three arguments to your function:
* locator: the string the user passed in
* inWindow: the currently selected window
* inDocument: the currently selected document
The function must return null if the element can't be found.
'strategyName' is the name of the strategy to define; this should use only letters [a-zA-Z] with no spaces or other punctuation.
'functionDefinition' is a string defining the body of a function in JavaScript. For example: ``return inDocument.getElementById(locator);``
"""
self.do_command("addLocationStrategy", [strategyName,functionDefinition,])
def capture_entire_page_screenshot(self,filename):
"""
Saves the entire contents of the current window canvas to a PNG file.
Currently this only works in Mozilla and when running in chrome mode.
Contrast this with the captureScreenshot command, which captures the
contents of the OS viewport (i.e. whatever is currently being displayed
on the monitor), and is implemented in the RC only. Implementation
mostly borrowed from the Screengrab! Firefox extension. Please see
http://www.screengrab.org for details.
'filename' is the path to the file to persist the screenshot as. No filename extension will be appended by default. Directories will not be created if they do not exist, and an exception will be thrown, possibly by native code.
"""
self.do_command("captureEntirePageScreenshot", [filename,])
def set_context(self,context):
"""
Writes a message to the status bar and adds a note to the browser-side
log.
'context' is the message to be sent to the browser
"""
self.do_command("setContext", [context,])
def attach_file(self,fieldLocator,fileLocator):
"""
Sets a file input (upload) field to the file listed in fileLocator
'fieldLocator' is an element locator
'fileLocator' is a URL pointing to the specified file. Before the file can be set in the input field (fieldLocator), Selenium RC may need to transfer the file to the local machine before attaching the file in a web page form. This is common in selenium grid configurations where the RC server driving the browser is not the same machine that started the test. Supported Browsers: Firefox ("\*chrome") only.
"""
self.do_command("attachFile", [fieldLocator,fileLocator,])
def capture_screenshot(self,filename):
"""
Captures a PNG screenshot to the specified file.
'filename' is the absolute path to the file to be written, e.g. "c:\blah\screenshot.png"
"""
self.do_command("captureScreenshot", [filename,])
def shut_down_selenium_server(self):
"""
Kills the running Selenium Server and all browser sessions. After you run this command, you will no longer be able to send
commands to the server; you can't remotely start the server once it has been stopped. Normally
you should prefer to run the "stop" command, which terminates the current browser session, rather than
shutting down the entire server.
"""
self.do_command("shutDownSeleniumServer", [])
def key_down_native(self,keycode):
"""
Simulates a user pressing a key (without releasing it yet) by sending a native operating system keystroke.
This function uses the java.awt.Robot class to send a keystroke; this more accurately simulates typing
a key on the keyboard. It does not honor settings from the shiftKeyDown, controlKeyDown, altKeyDown and
metaKeyDown commands, and does not target any particular HTML element. To send a keystroke to a particular
element, focus on the element first before running this command.
'keycode' is an integer keycode number corresponding to a java.awt.event.KeyEvent; note that Java keycodes are NOT the same thing as JavaScript keycodes!
"""
self.do_command("keyDownNative", [keycode,])
def key_up_native(self,keycode):
"""
Simulates a user releasing a key by sending a native operating system keystroke.
This function uses the java.awt.Robot class to send a keystroke; this more accurately simulates typing
a key on the keyboard. It does not honor settings from the shiftKeyDown, controlKeyDown, altKeyDown and
metaKeyDown commands, and does not target any particular HTML element. To send a keystroke to a particular
element, focus on the element first before running this command.
'keycode' is an integer keycode number corresponding to a java.awt.event.KeyEvent; note that Java keycodes are NOT the same thing as JavaScript keycodes!
"""
self.do_command("keyUpNative", [keycode,])
def key_press_native(self,keycode):
"""
Simulates a user pressing and releasing a key by sending a native operating system keystroke.
This function uses the java.awt.Robot class to send a keystroke; this more accurately simulates typing
a key on the keyboard. It does not honor settings from the shiftKeyDown, controlKeyDown, altKeyDown and
metaKeyDown commands, and does not target any particular HTML element. To send a keystroke to a particular
element, focus on the element first before running this command.
'keycode' is an integer keycode number corresponding to a java.awt.event.KeyEvent; note that Java keycodes are NOT the same thing as JavaScript keycodes!
"""
self.do_command("keyPressNative", [keycode,])
|
gpl-2.0
|
[
199,
624,
199,
7384,
8315,
18049,
10846,
25348,
12,
3277,
14,
199,
199,
31661,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
199,
13297,
1443,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
199,
5556,
1443,
3332,
282,
1331,
402,
314,
844,
737,
339,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
199,
5524,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
16832,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
199,
29946,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
199,
9295,
314,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
199,
3097,
1298,
1334,
314,
844,
14,
199,
624,
199,
363,
21841,
363,
275,
298,
26854,
655,
2,
199,
199,
3,
961,
570,
965,
2757,
5847,
4046,
4799,
1323,
4929,
199,
199,
646,
8809,
199,
646,
4011,
199,
646,
295,
199,
199,
533,
19481,
26,
272,
408,
272,
25022,
376,
909,
626,
7858,
3240,
9465,
3718,
14,
2286,
6566,
6263,
2750,
272,
18294,
2286,
6566,
6263,
2750,
11480,
3240,
9465,
1314,
4163,
1819,
282,
1414,
15724,
370,
14,
272,
710,
1475,
402,
282,
14067,
365,
26,
2286,
971,
627,
6354,
804,
7590,
1011,
29,
23262,
971,
627,
2094,
10,
17635,
2136,
2291,
314,
2569,
32647,
367,
4355,
1958,
4008,
26,
17635,
627,
257,
971,
1011,
5364,
23262,
26447,
627,
344,
19429,
4960,
9496,
314,
1819,
543,
314,
2013,
768,
344,
2225,
14,
982,
949,
1336,
365,
267,
1911,
12,
3504,
314,
1642,
1819,
7447,
768,
354,
2225,
365,
971,
627,
344,
4856,
267,
334,
2765,
365,
12252,
314,
849,
27,
1937,
5084,
4959,
272,
627,
257,
971,
1011,
344,
23262,
26447,
627,
344,
19429,
267,
9496,
314,
1819,
543,
314,
2013,
768,
344,
2225,
14,
272,
627,
257,
971,
1011,
354,
23262,
26447,
627,
354,
19429,
267,
9496,
314,
1642,
1819,
543,
314,
2013,
768,
354,
2225,
14,
2728,
627,
257,
3434,
267,
627,
257,
536,
29,
2473,
30712,
710,
536,
1443,
14190,
506,
9437,
701,
1373,
503,
1655,
971,
627,
2108,
13,
4273,
10381,
11673,
687,
314,
536,
701,
8139,
14,
221,
982,
314,
971,
627,
1541,
804,
10,
365,
440,
2013,
12,
971,
1011,
585,
23262,
221,
365,
10826,
14,
2728,
627,
257,
536,
29,
70,
3783,
567,
574,
29,
2239,
331,
750,
268,
5493,
627,
257,
971,
1011,
4556,
23262,
26447,
627,
9554,
9093,
19429,
221,
2728,
6668,
376,
1819,
701,
27083,
314,
2013,
1059,
14,
221,
961,
6127,
1265,
370,
24749,
314,
4163,
7543,
6935,
267,
5822,
1808,
15250,
14,
221,
3390,
626,
1265,
1471,
440,
372,
282,
574,
315,
642,
1059,
27,
9329,
1852,
652,
314,
2061,
3965,
315,
314,
1853,
14,
2728,
627,
257,
8266,
29,
3554,
14,
3351,
459,
1662,
2821,
2278,
1662,
11070,
2110,
267,
627,
257,
8266,
29,
3554,
14,
4782,
59,
1367,
61,
267,
627,
257,
8266,
29,
1593,
3925,
342,
469,
372,
2213,
14,
4614,
59,
17,
11566,
16735,
3925,
7303,
268,
5493,
627,
257,
971,
1011,
8006,
23262,
26447,
627,
8006,
9093,
19429,
4960,
6263,
323,
376,
1819,
1808,
376,
1323,
2042,
3965,
14,
2728,
627,
257,
14462,
29,
501,
4060,
14251,
4478,
534,
1918,
1834,
8791,
1318,
418,
267,
627,
257,
14462,
29,
501,
1224,
14251,
344,
534,
1224,
17,
418,
501,
454,
59,
20,
12978,
2076,
59,
18,
61,
267,
627,
257,
14462,
29,
501,
65,
59,
6134,
8,
32,
6399,
2584,
3,
344,
17,
5440,
267,
627,
257,
14462,
29,
501,
65,
59,
6134,
8,
32,
6399,
2584,
3,
344,
17,
5440,
15,
32,
533,
267,
627,
257,
14462,
2687,
501,
1224,
14251,
533,
534,
2487,
69,
1105,
501,
273,
59,
505,
342,
534,
1589,
2567,
1872,
28178,
5093,
2076,
267,
627,
257,
14462,
29,
501,
1210,
14251,
354,
534,
354,
18,
7,
436,
768,
585,
534,
5066,
418,
267,
627,
257,
14462,
29,
501,
60,
23033,
505,
342,
628,
1019,
937,
268,
5493,
627,
257,
971,
1011,
1073,
23262,
26447,
627,
505,
9959,
19429,
267,
9496,
314,
2142,
334,
11498,
9,
1819,
1314,
3509,
1318,
4877,
314,
267,
2013,
971,
627,
3401,
4856,
2728,
627,
257,
2142,
29,
1918,
2142,
1318,
268,
5493,
627,
257,
971,
1011,
3919,
23262,
26447,
627,
3919,
11212,
16626,
19429,
267,
9496,
314,
1819,
1808,
11431,
9759,
83,
14,
7754,
10618,
370,
15750,
18,
9759,
83,
12,
15750,
19,
9759,
83,
367,
1655,
2556,
14,
2047,
883,
2597,
1104,
314,
1379,
35,
385,
3040,
2750,
511,
315,
314,
19481,
511,
5241,
367,
376,
2893,
402,
4503,
12,
1314,
365,
5120,
315,
314,
13557,
19481,
6170,
2559,
14,
2728,
627,
257,
11431,
29,
65,
59,
6399,
13476,
344,
19,
937,
267,
627,
257,
11431,
29,
3751,
3,
22262,
435,
13598,
30712,
13550,
314,
11431,
9759,
14067,
5171,
1006,
11431,
17,
12,
11431,
18,
436,
11431,
19,
9759,
83,
871,
3231,
315,
11431,
19,
12,
2005,
15984,
3992,
8,
26,
16621,
13,
1618,
13,
466,
12,
520,
16621,
13,
2019,
13,
1618,
13,
466,
12,
520,
2246,
13,
1618,
13,
466,
12,
520,
2019,
13,
1618,
13,
466,
12,
520,
2118,
13,
1618,
13,
466,
12,
520,
21736,
12,
520,
22797,
12,
520,
2682,
12,
520,
12283,
12,
520,
262,
271,
14478,
9,
436,
15984,
4008,
8,
447,
2246,
13,
604,
12,
3800,
2246,
13,
9269,
12,
3800,
5592,
12,
3800,
5182,
12,
3800,
4399,
680,
221,
268,
1362,
17635,
23952,
376,
5027,
14067,
2403,
12,
3240,
9465,
4440,
314,
2569,
849,
272,
32647,
26,
17635,
627,
257,
971,
1011,
4556,
23262,
2360,
367,
4355,
2750,
6617,
543,
298,
3554,
2122,
272,
627,
257,
971,
1011,
8006,
23262,
2360,
367,
4355,
2750,
6617,
543,
23057,
2,
272,
627,
257,
971,
1011,
5364,
23262,
2360,
4257,
2286,
6566,
21240,
272,
32202,
23597,
2286,
6566,
4766,
883,
506,
1202,
543,
282,
14067,
370,
2984,
1132,
282,
769,
402,
7627,
4008,
14,
221,
9322,
787,
5544,
1202,
1454,
315,
314,
283,
354,
7,
1819,
13,
6354,
14,
2286,
21240,
3648,
8298,
2839,
4355,
2750,
12,
13446,
14,
2286,
971,
627,
1541,
804,
7590,
1011,
29,
23262,
971,
627,
2094,
10,
2286,
26167,
1819,
13,
4273,
787
] |
[
624,
199,
7384,
8315,
18049,
10846,
25348,
12,
3277,
14,
199,
199,
31661,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
199,
13297,
1443,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
199,
5556,
1443,
3332,
282,
1331,
402,
314,
844,
737,
339,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
199,
5524,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
16832,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
199,
29946,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
199,
9295,
314,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
199,
3097,
1298,
1334,
314,
844,
14,
199,
624,
199,
363,
21841,
363,
275,
298,
26854,
655,
2,
199,
199,
3,
961,
570,
965,
2757,
5847,
4046,
4799,
1323,
4929,
199,
199,
646,
8809,
199,
646,
4011,
199,
646,
295,
199,
199,
533,
19481,
26,
272,
408,
272,
25022,
376,
909,
626,
7858,
3240,
9465,
3718,
14,
2286,
6566,
6263,
2750,
272,
18294,
2286,
6566,
6263,
2750,
11480,
3240,
9465,
1314,
4163,
1819,
282,
1414,
15724,
370,
14,
272,
710,
1475,
402,
282,
14067,
365,
26,
2286,
971,
627,
6354,
804,
7590,
1011,
29,
23262,
971,
627,
2094,
10,
17635,
2136,
2291,
314,
2569,
32647,
367,
4355,
1958,
4008,
26,
17635,
627,
257,
971,
1011,
5364,
23262,
26447,
627,
344,
19429,
4960,
9496,
314,
1819,
543,
314,
2013,
768,
344,
2225,
14,
982,
949,
1336,
365,
267,
1911,
12,
3504,
314,
1642,
1819,
7447,
768,
354,
2225,
365,
971,
627,
344,
4856,
267,
334,
2765,
365,
12252,
314,
849,
27,
1937,
5084,
4959,
272,
627,
257,
971,
1011,
344,
23262,
26447,
627,
344,
19429,
267,
9496,
314,
1819,
543,
314,
2013,
768,
344,
2225,
14,
272,
627,
257,
971,
1011,
354,
23262,
26447,
627,
354,
19429,
267,
9496,
314,
1642,
1819,
543,
314,
2013,
768,
354,
2225,
14,
2728,
627,
257,
3434,
267,
627,
257,
536,
29,
2473,
30712,
710,
536,
1443,
14190,
506,
9437,
701,
1373,
503,
1655,
971,
627,
2108,
13,
4273,
10381,
11673,
687,
314,
536,
701,
8139,
14,
221,
982,
314,
971,
627,
1541,
804,
10,
365,
440,
2013,
12,
971,
1011,
585,
23262,
221,
365,
10826,
14,
2728,
627,
257,
536,
29,
70,
3783,
567,
574,
29,
2239,
331,
750,
268,
5493,
627,
257,
971,
1011,
4556,
23262,
26447,
627,
9554,
9093,
19429,
221,
2728,
6668,
376,
1819,
701,
27083,
314,
2013,
1059,
14,
221,
961,
6127,
1265,
370,
24749,
314,
4163,
7543,
6935,
267,
5822,
1808,
15250,
14,
221,
3390,
626,
1265,
1471,
440,
372,
282,
574,
315,
642,
1059,
27,
9329,
1852,
652,
314,
2061,
3965,
315,
314,
1853,
14,
2728,
627,
257,
8266,
29,
3554,
14,
3351,
459,
1662,
2821,
2278,
1662,
11070,
2110,
267,
627,
257,
8266,
29,
3554,
14,
4782,
59,
1367,
61,
267,
627,
257,
8266,
29,
1593,
3925,
342,
469,
372,
2213,
14,
4614,
59,
17,
11566,
16735,
3925,
7303,
268,
5493,
627,
257,
971,
1011,
8006,
23262,
26447,
627,
8006,
9093,
19429,
4960,
6263,
323,
376,
1819,
1808,
376,
1323,
2042,
3965,
14,
2728,
627,
257,
14462,
29,
501,
4060,
14251,
4478,
534,
1918,
1834,
8791,
1318,
418,
267,
627,
257,
14462,
29,
501,
1224,
14251,
344,
534,
1224,
17,
418,
501,
454,
59,
20,
12978,
2076,
59,
18,
61,
267,
627,
257,
14462,
29,
501,
65,
59,
6134,
8,
32,
6399,
2584,
3,
344,
17,
5440,
267,
627,
257,
14462,
29,
501,
65,
59,
6134,
8,
32,
6399,
2584,
3,
344,
17,
5440,
15,
32,
533,
267,
627,
257,
14462,
2687,
501,
1224,
14251,
533,
534,
2487,
69,
1105,
501,
273,
59,
505,
342,
534,
1589,
2567,
1872,
28178,
5093,
2076,
267,
627,
257,
14462,
29,
501,
1210,
14251,
354,
534,
354,
18,
7,
436,
768,
585,
534,
5066,
418,
267,
627,
257,
14462,
29,
501,
60,
23033,
505,
342,
628,
1019,
937,
268,
5493,
627,
257,
971,
1011,
1073,
23262,
26447,
627,
505,
9959,
19429,
267,
9496,
314,
2142,
334,
11498,
9,
1819,
1314,
3509,
1318,
4877,
314,
267,
2013,
971,
627,
3401,
4856,
2728,
627,
257,
2142,
29,
1918,
2142,
1318,
268,
5493,
627,
257,
971,
1011,
3919,
23262,
26447,
627,
3919,
11212,
16626,
19429,
267,
9496,
314,
1819,
1808,
11431,
9759,
83,
14,
7754,
10618,
370,
15750,
18,
9759,
83,
12,
15750,
19,
9759,
83,
367,
1655,
2556,
14,
2047,
883,
2597,
1104,
314,
1379,
35,
385,
3040,
2750,
511,
315,
314,
19481,
511,
5241,
367,
376,
2893,
402,
4503,
12,
1314,
365,
5120,
315,
314,
13557,
19481,
6170,
2559,
14,
2728,
627,
257,
11431,
29,
65,
59,
6399,
13476,
344,
19,
937,
267,
627,
257,
11431,
29,
3751,
3,
22262,
435,
13598,
30712,
13550,
314,
11431,
9759,
14067,
5171,
1006,
11431,
17,
12,
11431,
18,
436,
11431,
19,
9759,
83,
871,
3231,
315,
11431,
19,
12,
2005,
15984,
3992,
8,
26,
16621,
13,
1618,
13,
466,
12,
520,
16621,
13,
2019,
13,
1618,
13,
466,
12,
520,
2246,
13,
1618,
13,
466,
12,
520,
2019,
13,
1618,
13,
466,
12,
520,
2118,
13,
1618,
13,
466,
12,
520,
21736,
12,
520,
22797,
12,
520,
2682,
12,
520,
12283,
12,
520,
262,
271,
14478,
9,
436,
15984,
4008,
8,
447,
2246,
13,
604,
12,
3800,
2246,
13,
9269,
12,
3800,
5592,
12,
3800,
5182,
12,
3800,
4399,
680,
221,
268,
1362,
17635,
23952,
376,
5027,
14067,
2403,
12,
3240,
9465,
4440,
314,
2569,
849,
272,
32647,
26,
17635,
627,
257,
971,
1011,
4556,
23262,
2360,
367,
4355,
2750,
6617,
543,
298,
3554,
2122,
272,
627,
257,
971,
1011,
8006,
23262,
2360,
367,
4355,
2750,
6617,
543,
23057,
2,
272,
627,
257,
971,
1011,
5364,
23262,
2360,
4257,
2286,
6566,
21240,
272,
32202,
23597,
2286,
6566,
4766,
883,
506,
1202,
543,
282,
14067,
370,
2984,
1132,
282,
769,
402,
7627,
4008,
14,
221,
9322,
787,
5544,
1202,
1454,
315,
314,
283,
354,
7,
1819,
13,
6354,
14,
2286,
21240,
3648,
8298,
2839,
4355,
2750,
12,
13446,
14,
2286,
971,
627,
1541,
804,
7590,
1011,
29,
23262,
971,
627,
2094,
10,
2286,
26167,
1819,
13,
4273,
787,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
DavidAndreev/indico
|
indico/core/signals/event/notes.py
|
2
|
1122
|
# This file is part of Indico.
# Copyright (C) 2002 - 2016 European Organization for Nuclear Research (CERN).
#
# Indico 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.
#
# Indico 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 Indico; if not, see <http://www.gnu.org/licenses/>.
from blinker import Namespace
_signals = Namespace()
note_added = _signals.signal('note-added', """
Called when a note is added. The `sender` is the note.
""")
note_modified = _signals.signal('note-modified', """
Called when a note is modified. The `sender` is the note.
""")
note_deleted = _signals.signal('note-deleted', """
Called when a note is deleted. The `sender` is the note.
""")
|
gpl-3.0
|
[
3,
961,
570,
365,
1777,
402,
1010,
27347,
14,
199,
3,
1898,
334,
35,
9,
14790,
446,
7800,
31615,
290,
18863,
367,
653,
947,
4025,
26993,
334,
35,
14482,
680,
199,
3,
199,
3,
1010,
27347,
365,
2867,
2032,
27,
1265,
883,
3604,
652,
436,
15,
269,
199,
3,
2811,
652,
1334,
314,
2895,
402,
314,
1664,
1696,
1684,
844,
465,
199,
3,
3267,
701,
314,
2868,
2290,
2752,
27,
1902,
1015,
650,
402,
314,
199,
3,
844,
12,
503,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
1010,
27347,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
1325,
199,
3,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
1664,
199,
3,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
1696,
1684,
844,
199,
3,
3180,
543,
1010,
27347,
27,
340,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
199,
504,
330,
20311,
492,
19317,
199,
199,
63,
10458,
275,
19317,
342,
421,
199,
4610,
63,
3270,
275,
485,
10458,
14,
4653,
360,
4610,
13,
3270,
297,
408,
199,
10474,
1380,
282,
5317,
365,
3483,
14,
710,
658,
8114,
64,
365,
314,
5317,
14,
199,
6141,
199,
199,
4610,
63,
5540,
275,
485,
10458,
14,
4653,
360,
4610,
13,
5540,
297,
408,
199,
10474,
1380,
282,
5317,
365,
6042,
14,
710,
658,
8114,
64,
365,
314,
5317,
14,
199,
6141,
199,
199,
4610,
63,
6062,
275,
485,
10458,
14,
4653,
360,
4610,
13,
6062,
297,
408,
199,
10474,
1380,
282,
5317,
365,
5463,
14,
710,
658,
8114,
64,
365,
314,
5317,
14,
199,
6141,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,
1010,
27347,
14,
199,
3,
1898,
334,
35,
9,
14790,
446,
7800,
31615,
290,
18863,
367,
653,
947,
4025,
26993,
334,
35,
14482,
680,
199,
3,
199,
3,
1010,
27347,
365,
2867,
2032,
27,
1265,
883,
3604,
652,
436,
15,
269,
199,
3,
2811,
652,
1334,
314,
2895,
402,
314,
1664,
1696,
1684,
844,
465,
199,
3,
3267,
701,
314,
2868,
2290,
2752,
27,
1902,
1015,
650,
402,
314,
199,
3,
844,
12,
503,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
1010,
27347,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
1325,
199,
3,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
1664,
199,
3,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
1696,
1684,
844,
199,
3,
3180,
543,
1010,
27347,
27,
340,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
199,
504,
330,
20311,
492,
19317,
199,
199,
63,
10458,
275,
19317,
342,
421,
199,
4610,
63,
3270,
275,
485,
10458,
14,
4653,
360,
4610,
13,
3270,
297,
408,
199,
10474,
1380,
282,
5317,
365,
3483,
14,
710,
658,
8114,
64,
365,
314,
5317,
14,
199,
6141,
199,
199,
4610,
63,
5540,
275,
485,
10458,
14,
4653,
360,
4610,
13,
5540,
297,
408,
199,
10474,
1380,
282,
5317,
365,
6042,
14,
710,
658,
8114,
64,
365,
314,
5317,
14,
199,
6141,
199,
199,
4610,
63,
6062,
275,
485,
10458,
14,
4653,
360,
4610,
13,
6062,
297,
408,
199,
10474,
1380,
282,
5317,
365,
5463,
14,
710,
658,
8114,
64,
365,
314,
5317,
14,
199,
6141,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
d3banjan/polyamide
|
webdev/lib/python2.7/site-packages/pkg_resources/_vendor/packaging/_compat.py
|
901
|
1253
|
# Copyright 2014 Donald Stufft
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from __future__ import absolute_import, division, print_function
import sys
PY2 = sys.version_info[0] == 2
PY3 = sys.version_info[0] == 3
# flake8: noqa
if PY3:
string_types = str,
else:
string_types = basestring,
def with_metaclass(meta, *bases):
"""
Create a base class with a metaclass.
"""
# This requires a bit of explanation: the basic idea is to make a dummy
# metaclass for one level of class instantiation that replaces itself with
# the actual metaclass.
class metaclass(meta):
def __new__(cls, name, this_bases, d):
return meta(name, bases, d)
return type.__new__(metaclass, 'temporary_class', (), {})
|
bsd-2-clause
|
[
3,
1898,
6927,
7529,
27075,
1933,
3043,
84,
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,
504,
636,
2443,
363,
492,
3679,
63,
646,
12,
4629,
12,
870,
63,
1593,
199,
199,
646,
984,
421,
199,
4521,
18,
275,
984,
14,
1023,
63,
815,
59,
16,
61,
508,
499,
199,
4521,
19,
275,
984,
14,
1023,
63,
815,
59,
16,
61,
508,
650,
199,
199,
3,
27510,
24,
26,
8151,
199,
199,
692,
7843,
19,
26,
272,
1059,
63,
1313,
275,
620,
12,
199,
2836,
26,
272,
1059,
63,
1313,
275,
7116,
12,
421,
199,
318,
543,
63,
6577,
8,
2024,
12,
627,
12087,
304,
272,
408,
272,
2790,
282,
1300,
1021,
543,
282,
17074,
14,
272,
408,
272,
327,
961,
5074,
282,
4546,
402,
17531,
26,
314,
5678,
16819,
365,
370,
1852,
282,
7283,
272,
327,
17074,
367,
1373,
2166,
402,
1021,
26621,
626,
19058,
6337,
543,
272,
327,
314,
3503,
17074,
14,
272,
1021,
17074,
8,
2024,
304,
267,
347,
636,
1222,
721,
1886,
12,
536,
12,
642,
63,
12087,
12,
366,
304,
288,
372,
3404,
8,
354,
12,
9768,
12,
366,
9,
272,
372,
730,
855,
1222,
721,
6577,
12,
283,
13555,
63,
533,
297,
11969,
5009,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
1898,
6927,
7529,
27075,
1933,
3043,
84,
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,
504,
636,
2443,
363,
492,
3679,
63,
646,
12,
4629,
12,
870,
63,
1593,
199,
199,
646,
984,
421,
199,
4521,
18,
275,
984,
14,
1023,
63,
815,
59,
16,
61,
508,
499,
199,
4521,
19,
275,
984,
14,
1023,
63,
815,
59,
16,
61,
508,
650,
199,
199,
3,
27510,
24,
26,
8151,
199,
199,
692,
7843,
19,
26,
272,
1059,
63,
1313,
275,
620,
12,
199,
2836,
26,
272,
1059,
63,
1313,
275,
7116,
12,
421,
199,
318,
543,
63,
6577,
8,
2024,
12,
627,
12087,
304,
272,
408,
272,
2790,
282,
1300,
1021,
543,
282,
17074,
14,
272,
408,
272,
327,
961,
5074,
282,
4546,
402,
17531,
26,
314,
5678,
16819,
365,
370,
1852,
282,
7283,
272,
327,
17074,
367,
1373,
2166,
402,
1021,
26621,
626,
19058,
6337,
543,
272,
327,
314,
3503,
17074,
14,
272,
1021,
17074,
8,
2024,
304,
267,
347,
636,
1222,
721,
1886,
12,
536,
12,
642,
63,
12087,
12,
366,
304,
288,
372,
3404,
8,
354,
12,
9768,
12,
366,
9,
272,
372,
730,
855,
1222,
721,
6577,
12,
283,
13555,
63,
533,
297,
11969,
5009,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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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0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
omerucn/or-tools
|
tools/setup_data.py
|
18
|
1550
|
from setuptools import setup, Extension
from os.path import join as pjoin
from os.path import dirname
# Utility function to read the README file.
# Used for the long_description. It's nice, because now 1) we have a top level
# README file and 2) it's easier to type in the README file than to put a raw
# string in below ...
def read(fname):
return open(pjoin(dirname(__file__), fname)).read()
setup(
name='ortools_examples',
version='1.VVVV',
install_requires = ['ortools'],
license='Apache 2.0',
author = 'Google Inc',
author_email = 'lperron@google.com',
description = 'Google OR-Tools python libraries and modules',
keywords = ('operations research, constraint programming, ' +
'linear programming,' + 'flow algorithms,' +
'python'),
url = 'http://code.google.com/p/or-tools/',
classifiers = [
'Development Status :: 5 - Production/Stable',
'Intended Audience :: Developers',
'License :: OSI Approved :: Apache Software License',
'Operating System :: MacOS :: MacOS X',
'Operating System :: Microsoft :: Windows',
'Operating System :: POSIX :: Linux',
'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
'Topic :: Office/Business :: Scheduling',
'Topic :: Scientific/Engineering',
'Topic :: Scientific/Engineering :: Mathematics',
'Topic :: Software Development :: Libraries :: Python Modules'],
long_description = read('README.txt'),
)
|
apache-2.0
|
[
504,
9116,
492,
3272,
12,
13282,
199,
504,
747,
14,
515,
492,
4263,
465,
299,
904,
199,
504,
747,
14,
515,
492,
9017,
199,
199,
3,
20511,
805,
370,
1586,
314,
27781,
570,
14,
199,
3,
8051,
367,
314,
1846,
63,
1802,
14,
221,
2779,
1159,
14213,
12,
2952,
3063,
413,
9,
781,
1172,
282,
2746,
2166,
199,
3,
27781,
570,
436,
499,
9,
652,
1159,
14905,
370,
730,
315,
314,
27781,
570,
2419,
370,
5324,
282,
3066,
199,
3,
1059,
315,
5084,
2263,
199,
318,
1586,
8,
5252,
304,
272,
372,
1551,
8,
80,
904,
8,
3475,
3460,
493,
10139,
6748,
4992,
739,
342,
199,
199,
2758,
8,
272,
536,
534,
361,
5998,
63,
8589,
297,
272,
1015,
534,
17,
14,
17578,
17578,
297,
272,
3907,
63,
6537,
275,
788,
361,
5998,
995,
272,
4190,
534,
28993,
499,
14,
16,
297,
272,
4132,
275,
283,
13266,
3277,
297,
272,
4132,
63,
2123,
275,
283,
76,
529,
2641,
32,
3098,
14,
957,
297,
272,
1369,
275,
283,
13266,
1549,
13,
11654,
2366,
8363,
436,
4621,
297,
272,
7681,
275,
661,
8170,
295,
1733,
12,
5828,
31768,
12,
283,
435,
355,
283,
6676,
31768,
2584,
435,
283,
1659,
18036,
2584,
435,
355,
283,
1548,
659,
272,
1166,
275,
283,
1014,
921,
600,
14,
3098,
14,
957,
15,
80,
15,
269,
13,
2537,
3678,
272,
19137,
275,
359,
267,
283,
23753,
9795,
3800,
959,
446,
24114,
15,
933,
461,
297,
267,
283,
23910,
23975,
3800,
23493,
297,
267,
283,
3761,
3800,
25718,
26330,
3800,
3668,
2290,
844,
297,
267,
283,
23699,
6187,
3800,
10444,
3100,
3800,
10444,
3100,
1323,
297,
267,
283,
23699,
6187,
3800,
15332,
3800,
5417,
297,
267,
283,
23699,
6187,
3800,
18169,
3800,
10130,
297,
267,
283,
11411,
8466,
3800,
2018,
3800,
499,
14,
22,
297,
267,
283,
11411,
8466,
3800,
2018,
3800,
499,
14,
23,
297,
267,
283,
12157,
3800,
593,
11286,
301,
15,
12106,
9585,
3800,
428,
1809,
15633,
297,
267,
283,
12157,
3800,
16578,
23509,
15,
8524,
15663,
297,
267,
283,
12157,
3800,
16578,
23509,
15,
8524,
15663,
3800,
16593,
1589,
3889,
83,
297,
267,
283,
12157,
3800,
2290,
15290,
3800,
31454,
3800,
2018,
18167,
995,
272,
1846,
63,
1802,
275,
1586,
360,
18195,
14,
2424,
659,
199,
9,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
9116,
492,
3272,
12,
13282,
199,
504,
747,
14,
515,
492,
4263,
465,
299,
904,
199,
504,
747,
14,
515,
492,
9017,
199,
199,
3,
20511,
805,
370,
1586,
314,
27781,
570,
14,
199,
3,
8051,
367,
314,
1846,
63,
1802,
14,
221,
2779,
1159,
14213,
12,
2952,
3063,
413,
9,
781,
1172,
282,
2746,
2166,
199,
3,
27781,
570,
436,
499,
9,
652,
1159,
14905,
370,
730,
315,
314,
27781,
570,
2419,
370,
5324,
282,
3066,
199,
3,
1059,
315,
5084,
2263,
199,
318,
1586,
8,
5252,
304,
272,
372,
1551,
8,
80,
904,
8,
3475,
3460,
493,
10139,
6748,
4992,
739,
342,
199,
199,
2758,
8,
272,
536,
534,
361,
5998,
63,
8589,
297,
272,
1015,
534,
17,
14,
17578,
17578,
297,
272,
3907,
63,
6537,
275,
788,
361,
5998,
995,
272,
4190,
534,
28993,
499,
14,
16,
297,
272,
4132,
275,
283,
13266,
3277,
297,
272,
4132,
63,
2123,
275,
283,
76,
529,
2641,
32,
3098,
14,
957,
297,
272,
1369,
275,
283,
13266,
1549,
13,
11654,
2366,
8363,
436,
4621,
297,
272,
7681,
275,
661,
8170,
295,
1733,
12,
5828,
31768,
12,
283,
435,
355,
283,
6676,
31768,
2584,
435,
283,
1659,
18036,
2584,
435,
355,
283,
1548,
659,
272,
1166,
275,
283,
1014,
921,
600,
14,
3098,
14,
957,
15,
80,
15,
269,
13,
2537,
3678,
272,
19137,
275,
359,
267,
283,
23753,
9795,
3800,
959,
446,
24114,
15,
933,
461,
297,
267,
283,
23910,
23975,
3800,
23493,
297,
267,
283,
3761,
3800,
25718,
26330,
3800,
3668,
2290,
844,
297,
267,
283,
23699,
6187,
3800,
10444,
3100,
3800,
10444,
3100,
1323,
297,
267,
283,
23699,
6187,
3800,
15332,
3800,
5417,
297,
267,
283,
23699,
6187,
3800,
18169,
3800,
10130,
297,
267,
283,
11411,
8466,
3800,
2018,
3800,
499,
14,
22,
297,
267,
283,
11411,
8466,
3800,
2018,
3800,
499,
14,
23,
297,
267,
283,
12157,
3800,
593,
11286,
301,
15,
12106,
9585,
3800,
428,
1809,
15633,
297,
267,
283,
12157,
3800,
16578,
23509,
15,
8524,
15663,
297,
267,
283,
12157,
3800,
16578,
23509,
15,
8524,
15663,
3800,
16593,
1589,
3889,
83,
297,
267,
283,
12157,
3800,
2290,
15290,
3800,
31454,
3800,
2018,
18167,
995,
272,
1846,
63,
1802,
275,
1586,
360,
18195,
14,
2424,
659,
199,
9,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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list
if test_support.is_jython:
from java.util import ArrayList
from java.lang import String
class ListTestCase(unittest.TestCase):
def test_recursive_list_slices(self):
x = [1,2,3,4,5]
x[1:] = x
self.assertEquals(x, [1, 1, 2, 3, 4, 5],
"Recursive assignment to list slices failed")
def test_subclass_richcmp(self):
# http://bugs.jython.org/issue1115
class Foo(list):
def __init__(self, dotstring):
list.__init__(self, map(int, dotstring.split(".")))
bar1 = Foo('1.2.3')
bar2 = Foo('1.2.4')
self.assert_(bar1 < bar2)
self.assert_(bar1 <= bar2)
self.assert_(bar2 > bar1)
self.assert_(bar2 >= bar1)
def test_setget_override(self):
if not test_support.is_jython:
return
# http://bugs.jython.org/issue600790
class GoofyListMapThing(ArrayList):
def __init__(self):
self.silly = "Nothing"
def __setitem__(self, key, element):
self.silly = "spam"
def __getitem__(self, key):
self.silly = "eggs"
glmt = GoofyListMapThing()
glmt['my-key'] = String('el1')
self.assertEquals(glmt.silly, "spam")
glmt['my-key']
self.assertEquals(glmt.silly, "eggs")
def test_tuple_equality(self):
self.assertEqual([(1,), [1]].count([1]), 1) # http://bugs.jython.org/issue1317
def test_big_list(self):
"""Verify that fairly large collection literals of primitives can be constructed."""
# use \n to separate to avoid parser problems
lst = eval("[" + ",\n".join((str(x) for x in xrange(64000))) +"]")
self.assertEqual(len(lst), 64000)
self.assertEqual(sum(lst), 2047968000)
class ThreadSafetyTestCase(unittest.TestCase):
def run_threads(self, f, num=10):
threads = []
for i in xrange(num):
t = threading.Thread(target=f)
t.start()
threads.append(t)
timeout = 10. # be especially generous
for t in threads:
t.join(timeout)
timeout = 0.
for t in threads:
self.assertFalse(t.isAlive())
def test_append_remove(self):
# derived from Itamar Shtull-Trauring's test for issue 521701
lst = []
def tester():
ct = threading.currentThread()
for i in range(1000):
lst.append(ct)
time.sleep(0.0001)
lst.remove(ct)
self.run_threads(tester)
self.assertEqual(lst, [])
def test_sort(self):
lst = []
def tester():
ct = threading.currentThread()
for i in range(1000):
lst.append(ct)
lst.sort()
lst.remove(ct)
time.sleep(0.0001)
self.run_threads(tester)
self.assertEqual(lst, [])
def test_count_reverse(self):
lst = [0,1,2,3,4,5,6,7,8,9,10,0]
def tester():
ct = threading.currentThread()
for i in range(1000):
self.assertEqual(lst[0], 0)
if random.random() > 0.5:
time.sleep(0.0001)
lst.reverse()
self.assertEqual(lst.count(0), 2)
self.assert_(lst[1] in (1,10))
self.run_threads(tester)
class ExtendedSliceTestCase(unittest.TestCase):
'''Really thrash extended slice operations on list.'''
type2test = list
def test_extended_slice_delete(self):
# Based on list_tests.CommonTest.test_extendedslicing .
# In the cited test case, the stop value is nearly always the default
# (None), meaning the end of the list, and often the start value is too.
# This contributed to the release of http://bugs.jython.org/issue1873 .
# This is a supplementary test focused on correct stopping.
initial = [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13]
expected1 = self.type2test([ 0, 1, 2, 3, 4, 5, 10,11,12,13])
expected2 = self.type2test([ 0, 1, 2, 4, 6, 8, 10, 12,13])
expected4 = self.type2test([ 0, 1, 3, 4, 5, 7, 8, 9, 11,12,13])
# Positive step
a = self.type2test(initial)
del a[6:10:1]
self.assertEqual(a, expected1)
a = self.type2test(initial)
del a[3:13:2]
self.assertEqual(a, expected2)
a = self.type2test(initial)
del a[3:12:2]
self.assertEqual(a, expected2)
a = self.type2test(initial)
del a[2:11:4]
self.assertEqual(a, expected4)
a = self.type2test(initial)
del a[2::4]
self.assertEqual(a, expected4)
# Negative step (same results)
a = self.type2test(initial)
del a[9:5:-1]
self.assertEqual(a, expected1)
a = self.type2test(initial)
del a[11:1:-2]
self.assertEqual(a, expected2)
a = self.type2test(initial)
del a[11:2:-2]
self.assertEqual(a, expected2)
a = self.type2test(initial)
del a[10:1:-4]
self.assertEqual(a, expected4)
a = self.type2test(initial)
del a[10::-4]
self.assertEqual(a, expected4)
def test_extended_slice_assign(self):
# Based on list_tests.CommonTest.test_extendedslicing .
# In the cited test case, the stop value is nearly always the default.
# This is a supplementary test focused on correct stopping.
aa, bb, cc = 91, 92, 93
src = self.type2test([aa,bb,cc])
initial = [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13]
expected1 = self.type2test([ 0, 1, 2, 3, 4, 5,aa,bb,cc, 9,10,11,12,13])
expected2 = self.type2test([ 0, 1, 2,aa, 4,bb, 6,cc, 8, 9,10,11,12,13])
expected4 = self.type2test([ 0, 1,aa, 3, 4, 5,bb, 7, 8, 9,cc,11,12,13])
# Positive step
a = self.type2test(initial)
a[6:9:1] = src
self.assertEqual(a, expected1)
a = self.type2test(initial)
a[3:9:2] = src
self.assertEqual(a, expected2)
a = self.type2test(initial)
a[3:8:2] = src
self.assertEqual(a, expected2)
a = self.type2test(initial)
a[2:11:4] = src
self.assertEqual(a, expected4)
a = self.type2test(initial)
a[2::4] = src
self.assertEqual(a, expected4)
# Negative step (same results, as src is reversed)
src.reverse()
a = self.type2test(initial)
a[8:5:-1] = src
self.assertEqual(a, expected1)
a = self.type2test(initial)
a[7:2:-2] = src
self.assertEqual(a, expected2)
a = self.type2test(initial)
a[7:1:-2] = src
self.assertEqual(a, expected2)
a = self.type2test(initial)
a[10:1:-4] = src
self.assertEqual(a, expected4)
a = self.type2test(initial)
a[10::-4] = src
self.assertEqual(a, expected4)
class JavaListTestCase(test_list.ListTest):
type2test = ArrayList
def test_init(self):
# Iterable arg is optional
self.assertEqual(self.type2test([]), self.type2test())
# Unlike with builtin types, we do not guarantee objects can
# be overwritten; see corresponding tests
# Mutables always return a new object
a = self.type2test([1, 2, 3])
b = self.type2test(a)
self.assertNotEqual(id(a), id(b))
self.assertEqual(a, b)
def test_extend_java_ArrayList(self):
jl = ArrayList([])
jl.extend([1,2])
self.assertEqual(jl, ArrayList([1,2]))
jl.extend(ArrayList([3,4]))
self.assertEqual(jl, [1,2,3,4])
class ListSubclassTestCase(unittest.TestCase):
def test_subclass_iter_copy(self):
class MyList(list):
def __iter__(self):
i = 0
results = super(MyList, self).__iter__()
for result in results:
yield result
i += 1
# add extra result for validation
yield i
lst = MyList(['a', 'b', 'c'])
self.assertEqual(list(lst), ['a', 'b', 'c', 3])
def test_main():
test_support.run_unittest(ListSubclassTestCase,
ListTestCase,
ThreadSafetyTestCase,
ExtendedSliceTestCase,
JavaListTestCase)
if __name__ == "__main__":
test_main()
|
apache-2.0
|
[
646,
2882,
199,
646,
2196,
199,
646,
5796,
199,
646,
900,
199,
504,
511,
492,
511,
63,
4058,
199,
646,
511,
63,
513,
199,
199,
692,
511,
63,
4058,
14,
374,
63,
27179,
26,
272,
687,
12120,
14,
1974,
492,
8725,
1296,
272,
687,
12120,
14,
4159,
492,
2624,
199,
199,
533,
3820,
1746,
8,
2796,
14,
1746,
304,
339,
347,
511,
63,
9931,
63,
513,
63,
14865,
8,
277,
304,
267,
671,
275,
359,
17,
12,
18,
12,
19,
12,
20,
12,
21,
61,
267,
671,
59,
17,
2938,
275,
671,
267,
291,
14,
2947,
8,
88,
12,
359,
17,
12,
413,
12,
499,
12,
650,
12,
841,
12,
959,
467,
2079,
298,
25122,
9801,
370,
769,
17184,
3405,
531,
339,
347,
511,
63,
6083,
63,
10399,
5730,
8,
277,
304,
267,
327,
1455,
921,
13017,
14,
27179,
14,
1308,
15,
5237,
845,
1046,
267,
1021,
8024,
8,
513,
304,
288,
347,
636,
826,
721,
277,
12,
6308,
875,
304,
355,
769,
855,
826,
721,
277,
12,
2341,
8,
442,
12,
6308,
875,
14,
1294,
480,
2122,
1724,
267,
4681,
17,
275,
8024,
360,
17,
14,
18,
14,
19,
358,
267,
4681,
18,
275,
8024,
360,
17,
14,
18,
14,
20,
358,
267,
291,
14,
479,
2531,
1700,
17,
665,
4681,
18,
9,
267,
291,
14,
479,
2531,
1700,
17,
2695,
4681,
18,
9,
267,
291,
14,
479,
2531,
1700,
18,
690,
4681,
17,
9,
267,
291,
14,
479,
2531,
1700,
18,
2356,
4681,
17,
9,
339,
347,
511,
63,
409,
362,
63,
4415,
8,
277,
304,
267,
340,
440,
511,
63,
4058,
14,
374,
63,
27179,
26,
288,
372,
398,
327,
1455,
921,
13017,
14,
27179,
14,
1308,
15,
5237,
6683,
22252,
267,
1021,
598,
1534,
1399,
1296,
2956,
32218,
8,
3836,
1296,
304,
288,
347,
636,
826,
721,
277,
304,
355,
291,
14,
20329,
590,
275,
298,
19627,
2,
953,
347,
636,
8617,
721,
277,
12,
790,
12,
1819,
304,
355,
291,
14,
20329,
590,
275,
298,
8283,
2,
953,
347,
636,
6095,
721,
277,
12,
790,
304,
355,
291,
14,
20329,
590,
275,
298,
14488,
2,
398,
6482,
2037,
275,
598,
1534,
1399,
1296,
2956,
32218,
342,
267,
6482,
2037,
459,
1662,
13,
498,
418,
275,
2624,
360,
352,
17,
358,
267,
291,
14,
2947,
8,
3528,
2037,
14,
20329,
590,
12,
298,
8283,
531,
267,
6482,
2037,
459,
1662,
13,
498,
418,
267,
291,
14,
2947,
8,
3528,
2037,
14,
20329,
590,
12,
298,
14488,
531,
339,
347,
511,
63,
2960,
63,
20982,
8,
277,
304,
267,
291,
14,
629,
7694,
17,
4706,
359,
17,
20230,
835,
779,
17,
2522,
413,
9,
327,
1455,
921,
13017,
14,
27179,
14,
1308,
15,
5237,
969,
1196,
339,
347,
511,
63,
5076,
63,
513,
8,
277,
304,
267,
408,
7496,
626,
28092,
590,
7031,
3245,
18041,
402,
1979,
22337,
883,
506,
14701,
1041,
267,
327,
675,
971,
78,
370,
7396,
370,
5126,
1798,
8826,
267,
9877,
275,
3468,
480,
905,
435,
3872,
60,
78,
1674,
904,
1332,
495,
8,
88,
9,
367,
671,
315,
4945,
8,
772,
1493,
1724,
435,
937,
531,
267,
291,
14,
629,
8,
552,
8,
6916,
395,
5049,
1493,
9,
267,
291,
14,
629,
8,
1838,
8,
6916,
395,
14785,
1965,
2333,
1493,
9,
199,
199,
533,
11086,
11090,
369,
1746,
8,
2796,
14,
1746,
304,
339,
347,
1255,
63,
6962,
8,
277,
12,
289,
12,
1967,
29,
709,
304,
267,
7183,
275,
942,
267,
367,
284,
315,
4945,
8,
1507,
304,
288,
307,
275,
5796,
14,
4436,
8,
1375,
29,
70,
9,
288,
307,
14,
928,
342,
288,
7183,
14,
740,
8,
84,
9,
267,
2653,
275,
1616,
14,
327,
506,
24002,
1519,
1785,
267,
367,
307,
315,
7183,
26,
288,
307,
14,
904,
8,
2593,
9,
288,
2653,
275,
378,
14,
267,
367,
307,
315,
7183,
26,
288,
291,
14,
3334,
8,
84,
14,
374,
23692,
1012,
339,
347,
511,
63,
740,
63,
2168,
8,
277,
304,
267,
327,
7131,
687,
2779,
455,
285,
428,
517,
979,
13,
2437,
4039,
1159,
511,
367,
4976,
959,
9335,
614,
267,
9877,
275,
942,
267,
347,
17570,
837,
288,
9428,
275,
5796,
14,
1818,
4436,
342,
288,
367,
284,
315,
1425,
8,
5279,
304,
355,
9877,
14,
740,
8,
319,
9,
355,
900,
14,
4532,
8,
16,
14,
4183,
9,
355,
9877,
14,
2168,
8,
319,
9,
267,
291,
14,
1065,
63,
6962,
8,
8234,
9,
267,
291,
14,
629,
8,
6916,
12,
3073,
339,
347,
511,
63,
3191,
8,
277,
304,
267,
9877,
275,
942,
267,
347,
17570,
837,
288,
9428,
275,
5796,
14,
1818,
4436,
342,
288,
367,
284,
315,
1425,
8,
5279,
304,
355,
9877,
14,
740,
8,
319,
9,
355,
9877,
14,
3191,
342,
355,
9877,
14,
2168,
8,
319,
9,
355,
900,
14,
4532,
8,
16,
14,
4183,
9,
267,
291,
14,
1065,
63,
6962,
8,
8234,
9,
267,
291,
14,
629,
8,
6916,
12,
3073,
339,
347,
511,
63,
835,
63,
4471,
8,
277,
304,
267,
9877,
275,
359,
16,
12,
17,
12,
18,
12,
19,
12,
20,
12,
21,
12,
22,
12,
23,
12,
24,
12,
25,
12,
709,
12,
16,
61,
267,
347,
17570,
837,
288,
9428,
275,
5796,
14,
1818,
4436,
342,
288,
367,
284,
315,
1425,
8,
5279,
304,
355,
291,
14,
629,
8,
6916,
59,
16,
467,
378,
9,
355,
340,
2196,
14,
2355,
342,
690,
378,
14,
21,
26,
490,
900,
14,
4532,
8,
16,
14,
4183,
9,
355,
9877,
14,
4471,
342,
355,
291,
14,
629,
8,
6916,
14,
835,
8,
16,
395,
499,
9,
355,
291,
14,
479,
2531,
6916,
59,
17,
61,
315,
334,
17,
12,
709,
430,
267,
291,
14,
1065,
63,
6962,
8,
8234,
9,
199,
199,
533,
13706,
14034,
1746,
8,
2796,
14,
1746,
304,
272,
1449,
497,
1183,
294,
82,
1119,
9243,
6014,
5331,
641,
769,
10595,
272,
730,
18,
396,
275,
769,
339,
347,
511,
63,
10525,
63,
5224,
63,
1807,
8,
277,
304,
267,
327,
21311,
641,
769,
63,
2219,
14,
7844,
774,
14,
396,
63,
10525,
83,
17463,
1275,
267,
327,
1010,
314,
286,
5703,
511,
1930,
12,
314,
3631,
574,
365,
17429,
590,
3544,
314,
849
] |
[
2882,
199,
646,
2196,
199,
646,
5796,
199,
646,
900,
199,
504,
511,
492,
511,
63,
4058,
199,
646,
511,
63,
513,
199,
199,
692,
511,
63,
4058,
14,
374,
63,
27179,
26,
272,
687,
12120,
14,
1974,
492,
8725,
1296,
272,
687,
12120,
14,
4159,
492,
2624,
199,
199,
533,
3820,
1746,
8,
2796,
14,
1746,
304,
339,
347,
511,
63,
9931,
63,
513,
63,
14865,
8,
277,
304,
267,
671,
275,
359,
17,
12,
18,
12,
19,
12,
20,
12,
21,
61,
267,
671,
59,
17,
2938,
275,
671,
267,
291,
14,
2947,
8,
88,
12,
359,
17,
12,
413,
12,
499,
12,
650,
12,
841,
12,
959,
467,
2079,
298,
25122,
9801,
370,
769,
17184,
3405,
531,
339,
347,
511,
63,
6083,
63,
10399,
5730,
8,
277,
304,
267,
327,
1455,
921,
13017,
14,
27179,
14,
1308,
15,
5237,
845,
1046,
267,
1021,
8024,
8,
513,
304,
288,
347,
636,
826,
721,
277,
12,
6308,
875,
304,
355,
769,
855,
826,
721,
277,
12,
2341,
8,
442,
12,
6308,
875,
14,
1294,
480,
2122,
1724,
267,
4681,
17,
275,
8024,
360,
17,
14,
18,
14,
19,
358,
267,
4681,
18,
275,
8024,
360,
17,
14,
18,
14,
20,
358,
267,
291,
14,
479,
2531,
1700,
17,
665,
4681,
18,
9,
267,
291,
14,
479,
2531,
1700,
17,
2695,
4681,
18,
9,
267,
291,
14,
479,
2531,
1700,
18,
690,
4681,
17,
9,
267,
291,
14,
479,
2531,
1700,
18,
2356,
4681,
17,
9,
339,
347,
511,
63,
409,
362,
63,
4415,
8,
277,
304,
267,
340,
440,
511,
63,
4058,
14,
374,
63,
27179,
26,
288,
372,
398,
327,
1455,
921,
13017,
14,
27179,
14,
1308,
15,
5237,
6683,
22252,
267,
1021,
598,
1534,
1399,
1296,
2956,
32218,
8,
3836,
1296,
304,
288,
347,
636,
826,
721,
277,
304,
355,
291,
14,
20329,
590,
275,
298,
19627,
2,
953,
347,
636,
8617,
721,
277,
12,
790,
12,
1819,
304,
355,
291,
14,
20329,
590,
275,
298,
8283,
2,
953,
347,
636,
6095,
721,
277,
12,
790,
304,
355,
291,
14,
20329,
590,
275,
298,
14488,
2,
398,
6482,
2037,
275,
598,
1534,
1399,
1296,
2956,
32218,
342,
267,
6482,
2037,
459,
1662,
13,
498,
418,
275,
2624,
360,
352,
17,
358,
267,
291,
14,
2947,
8,
3528,
2037,
14,
20329,
590,
12,
298,
8283,
531,
267,
6482,
2037,
459,
1662,
13,
498,
418,
267,
291,
14,
2947,
8,
3528,
2037,
14,
20329,
590,
12,
298,
14488,
531,
339,
347,
511,
63,
2960,
63,
20982,
8,
277,
304,
267,
291,
14,
629,
7694,
17,
4706,
359,
17,
20230,
835,
779,
17,
2522,
413,
9,
327,
1455,
921,
13017,
14,
27179,
14,
1308,
15,
5237,
969,
1196,
339,
347,
511,
63,
5076,
63,
513,
8,
277,
304,
267,
408,
7496,
626,
28092,
590,
7031,
3245,
18041,
402,
1979,
22337,
883,
506,
14701,
1041,
267,
327,
675,
971,
78,
370,
7396,
370,
5126,
1798,
8826,
267,
9877,
275,
3468,
480,
905,
435,
3872,
60,
78,
1674,
904,
1332,
495,
8,
88,
9,
367,
671,
315,
4945,
8,
772,
1493,
1724,
435,
937,
531,
267,
291,
14,
629,
8,
552,
8,
6916,
395,
5049,
1493,
9,
267,
291,
14,
629,
8,
1838,
8,
6916,
395,
14785,
1965,
2333,
1493,
9,
199,
199,
533,
11086,
11090,
369,
1746,
8,
2796,
14,
1746,
304,
339,
347,
1255,
63,
6962,
8,
277,
12,
289,
12,
1967,
29,
709,
304,
267,
7183,
275,
942,
267,
367,
284,
315,
4945,
8,
1507,
304,
288,
307,
275,
5796,
14,
4436,
8,
1375,
29,
70,
9,
288,
307,
14,
928,
342,
288,
7183,
14,
740,
8,
84,
9,
267,
2653,
275,
1616,
14,
327,
506,
24002,
1519,
1785,
267,
367,
307,
315,
7183,
26,
288,
307,
14,
904,
8,
2593,
9,
288,
2653,
275,
378,
14,
267,
367,
307,
315,
7183,
26,
288,
291,
14,
3334,
8,
84,
14,
374,
23692,
1012,
339,
347,
511,
63,
740,
63,
2168,
8,
277,
304,
267,
327,
7131,
687,
2779,
455,
285,
428,
517,
979,
13,
2437,
4039,
1159,
511,
367,
4976,
959,
9335,
614,
267,
9877,
275,
942,
267,
347,
17570,
837,
288,
9428,
275,
5796,
14,
1818,
4436,
342,
288,
367,
284,
315,
1425,
8,
5279,
304,
355,
9877,
14,
740,
8,
319,
9,
355,
900,
14,
4532,
8,
16,
14,
4183,
9,
355,
9877,
14,
2168,
8,
319,
9,
267,
291,
14,
1065,
63,
6962,
8,
8234,
9,
267,
291,
14,
629,
8,
6916,
12,
3073,
339,
347,
511,
63,
3191,
8,
277,
304,
267,
9877,
275,
942,
267,
347,
17570,
837,
288,
9428,
275,
5796,
14,
1818,
4436,
342,
288,
367,
284,
315,
1425,
8,
5279,
304,
355,
9877,
14,
740,
8,
319,
9,
355,
9877,
14,
3191,
342,
355,
9877,
14,
2168,
8,
319,
9,
355,
900,
14,
4532,
8,
16,
14,
4183,
9,
267,
291,
14,
1065,
63,
6962,
8,
8234,
9,
267,
291,
14,
629,
8,
6916,
12,
3073,
339,
347,
511,
63,
835,
63,
4471,
8,
277,
304,
267,
9877,
275,
359,
16,
12,
17,
12,
18,
12,
19,
12,
20,
12,
21,
12,
22,
12,
23,
12,
24,
12,
25,
12,
709,
12,
16,
61,
267,
347,
17570,
837,
288,
9428,
275,
5796,
14,
1818,
4436,
342,
288,
367,
284,
315,
1425,
8,
5279,
304,
355,
291,
14,
629,
8,
6916,
59,
16,
467,
378,
9,
355,
340,
2196,
14,
2355,
342,
690,
378,
14,
21,
26,
490,
900,
14,
4532,
8,
16,
14,
4183,
9,
355,
9877,
14,
4471,
342,
355,
291,
14,
629,
8,
6916,
14,
835,
8,
16,
395,
499,
9,
355,
291,
14,
479,
2531,
6916,
59,
17,
61,
315,
334,
17,
12,
709,
430,
267,
291,
14,
1065,
63,
6962,
8,
8234,
9,
199,
199,
533,
13706,
14034,
1746,
8,
2796,
14,
1746,
304,
272,
1449,
497,
1183,
294,
82,
1119,
9243,
6014,
5331,
641,
769,
10595,
272,
730,
18,
396,
275,
769,
339,
347,
511,
63,
10525,
63,
5224,
63,
1807,
8,
277,
304,
267,
327,
21311,
641,
769,
63,
2219,
14,
7844,
774,
14,
396,
63,
10525,
83,
17463,
1275,
267,
327,
1010,
314,
286,
5703,
511,
1930,
12,
314,
3631,
574,
365,
17429,
590,
3544,
314,
849,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
scith/htpc-manager_ynh
|
sources/libs/cherrypy/lib/httpauth.py
|
47
|
13030
|
"""
This module defines functions to implement HTTP Digest Authentication
(:rfc:`2617`).
This has full compliance with 'Digest' and 'Basic' authentication methods. In
'Digest' it supports both MD5 and MD5-sess algorithms.
Usage:
First use 'doAuth' to request the client authentication for a
certain resource. You should send an httplib.UNAUTHORIZED response to the
client so he knows he has to authenticate itself.
Then use 'parseAuthorization' to retrieve the 'auth_map' used in
'checkResponse'.
To use 'checkResponse' you must have already verified the password
associated with the 'username' key in 'auth_map' dict. Then you use the
'checkResponse' function to verify if the password matches the one sent
by the client.
SUPPORTED_ALGORITHM - list of supported 'Digest' algorithms
SUPPORTED_QOP - list of supported 'Digest' 'qop'.
"""
__version__ = 1, 0, 1
__author__ = "Tiago Cogumbreiro <cogumbreiro@users.sf.net>"
__credits__ = """
Peter van Kampen for its recipe which implement most of Digest
authentication:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/302378
"""
__license__ = """
Copyright (c) 2005, Tiago Cogumbreiro <cogumbreiro@users.sf.net>
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 Sylvain Hellegouarch nor the names of his
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.
"""
__all__ = ("digestAuth", "basicAuth", "doAuth", "checkResponse",
"parseAuthorization", "SUPPORTED_ALGORITHM", "md5SessionKey",
"calculateNonce", "SUPPORTED_QOP")
##########################################################################
import time
from cherrypy._cpcompat import base64_decode, ntob, md5
from cherrypy._cpcompat import parse_http_list, parse_keqv_list
MD5 = "MD5"
MD5_SESS = "MD5-sess"
AUTH = "auth"
AUTH_INT = "auth-int"
SUPPORTED_ALGORITHM = (MD5, MD5_SESS)
SUPPORTED_QOP = (AUTH, AUTH_INT)
##########################################################################
# doAuth
#
DIGEST_AUTH_ENCODERS = {
MD5: lambda val: md5(ntob(val)).hexdigest(),
MD5_SESS: lambda val: md5(ntob(val)).hexdigest(),
# SHA: lambda val: sha.new(ntob(val)).hexdigest (),
}
def calculateNonce(realm, algorithm=MD5):
"""This is an auxaliary function that calculates 'nonce' value. It is used
to handle sessions."""
global SUPPORTED_ALGORITHM, DIGEST_AUTH_ENCODERS
assert algorithm in SUPPORTED_ALGORITHM
try:
encoder = DIGEST_AUTH_ENCODERS[algorithm]
except KeyError:
raise NotImplementedError("The chosen algorithm (%s) does not have "
"an implementation yet" % algorithm)
return encoder("%d:%s" % (time.time(), realm))
def digestAuth(realm, algorithm=MD5, nonce=None, qop=AUTH):
"""Challenges the client for a Digest authentication."""
global SUPPORTED_ALGORITHM, DIGEST_AUTH_ENCODERS, SUPPORTED_QOP
assert algorithm in SUPPORTED_ALGORITHM
assert qop in SUPPORTED_QOP
if nonce is None:
nonce = calculateNonce(realm, algorithm)
return 'Digest realm="%s", nonce="%s", algorithm="%s", qop="%s"' % (
realm, nonce, algorithm, qop
)
def basicAuth(realm):
"""Challengenes the client for a Basic authentication."""
assert '"' not in realm, "Realms cannot contain the \" (quote) character."
return 'Basic realm="%s"' % realm
def doAuth(realm):
"""'doAuth' function returns the challenge string b giving priority over
Digest and fallback to Basic authentication when the browser doesn't
support the first one.
This should be set in the HTTP header under the key 'WWW-Authenticate'."""
return digestAuth(realm) + " " + basicAuth(realm)
##########################################################################
# Parse authorization parameters
#
def _parseDigestAuthorization(auth_params):
# Convert the auth params to a dict
items = parse_http_list(auth_params)
params = parse_keqv_list(items)
# Now validate the params
# Check for required parameters
required = ["username", "realm", "nonce", "uri", "response"]
for k in required:
if k not in params:
return None
# If qop is sent then cnonce and nc MUST be present
if "qop" in params and not ("cnonce" in params
and "nc" in params):
return None
# If qop is not sent, neither cnonce nor nc can be present
if ("cnonce" in params or "nc" in params) and \
"qop" not in params:
return None
return params
def _parseBasicAuthorization(auth_params):
username, password = base64_decode(auth_params).split(":", 1)
return {"username": username, "password": password}
AUTH_SCHEMES = {
"basic": _parseBasicAuthorization,
"digest": _parseDigestAuthorization,
}
def parseAuthorization(credentials):
"""parseAuthorization will convert the value of the 'Authorization' key in
the HTTP header to a map itself. If the parsing fails 'None' is returned.
"""
global AUTH_SCHEMES
auth_scheme, auth_params = credentials.split(" ", 1)
auth_scheme = auth_scheme.lower()
parser = AUTH_SCHEMES[auth_scheme]
params = parser(auth_params)
if params is None:
return
assert "auth_scheme" not in params
params["auth_scheme"] = auth_scheme
return params
##########################################################################
# Check provided response for a valid password
#
def md5SessionKey(params, password):
"""
If the "algorithm" directive's value is "MD5-sess", then A1
[the session key] is calculated only once - on the first request by the
client following receipt of a WWW-Authenticate challenge from the server.
This creates a 'session key' for the authentication of subsequent
requests and responses which is different for each "authentication
session", thus limiting the amount of material hashed with any one
key.
Because the server need only use the hash of the user
credentials in order to create the A1 value, this construction could
be used in conjunction with a third party authentication service so
that the web server would not need the actual password value. The
specification of such a protocol is beyond the scope of this
specification.
"""
keys = ("username", "realm", "nonce", "cnonce")
params_copy = {}
for key in keys:
params_copy[key] = params[key]
params_copy["algorithm"] = MD5_SESS
return _A1(params_copy, password)
def _A1(params, password):
algorithm = params.get("algorithm", MD5)
H = DIGEST_AUTH_ENCODERS[algorithm]
if algorithm == MD5:
# If the "algorithm" directive's value is "MD5" or is
# unspecified, then A1 is:
# A1 = unq(username-value) ":" unq(realm-value) ":" passwd
return "%s:%s:%s" % (params["username"], params["realm"], password)
elif algorithm == MD5_SESS:
# This is A1 if qop is set
# A1 = H( unq(username-value) ":" unq(realm-value) ":" passwd )
# ":" unq(nonce-value) ":" unq(cnonce-value)
h_a1 = H("%s:%s:%s" % (params["username"], params["realm"], password))
return "%s:%s:%s" % (h_a1, params["nonce"], params["cnonce"])
def _A2(params, method, kwargs):
# If the "qop" directive's value is "auth" or is unspecified, then A2 is:
# A2 = Method ":" digest-uri-value
qop = params.get("qop", "auth")
if qop == "auth":
return method + ":" + params["uri"]
elif qop == "auth-int":
# If the "qop" value is "auth-int", then A2 is:
# A2 = Method ":" digest-uri-value ":" H(entity-body)
entity_body = kwargs.get("entity_body", "")
H = kwargs["H"]
return "%s:%s:%s" % (
method,
params["uri"],
H(entity_body)
)
else:
raise NotImplementedError("The 'qop' method is unknown: %s" % qop)
def _computeDigestResponse(auth_map, password, method="GET", A1=None,
**kwargs):
"""
Generates a response respecting the algorithm defined in RFC 2617
"""
params = auth_map
algorithm = params.get("algorithm", MD5)
H = DIGEST_AUTH_ENCODERS[algorithm]
KD = lambda secret, data: H(secret + ":" + data)
qop = params.get("qop", None)
H_A2 = H(_A2(params, method, kwargs))
if algorithm == MD5_SESS and A1 is not None:
H_A1 = H(A1)
else:
H_A1 = H(_A1(params, password))
if qop in ("auth", "auth-int"):
# If the "qop" value is "auth" or "auth-int":
# request-digest = <"> < KD ( H(A1), unq(nonce-value)
# ":" nc-value
# ":" unq(cnonce-value)
# ":" unq(qop-value)
# ":" H(A2)
# ) <">
request = "%s:%s:%s:%s:%s" % (
params["nonce"],
params["nc"],
params["cnonce"],
params["qop"],
H_A2,
)
elif qop is None:
# If the "qop" directive is not present (this construction is
# for compatibility with RFC 2069):
# request-digest =
# <"> < KD ( H(A1), unq(nonce-value) ":" H(A2) ) > <">
request = "%s:%s" % (params["nonce"], H_A2)
return KD(H_A1, request)
def _checkDigestResponse(auth_map, password, method="GET", A1=None, **kwargs):
"""This function is used to verify the response given by the client when
he tries to authenticate.
Optional arguments:
entity_body - when 'qop' is set to 'auth-int' you MUST provide the
raw data you are going to send to the client (usually the
HTML page.
request_uri - the uri from the request line compared with the 'uri'
directive of the authorization map. They must represent
the same resource (unused at this time).
"""
if auth_map['realm'] != kwargs.get('realm', None):
return False
response = _computeDigestResponse(
auth_map, password, method, A1, **kwargs)
return response == auth_map["response"]
def _checkBasicResponse(auth_map, password, method='GET', encrypt=None,
**kwargs):
# Note that the Basic response doesn't provide the realm value so we cannot
# test it
pass_through = lambda password, username=None: password
encrypt = encrypt or pass_through
try:
candidate = encrypt(auth_map["password"], auth_map["username"])
except TypeError:
# if encrypt only takes one parameter, it's the password
candidate = encrypt(auth_map["password"])
return candidate == password
AUTH_RESPONSES = {
"basic": _checkBasicResponse,
"digest": _checkDigestResponse,
}
def checkResponse(auth_map, password, method="GET", encrypt=None, **kwargs):
"""'checkResponse' compares the auth_map with the password and optionally
other arguments that each implementation might need.
If the response is of type 'Basic' then the function has the following
signature::
checkBasicResponse(auth_map, password) -> bool
If the response is of type 'Digest' then the function has the following
signature::
checkDigestResponse(auth_map, password, method='GET', A1=None) -> bool
The 'A1' argument is only used in MD5_SESS algorithm based responses.
Check md5SessionKey() for more info.
"""
checker = AUTH_RESPONSES[auth_map["auth_scheme"]]
return checker(auth_map, password, method=method, encrypt=encrypt,
**kwargs)
|
gpl-3.0
|
[
624,
199,
2765,
859,
7890,
3423,
370,
5669,
3101,
3757,
3199,
15995,
199,
8,
26,
8973,
1705,
1479,
1196,
14963,
199,
2765,
965,
2615,
4151,
543,
283,
18541,
7,
436,
283,
6845,
7,
6299,
3102,
14,
1010,
199,
7,
18541,
7,
652,
5171,
3865,
15830,
21,
436,
15830,
21,
13,
5480,
18036,
14,
199,
199,
7692,
26,
272,
7758,
675,
283,
1117,
2817,
7,
370,
1056,
314,
1890,
6299,
367,
282,
272,
9842,
2073,
14,
2047,
1077,
3222,
376,
8809,
14,
1734,
25303,
1149,
1177,
370,
314,
272,
1890,
880,
946,
19428,
946,
965,
370,
12895,
6337,
14,
339,
9442,
675,
283,
1122,
11626,
7,
370,
8044,
314,
283,
1178,
63,
1130,
7,
1202,
315,
272,
283,
1074,
2364,
1370,
339,
4005,
675,
283,
1074,
2364,
7,
1265,
1471,
1172,
2575,
16317,
314,
2505,
272,
4568,
543,
314,
283,
2473,
7,
790,
315,
283,
1178,
63,
1130,
7,
1211,
14,
9442,
1265,
675,
314,
272,
283,
1074,
2364,
7,
805,
370,
4911,
340,
314,
2505,
4450,
314,
1373,
4847,
272,
701,
314,
1890,
14,
199,
199,
15925,
63,
26613,
726,
1571,
45,
446,
769,
402,
3748,
283,
18541,
7,
18036,
199,
15925,
63,
49,
1938,
446,
769,
402,
3748,
283,
18541,
7,
283,
81,
411,
1370,
199,
624,
199,
363,
1023,
363,
275,
413,
12,
378,
12,
413,
199,
363,
2502,
363,
275,
298,
22731,
14315,
445,
974,
4295,
264,
14352,
665,
23147,
4295,
264,
14352,
32,
3707,
14,
7646,
14,
846,
4335,
199,
363,
22461,
363,
275,
408,
272,
22912,
20744,
1804,
5282,
287,
367,
2399,
17121,
1314,
5669,
4750,
402,
3757,
3199,
272,
6299,
26,
272,
1455,
921,
305,
4812,
14,
32595,
14,
957,
15,
1179,
9060,
15,
967,
32632,
15,
4718,
15,
25879,
15,
8551,
12046,
199,
624,
199,
199,
363,
1682,
363,
275,
408,
199,
7384,
334,
67,
9,
11811,
12,
377,
73,
14315,
445,
974,
4295,
264,
14352,
665,
23147,
4295,
264,
14352,
32,
3707,
14,
7646,
14,
846,
30,
199,
2422,
4481,
4644,
14,
199,
199,
497,
4972,
436,
675,
315,
1350,
436,
3366,
4513,
12,
543,
503,
1928,
199,
20945,
12,
787,
8211,
2741,
626,
314,
2569,
3704,
787,
7647,
26,
339,
627,
6823,
402,
1350,
1233,
1471,
8074,
314,
3432,
4248,
4245,
12,
489,
642,
769,
402,
3704,
436,
314,
2569,
6450,
14,
272,
627,
6823,
315,
3366,
1824,
1471,
9172,
314,
3432,
4248,
4245,
12,
489,
642,
769,
402,
3704,
436,
314,
2569,
6450,
315,
314,
3794,
489,
436,
15,
269,
1163,
8418,
2741,
543,
314,
4084,
14,
272,
627,
11443,
314,
536,
402,
5515,
6371,
1581,
869,
352,
4170,
810,
1047,
6590,
314,
1561,
402,
17049,
489,
8417,
1443,
506,
1202,
370,
10692,
503,
10016,
7585,
7131,
687,
489,
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,
199,
8974,
7168,
1549,
5292,
2990,
12,
6931,
12,
5400,
2845,
5471,
2296,
12,
2334,
5292,
199,
55,
2007,
2563,
1634,
3169,
2401,
3092,
2381,
437,
3115,
3104,
9315,
199,
6178,
8766,
1149,
14,
1621,
4825,
6461,
7000,
2334,
5877,
11489,
1549,
6483,
6262,
7024,
199,
2707,
1821,
8703,
12,
9168,
12,
9716,
12,
8820,
12,
9836,
12,
1549,
9110,
199,
36,
1156,
5383,
334,
6446,
12,
5400,
2845,
5471,
2296,
12,
9838,
1634,
9103,
9764,
1549,
199,
3279,
8670,
27,
9102,
1634,
4815,
12,
7126,
12,
1549,
9206,
27,
1549,
9748,
9831,
9,
9802,
199,
3263,
8558,
2401,
5258,
1821,
9815,
1634,
5603,
12,
7061,
1621,
7066,
12,
9644,
5603,
12,
199,
726,
7056,
334,
6446,
9254,
1549,
7334,
9,
7043,
1621,
1821,
9683,
5738,
1634,
2334,
4815,
199,
3359,
5749,
4141,
12,
9704,
8036,
9691,
1634,
2334,
9726,
1634,
9712,
9784,
14,
199,
624,
199,
199,
363,
452,
363,
275,
1689,
5671,
2817,
401,
298,
4316,
2817,
401,
298,
1117,
2817,
401,
298,
1074,
2364,
401,
1779,
298,
1122,
11626,
401,
298,
15925,
63,
26613,
726,
1571,
45,
401,
298,
1064,
21,
4434,
1197,
401,
1779,
298,
12063,
46,
5089,
401,
298,
15925,
63,
49,
1938,
531,
199,
199,
26863,
199,
646,
900,
199,
504,
13397,
423,
1850,
5819,
492,
1300,
772,
63,
2708,
12,
302,
475,
66,
12,
6128,
21,
199,
504,
13397,
423,
1850,
5819,
492,
2198,
63,
1014,
63,
513,
12,
2198,
63,
415,
81,
86,
63,
513,
199,
199,
5127,
21,
275,
298,
5127,
21,
2,
199,
5127,
21,
63,
51,
1608,
275,
298,
5127,
21,
13,
5480,
2,
199,
5580,
275,
298,
1178,
2,
199,
5580,
63,
2919,
275,
298,
1178,
13,
442,
2,
199,
199,
15925,
63,
26613,
726,
1571,
45,
275,
334,
5127,
21,
12,
15830,
21,
63,
51,
1608,
9,
199,
15925,
63,
49,
1938,
275,
334,
5580,
12,
7560,
63,
2919,
9,
199,
199,
26863,
199,
3,
886,
2817,
199,
3,
199,
22855,
1719,
63,
5580,
63,
742,
12592,
3960,
275,
469,
272,
15830,
21,
26,
2400,
1139,
26,
6128,
21,
8,
343,
2873,
8,
637,
4992,
11453,
1062,
272,
15830,
21,
63,
51,
1608,
26,
2400,
1139,
26,
6128,
21,
8,
343,
2873,
8,
637,
4992,
11453,
1062,
272,
327,
259,
12002,
26,
2400,
1139,
26,
7793,
14,
1222,
8,
343,
2873,
8,
637,
4992,
11453,
11969,
199,
93,
421,
199,
318,
8671,
46,
5089,
8,
7728,
12,
5563,
29,
5127,
21,
304,
272,
408,
2765,
365,
376,
11593,
10874,
695,
805,
626,
6966,
2335,
283,
10667,
7,
574,
14,
2779,
365,
1202,
272,
370,
2429,
12184,
1041,
339,
2288,
32501,
63,
26613,
726,
1571,
45,
12,
577,
1277,
1719,
63,
5580,
63,
742,
12592,
3960,
272,
702,
5563,
315,
32501,
63,
26613,
726,
1571,
45,
339,
862,
26,
267,
10295,
275,
577,
1277,
1719,
63,
5580,
63,
742,
12592,
3960,
59,
8833,
61,
272,
871,
4067,
26,
267,
746,
4279,
480,
1918,
12414,
5563,
4366,
83,
9,
1630,
440,
1172,
298,
3303,
298,
290,
4514,
5966,
2,
450,
5563,
9,
339,
372,
10295,
3647,
68,
2689,
83,
2,
450,
334,
521,
14,
521,
1062,
10482,
430,
421,
199,
318,
10017,
2817,
8,
7728,
12,
5563,
29,
5127,
21,
12,
13711,
29,
403,
12,
1894,
411,
29,
5580,
304,
272,
408,
1049,
30599,
314,
1890,
367,
282,
3757
] |
[
199,
2765,
859,
7890,
3423,
370,
5669,
3101,
3757,
3199,
15995,
199,
8,
26,
8973,
1705,
1479,
1196,
14963,
199,
2765,
965,
2615,
4151,
543,
283,
18541,
7,
436,
283,
6845,
7,
6299,
3102,
14,
1010,
199,
7,
18541,
7,
652,
5171,
3865,
15830,
21,
436,
15830,
21,
13,
5480,
18036,
14,
199,
199,
7692,
26,
272,
7758,
675,
283,
1117,
2817,
7,
370,
1056,
314,
1890,
6299,
367,
282,
272,
9842,
2073,
14,
2047,
1077,
3222,
376,
8809,
14,
1734,
25303,
1149,
1177,
370,
314,
272,
1890,
880,
946,
19428,
946,
965,
370,
12895,
6337,
14,
339,
9442,
675,
283,
1122,
11626,
7,
370,
8044,
314,
283,
1178,
63,
1130,
7,
1202,
315,
272,
283,
1074,
2364,
1370,
339,
4005,
675,
283,
1074,
2364,
7,
1265,
1471,
1172,
2575,
16317,
314,
2505,
272,
4568,
543,
314,
283,
2473,
7,
790,
315,
283,
1178,
63,
1130,
7,
1211,
14,
9442,
1265,
675,
314,
272,
283,
1074,
2364,
7,
805,
370,
4911,
340,
314,
2505,
4450,
314,
1373,
4847,
272,
701,
314,
1890,
14,
199,
199,
15925,
63,
26613,
726,
1571,
45,
446,
769,
402,
3748,
283,
18541,
7,
18036,
199,
15925,
63,
49,
1938,
446,
769,
402,
3748,
283,
18541,
7,
283,
81,
411,
1370,
199,
624,
199,
363,
1023,
363,
275,
413,
12,
378,
12,
413,
199,
363,
2502,
363,
275,
298,
22731,
14315,
445,
974,
4295,
264,
14352,
665,
23147,
4295,
264,
14352,
32,
3707,
14,
7646,
14,
846,
4335,
199,
363,
22461,
363,
275,
408,
272,
22912,
20744,
1804,
5282,
287,
367,
2399,
17121,
1314,
5669,
4750,
402,
3757,
3199,
272,
6299,
26,
272,
1455,
921,
305,
4812,
14,
32595,
14,
957,
15,
1179,
9060,
15,
967,
32632,
15,
4718,
15,
25879,
15,
8551,
12046,
199,
624,
199,
199,
363,
1682,
363,
275,
408,
199,
7384,
334,
67,
9,
11811,
12,
377,
73,
14315,
445,
974,
4295,
264,
14352,
665,
23147,
4295,
264,
14352,
32,
3707,
14,
7646,
14,
846,
30,
199,
2422,
4481,
4644,
14,
199,
199,
497,
4972,
436,
675,
315,
1350,
436,
3366,
4513,
12,
543,
503,
1928,
199,
20945,
12,
787,
8211,
2741,
626,
314,
2569,
3704,
787,
7647,
26,
339,
627,
6823,
402,
1350,
1233,
1471,
8074,
314,
3432,
4248,
4245,
12,
489,
642,
769,
402,
3704,
436,
314,
2569,
6450,
14,
272,
627,
6823,
315,
3366,
1824,
1471,
9172,
314,
3432,
4248,
4245,
12,
489,
642,
769,
402,
3704,
436,
314,
2569,
6450,
315,
314,
3794,
489,
436,
15,
269,
1163,
8418,
2741,
543,
314,
4084,
14,
272,
627,
11443,
314,
536,
402,
5515,
6371,
1581,
869,
352,
4170,
810,
1047,
6590,
314,
1561,
402,
17049,
489,
8417,
1443,
506,
1202,
370,
10692,
503,
10016,
7585,
7131,
687,
489,
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,
199,
8974,
7168,
1549,
5292,
2990,
12,
6931,
12,
5400,
2845,
5471,
2296,
12,
2334,
5292,
199,
55,
2007,
2563,
1634,
3169,
2401,
3092,
2381,
437,
3115,
3104,
9315,
199,
6178,
8766,
1149,
14,
1621,
4825,
6461,
7000,
2334,
5877,
11489,
1549,
6483,
6262,
7024,
199,
2707,
1821,
8703,
12,
9168,
12,
9716,
12,
8820,
12,
9836,
12,
1549,
9110,
199,
36,
1156,
5383,
334,
6446,
12,
5400,
2845,
5471,
2296,
12,
9838,
1634,
9103,
9764,
1549,
199,
3279,
8670,
27,
9102,
1634,
4815,
12,
7126,
12,
1549,
9206,
27,
1549,
9748,
9831,
9,
9802,
199,
3263,
8558,
2401,
5258,
1821,
9815,
1634,
5603,
12,
7061,
1621,
7066,
12,
9644,
5603,
12,
199,
726,
7056,
334,
6446,
9254,
1549,
7334,
9,
7043,
1621,
1821,
9683,
5738,
1634,
2334,
4815,
199,
3359,
5749,
4141,
12,
9704,
8036,
9691,
1634,
2334,
9726,
1634,
9712,
9784,
14,
199,
624,
199,
199,
363,
452,
363,
275,
1689,
5671,
2817,
401,
298,
4316,
2817,
401,
298,
1117,
2817,
401,
298,
1074,
2364,
401,
1779,
298,
1122,
11626,
401,
298,
15925,
63,
26613,
726,
1571,
45,
401,
298,
1064,
21,
4434,
1197,
401,
1779,
298,
12063,
46,
5089,
401,
298,
15925,
63,
49,
1938,
531,
199,
199,
26863,
199,
646,
900,
199,
504,
13397,
423,
1850,
5819,
492,
1300,
772,
63,
2708,
12,
302,
475,
66,
12,
6128,
21,
199,
504,
13397,
423,
1850,
5819,
492,
2198,
63,
1014,
63,
513,
12,
2198,
63,
415,
81,
86,
63,
513,
199,
199,
5127,
21,
275,
298,
5127,
21,
2,
199,
5127,
21,
63,
51,
1608,
275,
298,
5127,
21,
13,
5480,
2,
199,
5580,
275,
298,
1178,
2,
199,
5580,
63,
2919,
275,
298,
1178,
13,
442,
2,
199,
199,
15925,
63,
26613,
726,
1571,
45,
275,
334,
5127,
21,
12,
15830,
21,
63,
51,
1608,
9,
199,
15925,
63,
49,
1938,
275,
334,
5580,
12,
7560,
63,
2919,
9,
199,
199,
26863,
199,
3,
886,
2817,
199,
3,
199,
22855,
1719,
63,
5580,
63,
742,
12592,
3960,
275,
469,
272,
15830,
21,
26,
2400,
1139,
26,
6128,
21,
8,
343,
2873,
8,
637,
4992,
11453,
1062,
272,
15830,
21,
63,
51,
1608,
26,
2400,
1139,
26,
6128,
21,
8,
343,
2873,
8,
637,
4992,
11453,
1062,
272,
327,
259,
12002,
26,
2400,
1139,
26,
7793,
14,
1222,
8,
343,
2873,
8,
637,
4992,
11453,
11969,
199,
93,
421,
199,
318,
8671,
46,
5089,
8,
7728,
12,
5563,
29,
5127,
21,
304,
272,
408,
2765,
365,
376,
11593,
10874,
695,
805,
626,
6966,
2335,
283,
10667,
7,
574,
14,
2779,
365,
1202,
272,
370,
2429,
12184,
1041,
339,
2288,
32501,
63,
26613,
726,
1571,
45,
12,
577,
1277,
1719,
63,
5580,
63,
742,
12592,
3960,
272,
702,
5563,
315,
32501,
63,
26613,
726,
1571,
45,
339,
862,
26,
267,
10295,
275,
577,
1277,
1719,
63,
5580,
63,
742,
12592,
3960,
59,
8833,
61,
272,
871,
4067,
26,
267,
746,
4279,
480,
1918,
12414,
5563,
4366,
83,
9,
1630,
440,
1172,
298,
3303,
298,
290,
4514,
5966,
2,
450,
5563,
9,
339,
372,
10295,
3647,
68,
2689,
83,
2,
450,
334,
521,
14,
521,
1062,
10482,
430,
421,
199,
318,
10017,
2817,
8,
7728,
12,
5563,
29,
5127,
21,
12,
13711,
29,
403,
12,
1894,
411,
29,
5580,
304,
272,
408,
1049,
30599,
314,
1890,
367,
282,
3757,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
ForensicTools/GRREAT-475_2141-Chaigon-Failey-Siebert
|
lib/flows/general/fingerprint.py
|
4
|
4119
|
#!/usr/bin/env python
# Copyright 2012 Google Inc. All Rights Reserved.
"""Invoke the fingerprint client action on a file."""
from grr.lib import aff4
from grr.lib import flow
from grr.lib import rdfvalue
from grr.proto import flows_pb2
class FingerprintFileArgs(rdfvalue.RDFProtoStruct):
protobuf = flows_pb2.FingerprintFileArgs
class FingerprintFileResult(rdfvalue.RDFProtoStruct):
protobuf = flows_pb2.FingerprintFileResult
class FingerprintFileMixin(object):
"""Retrieve all fingerprints of a file."""
def FingerprintFile(self, pathspec, request_data=None):
"""Launch a fingerprint client action."""
request = rdfvalue.FingerprintRequest(pathspec=pathspec)
# Generic hash.
request.AddRequest(
fp_type=rdfvalue.FingerprintTuple.Type.FPT_GENERIC,
hashers=[rdfvalue.FingerprintTuple.Hash.MD5,
rdfvalue.FingerprintTuple.Hash.SHA1,
rdfvalue.FingerprintTuple.Hash.SHA256])
# Authenticode hash.
request.AddRequest(
fp_type=rdfvalue.FingerprintTuple.Type.FPT_PE_COFF,
hashers=[rdfvalue.FingerprintTuple.Hash.MD5,
rdfvalue.FingerprintTuple.Hash.SHA1,
rdfvalue.FingerprintTuple.Hash.SHA256])
self.CallClient("FingerprintFile", request, next_state="ProcessFingerprint",
request_data=request_data)
@flow.StateHandler()
def ProcessFingerprint(self, responses):
"""Store the fingerprint response."""
if not responses.success:
# Its better to raise rather than merely logging since it will make it to
# the flow's protobuf and users can inspect the reason this flow failed.
raise flow.FlowError("Could not fingerprint file: %s" % responses.status)
response = responses.First()
if response.pathspec.path:
urn = aff4.AFF4Object.VFSGRRClient.PathspecToURN(response.pathspec,
self.client_id)
else:
urn = aff4.AFF4Object.VFSGRRClient.PathspecToURN(self.args.pathspec,
self.client_id)
self.state.Register("urn", urn)
fd = aff4.FACTORY.Create(urn, "VFSFile", mode="w", token=self.token)
hash_obj = fd.Schema.HASH()
for result in response.results:
if result["name"] == "generic":
for hash_type in ["md5", "sha1", "sha256"]:
value = result.GetItem(hash_type)
if value:
setattr(hash_obj, hash_type, value)
if result["name"] == "pecoff":
for hash_type in ["md5", "sha1", "sha256"]:
value = result.GetItem(hash_type)
if value:
setattr(hash_obj, "pecoff_" + hash_type, value)
signed_data = result.GetItem("SignedData", [])
for data in signed_data:
hash_obj.signed_data.Append(
revision=data[0], cert_type=data[1], certificate=data[2])
fd.Set(hash_obj)
# TODO(user): This attribute will be deprecated in the future. Do not
# use.
fd.Set(fd.Schema.FINGERPRINT(response))
fd.Close(sync=False)
self.ReceiveFileFingerprint(
urn, hash_obj, request_data=responses.request_data)
def ReceiveFileFingerprint(self, urn, hash_obj, request_data=None):
"""This method will be called with the new urn and the received hash."""
class FingerprintFile(FingerprintFileMixin, flow.GRRFlow):
"""Retrieve all fingerprints of a file."""
category = "/Filesystem/"
args_type = FingerprintFileArgs
behaviours = flow.GRRFlow.behaviours + "ADVANCED"
@flow.StateHandler(next_state="Done")
def Start(self):
"""Issue the fingerprinting request."""
self.FingerprintFile(self.args.pathspec)
def ReceiveFileFingerprint(self, urn, hash_obj, request_data=None):
# Notify any parent flows.
self.SendReply(FingerprintFileResult(file_urn=urn, hash_entry=hash_obj))
@flow.StateHandler()
def End(self):
"""Finalize the flow."""
super(FingerprintFile, self).End()
self.Notify("ViewObject", self.state.urn, "Fingerprint retrieved.")
self.Status("Finished fingerprinting %s", self.args.pathspec.path)
|
apache-2.0
|
[
3381,
2647,
15,
1393,
15,
1813,
2366,
199,
3,
1898,
6029,
4475,
3277,
14,
2900,
5924,
5702,
14,
199,
624,
27736,
314,
18020,
1890,
1595,
641,
282,
570,
1041,
421,
199,
504,
31118,
14,
773,
492,
9876,
20,
199,
504,
31118,
14,
773,
492,
6369,
199,
504,
31118,
14,
773,
492,
18148,
585,
199,
504,
31118,
14,
2625,
492,
30708,
63,
3317,
18,
421,
199,
533,
481,
9429,
1173,
6213,
8,
17120,
585,
14,
28949,
8548,
4836,
304,
523,
25886,
275,
30708,
63,
3317,
18,
14,
28521,
1173,
6213,
421,
199,
533,
481,
9429,
1173,
2889,
8,
17120,
585,
14,
28949,
8548,
4836,
304,
523,
25886,
275,
30708,
63,
3317,
18,
14,
28521,
1173,
2889,
421,
199,
533,
481,
9429,
1173,
4256,
8,
785,
304,
523,
408,
15310,
1006,
18020,
83,
402,
282,
570,
1041,
819,
347,
481,
9429,
1173,
8,
277,
12,
931,
1650,
12,
1056,
63,
576,
29,
403,
304,
272,
408,
18543,
282,
18020,
1890,
1595,
1041,
272,
1056,
275,
18148,
585,
14,
28521,
2017,
8,
515,
1650,
29,
515,
1650,
9,
339,
327,
8307,
2631,
14,
272,
1056,
14,
1123,
2017,
8,
267,
4090,
63,
466,
29,
17120,
585,
14,
28521,
7075,
14,
804,
14,
38,
4189,
63,
29395,
12,
267,
2631,
1192,
1524,
17120,
585,
14,
28521,
7075,
14,
3476,
14,
5127,
21,
12,
326,
18148,
585,
14,
28521,
7075,
14,
3476,
14,
8461,
17,
12,
326,
18148,
585,
14,
28521,
7075,
14,
3476,
14,
8461,
3912,
566,
339,
327,
3590,
287,
280,
600,
2631,
14,
272,
1056,
14,
1123,
2017,
8,
267,
4090,
63,
466,
29,
17120,
585,
14,
28521,
7075,
14,
804,
14,
38,
4189,
63,
1510,
63,
1439,
1665,
12,
267,
2631,
1192,
1524,
17120,
585,
14,
28521,
7075,
14,
3476,
14,
5127,
21,
12,
326,
18148,
585,
14,
28521,
7075,
14,
3476,
14,
8461,
17,
12,
326,
18148,
585,
14,
28521,
7075,
14,
3476,
14,
8461,
3912,
566,
339,
291,
14,
2176,
3041,
480,
28521,
1173,
401,
1056,
12,
2163,
63,
929,
628,
3498,
28521,
401,
490,
1056,
63,
576,
29,
1069,
63,
576,
9,
819,
768,
1659,
14,
2223,
2461,
342,
523,
347,
7132,
28521,
8,
277,
12,
9320,
304,
272,
408,
5502,
314,
18020,
1177,
1041,
272,
340,
440,
9320,
14,
3742,
26,
489,
327,
22940,
8034,
370,
746,
7830,
2419,
562,
264,
590,
2050,
3967,
652,
911,
1852,
652,
370,
489,
327,
314,
6369,
1159,
25886,
436,
4390,
883,
6485,
314,
4499,
642,
6369,
3405,
14,
489,
746,
6369,
14,
5060,
547,
480,
6531,
440,
18020,
570,
26,
450,
83,
2,
450,
9320,
14,
1205,
9,
339,
1177,
275,
9320,
14,
7147,
342,
272,
340,
1177,
14,
515,
1650,
14,
515,
26,
489,
221,
349,
275,
9876,
20,
14,
25900,
20,
1692,
14,
54,
7079,
3975,
50,
3041,
14,
2042,
1650,
1378,
7648,
8,
1310,
14,
515,
1650,
12,
10940,
291,
14,
1258,
63,
344,
9,
272,
587,
26,
489,
221,
349,
275,
9876,
20,
14,
25900,
20,
1692,
14,
54,
7079,
3975,
50,
3041,
14,
2042,
1650,
1378,
7648,
8,
277,
14,
589,
14,
515,
1650,
12,
10940,
291,
14,
1258,
63,
344,
9,
272,
291,
14,
929,
14,
7099,
480,
349,
401,
221,
349,
9,
339,
6111,
275,
9876,
20,
14,
18164,
5347,
14,
2499,
8,
349,
12,
298,
54,
7079,
1173,
401,
818,
628,
87,
401,
1526,
29,
277,
14,
1418,
9,
339,
2631,
63,
1113,
275,
6111,
14,
6700,
14,
14395,
342,
339,
367,
754,
315,
1177,
14,
2604,
26,
489,
340,
754,
905,
354,
937,
508,
298,
6767,
582,
267,
367,
2631,
63,
466,
315,
2097,
1064,
21,
401,
298,
4835,
17,
401,
298,
4835,
3912,
6229,
881,
574,
275,
754,
14,
32474,
8,
2227,
63,
466,
9,
881,
340,
574,
26,
288,
5371,
8,
2227,
63,
1113,
12,
2631,
63,
466,
12,
574,
9,
2541,
340,
754,
905,
354,
937,
508,
298,
321,
331,
556,
582,
267,
367,
2631,
63,
466,
315,
2097,
1064,
21,
401,
298,
4835,
17,
401,
298,
4835,
3912,
6229,
881,
574,
275,
754,
14,
32474,
8,
2227,
63,
466,
9,
881,
340,
574,
26,
288,
5371,
8,
2227,
63,
1113,
12,
298,
321,
331,
556,
12172,
435,
2631,
63,
466,
12,
574,
9,
398,
10514,
63,
576,
275,
754,
14,
32474,
480,
23013,
1451,
401,
3073,
267,
367,
666,
315,
10514,
63,
576,
26,
881,
2631,
63,
1113,
14,
1737,
63,
576,
14,
8310,
8,
1598,
6974,
29,
576,
59,
16,
467,
6250,
63,
466,
29,
576,
59,
17,
467,
5897,
29,
576,
59,
18,
566,
339,
6111,
14,
1084,
8,
2227,
63,
1113,
9,
339,
327,
3254,
8,
751,
304,
961,
2225,
911,
506,
5906,
315,
314,
6466,
14,
4226,
440,
272,
327,
675,
14,
272,
6111,
14,
1084,
8,
2592,
14,
6700,
14,
38,
1206,
540,
21754,
8,
1310,
430,
272,
6111,
14,
4724,
8,
5186,
29,
797,
9,
339,
291,
14,
14235,
1173,
28521,
8,
267,
221,
349,
12,
2631,
63,
1113,
12,
1056,
63,
576,
29,
10360,
14,
1069,
63,
576,
9,
819,
347,
799,
5251,
1173,
28521,
8,
277,
12,
221,
349,
12,
2631,
63,
1113,
12,
1056,
63,
576,
29,
403,
304,
272,
408,
2765,
1083,
911,
506,
2797,
543,
314,
892,
221,
349,
436,
314,
3086,
2631,
1041,
421,
199,
533,
481,
9429,
1173,
8,
28521,
1173,
4256,
12,
6369,
14,
3975,
50,
5060,
304,
523,
408,
15310,
1006,
18020,
83,
402,
282,
570,
1041,
819,
4637,
275,
3286,
1173,
2253,
6687,
523,
1249,
63,
466,
275,
481,
9429,
1173,
6213,
523,
13942,
83,
275,
6369,
14,
3975,
50,
5060,
14,
1235,
4425,
16363,
435,
298,
1554,
54,
879,
25927,
2,
819,
768,
1659,
14,
2223,
2461,
8,
2184,
63,
929,
628,
10759,
531,
523,
347,
7707,
8,
277,
304,
272,
408,
17106,
314,
18020,
316,
1056,
1041,
272,
291,
14,
28521,
1173,
8,
277,
14,
589,
14,
515,
1650,
9,
819,
347,
799,
5251,
1173,
28521,
8,
277,
12,
221,
349,
12,
2631,
63,
1113,
12,
1056,
63,
576,
29,
403,
304,
272,
327,
31949,
1263,
1676,
30708,
14,
272,
291,
14,
6795,
14166,
8,
28521,
1173,
2889,
8,
493,
63,
349,
29,
349,
12,
2631,
63,
2373,
29,
2227,
63,
1113,
430
] |
[
2647,
15,
1393,
15,
1813,
2366,
199,
3,
1898,
6029,
4475,
3277,
14,
2900,
5924,
5702,
14,
199,
624,
27736,
314,
18020,
1890,
1595,
641,
282,
570,
1041,
421,
199,
504,
31118,
14,
773,
492,
9876,
20,
199,
504,
31118,
14,
773,
492,
6369,
199,
504,
31118,
14,
773,
492,
18148,
585,
199,
504,
31118,
14,
2625,
492,
30708,
63,
3317,
18,
421,
199,
533,
481,
9429,
1173,
6213,
8,
17120,
585,
14,
28949,
8548,
4836,
304,
523,
25886,
275,
30708,
63,
3317,
18,
14,
28521,
1173,
6213,
421,
199,
533,
481,
9429,
1173,
2889,
8,
17120,
585,
14,
28949,
8548,
4836,
304,
523,
25886,
275,
30708,
63,
3317,
18,
14,
28521,
1173,
2889,
421,
199,
533,
481,
9429,
1173,
4256,
8,
785,
304,
523,
408,
15310,
1006,
18020,
83,
402,
282,
570,
1041,
819,
347,
481,
9429,
1173,
8,
277,
12,
931,
1650,
12,
1056,
63,
576,
29,
403,
304,
272,
408,
18543,
282,
18020,
1890,
1595,
1041,
272,
1056,
275,
18148,
585,
14,
28521,
2017,
8,
515,
1650,
29,
515,
1650,
9,
339,
327,
8307,
2631,
14,
272,
1056,
14,
1123,
2017,
8,
267,
4090,
63,
466,
29,
17120,
585,
14,
28521,
7075,
14,
804,
14,
38,
4189,
63,
29395,
12,
267,
2631,
1192,
1524,
17120,
585,
14,
28521,
7075,
14,
3476,
14,
5127,
21,
12,
326,
18148,
585,
14,
28521,
7075,
14,
3476,
14,
8461,
17,
12,
326,
18148,
585,
14,
28521,
7075,
14,
3476,
14,
8461,
3912,
566,
339,
327,
3590,
287,
280,
600,
2631,
14,
272,
1056,
14,
1123,
2017,
8,
267,
4090,
63,
466,
29,
17120,
585,
14,
28521,
7075,
14,
804,
14,
38,
4189,
63,
1510,
63,
1439,
1665,
12,
267,
2631,
1192,
1524,
17120,
585,
14,
28521,
7075,
14,
3476,
14,
5127,
21,
12,
326,
18148,
585,
14,
28521,
7075,
14,
3476,
14,
8461,
17,
12,
326,
18148,
585,
14,
28521,
7075,
14,
3476,
14,
8461,
3912,
566,
339,
291,
14,
2176,
3041,
480,
28521,
1173,
401,
1056,
12,
2163,
63,
929,
628,
3498,
28521,
401,
490,
1056,
63,
576,
29,
1069,
63,
576,
9,
819,
768,
1659,
14,
2223,
2461,
342,
523,
347,
7132,
28521,
8,
277,
12,
9320,
304,
272,
408,
5502,
314,
18020,
1177,
1041,
272,
340,
440,
9320,
14,
3742,
26,
489,
327,
22940,
8034,
370,
746,
7830,
2419,
562,
264,
590,
2050,
3967,
652,
911,
1852,
652,
370,
489,
327,
314,
6369,
1159,
25886,
436,
4390,
883,
6485,
314,
4499,
642,
6369,
3405,
14,
489,
746,
6369,
14,
5060,
547,
480,
6531,
440,
18020,
570,
26,
450,
83,
2,
450,
9320,
14,
1205,
9,
339,
1177,
275,
9320,
14,
7147,
342,
272,
340,
1177,
14,
515,
1650,
14,
515,
26,
489,
221,
349,
275,
9876,
20,
14,
25900,
20,
1692,
14,
54,
7079,
3975,
50,
3041,
14,
2042,
1650,
1378,
7648,
8,
1310,
14,
515,
1650,
12,
10940,
291,
14,
1258,
63,
344,
9,
272,
587,
26,
489,
221,
349,
275,
9876,
20,
14,
25900,
20,
1692,
14,
54,
7079,
3975,
50,
3041,
14,
2042,
1650,
1378,
7648,
8,
277,
14,
589,
14,
515,
1650,
12,
10940,
291,
14,
1258,
63,
344,
9,
272,
291,
14,
929,
14,
7099,
480,
349,
401,
221,
349,
9,
339,
6111,
275,
9876,
20,
14,
18164,
5347,
14,
2499,
8,
349,
12,
298,
54,
7079,
1173,
401,
818,
628,
87,
401,
1526,
29,
277,
14,
1418,
9,
339,
2631,
63,
1113,
275,
6111,
14,
6700,
14,
14395,
342,
339,
367,
754,
315,
1177,
14,
2604,
26,
489,
340,
754,
905,
354,
937,
508,
298,
6767,
582,
267,
367,
2631,
63,
466,
315,
2097,
1064,
21,
401,
298,
4835,
17,
401,
298,
4835,
3912,
6229,
881,
574,
275,
754,
14,
32474,
8,
2227,
63,
466,
9,
881,
340,
574,
26,
288,
5371,
8,
2227,
63,
1113,
12,
2631,
63,
466,
12,
574,
9,
2541,
340,
754,
905,
354,
937,
508,
298,
321,
331,
556,
582,
267,
367,
2631,
63,
466,
315,
2097,
1064,
21,
401,
298,
4835,
17,
401,
298,
4835,
3912,
6229,
881,
574,
275,
754,
14,
32474,
8,
2227,
63,
466,
9,
881,
340,
574,
26,
288,
5371,
8,
2227,
63,
1113,
12,
298,
321,
331,
556,
12172,
435,
2631,
63,
466,
12,
574,
9,
398,
10514,
63,
576,
275,
754,
14,
32474,
480,
23013,
1451,
401,
3073,
267,
367,
666,
315,
10514,
63,
576,
26,
881,
2631,
63,
1113,
14,
1737,
63,
576,
14,
8310,
8,
1598,
6974,
29,
576,
59,
16,
467,
6250,
63,
466,
29,
576,
59,
17,
467,
5897,
29,
576,
59,
18,
566,
339,
6111,
14,
1084,
8,
2227,
63,
1113,
9,
339,
327,
3254,
8,
751,
304,
961,
2225,
911,
506,
5906,
315,
314,
6466,
14,
4226,
440,
272,
327,
675,
14,
272,
6111,
14,
1084,
8,
2592,
14,
6700,
14,
38,
1206,
540,
21754,
8,
1310,
430,
272,
6111,
14,
4724,
8,
5186,
29,
797,
9,
339,
291,
14,
14235,
1173,
28521,
8,
267,
221,
349,
12,
2631,
63,
1113,
12,
1056,
63,
576,
29,
10360,
14,
1069,
63,
576,
9,
819,
347,
799,
5251,
1173,
28521,
8,
277,
12,
221,
349,
12,
2631,
63,
1113,
12,
1056,
63,
576,
29,
403,
304,
272,
408,
2765,
1083,
911,
506,
2797,
543,
314,
892,
221,
349,
436,
314,
3086,
2631,
1041,
421,
199,
533,
481,
9429,
1173,
8,
28521,
1173,
4256,
12,
6369,
14,
3975,
50,
5060,
304,
523,
408,
15310,
1006,
18020,
83,
402,
282,
570,
1041,
819,
4637,
275,
3286,
1173,
2253,
6687,
523,
1249,
63,
466,
275,
481,
9429,
1173,
6213,
523,
13942,
83,
275,
6369,
14,
3975,
50,
5060,
14,
1235,
4425,
16363,
435,
298,
1554,
54,
879,
25927,
2,
819,
768,
1659,
14,
2223,
2461,
8,
2184,
63,
929,
628,
10759,
531,
523,
347,
7707,
8,
277,
304,
272,
408,
17106,
314,
18020,
316,
1056,
1041,
272,
291,
14,
28521,
1173,
8,
277,
14,
589,
14,
515,
1650,
9,
819,
347,
799,
5251,
1173,
28521,
8,
277,
12,
221,
349,
12,
2631,
63,
1113,
12,
1056,
63,
576,
29,
403,
304,
272,
327,
31949,
1263,
1676,
30708,
14,
272,
291,
14,
6795,
14166,
8,
28521,
1173,
2889,
8,
493,
63,
349,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1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
snd/dejavu
|
dejavu/wavio.py
|
20
|
4076
|
# wavio.py
# Author: Warren Weckesser
# License: BSD 3-Clause (http://opensource.org/licenses/BSD-3-Clause)
# Synopsis: A Python module for reading and writing 24 bit WAV files.
# Github: github.com/WarrenWeckesser/wavio
import wave as _wave
import numpy as _np
def _wav2array(nchannels, sampwidth, data):
"""data must be the string containing the bytes from the wav file."""
num_samples, remainder = divmod(len(data), sampwidth * nchannels)
if remainder > 0:
raise ValueError('The length of data is not a multiple of '
'sampwidth * num_channels.')
if sampwidth > 4:
raise ValueError("sampwidth must not be greater than 4.")
if sampwidth == 3:
a = _np.empty((num_samples, nchannels, 4), dtype=_np.uint8)
raw_bytes = _np.fromstring(data, dtype=_np.uint8)
a[:, :, :sampwidth] = raw_bytes.reshape(-1, nchannels, sampwidth)
a[:, :, sampwidth:] = (a[:, :, sampwidth - 1:sampwidth] >> 7) * 255
result = a.view('<i4').reshape(a.shape[:-1])
else:
# 8 bit samples are stored as unsigned ints; others as signed ints.
dt_char = 'u' if sampwidth == 1 else 'i'
a = _np.fromstring(data, dtype='<%s%d' % (dt_char, sampwidth))
result = a.reshape(-1, nchannels)
return result
def readwav(file):
"""
Read a WAV file.
Parameters
----------
file : string or file object
Either the name of a file or an open file pointer.
Return Values
-------------
rate : float
The sampling frequency (i.e. frame rate)
sampwidth : float
The sample width, in bytes. E.g. for a 24 bit WAV file,
sampwidth is 3.
data : numpy array
The array containing the data. The shape of the array is
(num_samples, num_channels). num_channels is the number of
audio channels (1 for mono, 2 for stereo).
Notes
-----
This function uses the `wave` module of the Python standard libary
to read the WAV file, so it has the same limitations as that library.
In particular, the function does not read compressed WAV files.
"""
wav = _wave.open(file)
rate = wav.getframerate()
nchannels = wav.getnchannels()
sampwidth = wav.getsampwidth()
nframes = wav.getnframes()
data = wav.readframes(nframes)
wav.close()
array = _wav2array(nchannels, sampwidth, data)
return rate, sampwidth, array
def writewav24(filename, rate, data):
"""
Create a 24 bit wav file.
Parameters
----------
filename : string
Name of the file to create.
rate : float
The sampling frequency (i.e. frame rate) of the data.
data : array-like collection of integer or floating point values
data must be "array-like", either 1- or 2-dimensional. If it
is 2-d, the rows are the frames (i.e. samples) and the columns
are the channels.
Notes
-----
The data is assumed to be signed, and the values are assumed to be
within the range of a 24 bit integer. Floating point values are
converted to integers. The data is not rescaled or normalized before
writing it to the file.
Example
-------
Create a 3 second 440 Hz sine wave.
>>> rate = 22050 # samples per second
>>> T = 3 # sample duration (seconds)
>>> f = 440.0 # sound frequency (Hz)
>>> t = np.linspace(0, T, T*rate, endpoint=False)
>>> x = (2**23 - 1) * np.sin(2 * np.pi * f * t)
>>> writewav24("sine24.wav", rate, x)
"""
a32 = _np.asarray(data, dtype=_np.int32)
if a32.ndim == 1:
# Convert to a 2D array with a single column.
a32.shape = a32.shape + (1,)
# By shifting first 0 bits, then 8, then 16, the resulting output
# is 24 bit little-endian.
a8 = (a32.reshape(a32.shape + (1,)) >> _np.array([0, 8, 16])) & 255
wavdata = a8.astype(_np.uint8).tostring()
w = _wave.open(filename, 'wb')
w.setnchannels(a32.shape[1])
w.setsampwidth(3)
w.setframerate(rate)
w.writeframes(wavdata)
w.close()
|
mit
|
[
3,
336,
7194,
79,
14,
647,
199,
3,
6529,
26,
644,
285,
828,
2136,
346,
6350,
199,
3,
844,
26,
6289,
650,
13,
16009,
334,
1014,
921,
16374,
14,
1308,
15,
2383,
15,
15400,
13,
19,
13,
16009,
9,
199,
3,
29988,
27573,
26,
437,
2018,
859,
367,
7664,
436,
3575,
5504,
4546,
644,
6087,
1584,
14,
199,
3,
598,
4049,
26,
12869,
14,
957,
15,
55,
285,
828,
6004,
346,
6350,
15,
758,
32052,
199,
199,
646,
12204,
465,
485,
10024,
199,
646,
2680,
465,
485,
1590,
421,
199,
318,
485,
19118,
18,
1144,
8,
78,
6324,
12,
2937,
311,
2063,
12,
666,
304,
272,
408,
576,
1471,
506,
314,
1059,
3035,
314,
2783,
687,
314,
336,
1214,
570,
1041,
272,
1967,
63,
3356,
12,
15748,
275,
16438,
8,
552,
8,
576,
395,
2937,
311,
2063,
627,
302,
6324,
9,
272,
340,
15748,
690,
378,
26,
267,
746,
1722,
360,
1918,
2582,
402,
666,
365,
440,
282,
3663,
402,
283,
586,
283,
16557,
2063,
627,
1967,
63,
6324,
2659,
272,
340,
2937,
311,
2063,
690,
841,
26,
267,
746,
1722,
480,
16557,
2063,
1471,
440,
506,
8932,
2419,
841,
2685,
339,
340,
2937,
311,
2063,
508,
650,
26,
267,
282,
275,
485,
1590,
14,
1667,
1332,
1507,
63,
3356,
12,
302,
6324,
12,
841,
395,
2152,
3699,
1590,
14,
1635,
24,
9,
267,
3066,
63,
2394,
275,
485,
1590,
14,
13521,
8,
576,
12,
2152,
3699,
1590,
14,
1635,
24,
9,
267,
282,
3981,
13785,
520,
16557,
2063,
61,
275,
3066,
63,
2394,
14,
5217,
2801,
17,
12,
302,
6324,
12,
2937,
311,
2063,
9,
267,
282,
3981,
13785,
2937,
311,
2063,
2938,
275,
334,
65,
3981,
13785,
2937,
311,
2063,
446,
413,
26,
16557,
2063,
61,
4331,
1520,
9,
627,
5450,
267,
754,
275,
282,
14,
1345,
4827,
73,
20,
1959,
5217,
8,
65,
14,
1392,
4439,
17,
566,
272,
587,
26,
267,
327,
1695,
4546,
5845,
787,
5489,
465,
7381,
14526,
27,
11789,
465,
10514,
14526,
14,
267,
4487,
63,
1560,
275,
283,
85,
7,
340,
2937,
311,
2063,
508,
413,
587,
283,
73,
7,
267,
282,
275,
485,
1590,
14,
13521,
8,
576,
12,
2152,
15829,
5,
83,
5,
68,
7,
450,
334,
3583,
63,
1560,
12,
2937,
311,
2063,
430,
267,
754,
275,
282,
14,
5217,
2801,
17,
12,
302,
6324,
9,
272,
372,
754,
421,
199,
318,
1586,
19118,
8,
493,
304,
272,
408,
272,
5574,
282,
644,
6087,
570,
14,
339,
3897,
272,
4143,
272,
570,
520,
1059,
503,
570,
909,
267,
13083,
314,
536,
402,
282,
570,
503,
376,
1551,
570,
7849,
14,
339,
1432,
13468,
272,
3001,
9858,
272,
6634,
520,
2069,
267,
710,
15877,
9857,
334,
73,
14,
69,
14,
2787,
6634,
9,
272,
2937,
311,
2063,
520,
2069,
267,
710,
2690,
3462,
12,
315,
2783,
14,
221,
662,
14,
71,
14,
367,
282,
5504,
4546,
644,
6087,
570,
12,
267,
2937,
311,
2063,
365,
650,
14,
272,
666,
520,
2680,
1625,
267,
710,
1625,
3035,
314,
666,
14,
221,
710,
2215,
402,
314,
1625,
365,
267,
334,
1507,
63,
3356,
12,
1967,
63,
6324,
680,
221,
1967,
63,
6324,
365,
314,
1329,
402,
267,
10491,
9245,
334,
17,
367,
3485,
79,
12,
499,
367,
20345,
13322,
680,
339,
8144,
272,
9063,
272,
961,
805,
4440,
314,
658,
10024,
64,
859,
402,
314,
2018,
4465,
1973,
695,
272,
370,
1586,
314,
644,
6087,
570,
12,
880,
652,
965,
314,
2011,
4204,
465,
626,
3555,
14,
272,
1010,
6770,
12,
314,
805,
1630,
440,
1586,
12335,
644,
6087,
1584,
14,
339,
408,
272,
336,
1214,
275,
485,
10024,
14,
1490,
8,
493,
9,
272,
6634,
275,
336,
1214,
14,
20912,
1866,
342,
272,
302,
6324,
275,
336,
1214,
14,
362,
78,
6324,
342,
272,
2937,
311,
2063,
275,
336,
1214,
14,
362,
16557,
2063,
342,
272,
302,
8444,
275,
336,
1214,
14,
362,
31607,
342,
272,
666,
275,
336,
1214,
14,
739,
8444,
8,
31607,
9,
272,
336,
1214,
14,
1600,
342,
272,
1625,
275,
485,
19118,
18,
1144,
8,
78,
6324,
12,
2937,
311,
2063,
12,
666,
9,
272,
372,
6634,
12,
2937,
311,
2063,
12,
1625,
421,
199,
318,
2218,
19118,
1194,
8,
1501,
12,
6634,
12,
666,
304,
272,
408,
272,
2790,
282,
5504,
4546,
336,
1214,
570,
14,
339,
3897,
272,
4143,
272,
1788,
520,
1059,
267,
2812,
402,
314,
570,
370,
1218,
14,
272,
6634,
520,
2069,
267,
710,
15877,
9857,
334,
73,
14,
69,
14,
2787,
6634,
9,
402,
314,
666,
14,
272,
666,
520,
1625,
13,
2930,
3245,
402,
3000,
503,
8402,
2376,
1338,
267,
666,
1471,
506,
298,
1144,
13,
2930,
401,
1902,
413,
13,
503,
499,
13,
13014,
14,
221,
982,
652,
267,
365,
499,
13,
68,
12,
314,
4730,
787,
314,
11223,
334,
73,
14,
69,
14,
5845,
9,
436,
314,
4362,
267,
787,
314,
9245,
14,
339,
8144,
272,
9063,
272,
710,
666,
365,
10826,
370,
506,
10514,
12,
436,
314,
1338,
787,
10826,
370,
506,
272,
4453,
314,
1425,
402,
282,
5504,
4546,
3000,
14,
221,
27729,
2376,
1338,
787,
272,
6702,
370,
9446,
14,
221,
710,
666,
365,
440,
522,
696,
1146,
503,
9657,
2544,
272,
3575,
652,
370,
314,
570,
14,
339,
5679,
272,
5514,
272,
2790,
282,
650,
3499,
841,
2167,
30152,
308,
1132,
12204,
14,
339,
1306,
6634,
275,
25647,
1400,
221,
327,
5845,
1126,
3499,
272,
1306,
377,
275,
650,
260,
327,
2690,
7373,
334,
4515,
9,
272,
1306,
289,
275,
841,
2167,
14,
16,
258,
327,
20453,
9857,
334,
13026,
9,
272,
1306,
307,
275,
980,
14,
11649,
8,
16,
12,
377,
12,
377,
10,
1866,
12,
6037,
29,
797,
9,
272,
1306,
671,
275,
334,
18,
538,
1789,
446,
413,
9,
627,
980,
14,
5911,
8,
18,
627,
980,
14,
1038,
627,
289,
627,
307,
9,
272,
1306,
2218,
19118,
1194,
480,
83,
1132,
1194,
14,
19118,
401,
6634,
12,
671,
9,
339,
408,
272,
282,
708,
275,
485,
1590,
14,
8748,
8,
576,
12,
2152,
3699,
1590,
14,
442,
708,
9,
272,
340,
282,
708,
14,
8322,
508,
413,
26,
267,
327,
7905,
370,
282,
499,
36,
1625,
543,
282,
2849,
2763,
14,
267,
282
] |
[
336,
7194,
79,
14,
647,
199,
3,
6529,
26,
644,
285,
828,
2136,
346,
6350,
199,
3,
844,
26,
6289,
650,
13,
16009,
334,
1014,
921,
16374,
14,
1308,
15,
2383,
15,
15400,
13,
19,
13,
16009,
9,
199,
3,
29988,
27573,
26,
437,
2018,
859,
367,
7664,
436,
3575,
5504,
4546,
644,
6087,
1584,
14,
199,
3,
598,
4049,
26,
12869,
14,
957,
15,
55,
285,
828,
6004,
346,
6350,
15,
758,
32052,
199,
199,
646,
12204,
465,
485,
10024,
199,
646,
2680,
465,
485,
1590,
421,
199,
318,
485,
19118,
18,
1144,
8,
78,
6324,
12,
2937,
311,
2063,
12,
666,
304,
272,
408,
576,
1471,
506,
314,
1059,
3035,
314,
2783,
687,
314,
336,
1214,
570,
1041,
272,
1967,
63,
3356,
12,
15748,
275,
16438,
8,
552,
8,
576,
395,
2937,
311,
2063,
627,
302,
6324,
9,
272,
340,
15748,
690,
378,
26,
267,
746,
1722,
360,
1918,
2582,
402,
666,
365,
440,
282,
3663,
402,
283,
586,
283,
16557,
2063,
627,
1967,
63,
6324,
2659,
272,
340,
2937,
311,
2063,
690,
841,
26,
267,
746,
1722,
480,
16557,
2063,
1471,
440,
506,
8932,
2419,
841,
2685,
339,
340,
2937,
311,
2063,
508,
650,
26,
267,
282,
275,
485,
1590,
14,
1667,
1332,
1507,
63,
3356,
12,
302,
6324,
12,
841,
395,
2152,
3699,
1590,
14,
1635,
24,
9,
267,
3066,
63,
2394,
275,
485,
1590,
14,
13521,
8,
576,
12,
2152,
3699,
1590,
14,
1635,
24,
9,
267,
282,
3981,
13785,
520,
16557,
2063,
61,
275,
3066,
63,
2394,
14,
5217,
2801,
17,
12,
302,
6324,
12,
2937,
311,
2063,
9,
267,
282,
3981,
13785,
2937,
311,
2063,
2938,
275,
334,
65,
3981,
13785,
2937,
311,
2063,
446,
413,
26,
16557,
2063,
61,
4331,
1520,
9,
627,
5450,
267,
754,
275,
282,
14,
1345,
4827,
73,
20,
1959,
5217,
8,
65,
14,
1392,
4439,
17,
566,
272,
587,
26,
267,
327,
1695,
4546,
5845,
787,
5489,
465,
7381,
14526,
27,
11789,
465,
10514,
14526,
14,
267,
4487,
63,
1560,
275,
283,
85,
7,
340,
2937,
311,
2063,
508,
413,
587,
283,
73,
7,
267,
282,
275,
485,
1590,
14,
13521,
8,
576,
12,
2152,
15829,
5,
83,
5,
68,
7,
450,
334,
3583,
63,
1560,
12,
2937,
311,
2063,
430,
267,
754,
275,
282,
14,
5217,
2801,
17,
12,
302,
6324,
9,
272,
372,
754,
421,
199,
318,
1586,
19118,
8,
493,
304,
272,
408,
272,
5574,
282,
644,
6087,
570,
14,
339,
3897,
272,
4143,
272,
570,
520,
1059,
503,
570,
909,
267,
13083,
314,
536,
402,
282,
570,
503,
376,
1551,
570,
7849,
14,
339,
1432,
13468,
272,
3001,
9858,
272,
6634,
520,
2069,
267,
710,
15877,
9857,
334,
73,
14,
69,
14,
2787,
6634,
9,
272,
2937,
311,
2063,
520,
2069,
267,
710,
2690,
3462,
12,
315,
2783,
14,
221,
662,
14,
71,
14,
367,
282,
5504,
4546,
644,
6087,
570,
12,
267,
2937,
311,
2063,
365,
650,
14,
272,
666,
520,
2680,
1625,
267,
710,
1625,
3035,
314,
666,
14,
221,
710,
2215,
402,
314,
1625,
365,
267,
334,
1507,
63,
3356,
12,
1967,
63,
6324,
680,
221,
1967,
63,
6324,
365,
314,
1329,
402,
267,
10491,
9245,
334,
17,
367,
3485,
79,
12,
499,
367,
20345,
13322,
680,
339,
8144,
272,
9063,
272,
961,
805,
4440,
314,
658,
10024,
64,
859,
402,
314,
2018,
4465,
1973,
695,
272,
370,
1586,
314,
644,
6087,
570,
12,
880,
652,
965,
314,
2011,
4204,
465,
626,
3555,
14,
272,
1010,
6770,
12,
314,
805,
1630,
440,
1586,
12335,
644,
6087,
1584,
14,
339,
408,
272,
336,
1214,
275,
485,
10024,
14,
1490,
8,
493,
9,
272,
6634,
275,
336,
1214,
14,
20912,
1866,
342,
272,
302,
6324,
275,
336,
1214,
14,
362,
78,
6324,
342,
272,
2937,
311,
2063,
275,
336,
1214,
14,
362,
16557,
2063,
342,
272,
302,
8444,
275,
336,
1214,
14,
362,
31607,
342,
272,
666,
275,
336,
1214,
14,
739,
8444,
8,
31607,
9,
272,
336,
1214,
14,
1600,
342,
272,
1625,
275,
485,
19118,
18,
1144,
8,
78,
6324,
12,
2937,
311,
2063,
12,
666,
9,
272,
372,
6634,
12,
2937,
311,
2063,
12,
1625,
421,
199,
318,
2218,
19118,
1194,
8,
1501,
12,
6634,
12,
666,
304,
272,
408,
272,
2790,
282,
5504,
4546,
336,
1214,
570,
14,
339,
3897,
272,
4143,
272,
1788,
520,
1059,
267,
2812,
402,
314,
570,
370,
1218,
14,
272,
6634,
520,
2069,
267,
710,
15877,
9857,
334,
73,
14,
69,
14,
2787,
6634,
9,
402,
314,
666,
14,
272,
666,
520,
1625,
13,
2930,
3245,
402,
3000,
503,
8402,
2376,
1338,
267,
666,
1471,
506,
298,
1144,
13,
2930,
401,
1902,
413,
13,
503,
499,
13,
13014,
14,
221,
982,
652,
267,
365,
499,
13,
68,
12,
314,
4730,
787,
314,
11223,
334,
73,
14,
69,
14,
5845,
9,
436,
314,
4362,
267,
787,
314,
9245,
14,
339,
8144,
272,
9063,
272,
710,
666,
365,
10826,
370,
506,
10514,
12,
436,
314,
1338,
787,
10826,
370,
506,
272,
4453,
314,
1425,
402,
282,
5504,
4546,
3000,
14,
221,
27729,
2376,
1338,
787,
272,
6702,
370,
9446,
14,
221,
710,
666,
365,
440,
522,
696,
1146,
503,
9657,
2544,
272,
3575,
652,
370,
314,
570,
14,
339,
5679,
272,
5514,
272,
2790,
282,
650,
3499,
841,
2167,
30152,
308,
1132,
12204,
14,
339,
1306,
6634,
275,
25647,
1400,
221,
327,
5845,
1126,
3499,
272,
1306,
377,
275,
650,
260,
327,
2690,
7373,
334,
4515,
9,
272,
1306,
289,
275,
841,
2167,
14,
16,
258,
327,
20453,
9857,
334,
13026,
9,
272,
1306,
307,
275,
980,
14,
11649,
8,
16,
12,
377,
12,
377,
10,
1866,
12,
6037,
29,
797,
9,
272,
1306,
671,
275,
334,
18,
538,
1789,
446,
413,
9,
627,
980,
14,
5911,
8,
18,
627,
980,
14,
1038,
627,
289,
627,
307,
9,
272,
1306,
2218,
19118,
1194,
480,
83,
1132,
1194,
14,
19118,
401,
6634,
12,
671,
9,
339,
408,
272,
282,
708,
275,
485,
1590,
14,
8748,
8,
576,
12,
2152,
3699,
1590,
14,
442,
708,
9,
272,
340,
282,
708,
14,
8322,
508,
413,
26,
267,
327,
7905,
370,
282,
499,
36,
1625,
543,
282,
2849,
2763,
14,
267,
282,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
GeyerA/android_external_chromium_org
|
chrome/common/extensions/docs/server2/sidenav_data_source.py
|
23
|
2419
|
# Copyright (c) 2012 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import copy
import json
import logging
class SidenavDataSource(object):
"""This class reads in and caches a JSON file representing the side navigation
menu.
"""
class Factory(object):
def __init__(self, compiled_fs_factory, json_path):
self._cache = compiled_fs_factory.Create(self._CreateSidenavDict,
SidenavDataSource)
self._json_path = json_path
def Create(self, path):
"""Create a SidenavDataSource, binding it to |path|. |path| is the url
of the page that is being rendered. It is used to determine which item
in the sidenav should be highlighted.
"""
return SidenavDataSource(self._cache, self._json_path, path)
def _AddLevels(self, items, level):
"""Levels represent how deeply this item is nested in the sidenav. We
start at 2 because the top <ul> is the only level 1 element.
"""
for item in items:
item['level'] = level
if 'items' in item:
self._AddLevels(item['items'], level + 1)
def _CreateSidenavDict(self, json_path, json_str):
items = json.loads(json_str)
self._AddLevels(items, 2);
return items
def __init__(self, cache, json_path, path):
self._cache = cache
self._json_path = json_path
self._href = '/' + path
def _AddSelected(self, items):
for item in items:
if item.get('href', '') == self._href:
item['selected'] = True
return True
if 'items' in item:
if self._AddSelected(item['items']):
item['child_selected'] = True
return True
return False
def _QualifyHrefs(self, items):
for item in items:
if 'items' in item:
self._QualifyHrefs(item['items'])
href = item.get('href')
if href is not None and not href.startswith(('http://', 'https://')):
if not href.startswith('/'):
logging.warn('Paths in sidenav must be qualified. %s is not.' % href)
href = '/' + href
item['href'] = href
def get(self, key):
sidenav = copy.deepcopy(self._cache.GetFromFile(
'%s/%s_sidenav.json' % (self._json_path, key)))
self._AddSelected(sidenav)
self._QualifyHrefs(sidenav)
return sidenav
|
bsd-3-clause
|
[
3,
1898,
334,
67,
9,
6029,
710,
12051,
6642,
14,
2900,
4481,
4644,
14,
199,
3,
3645,
402,
642,
1350,
1233,
365,
10413,
701,
282,
6289,
13,
2487,
4190,
626,
883,
506,
199,
3,
1911,
315,
314,
5113,
570,
14,
199,
199,
646,
1331,
199,
646,
2022,
199,
646,
2050,
199,
199,
533,
428,
9281,
1214,
16693,
8,
785,
304,
523,
408,
2765,
1021,
11597,
315,
436,
18014,
282,
4840,
570,
6144,
314,
5366,
19191,
523,
6269,
14,
523,
408,
523,
1021,
23616,
8,
785,
304,
272,
347,
636,
826,
721,
277,
12,
10311,
63,
2319,
63,
3702,
12,
2022,
63,
515,
304,
489,
291,
423,
1637,
275,
10311,
63,
2319,
63,
3702,
14,
2499,
8,
277,
423,
2499,
51,
9281,
1214,
2141,
12,
6901,
428,
9281,
1214,
16693,
9,
489,
291,
423,
1001,
63,
515,
275,
2022,
63,
515,
339,
347,
2790,
8,
277,
12,
931,
304,
489,
408,
2499,
282,
428,
9281,
1214,
16693,
12,
11696,
652,
370,
1204,
515,
18257,
1204,
515,
92,
365,
314,
1166,
489,
402,
314,
2034,
626,
365,
3769,
8018,
14,
2779,
365,
1202,
370,
6705,
1314,
1242,
489,
315,
314,
308,
9281,
1214,
1077,
506,
4721,
27883,
14,
489,
408,
489,
372,
428,
9281,
1214,
16693,
8,
277,
423,
1637,
12,
291,
423,
1001,
63,
515,
12,
931,
9,
339,
347,
485,
1123,
4670,
83,
8,
277,
12,
2974,
12,
2166,
304,
489,
408,
4670,
83,
2954,
4212,
13217,
590,
642,
1242,
365,
6032,
315,
314,
308,
9281,
1214,
14,
2136,
489,
1343,
737,
499,
2952,
314,
2746,
665,
348,
30,
365,
314,
1454,
2166,
413,
1819,
14,
489,
408,
489,
367,
1242,
315,
2974,
26,
267,
1242,
459,
1896,
418,
275,
2166,
267,
340,
283,
1744,
7,
315,
1242,
26,
881,
291,
423,
1123,
4670,
83,
8,
1053,
459,
1744,
995,
2166,
435,
413,
9,
339,
347,
485,
2499,
51,
9281,
1214,
2141,
8,
277,
12,
2022,
63,
515,
12,
2022,
63,
495,
304,
489,
2974,
275,
2022,
14,
3640,
8,
1001,
63,
495,
9,
489,
291,
423,
1123,
4670,
83,
8,
1744,
12,
499,
2736,
489,
372,
2974,
819,
347,
636,
826,
721,
277,
12,
2581,
12,
2022,
63,
515,
12,
931,
304,
272,
291,
423,
1637,
275,
2581,
272,
291,
423,
1001,
63,
515,
275,
2022,
63,
515,
272,
291,
423,
6399,
275,
7324,
435,
931,
819,
347,
485,
1123,
12461,
8,
277,
12,
2974,
304,
272,
367,
1242,
315,
2974,
26,
489,
340,
1242,
14,
362,
360,
6399,
297,
4074,
508,
291,
423,
6399,
26,
267,
1242,
459,
5511,
418,
275,
715,
267,
372,
715,
489,
340,
283,
1744,
7,
315,
1242,
26,
267,
340,
291,
423,
1123,
12461,
8,
1053,
459,
1744,
9090,
881,
1242,
459,
1739,
63,
5511,
418,
275,
715,
881,
372,
715,
272,
372,
756,
819,
347,
485,
12621,
2021,
40,
7655,
8,
277,
12,
2974,
304,
272,
367,
1242,
315,
2974,
26,
489,
340,
283,
1744,
7,
315,
1242,
26,
267,
291,
423,
12621,
2021,
40,
7655,
8,
1053,
459,
1744,
1105,
2541,
4369,
275,
1242,
14,
362,
360,
6399,
358,
489,
340,
4369,
365,
440,
488,
436,
440,
4369,
14,
2460,
4725,
1014,
921,
297,
283,
2859,
921,
8109,
267,
340,
440,
4369,
14,
2460,
18265,
881,
2050,
14,
4050,
360,
11804,
315,
308,
9281,
1214,
1471,
506,
12313,
14,
450,
83,
365,
440,
3530,
450,
4369,
9,
881,
4369,
275,
7324,
435,
4369,
267,
1242,
459,
6399,
418,
275,
4369,
819,
347,
664,
8,
277,
12,
790,
304,
272,
308,
9281,
1214,
275,
1331,
14,
8293,
8,
277,
423,
1637,
14,
1002,
26637,
8,
267,
1543,
83,
3149,
83,
63,
338,
848,
1214,
14,
1001,
7,
450,
334,
277,
423,
1001,
63,
515,
12,
790,
1724,
272,
291,
423,
1123,
12461,
8,
338,
848,
1214,
9,
272,
291,
423,
12621,
2021,
40,
7655,
8,
338,
848,
1214,
9,
272,
372,
308,
9281,
1214,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
1898,
334,
67,
9,
6029,
710,
12051,
6642,
14,
2900,
4481,
4644,
14,
199,
3,
3645,
402,
642,
1350,
1233,
365,
10413,
701,
282,
6289,
13,
2487,
4190,
626,
883,
506,
199,
3,
1911,
315,
314,
5113,
570,
14,
199,
199,
646,
1331,
199,
646,
2022,
199,
646,
2050,
199,
199,
533,
428,
9281,
1214,
16693,
8,
785,
304,
523,
408,
2765,
1021,
11597,
315,
436,
18014,
282,
4840,
570,
6144,
314,
5366,
19191,
523,
6269,
14,
523,
408,
523,
1021,
23616,
8,
785,
304,
272,
347,
636,
826,
721,
277,
12,
10311,
63,
2319,
63,
3702,
12,
2022,
63,
515,
304,
489,
291,
423,
1637,
275,
10311,
63,
2319,
63,
3702,
14,
2499,
8,
277,
423,
2499,
51,
9281,
1214,
2141,
12,
6901,
428,
9281,
1214,
16693,
9,
489,
291,
423,
1001,
63,
515,
275,
2022,
63,
515,
339,
347,
2790,
8,
277,
12,
931,
304,
489,
408,
2499,
282,
428,
9281,
1214,
16693,
12,
11696,
652,
370,
1204,
515,
18257,
1204,
515,
92,
365,
314,
1166,
489,
402,
314,
2034,
626,
365,
3769,
8018,
14,
2779,
365,
1202,
370,
6705,
1314,
1242,
489,
315,
314,
308,
9281,
1214,
1077,
506,
4721,
27883,
14,
489,
408,
489,
372,
428,
9281,
1214,
16693,
8,
277,
423,
1637,
12,
291,
423,
1001,
63,
515,
12,
931,
9,
339,
347,
485,
1123,
4670,
83,
8,
277,
12,
2974,
12,
2166,
304,
489,
408,
4670,
83,
2954,
4212,
13217,
590,
642,
1242,
365,
6032,
315,
314,
308,
9281,
1214,
14,
2136,
489,
1343,
737,
499,
2952,
314,
2746,
665,
348,
30,
365,
314,
1454,
2166,
413,
1819,
14,
489,
408,
489,
367,
1242,
315,
2974,
26,
267,
1242,
459,
1896,
418,
275,
2166,
267,
340,
283,
1744,
7,
315,
1242,
26,
881,
291,
423,
1123,
4670,
83,
8,
1053,
459,
1744,
995,
2166,
435,
413,
9,
339,
347,
485,
2499,
51,
9281,
1214,
2141,
8,
277,
12,
2022,
63,
515,
12,
2022,
63,
495,
304,
489,
2974,
275,
2022,
14,
3640,
8,
1001,
63,
495,
9,
489,
291,
423,
1123,
4670,
83,
8,
1744,
12,
499,
2736,
489,
372,
2974,
819,
347,
636,
826,
721,
277,
12,
2581,
12,
2022,
63,
515,
12,
931,
304,
272,
291,
423,
1637,
275,
2581,
272,
291,
423,
1001,
63,
515,
275,
2022,
63,
515,
272,
291,
423,
6399,
275,
7324,
435,
931,
819,
347,
485,
1123,
12461,
8,
277,
12,
2974,
304,
272,
367,
1242,
315,
2974,
26,
489,
340,
1242,
14,
362,
360,
6399,
297,
4074,
508,
291,
423,
6399,
26,
267,
1242,
459,
5511,
418,
275,
715,
267,
372,
715,
489,
340,
283,
1744,
7,
315,
1242,
26,
267,
340,
291,
423,
1123,
12461,
8,
1053,
459,
1744,
9090,
881,
1242,
459,
1739,
63,
5511,
418,
275,
715,
881,
372,
715,
272,
372,
756,
819,
347,
485,
12621,
2021,
40,
7655,
8,
277,
12,
2974,
304,
272,
367,
1242,
315,
2974,
26,
489,
340,
283,
1744,
7,
315,
1242,
26,
267,
291,
423,
12621,
2021,
40,
7655,
8,
1053,
459,
1744,
1105,
2541,
4369,
275,
1242,
14,
362,
360,
6399,
358,
489,
340,
4369,
365,
440,
488,
436,
440,
4369,
14,
2460,
4725,
1014,
921,
297,
283,
2859,
921,
8109,
267,
340,
440,
4369,
14,
2460,
18265,
881,
2050,
14,
4050,
360,
11804,
315,
308,
9281,
1214,
1471,
506,
12313,
14,
450,
83,
365,
440,
3530,
450,
4369,
9,
881,
4369,
275,
7324,
435,
4369,
267,
1242,
459,
6399,
418,
275,
4369,
819,
347,
664,
8,
277,
12,
790,
304,
272,
308,
9281,
1214,
275,
1331,
14,
8293,
8,
277,
423,
1637,
14,
1002,
26637,
8,
267,
1543,
83,
3149,
83,
63,
338,
848,
1214,
14,
1001,
7,
450,
334,
277,
423,
1001,
63,
515,
12,
790,
1724,
272,
291,
423,
1123,
12461,
8,
338,
848,
1214,
9,
272,
291,
423,
12621,
2021,
40,
7655,
8,
338,
848,
1214,
9,
272,
372,
308,
9281,
1214,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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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
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
amalakar/dd-agent
|
tests/core/test_modules.py
|
37
|
1954
|
# stdlib
import logging
import os
import sys
import unittest
# project
import modules
log = logging.getLogger('datadog.test')
TARGET_MODULE = 'tests.core.fixtures.target_module'
default_target = 'DEFAULT'
specified_target = 'SPECIFIED'
has_been_mutated = False
class TestModuleLoad(unittest.TestCase):
def setUp(self):
sys.modules[__name__].has_been_mutated = True
if TARGET_MODULE in sys.modules:
del sys.modules[TARGET_MODULE]
def tearDown(self):
sys.modules[__name__].has_been_mutated = False
def test_cached_module(self):
"""Modules already in the cache should be reused"""
self.assertTrue(modules.load('%s:has_been_mutated' % __name__))
def test_cache_population(self):
"""Python module cache should be populated"""
self.assertTrue(TARGET_MODULE not in sys.modules)
modules.load(TARGET_MODULE)
self.assertTrue(TARGET_MODULE in sys.modules)
def test_modname_load_default(self):
"""When the specifier contains no module name, any provided default
should be used"""
self.assertEquals(
modules.load(
TARGET_MODULE,
'default_target'),
'DEFAULT'
)
def test_modname_load_specified(self):
"""When the specifier contains a module name, any provided default
should be overridden"""
self.assertEquals(
modules.load(
'{0}:specified_target'.format(TARGET_MODULE),
'default_target'),
'SPECIFIED'
)
def test_pathname_load_finds_package(self):
""""Loading modules by absolute path should correctly set the name of
the loaded module to include any package containing it."""
m = modules.load(os.path.join(os.getcwd(),
TARGET_MODULE.replace('.', '/')))
self.assertEquals(m.__name__, TARGET_MODULE)
|
bsd-3-clause
|
[
3,
26678,
199,
646,
2050,
199,
646,
747,
199,
646,
984,
199,
646,
2882,
199,
199,
3,
2199,
199,
646,
4621,
199,
199,
793,
275,
2050,
14,
5572,
360,
4616,
30821,
14,
396,
358,
199,
199,
9268,
63,
10001,
275,
283,
2219,
14,
1018,
14,
8769,
14,
1375,
63,
578,
7,
199,
885,
63,
1375,
275,
283,
3472,
7,
199,
10085,
63,
1375,
275,
283,
22917,
19679,
7,
199,
1989,
63,
1235,
287,
63,
6552,
972,
275,
756,
421,
199,
533,
1379,
2377,
6200,
8,
2796,
14,
1746,
304,
339,
347,
3613,
8,
277,
304,
267,
984,
14,
3112,
28894,
354,
363,
1055,
1989,
63,
1235,
287,
63,
6552,
972,
275,
715,
267,
340,
26134,
63,
10001,
315,
984,
14,
3112,
26,
288,
2150,
984,
14,
3112,
59,
9268,
63,
10001,
61,
339,
347,
6766,
8,
277,
304,
267,
984,
14,
3112,
28894,
354,
363,
1055,
1989,
63,
1235,
287,
63,
6552,
972,
275,
756,
339,
347,
511,
63,
5245,
63,
578,
8,
277,
304,
267,
408,
17981,
2575,
315,
314,
2581,
1077,
506,
24826,
624,
267,
291,
14,
1815,
8,
3112,
14,
912,
3508,
83,
26,
1989,
63,
1235,
287,
63,
6552,
972,
7,
450,
636,
354,
8964,
339,
347,
511,
63,
1637,
63,
16003,
8,
277,
304,
267,
408,
4718,
859,
2581,
1077,
506,
16460,
624,
267,
291,
14,
1815,
8,
9268,
63,
10001,
440,
315,
984,
14,
3112,
9,
267,
4621,
14,
912,
8,
9268,
63,
10001,
9,
267,
291,
14,
1815,
8,
9268,
63,
10001,
315,
984,
14,
3112,
9,
339,
347,
511,
63,
14789,
63,
912,
63,
885,
8,
277,
304,
267,
408,
11423,
314,
16628,
3509,
949,
859,
536,
12,
1263,
2741,
849,
267,
1077,
506,
1202,
624,
267,
291,
14,
2947,
8,
288,
4621,
14,
912,
8,
355,
26134,
63,
10001,
12,
355,
283,
885,
63,
1375,
659,
288,
283,
3472,
7,
267,
776,
339,
347,
511,
63,
14789,
63,
912,
63,
10085,
8,
277,
304,
267,
408,
11423,
314,
16628,
3509,
282,
859,
536,
12,
1263,
2741,
849,
267,
1077,
506,
10087,
624,
267,
291,
14,
2947,
8,
288,
4621,
14,
912,
8,
355,
5041,
16,
9160,
10085,
63,
1375,
1370,
908,
8,
9268,
63,
10001,
395,
355,
283,
885,
63,
1375,
659,
288,
283,
22917,
19679,
7,
267,
776,
339,
347,
511,
63,
12445,
63,
912,
63,
1623,
83,
63,
2491,
8,
277,
304,
267,
408,
2,
19236,
4621,
701,
3679,
931,
1077,
6657,
663,
314,
536,
402,
267,
314,
6511,
859,
370,
2387,
1263,
2559,
3035,
652,
1041,
267,
333,
275,
4621,
14,
912,
8,
736,
14,
515,
14,
904,
8,
736,
14,
9458,
1062,
4228,
26134,
63,
10001,
14,
1814,
14078,
1994,
7058,
267,
291,
14,
2947,
8,
77,
855,
354,
3108,
26134,
63,
10001,
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
] |
[
26678,
199,
646,
2050,
199,
646,
747,
199,
646,
984,
199,
646,
2882,
199,
199,
3,
2199,
199,
646,
4621,
199,
199,
793,
275,
2050,
14,
5572,
360,
4616,
30821,
14,
396,
358,
199,
199,
9268,
63,
10001,
275,
283,
2219,
14,
1018,
14,
8769,
14,
1375,
63,
578,
7,
199,
885,
63,
1375,
275,
283,
3472,
7,
199,
10085,
63,
1375,
275,
283,
22917,
19679,
7,
199,
1989,
63,
1235,
287,
63,
6552,
972,
275,
756,
421,
199,
533,
1379,
2377,
6200,
8,
2796,
14,
1746,
304,
339,
347,
3613,
8,
277,
304,
267,
984,
14,
3112,
28894,
354,
363,
1055,
1989,
63,
1235,
287,
63,
6552,
972,
275,
715,
267,
340,
26134,
63,
10001,
315,
984,
14,
3112,
26,
288,
2150,
984,
14,
3112,
59,
9268,
63,
10001,
61,
339,
347,
6766,
8,
277,
304,
267,
984,
14,
3112,
28894,
354,
363,
1055,
1989,
63,
1235,
287,
63,
6552,
972,
275,
756,
339,
347,
511,
63,
5245,
63,
578,
8,
277,
304,
267,
408,
17981,
2575,
315,
314,
2581,
1077,
506,
24826,
624,
267,
291,
14,
1815,
8,
3112,
14,
912,
3508,
83,
26,
1989,
63,
1235,
287,
63,
6552,
972,
7,
450,
636,
354,
8964,
339,
347,
511,
63,
1637,
63,
16003,
8,
277,
304,
267,
408,
4718,
859,
2581,
1077,
506,
16460,
624,
267,
291,
14,
1815,
8,
9268,
63,
10001,
440,
315,
984,
14,
3112,
9,
267,
4621,
14,
912,
8,
9268,
63,
10001,
9,
267,
291,
14,
1815,
8,
9268,
63,
10001,
315,
984,
14,
3112,
9,
339,
347,
511,
63,
14789,
63,
912,
63,
885,
8,
277,
304,
267,
408,
11423,
314,
16628,
3509,
949,
859,
536,
12,
1263,
2741,
849,
267,
1077,
506,
1202,
624,
267,
291,
14,
2947,
8,
288,
4621,
14,
912,
8,
355,
26134,
63,
10001,
12,
355,
283,
885,
63,
1375,
659,
288,
283,
3472,
7,
267,
776,
339,
347,
511,
63,
14789,
63,
912,
63,
10085,
8,
277,
304,
267,
408,
11423,
314,
16628,
3509,
282,
859,
536,
12,
1263,
2741,
849,
267,
1077,
506,
10087,
624,
267,
291,
14,
2947,
8,
288,
4621,
14,
912,
8,
355,
5041,
16,
9160,
10085,
63,
1375,
1370,
908,
8,
9268,
63,
10001,
395,
355,
283,
885,
63,
1375,
659,
288,
283,
22917,
19679,
7,
267,
776,
339,
347,
511,
63,
12445,
63,
912,
63,
1623,
83,
63,
2491,
8,
277,
304,
267,
408,
2,
19236,
4621,
701,
3679,
931,
1077,
6657,
663,
314,
536,
402,
267,
314,
6511,
859,
370,
2387,
1263,
2559,
3035,
652,
1041,
267,
333,
275,
4621,
14,
912,
8,
736,
14,
515,
14,
904,
8,
736,
14,
9458,
1062,
4228,
26134,
63,
10001,
14,
1814,
14078,
1994,
7058,
267,
291,
14,
2947,
8,
77,
855,
354,
3108,
26134,
63,
10001,
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,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
rtfm-ctf/rtfmapi
|
modules/crypto/adfgx.py
|
1
|
2183
|
from rtfmapi.modules.crypto.base import Cipher
from rtfmapi.modules.crypto.columnartransposition import ColTrans
from rtfmapi.modules.crypto.polybius import PolybiusSquare
####################################################################################
class ADFGX(Cipher):
"""The ADFGX Cipher has a key consisting of a 5x5 key square and a word e.g. 'GERMAN'.
The algorithm is described here: http://www.practicalcryptography.com/ciphers/classical-era/adfgvx/
The key square consists of the letters A-Z with J omitted (25 characters total).
:param key: The keysquare, as a 25 character string.
:param keyword: The keyword, any word or phrase will do.
"""
def __init__(self,key='phqgmeaylnofdxkrcvszwbuti',keyword='GERMAN'):
self.key = [k.upper() for k in key]
self.keyword = keyword
assert len(key)==25, 'invalid key in init: must have length 25, has length '+str(len(key))
assert len(keyword)>0, 'invalid keyword in init: should have length >= 1'
def encipher(self,string):
"""Encipher string using ADFGX cipher according to initialised key information. Punctuation and whitespace
are removed from the input.
Example::
ciphertext = ADFGX('phqgmeaylnofdxkrcvszwbuti','HELLO').encipher(plaintext)
:param string: The string to encipher.
:returns: The enciphered string.
"""
step1 = PolybiusSquare(self.key,size=5,chars='ADFGX').encipher(string)
step2 = ColTrans(self.keyword).encipher(step1)
return step2
def decipher(self,string):
"""Decipher string using ADFGX cipher according to initialised key information. Punctuation and whitespace
are removed from the input.
Example::
plaintext = ADFGX('phqgmeaylnofdxkrcvszwbuti','HELLO').decipher(ciphertext)
:param string: The string to decipher.
:returns: The enciphered string.
"""
step2 = ColTrans(self.keyword).decipher(string)
step1 = PolybiusSquare(self.key,size=5,chars='ADFGX').decipher(step2)
return step1
|
gpl-2.0
|
[
504,
519,
3249,
391,
1038,
14,
3112,
14,
10316,
14,
1095,
492,
29683,
199,
504,
519,
3249,
391,
1038,
14,
3112,
14,
10316,
14,
2301,
285,
1515,
3124,
492,
3626,
3188,
199,
504,
519,
3249,
391,
1038,
14,
3112,
14,
10316,
14,
6023,
4492,
527,
492,
16869,
4492,
527,
23373,
199,
199,
13289,
381,
199,
533,
437,
3888,
39,
56,
8,
21967,
304,
272,
408,
1918,
437,
3888,
39,
56,
29683,
965,
282,
790,
22581,
402,
282,
959,
88,
21,
790,
12386,
436,
282,
4349,
325,
14,
71,
14,
283,
11784,
6588,
1370,
272,
710,
5563,
365,
11736,
2348,
26,
1455,
921,
1544,
14,
80,
6457,
3294,
10316,
9773,
14,
957,
15,
27426,
15,
12334,
915,
13,
32311,
15,
350,
9681,
18843,
15,
272,
710,
790,
12386,
18581,
402,
314,
14435,
437,
13,
58,
543,
1603,
11684,
334,
821,
4110,
3141,
680,
5591,
520,
635,
790,
26,
710,
2883,
5937,
12,
465,
282,
5661,
4528,
1059,
14,
272,
520,
635,
4252,
26,
710,
4252,
12,
1263,
4349,
503,
21621,
911,
886,
14,
263,
272,
408,
272,
347,
636,
826,
721,
277,
12,
498,
534,
838,
81,
71,
278,
1187,
76,
889,
2592,
28351,
1195,
3122,
90,
87,
464,
280,
297,
6691,
534,
11784,
6588,
735,
267,
291,
14,
498,
275,
359,
75,
14,
4142,
342,
367,
1022,
315,
790,
61,
267,
291,
14,
6691,
275,
4252,
267,
702,
822,
8,
498,
12694,
821,
12,
283,
3197,
790,
315,
4205,
26,
1471,
1172,
2582,
5661,
12,
965,
2582,
6681,
495,
8,
552,
8,
498,
430,
267,
702,
822,
8,
6691,
13032,
16,
12,
283,
3197,
4252,
315,
4205,
26,
1077,
1172,
2582,
2356,
413,
7,
267,
272,
347,
655,
9231,
8,
277,
12,
875,
304,
267,
408,
1327,
9231,
1059,
1808,
437,
3888,
39,
56,
10830,
7182,
370,
2536,
9096,
790,
2556,
14,
10357,
436,
8139,
267,
787,
4829,
687,
314,
1324,
14,
263,
267,
5679,
447,
288,
29147,
275,
437,
3888,
39,
56,
360,
838,
81,
71,
278,
1187,
76,
889,
2592,
28351,
1195,
3122,
90,
87,
464,
280,
1673,
24771,
1484,
1959,
287,
9231,
8,
17426,
9,
420,
267,
520,
635,
1059,
26,
710,
1059,
370,
655,
9231,
14,
267,
520,
5808,
26,
710,
655,
6237,
426,
581,
1059,
14,
267,
408,
8540,
267,
3650,
17,
275,
16869,
4492,
527,
23373,
8,
277,
14,
498,
12,
890,
29,
21,
12,
6574,
534,
1554,
27453,
56,
1959,
287,
9231,
8,
875,
9,
267,
3650,
18,
275,
3626,
3188,
8,
277,
14,
6691,
680,
287,
9231,
8,
2926,
17,
9,
267,
372,
3650,
18,
339,
347,
477,
9231,
8,
277,
12,
875,
304,
267,
408,
872,
9231,
1059,
1808,
437,
3888,
39,
56,
10830,
7182,
370,
2536,
9096,
790,
2556,
14,
10357,
436,
8139,
267,
787,
4829,
687,
314,
1324,
14,
263,
267,
5679,
447,
288,
18577,
275,
437,
3888,
39,
56,
360,
838,
81,
71,
278,
1187,
76,
889,
2592,
28351,
1195,
3122,
90,
87,
464,
280,
1673,
24771,
1484,
1959,
271,
9231,
8,
27661,
9,
420,
267,
520,
635,
1059,
26,
710,
1059,
370,
477,
9231,
14,
267,
520,
5808,
26,
710,
655,
6237,
426,
581,
1059,
14,
267,
408,
8540,
267,
3650,
18,
275,
3626,
3188,
8,
277,
14,
6691,
680,
271,
9231,
8,
875,
9,
267,
3650,
17,
275,
16869,
4492,
527,
23373,
8,
277,
14,
498,
12,
890,
29,
21,
12,
6574,
534,
1554,
27453,
56,
1959,
271,
9231,
8,
2926,
18,
9,
267,
372,
3650,
17,
258,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
519,
3249,
391,
1038,
14,
3112,
14,
10316,
14,
1095,
492,
29683,
199,
504,
519,
3249,
391,
1038,
14,
3112,
14,
10316,
14,
2301,
285,
1515,
3124,
492,
3626,
3188,
199,
504,
519,
3249,
391,
1038,
14,
3112,
14,
10316,
14,
6023,
4492,
527,
492,
16869,
4492,
527,
23373,
199,
199,
13289,
381,
199,
533,
437,
3888,
39,
56,
8,
21967,
304,
272,
408,
1918,
437,
3888,
39,
56,
29683,
965,
282,
790,
22581,
402,
282,
959,
88,
21,
790,
12386,
436,
282,
4349,
325,
14,
71,
14,
283,
11784,
6588,
1370,
272,
710,
5563,
365,
11736,
2348,
26,
1455,
921,
1544,
14,
80,
6457,
3294,
10316,
9773,
14,
957,
15,
27426,
15,
12334,
915,
13,
32311,
15,
350,
9681,
18843,
15,
272,
710,
790,
12386,
18581,
402,
314,
14435,
437,
13,
58,
543,
1603,
11684,
334,
821,
4110,
3141,
680,
5591,
520,
635,
790,
26,
710,
2883,
5937,
12,
465,
282,
5661,
4528,
1059,
14,
272,
520,
635,
4252,
26,
710,
4252,
12,
1263,
4349,
503,
21621,
911,
886,
14,
263,
272,
408,
272,
347,
636,
826,
721,
277,
12,
498,
534,
838,
81,
71,
278,
1187,
76,
889,
2592,
28351,
1195,
3122,
90,
87,
464,
280,
297,
6691,
534,
11784,
6588,
735,
267,
291,
14,
498,
275,
359,
75,
14,
4142,
342,
367,
1022,
315,
790,
61,
267,
291,
14,
6691,
275,
4252,
267,
702,
822,
8,
498,
12694,
821,
12,
283,
3197,
790,
315,
4205,
26,
1471,
1172,
2582,
5661,
12,
965,
2582,
6681,
495,
8,
552,
8,
498,
430,
267,
702,
822,
8,
6691,
13032,
16,
12,
283,
3197,
4252,
315,
4205,
26,
1077,
1172,
2582,
2356,
413,
7,
267,
272,
347,
655,
9231,
8,
277,
12,
875,
304,
267,
408,
1327,
9231,
1059,
1808,
437,
3888,
39,
56,
10830,
7182,
370,
2536,
9096,
790,
2556,
14,
10357,
436,
8139,
267,
787,
4829,
687,
314,
1324,
14,
263,
267,
5679,
447,
288,
29147,
275,
437,
3888,
39,
56,
360,
838,
81,
71,
278,
1187,
76,
889,
2592,
28351,
1195,
3122,
90,
87,
464,
280,
1673,
24771,
1484,
1959,
287,
9231,
8,
17426,
9,
420,
267,
520,
635,
1059,
26,
710,
1059,
370,
655,
9231,
14,
267,
520,
5808,
26,
710,
655,
6237,
426,
581,
1059,
14,
267,
408,
8540,
267,
3650,
17,
275,
16869,
4492,
527,
23373,
8,
277,
14,
498,
12,
890,
29,
21,
12,
6574,
534,
1554,
27453,
56,
1959,
287,
9231,
8,
875,
9,
267,
3650,
18,
275,
3626,
3188,
8,
277,
14,
6691,
680,
287,
9231,
8,
2926,
17,
9,
267,
372,
3650,
18,
339,
347,
477,
9231,
8,
277,
12,
875,
304,
267,
408,
872,
9231,
1059,
1808,
437,
3888,
39,
56,
10830,
7182,
370,
2536,
9096,
790,
2556,
14,
10357,
436,
8139,
267,
787,
4829,
687,
314,
1324,
14,
263,
267,
5679,
447,
288,
18577,
275,
437,
3888,
39,
56,
360,
838,
81,
71,
278,
1187,
76,
889,
2592,
28351,
1195,
3122,
90,
87,
464,
280,
1673,
24771,
1484,
1959,
271,
9231,
8,
27661,
9,
420,
267,
520,
635,
1059,
26,
710,
1059,
370,
477,
9231,
14,
267,
520,
5808,
26,
710,
655,
6237,
426,
581,
1059,
14,
267,
408,
8540,
267,
3650,
18,
275,
3626,
3188,
8,
277,
14,
6691,
680,
271,
9231,
8,
875,
9,
267,
3650,
17,
275,
16869,
4492,
527,
23373,
8,
277,
14,
498,
12,
890,
29,
21,
12,
6574,
534,
1554,
27453,
56,
1959,
271,
9231,
8,
2926,
18,
9,
267,
372,
3650,
17,
258,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
RayMick/scikit-learn
|
examples/neighbors/plot_species_kde.py
|
282
|
4059
|
"""
================================================
Kernel Density Estimate of Species Distributions
================================================
This shows an example of a neighbors-based query (in particular a kernel
density estimate) on geospatial data, using a Ball Tree built upon the
Haversine distance metric -- i.e. distances over points in latitude/longitude.
The dataset is provided by Phillips et. al. (2006).
If available, the example uses
`basemap <http://matplotlib.sourceforge.net/basemap/doc/html/>`_
to plot the coast lines and national boundaries of South America.
This example does not perform any learning over the data
(see :ref:`example_applications_plot_species_distribution_modeling.py` for
an example of classification based on the attributes in this dataset). It
simply shows the kernel density estimate of observed data points in
geospatial coordinates.
The two species are:
- `"Bradypus variegatus"
<http://www.iucnredlist.org/apps/redlist/details/3038/0>`_ ,
the Brown-throated Sloth.
- `"Microryzomys minutus"
<http://www.iucnredlist.org/apps/redlist/details/13408/0>`_ ,
also known as the Forest Small Rice Rat, a rodent that lives in Peru,
Colombia, Ecuador, Peru, and Venezuela.
References
----------
* `"Maximum entropy modeling of species geographic distributions"
<http://www.cs.princeton.edu/~schapire/papers/ecolmod.pdf>`_
S. J. Phillips, R. P. Anderson, R. E. Schapire - Ecological Modelling,
190:231-259, 2006.
"""
# Author: Jake Vanderplas <jakevdp@cs.washington.edu>
#
# License: BSD 3 clause
import numpy as np
import matplotlib.pyplot as plt
from sklearn.datasets import fetch_species_distributions
from sklearn.datasets.species_distributions import construct_grids
from sklearn.neighbors import KernelDensity
# if basemap is available, we'll use it.
# otherwise, we'll improvise later...
try:
from mpl_toolkits.basemap import Basemap
basemap = True
except ImportError:
basemap = False
# Get matrices/arrays of species IDs and locations
data = fetch_species_distributions()
species_names = ['Bradypus Variegatus', 'Microryzomys Minutus']
Xtrain = np.vstack([data['train']['dd lat'],
data['train']['dd long']]).T
ytrain = np.array([d.decode('ascii').startswith('micro')
for d in data['train']['species']], dtype='int')
Xtrain *= np.pi / 180. # Convert lat/long to radians
# Set up the data grid for the contour plot
xgrid, ygrid = construct_grids(data)
X, Y = np.meshgrid(xgrid[::5], ygrid[::5][::-1])
land_reference = data.coverages[6][::5, ::5]
land_mask = (land_reference > -9999).ravel()
xy = np.vstack([Y.ravel(), X.ravel()]).T
xy = xy[land_mask]
xy *= np.pi / 180.
# Plot map of South America with distributions of each species
fig = plt.figure()
fig.subplots_adjust(left=0.05, right=0.95, wspace=0.05)
for i in range(2):
plt.subplot(1, 2, i + 1)
# construct a kernel density estimate of the distribution
print(" - computing KDE in spherical coordinates")
kde = KernelDensity(bandwidth=0.04, metric='haversine',
kernel='gaussian', algorithm='ball_tree')
kde.fit(Xtrain[ytrain == i])
# evaluate only on the land: -9999 indicates ocean
Z = -9999 + np.zeros(land_mask.shape[0])
Z[land_mask] = np.exp(kde.score_samples(xy))
Z = Z.reshape(X.shape)
# plot contours of the density
levels = np.linspace(0, Z.max(), 25)
plt.contourf(X, Y, Z, levels=levels, cmap=plt.cm.Reds)
if basemap:
print(" - plot coastlines using basemap")
m = Basemap(projection='cyl', llcrnrlat=Y.min(),
urcrnrlat=Y.max(), llcrnrlon=X.min(),
urcrnrlon=X.max(), resolution='c')
m.drawcoastlines()
m.drawcountries()
else:
print(" - plot coastlines from coverage")
plt.contour(X, Y, land_reference,
levels=[-9999], colors="k",
linestyles="solid")
plt.xticks([])
plt.yticks([])
plt.title(species_names[i])
plt.show()
|
bsd-3-clause
|
[
624,
199,
12813,
199,
14127,
25187,
3677,
15896,
6897,
402,
5367,
397,
577,
5414,
852,
199,
12813,
199,
2765,
13703,
376,
2893,
402,
282,
15845,
13,
6788,
1827,
334,
262,
6770,
282,
5114,
199,
15669,
14497,
9,
641,
30259,
9491,
666,
12,
1808,
282,
699,
452,
12178,
6137,
12188,
314,
199,
15739,
14895,
1132,
6033,
6370,
1553,
284,
14,
69,
14,
15108,
1806,
4501,
315,
18896,
15,
13803,
14,
199,
1918,
4789,
365,
2741,
701,
11308,
8148,
1190,
10844,
14,
741,
14,
334,
7968,
680,
199,
3917,
2808,
12,
314,
2893,
4440,
199,
64,
1095,
1130,
665,
1014,
921,
16440,
14,
22943,
14,
846,
15,
1095,
1130,
15,
1301,
15,
1360,
3133,
18417,
199,
475,
5137,
314,
512,
1810,
2385,
436,
302,
6279,
18135,
402,
23150,
437,
8534,
14,
199,
199,
2765,
2893,
1630,
440,
5147,
1263,
9328,
1806,
314,
666,
199,
8,
3239,
520,
1121,
1705,
2694,
63,
15853,
63,
2798,
63,
17168,
63,
4972,
63,
1238,
316,
14,
647,
64,
367,
199,
290,
2893,
402,
12505,
4079,
641,
314,
3004,
315,
642,
4789,
680,
221,
2779,
199,
11184,
590,
13703,
314,
5114,
13650,
14497,
402,
20802,
666,
4501,
315,
199,
12151,
9491,
8983,
14,
199,
199,
1918,
2877,
20340,
787,
26,
421,
446,
28531,
34,
9525,
2279,
527,
4172,
5902,
896,
2,
2043,
665,
1014,
921,
1544,
14,
73,
947,
78,
581,
513,
14,
1308,
15,
5181,
15,
581,
513,
15,
5087,
15,
1216,
1703,
15,
16,
18740,
2360,
2043,
314,
699,
18406,
13,
273,
293,
972,
428,
320,
273,
14,
421,
446,
28531,
45,
530,
451,
19873,
676,
588,
1748,
337,
527,
2,
2043,
665,
1014,
921,
1544,
14,
73,
947,
78,
581,
513,
14,
1308,
15,
5181,
15,
581,
513,
15,
5087,
15,
7582,
2036,
15,
16,
18740,
2360,
2043,
2597,
6040,
465,
314,
21684,
270,
23704,
820,
1885,
820,
292,
12,
282,
882,
1326,
626,
27576,
315,
3492,
85,
12,
2043,
1849,
320,
887,
4674,
12,
662,
67,
8346,
269,
12,
3492,
85,
12,
436,
812,
6349,
90,
310,
416,
14,
199,
199,
15242,
199,
9460,
421,
627,
28531,
10915,
19490,
1402,
316,
402,
20340,
25637,
10208,
2,
2043,
665,
1014,
921,
1544,
14,
1259,
14,
2700,
2855,
1860,
14,
8654,
22500,
15820,
1246,
264,
15,
10443,
83,
15,
69,
761,
1494,
14,
5607,
18740,
2043,
428,
14,
1603,
14,
11308,
8148,
1190,
12,
820,
14,
510,
14,
1626,
424,
834,
12,
820,
14,
662,
14,
22985,
1246,
264,
446,
662,
331,
7954,
4900,
10564,
12,
2043,
29682,
26,
11921,
13,
11990,
12,
8315,
14,
199,
624,
199,
3,
6529,
26,
1603,
1728,
812,
11438,
1168,
305,
665,
74,
1728,
86,
5780,
32,
1259,
14,
87,
1119,
31673,
14,
8654,
30,
199,
3,
199,
3,
844,
26,
6289,
650,
8502,
199,
199,
646,
2680,
465,
980,
199,
646,
8027,
14,
13563,
465,
4488,
199,
504,
6357,
14,
12281,
492,
5267,
63,
17168,
63,
5613,
199,
504,
6357,
14,
12281,
14,
17168,
63,
5613,
492,
6982,
63,
7928,
795,
199,
504,
6357,
14,
11113,
492,
24901,
26211,
199,
199,
3,
340,
1300,
1130,
365,
2808,
12,
781,
7171,
675,
652,
14,
199,
3,
4257,
12,
781,
7171,
1742,
293,
433,
261,
2945,
1396,
199,
893,
26,
272,
687,
22513,
63,
3557,
75,
1405,
14,
1095,
1130,
492,
3523,
1130,
272,
1300,
1130,
275,
715,
199,
2590,
3545,
26,
272,
1300,
1130,
275,
756,
199,
199,
3,
2372,
12627,
15,
10095,
402,
20340,
11449,
436,
9918,
199,
576,
275,
5267,
63,
17168,
63,
5613,
342,
199,
17168,
63,
1247,
275,
788,
34,
9525,
2279,
527,
21107,
5902,
896,
297,
283,
45,
530,
451,
19873,
676,
588,
10195,
337,
527,
418,
199,
199,
56,
2834,
275,
980,
14,
20221,
779,
576,
459,
2834,
2545,
617,
8396,
995,
490,
666,
459,
2834,
2545,
617,
1846,
418,
6575,
52,
199,
89,
2834,
275,
980,
14,
1144,
779,
68,
14,
2708,
360,
4371,
1959,
2460,
360,
6453,
358,
2116,
367,
366,
315,
666,
459,
2834,
2545,
17168,
2157,
2152,
534,
442,
358,
199,
56,
2834,
9000,
980,
14,
1038,
1182,
13576,
14,
221,
327,
7905,
8396,
15,
2809,
370,
26874,
199,
199,
3,
2494,
1536,
314,
666,
6068,
367,
314,
23176,
5137,
199,
88,
3825,
12,
612,
3825,
275,
6982,
63,
7928,
795,
8,
576,
9,
199,
56,
12,
1488,
275,
980,
14,
6480,
3825,
8,
88,
3825,
10345,
21,
467,
612,
3825,
10345,
21,
1527,
21123,
17,
566,
199,
9688,
63,
4443,
275,
666,
14,
10828,
83,
59,
22,
1527,
447,
21,
12,
3800,
21,
61,
199,
9688,
63,
2629,
275,
334,
9688,
63,
4443,
690,
446,
5008,
680,
11186,
342,
199,
199,
1702,
275,
980,
14,
20221,
779,
57,
14,
11186,
1062,
1323,
14,
11186,
342,
6575,
52,
199,
1702,
275,
13222,
59,
9688,
63,
2629,
61,
199,
1702,
9000,
980,
14,
1038,
1182,
13576,
14,
199,
199,
3,
14794,
2341,
402,
23150,
437,
8534,
543,
10208,
402,
1924,
20340,
199,
592,
275,
4488,
14,
8941,
342,
199,
592,
14,
21430,
63,
10917,
8,
3039,
29,
16,
14,
1717,
12,
2451,
29,
16,
14,
2720,
12,
336,
2638,
29,
16,
14,
1717,
9,
199,
199,
509,
284,
315,
1425,
8,
18,
304,
272,
4488,
14,
13334,
8,
17,
12,
499,
12,
284,
435,
413,
9,
339,
327,
6982,
282,
5114,
13650,
14497,
402,
314,
4084,
272,
870,
480,
446,
17226,
1804,
1093,
315,
308,
27058,
8983,
531,
272,
1022,
271,
275,
24901,
26211,
8,
18358,
29,
16,
14,
966,
12,
6370,
534,
2411,
14895,
1132,
297,
717,
5114,
534,
22911,
297,
5563,
534,
8571,
63,
2350,
358,
272,
1022,
271,
14,
3269,
8,
56,
2834,
59,
89,
2834,
508,
284,
566,
339,
327,
9352,
1454,
641,
314,
20078,
26,
446,
5008,
9126,
312,
20867,
272,
3107,
275,
446,
5008,
435,
980,
14,
4250,
8,
9688,
63,
2629,
14,
1392,
59,
16,
566,
272,
3107,
59,
9688,
63,
2629,
61,
275,
980,
14,
1474,
8,
29461,
14,
3397,
63,
3356,
8,
1702,
430,
272,
3107,
275,
3107,
14,
5217,
8,
56,
14,
1392,
9,
339,
327,
5137,
23176,
83,
402,
314,
13650,
272,
11106,
275,
980,
14,
11649,
8,
16,
12,
3107,
14,
988,
1062,
5661,
9,
272,
4488,
14,
17798,
70,
8,
56
] |
[
199,
12813,
199,
14127,
25187,
3677,
15896,
6897,
402,
5367,
397,
577,
5414,
852,
199,
12813,
199,
2765,
13703,
376,
2893,
402,
282,
15845,
13,
6788,
1827,
334,
262,
6770,
282,
5114,
199,
15669,
14497,
9,
641,
30259,
9491,
666,
12,
1808,
282,
699,
452,
12178,
6137,
12188,
314,
199,
15739,
14895,
1132,
6033,
6370,
1553,
284,
14,
69,
14,
15108,
1806,
4501,
315,
18896,
15,
13803,
14,
199,
1918,
4789,
365,
2741,
701,
11308,
8148,
1190,
10844,
14,
741,
14,
334,
7968,
680,
199,
3917,
2808,
12,
314,
2893,
4440,
199,
64,
1095,
1130,
665,
1014,
921,
16440,
14,
22943,
14,
846,
15,
1095,
1130,
15,
1301,
15,
1360,
3133,
18417,
199,
475,
5137,
314,
512,
1810,
2385,
436,
302,
6279,
18135,
402,
23150,
437,
8534,
14,
199,
199,
2765,
2893,
1630,
440,
5147,
1263,
9328,
1806,
314,
666,
199,
8,
3239,
520,
1121,
1705,
2694,
63,
15853,
63,
2798,
63,
17168,
63,
4972,
63,
1238,
316,
14,
647,
64,
367,
199,
290,
2893,
402,
12505,
4079,
641,
314,
3004,
315,
642,
4789,
680,
221,
2779,
199,
11184,
590,
13703,
314,
5114,
13650,
14497,
402,
20802,
666,
4501,
315,
199,
12151,
9491,
8983,
14,
199,
199,
1918,
2877,
20340,
787,
26,
421,
446,
28531,
34,
9525,
2279,
527,
4172,
5902,
896,
2,
2043,
665,
1014,
921,
1544,
14,
73,
947,
78,
581,
513,
14,
1308,
15,
5181,
15,
581,
513,
15,
5087,
15,
1216,
1703,
15,
16,
18740,
2360,
2043,
314,
699,
18406,
13,
273,
293,
972,
428,
320,
273,
14,
421,
446,
28531,
45,
530,
451,
19873,
676,
588,
1748,
337,
527,
2,
2043,
665,
1014,
921,
1544,
14,
73,
947,
78,
581,
513,
14,
1308,
15,
5181,
15,
581,
513,
15,
5087,
15,
7582,
2036,
15,
16,
18740,
2360,
2043,
2597,
6040,
465,
314,
21684,
270,
23704,
820,
1885,
820,
292,
12,
282,
882,
1326,
626,
27576,
315,
3492,
85,
12,
2043,
1849,
320,
887,
4674,
12,
662,
67,
8346,
269,
12,
3492,
85,
12,
436,
812,
6349,
90,
310,
416,
14,
199,
199,
15242,
199,
9460,
421,
627,
28531,
10915,
19490,
1402,
316,
402,
20340,
25637,
10208,
2,
2043,
665,
1014,
921,
1544,
14,
1259,
14,
2700,
2855,
1860,
14,
8654,
22500,
15820,
1246,
264,
15,
10443,
83,
15,
69,
761,
1494,
14,
5607,
18740,
2043,
428,
14,
1603,
14,
11308,
8148,
1190,
12,
820,
14,
510,
14,
1626,
424,
834,
12,
820,
14,
662,
14,
22985,
1246,
264,
446,
662,
331,
7954,
4900,
10564,
12,
2043,
29682,
26,
11921,
13,
11990,
12,
8315,
14,
199,
624,
199,
3,
6529,
26,
1603,
1728,
812,
11438,
1168,
305,
665,
74,
1728,
86,
5780,
32,
1259,
14,
87,
1119,
31673,
14,
8654,
30,
199,
3,
199,
3,
844,
26,
6289,
650,
8502,
199,
199,
646,
2680,
465,
980,
199,
646,
8027,
14,
13563,
465,
4488,
199,
504,
6357,
14,
12281,
492,
5267,
63,
17168,
63,
5613,
199,
504,
6357,
14,
12281,
14,
17168,
63,
5613,
492,
6982,
63,
7928,
795,
199,
504,
6357,
14,
11113,
492,
24901,
26211,
199,
199,
3,
340,
1300,
1130,
365,
2808,
12,
781,
7171,
675,
652,
14,
199,
3,
4257,
12,
781,
7171,
1742,
293,
433,
261,
2945,
1396,
199,
893,
26,
272,
687,
22513,
63,
3557,
75,
1405,
14,
1095,
1130,
492,
3523,
1130,
272,
1300,
1130,
275,
715,
199,
2590,
3545,
26,
272,
1300,
1130,
275,
756,
199,
199,
3,
2372,
12627,
15,
10095,
402,
20340,
11449,
436,
9918,
199,
576,
275,
5267,
63,
17168,
63,
5613,
342,
199,
17168,
63,
1247,
275,
788,
34,
9525,
2279,
527,
21107,
5902,
896,
297,
283,
45,
530,
451,
19873,
676,
588,
10195,
337,
527,
418,
199,
199,
56,
2834,
275,
980,
14,
20221,
779,
576,
459,
2834,
2545,
617,
8396,
995,
490,
666,
459,
2834,
2545,
617,
1846,
418,
6575,
52,
199,
89,
2834,
275,
980,
14,
1144,
779,
68,
14,
2708,
360,
4371,
1959,
2460,
360,
6453,
358,
2116,
367,
366,
315,
666,
459,
2834,
2545,
17168,
2157,
2152,
534,
442,
358,
199,
56,
2834,
9000,
980,
14,
1038,
1182,
13576,
14,
221,
327,
7905,
8396,
15,
2809,
370,
26874,
199,
199,
3,
2494,
1536,
314,
666,
6068,
367,
314,
23176,
5137,
199,
88,
3825,
12,
612,
3825,
275,
6982,
63,
7928,
795,
8,
576,
9,
199,
56,
12,
1488,
275,
980,
14,
6480,
3825,
8,
88,
3825,
10345,
21,
467,
612,
3825,
10345,
21,
1527,
21123,
17,
566,
199,
9688,
63,
4443,
275,
666,
14,
10828,
83,
59,
22,
1527,
447,
21,
12,
3800,
21,
61,
199,
9688,
63,
2629,
275,
334,
9688,
63,
4443,
690,
446,
5008,
680,
11186,
342,
199,
199,
1702,
275,
980,
14,
20221,
779,
57,
14,
11186,
1062,
1323,
14,
11186,
342,
6575,
52,
199,
1702,
275,
13222,
59,
9688,
63,
2629,
61,
199,
1702,
9000,
980,
14,
1038,
1182,
13576,
14,
199,
199,
3,
14794,
2341,
402,
23150,
437,
8534,
543,
10208,
402,
1924,
20340,
199,
592,
275,
4488,
14,
8941,
342,
199,
592,
14,
21430,
63,
10917,
8,
3039,
29,
16,
14,
1717,
12,
2451,
29,
16,
14,
2720,
12,
336,
2638,
29,
16,
14,
1717,
9,
199,
199,
509,
284,
315,
1425,
8,
18,
304,
272,
4488,
14,
13334,
8,
17,
12,
499,
12,
284,
435,
413,
9,
339,
327,
6982,
282,
5114,
13650,
14497,
402,
314,
4084,
272,
870,
480,
446,
17226,
1804,
1093,
315,
308,
27058,
8983,
531,
272,
1022,
271,
275,
24901,
26211,
8,
18358,
29,
16,
14,
966,
12,
6370,
534,
2411,
14895,
1132,
297,
717,
5114,
534,
22911,
297,
5563,
534,
8571,
63,
2350,
358,
272,
1022,
271,
14,
3269,
8,
56,
2834,
59,
89,
2834,
508,
284,
566,
339,
327,
9352,
1454,
641,
314,
20078,
26,
446,
5008,
9126,
312,
20867,
272,
3107,
275,
446,
5008,
435,
980,
14,
4250,
8,
9688,
63,
2629,
14,
1392,
59,
16,
566,
272,
3107,
59,
9688,
63,
2629,
61,
275,
980,
14,
1474,
8,
29461,
14,
3397,
63,
3356,
8,
1702,
430,
272,
3107,
275,
3107,
14,
5217,
8,
56,
14,
1392,
9,
339,
327,
5137,
23176,
83,
402,
314,
13650,
272,
11106,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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
] |
vFense/vFenseAgent-nix
|
agent/deps/rpm6/Python-2.7.5/lib/python2.7/test/test_list.py
|
83
|
2642
|
import sys
from test import test_support, list_tests
class ListTest(list_tests.CommonTest):
type2test = list
def test_basic(self):
self.assertEqual(list([]), [])
l0_3 = [0, 1, 2, 3]
l0_3_bis = list(l0_3)
self.assertEqual(l0_3, l0_3_bis)
self.assertTrue(l0_3 is not l0_3_bis)
self.assertEqual(list(()), [])
self.assertEqual(list((0, 1, 2, 3)), [0, 1, 2, 3])
self.assertEqual(list(''), [])
self.assertEqual(list('spam'), ['s', 'p', 'a', 'm'])
if sys.maxsize == 0x7fffffff:
# This test can currently only work on 32-bit machines.
# XXX If/when PySequence_Length() returns a ssize_t, it should be
# XXX re-enabled.
# Verify clearing of bug #556025.
# This assumes that the max data size (sys.maxint) == max
# address size this also assumes that the address size is at
# least 4 bytes with 8 byte addresses, the bug is not well
# tested
#
# Note: This test is expected to SEGV under Cygwin 1.3.12 or
# earlier due to a newlib bug. See the following mailing list
# thread for the details:
# http://sources.redhat.com/ml/newlib/2002/msg00369.html
self.assertRaises(MemoryError, list, xrange(sys.maxint // 2))
# This code used to segfault in Py2.4a3
x = []
x.extend(-y for y in x)
self.assertEqual(x, [])
def test_truth(self):
super(ListTest, self).test_truth()
self.assertTrue(not [])
self.assertTrue([42])
def test_identity(self):
self.assertTrue([] is not [])
def test_len(self):
super(ListTest, self).test_len()
self.assertEqual(len([]), 0)
self.assertEqual(len([0]), 1)
self.assertEqual(len([0, 1, 2]), 3)
def test_overflow(self):
lst = [4, 5, 6, 7]
n = int((sys.maxint*2+2) // len(lst))
def mul(a, b): return a * b
def imul(a, b): a *= b
self.assertRaises((MemoryError, OverflowError), mul, lst, n)
self.assertRaises((MemoryError, OverflowError), imul, lst, n)
def test_main(verbose=None):
test_support.run_unittest(ListTest)
# verify reference counting
import sys
if verbose and hasattr(sys, "gettotalrefcount"):
import gc
counts = [None] * 5
for i in xrange(len(counts)):
test_support.run_unittest(ListTest)
gc.collect()
counts[i] = sys.gettotalrefcount()
print counts
if __name__ == "__main__":
test_main(verbose=True)
|
lgpl-3.0
|
[
646,
984,
199,
504,
511,
492,
511,
63,
4058,
12,
769,
63,
2219,
199,
199,
533,
3820,
774,
8,
513,
63,
2219,
14,
7844,
774,
304,
272,
730,
18,
396,
275,
769,
339,
347,
511,
63,
4316,
8,
277,
304,
267,
291,
14,
629,
8,
513,
25550,
3073,
267,
634,
16,
63,
19,
275,
359,
16,
12,
413,
12,
499,
12,
650,
61,
267,
634,
16,
63,
19,
63,
18797,
275,
769,
8,
76,
16,
63,
19,
9,
267,
291,
14,
629,
8,
76,
16,
63,
19,
12,
634,
16,
63,
19,
63,
18797,
9,
267,
291,
14,
1815,
8,
76,
16,
63,
19,
365,
440,
634,
16,
63,
19,
63,
18797,
9,
267,
291,
14,
629,
8,
513,
8,
4000,
3073,
267,
291,
14,
629,
8,
513,
1332,
16,
12,
413,
12,
499,
12,
650,
1826,
359,
16,
12,
413,
12,
499,
12,
650,
566,
267,
291,
14,
629,
8,
513,
31150,
3073,
267,
291,
14,
629,
8,
513,
360,
8283,
659,
788,
83,
297,
283,
80,
297,
283,
65,
297,
283,
77,
1105,
398,
340,
984,
14,
13634,
508,
378,
88,
23,
12596,
70,
26,
288,
327,
961,
511,
883,
5544,
1454,
1736,
641,
4337,
13,
2075,
20601,
14,
288,
327,
5787,
982,
15,
6526,
1611,
5826,
63,
4625,
342,
2529,
282,
308,
890,
63,
84,
12,
652,
1077,
506,
288,
327,
5787,
295,
13,
3827,
14,
288,
327,
7635,
5436,
316,
402,
6519,
327,
1229,
2259,
821,
14,
288,
327,
961,
15194,
626,
314,
1390,
666,
1568,
334,
1274,
14,
21411,
9,
508,
1390,
288,
327,
2287,
1568,
642,
2597,
15194,
626,
314,
2287,
1568,
365,
737,
288,
327,
5210,
841,
2783,
543,
1695,
3696,
7149,
12,
314,
6519,
365,
440,
5521,
288,
327,
12470,
288,
327,
288,
327,
3390,
26,
961,
511,
365,
1420,
370,
428,
4680,
54,
1334,
445,
18313,
413,
14,
19,
14,
713,
503,
288,
327,
14119,
7037,
370,
282,
892,
773,
6519,
14,
221,
1666,
314,
2569,
30939,
769,
288,
327,
2462,
367,
314,
2436,
26,
953,
327,
258,
1455,
921,
4553,
14,
17164,
14,
957,
15,
757,
15,
1222,
773,
15,
15135,
15,
1328,
383,
11939,
14,
1360,
288,
291,
14,
1855,
8,
8628,
547,
12,
769,
12,
4945,
8,
1274,
14,
21411,
5001,
499,
430,
398,
327,
961,
1233,
1202,
370,
8812,
1879,
315,
1611,
18,
14,
20,
65,
19,
267,
671,
275,
942,
267,
671,
14,
2880,
2801,
89,
367,
612,
315,
671,
9,
267,
291,
14,
629,
8,
88,
12,
3073,
339,
347,
511,
63,
17167,
8,
277,
304,
267,
1613,
8,
1296,
774,
12,
291,
680,
396,
63,
17167,
342,
267,
291,
14,
1815,
8,
1397,
3073,
267,
291,
14,
1815,
779,
2260,
566,
339,
347,
511,
63,
5582,
8,
277,
304,
267,
291,
14,
1815,
779,
61,
365,
440,
3073,
339,
347,
511,
63,
552,
8,
277,
304,
267,
1613,
8,
1296,
774,
12,
291,
680,
396,
63,
552,
342,
267,
291,
14,
629,
8,
552,
25550,
378,
9,
267,
291,
14,
629,
8,
552,
779,
16,
2522,
413,
9,
267,
291,
14,
629,
8,
552,
779,
16,
12,
413,
12,
499,
2522,
650,
9,
339,
347,
511,
63,
14108,
8,
277,
304,
267,
9877,
275,
359,
20,
12,
959,
12,
1227,
12,
1520,
61,
267,
302,
275,
1109,
1332,
1274,
14,
21411,
10,
18,
11,
18,
9,
5001,
822,
8,
6916,
430,
267,
347,
19207,
8,
65,
12,
330,
304,
372,
282,
627,
330,
267,
347,
3416,
348,
8,
65,
12,
330,
304,
282,
9000,
330,
267,
291,
14,
1855,
1332,
8628,
547,
12,
23870,
395,
19207,
12,
9877,
12,
302,
9,
267,
291,
14,
1855,
1332,
8628,
547,
12,
23870,
395,
3416,
348,
12,
9877,
12,
302,
9,
199,
199,
318,
511,
63,
973,
8,
3832,
29,
403,
304,
272,
511,
63,
4058,
14,
1065,
63,
2796,
8,
1296,
774,
9,
339,
327,
4911,
3659,
23190,
272,
492,
984,
272,
340,
3376,
436,
2688,
8,
1274,
12,
298,
362,
2923,
16497,
2349,
267,
492,
9486,
267,
8242,
275,
359,
403,
61,
627,
959,
267,
367,
284,
315,
4945,
8,
552,
8,
6851,
2298,
288,
511,
63,
4058,
14,
1065,
63,
2796,
8,
1296,
774,
9,
288,
9486,
14,
7112,
342,
288,
8242,
59,
73,
61,
275,
984,
14,
362,
2923,
16497,
342,
267,
870,
8242,
421,
199,
692,
636,
354,
363,
508,
4396,
973,
5727,
272,
511,
63,
973,
8,
3832,
29,
549,
9,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,
504,
511,
492,
511,
63,
4058,
12,
769,
63,
2219,
199,
199,
533,
3820,
774,
8,
513,
63,
2219,
14,
7844,
774,
304,
272,
730,
18,
396,
275,
769,
339,
347,
511,
63,
4316,
8,
277,
304,
267,
291,
14,
629,
8,
513,
25550,
3073,
267,
634,
16,
63,
19,
275,
359,
16,
12,
413,
12,
499,
12,
650,
61,
267,
634,
16,
63,
19,
63,
18797,
275,
769,
8,
76,
16,
63,
19,
9,
267,
291,
14,
629,
8,
76,
16,
63,
19,
12,
634,
16,
63,
19,
63,
18797,
9,
267,
291,
14,
1815,
8,
76,
16,
63,
19,
365,
440,
634,
16,
63,
19,
63,
18797,
9,
267,
291,
14,
629,
8,
513,
8,
4000,
3073,
267,
291,
14,
629,
8,
513,
1332,
16,
12,
413,
12,
499,
12,
650,
1826,
359,
16,
12,
413,
12,
499,
12,
650,
566,
267,
291,
14,
629,
8,
513,
31150,
3073,
267,
291,
14,
629,
8,
513,
360,
8283,
659,
788,
83,
297,
283,
80,
297,
283,
65,
297,
283,
77,
1105,
398,
340,
984,
14,
13634,
508,
378,
88,
23,
12596,
70,
26,
288,
327,
961,
511,
883,
5544,
1454,
1736,
641,
4337,
13,
2075,
20601,
14,
288,
327,
5787,
982,
15,
6526,
1611,
5826,
63,
4625,
342,
2529,
282,
308,
890,
63,
84,
12,
652,
1077,
506,
288,
327,
5787,
295,
13,
3827,
14,
288,
327,
7635,
5436,
316,
402,
6519,
327,
1229,
2259,
821,
14,
288,
327,
961,
15194,
626,
314,
1390,
666,
1568,
334,
1274,
14,
21411,
9,
508,
1390,
288,
327,
2287,
1568,
642,
2597,
15194,
626,
314,
2287,
1568,
365,
737,
288,
327,
5210,
841,
2783,
543,
1695,
3696,
7149,
12,
314,
6519,
365,
440,
5521,
288,
327,
12470,
288,
327,
288,
327,
3390,
26,
961,
511,
365,
1420,
370,
428,
4680,
54,
1334,
445,
18313,
413,
14,
19,
14,
713,
503,
288,
327,
14119,
7037,
370,
282,
892,
773,
6519,
14,
221,
1666,
314,
2569,
30939,
769,
288,
327,
2462,
367,
314,
2436,
26,
953,
327,
258,
1455,
921,
4553,
14,
17164,
14,
957,
15,
757,
15,
1222,
773,
15,
15135,
15,
1328,
383,
11939,
14,
1360,
288,
291,
14,
1855,
8,
8628,
547,
12,
769,
12,
4945,
8,
1274,
14,
21411,
5001,
499,
430,
398,
327,
961,
1233,
1202,
370,
8812,
1879,
315,
1611,
18,
14,
20,
65,
19,
267,
671,
275,
942,
267,
671,
14,
2880,
2801,
89,
367,
612,
315,
671,
9,
267,
291,
14,
629,
8,
88,
12,
3073,
339,
347,
511,
63,
17167,
8,
277,
304,
267,
1613,
8,
1296,
774,
12,
291,
680,
396,
63,
17167,
342,
267,
291,
14,
1815,
8,
1397,
3073,
267,
291,
14,
1815,
779,
2260,
566,
339,
347,
511,
63,
5582,
8,
277,
304,
267,
291,
14,
1815,
779,
61,
365,
440,
3073,
339,
347,
511,
63,
552,
8,
277,
304,
267,
1613,
8,
1296,
774,
12,
291,
680,
396,
63,
552,
342,
267,
291,
14,
629,
8,
552,
25550,
378,
9,
267,
291,
14,
629,
8,
552,
779,
16,
2522,
413,
9,
267,
291,
14,
629,
8,
552,
779,
16,
12,
413,
12,
499,
2522,
650,
9,
339,
347,
511,
63,
14108,
8,
277,
304,
267,
9877,
275,
359,
20,
12,
959,
12,
1227,
12,
1520,
61,
267,
302,
275,
1109,
1332,
1274,
14,
21411,
10,
18,
11,
18,
9,
5001,
822,
8,
6916,
430,
267,
347,
19207,
8,
65,
12,
330,
304,
372,
282,
627,
330,
267,
347,
3416,
348,
8,
65,
12,
330,
304,
282,
9000,
330,
267,
291,
14,
1855,
1332,
8628,
547,
12,
23870,
395,
19207,
12,
9877,
12,
302,
9,
267,
291,
14,
1855,
1332,
8628,
547,
12,
23870,
395,
3416,
348,
12,
9877,
12,
302,
9,
199,
199,
318,
511,
63,
973,
8,
3832,
29,
403,
304,
272,
511,
63,
4058,
14,
1065,
63,
2796,
8,
1296,
774,
9,
339,
327,
4911,
3659,
23190,
272,
492,
984,
272,
340,
3376,
436,
2688,
8,
1274,
12,
298,
362,
2923,
16497,
2349,
267,
492,
9486,
267,
8242,
275,
359,
403,
61,
627,
959,
267,
367,
284,
315,
4945,
8,
552,
8,
6851,
2298,
288,
511,
63,
4058,
14,
1065,
63,
2796,
8,
1296,
774,
9,
288,
9486,
14,
7112,
342,
288,
8242,
59,
73,
61,
275,
984,
14,
362,
2923,
16497,
342,
267,
870,
8242,
421,
199,
692,
636,
354,
363,
508,
4396,
973,
5727,
272,
511,
63,
973,
8,
3832,
29,
549,
9,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
MicroTrustRepos/microkernel
|
src/l4/pkg/python/contrib/Lib/plat-mac/lib-scriptpackages/Finder/Files.py
|
80
|
6439
|
"""Suite Files: Classes representing files
Level 1, version 1
Generated from /System/Library/CoreServices/Finder.app
AETE/AEUT resource version 0/144, language 0, script 0
"""
import aetools
import MacOS
_code = 'fndr'
class Files_Events:
pass
class alias_file(aetools.ComponentItem):
"""alias file - An alias file (created with \xd2Make Alias\xd3) """
want = 'alia'
class _Prop__3c_Inheritance_3e_(aetools.NProperty):
"""<Inheritance> - inherits some of its properties from the file class """
which = 'c@#^'
want = 'file'
class _Prop_original_item(aetools.NProperty):
"""original item - the original item pointed to by the alias """
which = 'orig'
want = 'obj '
alias_files = alias_file
class application_file(aetools.ComponentItem):
"""application file - An application's file on disk """
want = 'appf'
class _Prop_accepts_high_level_events(aetools.NProperty):
"""accepts high level events - Is the application high-level event aware? (OBSOLETE: always returns true) """
which = 'isab'
want = 'bool'
class _Prop_has_scripting_terminology(aetools.NProperty):
"""has scripting terminology - Does the process have a scripting terminology, i.e., can it be scripted? """
which = 'hscr'
want = 'bool'
class _Prop_minimum_size(aetools.NProperty):
"""minimum size - the smallest memory size with which the application can be launched """
which = 'mprt'
want = 'long'
class _Prop_opens_in_Classic(aetools.NProperty):
"""opens in Classic - Should the application launch in the Classic environment? """
which = 'Clsc'
want = 'bool'
class _Prop_preferred_size(aetools.NProperty):
"""preferred size - the memory size with which the application will be launched """
which = 'appt'
want = 'long'
class _Prop_suggested_size(aetools.NProperty):
"""suggested size - the memory size with which the developer recommends the application be launched """
which = 'sprt'
want = 'long'
application_files = application_file
class clipping(aetools.ComponentItem):
"""clipping - A clipping """
want = 'clpf'
class _Prop_clipping_window(aetools.NProperty):
"""clipping window - (NOT AVAILABLE YET) the clipping window for this clipping """
which = 'lwnd'
want = 'obj '
clippings = clipping
class document_file(aetools.ComponentItem):
"""document file - A document file """
want = 'docf'
document_files = document_file
class file(aetools.ComponentItem):
"""file - A file """
want = 'file'
class _Prop_creator_type(aetools.NProperty):
"""creator type - the OSType identifying the application that created the item """
which = 'fcrt'
want = 'type'
class _Prop_file_type(aetools.NProperty):
"""file type - the OSType identifying the type of data contained in the item """
which = 'asty'
want = 'type'
class _Prop_product_version(aetools.NProperty):
"""product version - the version of the product (visible at the top of the \xd2Get Info\xd3 window) """
which = 'ver2'
want = 'utxt'
class _Prop_stationery(aetools.NProperty):
"""stationery - Is the file a stationery pad? """
which = 'pspd'
want = 'bool'
class _Prop_version(aetools.NProperty):
"""version - the version of the file (visible at the bottom of the \xd2Get Info\xd3 window) """
which = 'vers'
want = 'utxt'
files = file
class internet_location_file(aetools.ComponentItem):
"""internet location file - An file containing an internet location """
want = 'inlf'
class _Prop_location(aetools.NProperty):
"""location - the internet location """
which = 'iloc'
want = 'utxt'
internet_location_files = internet_location_file
class package(aetools.ComponentItem):
"""package - A package """
want = 'pack'
packages = package
alias_file._superclassnames = ['file']
alias_file._privpropdict = {
'_3c_Inheritance_3e_' : _Prop__3c_Inheritance_3e_,
'original_item' : _Prop_original_item,
}
alias_file._privelemdict = {
}
application_file._superclassnames = ['file']
application_file._privpropdict = {
'_3c_Inheritance_3e_' : _Prop__3c_Inheritance_3e_,
'accepts_high_level_events' : _Prop_accepts_high_level_events,
'has_scripting_terminology' : _Prop_has_scripting_terminology,
'minimum_size' : _Prop_minimum_size,
'opens_in_Classic' : _Prop_opens_in_Classic,
'preferred_size' : _Prop_preferred_size,
'suggested_size' : _Prop_suggested_size,
}
application_file._privelemdict = {
}
clipping._superclassnames = ['file']
clipping._privpropdict = {
'_3c_Inheritance_3e_' : _Prop__3c_Inheritance_3e_,
'clipping_window' : _Prop_clipping_window,
}
clipping._privelemdict = {
}
document_file._superclassnames = ['file']
document_file._privpropdict = {
'_3c_Inheritance_3e_' : _Prop__3c_Inheritance_3e_,
}
document_file._privelemdict = {
}
import Finder_items
file._superclassnames = ['item']
file._privpropdict = {
'_3c_Inheritance_3e_' : _Prop__3c_Inheritance_3e_,
'creator_type' : _Prop_creator_type,
'file_type' : _Prop_file_type,
'product_version' : _Prop_product_version,
'stationery' : _Prop_stationery,
'version' : _Prop_version,
}
file._privelemdict = {
}
internet_location_file._superclassnames = ['file']
internet_location_file._privpropdict = {
'_3c_Inheritance_3e_' : _Prop__3c_Inheritance_3e_,
'location' : _Prop_location,
}
internet_location_file._privelemdict = {
}
package._superclassnames = ['item']
package._privpropdict = {
'_3c_Inheritance_3e_' : _Prop__3c_Inheritance_3e_,
}
package._privelemdict = {
}
#
# Indices of types declared in this module
#
_classdeclarations = {
'alia' : alias_file,
'appf' : application_file,
'clpf' : clipping,
'docf' : document_file,
'file' : file,
'inlf' : internet_location_file,
'pack' : package,
}
_propdeclarations = {
'Clsc' : _Prop_opens_in_Classic,
'appt' : _Prop_preferred_size,
'asty' : _Prop_file_type,
'c@#^' : _Prop__3c_Inheritance_3e_,
'fcrt' : _Prop_creator_type,
'hscr' : _Prop_has_scripting_terminology,
'iloc' : _Prop_location,
'isab' : _Prop_accepts_high_level_events,
'lwnd' : _Prop_clipping_window,
'mprt' : _Prop_minimum_size,
'orig' : _Prop_original_item,
'pspd' : _Prop_stationery,
'sprt' : _Prop_suggested_size,
'ver2' : _Prop_product_version,
'vers' : _Prop_version,
}
_compdeclarations = {
}
_enumdeclarations = {
}
|
gpl-2.0
|
[
624,
6207,
16920,
26,
27939,
6144,
1584,
199,
4670,
413,
12,
1015,
413,
199,
199,
12706,
687,
1182,
3989,
15,
7424,
15,
5402,
15803,
15,
11791,
14,
571,
199,
33,
5248,
15,
12500,
934,
2073,
1015,
378,
15,
9862,
12,
2637,
378,
12,
2884,
378,
199,
624,
199,
199,
646,
282,
25750,
199,
646,
10444,
3100,
199,
199,
63,
600,
275,
283,
70,
977,
82,
7,
199,
199,
533,
16920,
63,
11770,
26,
339,
986,
421,
199,
533,
5162,
63,
493,
8,
65,
25750,
14,
7004,
2081,
304,
272,
408,
3620,
570,
446,
1626,
5162,
570,
334,
3966,
543,
971,
2207,
18,
5483,
24777,
60,
2207,
19,
9,
408,
272,
2934,
275,
283,
19221,
7,
199,
533,
485,
9955,
363,
19,
67,
63,
23542,
554,
63,
19,
69,
2531,
65,
25750,
14,
46,
3697,
304,
272,
8894,
23542,
554,
30,
446,
21592,
2005,
402,
2399,
4382,
687,
314,
570,
1021,
408,
272,
1314,
275,
283,
67,
32,
3,
62,
7,
272,
2934,
275,
283,
493,
7,
199,
533,
485,
9955,
63,
5043,
63,
1053,
8,
65,
25750,
14,
46,
3697,
304,
272,
408,
5043,
1242,
446,
314,
3379,
1242,
32031,
370,
701,
314,
5162,
408,
272,
1314,
275,
283,
2981,
7,
272,
2934,
275,
283,
1113,
283,
199,
199,
3620,
63,
1725,
275,
5162,
63,
493,
199,
199,
533,
4223,
63,
493,
8,
65,
25750,
14,
7004,
2081,
304,
272,
408,
3578,
570,
446,
1626,
4223,
1159,
570,
641,
4543,
408,
272,
2934,
275,
283,
571,
70,
7,
199,
533,
485,
9955,
63,
27692,
63,
6260,
63,
1896,
63,
4368,
8,
65,
25750,
14,
46,
3697,
304,
272,
408,
27692,
4721,
2166,
4474,
446,
6596,
314,
4223,
4721,
13,
1896,
1566,
20381,
31,
334,
5488,
15096,
5248,
26,
3544,
2529,
2549,
9,
408,
272,
1314,
275,
283,
374,
371,
7,
272,
2934,
275,
283,
2245,
7,
199,
533,
485,
9955,
63,
1989,
63,
1579,
316,
63,
2704,
7085,
8,
65,
25750,
14,
46,
3697,
304,
272,
408,
1989,
2884,
316,
5537,
7085,
446,
12078,
314,
2112,
1172,
282,
2884,
316,
5537,
7085,
12,
284,
14,
69,
2020,
883,
652,
506,
308,
1408,
4979,
31,
408,
272,
1314,
275,
283,
72,
11047,
7,
272,
2934,
275,
283,
2245,
7,
199,
533,
485,
9955,
63,
10700,
63,
890,
8,
65,
25750,
14,
46,
3697,
304,
272,
408,
10700,
1568,
446,
314,
18604,
4402,
1568,
543,
1314,
314,
4223,
883,
506,
27725,
408,
272,
1314,
275,
283,
311,
2591,
7,
272,
2934,
275,
283,
2809,
7,
199,
533,
485,
9955,
63,
1490,
83,
63,
262,
63,
30722,
67,
8,
65,
25750,
14,
46,
3697,
304,
272,
408,
1490,
83,
315,
8465,
2608,
67,
446,
7719,
314,
4223,
10623,
315,
314,
8465,
2608,
67,
3734,
31,
408,
272,
1314,
275,
283,
24342,
67,
7,
272,
2934,
275,
283,
2245,
7,
199,
533,
485,
9955,
63,
17477,
63,
890,
8,
65,
25750,
14,
46,
3697,
304,
272,
408,
17477,
1568,
446,
314,
4402,
1568,
543,
1314,
314,
4223,
911,
506,
27725,
408,
272,
1314,
275,
283,
439,
541,
7,
272,
2934,
275,
283,
2809,
7,
199,
533,
485,
9955,
63,
29833,
63,
890,
8,
65,
25750,
14,
46,
3697,
304,
272,
408,
29833,
1568,
446,
314,
4402,
1568,
543,
1314,
314,
15030,
295,
9847,
795,
314,
4223,
506,
27725,
408,
272,
1314,
275,
283,
681,
2591,
7,
272,
2934,
275,
283,
2809,
7,
199,
199,
3578,
63,
1725,
275,
4223,
63,
493,
199,
199,
533,
5053,
3637,
8,
65,
25750,
14,
7004,
2081,
304,
272,
408,
2764,
3637,
446,
437,
5053,
3637,
408,
272,
2934,
275,
283,
429,
9928,
7,
199,
533,
485,
9955,
63,
2764,
3637,
63,
3806,
8,
65,
25750,
14,
46,
3697,
304,
272,
408,
2764,
3637,
4353,
446,
334,
4609,
437,
54,
6593,
2617,
1488,
775,
9,
314,
5053,
3637,
4353,
367,
642,
5053,
3637,
408,
272,
1314,
275,
283,
20692,
977,
7,
272,
2934,
275,
283,
1113,
283,
199,
199,
2764,
802,
780,
275,
5053,
3637,
199,
199,
533,
2213,
63,
493,
8,
65,
25750,
14,
7004,
2081,
304,
272,
408,
3554,
570,
446,
437,
2213,
570,
408,
272,
2934,
275,
283,
1301,
70,
7,
199,
199,
3554,
63,
1725,
275,
2213,
63,
493,
199,
199,
533,
570,
8,
65,
25750,
14,
7004,
2081,
304,
272,
408,
493,
446,
437,
570,
408,
272,
2934,
275,
283,
493,
7,
199,
533,
485,
9955,
63,
9986,
63,
466,
8,
65,
25750,
14,
46,
3697,
304,
272,
408,
9986,
730,
446,
314,
4403,
804,
21119,
314,
4223,
626,
2737,
314,
1242,
408,
272,
1314,
275,
283,
70,
16617,
7,
272,
2934,
275,
283,
466,
7,
199,
533,
485,
9955,
63,
493,
63,
466,
8,
65,
25750,
14,
46,
3697,
304,
272,
408,
493,
730,
446,
314,
4403,
804,
21119,
314,
730,
402,
666,
10470,
315,
314,
1242,
408,
272,
1314,
275,
283,
27352,
7,
272,
2934,
275,
283,
466,
7,
199,
533,
485,
9955,
63,
2558,
63,
1023,
8,
65,
25750,
14,
46,
3697,
304,
272,
408,
2558,
1015,
446,
314,
1015,
402,
314,
3336,
334,
6604,
737,
314,
2746,
402,
314,
971,
2207,
18,
1002,
10332,
60,
2207,
19,
4353,
9,
408,
272,
1314,
275,
283,
422,
18,
7,
272,
2934,
275,
283,
337,
400,
7,
199,
533,
485,
9955,
63,
10600,
994,
8,
65,
25750,
14,
46,
3697,
304,
272,
408,
10600,
994,
446,
6596,
314,
570,
282,
16518,
994,
6567,
31,
408,
272,
1314,
275,
283,
80,
681,
68,
7,
272,
2934,
275,
283,
2245,
7,
199,
533,
485,
9955,
63,
1023,
8,
65,
25750,
14,
46,
3697,
304,
272,
408,
1023,
446,
314,
1015,
402,
314,
570,
334,
6604,
737,
314,
9048,
402,
314,
971,
2207,
18,
1002,
10332,
60,
2207,
19,
4353,
9,
408,
272,
1314,
275,
283,
14895,
7,
272,
2934,
275,
283,
337,
400,
7,
199,
199,
1725,
275,
570,
199,
199,
533,
21408,
63,
1985,
63,
493,
8,
65,
25750,
14,
7004,
2081,
304,
272,
408,
4901,
2909,
570,
446,
1626,
570,
3035,
376,
21408,
2909,
408,
272,
2934,
275,
283,
262,
276,
7,
199,
533,
485,
9955,
63,
1985,
8,
65,
25750,
14,
46,
3697,
304,
272,
408,
1985,
446,
314,
21408,
2909,
408,
272,
1314,
275,
283
] |
[
6207,
16920,
26,
27939,
6144,
1584,
199,
4670,
413,
12,
1015,
413,
199,
199,
12706,
687,
1182,
3989,
15,
7424,
15,
5402,
15803,
15,
11791,
14,
571,
199,
33,
5248,
15,
12500,
934,
2073,
1015,
378,
15,
9862,
12,
2637,
378,
12,
2884,
378,
199,
624,
199,
199,
646,
282,
25750,
199,
646,
10444,
3100,
199,
199,
63,
600,
275,
283,
70,
977,
82,
7,
199,
199,
533,
16920,
63,
11770,
26,
339,
986,
421,
199,
533,
5162,
63,
493,
8,
65,
25750,
14,
7004,
2081,
304,
272,
408,
3620,
570,
446,
1626,
5162,
570,
334,
3966,
543,
971,
2207,
18,
5483,
24777,
60,
2207,
19,
9,
408,
272,
2934,
275,
283,
19221,
7,
199,
533,
485,
9955,
363,
19,
67,
63,
23542,
554,
63,
19,
69,
2531,
65,
25750,
14,
46,
3697,
304,
272,
8894,
23542,
554,
30,
446,
21592,
2005,
402,
2399,
4382,
687,
314,
570,
1021,
408,
272,
1314,
275,
283,
67,
32,
3,
62,
7,
272,
2934,
275,
283,
493,
7,
199,
533,
485,
9955,
63,
5043,
63,
1053,
8,
65,
25750,
14,
46,
3697,
304,
272,
408,
5043,
1242,
446,
314,
3379,
1242,
32031,
370,
701,
314,
5162,
408,
272,
1314,
275,
283,
2981,
7,
272,
2934,
275,
283,
1113,
283,
199,
199,
3620,
63,
1725,
275,
5162,
63,
493,
199,
199,
533,
4223,
63,
493,
8,
65,
25750,
14,
7004,
2081,
304,
272,
408,
3578,
570,
446,
1626,
4223,
1159,
570,
641,
4543,
408,
272,
2934,
275,
283,
571,
70,
7,
199,
533,
485,
9955,
63,
27692,
63,
6260,
63,
1896,
63,
4368,
8,
65,
25750,
14,
46,
3697,
304,
272,
408,
27692,
4721,
2166,
4474,
446,
6596,
314,
4223,
4721,
13,
1896,
1566,
20381,
31,
334,
5488,
15096,
5248,
26,
3544,
2529,
2549,
9,
408,
272,
1314,
275,
283,
374,
371,
7,
272,
2934,
275,
283,
2245,
7,
199,
533,
485,
9955,
63,
1989,
63,
1579,
316,
63,
2704,
7085,
8,
65,
25750,
14,
46,
3697,
304,
272,
408,
1989,
2884,
316,
5537,
7085,
446,
12078,
314,
2112,
1172,
282,
2884,
316,
5537,
7085,
12,
284,
14,
69,
2020,
883,
652,
506,
308,
1408,
4979,
31,
408,
272,
1314,
275,
283,
72,
11047,
7,
272,
2934,
275,
283,
2245,
7,
199,
533,
485,
9955,
63,
10700,
63,
890,
8,
65,
25750,
14,
46,
3697,
304,
272,
408,
10700,
1568,
446,
314,
18604,
4402,
1568,
543,
1314,
314,
4223,
883,
506,
27725,
408,
272,
1314,
275,
283,
311,
2591,
7,
272,
2934,
275,
283,
2809,
7,
199,
533,
485,
9955,
63,
1490,
83,
63,
262,
63,
30722,
67,
8,
65,
25750,
14,
46,
3697,
304,
272,
408,
1490,
83,
315,
8465,
2608,
67,
446,
7719,
314,
4223,
10623,
315,
314,
8465,
2608,
67,
3734,
31,
408,
272,
1314,
275,
283,
24342,
67,
7,
272,
2934,
275,
283,
2245,
7,
199,
533,
485,
9955,
63,
17477,
63,
890,
8,
65,
25750,
14,
46,
3697,
304,
272,
408,
17477,
1568,
446,
314,
4402,
1568,
543,
1314,
314,
4223,
911,
506,
27725,
408,
272,
1314,
275,
283,
439,
541,
7,
272,
2934,
275,
283,
2809,
7,
199,
533,
485,
9955,
63,
29833,
63,
890,
8,
65,
25750,
14,
46,
3697,
304,
272,
408,
29833,
1568,
446,
314,
4402,
1568,
543,
1314,
314,
15030,
295,
9847,
795,
314,
4223,
506,
27725,
408,
272,
1314,
275,
283,
681,
2591,
7,
272,
2934,
275,
283,
2809,
7,
199,
199,
3578,
63,
1725,
275,
4223,
63,
493,
199,
199,
533,
5053,
3637,
8,
65,
25750,
14,
7004,
2081,
304,
272,
408,
2764,
3637,
446,
437,
5053,
3637,
408,
272,
2934,
275,
283,
429,
9928,
7,
199,
533,
485,
9955,
63,
2764,
3637,
63,
3806,
8,
65,
25750,
14,
46,
3697,
304,
272,
408,
2764,
3637,
4353,
446,
334,
4609,
437,
54,
6593,
2617,
1488,
775,
9,
314,
5053,
3637,
4353,
367,
642,
5053,
3637,
408,
272,
1314,
275,
283,
20692,
977,
7,
272,
2934,
275,
283,
1113,
283,
199,
199,
2764,
802,
780,
275,
5053,
3637,
199,
199,
533,
2213,
63,
493,
8,
65,
25750,
14,
7004,
2081,
304,
272,
408,
3554,
570,
446,
437,
2213,
570,
408,
272,
2934,
275,
283,
1301,
70,
7,
199,
199,
3554,
63,
1725,
275,
2213,
63,
493,
199,
199,
533,
570,
8,
65,
25750,
14,
7004,
2081,
304,
272,
408,
493,
446,
437,
570,
408,
272,
2934,
275,
283,
493,
7,
199,
533,
485,
9955,
63,
9986,
63,
466,
8,
65,
25750,
14,
46,
3697,
304,
272,
408,
9986,
730,
446,
314,
4403,
804,
21119,
314,
4223,
626,
2737,
314,
1242,
408,
272,
1314,
275,
283,
70,
16617,
7,
272,
2934,
275,
283,
466,
7,
199,
533,
485,
9955,
63,
493,
63,
466,
8,
65,
25750,
14,
46,
3697,
304,
272,
408,
493,
730,
446,
314,
4403,
804,
21119,
314,
730,
402,
666,
10470,
315,
314,
1242,
408,
272,
1314,
275,
283,
27352,
7,
272,
2934,
275,
283,
466,
7,
199,
533,
485,
9955,
63,
2558,
63,
1023,
8,
65,
25750,
14,
46,
3697,
304,
272,
408,
2558,
1015,
446,
314,
1015,
402,
314,
3336,
334,
6604,
737,
314,
2746,
402,
314,
971,
2207,
18,
1002,
10332,
60,
2207,
19,
4353,
9,
408,
272,
1314,
275,
283,
422,
18,
7,
272,
2934,
275,
283,
337,
400,
7,
199,
533,
485,
9955,
63,
10600,
994,
8,
65,
25750,
14,
46,
3697,
304,
272,
408,
10600,
994,
446,
6596,
314,
570,
282,
16518,
994,
6567,
31,
408,
272,
1314,
275,
283,
80,
681,
68,
7,
272,
2934,
275,
283,
2245,
7,
199,
533,
485,
9955,
63,
1023,
8,
65,
25750,
14,
46,
3697,
304,
272,
408,
1023,
446,
314,
1015,
402,
314,
570,
334,
6604,
737,
314,
9048,
402,
314,
971,
2207,
18,
1002,
10332,
60,
2207,
19,
4353,
9,
408,
272,
1314,
275,
283,
14895,
7,
272,
2934,
275,
283,
337,
400,
7,
199,
199,
1725,
275,
570,
199,
199,
533,
21408,
63,
1985,
63,
493,
8,
65,
25750,
14,
7004,
2081,
304,
272,
408,
4901,
2909,
570,
446,
1626,
570,
3035,
376,
21408,
2909,
408,
272,
2934,
275,
283,
262,
276,
7,
199,
533,
485,
9955,
63,
1985,
8,
65,
25750,
14,
46,
3697,
304,
272,
408,
1985,
446,
314,
21408,
2909,
408,
272,
1314,
275,
283,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
leekchan/django_test
|
django/contrib/gis/db/backends/oracle/introspection.py
|
35
|
1975
|
import cx_Oracle
import sys
from django.db.backends.oracle.introspection import DatabaseIntrospection
from django.utils import six
class OracleIntrospection(DatabaseIntrospection):
# Associating any OBJECTVAR instances with GeometryField. Of course,
# this won't work right on Oracle objects that aren't MDSYS.SDO_GEOMETRY,
# but it is the only object type supported within Django anyways.
data_types_reverse = DatabaseIntrospection.data_types_reverse.copy()
data_types_reverse[cx_Oracle.OBJECT] = 'GeometryField'
def get_geometry_type(self, table_name, geo_col):
cursor = self.connection.cursor()
try:
# Querying USER_SDO_GEOM_METADATA to get the SRID and dimension information.
try:
cursor.execute(
'SELECT "DIMINFO", "SRID" FROM "USER_SDO_GEOM_METADATA" '
'WHERE "TABLE_NAME"=%s AND "COLUMN_NAME"=%s',
(table_name.upper(), geo_col.upper())
)
row = cursor.fetchone()
except Exception as msg:
new_msg = (
'Could not find entry in USER_SDO_GEOM_METADATA '
'corresponding to "%s"."%s"\n'
'Error message: %s.') % (table_name, geo_col, msg)
six.reraise(Exception, Exception(new_msg), sys.exc_info()[2])
# TODO: Research way to find a more specific geometry field type for
# the column's contents.
field_type = 'GeometryField'
# Getting the field parameters.
field_params = {}
dim, srid = row
if srid != 4326:
field_params['srid'] = srid
# Length of object array ( SDO_DIM_ARRAY ) is number of dimensions.
dim = len(dim)
if dim != 2:
field_params['dim'] = dim
finally:
cursor.close()
return field_type, field_params
|
bsd-3-clause
|
[
646,
17280,
63,
21202,
199,
646,
984,
199,
504,
1639,
14,
697,
14,
7765,
14,
16404,
14,
21627,
492,
8692,
30516,
199,
504,
1639,
14,
1208,
492,
3816,
421,
199,
533,
15309,
30516,
8,
7243,
30516,
304,
272,
327,
24207,
1958,
1263,
28652,
5550,
5568,
4454,
543,
30490,
14,
221,
24545,
2518,
12,
272,
327,
642,
7859,
1133,
1736,
2451,
641,
15309,
2251,
626,
10621,
1133,
603,
3177,
20238,
14,
24399,
63,
28472,
12,
272,
327,
1325,
652,
365,
314,
1454,
909,
730,
3748,
4453,
5634,
1263,
2885,
14,
272,
666,
63,
1313,
63,
4471,
275,
8692,
30516,
14,
576,
63,
1313,
63,
4471,
14,
1574,
342,
272,
666,
63,
1313,
63,
4471,
59,
11859,
63,
21202,
14,
9868,
61,
275,
283,
6831,
792,
7,
339,
347,
664,
63,
7660,
63,
466,
8,
277,
12,
1817,
63,
354,
12,
8509,
63,
761,
304,
267,
3920,
275,
291,
14,
2105,
14,
3937,
342,
267,
862,
26,
288,
327,
8133,
316,
13044,
63,
24399,
63,
31080,
63,
8314,
370,
664,
314,
22425,
436,
6240,
2556,
14,
288,
862,
26,
355,
3920,
14,
2526,
8,
490,
283,
4859,
298,
19080,
4531,
401,
298,
5943,
998,
2,
4442,
298,
3791,
63,
24399,
63,
31080,
63,
8314,
2,
283,
490,
283,
17688,
298,
8723,
63,
2339,
2,
2458,
83,
2401,
298,
21436,
63,
2339,
2,
2458,
83,
297,
490,
334,
1224,
63,
354,
14,
4142,
1062,
8509,
63,
761,
14,
4142,
1012,
355,
776,
355,
1962,
275,
3920,
14,
11591,
342,
288,
871,
2186,
465,
1499,
26,
355,
892,
63,
1328,
275,
334,
490,
283,
6531,
440,
2342,
2397,
315,
13044,
63,
24399,
63,
31080,
63,
8314,
283,
490,
283,
989,
31137,
370,
2071,
83,
1674,
6808,
83,
3212,
78,
7,
490,
283,
547,
1245,
26,
450,
83,
2659,
450,
334,
1224,
63,
354,
12,
8509,
63,
761,
12,
1499,
9,
355,
3816,
14,
20614,
8,
1726,
12,
2186,
8,
1222,
63,
1328,
395,
984,
14,
2804,
63,
815,
3430,
18,
566,
953,
327,
3254,
26,
26993,
4340,
370,
2342,
282,
1655,
2488,
3400,
901,
730,
367,
288,
327,
314,
2763,
1159,
4072,
14,
288,
901,
63,
466,
275,
283,
6831,
792,
7,
953,
327,
20703,
314,
901,
2633,
14,
288,
901,
63,
1162,
275,
1052,
288,
8134,
12,
15627,
275,
1962,
288,
340,
15627,
1137,
26719,
26,
355,
901,
63,
1162,
459,
10498,
418,
275,
15627,
288,
327,
19893,
402,
909,
1625,
334,
428,
1649,
63,
19080,
63,
12322,
776,
365,
1329,
402,
7365,
14,
288,
8134,
275,
822,
8,
3572,
9,
288,
340,
8134,
1137,
499,
26,
355,
901,
63,
1162,
459,
3572,
418,
275,
8134,
267,
3753,
26,
288,
3920,
14,
1600,
342,
398,
372,
901,
63,
466,
12,
901,
63,
1162,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
17280,
63,
21202,
199,
646,
984,
199,
504,
1639,
14,
697,
14,
7765,
14,
16404,
14,
21627,
492,
8692,
30516,
199,
504,
1639,
14,
1208,
492,
3816,
421,
199,
533,
15309,
30516,
8,
7243,
30516,
304,
272,
327,
24207,
1958,
1263,
28652,
5550,
5568,
4454,
543,
30490,
14,
221,
24545,
2518,
12,
272,
327,
642,
7859,
1133,
1736,
2451,
641,
15309,
2251,
626,
10621,
1133,
603,
3177,
20238,
14,
24399,
63,
28472,
12,
272,
327,
1325,
652,
365,
314,
1454,
909,
730,
3748,
4453,
5634,
1263,
2885,
14,
272,
666,
63,
1313,
63,
4471,
275,
8692,
30516,
14,
576,
63,
1313,
63,
4471,
14,
1574,
342,
272,
666,
63,
1313,
63,
4471,
59,
11859,
63,
21202,
14,
9868,
61,
275,
283,
6831,
792,
7,
339,
347,
664,
63,
7660,
63,
466,
8,
277,
12,
1817,
63,
354,
12,
8509,
63,
761,
304,
267,
3920,
275,
291,
14,
2105,
14,
3937,
342,
267,
862,
26,
288,
327,
8133,
316,
13044,
63,
24399,
63,
31080,
63,
8314,
370,
664,
314,
22425,
436,
6240,
2556,
14,
288,
862,
26,
355,
3920,
14,
2526,
8,
490,
283,
4859,
298,
19080,
4531,
401,
298,
5943,
998,
2,
4442,
298,
3791,
63,
24399,
63,
31080,
63,
8314,
2,
283,
490,
283,
17688,
298,
8723,
63,
2339,
2,
2458,
83,
2401,
298,
21436,
63,
2339,
2,
2458,
83,
297,
490,
334,
1224,
63,
354,
14,
4142,
1062,
8509,
63,
761,
14,
4142,
1012,
355,
776,
355,
1962,
275,
3920,
14,
11591,
342,
288,
871,
2186,
465,
1499,
26,
355,
892,
63,
1328,
275,
334,
490,
283,
6531,
440,
2342,
2397,
315,
13044,
63,
24399,
63,
31080,
63,
8314,
283,
490,
283,
989,
31137,
370,
2071,
83,
1674,
6808,
83,
3212,
78,
7,
490,
283,
547,
1245,
26,
450,
83,
2659,
450,
334,
1224,
63,
354,
12,
8509,
63,
761,
12,
1499,
9,
355,
3816,
14,
20614,
8,
1726,
12,
2186,
8,
1222,
63,
1328,
395,
984,
14,
2804,
63,
815,
3430,
18,
566,
953,
327,
3254,
26,
26993,
4340,
370,
2342,
282,
1655,
2488,
3400,
901,
730,
367,
288,
327,
314,
2763,
1159,
4072,
14,
288,
901,
63,
466,
275,
283,
6831,
792,
7,
953,
327,
20703,
314,
901,
2633,
14,
288,
901,
63,
1162,
275,
1052,
288,
8134,
12,
15627,
275,
1962,
288,
340,
15627,
1137,
26719,
26,
355,
901,
63,
1162,
459,
10498,
418,
275,
15627,
288,
327,
19893,
402,
909,
1625,
334,
428,
1649,
63,
19080,
63,
12322,
776,
365,
1329,
402,
7365,
14,
288,
8134,
275,
822,
8,
3572,
9,
288,
340,
8134,
1137,
499,
26,
355,
901,
63,
1162,
459,
3572,
418,
275,
8134,
267,
3753,
26,
288,
3920,
14,
1600,
342,
398,
372,
901,
63,
466,
12,
901,
63,
1162,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
edcast-inc/edx-platform-edcast
|
common/lib/symmath/symmath/symmath_check.py
|
36
|
12584
|
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# File: symmath_check.py
# Date: 02-May-12 (creation)
#
# Symbolic mathematical expression checker for edX. Uses sympy to check for expression equality.
#
# Takes in math expressions given as Presentation MathML (from ASCIIMathML), converts to Content MathML using SnuggleTeX
import traceback
from .formula import *
import logging
log = logging.getLogger(__name__)
#-----------------------------------------------------------------------------
# check function interface
#
# This is one of the main entry points to call.
def symmath_check_simple(expect, ans, adict={}, symtab=None, extra_options=None):
"""
Check a symbolic mathematical expression using sympy.
The input is an ascii string (not MathML) converted to math using sympy.sympify.
"""
options = {'__MATRIX__': False, '__ABC__': False, '__LOWER__': False}
if extra_options:
options.update(extra_options)
for op in options: # find options in expect string
if op in expect:
expect = expect.replace(op, '')
options[op] = True
expect = expect.replace('__OR__', '__or__') # backwards compatibility
if options['__LOWER__']:
expect = expect.lower()
ans = ans.lower()
try:
ret = check(expect, ans,
matrix=options['__MATRIX__'],
abcsym=options['__ABC__'],
symtab=symtab,
)
except Exception, err:
return {'ok': False,
'msg': 'Error %s<br/>Failed in evaluating check(%s,%s)' % (err, expect, ans)
}
return ret
#-----------------------------------------------------------------------------
# pretty generic checking function
def check(expect, given, numerical=False, matrix=False, normphase=False, abcsym=False, do_qubit=True, symtab=None, dosimplify=False):
"""
Returns dict with
'ok': True if check is good, False otherwise
'msg': response message (in HTML)
"expect" may have multiple possible acceptable answers, separated by "__OR__"
"""
if "__or__" in expect: # if multiple acceptable answers
eset = expect.split('__or__') # then see if any match
for eone in eset:
ret = check(eone, given, numerical, matrix, normphase, abcsym, do_qubit, symtab, dosimplify)
if ret['ok']:
return ret
return ret
flags = {}
if "__autonorm__" in expect:
flags['autonorm'] = True
expect = expect.replace('__autonorm__', '')
matrix = True
threshold = 1.0e-3
if "__threshold__" in expect:
(expect, st) = expect.split('__threshold__')
threshold = float(st)
numerical = True
if str(given) == '' and not (str(expect) == ''):
return {'ok': False, 'msg': ''}
try:
xgiven = my_sympify(given, normphase, matrix, do_qubit=do_qubit, abcsym=abcsym, symtab=symtab)
except Exception, err:
return {'ok': False, 'msg': 'Error %s<br/> in evaluating your expression "%s"' % (err, given)}
try:
xexpect = my_sympify(expect, normphase, matrix, do_qubit=do_qubit, abcsym=abcsym, symtab=symtab)
except Exception, err:
return {'ok': False, 'msg': 'Error %s<br/> in evaluating OUR expression "%s"' % (err, expect)}
if 'autonorm' in flags: # normalize trace of matrices
try:
xgiven /= xgiven.trace()
except Exception, err:
return {'ok': False, 'msg': 'Error %s<br/> in normalizing trace of your expression %s' % (err, to_latex(xgiven))}
try:
xexpect /= xexpect.trace()
except Exception, err:
return {'ok': False, 'msg': 'Error %s<br/> in normalizing trace of OUR expression %s' % (err, to_latex(xexpect))}
msg = 'Your expression was evaluated as ' + to_latex(xgiven)
# msg += '<br/>Expected ' + to_latex(xexpect)
# msg += "<br/>flags=%s" % flags
if matrix and numerical:
xgiven = my_evalf(xgiven, chop=True)
dm = my_evalf(sympy.Matrix(xexpect) - sympy.Matrix(xgiven), chop=True)
msg += " = " + to_latex(xgiven)
if abs(dm.vec().norm().evalf()) < threshold:
return {'ok': True, 'msg': msg}
else:
pass
#msg += "dm = " + to_latex(dm) + " diff = " + str(abs(dm.vec().norm().evalf()))
#msg += "expect = " + to_latex(xexpect)
elif dosimplify:
if (sympy.simplify(xexpect) == sympy.simplify(xgiven)):
return {'ok': True, 'msg': msg}
elif numerical:
if (abs((xexpect - xgiven).evalf(chop=True)) < threshold):
return {'ok': True, 'msg': msg}
elif (xexpect == xgiven):
return {'ok': True, 'msg': msg}
#msg += "<p/>expect='%s', given='%s'" % (expect,given) # debugging
# msg += "<p/> dot test " + to_latex(dot(sympy.Symbol('x'),sympy.Symbol('y')))
return {'ok': False, 'msg': msg}
#-----------------------------------------------------------------------------
# helper function to convert all <p> to <span class='inline-error'>
def make_error_message(msg):
# msg = msg.replace('<p>','<p><span class="inline-error">').replace('</p>','</span></p>')
msg = '<div class="capa_alert">%s</div>' % msg
return msg
def is_within_tolerance(expected, actual, tolerance):
if expected == 0:
return (abs(actual) < tolerance)
else:
return (abs(abs(actual - expected) / expected) < tolerance)
#-----------------------------------------------------------------------------
# Check function interface, which takes pmathml input
#
# This is one of the main entry points to call.
def symmath_check(expect, ans, dynamath=None, options=None, debug=None, xml=None):
"""
Check a symbolic mathematical expression using sympy.
The input may be presentation MathML. Uses formula.
This is the default Symbolic Response checking function
Desc of args:
expect is a sympy string representing the correct answer. It is interpreted
using my_sympify (from formula.py), which reads strings as sympy input
(e.g. 'integrate(x^2, (x,1,2))' would be valid, and evaluate to give 1.5)
ans is student-typed answer. It is expected to be ascii math, but the code
below would support a sympy string.
dynamath is the PMathML string converted by MathJax. It is used if
evaluation with ans is not sufficient.
options is a string with these possible substrings, set as an xml property
of the problem:
-matrix - make a sympy matrix, rather than a list of lists, if possible
-qubit - passed to my_sympify
-imaginary - used in formla, presumably to signal to use i as sqrt(-1)?
-numerical - force numerical comparison.
"""
msg = ''
# msg += '<p/>abname=%s' % abname
# msg += '<p/>adict=%s' % (repr(adict).replace('<','<'))
threshold = 1.0e-3 # for numerical comparison (also with matrices)
DEBUG = debug
if xml is not None:
DEBUG = xml.get('debug', False) # override debug flag using attribute in symbolicmath xml
if DEBUG in ['0', 'False']:
DEBUG = False
# options
do_matrix = 'matrix' in (options or '')
do_qubit = 'qubit' in (options or '')
do_imaginary = 'imaginary' in (options or '')
do_numerical = 'numerical' in (options or '')
# parse expected answer
try:
fexpect = my_sympify(str(expect), matrix=do_matrix, do_qubit=do_qubit)
except Exception, err:
msg += '<p>Error %s in parsing OUR expected answer "%s"</p>' % (err, expect)
return {'ok': False, 'msg': make_error_message(msg)}
###### Sympy input #######
# if expected answer is a number, try parsing provided answer as a number also
try:
fans = my_sympify(str(ans), matrix=do_matrix, do_qubit=do_qubit)
except Exception, err:
fans = None
# do a numerical comparison if both expected and answer are numbers
if hasattr(fexpect, 'is_number') and fexpect.is_number \
and hasattr(fans, 'is_number') and fans.is_number:
if is_within_tolerance(fexpect, fans, threshold):
return {'ok': True, 'msg': msg}
else:
msg += '<p>You entered: %s</p>' % to_latex(fans)
return {'ok': False, 'msg': msg}
if do_numerical: # numerical answer expected - force numerical comparison
if is_within_tolerance(fexpect, fans, threshold):
return {'ok': True, 'msg': msg}
else:
msg += '<p>You entered: %s (note that a numerical answer is expected)</p>' % to_latex(fans)
return {'ok': False, 'msg': msg}
if fexpect == fans:
msg += '<p>You entered: %s</p>' % to_latex(fans)
return {'ok': True, 'msg': msg}
###### PMathML input ######
# convert mathml answer to formula
try:
mmlans = dynamath[0] if dynamath else None
except Exception, err:
mmlans = None
if not mmlans:
return {'ok': False, 'msg': '[symmath_check] failed to get MathML for input; dynamath=%s' % dynamath}
f = formula(mmlans, options=options)
# get sympy representation of the formula
# if DEBUG: msg += '<p/> mmlans=%s' % repr(mmlans).replace('<','<')
try:
fsym = f.sympy
msg += '<p>You entered: %s</p>' % to_latex(f.sympy)
except Exception, err:
log.exception("Error evaluating expression '%s' as a valid equation" % ans)
msg += "<p>Error in evaluating your expression '%s' as a valid equation</p>" % (ans)
if "Illegal math" in str(err):
msg += "<p>Illegal math expression</p>"
if DEBUG:
msg += 'Error: %s' % str(err).replace('<', '<')
msg += '<hr>'
msg += '<p><font color="blue">DEBUG messages:</p>'
msg += "<p><pre>%s</pre></p>" % traceback.format_exc()
msg += '<p>cmathml=<pre>%s</pre></p>' % f.cmathml.replace('<', '<')
msg += '<p>pmathml=<pre>%s</pre></p>' % mmlans.replace('<', '<')
msg += '<hr>'
return {'ok': False, 'msg': make_error_message(msg)}
# do numerical comparison with expected
if hasattr(fexpect, 'is_number') and fexpect.is_number:
if hasattr(fsym, 'is_number') and fsym.is_number:
if abs(abs(fsym - fexpect) / fexpect) < threshold:
return {'ok': True, 'msg': msg}
return {'ok': False, 'msg': msg}
msg += "<p>Expecting a numerical answer!</p>"
msg += "<p>given = %s</p>" % repr(ans)
msg += "<p>fsym = %s</p>" % repr(fsym)
# msg += "<p>cmathml = <pre>%s</pre></p>" % str(f.cmathml).replace('<','<')
return {'ok': False, 'msg': make_error_message(msg)}
# Here is a good spot for adding calls to X.simplify() or X.expand(),
# allowing equivalence over binomial expansion or trig identities
# exactly the same?
if fexpect == fsym:
return {'ok': True, 'msg': msg}
if isinstance(fexpect, list):
try:
xgiven = my_evalf(fsym, chop=True)
dm = my_evalf(sympy.Matrix(fexpect) - sympy.Matrix(xgiven), chop=True)
if abs(dm.vec().norm().evalf()) < threshold:
return {'ok': True, 'msg': msg}
except sympy.ShapeError:
msg += "<p>Error - your input vector or matrix has the wrong dimensions"
return {'ok': False, 'msg': make_error_message(msg)}
except Exception, err:
msg += "<p>Error %s in comparing expected (a list) and your answer</p>" % str(err).replace('<', '<')
if DEBUG:
msg += "<p/><pre>%s</pre>" % traceback.format_exc()
return {'ok': False, 'msg': make_error_message(msg)}
#diff = (fexpect-fsym).simplify()
#fsym = fsym.simplify()
#fexpect = fexpect.simplify()
try:
diff = (fexpect - fsym)
except Exception, err:
diff = None
if DEBUG:
msg += '<hr>'
msg += '<p><font color="blue">DEBUG messages:</p>'
msg += "<p>Got: %s</p>" % repr(fsym)
# msg += "<p/>Got: %s" % str([type(x) for x in fsym.atoms()]).replace('<','<')
msg += "<p>Expecting: %s</p>" % repr(fexpect).replace('**', '^').replace('hat(I)', 'hat(i)')
# msg += "<p/>Expecting: %s" % str([type(x) for x in fexpect.atoms()]).replace('<','<')
if diff:
msg += "<p>Difference: %s</p>" % to_latex(diff)
msg += '<hr>'
# Used to return more keys: 'ex': fexpect, 'got': fsym
return {'ok': False, 'msg': msg}
|
agpl-3.0
|
[
3381,
2647,
15,
1393,
15,
1548,
199,
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
199,
3,
3814,
26,
257,
4678,
3442,
63,
1074,
14,
647,
199,
3,
6148,
26,
257,
12497,
13,
15586,
13,
713,
334,
8782,
9,
199,
3,
199,
3,
21478,
9670,
610,
28491,
3965,
7739,
367,
3988,
56,
14,
221,
14911,
5840,
370,
1104,
367,
3965,
16612,
14,
199,
3,
199,
3,
17415,
315,
3473,
8455,
1627,
465,
5543,
1150,
425,
21066,
1698,
334,
504,
4319,
3553,
1469,
1619,
1698,
395,
15373,
370,
6646,
21066,
1698,
1808,
428,
78,
1518,
3845,
12589,
199,
199,
646,
5190,
199,
504,
1275,
16798,
492,
627,
199,
646,
2050,
199,
199,
793,
275,
2050,
14,
5572,
3460,
354,
3368,
199,
199,
18045,
199,
3,
1104,
805,
3217,
199,
3,
199,
3,
961,
365,
1373,
402,
314,
2446,
2397,
4501,
370,
1240,
14,
421,
199,
318,
4678,
3442,
63,
1074,
63,
4129,
8,
4921,
12,
4987,
12,
282,
807,
10324,
1847,
2037,
371,
29,
403,
12,
2402,
63,
1419,
29,
403,
304,
272,
408,
272,
2670,
282,
13673,
610,
28491,
3965,
1808,
5840,
14,
272,
710,
1324,
365,
376,
13294,
1059,
334,
1397,
21066,
1698,
9,
6702,
370,
3473,
1808,
5840,
14,
1786,
18456,
14,
272,
408,
339,
1511,
275,
791,
363,
23483,
3706,
756,
12,
2560,
8390,
3706,
756,
12,
2560,
5896,
540,
3706,
756,
93,
272,
340,
2402,
63,
1419,
26,
267,
1511,
14,
873,
8,
2911,
63,
1419,
9,
272,
367,
1687,
315,
1511,
26,
9622,
198,
3,
2342,
1511,
315,
4282,
1059,
267,
340,
1687,
315,
4282,
26,
288,
4282,
275,
4282,
14,
1814,
8,
411,
12,
4074,
288,
1511,
59,
411,
61,
275,
715,
272,
4282,
275,
4282,
14,
1814,
10714,
726,
7500,
2560,
269,
13766,
198,
327,
8552,
7163,
339,
340,
1511,
13742,
5896,
540,
363,
2565,
267,
4282,
275,
4282,
14,
2325,
342,
267,
4987,
275,
4987,
14,
2325,
342,
339,
862,
26,
267,
2203,
275,
1104,
8,
4921,
12,
4987,
12,
490,
3634,
29,
1419,
13742,
23483,
363,
995,
490,
2236,
1259,
12828,
29,
1419,
13742,
8390,
363,
995,
490,
1847,
2037,
371,
29,
1786,
2037,
371,
12,
490,
776,
272,
871,
2186,
12,
2329,
26,
267,
372,
791,
745,
356,
756,
12,
355,
283,
1328,
356,
283,
547,
450,
83,
28,
3289,
3133,
4276,
315,
27083,
1104,
4042,
83,
8719,
83,
3171,
450,
334,
1508,
12,
4282,
12,
4987,
9,
355,
789,
272,
372,
2203,
199,
199,
18045,
199,
3,
7268,
7809,
7907,
805,
421,
199,
318,
1104,
8,
4921,
12,
1627,
12,
15470,
29,
797,
12,
3634,
29,
797,
12,
6590,
311,
72,
482,
29,
797,
12,
2236,
1259,
12828,
29,
797,
12,
886,
63,
392,
2075,
29,
549,
12,
1847,
2037,
371,
29,
403,
12,
886,
19084,
29,
797,
304,
272,
408,
272,
1803,
1211,
543,
2541,
283,
745,
356,
715,
340,
1104,
365,
6954,
12,
756,
4257,
489,
283,
1328,
356,
1177,
1245,
334,
262,
4163,
9,
339,
298,
4921,
2,
1443,
1172,
3663,
3962,
14712,
17133,
12,
11673,
701,
4396,
726,
16526,
339,
408,
339,
340,
4396,
269,
16526,
315,
4282,
26,
1057,
198,
3,
340,
3663,
14712,
17133,
267,
325,
409,
275,
4282,
14,
1294,
10714,
269,
13766,
198,
198,
3,
2066,
1937,
340,
1263,
1336,
267,
367,
325,
368,
315,
325,
409,
26,
288,
2203,
275,
1104,
8,
69,
368,
12,
1627,
12,
15470,
12,
3634,
12,
6590,
311,
72,
482,
12,
2236,
1259,
12828,
12,
886,
63,
392,
2075,
12,
1847,
2037,
371,
12,
886,
19084,
9,
288,
340,
2203,
459,
745,
2565,
355,
372,
2203,
267,
372,
2203,
339,
3285,
275,
1052,
272,
340,
4396,
6898,
265,
1025,
16526,
315,
4282,
26,
267,
3285,
459,
6898,
265,
1025,
418,
275,
715,
267,
4282,
275,
4282,
14,
1814,
10714,
6898,
265,
1025,
7500,
4074,
267,
3634,
275,
715,
339,
8765,
275,
413,
14,
16,
69,
13,
19,
272,
340,
4396,
7227,
16526,
315,
4282,
26,
267,
334,
4921,
12,
410,
9,
275,
4282,
14,
1294,
10714,
7227,
13766,
267,
8765,
275,
2069,
8,
270,
9,
267,
15470,
275,
715,
339,
340,
620,
8,
11809,
9,
508,
2125,
436,
440,
334,
495,
8,
4921,
9,
508,
21019,
267,
372,
791,
745,
356,
756,
12,
283,
1328,
356,
28174,
339,
862,
26,
267,
671,
11809,
275,
3002,
63,
1786,
18456,
8,
11809,
12,
6590,
311,
72,
482,
12,
3634,
12,
886,
63,
392,
2075,
29,
1117,
63,
392,
2075,
12,
2236,
1259,
12828,
29,
371,
1259,
12828,
12,
1847,
2037,
371,
29,
1786,
2037,
371,
9,
272,
871,
2186,
12,
2329,
26,
267,
372,
791,
745,
356,
756,
12,
283,
1328,
356,
283,
547,
450,
83,
28,
3289,
3133,
315,
27083,
2195,
3965,
2071,
83,
4507,
450,
334,
1508,
12,
1627,
6769,
339,
862,
26,
267,
671,
4921,
275,
3002,
63,
1786,
18456,
8,
4921,
12,
6590,
311,
72,
482,
12,
3634,
12,
886,
63,
392,
2075,
29,
1117,
63,
392,
2075,
12,
2236,
1259,
12828,
29,
371,
1259,
12828,
12,
1847,
2037,
371,
29,
1786,
2037,
371,
9,
272,
871,
2186,
12,
2329,
26,
267,
372,
791,
745,
356,
756,
12,
283,
1328,
356,
283,
547,
450,
83,
28,
3289,
3133,
315,
27083,
593,
1230,
3965,
2071,
83,
4507,
450,
334,
1508,
12,
4282,
6769,
339,
340,
283,
6898,
265,
1025,
7,
315,
3285,
26,
198,
327,
7666,
3307,
402,
12627,
267,
862,
26,
288,
671,
11809,
12257,
671,
11809,
14,
3446,
342,
267,
871,
2186,
12,
2329,
26,
288,
372,
791,
745,
356,
756,
12,
283,
1328,
356,
283,
547,
450,
83,
28,
3289,
3133,
315,
3293,
9147,
3307,
402,
2195,
3965,
450,
83,
7,
450,
334,
1508,
12,
370,
63,
7572,
8,
88,
11809,
430,
93,
267,
862,
26,
288,
671,
4921,
12257,
671,
4921,
14,
3446,
342,
267,
871,
2186,
12,
2329,
26,
288,
372,
791,
745,
356,
756,
12,
283,
1328,
356,
283,
547,
450,
83,
28,
3289,
3133,
315,
3293,
9147,
3307,
402,
593,
1230,
3965,
450,
83,
7,
450,
334,
1508,
12,
370,
63,
7572,
8,
88,
4921,
430,
93,
339,
1499,
275,
283,
14398,
3965,
1990,
13006,
465,
283,
435,
370,
63,
7572,
8,
88,
11809,
9,
272,
327,
1499,
847
] |
[
2647,
15,
1393,
15,
1548,
199,
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
199,
3,
3814,
26,
257,
4678,
3442,
63,
1074,
14,
647,
199,
3,
6148,
26,
257,
12497,
13,
15586,
13,
713,
334,
8782,
9,
199,
3,
199,
3,
21478,
9670,
610,
28491,
3965,
7739,
367,
3988,
56,
14,
221,
14911,
5840,
370,
1104,
367,
3965,
16612,
14,
199,
3,
199,
3,
17415,
315,
3473,
8455,
1627,
465,
5543,
1150,
425,
21066,
1698,
334,
504,
4319,
3553,
1469,
1619,
1698,
395,
15373,
370,
6646,
21066,
1698,
1808,
428,
78,
1518,
3845,
12589,
199,
199,
646,
5190,
199,
504,
1275,
16798,
492,
627,
199,
646,
2050,
199,
199,
793,
275,
2050,
14,
5572,
3460,
354,
3368,
199,
199,
18045,
199,
3,
1104,
805,
3217,
199,
3,
199,
3,
961,
365,
1373,
402,
314,
2446,
2397,
4501,
370,
1240,
14,
421,
199,
318,
4678,
3442,
63,
1074,
63,
4129,
8,
4921,
12,
4987,
12,
282,
807,
10324,
1847,
2037,
371,
29,
403,
12,
2402,
63,
1419,
29,
403,
304,
272,
408,
272,
2670,
282,
13673,
610,
28491,
3965,
1808,
5840,
14,
272,
710,
1324,
365,
376,
13294,
1059,
334,
1397,
21066,
1698,
9,
6702,
370,
3473,
1808,
5840,
14,
1786,
18456,
14,
272,
408,
339,
1511,
275,
791,
363,
23483,
3706,
756,
12,
2560,
8390,
3706,
756,
12,
2560,
5896,
540,
3706,
756,
93,
272,
340,
2402,
63,
1419,
26,
267,
1511,
14,
873,
8,
2911,
63,
1419,
9,
272,
367,
1687,
315,
1511,
26,
9622,
198,
3,
2342,
1511,
315,
4282,
1059,
267,
340,
1687,
315,
4282,
26,
288,
4282,
275,
4282,
14,
1814,
8,
411,
12,
4074,
288,
1511,
59,
411,
61,
275,
715,
272,
4282,
275,
4282,
14,
1814,
10714,
726,
7500,
2560,
269,
13766,
198,
327,
8552,
7163,
339,
340,
1511,
13742,
5896,
540,
363,
2565,
267,
4282,
275,
4282,
14,
2325,
342,
267,
4987,
275,
4987,
14,
2325,
342,
339,
862,
26,
267,
2203,
275,
1104,
8,
4921,
12,
4987,
12,
490,
3634,
29,
1419,
13742,
23483,
363,
995,
490,
2236,
1259,
12828,
29,
1419,
13742,
8390,
363,
995,
490,
1847,
2037,
371,
29,
1786,
2037,
371,
12,
490,
776,
272,
871,
2186,
12,
2329,
26,
267,
372,
791,
745,
356,
756,
12,
355,
283,
1328,
356,
283,
547,
450,
83,
28,
3289,
3133,
4276,
315,
27083,
1104,
4042,
83,
8719,
83,
3171,
450,
334,
1508,
12,
4282,
12,
4987,
9,
355,
789,
272,
372,
2203,
199,
199,
18045,
199,
3,
7268,
7809,
7907,
805,
421,
199,
318,
1104,
8,
4921,
12,
1627,
12,
15470,
29,
797,
12,
3634,
29,
797,
12,
6590,
311,
72,
482,
29,
797,
12,
2236,
1259,
12828,
29,
797,
12,
886,
63,
392,
2075,
29,
549,
12,
1847,
2037,
371,
29,
403,
12,
886,
19084,
29,
797,
304,
272,
408,
272,
1803,
1211,
543,
2541,
283,
745,
356,
715,
340,
1104,
365,
6954,
12,
756,
4257,
489,
283,
1328,
356,
1177,
1245,
334,
262,
4163,
9,
339,
298,
4921,
2,
1443,
1172,
3663,
3962,
14712,
17133,
12,
11673,
701,
4396,
726,
16526,
339,
408,
339,
340,
4396,
269,
16526,
315,
4282,
26,
1057,
198,
3,
340,
3663,
14712,
17133,
267,
325,
409,
275,
4282,
14,
1294,
10714,
269,
13766,
198,
198,
3,
2066,
1937,
340,
1263,
1336,
267,
367,
325,
368,
315,
325,
409,
26,
288,
2203,
275,
1104,
8,
69,
368,
12,
1627,
12,
15470,
12,
3634,
12,
6590,
311,
72,
482,
12,
2236,
1259,
12828,
12,
886,
63,
392,
2075,
12,
1847,
2037,
371,
12,
886,
19084,
9,
288,
340,
2203,
459,
745,
2565,
355,
372,
2203,
267,
372,
2203,
339,
3285,
275,
1052,
272,
340,
4396,
6898,
265,
1025,
16526,
315,
4282,
26,
267,
3285,
459,
6898,
265,
1025,
418,
275,
715,
267,
4282,
275,
4282,
14,
1814,
10714,
6898,
265,
1025,
7500,
4074,
267,
3634,
275,
715,
339,
8765,
275,
413,
14,
16,
69,
13,
19,
272,
340,
4396,
7227,
16526,
315,
4282,
26,
267,
334,
4921,
12,
410,
9,
275,
4282,
14,
1294,
10714,
7227,
13766,
267,
8765,
275,
2069,
8,
270,
9,
267,
15470,
275,
715,
339,
340,
620,
8,
11809,
9,
508,
2125,
436,
440,
334,
495,
8,
4921,
9,
508,
21019,
267,
372,
791,
745,
356,
756,
12,
283,
1328,
356,
28174,
339,
862,
26,
267,
671,
11809,
275,
3002,
63,
1786,
18456,
8,
11809,
12,
6590,
311,
72,
482,
12,
3634,
12,
886,
63,
392,
2075,
29,
1117,
63,
392,
2075,
12,
2236,
1259,
12828,
29,
371,
1259,
12828,
12,
1847,
2037,
371,
29,
1786,
2037,
371,
9,
272,
871,
2186,
12,
2329,
26,
267,
372,
791,
745,
356,
756,
12,
283,
1328,
356,
283,
547,
450,
83,
28,
3289,
3133,
315,
27083,
2195,
3965,
2071,
83,
4507,
450,
334,
1508,
12,
1627,
6769,
339,
862,
26,
267,
671,
4921,
275,
3002,
63,
1786,
18456,
8,
4921,
12,
6590,
311,
72,
482,
12,
3634,
12,
886,
63,
392,
2075,
29,
1117,
63,
392,
2075,
12,
2236,
1259,
12828,
29,
371,
1259,
12828,
12,
1847,
2037,
371,
29,
1786,
2037,
371,
9,
272,
871,
2186,
12,
2329,
26,
267,
372,
791,
745,
356,
756,
12,
283,
1328,
356,
283,
547,
450,
83,
28,
3289,
3133,
315,
27083,
593,
1230,
3965,
2071,
83,
4507,
450,
334,
1508,
12,
4282,
6769,
339,
340,
283,
6898,
265,
1025,
7,
315,
3285,
26,
198,
327,
7666,
3307,
402,
12627,
267,
862,
26,
288,
671,
11809,
12257,
671,
11809,
14,
3446,
342,
267,
871,
2186,
12,
2329,
26,
288,
372,
791,
745,
356,
756,
12,
283,
1328,
356,
283,
547,
450,
83,
28,
3289,
3133,
315,
3293,
9147,
3307,
402,
2195,
3965,
450,
83,
7,
450,
334,
1508,
12,
370,
63,
7572,
8,
88,
11809,
430,
93,
267,
862,
26,
288,
671,
4921,
12257,
671,
4921,
14,
3446,
342,
267,
871,
2186,
12,
2329,
26,
288,
372,
791,
745,
356,
756,
12,
283,
1328,
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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
] |
ingmar-k/2.6.31.14_OXNAS_kernel
|
scripts/tracing/draw_functrace.py
|
14676
|
3560
|
#!/usr/bin/python
"""
Copyright 2008 (c) Frederic Weisbecker <fweisbec@gmail.com>
Licensed under the terms of the GNU GPL License version 2
This script parses a trace provided by the function tracer in
kernel/trace/trace_functions.c
The resulted trace is processed into a tree to produce a more human
view of the call stack by drawing textual but hierarchical tree of
calls. Only the functions's names and the the call time are provided.
Usage:
Be sure that you have CONFIG_FUNCTION_TRACER
# mount -t debugfs nodev /sys/kernel/debug
# echo function > /sys/kernel/debug/tracing/current_tracer
$ cat /sys/kernel/debug/tracing/trace_pipe > ~/raw_trace_func
Wait some times but not too much, the script is a bit slow.
Break the pipe (Ctrl + Z)
$ scripts/draw_functrace.py < raw_trace_func > draw_functrace
Then you have your drawn trace in draw_functrace
"""
import sys, re
class CallTree:
""" This class provides a tree representation of the functions
call stack. If a function has no parent in the kernel (interrupt,
syscall, kernel thread...) then it is attached to a virtual parent
called ROOT.
"""
ROOT = None
def __init__(self, func, time = None, parent = None):
self._func = func
self._time = time
if parent is None:
self._parent = CallTree.ROOT
else:
self._parent = parent
self._children = []
def calls(self, func, calltime):
""" If a function calls another one, call this method to insert it
into the tree at the appropriate place.
@return: A reference to the newly created child node.
"""
child = CallTree(func, calltime, self)
self._children.append(child)
return child
def getParent(self, func):
""" Retrieve the last parent of the current node that
has the name given by func. If this function is not
on a parent, then create it as new child of root
@return: A reference to the parent.
"""
tree = self
while tree != CallTree.ROOT and tree._func != func:
tree = tree._parent
if tree == CallTree.ROOT:
child = CallTree.ROOT.calls(func, None)
return child
return tree
def __repr__(self):
return self.__toString("", True)
def __toString(self, branch, lastChild):
if self._time is not None:
s = "%s----%s (%s)\n" % (branch, self._func, self._time)
else:
s = "%s----%s\n" % (branch, self._func)
i = 0
if lastChild:
branch = branch[:-1] + " "
while i < len(self._children):
if i != len(self._children) - 1:
s += "%s" % self._children[i].__toString(branch +\
" |", False)
else:
s += "%s" % self._children[i].__toString(branch +\
" |", True)
i += 1
return s
class BrokenLineException(Exception):
"""If the last line is not complete because of the pipe breakage,
we want to stop the processing and ignore this line.
"""
pass
class CommentLineException(Exception):
""" If the line is a comment (as in the beginning of the trace file),
just ignore it.
"""
pass
def parseLine(line):
line = line.strip()
if line.startswith("#"):
raise CommentLineException
m = re.match("[^]]+?\\] +([0-9.]+): (\\w+) <-(\\w+)", line)
if m is None:
raise BrokenLineException
return (m.group(1), m.group(2), m.group(3))
def main():
CallTree.ROOT = CallTree("Root (Nowhere)", None, None)
tree = CallTree.ROOT
for line in sys.stdin:
try:
calltime, callee, caller = parseLine(line)
except BrokenLineException:
break
except CommentLineException:
continue
tree = tree.getParent(caller)
tree = tree.calls(callee, calltime)
print CallTree.ROOT
if __name__ == "__main__":
main()
|
gpl-2.0
|
[
3381,
2647,
15,
1393,
15,
1548,
199,
199,
624,
199,
7384,
9079,
334,
67,
9,
481,
21919,
1567,
2136,
374,
1235,
22043,
665,
70,
1129,
374,
24554,
32,
6799,
14,
957,
30,
199,
31661,
1334,
314,
2895,
402,
314,
1664,
14629,
844,
1015,
499,
199,
199,
2765,
2884,
19953,
282,
3307,
2741,
701,
314,
805,
29140,
315,
199,
4989,
15,
3446,
15,
3446,
63,
5777,
14,
67,
199,
1918,
522,
30355,
3307,
365,
7686,
1901,
282,
3123,
370,
7389,
282,
1655,
11779,
199,
1345,
402,
314,
1240,
3464,
701,
17455,
25884,
1325,
24787,
3123,
402,
199,
5352,
14,
5972,
314,
3423,
1159,
1561,
436,
314,
314,
1240,
900,
787,
2741,
14,
199,
199,
7692,
26,
199,
198,
3655,
3238,
626,
1265,
1172,
15869,
63,
15476,
63,
1766,
1348,
540,
199,
198,
3,
10760,
446,
84,
3105,
2319,
1031,
86,
1182,
1274,
15,
4989,
15,
1757,
199,
198,
3,
11343,
805,
690,
1182,
1274,
15,
4989,
15,
1757,
15,
21635,
15,
1818,
63,
16825,
199,
198,
4,
6230,
1182,
1274,
15,
4989,
15,
1757,
15,
21635,
15,
3446,
63,
4990,
690,
6146,
15,
1773,
63,
3446,
63,
1532,
199,
198,
7536,
2005,
5431,
1325,
440,
4634,
8298,
12,
314,
2884,
365,
282,
4546,
11999,
14,
199,
198,
13948,
314,
5200,
334,
9778,
435,
3107,
9,
199,
198,
4,
10554,
15,
5485,
63,
31939,
5986,
14,
647,
665,
3066,
63,
3446,
63,
1532,
690,
5954,
63,
31939,
5986,
199,
198,
28226,
1265,
1172,
2195,
19341,
3307,
315,
5954,
63,
31939,
5986,
199,
624,
421,
199,
646,
984,
12,
295,
199,
199,
533,
23491,
26,
199,
198,
624,
961,
1021,
6571,
282,
3123,
6025,
402,
314,
3423,
507,
198,
1250,
3464,
14,
982,
282,
805,
965,
949,
1676,
315,
314,
5114,
334,
20172,
12,
507,
198,
19444,
12,
5114,
2462,
11965,
2066,
652,
365,
10102,
370,
282,
5791,
1676,
507,
198,
3527,
16547,
14,
199,
198,
624,
199,
198,
5441,
275,
488,
421,
198,
318,
636,
826,
721,
277,
12,
2562,
12,
900,
275,
488,
12,
1676,
275,
488,
304,
507,
198,
277,
423,
1532,
275,
2562,
507,
198,
277,
423,
521,
275,
900,
507,
198,
692,
1676,
365,
488,
26,
686,
198,
277,
423,
1708,
275,
23491,
14,
5441,
507,
198,
2836,
26,
686,
198,
277,
423,
1708,
275,
1676,
507,
198,
277,
423,
3223,
275,
942,
421,
198,
318,
4882,
8,
277,
12,
2562,
12,
1240,
521,
304,
507,
198,
624,
982,
282,
805,
4882,
4573,
1373,
12,
1240,
642,
1083,
370,
5518,
652,
686,
198,
9924,
314,
3123,
737,
314,
5827,
4192,
14,
686,
198,
32,
1107,
26,
437,
3659,
370,
314,
13903,
2737,
1982,
1031,
14,
507,
198,
624,
507,
198,
1739,
275,
23491,
8,
1532,
12,
1240,
521,
12,
291,
9,
507,
198,
277,
423,
3223,
14,
740,
8,
1739,
9,
507,
198,
1107,
1982,
421,
198,
318,
664,
6652,
8,
277,
12,
2562,
304,
507,
198,
624,
13939,
314,
2061,
1676,
402,
314,
1453,
1031,
626,
686,
198,
1989,
314,
536,
1627,
701,
2562,
14,
982,
642,
805,
365,
440,
686,
198,
265,
282,
1676,
12,
2066,
1218,
652,
465,
892,
1982,
402,
1738,
686,
198,
32,
1107,
26,
437,
3659,
370,
314,
1676,
14,
507,
198,
624,
507,
198,
2350,
275,
291,
507,
198,
6710,
3123,
1137,
23491,
14,
5441,
436,
3123,
423,
1532,
1137,
2562,
26,
686,
198,
2350,
275,
3123,
423,
1708,
507,
198,
692,
3123,
508,
23491,
14,
5441,
26,
686,
198,
1739,
275,
23491,
14,
5441,
14,
5352,
8,
1532,
12,
488,
9,
686,
198,
1107,
1982,
507,
198,
1107,
3123,
421,
198,
318,
636,
2722,
721,
277,
304,
507,
198,
1107,
291,
855,
16695,
12398,
715,
9,
421,
198,
318,
636,
16695,
8,
277,
12,
5246,
12,
2061,
3493,
304,
507,
198,
692,
291,
423,
521,
365,
440,
488,
26,
686,
198,
83,
275,
2071,
83,
375,
5,
83,
4366,
83,
2862,
78,
2,
450,
334,
4694,
12,
291,
423,
1532,
12,
291,
423,
521,
9,
507,
198,
2836,
26,
686,
198,
83,
275,
2071,
83,
375,
5,
83,
60,
78,
2,
450,
334,
4694,
12,
291,
423,
1532,
9,
2742,
198,
73,
275,
378,
507,
198,
692,
2061,
3493,
26,
686,
198,
4694,
275,
5246,
4439,
17,
61,
435,
298,
298,
507,
198,
6710,
284,
665,
822,
8,
277,
423,
3223,
304,
686,
198,
692,
284,
1137,
822,
8,
277,
423,
3223,
9,
446,
413,
26,
1585,
198,
83,
847,
2071,
83,
2,
450,
291,
423,
3223,
59,
73,
17979,
16695,
8,
4694,
17992,
11674,
198,
2,
259,
1204,
401,
756,
9,
686,
198,
2836,
26,
1585,
198,
83,
847,
2071,
83,
2,
450,
291,
423,
3223,
59,
73,
17979,
16695,
8,
4694,
17992,
11674,
198,
2,
259,
1204,
401,
715,
9,
686,
198,
73,
847,
413,
507,
198,
1107,
308,
199,
199,
533,
23804,
29969,
8,
1726,
304,
199,
198,
624,
3917,
314,
2061,
1004,
365,
440,
4890,
2952,
402,
314,
5200,
2059,
474,
12,
21979,
781,
2934,
370,
3631,
314,
6661,
436,
3686,
642,
1004,
14,
199,
198,
624,
199,
198,
1529,
199,
199,
533,
6819,
29969,
8,
1726,
304,
199,
198,
624,
982,
314,
1004,
365,
282,
3721,
334,
305,
315,
314,
9608,
402,
314,
3307,
570,
395,
6722,
2951,
3686,
652,
14,
199,
198,
624,
199,
198,
1529,
421,
199,
318,
2198,
3049,
8,
604,
304,
199,
198,
604,
275,
1004,
14,
1913,
342,
199,
198,
692,
1004,
14,
2460,
10064,
2349,
507,
198,
3730,
6819,
29969,
199,
198,
77,
275,
295,
14,
1431,
480,
4735,
2677,
23778,
1103,
61,
435,
779,
16,
13,
25,
32455,
304,
334,
1103,
87,
8771,
665,
15426,
1103,
87,
11,
4186,
1004,
9,
199,
198,
692,
333,
365,
488,
26,
507,
198,
3730,
23804,
29969,
199,
198,
1107,
334,
77,
14,
923,
8,
17,
395,
333,
14,
923,
8,
18,
395,
333,
14,
923,
8,
19,
430,
421,
199,
318,
2446,
837,
199,
198,
2176,
3987,
14,
5441,
275,
23491,
480,
6405,
334,
14351,
1681,
4186,
488,
12,
488,
9,
199,
198,
2350,
275,
23491,
14,
5441,
421,
198,
509,
1004,
315,
984,
14,
6626,
26,
507,
198,
893,
26,
686,
198,
1250,
521,
12,
3213,
18387,
12,
8025,
275,
2198,
3049,
8,
604
] |
[
2647,
15,
1393,
15,
1548,
199,
199,
624,
199,
7384,
9079,
334,
67,
9,
481,
21919,
1567,
2136,
374,
1235,
22043,
665,
70,
1129,
374,
24554,
32,
6799,
14,
957,
30,
199,
31661,
1334,
314,
2895,
402,
314,
1664,
14629,
844,
1015,
499,
199,
199,
2765,
2884,
19953,
282,
3307,
2741,
701,
314,
805,
29140,
315,
199,
4989,
15,
3446,
15,
3446,
63,
5777,
14,
67,
199,
1918,
522,
30355,
3307,
365,
7686,
1901,
282,
3123,
370,
7389,
282,
1655,
11779,
199,
1345,
402,
314,
1240,
3464,
701,
17455,
25884,
1325,
24787,
3123,
402,
199,
5352,
14,
5972,
314,
3423,
1159,
1561,
436,
314,
314,
1240,
900,
787,
2741,
14,
199,
199,
7692,
26,
199,
198,
3655,
3238,
626,
1265,
1172,
15869,
63,
15476,
63,
1766,
1348,
540,
199,
198,
3,
10760,
446,
84,
3105,
2319,
1031,
86,
1182,
1274,
15,
4989,
15,
1757,
199,
198,
3,
11343,
805,
690,
1182,
1274,
15,
4989,
15,
1757,
15,
21635,
15,
1818,
63,
16825,
199,
198,
4,
6230,
1182,
1274,
15,
4989,
15,
1757,
15,
21635,
15,
3446,
63,
4990,
690,
6146,
15,
1773,
63,
3446,
63,
1532,
199,
198,
7536,
2005,
5431,
1325,
440,
4634,
8298,
12,
314,
2884,
365,
282,
4546,
11999,
14,
199,
198,
13948,
314,
5200,
334,
9778,
435,
3107,
9,
199,
198,
4,
10554,
15,
5485,
63,
31939,
5986,
14,
647,
665,
3066,
63,
3446,
63,
1532,
690,
5954,
63,
31939,
5986,
199,
198,
28226,
1265,
1172,
2195,
19341,
3307,
315,
5954,
63,
31939,
5986,
199,
624,
421,
199,
646,
984,
12,
295,
199,
199,
533,
23491,
26,
199,
198,
624,
961,
1021,
6571,
282,
3123,
6025,
402,
314,
3423,
507,
198,
1250,
3464,
14,
982,
282,
805,
965,
949,
1676,
315,
314,
5114,
334,
20172,
12,
507,
198,
19444,
12,
5114,
2462,
11965,
2066,
652,
365,
10102,
370,
282,
5791,
1676,
507,
198,
3527,
16547,
14,
199,
198,
624,
199,
198,
5441,
275,
488,
421,
198,
318,
636,
826,
721,
277,
12,
2562,
12,
900,
275,
488,
12,
1676,
275,
488,
304,
507,
198,
277,
423,
1532,
275,
2562,
507,
198,
277,
423,
521,
275,
900,
507,
198,
692,
1676,
365,
488,
26,
686,
198,
277,
423,
1708,
275,
23491,
14,
5441,
507,
198,
2836,
26,
686,
198,
277,
423,
1708,
275,
1676,
507,
198,
277,
423,
3223,
275,
942,
421,
198,
318,
4882,
8,
277,
12,
2562,
12,
1240,
521,
304,
507,
198,
624,
982,
282,
805,
4882,
4573,
1373,
12,
1240,
642,
1083,
370,
5518,
652,
686,
198,
9924,
314,
3123,
737,
314,
5827,
4192,
14,
686,
198,
32,
1107,
26,
437,
3659,
370,
314,
13903,
2737,
1982,
1031,
14,
507,
198,
624,
507,
198,
1739,
275,
23491,
8,
1532,
12,
1240,
521,
12,
291,
9,
507,
198,
277,
423,
3223,
14,
740,
8,
1739,
9,
507,
198,
1107,
1982,
421,
198,
318,
664,
6652,
8,
277,
12,
2562,
304,
507,
198,
624,
13939,
314,
2061,
1676,
402,
314,
1453,
1031,
626,
686,
198,
1989,
314,
536,
1627,
701,
2562,
14,
982,
642,
805,
365,
440,
686,
198,
265,
282,
1676,
12,
2066,
1218,
652,
465,
892,
1982,
402,
1738,
686,
198,
32,
1107,
26,
437,
3659,
370,
314,
1676,
14,
507,
198,
624,
507,
198,
2350,
275,
291,
507,
198,
6710,
3123,
1137,
23491,
14,
5441,
436,
3123,
423,
1532,
1137,
2562,
26,
686,
198,
2350,
275,
3123,
423,
1708,
507,
198,
692,
3123,
508,
23491,
14,
5441,
26,
686,
198,
1739,
275,
23491,
14,
5441,
14,
5352,
8,
1532,
12,
488,
9,
686,
198,
1107,
1982,
507,
198,
1107,
3123,
421,
198,
318,
636,
2722,
721,
277,
304,
507,
198,
1107,
291,
855,
16695,
12398,
715,
9,
421,
198,
318,
636,
16695,
8,
277,
12,
5246,
12,
2061,
3493,
304,
507,
198,
692,
291,
423,
521,
365,
440,
488,
26,
686,
198,
83,
275,
2071,
83,
375,
5,
83,
4366,
83,
2862,
78,
2,
450,
334,
4694,
12,
291,
423,
1532,
12,
291,
423,
521,
9,
507,
198,
2836,
26,
686,
198,
83,
275,
2071,
83,
375,
5,
83,
60,
78,
2,
450,
334,
4694,
12,
291,
423,
1532,
9,
2742,
198,
73,
275,
378,
507,
198,
692,
2061,
3493,
26,
686,
198,
4694,
275,
5246,
4439,
17,
61,
435,
298,
298,
507,
198,
6710,
284,
665,
822,
8,
277,
423,
3223,
304,
686,
198,
692,
284,
1137,
822,
8,
277,
423,
3223,
9,
446,
413,
26,
1585,
198,
83,
847,
2071,
83,
2,
450,
291,
423,
3223,
59,
73,
17979,
16695,
8,
4694,
17992,
11674,
198,
2,
259,
1204,
401,
756,
9,
686,
198,
2836,
26,
1585,
198,
83,
847,
2071,
83,
2,
450,
291,
423,
3223,
59,
73,
17979,
16695,
8,
4694,
17992,
11674,
198,
2,
259,
1204,
401,
715,
9,
686,
198,
73,
847,
413,
507,
198,
1107,
308,
199,
199,
533,
23804,
29969,
8,
1726,
304,
199,
198,
624,
3917,
314,
2061,
1004,
365,
440,
4890,
2952,
402,
314,
5200,
2059,
474,
12,
21979,
781,
2934,
370,
3631,
314,
6661,
436,
3686,
642,
1004,
14,
199,
198,
624,
199,
198,
1529,
199,
199,
533,
6819,
29969,
8,
1726,
304,
199,
198,
624,
982,
314,
1004,
365,
282,
3721,
334,
305,
315,
314,
9608,
402,
314,
3307,
570,
395,
6722,
2951,
3686,
652,
14,
199,
198,
624,
199,
198,
1529,
421,
199,
318,
2198,
3049,
8,
604,
304,
199,
198,
604,
275,
1004,
14,
1913,
342,
199,
198,
692,
1004,
14,
2460,
10064,
2349,
507,
198,
3730,
6819,
29969,
199,
198,
77,
275,
295,
14,
1431,
480,
4735,
2677,
23778,
1103,
61,
435,
779,
16,
13,
25,
32455,
304,
334,
1103,
87,
8771,
665,
15426,
1103,
87,
11,
4186,
1004,
9,
199,
198,
692,
333,
365,
488,
26,
507,
198,
3730,
23804,
29969,
199,
198,
1107,
334,
77,
14,
923,
8,
17,
395,
333,
14,
923,
8,
18,
395,
333,
14,
923,
8,
19,
430,
421,
199,
318,
2446,
837,
199,
198,
2176,
3987,
14,
5441,
275,
23491,
480,
6405,
334,
14351,
1681,
4186,
488,
12,
488,
9,
199,
198,
2350,
275,
23491,
14,
5441,
421,
198,
509,
1004,
315,
984,
14,
6626,
26,
507,
198,
893,
26,
686,
198,
1250,
521,
12,
3213,
18387,
12,
8025,
275,
2198,
3049,
8,
604,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
sivaramakrishnansr/ryu
|
ryu/lib/type_desc.py
|
8
|
2946
|
# Copyright (C) 2015 Nippon Telegraph and Telephone Corporation.
# Copyright (C) 2015 YAMAMOTO Takashi <yamamoto at valinux co jp>
#
# 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 six
from ryu.lib import addrconv
class TypeDescr(object):
pass
class IntDescr(TypeDescr):
def __init__(self, size):
self.size = size
def to_user(self, bin):
i = 0
for x in range(self.size):
c = bin[:1]
i = i * 256 + ord(c)
bin = bin[1:]
return i
def from_user(self, i):
bin = b''
for x in range(self.size):
bin = six.int2byte(i & 255) + bin
i //= 256
return bin
Int1 = IntDescr(1)
Int2 = IntDescr(2)
Int3 = IntDescr(3)
Int4 = IntDescr(4)
Int8 = IntDescr(8)
def _split_str(s, n):
"""
split string into list of strings by specified number.
"""
length = len(s)
return [s[i:i + n] for i in range(0, length, n)]
class IntDescrMlt(TypeDescr):
def __init__(self, length, num):
self.length = length
self.num = num
self.size = length * num
def to_user(self, bin):
assert len(bin) == self.size
lb = _split_str(bin, self.length)
li = []
for b in lb:
i = 0
for x in range(self.length):
c = b[:1]
i = i * 256 + ord(c)
b = b[1:]
li.append(i)
return tuple(li)
def from_user(self, li):
assert len(li) == self.num
bin = b''
for i in li:
b = b''
for x in range(self.length):
b = six.int2byte(i & 255) + b
i //= 256
bin += b
return bin
Int4Double = IntDescrMlt(4, 2)
class MacAddr(TypeDescr):
size = 6
to_user = addrconv.mac.bin_to_text
from_user = addrconv.mac.text_to_bin
class IPv4Addr(TypeDescr):
size = 4
to_user = addrconv.ipv4.bin_to_text
from_user = addrconv.ipv4.text_to_bin
class IPv6Addr(TypeDescr):
size = 16
to_user = addrconv.ipv6.bin_to_text
from_user = addrconv.ipv6.text_to_bin
class UnknownType(TypeDescr):
import base64
b64encode = base64.b64encode
if six.PY3:
@classmethod
def to_user(cls, data):
return cls.b64encode(data).decode('ascii')
else:
to_user = staticmethod(base64.b64encode)
from_user = staticmethod(base64.b64decode)
|
apache-2.0
|
[
3,
1898,
334,
35,
9,
6900,
653,
711,
678,
23884,
2180,
436,
23884,
9339,
11098,
14,
199,
3,
1898,
334,
35,
9,
6900,
1488,
1156,
1156,
31747,
377,
1151,
1119,
73,
665,
11552,
391,
77,
3459,
737,
1139,
7226,
512,
28921,
30,
199,
3,
199,
3,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
199,
3,
1265,
1443,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
199,
3,
2047,
1443,
3332,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
259,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
199,
3,
2428,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
199,
3,
2478,
14,
199,
3,
1666,
314,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
199,
3,
4204,
1334,
314,
844,
14,
421,
199,
646,
3816,
199,
199,
504,
25494,
14,
773,
492,
5552,
5598,
421,
199,
533,
2434,
28782,
8,
785,
304,
272,
986,
421,
199,
533,
9805,
28782,
8,
804,
28782,
304,
272,
347,
636,
826,
721,
277,
12,
1568,
304,
267,
291,
14,
890,
275,
1568,
339,
347,
370,
63,
751,
8,
277,
12,
2517,
304,
267,
284,
275,
378,
267,
367,
671,
315,
1425,
8,
277,
14,
890,
304,
288,
286,
275,
2517,
1491,
17,
61,
288,
284,
275,
284,
627,
7633,
435,
6206,
8,
67,
9,
288,
2517,
275,
2517,
59,
17,
2938,
267,
372,
284,
339,
347,
687,
63,
751,
8,
277,
12,
284,
304,
267,
2517,
275,
330,
891,
267,
367,
671,
315,
1425,
8,
277,
14,
890,
304,
288,
2517,
275,
3816,
14,
442,
18,
4414,
8,
73,
1253,
5450,
9,
435,
2517,
288,
284,
5001,
29,
7633,
267,
372,
2517,
199,
199,
3241,
17,
275,
9805,
28782,
8,
17,
9,
199,
3241,
18,
275,
9805,
28782,
8,
18,
9,
199,
3241,
19,
275,
9805,
28782,
8,
19,
9,
199,
3241,
20,
275,
9805,
28782,
8,
20,
9,
199,
3241,
24,
275,
9805,
28782,
8,
24,
9,
421,
199,
318,
485,
1294,
63,
495,
8,
83,
12,
302,
304,
272,
408,
272,
3715,
1059,
1901,
769,
402,
3326,
701,
2013,
1329,
14,
272,
408,
272,
2582,
275,
822,
8,
83,
9,
272,
372,
359,
83,
59,
73,
26,
73,
435,
302,
61,
367,
284,
315,
1425,
8,
16,
12,
2582,
12,
302,
1874,
421,
199,
533,
9805,
28782,
45,
4116,
8,
804,
28782,
304,
272,
347,
636,
826,
721,
277,
12,
2582,
12,
1967,
304,
267,
291,
14,
1267,
275,
2582,
267,
291,
14,
1507,
275,
1967,
267,
291,
14,
890,
275,
2582,
627,
1967,
339,
347,
370,
63,
751,
8,
277,
12,
2517,
304,
267,
702,
822,
8,
1393,
9,
508,
291,
14,
890,
267,
11104,
275,
485,
1294,
63,
495,
8,
1393,
12,
291,
14,
1267,
9,
267,
1212,
275,
942,
267,
367,
330,
315,
11104,
26,
288,
284,
275,
378,
288,
367,
671,
315,
1425,
8,
277,
14,
1267,
304,
355,
286,
275,
330,
1491,
17,
61,
355,
284,
275,
284,
627,
7633,
435,
6206,
8,
67,
9,
355,
330,
275,
330,
59,
17,
2938,
288,
1212,
14,
740,
8,
73,
9,
267,
372,
2008,
8,
317,
9,
339,
347,
687,
63,
751,
8,
277,
12,
1212,
304,
267,
702,
822,
8,
317,
9,
508,
291,
14,
1507,
267,
2517,
275,
330,
891,
267,
367,
284,
315,
1212,
26,
288,
330,
275,
330,
891,
288,
367,
671,
315,
1425,
8,
277,
14,
1267,
304,
355,
330,
275,
3816,
14,
442,
18,
4414,
8,
73,
1253,
5450,
9,
435,
330,
355,
284,
5001,
29,
7633,
288,
2517,
847,
330,
267,
372,
2517,
199,
199,
3241,
20,
7281,
275,
9805,
28782,
45,
4116,
8,
20,
12,
499,
9,
421,
199,
533,
10444,
11404,
8,
804,
28782,
304,
272,
1568,
275,
1227,
272,
370,
63,
751,
275,
5552,
5598,
14,
3088,
14,
1393,
63,
475,
63,
505,
272,
687,
63,
751,
275,
5552,
5598,
14,
3088,
14,
505,
63,
475,
63,
1393,
421,
199,
533,
6509,
20,
11404,
8,
804,
28782,
304,
272,
1568,
275,
841,
272,
370,
63,
751,
275,
5552,
5598,
14,
4774,
20,
14,
1393,
63,
475,
63,
505,
272,
687,
63,
751,
275,
5552,
5598,
14,
4774,
20,
14,
505,
63,
475,
63,
1393,
421,
199,
533,
6509,
22,
11404,
8,
804,
28782,
304,
272,
1568,
275,
3193,
272,
370,
63,
751,
275,
5552,
5598,
14,
4774,
22,
14,
1393,
63,
475,
63,
505,
272,
687,
63,
751,
275,
5552,
5598,
14,
4774,
22,
14,
505,
63,
475,
63,
1393,
421,
199,
533,
14831,
804,
8,
804,
28782,
304,
272,
492,
1300,
772,
339,
330,
772,
2143,
275,
1300,
772,
14,
66,
772,
2143,
272,
340,
3816,
14,
4521,
19,
26,
267,
768,
3744,
267,
347,
370,
63,
751,
8,
1886,
12,
666,
304,
288,
372,
843,
14,
66,
772,
2143,
8,
576,
680,
2708,
360,
4371,
358,
272,
587,
26,
267,
370,
63,
751,
275,
12822,
8,
1095,
772,
14,
66,
772,
2143,
9,
272,
687,
63,
751,
275,
12822,
8,
1095,
772,
14,
66,
772,
2708,
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
] |
[
1898,
334,
35,
9,
6900,
653,
711,
678,
23884,
2180,
436,
23884,
9339,
11098,
14,
199,
3,
1898,
334,
35,
9,
6900,
1488,
1156,
1156,
31747,
377,
1151,
1119,
73,
665,
11552,
391,
77,
3459,
737,
1139,
7226,
512,
28921,
30,
199,
3,
199,
3,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
199,
3,
1265,
1443,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
199,
3,
2047,
1443,
3332,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
259,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
199,
3,
2428,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
199,
3,
2478,
14,
199,
3,
1666,
314,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
199,
3,
4204,
1334,
314,
844,
14,
421,
199,
646,
3816,
199,
199,
504,
25494,
14,
773,
492,
5552,
5598,
421,
199,
533,
2434,
28782,
8,
785,
304,
272,
986,
421,
199,
533,
9805,
28782,
8,
804,
28782,
304,
272,
347,
636,
826,
721,
277,
12,
1568,
304,
267,
291,
14,
890,
275,
1568,
339,
347,
370,
63,
751,
8,
277,
12,
2517,
304,
267,
284,
275,
378,
267,
367,
671,
315,
1425,
8,
277,
14,
890,
304,
288,
286,
275,
2517,
1491,
17,
61,
288,
284,
275,
284,
627,
7633,
435,
6206,
8,
67,
9,
288,
2517,
275,
2517,
59,
17,
2938,
267,
372,
284,
339,
347,
687,
63,
751,
8,
277,
12,
284,
304,
267,
2517,
275,
330,
891,
267,
367,
671,
315,
1425,
8,
277,
14,
890,
304,
288,
2517,
275,
3816,
14,
442,
18,
4414,
8,
73,
1253,
5450,
9,
435,
2517,
288,
284,
5001,
29,
7633,
267,
372,
2517,
199,
199,
3241,
17,
275,
9805,
28782,
8,
17,
9,
199,
3241,
18,
275,
9805,
28782,
8,
18,
9,
199,
3241,
19,
275,
9805,
28782,
8,
19,
9,
199,
3241,
20,
275,
9805,
28782,
8,
20,
9,
199,
3241,
24,
275,
9805,
28782,
8,
24,
9,
421,
199,
318,
485,
1294,
63,
495,
8,
83,
12,
302,
304,
272,
408,
272,
3715,
1059,
1901,
769,
402,
3326,
701,
2013,
1329,
14,
272,
408,
272,
2582,
275,
822,
8,
83,
9,
272,
372,
359,
83,
59,
73,
26,
73,
435,
302,
61,
367,
284,
315,
1425,
8,
16,
12,
2582,
12,
302,
1874,
421,
199,
533,
9805,
28782,
45,
4116,
8,
804,
28782,
304,
272,
347,
636,
826,
721,
277,
12,
2582,
12,
1967,
304,
267,
291,
14,
1267,
275,
2582,
267,
291,
14,
1507,
275,
1967,
267,
291,
14,
890,
275,
2582,
627,
1967,
339,
347,
370,
63,
751,
8,
277,
12,
2517,
304,
267,
702,
822,
8,
1393,
9,
508,
291,
14,
890,
267,
11104,
275,
485,
1294,
63,
495,
8,
1393,
12,
291,
14,
1267,
9,
267,
1212,
275,
942,
267,
367,
330,
315,
11104,
26,
288,
284,
275,
378,
288,
367,
671,
315,
1425,
8,
277,
14,
1267,
304,
355,
286,
275,
330,
1491,
17,
61,
355,
284,
275,
284,
627,
7633,
435,
6206,
8,
67,
9,
355,
330,
275,
330,
59,
17,
2938,
288,
1212,
14,
740,
8,
73,
9,
267,
372,
2008,
8,
317,
9,
339,
347,
687,
63,
751,
8,
277,
12,
1212,
304,
267,
702,
822,
8,
317,
9,
508,
291,
14,
1507,
267,
2517,
275,
330,
891,
267,
367,
284,
315,
1212,
26,
288,
330,
275,
330,
891,
288,
367,
671,
315,
1425,
8,
277,
14,
1267,
304,
355,
330,
275,
3816,
14,
442,
18,
4414,
8,
73,
1253,
5450,
9,
435,
330,
355,
284,
5001,
29,
7633,
288,
2517,
847,
330,
267,
372,
2517,
199,
199,
3241,
20,
7281,
275,
9805,
28782,
45,
4116,
8,
20,
12,
499,
9,
421,
199,
533,
10444,
11404,
8,
804,
28782,
304,
272,
1568,
275,
1227,
272,
370,
63,
751,
275,
5552,
5598,
14,
3088,
14,
1393,
63,
475,
63,
505,
272,
687,
63,
751,
275,
5552,
5598,
14,
3088,
14,
505,
63,
475,
63,
1393,
421,
199,
533,
6509,
20,
11404,
8,
804,
28782,
304,
272,
1568,
275,
841,
272,
370,
63,
751,
275,
5552,
5598,
14,
4774,
20,
14,
1393,
63,
475,
63,
505,
272,
687,
63,
751,
275,
5552,
5598,
14,
4774,
20,
14,
505,
63,
475,
63,
1393,
421,
199,
533,
6509,
22,
11404,
8,
804,
28782,
304,
272,
1568,
275,
3193,
272,
370,
63,
751,
275,
5552,
5598,
14,
4774,
22,
14,
1393,
63,
475,
63,
505,
272,
687,
63,
751,
275,
5552,
5598,
14,
4774,
22,
14,
505,
63,
475,
63,
1393,
421,
199,
533,
14831,
804,
8,
804,
28782,
304,
272,
492,
1300,
772,
339,
330,
772,
2143,
275,
1300,
772,
14,
66,
772,
2143,
272,
340,
3816,
14,
4521,
19,
26,
267,
768,
3744,
267,
347,
370,
63,
751,
8,
1886,
12,
666,
304,
288,
372,
843,
14,
66,
772,
2143,
8,
576,
680,
2708,
360,
4371,
358,
272,
587,
26,
267,
370,
63,
751,
275,
12822,
8,
1095,
772,
14,
66,
772,
2143,
9,
272,
687,
63,
751,
275,
12822,
8,
1095,
772,
14,
66,
772,
2708,
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,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
redhat-cip/hardware
|
hardware/smart_utils_info.py
|
1
|
2135
|
# 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.
NVME_INFOS = {
'Model Number:': 'model_number',
'Serial Number:': 'serial_number',
'Firmware Version:': 'firmware_version',
'Total NVM Capacity:': 'total_nvm_capacity',
'Warning Comp. Temp. Threshold:': 'warning_temp_threshold',
'Critical Comp. Temp. Threshold:': 'critical_temp_threshold',
'Critical Warning:': 'critical_warning',
'Temperature:': 'temperature',
'Power Cycles:': 'power_cycles',
'Power On Hours:': 'power_on_hours',
'Unsafe Shutdowns:': 'unsafe_shutdowns',
'Media and Data Integrity Errors:': 'media_data_integrity_errors',
'Error Information Log Entries:': 'error_information_log_entries',
}
SMART_FIELDS = {
"Serial number:": "serial_number",
"SMART Health Status:": "health",
"Specified cycle count over device "
"lifetime:": "specified_start_stop_cycle_count_over_lifetime",
"Accumulated start-stop cycles:": "start_stop_cycle_count",
"Specified load-unload count over device "
"lifetime:": "specified_load_count_over_lifetime",
"Accumulated load-unload cycles:": "load_count",
"number of hours powered up =": "power_on_hours",
"Blocks sent to initiator =": "blocks_sent",
"Blocks received from initiator =": "blocks_received",
"Blocks read from cache and sent to initiator =": "blocks_read_from_cache",
"Non-medium error count:": "non_medium_errors_count",
"Current Drive Temperature:": "current_drive_temperature",
"Drive Trip Temperature:": "drive_trip_temperature",
"Manufactured in ": "manufacture_date",
"Rotation Rate": "rotation_rate",
}
|
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,
7312,
3635,
63,
11384,
3100,
275,
469,
272,
283,
1685,
4860,
25156,
283,
1238,
63,
1955,
297,
272,
283,
3571,
4860,
25156,
283,
2171,
63,
1955,
297,
272,
283,
38,
20678,
3394,
25156,
283,
26374,
63,
1023,
297,
272,
283,
7316,
653,
6849,
8790,
6192,
25156,
283,
2923,
63,
78,
2611,
63,
10457,
297,
272,
283,
3849,
221,
3599,
14,
12540,
14,
3868,
4480,
25156,
283,
3764,
63,
808,
63,
7227,
297,
272,
283,
27677,
3599,
14,
12540,
14,
3868,
4480,
25156,
283,
13138,
63,
808,
63,
7227,
297,
272,
283,
27677,
15902,
25156,
283,
13138,
63,
3764,
297,
272,
283,
27409,
25156,
283,
12954,
297,
272,
283,
6921,
18461,
2265,
83,
25156,
283,
5652,
63,
23356,
297,
272,
283,
6921,
4068,
869,
16363,
25156,
283,
5652,
63,
265,
63,
8419,
297,
272,
283,
9251,
6504,
5244,
337,
68,
23311,
25156,
283,
14242,
63,
609,
337,
68,
23311,
297,
272,
283,
11398,
436,
3918,
8883,
12997,
20456,
25156,
283,
4603,
63,
576,
63,
5707,
12997,
63,
2550,
297,
272,
283,
547,
17064,
5297,
23450,
1996,
25156,
283,
705,
63,
11697,
63,
793,
63,
3189,
297,
199,
93,
199,
199,
4029,
2294,
63,
12767,
275,
469,
272,
298,
3571,
1329,
25165,
298,
2171,
63,
1955,
401,
272,
298,
4029,
2294,
5311,
6130,
9795,
25165,
298,
9665,
401,
272,
298,
6154,
1290,
8643,
2338,
1806,
2243,
298,
272,
298,
27674,
25165,
298,
10085,
63,
928,
63,
2379,
63,
7612,
63,
835,
63,
1883,
63,
27674,
401,
272,
298,
23384,
8097,
1343,
13,
2379,
19001,
25165,
298,
928,
63,
2379,
63,
7612,
63,
835,
401,
272,
298,
6154,
1290,
2248,
13,
25477,
2338,
1806,
2243,
298,
272,
298,
27674,
25165,
298,
10085,
63,
912,
63,
835,
63,
1883,
63,
27674,
401,
272,
298,
23384,
8097,
2248,
13,
25477,
19001,
25165,
298,
912,
63,
835,
401,
272,
298,
1955,
402,
10857,
13131,
16179,
1536,
275,
582,
298,
5652,
63,
265,
63,
8419,
401,
272,
298,
24996,
4847,
370,
22094,
275,
582,
298,
4166,
63,
1150,
401,
272,
298,
24996,
3086,
687,
22094,
275,
582,
298,
4166,
63,
9226,
401,
272,
298,
24996,
1586,
687,
2581,
436,
4847,
370,
22094,
275,
582,
298,
4166,
63,
739,
63,
504,
63,
1637,
401,
272,
298,
6932,
13,
14345,
1125,
2338,
25165,
298,
2865,
63,
14345,
63,
2550,
63,
835,
401,
272,
298,
5639,
577,
6053,
12540,
7899,
25165,
298,
1818,
63,
9541,
63,
12954,
401,
272,
298,
24276,
12480,
80,
12540,
7899,
25165,
298,
9541,
63,
7254,
63,
12954,
401,
272,
298,
2395,
7415,
319,
3297,
315,
7244,
298,
1237,
17391,
63,
602,
401,
272,
298,
28247,
26311,
582,
298,
15362,
63,
1866,
401,
199,
93,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
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,
7312,
3635,
63,
11384,
3100,
275,
469,
272,
283,
1685,
4860,
25156,
283,
1238,
63,
1955,
297,
272,
283,
3571,
4860,
25156,
283,
2171,
63,
1955,
297,
272,
283,
38,
20678,
3394,
25156,
283,
26374,
63,
1023,
297,
272,
283,
7316,
653,
6849,
8790,
6192,
25156,
283,
2923,
63,
78,
2611,
63,
10457,
297,
272,
283,
3849,
221,
3599,
14,
12540,
14,
3868,
4480,
25156,
283,
3764,
63,
808,
63,
7227,
297,
272,
283,
27677,
3599,
14,
12540,
14,
3868,
4480,
25156,
283,
13138,
63,
808,
63,
7227,
297,
272,
283,
27677,
15902,
25156,
283,
13138,
63,
3764,
297,
272,
283,
27409,
25156,
283,
12954,
297,
272,
283,
6921,
18461,
2265,
83,
25156,
283,
5652,
63,
23356,
297,
272,
283,
6921,
4068,
869,
16363,
25156,
283,
5652,
63,
265,
63,
8419,
297,
272,
283,
9251,
6504,
5244,
337,
68,
23311,
25156,
283,
14242,
63,
609,
337,
68,
23311,
297,
272,
283,
11398,
436,
3918,
8883,
12997,
20456,
25156,
283,
4603,
63,
576,
63,
5707,
12997,
63,
2550,
297,
272,
283,
547,
17064,
5297,
23450,
1996,
25156,
283,
705,
63,
11697,
63,
793,
63,
3189,
297,
199,
93,
199,
199,
4029,
2294,
63,
12767,
275,
469,
272,
298,
3571,
1329,
25165,
298,
2171,
63,
1955,
401,
272,
298,
4029,
2294,
5311,
6130,
9795,
25165,
298,
9665,
401,
272,
298,
6154,
1290,
8643,
2338,
1806,
2243,
298,
272,
298,
27674,
25165,
298,
10085,
63,
928,
63,
2379,
63,
7612,
63,
835,
63,
1883,
63,
27674,
401,
272,
298,
23384,
8097,
1343,
13,
2379,
19001,
25165,
298,
928,
63,
2379,
63,
7612,
63,
835,
401,
272,
298,
6154,
1290,
2248,
13,
25477,
2338,
1806,
2243,
298,
272,
298,
27674,
25165,
298,
10085,
63,
912,
63,
835,
63,
1883,
63,
27674,
401,
272,
298,
23384,
8097,
2248,
13,
25477,
19001,
25165,
298,
912,
63,
835,
401,
272,
298,
1955,
402,
10857,
13131,
16179,
1536,
275,
582,
298,
5652,
63,
265,
63,
8419,
401,
272,
298,
24996,
4847,
370,
22094,
275,
582,
298,
4166,
63,
1150,
401,
272,
298,
24996,
3086,
687,
22094,
275,
582,
298,
4166,
63,
9226,
401,
272,
298,
24996,
1586,
687,
2581,
436,
4847,
370,
22094,
275,
582,
298,
4166,
63,
739,
63,
504,
63,
1637,
401,
272,
298,
6932,
13,
14345,
1125,
2338,
25165,
298,
2865,
63,
14345,
63,
2550,
63,
835,
401,
272,
298,
5639,
577,
6053,
12540,
7899,
25165,
298,
1818,
63,
9541,
63,
12954,
401,
272,
298,
24276,
12480,
80,
12540,
7899,
25165,
298,
9541,
63,
7254,
63,
12954,
401,
272,
298,
2395,
7415,
319,
3297,
315,
7244,
298,
1237,
17391,
63,
602,
401,
272,
298,
28247,
26311,
582,
298,
15362,
63,
1866,
401,
199,
93,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
takeshineshiro/django
|
django/core/cache/backends/base.py
|
145
|
9680
|
"Base Cache class."
from __future__ import unicode_literals
import time
import warnings
from django.core.exceptions import DjangoRuntimeWarning, ImproperlyConfigured
from django.utils.module_loading import import_string
class InvalidCacheBackendError(ImproperlyConfigured):
pass
class CacheKeyWarning(DjangoRuntimeWarning):
pass
# Stub class to ensure not passing in a `timeout` argument results in
# the default timeout
DEFAULT_TIMEOUT = object()
# Memcached does not accept keys longer than this.
MEMCACHE_MAX_KEY_LENGTH = 250
def default_key_func(key, key_prefix, version):
"""
Default function to generate keys.
Constructs the key used by all other methods. By default it prepends
the `key_prefix'. KEY_FUNCTION can be used to specify an alternate
function with custom key making behavior.
"""
return '%s:%s:%s' % (key_prefix, version, key)
def get_key_func(key_func):
"""
Function to decide which key function to use.
Defaults to ``default_key_func``.
"""
if key_func is not None:
if callable(key_func):
return key_func
else:
return import_string(key_func)
return default_key_func
class BaseCache(object):
def __init__(self, params):
timeout = params.get('timeout', params.get('TIMEOUT', 300))
if timeout is not None:
try:
timeout = int(timeout)
except (ValueError, TypeError):
timeout = 300
self.default_timeout = timeout
options = params.get('OPTIONS', {})
max_entries = params.get('max_entries', options.get('MAX_ENTRIES', 300))
try:
self._max_entries = int(max_entries)
except (ValueError, TypeError):
self._max_entries = 300
cull_frequency = params.get('cull_frequency', options.get('CULL_FREQUENCY', 3))
try:
self._cull_frequency = int(cull_frequency)
except (ValueError, TypeError):
self._cull_frequency = 3
self.key_prefix = params.get('KEY_PREFIX', '')
self.version = params.get('VERSION', 1)
self.key_func = get_key_func(params.get('KEY_FUNCTION'))
def get_backend_timeout(self, timeout=DEFAULT_TIMEOUT):
"""
Returns the timeout value usable by this backend based upon the provided
timeout.
"""
if timeout == DEFAULT_TIMEOUT:
timeout = self.default_timeout
elif timeout == 0:
# ticket 21147 - avoid time.time() related precision issues
timeout = -1
return None if timeout is None else time.time() + timeout
def make_key(self, key, version=None):
"""Constructs the key used by all other methods. By default it
uses the key_func to generate a key (which, by default,
prepends the `key_prefix' and 'version'). An different key
function can be provided at the time of cache construction;
alternatively, you can subclass the cache backend to provide
custom key making behavior.
"""
if version is None:
version = self.version
new_key = self.key_func(key, self.key_prefix, version)
return new_key
def add(self, key, value, timeout=DEFAULT_TIMEOUT, version=None):
"""
Set a value in the cache if the key does not already exist. If
timeout is given, that timeout will be used for the key; otherwise
the default cache timeout will be used.
Returns True if the value was stored, False otherwise.
"""
raise NotImplementedError('subclasses of BaseCache must provide an add() method')
def get(self, key, default=None, version=None):
"""
Fetch a given key from the cache. If the key does not exist, return
default, which itself defaults to None.
"""
raise NotImplementedError('subclasses of BaseCache must provide a get() method')
def set(self, key, value, timeout=DEFAULT_TIMEOUT, version=None):
"""
Set a value in the cache. If timeout is given, that timeout will be
used for the key; otherwise the default cache timeout will be used.
"""
raise NotImplementedError('subclasses of BaseCache must provide a set() method')
def delete(self, key, version=None):
"""
Delete a key from the cache, failing silently.
"""
raise NotImplementedError('subclasses of BaseCache must provide a delete() method')
def get_many(self, keys, version=None):
"""
Fetch a bunch of keys from the cache. For certain backends (memcached,
pgsql) this can be *much* faster when fetching multiple values.
Returns a dict mapping each key in keys to its value. If the given
key is missing, it will be missing from the response dict.
"""
d = {}
for k in keys:
val = self.get(k, version=version)
if val is not None:
d[k] = val
return d
def get_or_set(self, key, default=None, timeout=DEFAULT_TIMEOUT, version=None):
"""
Fetch a given key from the cache. If the key does not exist,
the key is added and set to the default value. The default value can
also be any callable. If timeout is given, that timeout will be used
for the key; otherwise the default cache timeout will be used.
Returns the value of the key stored or retrieved on success,
False on error.
"""
if default is None:
raise ValueError('You need to specify a value.')
val = self.get(key, version=version)
if val is None:
if callable(default):
default = default()
val = self.add(key, default, timeout=timeout, version=version)
if val:
return self.get(key, version=version)
return val
def has_key(self, key, version=None):
"""
Returns True if the key is in the cache and has not expired.
"""
return self.get(key, version=version) is not None
def incr(self, key, delta=1, version=None):
"""
Add delta to value in the cache. If the key does not exist, raise a
ValueError exception.
"""
value = self.get(key, version=version)
if value is None:
raise ValueError("Key '%s' not found" % key)
new_value = value + delta
self.set(key, new_value, version=version)
return new_value
def decr(self, key, delta=1, version=None):
"""
Subtract delta from value in the cache. If the key does not exist, raise
a ValueError exception.
"""
return self.incr(key, -delta, version=version)
def __contains__(self, key):
"""
Returns True if the key is in the cache and has not expired.
"""
# This is a separate method, rather than just a copy of has_key(),
# so that it always has the same functionality as has_key(), even
# if a subclass overrides it.
return self.has_key(key)
def set_many(self, data, timeout=DEFAULT_TIMEOUT, version=None):
"""
Set a bunch of values in the cache at once from a dict of key/value
pairs. For certain backends (memcached), this is much more efficient
than calling set() multiple times.
If timeout is given, that timeout will be used for the key; otherwise
the default cache timeout will be used.
"""
for key, value in data.items():
self.set(key, value, timeout=timeout, version=version)
def delete_many(self, keys, version=None):
"""
Set a bunch of values in the cache at once. For certain backends
(memcached), this is much more efficient than calling delete() multiple
times.
"""
for key in keys:
self.delete(key, version=version)
def clear(self):
"""Remove *all* values from the cache at once."""
raise NotImplementedError('subclasses of BaseCache must provide a clear() method')
def validate_key(self, key):
"""
Warn about keys that would not be portable to the memcached
backend. This encourages (but does not force) writing backend-portable
cache code.
"""
if len(key) > MEMCACHE_MAX_KEY_LENGTH:
warnings.warn('Cache key will cause errors if used with memcached: '
'%s (longer than %s)' % (key, MEMCACHE_MAX_KEY_LENGTH),
CacheKeyWarning)
for char in key:
if ord(char) < 33 or ord(char) == 127:
warnings.warn('Cache key contains characters that will cause '
'errors if used with memcached: %r' % key,
CacheKeyWarning)
def incr_version(self, key, delta=1, version=None):
"""Adds delta to the cache version for the supplied key. Returns the
new version.
"""
if version is None:
version = self.version
value = self.get(key, version=version)
if value is None:
raise ValueError("Key '%s' not found" % key)
self.set(key, value, version=version + delta)
self.delete(key, version=version)
return version + delta
def decr_version(self, key, delta=1, version=None):
"""Substracts delta from the cache version for the supplied key. Returns
the new version.
"""
return self.incr_version(key, -delta, version)
def close(self, **kwargs):
"""Close the cache connection"""
pass
|
bsd-3-clause
|
[
2,
1563,
11977,
1021,
2122,
199,
504,
636,
2443,
363,
492,
2649,
63,
5955,
199,
199,
646,
900,
199,
646,
3598,
199,
199,
504,
1639,
14,
1018,
14,
3924,
492,
5634,
14357,
3849,
12,
11897,
199,
504,
1639,
14,
1208,
14,
578,
63,
8786,
492,
492,
63,
875,
421,
199,
533,
6378,
4437,
8447,
547,
8,
8499,
10951,
304,
272,
986,
421,
199,
533,
11977,
1197,
3849,
8,
9323,
14357,
3849,
304,
272,
986,
421,
199,
3,
23429,
1021,
370,
4868,
440,
9476,
315,
282,
658,
2593,
64,
1423,
2058,
315,
199,
3,
314,
849,
2653,
199,
3472,
63,
8899,
275,
909,
342,
199,
199,
3,
30465,
5245,
1630,
440,
4729,
2883,
8088,
2419,
642,
14,
199,
10293,
8677,
63,
4283,
63,
3078,
63,
9127,
275,
16074,
421,
199,
318,
849,
63,
498,
63,
1532,
8,
498,
12,
790,
63,
1861,
12,
1015,
304,
272,
408,
272,
3758,
805,
370,
3550,
2883,
14,
339,
9215,
83,
314,
790,
1202,
701,
1006,
1163,
3102,
14,
4885,
849,
652,
19986,
3198,
272,
314,
658,
498,
63,
1861,
1370,
9301,
63,
15476,
883,
506,
1202,
370,
4165,
376,
18034,
272,
805,
543,
3537,
790,
10663,
5953,
14,
272,
408,
272,
372,
1543,
83,
2689,
83,
2689,
83,
7,
450,
334,
498,
63,
1861,
12,
1015,
12,
790,
9,
421,
199,
318,
664,
63,
498,
63,
1532,
8,
498,
63,
1532,
304,
272,
408,
272,
6801,
370,
19822,
1314,
790,
805,
370,
675,
14,
339,
7827,
370,
1124,
885,
63,
498,
63,
1532,
4345,
272,
408,
272,
340,
790,
63,
1532,
365,
440,
488,
26,
267,
340,
4550,
8,
498,
63,
1532,
304,
288,
372,
790,
63,
1532,
267,
587,
26,
288,
372,
492,
63,
875,
8,
498,
63,
1532,
9,
272,
372,
849,
63,
498,
63,
1532,
421,
199,
533,
3523,
4437,
8,
785,
304,
272,
347,
636,
826,
721,
277,
12,
1862,
304,
267,
2653,
275,
1862,
14,
362,
360,
2593,
297,
1862,
14,
362,
360,
8899,
297,
9601,
430,
267,
340,
2653,
365,
440,
488,
26,
288,
862,
26,
355,
2653,
275,
1109,
8,
2593,
9,
288,
871,
334,
3393,
12,
3146,
304,
355,
2653,
275,
9601,
267,
291,
14,
885,
63,
2593,
275,
2653,
398,
1511,
275,
1862,
14,
362,
360,
8808,
297,
5009,
267,
1390,
63,
3189,
275,
1862,
14,
362,
360,
988,
63,
3189,
297,
1511,
14,
362,
360,
4283,
63,
1309,
23359,
297,
9601,
430,
267,
862,
26,
288,
291,
423,
988,
63,
3189,
275,
1109,
8,
988,
63,
3189,
9,
267,
871,
334,
3393,
12,
3146,
304,
288,
291,
423,
988,
63,
3189,
275,
9601,
398,
286,
979,
63,
11132,
275,
1862,
14,
362,
360,
67,
979,
63,
11132,
297,
1511,
14,
362,
360,
35,
3785,
63,
38,
5255,
17059,
297,
650,
430,
267,
862,
26,
288,
291,
423,
67,
979,
63,
11132,
275,
1109,
8,
67,
979,
63,
11132,
9,
267,
871,
334,
3393,
12,
3146,
304,
288,
291,
423,
67,
979,
63,
11132,
275,
650,
398,
291,
14,
498,
63,
1861,
275,
1862,
14,
362,
360,
3078,
63,
6351,
297,
4074,
267,
291,
14,
1023,
275,
1862,
14,
362,
360,
4612,
297,
413,
9,
267,
291,
14,
498,
63,
1532,
275,
664,
63,
498,
63,
1532,
8,
1162,
14,
362,
360,
3078,
63,
15476,
1333,
339,
347,
664,
63,
4620,
63,
2593,
8,
277,
12,
2653,
29,
3472,
63,
8899,
304,
267,
408,
267,
1803,
314,
2653,
574,
18025,
701,
642,
4865,
4079,
12188,
314,
2741,
267,
2653,
14,
267,
408,
267,
340,
2653,
508,
6186,
63,
8899,
26,
288,
2653,
275,
291,
14,
885,
63,
2593,
267,
916,
2653,
508,
378,
26,
288,
327,
12052,
30301,
2417,
446,
5126,
900,
14,
521,
342,
4048,
7151,
10876,
288,
2653,
275,
446,
17,
267,
372,
488,
340,
2653,
365,
488,
587,
900,
14,
521,
342,
435,
2653,
339,
347,
1852,
63,
498,
8,
277,
12,
790,
12,
1015,
29,
403,
304,
267,
408,
27943,
314,
790,
1202,
701,
1006,
1163,
3102,
14,
4885,
849,
652,
267,
4440,
314,
790,
63,
1532,
370,
3550,
282,
790,
334,
6777,
12,
701,
849,
12,
267,
19986,
3198,
314,
658,
498,
63,
1861,
7,
436,
283,
1023,
1959,
1626,
3365,
790,
267,
805,
883,
506,
2741,
737,
314,
900,
402,
2581,
14538,
27,
267,
8679,
17330,
12,
1265,
883,
5516,
314,
2581,
4865,
370,
5647,
267,
3537,
790,
10663,
5953,
14,
267,
408,
267,
340,
1015,
365,
488,
26,
288,
1015,
275,
291,
14,
1023,
398,
892,
63,
498,
275,
291,
14,
498,
63,
1532,
8,
498,
12,
291,
14,
498,
63,
1861,
12,
1015,
9,
267,
372,
892,
63,
498,
339,
347,
1050,
8,
277,
12,
790,
12,
574,
12,
2653,
29,
3472,
63,
8899,
12,
1015,
29,
403,
304,
267,
408,
267,
2494,
282,
574,
315,
314,
2581,
340,
314,
790,
1630,
440,
2575,
2187,
14,
982,
267,
2653,
365,
1627,
12,
626,
2653,
911,
506,
1202,
367,
314,
790,
27,
4257,
267,
314,
849,
2581,
2653,
911,
506,
1202,
14,
398,
1803,
715,
340,
314,
574,
1990,
5489,
12,
756,
4257,
14,
267,
408,
267,
746,
4279,
360,
19094,
402,
3523,
4437,
1471,
5647,
376,
1050,
342,
1083,
358,
339,
347,
664,
8,
277,
12,
790,
12,
849,
29,
403,
12,
1015,
29,
403,
304,
267,
408,
267,
16347,
282,
1627,
790,
687,
314,
2581,
14,
982,
314,
790,
1630,
440,
2187,
12,
372,
267,
849,
12,
1314,
6337,
4243,
370,
488,
14,
267,
408,
267,
746,
4279,
360,
19094,
402,
3523,
4437,
1471,
5647,
282,
664,
342,
1083,
358,
339,
347,
663,
8,
277,
12,
790,
12,
574,
12,
2653,
29,
3472,
63,
8899,
12,
1015,
29,
403,
304,
267,
408,
267,
2494,
282,
574,
315,
314,
2581,
14,
982,
2653,
365,
1627,
12,
626,
2653,
911,
506,
267,
1202,
367,
314,
790,
27,
4257,
314,
849,
2581,
2653,
911,
506,
1202,
14,
267,
408,
267,
746,
4279,
360,
19094,
402,
3523,
4437,
1471,
5647,
282,
663,
342,
1083,
358,
339,
347,
3145,
8,
277,
12,
790,
12,
1015,
29,
403,
304,
267,
408,
267,
8496,
282,
790,
687,
314,
2581,
12,
18648,
18030,
14,
267,
408,
267,
746,
4279,
360,
19094,
402,
3523,
4437,
1471,
5647,
282,
3145
] |
[
1563,
11977,
1021,
2122,
199,
504,
636,
2443,
363,
492,
2649,
63,
5955,
199,
199,
646,
900,
199,
646,
3598,
199,
199,
504,
1639,
14,
1018,
14,
3924,
492,
5634,
14357,
3849,
12,
11897,
199,
504,
1639,
14,
1208,
14,
578,
63,
8786,
492,
492,
63,
875,
421,
199,
533,
6378,
4437,
8447,
547,
8,
8499,
10951,
304,
272,
986,
421,
199,
533,
11977,
1197,
3849,
8,
9323,
14357,
3849,
304,
272,
986,
421,
199,
3,
23429,
1021,
370,
4868,
440,
9476,
315,
282,
658,
2593,
64,
1423,
2058,
315,
199,
3,
314,
849,
2653,
199,
3472,
63,
8899,
275,
909,
342,
199,
199,
3,
30465,
5245,
1630,
440,
4729,
2883,
8088,
2419,
642,
14,
199,
10293,
8677,
63,
4283,
63,
3078,
63,
9127,
275,
16074,
421,
199,
318,
849,
63,
498,
63,
1532,
8,
498,
12,
790,
63,
1861,
12,
1015,
304,
272,
408,
272,
3758,
805,
370,
3550,
2883,
14,
339,
9215,
83,
314,
790,
1202,
701,
1006,
1163,
3102,
14,
4885,
849,
652,
19986,
3198,
272,
314,
658,
498,
63,
1861,
1370,
9301,
63,
15476,
883,
506,
1202,
370,
4165,
376,
18034,
272,
805,
543,
3537,
790,
10663,
5953,
14,
272,
408,
272,
372,
1543,
83,
2689,
83,
2689,
83,
7,
450,
334,
498,
63,
1861,
12,
1015,
12,
790,
9,
421,
199,
318,
664,
63,
498,
63,
1532,
8,
498,
63,
1532,
304,
272,
408,
272,
6801,
370,
19822,
1314,
790,
805,
370,
675,
14,
339,
7827,
370,
1124,
885,
63,
498,
63,
1532,
4345,
272,
408,
272,
340,
790,
63,
1532,
365,
440,
488,
26,
267,
340,
4550,
8,
498,
63,
1532,
304,
288,
372,
790,
63,
1532,
267,
587,
26,
288,
372,
492,
63,
875,
8,
498,
63,
1532,
9,
272,
372,
849,
63,
498,
63,
1532,
421,
199,
533,
3523,
4437,
8,
785,
304,
272,
347,
636,
826,
721,
277,
12,
1862,
304,
267,
2653,
275,
1862,
14,
362,
360,
2593,
297,
1862,
14,
362,
360,
8899,
297,
9601,
430,
267,
340,
2653,
365,
440,
488,
26,
288,
862,
26,
355,
2653,
275,
1109,
8,
2593,
9,
288,
871,
334,
3393,
12,
3146,
304,
355,
2653,
275,
9601,
267,
291,
14,
885,
63,
2593,
275,
2653,
398,
1511,
275,
1862,
14,
362,
360,
8808,
297,
5009,
267,
1390,
63,
3189,
275,
1862,
14,
362,
360,
988,
63,
3189,
297,
1511,
14,
362,
360,
4283,
63,
1309,
23359,
297,
9601,
430,
267,
862,
26,
288,
291,
423,
988,
63,
3189,
275,
1109,
8,
988,
63,
3189,
9,
267,
871,
334,
3393,
12,
3146,
304,
288,
291,
423,
988,
63,
3189,
275,
9601,
398,
286,
979,
63,
11132,
275,
1862,
14,
362,
360,
67,
979,
63,
11132,
297,
1511,
14,
362,
360,
35,
3785,
63,
38,
5255,
17059,
297,
650,
430,
267,
862,
26,
288,
291,
423,
67,
979,
63,
11132,
275,
1109,
8,
67,
979,
63,
11132,
9,
267,
871,
334,
3393,
12,
3146,
304,
288,
291,
423,
67,
979,
63,
11132,
275,
650,
398,
291,
14,
498,
63,
1861,
275,
1862,
14,
362,
360,
3078,
63,
6351,
297,
4074,
267,
291,
14,
1023,
275,
1862,
14,
362,
360,
4612,
297,
413,
9,
267,
291,
14,
498,
63,
1532,
275,
664,
63,
498,
63,
1532,
8,
1162,
14,
362,
360,
3078,
63,
15476,
1333,
339,
347,
664,
63,
4620,
63,
2593,
8,
277,
12,
2653,
29,
3472,
63,
8899,
304,
267,
408,
267,
1803,
314,
2653,
574,
18025,
701,
642,
4865,
4079,
12188,
314,
2741,
267,
2653,
14,
267,
408,
267,
340,
2653,
508,
6186,
63,
8899,
26,
288,
2653,
275,
291,
14,
885,
63,
2593,
267,
916,
2653,
508,
378,
26,
288,
327,
12052,
30301,
2417,
446,
5126,
900,
14,
521,
342,
4048,
7151,
10876,
288,
2653,
275,
446,
17,
267,
372,
488,
340,
2653,
365,
488,
587,
900,
14,
521,
342,
435,
2653,
339,
347,
1852,
63,
498,
8,
277,
12,
790,
12,
1015,
29,
403,
304,
267,
408,
27943,
314,
790,
1202,
701,
1006,
1163,
3102,
14,
4885,
849,
652,
267,
4440,
314,
790,
63,
1532,
370,
3550,
282,
790,
334,
6777,
12,
701,
849,
12,
267,
19986,
3198,
314,
658,
498,
63,
1861,
7,
436,
283,
1023,
1959,
1626,
3365,
790,
267,
805,
883,
506,
2741,
737,
314,
900,
402,
2581,
14538,
27,
267,
8679,
17330,
12,
1265,
883,
5516,
314,
2581,
4865,
370,
5647,
267,
3537,
790,
10663,
5953,
14,
267,
408,
267,
340,
1015,
365,
488,
26,
288,
1015,
275,
291,
14,
1023,
398,
892,
63,
498,
275,
291,
14,
498,
63,
1532,
8,
498,
12,
291,
14,
498,
63,
1861,
12,
1015,
9,
267,
372,
892,
63,
498,
339,
347,
1050,
8,
277,
12,
790,
12,
574,
12,
2653,
29,
3472,
63,
8899,
12,
1015,
29,
403,
304,
267,
408,
267,
2494,
282,
574,
315,
314,
2581,
340,
314,
790,
1630,
440,
2575,
2187,
14,
982,
267,
2653,
365,
1627,
12,
626,
2653,
911,
506,
1202,
367,
314,
790,
27,
4257,
267,
314,
849,
2581,
2653,
911,
506,
1202,
14,
398,
1803,
715,
340,
314,
574,
1990,
5489,
12,
756,
4257,
14,
267,
408,
267,
746,
4279,
360,
19094,
402,
3523,
4437,
1471,
5647,
376,
1050,
342,
1083,
358,
339,
347,
664,
8,
277,
12,
790,
12,
849,
29,
403,
12,
1015,
29,
403,
304,
267,
408,
267,
16347,
282,
1627,
790,
687,
314,
2581,
14,
982,
314,
790,
1630,
440,
2187,
12,
372,
267,
849,
12,
1314,
6337,
4243,
370,
488,
14,
267,
408,
267,
746,
4279,
360,
19094,
402,
3523,
4437,
1471,
5647,
282,
664,
342,
1083,
358,
339,
347,
663,
8,
277,
12,
790,
12,
574,
12,
2653,
29,
3472,
63,
8899,
12,
1015,
29,
403,
304,
267,
408,
267,
2494,
282,
574,
315,
314,
2581,
14,
982,
2653,
365,
1627,
12,
626,
2653,
911,
506,
267,
1202,
367,
314,
790,
27,
4257,
314,
849,
2581,
2653,
911,
506,
1202,
14,
267,
408,
267,
746,
4279,
360,
19094,
402,
3523,
4437,
1471,
5647,
282,
663,
342,
1083,
358,
339,
347,
3145,
8,
277,
12,
790,
12,
1015,
29,
403,
304,
267,
408,
267,
8496,
282,
790,
687,
314,
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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
] |
jackytu/newbrandx
|
src/oscar/apps/dashboard/orders/app.py
|
49
|
2013
|
from django.conf.urls import url
from oscar.core.application import Application
from oscar.core.loading import get_class
class OrdersDashboardApplication(Application):
name = None
default_permissions = ['is_staff', ]
permissions_map = {
'order-list': (['is_staff'], ['partner.dashboard_access']),
'order-stats': (['is_staff'], ['partner.dashboard_access']),
'order-detail': (['is_staff'], ['partner.dashboard_access']),
'order-detail-note': (['is_staff'], ['partner.dashboard_access']),
'order-line-detail': (['is_staff'], ['partner.dashboard_access']),
'order-shipping-address': (['is_staff'], ['partner.dashboard_access']),
}
order_list_view = get_class('dashboard.orders.views', 'OrderListView')
order_detail_view = get_class('dashboard.orders.views', 'OrderDetailView')
shipping_address_view = get_class('dashboard.orders.views',
'ShippingAddressUpdateView')
line_detail_view = get_class('dashboard.orders.views', 'LineDetailView')
order_stats_view = get_class('dashboard.orders.views', 'OrderStatsView')
def get_urls(self):
urls = [
url(r'^$', self.order_list_view.as_view(), name='order-list'),
url(r'^statistics/$', self.order_stats_view.as_view(),
name='order-stats'),
url(r'^(?P<number>[-\w]+)/$',
self.order_detail_view.as_view(), name='order-detail'),
url(r'^(?P<number>[-\w]+)/notes/(?P<note_id>\d+)/$',
self.order_detail_view.as_view(), name='order-detail-note'),
url(r'^(?P<number>[-\w]+)/lines/(?P<line_id>\d+)/$',
self.line_detail_view.as_view(), name='order-line-detail'),
url(r'^(?P<number>[-\w]+)/shipping-address/$',
self.shipping_address_view.as_view(),
name='order-shipping-address'),
]
return self.post_process_urls(urls)
application = OrdersDashboardApplication()
|
bsd-3-clause
|
[
504,
1639,
14,
2190,
14,
3603,
492,
1166,
199,
199,
504,
312,
22707,
14,
1018,
14,
3578,
492,
13515,
199,
504,
312,
22707,
14,
1018,
14,
8786,
492,
664,
63,
533,
421,
199,
533,
4236,
7735,
30122,
5039,
8,
5039,
304,
272,
536,
275,
488,
272,
849,
63,
6060,
275,
788,
374,
63,
7018,
297,
1622,
272,
3443,
63,
1130,
275,
469,
267,
283,
1648,
13,
513,
356,
21022,
374,
63,
7018,
995,
788,
3899,
14,
9743,
63,
2732,
3815,
267,
283,
1648,
13,
3200,
356,
21022,
374,
63,
7018,
995,
788,
3899,
14,
9743,
63,
2732,
3815,
267,
283,
1648,
13,
5506,
356,
21022,
374,
63,
7018,
995,
788,
3899,
14,
9743,
63,
2732,
3815,
267,
283,
1648,
13,
5506,
13,
4610,
356,
21022,
374,
63,
7018,
995,
788,
3899,
14,
9743,
63,
2732,
3815,
267,
283,
1648,
13,
604,
13,
5506,
356,
21022,
374,
63,
7018,
995,
788,
3899,
14,
9743,
63,
2732,
3815,
267,
283,
1648,
13,
17801,
13,
1562,
356,
21022,
374,
63,
7018,
995,
788,
3899,
14,
9743,
63,
2732,
3815,
272,
789,
339,
1865,
63,
513,
63,
1345,
275,
664,
63,
533,
360,
9743,
14,
14387,
14,
4196,
297,
283,
4738,
23239,
358,
272,
1865,
63,
5506,
63,
1345,
275,
664,
63,
533,
360,
9743,
14,
14387,
14,
4196,
297,
283,
4738,
28539,
358,
272,
27490,
63,
1562,
63,
1345,
275,
664,
63,
533,
360,
9743,
14,
14387,
14,
4196,
297,
4228,
283,
30707,
4073,
1476,
4152,
2768,
358,
272,
1004,
63,
5506,
63,
1345,
275,
664,
63,
533,
360,
9743,
14,
14387,
14,
4196,
297,
283,
3049,
28539,
358,
272,
1865,
63,
3200,
63,
1345,
275,
664,
63,
533,
360,
9743,
14,
14387,
14,
4196,
297,
283,
4738,
8257,
2768,
358,
339,
347,
664,
63,
3603,
8,
277,
304,
267,
8187,
275,
359,
288,
1166,
8,
82,
4289,
4268,
291,
14,
1648,
63,
513,
63,
1345,
14,
305,
63,
1345,
1062,
536,
534,
1648,
13,
513,
659,
288,
1166,
8,
82,
4289,
13724,
10884,
291,
14,
1648,
63,
3200,
63,
1345,
14,
305,
63,
1345,
1062,
355,
536,
534,
1648,
13,
3200,
659,
288,
1166,
8,
82,
24550,
48,
28,
1955,
30,
1988,
60,
87,
24598,
4268,
355,
291,
14,
1648,
63,
5506,
63,
1345,
14,
305,
63,
1345,
1062,
536,
534,
1648,
13,
5506,
659,
288,
1166,
8,
82,
24550,
48,
28,
1955,
30,
1988,
60,
87,
24598,
5983,
9448,
48,
28,
4610,
63,
344,
3072,
68,
18830,
4268,
355,
291,
14,
1648,
63,
5506,
63,
1345,
14,
305,
63,
1345,
1062,
536,
534,
1648,
13,
5506,
13,
4610,
659,
288,
1166,
8,
82,
24550,
48,
28,
1955,
30,
1988,
60,
87,
24598,
1278,
9448,
48,
28,
604,
63,
344,
3072,
68,
18830,
4268,
355,
291,
14,
604,
63,
5506,
63,
1345,
14,
305,
63,
1345,
1062,
536,
534,
1648,
13,
604,
13,
5506,
659,
288,
1166,
8,
82,
24550,
48,
28,
1955,
30,
1988,
60,
87,
24598,
17801,
13,
1562,
10884,
355,
291,
14,
17801,
63,
1562,
63,
1345,
14,
305,
63,
1345,
1062,
355,
536,
534,
1648,
13,
17801,
13,
1562,
659,
267,
1622,
267,
372,
291,
14,
1932,
63,
1412,
63,
3603,
8,
3603,
9,
421,
199,
3578,
275,
4236,
7735,
30122,
5039,
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
] |
[
1639,
14,
2190,
14,
3603,
492,
1166,
199,
199,
504,
312,
22707,
14,
1018,
14,
3578,
492,
13515,
199,
504,
312,
22707,
14,
1018,
14,
8786,
492,
664,
63,
533,
421,
199,
533,
4236,
7735,
30122,
5039,
8,
5039,
304,
272,
536,
275,
488,
272,
849,
63,
6060,
275,
788,
374,
63,
7018,
297,
1622,
272,
3443,
63,
1130,
275,
469,
267,
283,
1648,
13,
513,
356,
21022,
374,
63,
7018,
995,
788,
3899,
14,
9743,
63,
2732,
3815,
267,
283,
1648,
13,
3200,
356,
21022,
374,
63,
7018,
995,
788,
3899,
14,
9743,
63,
2732,
3815,
267,
283,
1648,
13,
5506,
356,
21022,
374,
63,
7018,
995,
788,
3899,
14,
9743,
63,
2732,
3815,
267,
283,
1648,
13,
5506,
13,
4610,
356,
21022,
374,
63,
7018,
995,
788,
3899,
14,
9743,
63,
2732,
3815,
267,
283,
1648,
13,
604,
13,
5506,
356,
21022,
374,
63,
7018,
995,
788,
3899,
14,
9743,
63,
2732,
3815,
267,
283,
1648,
13,
17801,
13,
1562,
356,
21022,
374,
63,
7018,
995,
788,
3899,
14,
9743,
63,
2732,
3815,
272,
789,
339,
1865,
63,
513,
63,
1345,
275,
664,
63,
533,
360,
9743,
14,
14387,
14,
4196,
297,
283,
4738,
23239,
358,
272,
1865,
63,
5506,
63,
1345,
275,
664,
63,
533,
360,
9743,
14,
14387,
14,
4196,
297,
283,
4738,
28539,
358,
272,
27490,
63,
1562,
63,
1345,
275,
664,
63,
533,
360,
9743,
14,
14387,
14,
4196,
297,
4228,
283,
30707,
4073,
1476,
4152,
2768,
358,
272,
1004,
63,
5506,
63,
1345,
275,
664,
63,
533,
360,
9743,
14,
14387,
14,
4196,
297,
283,
3049,
28539,
358,
272,
1865,
63,
3200,
63,
1345,
275,
664,
63,
533,
360,
9743,
14,
14387,
14,
4196,
297,
283,
4738,
8257,
2768,
358,
339,
347,
664,
63,
3603,
8,
277,
304,
267,
8187,
275,
359,
288,
1166,
8,
82,
4289,
4268,
291,
14,
1648,
63,
513,
63,
1345,
14,
305,
63,
1345,
1062,
536,
534,
1648,
13,
513,
659,
288,
1166,
8,
82,
4289,
13724,
10884,
291,
14,
1648,
63,
3200,
63,
1345,
14,
305,
63,
1345,
1062,
355,
536,
534,
1648,
13,
3200,
659,
288,
1166,
8,
82,
24550,
48,
28,
1955,
30,
1988,
60,
87,
24598,
4268,
355,
291,
14,
1648,
63,
5506,
63,
1345,
14,
305,
63,
1345,
1062,
536,
534,
1648,
13,
5506,
659,
288,
1166,
8,
82,
24550,
48,
28,
1955,
30,
1988,
60,
87,
24598,
5983,
9448,
48,
28,
4610,
63,
344,
3072,
68,
18830,
4268,
355,
291,
14,
1648,
63,
5506,
63,
1345,
14,
305,
63,
1345,
1062,
536,
534,
1648,
13,
5506,
13,
4610,
659,
288,
1166,
8,
82,
24550,
48,
28,
1955,
30,
1988,
60,
87,
24598,
1278,
9448,
48,
28,
604,
63,
344,
3072,
68,
18830,
4268,
355,
291,
14,
604,
63,
5506,
63,
1345,
14,
305,
63,
1345,
1062,
536,
534,
1648,
13,
604,
13,
5506,
659,
288,
1166,
8,
82,
24550,
48,
28,
1955,
30,
1988,
60,
87,
24598,
17801,
13,
1562,
10884,
355,
291,
14,
17801,
63,
1562,
63,
1345,
14,
305,
63,
1345,
1062,
355,
536,
534,
1648,
13,
17801,
13,
1562,
659,
267,
1622,
267,
372,
291,
14,
1932,
63,
1412,
63,
3603,
8,
3603,
9,
421,
199,
3578,
275,
4236,
7735,
30122,
5039,
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,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
olsaki/ansible-modules-extras
|
cloud/vmware/vmware_datacenter.py
|
3
|
5370
|
#!/usr/bin/python
# -*- coding: utf-8 -*-
# (c) 2015, Joseph Callen <jcallen () csc.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/>.
DOCUMENTATION = '''
---
module: vmware_datacenter
short_description: Manage VMware vSphere Datacenters
description:
- Manage VMware vSphere Datacenters
version_added: 2.0
author: Joseph Callen
notes:
- Tested on vSphere 5.5
requirements:
- PyVmomi
options:
hostname:
description:
- The hostname or IP address of the vSphere vCenter API server
required: True
username:
description:
- The username of the vSphere vCenter
required: True
aliases: ['user', 'admin']
password:
description:
- The password of the vSphere vCenter
required: True
aliases: ['pass', 'pwd']
datacenter_name:
description:
- The name of the datacenter the cluster will be created in.
required: True
state:
description:
- If the datacenter should be present or absent
choices: ['present', 'absent']
required: True
'''
EXAMPLES = '''
# Example vmware_datacenter command from Ansible Playbooks
- name: Create Datacenter
local_action: >
vmware_datacenter
hostname="{{ ansible_ssh_host }}" username=root password=vmware
datacenter_name="datacenter"
'''
try:
from pyVmomi import vim, vmodl
HAS_PYVMOMI = True
except ImportError:
HAS_PYVMOMI = False
def state_create_datacenter(module):
datacenter_name = module.params['datacenter_name']
content = module.params['content']
changed = True
datacenter = None
folder = content.rootFolder
try:
if not module.check_mode:
datacenter = folder.CreateDatacenter(name=datacenter_name)
module.exit_json(changed=changed, result=str(datacenter))
except vim.fault.DuplicateName:
module.fail_json(msg="A datacenter with the name %s already exists" % datacenter_name)
except vim.fault.InvalidName:
module.fail_json(msg="%s is an invalid name for a cluster" % datacenter_name)
except vmodl.fault.NotSupported:
# This should never happen
module.fail_json(msg="Trying to create a datacenter on an incorrect folder object")
except vmodl.RuntimeFault as runtime_fault:
module.fail_json(msg=runtime_fault.msg)
except vmodl.MethodFault as method_fault:
module.fail_json(msg=method_fault.msg)
def check_datacenter_state(module):
datacenter_name = module.params['datacenter_name']
try:
content = connect_to_api(module)
datacenter = find_datacenter_by_name(content, datacenter_name)
module.params['content'] = content
if datacenter is None:
return 'absent'
else:
module.params['datacenter'] = datacenter
return 'present'
except vmodl.RuntimeFault as runtime_fault:
module.fail_json(msg=runtime_fault.msg)
except vmodl.MethodFault as method_fault:
module.fail_json(msg=method_fault.msg)
def state_destroy_datacenter(module):
datacenter = module.params['datacenter']
changed = True
result = None
try:
if not module.check_mode:
task = datacenter.Destroy_Task()
changed, result = wait_for_task(task)
module.exit_json(changed=changed, result=result)
except vim.fault.VimFault as vim_fault:
module.fail_json(msg=vim_fault.msg)
except vmodl.RuntimeFault as runtime_fault:
module.fail_json(msg=runtime_fault.msg)
except vmodl.MethodFault as method_fault:
module.fail_json(msg=method_fault.msg)
def state_exit_unchanged(module):
module.exit_json(changed=False)
def main():
argument_spec = vmware_argument_spec()
argument_spec.update(
dict(
datacenter_name=dict(required=True, type='str'),
state=dict(required=True, choices=['present', 'absent'], type='str'),
)
)
module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True)
if not HAS_PYVMOMI:
module.fail_json(msg='pyvmomi is required for this module')
datacenter_states = {
'absent': {
'present': state_destroy_datacenter,
'absent': state_exit_unchanged,
},
'present': {
'present': state_exit_unchanged,
'absent': state_create_datacenter,
}
}
desired_state = module.params['state']
current_state = check_datacenter_state(module)
datacenter_states[desired_state][current_state](module)
from ansible.module_utils.basic import *
from ansible.module_utils.vmware import *
if __name__ == '__main__':
main()
|
gpl-3.0
|
[
3381,
2647,
15,
1393,
15,
1548,
199,
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
199,
3,
334,
67,
9,
6900,
12,
1603,
3362,
838,
445,
7670,
665,
74,
915,
552,
6248,
28308,
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,
8948,
275,
1449,
199,
2595,
199,
578,
26,
19365,
63,
17770,
199,
3612,
63,
1802,
26,
14944,
27391,
373,
22385,
3918,
15660,
199,
1802,
26,
272,
446,
14944,
27391,
373,
22385,
3918,
15660,
199,
1023,
63,
3270,
26,
499,
14,
16,
199,
2502,
26,
1603,
3362,
838,
445,
7670,
199,
5983,
26,
272,
446,
30568,
641,
373,
22385,
959,
14,
21,
199,
7538,
26,
272,
446,
1611,
54,
28603,
199,
1419,
26,
272,
6246,
26,
267,
1369,
26,
288,
446,
710,
6246,
503,
3531,
2287,
402,
314,
373,
22385,
373,
13551,
3261,
1654,
267,
1415,
26,
715,
272,
3434,
26,
267,
1369,
26,
288,
446,
710,
3434,
402,
314,
373,
22385,
373,
13551,
267,
1415,
26,
715,
267,
5481,
26,
788,
751,
297,
283,
2113,
418,
272,
2505,
26,
267,
1369,
26,
288,
446,
710,
2505,
402,
314,
373,
22385,
373,
13551,
267,
1415,
26,
715,
267,
5481,
26,
788,
1529,
297,
283,
14258,
418,
272,
16606,
63,
354,
26,
267,
1369,
26,
288,
446,
710,
536,
402,
314,
16606,
314,
4350,
911,
506,
2737,
315,
14,
267,
1415,
26,
715,
272,
1174,
26,
267,
1369,
26,
288,
446,
982,
314,
16606,
1077,
506,
3451,
503,
9552,
267,
3415,
26,
788,
1881,
297,
283,
5575,
418,
267,
1415,
26,
715,
199,
2344,
199,
199,
8918,
275,
1449,
199,
3,
5679,
19365,
63,
17770,
1414,
687,
2622,
16527,
8858,
199,
13,
536,
26,
2790,
3918,
4218,
489,
2257,
63,
1287,
26,
690,
267,
19365,
63,
17770,
267,
6246,
628,
3638,
3242,
63,
5510,
63,
1102,
7820,
3434,
29,
1231,
2505,
29,
18970,
267,
16606,
63,
354,
628,
17770,
2,
199,
2344,
199,
199,
893,
26,
272,
687,
1134,
54,
28603,
492,
6695,
12,
373,
1494,
76,
272,
7509,
63,
4521,
54,
2679,
10709,
275,
715,
199,
2590,
3545,
26,
272,
7509,
63,
4521,
54,
2679,
10709,
275,
756,
421,
199,
318,
1174,
63,
981,
63,
17770,
8,
578,
304,
272,
16606,
63,
354,
275,
859,
14,
1162,
459,
17770,
63,
354,
418,
272,
1564,
275,
859,
14,
1162,
459,
1317,
418,
272,
2896,
275,
715,
272,
16606,
275,
488,
339,
4922,
275,
1564,
14,
1231,
7850,
339,
862,
26,
267,
340,
440,
859,
14,
1074,
63,
632,
26,
288,
16606,
275,
4922,
14,
2499,
1451,
4218,
8,
354,
29,
17770,
63,
354,
9,
267,
859,
14,
2224,
63,
1001,
8,
2489,
29,
2489,
12,
754,
29,
495,
8,
17770,
430,
272,
871,
6695,
14,
1879,
14,
14773,
985,
26,
267,
859,
14,
1633,
63,
1001,
8,
1328,
628,
33,
16606,
543,
314,
536,
450,
83,
2575,
3495,
2,
450,
16606,
63,
354,
9,
272,
871,
6695,
14,
1879,
14,
3364,
985,
26,
267,
859,
14,
1633,
63,
1001,
8,
1328,
5961,
83,
365,
376,
3866,
536,
367,
282,
4350,
2,
450,
16606,
63,
354,
9,
272,
871,
373,
1494,
76,
14,
1879,
14,
26077,
26,
267,
327,
961,
1077,
7078,
5992,
267,
859,
14,
1633,
63,
1001,
8,
1328,
628,
27693,
370,
1218,
282,
16606,
641,
376,
8927,
4922,
909,
531,
272,
871,
373,
1494,
76,
14,
14357,
16665,
465,
8836,
63,
1879,
26,
267,
859,
14,
1633,
63,
1001,
8,
1328,
29,
7726,
63,
1879,
14,
1328,
9,
272,
871,
373,
1494,
76,
14,
3767,
16665,
465,
1083,
63,
1879,
26,
267,
859,
14,
1633,
63,
1001,
8,
1328,
29,
765,
63,
1879,
14,
1328,
9,
421,
199,
318,
1104,
63,
17770,
63,
929,
8,
578,
304,
272,
16606,
63,
354,
275,
859,
14,
1162,
459,
17770,
63,
354,
418,
339,
862,
26,
267,
1564,
275,
4907,
63,
475,
63,
1246,
8,
578,
9,
267,
16606,
275,
2342,
63,
17770,
63,
991,
63,
354,
8,
1317,
12,
16606,
63,
354,
9,
267,
859,
14,
1162,
459,
1317,
418,
275,
1564,
398,
340,
16606,
365,
488,
26,
288,
372,
283,
5575,
7,
267,
587,
26,
288,
859,
14,
1162,
459,
17770,
418,
275,
16606,
288,
372,
283,
1881,
7,
272,
871,
373,
1494,
76,
14,
14357,
16665,
465,
8836,
63,
1879,
26,
267,
859,
14,
1633,
63,
1001,
8,
1328,
29,
7726,
63,
1879,
14,
1328,
9,
272,
871,
373,
1494,
76,
14,
3767,
16665,
465,
1083,
63,
1879,
26,
267,
859,
14,
1633,
63,
1001,
8,
1328,
29,
765,
63,
1879,
14,
1328,
9,
421,
199,
318,
1174,
63,
7237,
63,
17770,
8,
578,
304,
272,
16606,
275,
859,
14,
1162,
459,
17770,
418,
272,
2896,
275,
715,
272,
754,
275,
488,
339,
862,
26,
267,
340,
440,
859,
14,
1074,
63,
632,
26,
288,
2120,
275,
16606,
14,
14704,
63,
4476,
342,
288,
2896,
12,
754,
275,
3618,
63,
509,
63,
1765,
8,
1765,
9,
267,
859,
14,
2224,
63,
1001,
8,
2489,
29,
2489,
12,
754,
29,
1099,
9,
272,
871,
6695,
14,
1879,
14,
54,
1017,
16665,
465,
6695,
63,
1879,
26,
267,
859,
14,
1633,
63,
1001,
8,
1328,
29,
16361,
63,
1879,
14,
1328,
9,
272,
871,
373,
1494,
76,
14,
14357,
16665,
465,
8836,
63,
1879,
26,
267,
859,
14,
1633
] |
[
2647,
15,
1393,
15,
1548,
199,
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
199,
3,
334,
67,
9,
6900,
12,
1603,
3362,
838,
445,
7670,
665,
74,
915,
552,
6248,
28308,
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,
8948,
275,
1449,
199,
2595,
199,
578,
26,
19365,
63,
17770,
199,
3612,
63,
1802,
26,
14944,
27391,
373,
22385,
3918,
15660,
199,
1802,
26,
272,
446,
14944,
27391,
373,
22385,
3918,
15660,
199,
1023,
63,
3270,
26,
499,
14,
16,
199,
2502,
26,
1603,
3362,
838,
445,
7670,
199,
5983,
26,
272,
446,
30568,
641,
373,
22385,
959,
14,
21,
199,
7538,
26,
272,
446,
1611,
54,
28603,
199,
1419,
26,
272,
6246,
26,
267,
1369,
26,
288,
446,
710,
6246,
503,
3531,
2287,
402,
314,
373,
22385,
373,
13551,
3261,
1654,
267,
1415,
26,
715,
272,
3434,
26,
267,
1369,
26,
288,
446,
710,
3434,
402,
314,
373,
22385,
373,
13551,
267,
1415,
26,
715,
267,
5481,
26,
788,
751,
297,
283,
2113,
418,
272,
2505,
26,
267,
1369,
26,
288,
446,
710,
2505,
402,
314,
373,
22385,
373,
13551,
267,
1415,
26,
715,
267,
5481,
26,
788,
1529,
297,
283,
14258,
418,
272,
16606,
63,
354,
26,
267,
1369,
26,
288,
446,
710,
536,
402,
314,
16606,
314,
4350,
911,
506,
2737,
315,
14,
267,
1415,
26,
715,
272,
1174,
26,
267,
1369,
26,
288,
446,
982,
314,
16606,
1077,
506,
3451,
503,
9552,
267,
3415,
26,
788,
1881,
297,
283,
5575,
418,
267,
1415,
26,
715,
199,
2344,
199,
199,
8918,
275,
1449,
199,
3,
5679,
19365,
63,
17770,
1414,
687,
2622,
16527,
8858,
199,
13,
536,
26,
2790,
3918,
4218,
489,
2257,
63,
1287,
26,
690,
267,
19365,
63,
17770,
267,
6246,
628,
3638,
3242,
63,
5510,
63,
1102,
7820,
3434,
29,
1231,
2505,
29,
18970,
267,
16606,
63,
354,
628,
17770,
2,
199,
2344,
199,
199,
893,
26,
272,
687,
1134,
54,
28603,
492,
6695,
12,
373,
1494,
76,
272,
7509,
63,
4521,
54,
2679,
10709,
275,
715,
199,
2590,
3545,
26,
272,
7509,
63,
4521,
54,
2679,
10709,
275,
756,
421,
199,
318,
1174,
63,
981,
63,
17770,
8,
578,
304,
272,
16606,
63,
354,
275,
859,
14,
1162,
459,
17770,
63,
354,
418,
272,
1564,
275,
859,
14,
1162,
459,
1317,
418,
272,
2896,
275,
715,
272,
16606,
275,
488,
339,
4922,
275,
1564,
14,
1231,
7850,
339,
862,
26,
267,
340,
440,
859,
14,
1074,
63,
632,
26,
288,
16606,
275,
4922,
14,
2499,
1451,
4218,
8,
354,
29,
17770,
63,
354,
9,
267,
859,
14,
2224,
63,
1001,
8,
2489,
29,
2489,
12,
754,
29,
495,
8,
17770,
430,
272,
871,
6695,
14,
1879,
14,
14773,
985,
26,
267,
859,
14,
1633,
63,
1001,
8,
1328,
628,
33,
16606,
543,
314,
536,
450,
83,
2575,
3495,
2,
450,
16606,
63,
354,
9,
272,
871,
6695,
14,
1879,
14,
3364,
985,
26,
267,
859,
14,
1633,
63,
1001,
8,
1328,
5961,
83,
365,
376,
3866,
536,
367,
282,
4350,
2,
450,
16606,
63,
354,
9,
272,
871,
373,
1494,
76,
14,
1879,
14,
26077,
26,
267,
327,
961,
1077,
7078,
5992,
267,
859,
14,
1633,
63,
1001,
8,
1328,
628,
27693,
370,
1218,
282,
16606,
641,
376,
8927,
4922,
909,
531,
272,
871,
373,
1494,
76,
14,
14357,
16665,
465,
8836,
63,
1879,
26,
267,
859,
14,
1633,
63,
1001,
8,
1328,
29,
7726,
63,
1879,
14,
1328,
9,
272,
871,
373,
1494,
76,
14,
3767,
16665,
465,
1083,
63,
1879,
26,
267,
859,
14,
1633,
63,
1001,
8,
1328,
29,
765,
63,
1879,
14,
1328,
9,
421,
199,
318,
1104,
63,
17770,
63,
929,
8,
578,
304,
272,
16606,
63,
354,
275,
859,
14,
1162,
459,
17770,
63,
354,
418,
339,
862,
26,
267,
1564,
275,
4907,
63,
475,
63,
1246,
8,
578,
9,
267,
16606,
275,
2342,
63,
17770,
63,
991,
63,
354,
8,
1317,
12,
16606,
63,
354,
9,
267,
859,
14,
1162,
459,
1317,
418,
275,
1564,
398,
340,
16606,
365,
488,
26,
288,
372,
283,
5575,
7,
267,
587,
26,
288,
859,
14,
1162,
459,
17770,
418,
275,
16606,
288,
372,
283,
1881,
7,
272,
871,
373,
1494,
76,
14,
14357,
16665,
465,
8836,
63,
1879,
26,
267,
859,
14,
1633,
63,
1001,
8,
1328,
29,
7726,
63,
1879,
14,
1328,
9,
272,
871,
373,
1494,
76,
14,
3767,
16665,
465,
1083,
63,
1879,
26,
267,
859,
14,
1633,
63,
1001,
8,
1328,
29,
765,
63,
1879,
14,
1328,
9,
421,
199,
318,
1174,
63,
7237,
63,
17770,
8,
578,
304,
272,
16606,
275,
859,
14,
1162,
459,
17770,
418,
272,
2896,
275,
715,
272,
754,
275,
488,
339,
862,
26,
267,
340,
440,
859,
14,
1074,
63,
632,
26,
288,
2120,
275,
16606,
14,
14704,
63,
4476,
342,
288,
2896,
12,
754,
275,
3618,
63,
509,
63,
1765,
8,
1765,
9,
267,
859,
14,
2224,
63,
1001,
8,
2489,
29,
2489,
12,
754,
29,
1099,
9,
272,
871,
6695,
14,
1879,
14,
54,
1017,
16665,
465,
6695,
63,
1879,
26,
267,
859,
14,
1633,
63,
1001,
8,
1328,
29,
16361,
63,
1879,
14,
1328,
9,
272,
871,
373,
1494,
76,
14,
14357,
16665,
465,
8836,
63,
1879,
26,
267,
859,
14,
1633,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
jmesteve/openerpseda
|
openerp/addons/project/report/__init__.py
|
444
|
1069
|
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import project_report
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
agpl-3.0
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
4605,
199,
3,
199,
3,
259,
7653,
12,
3232,
5800,
8259,
9274,
199,
3,
259,
1898,
334,
35,
9,
8353,
13,
6542,
11947,
12361,
8642,
1014,
921,
9864,
14,
1235,
10121,
199,
3,
199,
3,
259,
961,
2240,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
259,
652,
1334,
314,
2895,
402,
314,
1664,
4265,
1696,
1684,
844,
465,
199,
3,
259,
3267,
701,
314,
2868,
2290,
2752,
12,
1902,
1015,
650,
402,
314,
199,
3,
259,
844,
12,
503,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
259,
961,
2240,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
259,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
259,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
199,
3,
259,
1664,
4265,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
259,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
4265,
1696,
1684,
844,
199,
3,
259,
3180,
543,
642,
2240,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
3,
199,
4605,
199,
199,
646,
2199,
63,
3070,
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,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
4605,
199,
3,
199,
3,
259,
7653,
12,
3232,
5800,
8259,
9274,
199,
3,
259,
1898,
334,
35,
9,
8353,
13,
6542,
11947,
12361,
8642,
1014,
921,
9864,
14,
1235,
10121,
199,
3,
199,
3,
259,
961,
2240,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
259,
652,
1334,
314,
2895,
402,
314,
1664,
4265,
1696,
1684,
844,
465,
199,
3,
259,
3267,
701,
314,
2868,
2290,
2752,
12,
1902,
1015,
650,
402,
314,
199,
3,
259,
844,
12,
503,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
259,
961,
2240,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
259,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
259,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
199,
3,
259,
1664,
4265,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
259,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
4265,
1696,
1684,
844,
199,
3,
259,
3180,
543,
642,
2240,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
3,
199,
4605,
199,
199,
646,
2199,
63,
3070,
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,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,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sdphome/UHF_Reader
|
rfs/rootfs/usr/lib/python2.7/_abcoll.py
|
14
|
18415
|
# Copyright 2007 Google, Inc. All Rights Reserved.
# Licensed to PSF under a Contributor Agreement.
"""Abstract Base Classes (ABCs) for collections, according to PEP 3119.
DON'T USE THIS MODULE DIRECTLY! The classes here should be imported
via collections; they are defined here only to alleviate certain
bootstrapping issues. Unit tests are in test_collections.
"""
from abc import ABCMeta, abstractmethod
import sys
__all__ = ["Hashable", "Iterable", "Iterator",
"Sized", "Container", "Callable",
"Set", "MutableSet",
"Mapping", "MutableMapping",
"MappingView", "KeysView", "ItemsView", "ValuesView",
"Sequence", "MutableSequence",
]
### ONE-TRICK PONIES ###
def _hasattr(C, attr):
try:
return any(attr in B.__dict__ for B in C.__mro__)
except AttributeError:
# Old-style class
return hasattr(C, attr)
class Hashable:
__metaclass__ = ABCMeta
@abstractmethod
def __hash__(self):
return 0
@classmethod
def __subclasshook__(cls, C):
if cls is Hashable:
try:
for B in C.__mro__:
if "__hash__" in B.__dict__:
if B.__dict__["__hash__"]:
return True
break
except AttributeError:
# Old-style class
if getattr(C, "__hash__", None):
return True
return NotImplemented
class Iterable:
__metaclass__ = ABCMeta
@abstractmethod
def __iter__(self):
while False:
yield None
@classmethod
def __subclasshook__(cls, C):
if cls is Iterable:
if _hasattr(C, "__iter__"):
return True
return NotImplemented
Iterable.register(str)
class Iterator(Iterable):
@abstractmethod
def next(self):
'Return the next item from the iterator. When exhausted, raise StopIteration'
raise StopIteration
def __iter__(self):
return self
@classmethod
def __subclasshook__(cls, C):
if cls is Iterator:
if _hasattr(C, "next") and _hasattr(C, "__iter__"):
return True
return NotImplemented
class Sized:
__metaclass__ = ABCMeta
@abstractmethod
def __len__(self):
return 0
@classmethod
def __subclasshook__(cls, C):
if cls is Sized:
if _hasattr(C, "__len__"):
return True
return NotImplemented
class Container:
__metaclass__ = ABCMeta
@abstractmethod
def __contains__(self, x):
return False
@classmethod
def __subclasshook__(cls, C):
if cls is Container:
if _hasattr(C, "__contains__"):
return True
return NotImplemented
class Callable:
__metaclass__ = ABCMeta
@abstractmethod
def __call__(self, *args, **kwds):
return False
@classmethod
def __subclasshook__(cls, C):
if cls is Callable:
if _hasattr(C, "__call__"):
return True
return NotImplemented
### SETS ###
class Set(Sized, Iterable, Container):
"""A set is a finite, iterable container.
This class provides concrete generic implementations of all
methods except for __contains__, __iter__ and __len__.
To override the comparisons (presumably for speed, as the
semantics are fixed), redefine __le__ and __ge__,
then the other operations will automatically follow suit.
"""
def __le__(self, other):
if not isinstance(other, Set):
return NotImplemented
if len(self) > len(other):
return False
for elem in self:
if elem not in other:
return False
return True
def __lt__(self, other):
if not isinstance(other, Set):
return NotImplemented
return len(self) < len(other) and self.__le__(other)
def __gt__(self, other):
if not isinstance(other, Set):
return NotImplemented
return len(self) > len(other) and self.__ge__(other)
def __ge__(self, other):
if not isinstance(other, Set):
return NotImplemented
if len(self) < len(other):
return False
for elem in other:
if elem not in self:
return False
return True
def __eq__(self, other):
if not isinstance(other, Set):
return NotImplemented
return len(self) == len(other) and self.__le__(other)
def __ne__(self, other):
return not (self == other)
@classmethod
def _from_iterable(cls, it):
'''Construct an instance of the class from any iterable input.
Must override this method if the class constructor signature
does not accept an iterable for an input.
'''
return cls(it)
def __and__(self, other):
if not isinstance(other, Iterable):
return NotImplemented
return self._from_iterable(value for value in other if value in self)
__rand__ = __and__
def isdisjoint(self, other):
'Return True if two sets have a null intersection.'
for value in other:
if value in self:
return False
return True
def __or__(self, other):
if not isinstance(other, Iterable):
return NotImplemented
chain = (e for s in (self, other) for e in s)
return self._from_iterable(chain)
__ror__ = __or__
def __sub__(self, other):
if not isinstance(other, Set):
if not isinstance(other, Iterable):
return NotImplemented
other = self._from_iterable(other)
return self._from_iterable(value for value in self
if value not in other)
def __rsub__(self, other):
if not isinstance(other, Set):
if not isinstance(other, Iterable):
return NotImplemented
other = self._from_iterable(other)
return self._from_iterable(value for value in other
if value not in self)
def __xor__(self, other):
if not isinstance(other, Set):
if not isinstance(other, Iterable):
return NotImplemented
other = self._from_iterable(other)
return (self - other) | (other - self)
__rxor__ = __xor__
# Sets are not hashable by default, but subclasses can change this
__hash__ = None
def _hash(self):
"""Compute the hash value of a set.
Note that we don't define __hash__: not all sets are hashable.
But if you define a hashable set type, its __hash__ should
call this function.
This must be compatible __eq__.
All sets ought to compare equal if they contain the same
elements, regardless of how they are implemented, and
regardless of the order of the elements; so there's not much
freedom for __eq__ or __hash__. We match the algorithm used
by the built-in frozenset type.
"""
MAX = sys.maxint
MASK = 2 * MAX + 1
n = len(self)
h = 1927868237 * (n + 1)
h &= MASK
for x in self:
hx = hash(x)
h ^= (hx ^ (hx << 16) ^ 89869747) * 3644798167
h &= MASK
h = h * 69069 + 907133923
h &= MASK
if h > MAX:
h -= MASK + 1
if h == -1:
h = 590923713
return h
Set.register(frozenset)
class MutableSet(Set):
"""A mutable set is a finite, iterable container.
This class provides concrete generic implementations of all
methods except for __contains__, __iter__, __len__,
add(), and discard().
To override the comparisons (presumably for speed, as the
semantics are fixed), all you have to do is redefine __le__ and
then the other operations will automatically follow suit.
"""
@abstractmethod
def add(self, value):
"""Add an element."""
raise NotImplementedError
@abstractmethod
def discard(self, value):
"""Remove an element. Do not raise an exception if absent."""
raise NotImplementedError
def remove(self, value):
"""Remove an element. If not a member, raise a KeyError."""
if value not in self:
raise KeyError(value)
self.discard(value)
def pop(self):
"""Return the popped value. Raise KeyError if empty."""
it = iter(self)
try:
value = next(it)
except StopIteration:
raise KeyError
self.discard(value)
return value
def clear(self):
"""This is slow (creates N new iterators!) but effective."""
try:
while True:
self.pop()
except KeyError:
pass
def __ior__(self, it):
for value in it:
self.add(value)
return self
def __iand__(self, it):
for value in (self - it):
self.discard(value)
return self
def __ixor__(self, it):
if it is self:
self.clear()
else:
if not isinstance(it, Set):
it = self._from_iterable(it)
for value in it:
if value in self:
self.discard(value)
else:
self.add(value)
return self
def __isub__(self, it):
if it is self:
self.clear()
else:
for value in it:
self.discard(value)
return self
MutableSet.register(set)
### MAPPINGS ###
class Mapping(Sized, Iterable, Container):
"""A Mapping is a generic container for associating key/value
pairs.
This class provides concrete generic implementations of all
methods except for __getitem__, __iter__, and __len__.
"""
@abstractmethod
def __getitem__(self, key):
raise KeyError
def get(self, key, default=None):
'D.get(k[,d]) -> D[k] if k in D, else d. d defaults to None.'
try:
return self[key]
except KeyError:
return default
def __contains__(self, key):
try:
self[key]
except KeyError:
return False
else:
return True
def iterkeys(self):
'D.iterkeys() -> an iterator over the keys of D'
return iter(self)
def itervalues(self):
'D.itervalues() -> an iterator over the values of D'
for key in self:
yield self[key]
def iteritems(self):
'D.iteritems() -> an iterator over the (key, value) items of D'
for key in self:
yield (key, self[key])
def keys(self):
"D.keys() -> list of D's keys"
return list(self)
def items(self):
"D.items() -> list of D's (key, value) pairs, as 2-tuples"
return [(key, self[key]) for key in self]
def values(self):
"D.values() -> list of D's values"
return [self[key] for key in self]
# Mappings are not hashable by default, but subclasses can change this
__hash__ = None
def __eq__(self, other):
if not isinstance(other, Mapping):
return NotImplemented
return dict(self.items()) == dict(other.items())
def __ne__(self, other):
return not (self == other)
class MappingView(Sized):
def __init__(self, mapping):
self._mapping = mapping
def __len__(self):
return len(self._mapping)
def __repr__(self):
return '{0.__class__.__name__}({0._mapping!r})'.format(self)
class KeysView(MappingView, Set):
@classmethod
def _from_iterable(self, it):
return set(it)
def __contains__(self, key):
return key in self._mapping
def __iter__(self):
for key in self._mapping:
yield key
class ItemsView(MappingView, Set):
@classmethod
def _from_iterable(self, it):
return set(it)
def __contains__(self, item):
key, value = item
try:
v = self._mapping[key]
except KeyError:
return False
else:
return v == value
def __iter__(self):
for key in self._mapping:
yield (key, self._mapping[key])
class ValuesView(MappingView):
def __contains__(self, value):
for key in self._mapping:
if value == self._mapping[key]:
return True
return False
def __iter__(self):
for key in self._mapping:
yield self._mapping[key]
class MutableMapping(Mapping):
"""A MutableMapping is a generic container for associating
key/value pairs.
This class provides concrete generic implementations of all
methods except for __getitem__, __setitem__, __delitem__,
__iter__, and __len__.
"""
@abstractmethod
def __setitem__(self, key, value):
raise KeyError
@abstractmethod
def __delitem__(self, key):
raise KeyError
__marker = object()
def pop(self, key, default=__marker):
'''D.pop(k[,d]) -> v, remove specified key and return the corresponding value.
If key is not found, d is returned if given, otherwise KeyError is raised.
'''
try:
value = self[key]
except KeyError:
if default is self.__marker:
raise
return default
else:
del self[key]
return value
def popitem(self):
'''D.popitem() -> (k, v), remove and return some (key, value) pair
as a 2-tuple; but raise KeyError if D is empty.
'''
try:
key = next(iter(self))
except StopIteration:
raise KeyError
value = self[key]
del self[key]
return key, value
def clear(self):
'D.clear() -> None. Remove all items from D.'
try:
while True:
self.popitem()
except KeyError:
pass
def update(*args, **kwds):
''' D.update([E, ]**F) -> None. Update D from mapping/iterable E and F.
If E present and has a .keys() method, does: for k in E: D[k] = E[k]
If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v
In either case, this is followed by: for k, v in F.items(): D[k] = v
'''
if len(args) > 2:
raise TypeError("update() takes at most 2 positional "
"arguments ({} given)".format(len(args)))
elif not args:
raise TypeError("update() takes at least 1 argument (0 given)")
self = args[0]
other = args[1] if len(args) >= 2 else ()
if isinstance(other, Mapping):
for key in other:
self[key] = other[key]
elif hasattr(other, "keys"):
for key in other.keys():
self[key] = other[key]
else:
for key, value in other:
self[key] = value
for key, value in kwds.items():
self[key] = value
def setdefault(self, key, default=None):
'D.setdefault(k[,d]) -> D.get(k,d), also set D[k]=d if k not in D'
try:
return self[key]
except KeyError:
self[key] = default
return default
MutableMapping.register(dict)
### SEQUENCES ###
class Sequence(Sized, Iterable, Container):
"""All the operations on a read-only sequence.
Concrete subclasses must override __new__ or __init__,
__getitem__, and __len__.
"""
@abstractmethod
def __getitem__(self, index):
raise IndexError
def __iter__(self):
i = 0
try:
while True:
v = self[i]
yield v
i += 1
except IndexError:
return
def __contains__(self, value):
for v in self:
if v == value:
return True
return False
def __reversed__(self):
for i in reversed(range(len(self))):
yield self[i]
def index(self, value):
'''S.index(value) -> integer -- return first index of value.
Raises ValueError if the value is not present.
'''
for i, v in enumerate(self):
if v == value:
return i
raise ValueError
def count(self, value):
'S.count(value) -> integer -- return number of occurrences of value'
return sum(1 for v in self if v == value)
Sequence.register(tuple)
Sequence.register(basestring)
Sequence.register(buffer)
Sequence.register(xrange)
class MutableSequence(Sequence):
"""All the operations on a read-only sequence.
Concrete subclasses must provide __new__ or __init__,
__getitem__, __setitem__, __delitem__, __len__, and insert().
"""
@abstractmethod
def __setitem__(self, index, value):
raise IndexError
@abstractmethod
def __delitem__(self, index):
raise IndexError
@abstractmethod
def insert(self, index, value):
'S.insert(index, object) -- insert object before index'
raise IndexError
def append(self, value):
'S.append(object) -- append object to the end of the sequence'
self.insert(len(self), value)
def reverse(self):
'S.reverse() -- reverse *IN PLACE*'
n = len(self)
for i in range(n//2):
self[i], self[n-i-1] = self[n-i-1], self[i]
def extend(self, values):
'S.extend(iterable) -- extend sequence by appending elements from the iterable'
for v in values:
self.append(v)
def pop(self, index=-1):
'''S.pop([index]) -> item -- remove and return item at index (default last).
Raise IndexError if list is empty or index is out of range.
'''
v = self[index]
del self[index]
return v
def remove(self, value):
'''S.remove(value) -- remove first occurrence of value.
Raise ValueError if the value is not present.
'''
del self[self.index(value)]
def __iadd__(self, values):
self.extend(values)
return self
MutableSequence.register(list)
|
gpl-3.0
|
[
3,
1898,
10219,
4475,
12,
3277,
14,
2900,
5924,
5702,
14,
199,
3,
3909,
370,
29770,
1334,
282,
17636,
28629,
14,
199,
199,
624,
8458,
3523,
27939,
334,
8390,
83,
9,
367,
5055,
12,
7182,
370,
13663,
650,
7119,
14,
199,
199,
36,
615,
7,
52,
4815,
5749,
30223,
8703,
6084,
1,
221,
710,
3992,
2348,
1077,
506,
8439,
199,
12897,
5055,
27,
2985,
787,
3247,
2348,
1454,
370,
27458,
433,
323,
9842,
199,
4930,
14183,
3637,
10876,
14,
221,
12008,
2295,
787,
315,
511,
63,
7882,
14,
199,
624,
199,
199,
504,
13022,
492,
29565,
12,
9006,
765,
199,
646,
984,
199,
199,
363,
452,
363,
275,
2097,
3476,
461,
401,
298,
20852,
401,
298,
3585,
401,
1779,
298,
51,
1759,
401,
298,
4076,
401,
298,
16410,
401,
1779,
298,
1084,
401,
298,
17707,
1084,
401,
1779,
298,
7674,
401,
298,
17707,
7674,
401,
1779,
298,
7674,
2768,
401,
298,
6340,
2768,
401,
298,
7412,
2768,
401,
298,
6550,
2768,
401,
1779,
298,
5826,
401,
298,
17707,
5826,
401,
1779,
1622,
199,
199,
5680,
13051,
13,
1766,
13884,
510,
615,
2563,
6754,
199,
199,
318,
485,
11161,
8,
35,
12,
1921,
304,
272,
862,
26,
267,
372,
1263,
8,
962,
315,
699,
855,
807,
363,
367,
699,
315,
445,
855,
17335,
3368,
272,
871,
4281,
26,
267,
327,
21238,
13,
2487,
1021,
267,
372,
2688,
8,
35,
12,
1921,
9,
421,
199,
533,
16101,
461,
26,
272,
636,
6577,
363,
275,
29565,
339,
768,
10315,
272,
347,
636,
2227,
721,
277,
304,
267,
372,
378,
339,
768,
3744,
272,
347,
636,
6083,
3664,
721,
1886,
12,
445,
304,
267,
340,
843,
365,
16101,
461,
26,
288,
862,
26,
355,
367,
699,
315,
445,
855,
17335,
10651,
490,
340,
4396,
2227,
16526,
315,
699,
855,
807,
10651,
717,
340,
699,
855,
807,
363,
31313,
2227,
363,
6229,
1169,
372,
715,
717,
2059,
288,
871,
4281,
26,
355,
327,
21238,
13,
2487,
1021,
355,
340,
2519,
8,
35,
12,
4396,
2227,
13915,
488,
304,
490,
372,
715,
267,
372,
3784,
421,
199,
533,
19937,
26,
272,
636,
6577,
363,
275,
29565,
339,
768,
10315,
272,
347,
636,
1661,
721,
277,
304,
267,
1830,
756,
26,
288,
1995,
488,
339,
768,
3744,
272,
347,
636,
6083,
3664,
721,
1886,
12,
445,
304,
267,
340,
843,
365,
19937,
26,
288,
340,
485,
11161,
8,
35,
12,
4396,
1661,
363,
2349,
355,
372,
715,
267,
372,
3784,
199,
199,
20852,
14,
2683,
8,
495,
9,
421,
199,
533,
25769,
8,
20852,
304,
339,
768,
10315,
272,
347,
2163,
8,
277,
304,
267,
283,
1767,
314,
2163,
1242,
687,
314,
6122,
14,
3979,
31103,
12,
746,
10852,
7,
267,
746,
10852,
339,
347,
636,
1661,
721,
277,
304,
267,
372,
291,
339,
768,
3744,
272,
347,
636,
6083,
3664,
721,
1886,
12,
445,
304,
267,
340,
843,
365,
25769,
26,
288,
340,
485,
11161,
8,
35,
12,
298,
2184,
531,
436,
485,
11161,
8,
35,
12,
4396,
1661,
363,
2349,
355,
372,
715,
267,
372,
3784,
421,
199,
533,
428,
1759,
26,
272,
636,
6577,
363,
275,
29565,
339,
768,
10315,
272,
347,
636,
552,
721,
277,
304,
267,
372,
378,
339,
768,
3744,
272,
347,
636,
6083,
3664,
721,
1886,
12,
445,
304,
267,
340,
843,
365,
428,
1759,
26,
288,
340,
485,
11161,
8,
35,
12,
4396,
552,
363,
2349,
355,
372,
715,
267,
372,
3784,
421,
199,
533,
15395,
26,
272,
636,
6577,
363,
275,
29565,
339,
768,
10315,
272,
347,
636,
6134,
721,
277,
12,
671,
304,
267,
372,
756,
339,
768,
3744,
272,
347,
636,
6083,
3664,
721,
1886,
12,
445,
304,
267,
340,
843,
365,
15395,
26,
288,
340,
485,
11161,
8,
35,
12,
4396,
6134,
363,
2349,
355,
372,
715,
267,
372,
3784,
421,
199,
533,
16975,
26,
272,
636,
6577,
363,
275,
29565,
339,
768,
10315,
272,
347,
636,
1250,
721,
277,
12,
627,
589,
12,
1011,
10340,
304,
267,
372,
756,
339,
768,
3744,
272,
347,
636,
6083,
3664,
721,
1886,
12,
445,
304,
267,
340,
843,
365,
16975,
26,
288,
340,
485,
11161,
8,
35,
12,
4396,
1250,
363,
2349,
355,
372,
715,
267,
372,
3784,
421,
199,
5680,
11543,
51,
6754,
421,
199,
533,
2494,
8,
51,
1759,
12,
19937,
12,
15395,
304,
272,
408,
33,
663,
365,
282,
21837,
12,
6076,
3970,
14,
339,
961,
1021,
6571,
13801,
7809,
12591,
402,
1006,
272,
3102,
871,
367,
636,
6134,
3108,
636,
1661,
363,
436,
636,
552,
4343,
339,
4005,
4278,
314,
20448,
334,
24919,
453,
6665,
367,
8112,
12,
465,
314,
272,
19002,
787,
6317,
395,
295,
4640,
636,
274,
363,
436,
636,
303,
3108,
272,
2066,
314,
1163,
5331,
911,
5847,
2035,
308,
4993,
14,
272,
408,
339,
347,
636,
274,
721,
277,
12,
1163,
304,
267,
340,
440,
1228,
8,
1848,
12,
2494,
304,
288,
372,
3784,
267,
340,
822,
8,
277,
9,
690,
822,
8,
1848,
304,
288,
372,
756,
267,
367,
6193,
315,
291,
26,
288,
340,
6193,
440,
315,
1163,
26,
355,
372,
756,
267,
372,
715,
339,
347,
636,
4116,
721,
277,
12,
1163,
304,
267,
340,
440,
1228,
8,
1848,
12,
2494,
304,
288,
372,
3784,
267,
372,
822,
8,
277,
9,
665,
822,
8,
1848,
9,
436,
291,
855,
274,
721,
1848,
9,
339,
347,
636,
3308,
721,
277,
12,
1163,
304,
267,
340,
440,
1228,
8,
1848,
12,
2494,
304,
288,
372,
3784,
267,
372,
822,
8,
277,
9,
690,
822,
8,
1848,
9,
436,
291,
855,
303,
721,
1848,
9,
339,
347,
636,
303,
721,
277,
12,
1163,
304,
267,
340,
440,
1228,
8,
1848,
12,
2494,
304,
288,
372,
3784,
267,
340,
822,
8,
277,
9,
665,
822,
8,
1848,
304,
288,
372,
756,
267,
367,
6193,
315,
1163,
26,
288,
340,
6193,
440,
315,
291,
26,
355,
372,
756,
267,
372,
715,
339,
347,
636,
4077,
721,
277,
12,
1163,
304,
267,
340,
440,
1228,
8,
1848,
12,
2494,
304,
288,
372,
3784,
267,
372,
822,
8,
277,
9,
508,
822,
8,
1848,
9,
436,
291,
855,
274,
721,
1848,
9,
339,
347,
636,
685,
721,
277,
12,
1163,
304,
267,
372,
440,
334,
277,
508
] |
[
1898,
10219,
4475,
12,
3277,
14,
2900,
5924,
5702,
14,
199,
3,
3909,
370,
29770,
1334,
282,
17636,
28629,
14,
199,
199,
624,
8458,
3523,
27939,
334,
8390,
83,
9,
367,
5055,
12,
7182,
370,
13663,
650,
7119,
14,
199,
199,
36,
615,
7,
52,
4815,
5749,
30223,
8703,
6084,
1,
221,
710,
3992,
2348,
1077,
506,
8439,
199,
12897,
5055,
27,
2985,
787,
3247,
2348,
1454,
370,
27458,
433,
323,
9842,
199,
4930,
14183,
3637,
10876,
14,
221,
12008,
2295,
787,
315,
511,
63,
7882,
14,
199,
624,
199,
199,
504,
13022,
492,
29565,
12,
9006,
765,
199,
646,
984,
199,
199,
363,
452,
363,
275,
2097,
3476,
461,
401,
298,
20852,
401,
298,
3585,
401,
1779,
298,
51,
1759,
401,
298,
4076,
401,
298,
16410,
401,
1779,
298,
1084,
401,
298,
17707,
1084,
401,
1779,
298,
7674,
401,
298,
17707,
7674,
401,
1779,
298,
7674,
2768,
401,
298,
6340,
2768,
401,
298,
7412,
2768,
401,
298,
6550,
2768,
401,
1779,
298,
5826,
401,
298,
17707,
5826,
401,
1779,
1622,
199,
199,
5680,
13051,
13,
1766,
13884,
510,
615,
2563,
6754,
199,
199,
318,
485,
11161,
8,
35,
12,
1921,
304,
272,
862,
26,
267,
372,
1263,
8,
962,
315,
699,
855,
807,
363,
367,
699,
315,
445,
855,
17335,
3368,
272,
871,
4281,
26,
267,
327,
21238,
13,
2487,
1021,
267,
372,
2688,
8,
35,
12,
1921,
9,
421,
199,
533,
16101,
461,
26,
272,
636,
6577,
363,
275,
29565,
339,
768,
10315,
272,
347,
636,
2227,
721,
277,
304,
267,
372,
378,
339,
768,
3744,
272,
347,
636,
6083,
3664,
721,
1886,
12,
445,
304,
267,
340,
843,
365,
16101,
461,
26,
288,
862,
26,
355,
367,
699,
315,
445,
855,
17335,
10651,
490,
340,
4396,
2227,
16526,
315,
699,
855,
807,
10651,
717,
340,
699,
855,
807,
363,
31313,
2227,
363,
6229,
1169,
372,
715,
717,
2059,
288,
871,
4281,
26,
355,
327,
21238,
13,
2487,
1021,
355,
340,
2519,
8,
35,
12,
4396,
2227,
13915,
488,
304,
490,
372,
715,
267,
372,
3784,
421,
199,
533,
19937,
26,
272,
636,
6577,
363,
275,
29565,
339,
768,
10315,
272,
347,
636,
1661,
721,
277,
304,
267,
1830,
756,
26,
288,
1995,
488,
339,
768,
3744,
272,
347,
636,
6083,
3664,
721,
1886,
12,
445,
304,
267,
340,
843,
365,
19937,
26,
288,
340,
485,
11161,
8,
35,
12,
4396,
1661,
363,
2349,
355,
372,
715,
267,
372,
3784,
199,
199,
20852,
14,
2683,
8,
495,
9,
421,
199,
533,
25769,
8,
20852,
304,
339,
768,
10315,
272,
347,
2163,
8,
277,
304,
267,
283,
1767,
314,
2163,
1242,
687,
314,
6122,
14,
3979,
31103,
12,
746,
10852,
7,
267,
746,
10852,
339,
347,
636,
1661,
721,
277,
304,
267,
372,
291,
339,
768,
3744,
272,
347,
636,
6083,
3664,
721,
1886,
12,
445,
304,
267,
340,
843,
365,
25769,
26,
288,
340,
485,
11161,
8,
35,
12,
298,
2184,
531,
436,
485,
11161,
8,
35,
12,
4396,
1661,
363,
2349,
355,
372,
715,
267,
372,
3784,
421,
199,
533,
428,
1759,
26,
272,
636,
6577,
363,
275,
29565,
339,
768,
10315,
272,
347,
636,
552,
721,
277,
304,
267,
372,
378,
339,
768,
3744,
272,
347,
636,
6083,
3664,
721,
1886,
12,
445,
304,
267,
340,
843,
365,
428,
1759,
26,
288,
340,
485,
11161,
8,
35,
12,
4396,
552,
363,
2349,
355,
372,
715,
267,
372,
3784,
421,
199,
533,
15395,
26,
272,
636,
6577,
363,
275,
29565,
339,
768,
10315,
272,
347,
636,
6134,
721,
277,
12,
671,
304,
267,
372,
756,
339,
768,
3744,
272,
347,
636,
6083,
3664,
721,
1886,
12,
445,
304,
267,
340,
843,
365,
15395,
26,
288,
340,
485,
11161,
8,
35,
12,
4396,
6134,
363,
2349,
355,
372,
715,
267,
372,
3784,
421,
199,
533,
16975,
26,
272,
636,
6577,
363,
275,
29565,
339,
768,
10315,
272,
347,
636,
1250,
721,
277,
12,
627,
589,
12,
1011,
10340,
304,
267,
372,
756,
339,
768,
3744,
272,
347,
636,
6083,
3664,
721,
1886,
12,
445,
304,
267,
340,
843,
365,
16975,
26,
288,
340,
485,
11161,
8,
35,
12,
4396,
1250,
363,
2349,
355,
372,
715,
267,
372,
3784,
421,
199,
5680,
11543,
51,
6754,
421,
199,
533,
2494,
8,
51,
1759,
12,
19937,
12,
15395,
304,
272,
408,
33,
663,
365,
282,
21837,
12,
6076,
3970,
14,
339,
961,
1021,
6571,
13801,
7809,
12591,
402,
1006,
272,
3102,
871,
367,
636,
6134,
3108,
636,
1661,
363,
436,
636,
552,
4343,
339,
4005,
4278,
314,
20448,
334,
24919,
453,
6665,
367,
8112,
12,
465,
314,
272,
19002,
787,
6317,
395,
295,
4640,
636,
274,
363,
436,
636,
303,
3108,
272,
2066,
314,
1163,
5331,
911,
5847,
2035,
308,
4993,
14,
272,
408,
339,
347,
636,
274,
721,
277,
12,
1163,
304,
267,
340,
440,
1228,
8,
1848,
12,
2494,
304,
288,
372,
3784,
267,
340,
822,
8,
277,
9,
690,
822,
8,
1848,
304,
288,
372,
756,
267,
367,
6193,
315,
291,
26,
288,
340,
6193,
440,
315,
1163,
26,
355,
372,
756,
267,
372,
715,
339,
347,
636,
4116,
721,
277,
12,
1163,
304,
267,
340,
440,
1228,
8,
1848,
12,
2494,
304,
288,
372,
3784,
267,
372,
822,
8,
277,
9,
665,
822,
8,
1848,
9,
436,
291,
855,
274,
721,
1848,
9,
339,
347,
636,
3308,
721,
277,
12,
1163,
304,
267,
340,
440,
1228,
8,
1848,
12,
2494,
304,
288,
372,
3784,
267,
372,
822,
8,
277,
9,
690,
822,
8,
1848,
9,
436,
291,
855,
303,
721,
1848,
9,
339,
347,
636,
303,
721,
277,
12,
1163,
304,
267,
340,
440,
1228,
8,
1848,
12,
2494,
304,
288,
372,
3784,
267,
340,
822,
8,
277,
9,
665,
822,
8,
1848,
304,
288,
372,
756,
267,
367,
6193,
315,
1163,
26,
288,
340,
6193,
440,
315,
291,
26,
355,
372,
756,
267,
372,
715,
339,
347,
636,
4077,
721,
277,
12,
1163,
304,
267,
340,
440,
1228,
8,
1848,
12,
2494,
304,
288,
372,
3784,
267,
372,
822,
8,
277,
9,
508,
822,
8,
1848,
9,
436,
291,
855,
274,
721,
1848,
9,
339,
347,
636,
685,
721,
277,
12,
1163,
304,
267,
372,
440,
334,
277,
508,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
yanheven/neutron
|
neutron/tests/tempest/services/identity/v3/json/policy_client.py
|
24
|
2505
|
# Copyright 2013 OpenStack Foundation
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from oslo_serialization import jsonutils as json
from neutron.tests.tempest.common import service_client
class PolicyClientJSON(service_client.ServiceClient):
api_version = "v3"
def create_policy(self, blob, type):
"""Creates a Policy."""
post_body = {
"blob": blob,
"type": type
}
post_body = json.dumps({'policy': post_body})
resp, body = self.post('policies', post_body)
self.expected_success(201, resp.status)
body = json.loads(body)
return service_client.ResponseBody(resp, body['policy'])
def list_policies(self):
"""Lists the policies."""
resp, body = self.get('policies')
self.expected_success(200, resp.status)
body = json.loads(body)
return service_client.ResponseBodyList(resp, body['policies'])
def get_policy(self, policy_id):
"""Lists out the given policy."""
url = 'policies/%s' % policy_id
resp, body = self.get(url)
self.expected_success(200, resp.status)
body = json.loads(body)
return service_client.ResponseBody(resp, body['policy'])
def update_policy(self, policy_id, **kwargs):
"""Updates a policy."""
type = kwargs.get('type')
post_body = {
'type': type
}
post_body = json.dumps({'policy': post_body})
url = 'policies/%s' % policy_id
resp, body = self.patch(url, post_body)
self.expected_success(200, resp.status)
body = json.loads(body)
return service_client.ResponseBody(resp, body['policy'])
def delete_policy(self, policy_id):
"""Deletes the policy."""
url = "policies/%s" % policy_id
resp, body = self.delete(url)
self.expected_success(204, resp.status)
return service_client.ResponseBody(resp, body)
|
apache-2.0
|
[
3,
1898,
6171,
14260,
2752,
199,
3,
2900,
5924,
5702,
14,
199,
3,
199,
3,
259,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
1265,
1443,
199,
3,
259,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
2047,
1443,
3332,
199,
3,
259,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
260,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
259,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
259,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
2428,
199,
3,
259,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
1666,
314,
199,
3,
259,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
4204,
199,
3,
259,
1334,
314,
844,
14,
199,
199,
504,
11258,
63,
12161,
492,
18705,
465,
2022,
199,
199,
504,
8224,
14,
2219,
14,
808,
597,
14,
2330,
492,
2435,
63,
1258,
421,
199,
533,
18141,
3041,
6243,
8,
1364,
63,
1258,
14,
3167,
3041,
304,
272,
2986,
63,
1023,
275,
298,
86,
19,
2,
339,
347,
1218,
63,
3185,
8,
277,
12,
9182,
12,
730,
304,
267,
408,
10607,
282,
18141,
1041,
267,
2963,
63,
2030,
275,
469,
288,
298,
6582,
582,
9182,
12,
288,
298,
466,
582,
730,
267,
789,
267,
2963,
63,
2030,
275,
2022,
14,
4180,
3252,
3185,
356,
2963,
63,
2030,
1552,
267,
3085,
12,
2396,
275,
291,
14,
1932,
360,
11767,
297,
2963,
63,
2030,
9,
267,
291,
14,
2062,
63,
3742,
8,
1797,
12,
3085,
14,
1205,
9,
267,
2396,
275,
2022,
14,
3640,
8,
2030,
9,
267,
372,
2435,
63,
1258,
14,
2364,
8173,
8,
4518,
12,
2396,
459,
3185,
1105,
339,
347,
769,
63,
11767,
8,
277,
304,
267,
408,
15116,
314,
14118,
1041,
267,
3085,
12,
2396,
275,
291,
14,
362,
360,
11767,
358,
267,
291,
14,
2062,
63,
3742,
8,
1840,
12,
3085,
14,
1205,
9,
267,
2396,
275,
2022,
14,
3640,
8,
2030,
9,
267,
372,
2435,
63,
1258,
14,
2364,
8173,
1296,
8,
4518,
12,
2396,
459,
11767,
1105,
339,
347,
664,
63,
3185,
8,
277,
12,
4592,
63,
344,
304,
267,
408,
15116,
734,
314,
1627,
4592,
1041,
267,
1166,
275,
283,
11767,
3149,
83,
7,
450,
4592,
63,
344,
267,
3085,
12,
2396,
275,
291,
14,
362,
8,
633,
9,
267,
291,
14,
2062,
63,
3742,
8,
1840,
12,
3085,
14,
1205,
9,
267,
2396,
275,
2022,
14,
3640,
8,
2030,
9,
267,
372,
2435,
63,
1258,
14,
2364,
8173,
8,
4518,
12,
2396,
459,
3185,
1105,
339,
347,
1678,
63,
3185,
8,
277,
12,
4592,
63,
344,
12,
1011,
958,
304,
267,
408,
16083,
282,
4592,
1041,
267,
730,
275,
2074,
14,
362,
360,
466,
358,
267,
2963,
63,
2030,
275,
469,
288,
283,
466,
356,
730,
267,
789,
267,
2963,
63,
2030,
275,
2022,
14,
4180,
3252,
3185,
356,
2963,
63,
2030,
1552,
267,
1166,
275,
283,
11767,
3149,
83,
7,
450,
4592,
63,
344,
267,
3085,
12,
2396,
275,
291,
14,
2068,
8,
633,
12,
2963,
63,
2030,
9,
267,
291,
14,
2062,
63,
3742,
8,
1840,
12,
3085,
14,
1205,
9,
267,
2396,
275,
2022,
14,
3640,
8,
2030,
9,
267,
372,
2435,
63,
1258,
14,
2364,
8173,
8,
4518,
12,
2396,
459,
3185,
1105,
339,
347,
3145,
63,
3185,
8,
277,
12,
4592,
63,
344,
304,
267,
408,
26372,
314,
4592,
1041,
267,
1166,
275,
298,
11767,
3149,
83,
2,
450,
4592,
63,
344,
267,
3085,
12,
2396,
275,
291,
14,
1807,
8,
633,
9,
267,
291,
14,
2062,
63,
3742,
8,
6686,
12,
3085,
14,
1205,
9,
267,
372,
2435,
63,
1258,
14,
2364,
8173,
8,
4518,
12,
2396,
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
] |
[
1898,
6171,
14260,
2752,
199,
3,
2900,
5924,
5702,
14,
199,
3,
199,
3,
259,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
1265,
1443,
199,
3,
259,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
2047,
1443,
3332,
199,
3,
259,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
260,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
259,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
259,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
2428,
199,
3,
259,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
1666,
314,
199,
3,
259,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
4204,
199,
3,
259,
1334,
314,
844,
14,
199,
199,
504,
11258,
63,
12161,
492,
18705,
465,
2022,
199,
199,
504,
8224,
14,
2219,
14,
808,
597,
14,
2330,
492,
2435,
63,
1258,
421,
199,
533,
18141,
3041,
6243,
8,
1364,
63,
1258,
14,
3167,
3041,
304,
272,
2986,
63,
1023,
275,
298,
86,
19,
2,
339,
347,
1218,
63,
3185,
8,
277,
12,
9182,
12,
730,
304,
267,
408,
10607,
282,
18141,
1041,
267,
2963,
63,
2030,
275,
469,
288,
298,
6582,
582,
9182,
12,
288,
298,
466,
582,
730,
267,
789,
267,
2963,
63,
2030,
275,
2022,
14,
4180,
3252,
3185,
356,
2963,
63,
2030,
1552,
267,
3085,
12,
2396,
275,
291,
14,
1932,
360,
11767,
297,
2963,
63,
2030,
9,
267,
291,
14,
2062,
63,
3742,
8,
1797,
12,
3085,
14,
1205,
9,
267,
2396,
275,
2022,
14,
3640,
8,
2030,
9,
267,
372,
2435,
63,
1258,
14,
2364,
8173,
8,
4518,
12,
2396,
459,
3185,
1105,
339,
347,
769,
63,
11767,
8,
277,
304,
267,
408,
15116,
314,
14118,
1041,
267,
3085,
12,
2396,
275,
291,
14,
362,
360,
11767,
358,
267,
291,
14,
2062,
63,
3742,
8,
1840,
12,
3085,
14,
1205,
9,
267,
2396,
275,
2022,
14,
3640,
8,
2030,
9,
267,
372,
2435,
63,
1258,
14,
2364,
8173,
1296,
8,
4518,
12,
2396,
459,
11767,
1105,
339,
347,
664,
63,
3185,
8,
277,
12,
4592,
63,
344,
304,
267,
408,
15116,
734,
314,
1627,
4592,
1041,
267,
1166,
275,
283,
11767,
3149,
83,
7,
450,
4592,
63,
344,
267,
3085,
12,
2396,
275,
291,
14,
362,
8,
633,
9,
267,
291,
14,
2062,
63,
3742,
8,
1840,
12,
3085,
14,
1205,
9,
267,
2396,
275,
2022,
14,
3640,
8,
2030,
9,
267,
372,
2435,
63,
1258,
14,
2364,
8173,
8,
4518,
12,
2396,
459,
3185,
1105,
339,
347,
1678,
63,
3185,
8,
277,
12,
4592,
63,
344,
12,
1011,
958,
304,
267,
408,
16083,
282,
4592,
1041,
267,
730,
275,
2074,
14,
362,
360,
466,
358,
267,
2963,
63,
2030,
275,
469,
288,
283,
466,
356,
730,
267,
789,
267,
2963,
63,
2030,
275,
2022,
14,
4180,
3252,
3185,
356,
2963,
63,
2030,
1552,
267,
1166,
275,
283,
11767,
3149,
83,
7,
450,
4592,
63,
344,
267,
3085,
12,
2396,
275,
291,
14,
2068,
8,
633,
12,
2963,
63,
2030,
9,
267,
291,
14,
2062,
63,
3742,
8,
1840,
12,
3085,
14,
1205,
9,
267,
2396,
275,
2022,
14,
3640,
8,
2030,
9,
267,
372,
2435,
63,
1258,
14,
2364,
8173,
8,
4518,
12,
2396,
459,
3185,
1105,
339,
347,
3145,
63,
3185,
8,
277,
12,
4592,
63,
344,
304,
267,
408,
26372,
314,
4592,
1041,
267,
1166,
275,
298,
11767,
3149,
83,
2,
450,
4592,
63,
344,
267,
3085,
12,
2396,
275,
291,
14,
1807,
8,
633,
9,
267,
291,
14,
2062,
63,
3742,
8,
6686,
12,
3085,
14,
1205,
9,
267,
372,
2435,
63,
1258,
14,
2364,
8173,
8,
4518,
12,
2396,
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,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
ojengwa/oh-mainline
|
vendor/packages/twisted/twisted/application/strports.py
|
19
|
3134
|
# -*- test-case-name: twisted.test.test_strports -*-
# Copyright (c) Twisted Matrix Laboratories.
# See LICENSE for details.
"""
Construct listening port services from a simple string description.
@see: L{twisted.internet.endpoints.serverFromString}
@see: L{twisted.internet.endpoints.clientFromString}
"""
import warnings
from twisted.internet import endpoints
from twisted.python.deprecate import deprecatedModuleAttribute
from twisted.python.versions import Version
from twisted.application.internet import StreamServerEndpointService
def parse(description, factory, default='tcp'):
"""
This function is deprecated as of Twisted 10.2.
@see: L{twisted.internet.endpoints.server}
"""
return endpoints._parseServer(description, factory, default)
deprecatedModuleAttribute(
Version("Twisted", 10, 2, 0),
"in favor of twisted.internet.endpoints.serverFromString",
__name__, "parse")
_DEFAULT = object()
def service(description, factory, default=_DEFAULT, reactor=None):
"""
Return the service corresponding to a description.
@param description: The description of the listening port, in the syntax
described by L{twisted.internet.endpoints.server}.
@type description: C{str}
@param factory: The protocol factory which will build protocols for
connections to this service.
@type factory: L{twisted.internet.interfaces.IProtocolFactory}
@type default: C{str} or C{None}
@param default: Do not use this parameter. It is deprecated since Twisted
10.2.0.
@rtype: C{twisted.application.service.IService}
@return: the service corresponding to a description of a reliable
stream server.
@see: L{twisted.internet.endpoints.serverFromString}
"""
if reactor is None:
from twisted.internet import reactor
if default is _DEFAULT:
default = None
else:
message = "The 'default' parameter was deprecated in Twisted 10.2.0."
if default is not None:
message += (
" Use qualified endpoint descriptions; for example, "
"'tcp:%s'." % (description,))
warnings.warn(
message=message, category=DeprecationWarning, stacklevel=2)
svc = StreamServerEndpointService(
endpoints._serverFromStringLegacy(reactor, description, default),
factory)
svc._raiseSynchronously = True
return svc
def listen(description, factory, default=None):
"""Listen on a port corresponding to a description
@type description: C{str}
@type factory: L{twisted.internet.interfaces.IProtocolFactory}
@type default: C{str} or C{None}
@rtype: C{twisted.internet.interfaces.IListeningPort}
@return: the port corresponding to a description of a reliable
virtual circuit server.
See the documentation of the C{parse} function for description
of the semantics of the arguments.
"""
from twisted.internet import reactor
name, args, kw = parse(description, factory, default)
return getattr(reactor, 'listen'+name)(*args, **kw)
__all__ = ['parse', 'service', 'listen']
|
agpl-3.0
|
[
3,
1882,
511,
13,
2546,
13,
354,
26,
7390,
14,
396,
14,
396,
63,
495,
5203,
1882,
199,
3,
1898,
334,
67,
9,
17078,
8449,
26640,
14,
199,
3,
1666,
5113,
367,
2436,
14,
199,
199,
624,
199,
11493,
22721,
1844,
8500,
687,
282,
3486,
1059,
1369,
14,
199,
199,
32,
3239,
26,
491,
91,
12145,
14,
4901,
14,
14461,
14,
1000,
7671,
93,
199,
32,
3239,
26,
491,
91,
12145,
14,
4901,
14,
14461,
14,
1258,
7671,
93,
199,
624,
199,
199,
646,
3598,
199,
199,
504,
7390,
14,
4901,
492,
16173,
199,
504,
7390,
14,
1548,
14,
27891,
492,
5906,
2377,
1646,
199,
504,
7390,
14,
1548,
14,
6234,
492,
3394,
199,
504,
7390,
14,
3578,
14,
4901,
492,
8271,
3120,
11442,
3167,
4388,
199,
318,
2198,
8,
1802,
12,
6434,
12,
849,
534,
8815,
735,
272,
408,
272,
961,
805,
365,
5906,
465,
402,
17078,
1616,
14,
18,
14,
339,
768,
3239,
26,
491,
91,
12145,
14,
4901,
14,
14461,
14,
1000,
93,
272,
408,
272,
372,
16173,
423,
1122,
3120,
8,
1802,
12,
6434,
12,
849,
9,
199,
199,
6667,
2377,
1646,
8,
272,
3394,
480,
52,
5221,
401,
1616,
12,
499,
12,
378,
395,
272,
298,
262,
17914,
402,
7390,
14,
4901,
14,
14461,
14,
1000,
7671,
401,
272,
636,
354,
3108,
298,
1122,
531,
4388,
199,
63,
3472,
275,
909,
342,
199,
199,
318,
2435,
8,
1802,
12,
6434,
12,
849,
3699,
3472,
12,
9655,
29,
403,
304,
272,
408,
272,
1432,
314,
2435,
5226,
370,
282,
1369,
14,
339,
768,
635,
1369,
26,
710,
1369,
402,
314,
22721,
1844,
12,
315,
314,
6302,
267,
11736,
701,
491,
91,
12145,
14,
4901,
14,
14461,
14,
1000,
5565,
339,
768,
466,
1369,
26,
445,
91,
495,
93,
339,
768,
635,
6434,
26,
710,
4113,
6434,
1314,
911,
1900,
19230,
367,
267,
6947,
370,
642,
2435,
14,
339,
768,
466,
6434,
26,
491,
91,
12145,
14,
4901,
14,
7436,
14,
41,
3658,
2927,
93,
339,
768,
466,
849,
26,
445,
91,
495,
93,
503,
445,
91,
403,
93,
339,
768,
635,
849,
26,
4226,
440,
675,
642,
2725,
14,
221,
2779,
365,
5906,
3967,
17078,
267,
1616,
14,
18,
14,
16,
14,
339,
768,
4500,
26,
445,
91,
12145,
14,
3578,
14,
1364,
14,
1311,
281,
722,
93,
339,
768,
1107,
26,
314,
2435,
5226,
370,
282,
1369,
402,
282,
32150,
267,
2547,
1654,
14,
339,
768,
3239,
26,
491,
91,
12145,
14,
4901,
14,
14461,
14,
1000,
7671,
93,
272,
408,
272,
340,
9655,
365,
488,
26,
267,
687,
7390,
14,
4901,
492,
9655,
272,
340,
849,
365,
485,
3472,
26,
267,
849,
275,
488,
272,
587,
26,
267,
1245,
275,
298,
1918,
283,
885,
7,
2725,
1990,
5906,
315,
17078,
1616,
14,
18,
14,
16,
2122,
267,
340,
849,
365,
440,
488,
26,
288,
1245,
847,
334,
355,
298,
221,
3645,
12313,
6037,
18714,
27,
367,
2893,
12,
298,
355,
3546,
8815,
2689,
83,
16669,
450,
334,
1802,
4641,
267,
3598,
14,
4050,
8,
288,
1245,
29,
1188,
12,
4637,
29,
15561,
12,
13232,
29,
18,
9,
272,
19257,
275,
8271,
3120,
11442,
3167,
8,
267,
16173,
423,
1000,
7671,
22628,
8,
13544,
12,
1369,
12,
849,
395,
267,
6434,
9,
272,
19257,
423,
3730,
51,
9865,
590,
275,
715,
272,
372,
19257,
4388,
199,
318,
6938,
8,
1802,
12,
6434,
12,
849,
29,
403,
304,
272,
408,
8687,
641,
282,
1844,
5226,
370,
282,
1369,
339,
768,
466,
1369,
26,
445,
91,
495,
93,
272,
768,
466,
6434,
26,
491,
91,
12145,
14,
4901,
14,
7436,
14,
41,
3658,
2927,
93,
272,
768,
466,
849,
26,
445,
91,
495,
93,
503,
445,
91,
403,
93,
272,
768,
4500,
26,
445,
91,
12145,
14,
4901,
14,
7436,
14,
1193,
7938,
316,
4313,
93,
272,
768,
1107,
26,
314,
1844,
5226,
370,
282,
1369,
402,
282,
32150,
272,
5791,
20304,
1654,
14,
339,
1666,
314,
3794,
402,
314,
445,
91,
1122,
93,
805,
367,
1369,
272,
402,
314,
19002,
402,
314,
2368,
14,
272,
408,
272,
687,
7390,
14,
4901,
492,
9655,
272,
536,
12,
1249,
12,
4775,
275,
2198,
8,
1802,
12,
6434,
12,
849,
9,
272,
372,
2519,
8,
13544,
12,
283,
5859,
6828,
354,
25967,
589,
12,
1011,
829,
9,
4388,
199,
363,
452,
363,
275,
788,
1122,
297,
283,
1364,
297,
283,
5859,
418,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,
511,
13,
2546,
13,
354,
26,
7390,
14,
396,
14,
396,
63,
495,
5203,
1882,
199,
3,
1898,
334,
67,
9,
17078,
8449,
26640,
14,
199,
3,
1666,
5113,
367,
2436,
14,
199,
199,
624,
199,
11493,
22721,
1844,
8500,
687,
282,
3486,
1059,
1369,
14,
199,
199,
32,
3239,
26,
491,
91,
12145,
14,
4901,
14,
14461,
14,
1000,
7671,
93,
199,
32,
3239,
26,
491,
91,
12145,
14,
4901,
14,
14461,
14,
1258,
7671,
93,
199,
624,
199,
199,
646,
3598,
199,
199,
504,
7390,
14,
4901,
492,
16173,
199,
504,
7390,
14,
1548,
14,
27891,
492,
5906,
2377,
1646,
199,
504,
7390,
14,
1548,
14,
6234,
492,
3394,
199,
504,
7390,
14,
3578,
14,
4901,
492,
8271,
3120,
11442,
3167,
4388,
199,
318,
2198,
8,
1802,
12,
6434,
12,
849,
534,
8815,
735,
272,
408,
272,
961,
805,
365,
5906,
465,
402,
17078,
1616,
14,
18,
14,
339,
768,
3239,
26,
491,
91,
12145,
14,
4901,
14,
14461,
14,
1000,
93,
272,
408,
272,
372,
16173,
423,
1122,
3120,
8,
1802,
12,
6434,
12,
849,
9,
199,
199,
6667,
2377,
1646,
8,
272,
3394,
480,
52,
5221,
401,
1616,
12,
499,
12,
378,
395,
272,
298,
262,
17914,
402,
7390,
14,
4901,
14,
14461,
14,
1000,
7671,
401,
272,
636,
354,
3108,
298,
1122,
531,
4388,
199,
63,
3472,
275,
909,
342,
199,
199,
318,
2435,
8,
1802,
12,
6434,
12,
849,
3699,
3472,
12,
9655,
29,
403,
304,
272,
408,
272,
1432,
314,
2435,
5226,
370,
282,
1369,
14,
339,
768,
635,
1369,
26,
710,
1369,
402,
314,
22721,
1844,
12,
315,
314,
6302,
267,
11736,
701,
491,
91,
12145,
14,
4901,
14,
14461,
14,
1000,
5565,
339,
768,
466,
1369,
26,
445,
91,
495,
93,
339,
768,
635,
6434,
26,
710,
4113,
6434,
1314,
911,
1900,
19230,
367,
267,
6947,
370,
642,
2435,
14,
339,
768,
466,
6434,
26,
491,
91,
12145,
14,
4901,
14,
7436,
14,
41,
3658,
2927,
93,
339,
768,
466,
849,
26,
445,
91,
495,
93,
503,
445,
91,
403,
93,
339,
768,
635,
849,
26,
4226,
440,
675,
642,
2725,
14,
221,
2779,
365,
5906,
3967,
17078,
267,
1616,
14,
18,
14,
16,
14,
339,
768,
4500,
26,
445,
91,
12145,
14,
3578,
14,
1364,
14,
1311,
281,
722,
93,
339,
768,
1107,
26,
314,
2435,
5226,
370,
282,
1369,
402,
282,
32150,
267,
2547,
1654,
14,
339,
768,
3239,
26,
491,
91,
12145,
14,
4901,
14,
14461,
14,
1000,
7671,
93,
272,
408,
272,
340,
9655,
365,
488,
26,
267,
687,
7390,
14,
4901,
492,
9655,
272,
340,
849,
365,
485,
3472,
26,
267,
849,
275,
488,
272,
587,
26,
267,
1245,
275,
298,
1918,
283,
885,
7,
2725,
1990,
5906,
315,
17078,
1616,
14,
18,
14,
16,
2122,
267,
340,
849,
365,
440,
488,
26,
288,
1245,
847,
334,
355,
298,
221,
3645,
12313,
6037,
18714,
27,
367,
2893,
12,
298,
355,
3546,
8815,
2689,
83,
16669,
450,
334,
1802,
4641,
267,
3598,
14,
4050,
8,
288,
1245,
29,
1188,
12,
4637,
29,
15561,
12,
13232,
29,
18,
9,
272,
19257,
275,
8271,
3120,
11442,
3167,
8,
267,
16173,
423,
1000,
7671,
22628,
8,
13544,
12,
1369,
12,
849,
395,
267,
6434,
9,
272,
19257,
423,
3730,
51,
9865,
590,
275,
715,
272,
372,
19257,
4388,
199,
318,
6938,
8,
1802,
12,
6434,
12,
849,
29,
403,
304,
272,
408,
8687,
641,
282,
1844,
5226,
370,
282,
1369,
339,
768,
466,
1369,
26,
445,
91,
495,
93,
272,
768,
466,
6434,
26,
491,
91,
12145,
14,
4901,
14,
7436,
14,
41,
3658,
2927,
93,
272,
768,
466,
849,
26,
445,
91,
495,
93,
503,
445,
91,
403,
93,
272,
768,
4500,
26,
445,
91,
12145,
14,
4901,
14,
7436,
14,
1193,
7938,
316,
4313,
93,
272,
768,
1107,
26,
314,
1844,
5226,
370,
282,
1369,
402,
282,
32150,
272,
5791,
20304,
1654,
14,
339,
1666,
314,
3794,
402,
314,
445,
91,
1122,
93,
805,
367,
1369,
272,
402,
314,
19002,
402,
314,
2368,
14,
272,
408,
272,
687,
7390,
14,
4901,
492,
9655,
272,
536,
12,
1249,
12,
4775,
275,
2198,
8,
1802,
12,
6434,
12,
849,
9,
272,
372,
2519,
8,
13544,
12,
283,
5859,
6828,
354,
25967,
589,
12,
1011,
829,
9,
4388,
199,
363,
452,
363,
275,
788,
1122,
297,
283,
1364,
297,
283,
5859,
418,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,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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
] |
ottermegazord/ottermegazord.github.io
|
sortify-master/seaborn/tests/test_algorithms.py
|
35
|
6607
|
import numpy as np
from scipy import stats
from ..external.six.moves import range
import numpy.testing as npt
from numpy.testing import assert_array_equal
import nose.tools
from nose.tools import assert_equal, raises
from .. import algorithms as algo
rs = np.random.RandomState(sum(map(ord, "test_algorithms")))
a_norm = rs.randn(100)
def test_bootstrap():
"""Test that bootstrapping gives the right answer in dumb cases."""
a_ones = np.ones(10)
n_boot = 5
out1 = algo.bootstrap(a_ones, n_boot=n_boot)
assert_array_equal(out1, np.ones(n_boot))
out2 = algo.bootstrap(a_ones, n_boot=n_boot, func=np.median)
assert_array_equal(out2, np.ones(n_boot))
def test_bootstrap_length():
"""Test that we get a bootstrap array of the right shape."""
out = algo.bootstrap(a_norm)
assert_equal(len(out), 10000)
n_boot = 100
out = algo.bootstrap(a_norm, n_boot=n_boot)
assert_equal(len(out), n_boot)
def test_bootstrap_range():
"""Test that boostrapping a random array stays within the right range."""
min, max = a_norm.min(), a_norm.max()
out = algo.bootstrap(a_norm)
nose.tools.assert_less(min, out.min())
nose.tools.assert_greater_equal(max, out.max())
def test_bootstrap_multiarg():
"""Test that bootstrap works with multiple input arrays."""
x = np.vstack([[1, 10] for i in range(10)])
y = np.vstack([[5, 5] for i in range(10)])
test_func = lambda x, y: np.vstack((x, y)).max(axis=0)
out_actual = algo.bootstrap(x, y, n_boot=2, func=test_func)
out_wanted = np.array([[5, 10], [5, 10]])
assert_array_equal(out_actual, out_wanted)
def test_bootstrap_axis():
"""Test axis kwarg to bootstrap function."""
x = rs.randn(10, 20)
n_boot = 100
out_default = algo.bootstrap(x, n_boot=n_boot)
assert_equal(out_default.shape, (n_boot,))
out_axis = algo.bootstrap(x, n_boot=n_boot, axis=0)
assert_equal(out_axis.shape, (n_boot, 20))
def test_bootstrap_random_seed():
"""Test that we can get reproducible resamples by seeding the RNG."""
data = rs.randn(50)
seed = 42
boots1 = algo.bootstrap(data, random_seed=seed)
boots2 = algo.bootstrap(data, random_seed=seed)
assert_array_equal(boots1, boots2)
def test_smooth_bootstrap():
"""Test smooth bootstrap."""
x = rs.randn(15)
n_boot = 100
out_smooth = algo.bootstrap(x, n_boot=n_boot,
smooth=True, func=np.median)
assert(not np.median(out_smooth) in x)
def test_bootstrap_ols():
"""Test bootstrap of OLS model fit."""
ols_fit = lambda X, y: np.dot(np.dot(np.linalg.inv(
np.dot(X.T, X)), X.T), y)
X = np.column_stack((rs.randn(50, 4), np.ones(50)))
w = [2, 4, 0, 3, 5]
y_noisy = np.dot(X, w) + rs.randn(50) * 20
y_lownoise = np.dot(X, w) + rs.randn(50)
n_boot = 500
w_boot_noisy = algo.bootstrap(X, y_noisy,
n_boot=n_boot,
func=ols_fit)
w_boot_lownoise = algo.bootstrap(X, y_lownoise,
n_boot=n_boot,
func=ols_fit)
assert_equal(w_boot_noisy.shape, (n_boot, 5))
assert_equal(w_boot_lownoise.shape, (n_boot, 5))
nose.tools.assert_greater(w_boot_noisy.std(),
w_boot_lownoise.std())
def test_bootstrap_units():
"""Test that results make sense when passing unit IDs to bootstrap."""
data = rs.randn(50)
ids = np.repeat(range(10), 5)
bwerr = rs.normal(0, 2, 10)
bwerr = bwerr[ids]
data_rm = data + bwerr
seed = 77
boots_orig = algo.bootstrap(data_rm, random_seed=seed)
boots_rm = algo.bootstrap(data_rm, units=ids, random_seed=seed)
nose.tools.assert_greater(boots_rm.std(), boots_orig.std())
@raises(ValueError)
def test_bootstrap_arglength():
"""Test that different length args raise ValueError."""
algo.bootstrap(np.arange(5), np.arange(10))
@raises(TypeError)
def test_bootstrap_noncallable():
"""Test that we get a TypeError with noncallable algo.unc."""
non_func = "mean"
algo.bootstrap(a_norm, 100, non_func)
def test_randomize_corrmat():
"""Test the correctness of the correlation matrix p values."""
a = rs.randn(30)
b = a + rs.rand(30) * 3
c = rs.randn(30)
d = [a, b, c]
p_mat, dist = algo.randomize_corrmat(d, tail="upper", corrected=False,
return_dist=True)
nose.tools.assert_greater(p_mat[2, 0], p_mat[1, 0])
corrmat = np.corrcoef(d)
pctile = 100 - stats.percentileofscore(dist[2, 1], corrmat[2, 1])
nose.tools.assert_almost_equal(p_mat[2, 1] * 100, pctile)
d[1] = -a + rs.rand(30)
p_mat = algo.randomize_corrmat(d)
nose.tools.assert_greater(0.05, p_mat[1, 0])
def test_randomize_corrmat_dist():
"""Test that the distribution looks right."""
a = rs.randn(3, 20)
for n_i in [5, 10]:
p_mat, dist = algo.randomize_corrmat(a, n_iter=n_i, return_dist=True)
assert_equal(n_i, dist.shape[-1])
p_mat, dist = algo.randomize_corrmat(a, n_iter=10000, return_dist=True)
diag_mean = dist[0, 0].mean()
assert_equal(diag_mean, 1)
off_diag_mean = dist[0, 1].mean()
nose.tools.assert_greater(0.05, off_diag_mean)
def test_randomize_corrmat_correction():
"""Test that FWE correction works."""
a = rs.randn(3, 20)
p_mat = algo.randomize_corrmat(a, "upper", False)
p_mat_corr = algo.randomize_corrmat(a, "upper", True)
triu = np.triu_indices(3, 1)
npt.assert_array_less(p_mat[triu], p_mat_corr[triu])
def test_randimoize_corrmat_tails():
"""Test that the tail argument works."""
a = rs.randn(30)
b = a + rs.rand(30) * 8
c = rs.randn(30)
d = [a, b, c]
p_mat_b = algo.randomize_corrmat(d, "both", False, random_seed=0)
p_mat_u = algo.randomize_corrmat(d, "upper", False, random_seed=0)
p_mat_l = algo.randomize_corrmat(d, "lower", False, random_seed=0)
assert_equal(p_mat_b[0, 1], p_mat_u[0, 1] * 2)
assert_equal(p_mat_l[0, 1], 1 - p_mat_u[0, 1])
def test_randomise_corrmat_seed():
"""Test that we can seed the corrmat randomization."""
a = rs.randn(3, 20)
_, dist1 = algo.randomize_corrmat(a, random_seed=0, return_dist=True)
_, dist2 = algo.randomize_corrmat(a, random_seed=0, return_dist=True)
assert_array_equal(dist1, dist2)
@raises(ValueError)
def test_randomize_corrmat_tail_error():
"""Test that we are strict about tail paramete."""
a = rs.randn(3, 30)
algo.randomize_corrmat(a, "hello")
|
mit
|
[
646,
2680,
465,
980,
199,
504,
7026,
492,
5020,
199,
504,
2508,
5159,
14,
4174,
14,
4912,
492,
1425,
199,
199,
646,
2680,
14,
4776,
465,
29340,
199,
504,
2680,
14,
4776,
492,
702,
63,
1144,
63,
1452,
199,
646,
11354,
14,
2537,
199,
504,
11354,
14,
2537,
492,
702,
63,
1452,
12,
6534,
199,
199,
504,
2508,
492,
18036,
465,
24633,
199,
199,
2393,
275,
980,
14,
2355,
14,
15726,
8,
1838,
8,
1130,
8,
2181,
12,
298,
396,
63,
24365,
13324,
199,
65,
63,
4791,
275,
10717,
14,
10843,
8,
1960,
9,
421,
199,
318,
511,
63,
11146,
837,
272,
408,
774,
626,
8498,
14183,
3637,
10557,
314,
2451,
6385,
315,
32490,
5560,
1041,
272,
282,
63,
4548,
275,
980,
14,
4548,
8,
709,
9,
272,
302,
63,
4930,
275,
959,
272,
734,
17,
275,
24633,
14,
11146,
8,
65,
63,
4548,
12,
302,
63,
4930,
29,
78,
63,
4930,
9,
272,
702,
63,
1144,
63,
1452,
8,
548,
17,
12,
980,
14,
4548,
8,
78,
63,
4930,
430,
272,
734,
18,
275,
24633,
14,
11146,
8,
65,
63,
4548,
12,
302,
63,
4930,
29,
78,
63,
4930,
12,
2562,
29,
1590,
14,
13106,
9,
272,
702,
63,
1144,
63,
1452,
8,
548,
18,
12,
980,
14,
4548,
8,
78,
63,
4930,
430,
421,
199,
318,
511,
63,
11146,
63,
1267,
837,
272,
408,
774,
626,
781,
664,
282,
15865,
1625,
402,
314,
2451,
2215,
1041,
272,
734,
275,
24633,
14,
11146,
8,
65,
63,
4791,
9,
272,
702,
63,
1452,
8,
552,
8,
548,
395,
11630,
9,
339,
302,
63,
4930,
275,
2948,
272,
734,
275,
24633,
14,
11146,
8,
65,
63,
4791,
12,
302,
63,
4930,
29,
78,
63,
4930,
9,
272,
702,
63,
1452,
8,
552,
8,
548,
395,
302,
63,
4930,
9,
421,
199,
318,
511,
63,
11146,
63,
1842,
837,
272,
408,
774,
626,
20198,
15521,
282,
2196,
1625,
2612,
588,
4453,
314,
2451,
1425,
1041,
272,
1748,
12,
1390,
275,
282,
63,
4791,
14,
827,
1062,
282,
63,
4791,
14,
988,
342,
272,
734,
275,
24633,
14,
11146,
8,
65,
63,
4791,
9,
272,
11354,
14,
2537,
14,
479,
63,
2003,
8,
827,
12,
734,
14,
827,
1012,
272,
11354,
14,
2537,
14,
479,
63,
13154,
63,
1452,
8,
988,
12,
734,
14,
988,
1012,
421,
199,
318,
511,
63,
11146,
63,
3029,
1273,
837,
272,
408,
774,
626,
15865,
5419,
543,
3663,
1324,
6572,
1041,
272,
671,
275,
980,
14,
20221,
4038,
17,
12,
1616,
61,
367,
284,
315,
1425,
8,
709,
3948,
272,
612,
275,
980,
14,
20221,
4038,
21,
12,
959,
61,
367,
284,
315,
1425,
8,
709,
3948,
339,
511,
63,
1532,
275,
2400,
671,
12,
612,
26,
980,
14,
20221,
1332,
88,
12,
612,
4992,
988,
8,
3127,
29,
16,
9,
272,
734,
63,
6514,
275,
24633,
14,
11146,
8,
88,
12,
612,
12,
302,
63,
4930,
29,
18,
12,
2562,
29,
396,
63,
1532,
9,
272,
734,
63,
19361,
275,
980,
14,
1144,
4038,
21,
12,
1616,
467,
359,
21,
12,
1616,
3934,
272,
702,
63,
1144,
63,
1452,
8,
548,
63,
6514,
12,
734,
63,
19361,
9,
421,
199,
318,
511,
63,
11146,
63,
3127,
837,
272,
408,
774,
3114,
17582,
370,
15865,
805,
1041,
272,
671,
275,
10717,
14,
10843,
8,
709,
12,
3388,
9,
272,
302,
63,
4930,
275,
2948,
272,
734,
63,
885,
275,
24633,
14,
11146,
8,
88,
12,
302,
63,
4930,
29,
78,
63,
4930,
9,
272,
702,
63,
1452,
8,
548,
63,
885,
14,
1392,
12,
334,
78,
63,
4930,
4641,
272,
734,
63,
3127,
275,
24633,
14,
11146,
8,
88,
12,
302,
63,
4930,
29,
78,
63,
4930,
12,
3114,
29,
16,
9,
272,
702,
63,
1452,
8,
548,
63,
3127,
14,
1392,
12,
334,
78,
63,
4930,
12,
3388,
430,
421,
199,
318,
511,
63,
11146,
63,
2355,
63,
5176,
837,
272,
408,
774,
626,
781,
883,
664,
295,
496,
2033,
559,
830,
522,
1889,
701,
6347,
316,
314,
820,
12259,
1041,
272,
666,
275,
10717,
14,
10843,
8,
1400,
9,
272,
6347,
275,
5685,
272,
8498,
83,
17,
275,
24633,
14,
11146,
8,
576,
12,
2196,
63,
5176,
29,
5176,
9,
272,
8498,
83,
18,
275,
24633,
14,
11146,
8,
576,
12,
2196,
63,
5176,
29,
5176,
9,
272,
702,
63,
1144,
63,
1452,
8,
4930,
83,
17,
12,
8498,
83,
18,
9,
421,
199,
318,
511,
63,
19169,
63,
11146,
837,
272,
408,
774,
19608,
15865,
1041,
272,
671,
275,
10717,
14,
10843,
8,
1046,
9,
272,
302,
63,
4930,
275,
2948,
272,
734,
63,
19169,
275,
24633,
14,
11146,
8,
88,
12,
302,
63,
4930,
29,
78,
63,
4930,
12,
1816,
19608,
29,
549,
12,
2562,
29,
1590,
14,
13106,
9,
272,
702,
8,
1397,
980,
14,
13106,
8,
548,
63,
19169,
9,
315,
671,
9,
421,
199,
318,
511,
63,
11146,
63,
1446,
837,
272,
408,
774,
15865,
402,
593,
5296,
1402,
5542,
1041,
272,
312,
478,
63,
3269,
275,
2400,
1323,
12,
612,
26,
980,
14,
3287,
8,
1590,
14,
3287,
8,
1590,
14,
10096,
14,
5350,
8,
3303,
980,
14,
3287,
8,
56,
14,
52,
12,
1323,
1826,
1323,
14,
52,
395,
612,
9,
272,
1323,
275,
980,
14,
2301,
63,
2340,
1332,
2393,
14,
10843,
8,
1400,
12,
841,
395,
980,
14,
4548,
8,
1400,
1724,
272,
336,
275,
359,
18,
12,
841,
12,
378,
12,
650,
12,
959,
61,
272,
612,
63,
889,
19765,
275,
980,
14,
3287,
8,
56,
12,
336,
9,
435,
10717,
14,
10843,
8,
1400,
9,
627,
3388,
272,
612,
63,
674,
11838,
275,
980,
14,
3287,
8,
56,
12,
336,
9,
435,
10717,
14,
10843,
8,
1400,
9,
339,
302,
63,
4930,
275,
6891,
272,
336,
63,
4930,
63,
889,
19765,
275,
24633,
14,
11146,
8,
56,
12,
612,
63,
889,
19765,
12,
3303,
302,
63,
4930,
29,
78,
63,
4930,
12,
3303,
2562,
29,
1446,
63,
3269,
9,
272,
336,
63,
4930,
63,
674,
11838,
275,
24633,
14,
11146,
8,
56,
12,
612,
63,
674,
11838,
12,
3660,
302,
63,
4930,
29,
78,
63,
4930,
12,
3660,
2562,
29,
1446,
63,
3269,
9,
339,
702,
63,
1452
] |
[
2680,
465,
980,
199,
504,
7026,
492,
5020,
199,
504,
2508,
5159,
14,
4174,
14,
4912,
492,
1425,
199,
199,
646,
2680,
14,
4776,
465,
29340,
199,
504,
2680,
14,
4776,
492,
702,
63,
1144,
63,
1452,
199,
646,
11354,
14,
2537,
199,
504,
11354,
14,
2537,
492,
702,
63,
1452,
12,
6534,
199,
199,
504,
2508,
492,
18036,
465,
24633,
199,
199,
2393,
275,
980,
14,
2355,
14,
15726,
8,
1838,
8,
1130,
8,
2181,
12,
298,
396,
63,
24365,
13324,
199,
65,
63,
4791,
275,
10717,
14,
10843,
8,
1960,
9,
421,
199,
318,
511,
63,
11146,
837,
272,
408,
774,
626,
8498,
14183,
3637,
10557,
314,
2451,
6385,
315,
32490,
5560,
1041,
272,
282,
63,
4548,
275,
980,
14,
4548,
8,
709,
9,
272,
302,
63,
4930,
275,
959,
272,
734,
17,
275,
24633,
14,
11146,
8,
65,
63,
4548,
12,
302,
63,
4930,
29,
78,
63,
4930,
9,
272,
702,
63,
1144,
63,
1452,
8,
548,
17,
12,
980,
14,
4548,
8,
78,
63,
4930,
430,
272,
734,
18,
275,
24633,
14,
11146,
8,
65,
63,
4548,
12,
302,
63,
4930,
29,
78,
63,
4930,
12,
2562,
29,
1590,
14,
13106,
9,
272,
702,
63,
1144,
63,
1452,
8,
548,
18,
12,
980,
14,
4548,
8,
78,
63,
4930,
430,
421,
199,
318,
511,
63,
11146,
63,
1267,
837,
272,
408,
774,
626,
781,
664,
282,
15865,
1625,
402,
314,
2451,
2215,
1041,
272,
734,
275,
24633,
14,
11146,
8,
65,
63,
4791,
9,
272,
702,
63,
1452,
8,
552,
8,
548,
395,
11630,
9,
339,
302,
63,
4930,
275,
2948,
272,
734,
275,
24633,
14,
11146,
8,
65,
63,
4791,
12,
302,
63,
4930,
29,
78,
63,
4930,
9,
272,
702,
63,
1452,
8,
552,
8,
548,
395,
302,
63,
4930,
9,
421,
199,
318,
511,
63,
11146,
63,
1842,
837,
272,
408,
774,
626,
20198,
15521,
282,
2196,
1625,
2612,
588,
4453,
314,
2451,
1425,
1041,
272,
1748,
12,
1390,
275,
282,
63,
4791,
14,
827,
1062,
282,
63,
4791,
14,
988,
342,
272,
734,
275,
24633,
14,
11146,
8,
65,
63,
4791,
9,
272,
11354,
14,
2537,
14,
479,
63,
2003,
8,
827,
12,
734,
14,
827,
1012,
272,
11354,
14,
2537,
14,
479,
63,
13154,
63,
1452,
8,
988,
12,
734,
14,
988,
1012,
421,
199,
318,
511,
63,
11146,
63,
3029,
1273,
837,
272,
408,
774,
626,
15865,
5419,
543,
3663,
1324,
6572,
1041,
272,
671,
275,
980,
14,
20221,
4038,
17,
12,
1616,
61,
367,
284,
315,
1425,
8,
709,
3948,
272,
612,
275,
980,
14,
20221,
4038,
21,
12,
959,
61,
367,
284,
315,
1425,
8,
709,
3948,
339,
511,
63,
1532,
275,
2400,
671,
12,
612,
26,
980,
14,
20221,
1332,
88,
12,
612,
4992,
988,
8,
3127,
29,
16,
9,
272,
734,
63,
6514,
275,
24633,
14,
11146,
8,
88,
12,
612,
12,
302,
63,
4930,
29,
18,
12,
2562,
29,
396,
63,
1532,
9,
272,
734,
63,
19361,
275,
980,
14,
1144,
4038,
21,
12,
1616,
467,
359,
21,
12,
1616,
3934,
272,
702,
63,
1144,
63,
1452,
8,
548,
63,
6514,
12,
734,
63,
19361,
9,
421,
199,
318,
511,
63,
11146,
63,
3127,
837,
272,
408,
774,
3114,
17582,
370,
15865,
805,
1041,
272,
671,
275,
10717,
14,
10843,
8,
709,
12,
3388,
9,
272,
302,
63,
4930,
275,
2948,
272,
734,
63,
885,
275,
24633,
14,
11146,
8,
88,
12,
302,
63,
4930,
29,
78,
63,
4930,
9,
272,
702,
63,
1452,
8,
548,
63,
885,
14,
1392,
12,
334,
78,
63,
4930,
4641,
272,
734,
63,
3127,
275,
24633,
14,
11146,
8,
88,
12,
302,
63,
4930,
29,
78,
63,
4930,
12,
3114,
29,
16,
9,
272,
702,
63,
1452,
8,
548,
63,
3127,
14,
1392,
12,
334,
78,
63,
4930,
12,
3388,
430,
421,
199,
318,
511,
63,
11146,
63,
2355,
63,
5176,
837,
272,
408,
774,
626,
781,
883,
664,
295,
496,
2033,
559,
830,
522,
1889,
701,
6347,
316,
314,
820,
12259,
1041,
272,
666,
275,
10717,
14,
10843,
8,
1400,
9,
272,
6347,
275,
5685,
272,
8498,
83,
17,
275,
24633,
14,
11146,
8,
576,
12,
2196,
63,
5176,
29,
5176,
9,
272,
8498,
83,
18,
275,
24633,
14,
11146,
8,
576,
12,
2196,
63,
5176,
29,
5176,
9,
272,
702,
63,
1144,
63,
1452,
8,
4930,
83,
17,
12,
8498,
83,
18,
9,
421,
199,
318,
511,
63,
19169,
63,
11146,
837,
272,
408,
774,
19608,
15865,
1041,
272,
671,
275,
10717,
14,
10843,
8,
1046,
9,
272,
302,
63,
4930,
275,
2948,
272,
734,
63,
19169,
275,
24633,
14,
11146,
8,
88,
12,
302,
63,
4930,
29,
78,
63,
4930,
12,
1816,
19608,
29,
549,
12,
2562,
29,
1590,
14,
13106,
9,
272,
702,
8,
1397,
980,
14,
13106,
8,
548,
63,
19169,
9,
315,
671,
9,
421,
199,
318,
511,
63,
11146,
63,
1446,
837,
272,
408,
774,
15865,
402,
593,
5296,
1402,
5542,
1041,
272,
312,
478,
63,
3269,
275,
2400,
1323,
12,
612,
26,
980,
14,
3287,
8,
1590,
14,
3287,
8,
1590,
14,
10096,
14,
5350,
8,
3303,
980,
14,
3287,
8,
56,
14,
52,
12,
1323,
1826,
1323,
14,
52,
395,
612,
9,
272,
1323,
275,
980,
14,
2301,
63,
2340,
1332,
2393,
14,
10843,
8,
1400,
12,
841,
395,
980,
14,
4548,
8,
1400,
1724,
272,
336,
275,
359,
18,
12,
841,
12,
378,
12,
650,
12,
959,
61,
272,
612,
63,
889,
19765,
275,
980,
14,
3287,
8,
56,
12,
336,
9,
435,
10717,
14,
10843,
8,
1400,
9,
627,
3388,
272,
612,
63,
674,
11838,
275,
980,
14,
3287,
8,
56,
12,
336,
9,
435,
10717,
14,
10843,
8,
1400,
9,
339,
302,
63,
4930,
275,
6891,
272,
336,
63,
4930,
63,
889,
19765,
275,
24633,
14,
11146,
8,
56,
12,
612,
63,
889,
19765,
12,
3303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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
] |
Revanth47/addons-server
|
src/olympia/zadmin/models.py
|
3
|
10439
|
from decimal import Decimal
import json
import hashlib
import caching
from django.conf import settings
from django.db import models
from django.db.models import F
from olympia import amo
from olympia.amo.models import ModelBase
from olympia.amo.urlresolvers import reverse
from olympia.applications.models import AppVersion
from olympia.files.models import File
class Config(caching.base.CachingMixin, models.Model):
"""Sitewide settings."""
key = models.CharField(max_length=255, primary_key=True)
value = models.TextField()
objects = caching.base.CachingManager()
class Meta:
db_table = u'config'
def __unicode__(self):
return self.key
@property
def json(self):
try:
return json.loads(self.value)
except (TypeError, ValueError):
return {}
def get_config(conf):
try:
return Config.objects.get(key=conf).value
except Config.DoesNotExist:
return
def set_config(conf, value):
cf, created = Config.objects.get_or_create(key=conf)
cf.value = value
cf.save()
class ValidationJob(ModelBase):
application = models.PositiveIntegerField(choices=amo.APPS_CHOICES,
db_column='application_id')
curr_max_version = models.ForeignKey(AppVersion,
related_name='validation_current_set')
target_version = models.ForeignKey(AppVersion,
related_name='validation_target_set')
finish_email = models.EmailField(null=True, max_length=75)
completed = models.DateTimeField(null=True, db_index=True)
creator = models.ForeignKey('users.UserProfile', null=True)
def result_passing(self):
return self.result_set.exclude(completed=None).filter(errors=0,
task_error=None)
def result_completed(self):
return self.result_set.exclude(completed=None)
def result_errors(self):
return self.result_set.exclude(task_error=None)
def result_failing(self):
return self.result_set.exclude(completed=None).filter(errors__gt=0)
@property
def preview_notify_mail_link(self):
return self._preview_link(EmailPreviewTopic(self, 'notify'))
def _preview_link(self, topic):
qs = topic.filter()
if qs.count():
return reverse('zadmin.email_preview_csv', args=[topic.topic])
def preview_notify_mail(self, *args, **kwargs):
EmailPreviewTopic(self, 'notify').send_mail(*args, **kwargs)
def get_notify_preview_emails(self):
return EmailPreviewTopic(self, 'notify').filter()
def is_complete(self, as_int=False):
completed = self.completed is not None
if as_int:
return 1 if completed else 0
else:
return completed
@property
def stats(self):
if not hasattr(self, '_stats'):
self._stats = self._count_stats()
return self._stats
def _count_stats(self):
total = self.result_set.count()
completed = self.result_completed().count()
passing = self.result_passing().count()
errors = self.result_errors().count()
failing = self.result_failing().count()
return {
'job_id': self.pk,
'total': total,
'completed': completed,
'completed_timestamp': str(self.completed or ''),
'passing': passing,
'failing': failing,
'errors': errors,
'percent_complete': (
Decimal(completed) / Decimal(total) * Decimal(100)
if (total and completed) else 0),
}
class Meta:
db_table = 'validation_job'
class ValidationResult(ModelBase):
"""Result of a single validation task based on the addon file.
This is different than FileValidation because it allows multiple
validation results per file.
"""
validation_job = models.ForeignKey(ValidationJob,
related_name='result_set')
file = models.ForeignKey(File, related_name='validation_results')
valid = models.BooleanField(default=False)
errors = models.IntegerField(default=0, null=True)
warnings = models.IntegerField(default=0, null=True)
notices = models.IntegerField(default=0, null=True)
validation = models.TextField(null=True)
task_error = models.TextField(null=True)
completed = models.DateTimeField(null=True, db_index=True)
class Meta:
db_table = 'validation_result'
def apply_validation(self, validation):
self.validation = validation
results = json.loads(validation)
compat = results['compatibility_summary']
# TODO(Kumar) these numbers should not be combined. See bug 657936.
self.errors = results['errors'] + compat['errors']
self.warnings = results['warnings'] + compat['warnings']
self.notices = results['notices'] + compat['notices']
self.valid = self.errors == 0
generated = 'testcases_regex.generic._generated'
messages = results['messages']
message_ids = [(msg, '.'.join(msg['id'])) for msg in messages]
message_ids = [
hashlib.md5(msg['message']).hexdigest() if msg_id == generated
else msg_id for msg, msg_id in message_ids]
message_summary = {}
for message, message_id in zip(messages, message_ids):
compat_type = message.get('compatibility_type')
if not compat_type or compat_type != 'error':
continue
if message_id not in message_summary:
message_summary[message_id] = (
ValidationResultMessage.objects.get_or_create(
message_id=message_id,
validation_job=self.validation_job,
defaults={
'message': message.get('message', ''),
'compat_type': compat_type,
}
)[0]
)
for message in message_summary.values():
# All relevant messages are already created, to avoid
# any side-effects we run a separate UPDATE query instead
# of an explicit `.save()` so that the database handles atomic
# increments for us.
ValidationResultMessage.objects.filter(pk=message.pk).update(
addons_affected=F('addons_affected') + 1
)
ValidationResultAffectedAddon.objects.create(
validation_result_message=message,
addon=self.file.version.addon)
class ValidationResultMessage(ModelBase):
"""Summary of validation result messages"""
validation_job = models.ForeignKey(ValidationJob,
related_name='message_summary')
message_id = models.CharField(max_length=256)
message = models.TextField()
compat_type = models.CharField(max_length=256)
addons_affected = models.PositiveIntegerField(default=0)
class ValidationResultAffectedAddon(ModelBase):
"""Link to an add-on that is affected by a specific validation message."""
addon = models.ForeignKey('addons.Addon')
validation_result_message = models.ForeignKey(ValidationResultMessage)
class EmailPreviewTopic(object):
"""Store emails in a given topic so an admin can preview before
re-sending.
A topic is a unique string identifier that groups together preview emails.
If you pass in an object (a Model instance) you will get a poor man's
foreign key as your topic.
For example, EmailPreviewTopic(addon) will link all preview emails to
the ID of that addon object.
"""
def __init__(self, object=None, suffix='', topic=None):
if not topic:
assert object, 'object keyword is required when topic is empty'
topic = '%s-%s-%s' % (object.__class__._meta.db_table, object.pk,
suffix)
self.topic = topic
def filter(self, *args, **kw):
kw['topic'] = self.topic
return EmailPreview.objects.filter(**kw)
def send_mail(self, subject, body,
from_email=settings.DEFAULT_FROM_EMAIL,
recipient_list=None):
if recipient_list is None:
recipient_list = tuple([])
return EmailPreview.objects.create(
topic=self.topic,
subject=subject, body=body,
recipient_list=u','.join(recipient_list),
from_email=from_email)
class EmailPreview(ModelBase):
"""A log of emails for previewing purposes.
This is only for development and the data might get deleted at any time.
"""
topic = models.CharField(max_length=255, db_index=True)
recipient_list = models.TextField() # comma separated list of emails
from_email = models.EmailField(max_length=75)
subject = models.CharField(max_length=255)
body = models.TextField()
class Meta:
db_table = 'email_preview'
class SiteEvent(models.Model):
"""Information records about downtime, releases, and other pertinent
events on the site."""
SITE_EVENT_CHOICES = amo.SITE_EVENT_CHOICES.items()
start = models.DateField(db_index=True,
help_text='The time at which the event began.')
end = models.DateField(
db_index=True, null=True, blank=True,
help_text='If the event was a range, the time at which it ended.')
event_type = models.PositiveIntegerField(choices=SITE_EVENT_CHOICES,
db_index=True, default=0)
description = models.CharField(max_length=255, blank=True, null=True)
# An outbound link to an explanatory blog post or bug.
more_info_url = models.URLField(max_length=255, blank=True, null=True)
class Meta:
db_table = 'zadmin_siteevent'
class DownloadSource(models.Model):
# e.g., `mkt-search` or `mkt-detail-`.
name = models.CharField(max_length=255)
# e.g., `full` or `prefix`.
type = models.CharField(max_length=255)
description = models.TextField()
created = models.DateTimeField(auto_now_add=True)
class Meta:
db_table = 'download_sources'
def __unicode__(self):
return u'%s (%s)' % (self.name, self.type)
|
bsd-3-clause
|
[
504,
6107,
492,
6345,
199,
646,
2022,
199,
646,
8337,
199,
199,
646,
13627,
199,
199,
504,
1639,
14,
2190,
492,
2202,
199,
504,
1639,
14,
697,
492,
1709,
199,
504,
1639,
14,
697,
14,
992,
492,
481,
199,
199,
504,
312,
590,
311,
4674,
492,
30235,
199,
504,
312,
590,
311,
4674,
14,
4393,
14,
992,
492,
5822,
1563,
199,
504,
312,
590,
311,
4674,
14,
4393,
14,
16522,
492,
3837,
199,
504,
312,
590,
311,
4674,
14,
15853,
14,
992,
492,
4693,
3353,
199,
504,
312,
590,
311,
4674,
14,
1725,
14,
992,
492,
3814,
421,
199,
533,
4094,
8,
22738,
14,
1095,
14,
35,
23302,
4256,
12,
1709,
14,
1685,
304,
272,
408,
8972,
13062,
2202,
1041,
272,
790,
275,
1709,
14,
2183,
8,
988,
63,
1267,
29,
2299,
12,
5062,
63,
498,
29,
549,
9,
272,
574,
275,
1709,
14,
6254,
342,
272,
2251,
275,
13627,
14,
1095,
14,
35,
23302,
2988,
342,
339,
1021,
6288,
26,
267,
1592,
63,
1224,
275,
399,
7,
888,
7,
339,
347,
636,
2975,
721,
277,
304,
267,
372,
291,
14,
498,
339,
768,
1829,
272,
347,
2022,
8,
277,
304,
267,
862,
26,
288,
372,
2022,
14,
3640,
8,
277,
14,
585,
9,
267,
871,
334,
4333,
12,
1722,
304,
288,
372,
1052,
421,
199,
318,
664,
63,
888,
8,
2190,
304,
272,
862,
26,
267,
372,
4094,
14,
1462,
14,
362,
8,
498,
29,
2190,
680,
585,
272,
871,
4094,
14,
7400,
26,
267,
372,
421,
199,
318,
663,
63,
888,
8,
2190,
12,
574,
304,
272,
3980,
12,
2737,
275,
4094,
14,
1462,
14,
362,
63,
269,
63,
981,
8,
498,
29,
2190,
9,
272,
3980,
14,
585,
275,
574,
272,
3980,
14,
2117,
342,
421,
199,
533,
19381,
6694,
8,
1685,
1563,
304,
272,
4223,
275,
1709,
14,
8591,
8,
4577,
29,
4393,
14,
14219,
63,
16236,
12,
6343,
1592,
63,
2301,
534,
3578,
63,
344,
358,
272,
8230,
63,
988,
63,
1023,
275,
1709,
14,
3190,
8,
2640,
3353,
12,
1460,
4048,
63,
354,
534,
6136,
63,
1818,
63,
409,
358,
272,
1347,
63,
1023,
275,
1709,
14,
3190,
8,
2640,
3353,
12,
4318,
4048,
63,
354,
534,
6136,
63,
1375,
63,
409,
358,
272,
9578,
63,
2123,
275,
1709,
14,
16577,
8,
2307,
29,
549,
12,
1390,
63,
1267,
29,
2194,
9,
272,
9709,
275,
1709,
14,
4626,
8,
2307,
29,
549,
12,
1592,
63,
1080,
29,
549,
9,
272,
14875,
275,
1709,
14,
3190,
360,
3707,
14,
23544,
297,
2973,
29,
549,
9,
339,
347,
754,
63,
29436,
8,
277,
304,
267,
372,
291,
14,
1099,
63,
409,
14,
5473,
8,
12634,
29,
403,
680,
1541,
8,
2550,
29,
16,
12,
16854,
2120,
63,
705,
29,
403,
9,
339,
347,
754,
63,
12634,
8,
277,
304,
267,
372,
291,
14,
1099,
63,
409,
14,
5473,
8,
12634,
29,
403,
9,
339,
347,
754,
63,
2550,
8,
277,
304,
267,
372,
291,
14,
1099,
63,
409,
14,
5473,
8,
1765,
63,
705,
29,
403,
9,
339,
347,
754,
63,
25299,
8,
277,
304,
267,
372,
291,
14,
1099,
63,
409,
14,
5473,
8,
12634,
29,
403,
680,
1541,
8,
2550,
363,
3308,
29,
16,
9,
339,
768,
1829,
272,
347,
19653,
63,
6814,
63,
1198,
63,
1073,
8,
277,
304,
267,
372,
291,
423,
7780,
63,
1073,
8,
7035,
27116,
12157,
8,
277,
12,
283,
6814,
1333,
339,
347,
485,
7780,
63,
1073,
8,
277,
12,
7482,
304,
267,
6377,
275,
7482,
14,
1541,
342,
267,
340,
6377,
14,
835,
837,
288,
372,
3837,
360,
90,
2113,
14,
2123,
63,
7780,
63,
4737,
297,
1249,
1524,
5746,
14,
5746,
566,
339,
347,
19653,
63,
6814,
63,
1198,
8,
277,
12,
627,
589,
12,
1011,
958,
304,
267,
11426,
27116,
12157,
8,
277,
12,
283,
6814,
1959,
2254,
63,
1198,
2031,
589,
12,
1011,
958,
9,
339,
347,
664,
63,
6814,
63,
7780,
63,
14170,
8,
277,
304,
267,
372,
11426,
27116,
12157,
8,
277,
12,
283,
6814,
1959,
1541,
342,
339,
347,
365,
63,
4883,
8,
277,
12,
465,
63,
442,
29,
797,
304,
267,
9709,
275,
291,
14,
12634,
365,
440,
488,
267,
340,
465,
63,
442,
26,
288,
372,
413,
340,
9709,
587,
378,
267,
587,
26,
288,
372,
9709,
339,
768,
1829,
272,
347,
5020,
8,
277,
304,
267,
340,
440,
2688,
8,
277,
12,
2513,
3200,
735,
288,
291,
423,
3200,
275,
291,
423,
835,
63,
3200,
342,
267,
372,
291,
423,
3200,
339,
347,
485,
835,
63,
3200,
8,
277,
304,
267,
3141,
275,
291,
14,
1099,
63,
409,
14,
835,
342,
267,
9709,
275,
291,
14,
1099,
63,
12634,
1252,
835,
342,
267,
9476,
275,
291,
14,
1099,
63,
29436,
1252,
835,
342,
267,
2552,
275,
291,
14,
1099,
63,
2550,
1252,
835,
342,
267,
18648,
275,
291,
14,
1099,
63,
25299,
1252,
835,
342,
267,
372,
469,
288,
283,
2423,
63,
344,
356,
291,
14,
2051,
12,
288,
283,
2923,
356,
3141,
12,
288,
283,
12634,
356,
9709,
12,
288,
283,
12634,
63,
3954,
356,
620,
8,
277,
14,
12634,
503,
9929,
288,
283,
29436,
356,
9476,
12,
288,
283,
25299,
356,
18648,
12,
288,
283,
2550,
356,
2552,
12,
288,
283,
7045,
63,
4883,
356,
334,
355,
6345,
8,
12634,
9,
1182,
6345,
8,
2923,
9,
627,
6345,
8,
1960,
9,
355,
340,
334,
2923,
436,
9709,
9,
587,
378,
395,
267,
789,
339,
1021,
6288,
26,
267,
1592,
63,
1224,
275,
283,
6136,
63,
2423,
7,
421,
199,
533,
19381,
2889,
8,
1685,
1563,
304,
272,
408,
2889,
402,
282,
2849,
6411,
2120,
4079,
641,
314,
13553,
570,
14,
339,
961,
365,
3365,
2419,
3814,
13816,
2952,
652,
6127,
3663,
272,
6411,
2058,
1126,
570,
14,
272,
408,
272,
6411,
63,
2423,
275,
1709,
14,
3190,
8,
13816,
6694,
12,
4318,
4048,
63,
354,
534,
1099,
63,
409,
358,
272,
570,
275,
1709,
14,
3190,
8,
1173,
12,
4048,
63,
354,
534,
6136,
63,
2604,
358,
272,
1686,
275,
1709,
14,
5036,
8,
885,
29,
797,
9,
272,
2552,
275,
1709,
14,
3901,
8,
885,
29,
16,
12,
2973,
29,
549,
9,
272,
3598,
275,
1709,
14,
3901,
8
] |
[
6107,
492,
6345,
199,
646,
2022,
199,
646,
8337,
199,
199,
646,
13627,
199,
199,
504,
1639,
14,
2190,
492,
2202,
199,
504,
1639,
14,
697,
492,
1709,
199,
504,
1639,
14,
697,
14,
992,
492,
481,
199,
199,
504,
312,
590,
311,
4674,
492,
30235,
199,
504,
312,
590,
311,
4674,
14,
4393,
14,
992,
492,
5822,
1563,
199,
504,
312,
590,
311,
4674,
14,
4393,
14,
16522,
492,
3837,
199,
504,
312,
590,
311,
4674,
14,
15853,
14,
992,
492,
4693,
3353,
199,
504,
312,
590,
311,
4674,
14,
1725,
14,
992,
492,
3814,
421,
199,
533,
4094,
8,
22738,
14,
1095,
14,
35,
23302,
4256,
12,
1709,
14,
1685,
304,
272,
408,
8972,
13062,
2202,
1041,
272,
790,
275,
1709,
14,
2183,
8,
988,
63,
1267,
29,
2299,
12,
5062,
63,
498,
29,
549,
9,
272,
574,
275,
1709,
14,
6254,
342,
272,
2251,
275,
13627,
14,
1095,
14,
35,
23302,
2988,
342,
339,
1021,
6288,
26,
267,
1592,
63,
1224,
275,
399,
7,
888,
7,
339,
347,
636,
2975,
721,
277,
304,
267,
372,
291,
14,
498,
339,
768,
1829,
272,
347,
2022,
8,
277,
304,
267,
862,
26,
288,
372,
2022,
14,
3640,
8,
277,
14,
585,
9,
267,
871,
334,
4333,
12,
1722,
304,
288,
372,
1052,
421,
199,
318,
664,
63,
888,
8,
2190,
304,
272,
862,
26,
267,
372,
4094,
14,
1462,
14,
362,
8,
498,
29,
2190,
680,
585,
272,
871,
4094,
14,
7400,
26,
267,
372,
421,
199,
318,
663,
63,
888,
8,
2190,
12,
574,
304,
272,
3980,
12,
2737,
275,
4094,
14,
1462,
14,
362,
63,
269,
63,
981,
8,
498,
29,
2190,
9,
272,
3980,
14,
585,
275,
574,
272,
3980,
14,
2117,
342,
421,
199,
533,
19381,
6694,
8,
1685,
1563,
304,
272,
4223,
275,
1709,
14,
8591,
8,
4577,
29,
4393,
14,
14219,
63,
16236,
12,
6343,
1592,
63,
2301,
534,
3578,
63,
344,
358,
272,
8230,
63,
988,
63,
1023,
275,
1709,
14,
3190,
8,
2640,
3353,
12,
1460,
4048,
63,
354,
534,
6136,
63,
1818,
63,
409,
358,
272,
1347,
63,
1023,
275,
1709,
14,
3190,
8,
2640,
3353,
12,
4318,
4048,
63,
354,
534,
6136,
63,
1375,
63,
409,
358,
272,
9578,
63,
2123,
275,
1709,
14,
16577,
8,
2307,
29,
549,
12,
1390,
63,
1267,
29,
2194,
9,
272,
9709,
275,
1709,
14,
4626,
8,
2307,
29,
549,
12,
1592,
63,
1080,
29,
549,
9,
272,
14875,
275,
1709,
14,
3190,
360,
3707,
14,
23544,
297,
2973,
29,
549,
9,
339,
347,
754,
63,
29436,
8,
277,
304,
267,
372,
291,
14,
1099,
63,
409,
14,
5473,
8,
12634,
29,
403,
680,
1541,
8,
2550,
29,
16,
12,
16854,
2120,
63,
705,
29,
403,
9,
339,
347,
754,
63,
12634,
8,
277,
304,
267,
372,
291,
14,
1099,
63,
409,
14,
5473,
8,
12634,
29,
403,
9,
339,
347,
754,
63,
2550,
8,
277,
304,
267,
372,
291,
14,
1099,
63,
409,
14,
5473,
8,
1765,
63,
705,
29,
403,
9,
339,
347,
754,
63,
25299,
8,
277,
304,
267,
372,
291,
14,
1099,
63,
409,
14,
5473,
8,
12634,
29,
403,
680,
1541,
8,
2550,
363,
3308,
29,
16,
9,
339,
768,
1829,
272,
347,
19653,
63,
6814,
63,
1198,
63,
1073,
8,
277,
304,
267,
372,
291,
423,
7780,
63,
1073,
8,
7035,
27116,
12157,
8,
277,
12,
283,
6814,
1333,
339,
347,
485,
7780,
63,
1073,
8,
277,
12,
7482,
304,
267,
6377,
275,
7482,
14,
1541,
342,
267,
340,
6377,
14,
835,
837,
288,
372,
3837,
360,
90,
2113,
14,
2123,
63,
7780,
63,
4737,
297,
1249,
1524,
5746,
14,
5746,
566,
339,
347,
19653,
63,
6814,
63,
1198,
8,
277,
12,
627,
589,
12,
1011,
958,
304,
267,
11426,
27116,
12157,
8,
277,
12,
283,
6814,
1959,
2254,
63,
1198,
2031,
589,
12,
1011,
958,
9,
339,
347,
664,
63,
6814,
63,
7780,
63,
14170,
8,
277,
304,
267,
372,
11426,
27116,
12157,
8,
277,
12,
283,
6814,
1959,
1541,
342,
339,
347,
365,
63,
4883,
8,
277,
12,
465,
63,
442,
29,
797,
304,
267,
9709,
275,
291,
14,
12634,
365,
440,
488,
267,
340,
465,
63,
442,
26,
288,
372,
413,
340,
9709,
587,
378,
267,
587,
26,
288,
372,
9709,
339,
768,
1829,
272,
347,
5020,
8,
277,
304,
267,
340,
440,
2688,
8,
277,
12,
2513,
3200,
735,
288,
291,
423,
3200,
275,
291,
423,
835,
63,
3200,
342,
267,
372,
291,
423,
3200,
339,
347,
485,
835,
63,
3200,
8,
277,
304,
267,
3141,
275,
291,
14,
1099,
63,
409,
14,
835,
342,
267,
9709,
275,
291,
14,
1099,
63,
12634,
1252,
835,
342,
267,
9476,
275,
291,
14,
1099,
63,
29436,
1252,
835,
342,
267,
2552,
275,
291,
14,
1099,
63,
2550,
1252,
835,
342,
267,
18648,
275,
291,
14,
1099,
63,
25299,
1252,
835,
342,
267,
372,
469,
288,
283,
2423,
63,
344,
356,
291,
14,
2051,
12,
288,
283,
2923,
356,
3141,
12,
288,
283,
12634,
356,
9709,
12,
288,
283,
12634,
63,
3954,
356,
620,
8,
277,
14,
12634,
503,
9929,
288,
283,
29436,
356,
9476,
12,
288,
283,
25299,
356,
18648,
12,
288,
283,
2550,
356,
2552,
12,
288,
283,
7045,
63,
4883,
356,
334,
355,
6345,
8,
12634,
9,
1182,
6345,
8,
2923,
9,
627,
6345,
8,
1960,
9,
355,
340,
334,
2923,
436,
9709,
9,
587,
378,
395,
267,
789,
339,
1021,
6288,
26,
267,
1592,
63,
1224,
275,
283,
6136,
63,
2423,
7,
421,
199,
533,
19381,
2889,
8,
1685,
1563,
304,
272,
408,
2889,
402,
282,
2849,
6411,
2120,
4079,
641,
314,
13553,
570,
14,
339,
961,
365,
3365,
2419,
3814,
13816,
2952,
652,
6127,
3663,
272,
6411,
2058,
1126,
570,
14,
272,
408,
272,
6411,
63,
2423,
275,
1709,
14,
3190,
8,
13816,
6694,
12,
4318,
4048,
63,
354,
534,
1099,
63,
409,
358,
272,
570,
275,
1709,
14,
3190,
8,
1173,
12,
4048,
63,
354,
534,
6136,
63,
2604,
358,
272,
1686,
275,
1709,
14,
5036,
8,
885,
29,
797,
9,
272,
2552,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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
] |
jkyeung/XlsxWriter
|
xlsxwriter/test/comparison/test_chart_combined08.py
|
1
|
2754
|
###############################################################################
#
# Tests for XlsxWriter.
#
# Copyright (c), 2013-2016, John McNamara, jmcnamara@cpan.org
#
from ..excel_comparsion_test import ExcelComparisonTest
from ...workbook import Workbook
class TestCompareXLSXFiles(ExcelComparisonTest):
"""
Test file created by XlsxWriter against a file created by Excel.
"""
def setUp(self):
self.maxDiff = None
filename = 'chart_combined08.xlsx'
test_dir = 'xlsxwriter/test/comparison/'
self.got_filename = test_dir + '_test_' + filename
self.exp_filename = test_dir + 'xlsx_files/' + filename
self.ignore_files = []
# TODO. There are too many ignored elements here. Remove when the axis
# writing is fixed for secondary scatter charts.
self.ignore_elements = {'xl/charts/chart1.xml': ['<c:dispBlanksAs',
'<c:crossBetween',
'<c:tickLblPos',
'<c:auto',
'<c:valAx>',
'<c:catAx>',
'</c:valAx>',
'</c:catAx>',
'<c:crosses',
'<c:lblOffset',
'<c:lblAlgn']}
def test_create_file(self):
"""Test the creation of a simple XlsxWriter file."""
workbook = Workbook(self.got_filename)
worksheet = workbook.add_worksheet()
chart1 = workbook.add_chart({'type': 'column'})
chart2 = workbook.add_chart({'type': 'scatter'})
chart1.axis_ids = [81267328, 81297792]
chart2.axis_ids = [81267328, 81297792]
chart2.axis2_ids = [89510656, 84556032]
data = [
[2, 3, 4, 5, 6],
[20, 25, 10, 10, 20],
[5, 10, 15, 10, 5],
]
worksheet.write_column('A1', data[0])
worksheet.write_column('B1', data[1])
worksheet.write_column('C1', data[2])
chart1.add_series({
'categories': '=Sheet1!$A$1:$A$5',
'values': '=Sheet1!$B$1:$B$5'
})
chart2.add_series({
'categories': '=Sheet1!$A$1:$A$5',
'values': '=Sheet1!$C$1:$C$5',
'y2_axis': 1,
})
chart1.combine(chart2)
worksheet.insert_chart('E9', chart1)
workbook.close()
self.assertExcelEqual()
|
bsd-2-clause
|
[
11490,
199,
3,
199,
3,
6496,
367,
1323,
478,
88,
6261,
14,
199,
3,
199,
3,
1898,
334,
67,
395,
6171,
13,
9261,
12,
17815,
22895,
46,
455,
17956,
12,
1335,
5466,
17811,
17956,
32,
1850,
290,
14,
1308,
199,
3,
199,
199,
504,
2508,
28330,
63,
863,
285,
438,
63,
396,
492,
27832,
25834,
774,
199,
504,
2263,
30765,
492,
9361,
2706,
421,
199,
533,
1379,
16051,
56,
5296,
56,
5535,
8,
920,
6067,
25834,
774,
304,
272,
408,
272,
1379,
570,
2737,
701,
1323,
478,
88,
6261,
6169,
282,
570,
2737,
701,
27832,
14,
339,
408,
339,
347,
3613,
8,
277,
304,
267,
291,
14,
988,
10746,
275,
488,
398,
1788,
275,
283,
9019,
63,
17583,
2036,
14,
19023,
88,
7,
398,
511,
63,
694,
275,
283,
19023,
88,
5491,
15,
396,
15,
8547,
4805,
267,
291,
14,
7808,
63,
1501,
275,
511,
63,
694,
435,
2513,
396,
8650,
435,
1788,
267,
291,
14,
1474,
63,
1501,
275,
511,
63,
694,
435,
283,
19023,
88,
63,
1725,
4805,
435,
1788,
398,
291,
14,
4247,
63,
1725,
275,
942,
267,
327,
3254,
14,
6006,
787,
4634,
5002,
5525,
4008,
2348,
14,
5852,
1380,
314,
3114,
267,
327,
3575,
365,
6317,
367,
13851,
28618,
10943,
83,
14,
267,
291,
14,
4247,
63,
5527,
275,
791,
15455,
15,
31522,
15,
9019,
17,
14,
1652,
356,
12329,
67,
26,
13654,
28083,
83,
2822,
297,
12740,
2650,
67,
26,
7925,
24472,
3109,
297,
12740,
2650,
67,
26,
8284,
44,
3345,
6981,
297,
12740,
2650,
67,
26,
2495,
297,
12740,
2650,
67,
26,
637,
28000,
4206,
12740,
2650,
67,
26,
3385,
28000,
4206,
12740,
11936,
67,
26,
637,
28000,
4206,
12740,
11936,
67,
26,
3385,
28000,
4206,
12740,
2650,
67,
26,
20363,
874,
297,
12740,
2650,
67,
26,
18842,
6397,
297,
12740,
2650,
67,
26,
18842,
2439,
784,
12074,
339,
347,
511,
63,
981,
63,
493,
8,
277,
304,
267,
408,
774,
314,
7143,
402,
282,
3486,
1323,
478,
88,
6261,
570,
1041,
398,
1736,
2706,
275,
9361,
2706,
8,
277,
14,
7808,
63,
1501,
9,
398,
21127,
275,
1736,
2706,
14,
525,
63,
29776,
342,
267,
10943,
17,
275,
1736,
2706,
14,
525,
63,
9019,
3252,
466,
356,
283,
2301,
3071,
267,
10943,
18,
275,
1736,
2706,
14,
525,
63,
9019,
3252,
466,
356,
283,
13512,
3071,
398,
10943,
17,
14,
3127,
63,
1580,
275,
359,
29601,
1822,
12870,
12,
1695,
7263,
1138,
2942,
61,
267,
10943,
18,
14,
3127,
63,
1580,
275,
359,
29601,
1822,
12870,
12,
1695,
7263,
1138,
2942,
61,
267,
10943,
18,
14,
3127,
18,
63,
1580,
275,
359,
11382,
7357,
1367,
12,
8264,
1229,
2259,
708,
61,
398,
666,
275,
359,
288,
359,
18,
12,
650,
12,
841,
12,
959,
12,
1227,
467,
288,
359,
1165,
12,
5661,
12,
1616,
12,
1616,
12,
3388,
467,
288,
359,
21,
12,
1616,
12,
4114,
12,
1616,
12,
959,
467,
267,
1622,
398,
21127,
14,
952,
63,
2301,
360,
33,
17,
297,
666,
59,
16,
566,
267,
21127,
14,
952,
63,
2301,
360,
34,
17,
297,
666,
59,
17,
566,
267,
21127,
14,
952,
63,
2301,
360,
35,
17,
297,
666,
59,
18,
566,
398,
10943,
17,
14,
525,
63,
5602,
2561,
288,
283,
8906,
356,
26143,
16715,
17,
1,
4,
33,
4,
17,
26,
4,
33,
4,
21,
297,
288,
283,
1459,
356,
26143,
16715,
17,
1,
4,
34,
4,
17,
26,
4,
34,
4,
21,
7,
267,
3828,
398,
10943,
18,
14,
525,
63,
5602,
2561,
288,
283,
8906,
356,
26143,
16715,
17,
1,
4,
33,
4,
17,
26,
4,
33,
4,
21,
297,
288,
283,
1459,
356,
26143,
16715,
17,
1,
4,
35,
4,
17,
26,
4,
35,
4,
21,
297,
288,
283,
89,
18,
63,
3127,
356,
413,
12,
267,
3828,
398,
10943,
17,
14,
13307,
8,
9019,
18,
9,
398,
21127,
14,
3176,
63,
9019,
360,
37,
25,
297,
10943,
17,
9,
398,
1736,
2706,
14,
1600,
342,
398,
291,
14,
479,
920,
6067,
591,
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
] |
[
199,
3,
199,
3,
6496,
367,
1323,
478,
88,
6261,
14,
199,
3,
199,
3,
1898,
334,
67,
395,
6171,
13,
9261,
12,
17815,
22895,
46,
455,
17956,
12,
1335,
5466,
17811,
17956,
32,
1850,
290,
14,
1308,
199,
3,
199,
199,
504,
2508,
28330,
63,
863,
285,
438,
63,
396,
492,
27832,
25834,
774,
199,
504,
2263,
30765,
492,
9361,
2706,
421,
199,
533,
1379,
16051,
56,
5296,
56,
5535,
8,
920,
6067,
25834,
774,
304,
272,
408,
272,
1379,
570,
2737,
701,
1323,
478,
88,
6261,
6169,
282,
570,
2737,
701,
27832,
14,
339,
408,
339,
347,
3613,
8,
277,
304,
267,
291,
14,
988,
10746,
275,
488,
398,
1788,
275,
283,
9019,
63,
17583,
2036,
14,
19023,
88,
7,
398,
511,
63,
694,
275,
283,
19023,
88,
5491,
15,
396,
15,
8547,
4805,
267,
291,
14,
7808,
63,
1501,
275,
511,
63,
694,
435,
2513,
396,
8650,
435,
1788,
267,
291,
14,
1474,
63,
1501,
275,
511,
63,
694,
435,
283,
19023,
88,
63,
1725,
4805,
435,
1788,
398,
291,
14,
4247,
63,
1725,
275,
942,
267,
327,
3254,
14,
6006,
787,
4634,
5002,
5525,
4008,
2348,
14,
5852,
1380,
314,
3114,
267,
327,
3575,
365,
6317,
367,
13851,
28618,
10943,
83,
14,
267,
291,
14,
4247,
63,
5527,
275,
791,
15455,
15,
31522,
15,
9019,
17,
14,
1652,
356,
12329,
67,
26,
13654,
28083,
83,
2822,
297,
12740,
2650,
67,
26,
7925,
24472,
3109,
297,
12740,
2650,
67,
26,
8284,
44,
3345,
6981,
297,
12740,
2650,
67,
26,
2495,
297,
12740,
2650,
67,
26,
637,
28000,
4206,
12740,
2650,
67,
26,
3385,
28000,
4206,
12740,
11936,
67,
26,
637,
28000,
4206,
12740,
11936,
67,
26,
3385,
28000,
4206,
12740,
2650,
67,
26,
20363,
874,
297,
12740,
2650,
67,
26,
18842,
6397,
297,
12740,
2650,
67,
26,
18842,
2439,
784,
12074,
339,
347,
511,
63,
981,
63,
493,
8,
277,
304,
267,
408,
774,
314,
7143,
402,
282,
3486,
1323,
478,
88,
6261,
570,
1041,
398,
1736,
2706,
275,
9361,
2706,
8,
277,
14,
7808,
63,
1501,
9,
398,
21127,
275,
1736,
2706,
14,
525,
63,
29776,
342,
267,
10943,
17,
275,
1736,
2706,
14,
525,
63,
9019,
3252,
466,
356,
283,
2301,
3071,
267,
10943,
18,
275,
1736,
2706,
14,
525,
63,
9019,
3252,
466,
356,
283,
13512,
3071,
398,
10943,
17,
14,
3127,
63,
1580,
275,
359,
29601,
1822,
12870,
12,
1695,
7263,
1138,
2942,
61,
267,
10943,
18,
14,
3127,
63,
1580,
275,
359,
29601,
1822,
12870,
12,
1695,
7263,
1138,
2942,
61,
267,
10943,
18,
14,
3127,
18,
63,
1580,
275,
359,
11382,
7357,
1367,
12,
8264,
1229,
2259,
708,
61,
398,
666,
275,
359,
288,
359,
18,
12,
650,
12,
841,
12,
959,
12,
1227,
467,
288,
359,
1165,
12,
5661,
12,
1616,
12,
1616,
12,
3388,
467,
288,
359,
21,
12,
1616,
12,
4114,
12,
1616,
12,
959,
467,
267,
1622,
398,
21127,
14,
952,
63,
2301,
360,
33,
17,
297,
666,
59,
16,
566,
267,
21127,
14,
952,
63,
2301,
360,
34,
17,
297,
666,
59,
17,
566,
267,
21127,
14,
952,
63,
2301,
360,
35,
17,
297,
666,
59,
18,
566,
398,
10943,
17,
14,
525,
63,
5602,
2561,
288,
283,
8906,
356,
26143,
16715,
17,
1,
4,
33,
4,
17,
26,
4,
33,
4,
21,
297,
288,
283,
1459,
356,
26143,
16715,
17,
1,
4,
34,
4,
17,
26,
4,
34,
4,
21,
7,
267,
3828,
398,
10943,
18,
14,
525,
63,
5602,
2561,
288,
283,
8906,
356,
26143,
16715,
17,
1,
4,
33,
4,
17,
26,
4,
33,
4,
21,
297,
288,
283,
1459,
356,
26143,
16715,
17,
1,
4,
35,
4,
17,
26,
4,
35,
4,
21,
297,
288,
283,
89,
18,
63,
3127,
356,
413,
12,
267,
3828,
398,
10943,
17,
14,
13307,
8,
9019,
18,
9,
398,
21127,
14,
3176,
63,
9019,
360,
37,
25,
297,
10943,
17,
9,
398,
1736,
2706,
14,
1600,
342,
398,
291,
14,
479,
920,
6067,
591,
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,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
open-pli/enigma2
|
lib/python/Components/MediaPlayer.py
|
32
|
3735
|
from MenuList import MenuList
from Tools.Directories import SCOPE_CURRENT_SKIN, resolveFilename
from os import path
from enigma import eListboxPythonMultiContent, RT_VALIGN_CENTER, gFont, eServiceCenter
from Tools.LoadPixmap import LoadPixmap
import skin
STATE_PLAY = 0
STATE_PAUSE = 1
STATE_STOP = 2
STATE_REWIND = 3
STATE_FORWARD = 4
STATE_NONE = 5
class PlayList(MenuList):
def __init__(self, enableWrapAround = False):
MenuList.__init__(self, [], enableWrapAround, eListboxPythonMultiContent)
font = skin.fonts.get("PlayList", ("Regular", 18, 23))
self.l.setFont(0, gFont(font[0], font[1]))
self.l.setItemHeight(font[2])
self.currPlaying = -1
self.oldCurrPlaying = -1
self.serviceHandler = eServiceCenter.getInstance()
self.state = STATE_NONE
self.icons = [
LoadPixmap(resolveFilename(SCOPE_CURRENT_SKIN, "skin_default/icons/ico_mp_play.png")),
LoadPixmap(resolveFilename(SCOPE_CURRENT_SKIN, "skin_default/icons/ico_mp_pause.png")),
LoadPixmap(resolveFilename(SCOPE_CURRENT_SKIN, "skin_default/icons/ico_mp_stop.png")),
LoadPixmap(resolveFilename(SCOPE_CURRENT_SKIN, "skin_default/icons/ico_mp_rewind.png")),
LoadPixmap(path=resolveFilename(SCOPE_CURRENT_SKIN, "skin_default/icons/ico_mp_forward.png")),
]
def PlaylistEntryComponent(self, serviceref, state):
res = [ serviceref ]
text = serviceref.getName()
if text is "":
text = path.split(serviceref.getPath().split('/')[-1])[1]
x, y, w, h = skin.parameters.get("PlayListName",(25, 1, 470, 22))
res.append((eListboxPythonMultiContent.TYPE_TEXT, x, y, w, h, 0, RT_VALIGN_CENTER, text))
try:
png = self.icons[state]
x, y, w, h = skin.parameters.get("PlayListIcon",(5, 3, 16, 16))
res.append((eListboxPythonMultiContent.TYPE_PIXMAP_ALPHATEST, x, y, w, h, png))
except:
pass
return res
def clear(self):
del self.list[:]
self.l.setList(self.list)
self.currPlaying = -1
self.oldCurrPlaying = -1
def getSelection(self):
return self.l.getCurrentSelection() and self.l.getCurrentSelection()[0]
def addFile(self, serviceref):
self.list.append(self.PlaylistEntryComponent(serviceref, STATE_NONE))
def updateFile(self, index, newserviceref):
if index < len(self.list):
self.list[index] = self.PlaylistEntryComponent(newserviceref, STATE_NONE)
def deleteFile(self, index):
if self.currPlaying >= index:
self.currPlaying -= 1
del self.list[index]
def setCurrentPlaying(self, index):
self.oldCurrPlaying = self.currPlaying
self.currPlaying = index
self.moveToIndex(index)
def updateState(self, state):
self.state = state
if len(self.list) > self.oldCurrPlaying and self.oldCurrPlaying != -1:
self.list[self.oldCurrPlaying] = self.PlaylistEntryComponent(self.list[self.oldCurrPlaying][0], STATE_NONE)
if self.currPlaying != -1 and self.currPlaying < len(self.list):
self.list[self.currPlaying] = self.PlaylistEntryComponent(self.list[self.currPlaying][0], state)
self.updateList()
def isStopped(self):
return self.state in (STATE_STOP, STATE_NONE)
def playFile(self):
self.updateState(STATE_PLAY)
def pauseFile(self):
self.updateState(STATE_PAUSE)
def stopFile(self):
self.updateState(STATE_STOP)
def rewindFile(self):
self.updateState(STATE_REWIND)
def forwardFile(self):
self.updateState(STATE_FORWARD)
def updateList(self):
self.l.setList(self.list)
def getCurrentIndex(self):
return self.currPlaying
def getCurrentEvent(self):
l = self.l.getCurrentSelection()
return l and self.serviceHandler.info(l[0]).getEvent(l[0])
def getCurrent(self):
l = self.l.getCurrentSelection()
return l and l[0]
def getServiceRefList(self):
return [ x[0] for x in self.list ]
def __len__(self):
return len(self.list)
|
gpl-2.0
|
[
504,
18281,
1296,
492,
18281,
1296,
199,
199,
504,
23228,
14,
13752,
492,
428,
1439,
1510,
63,
14211,
63,
30619,
12,
7512,
8117,
199,
504,
747,
492,
931,
199,
199,
504,
655,
27021,
492,
325,
1296,
1977,
4718,
3947,
2714,
12,
24090,
63,
3204,
3203,
63,
17611,
12,
486,
6986,
12,
325,
3167,
13551,
199,
199,
504,
23228,
14,
6200,
16049,
492,
7190,
16049,
199,
646,
28337,
199,
199,
6689,
63,
11625,
275,
378,
199,
6689,
63,
8470,
4701,
275,
413,
199,
6689,
63,
11632,
275,
499,
199,
6689,
63,
907,
55,
3192,
275,
650,
199,
6689,
63,
29700,
275,
841,
199,
6689,
63,
9185,
275,
959,
199,
199,
533,
16527,
1296,
8,
5977,
1296,
304,
199,
198,
318,
636,
826,
721,
277,
12,
4756,
15991,
33,
2363,
275,
756,
304,
507,
198,
5977,
1296,
855,
826,
721,
277,
12,
990,
4756,
15991,
33,
2363,
12,
325,
1296,
1977,
4718,
3947,
2714,
9,
507,
198,
4246,
275,
28337,
14,
19864,
14,
362,
480,
9651,
1296,
401,
1689,
16038,
401,
6155,
12,
6546,
430,
507,
198,
277,
14,
76,
14,
24432,
8,
16,
12,
486,
6986,
8,
4246,
59,
16,
467,
5023,
59,
17,
2459,
507,
198,
277,
14,
76,
14,
29135,
8436,
8,
4246,
59,
18,
566,
507,
198,
277,
14,
9808,
29975,
275,
446,
17,
507,
198,
277,
14,
1753,
3864,
82,
29975,
275,
446,
17,
507,
198,
277,
14,
1364,
2461,
275,
325,
3167,
13551,
14,
29964,
342,
507,
198,
277,
14,
929,
275,
11377,
63,
9185,
507,
198,
277,
14,
16471,
275,
359,
686,
198,
6200,
16049,
8,
6983,
8117,
8,
17998,
63,
14211,
63,
30619,
12,
298,
16409,
63,
885,
15,
16471,
15,
12802,
63,
311,
63,
2802,
14,
4524,
8150,
686,
198,
6200,
16049,
8,
6983,
8117,
8,
17998,
63,
14211,
63,
30619,
12,
298,
16409,
63,
885,
15,
16471,
15,
12802,
63,
311,
63,
11241,
14,
4524,
8150,
686,
198,
6200,
16049,
8,
6983,
8117,
8,
17998,
63,
14211,
63,
30619,
12,
298,
16409,
63,
885,
15,
16471,
15,
12802,
63,
311,
63,
2379,
14,
4524,
8150,
686,
198,
6200,
16049,
8,
6983,
8117,
8,
17998,
63,
14211,
63,
30619,
12,
298,
16409,
63,
885,
15,
16471,
15,
12802,
63,
311,
63,
5257,
688,
14,
4524,
8150,
686,
198,
6200,
16049,
8,
515,
29,
6983,
8117,
8,
17998,
63,
14211,
63,
30619,
12,
298,
16409,
63,
885,
15,
16471,
15,
12802,
63,
311,
63,
6688,
14,
4524,
8150,
507,
198,
61,
421,
198,
318,
16527,
513,
3900,
7004,
8,
277,
12,
2435,
1121,
12,
1174,
304,
507,
198,
470,
275,
359,
2435,
1121,
1622,
507,
198,
505,
275,
2435,
1121,
14,
16405,
342,
507,
198,
692,
1318,
365,
10812,
686,
198,
505,
275,
931,
14,
1294,
8,
1364,
1121,
14,
362,
2042,
1252,
1294,
25804,
17,
11057,
17,
61,
507,
198,
88,
12,
612,
12,
336,
12,
394,
275,
28337,
14,
3214,
14,
362,
480,
9651,
1296,
985,
401,
8,
821,
12,
413,
12,
841,
2760,
12,
6928,
430,
507,
198,
470,
14,
740,
1332,
69,
1296,
1977,
4718,
3947,
2714,
14,
2711,
63,
3876,
12,
671,
12,
612,
12,
336,
12,
394,
12,
378,
12,
24090,
63,
3204,
3203,
63,
17611,
12,
1318,
430,
507,
198,
893,
26,
686,
198,
4524,
275,
291,
14,
16471,
59,
929,
61,
686,
198,
88,
12,
612,
12,
336,
12,
394,
275,
28337,
14,
3214,
14,
362,
480,
9651,
1296,
8954,
401,
8,
21,
12,
650,
12,
3193,
12,
3193,
430,
686,
198,
470,
14,
740,
1332,
69,
1296,
1977,
4718,
3947,
2714,
14,
2711,
63,
18545,
5443,
63,
748,
9791,
619,
1719,
12,
671,
12,
612,
12,
336,
12,
394,
12,
25296,
430,
507,
198,
2590,
26,
686,
263,
986,
507,
198,
1107,
522,
421,
198,
318,
5436,
8,
277,
304,
507,
198,
2264,
291,
14,
513,
5873,
507,
198,
277,
14,
76,
14,
409,
1296,
8,
277,
14,
513,
9,
507,
198,
277,
14,
9808,
29975,
275,
446,
17,
507,
198,
277,
14,
1753,
3864,
82,
29975,
275,
446,
17,
421,
198,
318,
664,
7713,
8,
277,
304,
507,
198,
1107,
291,
14,
76,
14,
16662,
7713,
342,
436,
291,
14,
76,
14,
16662,
7713,
3430,
16,
61,
421,
198,
318,
1050,
1173,
8,
277,
12,
2435,
1121,
304,
507,
198,
277,
14,
513,
14,
740,
8,
277,
14,
27259,
3900,
7004,
8,
1364,
1121,
12,
11377,
63,
9185,
430,
421,
198,
318,
1678,
1173,
8,
277,
12,
1478,
12,
892,
1364,
1121,
304,
507,
198,
692,
1478,
665,
822,
8,
277,
14,
513,
304,
15075,
291,
14,
513,
59,
1080,
61,
275,
291,
14,
27259,
3900,
7004,
8,
1222,
1364,
1121,
12,
11377,
63,
9185,
9,
421,
198,
318,
3145,
1173,
8,
277,
12,
1478,
304,
507,
198,
692,
291,
14,
9808,
29975,
2356,
1478,
26,
686,
198,
277,
14,
9808,
29975,
4862,
413,
507,
198,
2264,
291,
14,
513,
59,
1080,
61,
421,
198,
318,
663,
5639,
29975,
8,
277,
12,
1478,
304,
507,
198,
277,
14,
1753,
3864,
82,
29975,
275,
291,
14,
9808,
29975,
507,
198,
277,
14,
9808,
29975,
275,
1478,
507,
198,
277,
14,
31773,
2681,
8,
1080,
9,
421,
198,
318,
1678,
2223,
8,
277,
12,
1174,
304,
507,
198,
277,
14,
929,
275,
1174,
507,
198,
692,
822,
8,
277,
14,
513,
9,
690,
291,
14,
1753,
3864,
82,
29975,
436,
291,
14,
1753,
3864,
82,
29975,
1137,
446,
17,
26,
686,
198,
277,
14,
513,
59,
277,
14,
1753,
3864,
82,
29975,
61,
275,
291,
14,
27259,
3900,
7004,
8,
277,
14,
513,
59,
277,
14,
1753,
3864,
82,
29975,
1527,
16,
467,
11377,
63,
9185,
9,
507,
198,
692,
291,
14,
9808,
29975,
1137,
446,
17,
436,
291,
14,
9808,
29975,
665,
822,
8,
277,
14,
513,
304,
686,
198,
277,
14,
513,
59,
277,
14,
9808,
29975,
61,
275,
291,
14,
27259,
3900,
7004,
8,
277,
14,
513,
59,
277,
14,
9808,
29975,
1527,
16,
467,
1174,
9,
507,
198,
277,
14,
873,
1296,
342,
421,
198,
318,
365,
28500,
8,
277,
304,
507,
198,
1107,
291,
14,
929,
315,
334,
6689,
63,
11632,
12,
11377,
63,
9185,
9,
421,
198,
318,
5232,
1173,
8,
277,
304,
507
] |
[
18281,
1296,
492,
18281,
1296,
199,
199,
504,
23228,
14,
13752,
492,
428,
1439,
1510,
63,
14211,
63,
30619,
12,
7512,
8117,
199,
504,
747,
492,
931,
199,
199,
504,
655,
27021,
492,
325,
1296,
1977,
4718,
3947,
2714,
12,
24090,
63,
3204,
3203,
63,
17611,
12,
486,
6986,
12,
325,
3167,
13551,
199,
199,
504,
23228,
14,
6200,
16049,
492,
7190,
16049,
199,
646,
28337,
199,
199,
6689,
63,
11625,
275,
378,
199,
6689,
63,
8470,
4701,
275,
413,
199,
6689,
63,
11632,
275,
499,
199,
6689,
63,
907,
55,
3192,
275,
650,
199,
6689,
63,
29700,
275,
841,
199,
6689,
63,
9185,
275,
959,
199,
199,
533,
16527,
1296,
8,
5977,
1296,
304,
199,
198,
318,
636,
826,
721,
277,
12,
4756,
15991,
33,
2363,
275,
756,
304,
507,
198,
5977,
1296,
855,
826,
721,
277,
12,
990,
4756,
15991,
33,
2363,
12,
325,
1296,
1977,
4718,
3947,
2714,
9,
507,
198,
4246,
275,
28337,
14,
19864,
14,
362,
480,
9651,
1296,
401,
1689,
16038,
401,
6155,
12,
6546,
430,
507,
198,
277,
14,
76,
14,
24432,
8,
16,
12,
486,
6986,
8,
4246,
59,
16,
467,
5023,
59,
17,
2459,
507,
198,
277,
14,
76,
14,
29135,
8436,
8,
4246,
59,
18,
566,
507,
198,
277,
14,
9808,
29975,
275,
446,
17,
507,
198,
277,
14,
1753,
3864,
82,
29975,
275,
446,
17,
507,
198,
277,
14,
1364,
2461,
275,
325,
3167,
13551,
14,
29964,
342,
507,
198,
277,
14,
929,
275,
11377,
63,
9185,
507,
198,
277,
14,
16471,
275,
359,
686,
198,
6200,
16049,
8,
6983,
8117,
8,
17998,
63,
14211,
63,
30619,
12,
298,
16409,
63,
885,
15,
16471,
15,
12802,
63,
311,
63,
2802,
14,
4524,
8150,
686,
198,
6200,
16049,
8,
6983,
8117,
8,
17998,
63,
14211,
63,
30619,
12,
298,
16409,
63,
885,
15,
16471,
15,
12802,
63,
311,
63,
11241,
14,
4524,
8150,
686,
198,
6200,
16049,
8,
6983,
8117,
8,
17998,
63,
14211,
63,
30619,
12,
298,
16409,
63,
885,
15,
16471,
15,
12802,
63,
311,
63,
2379,
14,
4524,
8150,
686,
198,
6200,
16049,
8,
6983,
8117,
8,
17998,
63,
14211,
63,
30619,
12,
298,
16409,
63,
885,
15,
16471,
15,
12802,
63,
311,
63,
5257,
688,
14,
4524,
8150,
686,
198,
6200,
16049,
8,
515,
29,
6983,
8117,
8,
17998,
63,
14211,
63,
30619,
12,
298,
16409,
63,
885,
15,
16471,
15,
12802,
63,
311,
63,
6688,
14,
4524,
8150,
507,
198,
61,
421,
198,
318,
16527,
513,
3900,
7004,
8,
277,
12,
2435,
1121,
12,
1174,
304,
507,
198,
470,
275,
359,
2435,
1121,
1622,
507,
198,
505,
275,
2435,
1121,
14,
16405,
342,
507,
198,
692,
1318,
365,
10812,
686,
198,
505,
275,
931,
14,
1294,
8,
1364,
1121,
14,
362,
2042,
1252,
1294,
25804,
17,
11057,
17,
61,
507,
198,
88,
12,
612,
12,
336,
12,
394,
275,
28337,
14,
3214,
14,
362,
480,
9651,
1296,
985,
401,
8,
821,
12,
413,
12,
841,
2760,
12,
6928,
430,
507,
198,
470,
14,
740,
1332,
69,
1296,
1977,
4718,
3947,
2714,
14,
2711,
63,
3876,
12,
671,
12,
612,
12,
336,
12,
394,
12,
378,
12,
24090,
63,
3204,
3203,
63,
17611,
12,
1318,
430,
507,
198,
893,
26,
686,
198,
4524,
275,
291,
14,
16471,
59,
929,
61,
686,
198,
88,
12,
612,
12,
336,
12,
394,
275,
28337,
14,
3214,
14,
362,
480,
9651,
1296,
8954,
401,
8,
21,
12,
650,
12,
3193,
12,
3193,
430,
686,
198,
470,
14,
740,
1332,
69,
1296,
1977,
4718,
3947,
2714,
14,
2711,
63,
18545,
5443,
63,
748,
9791,
619,
1719,
12,
671,
12,
612,
12,
336,
12,
394,
12,
25296,
430,
507,
198,
2590,
26,
686,
263,
986,
507,
198,
1107,
522,
421,
198,
318,
5436,
8,
277,
304,
507,
198,
2264,
291,
14,
513,
5873,
507,
198,
277,
14,
76,
14,
409,
1296,
8,
277,
14,
513,
9,
507,
198,
277,
14,
9808,
29975,
275,
446,
17,
507,
198,
277,
14,
1753,
3864,
82,
29975,
275,
446,
17,
421,
198,
318,
664,
7713,
8,
277,
304,
507,
198,
1107,
291,
14,
76,
14,
16662,
7713,
342,
436,
291,
14,
76,
14,
16662,
7713,
3430,
16,
61,
421,
198,
318,
1050,
1173,
8,
277,
12,
2435,
1121,
304,
507,
198,
277,
14,
513,
14,
740,
8,
277,
14,
27259,
3900,
7004,
8,
1364,
1121,
12,
11377,
63,
9185,
430,
421,
198,
318,
1678,
1173,
8,
277,
12,
1478,
12,
892,
1364,
1121,
304,
507,
198,
692,
1478,
665,
822,
8,
277,
14,
513,
304,
15075,
291,
14,
513,
59,
1080,
61,
275,
291,
14,
27259,
3900,
7004,
8,
1222,
1364,
1121,
12,
11377,
63,
9185,
9,
421,
198,
318,
3145,
1173,
8,
277,
12,
1478,
304,
507,
198,
692,
291,
14,
9808,
29975,
2356,
1478,
26,
686,
198,
277,
14,
9808,
29975,
4862,
413,
507,
198,
2264,
291,
14,
513,
59,
1080,
61,
421,
198,
318,
663,
5639,
29975,
8,
277,
12,
1478,
304,
507,
198,
277,
14,
1753,
3864,
82,
29975,
275,
291,
14,
9808,
29975,
507,
198,
277,
14,
9808,
29975,
275,
1478,
507,
198,
277,
14,
31773,
2681,
8,
1080,
9,
421,
198,
318,
1678,
2223,
8,
277,
12,
1174,
304,
507,
198,
277,
14,
929,
275,
1174,
507,
198,
692,
822,
8,
277,
14,
513,
9,
690,
291,
14,
1753,
3864,
82,
29975,
436,
291,
14,
1753,
3864,
82,
29975,
1137,
446,
17,
26,
686,
198,
277,
14,
513,
59,
277,
14,
1753,
3864,
82,
29975,
61,
275,
291,
14,
27259,
3900,
7004,
8,
277,
14,
513,
59,
277,
14,
1753,
3864,
82,
29975,
1527,
16,
467,
11377,
63,
9185,
9,
507,
198,
692,
291,
14,
9808,
29975,
1137,
446,
17,
436,
291,
14,
9808,
29975,
665,
822,
8,
277,
14,
513,
304,
686,
198,
277,
14,
513,
59,
277,
14,
9808,
29975,
61,
275,
291,
14,
27259,
3900,
7004,
8,
277,
14,
513,
59,
277,
14,
9808,
29975,
1527,
16,
467,
1174,
9,
507,
198,
277,
14,
873,
1296,
342,
421,
198,
318,
365,
28500,
8,
277,
304,
507,
198,
1107,
291,
14,
929,
315,
334,
6689,
63,
11632,
12,
11377,
63,
9185,
9,
421,
198,
318,
5232,
1173,
8,
277,
304,
507,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
floresconlimon/qutebrowser
|
tests/unit/misc/test_lineparser.py
|
8
|
6158
|
# vim: ft=python fileencoding=utf-8 sts=4 sw=4 et:
# Copyright 2015 Florian Bruhin (The Compiler) <mail@qutebrowser.org>
#
# This file is part of qutebrowser.
#
# qutebrowser 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.
#
# qutebrowser 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 qutebrowser. If not, see <http://www.gnu.org/licenses/>.
"""Tests for qutebrowser.misc.lineparser."""
import io
import os
import pytest
from qutebrowser.misc import lineparser as lineparsermod
class LineParserWrapper:
"""A wrapper over lineparser.BaseLineParser to make it testable."""
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self._data = None
self._test_save_prepared = False
def _open(self, mode):
"""Override _open to use StringIO/BytesIO instead of a real file."""
if mode not in 'rwa':
raise ValueError("Unknown mode {!r}!".format(mode))
if self._test_save_prepared:
self._test_save_prepared = False
elif mode != 'r':
raise ValueError("Doing unprepared save!")
if mode in 'ar' and self._data is not None:
prev_val = self._data
else:
prev_val = None
if self._binary: # pylint: disable=no-member
fobj = io.BytesIO(prev_val)
else:
fobj = io.StringIO(prev_val)
if mode == 'a':
fobj.seek(0, os.SEEK_END)
return fobj
def _write(self, fp, data):
"""Extend _write to get the data after writing it."""
super()._write(fp, data)
self._data = fp.getvalue()
def _prepare_save(self):
"""Keep track if _prepare_save has been called."""
self._test_save_prepared = True
return True
class AppendLineParserTestable(LineParserWrapper,
lineparsermod.AppendLineParser):
"""Wrapper over AppendLineParser to make it testable."""
pass
class LineParserTestable(LineParserWrapper, lineparsermod.LineParser):
"""Wrapper over LineParser to make it testable."""
pass
class LimitLineParserTestable(LineParserWrapper,
lineparsermod.LimitLineParser):
"""Wrapper over LimitLineParser to make it testable."""
pass
class TestBaseLineParser:
"""Tests for BaseLineParser."""
CONFDIR = "this really doesn't matter"
FILENAME = "and neither does this"
@pytest.fixture
def lineparser(self):
"""Fixture providing a BaseLineParser."""
return lineparsermod.BaseLineParser(self.CONFDIR, self.FILENAME)
def test_prepare_save_existing(self, mocker, lineparser):
"""Test if _prepare_save does what it's supposed to do."""
os_mock = mocker.patch('qutebrowser.misc.lineparser.os')
os_mock.path.exists.return_value = True
lineparser._prepare_save()
assert not os_mock.makedirs.called
def test_prepare_save_missing(self, mocker, lineparser):
"""Test if _prepare_save does what it's supposed to do."""
os_mock = mocker.patch('qutebrowser.misc.lineparser.os')
os_mock.path.exists.return_value = False
lineparser._prepare_save()
os_mock.makedirs.assert_called_with(self.CONFDIR, 0o755)
class TestAppendLineParser:
"""Tests for AppendLineParser."""
BASE_DATA = ['old data 1', 'old data 2']
@pytest.fixture
def lineparser(self):
"""Fixture to get an AppendLineParser for tests."""
lp = AppendLineParserTestable('this really', 'does not matter')
lp.new_data = self.BASE_DATA
lp.save()
return lp
def _get_expected(self, new_data):
"""Get the expected data with newlines."""
return '\n'.join(self.BASE_DATA + new_data) + '\n'
def test_save(self, lineparser):
"""Test save()."""
new_data = ['new data 1', 'new data 2']
lineparser.new_data = new_data
lineparser.save()
assert lineparser._data == self._get_expected(new_data)
def test_iter_without_open(self, lineparser):
"""Test __iter__ without having called open()."""
with pytest.raises(ValueError):
iter(lineparser)
def test_iter(self, lineparser):
"""Test __iter__."""
new_data = ['new data 1', 'new data 2']
lineparser.new_data = new_data
with lineparser.open():
assert list(lineparser) == self.BASE_DATA + new_data
def test_iter_not_found(self, mocker):
"""Test __iter__ with no file."""
open_mock = mocker.patch(
'qutebrowser.misc.lineparser.AppendLineParser._open')
open_mock.side_effect = FileNotFoundError
new_data = ['new data 1', 'new data 2']
linep = lineparsermod.AppendLineParser('foo', 'bar')
linep.new_data = new_data
with linep.open():
assert list(linep) == new_data
def test_get_recent_none(self):
"""Test get_recent with no data."""
linep = AppendLineParserTestable('this really', 'does not matter')
assert linep.get_recent() == []
def test_get_recent_little(self, lineparser):
"""Test get_recent with little data."""
data = [e + '\n' for e in self.BASE_DATA]
assert lineparser.get_recent() == data
def test_get_recent_much(self, lineparser):
"""Test get_recent with much data."""
size = 64
new_data = ['new data {}'.format(i) for i in range(size)]
lineparser.new_data = new_data
lineparser.save()
data = '\n'.join(self.BASE_DATA + new_data)
data = [e + '\n' for e in data[-(size - 1):].splitlines()]
assert lineparser.get_recent(size) == data
|
gpl-3.0
|
[
3,
6695,
26,
18133,
29,
1548,
570,
2991,
29,
1624,
13,
24,
23014,
29,
20,
5584,
29,
20,
10844,
26,
199,
199,
3,
1898,
6900,
11040,
269,
5653,
699,
6558,
72,
262,
334,
1918,
27154,
9,
665,
1198,
32,
392,
31127,
14,
1308,
30,
199,
3,
199,
3,
961,
570,
365,
1777,
402,
2173,
31127,
14,
199,
3,
199,
3,
2173,
31127,
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,
2173,
31127,
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,
2173,
31127,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
199,
624,
2925,
367,
2173,
31127,
14,
9923,
14,
604,
2087,
1041,
199,
199,
646,
5890,
199,
646,
747,
199,
199,
646,
4613,
199,
199,
504,
2173,
31127,
14,
9923,
492,
1004,
2087,
465,
1004,
2087,
1494,
421,
199,
533,
7030,
2842,
4590,
26,
339,
408,
33,
4975,
1806,
1004,
2087,
14,
1563,
3049,
2842,
370,
1852,
652,
511,
461,
1041,
339,
347,
636,
826,
721,
277,
12,
627,
589,
12,
1011,
958,
304,
267,
1613,
11027,
826,
9308,
589,
12,
1011,
958,
9,
267,
291,
423,
576,
275,
488,
267,
291,
423,
396,
63,
2117,
63,
19260,
275,
756,
339,
347,
485,
1490,
8,
277,
12,
818,
304,
267,
408,
11954,
485,
1490,
370,
675,
5228,
15,
15466,
3140,
402,
282,
3363,
570,
1041,
267,
340,
818,
440,
315,
283,
82,
758,
356,
288,
746,
1722,
480,
5912,
818,
18776,
82,
93,
1,
1674,
908,
8,
632,
430,
267,
340,
291,
423,
396,
63,
2117,
63,
19260,
26,
288,
291,
423,
396,
63,
2117,
63,
19260,
275,
756,
267,
916,
818,
1137,
283,
82,
356,
288,
746,
1722,
480,
2585,
316,
625,
19260,
3354,
9124,
398,
340,
818,
315,
283,
285,
7,
436,
291,
423,
576,
365,
440,
488,
26,
288,
5071,
63,
637,
275,
291,
423,
576,
267,
587,
26,
288,
5071,
63,
637,
275,
488,
398,
340,
291,
423,
3008,
26,
221,
327,
4287,
26,
3507,
29,
889,
13,
1114,
288,
29962,
275,
5890,
14,
15466,
8,
5701,
63,
637,
9,
267,
587,
26,
288,
29962,
275,
5890,
14,
6424,
8,
5701,
63,
637,
9,
398,
340,
818,
508,
283,
65,
356,
288,
29962,
14,
5507,
8,
16,
12,
747,
14,
18439,
63,
3902,
9,
267,
372,
29962,
339,
347,
485,
952,
8,
277,
12,
4090,
12,
666,
304,
267,
408,
30775,
485,
952,
370,
664,
314,
666,
2410,
3575,
652,
1041,
267,
1613,
19050,
952,
8,
3997,
12,
666,
9,
267,
291,
423,
576,
275,
4090,
14,
7150,
342,
339,
347,
485,
6726,
63,
2117,
8,
277,
304,
267,
408,
18567,
4426,
340,
485,
6726,
63,
2117,
965,
2757,
2797,
1041,
267,
291,
423,
396,
63,
2117,
63,
19260,
275,
715,
267,
372,
715,
421,
199,
533,
18726,
3049,
2842,
774,
461,
8,
3049,
2842,
4590,
12,
3044,
1004,
2087,
1494,
14,
8310,
3049,
2842,
304,
339,
408,
4590,
1806,
18726,
3049,
2842,
370,
1852,
652,
511,
461,
1041,
339,
986,
421,
199,
533,
7030,
2842,
774,
461,
8,
3049,
2842,
4590,
12,
1004,
2087,
1494,
14,
3049,
2842,
304,
339,
408,
4590,
1806,
7030,
2842,
370,
1852,
652,
511,
461,
1041,
339,
986,
421,
199,
533,
22672,
3049,
2842,
774,
461,
8,
3049,
2842,
4590,
12,
2892,
1004,
2087,
1494,
14,
8407,
3049,
2842,
304,
339,
408,
4590,
1806,
22672,
3049,
2842,
370,
1852,
652,
511,
461,
1041,
339,
986,
421,
199,
533,
1379,
1563,
3049,
2842,
26,
339,
408,
2925,
367,
3523,
3049,
2842,
1041,
339,
6392,
3022,
275,
298,
3749,
7710,
3181,
1133,
17247,
2,
272,
16444,
11536,
275,
298,
460,
15564,
1630,
642,
2,
339,
768,
4462,
14,
5997,
272,
347,
1004,
2087,
8,
277,
304,
267,
408,
12812,
13070,
282,
3523,
3049,
2842,
1041,
267,
372,
1004,
2087,
1494,
14,
1563,
3049,
2842,
8,
277,
14,
3103,
3022,
12,
291,
14,
15440,
9,
339,
347,
511,
63,
6726,
63,
2117,
63,
5952,
8,
277,
12,
15981,
12,
1004,
2087,
304,
267,
408,
774,
340,
485,
6726,
63,
2117,
1630,
4052,
652,
1159,
20042,
370,
886,
1041,
267,
747,
63,
1805,
275,
15981,
14,
2068,
360,
392,
31127,
14,
9923,
14,
604,
2087,
14,
736,
358,
267,
747,
63,
1805,
14,
515,
14,
2444,
14,
1107,
63,
585,
275,
715,
398,
1004,
2087,
423,
6726,
63,
2117,
342,
267,
702,
440,
747,
63,
1805,
14,
8347,
14,
3527,
339,
347,
511,
63,
6726,
63,
2117,
63,
4752,
8,
277,
12,
15981,
12,
1004,
2087,
304,
267,
408,
774,
340,
485,
6726,
63,
2117,
1630,
4052,
652,
1159,
20042,
370,
886,
1041,
267,
747,
63,
1805,
275,
15981,
14,
2068,
360,
392,
31127,
14,
9923,
14,
604,
2087,
14,
736,
358,
267,
747,
63,
1805,
14,
515,
14,
2444,
14,
1107,
63,
585,
275,
756,
398,
1004,
2087,
423,
6726,
63,
2117,
342,
267,
747,
63,
1805,
14,
8347,
14,
479,
63,
3527,
63,
1045,
8,
277,
14,
3103,
3022,
12,
378,
79,
12315,
9,
421,
199,
533,
1379,
8310,
3049,
2842,
26,
339,
408,
2925,
367,
18726,
3049,
2842,
1041,
339,
19721,
63,
3998,
275,
788,
1753,
666,
413,
297,
283,
1753,
666,
499,
418,
339,
768,
4462,
14,
5997,
272,
347,
1004,
2087,
8,
277,
304,
267,
408,
12812,
370,
664,
376,
18726,
3049,
2842,
367,
2295,
1041,
267,
13204,
275,
18726,
3049,
2842,
774,
461,
360,
3749,
7710,
297,
283,
9105,
440,
17247,
358,
267,
13204,
14,
1222,
63,
576,
275,
291,
14,
5825,
63,
3998,
267,
13204,
14,
2117,
342,
267,
372,
13204,
339,
347
] |
[
6695,
26,
18133,
29,
1548,
570,
2991,
29,
1624,
13,
24,
23014,
29,
20,
5584,
29,
20,
10844,
26,
199,
199,
3,
1898,
6900,
11040,
269,
5653,
699,
6558,
72,
262,
334,
1918,
27154,
9,
665,
1198,
32,
392,
31127,
14,
1308,
30,
199,
3,
199,
3,
961,
570,
365,
1777,
402,
2173,
31127,
14,
199,
3,
199,
3,
2173,
31127,
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,
2173,
31127,
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,
2173,
31127,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
199,
624,
2925,
367,
2173,
31127,
14,
9923,
14,
604,
2087,
1041,
199,
199,
646,
5890,
199,
646,
747,
199,
199,
646,
4613,
199,
199,
504,
2173,
31127,
14,
9923,
492,
1004,
2087,
465,
1004,
2087,
1494,
421,
199,
533,
7030,
2842,
4590,
26,
339,
408,
33,
4975,
1806,
1004,
2087,
14,
1563,
3049,
2842,
370,
1852,
652,
511,
461,
1041,
339,
347,
636,
826,
721,
277,
12,
627,
589,
12,
1011,
958,
304,
267,
1613,
11027,
826,
9308,
589,
12,
1011,
958,
9,
267,
291,
423,
576,
275,
488,
267,
291,
423,
396,
63,
2117,
63,
19260,
275,
756,
339,
347,
485,
1490,
8,
277,
12,
818,
304,
267,
408,
11954,
485,
1490,
370,
675,
5228,
15,
15466,
3140,
402,
282,
3363,
570,
1041,
267,
340,
818,
440,
315,
283,
82,
758,
356,
288,
746,
1722,
480,
5912,
818,
18776,
82,
93,
1,
1674,
908,
8,
632,
430,
267,
340,
291,
423,
396,
63,
2117,
63,
19260,
26,
288,
291,
423,
396,
63,
2117,
63,
19260,
275,
756,
267,
916,
818,
1137,
283,
82,
356,
288,
746,
1722,
480,
2585,
316,
625,
19260,
3354,
9124,
398,
340,
818,
315,
283,
285,
7,
436,
291,
423,
576,
365,
440,
488,
26,
288,
5071,
63,
637,
275,
291,
423,
576,
267,
587,
26,
288,
5071,
63,
637,
275,
488,
398,
340,
291,
423,
3008,
26,
221,
327,
4287,
26,
3507,
29,
889,
13,
1114,
288,
29962,
275,
5890,
14,
15466,
8,
5701,
63,
637,
9,
267,
587,
26,
288,
29962,
275,
5890,
14,
6424,
8,
5701,
63,
637,
9,
398,
340,
818,
508,
283,
65,
356,
288,
29962,
14,
5507,
8,
16,
12,
747,
14,
18439,
63,
3902,
9,
267,
372,
29962,
339,
347,
485,
952,
8,
277,
12,
4090,
12,
666,
304,
267,
408,
30775,
485,
952,
370,
664,
314,
666,
2410,
3575,
652,
1041,
267,
1613,
19050,
952,
8,
3997,
12,
666,
9,
267,
291,
423,
576,
275,
4090,
14,
7150,
342,
339,
347,
485,
6726,
63,
2117,
8,
277,
304,
267,
408,
18567,
4426,
340,
485,
6726,
63,
2117,
965,
2757,
2797,
1041,
267,
291,
423,
396,
63,
2117,
63,
19260,
275,
715,
267,
372,
715,
421,
199,
533,
18726,
3049,
2842,
774,
461,
8,
3049,
2842,
4590,
12,
3044,
1004,
2087,
1494,
14,
8310,
3049,
2842,
304,
339,
408,
4590,
1806,
18726,
3049,
2842,
370,
1852,
652,
511,
461,
1041,
339,
986,
421,
199,
533,
7030,
2842,
774,
461,
8,
3049,
2842,
4590,
12,
1004,
2087,
1494,
14,
3049,
2842,
304,
339,
408,
4590,
1806,
7030,
2842,
370,
1852,
652,
511,
461,
1041,
339,
986,
421,
199,
533,
22672,
3049,
2842,
774,
461,
8,
3049,
2842,
4590,
12,
2892,
1004,
2087,
1494,
14,
8407,
3049,
2842,
304,
339,
408,
4590,
1806,
22672,
3049,
2842,
370,
1852,
652,
511,
461,
1041,
339,
986,
421,
199,
533,
1379,
1563,
3049,
2842,
26,
339,
408,
2925,
367,
3523,
3049,
2842,
1041,
339,
6392,
3022,
275,
298,
3749,
7710,
3181,
1133,
17247,
2,
272,
16444,
11536,
275,
298,
460,
15564,
1630,
642,
2,
339,
768,
4462,
14,
5997,
272,
347,
1004,
2087,
8,
277,
304,
267,
408,
12812,
13070,
282,
3523,
3049,
2842,
1041,
267,
372,
1004,
2087,
1494,
14,
1563,
3049,
2842,
8,
277,
14,
3103,
3022,
12,
291,
14,
15440,
9,
339,
347,
511,
63,
6726,
63,
2117,
63,
5952,
8,
277,
12,
15981,
12,
1004,
2087,
304,
267,
408,
774,
340,
485,
6726,
63,
2117,
1630,
4052,
652,
1159,
20042,
370,
886,
1041,
267,
747,
63,
1805,
275,
15981,
14,
2068,
360,
392,
31127,
14,
9923,
14,
604,
2087,
14,
736,
358,
267,
747,
63,
1805,
14,
515,
14,
2444,
14,
1107,
63,
585,
275,
715,
398,
1004,
2087,
423,
6726,
63,
2117,
342,
267,
702,
440,
747,
63,
1805,
14,
8347,
14,
3527,
339,
347,
511,
63,
6726,
63,
2117,
63,
4752,
8,
277,
12,
15981,
12,
1004,
2087,
304,
267,
408,
774,
340,
485,
6726,
63,
2117,
1630,
4052,
652,
1159,
20042,
370,
886,
1041,
267,
747,
63,
1805,
275,
15981,
14,
2068,
360,
392,
31127,
14,
9923,
14,
604,
2087,
14,
736,
358,
267,
747,
63,
1805,
14,
515,
14,
2444,
14,
1107,
63,
585,
275,
756,
398,
1004,
2087,
423,
6726,
63,
2117,
342,
267,
747,
63,
1805,
14,
8347,
14,
479,
63,
3527,
63,
1045,
8,
277,
14,
3103,
3022,
12,
378,
79,
12315,
9,
421,
199,
533,
1379,
8310,
3049,
2842,
26,
339,
408,
2925,
367,
18726,
3049,
2842,
1041,
339,
19721,
63,
3998,
275,
788,
1753,
666,
413,
297,
283,
1753,
666,
499,
418,
339,
768,
4462,
14,
5997,
272,
347,
1004,
2087,
8,
277,
304,
267,
408,
12812,
370,
664,
376,
18726,
3049,
2842,
367,
2295,
1041,
267,
13204,
275,
18726,
3049,
2842,
774,
461,
360,
3749,
7710,
297,
283,
9105,
440,
17247,
358,
267,
13204,
14,
1222,
63,
576,
275,
291,
14,
5825,
63,
3998,
267,
13204,
14,
2117,
342,
267,
372,
13204,
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,
1,
1,
1,
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
] |
skg-net/ansible
|
lib/ansible/modules/cloud/rackspace/rax_clb_nodes.py
|
95
|
8230
|
#!/usr/bin/python
# Copyright: Ansible Project
# 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: rax_clb_nodes
short_description: add, modify and remove nodes from a Rackspace Cloud Load Balancer
description:
- Adds, modifies and removes nodes from a Rackspace Cloud Load Balancer
version_added: "1.4"
options:
address:
required: false
description:
- IP address or domain name of the node
condition:
required: false
choices:
- enabled
- disabled
- draining
description:
- Condition for the node, which determines its role within the load
balancer
load_balancer_id:
required: true
description:
- Load balancer id
node_id:
required: false
description:
- Node id
port:
required: false
description:
- Port number of the load balanced service on the node
state:
required: false
default: "present"
choices:
- present
- absent
description:
- Indicate desired state of the node
type:
required: false
choices:
- primary
- secondary
description:
- Type of node
wait:
required: false
default: "no"
type: bool
description:
- Wait for the load balancer to become active before returning
wait_timeout:
required: false
default: 30
description:
- How long to wait before giving up and returning an error
weight:
required: false
description:
- Weight of node
author: "Lukasz Kawczynski (@neuroid)"
extends_documentation_fragment:
- rackspace
- rackspace.openstack
'''
EXAMPLES = '''
# Add a new node to the load balancer
- local_action:
module: rax_clb_nodes
load_balancer_id: 71
address: 10.2.2.3
port: 80
condition: enabled
type: primary
wait: yes
credentials: /path/to/credentials
# Drain connections from a node
- local_action:
module: rax_clb_nodes
load_balancer_id: 71
node_id: 410
condition: draining
wait: yes
credentials: /path/to/credentials
# Remove a node from the load balancer
- local_action:
module: rax_clb_nodes
load_balancer_id: 71
node_id: 410
state: absent
wait: yes
credentials: /path/to/credentials
'''
import os
try:
import pyrax
HAS_PYRAX = True
except ImportError:
HAS_PYRAX = False
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.rax import rax_argument_spec, rax_clb_node_to_dict, rax_required_together, setup_rax_module
def _activate_virtualenv(path):
activate_this = os.path.join(path, 'bin', 'activate_this.py')
with open(activate_this) as f:
code = compile(f.read(), activate_this, 'exec')
exec(code)
def _get_node(lb, node_id=None, address=None, port=None):
"""Return a matching node"""
for node in getattr(lb, 'nodes', []):
match_list = []
if node_id is not None:
match_list.append(getattr(node, 'id', None) == node_id)
if address is not None:
match_list.append(getattr(node, 'address', None) == address)
if port is not None:
match_list.append(getattr(node, 'port', None) == port)
if match_list and all(match_list):
return node
return None
def main():
argument_spec = rax_argument_spec()
argument_spec.update(
dict(
address=dict(),
condition=dict(choices=['enabled', 'disabled', 'draining']),
load_balancer_id=dict(required=True, type='int'),
node_id=dict(type='int'),
port=dict(type='int'),
state=dict(default='present', choices=['present', 'absent']),
type=dict(choices=['primary', 'secondary']),
virtualenv=dict(type='path'),
wait=dict(default=False, type='bool'),
wait_timeout=dict(default=30, type='int'),
weight=dict(type='int'),
)
)
module = AnsibleModule(
argument_spec=argument_spec,
required_together=rax_required_together(),
)
if not HAS_PYRAX:
module.fail_json(msg='pyrax is required for this module')
address = module.params['address']
condition = (module.params['condition'] and
module.params['condition'].upper())
load_balancer_id = module.params['load_balancer_id']
node_id = module.params['node_id']
port = module.params['port']
state = module.params['state']
typ = module.params['type'] and module.params['type'].upper()
virtualenv = module.params['virtualenv']
wait = module.params['wait']
wait_timeout = module.params['wait_timeout'] or 1
weight = module.params['weight']
if virtualenv:
try:
_activate_virtualenv(virtualenv)
except IOError as e:
module.fail_json(msg='Failed to activate virtualenv %s (%s)' % (
virtualenv, e))
setup_rax_module(module, pyrax)
if not pyrax.cloud_loadbalancers:
module.fail_json(msg='Failed to instantiate client. This '
'typically indicates an invalid region or an '
'incorrectly capitalized region name.')
try:
lb = pyrax.cloud_loadbalancers.get(load_balancer_id)
except pyrax.exc.PyraxException as e:
module.fail_json(msg='%s' % e.message)
node = _get_node(lb, node_id, address, port)
result = rax_clb_node_to_dict(node)
if state == 'absent':
if not node: # Removing a non-existent node
module.exit_json(changed=False, state=state)
try:
lb.delete_node(node)
result = {}
except pyrax.exc.NotFound:
module.exit_json(changed=False, state=state)
except pyrax.exc.PyraxException as e:
module.fail_json(msg='%s' % e.message)
else: # present
if not node:
if node_id: # Updating a non-existent node
msg = 'Node %d not found' % node_id
if lb.nodes:
msg += (' (available nodes: %s)' %
', '.join([str(x.id) for x in lb.nodes]))
module.fail_json(msg=msg)
else: # Creating a new node
try:
node = pyrax.cloudloadbalancers.Node(
address=address, port=port, condition=condition,
weight=weight, type=typ)
resp, body = lb.add_nodes([node])
result.update(body['nodes'][0])
except pyrax.exc.PyraxException as e:
module.fail_json(msg='%s' % e.message)
else: # Updating an existing node
mutable = {
'condition': condition,
'type': typ,
'weight': weight,
}
for name, value in mutable.items():
if value is None or value == getattr(node, name):
mutable.pop(name)
if not mutable:
module.exit_json(changed=False, state=state, node=result)
try:
# The diff has to be set explicitly to update node's weight and
# type; this should probably be fixed in pyrax
lb.update_node(node, diff=mutable)
result.update(mutable)
except pyrax.exc.PyraxException as e:
module.fail_json(msg='%s' % e.message)
if wait:
pyrax.utils.wait_until(lb, "status", "ACTIVE", interval=1,
attempts=wait_timeout)
if lb.status != 'ACTIVE':
module.fail_json(
msg='Load balancer not active after %ds (current status: %s)' %
(wait_timeout, lb.status.lower()))
kwargs = {'node': result} if result else {}
module.exit_json(changed=True, state=state, **kwargs)
if __name__ == '__main__':
main()
|
gpl-3.0
|
[
3381,
2647,
15,
1393,
15,
1548,
199,
3,
1898,
26,
2622,
7290,
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,
16937,
63,
429,
66,
63,
2415,
199,
3612,
63,
1802,
26,
1050,
12,
2811,
436,
2813,
3380,
687,
282,
32679,
8142,
7190,
23928,
7716,
199,
1802,
26,
523,
446,
15747,
12,
26473,
436,
14185,
3380,
687,
282,
32679,
8142,
7190,
23928,
7716,
199,
1023,
63,
3270,
26,
298,
17,
14,
20,
2,
199,
1419,
26,
523,
2287,
26,
272,
1415,
26,
3055,
272,
1369,
26,
489,
446,
3531,
2287,
503,
2881,
536,
402,
314,
1031,
523,
5558,
26,
272,
1415,
26,
3055,
272,
3415,
26,
489,
446,
5223,
489,
446,
6980,
489,
446,
366,
6322,
316,
272,
1369,
26,
489,
446,
28401,
367,
314,
1031,
12,
1314,
16756,
2399,
4719,
4453,
314,
2248,
267,
17005,
523,
2248,
63,
11841,
63,
344,
26,
272,
1415,
26,
2549,
272,
1369,
26,
489,
446,
7190,
17005,
1305,
523,
1031,
63,
344,
26,
272,
1415,
26,
3055,
272,
1369,
26,
489,
446,
5013,
1305,
523,
1844,
26,
272,
1415,
26,
3055,
272,
1369,
26,
489,
446,
10977,
1329,
402,
314,
2248,
14094,
68,
2435,
641,
314,
1031,
523,
1174,
26,
272,
1415,
26,
3055,
272,
849,
26,
298,
1881,
2,
272,
3415,
26,
489,
446,
3451,
489,
446,
9552,
272,
1369,
26,
489,
446,
1010,
10188,
6387,
1174,
402,
314,
1031,
523,
730,
26,
272,
1415,
26,
3055,
272,
3415,
26,
489,
446,
5062,
489,
446,
13851,
272,
1369,
26,
489,
446,
2434,
402,
1031,
523,
3618,
26,
272,
1415,
26,
3055,
272,
849,
26,
298,
889,
2,
272,
730,
26,
2155,
272,
1369,
26,
489,
446,
13144,
367,
314,
2248,
17005,
370,
8649,
4702,
2544,
8152,
523,
3618,
63,
2593,
26,
272,
1415,
26,
3055,
272,
849,
26,
4233,
272,
1369,
26,
489,
446,
7494,
1846,
370,
3618,
2544,
15131,
1536,
436,
8152,
376,
1125,
523,
5401,
26,
272,
1415,
26,
3055,
272,
1369,
26,
489,
446,
2136,
1070,
402,
1031,
199,
2502,
26,
298,
44,
3210,
305,
90,
1804,
10084,
67,
3605,
561,
8810,
8593,
685,
85,
3977,
2924,
199,
11036,
63,
9970,
63,
7677,
26,
523,
446,
660,
346,
2638,
523,
446,
660,
346,
2638,
14,
8512,
199,
2344,
199,
199,
8918,
275,
1449,
199,
3,
2654,
282,
892,
1031,
370,
314,
2248,
17005,
199,
13,
2257,
63,
1287,
26,
272,
859,
26,
16937,
63,
429,
66,
63,
2415,
272,
2248,
63,
11841,
63,
344,
26,
17245,
272,
2287,
26,
1616,
14,
18,
14,
18,
14,
19,
272,
1844,
26,
5939,
272,
5558,
26,
5223,
272,
730,
26,
5062,
272,
3618,
26,
9456,
272,
6235,
26,
1182,
515,
15,
475,
15,
6942,
199,
199,
3,
577,
6322,
6947,
687,
282,
1031,
199,
13,
2257,
63,
1287,
26,
272,
859,
26,
16937,
63,
429,
66,
63,
2415,
272,
2248,
63,
11841,
63,
344,
26,
17245,
272,
1031,
63,
344,
26,
32321,
272,
5558,
26,
366,
6322,
316,
272,
3618,
26,
9456,
272,
6235,
26,
1182,
515,
15,
475,
15,
6942,
199,
199,
3,
5852,
282,
1031,
687,
314,
2248,
17005,
199,
13,
2257,
63,
1287,
26,
272,
859,
26,
16937,
63,
429,
66,
63,
2415,
272,
2248,
63,
11841,
63,
344,
26,
17245,
272,
1031,
63,
344,
26,
32321,
272,
1174,
26,
9552,
272,
3618,
26,
9456,
272,
6235,
26,
1182,
515,
15,
475,
15,
6942,
199,
2344,
199,
199,
646,
747,
199,
199,
893,
26,
272,
492,
23944,
272,
7509,
63,
4521,
2847,
56,
275,
715,
199,
2590,
3545,
26,
272,
7509,
63,
4521,
2847,
56,
275,
756,
199,
199,
504,
3242,
14,
578,
63,
1208,
14,
4316,
492,
6953,
199,
504,
3242,
14,
578,
63,
1208,
14,
14495,
492,
16937,
63,
2094,
63,
1650,
12,
16937,
63,
429,
66,
63,
932,
63,
475,
63,
807,
12,
16937,
63,
2427,
63,
6314,
12,
3272,
63,
14495,
63,
578,
421,
199,
318,
485,
8222,
63,
21611,
8,
515,
304,
272,
15422,
63,
3749,
275,
747,
14,
515,
14,
904,
8,
515,
12,
283,
1393,
297,
283,
8222,
63,
3749,
14,
647,
358,
272,
543,
1551,
8,
8222,
63,
3749,
9,
465,
289,
26,
267,
1233,
275,
6555,
8,
70,
14,
739,
1062,
15422,
63,
3749,
12,
283,
1628,
358,
267,
2146,
8,
600,
9,
421,
199,
318,
485,
362,
63,
932,
8,
6374,
12,
1031,
63,
344,
29,
403,
12,
2287,
29,
403,
12,
1844,
29,
403,
304,
272,
408,
1767,
282,
4877,
1031,
624,
272,
367,
1031,
315,
2519,
8,
6374,
12,
283,
2415,
297,
12319,
267,
1336,
63,
513,
275,
942,
267,
340,
1031,
63,
344,
365,
440,
488,
26,
288,
1336,
63,
513,
14,
740,
8,
5675,
8,
932,
12,
283,
344,
297,
488,
9,
508,
1031,
63,
344,
9,
267,
340,
2287,
365,
440,
488,
26,
288,
1336,
63,
513,
14,
740,
8,
5675,
8,
932,
12,
283,
1562,
297,
488,
9,
508,
2287,
9,
267,
340,
1844,
365,
440,
488,
26,
288,
1336,
63,
513,
14,
740,
8,
5675,
8,
932,
12,
283,
719,
297,
488,
9,
508,
1844,
9,
398,
340,
1336,
63,
513,
436,
1006,
8,
1431,
63,
513,
304,
288,
372,
1031,
339,
372,
488,
421,
199,
318,
2446,
837,
272,
1423,
63,
1650,
275,
16937,
63,
2094,
63,
1650,
342,
272,
1423,
63,
1650,
14,
873,
8,
267,
1211,
8,
288,
2287,
29,
807,
1062,
288,
5558,
29,
807,
8,
4577,
2968,
3827,
297,
283,
7011,
297,
283,
30324,
316,
3815,
288,
2248,
63,
11841,
63,
344,
29,
807,
8,
2427,
29,
549,
12,
730,
534,
442,
659,
288,
1031,
63,
344,
29,
807,
8,
466,
534,
442,
659,
288,
1844,
29,
807,
8,
466,
534,
442,
659
] |
[
2647,
15,
1393,
15,
1548,
199,
3,
1898,
26,
2622,
7290,
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,
16937,
63,
429,
66,
63,
2415,
199,
3612,
63,
1802,
26,
1050,
12,
2811,
436,
2813,
3380,
687,
282,
32679,
8142,
7190,
23928,
7716,
199,
1802,
26,
523,
446,
15747,
12,
26473,
436,
14185,
3380,
687,
282,
32679,
8142,
7190,
23928,
7716,
199,
1023,
63,
3270,
26,
298,
17,
14,
20,
2,
199,
1419,
26,
523,
2287,
26,
272,
1415,
26,
3055,
272,
1369,
26,
489,
446,
3531,
2287,
503,
2881,
536,
402,
314,
1031,
523,
5558,
26,
272,
1415,
26,
3055,
272,
3415,
26,
489,
446,
5223,
489,
446,
6980,
489,
446,
366,
6322,
316,
272,
1369,
26,
489,
446,
28401,
367,
314,
1031,
12,
1314,
16756,
2399,
4719,
4453,
314,
2248,
267,
17005,
523,
2248,
63,
11841,
63,
344,
26,
272,
1415,
26,
2549,
272,
1369,
26,
489,
446,
7190,
17005,
1305,
523,
1031,
63,
344,
26,
272,
1415,
26,
3055,
272,
1369,
26,
489,
446,
5013,
1305,
523,
1844,
26,
272,
1415,
26,
3055,
272,
1369,
26,
489,
446,
10977,
1329,
402,
314,
2248,
14094,
68,
2435,
641,
314,
1031,
523,
1174,
26,
272,
1415,
26,
3055,
272,
849,
26,
298,
1881,
2,
272,
3415,
26,
489,
446,
3451,
489,
446,
9552,
272,
1369,
26,
489,
446,
1010,
10188,
6387,
1174,
402,
314,
1031,
523,
730,
26,
272,
1415,
26,
3055,
272,
3415,
26,
489,
446,
5062,
489,
446,
13851,
272,
1369,
26,
489,
446,
2434,
402,
1031,
523,
3618,
26,
272,
1415,
26,
3055,
272,
849,
26,
298,
889,
2,
272,
730,
26,
2155,
272,
1369,
26,
489,
446,
13144,
367,
314,
2248,
17005,
370,
8649,
4702,
2544,
8152,
523,
3618,
63,
2593,
26,
272,
1415,
26,
3055,
272,
849,
26,
4233,
272,
1369,
26,
489,
446,
7494,
1846,
370,
3618,
2544,
15131,
1536,
436,
8152,
376,
1125,
523,
5401,
26,
272,
1415,
26,
3055,
272,
1369,
26,
489,
446,
2136,
1070,
402,
1031,
199,
2502,
26,
298,
44,
3210,
305,
90,
1804,
10084,
67,
3605,
561,
8810,
8593,
685,
85,
3977,
2924,
199,
11036,
63,
9970,
63,
7677,
26,
523,
446,
660,
346,
2638,
523,
446,
660,
346,
2638,
14,
8512,
199,
2344,
199,
199,
8918,
275,
1449,
199,
3,
2654,
282,
892,
1031,
370,
314,
2248,
17005,
199,
13,
2257,
63,
1287,
26,
272,
859,
26,
16937,
63,
429,
66,
63,
2415,
272,
2248,
63,
11841,
63,
344,
26,
17245,
272,
2287,
26,
1616,
14,
18,
14,
18,
14,
19,
272,
1844,
26,
5939,
272,
5558,
26,
5223,
272,
730,
26,
5062,
272,
3618,
26,
9456,
272,
6235,
26,
1182,
515,
15,
475,
15,
6942,
199,
199,
3,
577,
6322,
6947,
687,
282,
1031,
199,
13,
2257,
63,
1287,
26,
272,
859,
26,
16937,
63,
429,
66,
63,
2415,
272,
2248,
63,
11841,
63,
344,
26,
17245,
272,
1031,
63,
344,
26,
32321,
272,
5558,
26,
366,
6322,
316,
272,
3618,
26,
9456,
272,
6235,
26,
1182,
515,
15,
475,
15,
6942,
199,
199,
3,
5852,
282,
1031,
687,
314,
2248,
17005,
199,
13,
2257,
63,
1287,
26,
272,
859,
26,
16937,
63,
429,
66,
63,
2415,
272,
2248,
63,
11841,
63,
344,
26,
17245,
272,
1031,
63,
344,
26,
32321,
272,
1174,
26,
9552,
272,
3618,
26,
9456,
272,
6235,
26,
1182,
515,
15,
475,
15,
6942,
199,
2344,
199,
199,
646,
747,
199,
199,
893,
26,
272,
492,
23944,
272,
7509,
63,
4521,
2847,
56,
275,
715,
199,
2590,
3545,
26,
272,
7509,
63,
4521,
2847,
56,
275,
756,
199,
199,
504,
3242,
14,
578,
63,
1208,
14,
4316,
492,
6953,
199,
504,
3242,
14,
578,
63,
1208,
14,
14495,
492,
16937,
63,
2094,
63,
1650,
12,
16937,
63,
429,
66,
63,
932,
63,
475,
63,
807,
12,
16937,
63,
2427,
63,
6314,
12,
3272,
63,
14495,
63,
578,
421,
199,
318,
485,
8222,
63,
21611,
8,
515,
304,
272,
15422,
63,
3749,
275,
747,
14,
515,
14,
904,
8,
515,
12,
283,
1393,
297,
283,
8222,
63,
3749,
14,
647,
358,
272,
543,
1551,
8,
8222,
63,
3749,
9,
465,
289,
26,
267,
1233,
275,
6555,
8,
70,
14,
739,
1062,
15422,
63,
3749,
12,
283,
1628,
358,
267,
2146,
8,
600,
9,
421,
199,
318,
485,
362,
63,
932,
8,
6374,
12,
1031,
63,
344,
29,
403,
12,
2287,
29,
403,
12,
1844,
29,
403,
304,
272,
408,
1767,
282,
4877,
1031,
624,
272,
367,
1031,
315,
2519,
8,
6374,
12,
283,
2415,
297,
12319,
267,
1336,
63,
513,
275,
942,
267,
340,
1031,
63,
344,
365,
440,
488,
26,
288,
1336,
63,
513,
14,
740,
8,
5675,
8,
932,
12,
283,
344,
297,
488,
9,
508,
1031,
63,
344,
9,
267,
340,
2287,
365,
440,
488,
26,
288,
1336,
63,
513,
14,
740,
8,
5675,
8,
932,
12,
283,
1562,
297,
488,
9,
508,
2287,
9,
267,
340,
1844,
365,
440,
488,
26,
288,
1336,
63,
513,
14,
740,
8,
5675,
8,
932,
12,
283,
719,
297,
488,
9,
508,
1844,
9,
398,
340,
1336,
63,
513,
436,
1006,
8,
1431,
63,
513,
304,
288,
372,
1031,
339,
372,
488,
421,
199,
318,
2446,
837,
272,
1423,
63,
1650,
275,
16937,
63,
2094,
63,
1650,
342,
272,
1423,
63,
1650,
14,
873,
8,
267,
1211,
8,
288,
2287,
29,
807,
1062,
288,
5558,
29,
807,
8,
4577,
2968,
3827,
297,
283,
7011,
297,
283,
30324,
316,
3815,
288,
2248,
63,
11841,
63,
344,
29,
807,
8,
2427,
29,
549,
12,
730,
534,
442,
659,
288,
1031,
63,
344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
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
ivotron/teuthology
|
teuthology/task/pexec.py
|
10
|
4274
|
"""
Handle parallel execution on remote hosts
"""
import logging
from teuthology import misc as teuthology
from teuthology.parallel import parallel
from teuthology.orchestra import run as tor
log = logging.getLogger(__name__)
from gevent import queue as queue
from gevent import event as event
def _init_barrier(barrier_queue, remote):
"""current just queues a remote host"""
barrier_queue.put(remote)
def _do_barrier(barrier, barrier_queue, remote):
"""special case for barrier"""
barrier_queue.get()
if barrier_queue.empty():
barrier.set()
barrier.clear()
else:
barrier.wait()
barrier_queue.put(remote)
if barrier_queue.full():
barrier.set()
barrier.clear()
else:
barrier.wait()
def _exec_host(barrier, barrier_queue, remote, sudo, testdir, ls):
"""Execute command remotely"""
log.info('Running commands on host %s', remote.name)
args = [
'TESTDIR={tdir}'.format(tdir=testdir),
'bash',
'-s'
]
if sudo:
args.insert(0, 'sudo')
r = remote.run( args=args, stdin=tor.PIPE, wait=False)
r.stdin.writelines(['set -e\n'])
r.stdin.flush()
for l in ls:
l.replace('$TESTDIR', testdir)
if l == "barrier":
_do_barrier(barrier, barrier_queue, remote)
continue
r.stdin.writelines([l, '\n'])
r.stdin.flush()
r.stdin.writelines(['\n'])
r.stdin.flush()
r.stdin.close()
tor.wait([r])
def _generate_remotes(ctx, config):
"""Return remote roles and the type of role specified in config"""
if 'all' in config and len(config) == 1:
ls = config['all']
for remote in ctx.cluster.remotes.iterkeys():
yield (remote, ls)
elif 'clients' in config:
ls = config['clients']
for role in teuthology.all_roles_of_type(ctx.cluster, 'client'):
(remote,) = ctx.cluster.only('client.{r}'.format(r=role)).remotes.iterkeys()
yield (remote, ls)
del config['clients']
for role, ls in config.iteritems():
(remote,) = ctx.cluster.only(role).remotes.iterkeys()
yield (remote, ls)
else:
for role, ls in config.iteritems():
(remote,) = ctx.cluster.only(role).remotes.iterkeys()
yield (remote, ls)
def task(ctx, config):
"""
Execute commands on multiple hosts in parallel
tasks:
- ceph:
- ceph-fuse: [client.0, client.1]
- pexec:
client.0:
- while true; do echo foo >> bar; done
client.1:
- sleep 1
- tail -f bar
- interactive:
Execute commands on all hosts in the cluster in parallel. This
is useful if there are many hosts and you want to run the same
command on all:
tasks:
- pexec:
all:
- grep FAIL /var/log/ceph/*
Or if you want to run in parallel on all clients:
tasks:
- pexec:
clients:
- dd if=/dev/zero of={testdir}/mnt.* count=1024 bs=1024
You can also ensure that parallel commands are synchronized with the
special 'barrier' statement:
tasks:
- pexec:
clients:
- cd {testdir}/mnt.*
- while true; do
- barrier
- dd if=/dev/zero of=./foo count=1024 bs=1024
- done
The above writes to the file foo on all clients over and over, but ensures that
all clients perform each write command in sync. If one client takes longer to
write, all the other clients will wait.
"""
log.info('Executing custom commands...')
assert isinstance(config, dict), "task pexec got invalid config"
sudo = False
if 'sudo' in config:
sudo = config['sudo']
del config['sudo']
testdir = teuthology.get_testdir(ctx)
remotes = list(_generate_remotes(ctx, config))
count = len(remotes)
barrier_queue = queue.Queue(count)
barrier = event.Event()
for remote in remotes:
_init_barrier(barrier_queue, remote[0])
with parallel() as p:
for remote in remotes:
p.spawn(_exec_host, barrier, barrier_queue, remote[0], sudo, testdir, remote[1])
|
mit
|
[
624,
199,
5940,
9861,
6451,
641,
3982,
7057,
199,
624,
199,
646,
2050,
199,
199,
504,
1565,
762,
7085,
492,
18576,
465,
1565,
762,
7085,
199,
504,
1565,
762,
7085,
14,
11887,
492,
9861,
199,
504,
1565,
762,
7085,
14,
269,
595,
14183,
492,
1255,
465,
11095,
199,
199,
793,
275,
2050,
14,
5572,
3460,
354,
3368,
199,
199,
504,
23386,
492,
4126,
465,
4126,
199,
504,
23386,
492,
1566,
465,
1566,
199,
199,
318,
485,
826,
63,
1700,
10742,
8,
1700,
10742,
63,
1825,
12,
3982,
304,
272,
408,
1818,
2951,
21366,
282,
3982,
1591,
624,
5591,
29741,
63,
1825,
14,
524,
8,
3846,
9,
199,
199,
318,
485,
1117,
63,
1700,
10742,
8,
1700,
10742,
12,
29741,
63,
1825,
12,
3982,
304,
272,
408,
6664,
1930,
367,
29741,
624,
272,
29741,
63,
1825,
14,
362,
342,
272,
340,
29741,
63,
1825,
14,
1667,
837,
267,
29741,
14,
409,
342,
267,
29741,
14,
3584,
342,
272,
587,
26,
267,
29741,
14,
2573,
342,
339,
29741,
63,
1825,
14,
524,
8,
3846,
9,
272,
340,
29741,
63,
1825,
14,
2861,
837,
267,
29741,
14,
409,
342,
267,
29741,
14,
3584,
342,
272,
587,
26,
267,
29741,
14,
2573,
342,
199,
199,
318,
485,
1628,
63,
1102,
8,
1700,
10742,
12,
29741,
63,
1825,
12,
3982,
12,
14682,
12,
7368,
12,
9100,
304,
272,
408,
12049,
1414,
3982,
590,
624,
272,
943,
14,
815,
360,
9602,
3718,
641,
1591,
450,
83,
297,
3982,
14,
354,
9,
272,
1249,
275,
359,
267,
283,
2864,
3022,
3126,
84,
694,
5285,
908,
8,
84,
694,
29,
16634,
395,
267,
283,
16408,
297,
267,
2475,
83,
7,
267,
1622,
272,
340,
14682,
26,
267,
1249,
14,
3176,
8,
16,
12,
283,
12095,
358,
2286,
519,
275,
3982,
14,
1065,
8,
1249,
29,
589,
12,
9009,
29,
8270,
14,
6089,
12,
3618,
29,
797,
9,
272,
519,
14,
6626,
14,
23277,
2941,
409,
446,
69,
60,
78,
1105,
272,
519,
14,
6626,
14,
4939,
342,
272,
367,
634,
315,
9100,
26,
267,
634,
14,
1814,
14676,
2864,
3022,
297,
7368,
9,
267,
340,
634,
508,
298,
1700,
10742,
582,
288,
485,
1117,
63,
1700,
10742,
8,
1700,
10742,
12,
29741,
63,
1825,
12,
3982,
9,
288,
1980,
398,
519,
14,
6626,
14,
23277,
779,
76,
12,
1557,
78,
1105,
267,
519,
14,
6626,
14,
4939,
342,
272,
519,
14,
6626,
14,
23277,
2941,
60,
78,
1105,
272,
519,
14,
6626,
14,
4939,
342,
272,
519,
14,
6626,
14,
1600,
342,
272,
11095,
14,
2573,
779,
82,
566,
199,
199,
318,
485,
4208,
63,
21420,
744,
8,
3799,
12,
1101,
304,
272,
408,
1767,
3982,
11689,
436,
314,
730,
402,
4719,
2013,
315,
1101,
624,
272,
340,
283,
452,
7,
315,
1101,
436,
822,
8,
888,
9,
508,
413,
26,
267,
9100,
275,
1101,
459,
452,
418,
267,
367,
3982,
315,
4027,
14,
4201,
14,
21420,
744,
14,
16007,
837,
288,
1995,
334,
3846,
12,
9100,
9,
272,
916,
283,
14555,
7,
315,
1101,
26,
267,
9100,
275,
1101,
459,
14555,
418,
267,
367,
4719,
315,
1565,
762,
7085,
14,
452,
63,
8050,
63,
1618,
63,
466,
8,
3799,
14,
4201,
12,
283,
1258,
735,
288,
334,
3846,
4258,
275,
4027,
14,
4201,
14,
2118,
360,
1258,
23379,
82,
5285,
908,
8,
82,
29,
3756,
4992,
21420,
744,
14,
16007,
342,
288,
1995,
334,
3846,
12,
9100,
9,
267,
2150,
1101,
459,
14555,
418,
267,
367,
4719,
12,
9100,
315,
1101,
14,
4611,
837,
288,
334,
3846,
4258,
275,
4027,
14,
4201,
14,
2118,
8,
3756,
680,
21420,
744,
14,
16007,
342,
288,
1995,
334,
3846,
12,
9100,
9,
272,
587,
26,
267,
367,
4719,
12,
9100,
315,
1101,
14,
4611,
837,
288,
334,
3846,
4258,
275,
4027,
14,
4201,
14,
2118,
8,
3756,
680,
21420,
744,
14,
16007,
342,
288,
1995,
334,
3846,
12,
9100,
9,
199,
199,
318,
2120,
8,
3799,
12,
1101,
304,
272,
408,
272,
17009,
3718,
641,
3663,
7057,
315,
9861,
398,
6527,
26,
267,
446,
27316,
26,
267,
446,
27316,
13,
70,
1180,
26,
359,
1258,
14,
16,
12,
1890,
14,
17,
61,
267,
446,
299,
1628,
26,
288,
1890,
14,
16,
26,
1598,
446,
1830,
2549,
27,
886,
11343,
3925,
4331,
4681,
27,
4224,
288,
1890,
14,
17,
26,
1598,
446,
9435,
413,
1598,
446,
9483,
446,
70,
4681,
267,
446,
12777,
26,
339,
17009,
3718,
641,
1006,
7057,
315,
314,
4350,
315,
9861,
14,
221,
961,
272,
365,
2997,
340,
2337,
787,
5002,
7057,
436,
1265,
2934,
370,
1255,
314,
2011,
272,
1414,
641,
1006,
26,
398,
6527,
26,
267,
446,
299,
1628,
26,
288,
1006,
26,
1598,
446,
20595,
10341,
1182,
1391,
15,
793,
15,
20266,
6331,
339,
4236,
340,
1265,
2934,
370,
1255,
315,
9861,
641,
1006,
13431,
26,
398,
6527,
26,
267,
446,
299,
1628,
26,
288,
13431,
26,
1598,
446,
13972,
340,
13043,
2374,
15,
4262,
402,
3126,
16634,
5995,
20481,
2795,
2338,
29,
7727,
9922,
29,
7727,
339,
2047,
883,
2597,
4868,
626,
9861,
3718,
787,
15354,
1759,
543,
314,
272,
4539,
283,
1700,
10742,
7,
5164,
26,
339,
6527,
26,
272,
446,
299,
1628,
26,
267,
13431,
26,
881,
446,
12829,
469,
16634,
5995,
20481,
2795,
881,
446,
1830,
2549,
27,
886,
881,
446,
257,
29741,
881,
446,
257,
13972,
340,
13043,
2374,
15,
4262,
402,
29,
13186,
1421,
2338,
29,
7727,
9922,
29,
7727,
881,
446,
4224,
339,
710,
3432,
14511,
370,
314,
570,
3925,
641,
1006,
13431,
1806,
436,
1806,
12,
1325,
15620,
626,
272,
1006,
13431,
5147,
1924,
2218,
1414,
315,
7604,
14,
221,
982,
1373,
1890,
6181,
8088,
370,
272,
2218,
12,
1006,
314,
1163,
13431,
911,
3618,
14,
339,
408,
272,
943,
14,
815,
360,
4858,
4655,
3537,
3718,
15103,
272,
702,
1228,
8,
888,
12,
1211,
395,
298,
1765,
299,
1628,
4788,
3866,
1101,
2,
339,
14682,
275,
756,
272,
340,
283,
12095,
7,
315,
1101,
26,
267,
14682,
275,
1101,
459,
12095,
418,
267,
2150,
1101,
459,
12095,
418,
339,
7368,
275,
1565,
762,
7085,
14,
362,
63,
16634,
8,
3799,
9,
339,
32178,
744,
275,
769,
1547,
4208,
63,
21420,
744,
8,
3799,
12,
1101,
430,
272,
2338,
275
] |
[
199,
5940,
9861,
6451,
641,
3982,
7057,
199,
624,
199,
646,
2050,
199,
199,
504,
1565,
762,
7085,
492,
18576,
465,
1565,
762,
7085,
199,
504,
1565,
762,
7085,
14,
11887,
492,
9861,
199,
504,
1565,
762,
7085,
14,
269,
595,
14183,
492,
1255,
465,
11095,
199,
199,
793,
275,
2050,
14,
5572,
3460,
354,
3368,
199,
199,
504,
23386,
492,
4126,
465,
4126,
199,
504,
23386,
492,
1566,
465,
1566,
199,
199,
318,
485,
826,
63,
1700,
10742,
8,
1700,
10742,
63,
1825,
12,
3982,
304,
272,
408,
1818,
2951,
21366,
282,
3982,
1591,
624,
5591,
29741,
63,
1825,
14,
524,
8,
3846,
9,
199,
199,
318,
485,
1117,
63,
1700,
10742,
8,
1700,
10742,
12,
29741,
63,
1825,
12,
3982,
304,
272,
408,
6664,
1930,
367,
29741,
624,
272,
29741,
63,
1825,
14,
362,
342,
272,
340,
29741,
63,
1825,
14,
1667,
837,
267,
29741,
14,
409,
342,
267,
29741,
14,
3584,
342,
272,
587,
26,
267,
29741,
14,
2573,
342,
339,
29741,
63,
1825,
14,
524,
8,
3846,
9,
272,
340,
29741,
63,
1825,
14,
2861,
837,
267,
29741,
14,
409,
342,
267,
29741,
14,
3584,
342,
272,
587,
26,
267,
29741,
14,
2573,
342,
199,
199,
318,
485,
1628,
63,
1102,
8,
1700,
10742,
12,
29741,
63,
1825,
12,
3982,
12,
14682,
12,
7368,
12,
9100,
304,
272,
408,
12049,
1414,
3982,
590,
624,
272,
943,
14,
815,
360,
9602,
3718,
641,
1591,
450,
83,
297,
3982,
14,
354,
9,
272,
1249,
275,
359,
267,
283,
2864,
3022,
3126,
84,
694,
5285,
908,
8,
84,
694,
29,
16634,
395,
267,
283,
16408,
297,
267,
2475,
83,
7,
267,
1622,
272,
340,
14682,
26,
267,
1249,
14,
3176,
8,
16,
12,
283,
12095,
358,
2286,
519,
275,
3982,
14,
1065,
8,
1249,
29,
589,
12,
9009,
29,
8270,
14,
6089,
12,
3618,
29,
797,
9,
272,
519,
14,
6626,
14,
23277,
2941,
409,
446,
69,
60,
78,
1105,
272,
519,
14,
6626,
14,
4939,
342,
272,
367,
634,
315,
9100,
26,
267,
634,
14,
1814,
14676,
2864,
3022,
297,
7368,
9,
267,
340,
634,
508,
298,
1700,
10742,
582,
288,
485,
1117,
63,
1700,
10742,
8,
1700,
10742,
12,
29741,
63,
1825,
12,
3982,
9,
288,
1980,
398,
519,
14,
6626,
14,
23277,
779,
76,
12,
1557,
78,
1105,
267,
519,
14,
6626,
14,
4939,
342,
272,
519,
14,
6626,
14,
23277,
2941,
60,
78,
1105,
272,
519,
14,
6626,
14,
4939,
342,
272,
519,
14,
6626,
14,
1600,
342,
272,
11095,
14,
2573,
779,
82,
566,
199,
199,
318,
485,
4208,
63,
21420,
744,
8,
3799,
12,
1101,
304,
272,
408,
1767,
3982,
11689,
436,
314,
730,
402,
4719,
2013,
315,
1101,
624,
272,
340,
283,
452,
7,
315,
1101,
436,
822,
8,
888,
9,
508,
413,
26,
267,
9100,
275,
1101,
459,
452,
418,
267,
367,
3982,
315,
4027,
14,
4201,
14,
21420,
744,
14,
16007,
837,
288,
1995,
334,
3846,
12,
9100,
9,
272,
916,
283,
14555,
7,
315,
1101,
26,
267,
9100,
275,
1101,
459,
14555,
418,
267,
367,
4719,
315,
1565,
762,
7085,
14,
452,
63,
8050,
63,
1618,
63,
466,
8,
3799,
14,
4201,
12,
283,
1258,
735,
288,
334,
3846,
4258,
275,
4027,
14,
4201,
14,
2118,
360,
1258,
23379,
82,
5285,
908,
8,
82,
29,
3756,
4992,
21420,
744,
14,
16007,
342,
288,
1995,
334,
3846,
12,
9100,
9,
267,
2150,
1101,
459,
14555,
418,
267,
367,
4719,
12,
9100,
315,
1101,
14,
4611,
837,
288,
334,
3846,
4258,
275,
4027,
14,
4201,
14,
2118,
8,
3756,
680,
21420,
744,
14,
16007,
342,
288,
1995,
334,
3846,
12,
9100,
9,
272,
587,
26,
267,
367,
4719,
12,
9100,
315,
1101,
14,
4611,
837,
288,
334,
3846,
4258,
275,
4027,
14,
4201,
14,
2118,
8,
3756,
680,
21420,
744,
14,
16007,
342,
288,
1995,
334,
3846,
12,
9100,
9,
199,
199,
318,
2120,
8,
3799,
12,
1101,
304,
272,
408,
272,
17009,
3718,
641,
3663,
7057,
315,
9861,
398,
6527,
26,
267,
446,
27316,
26,
267,
446,
27316,
13,
70,
1180,
26,
359,
1258,
14,
16,
12,
1890,
14,
17,
61,
267,
446,
299,
1628,
26,
288,
1890,
14,
16,
26,
1598,
446,
1830,
2549,
27,
886,
11343,
3925,
4331,
4681,
27,
4224,
288,
1890,
14,
17,
26,
1598,
446,
9435,
413,
1598,
446,
9483,
446,
70,
4681,
267,
446,
12777,
26,
339,
17009,
3718,
641,
1006,
7057,
315,
314,
4350,
315,
9861,
14,
221,
961,
272,
365,
2997,
340,
2337,
787,
5002,
7057,
436,
1265,
2934,
370,
1255,
314,
2011,
272,
1414,
641,
1006,
26,
398,
6527,
26,
267,
446,
299,
1628,
26,
288,
1006,
26,
1598,
446,
20595,
10341,
1182,
1391,
15,
793,
15,
20266,
6331,
339,
4236,
340,
1265,
2934,
370,
1255,
315,
9861,
641,
1006,
13431,
26,
398,
6527,
26,
267,
446,
299,
1628,
26,
288,
13431,
26,
1598,
446,
13972,
340,
13043,
2374,
15,
4262,
402,
3126,
16634,
5995,
20481,
2795,
2338,
29,
7727,
9922,
29,
7727,
339,
2047,
883,
2597,
4868,
626,
9861,
3718,
787,
15354,
1759,
543,
314,
272,
4539,
283,
1700,
10742,
7,
5164,
26,
339,
6527,
26,
272,
446,
299,
1628,
26,
267,
13431,
26,
881,
446,
12829,
469,
16634,
5995,
20481,
2795,
881,
446,
1830,
2549,
27,
886,
881,
446,
257,
29741,
881,
446,
257,
13972,
340,
13043,
2374,
15,
4262,
402,
29,
13186,
1421,
2338,
29,
7727,
9922,
29,
7727,
881,
446,
4224,
339,
710,
3432,
14511,
370,
314,
570,
3925,
641,
1006,
13431,
1806,
436,
1806,
12,
1325,
15620,
626,
272,
1006,
13431,
5147,
1924,
2218,
1414,
315,
7604,
14,
221,
982,
1373,
1890,
6181,
8088,
370,
272,
2218,
12,
1006,
314,
1163,
13431,
911,
3618,
14,
339,
408,
272,
943,
14,
815,
360,
4858,
4655,
3537,
3718,
15103,
272,
702,
1228,
8,
888,
12,
1211,
395,
298,
1765,
299,
1628,
4788,
3866,
1101,
2,
339,
14682,
275,
756,
272,
340,
283,
12095,
7,
315,
1101,
26,
267,
14682,
275,
1101,
459,
12095,
418,
267,
2150,
1101,
459,
12095,
418,
339,
7368,
275,
1565,
762,
7085,
14,
362,
63,
16634,
8,
3799,
9,
339,
32178,
744,
275,
769,
1547,
4208,
63,
21420,
744,
8,
3799,
12,
1101,
430,
272,
2338,
275,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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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
] |
GoogleCloudPlatform/stackdriver-metrics-export
|
get_timeseries/config.py
|
1
|
1308
|
#!/usr/bin/env python
# Copyright 2019 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.
PUBSUB_TOPIC="write_metrics"
AGGREGATION_ALIGNMENT_PERIOD="3600s"
GROUP_BY_STRING="metric.labels.key"
PAGE_SIZE=500
PUBSUB_VERIFICATION_TOKEN = '16b2ecfb-7734-48b9-817d-4ac8bd623c87'
BIGQUERY_DATASET='metric_export'
BIGQUERY_STATS_TABLE='sd_metrics_stats'
WRITE_BQ_STATS_FLAG=True
GAUGE="GAUGE"
DELTA="DELTA"
CUMULATIVE="CUMULATIVE"
BOOL="BOOL"
INT64="INT64"
DOUBLE="DOUBLE"
STRING="STRING"
DISTRIBUTION="DISTRIBUTION"
ALIGN_DELTA="ALIGN_DELTA"
ALIGN_FRACTION_TRUE="ALIGN_FRACTION_TRUE"
ALIGN_SUM="ALIGN_SUM"
ALIGN_COUNT="ALIGN_COUNT"
ALIGN_NONE="ALIGN_NONE"
REDUCE_FRACTION_TRUE="REDUCE_FRACTION_TRUE"
REDUCE_MEAN="REDUCE_MEAN"
REDUCE_SUM="REDUCE_SUM"
REDUCE_COUNT="REDUCE_COUNT"
REDUCE_NONE="REDUCE_NONE"
|
apache-2.0
|
[
3381,
2647,
15,
1393,
15,
1813,
2366,
199,
199,
3,
1898,
20312,
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,
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,
13047,
6348,
63,
23740,
628,
952,
63,
6759,
2,
199,
14083,
5616,
2594,
63,
15255,
4479,
63,
27081,
628,
11035,
83,
2,
199,
7823,
63,
8285,
63,
5353,
628,
5165,
14,
3512,
14,
498,
2,
199,
12898,
63,
4305,
29,
5783,
199,
13047,
6348,
63,
2111,
14456,
2594,
63,
8803,
275,
283,
975,
66,
18,
825,
4675,
13,
1138,
1082,
13,
2006,
66,
25,
13,
31023,
68,
13,
20,
645,
24,
3691,
31353,
67,
1555,
7,
199,
18643,
11938,
63,
28231,
775,
534,
5165,
63,
3790,
7,
199,
18643,
11938,
63,
19202,
63,
8723,
534,
3893,
63,
6759,
63,
3200,
7,
199,
10387,
63,
27383,
63,
19202,
63,
3719,
29,
549,
199,
199,
39,
9331,
4962,
628,
39,
9331,
4962,
2,
199,
4424,
6166,
628,
4424,
6166,
2,
199,
5497,
1293,
14277,
628,
5497,
1293,
14277,
2,
199,
199,
16026,
628,
16026,
2,
199,
2919,
772,
628,
2919,
772,
2,
199,
14989,
628,
14989,
2,
199,
5353,
628,
5353,
2,
199,
24580,
26601,
628,
24580,
26601,
2,
199,
199,
15255,
63,
4424,
6166,
628,
15255,
63,
4424,
6166,
2,
199,
15255,
63,
38,
20656,
63,
15064,
628,
15255,
63,
38,
20656,
63,
15064,
2,
199,
15255,
63,
13285,
628,
15255,
63,
13285,
2,
199,
15255,
63,
8760,
628,
15255,
63,
8760,
2,
199,
15255,
63,
9185,
628,
15255,
63,
9185,
2,
199,
907,
4980,
2089,
63,
38,
20656,
63,
15064,
628,
907,
4980,
2089,
63,
38,
20656,
63,
15064,
2,
199,
907,
4980,
2089,
63,
31840,
628,
907,
4980,
2089,
63,
31840,
2,
199,
907,
4980,
2089,
63,
13285,
628,
907,
4980,
2089,
63,
13285,
2,
199,
907,
4980,
2089,
63,
8760,
628,
907,
4980,
2089,
63,
8760,
2,
199,
907,
4980,
2089,
63,
9185,
628,
907,
4980,
2089,
63,
9185,
2,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
2647,
15,
1393,
15,
1813,
2366,
199,
199,
3,
1898,
20312,
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,
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,
13047,
6348,
63,
23740,
628,
952,
63,
6759,
2,
199,
14083,
5616,
2594,
63,
15255,
4479,
63,
27081,
628,
11035,
83,
2,
199,
7823,
63,
8285,
63,
5353,
628,
5165,
14,
3512,
14,
498,
2,
199,
12898,
63,
4305,
29,
5783,
199,
13047,
6348,
63,
2111,
14456,
2594,
63,
8803,
275,
283,
975,
66,
18,
825,
4675,
13,
1138,
1082,
13,
2006,
66,
25,
13,
31023,
68,
13,
20,
645,
24,
3691,
31353,
67,
1555,
7,
199,
18643,
11938,
63,
28231,
775,
534,
5165,
63,
3790,
7,
199,
18643,
11938,
63,
19202,
63,
8723,
534,
3893,
63,
6759,
63,
3200,
7,
199,
10387,
63,
27383,
63,
19202,
63,
3719,
29,
549,
199,
199,
39,
9331,
4962,
628,
39,
9331,
4962,
2,
199,
4424,
6166,
628,
4424,
6166,
2,
199,
5497,
1293,
14277,
628,
5497,
1293,
14277,
2,
199,
199,
16026,
628,
16026,
2,
199,
2919,
772,
628,
2919,
772,
2,
199,
14989,
628,
14989,
2,
199,
5353,
628,
5353,
2,
199,
24580,
26601,
628,
24580,
26601,
2,
199,
199,
15255,
63,
4424,
6166,
628,
15255,
63,
4424,
6166,
2,
199,
15255,
63,
38,
20656,
63,
15064,
628,
15255,
63,
38,
20656,
63,
15064,
2,
199,
15255,
63,
13285,
628,
15255,
63,
13285,
2,
199,
15255,
63,
8760,
628,
15255,
63,
8760,
2,
199,
15255,
63,
9185,
628,
15255,
63,
9185,
2,
199,
907,
4980,
2089,
63,
38,
20656,
63,
15064,
628,
907,
4980,
2089,
63,
38,
20656,
63,
15064,
2,
199,
907,
4980,
2089,
63,
31840,
628,
907,
4980,
2089,
63,
31840,
2,
199,
907,
4980,
2089,
63,
13285,
628,
907,
4980,
2089,
63,
13285,
2,
199,
907,
4980,
2089,
63,
8760,
628,
907,
4980,
2089,
63,
8760,
2,
199,
907,
4980,
2089,
63,
9185,
628,
907,
4980,
2089,
63,
9185,
2,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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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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
] |
geraldoandradee/pytest
|
_pytest/python.py
|
1
|
72287
|
""" Python test discovery, setup and run of test functions. """
import py
import inspect
import sys
import pytest
from _pytest.main import getfslineno
from _pytest.mark import MarkDecorator, MarkInfo
from _pytest.monkeypatch import monkeypatch
from py._code.code import TerminalRepr
import _pytest
cutdir = py.path.local(_pytest.__file__).dirpath()
NoneType = type(None)
callable = py.builtin.callable
def getimfunc(func):
try:
return func.__func__
except AttributeError:
try:
return func.im_func
except AttributeError:
return func
class FixtureFunctionMarker:
def __init__(self, scope, params, autouse=False, yieldctx=False):
self.scope = scope
self.params = params
self.autouse = autouse
self.yieldctx = yieldctx
def __call__(self, function):
if inspect.isclass(function):
raise ValueError(
"class fixtures not supported (may be in the future)")
function._pytestfixturefunction = self
return function
def fixture(scope="function", params=None, autouse=False):
""" (return a) decorator to mark a fixture factory function.
This decorator can be used (with or or without parameters) to define
a fixture function. The name of the fixture function can later be
referenced to cause its invocation ahead of running tests: test
modules or classes can use the pytest.mark.usefixtures(fixturename)
marker. Test functions can directly use fixture names as input
arguments in which case the fixture instance returned from the fixture
function will be injected.
:arg scope: the scope for which this fixture is shared, one of
"function" (default), "class", "module", "session".
:arg params: an optional list of parameters which will cause multiple
invocations of the fixture function and all of the tests
using it.
:arg autouse: if True, the fixture func is activated for all tests that
can see it. If False (the default) then an explicit
reference is needed to activate the fixture.
"""
if callable(scope) and params is None and autouse == False:
# direct decoration
return FixtureFunctionMarker(
"function", params, autouse)(scope)
else:
return FixtureFunctionMarker(scope, params, autouse)
def yield_fixture(scope="function", params=None, autouse=False):
""" (return a) decorator to mark a yield-fixture factory function
(EXPERIMENTAL).
This takes the same arguments as :py:func:`pytest.fixture` but
expects a fixture function to use a ``yield`` instead of a ``return``
statement to provide a fixture. See
http://pytest.org/en/latest/yieldfixture.html for more info.
"""
if callable(scope) and params is None and autouse == False:
# direct decoration
return FixtureFunctionMarker(
"function", params, autouse, yieldctx=True)(scope)
else:
return FixtureFunctionMarker(scope, params, autouse, yieldctx=True)
defaultfuncargprefixmarker = fixture()
def pyobj_property(name):
def get(self):
node = self.getparent(getattr(pytest, name))
if node is not None:
return node.obj
doc = "python %s object this node was collected from (can be None)." % (
name.lower(),)
return property(get, None, None, doc)
def pytest_addoption(parser):
group = parser.getgroup("general")
group.addoption('--fixtures', '--funcargs',
action="store_true", dest="showfixtures", default=False,
help="show available fixtures, sorted by plugin appearance")
parser.addini("usefixtures", type="args", default=[],
help="list of default fixtures to be used with this project")
parser.addini("python_files", type="args",
default=('test_*.py', '*_test.py'),
help="glob-style file patterns for Python test module discovery")
parser.addini("python_classes", type="args", default=("Test",),
help="prefixes for Python test class discovery")
parser.addini("python_functions", type="args", default=("test",),
help="prefixes for Python test function and method discovery")
def pytest_cmdline_main(config):
if config.option.showfixtures:
showfixtures(config)
return 0
def pytest_generate_tests(metafunc):
try:
markers = metafunc.function.parametrize
except AttributeError:
return
for marker in markers:
metafunc.parametrize(*marker.args, **marker.kwargs)
def pytest_configure(config):
config.addinivalue_line("markers",
"parametrize(argnames, argvalues): call a test function multiple "
"times passing in multiple different argument value sets. Example: "
"@parametrize('arg1', [1,2]) would lead to two calls of the decorated "
"test function, one with arg1=1 and another with arg1=2."
" see http://pytest.org/latest/parametrize.html for more info and "
"examples."
)
config.addinivalue_line("markers",
"usefixtures(fixturename1, fixturename2, ...): mark tests as needing "
"all of the specified fixtures. see http://pytest.org/latest/fixture.html#usefixtures "
)
def pytest_sessionstart(session):
session._fixturemanager = FixtureManager(session)
@pytest.mark.trylast
def pytest_namespace():
raises.Exception = pytest.fail.Exception
return {
'fixture': fixture,
'yield_fixture': yield_fixture,
'raises' : raises,
'collect': {
'Module': Module, 'Class': Class, 'Instance': Instance,
'Function': Function, 'Generator': Generator,
'_fillfuncargs': fillfixtures}
}
@fixture()
def pytestconfig(request):
""" the pytest config object with access to command line opts."""
return request.config
def pytest_pyfunc_call(__multicall__, pyfuncitem):
if not __multicall__.execute():
testfunction = pyfuncitem.obj
if pyfuncitem._isyieldedfunction():
testfunction(*pyfuncitem._args)
else:
funcargs = pyfuncitem.funcargs
testargs = {}
for arg in pyfuncitem._fixtureinfo.argnames:
testargs[arg] = funcargs[arg]
testfunction(**testargs)
def pytest_collect_file(path, parent):
ext = path.ext
pb = path.purebasename
if ext == ".py":
if not parent.session.isinitpath(path):
for pat in parent.config.getini('python_files'):
if path.fnmatch(pat):
break
else:
return
ihook = parent.session.gethookproxy(path)
return ihook.pytest_pycollect_makemodule(path=path, parent=parent)
def pytest_pycollect_makemodule(path, parent):
return Module(path, parent)
def pytest_pycollect_makeitem(__multicall__, collector, name, obj):
res = __multicall__.execute()
if res is not None:
return res
if inspect.isclass(obj):
#if hasattr(collector.obj, 'unittest'):
# return # we assume it's a mixin class for a TestCase derived one
if collector.classnamefilter(name):
Class = collector._getcustomclass("Class")
return Class(name, parent=collector)
elif collector.funcnamefilter(name) and hasattr(obj, '__call__') and \
getfixturemarker(obj) is None:
if is_generator(obj):
return Generator(name, parent=collector)
else:
return list(collector._genfunctions(name, obj))
def is_generator(func):
try:
return py.code.getrawcode(func).co_flags & 32 # generator function
except AttributeError: # builtin functions have no bytecode
# assume them to not be generators
return False
class PyobjContext(object):
module = pyobj_property("Module")
cls = pyobj_property("Class")
instance = pyobj_property("Instance")
class PyobjMixin(PyobjContext):
def obj():
def fget(self):
try:
return self._obj
except AttributeError:
self._obj = obj = self._getobj()
return obj
def fset(self, value):
self._obj = value
return property(fget, fset, None, "underlying python object")
obj = obj()
def _getobj(self):
return getattr(self.parent.obj, self.name)
def getmodpath(self, stopatmodule=True, includemodule=False):
""" return python path relative to the containing module. """
chain = self.listchain()
chain.reverse()
parts = []
for node in chain:
if isinstance(node, Instance):
continue
name = node.name
if isinstance(node, Module):
assert name.endswith(".py")
name = name[:-3]
if stopatmodule:
if includemodule:
parts.append(name)
break
parts.append(name)
parts.reverse()
s = ".".join(parts)
return s.replace(".[", "[")
def _getfslineno(self):
return getfslineno(self.obj)
def reportinfo(self):
# XXX caching?
obj = self.obj
if hasattr(obj, 'compat_co_firstlineno'):
# nose compatibility
fspath = sys.modules[obj.__module__].__file__
if fspath.endswith(".pyc"):
fspath = fspath[:-1]
lineno = obj.compat_co_firstlineno
modpath = obj.__module__
else:
fspath, lineno = getfslineno(obj)
modpath = self.getmodpath()
assert isinstance(lineno, int)
return fspath, lineno, modpath
class PyCollector(PyobjMixin, pytest.Collector):
def funcnamefilter(self, name):
for prefix in self.config.getini("python_functions"):
if name.startswith(prefix):
return True
def classnamefilter(self, name):
for prefix in self.config.getini("python_classes"):
if name.startswith(prefix):
return True
def collect(self):
# NB. we avoid random getattrs and peek in the __dict__ instead
# (XXX originally introduced from a PyPy need, still true?)
dicts = [getattr(self.obj, '__dict__', {})]
for basecls in inspect.getmro(self.obj.__class__):
dicts.append(basecls.__dict__)
seen = {}
l = []
for dic in dicts:
for name, obj in dic.items():
if name in seen:
continue
seen[name] = True
res = self.makeitem(name, obj)
if res is None:
continue
if not isinstance(res, list):
res = [res]
l.extend(res)
l.sort(key=lambda item: item.reportinfo()[:2])
return l
def makeitem(self, name, obj):
#assert self.ihook.fspath == self.fspath, self
return self.ihook.pytest_pycollect_makeitem(
collector=self, name=name, obj=obj)
def _genfunctions(self, name, funcobj):
module = self.getparent(Module).obj
clscol = self.getparent(Class)
cls = clscol and clscol.obj or None
transfer_markers(funcobj, cls, module)
fm = self.session._fixturemanager
fixtureinfo = fm.getfixtureinfo(self, funcobj, cls)
metafunc = Metafunc(funcobj, fixtureinfo, self.config,
cls=cls, module=module)
gentesthook = self.config.hook.pytest_generate_tests
extra = [module]
if cls is not None:
extra.append(cls())
plugins = self.getplugins() + extra
gentesthook.pcall(plugins, metafunc=metafunc)
Function = self._getcustomclass("Function")
if not metafunc._calls:
yield Function(name, parent=self)
else:
for callspec in metafunc._calls:
subname = "%s[%s]" %(name, callspec.id)
yield Function(name=subname, parent=self,
callspec=callspec, callobj=funcobj,
keywords={callspec.id:True})
class FuncFixtureInfo:
def __init__(self, argnames, names_closure, name2fixturedefs):
self.argnames = argnames
self.names_closure = names_closure
self.name2fixturedefs = name2fixturedefs
def transfer_markers(funcobj, cls, mod):
# XXX this should rather be code in the mark plugin or the mark
# plugin should merge with the python plugin.
for holder in (cls, mod):
try:
pytestmark = holder.pytestmark
except AttributeError:
continue
if isinstance(pytestmark, list):
for mark in pytestmark:
mark(funcobj)
else:
pytestmark(funcobj)
class Module(pytest.File, PyCollector):
""" Collector for test classes and functions. """
def _getobj(self):
return self._memoizedcall('_obj', self._importtestmodule)
def collect(self):
self.session._fixturemanager.parsefactories(self)
return super(Module, self).collect()
def _importtestmodule(self):
# we assume we are only called once per module
try:
mod = self.fspath.pyimport(ensuresyspath=True)
except SyntaxError:
excinfo = py.code.ExceptionInfo()
raise self.CollectError(excinfo.getrepr(style="short"))
except self.fspath.ImportMismatchError:
e = sys.exc_info()[1]
raise self.CollectError(
"import file mismatch:\n"
"imported module %r has this __file__ attribute:\n"
" %s\n"
"which is not the same as the test file we want to collect:\n"
" %s\n"
"HINT: remove __pycache__ / .pyc files and/or use a "
"unique basename for your test file modules"
% e.args
)
#print "imported test module", mod
self.config.pluginmanager.consider_module(mod)
return mod
def setup(self):
setup_module = xunitsetup(self.obj, "setUpModule")
if setup_module is None:
setup_module = xunitsetup(self.obj, "setup_module")
if setup_module is not None:
#XXX: nose compat hack, move to nose plugin
# if it takes a positional arg, its probably a pytest style one
# so we pass the current module object
if inspect.getargspec(setup_module)[0]:
setup_module(self.obj)
else:
setup_module()
fin = getattr(self.obj, 'tearDownModule', None)
if fin is None:
fin = getattr(self.obj, 'teardown_module', None)
if fin is not None:
#XXX: nose compat hack, move to nose plugin
# if it takes a positional arg, its probably a py.test style one
# so we pass the current module object
if inspect.getargspec(fin)[0]:
finalizer = lambda: fin(self.obj)
else:
finalizer = fin
self.addfinalizer(finalizer)
class Class(PyCollector):
""" Collector for test methods. """
def collect(self):
if hasinit(self.obj):
pytest.skip("class %s.%s with __init__ won't get collected" % (
self.obj.__module__,
self.obj.__name__,
))
return [self._getcustomclass("Instance")(name="()", parent=self)]
def setup(self):
setup_class = xunitsetup(self.obj, 'setup_class')
if setup_class is not None:
setup_class = getattr(setup_class, 'im_func', setup_class)
setup_class = getattr(setup_class, '__func__', setup_class)
setup_class(self.obj)
fin_class = getattr(self.obj, 'teardown_class', None)
if fin_class is not None:
fin_class = getattr(fin_class, 'im_func', fin_class)
fin_class = getattr(fin_class, '__func__', fin_class)
self.addfinalizer(lambda: fin_class(self.obj))
class Instance(PyCollector):
def _getobj(self):
obj = self.parent.obj()
return obj
def collect(self):
self.session._fixturemanager.parsefactories(self)
return super(Instance, self).collect()
def newinstance(self):
self.obj = self._getobj()
return self.obj
class FunctionMixin(PyobjMixin):
""" mixin for the code common to Function and Generator.
"""
def setup(self):
""" perform setup for this test function. """
if hasattr(self, '_preservedparent'):
obj = self._preservedparent
elif isinstance(self.parent, Instance):
obj = self.parent.newinstance()
self.obj = self._getobj()
else:
obj = self.parent.obj
if inspect.ismethod(self.obj):
setup_name = 'setup_method'
teardown_name = 'teardown_method'
else:
setup_name = 'setup_function'
teardown_name = 'teardown_function'
setup_func_or_method = xunitsetup(obj, setup_name)
if setup_func_or_method is not None:
setup_func_or_method(self.obj)
fin = getattr(obj, teardown_name, None)
if fin is not None:
self.addfinalizer(lambda: fin(self.obj))
def _prunetraceback(self, excinfo):
if hasattr(self, '_obj') and not self.config.option.fulltrace:
code = py.code.Code(self.obj)
path, firstlineno = code.path, code.firstlineno
traceback = excinfo.traceback
ntraceback = traceback.cut(path=path, firstlineno=firstlineno)
if ntraceback == traceback:
ntraceback = ntraceback.cut(path=path)
if ntraceback == traceback:
ntraceback = ntraceback.cut(excludepath=cutdir)
excinfo.traceback = ntraceback.filter()
def _repr_failure_py(self, excinfo, style="long"):
if excinfo.errisinstance(pytest.fail.Exception):
if not excinfo.value.pytrace:
return str(excinfo.value)
return super(FunctionMixin, self)._repr_failure_py(excinfo,
style=style)
def repr_failure(self, excinfo, outerr=None):
assert outerr is None, "XXX outerr usage is deprecated"
return self._repr_failure_py(excinfo,
style=self.config.option.tbstyle)
class Generator(FunctionMixin, PyCollector):
def collect(self):
# test generators are seen as collectors but they also
# invoke setup/teardown on popular request
# (induced by the common "test_*" naming shared with normal tests)
self.session._setupstate.prepare(self)
# see FunctionMixin.setup and test_setupstate_is_preserved_134
self._preservedparent = self.parent.obj
l = []
seen = {}
for i, x in enumerate(self.obj()):
name, call, args = self.getcallargs(x)
if not callable(call):
raise TypeError("%r yielded non callable test %r" %(self.obj, call,))
if name is None:
name = "[%d]" % i
else:
name = "['%s']" % name
if name in seen:
raise ValueError("%r generated tests with non-unique name %r" %(self, name))
seen[name] = True
l.append(self.Function(name, self, args=args, callobj=call))
return l
def getcallargs(self, obj):
if not isinstance(obj, (tuple, list)):
obj = (obj,)
# explict naming
if isinstance(obj[0], py.builtin._basestring):
name = obj[0]
obj = obj[1:]
else:
name = None
call, args = obj[0], obj[1:]
return name, call, args
def hasinit(obj):
init = getattr(obj, '__init__', None)
if init:
if init != object.__init__:
return True
def fillfixtures(function):
""" fill missing funcargs for a test function. """
if 1 or getattr(function, "_args", None) is None: # not a yielded function
try:
request = function._request
except AttributeError:
# XXX this special code path is only expected to execute
# with the oejskit plugin. It uses classes with funcargs
# and we thus have to work a bit to allow this.
fm = function.session._fixturemanager
fi = fm.getfixtureinfo(function.parent, function.obj, None)
function._fixtureinfo = fi
request = function._request = FixtureRequest(function)
request._fillfixtures()
# prune out funcargs for jstests
newfuncargs = {}
for name in fi.argnames:
newfuncargs[name] = function.funcargs[name]
function.funcargs = newfuncargs
else:
request._fillfixtures()
_notexists = object()
class CallSpec2(object):
def __init__(self, metafunc):
self.metafunc = metafunc
self.funcargs = {}
self._idlist = []
self.params = {}
self._globalid = _notexists
self._globalid_args = set()
self._globalparam = _notexists
self._arg2scopenum = {} # used for sorting parametrized resources
self.keywords = {}
def copy(self, metafunc):
cs = CallSpec2(self.metafunc)
cs.funcargs.update(self.funcargs)
cs.params.update(self.params)
cs.keywords.update(self.keywords)
cs._arg2scopenum.update(self._arg2scopenum)
cs._idlist = list(self._idlist)
cs._globalid = self._globalid
cs._globalid_args = self._globalid_args
cs._globalparam = self._globalparam
return cs
def _checkargnotcontained(self, arg):
if arg in self.params or arg in self.funcargs:
raise ValueError("duplicate %r" %(arg,))
def getparam(self, name):
try:
return self.params[name]
except KeyError:
if self._globalparam is _notexists:
raise ValueError(name)
return self._globalparam
@property
def id(self):
return "-".join(map(str, filter(None, self._idlist)))
def setmulti(self, valtype, argnames, valset, id, keywords, scopenum=0):
for arg,val in zip(argnames, valset):
self._checkargnotcontained(arg)
getattr(self, valtype)[arg] = val
# we want self.params to be always set because of
# parametrize_sorted() which groups tests by params/scope
if valtype == "funcargs":
self.params[arg] = id
self._arg2scopenum[arg] = scopenum
if val is _notexists:
self._emptyparamspecified = True
self._idlist.append(id)
self.keywords.update(keywords)
def setall(self, funcargs, id, param):
for x in funcargs:
self._checkargnotcontained(x)
self.funcargs.update(funcargs)
if id is not _notexists:
self._idlist.append(id)
if param is not _notexists:
assert self._globalparam is _notexists
self._globalparam = param
class FuncargnamesCompatAttr:
""" helper class so that Metafunc, Function and FixtureRequest
don't need to each define the "funcargnames" compatibility attribute.
"""
@property
def funcargnames(self):
""" alias attribute for ``fixturenames`` for pre-2.3 compatibility"""
return self.fixturenames
class Metafunc(FuncargnamesCompatAttr):
def __init__(self, function, fixtureinfo, config, cls=None, module=None):
self.config = config
self.module = module
self.function = function
self.fixturenames = fixtureinfo.names_closure
self._arg2fixturedefs = fixtureinfo.name2fixturedefs
self.cls = cls
self.module = module
self._calls = []
self._ids = py.builtin.set()
def parametrize(self, argnames, argvalues, indirect=False, ids=None,
scope=None):
""" Add new invocations to the underlying test function using the list
of argvalues for the given argnames. Parametrization is performed
during the collection phase. If you need to setup expensive resources
see about setting indirect=True to do it rather at test setup time.
:arg argnames: a comma-separated string denoting one or more argument
names, or a list/tuple of argument strings.
:arg argvalues: The list of argvalues determines how often a
test is invoked with different argument values. If only one
argname was specified argvalues is a list of simple values. If N
argnames were specified, argvalues must be a list of N-tuples,
where each tuple-element specifies a value for its respective
argname.
:arg indirect: if True each argvalue corresponding to an argname will
be passed as request.param to its respective argname fixture
function so that it can perform more expensive setups during the
setup phase of a test rather than at collection time.
:arg ids: list of string ids each corresponding to the argvalues so
that they are part of the test id. If no ids are provided they will
be generated automatically from the argvalues.
:arg scope: if specified it denotes the scope of the parameters.
The scope is used for grouping tests by parameter instances.
It will also override any fixture-function defined scope, allowing
to set a dynamic scope using test context or configuration.
"""
# individual parametrized argument sets can be wrapped in a
# marker in which case we unwrap the values and apply the mark
# at Function init
newkeywords = {}
unwrapped_argvalues = []
for i, argval in enumerate(argvalues):
if isinstance(argval, MarkDecorator):
newmark = MarkDecorator(argval.markname,
argval.args[:-1], argval.kwargs)
newkeywords[i] = {newmark.markname: newmark}
argval = argval.args[-1]
unwrapped_argvalues.append(argval)
argvalues = unwrapped_argvalues
if not isinstance(argnames, (tuple, list)):
argnames = [x.strip() for x in argnames.split(",") if x.strip()]
if len(argnames) == 1:
argvalues = [(val,) for val in argvalues]
if not argvalues:
argvalues = [(_notexists,) * len(argnames)]
if scope is None:
scope = "subfunction"
scopenum = scopes.index(scope)
if not indirect:
#XXX should we also check for the opposite case?
for arg in argnames:
if arg not in self.fixturenames:
raise ValueError("%r uses no fixture %r" %(
self.function, arg))
valtype = indirect and "params" or "funcargs"
if ids and len(ids) != len(argvalues):
raise ValueError('%d tests specified with %d ids' %(
len(argvalues), len(ids)))
if not ids:
ids = idmaker(argnames, argvalues)
newcalls = []
for callspec in self._calls or [CallSpec2(self)]:
for i, valset in enumerate(argvalues):
assert len(valset) == len(argnames)
newcallspec = callspec.copy(self)
newcallspec.setmulti(valtype, argnames, valset, ids[i],
newkeywords.get(i, {}), scopenum)
newcalls.append(newcallspec)
self._calls = newcalls
def addcall(self, funcargs=None, id=_notexists, param=_notexists):
""" (deprecated, use parametrize) Add a new call to the underlying
test function during the collection phase of a test run. Note that
request.addcall() is called during the test collection phase prior and
independently to actual test execution. You should only use addcall()
if you need to specify multiple arguments of a test function.
:arg funcargs: argument keyword dictionary used when invoking
the test function.
:arg id: used for reporting and identification purposes. If you
don't supply an `id` an automatic unique id will be generated.
:arg param: a parameter which will be exposed to a later fixture function
invocation through the ``request.param`` attribute.
"""
assert funcargs is None or isinstance(funcargs, dict)
if funcargs is not None:
for name in funcargs:
if name not in self.fixturenames:
pytest.fail("funcarg %r not used in this function." % name)
else:
funcargs = {}
if id is None:
raise ValueError("id=None not allowed")
if id is _notexists:
id = len(self._calls)
id = str(id)
if id in self._ids:
raise ValueError("duplicate id %r" % id)
self._ids.add(id)
cs = CallSpec2(self)
cs.setall(funcargs, id, param)
self._calls.append(cs)
def idmaker(argnames, argvalues):
idlist = []
for valindex, valset in enumerate(argvalues):
this_id = []
for nameindex, val in enumerate(valset):
if not isinstance(val, (float, int, str, bool, NoneType)):
this_id.append(str(argnames[nameindex])+str(valindex))
else:
this_id.append(str(val))
idlist.append("-".join(this_id))
return idlist
def showfixtures(config):
from _pytest.main import wrap_session
return wrap_session(config, _showfixtures_main)
def _showfixtures_main(config, session):
session.perform_collect()
curdir = py.path.local()
if session.items:
nodeid = session.items[0].nodeid
else:
part = session._initialparts[0]
nodeid = "::".join(map(str, [curdir.bestrelpath(part[0])] + part[1:]))
nodeid.replace(session.fspath.sep, "/")
tw = py.io.TerminalWriter()
verbose = config.getvalue("verbose")
fm = session._fixturemanager
available = []
for argname in fm._arg2fixturedefs:
fixturedefs = fm.getfixturedefs(argname, nodeid)
assert fixturedefs is not None
if not fixturedefs:
continue
fixturedef = fixturedefs[-1]
loc = getlocation(fixturedef.func, curdir)
available.append((len(fixturedef.baseid),
fixturedef.func.__module__,
curdir.bestrelpath(loc),
fixturedef.argname, fixturedef))
available.sort()
currentmodule = None
for baseid, module, bestrel, argname, fixturedef in available:
if currentmodule != module:
if not module.startswith("_pytest."):
tw.line()
tw.sep("-", "fixtures defined from %s" %(module,))
currentmodule = module
if verbose <= 0 and argname[0] == "_":
continue
if verbose > 0:
funcargspec = "%s -- %s" %(argname, bestrel,)
else:
funcargspec = argname
tw.line(funcargspec, green=True)
loc = getlocation(fixturedef.func, curdir)
doc = fixturedef.func.__doc__ or ""
if doc:
for line in doc.split("\n"):
tw.line(" " + line.strip())
else:
tw.line(" %s: no docstring available" %(loc,),
red=True)
def getlocation(function, curdir):
import inspect
fn = py.path.local(inspect.getfile(function))
lineno = py.builtin._getcode(function).co_firstlineno
if fn.relto(curdir):
fn = fn.relto(curdir)
return "%s:%d" %(fn, lineno+1)
# builtin pytest.raises helper
def raises(ExpectedException, *args, **kwargs):
""" assert that a code block/function call raises @ExpectedException
and raise a failure exception otherwise.
This helper produces a ``py.code.ExceptionInfo()`` object.
If using Python 2.5 or above, you may use this function as a
context manager::
>>> with raises(ZeroDivisionError):
... 1/0
Or you can specify a callable by passing a to-be-called lambda::
>>> raises(ZeroDivisionError, lambda: 1/0)
<ExceptionInfo ...>
or you can specify an arbitrary callable with arguments::
>>> def f(x): return 1/x
...
>>> raises(ZeroDivisionError, f, 0)
<ExceptionInfo ...>
>>> raises(ZeroDivisionError, f, x=0)
<ExceptionInfo ...>
A third possibility is to use a string to be executed::
>>> raises(ZeroDivisionError, "f(0)")
<ExceptionInfo ...>
"""
__tracebackhide__ = True
if ExpectedException is AssertionError:
# we want to catch a AssertionError
# replace our subclass with the builtin one
# see https://bitbucket.org/hpk42/pytest/issue/176/pytestraises
from _pytest.assertion.util import BuiltinAssertionError as ExpectedException
if not args:
return RaisesContext(ExpectedException)
elif isinstance(args[0], str):
code, = args
assert isinstance(code, str)
frame = sys._getframe(1)
loc = frame.f_locals.copy()
loc.update(kwargs)
#print "raises frame scope: %r" % frame.f_locals
try:
code = py.code.Source(code).compile()
py.builtin.exec_(code, frame.f_globals, loc)
# XXX didn'T mean f_globals == f_locals something special?
# this is destroyed here ...
except ExpectedException:
return py.code.ExceptionInfo()
else:
func = args[0]
try:
func(*args[1:], **kwargs)
except ExpectedException:
return py.code.ExceptionInfo()
k = ", ".join(["%s=%r" % x for x in kwargs.items()])
if k:
k = ', ' + k
expr = '%s(%r%s)' %(getattr(func, '__name__', func), args, k)
pytest.fail("DID NOT RAISE")
class RaisesContext(object):
def __init__(self, ExpectedException):
self.ExpectedException = ExpectedException
self.excinfo = None
def __enter__(self):
self.excinfo = object.__new__(py.code.ExceptionInfo)
return self.excinfo
def __exit__(self, *tp):
__tracebackhide__ = True
if tp[0] is None:
pytest.fail("DID NOT RAISE")
self.excinfo.__init__(tp)
return issubclass(self.excinfo.type, self.ExpectedException)
#
# the basic py.test Function item
#
_dummy = object()
class Function(FunctionMixin, pytest.Item, FuncargnamesCompatAttr):
""" a Function Item is responsible for setting up and executing a
Python test function.
"""
_genid = None
def __init__(self, name, parent, args=None, config=None,
callspec=None, callobj=_dummy, keywords=None, session=None):
super(Function, self).__init__(name, parent, config=config,
session=session)
self._args = args
if callobj is not _dummy:
self.obj = callobj
for name, val in (py.builtin._getfuncdict(self.obj) or {}).items():
self.keywords[name] = val
if callspec:
for name, val in callspec.keywords.items():
self.keywords[name] = val
if keywords:
for name, val in keywords.items():
self.keywords[name] = val
fm = self.session._fixturemanager
isyield = self._isyieldedfunction()
self._fixtureinfo = fi = fm.getfixtureinfo(self.parent, self.obj,
self.cls,
funcargs=not isyield)
self.fixturenames = fi.names_closure
if callspec is not None:
self.callspec = callspec
self._initrequest()
def _initrequest(self):
if self._isyieldedfunction():
assert not hasattr(self, "callspec"), (
"yielded functions (deprecated) cannot have funcargs")
self.funcargs = {}
else:
if hasattr(self, "callspec"):
callspec = self.callspec
self.funcargs = callspec.funcargs.copy()
self._genid = callspec.id
if hasattr(callspec, "param"):
self.param = callspec.param
else:
self.funcargs = {}
self._request = FixtureRequest(self)
@property
def function(self):
"underlying python 'function' object"
return getattr(self.obj, 'im_func', self.obj)
def _getobj(self):
name = self.name
i = name.find("[") # parametrization
if i != -1:
name = name[:i]
return getattr(self.parent.obj, name)
@property
def _pyfuncitem(self):
"(compatonly) for code expecting pytest-2.2 style request objects"
return self
def _isyieldedfunction(self):
return getattr(self, "_args", None) is not None
def runtest(self):
""" execute the underlying test function. """
self.ihook.pytest_pyfunc_call(pyfuncitem=self)
def setup(self):
# check if parametrization happend with an empty list
try:
empty = self.callspec._emptyparamspecified
except AttributeError:
pass
else:
fs, lineno = self._getfslineno()
pytest.skip("got empty parameter set, function %s at %s:%d" %(
self.function.__name__, fs, lineno))
super(Function, self).setup()
fillfixtures(self)
def __eq__(self, other):
try:
return (self.name == other.name and
self._args == other._args and
self.parent == other.parent and
self.obj == other.obj and
getattr(self, '_genid', None) ==
getattr(other, '_genid', None)
)
except AttributeError:
pass
return False
def __ne__(self, other):
return not self == other
def __hash__(self):
return hash((self.parent, self.name))
scope2props = dict(session=())
scope2props["module"] = ("fspath", "module")
scope2props["class"] = scope2props["module"] + ("cls",)
scope2props["instance"] = scope2props["class"] + ("instance", )
scope2props["function"] = scope2props["instance"] + ("function", "keywords")
def scopeproperty(name=None, doc=None):
def decoratescope(func):
scopename = name or func.__name__
def provide(self):
if func.__name__ in scope2props[self.scope]:
return func(self)
raise AttributeError("%s not available in %s-scoped context" % (
scopename, self.scope))
return property(provide, None, None, func.__doc__)
return decoratescope
class FixtureRequest(FuncargnamesCompatAttr):
""" A request for a fixture from a test or fixture function.
A request object gives access to the requesting test context
and has an optional ``param`` attribute in case
the fixture is parametrized indirectly.
"""
def __init__(self, pyfuncitem):
self._pyfuncitem = pyfuncitem
if hasattr(pyfuncitem, '_requestparam'):
self.param = pyfuncitem._requestparam
#: fixture for which this request is being performed
self.fixturename = None
#: Scope string, one of "function", "cls", "module", "session"
self.scope = "function"
self.getparent = pyfuncitem.getparent
self._funcargs = self._pyfuncitem.funcargs.copy()
self._fixtureinfo = fi = pyfuncitem._fixtureinfo
self._arg2fixturedefs = fi.name2fixturedefs
self._arg2index = {}
self.fixturenames = self._fixtureinfo.names_closure
self._fixturemanager = pyfuncitem.session._fixturemanager
self._parentid = pyfuncitem.parent.nodeid
self._fixturestack = []
@property
def node(self):
""" underlying collection node (depends on current request scope)"""
return self._getscopeitem(self.scope)
def _getnextfixturedef(self, argname):
fixturedefs = self._arg2fixturedefs.get(argname, None)
if fixturedefs is None:
# we arrive here because of a getfuncargvalue(argname) usage which
# was naturally not knowable at parsing/collection time
fixturedefs = self._fixturemanager.getfixturedefs(
argname, self._parentid)
self._arg2fixturedefs[argname] = fixturedefs
# fixturedefs is immutable so we maintain a decreasing index
index = self._arg2index.get(argname, 0) - 1
if fixturedefs is None or (-index > len(fixturedefs)):
raise FixtureLookupError(argname, self)
self._arg2index[argname] = index
return fixturedefs[index]
@property
def config(self):
""" the pytest config object associated with this request. """
return self._pyfuncitem.config
@scopeproperty()
def function(self):
""" test function object if the request has a per-function scope. """
return self._pyfuncitem.obj
@scopeproperty("class")
def cls(self):
""" class (can be None) where the test function was collected. """
clscol = self._pyfuncitem.getparent(pytest.Class)
if clscol:
return clscol.obj
@property
def instance(self):
""" instance (can be None) on which test function was collected. """
# unittest support hack, see _pytest.unittest.TestCaseFunction
try:
return self._pyfuncitem._testcase
except AttributeError:
return py.builtin._getimself(self.function)
@scopeproperty()
def module(self):
""" python module object where the test function was collected. """
return self._pyfuncitem.getparent(pytest.Module).obj
@scopeproperty()
def fspath(self):
""" the file system path of the test module which collected this test. """
return self._pyfuncitem.fspath
@property
def keywords(self):
""" keywords/markers dictionary for the underlying node. """
return self.node.keywords
@property
def session(self):
""" pytest session object. """
return self._pyfuncitem.session
def addfinalizer(self, finalizer):
"""add finalizer/teardown function to be called after the
last test within the requesting test context finished
execution. """
# XXX usually this method is shadowed by fixturedef specific ones
self._addfinalizer(finalizer, scope=self.scope)
def _addfinalizer(self, finalizer, scope):
if scope != "function" and hasattr(self, "param"):
# parametrized resources are sorted by param
# so we rather store finalizers per (argname, param)
colitem = (self.fixturename, self.param)
else:
colitem = self._getscopeitem(scope)
self._pyfuncitem.session._setupstate.addfinalizer(
finalizer=finalizer, colitem=colitem)
def applymarker(self, marker):
""" Apply a marker to a single test function invocation.
This method is useful if you don't want to have a keyword/marker
on all function invocations.
:arg marker: a :py:class:`_pytest.mark.MarkDecorator` object
created by a call to ``py.test.mark.NAME(...)``.
"""
try:
self.node.keywords[marker.markname] = marker
except AttributeError:
raise ValueError(marker)
def raiseerror(self, msg):
""" raise a FixtureLookupError with the given message. """
raise self._fixturemanager.FixtureLookupError(None, self, msg)
def _fillfixtures(self):
item = self._pyfuncitem
fixturenames = getattr(item, "fixturenames", self.fixturenames)
for argname in fixturenames:
if argname not in item.funcargs:
item.funcargs[argname] = self.getfuncargvalue(argname)
def cached_setup(self, setup, teardown=None, scope="module", extrakey=None):
""" (deprecated) Return a testing resource managed by ``setup`` &
``teardown`` calls. ``scope`` and ``extrakey`` determine when the
``teardown`` function will be called so that subsequent calls to
``setup`` would recreate the resource. With pytest-2.3 you often
do not need ``cached_setup()`` as you can directly declare a scope
on a fixture function and register a finalizer through
``request.addfinalizer()``.
:arg teardown: function receiving a previously setup resource.
:arg setup: a no-argument function creating a resource.
:arg scope: a string value out of ``function``, ``class``, ``module``
or ``session`` indicating the caching lifecycle of the resource.
:arg extrakey: added to internal caching key of (funcargname, scope).
"""
if not hasattr(self.config, '_setupcache'):
self.config._setupcache = {} # XXX weakref?
cachekey = (self.fixturename, self._getscopeitem(scope), extrakey)
cache = self.config._setupcache
try:
val = cache[cachekey]
except KeyError:
__tracebackhide__ = True
if scopemismatch(self.scope, scope):
raise ScopeMismatchError("You tried to access a %r scoped "
"resource with a %r scoped request object" %(
(scope, self.scope)))
__tracebackhide__ = False
val = setup()
cache[cachekey] = val
if teardown is not None:
def finalizer():
del cache[cachekey]
teardown(val)
self._addfinalizer(finalizer, scope=scope)
return val
def getfuncargvalue(self, argname):
""" Dynamically retrieve a named fixture function argument.
As of pytest-2.3, it is easier and usually better to access other
fixture values by stating it as an input argument in the fixture
function. If you only can decide about using another fixture at test
setup time, you may use this function to retrieve it inside a fixture
function body.
"""
try:
return self._funcargs[argname]
except KeyError:
pass
try:
fixturedef = self._getnextfixturedef(argname)
except FixtureLookupError:
if argname == "request":
return self
raise
self._fixturestack.append(fixturedef)
try:
result = self._getfuncargvalue(fixturedef)
self._funcargs[argname] = result
return result
finally:
self._fixturestack.pop()
def _getfuncargvalue(self, fixturedef):
try:
return fixturedef.cached_result # set by fixturedef.execute()
except AttributeError:
pass
# prepare request fixturename and param attributes before
# calling into fixture function
argname = fixturedef.argname
node = self._pyfuncitem
mp = monkeypatch()
mp.setattr(self, 'fixturename', argname)
try:
param = node.callspec.getparam(argname)
except (AttributeError, ValueError):
pass
else:
mp.setattr(self, 'param', param, raising=False)
# if a parametrize invocation set a scope it will override
# the static scope defined with the fixture function
scope = fixturedef.scope
try:
paramscopenum = node.callspec._arg2scopenum[argname]
except (KeyError, AttributeError):
pass
else:
if paramscopenum != scopenum_subfunction:
scope = scopes[paramscopenum]
# check if a higher-level scoped fixture accesses a lower level one
if scope is not None:
__tracebackhide__ = True
if scopemismatch(self.scope, scope):
# try to report something helpful
lines = self._factorytraceback()
raise ScopeMismatchError("You tried to access the %r scoped "
"funcarg %r with a %r scoped request object, "
"involved factories\n%s" %(
(scope, argname, self.scope, "\n".join(lines))))
__tracebackhide__ = False
mp.setattr(self, "scope", scope)
# route request.addfinalizer to fixturedef
mp.setattr(self, "addfinalizer", fixturedef.addfinalizer)
try:
# perform the fixture call
val = fixturedef.execute(request=self)
finally:
# if the fixture function failed it might still have
# registered finalizers so we can register
# prepare finalization according to scope
# (XXX analyse exact finalizing mechanics / cleanup)
self.session._setupstate.addfinalizer(fixturedef.finish,
self.node)
self._fixturemanager.addargfinalizer(fixturedef.finish, argname)
for subargname in fixturedef.argnames: # XXX all deps?
self._fixturemanager.addargfinalizer(fixturedef.finish,
subargname)
mp.undo()
return val
def _factorytraceback(self):
lines = []
for fixturedef in self._fixturestack:
factory = fixturedef.func
fs, lineno = getfslineno(factory)
p = self._pyfuncitem.session.fspath.bestrelpath(fs)
args = inspect.formatargspec(*inspect.getargspec(factory))
lines.append("%s:%d: def %s%s" %(
p, lineno, factory.__name__, args))
return lines
def _getscopeitem(self, scope):
if scope == "function":
return self._pyfuncitem
elif scope == "session":
return self.session
elif scope == "class":
x = self._pyfuncitem.getparent(pytest.Class)
if x is not None:
return x
# fallback to function
return self._pyfuncitem
if scope == "module":
return self._pyfuncitem.getparent(pytest.Module)
raise ValueError("unknown finalization scope %r" %(scope,))
def __repr__(self):
return "<FixtureRequest for %r>" %(self.node)
class ScopeMismatchError(Exception):
""" A fixture function tries to use a different fixture function which
which has a lower scope (e.g. a Session one calls a function one)
"""
scopes = "session module class function subfunction".split()
scopenum_subfunction = scopes.index("subfunction")
def scopemismatch(currentscope, newscope):
return scopes.index(newscope) > scopes.index(currentscope)
class FixtureLookupError(LookupError):
""" could not return a requested Fixture (missing or invalid). """
def __init__(self, argname, request, msg=None):
self.argname = argname
self.request = request
self.fixturestack = list(request._fixturestack)
self.msg = msg
def formatrepr(self):
tblines = []
addline = tblines.append
stack = [self.request._pyfuncitem.obj]
stack.extend(map(lambda x: x.func, self.fixturestack))
msg = self.msg
if msg is not None:
stack = stack[:-1] # the last fixture raise an error, let's present
# it at the requesting side
for function in stack:
fspath, lineno = getfslineno(function)
lines, _ = inspect.getsourcelines(function)
addline("file %s, line %s" % (fspath, lineno+1))
for i, line in enumerate(lines):
line = line.rstrip()
addline(" " + line)
if line.lstrip().startswith('def'):
break
if msg is None:
fm = self.request._fixturemanager
nodeid = self.request._parentid
available = []
for name, fixturedef in fm._arg2fixturedefs.items():
faclist = list(fm._matchfactories(fixturedef, self.request._parentid))
if faclist:
available.append(name)
msg = "fixture %r not found" % (self.argname,)
msg += "\n available fixtures: %s" %(", ".join(available),)
msg += "\n use 'py.test --fixtures [testpath]' for help on them."
return FixtureLookupErrorRepr(fspath, lineno, tblines, msg, self.argname)
class FixtureLookupErrorRepr(TerminalRepr):
def __init__(self, filename, firstlineno, tblines, errorstring, argname):
self.tblines = tblines
self.errorstring = errorstring
self.filename = filename
self.firstlineno = firstlineno
self.argname = argname
def toterminal(self, tw):
#tw.line("FixtureLookupError: %s" %(self.argname), red=True)
for tbline in self.tblines:
tw.line(tbline.rstrip())
for line in self.errorstring.split("\n"):
tw.line(" " + line.strip(), red=True)
tw.line()
tw.line("%s:%d" % (self.filename, self.firstlineno+1))
class FixtureManager:
"""
pytest fixtures definitions and information is stored and managed
from this class.
During collection fm.parsefactories() is called multiple times to parse
fixture function definitions into FixtureDef objects and internal
data structures.
During collection of test functions, metafunc-mechanics instantiate
a FuncFixtureInfo object which is cached per node/func-name.
This FuncFixtureInfo object is later retrieved by Function nodes
which themselves offer a fixturenames attribute.
The FuncFixtureInfo object holds information about fixtures and FixtureDefs
relevant for a particular function. An initial list of fixtures is
assembled like this:
- ini-defined usefixtures
- autouse-marked fixtures along the collection chain up from the function
- usefixtures markers at module/class/function level
- test function funcargs
Subsequently the funcfixtureinfo.fixturenames attribute is computed
as the closure of the fixtures needed to setup the initial fixtures,
i. e. fixtures needed by fixture functions themselves are appended
to the fixturenames list.
Upon the test-setup phases all fixturenames are instantiated, retrieved
by a lookup of their FuncFixtureInfo.
"""
_argprefix = "pytest_funcarg__"
FixtureLookupError = FixtureLookupError
FixtureLookupErrorRepr = FixtureLookupErrorRepr
def __init__(self, session):
self.session = session
self.config = session.config
self._arg2fixturedefs = {}
self._seenplugins = set()
self._holderobjseen = set()
self._arg2finish = {}
self._nodeid_and_autousenames = [("", self.config.getini("usefixtures"))]
session.config.pluginmanager.register(self, "funcmanage")
self._nodename2fixtureinfo = {}
def getfixtureinfo(self, node, func, cls, funcargs=True):
key = (node, func.__name__)
try:
return self._nodename2fixtureinfo[key]
except KeyError:
pass
if funcargs and not hasattr(node, "nofuncargs"):
if cls is not None:
startindex = 1
else:
startindex = None
argnames = getfuncargnames(func, startindex)
else:
argnames = ()
usefixtures = getattr(func, "usefixtures", None)
initialnames = argnames
if usefixtures is not None:
initialnames = usefixtures.args + initialnames
fm = node.session._fixturemanager
names_closure, arg2fixturedefs = fm.getfixtureclosure(initialnames,
node)
fixtureinfo = FuncFixtureInfo(argnames, names_closure,
arg2fixturedefs)
self._nodename2fixtureinfo[key] = fixtureinfo
return fixtureinfo
### XXX this hook should be called for historic events like pytest_configure
### so that we don't have to do the below pytest_configure hook
def pytest_plugin_registered(self, plugin):
if plugin in self._seenplugins:
return
nodeid = None
try:
p = py.path.local(plugin.__file__)
except AttributeError:
pass
else:
if p.basename.startswith("conftest.py"):
nodeid = p.dirpath().relto(self.session.fspath)
if p.sep != "/":
nodeid = nodeid.replace(p.sep, "/")
self.parsefactories(plugin, nodeid)
self._seenplugins.add(plugin)
@pytest.mark.tryfirst
def pytest_configure(self, config):
plugins = config.pluginmanager.getplugins()
for plugin in plugins:
self.pytest_plugin_registered(plugin)
def _getautousenames(self, nodeid):
""" return a tuple of fixture names to be used. """
autousenames = []
for baseid, basenames in self._nodeid_and_autousenames:
if nodeid.startswith(baseid):
if baseid:
i = len(baseid)
nextchar = nodeid[i:i+1]
if nextchar and nextchar not in ":/":
continue
autousenames.extend(basenames)
# make sure autousenames are sorted by scope, scopenum 0 is session
autousenames.sort(
key=lambda x: self._arg2fixturedefs[x][-1].scopenum)
return autousenames
def getfixtureclosure(self, fixturenames, parentnode):
# collect the closure of all fixtures , starting with the given
# fixturenames as the initial set. As we have to visit all
# factory definitions anyway, we also return a arg2fixturedefs
# mapping so that the caller can reuse it and does not have
# to re-discover fixturedefs again for each fixturename
# (discovering matching fixtures for a given name/node is expensive)
parentid = parentnode.nodeid
fixturenames_closure = self._getautousenames(parentid)
def merge(otherlist):
for arg in otherlist:
if arg not in fixturenames_closure:
fixturenames_closure.append(arg)
merge(fixturenames)
arg2fixturedefs = {}
lastlen = -1
while lastlen != len(fixturenames_closure):
lastlen = len(fixturenames_closure)
for argname in fixturenames_closure:
if argname in arg2fixturedefs:
continue
fixturedefs = self.getfixturedefs(argname, parentid)
arg2fixturedefs[argname] = fixturedefs
if fixturedefs is not None:
for fixturedef in fixturedefs:
merge(fixturedef.argnames)
return fixturenames_closure, arg2fixturedefs
def pytest_generate_tests(self, metafunc):
for argname in metafunc.fixturenames:
faclist = metafunc._arg2fixturedefs[argname]
if faclist is None:
continue # will raise FixtureLookupError at setup time
for fixturedef in faclist:
if fixturedef.params is not None:
metafunc.parametrize(argname, fixturedef.params, indirect=True,
scope=fixturedef.scope)
def pytest_collection_modifyitems(self, items):
# separate parametrized setups
items[:] = parametrize_sorted(items, set(), {}, 0)
def pytest_runtest_teardown(self, item, nextitem):
# XXX teardown needs to be normalized for parametrized and
# no-parametrized functions
try:
cs1 = item.callspec
except AttributeError:
return
# determine which fixtures are not needed anymore for the next test
keylist = []
for name in cs1.params:
try:
if name in nextitem.callspec.params and \
cs1.params[name] == nextitem.callspec.params[name]:
continue
except AttributeError:
pass
key = (-cs1._arg2scopenum[name], name, cs1.params[name])
keylist.append(key)
# sort by scope (function scope first, then higher ones)
keylist.sort()
for (scopenum, name, param) in keylist:
item.session._setupstate._callfinalizers((name, param))
l = self._arg2finish.pop(name, None)
if l is not None:
for fin in reversed(l):
fin()
def parsefactories(self, node_or_obj, nodeid=_dummy, unittest=False):
if nodeid is not _dummy:
holderobj = node_or_obj
else:
holderobj = node_or_obj.obj
nodeid = node_or_obj.nodeid
if holderobj in self._holderobjseen:
return
self._holderobjseen.add(holderobj)
autousenames = []
for name in dir(holderobj):
obj = getattr(holderobj, name, None)
if not callable(obj):
continue
# fixture functions have a pytest_funcarg__ prefix (pre-2.3 style)
# or are "@pytest.fixture" marked
marker = getfixturemarker(obj)
if marker is None:
if not name.startswith(self._argprefix):
continue
marker = defaultfuncargprefixmarker
name = name[len(self._argprefix):]
elif not isinstance(marker, FixtureFunctionMarker):
# magic globals with __getattr__ might have got us a wrong
# fixture attribute
continue
else:
assert not name.startswith(self._argprefix)
fixturedef = FixtureDef(self, nodeid, name, obj,
marker.scope, marker.params,
yieldctx=marker.yieldctx,
unittest=unittest)
faclist = self._arg2fixturedefs.setdefault(name, [])
if not fixturedef.has_location:
# All fixturedefs with no location are at the front
# so this inserts the current fixturedef after the
# existing fixturedefs from external plugins but
# before the fixturedefs provided in conftests.
i = len([f for f in faclist if not f.has_location])
else:
i = len(faclist) # append
faclist.insert(i, fixturedef)
if marker.autouse:
autousenames.append(name)
if autousenames:
self._nodeid_and_autousenames.append((nodeid or '', autousenames))
def getfixturedefs(self, argname, nodeid):
try:
fixturedefs = self._arg2fixturedefs[argname]
except KeyError:
return None
else:
return tuple(self._matchfactories(fixturedefs, nodeid))
def _matchfactories(self, fixturedefs, nodeid):
for fixturedef in fixturedefs:
if nodeid.startswith(fixturedef.baseid):
yield fixturedef
def addargfinalizer(self, finalizer, argname):
l = self._arg2finish.setdefault(argname, [])
l.append(finalizer)
def removefinalizer(self, finalizer):
for l in self._arg2finish.values():
try:
l.remove(finalizer)
except ValueError:
pass
def fail_fixturefunc(fixturefunc, msg):
fs, lineno = getfslineno(fixturefunc)
location = "%s:%s" % (fs, lineno+1)
source = py.code.Source(fixturefunc)
pytest.fail(msg + ":\n\n" + str(source.indent()) + "\n" + location,
pytrace=False)
def call_fixture_func(fixturefunc, request, kwargs, yieldctx):
if yieldctx:
if not is_generator(fixturefunc):
fail_fixturefunc(fixturefunc,
msg="yield_fixture requires yield statement in function")
iter = fixturefunc(**kwargs)
next = getattr(iter, "__next__", None)
if next is None:
next = getattr(iter, "next")
res = next()
def teardown():
try:
next()
except StopIteration:
pass
else:
fail_fixturefunc(fixturefunc,
"yield_fixture function has more than one 'yield'")
request.addfinalizer(teardown)
else:
if is_generator(fixturefunc):
fail_fixturefunc(fixturefunc,
msg="pytest.fixture functions cannot use ``yield``. "
"Instead write and return an inner function/generator "
"and let the consumer call and iterate over it.")
res = fixturefunc(**kwargs)
return res
class FixtureDef:
""" A container for a factory definition. """
def __init__(self, fixturemanager, baseid, argname, func, scope, params,
yieldctx, unittest=False):
self._fixturemanager = fixturemanager
self.baseid = baseid or ''
self.has_location = baseid is not None
self.func = func
self.argname = argname
self.scope = scope
self.scopenum = scopes.index(scope or "function")
self.params = params
startindex = unittest and 1 or None
self.argnames = getfuncargnames(func, startindex=startindex)
self.yieldctx = yieldctx
self.unittest = unittest
self._finalizer = []
def addfinalizer(self, finalizer):
self._finalizer.append(finalizer)
def finish(self):
while self._finalizer:
func = self._finalizer.pop()
func()
# check neccesity of next commented call
self._fixturemanager.removefinalizer(self.finish)
#print "finished", self
try:
del self.cached_result
except AttributeError:
pass
def execute(self, request):
kwargs = {}
for newname in self.argnames:
kwargs[newname] = request.getfuncargvalue(newname)
if self.unittest:
result = self.func(request.instance, **kwargs)
else:
fixturefunc = self.func
# the fixture function needs to be bound to the actual
# request.instance so that code working with "self" behaves
# as expected. XXX request.instance should maybe return None
# instead of raising AttributeError
try:
if request.instance is not None:
fixturefunc = getimfunc(self.func)
if fixturefunc != self.func:
fixturefunc = fixturefunc.__get__(request.instance)
except AttributeError:
pass
result = call_fixture_func(fixturefunc, request, kwargs,
self.yieldctx)
assert not hasattr(self, "cached_result")
self.cached_result = result
return result
def __repr__(self):
return ("<FixtureDef name=%r scope=%r baseid=%r module=%r>" %
(self.argname, self.scope, self.baseid, self.func.__module__))
def getfuncargnames(function, startindex=None):
# XXX merge with main.py's varnames
#assert not inspect.isclass(function)
realfunction = function
while hasattr(realfunction, "__wrapped__"):
realfunction = realfunction.__wrapped__
if startindex is None:
startindex = inspect.ismethod(function) and 1 or 0
if realfunction != function:
startindex += len(getattr(function, "patchings", []))
function = realfunction
argnames = inspect.getargs(py.code.getrawcode(function))[0]
defaults = getattr(function, 'func_defaults',
getattr(function, '__defaults__', None)) or ()
numdefaults = len(defaults)
if numdefaults:
return tuple(argnames[startindex:-numdefaults])
return tuple(argnames[startindex:])
# algorithm for sorting on a per-parametrized resource setup basis
def parametrize_sorted(items, ignore, cache, scopenum):
if scopenum >= 3:
return items
# we pick the first item which has a arg/param combo in the
# requested scope and sort other items with the same combo
# into "newitems" which then is a list of all items using this
# arg/param.
similar_items = []
other_items = []
slicing_argparam = None
slicing_index = 0
for item in items:
argparamlist = getfuncargparams(item, ignore, scopenum, cache)
if slicing_argparam is None and argparamlist:
slicing_argparam = argparamlist[0]
slicing_index = len(other_items)
if slicing_argparam in argparamlist:
similar_items.append(item)
else:
other_items.append(item)
if (len(similar_items) + slicing_index) > 1:
newignore = ignore.copy()
newignore.add(slicing_argparam)
part2 = parametrize_sorted(
similar_items + other_items[slicing_index:],
newignore, cache, scopenum)
part1 = parametrize_sorted(
other_items[:slicing_index], newignore,
cache, scopenum+1)
return part1 + part2
else:
other_items = parametrize_sorted(other_items, ignore, cache, scopenum+1)
return other_items + similar_items
def getfuncargparams(item, ignore, scopenum, cache):
""" return list of (arg,param) tuple, sorted by broader scope first. """
assert scopenum < 3 # function
try:
cs = item.callspec
except AttributeError:
return []
if scopenum == 0:
argparams = [x for x in cs.params.items() if x not in ignore
and cs._arg2scopenum[x[0]] == scopenum]
elif scopenum == 1: # module
argparams = []
for argname, param in cs.params.items():
if cs._arg2scopenum[argname] == scopenum:
key = (argname, param, item.fspath)
if key in ignore:
continue
argparams.append(key)
elif scopenum == 2: # class
argparams = []
for argname, param in cs.params.items():
if cs._arg2scopenum[argname] == scopenum:
l = cache.setdefault(item.fspath, [])
try:
i = l.index(item.cls)
except ValueError:
i = len(l)
l.append(item.cls)
key = (argname, param, item.fspath, i)
if key in ignore:
continue
argparams.append(key)
#elif scopenum == 3:
# argparams = []
# for argname, param in cs.params.items():
# if cs._arg2scopenum[argname] == scopenum:
# key = (argname, param, getfslineno(item.obj))
# if key in ignore:
# continue
# argparams.append(key)
return argparams
def xunitsetup(obj, name):
meth = getattr(obj, name, None)
if getfixturemarker(meth) is None:
return meth
def getfixturemarker(obj):
""" return fixturemarker or None if it doesn't exist or raised
exceptions."""
try:
return getattr(obj, "_pytestfixturefunction", None)
except KeyboardInterrupt:
raise
except Exception:
# some objects raise errors like request (from flask import request)
# we don't expect them to be fixture functions
return None
|
mit
|
[
624,
2018,
511,
13172,
12,
3272,
436,
1255,
402,
511,
3423,
14,
408,
199,
646,
1134,
199,
646,
6485,
199,
646,
984,
199,
646,
4613,
199,
504,
485,
4462,
14,
973,
492,
664,
2319,
3469,
199,
504,
485,
4462,
14,
1657,
492,
7173,
14946,
12,
7173,
2354,
199,
504,
485,
4462,
14,
20372,
2068,
492,
17309,
199,
504,
1134,
423,
600,
14,
600,
492,
20429,
279,
15713,
199,
199,
646,
485,
4462,
199,
5919,
694,
275,
1134,
14,
515,
14,
1832,
1547,
4462,
855,
493,
28634,
17254,
342,
199,
199,
26855,
275,
730,
8,
403,
9,
199,
199,
8296,
275,
1134,
14,
5351,
14,
8296,
199,
199,
318,
2312,
2906,
1532,
8,
1532,
304,
272,
862,
26,
267,
372,
2562,
855,
1532,
363,
272,
871,
4281,
26,
267,
862,
26,
288,
372,
2562,
14,
1017,
63,
1532,
267,
871,
4281,
26,
288,
372,
2562,
421,
199,
533,
31574,
4167,
3481,
12825,
26,
272,
347,
636,
826,
721,
277,
12,
4194,
12,
1862,
12,
6384,
7130,
29,
797,
12,
1995,
3799,
29,
797,
304,
267,
291,
14,
2645,
275,
4194,
267,
291,
14,
1162,
275,
1862,
267,
291,
14,
6898,
7130,
275,
6384,
7130,
267,
291,
14,
11481,
3799,
275,
1995,
3799,
339,
347,
636,
1250,
721,
277,
12,
805,
304,
267,
340,
6485,
14,
28450,
8,
1593,
304,
288,
746,
1722,
8,
490,
298,
533,
15188,
440,
3748,
334,
7551,
506,
315,
314,
6466,
6320,
267,
805,
423,
4462,
5997,
1593,
275,
291,
267,
372,
805,
421,
199,
318,
10949,
8,
2645,
628,
1593,
401,
1862,
29,
403,
12,
6384,
7130,
29,
797,
304,
272,
408,
334,
1107,
282,
9,
7531,
370,
2216,
282,
10949,
6434,
805,
14,
339,
961,
7531,
883,
506,
1202,
334,
1045,
503,
503,
1928,
2633,
9,
370,
5627,
272,
282,
10949,
805,
14,
221,
710,
536,
402,
314,
10949,
805,
883,
2945,
506,
272,
11812,
370,
7675,
2399,
19569,
23417,
402,
3879,
2295,
26,
511,
272,
4621,
503,
3992,
883,
675,
314,
4613,
14,
1657,
14,
1180,
8769,
8,
5997,
354,
9,
272,
3608,
14,
221,
1379,
3423,
883,
5370,
675,
10949,
1561,
465,
1324,
272,
2368,
315,
1314,
1930,
314,
10949,
1256,
2138,
687,
314,
10949,
272,
805,
911,
506,
26121,
14,
339,
520,
1273,
4194,
26,
314,
4194,
367,
1314,
642,
10949,
365,
5709,
12,
1373,
402,
355,
298,
1593,
2,
334,
885,
395,
298,
533,
401,
298,
578,
401,
298,
1730,
1674,
339,
520,
1273,
1862,
26,
376,
2716,
769,
402,
2633,
1314,
911,
7675,
3663,
355,
28202,
402,
314,
10949,
805,
436,
1006,
402,
314,
2295,
355,
1808,
652,
14,
339,
520,
1273,
6384,
7130,
26,
340,
715,
12,
314,
10949,
2562,
365,
22225,
367,
1006,
2295,
626,
355,
883,
1937,
652,
14,
221,
982,
756,
334,
1589,
849,
9,
2066,
376,
5027,
355,
3659,
365,
4346,
370,
15422,
314,
10949,
14,
339,
408,
272,
340,
4550,
8,
2645,
9,
436,
1862,
365,
488,
436,
6384,
7130,
508,
756,
26,
267,
327,
4125,
5509,
425,
267,
372,
31574,
4167,
3481,
12825,
8,
355,
298,
1593,
401,
1862,
12,
6384,
7130,
5130,
2645,
9,
272,
587,
26,
267,
372,
31574,
4167,
3481,
12825,
8,
2645,
12,
1862,
12,
6384,
7130,
9,
199,
199,
318,
1995,
63,
5997,
8,
2645,
628,
1593,
401,
1862,
29,
403,
12,
6384,
7130,
29,
797,
304,
272,
408,
334,
1107,
282,
9,
7531,
370,
2216,
282,
1995,
13,
5997,
6434,
805,
272,
334,
28722,
1309,
748,
680,
339,
961,
6181,
314,
2011,
2368,
465,
520,
647,
26,
1532,
1705,
4462,
14,
5997,
64,
1325,
272,
14292,
282,
10949,
805,
370,
675,
282,
1124,
11481,
1040,
3140,
402,
282,
1124,
1107,
1040,
272,
5164,
370,
5647,
282,
10949,
14,
221,
1666,
272,
1455,
921,
4462,
14,
1308,
15,
287,
15,
7410,
15,
11481,
5997,
14,
1360,
367,
1655,
2256,
14,
272,
408,
272,
340,
4550,
8,
2645,
9,
436,
1862,
365,
488,
436,
6384,
7130,
508,
756,
26,
267,
327,
4125,
5509,
425,
267,
372,
31574,
4167,
3481,
12825,
8,
355,
298,
1593,
401,
1862,
12,
6384,
7130,
12,
1995,
3799,
29,
549,
5130,
2645,
9,
272,
587,
26,
267,
372,
31574,
4167,
3481,
12825,
8,
2645,
12,
1862,
12,
6384,
7130,
12,
1995,
3799,
29,
549,
9,
199,
199,
885,
1532,
1273,
1861,
4211,
275,
10949,
342,
199,
199,
318,
1134,
1113,
63,
1829,
8,
354,
304,
272,
347,
664,
8,
277,
304,
267,
1031,
275,
291,
14,
362,
1708,
8,
5675,
8,
4462,
12,
536,
430,
267,
340,
1031,
365,
440,
488,
26,
288,
372,
1031,
14,
1113,
272,
1382,
275,
298,
1548,
450,
83,
909,
642,
1031,
1990,
13736,
687,
334,
2425,
506,
488,
17617,
450,
334,
881,
536,
14,
2325,
1062,
9,
272,
372,
3324,
8,
362,
12,
488,
12,
488,
12,
1382,
9,
421,
199,
318,
4613,
63,
525,
1422,
8,
2087,
304,
272,
1572,
275,
1798,
14,
362,
923,
480,
10706,
531,
272,
1572,
14,
525,
1422,
4517,
8769,
297,
2850,
1532,
589,
297,
2049,
1595,
628,
1617,
63,
2052,
401,
2053,
628,
2384,
8769,
401,
849,
29,
797,
12,
2049,
1720,
628,
2384,
2808,
15188,
12,
3355,
701,
3589,
7468,
554,
531,
272,
1798,
14,
525,
2730,
480,
1180,
8769,
401,
730,
628,
589,
401,
849,
6034,
267,
1720,
628,
513,
402,
849,
15188,
370,
506,
1202,
543,
642,
2199,
531,
272,
1798,
14,
525,
2730,
480,
1548,
63,
1725,
401,
730,
628,
589,
401,
267,
849,
7782,
396,
63,
4856,
647,
297,
6438,
63,
396,
14,
647,
659,
267,
1720,
628,
6463,
13,
2487,
570,
7970,
367,
2018,
511,
859,
13172,
531,
272,
1798,
14,
525,
2730,
480,
1548,
63,
2888,
401,
730,
628,
589,
401,
849,
15387,
774,
18529,
267,
1720,
628,
14124,
367,
2018,
511,
1021,
13172,
531,
272,
1798,
14,
525,
2730,
480,
1548,
63,
5777,
401,
730,
628,
589,
401,
849,
15387,
396,
18529,
267,
1720,
628,
14124,
367,
2018,
511,
805,
436,
1083,
13172,
531,
199,
199,
318,
4613,
63,
15612,
63,
973,
8,
888,
304,
272,
340,
1101,
14,
1422,
14,
2384,
8769,
26,
267,
2498,
8769,
8,
888,
9,
267,
372,
378,
421,
199,
318,
4613,
63,
4208,
63,
2219,
8,
2024,
1532,
304,
272,
862,
26
] |
[
2018,
511,
13172,
12,
3272,
436,
1255,
402,
511,
3423,
14,
408,
199,
646,
1134,
199,
646,
6485,
199,
646,
984,
199,
646,
4613,
199,
504,
485,
4462,
14,
973,
492,
664,
2319,
3469,
199,
504,
485,
4462,
14,
1657,
492,
7173,
14946,
12,
7173,
2354,
199,
504,
485,
4462,
14,
20372,
2068,
492,
17309,
199,
504,
1134,
423,
600,
14,
600,
492,
20429,
279,
15713,
199,
199,
646,
485,
4462,
199,
5919,
694,
275,
1134,
14,
515,
14,
1832,
1547,
4462,
855,
493,
28634,
17254,
342,
199,
199,
26855,
275,
730,
8,
403,
9,
199,
199,
8296,
275,
1134,
14,
5351,
14,
8296,
199,
199,
318,
2312,
2906,
1532,
8,
1532,
304,
272,
862,
26,
267,
372,
2562,
855,
1532,
363,
272,
871,
4281,
26,
267,
862,
26,
288,
372,
2562,
14,
1017,
63,
1532,
267,
871,
4281,
26,
288,
372,
2562,
421,
199,
533,
31574,
4167,
3481,
12825,
26,
272,
347,
636,
826,
721,
277,
12,
4194,
12,
1862,
12,
6384,
7130,
29,
797,
12,
1995,
3799,
29,
797,
304,
267,
291,
14,
2645,
275,
4194,
267,
291,
14,
1162,
275,
1862,
267,
291,
14,
6898,
7130,
275,
6384,
7130,
267,
291,
14,
11481,
3799,
275,
1995,
3799,
339,
347,
636,
1250,
721,
277,
12,
805,
304,
267,
340,
6485,
14,
28450,
8,
1593,
304,
288,
746,
1722,
8,
490,
298,
533,
15188,
440,
3748,
334,
7551,
506,
315,
314,
6466,
6320,
267,
805,
423,
4462,
5997,
1593,
275,
291,
267,
372,
805,
421,
199,
318,
10949,
8,
2645,
628,
1593,
401,
1862,
29,
403,
12,
6384,
7130,
29,
797,
304,
272,
408,
334,
1107,
282,
9,
7531,
370,
2216,
282,
10949,
6434,
805,
14,
339,
961,
7531,
883,
506,
1202,
334,
1045,
503,
503,
1928,
2633,
9,
370,
5627,
272,
282,
10949,
805,
14,
221,
710,
536,
402,
314,
10949,
805,
883,
2945,
506,
272,
11812,
370,
7675,
2399,
19569,
23417,
402,
3879,
2295,
26,
511,
272,
4621,
503,
3992,
883,
675,
314,
4613,
14,
1657,
14,
1180,
8769,
8,
5997,
354,
9,
272,
3608,
14,
221,
1379,
3423,
883,
5370,
675,
10949,
1561,
465,
1324,
272,
2368,
315,
1314,
1930,
314,
10949,
1256,
2138,
687,
314,
10949,
272,
805,
911,
506,
26121,
14,
339,
520,
1273,
4194,
26,
314,
4194,
367,
1314,
642,
10949,
365,
5709,
12,
1373,
402,
355,
298,
1593,
2,
334,
885,
395,
298,
533,
401,
298,
578,
401,
298,
1730,
1674,
339,
520,
1273,
1862,
26,
376,
2716,
769,
402,
2633,
1314,
911,
7675,
3663,
355,
28202,
402,
314,
10949,
805,
436,
1006,
402,
314,
2295,
355,
1808,
652,
14,
339,
520,
1273,
6384,
7130,
26,
340,
715,
12,
314,
10949,
2562,
365,
22225,
367,
1006,
2295,
626,
355,
883,
1937,
652,
14,
221,
982,
756,
334,
1589,
849,
9,
2066,
376,
5027,
355,
3659,
365,
4346,
370,
15422,
314,
10949,
14,
339,
408,
272,
340,
4550,
8,
2645,
9,
436,
1862,
365,
488,
436,
6384,
7130,
508,
756,
26,
267,
327,
4125,
5509,
425,
267,
372,
31574,
4167,
3481,
12825,
8,
355,
298,
1593,
401,
1862,
12,
6384,
7130,
5130,
2645,
9,
272,
587,
26,
267,
372,
31574,
4167,
3481,
12825,
8,
2645,
12,
1862,
12,
6384,
7130,
9,
199,
199,
318,
1995,
63,
5997,
8,
2645,
628,
1593,
401,
1862,
29,
403,
12,
6384,
7130,
29,
797,
304,
272,
408,
334,
1107,
282,
9,
7531,
370,
2216,
282,
1995,
13,
5997,
6434,
805,
272,
334,
28722,
1309,
748,
680,
339,
961,
6181,
314,
2011,
2368,
465,
520,
647,
26,
1532,
1705,
4462,
14,
5997,
64,
1325,
272,
14292,
282,
10949,
805,
370,
675,
282,
1124,
11481,
1040,
3140,
402,
282,
1124,
1107,
1040,
272,
5164,
370,
5647,
282,
10949,
14,
221,
1666,
272,
1455,
921,
4462,
14,
1308,
15,
287,
15,
7410,
15,
11481,
5997,
14,
1360,
367,
1655,
2256,
14,
272,
408,
272,
340,
4550,
8,
2645,
9,
436,
1862,
365,
488,
436,
6384,
7130,
508,
756,
26,
267,
327,
4125,
5509,
425,
267,
372,
31574,
4167,
3481,
12825,
8,
355,
298,
1593,
401,
1862,
12,
6384,
7130,
12,
1995,
3799,
29,
549,
5130,
2645,
9,
272,
587,
26,
267,
372,
31574,
4167,
3481,
12825,
8,
2645,
12,
1862,
12,
6384,
7130,
12,
1995,
3799,
29,
549,
9,
199,
199,
885,
1532,
1273,
1861,
4211,
275,
10949,
342,
199,
199,
318,
1134,
1113,
63,
1829,
8,
354,
304,
272,
347,
664,
8,
277,
304,
267,
1031,
275,
291,
14,
362,
1708,
8,
5675,
8,
4462,
12,
536,
430,
267,
340,
1031,
365,
440,
488,
26,
288,
372,
1031,
14,
1113,
272,
1382,
275,
298,
1548,
450,
83,
909,
642,
1031,
1990,
13736,
687,
334,
2425,
506,
488,
17617,
450,
334,
881,
536,
14,
2325,
1062,
9,
272,
372,
3324,
8,
362,
12,
488,
12,
488,
12,
1382,
9,
421,
199,
318,
4613,
63,
525,
1422,
8,
2087,
304,
272,
1572,
275,
1798,
14,
362,
923,
480,
10706,
531,
272,
1572,
14,
525,
1422,
4517,
8769,
297,
2850,
1532,
589,
297,
2049,
1595,
628,
1617,
63,
2052,
401,
2053,
628,
2384,
8769,
401,
849,
29,
797,
12,
2049,
1720,
628,
2384,
2808,
15188,
12,
3355,
701,
3589,
7468,
554,
531,
272,
1798,
14,
525,
2730,
480,
1180,
8769,
401,
730,
628,
589,
401,
849,
6034,
267,
1720,
628,
513,
402,
849,
15188,
370,
506,
1202,
543,
642,
2199,
531,
272,
1798,
14,
525,
2730,
480,
1548,
63,
1725,
401,
730,
628,
589,
401,
267,
849,
7782,
396,
63,
4856,
647,
297,
6438,
63,
396,
14,
647,
659,
267,
1720,
628,
6463,
13,
2487,
570,
7970,
367,
2018,
511,
859,
13172,
531,
272,
1798,
14,
525,
2730,
480,
1548,
63,
2888,
401,
730,
628,
589,
401,
849,
15387,
774,
18529,
267,
1720,
628,
14124,
367,
2018,
511,
1021,
13172,
531,
272,
1798,
14,
525,
2730,
480,
1548,
63,
5777,
401,
730,
628,
589,
401,
849,
15387,
396,
18529,
267,
1720,
628,
14124,
367,
2018,
511,
805,
436,
1083,
13172,
531,
199,
199,
318,
4613,
63,
15612,
63,
973,
8,
888,
304,
272,
340,
1101,
14,
1422,
14,
2384,
8769,
26,
267,
2498,
8769,
8,
888,
9,
267,
372,
378,
421,
199,
318,
4613,
63,
4208,
63,
2219,
8,
2024,
1532,
304,
272,
862,
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,
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
] |
jaryn/packstack
|
packstack/installer/setup_controller.py
|
7
|
5428
|
"""
Controller class is a SINGLETON which handles all groups, params, sequences,
steps and replaces the CONF dictionary.
"""
from .core.parameters import Group
from .core.sequences import Sequence
def steps_new_format(steplist):
# we have to duplicate title to name parameter and also only sigle
# function is allowed in new step
return [{'name': i['title'], 'title': i['title'],
'function': i['functions'][0]} for i in steplist]
class Controller(object):
__GROUPS=[]
__SEQUENCES=[]
__PLUGINS=[]
MESSAGES=[]
CONF={}
__single = None # the one, true Singleton ... for god's sake why ??? :)
def __new__(self, *args, **kwargs):
"""
Singleton implementation.
Will return __single if self is the same class as the class of __single
which means that we will not invoke this singleton if someone tries to create a new
instance from a class which inherit Controller.
did not use isinstance because inheritence makes it behave erratically.
"""
if self != type(self.__single):
self.__single = object.__new__(self, *args, **kwargs)
return self.__single
def __init__(self):
# Resources that should be copied to each host along with the puppet
# files, on the remote host the file will be placed in
# $PACKSTACK_VAR_DIR/resources. This controller should copy the files,
# for now the puppet plugin is doing it format
# {'host':[('/path/to/fileordirectory', 'filenameonremotehost'), ..]}
self.resources = {}
def addResource(self, host, localpath, remotename):
""" Populates self.resources """
current_value_for_host = self.resources.get(host, [])
current_value_for_host.append((localpath,remotename))
self.resources[host] = current_value_for_host
# PLugins
def addPlugin(self, plugObj):
self.__PLUGINS.append(plugObj)
def getPluginByName(self, pluginName):
for plugin in self.__PLUGINS:
if plugin.__name__ == pluginName:
return plugin
return None
def getAllPlugins(self):
return self.__PLUGINS
# Sequences and steps
def addSequence(self, desc, cond, cond_match, steps):
self.__SEQUENCES.append(Sequence(desc, steps_new_format(steps),
condition=cond,
cond_match=cond_match))
def insertSequence(self, desc, cond, cond_match, steps, index=0):
self.__SEQUENCES.insert(index, Sequence(desc,
steps_new_format(steps),
condition=cond,
cond_match=cond_match))
def getAllSequences(self):
return self.__SEQUENCES
def runAllSequences(self):
for sequence in self.__SEQUENCES:
sequence.run(self.CONF)
def getSequenceByDesc(self, desc):
for sequence in self.getAllSequences():
if sequence.name == desc:
return sequence
return None
def __getSequenceIndexByDesc(self, desc):
for sequence in self.getAllSequences():
if sequence.name == desc:
return self.__SEQUENCES.index(sequence)
return None
def insertSequenceBeforeSequence(self, sequenceName, desc, cond, cond_match, steps):
"""
Insert a sequence before a named sequence.
i.e. if the specified sequence name is "update x", the new
sequence will be inserted BEFORE "update x"
"""
index = self.__getSequenceIndexByDesc(sequenceName)
if index == None:
index = len(self.getAllSequences())
self.__SEQUENCES.insert(index, Sequence(desc,
steps_new_format(steps),
condition=cond,
cond_match=cond_match))
# Groups and params
def addGroup(self, group, params):
self.__GROUPS.append(Group(group, params))
def getGroupByName(self, groupName):
for group in self.getAllGroups():
if group.GROUP_NAME == groupName:
return group
return None
def getAllGroups(self):
return self.__GROUPS
def __getGroupIndexByDesc(self, name):
for group in self.getAllGroups():
if group.GROUP_NAME == name:
return self.__GROUPS.index(group)
return None
def insertGroupBeforeGroup(self, groupName, group, params):
"""
Insert a group before a named group.
i.e. if the specified group name is "update x", the new
group will be inserted BEFORE "update x"
"""
index = self.__getGroupIndexByDesc(groupName)
if index == None:
index = len(self.getAllGroups())
self.__GROUPS.insert(index, Group(group, params))
def getParamByName(self, paramName):
for group in self.getAllGroups():
if paramName in group.parameters:
return group.parameters[paramName]
return None
def getParamKeyValue(self, paramName, keyName):
param = self.getParamByName(paramName)
if param:
return getattr(param, keyName)
else:
return None
|
apache-2.0
|
[
624,
199,
7506,
1021,
365,
282,
428,
1206,
44,
775,
615,
1314,
10022,
1006,
4652,
12,
1862,
12,
8013,
12,
199,
5895,
436,
19058,
314,
6392,
2600,
14,
199,
624,
199,
504,
1275,
1018,
14,
3214,
492,
5611,
199,
504,
1275,
1018,
14,
13436,
492,
10975,
421,
199,
318,
7124,
63,
1222,
63,
908,
8,
2926,
513,
304,
272,
327,
781,
1172,
370,
9250,
2538,
370,
536,
2725,
436,
2597,
1454,
5259,
274,
272,
327,
805,
365,
4370,
315,
892,
3650,
272,
372,
9016,
354,
356,
284,
459,
1213,
995,
283,
1213,
356,
284,
459,
1213,
995,
1467,
283,
1593,
356,
284,
459,
5777,
3488,
16,
9420,
367,
284,
315,
3650,
513,
61,
421,
199,
533,
16282,
8,
785,
304,
339,
636,
27544,
9811,
272,
636,
7326,
22243,
9811,
272,
636,
16483,
10789,
9811,
272,
603,
1608,
5383,
9811,
272,
6392,
7622,
339,
636,
4780,
275,
488,
327,
314,
1373,
12,
2549,
13050,
1860,
2263,
367,
486,
364,
1159,
308,
1728,
10842,
5805,
10674,
32428,
339,
347,
636,
1222,
721,
277,
12,
627,
589,
12,
1011,
958,
304,
267,
408,
267,
13050,
1860,
4514,
14,
267,
12823,
372,
636,
4780,
340,
291,
365,
314,
2011,
1021,
465,
314,
1021,
402,
636,
4780,
267,
1314,
4910,
626,
781,
911,
440,
12677,
642,
19768,
340,
17122,
11275,
370,
1218,
282,
892,
267,
1256,
687,
282,
1021,
1314,
8287,
16282,
14,
267,
8103,
440,
675,
1228,
2952,
315,
2523,
73,
6692,
7704,
652,
24062,
9266,
345,
17269,
14,
267,
408,
267,
340,
291,
1137,
730,
8,
277,
855,
4780,
304,
288,
291,
855,
4780,
275,
909,
855,
1222,
721,
277,
12,
627,
589,
12,
1011,
958,
9,
267,
372,
291,
855,
4780,
339,
347,
636,
826,
721,
277,
304,
267,
327,
26250,
626,
1077,
506,
8876,
370,
1924,
1591,
3180,
543,
314,
299,
17934,
267,
327,
1584,
12,
641,
314,
3982,
1591,
314,
570,
911,
506,
15090,
315,
267,
327,
2672,
6961,
17014,
63,
5568,
63,
3022,
15,
4435,
14,
961,
7614,
1077,
1331,
314,
1584,
12,
267,
327,
367,
3063,
314,
299,
17934,
3589,
365,
9689,
652,
1475,
267,
327,
791,
1102,
15211,
2336,
515,
15,
475,
15,
493,
269,
3619,
297,
283,
1501,
265,
3846,
1102,
659,
2508,
9420,
267,
291,
14,
4435,
275,
1052,
2378,
347,
1050,
4031,
8,
277,
12,
1591,
12,
2257,
515,
12,
3982,
354,
304,
267,
408,
13244,
15409,
291,
14,
4435,
408,
267,
1453,
63,
585,
63,
509,
63,
1102,
275,
291,
14,
4435,
14,
362,
8,
1102,
12,
3073,
267,
1453,
63,
585,
63,
509,
63,
1102,
14,
740,
1332,
1832,
515,
12,
3846,
354,
430,
267,
291,
14,
4435,
59,
1102,
61,
275,
1453,
63,
585,
63,
509,
63,
1102,
2378,
327,
10092,
1632,
83,
272,
347,
1050,
5061,
8,
277,
12,
14202,
5665,
304,
267,
291,
855,
16483,
10789,
14,
740,
8,
13963,
5665,
9,
339,
347,
664,
5061,
11190,
8,
277,
12,
3589,
985,
304,
267,
367,
3589,
315,
291,
855,
16483,
10789,
26,
288,
340,
3589,
855,
354,
363,
508,
3589,
985,
26,
355,
372,
3589,
267,
372,
488,
339,
347,
664,
2422,
19330,
8,
277,
304,
267,
372,
291,
855,
16483,
10789,
339,
327,
3240,
6227,
436,
7124,
272,
347,
1050,
5826,
8,
277,
12,
4328,
12,
9288,
12,
9288,
63,
1431,
12,
7124,
304,
267,
291,
855,
7326,
22243,
14,
740,
8,
5826,
8,
3257,
12,
7124,
63,
1222,
63,
908,
8,
5895,
395,
1460,
5558,
29,
2067,
12,
1460,
9288,
63,
1431,
29,
2067,
63,
1431,
430,
339,
347,
5518,
5826,
8,
277,
12,
4328,
12,
9288,
12,
9288,
63,
1431,
12,
7124,
12,
1478,
29,
16,
304,
267,
291,
855,
7326,
22243,
14,
3176,
8,
1080,
12,
10975,
8,
3257,
12,
6059,
7124,
63,
1222,
63,
908,
8,
5895,
395,
6059,
5558,
29,
2067,
12,
6059,
9288,
63,
1431,
29,
2067,
63,
1431,
430,
339,
347,
664,
2422,
1513,
6227,
8,
277,
304,
267,
372,
291,
855,
7326,
22243,
339,
347,
1255,
2422,
1513,
6227,
8,
277,
304,
267,
367,
3414,
315,
291,
855,
7326,
22243,
26,
288,
3414,
14,
1065,
8,
277,
14,
3103,
9,
339,
347,
664,
5826,
2175,
9921,
8,
277,
12,
4328,
304,
267,
367,
3414,
315,
291,
14,
31359,
1513,
6227,
837,
288,
340,
3414,
14,
354,
508,
4328,
26,
355,
372,
3414,
267,
372,
488,
339,
347,
636,
362,
5826,
2681,
2175,
9921,
8,
277,
12,
4328,
304,
267,
367,
3414,
315,
291,
14,
31359,
1513,
6227,
837,
288,
340,
3414,
14,
354,
508,
4328,
26,
355,
372,
291,
855,
7326,
22243,
14,
1080,
8,
4041,
9,
267,
372,
488,
339,
347,
5518,
5826,
13569,
5826,
8,
277,
12,
3414,
985,
12,
4328,
12,
9288,
12,
9288,
63,
1431,
12,
7124,
304,
267,
408,
267,
15496,
282,
3414,
2544,
282,
4310,
3414,
14,
267,
284,
14,
69,
14,
340,
314,
2013,
3414,
536,
365,
298,
873,
671,
401,
314,
892,
267,
3414,
911,
506,
11788,
6262,
18155,
298,
873,
671,
2,
267,
408,
267,
1478,
275,
291,
855,
362,
5826,
2681,
2175,
9921,
8,
4041,
985,
9,
267,
340,
1478,
508,
488,
26,
288,
1478,
275,
822,
8,
277,
14,
31359,
1513,
6227,
1012,
267,
291,
855,
7326,
22243,
14,
3176,
8,
1080,
12,
10975,
8,
3257,
12,
6059,
7124,
63,
1222,
63,
908,
8,
5895,
395,
6059,
5558,
29,
2067,
12,
6059,
9288,
63,
1431,
29,
2067,
63,
1431,
430,
339,
327,
25031,
436,
1862,
272,
347,
1050,
2448,
8,
277,
12,
1572,
12,
1862,
304,
267,
291,
855,
27544,
14,
740,
8,
2448,
8,
923,
12,
1862,
430,
339,
347,
664,
2448,
11190,
8,
277,
12,
1572,
985,
304,
267,
367,
1572,
315,
291,
14,
31359,
10177,
837,
288,
340,
1572,
14,
7823,
63,
2339,
508,
1572,
985,
26,
355,
372,
1572,
267,
372,
488,
339,
347,
664,
2422,
10177,
8,
277,
304,
267,
372,
291,
855,
27544,
339,
347,
636,
362,
2448,
2681,
2175,
9921,
8,
277,
12,
536,
304,
267,
367,
1572,
315,
291,
14,
31359,
10177,
837,
288,
340,
1572,
14,
7823,
63,
2339,
508,
536,
26,
355,
372,
291,
855,
27544,
14,
1080,
8,
923,
9,
267,
372,
488,
339,
347,
5518,
2448,
13569,
2448,
8,
277,
12
] |
[
199,
7506,
1021,
365,
282,
428,
1206,
44,
775,
615,
1314,
10022,
1006,
4652,
12,
1862,
12,
8013,
12,
199,
5895,
436,
19058,
314,
6392,
2600,
14,
199,
624,
199,
504,
1275,
1018,
14,
3214,
492,
5611,
199,
504,
1275,
1018,
14,
13436,
492,
10975,
421,
199,
318,
7124,
63,
1222,
63,
908,
8,
2926,
513,
304,
272,
327,
781,
1172,
370,
9250,
2538,
370,
536,
2725,
436,
2597,
1454,
5259,
274,
272,
327,
805,
365,
4370,
315,
892,
3650,
272,
372,
9016,
354,
356,
284,
459,
1213,
995,
283,
1213,
356,
284,
459,
1213,
995,
1467,
283,
1593,
356,
284,
459,
5777,
3488,
16,
9420,
367,
284,
315,
3650,
513,
61,
421,
199,
533,
16282,
8,
785,
304,
339,
636,
27544,
9811,
272,
636,
7326,
22243,
9811,
272,
636,
16483,
10789,
9811,
272,
603,
1608,
5383,
9811,
272,
6392,
7622,
339,
636,
4780,
275,
488,
327,
314,
1373,
12,
2549,
13050,
1860,
2263,
367,
486,
364,
1159,
308,
1728,
10842,
5805,
10674,
32428,
339,
347,
636,
1222,
721,
277,
12,
627,
589,
12,
1011,
958,
304,
267,
408,
267,
13050,
1860,
4514,
14,
267,
12823,
372,
636,
4780,
340,
291,
365,
314,
2011,
1021,
465,
314,
1021,
402,
636,
4780,
267,
1314,
4910,
626,
781,
911,
440,
12677,
642,
19768,
340,
17122,
11275,
370,
1218,
282,
892,
267,
1256,
687,
282,
1021,
1314,
8287,
16282,
14,
267,
8103,
440,
675,
1228,
2952,
315,
2523,
73,
6692,
7704,
652,
24062,
9266,
345,
17269,
14,
267,
408,
267,
340,
291,
1137,
730,
8,
277,
855,
4780,
304,
288,
291,
855,
4780,
275,
909,
855,
1222,
721,
277,
12,
627,
589,
12,
1011,
958,
9,
267,
372,
291,
855,
4780,
339,
347,
636,
826,
721,
277,
304,
267,
327,
26250,
626,
1077,
506,
8876,
370,
1924,
1591,
3180,
543,
314,
299,
17934,
267,
327,
1584,
12,
641,
314,
3982,
1591,
314,
570,
911,
506,
15090,
315,
267,
327,
2672,
6961,
17014,
63,
5568,
63,
3022,
15,
4435,
14,
961,
7614,
1077,
1331,
314,
1584,
12,
267,
327,
367,
3063,
314,
299,
17934,
3589,
365,
9689,
652,
1475,
267,
327,
791,
1102,
15211,
2336,
515,
15,
475,
15,
493,
269,
3619,
297,
283,
1501,
265,
3846,
1102,
659,
2508,
9420,
267,
291,
14,
4435,
275,
1052,
2378,
347,
1050,
4031,
8,
277,
12,
1591,
12,
2257,
515,
12,
3982,
354,
304,
267,
408,
13244,
15409,
291,
14,
4435,
408,
267,
1453,
63,
585,
63,
509,
63,
1102,
275,
291,
14,
4435,
14,
362,
8,
1102,
12,
3073,
267,
1453,
63,
585,
63,
509,
63,
1102,
14,
740,
1332,
1832,
515,
12,
3846,
354,
430,
267,
291,
14,
4435,
59,
1102,
61,
275,
1453,
63,
585,
63,
509,
63,
1102,
2378,
327,
10092,
1632,
83,
272,
347,
1050,
5061,
8,
277,
12,
14202,
5665,
304,
267,
291,
855,
16483,
10789,
14,
740,
8,
13963,
5665,
9,
339,
347,
664,
5061,
11190,
8,
277,
12,
3589,
985,
304,
267,
367,
3589,
315,
291,
855,
16483,
10789,
26,
288,
340,
3589,
855,
354,
363,
508,
3589,
985,
26,
355,
372,
3589,
267,
372,
488,
339,
347,
664,
2422,
19330,
8,
277,
304,
267,
372,
291,
855,
16483,
10789,
339,
327,
3240,
6227,
436,
7124,
272,
347,
1050,
5826,
8,
277,
12,
4328,
12,
9288,
12,
9288,
63,
1431,
12,
7124,
304,
267,
291,
855,
7326,
22243,
14,
740,
8,
5826,
8,
3257,
12,
7124,
63,
1222,
63,
908,
8,
5895,
395,
1460,
5558,
29,
2067,
12,
1460,
9288,
63,
1431,
29,
2067,
63,
1431,
430,
339,
347,
5518,
5826,
8,
277,
12,
4328,
12,
9288,
12,
9288,
63,
1431,
12,
7124,
12,
1478,
29,
16,
304,
267,
291,
855,
7326,
22243,
14,
3176,
8,
1080,
12,
10975,
8,
3257,
12,
6059,
7124,
63,
1222,
63,
908,
8,
5895,
395,
6059,
5558,
29,
2067,
12,
6059,
9288,
63,
1431,
29,
2067,
63,
1431,
430,
339,
347,
664,
2422,
1513,
6227,
8,
277,
304,
267,
372,
291,
855,
7326,
22243,
339,
347,
1255,
2422,
1513,
6227,
8,
277,
304,
267,
367,
3414,
315,
291,
855,
7326,
22243,
26,
288,
3414,
14,
1065,
8,
277,
14,
3103,
9,
339,
347,
664,
5826,
2175,
9921,
8,
277,
12,
4328,
304,
267,
367,
3414,
315,
291,
14,
31359,
1513,
6227,
837,
288,
340,
3414,
14,
354,
508,
4328,
26,
355,
372,
3414,
267,
372,
488,
339,
347,
636,
362,
5826,
2681,
2175,
9921,
8,
277,
12,
4328,
304,
267,
367,
3414,
315,
291,
14,
31359,
1513,
6227,
837,
288,
340,
3414,
14,
354,
508,
4328,
26,
355,
372,
291,
855,
7326,
22243,
14,
1080,
8,
4041,
9,
267,
372,
488,
339,
347,
5518,
5826,
13569,
5826,
8,
277,
12,
3414,
985,
12,
4328,
12,
9288,
12,
9288,
63,
1431,
12,
7124,
304,
267,
408,
267,
15496,
282,
3414,
2544,
282,
4310,
3414,
14,
267,
284,
14,
69,
14,
340,
314,
2013,
3414,
536,
365,
298,
873,
671,
401,
314,
892,
267,
3414,
911,
506,
11788,
6262,
18155,
298,
873,
671,
2,
267,
408,
267,
1478,
275,
291,
855,
362,
5826,
2681,
2175,
9921,
8,
4041,
985,
9,
267,
340,
1478,
508,
488,
26,
288,
1478,
275,
822,
8,
277,
14,
31359,
1513,
6227,
1012,
267,
291,
855,
7326,
22243,
14,
3176,
8,
1080,
12,
10975,
8,
3257,
12,
6059,
7124,
63,
1222,
63,
908,
8,
5895,
395,
6059,
5558,
29,
2067,
12,
6059,
9288,
63,
1431,
29,
2067,
63,
1431,
430,
339,
327,
25031,
436,
1862,
272,
347,
1050,
2448,
8,
277,
12,
1572,
12,
1862,
304,
267,
291,
855,
27544,
14,
740,
8,
2448,
8,
923,
12,
1862,
430,
339,
347,
664,
2448,
11190,
8,
277,
12,
1572,
985,
304,
267,
367,
1572,
315,
291,
14,
31359,
10177,
837,
288,
340,
1572,
14,
7823,
63,
2339,
508,
1572,
985,
26,
355,
372,
1572,
267,
372,
488,
339,
347,
664,
2422,
10177,
8,
277,
304,
267,
372,
291,
855,
27544,
339,
347,
636,
362,
2448,
2681,
2175,
9921,
8,
277,
12,
536,
304,
267,
367,
1572,
315,
291,
14,
31359,
10177,
837,
288,
340,
1572,
14,
7823,
63,
2339,
508,
536,
26,
355,
372,
291,
855,
27544,
14,
1080,
8,
923,
9,
267,
372,
488,
339,
347,
5518,
2448,
13569,
2448,
8,
277,
12,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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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
] |
fafaman/scrapy
|
tests/__init__.py
|
95
|
1154
|
"""
tests: this package contains all Scrapy unittests
see http://doc.scrapy.org/en/latest/contributing.html#running-tests
"""
import os
# ignore system-wide proxies for tests
# which would send requests to a totally unsuspecting server
# (e.g. because urllib does not fully understand the proxy spec)
os.environ['http_proxy'] = ''
os.environ['https_proxy'] = ''
os.environ['ftp_proxy'] = ''
# Absolutize paths to coverage config and output file because tests that
# spawn subprocesses also changes current working directory.
_sourceroot = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
if 'COV_CORE_CONFIG' in os.environ:
os.environ['COVERAGE_FILE'] = os.path.join(_sourceroot, '.coverage')
os.environ['COV_CORE_CONFIG'] = os.path.join(_sourceroot,
os.environ['COV_CORE_CONFIG'])
try:
import unittest.mock as mock
except ImportError:
import mock
tests_datadir = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'sample_data')
def get_testdata(*paths):
"""Return test data"""
path = os.path.join(tests_datadir, *paths)
return open(path, 'rb').read()
|
bsd-3-clause
|
[
624,
199,
2219,
26,
642,
2559,
3509,
1006,
13916,
345,
647,
2882,
83,
199,
199,
3239,
1455,
921,
1301,
14,
26442,
14,
1308,
15,
287,
15,
7410,
15,
2828,
4655,
14,
1360,
3,
5720,
13,
2219,
199,
624,
199,
199,
646,
747,
199,
199,
3,
3686,
2656,
13,
13062,
14942,
367,
2295,
199,
3,
1314,
3955,
3222,
4145,
370,
282,
12657,
1183,
625,
25253,
1764,
316,
1654,
199,
3,
334,
69,
14,
71,
14,
2952,
4011,
1630,
440,
9999,
20647,
314,
4566,
3158,
9,
199,
736,
14,
2314,
459,
1014,
63,
3280,
418,
275,
2125,
199,
736,
14,
2314,
459,
2859,
63,
3280,
418,
275,
2125,
199,
736,
14,
2314,
459,
8915,
63,
3280,
418,
275,
2125,
199,
199,
3,
20319,
393,
935,
806,
3792,
370,
11745,
1101,
436,
1072,
570,
2952,
2295,
626,
199,
3,
15187,
1007,
11816,
2597,
4493,
1453,
6449,
2082,
14,
199,
63,
83,
567,
2247,
26974,
275,
747,
14,
515,
14,
3475,
8,
736,
14,
515,
14,
3475,
8,
736,
14,
515,
14,
4832,
3460,
493,
29658,
199,
692,
283,
1439,
54,
63,
24428,
63,
5569,
7,
315,
747,
14,
2314,
26,
272,
747,
14,
2314,
459,
19052,
2962,
63,
3817,
418,
275,
747,
14,
515,
14,
904,
1547,
83,
567,
2247,
26974,
12,
1987,
10828,
358,
272,
747,
14,
2314,
459,
1439,
54,
63,
24428,
63,
5569,
418,
275,
747,
14,
515,
14,
904,
1547,
83,
567,
2247,
26974,
12,
1740,
747,
14,
2314,
459,
1439,
54,
63,
24428,
63,
5569,
1105,
199,
199,
893,
26,
272,
492,
2882,
14,
1805,
465,
1683,
199,
2590,
3545,
26,
272,
492,
1683,
199,
199,
2219,
63,
18259,
275,
747,
14,
515,
14,
904,
8,
736,
14,
515,
14,
4832,
8,
736,
14,
515,
14,
3475,
3460,
493,
22159,
283,
3271,
63,
576,
358,
199,
199,
318,
664,
63,
18481,
2031,
3771,
304,
272,
408,
1767,
511,
666,
624,
272,
931,
275,
747,
14,
515,
14,
904,
8,
2219,
63,
18259,
12,
627,
3771,
9,
272,
372,
1551,
8,
515,
12,
283,
4848,
1959,
739,
342,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
199,
2219,
26,
642,
2559,
3509,
1006,
13916,
345,
647,
2882,
83,
199,
199,
3239,
1455,
921,
1301,
14,
26442,
14,
1308,
15,
287,
15,
7410,
15,
2828,
4655,
14,
1360,
3,
5720,
13,
2219,
199,
624,
199,
199,
646,
747,
199,
199,
3,
3686,
2656,
13,
13062,
14942,
367,
2295,
199,
3,
1314,
3955,
3222,
4145,
370,
282,
12657,
1183,
625,
25253,
1764,
316,
1654,
199,
3,
334,
69,
14,
71,
14,
2952,
4011,
1630,
440,
9999,
20647,
314,
4566,
3158,
9,
199,
736,
14,
2314,
459,
1014,
63,
3280,
418,
275,
2125,
199,
736,
14,
2314,
459,
2859,
63,
3280,
418,
275,
2125,
199,
736,
14,
2314,
459,
8915,
63,
3280,
418,
275,
2125,
199,
199,
3,
20319,
393,
935,
806,
3792,
370,
11745,
1101,
436,
1072,
570,
2952,
2295,
626,
199,
3,
15187,
1007,
11816,
2597,
4493,
1453,
6449,
2082,
14,
199,
63,
83,
567,
2247,
26974,
275,
747,
14,
515,
14,
3475,
8,
736,
14,
515,
14,
3475,
8,
736,
14,
515,
14,
4832,
3460,
493,
29658,
199,
692,
283,
1439,
54,
63,
24428,
63,
5569,
7,
315,
747,
14,
2314,
26,
272,
747,
14,
2314,
459,
19052,
2962,
63,
3817,
418,
275,
747,
14,
515,
14,
904,
1547,
83,
567,
2247,
26974,
12,
1987,
10828,
358,
272,
747,
14,
2314,
459,
1439,
54,
63,
24428,
63,
5569,
418,
275,
747,
14,
515,
14,
904,
1547,
83,
567,
2247,
26974,
12,
1740,
747,
14,
2314,
459,
1439,
54,
63,
24428,
63,
5569,
1105,
199,
199,
893,
26,
272,
492,
2882,
14,
1805,
465,
1683,
199,
2590,
3545,
26,
272,
492,
1683,
199,
199,
2219,
63,
18259,
275,
747,
14,
515,
14,
904,
8,
736,
14,
515,
14,
4832,
8,
736,
14,
515,
14,
3475,
3460,
493,
22159,
283,
3271,
63,
576,
358,
199,
199,
318,
664,
63,
18481,
2031,
3771,
304,
272,
408,
1767,
511,
666,
624,
272,
931,
275,
747,
14,
515,
14,
904,
8,
2219,
63,
18259,
12,
627,
3771,
9,
272,
372,
1551,
8,
515,
12,
283,
4848,
1959,
739,
342,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1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
dmitriy0611/django
|
tests/sitemaps_tests/test_http.py
|
46
|
10727
|
from __future__ import unicode_literals
import os
from datetime import date
from unittest import skipUnless
from django.apps import apps
from django.conf import settings
from django.contrib.sitemaps import GenericSitemap, Sitemap
from django.contrib.sites.models import Site
from django.core.exceptions import ImproperlyConfigured
from django.test import ignore_warnings, modify_settings, override_settings
from django.utils._os import upath
from django.utils.deprecation import RemovedInDjango20Warning
from django.utils.formats import localize
from django.utils.translation import activate, deactivate
from .base import SitemapTestsBase
from .models import TestModel
class HTTPSitemapTests(SitemapTestsBase):
@ignore_warnings(category=RemovedInDjango20Warning)
def test_simple_sitemap_index(self):
"A simple sitemap index can be rendered"
# The URL for views.sitemap in tests/urls/http.py has been updated
# with a name but since reversing by Python path is tried first
# before reversing by name and works since we're giving
# name='django.contrib.sitemaps.views.sitemap', we need to silence
# the erroneous warning until reversing by dotted path is removed.
# The test will work without modification when it's removed.
response = self.client.get('/simple/index.xml')
expected_content = """<?xml version="1.0" encoding="UTF-8"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<sitemap><loc>%s/simple/sitemap-simple.xml</loc></sitemap>
</sitemapindex>
""" % self.base_url
self.assertXMLEqual(response.content.decode('utf-8'), expected_content)
@ignore_warnings(category=RemovedInDjango20Warning)
@override_settings(TEMPLATES=[{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(os.path.dirname(upath(__file__)), 'templates')],
}])
def test_simple_sitemap_custom_index(self):
"A simple sitemap index can be rendered with a custom template"
# The URL for views.sitemap in tests/urls/http.py has been updated
# with a name but since reversing by Python path is tried first
# before reversing by name and works since we're giving
# name='django.contrib.sitemaps.views.sitemap', we need to silence
# the erroneous warning until reversing by dotted path is removed.
# The test will work without modification when it's removed.
response = self.client.get('/simple/custom-index.xml')
expected_content = """<?xml version="1.0" encoding="UTF-8"?>
<!-- This is a customised template -->
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<sitemap><loc>%s/simple/sitemap-simple.xml</loc></sitemap>
</sitemapindex>
""" % self.base_url
self.assertXMLEqual(response.content.decode('utf-8'), expected_content)
def test_simple_sitemap_section(self):
"A simple sitemap section can be rendered"
response = self.client.get('/simple/sitemap-simple.xml')
expected_content = """<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url><loc>%s/location/</loc><lastmod>%s</lastmod><changefreq>never</changefreq><priority>0.5</priority></url>
</urlset>
""" % (self.base_url, date.today())
self.assertXMLEqual(response.content.decode('utf-8'), expected_content)
def test_simple_sitemap(self):
"A simple sitemap can be rendered"
response = self.client.get('/simple/sitemap.xml')
expected_content = """<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url><loc>%s/location/</loc><lastmod>%s</lastmod><changefreq>never</changefreq><priority>0.5</priority></url>
</urlset>
""" % (self.base_url, date.today())
self.assertXMLEqual(response.content.decode('utf-8'), expected_content)
@override_settings(TEMPLATES=[{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(os.path.dirname(upath(__file__)), 'templates')],
}])
def test_simple_custom_sitemap(self):
"A simple sitemap can be rendered with a custom template"
response = self.client.get('/simple/custom-sitemap.xml')
expected_content = """<?xml version="1.0" encoding="UTF-8"?>
<!-- This is a customised template -->
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url><loc>%s/location/</loc><lastmod>%s</lastmod><changefreq>never</changefreq><priority>0.5</priority></url>
</urlset>
""" % (self.base_url, date.today())
self.assertXMLEqual(response.content.decode('utf-8'), expected_content)
def test_sitemap_last_modified(self):
"Tests that Last-Modified header is set correctly"
response = self.client.get('/lastmod/sitemap.xml')
self.assertEqual(response['Last-Modified'], 'Wed, 13 Mar 2013 10:00:00 GMT')
def test_sitemap_last_modified_date(self):
"""
The Last-Modified header should be support dates (without time).
"""
response = self.client.get('/lastmod/date-sitemap.xml')
self.assertEqual(response['Last-Modified'], 'Wed, 13 Mar 2013 00:00:00 GMT')
def test_sitemap_last_modified_tz(self):
"""
The Last-Modified header should be converted from timezone aware dates
to GMT.
"""
response = self.client.get('/lastmod/tz-sitemap.xml')
self.assertEqual(response['Last-Modified'], 'Wed, 13 Mar 2013 15:00:00 GMT')
def test_sitemap_last_modified_missing(self):
"Tests that Last-Modified header is missing when sitemap has no lastmod"
response = self.client.get('/generic/sitemap.xml')
self.assertFalse(response.has_header('Last-Modified'))
def test_sitemap_last_modified_mixed(self):
"Tests that Last-Modified header is omitted when lastmod not on all items"
response = self.client.get('/lastmod-mixed/sitemap.xml')
self.assertFalse(response.has_header('Last-Modified'))
@skipUnless(settings.USE_I18N, "Internationalization is not enabled")
@override_settings(USE_L10N=True)
def test_localized_priority(self):
"The priority value should not be localized (Refs #14164)"
activate('fr')
self.assertEqual('0,3', localize(0.3))
# Retrieve the sitemap. Check that priorities
# haven't been rendered in localized format
response = self.client.get('/simple/sitemap.xml')
self.assertContains(response, '<priority>0.5</priority>')
self.assertContains(response, '<lastmod>%s</lastmod>' % date.today())
deactivate()
@modify_settings(INSTALLED_APPS={'remove': 'django.contrib.sites'})
def test_requestsite_sitemap(self):
# Make sure hitting the flatpages sitemap without the sites framework
# installed doesn't raise an exception.
response = self.client.get('/simple/sitemap.xml')
expected_content = """<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url><loc>http://testserver/location/</loc><lastmod>%s</lastmod><changefreq>never</changefreq><priority>0.5</priority></url>
</urlset>
""" % date.today()
self.assertXMLEqual(response.content.decode('utf-8'), expected_content)
@skipUnless(apps.is_installed('django.contrib.sites'),
"django.contrib.sites app not installed.")
def test_sitemap_get_urls_no_site_1(self):
"""
Check we get ImproperlyConfigured if we don't pass a site object to
Sitemap.get_urls and no Site objects exist
"""
Site.objects.all().delete()
self.assertRaises(ImproperlyConfigured, Sitemap().get_urls)
@modify_settings(INSTALLED_APPS={'remove': 'django.contrib.sites'})
def test_sitemap_get_urls_no_site_2(self):
"""
Check we get ImproperlyConfigured when we don't pass a site object to
Sitemap.get_urls if Site objects exists, but the sites framework is not
actually installed.
"""
self.assertRaises(ImproperlyConfigured, Sitemap().get_urls)
def test_sitemap_item(self):
"""
Check to make sure that the raw item is included with each
Sitemap.get_url() url result.
"""
test_sitemap = GenericSitemap({'queryset': TestModel.objects.all()})
def is_testmodel(url):
return isinstance(url['item'], TestModel)
item_in_url_info = all(map(is_testmodel, test_sitemap.get_urls()))
self.assertTrue(item_in_url_info)
def test_cached_sitemap_index(self):
"""
Check that a cached sitemap index can be rendered (#2713).
"""
response = self.client.get('/cached/index.xml')
expected_content = """<?xml version="1.0" encoding="UTF-8"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<sitemap><loc>%s/cached/sitemap-simple.xml</loc></sitemap>
</sitemapindex>
""" % self.base_url
self.assertXMLEqual(response.content.decode('utf-8'), expected_content)
@ignore_warnings(category=RemovedInDjango20Warning)
def test_x_robots_sitemap(self):
# The URL for views.sitemap in tests/urls/http.py has been updated
# with a name but since reversing by Python path is tried first
# before reversing by name and works since we're giving
# name='django.contrib.sitemaps.views.sitemap', we need to silence
# the erroneous warning until reversing by dotted path is removed.
# The test will work without modification when it's removed.
response = self.client.get('/simple/index.xml')
self.assertEqual(response['X-Robots-Tag'], 'noindex, noodp, noarchive')
response = self.client.get('/simple/sitemap.xml')
self.assertEqual(response['X-Robots-Tag'], 'noindex, noodp, noarchive')
def test_empty_sitemap(self):
response = self.client.get('/empty/sitemap.xml')
self.assertEqual(response.status_code, 200)
@override_settings(LANGUAGES=(('en', 'English'), ('pt', 'Portuguese')))
def test_simple_i18nsitemap_index(self):
"A simple i18n sitemap index can be rendered"
response = self.client.get('/simple/i18n.xml')
expected_content = """<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url><loc>{0}/en/i18n/testmodel/{1}/</loc><changefreq>never</changefreq><priority>0.5</priority></url><url><loc>{0}/pt/i18n/testmodel/{1}/</loc><changefreq>never</changefreq><priority>0.5</priority></url>
</urlset>
""".format(self.base_url, self.i18n_model.pk)
self.assertXMLEqual(response.content.decode('utf-8'), expected_content)
|
bsd-3-clause
|
[
504,
636,
2443,
363,
492,
2649,
63,
5955,
199,
199,
646,
747,
199,
504,
2197,
492,
1434,
199,
504,
2882,
492,
3372,
5524,
199,
199,
504,
1639,
14,
5181,
492,
8686,
199,
504,
1639,
14,
2190,
492,
2202,
199,
504,
1639,
14,
2828,
14,
30515,
492,
8307,
8972,
1130,
12,
11666,
1130,
199,
504,
1639,
14,
2828,
14,
8619,
14,
992,
492,
11666,
199,
504,
1639,
14,
1018,
14,
3924,
492,
11897,
199,
504,
1639,
14,
396,
492,
3686,
63,
5451,
12,
2811,
63,
1751,
12,
4278,
63,
1751,
199,
504,
1639,
14,
1208,
423,
736,
492,
1536,
1619,
199,
504,
1639,
14,
1208,
14,
15383,
492,
23687,
1165,
3849,
199,
504,
1639,
14,
1208,
14,
6321,
492,
2257,
794,
199,
504,
1639,
14,
1208,
14,
6893,
492,
15422,
12,
25560,
199,
199,
504,
1275,
1095,
492,
11666,
1130,
2925,
1563,
199,
504,
1275,
992,
492,
1379,
1685,
421,
199,
533,
3101,
8972,
1130,
2925,
8,
8972,
1130,
2925,
1563,
304,
339,
768,
4247,
63,
5451,
8,
3710,
29,
497,
19797,
1165,
3849,
9,
272,
347,
511,
63,
4129,
63,
17205,
63,
1080,
8,
277,
304,
267,
298,
33,
3486,
25121,
1478,
883,
506,
8018,
2,
267,
327,
710,
2851,
367,
6858,
14,
17205,
315,
2295,
15,
3603,
15,
1014,
14,
647,
965,
2757,
4588,
267,
327,
543,
282,
536,
1325,
3967,
29465,
1044,
701,
2018,
931,
365,
16416,
1642,
267,
327,
2544,
29465,
1044,
701,
536,
436,
5419,
3967,
781,
3984,
15131,
267,
327,
536,
534,
1176,
14,
2828,
14,
30515,
14,
4196,
14,
17205,
297,
781,
1929,
370,
9767,
21225,
267,
327,
314,
2329,
368,
1785,
5721,
5133,
29465,
1044,
701,
18947,
931,
365,
4829,
14,
267,
327,
710,
511,
911,
1736,
1928,
7100,
1380,
652,
1159,
4829,
14,
267,
1177,
275,
291,
14,
1258,
14,
362,
2336,
4129,
15,
1080,
14,
1652,
358,
267,
1420,
63,
1317,
275,
31501,
1652,
1015,
628,
17,
14,
16,
2,
2644,
628,
6610,
13,
24,
24327,
199,
28,
17205,
1080,
9604,
628,
1014,
921,
1544,
14,
30515,
14,
1308,
15,
9482,
15,
17205,
15,
16,
14,
25,
1743,
199,
28,
17205,
2535,
2102,
6598,
83,
15,
4129,
15,
17205,
13,
4129,
14,
1652,
1108,
2102,
2957,
17205,
30,
199,
1108,
17205,
1080,
30,
199,
624,
450,
291,
14,
1095,
63,
633,
267,
291,
14,
479,
4317,
591,
8,
1310,
14,
1317,
14,
2708,
360,
1624,
13,
24,
659,
1420,
63,
1317,
9,
339,
768,
4247,
63,
5451,
8,
3710,
29,
497,
19797,
1165,
3849,
9,
272,
768,
4415,
63,
1751,
8,
25437,
1524,
91,
267,
283,
18145,
356,
283,
1176,
14,
1160,
14,
7765,
14,
1176,
14,
9323,
17969,
297,
267,
283,
14455,
356,
359,
736,
14,
515,
14,
904,
8,
736,
14,
515,
14,
3475,
8,
384,
1619,
3460,
493,
22159,
283,
5876,
2665,
272,
789,
566,
272,
347,
511,
63,
4129,
63,
17205,
63,
4229,
63,
1080,
8,
277,
304,
267,
298,
33,
3486,
25121,
1478,
883,
506,
8018,
543,
282,
3537,
1978,
2,
267,
327,
710,
2851,
367,
6858,
14,
17205,
315,
2295,
15,
3603,
15,
1014,
14,
647,
965,
2757,
4588,
267,
327,
543,
282,
536,
1325,
3967,
29465,
1044,
701,
2018,
931,
365,
16416,
1642,
267,
327,
2544,
29465,
1044,
701,
536,
436,
5419,
3967,
781,
3984,
15131,
267,
327,
536,
534,
1176,
14,
2828,
14,
30515,
14,
4196,
14,
17205,
297,
781,
1929,
370,
9767,
21225,
267,
327,
314,
2329,
368,
1785,
5721,
5133,
29465,
1044,
701,
18947,
931,
365,
4829,
14,
267,
327,
710,
511,
911,
1736,
1928,
7100,
1380,
652,
1159,
4829,
14,
267,
1177,
275,
291,
14,
1258,
14,
362,
2336,
4129,
15,
4229,
13,
1080,
14,
1652,
358,
267,
1420,
63,
1317,
275,
31501,
1652,
1015,
628,
17,
14,
16,
2,
2644,
628,
6610,
13,
24,
24327,
199,
25273,
961,
365,
282,
3537,
9096,
1978,
10541,
199,
28,
17205,
1080,
9604,
628,
1014,
921,
1544,
14,
30515,
14,
1308,
15,
9482,
15,
17205,
15,
16,
14,
25,
1743,
199,
28,
17205,
2535,
2102,
6598,
83,
15,
4129,
15,
17205,
13,
4129,
14,
1652,
1108,
2102,
2957,
17205,
30,
199,
1108,
17205,
1080,
30,
199,
624,
450,
291,
14,
1095,
63,
633,
267,
291,
14,
479,
4317,
591,
8,
1310,
14,
1317,
14,
2708,
360,
1624,
13,
24,
659,
1420,
63,
1317,
9,
339,
347,
511,
63,
4129,
63,
17205,
63,
2792,
8,
277,
304,
267,
298,
33,
3486,
25121,
3420,
883,
506,
8018,
2,
267,
1177,
275,
291,
14,
1258,
14,
362,
2336,
4129,
15,
17205,
13,
4129,
14,
1652,
358,
267,
1420,
63,
1317,
275,
31501,
1652,
1015,
628,
17,
14,
16,
2,
2644,
628,
6610,
13,
24,
24327,
199,
28,
633,
409,
9604,
628,
1014,
921,
1544,
14,
30515,
14,
1308,
15,
9482,
15,
17205,
15,
16,
14,
25,
1743,
199,
28,
633,
2535,
2102,
6598,
83,
15,
1985,
15,
1108,
2102,
2535,
2019,
1494,
6598,
83,
1108,
2019,
1494,
2535,
1461,
5646,
30,
18178,
1108,
1461,
5646,
2535,
6693,
30,
16,
14,
21,
1108,
6693,
2957,
633,
30,
199,
1108,
633,
409,
30,
199,
624,
450,
334,
277,
14,
1095,
63,
633,
12,
1434,
14,
8136,
1012,
267,
291,
14,
479,
4317,
591,
8,
1310,
14,
1317,
14,
2708,
360,
1624,
13,
24,
659,
1420,
63,
1317,
9,
339,
347,
511,
63,
4129,
63,
17205,
8,
277,
304,
267,
298,
33,
3486,
25121,
883,
506,
8018,
2,
267,
1177,
275,
291,
14,
1258,
14,
362,
2336,
4129,
15,
17205,
14,
1652,
358,
267,
1420,
63,
1317,
275,
31501,
1652,
1015,
628,
17,
14,
16,
2,
2644,
628,
6610,
13,
24,
24327,
199,
28,
633,
409,
9604,
628,
1014,
921,
1544,
14,
30515,
14,
1308,
15,
9482,
15,
17205,
15,
16,
14,
25,
1743,
199,
28,
633,
2535,
2102,
6598,
83,
15,
1985,
15,
1108,
2102,
2535,
2019,
1494,
6598,
83,
1108,
2019,
1494,
2535,
1461,
5646,
30,
18178,
1108,
1461,
5646,
2535,
6693,
30,
16,
14,
21,
1108,
6693,
2957,
633,
30,
199,
1108,
633,
409,
30,
199,
624,
450,
334,
277,
14,
1095,
63,
633,
12,
1434,
14,
8136,
1012,
267,
291,
14,
479,
4317,
591,
8,
1310,
14,
1317,
14,
2708,
360,
1624,
13,
24,
659,
1420,
63,
1317,
9
] |
[
636,
2443,
363,
492,
2649,
63,
5955,
199,
199,
646,
747,
199,
504,
2197,
492,
1434,
199,
504,
2882,
492,
3372,
5524,
199,
199,
504,
1639,
14,
5181,
492,
8686,
199,
504,
1639,
14,
2190,
492,
2202,
199,
504,
1639,
14,
2828,
14,
30515,
492,
8307,
8972,
1130,
12,
11666,
1130,
199,
504,
1639,
14,
2828,
14,
8619,
14,
992,
492,
11666,
199,
504,
1639,
14,
1018,
14,
3924,
492,
11897,
199,
504,
1639,
14,
396,
492,
3686,
63,
5451,
12,
2811,
63,
1751,
12,
4278,
63,
1751,
199,
504,
1639,
14,
1208,
423,
736,
492,
1536,
1619,
199,
504,
1639,
14,
1208,
14,
15383,
492,
23687,
1165,
3849,
199,
504,
1639,
14,
1208,
14,
6321,
492,
2257,
794,
199,
504,
1639,
14,
1208,
14,
6893,
492,
15422,
12,
25560,
199,
199,
504,
1275,
1095,
492,
11666,
1130,
2925,
1563,
199,
504,
1275,
992,
492,
1379,
1685,
421,
199,
533,
3101,
8972,
1130,
2925,
8,
8972,
1130,
2925,
1563,
304,
339,
768,
4247,
63,
5451,
8,
3710,
29,
497,
19797,
1165,
3849,
9,
272,
347,
511,
63,
4129,
63,
17205,
63,
1080,
8,
277,
304,
267,
298,
33,
3486,
25121,
1478,
883,
506,
8018,
2,
267,
327,
710,
2851,
367,
6858,
14,
17205,
315,
2295,
15,
3603,
15,
1014,
14,
647,
965,
2757,
4588,
267,
327,
543,
282,
536,
1325,
3967,
29465,
1044,
701,
2018,
931,
365,
16416,
1642,
267,
327,
2544,
29465,
1044,
701,
536,
436,
5419,
3967,
781,
3984,
15131,
267,
327,
536,
534,
1176,
14,
2828,
14,
30515,
14,
4196,
14,
17205,
297,
781,
1929,
370,
9767,
21225,
267,
327,
314,
2329,
368,
1785,
5721,
5133,
29465,
1044,
701,
18947,
931,
365,
4829,
14,
267,
327,
710,
511,
911,
1736,
1928,
7100,
1380,
652,
1159,
4829,
14,
267,
1177,
275,
291,
14,
1258,
14,
362,
2336,
4129,
15,
1080,
14,
1652,
358,
267,
1420,
63,
1317,
275,
31501,
1652,
1015,
628,
17,
14,
16,
2,
2644,
628,
6610,
13,
24,
24327,
199,
28,
17205,
1080,
9604,
628,
1014,
921,
1544,
14,
30515,
14,
1308,
15,
9482,
15,
17205,
15,
16,
14,
25,
1743,
199,
28,
17205,
2535,
2102,
6598,
83,
15,
4129,
15,
17205,
13,
4129,
14,
1652,
1108,
2102,
2957,
17205,
30,
199,
1108,
17205,
1080,
30,
199,
624,
450,
291,
14,
1095,
63,
633,
267,
291,
14,
479,
4317,
591,
8,
1310,
14,
1317,
14,
2708,
360,
1624,
13,
24,
659,
1420,
63,
1317,
9,
339,
768,
4247,
63,
5451,
8,
3710,
29,
497,
19797,
1165,
3849,
9,
272,
768,
4415,
63,
1751,
8,
25437,
1524,
91,
267,
283,
18145,
356,
283,
1176,
14,
1160,
14,
7765,
14,
1176,
14,
9323,
17969,
297,
267,
283,
14455,
356,
359,
736,
14,
515,
14,
904,
8,
736,
14,
515,
14,
3475,
8,
384,
1619,
3460,
493,
22159,
283,
5876,
2665,
272,
789,
566,
272,
347,
511,
63,
4129,
63,
17205,
63,
4229,
63,
1080,
8,
277,
304,
267,
298,
33,
3486,
25121,
1478,
883,
506,
8018,
543,
282,
3537,
1978,
2,
267,
327,
710,
2851,
367,
6858,
14,
17205,
315,
2295,
15,
3603,
15,
1014,
14,
647,
965,
2757,
4588,
267,
327,
543,
282,
536,
1325,
3967,
29465,
1044,
701,
2018,
931,
365,
16416,
1642,
267,
327,
2544,
29465,
1044,
701,
536,
436,
5419,
3967,
781,
3984,
15131,
267,
327,
536,
534,
1176,
14,
2828,
14,
30515,
14,
4196,
14,
17205,
297,
781,
1929,
370,
9767,
21225,
267,
327,
314,
2329,
368,
1785,
5721,
5133,
29465,
1044,
701,
18947,
931,
365,
4829,
14,
267,
327,
710,
511,
911,
1736,
1928,
7100,
1380,
652,
1159,
4829,
14,
267,
1177,
275,
291,
14,
1258,
14,
362,
2336,
4129,
15,
4229,
13,
1080,
14,
1652,
358,
267,
1420,
63,
1317,
275,
31501,
1652,
1015,
628,
17,
14,
16,
2,
2644,
628,
6610,
13,
24,
24327,
199,
25273,
961,
365,
282,
3537,
9096,
1978,
10541,
199,
28,
17205,
1080,
9604,
628,
1014,
921,
1544,
14,
30515,
14,
1308,
15,
9482,
15,
17205,
15,
16,
14,
25,
1743,
199,
28,
17205,
2535,
2102,
6598,
83,
15,
4129,
15,
17205,
13,
4129,
14,
1652,
1108,
2102,
2957,
17205,
30,
199,
1108,
17205,
1080,
30,
199,
624,
450,
291,
14,
1095,
63,
633,
267,
291,
14,
479,
4317,
591,
8,
1310,
14,
1317,
14,
2708,
360,
1624,
13,
24,
659,
1420,
63,
1317,
9,
339,
347,
511,
63,
4129,
63,
17205,
63,
2792,
8,
277,
304,
267,
298,
33,
3486,
25121,
3420,
883,
506,
8018,
2,
267,
1177,
275,
291,
14,
1258,
14,
362,
2336,
4129,
15,
17205,
13,
4129,
14,
1652,
358,
267,
1420,
63,
1317,
275,
31501,
1652,
1015,
628,
17,
14,
16,
2,
2644,
628,
6610,
13,
24,
24327,
199,
28,
633,
409,
9604,
628,
1014,
921,
1544,
14,
30515,
14,
1308,
15,
9482,
15,
17205,
15,
16,
14,
25,
1743,
199,
28,
633,
2535,
2102,
6598,
83,
15,
1985,
15,
1108,
2102,
2535,
2019,
1494,
6598,
83,
1108,
2019,
1494,
2535,
1461,
5646,
30,
18178,
1108,
1461,
5646,
2535,
6693,
30,
16,
14,
21,
1108,
6693,
2957,
633,
30,
199,
1108,
633,
409,
30,
199,
624,
450,
334,
277,
14,
1095,
63,
633,
12,
1434,
14,
8136,
1012,
267,
291,
14,
479,
4317,
591,
8,
1310,
14,
1317,
14,
2708,
360,
1624,
13,
24,
659,
1420,
63,
1317,
9,
339,
347,
511,
63,
4129,
63,
17205,
8,
277,
304,
267,
298,
33,
3486,
25121,
883,
506,
8018,
2,
267,
1177,
275,
291,
14,
1258,
14,
362,
2336,
4129,
15,
17205,
14,
1652,
358,
267,
1420,
63,
1317,
275,
31501,
1652,
1015,
628,
17,
14,
16,
2,
2644,
628,
6610,
13,
24,
24327,
199,
28,
633,
409,
9604,
628,
1014,
921,
1544,
14,
30515,
14,
1308,
15,
9482,
15,
17205,
15,
16,
14,
25,
1743,
199,
28,
633,
2535,
2102,
6598,
83,
15,
1985,
15,
1108,
2102,
2535,
2019,
1494,
6598,
83,
1108,
2019,
1494,
2535,
1461,
5646,
30,
18178,
1108,
1461,
5646,
2535,
6693,
30,
16,
14,
21,
1108,
6693,
2957,
633,
30,
199,
1108,
633,
409,
30,
199,
624,
450,
334,
277,
14,
1095,
63,
633,
12,
1434,
14,
8136,
1012,
267,
291,
14,
479,
4317,
591,
8,
1310,
14,
1317,
14,
2708,
360,
1624,
13,
24,
659,
1420,
63,
1317,
9,
0
] |
[
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|
SeedScientific/luigi
|
test/db_task_history_test.py
|
25
|
4338
|
# -*- 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.
#
from helpers import unittest
from luigi import six
from helpers import with_config
import luigi
from luigi.db_task_history import DbTaskHistory, Base
from luigi.task_status import DONE, PENDING, RUNNING
class DummyTask(luigi.Task):
foo = luigi.Parameter(default='foo')
class ParamTask(luigi.Task):
param1 = luigi.Parameter()
param2 = luigi.IntParameter()
class DbTaskHistoryTest(unittest.TestCase):
@with_config(dict(task_history=dict(db_connection='sqlite:///:memory:')))
def setUp(self):
self.history = DbTaskHistory()
def test_task_list(self):
self.run_task(DummyTask())
self.run_task(DummyTask(foo='bar'))
tasks = list(self.history.find_all_by_name('DummyTask'))
self.assertEqual(len(tasks), 2)
for task in tasks:
self.assertEqual(task.name, 'DummyTask')
self.assertEqual(task.host, 'hostname')
def test_task_events(self):
self.run_task(DummyTask())
tasks = list(self.history.find_all_by_name('DummyTask'))
self.assertEqual(len(tasks), 1)
[task] = tasks
self.assertEqual(task.name, 'DummyTask')
self.assertEqual(len(task.events), 3)
for (event, name) in zip(task.events, [DONE, RUNNING, PENDING]):
self.assertEqual(event.event_name, name)
def test_task_by_params(self):
task1 = ParamTask('foo', 'bar')
task2 = ParamTask('bar', 'foo')
self.run_task(task1)
self.run_task(task2)
task1_record = self.history.find_all_by_parameters(task_name='ParamTask', param1='foo', param2='bar')
task2_record = self.history.find_all_by_parameters(task_name='ParamTask', param1='bar', param2='foo')
for task, records in zip((task1, task2), (task1_record, task2_record)):
records = list(records)
self.assertEqual(len(records), 1)
[record] = records
self.assertEqual(task.task_family, record.name)
for param_name, param_value in six.iteritems(task.param_kwargs):
self.assertTrue(param_name in record.parameters)
self.assertEqual(str(param_value), record.parameters[param_name].value)
def run_task(self, task):
self.history.task_scheduled(task.task_id)
self.history.task_started(task.task_id, 'hostname')
self.history.task_finished(task.task_id, successful=True)
class MySQLDbTaskHistoryTest(unittest.TestCase):
@with_config(dict(task_history=dict(db_connection='mysql+mysqlconnector://travis@localhost/luigi_test')))
def setUp(self):
try:
self.history = DbTaskHistory()
except Exception:
raise unittest.SkipTest('DBTaskHistory cannot be created: probably no MySQL available')
def test_subsecond_timestamp(self):
# Add 2 events in <1s
task = DummyTask()
self.run_task(task)
task_record = six.advance_iterator(self.history.find_all_by_name('DummyTask'))
print (task_record.events)
self.assertEqual(task_record.events[0].event_name, DONE)
def test_utc_conversion(self):
from luigi.server import from_utc
task = DummyTask()
self.run_task(task)
task_record = six.advance_iterator(self.history.find_all_by_name('DummyTask'))
last_event = task_record.events[0]
try:
print (from_utc(str(last_event.ts)))
except ValueError:
self.fail("Failed to convert timestamp {} to UTC".format(last_event.ts))
def run_task(self, task):
self.history.task_scheduled(task.task_id)
self.history.task_started(task.task_id, 'hostname')
self.history.task_finished(task.task_id, successful=True)
|
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,
504,
10897,
492,
2882,
199,
199,
504,
19485,
492,
3816,
199,
199,
504,
10897,
492,
543,
63,
888,
199,
646,
19485,
199,
504,
19485,
14,
697,
63,
1765,
63,
5570,
492,
28822,
4476,
12114,
12,
3523,
199,
504,
19485,
14,
1765,
63,
1205,
492,
577,
4817,
12,
510,
15219,
12,
21277,
6024,
421,
199,
533,
9762,
4476,
8,
26795,
14,
4476,
304,
272,
3925,
275,
19485,
14,
4720,
8,
885,
534,
1421,
358,
421,
199,
533,
12608,
4476,
8,
26795,
14,
4476,
304,
272,
1215,
17,
275,
19485,
14,
4720,
342,
272,
1215,
18,
275,
19485,
14,
3241,
4720,
342,
421,
199,
533,
28822,
4476,
12114,
774,
8,
2796,
14,
1746,
304,
339,
768,
1045,
63,
888,
8,
807,
8,
1765,
63,
5570,
29,
807,
8,
697,
63,
2105,
534,
10659,
921,
22075,
4844,
26,
7058,
272,
347,
3613,
8,
277,
304,
267,
291,
14,
5570,
275,
28822,
4476,
12114,
342,
339,
347,
511,
63,
1765,
63,
513,
8,
277,
304,
267,
291,
14,
1065,
63,
1765,
8,
11324,
4476,
1012,
267,
291,
14,
1065,
63,
1765,
8,
11324,
4476,
8,
1421,
534,
1700,
1333,
398,
6527,
275,
769,
8,
277,
14,
5570,
14,
1623,
63,
452,
63,
991,
63,
354,
360,
11324,
4476,
1333,
398,
291,
14,
629,
8,
552,
8,
5054,
395,
499,
9,
267,
367,
2120,
315,
6527,
26,
288,
291,
14,
629,
8,
1765,
14,
354,
12,
283,
11324,
4476,
358,
288,
291,
14,
629,
8,
1765,
14,
1102,
12,
283,
4269,
358,
339,
347,
511,
63,
1765,
63,
4368,
8,
277,
304,
267,
291,
14,
1065,
63,
1765,
8,
11324,
4476,
1012,
267,
6527,
275,
769,
8,
277,
14,
5570,
14,
1623,
63,
452,
63,
991,
63,
354,
360,
11324,
4476,
1333,
267,
291,
14,
629,
8,
552,
8,
5054,
395,
413,
9,
267,
359,
1765,
61,
275,
6527,
267,
291,
14,
629,
8,
1765,
14,
354,
12,
283,
11324,
4476,
358,
267,
291,
14,
629,
8,
552,
8,
1765,
14,
4368,
395,
650,
9,
267,
367,
334,
1430,
12,
536,
9,
315,
3482,
8,
1765,
14,
4368,
12,
359,
22162,
12,
21277,
6024,
12,
510,
15219,
4682,
288,
291,
14,
629,
8,
1430,
14,
1430,
63,
354,
12,
536,
9,
339,
347,
511,
63,
1765,
63,
991,
63,
1162,
8,
277,
304,
267,
2120,
17,
275,
12608,
4476,
360,
1421,
297,
283,
1700,
358,
267,
2120,
18,
275,
12608,
4476,
360,
1700,
297,
283,
1421,
358,
398,
291,
14,
1065,
63,
1765,
8,
1765,
17,
9,
267,
291,
14,
1065,
63,
1765,
8,
1765,
18,
9,
267,
2120,
17,
63,
3059,
275,
291,
14,
5570,
14,
1623,
63,
452,
63,
991,
63,
3214,
8,
1765,
63,
354,
534,
4098,
4476,
297,
1215,
17,
534,
1421,
297,
1215,
18,
534,
1700,
358,
267,
2120,
18,
63,
3059,
275,
291,
14,
5570,
14,
1623,
63,
452,
63,
991,
63,
3214,
8,
1765,
63,
354,
534,
4098,
4476,
297,
1215,
17,
534,
1700,
297,
1215,
18,
534,
1421,
358,
267,
367,
2120,
12,
5767,
315,
3482,
1332,
1765,
17,
12,
2120,
18,
395,
334,
1765,
17,
63,
3059,
12,
2120,
18,
63,
3059,
2298,
288,
5767,
275,
769,
8,
6502,
9,
288,
291,
14,
629,
8,
552,
8,
6502,
395,
413,
9,
288,
359,
3059,
61,
275,
5767,
288,
291,
14,
629,
8,
1765,
14,
1765,
63,
6606,
12,
2777,
14,
354,
9,
288,
367,
1215,
63,
354,
12,
1215,
63,
585,
315,
3816,
14,
4611,
8,
1765,
14,
635,
63,
958,
304,
355,
291,
14,
1815,
8,
635,
63,
354,
315,
2777,
14,
3214,
9,
355,
291,
14,
629,
8,
495,
8,
635,
63,
585,
395,
2777,
14,
3214,
59,
635,
63,
354,
1055,
585,
9,
339,
347,
1255,
63,
1765,
8,
277,
12,
2120,
304,
267,
291,
14,
5570,
14,
1765,
63,
19274,
8,
1765,
14,
1765,
63,
344,
9,
267,
291,
14,
5570,
14,
1765,
63,
8924,
8,
1765,
14,
1765,
63,
344,
12,
283,
4269,
358,
267,
291,
14,
5570,
14,
1765,
63,
8669,
8,
1765,
14,
1765,
63,
344,
12,
9512,
29,
549,
9,
421,
199,
533,
11200,
8882,
4476,
12114,
774,
8,
2796,
14,
1746,
304,
339,
768,
1045,
63,
888,
8,
807,
8,
1765,
63,
5570,
29,
807,
8,
697,
63,
2105,
534,
8644,
11,
8644,
11815,
921,
1239,
5068,
32,
5967,
15,
26795,
63,
396,
7058,
272,
347,
3613,
8,
277,
304,
267,
862,
26,
288,
291,
14,
5570,
275,
28822,
4476,
12114,
342,
267,
871,
2186,
26,
288,
746,
2882,
14,
25755,
360,
2846,
4476,
12114,
3913,
506,
2737,
26,
8646,
949,
11200,
2808,
358,
339,
347,
511,
63,
954,
4375,
63,
3954,
8,
277,
304,
267,
327,
2654,
499,
4474,
315,
665,
17,
83,
267,
2120,
275,
9762,
4476,
342,
267,
291,
14,
1065,
63,
1765,
8,
1765,
9,
398,
2120,
63,
3059,
275,
3816,
14,
21195,
63,
5778,
8,
277,
14,
5570,
14,
1623,
63,
452,
63,
991,
63,
354,
360,
11324,
4476,
1333,
267,
870,
334,
1765,
63,
3059,
14,
4368,
9,
267,
291,
14,
629,
8,
1765,
63,
3059,
14,
4368,
59,
16,
1055,
1430,
63,
354,
12,
577,
4817,
9,
339,
347,
511,
63,
5834,
63,
15083,
8,
277,
304,
267,
687,
19485,
14,
1000,
492,
687,
63,
5834,
398,
2120,
275,
9762
] |
[
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,
504,
10897,
492,
2882,
199,
199,
504,
19485,
492,
3816,
199,
199,
504,
10897,
492,
543,
63,
888,
199,
646,
19485,
199,
504,
19485,
14,
697,
63,
1765,
63,
5570,
492,
28822,
4476,
12114,
12,
3523,
199,
504,
19485,
14,
1765,
63,
1205,
492,
577,
4817,
12,
510,
15219,
12,
21277,
6024,
421,
199,
533,
9762,
4476,
8,
26795,
14,
4476,
304,
272,
3925,
275,
19485,
14,
4720,
8,
885,
534,
1421,
358,
421,
199,
533,
12608,
4476,
8,
26795,
14,
4476,
304,
272,
1215,
17,
275,
19485,
14,
4720,
342,
272,
1215,
18,
275,
19485,
14,
3241,
4720,
342,
421,
199,
533,
28822,
4476,
12114,
774,
8,
2796,
14,
1746,
304,
339,
768,
1045,
63,
888,
8,
807,
8,
1765,
63,
5570,
29,
807,
8,
697,
63,
2105,
534,
10659,
921,
22075,
4844,
26,
7058,
272,
347,
3613,
8,
277,
304,
267,
291,
14,
5570,
275,
28822,
4476,
12114,
342,
339,
347,
511,
63,
1765,
63,
513,
8,
277,
304,
267,
291,
14,
1065,
63,
1765,
8,
11324,
4476,
1012,
267,
291,
14,
1065,
63,
1765,
8,
11324,
4476,
8,
1421,
534,
1700,
1333,
398,
6527,
275,
769,
8,
277,
14,
5570,
14,
1623,
63,
452,
63,
991,
63,
354,
360,
11324,
4476,
1333,
398,
291,
14,
629,
8,
552,
8,
5054,
395,
499,
9,
267,
367,
2120,
315,
6527,
26,
288,
291,
14,
629,
8,
1765,
14,
354,
12,
283,
11324,
4476,
358,
288,
291,
14,
629,
8,
1765,
14,
1102,
12,
283,
4269,
358,
339,
347,
511,
63,
1765,
63,
4368,
8,
277,
304,
267,
291,
14,
1065,
63,
1765,
8,
11324,
4476,
1012,
267,
6527,
275,
769,
8,
277,
14,
5570,
14,
1623,
63,
452,
63,
991,
63,
354,
360,
11324,
4476,
1333,
267,
291,
14,
629,
8,
552,
8,
5054,
395,
413,
9,
267,
359,
1765,
61,
275,
6527,
267,
291,
14,
629,
8,
1765,
14,
354,
12,
283,
11324,
4476,
358,
267,
291,
14,
629,
8,
552,
8,
1765,
14,
4368,
395,
650,
9,
267,
367,
334,
1430,
12,
536,
9,
315,
3482,
8,
1765,
14,
4368,
12,
359,
22162,
12,
21277,
6024,
12,
510,
15219,
4682,
288,
291,
14,
629,
8,
1430,
14,
1430,
63,
354,
12,
536,
9,
339,
347,
511,
63,
1765,
63,
991,
63,
1162,
8,
277,
304,
267,
2120,
17,
275,
12608,
4476,
360,
1421,
297,
283,
1700,
358,
267,
2120,
18,
275,
12608,
4476,
360,
1700,
297,
283,
1421,
358,
398,
291,
14,
1065,
63,
1765,
8,
1765,
17,
9,
267,
291,
14,
1065,
63,
1765,
8,
1765,
18,
9,
267,
2120,
17,
63,
3059,
275,
291,
14,
5570,
14,
1623,
63,
452,
63,
991,
63,
3214,
8,
1765,
63,
354,
534,
4098,
4476,
297,
1215,
17,
534,
1421,
297,
1215,
18,
534,
1700,
358,
267,
2120,
18,
63,
3059,
275,
291,
14,
5570,
14,
1623,
63,
452,
63,
991,
63,
3214,
8,
1765,
63,
354,
534,
4098,
4476,
297,
1215,
17,
534,
1700,
297,
1215,
18,
534,
1421,
358,
267,
367,
2120,
12,
5767,
315,
3482,
1332,
1765,
17,
12,
2120,
18,
395,
334,
1765,
17,
63,
3059,
12,
2120,
18,
63,
3059,
2298,
288,
5767,
275,
769,
8,
6502,
9,
288,
291,
14,
629,
8,
552,
8,
6502,
395,
413,
9,
288,
359,
3059,
61,
275,
5767,
288,
291,
14,
629,
8,
1765,
14,
1765,
63,
6606,
12,
2777,
14,
354,
9,
288,
367,
1215,
63,
354,
12,
1215,
63,
585,
315,
3816,
14,
4611,
8,
1765,
14,
635,
63,
958,
304,
355,
291,
14,
1815,
8,
635,
63,
354,
315,
2777,
14,
3214,
9,
355,
291,
14,
629,
8,
495,
8,
635,
63,
585,
395,
2777,
14,
3214,
59,
635,
63,
354,
1055,
585,
9,
339,
347,
1255,
63,
1765,
8,
277,
12,
2120,
304,
267,
291,
14,
5570,
14,
1765,
63,
19274,
8,
1765,
14,
1765,
63,
344,
9,
267,
291,
14,
5570,
14,
1765,
63,
8924,
8,
1765,
14,
1765,
63,
344,
12,
283,
4269,
358,
267,
291,
14,
5570,
14,
1765,
63,
8669,
8,
1765,
14,
1765,
63,
344,
12,
9512,
29,
549,
9,
421,
199,
533,
11200,
8882,
4476,
12114,
774,
8,
2796,
14,
1746,
304,
339,
768,
1045,
63,
888,
8,
807,
8,
1765,
63,
5570,
29,
807,
8,
697,
63,
2105,
534,
8644,
11,
8644,
11815,
921,
1239,
5068,
32,
5967,
15,
26795,
63,
396,
7058,
272,
347,
3613,
8,
277,
304,
267,
862,
26,
288,
291,
14,
5570,
275,
28822,
4476,
12114,
342,
267,
871,
2186,
26,
288,
746,
2882,
14,
25755,
360,
2846,
4476,
12114,
3913,
506,
2737,
26,
8646,
949,
11200,
2808,
358,
339,
347,
511,
63,
954,
4375,
63,
3954,
8,
277,
304,
267,
327,
2654,
499,
4474,
315,
665,
17,
83,
267,
2120,
275,
9762,
4476,
342,
267,
291,
14,
1065,
63,
1765,
8,
1765,
9,
398,
2120,
63,
3059,
275,
3816,
14,
21195,
63,
5778,
8,
277,
14,
5570,
14,
1623,
63,
452,
63,
991,
63,
354,
360,
11324,
4476,
1333,
267,
870,
334,
1765,
63,
3059,
14,
4368,
9,
267,
291,
14,
629,
8,
1765,
63,
3059,
14,
4368,
59,
16,
1055,
1430,
63,
354,
12,
577,
4817,
9,
339,
347,
511,
63,
5834,
63,
15083,
8,
277,
304,
267,
687,
19485,
14,
1000,
492,
687,
63,
5834,
398,
2120,
275,
9762,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
varunarya10/tempest-lib
|
tempest_lib/tests/fake_identity.py
|
20
|
4526
|
# Copyright 2014 IBM Corp.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import json
import httplib2
FAKE_AUTH_URL = 'http://fake_uri.com/auth'
TOKEN = "fake_token"
ALT_TOKEN = "alt_fake_token"
# Fake Identity v2 constants
COMPUTE_ENDPOINTS_V2 = {
"endpoints": [
{
"adminURL": "http://fake_url/v2/first_endpoint/admin",
"region": "NoMatchRegion",
"internalURL": "http://fake_url/v2/first_endpoint/internal",
"publicURL": "http://fake_url/v2/first_endpoint/public"
},
{
"adminURL": "http://fake_url/v2/second_endpoint/admin",
"region": "FakeRegion",
"internalURL": "http://fake_url/v2/second_endpoint/internal",
"publicURL": "http://fake_url/v2/second_endpoint/public"
},
],
"type": "compute",
"name": "nova"
}
CATALOG_V2 = [COMPUTE_ENDPOINTS_V2, ]
ALT_IDENTITY_V2_RESPONSE = {
"access": {
"token": {
"expires": "2020-01-01T00:00:10Z",
"id": ALT_TOKEN,
"tenant": {
"id": "fake_tenant_id"
},
},
"user": {
"id": "fake_user_id",
},
"serviceCatalog": CATALOG_V2,
},
}
IDENTITY_V2_RESPONSE = {
"access": {
"token": {
"expires": "2020-01-01T00:00:10Z",
"id": TOKEN,
"tenant": {
"id": "fake_tenant_id"
},
},
"user": {
"id": "fake_user_id",
},
"serviceCatalog": CATALOG_V2,
},
}
# Fake Identity V3 constants
COMPUTE_ENDPOINTS_V3 = {
"endpoints": [
{
"id": "first_compute_fake_service",
"interface": "public",
"region": "NoMatchRegion",
"url": "http://fake_url/v3/first_endpoint/api"
},
{
"id": "second_fake_service",
"interface": "public",
"region": "FakeRegion",
"url": "http://fake_url/v3/second_endpoint/api"
},
{
"id": "third_fake_service",
"interface": "admin",
"region": "MiddleEarthRegion",
"url": "http://fake_url/v3/third_endpoint/api"
}
],
"type": "compute",
"id": "fake_compute_endpoint"
}
CATALOG_V3 = [COMPUTE_ENDPOINTS_V3, ]
IDENTITY_V3_RESPONSE = {
"token": {
"methods": [
"token",
"password"
],
"expires_at": "2020-01-01T00:00:10.000123Z",
"project": {
"domain": {
"id": "fake_domain_id",
"name": "fake"
},
"id": "project_id",
"name": "project_name"
},
"user": {
"domain": {
"id": "fake_domain_id",
"name": "domain_name"
},
"id": "fake_user_id",
"name": "username"
},
"issued_at": "2013-05-29T16:55:21.468960Z",
"catalog": CATALOG_V3
}
}
ALT_IDENTITY_V3 = IDENTITY_V3_RESPONSE
def _fake_v3_response(self, uri, method="GET", body=None, headers=None,
redirections=5, connection_type=None):
fake_headers = {
"status": "201",
"x-subject-token": TOKEN
}
return (httplib2.Response(fake_headers),
json.dumps(IDENTITY_V3_RESPONSE))
def _fake_v2_response(self, uri, method="GET", body=None, headers=None,
redirections=5, connection_type=None):
return (httplib2.Response({"status": "200"}),
json.dumps(IDENTITY_V2_RESPONSE))
def _fake_auth_failure_response():
# the response body isn't really used in this case, but lets send it anyway
# to have a safe check in some future change on the rest client.
body = {
"unauthorized": {
"message": "Unauthorized",
"code": "401"
}
}
return httplib2.Response({"status": "401"}), json.dumps(body)
|
apache-2.0
|
[
3,
1898,
6927,
26202,
22304,
14,
199,
3,
2900,
5924,
5702,
14,
199,
3,
199,
3,
259,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
1265,
1443,
199,
3,
259,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
2047,
1443,
3332,
199,
3,
259,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
260,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
259,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
259,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
2428,
199,
3,
259,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
1666,
314,
199,
3,
259,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
4204,
199,
3,
259,
1334,
314,
844,
14,
199,
199,
646,
2022,
199,
199,
646,
8809,
18,
199,
199,
14623,
63,
5580,
63,
2632,
275,
283,
1014,
921,
3183,
63,
2302,
14,
957,
15,
1178,
7,
199,
199,
8803,
275,
298,
3183,
63,
1418,
2,
199,
19600,
63,
8803,
275,
298,
4478,
63,
3183,
63,
1418,
2,
199,
199,
3,
7777,
22034,
373,
18,
5262,
199,
6790,
4586,
63,
21054,
51,
63,
54,
18,
275,
469,
272,
298,
14461,
582,
359,
267,
469,
288,
298,
2113,
2632,
582,
298,
1014,
921,
3183,
63,
633,
15,
86,
18,
15,
2246,
63,
6520,
15,
2113,
401,
288,
298,
4551,
582,
298,
1944,
4486,
10708,
401,
288,
298,
4672,
2632,
582,
298,
1014,
921,
3183,
63,
633,
15,
86,
18,
15,
2246,
63,
6520,
15,
4672,
401,
288,
298,
3455,
2632,
582,
298,
1014,
921,
3183,
63,
633,
15,
86,
18,
15,
2246,
63,
6520,
15,
3455,
2,
267,
1660,
267,
469,
288,
298,
2113,
2632,
582,
298,
1014,
921,
3183,
63,
633,
15,
86,
18,
15,
4375,
63,
6520,
15,
2113,
401,
288,
298,
4551,
582,
298,
8249,
10708,
401,
288,
298,
4672,
2632,
582,
298,
1014,
921,
3183,
63,
633,
15,
86,
18,
15,
4375,
63,
6520,
15,
4672,
401,
288,
298,
3455,
2632,
582,
298,
1014,
921,
3183,
63,
633,
15,
86,
18,
15,
4375,
63,
6520,
15,
3455,
2,
267,
1660,
272,
2156,
272,
298,
466,
582,
298,
3357,
401,
272,
298,
354,
582,
298,
6765,
2,
199,
93,
199,
199,
11206,
23622,
63,
54,
18,
275,
359,
6790,
4586,
63,
21054,
51,
63,
54,
18,
12,
1622,
199,
199,
19600,
63,
7466,
1922,
63,
54,
18,
63,
12801,
275,
469,
272,
298,
2732,
582,
469,
267,
298,
1418,
582,
469,
288,
298,
12342,
582,
298,
13934,
13,
614,
13,
614,
52,
383,
26,
383,
26,
709,
58,
401,
288,
298,
344,
582,
12112,
52,
63,
8803,
12,
288,
298,
4647,
582,
469,
355,
298,
344,
582,
298,
3183,
63,
4647,
63,
344,
2,
288,
1660,
267,
1660,
267,
298,
751,
582,
469,
288,
298,
344,
582,
298,
3183,
63,
751,
63,
344,
401,
267,
1660,
267,
298,
1364,
17161,
582,
445,
619,
23622,
63,
54,
18,
12,
272,
1660,
199,
93,
199,
199,
7466,
1922,
63,
54,
18,
63,
12801,
275,
469,
272,
298,
2732,
582,
469,
267,
298,
1418,
582,
469,
288,
298,
12342,
582,
298,
13934,
13,
614,
13,
614,
52,
383,
26,
383,
26,
709,
58,
401,
288,
298,
344,
582,
18243,
12,
288,
298,
4647,
582,
469,
355,
298,
344,
582,
298,
3183,
63,
4647,
63,
344,
2,
288,
1660,
267,
1660,
267,
298,
751,
582,
469,
288,
298,
344,
582,
298,
3183,
63,
751,
63,
344,
401,
267,
1660,
267,
298,
1364,
17161,
582,
445,
619,
23622,
63,
54,
18,
12,
272,
1660,
199,
93,
199,
199,
3,
7777,
22034,
812,
19,
5262,
199,
6790,
4586,
63,
21054,
51,
63,
54,
19,
275,
469,
272,
298,
14461,
582,
359,
267,
469,
288,
298,
344,
582,
298,
2246,
63,
3357,
63,
3183,
63,
1364,
401,
288,
298,
3266,
582,
298,
3455,
401,
288,
298,
4551,
582,
298,
1944,
4486,
10708,
401,
288,
298,
633,
582,
298,
1014,
921,
3183,
63,
633,
15,
86,
19,
15,
2246,
63,
6520,
15,
1246,
2,
267,
1660,
267,
469,
288,
298,
344,
582,
298,
4375,
63,
3183,
63,
1364,
401,
288,
298,
3266,
582,
298,
3455,
401,
288,
298,
4551,
582,
298,
8249,
10708,
401,
288,
298,
633,
582,
298,
1014,
921,
3183,
63,
633,
15,
86,
19,
15,
4375,
63,
6520,
15,
1246,
2,
267,
1660,
267,
469,
288,
298,
344,
582,
298,
11470,
63,
3183,
63,
1364,
401,
288,
298,
3266,
582,
298,
2113,
401,
288,
298,
4551,
582,
298,
30734,
37,
19677,
10708,
401,
288,
298,
633,
582,
298,
1014,
921,
3183,
63,
633,
15,
86,
19,
15,
11470,
63,
6520,
15,
1246,
2,
267,
789,
339,
2156,
272,
298,
466,
582,
298,
3357,
401,
272,
298,
344,
582,
298,
3183,
63,
3357,
63,
6520,
2,
199,
93,
199,
199,
11206,
23622,
63,
54,
19,
275,
359,
6790,
4586,
63,
21054,
51,
63,
54,
19,
12,
1622,
199,
199,
7466,
1922,
63,
54,
19,
63,
12801,
275,
469,
272,
298,
1418,
582,
469,
267,
298,
2474,
582,
359,
288,
298,
1418,
401,
288,
298,
2060,
2,
267,
2156,
267,
298,
12342,
63,
292,
582,
298,
13934,
13,
614,
13,
614,
52,
383,
26,
383,
26,
709,
14,
4183,
1789,
58,
401,
267,
298,
1715,
582,
469,
288,
298,
2261,
582,
469,
355,
298,
344,
582,
298,
3183,
63,
2261,
63,
344,
401,
355,
298,
354,
582,
298,
3183,
2,
288,
1660,
288,
298,
344,
582,
298,
1715,
63,
344,
401,
288,
298,
354,
582,
298,
1715,
63,
354,
2,
267,
1660,
267,
298,
751,
582,
469,
288,
298,
2261,
582,
469,
355,
298,
344,
582,
298,
3183,
63,
2261,
63,
344,
401,
355,
298,
354,
582,
298,
2261,
63,
354,
2,
288,
1660,
288,
298,
344,
582,
298,
3183,
63,
751,
63,
344,
401,
288,
298,
354,
582,
298,
2473,
2,
267,
1660,
267,
298,
5237,
68,
63,
292,
582,
298,
6965,
13,
1717,
13,
1398,
52,
975,
26,
1229,
26,
2025,
14,
2466,
1407,
2259,
58,
401,
267,
298,
7959,
582,
445,
619,
23622,
63
] |
[
1898,
6927,
26202,
22304,
14,
199,
3,
2900,
5924,
5702,
14,
199,
3,
199,
3,
259,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
1265,
1443,
199,
3,
259,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
2047,
1443,
3332,
199,
3,
259,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
260,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
259,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
259,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
2428,
199,
3,
259,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
1666,
314,
199,
3,
259,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
4204,
199,
3,
259,
1334,
314,
844,
14,
199,
199,
646,
2022,
199,
199,
646,
8809,
18,
199,
199,
14623,
63,
5580,
63,
2632,
275,
283,
1014,
921,
3183,
63,
2302,
14,
957,
15,
1178,
7,
199,
199,
8803,
275,
298,
3183,
63,
1418,
2,
199,
19600,
63,
8803,
275,
298,
4478,
63,
3183,
63,
1418,
2,
199,
199,
3,
7777,
22034,
373,
18,
5262,
199,
6790,
4586,
63,
21054,
51,
63,
54,
18,
275,
469,
272,
298,
14461,
582,
359,
267,
469,
288,
298,
2113,
2632,
582,
298,
1014,
921,
3183,
63,
633,
15,
86,
18,
15,
2246,
63,
6520,
15,
2113,
401,
288,
298,
4551,
582,
298,
1944,
4486,
10708,
401,
288,
298,
4672,
2632,
582,
298,
1014,
921,
3183,
63,
633,
15,
86,
18,
15,
2246,
63,
6520,
15,
4672,
401,
288,
298,
3455,
2632,
582,
298,
1014,
921,
3183,
63,
633,
15,
86,
18,
15,
2246,
63,
6520,
15,
3455,
2,
267,
1660,
267,
469,
288,
298,
2113,
2632,
582,
298,
1014,
921,
3183,
63,
633,
15,
86,
18,
15,
4375,
63,
6520,
15,
2113,
401,
288,
298,
4551,
582,
298,
8249,
10708,
401,
288,
298,
4672,
2632,
582,
298,
1014,
921,
3183,
63,
633,
15,
86,
18,
15,
4375,
63,
6520,
15,
4672,
401,
288,
298,
3455,
2632,
582,
298,
1014,
921,
3183,
63,
633,
15,
86,
18,
15,
4375,
63,
6520,
15,
3455,
2,
267,
1660,
272,
2156,
272,
298,
466,
582,
298,
3357,
401,
272,
298,
354,
582,
298,
6765,
2,
199,
93,
199,
199,
11206,
23622,
63,
54,
18,
275,
359,
6790,
4586,
63,
21054,
51,
63,
54,
18,
12,
1622,
199,
199,
19600,
63,
7466,
1922,
63,
54,
18,
63,
12801,
275,
469,
272,
298,
2732,
582,
469,
267,
298,
1418,
582,
469,
288,
298,
12342,
582,
298,
13934,
13,
614,
13,
614,
52,
383,
26,
383,
26,
709,
58,
401,
288,
298,
344,
582,
12112,
52,
63,
8803,
12,
288,
298,
4647,
582,
469,
355,
298,
344,
582,
298,
3183,
63,
4647,
63,
344,
2,
288,
1660,
267,
1660,
267,
298,
751,
582,
469,
288,
298,
344,
582,
298,
3183,
63,
751,
63,
344,
401,
267,
1660,
267,
298,
1364,
17161,
582,
445,
619,
23622,
63,
54,
18,
12,
272,
1660,
199,
93,
199,
199,
7466,
1922,
63,
54,
18,
63,
12801,
275,
469,
272,
298,
2732,
582,
469,
267,
298,
1418,
582,
469,
288,
298,
12342,
582,
298,
13934,
13,
614,
13,
614,
52,
383,
26,
383,
26,
709,
58,
401,
288,
298,
344,
582,
18243,
12,
288,
298,
4647,
582,
469,
355,
298,
344,
582,
298,
3183,
63,
4647,
63,
344,
2,
288,
1660,
267,
1660,
267,
298,
751,
582,
469,
288,
298,
344,
582,
298,
3183,
63,
751,
63,
344,
401,
267,
1660,
267,
298,
1364,
17161,
582,
445,
619,
23622,
63,
54,
18,
12,
272,
1660,
199,
93,
199,
199,
3,
7777,
22034,
812,
19,
5262,
199,
6790,
4586,
63,
21054,
51,
63,
54,
19,
275,
469,
272,
298,
14461,
582,
359,
267,
469,
288,
298,
344,
582,
298,
2246,
63,
3357,
63,
3183,
63,
1364,
401,
288,
298,
3266,
582,
298,
3455,
401,
288,
298,
4551,
582,
298,
1944,
4486,
10708,
401,
288,
298,
633,
582,
298,
1014,
921,
3183,
63,
633,
15,
86,
19,
15,
2246,
63,
6520,
15,
1246,
2,
267,
1660,
267,
469,
288,
298,
344,
582,
298,
4375,
63,
3183,
63,
1364,
401,
288,
298,
3266,
582,
298,
3455,
401,
288,
298,
4551,
582,
298,
8249,
10708,
401,
288,
298,
633,
582,
298,
1014,
921,
3183,
63,
633,
15,
86,
19,
15,
4375,
63,
6520,
15,
1246,
2,
267,
1660,
267,
469,
288,
298,
344,
582,
298,
11470,
63,
3183,
63,
1364,
401,
288,
298,
3266,
582,
298,
2113,
401,
288,
298,
4551,
582,
298,
30734,
37,
19677,
10708,
401,
288,
298,
633,
582,
298,
1014,
921,
3183,
63,
633,
15,
86,
19,
15,
11470,
63,
6520,
15,
1246,
2,
267,
789,
339,
2156,
272,
298,
466,
582,
298,
3357,
401,
272,
298,
344,
582,
298,
3183,
63,
3357,
63,
6520,
2,
199,
93,
199,
199,
11206,
23622,
63,
54,
19,
275,
359,
6790,
4586,
63,
21054,
51,
63,
54,
19,
12,
1622,
199,
199,
7466,
1922,
63,
54,
19,
63,
12801,
275,
469,
272,
298,
1418,
582,
469,
267,
298,
2474,
582,
359,
288,
298,
1418,
401,
288,
298,
2060,
2,
267,
2156,
267,
298,
12342,
63,
292,
582,
298,
13934,
13,
614,
13,
614,
52,
383,
26,
383,
26,
709,
14,
4183,
1789,
58,
401,
267,
298,
1715,
582,
469,
288,
298,
2261,
582,
469,
355,
298,
344,
582,
298,
3183,
63,
2261,
63,
344,
401,
355,
298,
354,
582,
298,
3183,
2,
288,
1660,
288,
298,
344,
582,
298,
1715,
63,
344,
401,
288,
298,
354,
582,
298,
1715,
63,
354,
2,
267,
1660,
267,
298,
751,
582,
469,
288,
298,
2261,
582,
469,
355,
298,
344,
582,
298,
3183,
63,
2261,
63,
344,
401,
355,
298,
354,
582,
298,
2261,
63,
354,
2,
288,
1660,
288,
298,
344,
582,
298,
3183,
63,
751,
63,
344,
401,
288,
298,
354,
582,
298,
2473,
2,
267,
1660,
267,
298,
5237,
68,
63,
292,
582,
298,
6965,
13,
1717,
13,
1398,
52,
975,
26,
1229,
26,
2025,
14,
2466,
1407,
2259,
58,
401,
267,
298,
7959,
582,
445,
619,
23622,
63,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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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
] |
hanicker/odoo
|
openerp/tools/parse_version.py
|
380
|
4462
|
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2009 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/>.
#
##############################################################################
## this functions are taken from the setuptools package (version 0.6c8)
## http://peak.telecommunity.com/DevCenter/PkgResources#parsing-utilities
import re
component_re = re.compile(r'(\d+ | [a-z]+ | \.| -)', re.VERBOSE)
replace = {'pre':'c', 'preview':'c','-':'final-','_':'final-','rc':'c','dev':'@','saas':'','~':''}.get
def _parse_version_parts(s):
for part in component_re.split(s):
part = replace(part,part)
if not part or part=='.':
continue
if part[:1] in '0123456789':
yield part.zfill(8) # pad for numeric comparison
else:
yield '*'+part
yield '*final' # ensure that alpha/beta/candidate are before final
def parse_version(s):
"""Convert a version string to a chronologically-sortable key
This is a rough cross between distutils' StrictVersion and LooseVersion;
if you give it versions that would work with StrictVersion, then it behaves
the same; otherwise it acts like a slightly-smarter LooseVersion. It is
*possible* to create pathological version coding schemes that will fool
this parser, but they should be very rare in practice.
The returned value will be a tuple of strings. Numeric portions of the
version are padded to 8 digits so they will compare numerically, but
without relying on how numbers compare relative to strings. Dots are
dropped, but dashes are retained. Trailing zeros between alpha segments
or dashes are suppressed, so that e.g. "2.4.0" is considered the same as
"2.4". Alphanumeric parts are lower-cased.
The algorithm assumes that strings like "-" and any alpha string that
alphabetically follows "final" represents a "patch level". So, "2.4-1"
is assumed to be a branch or patch of "2.4", and therefore "2.4.1" is
considered newer than "2.4-1", whic in turn is newer than "2.4".
Strings like "a", "b", "c", "alpha", "beta", "candidate" and so on (that
come before "final" alphabetically) are assumed to be pre-release versions,
so that the version "2.4" is considered newer than "2.4a1".
Finally, to handle miscellaneous cases, the strings "pre", "preview", and
"rc" are treated as if they were "c", i.e. as though they were release
candidates, and therefore are not as new as a version string that does not
contain them.
"""
parts = []
for part in _parse_version_parts((s or '0.1').lower()):
if part.startswith('*'):
if part<'*final': # remove '-' before a prerelease tag
while parts and parts[-1]=='*final-': parts.pop()
# remove trailing zeros from each series of numeric parts
while parts and parts[-1]=='00000000':
parts.pop()
parts.append(part)
return tuple(parts)
if __name__ == '__main__':
def cmp(a, b):
msg = '%s < %s == %s' % (a, b, a < b)
assert a < b, msg
return b
def chk(lst, verbose=False):
pvs = []
for v in lst:
pv = parse_version(v)
pvs.append(pv)
if verbose:
print v, pv
reduce(cmp, pvs)
chk(('0', '4.2', '4.2.3.4', '5.0.0-alpha', '5.0.0-rc1', '5.0.0-rc1.1', '5.0.0_rc2', '5.0.0_rc3', '5.0.0'), False)
chk(('5.0.0-0_rc3', '5.0.0-1dev', '5.0.0-1'), False)
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
agpl-3.0
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
4605,
199,
3,
258,
199,
3,
259,
7653,
12,
3232,
5800,
8259,
9274,
199,
3,
259,
1898,
334,
35,
9,
8353,
13,
8664,
11947,
12361,
8642,
1014,
921,
9864,
14,
1235,
10121,
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,
420,
199,
3,
199,
4605,
199,
199,
309,
642,
3423,
787,
9394,
687,
314,
9116,
2559,
334,
1023,
378,
14,
22,
67,
24,
9,
199,
309,
1455,
921,
8556,
14,
15253,
9387,
14,
957,
15,
12680,
13551,
15,
26878,
13745,
3,
11059,
13,
16355,
199,
199,
646,
295,
199,
199,
3173,
63,
264,
275,
295,
14,
2014,
8,
82,
13445,
68,
11,
1204,
359,
65,
13,
90,
2807,
1204,
971,
14,
92,
446,
3196,
295,
14,
16075,
9,
199,
1814,
275,
791,
657,
5242,
67,
297,
283,
7780,
5242,
67,
21810,
5242,
5094,
13,
1673,
63,
5242,
5094,
13,
1673,
1195,
5242,
67,
1673,
2374,
5242,
32,
1673,
2231,
305,
5242,
1673,
94,
356,
891,
5565,
362,
199,
199,
318,
485,
1122,
63,
1023,
63,
4181,
8,
83,
304,
272,
367,
1777,
315,
3931,
63,
264,
14,
1294,
8,
83,
304,
267,
1777,
275,
3350,
8,
2064,
12,
2064,
9,
267,
340,
440,
1777,
503,
1777,
389,
1370,
356,
288,
1980,
267,
340,
1777,
1491,
17,
61,
315,
283,
11371,
356,
288,
1995,
1777,
14,
26626,
8,
24,
9,
259,
327,
6567,
367,
8950,
9132,
267,
587,
26,
288,
1995,
6438,
6828,
2064,
339,
1995,
6438,
5094,
7,
221,
327,
4868,
626,
5131,
15,
5683,
15,
9007,
787,
2544,
4242,
199,
199,
318,
2198,
63,
1023,
8,
83,
304,
272,
408,
7306,
282,
1015,
1059,
370,
282,
682,
2641,
79,
793,
7288,
13,
3191,
461,
790,
339,
961,
365,
282,
28568,
8059,
3382,
7065,
7,
23052,
3353,
436,
18462,
27,
272,
340,
1265,
8120,
652,
5459,
626,
3955,
1736,
543,
23052,
3353,
12,
2066,
652,
25113,
272,
314,
2011,
27,
4257,
652,
17795,
2839,
282,
18023,
13,
3300,
16972,
18462,
14,
2779,
365,
272,
627,
13893,
10,
370,
1218,
931,
79,
7954,
1015,
2803,
21149,
626,
911,
7090,
393,
272,
642,
1798,
12,
1325,
2985,
1077,
506,
7437,
24063,
315,
24471,
14,
339,
710,
2138,
574,
911,
506,
282,
2008,
402,
3326,
14,
221,
19378,
12468,
402,
314,
272,
1015,
787,
21824,
370,
1695,
7576,
880,
2985,
911,
6540,
8950,
1183,
12,
1325,
272,
1928,
295,
6670,
641,
4212,
5579,
6540,
3847,
370,
3326,
14,
221,
577,
16673,
787,
272,
17481,
12,
1325,
21106,
787,
30403,
14,
221,
12643,
5662,
10136,
3382,
5131,
11998,
272,
503,
21106,
787,
30581,
12,
880,
626,
325,
14,
71,
14,
298,
18,
14,
20,
14,
16,
2,
365,
8652,
314,
2011,
465,
272,
298,
18,
14,
20,
1674,
4580,
16014,
4105,
4184,
787,
5117,
13,
32738,
14,
339,
710,
5563,
15194,
626,
3326,
2839,
17155,
436,
1263,
5131,
1059,
626,
272,
23331,
17269,
11924,
298,
5094,
2,
221,
8469,
282,
298,
2068,
2166,
1674,
221,
2002,
12,
298,
18,
14,
20,
13,
17,
2,
272,
365,
10826,
370,
506,
282,
5246,
503,
3371,
402,
298,
18,
14,
20,
401,
436,
16119,
298,
18,
14,
20,
14,
17,
2,
365,
272,
8652,
15666,
2419,
298,
18,
14,
20,
13,
17,
401,
704,
530,
315,
7485,
365,
15666,
2419,
298,
18,
14,
20,
1674,
339,
24361,
2839,
298,
65,
401,
298,
66,
401,
298,
67,
401,
298,
4468,
401,
298,
5683,
401,
298,
9007,
2,
436,
880,
641,
334,
9099,
272,
11492,
2544,
298,
5094,
2,
23331,
17269,
9,
787,
10826,
370,
506,
876,
13,
3221,
5459,
12,
272,
880,
626,
314,
1015,
298,
18,
14,
20,
2,
365,
8652,
15666,
2419,
298,
18,
14,
20,
65,
17,
1674,
339,
19177,
12,
370,
2429,
3201,
19549,
5560,
12,
314,
3326,
298,
657,
401,
298,
7780,
401,
436,
272,
298,
1195,
2,
787,
10184,
465,
340,
2985,
4898,
298,
67,
401,
284,
14,
69,
14,
465,
10617,
2985,
4898,
4683,
272,
15101,
12,
436,
16119,
787,
440,
465,
892,
465,
282,
1015,
1059,
626,
1630,
440,
272,
1395,
3062,
14,
272,
408,
272,
4184,
275,
942,
272,
367,
1777,
315,
485,
1122,
63,
1023,
63,
4181,
1332,
83,
503,
283,
16,
14,
17,
1959,
2325,
5109,
267,
340,
1777,
14,
2460,
18225,
735,
288,
340,
1777,
28,
16804,
5094,
356,
257,
327,
2813,
10791,
2544,
282,
876,
3221,
1947,
355,
1830,
4184,
436,
4184,
1988,
17,
22954,
10,
5094,
13,
356,
4184,
14,
1935,
342,
288,
327,
2813,
8520,
10136,
687,
1924,
6779,
402,
8950,
4184,
288,
1830,
4184,
436,
4184,
1988,
17,
22954,
3607,
356,
355,
4184,
14,
1935,
342,
267,
4184,
14,
740,
8,
2064,
9,
272,
372,
2008,
8,
4181,
9,
199,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
2728,
347,
10467,
8,
65,
12,
330,
304,
288,
1499,
275,
1543,
83,
665,
450,
83,
508,
450,
83,
7,
450,
334,
65,
12,
330,
12,
282,
665,
330,
9,
288,
702,
282,
665,
330,
12,
1499,
288,
372,
330,
398,
347,
26979,
8,
6916,
12,
3376,
29,
797,
304,
288,
299,
3122,
275,
942,
288,
367,
373,
315,
9877,
26,
355,
20279,
275,
2198,
63,
1023,
8,
86,
9,
355,
299,
3122,
14,
740,
8,
1381,
9,
355,
340,
3376,
26
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
4605,
199,
3,
258,
199,
3,
259,
7653,
12,
3232,
5800,
8259,
9274,
199,
3,
259,
1898,
334,
35,
9,
8353,
13,
8664,
11947,
12361,
8642,
1014,
921,
9864,
14,
1235,
10121,
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,
420,
199,
3,
199,
4605,
199,
199,
309,
642,
3423,
787,
9394,
687,
314,
9116,
2559,
334,
1023,
378,
14,
22,
67,
24,
9,
199,
309,
1455,
921,
8556,
14,
15253,
9387,
14,
957,
15,
12680,
13551,
15,
26878,
13745,
3,
11059,
13,
16355,
199,
199,
646,
295,
199,
199,
3173,
63,
264,
275,
295,
14,
2014,
8,
82,
13445,
68,
11,
1204,
359,
65,
13,
90,
2807,
1204,
971,
14,
92,
446,
3196,
295,
14,
16075,
9,
199,
1814,
275,
791,
657,
5242,
67,
297,
283,
7780,
5242,
67,
21810,
5242,
5094,
13,
1673,
63,
5242,
5094,
13,
1673,
1195,
5242,
67,
1673,
2374,
5242,
32,
1673,
2231,
305,
5242,
1673,
94,
356,
891,
5565,
362,
199,
199,
318,
485,
1122,
63,
1023,
63,
4181,
8,
83,
304,
272,
367,
1777,
315,
3931,
63,
264,
14,
1294,
8,
83,
304,
267,
1777,
275,
3350,
8,
2064,
12,
2064,
9,
267,
340,
440,
1777,
503,
1777,
389,
1370,
356,
288,
1980,
267,
340,
1777,
1491,
17,
61,
315,
283,
11371,
356,
288,
1995,
1777,
14,
26626,
8,
24,
9,
259,
327,
6567,
367,
8950,
9132,
267,
587,
26,
288,
1995,
6438,
6828,
2064,
339,
1995,
6438,
5094,
7,
221,
327,
4868,
626,
5131,
15,
5683,
15,
9007,
787,
2544,
4242,
199,
199,
318,
2198,
63,
1023,
8,
83,
304,
272,
408,
7306,
282,
1015,
1059,
370,
282,
682,
2641,
79,
793,
7288,
13,
3191,
461,
790,
339,
961,
365,
282,
28568,
8059,
3382,
7065,
7,
23052,
3353,
436,
18462,
27,
272,
340,
1265,
8120,
652,
5459,
626,
3955,
1736,
543,
23052,
3353,
12,
2066,
652,
25113,
272,
314,
2011,
27,
4257,
652,
17795,
2839,
282,
18023,
13,
3300,
16972,
18462,
14,
2779,
365,
272,
627,
13893,
10,
370,
1218,
931,
79,
7954,
1015,
2803,
21149,
626,
911,
7090,
393,
272,
642,
1798,
12,
1325,
2985,
1077,
506,
7437,
24063,
315,
24471,
14,
339,
710,
2138,
574,
911,
506,
282,
2008,
402,
3326,
14,
221,
19378,
12468,
402,
314,
272,
1015,
787,
21824,
370,
1695,
7576,
880,
2985,
911,
6540,
8950,
1183,
12,
1325,
272,
1928,
295,
6670,
641,
4212,
5579,
6540,
3847,
370,
3326,
14,
221,
577,
16673,
787,
272,
17481,
12,
1325,
21106,
787,
30403,
14,
221,
12643,
5662,
10136,
3382,
5131,
11998,
272,
503,
21106,
787,
30581,
12,
880,
626,
325,
14,
71,
14,
298,
18,
14,
20,
14,
16,
2,
365,
8652,
314,
2011,
465,
272,
298,
18,
14,
20,
1674,
4580,
16014,
4105,
4184,
787,
5117,
13,
32738,
14,
339,
710,
5563,
15194,
626,
3326,
2839,
17155,
436,
1263,
5131,
1059,
626,
272,
23331,
17269,
11924,
298,
5094,
2,
221,
8469,
282,
298,
2068,
2166,
1674,
221,
2002,
12,
298,
18,
14,
20,
13,
17,
2,
272,
365,
10826,
370,
506,
282,
5246,
503,
3371,
402,
298,
18,
14,
20,
401,
436,
16119,
298,
18,
14,
20,
14,
17,
2,
365,
272,
8652,
15666,
2419,
298,
18,
14,
20,
13,
17,
401,
704,
530,
315,
7485,
365,
15666,
2419,
298,
18,
14,
20,
1674,
339,
24361,
2839,
298,
65,
401,
298,
66,
401,
298,
67,
401,
298,
4468,
401,
298,
5683,
401,
298,
9007,
2,
436,
880,
641,
334,
9099,
272,
11492,
2544,
298,
5094,
2,
23331,
17269,
9,
787,
10826,
370,
506,
876,
13,
3221,
5459,
12,
272,
880,
626,
314,
1015,
298,
18,
14,
20,
2,
365,
8652,
15666,
2419,
298,
18,
14,
20,
65,
17,
1674,
339,
19177,
12,
370,
2429,
3201,
19549,
5560,
12,
314,
3326,
298,
657,
401,
298,
7780,
401,
436,
272,
298,
1195,
2,
787,
10184,
465,
340,
2985,
4898,
298,
67,
401,
284,
14,
69,
14,
465,
10617,
2985,
4898,
4683,
272,
15101,
12,
436,
16119,
787,
440,
465,
892,
465,
282,
1015,
1059,
626,
1630,
440,
272,
1395,
3062,
14,
272,
408,
272,
4184,
275,
942,
272,
367,
1777,
315,
485,
1122,
63,
1023,
63,
4181,
1332,
83,
503,
283,
16,
14,
17,
1959,
2325,
5109,
267,
340,
1777,
14,
2460,
18225,
735,
288,
340,
1777,
28,
16804,
5094,
356,
257,
327,
2813,
10791,
2544,
282,
876,
3221,
1947,
355,
1830,
4184,
436,
4184,
1988,
17,
22954,
10,
5094,
13,
356,
4184,
14,
1935,
342,
288,
327,
2813,
8520,
10136,
687,
1924,
6779,
402,
8950,
4184,
288,
1830,
4184,
436,
4184,
1988,
17,
22954,
3607,
356,
355,
4184,
14,
1935,
342,
267,
4184,
14,
740,
8,
2064,
9,
272,
372,
2008,
8,
4181,
9,
199,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
2728,
347,
10467,
8,
65,
12,
330,
304,
288,
1499,
275,
1543,
83,
665,
450,
83,
508,
450,
83,
7,
450,
334,
65,
12,
330,
12,
282,
665,
330,
9,
288,
702,
282,
665,
330,
12,
1499,
288,
372,
330,
398,
347,
26979,
8,
6916,
12,
3376,
29,
797,
304,
288,
299,
3122,
275,
942,
288,
367,
373,
315,
9877,
26,
355,
20279,
275,
2198,
63,
1023,
8,
86,
9,
355,
299,
3122,
14,
740,
8,
1381,
9,
355,
340,
3376,
26,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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common.py
|
1292
|
20063
|
# Copyright (c) 2012 Google Inc. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
from __future__ import with_statement
import collections
import errno
import filecmp
import os.path
import re
import tempfile
import sys
# A minimal memoizing decorator. It'll blow up if the args aren't immutable,
# among other "problems".
class memoize(object):
def __init__(self, func):
self.func = func
self.cache = {}
def __call__(self, *args):
try:
return self.cache[args]
except KeyError:
result = self.func(*args)
self.cache[args] = result
return result
class GypError(Exception):
"""Error class representing an error, which is to be presented
to the user. The main entry point will catch and display this.
"""
pass
def ExceptionAppend(e, msg):
"""Append a message to the given exception's message."""
if not e.args:
e.args = (msg,)
elif len(e.args) == 1:
e.args = (str(e.args[0]) + ' ' + msg,)
else:
e.args = (str(e.args[0]) + ' ' + msg,) + e.args[1:]
def FindQualifiedTargets(target, qualified_list):
"""
Given a list of qualified targets, return the qualified targets for the
specified |target|.
"""
return [t for t in qualified_list if ParseQualifiedTarget(t)[1] == target]
def ParseQualifiedTarget(target):
# Splits a qualified target into a build file, target name and toolset.
# NOTE: rsplit is used to disambiguate the Windows drive letter separator.
target_split = target.rsplit(':', 1)
if len(target_split) == 2:
[build_file, target] = target_split
else:
build_file = None
target_split = target.rsplit('#', 1)
if len(target_split) == 2:
[target, toolset] = target_split
else:
toolset = None
return [build_file, target, toolset]
def ResolveTarget(build_file, target, toolset):
# This function resolves a target into a canonical form:
# - a fully defined build file, either absolute or relative to the current
# directory
# - a target name
# - a toolset
#
# build_file is the file relative to which 'target' is defined.
# target is the qualified target.
# toolset is the default toolset for that target.
[parsed_build_file, target, parsed_toolset] = ParseQualifiedTarget(target)
if parsed_build_file:
if build_file:
# If a relative path, parsed_build_file is relative to the directory
# containing build_file. If build_file is not in the current directory,
# parsed_build_file is not a usable path as-is. Resolve it by
# interpreting it as relative to build_file. If parsed_build_file is
# absolute, it is usable as a path regardless of the current directory,
# and os.path.join will return it as-is.
build_file = os.path.normpath(os.path.join(os.path.dirname(build_file),
parsed_build_file))
# Further (to handle cases like ../cwd), make it relative to cwd)
if not os.path.isabs(build_file):
build_file = RelativePath(build_file, '.')
else:
build_file = parsed_build_file
if parsed_toolset:
toolset = parsed_toolset
return [build_file, target, toolset]
def BuildFile(fully_qualified_target):
# Extracts the build file from the fully qualified target.
return ParseQualifiedTarget(fully_qualified_target)[0]
def GetEnvironFallback(var_list, default):
"""Look up a key in the environment, with fallback to secondary keys
and finally falling back to a default value."""
for var in var_list:
if var in os.environ:
return os.environ[var]
return default
def QualifiedTarget(build_file, target, toolset):
# "Qualified" means the file that a target was defined in and the target
# name, separated by a colon, suffixed by a # and the toolset name:
# /path/to/file.gyp:target_name#toolset
fully_qualified = build_file + ':' + target
if toolset:
fully_qualified = fully_qualified + '#' + toolset
return fully_qualified
@memoize
def RelativePath(path, relative_to, follow_path_symlink=True):
# Assuming both |path| and |relative_to| are relative to the current
# directory, returns a relative path that identifies path relative to
# relative_to.
# If |follow_symlink_path| is true (default) and |path| is a symlink, then
# this method returns a path to the real file represented by |path|. If it is
# false, this method returns a path to the symlink. If |path| is not a
# symlink, this option has no effect.
# Convert to normalized (and therefore absolute paths).
if follow_path_symlink:
path = os.path.realpath(path)
else:
path = os.path.abspath(path)
relative_to = os.path.realpath(relative_to)
# On Windows, we can't create a relative path to a different drive, so just
# use the absolute path.
if sys.platform == 'win32':
if (os.path.splitdrive(path)[0].lower() !=
os.path.splitdrive(relative_to)[0].lower()):
return path
# Split the paths into components.
path_split = path.split(os.path.sep)
relative_to_split = relative_to.split(os.path.sep)
# Determine how much of the prefix the two paths share.
prefix_len = len(os.path.commonprefix([path_split, relative_to_split]))
# Put enough ".." components to back up out of relative_to to the common
# prefix, and then append the part of path_split after the common prefix.
relative_split = [os.path.pardir] * (len(relative_to_split) - prefix_len) + \
path_split[prefix_len:]
if len(relative_split) == 0:
# The paths were the same.
return ''
# Turn it back into a string and we're done.
return os.path.join(*relative_split)
@memoize
def InvertRelativePath(path, toplevel_dir=None):
"""Given a path like foo/bar that is relative to toplevel_dir, return
the inverse relative path back to the toplevel_dir.
E.g. os.path.normpath(os.path.join(path, InvertRelativePath(path)))
should always produce the empty string, unless the path contains symlinks.
"""
if not path:
return path
toplevel_dir = '.' if toplevel_dir is None else toplevel_dir
return RelativePath(toplevel_dir, os.path.join(toplevel_dir, path))
def FixIfRelativePath(path, relative_to):
# Like RelativePath but returns |path| unchanged if it is absolute.
if os.path.isabs(path):
return path
return RelativePath(path, relative_to)
def UnrelativePath(path, relative_to):
# Assuming that |relative_to| is relative to the current directory, and |path|
# is a path relative to the dirname of |relative_to|, returns a path that
# identifies |path| relative to the current directory.
rel_dir = os.path.dirname(relative_to)
return os.path.normpath(os.path.join(rel_dir, path))
# re objects used by EncodePOSIXShellArgument. See IEEE 1003.1 XCU.2.2 at
# http://www.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#tag_02_02
# and the documentation for various shells.
# _quote is a pattern that should match any argument that needs to be quoted
# with double-quotes by EncodePOSIXShellArgument. It matches the following
# characters appearing anywhere in an argument:
# \t, \n, space parameter separators
# # comments
# $ expansions (quoted to always expand within one argument)
# % called out by IEEE 1003.1 XCU.2.2
# & job control
# ' quoting
# (, ) subshell execution
# *, ?, [ pathname expansion
# ; command delimiter
# <, >, | redirection
# = assignment
# {, } brace expansion (bash)
# ~ tilde expansion
# It also matches the empty string, because "" (or '') is the only way to
# represent an empty string literal argument to a POSIX shell.
#
# This does not match the characters in _escape, because those need to be
# backslash-escaped regardless of whether they appear in a double-quoted
# string.
_quote = re.compile('[\t\n #$%&\'()*;<=>?[{|}~]|^$')
# _escape is a pattern that should match any character that needs to be
# escaped with a backslash, whether or not the argument matched the _quote
# pattern. _escape is used with re.sub to backslash anything in _escape's
# first match group, hence the (parentheses) in the regular expression.
#
# _escape matches the following characters appearing anywhere in an argument:
# " to prevent POSIX shells from interpreting this character for quoting
# \ to prevent POSIX shells from interpreting this character for escaping
# ` to prevent POSIX shells from interpreting this character for command
# substitution
# Missing from this list is $, because the desired behavior of
# EncodePOSIXShellArgument is to permit parameter (variable) expansion.
#
# Also missing from this list is !, which bash will interpret as the history
# expansion character when history is enabled. bash does not enable history
# by default in non-interactive shells, so this is not thought to be a problem.
# ! was omitted from this list because bash interprets "\!" as a literal string
# including the backslash character (avoiding history expansion but retaining
# the backslash), which would not be correct for argument encoding. Handling
# this case properly would also be problematic because bash allows the history
# character to be changed with the histchars shell variable. Fortunately,
# as history is not enabled in non-interactive shells and
# EncodePOSIXShellArgument is only expected to encode for non-interactive
# shells, there is no room for error here by ignoring !.
_escape = re.compile(r'(["\\`])')
def EncodePOSIXShellArgument(argument):
"""Encodes |argument| suitably for consumption by POSIX shells.
argument may be quoted and escaped as necessary to ensure that POSIX shells
treat the returned value as a literal representing the argument passed to
this function. Parameter (variable) expansions beginning with $ are allowed
to remain intact without escaping the $, to allow the argument to contain
references to variables to be expanded by the shell.
"""
if not isinstance(argument, str):
argument = str(argument)
if _quote.search(argument):
quote = '"'
else:
quote = ''
encoded = quote + re.sub(_escape, r'\\\1', argument) + quote
return encoded
def EncodePOSIXShellList(list):
"""Encodes |list| suitably for consumption by POSIX shells.
Returns EncodePOSIXShellArgument for each item in list, and joins them
together using the space character as an argument separator.
"""
encoded_arguments = []
for argument in list:
encoded_arguments.append(EncodePOSIXShellArgument(argument))
return ' '.join(encoded_arguments)
def DeepDependencyTargets(target_dicts, roots):
"""Returns the recursive list of target dependencies."""
dependencies = set()
pending = set(roots)
while pending:
# Pluck out one.
r = pending.pop()
# Skip if visited already.
if r in dependencies:
continue
# Add it.
dependencies.add(r)
# Add its children.
spec = target_dicts[r]
pending.update(set(spec.get('dependencies', [])))
pending.update(set(spec.get('dependencies_original', [])))
return list(dependencies - set(roots))
def BuildFileTargets(target_list, build_file):
"""From a target_list, returns the subset from the specified build_file.
"""
return [p for p in target_list if BuildFile(p) == build_file]
def AllTargets(target_list, target_dicts, build_file):
"""Returns all targets (direct and dependencies) for the specified build_file.
"""
bftargets = BuildFileTargets(target_list, build_file)
deptargets = DeepDependencyTargets(target_dicts, bftargets)
return bftargets + deptargets
def WriteOnDiff(filename):
"""Write to a file only if the new contents differ.
Arguments:
filename: name of the file to potentially write to.
Returns:
A file like object which will write to temporary file and only overwrite
the target if it differs (on close).
"""
class Writer(object):
"""Wrapper around file which only covers the target if it differs."""
def __init__(self):
# Pick temporary file.
tmp_fd, self.tmp_path = tempfile.mkstemp(
suffix='.tmp',
prefix=os.path.split(filename)[1] + '.gyp.',
dir=os.path.split(filename)[0])
try:
self.tmp_file = os.fdopen(tmp_fd, 'wb')
except Exception:
# Don't leave turds behind.
os.unlink(self.tmp_path)
raise
def __getattr__(self, attrname):
# Delegate everything else to self.tmp_file
return getattr(self.tmp_file, attrname)
def close(self):
try:
# Close tmp file.
self.tmp_file.close()
# Determine if different.
same = False
try:
same = filecmp.cmp(self.tmp_path, filename, False)
except OSError, e:
if e.errno != errno.ENOENT:
raise
if same:
# The new file is identical to the old one, just get rid of the new
# one.
os.unlink(self.tmp_path)
else:
# The new file is different from the old one, or there is no old one.
# Rename the new file to the permanent name.
#
# tempfile.mkstemp uses an overly restrictive mode, resulting in a
# file that can only be read by the owner, regardless of the umask.
# There's no reason to not respect the umask here, which means that
# an extra hoop is required to fetch it and reset the new file's mode.
#
# No way to get the umask without setting a new one? Set a safe one
# and then set it back to the old value.
umask = os.umask(077)
os.umask(umask)
os.chmod(self.tmp_path, 0666 & ~umask)
if sys.platform == 'win32' and os.path.exists(filename):
# NOTE: on windows (but not cygwin) rename will not replace an
# existing file, so it must be preceded with a remove. Sadly there
# is no way to make the switch atomic.
os.remove(filename)
os.rename(self.tmp_path, filename)
except Exception:
# Don't leave turds behind.
os.unlink(self.tmp_path)
raise
return Writer()
def EnsureDirExists(path):
"""Make sure the directory for |path| exists."""
try:
os.makedirs(os.path.dirname(path))
except OSError:
pass
def GetFlavor(params):
"""Returns |params.flavor| if it's set, the system's default flavor else."""
flavors = {
'cygwin': 'win',
'win32': 'win',
'darwin': 'mac',
}
if 'flavor' in params:
return params['flavor']
if sys.platform in flavors:
return flavors[sys.platform]
if sys.platform.startswith('sunos'):
return 'solaris'
if sys.platform.startswith('freebsd'):
return 'freebsd'
if sys.platform.startswith('openbsd'):
return 'openbsd'
if sys.platform.startswith('netbsd'):
return 'netbsd'
if sys.platform.startswith('aix'):
return 'aix'
return 'linux'
def CopyTool(flavor, out_path):
"""Finds (flock|mac|win)_tool.gyp in the gyp directory and copies it
to |out_path|."""
# aix and solaris just need flock emulation. mac and win use more complicated
# support scripts.
prefix = {
'aix': 'flock',
'solaris': 'flock',
'mac': 'mac',
'win': 'win'
}.get(flavor, None)
if not prefix:
return
# Slurp input file.
source_path = os.path.join(
os.path.dirname(os.path.abspath(__file__)), '%s_tool.py' % prefix)
with open(source_path) as source_file:
source = source_file.readlines()
# Add header and write it out.
tool_path = os.path.join(out_path, 'gyp-%s-tool' % prefix)
with open(tool_path, 'w') as tool_file:
tool_file.write(
''.join([source[0], '# Generated by gyp. Do not edit.\n'] + source[1:]))
# Make file executable.
os.chmod(tool_path, 0755)
# From Alex Martelli,
# http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52560
# ASPN: Python Cookbook: Remove duplicates from a sequence
# First comment, dated 2001/10/13.
# (Also in the printed Python Cookbook.)
def uniquer(seq, idfun=None):
if idfun is None:
idfun = lambda x: x
seen = {}
result = []
for item in seq:
marker = idfun(item)
if marker in seen: continue
seen[marker] = 1
result.append(item)
return result
# Based on http://code.activestate.com/recipes/576694/.
class OrderedSet(collections.MutableSet):
def __init__(self, iterable=None):
self.end = end = []
end += [None, end, end] # sentinel node for doubly linked list
self.map = {} # key --> [key, prev, next]
if iterable is not None:
self |= iterable
def __len__(self):
return len(self.map)
def __contains__(self, key):
return key in self.map
def add(self, key):
if key not in self.map:
end = self.end
curr = end[1]
curr[2] = end[1] = self.map[key] = [key, curr, end]
def discard(self, key):
if key in self.map:
key, prev_item, next_item = self.map.pop(key)
prev_item[2] = next_item
next_item[1] = prev_item
def __iter__(self):
end = self.end
curr = end[2]
while curr is not end:
yield curr[0]
curr = curr[2]
def __reversed__(self):
end = self.end
curr = end[1]
while curr is not end:
yield curr[0]
curr = curr[1]
# The second argument is an addition that causes a pylint warning.
def pop(self, last=True): # pylint: disable=W0221
if not self:
raise KeyError('set is empty')
key = self.end[1][0] if last else self.end[2][0]
self.discard(key)
return key
def __repr__(self):
if not self:
return '%s()' % (self.__class__.__name__,)
return '%s(%r)' % (self.__class__.__name__, list(self))
def __eq__(self, other):
if isinstance(other, OrderedSet):
return len(self) == len(other) and list(self) == list(other)
return set(self) == set(other)
# Extensions to the recipe.
def update(self, iterable):
for i in iterable:
if i not in self:
self.add(i)
class CycleError(Exception):
"""An exception raised when an unexpected cycle is detected."""
def __init__(self, nodes):
self.nodes = nodes
def __str__(self):
return 'CycleError: cycle involving: ' + str(self.nodes)
def TopologicallySorted(graph, get_edges):
r"""Topologically sort based on a user provided edge definition.
Args:
graph: A list of node names.
get_edges: A function mapping from node name to a hashable collection
of node names which this node has outgoing edges to.
Returns:
A list containing all of the node in graph in topological order.
It is assumed that calling get_edges once for each node and caching is
cheaper than repeatedly calling get_edges.
Raises:
CycleError in the event of a cycle.
Example:
graph = {'a': '$(b) $(c)', 'b': 'hi', 'c': '$(b)'}
def GetEdges(node):
return re.findall(r'\$\(([^))]\)', graph[node])
print TopologicallySorted(graph.keys(), GetEdges)
==>
['a', 'c', b']
"""
get_edges = memoize(get_edges)
visited = set()
visiting = set()
ordered_nodes = []
def Visit(node):
if node in visiting:
raise CycleError(visiting)
if node in visited:
return
visited.add(node)
visiting.add(node)
for neighbor in get_edges(node):
Visit(neighbor)
visiting.remove(node)
ordered_nodes.insert(0, node)
for node in sorted(graph):
Visit(node)
return ordered_nodes
def CrossCompileRequested():
# TODO: figure out how to not build extra host objects in the
# non-cross-compile case when this is enabled, and enable unconditionally.
return (os.environ.get('GYP_CROSSCOMPILE') or
os.environ.get('AR_host') or
os.environ.get('CC_host') or
os.environ.get('CXX_host') or
os.environ.get('AR_target') or
os.environ.get('CC_target') or
os.environ.get('CXX_target'))
|
mit
|
[
3,
1898,
334,
67,
9,
6029,
4475,
3277,
14,
2900,
4481,
4644,
14,
199,
3,
3645,
402,
642,
1350,
1233,
365,
10413,
701,
282,
6289,
13,
2487,
4190,
626,
883,
506,
199,
3,
1911,
315,
314,
5113,
570,
14,
199,
199,
504,
636,
2443,
363,
492,
543,
63,
6242,
199,
199,
646,
5055,
199,
646,
7554,
199,
646,
570,
5730,
199,
646,
747,
14,
515,
199,
646,
295,
199,
646,
5549,
199,
646,
984,
421,
199,
3,
437,
13460,
11955,
9147,
7531,
14,
2779,
7171,
28511,
1536,
340,
314,
1249,
10621,
1133,
17092,
12,
199,
3,
16885,
1163,
298,
22959,
1674,
199,
533,
11955,
794,
8,
785,
304,
523,
347,
636,
826,
721,
277,
12,
2562,
304,
272,
291,
14,
1532,
275,
2562,
272,
291,
14,
1637,
275,
1052,
523,
347,
636,
1250,
721,
277,
12,
627,
589,
304,
272,
862,
26,
489,
372,
291,
14,
1637,
59,
589,
61,
272,
871,
4067,
26,
489,
754,
275,
291,
14,
1532,
2031,
589,
9,
489,
291,
14,
1637,
59,
589,
61,
275,
754,
489,
372,
754,
421,
199,
533,
18151,
8,
1726,
304,
523,
408,
547,
1021,
6144,
376,
1125,
12,
1314,
365,
370,
506,
26568,
523,
370,
314,
922,
14,
221,
710,
2446,
2397,
2376,
911,
8579,
436,
2929,
642,
14,
523,
408,
523,
986,
421,
199,
318,
2186,
8310,
8,
69,
12,
1499,
304,
523,
408,
8310,
282,
1245,
370,
314,
1627,
1919,
1159,
1245,
1041,
523,
340,
440,
325,
14,
589,
26,
272,
325,
14,
589,
275,
334,
1328,
4258,
523,
916,
822,
8,
69,
14,
589,
9,
508,
413,
26,
272,
325,
14,
589,
275,
334,
495,
8,
69,
14,
589,
59,
16,
566,
435,
283,
283,
435,
1499,
4258,
523,
587,
26,
272,
325,
14,
589,
275,
334,
495,
8,
69,
14,
589,
59,
16,
566,
435,
283,
283,
435,
1499,
4258,
435,
325,
14,
589,
59,
17,
2938,
421,
199,
318,
6668,
23279,
14126,
8,
1375,
12,
12313,
63,
513,
304,
523,
408,
523,
9138,
282,
769,
402,
12313,
4545,
12,
372,
314,
12313,
4545,
367,
314,
523,
2013,
1204,
1375,
18257,
523,
408,
523,
372,
359,
84,
367,
307,
315,
12313,
63,
513,
340,
6077,
30663,
8,
84,
2788,
17,
61,
508,
1347,
61,
421,
199,
318,
6077,
30663,
8,
1375,
304,
523,
327,
11740,
83,
282,
12313,
1347,
1901,
282,
1900,
570,
12,
1347,
536,
436,
20070,
14,
819,
327,
6944,
26,
519,
1294,
365,
1202,
370,
2153,
16902,
4767,
314,
5417,
12912,
8082,
9432,
14,
523,
1347,
63,
1294,
275,
1347,
14,
13490,
16451,
413,
9,
523,
340,
822,
8,
1375,
63,
1294,
9,
508,
499,
26,
272,
359,
1506,
63,
493,
12,
1347,
61,
275,
1347,
63,
1294,
523,
587,
26,
272,
1900,
63,
493,
275,
488,
819,
1347,
63,
1294,
275,
1347,
14,
13490,
7863,
297,
413,
9,
523,
340,
822,
8,
1375,
63,
1294,
9,
508,
499,
26,
272,
359,
1375,
12,
20070,
61,
275,
1347,
63,
1294,
523,
587,
26,
272,
20070,
275,
488,
819,
372,
359,
1506,
63,
493,
12,
1347,
12,
20070,
61,
421,
199,
318,
31096,
4277,
8,
1506,
63,
493,
12,
1347,
12,
20070,
304,
523,
327,
961,
805,
32253,
282,
1347,
1901,
282,
11358,
1824,
26,
523,
327,
446,
282,
9999,
3247,
1900,
570,
12,
1902,
3679,
503,
3847,
370,
314,
1453,
523,
327,
2082,
523,
327,
446,
282,
1347,
536,
523,
327,
446,
282,
20070,
523,
327,
523,
327,
1900,
63,
493,
365,
314,
570,
3847,
370,
1314,
283,
1375,
7,
365,
3247,
14,
523,
327,
1347,
365,
314,
12313,
1347,
14,
523,
327,
20070,
365,
314,
849,
20070,
367,
626,
1347,
14,
523,
359,
6751,
63,
1506,
63,
493,
12,
1347,
12,
4565,
63,
12081,
61,
275,
6077,
30663,
8,
1375,
9,
819,
340,
4565,
63,
1506,
63,
493,
26,
272,
340,
1900,
63,
493,
26,
489,
327,
982,
282,
3847,
931,
12,
4565,
63,
1506,
63,
493,
365,
3847,
370,
314,
2082,
489,
327,
3035,
1900,
63,
493,
14,
221,
982,
1900,
63,
493,
365,
440,
315,
314,
1453,
2082,
12,
489,
327,
4565,
63,
1506,
63,
493,
365,
440,
282,
18025,
931,
465,
13,
374,
14,
221,
31096,
652,
701,
489,
327,
6421,
1337,
652,
465,
3847,
370,
1900,
63,
493,
14,
221,
982,
4565,
63,
1506,
63,
493,
365,
489,
327,
3679,
12,
652,
365,
18025,
465,
282,
931,
15270,
402,
314,
1453,
2082,
12,
489,
327,
436,
747,
14,
515,
14,
904,
911,
372,
652,
465,
13,
374,
14,
489,
1900,
63,
493,
275,
747,
14,
515,
14,
9267,
8,
736,
14,
515,
14,
904,
8,
736,
14,
515,
14,
3475,
8,
1506,
63,
493,
395,
1740,
4565,
63,
1506,
63,
493,
430,
489,
327,
28876,
334,
475,
2429,
5560,
2839,
24272,
6525,
395,
1852,
652,
3847,
370,
8288,
9,
489,
340,
440,
747,
14,
515,
14,
17896,
8,
1506,
63,
493,
304,
267,
1900,
63,
493,
275,
22419,
2042,
8,
1506,
63,
493,
12,
20093,
272,
587,
26,
489,
1900,
63,
493,
275,
4565,
63,
1506,
63,
493,
819,
340,
4565,
63,
12081,
26,
272,
20070,
275,
4565,
63,
12081,
819,
372,
359,
1506,
63,
493,
12,
1347,
12,
20070,
61,
421,
199,
318,
6516,
1173,
8,
5836,
63,
11661,
63,
1375,
304,
523,
327,
12892,
83,
314,
1900,
570,
687,
314,
9999,
12313,
1347,
14,
523,
372,
6077,
30663,
8,
5836,
63,
11661,
63,
1375,
2788,
16,
61,
421,
199,
318,
2372,
23027,
21860,
8,
1391,
63,
513,
12,
849,
304,
523,
408,
20926,
1536,
282,
790,
315,
314,
3734,
12,
543,
9567,
370,
13851,
2883,
523,
436,
3753,
32039,
1771,
370,
282,
849,
574,
1041,
523,
367,
2729,
315,
2729,
63,
513,
26,
272,
340,
2729,
315,
747,
14,
2314,
26,
489,
372,
747,
14,
2314,
59,
1391,
61,
523,
372,
849,
421,
199,
318,
19933,
4541,
4277,
8,
1506,
63,
493,
12,
1347,
12,
20070,
304,
523,
327,
298,
23279,
2,
4910,
314,
570,
626,
282,
1347,
1990,
3247,
315,
436,
314,
1347,
523,
327,
536,
12,
11673,
701,
282,
18307,
12,
4739,
379,
701,
282,
327,
436,
314,
20070,
536,
26,
523,
327,
1182,
515,
15,
475,
15,
493,
14,
6179,
26,
1375,
63,
354,
3
] |
[
1898,
334,
67,
9,
6029,
4475,
3277,
14,
2900,
4481,
4644,
14,
199,
3,
3645,
402,
642,
1350,
1233,
365,
10413,
701,
282,
6289,
13,
2487,
4190,
626,
883,
506,
199,
3,
1911,
315,
314,
5113,
570,
14,
199,
199,
504,
636,
2443,
363,
492,
543,
63,
6242,
199,
199,
646,
5055,
199,
646,
7554,
199,
646,
570,
5730,
199,
646,
747,
14,
515,
199,
646,
295,
199,
646,
5549,
199,
646,
984,
421,
199,
3,
437,
13460,
11955,
9147,
7531,
14,
2779,
7171,
28511,
1536,
340,
314,
1249,
10621,
1133,
17092,
12,
199,
3,
16885,
1163,
298,
22959,
1674,
199,
533,
11955,
794,
8,
785,
304,
523,
347,
636,
826,
721,
277,
12,
2562,
304,
272,
291,
14,
1532,
275,
2562,
272,
291,
14,
1637,
275,
1052,
523,
347,
636,
1250,
721,
277,
12,
627,
589,
304,
272,
862,
26,
489,
372,
291,
14,
1637,
59,
589,
61,
272,
871,
4067,
26,
489,
754,
275,
291,
14,
1532,
2031,
589,
9,
489,
291,
14,
1637,
59,
589,
61,
275,
754,
489,
372,
754,
421,
199,
533,
18151,
8,
1726,
304,
523,
408,
547,
1021,
6144,
376,
1125,
12,
1314,
365,
370,
506,
26568,
523,
370,
314,
922,
14,
221,
710,
2446,
2397,
2376,
911,
8579,
436,
2929,
642,
14,
523,
408,
523,
986,
421,
199,
318,
2186,
8310,
8,
69,
12,
1499,
304,
523,
408,
8310,
282,
1245,
370,
314,
1627,
1919,
1159,
1245,
1041,
523,
340,
440,
325,
14,
589,
26,
272,
325,
14,
589,
275,
334,
1328,
4258,
523,
916,
822,
8,
69,
14,
589,
9,
508,
413,
26,
272,
325,
14,
589,
275,
334,
495,
8,
69,
14,
589,
59,
16,
566,
435,
283,
283,
435,
1499,
4258,
523,
587,
26,
272,
325,
14,
589,
275,
334,
495,
8,
69,
14,
589,
59,
16,
566,
435,
283,
283,
435,
1499,
4258,
435,
325,
14,
589,
59,
17,
2938,
421,
199,
318,
6668,
23279,
14126,
8,
1375,
12,
12313,
63,
513,
304,
523,
408,
523,
9138,
282,
769,
402,
12313,
4545,
12,
372,
314,
12313,
4545,
367,
314,
523,
2013,
1204,
1375,
18257,
523,
408,
523,
372,
359,
84,
367,
307,
315,
12313,
63,
513,
340,
6077,
30663,
8,
84,
2788,
17,
61,
508,
1347,
61,
421,
199,
318,
6077,
30663,
8,
1375,
304,
523,
327,
11740,
83,
282,
12313,
1347,
1901,
282,
1900,
570,
12,
1347,
536,
436,
20070,
14,
819,
327,
6944,
26,
519,
1294,
365,
1202,
370,
2153,
16902,
4767,
314,
5417,
12912,
8082,
9432,
14,
523,
1347,
63,
1294,
275,
1347,
14,
13490,
16451,
413,
9,
523,
340,
822,
8,
1375,
63,
1294,
9,
508,
499,
26,
272,
359,
1506,
63,
493,
12,
1347,
61,
275,
1347,
63,
1294,
523,
587,
26,
272,
1900,
63,
493,
275,
488,
819,
1347,
63,
1294,
275,
1347,
14,
13490,
7863,
297,
413,
9,
523,
340,
822,
8,
1375,
63,
1294,
9,
508,
499,
26,
272,
359,
1375,
12,
20070,
61,
275,
1347,
63,
1294,
523,
587,
26,
272,
20070,
275,
488,
819,
372,
359,
1506,
63,
493,
12,
1347,
12,
20070,
61,
421,
199,
318,
31096,
4277,
8,
1506,
63,
493,
12,
1347,
12,
20070,
304,
523,
327,
961,
805,
32253,
282,
1347,
1901,
282,
11358,
1824,
26,
523,
327,
446,
282,
9999,
3247,
1900,
570,
12,
1902,
3679,
503,
3847,
370,
314,
1453,
523,
327,
2082,
523,
327,
446,
282,
1347,
536,
523,
327,
446,
282,
20070,
523,
327,
523,
327,
1900,
63,
493,
365,
314,
570,
3847,
370,
1314,
283,
1375,
7,
365,
3247,
14,
523,
327,
1347,
365,
314,
12313,
1347,
14,
523,
327,
20070,
365,
314,
849,
20070,
367,
626,
1347,
14,
523,
359,
6751,
63,
1506,
63,
493,
12,
1347,
12,
4565,
63,
12081,
61,
275,
6077,
30663,
8,
1375,
9,
819,
340,
4565,
63,
1506,
63,
493,
26,
272,
340,
1900,
63,
493,
26,
489,
327,
982,
282,
3847,
931,
12,
4565,
63,
1506,
63,
493,
365,
3847,
370,
314,
2082,
489,
327,
3035,
1900,
63,
493,
14,
221,
982,
1900,
63,
493,
365,
440,
315,
314,
1453,
2082,
12,
489,
327,
4565,
63,
1506,
63,
493,
365,
440,
282,
18025,
931,
465,
13,
374,
14,
221,
31096,
652,
701,
489,
327,
6421,
1337,
652,
465,
3847,
370,
1900,
63,
493,
14,
221,
982,
4565,
63,
1506,
63,
493,
365,
489,
327,
3679,
12,
652,
365,
18025,
465,
282,
931,
15270,
402,
314,
1453,
2082,
12,
489,
327,
436,
747,
14,
515,
14,
904,
911,
372,
652,
465,
13,
374,
14,
489,
1900,
63,
493,
275,
747,
14,
515,
14,
9267,
8,
736,
14,
515,
14,
904,
8,
736,
14,
515,
14,
3475,
8,
1506,
63,
493,
395,
1740,
4565,
63,
1506,
63,
493,
430,
489,
327,
28876,
334,
475,
2429,
5560,
2839,
24272,
6525,
395,
1852,
652,
3847,
370,
8288,
9,
489,
340,
440,
747,
14,
515,
14,
17896,
8,
1506,
63,
493,
304,
267,
1900,
63,
493,
275,
22419,
2042,
8,
1506,
63,
493,
12,
20093,
272,
587,
26,
489,
1900,
63,
493,
275,
4565,
63,
1506,
63,
493,
819,
340,
4565,
63,
12081,
26,
272,
20070,
275,
4565,
63,
12081,
819,
372,
359,
1506,
63,
493,
12,
1347,
12,
20070,
61,
421,
199,
318,
6516,
1173,
8,
5836,
63,
11661,
63,
1375,
304,
523,
327,
12892,
83,
314,
1900,
570,
687,
314,
9999,
12313,
1347,
14,
523,
372,
6077,
30663,
8,
5836,
63,
11661,
63,
1375,
2788,
16,
61,
421,
199,
318,
2372,
23027,
21860,
8,
1391,
63,
513,
12,
849,
304,
523,
408,
20926,
1536,
282,
790,
315,
314,
3734,
12,
543,
9567,
370,
13851,
2883,
523,
436,
3753,
32039,
1771,
370,
282,
849,
574,
1041,
523,
367,
2729,
315,
2729,
63,
513,
26,
272,
340,
2729,
315,
747,
14,
2314,
26,
489,
372,
747,
14,
2314,
59,
1391,
61,
523,
372,
849,
421,
199,
318,
19933,
4541,
4277,
8,
1506,
63,
493,
12,
1347,
12,
20070,
304,
523,
327,
298,
23279,
2,
4910,
314,
570,
626,
282,
1347,
1990,
3247,
315,
436,
314,
1347,
523,
327,
536,
12,
11673,
701,
282,
18307,
12,
4739,
379,
701,
282,
327,
436,
314,
20070,
536,
26,
523,
327,
1182,
515,
15,
475,
15,
493,
14,
6179,
26,
1375,
63,
354,
3,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
GbalsaC/bitnamiP
|
venv/lib/python2.7/site-packages/xblock/django/request.py
|
10
|
4573
|
"""Helpers for WebOb requests and responses."""
import webob
from collections import MutableMapping
from lazy import lazy
from itertools import chain, repeat, izip
from webob.multidict import MultiDict, NestedMultiDict, NoVars
def webob_to_django_response(webob_response):
"""Returns a django response to the `webob_response`"""
from django.http import HttpResponse
django_response = HttpResponse(
webob_response.app_iter,
content_type=webob_response.content_type,
status=webob_response.status_code,
)
for name, value in webob_response.headerlist:
django_response[name] = value
return django_response
class HeaderDict(MutableMapping):
"""
Provide a dictionary view of the HTTP headers in a
Django request.META dictionary that translates the
keys into actually HTTP header names
"""
UNPREFIXED_HEADERS = ('CONTENT_TYPE', 'CONTENT_LENGTH')
def __init__(self, meta):
self._meta = meta
def _meta_name(self, name):
"""
Translate HTTP header names to the format used by Django request objects.
See https://docs.djangoproject.com/en/1.4/ref/request-response/#django.http.HttpRequest.META
"""
name = name.upper().replace('-', '_')
if name not in self.UNPREFIXED_HEADERS:
name = 'HTTP_' + name
return name
def _un_meta_name(self, name):
"""
Reverse of _meta_name
"""
if name.startswith('HTTP_'):
name = name[5:]
return name.replace('_', '-').title()
def __getitem__(self, name):
return self._meta[self._meta_name(name)]
def __setitem__(self, name, value):
self._meta[self._meta_name(name)] = value
def __delitem__(self, name):
del self._meta[self._meta_name(name)]
def __iter__(self):
for key in self._meta:
if key in self.UNPREFIXED_HEADERS or key.startswith('HTTP_'):
yield self._un_meta_name(key)
def __len__(self):
return len(list(self))
def querydict_to_multidict(query_dict, wrap=None):
"""
Returns a new `webob.MultiDict` from a `django.http.QueryDict`.
If `wrap` is provided, it's used to wrap the values.
"""
wrap = wrap or (lambda val: val)
return MultiDict(chain.from_iterable(
izip(repeat(key), (wrap(v) for v in vals))
for key, vals in query_dict.iterlists()
))
class DjangoUploadedFile(object):
"""
Looks like a cgi.FieldStorage, but wraps a Django UploadedFile.
"""
def __init__(self, uploaded):
# FieldStorage needs a file attribute.
self.file = uploaded
@property
def name(self):
"""The name of the input element used to upload the file."""
return self.file.field_name
@property
def filename(self):
"""The name of the uploaded file."""
return self.file.name
class DjangoWebobRequest(webob.Request):
"""
An implementation of the webob request api, backed
by a django request
"""
def __init__(self, request):
self._request = request
super(DjangoWebobRequest, self).__init__(self.environ)
@lazy
def environ(self):
"""
Add path_info to the request's META dictionary.
"""
environ = dict(self._request.META)
environ['PATH_INFO'] = self._request.path_info
return environ
@property
def GET(self):
"""
Returns a new `webob.MultiDict` from the request's GET query.
"""
return querydict_to_multidict(self._request.GET)
@property
def POST(self):
if self.method not in ('POST', 'PUT', 'PATCH'):
return NoVars('Not a form request')
# Webob puts uploaded files into the POST dictionary, so here we
# combine the Django POST data and uploaded FILES data into a single
# dict.
return NestedMultiDict(
querydict_to_multidict(self._request.POST),
querydict_to_multidict(self._request.FILES, wrap=DjangoUploadedFile),
)
@lazy
def body(self): # pylint: disable=method-hidden
"""
Return the content of the request body.
"""
return self._request.body
@lazy
def body_file(self): # pylint: disable=method-hidden
"""
Input stream of the request
"""
return self._request
def django_to_webob_request(django_request):
"""Returns a WebOb request to the `django_request`"""
return DjangoWebobRequest(django_request)
|
agpl-3.0
|
[
624,
4433,
83,
367,
6001,
11394,
4145,
436,
9320,
1041,
199,
199,
646,
14568,
199,
504,
5055,
492,
29396,
199,
504,
9617,
492,
9617,
199,
504,
7975,
492,
6036,
12,
11982,
12,
28697,
199,
504,
14568,
14,
3029,
807,
492,
29393,
12,
23137,
21365,
12,
3091,
16270,
421,
199,
318,
14568,
63,
475,
63,
1176,
63,
1310,
8,
24057,
63,
1310,
304,
272,
408,
3407,
282,
1639,
1177,
370,
314,
658,
24057,
63,
1310,
64,
624,
272,
687,
1639,
14,
1014,
492,
6183,
272,
1639,
63,
1310,
275,
6183,
8,
267,
14568,
63,
1310,
14,
571,
63,
1661,
12,
267,
1564,
63,
466,
29,
24057,
63,
1310,
14,
1317,
63,
466,
12,
267,
2004,
29,
24057,
63,
1310,
14,
1205,
63,
600,
12,
272,
776,
272,
367,
536,
12,
574,
315,
14568,
63,
1310,
14,
1291,
513,
26,
267,
1639,
63,
1310,
59,
354,
61,
275,
574,
272,
372,
1639,
63,
1310,
421,
199,
533,
10240,
2141,
8,
17707,
7674,
304,
272,
408,
272,
22896,
282,
2600,
2455,
402,
314,
3101,
2323,
315,
282,
272,
5634,
1056,
14,
10614,
2600,
626,
9028,
83,
314,
272,
2883,
1901,
5965,
3101,
1406,
1561,
272,
408,
272,
6778,
6351,
1149,
63,
21178,
275,
661,
9663,
63,
2711,
297,
283,
9663,
63,
9127,
358,
339,
347,
636,
826,
721,
277,
12,
3404,
304,
267,
291,
423,
2024,
275,
3404,
339,
347,
485,
2024,
63,
354,
8,
277,
12,
536,
304,
267,
408,
267,
25540,
3101,
1406,
1561,
370,
314,
1475,
1202,
701,
5634,
1056,
2251,
14,
398,
1666,
4178,
921,
4757,
14,
14013,
14,
957,
15,
287,
15,
17,
14,
20,
15,
1121,
15,
1069,
13,
1310,
12645,
1176,
14,
1014,
14,
10441,
14,
10614,
267,
408,
267,
536,
275,
536,
14,
4142,
1252,
1814,
13858,
18962,
267,
340,
536,
440,
315,
291,
14,
1734,
6351,
1149,
63,
21178,
26,
288,
536,
275,
283,
2856,
8650,
435,
536,
267,
372,
536,
339,
347,
485,
324,
63,
2024,
63,
354,
8,
277,
12,
536,
304,
267,
408,
267,
22734,
402,
485,
2024,
63,
354,
267,
408,
267,
340,
536,
14,
2460,
360,
2856,
25865,
288,
536,
275,
536,
59,
21,
2938,
267,
372,
536,
14,
1814,
20928,
2475,
1959,
1213,
342,
339,
347,
636,
6095,
721,
277,
12,
536,
304,
267,
372,
291,
423,
2024,
59,
277,
423,
2024,
63,
354,
8,
354,
1874,
339,
347,
636,
8617,
721,
277,
12,
536,
12,
574,
304,
267,
291,
423,
2024,
59,
277,
423,
2024,
63,
354,
8,
354,
1874,
275,
574,
339,
347,
636,
13228,
721,
277,
12,
536,
304,
267,
2150,
291,
423,
2024,
59,
277,
423,
2024,
63,
354,
8,
354,
1874,
339,
347,
636,
1661,
721,
277,
304,
267,
367,
790,
315,
291,
423,
2024,
26,
288,
340,
790,
315,
291,
14,
1734,
6351,
1149,
63,
21178,
503,
790,
14,
2460,
360,
2856,
25865,
355,
1995,
291,
423,
324,
63,
2024,
63,
354,
8,
498,
9,
339,
347,
636,
552,
721,
277,
304,
267,
372,
822,
8,
513,
8,
277,
430,
421,
199,
318,
1827,
807,
63,
475,
63,
3029,
807,
8,
1131,
63,
807,
12,
4816,
29,
403,
304,
272,
408,
272,
1803,
282,
892,
658,
24057,
14,
21365,
64,
687,
282,
658,
1176,
14,
1014,
14,
3227,
2141,
2313,
339,
982,
658,
3823,
64,
365,
2741,
12,
652,
1159,
1202,
370,
4816,
314,
1338,
14,
339,
408,
272,
4816,
275,
4816,
503,
334,
2734,
1139,
26,
1139,
9,
272,
372,
29393,
8,
4429,
14,
504,
63,
8147,
8,
267,
28697,
8,
8755,
8,
498,
395,
334,
3823,
8,
86,
9,
367,
373,
315,
5322,
430,
267,
367,
790,
12,
5322,
315,
1827,
63,
807,
14,
1661,
6717,
342,
272,
5082,
421,
199,
533,
5634,
24665,
8,
785,
304,
272,
408,
272,
12077,
83,
2839,
282,
16004,
14,
792,
6408,
12,
1325,
14018,
282,
5634,
4949,
4591,
1173,
14,
272,
408,
272,
347,
636,
826,
721,
277,
12,
14238,
304,
267,
327,
5024,
6408,
4839,
282,
570,
2225,
14,
267,
291,
14,
493,
275,
14238,
339,
768,
1829,
272,
347,
536,
8,
277,
304,
267,
408,
1918,
536,
402,
314,
1324,
1819,
1202,
370,
5802,
314,
570,
1041,
267,
372,
291,
14,
493,
14,
698,
63,
354,
339,
768,
1829,
272,
347,
1788,
8,
277,
304,
267,
408,
1918,
536,
402,
314,
14238,
570,
1041,
267,
372,
291,
14,
493,
14,
354,
421,
199,
533,
5634,
6004,
7913,
2017,
8,
24057,
14,
2017,
304,
272,
408,
272,
1626,
4514,
402,
314,
14568,
1056,
2986,
12,
1771,
379,
272,
701,
282,
1639,
1056,
272,
408,
272,
347,
636,
826,
721,
277,
12,
1056,
304,
267,
291,
423,
1069,
275,
1056,
267,
1613,
8,
9323,
6004,
7913,
2017,
12,
291,
2843,
826,
721,
277,
14,
2314,
9,
339,
768,
6395,
272,
347,
6160,
8,
277,
304,
267,
408,
267,
2654,
931,
63,
815,
370,
314,
1056,
1159,
603,
15808,
2600,
14,
267,
408,
267,
6160,
275,
1211,
8,
277,
423,
1069,
14,
10614,
9,
398,
6160,
459,
3243,
63,
4531,
418,
275,
291,
423,
1069,
14,
515,
63,
815,
398,
372,
6160,
339,
768,
1829,
272,
347,
9576,
8,
277,
304,
267,
408,
267,
1803,
282,
892,
658,
24057,
14,
21365,
64,
687,
314,
1056,
1159,
9576,
1827,
14,
267,
408,
267,
372,
1827,
807,
63,
475,
63,
3029,
807,
8,
277,
423,
1069,
14,
2970,
9,
339,
768,
1829,
272,
347,
8761,
8,
277,
304,
267,
340,
291,
14,
765,
440,
315,
661,
4030,
297,
283,
4013,
297,
283,
17073,
735,
288,
372,
3091,
16270,
360,
1763,
282,
1824,
1056,
358,
398,
327,
2136,
7913,
27000,
14238,
1584,
1901,
314,
8761,
2600,
12,
880,
2348,
781,
267,
327,
13323,
314,
5634,
8761,
666,
436,
14238,
16444,
654,
666,
1901,
282,
2849,
267,
327,
1211,
14,
267,
372,
23137,
21365,
8,
288,
1827,
807,
63,
475,
63,
3029,
807,
8,
277,
423,
1069,
14,
4030,
395,
288,
1827,
807,
63,
475,
63,
3029,
807,
8,
277,
423,
1069,
14,
9472,
12,
4816,
29,
9323,
24665,
395,
267,
776,
339,
768,
6395,
272,
347,
2396,
8,
277,
304,
221,
327,
4287,
26,
3507,
29,
765,
13,
5642,
267,
408,
267,
1432,
314,
1564,
402,
314,
1056,
2396,
14,
267
] |
[
4433,
83,
367,
6001,
11394,
4145,
436,
9320,
1041,
199,
199,
646,
14568,
199,
504,
5055,
492,
29396,
199,
504,
9617,
492,
9617,
199,
504,
7975,
492,
6036,
12,
11982,
12,
28697,
199,
504,
14568,
14,
3029,
807,
492,
29393,
12,
23137,
21365,
12,
3091,
16270,
421,
199,
318,
14568,
63,
475,
63,
1176,
63,
1310,
8,
24057,
63,
1310,
304,
272,
408,
3407,
282,
1639,
1177,
370,
314,
658,
24057,
63,
1310,
64,
624,
272,
687,
1639,
14,
1014,
492,
6183,
272,
1639,
63,
1310,
275,
6183,
8,
267,
14568,
63,
1310,
14,
571,
63,
1661,
12,
267,
1564,
63,
466,
29,
24057,
63,
1310,
14,
1317,
63,
466,
12,
267,
2004,
29,
24057,
63,
1310,
14,
1205,
63,
600,
12,
272,
776,
272,
367,
536,
12,
574,
315,
14568,
63,
1310,
14,
1291,
513,
26,
267,
1639,
63,
1310,
59,
354,
61,
275,
574,
272,
372,
1639,
63,
1310,
421,
199,
533,
10240,
2141,
8,
17707,
7674,
304,
272,
408,
272,
22896,
282,
2600,
2455,
402,
314,
3101,
2323,
315,
282,
272,
5634,
1056,
14,
10614,
2600,
626,
9028,
83,
314,
272,
2883,
1901,
5965,
3101,
1406,
1561,
272,
408,
272,
6778,
6351,
1149,
63,
21178,
275,
661,
9663,
63,
2711,
297,
283,
9663,
63,
9127,
358,
339,
347,
636,
826,
721,
277,
12,
3404,
304,
267,
291,
423,
2024,
275,
3404,
339,
347,
485,
2024,
63,
354,
8,
277,
12,
536,
304,
267,
408,
267,
25540,
3101,
1406,
1561,
370,
314,
1475,
1202,
701,
5634,
1056,
2251,
14,
398,
1666,
4178,
921,
4757,
14,
14013,
14,
957,
15,
287,
15,
17,
14,
20,
15,
1121,
15,
1069,
13,
1310,
12645,
1176,
14,
1014,
14,
10441,
14,
10614,
267,
408,
267,
536,
275,
536,
14,
4142,
1252,
1814,
13858,
18962,
267,
340,
536,
440,
315,
291,
14,
1734,
6351,
1149,
63,
21178,
26,
288,
536,
275,
283,
2856,
8650,
435,
536,
267,
372,
536,
339,
347,
485,
324,
63,
2024,
63,
354,
8,
277,
12,
536,
304,
267,
408,
267,
22734,
402,
485,
2024,
63,
354,
267,
408,
267,
340,
536,
14,
2460,
360,
2856,
25865,
288,
536,
275,
536,
59,
21,
2938,
267,
372,
536,
14,
1814,
20928,
2475,
1959,
1213,
342,
339,
347,
636,
6095,
721,
277,
12,
536,
304,
267,
372,
291,
423,
2024,
59,
277,
423,
2024,
63,
354,
8,
354,
1874,
339,
347,
636,
8617,
721,
277,
12,
536,
12,
574,
304,
267,
291,
423,
2024,
59,
277,
423,
2024,
63,
354,
8,
354,
1874,
275,
574,
339,
347,
636,
13228,
721,
277,
12,
536,
304,
267,
2150,
291,
423,
2024,
59,
277,
423,
2024,
63,
354,
8,
354,
1874,
339,
347,
636,
1661,
721,
277,
304,
267,
367,
790,
315,
291,
423,
2024,
26,
288,
340,
790,
315,
291,
14,
1734,
6351,
1149,
63,
21178,
503,
790,
14,
2460,
360,
2856,
25865,
355,
1995,
291,
423,
324,
63,
2024,
63,
354,
8,
498,
9,
339,
347,
636,
552,
721,
277,
304,
267,
372,
822,
8,
513,
8,
277,
430,
421,
199,
318,
1827,
807,
63,
475,
63,
3029,
807,
8,
1131,
63,
807,
12,
4816,
29,
403,
304,
272,
408,
272,
1803,
282,
892,
658,
24057,
14,
21365,
64,
687,
282,
658,
1176,
14,
1014,
14,
3227,
2141,
2313,
339,
982,
658,
3823,
64,
365,
2741,
12,
652,
1159,
1202,
370,
4816,
314,
1338,
14,
339,
408,
272,
4816,
275,
4816,
503,
334,
2734,
1139,
26,
1139,
9,
272,
372,
29393,
8,
4429,
14,
504,
63,
8147,
8,
267,
28697,
8,
8755,
8,
498,
395,
334,
3823,
8,
86,
9,
367,
373,
315,
5322,
430,
267,
367,
790,
12,
5322,
315,
1827,
63,
807,
14,
1661,
6717,
342,
272,
5082,
421,
199,
533,
5634,
24665,
8,
785,
304,
272,
408,
272,
12077,
83,
2839,
282,
16004,
14,
792,
6408,
12,
1325,
14018,
282,
5634,
4949,
4591,
1173,
14,
272,
408,
272,
347,
636,
826,
721,
277,
12,
14238,
304,
267,
327,
5024,
6408,
4839,
282,
570,
2225,
14,
267,
291,
14,
493,
275,
14238,
339,
768,
1829,
272,
347,
536,
8,
277,
304,
267,
408,
1918,
536,
402,
314,
1324,
1819,
1202,
370,
5802,
314,
570,
1041,
267,
372,
291,
14,
493,
14,
698,
63,
354,
339,
768,
1829,
272,
347,
1788,
8,
277,
304,
267,
408,
1918,
536,
402,
314,
14238,
570,
1041,
267,
372,
291,
14,
493,
14,
354,
421,
199,
533,
5634,
6004,
7913,
2017,
8,
24057,
14,
2017,
304,
272,
408,
272,
1626,
4514,
402,
314,
14568,
1056,
2986,
12,
1771,
379,
272,
701,
282,
1639,
1056,
272,
408,
272,
347,
636,
826,
721,
277,
12,
1056,
304,
267,
291,
423,
1069,
275,
1056,
267,
1613,
8,
9323,
6004,
7913,
2017,
12,
291,
2843,
826,
721,
277,
14,
2314,
9,
339,
768,
6395,
272,
347,
6160,
8,
277,
304,
267,
408,
267,
2654,
931,
63,
815,
370,
314,
1056,
1159,
603,
15808,
2600,
14,
267,
408,
267,
6160,
275,
1211,
8,
277,
423,
1069,
14,
10614,
9,
398,
6160,
459,
3243,
63,
4531,
418,
275,
291,
423,
1069,
14,
515,
63,
815,
398,
372,
6160,
339,
768,
1829,
272,
347,
9576,
8,
277,
304,
267,
408,
267,
1803,
282,
892,
658,
24057,
14,
21365,
64,
687,
314,
1056,
1159,
9576,
1827,
14,
267,
408,
267,
372,
1827,
807,
63,
475,
63,
3029,
807,
8,
277,
423,
1069,
14,
2970,
9,
339,
768,
1829,
272,
347,
8761,
8,
277,
304,
267,
340,
291,
14,
765,
440,
315,
661,
4030,
297,
283,
4013,
297,
283,
17073,
735,
288,
372,
3091,
16270,
360,
1763,
282,
1824,
1056,
358,
398,
327,
2136,
7913,
27000,
14238,
1584,
1901,
314,
8761,
2600,
12,
880,
2348,
781,
267,
327,
13323,
314,
5634,
8761,
666,
436,
14238,
16444,
654,
666,
1901,
282,
2849,
267,
327,
1211,
14,
267,
372,
23137,
21365,
8,
288,
1827,
807,
63,
475,
63,
3029,
807,
8,
277,
423,
1069,
14,
4030,
395,
288,
1827,
807,
63,
475,
63,
3029,
807,
8,
277,
423,
1069,
14,
9472,
12,
4816,
29,
9323,
24665,
395,
267,
776,
339,
768,
6395,
272,
347,
2396,
8,
277,
304,
221,
327,
4287,
26,
3507,
29,
765,
13,
5642,
267,
408,
267,
1432,
314,
1564,
402,
314,
1056,
2396,
14,
267,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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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
] |
ostcar/OpenSlides
|
server/tests/unit/agenda/test_views.py
|
5
|
5173
|
from unittest import TestCase
from unittest.mock import MagicMock, patch
import pytest
from openslides.agenda.views import ListOfSpeakersViewSet
class ListOfSpeakersViewSetManageSpeaker(TestCase):
"""
Tests views of ListOfSpeakersViewSet to manage speakers.
"""
def setUp(self):
self.request = MagicMock()
self.view_instance = ListOfSpeakersViewSet()
self.view_instance.request = self.request
self.view_instance.get_object = get_object_mock = MagicMock()
get_object_mock.return_value = self.mock_list_of_speakers = MagicMock()
@patch("openslides.agenda.views.inform_changed_data")
@patch("openslides.agenda.views.has_perm")
@patch("openslides.agenda.views.Speaker")
@pytest.mark.django_db(transaction=False)
def test_add_oneself_as_speaker(self, mock_speaker, mock_has_perm, mock_icd):
self.request.method = "POST"
self.request.user = 1
mock_has_perm.return_value = True
self.request.data = {}
self.mock_list_of_speakers.closed = False
self.view_instance.manage_speaker(self.request)
mock_speaker.objects.add.assert_called_with(
self.request.user,
self.mock_list_of_speakers,
point_of_order=False,
note=None,
)
@patch("openslides.agenda.views.inform_changed_data")
@patch("openslides.agenda.views.has_perm")
@patch("openslides.agenda.views.get_user_model")
@patch("openslides.agenda.views.Speaker")
@pytest.mark.django_db(transaction=False)
def test_add_someone_else_as_speaker(
self, mock_speaker, mock_get_user_model, mock_has_perm, mock_icd
):
self.request.method = "POST"
self.request.user = 1
self.request.data = {
"user": 2
} # It is assumed that the request user has pk!=2.
mock_get_user_model.return_value = MockUser = MagicMock()
MockUser.objects.get.return_value = mock_user = MagicMock()
mock_has_perm.return_value = True
self.view_instance.manage_speaker(self.request)
MockUser.objects.get.assert_called_with(pk=2)
mock_speaker.objects.add.assert_called_with(
mock_user, self.mock_list_of_speakers, point_of_order=False, note=None
)
@patch("openslides.agenda.views.Speaker")
@pytest.mark.django_db(transaction=False)
def test_remove_oneself(self, mock_speaker):
self.request.method = "DELETE"
self.request.data = {}
self.view_instance.manage_speaker(self.request)
mock_queryset = mock_speaker.objects.filter.return_value.exclude.return_value
mock_queryset.all.return_value.delete.assert_called_with()
@patch("openslides.agenda.views.inform_changed_data")
@patch("openslides.agenda.views.has_perm")
@patch("openslides.agenda.views.Speaker")
@pytest.mark.django_db(transaction=False)
def test_remove_someone_else(
self, mock_speaker, mock_has_perm, mock_inform_changed_data
):
self.request.method = "DELETE"
self.request.user = 1
self.request.data = {"speaker": "1"}
mock_has_perm.return_value = True
self.view_instance.manage_speaker(self.request)
mock_speaker.objects.get.assert_called_with(pk=1)
mock_speaker.objects.get.return_value.delete.assert_called_with(
skip_autoupdate=True
)
mock_inform_changed_data.assert_called_with(self.mock_list_of_speakers)
class ListOfSpeakersViewSetSpeak(TestCase):
"""
Tests views of ListOfSpeakersViewSet to begin and end speech.
"""
def setUp(self):
self.request = MagicMock()
self.view_instance = ListOfSpeakersViewSet()
self.view_instance.request = self.request
self.view_instance.get_object = get_object_mock = MagicMock()
get_object_mock.return_value = self.mock_list_of_speakers = MagicMock()
def test_begin_speech(self):
self.request.method = "PUT"
self.request.user.has_perm.return_value = True
self.request.data = {}
self.mock_list_of_speakers.get_next_speaker.return_value = (
mock_next_speaker
) = MagicMock()
self.view_instance.speak(self.request)
mock_next_speaker.begin_speech.assert_called_with()
@patch("openslides.agenda.views.Speaker")
def test_begin_speech_specific_speaker(self, mock_speaker):
self.request.method = "PUT"
self.request.user.has_perm.return_value = True
self.request.data = {"speaker": "1"}
mock_speaker.objects.get.return_value = mock_next_speaker = MagicMock()
self.view_instance.speak(self.request)
mock_next_speaker.begin_speech.assert_called_with()
@patch("openslides.agenda.views.Speaker")
def test_end_speech(self, mock_speaker):
self.request.method = "DELETE"
self.request.user.has_perm.return_value = True
mock_speaker.objects.filter.return_value.exclude.return_value.get.return_value = (
mock_speaker
) = MagicMock()
self.view_instance.speak(self.request)
mock_speaker.end_speech.assert_called_with()
|
mit
|
[
504,
2882,
492,
7640,
199,
504,
2882,
14,
1805,
492,
10079,
12,
3371,
199,
199,
646,
4613,
199,
199,
504,
1551,
23766,
3424,
14,
643,
29162,
14,
4196,
492,
3820,
3466,
51,
8556,
1192,
21902,
421,
199,
533,
3820,
3466,
51,
8556,
1192,
21902,
20588,
51,
19838,
8,
1746,
304,
272,
408,
272,
6496,
6858,
402,
3820,
3466,
51,
8556,
1192,
21902,
370,
9635,
308,
8556,
1192,
14,
272,
408,
339,
347,
3613,
8,
277,
304,
267,
291,
14,
1069,
275,
10079,
342,
267,
291,
14,
1345,
63,
842,
275,
3820,
3466,
51,
8556,
1192,
21902,
342,
267,
291,
14,
1345,
63,
842,
14,
1069,
275,
291,
14,
1069,
267,
291,
14,
1345,
63,
842,
14,
362,
63,
785,
275,
664,
63,
785,
63,
1805,
275,
10079,
342,
267,
664,
63,
785,
63,
1805,
14,
1107,
63,
585,
275,
291,
14,
1805,
63,
513,
63,
1618,
63,
31258,
1192,
275,
10079,
342,
339,
768,
2068,
480,
1490,
23766,
3424,
14,
643,
29162,
14,
4196,
14,
262,
964,
63,
2489,
63,
576,
531,
272,
768,
2068,
480,
1490,
23766,
3424,
14,
643,
29162,
14,
4196,
14,
1989,
63,
8220,
531,
272,
768,
2068,
480,
1490,
23766,
3424,
14,
643,
29162,
14,
4196,
14,
51,
19838,
531,
272,
768,
4462,
14,
1657,
14,
1176,
63,
697,
8,
5945,
29,
797,
9,
272,
347,
511,
63,
525,
63,
368,
277,
63,
305,
63,
32263,
8,
277,
12,
1683,
63,
32263,
12,
1683,
63,
1989,
63,
8220,
12,
1683,
63,
530,
68,
304,
267,
291,
14,
1069,
14,
765,
275,
298,
4030,
2,
267,
291,
14,
1069,
14,
751,
275,
413,
267,
1683,
63,
1989,
63,
8220,
14,
1107,
63,
585,
275,
715,
267,
291,
14,
1069,
14,
576,
275,
1052,
267,
291,
14,
1805,
63,
513,
63,
1618,
63,
31258,
1192,
14,
5938,
275,
756,
398,
291,
14,
1345,
63,
842,
14,
9053,
63,
32263,
8,
277,
14,
1069,
9,
398,
1683,
63,
32263,
14,
1462,
14,
525,
14,
479,
63,
3527,
63,
1045,
8,
288,
291,
14,
1069,
14,
751,
12,
288,
291,
14,
1805,
63,
513,
63,
1618,
63,
31258,
1192,
12,
288,
2376,
63,
1618,
63,
1648,
29,
797,
12,
288,
5317,
29,
403,
12,
267,
776,
339,
768,
2068,
480,
1490,
23766,
3424,
14,
643,
29162,
14,
4196,
14,
262,
964,
63,
2489,
63,
576,
531,
272,
768,
2068,
480,
1490,
23766,
3424,
14,
643,
29162,
14,
4196,
14,
1989,
63,
8220,
531,
272,
768,
2068,
480,
1490,
23766,
3424,
14,
643,
29162,
14,
4196,
14,
362,
63,
751,
63,
1238,
531,
272,
768,
2068,
480,
1490,
23766,
3424,
14,
643,
29162,
14,
4196,
14,
51,
19838,
531,
272,
768,
4462,
14,
1657,
14,
1176,
63,
697,
8,
5945,
29,
797,
9,
272,
347,
511,
63,
525,
63,
3972,
368,
63,
2836,
63,
305,
63,
32263,
8,
267,
291,
12,
1683,
63,
32263,
12,
1683,
63,
362,
63,
751,
63,
1238,
12,
1683,
63,
1989,
63,
8220,
12,
1683,
63,
530,
68,
272,
3461,
267,
291,
14,
1069,
14,
765,
275,
298,
4030,
2,
267,
291,
14,
1069,
14,
751,
275,
413,
267,
291,
14,
1069,
14,
576,
275,
469,
288,
298,
751,
582,
499,
267,
789,
221,
327,
2779,
365,
10826,
626,
314,
1056,
922,
965,
3803,
1111,
18,
14,
267,
1683,
63,
362,
63,
751,
63,
1238,
14,
1107,
63,
585,
275,
4420,
1899,
275,
10079,
342,
267,
4420,
1899,
14,
1462,
14,
362,
14,
1107,
63,
585,
275,
1683,
63,
751,
275,
10079,
342,
267,
1683,
63,
1989,
63,
8220,
14,
1107,
63,
585,
275,
715,
398,
291,
14,
1345,
63,
842,
14,
9053,
63,
32263,
8,
277,
14,
1069,
9,
398,
4420,
1899,
14,
1462,
14,
362,
14,
479,
63,
3527,
63,
1045,
8,
2051,
29,
18,
9,
267,
1683,
63,
32263,
14,
1462,
14,
525,
14,
479,
63,
3527,
63,
1045,
8,
288,
1683,
63,
751,
12,
291,
14,
1805,
63,
513,
63,
1618,
63,
31258,
1192,
12,
2376,
63,
1618,
63,
1648,
29,
797,
12,
5317,
29,
403,
267,
776,
339,
768,
2068,
480,
1490,
23766,
3424,
14,
643,
29162,
14,
4196,
14,
51,
19838,
531,
272,
768,
4462,
14,
1657,
14,
1176,
63,
697,
8,
5945,
29,
797,
9,
272,
347,
511,
63,
2168,
63,
368,
277,
8,
277,
12,
1683,
63,
32263,
304,
267,
291,
14,
1069,
14,
765,
275,
298,
7014,
2,
267,
291,
14,
1069,
14,
576,
275,
1052,
267,
291,
14,
1345,
63,
842,
14,
9053,
63,
32263,
8,
277,
14,
1069,
9,
267,
1683,
63,
7924,
275,
1683,
63,
32263,
14,
1462,
14,
1541,
14,
1107,
63,
585,
14,
5473,
14,
1107,
63,
585,
267,
1683,
63,
7924,
14,
452,
14,
1107,
63,
585,
14,
1807,
14,
479,
63,
3527,
63,
1045,
342,
339,
768,
2068,
480,
1490,
23766,
3424,
14,
643,
29162,
14,
4196,
14,
262,
964,
63,
2489,
63,
576,
531,
272,
768,
2068,
480,
1490,
23766,
3424,
14,
643,
29162,
14,
4196,
14,
1989,
63,
8220,
531,
272,
768,
2068,
480,
1490,
23766,
3424,
14,
643,
29162,
14,
4196,
14,
51,
19838,
531,
272,
768,
4462,
14,
1657,
14,
1176,
63,
697,
8,
5945,
29,
797,
9,
272,
347,
511,
63,
2168,
63,
3972,
368,
63,
2836,
8,
267,
291,
12,
1683,
63,
32263,
12,
1683,
63,
1989,
63,
8220,
12,
1683,
63,
262,
964,
63,
2489,
63,
576,
272,
3461,
267,
291,
14,
1069,
14,
765,
275,
298,
7014,
2,
267,
291,
14,
1069,
14,
751,
275,
413,
267,
291,
14,
1069,
14,
576,
275,
2420,
32263,
582,
298,
17,
3570,
267,
1683,
63,
1989,
63,
8220,
14,
1107,
63,
585,
275,
715,
398,
291,
14,
1345,
63,
842,
14,
9053,
63,
32263,
8,
277,
14,
1069,
9,
398,
1683,
63,
32263,
14,
1462,
14,
362,
14,
479,
63,
3527,
63,
1045,
8,
2051,
29,
17,
9,
267,
1683,
63,
32263,
14,
1462,
14,
362,
14,
1107,
63,
585,
14,
1807,
14,
479,
63,
3527,
63,
1045,
8,
288,
3372,
63,
2495,
873,
29,
549,
267,
776,
267,
1683,
63,
262,
964,
63,
2489,
63,
576,
14,
479,
63,
3527,
63,
1045,
8,
277,
14,
1805,
63,
513,
63,
1618,
63,
31258,
1192,
9,
421,
199,
533
] |
[
2882,
492,
7640,
199,
504,
2882,
14,
1805,
492,
10079,
12,
3371,
199,
199,
646,
4613,
199,
199,
504,
1551,
23766,
3424,
14,
643,
29162,
14,
4196,
492,
3820,
3466,
51,
8556,
1192,
21902,
421,
199,
533,
3820,
3466,
51,
8556,
1192,
21902,
20588,
51,
19838,
8,
1746,
304,
272,
408,
272,
6496,
6858,
402,
3820,
3466,
51,
8556,
1192,
21902,
370,
9635,
308,
8556,
1192,
14,
272,
408,
339,
347,
3613,
8,
277,
304,
267,
291,
14,
1069,
275,
10079,
342,
267,
291,
14,
1345,
63,
842,
275,
3820,
3466,
51,
8556,
1192,
21902,
342,
267,
291,
14,
1345,
63,
842,
14,
1069,
275,
291,
14,
1069,
267,
291,
14,
1345,
63,
842,
14,
362,
63,
785,
275,
664,
63,
785,
63,
1805,
275,
10079,
342,
267,
664,
63,
785,
63,
1805,
14,
1107,
63,
585,
275,
291,
14,
1805,
63,
513,
63,
1618,
63,
31258,
1192,
275,
10079,
342,
339,
768,
2068,
480,
1490,
23766,
3424,
14,
643,
29162,
14,
4196,
14,
262,
964,
63,
2489,
63,
576,
531,
272,
768,
2068,
480,
1490,
23766,
3424,
14,
643,
29162,
14,
4196,
14,
1989,
63,
8220,
531,
272,
768,
2068,
480,
1490,
23766,
3424,
14,
643,
29162,
14,
4196,
14,
51,
19838,
531,
272,
768,
4462,
14,
1657,
14,
1176,
63,
697,
8,
5945,
29,
797,
9,
272,
347,
511,
63,
525,
63,
368,
277,
63,
305,
63,
32263,
8,
277,
12,
1683,
63,
32263,
12,
1683,
63,
1989,
63,
8220,
12,
1683,
63,
530,
68,
304,
267,
291,
14,
1069,
14,
765,
275,
298,
4030,
2,
267,
291,
14,
1069,
14,
751,
275,
413,
267,
1683,
63,
1989,
63,
8220,
14,
1107,
63,
585,
275,
715,
267,
291,
14,
1069,
14,
576,
275,
1052,
267,
291,
14,
1805,
63,
513,
63,
1618,
63,
31258,
1192,
14,
5938,
275,
756,
398,
291,
14,
1345,
63,
842,
14,
9053,
63,
32263,
8,
277,
14,
1069,
9,
398,
1683,
63,
32263,
14,
1462,
14,
525,
14,
479,
63,
3527,
63,
1045,
8,
288,
291,
14,
1069,
14,
751,
12,
288,
291,
14,
1805,
63,
513,
63,
1618,
63,
31258,
1192,
12,
288,
2376,
63,
1618,
63,
1648,
29,
797,
12,
288,
5317,
29,
403,
12,
267,
776,
339,
768,
2068,
480,
1490,
23766,
3424,
14,
643,
29162,
14,
4196,
14,
262,
964,
63,
2489,
63,
576,
531,
272,
768,
2068,
480,
1490,
23766,
3424,
14,
643,
29162,
14,
4196,
14,
1989,
63,
8220,
531,
272,
768,
2068,
480,
1490,
23766,
3424,
14,
643,
29162,
14,
4196,
14,
362,
63,
751,
63,
1238,
531,
272,
768,
2068,
480,
1490,
23766,
3424,
14,
643,
29162,
14,
4196,
14,
51,
19838,
531,
272,
768,
4462,
14,
1657,
14,
1176,
63,
697,
8,
5945,
29,
797,
9,
272,
347,
511,
63,
525,
63,
3972,
368,
63,
2836,
63,
305,
63,
32263,
8,
267,
291,
12,
1683,
63,
32263,
12,
1683,
63,
362,
63,
751,
63,
1238,
12,
1683,
63,
1989,
63,
8220,
12,
1683,
63,
530,
68,
272,
3461,
267,
291,
14,
1069,
14,
765,
275,
298,
4030,
2,
267,
291,
14,
1069,
14,
751,
275,
413,
267,
291,
14,
1069,
14,
576,
275,
469,
288,
298,
751,
582,
499,
267,
789,
221,
327,
2779,
365,
10826,
626,
314,
1056,
922,
965,
3803,
1111,
18,
14,
267,
1683,
63,
362,
63,
751,
63,
1238,
14,
1107,
63,
585,
275,
4420,
1899,
275,
10079,
342,
267,
4420,
1899,
14,
1462,
14,
362,
14,
1107,
63,
585,
275,
1683,
63,
751,
275,
10079,
342,
267,
1683,
63,
1989,
63,
8220,
14,
1107,
63,
585,
275,
715,
398,
291,
14,
1345,
63,
842,
14,
9053,
63,
32263,
8,
277,
14,
1069,
9,
398,
4420,
1899,
14,
1462,
14,
362,
14,
479,
63,
3527,
63,
1045,
8,
2051,
29,
18,
9,
267,
1683,
63,
32263,
14,
1462,
14,
525,
14,
479,
63,
3527,
63,
1045,
8,
288,
1683,
63,
751,
12,
291,
14,
1805,
63,
513,
63,
1618,
63,
31258,
1192,
12,
2376,
63,
1618,
63,
1648,
29,
797,
12,
5317,
29,
403,
267,
776,
339,
768,
2068,
480,
1490,
23766,
3424,
14,
643,
29162,
14,
4196,
14,
51,
19838,
531,
272,
768,
4462,
14,
1657,
14,
1176,
63,
697,
8,
5945,
29,
797,
9,
272,
347,
511,
63,
2168,
63,
368,
277,
8,
277,
12,
1683,
63,
32263,
304,
267,
291,
14,
1069,
14,
765,
275,
298,
7014,
2,
267,
291,
14,
1069,
14,
576,
275,
1052,
267,
291,
14,
1345,
63,
842,
14,
9053,
63,
32263,
8,
277,
14,
1069,
9,
267,
1683,
63,
7924,
275,
1683,
63,
32263,
14,
1462,
14,
1541,
14,
1107,
63,
585,
14,
5473,
14,
1107,
63,
585,
267,
1683,
63,
7924,
14,
452,
14,
1107,
63,
585,
14,
1807,
14,
479,
63,
3527,
63,
1045,
342,
339,
768,
2068,
480,
1490,
23766,
3424,
14,
643,
29162,
14,
4196,
14,
262,
964,
63,
2489,
63,
576,
531,
272,
768,
2068,
480,
1490,
23766,
3424,
14,
643,
29162,
14,
4196,
14,
1989,
63,
8220,
531,
272,
768,
2068,
480,
1490,
23766,
3424,
14,
643,
29162,
14,
4196,
14,
51,
19838,
531,
272,
768,
4462,
14,
1657,
14,
1176,
63,
697,
8,
5945,
29,
797,
9,
272,
347,
511,
63,
2168,
63,
3972,
368,
63,
2836,
8,
267,
291,
12,
1683,
63,
32263,
12,
1683,
63,
1989,
63,
8220,
12,
1683,
63,
262,
964,
63,
2489,
63,
576,
272,
3461,
267,
291,
14,
1069,
14,
765,
275,
298,
7014,
2,
267,
291,
14,
1069,
14,
751,
275,
413,
267,
291,
14,
1069,
14,
576,
275,
2420,
32263,
582,
298,
17,
3570,
267,
1683,
63,
1989,
63,
8220,
14,
1107,
63,
585,
275,
715,
398,
291,
14,
1345,
63,
842,
14,
9053,
63,
32263,
8,
277,
14,
1069,
9,
398,
1683,
63,
32263,
14,
1462,
14,
362,
14,
479,
63,
3527,
63,
1045,
8,
2051,
29,
17,
9,
267,
1683,
63,
32263,
14,
1462,
14,
362,
14,
1107,
63,
585,
14,
1807,
14,
479,
63,
3527,
63,
1045,
8,
288,
3372,
63,
2495,
873,
29,
549,
267,
776,
267,
1683,
63,
262,
964,
63,
2489,
63,
576,
14,
479,
63,
3527,
63,
1045,
8,
277,
14,
1805,
63,
513,
63,
1618,
63,
31258,
1192,
9,
421,
199,
533,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
Karel-van-de-Plassche/PF2q
|
pf2q/tools.py
|
1
|
9139
|
#! /usr/bin/env python
# -*- coding: utf-8 -*-
"""
This module contains tools miscellaneous tools used throughout the PF2q module.
It also contains some deprecated functions that you can use at your own risk.
@author: Karel van de Plassche
@licence: GPLv3
"""
import os
import warnings
from math import ceil
import numpy as np
#from scipy.optimize import curve_fit
from scipy.interpolate import interp1d
# Needed for file manipulation
from sys import platform
if platform == "win32":
from win32com.client import Dispatch
def range_0_2pi(narray, tolerance=0.001):
"""Remap all values from [-2pi, 2pi] to [0, 2pi]."""
# Prevent weird stuff around 000
narray[abs(narray) < tolerance] = 0
negative_indices = narray < 0
narray[negative_indices] = narray[negative_indices] + 2 * np.pi
return narray
def smart_diff(narray):
"""Calculate a smart diff.
Calculate a smart diff over the poloidal axis (axis=0) exploiting that
the first and last poloidal points of the FINESSE grid are the same point.
"""
diff = np.diff(narray, axis=0)
diff_list = np.empty(diff.shape[1])
for j in range(diff.shape[1]):
diff_list[j] = narray[0, j] - narray[-1, j]
diff_simps = np.insert(diff, 0, diff_list, axis=0)
return diff_simps
def rescale(values, new_0=1, new_1=0):
"""
Linearly rescale an array of numbers.
"""
scale = (new_0 - new_1) / (values[0] - values[-1])
shift = new_0 - scale * values[0]
if values.__class__ is np.lib.polynomial.poly1d:
new_poly = np.poly1d(scale * values)
new_poly[0] = values[0] + shift
output = new_poly
else:
output = scale * values + shift
return output, (scale, shift)
plotcounter = 0
def relative_error(real, estimate):
return abs(1 - estimate / real)
def badness(rho_real, real, rho_est, est):
""" Determine the badness of an estimate
Calculate the relative errors at q = 1, q = 1.1, rho = .08, one-but-last
element, and the average relative error. The value is negative if
real < est.
This is returned as the 'badness' together with the index of these points
in the estimate array.
Arguments:
rho_real -- real values of rho
real -- values of the function at the real values of rho
rho_est -- estimated values of rho
est -- values of the function at the estimated values of rho
Returns:
(total_badness,
((badness_pre_q_1_index, badness_pre_q_1),
(badness_q_1_index, badness_q_1),
(badness_post_q_1_index, badness_post_q_1),
(badness_end_index, badness_end),
(badness_max_index, badness_max)))
with:
total_badness -- the average badness
badness_* -- the badness at the specific point
*_index -- the index of the point in rho_est
"""
freal_vs_rho_real = extrap1d(interp1d(rho_real, real))
# Remap real values
real_resc = freal_vs_rho_real(rho_est)
rel_error = relative_error(real_resc,
est)
total_badness = np.nanmean(rel_error)
# Find the index for which the real value is one
index = np.int((np.abs(real_resc-1)).argmin())
badness = rel_error[index]
if real_resc[index] > est[index]:
badness *= -1
badness_q_1_index = index
badness_q_1 = badness
# Find the index for which the real rho is 0.08
index = np.int((np.abs(rho_est-0.08)).argmin())
badness = rel_error[index]
if real_resc[index] > est[index]:
badness *= -1
badness_pre_q_1_index = index
badness_pre_q_1 = badness
# Find the index for which the real value is 1.1
index = np.int((np.abs(real_resc-1.1)).argmin())
badness = rel_error[index]
if real_resc[index] > est[index]:
badness *= -1
badness_post_q_1_index = index
badness_post_q_1 = badness
# Find the one but last index
index = -2
badness = rel_error[index]
if real_resc[index] > est[index]:
badness *= -1
badness_end_index = index
badness_end = badness
if len(np.where(np.nanmax(rel_error) == rel_error)[0]) != 0:
badness_max_index = np.where(np.nanmax(rel_error) == rel_error)[0][0]
badness_max = rel_error[badness_max_index]
else:
badness_max_index = 0
badness_max = np.inf
return (total_badness,
((badness_pre_q_1_index, badness_pre_q_1),
(badness_q_1_index, badness_q_1),
(badness_post_q_1_index, badness_post_q_1),
(badness_end_index, badness_end),
(badness_max_index, badness_max)))
def extrap1d(interpolator):
xs = interpolator.x
ys = interpolator.y
def pointwise(x):
if x < xs[0]:
return ys[0]+(x-xs[0])*(ys[1]-ys[0])/(xs[1]-xs[0])
elif x > xs[-1]:
return ys[-1]+(x-xs[-1])*(ys[-1]-ys[-2])/(xs[-1]-xs[-2])
else:
return interpolator(x)
def ufunclike(xs):
return np.array(list(map(pointwise, np.array(xs))))
return ufunclike
if platform == "win32":
def create_windows_shortcut(src, dst):
"""
Create a shortcut on a windows system. This function is deprecated.
"""
warnings.warn("Function is deprecated and might give unexpected results")
path = os.path.join(dst + ".lnk")
target = src
wDir = os.path.dirname(dst)
icon = src
shell = Dispatch('WScript.Shell')
shortcut = shell.CreateShortCut(path)
shortcut.Targetpath = target
shortcut.Workingdirectory = wDir
shortcut.IconLocation = icon
shortcut.save()
def combine_badness(stuff, weights=[1, 4, 8, 6, 4]):
"""
Combine the badness array generated with the badness() function into one
combined badness number. Function is deprecated.
"""
warnings.warn("Function is deprecated and might give unexpected results")
(tot, ((i_0, bd0), (i_1, bd1), (i_2, bd2), (i_3, bd3), (i_4, bd4))) = stuff
badness = np.average([tot, bd0, bd1, bd2, bd3], weights=weights)
if bd4 > 0.8:
badness += bd4
return badness
#def fit_finesse_poly(x, y):
# """
# Fit a polynomial with a constraint on the coefficients.
# This function is deprecated.
# """
# warnings.warn("Function is deprecated and might give unexpected results")
# constraint = 50
# penalty = 1
#
# def order3(x, p3, p2, p1, p0):
# have_penalty = np.any(np.abs([p3, p2, p1, p0]) > constraint)
# return p0 + p1 * x + p2 * x ** 2 + p3 * x ** 3 + have_penalty * penalty
#
# def order4(x, p4, p3, p2, p1, p0):
# have_penalty = np.any(np.abs([p4, p3, p2, p1, p0]) > constraint)
# return p0 + p1 * x + p2 * x ** 2 + p3 * x ** 3 + p4 * x ** 4 + have_penalty * penalty
#
# def order5(x, p5, p4, p3, p2, p1, p0):
# have_penalty = np.any(np.abs([p5, p4, p3, p2, p1, p0]) > constraint)
# return p0 + p1 * x + p2 * x ** 2 + p3 * x ** 3 + p4 * x ** 4 + p5 * x ** 5 + have_penalty * penalty
#
# def order6(x, p6, p5, p4, p3, p2, p1, p0):
# have_penalty = np.any(np.abs([p6, p5, p4, p3, p2, p1, p0]) > constraint)
# return p0 + p1 * x + p2 * x ** 2 + p3 * x ** 3 + p4 * x ** 4 + p5 * x ** 5 + p6 * x ** 6 + have_penalty * penalty
#
# def order7(x, p7, p6, p5, p4, p3, p2, p1, p0):
# have_penalty = np.any(np.abs([p7, p6, p5, p4, p3, p2, p1, p0]) > constraint)
# return p0 + p1 * x + p2 * x ** 2 + p3 * x ** 3 + p4 * x ** 4 + p5 * x ** 5 + p6 * x ** 6 + p7 * x ** 7 + have_penalty * penalty
# poly_list = [order3, order4, order5, order6, order7]
#
# polies = []
# for i, poly in enumerate(poly_list):
# if i == 0:
# init_guess = [1, 1, 1, 1]
# else:
# init_guess = np.append(polies[i-1], 1)
#
# popt, pcov, infodict, errmsg, ier = curve_fit(poly, x, y,
# p0=init_guess,
# full_output=True)
# polies.append(popt)
# values = np.polyval(popt, x)
# values_mean = np.mean(values)
# ss_tot = np.sum((values - values_mean) ** 2)
# ss_res = np.sum((values - y) ** 2)
# rsquared = 1-(ss_res / ss_tot)
#
# bestFit = popt
#
# return bestFit
def frange(start, stop=None, step=1, precision=3):
"""frange generates a set of floating point values over the
This function is deprecated.
range [start, stop] with step size step rounded with precision places
after the decimal point.
frange([start,] stop [, step ])
"""
warnings.warn("Function is deprecated and might give unexpected results")
_xrange = xrange
if stop is None:
for x in _xrange(int(ceil(start))):
yield x
else:
# create a generator expression for the index values
indices = (i for i in _xrange(0, int(round((stop-start)/step + 1,
precision))))
# yield results
for i in indices:
yield start + step*i
|
gpl-3.0
|
[
3168,
1182,
2647,
15,
1393,
15,
1813,
2366,
199,
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
624,
199,
2765,
859,
3509,
7249,
3201,
19549,
7249,
1202,
23088,
314,
17689,
18,
81,
859,
14,
199,
7940,
2597,
3509,
2005,
5906,
3423,
626,
1265,
883,
675,
737,
2195,
5705,
22633,
14,
199,
32,
2502,
26,
1804,
1530,
76,
20744,
477,
510,
4297,
595,
199,
32,
606,
4894,
26,
14629,
86,
19,
199,
624,
199,
199,
646,
747,
199,
646,
3598,
199,
504,
3473,
492,
30449,
199,
199,
646,
2680,
465,
980,
199,
3,
504,
7026,
14,
13416,
492,
15318,
63,
3269,
199,
504,
7026,
14,
21294,
492,
23716,
17,
68,
199,
199,
3,
28196,
367,
570,
26212,
199,
504,
984,
492,
4298,
199,
692,
4298,
508,
298,
2676,
708,
582,
272,
687,
4747,
708,
957,
14,
1258,
492,
28626,
421,
199,
318,
1425,
63,
16,
63,
18,
1038,
8,
78,
1144,
12,
13464,
29,
16,
14,
4587,
304,
272,
408,
497,
1130,
1006,
1338,
687,
5243,
18,
1038,
12,
499,
1038,
61,
370,
359,
16,
12,
499,
1038,
61,
1041,
272,
327,
29861,
22965,
8292,
6818,
21551,
272,
302,
1144,
59,
2101,
8,
78,
1144,
9,
665,
13464,
61,
275,
378,
272,
6946,
63,
4108,
275,
302,
1144,
665,
378,
272,
302,
1144,
59,
7371,
63,
4108,
61,
275,
302,
1144,
59,
7371,
63,
4108,
61,
435,
499,
627,
980,
14,
1038,
272,
372,
302,
1144,
421,
199,
318,
11179,
63,
3028,
8,
78,
1144,
304,
272,
408,
14860,
282,
11179,
3915,
14,
339,
12707,
282,
11179,
3915,
1806,
314,
1115,
320,
344,
279,
3114,
334,
3127,
29,
16,
9,
15868,
390,
316,
626,
272,
314,
1642,
436,
2061,
1115,
320,
344,
279,
4501,
402,
314,
481,
568,
654,
899,
6068,
787,
314,
2011,
2376,
14,
272,
408,
272,
3915,
275,
980,
14,
3028,
8,
78,
1144,
12,
3114,
29,
16,
9,
272,
3915,
63,
513,
275,
980,
14,
1667,
8,
3028,
14,
1392,
59,
17,
566,
272,
367,
1335,
315,
1425,
8,
3028,
14,
1392,
59,
17,
4682,
267,
3915,
63,
513,
59,
74,
61,
275,
302,
1144,
59,
16,
12,
1335,
61,
446,
302,
1144,
1988,
17,
12,
1335,
61,
272,
3915,
63,
11184,
83,
275,
980,
14,
3176,
8,
3028,
12,
378,
12,
3915,
63,
513,
12,
3114,
29,
16,
9,
272,
372,
3915,
63,
11184,
83,
421,
199,
318,
522,
2357,
8,
1459,
12,
892,
63,
16,
29,
17,
12,
892,
63,
17,
29,
16,
304,
272,
408,
272,
12489,
590,
522,
2357,
376,
1625,
402,
5579,
14,
272,
408,
272,
4666,
275,
334,
1222,
63,
16,
446,
892,
63,
17,
9,
1182,
334,
1459,
59,
16,
61,
446,
1338,
1988,
17,
566,
272,
7706,
275,
892,
63,
16,
446,
4666,
627,
1338,
59,
16,
61,
272,
340,
1338,
855,
533,
363,
365,
980,
14,
773,
14,
22104,
14,
6023,
17,
68,
26,
267,
892,
63,
6023,
275,
980,
14,
6023,
17,
68,
8,
3467,
627,
1338,
9,
267,
892,
63,
6023,
59,
16,
61,
275,
1338,
59,
16,
61,
435,
7706,
267,
1072,
275,
892,
63,
6023,
272,
587,
26,
267,
1072,
275,
4666,
627,
1338,
435,
7706,
339,
372,
1072,
12,
334,
3467,
12,
7706,
9,
199,
199,
2798,
5337,
275,
378,
421,
199,
318,
3847,
63,
705,
8,
3093,
12,
14497,
304,
272,
372,
2853,
8,
17,
446,
14497,
1182,
3363,
9,
421,
199,
318,
4875,
4171,
8,
10412,
63,
3093,
12,
3363,
12,
17908,
63,
597,
12,
4347,
304,
272,
408,
14703,
314,
4875,
4171,
402,
376,
14497,
272,
12707,
314,
3847,
2552,
737,
1894,
275,
413,
12,
1894,
275,
413,
14,
17,
12,
17908,
275,
1275,
2036,
12,
1373,
13,
7911,
13,
2019,
272,
1819,
12,
436,
314,
8095,
3847,
1125,
14,
710,
574,
365,
6946,
340,
272,
3363,
665,
4347,
14,
272,
961,
365,
2138,
465,
314,
283,
4087,
4171,
7,
10451,
543,
314,
1478,
402,
3520,
4501,
272,
315,
314,
14497,
1625,
14,
339,
7628,
26,
272,
17908,
63,
3093,
1553,
3363,
1338,
402,
17908,
272,
3363,
1553,
1338,
402,
314,
805,
737,
314,
3363,
1338,
402,
17908,
272,
17908,
63,
597,
1553,
20077,
1338,
402,
17908,
272,
4347,
1553,
1338,
402,
314,
805,
737,
314,
20077,
1338,
402,
17908,
339,
1803,
26,
272,
334,
2923,
63,
4087,
4171,
12,
673,
3666,
4087,
4171,
63,
657,
63,
81,
63,
17,
63,
1080,
12,
221,
4875,
4171,
63,
657,
63,
81,
63,
17,
395,
490,
334,
4087,
4171,
63,
81,
63,
17,
63,
1080,
12,
420,
4875,
4171,
63,
81,
63,
17,
395,
490,
334,
4087,
4171,
63,
1932,
63,
81,
63,
17,
63,
1080,
12,
4875,
4171,
63,
1932,
63,
81,
63,
17,
395,
490,
334,
4087,
4171,
63,
500,
63,
1080,
12,
420,
4875,
4171,
63,
500,
395,
490,
334,
4087,
4171,
63,
988,
63,
1080,
12,
420,
4875,
4171,
63,
988,
1724,
272,
543,
26,
272,
3141,
63,
4087,
4171,
1553,
314,
8095,
4875,
4171,
272,
4875,
4171,
15192,
1553,
314,
4875,
4171,
737,
314,
2488,
2376,
272,
20841,
1080,
1553,
314,
1478,
402,
314,
2376,
315,
17908,
63,
597,
272,
408,
339,
289,
3093,
63,
3122,
63,
10412,
63,
3093,
275,
31964,
17,
68,
8,
14252,
17,
68,
8,
10412,
63,
3093,
12,
3363,
430,
272,
327,
799,
1130,
3363,
1338,
272,
3363,
63,
32318,
275,
289,
3093,
63,
3122,
63,
10412,
63,
3093,
8,
10412,
63,
597,
9,
272,
4668,
63,
705,
275,
3847,
63,
705,
8,
3093,
63,
32318,
12,
3044,
4347,
9,
272,
3141,
63,
4087,
4171,
275,
980,
14,
4304,
3670,
8,
3369,
63,
705,
9,
339,
327,
6668,
314,
1478,
367,
1314,
314,
3363,
574,
365,
1373,
272,
1478,
275,
980,
14,
442,
1332,
1590,
14,
2101,
8,
3093,
63,
32318,
13,
17,
4992,
26488,
1012,
272,
4875,
4171,
275,
4668,
63,
705,
59,
1080,
61,
272,
340,
3363,
63,
32318,
59,
1080,
61,
690,
4347,
59,
1080,
2189,
267,
4875,
4171,
9000,
446,
17,
272,
4875,
4171,
63,
81,
63,
17,
63,
1080,
275,
1478,
272,
4875,
4171,
63,
81,
63,
17,
275,
4875,
4171,
339,
327,
6668,
314,
1478,
367,
1314,
314,
3363,
17908,
365,
378,
14,
2036,
272,
1478,
275,
980,
14
] |
[
1182,
2647,
15,
1393,
15,
1813,
2366,
199,
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
624,
199,
2765,
859,
3509,
7249,
3201,
19549,
7249,
1202,
23088,
314,
17689,
18,
81,
859,
14,
199,
7940,
2597,
3509,
2005,
5906,
3423,
626,
1265,
883,
675,
737,
2195,
5705,
22633,
14,
199,
32,
2502,
26,
1804,
1530,
76,
20744,
477,
510,
4297,
595,
199,
32,
606,
4894,
26,
14629,
86,
19,
199,
624,
199,
199,
646,
747,
199,
646,
3598,
199,
504,
3473,
492,
30449,
199,
199,
646,
2680,
465,
980,
199,
3,
504,
7026,
14,
13416,
492,
15318,
63,
3269,
199,
504,
7026,
14,
21294,
492,
23716,
17,
68,
199,
199,
3,
28196,
367,
570,
26212,
199,
504,
984,
492,
4298,
199,
692,
4298,
508,
298,
2676,
708,
582,
272,
687,
4747,
708,
957,
14,
1258,
492,
28626,
421,
199,
318,
1425,
63,
16,
63,
18,
1038,
8,
78,
1144,
12,
13464,
29,
16,
14,
4587,
304,
272,
408,
497,
1130,
1006,
1338,
687,
5243,
18,
1038,
12,
499,
1038,
61,
370,
359,
16,
12,
499,
1038,
61,
1041,
272,
327,
29861,
22965,
8292,
6818,
21551,
272,
302,
1144,
59,
2101,
8,
78,
1144,
9,
665,
13464,
61,
275,
378,
272,
6946,
63,
4108,
275,
302,
1144,
665,
378,
272,
302,
1144,
59,
7371,
63,
4108,
61,
275,
302,
1144,
59,
7371,
63,
4108,
61,
435,
499,
627,
980,
14,
1038,
272,
372,
302,
1144,
421,
199,
318,
11179,
63,
3028,
8,
78,
1144,
304,
272,
408,
14860,
282,
11179,
3915,
14,
339,
12707,
282,
11179,
3915,
1806,
314,
1115,
320,
344,
279,
3114,
334,
3127,
29,
16,
9,
15868,
390,
316,
626,
272,
314,
1642,
436,
2061,
1115,
320,
344,
279,
4501,
402,
314,
481,
568,
654,
899,
6068,
787,
314,
2011,
2376,
14,
272,
408,
272,
3915,
275,
980,
14,
3028,
8,
78,
1144,
12,
3114,
29,
16,
9,
272,
3915,
63,
513,
275,
980,
14,
1667,
8,
3028,
14,
1392,
59,
17,
566,
272,
367,
1335,
315,
1425,
8,
3028,
14,
1392,
59,
17,
4682,
267,
3915,
63,
513,
59,
74,
61,
275,
302,
1144,
59,
16,
12,
1335,
61,
446,
302,
1144,
1988,
17,
12,
1335,
61,
272,
3915,
63,
11184,
83,
275,
980,
14,
3176,
8,
3028,
12,
378,
12,
3915,
63,
513,
12,
3114,
29,
16,
9,
272,
372,
3915,
63,
11184,
83,
421,
199,
318,
522,
2357,
8,
1459,
12,
892,
63,
16,
29,
17,
12,
892,
63,
17,
29,
16,
304,
272,
408,
272,
12489,
590,
522,
2357,
376,
1625,
402,
5579,
14,
272,
408,
272,
4666,
275,
334,
1222,
63,
16,
446,
892,
63,
17,
9,
1182,
334,
1459,
59,
16,
61,
446,
1338,
1988,
17,
566,
272,
7706,
275,
892,
63,
16,
446,
4666,
627,
1338,
59,
16,
61,
272,
340,
1338,
855,
533,
363,
365,
980,
14,
773,
14,
22104,
14,
6023,
17,
68,
26,
267,
892,
63,
6023,
275,
980,
14,
6023,
17,
68,
8,
3467,
627,
1338,
9,
267,
892,
63,
6023,
59,
16,
61,
275,
1338,
59,
16,
61,
435,
7706,
267,
1072,
275,
892,
63,
6023,
272,
587,
26,
267,
1072,
275,
4666,
627,
1338,
435,
7706,
339,
372,
1072,
12,
334,
3467,
12,
7706,
9,
199,
199,
2798,
5337,
275,
378,
421,
199,
318,
3847,
63,
705,
8,
3093,
12,
14497,
304,
272,
372,
2853,
8,
17,
446,
14497,
1182,
3363,
9,
421,
199,
318,
4875,
4171,
8,
10412,
63,
3093,
12,
3363,
12,
17908,
63,
597,
12,
4347,
304,
272,
408,
14703,
314,
4875,
4171,
402,
376,
14497,
272,
12707,
314,
3847,
2552,
737,
1894,
275,
413,
12,
1894,
275,
413,
14,
17,
12,
17908,
275,
1275,
2036,
12,
1373,
13,
7911,
13,
2019,
272,
1819,
12,
436,
314,
8095,
3847,
1125,
14,
710,
574,
365,
6946,
340,
272,
3363,
665,
4347,
14,
272,
961,
365,
2138,
465,
314,
283,
4087,
4171,
7,
10451,
543,
314,
1478,
402,
3520,
4501,
272,
315,
314,
14497,
1625,
14,
339,
7628,
26,
272,
17908,
63,
3093,
1553,
3363,
1338,
402,
17908,
272,
3363,
1553,
1338,
402,
314,
805,
737,
314,
3363,
1338,
402,
17908,
272,
17908,
63,
597,
1553,
20077,
1338,
402,
17908,
272,
4347,
1553,
1338,
402,
314,
805,
737,
314,
20077,
1338,
402,
17908,
339,
1803,
26,
272,
334,
2923,
63,
4087,
4171,
12,
673,
3666,
4087,
4171,
63,
657,
63,
81,
63,
17,
63,
1080,
12,
221,
4875,
4171,
63,
657,
63,
81,
63,
17,
395,
490,
334,
4087,
4171,
63,
81,
63,
17,
63,
1080,
12,
420,
4875,
4171,
63,
81,
63,
17,
395,
490,
334,
4087,
4171,
63,
1932,
63,
81,
63,
17,
63,
1080,
12,
4875,
4171,
63,
1932,
63,
81,
63,
17,
395,
490,
334,
4087,
4171,
63,
500,
63,
1080,
12,
420,
4875,
4171,
63,
500,
395,
490,
334,
4087,
4171,
63,
988,
63,
1080,
12,
420,
4875,
4171,
63,
988,
1724,
272,
543,
26,
272,
3141,
63,
4087,
4171,
1553,
314,
8095,
4875,
4171,
272,
4875,
4171,
15192,
1553,
314,
4875,
4171,
737,
314,
2488,
2376,
272,
20841,
1080,
1553,
314,
1478,
402,
314,
2376,
315,
17908,
63,
597,
272,
408,
339,
289,
3093,
63,
3122,
63,
10412,
63,
3093,
275,
31964,
17,
68,
8,
14252,
17,
68,
8,
10412,
63,
3093,
12,
3363,
430,
272,
327,
799,
1130,
3363,
1338,
272,
3363,
63,
32318,
275,
289,
3093,
63,
3122,
63,
10412,
63,
3093,
8,
10412,
63,
597,
9,
272,
4668,
63,
705,
275,
3847,
63,
705,
8,
3093,
63,
32318,
12,
3044,
4347,
9,
272,
3141,
63,
4087,
4171,
275,
980,
14,
4304,
3670,
8,
3369,
63,
705,
9,
339,
327,
6668,
314,
1478,
367,
1314,
314,
3363,
574,
365,
1373,
272,
1478,
275,
980,
14,
442,
1332,
1590,
14,
2101,
8,
3093,
63,
32318,
13,
17,
4992,
26488,
1012,
272,
4875,
4171,
275,
4668,
63,
705,
59,
1080,
61,
272,
340,
3363,
63,
32318,
59,
1080,
61,
690,
4347,
59,
1080,
2189,
267,
4875,
4171,
9000,
446,
17,
272,
4875,
4171,
63,
81,
63,
17,
63,
1080,
275,
1478,
272,
4875,
4171,
63,
81,
63,
17,
275,
4875,
4171,
339,
327,
6668,
314,
1478,
367,
1314,
314,
3363,
17908,
365,
378,
14,
2036,
272,
1478,
275,
980,
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,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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
] |
nilbody/h2o-3
|
h2o-py/tests/testdir_algos/deeplearning/pyunit_iris_grid_deeplearning.py
|
2
|
1446
|
from __future__ import print_function
from builtins import map
from builtins import range
import sys
sys.path.insert(1,"../../../")
import h2o
from tests import pyunit_utils
import itertools
from h2o.grid.grid_search import H2OGridSearch
from h2o.estimators.deeplearning import H2ODeepLearningEstimator
from collections import OrderedDict
def iris_dl_grid():
train = h2o.import_file(path=pyunit_utils.locate("smalldata/iris/iris_wheader.csv"))
# Run DL
hidden_opts = [[20,20],[50,50,50]]
loss_opts = ["Quadratic","CrossEntropy"]
size_of_hyper_space = len(hidden_opts) * len(loss_opts)
hyper_parameters = OrderedDict()
hyper_parameters["loss"] = loss_opts
hyper_parameters["hidden"] = hidden_opts
print("DL grid with the following hyper_parameters:", hyper_parameters)
gs = H2OGridSearch(H2ODeepLearningEstimator, hyper_params=hyper_parameters)
gs.train(x=list(range(4)), y=4, training_frame=train)
print(gs.sort_by("mse"))
for model in gs:
assert isinstance(model, H2ODeepLearningEstimator)
assert len(gs) == size_of_hyper_space
total_grid_space = list(map(list, itertools.product(*list(hyper_parameters.values()))))
for model in gs.models:
combo = [model.parms['loss']['actual_value']] + [model.parms['hidden']['actual_value']]
assert combo in total_grid_space
total_grid_space.remove(combo)
if __name__ == "__main__":
pyunit_utils.standalone_test(iris_dl_grid)
else:
iris_dl_grid()
|
apache-2.0
|
[
504,
636,
2443,
363,
492,
870,
63,
1593,
199,
504,
12963,
492,
2341,
199,
504,
12963,
492,
1425,
199,
646,
984,
199,
1274,
14,
515,
14,
3176,
8,
17,
4589,
29866,
531,
199,
646,
394,
18,
79,
199,
504,
2295,
492,
1134,
3248,
63,
1208,
199,
646,
7975,
199,
504,
394,
18,
79,
14,
3825,
14,
3825,
63,
1733,
492,
869,
18,
47,
7900,
5278,
199,
504,
394,
18,
79,
14,
10646,
14,
16131,
10546,
492,
869,
18,
47,
27753,
25519,
13183,
199,
504,
5055,
492,
8773,
199,
199,
318,
12192,
63,
5030,
63,
3825,
837,
523,
3560,
275,
394,
18,
79,
14,
646,
63,
493,
8,
515,
29,
647,
3248,
63,
1208,
14,
6280,
480,
7241,
576,
15,
11885,
15,
11885,
63,
87,
1291,
14,
4737,
2237,
819,
327,
3378,
577,
44,
819,
8752,
63,
3291,
275,
3474,
1165,
12,
1165,
6922,
1400,
12,
1400,
12,
1400,
2677,
523,
5621,
63,
3291,
275,
2097,
23053,
19826,
2266,
14072,
31224,
937,
523,
1568,
63,
1618,
63,
9547,
63,
2638,
275,
822,
8,
5642,
63,
3291,
9,
627,
822,
8,
4358,
63,
3291,
9,
523,
10342,
63,
3214,
275,
8773,
342,
523,
10342,
63,
3214,
905,
4358,
937,
221,
275,
5621,
63,
3291,
523,
10342,
63,
3214,
905,
5642,
937,
275,
8752,
63,
3291,
523,
870,
480,
8045,
6068,
543,
314,
2569,
10342,
63,
3214,
6783,
10342,
63,
3214,
9,
819,
8763,
275,
869,
18,
47,
7900,
5278,
8,
40,
18,
47,
27753,
25519,
13183,
12,
10342,
63,
1162,
29,
9547,
63,
3214,
9,
523,
8763,
14,
2834,
8,
88,
29,
513,
8,
1842,
8,
20,
1826,
612,
29,
20,
12,
6093,
63,
1943,
29,
2834,
9,
523,
870,
8,
458,
14,
3191,
63,
991,
480,
23927,
2237,
819,
367,
1402,
315,
8763,
26,
272,
702,
1228,
8,
1238,
12,
869,
18,
47,
27753,
25519,
13183,
9,
819,
702,
822,
8,
458,
9,
508,
1568,
63,
1618,
63,
9547,
63,
2638,
523,
3141,
63,
3825,
63,
2638,
275,
769,
8,
1130,
8,
513,
12,
7975,
14,
2558,
2031,
513,
8,
9547,
63,
3214,
14,
1459,
4059,
430,
523,
367,
1402,
315,
8763,
14,
992,
26,
272,
20972,
275,
359,
1238,
14,
28899,
459,
4358,
2545,
6514,
63,
585,
6538,
435,
359,
1238,
14,
28899,
459,
5642,
2545,
6514,
63,
585,
6538,
272,
702,
20972,
315,
3141,
63,
3825,
63,
2638,
272,
3141,
63,
3825,
63,
2638,
14,
2168,
8,
12650,
9,
4388,
199,
692,
636,
354,
363,
508,
4396,
973,
5727,
523,
1134,
3248,
63,
1208,
14,
20323,
63,
396,
8,
11885,
63,
5030,
63,
3825,
9,
199,
2836,
26,
523,
12192,
63,
5030,
63,
3825,
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
] |
[
636,
2443,
363,
492,
870,
63,
1593,
199,
504,
12963,
492,
2341,
199,
504,
12963,
492,
1425,
199,
646,
984,
199,
1274,
14,
515,
14,
3176,
8,
17,
4589,
29866,
531,
199,
646,
394,
18,
79,
199,
504,
2295,
492,
1134,
3248,
63,
1208,
199,
646,
7975,
199,
504,
394,
18,
79,
14,
3825,
14,
3825,
63,
1733,
492,
869,
18,
47,
7900,
5278,
199,
504,
394,
18,
79,
14,
10646,
14,
16131,
10546,
492,
869,
18,
47,
27753,
25519,
13183,
199,
504,
5055,
492,
8773,
199,
199,
318,
12192,
63,
5030,
63,
3825,
837,
523,
3560,
275,
394,
18,
79,
14,
646,
63,
493,
8,
515,
29,
647,
3248,
63,
1208,
14,
6280,
480,
7241,
576,
15,
11885,
15,
11885,
63,
87,
1291,
14,
4737,
2237,
819,
327,
3378,
577,
44,
819,
8752,
63,
3291,
275,
3474,
1165,
12,
1165,
6922,
1400,
12,
1400,
12,
1400,
2677,
523,
5621,
63,
3291,
275,
2097,
23053,
19826,
2266,
14072,
31224,
937,
523,
1568,
63,
1618,
63,
9547,
63,
2638,
275,
822,
8,
5642,
63,
3291,
9,
627,
822,
8,
4358,
63,
3291,
9,
523,
10342,
63,
3214,
275,
8773,
342,
523,
10342,
63,
3214,
905,
4358,
937,
221,
275,
5621,
63,
3291,
523,
10342,
63,
3214,
905,
5642,
937,
275,
8752,
63,
3291,
523,
870,
480,
8045,
6068,
543,
314,
2569,
10342,
63,
3214,
6783,
10342,
63,
3214,
9,
819,
8763,
275,
869,
18,
47,
7900,
5278,
8,
40,
18,
47,
27753,
25519,
13183,
12,
10342,
63,
1162,
29,
9547,
63,
3214,
9,
523,
8763,
14,
2834,
8,
88,
29,
513,
8,
1842,
8,
20,
1826,
612,
29,
20,
12,
6093,
63,
1943,
29,
2834,
9,
523,
870,
8,
458,
14,
3191,
63,
991,
480,
23927,
2237,
819,
367,
1402,
315,
8763,
26,
272,
702,
1228,
8,
1238,
12,
869,
18,
47,
27753,
25519,
13183,
9,
819,
702,
822,
8,
458,
9,
508,
1568,
63,
1618,
63,
9547,
63,
2638,
523,
3141,
63,
3825,
63,
2638,
275,
769,
8,
1130,
8,
513,
12,
7975,
14,
2558,
2031,
513,
8,
9547,
63,
3214,
14,
1459,
4059,
430,
523,
367,
1402,
315,
8763,
14,
992,
26,
272,
20972,
275,
359,
1238,
14,
28899,
459,
4358,
2545,
6514,
63,
585,
6538,
435,
359,
1238,
14,
28899,
459,
5642,
2545,
6514,
63,
585,
6538,
272,
702,
20972,
315,
3141,
63,
3825,
63,
2638,
272,
3141,
63,
3825,
63,
2638,
14,
2168,
8,
12650,
9,
4388,
199,
692,
636,
354,
363,
508,
4396,
973,
5727,
523,
1134,
3248,
63,
1208,
14,
20323,
63,
396,
8,
11885,
63,
5030,
63,
3825,
9,
199,
2836,
26,
523,
12192,
63,
5030,
63,
3825,
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,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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import COMM, ID3
from flash_air_music.convert import discover, id3_flac_tags
from tests import HERE
@pytest.mark.parametrize('mode', ['no target', 'no prev metadata', 'st', 'ss', 'tt', 'ts', 'up to date'])
def test_song(tmpdir, mode):
"""Test Song class.
:param tmpdir: pytest fixture.
:param str mode: Scenario to test for.
"""
source_file = tmpdir.ensure('source', 'song.mp3')
target_file = tmpdir.ensure('target', 'song.mp3')
HERE.join('1khz_sine_2.mp3').copy(source_file)
# Write metadata.
if mode != 'no target':
source_file.copy(target_file)
if mode != 'no prev metadata':
ID3(str(target_file)).save(padding=lambda _: 200)
metadata = dict(
source_mtime=int(source_file.stat().mtime) - (20 if mode == 'st' else 0),
source_size=int(source_file.stat().size) - (20 if mode == 'ss' else 0),
target_mtime=int(target_file.stat().mtime) - (20 if mode == 'tt' else 0),
target_size=int(target_file.stat().size) - (20 if mode == 'ts' else 0),
)
atime, mtime = time.time(), target_file.stat().mtime
id3 = ID3(str(target_file))
id3.add(COMM(desc=id3_flac_tags.COMMENT_DESCRIPTION, encoding=3, lang='eng', text=json.dumps(metadata)))
id3.save()
os.utime(str(target_file), (atime, mtime))
# Run.
song = discover.Song(str(source_file), source_file.dirname, target_file.dirname)
# Verify.
assert song.source == str(source_file)
assert song.target == str(target_file)
assert song.needs_action is (False if mode == 'up to date' else True)
assert repr(song) == '<Song name=song.mp3 needs_action={}>'.format(song.needs_action)
assert song.changed is False
# Test changed.
ID3(str(source_file)).save(padding=lambda _: 200)
assert song.changed is True
song.refresh_live_metadata()
assert song.changed is False
def test_get_songs(tmpdir):
"""Test get_songs() function.
:param tmpdir: pytest fixture.
"""
source_dir = tmpdir.ensure_dir('source')
target_dir = tmpdir.ensure_dir('target')
# Test empty.
songs, valid_targets = discover.get_songs(str(source_dir), str(target_dir))
assert not songs
assert not valid_targets
# Test ignore.
source_dir.ensure('ignore.txt')
songs, valid_targets = discover.get_songs(str(source_dir), str(target_dir))
assert not songs
assert not valid_targets
# Create mp3 that needs conversion and FLAC that doesn't.
HERE.join('1khz_sine_2.mp3').copy(source_dir.join('song1.mp3'))
HERE.join('1khz_sine_1.flac').copy(source_dir.join('song2.flac'))
HERE.join('1khz_sine_2.mp3').copy(target_dir.join('song2.mp3'))
ID3(str(target_dir.join('song2.mp3'))).save(padding=lambda _: 200)
metadata = dict(
source_mtime=int(source_dir.join('song2.flac').stat().mtime),
source_size=int(source_dir.join('song2.flac').stat().size),
target_mtime=int(target_dir.join('song2.mp3').stat().mtime),
target_size=int(target_dir.join('song2.mp3').stat().size),
)
atime, mtime = time.time(), target_dir.join('song2.mp3').stat().mtime
id3 = ID3(str(target_dir.join('song2.mp3')))
id3.add(COMM(desc=id3_flac_tags.COMMENT_DESCRIPTION, encoding=3, lang='eng', text=json.dumps(metadata)))
id3.save()
os.utime(str(target_dir.join('song2.mp3')), (atime, mtime))
# Test those files.
songs, valid_targets = discover.get_songs(str(source_dir), str(target_dir))
assert len(songs) == 1
assert len(valid_targets) == 2
assert songs[0].source == str(source_dir.join('song1.mp3'))
assert songs[0].target == str(target_dir.join('song1.mp3'))
assert sorted(valid_targets) == [str(target_dir.join('song1.mp3')), str(target_dir.join('song2.mp3'))]
def test_get_songs_subdirectories(tmpdir):
"""Test get_songs() with nested subdirectories.
:param tmpdir: pytest fixture.
"""
# Setup directory structure.
source_dir = tmpdir.ensure_dir('source')
source_dir_a = source_dir.ensure_dir('a')
source_dir_b = source_dir.ensure_dir('b')
source_dir_c = source_dir.ensure_dir('b', 'c')
source_dir_d = source_dir.ensure_dir('b', 'c', 'd')
target_dir = tmpdir.ensure_dir('target')
# Copy files.
HERE.join('1khz_sine_2.mp3').copy(source_dir.join('song1.mp3'))
HERE.join('1khz_sine_2.mp3').copy(source_dir_a.join('song2.mp3'))
HERE.join('1khz_sine_2.mp3').copy(source_dir_b.join('song3.mp3'))
HERE.join('1khz_sine_2.mp3').copy(source_dir_c.join('song4.mp3'))
HERE.join('1khz_sine_2.mp3').copy(source_dir_d.join('song5.mp3'))
# Test those files.
songs, valid_targets = discover.get_songs(str(source_dir), str(target_dir))
assert len(songs) == 5
assert len(valid_targets) == 5
expected = {
str(source_dir.join('song1.mp3')),
str(source_dir_a.join('song2.mp3')),
str(source_dir_b.join('song3.mp3')),
str(source_dir_c.join('song4.mp3')),
str(source_dir_d.join('song5.mp3')),
}
assert {s.source for s in songs} == expected
expected = {
str(target_dir.join('song1.mp3')),
str(target_dir.join('a', 'song2.mp3')),
str(target_dir.join('b', 'song3.mp3')),
str(target_dir.join('b', 'c', 'song4.mp3')),
str(target_dir.join('b', 'c', 'd', 'song5.mp3')),
}
assert {s.target for s in songs} == expected
assert sorted(valid_targets) == sorted(expected)
def test_files_dirs_to_delete(tmpdir):
"""Test files_dirs_to_delete() function.
:param tmpdir: pytest fixture.
"""
target_dir = tmpdir.ensure_dir('target')
valid_targets = list()
# Test empty.
delete_files, remove_dirs = discover.files_dirs_to_delete(str(target_dir), valid_targets)
assert not delete_files
assert not remove_dirs
# Test ignore.
target_dir.ensure('ignore.txt')
target_dir.ensure_dir('not_empty').ensure('ignore.txt')
delete_files, remove_dirs = discover.files_dirs_to_delete(str(target_dir), valid_targets)
assert not delete_files
assert not remove_dirs
# Setup filesystem.
expected_delete, expected_remove = set(), {str(target_dir.ensure_dir('remove_this_dir'))}
expected_delete.add(str(target_dir.ensure('remove_this_dir', 'remove_me.mp3')))
expected_delete.add(str(target_dir.ensure('remove_me_too.mp3')))
expected_remove.add(str(target_dir.ensure_dir('remove_this_dir_too')))
valid_targets.append(str(target_dir.ensure('keep_me.mp3')))
valid_targets.append(str(target_dir.ensure_dir('keep_this').ensure('keep_me.mp3')))
# Test those files.
delete_files, remove_dirs = discover.files_dirs_to_delete(str(target_dir), valid_targets)
assert delete_files == expected_delete
assert remove_dirs == expected_remove
|
mit
|
[
624,
774,
3423,
315,
859,
1041,
199,
199,
646,
2022,
199,
646,
747,
199,
646,
900,
199,
199,
646,
4613,
199,
504,
8567,
24758,
14,
344,
19,
492,
11293,
12,
2870,
19,
199,
199,
504,
14775,
63,
8387,
63,
20544,
14,
3916,
492,
20131,
12,
1305,
19,
63,
14163,
67,
63,
2969,
199,
504,
2295,
492,
869,
28106,
421,
199,
32,
4462,
14,
1657,
14,
10396,
360,
632,
297,
788,
889,
1347,
297,
283,
889,
5071,
3341,
297,
283,
270,
297,
283,
385,
297,
283,
6215,
297,
283,
1086,
297,
283,
384,
370,
1434,
1105,
199,
318,
511,
63,
19351,
8,
8616,
12,
818,
304,
272,
408,
774,
29405,
1021,
14,
339,
520,
635,
12885,
26,
4613,
10949,
14,
272,
520,
635,
620,
818,
26,
22840,
370,
511,
367,
14,
272,
408,
272,
1350,
63,
493,
275,
12885,
14,
7505,
360,
1365,
297,
283,
19351,
14,
311,
19,
358,
272,
1347,
63,
493,
275,
12885,
14,
7505,
360,
1375,
297,
283,
19351,
14,
311,
19,
358,
272,
869,
28106,
14,
904,
360,
17,
75,
19552,
63,
83,
1132,
63,
18,
14,
311,
19,
1959,
1574,
8,
1365,
63,
493,
9,
339,
327,
6990,
3341,
14,
272,
340,
818,
1137,
283,
889,
1347,
356,
267,
1350,
63,
493,
14,
1574,
8,
1375,
63,
493,
9,
267,
340,
818,
1137,
283,
889,
5071,
3341,
356,
288,
2870,
19,
8,
495,
8,
1375,
63,
493,
4992,
2117,
8,
8358,
29,
2734,
24700,
1926,
9,
288,
3341,
275,
1211,
8,
355,
1350,
63,
8180,
29,
442,
8,
1365,
63,
493,
14,
3736,
1252,
8180,
9,
446,
334,
1165,
340,
818,
508,
283,
270,
7,
587,
378,
395,
355,
1350,
63,
890,
29,
442,
8,
1365,
63,
493,
14,
3736,
1252,
890,
9,
446,
334,
1165,
340,
818,
508,
283,
385,
7,
587,
378,
395,
355,
1347,
63,
8180,
29,
442,
8,
1375,
63,
493,
14,
3736,
1252,
8180,
9,
446,
334,
1165,
340,
818,
508,
283,
6215,
7,
587,
378,
395,
355,
1347,
63,
890,
29,
442,
8,
1375,
63,
493,
14,
3736,
1252,
890,
9,
446,
334,
1165,
340,
818,
508,
283,
1086,
7,
587,
378,
395,
288,
776,
288,
282,
521,
12,
15005,
275,
900,
14,
521,
1062,
1347,
63,
493,
14,
3736,
1252,
8180,
288,
1305,
19,
275,
2870,
19,
8,
495,
8,
1375,
63,
493,
430,
288,
1305,
19,
14,
525,
8,
5378,
8,
3257,
29,
344,
19,
63,
14163,
67,
63,
2969,
14,
10973,
63,
17705,
12,
2644,
29,
19,
12,
6339,
534,
7420,
297,
1318,
29,
1001,
14,
4180,
8,
2343,
1724,
288,
1305,
19,
14,
2117,
342,
288,
747,
14,
24043,
8,
495,
8,
1375,
63,
493,
395,
334,
27867,
12,
15005,
430,
339,
327,
3378,
14,
272,
20178,
275,
20131,
14,
51,
951,
8,
495,
8,
1365,
63,
493,
395,
1350,
63,
493,
14,
3475,
12,
1347,
63,
493,
14,
3475,
9,
339,
327,
7635,
14,
272,
702,
20178,
14,
1365,
508,
620,
8,
1365,
63,
493,
9,
272,
702,
20178,
14,
1375,
508,
620,
8,
1375,
63,
493,
9,
272,
702,
20178,
14,
10065,
63,
1287,
365,
334,
797,
340,
818,
508,
283,
384,
370,
1434,
7,
587,
715,
9,
272,
702,
4700,
8,
19351,
9,
508,
2650,
51,
951,
536,
29,
19351,
14,
311,
19,
4839,
63,
1287,
7622,
22936,
908,
8,
19351,
14,
10065,
63,
1287,
9,
272,
702,
20178,
14,
2489,
365,
756,
339,
327,
1379,
2896,
14,
272,
2870,
19,
8,
495,
8,
1365,
63,
493,
4992,
2117,
8,
8358,
29,
2734,
24700,
1926,
9,
272,
702,
20178,
14,
2489,
365,
715,
272,
20178,
14,
6635,
63,
6442,
63,
2343,
342,
272,
702,
20178,
14,
2489,
365,
756,
421,
199,
318,
511,
63,
362,
63,
834,
458,
8,
8616,
304,
272,
408,
774,
664,
63,
834,
458,
342,
805,
14,
339,
520,
635,
12885,
26,
4613,
10949,
14,
272,
408,
272,
1350,
63,
694,
275,
12885,
14,
7505,
63,
694,
360,
1365,
358,
272,
1347,
63,
694,
275,
12885,
14,
7505,
63,
694,
360,
1375,
358,
339,
327,
1379,
2701,
14,
272,
308,
12358,
12,
1686,
63,
4684,
275,
20131,
14,
362,
63,
834,
458,
8,
495,
8,
1365,
63,
694,
395,
620,
8,
1375,
63,
694,
430,
272,
702,
440,
308,
12358,
272,
702,
440,
1686,
63,
4684,
339,
327,
1379,
3686,
14,
272,
1350,
63,
694,
14,
7505,
360,
4247,
14,
2424,
358,
272,
308,
12358,
12,
1686,
63,
4684,
275,
20131,
14,
362,
63,
834,
458,
8,
495,
8,
1365,
63,
694,
395,
620,
8,
1375,
63,
694,
430,
272,
702,
440,
308,
12358,
272,
702,
440,
1686,
63,
4684,
339,
327,
2790,
6118,
19,
626,
4839,
8603,
436,
9821,
1348,
626,
3181,
1133,
14,
272,
869,
28106,
14,
904,
360,
17,
75,
19552,
63,
83,
1132,
63,
18,
14,
311,
19,
1959,
1574,
8,
1365,
63,
694,
14,
904,
360,
19351,
17,
14,
311,
19,
1333,
272,
869,
28106,
14,
904,
360,
17,
75,
19552,
63,
83,
1132,
63,
17,
14,
14163,
67,
1959,
1574,
8,
1365,
63,
694,
14,
904,
360,
19351,
18,
14,
14163,
67,
1333,
272,
869,
28106,
14,
904,
360,
17,
75,
19552,
63,
83,
1132,
63,
18,
14,
311,
19,
1959,
1574,
8,
1375,
63,
694,
14,
904,
360,
19351,
18,
14,
311,
19,
1333,
272,
2870,
19,
8,
495,
8,
1375,
63,
694,
14,
904,
360,
19351,
18,
14,
311,
19,
358,
4992,
2117,
8,
8358,
29,
2734,
24700,
1926,
9,
272,
3341,
275,
1211,
8,
267,
1350,
63,
8180,
29,
442,
8,
1365,
63,
694,
14,
904,
360,
19351,
18,
14,
14163,
67,
1959,
3736,
1252,
8180,
395,
267,
1350,
63,
890,
29,
442,
8,
1365,
63,
694,
14,
904,
360,
19351,
18,
14,
14163,
67,
1959,
3736,
1252,
890,
395,
267,
1347,
63,
8180,
29,
442,
8,
1375,
63,
694,
14,
904,
360,
19351,
18,
14,
311,
19,
1959,
3736,
1252,
8180,
395,
267,
1347,
63,
890,
29,
442,
8,
1375,
63,
694,
14,
904,
360,
19351,
18,
14,
311,
19,
1959,
3736,
1252,
890,
395,
272,
776,
272,
282,
521,
12,
15005,
275,
900,
14,
521,
1062,
1347,
63,
694,
14,
904,
360,
19351,
18,
14,
311,
19,
1959,
3736,
1252,
8180
] |
[
774,
3423,
315,
859,
1041,
199,
199,
646,
2022,
199,
646,
747,
199,
646,
900,
199,
199,
646,
4613,
199,
504,
8567,
24758,
14,
344,
19,
492,
11293,
12,
2870,
19,
199,
199,
504,
14775,
63,
8387,
63,
20544,
14,
3916,
492,
20131,
12,
1305,
19,
63,
14163,
67,
63,
2969,
199,
504,
2295,
492,
869,
28106,
421,
199,
32,
4462,
14,
1657,
14,
10396,
360,
632,
297,
788,
889,
1347,
297,
283,
889,
5071,
3341,
297,
283,
270,
297,
283,
385,
297,
283,
6215,
297,
283,
1086,
297,
283,
384,
370,
1434,
1105,
199,
318,
511,
63,
19351,
8,
8616,
12,
818,
304,
272,
408,
774,
29405,
1021,
14,
339,
520,
635,
12885,
26,
4613,
10949,
14,
272,
520,
635,
620,
818,
26,
22840,
370,
511,
367,
14,
272,
408,
272,
1350,
63,
493,
275,
12885,
14,
7505,
360,
1365,
297,
283,
19351,
14,
311,
19,
358,
272,
1347,
63,
493,
275,
12885,
14,
7505,
360,
1375,
297,
283,
19351,
14,
311,
19,
358,
272,
869,
28106,
14,
904,
360,
17,
75,
19552,
63,
83,
1132,
63,
18,
14,
311,
19,
1959,
1574,
8,
1365,
63,
493,
9,
339,
327,
6990,
3341,
14,
272,
340,
818,
1137,
283,
889,
1347,
356,
267,
1350,
63,
493,
14,
1574,
8,
1375,
63,
493,
9,
267,
340,
818,
1137,
283,
889,
5071,
3341,
356,
288,
2870,
19,
8,
495,
8,
1375,
63,
493,
4992,
2117,
8,
8358,
29,
2734,
24700,
1926,
9,
288,
3341,
275,
1211,
8,
355,
1350,
63,
8180,
29,
442,
8,
1365,
63,
493,
14,
3736,
1252,
8180,
9,
446,
334,
1165,
340,
818,
508,
283,
270,
7,
587,
378,
395,
355,
1350,
63,
890,
29,
442,
8,
1365,
63,
493,
14,
3736,
1252,
890,
9,
446,
334,
1165,
340,
818,
508,
283,
385,
7,
587,
378,
395,
355,
1347,
63,
8180,
29,
442,
8,
1375,
63,
493,
14,
3736,
1252,
8180,
9,
446,
334,
1165,
340,
818,
508,
283,
6215,
7,
587,
378,
395,
355,
1347,
63,
890,
29,
442,
8,
1375,
63,
493,
14,
3736,
1252,
890,
9,
446,
334,
1165,
340,
818,
508,
283,
1086,
7,
587,
378,
395,
288,
776,
288,
282,
521,
12,
15005,
275,
900,
14,
521,
1062,
1347,
63,
493,
14,
3736,
1252,
8180,
288,
1305,
19,
275,
2870,
19,
8,
495,
8,
1375,
63,
493,
430,
288,
1305,
19,
14,
525,
8,
5378,
8,
3257,
29,
344,
19,
63,
14163,
67,
63,
2969,
14,
10973,
63,
17705,
12,
2644,
29,
19,
12,
6339,
534,
7420,
297,
1318,
29,
1001,
14,
4180,
8,
2343,
1724,
288,
1305,
19,
14,
2117,
342,
288,
747,
14,
24043,
8,
495,
8,
1375,
63,
493,
395,
334,
27867,
12,
15005,
430,
339,
327,
3378,
14,
272,
20178,
275,
20131,
14,
51,
951,
8,
495,
8,
1365,
63,
493,
395,
1350,
63,
493,
14,
3475,
12,
1347,
63,
493,
14,
3475,
9,
339,
327,
7635,
14,
272,
702,
20178,
14,
1365,
508,
620,
8,
1365,
63,
493,
9,
272,
702,
20178,
14,
1375,
508,
620,
8,
1375,
63,
493,
9,
272,
702,
20178,
14,
10065,
63,
1287,
365,
334,
797,
340,
818,
508,
283,
384,
370,
1434,
7,
587,
715,
9,
272,
702,
4700,
8,
19351,
9,
508,
2650,
51,
951,
536,
29,
19351,
14,
311,
19,
4839,
63,
1287,
7622,
22936,
908,
8,
19351,
14,
10065,
63,
1287,
9,
272,
702,
20178,
14,
2489,
365,
756,
339,
327,
1379,
2896,
14,
272,
2870,
19,
8,
495,
8,
1365,
63,
493,
4992,
2117,
8,
8358,
29,
2734,
24700,
1926,
9,
272,
702,
20178,
14,
2489,
365,
715,
272,
20178,
14,
6635,
63,
6442,
63,
2343,
342,
272,
702,
20178,
14,
2489,
365,
756,
421,
199,
318,
511,
63,
362,
63,
834,
458,
8,
8616,
304,
272,
408,
774,
664,
63,
834,
458,
342,
805,
14,
339,
520,
635,
12885,
26,
4613,
10949,
14,
272,
408,
272,
1350,
63,
694,
275,
12885,
14,
7505,
63,
694,
360,
1365,
358,
272,
1347,
63,
694,
275,
12885,
14,
7505,
63,
694,
360,
1375,
358,
339,
327,
1379,
2701,
14,
272,
308,
12358,
12,
1686,
63,
4684,
275,
20131,
14,
362,
63,
834,
458,
8,
495,
8,
1365,
63,
694,
395,
620,
8,
1375,
63,
694,
430,
272,
702,
440,
308,
12358,
272,
702,
440,
1686,
63,
4684,
339,
327,
1379,
3686,
14,
272,
1350,
63,
694,
14,
7505,
360,
4247,
14,
2424,
358,
272,
308,
12358,
12,
1686,
63,
4684,
275,
20131,
14,
362,
63,
834,
458,
8,
495,
8,
1365,
63,
694,
395,
620,
8,
1375,
63,
694,
430,
272,
702,
440,
308,
12358,
272,
702,
440,
1686,
63,
4684,
339,
327,
2790,
6118,
19,
626,
4839,
8603,
436,
9821,
1348,
626,
3181,
1133,
14,
272,
869,
28106,
14,
904,
360,
17,
75,
19552,
63,
83,
1132,
63,
18,
14,
311,
19,
1959,
1574,
8,
1365,
63,
694,
14,
904,
360,
19351,
17,
14,
311,
19,
1333,
272,
869,
28106,
14,
904,
360,
17,
75,
19552,
63,
83,
1132,
63,
17,
14,
14163,
67,
1959,
1574,
8,
1365,
63,
694,
14,
904,
360,
19351,
18,
14,
14163,
67,
1333,
272,
869,
28106,
14,
904,
360,
17,
75,
19552,
63,
83,
1132,
63,
18,
14,
311,
19,
1959,
1574,
8,
1375,
63,
694,
14,
904,
360,
19351,
18,
14,
311,
19,
1333,
272,
2870,
19,
8,
495,
8,
1375,
63,
694,
14,
904,
360,
19351,
18,
14,
311,
19,
358,
4992,
2117,
8,
8358,
29,
2734,
24700,
1926,
9,
272,
3341,
275,
1211,
8,
267,
1350,
63,
8180,
29,
442,
8,
1365,
63,
694,
14,
904,
360,
19351,
18,
14,
14163,
67,
1959,
3736,
1252,
8180,
395,
267,
1350,
63,
890,
29,
442,
8,
1365,
63,
694,
14,
904,
360,
19351,
18,
14,
14163,
67,
1959,
3736,
1252,
890,
395,
267,
1347,
63,
8180,
29,
442,
8,
1375,
63,
694,
14,
904,
360,
19351,
18,
14,
311,
19,
1959,
3736,
1252,
8180,
395,
267,
1347,
63,
890,
29,
442,
8,
1375,
63,
694,
14,
904,
360,
19351,
18,
14,
311,
19,
1959,
3736,
1252,
890,
395,
272,
776,
272,
282,
521,
12,
15005,
275,
900,
14,
521,
1062,
1347,
63,
694,
14,
904,
360,
19351,
18,
14,
311,
19,
1959,
3736,
1252,
8180,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
veg/idepi
|
idepi/__init__.py
|
3
|
1108
|
#
# idepi :: (IDentify EPItope) python libraries containing some useful machine
# learning interfaces for regression and discrete analysis (including
# cross-validation, grid-search, and maximum-relevance/mRMR feature selection)
# and utilities to help identify neutralizing antibody epitopes via machine
# learning.
#
# Copyright (C) 2011 N Lance Hepler <nlhepler@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.
#
__version__ = '0.9.15'
|
gpl-3.0
|
[
3,
199,
3,
9979,
1038,
3800,
334,
998,
287,
3338,
662,
2252,
475,
321,
9,
2366,
8363,
3035,
2005,
2997,
6844,
199,
3,
9328,
8386,
367,
10864,
436,
24635,
11284,
334,
15768,
199,
3,
8059,
13,
6136,
12,
6068,
13,
1733,
12,
436,
5696,
13,
264,
28791,
15,
77,
11026,
50,
3878,
7267,
9,
199,
3,
436,
15841,
370,
1720,
10405,
1279,
29358,
9147,
24141,
2030,
5442,
390,
13458,
83,
4799,
6844,
199,
3,
9328,
14,
199,
3,
199,
3,
1898,
334,
35,
9,
7760,
653,
491,
554,
869,
1545,
1435,
665,
7530,
426,
80,
1435,
32,
6799,
14,
957,
30,
199,
3,
199,
3,
961,
2240,
365,
2867,
2032,
27,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
652,
1334,
314,
2895,
402,
314,
1664,
1696,
1684,
844,
465,
3267,
701,
199,
3,
314,
2868,
2290,
2752,
27,
1902,
1015,
499,
402,
314,
844,
12,
503,
199,
3,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
961,
2240,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
199,
3,
1664,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
1696,
1684,
844,
3180,
199,
3,
543,
642,
2240,
27,
340,
440,
12,
2218,
370,
314,
2868,
2290,
2752,
12,
3277,
2020,
199,
3,
8026,
11236,
14259,
12,
12066,
11844,
12,
8226,
12,
4828,
11315,
13,
10067,
8217,
14,
199,
3,
199,
199,
363,
1023,
363,
275,
283,
16,
14,
25,
14,
1046,
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,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,
9979,
1038,
3800,
334,
998,
287,
3338,
662,
2252,
475,
321,
9,
2366,
8363,
3035,
2005,
2997,
6844,
199,
3,
9328,
8386,
367,
10864,
436,
24635,
11284,
334,
15768,
199,
3,
8059,
13,
6136,
12,
6068,
13,
1733,
12,
436,
5696,
13,
264,
28791,
15,
77,
11026,
50,
3878,
7267,
9,
199,
3,
436,
15841,
370,
1720,
10405,
1279,
29358,
9147,
24141,
2030,
5442,
390,
13458,
83,
4799,
6844,
199,
3,
9328,
14,
199,
3,
199,
3,
1898,
334,
35,
9,
7760,
653,
491,
554,
869,
1545,
1435,
665,
7530,
426,
80,
1435,
32,
6799,
14,
957,
30,
199,
3,
199,
3,
961,
2240,
365,
2867,
2032,
27,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
652,
1334,
314,
2895,
402,
314,
1664,
1696,
1684,
844,
465,
3267,
701,
199,
3,
314,
2868,
2290,
2752,
27,
1902,
1015,
499,
402,
314,
844,
12,
503,
199,
3,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
961,
2240,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
199,
3,
1664,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
1696,
1684,
844,
3180,
199,
3,
543,
642,
2240,
27,
340,
440,
12,
2218,
370,
314,
2868,
2290,
2752,
12,
3277,
2020,
199,
3,
8026,
11236,
14259,
12,
12066,
11844,
12,
8226,
12,
4828,
11315,
13,
10067,
8217,
14,
199,
3,
199,
199,
363,
1023,
363,
275,
283,
16,
14,
25,
14,
1046,
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,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,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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
] |
mims2707/bite-project
|
deps/gdata-python-client/samples/apps/marketplace_sample/gdata/gauth.py
|
22
|
58099
|
#!/usr/bin/env python
#
# Copyright (C) 2009 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.
# This module is used for version 2 of the Google Data APIs.
"""Provides auth related token classes and functions for Google Data APIs.
Token classes represent a user's authorization of this app to access their
data. Usually these are not created directly but by a GDClient object.
ClientLoginToken
AuthSubToken
SecureAuthSubToken
OAuthHmacToken
OAuthRsaToken
TwoLeggedOAuthHmacToken
TwoLeggedOAuthRsaToken
Functions which are often used in application code (as opposed to just within
the gdata-python-client library) are the following:
generate_auth_sub_url
authorize_request_token
The following are helper functions which are used to save and load auth token
objects in the App Engine datastore. These should only be used if you are using
this library within App Engine:
ae_load
ae_save
"""
import datetime
import time
import random
import urllib
import urlparse
import atom.http_core
try:
import simplejson
except ImportError:
try:
# Try to import from django, should work on App Engine
from django.utils import simplejson
except ImportError:
# Should work for Python2.6 and higher.
import json as simplejson
try:
from urlparse import parse_qsl
except ImportError:
from cgi import parse_qsl
__author__ = 'j.s@google.com (Jeff Scudder)'
PROGRAMMATIC_AUTH_LABEL = 'GoogleLogin auth='
AUTHSUB_AUTH_LABEL = 'AuthSub token='
OAUTH2_AUTH_LABEL = 'OAuth '
# This dict provides the AuthSub and OAuth scopes for all services by service
# name. The service name (key) is used in ClientLogin requests.
AUTH_SCOPES = {
'cl': ( # Google Calendar API
'https://www.google.com/calendar/feeds/',
'http://www.google.com/calendar/feeds/'),
'gbase': ( # Google Base API
'http://base.google.com/base/feeds/',
'http://www.google.com/base/feeds/'),
'blogger': ( # Blogger API
'http://www.blogger.com/feeds/',),
'codesearch': ( # Google Code Search API
'http://www.google.com/codesearch/feeds/',),
'cp': ( # Contacts API
'https://www.google.com/m8/feeds/',
'http://www.google.com/m8/feeds/'),
'finance': ( # Google Finance API
'http://finance.google.com/finance/feeds/',),
'health': ( # Google Health API
'https://www.google.com/health/feeds/',),
'writely': ( # Documents List API
'https://docs.google.com/feeds/',
'https://spreadsheets.google.com/feeds/',
'https://docs.googleusercontent.com/'),
'lh2': ( # Picasa Web Albums API
'http://picasaweb.google.com/data/',),
'apps': ( # Google Apps Provisioning API
'https://apps-apis.google.com/a/feeds/user/',
'https://apps-apis.google.com/a/feeds/policies/',
'https://apps-apis.google.com/a/feeds/alias/',
'https://apps-apis.google.com/a/feeds/groups/'),
'weaver': ( # Health H9 Sandbox
'https://www.google.com/h9/feeds/',),
'wise': ( # Spreadsheets Data API
'https://spreadsheets.google.com/feeds/',),
'sitemaps': ( # Google Webmaster Tools API
'https://www.google.com/webmasters/tools/feeds/',),
'youtube': ( # YouTube API
'http://gdata.youtube.com/feeds/api/',
'http://uploads.gdata.youtube.com/feeds/api',
'http://gdata.youtube.com/action/GetUploadToken'),
'books': ( # Google Books API
'http://www.google.com/books/feeds/',),
'analytics': ( # Google Analytics API
'https://www.google.com/analytics/feeds/',),
'jotspot': ( # Google Sites API
'http://sites.google.com/feeds/',
'https://sites.google.com/feeds/'),
'local': ( # Google Maps Data API
'http://maps.google.com/maps/feeds/',),
'code': ( # Project Hosting Data API
'http://code.google.com/feeds/issues',)}
class Error(Exception):
pass
class UnsupportedTokenType(Error):
"""Raised when token to or from blob is unable to convert the token."""
pass
class OAuth2AccessTokenError(Error):
"""Raised when an OAuth2 error occurs."""
def __init__(self, error_message):
self.error_message = error_message
# ClientLogin functions and classes.
def generate_client_login_request_body(email, password, service, source,
account_type='HOSTED_OR_GOOGLE', captcha_token=None,
captcha_response=None):
"""Creates the body of the autentication request
See http://code.google.com/apis/accounts/AuthForInstalledApps.html#Request
for more details.
Args:
email: str
password: str
service: str
source: str
account_type: str (optional) Defaul is 'HOSTED_OR_GOOGLE', other valid
values are 'GOOGLE' and 'HOSTED'
captcha_token: str (optional)
captcha_response: str (optional)
Returns:
The HTTP body to send in a request for a client login token.
"""
# Create a POST body containing the user's credentials.
request_fields = {'Email': email,
'Passwd': password,
'accountType': account_type,
'service': service,
'source': source}
if captcha_token and captcha_response:
# Send the captcha token and response as part of the POST body if the
# user is responding to a captch challenge.
request_fields['logintoken'] = captcha_token
request_fields['logincaptcha'] = captcha_response
return urllib.urlencode(request_fields)
GenerateClientLoginRequestBody = generate_client_login_request_body
def get_client_login_token_string(http_body):
"""Returns the token value for a ClientLoginToken.
Reads the token from the server's response to a Client Login request and
creates the token value string to use in requests.
Args:
http_body: str The body of the server's HTTP response to a Client Login
request
Returns:
The token value string for a ClientLoginToken.
"""
for response_line in http_body.splitlines():
if response_line.startswith('Auth='):
# Strip off the leading Auth= and return the Authorization value.
return response_line[5:]
return None
GetClientLoginTokenString = get_client_login_token_string
def get_captcha_challenge(http_body,
captcha_base_url='http://www.google.com/accounts/'):
"""Returns the URL and token for a CAPTCHA challenge issued by the server.
Args:
http_body: str The body of the HTTP response from the server which
contains the CAPTCHA challenge.
captcha_base_url: str This function returns a full URL for viewing the
challenge image which is built from the server's response. This
base_url is used as the beginning of the URL because the server
only provides the end of the URL. For example the server provides
'Captcha?ctoken=Hi...N' and the URL for the image is
'http://www.google.com/accounts/Captcha?ctoken=Hi...N'
Returns:
A dictionary containing the information needed to repond to the CAPTCHA
challenge, the image URL and the ID token of the challenge. The
dictionary is in the form:
{'token': string identifying the CAPTCHA image,
'url': string containing the URL of the image}
Returns None if there was no CAPTCHA challenge in the response.
"""
contains_captcha_challenge = False
captcha_parameters = {}
for response_line in http_body.splitlines():
if response_line.startswith('Error=CaptchaRequired'):
contains_captcha_challenge = True
elif response_line.startswith('CaptchaToken='):
# Strip off the leading CaptchaToken=
captcha_parameters['token'] = response_line[13:]
elif response_line.startswith('CaptchaUrl='):
captcha_parameters['url'] = '%s%s' % (captcha_base_url,
response_line[11:])
if contains_captcha_challenge:
return captcha_parameters
else:
return None
GetCaptchaChallenge = get_captcha_challenge
class ClientLoginToken(object):
def __init__(self, token_string):
self.token_string = token_string
def modify_request(self, http_request):
http_request.headers['Authorization'] = '%s%s' % (PROGRAMMATIC_AUTH_LABEL,
self.token_string)
ModifyRequest = modify_request
# AuthSub functions and classes.
def _to_uri(str_or_uri):
if isinstance(str_or_uri, (str, unicode)):
return atom.http_core.Uri.parse_uri(str_or_uri)
return str_or_uri
def generate_auth_sub_url(next, scopes, secure=False, session=True,
request_url=atom.http_core.parse_uri(
'https://www.google.com/accounts/AuthSubRequest'),
domain='default', scopes_param_prefix='auth_sub_scopes'):
"""Constructs a URI for requesting a multiscope AuthSub token.
The generated token will contain a URL parameter to pass along the
requested scopes to the next URL. When the Google Accounts page
redirects the broswser to the 'next' URL, it appends the single use
AuthSub token value to the URL as a URL parameter with the key 'token'.
However, the information about which scopes were requested is not
included by Google Accounts. This method adds the scopes to the next
URL before making the request so that the redirect will be sent to
a page, and both the token value and the list of scopes for which the token
was requested.
Args:
next: atom.http_core.Uri or string The URL user will be sent to after
authorizing this web application to access their data.
scopes: list containint strings or atom.http_core.Uri objects. The URLs
of the services to be accessed. Could also be a single string
or single atom.http_core.Uri for requesting just one scope.
secure: boolean (optional) Determines whether or not the issued token
is a secure token.
session: boolean (optional) Determines whether or not the issued token
can be upgraded to a session token.
request_url: atom.http_core.Uri or str The beginning of the request URL.
This is normally
'http://www.google.com/accounts/AuthSubRequest' or
'/accounts/AuthSubRequest'
domain: The domain which the account is part of. This is used for Google
Apps accounts, the default value is 'default' which means that
the requested account is a Google Account (@gmail.com for
example)
scopes_param_prefix: str (optional) The requested scopes are added as a
URL parameter to the next URL so that the page at
the 'next' URL can extract the token value and the
valid scopes from the URL. The key for the URL
parameter defaults to 'auth_sub_scopes'
Returns:
An atom.http_core.Uri which the user's browser should be directed to in
order to authorize this application to access their information.
"""
if isinstance(next, (str, unicode)):
next = atom.http_core.Uri.parse_uri(next)
# If the user passed in a string instead of a list for scopes, convert to
# a single item tuple.
if isinstance(scopes, (str, unicode, atom.http_core.Uri)):
scopes = (scopes,)
scopes_string = ' '.join([str(scope) for scope in scopes])
next.query[scopes_param_prefix] = scopes_string
if isinstance(request_url, (str, unicode)):
request_url = atom.http_core.Uri.parse_uri(request_url)
request_url.query['next'] = str(next)
request_url.query['scope'] = scopes_string
if session:
request_url.query['session'] = '1'
else:
request_url.query['session'] = '0'
if secure:
request_url.query['secure'] = '1'
else:
request_url.query['secure'] = '0'
request_url.query['hd'] = domain
return request_url
def auth_sub_string_from_url(url, scopes_param_prefix='auth_sub_scopes'):
"""Finds the token string (and scopes) after the browser is redirected.
After the Google Accounts AuthSub pages redirect the user's broswer back to
the web application (using the 'next' URL from the request) the web app must
extract the token from the current page's URL. The token is provided as a
URL parameter named 'token' and if generate_auth_sub_url was used to create
the request, the token's valid scopes are included in a URL parameter whose
name is specified in scopes_param_prefix.
Args:
url: atom.url.Url or str representing the current URL. The token value
and valid scopes should be included as URL parameters.
scopes_param_prefix: str (optional) The URL parameter key which maps to
the list of valid scopes for the token.
Returns:
A tuple containing the token value as a string, and a tuple of scopes
(as atom.http_core.Uri objects) which are URL prefixes under which this
token grants permission to read and write user data.
(token_string, (scope_uri, scope_uri, scope_uri, ...))
If no scopes were included in the URL, the second value in the tuple is
None. If there was no token param in the url, the tuple returned is
(None, None)
"""
if isinstance(url, (str, unicode)):
url = atom.http_core.Uri.parse_uri(url)
if 'token' not in url.query:
return (None, None)
token = url.query['token']
# TODO: decide whether no scopes should be None or ().
scopes = None # Default to None for no scopes.
if scopes_param_prefix in url.query:
scopes = tuple(url.query[scopes_param_prefix].split(' '))
return (token, scopes)
AuthSubStringFromUrl = auth_sub_string_from_url
def auth_sub_string_from_body(http_body):
"""Extracts the AuthSub token from an HTTP body string.
Used to find the new session token after making a request to upgrade a
single use AuthSub token.
Args:
http_body: str The repsonse from the server which contains the AuthSub
key. For example, this function would find the new session token
from the server's response to an upgrade token request.
Returns:
The raw token value string to use in an AuthSubToken object.
"""
for response_line in http_body.splitlines():
if response_line.startswith('Token='):
# Strip off Token= and return the token value string.
return response_line[6:]
return None
class AuthSubToken(object):
def __init__(self, token_string, scopes=None):
self.token_string = token_string
self.scopes = scopes or []
def modify_request(self, http_request):
"""Sets Authorization header, allows app to act on the user's behalf."""
http_request.headers['Authorization'] = '%s%s' % (AUTHSUB_AUTH_LABEL,
self.token_string)
ModifyRequest = modify_request
def from_url(str_or_uri):
"""Creates a new AuthSubToken using information in the URL.
Uses auth_sub_string_from_url.
Args:
str_or_uri: The current page's URL (as a str or atom.http_core.Uri)
which should contain a token query parameter since the
Google auth server redirected the user's browser to this
URL.
"""
token_and_scopes = auth_sub_string_from_url(str_or_uri)
return AuthSubToken(token_and_scopes[0], token_and_scopes[1])
from_url = staticmethod(from_url)
FromUrl = from_url
def _upgrade_token(self, http_body):
"""Replaces the token value with a session token from the auth server.
Uses the response of a token upgrade request to modify this token. Uses
auth_sub_string_from_body.
"""
self.token_string = auth_sub_string_from_body(http_body)
# Functions and classes for Secure-mode AuthSub
def build_auth_sub_data(http_request, timestamp, nonce):
"""Creates the data string which must be RSA-signed in secure requests.
For more details see the documenation on secure AuthSub requests:
http://code.google.com/apis/accounts/docs/AuthSub.html#signingrequests
Args:
http_request: The request being made to the server. The Request's URL
must be complete before this signature is calculated as any changes
to the URL will invalidate the signature.
nonce: str Random 64-bit, unsigned number encoded as an ASCII string in
decimal format. The nonce/timestamp pair should always be unique to
prevent replay attacks.
timestamp: Integer representing the time the request is sent. The
timestamp should be expressed in number of seconds after January 1,
1970 00:00:00 GMT.
"""
return '%s %s %s %s' % (http_request.method, str(http_request.uri),
str(timestamp), nonce)
def generate_signature(data, rsa_key):
"""Signs the data string for a secure AuthSub request."""
import base64
try:
from tlslite.utils import keyfactory
except ImportError:
try:
from gdata.tlslite.utils import keyfactory
except ImportError:
from tlslite.tlslite.utils import keyfactory
private_key = keyfactory.parsePrivateKey(rsa_key)
signed = private_key.hashAndSign(data)
# Python2.3 and lower does not have the base64.b64encode function.
if hasattr(base64, 'b64encode'):
return base64.b64encode(signed)
else:
return base64.encodestring(signed).replace('\n', '')
class SecureAuthSubToken(AuthSubToken):
def __init__(self, token_string, rsa_private_key, scopes=None):
self.token_string = token_string
self.scopes = scopes or []
self.rsa_private_key = rsa_private_key
def from_url(str_or_uri, rsa_private_key):
"""Creates a new SecureAuthSubToken using information in the URL.
Uses auth_sub_string_from_url.
Args:
str_or_uri: The current page's URL (as a str or atom.http_core.Uri)
which should contain a token query parameter since the Google auth
server redirected the user's browser to this URL.
rsa_private_key: str the private RSA key cert used to sign all requests
made with this token.
"""
token_and_scopes = auth_sub_string_from_url(str_or_uri)
return SecureAuthSubToken(token_and_scopes[0], rsa_private_key,
token_and_scopes[1])
from_url = staticmethod(from_url)
FromUrl = from_url
def modify_request(self, http_request):
"""Sets the Authorization header and includes a digital signature.
Calculates a digital signature using the private RSA key, a timestamp
(uses now at the time this method is called) and a random nonce.
Args:
http_request: The atom.http_core.HttpRequest which contains all of the
information needed to send a request to the remote server. The
URL and the method of the request must be already set and cannot be
changed after this token signs the request, or the signature will
not be valid.
"""
timestamp = str(int(time.time()))
nonce = ''.join([str(random.randint(0, 9)) for i in xrange(15)])
data = build_auth_sub_data(http_request, timestamp, nonce)
signature = generate_signature(data, self.rsa_private_key)
http_request.headers['Authorization'] = (
'%s%s sigalg="rsa-sha1" data="%s" sig="%s"' % (AUTHSUB_AUTH_LABEL,
self.token_string, data, signature))
ModifyRequest = modify_request
# OAuth functions and classes.
RSA_SHA1 = 'RSA-SHA1'
HMAC_SHA1 = 'HMAC-SHA1'
def build_oauth_base_string(http_request, consumer_key, nonce, signaure_type,
timestamp, version, next='oob', token=None,
verifier=None):
"""Generates the base string to be signed in the OAuth request.
Args:
http_request: The request being made to the server. The Request's URL
must be complete before this signature is calculated as any changes
to the URL will invalidate the signature.
consumer_key: Domain identifying the third-party web application. This is
the domain used when registering the application with Google. It
identifies who is making the request on behalf of the user.
nonce: Random 64-bit, unsigned number encoded as an ASCII string in decimal
format. The nonce/timestamp pair should always be unique to prevent
replay attacks.
signaure_type: either RSA_SHA1 or HMAC_SHA1
timestamp: Integer representing the time the request is sent. The
timestamp should be expressed in number of seconds after January 1,
1970 00:00:00 GMT.
version: The OAuth version used by the requesting web application. This
value must be '1.0' or '1.0a'. If not provided, Google assumes version
1.0 is in use.
next: The URL the user should be redirected to after granting access
to a Google service(s). It can include url-encoded query parameters.
The default value is 'oob'. (This is the oauth_callback.)
token: The string for the OAuth request token or OAuth access token.
verifier: str Sent as the oauth_verifier and required when upgrading a
request token to an access token.
"""
# First we must build the canonical base string for the request.
params = http_request.uri.query.copy()
params['oauth_consumer_key'] = consumer_key
params['oauth_nonce'] = nonce
params['oauth_signature_method'] = signaure_type
params['oauth_timestamp'] = str(timestamp)
if next is not None:
params['oauth_callback'] = str(next)
if token is not None:
params['oauth_token'] = token
if version is not None:
params['oauth_version'] = version
if verifier is not None:
params['oauth_verifier'] = verifier
# We need to get the key value pairs in lexigraphically sorted order.
sorted_keys = None
try:
sorted_keys = sorted(params.keys())
# The sorted function is not available in Python2.3 and lower
except NameError:
sorted_keys = params.keys()
sorted_keys.sort()
pairs = []
for key in sorted_keys:
pairs.append('%s=%s' % (urllib.quote(key, safe='~'),
urllib.quote(params[key], safe='~')))
# We want to escape /'s too, so use safe='~'
all_parameters = urllib.quote('&'.join(pairs), safe='~')
normailzed_host = http_request.uri.host.lower()
normalized_scheme = (http_request.uri.scheme or 'http').lower()
non_default_port = None
if (http_request.uri.port is not None
and ((normalized_scheme == 'https' and http_request.uri.port != 443)
or (normalized_scheme == 'http' and http_request.uri.port != 80))):
non_default_port = http_request.uri.port
path = http_request.uri.path or '/'
request_path = None
if not path.startswith('/'):
path = '/%s' % path
if non_default_port is not None:
# Set the only safe char in url encoding to ~ since we want to escape /
# as well.
request_path = urllib.quote('%s://%s:%s%s' % (
normalized_scheme, normailzed_host, non_default_port, path), safe='~')
else:
# Set the only safe char in url encoding to ~ since we want to escape /
# as well.
request_path = urllib.quote('%s://%s%s' % (
normalized_scheme, normailzed_host, path), safe='~')
# TODO: ensure that token escaping logic is correct, not sure if the token
# value should be double escaped instead of single.
base_string = '&'.join((http_request.method.upper(), request_path,
all_parameters))
# Now we have the base string, we can calculate the oauth_signature.
return base_string
def generate_hmac_signature(http_request, consumer_key, consumer_secret,
timestamp, nonce, version, next='oob',
token=None, token_secret=None, verifier=None):
import hmac
import base64
base_string = build_oauth_base_string(
http_request, consumer_key, nonce, HMAC_SHA1, timestamp, version,
next, token, verifier=verifier)
hash_key = None
hashed = None
if token_secret is not None:
hash_key = '%s&%s' % (urllib.quote(consumer_secret, safe='~'),
urllib.quote(token_secret, safe='~'))
else:
hash_key = '%s&' % urllib.quote(consumer_secret, safe='~')
try:
import hashlib
hashed = hmac.new(hash_key, base_string, hashlib.sha1)
except ImportError:
import sha
hashed = hmac.new(hash_key, base_string, sha)
# Python2.3 does not have base64.b64encode.
if hasattr(base64, 'b64encode'):
return base64.b64encode(hashed.digest())
else:
return base64.encodestring(hashed.digest()).replace('\n', '')
def generate_rsa_signature(http_request, consumer_key, rsa_key,
timestamp, nonce, version, next='oob',
token=None, token_secret=None, verifier=None):
import base64
try:
from tlslite.utils import keyfactory
except ImportError:
try:
from gdata.tlslite.utils import keyfactory
except ImportError:
from tlslite.tlslite.utils import keyfactory
base_string = build_oauth_base_string(
http_request, consumer_key, nonce, RSA_SHA1, timestamp, version,
next, token, verifier=verifier)
private_key = keyfactory.parsePrivateKey(rsa_key)
# Sign using the key
signed = private_key.hashAndSign(base_string)
# Python2.3 does not have base64.b64encode.
if hasattr(base64, 'b64encode'):
return base64.b64encode(signed)
else:
return base64.encodestring(signed).replace('\n', '')
def generate_auth_header(consumer_key, timestamp, nonce, signature_type,
signature, version='1.0', next=None, token=None,
verifier=None):
"""Builds the Authorization header to be sent in the request.
Args:
consumer_key: Identifies the application making the request (str).
timestamp:
nonce:
signature_type: One of either HMAC_SHA1 or RSA_SHA1
signature: The HMAC or RSA signature for the request as a base64
encoded string.
version: The version of the OAuth protocol that this request is using.
Default is '1.0'
next: The URL of the page that the user's browser should be sent to
after they authorize the token. (Optional)
token: str The OAuth token value to be used in the oauth_token parameter
of the header.
verifier: str The OAuth verifier which must be included when you are
upgrading a request token to an access token.
"""
params = {
'oauth_consumer_key': consumer_key,
'oauth_version': version,
'oauth_nonce': nonce,
'oauth_timestamp': str(timestamp),
'oauth_signature_method': signature_type,
'oauth_signature': signature}
if next is not None:
params['oauth_callback'] = str(next)
if token is not None:
params['oauth_token'] = token
if verifier is not None:
params['oauth_verifier'] = verifier
pairs = [
'%s="%s"' % (
k, urllib.quote(v, safe='~')) for k, v in params.iteritems()]
return 'OAuth %s' % (', '.join(pairs))
REQUEST_TOKEN_URL = 'https://www.google.com/accounts/OAuthGetRequestToken'
ACCESS_TOKEN_URL = 'https://www.google.com/accounts/OAuthGetAccessToken'
def generate_request_for_request_token(
consumer_key, signature_type, scopes, rsa_key=None, consumer_secret=None,
auth_server_url=REQUEST_TOKEN_URL, next='oob', version='1.0'):
"""Creates request to be sent to auth server to get an OAuth request token.
Args:
consumer_key:
signature_type: either RSA_SHA1 or HMAC_SHA1. The rsa_key must be
provided if the signature type is RSA but if the signature method
is HMAC, the consumer_secret must be used.
scopes: List of URL prefixes for the data which we want to access. For
example, to request access to the user's Blogger and Google Calendar
data, we would request
['http://www.blogger.com/feeds/',
'https://www.google.com/calendar/feeds/',
'http://www.google.com/calendar/feeds/']
rsa_key: Only used if the signature method is RSA_SHA1.
consumer_secret: Only used if the signature method is HMAC_SHA1.
auth_server_url: The URL to which the token request should be directed.
Defaults to 'https://www.google.com/accounts/OAuthGetRequestToken'.
next: The URL of the page that the user's browser should be sent to
after they authorize the token. (Optional)
version: The OAuth version used by the requesting web application.
Defaults to '1.0a'
Returns:
An atom.http_core.HttpRequest object with the URL, Authorization header
and body filled in.
"""
request = atom.http_core.HttpRequest(auth_server_url, 'POST')
# Add the requested auth scopes to the Auth request URL.
if scopes:
request.uri.query['scope'] = ' '.join(scopes)
timestamp = str(int(time.time()))
nonce = ''.join([str(random.randint(0, 9)) for i in xrange(15)])
signature = None
if signature_type == HMAC_SHA1:
signature = generate_hmac_signature(
request, consumer_key, consumer_secret, timestamp, nonce, version,
next=next)
elif signature_type == RSA_SHA1:
signature = generate_rsa_signature(
request, consumer_key, rsa_key, timestamp, nonce, version, next=next)
else:
return None
request.headers['Authorization'] = generate_auth_header(
consumer_key, timestamp, nonce, signature_type, signature, version,
next)
request.headers['Content-Length'] = '0'
return request
def generate_request_for_access_token(
request_token, auth_server_url=ACCESS_TOKEN_URL):
"""Creates a request to ask the OAuth server for an access token.
Requires a request token which the user has authorized. See the
documentation on OAuth with Google Data for more details:
http://code.google.com/apis/accounts/docs/OAuth.html#AccessToken
Args:
request_token: An OAuthHmacToken or OAuthRsaToken which the user has
approved using their browser.
auth_server_url: (optional) The URL at which the OAuth access token is
requested. Defaults to
https://www.google.com/accounts/OAuthGetAccessToken
Returns:
A new HttpRequest object which can be sent to the OAuth server to
request an OAuth Access Token.
"""
http_request = atom.http_core.HttpRequest(auth_server_url, 'POST')
http_request.headers['Content-Length'] = '0'
return request_token.modify_request(http_request)
def oauth_token_info_from_body(http_body):
"""Exracts an OAuth request token from the server's response.
Returns:
A tuple of strings containing the OAuth token and token secret. If
neither of these are present in the body, returns (None, None)
"""
token = None
token_secret = None
for pair in http_body.split('&'):
if pair.startswith('oauth_token='):
token = urllib.unquote(pair[len('oauth_token='):])
if pair.startswith('oauth_token_secret='):
token_secret = urllib.unquote(pair[len('oauth_token_secret='):])
return (token, token_secret)
def hmac_token_from_body(http_body, consumer_key, consumer_secret,
auth_state):
token_value, token_secret = oauth_token_info_from_body(http_body)
token = OAuthHmacToken(consumer_key, consumer_secret, token_value,
token_secret, auth_state)
return token
def rsa_token_from_body(http_body, consumer_key, rsa_private_key,
auth_state):
token_value, token_secret = oauth_token_info_from_body(http_body)
token = OAuthRsaToken(consumer_key, rsa_private_key, token_value,
token_secret, auth_state)
return token
DEFAULT_DOMAIN = 'default'
OAUTH_AUTHORIZE_URL = 'https://www.google.com/accounts/OAuthAuthorizeToken'
def generate_oauth_authorization_url(
token, next=None, hd=DEFAULT_DOMAIN, hl=None, btmpl=None,
auth_server=OAUTH_AUTHORIZE_URL):
"""Creates a URL for the page where the request token can be authorized.
Args:
token: str The request token from the OAuth server.
next: str (optional) URL the user should be redirected to after granting
access to a Google service(s). It can include url-encoded query
parameters.
hd: str (optional) Identifies a particular hosted domain account to be
accessed (for example, 'mycollege.edu'). Uses 'default' to specify a
regular Google account ('username@gmail.com').
hl: str (optional) An ISO 639 country code identifying what language the
approval page should be translated in (for example, 'hl=en' for
English). The default is the user's selected language.
btmpl: str (optional) Forces a mobile version of the approval page. The
only accepted value is 'mobile'.
auth_server: str (optional) The start of the token authorization web
page. Defaults to
'https://www.google.com/accounts/OAuthAuthorizeToken'
Returns:
An atom.http_core.Uri pointing to the token authorization page where the
user may allow or deny this app to access their Google data.
"""
uri = atom.http_core.Uri.parse_uri(auth_server)
uri.query['oauth_token'] = token
uri.query['hd'] = hd
if next is not None:
uri.query['oauth_callback'] = str(next)
if hl is not None:
uri.query['hl'] = hl
if btmpl is not None:
uri.query['btmpl'] = btmpl
return uri
def oauth_token_info_from_url(url):
"""Exracts an OAuth access token from the redirected page's URL.
Returns:
A tuple of strings containing the OAuth token and the OAuth verifier which
need to sent when upgrading a request token to an access token.
"""
if isinstance(url, (str, unicode)):
url = atom.http_core.Uri.parse_uri(url)
token = None
verifier = None
if 'oauth_token' in url.query:
token = urllib.unquote(url.query['oauth_token'])
if 'oauth_verifier' in url.query:
verifier = urllib.unquote(url.query['oauth_verifier'])
return (token, verifier)
def authorize_request_token(request_token, url):
"""Adds information to request token to allow it to become an access token.
Modifies the request_token object passed in by setting and unsetting the
necessary fields to allow this token to form a valid upgrade request.
Args:
request_token: The OAuth request token which has been authorized by the
user. In order for this token to be upgraded to an access token,
certain fields must be extracted from the URL and added to the token
so that they can be passed in an upgrade-token request.
url: The URL of the current page which the user's browser was redirected
to after they authorized access for the app. This function extracts
information from the URL which is needed to upgraded the token from
a request token to an access token.
Returns:
The same token object which was passed in.
"""
token, verifier = oauth_token_info_from_url(url)
request_token.token = token
request_token.verifier = verifier
request_token.auth_state = AUTHORIZED_REQUEST_TOKEN
return request_token
AuthorizeRequestToken = authorize_request_token
def upgrade_to_access_token(request_token, server_response_body):
"""Extracts access token information from response to an upgrade request.
Once the server has responded with the new token info for the OAuth
access token, this method modifies the request_token to set and unset
necessary fields to create valid OAuth authorization headers for requests.
Args:
request_token: An OAuth token which this function modifies to allow it
to be used as an access token.
server_response_body: str The server's response to an OAuthAuthorizeToken
request. This should contain the new token and token_secret which
are used to generate the signature and parameters of the Authorization
header in subsequent requests to Google Data APIs.
Returns:
The same token object which was passed in.
"""
token, token_secret = oauth_token_info_from_body(server_response_body)
request_token.token = token
request_token.token_secret = token_secret
request_token.auth_state = ACCESS_TOKEN
request_token.next = None
request_token.verifier = None
return request_token
UpgradeToAccessToken = upgrade_to_access_token
REQUEST_TOKEN = 1
AUTHORIZED_REQUEST_TOKEN = 2
ACCESS_TOKEN = 3
class OAuthHmacToken(object):
SIGNATURE_METHOD = HMAC_SHA1
def __init__(self, consumer_key, consumer_secret, token, token_secret,
auth_state, next=None, verifier=None):
self.consumer_key = consumer_key
self.consumer_secret = consumer_secret
self.token = token
self.token_secret = token_secret
self.auth_state = auth_state
self.next = next
self.verifier = verifier # Used to convert request token to access token.
def generate_authorization_url(
self, google_apps_domain=DEFAULT_DOMAIN, language=None, btmpl=None,
auth_server=OAUTH_AUTHORIZE_URL):
"""Creates the URL at which the user can authorize this app to access.
Args:
google_apps_domain: str (optional) If the user should be signing in
using an account under a known Google Apps domain, provide the
domain name ('example.com') here. If not provided, 'default'
will be used, and the user will be prompted to select an account
if they are signed in with a Google Account and Google Apps
accounts.
language: str (optional) An ISO 639 country code identifying what
language the approval page should be translated in (for example,
'en' for English). The default is the user's selected language.
btmpl: str (optional) Forces a mobile version of the approval page. The
only accepted value is 'mobile'.
auth_server: str (optional) The start of the token authorization web
page. Defaults to
'https://www.google.com/accounts/OAuthAuthorizeToken'
"""
return generate_oauth_authorization_url(
self.token, hd=google_apps_domain, hl=language, btmpl=btmpl,
auth_server=auth_server)
GenerateAuthorizationUrl = generate_authorization_url
def modify_request(self, http_request):
"""Sets the Authorization header in the HTTP request using the token.
Calculates an HMAC signature using the information in the token to
indicate that the request came from this application and that this
application has permission to access a particular user's data.
Returns:
The same HTTP request object which was passed in.
"""
timestamp = str(int(time.time()))
nonce = ''.join([str(random.randint(0, 9)) for i in xrange(15)])
signature = generate_hmac_signature(
http_request, self.consumer_key, self.consumer_secret, timestamp,
nonce, version='1.0', next=self.next, token=self.token,
token_secret=self.token_secret, verifier=self.verifier)
http_request.headers['Authorization'] = generate_auth_header(
self.consumer_key, timestamp, nonce, HMAC_SHA1, signature,
version='1.0', next=self.next, token=self.token,
verifier=self.verifier)
return http_request
ModifyRequest = modify_request
class OAuthRsaToken(OAuthHmacToken):
SIGNATURE_METHOD = RSA_SHA1
def __init__(self, consumer_key, rsa_private_key, token, token_secret,
auth_state, next=None, verifier=None):
self.consumer_key = consumer_key
self.rsa_private_key = rsa_private_key
self.token = token
self.token_secret = token_secret
self.auth_state = auth_state
self.next = next
self.verifier = verifier # Used to convert request token to access token.
def modify_request(self, http_request):
"""Sets the Authorization header in the HTTP request using the token.
Calculates an RSA signature using the information in the token to
indicate that the request came from this application and that this
application has permission to access a particular user's data.
Returns:
The same HTTP request object which was passed in.
"""
timestamp = str(int(time.time()))
nonce = ''.join([str(random.randint(0, 9)) for i in xrange(15)])
signature = generate_rsa_signature(
http_request, self.consumer_key, self.rsa_private_key, timestamp,
nonce, version='1.0', next=self.next, token=self.token,
token_secret=self.token_secret, verifier=self.verifier)
http_request.headers['Authorization'] = generate_auth_header(
self.consumer_key, timestamp, nonce, RSA_SHA1, signature,
version='1.0', next=self.next, token=self.token,
verifier=self.verifier)
return http_request
ModifyRequest = modify_request
class TwoLeggedOAuthHmacToken(OAuthHmacToken):
def __init__(self, consumer_key, consumer_secret, requestor_id):
self.requestor_id = requestor_id
OAuthHmacToken.__init__(
self, consumer_key, consumer_secret, None, None, ACCESS_TOKEN,
next=None, verifier=None)
def modify_request(self, http_request):
"""Sets the Authorization header in the HTTP request using the token.
Calculates an HMAC signature using the information in the token to
indicate that the request came from this application and that this
application has permission to access a particular user's data using 2LO.
Returns:
The same HTTP request object which was passed in.
"""
http_request.uri.query['xoauth_requestor_id'] = self.requestor_id
return OAuthHmacToken.modify_request(self, http_request)
ModifyRequest = modify_request
class TwoLeggedOAuthRsaToken(OAuthRsaToken):
def __init__(self, consumer_key, rsa_private_key, requestor_id):
self.requestor_id = requestor_id
OAuthRsaToken.__init__(
self, consumer_key, rsa_private_key, None, None, ACCESS_TOKEN,
next=None, verifier=None)
def modify_request(self, http_request):
"""Sets the Authorization header in the HTTP request using the token.
Calculates an RSA signature using the information in the token to
indicate that the request came from this application and that this
application has permission to access a particular user's data using 2LO.
Returns:
The same HTTP request object which was passed in.
"""
http_request.uri.query['xoauth_requestor_id'] = self.requestor_id
return OAuthRsaToken.modify_request(self, http_request)
ModifyRequest = modify_request
class OAuth2Token(object):
"""Token object for OAuth 2.0 as described on
<http://code.google.com/apis/accounts/docs/OAuth2.html>.
Token can be applied to a gdata.client.GDClient object using the authorize()
method, which then signs each request from that object with the OAuth 2.0
access token.
This class supports 3 flows of OAuth 2.0:
Client-side web flow: call generate_authorize_url with `response_type='token''
and the registered `redirect_uri'.
Server-side web flow: call generate_authorize_url with the registered
`redirect_url'.
Native applications flow: call generate_authorize_url as it is. You will have
to ask the user to go to the generated url and pass in the authorization
code to your application.
"""
def __init__(self, client_id, client_secret, scope, user_agent,
auth_uri='https://accounts.google.com/o/oauth2/auth',
token_uri='https://accounts.google.com/o/oauth2/token',
access_token=None, refresh_token=None):
"""Create an instance of OAuth2Token
This constructor is not usually called by the user, instead
OAuth2Credentials objects are instantiated by the OAuth2WebServerFlow.
Args:
client_id: string, client identifier.
client_secret: string client secret.
scope: string, scope of the credentials being requested.
user_agent: string, HTTP User-Agent to provide for this application.
auth_uri: string, URI for authorization endpoint. For convenience
defaults to Google's endpoints but any OAuth 2.0 provider can be used.
token_uri: string, URI for token endpoint. For convenience
defaults to Google's endpoints but any OAuth 2.0 provider can be used.
access_token: string, access token.
refresh_token: string, refresh token.
"""
self.client_id = client_id
self.client_secret = client_secret
self.scope = scope
self.user_agent = user_agent
self.auth_uri = auth_uri
self.token_uri = token_uri
self.access_token = access_token
self.refresh_token = refresh_token
# True if the credentials have been revoked or expired and can't be
# refreshed.
self._invalid = False
@property
def invalid(self):
"""True if the credentials are invalid, such as being revoked."""
return getattr(self, '_invalid', False)
def _refresh(self, request):
"""Refresh the access_token using the refresh_token.
Args:
http: An instance of httplib2.Http.request
or something that acts like it.
"""
body = urllib.urlencode({
'grant_type': 'refresh_token',
'client_id': self.client_id,
'client_secret': self.client_secret,
'refresh_token' : self.refresh_token
})
headers = {
'user-agent': self.user_agent,
}
http_request = atom.http_core.HttpRequest(uri=self.token_uri, method='POST', headers=headers)
http_request.add_body_part(body, mime_type='application/x-www-form-urlencoded')
response = request(http_request)
body = response.read()
if response.status == 200:
self._extract_tokens(body)
else:
self._invalid = True
return response
def _extract_tokens(self, body):
d = simplejson.loads(body)
self.access_token = d['access_token']
self.refresh_token = d.get('refresh_token', self.refresh_token)
if 'expires_in' in d:
self.token_expiry = datetime.timedelta(
seconds = int(d['expires_in'])) + datetime.datetime.now()
else:
self.token_expiry = None
def generate_authorize_url(self, redirect_uri='oob', response_type='code', **kwargs):
"""Returns a URI to redirect to the provider.
Args:
redirect_uri: string, Either the string 'oob' for a non-web-based
application, or a URI that handles the callback from
the authorization server.
response_type: string, Either the string 'code' for server-side or
native application, or the string 'token' for client-
side application.
If redirect_uri is 'oob' then pass in the
generated verification code to get_access_token,
otherwise pass in the query parameters received
at the callback uri to get_access_token.
If the response_type is 'token', no need to call
get_access_token as the API will return it within
the query parameters received at the callback:
oauth2_token.access_token = YOUR_ACCESS_TOKEN
"""
self.redirect_uri = redirect_uri
query = {
'response_type': response_type,
'client_id': self.client_id,
'redirect_uri': redirect_uri,
'scope': self.scope,
}
query.update(kwargs)
parts = list(urlparse.urlparse(self.auth_uri))
query.update(dict(parse_qsl(parts[4]))) # 4 is the index of the query part
parts[4] = urllib.urlencode(query)
return urlparse.urlunparse(parts)
def get_access_token(self, code):
"""Exhanges a code for an access token.
Args:
code: string or dict, either the code as a string, or a dictionary
of the query parameters to the redirect_uri, which contains
the code.
"""
if not (isinstance(code, str) or isinstance(code, unicode)):
code = code['code']
body = urllib.urlencode({
'grant_type': 'authorization_code',
'client_id': self.client_id,
'client_secret': self.client_secret,
'code': code,
'redirect_uri': self.redirect_uri,
'scope': self.scope
})
headers = {
'user-agent': self.user_agent,
}
http_client = atom.http_core.HttpClient()
http_request = atom.http_core.HttpRequest(uri=self.token_uri, method='POST',
headers=headers)
http_request.add_body_part(data=body, mime_type='application/x-www-form-urlencoded')
response = http_client.request(http_request)
body = response.read()
if response.status == 200:
self._extract_tokens(body)
return self
else:
error_msg = 'Invalid response %s.' % response.status
try:
d = simplejson.loads(body)
if 'error' in d:
error_msg = d['error']
except:
pass
raise OAuth2AccessTokenError(error_msg)
def authorize(self, client):
"""Authorize a gdata.client.GDClient instance with these credentials.
Args:
client: An instance of gdata.client.GDClient
or something that acts like it.
Returns:
A modified instance of client that was passed in.
Example:
c = gdata.client.GDClient(source='user-agent')
c = token.authorize(c)
"""
client.auth_token = self
request_orig = client.http_client.request
def new_request(http_request):
response = request_orig(http_request)
if response.status == 401:
refresh_response = self._refresh(request_orig)
if self._invalid:
return refresh_response
else:
self.modify_request(http_request)
return request_orig(http_request)
else:
return response
client.http_client.request = new_request
return client
def modify_request(self, http_request):
"""Sets the Authorization header in the HTTP request using the token.
Returns:
The same HTTP request object which was passed in.
"""
http_request.headers['Authorization'] = '%s%s' % (OAUTH2_AUTH_LABEL, self.access_token)
return http_request
ModifyRequest = modify_request
def _join_token_parts(*args):
""""Escapes and combines all strings passed in.
Used to convert a token object's members into a string instead of
using pickle.
Note: A None value will be converted to an empty string.
Returns:
A string in the form 1x|member1|member2|member3...
"""
return '|'.join([urllib.quote_plus(a or '') for a in args])
def _split_token_parts(blob):
"""Extracts and unescapes fields from the provided binary string.
Reverses the packing performed by _join_token_parts. Used to extract
the members of a token object.
Note: An empty string from the blob will be interpreted as None.
Args:
blob: str A string of the form 1x|member1|member2|member3 as created
by _join_token_parts
Returns:
A list of unescaped strings.
"""
return [urllib.unquote_plus(part) or None for part in blob.split('|')]
def token_to_blob(token):
"""Serializes the token data as a string for storage in a datastore.
Supported token classes: ClientLoginToken, AuthSubToken, SecureAuthSubToken,
OAuthRsaToken, and OAuthHmacToken, TwoLeggedOAuthRsaToken,
TwoLeggedOAuthHmacToken and OAuth2Token.
Args:
token: A token object which must be of one of the supported token classes.
Raises:
UnsupportedTokenType if the token is not one of the supported token
classes listed above.
Returns:
A string represenging this token. The string can be converted back into
an equivalent token object using token_from_blob. Note that any members
which are set to '' will be set to None when the token is deserialized
by token_from_blob.
"""
if isinstance(token, ClientLoginToken):
return _join_token_parts('1c', token.token_string)
# Check for secure auth sub type first since it is a subclass of
# AuthSubToken.
elif isinstance(token, SecureAuthSubToken):
return _join_token_parts('1s', token.token_string, token.rsa_private_key,
*token.scopes)
elif isinstance(token, AuthSubToken):
return _join_token_parts('1a', token.token_string, *token.scopes)
elif isinstance(token, TwoLeggedOAuthRsaToken):
return _join_token_parts(
'1rtl', token.consumer_key, token.rsa_private_key, token.requestor_id)
elif isinstance(token, TwoLeggedOAuthHmacToken):
return _join_token_parts(
'1htl', token.consumer_key, token.consumer_secret, token.requestor_id)
# Check RSA OAuth token first since the OAuthRsaToken is a subclass of
# OAuthHmacToken.
elif isinstance(token, OAuthRsaToken):
return _join_token_parts(
'1r', token.consumer_key, token.rsa_private_key, token.token,
token.token_secret, str(token.auth_state), token.next,
token.verifier)
elif isinstance(token, OAuthHmacToken):
return _join_token_parts(
'1h', token.consumer_key, token.consumer_secret, token.token,
token.token_secret, str(token.auth_state), token.next,
token.verifier)
elif isinstance(token, OAuth2Token):
return _join_token_parts(
'2o', token.client_id, token.client_secret, token.scope,
token.user_agent, token.auth_uri, token.token_uri,
token.access_token, token.refresh_token)
else:
raise UnsupportedTokenType(
'Unable to serialize token of type %s' % type(token))
TokenToBlob = token_to_blob
def token_from_blob(blob):
"""Deserializes a token string from the datastore back into a token object.
Supported token classes: ClientLoginToken, AuthSubToken, SecureAuthSubToken,
OAuthRsaToken, and OAuthHmacToken, TwoLeggedOAuthRsaToken,
TwoLeggedOAuthHmacToken and OAuth2Token.
Args:
blob: string created by token_to_blob.
Raises:
UnsupportedTokenType if the token is not one of the supported token
classes listed above.
Returns:
A new token object with members set to the values serialized in the
blob string. Note that any members which were set to '' in the original
token will now be None.
"""
parts = _split_token_parts(blob)
if parts[0] == '1c':
return ClientLoginToken(parts[1])
elif parts[0] == '1a':
return AuthSubToken(parts[1], parts[2:])
elif parts[0] == '1s':
return SecureAuthSubToken(parts[1], parts[2], parts[3:])
elif parts[0] == '1rtl':
return TwoLeggedOAuthRsaToken(parts[1], parts[2], parts[3])
elif parts[0] == '1htl':
return TwoLeggedOAuthHmacToken(parts[1], parts[2], parts[3])
elif parts[0] == '1r':
auth_state = int(parts[5])
return OAuthRsaToken(parts[1], parts[2], parts[3], parts[4], auth_state,
parts[6], parts[7])
elif parts[0] == '1h':
auth_state = int(parts[5])
return OAuthHmacToken(parts[1], parts[2], parts[3], parts[4], auth_state,
parts[6], parts[7])
elif parts[0] == '2o':
return OAuth2Token(parts[1], parts[2], parts[3], parts[4], parts[5],
parts[6], parts[7], parts[8])
else:
raise UnsupportedTokenType(
'Unable to deserialize token with type marker of %s' % parts[0])
TokenFromBlob = token_from_blob
def dump_tokens(tokens):
return ','.join([token_to_blob(t) for t in tokens])
def load_tokens(blob):
return [token_from_blob(s) for s in blob.split(',')]
def find_scopes_for_services(service_names=None):
"""Creates a combined list of scope URLs for the desired services.
This method searches the AUTH_SCOPES dictionary.
Args:
service_names: list of strings (optional) Each name must be a key in the
AUTH_SCOPES dictionary. If no list is provided (None) then
the resulting list will contain all scope URLs in the
AUTH_SCOPES dict.
Returns:
A list of URL strings which are the scopes needed to access these services
when requesting a token using AuthSub or OAuth.
"""
result_scopes = []
if service_names is None:
for service_name, scopes in AUTH_SCOPES.iteritems():
result_scopes.extend(scopes)
else:
for service_name in service_names:
result_scopes.extend(AUTH_SCOPES[service_name])
return result_scopes
FindScopesForServices = find_scopes_for_services
def ae_save(token, token_key):
"""Stores an auth token in the App Engine datastore.
This is a convenience method for using the library with App Engine.
Recommended usage is to associate the auth token with the current_user.
If a user is signed in to the app using the App Engine users API, you
can use
gdata.gauth.ae_save(some_token, users.get_current_user().user_id())
If you are not using the Users API you are free to choose whatever
string you would like for a token_string.
Args:
token: an auth token object. Must be one of ClientLoginToken,
AuthSubToken, SecureAuthSubToken, OAuthRsaToken, or OAuthHmacToken
(see token_to_blob).
token_key: str A unique identified to be used when you want to retrieve
the token. If the user is signed in to App Engine using the
users API, I recommend using the user ID for the token_key:
users.get_current_user().user_id()
"""
import gdata.alt.app_engine
key_name = ''.join(('gd_auth_token', token_key))
return gdata.alt.app_engine.set_token(key_name, token_to_blob(token))
AeSave = ae_save
def ae_load(token_key):
"""Retrieves a token object from the App Engine datastore.
This is a convenience method for using the library with App Engine.
See also ae_save.
Args:
token_key: str The unique key associated with the desired token when it
was saved using ae_save.
Returns:
A token object if there was a token associated with the token_key or None
if the key could not be found.
"""
import gdata.alt.app_engine
key_name = ''.join(('gd_auth_token', token_key))
token_string = gdata.alt.app_engine.get_token(key_name)
if token_string is not None:
return token_from_blob(token_string)
else:
return None
AeLoad = ae_load
def ae_delete(token_key):
"""Removes the token object from the App Engine datastore."""
import gdata.alt.app_engine
key_name = ''.join(('gd_auth_token', token_key))
gdata.alt.app_engine.delete_token(key_name)
AeDelete = ae_delete
|
apache-2.0
|
[
3381,
2647,
15,
1393,
15,
1813,
2366,
199,
3,
199,
3,
1898,
334,
35,
9,
8937,
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,
421,
199,
3,
961,
859,
365,
1202,
367,
1015,
499,
402,
314,
4475,
3918,
15913,
14,
421,
199,
624,
17473,
1790,
4048,
1526,
3992,
436,
3423,
367,
4475,
3918,
15913,
14,
199,
199,
3264,
3992,
2954,
282,
922,
1159,
13448,
402,
642,
1145,
370,
2879,
3932,
199,
576,
14,
24612,
3520,
787,
440,
2737,
5370,
1325,
701,
282,
598,
36,
3041,
909,
14,
199,
199,
3041,
8880,
3264,
199,
2817,
2610,
3264,
199,
24117,
2817,
2610,
3264,
199,
12906,
40,
3088,
3264,
199,
12906,
50,
2231,
3264,
199,
11467,
13257,
3046,
12906,
40,
3088,
3264,
199,
11467,
13257,
3046,
12906,
50,
2231,
3264,
199,
199,
13967,
1314,
787,
14115,
1202,
315,
4223,
1233,
334,
305,
25068,
370,
2951,
4453,
199,
1589,
11006,
13,
1548,
13,
1258,
3555,
9,
787,
314,
2569,
26,
199,
199,
4208,
63,
1178,
63,
954,
63,
633,
199,
14204,
63,
1069,
63,
1418,
199,
199,
1918,
2569,
787,
5922,
3423,
1314,
787,
1202,
370,
3354,
436,
2248,
1790,
1526,
199,
1462,
315,
314,
4693,
12580,
12007,
14,
5723,
1077,
1454,
506,
1202,
340,
1265,
787,
1808,
199,
3749,
3555,
4453,
4693,
12580,
26,
199,
199,
3624,
63,
912,
199,
3624,
63,
2117,
199,
624,
421,
199,
646,
2197,
199,
646,
900,
199,
646,
2196,
199,
646,
4011,
199,
646,
7097,
199,
646,
6222,
14,
1014,
63,
1018,
199,
199,
893,
26,
523,
492,
13804,
199,
2590,
3545,
26,
523,
862,
26,
272,
327,
7649,
370,
492,
687,
1639,
12,
1077,
1736,
641,
4693,
12580,
272,
687,
1639,
14,
1208,
492,
13804,
523,
871,
3545,
26,
272,
327,
7719,
1736,
367,
2018,
18,
14,
22,
436,
10948,
14,
272,
492,
2022,
465,
13804,
199,
199,
893,
26,
272,
687,
7097,
492,
2198,
63,
26714,
199,
2590,
3545,
26,
272,
687,
16004,
492,
2198,
63,
26714,
421,
199,
363,
2502,
363,
275,
283,
74,
14,
83,
32,
3098,
14,
957,
334,
42,
3609,
13916,
1181,
424,
3171,
421,
199,
15605,
16996,
948,
63,
5580,
63,
13837,
275,
283,
13266,
8880,
1790,
534,
199,
5580,
6348,
63,
5580,
63,
13837,
275,
283,
2817,
2610,
1526,
534,
199,
24041,
18,
63,
5580,
63,
13837,
275,
283,
12906,
283,
421,
199,
3,
961,
1211,
6571,
314,
3590,
2610,
436,
11715,
14570,
367,
1006,
8500,
701,
2435,
199,
3,
536,
14,
710,
2435,
536,
334,
498,
9,
365,
1202,
315,
6810,
8880,
4145,
14,
199,
5580,
63,
15901,
48,
654,
275,
469,
272,
283,
429,
356,
334,
327,
4475,
27779,
3261,
267,
283,
2859,
921,
1544,
14,
3098,
14,
957,
15,
8183,
15,
11522,
3678,
267,
283,
1014,
921,
1544,
14,
3098,
14,
957,
15,
8183,
15,
11522,
20467,
272,
283,
71,
1095,
356,
334,
327,
4475,
3523,
3261,
267,
283,
1014,
921,
1095,
14,
3098,
14,
957,
15,
1095,
15,
11522,
3678,
267,
283,
1014,
921,
1544,
14,
3098,
14,
957,
15,
1095,
15,
11522,
20467,
272,
283,
66,
2921,
356,
334,
327,
699,
2921,
3261,
267,
283,
1014,
921,
1544,
14,
66,
2921,
14,
957,
15,
11522,
3678,
395,
272,
283,
600,
1733,
356,
334,
327,
4475,
5495,
8730,
3261,
267,
283,
1014,
921,
1544,
14,
3098,
14,
957,
15,
600,
1733,
15,
11522,
3678,
395,
272,
283,
1850,
356,
334,
327,
1448,
11961,
3261,
267,
283,
2859,
921,
1544,
14,
3098,
14,
957,
15,
77,
24,
15,
11522,
3678,
267,
283,
1014,
921,
1544,
14,
3098,
14,
957,
15,
77,
24,
15,
11522,
20467,
272,
283,
2408,
554,
356,
334,
327,
4475,
11711,
554,
3261,
267,
283,
1014,
921,
2408,
554,
14,
3098,
14,
957,
15,
2408,
554,
15,
11522,
3678,
395,
272,
283,
9665,
356,
334,
327,
4475,
5311,
6130,
3261,
267,
283,
2859,
921,
1544,
14,
3098,
14,
957,
15,
9665,
15,
11522,
3678,
395,
272,
283,
952,
590,
356,
334,
327,
21361,
3820,
3261,
267,
283,
2859,
921,
4757,
14,
3098,
14,
957,
15,
11522,
3678,
267,
283,
2859,
921,
19930,
83,
14,
3098,
14,
957,
15,
11522,
3678,
267,
283,
2859,
921,
4757,
14,
3098,
751,
1317,
14,
957,
20467,
272,
283,
25514,
18,
356,
334,
327,
510,
530,
30253,
6001,
4580,
7767,
83,
3261,
267,
283,
1014,
921,
12475,
30253,
2520,
14,
3098,
14,
957,
15,
576,
3678,
395,
272,
283,
5181,
356,
334,
327,
4475,
4693,
83,
2165,
2317,
316,
3261,
267,
283,
2859,
921,
5181,
13,
12662,
14,
3098,
14,
957,
15,
65,
15,
11522,
15,
751,
3678,
267,
283,
2859,
921,
5181,
13,
12662,
14,
3098,
14,
957,
15,
65,
15,
11522,
15,
11767,
3678,
267,
283,
2859,
921,
5181,
13,
12662,
14,
3098,
14,
957,
15,
65,
15,
11522,
15,
3620,
3678,
267,
283,
2859,
921,
5181,
13,
12662,
14,
3098,
14,
957,
15,
65,
15,
11522,
15,
2634,
20467,
272,
283,
1129,
28396,
356,
334,
327,
5311,
6130,
869,
25,
428,
10075,
267,
283,
2859,
921,
1544,
14,
3098,
14,
957,
15,
72,
25,
15,
11522,
3678,
395,
272,
283,
2605,
356,
334,
327,
428,
12032,
83,
3918,
3261,
267,
283,
2859,
921,
19930,
83,
14,
3098,
14,
957,
15,
11522,
3678,
395,
272,
283,
30515,
356,
334,
327,
4475,
6001,
4133,
23228,
3261,
267,
283,
2859,
921,
1544,
14,
3098,
14,
957,
15,
2520,
5892,
878,
15,
2537,
15,
11522,
3678,
395,
272,
283,
9788,
356,
334,
327,
23534,
3261,
267,
283
] |
[
2647,
15,
1393,
15,
1813,
2366,
199,
3,
199,
3,
1898,
334,
35,
9,
8937,
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,
421,
199,
3,
961,
859,
365,
1202,
367,
1015,
499,
402,
314,
4475,
3918,
15913,
14,
421,
199,
624,
17473,
1790,
4048,
1526,
3992,
436,
3423,
367,
4475,
3918,
15913,
14,
199,
199,
3264,
3992,
2954,
282,
922,
1159,
13448,
402,
642,
1145,
370,
2879,
3932,
199,
576,
14,
24612,
3520,
787,
440,
2737,
5370,
1325,
701,
282,
598,
36,
3041,
909,
14,
199,
199,
3041,
8880,
3264,
199,
2817,
2610,
3264,
199,
24117,
2817,
2610,
3264,
199,
12906,
40,
3088,
3264,
199,
12906,
50,
2231,
3264,
199,
11467,
13257,
3046,
12906,
40,
3088,
3264,
199,
11467,
13257,
3046,
12906,
50,
2231,
3264,
199,
199,
13967,
1314,
787,
14115,
1202,
315,
4223,
1233,
334,
305,
25068,
370,
2951,
4453,
199,
1589,
11006,
13,
1548,
13,
1258,
3555,
9,
787,
314,
2569,
26,
199,
199,
4208,
63,
1178,
63,
954,
63,
633,
199,
14204,
63,
1069,
63,
1418,
199,
199,
1918,
2569,
787,
5922,
3423,
1314,
787,
1202,
370,
3354,
436,
2248,
1790,
1526,
199,
1462,
315,
314,
4693,
12580,
12007,
14,
5723,
1077,
1454,
506,
1202,
340,
1265,
787,
1808,
199,
3749,
3555,
4453,
4693,
12580,
26,
199,
199,
3624,
63,
912,
199,
3624,
63,
2117,
199,
624,
421,
199,
646,
2197,
199,
646,
900,
199,
646,
2196,
199,
646,
4011,
199,
646,
7097,
199,
646,
6222,
14,
1014,
63,
1018,
199,
199,
893,
26,
523,
492,
13804,
199,
2590,
3545,
26,
523,
862,
26,
272,
327,
7649,
370,
492,
687,
1639,
12,
1077,
1736,
641,
4693,
12580,
272,
687,
1639,
14,
1208,
492,
13804,
523,
871,
3545,
26,
272,
327,
7719,
1736,
367,
2018,
18,
14,
22,
436,
10948,
14,
272,
492,
2022,
465,
13804,
199,
199,
893,
26,
272,
687,
7097,
492,
2198,
63,
26714,
199,
2590,
3545,
26,
272,
687,
16004,
492,
2198,
63,
26714,
421,
199,
363,
2502,
363,
275,
283,
74,
14,
83,
32,
3098,
14,
957,
334,
42,
3609,
13916,
1181,
424,
3171,
421,
199,
15605,
16996,
948,
63,
5580,
63,
13837,
275,
283,
13266,
8880,
1790,
534,
199,
5580,
6348,
63,
5580,
63,
13837,
275,
283,
2817,
2610,
1526,
534,
199,
24041,
18,
63,
5580,
63,
13837,
275,
283,
12906,
283,
421,
199,
3,
961,
1211,
6571,
314,
3590,
2610,
436,
11715,
14570,
367,
1006,
8500,
701,
2435,
199,
3,
536,
14,
710,
2435,
536,
334,
498,
9,
365,
1202,
315,
6810,
8880,
4145,
14,
199,
5580,
63,
15901,
48,
654,
275,
469,
272,
283,
429,
356,
334,
327,
4475,
27779,
3261,
267,
283,
2859,
921,
1544,
14,
3098,
14,
957,
15,
8183,
15,
11522,
3678,
267,
283,
1014,
921,
1544,
14,
3098,
14,
957,
15,
8183,
15,
11522,
20467,
272,
283,
71,
1095,
356,
334,
327,
4475,
3523,
3261,
267,
283,
1014,
921,
1095,
14,
3098,
14,
957,
15,
1095,
15,
11522,
3678,
267,
283,
1014,
921,
1544,
14,
3098,
14,
957,
15,
1095,
15,
11522,
20467,
272,
283,
66,
2921,
356,
334,
327,
699,
2921,
3261,
267,
283,
1014,
921,
1544,
14,
66,
2921,
14,
957,
15,
11522,
3678,
395,
272,
283,
600,
1733,
356,
334,
327,
4475,
5495,
8730,
3261,
267,
283,
1014,
921,
1544,
14,
3098,
14,
957,
15,
600,
1733,
15,
11522,
3678,
395,
272,
283,
1850,
356,
334,
327,
1448,
11961,
3261,
267,
283,
2859,
921,
1544,
14,
3098,
14,
957,
15,
77,
24,
15,
11522,
3678,
267,
283,
1014,
921,
1544,
14,
3098,
14,
957,
15,
77,
24,
15,
11522,
20467,
272,
283,
2408,
554,
356,
334,
327,
4475,
11711,
554,
3261,
267,
283,
1014,
921,
2408,
554,
14,
3098,
14,
957,
15,
2408,
554,
15,
11522,
3678,
395,
272,
283,
9665,
356,
334,
327,
4475,
5311,
6130,
3261,
267,
283,
2859,
921,
1544,
14,
3098,
14,
957,
15,
9665,
15,
11522,
3678,
395,
272,
283,
952,
590,
356,
334,
327,
21361,
3820,
3261,
267,
283,
2859,
921,
4757,
14,
3098,
14,
957,
15,
11522,
3678,
267,
283,
2859,
921,
19930,
83,
14,
3098,
14,
957,
15,
11522,
3678,
267,
283,
2859,
921,
4757,
14,
3098,
751,
1317,
14,
957,
20467,
272,
283,
25514,
18,
356,
334,
327,
510,
530,
30253,
6001,
4580,
7767,
83,
3261,
267,
283,
1014,
921,
12475,
30253,
2520,
14,
3098,
14,
957,
15,
576,
3678,
395,
272,
283,
5181,
356,
334,
327,
4475,
4693,
83,
2165,
2317,
316,
3261,
267,
283,
2859,
921,
5181,
13,
12662,
14,
3098,
14,
957,
15,
65,
15,
11522,
15,
751,
3678,
267,
283,
2859,
921,
5181,
13,
12662,
14,
3098,
14,
957,
15,
65,
15,
11522,
15,
11767,
3678,
267,
283,
2859,
921,
5181,
13,
12662,
14,
3098,
14,
957,
15,
65,
15,
11522,
15,
3620,
3678,
267,
283,
2859,
921,
5181,
13,
12662,
14,
3098,
14,
957,
15,
65,
15,
11522,
15,
2634,
20467,
272,
283,
1129,
28396,
356,
334,
327,
5311,
6130,
869,
25,
428,
10075,
267,
283,
2859,
921,
1544,
14,
3098,
14,
957,
15,
72,
25,
15,
11522,
3678,
395,
272,
283,
2605,
356,
334,
327,
428,
12032,
83,
3918,
3261,
267,
283,
2859,
921,
19930,
83,
14,
3098,
14,
957,
15,
11522,
3678,
395,
272,
283,
30515,
356,
334,
327,
4475,
6001,
4133,
23228,
3261,
267,
283,
2859,
921,
1544,
14,
3098,
14,
957,
15,
2520,
5892,
878,
15,
2537,
15,
11522,
3678,
395,
272,
283,
9788,
356,
334,
327,
23534,
3261,
267,
283,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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