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
|
|---|---|---|---|---|---|---|---|---|
TheDSCPL/SSRE_2017-2018_group8
|
Projeto/Python/cryptopy/crypto/cipher/rijndael.py
|
1
|
14718
|
# -*- coding: utf-8 -*-
""" crypto.cipher.rijndael
Rijndael encryption algorithm
This byte oriented implementation is intended to closely
match FIPS specification for readability. It is not implemented
for performance.
Copyright © (c) 2002 by Paul A. Lambert
Read LICENSE.txt for license information.
2002-06-01
"""
from crypto.cipher.base import BlockCipher, padWithPadLen, noPadding
class Rijndael(BlockCipher):
""" Rijndael encryption algorithm """
def __init__(self, key = None, padding = padWithPadLen(), keySize=16, blockSize=16 ):
self.name = 'RIJNDAEL'
self.keySize = keySize
self.strength = keySize*8
self.blockSize = blockSize # blockSize is in bytes
self.padding = padding # change default to noPadding() to get normal ECB behavior
assert( keySize%4==0 and NrTable[4].has_key(keySize/4)),'key size must be 16,20,24,29 or 32 bytes'
assert( blockSize%4==0 and NrTable.has_key(blockSize/4)), 'block size must be 16,20,24,29 or 32 bytes'
self.Nb = self.blockSize/4 # Nb is number of columns of 32 bit words
self.Nk = keySize/4 # Nk is the key length in 32-bit words
self.Nr = NrTable[self.Nb][self.Nk] # The number of rounds (Nr) is a function of
# the block (Nb) and key (Nk) sizes.
if key != None:
self.setKey(key)
def setKey(self, key):
""" Set a key and generate the expanded key """
assert( len(key) == (self.Nk*4) ), 'Key length must be same as keySize parameter'
self.__expandedKey = keyExpansion(self, key)
self.reset() # BlockCipher.reset()
def encryptBlock(self, plainTextBlock):
""" Encrypt a block, plainTextBlock must be a array of bytes [Nb by 4] """
self.state = self._toBlock(plainTextBlock)
AddRoundKey(self, self.__expandedKey[0:self.Nb])
for round in range(1,self.Nr): #for round = 1 step 1 to Nr1
SubBytes(self)
ShiftRows(self)
MixColumns(self)
AddRoundKey(self, self.__expandedKey[round*self.Nb:(round+1)*self.Nb])
SubBytes(self)
ShiftRows(self)
AddRoundKey(self, self.__expandedKey[self.Nr*self.Nb:(self.Nr+1)*self.Nb])
return self._toBString(self.state)
def decryptBlock(self, encryptedBlock):
""" decrypt a block (array of bytes) """
self.state = self._toBlock(encryptedBlock)
AddRoundKey(self, self.__expandedKey[self.Nr*self.Nb:(self.Nr+1)*self.Nb])
for round in range(self.Nr-1,0,-1):
InvShiftRows(self)
InvSubBytes(self)
AddRoundKey(self, self.__expandedKey[round*self.Nb:(round+1)*self.Nb])
InvMixColumns(self)
InvShiftRows(self)
InvSubBytes(self)
AddRoundKey(self, self.__expandedKey[0:self.Nb])
return self._toBString(self.state)
def _toBlock(self, bs):
""" Convert binary string to array of bytes, state[col][row]"""
assert ( len(bs) == 4*self.Nb ), 'Rijndarl blocks must be of size blockSize'
return [[ord(bs[4*i]),ord(bs[4*i+1]),ord(bs[4*i+2]),ord(bs[4*i+3])] for i in range(self.Nb)]
def _toBString(self, block):
""" Convert block (array of bytes) to binary string """
l = []
for col in block:
for rowElement in col:
l.append(chr(rowElement))
return ''.join(l)
#-------------------------------------
""" Number of rounds Nr = NrTable[Nb][Nk]
Nb Nk=4 Nk=5 Nk=6 Nk=7 Nk=8
------------------------------------- """
NrTable = {4: {4:10, 5:11, 6:12, 7:13, 8:14},
5: {4:11, 5:11, 6:12, 7:13, 8:14},
6: {4:12, 5:12, 6:12, 7:13, 8:14},
7: {4:13, 5:13, 6:13, 7:13, 8:14},
8: {4:14, 5:14, 6:14, 7:14, 8:14}}
#-------------------------------------
def keyExpansion(algInstance, keyString):
""" Expand a string of size keySize into a larger array """
Nk, Nb, Nr = algInstance.Nk, algInstance.Nb, algInstance.Nr # for readability
key = [ord(byte) for byte in keyString] # convert string to list
w = [[key[4*i],key[4*i+1],key[4*i+2],key[4*i+3]] for i in range(Nk)]
for i in range(Nk,Nb*(Nr+1)):
temp = w[i-1] # a four byte column
if (i%Nk) == 0 :
temp = temp[1:]+[temp[0]] # RotWord(temp)
temp = [ Sbox[byte] for byte in temp ]
temp[0] ^= Rcon[i/Nk]
elif Nk > 6 and i%Nk == 4 :
temp = [ Sbox[byte] for byte in temp ] # SubWord(temp)
w.append( [ w[i-Nk][byte]^temp[byte] for byte in range(4) ] )
return w
Rcon = (0,0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80,0x1b,0x36, # note extra '0' !!!
0x6c,0xd8,0xab,0x4d,0x9a,0x2f,0x5e,0xbc,0x63,0xc6,
0x97,0x35,0x6a,0xd4,0xb3,0x7d,0xfa,0xef,0xc5,0x91)
#-------------------------------------
def AddRoundKey(algInstance, keyBlock):
""" XOR the algorithm state with a block of key material """
for column in range(algInstance.Nb):
for row in range(4):
algInstance.state[column][row] ^= keyBlock[column][row]
#-------------------------------------
def SubBytes(algInstance):
for column in range(algInstance.Nb):
for row in range(4):
algInstance.state[column][row] = Sbox[algInstance.state[column][row]]
def InvSubBytes(algInstance):
for column in range(algInstance.Nb):
for row in range(4):
algInstance.state[column][row] = InvSbox[algInstance.state[column][row]]
Sbox = (0x63,0x7c,0x77,0x7b,0xf2,0x6b,0x6f,0xc5,
0x30,0x01,0x67,0x2b,0xfe,0xd7,0xab,0x76,
0xca,0x82,0xc9,0x7d,0xfa,0x59,0x47,0xf0,
0xad,0xd4,0xa2,0xaf,0x9c,0xa4,0x72,0xc0,
0xb7,0xfd,0x93,0x26,0x36,0x3f,0xf7,0xcc,
0x34,0xa5,0xe5,0xf1,0x71,0xd8,0x31,0x15,
0x04,0xc7,0x23,0xc3,0x18,0x96,0x05,0x9a,
0x07,0x12,0x80,0xe2,0xeb,0x27,0xb2,0x75,
0x09,0x83,0x2c,0x1a,0x1b,0x6e,0x5a,0xa0,
0x52,0x3b,0xd6,0xb3,0x29,0xe3,0x2f,0x84,
0x53,0xd1,0x00,0xed,0x20,0xfc,0xb1,0x5b,
0x6a,0xcb,0xbe,0x39,0x4a,0x4c,0x58,0xcf,
0xd0,0xef,0xaa,0xfb,0x43,0x4d,0x33,0x85,
0x45,0xf9,0x02,0x7f,0x50,0x3c,0x9f,0xa8,
0x51,0xa3,0x40,0x8f,0x92,0x9d,0x38,0xf5,
0xbc,0xb6,0xda,0x21,0x10,0xff,0xf3,0xd2,
0xcd,0x0c,0x13,0xec,0x5f,0x97,0x44,0x17,
0xc4,0xa7,0x7e,0x3d,0x64,0x5d,0x19,0x73,
0x60,0x81,0x4f,0xdc,0x22,0x2a,0x90,0x88,
0x46,0xee,0xb8,0x14,0xde,0x5e,0x0b,0xdb,
0xe0,0x32,0x3a,0x0a,0x49,0x06,0x24,0x5c,
0xc2,0xd3,0xac,0x62,0x91,0x95,0xe4,0x79,
0xe7,0xc8,0x37,0x6d,0x8d,0xd5,0x4e,0xa9,
0x6c,0x56,0xf4,0xea,0x65,0x7a,0xae,0x08,
0xba,0x78,0x25,0x2e,0x1c,0xa6,0xb4,0xc6,
0xe8,0xdd,0x74,0x1f,0x4b,0xbd,0x8b,0x8a,
0x70,0x3e,0xb5,0x66,0x48,0x03,0xf6,0x0e,
0x61,0x35,0x57,0xb9,0x86,0xc1,0x1d,0x9e,
0xe1,0xf8,0x98,0x11,0x69,0xd9,0x8e,0x94,
0x9b,0x1e,0x87,0xe9,0xce,0x55,0x28,0xdf,
0x8c,0xa1,0x89,0x0d,0xbf,0xe6,0x42,0x68,
0x41,0x99,0x2d,0x0f,0xb0,0x54,0xbb,0x16)
InvSbox = (0x52,0x09,0x6a,0xd5,0x30,0x36,0xa5,0x38,
0xbf,0x40,0xa3,0x9e,0x81,0xf3,0xd7,0xfb,
0x7c,0xe3,0x39,0x82,0x9b,0x2f,0xff,0x87,
0x34,0x8e,0x43,0x44,0xc4,0xde,0xe9,0xcb,
0x54,0x7b,0x94,0x32,0xa6,0xc2,0x23,0x3d,
0xee,0x4c,0x95,0x0b,0x42,0xfa,0xc3,0x4e,
0x08,0x2e,0xa1,0x66,0x28,0xd9,0x24,0xb2,
0x76,0x5b,0xa2,0x49,0x6d,0x8b,0xd1,0x25,
0x72,0xf8,0xf6,0x64,0x86,0x68,0x98,0x16,
0xd4,0xa4,0x5c,0xcc,0x5d,0x65,0xb6,0x92,
0x6c,0x70,0x48,0x50,0xfd,0xed,0xb9,0xda,
0x5e,0x15,0x46,0x57,0xa7,0x8d,0x9d,0x84,
0x90,0xd8,0xab,0x00,0x8c,0xbc,0xd3,0x0a,
0xf7,0xe4,0x58,0x05,0xb8,0xb3,0x45,0x06,
0xd0,0x2c,0x1e,0x8f,0xca,0x3f,0x0f,0x02,
0xc1,0xaf,0xbd,0x03,0x01,0x13,0x8a,0x6b,
0x3a,0x91,0x11,0x41,0x4f,0x67,0xdc,0xea,
0x97,0xf2,0xcf,0xce,0xf0,0xb4,0xe6,0x73,
0x96,0xac,0x74,0x22,0xe7,0xad,0x35,0x85,
0xe2,0xf9,0x37,0xe8,0x1c,0x75,0xdf,0x6e,
0x47,0xf1,0x1a,0x71,0x1d,0x29,0xc5,0x89,
0x6f,0xb7,0x62,0x0e,0xaa,0x18,0xbe,0x1b,
0xfc,0x56,0x3e,0x4b,0xc6,0xd2,0x79,0x20,
0x9a,0xdb,0xc0,0xfe,0x78,0xcd,0x5a,0xf4,
0x1f,0xdd,0xa8,0x33,0x88,0x07,0xc7,0x31,
0xb1,0x12,0x10,0x59,0x27,0x80,0xec,0x5f,
0x60,0x51,0x7f,0xa9,0x19,0xb5,0x4a,0x0d,
0x2d,0xe5,0x7a,0x9f,0x93,0xc9,0x9c,0xef,
0xa0,0xe0,0x3b,0x4d,0xae,0x2a,0xf5,0xb0,
0xc8,0xeb,0xbb,0x3c,0x83,0x53,0x99,0x61,
0x17,0x2b,0x04,0x7e,0xba,0x77,0xd6,0x26,
0xe1,0x69,0x14,0x63,0x55,0x21,0x0c,0x7d)
#-------------------------------------
""" For each block size (Nb), the ShiftRow operation shifts row i
by the amount Ci. Note that row 0 is not shifted.
Nb C1 C2 C3
------------------- """
shiftOffset = { 4 : ( 0, 1, 2, 3),
5 : ( 0, 1, 2, 3),
6 : ( 0, 1, 2, 3),
7 : ( 0, 1, 2, 4),
8 : ( 0, 1, 3, 4) }
def ShiftRows(algInstance):
tmp = [0]*algInstance.Nb # list of size Nb
for r in range(1,4): # row 0 reamains unchanged and can be skipped
for c in range(algInstance.Nb):
tmp[c] = algInstance.state[(c+shiftOffset[algInstance.Nb][r]) % algInstance.Nb][r]
for c in range(algInstance.Nb):
algInstance.state[c][r] = tmp[c]
def InvShiftRows(algInstance):
tmp = [0]*algInstance.Nb # list of size Nb
for r in range(1,4): # row 0 reamains unchanged and can be skipped
for c in range(algInstance.Nb):
tmp[c] = algInstance.state[(c+algInstance.Nb-shiftOffset[algInstance.Nb][r]) % algInstance.Nb][r]
for c in range(algInstance.Nb):
algInstance.state[c][r] = tmp[c]
#-------------------------------------
def MixColumns(a):
Sprime = [0,0,0,0]
for j in range(a.Nb): # for each column
Sprime[0] = mul(2,a.state[j][0])^mul(3,a.state[j][1])^mul(1,a.state[j][2])^mul(1,a.state[j][3])
Sprime[1] = mul(1,a.state[j][0])^mul(2,a.state[j][1])^mul(3,a.state[j][2])^mul(1,a.state[j][3])
Sprime[2] = mul(1,a.state[j][0])^mul(1,a.state[j][1])^mul(2,a.state[j][2])^mul(3,a.state[j][3])
Sprime[3] = mul(3,a.state[j][0])^mul(1,a.state[j][1])^mul(1,a.state[j][2])^mul(2,a.state[j][3])
for i in range(4):
a.state[j][i] = Sprime[i]
def InvMixColumns(a):
""" Mix the four bytes of every column in a linear way
This is the opposite operation of Mixcolumn """
Sprime = [0,0,0,0]
for j in range(a.Nb): # for each column
Sprime[0] = mul(0x0E,a.state[j][0])^mul(0x0B,a.state[j][1])^mul(0x0D,a.state[j][2])^mul(0x09,a.state[j][3])
Sprime[1] = mul(0x09,a.state[j][0])^mul(0x0E,a.state[j][1])^mul(0x0B,a.state[j][2])^mul(0x0D,a.state[j][3])
Sprime[2] = mul(0x0D,a.state[j][0])^mul(0x09,a.state[j][1])^mul(0x0E,a.state[j][2])^mul(0x0B,a.state[j][3])
Sprime[3] = mul(0x0B,a.state[j][0])^mul(0x0D,a.state[j][1])^mul(0x09,a.state[j][2])^mul(0x0E,a.state[j][3])
for i in range(4):
a.state[j][i] = Sprime[i]
#-------------------------------------
def mul(a, b):
""" Multiply two elements of GF(2^m)
needed for MixColumn and InvMixColumn """
if (a !=0 and b!=0):
return Alogtable[(Logtable[a] + Logtable[b])%255]
else:
return 0
Logtable = ( 0, 0, 25, 1, 50, 2, 26, 198, 75, 199, 27, 104, 51, 238, 223, 3,
100, 4, 224, 14, 52, 141, 129, 239, 76, 113, 8, 200, 248, 105, 28, 193,
125, 194, 29, 181, 249, 185, 39, 106, 77, 228, 166, 114, 154, 201, 9, 120,
101, 47, 138, 5, 33, 15, 225, 36, 18, 240, 130, 69, 53, 147, 218, 142,
150, 143, 219, 189, 54, 208, 206, 148, 19, 92, 210, 241, 64, 70, 131, 56,
102, 221, 253, 48, 191, 6, 139, 98, 179, 37, 226, 152, 34, 136, 145, 16,
126, 110, 72, 195, 163, 182, 30, 66, 58, 107, 40, 84, 250, 133, 61, 186,
43, 121, 10, 21, 155, 159, 94, 202, 78, 212, 172, 229, 243, 115, 167, 87,
175, 88, 168, 80, 244, 234, 214, 116, 79, 174, 233, 213, 231, 230, 173, 232,
44, 215, 117, 122, 235, 22, 11, 245, 89, 203, 95, 176, 156, 169, 81, 160,
127, 12, 246, 111, 23, 196, 73, 236, 216, 67, 31, 45, 164, 118, 123, 183,
204, 187, 62, 90, 251, 96, 177, 134, 59, 82, 161, 108, 170, 85, 41, 157,
151, 178, 135, 144, 97, 190, 220, 252, 188, 149, 207, 205, 55, 63, 91, 209,
83, 57, 132, 60, 65, 162, 109, 71, 20, 42, 158, 93, 86, 242, 211, 171,
68, 17, 146, 217, 35, 32, 46, 137, 180, 124, 184, 38, 119, 153, 227, 165,
103, 74, 237, 222, 197, 49, 254, 24, 13, 99, 140, 128, 192, 247, 112, 7)
Alogtable= ( 1, 3, 5, 15, 17, 51, 85, 255, 26, 46, 114, 150, 161, 248, 19, 53,
95, 225, 56, 72, 216, 115, 149, 164, 247, 2, 6, 10, 30, 34, 102, 170,
229, 52, 92, 228, 55, 89, 235, 38, 106, 190, 217, 112, 144, 171, 230, 49,
83, 245, 4, 12, 20, 60, 68, 204, 79, 209, 104, 184, 211, 110, 178, 205,
76, 212, 103, 169, 224, 59, 77, 215, 98, 166, 241, 8, 24, 40, 120, 136,
131, 158, 185, 208, 107, 189, 220, 127, 129, 152, 179, 206, 73, 219, 118, 154,
181, 196, 87, 249, 16, 48, 80, 240, 11, 29, 39, 105, 187, 214, 97, 163,
254, 25, 43, 125, 135, 146, 173, 236, 47, 113, 147, 174, 233, 32, 96, 160,
251, 22, 58, 78, 210, 109, 183, 194, 93, 231, 50, 86, 250, 21, 63, 65,
195, 94, 226, 61, 71, 201, 64, 192, 91, 237, 44, 116, 156, 191, 218, 117,
159, 186, 213, 100, 172, 239, 42, 126, 130, 157, 188, 223, 122, 142, 137, 128,
155, 182, 193, 88, 232, 35, 101, 175, 234, 37, 111, 177, 200, 67, 197, 84,
252, 31, 33, 99, 165, 244, 7, 9, 27, 45, 119, 153, 176, 203, 70, 202,
69, 207, 74, 222, 121, 139, 134, 145, 168, 227, 62, 66, 198, 81, 243, 14,
18, 54, 90, 238, 41, 123, 141, 140, 143, 138, 133, 148, 167, 242, 13, 23,
57, 75, 221, 124, 132, 151, 162, 253, 28, 36, 108, 180, 199, 82, 246, 1)
|
mit
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
624,
13230,
14,
9231,
14,
322,
74,
977,
10643,
339,
820,
7879,
977,
10643,
14396,
5563,
339,
961,
3696,
503,
24555,
471,
4514,
365,
11619,
370,
4002,
590,
272,
1336,
481,
12346,
8929,
367,
1586,
3616,
14,
221,
2779,
365,
440,
6366,
272,
367,
10238,
14,
339,
1898,
22405,
103,
334,
67,
9,
14790,
701,
28574,
437,
14,
491,
455,
12504,
272,
5574,
5113,
14,
2424,
367,
4190,
2556,
14,
339,
14790,
13,
1690,
13,
614,
199,
624,
199,
199,
504,
13230,
14,
9231,
14,
1095,
492,
8651,
21967,
12,
6567,
3007,
18584,
3166,
12,
949,
15069,
199,
199,
533,
820,
7879,
977,
10643,
8,
3142,
21967,
304,
272,
408,
820,
7879,
977,
10643,
14396,
5563,
408,
272,
347,
636,
826,
721,
277,
12,
790,
275,
488,
12,
6273,
275,
6567,
3007,
18584,
3166,
1062,
790,
2320,
29,
975,
12,
1853,
2320,
29,
975,
3461,
267,
291,
14,
354,
755,
275,
283,
6129,
42,
8711,
33,
2901,
7,
267,
291,
14,
498,
2320,
259,
275,
790,
2320,
267,
291,
14,
21049,
257,
275,
790,
2320,
10,
24,
267,
291,
14,
1457,
2320,
221,
275,
1853,
2320,
221,
327,
1853,
2320,
365,
315,
2783,
267,
291,
14,
8358,
259,
275,
6273,
259,
327,
1570,
849,
370,
949,
15069,
342,
370,
664,
3293,
662,
9956,
5953,
398,
702,
8,
790,
2320,
5,
20,
389,
16,
436,
653,
82,
3186,
59,
20,
1055,
1989,
63,
498,
8,
498,
2320,
15,
20,
1826,
7,
498,
1568,
1471,
506,
3193,
12,
1165,
12,
1194,
12,
1398,
503,
4337,
2783,
7,
267,
702,
8,
1853,
2320,
5,
20,
389,
16,
436,
653,
82,
3186,
14,
1989,
63,
498,
8,
1457,
2320,
15,
20,
1826,
283,
1457,
1568,
1471,
506,
3193,
12,
1165,
12,
1194,
12,
1398,
503,
4337,
2783,
7,
398,
291,
14,
26183,
275,
291,
14,
1457,
2320,
15,
20,
3515,
327,
653,
66,
365,
1329,
402,
4362,
402,
4337,
4546,
5932,
267,
291,
14,
46,
75,
275,
790,
2320,
15,
20,
463,
327,
653,
75,
365,
314,
790,
2582,
315,
4337,
13,
2075,
5932,
267,
291,
14,
46,
82,
275,
653,
82,
3186,
59,
277,
14,
26183,
1527,
277,
14,
46,
75,
61,
327,
710,
1329,
402,
27194,
334,
46,
82,
9,
365,
282,
805,
402,
4490,
327,
314,
1853,
334,
26183,
9,
436,
790,
334,
46,
75,
9,
10627,
14,
267,
340,
790,
1137,
488,
26,
288,
291,
14,
409,
1197,
8,
498,
9,
339,
347,
663,
1197,
8,
277,
12,
790,
304,
267,
408,
2494,
282,
790,
436,
3550,
314,
11507,
790,
408,
267,
702,
8,
822,
8,
498,
9,
508,
334,
277,
14,
46,
75,
10,
20,
9,
2318,
283,
1197,
2582,
1471,
506,
2011,
465,
790,
2320,
2725,
7,
267,
291,
855,
15645,
1197,
275,
790,
26048,
8,
277,
12,
790,
9,
267,
291,
14,
3958,
342,
7861,
327,
8651,
21967,
14,
3958,
342,
339,
347,
14645,
3142,
8,
277,
12,
8971,
1872,
3142,
304,
267,
408,
3447,
4997,
282,
1853,
12,
8971,
1872,
3142,
1471,
506,
282,
1625,
402,
2783,
359,
26183,
701,
841,
61,
408,
267,
291,
14,
929,
275,
291,
423,
475,
3142,
8,
6104,
1872,
3142,
9,
267,
2654,
18579,
1197,
8,
277,
12,
291,
855,
15645,
1197,
59,
16,
26,
277,
14,
26183,
566,
267,
367,
6168,
315,
1425,
8,
17,
12,
277,
14,
46,
82,
304,
3515,
327,
509,
6168,
275,
413,
3650,
413,
370,
653,
82,
127,
245,
17,
288,
4804,
5571,
8,
277,
9,
288,
29800,
13405,
8,
277,
9,
288,
603,
1148,
15086,
8,
277,
9,
288,
2654,
18579,
1197,
8,
277,
12,
291,
855,
15645,
1197,
59,
2363,
10,
277,
14,
26183,
20334,
2363,
11,
17,
3342,
277,
14,
26183,
566,
267,
4804,
5571,
8,
277,
9,
267,
29800,
13405,
8,
277,
9,
267,
2654,
18579,
1197,
8,
277,
12,
291,
855,
15645,
1197,
59,
277,
14,
46,
82,
10,
277,
14,
26183,
20334,
277,
14,
46,
82,
11,
17,
3342,
277,
14,
26183,
566,
267,
372,
291,
423,
475,
34,
1558,
8,
277,
14,
929,
9,
2378,
347,
20090,
3142,
8,
277,
12,
14862,
3142,
304,
267,
408,
20090,
282,
1853,
334,
1144,
402,
2783,
9,
408,
267,
291,
14,
929,
275,
291,
423,
475,
3142,
8,
15078,
3142,
9,
267,
2654,
18579,
1197,
8,
277,
12,
291,
855,
15645,
1197,
59,
277,
14,
46,
82,
10,
277,
14,
26183,
20334,
277,
14,
46,
82,
11,
17,
3342,
277,
14,
26183,
566,
267,
367,
6168,
315,
1425,
8,
277,
14,
46,
82,
13,
17,
12,
16,
3057,
17,
304,
288,
30110,
14379,
13405,
8,
277,
9,
288,
30110,
2610,
5571,
8,
277,
9,
288,
2654,
18579,
1197,
8,
277,
12,
291,
855,
15645,
1197,
59,
2363,
10,
277,
14,
26183,
20334,
2363,
11,
17,
3342,
277,
14,
26183,
566,
288,
30110,
18854,
15086,
8,
277,
9,
267,
30110,
14379,
13405,
8,
277,
9,
267,
30110,
2610,
5571,
8,
277,
9,
267,
2654,
18579,
1197,
8,
277,
12,
291,
855,
15645,
1197,
59,
16,
26,
277,
14,
26183,
566,
267,
372,
291,
423,
475,
34,
1558,
8,
277,
14,
929,
9,
339,
347,
485,
475,
3142,
8,
277,
12,
9922,
304,
267,
408,
7905,
3366,
1059,
370,
1625,
402,
2783,
12,
1174,
59,
761,
1527,
1143,
61,
624,
267,
702,
334,
822,
8,
1533,
9,
508,
841,
10,
277,
14,
26183,
2318,
283,
50,
7879,
977,
285,
76,
5664,
1471,
506,
402,
1568,
1853,
2320,
7,
267,
372,
3474,
2181,
8,
1533,
59,
20,
10,
73,
2522,
2181,
8,
1533,
59,
20,
10,
73,
11,
17,
2522,
2181,
8,
1533,
59,
20,
10,
73,
11,
18,
2522,
2181,
8,
1533,
59,
20,
10,
73,
11,
19,
12457,
367,
284,
315,
1425,
8,
277,
14,
26183,
1874,
339,
347,
485,
475,
34,
1558,
8,
277,
12,
1853,
304,
267,
408,
7905,
1853,
334,
1144,
402,
2783,
9,
370,
3366,
1059,
408,
267,
634,
275,
942,
267,
367,
1048,
315,
1853,
26,
288,
367,
1962,
2162,
315,
1048,
26,
355,
634,
14,
740,
8,
10194,
8,
1143,
2162,
430,
267,
372,
6522,
904,
8,
76,
9,
199,
3,
1444,
9858,
199,
624,
259,
4860,
402,
27194,
653
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
624,
13230,
14,
9231,
14,
322,
74,
977,
10643,
339,
820,
7879,
977,
10643,
14396,
5563,
339,
961,
3696,
503,
24555,
471,
4514,
365,
11619,
370,
4002,
590,
272,
1336,
481,
12346,
8929,
367,
1586,
3616,
14,
221,
2779,
365,
440,
6366,
272,
367,
10238,
14,
339,
1898,
22405,
103,
334,
67,
9,
14790,
701,
28574,
437,
14,
491,
455,
12504,
272,
5574,
5113,
14,
2424,
367,
4190,
2556,
14,
339,
14790,
13,
1690,
13,
614,
199,
624,
199,
199,
504,
13230,
14,
9231,
14,
1095,
492,
8651,
21967,
12,
6567,
3007,
18584,
3166,
12,
949,
15069,
199,
199,
533,
820,
7879,
977,
10643,
8,
3142,
21967,
304,
272,
408,
820,
7879,
977,
10643,
14396,
5563,
408,
272,
347,
636,
826,
721,
277,
12,
790,
275,
488,
12,
6273,
275,
6567,
3007,
18584,
3166,
1062,
790,
2320,
29,
975,
12,
1853,
2320,
29,
975,
3461,
267,
291,
14,
354,
755,
275,
283,
6129,
42,
8711,
33,
2901,
7,
267,
291,
14,
498,
2320,
259,
275,
790,
2320,
267,
291,
14,
21049,
257,
275,
790,
2320,
10,
24,
267,
291,
14,
1457,
2320,
221,
275,
1853,
2320,
221,
327,
1853,
2320,
365,
315,
2783,
267,
291,
14,
8358,
259,
275,
6273,
259,
327,
1570,
849,
370,
949,
15069,
342,
370,
664,
3293,
662,
9956,
5953,
398,
702,
8,
790,
2320,
5,
20,
389,
16,
436,
653,
82,
3186,
59,
20,
1055,
1989,
63,
498,
8,
498,
2320,
15,
20,
1826,
7,
498,
1568,
1471,
506,
3193,
12,
1165,
12,
1194,
12,
1398,
503,
4337,
2783,
7,
267,
702,
8,
1853,
2320,
5,
20,
389,
16,
436,
653,
82,
3186,
14,
1989,
63,
498,
8,
1457,
2320,
15,
20,
1826,
283,
1457,
1568,
1471,
506,
3193,
12,
1165,
12,
1194,
12,
1398,
503,
4337,
2783,
7,
398,
291,
14,
26183,
275,
291,
14,
1457,
2320,
15,
20,
3515,
327,
653,
66,
365,
1329,
402,
4362,
402,
4337,
4546,
5932,
267,
291,
14,
46,
75,
275,
790,
2320,
15,
20,
463,
327,
653,
75,
365,
314,
790,
2582,
315,
4337,
13,
2075,
5932,
267,
291,
14,
46,
82,
275,
653,
82,
3186,
59,
277,
14,
26183,
1527,
277,
14,
46,
75,
61,
327,
710,
1329,
402,
27194,
334,
46,
82,
9,
365,
282,
805,
402,
4490,
327,
314,
1853,
334,
26183,
9,
436,
790,
334,
46,
75,
9,
10627,
14,
267,
340,
790,
1137,
488,
26,
288,
291,
14,
409,
1197,
8,
498,
9,
339,
347,
663,
1197,
8,
277,
12,
790,
304,
267,
408,
2494,
282,
790,
436,
3550,
314,
11507,
790,
408,
267,
702,
8,
822,
8,
498,
9,
508,
334,
277,
14,
46,
75,
10,
20,
9,
2318,
283,
1197,
2582,
1471,
506,
2011,
465,
790,
2320,
2725,
7,
267,
291,
855,
15645,
1197,
275,
790,
26048,
8,
277,
12,
790,
9,
267,
291,
14,
3958,
342,
7861,
327,
8651,
21967,
14,
3958,
342,
339,
347,
14645,
3142,
8,
277,
12,
8971,
1872,
3142,
304,
267,
408,
3447,
4997,
282,
1853,
12,
8971,
1872,
3142,
1471,
506,
282,
1625,
402,
2783,
359,
26183,
701,
841,
61,
408,
267,
291,
14,
929,
275,
291,
423,
475,
3142,
8,
6104,
1872,
3142,
9,
267,
2654,
18579,
1197,
8,
277,
12,
291,
855,
15645,
1197,
59,
16,
26,
277,
14,
26183,
566,
267,
367,
6168,
315,
1425,
8,
17,
12,
277,
14,
46,
82,
304,
3515,
327,
509,
6168,
275,
413,
3650,
413,
370,
653,
82,
127,
245,
17,
288,
4804,
5571,
8,
277,
9,
288,
29800,
13405,
8,
277,
9,
288,
603,
1148,
15086,
8,
277,
9,
288,
2654,
18579,
1197,
8,
277,
12,
291,
855,
15645,
1197,
59,
2363,
10,
277,
14,
26183,
20334,
2363,
11,
17,
3342,
277,
14,
26183,
566,
267,
4804,
5571,
8,
277,
9,
267,
29800,
13405,
8,
277,
9,
267,
2654,
18579,
1197,
8,
277,
12,
291,
855,
15645,
1197,
59,
277,
14,
46,
82,
10,
277,
14,
26183,
20334,
277,
14,
46,
82,
11,
17,
3342,
277,
14,
26183,
566,
267,
372,
291,
423,
475,
34,
1558,
8,
277,
14,
929,
9,
2378,
347,
20090,
3142,
8,
277,
12,
14862,
3142,
304,
267,
408,
20090,
282,
1853,
334,
1144,
402,
2783,
9,
408,
267,
291,
14,
929,
275,
291,
423,
475,
3142,
8,
15078,
3142,
9,
267,
2654,
18579,
1197,
8,
277,
12,
291,
855,
15645,
1197,
59,
277,
14,
46,
82,
10,
277,
14,
26183,
20334,
277,
14,
46,
82,
11,
17,
3342,
277,
14,
26183,
566,
267,
367,
6168,
315,
1425,
8,
277,
14,
46,
82,
13,
17,
12,
16,
3057,
17,
304,
288,
30110,
14379,
13405,
8,
277,
9,
288,
30110,
2610,
5571,
8,
277,
9,
288,
2654,
18579,
1197,
8,
277,
12,
291,
855,
15645,
1197,
59,
2363,
10,
277,
14,
26183,
20334,
2363,
11,
17,
3342,
277,
14,
26183,
566,
288,
30110,
18854,
15086,
8,
277,
9,
267,
30110,
14379,
13405,
8,
277,
9,
267,
30110,
2610,
5571,
8,
277,
9,
267,
2654,
18579,
1197,
8,
277,
12,
291,
855,
15645,
1197,
59,
16,
26,
277,
14,
26183,
566,
267,
372,
291,
423,
475,
34,
1558,
8,
277,
14,
929,
9,
339,
347,
485,
475,
3142,
8,
277,
12,
9922,
304,
267,
408,
7905,
3366,
1059,
370,
1625,
402,
2783,
12,
1174,
59,
761,
1527,
1143,
61,
624,
267,
702,
334,
822,
8,
1533,
9,
508,
841,
10,
277,
14,
26183,
2318,
283,
50,
7879,
977,
285,
76,
5664,
1471,
506,
402,
1568,
1853,
2320,
7,
267,
372,
3474,
2181,
8,
1533,
59,
20,
10,
73,
2522,
2181,
8,
1533,
59,
20,
10,
73,
11,
17,
2522,
2181,
8,
1533,
59,
20,
10,
73,
11,
18,
2522,
2181,
8,
1533,
59,
20,
10,
73,
11,
19,
12457,
367,
284,
315,
1425,
8,
277,
14,
26183,
1874,
339,
347,
485,
475,
34,
1558,
8,
277,
12,
1853,
304,
267,
408,
7905,
1853,
334,
1144,
402,
2783,
9,
370,
3366,
1059,
408,
267,
634,
275,
942,
267,
367,
1048,
315,
1853,
26,
288,
367,
1962,
2162,
315,
1048,
26,
355,
634,
14,
740,
8,
10194,
8,
1143,
2162,
430,
267,
372,
6522,
904,
8,
76,
9,
199,
3,
1444,
9858,
199,
624,
259,
4860,
402,
27194,
653,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
Ninad998/FinalYearProject
|
deep_stylo/migrations/0001_initial.py
|
1
|
1563
|
# -*- coding: utf-8 -*-
# Generated by Django 1.10.6 on 2017-03-24 16:30
from __future__ import unicode_literals
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
import django.utils.timezone
class Migration(migrations.Migration):
initial = True
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]
operations = [
migrations.CreateModel(
name='Result',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('doc_id', models.IntegerField()),
('authorList', models.CharField(max_length=200)),
('predicted_author', models.CharField(max_length=200, null=True)),
('train_accuracy', models.DecimalField(decimal_places=10, max_digits=11, null=True)),
('validation_accuracy', models.DecimalField(decimal_places=10, max_digits=11, null=True)),
('test_accuracy', models.DecimalField(decimal_places=10, max_digits=11, null=True)),
('test_binary', models.DecimalField(decimal_places=1, max_digits=2, null=True)),
('upload_date', models.DateTimeField(default=django.utils.timezone.now)),
('status', models.DecimalField(decimal_places=1, default=0.0, max_digits=2)),
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
],
),
]
|
mit
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
17065,
701,
5634,
413,
14,
709,
14,
22,
641,
9708,
13,
1644,
13,
1194,
3193,
26,
1216,
199,
504,
636,
2443,
363,
492,
2649,
63,
5955,
199,
199,
504,
1639,
14,
2190,
492,
2202,
199,
504,
1639,
14,
697,
492,
6180,
12,
1709,
199,
646,
1639,
14,
697,
14,
992,
14,
14281,
199,
646,
1639,
14,
1208,
14,
7145,
421,
199,
533,
12090,
8,
7685,
14,
9816,
304,
339,
2536,
275,
715,
339,
5124,
275,
359,
267,
6180,
14,
31925,
63,
8575,
8,
1751,
14,
5580,
63,
3791,
63,
11429,
395,
272,
1622,
339,
5331,
275,
359,
267,
6180,
14,
14907,
8,
288,
536,
534,
2889,
297,
288,
1504,
1524,
355,
661,
344,
297,
1709,
14,
4378,
8,
2495,
63,
3966,
29,
549,
12,
5062,
63,
498,
29,
549,
12,
8437,
29,
797,
12,
3376,
63,
354,
534,
998,
3855,
355,
661,
1301,
63,
344,
297,
1709,
14,
3901,
4000,
355,
661,
2502,
1296,
297,
1709,
14,
2183,
8,
988,
63,
1267,
29,
1840,
1826,
355,
661,
21118,
63,
2502,
297,
1709,
14,
2183,
8,
988,
63,
1267,
29,
1840,
12,
2973,
29,
549,
1826,
355,
661,
2834,
63,
13374,
297,
1709,
14,
15975,
8,
6355,
63,
10696,
29,
709,
12,
1390,
63,
7022,
29,
845,
12,
2973,
29,
549,
1826,
355,
661,
6136,
63,
13374,
297,
1709,
14,
15975,
8,
6355,
63,
10696,
29,
709,
12,
1390,
63,
7022,
29,
845,
12,
2973,
29,
549,
1826,
355,
661,
396,
63,
13374,
297,
1709,
14,
15975,
8,
6355,
63,
10696,
29,
709,
12,
1390,
63,
7022,
29,
845,
12,
2973,
29,
549,
1826,
355,
661,
396,
63,
3008,
297,
1709,
14,
15975,
8,
6355,
63,
10696,
29,
17,
12,
1390,
63,
7022,
29,
18,
12,
2973,
29,
549,
1826,
355,
661,
5064,
63,
602,
297,
1709,
14,
4626,
8,
885,
29,
1176,
14,
1208,
14,
7145,
14,
2131,
1826,
355,
661,
1205,
297,
1709,
14,
15975,
8,
6355,
63,
10696,
29,
17,
12,
849,
29,
16,
14,
16,
12,
1390,
63,
7022,
29,
18,
1826,
355,
661,
751,
297,
1709,
14,
3190,
8,
265,
63,
1807,
29,
1176,
14,
697,
14,
992,
14,
14281,
14,
10855,
12,
370,
29,
1751,
14,
5580,
63,
3791,
63,
11429,
1826,
288,
2156,
267,
2318,
272,
1622,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,
17065,
701,
5634,
413,
14,
709,
14,
22,
641,
9708,
13,
1644,
13,
1194,
3193,
26,
1216,
199,
504,
636,
2443,
363,
492,
2649,
63,
5955,
199,
199,
504,
1639,
14,
2190,
492,
2202,
199,
504,
1639,
14,
697,
492,
6180,
12,
1709,
199,
646,
1639,
14,
697,
14,
992,
14,
14281,
199,
646,
1639,
14,
1208,
14,
7145,
421,
199,
533,
12090,
8,
7685,
14,
9816,
304,
339,
2536,
275,
715,
339,
5124,
275,
359,
267,
6180,
14,
31925,
63,
8575,
8,
1751,
14,
5580,
63,
3791,
63,
11429,
395,
272,
1622,
339,
5331,
275,
359,
267,
6180,
14,
14907,
8,
288,
536,
534,
2889,
297,
288,
1504,
1524,
355,
661,
344,
297,
1709,
14,
4378,
8,
2495,
63,
3966,
29,
549,
12,
5062,
63,
498,
29,
549,
12,
8437,
29,
797,
12,
3376,
63,
354,
534,
998,
3855,
355,
661,
1301,
63,
344,
297,
1709,
14,
3901,
4000,
355,
661,
2502,
1296,
297,
1709,
14,
2183,
8,
988,
63,
1267,
29,
1840,
1826,
355,
661,
21118,
63,
2502,
297,
1709,
14,
2183,
8,
988,
63,
1267,
29,
1840,
12,
2973,
29,
549,
1826,
355,
661,
2834,
63,
13374,
297,
1709,
14,
15975,
8,
6355,
63,
10696,
29,
709,
12,
1390,
63,
7022,
29,
845,
12,
2973,
29,
549,
1826,
355,
661,
6136,
63,
13374,
297,
1709,
14,
15975,
8,
6355,
63,
10696,
29,
709,
12,
1390,
63,
7022,
29,
845,
12,
2973,
29,
549,
1826,
355,
661,
396,
63,
13374,
297,
1709,
14,
15975,
8,
6355,
63,
10696,
29,
709,
12,
1390,
63,
7022,
29,
845,
12,
2973,
29,
549,
1826,
355,
661,
396,
63,
3008,
297,
1709,
14,
15975,
8,
6355,
63,
10696,
29,
17,
12,
1390,
63,
7022,
29,
18,
12,
2973,
29,
549,
1826,
355,
661,
5064,
63,
602,
297,
1709,
14,
4626,
8,
885,
29,
1176,
14,
1208,
14,
7145,
14,
2131,
1826,
355,
661,
1205,
297,
1709,
14,
15975,
8,
6355,
63,
10696,
29,
17,
12,
849,
29,
16,
14,
16,
12,
1390,
63,
7022,
29,
18,
1826,
355,
661,
751,
297,
1709,
14,
3190,
8,
265,
63,
1807,
29,
1176,
14,
697,
14,
992,
14,
14281,
14,
10855,
12,
370,
29,
1751,
14,
5580,
63,
3791,
63,
11429,
1826,
288,
2156,
267,
2318,
272,
1622,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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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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
] |
senthil10/genologics
|
examples/get_projects.py
|
6
|
1394
|
"""Python interface to GenoLogics LIMS via its REST API.
Usage example: Get some projects.
Per Kraulis, Science for Life Laboratory, Stockholm, Sweden.
"""
import codecs
from genologics.lims import *
# Login parameters for connecting to a LIMS instance.
from genologics.config import BASEURI, USERNAME, PASSWORD
# Create the LIMS interface instance, and check the connection and version.
lims = Lims(BASEURI, USERNAME, PASSWORD)
lims.check_version()
# Get the list of all projects.
projects = lims.get_projects()
print len(projects), 'projects in total'
# Get the list of all projects opened since May 30th 2012.
day = '2012-05-30'
projects = lims.get_projects(open_date=day)
print len(projects), 'projects opened since', day
# Get the project with the specified LIMS id, and print some info.
project = Project(lims, id='P193')
print project, project.name, project.open_date, project.close_date
print ' UDFs:'
for key, value in project.udf.items():
if isinstance(value, unicode):
value = codecs.encode(value, 'UTF-8')
print ' ', key, '=', value
udt = project.udt
print ' UDT:', udt.udt
for key, value in udt.items():
if isinstance(value, unicode):
value = codecs.encode(value, 'UTF-8')
print ' ', key, '=', value
print ' files:'
for file in project.files:
print file.id
print file.content_location
print file.original_location
|
mit
|
[
624,
4718,
3217,
370,
18870,
79,
2445,
2932,
491,
1469,
51,
4799,
2399,
14880,
3261,
14,
199,
199,
7692,
2893,
26,
2372,
2005,
11336,
14,
4388,
199,
2623,
1804,
345,
13987,
83,
12,
27491,
367,
491,
16839,
16871,
31671,
12,
28406,
24588,
77,
12,
428,
1129,
848,
14,
199,
624,
199,
199,
646,
6010,
199,
199,
504,
3805,
79,
793,
2932,
14,
31689,
492,
627,
199,
199,
3,
16430,
2633,
367,
18170,
370,
282,
491,
1469,
51,
1256,
14,
199,
504,
3805,
79,
793,
2932,
14,
888,
492,
19721,
7639,
12,
13044,
2339,
12,
21705,
5172,
199,
199,
3,
2790,
314,
491,
1469,
51,
3217,
1256,
12,
436,
1104,
314,
1950,
436,
1015,
14,
199,
31689,
275,
491,
11171,
8,
5825,
7639,
12,
13044,
2339,
12,
21705,
5172,
9,
199,
31689,
14,
1074,
63,
1023,
342,
199,
199,
3,
2372,
314,
769,
402,
1006,
11336,
14,
199,
6776,
275,
1212,
706,
14,
362,
63,
6776,
342,
199,
1361,
822,
8,
6776,
395,
283,
6776,
315,
3141,
7,
199,
199,
3,
2372,
314,
769,
402,
1006,
11336,
12123,
3967,
10162,
4233,
273,
6029,
14,
199,
2977,
275,
283,
7409,
13,
1717,
13,
1216,
7,
199,
6776,
275,
1212,
706,
14,
362,
63,
6776,
8,
1490,
63,
602,
29,
2977,
9,
199,
1361,
822,
8,
6776,
395,
283,
6776,
12123,
3967,
297,
5382,
199,
199,
3,
2372,
314,
2199,
543,
314,
2013,
491,
1469,
51,
1305,
12,
436,
870,
2005,
2256,
14,
199,
1715,
275,
7290,
8,
31689,
12,
1305,
534,
48,
13015,
358,
199,
1361,
2199,
12,
2199,
14,
354,
12,
2199,
14,
1490,
63,
602,
12,
2199,
14,
1600,
63,
602,
199,
199,
1361,
283,
259,
738,
3888,
83,
4881,
199,
509,
790,
12,
574,
315,
2199,
14,
10031,
14,
1744,
837,
272,
340,
1228,
8,
585,
12,
2649,
304,
267,
574,
275,
6010,
14,
2143,
8,
585,
12,
283,
6610,
13,
24,
358,
272,
870,
283,
1656,
790,
12,
6291,
574,
199,
199,
1181,
84,
275,
2199,
14,
1181,
84,
199,
1361,
283,
259,
738,
7438,
6536,
399,
3583,
14,
1181,
84,
199,
509,
790,
12,
574,
315,
399,
3583,
14,
1744,
837,
272,
340,
1228,
8,
585,
12,
2649,
304,
267,
574,
275,
6010,
14,
2143,
8,
585,
12,
283,
6610,
13,
24,
358,
272,
870,
283,
1656,
790,
12,
6291,
574,
199,
199,
1361,
283,
259,
1584,
4881,
199,
509,
570,
315,
2199,
14,
1725,
26,
272,
870,
570,
14,
344,
272,
870,
570,
14,
1317,
63,
1985,
272,
870,
570,
14,
5043,
63,
1985,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
4718,
3217,
370,
18870,
79,
2445,
2932,
491,
1469,
51,
4799,
2399,
14880,
3261,
14,
199,
199,
7692,
2893,
26,
2372,
2005,
11336,
14,
4388,
199,
2623,
1804,
345,
13987,
83,
12,
27491,
367,
491,
16839,
16871,
31671,
12,
28406,
24588,
77,
12,
428,
1129,
848,
14,
199,
624,
199,
199,
646,
6010,
199,
199,
504,
3805,
79,
793,
2932,
14,
31689,
492,
627,
199,
199,
3,
16430,
2633,
367,
18170,
370,
282,
491,
1469,
51,
1256,
14,
199,
504,
3805,
79,
793,
2932,
14,
888,
492,
19721,
7639,
12,
13044,
2339,
12,
21705,
5172,
199,
199,
3,
2790,
314,
491,
1469,
51,
3217,
1256,
12,
436,
1104,
314,
1950,
436,
1015,
14,
199,
31689,
275,
491,
11171,
8,
5825,
7639,
12,
13044,
2339,
12,
21705,
5172,
9,
199,
31689,
14,
1074,
63,
1023,
342,
199,
199,
3,
2372,
314,
769,
402,
1006,
11336,
14,
199,
6776,
275,
1212,
706,
14,
362,
63,
6776,
342,
199,
1361,
822,
8,
6776,
395,
283,
6776,
315,
3141,
7,
199,
199,
3,
2372,
314,
769,
402,
1006,
11336,
12123,
3967,
10162,
4233,
273,
6029,
14,
199,
2977,
275,
283,
7409,
13,
1717,
13,
1216,
7,
199,
6776,
275,
1212,
706,
14,
362,
63,
6776,
8,
1490,
63,
602,
29,
2977,
9,
199,
1361,
822,
8,
6776,
395,
283,
6776,
12123,
3967,
297,
5382,
199,
199,
3,
2372,
314,
2199,
543,
314,
2013,
491,
1469,
51,
1305,
12,
436,
870,
2005,
2256,
14,
199,
1715,
275,
7290,
8,
31689,
12,
1305,
534,
48,
13015,
358,
199,
1361,
2199,
12,
2199,
14,
354,
12,
2199,
14,
1490,
63,
602,
12,
2199,
14,
1600,
63,
602,
199,
199,
1361,
283,
259,
738,
3888,
83,
4881,
199,
509,
790,
12,
574,
315,
2199,
14,
10031,
14,
1744,
837,
272,
340,
1228,
8,
585,
12,
2649,
304,
267,
574,
275,
6010,
14,
2143,
8,
585,
12,
283,
6610,
13,
24,
358,
272,
870,
283,
1656,
790,
12,
6291,
574,
199,
199,
1181,
84,
275,
2199,
14,
1181,
84,
199,
1361,
283,
259,
738,
7438,
6536,
399,
3583,
14,
1181,
84,
199,
509,
790,
12,
574,
315,
399,
3583,
14,
1744,
837,
272,
340,
1228,
8,
585,
12,
2649,
304,
267,
574,
275,
6010,
14,
2143,
8,
585,
12,
283,
6610,
13,
24,
358,
272,
870,
283,
1656,
790,
12,
6291,
574,
199,
199,
1361,
283,
259,
1584,
4881,
199,
509,
570,
315,
2199,
14,
1725,
26,
272,
870,
570,
14,
344,
272,
870,
570,
14,
1317,
63,
1985,
272,
870,
570,
14,
5043,
63,
1985,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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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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
] |
wang1352083/pythontool
|
python-2.7.12-lib/lib2to3/fixes/fix_itertools_imports.py
|
325
|
2094
|
""" Fixer for imports of itertools.(imap|ifilter|izip|ifilterfalse) """
# Local imports
from lib2to3 import fixer_base
from lib2to3.fixer_util import BlankLine, syms, token
class FixItertoolsImports(fixer_base.BaseFix):
BM_compatible = True
PATTERN = """
import_from< 'from' 'itertools' 'import' imports=any >
""" %(locals())
def transform(self, node, results):
imports = results['imports']
if imports.type == syms.import_as_name or not imports.children:
children = [imports]
else:
children = imports.children
for child in children[::2]:
if child.type == token.NAME:
member = child.value
name_node = child
elif child.type == token.STAR:
# Just leave the import as is.
return
else:
assert child.type == syms.import_as_name
name_node = child.children[0]
member_name = name_node.value
if member_name in (u'imap', u'izip', u'ifilter'):
child.value = None
child.remove()
elif member_name in (u'ifilterfalse', u'izip_longest'):
node.changed()
name_node.value = (u'filterfalse' if member_name[1] == u'f'
else u'zip_longest')
# Make sure the import statement is still sane
children = imports.children[:] or [imports]
remove_comma = True
for child in children:
if remove_comma and child.type == token.COMMA:
child.remove()
else:
remove_comma ^= True
while children and children[-1].type == token.COMMA:
children.pop().remove()
# If there are no imports left, just get rid of the entire statement
if (not (imports.children or getattr(imports, 'value', None)) or
imports.parent is None):
p = node.prefix
node = BlankLine()
node.prefix = p
return node
|
mit
|
[
624,
14811,
281,
367,
8925,
402,
7975,
14,
8,
15311,
92,
73,
1541,
92,
565,
711,
92,
73,
1541,
3910,
9,
408,
199,
199,
3,
10111,
8925,
199,
504,
1973,
18,
475,
19,
492,
24739,
63,
1095,
199,
504,
1973,
18,
475,
19,
14,
25973,
63,
1974,
492,
699,
1983,
3049,
12,
25308,
12,
1526,
421,
199,
533,
14811,
3315,
2537,
32447,
8,
25973,
63,
1095,
14,
1563,
11985,
304,
272,
699,
45,
63,
6490,
275,
715,
272,
31467,
7689,
275,
408,
1598,
492,
63,
504,
28,
283,
504,
7,
283,
17691,
7,
283,
646,
7,
8925,
29,
1629,
690,
1598,
408,
2818,
9350,
1012,
339,
347,
5793,
8,
277,
12,
1031,
12,
2058,
304,
267,
8925,
275,
2058,
459,
12775,
418,
267,
340,
8925,
14,
466,
508,
25308,
14,
646,
63,
305,
63,
354,
503,
440,
8925,
14,
3223,
26,
288,
4978,
275,
359,
12775,
61,
267,
587,
26,
288,
4978,
275,
8925,
14,
3223,
267,
367,
1982,
315,
4978,
10345,
18,
2189,
288,
340,
1982,
14,
466,
508,
1526,
14,
2339,
26,
355,
3653,
275,
1982,
14,
585,
355,
536,
63,
932,
275,
1982,
288,
916,
1982,
14,
466,
508,
1526,
14,
30302,
26,
355,
327,
13870,
10137,
314,
492,
465,
365,
14,
355,
372,
288,
587,
26,
355,
702,
1982,
14,
466,
508,
25308,
14,
646,
63,
305,
63,
354,
355,
536,
63,
932,
275,
1982,
14,
3223,
59,
16,
61,
288,
3653,
63,
354,
275,
536,
63,
932,
14,
585,
288,
340,
3653,
63,
354,
315,
334,
85,
7,
15311,
297,
399,
7,
565,
711,
297,
399,
7,
73,
1541,
735,
355,
1982,
14,
585,
275,
488,
355,
1982,
14,
2168,
342,
288,
916,
3653,
63,
354,
315,
334,
85,
7,
73,
1541,
3910,
297,
399,
7,
565,
711,
63,
20820,
735,
355,
1031,
14,
2489,
342,
355,
536,
63,
932,
14,
585,
275,
334,
85,
7,
1541,
3910,
7,
340,
3653,
63,
354,
59,
17,
61,
508,
399,
7,
70,
7,
3521,
587,
399,
7,
3065,
63,
20820,
358,
398,
327,
4155,
3238,
314,
492,
5164,
365,
5139,
31648,
267,
4978,
275,
8925,
14,
3223,
5873,
503,
359,
12775,
61,
267,
2813,
63,
13184,
275,
715,
267,
367,
1982,
315,
4978,
26,
288,
340,
2813,
63,
13184,
436,
1982,
14,
466,
508,
1526,
14,
11265,
2054,
26,
355,
1982,
14,
2168,
342,
288,
587,
26,
355,
2813,
63,
13184,
31753,
715,
398,
1830,
4978,
436,
4978,
1988,
17,
1055,
466,
508,
1526,
14,
11265,
2054,
26,
288,
4978,
14,
1935,
1252,
2168,
342,
398,
327,
982,
2337,
787,
949,
8925,
3602,
12,
2951,
664,
16146,
402,
314,
8039,
5164,
267,
340,
334,
1397,
334,
12775,
14,
3223,
503,
2519,
8,
12775,
12,
283,
585,
297,
488,
430,
503,
288,
8925,
14,
1708,
365,
488,
304,
288,
299,
275,
1031,
14,
1861,
288,
1031,
275,
699,
1983,
3049,
342,
288,
1031,
14,
1861,
275,
299,
288,
372,
1031,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
14811,
281,
367,
8925,
402,
7975,
14,
8,
15311,
92,
73,
1541,
92,
565,
711,
92,
73,
1541,
3910,
9,
408,
199,
199,
3,
10111,
8925,
199,
504,
1973,
18,
475,
19,
492,
24739,
63,
1095,
199,
504,
1973,
18,
475,
19,
14,
25973,
63,
1974,
492,
699,
1983,
3049,
12,
25308,
12,
1526,
421,
199,
533,
14811,
3315,
2537,
32447,
8,
25973,
63,
1095,
14,
1563,
11985,
304,
272,
699,
45,
63,
6490,
275,
715,
272,
31467,
7689,
275,
408,
1598,
492,
63,
504,
28,
283,
504,
7,
283,
17691,
7,
283,
646,
7,
8925,
29,
1629,
690,
1598,
408,
2818,
9350,
1012,
339,
347,
5793,
8,
277,
12,
1031,
12,
2058,
304,
267,
8925,
275,
2058,
459,
12775,
418,
267,
340,
8925,
14,
466,
508,
25308,
14,
646,
63,
305,
63,
354,
503,
440,
8925,
14,
3223,
26,
288,
4978,
275,
359,
12775,
61,
267,
587,
26,
288,
4978,
275,
8925,
14,
3223,
267,
367,
1982,
315,
4978,
10345,
18,
2189,
288,
340,
1982,
14,
466,
508,
1526,
14,
2339,
26,
355,
3653,
275,
1982,
14,
585,
355,
536,
63,
932,
275,
1982,
288,
916,
1982,
14,
466,
508,
1526,
14,
30302,
26,
355,
327,
13870,
10137,
314,
492,
465,
365,
14,
355,
372,
288,
587,
26,
355,
702,
1982,
14,
466,
508,
25308,
14,
646,
63,
305,
63,
354,
355,
536,
63,
932,
275,
1982,
14,
3223,
59,
16,
61,
288,
3653,
63,
354,
275,
536,
63,
932,
14,
585,
288,
340,
3653,
63,
354,
315,
334,
85,
7,
15311,
297,
399,
7,
565,
711,
297,
399,
7,
73,
1541,
735,
355,
1982,
14,
585,
275,
488,
355,
1982,
14,
2168,
342,
288,
916,
3653,
63,
354,
315,
334,
85,
7,
73,
1541,
3910,
297,
399,
7,
565,
711,
63,
20820,
735,
355,
1031,
14,
2489,
342,
355,
536,
63,
932,
14,
585,
275,
334,
85,
7,
1541,
3910,
7,
340,
3653,
63,
354,
59,
17,
61,
508,
399,
7,
70,
7,
3521,
587,
399,
7,
3065,
63,
20820,
358,
398,
327,
4155,
3238,
314,
492,
5164,
365,
5139,
31648,
267,
4978,
275,
8925,
14,
3223,
5873,
503,
359,
12775,
61,
267,
2813,
63,
13184,
275,
715,
267,
367,
1982,
315,
4978,
26,
288,
340,
2813,
63,
13184,
436,
1982,
14,
466,
508,
1526,
14,
11265,
2054,
26,
355,
1982,
14,
2168,
342,
288,
587,
26,
355,
2813,
63,
13184,
31753,
715,
398,
1830,
4978,
436,
4978,
1988,
17,
1055,
466,
508,
1526,
14,
11265,
2054,
26,
288,
4978,
14,
1935,
1252,
2168,
342,
398,
327,
982,
2337,
787,
949,
8925,
3602,
12,
2951,
664,
16146,
402,
314,
8039,
5164,
267,
340,
334,
1397,
334,
12775,
14,
3223,
503,
2519,
8,
12775,
12,
283,
585,
297,
488,
430,
503,
288,
8925,
14,
1708,
365,
488,
304,
288,
299,
275,
1031,
14,
1861,
288,
1031,
275,
699,
1983,
3049,
342,
288,
1031,
14,
1861,
275,
299,
288,
372,
1031,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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
] |
yuezh/azure-linux-extensions
|
OSPatching/check.py
|
16
|
1630
|
#!/usr/bin/python
#
# OSPatching extension
#
# Copyright 2014 Microsoft Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Requires Python 2.4+
import os
import sys
import datetime
def main():
intervalOfWeeks = int(sys.argv[1])
if intervalOfWeeks == 1:
sys.exit(0)
history_scheduled = os.path.join(os.path.dirname(sys.argv[0]),
'scheduled/history')
today = datetime.date.today()
today_dayOfWeek = today.strftime('%a')
last_scheduled_date = None
with open(history_scheduled) as f:
lines = f.readlines()
lines.reverse()
for line in lines:
line = line.strip()
if line.endswith(today_dayOfWeek):
last_scheduled_date = datetime.datetime.strptime(line,
'%Y-%m-%d %a')
break
if (last_scheduled_date is not None and last_scheduled_date.date() +
datetime.timedelta(days=intervalOfWeeks*7) > today):
sys.exit(1)
else:
sys.exit(0)
if __name__ == '__main__':
main()
|
apache-2.0
|
[
3381,
2647,
15,
1393,
15,
1548,
199,
3,
199,
3,
4403,
11173,
316,
3329,
199,
3,
199,
3,
1898,
6927,
15332,
11098,
199,
3,
199,
3,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
199,
3,
1265,
1443,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
199,
3,
2047,
1443,
3332,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
258,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
199,
3,
2428,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
199,
3,
1666,
314,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
199,
3,
4204,
1334,
314,
844,
14,
199,
3,
199,
3,
15127,
2018,
499,
14,
20,
11,
199,
199,
646,
747,
199,
646,
984,
199,
646,
2197,
421,
199,
318,
2446,
837,
272,
6252,
3466,
20995,
83,
275,
1109,
8,
1274,
14,
3020,
59,
17,
566,
272,
340,
6252,
3466,
20995,
83,
508,
413,
26,
267,
984,
14,
2224,
8,
16,
9,
339,
7994,
63,
19274,
275,
747,
14,
515,
14,
904,
8,
736,
14,
515,
14,
3475,
8,
1274,
14,
3020,
59,
16,
2522,
3660,
283,
19274,
15,
5570,
358,
272,
11168,
275,
2197,
14,
602,
14,
8136,
342,
272,
11168,
63,
2977,
3466,
20995,
275,
11168,
14,
6205,
3508,
65,
358,
339,
2061,
63,
19274,
63,
602,
275,
488,
272,
543,
1551,
8,
5570,
63,
19274,
9,
465,
289,
26,
267,
2385,
275,
289,
14,
9684,
342,
267,
2385,
14,
4471,
342,
267,
367,
1004,
315,
2385,
26,
288,
1004,
275,
1004,
14,
1913,
342,
288,
340,
1004,
14,
4130,
8,
8136,
63,
2977,
3466,
20995,
304,
355,
2061,
63,
19274,
63,
602,
275,
2197,
14,
2083,
14,
9866,
8,
604,
12,
6684,
1543,
57,
3295,
77,
3295,
68,
450,
65,
358,
355,
2059,
339,
340,
334,
2019,
63,
19274,
63,
602,
365,
440,
488,
436,
2061,
63,
19274,
63,
602,
14,
602,
342,
435,
288,
2197,
14,
7473,
8,
4899,
29,
4284,
3466,
20995,
83,
10,
23,
9,
690,
11168,
304,
267,
984,
14,
2224,
8,
17,
9,
272,
587,
26,
267,
984,
14,
2224,
8,
16,
9,
199,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
272,
2446,
342,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,
4403,
11173,
316,
3329,
199,
3,
199,
3,
1898,
6927,
15332,
11098,
199,
3,
199,
3,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
199,
3,
1265,
1443,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
199,
3,
2047,
1443,
3332,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
258,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
199,
3,
2428,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
199,
3,
1666,
314,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
199,
3,
4204,
1334,
314,
844,
14,
199,
3,
199,
3,
15127,
2018,
499,
14,
20,
11,
199,
199,
646,
747,
199,
646,
984,
199,
646,
2197,
421,
199,
318,
2446,
837,
272,
6252,
3466,
20995,
83,
275,
1109,
8,
1274,
14,
3020,
59,
17,
566,
272,
340,
6252,
3466,
20995,
83,
508,
413,
26,
267,
984,
14,
2224,
8,
16,
9,
339,
7994,
63,
19274,
275,
747,
14,
515,
14,
904,
8,
736,
14,
515,
14,
3475,
8,
1274,
14,
3020,
59,
16,
2522,
3660,
283,
19274,
15,
5570,
358,
272,
11168,
275,
2197,
14,
602,
14,
8136,
342,
272,
11168,
63,
2977,
3466,
20995,
275,
11168,
14,
6205,
3508,
65,
358,
339,
2061,
63,
19274,
63,
602,
275,
488,
272,
543,
1551,
8,
5570,
63,
19274,
9,
465,
289,
26,
267,
2385,
275,
289,
14,
9684,
342,
267,
2385,
14,
4471,
342,
267,
367,
1004,
315,
2385,
26,
288,
1004,
275,
1004,
14,
1913,
342,
288,
340,
1004,
14,
4130,
8,
8136,
63,
2977,
3466,
20995,
304,
355,
2061,
63,
19274,
63,
602,
275,
2197,
14,
2083,
14,
9866,
8,
604,
12,
6684,
1543,
57,
3295,
77,
3295,
68,
450,
65,
358,
355,
2059,
339,
340,
334,
2019,
63,
19274,
63,
602,
365,
440,
488,
436,
2061,
63,
19274,
63,
602,
14,
602,
342,
435,
288,
2197,
14,
7473,
8,
4899,
29,
4284,
3466,
20995,
83,
10,
23,
9,
690,
11168,
304,
267,
984,
14,
2224,
8,
17,
9,
272,
587,
26,
267,
984,
14,
2224,
8,
16,
9,
199,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
272,
2446,
342,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,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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
] |
AutoQuad/mavlink
|
pymavlink/tools/mavflightmodes.py
|
45
|
2736
|
#!/usr/bin/env python
'''
show changes in flight modes
'''
import sys, time, datetime, os
from argparse import ArgumentParser
parser = ArgumentParser(description=__doc__)
parser.add_argument("logs", metavar="LOG", nargs="+")
args = parser.parse_args()
from pymavlink import mavutil
def flight_modes(logfile):
'''show flight modes for a log file'''
print("Processing log %s" % filename)
mlog = mavutil.mavlink_connection(filename)
mode = ""
previous_mode = ""
mode_start_timestamp = -1
time_in_mode = {}
previous_percent = -1
seconds_per_percent = -1
filesize = os.path.getsize(filename)
while True:
m = mlog.recv_match(type=['SYS_STATUS','HEARTBEAT','MODE'],
condition='MAV.flightmode!="%s"' % mlog.flightmode)
if m is None:
break
print('%s MAV.flightmode=%-12s (MAV.timestamp=%u %u%%)' % (
time.asctime(time.localtime(m._timestamp)),
mlog.flightmode,
m._timestamp, mlog.percent))
mode = mlog.flightmode
if (mode not in time_in_mode):
time_in_mode[mode] = 0
if (mode_start_timestamp == -1):
mode_start_timestamp = m._timestamp
elif (previous_mode != "" and previous_mode != mode):
time_in_mode[previous_mode] = time_in_mode[previous_mode] + (m._timestamp - mode_start_timestamp)
#figure out how many seconds per percentage point so I can
#caculate how many seconds for the final mode
if (seconds_per_percent == -1 and previous_percent != -1
and previous_percent != mlog.percent):
seconds_per_percent = (m._timestamp - mode_start_timestamp) / (mlog.percent - previous_percent)
mode_start_timestamp = m._timestamp
previous_mode = mode
previous_percent = mlog.percent
#put a whitespace line before the per-mode report
print()
print("Time per mode:")
#need to get the time in the final mode
if (seconds_per_percent != -1):
seconds_remaining = (100.0 - previous_percent) * seconds_per_percent
time_in_mode[previous_mode] = time_in_mode[previous_mode] + seconds_remaining
total_flight_time = 0
for key, value in time_in_mode.iteritems():
total_flight_time = total_flight_time + value
for key, value in time_in_mode.iteritems():
print('%-12s %s %.2f%%' % (key, str(datetime.timedelta(seconds=int(value))), (value / total_flight_time) * 100.0))
else:
#can't print time in mode if only one mode during flight
print(previous_mode, " 100% of flight time")
for filename in args.logs:
flight_modes(filename)
|
lgpl-3.0
|
[
3381,
2647,
15,
1393,
15,
1813,
2366,
199,
199,
2344,
199,
2384,
4493,
315,
289,
4040,
12404,
199,
2344,
199,
199,
646,
984,
12,
900,
12,
2197,
12,
747,
199,
199,
504,
7534,
492,
27615,
199,
2087,
275,
27615,
8,
1802,
18971,
1301,
3368,
199,
2087,
14,
525,
63,
2094,
480,
7270,
401,
8214,
628,
4947,
401,
9237,
16368,
531,
199,
199,
589,
275,
1798,
14,
1122,
63,
589,
342,
199,
199,
504,
1134,
24610,
492,
11456,
1974,
421,
199,
318,
289,
4040,
63,
10433,
8,
12804,
304,
272,
1449,
2384,
289,
4040,
12404,
367,
282,
943,
570,
2344,
272,
870,
480,
9589,
943,
450,
83,
2,
450,
1788,
9,
272,
333,
793,
275,
11456,
1974,
14,
24610,
63,
2105,
8,
1501,
9,
339,
818,
275,
3087,
272,
4136,
63,
632,
275,
3087,
272,
818,
63,
928,
63,
3954,
275,
446,
17,
272,
900,
63,
262,
63,
632,
275,
1052,
272,
4136,
63,
7045,
275,
446,
17,
272,
4696,
63,
529,
63,
7045,
275,
446,
17,
339,
23858,
275,
747,
14,
515,
14,
20733,
8,
1501,
9,
339,
1830,
715,
26,
267,
333,
275,
333,
793,
14,
7637,
63,
1431,
8,
466,
2968,
13326,
63,
6305,
1673,
1645,
2294,
6773,
619,
1673,
6963,
995,
1169,
5558,
534,
19273,
14,
28807,
632,
1,
5961,
83,
4507,
450,
333,
793,
14,
28807,
632,
9,
267,
340,
333,
365,
488,
26,
288,
2059,
267,
870,
3508,
83,
20553,
14,
28807,
632,
2458,
13,
713,
83,
334,
19273,
14,
3954,
2458,
85,
450,
85,
8530,
3171,
450,
334,
288,
900,
14,
18331,
8,
521,
14,
15198,
8,
77,
423,
3954,
1826,
288,
333,
793,
14,
28807,
632,
12,
288,
333,
423,
3954,
12,
333,
793,
14,
7045,
430,
398,
818,
275,
333,
793,
14,
28807,
632,
267,
340,
334,
632,
440,
315,
900,
63,
262,
63,
632,
304,
288,
900,
63,
262,
63,
632,
59,
632,
61,
275,
378,
398,
340,
334,
632,
63,
928,
63,
3954,
508,
446,
17,
304,
288,
818,
63,
928,
63,
3954,
275,
333,
423,
3954,
267,
916,
334,
6352,
63,
632,
1137,
3087,
436,
4136,
63,
632,
1137,
818,
304,
288,
900,
63,
262,
63,
632,
59,
6352,
63,
632,
61,
275,
900,
63,
262,
63,
632,
59,
6352,
63,
632,
61,
435,
334,
77,
423,
3954,
446,
818,
63,
928,
63,
3954,
9,
953,
327,
8941,
734,
4212,
5002,
4696,
1126,
16327,
2376,
880,
473,
883,
288,
327,
11055,
5434,
4212,
5002,
4696,
367,
314,
4242,
818,
288,
340,
334,
4515,
63,
529,
63,
7045,
508,
446,
17,
436,
4136,
63,
7045,
1137,
446,
17,
490,
436,
4136,
63,
7045,
1137,
333,
793,
14,
7045,
304,
355,
4696,
63,
529,
63,
7045,
275,
334,
77,
423,
3954,
446,
818,
63,
928,
63,
3954,
9,
1182,
334,
77,
793,
14,
7045,
446,
4136,
63,
7045,
9,
953,
818,
63,
928,
63,
3954,
275,
333,
423,
3954,
398,
4136,
63,
632,
275,
818,
267,
4136,
63,
7045,
275,
333,
793,
14,
7045,
339,
327,
524,
282,
8139,
1004,
2544,
314,
1126,
13,
632,
3622,
272,
870,
342,
272,
870,
480,
1366,
1126,
818,
9107,
339,
327,
9321,
370,
664,
314,
900,
315,
314,
4242,
818,
272,
340,
334,
4515,
63,
529,
63,
7045,
1137,
446,
17,
304,
267,
4696,
63,
11266,
275,
334,
1960,
14,
16,
446,
4136,
63,
7045,
9,
627,
4696,
63,
529,
63,
7045,
398,
900,
63,
262,
63,
632,
59,
6352,
63,
632,
61,
275,
900,
63,
262,
63,
632,
59,
6352,
63,
632,
61,
435,
4696,
63,
11266,
398,
3141,
63,
28807,
63,
521,
275,
378,
267,
367,
790,
12,
574,
315,
900,
63,
262,
63,
632,
14,
4611,
837,
288,
3141,
63,
28807,
63,
521,
275,
3141,
63,
28807,
63,
521,
435,
574,
398,
367,
790,
12,
574,
315,
900,
63,
262,
63,
632,
14,
4611,
837,
288,
870,
3508,
13,
713,
83,
450,
83,
10536,
18,
70,
8530,
7,
450,
334,
498,
12,
620,
8,
2083,
14,
7473,
8,
4515,
29,
442,
8,
585,
11508,
334,
585,
1182,
3141,
63,
28807,
63,
521,
9,
627,
2948,
14,
16,
430,
272,
587,
26,
267,
327,
2425,
1133,
870,
900,
315,
818,
340,
1454,
1373,
818,
5309,
289,
4040,
267,
870,
8,
6352,
63,
632,
12,
298,
2948,
5,
402,
289,
4040,
900,
531,
199,
199,
509,
1788,
315,
1249,
14,
7270,
26,
272,
289,
4040,
63,
10433,
8,
1501,
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
] |
[
2647,
15,
1393,
15,
1813,
2366,
199,
199,
2344,
199,
2384,
4493,
315,
289,
4040,
12404,
199,
2344,
199,
199,
646,
984,
12,
900,
12,
2197,
12,
747,
199,
199,
504,
7534,
492,
27615,
199,
2087,
275,
27615,
8,
1802,
18971,
1301,
3368,
199,
2087,
14,
525,
63,
2094,
480,
7270,
401,
8214,
628,
4947,
401,
9237,
16368,
531,
199,
199,
589,
275,
1798,
14,
1122,
63,
589,
342,
199,
199,
504,
1134,
24610,
492,
11456,
1974,
421,
199,
318,
289,
4040,
63,
10433,
8,
12804,
304,
272,
1449,
2384,
289,
4040,
12404,
367,
282,
943,
570,
2344,
272,
870,
480,
9589,
943,
450,
83,
2,
450,
1788,
9,
272,
333,
793,
275,
11456,
1974,
14,
24610,
63,
2105,
8,
1501,
9,
339,
818,
275,
3087,
272,
4136,
63,
632,
275,
3087,
272,
818,
63,
928,
63,
3954,
275,
446,
17,
272,
900,
63,
262,
63,
632,
275,
1052,
272,
4136,
63,
7045,
275,
446,
17,
272,
4696,
63,
529,
63,
7045,
275,
446,
17,
339,
23858,
275,
747,
14,
515,
14,
20733,
8,
1501,
9,
339,
1830,
715,
26,
267,
333,
275,
333,
793,
14,
7637,
63,
1431,
8,
466,
2968,
13326,
63,
6305,
1673,
1645,
2294,
6773,
619,
1673,
6963,
995,
1169,
5558,
534,
19273,
14,
28807,
632,
1,
5961,
83,
4507,
450,
333,
793,
14,
28807,
632,
9,
267,
340,
333,
365,
488,
26,
288,
2059,
267,
870,
3508,
83,
20553,
14,
28807,
632,
2458,
13,
713,
83,
334,
19273,
14,
3954,
2458,
85,
450,
85,
8530,
3171,
450,
334,
288,
900,
14,
18331,
8,
521,
14,
15198,
8,
77,
423,
3954,
1826,
288,
333,
793,
14,
28807,
632,
12,
288,
333,
423,
3954,
12,
333,
793,
14,
7045,
430,
398,
818,
275,
333,
793,
14,
28807,
632,
267,
340,
334,
632,
440,
315,
900,
63,
262,
63,
632,
304,
288,
900,
63,
262,
63,
632,
59,
632,
61,
275,
378,
398,
340,
334,
632,
63,
928,
63,
3954,
508,
446,
17,
304,
288,
818,
63,
928,
63,
3954,
275,
333,
423,
3954,
267,
916,
334,
6352,
63,
632,
1137,
3087,
436,
4136,
63,
632,
1137,
818,
304,
288,
900,
63,
262,
63,
632,
59,
6352,
63,
632,
61,
275,
900,
63,
262,
63,
632,
59,
6352,
63,
632,
61,
435,
334,
77,
423,
3954,
446,
818,
63,
928,
63,
3954,
9,
953,
327,
8941,
734,
4212,
5002,
4696,
1126,
16327,
2376,
880,
473,
883,
288,
327,
11055,
5434,
4212,
5002,
4696,
367,
314,
4242,
818,
288,
340,
334,
4515,
63,
529,
63,
7045,
508,
446,
17,
436,
4136,
63,
7045,
1137,
446,
17,
490,
436,
4136,
63,
7045,
1137,
333,
793,
14,
7045,
304,
355,
4696,
63,
529,
63,
7045,
275,
334,
77,
423,
3954,
446,
818,
63,
928,
63,
3954,
9,
1182,
334,
77,
793,
14,
7045,
446,
4136,
63,
7045,
9,
953,
818,
63,
928,
63,
3954,
275,
333,
423,
3954,
398,
4136,
63,
632,
275,
818,
267,
4136,
63,
7045,
275,
333,
793,
14,
7045,
339,
327,
524,
282,
8139,
1004,
2544,
314,
1126,
13,
632,
3622,
272,
870,
342,
272,
870,
480,
1366,
1126,
818,
9107,
339,
327,
9321,
370,
664,
314,
900,
315,
314,
4242,
818,
272,
340,
334,
4515,
63,
529,
63,
7045,
1137,
446,
17,
304,
267,
4696,
63,
11266,
275,
334,
1960,
14,
16,
446,
4136,
63,
7045,
9,
627,
4696,
63,
529,
63,
7045,
398,
900,
63,
262,
63,
632,
59,
6352,
63,
632,
61,
275,
900,
63,
262,
63,
632,
59,
6352,
63,
632,
61,
435,
4696,
63,
11266,
398,
3141,
63,
28807,
63,
521,
275,
378,
267,
367,
790,
12,
574,
315,
900,
63,
262,
63,
632,
14,
4611,
837,
288,
3141,
63,
28807,
63,
521,
275,
3141,
63,
28807,
63,
521,
435,
574,
398,
367,
790,
12,
574,
315,
900,
63,
262,
63,
632,
14,
4611,
837,
288,
870,
3508,
13,
713,
83,
450,
83,
10536,
18,
70,
8530,
7,
450,
334,
498,
12,
620,
8,
2083,
14,
7473,
8,
4515,
29,
442,
8,
585,
11508,
334,
585,
1182,
3141,
63,
28807,
63,
521,
9,
627,
2948,
14,
16,
430,
272,
587,
26,
267,
327,
2425,
1133,
870,
900,
315,
818,
340,
1454,
1373,
818,
5309,
289,
4040,
267,
870,
8,
6352,
63,
632,
12,
298,
2948,
5,
402,
289,
4040,
900,
531,
199,
199,
509,
1788,
315,
1249,
14,
7270,
26,
272,
289,
4040,
63,
10433,
8,
1501,
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,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
cmattoon/libforensics
|
code/lf/apps/msoffice/shared/consts.py
|
13
|
4030
|
# Copyright 2010 Michael Murr
#
# This file is part of LibForensics.
#
# LibForensics is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# LibForensics 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 LibForensics. If not, see <http://www.gnu.org/licenses/>.
"""Shared constants for various Microsoft Office products."""
__docformat__ = "restructuredtext en"
__all__ = [
"PIDSI_CODEPAGE", "PIDSI_TITLE", "PIDSI_SUBJECT", "PIDSI_AUTHOR",
"PIDSI_KEYWORDS", "PIDSI_COMMENTS", "PIDSI_TEMPLATE", "PIDSI_LAST_AUTHOR",
"PIDSI_REV_NUMBER", "PIDSI_EDIT_TIME", "PIDSI_LAST_PRINTED_TIME",
"PIDSI_CREATE_TIME", "PIDSI_SAVE_TIME", "PIDSI_PAGE_COUNT",
"PIDSI_WORD_COUNT", "PIDSI_CHAR_COUNT", "PIDSI_THUMBNAIL",
"PIDSI_APP_NAME", "PIDSI_DOC_SECURITY","PIDDSI_CODEPAGE",
"PIDDSI_CATEGORY", "PIDDSI_PRESFORMAT", "PIDDSI_BYTECOUNT",
"PIDDSI_LINECOUNT", "PIDDSI_PARACOUNT", "PIDDSI_SLIDECOUNT",
"PIDDSI_NOTECOUNT", "PIDDSI_HIDDENCOUNT", "PIDDSI_MMCLIPCOUNT",
"PIDDSI_SCALE", "PIDDSI_HEADINGPAIR", "PIDDSI_DOCPARTS", "PIDDSI_MANAGER",
"PIDDSI_COMPANY", "PIDDSI_LINKSDIRTY", "PIDDSI_CCHWITHSPACES",
"PIDDSI_SHAREDDOC", "PIDDSI_LINKBASE","PIDDSI_HLINKS",
"PIDDSI_HYPERLINKSCHANGED", "PIDDSI_VERSION", "PIDDSI_DIGSIG",
"PIDDSI_CONTENTTYPE", "PIDDSI_CONTENTSTATUS", "PIDDSI_LANGUAGE",
"PIDDSI_DOCVERSION",
"PIDSI", "PIDDSI", "SUMMARY_INFORMATION_NAME",
"DOC_SUMMARY_INFORMATION_NAME"
]
PIDSI_CODEPAGE = 1
PIDSI_TITLE = 2
PIDSI_SUBJECT = 3
PIDSI_AUTHOR = 4
PIDSI_KEYWORDS = 5
PIDSI_COMMENTS = 6
PIDSI_TEMPLATE = 7
PIDSI_LAST_AUTHOR = 8
PIDSI_REV_NUMBER = 9
PIDSI_EDIT_TIME = 0xA
PIDSI_LAST_PRINTED_TIME = 0xB
PIDSI_CREATE_TIME = 0xC
PIDSI_SAVE_TIME = 0xD
PIDSI_PAGE_COUNT = 0xE
PIDSI_WORD_COUNT = 0xF
PIDSI_CHAR_COUNT = 0x10
PIDSI_THUMBNAIL = 0x11
PIDSI_APP_NAME = 0x12
PIDSI_DOC_SECURITY = 0x13
PIDDSI_CODEPAGE = 1
PIDDSI_CATEGORY = 2
PIDDSI_PRESFORMAT = 3
PIDDSI_BYTECOUNT = 4
PIDDSI_LINECOUNT = 5
PIDDSI_PARACOUNT = 6
PIDDSI_SLIDECOUNT = 7
PIDDSI_NOTECOUNT = 8
PIDDSI_HIDDENCOUNT = 9
PIDDSI_MMCLIPCOUNT = 0xA
PIDDSI_SCALE = 0xB
PIDDSI_HEADINGPAIR = 0xC
PIDDSI_DOCPARTS = 0xD
PIDDSI_MANAGER = 0xE
PIDDSI_COMPANY = 0xF
PIDDSI_LINKSDIRTY = 0x10
PIDDSI_CCHWITHSPACES = 0x11
PIDDSI_SHAREDDOC = 0x13
PIDDSI_LINKBASE = 0x14
PIDDSI_HLINKS = 0x15
PIDDSI_HYPERLINKSCHANGED = 0x16
PIDDSI_VERSION = 0x17
PIDDSI_DIGSIG = 0x18
PIDDSI_CONTENTTYPE = 0x1A
PIDDSI_CONTENTSTATUS = 0x1B
PIDDSI_LANGUAGE = 0x1C
PIDDSI_DOCVERSION = 0x1D
class PIDSI():
CODEPAGE = 1
TITLE = 2
SUBJECT = 3
AUTHOR = 4
KEYWORDS = 5
COMMENTS = 6
TEMPLATE = 7
LAST_AUTHOR = 8
REVNUMBER = 9
EDIT_TIME = 0xA
LAST_PRINTED_TIME = 0xB
CREATE_TIME = 0xC
SAVE_TIME = 0xD
PAGE_COUNT = 0xE
WORD_COUNT = 0xF
CHAR_COUNT = 0x10
THUMBNAIL = 0x11
APPNAME = 0x12
DOC_SECURITY = 0x13
# end class PIDSI
class PIDDSI():
CODEPAGE = 1
CATEGORY = 2
PRESFORMAT = 3
BYTECOUNT = 4
LINECOUNT = 5
PARACOUNT = 6
SLIDECOUNT = 7
NOTECOUNT = 8
HIDDENCOUNT = 9
MMCLIPCOUNT = 0xA
SCALE = 0xB
HEADINGPAIR = 0xC
DOCPARTS = 0xD
MANAGER = 0xE
COMPANY = 0xF
LINKSDIRTY = 0x10
CCHWITHSPACES = 0x11
SHAREDDOC = 0x13
LINKBASE = 0x14
HLINKS = 0x15
HYPERLINKSCHANGED = 0x16
VERSION = 0x17
DIGSIG = 0x18
CONTENTTYPE = 0x1A
CONTENTSTATUS = 0x1B
LANGUAGE = 0x1C
DOCVERSION = 0x1D
# end class PIDDSI
SUMMARY_INFORMATION_NAME = "\x05SummaryInformation"
DOC_SUMMARY_INFORMATION_NAME = "\x05DocumentSummaryInformation"
|
gpl-3.0
|
[
3,
1898,
7129,
16922,
603,
300,
82,
199,
3,
199,
3,
961,
570,
365,
1777,
402,
8003,
13099,
78,
17378,
14,
199,
3,
199,
3,
8003,
13099,
78,
17378,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
652,
1334,
314,
2895,
402,
314,
1664,
6401,
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,
8003,
13099,
78,
17378,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
199,
3,
1664,
6401,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
6401,
1696,
1684,
844,
199,
3,
3180,
543,
8003,
13099,
78,
17378,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
199,
624,
12197,
5262,
367,
7750,
15332,
593,
11286,
301,
7585,
1041,
199,
199,
363,
21841,
363,
275,
298,
26854,
655,
2,
199,
363,
452,
363,
275,
359,
272,
298,
16098,
2684,
63,
6012,
12898,
401,
298,
16098,
2684,
63,
19091,
401,
298,
16098,
2684,
63,
6348,
5550,
401,
298,
16098,
2684,
63,
27938,
401,
272,
298,
16098,
2684,
63,
32187,
401,
298,
16098,
2684,
63,
10973,
51,
401,
298,
16098,
2684,
63,
7433,
401,
298,
16098,
2684,
63,
16901,
63,
27938,
401,
272,
298,
16098,
2684,
63,
23817,
63,
9190,
401,
298,
16098,
2684,
63,
17929,
63,
4961,
401,
298,
16098,
2684,
63,
16901,
63,
21754,
1149,
63,
4961,
401,
272,
298,
16098,
2684,
63,
8366,
63,
4961,
401,
298,
16098,
2684,
63,
19318,
63,
4961,
401,
298,
16098,
2684,
63,
12898,
63,
8760,
401,
272,
298,
16098,
2684,
63,
5172,
63,
8760,
401,
298,
16098,
2684,
63,
5901,
63,
8760,
401,
298,
16098,
2684,
63,
2080,
2639,
18273,
6593,
401,
272,
298,
16098,
2684,
63,
7121,
63,
2339,
401,
298,
16098,
2684,
63,
16618,
63,
13554,
2266,
48,
10408,
2684,
63,
6012,
12898,
401,
272,
298,
48,
10408,
2684,
63,
22690,
401,
298,
48,
10408,
2684,
63,
14956,
4807,
401,
298,
48,
10408,
2684,
63,
19714,
8760,
401,
272,
298,
48,
10408,
2684,
63,
6174,
8760,
401,
298,
48,
10408,
2684,
63,
4014,
1348,
47,
17252,
401,
298,
48,
10408,
2684,
63,
4929,
11259,
8760,
401,
272,
298,
48,
10408,
2684,
63,
19855,
8760,
401,
298,
48,
10408,
2684,
63,
40,
22436,
8760,
401,
298,
48,
10408,
2684,
63,
3218,
1981,
1772,
8760,
401,
272,
298,
48,
10408,
2684,
63,
24333,
401,
298,
48,
10408,
2684,
63,
5211,
1206,
28263,
401,
298,
48,
10408,
2684,
63,
1649,
2890,
2294,
51,
401,
298,
48,
10408,
2684,
63,
28541,
401,
272,
298,
48,
10408,
2684,
63,
6790,
8974,
401,
298,
48,
10408,
2684,
63,
7916,
51,
3022,
2099,
401,
298,
48,
10408,
2684,
63,
35,
1244,
9139,
5763,
21287,
401,
272,
298,
48,
10408,
2684,
63,
13772,
16618,
401,
298,
48,
10408,
2684,
63,
7916,
5825,
2266,
48,
10408,
2684,
63,
40,
7916,
51,
401,
272,
298,
48,
10408,
2684,
63,
16255,
4227,
7916,
13900,
3986,
1149,
401,
298,
48,
10408,
2684,
63,
4612,
401,
298,
48,
10408,
2684,
63,
22855,
7864,
401,
272,
298,
48,
10408,
2684,
63,
9663,
2711,
401,
298,
48,
10408,
2684,
63,
9663,
6305,
401,
298,
48,
10408,
2684,
63,
13947,
401,
272,
298,
48,
10408,
2684,
63,
16618,
4612,
401,
339,
298,
16098,
2684,
401,
298,
48,
10408,
2684,
401,
298,
29508,
63,
21583,
63,
2339,
401,
272,
298,
16618,
63,
29508,
63,
21583,
63,
2339,
2,
199,
61,
199,
199,
16098,
2684,
63,
6012,
12898,
275,
413,
199,
16098,
2684,
63,
19091,
275,
499,
199,
16098,
2684,
63,
6348,
5550,
275,
650,
199,
16098,
2684,
63,
27938,
275,
841,
199,
16098,
2684,
63,
32187,
275,
959,
199,
16098,
2684,
63,
10973,
51,
275,
1227,
199,
16098,
2684,
63,
7433,
275,
1520,
199,
16098,
2684,
63,
16901,
63,
27938,
275,
1695,
199,
16098,
2684,
63,
23817,
63,
9190,
275,
1749,
199,
16098,
2684,
63,
17929,
63,
4961,
275,
378,
7471,
199,
16098,
2684,
63,
16901,
63,
21754,
1149,
63,
4961,
275,
378,
8094,
199,
16098,
2684,
63,
8366,
63,
4961,
275,
378,
8163,
199,
16098,
2684,
63,
19318,
63,
4961,
275,
378,
8313,
199,
16098,
2684,
63,
12898,
63,
8760,
275,
378,
6991,
199,
16098,
2684,
63,
5172,
63,
8760,
275,
378,
6287,
199,
16098,
2684,
63,
5901,
63,
8760,
275,
378,
88,
709,
199,
16098,
2684,
63,
2080,
2639,
18273,
6593,
275,
378,
88,
845,
199,
16098,
2684,
63,
7121,
63,
2339,
275,
378,
88,
713,
199,
16098,
2684,
63,
16618,
63,
13554,
275,
378,
88,
969,
199,
199,
48,
10408,
2684,
63,
6012,
12898,
275,
413,
199,
48,
10408,
2684,
63,
22690,
275,
499,
199,
48,
10408,
2684,
63,
14956,
4807,
275,
650,
199,
48,
10408,
2684,
63,
19714,
8760,
275,
841,
199,
48,
10408,
2684,
63,
6174,
8760,
275,
959,
199,
48,
10408,
2684,
63,
4014,
1348,
47,
17252,
275,
1227,
199,
48,
10408,
2684,
63,
4929,
11259,
8760,
275,
1520,
199,
48,
10408,
2684,
63,
19855,
8760,
275,
1695,
199,
48,
10408,
2684,
63,
40,
22436,
8760,
275,
1749,
199,
48,
10408,
2684,
63,
3218,
1981,
1772,
8760,
275,
378,
7471,
199,
48,
10408,
2684,
63,
24333,
275,
378,
8094,
199,
48,
10408,
2684,
63,
5211,
1206,
28263,
275,
378,
8163,
199,
48,
10408,
2684,
63,
1649,
2890,
2294,
51,
275,
378,
8313,
199,
48,
10408,
2684,
63,
28541,
275,
378,
6991,
199,
48,
10408,
2684,
63,
6790,
8974,
275,
378,
6287,
199,
48,
10408,
2684,
63,
7916,
51,
3022,
2099,
275,
378,
88,
709,
199,
48,
10408,
2684,
63,
35,
1244,
9139,
5763,
21287,
275,
378,
88,
845,
199,
48,
10408,
2684,
63,
13772,
16618,
275,
378,
88,
969,
199,
48,
10408,
2684,
63,
7916,
5825,
275,
378,
88,
1079,
199,
48,
10408,
2684,
63,
40,
7916,
51,
275,
378,
88,
1046,
199,
48,
10408,
2684,
63,
16255,
4227,
7916,
13900
] |
[
1898,
7129,
16922,
603,
300,
82,
199,
3,
199,
3,
961,
570,
365,
1777,
402,
8003,
13099,
78,
17378,
14,
199,
3,
199,
3,
8003,
13099,
78,
17378,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
652,
1334,
314,
2895,
402,
314,
1664,
6401,
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,
8003,
13099,
78,
17378,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
199,
3,
1664,
6401,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
6401,
1696,
1684,
844,
199,
3,
3180,
543,
8003,
13099,
78,
17378,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
199,
624,
12197,
5262,
367,
7750,
15332,
593,
11286,
301,
7585,
1041,
199,
199,
363,
21841,
363,
275,
298,
26854,
655,
2,
199,
363,
452,
363,
275,
359,
272,
298,
16098,
2684,
63,
6012,
12898,
401,
298,
16098,
2684,
63,
19091,
401,
298,
16098,
2684,
63,
6348,
5550,
401,
298,
16098,
2684,
63,
27938,
401,
272,
298,
16098,
2684,
63,
32187,
401,
298,
16098,
2684,
63,
10973,
51,
401,
298,
16098,
2684,
63,
7433,
401,
298,
16098,
2684,
63,
16901,
63,
27938,
401,
272,
298,
16098,
2684,
63,
23817,
63,
9190,
401,
298,
16098,
2684,
63,
17929,
63,
4961,
401,
298,
16098,
2684,
63,
16901,
63,
21754,
1149,
63,
4961,
401,
272,
298,
16098,
2684,
63,
8366,
63,
4961,
401,
298,
16098,
2684,
63,
19318,
63,
4961,
401,
298,
16098,
2684,
63,
12898,
63,
8760,
401,
272,
298,
16098,
2684,
63,
5172,
63,
8760,
401,
298,
16098,
2684,
63,
5901,
63,
8760,
401,
298,
16098,
2684,
63,
2080,
2639,
18273,
6593,
401,
272,
298,
16098,
2684,
63,
7121,
63,
2339,
401,
298,
16098,
2684,
63,
16618,
63,
13554,
2266,
48,
10408,
2684,
63,
6012,
12898,
401,
272,
298,
48,
10408,
2684,
63,
22690,
401,
298,
48,
10408,
2684,
63,
14956,
4807,
401,
298,
48,
10408,
2684,
63,
19714,
8760,
401,
272,
298,
48,
10408,
2684,
63,
6174,
8760,
401,
298,
48,
10408,
2684,
63,
4014,
1348,
47,
17252,
401,
298,
48,
10408,
2684,
63,
4929,
11259,
8760,
401,
272,
298,
48,
10408,
2684,
63,
19855,
8760,
401,
298,
48,
10408,
2684,
63,
40,
22436,
8760,
401,
298,
48,
10408,
2684,
63,
3218,
1981,
1772,
8760,
401,
272,
298,
48,
10408,
2684,
63,
24333,
401,
298,
48,
10408,
2684,
63,
5211,
1206,
28263,
401,
298,
48,
10408,
2684,
63,
1649,
2890,
2294,
51,
401,
298,
48,
10408,
2684,
63,
28541,
401,
272,
298,
48,
10408,
2684,
63,
6790,
8974,
401,
298,
48,
10408,
2684,
63,
7916,
51,
3022,
2099,
401,
298,
48,
10408,
2684,
63,
35,
1244,
9139,
5763,
21287,
401,
272,
298,
48,
10408,
2684,
63,
13772,
16618,
401,
298,
48,
10408,
2684,
63,
7916,
5825,
2266,
48,
10408,
2684,
63,
40,
7916,
51,
401,
272,
298,
48,
10408,
2684,
63,
16255,
4227,
7916,
13900,
3986,
1149,
401,
298,
48,
10408,
2684,
63,
4612,
401,
298,
48,
10408,
2684,
63,
22855,
7864,
401,
272,
298,
48,
10408,
2684,
63,
9663,
2711,
401,
298,
48,
10408,
2684,
63,
9663,
6305,
401,
298,
48,
10408,
2684,
63,
13947,
401,
272,
298,
48,
10408,
2684,
63,
16618,
4612,
401,
339,
298,
16098,
2684,
401,
298,
48,
10408,
2684,
401,
298,
29508,
63,
21583,
63,
2339,
401,
272,
298,
16618,
63,
29508,
63,
21583,
63,
2339,
2,
199,
61,
199,
199,
16098,
2684,
63,
6012,
12898,
275,
413,
199,
16098,
2684,
63,
19091,
275,
499,
199,
16098,
2684,
63,
6348,
5550,
275,
650,
199,
16098,
2684,
63,
27938,
275,
841,
199,
16098,
2684,
63,
32187,
275,
959,
199,
16098,
2684,
63,
10973,
51,
275,
1227,
199,
16098,
2684,
63,
7433,
275,
1520,
199,
16098,
2684,
63,
16901,
63,
27938,
275,
1695,
199,
16098,
2684,
63,
23817,
63,
9190,
275,
1749,
199,
16098,
2684,
63,
17929,
63,
4961,
275,
378,
7471,
199,
16098,
2684,
63,
16901,
63,
21754,
1149,
63,
4961,
275,
378,
8094,
199,
16098,
2684,
63,
8366,
63,
4961,
275,
378,
8163,
199,
16098,
2684,
63,
19318,
63,
4961,
275,
378,
8313,
199,
16098,
2684,
63,
12898,
63,
8760,
275,
378,
6991,
199,
16098,
2684,
63,
5172,
63,
8760,
275,
378,
6287,
199,
16098,
2684,
63,
5901,
63,
8760,
275,
378,
88,
709,
199,
16098,
2684,
63,
2080,
2639,
18273,
6593,
275,
378,
88,
845,
199,
16098,
2684,
63,
7121,
63,
2339,
275,
378,
88,
713,
199,
16098,
2684,
63,
16618,
63,
13554,
275,
378,
88,
969,
199,
199,
48,
10408,
2684,
63,
6012,
12898,
275,
413,
199,
48,
10408,
2684,
63,
22690,
275,
499,
199,
48,
10408,
2684,
63,
14956,
4807,
275,
650,
199,
48,
10408,
2684,
63,
19714,
8760,
275,
841,
199,
48,
10408,
2684,
63,
6174,
8760,
275,
959,
199,
48,
10408,
2684,
63,
4014,
1348,
47,
17252,
275,
1227,
199,
48,
10408,
2684,
63,
4929,
11259,
8760,
275,
1520,
199,
48,
10408,
2684,
63,
19855,
8760,
275,
1695,
199,
48,
10408,
2684,
63,
40,
22436,
8760,
275,
1749,
199,
48,
10408,
2684,
63,
3218,
1981,
1772,
8760,
275,
378,
7471,
199,
48,
10408,
2684,
63,
24333,
275,
378,
8094,
199,
48,
10408,
2684,
63,
5211,
1206,
28263,
275,
378,
8163,
199,
48,
10408,
2684,
63,
1649,
2890,
2294,
51,
275,
378,
8313,
199,
48,
10408,
2684,
63,
28541,
275,
378,
6991,
199,
48,
10408,
2684,
63,
6790,
8974,
275,
378,
6287,
199,
48,
10408,
2684,
63,
7916,
51,
3022,
2099,
275,
378,
88,
709,
199,
48,
10408,
2684,
63,
35,
1244,
9139,
5763,
21287,
275,
378,
88,
845,
199,
48,
10408,
2684,
63,
13772,
16618,
275,
378,
88,
969,
199,
48,
10408,
2684,
63,
7916,
5825,
275,
378,
88,
1079,
199,
48,
10408,
2684,
63,
40,
7916,
51,
275,
378,
88,
1046,
199,
48,
10408,
2684,
63,
16255,
4227,
7916,
13900,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
Ayrx/cryptography
|
src/_cffi_src/openssl/crypto.py
|
1
|
3371
|
# This file is dual licensed under the terms of the Apache License, Version
# 2.0, and the BSD License. See the LICENSE file in the root of this repository
# for complete details.
from __future__ import absolute_import, division, print_function
INCLUDES = """
#include <openssl/crypto.h>
"""
TYPES = """
static const long Cryptography_HAS_LOCKING_CALLBACKS;
static const int SSLEAY_VERSION;
static const int SSLEAY_CFLAGS;
static const int SSLEAY_PLATFORM;
static const int SSLEAY_DIR;
static const int SSLEAY_BUILT_ON;
static const int OPENSSL_VERSION;
static const int OPENSSL_CFLAGS;
static const int OPENSSL_BUILT_ON;
static const int OPENSSL_PLATFORM;
static const int OPENSSL_DIR;
static const int CRYPTO_MEM_CHECK_ON;
static const int CRYPTO_MEM_CHECK_OFF;
static const int CRYPTO_MEM_CHECK_ENABLE;
static const int CRYPTO_MEM_CHECK_DISABLE;
static const int CRYPTO_LOCK;
static const int CRYPTO_UNLOCK;
static const int CRYPTO_READ;
static const int CRYPTO_LOCK_SSL;
"""
FUNCTIONS = """
int CRYPTO_mem_ctrl(int);
int CRYPTO_is_mem_check_on(void);
void CRYPTO_mem_leaks(struct bio_st *);
"""
MACROS = """
/* CRYPTO_cleanup_all_ex_data became a macro in 1.1.0 */
void CRYPTO_cleanup_all_ex_data(void);
/* as of 1.1.0 OpenSSL does its own locking *angelic chorus*. These functions
have become macros that are no ops */
int CRYPTO_num_locks(void);
void CRYPTO_set_locking_callback(void(*)(int, int, const char *, int));
void (*CRYPTO_get_locking_callback(void))(int, int, const char *, int);
/* SSLeay was removed in 1.1.0 */
unsigned long SSLeay(void);
const char *SSLeay_version(int);
/* these functions were added to replace the SSLeay functions in 1.1.0 */
unsigned long OpenSSL_version_num(void);
const char *OpenSSL_version(int);
/* this is a macro in 1.1.0 */
void OPENSSL_free(void *);
/* This was removed in 1.1.0 */
void CRYPTO_lock(int, int, const char *, int);
"""
CUSTOMIZATIONS = """
/* In 1.1.0 SSLeay has finally been retired. We bidirectionally define the
values so you can use either one. This is so we can use the new function
names no matter what OpenSSL we're running on, but users on older pyOpenSSL
releases won't see issues if they're running OpenSSL 1.1.0 */
#if !defined(SSLEAY_VERSION)
# define SSLeay OpenSSL_version_num
# define SSLeay_version OpenSSL_version
# define SSLEAY_VERSION_NUMBER OPENSSL_VERSION_NUMBER
# define SSLEAY_VERSION OPENSSL_VERSION
# define SSLEAY_CFLAGS OPENSSL_CFLAGS
# define SSLEAY_BUILT_ON OPENSSL_BUILT_ON
# define SSLEAY_PLATFORM OPENSSL_PLATFORM
# define SSLEAY_DIR OPENSSL_DIR
#endif
#if !defined(OPENSSL_VERSION)
# define OpenSSL_version_num SSLeay
# define OpenSSL_version SSLeay_version
# define OPENSSL_VERSION SSLEAY_VERSION
# define OPENSSL_CFLAGS SSLEAY_CFLAGS
# define OPENSSL_BUILT_ON SSLEAY_BUILT_ON
# define OPENSSL_PLATFORM SSLEAY_PLATFORM
# define OPENSSL_DIR SSLEAY_DIR
#endif
#if !defined(CRYPTO_LOCK)
static const long Cryptography_HAS_LOCKING_CALLBACKS = 0;
static const long CRYPTO_LOCK = 0;
static const long CRYPTO_UNLOCK = 0;
static const long CRYPTO_READ = 0;
static const long CRYPTO_LOCK_SSL = 0;
void (*CRYPTO_lock)(int, int, const char *, int) = NULL;
#else
static const long Cryptography_HAS_LOCKING_CALLBACKS = 1;
#endif
"""
|
bsd-3-clause
|
[
3,
961,
570,
365,
21164,
18233,
1334,
314,
2895,
402,
314,
3668,
844,
12,
3394,
199,
3,
499,
14,
16,
12,
436,
314,
6289,
844,
14,
1666,
314,
5113,
570,
315,
314,
1738,
402,
642,
7611,
199,
3,
367,
4890,
2436,
14,
199,
199,
504,
636,
2443,
363,
492,
3679,
63,
646,
12,
4629,
12,
870,
63,
1593,
199,
199,
568,
29992,
275,
408,
199,
3,
2613,
665,
14837,
15,
10316,
14,
72,
30,
199,
624,
199,
199,
7893,
275,
408,
199,
1986,
950,
1846,
18855,
9773,
63,
13533,
63,
4406,
1206,
63,
28100,
51,
27,
199,
199,
1986,
950,
1109,
32101,
906,
3448,
63,
4612,
27,
199,
1986,
950,
1109,
32101,
906,
3448,
63,
14804,
27,
199,
1986,
950,
1109,
32101,
906,
3448,
63,
17805,
27,
199,
1986,
950,
1109,
32101,
906,
3448,
63,
3022,
27,
199,
1986,
950,
1109,
32101,
906,
3448,
63,
18637,
52,
63,
615,
27,
199,
1986,
950,
1109,
24164,
5413,
63,
4612,
27,
199,
1986,
950,
1109,
24164,
5413,
63,
14804,
27,
199,
1986,
950,
1109,
24164,
5413,
63,
18637,
52,
63,
615,
27,
199,
1986,
950,
1109,
24164,
5413,
63,
17805,
27,
199,
1986,
950,
1109,
24164,
5413,
63,
3022,
27,
199,
1986,
950,
1109,
445,
5782,
48,
2566,
63,
10293,
63,
8936,
63,
615,
27,
199,
1986,
950,
1109,
445,
5782,
48,
2566,
63,
10293,
63,
8936,
63,
7517,
27,
199,
1986,
950,
1109,
445,
5782,
48,
2566,
63,
10293,
63,
8936,
63,
8898,
27,
199,
1986,
950,
1109,
445,
5782,
48,
2566,
63,
10293,
63,
8936,
63,
13052,
27,
199,
1986,
950,
1109,
445,
5782,
48,
2566,
63,
4406,
27,
199,
1986,
950,
1109,
445,
5782,
48,
2566,
63,
1734,
4406,
27,
199,
1986,
950,
1109,
445,
5782,
48,
2566,
63,
5670,
27,
199,
1986,
950,
1109,
445,
5782,
48,
2566,
63,
4406,
63,
5413,
27,
199,
624,
199,
199,
29865,
275,
408,
199,
442,
445,
5782,
48,
2566,
63,
5286,
63,
12476,
8,
442,
2736,
199,
442,
445,
5782,
48,
2566,
63,
374,
63,
5286,
63,
1074,
63,
265,
8,
1647,
2736,
199,
1647,
445,
5782,
48,
2566,
63,
5286,
63,
28477,
8,
1820,
28897,
63,
270,
627,
2736,
199,
624,
199,
199,
9410,
1092,
51,
275,
408,
199,
6331,
445,
5782,
48,
2566,
63,
7661,
63,
452,
63,
476,
63,
576,
506,
27467,
282,
9559,
315,
413,
14,
17,
14,
16,
11589,
199,
1647,
445,
5782,
48,
2566,
63,
7661,
63,
452,
63,
476,
63,
576,
8,
1647,
2736,
199,
199,
6331,
465,
402,
413,
14,
17,
14,
16,
14296,
1630,
2399,
5705,
27267,
627,
618,
606,
682,
269,
527,
4856,
5723,
3423,
2043,
1172,
8649,
16954,
626,
787,
949,
4156,
11589,
199,
442,
445,
5782,
48,
2566,
63,
1507,
63,
20218,
8,
1647,
2736,
199,
1647,
445,
5782,
48,
2566,
63,
409,
63,
24056,
63,
3058,
8,
1647,
2031,
5130,
442,
12,
1109,
12,
950,
1495,
9889,
1109,
16674,
199,
1647,
19943,
2944,
7431,
2566,
63,
362,
63,
24056,
63,
3058,
8,
1647,
430,
8,
442,
12,
1109,
12,
950,
1495,
9889,
1109,
2736,
199,
199,
6331,
32101,
2553,
1187,
1990,
4829,
315,
413,
14,
17,
14,
16,
11589,
199,
2244,
1846,
32101,
2553,
1187,
8,
1647,
2736,
199,
1297,
1495,
627,
2300,
2553,
1187,
63,
1023,
8,
442,
2736,
199,
6331,
3520,
3423,
4898,
3483,
370,
3350,
314,
32101,
2553,
1187,
3423,
315,
413,
14,
17,
14,
16,
11589,
199,
2244,
1846,
14296,
63,
1023,
63,
1507,
8,
1647,
2736,
199,
1297,
1495,
627,
22791,
63,
1023,
8,
442,
2736,
199,
199,
6331,
642,
365,
282,
9559,
315,
413,
14,
17,
14,
16,
11589,
199,
1647,
24164,
5413,
63,
4624,
8,
1647,
627,
2736,
199,
199,
6331,
961,
1990,
4829,
315,
413,
14,
17,
14,
16,
11589,
199,
1647,
445,
5782,
48,
2566,
63,
831,
8,
442,
12,
1109,
12,
950,
1495,
9889,
1109,
2736,
199,
624,
199,
199,
20519,
5357,
12969,
275,
408,
199,
6331,
1010,
413,
14,
17,
14,
16,
32101,
2553,
1187,
965,
3753,
2757,
295,
280,
581,
14,
2136,
12111,
6874,
1183,
5627,
314,
2043,
1338,
880,
1265,
883,
675,
1902,
1373,
14,
961,
365,
880,
781,
883,
675,
314,
892,
805,
2043,
1561,
949,
17247,
4052,
14296,
781,
3984,
3879,
641,
12,
1325,
4390,
641,
12731,
1134,
22791,
2043,
19015,
7859,
1133,
1937,
10876,
340,
2985,
3984,
3879,
14296,
413,
14,
17,
14,
16,
11589,
199,
3,
692,
8546,
4037,
8,
2300,
906,
3448,
63,
4612,
9,
199,
3,
5627,
32101,
2553,
1187,
8295,
14296,
63,
1023,
63,
1507,
199,
3,
5627,
32101,
2553,
1187,
63,
1023,
3515,
14296,
63,
1023,
199,
3,
5627,
32101,
906,
3448,
63,
4612,
63,
9190,
257,
24164,
5413,
63,
4612,
63,
9190,
199,
3,
5627,
32101,
906,
3448,
63,
4612,
3515,
24164,
5413,
63,
4612,
199,
3,
5627,
32101,
906,
3448,
63,
14804,
3698,
24164,
5413,
63,
14804,
199,
3,
5627,
32101,
906,
3448,
63,
18637,
52,
63,
615,
260,
24164,
5413,
63,
18637,
52,
63,
615,
199,
3,
5627,
32101,
906,
3448,
63,
17805,
260,
24164,
5413,
63,
17805,
199,
3,
5627,
32101,
906,
3448,
63,
3022,
4519,
24164,
5413,
63,
3022,
199,
3,
13739,
199,
3,
692,
8546,
4037,
8,
9935,
5413,
63,
4612,
9,
199,
3,
5627,
14296,
63,
1023,
63,
1507,
258,
32101,
2553,
1187,
199,
3,
5627,
14296,
63,
1023,
260,
32101,
2553,
1187,
63,
1023,
199,
3,
5627,
24164,
5413,
63,
4612,
260,
32101,
906,
3448,
63,
4612,
199,
3,
5627,
24164,
5413,
63,
14804,
3515,
32101,
906,
3448,
63,
14804,
199,
3,
5627,
24164,
5413,
63,
18637,
52,
63,
615,
263,
32101,
906,
3448,
63,
18637,
52,
63,
615,
199,
3,
5627,
24164,
5413,
63,
17805,
263,
32101,
906,
3448,
63,
17805,
199,
3,
5627,
24164,
5413,
63,
3022,
3777,
32101,
906,
3448,
63,
3022,
199,
3,
13739,
199,
3,
692,
8546,
4037,
8,
2944,
7431,
2566,
63,
4406,
9,
199,
1986,
950,
1846,
18855,
9773,
63,
13533,
63,
4406,
1206,
63,
28100,
51,
275,
378,
27,
199,
1986,
950,
1846,
445,
5782,
48,
2566,
63,
4406,
275,
378,
27,
199,
1986,
950,
1846,
445,
5782,
48,
2566,
63,
1734,
4406,
275,
378,
27,
199,
1986,
950,
1846,
445,
5782,
48,
2566,
63
] |
[
961,
570,
365,
21164,
18233,
1334,
314,
2895,
402,
314,
3668,
844,
12,
3394,
199,
3,
499,
14,
16,
12,
436,
314,
6289,
844,
14,
1666,
314,
5113,
570,
315,
314,
1738,
402,
642,
7611,
199,
3,
367,
4890,
2436,
14,
199,
199,
504,
636,
2443,
363,
492,
3679,
63,
646,
12,
4629,
12,
870,
63,
1593,
199,
199,
568,
29992,
275,
408,
199,
3,
2613,
665,
14837,
15,
10316,
14,
72,
30,
199,
624,
199,
199,
7893,
275,
408,
199,
1986,
950,
1846,
18855,
9773,
63,
13533,
63,
4406,
1206,
63,
28100,
51,
27,
199,
199,
1986,
950,
1109,
32101,
906,
3448,
63,
4612,
27,
199,
1986,
950,
1109,
32101,
906,
3448,
63,
14804,
27,
199,
1986,
950,
1109,
32101,
906,
3448,
63,
17805,
27,
199,
1986,
950,
1109,
32101,
906,
3448,
63,
3022,
27,
199,
1986,
950,
1109,
32101,
906,
3448,
63,
18637,
52,
63,
615,
27,
199,
1986,
950,
1109,
24164,
5413,
63,
4612,
27,
199,
1986,
950,
1109,
24164,
5413,
63,
14804,
27,
199,
1986,
950,
1109,
24164,
5413,
63,
18637,
52,
63,
615,
27,
199,
1986,
950,
1109,
24164,
5413,
63,
17805,
27,
199,
1986,
950,
1109,
24164,
5413,
63,
3022,
27,
199,
1986,
950,
1109,
445,
5782,
48,
2566,
63,
10293,
63,
8936,
63,
615,
27,
199,
1986,
950,
1109,
445,
5782,
48,
2566,
63,
10293,
63,
8936,
63,
7517,
27,
199,
1986,
950,
1109,
445,
5782,
48,
2566,
63,
10293,
63,
8936,
63,
8898,
27,
199,
1986,
950,
1109,
445,
5782,
48,
2566,
63,
10293,
63,
8936,
63,
13052,
27,
199,
1986,
950,
1109,
445,
5782,
48,
2566,
63,
4406,
27,
199,
1986,
950,
1109,
445,
5782,
48,
2566,
63,
1734,
4406,
27,
199,
1986,
950,
1109,
445,
5782,
48,
2566,
63,
5670,
27,
199,
1986,
950,
1109,
445,
5782,
48,
2566,
63,
4406,
63,
5413,
27,
199,
624,
199,
199,
29865,
275,
408,
199,
442,
445,
5782,
48,
2566,
63,
5286,
63,
12476,
8,
442,
2736,
199,
442,
445,
5782,
48,
2566,
63,
374,
63,
5286,
63,
1074,
63,
265,
8,
1647,
2736,
199,
1647,
445,
5782,
48,
2566,
63,
5286,
63,
28477,
8,
1820,
28897,
63,
270,
627,
2736,
199,
624,
199,
199,
9410,
1092,
51,
275,
408,
199,
6331,
445,
5782,
48,
2566,
63,
7661,
63,
452,
63,
476,
63,
576,
506,
27467,
282,
9559,
315,
413,
14,
17,
14,
16,
11589,
199,
1647,
445,
5782,
48,
2566,
63,
7661,
63,
452,
63,
476,
63,
576,
8,
1647,
2736,
199,
199,
6331,
465,
402,
413,
14,
17,
14,
16,
14296,
1630,
2399,
5705,
27267,
627,
618,
606,
682,
269,
527,
4856,
5723,
3423,
2043,
1172,
8649,
16954,
626,
787,
949,
4156,
11589,
199,
442,
445,
5782,
48,
2566,
63,
1507,
63,
20218,
8,
1647,
2736,
199,
1647,
445,
5782,
48,
2566,
63,
409,
63,
24056,
63,
3058,
8,
1647,
2031,
5130,
442,
12,
1109,
12,
950,
1495,
9889,
1109,
16674,
199,
1647,
19943,
2944,
7431,
2566,
63,
362,
63,
24056,
63,
3058,
8,
1647,
430,
8,
442,
12,
1109,
12,
950,
1495,
9889,
1109,
2736,
199,
199,
6331,
32101,
2553,
1187,
1990,
4829,
315,
413,
14,
17,
14,
16,
11589,
199,
2244,
1846,
32101,
2553,
1187,
8,
1647,
2736,
199,
1297,
1495,
627,
2300,
2553,
1187,
63,
1023,
8,
442,
2736,
199,
6331,
3520,
3423,
4898,
3483,
370,
3350,
314,
32101,
2553,
1187,
3423,
315,
413,
14,
17,
14,
16,
11589,
199,
2244,
1846,
14296,
63,
1023,
63,
1507,
8,
1647,
2736,
199,
1297,
1495,
627,
22791,
63,
1023,
8,
442,
2736,
199,
199,
6331,
642,
365,
282,
9559,
315,
413,
14,
17,
14,
16,
11589,
199,
1647,
24164,
5413,
63,
4624,
8,
1647,
627,
2736,
199,
199,
6331,
961,
1990,
4829,
315,
413,
14,
17,
14,
16,
11589,
199,
1647,
445,
5782,
48,
2566,
63,
831,
8,
442,
12,
1109,
12,
950,
1495,
9889,
1109,
2736,
199,
624,
199,
199,
20519,
5357,
12969,
275,
408,
199,
6331,
1010,
413,
14,
17,
14,
16,
32101,
2553,
1187,
965,
3753,
2757,
295,
280,
581,
14,
2136,
12111,
6874,
1183,
5627,
314,
2043,
1338,
880,
1265,
883,
675,
1902,
1373,
14,
961,
365,
880,
781,
883,
675,
314,
892,
805,
2043,
1561,
949,
17247,
4052,
14296,
781,
3984,
3879,
641,
12,
1325,
4390,
641,
12731,
1134,
22791,
2043,
19015,
7859,
1133,
1937,
10876,
340,
2985,
3984,
3879,
14296,
413,
14,
17,
14,
16,
11589,
199,
3,
692,
8546,
4037,
8,
2300,
906,
3448,
63,
4612,
9,
199,
3,
5627,
32101,
2553,
1187,
8295,
14296,
63,
1023,
63,
1507,
199,
3,
5627,
32101,
2553,
1187,
63,
1023,
3515,
14296,
63,
1023,
199,
3,
5627,
32101,
906,
3448,
63,
4612,
63,
9190,
257,
24164,
5413,
63,
4612,
63,
9190,
199,
3,
5627,
32101,
906,
3448,
63,
4612,
3515,
24164,
5413,
63,
4612,
199,
3,
5627,
32101,
906,
3448,
63,
14804,
3698,
24164,
5413,
63,
14804,
199,
3,
5627,
32101,
906,
3448,
63,
18637,
52,
63,
615,
260,
24164,
5413,
63,
18637,
52,
63,
615,
199,
3,
5627,
32101,
906,
3448,
63,
17805,
260,
24164,
5413,
63,
17805,
199,
3,
5627,
32101,
906,
3448,
63,
3022,
4519,
24164,
5413,
63,
3022,
199,
3,
13739,
199,
3,
692,
8546,
4037,
8,
9935,
5413,
63,
4612,
9,
199,
3,
5627,
14296,
63,
1023,
63,
1507,
258,
32101,
2553,
1187,
199,
3,
5627,
14296,
63,
1023,
260,
32101,
2553,
1187,
63,
1023,
199,
3,
5627,
24164,
5413,
63,
4612,
260,
32101,
906,
3448,
63,
4612,
199,
3,
5627,
24164,
5413,
63,
14804,
3515,
32101,
906,
3448,
63,
14804,
199,
3,
5627,
24164,
5413,
63,
18637,
52,
63,
615,
263,
32101,
906,
3448,
63,
18637,
52,
63,
615,
199,
3,
5627,
24164,
5413,
63,
17805,
263,
32101,
906,
3448,
63,
17805,
199,
3,
5627,
24164,
5413,
63,
3022,
3777,
32101,
906,
3448,
63,
3022,
199,
3,
13739,
199,
3,
692,
8546,
4037,
8,
2944,
7431,
2566,
63,
4406,
9,
199,
1986,
950,
1846,
18855,
9773,
63,
13533,
63,
4406,
1206,
63,
28100,
51,
275,
378,
27,
199,
1986,
950,
1846,
445,
5782,
48,
2566,
63,
4406,
275,
378,
27,
199,
1986,
950,
1846,
445,
5782,
48,
2566,
63,
1734,
4406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
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
mfsteen/CIQTranslate-Kristian
|
openpyxl/styles/fills.py
|
1
|
5258
|
from __future__ import absolute_import
# Copyright (c) 2010-2016 openpyxl
from openpyxl.descriptors import Float, Set, Alias, NoneSet
from openpyxl.descriptors.sequence import ValueSequence
from openpyxl.compat import safe_string
from .colors import ColorDescriptor, Color
from .hashable import HashableObject
from openpyxl.xml.functions import Element, localname, safe_iterator
from openpyxl.xml.constants import SHEET_MAIN_NS
FILL_NONE = 'none'
FILL_SOLID = 'solid'
FILL_PATTERN_DARKDOWN = 'darkDown'
FILL_PATTERN_DARKGRAY = 'darkGray'
FILL_PATTERN_DARKGRID = 'darkGrid'
FILL_PATTERN_DARKHORIZONTAL = 'darkHorizontal'
FILL_PATTERN_DARKTRELLIS = 'darkTrellis'
FILL_PATTERN_DARKUP = 'darkUp'
FILL_PATTERN_DARKVERTICAL = 'darkVertical'
FILL_PATTERN_GRAY0625 = 'gray0625'
FILL_PATTERN_GRAY125 = 'gray125'
FILL_PATTERN_LIGHTDOWN = 'lightDown'
FILL_PATTERN_LIGHTGRAY = 'lightGray'
FILL_PATTERN_LIGHTGRID = 'lightGrid'
FILL_PATTERN_LIGHTHORIZONTAL = 'lightHorizontal'
FILL_PATTERN_LIGHTTRELLIS = 'lightTrellis'
FILL_PATTERN_LIGHTUP = 'lightUp'
FILL_PATTERN_LIGHTVERTICAL = 'lightVertical'
FILL_PATTERN_MEDIUMGRAY = 'mediumGray'
fills = (FILL_SOLID, FILL_PATTERN_DARKDOWN, FILL_PATTERN_DARKGRAY,
FILL_PATTERN_DARKGRID, FILL_PATTERN_DARKHORIZONTAL, FILL_PATTERN_DARKTRELLIS,
FILL_PATTERN_DARKUP, FILL_PATTERN_DARKVERTICAL, FILL_PATTERN_GRAY0625,
FILL_PATTERN_GRAY125, FILL_PATTERN_LIGHTDOWN, FILL_PATTERN_LIGHTGRAY,
FILL_PATTERN_LIGHTGRID, FILL_PATTERN_LIGHTHORIZONTAL,
FILL_PATTERN_LIGHTTRELLIS, FILL_PATTERN_LIGHTUP, FILL_PATTERN_LIGHTVERTICAL,
FILL_PATTERN_MEDIUMGRAY)
class Fill(HashableObject):
"""Base class"""
tagname = "fill"
@classmethod
def from_tree(cls, el):
children = [c for c in el]
if not children:
return
child = children[0]
if "patternFill" in child.tag:
return PatternFill._from_tree(child)
else:
return GradientFill._from_tree(child)
class PatternFill(Fill):
"""Area fill patterns for use in styles.
Caution: if you do not specify a fill_type, other attributes will have
no effect !"""
tagname = "patternFill"
__fields__ = ('patternType',
'fgColor',
'bgColor')
__elements__ = ('fgColor', 'bgColor')
patternType = NoneSet(values=fills)
fill_type = Alias("patternType")
fgColor = ColorDescriptor()
start_color = Alias("fgColor")
bgColor = ColorDescriptor()
end_color = Alias("bgColor")
def __init__(self, patternType=None, fgColor=Color(), bgColor=Color(),
fill_type=None, start_color=None, end_color=None):
if fill_type is not None:
patternType = fill_type
self.patternType = patternType
if start_color is not None:
fgColor = start_color
self.fgColor = fgColor
if end_color is not None:
bgColor = end_color
self.bgColor = bgColor
@classmethod
def _from_tree(cls, el):
attrib = dict(el.attrib)
for child in el:
desc = localname(child)
attrib[desc] = Color.from_tree(child)
return cls(**attrib)
def to_tree(self, tagname=None):
parent = Element("fill")
el = Element(self.tagname)
if self.patternType is not None:
el.set('patternType', self.patternType)
for c in self.__elements__:
value = getattr(self, c)
if value != Color():
el.append(value.to_tree(c))
parent.append(el)
return parent
DEFAULT_EMPTY_FILL = PatternFill()
DEFAULT_GRAY_FILL = PatternFill(patternType='gray125')
def _serialise_stop(tagname, sequence, namespace=None):
for idx, color in enumerate(sequence):
stop = Element("stop", position=str(idx))
stop.append(color.to_tree())
yield stop
class GradientFill(Fill):
tagname = "gradientFill"
__fields__ = ('type', 'degree', 'left', 'right', 'top', 'bottom', 'stop')
type = Set(values=('linear', 'path'))
fill_type = Alias("type")
degree = Float()
left = Float()
right = Float()
top = Float()
bottom = Float()
stop = ValueSequence(expected_type=Color, to_tree=_serialise_stop)
def __init__(self, type="linear", degree=0, left=0, right=0, top=0,
bottom=0, stop=(), fill_type=None):
self.degree = degree
self.left = left
self.right = right
self.top = top
self.bottom = bottom
self.stop = stop
if fill_type is not None:
type = fill_type
self.type = type
def __iter__(self):
for attr in self.__attrs__:
value = getattr(self, attr)
if value:
yield attr, safe_string(value)
@classmethod
def _from_tree(cls, node):
colors = []
for color in safe_iterator(node, "{%s}color" % SHEET_MAIN_NS):
colors.append(Color.from_tree(color))
return cls(stop=colors, **node.attrib)
def to_tree(self, tagname=None, namespace=None):
parent = Element("fill")
el = super(GradientFill, self).to_tree()
parent.append(el)
return parent
|
gpl-3.0
|
[
504,
636,
2443,
363,
492,
3679,
63,
646,
199,
3,
1898,
334,
67,
9,
7129,
13,
9261,
1551,
647,
15455,
199,
199,
504,
1551,
647,
15455,
14,
17752,
492,
11140,
12,
2494,
12,
24777,
12,
488,
1084,
199,
504,
1551,
647,
15455,
14,
17752,
14,
4041,
492,
1594,
5826,
199,
504,
1551,
647,
15455,
14,
5819,
492,
5048,
63,
875,
199,
199,
504,
1275,
7120,
492,
11581,
4311,
12,
11581,
199,
504,
1275,
24596,
492,
16101,
461,
1692,
199,
199,
504,
1551,
647,
15455,
14,
1652,
14,
5777,
492,
6566,
12,
2257,
354,
12,
5048,
63,
5778,
199,
504,
1551,
647,
15455,
14,
1652,
14,
5559,
492,
428,
1645,
775,
63,
5848,
63,
2709,
421,
199,
5110,
44,
63,
9185,
275,
283,
3592,
7,
199,
5110,
44,
63,
15096,
998,
275,
283,
18533,
7,
199,
5110,
44,
63,
10764,
63,
36,
5748,
8819,
275,
283,
13625,
3514,
7,
199,
5110,
44,
63,
10764,
63,
36,
5748,
18583,
57,
275,
283,
13625,
39,
803,
7,
199,
5110,
44,
63,
10764,
63,
36,
5748,
22093,
275,
283,
13625,
7900,
7,
199,
5110,
44,
63,
10764,
63,
36,
5748,
25968,
275,
283,
13625,
19918,
7,
199,
5110,
44,
63,
10764,
63,
36,
5748,
52,
907,
4464,
1311,
275,
283,
13625,
52,
3369,
14392,
7,
199,
5110,
44,
63,
10764,
63,
36,
5748,
2160,
275,
283,
13625,
1721,
7,
199,
5110,
44,
63,
10764,
63,
36,
5748,
22634,
275,
283,
13625,
19462,
7,
199,
5110,
44,
63,
10764,
63,
18583,
57,
1690,
821,
275,
283,
12150,
1690,
821,
7,
199,
5110,
44,
63,
10764,
63,
18583,
57,
6889,
275,
283,
12150,
6889,
7,
199,
5110,
44,
63,
10764,
63,
21613,
8819,
275,
283,
4040,
3514,
7,
199,
5110,
44,
63,
10764,
63,
21613,
18583,
57,
275,
283,
4040,
39,
803,
7,
199,
5110,
44,
63,
10764,
63,
21613,
22093,
275,
283,
4040,
7900,
7,
199,
5110,
44,
63,
10764,
63,
44,
13454,
2080,
7990,
275,
283,
4040,
19918,
7,
199,
5110,
44,
63,
10764,
63,
44,
13454,
1481,
907,
4464,
1311,
275,
283,
4040,
52,
3369,
14392,
7,
199,
5110,
44,
63,
10764,
63,
21613,
2160,
275,
283,
4040,
1721,
7,
199,
5110,
44,
63,
10764,
63,
21613,
22634,
275,
283,
4040,
19462,
7,
199,
5110,
44,
63,
10764,
63,
9754,
2639,
18583,
57,
275,
283,
14345,
39,
803,
7,
199,
199,
1289,
478,
275,
334,
5110,
44,
63,
15096,
998,
12,
481,
14961,
63,
10764,
63,
36,
5748,
8819,
12,
481,
14961,
63,
10764,
63,
36,
5748,
18583,
57,
12,
268,
481,
14961,
63,
10764,
63,
36,
5748,
22093,
12,
481,
14961,
63,
10764,
63,
36,
5748,
25968,
12,
481,
14961,
63,
10764,
63,
36,
5748,
52,
907,
4464,
1311,
12,
268,
481,
14961,
63,
10764,
63,
36,
5748,
2160,
12,
481,
14961,
63,
10764,
63,
36,
5748,
22634,
12,
481,
14961,
63,
10764,
63,
18583,
57,
1690,
821,
12,
268,
481,
14961,
63,
10764,
63,
18583,
57,
6889,
12,
481,
14961,
63,
10764,
63,
21613,
8819,
12,
481,
14961,
63,
10764,
63,
21613,
18583,
57,
12,
268,
481,
14961,
63,
10764,
63,
21613,
22093,
12,
481,
14961,
63,
10764,
63,
44,
13454,
2080,
7990,
12,
268,
481,
14961,
63,
10764,
63,
44,
13454,
1481,
907,
4464,
1311,
12,
481,
14961,
63,
10764,
63,
21613,
2160,
12,
481,
14961,
63,
10764,
63,
21613,
22634,
12,
268,
481,
14961,
63,
10764,
63,
9754,
2639,
18583,
57,
9,
421,
199,
533,
24797,
8,
3476,
461,
1692,
304,
339,
408,
1563,
1021,
624,
339,
24009,
275,
298,
4498,
2,
339,
768,
3744,
272,
347,
687,
63,
2350,
8,
1886,
12,
579,
304,
267,
4978,
275,
359,
67,
367,
286,
315,
579,
61,
267,
340,
440,
4978,
26,
288,
372,
267,
1982,
275,
4978,
59,
16,
61,
267,
340,
298,
3401,
12914,
2,
315,
1982,
14,
1450,
26,
288,
372,
27019,
12914,
423,
504,
63,
2350,
8,
1739,
9,
267,
587,
26,
288,
372,
19603,
12914,
423,
504,
63,
2350,
8,
1739,
9,
421,
199,
533,
27019,
12914,
8,
12914,
304,
272,
408,
11043,
5554,
7970,
367,
675,
315,
15725,
14,
272,
8790,
2206,
26,
340,
1265,
886,
440,
4165,
282,
5554,
63,
466,
12,
1163,
3004,
911,
1172,
272,
949,
7763,
8546,
624,
339,
24009,
275,
298,
3401,
12914,
2,
339,
636,
955,
363,
275,
661,
3401,
804,
297,
2116,
283,
9681,
4117,
297,
2116,
283,
6856,
4117,
358,
339,
636,
5527,
363,
275,
661,
9681,
4117,
297,
283,
6856,
4117,
358,
339,
3851,
804,
275,
488,
1084,
8,
1459,
29,
1289,
478,
9,
272,
5554,
63,
466,
275,
24777,
480,
3401,
804,
531,
272,
16587,
4117,
275,
11581,
4311,
342,
272,
1343,
63,
2326,
275,
24777,
480,
9681,
4117,
531,
272,
12994,
4117,
275,
11581,
4311,
342,
272,
1284,
63,
2326,
275,
24777,
480,
6856,
4117,
531,
339,
347,
636,
826,
721,
277,
12,
3851,
804,
29,
403,
12,
16587,
4117,
29,
4117,
1062,
12994,
4117,
29,
4117,
1062,
326,
5554,
63,
466,
29,
403,
12,
1343,
63,
2326,
29,
403,
12,
1284,
63,
2326,
29,
403,
304,
267,
340,
5554,
63,
466,
365,
440,
488,
26,
288,
3851,
804,
275,
5554,
63,
466,
267,
291,
14,
3401,
804,
275,
3851,
804,
267,
340,
1343,
63,
2326,
365,
440,
488,
26,
288,
16587,
4117,
275,
1343,
63,
2326,
267,
291,
14,
9681,
4117,
275,
16587,
4117,
267,
340,
1284,
63,
2326,
365,
440,
488,
26,
288,
12994,
4117,
275,
1284,
63,
2326,
267,
291,
14,
6856,
4117,
275,
12994,
4117,
339,
768,
3744,
272,
347,
485,
504,
63,
2350,
8,
1886,
12,
579,
304,
267,
14399,
275,
1211,
8,
352,
14,
6640,
9,
267,
367,
1982,
315,
579,
26,
288,
4328,
275,
2257,
354,
8,
1739,
9,
288,
14399,
59,
3257,
61,
275,
11581,
14,
504,
63,
2350,
8,
1739,
9,
267,
372,
843,
3682,
6640,
9,
2378,
347,
370,
63,
2350,
8,
277,
12,
24009,
29,
403,
304,
267,
1676,
275,
6566,
480,
4498,
531,
267,
579,
275,
6566,
8,
277,
14,
24173,
9,
267,
340,
291,
14,
3401,
804,
365,
440,
488,
26,
288,
579,
14,
409,
360,
3401,
804,
297,
291,
14,
3401,
804,
9,
267,
367,
286,
315,
291,
855,
5527,
10651,
288,
574,
275
] |
[
636,
2443,
363,
492,
3679,
63,
646,
199,
3,
1898,
334,
67,
9,
7129,
13,
9261,
1551,
647,
15455,
199,
199,
504,
1551,
647,
15455,
14,
17752,
492,
11140,
12,
2494,
12,
24777,
12,
488,
1084,
199,
504,
1551,
647,
15455,
14,
17752,
14,
4041,
492,
1594,
5826,
199,
504,
1551,
647,
15455,
14,
5819,
492,
5048,
63,
875,
199,
199,
504,
1275,
7120,
492,
11581,
4311,
12,
11581,
199,
504,
1275,
24596,
492,
16101,
461,
1692,
199,
199,
504,
1551,
647,
15455,
14,
1652,
14,
5777,
492,
6566,
12,
2257,
354,
12,
5048,
63,
5778,
199,
504,
1551,
647,
15455,
14,
1652,
14,
5559,
492,
428,
1645,
775,
63,
5848,
63,
2709,
421,
199,
5110,
44,
63,
9185,
275,
283,
3592,
7,
199,
5110,
44,
63,
15096,
998,
275,
283,
18533,
7,
199,
5110,
44,
63,
10764,
63,
36,
5748,
8819,
275,
283,
13625,
3514,
7,
199,
5110,
44,
63,
10764,
63,
36,
5748,
18583,
57,
275,
283,
13625,
39,
803,
7,
199,
5110,
44,
63,
10764,
63,
36,
5748,
22093,
275,
283,
13625,
7900,
7,
199,
5110,
44,
63,
10764,
63,
36,
5748,
25968,
275,
283,
13625,
19918,
7,
199,
5110,
44,
63,
10764,
63,
36,
5748,
52,
907,
4464,
1311,
275,
283,
13625,
52,
3369,
14392,
7,
199,
5110,
44,
63,
10764,
63,
36,
5748,
2160,
275,
283,
13625,
1721,
7,
199,
5110,
44,
63,
10764,
63,
36,
5748,
22634,
275,
283,
13625,
19462,
7,
199,
5110,
44,
63,
10764,
63,
18583,
57,
1690,
821,
275,
283,
12150,
1690,
821,
7,
199,
5110,
44,
63,
10764,
63,
18583,
57,
6889,
275,
283,
12150,
6889,
7,
199,
5110,
44,
63,
10764,
63,
21613,
8819,
275,
283,
4040,
3514,
7,
199,
5110,
44,
63,
10764,
63,
21613,
18583,
57,
275,
283,
4040,
39,
803,
7,
199,
5110,
44,
63,
10764,
63,
21613,
22093,
275,
283,
4040,
7900,
7,
199,
5110,
44,
63,
10764,
63,
44,
13454,
2080,
7990,
275,
283,
4040,
19918,
7,
199,
5110,
44,
63,
10764,
63,
44,
13454,
1481,
907,
4464,
1311,
275,
283,
4040,
52,
3369,
14392,
7,
199,
5110,
44,
63,
10764,
63,
21613,
2160,
275,
283,
4040,
1721,
7,
199,
5110,
44,
63,
10764,
63,
21613,
22634,
275,
283,
4040,
19462,
7,
199,
5110,
44,
63,
10764,
63,
9754,
2639,
18583,
57,
275,
283,
14345,
39,
803,
7,
199,
199,
1289,
478,
275,
334,
5110,
44,
63,
15096,
998,
12,
481,
14961,
63,
10764,
63,
36,
5748,
8819,
12,
481,
14961,
63,
10764,
63,
36,
5748,
18583,
57,
12,
268,
481,
14961,
63,
10764,
63,
36,
5748,
22093,
12,
481,
14961,
63,
10764,
63,
36,
5748,
25968,
12,
481,
14961,
63,
10764,
63,
36,
5748,
52,
907,
4464,
1311,
12,
268,
481,
14961,
63,
10764,
63,
36,
5748,
2160,
12,
481,
14961,
63,
10764,
63,
36,
5748,
22634,
12,
481,
14961,
63,
10764,
63,
18583,
57,
1690,
821,
12,
268,
481,
14961,
63,
10764,
63,
18583,
57,
6889,
12,
481,
14961,
63,
10764,
63,
21613,
8819,
12,
481,
14961,
63,
10764,
63,
21613,
18583,
57,
12,
268,
481,
14961,
63,
10764,
63,
21613,
22093,
12,
481,
14961,
63,
10764,
63,
44,
13454,
2080,
7990,
12,
268,
481,
14961,
63,
10764,
63,
44,
13454,
1481,
907,
4464,
1311,
12,
481,
14961,
63,
10764,
63,
21613,
2160,
12,
481,
14961,
63,
10764,
63,
21613,
22634,
12,
268,
481,
14961,
63,
10764,
63,
9754,
2639,
18583,
57,
9,
421,
199,
533,
24797,
8,
3476,
461,
1692,
304,
339,
408,
1563,
1021,
624,
339,
24009,
275,
298,
4498,
2,
339,
768,
3744,
272,
347,
687,
63,
2350,
8,
1886,
12,
579,
304,
267,
4978,
275,
359,
67,
367,
286,
315,
579,
61,
267,
340,
440,
4978,
26,
288,
372,
267,
1982,
275,
4978,
59,
16,
61,
267,
340,
298,
3401,
12914,
2,
315,
1982,
14,
1450,
26,
288,
372,
27019,
12914,
423,
504,
63,
2350,
8,
1739,
9,
267,
587,
26,
288,
372,
19603,
12914,
423,
504,
63,
2350,
8,
1739,
9,
421,
199,
533,
27019,
12914,
8,
12914,
304,
272,
408,
11043,
5554,
7970,
367,
675,
315,
15725,
14,
272,
8790,
2206,
26,
340,
1265,
886,
440,
4165,
282,
5554,
63,
466,
12,
1163,
3004,
911,
1172,
272,
949,
7763,
8546,
624,
339,
24009,
275,
298,
3401,
12914,
2,
339,
636,
955,
363,
275,
661,
3401,
804,
297,
2116,
283,
9681,
4117,
297,
2116,
283,
6856,
4117,
358,
339,
636,
5527,
363,
275,
661,
9681,
4117,
297,
283,
6856,
4117,
358,
339,
3851,
804,
275,
488,
1084,
8,
1459,
29,
1289,
478,
9,
272,
5554,
63,
466,
275,
24777,
480,
3401,
804,
531,
272,
16587,
4117,
275,
11581,
4311,
342,
272,
1343,
63,
2326,
275,
24777,
480,
9681,
4117,
531,
272,
12994,
4117,
275,
11581,
4311,
342,
272,
1284,
63,
2326,
275,
24777,
480,
6856,
4117,
531,
339,
347,
636,
826,
721,
277,
12,
3851,
804,
29,
403,
12,
16587,
4117,
29,
4117,
1062,
12994,
4117,
29,
4117,
1062,
326,
5554,
63,
466,
29,
403,
12,
1343,
63,
2326,
29,
403,
12,
1284,
63,
2326,
29,
403,
304,
267,
340,
5554,
63,
466,
365,
440,
488,
26,
288,
3851,
804,
275,
5554,
63,
466,
267,
291,
14,
3401,
804,
275,
3851,
804,
267,
340,
1343,
63,
2326,
365,
440,
488,
26,
288,
16587,
4117,
275,
1343,
63,
2326,
267,
291,
14,
9681,
4117,
275,
16587,
4117,
267,
340,
1284,
63,
2326,
365,
440,
488,
26,
288,
12994,
4117,
275,
1284,
63,
2326,
267,
291,
14,
6856,
4117,
275,
12994,
4117,
339,
768,
3744,
272,
347,
485,
504,
63,
2350,
8,
1886,
12,
579,
304,
267,
14399,
275,
1211,
8,
352,
14,
6640,
9,
267,
367,
1982,
315,
579,
26,
288,
4328,
275,
2257,
354,
8,
1739,
9,
288,
14399,
59,
3257,
61,
275,
11581,
14,
504,
63,
2350,
8,
1739,
9,
267,
372,
843,
3682,
6640,
9,
2378,
347,
370,
63,
2350,
8,
277,
12,
24009,
29,
403,
304,
267,
1676,
275,
6566,
480,
4498,
531,
267,
579,
275,
6566,
8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1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
MaxTyutyunnikov/lino
|
lino/lino_site.py
|
1
|
69806
|
# -*- coding: UTF-8 -*-
## Copyright 2002-2013 Luc Saffre
## This file is part of the Lino project.
## Lino 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.
## Lino 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 Lino; if not, see <http://www.gnu.org/licenses/>.
"""
This defines the :class:`Site` class.
It has a lot of class attributes which may be
overridden by the application developer and/or the local site
administrator.
Here is a list of Lino-specific settings.
The settings inherited :class:`north.north_site.Site`
and :class:`djangosite.Site` are documented there.
.. setting:: config_id
The primary key of the one and only `SiteConfig` instance of this
SITE. Default value is 1.
This is Lino's equivalent of Django's :setting:`SITE_ID` setting.
Lino applications don't need ``django.contrib.sites``
(`The "sites" framework
<https://docs.djangoproject.com/en/dev/ref/contrib/sites/>`_)
because this
functionality is integral part of :mod:`lino.modlib.system`.
.. setting:: use_davlink
Set this to `True` if this site should feature WebDAV-enabled links
using :ref:`davlink`.
.. setting:: use_eidreader
No longer used. Replaced by :class:`lino.mixins.beid.BeIdReaderPlugin`.
Set this to `True` if this site should feature using :ref:`eidreader`.
.. setting:: auto_configure_logger_names
A string with a space-separated list of logger names to be automatically
configured. See :mod:`lino.utils.log`.
.. setting:: user_model
Set this to ``"users.User"`` if you use `lino.modlib.users`.
Default value us `None`, meaning that this site has no user management
(feature used by e.g. :mod:`lino.test_apps.1`)
Set this to ``"auth.User"`` if you use `django.contrib.auth` instead of
`lino.modlib.users` (not tested).
.. setting:: remote_user_header
The name of the header (set by the web server) that Lino should consult
for finding the user of a request.
The default value `None` means that http authentication is not used.
Apache's default value is ``"REMOTE_USER"``.
.. setting:: ldap_auth_server
This should be a string with the domain name and DNS (separated by a
space) of the LDAP server to be used for authentication.
Example::
ldap_auth_server = 'DOMAIN_NAME SERVER_DNS'
.. setting:: auth_middleware
Override used Authorisation middlewares with supplied tuple of
middleware class names.
If None, use logic described in :doc:`/topics/auth`
.. setting:: project_model
Optionally set this to the <applabel.modelname> of a
model used as "central project" in your application.
Which concretely means that certain other models
like notes.Note, outbox.Mail, ... have an additional foreignkey
to this model.
Not yet decided whther this makes sense.
It is probably an obsolete pattern.
.. setting:: admin_prefix
The prefix to use for Lino "admin mode"
(i.e. the "admin main page" with a pull-down "main menu").
The default value is an empty string, resulting in a
website whose root url shows the admin mode.
Note that unlike Django's `MEDIA_URL
<https://docs.djangoproject.com/en/dev/ref/settings/#media-url>`__
setting, this must not contain any slash.
If this is nonempty, then your site features a "web content mode":
the root url renders "web content" defined by :mod:`lino.modlib.pages`.
The usual value in that case is ``admin_prefix = "admin"``.
See also
- `telling Django to recognize a different application root url
<http://groups.google.com/group/django-users/browse_thread/thread/c95ba83e8f666ae5?pli=1>`__
- `How to get site's root path in Django
<http://groups.google.com/group/django-users/browse_thread/thread/27f035aa8e566af6>`__
- `#8906 django.contrib.auth settings.py URL's aren't portable <https://code.djangoproject.com/ticket/8906>`__
- `Changed the way URL paths are determined
<https://code.djangoproject.com/wiki/BackwardsIncompatibleChanges#ChangedthewayURLpathsaredetermined>`__
.. setting:: plain_prefix
The prefix to use for "plain html" URLs.
Default value is ``'plain'``.
Exactly one of
:setting:`admin_prefix`
and
:setting:`plain_prefix`
must be empty.
.. setting:: preview_limit
Default value for the
:attr:`preview_limit <lino.core.tables.AbstractTable.preview_limit>`
parameter of all tables who don't specify their own one.
Default value is 15.
.. setting:: calendar_start_hour
The time at which the CalendarPanel's daily view starts.
Used when :setting:`use_extensible` is True.
.. setting:: calendar_end_hour
The time at which the CalendarPanel's daily view ends.
Used when :setting:`use_extensible` is True.
.. setting:: start_year
An integer with the calendar year in which this site starts working.
Used e.g.
by :mod:`lino.modlib.ledger.utils`
to fill the default list of FixcalYears.
Or by :mod:`lino.modlib.ledger.fixtures.mini`
to generate demo invoices.
.. setting:: setup_choicelists
Redefine application-specific Choice Lists.
Especially used to define application-specific
:class:`UserProfiles <lino.core.perms.UserProfiles>`.
Lino by default has two user profiles "User"
and "Administrator", defined in :mod:`lino.core.perms`.
Application developers who use group-based requirements
must override this in their application's :xfile:`settings.py`
to provide a default list of user profiles for their
application.
See the source code of :mod:`lino.projects.presto`
or :mod:`lino.projects.pcsw` for a usage example.
Local site administrators may again override this in their
:xfile:`settings.py`.
Note that you may not specify values longer
than `max_length` when redefining your choicelists.
This limitation is because these redefinitions happen at a
moment where database fields have already been instantiated,
so it is too late to change their max_length.
Not that this limitation is only for the *values*, not for the names
or texts of choices.
.. setting:: get_installed_apps
This method is expected to yield the list of strings
to be stored into Django's :setting:`INSTALLED_APPS` setting.
"""
from __future__ import unicode_literals
import logging
logger = logging.getLogger(__name__)
import os
from os.path import join, abspath, dirname, normpath, isdir, exists
import sys
import cgi
import inspect
import datetime
from decimal import Decimal
from urllib import urlencode
from pkg_resources import Requirement, resource_filename, DistributionNotFound
from lino.utils.xmlgen import html as xghtml
from lino.utils import AttrDict
#~ from lino import SETUP_INFO
from django.utils.translation import ugettext_lazy as _
from north import Site
import lino
from lino import ad
from lino.utils.xmlgen.html import E
class Site(Site):
"""
This is the base for every Lino Site.
"""
config_id = 1
preview_limit = 15
calendar_start_hour = 8
calendar_end_hour = 18
override_modlib_models = set()
"See :attr:`lino.site.Site.override_modlib_models`."
textfield_format = 'plain'
"""
The default format for text fields.
Valid choices are currently 'plain' and 'html'.
Text fields are either Django's `models.TextField`
or :class:`lino.fields.RichTextField`.
You'll probably better leave the global option as 'plain',
and specify explicitly the fields you want as html by declaring
them::
foo = fields.RichTextField(...,format='html')
We even recommend that you declare your *plain* text fields also
using `fields.RichTextField` and not `models.TextField`::
foo = fields.RichTextField()
Because that gives subclasses of your application the possibility to
make that specific field html-formatted::
resolve_field('Bar.foo').set_format('html')
"""
help_url = "http://code.google.com/p/lino"
#~ site_url =
#~ index_html = "This is the main page."
#~ title = None
title = "Unnamed Lino site"
#~ domain = "www.example.com"
catch_layout_exceptions = True
"""
Lino usually catches any exception during
:meth:`lino.ui.extjs3.ExtUI.create_layout_element`
to report errors of style
"Unknown element "postings.PostingsByController ('postings')"
referred in layout <PageDetail on pages.Pages>."
Setting this to `False` is
useful when there's some problem *within* the framework.
"""
#~ preferred_build_method = 'pisa'
#~ preferred_build_method = 'appypdf'
csv_params = dict()
"""
Site-wide default parameters for CSV generation.
This must be a dictionary that will be used
as keyword parameters to Python `csv.writer()
<http://docs.python.org/library/csv.html#csv.writer>`_
Possible keys include:
- encoding :
the charset to use when responding to a CSV request.
See
http://docs.python.org/library/codecs.html#standard-encodings
for a list of available values.
- many more allowed keys are explained in
`Dialects and Formatting Parameters
<http://docs.python.org/library/csv.html#csv-fmt-params>`_.
"""
auto_configure_logger_names = 'djangosite north lino'
appy_params = dict(ooPort=8100)
"""
Used by :class:`lino.mixins.printable.AppyBuildMethod`.
"""
modules = AttrDict()
# this is explained in the polls tutorial
# cannot use autodoc for this attribute
# because autodoc shows the "default" value
#~ decimal_separator = '.'
decimal_separator = ','
"""
Set this to either ``'.'`` or ``','`` to define wether to use
comma or dot as decimal point separator when entering
a `DecimalField`.
"""
#~ decimal_group_separator = ','
decimal_group_separator = ' '
"""
Decimal group separator for :func:`lino.utils.moneyfmt`.
"""
time_format_strftime = '%H:%M'
"""
Format (in strftime syntax) to use for displaying dates to the user.
If you change this setting, you also need to override :meth:`parse_time`.
"""
date_format_strftime = '%d.%m.%Y'
"""
Format (in strftime syntax) to use for displaying dates to the user.
If you change this setting, you also need to override :meth:`parse_date`.
"""
#~ date_format_regex = "/^[0123]\d\.[01]\d\.-?\d+$/"
date_format_regex = "/^[0123]?\d\.[01]?\d\.-?\d+$/"
"""
Format (in Javascript regex syntax) to use for displaying dates to the user.
If you change this setting, you also need to override :meth:`parse_date`.
"""
datetime_format_strftime = '%Y-%m-%dT%H:%M:%S'
"""
Format (in strftime syntax) to use for formatting timestamps in AJAX responses.
If you change this setting, you also need to override :meth:`parse_datetime`.
"""
datetime_format_extjs = 'Y-m-d\TH:i:s'
"""
Format (in ExtJS syntax) to use for formatting timestamps in AJAX calls.
If you change this setting, you also need to override :meth:`parse_datetime`.
"""
_welcome_actors = []
def init_before_local(self,*args):
super(Site,self).init_before_local(*args)
self.GFK_LIST = []
self.VIRTUAL_FIELDS = []
self.update_settings(
LOGGING_CONFIG='lino.utils.log.configure',
LOGGING=dict(filename=None,
level='INFO',
logger_names=self.auto_configure_logger_names,
disable_existing_loggers=True, # Django >= 1.5
),
)
def parse_date(self,s):
"""
Convert a string formatted using
:attr:`date_format_strftime` or :attr:`date_format_extjs`
into a `(y,m,d)` tuple (not a `datetime.date` instance).
See `/blog/2010/1130`.
"""
ymd = tuple(reversed(map(int,s.split('.'))))
assert len(ymd) == 3
return ymd
#~ return datetime.date(*ymd)
def parse_time(self,s):
"""
Convert a string formatted using
:attr:`time_format_strftime` or :attr:`time_format_extjs`
into a datetime.time instance.
"""
hms = map(int,s.split(':'))
return datetime.time(*hms)
def parse_datetime(self,s):
"""
Convert a string formatted using
:attr:`datetime_format_strftime` or :attr:`datetime_format_extjs`
into a datetime.datetime instance.
"""
#~ print "20110701 parse_datetime(%r)" % s
#~ s2 = s.split()
s2 = s.split('T')
if len(s2) != 2:
raise Exception("Invalid datetime string %r" % s)
ymd = map(int,s2[0].split('-'))
hms = map(int,s2[1].split(':'))
return datetime.datetime(*(ymd+hms))
#~ d = datetime.date(*self.parse_date(s[0]))
#~ return datetime.combine(d,t)
ignore_dates_before = datetime.date.today() + datetime.timedelta(days=-7)
"""
Ignore dates before the gived date.
Set this to None if you want no limit.
"""
#~ def get_user_model(self):
#~ if 'django.contrib.auth' in self.django_settings['INSTALLED_APPS']:
#~ from django.contrib.auth.models import User
#~ return 'auth.User'
#~ else:
#~ from lino.modlib.users.models import User
#~ return User
#~ return 'users.User'
#~ def add_dummy_message(self,s):
#~ self.dummy_messages.add(s)
#~ def get_app_source_file(self):
#~ "Override this in each application"
#~ return __file__
#~ def analyze_models(self):
#~ from lino.core.kernel import analyze_models
#~ analyze_models()
def resolve_virtual_fields(self):
#~ print "20130827 resolve_virtual_fields", len(self.VIRTUAL_FIELDS)
#~ global VIRTUAL_FIELDS
for vf in self.VIRTUAL_FIELDS:
vf.lino_resolve_type()
#~ VIRTUAL_FIELDS = None
self.VIRTUAL_FIELDS = []
def register_virtual_field(self,vf):
#~ print "20130827 register_virtual_field", vf
self.VIRTUAL_FIELDS.append(vf)
def do_site_startup(self):
"""
Start the Lino instance (the object stored as :setting:`LINO` in
your :xfile:`settings.py`).
This is called exactly once from :mod:`lino.models`
when Django has has populated it's model cache.
This code can run several times at once when running e.g. under mod_wsgi:
another thread has started and not yet finished `startup_site()`.
"""
super(Site,self).do_site_startup()
from lino.core.kernel import startup_site
startup_site(self)
from django.conf import settings
if self.build_js_cache_on_startup is None:
from lino.core.dbutils import is_devserver
self.build_js_cache_on_startup = not (settings.DEBUG or is_devserver())
from lino.core.web import site_setup
site_setup(self)
from lino.ui.ui import ExtUI
self.ui = ExtUI(self)
from lino.core import actors
for a in actors.actors_list:
if a.get_welcome_messages is not None:
self._welcome_actors.append(a)
#~ def shutdown(self):
#~ return super(Site,self).shutdown()
#~ from lino.core.kernel import shutdown_site
#~ shutdown_site(self)
#~
def setup_workflows(self):
self.on_each_app('setup_workflows')
def setup_choicelists(self):
from lino.utils import dblogger as logger
#~ raise Exception("20130302 setup_choicelists()")
#~ logger.info("20130302 setup_choicelists()")
from django.utils.translation import ugettext_lazy as _
from lino import dd
dd.UserProfiles.reset()
add = dd.UserProfiles.add_item
add('000', _("Anonymous"), name='anonymous', level=None,
#~ readonly=True,
authenticated=False)
add('100', _("User"), name='user', level='user')
add('900', _("Administrator"), name='admin', level='admin')
def add_user_field(self,name,fld):
if self.user_model:
from lino import dd
#~ User = dd.resolve_model(self.user_model)
dd.inject_field(self.user_model,name,fld)
#~ if profile:
#~ self.user_profile_fields.append(name)
def get_generic_related(self,obj):
"""
Yield all database objects in database which have a GenericForeignKey
that points to the object `obj`.
"""
from django.contrib.contenttypes.models import ContentType
for gfk in self.GFK_LIST:
ct = ContentType.objects.get_for_model(gfk.model)
kw = dict()
kw[gfk.fk_field] = obj.pk
yield gfk, ct.get_all_objects_for_this_type(**kw)
def using(self,ui=None):
"""
Adds Lino, Jinja, Spinx, dateutil, ...
"""
import lino
yield ("Lino",lino.SETUP_INFO['version'],lino.SETUP_INFO['url'])
for u in super(Site,self).using(ui): yield u
#~ import tidylib
#~ version = getattr(tidylib,'__version__','')
#~ yield ("tidylib",version,"http://countergram.com/open-source/pytidylib")
#~ import pyPdf
#~ version = getattr(pyPdf,'__version__','')
#~ yield ("pyPdf",version,"http://countergram.com/open-source/pytidylib")
import jinja2
version = getattr(jinja2,'__version__','')
yield ("Jinja",version,"http://jinja.pocoo.org/")
import sphinx
version = getattr(sphinx,'__version__','')
yield ("Sphinx",version,"http://sphinx-doc.org/")
import dateutil
version = getattr(dateutil,'__version__','')
yield ("python-dateutil",version,"http://labix.org/python-dateutil")
#~ try:
#~ import Cheetah
#~ version = Cheetah.Version
#~ yield ("Cheetah",version ,"http://cheetahtemplate.org/")
#~ except ImportError:
#~ pass
try:
from odf import opendocument
version = opendocument.__version__
except ImportError:
version = self.not_found_msg
yield ("OdfPy",version ,"http://pypi.python.org/pypi/odfpy")
try:
import docutils
version = docutils.__version__
except ImportError:
version = self.not_found_msg
yield ("docutils",version ,"http://docutils.sourceforge.net/")
try:
import suds
version = suds.__version__
except ImportError:
version = self.not_found_msg
yield ("suds",version ,"https://fedorahosted.org/suds/")
import yaml
version = getattr(yaml,'__version__','')
yield ("PyYaml",version,"http://pyyaml.org/")
if False:
try:
import pyratemp
version = getattr(pyratemp,'__version__','')
except ImportError:
version = self.not_found_msg
yield ("pyratemp",version,"http://www.simple-is-better.org/template/pyratemp.html")
if False:
try:
import ho.pisa as pisa
version = getattr(pisa,'__version__','')
yield ("xhtml2pdf",version,"http://www.xhtml2pdf.com")
except ImportError:
pass
try:
import reportlab
version = reportlab.Version
except ImportError:
version = self.not_found_msg
yield ("ReportLab",version,"http://www.reportlab.org/rl_toolkit.html")
try:
#~ import appy
from appy import version
version = version.verbose
except ImportError:
version = self.not_found_msg
yield ("Appy",version ,"http://appyframework.org/pod.html")
#~ for p in self.installed_plugins
if ui and self.use_extjs:
#~ version = '<script type="text/javascript">document.write(Ext.version);</script>'
onclick = "alert('ExtJS client version is ' + Ext.version);"
tip = "Click to see ExtJS client version"
text = "(version)"
#~ version = """<a href="#" onclick="%s" title="%s">%s</a>""" % (onclick,tip,text)
version = E.a(text,href='#',onclick=onclick,title=tip)
yield ("ExtJS",version ,"http://www.sencha.com")
if self.use_extensible:
onclick = "alert('Extensible Calendar version is ' + Ext.ensible.version);"
tip = "Click to see Extensible Calendar version"
text = "(version)"
#~ version = """<a href="#" onclick="%s" title="%s">%s</a>""" % (onclick,tip,text)
version = E.a(text,href='#',onclick=onclick,title=tip)
yield ("Extensible",version ,"http://ext.ensible.com/products/calendar/")
yield ("Silk Icons",'1.3',"http://www.famfamfam.com/lab/icons/silk/")
def get_db_overview_rst(self):
"""
Returns a reStructredText-formatted "database overview" report.
Used by the :mod:`diag <lino.management.commands.diag>` command
and in test cases.
"""
from atelier import rstgen
from lino.core.dbutils import obj2str, full_model_name, sorted_models_list, app_labels
#~ writeln("Lino %s" % lino.__version__)
#~ yield (settings.SITE.verbose_name, settings.SITE.version)
#~ writeln(settings.SITE.title)
models_list = sorted_models_list()
apps = app_labels()
s = "%d applications: %s." % (len(apps), ", ".join(apps))
s += "\n%d models:\n" % len(models_list)
i = 0
headers = [
#~ "No.",
"Name",
#~ "Class",
#~ "M",
"#fields",
"#rows",
#~ ,"first","last"
]
rows = []
for model in models_list:
if model._meta.managed:
i += 1
cells = []
#~ cells.append(str(i))
cells.append(full_model_name(model))
#~ cells.append(str(model))
#~ if model._meta.managed:
#~ cells.append('X')
#~ else:
#~ cells.append('')
cells.append(str(len(model._meta.fields)))
#~ qs = model.objects.all()
qs = model.objects.order_by('pk')
n = qs.count()
cells.append(str(n))
#~ if n:
#~ cells.append(obj2str(qs[0]))
#~ cells.append(obj2str(qs[n-1]))
#~ else:
#~ cells.append('')
#~ cells.append('')
rows.append(cells)
s += rstgen.table(headers,rows)
return s
partners_app_label = 'contacts'
"""
Temporary setting, see :ref:`polymorphism`.
"""
# three constants used by lino.modlib.workflows:
max_state_value_length = 20
max_action_name_length = 50
max_actor_name_length = 100
trusted_templates = False
"""
Set this to True if you are sure that the users of your site won't try to
misuse Jinja's capabilities.
"""
#~ def add_config_value(self,name,default,help_text):
#~ if not hasattr(self,name):
#~ setattr(self,name,default)
#~ add_config_value('allow_duplicate_cities',False)
allow_duplicate_cities = False
"""
In a default configuration (when :attr:`allow_duplicate_cities` is False),
Lino declares a UNIQUE clause
for :class:`Cities <lino.modlib.countries.models.Cities>`
to make sure that your database never contains duplicate cities.
This behaviour mighr disturb e.g. when importing legacy data that
did not have this restriction.
Set it to True to remove the UNIQUE clause.
Changing this setting might affect your database structure
and thus require a :doc:`/topics/datamig`
if your application uses :mod:`lino.modlib.countries`.
"""
uid = 'myuid'
"""
A universal identifier for this Site.
This is needed when synchronizing with CalDAV server.
Locally created calendar components in remote calendars
will get a UID based on this parameter,
using ``"%s@%s" (self.pk,settings.SITE.ui)``.
The default value is ``'myuid'``, and
you should certainly override this
on a production server that uses remote calendars.
"""
#~ person_model = None
#~ person_model = "contacts.Person"
#~ """
#~ If your application uses :model:`lino.modlib.contacts`,
#~ set this to a string "applabel.Modelname" which identifies
#~ your Person model (which should inherit from
#~ :class:`lino.modlib.contacts.models.Person`).
#~ """
#~ company_model = None
#~ company_model = "contacts.Company"
#~ """
#~ If your application uses :model:`lino.modlib.contacts`,
#~ set this to a string "applabel.Modelname" which identifies
#~ your Company model (which should inherit from
#~ :class:`lino.modlib.contacts.models.Company`).
#~ """
project_model = None
#~ user_model = "users.User"
user_model = None
auth_middleware = None
legacy_data_path = None
"""
Used by custom fixtures that import data from some legacy database.
"""
propvalue_max_length = 200
"""
Used by :mod:`lino.modlib.properties`.
"""
never_build_site_cache = False
"""
Set this to `True` if you want that Lino
never (re)builds the site cache (even when asked).
This can be useful on a development server when you are debugging
directly on the generated :xfile:`lino*.js`.
Or for certain unit test cases.
"""
show_internal_field_names = False
"""
Whether the internal field names should be visible.
Default is `False`.
ExtUI implements this by prepending them to the tooltip,
which means that :attr:`use_quicktips` must also be `True`.
"""
build_js_cache_on_startup = None
"""
Whether the Javascript cache files should be built on startup
for all user profiles and languages.
On a production server this should be `True` for best performance,
but while developing, it may be easier to set it to `False`, which means
that each file is built upon need (when a first request comes in).
The default value `None` means that Lino decides automatically
during startup:
it becomes `False` if
either :func:`lino.core.dbutils.is_devserver` returns True
or setting:`DEBUG` is set.
"""
#~ replace_django_templates = True
#~ """
#~ Whether to replace Djano's template engine by Jinja.
#~ """
use_experimental_features = False
"""
Whether to include "experimental" features.
"""
site_config_defaults = {}
"""
Default values to be used when creating the
:class:`lino.models.SiteConfig` instance.
Usage example::
site_config_defaults = dict(default_build_method='appypdf')
"""
is_demo_site = True
"""
When this is `True`, then this site runs in "demo" mode.
"Demo mode" means:
- the welcome text for anonymous users says "This demo site has X
users, they all have "1234" as password",
followed by a list of available usernames.
Default value is `True`.
On a production site you will of course set this to `False`.
See also :attr:`demo_fixtures`.
"""
demo_email = 'demo@example.com'
"""
"""
demo_fixtures = ['std','demo','demo2']
"""
The list of fixtures to be loaded by the
:mod:`initdb_demo <lino.management.commands.initdb_demo>`
command.
"""
use_spinner = False # doesn't work. leave this to False
#~ django_admin_prefix = '/django'
django_admin_prefix = None
"""
The prefix to use for Django admin URLs.
Leave this unchanged as long as :doc:`/tickets/70` is not solved.
"""
start_year = 2011
plain_prefix = 'plain'
#~ admin_prefix = 'admin'
admin_prefix = ''
use_extjs = True
time_format_extjs = 'H:i'
"""
Format (in ExtJS syntax) to use for displaying dates to the user.
If you change this setting, you also need to override :meth:`parse_time`.
"""
date_format_extjs = 'd.m.Y'
"""
Format (in ExtJS syntax) to use for displaying dates to the user.
If you change this setting, you also need to override :meth:`parse_date`.
"""
alt_date_formats_extjs = 'd/m/Y|Y-m-d'
"""
Alternative date entry formats accepted by ExtJS Date widgets.
"""
#~ default_number_format_extjs = '0,000.00/i'
default_number_format_extjs = '0,00/i'
uppercase_last_name = False
"""
Whether last name of persons should be printed with uppercase letters.
See :mod:`lino.test_apps.human`
"""
extjs_root = None
"""
Path to the ExtJS root directory.
Only used when :attr:`extjs_base_url` is None,
and when the `media` directory has no symbolic link named `extjs`
pointing to the ExtJS root directory.
"""
extjs_base_url = "http://extjs-public.googlecode.com/svn/tags/extjs-3.3.1/release/"
"""
The URL from where to include the ExtJS library files.
The default value points to the
`extjs-public <http://code.google.com/p/extjs-public/>`_
repository and thus requires the clients to have an internet
connection.
This relieves newcomers from the burden of having to
specify a download location in their :xfile:`settings.py`.
On a production site you'll probably want to download and serve
these files yourself by setting this to `None` and
setting :attr:`extjs_root`
(or a symbolic link "extjs" in your :xfile:`media` directory)
to point to the local directory where ExtJS 3.3.1 is installed).
The same rules apply to the attributes
:attr:`extensible_base_url <lino.site.Site.extensible_base_url>`,
:attr:`bootstrap_base_url <lino.site.Site.bootstrap_base_url>` and
:attr:`tinymce_base_url <lino.site.Site.tinymce_base_url>`.
"""
extensible_base_url = "http://ext.ensible.com/deploy/1.0.2/"
"Similar to :attr:`extjs_base_url` but pointing to ext.ensible.com."
bootstrap_base_url = "http://twitter.github.com/bootstrap/assets/"
"Similar to :attr:`extjs_base_url` but pointing to twitter.github.com."
tinymce_base_url = "http://www.tinymce.com/js/tinymce/jscripts/tiny_mce/"
"Similar to :attr:`extjs_base_url` but pointing to http://www.tinymce.com."
bootstrap_root = None
"""
Path to the Jasmine root directory.
Only used on a development server
whose `media` directory hasn't already a symbolic link or subdirectory,
and only if :attr:`use_bootstrap` is True.
"""
jasmine_root = None
"""
Path to the Jasmine root directory.
Only used on a development server
if the `media` directory has no symbolic link to the Jasmine root directory
and only if :attr:`use_jasmine` is True.
"""
extensible_root = None
"""
Path to the Extensible root directory.
Only used on a development server
if the `media` directory has no symbolic link to the Extensible root directory,
and only if :attr:`use_extensible` is True.
"""
tinymce_root = None
"""
Path to the tinymce root directory.
Only to be used on a development server
if the `media` directory has no symbolic link to the TinyMCE root directory,
and only if :attr:`use_tinymce` is True.
"""
eid_jslib_root = None
"""
Path to the `eid_jslib` root directory.
Only to be used on a development server
if the `media` directory has no symbolic link to the directory,
and only if :attr:`use_eid_jslib` is True.
http://code.google.com/p/eid-javascript-lib/
"""
default_user = None
"""
Username to be used if a request with
no REMOTE_USER header makes its way through to Lino.
Which may happen on a development server and if Apache is
configured to allow it.
Used by :mod:`lino.core.auth`.
"""
anonymous_user_profile = '000'
"""
The UserProfile to be assigned to anonymous user.
"""
#~ remote_user_header = "REMOTE_USER"
remote_user_header = None
ldap_auth_server = None
#~ simulate_remote_user = False
use_gridfilters = True
use_eid_applet = False
"""
Whether to include functionality to read Belgian id cards
using the official
`eid-applet <http://code.google.com/p/eid-applet>`_.
This option is experimental and doesn't yet work.
See `/blog/2012/1105`.
"""
use_eid_jslib = False
"""
Whether to include functionality to read Belgian id cards
using Johan De Schutter's
`eid-javascript-lib <http://code.google.com/p/eid-javascript-lib/>`_.
If this is True, Lino expects eid-javascript-lib
to be installed in a directory `media/beid-jslib`.
See also :attr:`eid_jslib_root`.
"""
use_esteid = False
"""
Whether to include functionality to read Estonian id cards.
This option is experimental and doesn't yet work.
"""
use_filterRow = not use_gridfilters
"""
See `/blog/2011/0630`.
This option was experimental and doesn't yet work (and maybe never will).
"""
use_awesome_uploader = False
"""
Whether to use AwesomeUploader.
This option was experimental and doesn't yet work (and maybe never will).
"""
use_tinymce = True
"""
Whether to use TinyMCE instead of Ext.form.HtmlEditor.
See also :attr:`tinymce_root`.
See `/blog/2011/0523`.
"""
use_bootstrap = True
"""
Whether to use the `Bootstrap <http://twitter.github.com/bootstrap>`_ CSS toolkit.
"""
use_jasmine = False
"""
Whether to use the `Jasmine <https://github.com/pivotal/jasmine>`_ testing library.
"""
use_extensible = True
"""
Whether to use the `Extensible <http://ext.ensible.com>`_ calendar library.
"""
use_quicktips = True
"""
Whether to make use of `Ext.QuickTips
<http://docs.sencha.com/ext-js/3-4/#!/api/Ext.QuickTips>`_
when displaying :ref:`help_texts`.
"""
use_css_tooltips = False
"""
Whether to make use of CSS tooltips
when displaying help texts defined in :class:`lino.models.HelpText`.
"""
use_vinylfox = False
"""
Whether to use VinylFox extensions for HtmlEditor.
This feature was experimental and doesn't yet work (and maybe never will).
See `/blog/2011/0523`.
"""
webdav_root = None
"""
The path on server to store webdav files.
Default is "PROJECT_DIR/media/webdav".
"""
webdav_url = None
"""
The URL prefix for webdav files.
In a normal production configuration you should leave this to `None`,
Lino will set a default value "/media/webdav/",
supposing that your Apache is configured as described in
:doc:`/admin/webdav`.
This may be used to simulate a :term:`WebDAV` location
on a development server.
For example on a Windows machine, you may set it to ``w:\``,
and before invoking :term:`runserver`, you issue in a command prompt::
subst w: <dev_project_path>\media\webdav
"""
#~ use_eidreader = False
#~ """
#~ Set this to `True` if this site should feature using :ref:`eidreader`.
#~ """
use_davlink = False
#~ max_auto_events = 72
#~ """
#~ Maximum number of automatic events to be generated.
#~ """
#~ mergeable_models = []
#~ """
#~ A list of models that should have a "Merge" action
#~ (see :mod:`lino.mixins.mergeable`).
#~ """
override_modlib_models = None
sidebar_width = 0
"""
Width of the sidebar in 1/12 of total screen width.
Meaningful values are 0 (no sidebar), 2 or 3.
"""
# for internal use:
#~ _extjs_ui = None
#~ _groph_ui = None
_site_config = None
def override_defaults(self,**kwargs):
"""
"""
#~ logger.info("20130404 lino.site.Site.override_defaults")
super(Site,self).override_defaults(**kwargs)
installed_apps = tuple(self.get_installed_apps()) + ('lino','djangosite')
installed_apps = tuple([str(x) for x in installed_apps])
self.update_settings(INSTALLED_APPS=installed_apps)
if self.override_modlib_models is None:
self.override_modlib_models = set()
from django.utils.importlib import import_module
for n in installed_apps:
m = import_module(n)
app = getattr(m,'App',None)
if app is not None:
if app.extends_models is not None:
for m in app.extends_models:
self.override_modlib_models.add(m)
#~ fd = list()
#~ self.update_settings(FIXTURE_DIRS=tuple(settings_subdirs('fixtures')))
if self.webdav_url is None:
self.webdav_url = '/media/webdav/'
if self.webdav_root is None:
self.webdav_root = join(abspath(self.project_dir),'media','webdav')
if not self.django_settings.get('MEDIA_ROOT',False):
"""
Django's default value for MEDIA_ROOT is an empty string.
In certain test cases there migth be no MEDIA_ROOT key at all.
Lino's default value for MEDIA_ROOT is ``<project_dir>/media``.
"""
self.django_settings.update(MEDIA_ROOT=join(self.project_dir,'media'))
self.update_settings(
ROOT_URLCONF = 'lino.ui.urls'
)
self.update_settings(
MEDIA_URL = '/media/'
)
self.update_settings(
TEMPLATE_LOADERS=tuple([
'lino.core.web.Loader',
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
#~ 'django.template.loaders.eggs.Loader',
]))
tcp = []
if self.user_model == 'auth.User':
self.update_settings(LOGIN_URL = '/accounts/login/')
self.update_settings(LOGIN_REDIRECT_URL = "/")
tcp += [ 'django.contrib.auth.context_processors.auth' ]
tcp += [
'django.core.context_processors.debug',
'django.core.context_processors.i18n',
'django.core.context_processors.media',
'django.core.context_processors.static',
# 'django.core.context_processors.request',
#~ 'django.contrib.messages.context_processors.messages',
]
self.update_settings(TEMPLATE_CONTEXT_PROCESSORS = tuple(tcp))
self.define_settings(
MIDDLEWARE_CLASSES=tuple(self.get_middleware_classes()))
#~ print 20130313, self.django_settings['MIDDLEWARE_CLASSES']
#~ def get_plugins(self):
#~ from lino.ui.ui import ExtUI
#~ yield ExtUI()
#~ def do_site_startup(self):
#~ raise Exception("20130302")
#~ try:
#~ super(Site,self).do_site_startup()
#~ if True:
#~ self.ui =
#~ except Exception as e:
#~ import traceback
#~ traceback.print_exc(e)
#~ sys.exit(-10)
#~ raise Exception("20130302")
def is_abstract_model(self,name):
"""
Return True if the named model ("myapp.MyModel") is declared in
:attr:`override_modlib_models`.
"""
return name in self.override_modlib_models
def is_imported_partner(self,obj):
"""
Return whether the specified
:class:`Partner <lino.modlib.contacts.models.Partner>` instance
`obj` is to be considered as imported from some legacy database.
"""
#~ return obj.id is not None and (obj.id < 200000 or obj.id > 299999)
return False
#~ return obj.id is not None and (obj.id > 10 and obj.id < 21)
def site_header(self):
"""
Used in footnote or header of certain printed documents.
The convention is to call it as follows from an appy.pod template
(use the `html` function, not `xhtml`)
::
do text
from html(settings.SITE.site_header())
Note that this is expected to return a unicode string possibly
containing valid HTML (not XHTML) tags for formatting.
"""
if self.is_installed('contacts'):
if self.site_config.site_company:
return self.site_config.site_company.get_address('<br/>')
#~ s = unicode(self.site_config.site_company) + " / " + s
#~ return ''
def setup_main_menu(self):
"""
To be implemented by applications.
"""
pass
#~ @property
#~ def site_config(self):
#~ SiteConfig = self.modules.system.SiteConfig
#~ try:
#~ return SiteConfig.objects.get(pk=1)
#~ except SiteConfig.DoesNotExist:
#~ kw = dict(pk=1)
#~ kw.update(self.site_config_defaults)
#~ sc = SiteConfig(**kw)
#~ sc.full_clean()
#~ sc.save()
#~ return sc
@property
def site_config(self):
"""
Returns the one and only
:class:`lino.modlib.system.models.SiteConfig` instance which
contains Site configuration parameters which are stored in the
database and editable using the web interface.
If no instance exists (which happens in a virgin database),
we create it using default values from :attr:`site_config_defaults`.
"""
if self._site_config is None:
#~ raise Exception(20130301)
#~ print '20130320 create _site_config'
#~ from lino.core.dbutils import resolve_model
#~ from lino.core.dbutils import obj2str
#~ from lino.utils import dblogger as logger
#~ SiteConfig = resolve_model('system.SiteConfig')
SiteConfig = self.modules.system.SiteConfig
#~ from .models import SiteConfig
#~ from django.db.utils import DatabaseError
try:
#~ self._site_config = SiteConfig.real_objects.get(pk=1)
self._site_config = SiteConfig.real_objects.get(pk=self.config_id)
#~ print "20130301 Loaded SiteConfig record", obj2str(self._site_config,True)
#~ except (SiteConfig.DoesNotExist,DatabaseError):
except SiteConfig.DoesNotExist:
#~ except Exception,e:
kw = dict(pk=self.config_id)
#~ kw.update(settings.SITE.site_config_defaults)
kw.update(self.site_config_defaults)
self._site_config = SiteConfig(**kw)
#~ print "20130301 Created SiteConfig record", obj2str(self._site_config,True)
# 20120725
# polls_tutorial menu selection `Config --> Site Parameters`
# said "SiteConfig 1 does not exist"
# cannot save the instance here because the db table possibly doesn't yet exit.
#~ self._site_config.save()
return self._site_config
#~ site_config = property(get_site_config)
#~ def shutdown(self):
#~ self.clear_site_config()
#~ return super(Site,self).shutdown()
def clear_site_config(self):
"""
Clear the cached SiteConfig instance.
This is needed e.g. when the test runner has created a new
test database.
"""
self._site_config = None
#~ print "20130320 clear_site_config"
#~ def on_site_config_saved(self,sc):
#~ """
#~ Used internally. Called by SiteConfig.save() to update the cached instance.
#~ """
#~ pass
#~ self._site_config = sc
#~ from lino.core.dbutils import obj2str
#~ print '20120801 site_config saved', obj2str(sc,True)
def is_imported_partner(self,obj):
"""
Return whether the specified
:class:`Partner <lino.modlib.contacts.models.Partner>` instance
`obj` is to be considered as imported from some legacy database.
"""
#~ return obj.id is not None and (obj.id < 200000 or obj.id > 299999)
return False
#~ return obj.id is not None and (obj.id > 10 and obj.id < 21)
def get_quicklinks(self,ar):
from lino.core import menus
m = menus.Toolbar(ar.get_user().profile,'quicklinks')
self.setup_quicklinks(ar,m)
return m
def get_site_menu(self,ui,profile):
"""
Return this site's main menu for the given UserProfile.
Must be a :class:`lino.core.menus.Toolbar` instance.
Applications usually should not need to override this.
"""
from django.utils.translation import ugettext_lazy as _
from lino.core import menus
main = menus.Toolbar(profile,'main')
self.setup_menu(ui,profile,main)
main.compress()
#~ url = self.admin_url
#~ if not url:
#~ url = "/"
#~ main.add_url_button(url,label=_("Home"))
#~ url = "javascript:Lino.close_all_windows()"
#~ main.add_url_button(url,label=_("Home"))
return main
def setup_quicklinks(self,ar,m):
"""
Override this
in application-specific (or even local) :xfile:`settings.py` files
to define a series of *quick links* to appear below the main menu bar.
Example see :meth:`lino.projects.pcsw.settings.Site.setup_quicklinks`.
"""
self.on_each_app('setup_quicklinks',ar,m)
def setup_menu(self,ui,profile,main):
"""
Set up the application's menu structure.
The default implementation uses a system of
predefined top-level items that are filled by the
different :setting:`INSTALLED_APPS`.
To use this system, application programmers
define one or several of the following functions in
their `models` module:
- `setup_master_menu`
- `setup_main_menu`
- `setup_reports_menu`
- `setup_config_menu`
- `setup_explorer_menu`
- `setup_site_menu`
These functions, if present, will be called with three
positional arguments: `ui`, `profile` and `menu`.
Deserves more documentation.
"""
from django.utils.translation import ugettext_lazy as _
m = main.add_menu("master",_("Master"))
self.on_each_app('setup_master_menu',ui,profile,m)
#~ if not profile.readonly:
#~ m = main.add_menu("my",_("My menu"))
#~ self.on_each_app('setup_my_menu',ui,profile,m)
self.on_each_app('setup_main_menu',ui,profile,main)
m = main.add_menu("reports",_("Reports"))
self.on_each_app('setup_reports_menu',ui,profile,m)
m = main.add_menu("config",_("Configure"))
self.on_each_app('setup_config_menu',ui,profile,m)
m = main.add_menu("explorer",_("Explorer"))
self.on_each_app('setup_explorer_menu',ui,profile,m)
m = main.add_menu("site",_("Site"))
self.on_each_app('setup_site_menu',ui,profile,m)
return main
def get_middleware_classes(self):
"""
Yields the strings to be stored in
the :setting:`MIDDLEWARE_CLASSES` setting.
In case you don't want to use this method
for defining :setting:`MIDDLEWARE_CLASSES`,
you can simply set :setting:`MIDDLEWARE_CLASSES`
in your :xfile:`settings.py`
after the :class:`lino.site.Site` has been instantiated.
`Django and standard HTTP authentication
<http://stackoverflow.com/questions/152248/can-i-use-http-basic-authentication-with-django>`_
"""
yield 'django.middleware.common.CommonMiddleware'
#~ yield 'django.contrib.sessions.middleware.SessionMiddleware'
if self.languages and len(self.languages) > 1:
yield 'django.middleware.locale.LocaleMiddleware'
#~ yield 'django.contrib.auth.middleware.AuthenticationMiddleware'
#~ if self.user_model:
#~ if self.user_model is None:
#~ yield 'lino.core.auth.NoUserMiddleware'
#~ elif self.remote_user_header:
if self.auth_middleware:
yield self.auth_middleware
else:
if self.user_model is None:
yield 'lino.core.auth.NoUserMiddleware'
elif self.remote_user_header:
yield 'lino.core.auth.RemoteUserMiddleware'
#~ yield 'django.middleware.doc.XViewMiddleware'
else:
# not using remote http auth, so we need sessions
yield 'django.contrib.sessions.middleware.SessionMiddleware'
if self.ldap_auth_server:
yield 'lino.core.auth.LDAPAuthMiddleware'
else:
yield 'lino.core.auth.SessionUserMiddleware'
#~ raise Exception("""\
#~ `user_model` is not None, but no `remote_user_header` in your settings.SITE.""")
#~ yield 'lino.utils.editing.EditingMiddleware'
if True:
yield 'lino.utils.ajax.AjaxExceptionResponse'
if False: # not BYPASS_PERMS:
yield 'django.contrib.auth.middleware.RemoteUserMiddleware'
# TODO: find solution for this:
#~ AUTHENTICATION_BACKENDS = (
#~ 'django.contrib.auth.backends.RemoteUserBackend',
#~ )
if False:
#~ yield 'lino.utils.sqllog.ShortSQLLogToConsoleMiddleware'
yield 'lino.utils.sqllog.SQLLogToConsoleMiddleware'
#~ yield 'lino.utils.sqllog.SQLLogMiddleware'
def get_main_action(self,profile):
"""
Return the action to show as top-level "index.html".
The default implementation returns `None`, which means
that Lino will call :meth:`get_main_html`.
"""
return None
def get_main_html(self,request):
"""
Return a chunk of html to be displayed in the main area of the admin index.
This is being called only if :meth:`get_main_action` returns `None`.
The default implementation renders the :xfile:`admin_main.html` template.
"""
from lino.core import web
return web.render_from_request(request,'admin_main.html')
def get_welcome_messages(self,ar):
"""
Return or yield a list of messages to display for welcome.
"""
for a in self._welcome_actors:
for msg in a.get_welcome_messages(ar):
yield msg
def get_todo_tables(self,ar):
"""
Return or yield a list of tables that should be empty
"""
from django.db import models
for app_module in models.get_apps():
meth = getattr(app_module,'get_todo_tables',None)
if meth is not None:
#~ dblogger.debug("Running %s of %s", methname, mod.__name__)
for table,text in meth(ar):
if isinstance(table,basestring):
table = self.modules.resolve(table)
if table.default_action.get_view_permission(ar.get_user().profile):
if table.default_action.get_row_permission(ar,None,None):
#~ if table.default_action.get_bound_action_permission(ar,None,None):
if text is None:
text = "%d " + unicode(table.label)
yield (table,text)
def get_installed_apps(self):
#~ yield 'lino.ui'
if self.user_model is not None and self.remote_user_header is None:
yield 'django.contrib.sessions' # 20121103
if self.django_admin_prefix:
yield 'django.contrib.admin'
#~ 'django.contrib.markup',
#~ yield 'django_extensions'
yield 'lino.modlib.about'
#~ if self.admin_prefix:
#~ yield 'lino.modlib.pages'
for a in self.user_apps:
yield a
#~ def get_guest_greeting(self):
#~ return E.p("Please log in")
site_prefix = '/'
"""
This must be set if your project is not sitting at the "root" URL
of your server.
It must start *and* end with a *slash*. Default value is ``'/'``.
For example if you have::
WSGIScriptAlias /foo /home/luc/mypy/lino_sites/foo/wsgi.py
Then your :xfile:`settings.py` should specify::
site_prefix = '/foo/'
See also :ref:`mass_hosting`.
"""
def buildurl(self,*args,**kw):
#~ url = '/' + ("/".join(args))
url = self.site_prefix + ("/".join(args))
if len(kw):
url += "?" + urlencode(kw)
return url
def build_admin_url(self,*args,**kw):
if self.admin_prefix:
return self.buildurl(self.admin_prefix,*args,**kw)
return self.buildurl(*args,**kw)
def build_media_url(self,*args,**kw):
return self.buildurl('media',*args,**kw)
def build_plain_url(self,*args,**kw):
if self.plain_prefix:
return self.buildurl('plain',*args,**kw)
return self.buildurl(*args,**kw)
#~ return self.plain_prefix + self.buildurl(*args,**kw)
def build_extjs_url(self,url):
if self.extjs_base_url:
return self.extjs_base_url + url
return self.build_media_url('extjs',url)
def build_extensible_url(self,url):
if self.extensible_base_url:
return self.extensible_base_url + url
return self.build_media_url('extensible',url)
def build_bootstrap_url(self,url):
if self.bootstrap_base_url:
return self.bootstrap_base_url + url
return self.build_media_url('bootstrap',url)
def build_tinymce_url(self,url):
if self.tinymce_base_url:
return self.tinymce_base_url + url
return self.build_media_url('tinymce',url)
def get_system_note_recipients(self,ar,obj,silent):
"""
Return or yield a list of recipients
(i.e. strings "Full Name <name@example.com>" )
to be notified by email about a system note issued
by action request `ar` about the object instance `obj`.
Default behaviour is to simply forwar it to the `obj`'s
:meth:`get_system_note_recipients <lino.core.model.Model.get_system_note_recipients>`,
but here is a hook to define local exceptions to the
application specific default rules.
"""
return obj.get_system_note_recipients(ar,silent)
def welcome_html(self,ui=None):
"""
Return a HTML version of the "This is APPLICATION
version VERSION using ..." text. to be displayed in the
About dialog, in the plain html footer, and maybe at other
places.
"""
from django.utils.translation import ugettext as _
p = []
sep = ''
if self.verbose_name:
p.append(_("This is "))
if self.url:
p.append(E.a(self.verbose_name,href=self.url,target='_blank'))
else:
p.append(E.b(self.verbose_name))
if self.version:
p.append(' ')
p.append(self.version)
sep = _(' using ')
for name,version,url in self.using(True):
p.append(sep)
p.append(E.a(name,href=url,target='_blank'))
p.append(' ')
p.append(version)
sep = ', '
return E.span(*p)
#~ def welcome_html(self,ui=None):
#~ """
#~ Text to display in the "about" dialog of a GUI application.
#~ """
#~ sep = '<br/>'
#~ kw = dict(me=self.site_version(),
#~ using = sep.join(['<a href="%s" target="_blank">%s</a> %s'
#~ % (u,n,v) for n,v,u in self.using(ui)]))
#~ return "This is %(me)s using %(using)s." % kw
def login(self,username=None,**kw):
"""
For usage from a shell.
The :meth:`login <lino.site.Site.login>` method doesn't require any
password because when somebody has command-line access we trust
that she has already authenticated. It returns a
:class:`BaseRequest <lino.core.requests.BaseRequest>` object which
has a :meth:`show <lino.core.requests.BaseRequest.show>` method.
"""
if username is None:
if not kw.has_key('user'):
from lino.core.auth import AnonymousUser
kw.update(user=AnonymousUser.instance())
else:
kw.update(user=self.user_model.objects.get(username=username))
if not kw.has_key('renderer'):
kw.update(renderer=self.ui.text_renderer)
from lino.core import requests
import lino.ui.urls # hack: trigger ui instantiation
#~ if u.language:
#~ from north.dbutils import set_language
#~ set_language(u.language)
return requests.BaseRequest(**kw)
def get_media_urls(self):
#~ print "20121110 get_media_urls"
from django.conf.urls import patterns, url, include
from lino.core.dbutils import is_devserver
from django.conf import settings
urlpatterns = []
logger.debug("Checking /media URLs ")
prefix = settings.MEDIA_URL[1:]
if not prefix.endswith('/'):
raise Exception("MEDIA_URL %r doesn't end with a '/'!" % settings.MEDIA_URL)
def setup_media_link(short_name,attr_name=None,source=None):
target = join(settings.MEDIA_ROOT,short_name)
if exists(target):
#~ logger.info("20130409 path exists: %s",target)
return
if attr_name is not None:
source = getattr(self,attr_name)
if not source:
raise Exception(
"%s does not exist and SITE.%s is not set." % (
target,attr_name))
if not exists(source):
raise Exception("SITE.%s (%s) does not exist" % (attr_name,source))
elif not exists(source):
raise Exception("%s does not exist" % source)
if is_devserver():
#~ logger.info("django.views.static serving /%s%s from %s",prefix,short_name,source)
urlpatterns.extend(patterns('django.views.static',
(r'^%s%s/(?P<path>.*)$' % (prefix,short_name),
'serve', {
'document_root': source,
'show_indexes': False })))
else:
symlink = getattr(os,'symlink',None)
if symlink is None:
logger.info("Cannot create symlink %s -> %s.",target,source)
#~ raise Exception("Cannot run a production server on an OS that doesn't have symlinks")
else:
logger.info("Create symlink %s -> %s.",target,source)
symlink(source,target)
if not self.extjs_base_url:
setup_media_link('extjs','extjs_root')
if self.use_bootstrap:
if not self.bootstrap_base_url:
setup_media_link('bootstrap','bootstrap_root')
#~ else:
#~ logger.info("20130409 self.bootstrap_base_url is %s",self.bootstrap_base_url)
#~ else:
#~ logger.info("20130409 self.use_bootstrap is False")
if self.use_extensible:
if not self.extensible_base_url:
setup_media_link('extensible','extensible_root')
if self.use_tinymce:
if not self.tinymce_base_url:
setup_media_link('tinymce','tinymce_root')
if self.use_jasmine:
setup_media_link('jasmine','jasmine_root')
if self.use_eid_jslib:
setup_media_link('eid-jslib','eid_jslib_root')
#~ setup_media_link('lino',source=join(dirname(lino.__file__),'..','media'))
try:
setup_media_link('lino',source=resource_filename(Requirement.parse("lino"),"lino/media"))
except DistributionNotFound as e:
# if it is not installed using pip, link directly to the source tree
setup_media_link('lino',source=join(dirname(lino.__file__),'media'))
#~ logger.info("20130409 is_devserver() returns %s.",is_devserver())
if is_devserver():
urlpatterns += patterns('django.views.static',
(r'^%s(?P<path>.*)$' % prefix, 'serve',
{ 'document_root': settings.MEDIA_ROOT,
'show_indexes': True }),
)
return urlpatterns
def get_pages_urls(self):
from django.conf.urls import patterns, url, include
from django import http
from django.views.generic import View
from lino import dd
pages = dd.resolve_app('pages')
class PagesIndex(View):
def get(self, request,ref='index'):
if not ref:
ref = 'index'
#~ print 20121220, ref
obj = pages.lookup(ref,None)
if obj is None:
raise http.Http404("Unknown page %r" % ref)
html = pages.render_node(request,obj)
return http.HttpResponse(html)
return patterns('',
(r'^(?P<ref>\w*)$', PagesIndex.as_view()),
)
def get_plain_urls(self):
from django.conf.urls import patterns, url, include
from lino.ui import views
urlpatterns = []
rx = '^'
urlpatterns = patterns('',
(rx+r'$', views.PlainIndex.as_view()),
(rx+r'(?P<app_label>\w+)/(?P<actor>\w+)$', views.PlainList.as_view()),
(rx+r'(?P<app_label>\w+)/(?P<actor>\w+)/(?P<pk>.+)$', views.PlainElement.as_view()),
)
return urlpatterns
def get_ext_urls(self):
from django.conf.urls import patterns, url, include
from lino.ui import views
#~ print "20121110 get_urls"
self.ui.ext_renderer.build_site_cache()
rx = '^'
urlpatterns = patterns('',
(rx+'$', views.AdminIndex.as_view()),
(rx+r'api/main_html$', views.MainHtml.as_view()),
(rx+r'auth$', views.Authenticate.as_view()),
(rx+r'grid_config/(?P<app_label>\w+)/(?P<actor>\w+)$', views.GridConfig.as_view()),
(rx+r'api/(?P<app_label>\w+)/(?P<actor>\w+)$', views.ApiList.as_view()),
(rx+r'api/(?P<app_label>\w+)/(?P<actor>\w+)/(?P<pk>.+)$', views.ApiElement.as_view()),
(rx+r'restful/(?P<app_label>\w+)/(?P<actor>\w+)$', views.Restful.as_view()),
(rx+r'restful/(?P<app_label>\w+)/(?P<actor>\w+)/(?P<pk>.+)$', views.Restful.as_view()),
(rx+r'choices/(?P<app_label>\w+)/(?P<rptname>\w+)$', views.Choices.as_view()),
(rx+r'choices/(?P<app_label>\w+)/(?P<rptname>\w+)/(?P<fldname>\w+)$', views.Choices.as_view()),
(rx+r'apchoices/(?P<app_label>\w+)/(?P<actor>\w+)/(?P<an>\w+)/(?P<field>\w+)$', views.ActionParamChoices.as_view()),
# the thread_id can be a negative number:
(rx+r'callbacks/(?P<thread_id>[\-0-9a-zA-Z]+)/(?P<button_id>\w+)$', views.Callbacks.as_view()),
)
if self.use_eid_applet:
urlpatterns += patterns('',
(rx+r'eid-applet-service$', views.EidAppletService.as_view()),
)
if self.use_jasmine:
urlpatterns += patterns('',
(rx+r'run-jasmine$', views.RunJasmine.as_view()),
)
if self.user_model and self.use_tinymce:
urlpatterns += patterns('',
(rx+r'templates/(?P<app_label>\w+)/(?P<actor>\w+)/(?P<pk>\w+)/(?P<fldname>\w+)$',
views.Templates.as_view()),
(rx+r'templates/(?P<app_label>\w+)/(?P<actor>\w+)/(?P<pk>\w+)/(?P<fldname>\w+)/(?P<tplname>\w+)$',
views.Templates.as_view()),
)
return urlpatterns
def get_patterns(self):
self.startup()
from djangosite.signals import database_ready
database_ready.send(self)
#~ self.logger.info("20130418 get_patterns()")
from django.conf.urls import patterns, url, include
urlpatterns = self.get_media_urls()
if self.use_extjs and self.admin_prefix:
urlpatterns += patterns('',
('^'+self.admin_prefix, include(self.get_ext_urls())))
if self.plain_prefix:
urlpatterns += patterns('',
('^'+self.plain_prefix+"/", include(self.get_plain_urls()))
)
if self.django_admin_prefix: # experimental
from django.contrib import admin
admin.autodiscover()
urlpatterns += patterns('',
('^'+self.django_admin_prefix[1:]+"/", include(admin.site.urls))
)
if not self.plain_prefix:
urlpatterns += self.get_plain_urls()
if self.use_extjs and not self.admin_prefix:
urlpatterns += self.get_ext_urls()
#~ elif self.plain_prefix:
#~ urlpatterns += self.get_pages_urls()
#~ print 20131021, urlpatterns
return urlpatterns
def for_each_app(self,func,*args,**kw):
"""
Successor of :meth:`djangosite.Site.on_each_app`.
This also loops over
- apps that don't have a models module
- inherited apps
"""
from django.utils.importlib import import_module
for app_name in self.get_installed_apps():
app_mod = import_module(app_name)
app = getattr(app_mod,'App',None)
if app is not None and issubclass(app,ad.App) and app.extends:
parent = import_module(app.extends)
func(app.extends,parent,*args,**kw)
func(app_name,app_mod,*args,**kw)
def get_letter_date_text(self,today=None):
"""
Returns a string like "Eupen, den 26. August 2013".
"""
sc = self.site_config.site_company
if today is None: today = datetime.date.today()
from lino import dd
if sc and sc.city:
return _("%(place)s, %(date)s") % dict(
place=unicode(sc.city.name), date=dd.fdl(today))
return dd.fdl(today)
#~ def get_letter_margin_top_html(self,ar):
#~ s = '<p class="Centered9pt">%s</p>'
#~ s = s % self.site_config.site_company.get_address('<br/>')
#~ return s
#~ from lino.utils.config import find_config_file
#~ logo_path = find_config_file('logo.jpg')
#~ return '<img src="%s"/>' % logo_path
#~ return '<img src="file://%s" />' % logo_path
#~ def get_letter_margin_bottom_html(self,ar):
#~ s = '<p class="Centered9pt">%s</p>'
#~ s = s % self.site_config.site_company.get_address('<br/>')
#~ return s
#~ return ''
def get_admin_main_items(self,ar):
"""
Yield a sequence of "items" to be rendered
in :xfile:`admin_main.html`.
"""
return []
#~ def make_url_tester(self):
#~ from lino.utils.test import URLTester
#~ return URLTester()
|
gpl-3.0
|
[
3,
1882,
2803,
26,
9094,
13,
24,
1882,
199,
309,
1898,
14790,
13,
6965,
491,
947,
428,
9181,
264,
199,
309,
961,
570,
365,
1777,
402,
314,
491,
10175,
2199,
14,
199,
309,
491,
10175,
365,
2867,
2032,
27,
1265,
883,
3604,
652,
436,
15,
269,
2811,
221,
199,
309,
652,
1334,
314,
2895,
402,
314,
1664,
1696,
1684,
844,
465,
3267,
701,
199,
309,
314,
2868,
2290,
2752,
27,
1902,
1015,
650,
402,
314,
844,
12,
503,
199,
309,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
309,
491,
10175,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
221,
199,
309,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
309,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
221,
199,
309,
1664,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
309,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
1696,
1684,
844,
199,
309,
3180,
543,
491,
10175,
27,
340,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
199,
624,
199,
2765,
7890,
314,
520,
533,
1705,
8972,
64,
1021,
14,
199,
7940,
965,
282,
13918,
402,
1021,
3004,
1314,
1443,
506,
221,
199,
30769,
701,
314,
4223,
15030,
436,
15,
269,
314,
2257,
4770,
221,
199,
2113,
14710,
14,
199,
199,
21741,
365,
282,
769,
402,
491,
10175,
13,
6100,
2202,
14,
221,
199,
1918,
2202,
12623,
520,
533,
1705,
26753,
14,
26753,
63,
2124,
14,
8972,
64,
221,
199,
460,
520,
533,
1705,
1176,
2124,
14,
8972,
64,
787,
22751,
2337,
14,
199,
199,
703,
4260,
447,
1101,
63,
344,
199,
199,
1918,
5062,
790,
402,
314,
1373,
436,
1454,
658,
8972,
2028,
64,
1256,
402,
642,
221,
199,
7917,
14,
3758,
574,
365,
413,
14,
199,
199,
2765,
365,
491,
10175,
1159,
7353,
402,
5634,
1159,
520,
6031,
1705,
7917,
63,
998,
64,
4260,
14,
199,
44,
10175,
13103,
2793,
1133,
1929,
1124,
1176,
14,
2828,
14,
8619,
1040,
221,
199,
8,
64,
1918,
298,
8619,
2,
10059,
199,
28,
2859,
921,
4757,
14,
14013,
14,
957,
15,
287,
15,
2374,
15,
1121,
15,
2828,
15,
8619,
3133,
64,
4602,
199,
20684,
642,
221,
199,
1593,
6712,
365,
20583,
1777,
402,
520,
1494,
1705,
472,
79,
14,
1494,
773,
14,
2253,
2313,
421,
199,
703,
4260,
447,
675,
63,
31496,
1073,
199,
199,
1084,
642,
370,
658,
549,
64,
340,
642,
4770,
1077,
3878,
6001,
36,
6087,
13,
3827,
6220,
221,
199,
4941,
520,
1121,
1705,
31496,
1073,
2313,
199,
199,
703,
4260,
447,
675,
63,
30065,
5503,
199,
199,
1944,
8088,
1202,
14,
14402,
68,
701,
520,
533,
1705,
472,
79,
14,
30192,
14,
1235,
344,
14,
3655,
1304,
5929,
5061,
2313,
199,
199,
1084,
642,
370,
658,
549,
64,
340,
642,
4770,
1077,
3878,
1808,
520,
1121,
1705,
30065,
5503,
2313,
421,
199,
703,
4260,
447,
2599,
63,
6472,
63,
2921,
63,
1247,
199,
199,
33,
1059,
543,
282,
4601,
13,
12794,
769,
402,
2512,
1561,
370,
506,
5847,
221,
199,
11786,
14,
1666,
520,
1494,
1705,
472,
79,
14,
1208,
14,
793,
2313,
199,
199,
703,
4260,
447,
922,
63,
1238,
199,
199,
1084,
642,
370,
25916,
3707,
14,
1899,
31002,
340,
1265,
675,
658,
472,
79,
14,
1494,
773,
14,
3707,
2313,
9948,
199,
2698,
574,
2739,
658,
403,
3559,
11150,
626,
642,
4770,
965,
949,
922,
10041,
221,
199,
8,
4445,
1202,
701,
325,
14,
71,
14,
520,
1494,
1705,
472,
79,
14,
396,
63,
5181,
14,
17,
10522,
199,
199,
1084,
642,
370,
25916,
1178,
14,
1899,
31002,
340,
1265,
675,
658,
1176,
14,
2828,
14,
1178,
64,
3140,
402,
199,
64,
472,
79,
14,
1494,
773,
14,
3707,
64,
334,
1397,
12470,
680,
421,
199,
703,
4260,
447,
3982,
63,
751,
63,
1291,
1362,
199,
1918,
536,
402,
314,
1406,
334,
409,
701,
314,
3330,
1654,
9,
626,
491,
10175,
1077,
13447,
427,
221,
199,
509,
17196,
314,
922,
402,
282,
1056,
14,
199,
1918,
849,
574,
658,
403,
64,
4910,
626,
1455,
6299,
365,
440,
1202,
14,
199,
28993,
1159,
849,
574,
365,
25916,
16058,
63,
3791,
2,
4345,
421,
199,
703,
4260,
447,
13727,
63,
1178,
63,
1000,
199,
199,
2765,
1077,
506,
282,
1059,
543,
314,
2881,
536,
436,
10237,
334,
12794,
701,
282,
221,
199,
2638,
9,
402,
314,
20717,
1654,
370,
506,
1202,
367,
6299,
14,
199,
9846,
447,
819,
13727,
63,
1178,
63,
1000,
275,
283,
7378,
63,
2339,
23578,
63,
12323,
7,
2043,
199,
703,
4260,
447,
1790,
63,
5754,
199,
199,
11954,
1202,
6529,
19914,
12180,
758,
470,
543,
6841,
2008,
402,
221,
199,
5754,
1021,
1561,
14,
199,
199,
3917,
488,
12,
675,
9661,
11736,
315,
520,
1301,
1705,
15,
11299,
15,
1178,
64,
2043,
421,
199,
703,
4260,
447,
2199,
63,
1238,
199,
199,
2602,
1183,
663,
642,
370,
314,
665,
571,
1302,
14,
1238,
354,
30,
402,
282,
221,
199,
1238,
1202,
465,
298,
16067,
2199,
2,
315,
2195,
4223,
14,
221,
199,
31619,
13801,
590,
4910,
626,
9842,
1163,
1709,
221,
199,
2930,
12681,
14,
7443,
12,
734,
1977,
14,
13681,
12,
2263,
1172,
376,
4722,
11608,
498,
221,
199,
475,
642,
1402,
14,
199,
1763,
5966,
12985,
770,
704,
728,
642,
7704,
12249,
14,
221,
199,
7940,
365,
8646,
376,
24985,
3851,
14,
4388,
199,
703,
4260,
447,
4628,
63,
1861,
199,
199,
1918,
2403,
370,
675,
367,
491,
10175,
298,
2113,
818,
2,
199,
8,
73,
14,
69,
14,
314,
298,
2113,
2446,
2034,
2,
543,
282,
10299,
13,
2110,
298,
973,
6269,
3471,
199,
199,
1918,
849,
574,
365,
376,
2701,
1059,
12,
9183,
315,
282,
221,
199,
7360,
7447,
1738,
1166,
13703,
314,
4628,
818,
14,
199,
199,
7443,
626,
29750,
5634,
1159,
658,
13669,
63,
2632,
199,
28,
2859,
921,
4757,
14,
14013,
14,
957,
15,
287,
15,
2374,
15,
1121,
15,
1751,
12645,
4603,
13,
633,
8637,
363,
221,
199,
6031,
12,
642,
1471,
440,
1395,
1263,
14457,
14,
199,
199,
3917,
642,
365,
7179,
1171,
12,
2066,
2195,
4770,
4534,
282,
298,
2520,
1564,
818,
582,
221,
199,
1589,
1738,
1166,
3795,
83,
298
] |
[
1882,
2803,
26,
9094,
13,
24,
1882,
199,
309,
1898,
14790,
13,
6965,
491,
947,
428,
9181,
264,
199,
309,
961,
570,
365,
1777,
402,
314,
491,
10175,
2199,
14,
199,
309,
491,
10175,
365,
2867,
2032,
27,
1265,
883,
3604,
652,
436,
15,
269,
2811,
221,
199,
309,
652,
1334,
314,
2895,
402,
314,
1664,
1696,
1684,
844,
465,
3267,
701,
199,
309,
314,
2868,
2290,
2752,
27,
1902,
1015,
650,
402,
314,
844,
12,
503,
199,
309,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
309,
491,
10175,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
221,
199,
309,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
309,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
221,
199,
309,
1664,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
309,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
1696,
1684,
844,
199,
309,
3180,
543,
491,
10175,
27,
340,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
199,
624,
199,
2765,
7890,
314,
520,
533,
1705,
8972,
64,
1021,
14,
199,
7940,
965,
282,
13918,
402,
1021,
3004,
1314,
1443,
506,
221,
199,
30769,
701,
314,
4223,
15030,
436,
15,
269,
314,
2257,
4770,
221,
199,
2113,
14710,
14,
199,
199,
21741,
365,
282,
769,
402,
491,
10175,
13,
6100,
2202,
14,
221,
199,
1918,
2202,
12623,
520,
533,
1705,
26753,
14,
26753,
63,
2124,
14,
8972,
64,
221,
199,
460,
520,
533,
1705,
1176,
2124,
14,
8972,
64,
787,
22751,
2337,
14,
199,
199,
703,
4260,
447,
1101,
63,
344,
199,
199,
1918,
5062,
790,
402,
314,
1373,
436,
1454,
658,
8972,
2028,
64,
1256,
402,
642,
221,
199,
7917,
14,
3758,
574,
365,
413,
14,
199,
199,
2765,
365,
491,
10175,
1159,
7353,
402,
5634,
1159,
520,
6031,
1705,
7917,
63,
998,
64,
4260,
14,
199,
44,
10175,
13103,
2793,
1133,
1929,
1124,
1176,
14,
2828,
14,
8619,
1040,
221,
199,
8,
64,
1918,
298,
8619,
2,
10059,
199,
28,
2859,
921,
4757,
14,
14013,
14,
957,
15,
287,
15,
2374,
15,
1121,
15,
2828,
15,
8619,
3133,
64,
4602,
199,
20684,
642,
221,
199,
1593,
6712,
365,
20583,
1777,
402,
520,
1494,
1705,
472,
79,
14,
1494,
773,
14,
2253,
2313,
421,
199,
703,
4260,
447,
675,
63,
31496,
1073,
199,
199,
1084,
642,
370,
658,
549,
64,
340,
642,
4770,
1077,
3878,
6001,
36,
6087,
13,
3827,
6220,
221,
199,
4941,
520,
1121,
1705,
31496,
1073,
2313,
199,
199,
703,
4260,
447,
675,
63,
30065,
5503,
199,
199,
1944,
8088,
1202,
14,
14402,
68,
701,
520,
533,
1705,
472,
79,
14,
30192,
14,
1235,
344,
14,
3655,
1304,
5929,
5061,
2313,
199,
199,
1084,
642,
370,
658,
549,
64,
340,
642,
4770,
1077,
3878,
1808,
520,
1121,
1705,
30065,
5503,
2313,
421,
199,
703,
4260,
447,
2599,
63,
6472,
63,
2921,
63,
1247,
199,
199,
33,
1059,
543,
282,
4601,
13,
12794,
769,
402,
2512,
1561,
370,
506,
5847,
221,
199,
11786,
14,
1666,
520,
1494,
1705,
472,
79,
14,
1208,
14,
793,
2313,
199,
199,
703,
4260,
447,
922,
63,
1238,
199,
199,
1084,
642,
370,
25916,
3707,
14,
1899,
31002,
340,
1265,
675,
658,
472,
79,
14,
1494,
773,
14,
3707,
2313,
9948,
199,
2698,
574,
2739,
658,
403,
3559,
11150,
626,
642,
4770,
965,
949,
922,
10041,
221,
199,
8,
4445,
1202,
701,
325,
14,
71,
14,
520,
1494,
1705,
472,
79,
14,
396,
63,
5181,
14,
17,
10522,
199,
199,
1084,
642,
370,
25916,
1178,
14,
1899,
31002,
340,
1265,
675,
658,
1176,
14,
2828,
14,
1178,
64,
3140,
402,
199,
64,
472,
79,
14,
1494,
773,
14,
3707,
64,
334,
1397,
12470,
680,
421,
199,
703,
4260,
447,
3982,
63,
751,
63,
1291,
1362,
199,
1918,
536,
402,
314,
1406,
334,
409,
701,
314,
3330,
1654,
9,
626,
491,
10175,
1077,
13447,
427,
221,
199,
509,
17196,
314,
922,
402,
282,
1056,
14,
199,
1918,
849,
574,
658,
403,
64,
4910,
626,
1455,
6299,
365,
440,
1202,
14,
199,
28993,
1159,
849,
574,
365,
25916,
16058,
63,
3791,
2,
4345,
421,
199,
703,
4260,
447,
13727,
63,
1178,
63,
1000,
199,
199,
2765,
1077,
506,
282,
1059,
543,
314,
2881,
536,
436,
10237,
334,
12794,
701,
282,
221,
199,
2638,
9,
402,
314,
20717,
1654,
370,
506,
1202,
367,
6299,
14,
199,
9846,
447,
819,
13727,
63,
1178,
63,
1000,
275,
283,
7378,
63,
2339,
23578,
63,
12323,
7,
2043,
199,
703,
4260,
447,
1790,
63,
5754,
199,
199,
11954,
1202,
6529,
19914,
12180,
758,
470,
543,
6841,
2008,
402,
221,
199,
5754,
1021,
1561,
14,
199,
199,
3917,
488,
12,
675,
9661,
11736,
315,
520,
1301,
1705,
15,
11299,
15,
1178,
64,
2043,
421,
199,
703,
4260,
447,
2199,
63,
1238,
199,
199,
2602,
1183,
663,
642,
370,
314,
665,
571,
1302,
14,
1238,
354,
30,
402,
282,
221,
199,
1238,
1202,
465,
298,
16067,
2199,
2,
315,
2195,
4223,
14,
221,
199,
31619,
13801,
590,
4910,
626,
9842,
1163,
1709,
221,
199,
2930,
12681,
14,
7443,
12,
734,
1977,
14,
13681,
12,
2263,
1172,
376,
4722,
11608,
498,
221,
199,
475,
642,
1402,
14,
199,
1763,
5966,
12985,
770,
704,
728,
642,
7704,
12249,
14,
221,
199,
7940,
365,
8646,
376,
24985,
3851,
14,
4388,
199,
703,
4260,
447,
4628,
63,
1861,
199,
199,
1918,
2403,
370,
675,
367,
491,
10175,
298,
2113,
818,
2,
199,
8,
73,
14,
69,
14,
314,
298,
2113,
2446,
2034,
2,
543,
282,
10299,
13,
2110,
298,
973,
6269,
3471,
199,
199,
1918,
849,
574,
365,
376,
2701,
1059,
12,
9183,
315,
282,
221,
199,
7360,
7447,
1738,
1166,
13703,
314,
4628,
818,
14,
199,
199,
7443,
626,
29750,
5634,
1159,
658,
13669,
63,
2632,
199,
28,
2859,
921,
4757,
14,
14013,
14,
957,
15,
287,
15,
2374,
15,
1121,
15,
1751,
12645,
4603,
13,
633,
8637,
363,
221,
199,
6031,
12,
642,
1471,
440,
1395,
1263,
14457,
14,
199,
199,
3917,
642,
365,
7179,
1171,
12,
2066,
2195,
4770,
4534,
282,
298,
2520,
1564,
818,
582,
221,
199,
1589,
1738,
1166,
3795,
83,
298,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
sserrot/champion_relationships
|
venv/Lib/site-packages/IPython/core/inputsplitter.py
|
1
|
28155
|
"""DEPRECATED: Input handling and transformation machinery.
This module was deprecated in IPython 7.0, in favour of inputtransformer2.
The first class in this module, :class:`InputSplitter`, is designed to tell when
input from a line-oriented frontend is complete and should be executed, and when
the user should be prompted for another line of code instead. The name 'input
splitter' is largely for historical reasons.
A companion, :class:`IPythonInputSplitter`, provides the same functionality but
with full support for the extended IPython syntax (magics, system calls, etc).
The code to actually do these transformations is in :mod:`IPython.core.inputtransformer`.
:class:`IPythonInputSplitter` feeds the raw code to the transformers in order
and stores the results.
For more details, see the class docstrings below.
"""
from warnings import warn
warn('IPython.core.inputsplitter is deprecated since IPython 7 in favor of `IPython.core.inputtransformer2`',
DeprecationWarning)
# Copyright (c) IPython Development Team.
# Distributed under the terms of the Modified BSD License.
import ast
import codeop
import io
import re
import sys
import tokenize
import warnings
from IPython.core.inputtransformer import (leading_indent,
classic_prompt,
ipy_prompt,
cellmagic,
assemble_logical_lines,
help_end,
escaped_commands,
assign_from_magic,
assign_from_system,
assemble_python_lines,
)
# These are available in this module for backwards compatibility.
from IPython.core.inputtransformer import (ESC_SHELL, ESC_SH_CAP, ESC_HELP,
ESC_HELP2, ESC_MAGIC, ESC_MAGIC2,
ESC_QUOTE, ESC_QUOTE2, ESC_PAREN, ESC_SEQUENCES)
#-----------------------------------------------------------------------------
# Utilities
#-----------------------------------------------------------------------------
# FIXME: These are general-purpose utilities that later can be moved to the
# general ward. Kept here for now because we're being very strict about test
# coverage with this code, and this lets us ensure that we keep 100% coverage
# while developing.
# compiled regexps for autoindent management
dedent_re = re.compile('|'.join([
r'^\s+raise(\s.*)?$', # raise statement (+ space + other stuff, maybe)
r'^\s+raise\([^\)]*\).*$', # wacky raise with immediate open paren
r'^\s+return(\s.*)?$', # normal return (+ space + other stuff, maybe)
r'^\s+return\([^\)]*\).*$', # wacky return with immediate open paren
r'^\s+pass\s*$', # pass (optionally followed by trailing spaces)
r'^\s+break\s*$', # break (optionally followed by trailing spaces)
r'^\s+continue\s*$', # continue (optionally followed by trailing spaces)
]))
ini_spaces_re = re.compile(r'^([ \t\r\f\v]+)')
# regexp to match pure comment lines so we don't accidentally insert 'if 1:'
# before pure comments
comment_line_re = re.compile(r'^\s*\#')
def num_ini_spaces(s):
"""Return the number of initial spaces in a string.
Note that tabs are counted as a single space. For now, we do *not* support
mixing of tabs and spaces in the user's input.
Parameters
----------
s : string
Returns
-------
n : int
"""
ini_spaces = ini_spaces_re.match(s)
if ini_spaces:
return ini_spaces.end()
else:
return 0
# Fake token types for partial_tokenize:
INCOMPLETE_STRING = tokenize.N_TOKENS
IN_MULTILINE_STATEMENT = tokenize.N_TOKENS + 1
# The 2 classes below have the same API as TokenInfo, but don't try to look up
# a token type name that they won't find.
class IncompleteString:
type = exact_type = INCOMPLETE_STRING
def __init__(self, s, start, end, line):
self.s = s
self.start = start
self.end = end
self.line = line
class InMultilineStatement:
type = exact_type = IN_MULTILINE_STATEMENT
def __init__(self, pos, line):
self.s = ''
self.start = self.end = pos
self.line = line
def partial_tokens(s):
"""Iterate over tokens from a possibly-incomplete string of code.
This adds two special token types: INCOMPLETE_STRING and
IN_MULTILINE_STATEMENT. These can only occur as the last token yielded, and
represent the two main ways for code to be incomplete.
"""
readline = io.StringIO(s).readline
token = tokenize.TokenInfo(tokenize.NEWLINE, '', (1, 0), (1, 0), '')
try:
for token in tokenize.generate_tokens(readline):
yield token
except tokenize.TokenError as e:
# catch EOF error
lines = s.splitlines(keepends=True)
end = len(lines), len(lines[-1])
if 'multi-line string' in e.args[0]:
l, c = start = token.end
s = lines[l-1][c:] + ''.join(lines[l:])
yield IncompleteString(s, start, end, lines[-1])
elif 'multi-line statement' in e.args[0]:
yield InMultilineStatement(end, lines[-1])
else:
raise
def find_next_indent(code):
"""Find the number of spaces for the next line of indentation"""
tokens = list(partial_tokens(code))
if tokens[-1].type == tokenize.ENDMARKER:
tokens.pop()
if not tokens:
return 0
while (tokens[-1].type in {tokenize.DEDENT, tokenize.NEWLINE, tokenize.COMMENT}):
tokens.pop()
if tokens[-1].type == INCOMPLETE_STRING:
# Inside a multiline string
return 0
# Find the indents used before
prev_indents = [0]
def _add_indent(n):
if n != prev_indents[-1]:
prev_indents.append(n)
tokiter = iter(tokens)
for tok in tokiter:
if tok.type in {tokenize.INDENT, tokenize.DEDENT}:
_add_indent(tok.end[1])
elif (tok.type == tokenize.NL):
try:
_add_indent(next(tokiter).start[1])
except StopIteration:
break
last_indent = prev_indents.pop()
# If we've just opened a multiline statement (e.g. 'a = ['), indent more
if tokens[-1].type == IN_MULTILINE_STATEMENT:
if tokens[-2].exact_type in {tokenize.LPAR, tokenize.LSQB, tokenize.LBRACE}:
return last_indent + 4
return last_indent
if tokens[-1].exact_type == tokenize.COLON:
# Line ends with colon - indent
return last_indent + 4
if last_indent:
# Examine the last line for dedent cues - statements like return or
# raise which normally end a block of code.
last_line_starts = 0
for i, tok in enumerate(tokens):
if tok.type == tokenize.NEWLINE:
last_line_starts = i + 1
last_line_tokens = tokens[last_line_starts:]
names = [t.string for t in last_line_tokens if t.type == tokenize.NAME]
if names and names[0] in {'raise', 'return', 'pass', 'break', 'continue'}:
# Find the most recent indentation less than the current level
for indent in reversed(prev_indents):
if indent < last_indent:
return indent
return last_indent
def last_blank(src):
"""Determine if the input source ends in a blank.
A blank is either a newline or a line consisting of whitespace.
Parameters
----------
src : string
A single or multiline string.
"""
if not src: return False
ll = src.splitlines()[-1]
return (ll == '') or ll.isspace()
last_two_blanks_re = re.compile(r'\n\s*\n\s*$', re.MULTILINE)
last_two_blanks_re2 = re.compile(r'.+\n\s*\n\s+$', re.MULTILINE)
def last_two_blanks(src):
"""Determine if the input source ends in two blanks.
A blank is either a newline or a line consisting of whitespace.
Parameters
----------
src : string
A single or multiline string.
"""
if not src: return False
# The logic here is tricky: I couldn't get a regexp to work and pass all
# the tests, so I took a different approach: split the source by lines,
# grab the last two and prepend '###\n' as a stand-in for whatever was in
# the body before the last two lines. Then, with that structure, it's
# possible to analyze with two regexps. Not the most elegant solution, but
# it works. If anyone tries to change this logic, make sure to validate
# the whole test suite first!
new_src = '\n'.join(['###\n'] + src.splitlines()[-2:])
return (bool(last_two_blanks_re.match(new_src)) or
bool(last_two_blanks_re2.match(new_src)) )
def remove_comments(src):
"""Remove all comments from input source.
Note: comments are NOT recognized inside of strings!
Parameters
----------
src : string
A single or multiline input string.
Returns
-------
String with all Python comments removed.
"""
return re.sub('#.*', '', src)
def get_input_encoding():
"""Return the default standard input encoding.
If sys.stdin has no encoding, 'ascii' is returned."""
# There are strange environments for which sys.stdin.encoding is None. We
# ensure that a valid encoding is returned.
encoding = getattr(sys.stdin, 'encoding', None)
if encoding is None:
encoding = 'ascii'
return encoding
#-----------------------------------------------------------------------------
# Classes and functions for normal Python syntax handling
#-----------------------------------------------------------------------------
class InputSplitter(object):
r"""An object that can accumulate lines of Python source before execution.
This object is designed to be fed python source line-by-line, using
:meth:`push`. It will return on each push whether the currently pushed
code could be executed already. In addition, it provides a method called
:meth:`push_accepts_more` that can be used to query whether more input
can be pushed into a single interactive block.
This is a simple example of how an interactive terminal-based client can use
this tool::
isp = InputSplitter()
while isp.push_accepts_more():
indent = ' '*isp.indent_spaces
prompt = '>>> ' + indent
line = indent + raw_input(prompt)
isp.push(line)
print 'Input source was:\n', isp.source_reset(),
"""
# A cache for storing the current indentation
# The first value stores the most recently processed source input
# The second value is the number of spaces for the current indentation
# If self.source matches the first value, the second value is a valid
# current indentation. Otherwise, the cache is invalid and the indentation
# must be recalculated.
_indent_spaces_cache = None, None
# String, indicating the default input encoding. It is computed by default
# at initialization time via get_input_encoding(), but it can be reset by a
# client with specific knowledge of the encoding.
encoding = ''
# String where the current full source input is stored, properly encoded.
# Reading this attribute is the normal way of querying the currently pushed
# source code, that has been properly encoded.
source = ''
# Code object corresponding to the current source. It is automatically
# synced to the source, so it can be queried at any time to obtain the code
# object; it will be None if the source doesn't compile to valid Python.
code = None
# Private attributes
# List with lines of input accumulated so far
_buffer = None
# Command compiler
_compile = None
# Boolean indicating whether the current block is complete
_is_complete = None
# Boolean indicating whether the current block has an unrecoverable syntax error
_is_invalid = False
def __init__(self):
"""Create a new InputSplitter instance.
"""
self._buffer = []
self._compile = codeop.CommandCompiler()
self.encoding = get_input_encoding()
def reset(self):
"""Reset the input buffer and associated state."""
self._buffer[:] = []
self.source = ''
self.code = None
self._is_complete = False
self._is_invalid = False
def source_reset(self):
"""Return the input source and perform a full reset.
"""
out = self.source
self.reset()
return out
def check_complete(self, source):
"""Return whether a block of code is ready to execute, or should be continued
This is a non-stateful API, and will reset the state of this InputSplitter.
Parameters
----------
source : string
Python input code, which can be multiline.
Returns
-------
status : str
One of 'complete', 'incomplete', or 'invalid' if source is not a
prefix of valid code.
indent_spaces : int or None
The number of spaces by which to indent the next line of code. If
status is not 'incomplete', this is None.
"""
self.reset()
try:
self.push(source)
except SyntaxError:
# Transformers in IPythonInputSplitter can raise SyntaxError,
# which push() will not catch.
return 'invalid', None
else:
if self._is_invalid:
return 'invalid', None
elif self.push_accepts_more():
return 'incomplete', self.get_indent_spaces()
else:
return 'complete', None
finally:
self.reset()
def push(self, lines:str) -> bool:
"""Push one or more lines of input.
This stores the given lines and returns a status code indicating
whether the code forms a complete Python block or not.
Any exceptions generated in compilation are swallowed, but if an
exception was produced, the method returns True.
Parameters
----------
lines : string
One or more lines of Python input.
Returns
-------
is_complete : boolean
True if the current input source (the result of the current input
plus prior inputs) forms a complete Python execution block. Note that
this value is also stored as a private attribute (``_is_complete``), so it
can be queried at any time.
"""
assert isinstance(lines, str)
self._store(lines)
source = self.source
# Before calling _compile(), reset the code object to None so that if an
# exception is raised in compilation, we don't mislead by having
# inconsistent code/source attributes.
self.code, self._is_complete = None, None
self._is_invalid = False
# Honor termination lines properly
if source.endswith('\\\n'):
return False
try:
with warnings.catch_warnings():
warnings.simplefilter('error', SyntaxWarning)
self.code = self._compile(source, symbol="exec")
# Invalid syntax can produce any of a number of different errors from
# inside the compiler, so we have to catch them all. Syntax errors
# immediately produce a 'ready' block, so the invalid Python can be
# sent to the kernel for evaluation with possible ipython
# special-syntax conversion.
except (SyntaxError, OverflowError, ValueError, TypeError,
MemoryError, SyntaxWarning):
self._is_complete = True
self._is_invalid = True
else:
# Compilation didn't produce any exceptions (though it may not have
# given a complete code object)
self._is_complete = self.code is not None
return self._is_complete
def push_accepts_more(self):
"""Return whether a block of interactive input can accept more input.
This method is meant to be used by line-oriented frontends, who need to
guess whether a block is complete or not based solely on prior and
current input lines. The InputSplitter considers it has a complete
interactive block and will not accept more input when either:
* A SyntaxError is raised
* The code is complete and consists of a single line or a single
non-compound statement
* The code is complete and has a blank line at the end
If the current input produces a syntax error, this method immediately
returns False but does *not* raise the syntax error exception, as
typically clients will want to send invalid syntax to an execution
backend which might convert the invalid syntax into valid Python via
one of the dynamic IPython mechanisms.
"""
# With incomplete input, unconditionally accept more
# A syntax error also sets _is_complete to True - see push()
if not self._is_complete:
#print("Not complete") # debug
return True
# The user can make any (complete) input execute by leaving a blank line
last_line = self.source.splitlines()[-1]
if (not last_line) or last_line.isspace():
#print("Blank line") # debug
return False
# If there's just a single line or AST node, and we're flush left, as is
# the case after a simple statement such as 'a=1', we want to execute it
# straight away.
if self.get_indent_spaces() == 0:
if len(self.source.splitlines()) <= 1:
return False
try:
code_ast = ast.parse(u''.join(self._buffer))
except Exception:
#print("Can't parse AST") # debug
return False
else:
if len(code_ast.body) == 1 and \
not hasattr(code_ast.body[0], 'body'):
#print("Simple statement") # debug
return False
# General fallback - accept more code
return True
def get_indent_spaces(self):
sourcefor, n = self._indent_spaces_cache
if sourcefor == self.source:
return n
# self.source always has a trailing newline
n = find_next_indent(self.source[:-1])
self._indent_spaces_cache = (self.source, n)
return n
# Backwards compatibility. I think all code that used .indent_spaces was
# inside IPython, but we can leave this here until IPython 7 in case any
# other modules are using it. -TK, November 2017
indent_spaces = property(get_indent_spaces)
def _store(self, lines, buffer=None, store='source'):
"""Store one or more lines of input.
If input lines are not newline-terminated, a newline is automatically
appended."""
if buffer is None:
buffer = self._buffer
if lines.endswith('\n'):
buffer.append(lines)
else:
buffer.append(lines+'\n')
setattr(self, store, self._set_source(buffer))
def _set_source(self, buffer):
return u''.join(buffer)
class IPythonInputSplitter(InputSplitter):
"""An input splitter that recognizes all of IPython's special syntax."""
# String with raw, untransformed input.
source_raw = ''
# Flag to track when a transformer has stored input that it hasn't given
# back yet.
transformer_accumulating = False
# Flag to track when assemble_python_lines has stored input that it hasn't
# given back yet.
within_python_line = False
# Private attributes
# List with lines of raw input accumulated so far.
_buffer_raw = None
def __init__(self, line_input_checker=True, physical_line_transforms=None,
logical_line_transforms=None, python_line_transforms=None):
super(IPythonInputSplitter, self).__init__()
self._buffer_raw = []
self._validate = True
if physical_line_transforms is not None:
self.physical_line_transforms = physical_line_transforms
else:
self.physical_line_transforms = [
leading_indent(),
classic_prompt(),
ipy_prompt(),
cellmagic(end_on_blank_line=line_input_checker),
]
self.assemble_logical_lines = assemble_logical_lines()
if logical_line_transforms is not None:
self.logical_line_transforms = logical_line_transforms
else:
self.logical_line_transforms = [
help_end(),
escaped_commands(),
assign_from_magic(),
assign_from_system(),
]
self.assemble_python_lines = assemble_python_lines()
if python_line_transforms is not None:
self.python_line_transforms = python_line_transforms
else:
# We don't use any of these at present
self.python_line_transforms = []
@property
def transforms(self):
"Quick access to all transformers."
return self.physical_line_transforms + \
[self.assemble_logical_lines] + self.logical_line_transforms + \
[self.assemble_python_lines] + self.python_line_transforms
@property
def transforms_in_use(self):
"""Transformers, excluding logical line transformers if we're in a
Python line."""
t = self.physical_line_transforms[:]
if not self.within_python_line:
t += [self.assemble_logical_lines] + self.logical_line_transforms
return t + [self.assemble_python_lines] + self.python_line_transforms
def reset(self):
"""Reset the input buffer and associated state."""
super(IPythonInputSplitter, self).reset()
self._buffer_raw[:] = []
self.source_raw = ''
self.transformer_accumulating = False
self.within_python_line = False
for t in self.transforms:
try:
t.reset()
except SyntaxError:
# Nothing that calls reset() expects to handle transformer
# errors
pass
def flush_transformers(self):
def _flush(transform, outs):
"""yield transformed lines
always strings, never None
transform: the current transform
outs: an iterable of previously transformed inputs.
Each may be multiline, which will be passed
one line at a time to transform.
"""
for out in outs:
for line in out.splitlines():
# push one line at a time
tmp = transform.push(line)
if tmp is not None:
yield tmp
# reset the transform
tmp = transform.reset()
if tmp is not None:
yield tmp
out = []
for t in self.transforms_in_use:
out = _flush(t, out)
out = list(out)
if out:
self._store('\n'.join(out))
def raw_reset(self):
"""Return raw input only and perform a full reset.
"""
out = self.source_raw
self.reset()
return out
def source_reset(self):
try:
self.flush_transformers()
return self.source
finally:
self.reset()
def push_accepts_more(self):
if self.transformer_accumulating:
return True
else:
return super(IPythonInputSplitter, self).push_accepts_more()
def transform_cell(self, cell):
"""Process and translate a cell of input.
"""
self.reset()
try:
self.push(cell)
self.flush_transformers()
return self.source
finally:
self.reset()
def push(self, lines:str) -> bool:
"""Push one or more lines of IPython input.
This stores the given lines and returns a status code indicating
whether the code forms a complete Python block or not, after processing
all input lines for special IPython syntax.
Any exceptions generated in compilation are swallowed, but if an
exception was produced, the method returns True.
Parameters
----------
lines : string
One or more lines of Python input.
Returns
-------
is_complete : boolean
True if the current input source (the result of the current input
plus prior inputs) forms a complete Python execution block. Note that
this value is also stored as a private attribute (_is_complete), so it
can be queried at any time.
"""
assert isinstance(lines, str)
# We must ensure all input is pure unicode
# ''.splitlines() --> [], but we need to push the empty line to transformers
lines_list = lines.splitlines()
if not lines_list:
lines_list = ['']
# Store raw source before applying any transformations to it. Note
# that this must be done *after* the reset() call that would otherwise
# flush the buffer.
self._store(lines, self._buffer_raw, 'source_raw')
transformed_lines_list = []
for line in lines_list:
transformed = self._transform_line(line)
if transformed is not None:
transformed_lines_list.append(transformed)
if transformed_lines_list:
transformed_lines = '\n'.join(transformed_lines_list)
return super(IPythonInputSplitter, self).push(transformed_lines)
else:
# Got nothing back from transformers - they must be waiting for
# more input.
return False
def _transform_line(self, line):
"""Push a line of input code through the various transformers.
Returns any output from the transformers, or None if a transformer
is accumulating lines.
Sets self.transformer_accumulating as a side effect.
"""
def _accumulating(dbg):
#print(dbg)
self.transformer_accumulating = True
return None
for transformer in self.physical_line_transforms:
line = transformer.push(line)
if line is None:
return _accumulating(transformer)
if not self.within_python_line:
line = self.assemble_logical_lines.push(line)
if line is None:
return _accumulating('acc logical line')
for transformer in self.logical_line_transforms:
line = transformer.push(line)
if line is None:
return _accumulating(transformer)
line = self.assemble_python_lines.push(line)
if line is None:
self.within_python_line = True
return _accumulating('acc python line')
else:
self.within_python_line = False
for transformer in self.python_line_transforms:
line = transformer.push(line)
if line is None:
return _accumulating(transformer)
#print("transformers clear") #debug
self.transformer_accumulating = False
return line
|
mit
|
[
624,
25832,
26,
6924,
7252,
436,
13315,
28540,
14,
199,
199,
2765,
859,
1990,
5906,
315,
16243,
1520,
14,
16,
12,
315,
289,
1214,
567,
402,
1324,
19754,
18,
14,
199,
199,
1918,
1642,
1021,
315,
642,
859,
12,
520,
533,
1705,
3205,
26407,
3559,
365,
19829,
370,
11480,
1380,
199,
1210,
687,
282,
1004,
13,
16039,
287,
471,
22523,
365,
4890,
436,
1077,
506,
7934,
12,
436,
1380,
199,
1589,
922,
1077,
506,
21652,
471,
367,
4573,
1004,
402,
1233,
3140,
14,
710,
536,
283,
1210,
199,
25234,
7,
365,
7031,
590,
367,
32530,
14872,
14,
199,
199,
33,
1013,
32012,
12,
520,
533,
1705,
1772,
11361,
3205,
26407,
3559,
6571,
314,
2011,
9330,
1325,
199,
1045,
2615,
2291,
367,
314,
9243,
16243,
6302,
334,
5615,
2932,
12,
2656,
4882,
12,
5423,
680,
199,
1918,
1233,
370,
5965,
886,
3520,
25947,
365,
315,
520,
1494,
1705,
1772,
11361,
14,
1018,
14,
1210,
19754,
2313,
199,
26,
533,
1705,
1772,
11361,
3205,
26407,
64,
22295,
314,
3066,
1233,
370,
314,
1752,
22932,
315,
1865,
199,
460,
14086,
314,
2058,
14,
199,
199,
1858,
1655,
2436,
12,
1937,
314,
1021,
20964,
5084,
14,
199,
624,
199,
199,
504,
3598,
492,
7987,
199,
199,
4050,
360,
1772,
11361,
14,
1018,
14,
1210,
25234,
365,
5906,
3967,
16243,
1520,
315,
17914,
402,
658,
1772,
11361,
14,
1018,
14,
1210,
19754,
18,
30880,
1362,
13413,
9,
199,
199,
3,
1898,
334,
67,
9,
16243,
15290,
11682,
14,
199,
3,
17484,
1334,
314,
2895,
402,
314,
22016,
6289,
844,
14,
199,
646,
6073,
199,
646,
1233,
411,
199,
646,
5890,
199,
646,
295,
199,
646,
984,
199,
646,
13343,
199,
646,
3598,
199,
199,
504,
16243,
14,
1018,
14,
1210,
19754,
492,
334,
16812,
63,
3724,
12,
5644,
31205,
63,
7650,
12,
5644,
284,
647,
63,
7650,
12,
5644,
4917,
11523,
12,
5644,
22931,
63,
7954,
63,
1278,
12,
5644,
1720,
63,
500,
12,
5644,
11077,
63,
4405,
12,
5644,
5090,
63,
504,
63,
11523,
12,
5644,
5090,
63,
504,
63,
2253,
12,
5644,
22931,
63,
1548,
63,
1278,
12,
5644,
776,
199,
199,
3,
5723,
787,
2808,
315,
642,
859,
367,
8552,
7163,
14,
199,
504,
16243,
14,
1018,
14,
1210,
19754,
492,
334,
654,
35,
63,
29085,
12,
10427,
35,
63,
3234,
63,
8549,
12,
10427,
35,
63,
17930,
12,
3147,
10427,
35,
63,
17930,
18,
12,
10427,
35,
63,
19973,
12,
10427,
35,
63,
19973,
18,
12,
3147,
10427,
35,
63,
18495,
12,
10427,
35,
63,
18495,
18,
12,
10427,
35,
63,
22169,
12,
10427,
35,
63,
7326,
22243,
9,
199,
199,
18045,
199,
3,
738,
17933,
199,
18045,
199,
199,
3,
7600,
26,
5723,
787,
8605,
13,
22615,
15841,
626,
2945,
883,
506,
12155,
370,
314,
199,
3,
8605,
336,
1005,
14,
221,
25645,
541,
2348,
367,
3063,
2952,
781,
3984,
3769,
7437,
7478,
3595,
511,
199,
3,
11745,
543,
642,
1233,
12,
436,
642,
19083,
2739,
4868,
626,
781,
4215,
2948,
5,
11745,
199,
3,
1830,
477,
3419,
4073,
14,
199,
199,
3,
10311,
5163,
1190,
367,
2599,
3724,
10041,
199,
14674,
63,
264,
275,
295,
14,
2014,
20137,
1370,
904,
779,
272,
519,
15542,
83,
11,
3730,
2961,
83,
2795,
5547,
4268,
327,
746,
5164,
334,
11,
4601,
435,
1163,
8292,
12,
11703,
9,
272,
519,
15542,
83,
11,
3730,
60,
21690,
1874,
7590,
680,
32125,
327,
336,
564,
89,
746,
543,
8569,
1551,
13566,
272,
519,
15542,
83,
11,
1107,
2961,
83,
2795,
5547,
4268,
327,
3293,
372,
334,
11,
4601,
435,
1163,
8292,
12,
11703,
9,
272,
519,
15542,
83,
11,
1107,
60,
21690,
1874,
7590,
680,
32125,
327,
336,
564,
89,
372,
543,
8569,
1551,
13566,
272,
519,
15542,
83,
11,
1529,
60,
83,
32125,
327,
986,
334,
1422,
1183,
9437,
701,
8520,
7883,
9,
272,
519,
15542,
83,
11,
4785,
60,
83,
32125,
327,
2059,
334,
1422,
1183,
9437,
701,
8520,
7883,
9,
272,
519,
15542,
83,
11,
6958,
60,
83,
32125,
327,
1980,
334,
1422,
1183,
9437,
701,
8520,
7883,
9,
199,
2459,
199,
2730,
63,
10749,
63,
264,
275,
295,
14,
2014,
8,
82,
4289,
779,
971,
84,
60,
82,
60,
70,
60,
86,
2807,
5942,
199,
199,
3,
13156,
370,
1336,
15111,
3721,
2385,
880,
781,
2793,
1133,
24634,
1183,
5518,
283,
692,
413,
4881,
199,
3,
2544,
15111,
6786,
199,
3349,
63,
604,
63,
264,
275,
295,
14,
2014,
8,
82,
15542,
83,
7590,
3,
358,
421,
199,
318,
1967,
63,
2730,
63,
10749,
8,
83,
304,
272,
408,
1767,
314,
1329,
402,
2536,
7883,
315,
282,
1059,
14,
339,
3390,
626,
12187,
787,
31662,
465,
282,
2849,
4601,
14,
221,
2104,
3063,
12,
781,
886,
627,
1397,
10,
2291,
272,
13667,
316,
402,
12187,
436,
7883,
315,
314,
922,
1159,
1324,
14,
339,
3897,
272,
4143,
272,
308,
520,
1059,
339,
1803,
272,
5514,
272,
302,
520,
1109,
272,
408,
339,
20364,
63,
10749,
275,
20364,
63,
10749,
63,
264,
14,
1431,
8,
83,
9,
272,
340,
20364,
63,
10749,
26,
267,
372,
20364,
63,
10749,
14,
500,
342,
272,
587,
26,
267,
372,
378,
199,
199,
3,
7777,
1526,
2943,
367,
7417,
63,
15246,
26,
199,
568,
15558,
63,
5353,
275,
13343,
14,
46,
63,
8803,
51,
199,
568,
63,
16661,
63,
6689,
4479,
275,
13343,
14,
46,
63,
8803,
51,
435,
413,
199,
199,
3,
710,
499,
3992,
5084,
1172,
314,
2011,
3261,
465,
8767,
2354,
12,
1325,
2793,
1133,
862,
370,
3648,
1536,
199,
3,
282,
1526,
730,
536,
626,
2985,
7859,
1133,
2342,
14,
199,
533,
1010,
4883,
1558,
26,
272,
730,
275,
5835,
63,
466,
275,
1621,
15558,
63,
5353,
272,
347,
636,
826,
721,
277,
12,
308,
12,
1343,
12,
1284,
12,
1004,
304,
267,
291,
14,
83,
275,
308,
267,
291,
14,
928,
275,
1343,
267,
291,
14,
500,
275,
1284,
267,
291,
14,
604,
275,
1004,
199,
199,
533,
1010,
18933,
15173,
26,
272,
730,
275,
5835,
63,
466,
275,
1621,
63,
16661,
63,
6689,
4479,
272,
347,
636,
826,
721,
277,
12,
2086,
12,
1004,
304,
267,
291,
14,
83,
275,
2125,
267,
291,
14,
928,
275,
291,
14,
500,
275,
2086,
267,
291,
14
] |
[
25832,
26,
6924,
7252,
436,
13315,
28540,
14,
199,
199,
2765,
859,
1990,
5906,
315,
16243,
1520,
14,
16,
12,
315,
289,
1214,
567,
402,
1324,
19754,
18,
14,
199,
199,
1918,
1642,
1021,
315,
642,
859,
12,
520,
533,
1705,
3205,
26407,
3559,
365,
19829,
370,
11480,
1380,
199,
1210,
687,
282,
1004,
13,
16039,
287,
471,
22523,
365,
4890,
436,
1077,
506,
7934,
12,
436,
1380,
199,
1589,
922,
1077,
506,
21652,
471,
367,
4573,
1004,
402,
1233,
3140,
14,
710,
536,
283,
1210,
199,
25234,
7,
365,
7031,
590,
367,
32530,
14872,
14,
199,
199,
33,
1013,
32012,
12,
520,
533,
1705,
1772,
11361,
3205,
26407,
3559,
6571,
314,
2011,
9330,
1325,
199,
1045,
2615,
2291,
367,
314,
9243,
16243,
6302,
334,
5615,
2932,
12,
2656,
4882,
12,
5423,
680,
199,
1918,
1233,
370,
5965,
886,
3520,
25947,
365,
315,
520,
1494,
1705,
1772,
11361,
14,
1018,
14,
1210,
19754,
2313,
199,
26,
533,
1705,
1772,
11361,
3205,
26407,
64,
22295,
314,
3066,
1233,
370,
314,
1752,
22932,
315,
1865,
199,
460,
14086,
314,
2058,
14,
199,
199,
1858,
1655,
2436,
12,
1937,
314,
1021,
20964,
5084,
14,
199,
624,
199,
199,
504,
3598,
492,
7987,
199,
199,
4050,
360,
1772,
11361,
14,
1018,
14,
1210,
25234,
365,
5906,
3967,
16243,
1520,
315,
17914,
402,
658,
1772,
11361,
14,
1018,
14,
1210,
19754,
18,
30880,
1362,
13413,
9,
199,
199,
3,
1898,
334,
67,
9,
16243,
15290,
11682,
14,
199,
3,
17484,
1334,
314,
2895,
402,
314,
22016,
6289,
844,
14,
199,
646,
6073,
199,
646,
1233,
411,
199,
646,
5890,
199,
646,
295,
199,
646,
984,
199,
646,
13343,
199,
646,
3598,
199,
199,
504,
16243,
14,
1018,
14,
1210,
19754,
492,
334,
16812,
63,
3724,
12,
5644,
31205,
63,
7650,
12,
5644,
284,
647,
63,
7650,
12,
5644,
4917,
11523,
12,
5644,
22931,
63,
7954,
63,
1278,
12,
5644,
1720,
63,
500,
12,
5644,
11077,
63,
4405,
12,
5644,
5090,
63,
504,
63,
11523,
12,
5644,
5090,
63,
504,
63,
2253,
12,
5644,
22931,
63,
1548,
63,
1278,
12,
5644,
776,
199,
199,
3,
5723,
787,
2808,
315,
642,
859,
367,
8552,
7163,
14,
199,
504,
16243,
14,
1018,
14,
1210,
19754,
492,
334,
654,
35,
63,
29085,
12,
10427,
35,
63,
3234,
63,
8549,
12,
10427,
35,
63,
17930,
12,
3147,
10427,
35,
63,
17930,
18,
12,
10427,
35,
63,
19973,
12,
10427,
35,
63,
19973,
18,
12,
3147,
10427,
35,
63,
18495,
12,
10427,
35,
63,
18495,
18,
12,
10427,
35,
63,
22169,
12,
10427,
35,
63,
7326,
22243,
9,
199,
199,
18045,
199,
3,
738,
17933,
199,
18045,
199,
199,
3,
7600,
26,
5723,
787,
8605,
13,
22615,
15841,
626,
2945,
883,
506,
12155,
370,
314,
199,
3,
8605,
336,
1005,
14,
221,
25645,
541,
2348,
367,
3063,
2952,
781,
3984,
3769,
7437,
7478,
3595,
511,
199,
3,
11745,
543,
642,
1233,
12,
436,
642,
19083,
2739,
4868,
626,
781,
4215,
2948,
5,
11745,
199,
3,
1830,
477,
3419,
4073,
14,
199,
199,
3,
10311,
5163,
1190,
367,
2599,
3724,
10041,
199,
14674,
63,
264,
275,
295,
14,
2014,
20137,
1370,
904,
779,
272,
519,
15542,
83,
11,
3730,
2961,
83,
2795,
5547,
4268,
327,
746,
5164,
334,
11,
4601,
435,
1163,
8292,
12,
11703,
9,
272,
519,
15542,
83,
11,
3730,
60,
21690,
1874,
7590,
680,
32125,
327,
336,
564,
89,
746,
543,
8569,
1551,
13566,
272,
519,
15542,
83,
11,
1107,
2961,
83,
2795,
5547,
4268,
327,
3293,
372,
334,
11,
4601,
435,
1163,
8292,
12,
11703,
9,
272,
519,
15542,
83,
11,
1107,
60,
21690,
1874,
7590,
680,
32125,
327,
336,
564,
89,
372,
543,
8569,
1551,
13566,
272,
519,
15542,
83,
11,
1529,
60,
83,
32125,
327,
986,
334,
1422,
1183,
9437,
701,
8520,
7883,
9,
272,
519,
15542,
83,
11,
4785,
60,
83,
32125,
327,
2059,
334,
1422,
1183,
9437,
701,
8520,
7883,
9,
272,
519,
15542,
83,
11,
6958,
60,
83,
32125,
327,
1980,
334,
1422,
1183,
9437,
701,
8520,
7883,
9,
199,
2459,
199,
2730,
63,
10749,
63,
264,
275,
295,
14,
2014,
8,
82,
4289,
779,
971,
84,
60,
82,
60,
70,
60,
86,
2807,
5942,
199,
199,
3,
13156,
370,
1336,
15111,
3721,
2385,
880,
781,
2793,
1133,
24634,
1183,
5518,
283,
692,
413,
4881,
199,
3,
2544,
15111,
6786,
199,
3349,
63,
604,
63,
264,
275,
295,
14,
2014,
8,
82,
15542,
83,
7590,
3,
358,
421,
199,
318,
1967,
63,
2730,
63,
10749,
8,
83,
304,
272,
408,
1767,
314,
1329,
402,
2536,
7883,
315,
282,
1059,
14,
339,
3390,
626,
12187,
787,
31662,
465,
282,
2849,
4601,
14,
221,
2104,
3063,
12,
781,
886,
627,
1397,
10,
2291,
272,
13667,
316,
402,
12187,
436,
7883,
315,
314,
922,
1159,
1324,
14,
339,
3897,
272,
4143,
272,
308,
520,
1059,
339,
1803,
272,
5514,
272,
302,
520,
1109,
272,
408,
339,
20364,
63,
10749,
275,
20364,
63,
10749,
63,
264,
14,
1431,
8,
83,
9,
272,
340,
20364,
63,
10749,
26,
267,
372,
20364,
63,
10749,
14,
500,
342,
272,
587,
26,
267,
372,
378,
199,
199,
3,
7777,
1526,
2943,
367,
7417,
63,
15246,
26,
199,
568,
15558,
63,
5353,
275,
13343,
14,
46,
63,
8803,
51,
199,
568,
63,
16661,
63,
6689,
4479,
275,
13343,
14,
46,
63,
8803,
51,
435,
413,
199,
199,
3,
710,
499,
3992,
5084,
1172,
314,
2011,
3261,
465,
8767,
2354,
12,
1325,
2793,
1133,
862,
370,
3648,
1536,
199,
3,
282,
1526,
730,
536,
626,
2985,
7859,
1133,
2342,
14,
199,
533,
1010,
4883,
1558,
26,
272,
730,
275,
5835,
63,
466,
275,
1621,
15558,
63,
5353,
272,
347,
636,
826,
721,
277,
12,
308,
12,
1343,
12,
1284,
12,
1004,
304,
267,
291,
14,
83,
275,
308,
267,
291,
14,
928,
275,
1343,
267,
291,
14,
500,
275,
1284,
267,
291,
14,
604,
275,
1004,
199,
199,
533,
1010,
18933,
15173,
26,
272,
730,
275,
5835,
63,
466,
275,
1621,
63,
16661,
63,
6689,
4479,
272,
347,
636,
826,
721,
277,
12,
2086,
12,
1004,
304,
267,
291,
14,
83,
275,
2125,
267,
291,
14,
928,
275,
291,
14,
500,
275,
2086,
267,
291,
14,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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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
] |
ShaneHarvey/mongo-python-driver
|
pymongo/driver_info.py
|
2
|
1596
|
# Copyright 2018-present MongoDB, 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.
"""Advanced options for MongoDB drivers implemented on top of PyMongo."""
from collections import namedtuple
class DriverInfo(namedtuple('DriverInfo', ['name', 'version', 'platform'])):
"""Info about a driver wrapping PyMongo.
The MongoDB server logs PyMongo's name, version, and platform whenever
PyMongo establishes a connection. A driver implemented on top of PyMongo
can add its own info to this log message. Initialize with three strings
like 'MyDriver', '1.2.3', 'some platform info'. Any of these strings may be
None to accept PyMongo's default.
"""
def __new__(cls, name=None, version=None, platform=None):
self = super(DriverInfo, cls).__new__(cls, name, version, platform)
for key, value in self._asdict().items():
if value is not None and not isinstance(value, str):
raise TypeError("Wrong type for DriverInfo %s option, value "
"must be an instance of str" % (key,))
return self
|
apache-2.0
|
[
3,
1898,
14894,
13,
1881,
28458,
12,
3277,
14,
199,
3,
199,
3,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
1265,
199,
3,
1443,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
221,
2047,
199,
3,
1443,
3332,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
199,
3,
2428,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
199,
3,
2478,
14,
221,
1666,
314,
844,
367,
314,
2488,
2637,
4210,
199,
3,
3443,
436,
4204,
1334,
314,
844,
14,
199,
199,
624,
23613,
1511,
367,
28458,
19016,
6366,
641,
2746,
402,
1611,
20393,
1041,
199,
199,
504,
5055,
492,
12863,
421,
199,
533,
19447,
2354,
8,
18921,
360,
6158,
2354,
297,
788,
354,
297,
283,
1023,
297,
283,
3246,
26536,
272,
408,
2354,
3595,
282,
5253,
19696,
1611,
20393,
14,
339,
710,
28458,
1654,
9610,
1611,
20393,
1159,
536,
12,
1015,
12,
436,
4298,
18119,
272,
1611,
20393,
16873,
397,
282,
1950,
14,
437,
5253,
6366,
641,
2746,
402,
1611,
20393,
272,
883,
1050,
2399,
5705,
2256,
370,
642,
943,
1245,
14,
11578,
543,
7795,
3326,
272,
2839,
283,
5713,
6158,
297,
283,
17,
14,
18,
14,
19,
297,
283,
3972,
4298,
2256,
1370,
6184,
402,
3520,
3326,
1443,
506,
272,
488,
370,
4729,
1611,
20393,
1159,
849,
14,
272,
408,
272,
347,
636,
1222,
721,
1886,
12,
536,
29,
403,
12,
1015,
29,
403,
12,
4298,
29,
403,
304,
267,
291,
275,
1613,
8,
6158,
2354,
12,
843,
2843,
1222,
721,
1886,
12,
536,
12,
1015,
12,
4298,
9,
267,
367,
790,
12,
574,
315,
291,
423,
305,
807,
1252,
1744,
837,
288,
340,
574,
365,
440,
488,
436,
440,
1228,
8,
585,
12,
620,
304,
355,
746,
3146,
480,
14858,
730,
367,
19447,
2354,
450,
83,
945,
12,
574,
298,
1816,
298,
7790,
506,
376,
1256,
402,
620,
2,
450,
334,
498,
4641,
398,
372,
291,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
1898,
14894,
13,
1881,
28458,
12,
3277,
14,
199,
3,
199,
3,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
1265,
199,
3,
1443,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
221,
2047,
199,
3,
1443,
3332,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
199,
3,
2428,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
199,
3,
2478,
14,
221,
1666,
314,
844,
367,
314,
2488,
2637,
4210,
199,
3,
3443,
436,
4204,
1334,
314,
844,
14,
199,
199,
624,
23613,
1511,
367,
28458,
19016,
6366,
641,
2746,
402,
1611,
20393,
1041,
199,
199,
504,
5055,
492,
12863,
421,
199,
533,
19447,
2354,
8,
18921,
360,
6158,
2354,
297,
788,
354,
297,
283,
1023,
297,
283,
3246,
26536,
272,
408,
2354,
3595,
282,
5253,
19696,
1611,
20393,
14,
339,
710,
28458,
1654,
9610,
1611,
20393,
1159,
536,
12,
1015,
12,
436,
4298,
18119,
272,
1611,
20393,
16873,
397,
282,
1950,
14,
437,
5253,
6366,
641,
2746,
402,
1611,
20393,
272,
883,
1050,
2399,
5705,
2256,
370,
642,
943,
1245,
14,
11578,
543,
7795,
3326,
272,
2839,
283,
5713,
6158,
297,
283,
17,
14,
18,
14,
19,
297,
283,
3972,
4298,
2256,
1370,
6184,
402,
3520,
3326,
1443,
506,
272,
488,
370,
4729,
1611,
20393,
1159,
849,
14,
272,
408,
272,
347,
636,
1222,
721,
1886,
12,
536,
29,
403,
12,
1015,
29,
403,
12,
4298,
29,
403,
304,
267,
291,
275,
1613,
8,
6158,
2354,
12,
843,
2843,
1222,
721,
1886,
12,
536,
12,
1015,
12,
4298,
9,
267,
367,
790,
12,
574,
315,
291,
423,
305,
807,
1252,
1744,
837,
288,
340,
574,
365,
440,
488,
436,
440,
1228,
8,
585,
12,
620,
304,
355,
746,
3146,
480,
14858,
730,
367,
19447,
2354,
450,
83,
945,
12,
574,
298,
1816,
298,
7790,
506,
376,
1256,
402,
620,
2,
450,
334,
498,
4641,
398,
372,
291,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,
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
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
pataquets/namecoin-core
|
test/functional/wallet_keypool_topup.py
|
5
|
4373
|
#!/usr/bin/env python3
# Copyright (c) 2017-2019 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test HD Wallet keypool restore function.
Two nodes. Node1 is under test. Node0 is providing transactions and generating blocks.
- Start node1, shutdown and backup wallet.
- Generate 110 keys (enough to drain the keypool). Store key 90 (in the initial keypool) and key 110 (beyond the initial keypool). Send funds to key 90 and key 110.
- Stop node1, clear the datadir, move wallet file back into the datadir and restart node1.
- connect node1 to node0. Verify that they sync and node1 receives its funds."""
import os
import shutil
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import (
assert_equal,
)
class KeypoolRestoreTest(BitcoinTestFramework):
def set_test_params(self):
self.setup_clean_chain = True
self.num_nodes = 4
self.extra_args = [[], ['-keypool=100'], ['-keypool=100'], ['-keypool=100']]
def skip_test_if_missing_module(self):
self.skip_if_no_wallet()
def run_test(self):
wallet_path = os.path.join(self.nodes[1].datadir, self.chain, "wallets", self.default_wallet_name, self.wallet_data_filename)
wallet_backup_path = os.path.join(self.nodes[1].datadir, "wallet.bak")
self.nodes[0].generate(101)
self.log.info("Make backup of wallet")
self.stop_node(1)
shutil.copyfile(wallet_path, wallet_backup_path)
self.start_node(1, self.extra_args[1])
self.connect_nodes(0, 1)
self.connect_nodes(0, 2)
self.connect_nodes(0, 3)
for i, output_type in enumerate(["legacy", "p2sh-segwit", "bech32"]):
self.log.info("Generate keys for wallet with address type: {}".format(output_type))
idx = i+1
for _ in range(90):
addr_oldpool = self.nodes[idx].getnewaddress(address_type=output_type)
for _ in range(20):
addr_extpool = self.nodes[idx].getnewaddress(address_type=output_type)
# Make sure we're creating the outputs we expect
address_details = self.nodes[idx].validateaddress(addr_extpool)
if i == 0:
assert not address_details["isscript"] and not address_details["iswitness"]
elif i == 1:
assert address_details["isscript"] and not address_details["iswitness"]
else:
assert not address_details["isscript"] and address_details["iswitness"]
self.log.info("Send funds to wallet")
self.nodes[0].sendtoaddress(addr_oldpool, 10)
self.nodes[0].generate(1)
self.nodes[0].sendtoaddress(addr_extpool, 5)
self.nodes[0].generate(1)
self.sync_blocks()
self.log.info("Restart node with wallet backup")
self.stop_node(idx)
shutil.copyfile(wallet_backup_path, wallet_path)
self.start_node(idx, self.extra_args[idx])
self.connect_nodes(0, idx)
self.sync_all()
self.log.info("Verify keypool is restored and balance is correct")
assert_equal(self.nodes[idx].getbalance(), 15)
assert_equal(self.nodes[idx].listtransactions()[0]['category'], "receive")
# Check that we have marked all keys up to the used keypool key as used
if self.options.descriptors:
if output_type == 'legacy':
assert_equal(self.nodes[idx].getaddressinfo(self.nodes[idx].getnewaddress(address_type=output_type))['hdkeypath'], "m/44'/1'/0'/0/110")
elif output_type == 'p2sh-segwit':
assert_equal(self.nodes[idx].getaddressinfo(self.nodes[idx].getnewaddress(address_type=output_type))['hdkeypath'], "m/49'/1'/0'/0/110")
elif output_type == 'bech32':
assert_equal(self.nodes[idx].getaddressinfo(self.nodes[idx].getnewaddress(address_type=output_type))['hdkeypath'], "m/84'/1'/0'/0/110")
else:
assert_equal(self.nodes[idx].getaddressinfo(self.nodes[idx].getnewaddress(address_type=output_type))['hdkeypath'], "m/0'/0'/110'")
if __name__ == '__main__':
KeypoolRestoreTest().main()
|
mit
|
[
3381,
2647,
15,
1393,
15,
1813,
2366,
19,
199,
3,
1898,
334,
67,
9,
9708,
13,
14982,
710,
21158,
11672,
19782,
199,
3,
17484,
1334,
314,
10697,
2032,
4190,
12,
1937,
314,
23073,
199,
3,
570,
9685,
503,
1455,
921,
1544,
14,
16374,
14,
1308,
15,
2383,
15,
1147,
13,
1682,
14,
8624,
14,
199,
624,
774,
869,
36,
644,
9478,
790,
2293,
9066,
805,
14,
199,
199,
11467,
3380,
14,
5013,
17,
365,
1334,
511,
14,
5013,
16,
365,
13070,
15809,
436,
12999,
5664,
14,
199,
199,
13,
7707,
1031,
17,
12,
12842,
436,
6902,
20534,
14,
199,
13,
7958,
16814,
2883,
334,
30881,
370,
366,
6322,
314,
790,
2293,
680,
13874,
790,
9137,
334,
262,
314,
2536,
790,
2293,
9,
436,
790,
16814,
334,
1235,
17666,
314,
2536,
790,
2293,
680,
10217,
27440,
83,
370,
790,
9137,
436,
790,
16814,
14,
199,
13,
8015,
1031,
17,
12,
5436,
314,
666,
694,
12,
4057,
20534,
570,
1771,
1901,
314,
666,
694,
436,
11004,
1031,
17,
14,
199,
13,
4907,
1031,
17,
370,
1031,
16,
14,
7635,
626,
2985,
7604,
436,
1031,
17,
23192,
2399,
27440,
83,
1041,
199,
646,
747,
199,
646,
5145,
199,
199,
504,
511,
63,
4857,
14,
396,
63,
4857,
492,
21158,
26203,
199,
504,
511,
63,
4857,
14,
1974,
492,
334,
272,
702,
63,
1452,
12,
199,
9,
421,
199,
533,
2606,
2293,
21012,
774,
8,
4734,
9061,
26203,
304,
272,
347,
663,
63,
396,
63,
1162,
8,
277,
304,
267,
291,
14,
2758,
63,
3118,
63,
4429,
275,
715,
267,
291,
14,
1507,
63,
2415,
275,
841,
267,
291,
14,
2911,
63,
589,
275,
3474,
467,
11573,
498,
2293,
29,
1960,
995,
11573,
498,
2293,
29,
1960,
995,
11573,
498,
2293,
29,
1960,
6538,
339,
347,
3372,
63,
396,
63,
692,
63,
4752,
63,
578,
8,
277,
304,
267,
291,
14,
2759,
63,
692,
63,
889,
63,
13892,
342,
339,
347,
1255,
63,
396,
8,
277,
304,
267,
20534,
63,
515,
275,
747,
14,
515,
14,
904,
8,
277,
14,
2415,
59,
17,
1055,
18259,
12,
291,
14,
4429,
12,
298,
87,
4598,
1086,
401,
291,
14,
885,
63,
13892,
63,
354,
12,
291,
14,
13892,
63,
576,
63,
1501,
9,
267,
20534,
63,
5751,
63,
515,
275,
747,
14,
515,
14,
904,
8,
277,
14,
2415,
59,
17,
1055,
18259,
12,
298,
13892,
14,
27162,
531,
267,
291,
14,
2415,
59,
16,
1055,
4208,
8,
4893,
9,
398,
291,
14,
793,
14,
815,
480,
5483,
6902,
402,
20534,
531,
267,
291,
14,
2379,
63,
932,
8,
17,
9,
267,
5145,
14,
21997,
8,
13892,
63,
515,
12,
20534,
63,
5751,
63,
515,
9,
267,
291,
14,
928,
63,
932,
8,
17,
12,
291,
14,
2911,
63,
589,
59,
17,
566,
267,
291,
14,
2242,
63,
2415,
8,
16,
12,
413,
9,
267,
291,
14,
2242,
63,
2415,
8,
16,
12,
499,
9,
267,
291,
14,
2242,
63,
2415,
8,
16,
12,
650,
9,
398,
367,
284,
12,
1072,
63,
466,
315,
3874,
5234,
10000,
401,
298,
80,
18,
609,
13,
8359,
2503,
401,
298,
1235,
335,
708,
21473,
953,
291,
14,
793,
14,
815,
480,
6864,
2883,
367,
20534,
543,
2287,
730,
26,
8352,
908,
8,
1199,
63,
466,
430,
288,
4280,
275,
284,
11,
17,
288,
367,
485,
315,
1425,
8,
2710,
304,
355,
5552,
63,
1753,
2293,
275,
291,
14,
2415,
59,
2996,
1055,
21102,
8,
1562,
63,
466,
29,
1199,
63,
466,
9,
288,
367,
485,
315,
1425,
8,
1165,
304,
355,
5552,
63,
832,
2293,
275,
291,
14,
2415,
59,
2996,
1055,
21102,
8,
1562,
63,
466,
29,
1199,
63,
466,
9,
953,
327,
4155,
3238,
781,
3984,
6425,
314,
4704,
781,
4282,
288,
2287,
63,
5087,
275,
291,
14,
2415,
59,
2996,
1055,
3502,
1562,
8,
2697,
63,
832,
2293,
9,
288,
340,
284,
508,
378,
26,
355,
702,
440,
2287,
63,
5087,
905,
374,
1579,
937,
436,
440,
2287,
63,
5087,
905,
374,
22179,
937,
288,
916,
284,
508,
413,
26,
355,
702,
2287,
63,
5087,
905,
374,
1579,
937,
436,
440,
2287,
63,
5087,
905,
374,
22179,
937,
288,
587,
26,
355,
702,
440,
2287,
63,
5087,
905,
374,
1579,
937,
436,
2287,
63,
5087,
905,
374,
22179,
937,
22919,
291,
14,
793,
14,
815,
480,
6795,
27440,
83,
370,
20534,
531,
288,
291,
14,
2415,
59,
16,
1055,
23267,
1562,
8,
2697,
63,
1753,
2293,
12,
1616,
9,
288,
291,
14,
2415,
59,
16,
1055,
4208,
8,
17,
9,
288,
291,
14,
2415,
59,
16,
1055,
23267,
1562,
8,
2697,
63,
832,
2293,
12,
959,
9,
288,
291,
14,
2415,
59,
16,
1055,
4208,
8,
17,
9,
288,
291,
14,
5186,
63,
4166,
342,
953,
291,
14,
793,
14,
815,
480,
25493,
1031,
543,
20534,
6902,
531,
288,
291,
14,
2379,
63,
932,
8,
2996,
9,
288,
5145,
14,
21997,
8,
13892,
63,
5751,
63,
515,
12,
20534,
63,
515,
9,
288,
291,
14,
928,
63,
932,
8,
2996,
12,
291,
14,
2911,
63,
589,
59,
2996,
566,
288,
291,
14,
2242,
63,
2415,
8,
16,
12,
4280,
9,
288,
291,
14,
5186,
63,
452,
342,
953,
291,
14,
793,
14,
815,
480,
7496,
790,
2293,
365,
14429,
436,
14094,
365,
3211,
531,
288,
702,
63,
1452,
8,
277,
14,
2415,
59,
2996,
1055,
29213,
1062,
4114,
9,
288,
702,
63,
1452,
8,
277,
14,
2415,
59,
2996,
1055,
513,
13754,
3430,
16,
2733,
3710,
995,
298,
9391,
531,
288,
327,
2670,
626,
781,
1172,
11584,
1006,
2883,
1536,
370,
314,
1202,
790,
2293,
790,
465,
1202,
288,
340,
291,
14,
1419,
14,
17752,
26,
355,
340,
1072,
63,
466,
508,
283,
10000,
356,
490,
702,
63,
1452,
8,
277,
14,
2415,
59,
2996,
1055,
362,
1562,
815,
8,
277,
14,
2415,
59,
2996,
1055,
21102,
8,
1562,
63,
466,
29,
1199,
63,
466,
430,
459,
7952,
498,
515,
995,
298,
77,
15,
1602,
9807,
17,
9807,
16,
9807,
16,
15,
6019,
531,
355,
916,
1072,
63,
466,
508,
283,
80,
18,
609,
13,
8359,
2503,
356,
490,
702,
63,
1452,
8,
277,
14,
2415,
59,
2996,
1055,
362,
1562,
815,
8,
277,
14,
2415,
59,
2996,
1055,
21102
] |
[
2647,
15,
1393,
15,
1813,
2366,
19,
199,
3,
1898,
334,
67,
9,
9708,
13,
14982,
710,
21158,
11672,
19782,
199,
3,
17484,
1334,
314,
10697,
2032,
4190,
12,
1937,
314,
23073,
199,
3,
570,
9685,
503,
1455,
921,
1544,
14,
16374,
14,
1308,
15,
2383,
15,
1147,
13,
1682,
14,
8624,
14,
199,
624,
774,
869,
36,
644,
9478,
790,
2293,
9066,
805,
14,
199,
199,
11467,
3380,
14,
5013,
17,
365,
1334,
511,
14,
5013,
16,
365,
13070,
15809,
436,
12999,
5664,
14,
199,
199,
13,
7707,
1031,
17,
12,
12842,
436,
6902,
20534,
14,
199,
13,
7958,
16814,
2883,
334,
30881,
370,
366,
6322,
314,
790,
2293,
680,
13874,
790,
9137,
334,
262,
314,
2536,
790,
2293,
9,
436,
790,
16814,
334,
1235,
17666,
314,
2536,
790,
2293,
680,
10217,
27440,
83,
370,
790,
9137,
436,
790,
16814,
14,
199,
13,
8015,
1031,
17,
12,
5436,
314,
666,
694,
12,
4057,
20534,
570,
1771,
1901,
314,
666,
694,
436,
11004,
1031,
17,
14,
199,
13,
4907,
1031,
17,
370,
1031,
16,
14,
7635,
626,
2985,
7604,
436,
1031,
17,
23192,
2399,
27440,
83,
1041,
199,
646,
747,
199,
646,
5145,
199,
199,
504,
511,
63,
4857,
14,
396,
63,
4857,
492,
21158,
26203,
199,
504,
511,
63,
4857,
14,
1974,
492,
334,
272,
702,
63,
1452,
12,
199,
9,
421,
199,
533,
2606,
2293,
21012,
774,
8,
4734,
9061,
26203,
304,
272,
347,
663,
63,
396,
63,
1162,
8,
277,
304,
267,
291,
14,
2758,
63,
3118,
63,
4429,
275,
715,
267,
291,
14,
1507,
63,
2415,
275,
841,
267,
291,
14,
2911,
63,
589,
275,
3474,
467,
11573,
498,
2293,
29,
1960,
995,
11573,
498,
2293,
29,
1960,
995,
11573,
498,
2293,
29,
1960,
6538,
339,
347,
3372,
63,
396,
63,
692,
63,
4752,
63,
578,
8,
277,
304,
267,
291,
14,
2759,
63,
692,
63,
889,
63,
13892,
342,
339,
347,
1255,
63,
396,
8,
277,
304,
267,
20534,
63,
515,
275,
747,
14,
515,
14,
904,
8,
277,
14,
2415,
59,
17,
1055,
18259,
12,
291,
14,
4429,
12,
298,
87,
4598,
1086,
401,
291,
14,
885,
63,
13892,
63,
354,
12,
291,
14,
13892,
63,
576,
63,
1501,
9,
267,
20534,
63,
5751,
63,
515,
275,
747,
14,
515,
14,
904,
8,
277,
14,
2415,
59,
17,
1055,
18259,
12,
298,
13892,
14,
27162,
531,
267,
291,
14,
2415,
59,
16,
1055,
4208,
8,
4893,
9,
398,
291,
14,
793,
14,
815,
480,
5483,
6902,
402,
20534,
531,
267,
291,
14,
2379,
63,
932,
8,
17,
9,
267,
5145,
14,
21997,
8,
13892,
63,
515,
12,
20534,
63,
5751,
63,
515,
9,
267,
291,
14,
928,
63,
932,
8,
17,
12,
291,
14,
2911,
63,
589,
59,
17,
566,
267,
291,
14,
2242,
63,
2415,
8,
16,
12,
413,
9,
267,
291,
14,
2242,
63,
2415,
8,
16,
12,
499,
9,
267,
291,
14,
2242,
63,
2415,
8,
16,
12,
650,
9,
398,
367,
284,
12,
1072,
63,
466,
315,
3874,
5234,
10000,
401,
298,
80,
18,
609,
13,
8359,
2503,
401,
298,
1235,
335,
708,
21473,
953,
291,
14,
793,
14,
815,
480,
6864,
2883,
367,
20534,
543,
2287,
730,
26,
8352,
908,
8,
1199,
63,
466,
430,
288,
4280,
275,
284,
11,
17,
288,
367,
485,
315,
1425,
8,
2710,
304,
355,
5552,
63,
1753,
2293,
275,
291,
14,
2415,
59,
2996,
1055,
21102,
8,
1562,
63,
466,
29,
1199,
63,
466,
9,
288,
367,
485,
315,
1425,
8,
1165,
304,
355,
5552,
63,
832,
2293,
275,
291,
14,
2415,
59,
2996,
1055,
21102,
8,
1562,
63,
466,
29,
1199,
63,
466,
9,
953,
327,
4155,
3238,
781,
3984,
6425,
314,
4704,
781,
4282,
288,
2287,
63,
5087,
275,
291,
14,
2415,
59,
2996,
1055,
3502,
1562,
8,
2697,
63,
832,
2293,
9,
288,
340,
284,
508,
378,
26,
355,
702,
440,
2287,
63,
5087,
905,
374,
1579,
937,
436,
440,
2287,
63,
5087,
905,
374,
22179,
937,
288,
916,
284,
508,
413,
26,
355,
702,
2287,
63,
5087,
905,
374,
1579,
937,
436,
440,
2287,
63,
5087,
905,
374,
22179,
937,
288,
587,
26,
355,
702,
440,
2287,
63,
5087,
905,
374,
1579,
937,
436,
2287,
63,
5087,
905,
374,
22179,
937,
22919,
291,
14,
793,
14,
815,
480,
6795,
27440,
83,
370,
20534,
531,
288,
291,
14,
2415,
59,
16,
1055,
23267,
1562,
8,
2697,
63,
1753,
2293,
12,
1616,
9,
288,
291,
14,
2415,
59,
16,
1055,
4208,
8,
17,
9,
288,
291,
14,
2415,
59,
16,
1055,
23267,
1562,
8,
2697,
63,
832,
2293,
12,
959,
9,
288,
291,
14,
2415,
59,
16,
1055,
4208,
8,
17,
9,
288,
291,
14,
5186,
63,
4166,
342,
953,
291,
14,
793,
14,
815,
480,
25493,
1031,
543,
20534,
6902,
531,
288,
291,
14,
2379,
63,
932,
8,
2996,
9,
288,
5145,
14,
21997,
8,
13892,
63,
5751,
63,
515,
12,
20534,
63,
515,
9,
288,
291,
14,
928,
63,
932,
8,
2996,
12,
291,
14,
2911,
63,
589,
59,
2996,
566,
288,
291,
14,
2242,
63,
2415,
8,
16,
12,
4280,
9,
288,
291,
14,
5186,
63,
452,
342,
953,
291,
14,
793,
14,
815,
480,
7496,
790,
2293,
365,
14429,
436,
14094,
365,
3211,
531,
288,
702,
63,
1452,
8,
277,
14,
2415,
59,
2996,
1055,
29213,
1062,
4114,
9,
288,
702,
63,
1452,
8,
277,
14,
2415,
59,
2996,
1055,
513,
13754,
3430,
16,
2733,
3710,
995,
298,
9391,
531,
288,
327,
2670,
626,
781,
1172,
11584,
1006,
2883,
1536,
370,
314,
1202,
790,
2293,
790,
465,
1202,
288,
340,
291,
14,
1419,
14,
17752,
26,
355,
340,
1072,
63,
466,
508,
283,
10000,
356,
490,
702,
63,
1452,
8,
277,
14,
2415,
59,
2996,
1055,
362,
1562,
815,
8,
277,
14,
2415,
59,
2996,
1055,
21102,
8,
1562,
63,
466,
29,
1199,
63,
466,
430,
459,
7952,
498,
515,
995,
298,
77,
15,
1602,
9807,
17,
9807,
16,
9807,
16,
15,
6019,
531,
355,
916,
1072,
63,
466,
508,
283,
80,
18,
609,
13,
8359,
2503,
356,
490,
702,
63,
1452,
8,
277,
14,
2415,
59,
2996,
1055,
362,
1562,
815,
8,
277,
14,
2415,
59,
2996,
1055,
21102,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
Equitable/trump
|
docs/diagrams/tsadisplay/describe.py
|
2
|
5741
|
# -*- coding: utf-8 -*-
import uuid
import types
from sqlalchemy import exc, orm
from sqlalchemy.orm import class_mapper
from sqlalchemy import Column, Integer, Table
from sqlalchemy.orm.properties import ColumnProperty
def describe(items, show_methods=True, show_properties=True):
"""Detecting attributes, inherits and relations
:param items: list of objects to describe
:param show_methods: do detection of methods
:param show_properties: do detection of properties
Return tuple (objects, relations, inherits)
Where objects is list::
[{
'name': '<Mapper class name or table name>',
'cols': [
('<Column type class name>', '<Column name>'),
...
],
'props': ['<Property name>'],
'methods': ['<Method name>', ...],
}, ...]
Relations is::
[{
'from': '<From mapper class name>',
'by': '<By mapper foreign key column name>',
'to': '<To mapper class name>',
}, ...]
Example usage::
import sadisplay
from app import models
desc = sadisplay.describe([
getattr(model, attr) for attr in dir(model)
])
desc = sadisplay.describe([models.User, models.Group])
"""
class EntryItem(object):
"""Class adaptor for mapped classes and tables"""
name = None
methods = []
columns = []
inherits = None
properties = []
bases = tuple()
def __init__(self, mapper=None, table=None):
if mapper is not None:
self.name = mapper.class_.__name__
self.columns = mapper.columns
self.methods = mapper.class_.__dict__.items()
self.inherits = mapper.inherits
self.properties = mapper.iterate_properties
self.bases = mapper.class_.__bases__
self.class_ = mapper.class_
self.table_name = str(mapper.mapped_table)
elif table is not None:
self.name = table.name
self.table_name = table.name
# prepend schema if exists for foreign key matching
if hasattr(table, "schema") and table.schema:
self.table_name = table.schema + "." + self.table_name
self.columns = table.columns
else:
pass
def __repr__(self):
return '<{s.__class__.__name__} {s.name}>'.format(s=self)
def __eq__(self, other):
if other.inherits or self.inherits:
return self.name == other.name
return self.table_name == other.table_name
objects = []
relations = []
inherits = []
entries = []
for item in items:
try:
mapper = class_mapper(item)
except (exc.ArgumentError, orm.exc.UnmappedClassError):
if isinstance(item, Table):
entity = EntryItem(table=item)
else:
continue
else:
entity = EntryItem(mapper=mapper)
if entity not in entries:
entries.append(entity)
for entry in entries:
result_item = {
'name': entry.name,
'cols': [
(c.type.__class__.__name__, c.name) for c in entry.columns
],
'props': [],
'methods': [],
}
if show_methods and entry.methods:
if entry.inherits:
base_methods = entry.inherits.class_.__dict__.keys()
else:
# Create the DummyClass subclass of mapper bases
# for detecting mapper own methods
suffix = '%s' % str(uuid.uuid4())
params = {
'__tablename__': 'dummy_table_%s' % suffix,
'dummy_id_col': Column(Integer, primary_key=True)
}
DummyClass = type('Dummy%s' % suffix, entry.bases, params)
base_methods = DummyClass.__dict__.keys()
# Filter mapper methods
for name, func in entry.methods:
if name[0] != '_' and name not in base_methods:
if isinstance(func, types.FunctionType):
result_item['methods'].append(name)
if show_properties and entry.properties:
for item in entry.properties:
if not isinstance(item, ColumnProperty):
result_item['props'].append(item.key)
# ordering
for key in ('methods', 'props'):
result_item[key].sort()
objects.append(result_item)
# Detect relations by ForeignKey
for col in entry.columns:
for fk in col.foreign_keys:
table = fk.column.table
for m in entries:
try:
if str(table) == str(m.table_name):
relations.append({
'from': entry.name,
'by': col.name,
'to': m.name,
})
except AttributeError:
pass
if entry.inherits:
inh = {
'child': entry.name,
'parent': EntryItem(mapper=entry.inherits).name,
}
inherits.append(inh)
# Delete relation by inherits
for i, rel in enumerate(relations):
if inh['child'] == rel['from'] and inh['parent'] == rel['to']:
relations.pop(i)
return objects, relations, inherits
|
bsd-3-clause
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
646,
5377,
199,
646,
2943,
199,
504,
8335,
492,
3178,
12,
9813,
199,
504,
8335,
14,
1025,
492,
1021,
63,
7153,
199,
504,
8335,
492,
4996,
12,
7225,
12,
6957,
199,
504,
8335,
14,
1025,
14,
3282,
492,
4996,
3697,
421,
199,
318,
13743,
8,
1744,
12,
2498,
63,
2474,
29,
549,
12,
2498,
63,
3282,
29,
549,
304,
272,
408,
20064,
316,
3004,
12,
21592,
436,
16109,
339,
520,
635,
2974,
26,
769,
402,
2251,
370,
13743,
272,
520,
635,
2498,
63,
2474,
26,
886,
15212,
402,
3102,
272,
520,
635,
2498,
63,
3282,
26,
886,
15212,
402,
4382,
339,
1432,
2008,
334,
1462,
12,
16109,
12,
21592,
9,
2378,
17685,
2251,
365,
769,
447,
398,
8910,
288,
283,
354,
356,
2650,
11880,
1021,
536,
503,
1817,
536,
4206,
288,
283,
4574,
356,
359,
355,
19990,
4547,
730,
1021,
536,
4206,
2650,
4547,
536,
25642,
355,
2263,
288,
2156,
288,
283,
6750,
356,
12329,
3697,
536,
16619,
288,
283,
2474,
356,
12329,
3767,
536,
4206,
2263,
467,
267,
1660,
21214,
2378,
9781,
1298,
365,
447,
398,
8910,
288,
283,
504,
356,
2650,
2532,
7796,
1021,
536,
4206,
288,
283,
991,
356,
2650,
2175,
7796,
11608,
790,
2763,
536,
4206,
288,
283,
475,
356,
2650,
1378,
7796,
1021,
536,
4206,
267,
1660,
21214,
2378,
5679,
4503,
447,
398,
492,
2937,
2918,
267,
687,
1145,
492,
1709,
398,
4328,
275,
2937,
2918,
14,
11935,
779,
288,
2519,
8,
1238,
12,
1921,
9,
367,
1921,
315,
2935,
8,
1238,
9,
267,
4794,
398,
4328,
275,
2937,
2918,
14,
11935,
779,
992,
14,
1899,
12,
1709,
14,
2448,
566,
272,
408,
339,
1021,
11855,
2081,
8,
785,
304,
267,
408,
2543,
19520,
269,
367,
9994,
3992,
436,
6716,
624,
267,
536,
275,
488,
267,
3102,
275,
942,
267,
4362,
275,
942,
267,
21592,
275,
488,
267,
4382,
275,
942,
267,
9768,
275,
2008,
342,
398,
347,
636,
826,
721,
277,
12,
7796,
29,
403,
12,
1817,
29,
403,
304,
953,
340,
7796,
365,
440,
488,
26,
355,
291,
14,
354,
275,
7796,
14,
533,
63,
855,
354,
363,
355,
291,
14,
3406,
275,
7796,
14,
3406,
355,
291,
14,
2474,
275,
7796,
14,
533,
63,
855,
807,
4343,
1744,
342,
355,
291,
14,
20882,
275,
7796,
14,
20882,
355,
291,
14,
3282,
275,
7796,
14,
20627,
63,
3282,
355,
291,
14,
12087,
275,
7796,
14,
533,
63,
855,
12087,
363,
355,
291,
14,
533,
63,
275,
7796,
14,
533,
63,
355,
291,
14,
1224,
63,
354,
275,
620,
8,
7153,
14,
11663,
63,
1224,
9,
953,
916,
1817,
365,
440,
488,
26,
355,
291,
14,
354,
275,
1817,
14,
354,
355,
291,
14,
1224,
63,
354,
275,
1817,
14,
354,
355,
327,
18213,
4177,
340,
3495,
367,
11608,
790,
4877,
355,
340,
2688,
8,
1224,
12,
298,
3629,
531,
436,
1817,
14,
3629,
26,
490,
291,
14,
1224,
63,
354,
275,
1817,
14,
3629,
435,
14530,
435,
291,
14,
1224,
63,
354,
355,
291,
14,
3406,
275,
1817,
14,
3406,
288,
587,
26,
355,
986,
398,
347,
636,
2722,
721,
277,
304,
288,
372,
2650,
91,
83,
855,
533,
4914,
354,
363,
93,
469,
83,
14,
354,
93,
22936,
908,
8,
83,
29,
277,
9,
398,
347,
636,
4077,
721,
277,
12,
1163,
304,
288,
340,
1163,
14,
20882,
503,
291,
14,
20882,
26,
355,
372,
291,
14,
354,
508,
1163,
14,
354,
288,
372,
291,
14,
1224,
63,
354,
508,
1163,
14,
1224,
63,
354,
339,
2251,
275,
942,
272,
16109,
275,
942,
272,
21592,
275,
942,
339,
4811,
275,
942,
272,
367,
1242,
315,
2974,
26,
267,
862,
26,
288,
7796,
275,
1021,
63,
7153,
8,
1053,
9,
267,
871,
334,
2804,
14,
17042,
12,
9813,
14,
2804,
14,
1358,
11663,
2543,
547,
304,
288,
340,
1228,
8,
1053,
12,
6957,
304,
355,
4642,
275,
11855,
2081,
8,
1224,
29,
1053,
9,
288,
587,
26,
355,
1980,
267,
587,
26,
288,
4642,
275,
11855,
2081,
8,
7153,
29,
7153,
9,
398,
340,
4642,
440,
315,
4811,
26,
288,
4811,
14,
740,
8,
4502,
9,
339,
367,
2397,
315,
4811,
26,
398,
754,
63,
1053,
275,
469,
288,
283,
354,
356,
2397,
14,
354,
12,
288,
283,
4574,
356,
359,
355,
334,
67,
14,
466,
855,
533,
4914,
354,
3108,
286,
14,
354,
9,
367,
286,
315,
2397,
14,
3406,
288,
2156,
288,
283,
6750,
356,
990,
288,
283,
2474,
356,
990,
267,
789,
398,
340,
2498,
63,
2474,
436,
2397,
14,
2474,
26,
953,
340,
2397,
14,
20882,
26,
355,
1300,
63,
2474,
275,
2397,
14,
20882,
14,
533,
63,
855,
807,
4343,
1612,
342,
288,
587,
26,
355,
327,
2790,
314,
9762,
2543,
5516,
402,
7796,
9768,
355,
327,
367,
9696,
316,
7796,
5705,
3102,
355,
4739,
275,
1543,
83,
7,
450,
620,
8,
2580,
14,
2580,
20,
1012,
355,
1862,
275,
469,
490,
2560,
10983,
3706,
283,
5869,
63,
1224,
4970,
83,
7,
450,
4739,
12,
490,
283,
5869,
63,
344,
63,
761,
356,
4996,
8,
2674,
12,
5062,
63,
498,
29,
549,
9,
355,
789,
2234,
9762,
2543,
275,
730,
360,
11324,
5,
83,
7,
450,
4739,
12,
2397,
14,
12087,
12,
1862,
9,
2234,
1300,
63,
2474,
275,
9762,
2543,
855,
807,
4343,
1612,
342,
953,
327,
9388,
7796,
3102,
288,
367,
536,
12,
2562,
315,
2397,
14,
2474,
26,
355,
340,
536,
59,
16,
61,
1137,
14135,
436,
536,
440,
315,
1300,
63,
2474,
26,
490,
340,
1228,
8,
1532,
12,
2943,
14,
26371,
304,
717,
754,
63,
1053,
459,
2474,
2278,
740,
8,
354,
9,
398,
340,
2498,
63,
3282,
436,
2397,
14,
3282,
26,
288,
367,
1242,
315,
2397,
14,
3282,
26,
355,
340,
440,
1228,
8,
1053,
12,
4996,
3697,
304,
490,
754,
63,
1053,
459,
6750,
2278,
740,
8,
1053,
14,
498,
9,
398,
327,
7794,
267,
367,
790,
315,
661,
2474,
297,
283,
6750,
735,
288,
754,
63,
1053,
59,
498,
1055,
3191,
342,
398,
2251,
14,
740,
8,
1099,
63,
1053,
9,
398,
327,
30577,
16109,
701,
12718,
267,
367,
1048,
315,
2397,
14,
3406,
26,
288,
367,
14830,
315,
1048,
14,
6846,
63,
1612
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
646,
5377,
199,
646,
2943,
199,
504,
8335,
492,
3178,
12,
9813,
199,
504,
8335,
14,
1025,
492,
1021,
63,
7153,
199,
504,
8335,
492,
4996,
12,
7225,
12,
6957,
199,
504,
8335,
14,
1025,
14,
3282,
492,
4996,
3697,
421,
199,
318,
13743,
8,
1744,
12,
2498,
63,
2474,
29,
549,
12,
2498,
63,
3282,
29,
549,
304,
272,
408,
20064,
316,
3004,
12,
21592,
436,
16109,
339,
520,
635,
2974,
26,
769,
402,
2251,
370,
13743,
272,
520,
635,
2498,
63,
2474,
26,
886,
15212,
402,
3102,
272,
520,
635,
2498,
63,
3282,
26,
886,
15212,
402,
4382,
339,
1432,
2008,
334,
1462,
12,
16109,
12,
21592,
9,
2378,
17685,
2251,
365,
769,
447,
398,
8910,
288,
283,
354,
356,
2650,
11880,
1021,
536,
503,
1817,
536,
4206,
288,
283,
4574,
356,
359,
355,
19990,
4547,
730,
1021,
536,
4206,
2650,
4547,
536,
25642,
355,
2263,
288,
2156,
288,
283,
6750,
356,
12329,
3697,
536,
16619,
288,
283,
2474,
356,
12329,
3767,
536,
4206,
2263,
467,
267,
1660,
21214,
2378,
9781,
1298,
365,
447,
398,
8910,
288,
283,
504,
356,
2650,
2532,
7796,
1021,
536,
4206,
288,
283,
991,
356,
2650,
2175,
7796,
11608,
790,
2763,
536,
4206,
288,
283,
475,
356,
2650,
1378,
7796,
1021,
536,
4206,
267,
1660,
21214,
2378,
5679,
4503,
447,
398,
492,
2937,
2918,
267,
687,
1145,
492,
1709,
398,
4328,
275,
2937,
2918,
14,
11935,
779,
288,
2519,
8,
1238,
12,
1921,
9,
367,
1921,
315,
2935,
8,
1238,
9,
267,
4794,
398,
4328,
275,
2937,
2918,
14,
11935,
779,
992,
14,
1899,
12,
1709,
14,
2448,
566,
272,
408,
339,
1021,
11855,
2081,
8,
785,
304,
267,
408,
2543,
19520,
269,
367,
9994,
3992,
436,
6716,
624,
267,
536,
275,
488,
267,
3102,
275,
942,
267,
4362,
275,
942,
267,
21592,
275,
488,
267,
4382,
275,
942,
267,
9768,
275,
2008,
342,
398,
347,
636,
826,
721,
277,
12,
7796,
29,
403,
12,
1817,
29,
403,
304,
953,
340,
7796,
365,
440,
488,
26,
355,
291,
14,
354,
275,
7796,
14,
533,
63,
855,
354,
363,
355,
291,
14,
3406,
275,
7796,
14,
3406,
355,
291,
14,
2474,
275,
7796,
14,
533,
63,
855,
807,
4343,
1744,
342,
355,
291,
14,
20882,
275,
7796,
14,
20882,
355,
291,
14,
3282,
275,
7796,
14,
20627,
63,
3282,
355,
291,
14,
12087,
275,
7796,
14,
533,
63,
855,
12087,
363,
355,
291,
14,
533,
63,
275,
7796,
14,
533,
63,
355,
291,
14,
1224,
63,
354,
275,
620,
8,
7153,
14,
11663,
63,
1224,
9,
953,
916,
1817,
365,
440,
488,
26,
355,
291,
14,
354,
275,
1817,
14,
354,
355,
291,
14,
1224,
63,
354,
275,
1817,
14,
354,
355,
327,
18213,
4177,
340,
3495,
367,
11608,
790,
4877,
355,
340,
2688,
8,
1224,
12,
298,
3629,
531,
436,
1817,
14,
3629,
26,
490,
291,
14,
1224,
63,
354,
275,
1817,
14,
3629,
435,
14530,
435,
291,
14,
1224,
63,
354,
355,
291,
14,
3406,
275,
1817,
14,
3406,
288,
587,
26,
355,
986,
398,
347,
636,
2722,
721,
277,
304,
288,
372,
2650,
91,
83,
855,
533,
4914,
354,
363,
93,
469,
83,
14,
354,
93,
22936,
908,
8,
83,
29,
277,
9,
398,
347,
636,
4077,
721,
277,
12,
1163,
304,
288,
340,
1163,
14,
20882,
503,
291,
14,
20882,
26,
355,
372,
291,
14,
354,
508,
1163,
14,
354,
288,
372,
291,
14,
1224,
63,
354,
508,
1163,
14,
1224,
63,
354,
339,
2251,
275,
942,
272,
16109,
275,
942,
272,
21592,
275,
942,
339,
4811,
275,
942,
272,
367,
1242,
315,
2974,
26,
267,
862,
26,
288,
7796,
275,
1021,
63,
7153,
8,
1053,
9,
267,
871,
334,
2804,
14,
17042,
12,
9813,
14,
2804,
14,
1358,
11663,
2543,
547,
304,
288,
340,
1228,
8,
1053,
12,
6957,
304,
355,
4642,
275,
11855,
2081,
8,
1224,
29,
1053,
9,
288,
587,
26,
355,
1980,
267,
587,
26,
288,
4642,
275,
11855,
2081,
8,
7153,
29,
7153,
9,
398,
340,
4642,
440,
315,
4811,
26,
288,
4811,
14,
740,
8,
4502,
9,
339,
367,
2397,
315,
4811,
26,
398,
754,
63,
1053,
275,
469,
288,
283,
354,
356,
2397,
14,
354,
12,
288,
283,
4574,
356,
359,
355,
334,
67,
14,
466,
855,
533,
4914,
354,
3108,
286,
14,
354,
9,
367,
286,
315,
2397,
14,
3406,
288,
2156,
288,
283,
6750,
356,
990,
288,
283,
2474,
356,
990,
267,
789,
398,
340,
2498,
63,
2474,
436,
2397,
14,
2474,
26,
953,
340,
2397,
14,
20882,
26,
355,
1300,
63,
2474,
275,
2397,
14,
20882,
14,
533,
63,
855,
807,
4343,
1612,
342,
288,
587,
26,
355,
327,
2790,
314,
9762,
2543,
5516,
402,
7796,
9768,
355,
327,
367,
9696,
316,
7796,
5705,
3102,
355,
4739,
275,
1543,
83,
7,
450,
620,
8,
2580,
14,
2580,
20,
1012,
355,
1862,
275,
469,
490,
2560,
10983,
3706,
283,
5869,
63,
1224,
4970,
83,
7,
450,
4739,
12,
490,
283,
5869,
63,
344,
63,
761,
356,
4996,
8,
2674,
12,
5062,
63,
498,
29,
549,
9,
355,
789,
2234,
9762,
2543,
275,
730,
360,
11324,
5,
83,
7,
450,
4739,
12,
2397,
14,
12087,
12,
1862,
9,
2234,
1300,
63,
2474,
275,
9762,
2543,
855,
807,
4343,
1612,
342,
953,
327,
9388,
7796,
3102,
288,
367,
536,
12,
2562,
315,
2397,
14,
2474,
26,
355,
340,
536,
59,
16,
61,
1137,
14135,
436,
536,
440,
315,
1300,
63,
2474,
26,
490,
340,
1228,
8,
1532,
12,
2943,
14,
26371,
304,
717,
754,
63,
1053,
459,
2474,
2278,
740,
8,
354,
9,
398,
340,
2498,
63,
3282,
436,
2397,
14,
3282,
26,
288,
367,
1242,
315,
2397,
14,
3282,
26,
355,
340,
440,
1228,
8,
1053,
12,
4996,
3697,
304,
490,
754,
63,
1053,
459,
6750,
2278,
740,
8,
1053,
14,
498,
9,
398,
327,
7794,
267,
367,
790,
315,
661,
2474,
297,
283,
6750,
735,
288,
754,
63,
1053,
59,
498,
1055,
3191,
342,
398,
2251,
14,
740,
8,
1099,
63,
1053,
9,
398,
327,
30577,
16109,
701,
12718,
267,
367,
1048,
315,
2397,
14,
3406,
26,
288,
367,
14830,
315,
1048,
14,
6846,
63,
1612,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
HackToday/kolla
|
tests/test_build.py
|
1
|
3763
|
# 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 mock import patch
from os import path
from oslo_log import fixture as log_fixture
from oslo_log import log as logging
from oslotest import base
import sys
sys.path.append(path.abspath(path.join(path.dirname(__file__), '../tools')))
from tools import build
LOG = logging.getLogger(__name__)
class BuildTest(base.BaseTestCase):
def setUp(self):
super(BuildTest, self).setUp()
self.useFixture(log_fixture.SetLogLevel([__name__],
logging.logging.INFO))
self.build_args = [__name__, "--debug"]
def runTest(self):
with patch.object(sys, 'argv', self.build_args):
LOG.info("Running with args %s" % self.build_args)
bad_results, good_results = build.main()
# these are images that are known to not build properly
excluded_images = ["gnocchi-api",
"gnocchi-statsd"]
failures = 0
for image, result in bad_results.iteritems():
if image in excluded_images:
if result is 'error':
continue
failures = failures + 1
LOG.warning(">>> Expected image '%s' to fail, please update"
" the excluded_images in source file above if the"
" image build has been fixed." % image)
else:
if result is not 'error':
continue
failures = failures + 1
LOG.critical(">>> Expected image '%s' to succeed!" % image)
self.assertEqual(failures, 0, "%d failure(s) occurred" % failures)
class BuildTestCentosBinaryDocker(BuildTest):
def setUp(self):
super(BuildTestCentosBinaryDocker, self).setUp()
self.build_args.extend(["--base", "centos",
"--type", "binary"])
class BuildTestCentosSourceDocker(BuildTest):
def setUp(self):
super(BuildTestCentosSourceDocker, self).setUp()
self.build_args.extend(["--base", "centos",
"--type", "source"])
class BuildTestUbuntuSourceDocker(BuildTest):
def setUp(self):
super(BuildTestUbuntuSourceDocker, self).setUp()
self.build_args.extend(["--base", "ubuntu",
"--type", "source"])
class BuildTestCentosBinaryTemplate(BuildTest):
def setUp(self):
super(BuildTestCentosBinaryTemplate, self).setUp()
self.build_args.extend(["--base", "centos",
"--type", "binary",
"--template"])
class BuildTestCentosSourceTemplate(BuildTest):
def setUp(self):
super(BuildTestCentosSourceTemplate, self).setUp()
self.build_args.extend(["--base", "centos",
"--type", "source",
"--template"])
class BuildTestUbuntuSourceTemplate(BuildTest):
def setUp(self):
super(BuildTestUbuntuSourceTemplate, self).setUp()
self.build_args.extend(["--base", "ubuntu",
"--type", "source",
"--template"])
|
apache-2.0
|
[
3,
259,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
1265,
1443,
199,
3,
259,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
2047,
1443,
3332,
199,
3,
259,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
260,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
259,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
259,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
2428,
199,
3,
259,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
1666,
314,
199,
3,
259,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
4204,
199,
3,
259,
1334,
314,
844,
14,
421,
199,
504,
1683,
492,
3371,
199,
504,
747,
492,
931,
199,
504,
11258,
63,
793,
492,
10949,
465,
943,
63,
5997,
199,
504,
11258,
63,
793,
492,
943,
465,
2050,
199,
504,
11258,
396,
492,
1300,
199,
199,
646,
984,
199,
1274,
14,
515,
14,
740,
8,
515,
14,
4832,
8,
515,
14,
904,
8,
515,
14,
3475,
3460,
493,
10139,
20644,
2537,
7058,
199,
504,
7249,
492,
1900,
199,
199,
4947,
275,
2050,
14,
5572,
3460,
354,
3368,
421,
199,
533,
6516,
774,
8,
1095,
14,
20760,
304,
339,
347,
3613,
8,
277,
304,
267,
1613,
8,
3425,
774,
12,
291,
680,
5996,
342,
267,
291,
14,
31015,
8,
793,
63,
5997,
14,
1084,
2445,
4670,
779,
363,
354,
363,
467,
6059,
2050,
14,
4806,
14,
4531,
430,
267,
291,
14,
1506,
63,
589,
275,
359,
363,
354,
3108,
4320,
1757,
937,
339,
347,
29779,
8,
277,
304,
267,
543,
3371,
14,
785,
8,
1274,
12,
283,
3020,
297,
291,
14,
1506,
63,
589,
304,
288,
5051,
14,
815,
480,
9602,
543,
1249,
450,
83,
2,
450,
291,
14,
1506,
63,
589,
9,
288,
4875,
63,
2604,
12,
6954,
63,
2604,
275,
1900,
14,
973,
342,
398,
327,
3520,
787,
5935,
626,
787,
6040,
370,
440,
1900,
7684,
267,
8789,
63,
4782,
275,
2097,
784,
679,
13175,
13,
1246,
401,
2574,
298,
784,
679,
13175,
13,
3200,
68,
937,
398,
9081,
275,
378,
267,
367,
1834,
12,
754,
315,
4875,
63,
2604,
14,
4611,
837,
288,
340,
1834,
315,
8789,
63,
4782,
26,
355,
340,
754,
365,
283,
705,
356,
490,
1980,
355,
9081,
275,
9081,
435,
413,
355,
5051,
14,
3764,
480,
6071,
13796,
1834,
1543,
83,
7,
370,
2449,
12,
8749,
1678,
2,
1169,
298,
314,
8789,
63,
4782,
315,
1350,
570,
3432,
340,
314,
2,
1169,
298,
1834,
1900,
965,
2757,
6317,
2122,
450,
1834,
9,
288,
587,
26,
355,
340,
754,
365,
440,
283,
705,
356,
490,
1980,
355,
9081,
275,
9081,
435,
413,
355,
5051,
14,
13138,
480,
6071,
13796,
1834,
1543,
83,
7,
370,
17961,
9539,
450,
1834,
9,
398,
291,
14,
629,
8,
9968,
12,
378,
12,
2071,
68,
5988,
8,
83,
9,
8920,
2,
450,
9081,
9,
421,
199,
533,
6516,
774,
18345,
14543,
6636,
31463,
8,
3425,
774,
304,
272,
347,
3613,
8,
277,
304,
267,
1613,
8,
3425,
774,
18345,
14543,
6636,
31463,
12,
291,
680,
5996,
342,
267,
291,
14,
1506,
63,
589,
14,
2880,
5234,
306,
1095,
401,
298,
2497,
14543,
401,
1816,
4320,
466,
401,
298,
3008,
3135,
421,
199,
533,
6516,
774,
18345,
14543,
2980,
31463,
8,
3425,
774,
304,
272,
347,
3613,
8,
277,
304,
267,
1613,
8,
3425,
774,
18345,
14543,
2980,
31463,
12,
291,
680,
5996,
342,
267,
291,
14,
1506,
63,
589,
14,
2880,
5234,
306,
1095,
401,
298,
2497,
14543,
401,
1816,
4320,
466,
401,
298,
1365,
3135,
421,
199,
533,
6516,
774,
53,
19313,
2980,
31463,
8,
3425,
774,
304,
272,
347,
3613,
8,
277,
304,
267,
1613,
8,
3425,
774,
53,
19313,
2980,
31463,
12,
291,
680,
5996,
342,
267,
291,
14,
1506,
63,
589,
14,
2880,
5234,
306,
1095,
401,
298,
21151,
401,
1816,
4320,
466,
401,
298,
1365,
3135,
421,
199,
533,
6516,
774,
18345,
14543,
6636,
4231,
8,
3425,
774,
304,
272,
347,
3613,
8,
277,
304,
267,
1613,
8,
3425,
774,
18345,
14543,
6636,
4231,
12,
291,
680,
5996,
342,
267,
291,
14,
1506,
63,
589,
14,
2880,
5234,
306,
1095,
401,
298,
2497,
14543,
401,
1816,
4320,
466,
401,
298,
3008,
401,
1816,
4320,
1160,
3135,
421,
199,
533,
6516,
774,
18345,
14543,
2980,
4231,
8,
3425,
774,
304,
272,
347,
3613,
8,
277,
304,
267,
1613,
8,
3425,
774,
18345,
14543,
2980,
4231,
12,
291,
680,
5996,
342,
267,
291,
14,
1506,
63,
589,
14,
2880,
5234,
306,
1095,
401,
298,
2497,
14543,
401,
1816,
4320,
466,
401,
298,
1365,
401,
1816,
4320,
1160,
3135,
421,
199,
533,
6516,
774,
53,
19313,
2980,
4231,
8,
3425,
774,
304,
272,
347,
3613,
8,
277,
304,
267,
1613,
8,
3425,
774,
53,
19313,
2980,
4231,
12,
291,
680,
5996,
342,
267,
291,
14,
1506,
63,
589,
14,
2880,
5234,
306,
1095,
401,
298,
21151,
401,
1816,
4320,
466,
401,
298,
1365,
401,
1816,
4320,
1160,
3135,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
259,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
1265,
1443,
199,
3,
259,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
2047,
1443,
3332,
199,
3,
259,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
260,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
259,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
259,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
2428,
199,
3,
259,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
1666,
314,
199,
3,
259,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
4204,
199,
3,
259,
1334,
314,
844,
14,
421,
199,
504,
1683,
492,
3371,
199,
504,
747,
492,
931,
199,
504,
11258,
63,
793,
492,
10949,
465,
943,
63,
5997,
199,
504,
11258,
63,
793,
492,
943,
465,
2050,
199,
504,
11258,
396,
492,
1300,
199,
199,
646,
984,
199,
1274,
14,
515,
14,
740,
8,
515,
14,
4832,
8,
515,
14,
904,
8,
515,
14,
3475,
3460,
493,
10139,
20644,
2537,
7058,
199,
504,
7249,
492,
1900,
199,
199,
4947,
275,
2050,
14,
5572,
3460,
354,
3368,
421,
199,
533,
6516,
774,
8,
1095,
14,
20760,
304,
339,
347,
3613,
8,
277,
304,
267,
1613,
8,
3425,
774,
12,
291,
680,
5996,
342,
267,
291,
14,
31015,
8,
793,
63,
5997,
14,
1084,
2445,
4670,
779,
363,
354,
363,
467,
6059,
2050,
14,
4806,
14,
4531,
430,
267,
291,
14,
1506,
63,
589,
275,
359,
363,
354,
3108,
4320,
1757,
937,
339,
347,
29779,
8,
277,
304,
267,
543,
3371,
14,
785,
8,
1274,
12,
283,
3020,
297,
291,
14,
1506,
63,
589,
304,
288,
5051,
14,
815,
480,
9602,
543,
1249,
450,
83,
2,
450,
291,
14,
1506,
63,
589,
9,
288,
4875,
63,
2604,
12,
6954,
63,
2604,
275,
1900,
14,
973,
342,
398,
327,
3520,
787,
5935,
626,
787,
6040,
370,
440,
1900,
7684,
267,
8789,
63,
4782,
275,
2097,
784,
679,
13175,
13,
1246,
401,
2574,
298,
784,
679,
13175,
13,
3200,
68,
937,
398,
9081,
275,
378,
267,
367,
1834,
12,
754,
315,
4875,
63,
2604,
14,
4611,
837,
288,
340,
1834,
315,
8789,
63,
4782,
26,
355,
340,
754,
365,
283,
705,
356,
490,
1980,
355,
9081,
275,
9081,
435,
413,
355,
5051,
14,
3764,
480,
6071,
13796,
1834,
1543,
83,
7,
370,
2449,
12,
8749,
1678,
2,
1169,
298,
314,
8789,
63,
4782,
315,
1350,
570,
3432,
340,
314,
2,
1169,
298,
1834,
1900,
965,
2757,
6317,
2122,
450,
1834,
9,
288,
587,
26,
355,
340,
754,
365,
440,
283,
705,
356,
490,
1980,
355,
9081,
275,
9081,
435,
413,
355,
5051,
14,
13138,
480,
6071,
13796,
1834,
1543,
83,
7,
370,
17961,
9539,
450,
1834,
9,
398,
291,
14,
629,
8,
9968,
12,
378,
12,
2071,
68,
5988,
8,
83,
9,
8920,
2,
450,
9081,
9,
421,
199,
533,
6516,
774,
18345,
14543,
6636,
31463,
8,
3425,
774,
304,
272,
347,
3613,
8,
277,
304,
267,
1613,
8,
3425,
774,
18345,
14543,
6636,
31463,
12,
291,
680,
5996,
342,
267,
291,
14,
1506,
63,
589,
14,
2880,
5234,
306,
1095,
401,
298,
2497,
14543,
401,
1816,
4320,
466,
401,
298,
3008,
3135,
421,
199,
533,
6516,
774,
18345,
14543,
2980,
31463,
8,
3425,
774,
304,
272,
347,
3613,
8,
277,
304,
267,
1613,
8,
3425,
774,
18345,
14543,
2980,
31463,
12,
291,
680,
5996,
342,
267,
291,
14,
1506,
63,
589,
14,
2880,
5234,
306,
1095,
401,
298,
2497,
14543,
401,
1816,
4320,
466,
401,
298,
1365,
3135,
421,
199,
533,
6516,
774,
53,
19313,
2980,
31463,
8,
3425,
774,
304,
272,
347,
3613,
8,
277,
304,
267,
1613,
8,
3425,
774,
53,
19313,
2980,
31463,
12,
291,
680,
5996,
342,
267,
291,
14,
1506,
63,
589,
14,
2880,
5234,
306,
1095,
401,
298,
21151,
401,
1816,
4320,
466,
401,
298,
1365,
3135,
421,
199,
533,
6516,
774,
18345,
14543,
6636,
4231,
8,
3425,
774,
304,
272,
347,
3613,
8,
277,
304,
267,
1613,
8,
3425,
774,
18345,
14543,
6636,
4231,
12,
291,
680,
5996,
342,
267,
291,
14,
1506,
63,
589,
14,
2880,
5234,
306,
1095,
401,
298,
2497,
14543,
401,
1816,
4320,
466,
401,
298,
3008,
401,
1816,
4320,
1160,
3135,
421,
199,
533,
6516,
774,
18345,
14543,
2980,
4231,
8,
3425,
774,
304,
272,
347,
3613,
8,
277,
304,
267,
1613,
8,
3425,
774,
18345,
14543,
2980,
4231,
12,
291,
680,
5996,
342,
267,
291,
14,
1506,
63,
589,
14,
2880,
5234,
306,
1095,
401,
298,
2497,
14543,
401,
1816,
4320,
466,
401,
298,
1365,
401,
1816,
4320,
1160,
3135,
421,
199,
533,
6516,
774,
53,
19313,
2980,
4231,
8,
3425,
774,
304,
272,
347,
3613,
8,
277,
304,
267,
1613,
8,
3425,
774,
53,
19313,
2980,
4231,
12,
291,
680,
5996,
342,
267,
291,
14,
1506,
63,
589,
14,
2880,
5234,
306,
1095,
401,
298,
21151,
401,
1816,
4320,
466,
401,
298,
1365,
401,
1816,
4320,
1160,
3135,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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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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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
admetricks/phantomjs
|
src/qt/qtwebkit/Tools/Scripts/webkitpy/tool/commands/stepsequence.py
|
126
|
3584
|
# Copyright (C) 2009 Google Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following disclaimer
# in the documentation and/or other materials provided with the
# distribution.
# * Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import logging
from webkitpy.tool import steps
from webkitpy.common.checkout.scm import CheckoutNeedsUpdate
from webkitpy.common.system.executive import ScriptError
from webkitpy.tool.bot.queueengine import QueueEngine
_log = logging.getLogger(__name__)
class StepSequenceErrorHandler():
@classmethod
def handle_script_error(cls, tool, patch, script_error):
raise NotImplementedError, "subclasses must implement"
@classmethod
def handle_checkout_needs_update(cls, tool, state, options, error):
raise NotImplementedError, "subclasses must implement"
class StepSequence(object):
def __init__(self, steps):
self._steps = steps or []
def options(self):
collected_options = [
steps.Options.parent_command,
steps.Options.quiet,
]
for step in self._steps:
collected_options = collected_options + step.options()
# Remove duplicates.
collected_options = sorted(set(collected_options))
return collected_options
def _run(self, tool, options, state):
for step in self._steps:
step(tool, options).run(state)
def run_and_handle_errors(self, tool, options, state=None):
if not state:
state = {}
try:
self._run(tool, options, state)
except CheckoutNeedsUpdate, e:
_log.info("Commit failed because the checkout is out of date. Please update and try again.")
if options.parent_command:
command = tool.command_by_name(options.parent_command)
command.handle_checkout_needs_update(tool, state, options, e)
QueueEngine.exit_after_handled_error(e)
except ScriptError, e:
if not options.quiet:
_log.error(e.message_with_output())
if options.parent_command:
command = tool.command_by_name(options.parent_command)
command.handle_script_error(tool, state, e)
QueueEngine.exit_after_handled_error(e)
|
bsd-3-clause
|
[
3,
1898,
334,
35,
9,
8937,
4475,
3277,
14,
2900,
4481,
4644,
14,
199,
3,
221,
199,
3,
10114,
436,
675,
315,
1350,
436,
3366,
4513,
12,
543,
503,
1928,
199,
3,
7100,
12,
787,
8211,
2741,
626,
314,
2569,
3704,
787,
199,
3,
7647,
26,
199,
3,
221,
199,
3,
258,
627,
6823,
402,
1350,
1233,
1471,
8074,
314,
3432,
4248,
199,
3,
4245,
12,
642,
769,
402,
3704,
436,
314,
2569,
6450,
14,
199,
3,
258,
627,
6823,
315,
3366,
1824,
1471,
9172,
314,
3432,
199,
3,
4248,
4245,
12,
642,
769,
402,
3704,
436,
314,
2569,
6450,
199,
3,
315,
314,
3794,
436,
15,
269,
1163,
8418,
2741,
543,
314,
199,
3,
4084,
14,
199,
3,
258,
627,
11443,
314,
536,
402,
4475,
3277,
14,
6590,
314,
1561,
402,
2399,
199,
3,
8417,
1443,
506,
1202,
370,
10692,
503,
10016,
7585,
7131,
687,
199,
3,
642,
2032,
1928,
2488,
6791,
5313,
4983,
14,
199,
3,
221,
199,
3,
5749,
4141,
2281,
7049,
6515,
2334,
5877,
8164,
2401,
6483,
199,
3,
298,
1179,
2281,
2,
2401,
1821,
7168,
1549,
5292,
2990,
12,
6931,
12,
5400,
2845,
199,
3,
5471,
2296,
12,
2334,
5292,
2990,
1634,
3169,
2401,
3092,
2381,
199,
3,
437,
3115,
3104,
9315,
9706,
14,
1621,
4825,
6461,
7000,
2334,
5877,
199,
3,
11489,
1549,
6483,
6262,
7024,
2381,
1821,
8703,
12,
9168,
12,
9716,
12,
199,
3,
8820,
12,
9836,
12,
1549,
9110,
6736,
334,
6446,
12,
5400,
2845,
199,
3,
5471,
2296,
12,
9838,
1634,
9103,
9764,
1549,
9714,
27,
9102,
1634,
4815,
12,
199,
3,
7126,
12,
1549,
9206,
27,
1549,
9748,
9831,
9,
9802,
9817,
2401,
5258,
1821,
199,
3,
9815,
1634,
5603,
12,
7061,
1621,
7066,
12,
9644,
5603,
12,
1549,
7056,
199,
3,
334,
6446,
9254,
1549,
7334,
9,
7043,
1621,
1821,
9683,
5738,
1634,
2334,
4815,
199,
3,
1634,
5749,
4141,
12,
9704,
8036,
9691,
1634,
2334,
9726,
1634,
9712,
9784,
14,
199,
199,
646,
2050,
199,
199,
504,
18007,
14,
3557,
492,
7124,
199,
199,
504,
18007,
14,
2330,
14,
12891,
14,
17143,
492,
2670,
548,
28390,
4152,
199,
504,
18007,
14,
2330,
14,
2253,
14,
1628,
13441,
492,
14914,
547,
199,
504,
18007,
14,
3557,
14,
3018,
14,
1825,
3908,
492,
10703,
8524,
199,
199,
63,
793,
275,
2050,
14,
5572,
3460,
354,
3368,
421,
199,
533,
13382,
5826,
25933,
837,
272,
768,
3744,
272,
347,
2429,
63,
1579,
63,
705,
8,
1886,
12,
4744,
12,
3371,
12,
2884,
63,
705,
304,
267,
746,
4279,
12,
298,
19094,
1471,
5669,
2,
339,
768,
3744,
272,
347,
2429,
63,
12891,
63,
10065,
63,
873,
8,
1886,
12,
4744,
12,
1174,
12,
1511,
12,
1125,
304,
267,
746,
4279,
12,
298,
19094,
1471,
5669,
2,
421,
199,
533,
13382,
5826,
8,
785,
304,
272,
347,
636,
826,
721,
277,
12,
7124,
304,
267,
291,
423,
5895,
275,
7124,
503,
942,
339,
347,
1511,
8,
277,
304,
267,
13736,
63,
1419,
275,
359,
288,
7124,
14,
4558,
14,
1708,
63,
1531,
12,
288,
7124,
14,
4558,
14,
10243,
12,
267,
1622,
267,
367,
3650,
315,
291,
423,
5895,
26,
288,
13736,
63,
1419,
275,
13736,
63,
1419,
435,
3650,
14,
1419,
342,
267,
327,
5852,
15755,
14,
267,
13736,
63,
1419,
275,
3355,
8,
409,
8,
22766,
63,
1419,
430,
267,
372,
13736,
63,
1419,
339,
347,
485,
1065,
8,
277,
12,
4744,
12,
1511,
12,
1174,
304,
267,
367,
3650,
315,
291,
423,
5895,
26,
288,
3650,
8,
3557,
12,
1511,
680,
1065,
8,
929,
9,
339,
347,
1255,
63,
460,
63,
2479,
63,
2550,
8,
277,
12,
4744,
12,
1511,
12,
1174,
29,
403,
304,
267,
340,
440,
1174,
26,
288,
1174,
275,
1052,
267,
862,
26,
288,
291,
423,
1065,
8,
3557,
12,
1511,
12,
1174,
9,
267,
871,
2670,
548,
28390,
4152,
12,
325,
26,
288,
485,
793,
14,
815,
480,
11421,
3405,
2952,
314,
15243,
365,
734,
402,
1434,
14,
7754,
1678,
436,
862,
4020,
2685,
288,
340,
1511,
14,
1708,
63,
1531,
26,
355,
1414,
275,
4744,
14,
1531,
63,
991,
63,
354,
8,
1419,
14,
1708,
63,
1531,
9,
355,
1414,
14,
2479,
63,
12891,
63,
10065,
63,
873,
8,
3557,
12,
1174,
12,
1511,
12,
325,
9,
288,
10703,
8524,
14,
2224,
63,
4399,
63,
11217,
63,
705,
8,
69,
9,
267,
871,
14914,
547,
12,
325,
26,
288,
340,
440,
1511,
14,
10243,
26,
355,
485,
793,
14,
705,
8,
69,
14,
1188,
63,
1045,
63,
1199,
1012,
288,
340,
1511,
14,
1708,
63,
1531,
26,
355,
1414,
275,
4744,
14,
1531,
63,
991,
63,
354,
8,
1419,
14,
1708,
63,
1531,
9,
355,
1414,
14,
2479,
63,
1579,
63,
705,
8,
3557,
12,
1174,
12,
325,
9,
288,
10703,
8524,
14,
2224,
63,
4399,
63,
11217,
63,
705,
8,
69,
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
] |
[
1898,
334,
35,
9,
8937,
4475,
3277,
14,
2900,
4481,
4644,
14,
199,
3,
221,
199,
3,
10114,
436,
675,
315,
1350,
436,
3366,
4513,
12,
543,
503,
1928,
199,
3,
7100,
12,
787,
8211,
2741,
626,
314,
2569,
3704,
787,
199,
3,
7647,
26,
199,
3,
221,
199,
3,
258,
627,
6823,
402,
1350,
1233,
1471,
8074,
314,
3432,
4248,
199,
3,
4245,
12,
642,
769,
402,
3704,
436,
314,
2569,
6450,
14,
199,
3,
258,
627,
6823,
315,
3366,
1824,
1471,
9172,
314,
3432,
199,
3,
4248,
4245,
12,
642,
769,
402,
3704,
436,
314,
2569,
6450,
199,
3,
315,
314,
3794,
436,
15,
269,
1163,
8418,
2741,
543,
314,
199,
3,
4084,
14,
199,
3,
258,
627,
11443,
314,
536,
402,
4475,
3277,
14,
6590,
314,
1561,
402,
2399,
199,
3,
8417,
1443,
506,
1202,
370,
10692,
503,
10016,
7585,
7131,
687,
199,
3,
642,
2032,
1928,
2488,
6791,
5313,
4983,
14,
199,
3,
221,
199,
3,
5749,
4141,
2281,
7049,
6515,
2334,
5877,
8164,
2401,
6483,
199,
3,
298,
1179,
2281,
2,
2401,
1821,
7168,
1549,
5292,
2990,
12,
6931,
12,
5400,
2845,
199,
3,
5471,
2296,
12,
2334,
5292,
2990,
1634,
3169,
2401,
3092,
2381,
199,
3,
437,
3115,
3104,
9315,
9706,
14,
1621,
4825,
6461,
7000,
2334,
5877,
199,
3,
11489,
1549,
6483,
6262,
7024,
2381,
1821,
8703,
12,
9168,
12,
9716,
12,
199,
3,
8820,
12,
9836,
12,
1549,
9110,
6736,
334,
6446,
12,
5400,
2845,
199,
3,
5471,
2296,
12,
9838,
1634,
9103,
9764,
1549,
9714,
27,
9102,
1634,
4815,
12,
199,
3,
7126,
12,
1549,
9206,
27,
1549,
9748,
9831,
9,
9802,
9817,
2401,
5258,
1821,
199,
3,
9815,
1634,
5603,
12,
7061,
1621,
7066,
12,
9644,
5603,
12,
1549,
7056,
199,
3,
334,
6446,
9254,
1549,
7334,
9,
7043,
1621,
1821,
9683,
5738,
1634,
2334,
4815,
199,
3,
1634,
5749,
4141,
12,
9704,
8036,
9691,
1634,
2334,
9726,
1634,
9712,
9784,
14,
199,
199,
646,
2050,
199,
199,
504,
18007,
14,
3557,
492,
7124,
199,
199,
504,
18007,
14,
2330,
14,
12891,
14,
17143,
492,
2670,
548,
28390,
4152,
199,
504,
18007,
14,
2330,
14,
2253,
14,
1628,
13441,
492,
14914,
547,
199,
504,
18007,
14,
3557,
14,
3018,
14,
1825,
3908,
492,
10703,
8524,
199,
199,
63,
793,
275,
2050,
14,
5572,
3460,
354,
3368,
421,
199,
533,
13382,
5826,
25933,
837,
272,
768,
3744,
272,
347,
2429,
63,
1579,
63,
705,
8,
1886,
12,
4744,
12,
3371,
12,
2884,
63,
705,
304,
267,
746,
4279,
12,
298,
19094,
1471,
5669,
2,
339,
768,
3744,
272,
347,
2429,
63,
12891,
63,
10065,
63,
873,
8,
1886,
12,
4744,
12,
1174,
12,
1511,
12,
1125,
304,
267,
746,
4279,
12,
298,
19094,
1471,
5669,
2,
421,
199,
533,
13382,
5826,
8,
785,
304,
272,
347,
636,
826,
721,
277,
12,
7124,
304,
267,
291,
423,
5895,
275,
7124,
503,
942,
339,
347,
1511,
8,
277,
304,
267,
13736,
63,
1419,
275,
359,
288,
7124,
14,
4558,
14,
1708,
63,
1531,
12,
288,
7124,
14,
4558,
14,
10243,
12,
267,
1622,
267,
367,
3650,
315,
291,
423,
5895,
26,
288,
13736,
63,
1419,
275,
13736,
63,
1419,
435,
3650,
14,
1419,
342,
267,
327,
5852,
15755,
14,
267,
13736,
63,
1419,
275,
3355,
8,
409,
8,
22766,
63,
1419,
430,
267,
372,
13736,
63,
1419,
339,
347,
485,
1065,
8,
277,
12,
4744,
12,
1511,
12,
1174,
304,
267,
367,
3650,
315,
291,
423,
5895,
26,
288,
3650,
8,
3557,
12,
1511,
680,
1065,
8,
929,
9,
339,
347,
1255,
63,
460,
63,
2479,
63,
2550,
8,
277,
12,
4744,
12,
1511,
12,
1174,
29,
403,
304,
267,
340,
440,
1174,
26,
288,
1174,
275,
1052,
267,
862,
26,
288,
291,
423,
1065,
8,
3557,
12,
1511,
12,
1174,
9,
267,
871,
2670,
548,
28390,
4152,
12,
325,
26,
288,
485,
793,
14,
815,
480,
11421,
3405,
2952,
314,
15243,
365,
734,
402,
1434,
14,
7754,
1678,
436,
862,
4020,
2685,
288,
340,
1511,
14,
1708,
63,
1531,
26,
355,
1414,
275,
4744,
14,
1531,
63,
991,
63,
354,
8,
1419,
14,
1708,
63,
1531,
9,
355,
1414,
14,
2479,
63,
12891,
63,
10065,
63,
873,
8,
3557,
12,
1174,
12,
1511,
12,
325,
9,
288,
10703,
8524,
14,
2224,
63,
4399,
63,
11217,
63,
705,
8,
69,
9,
267,
871,
14914,
547,
12,
325,
26,
288,
340,
440,
1511,
14,
10243,
26,
355,
485,
793,
14,
705,
8,
69,
14,
1188,
63,
1045,
63,
1199,
1012,
288,
340,
1511,
14,
1708,
63,
1531,
26,
355,
1414,
275,
4744,
14,
1531,
63,
991,
63,
354,
8,
1419,
14,
1708,
63,
1531,
9,
355,
1414,
14,
2479,
63,
1579,
63,
705,
8,
3557,
12,
1174,
12,
325,
9,
288,
10703,
8524,
14,
2224,
63,
4399,
63,
11217,
63,
705,
8,
69,
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,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
mbrubeck/servo
|
tests/wpt/web-platform-tests/tools/pywebsocket/example/echo_noext_wsh.py
|
465
|
2404
|
# Copyright 2013, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following disclaimer
# in the documentation and/or other materials provided with the
# distribution.
# * Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
_GOODBYE_MESSAGE = u'Goodbye'
def web_socket_do_extra_handshake(request):
"""Received Sec-WebSocket-Extensions header value is parsed into
request.ws_requested_extensions. pywebsocket creates extension
processors using it before do_extra_handshake call and never looks at it
after the call.
To reject requested extensions, clear the processor list.
"""
request.ws_extension_processors = []
def web_socket_transfer_data(request):
"""Echo. Same as echo_wsh.py."""
while True:
line = request.ws_stream.receive_message()
if line is None:
return
if isinstance(line, unicode):
request.ws_stream.send_message(line, binary=False)
if line == _GOODBYE_MESSAGE:
return
else:
request.ws_stream.send_message(line, binary=True)
# vi:sts=4 sw=4 et
|
mpl-2.0
|
[
3,
1898,
6171,
12,
4475,
3277,
14,
199,
3,
2900,
4481,
4644,
14,
199,
3,
199,
3,
10114,
436,
675,
315,
1350,
436,
3366,
4513,
12,
543,
503,
1928,
199,
3,
7100,
12,
787,
8211,
2741,
626,
314,
2569,
3704,
787,
199,
3,
7647,
26,
199,
3,
199,
3,
258,
627,
6823,
402,
1350,
1233,
1471,
8074,
314,
3432,
4248,
199,
3,
4245,
12,
642,
769,
402,
3704,
436,
314,
2569,
6450,
14,
199,
3,
258,
627,
6823,
315,
3366,
1824,
1471,
9172,
314,
3432,
199,
3,
4248,
4245,
12,
642,
769,
402,
3704,
436,
314,
2569,
6450,
199,
3,
315,
314,
3794,
436,
15,
269,
1163,
8418,
2741,
543,
314,
199,
3,
4084,
14,
199,
3,
258,
627,
11443,
314,
536,
402,
4475,
3277,
14,
6590,
314,
1561,
402,
2399,
199,
3,
8417,
1443,
506,
1202,
370,
10692,
503,
10016,
7585,
7131,
687,
199,
3,
642,
2032,
1928,
2488,
6791,
5313,
4983,
14,
199,
3,
199,
3,
5749,
4141,
2281,
7049,
6515,
2334,
5877,
8164,
2401,
6483,
199,
3,
298,
1179,
2281,
2,
2401,
1821,
7168,
1549,
5292,
2990,
12,
6931,
12,
5400,
2845,
199,
3,
5471,
2296,
12,
2334,
5292,
2990,
1634,
3169,
2401,
3092,
2381,
199,
3,
437,
3115,
3104,
9315,
9706,
14,
1621,
4825,
6461,
7000,
2334,
5877,
199,
3,
11489,
1549,
6483,
6262,
7024,
2381,
1821,
8703,
12,
9168,
12,
9716,
12,
199,
3,
8820,
12,
9836,
12,
1549,
9110,
6736,
334,
6446,
12,
5400,
2845,
199,
3,
5471,
2296,
12,
9838,
1634,
9103,
9764,
1549,
9714,
27,
9102,
1634,
4815,
12,
199,
3,
7126,
12,
1549,
9206,
27,
1549,
9748,
9831,
9,
9802,
9817,
2401,
5258,
1821,
199,
3,
9815,
1634,
5603,
12,
7061,
1621,
7066,
12,
9644,
5603,
12,
1549,
7056,
199,
3,
334,
6446,
9254,
1549,
7334,
9,
7043,
1621,
1821,
9683,
5738,
1634,
2334,
4815,
199,
3,
1634,
5749,
4141,
12,
9704,
8036,
9691,
1634,
2334,
9726,
1634,
9712,
9784,
14,
421,
199,
63,
17316,
2846,
57,
37,
63,
8272,
275,
399,
7,
20652,
16481,
7,
421,
199,
318,
3330,
63,
3450,
63,
1117,
63,
2911,
63,
11913,
8,
1069,
304,
272,
408,
9392,
9433,
13,
18477,
13,
10597,
1406,
574,
365,
4565,
1901,
272,
1056,
14,
3569,
63,
11151,
63,
5359,
14,
1134,
13508,
8491,
3329,
272,
21620,
1808,
652,
2544,
886,
63,
2911,
63,
11913,
1240,
436,
7078,
10734,
737,
652,
272,
2410,
314,
1240,
14,
339,
4005,
17100,
5839,
5478,
12,
5436,
314,
12495,
769,
14,
272,
408,
339,
1056,
14,
3569,
63,
3435,
63,
10547,
275,
942,
421,
199,
318,
3330,
63,
3450,
63,
9609,
63,
576,
8,
1069,
304,
272,
408,
18690,
14,
14766,
465,
11343,
63,
87,
609,
14,
647,
1041,
339,
1830,
715,
26,
267,
1004,
275,
1056,
14,
3569,
63,
1745,
14,
9391,
63,
1188,
342,
267,
340,
1004,
365,
488,
26,
288,
372,
267,
340,
1228,
8,
604,
12,
2649,
304,
288,
1056,
14,
3569,
63,
1745,
14,
2254,
63,
1188,
8,
604,
12,
3366,
29,
797,
9,
288,
340,
1004,
508,
485,
17316,
2846,
57,
37,
63,
8272,
26,
355,
372,
267,
587,
26,
288,
1056,
14,
3569,
63,
1745,
14,
2254,
63,
1188,
8,
604,
12,
3366,
29,
549,
9,
421,
199,
3,
1321,
26,
10329,
29,
20,
5584,
29,
20,
10844,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
1898,
6171,
12,
4475,
3277,
14,
199,
3,
2900,
4481,
4644,
14,
199,
3,
199,
3,
10114,
436,
675,
315,
1350,
436,
3366,
4513,
12,
543,
503,
1928,
199,
3,
7100,
12,
787,
8211,
2741,
626,
314,
2569,
3704,
787,
199,
3,
7647,
26,
199,
3,
199,
3,
258,
627,
6823,
402,
1350,
1233,
1471,
8074,
314,
3432,
4248,
199,
3,
4245,
12,
642,
769,
402,
3704,
436,
314,
2569,
6450,
14,
199,
3,
258,
627,
6823,
315,
3366,
1824,
1471,
9172,
314,
3432,
199,
3,
4248,
4245,
12,
642,
769,
402,
3704,
436,
314,
2569,
6450,
199,
3,
315,
314,
3794,
436,
15,
269,
1163,
8418,
2741,
543,
314,
199,
3,
4084,
14,
199,
3,
258,
627,
11443,
314,
536,
402,
4475,
3277,
14,
6590,
314,
1561,
402,
2399,
199,
3,
8417,
1443,
506,
1202,
370,
10692,
503,
10016,
7585,
7131,
687,
199,
3,
642,
2032,
1928,
2488,
6791,
5313,
4983,
14,
199,
3,
199,
3,
5749,
4141,
2281,
7049,
6515,
2334,
5877,
8164,
2401,
6483,
199,
3,
298,
1179,
2281,
2,
2401,
1821,
7168,
1549,
5292,
2990,
12,
6931,
12,
5400,
2845,
199,
3,
5471,
2296,
12,
2334,
5292,
2990,
1634,
3169,
2401,
3092,
2381,
199,
3,
437,
3115,
3104,
9315,
9706,
14,
1621,
4825,
6461,
7000,
2334,
5877,
199,
3,
11489,
1549,
6483,
6262,
7024,
2381,
1821,
8703,
12,
9168,
12,
9716,
12,
199,
3,
8820,
12,
9836,
12,
1549,
9110,
6736,
334,
6446,
12,
5400,
2845,
199,
3,
5471,
2296,
12,
9838,
1634,
9103,
9764,
1549,
9714,
27,
9102,
1634,
4815,
12,
199,
3,
7126,
12,
1549,
9206,
27,
1549,
9748,
9831,
9,
9802,
9817,
2401,
5258,
1821,
199,
3,
9815,
1634,
5603,
12,
7061,
1621,
7066,
12,
9644,
5603,
12,
1549,
7056,
199,
3,
334,
6446,
9254,
1549,
7334,
9,
7043,
1621,
1821,
9683,
5738,
1634,
2334,
4815,
199,
3,
1634,
5749,
4141,
12,
9704,
8036,
9691,
1634,
2334,
9726,
1634,
9712,
9784,
14,
421,
199,
63,
17316,
2846,
57,
37,
63,
8272,
275,
399,
7,
20652,
16481,
7,
421,
199,
318,
3330,
63,
3450,
63,
1117,
63,
2911,
63,
11913,
8,
1069,
304,
272,
408,
9392,
9433,
13,
18477,
13,
10597,
1406,
574,
365,
4565,
1901,
272,
1056,
14,
3569,
63,
11151,
63,
5359,
14,
1134,
13508,
8491,
3329,
272,
21620,
1808,
652,
2544,
886,
63,
2911,
63,
11913,
1240,
436,
7078,
10734,
737,
652,
272,
2410,
314,
1240,
14,
339,
4005,
17100,
5839,
5478,
12,
5436,
314,
12495,
769,
14,
272,
408,
339,
1056,
14,
3569,
63,
3435,
63,
10547,
275,
942,
421,
199,
318,
3330,
63,
3450,
63,
9609,
63,
576,
8,
1069,
304,
272,
408,
18690,
14,
14766,
465,
11343,
63,
87,
609,
14,
647,
1041,
339,
1830,
715,
26,
267,
1004,
275,
1056,
14,
3569,
63,
1745,
14,
9391,
63,
1188,
342,
267,
340,
1004,
365,
488,
26,
288,
372,
267,
340,
1228,
8,
604,
12,
2649,
304,
288,
1056,
14,
3569,
63,
1745,
14,
2254,
63,
1188,
8,
604,
12,
3366,
29,
797,
9,
288,
340,
1004,
508,
485,
17316,
2846,
57,
37,
63,
8272,
26,
355,
372,
267,
587,
26,
288,
1056,
14,
3569,
63,
1745,
14,
2254,
63,
1188,
8,
604,
12,
3366,
29,
549,
9,
421,
199,
3,
1321,
26,
10329,
29,
20,
5584,
29,
20,
10844,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1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-python
|
azure-mgmt-resource/azure/mgmt/resource/resources/models/debug_setting.py
|
5
|
1296
|
# coding=utf-8
# --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
#
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
# --------------------------------------------------------------------------
from msrest.serialization import Model
class DebugSetting(Model):
"""DebugSetting.
:param detail_level: Specifies the type of information to log for
debugging. The permitted values are none, requestContent, responseContent,
or both requestContent and responseContent separated by a comma. The
default is none. When setting this value, carefully consider the type of
information you are passing in during deployment. By logging information
about the request or response, you could potentially expose sensitive data
that is retrieved through the deployment operations.
:type detail_level: str
"""
_attribute_map = {
'detail_level': {'key': 'detailLevel', 'type': 'str'},
}
def __init__(self, detail_level=None):
self.detail_level = detail_level
|
mit
|
[
3,
2803,
29,
1624,
13,
24,
199,
3,
24775,
199,
3,
1898,
334,
67,
9,
15332,
11098,
14,
2900,
4481,
4644,
14,
199,
3,
3909,
1334,
314,
10697,
844,
14,
1666,
844,
14,
2424,
315,
314,
2199,
1738,
367,
199,
3,
4190,
2556,
14,
199,
3,
199,
3,
5495,
4046,
701,
15332,
334,
50,
9,
9195,
13726,
5495,
15042,
14,
199,
3,
18784,
1443,
7675,
8927,
5953,
436,
911,
506,
14669,
340,
314,
1233,
365,
199,
3,
31904,
14,
199,
3,
24775,
199,
199,
504,
6605,
3911,
14,
12161,
492,
5822,
421,
199,
533,
14245,
7776,
8,
1685,
304,
272,
408,
7084,
7776,
14,
339,
520,
635,
10093,
63,
1896,
26,
11015,
314,
730,
402,
2556,
370,
943,
367,
1362,
10201,
14,
710,
8211,
1338,
787,
7179,
12,
1056,
2714,
12,
1177,
2714,
12,
1362,
503,
3865,
1056,
2714,
436,
1177,
2714,
11673,
701,
282,
10029,
14,
710,
1362,
849,
365,
7179,
14,
3979,
4260,
642,
574,
12,
21191,
8525,
11201,
314,
730,
402,
1362,
2556,
1265,
787,
9476,
315,
5309,
14295,
14,
4885,
2050,
2556,
1362,
3595,
314,
1056,
503,
1177,
12,
1265,
4293,
18994,
23705,
18423,
666,
1362,
626,
365,
12396,
4012,
314,
14295,
5331,
14,
272,
520,
466,
10093,
63,
1896,
26,
620,
272,
408,
339,
485,
3215,
63,
1130,
275,
469,
267,
283,
5506,
63,
1896,
356,
791,
498,
356,
283,
5506,
4670,
297,
283,
466,
356,
283,
495,
2267,
272,
789,
339,
347,
636,
826,
721,
277,
12,
10093,
63,
1896,
29,
403,
304,
267,
291,
14,
5506,
63,
1896,
275,
10093,
63,
1896,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
2803,
29,
1624,
13,
24,
199,
3,
24775,
199,
3,
1898,
334,
67,
9,
15332,
11098,
14,
2900,
4481,
4644,
14,
199,
3,
3909,
1334,
314,
10697,
844,
14,
1666,
844,
14,
2424,
315,
314,
2199,
1738,
367,
199,
3,
4190,
2556,
14,
199,
3,
199,
3,
5495,
4046,
701,
15332,
334,
50,
9,
9195,
13726,
5495,
15042,
14,
199,
3,
18784,
1443,
7675,
8927,
5953,
436,
911,
506,
14669,
340,
314,
1233,
365,
199,
3,
31904,
14,
199,
3,
24775,
199,
199,
504,
6605,
3911,
14,
12161,
492,
5822,
421,
199,
533,
14245,
7776,
8,
1685,
304,
272,
408,
7084,
7776,
14,
339,
520,
635,
10093,
63,
1896,
26,
11015,
314,
730,
402,
2556,
370,
943,
367,
1362,
10201,
14,
710,
8211,
1338,
787,
7179,
12,
1056,
2714,
12,
1177,
2714,
12,
1362,
503,
3865,
1056,
2714,
436,
1177,
2714,
11673,
701,
282,
10029,
14,
710,
1362,
849,
365,
7179,
14,
3979,
4260,
642,
574,
12,
21191,
8525,
11201,
314,
730,
402,
1362,
2556,
1265,
787,
9476,
315,
5309,
14295,
14,
4885,
2050,
2556,
1362,
3595,
314,
1056,
503,
1177,
12,
1265,
4293,
18994,
23705,
18423,
666,
1362,
626,
365,
12396,
4012,
314,
14295,
5331,
14,
272,
520,
466,
10093,
63,
1896,
26,
620,
272,
408,
339,
485,
3215,
63,
1130,
275,
469,
267,
283,
5506,
63,
1896,
356,
791,
498,
356,
283,
5506,
4670,
297,
283,
466,
356,
283,
495,
2267,
272,
789,
339,
347,
636,
826,
721,
277,
12,
10093,
63,
1896,
29,
403,
304,
267,
291,
14,
5506,
63,
1896,
275,
10093,
63,
1896,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
iruga090/python-social-auth
|
social/tests/test_utils.py
|
73
|
5018
|
import sys
import unittest2 as unittest
from mock import Mock
from social.utils import sanitize_redirect, user_is_authenticated, \
user_is_active, slugify, build_absolute_uri, \
partial_pipeline_data
PY3 = sys.version_info[0] == 3
class SanitizeRedirectTest(unittest.TestCase):
def test_none_redirect(self):
self.assertEqual(sanitize_redirect('myapp.com', None), None)
def test_empty_redirect(self):
self.assertEqual(sanitize_redirect('myapp.com', ''), None)
def test_dict_redirect(self):
self.assertEqual(sanitize_redirect('myapp.com', {}), None)
def test_invalid_redirect(self):
self.assertEqual(sanitize_redirect('myapp.com', {'foo': 'bar'}), None)
def test_wrong_path_redirect(self):
self.assertEqual(
sanitize_redirect('myapp.com', 'http://notmyapp.com/path/'),
None
)
def test_valid_absolute_redirect(self):
self.assertEqual(
sanitize_redirect('myapp.com', 'http://myapp.com/path/'),
'http://myapp.com/path/'
)
def test_valid_relative_redirect(self):
self.assertEqual(sanitize_redirect('myapp.com', '/path/'), '/path/')
class UserIsAuthenticatedTest(unittest.TestCase):
def test_user_is_none(self):
self.assertEqual(user_is_authenticated(None), False)
def test_user_is_not_none(self):
self.assertEqual(user_is_authenticated(object()), True)
def test_user_has_is_authenticated(self):
class User(object):
is_authenticated = True
self.assertEqual(user_is_authenticated(User()), True)
def test_user_has_is_authenticated_callable(self):
class User(object):
def is_authenticated(self):
return True
self.assertEqual(user_is_authenticated(User()), True)
class UserIsActiveTest(unittest.TestCase):
def test_user_is_none(self):
self.assertEqual(user_is_active(None), False)
def test_user_is_not_none(self):
self.assertEqual(user_is_active(object()), True)
def test_user_has_is_active(self):
class User(object):
is_active = True
self.assertEqual(user_is_active(User()), True)
def test_user_has_is_active_callable(self):
class User(object):
def is_active(self):
return True
self.assertEqual(user_is_active(User()), True)
class SlugifyTest(unittest.TestCase):
def test_slugify_formats(self):
if PY3:
self.assertEqual(slugify('FooBar'), 'foobar')
self.assertEqual(slugify('Foo Bar'), 'foo-bar')
self.assertEqual(slugify('Foo (Bar)'), 'foo-bar')
else:
self.assertEqual(slugify('FooBar'.decode('utf-8')), 'foobar')
self.assertEqual(slugify('Foo Bar'.decode('utf-8')), 'foo-bar')
self.assertEqual(slugify('Foo (Bar)'.decode('utf-8')), 'foo-bar')
class BuildAbsoluteURITest(unittest.TestCase):
def setUp(self):
self.host = 'http://foobar.com'
def tearDown(self):
self.host = None
def test_path_none(self):
self.assertEqual(build_absolute_uri(self.host), self.host)
def test_path_empty(self):
self.assertEqual(build_absolute_uri(self.host, ''), self.host)
def test_path_http(self):
self.assertEqual(build_absolute_uri(self.host, 'http://barfoo.com'),
'http://barfoo.com')
def test_path_https(self):
self.assertEqual(build_absolute_uri(self.host, 'https://barfoo.com'),
'https://barfoo.com')
def test_host_ends_with_slash_and_path_starts_with_slash(self):
self.assertEqual(build_absolute_uri(self.host + '/', '/foo/bar'),
'http://foobar.com/foo/bar')
def test_absolute_uri(self):
self.assertEqual(build_absolute_uri(self.host, '/foo/bar'),
'http://foobar.com/foo/bar')
class PartialPipelineData(unittest.TestCase):
def test_kwargs_included_in_result(self):
backend = self._backend()
key, val = ('foo', 'bar')
_, xkwargs = partial_pipeline_data(backend, None,
*(), **dict([(key, val)]))
self.assertTrue(key in xkwargs)
self.assertEqual(xkwargs[key], val)
def test_update_user(self):
user = object()
backend = self._backend(session_kwargs={'user': None})
_, xkwargs = partial_pipeline_data(backend, user)
self.assertTrue('user' in xkwargs)
self.assertEqual(xkwargs['user'], user)
def _backend(self, session_kwargs=None):
strategy = Mock()
strategy.request = None
strategy.session_get.return_value = object()
strategy.partial_from_session.return_value = \
(0, 'mock-backend', [], session_kwargs or {})
backend = Mock()
backend.name = 'mock-backend'
backend.strategy = strategy
return backend
|
bsd-3-clause
|
[
646,
984,
199,
646,
2882,
18,
465,
2882,
199,
199,
504,
1683,
492,
4420,
199,
199,
504,
20295,
14,
1208,
492,
21077,
63,
4876,
12,
922,
63,
374,
63,
12177,
12,
971,
586,
922,
63,
374,
63,
2682,
12,
29864,
12,
1900,
63,
6116,
63,
2302,
12,
971,
586,
7417,
63,
7379,
63,
576,
421,
199,
4521,
19,
275,
984,
14,
1023,
63,
815,
59,
16,
61,
508,
650,
421,
199,
533,
428,
12531,
7071,
774,
8,
2796,
14,
1746,
304,
272,
347,
511,
63,
3592,
63,
4876,
8,
277,
304,
267,
291,
14,
629,
8,
18177,
63,
4876,
360,
1662,
571,
14,
957,
297,
488,
395,
488,
9,
339,
347,
511,
63,
1667,
63,
4876,
8,
277,
304,
267,
291,
14,
629,
8,
18177,
63,
4876,
360,
1662,
571,
14,
957,
297,
9929,
488,
9,
339,
347,
511,
63,
807,
63,
4876,
8,
277,
304,
267,
291,
14,
629,
8,
18177,
63,
4876,
360,
1662,
571,
14,
957,
297,
8613,
488,
9,
339,
347,
511,
63,
3197,
63,
4876,
8,
277,
304,
267,
291,
14,
629,
8,
18177,
63,
4876,
360,
1662,
571,
14,
957,
297,
791,
1421,
356,
283,
1700,
1604,
488,
9,
339,
347,
511,
63,
10603,
63,
515,
63,
4876,
8,
277,
304,
267,
291,
14,
629,
8,
288,
21077,
63,
4876,
360,
1662,
571,
14,
957,
297,
283,
1014,
921,
1397,
1662,
571,
14,
957,
15,
515,
20467,
288,
488,
267,
776,
339,
347,
511,
63,
1078,
63,
6116,
63,
4876,
8,
277,
304,
267,
291,
14,
629,
8,
288,
21077,
63,
4876,
360,
1662,
571,
14,
957,
297,
283,
1014,
921,
1662,
571,
14,
957,
15,
515,
20467,
288,
283,
1014,
921,
1662,
571,
14,
957,
15,
515,
4805,
267,
776,
339,
347,
511,
63,
1078,
63,
6188,
63,
4876,
8,
277,
304,
267,
291,
14,
629,
8,
18177,
63,
4876,
360,
1662,
571,
14,
957,
297,
1994,
515,
20467,
1994,
515,
6217,
421,
199,
533,
2876,
1831,
30871,
774,
8,
2796,
14,
1746,
304,
272,
347,
511,
63,
751,
63,
374,
63,
3592,
8,
277,
304,
267,
291,
14,
629,
8,
751,
63,
374,
63,
12177,
8,
403,
395,
756,
9,
339,
347,
511,
63,
751,
63,
374,
63,
1397,
63,
3592,
8,
277,
304,
267,
291,
14,
629,
8,
751,
63,
374,
63,
12177,
8,
785,
4000,
715,
9,
339,
347,
511,
63,
751,
63,
1989,
63,
374,
63,
12177,
8,
277,
304,
267,
1021,
2876,
8,
785,
304,
288,
365,
63,
12177,
275,
715,
267,
291,
14,
629,
8,
751,
63,
374,
63,
12177,
8,
1899,
4000,
715,
9,
339,
347,
511,
63,
751,
63,
1989,
63,
374,
63,
12177,
63,
8296,
8,
277,
304,
267,
1021,
2876,
8,
785,
304,
288,
347,
365,
63,
12177,
8,
277,
304,
355,
372,
715,
267,
291,
14,
629,
8,
751,
63,
374,
63,
12177,
8,
1899,
4000,
715,
9,
421,
199,
533,
2876,
1831,
7472,
774,
8,
2796,
14,
1746,
304,
272,
347,
511,
63,
751,
63,
374,
63,
3592,
8,
277,
304,
267,
291,
14,
629,
8,
751,
63,
374,
63,
2682,
8,
403,
395,
756,
9,
339,
347,
511,
63,
751,
63,
374,
63,
1397,
63,
3592,
8,
277,
304,
267,
291,
14,
629,
8,
751,
63,
374,
63,
2682,
8,
785,
4000,
715,
9,
339,
347,
511,
63,
751,
63,
1989,
63,
374,
63,
2682,
8,
277,
304,
267,
1021,
2876,
8,
785,
304,
288,
365,
63,
2682,
275,
715,
267,
291,
14,
629,
8,
751,
63,
374,
63,
2682,
8,
1899,
4000,
715,
9,
339,
347,
511,
63,
751,
63,
1989,
63,
374,
63,
2682,
63,
8296,
8,
277,
304,
267,
1021,
2876,
8,
785,
304,
288,
347,
365,
63,
2682,
8,
277,
304,
355,
372,
715,
267,
291,
14,
629,
8,
751,
63,
374,
63,
2682,
8,
1899,
4000,
715,
9,
421,
199,
533,
428,
32047,
2021,
774,
8,
2796,
14,
1746,
304,
272,
347,
511,
63,
5464,
2021,
63,
6321,
8,
277,
304,
267,
340,
7843,
19,
26,
288,
291,
14,
629,
8,
5464,
2021,
360,
5686,
5281,
659,
283,
9664,
358,
288,
291,
14,
629,
8,
5464,
2021,
360,
5686,
12377,
659,
283,
1421,
13,
1700,
358,
288,
291,
14,
629,
8,
5464,
2021,
360,
5686,
334,
5281,
11218,
283,
1421,
13,
1700,
358,
267,
587,
26,
288,
291,
14,
629,
8,
5464,
2021,
360,
5686,
5281,
1370,
2708,
360,
1624,
13,
24,
3855,
283,
9664,
358,
288,
291,
14,
629,
8,
5464,
2021,
360,
5686,
12377,
1370,
2708,
360,
1624,
13,
24,
3855,
283,
1421,
13,
1700,
358,
288,
291,
14,
629,
8,
5464,
2021,
360,
5686,
334,
5281,
9,
1370,
2708,
360,
1624,
13,
24,
3855,
283,
1421,
13,
1700,
358,
421,
199,
533,
6516,
24677,
1230,
649,
597,
8,
2796,
14,
1746,
304,
272,
347,
3613,
8,
277,
304,
267,
291,
14,
1102,
275,
283,
1014,
921,
9664,
14,
957,
7,
339,
347,
6766,
8,
277,
304,
267,
291,
14,
1102,
275,
488,
339,
347,
511,
63,
515,
63,
3592,
8,
277,
304,
267,
291,
14,
629,
8,
1506,
63,
6116,
63,
2302,
8,
277,
14,
1102,
395,
291,
14,
1102,
9,
339,
347,
511,
63,
515,
63,
1667,
8,
277,
304,
267,
291,
14,
629,
8,
1506,
63,
6116,
63,
2302,
8,
277,
14,
1102,
12,
9929,
291,
14,
1102,
9,
339,
347,
511,
63,
515,
63,
1014,
8,
277,
304,
267,
291,
14,
629,
8,
1506,
63,
6116,
63,
2302,
8,
277,
14,
1102,
12,
283,
1014,
921,
1700,
1421,
14,
957,
659,
586,
283,
1014,
921,
1700,
1421,
14,
957,
358,
339,
347,
511,
63,
515,
63,
2859,
8,
277,
304,
267,
291,
14,
629,
8,
1506,
63,
6116,
63,
2302,
8,
277,
14,
1102,
12,
283,
2859,
921,
1700,
1421,
14,
957,
659,
586,
283,
2859,
921,
1700,
1421,
14,
957,
358,
339,
347,
511,
63,
1102,
63,
3198,
63,
1045,
63,
7001,
63,
460,
63,
515,
63,
17116,
63,
1045,
63,
7001,
8,
277,
304,
267,
291,
14,
629,
8,
1506,
63,
6116,
63,
2302,
8,
277,
14,
1102,
435,
17220,
1994,
1421,
15,
1700,
659,
586,
283,
1014,
921,
9664,
14,
957,
15,
1421,
15,
1700,
358,
339,
347,
511,
63
] |
[
984,
199,
646,
2882,
18,
465,
2882,
199,
199,
504,
1683,
492,
4420,
199,
199,
504,
20295,
14,
1208,
492,
21077,
63,
4876,
12,
922,
63,
374,
63,
12177,
12,
971,
586,
922,
63,
374,
63,
2682,
12,
29864,
12,
1900,
63,
6116,
63,
2302,
12,
971,
586,
7417,
63,
7379,
63,
576,
421,
199,
4521,
19,
275,
984,
14,
1023,
63,
815,
59,
16,
61,
508,
650,
421,
199,
533,
428,
12531,
7071,
774,
8,
2796,
14,
1746,
304,
272,
347,
511,
63,
3592,
63,
4876,
8,
277,
304,
267,
291,
14,
629,
8,
18177,
63,
4876,
360,
1662,
571,
14,
957,
297,
488,
395,
488,
9,
339,
347,
511,
63,
1667,
63,
4876,
8,
277,
304,
267,
291,
14,
629,
8,
18177,
63,
4876,
360,
1662,
571,
14,
957,
297,
9929,
488,
9,
339,
347,
511,
63,
807,
63,
4876,
8,
277,
304,
267,
291,
14,
629,
8,
18177,
63,
4876,
360,
1662,
571,
14,
957,
297,
8613,
488,
9,
339,
347,
511,
63,
3197,
63,
4876,
8,
277,
304,
267,
291,
14,
629,
8,
18177,
63,
4876,
360,
1662,
571,
14,
957,
297,
791,
1421,
356,
283,
1700,
1604,
488,
9,
339,
347,
511,
63,
10603,
63,
515,
63,
4876,
8,
277,
304,
267,
291,
14,
629,
8,
288,
21077,
63,
4876,
360,
1662,
571,
14,
957,
297,
283,
1014,
921,
1397,
1662,
571,
14,
957,
15,
515,
20467,
288,
488,
267,
776,
339,
347,
511,
63,
1078,
63,
6116,
63,
4876,
8,
277,
304,
267,
291,
14,
629,
8,
288,
21077,
63,
4876,
360,
1662,
571,
14,
957,
297,
283,
1014,
921,
1662,
571,
14,
957,
15,
515,
20467,
288,
283,
1014,
921,
1662,
571,
14,
957,
15,
515,
4805,
267,
776,
339,
347,
511,
63,
1078,
63,
6188,
63,
4876,
8,
277,
304,
267,
291,
14,
629,
8,
18177,
63,
4876,
360,
1662,
571,
14,
957,
297,
1994,
515,
20467,
1994,
515,
6217,
421,
199,
533,
2876,
1831,
30871,
774,
8,
2796,
14,
1746,
304,
272,
347,
511,
63,
751,
63,
374,
63,
3592,
8,
277,
304,
267,
291,
14,
629,
8,
751,
63,
374,
63,
12177,
8,
403,
395,
756,
9,
339,
347,
511,
63,
751,
63,
374,
63,
1397,
63,
3592,
8,
277,
304,
267,
291,
14,
629,
8,
751,
63,
374,
63,
12177,
8,
785,
4000,
715,
9,
339,
347,
511,
63,
751,
63,
1989,
63,
374,
63,
12177,
8,
277,
304,
267,
1021,
2876,
8,
785,
304,
288,
365,
63,
12177,
275,
715,
267,
291,
14,
629,
8,
751,
63,
374,
63,
12177,
8,
1899,
4000,
715,
9,
339,
347,
511,
63,
751,
63,
1989,
63,
374,
63,
12177,
63,
8296,
8,
277,
304,
267,
1021,
2876,
8,
785,
304,
288,
347,
365,
63,
12177,
8,
277,
304,
355,
372,
715,
267,
291,
14,
629,
8,
751,
63,
374,
63,
12177,
8,
1899,
4000,
715,
9,
421,
199,
533,
2876,
1831,
7472,
774,
8,
2796,
14,
1746,
304,
272,
347,
511,
63,
751,
63,
374,
63,
3592,
8,
277,
304,
267,
291,
14,
629,
8,
751,
63,
374,
63,
2682,
8,
403,
395,
756,
9,
339,
347,
511,
63,
751,
63,
374,
63,
1397,
63,
3592,
8,
277,
304,
267,
291,
14,
629,
8,
751,
63,
374,
63,
2682,
8,
785,
4000,
715,
9,
339,
347,
511,
63,
751,
63,
1989,
63,
374,
63,
2682,
8,
277,
304,
267,
1021,
2876,
8,
785,
304,
288,
365,
63,
2682,
275,
715,
267,
291,
14,
629,
8,
751,
63,
374,
63,
2682,
8,
1899,
4000,
715,
9,
339,
347,
511,
63,
751,
63,
1989,
63,
374,
63,
2682,
63,
8296,
8,
277,
304,
267,
1021,
2876,
8,
785,
304,
288,
347,
365,
63,
2682,
8,
277,
304,
355,
372,
715,
267,
291,
14,
629,
8,
751,
63,
374,
63,
2682,
8,
1899,
4000,
715,
9,
421,
199,
533,
428,
32047,
2021,
774,
8,
2796,
14,
1746,
304,
272,
347,
511,
63,
5464,
2021,
63,
6321,
8,
277,
304,
267,
340,
7843,
19,
26,
288,
291,
14,
629,
8,
5464,
2021,
360,
5686,
5281,
659,
283,
9664,
358,
288,
291,
14,
629,
8,
5464,
2021,
360,
5686,
12377,
659,
283,
1421,
13,
1700,
358,
288,
291,
14,
629,
8,
5464,
2021,
360,
5686,
334,
5281,
11218,
283,
1421,
13,
1700,
358,
267,
587,
26,
288,
291,
14,
629,
8,
5464,
2021,
360,
5686,
5281,
1370,
2708,
360,
1624,
13,
24,
3855,
283,
9664,
358,
288,
291,
14,
629,
8,
5464,
2021,
360,
5686,
12377,
1370,
2708,
360,
1624,
13,
24,
3855,
283,
1421,
13,
1700,
358,
288,
291,
14,
629,
8,
5464,
2021,
360,
5686,
334,
5281,
9,
1370,
2708,
360,
1624,
13,
24,
3855,
283,
1421,
13,
1700,
358,
421,
199,
533,
6516,
24677,
1230,
649,
597,
8,
2796,
14,
1746,
304,
272,
347,
3613,
8,
277,
304,
267,
291,
14,
1102,
275,
283,
1014,
921,
9664,
14,
957,
7,
339,
347,
6766,
8,
277,
304,
267,
291,
14,
1102,
275,
488,
339,
347,
511,
63,
515,
63,
3592,
8,
277,
304,
267,
291,
14,
629,
8,
1506,
63,
6116,
63,
2302,
8,
277,
14,
1102,
395,
291,
14,
1102,
9,
339,
347,
511,
63,
515,
63,
1667,
8,
277,
304,
267,
291,
14,
629,
8,
1506,
63,
6116,
63,
2302,
8,
277,
14,
1102,
12,
9929,
291,
14,
1102,
9,
339,
347,
511,
63,
515,
63,
1014,
8,
277,
304,
267,
291,
14,
629,
8,
1506,
63,
6116,
63,
2302,
8,
277,
14,
1102,
12,
283,
1014,
921,
1700,
1421,
14,
957,
659,
586,
283,
1014,
921,
1700,
1421,
14,
957,
358,
339,
347,
511,
63,
515,
63,
2859,
8,
277,
304,
267,
291,
14,
629,
8,
1506,
63,
6116,
63,
2302,
8,
277,
14,
1102,
12,
283,
2859,
921,
1700,
1421,
14,
957,
659,
586,
283,
2859,
921,
1700,
1421,
14,
957,
358,
339,
347,
511,
63,
1102,
63,
3198,
63,
1045,
63,
7001,
63,
460,
63,
515,
63,
17116,
63,
1045,
63,
7001,
8,
277,
304,
267,
291,
14,
629,
8,
1506,
63,
6116,
63,
2302,
8,
277,
14,
1102,
435,
17220,
1994,
1421,
15,
1700,
659,
586,
283,
1014,
921,
9664,
14,
957,
15,
1421,
15,
1700,
358,
339,
347,
511,
63,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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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
] |
vamshing/mase
|
python101/code/Card.py
|
19
|
3189
|
"""This module contains code from
Think Python by Allen B. Downey
http://thinkpython.com
Copyright 2012 Allen B. Downey
License: GNU GPLv3 http://www.gnu.org/licenses/gpl.html
"""
import random
class Card(object):
"""Represents a standard playing card.
Attributes:
suit: integer 0-3
rank: integer 1-13
"""
suit_names = ["Clubs", "Diamonds", "Hearts", "Spades"]
rank_names = [None, "Ace", "2", "3", "4", "5", "6", "7",
"8", "9", "10", "Jack", "Queen", "King"]
def __init__(self, suit=0, rank=2):
self.suit = suit
self.rank = rank
def __str__(self):
"""Returns a human-readable string representation."""
return '%s of %s' % (Card.rank_names[self.rank],
Card.suit_names[self.suit])
def __cmp__(self, other):
"""Compares this card to other, first by suit, then rank.
Returns a positive number if this > other; negative if other > this;
and 0 if they are equivalent.
"""
t1 = self.suit, self.rank
t2 = other.suit, other.rank
return cmp(t1, t2)
class Deck(object):
"""Represents a deck of cards.
Attributes:
cards: list of Card objects.
"""
def __init__(self):
self.cards = []
for suit in range(4):
for rank in range(1, 14):
card = Card(suit, rank)
self.cards.append(card)
def __str__(self):
res = []
for card in self.cards:
res.append(str(card))
return '\n'.join(res)
def add_card(self, card):
"""Adds a card to the deck."""
self.cards.append(card)
def remove_card(self, card):
"""Removes a card from the deck."""
self.cards.remove(card)
def pop_card(self, i=-1):
"""Removes and returns a card from the deck.
i: index of the card to pop; by default, pops the last card.
"""
return self.cards.pop(i)
def shuffle(self):
"""Shuffles the cards in this deck."""
random.shuffle(self.cards)
def sort(self):
"""Sorts the cards in ascending order."""
self.cards.sort()
def move_cards(self, hand, num):
"""Moves the given number of cards from the deck into the Hand.
hand: destination Hand object
num: integer number of cards to move
"""
for i in range(num):
hand.add_card(self.pop_card())
class Hand(Deck):
"""Represents a hand of playing cards."""
def __init__(self, label=''):
self.cards = []
self.label = label
def find_defining_class(obj, method_name):
"""Finds and returns the class object that will provide
the definition of method_name (as a string) if it is
invoked on obj.
obj: any python object
method_name: string method name
"""
for ty in type(obj).mro():
if method_name in ty.__dict__:
return ty
return None
if __name__ == '__main__':
deck = Deck()
deck.shuffle()
hand = Hand()
print find_defining_class(hand, 'shuffle')
deck.move_cards(hand, 5)
hand.sort()
print hand
|
unlicense
|
[
624,
2765,
859,
3509,
1233,
687,
199,
2719,
2292,
2018,
701,
4580,
552,
699,
14,
577,
583,
23263,
199,
1014,
921,
29727,
1548,
14,
957,
199,
199,
7384,
6029,
4580,
552,
699,
14,
577,
583,
23263,
199,
3761,
26,
1664,
14629,
86,
19,
1455,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
15,
11692,
14,
1360,
199,
199,
624,
199,
199,
646,
2196,
421,
199,
533,
445,
1005,
8,
785,
304,
272,
408,
18089,
282,
4465,
25692,
12564,
14,
2286,
9382,
26,
489,
308,
4993,
26,
3000,
378,
13,
19,
489,
6915,
26,
3000,
413,
13,
969,
272,
408,
339,
308,
4993,
63,
1247,
275,
2097,
1968,
30327,
401,
298,
1341,
455,
265,
795,
401,
298,
1966,
32611,
401,
298,
12739,
3424,
937,
272,
6915,
63,
1247,
275,
359,
403,
12,
298,
33,
301,
401,
298,
18,
401,
298,
19,
401,
298,
20,
401,
298,
21,
401,
298,
22,
401,
298,
23,
401,
221,
1598,
298,
24,
401,
298,
25,
401,
298,
709,
401,
298,
42,
564,
401,
298,
49,
310,
287,
401,
298,
43,
316,
937,
339,
347,
636,
826,
721,
277,
12,
308,
4993,
29,
16,
12,
6915,
29,
18,
304,
267,
291,
14,
83,
4993,
275,
308,
4993,
267,
291,
14,
4648,
275,
6915,
339,
347,
636,
495,
721,
277,
304,
267,
408,
3407,
282,
11779,
13,
11875,
1059,
6025,
1041,
267,
372,
1543,
83,
402,
450,
83,
7,
450,
334,
13832,
14,
4648,
63,
1247,
59,
277,
14,
4648,
467,
2490,
445,
1005,
14,
83,
4993,
63,
1247,
59,
277,
14,
83,
4993,
566,
339,
347,
636,
5730,
721,
277,
12,
1163,
304,
267,
408,
2404,
11044,
642,
12564,
370,
1163,
12,
1642,
701,
308,
4993,
12,
2066,
6915,
14,
398,
1803,
282,
7317,
1329,
340,
642,
690,
1163,
27,
6946,
340,
1163,
690,
642,
27,
267,
436,
378,
340,
2985,
787,
7353,
14,
267,
408,
267,
307,
17,
275,
291,
14,
83,
4993,
12,
291,
14,
4648,
267,
307,
18,
275,
1163,
14,
83,
4993,
12,
1163,
14,
4648,
267,
372,
10467,
8,
84,
17,
12,
307,
18,
9,
421,
199,
533,
1487,
346,
8,
785,
304,
272,
408,
18089,
282,
477,
346,
402,
27181,
14,
339,
9382,
26,
489,
27181,
26,
769,
402,
445,
1005,
2251,
14,
272,
408,
2286,
347,
636,
826,
721,
277,
304,
267,
291,
14,
13761,
275,
942,
267,
367,
308,
4993,
315,
1425,
8,
20,
304,
288,
367,
6915,
315,
1425,
8,
17,
12,
4329,
304,
355,
12564,
275,
445,
1005,
8,
83,
4993,
12,
6915,
9,
355,
291,
14,
13761,
14,
740,
8,
5841,
9,
339,
347,
636,
495,
721,
277,
304,
267,
522,
275,
942,
267,
367,
12564,
315,
291,
14,
13761,
26,
288,
522,
14,
740,
8,
495,
8,
5841,
430,
267,
372,
1557,
78,
1370,
904,
8,
470,
9,
339,
347,
1050,
63,
5841,
8,
277,
12,
12564,
304,
267,
408,
14995,
282,
12564,
370,
314,
477,
346,
1041,
267,
291,
14,
13761,
14,
740,
8,
5841,
9,
339,
347,
2813,
63,
5841,
8,
277,
12,
12564,
304,
267,
408,
22948,
282,
12564,
687,
314,
477,
346,
1041,
267,
291,
14,
13761,
14,
2168,
8,
5841,
9,
339,
347,
4560,
63,
5841,
8,
277,
12,
284,
4022,
17,
304,
267,
408,
22948,
436,
2529,
282,
12564,
687,
314,
477,
346,
14,
398,
284,
26,
1478,
402,
314,
12564,
370,
4560,
27,
701,
849,
12,
299,
1483,
314,
2061,
12564,
14,
267,
408,
267,
372,
291,
14,
13761,
14,
1935,
8,
73,
9,
339,
347,
13031,
8,
277,
304,
267,
408,
2662,
3043,
2978,
314,
27181,
315,
642,
477,
346,
1041,
267,
2196,
14,
11777,
8,
277,
14,
13761,
9,
339,
347,
4069,
8,
277,
304,
267,
408,
14376,
83,
314,
27181,
315,
24525,
1865,
1041,
267,
291,
14,
13761,
14,
3191,
342,
339,
347,
4057,
63,
13761,
8,
277,
12,
4926,
12,
1967,
304,
267,
408,
3716,
2310,
314,
1627,
1329,
402,
27181,
687,
314,
477,
346,
1901,
314,
18405,
14,
398,
4926,
26,
5724,
18405,
909,
267,
1967,
26,
3000,
1329,
402,
27181,
370,
4057,
267,
408,
267,
367,
284,
315,
1425,
8,
1507,
304,
288,
4926,
14,
525,
63,
5841,
8,
277,
14,
1935,
63,
5841,
1012,
421,
199,
533,
18405,
8,
872,
346,
304,
272,
408,
18089,
282,
4926,
402,
25692,
27181,
1041,
2286,
347,
636,
826,
721,
277,
12,
1768,
9280,
267,
291,
14,
13761,
275,
942,
267,
291,
14,
1302,
275,
1768,
421,
199,
318,
2342,
63,
318,
7969,
63,
533,
8,
1113,
12,
1083,
63,
354,
304,
272,
408,
30344,
436,
2529,
314,
1021,
909,
626,
911,
5647,
5591,
314,
5492,
402,
1083,
63,
354,
334,
305,
282,
1059,
9,
340,
652,
365,
272,
10302,
641,
1559,
14,
339,
1559,
26,
1263,
2366,
909,
272,
1083,
63,
354,
26,
1059,
1083,
536,
272,
408,
272,
367,
10284,
315,
730,
8,
1113,
680,
17335,
837,
267,
340,
1083,
63,
354,
315,
10284,
855,
807,
10651,
288,
372,
10284,
272,
372,
488,
421,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
272,
477,
346,
275,
1487,
346,
342,
272,
477,
346,
14,
11777,
342,
339,
4926,
275,
18405,
342,
272,
870,
2342,
63,
318,
7969,
63,
533,
8,
6868,
12,
283,
11777,
358,
339,
477,
346,
14,
1185,
63,
13761,
8,
6868,
12,
959,
9,
272,
4926,
14,
3191,
342,
272,
870,
4926,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
2765,
859,
3509,
1233,
687,
199,
2719,
2292,
2018,
701,
4580,
552,
699,
14,
577,
583,
23263,
199,
1014,
921,
29727,
1548,
14,
957,
199,
199,
7384,
6029,
4580,
552,
699,
14,
577,
583,
23263,
199,
3761,
26,
1664,
14629,
86,
19,
1455,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
15,
11692,
14,
1360,
199,
199,
624,
199,
199,
646,
2196,
421,
199,
533,
445,
1005,
8,
785,
304,
272,
408,
18089,
282,
4465,
25692,
12564,
14,
2286,
9382,
26,
489,
308,
4993,
26,
3000,
378,
13,
19,
489,
6915,
26,
3000,
413,
13,
969,
272,
408,
339,
308,
4993,
63,
1247,
275,
2097,
1968,
30327,
401,
298,
1341,
455,
265,
795,
401,
298,
1966,
32611,
401,
298,
12739,
3424,
937,
272,
6915,
63,
1247,
275,
359,
403,
12,
298,
33,
301,
401,
298,
18,
401,
298,
19,
401,
298,
20,
401,
298,
21,
401,
298,
22,
401,
298,
23,
401,
221,
1598,
298,
24,
401,
298,
25,
401,
298,
709,
401,
298,
42,
564,
401,
298,
49,
310,
287,
401,
298,
43,
316,
937,
339,
347,
636,
826,
721,
277,
12,
308,
4993,
29,
16,
12,
6915,
29,
18,
304,
267,
291,
14,
83,
4993,
275,
308,
4993,
267,
291,
14,
4648,
275,
6915,
339,
347,
636,
495,
721,
277,
304,
267,
408,
3407,
282,
11779,
13,
11875,
1059,
6025,
1041,
267,
372,
1543,
83,
402,
450,
83,
7,
450,
334,
13832,
14,
4648,
63,
1247,
59,
277,
14,
4648,
467,
2490,
445,
1005,
14,
83,
4993,
63,
1247,
59,
277,
14,
83,
4993,
566,
339,
347,
636,
5730,
721,
277,
12,
1163,
304,
267,
408,
2404,
11044,
642,
12564,
370,
1163,
12,
1642,
701,
308,
4993,
12,
2066,
6915,
14,
398,
1803,
282,
7317,
1329,
340,
642,
690,
1163,
27,
6946,
340,
1163,
690,
642,
27,
267,
436,
378,
340,
2985,
787,
7353,
14,
267,
408,
267,
307,
17,
275,
291,
14,
83,
4993,
12,
291,
14,
4648,
267,
307,
18,
275,
1163,
14,
83,
4993,
12,
1163,
14,
4648,
267,
372,
10467,
8,
84,
17,
12,
307,
18,
9,
421,
199,
533,
1487,
346,
8,
785,
304,
272,
408,
18089,
282,
477,
346,
402,
27181,
14,
339,
9382,
26,
489,
27181,
26,
769,
402,
445,
1005,
2251,
14,
272,
408,
2286,
347,
636,
826,
721,
277,
304,
267,
291,
14,
13761,
275,
942,
267,
367,
308,
4993,
315,
1425,
8,
20,
304,
288,
367,
6915,
315,
1425,
8,
17,
12,
4329,
304,
355,
12564,
275,
445,
1005,
8,
83,
4993,
12,
6915,
9,
355,
291,
14,
13761,
14,
740,
8,
5841,
9,
339,
347,
636,
495,
721,
277,
304,
267,
522,
275,
942,
267,
367,
12564,
315,
291,
14,
13761,
26,
288,
522,
14,
740,
8,
495,
8,
5841,
430,
267,
372,
1557,
78,
1370,
904,
8,
470,
9,
339,
347,
1050,
63,
5841,
8,
277,
12,
12564,
304,
267,
408,
14995,
282,
12564,
370,
314,
477,
346,
1041,
267,
291,
14,
13761,
14,
740,
8,
5841,
9,
339,
347,
2813,
63,
5841,
8,
277,
12,
12564,
304,
267,
408,
22948,
282,
12564,
687,
314,
477,
346,
1041,
267,
291,
14,
13761,
14,
2168,
8,
5841,
9,
339,
347,
4560,
63,
5841,
8,
277,
12,
284,
4022,
17,
304,
267,
408,
22948,
436,
2529,
282,
12564,
687,
314,
477,
346,
14,
398,
284,
26,
1478,
402,
314,
12564,
370,
4560,
27,
701,
849,
12,
299,
1483,
314,
2061,
12564,
14,
267,
408,
267,
372,
291,
14,
13761,
14,
1935,
8,
73,
9,
339,
347,
13031,
8,
277,
304,
267,
408,
2662,
3043,
2978,
314,
27181,
315,
642,
477,
346,
1041,
267,
2196,
14,
11777,
8,
277,
14,
13761,
9,
339,
347,
4069,
8,
277,
304,
267,
408,
14376,
83,
314,
27181,
315,
24525,
1865,
1041,
267,
291,
14,
13761,
14,
3191,
342,
339,
347,
4057,
63,
13761,
8,
277,
12,
4926,
12,
1967,
304,
267,
408,
3716,
2310,
314,
1627,
1329,
402,
27181,
687,
314,
477,
346,
1901,
314,
18405,
14,
398,
4926,
26,
5724,
18405,
909,
267,
1967,
26,
3000,
1329,
402,
27181,
370,
4057,
267,
408,
267,
367,
284,
315,
1425,
8,
1507,
304,
288,
4926,
14,
525,
63,
5841,
8,
277,
14,
1935,
63,
5841,
1012,
421,
199,
533,
18405,
8,
872,
346,
304,
272,
408,
18089,
282,
4926,
402,
25692,
27181,
1041,
2286,
347,
636,
826,
721,
277,
12,
1768,
9280,
267,
291,
14,
13761,
275,
942,
267,
291,
14,
1302,
275,
1768,
421,
199,
318,
2342,
63,
318,
7969,
63,
533,
8,
1113,
12,
1083,
63,
354,
304,
272,
408,
30344,
436,
2529,
314,
1021,
909,
626,
911,
5647,
5591,
314,
5492,
402,
1083,
63,
354,
334,
305,
282,
1059,
9,
340,
652,
365,
272,
10302,
641,
1559,
14,
339,
1559,
26,
1263,
2366,
909,
272,
1083,
63,
354,
26,
1059,
1083,
536,
272,
408,
272,
367,
10284,
315,
730,
8,
1113,
680,
17335,
837,
267,
340,
1083,
63,
354,
315,
10284,
855,
807,
10651,
288,
372,
10284,
272,
372,
488,
421,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
272,
477,
346,
275,
1487,
346,
342,
272,
477,
346,
14,
11777,
342,
339,
4926,
275,
18405,
342,
272,
870,
2342,
63,
318,
7969,
63,
533,
8,
6868,
12,
283,
11777,
358,
339,
477,
346,
14,
1185,
63,
13761,
8,
6868,
12,
959,
9,
272,
4926,
14,
3191,
342,
272,
870,
4926,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
Ajapaik/ajapaik-web
|
ajapaik/ajapaik_face_recognition/management/commands/run_face_encoding_on_unencoded_rectangles.py
|
1
|
1387
|
import multiprocessing
from json import loads, dumps
import face_recognition
from django.core.management.base import BaseCommand
from ajapaik.ajapaik_face_recognition.models import FaceRecognitionRectangle
def encode_single_rectangle(rectangle: FaceRecognitionRectangle) -> None:
print('Processing rectangle %s' % rectangle.pk)
try:
image = face_recognition.load_image_file(rectangle.photo.image)
except: # noqa
return
try:
encodings = face_recognition.face_encodings(image, known_face_locations=[loads(rectangle.coordinates)])
except: # noqa
return
if len(encodings) == 1:
my_encoding = encodings[0]
try:
rectangle.face_encoding = dumps(my_encoding.tolist())
rectangle.save()
except: # noqa
return
else:
print('Found % face encodings for rectangle %s, should find only 1' % (len(encodings), rectangle.id))
class Command(BaseCommand):
help = 'Will run face encoding on all identified faces'
args = 'subject_id'
def handle(self, *args, **options):
unknown_rectangles = FaceRecognitionRectangle.objects.filter(face_encoding__isnull=True).all()
print('Found %s rectangles to run on' % unknown_rectangles.count())
with multiprocessing.Pool() as pool:
pool.map(encode_single_rectangle, unknown_rectangles)
|
gpl-3.0
|
[
646,
12866,
199,
504,
2022,
492,
14404,
12,
16864,
199,
199,
646,
8870,
63,
29324,
15415,
199,
504,
1639,
14,
1018,
14,
8110,
14,
1095,
492,
22239,
199,
199,
504,
282,
3387,
387,
3258,
14,
65,
3387,
387,
3258,
63,
1409,
63,
29324,
15415,
14,
992,
492,
21459,
497,
6862,
15415,
18127,
421,
199,
318,
3752,
63,
4780,
63,
19954,
8,
19954,
26,
21459,
497,
6862,
15415,
18127,
9,
1035,
488,
26,
272,
870,
360,
9589,
20412,
450,
83,
7,
450,
20412,
14,
2051,
9,
272,
862,
26,
267,
1834,
275,
8870,
63,
29324,
15415,
14,
912,
63,
1569,
63,
493,
8,
19954,
14,
13834,
14,
1569,
9,
272,
871,
26,
221,
327,
8151,
267,
372,
272,
862,
26,
267,
14134,
275,
8870,
63,
29324,
15415,
14,
1409,
63,
21138,
8,
1569,
12,
6040,
63,
1409,
63,
8022,
1524,
3640,
8,
19954,
14,
12924,
3948,
272,
871,
26,
221,
327,
8151,
267,
372,
272,
340,
822,
8,
21138,
9,
508,
413,
26,
267,
3002,
63,
2991,
275,
14134,
59,
16,
61,
267,
862,
26,
288,
20412,
14,
1409,
63,
2991,
275,
16864,
8,
1662,
63,
2991,
14,
13633,
1012,
288,
20412,
14,
2117,
342,
267,
871,
26,
221,
327,
8151,
288,
372,
272,
587,
26,
267,
870,
360,
3601,
450,
8870,
14134,
367,
20412,
450,
83,
12,
1077,
2342,
1454,
413,
7,
450,
334,
552,
8,
21138,
395,
20412,
14,
344,
430,
421,
199,
533,
5817,
8,
25150,
304,
272,
1720,
275,
283,
20326,
1255,
8870,
2644,
641,
1006,
15836,
21143,
7,
272,
1249,
275,
283,
5875,
63,
344,
7,
339,
347,
2429,
8,
277,
12,
627,
589,
12,
1011,
1419,
304,
267,
5809,
63,
1201,
13162,
275,
21459,
497,
6862,
15415,
18127,
14,
1462,
14,
1541,
8,
1409,
63,
2991,
363,
15114,
29,
549,
680,
452,
342,
267,
870,
360,
3601,
450,
83,
8626,
13162,
370,
1255,
641,
7,
450,
5809,
63,
1201,
13162,
14,
835,
1012,
267,
543,
12866,
14,
5453,
342,
465,
4203,
26,
288,
4203,
14,
1130,
8,
2143,
63,
4780,
63,
19954,
12,
5809,
63,
1201,
13162,
9,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
12866,
199,
504,
2022,
492,
14404,
12,
16864,
199,
199,
646,
8870,
63,
29324,
15415,
199,
504,
1639,
14,
1018,
14,
8110,
14,
1095,
492,
22239,
199,
199,
504,
282,
3387,
387,
3258,
14,
65,
3387,
387,
3258,
63,
1409,
63,
29324,
15415,
14,
992,
492,
21459,
497,
6862,
15415,
18127,
421,
199,
318,
3752,
63,
4780,
63,
19954,
8,
19954,
26,
21459,
497,
6862,
15415,
18127,
9,
1035,
488,
26,
272,
870,
360,
9589,
20412,
450,
83,
7,
450,
20412,
14,
2051,
9,
272,
862,
26,
267,
1834,
275,
8870,
63,
29324,
15415,
14,
912,
63,
1569,
63,
493,
8,
19954,
14,
13834,
14,
1569,
9,
272,
871,
26,
221,
327,
8151,
267,
372,
272,
862,
26,
267,
14134,
275,
8870,
63,
29324,
15415,
14,
1409,
63,
21138,
8,
1569,
12,
6040,
63,
1409,
63,
8022,
1524,
3640,
8,
19954,
14,
12924,
3948,
272,
871,
26,
221,
327,
8151,
267,
372,
272,
340,
822,
8,
21138,
9,
508,
413,
26,
267,
3002,
63,
2991,
275,
14134,
59,
16,
61,
267,
862,
26,
288,
20412,
14,
1409,
63,
2991,
275,
16864,
8,
1662,
63,
2991,
14,
13633,
1012,
288,
20412,
14,
2117,
342,
267,
871,
26,
221,
327,
8151,
288,
372,
272,
587,
26,
267,
870,
360,
3601,
450,
8870,
14134,
367,
20412,
450,
83,
12,
1077,
2342,
1454,
413,
7,
450,
334,
552,
8,
21138,
395,
20412,
14,
344,
430,
421,
199,
533,
5817,
8,
25150,
304,
272,
1720,
275,
283,
20326,
1255,
8870,
2644,
641,
1006,
15836,
21143,
7,
272,
1249,
275,
283,
5875,
63,
344,
7,
339,
347,
2429,
8,
277,
12,
627,
589,
12,
1011,
1419,
304,
267,
5809,
63,
1201,
13162,
275,
21459,
497,
6862,
15415,
18127,
14,
1462,
14,
1541,
8,
1409,
63,
2991,
363,
15114,
29,
549,
680,
452,
342,
267,
870,
360,
3601,
450,
83,
8626,
13162,
370,
1255,
641,
7,
450,
5809,
63,
1201,
13162,
14,
835,
1012,
267,
543,
12866,
14,
5453,
342,
465,
4203,
26,
288,
4203,
14,
1130,
8,
2143,
63,
4780,
63,
19954,
12,
5809,
63,
1201,
13162,
9,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
servo/servo
|
tests/wpt/web-platform-tests/css/vendor-imports/mozilla/mozilla-central-reftests/text3/support/generate-segment-break-transformation-rules-tests.py
|
10
|
4886
|
#!/usr/bin/env python
# - * - coding: UTF-8 - * -
"""
This script generates tests segment-break-transformation-rules-001 ~ 049 which
cover all possible combinations of characters at two sides of segment breaks.
More specifically, there are seven types of characters involve in these rules:
1. East Asian Full-width (F)
2. East Asian Half-width (H)
3. East Asian Wide (W) except Hangul
4. East Asian Narrow (Na)
5. East Asian Ambiguous (A)
6. Not East Asian (Neutral)
7. Hangul
So there are 49 different combinations. It outputs a list of all
tests it generated in the format of Mozilla reftest.list to the stdout.
"""
from __future__ import unicode_literals, print_function, absolute_import
TEST_FILE = 'segment-break-transformation-rules-{:03}.html'
TEST_TEMPLATE = '''<!DOCTYPE html>
<meta charset="utf-8">
<title>CSS Reftest Test: Segment Break Transformation Rules</title>
<link rel="author" title="Chun-Min (Jeremy) Chen" href="mailto:jeremychen@mozilla.com">
<link rel="author" title="Mozilla" href="https://www.mozilla.org">
<link rel="help" href="https://drafts.csswg.org/css-text-3/#line-break-transform">
<meta name="assert" content="'segment-break-transformation-rules: with {prev}/{next} in front/back of the semgment break.">
<link rel="stylesheet" type="text/css" href="/fonts/ahem.css">
<link rel="match" href="segment-break-transformation-rules-{index:03}-ref.html">
<style> p {{ font-family: ahem; }} </style>
<div>Pass if there is {expect} white space between the two strings below.
<p>{prevchar}
{nextchar}</p>
</div>
'''
REF_FILE = 'segment-break-transformation-rules-{:03}-ref.html'
REF_TEMPLATE_REMOVE = '''<!DOCTYPE html>
<meta charset="utf-8">
<title>CSS Reftest Reference: Segment Break Transformation Rules</title>
<link rel="author" title="Chun-Min (Jeremy) Chen" href="mailto:jeremychen@mozilla.com">
<link rel="author" title="Mozilla" href="https://www.mozilla.org">
<link rel="stylesheet" type="text/css" href="/fonts/ahem.css">
<style> p {{ font-family: ahem; }} </style>
<div>Pass if there is NO white space between the two strings below.
<p>{0}{1}</p>
</div>
'''
REF_TEMPLATE_KEEP = '''<!DOCTYPE html>
<meta charset="utf-8">
<title>CSS Reftest Reference: Segment Break Transformation Rules</title>
<link rel="author" title="Chun-Min (Jeremy) Chen" href="mailto:jeremychen@mozilla.com">
<link rel="author" title="Mozilla" href="https://www.mozilla.org">
<link rel="stylesheet" type="text/css" href="/fonts/ahem.css">
<style> p {{ font-family: ahem; }} </style>
<div>Pass if there is ONE white space between the two strings below.
<p>{0}{2}{1}</p>
</div>
'''
CHAR_SET = [
('East Asian Full-width (F)', 'FULLWIDTH'),
('East Asian Half-width (H)', 'テスト'),
('East Asian Wide (W) except Hangul', '測試'),
('East Asian Narrow (Na)', 'narrow'),
('East Asian Ambiguous (A)', '■'),
('Not East Asian (Neutral)', 'آزمون'),
('Hangul', '테스트'),
]
def write_file(filename, content):
with open(filename, 'wb') as f:
f.write(content.encode('UTF-8'))
print("# START tests from {}".format(__file__))
global idx
idx = 0
for i, (prevtype, prevchars) in enumerate(CHAR_SET):
for j, (nextype, nextchars) in enumerate(CHAR_SET):
idx += 1
reffilename = REF_FILE.format(idx)
testfilename = TEST_FILE.format(idx)
# According to CSS Text 3 - 4.1.2. Segment Break Transformation Rules,
# if the East Asian Width property of both the character before and
# after the segment break is F, W, or H (not A), and neither side is
# Hangul, then the segment break is removed. Otherwise, the segment
# break is converted to a space (U+0020).
if i < 3 and j < 3:
write_file(reffilename,
REF_TEMPLATE_REMOVE.format(prevchars, nextchars))
write_file(testfilename,
TEST_TEMPLATE.format(index=idx, prev=prevtype,
next=nextype,
prevchar=prevchars,
nextchar=nextchars,
expect='NO'))
else:
write_file(reffilename,
REF_TEMPLATE_KEEP.format(prevchars, nextchars, ' '))
write_file(testfilename,
TEST_TEMPLATE.format(index=idx, prev=prevtype,
next=nextype,
prevchar=prevchars,
nextchar=nextchars,
expect='ONE'))
print("== {} {}".format(testfilename, reffilename))
print("# END tests from {}".format(__file__))
|
mpl-2.0
|
[
3381,
2647,
15,
1393,
15,
1813,
2366,
199,
3,
446,
627,
446,
2803,
26,
9094,
13,
24,
446,
627,
446,
199,
199,
624,
199,
2765,
2884,
12821,
2295,
8135,
13,
4785,
13,
31400,
13,
4423,
13,
4587,
6146,
378,
1887,
1314,
199,
5899,
1006,
3962,
15821,
402,
4110,
737,
2877,
27613,
402,
8135,
18277,
14,
199,
11053,
22543,
12,
2337,
787,
542,
1856,
2943,
402,
4110,
4572,
3344,
315,
3520,
4713,
26,
199,
199,
17,
14,
662,
1810,
437,
6214,
16579,
13,
2063,
334,
38,
9,
199,
18,
14,
662,
1810,
437,
6214,
869,
7411,
13,
2063,
334,
40,
9,
199,
19,
14,
662,
1810,
437,
6214,
32612,
334,
55,
9,
871,
869,
621,
348,
199,
20,
14,
662,
1810,
437,
6214,
653,
7691,
334,
8565,
9,
199,
21,
14,
662,
1810,
437,
6214,
437,
887,
20357,
334,
33,
9,
199,
22,
14,
2832,
662,
1810,
437,
6214,
334,
4698,
29358,
9,
199,
23,
14,
869,
621,
348,
199,
199,
5158,
2337,
787,
12260,
3365,
15821,
14,
2779,
4704,
282,
769,
402,
1006,
199,
2219,
652,
4046,
315,
314,
1475,
402,
17728,
2984,
396,
14,
513,
370,
314,
3839,
14,
199,
624,
199,
199,
504,
636,
2443,
363,
492,
2649,
63,
5955,
12,
870,
63,
1593,
12,
3679,
63,
646,
199,
199,
2864,
63,
3817,
275,
283,
9255,
13,
4785,
13,
31400,
13,
4423,
24185,
26,
1644,
5565,
1360,
7,
199,
2864,
63,
7433,
275,
1449,
11230,
16556,
3517,
30,
199,
28,
2024,
5960,
628,
1624,
13,
24,
1743,
199,
28,
1213,
30,
14391,
15397,
396,
1379,
26,
29858,
22535,
6266,
1869,
24259,
1108,
1213,
30,
199,
28,
1073,
4668,
628,
2502,
2,
2538,
628,
1049,
324,
13,
4649,
334,
27888,
264,
1662,
9,
2799,
287,
2,
4369,
628,
26206,
26,
6532,
264,
1662,
24604,
32,
12102,
14,
957,
1743,
199,
28,
1073,
4668,
628,
2502,
2,
2538,
628,
22285,
2,
4369,
628,
2859,
921,
1544,
14,
12102,
14,
1308,
1743,
199,
28,
1073,
4668,
628,
3437,
2,
4369,
628,
2859,
921,
7185,
83,
14,
3919,
23596,
14,
1308,
15,
3919,
13,
505,
13,
19,
12645,
604,
13,
4785,
13,
4711,
1743,
199,
28,
2024,
536,
628,
479,
2,
1564,
26957,
9255,
13,
4785,
13,
31400,
13,
4423,
26,
543,
469,
5701,
16152,
2184,
93,
315,
13738,
15,
894,
402,
314,
26298,
4740,
2059,
14,
1743,
199,
28,
1073,
4668,
628,
15479,
2,
730,
628,
505,
15,
3919,
2,
4369,
9555,
19864,
15,
65,
27037,
14,
3919,
1743,
199,
28,
1073,
4668,
628,
1431,
2,
4369,
628,
9255,
13,
4785,
13,
31400,
13,
4423,
24185,
1080,
26,
1644,
17063,
1121,
14,
1360,
1743,
199,
28,
2487,
30,
299,
8448,
5023,
13,
6606,
26,
282,
27037,
27,
3586,
3068,
2487,
30,
199,
28,
3015,
30,
4986,
340,
2337,
365,
469,
4921,
93,
10424,
4601,
3382,
314,
2877,
3326,
5084,
14,
199,
28,
80,
22266,
5701,
1560,
93,
7997,
88,
1493,
65,
27,
91,
2184,
1560,
17890,
80,
30,
199,
1108,
3015,
30,
199,
2344,
199,
199,
8279,
63,
3817,
275,
283,
9255,
13,
4785,
13,
31400,
13,
4423,
24185,
26,
1644,
17063,
1121,
14,
1360,
7,
199,
8279,
63,
7433,
63,
25856,
275,
1449,
11230,
16556,
3517,
30,
199,
28,
2024,
5960,
628,
1624,
13,
24,
1743,
199,
28,
1213,
30,
14391,
15397,
396,
10944,
26,
29858,
22535,
6266,
1869,
24259,
1108,
1213,
30,
199,
28,
1073,
4668,
628,
2502,
2,
2538,
628,
1049,
324,
13,
4649,
334,
27888,
264,
1662,
9,
2799,
287,
2,
4369,
628,
26206,
26,
6532,
264,
1662,
24604,
32,
12102,
14,
957,
1743,
199,
28,
1073,
4668,
628,
2502,
2,
2538,
628,
22285,
2,
4369,
628,
2859,
921,
1544,
14,
12102,
14,
1308,
1743,
199,
28,
1073,
4668,
628,
15479,
2,
730,
628,
505,
15,
3919,
2,
4369,
9555,
19864,
15,
65,
27037,
14,
3919,
1743,
199,
28,
2487,
30,
299,
8448,
5023,
13,
6606,
26,
282,
27037,
27,
3586,
3068,
2487,
30,
199,
28,
3015,
30,
4986,
340,
2337,
365,
4825,
10424,
4601,
3382,
314,
2877,
3326,
5084,
14,
199,
28,
80,
22266,
16,
8847,
17,
17890,
80,
30,
199,
1108,
3015,
30,
199,
2344,
199,
8279,
63,
7433,
63,
32162,
275,
1449,
11230,
16556,
3517,
30,
199,
28,
2024,
5960,
628,
1624,
13,
24,
1743,
199,
28,
1213,
30,
14391,
15397,
396,
10944,
26,
29858,
22535,
6266,
1869,
24259,
1108,
1213,
30,
199,
28,
1073,
4668,
628,
2502,
2,
2538,
628,
1049,
324,
13,
4649,
334,
27888,
264,
1662,
9,
2799,
287,
2,
4369,
628,
26206,
26,
6532,
264,
1662,
24604,
32,
12102,
14,
957,
1743,
199,
28,
1073,
4668,
628,
2502,
2,
2538,
628,
22285,
2,
4369,
628,
2859,
921,
1544,
14,
12102,
14,
1308,
1743,
199,
28,
1073,
4668,
628,
15479,
2,
730,
628,
505,
15,
3919,
2,
4369,
9555,
19864,
15,
65,
27037,
14,
3919,
1743,
199,
28,
2487,
30,
299,
8448,
5023,
13,
6606,
26,
282,
27037,
27,
3586,
3068,
2487,
30,
199,
28,
3015,
30,
4986,
340,
2337,
365,
13051,
10424,
4601,
3382,
314,
2877,
3326,
5084,
14,
199,
28,
80,
22266,
16,
8847,
18,
8847,
17,
17890,
80,
30,
199,
1108,
3015,
30,
199,
2344,
199,
199,
5901,
63,
3597,
275,
359,
267,
661,
37,
1810,
437,
6214,
16579,
13,
2063,
334,
38,
3196,
260,
283,
8454,
100,
8454,
114,
8454,
106,
8454,
106,
8454,
116,
8454,
103,
8454,
98,
8454,
113,
8454,
102,
659,
267,
661,
37,
1810,
437,
6214,
869,
7411,
13,
2063,
334,
40,
3196,
260,
283,
172,
123,
226,
172,
122,
122,
172,
123,
227,
659,
267,
661,
37,
1810,
437,
6214,
32612,
334,
55,
9,
871,
869,
621,
348,
297,
283,
163,
117,
106,
165,
103,
100,
659,
267,
661,
37,
1810,
437,
6214,
653,
7691,
334,
8565,
3196,
3322,
283,
15485,
659,
267,
661,
37,
1810,
437,
6214,
437,
887,
20357,
334,
33,
3196,
3515,
283,
11079,
255,
659,
267,
661,
1763,
662,
1810,
437,
6214,
334,
4698,
29358,
3196,
3515,
283,
149,
96,
149,
111,
9789,
9012,
11056,
659,
267,
661,
40,
621,
348,
297,
14960,
283,
170,
228,
235,
169,
233,
98,
170,
233,
117,
659,
267,
1622,
199,
199,
318,
2218,
63,
493,
8,
1501,
12,
1564,
304,
272,
543,
1551,
8,
1501
] |
[
2647,
15,
1393,
15,
1813,
2366,
199,
3,
446,
627,
446,
2803,
26,
9094,
13,
24,
446,
627,
446,
199,
199,
624,
199,
2765,
2884,
12821,
2295,
8135,
13,
4785,
13,
31400,
13,
4423,
13,
4587,
6146,
378,
1887,
1314,
199,
5899,
1006,
3962,
15821,
402,
4110,
737,
2877,
27613,
402,
8135,
18277,
14,
199,
11053,
22543,
12,
2337,
787,
542,
1856,
2943,
402,
4110,
4572,
3344,
315,
3520,
4713,
26,
199,
199,
17,
14,
662,
1810,
437,
6214,
16579,
13,
2063,
334,
38,
9,
199,
18,
14,
662,
1810,
437,
6214,
869,
7411,
13,
2063,
334,
40,
9,
199,
19,
14,
662,
1810,
437,
6214,
32612,
334,
55,
9,
871,
869,
621,
348,
199,
20,
14,
662,
1810,
437,
6214,
653,
7691,
334,
8565,
9,
199,
21,
14,
662,
1810,
437,
6214,
437,
887,
20357,
334,
33,
9,
199,
22,
14,
2832,
662,
1810,
437,
6214,
334,
4698,
29358,
9,
199,
23,
14,
869,
621,
348,
199,
199,
5158,
2337,
787,
12260,
3365,
15821,
14,
2779,
4704,
282,
769,
402,
1006,
199,
2219,
652,
4046,
315,
314,
1475,
402,
17728,
2984,
396,
14,
513,
370,
314,
3839,
14,
199,
624,
199,
199,
504,
636,
2443,
363,
492,
2649,
63,
5955,
12,
870,
63,
1593,
12,
3679,
63,
646,
199,
199,
2864,
63,
3817,
275,
283,
9255,
13,
4785,
13,
31400,
13,
4423,
24185,
26,
1644,
5565,
1360,
7,
199,
2864,
63,
7433,
275,
1449,
11230,
16556,
3517,
30,
199,
28,
2024,
5960,
628,
1624,
13,
24,
1743,
199,
28,
1213,
30,
14391,
15397,
396,
1379,
26,
29858,
22535,
6266,
1869,
24259,
1108,
1213,
30,
199,
28,
1073,
4668,
628,
2502,
2,
2538,
628,
1049,
324,
13,
4649,
334,
27888,
264,
1662,
9,
2799,
287,
2,
4369,
628,
26206,
26,
6532,
264,
1662,
24604,
32,
12102,
14,
957,
1743,
199,
28,
1073,
4668,
628,
2502,
2,
2538,
628,
22285,
2,
4369,
628,
2859,
921,
1544,
14,
12102,
14,
1308,
1743,
199,
28,
1073,
4668,
628,
3437,
2,
4369,
628,
2859,
921,
7185,
83,
14,
3919,
23596,
14,
1308,
15,
3919,
13,
505,
13,
19,
12645,
604,
13,
4785,
13,
4711,
1743,
199,
28,
2024,
536,
628,
479,
2,
1564,
26957,
9255,
13,
4785,
13,
31400,
13,
4423,
26,
543,
469,
5701,
16152,
2184,
93,
315,
13738,
15,
894,
402,
314,
26298,
4740,
2059,
14,
1743,
199,
28,
1073,
4668,
628,
15479,
2,
730,
628,
505,
15,
3919,
2,
4369,
9555,
19864,
15,
65,
27037,
14,
3919,
1743,
199,
28,
1073,
4668,
628,
1431,
2,
4369,
628,
9255,
13,
4785,
13,
31400,
13,
4423,
24185,
1080,
26,
1644,
17063,
1121,
14,
1360,
1743,
199,
28,
2487,
30,
299,
8448,
5023,
13,
6606,
26,
282,
27037,
27,
3586,
3068,
2487,
30,
199,
28,
3015,
30,
4986,
340,
2337,
365,
469,
4921,
93,
10424,
4601,
3382,
314,
2877,
3326,
5084,
14,
199,
28,
80,
22266,
5701,
1560,
93,
7997,
88,
1493,
65,
27,
91,
2184,
1560,
17890,
80,
30,
199,
1108,
3015,
30,
199,
2344,
199,
199,
8279,
63,
3817,
275,
283,
9255,
13,
4785,
13,
31400,
13,
4423,
24185,
26,
1644,
17063,
1121,
14,
1360,
7,
199,
8279,
63,
7433,
63,
25856,
275,
1449,
11230,
16556,
3517,
30,
199,
28,
2024,
5960,
628,
1624,
13,
24,
1743,
199,
28,
1213,
30,
14391,
15397,
396,
10944,
26,
29858,
22535,
6266,
1869,
24259,
1108,
1213,
30,
199,
28,
1073,
4668,
628,
2502,
2,
2538,
628,
1049,
324,
13,
4649,
334,
27888,
264,
1662,
9,
2799,
287,
2,
4369,
628,
26206,
26,
6532,
264,
1662,
24604,
32,
12102,
14,
957,
1743,
199,
28,
1073,
4668,
628,
2502,
2,
2538,
628,
22285,
2,
4369,
628,
2859,
921,
1544,
14,
12102,
14,
1308,
1743,
199,
28,
1073,
4668,
628,
15479,
2,
730,
628,
505,
15,
3919,
2,
4369,
9555,
19864,
15,
65,
27037,
14,
3919,
1743,
199,
28,
2487,
30,
299,
8448,
5023,
13,
6606,
26,
282,
27037,
27,
3586,
3068,
2487,
30,
199,
28,
3015,
30,
4986,
340,
2337,
365,
4825,
10424,
4601,
3382,
314,
2877,
3326,
5084,
14,
199,
28,
80,
22266,
16,
8847,
17,
17890,
80,
30,
199,
1108,
3015,
30,
199,
2344,
199,
8279,
63,
7433,
63,
32162,
275,
1449,
11230,
16556,
3517,
30,
199,
28,
2024,
5960,
628,
1624,
13,
24,
1743,
199,
28,
1213,
30,
14391,
15397,
396,
10944,
26,
29858,
22535,
6266,
1869,
24259,
1108,
1213,
30,
199,
28,
1073,
4668,
628,
2502,
2,
2538,
628,
1049,
324,
13,
4649,
334,
27888,
264,
1662,
9,
2799,
287,
2,
4369,
628,
26206,
26,
6532,
264,
1662,
24604,
32,
12102,
14,
957,
1743,
199,
28,
1073,
4668,
628,
2502,
2,
2538,
628,
22285,
2,
4369,
628,
2859,
921,
1544,
14,
12102,
14,
1308,
1743,
199,
28,
1073,
4668,
628,
15479,
2,
730,
628,
505,
15,
3919,
2,
4369,
9555,
19864,
15,
65,
27037,
14,
3919,
1743,
199,
28,
2487,
30,
299,
8448,
5023,
13,
6606,
26,
282,
27037,
27,
3586,
3068,
2487,
30,
199,
28,
3015,
30,
4986,
340,
2337,
365,
13051,
10424,
4601,
3382,
314,
2877,
3326,
5084,
14,
199,
28,
80,
22266,
16,
8847,
18,
8847,
17,
17890,
80,
30,
199,
1108,
3015,
30,
199,
2344,
199,
199,
5901,
63,
3597,
275,
359,
267,
661,
37,
1810,
437,
6214,
16579,
13,
2063,
334,
38,
3196,
260,
283,
8454,
100,
8454,
114,
8454,
106,
8454,
106,
8454,
116,
8454,
103,
8454,
98,
8454,
113,
8454,
102,
659,
267,
661,
37,
1810,
437,
6214,
869,
7411,
13,
2063,
334,
40,
3196,
260,
283,
172,
123,
226,
172,
122,
122,
172,
123,
227,
659,
267,
661,
37,
1810,
437,
6214,
32612,
334,
55,
9,
871,
869,
621,
348,
297,
283,
163,
117,
106,
165,
103,
100,
659,
267,
661,
37,
1810,
437,
6214,
653,
7691,
334,
8565,
3196,
3322,
283,
15485,
659,
267,
661,
37,
1810,
437,
6214,
437,
887,
20357,
334,
33,
3196,
3515,
283,
11079,
255,
659,
267,
661,
1763,
662,
1810,
437,
6214,
334,
4698,
29358,
3196,
3515,
283,
149,
96,
149,
111,
9789,
9012,
11056,
659,
267,
661,
40,
621,
348,
297,
14960,
283,
170,
228,
235,
169,
233,
98,
170,
233,
117,
659,
267,
1622,
199,
199,
318,
2218,
63,
493,
8,
1501,
12,
1564,
304,
272,
543,
1551,
8,
1501,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
ctgriffiths/twister
|
lib/tShark.py
|
2
|
6703
|
import time
import datetime
import os
import sys
import json
import stat
import thread
import threading
import select
try:
from scapy.all import *
except Exception as e:
print 'Install scapy python module {}'.format(e)
sys.exit(1)
class TSharkHandler(object):
def __init__(self, active, interface, read_flags, write_flags, max_packets, cap_file, cap_dir):
"""
Initialize the sniffer handler.
"""
self.active = active
self.interface = interface
self.cap_file = cap_file
self.cap_dir = cap_dir
self.max_packets = max_packets
#TShark read flags
self.read_flags=[]
rflags = read_flags.split(' ')
self.read_flags = self.read_flags+rflags
#TShark write flags
self.write_flags = ['-i', self.interface]
wflags = write_flags.split(' ')
self.write_flags = self.write_flags + wflags
self.handler = TSharkEmu(self.max_packets, iface=self.interface, filter=write_flags)
def createCapFile(self):
"""
Creates the file where the packets will be stored.
"""
with open(self.cap_file, 'w') as f:
f.close()
def start(self):
"""
Starts the capture.
"""
if(self.active == True):
self.createCapFile()
self.handler.startCapture(self.cap_file, self.write_flags)
return True
else:
print 'tShark not enabled.'
return False
def stop(self):
"""
Stops the capture.
"""
self.handler.stopCapture()
self.active=False
return True
class TSharkEmu(threading.Thread):
def __init__(self, max_packets, *arg,**karg):
"""
A separate thread that actually captures the packets.
"""
threading.Thread.__init__(self)
self.arg = arg
self.karg = karg
self.packets = []
self.cap_file = None
self.active = False
self.lock = thread.allocate_lock()
self.lock.acquire()
self.max_packets = max_packets
self.packet_count = 0
def stopCapture(self):
"""
The is stopped and the packets are written into a file
"""
if(len(self.packets) > 0):
wrpcap(self.cap_file, self.packets)
else:
print 'No packets were captured!'
self.packets = []
self.packet_count = 0
if(not self.lock.locked()):
self.lock.acquire()
def startCapture(self, cap_file, tshark_flags):
"""
The capture is initiated. A the capturing thread is started.
"""
self.cap_file = cap_file
if(self.active == False):
self.start()
self.active = True
else:
print 'The sniffer is already running.'
if(self.lock.locked()):
self.lock.release()
def run(self):
"""
Here the packets are captured.
The scapy library is used.
"""
L2socket = conf.L2listen
#print 'args: {}'.format(self.arg)
#print 'kargs: {}'.format(self.karg)
s = L2socket(type=ETH_P_ALL, *self.arg, **self.karg)
while True:
sel = select.select([s],[],[],None)
if s in sel[0]:
p = s.recv(MTU)
if p is None:
break
self.packet_count += 1
if(self.packet_count > self.max_packets):
print 'Maximum packets captured.'
time.sleep(0.5)
continue
self.packets.append(p)
with self.lock:
pass
SNIFFER_HANDLER = None
def start_capture(tshark_enabled,
tshark_iface = 'lo',
tshark_read_flags= '',
tshark_write_flags = '',
max_packets = 1000,
tshark_cap_dir = os.getenv('TWISTER_PATH')):
"""
Is the interface for the user to start a packet capture.
tshark_iface = the interface that tShark is listening to
tshark_read_flags= '-R of13.ofp_header'
tshark_write_flags = 'port 6633' -> acts like a filter.
"""
global SNIFFER_HANDLER
# verify that the client/EP runs with root privileges
if os.getuid() != 0:
print 'The client should run with root privileges'
return False
# tshark should be installed to be able to capture packets
try:
os.system('tshark -v')
except Exception as e:
print 'Please install tshark before starting the packet capture {}'.format(e)
return False
cap_file = datetime.datetime.now().strftime('%Y_%m_%d_%H_%M_%S_%f')+'.cap'
print 'CAP_FILE: {}'.format(cap_file)
print tshark_cap_dir
if 'pcap' not in os.listdir(tshark_cap_dir):
tshark_cap_dir += '/'+'pcap'
try:
os.mkdir(tshark_cap_dir)
os.chmod(tshark_cap_dir, stat.S_IRWXG|stat.S_IRWXU|stat.S_IRWXO)
except Exception as e:
print 'Cannot make `{}` directory {}'.format(tshark_cap_dir, e)
return False
else:
tshark_cap_dir += '/pcap'
cap_file = tshark_cap_dir+'/'+cap_file
if SNIFFER_HANDLER is None:
SNIFFER_HANDLER = TSharkHandler(tshark_enabled,
tshark_iface,
tshark_read_flags,
tshark_write_flags,
max_packets,
cap_file,
tshark_cap_dir)
SNIFFER_HANDLER.start()
print 'Sniffer started ...'
else:
print 'Another capture is running. Please stop the current capture before starting another one!'
return False
return True
def stop_capture():
"""
Is the interface for the user to stop the current capture.
"""
global SNIFFER_HANDLER
if not SNIFFER_HANDLER:
print 'The capture was not started!'
return False
SNIFFER_HANDLER.stop()
print 'Sniffer stopped ...'
# config_file = SNIFFER_HANDLER.cap_file[:-3]+'cfg'
# config = open(config_file, 'w')
# sniffer_config = {'interface' : SNIFFER_HANDLER.interface,
# 'max_packets' : SNIFFER_HANDLER.max_packets,
# 'read_flags' : SNIFFER_HANDLER.read_flags,
# 'write_flags' : SNIFFER_HANDLER.write_flags}
# print 'SNIFFER_CONFIG: {}'.format(sniffer_config)
# json.dump(sniffer_config, config)
# config.close()
SNIFFER_HANDLER = None
return True
|
apache-2.0
|
[
199,
646,
900,
199,
646,
2197,
199,
646,
747,
199,
646,
984,
199,
646,
2022,
199,
646,
5672,
199,
646,
2462,
199,
646,
5796,
199,
646,
3504,
199,
199,
893,
26,
272,
687,
308,
2874,
89,
14,
452,
492,
627,
199,
2590,
2186,
465,
325,
26,
272,
870,
283,
8154,
308,
2874,
89,
2366,
859,
9499,
908,
8,
69,
9,
272,
984,
14,
2224,
8,
17,
9,
421,
199,
533,
377,
2662,
1096,
2461,
8,
785,
304,
339,
347,
636,
826,
721,
277,
12,
4702,
12,
3217,
12,
1586,
63,
2469,
12,
2218,
63,
2469,
12,
1390,
63,
18853,
12,
4021,
63,
493,
12,
4021,
63,
694,
304,
267,
408,
267,
11578,
314,
6895,
73,
1260,
3016,
14,
267,
408,
267,
291,
14,
2682,
275,
4702,
267,
291,
14,
3266,
275,
3217,
267,
291,
14,
2874,
63,
493,
275,
4021,
63,
493,
267,
291,
14,
2874,
63,
694,
275,
4021,
63,
694,
267,
291,
14,
988,
63,
18853,
275,
1390,
63,
18853,
398,
327,
52,
2662,
1096,
1586,
3285,
267,
291,
14,
739,
63,
2469,
9811,
267,
519,
2469,
275,
1586,
63,
2469,
14,
1294,
360,
5320,
267,
291,
14,
739,
63,
2469,
275,
291,
14,
739,
63,
2469,
11,
82,
2469,
24807,
327,
52,
2662,
1096,
2218,
3285,
267,
291,
14,
952,
63,
2469,
275,
11573,
73,
297,
291,
14,
3266,
61,
267,
336,
2469,
275,
2218,
63,
2469,
14,
1294,
360,
5320,
267,
291,
14,
952,
63,
2469,
275,
291,
14,
952,
63,
2469,
435,
336,
2469,
398,
291,
14,
2232,
275,
377,
2662,
1096,
37,
6553,
8,
277,
14,
988,
63,
18853,
12,
13395,
29,
277,
14,
3266,
12,
2457,
29,
952,
63,
2469,
9,
2378,
347,
1218,
9155,
1173,
8,
277,
304,
267,
408,
267,
10560,
314,
570,
2382,
314,
14593,
911,
506,
5489,
14,
267,
408,
267,
543,
1551,
8,
277,
14,
2874,
63,
493,
12,
283,
87,
358,
465,
289,
26,
288,
289,
14,
1600,
342,
2378,
347,
1343,
8,
277,
304,
267,
408,
267,
7707,
83,
314,
12296,
14,
267,
408,
267,
340,
8,
277,
14,
2682,
508,
715,
304,
288,
291,
14,
981,
9155,
1173,
342,
288,
291,
14,
2232,
14,
928,
16640,
8,
277,
14,
2874,
63,
493,
12,
291,
14,
952,
63,
2469,
9,
288,
372,
715,
267,
587,
26,
288,
870,
283,
84,
2662,
1096,
440,
5223,
3530,
288,
372,
756,
2378,
347,
3631,
8,
277,
304,
267,
408,
267,
1933,
1483,
314,
12296,
14,
267,
408,
267,
291,
14,
2232,
14,
2379,
16640,
342,
267,
291,
14,
2682,
29,
797,
267,
372,
715,
421,
199,
533,
377,
2662,
1096,
37,
6553,
8,
12562,
14,
4436,
304,
272,
347,
636,
826,
721,
277,
12,
1390,
63,
18853,
12,
627,
1273,
12663,
75,
1273,
304,
267,
408,
267,
437,
7396,
2462,
626,
5965,
12162,
1482,
314,
14593,
14,
267,
408,
267,
5796,
14,
4436,
855,
826,
721,
277,
9,
267,
291,
14,
1273,
275,
1680,
267,
291,
14,
75,
1273,
275,
1022,
1273,
267,
291,
14,
18853,
275,
942,
267,
291,
14,
2874,
63,
493,
275,
488,
267,
291,
14,
2682,
275,
756,
267,
291,
14,
831,
275,
2462,
14,
12991,
63,
831,
342,
267,
291,
14,
831,
14,
8174,
342,
267,
291,
14,
988,
63,
18853,
275,
1390,
63,
18853,
267,
291,
14,
6253,
63,
835,
275,
378,
2378,
347,
3631,
16640,
8,
277,
304,
267,
408,
267,
710,
365,
15248,
436,
314,
14593,
787,
5313,
1901,
282,
570,
267,
408,
267,
340,
8,
552,
8,
277,
14,
18853,
9,
690,
378,
304,
288,
336,
4354,
439,
8,
277,
14,
2874,
63,
493,
12,
291,
14,
18853,
9,
267,
587,
26,
288,
870,
283,
1944,
14593,
4898,
17487,
11213,
267,
291,
14,
18853,
275,
942,
267,
291,
14,
6253,
63,
835,
275,
378,
267,
340,
8,
1397,
291,
14,
831,
14,
9325,
5109,
288,
291,
14,
831,
14,
8174,
342,
339,
347,
1343,
16640,
8,
277,
12,
4021,
63,
493,
12,
307,
609,
1096,
63,
2469,
304,
267,
408,
267,
710,
12296,
365,
11023,
972,
14,
437,
314,
12162,
4039,
2462,
365,
8239,
14,
267,
408,
267,
291,
14,
2874,
63,
493,
275,
4021,
63,
493,
267,
340,
8,
277,
14,
2682,
508,
756,
304,
288,
291,
14,
928,
342,
288,
291,
14,
2682,
275,
715,
4960,
587,
26,
288,
870,
283,
1918,
6895,
73,
1260,
365,
2575,
3879,
3530,
267,
340,
8,
277,
14,
831,
14,
9325,
5109,
288,
291,
14,
831,
14,
3221,
342,
5493,
347,
1255,
8,
277,
304,
267,
408,
267,
11842,
314,
14593,
787,
17487,
14,
267,
710,
308,
2874,
89,
3555,
365,
1202,
14,
267,
408,
267,
491,
18,
3450,
275,
3743,
14,
44,
18,
5859,
267,
327,
1361,
283,
589,
26,
9499,
908,
8,
277,
14,
1273,
9,
267,
327,
1361,
283,
24459,
26,
9499,
908,
8,
277,
14,
75,
1273,
9,
267,
308,
275,
491,
18,
3450,
8,
466,
29,
21265,
63,
48,
63,
1761,
12,
627,
277,
14,
1273,
12,
1011,
277,
14,
75,
1273,
9,
267,
1830,
715,
26,
288,
13680,
275,
3504,
14,
2416,
779,
83,
6922,
6922,
467,
403,
9,
288,
340,
308,
315,
13680,
59,
16,
2189,
355,
299,
275,
308,
14,
7637,
8,
5747,
53,
9,
355,
340,
299,
365,
488,
26,
490,
2059,
355,
291,
14,
6253,
63,
835,
847,
413,
355,
340,
8,
277,
14,
6253,
63,
835,
690,
291,
14,
988,
63,
18853,
304,
490,
870,
283,
10915,
14593,
17487,
3530,
490,
900,
14,
4532,
8,
16,
14,
21,
9,
490,
1980,
355,
291,
14,
18853,
14,
740,
8,
80,
9,
355,
543,
291,
14,
831,
26,
490,
986,
4388,
199,
8199,
24150,
540,
63,
30872,
275,
488,
199,
199,
318,
1343,
63,
12685,
8,
84,
609,
1096,
63,
3827,
12,
20177,
307,
609,
1096,
63,
11166,
275,
283,
320,
297,
20177,
307,
609,
1096,
63,
739,
63,
2469,
29,
3260,
20177,
307,
609,
1096,
63,
952,
63,
2469,
275,
3260,
2116,
1390,
63,
18853,
275,
5198,
12,
2116,
307,
609,
1096,
63,
2874,
63,
694,
275,
747,
14,
12959,
360,
16491,
19027,
63,
3243,
8109,
272,
408,
272,
6596,
314,
3217,
367,
314,
922,
370,
1343,
282,
3644,
12296,
14,
339,
307,
609,
1096,
63
] |
[
646,
900,
199,
646,
2197,
199,
646,
747,
199,
646,
984,
199,
646,
2022,
199,
646,
5672,
199,
646,
2462,
199,
646,
5796,
199,
646,
3504,
199,
199,
893,
26,
272,
687,
308,
2874,
89,
14,
452,
492,
627,
199,
2590,
2186,
465,
325,
26,
272,
870,
283,
8154,
308,
2874,
89,
2366,
859,
9499,
908,
8,
69,
9,
272,
984,
14,
2224,
8,
17,
9,
421,
199,
533,
377,
2662,
1096,
2461,
8,
785,
304,
339,
347,
636,
826,
721,
277,
12,
4702,
12,
3217,
12,
1586,
63,
2469,
12,
2218,
63,
2469,
12,
1390,
63,
18853,
12,
4021,
63,
493,
12,
4021,
63,
694,
304,
267,
408,
267,
11578,
314,
6895,
73,
1260,
3016,
14,
267,
408,
267,
291,
14,
2682,
275,
4702,
267,
291,
14,
3266,
275,
3217,
267,
291,
14,
2874,
63,
493,
275,
4021,
63,
493,
267,
291,
14,
2874,
63,
694,
275,
4021,
63,
694,
267,
291,
14,
988,
63,
18853,
275,
1390,
63,
18853,
398,
327,
52,
2662,
1096,
1586,
3285,
267,
291,
14,
739,
63,
2469,
9811,
267,
519,
2469,
275,
1586,
63,
2469,
14,
1294,
360,
5320,
267,
291,
14,
739,
63,
2469,
275,
291,
14,
739,
63,
2469,
11,
82,
2469,
24807,
327,
52,
2662,
1096,
2218,
3285,
267,
291,
14,
952,
63,
2469,
275,
11573,
73,
297,
291,
14,
3266,
61,
267,
336,
2469,
275,
2218,
63,
2469,
14,
1294,
360,
5320,
267,
291,
14,
952,
63,
2469,
275,
291,
14,
952,
63,
2469,
435,
336,
2469,
398,
291,
14,
2232,
275,
377,
2662,
1096,
37,
6553,
8,
277,
14,
988,
63,
18853,
12,
13395,
29,
277,
14,
3266,
12,
2457,
29,
952,
63,
2469,
9,
2378,
347,
1218,
9155,
1173,
8,
277,
304,
267,
408,
267,
10560,
314,
570,
2382,
314,
14593,
911,
506,
5489,
14,
267,
408,
267,
543,
1551,
8,
277,
14,
2874,
63,
493,
12,
283,
87,
358,
465,
289,
26,
288,
289,
14,
1600,
342,
2378,
347,
1343,
8,
277,
304,
267,
408,
267,
7707,
83,
314,
12296,
14,
267,
408,
267,
340,
8,
277,
14,
2682,
508,
715,
304,
288,
291,
14,
981,
9155,
1173,
342,
288,
291,
14,
2232,
14,
928,
16640,
8,
277,
14,
2874,
63,
493,
12,
291,
14,
952,
63,
2469,
9,
288,
372,
715,
267,
587,
26,
288,
870,
283,
84,
2662,
1096,
440,
5223,
3530,
288,
372,
756,
2378,
347,
3631,
8,
277,
304,
267,
408,
267,
1933,
1483,
314,
12296,
14,
267,
408,
267,
291,
14,
2232,
14,
2379,
16640,
342,
267,
291,
14,
2682,
29,
797,
267,
372,
715,
421,
199,
533,
377,
2662,
1096,
37,
6553,
8,
12562,
14,
4436,
304,
272,
347,
636,
826,
721,
277,
12,
1390,
63,
18853,
12,
627,
1273,
12663,
75,
1273,
304,
267,
408,
267,
437,
7396,
2462,
626,
5965,
12162,
1482,
314,
14593,
14,
267,
408,
267,
5796,
14,
4436,
855,
826,
721,
277,
9,
267,
291,
14,
1273,
275,
1680,
267,
291,
14,
75,
1273,
275,
1022,
1273,
267,
291,
14,
18853,
275,
942,
267,
291,
14,
2874,
63,
493,
275,
488,
267,
291,
14,
2682,
275,
756,
267,
291,
14,
831,
275,
2462,
14,
12991,
63,
831,
342,
267,
291,
14,
831,
14,
8174,
342,
267,
291,
14,
988,
63,
18853,
275,
1390,
63,
18853,
267,
291,
14,
6253,
63,
835,
275,
378,
2378,
347,
3631,
16640,
8,
277,
304,
267,
408,
267,
710,
365,
15248,
436,
314,
14593,
787,
5313,
1901,
282,
570,
267,
408,
267,
340,
8,
552,
8,
277,
14,
18853,
9,
690,
378,
304,
288,
336,
4354,
439,
8,
277,
14,
2874,
63,
493,
12,
291,
14,
18853,
9,
267,
587,
26,
288,
870,
283,
1944,
14593,
4898,
17487,
11213,
267,
291,
14,
18853,
275,
942,
267,
291,
14,
6253,
63,
835,
275,
378,
267,
340,
8,
1397,
291,
14,
831,
14,
9325,
5109,
288,
291,
14,
831,
14,
8174,
342,
339,
347,
1343,
16640,
8,
277,
12,
4021,
63,
493,
12,
307,
609,
1096,
63,
2469,
304,
267,
408,
267,
710,
12296,
365,
11023,
972,
14,
437,
314,
12162,
4039,
2462,
365,
8239,
14,
267,
408,
267,
291,
14,
2874,
63,
493,
275,
4021,
63,
493,
267,
340,
8,
277,
14,
2682,
508,
756,
304,
288,
291,
14,
928,
342,
288,
291,
14,
2682,
275,
715,
4960,
587,
26,
288,
870,
283,
1918,
6895,
73,
1260,
365,
2575,
3879,
3530,
267,
340,
8,
277,
14,
831,
14,
9325,
5109,
288,
291,
14,
831,
14,
3221,
342,
5493,
347,
1255,
8,
277,
304,
267,
408,
267,
11842,
314,
14593,
787,
17487,
14,
267,
710,
308,
2874,
89,
3555,
365,
1202,
14,
267,
408,
267,
491,
18,
3450,
275,
3743,
14,
44,
18,
5859,
267,
327,
1361,
283,
589,
26,
9499,
908,
8,
277,
14,
1273,
9,
267,
327,
1361,
283,
24459,
26,
9499,
908,
8,
277,
14,
75,
1273,
9,
267,
308,
275,
491,
18,
3450,
8,
466,
29,
21265,
63,
48,
63,
1761,
12,
627,
277,
14,
1273,
12,
1011,
277,
14,
75,
1273,
9,
267,
1830,
715,
26,
288,
13680,
275,
3504,
14,
2416,
779,
83,
6922,
6922,
467,
403,
9,
288,
340,
308,
315,
13680,
59,
16,
2189,
355,
299,
275,
308,
14,
7637,
8,
5747,
53,
9,
355,
340,
299,
365,
488,
26,
490,
2059,
355,
291,
14,
6253,
63,
835,
847,
413,
355,
340,
8,
277,
14,
6253,
63,
835,
690,
291,
14,
988,
63,
18853,
304,
490,
870,
283,
10915,
14593,
17487,
3530,
490,
900,
14,
4532,
8,
16,
14,
21,
9,
490,
1980,
355,
291,
14,
18853,
14,
740,
8,
80,
9,
355,
543,
291,
14,
831,
26,
490,
986,
4388,
199,
8199,
24150,
540,
63,
30872,
275,
488,
199,
199,
318,
1343,
63,
12685,
8,
84,
609,
1096,
63,
3827,
12,
20177,
307,
609,
1096,
63,
11166,
275,
283,
320,
297,
20177,
307,
609,
1096,
63,
739,
63,
2469,
29,
3260,
20177,
307,
609,
1096,
63,
952,
63,
2469,
275,
3260,
2116,
1390,
63,
18853,
275,
5198,
12,
2116,
307,
609,
1096,
63,
2874,
63,
694,
275,
747,
14,
12959,
360,
16491,
19027,
63,
3243,
8109,
272,
408,
272,
6596,
314,
3217,
367,
314,
922,
370,
1343,
282,
3644,
12296,
14,
339,
307,
609,
1096,
63,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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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
] |
ashwin713/Arduino
|
arduino-core/src/processing/app/i18n/python/requests/packages/charade/sjisprober.py
|
1182
|
3734
|
######################## BEGIN LICENSE BLOCK ########################
# The Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is
# Netscape Communications Corporation.
# Portions created by the Initial Developer are Copyright (C) 1998
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
# Mark Pilgrim - port to Python
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
# 02110-1301 USA
######################### END LICENSE BLOCK #########################
import sys
from .mbcharsetprober import MultiByteCharSetProber
from .codingstatemachine import CodingStateMachine
from .chardistribution import SJISDistributionAnalysis
from .jpcntx import SJISContextAnalysis
from .mbcssm import SJISSMModel
from . import constants
class SJISProber(MultiByteCharSetProber):
def __init__(self):
MultiByteCharSetProber.__init__(self)
self._mCodingSM = CodingStateMachine(SJISSMModel)
self._mDistributionAnalyzer = SJISDistributionAnalysis()
self._mContextAnalyzer = SJISContextAnalysis()
self.reset()
def reset(self):
MultiByteCharSetProber.reset(self)
self._mContextAnalyzer.reset()
def get_charset_name(self):
return "SHIFT_JIS"
def feed(self, aBuf):
aLen = len(aBuf)
for i in range(0, aLen):
codingState = self._mCodingSM.next_state(aBuf[i])
if codingState == constants.eError:
if constants._debug:
sys.stderr.write(self.get_charset_name()
+ ' prober hit error at byte ' + str(i)
+ '\n')
self._mState = constants.eNotMe
break
elif codingState == constants.eItsMe:
self._mState = constants.eFoundIt
break
elif codingState == constants.eStart:
charLen = self._mCodingSM.get_current_charlen()
if i == 0:
self._mLastChar[1] = aBuf[0]
self._mContextAnalyzer.feed(self._mLastChar[2 - charLen:],
charLen)
self._mDistributionAnalyzer.feed(self._mLastChar, charLen)
else:
self._mContextAnalyzer.feed(aBuf[i + 1 - charLen:i + 3
- charLen], charLen)
self._mDistributionAnalyzer.feed(aBuf[i - 1:i + 1],
charLen)
self._mLastChar[0] = aBuf[aLen - 1]
if self.get_state() == constants.eDetecting:
if (self._mContextAnalyzer.got_enough_data() and
(self.get_confidence() > constants.SHORTCUT_THRESHOLD)):
self._mState = constants.eFoundIt
return self.get_state()
def get_confidence(self):
contxtCf = self._mContextAnalyzer.get_confidence()
distribCf = self._mDistributionAnalyzer.get_confidence()
return max(contxtCf, distribCf)
|
lgpl-2.1
|
[
6565,
16427,
5113,
8068,
11945,
199,
3,
710,
12769,
5495,
365,
1303,
6956,
14,
1308,
1233,
14,
199,
3,
199,
3,
710,
6026,
9607,
402,
314,
12769,
5495,
365,
199,
3,
20433,
18686,
11098,
14,
199,
3,
20825,
2737,
701,
314,
6026,
9607,
787,
1898,
334,
35,
9,
19960,
199,
3,
314,
6026,
9607,
14,
2900,
5924,
5702,
14,
199,
3,
199,
3,
17636,
8,
83,
304,
199,
3,
257,
7173,
19641,
446,
1844,
370,
2018,
199,
3,
199,
3,
961,
3555,
365,
2867,
2032,
27,
1265,
883,
3604,
652,
436,
15,
269,
199,
3,
2811,
652,
1334,
314,
2895,
402,
314,
1664,
6401,
1696,
1684,
199,
3,
844,
465,
3267,
701,
314,
2868,
2290,
2752,
27,
1902,
199,
3,
1015,
499,
14,
17,
402,
314,
844,
12,
503,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
961,
3555,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
1664,
199,
3,
6401,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
6401,
1696,
1684,
199,
3,
844,
3180,
543,
642,
3555,
27,
340,
440,
12,
2218,
370,
314,
2868,
2290,
199,
3,
2752,
12,
3277,
2020,
8026,
11236,
1933,
12,
12066,
11844,
12,
8226,
12,
4828,
199,
3,
11315,
13,
10067,
221,
8217,
199,
19054,
7729,
5113,
8068,
21186,
199,
199,
646,
984,
199,
504,
1275,
887,
6043,
19903,
492,
6879,
21312,
199,
504,
1275,
1523,
929,
6744,
492,
30539,
199,
504,
1275,
1560,
4972,
492,
428,
22290,
24906,
199,
504,
1275,
74,
2352,
343,
88,
492,
428,
22290,
2998,
13182,
199,
504,
1275,
887,
3919,
77,
492,
428,
22290,
25335,
199,
504,
1275,
492,
5262,
421,
199,
533,
428,
22290,
8029,
8,
3947,
21312,
304,
272,
347,
636,
826,
721,
277,
304,
267,
6879,
21312,
855,
826,
721,
277,
9,
267,
291,
423,
29633,
275,
30539,
8,
51,
22290,
25335,
9,
267,
291,
423,
77,
8580,
17606,
275,
428,
22290,
24906,
342,
267,
291,
423,
77,
2998,
17606,
275,
428,
22290,
2998,
13182,
342,
267,
291,
14,
3958,
342,
339,
347,
5305,
8,
277,
304,
267,
6879,
21312,
14,
3958,
8,
277,
9,
267,
291,
423,
77,
2998,
17606,
14,
3958,
342,
339,
347,
664,
63,
6043,
63,
354,
8,
277,
304,
267,
372,
298,
18013,
63,
22290,
2,
339,
347,
4733,
8,
277,
12,
17407,
304,
267,
282,
3166,
275,
822,
8,
22353,
9,
267,
367,
284,
315,
1425,
8,
16,
12,
282,
3166,
304,
288,
2803,
2223,
275,
291,
423,
29633,
14,
2184,
63,
929,
8,
22353,
59,
73,
566,
288,
340,
2803,
2223,
508,
5262,
14,
6259,
26,
355,
340,
5262,
423,
1757,
26,
490,
984,
14,
3083,
14,
952,
8,
277,
14,
362,
63,
6043,
63,
354,
342,
3660,
435,
283,
16118,
9793,
1125,
737,
3696,
283,
435,
620,
8,
73,
9,
3660,
435,
1557,
78,
358,
355,
291,
423,
31984,
275,
5262,
14,
69,
1763,
1352,
355,
2059,
288,
916,
2803,
2223,
508,
5262,
14,
13241,
26,
355,
291,
423,
31984,
275,
5262,
14,
69,
3601,
7940,
355,
2059,
288,
916,
2803,
2223,
508,
5262,
14,
11724,
26,
355,
29205,
275,
291,
423,
29633,
14,
362,
63,
1818,
63,
1560,
552,
342,
355,
340,
284,
508,
378,
26,
490,
291,
423,
30875,
59,
17,
61,
275,
17407,
59,
16,
61,
490,
291,
423,
77,
2998,
17606,
14,
3871,
8,
277,
423,
30875,
59,
18,
446,
29205,
8429,
6059,
29205,
9,
490,
291,
423,
77,
8580,
17606,
14,
3871,
8,
277,
423,
30875,
12,
29205,
9,
355,
587,
26,
490,
291,
423,
77,
2998,
17606,
14,
3871,
8,
22353,
59,
73,
435,
413,
446,
29205,
26,
73,
435,
650,
9349,
446,
29205,
467,
29205,
9,
490,
291,
423,
77,
8580,
17606,
14,
3871,
8,
22353,
59,
73,
446,
413,
26,
73,
435,
413,
467,
9349,
29205,
9,
398,
291,
423,
30875,
59,
16,
61,
275,
17407,
59,
65,
3166,
446,
413,
61,
398,
340,
291,
14,
362,
63,
929,
342,
508,
5262,
14,
69,
20064,
316,
26,
288,
340,
334,
277,
423,
77,
2998,
17606,
14,
7808,
63,
30881,
63,
576,
342,
436,
2049,
334,
277,
14,
362,
63,
13969,
342,
690,
5262,
14,
13003,
24678,
63,
19307,
2298,
355,
291,
423,
31984,
275,
5262,
14,
69,
3601,
7940,
398,
372,
291,
14,
362,
63,
929,
342,
339,
347,
664,
63,
13969,
8,
277,
304,
267,
406,
2424,
24304,
275,
291,
423,
77,
2998,
17606,
14,
362,
63,
13969,
342,
267,
29573,
24304,
275,
291,
423,
77,
8580,
17606,
14,
362,
63,
13969,
342,
267,
372,
1390,
8,
388,
2424,
24304,
12,
29573,
24304,
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
] |
[
16427,
5113,
8068,
11945,
199,
3,
710,
12769,
5495,
365,
1303,
6956,
14,
1308,
1233,
14,
199,
3,
199,
3,
710,
6026,
9607,
402,
314,
12769,
5495,
365,
199,
3,
20433,
18686,
11098,
14,
199,
3,
20825,
2737,
701,
314,
6026,
9607,
787,
1898,
334,
35,
9,
19960,
199,
3,
314,
6026,
9607,
14,
2900,
5924,
5702,
14,
199,
3,
199,
3,
17636,
8,
83,
304,
199,
3,
257,
7173,
19641,
446,
1844,
370,
2018,
199,
3,
199,
3,
961,
3555,
365,
2867,
2032,
27,
1265,
883,
3604,
652,
436,
15,
269,
199,
3,
2811,
652,
1334,
314,
2895,
402,
314,
1664,
6401,
1696,
1684,
199,
3,
844,
465,
3267,
701,
314,
2868,
2290,
2752,
27,
1902,
199,
3,
1015,
499,
14,
17,
402,
314,
844,
12,
503,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
961,
3555,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
1664,
199,
3,
6401,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
6401,
1696,
1684,
199,
3,
844,
3180,
543,
642,
3555,
27,
340,
440,
12,
2218,
370,
314,
2868,
2290,
199,
3,
2752,
12,
3277,
2020,
8026,
11236,
1933,
12,
12066,
11844,
12,
8226,
12,
4828,
199,
3,
11315,
13,
10067,
221,
8217,
199,
19054,
7729,
5113,
8068,
21186,
199,
199,
646,
984,
199,
504,
1275,
887,
6043,
19903,
492,
6879,
21312,
199,
504,
1275,
1523,
929,
6744,
492,
30539,
199,
504,
1275,
1560,
4972,
492,
428,
22290,
24906,
199,
504,
1275,
74,
2352,
343,
88,
492,
428,
22290,
2998,
13182,
199,
504,
1275,
887,
3919,
77,
492,
428,
22290,
25335,
199,
504,
1275,
492,
5262,
421,
199,
533,
428,
22290,
8029,
8,
3947,
21312,
304,
272,
347,
636,
826,
721,
277,
304,
267,
6879,
21312,
855,
826,
721,
277,
9,
267,
291,
423,
29633,
275,
30539,
8,
51,
22290,
25335,
9,
267,
291,
423,
77,
8580,
17606,
275,
428,
22290,
24906,
342,
267,
291,
423,
77,
2998,
17606,
275,
428,
22290,
2998,
13182,
342,
267,
291,
14,
3958,
342,
339,
347,
5305,
8,
277,
304,
267,
6879,
21312,
14,
3958,
8,
277,
9,
267,
291,
423,
77,
2998,
17606,
14,
3958,
342,
339,
347,
664,
63,
6043,
63,
354,
8,
277,
304,
267,
372,
298,
18013,
63,
22290,
2,
339,
347,
4733,
8,
277,
12,
17407,
304,
267,
282,
3166,
275,
822,
8,
22353,
9,
267,
367,
284,
315,
1425,
8,
16,
12,
282,
3166,
304,
288,
2803,
2223,
275,
291,
423,
29633,
14,
2184,
63,
929,
8,
22353,
59,
73,
566,
288,
340,
2803,
2223,
508,
5262,
14,
6259,
26,
355,
340,
5262,
423,
1757,
26,
490,
984,
14,
3083,
14,
952,
8,
277,
14,
362,
63,
6043,
63,
354,
342,
3660,
435,
283,
16118,
9793,
1125,
737,
3696,
283,
435,
620,
8,
73,
9,
3660,
435,
1557,
78,
358,
355,
291,
423,
31984,
275,
5262,
14,
69,
1763,
1352,
355,
2059,
288,
916,
2803,
2223,
508,
5262,
14,
13241,
26,
355,
291,
423,
31984,
275,
5262,
14,
69,
3601,
7940,
355,
2059,
288,
916,
2803,
2223,
508,
5262,
14,
11724,
26,
355,
29205,
275,
291,
423,
29633,
14,
362,
63,
1818,
63,
1560,
552,
342,
355,
340,
284,
508,
378,
26,
490,
291,
423,
30875,
59,
17,
61,
275,
17407,
59,
16,
61,
490,
291,
423,
77,
2998,
17606,
14,
3871,
8,
277,
423,
30875,
59,
18,
446,
29205,
8429,
6059,
29205,
9,
490,
291,
423,
77,
8580,
17606,
14,
3871,
8,
277,
423,
30875,
12,
29205,
9,
355,
587,
26,
490,
291,
423,
77,
2998,
17606,
14,
3871,
8,
22353,
59,
73,
435,
413,
446,
29205,
26,
73,
435,
650,
9349,
446,
29205,
467,
29205,
9,
490,
291,
423,
77,
8580,
17606,
14,
3871,
8,
22353,
59,
73,
446,
413,
26,
73,
435,
413,
467,
9349,
29205,
9,
398,
291,
423,
30875,
59,
16,
61,
275,
17407,
59,
65,
3166,
446,
413,
61,
398,
340,
291,
14,
362,
63,
929,
342,
508,
5262,
14,
69,
20064,
316,
26,
288,
340,
334,
277,
423,
77,
2998,
17606,
14,
7808,
63,
30881,
63,
576,
342,
436,
2049,
334,
277,
14,
362,
63,
13969,
342,
690,
5262,
14,
13003,
24678,
63,
19307,
2298,
355,
291,
423,
31984,
275,
5262,
14,
69,
3601,
7940,
398,
372,
291,
14,
362,
63,
929,
342,
339,
347,
664,
63,
13969,
8,
277,
304,
267,
406,
2424,
24304,
275,
291,
423,
77,
2998,
17606,
14,
362,
63,
13969,
342,
267,
29573,
24304,
275,
291,
423,
77,
8580,
17606,
14,
362,
63,
13969,
342,
267,
372,
1390,
8,
388,
2424,
24304,
12,
29573,
24304,
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,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
bharadwajyarlagadda/bingmaps
|
tests/test_location_by_address_url_schema.py
|
1
|
2911
|
import pytest
from bingmaps.apiservices import LocationByAddress
from bingmaps.urls import LocationByAddressSchema
from .fixtures import parametrize, BING_MAPS_KEY
http_protocol = 'http'
https_protocol = 'https'
DATA = [{'adminDistrict': 'WA'},
{'key': 'vds'},
{'adminDistrict': 'WA',
'locality': 'Seattle',
'key': 'abs'},
{'adminDistrict': 'WA',
'locality': 'Seattle',
'key': BING_MAPS_KEY},
{'adminDistrict': 'WA',
'locality': 'Seattle',
'key': BING_MAPS_KEY},
{'adminDistrict': 'WA',
'locality': 'Seattle',
'o': 'xml',
'key': BING_MAPS_KEY}
]
EXPECTED = [
True,
False,
'adminDistrict=WA&locality=Seattle&includeNeighborhood='
'0&include=ciso2&maxResults=20&key=abs',
'http://dev.virtualearth.net/REST/v1/Locations?'
'adminDistrict=WA&locality=Seattle&includeNeighborhood='
'0&include=ciso2&maxResults='
'20&key={0}'.format(BING_MAPS_KEY),
'https://dev.virtualearth.net/REST/v1/Locations?'
'adminDistrict=WA&locality=Seattle&includeNeighborhood='
'0&include=ciso2&maxResults='
'20&key={0}'.format(BING_MAPS_KEY),
'https://dev.virtualearth.net/REST/v1/Locations?'
'adminDistrict=WA&locality=Seattle&o=xml&includeNeighborhood='
'0&include=ciso2&maxResults='
'20&key={0}'.format(BING_MAPS_KEY)
]
@parametrize('data,expected', [
(DATA[0], EXPECTED[0]),
(DATA[1], EXPECTED[1])
])
def test_schema_without_key(data, expected):
schema = LocationByAddressSchema()
is_valid_schema = schema.validate(data)
assert bool(is_valid_schema) is expected
@parametrize('data,expected', [
(DATA[2], EXPECTED[2])
])
def test_consolidate_query_dict(data, expected):
query = LocationByAddressSchema()
query_string = query.dump(data).data
assert query_string['query'] == expected
@parametrize('data,expected', [
(DATA[3], EXPECTED[3])
])
def test_build_url_http_protocol(data, expected):
loc_by_address = LocationByAddress(data, http_protocol)
url = loc_by_address.build_url()
assert url == expected
@parametrize('data,expected', [
(DATA[4], EXPECTED[4]),
(DATA[5], EXPECTED[5])
])
def test_build_url_https_protocol(data, expected):
loc_by_address = LocationByAddress(data, https_protocol)
url = loc_by_address.build_url()
assert url == expected
@parametrize('data', [
(DATA[0])
])
def test_schema_without_key_exception(data):
with pytest.raises(KeyError) as exc:
loc_by_address = LocationByAddress(data, https_protocol)
schema = loc_by_address.build_url()
assert exc == {'queryParameters': {'key': ['Please provide a key']}}
@parametrize('data', [
('')
])
def test_schema_no_data(data):
with pytest.raises(TypeError) as exc:
loc_by_address = LocationByAddress(data)
assert exc == "No data given"
|
mit
|
[
646,
4613,
199,
199,
504,
330,
316,
8919,
14,
1246,
5950,
492,
12625,
2175,
1476,
199,
504,
330,
316,
8919,
14,
3603,
492,
12625,
2175,
1476,
6700,
199,
504,
1275,
8769,
492,
18117,
599,
806,
12,
699,
1206,
63,
5443,
51,
63,
3078,
199,
199,
1014,
63,
3922,
275,
283,
1014,
7,
199,
2859,
63,
3922,
275,
283,
2859,
7,
199,
199,
3998,
275,
9016,
2113,
36,
5230,
319,
356,
283,
9004,
2267,
267,
791,
498,
356,
283,
86,
795,
2267,
267,
791,
2113,
36,
5230,
319,
356,
283,
9004,
297,
268,
283,
1832,
1209,
356,
283,
1513,
29274,
297,
268,
283,
498,
356,
283,
2101,
2267,
267,
791,
2113,
36,
5230,
319,
356,
283,
9004,
297,
268,
283,
1832,
1209,
356,
283,
1513,
29274,
297,
268,
283,
498,
356,
699,
1206,
63,
5443,
51,
63,
3078,
1386,
267,
791,
2113,
36,
5230,
319,
356,
283,
9004,
297,
268,
283,
1832,
1209,
356,
283,
1513,
29274,
297,
268,
283,
498,
356,
699,
1206,
63,
5443,
51,
63,
3078,
1386,
267,
791,
2113,
36,
5230,
319,
356,
283,
9004,
297,
268,
283,
1832,
1209,
356,
283,
1513,
29274,
297,
268,
283,
79,
356,
283,
1652,
297,
268,
283,
498,
356,
699,
1206,
63,
5443,
51,
63,
3078,
93,
267,
1622,
199,
199,
22358,
275,
359,
272,
715,
12,
272,
756,
12,
272,
283,
2113,
36,
5230,
319,
29,
9004,
6,
1832,
1209,
29,
1513,
29274,
6,
2613,
13779,
10422,
534,
272,
283,
16,
6,
2613,
29,
67,
4595,
18,
6,
988,
6579,
29,
1165,
6,
498,
29,
2101,
297,
272,
283,
1014,
921,
2374,
14,
4549,
1458,
4025,
273,
14,
846,
15,
15740,
15,
86,
17,
15,
27727,
14069,
272,
283,
2113,
36,
5230,
319,
29,
9004,
6,
1832,
1209,
29,
1513,
29274,
6,
2613,
13779,
10422,
534,
272,
283,
16,
6,
2613,
29,
67,
4595,
18,
6,
988,
6579,
534,
272,
283,
1165,
6,
498,
3126,
16,
5285,
908,
8,
34,
1206,
63,
5443,
51,
63,
3078,
395,
272,
283,
2859,
921,
2374,
14,
4549,
1458,
4025,
273,
14,
846,
15,
15740,
15,
86,
17,
15,
27727,
14069,
272,
283,
2113,
36,
5230,
319,
29,
9004,
6,
1832,
1209,
29,
1513,
29274,
6,
2613,
13779,
10422,
534,
272,
283,
16,
6,
2613,
29,
67,
4595,
18,
6,
988,
6579,
534,
272,
283,
1165,
6,
498,
3126,
16,
5285,
908,
8,
34,
1206,
63,
5443,
51,
63,
3078,
395,
272,
283,
2859,
921,
2374,
14,
4549,
1458,
4025,
273,
14,
846,
15,
15740,
15,
86,
17,
15,
27727,
14069,
272,
283,
2113,
36,
5230,
319,
29,
9004,
6,
1832,
1209,
29,
1513,
29274,
6,
79,
29,
1652,
6,
2613,
13779,
10422,
534,
272,
283,
16,
6,
2613,
29,
67,
4595,
18,
6,
988,
6579,
534,
272,
283,
1165,
6,
498,
3126,
16,
5285,
908,
8,
34,
1206,
63,
5443,
51,
63,
3078,
9,
199,
61,
421,
199,
32,
10396,
360,
576,
12,
2062,
297,
359,
272,
334,
3998,
59,
16,
467,
20464,
1149,
59,
16,
2522,
272,
334,
3998,
59,
17,
467,
20464,
1149,
59,
17,
566,
199,
566,
199,
318,
511,
63,
3629,
63,
7395,
63,
498,
8,
576,
12,
1420,
304,
272,
4177,
275,
12625,
2175,
1476,
6700,
342,
272,
365,
63,
1078,
63,
3629,
275,
4177,
14,
3502,
8,
576,
9,
272,
702,
2155,
8,
374,
63,
1078,
63,
3629,
9,
365,
1420,
421,
199,
32,
10396,
360,
576,
12,
2062,
297,
359,
272,
334,
3998,
59,
18,
467,
20464,
1149,
59,
18,
566,
199,
566,
199,
318,
511,
63,
388,
28335,
602,
63,
1131,
63,
807,
8,
576,
12,
1420,
304,
272,
1827,
275,
12625,
2175,
1476,
6700,
342,
272,
1827,
63,
875,
275,
1827,
14,
2724,
8,
576,
680,
576,
272,
702,
1827,
63,
875,
459,
1131,
418,
508,
1420,
421,
199,
32,
10396,
360,
576,
12,
2062,
297,
359,
272,
334,
3998,
59,
19,
467,
20464,
1149,
59,
19,
566,
199,
566,
199,
318,
511,
63,
1506,
63,
633,
63,
1014,
63,
3922,
8,
576,
12,
1420,
304,
272,
4355,
63,
991,
63,
1562,
275,
12625,
2175,
1476,
8,
576,
12,
1455,
63,
3922,
9,
272,
1166,
275,
4355,
63,
991,
63,
1562,
14,
1506,
63,
633,
342,
272,
702,
1166,
508,
1420,
421,
199,
32,
10396,
360,
576,
12,
2062,
297,
359,
272,
334,
3998,
59,
20,
467,
20464,
1149,
59,
20,
2522,
272,
334,
3998,
59,
21,
467,
20464,
1149,
59,
21,
566,
199,
566,
199,
318,
511,
63,
1506,
63,
633,
63,
2859,
63,
3922,
8,
576,
12,
1420,
304,
272,
4355,
63,
991,
63,
1562,
275,
12625,
2175,
1476,
8,
576,
12,
4178,
63,
3922,
9,
272,
1166,
275,
4355,
63,
991,
63,
1562,
14,
1506,
63,
633,
342,
272,
702,
1166,
508,
1420,
421,
199,
32,
10396,
360,
576,
297,
359,
272,
334,
3998,
59,
16,
566,
199,
566,
199,
318,
511,
63,
3629,
63,
7395,
63,
498,
63,
1971,
8,
576,
304,
272,
543,
4613,
14,
3536,
8,
10230,
9,
465,
3178,
26,
267,
4355,
63,
991,
63,
1562,
275,
12625,
2175,
1476,
8,
576,
12,
4178,
63,
3922,
9,
267,
4177,
275,
4355,
63,
991,
63,
1562,
14,
1506,
63,
633,
342,
267,
702,
3178,
508,
791,
1131,
5976,
356,
791,
498,
356,
788,
8254,
5647,
282,
790,
418,
4863,
421,
199,
32,
10396,
360,
576,
297,
359,
272,
661,
358,
199,
566,
199,
318,
511,
63,
3629,
63,
889,
63,
576,
8,
576,
304,
272,
543,
4613,
14,
3536,
8,
4333,
9,
465,
3178,
26,
267,
4355,
63,
991,
63,
1562,
275,
12625,
2175,
1476,
8,
576,
9,
267,
702,
3178,
508,
298,
1944,
666,
1627,
2,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
4613,
199,
199,
504,
330,
316,
8919,
14,
1246,
5950,
492,
12625,
2175,
1476,
199,
504,
330,
316,
8919,
14,
3603,
492,
12625,
2175,
1476,
6700,
199,
504,
1275,
8769,
492,
18117,
599,
806,
12,
699,
1206,
63,
5443,
51,
63,
3078,
199,
199,
1014,
63,
3922,
275,
283,
1014,
7,
199,
2859,
63,
3922,
275,
283,
2859,
7,
199,
199,
3998,
275,
9016,
2113,
36,
5230,
319,
356,
283,
9004,
2267,
267,
791,
498,
356,
283,
86,
795,
2267,
267,
791,
2113,
36,
5230,
319,
356,
283,
9004,
297,
268,
283,
1832,
1209,
356,
283,
1513,
29274,
297,
268,
283,
498,
356,
283,
2101,
2267,
267,
791,
2113,
36,
5230,
319,
356,
283,
9004,
297,
268,
283,
1832,
1209,
356,
283,
1513,
29274,
297,
268,
283,
498,
356,
699,
1206,
63,
5443,
51,
63,
3078,
1386,
267,
791,
2113,
36,
5230,
319,
356,
283,
9004,
297,
268,
283,
1832,
1209,
356,
283,
1513,
29274,
297,
268,
283,
498,
356,
699,
1206,
63,
5443,
51,
63,
3078,
1386,
267,
791,
2113,
36,
5230,
319,
356,
283,
9004,
297,
268,
283,
1832,
1209,
356,
283,
1513,
29274,
297,
268,
283,
79,
356,
283,
1652,
297,
268,
283,
498,
356,
699,
1206,
63,
5443,
51,
63,
3078,
93,
267,
1622,
199,
199,
22358,
275,
359,
272,
715,
12,
272,
756,
12,
272,
283,
2113,
36,
5230,
319,
29,
9004,
6,
1832,
1209,
29,
1513,
29274,
6,
2613,
13779,
10422,
534,
272,
283,
16,
6,
2613,
29,
67,
4595,
18,
6,
988,
6579,
29,
1165,
6,
498,
29,
2101,
297,
272,
283,
1014,
921,
2374,
14,
4549,
1458,
4025,
273,
14,
846,
15,
15740,
15,
86,
17,
15,
27727,
14069,
272,
283,
2113,
36,
5230,
319,
29,
9004,
6,
1832,
1209,
29,
1513,
29274,
6,
2613,
13779,
10422,
534,
272,
283,
16,
6,
2613,
29,
67,
4595,
18,
6,
988,
6579,
534,
272,
283,
1165,
6,
498,
3126,
16,
5285,
908,
8,
34,
1206,
63,
5443,
51,
63,
3078,
395,
272,
283,
2859,
921,
2374,
14,
4549,
1458,
4025,
273,
14,
846,
15,
15740,
15,
86,
17,
15,
27727,
14069,
272,
283,
2113,
36,
5230,
319,
29,
9004,
6,
1832,
1209,
29,
1513,
29274,
6,
2613,
13779,
10422,
534,
272,
283,
16,
6,
2613,
29,
67,
4595,
18,
6,
988,
6579,
534,
272,
283,
1165,
6,
498,
3126,
16,
5285,
908,
8,
34,
1206,
63,
5443,
51,
63,
3078,
395,
272,
283,
2859,
921,
2374,
14,
4549,
1458,
4025,
273,
14,
846,
15,
15740,
15,
86,
17,
15,
27727,
14069,
272,
283,
2113,
36,
5230,
319,
29,
9004,
6,
1832,
1209,
29,
1513,
29274,
6,
79,
29,
1652,
6,
2613,
13779,
10422,
534,
272,
283,
16,
6,
2613,
29,
67,
4595,
18,
6,
988,
6579,
534,
272,
283,
1165,
6,
498,
3126,
16,
5285,
908,
8,
34,
1206,
63,
5443,
51,
63,
3078,
9,
199,
61,
421,
199,
32,
10396,
360,
576,
12,
2062,
297,
359,
272,
334,
3998,
59,
16,
467,
20464,
1149,
59,
16,
2522,
272,
334,
3998,
59,
17,
467,
20464,
1149,
59,
17,
566,
199,
566,
199,
318,
511,
63,
3629,
63,
7395,
63,
498,
8,
576,
12,
1420,
304,
272,
4177,
275,
12625,
2175,
1476,
6700,
342,
272,
365,
63,
1078,
63,
3629,
275,
4177,
14,
3502,
8,
576,
9,
272,
702,
2155,
8,
374,
63,
1078,
63,
3629,
9,
365,
1420,
421,
199,
32,
10396,
360,
576,
12,
2062,
297,
359,
272,
334,
3998,
59,
18,
467,
20464,
1149,
59,
18,
566,
199,
566,
199,
318,
511,
63,
388,
28335,
602,
63,
1131,
63,
807,
8,
576,
12,
1420,
304,
272,
1827,
275,
12625,
2175,
1476,
6700,
342,
272,
1827,
63,
875,
275,
1827,
14,
2724,
8,
576,
680,
576,
272,
702,
1827,
63,
875,
459,
1131,
418,
508,
1420,
421,
199,
32,
10396,
360,
576,
12,
2062,
297,
359,
272,
334,
3998,
59,
19,
467,
20464,
1149,
59,
19,
566,
199,
566,
199,
318,
511,
63,
1506,
63,
633,
63,
1014,
63,
3922,
8,
576,
12,
1420,
304,
272,
4355,
63,
991,
63,
1562,
275,
12625,
2175,
1476,
8,
576,
12,
1455,
63,
3922,
9,
272,
1166,
275,
4355,
63,
991,
63,
1562,
14,
1506,
63,
633,
342,
272,
702,
1166,
508,
1420,
421,
199,
32,
10396,
360,
576,
12,
2062,
297,
359,
272,
334,
3998,
59,
20,
467,
20464,
1149,
59,
20,
2522,
272,
334,
3998,
59,
21,
467,
20464,
1149,
59,
21,
566,
199,
566,
199,
318,
511,
63,
1506,
63,
633,
63,
2859,
63,
3922,
8,
576,
12,
1420,
304,
272,
4355,
63,
991,
63,
1562,
275,
12625,
2175,
1476,
8,
576,
12,
4178,
63,
3922,
9,
272,
1166,
275,
4355,
63,
991,
63,
1562,
14,
1506,
63,
633,
342,
272,
702,
1166,
508,
1420,
421,
199,
32,
10396,
360,
576,
297,
359,
272,
334,
3998,
59,
16,
566,
199,
566,
199,
318,
511,
63,
3629,
63,
7395,
63,
498,
63,
1971,
8,
576,
304,
272,
543,
4613,
14,
3536,
8,
10230,
9,
465,
3178,
26,
267,
4355,
63,
991,
63,
1562,
275,
12625,
2175,
1476,
8,
576,
12,
4178,
63,
3922,
9,
267,
4177,
275,
4355,
63,
991,
63,
1562,
14,
1506,
63,
633,
342,
267,
702,
3178,
508,
791,
1131,
5976,
356,
791,
498,
356,
788,
8254,
5647,
282,
790,
418,
4863,
421,
199,
32,
10396,
360,
576,
297,
359,
272,
661,
358,
199,
566,
199,
318,
511,
63,
3629,
63,
889,
63,
576,
8,
576,
304,
272,
543,
4613,
14,
3536,
8,
4333,
9,
465,
3178,
26,
267,
4355,
63,
991,
63,
1562,
275,
12625,
2175,
1476,
8,
576,
9,
267,
702,
3178,
508,
298,
1944,
666,
1627,
2,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
Tejal011089/trufil-erpnext
|
erpnext/stock/doctype/item/test_item.py
|
1
|
2870
|
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import unittest
import frappe
from frappe.test_runner import make_test_records
from erpnext.stock.doctype.item.item import WarehouseNotSet, ItemTemplateCannotHaveStock
from erpnext.stock.doctype.stock_entry.test_stock_entry import make_stock_entry
test_ignore = ["BOM"]
test_dependencies = ["Warehouse"]
def make_item(item_code, properties=None):
if frappe.db.exists("Item", item_code):
return frappe.get_doc("Item", item_code)
item = frappe.get_doc({
"doctype": "Item",
"item_code": item_code,
"item_name": item_code,
"description": item_code,
"item_group": "Products"
})
if properties:
item.update(properties)
if item.is_stock_item and not item.default_warehouse:
item.default_warehouse = "_Test Warehouse - _TC"
item.insert()
return item
class TestItem(unittest.TestCase):
def get_item(self, idx):
item_code = test_records[idx].get("item_code")
if not frappe.db.exists("Item", item_code):
item = frappe.copy_doc(test_records[idx])
item.insert()
else:
item = frappe.get_doc("Item", item_code)
return item
def test_template_cannot_have_stock(self):
item = self.get_item(10)
make_stock_entry(item_code=item.name, target="Stores - _TC", qty=1, incoming_rate=1)
item.has_variants = 1
self.assertRaises(ItemTemplateCannotHaveStock, item.save)
def test_default_warehouse(self):
item = frappe.copy_doc(test_records[0])
item.is_stock_item = 1
item.default_warehouse = None
self.assertRaises(WarehouseNotSet, item.insert)
def test_get_item_details(self):
from erpnext.stock.get_item_details import get_item_details
to_check = {
"item_code": "_Test Item",
"item_name": "_Test Item",
"description": "_Test Item 1",
"warehouse": "_Test Warehouse - _TC",
"income_account": "Sales - _TC",
"expense_account": "_Test Account Cost for Goods Sold - _TC",
"cost_center": "_Test Cost Center 2 - _TC",
"qty": 1.0,
"price_list_rate": 100.0,
"base_price_list_rate": 0.0,
"discount_percentage": 0.0,
"rate": 0.0,
"base_rate": 0.0,
"amount": 0.0,
"base_amount": 0.0,
"batch_no": None,
"item_tax_rate": '{}',
"uom": "_Test UOM",
"conversion_factor": 1.0,
}
make_test_records("Item Price")
details = get_item_details({
"item_code": "_Test Item",
"company": "_Test Company",
"price_list": "_Test Price List",
"currency": "_Test Currency",
"parenttype": "Sales Order",
"conversion_rate": 1,
"price_list_currency": "_Test Currency",
"plc_conversion_rate": 1,
"order_type": "Sales",
"transaction_type": "selling"
})
for key, value in to_check.iteritems():
self.assertEquals(value, details.get(key))
test_records = frappe.get_test_records('Item')
|
agpl-3.0
|
[
3,
1898,
334,
67,
9,
6900,
12,
481,
5034,
19215,
29053,
14,
12126,
14,
436,
23212,
199,
3,
844,
26,
1664,
1696,
1684,
844,
373,
19,
14,
1666,
4190,
14,
2424,
199,
199,
504,
636,
2443,
363,
492,
2649,
63,
5955,
199,
646,
2882,
199,
646,
6950,
199,
199,
504,
6950,
14,
396,
63,
5933,
492,
1852,
63,
396,
63,
6502,
199,
504,
29106,
14,
6088,
14,
6356,
14,
1053,
14,
1053,
492,
644,
11499,
15953,
12,
7020,
4231,
6612,
40,
811,
17103,
199,
504,
29106,
14,
6088,
14,
6356,
14,
6088,
63,
2373,
14,
396,
63,
6088,
63,
2373,
492,
1852,
63,
6088,
63,
2373,
199,
199,
396,
63,
4247,
275,
2097,
19550,
937,
199,
396,
63,
5714,
275,
2097,
55,
11499,
937,
199,
199,
318,
1852,
63,
1053,
8,
1053,
63,
600,
12,
4382,
29,
403,
304,
199,
198,
692,
6950,
14,
697,
14,
2444,
480,
2081,
401,
1242,
63,
600,
304,
507,
198,
1107,
6950,
14,
362,
63,
1301,
480,
2081,
401,
1242,
63,
600,
9,
421,
198,
1053,
275,
6950,
14,
362,
63,
1301,
2561,
507,
198,
2,
6356,
582,
298,
2081,
401,
507,
198,
2,
1053,
63,
600,
582,
1242,
63,
600,
12,
507,
198,
2,
1053,
63,
354,
582,
1242,
63,
600,
12,
507,
198,
2,
1802,
582,
1242,
63,
600,
12,
507,
198,
2,
1053,
63,
923,
582,
298,
29631,
2,
199,
198,
1552,
421,
198,
692,
4382,
26,
507,
198,
1053,
14,
873,
8,
3282,
9,
4388,
198,
692,
1242,
14,
374,
63,
6088,
63,
1053,
436,
440,
1242,
14,
885,
63,
12806,
26,
507,
198,
1053,
14,
885,
63,
12806,
275,
2668,
774,
644,
11499,
446,
485,
5708,
2,
421,
198,
1053,
14,
3176,
342,
421,
198,
1107,
1242,
199,
199,
533,
1379,
2081,
8,
2796,
14,
1746,
304,
199,
198,
318,
664,
63,
1053,
8,
277,
12,
4280,
304,
507,
198,
1053,
63,
600,
275,
511,
63,
6502,
59,
2996,
1055,
362,
480,
1053,
63,
600,
531,
507,
198,
692,
440,
6950,
14,
697,
14,
2444,
480,
2081,
401,
1242,
63,
600,
304,
686,
198,
1053,
275,
6950,
14,
1574,
63,
1301,
8,
396,
63,
6502,
59,
2996,
566,
686,
198,
1053,
14,
3176,
342,
507,
198,
2836,
26,
686,
198,
1053,
275,
6950,
14,
362,
63,
1301,
480,
2081,
401,
1242,
63,
600,
9,
507,
198,
1107,
1242,
421,
198,
318,
511,
63,
1160,
63,
11250,
63,
7804,
63,
6088,
8,
277,
304,
686,
198,
1053,
275,
291,
14,
362,
63,
1053,
8,
709,
9,
686,
198,
1875,
63,
6088,
63,
2373,
8,
1053,
63,
600,
29,
1053,
14,
354,
12,
1347,
628,
4759,
470,
446,
485,
5708,
401,
13556,
29,
17,
12,
12467,
63,
1866,
29,
17,
9,
686,
198,
1053,
14,
1989,
63,
15680,
275,
413,
686,
198,
277,
14,
1855,
8,
2081,
4231,
6612,
40,
811,
17103,
12,
1242,
14,
2117,
9,
421,
198,
318,
511,
63,
885,
63,
12806,
8,
277,
304,
507,
198,
1053,
275,
6950,
14,
1574,
63,
1301,
8,
396,
63,
6502,
59,
16,
566,
507,
198,
1053,
14,
374,
63,
6088,
63,
1053,
275,
413,
507,
198,
1053,
14,
885,
63,
12806,
275,
488,
507,
198,
277,
14,
1855,
8,
55,
11499,
15953,
12,
1242,
14,
3176,
9,
421,
198,
318,
511,
63,
362,
63,
1053,
63,
5087,
8,
277,
304,
507,
198,
504,
29106,
14,
6088,
14,
362,
63,
1053,
63,
5087,
492,
664,
63,
1053,
63,
5087,
507,
198,
475,
63,
1074,
275,
469,
686,
198,
2,
1053,
63,
600,
582,
2668,
774,
7020,
401,
686,
198,
2,
1053,
63,
354,
582,
2668,
774,
7020,
401,
686,
198,
2,
1802,
582,
2668,
774,
7020,
413,
401,
686,
198,
2,
12806,
582,
2668,
774,
644,
11499,
446,
485,
5708,
401,
686,
198,
2,
23607,
63,
2048,
582,
298,
18220,
446,
485,
5708,
401,
686,
198,
2,
16886,
63,
2048,
582,
2668,
774,
9973,
24681,
367,
22311,
83,
428,
1753,
446,
485,
5708,
401,
686,
198,
2,
6336,
63,
4218,
582,
2668,
774,
24681,
24699,
499,
446,
485,
5708,
401,
686,
198,
2,
5643,
582,
413,
14,
16,
12,
686,
198,
2,
4777,
63,
513,
63,
1866,
582,
2948,
14,
16,
12,
686,
198,
2,
1095,
63,
4777,
63,
513,
63,
1866,
582,
378,
14,
16,
12,
686,
198,
2,
15446,
63,
14200,
582,
378,
14,
16,
12,
686,
198,
2,
1866,
582,
378,
14,
16,
12,
686,
198,
2,
1095,
63,
1866,
582,
378,
14,
16,
12,
686,
198,
2,
4606,
582,
378,
14,
16,
12,
686,
198,
2,
1095,
63,
4606,
582,
378,
14,
16,
12,
686,
198,
2,
2912,
63,
889,
582,
488,
12,
686,
198,
2,
1053,
63,
5530,
63,
1866,
582,
9005,
297,
686,
198,
2,
7519,
582,
2668,
774,
738,
7474,
401,
686,
198,
2,
15083,
63,
4778,
582,
413,
14,
16,
12,
507,
198,
93,
2742,
198,
1875,
63,
396,
63,
6502,
480,
2081,
20276,
531,
2742,
198,
5087,
275,
664,
63,
1053,
63,
5087,
2561,
686,
198,
2,
1053,
63,
600,
582,
2668,
774,
7020,
401,
686,
198,
2,
4627,
582,
2668,
774,
15878,
401,
686,
198,
2,
4777,
63,
513,
582,
2668,
774,
20276,
3820,
401,
686,
198,
2,
4968,
582,
2668,
774,
7319,
3860,
401,
686,
198,
2,
1708,
466,
582,
298,
18220,
9240,
401,
686,
198,
2,
15083,
63,
1866,
582,
413,
12,
686,
198,
2,
4777,
63,
513,
63,
4968,
582,
2668,
774,
7319,
3860,
401,
686,
198,
2,
1168,
67,
63,
15083,
63,
1866,
582,
413,
12,
686,
198,
2,
1648,
63,
466,
582,
298,
18220,
401,
686,
198,
2,
5945,
63,
466,
582,
298,
261,
10564,
2,
507,
198,
1552,
2742,
198,
509,
790,
12,
574,
315,
370,
63,
1074,
14,
4611,
837,
686,
198,
277,
14,
2947,
8,
585,
12,
2436,
14,
362,
8,
498,
430,
199,
199,
396,
63,
6502,
275,
6950,
14,
362,
63,
396,
63,
6502,
360,
2081,
358,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
1898,
334,
67,
9,
6900,
12,
481,
5034,
19215,
29053,
14,
12126,
14,
436,
23212,
199,
3,
844,
26,
1664,
1696,
1684,
844,
373,
19,
14,
1666,
4190,
14,
2424,
199,
199,
504,
636,
2443,
363,
492,
2649,
63,
5955,
199,
646,
2882,
199,
646,
6950,
199,
199,
504,
6950,
14,
396,
63,
5933,
492,
1852,
63,
396,
63,
6502,
199,
504,
29106,
14,
6088,
14,
6356,
14,
1053,
14,
1053,
492,
644,
11499,
15953,
12,
7020,
4231,
6612,
40,
811,
17103,
199,
504,
29106,
14,
6088,
14,
6356,
14,
6088,
63,
2373,
14,
396,
63,
6088,
63,
2373,
492,
1852,
63,
6088,
63,
2373,
199,
199,
396,
63,
4247,
275,
2097,
19550,
937,
199,
396,
63,
5714,
275,
2097,
55,
11499,
937,
199,
199,
318,
1852,
63,
1053,
8,
1053,
63,
600,
12,
4382,
29,
403,
304,
199,
198,
692,
6950,
14,
697,
14,
2444,
480,
2081,
401,
1242,
63,
600,
304,
507,
198,
1107,
6950,
14,
362,
63,
1301,
480,
2081,
401,
1242,
63,
600,
9,
421,
198,
1053,
275,
6950,
14,
362,
63,
1301,
2561,
507,
198,
2,
6356,
582,
298,
2081,
401,
507,
198,
2,
1053,
63,
600,
582,
1242,
63,
600,
12,
507,
198,
2,
1053,
63,
354,
582,
1242,
63,
600,
12,
507,
198,
2,
1802,
582,
1242,
63,
600,
12,
507,
198,
2,
1053,
63,
923,
582,
298,
29631,
2,
199,
198,
1552,
421,
198,
692,
4382,
26,
507,
198,
1053,
14,
873,
8,
3282,
9,
4388,
198,
692,
1242,
14,
374,
63,
6088,
63,
1053,
436,
440,
1242,
14,
885,
63,
12806,
26,
507,
198,
1053,
14,
885,
63,
12806,
275,
2668,
774,
644,
11499,
446,
485,
5708,
2,
421,
198,
1053,
14,
3176,
342,
421,
198,
1107,
1242,
199,
199,
533,
1379,
2081,
8,
2796,
14,
1746,
304,
199,
198,
318,
664,
63,
1053,
8,
277,
12,
4280,
304,
507,
198,
1053,
63,
600,
275,
511,
63,
6502,
59,
2996,
1055,
362,
480,
1053,
63,
600,
531,
507,
198,
692,
440,
6950,
14,
697,
14,
2444,
480,
2081,
401,
1242,
63,
600,
304,
686,
198,
1053,
275,
6950,
14,
1574,
63,
1301,
8,
396,
63,
6502,
59,
2996,
566,
686,
198,
1053,
14,
3176,
342,
507,
198,
2836,
26,
686,
198,
1053,
275,
6950,
14,
362,
63,
1301,
480,
2081,
401,
1242,
63,
600,
9,
507,
198,
1107,
1242,
421,
198,
318,
511,
63,
1160,
63,
11250,
63,
7804,
63,
6088,
8,
277,
304,
686,
198,
1053,
275,
291,
14,
362,
63,
1053,
8,
709,
9,
686,
198,
1875,
63,
6088,
63,
2373,
8,
1053,
63,
600,
29,
1053,
14,
354,
12,
1347,
628,
4759,
470,
446,
485,
5708,
401,
13556,
29,
17,
12,
12467,
63,
1866,
29,
17,
9,
686,
198,
1053,
14,
1989,
63,
15680,
275,
413,
686,
198,
277,
14,
1855,
8,
2081,
4231,
6612,
40,
811,
17103,
12,
1242,
14,
2117,
9,
421,
198,
318,
511,
63,
885,
63,
12806,
8,
277,
304,
507,
198,
1053,
275,
6950,
14,
1574,
63,
1301,
8,
396,
63,
6502,
59,
16,
566,
507,
198,
1053,
14,
374,
63,
6088,
63,
1053,
275,
413,
507,
198,
1053,
14,
885,
63,
12806,
275,
488,
507,
198,
277,
14,
1855,
8,
55,
11499,
15953,
12,
1242,
14,
3176,
9,
421,
198,
318,
511,
63,
362,
63,
1053,
63,
5087,
8,
277,
304,
507,
198,
504,
29106,
14,
6088,
14,
362,
63,
1053,
63,
5087,
492,
664,
63,
1053,
63,
5087,
507,
198,
475,
63,
1074,
275,
469,
686,
198,
2,
1053,
63,
600,
582,
2668,
774,
7020,
401,
686,
198,
2,
1053,
63,
354,
582,
2668,
774,
7020,
401,
686,
198,
2,
1802,
582,
2668,
774,
7020,
413,
401,
686,
198,
2,
12806,
582,
2668,
774,
644,
11499,
446,
485,
5708,
401,
686,
198,
2,
23607,
63,
2048,
582,
298,
18220,
446,
485,
5708,
401,
686,
198,
2,
16886,
63,
2048,
582,
2668,
774,
9973,
24681,
367,
22311,
83,
428,
1753,
446,
485,
5708,
401,
686,
198,
2,
6336,
63,
4218,
582,
2668,
774,
24681,
24699,
499,
446,
485,
5708,
401,
686,
198,
2,
5643,
582,
413,
14,
16,
12,
686,
198,
2,
4777,
63,
513,
63,
1866,
582,
2948,
14,
16,
12,
686,
198,
2,
1095,
63,
4777,
63,
513,
63,
1866,
582,
378,
14,
16,
12,
686,
198,
2,
15446,
63,
14200,
582,
378,
14,
16,
12,
686,
198,
2,
1866,
582,
378,
14,
16,
12,
686,
198,
2,
1095,
63,
1866,
582,
378,
14,
16,
12,
686,
198,
2,
4606,
582,
378,
14,
16,
12,
686,
198,
2,
1095,
63,
4606,
582,
378,
14,
16,
12,
686,
198,
2,
2912,
63,
889,
582,
488,
12,
686,
198,
2,
1053,
63,
5530,
63,
1866,
582,
9005,
297,
686,
198,
2,
7519,
582,
2668,
774,
738,
7474,
401,
686,
198,
2,
15083,
63,
4778,
582,
413,
14,
16,
12,
507,
198,
93,
2742,
198,
1875,
63,
396,
63,
6502,
480,
2081,
20276,
531,
2742,
198,
5087,
275,
664,
63,
1053,
63,
5087,
2561,
686,
198,
2,
1053,
63,
600,
582,
2668,
774,
7020,
401,
686,
198,
2,
4627,
582,
2668,
774,
15878,
401,
686,
198,
2,
4777,
63,
513,
582,
2668,
774,
20276,
3820,
401,
686,
198,
2,
4968,
582,
2668,
774,
7319,
3860,
401,
686,
198,
2,
1708,
466,
582,
298,
18220,
9240,
401,
686,
198,
2,
15083,
63,
1866,
582,
413,
12,
686,
198,
2,
4777,
63,
513,
63,
4968,
582,
2668,
774,
7319,
3860,
401,
686,
198,
2,
1168,
67,
63,
15083,
63,
1866,
582,
413,
12,
686,
198,
2,
1648,
63,
466,
582,
298,
18220,
401,
686,
198,
2,
5945,
63,
466,
582,
298,
261,
10564,
2,
507,
198,
1552,
2742,
198,
509,
790,
12,
574,
315,
370,
63,
1074,
14,
4611,
837,
686,
198,
277,
14,
2947,
8,
585,
12,
2436,
14,
362,
8,
498,
430,
199,
199,
396,
63,
6502,
275,
6950,
14,
362,
63,
396,
63,
6502,
360,
2081,
358,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
kevinmel2000/sl4a
|
python-build/python-libs/gdata/tests/atom_tests/token_store_test.py
|
128
|
2896
|
#!/usr/bin/python
#
# Copyright (C) 2008 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.
__author__ = 'j.s@google.com (Jeff Scudder)'
import unittest
import atom.token_store
import atom.http_interface
import atom.service
import atom.url
class TokenStoreTest(unittest.TestCase):
def setUp(self):
self.token = atom.service.BasicAuthToken('aaa1', scopes=[
'http://example.com/', 'http://example.org'])
self.tokens = atom.token_store.TokenStore()
self.tokens.add_token(self.token)
def testAddAndFindTokens(self):
self.assert_(self.tokens.find_token('http://example.com/') == self.token)
self.assert_(self.tokens.find_token('http://example.org/') == self.token)
self.assert_(self.tokens.find_token('http://example.org/foo?ok=1') == (
self.token))
self.assert_(isinstance(self.tokens.find_token('http://example.net/'),
atom.http_interface.GenericToken))
self.assert_(isinstance(self.tokens.find_token('example.com/'),
atom.http_interface.GenericToken))
def testFindTokenUsingMultipleUrls(self):
self.assert_(self.tokens.find_token(
'http://example.com/') == self.token)
self.assert_(self.tokens.find_token(
'http://example.org/bar') == self.token)
self.assert_(isinstance(self.tokens.find_token(''),
atom.http_interface.GenericToken))
self.assert_(isinstance(self.tokens.find_token(
'http://example.net/'),
atom.http_interface.GenericToken))
def testFindTokenWithPartialScopes(self):
token = atom.service.BasicAuthToken('aaa1',
scopes=[atom.url.Url(host='www.example.com', path='/foo'),
atom.url.Url(host='www.example.net')])
token_store = atom.token_store.TokenStore()
token_store.add_token(token)
self.assert_(token_store.find_token(
'http://www.example.com/foobar') == token)
self.assert_(token_store.find_token(
'https://www.example.com:443/foobar') == token)
self.assert_(token_store.find_token(
'http://www.example.net/xyz') == token)
self.assert_(token_store.find_token('http://www.example.org/') != token)
self.assert_(isinstance(token_store.find_token('http://example.org/'),
atom.http_interface.GenericToken))
def suite():
return unittest.TestSuite((unittest.makeSuite(TokenStoreTest,'test'),))
if __name__ == '__main__':
unittest.main()
|
apache-2.0
|
[
3381,
2647,
15,
1393,
15,
1548,
199,
3,
199,
3,
1898,
334,
35,
9,
9079,
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,
363,
2502,
363,
275,
283,
74,
14,
83,
32,
3098,
14,
957,
334,
42,
3609,
13916,
1181,
424,
3171,
421,
199,
646,
2882,
199,
646,
6222,
14,
1418,
63,
1617,
199,
646,
6222,
14,
1014,
63,
3266,
199,
646,
6222,
14,
1364,
199,
646,
6222,
14,
633,
199,
199,
533,
8767,
5502,
774,
8,
2796,
14,
1746,
304,
819,
347,
3613,
8,
277,
304,
272,
291,
14,
1418,
275,
6222,
14,
1364,
14,
6845,
2817,
3264,
360,
11629,
17,
297,
14570,
1524,
267,
283,
1014,
921,
2694,
14,
957,
3678,
283,
1014,
921,
2694,
14,
1308,
1105,
272,
291,
14,
4504,
275,
6222,
14,
1418,
63,
1617,
14,
3264,
5502,
342,
272,
291,
14,
4504,
14,
525,
63,
1418,
8,
277,
14,
1418,
9,
819,
347,
511,
1123,
3325,
6591,
16419,
8,
277,
304,
272,
291,
14,
479,
2531,
277,
14,
4504,
14,
1623,
63,
1418,
360,
1014,
921,
2694,
14,
957,
6217,
508,
291,
14,
1418,
9,
272,
291,
14,
479,
2531,
277,
14,
4504,
14,
1623,
63,
1418,
360,
1014,
921,
2694,
14,
1308,
6217,
508,
291,
14,
1418,
9,
272,
291,
14,
479,
2531,
277,
14,
4504,
14,
1623,
63,
1418,
360,
1014,
921,
2694,
14,
1308,
15,
1421,
31,
745,
29,
17,
358,
508,
334,
267,
291,
14,
1418,
430,
272,
291,
14,
479,
2531,
6074,
8,
277,
14,
4504,
14,
1623,
63,
1418,
360,
1014,
921,
2694,
14,
846,
20467,
267,
6222,
14,
1014,
63,
3266,
14,
9417,
3264,
430,
272,
291,
14,
479,
2531,
6074,
8,
277,
14,
4504,
14,
1623,
63,
1418,
360,
2694,
14,
957,
20467,
4960,
6222,
14,
1014,
63,
3266,
14,
9417,
3264,
430,
819,
347,
511,
6591,
3264,
10369,
8433,
21867,
478,
8,
277,
304,
272,
291,
14,
479,
2531,
277,
14,
4504,
14,
1623,
63,
1418,
8,
267,
283,
1014,
921,
2694,
14,
957,
6217,
508,
291,
14,
1418,
9,
272,
291,
14,
479,
2531,
277,
14,
4504,
14,
1623,
63,
1418,
8,
267,
283,
1014,
921,
2694,
14,
1308,
15,
1700,
358,
508,
291,
14,
1418,
9,
272,
291,
14,
479,
2531,
6074,
8,
277,
14,
4504,
14,
1623,
63,
1418,
31150,
4960,
6222,
14,
1014,
63,
3266,
14,
9417,
3264,
430,
272,
291,
14,
479,
2531,
6074,
8,
277,
14,
4504,
14,
1623,
63,
1418,
8,
288,
283,
1014,
921,
2694,
14,
846,
20467,
4960,
6222,
14,
1014,
63,
3266,
14,
9417,
3264,
430,
819,
347,
511,
6591,
3264,
3007,
18192,
7812,
83,
8,
277,
304,
272,
1526,
275,
6222,
14,
1364,
14,
6845,
2817,
3264,
360,
11629,
17,
297,
4960,
14570,
1524,
4188,
14,
633,
14,
6417,
8,
1102,
534,
1544,
14,
2694,
14,
957,
297,
931,
8805,
1421,
659,
8892,
6222,
14,
633,
14,
6417,
8,
1102,
534,
1544,
14,
2694,
14,
846,
2023,
272,
1526,
63,
1617,
275,
6222,
14,
1418,
63,
1617,
14,
3264,
5502,
342,
272,
1526,
63,
1617,
14,
525,
63,
1418,
8,
1418,
9,
272,
291,
14,
479,
2531,
1418,
63,
1617,
14,
1623,
63,
1418,
8,
267,
283,
1014,
921,
1544,
14,
2694,
14,
957,
15,
9664,
358,
508,
1526,
9,
272,
291,
14,
479,
2531,
1418,
63,
1617,
14,
1623,
63,
1418,
8,
267,
283,
2859,
921,
1544,
14,
2694,
14,
957,
26,
16284,
15,
9664,
358,
508,
1526,
9,
272,
291,
14,
479,
2531,
1418,
63,
1617,
14,
1623,
63,
1418,
8,
267,
283,
1014,
921,
1544,
14,
2694,
14,
846,
15,
8568,
358,
508,
1526,
9,
272,
291,
14,
479,
2531,
1418,
63,
1617,
14,
1623,
63,
1418,
360,
1014,
921,
1544,
14,
2694,
14,
1308,
6217,
1137,
1526,
9,
272,
291,
14,
479,
2531,
6074,
8,
1418,
63,
1617,
14,
1623,
63,
1418,
360,
1014,
921,
2694,
14,
1308,
20467,
4960,
6222,
14,
1014,
63,
3266,
14,
9417,
3264,
430,
421,
199,
318,
5241,
837,
523,
372,
2882,
14,
10591,
1332,
2796,
14,
18275,
8,
3264,
5502,
774,
2584,
396,
659,
430,
421,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
523,
2882,
14,
973,
342,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
2647,
15,
1393,
15,
1548,
199,
3,
199,
3,
1898,
334,
35,
9,
9079,
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,
363,
2502,
363,
275,
283,
74,
14,
83,
32,
3098,
14,
957,
334,
42,
3609,
13916,
1181,
424,
3171,
421,
199,
646,
2882,
199,
646,
6222,
14,
1418,
63,
1617,
199,
646,
6222,
14,
1014,
63,
3266,
199,
646,
6222,
14,
1364,
199,
646,
6222,
14,
633,
199,
199,
533,
8767,
5502,
774,
8,
2796,
14,
1746,
304,
819,
347,
3613,
8,
277,
304,
272,
291,
14,
1418,
275,
6222,
14,
1364,
14,
6845,
2817,
3264,
360,
11629,
17,
297,
14570,
1524,
267,
283,
1014,
921,
2694,
14,
957,
3678,
283,
1014,
921,
2694,
14,
1308,
1105,
272,
291,
14,
4504,
275,
6222,
14,
1418,
63,
1617,
14,
3264,
5502,
342,
272,
291,
14,
4504,
14,
525,
63,
1418,
8,
277,
14,
1418,
9,
819,
347,
511,
1123,
3325,
6591,
16419,
8,
277,
304,
272,
291,
14,
479,
2531,
277,
14,
4504,
14,
1623,
63,
1418,
360,
1014,
921,
2694,
14,
957,
6217,
508,
291,
14,
1418,
9,
272,
291,
14,
479,
2531,
277,
14,
4504,
14,
1623,
63,
1418,
360,
1014,
921,
2694,
14,
1308,
6217,
508,
291,
14,
1418,
9,
272,
291,
14,
479,
2531,
277,
14,
4504,
14,
1623,
63,
1418,
360,
1014,
921,
2694,
14,
1308,
15,
1421,
31,
745,
29,
17,
358,
508,
334,
267,
291,
14,
1418,
430,
272,
291,
14,
479,
2531,
6074,
8,
277,
14,
4504,
14,
1623,
63,
1418,
360,
1014,
921,
2694,
14,
846,
20467,
267,
6222,
14,
1014,
63,
3266,
14,
9417,
3264,
430,
272,
291,
14,
479,
2531,
6074,
8,
277,
14,
4504,
14,
1623,
63,
1418,
360,
2694,
14,
957,
20467,
4960,
6222,
14,
1014,
63,
3266,
14,
9417,
3264,
430,
819,
347,
511,
6591,
3264,
10369,
8433,
21867,
478,
8,
277,
304,
272,
291,
14,
479,
2531,
277,
14,
4504,
14,
1623,
63,
1418,
8,
267,
283,
1014,
921,
2694,
14,
957,
6217,
508,
291,
14,
1418,
9,
272,
291,
14,
479,
2531,
277,
14,
4504,
14,
1623,
63,
1418,
8,
267,
283,
1014,
921,
2694,
14,
1308,
15,
1700,
358,
508,
291,
14,
1418,
9,
272,
291,
14,
479,
2531,
6074,
8,
277,
14,
4504,
14,
1623,
63,
1418,
31150,
4960,
6222,
14,
1014,
63,
3266,
14,
9417,
3264,
430,
272,
291,
14,
479,
2531,
6074,
8,
277,
14,
4504,
14,
1623,
63,
1418,
8,
288,
283,
1014,
921,
2694,
14,
846,
20467,
4960,
6222,
14,
1014,
63,
3266,
14,
9417,
3264,
430,
819,
347,
511,
6591,
3264,
3007,
18192,
7812,
83,
8,
277,
304,
272,
1526,
275,
6222,
14,
1364,
14,
6845,
2817,
3264,
360,
11629,
17,
297,
4960,
14570,
1524,
4188,
14,
633,
14,
6417,
8,
1102,
534,
1544,
14,
2694,
14,
957,
297,
931,
8805,
1421,
659,
8892,
6222,
14,
633,
14,
6417,
8,
1102,
534,
1544,
14,
2694,
14,
846,
2023,
272,
1526,
63,
1617,
275,
6222,
14,
1418,
63,
1617,
14,
3264,
5502,
342,
272,
1526,
63,
1617,
14,
525,
63,
1418,
8,
1418,
9,
272,
291,
14,
479,
2531,
1418,
63,
1617,
14,
1623,
63,
1418,
8,
267,
283,
1014,
921,
1544,
14,
2694,
14,
957,
15,
9664,
358,
508,
1526,
9,
272,
291,
14,
479,
2531,
1418,
63,
1617,
14,
1623,
63,
1418,
8,
267,
283,
2859,
921,
1544,
14,
2694,
14,
957,
26,
16284,
15,
9664,
358,
508,
1526,
9,
272,
291,
14,
479,
2531,
1418,
63,
1617,
14,
1623,
63,
1418,
8,
267,
283,
1014,
921,
1544,
14,
2694,
14,
846,
15,
8568,
358,
508,
1526,
9,
272,
291,
14,
479,
2531,
1418,
63,
1617,
14,
1623,
63,
1418,
360,
1014,
921,
1544,
14,
2694,
14,
1308,
6217,
1137,
1526,
9,
272,
291,
14,
479,
2531,
6074,
8,
1418,
63,
1617,
14,
1623,
63,
1418,
360,
1014,
921,
2694,
14,
1308,
20467,
4960,
6222,
14,
1014,
63,
3266,
14,
9417,
3264,
430,
421,
199,
318,
5241,
837,
523,
372,
2882,
14,
10591,
1332,
2796,
14,
18275,
8,
3264,
5502,
774,
2584,
396,
659,
430,
421,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
523,
2882,
14,
973,
342,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
simongoffin/website_version
|
addons/sale/sale.py
|
3
|
67882
|
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from datetime import datetime, timedelta
import time
from openerp.osv import fields, osv
from openerp.tools.translate import _
from openerp.tools import DEFAULT_SERVER_DATE_FORMAT, DEFAULT_SERVER_DATETIME_FORMAT
import openerp.addons.decimal_precision as dp
from openerp import workflow
class sale_order(osv.osv):
_name = "sale.order"
_inherit = ['mail.thread', 'ir.needaction_mixin']
_description = "Sales Order"
_track = {
'state': {
'sale.mt_order_confirmed': lambda self, cr, uid, obj, ctx=None: obj.state in ['manual'],
'sale.mt_order_sent': lambda self, cr, uid, obj, ctx=None: obj.state in ['sent']
},
}
def _amount_line_tax(self, cr, uid, line, context=None):
val = 0.0
for c in self.pool.get('account.tax').compute_all(cr, uid, line.tax_id, line.price_unit * (1-(line.discount or 0.0)/100.0), line.product_uom_qty, line.product_id, line.order_id.partner_id)['taxes']:
val += c.get('amount', 0.0)
return val
def _amount_all_wrapper(self, cr, uid, ids, field_name, arg, context=None):
""" Wrapper because of direct method passing as parameter for function fields """
return self._amount_all(cr, uid, ids, field_name, arg, context=context)
def _amount_all(self, cr, uid, ids, field_name, arg, context=None):
cur_obj = self.pool.get('res.currency')
res = {}
for order in self.browse(cr, uid, ids, context=context):
res[order.id] = {
'amount_untaxed': 0.0,
'amount_tax': 0.0,
'amount_total': 0.0,
}
val = val1 = 0.0
cur = order.pricelist_id.currency_id
for line in order.order_line:
val1 += line.price_subtotal
val += self._amount_line_tax(cr, uid, line, context=context)
res[order.id]['amount_tax'] = cur_obj.round(cr, uid, cur, val)
res[order.id]['amount_untaxed'] = cur_obj.round(cr, uid, cur, val1)
res[order.id]['amount_total'] = res[order.id]['amount_untaxed'] + res[order.id]['amount_tax']
return res
def _invoiced_rate(self, cursor, user, ids, name, arg, context=None):
res = {}
for sale in self.browse(cursor, user, ids, context=context):
if sale.invoiced:
res[sale.id] = 100.0
continue
tot = 0.0
for invoice in sale.invoice_ids:
if invoice.state not in ('draft', 'cancel'):
tot += invoice.amount_untaxed
if tot:
res[sale.id] = min(100.0, tot * 100.0 / (sale.amount_untaxed or 1.00))
else:
res[sale.id] = 0.0
return res
def _invoice_exists(self, cursor, user, ids, name, arg, context=None):
res = {}
for sale in self.browse(cursor, user, ids, context=context):
res[sale.id] = False
if sale.invoice_ids:
res[sale.id] = True
return res
def _invoiced(self, cursor, user, ids, name, arg, context=None):
res = {}
for sale in self.browse(cursor, user, ids, context=context):
res[sale.id] = True
invoice_existence = False
for invoice in sale.invoice_ids:
if invoice.state!='cancel':
invoice_existence = True
if invoice.state != 'paid':
res[sale.id] = False
break
if not invoice_existence or sale.state == 'manual':
res[sale.id] = False
return res
def _invoiced_search(self, cursor, user, obj, name, args, context=None):
if not len(args):
return []
clause = ''
sale_clause = ''
no_invoiced = False
for arg in args:
if (arg[1] == '=' and arg[2]) or (arg[1] == '!=' and not arg[2]):
clause += 'AND inv.state = \'paid\''
else:
clause += 'AND inv.state != \'cancel\' AND sale.state != \'cancel\' AND inv.state <> \'paid\' AND rel.order_id = sale.id '
sale_clause = ', sale_order AS sale '
no_invoiced = True
cursor.execute('SELECT rel.order_id ' \
'FROM sale_order_invoice_rel AS rel, account_invoice AS inv '+ sale_clause + \
'WHERE rel.invoice_id = inv.id ' + clause)
res = cursor.fetchall()
if no_invoiced:
cursor.execute('SELECT sale.id ' \
'FROM sale_order AS sale ' \
'WHERE sale.id NOT IN ' \
'(SELECT rel.order_id ' \
'FROM sale_order_invoice_rel AS rel) and sale.state != \'cancel\'')
res.extend(cursor.fetchall())
if not res:
return [('id', '=', 0)]
return [('id', 'in', [x[0] for x in res])]
def _get_order(self, cr, uid, ids, context=None):
result = {}
for line in self.pool.get('sale.order.line').browse(cr, uid, ids, context=context):
result[line.order_id.id] = True
return result.keys()
def _get_default_company(self, cr, uid, context=None):
company_id = self.pool.get('res.users')._get_company(cr, uid, context=context)
if not company_id:
raise osv.except_osv(_('Error!'), _('There is no default company for the current user!'))
return company_id
def _get_default_section_id(self, cr, uid, context=None):
""" Gives default section by checking if present in the context """
section_id = self._resolve_section_id_from_context(cr, uid, context=context) or False
if not section_id:
section_id = self.pool.get('res.users').browse(cr, uid, uid, context).default_section_id.id or False
return section_id
def _resolve_section_id_from_context(self, cr, uid, context=None):
""" Returns ID of section based on the value of 'section_id'
context key, or None if it cannot be resolved to a single
Sales Team.
"""
if context is None:
context = {}
if type(context.get('default_section_id')) in (int, long):
return context.get('default_section_id')
if isinstance(context.get('default_section_id'), basestring):
section_ids = self.pool.get('crm.case.section').name_search(cr, uid, name=context['default_section_id'], context=context)
if len(section_ids) == 1:
return int(section_ids[0][0])
return None
_columns = {
'name': fields.char('Order Reference', required=True, copy=False,
readonly=True, states={'draft': [('readonly', False)], 'sent': [('readonly', False)]}, select=True),
'origin': fields.char('Source Document', help="Reference of the document that generated this sales order request."),
'client_order_ref': fields.char('Customer Reference', copy=False),
'state': fields.selection([
('draft', 'Draft Quotation'),
('sent', 'Quotation Sent'),
('cancel', 'Cancelled'),
('waiting_date', 'Waiting Schedule'),
('progress', 'Sales Order'),
('manual', 'Sale to Invoice'),
('shipping_except', 'Shipping Exception'),
('invoice_except', 'Invoice Exception'),
('done', 'Done'),
], 'Status', readonly=True, copy=False, help="Gives the status of the quotation or sales order.\
\nThe exception status is automatically set when a cancel operation occurs \
in the invoice validation (Invoice Exception) or in the picking list process (Shipping Exception).\nThe 'Waiting Schedule' status is set when the invoice is confirmed\
but waiting for the scheduler to run on the order date.", select=True),
'date_order': fields.datetime('Date', required=True, readonly=True, select=True, states={'draft': [('readonly', False)], 'sent': [('readonly', False)]}, copy=False),
'create_date': fields.datetime('Creation Date', readonly=True, select=True, help="Date on which sales order is created."),
'date_confirm': fields.date('Confirmation Date', readonly=True, select=True, help="Date on which sales order is confirmed.", copy=False),
'user_id': fields.many2one('res.users', 'Salesperson', states={'draft': [('readonly', False)], 'sent': [('readonly', False)]}, select=True, track_visibility='onchange'),
'partner_id': fields.many2one('res.partner', 'Customer', readonly=True, states={'draft': [('readonly', False)], 'sent': [('readonly', False)]}, required=True, change_default=True, select=True, track_visibility='always'),
'partner_invoice_id': fields.many2one('res.partner', 'Invoice Address', readonly=True, required=True, states={'draft': [('readonly', False)], 'sent': [('readonly', False)]}, help="Invoice address for current sales order."),
'partner_shipping_id': fields.many2one('res.partner', 'Delivery Address', readonly=True, required=True, states={'draft': [('readonly', False)], 'sent': [('readonly', False)]}, help="Delivery address for current sales order."),
'order_policy': fields.selection([
('manual', 'On Demand'),
], 'Create Invoice', required=True, readonly=True, states={'draft': [('readonly', False)], 'sent': [('readonly', False)]},
help="""This field controls how invoice and delivery operations are synchronized."""),
'pricelist_id': fields.many2one('product.pricelist', 'Pricelist', required=True, readonly=True, states={'draft': [('readonly', False)], 'sent': [('readonly', False)]}, help="Pricelist for current sales order."),
'currency_id': fields.related('pricelist_id', 'currency_id', type="many2one", relation="res.currency", string="Currency", readonly=True, required=True),
'project_id': fields.many2one('account.analytic.account', 'Contract / Analytic', readonly=True, states={'draft': [('readonly', False)], 'sent': [('readonly', False)]}, help="The analytic account related to a sales order."),
'order_line': fields.one2many('sale.order.line', 'order_id', 'Order Lines', readonly=True, states={'draft': [('readonly', False)], 'sent': [('readonly', False)]}, copy=True),
'invoice_ids': fields.many2many('account.invoice', 'sale_order_invoice_rel', 'order_id', 'invoice_id', 'Invoices', readonly=True, copy=False, help="This is the list of invoices that have been generated for this sales order. The same sales order may have been invoiced in several times (by line for example)."),
'invoiced_rate': fields.function(_invoiced_rate, string='Invoiced Ratio', type='float'),
'invoiced': fields.function(_invoiced, string='Paid',
fnct_search=_invoiced_search, type='boolean', help="It indicates that an invoice has been paid."),
'invoice_exists': fields.function(_invoice_exists, string='Invoiced',
fnct_search=_invoiced_search, type='boolean', help="It indicates that sales order has at least one invoice."),
'note': fields.text('Terms and conditions'),
'amount_untaxed': fields.function(_amount_all_wrapper, digits_compute=dp.get_precision('Account'), string='Untaxed Amount',
store={
'sale.order': (lambda self, cr, uid, ids, c={}: ids, ['order_line'], 10),
'sale.order.line': (_get_order, ['price_unit', 'tax_id', 'discount', 'product_uom_qty'], 10),
},
multi='sums', help="The amount without tax.", track_visibility='always'),
'amount_tax': fields.function(_amount_all_wrapper, digits_compute=dp.get_precision('Account'), string='Taxes',
store={
'sale.order': (lambda self, cr, uid, ids, c={}: ids, ['order_line'], 10),
'sale.order.line': (_get_order, ['price_unit', 'tax_id', 'discount', 'product_uom_qty'], 10),
},
multi='sums', help="The tax amount."),
'amount_total': fields.function(_amount_all_wrapper, digits_compute=dp.get_precision('Account'), string='Total',
store={
'sale.order': (lambda self, cr, uid, ids, c={}: ids, ['order_line'], 10),
'sale.order.line': (_get_order, ['price_unit', 'tax_id', 'discount', 'product_uom_qty'], 10),
},
multi='sums', help="The total amount."),
'payment_term': fields.many2one('account.payment.term', 'Payment Term'),
'fiscal_position': fields.many2one('account.fiscal.position', 'Fiscal Position'),
'company_id': fields.many2one('res.company', 'Company'),
'section_id': fields.many2one('crm.case.section', 'Sales Team'),
'procurement_group_id': fields.many2one('procurement.group', 'Procurement group', copy=False),
}
_defaults = {
'date_order': fields.datetime.now,
'order_policy': 'manual',
'company_id': _get_default_company,
'state': 'draft',
'user_id': lambda obj, cr, uid, context: uid,
'name': lambda obj, cr, uid, context: '/',
'partner_invoice_id': lambda self, cr, uid, context: context.get('partner_id', False) and self.pool.get('res.partner').address_get(cr, uid, [context['partner_id']], ['invoice'])['invoice'],
'partner_shipping_id': lambda self, cr, uid, context: context.get('partner_id', False) and self.pool.get('res.partner').address_get(cr, uid, [context['partner_id']], ['delivery'])['delivery'],
'note': lambda self, cr, uid, context: self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id.sale_note,
'section_id': lambda s, cr, uid, c: s._get_default_section_id(cr, uid, c),
}
_sql_constraints = [
('name_uniq', 'unique(name, company_id)', 'Order Reference must be unique per Company!'),
]
_order = 'date_order desc, id desc'
# Form filling
def unlink(self, cr, uid, ids, context=None):
sale_orders = self.read(cr, uid, ids, ['state'], context=context)
unlink_ids = []
for s in sale_orders:
if s['state'] in ['draft', 'cancel']:
unlink_ids.append(s['id'])
else:
raise osv.except_osv(_('Invalid Action!'), _('In order to delete a confirmed sales order, you must cancel it before!'))
return osv.osv.unlink(self, cr, uid, unlink_ids, context=context)
def copy_quotation(self, cr, uid, ids, context=None):
id = self.copy(cr, uid, ids[0], context=None)
view_ref = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'sale', 'view_order_form')
view_id = view_ref and view_ref[1] or False,
return {
'type': 'ir.actions.act_window',
'name': _('Sales Order'),
'res_model': 'sale.order',
'res_id': id,
'view_type': 'form',
'view_mode': 'form',
'view_id': view_id,
'target': 'current',
'nodestroy': True,
}
def onchange_pricelist_id(self, cr, uid, ids, pricelist_id, order_lines, context=None):
context = context or {}
if not pricelist_id:
return {}
value = {
'currency_id': self.pool.get('product.pricelist').browse(cr, uid, pricelist_id, context=context).currency_id.id
}
if not order_lines:
return {'value': value}
warning = {
'title': _('Pricelist Warning!'),
'message' : _('If you change the pricelist of this order (and eventually the currency), prices of existing order lines will not be updated.')
}
return {'warning': warning, 'value': value}
def get_salenote(self, cr, uid, ids, partner_id, context=None):
context_lang = context.copy()
if partner_id:
partner_lang = self.pool.get('res.partner').browse(cr, uid, partner_id, context=context).lang
context_lang.update({'lang': partner_lang})
return self.pool.get('res.users').browse(cr, uid, uid, context=context_lang).company_id.sale_note
def onchange_delivery_id(self, cr, uid, ids, company_id, partner_id, delivery_id, fiscal_position, context=None):
r = {'value': {}}
if not fiscal_position:
if not company_id:
company_id = self._get_default_company(cr, uid, context=context)
fiscal_position = self.pool['account.fiscal.position'].get_fiscal_position(cr, uid, company_id, partner_id, delivery_id, context=context)
if fiscal_position:
r['value']['fiscal_position'] = fiscal_position
return r
def onchange_partner_id(self, cr, uid, ids, part, context=None):
if not part:
return {'value': {'partner_invoice_id': False, 'partner_shipping_id': False, 'payment_term': False, 'fiscal_position': False}}
part = self.pool.get('res.partner').browse(cr, uid, part, context=context)
addr = self.pool.get('res.partner').address_get(cr, uid, [part.id], ['delivery', 'invoice', 'contact'])
pricelist = part.property_product_pricelist and part.property_product_pricelist.id or False
payment_term = part.property_payment_term and part.property_payment_term.id or False
dedicated_salesman = part.user_id and part.user_id.id or uid
val = {
'partner_invoice_id': addr['invoice'],
'partner_shipping_id': addr['delivery'],
'payment_term': payment_term,
'user_id': dedicated_salesman,
}
delivery_onchange = self.onchange_delivery_id(cr, uid, ids, False, part.id, addr['delivery'], False, context=context)
val.update(delivery_onchange['value'])
if pricelist:
val['pricelist_id'] = pricelist
sale_note = self.get_salenote(cr, uid, ids, part.id, context=context)
if sale_note: val.update({'note': sale_note})
return {'value': val}
def create(self, cr, uid, vals, context=None):
if context is None:
context = {}
if vals.get('name', '/') == '/':
vals['name'] = self.pool.get('ir.sequence').get(cr, uid, 'sale.order') or '/'
if vals.get('partner_id') and any(f not in vals for f in ['partner_invoice_id', 'partner_shipping_id', 'pricelist_id', 'fiscal_position']):
defaults = self.onchange_partner_id(cr, uid, [], vals['partner_id'], context=context)['value']
if not vals.get('fiscal_position') and vals.get('partner_shipping_id'):
delivery_onchange = self.onchange_delivery_id(cr, uid, [], vals.get('company_id'), None, vals['partner_id'], vals.get('partner_shipping_id'), context=context)
defaults.update(delivery_onchange['value'])
vals = dict(defaults, **vals)
ctx = dict(context or {}, mail_create_nolog=True)
new_id = super(sale_order, self).create(cr, uid, vals, context=ctx)
self.message_post(cr, uid, [new_id], body=_("Quotation created"), context=ctx)
return new_id
def button_dummy(self, cr, uid, ids, context=None):
return True
# FIXME: deprecated method, overriders should be using _prepare_invoice() instead.
# can be removed after 6.1.
def _inv_get(self, cr, uid, order, context=None):
return {}
def _prepare_invoice(self, cr, uid, order, lines, context=None):
"""Prepare the dict of values to create the new invoice for a
sales order. This method may be overridden to implement custom
invoice generation (making sure to call super() to establish
a clean extension chain).
:param browse_record order: sale.order record to invoice
:param list(int) line: list of invoice line IDs that must be
attached to the invoice
:return: dict of value to create() the invoice
"""
if context is None:
context = {}
journal_ids = self.pool.get('account.journal').search(cr, uid,
[('type', '=', 'sale'), ('company_id', '=', order.company_id.id)],
limit=1)
if not journal_ids:
raise osv.except_osv(_('Error!'),
_('Please define sales journal for this company: "%s" (id:%d).') % (order.company_id.name, order.company_id.id))
invoice_vals = {
'name': order.client_order_ref or '',
'origin': order.name,
'type': 'out_invoice',
'reference': order.client_order_ref or order.name,
'account_id': order.partner_id.property_account_receivable.id,
'partner_id': order.partner_invoice_id.id,
'journal_id': journal_ids[0],
'invoice_line': [(6, 0, lines)],
'currency_id': order.pricelist_id.currency_id.id,
'comment': order.note,
'payment_term': order.payment_term and order.payment_term.id or False,
'fiscal_position': order.fiscal_position.id or order.partner_id.property_account_position.id,
'date_invoice': context.get('date_invoice', False),
'company_id': order.company_id.id,
'user_id': order.user_id and order.user_id.id or False,
'section_id' : order.section_id.id
}
# Care for deprecated _inv_get() hook - FIXME: to be removed after 6.1
invoice_vals.update(self._inv_get(cr, uid, order, context=context))
return invoice_vals
def _make_invoice(self, cr, uid, order, lines, context=None):
inv_obj = self.pool.get('account.invoice')
obj_invoice_line = self.pool.get('account.invoice.line')
if context is None:
context = {}
invoiced_sale_line_ids = self.pool.get('sale.order.line').search(cr, uid, [('order_id', '=', order.id), ('invoiced', '=', True)], context=context)
from_line_invoice_ids = []
for invoiced_sale_line_id in self.pool.get('sale.order.line').browse(cr, uid, invoiced_sale_line_ids, context=context):
for invoice_line_id in invoiced_sale_line_id.invoice_lines:
if invoice_line_id.invoice_id.id not in from_line_invoice_ids:
from_line_invoice_ids.append(invoice_line_id.invoice_id.id)
for preinv in order.invoice_ids:
if preinv.state not in ('cancel',) and preinv.id not in from_line_invoice_ids:
for preline in preinv.invoice_line:
inv_line_id = obj_invoice_line.copy(cr, uid, preline.id, {'invoice_id': False, 'price_unit': -preline.price_unit})
lines.append(inv_line_id)
inv = self._prepare_invoice(cr, uid, order, lines, context=context)
inv_id = inv_obj.create(cr, uid, inv, context=context)
data = inv_obj.onchange_payment_term_date_invoice(cr, uid, [inv_id], inv['payment_term'], time.strftime(DEFAULT_SERVER_DATE_FORMAT))
if data.get('value', False):
inv_obj.write(cr, uid, [inv_id], data['value'], context=context)
inv_obj.button_compute(cr, uid, [inv_id])
return inv_id
def print_quotation(self, cr, uid, ids, context=None):
'''
This function prints the sales order and mark it as sent, so that we can see more easily the next step of the workflow
'''
assert len(ids) == 1, 'This option should only be used for a single id at a time'
self.signal_workflow(cr, uid, ids, 'quotation_sent')
return self.pool['report'].get_action(cr, uid, ids, 'sale.report_saleorder', context=context)
def manual_invoice(self, cr, uid, ids, context=None):
""" create invoices for the given sales orders (ids), and open the form
view of one of the newly created invoices
"""
mod_obj = self.pool.get('ir.model.data')
# create invoices through the sales orders' workflow
inv_ids0 = set(inv.id for sale in self.browse(cr, uid, ids, context) for inv in sale.invoice_ids)
self.signal_workflow(cr, uid, ids, 'manual_invoice')
inv_ids1 = set(inv.id for sale in self.browse(cr, uid, ids, context) for inv in sale.invoice_ids)
# determine newly created invoices
new_inv_ids = list(inv_ids1 - inv_ids0)
res = mod_obj.get_object_reference(cr, uid, 'account', 'invoice_form')
res_id = res and res[1] or False,
return {
'name': _('Customer Invoices'),
'view_type': 'form',
'view_mode': 'form',
'view_id': [res_id],
'res_model': 'account.invoice',
'context': "{'type':'out_invoice'}",
'type': 'ir.actions.act_window',
'nodestroy': True,
'target': 'current',
'res_id': new_inv_ids and new_inv_ids[0] or False,
}
def action_view_invoice(self, cr, uid, ids, context=None):
'''
This function returns an action that display existing invoices of given sales order ids. It can either be a in a list or in a form view, if there is only one invoice to show.
'''
mod_obj = self.pool.get('ir.model.data')
act_obj = self.pool.get('ir.actions.act_window')
result = mod_obj.get_object_reference(cr, uid, 'account', 'action_invoice_tree1')
id = result and result[1] or False
result = act_obj.read(cr, uid, [id], context=context)[0]
#compute the number of invoices to display
inv_ids = []
for so in self.browse(cr, uid, ids, context=context):
inv_ids += [invoice.id for invoice in so.invoice_ids]
#choose the view_mode accordingly
if len(inv_ids)>1:
result['domain'] = "[('id','in',["+','.join(map(str, inv_ids))+"])]"
else:
res = mod_obj.get_object_reference(cr, uid, 'account', 'invoice_form')
result['views'] = [(res and res[1] or False, 'form')]
result['res_id'] = inv_ids and inv_ids[0] or False
return result
def test_no_product(self, cr, uid, order, context):
for line in order.order_line:
if line.product_id and (line.product_id.type<>'service'):
return False
return True
def action_invoice_create(self, cr, uid, ids, grouped=False, states=None, date_invoice = False, context=None):
if states is None:
states = ['confirmed', 'done', 'exception']
res = False
invoices = {}
invoice_ids = []
invoice = self.pool.get('account.invoice')
obj_sale_order_line = self.pool.get('sale.order.line')
partner_currency = {}
# If date was specified, use it as date invoiced, usefull when invoices are generated this month and put the
# last day of the last month as invoice date
if date_invoice:
context = dict(context or {}, date_invoice=date_invoice)
for o in self.browse(cr, uid, ids, context=context):
currency_id = o.pricelist_id.currency_id.id
if (o.partner_id.id in partner_currency) and (partner_currency[o.partner_id.id] <> currency_id):
raise osv.except_osv(
_('Error!'),
_('You cannot group sales having different currencies for the same partner.'))
partner_currency[o.partner_id.id] = currency_id
lines = []
for line in o.order_line:
if line.invoiced:
continue
elif (line.state in states):
lines.append(line.id)
created_lines = obj_sale_order_line.invoice_line_create(cr, uid, lines)
if created_lines:
invoices.setdefault(o.partner_invoice_id.id or o.partner_id.id, []).append((o, created_lines))
if not invoices:
for o in self.browse(cr, uid, ids, context=context):
for i in o.invoice_ids:
if i.state == 'draft':
return i.id
for val in invoices.values():
if grouped:
res = self._make_invoice(cr, uid, val[0][0], reduce(lambda x, y: x + y, [l for o, l in val], []), context=context)
invoice_ref = ''
origin_ref = ''
for o, l in val:
invoice_ref += (o.client_order_ref or o.name) + '|'
origin_ref += (o.origin or o.name) + '|'
self.write(cr, uid, [o.id], {'state': 'progress'})
cr.execute('insert into sale_order_invoice_rel (order_id,invoice_id) values (%s,%s)', (o.id, res))
self.invalidate_cache(cr, uid, ['invoice_ids'], [o.id], context=context)
#remove last '|' in invoice_ref
if len(invoice_ref) >= 1:
invoice_ref = invoice_ref[:-1]
if len(origin_ref) >= 1:
origin_ref = origin_ref[:-1]
invoice.write(cr, uid, [res], {'origin': origin_ref, 'name': invoice_ref})
else:
for order, il in val:
res = self._make_invoice(cr, uid, order, il, context=context)
invoice_ids.append(res)
self.write(cr, uid, [order.id], {'state': 'progress'})
cr.execute('insert into sale_order_invoice_rel (order_id,invoice_id) values (%s,%s)', (order.id, res))
self.invalidate_cache(cr, uid, ['invoice_ids'], [order.id], context=context)
return res
def action_invoice_cancel(self, cr, uid, ids, context=None):
self.write(cr, uid, ids, {'state': 'invoice_except'}, context=context)
return True
def action_invoice_end(self, cr, uid, ids, context=None):
for this in self.browse(cr, uid, ids, context=context):
for line in this.order_line:
if line.state == 'exception':
line.write({'state': 'confirmed'})
if this.state == 'invoice_except':
this.write({'state': 'progress'})
return True
def action_cancel(self, cr, uid, ids, context=None):
if context is None:
context = {}
sale_order_line_obj = self.pool.get('sale.order.line')
account_invoice_obj = self.pool.get('account.invoice')
for sale in self.browse(cr, uid, ids, context=context):
for inv in sale.invoice_ids:
if inv.state not in ('draft', 'cancel'):
raise osv.except_osv(
_('Cannot cancel this sales order!'),
_('First cancel all invoices attached to this sales order.'))
inv.signal_workflow('invoice_cancel')
sale_order_line_obj.write(cr, uid, [l.id for l in sale.order_line],
{'state': 'cancel'})
self.write(cr, uid, ids, {'state': 'cancel'})
return True
def action_button_confirm(self, cr, uid, ids, context=None):
assert len(ids) == 1, 'This option should only be used for a single id at a time.'
self.signal_workflow(cr, uid, ids, 'order_confirm')
# redisplay the record as a sales order
view_ref = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'sale', 'view_order_form')
view_id = view_ref and view_ref[1] or False,
return {
'type': 'ir.actions.act_window',
'name': _('Sales Order'),
'res_model': 'sale.order',
'res_id': ids[0],
'view_type': 'form',
'view_mode': 'form',
'view_id': view_id,
'target': 'current',
'nodestroy': True,
}
def action_wait(self, cr, uid, ids, context=None):
context = context or {}
for o in self.browse(cr, uid, ids):
if not o.order_line:
raise osv.except_osv(_('Error!'),_('You cannot confirm a sales order which has no line.'))
noprod = self.test_no_product(cr, uid, o, context)
if (o.order_policy == 'manual') or noprod:
self.write(cr, uid, [o.id], {'state': 'manual', 'date_confirm': fields.date.context_today(self, cr, uid, context=context)})
else:
self.write(cr, uid, [o.id], {'state': 'progress', 'date_confirm': fields.date.context_today(self, cr, uid, context=context)})
self.pool.get('sale.order.line').button_confirm(cr, uid, [x.id for x in o.order_line])
return True
def action_quotation_send(self, cr, uid, ids, context=None):
'''
This function opens a window to compose an email, with the edi sale template message loaded by default
'''
assert len(ids) == 1, 'This option should only be used for a single id at a time.'
ir_model_data = self.pool.get('ir.model.data')
try:
template_id = ir_model_data.get_object_reference(cr, uid, 'sale', 'email_template_edi_sale')[1]
except ValueError:
template_id = False
try:
compose_form_id = ir_model_data.get_object_reference(cr, uid, 'mail', 'email_compose_message_wizard_form')[1]
except ValueError:
compose_form_id = False
ctx = dict(context)
ctx.update({
'default_model': 'sale.order',
'default_res_id': ids[0],
'default_use_template': bool(template_id),
'default_template_id': template_id,
'default_composition_mode': 'comment',
'mark_so_as_sent': True
})
return {
'type': 'ir.actions.act_window',
'view_type': 'form',
'view_mode': 'form',
'res_model': 'mail.compose.message',
'views': [(compose_form_id, 'form')],
'view_id': compose_form_id,
'target': 'new',
'context': ctx,
}
def action_done(self, cr, uid, ids, context=None):
for order in self.browse(cr, uid, ids, context=context):
self.pool.get('sale.order.line').write(cr, uid, [line.id for line in order.order_line], {'state': 'done'}, context=context)
return self.write(cr, uid, ids, {'state': 'done'}, context=context)
def _prepare_order_line_procurement(self, cr, uid, order, line, group_id=False, context=None):
date_planned = self._get_date_planned(cr, uid, order, line, order.date_order, context=context)
return {
'name': line.name,
'origin': order.name,
'date_planned': date_planned,
'product_id': line.product_id.id,
'product_qty': line.product_uom_qty,
'product_uom': line.product_uom.id,
'product_uos_qty': (line.product_uos and line.product_uos_qty) or line.product_uom_qty,
'product_uos': (line.product_uos and line.product_uos.id) or line.product_uom.id,
'company_id': order.company_id.id,
'group_id': group_id,
'invoice_state': (order.order_policy == 'picking') and '2binvoiced' or 'none',
'sale_line_id': line.id
}
def _get_date_planned(self, cr, uid, order, line, start_date, context=None):
date_planned = datetime.strptime(start_date, DEFAULT_SERVER_DATETIME_FORMAT) + timedelta(days=line.delay or 0.0)
return date_planned
def _prepare_procurement_group(self, cr, uid, order, context=None):
return {'name': order.name, 'partner_id': order.partner_shipping_id.id}
def procurement_needed(self, cr, uid, ids, context=None):
#when sale is installed only, there is no need to create procurements, that's only
#further installed modules (sale_service, sale_stock) that will change this.
sale_line_obj = self.pool.get('sale.order.line')
res = []
for order in self.browse(cr, uid, ids, context=context):
res.append(sale_line_obj.need_procurement(cr, uid, [line.id for line in order.order_line], context=context))
return any(res)
def action_ignore_delivery_exception(self, cr, uid, ids, context=None):
for sale_order in self.browse(cr, uid, ids, context=context):
self.write(cr, uid, ids, {'state': 'progress' if sale_order.invoice_exists else 'manual'}, context=context)
return True
def action_ship_create(self, cr, uid, ids, context=None):
"""Create the required procurements to supply sales order lines, also connecting
the procurements to appropriate stock moves in order to bring the goods to the
sales order's requested location.
:return: True
"""
procurement_obj = self.pool.get('procurement.order')
sale_line_obj = self.pool.get('sale.order.line')
for order in self.browse(cr, uid, ids, context=context):
proc_ids = []
vals = self._prepare_procurement_group(cr, uid, order, context=context)
if not order.procurement_group_id:
group_id = self.pool.get("procurement.group").create(cr, uid, vals, context=context)
order.write({'procurement_group_id': group_id}, context=context)
for line in order.order_line:
#Try to fix exception procurement (possible when after a shipping exception the user choose to recreate)
if line.procurement_ids:
#first check them to see if they are in exception or not (one of the related moves is cancelled)
procurement_obj.check(cr, uid, [x.id for x in line.procurement_ids if x.state not in ['cancel', 'done']])
line.refresh()
#run again procurement that are in exception in order to trigger another move
proc_ids += [x.id for x in line.procurement_ids if x.state == 'exception']
elif sale_line_obj.need_procurement(cr, uid, [line.id], context=context):
if (line.state == 'done') or not line.product_id:
continue
vals = self._prepare_order_line_procurement(cr, uid, order, line, group_id=group_id, context=context)
proc_id = procurement_obj.create(cr, uid, vals, context=context)
proc_ids.append(proc_id)
#Confirm procurement order such that rules will be applied on it
#note that the workflow normally ensure proc_ids isn't an empty list
procurement_obj.run(cr, uid, proc_ids, context=context)
#if shipping was in exception and the user choose to recreate the delivery order, write the new status of SO
if order.state == 'shipping_except':
val = {'state': 'progress', 'shipped': False}
if (order.order_policy == 'manual'):
for line in order.order_line:
if (not line.invoiced) and (line.state not in ('cancel', 'draft')):
val['state'] = 'manual'
break
order.write(val)
return True
# if mode == 'finished':
# returns True if all lines are done, False otherwise
# if mode == 'canceled':
# returns True if there is at least one canceled line, False otherwise
def test_state(self, cr, uid, ids, mode, *args):
assert mode in ('finished', 'canceled'), _("invalid mode for test_state")
finished = True
canceled = False
write_done_ids = []
write_cancel_ids = []
for order in self.browse(cr, uid, ids, context={}):
#TODO: Need to rethink what happens when cancelling
for line in order.order_line:
states = [x.state for x in line.procurement_ids]
cancel = states and all([x == 'cancel' for x in states])
doneorcancel = all([x in ('done', 'cancel') for x in states])
if cancel:
canceled = True
if line.state != 'exception':
write_cancel_ids.append(line.id)
if not doneorcancel:
finished = False
if doneorcancel and not cancel:
write_done_ids.append(line.id)
if write_done_ids:
self.pool.get('sale.order.line').write(cr, uid, write_done_ids, {'state': 'done'})
if write_cancel_ids:
self.pool.get('sale.order.line').write(cr, uid, write_cancel_ids, {'state': 'exception'})
if mode == 'finished':
return finished
elif mode == 'canceled':
return canceled
def procurement_lines_get(self, cr, uid, ids, *args):
res = []
for order in self.browse(cr, uid, ids, context={}):
for line in order.order_line:
res += [x.id for x in line.procurement_ids]
return res
def onchange_fiscal_position(self, cr, uid, ids, fiscal_position, order_lines, context=None):
'''Update taxes of order lines for each line where a product is defined
:param list ids: not used
:param int fiscal_position: sale order fiscal position
:param list order_lines: command list for one2many write method
'''
order_line = []
fiscal_obj = self.pool.get('account.fiscal.position')
product_obj = self.pool.get('product.product')
line_obj = self.pool.get('sale.order.line')
fpos = False
if fiscal_position:
fpos = fiscal_obj.browse(cr, uid, fiscal_position, context=context)
for line in order_lines:
# create (0, 0, { fields })
# update (1, ID, { fields })
if line[0] in [0, 1]:
prod = None
if line[2].get('product_id'):
prod = product_obj.browse(cr, uid, line[2]['product_id'], context=context)
elif line[1]:
prod = line_obj.browse(cr, uid, line[1], context=context).product_id
if prod and prod.taxes_id:
line[2]['tax_id'] = [[6, 0, fiscal_obj.map_tax(cr, uid, fpos, prod.taxes_id)]]
order_line.append(line)
# link (4, ID)
# link all (6, 0, IDS)
elif line[0] in [4, 6]:
line_ids = line[0] == 4 and [line[1]] or line[2]
for line_id in line_ids:
prod = line_obj.browse(cr, uid, line_id, context=context).product_id
if prod and prod.taxes_id:
order_line.append([1, line_id, {'tax_id': [[6, 0, fiscal_obj.map_tax(cr, uid, fpos, prod.taxes_id)]]}])
else:
order_line.append([4, line_id])
else:
order_line.append(line)
return {'value': {'order_line': order_line}}
# TODO add a field price_unit_uos
# - update it on change product and unit price
# - use it in report if there is a uos
class sale_order_line(osv.osv):
def need_procurement(self, cr, uid, ids, context=None):
#when sale is installed only, there is no need to create procurements, that's only
#further installed modules (sale_service, sale_stock) that will change this.
return False
def _amount_line(self, cr, uid, ids, field_name, arg, context=None):
tax_obj = self.pool.get('account.tax')
cur_obj = self.pool.get('res.currency')
res = {}
if context is None:
context = {}
for line in self.browse(cr, uid, ids, context=context):
price = line.price_unit * (1 - (line.discount or 0.0) / 100.0)
taxes = tax_obj.compute_all(cr, uid, line.tax_id, price, line.product_uom_qty, line.product_id, line.order_id.partner_id)
cur = line.order_id.pricelist_id.currency_id
res[line.id] = cur_obj.round(cr, uid, cur, taxes['total'])
return res
def _get_uom_id(self, cr, uid, *args):
try:
proxy = self.pool.get('ir.model.data')
result = proxy.get_object_reference(cr, uid, 'product', 'product_uom_unit')
return result[1]
except Exception, ex:
return False
def _fnct_line_invoiced(self, cr, uid, ids, field_name, args, context=None):
res = dict.fromkeys(ids, False)
for this in self.browse(cr, uid, ids, context=context):
res[this.id] = this.invoice_lines and \
all(iline.invoice_id.state != 'cancel' for iline in this.invoice_lines)
return res
def _order_lines_from_invoice(self, cr, uid, ids, context=None):
# direct access to the m2m table is the less convoluted way to achieve this (and is ok ACL-wise)
cr.execute("""SELECT DISTINCT sol.id FROM sale_order_invoice_rel rel JOIN
sale_order_line sol ON (sol.order_id = rel.order_id)
WHERE rel.invoice_id = ANY(%s)""", (list(ids),))
return [i[0] for i in cr.fetchall()]
_name = 'sale.order.line'
_description = 'Sales Order Line'
_columns = {
'order_id': fields.many2one('sale.order', 'Order Reference', required=True, ondelete='cascade', select=True, readonly=True, states={'draft':[('readonly',False)]}),
'name': fields.text('Description', required=True, readonly=True, states={'draft': [('readonly', False)]}),
'sequence': fields.integer('Sequence', help="Gives the sequence order when displaying a list of sales order lines."),
'product_id': fields.many2one('product.product', 'Product', domain=[('sale_ok', '=', True)], change_default=True, readonly=True, states={'draft': [('readonly', False)]}, ondelete='restrict'),
'invoice_lines': fields.many2many('account.invoice.line', 'sale_order_line_invoice_rel', 'order_line_id', 'invoice_id', 'Invoice Lines', readonly=True, copy=False),
'invoiced': fields.function(_fnct_line_invoiced, string='Invoiced', type='boolean',
store={
'account.invoice': (_order_lines_from_invoice, ['state'], 10),
'sale.order.line': (lambda self,cr,uid,ids,ctx=None: ids, ['invoice_lines'], 10)
}),
'price_unit': fields.float('Unit Price', required=True, digits_compute= dp.get_precision('Product Price'), readonly=True, states={'draft': [('readonly', False)]}),
'price_subtotal': fields.function(_amount_line, string='Subtotal', digits_compute= dp.get_precision('Account')),
'tax_id': fields.many2many('account.tax', 'sale_order_tax', 'order_line_id', 'tax_id', 'Taxes', readonly=True, states={'draft': [('readonly', False)]}),
'address_allotment_id': fields.many2one('res.partner', 'Allotment Partner',help="A partner to whom the particular product needs to be allotted."),
'product_uom_qty': fields.float('Quantity', digits_compute= dp.get_precision('Product UoS'), required=True, readonly=True, states={'draft': [('readonly', False)]}),
'product_uom': fields.many2one('product.uom', 'Unit of Measure ', required=True, readonly=True, states={'draft': [('readonly', False)]}),
'product_uos_qty': fields.float('Quantity (UoS)' ,digits_compute= dp.get_precision('Product UoS'), readonly=True, states={'draft': [('readonly', False)]}),
'product_uos': fields.many2one('product.uom', 'Product UoS'),
'discount': fields.float('Discount (%)', digits_compute= dp.get_precision('Discount'), readonly=True, states={'draft': [('readonly', False)]}),
'th_weight': fields.float('Weight', readonly=True, states={'draft': [('readonly', False)]}),
'state': fields.selection(
[('cancel', 'Cancelled'),('draft', 'Draft'),('confirmed', 'Confirmed'),('exception', 'Exception'),('done', 'Done')],
'Status', required=True, readonly=True, copy=False,
help='* The \'Draft\' status is set when the related sales order in draft status. \
\n* The \'Confirmed\' status is set when the related sales order is confirmed. \
\n* The \'Exception\' status is set when the related sales order is set as exception. \
\n* The \'Done\' status is set when the sales order line has been picked. \
\n* The \'Cancelled\' status is set when a user cancel the sales order related.'),
'order_partner_id': fields.related('order_id', 'partner_id', type='many2one', relation='res.partner', store=True, string='Customer'),
'salesman_id':fields.related('order_id', 'user_id', type='many2one', relation='res.users', store=True, string='Salesperson'),
'company_id': fields.related('order_id', 'company_id', type='many2one', relation='res.company', string='Company', store=True, readonly=True),
'delay': fields.float('Delivery Lead Time', required=True, help="Number of days between the order confirmation and the shipping of the products to the customer", readonly=True, states={'draft': [('readonly', False)]}),
'procurement_ids': fields.one2many('procurement.order', 'sale_line_id', 'Procurements'),
}
_order = 'order_id desc, sequence, id'
_defaults = {
'product_uom' : _get_uom_id,
'discount': 0.0,
'product_uom_qty': 1,
'product_uos_qty': 1,
'sequence': 10,
'state': 'draft',
'price_unit': 0.0,
'delay': 0.0,
}
def _get_line_qty(self, cr, uid, line, context=None):
if line.product_uos:
return line.product_uos_qty or 0.0
return line.product_uom_qty
def _get_line_uom(self, cr, uid, line, context=None):
if line.product_uos:
return line.product_uos.id
return line.product_uom.id
def _prepare_order_line_invoice_line(self, cr, uid, line, account_id=False, context=None):
"""Prepare the dict of values to create the new invoice line for a
sales order line. This method may be overridden to implement custom
invoice generation (making sure to call super() to establish
a clean extension chain).
:param browse_record line: sale.order.line record to invoice
:param int account_id: optional ID of a G/L account to force
(this is used for returning products including service)
:return: dict of values to create() the invoice line
"""
res = {}
if not line.invoiced:
if not account_id:
if line.product_id:
account_id = line.product_id.property_account_income.id
if not account_id:
account_id = line.product_id.categ_id.property_account_income_categ.id
if not account_id:
raise osv.except_osv(_('Error!'),
_('Please define income account for this product: "%s" (id:%d).') % \
(line.product_id.name, line.product_id.id,))
else:
prop = self.pool.get('ir.property').get(cr, uid,
'property_account_income_categ', 'product.category',
context=context)
account_id = prop and prop.id or False
uosqty = self._get_line_qty(cr, uid, line, context=context)
uos_id = self._get_line_uom(cr, uid, line, context=context)
pu = 0.0
if uosqty:
pu = round(line.price_unit * line.product_uom_qty / uosqty,
self.pool.get('decimal.precision').precision_get(cr, uid, 'Product Price'))
fpos = line.order_id.fiscal_position or False
account_id = self.pool.get('account.fiscal.position').map_account(cr, uid, fpos, account_id)
if not account_id:
raise osv.except_osv(_('Error!'),
_('There is no Fiscal Position defined or Income category account defined for default properties of Product categories.'))
res = {
'name': line.name,
'sequence': line.sequence,
'origin': line.order_id.name,
'account_id': account_id,
'price_unit': pu,
'quantity': uosqty,
'discount': line.discount,
'uos_id': uos_id,
'product_id': line.product_id.id or False,
'invoice_line_tax_id': [(6, 0, [x.id for x in line.tax_id])],
'account_analytic_id': line.order_id.project_id and line.order_id.project_id.id or False,
}
return res
def invoice_line_create(self, cr, uid, ids, context=None):
if context is None:
context = {}
create_ids = []
sales = set()
for line in self.browse(cr, uid, ids, context=context):
vals = self._prepare_order_line_invoice_line(cr, uid, line, False, context)
if vals:
inv_id = self.pool.get('account.invoice.line').create(cr, uid, vals, context=context)
self.write(cr, uid, [line.id], {'invoice_lines': [(4, inv_id)]}, context=context)
sales.add(line.order_id.id)
create_ids.append(inv_id)
# Trigger workflow events
for sale_id in sales:
workflow.trg_write(uid, 'sale.order', sale_id, cr)
return create_ids
def button_cancel(self, cr, uid, ids, context=None):
for line in self.browse(cr, uid, ids, context=context):
if line.invoiced:
raise osv.except_osv(_('Invalid Action!'), _('You cannot cancel a sales order line that has already been invoiced.'))
return self.write(cr, uid, ids, {'state': 'cancel'})
def button_confirm(self, cr, uid, ids, context=None):
return self.write(cr, uid, ids, {'state': 'confirmed'})
def button_done(self, cr, uid, ids, context=None):
res = self.write(cr, uid, ids, {'state': 'done'})
for line in self.browse(cr, uid, ids, context=context):
workflow.trg_write(uid, 'sale.order', line.order_id.id, cr)
return res
def uos_change(self, cr, uid, ids, product_uos, product_uos_qty=0, product_id=None):
product_obj = self.pool.get('product.product')
if not product_id:
return {'value': {'product_uom': product_uos,
'product_uom_qty': product_uos_qty}, 'domain': {}}
product = product_obj.browse(cr, uid, product_id)
value = {
'product_uom': product.uom_id.id,
}
# FIXME must depend on uos/uom of the product and not only of the coeff.
try:
value.update({
'product_uom_qty': product_uos_qty / product.uos_coeff,
'th_weight': product_uos_qty / product.uos_coeff * product.weight
})
except ZeroDivisionError:
pass
return {'value': value}
def create(self, cr, uid, values, context=None):
if values.get('order_id') and values.get('product_id') and any(f not in values for f in ['name', 'price_unit', 'type', 'product_uom_qty', 'product_uom']):
order = self.pool['sale.order'].read(cr, uid, values['order_id'], ['pricelist_id', 'partner_id', 'date_order', 'fiscal_position'], context=context)
defaults = self.product_id_change(cr, uid, [], order['pricelist_id'][0], values['product_id'],
qty=float(values.get('product_uom_qty', False)),
uom=values.get('product_uom', False),
qty_uos=float(values.get('product_uos_qty', False)),
uos=values.get('product_uos', False),
name=values.get('name', False),
partner_id=order['partner_id'][0],
date_order=order['date_order'],
fiscal_position=order['fiscal_position'][0] if order['fiscal_position'] else False,
flag=False, # Force name update
context=context
)['value']
values = dict(defaults, **values)
return super(sale_order_line, self).create(cr, uid, values, context=context)
def product_id_change(self, cr, uid, ids, pricelist, product, qty=0,
uom=False, qty_uos=0, uos=False, name='', partner_id=False,
lang=False, update_tax=True, date_order=False, packaging=False, fiscal_position=False, flag=False, context=None):
context = context or {}
lang = lang or context.get('lang', False)
if not partner_id:
raise osv.except_osv(_('No Customer Defined!'), _('Before choosing a product,\n select a customer in the sales form.'))
warning = False
product_uom_obj = self.pool.get('product.uom')
partner_obj = self.pool.get('res.partner')
product_obj = self.pool.get('product.product')
context = {'lang': lang, 'partner_id': partner_id}
partner = partner_obj.browse(cr, uid, partner_id)
lang = partner.lang
context_partner = {'lang': lang, 'partner_id': partner_id}
if not product:
return {'value': {'th_weight': 0,
'product_uos_qty': qty}, 'domain': {'product_uom': [],
'product_uos': []}}
if not date_order:
date_order = time.strftime(DEFAULT_SERVER_DATE_FORMAT)
result = {}
warning_msgs = ''
product_obj = product_obj.browse(cr, uid, product, context=context_partner)
uom2 = False
if uom:
uom2 = product_uom_obj.browse(cr, uid, uom)
if product_obj.uom_id.category_id.id != uom2.category_id.id:
uom = False
if uos:
if product_obj.uos_id:
uos2 = product_uom_obj.browse(cr, uid, uos)
if product_obj.uos_id.category_id.id != uos2.category_id.id:
uos = False
else:
uos = False
fpos = False
if not fiscal_position:
fpos = partner.property_account_position or False
else:
fpos = self.pool.get('account.fiscal.position').browse(cr, uid, fiscal_position)
if update_tax: #The quantity only have changed
result['tax_id'] = self.pool.get('account.fiscal.position').map_tax(cr, uid, fpos, product_obj.taxes_id)
if not flag:
result['name'] = self.pool.get('product.product').name_get(cr, uid, [product_obj.id], context=context_partner)[0][1]
if product_obj.description_sale:
result['name'] += '\n'+product_obj.description_sale
domain = {}
if (not uom) and (not uos):
result['product_uom'] = product_obj.uom_id.id
if product_obj.uos_id:
result['product_uos'] = product_obj.uos_id.id
result['product_uos_qty'] = qty * product_obj.uos_coeff
uos_category_id = product_obj.uos_id.category_id.id
else:
result['product_uos'] = False
result['product_uos_qty'] = qty
uos_category_id = False
result['th_weight'] = qty * product_obj.weight
domain = {'product_uom':
[('category_id', '=', product_obj.uom_id.category_id.id)],
'product_uos':
[('category_id', '=', uos_category_id)]}
elif uos and not uom: # only happens if uom is False
result['product_uom'] = product_obj.uom_id and product_obj.uom_id.id
result['product_uom_qty'] = qty_uos / product_obj.uos_coeff
result['th_weight'] = result['product_uom_qty'] * product_obj.weight
elif uom: # whether uos is set or not
default_uom = product_obj.uom_id and product_obj.uom_id.id
q = product_uom_obj._compute_qty(cr, uid, uom, qty, default_uom)
if product_obj.uos_id:
result['product_uos'] = product_obj.uos_id.id
result['product_uos_qty'] = qty * product_obj.uos_coeff
else:
result['product_uos'] = False
result['product_uos_qty'] = qty
result['th_weight'] = q * product_obj.weight # Round the quantity up
if not uom2:
uom2 = product_obj.uom_id
# get unit price
if not pricelist:
warn_msg = _('You have to select a pricelist or a customer in the sales form !\n'
'Please set one before choosing a product.')
warning_msgs += _("No Pricelist ! : ") + warn_msg +"\n\n"
else:
price = self.pool.get('product.pricelist').price_get(cr, uid, [pricelist],
product, qty or 1.0, partner_id, {
'uom': uom or result.get('product_uom'),
'date': date_order,
})[pricelist]
if price is False:
warn_msg = _("Cannot find a pricelist line matching this product and quantity.\n"
"You have to change either the product, the quantity or the pricelist.")
warning_msgs += _("No valid pricelist line found ! :") + warn_msg +"\n\n"
else:
result.update({'price_unit': price})
if warning_msgs:
warning = {
'title': _('Configuration Error!'),
'message' : warning_msgs
}
return {'value': result, 'domain': domain, 'warning': warning}
def product_uom_change(self, cursor, user, ids, pricelist, product, qty=0,
uom=False, qty_uos=0, uos=False, name='', partner_id=False,
lang=False, update_tax=True, date_order=False, context=None):
context = context or {}
lang = lang or ('lang' in context and context['lang'])
if not uom:
return {'value': {'price_unit': 0.0, 'product_uom' : uom or False}}
return self.product_id_change(cursor, user, ids, pricelist, product,
qty=qty, uom=uom, qty_uos=qty_uos, uos=uos, name=name,
partner_id=partner_id, lang=lang, update_tax=update_tax,
date_order=date_order, context=context)
def unlink(self, cr, uid, ids, context=None):
if context is None:
context = {}
"""Allows to delete sales order lines in draft,cancel states"""
for rec in self.browse(cr, uid, ids, context=context):
if rec.state not in ['draft', 'cancel']:
raise osv.except_osv(_('Invalid Action!'), _('Cannot delete a sales order line which is in state \'%s\'.') %(rec.state,))
return super(sale_order_line, self).unlink(cr, uid, ids, context=context)
class res_company(osv.Model):
_inherit = "res.company"
_columns = {
'sale_note': fields.text('Default Terms and Conditions', translate=True, help="Default terms and conditions for quotations."),
}
class mail_compose_message(osv.Model):
_inherit = 'mail.compose.message'
def send_mail(self, cr, uid, ids, context=None):
context = context or {}
if context.get('default_model') == 'sale.order' and context.get('default_res_id') and context.get('mark_so_as_sent'):
context = dict(context, mail_post_autofollow=True)
self.pool.get('sale.order').signal_workflow(cr, uid, [context['default_res_id']], 'quotation_sent')
return super(mail_compose_message, self).send_mail(cr, uid, ids, context=context)
class account_invoice(osv.Model):
_inherit = 'account.invoice'
def _get_default_section_id(self, cr, uid, context=None):
""" Gives default section by checking if present in the context """
section_id = self._resolve_section_id_from_context(cr, uid, context=context) or False
if not section_id:
section_id = self.pool.get('res.users').browse(cr, uid, uid, context).default_section_id.id or False
return section_id
def _resolve_section_id_from_context(self, cr, uid, context=None):
""" Returns ID of section based on the value of 'section_id'
context key, or None if it cannot be resolved to a single
Sales Team.
"""
if context is None:
context = {}
if type(context.get('default_section_id')) in (int, long):
return context.get('default_section_id')
if isinstance(context.get('default_section_id'), basestring):
section_ids = self.pool.get('crm.case.section').name_search(cr, uid, name=context['default_section_id'], context=context)
if len(section_ids) == 1:
return int(section_ids[0][0])
return None
_columns = {
'section_id': fields.many2one('crm.case.section', 'Sales Team'),
}
_defaults = {
'section_id': lambda self, cr, uid, c=None: self._get_default_section_id(cr, uid, context=c)
}
def confirm_paid(self, cr, uid, ids, context=None):
sale_order_obj = self.pool.get('sale.order')
res = super(account_invoice, self).confirm_paid(cr, uid, ids, context=context)
so_ids = sale_order_obj.search(cr, uid, [('invoice_ids', 'in', ids)], context=context)
for so_id in so_ids:
sale_order_obj.message_post(cr, uid, so_id, body=_("Invoice paid"), context=context)
return res
def unlink(self, cr, uid, ids, context=None):
""" Overwrite unlink method of account invoice to send a trigger to the sale workflow upon invoice deletion """
invoice_ids = self.search(cr, uid, [('id', 'in', ids), ('state', 'in', ['draft', 'cancel'])], context=context)
#if we can't cancel all invoices, do nothing
if len(invoice_ids) == len(ids):
#Cancel invoice(s) first before deleting them so that if any sale order is associated with them
#it will trigger the workflow to put the sale order in an 'invoice exception' state
for id in ids:
workflow.trg_validate(uid, 'account.invoice', id, 'invoice_cancel', cr)
return super(account_invoice, self).unlink(cr, uid, ids, context=context)
class procurement_order(osv.osv):
_inherit = 'procurement.order'
_columns = {
'sale_line_id': fields.many2one('sale.order.line', string='Sale Order Line'),
}
class product_product(osv.Model):
_inherit = 'product.product'
def _sales_count(self, cr, uid, ids, field_name, arg, context=None):
SaleOrderLine = self.pool['sale.order.line']
return {
product_id: SaleOrderLine.search_count(cr,uid, [('product_id', '=', product_id)], context=context)
for product_id in ids
}
_columns = {
'sales_count': fields.function(_sales_count, string='# Sales', type='integer'),
}
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
agpl-3.0
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
4605,
199,
3,
199,
3,
259,
7653,
12,
3232,
5800,
8259,
9274,
199,
3,
259,
1898,
334,
35,
9,
8353,
13,
6542,
11947,
12361,
8642,
1014,
921,
9864,
14,
1235,
10121,
199,
3,
199,
3,
259,
961,
2240,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
259,
652,
1334,
314,
2895,
402,
314,
1664,
4265,
1696,
1684,
844,
465,
199,
3,
259,
3267,
701,
314,
2868,
2290,
2752,
12,
1902,
1015,
650,
402,
314,
199,
3,
259,
844,
12,
503,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
259,
961,
2240,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
259,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
259,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
199,
3,
259,
1664,
4265,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
259,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
4265,
1696,
1684,
844,
199,
3,
259,
3180,
543,
642,
2240,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
3,
199,
4605,
199,
199,
504,
2197,
492,
2197,
12,
6871,
199,
646,
900,
199,
504,
5166,
14,
4795,
492,
1504,
12,
9506,
199,
504,
5166,
14,
2537,
14,
5275,
492,
485,
199,
504,
5166,
14,
2537,
492,
6186,
63,
6613,
63,
5390,
63,
4807,
12,
6186,
63,
6613,
63,
12488,
63,
4807,
199,
646,
5166,
14,
10788,
14,
6355,
63,
6833,
465,
12392,
199,
504,
5166,
492,
10431,
199,
199,
533,
13590,
63,
1648,
8,
4795,
14,
4795,
304,
272,
485,
354,
275,
298,
8515,
14,
1648,
2,
272,
485,
6486,
275,
788,
1198,
14,
2671,
297,
283,
723,
14,
9321,
1287,
63,
20406,
418,
272,
485,
1802,
275,
298,
18220,
9240,
2,
272,
485,
3885,
275,
469,
267,
283,
929,
356,
469,
288,
283,
8515,
14,
2037,
63,
1648,
63,
16391,
356,
2400,
291,
12,
2467,
12,
1747,
12,
1559,
12,
4027,
29,
403,
26,
1559,
14,
929,
315,
788,
9285,
995,
288,
283,
8515,
14,
2037,
63,
1648,
63,
1150,
356,
2400,
291,
12,
2467,
12,
1747,
12,
1559,
12,
4027,
29,
403,
26,
1559,
14,
929,
315,
788,
1150,
418,
267,
1660,
272,
789,
339,
347,
485,
4606,
63,
604,
63,
5530,
8,
277,
12,
2467,
12,
1747,
12,
1004,
12,
1067,
29,
403,
304,
267,
1139,
275,
378,
14,
16,
267,
367,
286,
315,
291,
14,
2293,
14,
362,
360,
2048,
14,
5530,
1959,
3357,
63,
452,
8,
1556,
12,
1747,
12,
1004,
14,
5530,
63,
344,
12,
1004,
14,
4777,
63,
3248,
627,
334,
17,
15426,
604,
14,
15446,
503,
378,
14,
16,
2447,
1960,
14,
16,
395,
1004,
14,
2558,
63,
7519,
63,
5643,
12,
1004,
14,
2558,
63,
344,
12,
1004,
14,
1648,
63,
344,
14,
3899,
63,
344,
11820,
22272,
2565,
288,
1139,
847,
286,
14,
362,
360,
4606,
297,
378,
14,
16,
9,
267,
372,
1139,
339,
347,
485,
4606,
63,
452,
63,
5029,
8,
277,
12,
2467,
12,
1747,
12,
2762,
12,
901,
63,
354,
12,
1680,
12,
1067,
29,
403,
304,
267,
408,
21947,
2952,
402,
4125,
1083,
9476,
465,
2725,
367,
805,
1504,
408,
267,
372,
291,
423,
4606,
63,
452,
8,
1556,
12,
1747,
12,
2762,
12,
901,
63,
354,
12,
1680,
12,
1067,
29,
1100,
9,
339,
347,
485,
4606,
63,
452,
8,
277,
12,
2467,
12,
1747,
12,
2762,
12,
901,
63,
354,
12,
1680,
12,
1067,
29,
403,
304,
267,
1094,
63,
1113,
275,
291,
14,
2293,
14,
362,
360,
470,
14,
4968,
358,
267,
522,
275,
1052,
267,
367,
1865,
315,
291,
14,
4570,
8,
1556,
12,
1747,
12,
2762,
12,
1067,
29,
1100,
304,
288,
522,
59,
1648,
14,
344,
61,
275,
469,
355,
283,
4606,
63,
324,
5530,
379,
356,
378,
14,
16,
12,
355,
283,
4606,
63,
5530,
356,
378,
14,
16,
12,
355,
283,
4606,
63,
2923,
356,
378,
14,
16,
12,
288,
789,
288,
1139,
275,
1139,
17,
275,
378,
14,
16,
288,
1094,
275,
1865,
14,
17385,
63,
344,
14,
4968,
63,
344,
288,
367,
1004,
315,
1865,
14,
1648,
63,
604,
26,
355,
1139,
17,
847,
1004,
14,
4777,
63,
954,
2923,
355,
1139,
847,
291,
423,
4606,
63,
604,
63,
5530,
8,
1556,
12,
1747,
12,
1004,
12,
1067,
29,
1100,
9,
288,
522,
59,
1648,
14,
344,
2733,
4606,
63,
5530,
418,
275,
1094,
63,
1113,
14,
2363,
8,
1556,
12,
1747,
12,
1094,
12,
1139,
9,
288,
522,
59,
1648,
14,
344,
2733,
4606,
63,
324,
5530,
379,
418,
275,
1094,
63,
1113,
14,
2363,
8,
1556,
12,
1747,
12,
1094,
12,
1139,
17,
9,
288,
522,
59,
1648,
14,
344,
2733,
4606,
63,
2923,
418,
275,
522,
59,
1648,
14,
344,
2733,
4606,
63,
324,
5530,
379,
418,
435,
522,
59,
1648,
14,
344,
2733,
4606,
63,
5530,
418,
267,
372,
522,
2378,
347,
485,
25614,
63,
1866,
8,
277,
12,
3920,
12,
922,
12,
2762,
12,
536,
12,
1680,
12,
1067,
29,
403,
304,
267,
522,
275,
1052,
267,
367,
13590,
315,
291,
14,
4570,
8,
3937,
12,
922,
12,
2762,
12,
1067,
29,
1100,
304,
288,
340,
13590,
14,
25614,
26,
355,
522,
59,
8515,
14,
344,
61,
275,
2948,
14,
16,
355,
1980,
288,
12657,
275,
378,
14,
16,
288,
367,
8485,
315,
13590,
14,
5404,
63,
1580,
26,
355,
340,
8485,
14,
929,
440,
315,
661,
7185,
297,
283,
6406,
735,
490,
12657,
847,
8485,
14,
4606,
63,
324,
5530,
379,
288,
340,
12657,
26,
355,
522,
59,
8515,
14,
344,
61,
275,
1748,
8,
1960,
14,
16,
12,
12657,
627,
2948,
14,
16,
1182,
334,
8515,
14,
4606,
63,
324,
5530,
379,
503,
413,
14,
383,
430,
288,
587,
26,
355,
522,
59,
8515,
14,
344,
61,
275,
378,
14,
16,
267,
372,
522,
339,
347,
485,
5404,
63,
2444,
8,
277,
12,
3920,
12,
922,
12,
2762,
12,
536,
12,
1680,
12,
1067,
29,
403,
304,
267,
522,
275,
1052,
267,
367,
13590,
315
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
4605,
199,
3,
199,
3,
259,
7653,
12,
3232,
5800,
8259,
9274,
199,
3,
259,
1898,
334,
35,
9,
8353,
13,
6542,
11947,
12361,
8642,
1014,
921,
9864,
14,
1235,
10121,
199,
3,
199,
3,
259,
961,
2240,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
259,
652,
1334,
314,
2895,
402,
314,
1664,
4265,
1696,
1684,
844,
465,
199,
3,
259,
3267,
701,
314,
2868,
2290,
2752,
12,
1902,
1015,
650,
402,
314,
199,
3,
259,
844,
12,
503,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
259,
961,
2240,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
259,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
259,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
199,
3,
259,
1664,
4265,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
259,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
4265,
1696,
1684,
844,
199,
3,
259,
3180,
543,
642,
2240,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
3,
199,
4605,
199,
199,
504,
2197,
492,
2197,
12,
6871,
199,
646,
900,
199,
504,
5166,
14,
4795,
492,
1504,
12,
9506,
199,
504,
5166,
14,
2537,
14,
5275,
492,
485,
199,
504,
5166,
14,
2537,
492,
6186,
63,
6613,
63,
5390,
63,
4807,
12,
6186,
63,
6613,
63,
12488,
63,
4807,
199,
646,
5166,
14,
10788,
14,
6355,
63,
6833,
465,
12392,
199,
504,
5166,
492,
10431,
199,
199,
533,
13590,
63,
1648,
8,
4795,
14,
4795,
304,
272,
485,
354,
275,
298,
8515,
14,
1648,
2,
272,
485,
6486,
275,
788,
1198,
14,
2671,
297,
283,
723,
14,
9321,
1287,
63,
20406,
418,
272,
485,
1802,
275,
298,
18220,
9240,
2,
272,
485,
3885,
275,
469,
267,
283,
929,
356,
469,
288,
283,
8515,
14,
2037,
63,
1648,
63,
16391,
356,
2400,
291,
12,
2467,
12,
1747,
12,
1559,
12,
4027,
29,
403,
26,
1559,
14,
929,
315,
788,
9285,
995,
288,
283,
8515,
14,
2037,
63,
1648,
63,
1150,
356,
2400,
291,
12,
2467,
12,
1747,
12,
1559,
12,
4027,
29,
403,
26,
1559,
14,
929,
315,
788,
1150,
418,
267,
1660,
272,
789,
339,
347,
485,
4606,
63,
604,
63,
5530,
8,
277,
12,
2467,
12,
1747,
12,
1004,
12,
1067,
29,
403,
304,
267,
1139,
275,
378,
14,
16,
267,
367,
286,
315,
291,
14,
2293,
14,
362,
360,
2048,
14,
5530,
1959,
3357,
63,
452,
8,
1556,
12,
1747,
12,
1004,
14,
5530,
63,
344,
12,
1004,
14,
4777,
63,
3248,
627,
334,
17,
15426,
604,
14,
15446,
503,
378,
14,
16,
2447,
1960,
14,
16,
395,
1004,
14,
2558,
63,
7519,
63,
5643,
12,
1004,
14,
2558,
63,
344,
12,
1004,
14,
1648,
63,
344,
14,
3899,
63,
344,
11820,
22272,
2565,
288,
1139,
847,
286,
14,
362,
360,
4606,
297,
378,
14,
16,
9,
267,
372,
1139,
339,
347,
485,
4606,
63,
452,
63,
5029,
8,
277,
12,
2467,
12,
1747,
12,
2762,
12,
901,
63,
354,
12,
1680,
12,
1067,
29,
403,
304,
267,
408,
21947,
2952,
402,
4125,
1083,
9476,
465,
2725,
367,
805,
1504,
408,
267,
372,
291,
423,
4606,
63,
452,
8,
1556,
12,
1747,
12,
2762,
12,
901,
63,
354,
12,
1680,
12,
1067,
29,
1100,
9,
339,
347,
485,
4606,
63,
452,
8,
277,
12,
2467,
12,
1747,
12,
2762,
12,
901,
63,
354,
12,
1680,
12,
1067,
29,
403,
304,
267,
1094,
63,
1113,
275,
291,
14,
2293,
14,
362,
360,
470,
14,
4968,
358,
267,
522,
275,
1052,
267,
367,
1865,
315,
291,
14,
4570,
8,
1556,
12,
1747,
12,
2762,
12,
1067,
29,
1100,
304,
288,
522,
59,
1648,
14,
344,
61,
275,
469,
355,
283,
4606,
63,
324,
5530,
379,
356,
378,
14,
16,
12,
355,
283,
4606,
63,
5530,
356,
378,
14,
16,
12,
355,
283,
4606,
63,
2923,
356,
378,
14,
16,
12,
288,
789,
288,
1139,
275,
1139,
17,
275,
378,
14,
16,
288,
1094,
275,
1865,
14,
17385,
63,
344,
14,
4968,
63,
344,
288,
367,
1004,
315,
1865,
14,
1648,
63,
604,
26,
355,
1139,
17,
847,
1004,
14,
4777,
63,
954,
2923,
355,
1139,
847,
291,
423,
4606,
63,
604,
63,
5530,
8,
1556,
12,
1747,
12,
1004,
12,
1067,
29,
1100,
9,
288,
522,
59,
1648,
14,
344,
2733,
4606,
63,
5530,
418,
275,
1094,
63,
1113,
14,
2363,
8,
1556,
12,
1747,
12,
1094,
12,
1139,
9,
288,
522,
59,
1648,
14,
344,
2733,
4606,
63,
324,
5530,
379,
418,
275,
1094,
63,
1113,
14,
2363,
8,
1556,
12,
1747,
12,
1094,
12,
1139,
17,
9,
288,
522,
59,
1648,
14,
344,
2733,
4606,
63,
2923,
418,
275,
522,
59,
1648,
14,
344,
2733,
4606,
63,
324,
5530,
379,
418,
435,
522,
59,
1648,
14,
344,
2733,
4606,
63,
5530,
418,
267,
372,
522,
2378,
347,
485,
25614,
63,
1866,
8,
277,
12,
3920,
12,
922,
12,
2762,
12,
536,
12,
1680,
12,
1067,
29,
403,
304,
267,
522,
275,
1052,
267,
367,
13590,
315,
291,
14,
4570,
8,
3937,
12,
922,
12,
2762,
12,
1067,
29,
1100,
304,
288,
340,
13590,
14,
25614,
26,
355,
522,
59,
8515,
14,
344,
61,
275,
2948,
14,
16,
355,
1980,
288,
12657,
275,
378,
14,
16,
288,
367,
8485,
315,
13590,
14,
5404,
63,
1580,
26,
355,
340,
8485,
14,
929,
440,
315,
661,
7185,
297,
283,
6406,
735,
490,
12657,
847,
8485,
14,
4606,
63,
324,
5530,
379,
288,
340,
12657,
26,
355,
522,
59,
8515,
14,
344,
61,
275,
1748,
8,
1960,
14,
16,
12,
12657,
627,
2948,
14,
16,
1182,
334,
8515,
14,
4606,
63,
324,
5530,
379,
503,
413,
14,
383,
430,
288,
587,
26,
355,
522,
59,
8515,
14,
344,
61,
275,
378,
14,
16,
267,
372,
522,
339,
347,
485,
5404,
63,
2444,
8,
277,
12,
3920,
12,
922,
12,
2762,
12,
536,
12,
1680,
12,
1067,
29,
403,
304,
267,
522,
275,
1052,
267,
367,
13590,
315,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
ganeshnalawade/ansible
|
lib/ansible/utils/lock.py
|
31
|
1390
|
# Copyright (c) 2020 Matt Martz <matt@sivel.net>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# Make coding more python3-ish
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
from functools import wraps
def lock_decorator(attr='missing_lock_attr', lock=None):
'''This decorator is a generic implementation that allows you
to either use a pre-defined instance attribute as the location
of the lock, or to explicitly pass a lock object.
This code was implemented with ``threading.Lock`` in mind, but
may work with other locks, assuming that they function as
context managers.
When using ``attr``, the assumption is the first argument to
the wrapped method, is ``self`` or ``cls``.
Examples:
@lock_decorator(attr='_callback_lock')
def send_callback(...):
@lock_decorator(lock=threading.Lock())
def some_method(...):
'''
def outer(func):
@wraps(func)
def inner(*args, **kwargs):
# Python2 doesn't have ``nonlocal``
# assign the actual lock to ``_lock``
if lock is None:
_lock = getattr(args[0], attr)
else:
_lock = lock
with _lock:
return func(*args, **kwargs)
return inner
return outer
|
gpl-3.0
|
[
3,
1898,
334,
67,
9,
25455,
31653,
603,
28124,
665,
569,
84,
32,
338,
1090,
14,
846,
30,
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,
3,
4155,
2803,
1655,
2366,
19,
13,
2453,
199,
504,
636,
2443,
363,
492,
334,
6116,
63,
646,
12,
4629,
12,
870,
63,
1593,
9,
199,
363,
6577,
363,
275,
730,
199,
199,
504,
9143,
492,
14018,
421,
199,
318,
4650,
63,
11547,
8,
962,
534,
4752,
63,
831,
63,
962,
297,
4650,
29,
403,
304,
272,
1449,
2765,
7531,
365,
282,
7809,
4514,
626,
6127,
1265,
272,
370,
1902,
675,
282,
876,
13,
4037,
1256,
2225,
465,
314,
2909,
272,
402,
314,
4650,
12,
503,
370,
7662,
986,
282,
4650,
909,
14,
339,
961,
1233,
1990,
6366,
543,
1124,
12562,
14,
6432,
1040,
315,
25169,
12,
1325,
272,
1443,
1736,
543,
1163,
23340,
12,
18002,
626,
2985,
805,
465,
272,
1067,
19680,
14,
339,
3979,
1808,
1124,
962,
4542,
314,
30075,
365,
314,
1642,
1423,
370,
272,
314,
8072,
1083,
12,
365,
1124,
277,
1040,
503,
1124,
1886,
4345,
339,
6058,
26,
398,
768,
831,
63,
11547,
8,
962,
17574,
3058,
63,
831,
358,
267,
347,
3222,
63,
3058,
29195,
304,
398,
768,
831,
63,
11547,
8,
831,
29,
12562,
14,
6432,
1012,
267,
347,
2005,
63,
765,
29195,
304,
272,
1449,
272,
347,
6890,
8,
1532,
304,
267,
768,
13582,
8,
1532,
9,
267,
347,
6506,
2031,
589,
12,
1011,
958,
304,
288,
327,
2018,
18,
3181,
1133,
1172,
1124,
2865,
1832,
1040,
288,
327,
5090,
314,
3503,
4650,
370,
24507,
831,
1040,
288,
340,
4650,
365,
488,
26,
355,
485,
831,
275,
2519,
8,
589,
59,
16,
467,
1921,
9,
288,
587,
26,
355,
485,
831,
275,
4650,
288,
543,
485,
831,
26,
355,
372,
2562,
2031,
589,
12,
1011,
958,
9,
267,
372,
6506,
272,
372,
6890,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,
25455,
31653,
603,
28124,
665,
569,
84,
32,
338,
1090,
14,
846,
30,
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,
3,
4155,
2803,
1655,
2366,
19,
13,
2453,
199,
504,
636,
2443,
363,
492,
334,
6116,
63,
646,
12,
4629,
12,
870,
63,
1593,
9,
199,
363,
6577,
363,
275,
730,
199,
199,
504,
9143,
492,
14018,
421,
199,
318,
4650,
63,
11547,
8,
962,
534,
4752,
63,
831,
63,
962,
297,
4650,
29,
403,
304,
272,
1449,
2765,
7531,
365,
282,
7809,
4514,
626,
6127,
1265,
272,
370,
1902,
675,
282,
876,
13,
4037,
1256,
2225,
465,
314,
2909,
272,
402,
314,
4650,
12,
503,
370,
7662,
986,
282,
4650,
909,
14,
339,
961,
1233,
1990,
6366,
543,
1124,
12562,
14,
6432,
1040,
315,
25169,
12,
1325,
272,
1443,
1736,
543,
1163,
23340,
12,
18002,
626,
2985,
805,
465,
272,
1067,
19680,
14,
339,
3979,
1808,
1124,
962,
4542,
314,
30075,
365,
314,
1642,
1423,
370,
272,
314,
8072,
1083,
12,
365,
1124,
277,
1040,
503,
1124,
1886,
4345,
339,
6058,
26,
398,
768,
831,
63,
11547,
8,
962,
17574,
3058,
63,
831,
358,
267,
347,
3222,
63,
3058,
29195,
304,
398,
768,
831,
63,
11547,
8,
831,
29,
12562,
14,
6432,
1012,
267,
347,
2005,
63,
765,
29195,
304,
272,
1449,
272,
347,
6890,
8,
1532,
304,
267,
768,
13582,
8,
1532,
9,
267,
347,
6506,
2031,
589,
12,
1011,
958,
304,
288,
327,
2018,
18,
3181,
1133,
1172,
1124,
2865,
1832,
1040,
288,
327,
5090,
314,
3503,
4650,
370,
24507,
831,
1040,
288,
340,
4650,
365,
488,
26,
355,
485,
831,
275,
2519,
8,
589,
59,
16,
467,
1921,
9,
288,
587,
26,
355,
485,
831,
275,
4650,
288,
543,
485,
831,
26,
355,
372,
2562,
2031,
589,
12,
1011,
958,
9,
267,
372,
6506,
272,
372,
6890,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,
0
] |
SteveHNH/ansible
|
lib/ansible/compat/tests/__init__.py
|
128
|
1267
|
# (c) 2014, Toshio Kuratomi <tkuratomi@ansible.com>
#
# This file is part of Ansible
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
# Make coding more python3-ish
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
'''
This module contains things that are only needed for compat in the testsuites,
not in ansible itself. If you are not installing the test suite, you can
safely remove this subdirectory.
'''
#
# Compat for python2.7
#
# One unittest needs to import builtins via __import__() so we need to have
# the string that represents it
try:
import __builtin__
except ImportError:
BUILTINS = 'builtins'
else:
BUILTINS = '__builtin__'
|
gpl-3.0
|
[
3,
334,
67,
9,
6927,
12,
4005,
609,
2308,
1804,
300,
4188,
73,
665,
2663,
300,
4188,
73,
32,
4853,
14,
957,
30,
199,
3,
199,
3,
961,
570,
365,
1777,
402,
2622,
199,
3,
199,
3,
2622,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
652,
1334,
314,
2895,
402,
314,
1664,
1696,
1684,
844,
465,
3267,
701,
199,
3,
314,
2868,
2290,
2752,
12,
1902,
1015,
650,
402,
314,
844,
12,
503,
199,
3,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
2622,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
199,
3,
1664,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
1696,
1684,
844,
199,
3,
3180,
543,
2622,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
199,
3,
4155,
2803,
1655,
2366,
19,
13,
2453,
199,
504,
636,
2443,
363,
492,
334,
6116,
63,
646,
12,
4629,
12,
870,
63,
1593,
9,
199,
363,
6577,
363,
275,
730,
199,
199,
2344,
199,
2765,
859,
3509,
7645,
626,
787,
1454,
4346,
367,
8434,
315,
314,
2295,
11650,
12,
199,
1397,
315,
3242,
6337,
14,
221,
982,
1265,
787,
440,
22200,
314,
511,
5241,
12,
1265,
883,
199,
2231,
70,
7742,
2813,
642,
25094,
14,
199,
2344,
199,
199,
3,
199,
3,
3599,
292,
367,
2366,
18,
14,
23,
199,
3,
199,
199,
3,
7309,
2882,
4839,
370,
492,
12963,
4799,
636,
646,
4533,
880,
781,
1929,
370,
1172,
199,
3,
314,
1059,
626,
8469,
652,
199,
893,
26,
272,
492,
636,
5351,
363,
199,
2590,
3545,
26,
272,
16331,
1193,
52,
10789,
275,
283,
10372,
7,
199,
2836,
26,
272,
16331,
1193,
52,
10789,
275,
2560,
5351,
12217,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
334,
67,
9,
6927,
12,
4005,
609,
2308,
1804,
300,
4188,
73,
665,
2663,
300,
4188,
73,
32,
4853,
14,
957,
30,
199,
3,
199,
3,
961,
570,
365,
1777,
402,
2622,
199,
3,
199,
3,
2622,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
652,
1334,
314,
2895,
402,
314,
1664,
1696,
1684,
844,
465,
3267,
701,
199,
3,
314,
2868,
2290,
2752,
12,
1902,
1015,
650,
402,
314,
844,
12,
503,
199,
3,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
2622,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
199,
3,
1664,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
1696,
1684,
844,
199,
3,
3180,
543,
2622,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
199,
3,
4155,
2803,
1655,
2366,
19,
13,
2453,
199,
504,
636,
2443,
363,
492,
334,
6116,
63,
646,
12,
4629,
12,
870,
63,
1593,
9,
199,
363,
6577,
363,
275,
730,
199,
199,
2344,
199,
2765,
859,
3509,
7645,
626,
787,
1454,
4346,
367,
8434,
315,
314,
2295,
11650,
12,
199,
1397,
315,
3242,
6337,
14,
221,
982,
1265,
787,
440,
22200,
314,
511,
5241,
12,
1265,
883,
199,
2231,
70,
7742,
2813,
642,
25094,
14,
199,
2344,
199,
199,
3,
199,
3,
3599,
292,
367,
2366,
18,
14,
23,
199,
3,
199,
199,
3,
7309,
2882,
4839,
370,
492,
12963,
4799,
636,
646,
4533,
880,
781,
1929,
370,
1172,
199,
3,
314,
1059,
626,
8469,
652,
199,
893,
26,
272,
492,
636,
5351,
363,
199,
2590,
3545,
26,
272,
16331,
1193,
52,
10789,
275,
283,
10372,
7,
199,
2836,
26,
272,
16331,
1193,
52,
10789,
275,
2560,
5351,
12217,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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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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
] |
ojengwa/oh-mainline
|
vendor/packages/python-social-auth/social/tests/actions/test_login.py
|
79
|
2639
|
from social.tests.models import User
from social.tests.actions.actions import BaseActionTest
class LoginActionTest(BaseActionTest):
def test_login(self):
self.do_login()
def test_login_with_partial_pipeline(self):
self.do_login_with_partial_pipeline()
def test_fields_stored_in_session(self):
self.strategy.set_settings({
'SOCIAL_AUTH_FIELDS_STORED_IN_SESSION': ['foo', 'bar']
})
self.strategy.set_request_data({'foo': '1', 'bar': '2'}, self.backend)
self.do_login()
self.assertEqual(self.strategy.session_get('foo'), '1')
self.assertEqual(self.strategy.session_get('bar'), '2')
def test_redirect_value(self):
self.strategy.set_request_data({'next': '/after-login'}, self.backend)
redirect = self.do_login(after_complete_checks=False)
self.assertEqual(redirect.url, '/after-login')
def test_login_with_invalid_partial_pipeline(self):
def before_complete():
partial = self.strategy.session_get('partial_pipeline')
partial['backend'] = 'foobar'
self.strategy.session_set('partial_pipeline', partial)
self.do_login_with_partial_pipeline(before_complete)
def test_new_user(self):
self.strategy.set_settings({
'SOCIAL_AUTH_NEW_USER_REDIRECT_URL': '/new-user'
})
redirect = self.do_login(after_complete_checks=False)
self.assertEqual(redirect.url, '/new-user')
def test_inactive_user(self):
self.strategy.set_settings({
'SOCIAL_AUTH_INACTIVE_USER_URL': '/inactive'
})
User.set_active(False)
redirect = self.do_login(after_complete_checks=False)
self.assertEqual(redirect.url, '/inactive')
def test_invalid_user(self):
self.strategy.set_settings({
'SOCIAL_AUTH_LOGIN_ERROR_URL': '/error',
'SOCIAL_AUTH_PIPELINE': (
'social.pipeline.social_auth.social_details',
'social.pipeline.social_auth.social_uid',
'social.pipeline.social_auth.auth_allowed',
'social.pipeline.social_auth.social_user',
'social.pipeline.user.get_username',
'social.pipeline.user.create_user',
'social.pipeline.social_auth.associate_user',
'social.pipeline.social_auth.load_extra_data',
'social.pipeline.user.user_details',
'social.tests.pipeline.remove_user'
)
})
redirect = self.do_login(after_complete_checks=False)
self.assertEqual(redirect.url, '/error')
|
agpl-3.0
|
[
504,
20295,
14,
2219,
14,
992,
492,
2876,
199,
504,
20295,
14,
2219,
14,
3723,
14,
3723,
492,
3523,
3310,
774,
421,
199,
533,
16430,
3310,
774,
8,
1563,
3310,
774,
304,
272,
347,
511,
63,
2886,
8,
277,
304,
267,
291,
14,
1117,
63,
2886,
342,
339,
347,
511,
63,
2886,
63,
1045,
63,
6672,
63,
7379,
8,
277,
304,
267,
291,
14,
1117,
63,
2886,
63,
1045,
63,
6672,
63,
7379,
342,
339,
347,
511,
63,
955,
63,
16431,
63,
262,
63,
1730,
8,
277,
304,
267,
291,
14,
8590,
14,
409,
63,
1751,
2561,
288,
283,
4118,
21212,
63,
5580,
63,
12767,
63,
29456,
63,
568,
63,
12763,
356,
788,
1421,
297,
283,
1700,
418,
267,
3828,
267,
291,
14,
8590,
14,
409,
63,
1069,
63,
576,
3252,
1421,
356,
283,
17,
297,
283,
1700,
356,
283,
18,
2267,
291,
14,
4620,
9,
267,
291,
14,
1117,
63,
2886,
342,
267,
291,
14,
629,
8,
277,
14,
8590,
14,
1730,
63,
362,
360,
1421,
659,
283,
17,
358,
267,
291,
14,
629,
8,
277,
14,
8590,
14,
1730,
63,
362,
360,
1700,
659,
283,
18,
358,
339,
347,
511,
63,
4876,
63,
585,
8,
277,
304,
267,
291,
14,
8590,
14,
409,
63,
1069,
63,
576,
3252,
2184,
356,
1994,
4399,
13,
2886,
2267,
291,
14,
4620,
9,
267,
4660,
275,
291,
14,
1117,
63,
2886,
8,
4399,
63,
4883,
63,
8625,
29,
797,
9,
267,
291,
14,
629,
8,
4876,
14,
633,
12,
1994,
4399,
13,
2886,
358,
339,
347,
511,
63,
2886,
63,
1045,
63,
3197,
63,
6672,
63,
7379,
8,
277,
304,
267,
347,
2544,
63,
4883,
837,
288,
7417,
275,
291,
14,
8590,
14,
1730,
63,
362,
360,
6672,
63,
7379,
358,
288,
7417,
459,
4620,
418,
275,
283,
9664,
7,
288,
291,
14,
8590,
14,
1730,
63,
409,
360,
6672,
63,
7379,
297,
7417,
9,
267,
291,
14,
1117,
63,
2886,
63,
1045,
63,
6672,
63,
7379,
8,
5182,
63,
4883,
9,
339,
347,
511,
63,
1222,
63,
751,
8,
277,
304,
267,
291,
14,
8590,
14,
409,
63,
1751,
2561,
288,
283,
4118,
21212,
63,
5580,
63,
11365,
63,
3791,
63,
19747,
63,
2632,
356,
1994,
1222,
13,
751,
7,
267,
3828,
267,
4660,
275,
291,
14,
1117,
63,
2886,
8,
4399,
63,
4883,
63,
8625,
29,
797,
9,
267,
291,
14,
629,
8,
4876,
14,
633,
12,
1994,
1222,
13,
751,
358,
339,
347,
511,
63,
16856,
63,
751,
8,
277,
304,
267,
291,
14,
8590,
14,
409,
63,
1751,
2561,
288,
283,
4118,
21212,
63,
5580,
63,
568,
10401,
63,
3791,
63,
2632,
356,
1994,
16856,
7,
267,
3828,
267,
2876,
14,
409,
63,
2682,
8,
797,
9,
267,
4660,
275,
291,
14,
1117,
63,
2886,
8,
4399,
63,
4883,
63,
8625,
29,
797,
9,
267,
291,
14,
629,
8,
4876,
14,
633,
12,
1994,
16856,
358,
339,
347,
511,
63,
3197,
63,
751,
8,
277,
304,
267,
291,
14,
8590,
14,
409,
63,
1751,
2561,
288,
283,
4118,
21212,
63,
5580,
63,
17208,
63,
3170,
63,
2632,
356,
1994,
705,
297,
288,
283,
4118,
21212,
63,
5580,
63,
6089,
6174,
356,
334,
355,
283,
13574,
14,
7379,
14,
13574,
63,
1178,
14,
13574,
63,
5087,
297,
355,
283,
13574,
14,
7379,
14,
13574,
63,
1178,
14,
13574,
63,
1535,
297,
355,
283,
13574,
14,
7379,
14,
13574,
63,
1178,
14,
1178,
63,
6541,
297,
355,
283,
13574,
14,
7379,
14,
13574,
63,
1178,
14,
13574,
63,
751,
297,
355,
283,
13574,
14,
7379,
14,
751,
14,
362,
63,
2473,
297,
355,
283,
13574,
14,
7379,
14,
751,
14,
981,
63,
751,
297,
355,
283,
13574,
14,
7379,
14,
13574,
63,
1178,
14,
16021,
63,
751,
297,
355,
283,
13574,
14,
7379,
14,
13574,
63,
1178,
14,
912,
63,
2911,
63,
576,
297,
355,
283,
13574,
14,
7379,
14,
751,
14,
751,
63,
5087,
297,
355,
283,
13574,
14,
2219,
14,
7379,
14,
2168,
63,
751,
7,
288,
776,
267,
3828,
267,
4660,
275,
291,
14,
1117,
63,
2886,
8,
4399,
63,
4883,
63,
8625,
29,
797,
9,
267,
291,
14,
629,
8,
4876,
14,
633,
12,
1994,
705,
358,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
20295,
14,
2219,
14,
992,
492,
2876,
199,
504,
20295,
14,
2219,
14,
3723,
14,
3723,
492,
3523,
3310,
774,
421,
199,
533,
16430,
3310,
774,
8,
1563,
3310,
774,
304,
272,
347,
511,
63,
2886,
8,
277,
304,
267,
291,
14,
1117,
63,
2886,
342,
339,
347,
511,
63,
2886,
63,
1045,
63,
6672,
63,
7379,
8,
277,
304,
267,
291,
14,
1117,
63,
2886,
63,
1045,
63,
6672,
63,
7379,
342,
339,
347,
511,
63,
955,
63,
16431,
63,
262,
63,
1730,
8,
277,
304,
267,
291,
14,
8590,
14,
409,
63,
1751,
2561,
288,
283,
4118,
21212,
63,
5580,
63,
12767,
63,
29456,
63,
568,
63,
12763,
356,
788,
1421,
297,
283,
1700,
418,
267,
3828,
267,
291,
14,
8590,
14,
409,
63,
1069,
63,
576,
3252,
1421,
356,
283,
17,
297,
283,
1700,
356,
283,
18,
2267,
291,
14,
4620,
9,
267,
291,
14,
1117,
63,
2886,
342,
267,
291,
14,
629,
8,
277,
14,
8590,
14,
1730,
63,
362,
360,
1421,
659,
283,
17,
358,
267,
291,
14,
629,
8,
277,
14,
8590,
14,
1730,
63,
362,
360,
1700,
659,
283,
18,
358,
339,
347,
511,
63,
4876,
63,
585,
8,
277,
304,
267,
291,
14,
8590,
14,
409,
63,
1069,
63,
576,
3252,
2184,
356,
1994,
4399,
13,
2886,
2267,
291,
14,
4620,
9,
267,
4660,
275,
291,
14,
1117,
63,
2886,
8,
4399,
63,
4883,
63,
8625,
29,
797,
9,
267,
291,
14,
629,
8,
4876,
14,
633,
12,
1994,
4399,
13,
2886,
358,
339,
347,
511,
63,
2886,
63,
1045,
63,
3197,
63,
6672,
63,
7379,
8,
277,
304,
267,
347,
2544,
63,
4883,
837,
288,
7417,
275,
291,
14,
8590,
14,
1730,
63,
362,
360,
6672,
63,
7379,
358,
288,
7417,
459,
4620,
418,
275,
283,
9664,
7,
288,
291,
14,
8590,
14,
1730,
63,
409,
360,
6672,
63,
7379,
297,
7417,
9,
267,
291,
14,
1117,
63,
2886,
63,
1045,
63,
6672,
63,
7379,
8,
5182,
63,
4883,
9,
339,
347,
511,
63,
1222,
63,
751,
8,
277,
304,
267,
291,
14,
8590,
14,
409,
63,
1751,
2561,
288,
283,
4118,
21212,
63,
5580,
63,
11365,
63,
3791,
63,
19747,
63,
2632,
356,
1994,
1222,
13,
751,
7,
267,
3828,
267,
4660,
275,
291,
14,
1117,
63,
2886,
8,
4399,
63,
4883,
63,
8625,
29,
797,
9,
267,
291,
14,
629,
8,
4876,
14,
633,
12,
1994,
1222,
13,
751,
358,
339,
347,
511,
63,
16856,
63,
751,
8,
277,
304,
267,
291,
14,
8590,
14,
409,
63,
1751,
2561,
288,
283,
4118,
21212,
63,
5580,
63,
568,
10401,
63,
3791,
63,
2632,
356,
1994,
16856,
7,
267,
3828,
267,
2876,
14,
409,
63,
2682,
8,
797,
9,
267,
4660,
275,
291,
14,
1117,
63,
2886,
8,
4399,
63,
4883,
63,
8625,
29,
797,
9,
267,
291,
14,
629,
8,
4876,
14,
633,
12,
1994,
16856,
358,
339,
347,
511,
63,
3197,
63,
751,
8,
277,
304,
267,
291,
14,
8590,
14,
409,
63,
1751,
2561,
288,
283,
4118,
21212,
63,
5580,
63,
17208,
63,
3170,
63,
2632,
356,
1994,
705,
297,
288,
283,
4118,
21212,
63,
5580,
63,
6089,
6174,
356,
334,
355,
283,
13574,
14,
7379,
14,
13574,
63,
1178,
14,
13574,
63,
5087,
297,
355,
283,
13574,
14,
7379,
14,
13574,
63,
1178,
14,
13574,
63,
1535,
297,
355,
283,
13574,
14,
7379,
14,
13574,
63,
1178,
14,
1178,
63,
6541,
297,
355,
283,
13574,
14,
7379,
14,
13574,
63,
1178,
14,
13574,
63,
751,
297,
355,
283,
13574,
14,
7379,
14,
751,
14,
362,
63,
2473,
297,
355,
283,
13574,
14,
7379,
14,
751,
14,
981,
63,
751,
297,
355,
283,
13574,
14,
7379,
14,
13574,
63,
1178,
14,
16021,
63,
751,
297,
355,
283,
13574,
14,
7379,
14,
13574,
63,
1178,
14,
912,
63,
2911,
63,
576,
297,
355,
283,
13574,
14,
7379,
14,
751,
14,
751,
63,
5087,
297,
355,
283,
13574,
14,
2219,
14,
7379,
14,
2168,
63,
751,
7,
288,
776,
267,
3828,
267,
4660,
275,
291,
14,
1117,
63,
2886,
8,
4399,
63,
4883,
63,
8625,
29,
797,
9,
267,
291,
14,
629,
8,
4876,
14,
633,
12,
1994,
705,
358,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
samdoran/ansible
|
lib/ansible/plugins/callback/logentries.py
|
24
|
11304
|
""" (c) 2015, Logentries.com, Jimmy Tang <jimmy.tang@logentries.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/>.
This callback plugin will generate json objects to be sent to logentries
for auditing/debugging purposes.
Todo:
* Better formatting of output before sending out to logentries data/api nodes.
To use:
Add this to your ansible.cfg file in the defaults block
[defaults]
callback_plugins = ./callback_plugins
callback_stdout = logentries
callback_whitelist = logentries
Copy the callback plugin into the callback_plugins directory
Either set the environment variables
export LOGENTRIES_API=data.logentries.com
export LOGENTRIES_PORT=10000
export LOGENTRIES_ANSIBLE_TOKEN=dd21fc88-f00a-43ff-b977-e3a4233c53af
Or create a logentries.ini config file that sites next to the plugin with the following contents
[logentries]
api = data.logentries.com
port = 10000
tls_port = 20000
use_tls = no
token = dd21fc88-f00a-43ff-b977-e3a4233c53af
flatten = False
"""
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
import os
import socket
import random
import time
import codecs
import uuid
try:
import certifi
HAS_CERTIFI = True
except ImportError:
HAS_CERTIFI = False
try:
import flatdict
HAS_FLATDICT = True
except ImportError:
HAS_FLATDICT = False
from ansible.module_utils.six.moves import configparser
from ansible.plugins.callback import CallbackBase
def is_unicode(ch):
return isinstance(ch, unicode)
def create_unicode(ch):
return unicode(ch, 'utf-8')
class PlainTextSocketAppender(object):
def __init__(self,
verbose=True,
LE_API='data.logentries.com',
LE_PORT=80,
LE_TLS_PORT=443):
self.LE_API = LE_API
self.LE_PORT = LE_PORT
self.LE_TLS_PORT = LE_TLS_PORT
self.MIN_DELAY = 0.1
self.MAX_DELAY = 10
# Error message displayed when an incorrect Token has been detected
self.INVALID_TOKEN = ("\n\nIt appears the LOGENTRIES_TOKEN "
"parameter you entered is incorrect!\n\n")
# Unicode Line separator character \u2028
self.LINE_SEP = u'\u2028'
self.verbose = verbose
self._conn = None
def open_connection(self):
self._conn = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self._conn.connect((self.LE_API, self.LE_PORT))
def reopen_connection(self):
self.close_connection()
root_delay = self.MIN_DELAY
while True:
try:
self.open_connection()
return
except Exception:
if self.verbose:
self._display.warning("Unable to connect to Logentries")
root_delay *= 2
if (root_delay > self.MAX_DELAY):
root_delay = self.MAX_DELAY
wait_for = root_delay + random.uniform(0, root_delay)
try:
time.sleep(wait_for)
except KeyboardInterrupt:
raise
def close_connection(self):
if self._conn is not None:
self._conn.close()
def put(self, data):
# Replace newlines with Unicode line separator
# for multi-line events
if not is_unicode(data):
multiline = create_unicode(data).replace('\n', self.LINE_SEP)
else:
multiline = data.replace('\n', self.LINE_SEP)
multiline += "\n"
# Send data, reconnect if needed
while True:
try:
self._conn.send(multiline.encode('utf-8'))
except socket.error:
self.reopen_connection()
continue
break
self.close_connection()
try:
import ssl
HAS_SSL = True
except ImportError: # for systems without TLS support.
SocketAppender = PlainTextSocketAppender
HAS_SSL = False
else:
class TLSSocketAppender(PlainTextSocketAppender):
def open_connection(self):
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock = ssl.wrap_socket(
sock=sock,
keyfile=None,
certfile=None,
server_side=False,
cert_reqs=ssl.CERT_REQUIRED,
ssl_version=getattr(
ssl, 'PROTOCOL_TLSv1_2', ssl.PROTOCOL_TLSv1),
ca_certs=certifi.where(),
do_handshake_on_connect=True,
suppress_ragged_eofs=True, )
sock.connect((self.LE_API, self.LE_TLS_PORT))
self._conn = sock
SocketAppender = TLSSocketAppender
class CallbackModule(CallbackBase):
CALLBACK_VERSION = 2.0
CALLBACK_TYPE = 'notification'
CALLBACK_NAME = 'logentries'
CALLBACK_NEEDS_WHITELIST = True
def __init__(self):
super(CallbackModule, self).__init__()
if not HAS_SSL:
self._display.warning("Unable to import ssl module. Will send over port 80.")
if not HAS_CERTIFI:
self.disabled = True
self._display.warning('The `certifi` python module is not installed. '
'Disabling the Logentries callback plugin.')
if not HAS_FLATDICT:
self.disabled = True
self._display.warning('The `flatdict` python module is not installed. '
'Disabling the Logentries callback plugin.')
config_path = os.path.abspath(os.path.dirname(__file__))
config = configparser.ConfigParser()
try:
config.readfp(open(os.path.join(config_path, 'logentries.ini')))
if config.has_option('logentries', 'api'):
self.api_uri = config.get('logentries', 'api')
if config.has_option('logentries', 'port'):
self.api_port = config.getint('logentries', 'port')
if config.has_option('logentries', 'tls_port'):
self.api_tls_port = config.getint('logentries', 'tls_port')
if config.has_option('logentries', 'use_tls'):
self.use_tls = config.getboolean('logentries', 'use_tls')
if config.has_option('logentries', 'token'):
self.token = config.get('logentries', 'token')
if config.has_option('logentries', 'flatten'):
self.flatten = config.getboolean('logentries', 'flatten')
except:
self.api_uri = os.getenv('LOGENTRIES_API')
if self.api_uri is None:
self.api_uri = 'data.logentries.com'
try:
self.api_port = int(os.getenv('LOGENTRIES_PORT'))
if self.api_port is None:
self.api_port = 80
except TypeError:
self.api_port = 80
try:
self.api_tls_port = int(os.getenv('LOGENTRIES_TLS_PORT'))
if self.api_tls_port is None:
self.api_tls_port = 443
except TypeError:
self.api_tls_port = 443
# this just needs to be set to use TLS
self.use_tls = os.getenv('LOGENTRIES_USE_TLS')
if self.use_tls is None:
self.use_tls = False
elif self.use_tls.lower() in ['yes', 'true']:
self.use_tls = True
self.token = os.getenv('LOGENTRIES_ANSIBLE_TOKEN')
if self.token is None:
self.disabled = True
self._display.warning('Logentries token could not be loaded. The logentries token can be provided using the `LOGENTRIES_TOKEN` environment '
'variable')
self.flatten = os.getenv('LOGENTRIES_FLATTEN')
if self.flatten is None:
self.flatten = False
elif self.flatten.lower() in ['yes', 'true']:
self.flatten = True
self.verbose = False
self.timeout = 10
self.le_jobid = str(uuid.uuid4())
if self.use_tls:
self._appender = TLSSocketAppender(verbose=self.verbose,
LE_API=self.api_uri,
LE_TLS_PORT=self.api_tls_port)
else:
self._appender = PlainTextSocketAppender(verbose=self.verbose,
LE_API=self.api_uri,
LE_PORT=self.api_port)
self._appender.reopen_connection()
def emit_formatted(self, record):
if self.flatten:
results = flatdict.FlatDict(record)
self.emit(self._dump_results(results))
else:
self.emit(self._dump_results(record))
def emit(self, record):
msg = record.rstrip('\n')
msg = "{} {}".format(self.token, msg)
self._appender.put(msg)
def runner_on_ok(self, host, res):
results = {}
results['le_jobid'] = self.le_jobid
results['hostname'] = host
results['results'] = res
results['status'] = 'OK'
self.emit_formatted(results)
def runner_on_failed(self, host, res, ignore_errors=False):
results = {}
results['le_jobid'] = self.le_jobid
results['hostname'] = host
results['results'] = res
results['status'] = 'FAILED'
self.emit_formatted(results)
def runner_on_skipped(self, host, item=None):
results = {}
results['le_jobid'] = self.le_jobid
results['hostname'] = host
results['status'] = 'SKIPPED'
self.emit_formatted(results)
def runner_on_unreachable(self, host, res):
results = {}
results['le_jobid'] = self.le_jobid
results['hostname'] = host
results['results'] = res
results['status'] = 'UNREACHABLE'
self.emit_formatted(results)
def runner_on_async_failed(self, host, res, jid):
results = {}
results['le_jobid'] = self.le_jobid
results['hostname'] = host
results['results'] = res
results['jid'] = jid
results['status'] = 'ASYNC_FAILED'
self.emit_formatted(results)
def v2_playbook_on_play_start(self, play):
results = {}
results['le_jobid'] = self.le_jobid
results['started_by'] = os.getlogin()
if play.name:
results['play'] = play.name
results['hosts'] = play.hosts
self.emit_formatted(results)
def playbook_on_stats(self, stats):
""" close connection """
self._appender.close_connection()
|
gpl-3.0
|
[
624,
334,
67,
9,
6900,
12,
5297,
3189,
14,
957,
12,
1603,
20066,
89,
377,
621,
665,
8047,
31155,
14,
84,
621,
32,
793,
3189,
14,
957,
30,
199,
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,
2765,
3233,
3589,
911,
3550,
2022,
2251,
370,
506,
4847,
370,
943,
3189,
199,
509,
10576,
328,
1337,
15,
24913,
12901,
14,
199,
199,
52,
19657,
26,
199,
199,
10,
31535,
351,
10803,
402,
1072,
2544,
10209,
734,
370,
943,
3189,
666,
15,
1246,
3380,
14,
199,
199,
1378,
675,
26,
199,
199,
1123,
642,
370,
2195,
3242,
14,
4128,
570,
315,
314,
4243,
1853,
339,
359,
4322,
61,
272,
3233,
63,
5265,
275,
16605,
3058,
63,
5265,
272,
3233,
63,
2703,
275,
943,
3189,
272,
3233,
63,
14189,
275,
943,
3189,
199,
199,
5116,
314,
3233,
3589,
1901,
314,
3233,
63,
5265,
2082,
199,
199,
37,
1711,
663,
314,
3734,
2860,
339,
4843,
5051,
1309,
23359,
63,
3735,
29,
576,
14,
793,
3189,
14,
957,
272,
4843,
5051,
1309,
23359,
63,
3657,
29,
9943,
272,
4843,
5051,
1309,
23359,
63,
8490,
63,
8803,
29,
617,
2025,
3003,
1299,
13,
70,
383,
65,
13,
2824,
556,
13,
66,
30605,
13,
69,
19,
65,
2260,
1153,
67,
2481,
2756,
199,
199,
2844,
1218,
282,
943,
3189,
14,
2730,
1101,
570,
626,
15424,
2163,
370,
314,
3589,
543,
314,
2569,
4072,
339,
359,
793,
3189,
61,
272,
2986,
275,
666,
14,
793,
3189,
14,
957,
272,
1844,
275,
11630,
272,
15142,
63,
719,
275,
499,
993,
272,
675,
63,
9945,
275,
949,
272,
1526,
275,
13972,
2025,
3003,
1299,
13,
70,
383,
65,
13,
2824,
556,
13,
66,
30605,
13,
69,
19,
65,
2260,
1153,
67,
2481,
2756,
272,
9378,
275,
756,
421,
199,
624,
199,
199,
504,
636,
2443,
363,
492,
334,
6116,
63,
646,
12,
4629,
12,
870,
63,
1593,
9,
199,
363,
6577,
363,
275,
730,
199,
199,
646,
747,
199,
646,
2838,
199,
646,
2196,
199,
646,
900,
199,
646,
6010,
199,
646,
5377,
199,
199,
893,
26,
272,
492,
3361,
1428,
272,
7509,
63,
11163,
11100,
275,
715,
199,
2590,
3545,
26,
272,
7509,
63,
11163,
11100,
275,
756,
199,
199,
893,
26,
272,
492,
6829,
807,
272,
7509,
63,
3143,
619,
12511,
275,
715,
199,
2590,
3545,
26,
272,
7509,
63,
3143,
619,
12511,
275,
756,
199,
199,
504,
3242,
14,
578,
63,
1208,
14,
4174,
14,
4912,
492,
21230,
199,
504,
3242,
14,
5265,
14,
3058,
492,
17555,
1563,
421,
199,
318,
365,
63,
2975,
8,
335,
304,
272,
372,
1228,
8,
335,
12,
2649,
9,
421,
199,
318,
1218,
63,
2975,
8,
335,
304,
272,
372,
2649,
8,
335,
12,
283,
1624,
13,
24,
358,
421,
199,
533,
510,
3993,
1872,
3869,
2640,
13747,
8,
785,
304,
272,
347,
636,
826,
721,
277,
12,
326,
3376,
29,
549,
12,
326,
6124,
63,
3735,
534,
576,
14,
793,
3189,
14,
957,
297,
326,
6124,
63,
3657,
29,
1257,
12,
326,
6124,
63,
10224,
63,
3657,
29,
16284,
304,
398,
291,
14,
906,
63,
3735,
275,
6124,
63,
3735,
267,
291,
14,
906,
63,
3657,
275,
6124,
63,
3657,
267,
291,
14,
906,
63,
10224,
63,
3657,
275,
6124,
63,
10224,
63,
3657,
267,
291,
14,
4896,
63,
18616,
275,
378,
14,
17,
267,
291,
14,
4283,
63,
18616,
275,
1616,
267,
327,
4520,
1245,
9080,
1380,
376,
8927,
8767,
965,
2757,
10501,
267,
291,
14,
9692,
63,
8803,
275,
25381,
78,
60,
78,
7940,
11337,
314,
5051,
1309,
23359,
63,
8803,
298,
2892,
298,
5329,
1265,
19138,
365,
8927,
12525,
78,
60,
78,
531,
267,
327,
6140,
7030,
9432,
4528,
257,
971,
85,
25247,
267,
291,
14,
6174,
63,
20848,
275,
399,
1154,
85,
25247,
7,
398,
291,
14,
3832,
275,
3376,
267,
291,
423,
1631,
275,
488,
339,
347,
1551,
63,
2105,
8,
277,
304,
267,
291,
423,
1631,
275,
2838,
14,
3450,
8,
3450,
14,
5699,
63,
11367,
12,
2838,
14,
9469,
63,
9484,
9,
267,
291,
423,
1631,
14,
2242,
1332,
277,
14,
906,
63,
3735,
12,
291,
14,
906,
63,
3657,
430,
339,
347,
295,
1490,
63,
2105,
8,
277,
304,
267,
291,
14,
1600,
63,
2105,
342,
398,
1738,
63,
5814,
275,
291,
14,
4896,
63,
18616,
267,
1830,
715,
26,
288,
862,
26,
355,
291,
14,
1490,
63,
2105,
342,
355,
372,
288,
871,
2186,
26,
355,
340,
291,
14,
3832,
26,
490,
291,
423,
2918,
14,
3764,
480,
6005,
370,
4907,
370,
5297,
3189,
531,
953,
1738,
63,
5814,
9000,
499,
288,
340,
334,
1231,
63,
5814,
690,
291,
14,
4283,
63,
18616,
304,
355,
1738,
63,
5814,
275,
291,
14,
4283,
63,
18616,
953,
3618,
63,
509,
275,
1738,
63,
5814,
435,
2196,
14,
8830,
8,
16,
12,
1738,
63,
5814,
9,
953,
862,
26,
355,
900,
14,
4532,
8,
2573,
63,
509,
9,
288,
871,
13483,
26,
355,
746,
339,
347,
4002,
63,
2105,
8,
277,
304,
267,
340,
291,
423,
1631,
365,
440,
488,
26,
288,
291,
423,
1631,
14,
1600,
342,
339,
347,
5324,
8,
277,
12,
666,
304,
267,
327,
14402,
14930,
543,
6140,
1004,
9432,
267,
327,
367,
3510,
13,
604,
4474,
267,
340,
440,
365,
63,
2975,
8,
576,
304,
288,
21838,
275,
1218,
63,
2975,
8,
576
] |
[
334,
67,
9,
6900,
12,
5297,
3189,
14,
957,
12,
1603,
20066,
89,
377,
621,
665,
8047,
31155,
14,
84,
621,
32,
793,
3189,
14,
957,
30,
199,
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,
2765,
3233,
3589,
911,
3550,
2022,
2251,
370,
506,
4847,
370,
943,
3189,
199,
509,
10576,
328,
1337,
15,
24913,
12901,
14,
199,
199,
52,
19657,
26,
199,
199,
10,
31535,
351,
10803,
402,
1072,
2544,
10209,
734,
370,
943,
3189,
666,
15,
1246,
3380,
14,
199,
199,
1378,
675,
26,
199,
199,
1123,
642,
370,
2195,
3242,
14,
4128,
570,
315,
314,
4243,
1853,
339,
359,
4322,
61,
272,
3233,
63,
5265,
275,
16605,
3058,
63,
5265,
272,
3233,
63,
2703,
275,
943,
3189,
272,
3233,
63,
14189,
275,
943,
3189,
199,
199,
5116,
314,
3233,
3589,
1901,
314,
3233,
63,
5265,
2082,
199,
199,
37,
1711,
663,
314,
3734,
2860,
339,
4843,
5051,
1309,
23359,
63,
3735,
29,
576,
14,
793,
3189,
14,
957,
272,
4843,
5051,
1309,
23359,
63,
3657,
29,
9943,
272,
4843,
5051,
1309,
23359,
63,
8490,
63,
8803,
29,
617,
2025,
3003,
1299,
13,
70,
383,
65,
13,
2824,
556,
13,
66,
30605,
13,
69,
19,
65,
2260,
1153,
67,
2481,
2756,
199,
199,
2844,
1218,
282,
943,
3189,
14,
2730,
1101,
570,
626,
15424,
2163,
370,
314,
3589,
543,
314,
2569,
4072,
339,
359,
793,
3189,
61,
272,
2986,
275,
666,
14,
793,
3189,
14,
957,
272,
1844,
275,
11630,
272,
15142,
63,
719,
275,
499,
993,
272,
675,
63,
9945,
275,
949,
272,
1526,
275,
13972,
2025,
3003,
1299,
13,
70,
383,
65,
13,
2824,
556,
13,
66,
30605,
13,
69,
19,
65,
2260,
1153,
67,
2481,
2756,
272,
9378,
275,
756,
421,
199,
624,
199,
199,
504,
636,
2443,
363,
492,
334,
6116,
63,
646,
12,
4629,
12,
870,
63,
1593,
9,
199,
363,
6577,
363,
275,
730,
199,
199,
646,
747,
199,
646,
2838,
199,
646,
2196,
199,
646,
900,
199,
646,
6010,
199,
646,
5377,
199,
199,
893,
26,
272,
492,
3361,
1428,
272,
7509,
63,
11163,
11100,
275,
715,
199,
2590,
3545,
26,
272,
7509,
63,
11163,
11100,
275,
756,
199,
199,
893,
26,
272,
492,
6829,
807,
272,
7509,
63,
3143,
619,
12511,
275,
715,
199,
2590,
3545,
26,
272,
7509,
63,
3143,
619,
12511,
275,
756,
199,
199,
504,
3242,
14,
578,
63,
1208,
14,
4174,
14,
4912,
492,
21230,
199,
504,
3242,
14,
5265,
14,
3058,
492,
17555,
1563,
421,
199,
318,
365,
63,
2975,
8,
335,
304,
272,
372,
1228,
8,
335,
12,
2649,
9,
421,
199,
318,
1218,
63,
2975,
8,
335,
304,
272,
372,
2649,
8,
335,
12,
283,
1624,
13,
24,
358,
421,
199,
533,
510,
3993,
1872,
3869,
2640,
13747,
8,
785,
304,
272,
347,
636,
826,
721,
277,
12,
326,
3376,
29,
549,
12,
326,
6124,
63,
3735,
534,
576,
14,
793,
3189,
14,
957,
297,
326,
6124,
63,
3657,
29,
1257,
12,
326,
6124,
63,
10224,
63,
3657,
29,
16284,
304,
398,
291,
14,
906,
63,
3735,
275,
6124,
63,
3735,
267,
291,
14,
906,
63,
3657,
275,
6124,
63,
3657,
267,
291,
14,
906,
63,
10224,
63,
3657,
275,
6124,
63,
10224,
63,
3657,
267,
291,
14,
4896,
63,
18616,
275,
378,
14,
17,
267,
291,
14,
4283,
63,
18616,
275,
1616,
267,
327,
4520,
1245,
9080,
1380,
376,
8927,
8767,
965,
2757,
10501,
267,
291,
14,
9692,
63,
8803,
275,
25381,
78,
60,
78,
7940,
11337,
314,
5051,
1309,
23359,
63,
8803,
298,
2892,
298,
5329,
1265,
19138,
365,
8927,
12525,
78,
60,
78,
531,
267,
327,
6140,
7030,
9432,
4528,
257,
971,
85,
25247,
267,
291,
14,
6174,
63,
20848,
275,
399,
1154,
85,
25247,
7,
398,
291,
14,
3832,
275,
3376,
267,
291,
423,
1631,
275,
488,
339,
347,
1551,
63,
2105,
8,
277,
304,
267,
291,
423,
1631,
275,
2838,
14,
3450,
8,
3450,
14,
5699,
63,
11367,
12,
2838,
14,
9469,
63,
9484,
9,
267,
291,
423,
1631,
14,
2242,
1332,
277,
14,
906,
63,
3735,
12,
291,
14,
906,
63,
3657,
430,
339,
347,
295,
1490,
63,
2105,
8,
277,
304,
267,
291,
14,
1600,
63,
2105,
342,
398,
1738,
63,
5814,
275,
291,
14,
4896,
63,
18616,
267,
1830,
715,
26,
288,
862,
26,
355,
291,
14,
1490,
63,
2105,
342,
355,
372,
288,
871,
2186,
26,
355,
340,
291,
14,
3832,
26,
490,
291,
423,
2918,
14,
3764,
480,
6005,
370,
4907,
370,
5297,
3189,
531,
953,
1738,
63,
5814,
9000,
499,
288,
340,
334,
1231,
63,
5814,
690,
291,
14,
4283,
63,
18616,
304,
355,
1738,
63,
5814,
275,
291,
14,
4283,
63,
18616,
953,
3618,
63,
509,
275,
1738,
63,
5814,
435,
2196,
14,
8830,
8,
16,
12,
1738,
63,
5814,
9,
953,
862,
26,
355,
900,
14,
4532,
8,
2573,
63,
509,
9,
288,
871,
13483,
26,
355,
746,
339,
347,
4002,
63,
2105,
8,
277,
304,
267,
340,
291,
423,
1631,
365,
440,
488,
26,
288,
291,
423,
1631,
14,
1600,
342,
339,
347,
5324,
8,
277,
12,
666,
304,
267,
327,
14402,
14930,
543,
6140,
1004,
9432,
267,
327,
367,
3510,
13,
604,
4474,
267,
340,
440,
365,
63,
2975,
8,
576,
304,
288,
21838,
275,
1218,
63,
2975,
8,
576,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
daniel-yu-papa/Maggie-OpenMax
|
external/build/Tools/SCons/gcc-generic.py
|
2
|
1528
|
import os
def generate(env, gcc_cross_prefix=None, gcc_strict=False, gcc_stop_on_warning=None, gcc_extra_options=''):
if gcc_stop_on_warning == None: gcc_stop_on_warning = env['stop_on_warning']
### compiler flags
if gcc_strict:
env['CCFLAGS'] = ""
env['CFLAGS'] = ""
env.AppendUnique(CCFLAGS = ['-pedantic', '-Werror', '-Wno-variadic-macros', '-Wno-long-long', '-Wno-multichar'])
env.AppendUnique(CFLAGS = ['-Wmissing-prototypes', '-Wmissing-declarations'])
else:
env['CCFLAGS'] = ""
env.AppendUnique(CCFLAGS = ['-Wall', '-Wno-multichar'])
compiler_defines = ['-D_REENTRANT', '-D__STDC_CONSTANT_MACROS']
env.AppendUnique(CCFLAGS = compiler_defines)
env.AppendUnique(CPPFLAGS = compiler_defines)
env.AppendUnique(LINKFLAGS = ['-lpthread', '-lrt'])
if env['build_config'] == 'Debug':
env.AppendUnique(CCFLAGS = '-g')
else:
env.AppendUnique(CCFLAGS = '-O3')
if gcc_stop_on_warning:
env.AppendUnique(CCFLAGS = ['-Werror'])
env['STRIP'] = 'strip'
if gcc_cross_prefix:
env['ENV']['PATH'] += os.environ['PATH']
env['AR'] = gcc_cross_prefix+'-ar'
env['RANLIB'] = gcc_cross_prefix+'-ranlib'
env['CC'] = gcc_cross_prefix+'-gcc ' + gcc_extra_options
env['CXX'] = gcc_cross_prefix+'-g++ ' + gcc_extra_options
env['LINK'] = gcc_cross_prefix+'-g++ ' + gcc_extra_options
env['STRIP'] = gcc_cross_prefix+'-strip'
|
lgpl-3.0
|
[
646,
747,
199,
199,
318,
3550,
8,
1813,
12,
19443,
63,
7925,
63,
1861,
29,
403,
12,
19443,
63,
4768,
29,
797,
12,
19443,
63,
2379,
63,
265,
63,
3764,
29,
403,
12,
19443,
63,
2911,
63,
1419,
9280,
272,
340,
19443,
63,
2379,
63,
265,
63,
3764,
508,
488,
26,
19443,
63,
2379,
63,
265,
63,
3764,
275,
2589,
459,
2379,
63,
265,
63,
3764,
418,
339,
6754,
6365,
3285,
272,
340,
19443,
63,
4768,
26,
267,
2589,
459,
2571,
4831,
418,
275,
3087,
267,
2589,
459,
14804,
418,
275,
3087,
267,
2589,
14,
8310,
11427,
8,
2571,
4831,
275,
11573,
1915,
290,
764,
297,
2475,
55,
705,
297,
2475,
55,
889,
13,
3808,
31764,
13,
16358,
297,
2475,
55,
889,
13,
2809,
13,
2809,
297,
2475,
55,
889,
13,
3029,
1560,
1105,
267,
2589,
14,
8310,
11427,
8,
14804,
221,
275,
11573,
55,
4752,
13,
16141,
83,
297,
2475,
55,
4752,
13,
21200,
1105,
272,
587,
26,
267,
2589,
459,
2571,
4831,
418,
275,
3087,
267,
2589,
14,
8310,
11427,
8,
2571,
4831,
275,
11573,
18018,
297,
2475,
55,
889,
13,
3029,
1560,
1105,
2286,
6365,
63,
14334,
275,
11573,
36,
63,
907,
1309,
50,
1441,
297,
2475,
36,
363,
840,
5196,
63,
25825,
63,
9410,
1092,
51,
418,
272,
2589,
14,
8310,
11427,
8,
2571,
4831,
221,
275,
6365,
63,
14334,
9,
272,
2589,
14,
8310,
11427,
8,
14533,
4831,
275,
6365,
63,
14334,
9,
2286,
2589,
14,
8310,
11427,
8,
30388,
275,
11573,
10343,
2671,
297,
2475,
76,
2591,
1105,
339,
340,
2589,
459,
1506,
63,
888,
418,
508,
283,
7084,
356,
267,
2589,
14,
8310,
11427,
8,
2571,
4831,
275,
2475,
71,
358,
272,
587,
26,
267,
2589,
14,
8310,
11427,
8,
2571,
4831,
275,
2475,
47,
19,
358,
2286,
340,
19443,
63,
2379,
63,
265,
63,
3764,
26,
267,
2589,
14,
8310,
11427,
8,
2571,
4831,
275,
11573,
55,
705,
1105,
5493,
2589,
459,
31296,
418,
221,
275,
283,
1913,
7,
339,
340,
19443,
63,
7925,
63,
1861,
26,
267,
2589,
459,
9984,
2545,
3243,
418,
847,
747,
14,
2314,
459,
3243,
418,
267,
2589,
459,
689,
418,
258,
275,
19443,
63,
7925,
63,
1861,
4786,
13,
285,
7,
267,
2589,
459,
27644,
5617,
418,
275,
19443,
63,
7925,
63,
1861,
4786,
13,
1312,
773,
7,
267,
2589,
459,
2571,
418,
258,
275,
19443,
63,
7925,
63,
1861,
4786,
13,
13112,
283,
435,
19443,
63,
2911,
63,
1419,
267,
2589,
459,
12206,
418,
259,
275,
19443,
63,
7925,
63,
1861,
4786,
13,
71,
4176,
283,
435,
19443,
63,
2911,
63,
1419,
267,
2589,
459,
7916,
418,
257,
275,
19443,
63,
7925,
63,
1861,
4786,
13,
71,
4176,
283,
435,
19443,
63,
2911,
63,
1419,
267,
2589,
459,
31296,
418,
221,
275,
19443,
63,
7925,
63,
1861,
4786,
13,
1913,
7,
10813,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
747,
199,
199,
318,
3550,
8,
1813,
12,
19443,
63,
7925,
63,
1861,
29,
403,
12,
19443,
63,
4768,
29,
797,
12,
19443,
63,
2379,
63,
265,
63,
3764,
29,
403,
12,
19443,
63,
2911,
63,
1419,
9280,
272,
340,
19443,
63,
2379,
63,
265,
63,
3764,
508,
488,
26,
19443,
63,
2379,
63,
265,
63,
3764,
275,
2589,
459,
2379,
63,
265,
63,
3764,
418,
339,
6754,
6365,
3285,
272,
340,
19443,
63,
4768,
26,
267,
2589,
459,
2571,
4831,
418,
275,
3087,
267,
2589,
459,
14804,
418,
275,
3087,
267,
2589,
14,
8310,
11427,
8,
2571,
4831,
275,
11573,
1915,
290,
764,
297,
2475,
55,
705,
297,
2475,
55,
889,
13,
3808,
31764,
13,
16358,
297,
2475,
55,
889,
13,
2809,
13,
2809,
297,
2475,
55,
889,
13,
3029,
1560,
1105,
267,
2589,
14,
8310,
11427,
8,
14804,
221,
275,
11573,
55,
4752,
13,
16141,
83,
297,
2475,
55,
4752,
13,
21200,
1105,
272,
587,
26,
267,
2589,
459,
2571,
4831,
418,
275,
3087,
267,
2589,
14,
8310,
11427,
8,
2571,
4831,
275,
11573,
18018,
297,
2475,
55,
889,
13,
3029,
1560,
1105,
2286,
6365,
63,
14334,
275,
11573,
36,
63,
907,
1309,
50,
1441,
297,
2475,
36,
363,
840,
5196,
63,
25825,
63,
9410,
1092,
51,
418,
272,
2589,
14,
8310,
11427,
8,
2571,
4831,
221,
275,
6365,
63,
14334,
9,
272,
2589,
14,
8310,
11427,
8,
14533,
4831,
275,
6365,
63,
14334,
9,
2286,
2589,
14,
8310,
11427,
8,
30388,
275,
11573,
10343,
2671,
297,
2475,
76,
2591,
1105,
339,
340,
2589,
459,
1506,
63,
888,
418,
508,
283,
7084,
356,
267,
2589,
14,
8310,
11427,
8,
2571,
4831,
275,
2475,
71,
358,
272,
587,
26,
267,
2589,
14,
8310,
11427,
8,
2571,
4831,
275,
2475,
47,
19,
358,
2286,
340,
19443,
63,
2379,
63,
265,
63,
3764,
26,
267,
2589,
14,
8310,
11427,
8,
2571,
4831,
275,
11573,
55,
705,
1105,
5493,
2589,
459,
31296,
418,
221,
275,
283,
1913,
7,
339,
340,
19443,
63,
7925,
63,
1861,
26,
267,
2589,
459,
9984,
2545,
3243,
418,
847,
747,
14,
2314,
459,
3243,
418,
267,
2589,
459,
689,
418,
258,
275,
19443,
63,
7925,
63,
1861,
4786,
13,
285,
7,
267,
2589,
459,
27644,
5617,
418,
275,
19443,
63,
7925,
63,
1861,
4786,
13,
1312,
773,
7,
267,
2589,
459,
2571,
418,
258,
275,
19443,
63,
7925,
63,
1861,
4786,
13,
13112,
283,
435,
19443,
63,
2911,
63,
1419,
267,
2589,
459,
12206,
418,
259,
275,
19443,
63,
7925,
63,
1861,
4786,
13,
71,
4176,
283,
435,
19443,
63,
2911,
63,
1419,
267,
2589,
459,
7916,
418,
257,
275,
19443,
63,
7925,
63,
1861,
4786,
13,
71,
4176,
283,
435,
19443,
63,
2911,
63,
1419,
267,
2589,
459,
31296,
418,
221,
275,
19443,
63,
7925,
63,
1861,
4786,
13,
1913,
7,
10813,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,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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
] |
eul721/The-Perfect-Pokemon-Team-Balancer
|
libs/env/Lib/site-packages/pip/_vendor/requests/packages/urllib3/connectionpool.py
|
223
|
25767
|
# urllib3/connectionpool.py
# Copyright 2008-2013 Andrey Petrov and contributors (see CONTRIBUTORS.txt)
#
# This module is part of urllib3 and is released under
# the MIT License: http://www.opensource.org/licenses/mit-license.php
import errno
import logging
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,
ConnectTimeoutError,
EmptyPoolError,
HostChangedError,
MaxRetryError,
SSLError,
TimeoutError,
ReadTimeoutError,
ProxyError,
)
from .packages.ssl_match_hostname import CertificateError
from .packages import six
from .connection import (
port_by_scheme,
DummyConnection,
HTTPConnection, HTTPSConnection, VerifiedHTTPSConnection,
HTTPException, BaseSSLError,
)
from .request import RequestMethods
from .response import HTTPResponse
from .util import (
assert_fingerprint,
get_host,
is_connection_dropped,
Timeout,
)
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):
# httplib doesn't like it when we include brackets in ipv6 addresses
host = host.strip('[]')
self.host = host
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 _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`"
"""
scheme = 'http'
ConnectionCls = HTTPConnection
def __init__(self, host, port=None, strict=False,
timeout=Timeout.DEFAULT_TIMEOUT, maxsize=1, block=False,
headers=None, _proxy=None, _proxy_headers=None):
ConnectionPool.__init__(self, host, port)
RequestMethods.__init__(self, headers)
self.strict = strict
# This is for backwards compatibility and can be removed once a timeout
# can only be set to a Timeout object
if not isinstance(timeout, Timeout):
timeout = Timeout.from_float(timeout)
self.timeout = timeout
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
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))
extra_params = {}
if not six.PY3: # Python 2
extra_params['strict'] = self.strict
conn = self.ConnectionCls(host=self.host, port=self.port,
timeout=self.timeout.connect_timeout,
**extra_params)
if self.proxy is not None:
# Enable Nagle's algorithm for proxies, to avoid packet
# fragmentation.
conn.tcp_nodelay = 0
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()
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("HttpConnectionPool is full, discarding connection: %s"
% self.host)
# Connection never got put back into the pool, close it.
if conn:
conn.close()
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 _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)
try:
timeout_obj.start_connect()
conn.timeout = timeout_obj.connect_timeout
# 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)
except SocketTimeout:
raise ConnectTimeoutError(
self, "Connection to %s timed out. (connect timeout=%s)" %
(self.host, timeout_obj.connect_timeout))
# Reset the timeout for the recv() on the socket
read_timeout = timeout_obj.read_timeout
# App Engine doesn't have a sock attr
if hasattr(conn, 'sock'):
# 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:
raise ReadTimeoutError(
self, url, "Read timed out. (read timeout=%s)" % read_timeout)
except BaseSSLError as e:
# 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(e) or \
'did not complete (read)' in str(e): # Python 2.6
raise ReadTimeoutError(self, url, "Read timed out.")
raise
except SocketError as e: # Platform-specific: Python 2
# See the above comment about EAGAIN in Python 3. In Python 2 we
# have to specifically catch it and throw the timeout error
if e.errno in _blocking_errnos:
raise ReadTimeoutError(
self, url,
"Read timed out. (read timeout=%s)" % 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=3,
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:
Number of retries to allow before raising a MaxRetryError exception.
:param redirect:
If True, automatically handle redirects (status codes 301, 302,
303, 307, 308). Each redirect counts as a retry.
: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 retries < 0:
raise MaxRetryError(self, url)
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 - 1)
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)
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 as e:
raise SSLError(e)
except CertificateError as e:
# Name mismatch
raise SSLError(e)
except TimeoutError as e:
# Connection broken, discard.
conn = None
# Save the error off for retry logic.
err = e
if retries == 0:
raise
except (HTTPException, SocketError) as e:
# Connection broken, discard. It will be replaced next _get_conn().
conn = None
# This is necessary so we can access e below
err = e
if retries == 0:
if isinstance(e, SocketError) and self.proxy is not None:
raise ProxyError('Cannot connect to proxy. '
'Socket error: %s.' % e)
else:
raise MaxRetryError(self, url, 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.warn("Retrying (%d attempts remain) after connection "
"broken by '%r': %s" % (retries, err, url))
return self.urlopen(method, url, body, headers, retries - 1,
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'
log.info("Redirecting %s -> %s" % (url, redirect_location))
return self.urlopen(method, redirect_location, body, headers,
retries - 1, redirect, 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=None, maxsize=1,
block=False, headers=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):
HTTPConnectionPool.__init__(self, host, port, strict, timeout, maxsize,
block, headers, _proxy, _proxy_headers)
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
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
extra_params = {}
if not six.PY3: # Python 2
extra_params['strict'] = self.strict
conn = self.ConnectionCls(host=actual_host, port=actual_port,
timeout=self.timeout.connect_timeout,
**extra_params)
if self.proxy is not None:
# Enable Nagle's algorithm for proxies, to avoid packet
# fragmentation.
conn.tcp_nodelay = 0
return self._prepare_conn(conn)
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)
|
gpl-2.0
|
[
3,
4011,
19,
15,
2105,
2293,
14,
647,
199,
3,
1898,
9079,
13,
6965,
6061,
17885,
31449,
293,
86,
436,
8417,
334,
3239,
6483,
14,
2424,
9,
199,
3,
199,
3,
961,
859,
365,
1777,
402,
4011,
19,
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,
646,
7554,
199,
646,
2050,
199,
199,
504,
2838,
492,
1125,
465,
17766,
547,
12,
2653,
465,
17766,
6372,
199,
646,
2838,
199,
199,
893,
26,
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,
15175,
19382,
12,
272,
9630,
5453,
547,
12,
272,
10891,
6970,
547,
12,
272,
8228,
12989,
547,
12,
272,
7799,
547,
12,
272,
31886,
12,
272,
5574,
19382,
12,
272,
12373,
547,
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,
199,
9,
199,
504,
1275,
1069,
492,
4784,
10385,
199,
504,
1275,
1310,
492,
29034,
199,
504,
1275,
1974,
492,
334,
272,
702,
63,
15077,
12,
272,
664,
63,
1102,
12,
272,
365,
63,
2105,
63,
27557,
12,
272,
12878,
12,
199,
9,
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,
199,
199,
309,
15553,
2251,
199,
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,
327,
8809,
3181,
1133,
2839,
652,
1380,
781,
2387,
21873,
315,
3278,
22,
7149,
267,
1591,
275,
1591,
14,
1913,
360,
8607,
358,
398,
291,
14,
1102,
275,
1591,
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,
199,
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,
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,
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,
14,
3472,
63,
8899,
12,
19791,
29,
17,
12,
1853,
29,
797,
12,
326,
2323,
29,
403,
12,
485,
3280,
29,
403,
12,
485,
3280,
63,
2139,
29,
403,
304
] |
[
4011,
19,
15,
2105,
2293,
14,
647,
199,
3,
1898,
9079,
13,
6965,
6061,
17885,
31449,
293,
86,
436,
8417,
334,
3239,
6483,
14,
2424,
9,
199,
3,
199,
3,
961,
859,
365,
1777,
402,
4011,
19,
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,
646,
7554,
199,
646,
2050,
199,
199,
504,
2838,
492,
1125,
465,
17766,
547,
12,
2653,
465,
17766,
6372,
199,
646,
2838,
199,
199,
893,
26,
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,
15175,
19382,
12,
272,
9630,
5453,
547,
12,
272,
10891,
6970,
547,
12,
272,
8228,
12989,
547,
12,
272,
7799,
547,
12,
272,
31886,
12,
272,
5574,
19382,
12,
272,
12373,
547,
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,
199,
9,
199,
504,
1275,
1069,
492,
4784,
10385,
199,
504,
1275,
1310,
492,
29034,
199,
504,
1275,
1974,
492,
334,
272,
702,
63,
15077,
12,
272,
664,
63,
1102,
12,
272,
365,
63,
2105,
63,
27557,
12,
272,
12878,
12,
199,
9,
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,
199,
199,
309,
15553,
2251,
199,
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,
327,
8809,
3181,
1133,
2839,
652,
1380,
781,
2387,
21873,
315,
3278,
22,
7149,
267,
1591,
275,
1591,
14,
1913,
360,
8607,
358,
398,
291,
14,
1102,
275,
1591,
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,
199,
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,
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,
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,
14,
3472,
63,
8899,
12,
19791,
29,
17,
12,
1853,
29,
797,
12,
326,
2323,
29,
403,
12,
485,
3280,
29,
403,
12,
485,
3280,
63,
2139,
29,
403,
304,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
hakanb/django-mailer-2
|
django_mailer/management/commands/send_mail.py
|
3
|
2511
|
from django.core.management.base import NoArgsCommand
from django.db import connection
from django_mailer import models, settings
from django_mailer.engine import send_all
from django_mailer.management.commands import create_handler
from optparse import make_option
import logging
import sys
try:
from django.core.mail import get_connection
EMAIL_BACKEND_SUPPORT = True
except ImportError:
# Django version < 1.2
EMAIL_BACKEND_SUPPORT = False
class Command(NoArgsCommand):
help = 'Iterate the mail queue, attempting to send all mail.'
option_list = NoArgsCommand.option_list + (
make_option('-b', '--block-size', default=500, type='int',
help='The number of messages to iterate before checking the queue '
'again (in case new messages have been added while the queue '
'is being cleared).'),
make_option('-c', '--count', action='store_true', default=False,
help='Return the number of messages in the queue (without '
'actually sending any)'),
)
def handle_noargs(self, verbosity, block_size, count, **options):
# If this is just a count request the just calculate, report and exit.
if count:
queued = models.QueuedMessage.objects.non_deferred().count()
deferred = models.QueuedMessage.objects.non_deferred().count()
sys.stdout.write('%s queued message%s (and %s deferred message%s).'
'\n' % (queued, queued != 1 and 's' or '',
deferred, deferred != 1 and 's' or ''))
sys.exit()
# Send logged messages to the console.
logger = logging.getLogger('django_mailer')
handler = create_handler(verbosity)
logger.addHandler(handler)
# if PAUSE_SEND is turned on don't do anything.
if not settings.PAUSE_SEND:
if EMAIL_BACKEND_SUPPORT:
send_all(block_size, backend=settings.USE_BACKEND)
else:
send_all(block_size)
else:
logger = logging.getLogger('django_mailer.commands.send_mail')
logger.warning("Sending is paused, exiting without sending "
"queued mail.")
logger.removeHandler(handler)
# Stop superfluous "unexpected EOF on client connection" errors in
# Postgres log files caused by the database connection not being
# explicitly closed.
connection.close()
|
mit
|
[
504,
1639,
14,
1018,
14,
8110,
14,
1095,
492,
3091,
6213,
3110,
199,
504,
1639,
14,
697,
492,
1950,
199,
504,
1639,
63,
391,
3566,
492,
1709,
12,
2202,
199,
504,
1639,
63,
391,
3566,
14,
3908,
492,
3222,
63,
452,
199,
504,
1639,
63,
391,
3566,
14,
8110,
14,
4405,
492,
1218,
63,
2232,
199,
504,
8691,
492,
1852,
63,
1422,
199,
646,
2050,
199,
646,
984,
199,
893,
26,
272,
687,
1639,
14,
1018,
14,
1198,
492,
664,
63,
2105,
272,
32320,
63,
18145,
63,
10640,
275,
715,
199,
2590,
3545,
26,
272,
327,
5634,
1015,
665,
413,
14,
18,
272,
32320,
63,
18145,
63,
10640,
275,
756,
199,
199,
533,
5817,
8,
27099,
3110,
304,
272,
1720,
275,
283,
3315,
323,
314,
6016,
4126,
12,
19595,
370,
3222,
1006,
6016,
3530,
272,
945,
63,
513,
275,
3091,
6213,
3110,
14,
1422,
63,
513,
435,
334,
267,
1852,
63,
1422,
3654,
66,
297,
2850,
1457,
13,
890,
297,
849,
29,
5783,
12,
730,
534,
442,
297,
288,
1720,
534,
1918,
1329,
402,
3788,
370,
13974,
2544,
7907,
314,
4126,
283,
355,
283,
14199,
334,
262,
1930,
892,
3788,
1172,
2757,
3483,
1830,
314,
4126,
283,
355,
283,
374,
3769,
20518,
680,
659,
267,
1852,
63,
1422,
3654,
67,
297,
2850,
835,
297,
1595,
534,
1617,
63,
2052,
297,
849,
29,
797,
12,
288,
1720,
534,
1767,
314,
1329,
402,
3788,
315,
314,
4126,
334,
7395,
283,
355,
283,
2442,
3163,
10209,
1263,
11218,
272,
776,
339,
347,
2429,
63,
889,
589,
8,
277,
12,
8661,
12,
1853,
63,
890,
12,
2338,
12,
1011,
1419,
304,
267,
327,
982,
642,
365,
2951,
282,
2338,
1056,
314,
2951,
8671,
12,
3622,
436,
4458,
14,
267,
340,
2338,
26,
288,
26102,
275,
1709,
14,
3737,
68,
2209,
14,
1462,
14,
2865,
63,
12116,
1252,
835,
342,
288,
12309,
275,
1709,
14,
3737,
68,
2209,
14,
1462,
14,
2865,
63,
12116,
1252,
835,
342,
288,
984,
14,
2703,
14,
952,
3508,
83,
26102,
1245,
5,
83,
334,
460,
450,
83,
12309,
1245,
5,
83,
28823,
2490,
1557,
78,
7,
450,
334,
14268,
12,
26102,
1137,
413,
436,
283,
83,
7,
503,
3260,
3660,
12309,
12,
12309,
1137,
413,
436,
283,
83,
7,
503,
12381,
288,
984,
14,
2224,
342,
398,
327,
10217,
10367,
3788,
370,
314,
8559,
14,
267,
2512,
275,
2050,
14,
5572,
360,
1176,
63,
391,
3566,
358,
267,
3016,
275,
1218,
63,
2232,
8,
9833,
9,
267,
2512,
14,
18826,
8,
2232,
9,
398,
327,
340,
510,
33,
4701,
63,
20469,
365,
19136,
641,
2793,
1133,
886,
7003,
14,
267,
340,
440,
2202,
14,
8470,
4701,
63,
20469,
26,
288,
340,
32320,
63,
18145,
63,
10640,
26,
355,
3222,
63,
452,
8,
1457,
63,
890,
12,
4865,
29,
1751,
14,
4701,
63,
18145,
9,
288,
587,
26,
355,
3222,
63,
452,
8,
1457,
63,
890,
9,
267,
587,
26,
288,
2512,
275,
2050,
14,
5572,
360,
1176,
63,
391,
3566,
14,
4405,
14,
2254,
63,
1198,
358,
288,
2512,
14,
3764,
480,
27219,
365,
691,
2972,
12,
24234,
1928,
10209,
298,
2574,
298,
14268,
6016,
2685,
398,
2512,
14,
2168,
2461,
8,
2232,
9,
398,
327,
8015,
1613,
2327,
7514,
298,
8953,
9027,
641,
1890,
1950,
2,
2552,
315,
267,
327,
7711,
7266,
943,
1584,
18104,
701,
314,
3050,
1950,
440,
3769,
267,
327,
7662,
6876,
14,
267,
1950,
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
] |
[
1639,
14,
1018,
14,
8110,
14,
1095,
492,
3091,
6213,
3110,
199,
504,
1639,
14,
697,
492,
1950,
199,
504,
1639,
63,
391,
3566,
492,
1709,
12,
2202,
199,
504,
1639,
63,
391,
3566,
14,
3908,
492,
3222,
63,
452,
199,
504,
1639,
63,
391,
3566,
14,
8110,
14,
4405,
492,
1218,
63,
2232,
199,
504,
8691,
492,
1852,
63,
1422,
199,
646,
2050,
199,
646,
984,
199,
893,
26,
272,
687,
1639,
14,
1018,
14,
1198,
492,
664,
63,
2105,
272,
32320,
63,
18145,
63,
10640,
275,
715,
199,
2590,
3545,
26,
272,
327,
5634,
1015,
665,
413,
14,
18,
272,
32320,
63,
18145,
63,
10640,
275,
756,
199,
199,
533,
5817,
8,
27099,
3110,
304,
272,
1720,
275,
283,
3315,
323,
314,
6016,
4126,
12,
19595,
370,
3222,
1006,
6016,
3530,
272,
945,
63,
513,
275,
3091,
6213,
3110,
14,
1422,
63,
513,
435,
334,
267,
1852,
63,
1422,
3654,
66,
297,
2850,
1457,
13,
890,
297,
849,
29,
5783,
12,
730,
534,
442,
297,
288,
1720,
534,
1918,
1329,
402,
3788,
370,
13974,
2544,
7907,
314,
4126,
283,
355,
283,
14199,
334,
262,
1930,
892,
3788,
1172,
2757,
3483,
1830,
314,
4126,
283,
355,
283,
374,
3769,
20518,
680,
659,
267,
1852,
63,
1422,
3654,
67,
297,
2850,
835,
297,
1595,
534,
1617,
63,
2052,
297,
849,
29,
797,
12,
288,
1720,
534,
1767,
314,
1329,
402,
3788,
315,
314,
4126,
334,
7395,
283,
355,
283,
2442,
3163,
10209,
1263,
11218,
272,
776,
339,
347,
2429,
63,
889,
589,
8,
277,
12,
8661,
12,
1853,
63,
890,
12,
2338,
12,
1011,
1419,
304,
267,
327,
982,
642,
365,
2951,
282,
2338,
1056,
314,
2951,
8671,
12,
3622,
436,
4458,
14,
267,
340,
2338,
26,
288,
26102,
275,
1709,
14,
3737,
68,
2209,
14,
1462,
14,
2865,
63,
12116,
1252,
835,
342,
288,
12309,
275,
1709,
14,
3737,
68,
2209,
14,
1462,
14,
2865,
63,
12116,
1252,
835,
342,
288,
984,
14,
2703,
14,
952,
3508,
83,
26102,
1245,
5,
83,
334,
460,
450,
83,
12309,
1245,
5,
83,
28823,
2490,
1557,
78,
7,
450,
334,
14268,
12,
26102,
1137,
413,
436,
283,
83,
7,
503,
3260,
3660,
12309,
12,
12309,
1137,
413,
436,
283,
83,
7,
503,
12381,
288,
984,
14,
2224,
342,
398,
327,
10217,
10367,
3788,
370,
314,
8559,
14,
267,
2512,
275,
2050,
14,
5572,
360,
1176,
63,
391,
3566,
358,
267,
3016,
275,
1218,
63,
2232,
8,
9833,
9,
267,
2512,
14,
18826,
8,
2232,
9,
398,
327,
340,
510,
33,
4701,
63,
20469,
365,
19136,
641,
2793,
1133,
886,
7003,
14,
267,
340,
440,
2202,
14,
8470,
4701,
63,
20469,
26,
288,
340,
32320,
63,
18145,
63,
10640,
26,
355,
3222,
63,
452,
8,
1457,
63,
890,
12,
4865,
29,
1751,
14,
4701,
63,
18145,
9,
288,
587,
26,
355,
3222,
63,
452,
8,
1457,
63,
890,
9,
267,
587,
26,
288,
2512,
275,
2050,
14,
5572,
360,
1176,
63,
391,
3566,
14,
4405,
14,
2254,
63,
1198,
358,
288,
2512,
14,
3764,
480,
27219,
365,
691,
2972,
12,
24234,
1928,
10209,
298,
2574,
298,
14268,
6016,
2685,
398,
2512,
14,
2168,
2461,
8,
2232,
9,
398,
327,
8015,
1613,
2327,
7514,
298,
8953,
9027,
641,
1890,
1950,
2,
2552,
315,
267,
327,
7711,
7266,
943,
1584,
18104,
701,
314,
3050,
1950,
440,
3769,
267,
327,
7662,
6876,
14,
267,
1950,
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,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
protatremy/buildbot
|
worker/buildbot_worker/test/util/misc.py
|
9
|
8057
|
# This file is part of Buildbot. Buildbot is free software: you can
# redistribute it and/or modify it under the terms of the GNU General Public
# License as published by the Free Software Foundation, version 2.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, write to the Free Software Foundation, Inc., 51
# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Copyright Buildbot Team Members
# We cannot use the builtins module here from Python-Future.
# We need to use the native __builtin__ module on Python 2,
# and builtins module on Python 3, because we need to override
# the actual native open method.
from __future__ import absolute_import
from __future__ import print_function
from future.utils import PY3
from future.utils import string_types
import errno
import os
import re
import shutil
import sys
from io import BytesIO
from io import StringIO
import mock
from twisted.python import log
from buildbot_worker.scripts import base
try:
# Python 2
import __builtin__ as builtins
except ImportError:
# Python 3
import builtins
def nl(s):
"""Convert the given string to the native newline format, assuming it is
already in normal UNIX newline format (\n). Use this to create the
appropriate expectation in an assertEqual"""
if not isinstance(s, string_types):
return s
return s.replace('\n', os.linesep)
class BasedirMixin(object):
"""Mix this in and call setUpBasedir and tearDownBasedir to set up
a clean basedir with a name given in self.basedir."""
def setUpBasedir(self):
self.basedir = "test-basedir"
if os.path.exists(self.basedir):
shutil.rmtree(self.basedir)
def tearDownBasedir(self):
if os.path.exists(self.basedir):
shutil.rmtree(self.basedir)
class IsWorkerDirMixin(object):
"""
Mixin for setting up mocked base.isWorkerDir() function
"""
def setupUpIsWorkerDir(self, return_value):
self.isWorkerDir = mock.Mock(return_value=return_value)
self.patch(base, "isWorkerDir", self.isWorkerDir)
class PatcherMixin(object):
"""
Mix this in to get a few special-cased patching methods
"""
def patch_os_uname(self, replacement):
# twisted's 'patch' doesn't handle the case where an attribute
# doesn't exist..
if hasattr(os, 'uname'):
self.patch(os, 'uname', replacement)
else:
def cleanup():
del os.uname
self.addCleanup(cleanup)
os.uname = replacement
class FileIOMixin(object):
"""
Mixin for patching open(), read() and write() to simulate successful
I/O operations and various I/O errors.
"""
def setUpOpen(self, file_contents="dummy-contents"):
"""
patch open() to return file object with provided contents.
@param file_contents: contents that will be returned by file object's
read() method
"""
# Use mock.mock_open() to create a substitute for
# open().
fakeOpen = mock.mock_open(read_data=file_contents)
# When fakeOpen() is called, it returns a Mock
# that has these methods: read(), write(), __enter__(), __exit__().
# read() will always return the value of the 'file_contents variable.
self.fileobj = fakeOpen()
# patch open() to always return our Mock file object
self.open = mock.Mock(return_value=self.fileobj)
self.patch(builtins, "open", self.open)
def setUpOpenError(self, errno=errno.ENOENT, strerror="dummy-msg",
filename="dummy-file"):
"""
patch open() to raise IOError
@param errno: exception's errno value
@param strerror: exception's strerror value
@param filename: exception's filename value
"""
# Use mock.mock_open() to create a substitute for
# open().
fakeOpen = mock.mock_open()
# Add side_effect so that calling fakeOpen() will always
# raise an IOError.
fakeOpen.side_effect = IOError(errno, strerror, filename)
self.open = fakeOpen
self.patch(builtins, "open", self.open)
def setUpReadError(self, errno=errno.EIO, strerror="dummy-msg",
filename="dummy-file"):
"""
patch open() to return a file object that will raise IOError on read()
@param errno: exception's errno value
@param strerror: exception's strerror value
@param filename: exception's filename value
"""
# Use mock.mock_open() to create a substitute for
# open().
fakeOpen = mock.mock_open()
# When fakeOpen() is called, it returns a Mock
# that has these methods: read(), write(), __enter__(), __exit__().
self.fileobj = fakeOpen()
# Add side_effect so that calling read() will always
# raise an IOError.
self.fileobj.read.side_effect = IOError(errno, strerror, filename)
# patch open() to always return our Mock file object
self.open = mock.Mock(return_value=self.fileobj)
self.patch(builtins, "open", self.open)
def setUpWriteError(self, errno=errno.ENOSPC, strerror="dummy-msg",
filename="dummy-file"):
"""
patch open() to return a file object that will raise IOError on write()
@param errno: exception's errno value
@param strerror: exception's strerror value
@param filename: exception's filename value
"""
# Use mock.mock_open() to create a substitute for
# open().
fakeOpen = mock.mock_open()
# When fakeOpen() is called, it returns a Mock
# that has these methods: read(), write(), __enter__(), __exit__().
self.fileobj = fakeOpen()
# Add side_effect so that calling write() will always
# raise an IOError.
self.fileobj.write.side_effect = IOError(errno, strerror, filename)
# patch open() to always return our Mock file object
self.open = mock.Mock(return_value=self.fileobj)
self.patch(builtins, "open", self.open)
class LoggingMixin(object):
def setUpLogging(self):
self._logEvents = []
log.addObserver(self._logEvents.append)
self.addCleanup(log.removeObserver, self._logEvents.append)
def assertLogged(self, *args):
for regexp in args:
r = re.compile(regexp)
for event in self._logEvents:
msg = log.textFromEventDict(event)
if msg is not None and r.search(msg):
return
self.fail(
"%r not matched in log output.\n%s " % (regexp, self._logEvents))
def assertWasQuiet(self):
self.assertEqual(self._logEvents, [])
class StdoutAssertionsMixin(object):
"""
Mix this in to be able to assert on stdout during the test
"""
def setUpStdoutAssertions(self):
#
# sys.stdout is implemented differently
# in Python 2 and Python 3, so we need to
# override it differently.
# In Python 2, sys.stdout is a byte stream.
# In Python 3, sys.stdout is a text stream.
if PY3:
self.stdout = StringIO()
else:
self.stdout = BytesIO()
self.patch(sys, 'stdout', self.stdout)
def assertWasQuiet(self):
self.assertEqual(self.stdout.getvalue(), '')
def assertInStdout(self, exp):
self.assertIn(exp, self.stdout.getvalue())
def assertStdoutEqual(self, exp, msg=None):
self.assertEqual(exp, self.stdout.getvalue(), msg)
def getStdout(self):
return self.stdout.getvalue().strip()
|
gpl-2.0
|
[
3,
961,
570,
365,
1777,
402,
6516,
3018,
14,
221,
6516,
3018,
365,
2867,
2032,
26,
1265,
883,
199,
3,
3604,
652,
436,
15,
269,
2811,
652,
1334,
314,
2895,
402,
314,
1664,
1696,
1684,
199,
3,
844,
465,
3267,
701,
314,
2868,
2290,
2752,
12,
1015,
499,
14,
199,
3,
199,
3,
961,
2240,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
1325,
2428,
199,
3,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
3169,
503,
3092,
199,
3,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
1664,
1696,
1684,
844,
367,
1655,
199,
3,
2436,
14,
199,
3,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
1696,
1684,
844,
3180,
543,
199,
3,
642,
2240,
27,
340,
440,
12,
2218,
370,
314,
2868,
2290,
2752,
12,
3277,
2020,
8026,
199,
3,
11236,
14259,
12,
12066,
11844,
12,
8226,
12,
4828,
11315,
13,
10067,
8217,
14,
199,
3,
199,
3,
1898,
6516,
3018,
11682,
14409,
83,
199,
199,
3,
2136,
3913,
675,
314,
12963,
859,
2348,
687,
2018,
13,
14224,
14,
199,
3,
2136,
1929,
370,
675,
314,
5438,
636,
5351,
363,
859,
641,
2018,
499,
12,
199,
3,
436,
12963,
859,
641,
2018,
650,
12,
2952,
781,
1929,
370,
4278,
199,
3,
314,
3503,
5438,
1551,
1083,
14,
199,
199,
504,
636,
2443,
363,
492,
3679,
63,
646,
199,
504,
636,
2443,
363,
492,
870,
63,
1593,
199,
504,
6466,
14,
1208,
492,
7843,
19,
199,
504,
6466,
14,
1208,
492,
1059,
63,
1313,
199,
199,
646,
7554,
199,
646,
747,
199,
646,
295,
199,
646,
5145,
199,
646,
984,
199,
504,
5890,
492,
11808,
199,
504,
5890,
492,
5228,
199,
199,
646,
1683,
199,
199,
504,
7390,
14,
1548,
492,
943,
199,
199,
504,
21306,
63,
6599,
14,
6429,
492,
1300,
199,
199,
893,
26,
272,
327,
2018,
499,
272,
492,
636,
5351,
363,
465,
12963,
199,
2590,
3545,
26,
272,
327,
2018,
650,
272,
492,
12963,
421,
199,
318,
12992,
8,
83,
304,
272,
408,
7306,
314,
1627,
1059,
370,
314,
5438,
8057,
1475,
12,
18002,
652,
365,
272,
2575,
315,
3293,
22242,
8057,
1475,
14749,
78,
680,
221,
3645,
642,
370,
1218,
314,
272,
5827,
17513,
315,
376,
26400,
624,
272,
340,
440,
1228,
8,
83,
12,
1059,
63,
1313,
304,
267,
372,
308,
272,
372,
308,
14,
1814,
2258,
78,
297,
747,
14,
19254,
9,
421,
199,
533,
3523,
694,
4256,
8,
785,
304,
339,
408,
18854,
642,
315,
436,
1240,
3613,
1563,
694,
436,
6766,
1563,
694,
370,
663,
1536,
272,
282,
3633,
19380,
543,
282,
536,
1627,
315,
291,
14,
12484,
1041,
339,
347,
3613,
1563,
694,
8,
277,
304,
267,
291,
14,
12484,
275,
298,
396,
13,
12484,
2,
267,
340,
747,
14,
515,
14,
2444,
8,
277,
14,
12484,
304,
288,
5145,
14,
9242,
8,
277,
14,
12484,
9,
339,
347,
6766,
1563,
694,
8,
277,
304,
267,
340,
747,
14,
515,
14,
2444,
8,
277,
14,
12484,
304,
288,
5145,
14,
9242,
8,
277,
14,
12484,
9,
421,
199,
533,
6596,
12678,
3567,
4256,
8,
785,
304,
339,
408,
272,
28438,
367,
4260,
1536,
16991,
1300,
14,
374,
12678,
3567,
342,
805,
272,
408,
339,
347,
3272,
1721,
1831,
12678,
3567,
8,
277,
12,
372,
63,
585,
304,
267,
291,
14,
374,
12678,
3567,
275,
1683,
14,
3346,
8,
1107,
63,
585,
29,
1107,
63,
585,
9,
267,
291,
14,
2068,
8,
1095,
12,
298,
374,
12678,
3567,
401,
291,
14,
374,
12678,
3567,
9,
421,
199,
533,
19292,
281,
4256,
8,
785,
304,
339,
408,
272,
603,
1148,
642,
315,
370,
664,
282,
9284,
4539,
13,
32738,
3371,
316,
3102,
272,
408,
339,
347,
3371,
63,
736,
63,
16040,
8,
277,
12,
8343,
304,
267,
327,
7390,
1159,
283,
2068,
7,
3181,
1133,
2429,
314,
1930,
2382,
376,
2225,
267,
327,
3181,
1133,
2187,
703,
267,
340,
2688,
8,
736,
12,
283,
16040,
735,
288,
291,
14,
2068,
8,
736,
12,
283,
16040,
297,
8343,
9,
267,
587,
26,
288,
347,
9058,
837,
355,
2150,
747,
14,
16040,
288,
291,
14,
12808,
8,
7661,
9,
288,
747,
14,
16040,
275,
8343,
421,
199,
533,
3814,
2090,
4256,
8,
785,
304,
339,
408,
272,
28438,
367,
3371,
316,
1551,
1062,
1586,
342,
436,
2218,
342,
370,
20577,
9512,
272,
473,
15,
47,
5331,
436,
7750,
473,
15,
47,
2552,
14,
272,
408,
339,
347,
3613,
4299,
8,
277,
12,
570,
63,
4407,
628,
5869,
13,
4407,
2349,
267,
408,
267,
3371,
1551,
342,
370,
372,
570,
909,
543,
2741,
4072,
14,
398,
768,
635,
570,
63,
4407,
26,
4072,
626,
911,
506,
2138,
701,
570,
909,
1159,
2892,
1586,
342,
1083,
267,
408,
267,
327,
3645,
1683,
14,
1805,
63,
1490,
342,
370,
1218,
282,
23080,
367,
267,
327,
1551,
1252,
267,
4026,
4299,
275,
1683,
14,
1805,
63,
1490,
8,
739,
63,
576,
29,
493,
63,
4407,
9,
398,
327,
3979,
4026,
4299,
342,
365,
2797,
12,
652,
2529,
282,
4420,
267,
327,
626,
965,
3520,
3102,
26,
1586,
1062,
2218,
1062,
636,
4200,
29709,
636,
2224,
31261,
267,
327,
1586,
342,
911,
3544,
372,
314,
574,
402,
314,
283,
493,
63,
4407,
1750,
14,
267,
291,
14,
9234,
275,
4026,
4299,
342,
398,
327,
3371,
1551,
342,
370,
3544,
372,
4154,
4420,
570,
909,
267,
291,
14,
1490,
275,
1683,
14,
3346,
8,
1107,
63,
585,
29,
277,
14,
9234,
9,
267,
291,
14,
2068,
8,
10372,
12,
298,
1490,
401,
291,
14,
1490,
9,
339,
347,
3613,
4299,
547,
8,
277,
12,
7554,
29,
7931,
14,
20465,
12,
410,
17844,
628,
5869,
13,
1328,
401,
2432,
1788,
628,
5869,
13,
493,
2349,
267,
408,
267,
3371,
1551,
342,
370,
746,
5925,
398,
768,
635,
259,
7554,
26,
1919,
1159,
7554,
574,
267,
768,
635,
410,
17844,
26,
1919,
1159,
410,
17844,
574,
267,
768,
635,
1788,
26,
1919,
1159,
1788,
574,
267,
408,
267,
327,
3645,
1683,
14,
1805,
63,
1490,
342,
370,
1218,
282,
23080,
367,
267,
327,
1551,
1252,
267,
4026,
4299,
275,
1683,
14,
1805,
63,
1490,
342,
398,
327,
2654,
5366,
63,
5881,
880,
626,
6358,
4026,
4299,
342
] |
[
961,
570,
365,
1777,
402,
6516,
3018,
14,
221,
6516,
3018,
365,
2867,
2032,
26,
1265,
883,
199,
3,
3604,
652,
436,
15,
269,
2811,
652,
1334,
314,
2895,
402,
314,
1664,
1696,
1684,
199,
3,
844,
465,
3267,
701,
314,
2868,
2290,
2752,
12,
1015,
499,
14,
199,
3,
199,
3,
961,
2240,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
1325,
2428,
199,
3,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
3169,
503,
3092,
199,
3,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
1664,
1696,
1684,
844,
367,
1655,
199,
3,
2436,
14,
199,
3,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
1696,
1684,
844,
3180,
543,
199,
3,
642,
2240,
27,
340,
440,
12,
2218,
370,
314,
2868,
2290,
2752,
12,
3277,
2020,
8026,
199,
3,
11236,
14259,
12,
12066,
11844,
12,
8226,
12,
4828,
11315,
13,
10067,
8217,
14,
199,
3,
199,
3,
1898,
6516,
3018,
11682,
14409,
83,
199,
199,
3,
2136,
3913,
675,
314,
12963,
859,
2348,
687,
2018,
13,
14224,
14,
199,
3,
2136,
1929,
370,
675,
314,
5438,
636,
5351,
363,
859,
641,
2018,
499,
12,
199,
3,
436,
12963,
859,
641,
2018,
650,
12,
2952,
781,
1929,
370,
4278,
199,
3,
314,
3503,
5438,
1551,
1083,
14,
199,
199,
504,
636,
2443,
363,
492,
3679,
63,
646,
199,
504,
636,
2443,
363,
492,
870,
63,
1593,
199,
504,
6466,
14,
1208,
492,
7843,
19,
199,
504,
6466,
14,
1208,
492,
1059,
63,
1313,
199,
199,
646,
7554,
199,
646,
747,
199,
646,
295,
199,
646,
5145,
199,
646,
984,
199,
504,
5890,
492,
11808,
199,
504,
5890,
492,
5228,
199,
199,
646,
1683,
199,
199,
504,
7390,
14,
1548,
492,
943,
199,
199,
504,
21306,
63,
6599,
14,
6429,
492,
1300,
199,
199,
893,
26,
272,
327,
2018,
499,
272,
492,
636,
5351,
363,
465,
12963,
199,
2590,
3545,
26,
272,
327,
2018,
650,
272,
492,
12963,
421,
199,
318,
12992,
8,
83,
304,
272,
408,
7306,
314,
1627,
1059,
370,
314,
5438,
8057,
1475,
12,
18002,
652,
365,
272,
2575,
315,
3293,
22242,
8057,
1475,
14749,
78,
680,
221,
3645,
642,
370,
1218,
314,
272,
5827,
17513,
315,
376,
26400,
624,
272,
340,
440,
1228,
8,
83,
12,
1059,
63,
1313,
304,
267,
372,
308,
272,
372,
308,
14,
1814,
2258,
78,
297,
747,
14,
19254,
9,
421,
199,
533,
3523,
694,
4256,
8,
785,
304,
339,
408,
18854,
642,
315,
436,
1240,
3613,
1563,
694,
436,
6766,
1563,
694,
370,
663,
1536,
272,
282,
3633,
19380,
543,
282,
536,
1627,
315,
291,
14,
12484,
1041,
339,
347,
3613,
1563,
694,
8,
277,
304,
267,
291,
14,
12484,
275,
298,
396,
13,
12484,
2,
267,
340,
747,
14,
515,
14,
2444,
8,
277,
14,
12484,
304,
288,
5145,
14,
9242,
8,
277,
14,
12484,
9,
339,
347,
6766,
1563,
694,
8,
277,
304,
267,
340,
747,
14,
515,
14,
2444,
8,
277,
14,
12484,
304,
288,
5145,
14,
9242,
8,
277,
14,
12484,
9,
421,
199,
533,
6596,
12678,
3567,
4256,
8,
785,
304,
339,
408,
272,
28438,
367,
4260,
1536,
16991,
1300,
14,
374,
12678,
3567,
342,
805,
272,
408,
339,
347,
3272,
1721,
1831,
12678,
3567,
8,
277,
12,
372,
63,
585,
304,
267,
291,
14,
374,
12678,
3567,
275,
1683,
14,
3346,
8,
1107,
63,
585,
29,
1107,
63,
585,
9,
267,
291,
14,
2068,
8,
1095,
12,
298,
374,
12678,
3567,
401,
291,
14,
374,
12678,
3567,
9,
421,
199,
533,
19292,
281,
4256,
8,
785,
304,
339,
408,
272,
603,
1148,
642,
315,
370,
664,
282,
9284,
4539,
13,
32738,
3371,
316,
3102,
272,
408,
339,
347,
3371,
63,
736,
63,
16040,
8,
277,
12,
8343,
304,
267,
327,
7390,
1159,
283,
2068,
7,
3181,
1133,
2429,
314,
1930,
2382,
376,
2225,
267,
327,
3181,
1133,
2187,
703,
267,
340,
2688,
8,
736,
12,
283,
16040,
735,
288,
291,
14,
2068,
8,
736,
12,
283,
16040,
297,
8343,
9,
267,
587,
26,
288,
347,
9058,
837,
355,
2150,
747,
14,
16040,
288,
291,
14,
12808,
8,
7661,
9,
288,
747,
14,
16040,
275,
8343,
421,
199,
533,
3814,
2090,
4256,
8,
785,
304,
339,
408,
272,
28438,
367,
3371,
316,
1551,
1062,
1586,
342,
436,
2218,
342,
370,
20577,
9512,
272,
473,
15,
47,
5331,
436,
7750,
473,
15,
47,
2552,
14,
272,
408,
339,
347,
3613,
4299,
8,
277,
12,
570,
63,
4407,
628,
5869,
13,
4407,
2349,
267,
408,
267,
3371,
1551,
342,
370,
372,
570,
909,
543,
2741,
4072,
14,
398,
768,
635,
570,
63,
4407,
26,
4072,
626,
911,
506,
2138,
701,
570,
909,
1159,
2892,
1586,
342,
1083,
267,
408,
267,
327,
3645,
1683,
14,
1805,
63,
1490,
342,
370,
1218,
282,
23080,
367,
267,
327,
1551,
1252,
267,
4026,
4299,
275,
1683,
14,
1805,
63,
1490,
8,
739,
63,
576,
29,
493,
63,
4407,
9,
398,
327,
3979,
4026,
4299,
342,
365,
2797,
12,
652,
2529,
282,
4420,
267,
327,
626,
965,
3520,
3102,
26,
1586,
1062,
2218,
1062,
636,
4200,
29709,
636,
2224,
31261,
267,
327,
1586,
342,
911,
3544,
372,
314,
574,
402,
314,
283,
493,
63,
4407,
1750,
14,
267,
291,
14,
9234,
275,
4026,
4299,
342,
398,
327,
3371,
1551,
342,
370,
3544,
372,
4154,
4420,
570,
909,
267,
291,
14,
1490,
275,
1683,
14,
3346,
8,
1107,
63,
585,
29,
277,
14,
9234,
9,
267,
291,
14,
2068,
8,
10372,
12,
298,
1490,
401,
291,
14,
1490,
9,
339,
347,
3613,
4299,
547,
8,
277,
12,
7554,
29,
7931,
14,
20465,
12,
410,
17844,
628,
5869,
13,
1328,
401,
2432,
1788,
628,
5869,
13,
493,
2349,
267,
408,
267,
3371,
1551,
342,
370,
746,
5925,
398,
768,
635,
259,
7554,
26,
1919,
1159,
7554,
574,
267,
768,
635,
410,
17844,
26,
1919,
1159,
410,
17844,
574,
267,
768,
635,
1788,
26,
1919,
1159,
1788,
574,
267,
408,
267,
327,
3645,
1683,
14,
1805,
63,
1490,
342,
370,
1218,
282,
23080,
367,
267,
327,
1551,
1252,
267,
4026,
4299,
275,
1683,
14,
1805,
63,
1490,
342,
398,
327,
2654,
5366,
63,
5881,
880,
626,
6358,
4026,
4299,
342,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_writer.py
|
16
|
11959
|
from __future__ import absolute_import
import re
from cStringIO import StringIO
from datetime import datetime, date, timedelta
from psycopg2.extensions import QuotedString, Binary, AsIs
class PostgresWriter(object):
"""Base class for :py:class:`mysql2pgsql.lib.postgres_file_writer.PostgresFileWriter`
and :py:class:`mysql2pgsql.lib.postgres_db_writer.PostgresDbWriter`.
"""
def __init__(self):
self.column_types = {}
def column_description(self, column):
return '"%s" %s' % (column['name'], self.column_type_info(column))
def column_type(self, column):
hash_key = hash(frozenset(column.items()))
self.column_types[hash_key] = self.column_type_info(column).split(" ")[0]
return self.column_types[hash_key]
def column_type_info(self, column):
"""
"""
if column.get('auto_increment', None):
return 'integer DEFAULT nextval(\'%s_%s_seq\'::regclass) NOT NULL' % (
column['table_name'], column['name'])
null = "" if column['null'] else " NOT NULL"
def get_type(column):
"""This in conjunction with :py:class:`mysql2pgsql.lib.mysql_reader.MysqlReader._convert_type`
determines the PostgreSQL data type. In my opinion this is way too fugly, will need
to refactor one day.
"""
t = lambda v: not v == None
default = (' DEFAULT %s' % QuotedString(column['default']).getquoted()) if t(column['default']) else None
if column['type'] == 'char':
default = ('%s::char' % default) if t(default) else None
return default, 'character(%s)' % column['length']
elif column['type'] == 'varchar':
default = ('%s::character varying' % default) if t(default) else None
return default, 'character varying(%s)' % column['length']
elif column['type'] == 'integer':
default = (" DEFAULT %s" % (column['default'] if t(column['default']) else 'NULL')) if t(default) else None
return default, 'integer'
elif column['type'] == 'bigint':
default = (" DEFAULT %s" % (column['default'] if t(column['default']) else 'NULL')) if t(default) else None
return default, 'bigint'
elif column['type'] == 'tinyint':
default = (" DEFAULT %s" % (column['default'] if t(column['default']) else 'NULL')) if t(default) else None
return default, 'smallint'
elif column['type'] == 'boolean':
default = (" DEFAULT %s" % ('true' if int(column['default']) == 1 else 'false')) if t(default) else None
return default, 'boolean'
elif column['type'] == 'float':
default = (" DEFAULT %s" % (column['default'] if t(column['default']) else 'NULL')) if t(default) else None
return default, 'real'
elif column['type'] == 'float unsigned':
default = (" DEFAULT %s" % (column['default'] if t(column['default']) else 'NULL')) if t(default) else None
return default, 'real'
elif column['type'] in ('numeric', 'decimal'):
default = (" DEFAULT %s" % (column['default'] if t(column['default']) else 'NULL')) if t(default) else None
return default, 'numeric(%s, %s)' % (column['length'] or 20, column['decimals'] or 0)
elif column['type'] == 'double precision':
default = (" DEFAULT %s" % (column['default'] if t(column['default']) else 'NULL')) if t(default) else None
return default, 'double precision'
elif column['type'] == 'datetime':
default = None
return default, 'timestamp without time zone'
elif column['type'] == 'date':
default = None
return default, 'date'
elif column['type'] == 'timestamp':
if "CURRENT_TIMESTAMP" in column['default']:
default = ' DEFAULT CURRENT_TIMESTAMP'
if "0000-00-00 00:00" in column['default']:
default = " DEFAULT '1970-01-01 00:00'"
if "0000-00-00 00:00:00" in column['default']:
default = " DEFAULT '1970-01-01 00:00:00'"
return default, 'timestamp without time zone'
elif column['type'] == 'time':
default = " DEFAULT NOW()" if t(default) else None
return default, 'time without time zone'
elif 'blob' in column['type'] or 'binary' in column['type']:
return default, 'bytea'
elif column['type'] in ('tinytext', 'mediumtext', 'longtext', 'text'):
return default, 'text'
elif re.search(r'^enum', column['type']):
default = (' %s::character varying' % default) if t(default) else None
enum = re.sub(r'enum|\(|\)', '', column['type'])
max_enum_size = max([(len(e) - 2) for e in enum.split(',')])
return default, ' character varying(%s) check(%s in (%s))' % (max_enum_size, column['name'], enum)
elif 'bit(' in column['type']:
return ' DEFAULT %s' % column['default'].upper() if column['default'] else column['default'], 'varbit(%s)' % re.search(r'\((\d+)\)', column['type']).group(1)
elif 'set(' in column['type']:
if default:
default = ' DEFAULT ARRAY[%s]::text[]' % ','.join(QuotedString(v).getquoted() for v in re.search(r"'(.*)'", default).group(1).split(','))
return default, 'text[]'
else:
raise Exception('unknown %s' % column['type'])
default, column_type = get_type(column)
return '%s%s%s' % (column_type, (default if not default == None else ''), null)
def process_row(self, table, row):
"""Examines row data from MySQL and alters
the values when necessary to be compatible with
sending to PostgreSQL via the copy command
"""
for index, column in enumerate(table.columns):
hash_key = hash(frozenset(column.items()))
column_type = self.column_types[hash_key] if hash_key in self.column_types else self.column_type(column)
if row[index] == None and ('timestamp' not in column_type or not column['default']):
row[index] = '\N'
elif row[index] == None and column['default']:
row[index] = '1970-01-01 00:00:00'
elif 'bit' in column_type:
row[index] = bin(ord(row[index]))[2:]
elif isinstance(row[index], (str, unicode, basestring)):
if column_type == 'bytea':
row[index] = Binary(row[index]).getquoted()[1:-8] if row[index] else row[index]
elif 'text[' in column_type:
row[index] = '{%s}' % ','.join('"%s"' % v.replace('"', r'\"') for v in row[index].split(','))
else:
row[index] = row[index].replace('\\', r'\\').replace('\n', r'\n').replace('\t', r'\t').replace('\r', r'\r').replace('\0', '')
elif column_type == 'boolean':
# We got here because you used a tinyint(1), if you didn't want a bool, don't use that type
row[index] = 't' if row[index] not in (None, 0) else 'f' if row[index] == 0 else row[index]
elif isinstance(row[index], (date, datetime)):
row[index] = row[index].isoformat()
elif isinstance(row[index], timedelta):
row[index] = datetime.utcfromtimestamp(row[index].total_seconds()).time().isoformat()
else:
row[index] = AsIs(row[index]).getquoted()
def table_attributes(self, table):
primary_keys = []
serial_key = None
maxval = None
columns = StringIO()
for column in table.columns:
if column['auto_increment']:
serial_key = column['name']
maxval = 1 if column['maxval'] < 1 else column['maxval'] + 1
if column['primary_key']:
primary_keys.append(column['name'])
columns.write(' %s,\n' % self.column_description(column))
return primary_keys, serial_key, maxval, columns.getvalue()[:-2]
def truncate(self, table):
serial_key = None
maxval = None
for column in table.columns:
if column['auto_increment']:
serial_key = column['name']
maxval = 1 if column['maxval'] < 1 else column['maxval'] + 1
truncate_sql = 'TRUNCATE "%s" CASCADE;' % table.name
serial_key_sql = None
if serial_key:
serial_key_sql = "SELECT pg_catalog.setval(pg_get_serial_sequence(%(table_name)s, %(serial_key)s), %(maxval)s, true);" % {
'table_name': QuotedString(table.name).getquoted(),
'serial_key': QuotedString(serial_key).getquoted(),
'maxval': maxval}
return (truncate_sql, serial_key_sql)
def write_table(self, table):
primary_keys, serial_key, maxval, columns = self.table_attributes(table)
serial_key_sql = []
table_sql = []
if serial_key:
serial_key_seq = '%s_%s_seq' % (table.name, serial_key)
serial_key_sql.append('DROP SEQUENCE IF EXISTS %s CASCADE;' % serial_key_seq)
serial_key_sql.append("""CREATE SEQUENCE %s INCREMENT BY 1
NO MAXVALUE NO MINVALUE CACHE 1;""" % serial_key_seq)
serial_key_sql.append('SELECT pg_catalog.setval(%s, %s, true);' % (QuotedString(serial_key_seq).getquoted(), maxval))
table_sql.append('DROP TABLE IF EXISTS "%s" CASCADE;' % table.name)
table_sql.append('CREATE TABLE "%s" (\n%s\n)\nWITHOUT OIDS;' % (table.name, columns))
return (table_sql, serial_key_sql)
def write_indexes(self, table):
index_sql = []
primary_index = [idx for idx in table.indexes if idx.get('primary', None)]
if primary_index:
index_sql.append('ALTER TABLE "%(table_name)s" ADD CONSTRAINT "%(index_name)s_pkey" PRIMARY KEY(%(column_names)s);' % {
'table_name': table.name,
'index_name': '%s_%s' % (table.name, '_'.join(re.sub('[\W]+', '', c) for c in primary_index[0]['columns'])),
'column_names': ', '.join('%s' % col for col in primary_index[0]['columns']),
})
for index in table.indexes:
if 'primary' in index:
continue
unique = 'UNIQUE ' if index.get('unique', None) else ''
index_name = '%s_%s' % (table.name, '_'.join(index['columns']))
index_sql.append('DROP INDEX IF EXISTS "%s" CASCADE;' % index_name)
index_sql.append('CREATE %(unique)sINDEX "%(index_name)s" ON "%(table_name)s" (%(column_names)s);' % {
'unique': unique,
'index_name': index_name,
'table_name': table.name,
'column_names': ', '.join('"%s"' % col for col in index['columns']),
})
return index_sql
def write_constraints(self, table):
constraint_sql = []
for key in table.foreign_keys:
constraint_sql.append("""ALTER TABLE "%(table_name)s" ADD FOREIGN KEY ("%(column_name)s")
REFERENCES "%(ref_table_name)s"(%(ref_column_name)s);""" % {
'table_name': table.name,
'column_name': key['column'],
'ref_table_name': key['ref_table'],
'ref_column_name': key['ref_column']})
return constraint_sql
def close(self):
raise NotImplementedError
def write_contents(self, table, reader):
raise NotImplementedError
|
bsd-3-clause
|
[
504,
636,
2443,
363,
492,
3679,
63,
646,
199,
199,
646,
295,
199,
504,
15073,
492,
5228,
199,
504,
2197,
492,
2197,
12,
1434,
12,
6871,
199,
199,
504,
15492,
18,
14,
5359,
492,
5843,
5731,
1558,
12,
14161,
12,
3709,
1831,
421,
199,
533,
7711,
7266,
6261,
8,
785,
304,
272,
408,
1563,
1021,
367,
520,
647,
26,
533,
1705,
8644,
18,
80,
458,
1710,
14,
773,
14,
10675,
63,
493,
63,
5491,
14,
6564,
7266,
28199,
64,
272,
436,
520,
647,
26,
533,
1705,
8644,
18,
80,
458,
1710,
14,
773,
14,
10675,
63,
697,
63,
5491,
14,
6564,
7266,
8882,
6261,
2313,
272,
408,
272,
347,
636,
826,
721,
277,
304,
267,
291,
14,
2301,
63,
1313,
275,
1052,
339,
347,
2763,
63,
1802,
8,
277,
12,
2763,
304,
267,
372,
18253,
83,
2,
450,
83,
7,
450,
334,
2301,
459,
354,
995,
291,
14,
2301,
63,
466,
63,
815,
8,
2301,
430,
339,
347,
2763,
63,
466,
8,
277,
12,
2763,
304,
267,
2631,
63,
498,
275,
2631,
8,
21362,
8,
2301,
14,
1744,
4059,
267,
291,
14,
2301,
63,
1313,
59,
2227,
63,
498,
61,
275,
291,
14,
2301,
63,
466,
63,
815,
8,
2301,
680,
1294,
480,
298,
2788,
16,
61,
267,
372,
291,
14,
2301,
63,
1313,
59,
2227,
63,
498,
61,
339,
347,
2763,
63,
466,
63,
815,
8,
277,
12,
2763,
304,
267,
408,
267,
408,
267,
340,
2763,
14,
362,
360,
2495,
63,
9728,
297,
488,
304,
288,
372,
283,
4115,
6186,
2163,
637,
2961,
5956,
83,
4970,
83,
63,
3610,
60,
356,
26,
1135,
533,
9,
2845,
5962,
7,
450,
334,
673,
2763,
459,
1224,
63,
354,
995,
2763,
459,
354,
1105,
398,
2973,
275,
3087,
340,
2763,
459,
2307,
418,
587,
298,
2845,
5962,
2,
398,
347,
664,
63,
466,
8,
2301,
304,
288,
408,
2765,
315,
22888,
543,
520,
647,
26,
533,
1705,
8644,
18,
80,
458,
1710,
14,
773,
14,
8644,
63,
5503,
14,
45,
6398,
5929,
423,
3916,
63,
466,
64,
288,
16756,
314,
20175,
666,
730,
14,
1010,
3002,
1687,
262,
1636,
642,
365,
4340,
4634,
289,
1518,
590,
12,
911,
1929,
288,
370,
24200,
1373,
5382,
14,
288,
408,
288,
307,
275,
2400,
373,
26,
440,
373,
508,
488,
288,
849,
275,
661,
6186,
450,
83,
7,
450,
5843,
5731,
1558,
8,
2301,
459,
885,
13227,
362,
9888,
1012,
340,
307,
8,
2301,
459,
885,
1105,
587,
488,
953,
340,
2763,
459,
466,
418,
508,
283,
1560,
356,
355,
849,
275,
16651,
83,
447,
1560,
7,
450,
849,
9,
340,
307,
8,
885,
9,
587,
488,
355,
372,
849,
12,
283,
10856,
4042,
83,
3171,
450,
2763,
459,
1267,
418,
288,
916,
2763,
459,
466,
418,
508,
283,
25545,
356,
355,
849,
275,
16651,
83,
447,
10856,
17083,
316,
7,
450,
849,
9,
340,
307,
8,
885,
9,
587,
488,
355,
372,
849,
12,
283,
10856,
17083,
316,
4042,
83,
3171,
450,
2763,
459,
1267,
418,
288,
916,
2763,
459,
466,
418,
508,
283,
4115,
356,
355,
849,
275,
1689,
6186,
450,
83,
2,
450,
334,
2301,
459,
885,
418,
340,
307,
8,
2301,
459,
885,
1105,
587,
283,
8084,
1333,
340,
307,
8,
885,
9,
587,
488,
355,
372,
849,
12,
283,
4115,
7,
288,
916,
2763,
459,
466,
418,
508,
283,
24884,
356,
355,
849,
275,
1689,
6186,
450,
83,
2,
450,
334,
2301,
459,
885,
418,
340,
307,
8,
2301,
459,
885,
1105,
587,
283,
8084,
1333,
340,
307,
8,
885,
9,
587,
488,
355,
372,
849,
12,
283,
24884,
7,
288,
916,
2763,
459,
466,
418,
508,
283,
9864,
442,
356,
355,
849,
275,
1689,
6186,
450,
83,
2,
450,
334,
2301,
459,
885,
418,
340,
307,
8,
2301,
459,
885,
1105,
587,
283,
8084,
1333,
340,
307,
8,
885,
9,
587,
488,
355,
372,
849,
12,
283,
7241,
442,
7,
288,
916,
2763,
459,
466,
418,
508,
283,
4871,
356,
355,
849,
275,
1689,
6186,
450,
83,
2,
450,
661,
2052,
7,
340,
1109,
8,
2301,
459,
885,
1105,
508,
413,
587,
283,
3910,
1333,
340,
307,
8,
885,
9,
587,
488,
355,
372,
849,
12,
283,
4871,
7,
288,
916,
2763,
459,
466,
418,
508,
283,
1609,
356,
355,
849,
275,
1689,
6186,
450,
83,
2,
450,
334,
2301,
459,
885,
418,
340,
307,
8,
2301,
459,
885,
1105,
587,
283,
8084,
1333,
340,
307,
8,
885,
9,
587,
488,
355,
372,
849,
12,
283,
3093,
7,
288,
916,
2763,
459,
466,
418,
508,
283,
1609,
7381,
356,
355,
849,
275,
1689,
6186,
450,
83,
2,
450,
334,
2301,
459,
885,
418,
340,
307,
8,
2301,
459,
885,
1105,
587,
283,
8084,
1333,
340,
307,
8,
885,
9,
587,
488,
355,
372,
849,
12,
283,
3093,
7,
288,
916,
2763,
459,
466,
418,
315,
661,
6677,
297,
283,
6355,
735,
355,
849,
275,
1689,
6186,
450,
83,
2,
450,
334,
2301,
459,
885,
418,
340,
307,
8,
2301,
459,
885,
1105,
587,
283,
8084,
1333,
340,
307,
8,
885,
9,
587,
488,
355,
372,
849,
12,
283,
6677,
4042,
83,
12,
450,
83,
3171,
450,
334,
2301,
459,
1267,
418,
503,
3388,
12,
2763,
459,
6355,
83,
418,
503,
378,
9,
288,
916,
2763,
459,
466,
418,
508,
283,
3157,
7151,
356,
355,
849,
275,
1689,
6186,
450,
83,
2,
450,
334,
2301,
459,
885,
418,
340,
307,
8,
2301,
459,
885,
1105,
587,
283,
8084,
1333,
340,
307,
8,
885,
9,
587,
488,
355,
372,
849,
12,
283,
3157,
7151,
7,
288,
916,
2763,
459,
466,
418,
508,
283,
2083,
356,
355,
849,
275,
488,
355,
372,
849,
12,
283,
3954,
1928,
900,
5718,
7,
288,
916,
2763,
459,
466,
418,
508,
283,
602,
356,
355,
849,
275,
488,
355,
372,
849,
12,
283,
602,
7,
288,
916,
2763,
459,
466,
418,
508,
283,
3954,
356,
355,
340,
298,
14211,
63,
20277,
2,
315,
2763,
459,
885,
2565,
490,
849,
275,
283,
6186,
27946,
63,
20277,
7,
355,
340,
298,
993,
13,
383,
13,
383,
8733,
26,
383,
2,
315,
221,
2763,
459,
885,
2565,
490,
849,
275,
298,
6186,
283,
21740,
13,
614,
13,
614,
8733,
26,
383,
4065
] |
[
636,
2443,
363,
492,
3679,
63,
646,
199,
199,
646,
295,
199,
504,
15073,
492,
5228,
199,
504,
2197,
492,
2197,
12,
1434,
12,
6871,
199,
199,
504,
15492,
18,
14,
5359,
492,
5843,
5731,
1558,
12,
14161,
12,
3709,
1831,
421,
199,
533,
7711,
7266,
6261,
8,
785,
304,
272,
408,
1563,
1021,
367,
520,
647,
26,
533,
1705,
8644,
18,
80,
458,
1710,
14,
773,
14,
10675,
63,
493,
63,
5491,
14,
6564,
7266,
28199,
64,
272,
436,
520,
647,
26,
533,
1705,
8644,
18,
80,
458,
1710,
14,
773,
14,
10675,
63,
697,
63,
5491,
14,
6564,
7266,
8882,
6261,
2313,
272,
408,
272,
347,
636,
826,
721,
277,
304,
267,
291,
14,
2301,
63,
1313,
275,
1052,
339,
347,
2763,
63,
1802,
8,
277,
12,
2763,
304,
267,
372,
18253,
83,
2,
450,
83,
7,
450,
334,
2301,
459,
354,
995,
291,
14,
2301,
63,
466,
63,
815,
8,
2301,
430,
339,
347,
2763,
63,
466,
8,
277,
12,
2763,
304,
267,
2631,
63,
498,
275,
2631,
8,
21362,
8,
2301,
14,
1744,
4059,
267,
291,
14,
2301,
63,
1313,
59,
2227,
63,
498,
61,
275,
291,
14,
2301,
63,
466,
63,
815,
8,
2301,
680,
1294,
480,
298,
2788,
16,
61,
267,
372,
291,
14,
2301,
63,
1313,
59,
2227,
63,
498,
61,
339,
347,
2763,
63,
466,
63,
815,
8,
277,
12,
2763,
304,
267,
408,
267,
408,
267,
340,
2763,
14,
362,
360,
2495,
63,
9728,
297,
488,
304,
288,
372,
283,
4115,
6186,
2163,
637,
2961,
5956,
83,
4970,
83,
63,
3610,
60,
356,
26,
1135,
533,
9,
2845,
5962,
7,
450,
334,
673,
2763,
459,
1224,
63,
354,
995,
2763,
459,
354,
1105,
398,
2973,
275,
3087,
340,
2763,
459,
2307,
418,
587,
298,
2845,
5962,
2,
398,
347,
664,
63,
466,
8,
2301,
304,
288,
408,
2765,
315,
22888,
543,
520,
647,
26,
533,
1705,
8644,
18,
80,
458,
1710,
14,
773,
14,
8644,
63,
5503,
14,
45,
6398,
5929,
423,
3916,
63,
466,
64,
288,
16756,
314,
20175,
666,
730,
14,
1010,
3002,
1687,
262,
1636,
642,
365,
4340,
4634,
289,
1518,
590,
12,
911,
1929,
288,
370,
24200,
1373,
5382,
14,
288,
408,
288,
307,
275,
2400,
373,
26,
440,
373,
508,
488,
288,
849,
275,
661,
6186,
450,
83,
7,
450,
5843,
5731,
1558,
8,
2301,
459,
885,
13227,
362,
9888,
1012,
340,
307,
8,
2301,
459,
885,
1105,
587,
488,
953,
340,
2763,
459,
466,
418,
508,
283,
1560,
356,
355,
849,
275,
16651,
83,
447,
1560,
7,
450,
849,
9,
340,
307,
8,
885,
9,
587,
488,
355,
372,
849,
12,
283,
10856,
4042,
83,
3171,
450,
2763,
459,
1267,
418,
288,
916,
2763,
459,
466,
418,
508,
283,
25545,
356,
355,
849,
275,
16651,
83,
447,
10856,
17083,
316,
7,
450,
849,
9,
340,
307,
8,
885,
9,
587,
488,
355,
372,
849,
12,
283,
10856,
17083,
316,
4042,
83,
3171,
450,
2763,
459,
1267,
418,
288,
916,
2763,
459,
466,
418,
508,
283,
4115,
356,
355,
849,
275,
1689,
6186,
450,
83,
2,
450,
334,
2301,
459,
885,
418,
340,
307,
8,
2301,
459,
885,
1105,
587,
283,
8084,
1333,
340,
307,
8,
885,
9,
587,
488,
355,
372,
849,
12,
283,
4115,
7,
288,
916,
2763,
459,
466,
418,
508,
283,
24884,
356,
355,
849,
275,
1689,
6186,
450,
83,
2,
450,
334,
2301,
459,
885,
418,
340,
307,
8,
2301,
459,
885,
1105,
587,
283,
8084,
1333,
340,
307,
8,
885,
9,
587,
488,
355,
372,
849,
12,
283,
24884,
7,
288,
916,
2763,
459,
466,
418,
508,
283,
9864,
442,
356,
355,
849,
275,
1689,
6186,
450,
83,
2,
450,
334,
2301,
459,
885,
418,
340,
307,
8,
2301,
459,
885,
1105,
587,
283,
8084,
1333,
340,
307,
8,
885,
9,
587,
488,
355,
372,
849,
12,
283,
7241,
442,
7,
288,
916,
2763,
459,
466,
418,
508,
283,
4871,
356,
355,
849,
275,
1689,
6186,
450,
83,
2,
450,
661,
2052,
7,
340,
1109,
8,
2301,
459,
885,
1105,
508,
413,
587,
283,
3910,
1333,
340,
307,
8,
885,
9,
587,
488,
355,
372,
849,
12,
283,
4871,
7,
288,
916,
2763,
459,
466,
418,
508,
283,
1609,
356,
355,
849,
275,
1689,
6186,
450,
83,
2,
450,
334,
2301,
459,
885,
418,
340,
307,
8,
2301,
459,
885,
1105,
587,
283,
8084,
1333,
340,
307,
8,
885,
9,
587,
488,
355,
372,
849,
12,
283,
3093,
7,
288,
916,
2763,
459,
466,
418,
508,
283,
1609,
7381,
356,
355,
849,
275,
1689,
6186,
450,
83,
2,
450,
334,
2301,
459,
885,
418,
340,
307,
8,
2301,
459,
885,
1105,
587,
283,
8084,
1333,
340,
307,
8,
885,
9,
587,
488,
355,
372,
849,
12,
283,
3093,
7,
288,
916,
2763,
459,
466,
418,
315,
661,
6677,
297,
283,
6355,
735,
355,
849,
275,
1689,
6186,
450,
83,
2,
450,
334,
2301,
459,
885,
418,
340,
307,
8,
2301,
459,
885,
1105,
587,
283,
8084,
1333,
340,
307,
8,
885,
9,
587,
488,
355,
372,
849,
12,
283,
6677,
4042,
83,
12,
450,
83,
3171,
450,
334,
2301,
459,
1267,
418,
503,
3388,
12,
2763,
459,
6355,
83,
418,
503,
378,
9,
288,
916,
2763,
459,
466,
418,
508,
283,
3157,
7151,
356,
355,
849,
275,
1689,
6186,
450,
83,
2,
450,
334,
2301,
459,
885,
418,
340,
307,
8,
2301,
459,
885,
1105,
587,
283,
8084,
1333,
340,
307,
8,
885,
9,
587,
488,
355,
372,
849,
12,
283,
3157,
7151,
7,
288,
916,
2763,
459,
466,
418,
508,
283,
2083,
356,
355,
849,
275,
488,
355,
372,
849,
12,
283,
3954,
1928,
900,
5718,
7,
288,
916,
2763,
459,
466,
418,
508,
283,
602,
356,
355,
849,
275,
488,
355,
372,
849,
12,
283,
602,
7,
288,
916,
2763,
459,
466,
418,
508,
283,
3954,
356,
355,
340,
298,
14211,
63,
20277,
2,
315,
2763,
459,
885,
2565,
490,
849,
275,
283,
6186,
27946,
63,
20277,
7,
355,
340,
298,
993,
13,
383,
13,
383,
8733,
26,
383,
2,
315,
221,
2763,
459,
885,
2565,
490,
849,
275,
298,
6186,
283,
21740,
13,
614,
13,
614,
8733,
26,
383,
4065,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
skmezanul/seahub
|
seahub/auth/admin.py
|
40
|
6068
|
from django import template
from django.db import transaction
from django.conf import settings
from django.contrib import admin
from django.contrib.auth.forms import UserCreationForm, UserChangeForm, AdminPasswordChangeForm
from django.contrib.auth.models import User, Group
from django.contrib import messages
from django.core.exceptions import PermissionDenied
from django.http import HttpResponseRedirect, Http404
from django.shortcuts import render_to_response, get_object_or_404
from django.template import RequestContext
from django.utils.html import escape
from django.utils.decorators import method_decorator
from django.utils.translation import ugettext, ugettext_lazy as _
from django.views.decorators.csrf import csrf_protect
csrf_protect_m = method_decorator(csrf_protect)
class GroupAdmin(admin.ModelAdmin):
search_fields = ('name',)
ordering = ('name',)
filter_horizontal = ('permissions',)
class UserAdmin(admin.ModelAdmin):
add_form_template = 'admin/auth/user/add_form.html'
change_user_password_template = None
fieldsets = (
(None, {'fields': ('username', 'password')}),
(_('Personal info'), {'fields': ('first_name', 'last_name', 'email')}),
(_('Permissions'), {'fields': ('is_active', 'is_staff', 'is_superuser', 'user_permissions')}),
(_('Important dates'), {'fields': ('last_login', 'date_joined')}),
(_('Groups'), {'fields': ('groups',)}),
)
add_fieldsets = (
(None, {
'classes': ('wide',),
'fields': ('username', 'password1', 'password2')}
),
)
form = UserChangeForm
add_form = UserCreationForm
change_password_form = AdminPasswordChangeForm
list_display = ('username', 'email', 'first_name', 'last_name', 'is_staff')
list_filter = ('is_staff', 'is_superuser', 'is_active')
search_fields = ('username', 'first_name', 'last_name', 'email')
ordering = ('username',)
filter_horizontal = ('user_permissions',)
def __call__(self, request, url):
# this should not be here, but must be due to the way __call__ routes
# in ModelAdmin.
if url is None:
return self.changelist_view(request)
if url.endswith('password'):
return self.user_change_password(request, url.split('/')[0])
return super(UserAdmin, self).__call__(request, url)
def get_fieldsets(self, request, obj=None):
if not obj:
return self.add_fieldsets
return super(UserAdmin, self).get_fieldsets(request, obj)
def get_form(self, request, obj=None, **kwargs):
"""
Use special form during user creation
"""
defaults = {}
if obj is None:
defaults.update({
'form': self.add_form,
'fields': admin.util.flatten_fieldsets(self.add_fieldsets),
})
defaults.update(kwargs)
return super(UserAdmin, self).get_form(request, obj, **defaults)
def get_urls(self):
from django.conf.urls.defaults import patterns
return patterns('',
(r'^(\d+)/password/$', self.admin_site.admin_view(self.user_change_password))
) + super(UserAdmin, self).get_urls()
@csrf_protect_m
@transaction.commit_on_success
def add_view(self, request, form_url='', extra_context=None):
# It's an error for a user to have add permission but NOT change
# permission for users. If we allowed such users to add users, they
# could create superusers, which would mean they would essentially have
# the permission to change users. To avoid the problem entirely, we
# disallow users from adding users if they don't have change
# permission.
if not self.has_change_permission(request):
if self.has_add_permission(request) and settings.DEBUG:
# Raise Http404 in debug mode so that the user gets a helpful
# error message.
raise Http404('Your user does not have the "Change user" permission. In order to add users, Django requires that your user account have both the "Add user" and "Change user" permissions set.')
raise PermissionDenied
if extra_context is None:
extra_context = {}
defaults = {
'auto_populated_fields': (),
'username_help_text': self.model._meta.get_field('username').help_text,
}
extra_context.update(defaults)
return super(UserAdmin, self).add_view(request, form_url, extra_context)
def user_change_password(self, request, id):
if not self.has_change_permission(request):
raise PermissionDenied
user = get_object_or_404(self.model, pk=id)
if request.method == 'POST':
form = self.change_password_form(user, request.POST)
if form.is_valid():
new_user = form.save()
msg = ugettext('Password changed successfully.')
messages.success(request, msg)
return HttpResponseRedirect('..')
else:
form = self.change_password_form(user)
fieldsets = [(None, {'fields': form.base_fields.keys()})]
adminForm = admin.helpers.AdminForm(form, fieldsets, {})
return render_to_response(self.change_user_password_template or 'admin/auth/user/change_password.html', {
'title': _('Change password: %s') % escape(user.username),
'adminForm': adminForm,
'form': form,
'is_popup': '_popup' in request.REQUEST,
'add': True,
'change': False,
'has_delete_permission': False,
'has_change_permission': True,
'has_absolute_url': False,
'opts': self.model._meta,
'original': user,
'save_as': False,
'show_save': True,
'root_path': self.admin_site.root_path,
}, context_instance=RequestContext(request))
admin.site.register(Group, GroupAdmin)
admin.site.register(User, UserAdmin)
|
apache-2.0
|
[
504,
1639,
492,
1978,
199,
504,
1639,
14,
697,
492,
6008,
199,
504,
1639,
14,
2190,
492,
2202,
199,
504,
1639,
14,
2828,
492,
4628,
199,
504,
1639,
14,
2828,
14,
1178,
14,
3351,
492,
2876,
13921,
2821,
12,
2876,
32523,
12,
9516,
6139,
32523,
199,
504,
1639,
14,
2828,
14,
1178,
14,
992,
492,
2876,
12,
5611,
199,
504,
1639,
14,
2828,
492,
3788,
199,
504,
1639,
14,
1018,
14,
3924,
492,
23724,
199,
504,
1639,
14,
1014,
492,
14935,
12,
4760,
5188,
199,
504,
1639,
14,
17469,
492,
3795,
63,
475,
63,
1310,
12,
664,
63,
785,
63,
269,
63,
5188,
199,
504,
1639,
14,
1160,
492,
22538,
199,
504,
1639,
14,
1208,
14,
1360,
492,
4772,
199,
504,
1639,
14,
1208,
14,
11582,
492,
1083,
63,
11547,
199,
504,
1639,
14,
1208,
14,
6893,
492,
10366,
12,
10366,
63,
6395,
465,
485,
199,
504,
1639,
14,
4196,
14,
11582,
14,
10088,
492,
19213,
63,
18292,
199,
199,
10088,
63,
18292,
63,
77,
275,
1083,
63,
11547,
8,
10088,
63,
18292,
9,
199,
199,
533,
5611,
4880,
8,
2113,
14,
12976,
304,
272,
2754,
63,
955,
275,
661,
354,
9538,
272,
7794,
275,
661,
354,
9538,
272,
2457,
63,
11392,
275,
661,
6060,
9538,
199,
199,
533,
2876,
4880,
8,
2113,
14,
12976,
304,
272,
1050,
63,
964,
63,
1160,
275,
283,
2113,
15,
1178,
15,
751,
15,
525,
63,
964,
14,
1360,
7,
272,
1570,
63,
751,
63,
2060,
63,
1160,
275,
488,
272,
901,
2193,
275,
334,
267,
334,
403,
12,
791,
955,
356,
661,
2473,
297,
283,
2060,
358,
8688,
267,
21790,
7344,
279,
2256,
659,
791,
955,
356,
661,
2246,
63,
354,
297,
283,
2019,
63,
354,
297,
283,
2123,
358,
8688,
267,
21790,
17004,
659,
791,
955,
356,
661,
374,
63,
2682,
297,
283,
374,
63,
7018,
297,
283,
374,
63,
11434,
297,
283,
751,
63,
6060,
358,
8688,
267,
21790,
6295,
867,
10831,
659,
791,
955,
356,
661,
2019,
63,
2886,
297,
283,
602,
63,
11806,
358,
8688,
267,
21790,
10177,
659,
791,
955,
356,
661,
2634,
297,
6769,
395,
272,
776,
272,
1050,
63,
23501,
275,
334,
267,
334,
403,
12,
469,
288,
283,
2888,
356,
661,
13062,
5529,
288,
283,
955,
356,
661,
2473,
297,
283,
2060,
17,
297,
283,
2060,
18,
21004,
267,
2318,
272,
776,
272,
1824,
275,
2876,
32523,
272,
1050,
63,
964,
275,
2876,
13921,
2821,
272,
1570,
63,
2060,
63,
964,
275,
9516,
6139,
32523,
272,
769,
63,
2918,
275,
661,
2473,
297,
283,
2123,
297,
283,
2246,
63,
354,
297,
283,
2019,
63,
354,
297,
283,
374,
63,
7018,
358,
272,
769,
63,
1541,
275,
661,
374,
63,
7018,
297,
283,
374,
63,
11434,
297,
283,
374,
63,
2682,
358,
272,
2754,
63,
955,
275,
661,
2473,
297,
283,
2246,
63,
354,
297,
283,
2019,
63,
354,
297,
283,
2123,
358,
272,
7794,
275,
661,
2473,
9538,
272,
2457,
63,
11392,
275,
661,
751,
63,
6060,
9538,
339,
347,
636,
1250,
721,
277,
12,
1056,
12,
1166,
304,
267,
327,
642,
1077,
440,
506,
2348,
12,
1325,
1471,
506,
7037,
370,
314,
4340,
636,
1250,
363,
15777,
267,
327,
315,
30093,
14,
267,
340,
1166,
365,
488,
26,
288,
372,
291,
14,
19043,
63,
1345,
8,
1069,
9,
267,
340,
1166,
14,
4130,
360,
2060,
735,
288,
372,
291,
14,
751,
63,
1461,
63,
2060,
8,
1069,
12,
1166,
14,
1294,
30746,
16,
566,
267,
372,
1613,
8,
1899,
4880,
12,
291,
2843,
1250,
721,
1069,
12,
1166,
9,
339,
347,
664,
63,
23501,
8,
277,
12,
1056,
12,
1559,
29,
403,
304,
267,
340,
440,
1559,
26,
288,
372,
291,
14,
525,
63,
23501,
267,
372,
1613,
8,
1899,
4880,
12,
291,
680,
362,
63,
23501,
8,
1069,
12,
1559,
9,
339,
347,
664,
63,
964,
8,
277,
12,
1056,
12,
1559,
29,
403,
12,
1011,
958,
304,
267,
408,
267,
3645,
4539,
1824,
5309,
922,
7143,
267,
408,
267,
4243,
275,
1052,
267,
340,
1559,
365,
488,
26,
288,
4243,
14,
873,
2561,
355,
283,
964,
356,
291,
14,
525,
63,
964,
12,
355,
283,
955,
356,
4628,
14,
1974,
14,
8487,
63,
23501,
8,
277,
14,
525,
63,
23501,
395,
288,
3828,
267,
4243,
14,
873,
8,
958,
9,
267,
372,
1613,
8,
1899,
4880,
12,
291,
680,
362,
63,
964,
8,
1069,
12,
1559,
12,
1011,
4322,
9,
339,
347,
664,
63,
3603,
8,
277,
304,
267,
687,
1639,
14,
2190,
14,
3603,
14,
4322,
492,
7970,
267,
372,
7970,
8594,
288,
334,
82,
31344,
68,
18830,
2060,
10884,
291,
14,
2113,
63,
2124,
14,
2113,
63,
1345,
8,
277,
14,
751,
63,
1461,
63,
2060,
430,
267,
776,
435,
1613,
8,
1899,
4880,
12,
291,
680,
362,
63,
3603,
342,
339,
768,
10088,
63,
18292,
63,
77,
272,
768,
5945,
14,
3543,
63,
265,
63,
3742,
272,
347,
1050,
63,
1345,
8,
277,
12,
1056,
12,
1824,
63,
633,
4581,
2402,
63,
1100,
29,
403,
304,
267,
327,
2779,
1159,
376,
1125,
367,
282,
922,
370,
1172,
1050,
4983,
1325,
2845,
1570,
267,
327,
4983,
367,
4390,
14,
982,
781,
4370,
4066,
4390,
370,
1050,
4390,
12,
2985,
267,
327,
4293,
1218,
1613,
3707,
12,
1314,
3955,
4615,
2985,
3955,
28891,
1172,
267,
327,
314,
4983,
370,
1570,
4390,
14,
4005,
5126,
314,
5160,
21926,
12,
781,
267,
327,
2153,
3306,
4390,
687,
7791,
4390,
340,
2985,
2793,
1133,
1172,
1570,
267,
327,
4983,
14,
267,
340,
440,
291,
14,
1989,
63,
1461,
63,
5693,
8,
1069,
304,
288,
340,
291,
14,
1989,
63,
525,
63,
5693,
8,
1069,
9,
436,
2202,
14,
5287,
26,
355,
327,
14771,
4760,
5188,
315,
3105,
818,
880,
626,
314,
922,
7545,
282,
24606,
355,
327,
1125,
1245,
14,
355,
746,
4760,
5188,
360,
14398,
922,
1630,
440,
1172,
314,
298,
4001,
922,
2,
4983,
14,
1010,
1865,
370,
1050,
4390,
12,
5634,
5074,
626,
2195,
922,
2933,
1172,
3865,
314,
298,
1123,
922,
2,
436,
298,
4001,
922,
2,
3443,
663,
2659,
288,
746,
23724,
267,
340,
2402,
63,
1100,
365,
488,
26,
288,
2402,
63,
1100,
275,
1052,
267,
4243,
275,
469,
288,
283,
2495
] |
[
1639,
492,
1978,
199,
504,
1639,
14,
697,
492,
6008,
199,
504,
1639,
14,
2190,
492,
2202,
199,
504,
1639,
14,
2828,
492,
4628,
199,
504,
1639,
14,
2828,
14,
1178,
14,
3351,
492,
2876,
13921,
2821,
12,
2876,
32523,
12,
9516,
6139,
32523,
199,
504,
1639,
14,
2828,
14,
1178,
14,
992,
492,
2876,
12,
5611,
199,
504,
1639,
14,
2828,
492,
3788,
199,
504,
1639,
14,
1018,
14,
3924,
492,
23724,
199,
504,
1639,
14,
1014,
492,
14935,
12,
4760,
5188,
199,
504,
1639,
14,
17469,
492,
3795,
63,
475,
63,
1310,
12,
664,
63,
785,
63,
269,
63,
5188,
199,
504,
1639,
14,
1160,
492,
22538,
199,
504,
1639,
14,
1208,
14,
1360,
492,
4772,
199,
504,
1639,
14,
1208,
14,
11582,
492,
1083,
63,
11547,
199,
504,
1639,
14,
1208,
14,
6893,
492,
10366,
12,
10366,
63,
6395,
465,
485,
199,
504,
1639,
14,
4196,
14,
11582,
14,
10088,
492,
19213,
63,
18292,
199,
199,
10088,
63,
18292,
63,
77,
275,
1083,
63,
11547,
8,
10088,
63,
18292,
9,
199,
199,
533,
5611,
4880,
8,
2113,
14,
12976,
304,
272,
2754,
63,
955,
275,
661,
354,
9538,
272,
7794,
275,
661,
354,
9538,
272,
2457,
63,
11392,
275,
661,
6060,
9538,
199,
199,
533,
2876,
4880,
8,
2113,
14,
12976,
304,
272,
1050,
63,
964,
63,
1160,
275,
283,
2113,
15,
1178,
15,
751,
15,
525,
63,
964,
14,
1360,
7,
272,
1570,
63,
751,
63,
2060,
63,
1160,
275,
488,
272,
901,
2193,
275,
334,
267,
334,
403,
12,
791,
955,
356,
661,
2473,
297,
283,
2060,
358,
8688,
267,
21790,
7344,
279,
2256,
659,
791,
955,
356,
661,
2246,
63,
354,
297,
283,
2019,
63,
354,
297,
283,
2123,
358,
8688,
267,
21790,
17004,
659,
791,
955,
356,
661,
374,
63,
2682,
297,
283,
374,
63,
7018,
297,
283,
374,
63,
11434,
297,
283,
751,
63,
6060,
358,
8688,
267,
21790,
6295,
867,
10831,
659,
791,
955,
356,
661,
2019,
63,
2886,
297,
283,
602,
63,
11806,
358,
8688,
267,
21790,
10177,
659,
791,
955,
356,
661,
2634,
297,
6769,
395,
272,
776,
272,
1050,
63,
23501,
275,
334,
267,
334,
403,
12,
469,
288,
283,
2888,
356,
661,
13062,
5529,
288,
283,
955,
356,
661,
2473,
297,
283,
2060,
17,
297,
283,
2060,
18,
21004,
267,
2318,
272,
776,
272,
1824,
275,
2876,
32523,
272,
1050,
63,
964,
275,
2876,
13921,
2821,
272,
1570,
63,
2060,
63,
964,
275,
9516,
6139,
32523,
272,
769,
63,
2918,
275,
661,
2473,
297,
283,
2123,
297,
283,
2246,
63,
354,
297,
283,
2019,
63,
354,
297,
283,
374,
63,
7018,
358,
272,
769,
63,
1541,
275,
661,
374,
63,
7018,
297,
283,
374,
63,
11434,
297,
283,
374,
63,
2682,
358,
272,
2754,
63,
955,
275,
661,
2473,
297,
283,
2246,
63,
354,
297,
283,
2019,
63,
354,
297,
283,
2123,
358,
272,
7794,
275,
661,
2473,
9538,
272,
2457,
63,
11392,
275,
661,
751,
63,
6060,
9538,
339,
347,
636,
1250,
721,
277,
12,
1056,
12,
1166,
304,
267,
327,
642,
1077,
440,
506,
2348,
12,
1325,
1471,
506,
7037,
370,
314,
4340,
636,
1250,
363,
15777,
267,
327,
315,
30093,
14,
267,
340,
1166,
365,
488,
26,
288,
372,
291,
14,
19043,
63,
1345,
8,
1069,
9,
267,
340,
1166,
14,
4130,
360,
2060,
735,
288,
372,
291,
14,
751,
63,
1461,
63,
2060,
8,
1069,
12,
1166,
14,
1294,
30746,
16,
566,
267,
372,
1613,
8,
1899,
4880,
12,
291,
2843,
1250,
721,
1069,
12,
1166,
9,
339,
347,
664,
63,
23501,
8,
277,
12,
1056,
12,
1559,
29,
403,
304,
267,
340,
440,
1559,
26,
288,
372,
291,
14,
525,
63,
23501,
267,
372,
1613,
8,
1899,
4880,
12,
291,
680,
362,
63,
23501,
8,
1069,
12,
1559,
9,
339,
347,
664,
63,
964,
8,
277,
12,
1056,
12,
1559,
29,
403,
12,
1011,
958,
304,
267,
408,
267,
3645,
4539,
1824,
5309,
922,
7143,
267,
408,
267,
4243,
275,
1052,
267,
340,
1559,
365,
488,
26,
288,
4243,
14,
873,
2561,
355,
283,
964,
356,
291,
14,
525,
63,
964,
12,
355,
283,
955,
356,
4628,
14,
1974,
14,
8487,
63,
23501,
8,
277,
14,
525,
63,
23501,
395,
288,
3828,
267,
4243,
14,
873,
8,
958,
9,
267,
372,
1613,
8,
1899,
4880,
12,
291,
680,
362,
63,
964,
8,
1069,
12,
1559,
12,
1011,
4322,
9,
339,
347,
664,
63,
3603,
8,
277,
304,
267,
687,
1639,
14,
2190,
14,
3603,
14,
4322,
492,
7970,
267,
372,
7970,
8594,
288,
334,
82,
31344,
68,
18830,
2060,
10884,
291,
14,
2113,
63,
2124,
14,
2113,
63,
1345,
8,
277,
14,
751,
63,
1461,
63,
2060,
430,
267,
776,
435,
1613,
8,
1899,
4880,
12,
291,
680,
362,
63,
3603,
342,
339,
768,
10088,
63,
18292,
63,
77,
272,
768,
5945,
14,
3543,
63,
265,
63,
3742,
272,
347,
1050,
63,
1345,
8,
277,
12,
1056,
12,
1824,
63,
633,
4581,
2402,
63,
1100,
29,
403,
304,
267,
327,
2779,
1159,
376,
1125,
367,
282,
922,
370,
1172,
1050,
4983,
1325,
2845,
1570,
267,
327,
4983,
367,
4390,
14,
982,
781,
4370,
4066,
4390,
370,
1050,
4390,
12,
2985,
267,
327,
4293,
1218,
1613,
3707,
12,
1314,
3955,
4615,
2985,
3955,
28891,
1172,
267,
327,
314,
4983,
370,
1570,
4390,
14,
4005,
5126,
314,
5160,
21926,
12,
781,
267,
327,
2153,
3306,
4390,
687,
7791,
4390,
340,
2985,
2793,
1133,
1172,
1570,
267,
327,
4983,
14,
267,
340,
440,
291,
14,
1989,
63,
1461,
63,
5693,
8,
1069,
304,
288,
340,
291,
14,
1989,
63,
525,
63,
5693,
8,
1069,
9,
436,
2202,
14,
5287,
26,
355,
327,
14771,
4760,
5188,
315,
3105,
818,
880,
626,
314,
922,
7545,
282,
24606,
355,
327,
1125,
1245,
14,
355,
746,
4760,
5188,
360,
14398,
922,
1630,
440,
1172,
314,
298,
4001,
922,
2,
4983,
14,
1010,
1865,
370,
1050,
4390,
12,
5634,
5074,
626,
2195,
922,
2933,
1172,
3865,
314,
298,
1123,
922,
2,
436,
298,
4001,
922,
2,
3443,
663,
2659,
288,
746,
23724,
267,
340,
2402,
63,
1100,
365,
488,
26,
288,
2402,
63,
1100,
275,
1052,
267,
4243,
275,
469,
288,
283,
2495,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
yousafsyed/casperjs
|
bin/Lib/encodings/ptcp154.py
|
219
|
14015
|
""" Python Character Mapping Codec generated from 'PTCP154.txt' with gencodec.py.
Written by Marc-Andre Lemburg (mal@lemburg.com).
(c) Copyright CNRI, All Rights Reserved. NO WARRANTY.
(c) Copyright 2000 Guido van Rossum.
"""#"
import codecs
### Codec APIs
class Codec(codecs.Codec):
def encode(self,input,errors='strict'):
return codecs.charmap_encode(input,errors,encoding_table)
def decode(self,input,errors='strict'):
return codecs.charmap_decode(input,errors,decoding_table)
class IncrementalEncoder(codecs.IncrementalEncoder):
def encode(self, input, final=False):
return codecs.charmap_encode(input,self.errors,encoding_table)[0]
class IncrementalDecoder(codecs.IncrementalDecoder):
def decode(self, input, final=False):
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
class StreamWriter(Codec,codecs.StreamWriter):
pass
class StreamReader(Codec,codecs.StreamReader):
pass
### encodings module API
def getregentry():
return codecs.CodecInfo(
name='ptcp154',
encode=Codec().encode,
decode=Codec().decode,
incrementalencoder=IncrementalEncoder,
incrementaldecoder=IncrementalDecoder,
streamreader=StreamReader,
streamwriter=StreamWriter,
)
### Decoding Table
decoding_table = (
'\x00' # 0x00 -> NULL
'\x01' # 0x01 -> START OF HEADING
'\x02' # 0x02 -> START OF TEXT
'\x03' # 0x03 -> END OF TEXT
'\x04' # 0x04 -> END OF TRANSMISSION
'\x05' # 0x05 -> ENQUIRY
'\x06' # 0x06 -> ACKNOWLEDGE
'\x07' # 0x07 -> BELL
'\x08' # 0x08 -> BACKSPACE
'\t' # 0x09 -> HORIZONTAL TABULATION
'\n' # 0x0A -> LINE FEED
'\x0b' # 0x0B -> VERTICAL TABULATION
'\x0c' # 0x0C -> FORM FEED
'\r' # 0x0D -> CARRIAGE RETURN
'\x0e' # 0x0E -> SHIFT OUT
'\x0f' # 0x0F -> SHIFT IN
'\x10' # 0x10 -> DATA LINK ESCAPE
'\x11' # 0x11 -> DEVICE CONTROL ONE
'\x12' # 0x12 -> DEVICE CONTROL TWO
'\x13' # 0x13 -> DEVICE CONTROL THREE
'\x14' # 0x14 -> DEVICE CONTROL FOUR
'\x15' # 0x15 -> NEGATIVE ACKNOWLEDGE
'\x16' # 0x16 -> SYNCHRONOUS IDLE
'\x17' # 0x17 -> END OF TRANSMISSION BLOCK
'\x18' # 0x18 -> CANCEL
'\x19' # 0x19 -> END OF MEDIUM
'\x1a' # 0x1A -> SUBSTITUTE
'\x1b' # 0x1B -> ESCAPE
'\x1c' # 0x1C -> FILE SEPARATOR
'\x1d' # 0x1D -> GROUP SEPARATOR
'\x1e' # 0x1E -> RECORD SEPARATOR
'\x1f' # 0x1F -> UNIT SEPARATOR
' ' # 0x20 -> SPACE
'!' # 0x21 -> EXCLAMATION MARK
'"' # 0x22 -> QUOTATION MARK
'#' # 0x23 -> NUMBER SIGN
'$' # 0x24 -> DOLLAR SIGN
'%' # 0x25 -> PERCENT SIGN
'&' # 0x26 -> AMPERSAND
"'" # 0x27 -> APOSTROPHE
'(' # 0x28 -> LEFT PARENTHESIS
')' # 0x29 -> RIGHT PARENTHESIS
'*' # 0x2A -> ASTERISK
'+' # 0x2B -> PLUS SIGN
',' # 0x2C -> COMMA
'-' # 0x2D -> HYPHEN-MINUS
'.' # 0x2E -> FULL STOP
'/' # 0x2F -> SOLIDUS
'0' # 0x30 -> DIGIT ZERO
'1' # 0x31 -> DIGIT ONE
'2' # 0x32 -> DIGIT TWO
'3' # 0x33 -> DIGIT THREE
'4' # 0x34 -> DIGIT FOUR
'5' # 0x35 -> DIGIT FIVE
'6' # 0x36 -> DIGIT SIX
'7' # 0x37 -> DIGIT SEVEN
'8' # 0x38 -> DIGIT EIGHT
'9' # 0x39 -> DIGIT NINE
':' # 0x3A -> COLON
';' # 0x3B -> SEMICOLON
'<' # 0x3C -> LESS-THAN SIGN
'=' # 0x3D -> EQUALS SIGN
'>' # 0x3E -> GREATER-THAN SIGN
'?' # 0x3F -> QUESTION MARK
'@' # 0x40 -> COMMERCIAL AT
'A' # 0x41 -> LATIN CAPITAL LETTER A
'B' # 0x42 -> LATIN CAPITAL LETTER B
'C' # 0x43 -> LATIN CAPITAL LETTER C
'D' # 0x44 -> LATIN CAPITAL LETTER D
'E' # 0x45 -> LATIN CAPITAL LETTER E
'F' # 0x46 -> LATIN CAPITAL LETTER F
'G' # 0x47 -> LATIN CAPITAL LETTER G
'H' # 0x48 -> LATIN CAPITAL LETTER H
'I' # 0x49 -> LATIN CAPITAL LETTER I
'J' # 0x4A -> LATIN CAPITAL LETTER J
'K' # 0x4B -> LATIN CAPITAL LETTER K
'L' # 0x4C -> LATIN CAPITAL LETTER L
'M' # 0x4D -> LATIN CAPITAL LETTER M
'N' # 0x4E -> LATIN CAPITAL LETTER N
'O' # 0x4F -> LATIN CAPITAL LETTER O
'P' # 0x50 -> LATIN CAPITAL LETTER P
'Q' # 0x51 -> LATIN CAPITAL LETTER Q
'R' # 0x52 -> LATIN CAPITAL LETTER R
'S' # 0x53 -> LATIN CAPITAL LETTER S
'T' # 0x54 -> LATIN CAPITAL LETTER T
'U' # 0x55 -> LATIN CAPITAL LETTER U
'V' # 0x56 -> LATIN CAPITAL LETTER V
'W' # 0x57 -> LATIN CAPITAL LETTER W
'X' # 0x58 -> LATIN CAPITAL LETTER X
'Y' # 0x59 -> LATIN CAPITAL LETTER Y
'Z' # 0x5A -> LATIN CAPITAL LETTER Z
'[' # 0x5B -> LEFT SQUARE BRACKET
'\\' # 0x5C -> REVERSE SOLIDUS
']' # 0x5D -> RIGHT SQUARE BRACKET
'^' # 0x5E -> CIRCUMFLEX ACCENT
'_' # 0x5F -> LOW LINE
'`' # 0x60 -> GRAVE ACCENT
'a' # 0x61 -> LATIN SMALL LETTER A
'b' # 0x62 -> LATIN SMALL LETTER B
'c' # 0x63 -> LATIN SMALL LETTER C
'd' # 0x64 -> LATIN SMALL LETTER D
'e' # 0x65 -> LATIN SMALL LETTER E
'f' # 0x66 -> LATIN SMALL LETTER F
'g' # 0x67 -> LATIN SMALL LETTER G
'h' # 0x68 -> LATIN SMALL LETTER H
'i' # 0x69 -> LATIN SMALL LETTER I
'j' # 0x6A -> LATIN SMALL LETTER J
'k' # 0x6B -> LATIN SMALL LETTER K
'l' # 0x6C -> LATIN SMALL LETTER L
'm' # 0x6D -> LATIN SMALL LETTER M
'n' # 0x6E -> LATIN SMALL LETTER N
'o' # 0x6F -> LATIN SMALL LETTER O
'p' # 0x70 -> LATIN SMALL LETTER P
'q' # 0x71 -> LATIN SMALL LETTER Q
'r' # 0x72 -> LATIN SMALL LETTER R
's' # 0x73 -> LATIN SMALL LETTER S
't' # 0x74 -> LATIN SMALL LETTER T
'u' # 0x75 -> LATIN SMALL LETTER U
'v' # 0x76 -> LATIN SMALL LETTER V
'w' # 0x77 -> LATIN SMALL LETTER W
'x' # 0x78 -> LATIN SMALL LETTER X
'y' # 0x79 -> LATIN SMALL LETTER Y
'z' # 0x7A -> LATIN SMALL LETTER Z
'{' # 0x7B -> LEFT CURLY BRACKET
'|' # 0x7C -> VERTICAL LINE
'}' # 0x7D -> RIGHT CURLY BRACKET
'~' # 0x7E -> TILDE
'\x7f' # 0x7F -> DELETE (DEL)
'\u0496' # 0x80 -> CYRILLIC CAPITAL LETTER ZHE WITH DESCENDER
'\u0492' # 0x81 -> CYRILLIC CAPITAL LETTER GHE WITH STROKE
'\u04ee' # 0x82 -> CYRILLIC CAPITAL LETTER U WITH MACRON
'\u0493' # 0x83 -> CYRILLIC SMALL LETTER GHE WITH STROKE
'\u201e' # 0x84 -> DOUBLE LOW-9 QUOTATION MARK
'\u2026' # 0x85 -> HORIZONTAL ELLIPSIS
'\u04b6' # 0x86 -> CYRILLIC CAPITAL LETTER CHE WITH DESCENDER
'\u04ae' # 0x87 -> CYRILLIC CAPITAL LETTER STRAIGHT U
'\u04b2' # 0x88 -> CYRILLIC CAPITAL LETTER HA WITH DESCENDER
'\u04af' # 0x89 -> CYRILLIC SMALL LETTER STRAIGHT U
'\u04a0' # 0x8A -> CYRILLIC CAPITAL LETTER BASHKIR KA
'\u04e2' # 0x8B -> CYRILLIC CAPITAL LETTER I WITH MACRON
'\u04a2' # 0x8C -> CYRILLIC CAPITAL LETTER EN WITH DESCENDER
'\u049a' # 0x8D -> CYRILLIC CAPITAL LETTER KA WITH DESCENDER
'\u04ba' # 0x8E -> CYRILLIC CAPITAL LETTER SHHA
'\u04b8' # 0x8F -> CYRILLIC CAPITAL LETTER CHE WITH VERTICAL STROKE
'\u0497' # 0x90 -> CYRILLIC SMALL LETTER ZHE WITH DESCENDER
'\u2018' # 0x91 -> LEFT SINGLE QUOTATION MARK
'\u2019' # 0x92 -> RIGHT SINGLE QUOTATION MARK
'\u201c' # 0x93 -> LEFT DOUBLE QUOTATION MARK
'\u201d' # 0x94 -> RIGHT DOUBLE QUOTATION MARK
'\u2022' # 0x95 -> BULLET
'\u2013' # 0x96 -> EN DASH
'\u2014' # 0x97 -> EM DASH
'\u04b3' # 0x98 -> CYRILLIC SMALL LETTER HA WITH DESCENDER
'\u04b7' # 0x99 -> CYRILLIC SMALL LETTER CHE WITH DESCENDER
'\u04a1' # 0x9A -> CYRILLIC SMALL LETTER BASHKIR KA
'\u04e3' # 0x9B -> CYRILLIC SMALL LETTER I WITH MACRON
'\u04a3' # 0x9C -> CYRILLIC SMALL LETTER EN WITH DESCENDER
'\u049b' # 0x9D -> CYRILLIC SMALL LETTER KA WITH DESCENDER
'\u04bb' # 0x9E -> CYRILLIC SMALL LETTER SHHA
'\u04b9' # 0x9F -> CYRILLIC SMALL LETTER CHE WITH VERTICAL STROKE
'\xa0' # 0xA0 -> NO-BREAK SPACE
'\u040e' # 0xA1 -> CYRILLIC CAPITAL LETTER SHORT U (Byelorussian)
'\u045e' # 0xA2 -> CYRILLIC SMALL LETTER SHORT U (Byelorussian)
'\u0408' # 0xA3 -> CYRILLIC CAPITAL LETTER JE
'\u04e8' # 0xA4 -> CYRILLIC CAPITAL LETTER BARRED O
'\u0498' # 0xA5 -> CYRILLIC CAPITAL LETTER ZE WITH DESCENDER
'\u04b0' # 0xA6 -> CYRILLIC CAPITAL LETTER STRAIGHT U WITH STROKE
'\xa7' # 0xA7 -> SECTION SIGN
'\u0401' # 0xA8 -> CYRILLIC CAPITAL LETTER IO
'\xa9' # 0xA9 -> COPYRIGHT SIGN
'\u04d8' # 0xAA -> CYRILLIC CAPITAL LETTER SCHWA
'\xab' # 0xAB -> LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
'\xac' # 0xAC -> NOT SIGN
'\u04ef' # 0xAD -> CYRILLIC SMALL LETTER U WITH MACRON
'\xae' # 0xAE -> REGISTERED SIGN
'\u049c' # 0xAF -> CYRILLIC CAPITAL LETTER KA WITH VERTICAL STROKE
'\xb0' # 0xB0 -> DEGREE SIGN
'\u04b1' # 0xB1 -> CYRILLIC SMALL LETTER STRAIGHT U WITH STROKE
'\u0406' # 0xB2 -> CYRILLIC CAPITAL LETTER BYELORUSSIAN-UKRAINIAN I
'\u0456' # 0xB3 -> CYRILLIC SMALL LETTER BYELORUSSIAN-UKRAINIAN I
'\u0499' # 0xB4 -> CYRILLIC SMALL LETTER ZE WITH DESCENDER
'\u04e9' # 0xB5 -> CYRILLIC SMALL LETTER BARRED O
'\xb6' # 0xB6 -> PILCROW SIGN
'\xb7' # 0xB7 -> MIDDLE DOT
'\u0451' # 0xB8 -> CYRILLIC SMALL LETTER IO
'\u2116' # 0xB9 -> NUMERO SIGN
'\u04d9' # 0xBA -> CYRILLIC SMALL LETTER SCHWA
'\xbb' # 0xBB -> RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
'\u0458' # 0xBC -> CYRILLIC SMALL LETTER JE
'\u04aa' # 0xBD -> CYRILLIC CAPITAL LETTER ES WITH DESCENDER
'\u04ab' # 0xBE -> CYRILLIC SMALL LETTER ES WITH DESCENDER
'\u049d' # 0xBF -> CYRILLIC SMALL LETTER KA WITH VERTICAL STROKE
'\u0410' # 0xC0 -> CYRILLIC CAPITAL LETTER A
'\u0411' # 0xC1 -> CYRILLIC CAPITAL LETTER BE
'\u0412' # 0xC2 -> CYRILLIC CAPITAL LETTER VE
'\u0413' # 0xC3 -> CYRILLIC CAPITAL LETTER GHE
'\u0414' # 0xC4 -> CYRILLIC CAPITAL LETTER DE
'\u0415' # 0xC5 -> CYRILLIC CAPITAL LETTER IE
'\u0416' # 0xC6 -> CYRILLIC CAPITAL LETTER ZHE
'\u0417' # 0xC7 -> CYRILLIC CAPITAL LETTER ZE
'\u0418' # 0xC8 -> CYRILLIC CAPITAL LETTER I
'\u0419' # 0xC9 -> CYRILLIC CAPITAL LETTER SHORT I
'\u041a' # 0xCA -> CYRILLIC CAPITAL LETTER KA
'\u041b' # 0xCB -> CYRILLIC CAPITAL LETTER EL
'\u041c' # 0xCC -> CYRILLIC CAPITAL LETTER EM
'\u041d' # 0xCD -> CYRILLIC CAPITAL LETTER EN
'\u041e' # 0xCE -> CYRILLIC CAPITAL LETTER O
'\u041f' # 0xCF -> CYRILLIC CAPITAL LETTER PE
'\u0420' # 0xD0 -> CYRILLIC CAPITAL LETTER ER
'\u0421' # 0xD1 -> CYRILLIC CAPITAL LETTER ES
'\u0422' # 0xD2 -> CYRILLIC CAPITAL LETTER TE
'\u0423' # 0xD3 -> CYRILLIC CAPITAL LETTER U
'\u0424' # 0xD4 -> CYRILLIC CAPITAL LETTER EF
'\u0425' # 0xD5 -> CYRILLIC CAPITAL LETTER HA
'\u0426' # 0xD6 -> CYRILLIC CAPITAL LETTER TSE
'\u0427' # 0xD7 -> CYRILLIC CAPITAL LETTER CHE
'\u0428' # 0xD8 -> CYRILLIC CAPITAL LETTER SHA
'\u0429' # 0xD9 -> CYRILLIC CAPITAL LETTER SHCHA
'\u042a' # 0xDA -> CYRILLIC CAPITAL LETTER HARD SIGN
'\u042b' # 0xDB -> CYRILLIC CAPITAL LETTER YERU
'\u042c' # 0xDC -> CYRILLIC CAPITAL LETTER SOFT SIGN
'\u042d' # 0xDD -> CYRILLIC CAPITAL LETTER E
'\u042e' # 0xDE -> CYRILLIC CAPITAL LETTER YU
'\u042f' # 0xDF -> CYRILLIC CAPITAL LETTER YA
'\u0430' # 0xE0 -> CYRILLIC SMALL LETTER A
'\u0431' # 0xE1 -> CYRILLIC SMALL LETTER BE
'\u0432' # 0xE2 -> CYRILLIC SMALL LETTER VE
'\u0433' # 0xE3 -> CYRILLIC SMALL LETTER GHE
'\u0434' # 0xE4 -> CYRILLIC SMALL LETTER DE
'\u0435' # 0xE5 -> CYRILLIC SMALL LETTER IE
'\u0436' # 0xE6 -> CYRILLIC SMALL LETTER ZHE
'\u0437' # 0xE7 -> CYRILLIC SMALL LETTER ZE
'\u0438' # 0xE8 -> CYRILLIC SMALL LETTER I
'\u0439' # 0xE9 -> CYRILLIC SMALL LETTER SHORT I
'\u043a' # 0xEA -> CYRILLIC SMALL LETTER KA
'\u043b' # 0xEB -> CYRILLIC SMALL LETTER EL
'\u043c' # 0xEC -> CYRILLIC SMALL LETTER EM
'\u043d' # 0xED -> CYRILLIC SMALL LETTER EN
'\u043e' # 0xEE -> CYRILLIC SMALL LETTER O
'\u043f' # 0xEF -> CYRILLIC SMALL LETTER PE
'\u0440' # 0xF0 -> CYRILLIC SMALL LETTER ER
'\u0441' # 0xF1 -> CYRILLIC SMALL LETTER ES
'\u0442' # 0xF2 -> CYRILLIC SMALL LETTER TE
'\u0443' # 0xF3 -> CYRILLIC SMALL LETTER U
'\u0444' # 0xF4 -> CYRILLIC SMALL LETTER EF
'\u0445' # 0xF5 -> CYRILLIC SMALL LETTER HA
'\u0446' # 0xF6 -> CYRILLIC SMALL LETTER TSE
'\u0447' # 0xF7 -> CYRILLIC SMALL LETTER CHE
'\u0448' # 0xF8 -> CYRILLIC SMALL LETTER SHA
'\u0449' # 0xF9 -> CYRILLIC SMALL LETTER SHCHA
'\u044a' # 0xFA -> CYRILLIC SMALL LETTER HARD SIGN
'\u044b' # 0xFB -> CYRILLIC SMALL LETTER YERU
'\u044c' # 0xFC -> CYRILLIC SMALL LETTER SOFT SIGN
'\u044d' # 0xFD -> CYRILLIC SMALL LETTER E
'\u044e' # 0xFE -> CYRILLIC SMALL LETTER YU
'\u044f' # 0xFF -> CYRILLIC SMALL LETTER YA
)
### Encoding table
encoding_table=codecs.charmap_build(decoding_table)
|
mit
|
[
624,
2018,
17660,
12340,
13732,
4046,
687,
283,
4189,
2890,
10478,
14,
2424,
7,
543,
486,
2143,
67,
14,
647,
14,
199,
199,
32329,
701,
603,
9912,
13,
3325,
264,
7005,
32649,
334,
2174,
32,
274,
32649,
14,
957,
680,
199,
199,
8,
67,
9,
1898,
445,
46,
6129,
12,
2900,
5924,
5702,
14,
4825,
3408,
14,
199,
8,
67,
9,
1898,
12293,
598,
1535,
79,
20744,
6848,
385,
453,
14,
199,
199,
624,
23662,
199,
199,
646,
6010,
199,
199,
5680,
13732,
15913,
199,
199,
533,
13732,
8,
8933,
14,
8818,
304,
339,
347,
3752,
8,
277,
12,
1210,
12,
2550,
534,
4768,
735,
267,
372,
6010,
14,
13391,
63,
2143,
8,
1210,
12,
2550,
12,
2991,
63,
1224,
9,
339,
347,
4849,
8,
277,
12,
1210,
12,
2550,
534,
4768,
735,
267,
372,
6010,
14,
13391,
63,
2708,
8,
1210,
12,
2550,
12,
12796,
63,
1224,
9,
199,
199,
533,
24350,
8,
8933,
14,
17016,
304,
272,
347,
3752,
8,
277,
12,
1324,
12,
4242,
29,
797,
304,
267,
372,
6010,
14,
13391,
63,
2143,
8,
1210,
12,
277,
14,
2550,
12,
2991,
63,
1224,
2788,
16,
61,
199,
199,
533,
24385,
8,
8933,
14,
16703,
304,
272,
347,
4849,
8,
277,
12,
1324,
12,
4242,
29,
797,
304,
267,
372,
6010,
14,
13391,
63,
2708,
8,
1210,
12,
277,
14,
2550,
12,
12796,
63,
1224,
2788,
16,
61,
199,
199,
533,
24163,
8,
8818,
12,
8933,
14,
16551,
304,
272,
986,
199,
199,
533,
22970,
8,
8818,
12,
8933,
14,
16132,
304,
272,
986,
199,
199,
5680,
14134,
859,
3261,
199,
199,
318,
26116,
837,
272,
372,
6010,
14,
26375,
8,
267,
536,
534,
541,
1850,
10478,
297,
267,
3752,
29,
8818,
1252,
2143,
12,
267,
4849,
29,
8818,
1252,
2708,
12,
267,
26329,
29,
17016,
12,
267,
26317,
29,
16703,
12,
267,
26101,
29,
16132,
12,
267,
26112,
29,
16551,
12,
272,
776,
421,
199,
5680,
27368,
6957,
199,
199,
12796,
63,
1224,
275,
334,
272,
1557,
88,
383,
7,
258,
327,
221,
378,
88,
383,
1035,
5962,
272,
1557,
88,
614,
7,
258,
327,
221,
378,
88,
614,
1035,
13910,
1634,
32674,
272,
1557,
88,
996,
7,
258,
327,
221,
378,
88,
996,
1035,
13910,
1634,
11951,
272,
1557,
88,
1644,
7,
258,
327,
221,
378,
88,
1644,
1035,
7729,
1634,
11951,
272,
1557,
88,
966,
7,
258,
327,
221,
378,
88,
966,
1035,
7729,
1634,
22499,
272,
1557,
88,
1717,
7,
258,
327,
221,
378,
88,
1717,
1035,
5070,
31115,
57,
272,
1557,
88,
1690,
7,
258,
327,
221,
378,
88,
1690,
1035,
22549,
272,
1557,
88,
1780,
7,
258,
327,
221,
378,
88,
1780,
1035,
699,
14952,
272,
1557,
88,
2036,
7,
258,
327,
221,
378,
88,
2036,
1035,
22658,
11658,
272,
1557,
84,
7,
755,
327,
221,
378,
88,
1643,
1035,
8724,
22450,
272,
1557,
78,
7,
755,
327,
221,
378,
88,
16,
33,
1035,
13587,
21567,
272,
1557,
88,
16,
66,
7,
258,
327,
221,
378,
88,
16,
34,
1035,
8267,
22450,
272,
1557,
88,
16,
67,
7,
258,
327,
221,
378,
88,
16,
35,
1035,
11295,
21567,
272,
1557,
82,
7,
755,
327,
221,
378,
88,
16,
36,
1035,
445,
32622,
24646,
272,
1557,
88,
16,
69,
7,
258,
327,
221,
378,
88,
16,
37,
1035,
20754,
5738,
272,
1557,
88,
16,
70,
7,
258,
327,
221,
378,
88,
16,
38,
1035,
20754,
1621,
272,
1557,
88,
709,
7,
258,
327,
221,
378,
88,
709,
1035,
7126,
19774,
17682,
272,
1557,
88,
845,
7,
258,
327,
221,
378,
88,
845,
1035,
11643,
8098,
13051,
272,
1557,
88,
713,
7,
258,
327,
221,
378,
88,
713,
1035,
11643,
8098,
16562,
272,
1557,
88,
969,
7,
258,
327,
221,
378,
88,
969,
1035,
11643,
8098,
16296,
272,
1557,
88,
1079,
7,
258,
327,
221,
378,
88,
1079,
1035,
11643,
8098,
14473,
272,
1557,
88,
1046,
7,
258,
327,
221,
378,
88,
1046,
1035,
29837,
22549,
272,
1557,
88,
975,
7,
258,
327,
221,
378,
88,
975,
1035,
10046,
30782,
23240,
272,
1557,
88,
1196,
7,
258,
327,
221,
378,
88,
1196,
1035,
7729,
1634,
22499,
8068,
272,
1557,
88,
1085,
7,
258,
327,
221,
378,
88,
1085,
1035,
27385,
272,
1557,
88,
1167,
7,
258,
327,
221,
378,
88,
1167,
1035,
7729,
1634,
22650,
272,
1557,
88,
17,
65,
7,
258,
327,
221,
378,
88,
17,
33,
1035,
9103,
272,
1557,
88,
17,
66,
7,
258,
327,
221,
378,
88,
17,
34,
1035,
17682,
272,
1557,
88,
17,
67,
7,
258,
327,
221,
378,
88,
17,
35,
1035,
13024,
14782,
272,
1557,
88,
17,
68,
7,
258,
327,
221,
378,
88,
17,
36,
1035,
15443,
14782,
272,
1557,
88,
17,
69,
7,
258,
327,
221,
378,
88,
17,
37,
1035,
24973,
14782,
272,
1557,
88,
17,
70,
7,
258,
327,
221,
378,
88,
17,
38,
1035,
25836,
14782,
272,
283,
283,
263,
327,
221,
378,
88,
1165,
1035,
16796,
272,
29376,
263,
327,
221,
378,
88,
2025,
1035,
24232,
8132,
272,
14788,
263,
327,
221,
378,
88,
1081,
1035,
11830,
8132,
272,
19619,
263,
327,
221,
378,
88,
1789,
1035,
18122,
5056,
272,
25271,
263,
327,
221,
378,
88,
1194,
1035,
30857,
5056,
272,
26386,
263,
327,
221,
378,
88,
821,
1035,
26684,
5056,
272,
29285,
263,
327,
221,
378,
88,
1479,
1035,
30602,
272,
21673,
263,
327,
221,
378,
88,
1465,
1035,
30876,
272,
16746,
263,
327,
221,
378,
88,
1651,
1035,
6578,
20570,
272,
16107,
263,
327,
221,
378,
88,
1398,
1035,
7052,
20570,
272,
13626,
263,
327,
221,
378,
88,
18,
33,
1035,
29725,
272,
20246,
263,
327,
221,
378,
88,
18,
34,
1035,
18807,
5056,
272,
13647,
263,
327,
221,
378,
88,
18,
35,
1035,
22849,
272,
10791,
263,
327,
221,
378,
88,
18,
36,
1035,
22553,
13,
18004,
272,
7815,
263,
327,
221,
378,
88,
18,
37,
1035,
18530,
22348,
272,
7324,
263,
327,
221,
378,
88,
18,
38,
1035,
20585,
272,
283,
16,
7,
263,
327,
221,
378,
88,
1216,
1035,
7298,
20348,
272,
283,
17,
7,
263,
327,
221,
378,
88,
2192,
1035,
7298,
13051,
272,
283,
18,
7,
263,
327,
221,
378,
88,
708,
1035,
7298,
16562,
272
] |
[
2018,
17660,
12340,
13732,
4046,
687,
283,
4189,
2890,
10478,
14,
2424,
7,
543,
486,
2143,
67,
14,
647,
14,
199,
199,
32329,
701,
603,
9912,
13,
3325,
264,
7005,
32649,
334,
2174,
32,
274,
32649,
14,
957,
680,
199,
199,
8,
67,
9,
1898,
445,
46,
6129,
12,
2900,
5924,
5702,
14,
4825,
3408,
14,
199,
8,
67,
9,
1898,
12293,
598,
1535,
79,
20744,
6848,
385,
453,
14,
199,
199,
624,
23662,
199,
199,
646,
6010,
199,
199,
5680,
13732,
15913,
199,
199,
533,
13732,
8,
8933,
14,
8818,
304,
339,
347,
3752,
8,
277,
12,
1210,
12,
2550,
534,
4768,
735,
267,
372,
6010,
14,
13391,
63,
2143,
8,
1210,
12,
2550,
12,
2991,
63,
1224,
9,
339,
347,
4849,
8,
277,
12,
1210,
12,
2550,
534,
4768,
735,
267,
372,
6010,
14,
13391,
63,
2708,
8,
1210,
12,
2550,
12,
12796,
63,
1224,
9,
199,
199,
533,
24350,
8,
8933,
14,
17016,
304,
272,
347,
3752,
8,
277,
12,
1324,
12,
4242,
29,
797,
304,
267,
372,
6010,
14,
13391,
63,
2143,
8,
1210,
12,
277,
14,
2550,
12,
2991,
63,
1224,
2788,
16,
61,
199,
199,
533,
24385,
8,
8933,
14,
16703,
304,
272,
347,
4849,
8,
277,
12,
1324,
12,
4242,
29,
797,
304,
267,
372,
6010,
14,
13391,
63,
2708,
8,
1210,
12,
277,
14,
2550,
12,
12796,
63,
1224,
2788,
16,
61,
199,
199,
533,
24163,
8,
8818,
12,
8933,
14,
16551,
304,
272,
986,
199,
199,
533,
22970,
8,
8818,
12,
8933,
14,
16132,
304,
272,
986,
199,
199,
5680,
14134,
859,
3261,
199,
199,
318,
26116,
837,
272,
372,
6010,
14,
26375,
8,
267,
536,
534,
541,
1850,
10478,
297,
267,
3752,
29,
8818,
1252,
2143,
12,
267,
4849,
29,
8818,
1252,
2708,
12,
267,
26329,
29,
17016,
12,
267,
26317,
29,
16703,
12,
267,
26101,
29,
16132,
12,
267,
26112,
29,
16551,
12,
272,
776,
421,
199,
5680,
27368,
6957,
199,
199,
12796,
63,
1224,
275,
334,
272,
1557,
88,
383,
7,
258,
327,
221,
378,
88,
383,
1035,
5962,
272,
1557,
88,
614,
7,
258,
327,
221,
378,
88,
614,
1035,
13910,
1634,
32674,
272,
1557,
88,
996,
7,
258,
327,
221,
378,
88,
996,
1035,
13910,
1634,
11951,
272,
1557,
88,
1644,
7,
258,
327,
221,
378,
88,
1644,
1035,
7729,
1634,
11951,
272,
1557,
88,
966,
7,
258,
327,
221,
378,
88,
966,
1035,
7729,
1634,
22499,
272,
1557,
88,
1717,
7,
258,
327,
221,
378,
88,
1717,
1035,
5070,
31115,
57,
272,
1557,
88,
1690,
7,
258,
327,
221,
378,
88,
1690,
1035,
22549,
272,
1557,
88,
1780,
7,
258,
327,
221,
378,
88,
1780,
1035,
699,
14952,
272,
1557,
88,
2036,
7,
258,
327,
221,
378,
88,
2036,
1035,
22658,
11658,
272,
1557,
84,
7,
755,
327,
221,
378,
88,
1643,
1035,
8724,
22450,
272,
1557,
78,
7,
755,
327,
221,
378,
88,
16,
33,
1035,
13587,
21567,
272,
1557,
88,
16,
66,
7,
258,
327,
221,
378,
88,
16,
34,
1035,
8267,
22450,
272,
1557,
88,
16,
67,
7,
258,
327,
221,
378,
88,
16,
35,
1035,
11295,
21567,
272,
1557,
82,
7,
755,
327,
221,
378,
88,
16,
36,
1035,
445,
32622,
24646,
272,
1557,
88,
16,
69,
7,
258,
327,
221,
378,
88,
16,
37,
1035,
20754,
5738,
272,
1557,
88,
16,
70,
7,
258,
327,
221,
378,
88,
16,
38,
1035,
20754,
1621,
272,
1557,
88,
709,
7,
258,
327,
221,
378,
88,
709,
1035,
7126,
19774,
17682,
272,
1557,
88,
845,
7,
258,
327,
221,
378,
88,
845,
1035,
11643,
8098,
13051,
272,
1557,
88,
713,
7,
258,
327,
221,
378,
88,
713,
1035,
11643,
8098,
16562,
272,
1557,
88,
969,
7,
258,
327,
221,
378,
88,
969,
1035,
11643,
8098,
16296,
272,
1557,
88,
1079,
7,
258,
327,
221,
378,
88,
1079,
1035,
11643,
8098,
14473,
272,
1557,
88,
1046,
7,
258,
327,
221,
378,
88,
1046,
1035,
29837,
22549,
272,
1557,
88,
975,
7,
258,
327,
221,
378,
88,
975,
1035,
10046,
30782,
23240,
272,
1557,
88,
1196,
7,
258,
327,
221,
378,
88,
1196,
1035,
7729,
1634,
22499,
8068,
272,
1557,
88,
1085,
7,
258,
327,
221,
378,
88,
1085,
1035,
27385,
272,
1557,
88,
1167,
7,
258,
327,
221,
378,
88,
1167,
1035,
7729,
1634,
22650,
272,
1557,
88,
17,
65,
7,
258,
327,
221,
378,
88,
17,
33,
1035,
9103,
272,
1557,
88,
17,
66,
7,
258,
327,
221,
378,
88,
17,
34,
1035,
17682,
272,
1557,
88,
17,
67,
7,
258,
327,
221,
378,
88,
17,
35,
1035,
13024,
14782,
272,
1557,
88,
17,
68,
7,
258,
327,
221,
378,
88,
17,
36,
1035,
15443,
14782,
272,
1557,
88,
17,
69,
7,
258,
327,
221,
378,
88,
17,
37,
1035,
24973,
14782,
272,
1557,
88,
17,
70,
7,
258,
327,
221,
378,
88,
17,
38,
1035,
25836,
14782,
272,
283,
283,
263,
327,
221,
378,
88,
1165,
1035,
16796,
272,
29376,
263,
327,
221,
378,
88,
2025,
1035,
24232,
8132,
272,
14788,
263,
327,
221,
378,
88,
1081,
1035,
11830,
8132,
272,
19619,
263,
327,
221,
378,
88,
1789,
1035,
18122,
5056,
272,
25271,
263,
327,
221,
378,
88,
1194,
1035,
30857,
5056,
272,
26386,
263,
327,
221,
378,
88,
821,
1035,
26684,
5056,
272,
29285,
263,
327,
221,
378,
88,
1479,
1035,
30602,
272,
21673,
263,
327,
221,
378,
88,
1465,
1035,
30876,
272,
16746,
263,
327,
221,
378,
88,
1651,
1035,
6578,
20570,
272,
16107,
263,
327,
221,
378,
88,
1398,
1035,
7052,
20570,
272,
13626,
263,
327,
221,
378,
88,
18,
33,
1035,
29725,
272,
20246,
263,
327,
221,
378,
88,
18,
34,
1035,
18807,
5056,
272,
13647,
263,
327,
221,
378,
88,
18,
35,
1035,
22849,
272,
10791,
263,
327,
221,
378,
88,
18,
36,
1035,
22553,
13,
18004,
272,
7815,
263,
327,
221,
378,
88,
18,
37,
1035,
18530,
22348,
272,
7324,
263,
327,
221,
378,
88,
18,
38,
1035,
20585,
272,
283,
16,
7,
263,
327,
221,
378,
88,
1216,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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
] |
hxddh/shadowsocks
|
shadowsocks/manager.py
|
925
|
9692
|
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# Copyright 2015 clowwindy
#
# 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, \
with_statement
import errno
import traceback
import socket
import logging
import json
import collections
from shadowsocks import common, eventloop, tcprelay, udprelay, asyncdns, shell
BUF_SIZE = 1506
STAT_SEND_LIMIT = 100
class Manager(object):
def __init__(self, config):
self._config = config
self._relays = {} # (tcprelay, udprelay)
self._loop = eventloop.EventLoop()
self._dns_resolver = asyncdns.DNSResolver()
self._dns_resolver.add_to_loop(self._loop)
self._statistics = collections.defaultdict(int)
self._control_client_addr = None
try:
manager_address = config['manager_address']
if ':' in manager_address:
addr = manager_address.rsplit(':', 1)
addr = addr[0], int(addr[1])
addrs = socket.getaddrinfo(addr[0], addr[1])
if addrs:
family = addrs[0][0]
else:
logging.error('invalid address: %s', manager_address)
exit(1)
else:
addr = manager_address
family = socket.AF_UNIX
self._control_socket = socket.socket(family,
socket.SOCK_DGRAM)
self._control_socket.bind(addr)
self._control_socket.setblocking(False)
except (OSError, IOError) as e:
logging.error(e)
logging.error('can not bind to manager address')
exit(1)
self._loop.add(self._control_socket,
eventloop.POLL_IN, self)
self._loop.add_periodic(self.handle_periodic)
port_password = config['port_password']
del config['port_password']
for port, password in port_password.items():
a_config = config.copy()
a_config['server_port'] = int(port)
a_config['password'] = password
self.add_port(a_config)
def add_port(self, config):
port = int(config['server_port'])
servers = self._relays.get(port, None)
if servers:
logging.error("server already exists at %s:%d" % (config['server'],
port))
return
logging.info("adding server at %s:%d" % (config['server'], port))
t = tcprelay.TCPRelay(config, self._dns_resolver, False,
self.stat_callback)
u = udprelay.UDPRelay(config, self._dns_resolver, False,
self.stat_callback)
t.add_to_loop(self._loop)
u.add_to_loop(self._loop)
self._relays[port] = (t, u)
def remove_port(self, config):
port = int(config['server_port'])
servers = self._relays.get(port, None)
if servers:
logging.info("removing server at %s:%d" % (config['server'], port))
t, u = servers
t.close(next_tick=False)
u.close(next_tick=False)
del self._relays[port]
else:
logging.error("server not exist at %s:%d" % (config['server'],
port))
def handle_event(self, sock, fd, event):
if sock == self._control_socket and event == eventloop.POLL_IN:
data, self._control_client_addr = sock.recvfrom(BUF_SIZE)
parsed = self._parse_command(data)
if parsed:
command, config = parsed
a_config = self._config.copy()
if config:
# let the command override the configuration file
a_config.update(config)
if 'server_port' not in a_config:
logging.error('can not find server_port in config')
else:
if command == 'add':
self.add_port(a_config)
self._send_control_data(b'ok')
elif command == 'remove':
self.remove_port(a_config)
self._send_control_data(b'ok')
elif command == 'ping':
self._send_control_data(b'pong')
else:
logging.error('unknown command %s', command)
def _parse_command(self, data):
# commands:
# add: {"server_port": 8000, "password": "foobar"}
# remove: {"server_port": 8000"}
data = common.to_str(data)
parts = data.split(':', 1)
if len(parts) < 2:
return data, None
command, config_json = parts
try:
config = shell.parse_json_in_str(config_json)
return command, config
except Exception as e:
logging.error(e)
return None
def stat_callback(self, port, data_len):
self._statistics[port] += data_len
def handle_periodic(self):
r = {}
i = 0
def send_data(data_dict):
if data_dict:
# use compact JSON format (without space)
data = common.to_bytes(json.dumps(data_dict,
separators=(',', ':')))
self._send_control_data(b'stat: ' + data)
for k, v in self._statistics.items():
r[k] = v
i += 1
# split the data into segments that fit in UDP packets
if i >= STAT_SEND_LIMIT:
send_data(r)
r.clear()
send_data(r)
self._statistics.clear()
def _send_control_data(self, data):
if self._control_client_addr:
try:
self._control_socket.sendto(data, self._control_client_addr)
except (socket.error, OSError, IOError) as e:
error_no = eventloop.errno_from_exception(e)
if error_no in (errno.EAGAIN, errno.EINPROGRESS,
errno.EWOULDBLOCK):
return
else:
shell.print_exception(e)
if self._config['verbose']:
traceback.print_exc()
def run(self):
self._loop.run()
def run(config):
Manager(config).run()
def test():
import time
import threading
import struct
from shadowsocks import encrypt
logging.basicConfig(level=5,
format='%(asctime)s %(levelname)-8s %(message)s',
datefmt='%Y-%m-%d %H:%M:%S')
enc = []
eventloop.TIMEOUT_PRECISION = 1
def run_server():
config = {
'server': '127.0.0.1',
'local_port': 1081,
'port_password': {
'8381': 'foobar1',
'8382': 'foobar2'
},
'method': 'aes-256-cfb',
'manager_address': '127.0.0.1:6001',
'timeout': 60,
'fast_open': False,
'verbose': 2
}
manager = Manager(config)
enc.append(manager)
manager.run()
t = threading.Thread(target=run_server)
t.start()
time.sleep(1)
manager = enc[0]
cli = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
cli.connect(('127.0.0.1', 6001))
# test add and remove
time.sleep(1)
cli.send(b'add: {"server_port":7001, "password":"asdfadsfasdf"}')
time.sleep(1)
assert 7001 in manager._relays
data, addr = cli.recvfrom(1506)
assert b'ok' in data
cli.send(b'remove: {"server_port":8381}')
time.sleep(1)
assert 8381 not in manager._relays
data, addr = cli.recvfrom(1506)
assert b'ok' in data
logging.info('add and remove test passed')
# test statistics for TCP
header = common.pack_addr(b'google.com') + struct.pack('>H', 80)
data = encrypt.encrypt_all(b'asdfadsfasdf', 'aes-256-cfb', 1,
header + b'GET /\r\n\r\n')
tcp_cli = socket.socket()
tcp_cli.connect(('127.0.0.1', 7001))
tcp_cli.send(data)
tcp_cli.recv(4096)
tcp_cli.close()
data, addr = cli.recvfrom(1506)
data = common.to_str(data)
assert data.startswith('stat: ')
data = data.split('stat:')[1]
stats = shell.parse_json_in_str(data)
assert '7001' in stats
logging.info('TCP statistics test passed')
# test statistics for UDP
header = common.pack_addr(b'127.0.0.1') + struct.pack('>H', 80)
data = encrypt.encrypt_all(b'foobar2', 'aes-256-cfb', 1,
header + b'test')
udp_cli = socket.socket(type=socket.SOCK_DGRAM)
udp_cli.sendto(data, ('127.0.0.1', 8382))
tcp_cli.close()
data, addr = cli.recvfrom(1506)
data = common.to_str(data)
assert data.startswith('stat: ')
data = data.split('stat:')[1]
stats = json.loads(data)
assert '8382' in stats
logging.info('UDP statistics test passed')
manager._loop.stop()
t.join()
if __name__ == '__main__':
test()
|
apache-2.0
|
[
3381,
2647,
15,
1393,
15,
1548,
199,
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
199,
3,
1898,
6900,
286,
674,
11530,
89,
199,
3,
199,
3,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
1265,
1443,
199,
3,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
2047,
1443,
3332,
199,
3,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
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,
2428,
199,
3,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
1666,
314,
199,
3,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
4204,
199,
3,
1334,
314,
844,
14,
199,
199,
504,
636,
2443,
363,
492,
3679,
63,
646,
12,
4629,
12,
870,
63,
1593,
12,
971,
272,
543,
63,
6242,
199,
199,
646,
7554,
199,
646,
5190,
199,
646,
2838,
199,
646,
2050,
199,
646,
2022,
199,
646,
5055,
199,
199,
504,
15084,
21234,
492,
2863,
12,
1566,
3813,
12,
14415,
657,
817,
12,
26759,
657,
817,
12,
5316,
5797,
12,
5218,
421,
199,
21323,
63,
4305,
275,
413,
13725,
199,
4315,
63,
20469,
63,
13387,
275,
2948,
421,
199,
533,
13537,
8,
785,
304,
339,
347,
636,
826,
721,
277,
12,
1101,
304,
267,
291,
423,
888,
275,
1101,
267,
291,
423,
264,
9316,
275,
1052,
221,
327,
334,
3641,
657,
817,
12,
26759,
657,
817,
9,
267,
291,
423,
3813,
275,
1566,
3813,
14,
2390,
7382,
342,
267,
291,
423,
5797,
63,
7717,
275,
5316,
5797,
14,
12323,
12407,
342,
267,
291,
423,
5797,
63,
7717,
14,
525,
63,
475,
63,
3813,
8,
277,
423,
3813,
9,
398,
291,
423,
13724,
275,
5055,
14,
21501,
8,
442,
9,
267,
291,
423,
2785,
63,
1258,
63,
2697,
275,
488,
267,
862,
26,
288,
5256,
63,
1562,
275,
1101,
459,
2609,
63,
1562,
418,
288,
340,
10871,
315,
5256,
63,
1562,
26,
355,
5552,
275,
5256,
63,
1562,
14,
13490,
16451,
413,
9,
355,
5552,
275,
5552,
59,
16,
467,
1109,
8,
2697,
59,
17,
566,
355,
29259,
275,
2838,
14,
27606,
815,
8,
2697,
59,
16,
467,
5552,
59,
17,
566,
355,
340,
29259,
26,
490,
9614,
275,
29259,
59,
16,
1527,
16,
61,
355,
587,
26,
490,
2050,
14,
705,
360,
3197,
2287,
26,
450,
83,
297,
5256,
63,
1562,
9,
490,
4458,
8,
17,
9,
288,
587,
26,
355,
5552,
275,
5256,
63,
1562,
355,
9614,
275,
2838,
14,
5699,
63,
19584,
288,
291,
423,
2785,
63,
3450,
275,
2838,
14,
3450,
8,
6606,
12,
1740,
2838,
14,
9469,
63,
25351,
9,
288,
291,
423,
2785,
63,
3450,
14,
3409,
8,
2697,
9,
288,
291,
423,
2785,
63,
3450,
14,
409,
13091,
8,
797,
9,
267,
871,
334,
16719,
12,
5925,
9,
465,
325,
26,
288,
2050,
14,
705,
8,
69,
9,
288,
2050,
14,
705,
360,
2425,
440,
5398,
370,
5256,
2287,
358,
288,
4458,
8,
17,
9,
267,
291,
423,
3813,
14,
525,
8,
277,
423,
2785,
63,
3450,
12,
2432,
1566,
3813,
14,
16428,
63,
568,
12,
291,
9,
267,
291,
423,
3813,
14,
525,
63,
20339,
8,
277,
14,
2479,
63,
20339,
9,
398,
1844,
63,
2060,
275,
1101,
459,
719,
63,
2060,
418,
267,
2150,
1101,
459,
719,
63,
2060,
418,
267,
367,
1844,
12,
2505,
315,
1844,
63,
2060,
14,
1744,
837,
288,
282,
63,
888,
275,
1101,
14,
1574,
342,
288,
282,
63,
888,
459,
1000,
63,
719,
418,
275,
1109,
8,
719,
9,
288,
282,
63,
888,
459,
2060,
418,
275,
2505,
288,
291,
14,
525,
63,
719,
8,
65,
63,
888,
9,
339,
347,
1050,
63,
719,
8,
277,
12,
1101,
304,
267,
1844,
275,
1109,
8,
888,
459,
1000,
63,
719,
1105,
267,
8037,
275,
291,
423,
264,
9316,
14,
362,
8,
719,
12,
488,
9,
267,
340,
8037,
26,
288,
2050,
14,
705,
480,
1000,
2575,
3495,
737,
450,
83,
2689,
68,
2,
450,
334,
888,
459,
1000,
995,
16854,
1844,
430,
288,
372,
267,
2050,
14,
815,
480,
4095,
1654,
737,
450,
83,
2689,
68,
2,
450,
334,
888,
459,
1000,
995,
1844,
430,
267,
307,
275,
14415,
657,
817,
14,
9735,
5640,
1187,
8,
888,
12,
291,
423,
5797,
63,
7717,
12,
756,
12,
2892,
291,
14,
3736,
63,
3058,
9,
267,
399,
275,
26759,
657,
817,
14,
3383,
3311,
352,
1187,
8,
888,
12,
291,
423,
5797,
63,
7717,
12,
756,
12,
2892,
291,
14,
3736,
63,
3058,
9,
267,
307,
14,
525,
63,
475,
63,
3813,
8,
277,
423,
3813,
9,
267,
399,
14,
525,
63,
475,
63,
3813,
8,
277,
423,
3813,
9,
267,
291,
423,
264,
9316,
59,
719,
61,
275,
334,
84,
12,
399,
9,
339,
347,
2813,
63,
719,
8,
277,
12,
1101,
304,
267,
1844,
275,
1109,
8,
888,
459,
1000,
63,
719,
1105,
267,
8037,
275,
291,
423,
264,
9316,
14,
362,
8,
719,
12,
488,
9,
267,
340,
8037,
26,
288,
2050,
14,
815,
480,
264,
7665,
1654,
737,
450,
83,
2689,
68,
2,
450,
334,
888,
459,
1000,
995,
1844,
430,
288,
307,
12,
399,
275,
8037,
288,
307,
14,
1600,
8,
2184,
63,
8284,
29,
797,
9,
288,
399,
14,
1600,
8,
2184,
63,
8284,
29,
797,
9,
288,
2150,
291,
423,
264,
9316,
59,
719,
61,
267,
587,
26,
288,
2050,
14,
705,
480,
1000,
440,
2187,
737,
450,
83,
2689,
68,
2,
450,
334,
888,
459,
1000,
995,
12740,
1844,
430,
339,
347,
2429,
63,
1430,
8,
277,
12,
6771,
12,
6111,
12,
1566,
304,
267,
340,
6771,
508,
291,
423,
2785,
63,
3450,
436,
1566,
508,
1566,
3813,
14,
16428,
63,
568,
26,
288,
666,
12,
291,
423,
2785,
63,
1258,
63,
2697,
275,
6771,
14,
7637,
504,
8,
21323,
63,
4305,
9,
288,
4565,
275,
291,
423,
1122,
63,
1531,
8,
576,
9,
288,
340,
4565,
26,
355,
1414,
12,
1101,
275,
4565,
355,
282
] |
[
2647,
15,
1393,
15,
1548,
199,
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
199,
3,
1898,
6900,
286,
674,
11530,
89,
199,
3,
199,
3,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
1265,
1443,
199,
3,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
2047,
1443,
3332,
199,
3,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
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,
2428,
199,
3,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
1666,
314,
199,
3,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
4204,
199,
3,
1334,
314,
844,
14,
199,
199,
504,
636,
2443,
363,
492,
3679,
63,
646,
12,
4629,
12,
870,
63,
1593,
12,
971,
272,
543,
63,
6242,
199,
199,
646,
7554,
199,
646,
5190,
199,
646,
2838,
199,
646,
2050,
199,
646,
2022,
199,
646,
5055,
199,
199,
504,
15084,
21234,
492,
2863,
12,
1566,
3813,
12,
14415,
657,
817,
12,
26759,
657,
817,
12,
5316,
5797,
12,
5218,
421,
199,
21323,
63,
4305,
275,
413,
13725,
199,
4315,
63,
20469,
63,
13387,
275,
2948,
421,
199,
533,
13537,
8,
785,
304,
339,
347,
636,
826,
721,
277,
12,
1101,
304,
267,
291,
423,
888,
275,
1101,
267,
291,
423,
264,
9316,
275,
1052,
221,
327,
334,
3641,
657,
817,
12,
26759,
657,
817,
9,
267,
291,
423,
3813,
275,
1566,
3813,
14,
2390,
7382,
342,
267,
291,
423,
5797,
63,
7717,
275,
5316,
5797,
14,
12323,
12407,
342,
267,
291,
423,
5797,
63,
7717,
14,
525,
63,
475,
63,
3813,
8,
277,
423,
3813,
9,
398,
291,
423,
13724,
275,
5055,
14,
21501,
8,
442,
9,
267,
291,
423,
2785,
63,
1258,
63,
2697,
275,
488,
267,
862,
26,
288,
5256,
63,
1562,
275,
1101,
459,
2609,
63,
1562,
418,
288,
340,
10871,
315,
5256,
63,
1562,
26,
355,
5552,
275,
5256,
63,
1562,
14,
13490,
16451,
413,
9,
355,
5552,
275,
5552,
59,
16,
467,
1109,
8,
2697,
59,
17,
566,
355,
29259,
275,
2838,
14,
27606,
815,
8,
2697,
59,
16,
467,
5552,
59,
17,
566,
355,
340,
29259,
26,
490,
9614,
275,
29259,
59,
16,
1527,
16,
61,
355,
587,
26,
490,
2050,
14,
705,
360,
3197,
2287,
26,
450,
83,
297,
5256,
63,
1562,
9,
490,
4458,
8,
17,
9,
288,
587,
26,
355,
5552,
275,
5256,
63,
1562,
355,
9614,
275,
2838,
14,
5699,
63,
19584,
288,
291,
423,
2785,
63,
3450,
275,
2838,
14,
3450,
8,
6606,
12,
1740,
2838,
14,
9469,
63,
25351,
9,
288,
291,
423,
2785,
63,
3450,
14,
3409,
8,
2697,
9,
288,
291,
423,
2785,
63,
3450,
14,
409,
13091,
8,
797,
9,
267,
871,
334,
16719,
12,
5925,
9,
465,
325,
26,
288,
2050,
14,
705,
8,
69,
9,
288,
2050,
14,
705,
360,
2425,
440,
5398,
370,
5256,
2287,
358,
288,
4458,
8,
17,
9,
267,
291,
423,
3813,
14,
525,
8,
277,
423,
2785,
63,
3450,
12,
2432,
1566,
3813,
14,
16428,
63,
568,
12,
291,
9,
267,
291,
423,
3813,
14,
525,
63,
20339,
8,
277,
14,
2479,
63,
20339,
9,
398,
1844,
63,
2060,
275,
1101,
459,
719,
63,
2060,
418,
267,
2150,
1101,
459,
719,
63,
2060,
418,
267,
367,
1844,
12,
2505,
315,
1844,
63,
2060,
14,
1744,
837,
288,
282,
63,
888,
275,
1101,
14,
1574,
342,
288,
282,
63,
888,
459,
1000,
63,
719,
418,
275,
1109,
8,
719,
9,
288,
282,
63,
888,
459,
2060,
418,
275,
2505,
288,
291,
14,
525,
63,
719,
8,
65,
63,
888,
9,
339,
347,
1050,
63,
719,
8,
277,
12,
1101,
304,
267,
1844,
275,
1109,
8,
888,
459,
1000,
63,
719,
1105,
267,
8037,
275,
291,
423,
264,
9316,
14,
362,
8,
719,
12,
488,
9,
267,
340,
8037,
26,
288,
2050,
14,
705,
480,
1000,
2575,
3495,
737,
450,
83,
2689,
68,
2,
450,
334,
888,
459,
1000,
995,
16854,
1844,
430,
288,
372,
267,
2050,
14,
815,
480,
4095,
1654,
737,
450,
83,
2689,
68,
2,
450,
334,
888,
459,
1000,
995,
1844,
430,
267,
307,
275,
14415,
657,
817,
14,
9735,
5640,
1187,
8,
888,
12,
291,
423,
5797,
63,
7717,
12,
756,
12,
2892,
291,
14,
3736,
63,
3058,
9,
267,
399,
275,
26759,
657,
817,
14,
3383,
3311,
352,
1187,
8,
888,
12,
291,
423,
5797,
63,
7717,
12,
756,
12,
2892,
291,
14,
3736,
63,
3058,
9,
267,
307,
14,
525,
63,
475,
63,
3813,
8,
277,
423,
3813,
9,
267,
399,
14,
525,
63,
475,
63,
3813,
8,
277,
423,
3813,
9,
267,
291,
423,
264,
9316,
59,
719,
61,
275,
334,
84,
12,
399,
9,
339,
347,
2813,
63,
719,
8,
277,
12,
1101,
304,
267,
1844,
275,
1109,
8,
888,
459,
1000,
63,
719,
1105,
267,
8037,
275,
291,
423,
264,
9316,
14,
362,
8,
719,
12,
488,
9,
267,
340,
8037,
26,
288,
2050,
14,
815,
480,
264,
7665,
1654,
737,
450,
83,
2689,
68,
2,
450,
334,
888,
459,
1000,
995,
1844,
430,
288,
307,
12,
399,
275,
8037,
288,
307,
14,
1600,
8,
2184,
63,
8284,
29,
797,
9,
288,
399,
14,
1600,
8,
2184,
63,
8284,
29,
797,
9,
288,
2150,
291,
423,
264,
9316,
59,
719,
61,
267,
587,
26,
288,
2050,
14,
705,
480,
1000,
440,
2187,
737,
450,
83,
2689,
68,
2,
450,
334,
888,
459,
1000,
995,
12740,
1844,
430,
339,
347,
2429,
63,
1430,
8,
277,
12,
6771,
12,
6111,
12,
1566,
304,
267,
340,
6771,
508,
291,
423,
2785,
63,
3450,
436,
1566,
508,
1566,
3813,
14,
16428,
63,
568,
26,
288,
666,
12,
291,
423,
2785,
63,
1258,
63,
2697,
275,
6771,
14,
7637,
504,
8,
21323,
63,
4305,
9,
288,
4565,
275,
291,
423,
1122,
63,
1531,
8,
576,
9,
288,
340,
4565,
26,
355,
1414,
12,
1101,
275,
4565,
355,
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,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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
] |
haripradhan/MissionPlanner
|
Lib/io.py
|
53
|
3722
|
"""The io module provides the Python interfaces to stream handling. The
builtin open function is defined in this module.
At the top of the I/O hierarchy is the abstract base class IOBase. It
defines the basic interface to a stream. Note, however, that there is no
separation between reading and writing to streams; implementations are
allowed to throw an IOError if they do not support a given operation.
Extending IOBase is RawIOBase which deals simply with the reading and
writing of raw bytes to a stream. FileIO subclasses RawIOBase to provide
an interface to OS files.
BufferedIOBase deals with buffering on a raw byte stream (RawIOBase). Its
subclasses, BufferedWriter, BufferedReader, and BufferedRWPair buffer
streams that are readable, writable, and both respectively.
BufferedRandom provides a buffered interface to random access
streams. BytesIO is a simple stream of in-memory bytes.
Another IOBase subclass, TextIOBase, deals with the encoding and decoding
of streams into text. TextIOWrapper, which extends it, is a buffered text
interface to a buffered raw stream (`BufferedIOBase`). Finally, StringIO
is a in-memory stream for text.
Argument names are not part of the specification, and only the arguments
of open() are intended to be used as keyword arguments.
data:
DEFAULT_BUFFER_SIZE
An int containing the default buffer size used by the module's buffered
I/O classes. open() uses the file's blksize (as obtained by os.stat) if
possible.
"""
# New I/O library conforming to PEP 3116.
# XXX edge cases when switching between reading/writing
# XXX need to support 1 meaning line-buffered
# XXX whenever an argument is None, use the default value
# XXX read/write ops should check readable/writable
# XXX buffered readinto should work with arbitrary buffer objects
# XXX use incremental encoder for text output, at least for UTF-16 and UTF-8-SIG
# XXX check writable, readable and seekable in appropriate places
__author__ = ("Guido van Rossum <guido@python.org>, "
"Mike Verdone <mike.verdone@gmail.com>, "
"Mark Russell <mark.russell@zen.co.uk>, "
"Antoine Pitrou <solipsis@pitrou.net>, "
"Amaury Forgeot d'Arc <amauryfa@gmail.com>, "
"Benjamin Peterson <benjamin@python.org>")
__all__ = ["BlockingIOError", "open", "IOBase", "RawIOBase", "FileIO",
"BytesIO", "StringIO", "BufferedIOBase",
"BufferedReader", "BufferedWriter", "BufferedRWPair",
"BufferedRandom", "TextIOBase", "TextIOWrapper",
"UnsupportedOperation", "SEEK_SET", "SEEK_CUR", "SEEK_END"]
import _io
import abc
from _io import (DEFAULT_BUFFER_SIZE, BlockingIOError, UnsupportedOperation,
open, FileIO, BytesIO, StringIO, BufferedReader,
BufferedWriter, BufferedRWPair, BufferedRandom,
IncrementalNewlineDecoder, TextIOWrapper)
OpenWrapper = _io.open # for compatibility with _pyio
# for seek()
SEEK_SET = 0
SEEK_CUR = 1
SEEK_END = 2
# Declaring ABCs in C is tricky so we do it here.
# Method descriptions and default implementations are inherited from the C
# version however.
class IOBase(_io._IOBase):
__metaclass__ = abc.ABCMeta
class RawIOBase(_io._RawIOBase, IOBase):
pass
class BufferedIOBase(_io._BufferedIOBase, IOBase):
pass
class TextIOBase(_io._TextIOBase, IOBase):
pass
RawIOBase.register(FileIO)
for klass in (BytesIO, BufferedReader, BufferedWriter, BufferedRandom,
BufferedRWPair):
BufferedIOBase.register(klass)
for klass in (StringIO, TextIOWrapper):
TextIOBase.register(klass)
del klass
|
gpl-3.0
|
[
624,
1918,
5890,
859,
6571,
314,
2018,
8386,
370,
2547,
7252,
14,
710,
202,
199,
5351,
1551,
805,
365,
3247,
315,
642,
859,
14,
2999,
199,
1271,
314,
2746,
402,
314,
473,
15,
47,
14446,
365,
314,
9006,
1300,
1021,
5004,
1563,
14,
2779,
202,
199,
14334,
314,
5678,
3217,
370,
282,
2547,
14,
3390,
12,
13432,
12,
626,
2337,
365,
949,
202,
199,
6175,
425,
3382,
7664,
436,
3575,
370,
13788,
27,
12591,
787,
202,
199,
6541,
370,
7978,
376,
5925,
340,
2985,
886,
440,
2291,
282,
1627,
3439,
14,
2999,
199,
4377,
1098,
5004,
1563,
365,
13480,
23413,
1314,
477,
2551,
9329,
543,
314,
7664,
436,
202,
199,
14827,
402,
3066,
2783,
370,
282,
2547,
14,
3814,
2090,
9180,
13480,
23413,
370,
5647,
202,
199,
290,
3217,
370,
4403,
1584,
14,
2999,
199,
23139,
23413,
477,
2551,
543,
21033,
641,
282,
3066,
3696,
2547,
334,
7963,
23413,
680,
22940,
202,
199,
19094,
12,
26832,
6261,
12,
26832,
5929,
12,
436,
26832,
25438,
12882,
3335,
202,
199,
11231,
626,
787,
12701,
12,
17267,
12,
436,
3865,
17342,
14,
202,
199,
23139,
3883,
6571,
282,
20224,
3217,
370,
2196,
2879,
202,
199,
11231,
14,
11808,
365,
282,
3486,
2547,
402,
315,
13,
4844,
2783,
14,
2999,
199,
23296,
5004,
1563,
5516,
12,
4516,
23413,
12,
477,
2551,
543,
314,
2644,
436,
15952,
202,
199,
1618,
13788,
1901,
1318,
14,
4516,
29365,
12,
1314,
16879,
652,
12,
365,
282,
20224,
1318,
202,
199,
3266,
370,
282,
20224,
3066,
2547,
13493,
23139,
23413,
14963,
19177,
12,
5228,
202,
199,
374,
282,
315,
13,
4844,
2547,
367,
1318,
14,
2999,
199,
5201,
1561,
787,
440,
1777,
402,
314,
8929,
12,
436,
1454,
314,
2368,
202,
199,
1618,
1551,
342,
787,
11619,
370,
506,
1202,
465,
4252,
2368,
14,
2999,
199,
576,
26,
2999,
199,
3472,
63,
10960,
63,
4305,
10060,
257,
1626,
1109,
3035,
314,
849,
3335,
1568,
1202,
701,
314,
859,
1159,
20224,
15497,
473,
15,
47,
3992,
14,
1551,
342,
4440,
314,
570,
1159,
22742,
890,
334,
305,
15884,
701,
747,
14,
3736,
9,
340,
15497,
3962,
14,
202,
199,
624,
202,
199,
3,
7053,
473,
15,
47,
3555,
26449,
316,
370,
13663,
650,
7524,
14,
2999,
199,
3,
5787,
6275,
5560,
1380,
31620,
3382,
7664,
15,
14827,
202,
199,
3,
5787,
1929,
370,
2291,
413,
11150,
1004,
13,
17605,
202,
199,
3,
5787,
18119,
376,
1423,
365,
488,
12,
675,
314,
849,
574,
202,
199,
3,
5787,
1586,
15,
952,
4156,
1077,
1104,
12701,
15,
15053,
202,
199,
3,
5787,
20224,
1586,
9924,
1077,
1736,
543,
9697,
3335,
2251,
202,
199,
3,
5787,
675,
16316,
10295,
367,
1318,
1072,
12,
737,
5210,
367,
9094,
13,
975,
436,
9094,
13,
24,
13,
7864,
202,
199,
3,
5787,
1104,
17267,
12,
12701,
436,
12005,
461,
315,
5827,
9825,
8065,
199,
363,
2502,
363,
275,
1689,
18834,
79,
20744,
6848,
385,
453,
665,
9473,
79,
32,
1548,
14,
1308,
6244,
298,
23284,
298,
45,
7455,
5444,
4456,
665,
2664,
415,
14,
422,
4456,
32,
6799,
14,
957,
6244,
298,
23284,
298,
6470,
820,
527,
23235,
665,
1657,
14,
20791,
23235,
32,
5193,
14,
331,
14,
3210,
6244,
298,
23284,
298,
33,
29680,
1132,
510,
390,
7930,
665,
1152,
3587,
2316,
32,
80,
390,
7930,
14,
846,
6244,
298,
23284,
298,
33,
391,
18359,
2104,
303,
357,
366,
7,
27604,
665,
14541,
18359,
667,
32,
6799,
14,
957,
6244,
298,
23284,
298,
31231,
16997,
262,
22912,
834,
665,
18486,
16997,
262,
32,
1548,
14,
1308,
9579,
2999,
199,
363,
452,
363,
275,
2097,
27132,
13760,
401,
298,
1490,
401,
298,
23413,
401,
298,
7963,
23413,
401,
298,
26126,
401,
18691,
298,
15466,
401,
298,
6424,
401,
298,
23139,
23413,
401,
18691,
298,
23139,
5929,
401,
298,
23139,
6261,
401,
298,
23139,
25438,
12882,
401,
18691,
298,
23139,
3883,
401,
298,
1872,
23413,
401,
298,
1872,
29365,
401,
18691,
298,
12647,
6044,
401,
298,
18439,
63,
3597,
401,
298,
18439,
63,
7013,
401,
298,
18439,
63,
3902,
937,
8065,
199,
646,
485,
2308,
202,
199,
646,
13022,
2999,
199,
504,
485,
2308,
492,
334,
3472,
63,
10960,
63,
4305,
12,
8651,
316,
13760,
12,
19022,
6044,
12,
20085,
1551,
12,
3814,
2090,
12,
11808,
12,
5228,
12,
26832,
5929,
12,
20085,
26832,
6261,
12,
26832,
25438,
12882,
12,
26832,
3883,
12,
20085,
14684,
4665,
604,
8326,
12,
4516,
29365,
9,
2999,
199,
4299,
4590,
275,
485,
2308,
14,
1490,
327,
367,
7163,
543,
485,
647,
2308,
2999,
199,
3,
367,
12005,
342,
202,
199,
18439,
63,
3597,
275,
378,
202,
199,
18439,
63,
7013,
275,
413,
202,
199,
18439,
63,
3902,
275,
499,
2999,
199,
3,
1487,
4925,
316,
17281,
83,
315,
445,
365,
32553,
880,
781,
886,
652,
2348,
14,
202,
199,
3,
9075,
18714,
436,
849,
12591,
787,
12623,
687,
314,
445,
202,
199,
3,
1015,
13432,
14,
202,
199,
533,
5004,
1563,
1547,
2308,
423,
23413,
304,
1128,
636,
6577,
363,
275,
13022,
14,
22254,
2999,
199,
533,
13480,
23413,
1547,
2308,
423,
7963,
23413,
12,
5004,
1563,
304,
1128,
986,
2999,
199,
533,
26832,
23413,
1547,
2308,
423,
23139,
23413,
12,
5004,
1563,
304,
1128,
986,
2999,
199,
533,
4516,
23413,
1547,
2308,
423,
1872,
23413,
12,
5004,
1563,
304,
1128,
986,
2999,
199,
7963,
23413,
14,
2683,
8,
26126,
9,
2999,
199,
509,
8531,
315,
334,
15466,
12,
26832,
5929,
12,
26832,
6261,
12,
26832,
3883,
12,
23284,
26832,
25438,
12882,
304,
1128,
26832,
23413,
14,
2683,
8,
11645,
9,
2999,
199,
509,
8531,
315,
334,
6424,
12,
4516,
29365,
304,
1128,
4516,
23413,
14,
2683,
8,
11645,
9,
202,
199,
2264,
8531,
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
] |
[
1918,
5890,
859,
6571,
314,
2018,
8386,
370,
2547,
7252,
14,
710,
202,
199,
5351,
1551,
805,
365,
3247,
315,
642,
859,
14,
2999,
199,
1271,
314,
2746,
402,
314,
473,
15,
47,
14446,
365,
314,
9006,
1300,
1021,
5004,
1563,
14,
2779,
202,
199,
14334,
314,
5678,
3217,
370,
282,
2547,
14,
3390,
12,
13432,
12,
626,
2337,
365,
949,
202,
199,
6175,
425,
3382,
7664,
436,
3575,
370,
13788,
27,
12591,
787,
202,
199,
6541,
370,
7978,
376,
5925,
340,
2985,
886,
440,
2291,
282,
1627,
3439,
14,
2999,
199,
4377,
1098,
5004,
1563,
365,
13480,
23413,
1314,
477,
2551,
9329,
543,
314,
7664,
436,
202,
199,
14827,
402,
3066,
2783,
370,
282,
2547,
14,
3814,
2090,
9180,
13480,
23413,
370,
5647,
202,
199,
290,
3217,
370,
4403,
1584,
14,
2999,
199,
23139,
23413,
477,
2551,
543,
21033,
641,
282,
3066,
3696,
2547,
334,
7963,
23413,
680,
22940,
202,
199,
19094,
12,
26832,
6261,
12,
26832,
5929,
12,
436,
26832,
25438,
12882,
3335,
202,
199,
11231,
626,
787,
12701,
12,
17267,
12,
436,
3865,
17342,
14,
202,
199,
23139,
3883,
6571,
282,
20224,
3217,
370,
2196,
2879,
202,
199,
11231,
14,
11808,
365,
282,
3486,
2547,
402,
315,
13,
4844,
2783,
14,
2999,
199,
23296,
5004,
1563,
5516,
12,
4516,
23413,
12,
477,
2551,
543,
314,
2644,
436,
15952,
202,
199,
1618,
13788,
1901,
1318,
14,
4516,
29365,
12,
1314,
16879,
652,
12,
365,
282,
20224,
1318,
202,
199,
3266,
370,
282,
20224,
3066,
2547,
13493,
23139,
23413,
14963,
19177,
12,
5228,
202,
199,
374,
282,
315,
13,
4844,
2547,
367,
1318,
14,
2999,
199,
5201,
1561,
787,
440,
1777,
402,
314,
8929,
12,
436,
1454,
314,
2368,
202,
199,
1618,
1551,
342,
787,
11619,
370,
506,
1202,
465,
4252,
2368,
14,
2999,
199,
576,
26,
2999,
199,
3472,
63,
10960,
63,
4305,
10060,
257,
1626,
1109,
3035,
314,
849,
3335,
1568,
1202,
701,
314,
859,
1159,
20224,
15497,
473,
15,
47,
3992,
14,
1551,
342,
4440,
314,
570,
1159,
22742,
890,
334,
305,
15884,
701,
747,
14,
3736,
9,
340,
15497,
3962,
14,
202,
199,
624,
202,
199,
3,
7053,
473,
15,
47,
3555,
26449,
316,
370,
13663,
650,
7524,
14,
2999,
199,
3,
5787,
6275,
5560,
1380,
31620,
3382,
7664,
15,
14827,
202,
199,
3,
5787,
1929,
370,
2291,
413,
11150,
1004,
13,
17605,
202,
199,
3,
5787,
18119,
376,
1423,
365,
488,
12,
675,
314,
849,
574,
202,
199,
3,
5787,
1586,
15,
952,
4156,
1077,
1104,
12701,
15,
15053,
202,
199,
3,
5787,
20224,
1586,
9924,
1077,
1736,
543,
9697,
3335,
2251,
202,
199,
3,
5787,
675,
16316,
10295,
367,
1318,
1072,
12,
737,
5210,
367,
9094,
13,
975,
436,
9094,
13,
24,
13,
7864,
202,
199,
3,
5787,
1104,
17267,
12,
12701,
436,
12005,
461,
315,
5827,
9825,
8065,
199,
363,
2502,
363,
275,
1689,
18834,
79,
20744,
6848,
385,
453,
665,
9473,
79,
32,
1548,
14,
1308,
6244,
298,
23284,
298,
45,
7455,
5444,
4456,
665,
2664,
415,
14,
422,
4456,
32,
6799,
14,
957,
6244,
298,
23284,
298,
6470,
820,
527,
23235,
665,
1657,
14,
20791,
23235,
32,
5193,
14,
331,
14,
3210,
6244,
298,
23284,
298,
33,
29680,
1132,
510,
390,
7930,
665,
1152,
3587,
2316,
32,
80,
390,
7930,
14,
846,
6244,
298,
23284,
298,
33,
391,
18359,
2104,
303,
357,
366,
7,
27604,
665,
14541,
18359,
667,
32,
6799,
14,
957,
6244,
298,
23284,
298,
31231,
16997,
262,
22912,
834,
665,
18486,
16997,
262,
32,
1548,
14,
1308,
9579,
2999,
199,
363,
452,
363,
275,
2097,
27132,
13760,
401,
298,
1490,
401,
298,
23413,
401,
298,
7963,
23413,
401,
298,
26126,
401,
18691,
298,
15466,
401,
298,
6424,
401,
298,
23139,
23413,
401,
18691,
298,
23139,
5929,
401,
298,
23139,
6261,
401,
298,
23139,
25438,
12882,
401,
18691,
298,
23139,
3883,
401,
298,
1872,
23413,
401,
298,
1872,
29365,
401,
18691,
298,
12647,
6044,
401,
298,
18439,
63,
3597,
401,
298,
18439,
63,
7013,
401,
298,
18439,
63,
3902,
937,
8065,
199,
646,
485,
2308,
202,
199,
646,
13022,
2999,
199,
504,
485,
2308,
492,
334,
3472,
63,
10960,
63,
4305,
12,
8651,
316,
13760,
12,
19022,
6044,
12,
20085,
1551,
12,
3814,
2090,
12,
11808,
12,
5228,
12,
26832,
5929,
12,
20085,
26832,
6261,
12,
26832,
25438,
12882,
12,
26832,
3883,
12,
20085,
14684,
4665,
604,
8326,
12,
4516,
29365,
9,
2999,
199,
4299,
4590,
275,
485,
2308,
14,
1490,
327,
367,
7163,
543,
485,
647,
2308,
2999,
199,
3,
367,
12005,
342,
202,
199,
18439,
63,
3597,
275,
378,
202,
199,
18439,
63,
7013,
275,
413,
202,
199,
18439,
63,
3902,
275,
499,
2999,
199,
3,
1487,
4925,
316,
17281,
83,
315,
445,
365,
32553,
880,
781,
886,
652,
2348,
14,
202,
199,
3,
9075,
18714,
436,
849,
12591,
787,
12623,
687,
314,
445,
202,
199,
3,
1015,
13432,
14,
202,
199,
533,
5004,
1563,
1547,
2308,
423,
23413,
304,
1128,
636,
6577,
363,
275,
13022,
14,
22254,
2999,
199,
533,
13480,
23413,
1547,
2308,
423,
7963,
23413,
12,
5004,
1563,
304,
1128,
986,
2999,
199,
533,
26832,
23413,
1547,
2308,
423,
23139,
23413,
12,
5004,
1563,
304,
1128,
986,
2999,
199,
533,
4516,
23413,
1547,
2308,
423,
1872,
23413,
12,
5004,
1563,
304,
1128,
986,
2999,
199,
7963,
23413,
14,
2683,
8,
26126,
9,
2999,
199,
509,
8531,
315,
334,
15466,
12,
26832,
5929,
12,
26832,
6261,
12,
26832,
3883,
12,
23284,
26832,
25438,
12882,
304,
1128,
26832,
23413,
14,
2683,
8,
11645,
9,
2999,
199,
509,
8531,
315,
334,
6424,
12,
4516,
29365,
304,
1128,
4516,
23413,
14,
2683,
8,
11645,
9,
202,
199,
2264,
8531,
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,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
VirtusLab/ansible-modules-extras
|
windows/win_iis_website.py
|
84
|
3462
|
#!/usr/bin/python
# -*- coding: utf-8 -*-
# (c) 2015, Henrik Wallström <henrik@wallstroms.nu>
#
# 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: win_iis_website
version_added: "2.0"
short_description: Configures a IIS Web site.
description:
- Creates, Removes and configures a IIS Web site
options:
name:
description:
- Names of web site
required: true
default: null
aliases: []
state:
description:
- State of the web site
choices:
- started
- restarted
- stopped
- absent
required: false
default: null
aliases: []
physical_path:
description:
- The physical path on the remote host to use for the new site. The specified folder must already exist.
required: false
default: null
aliases: []
application_pool:
description:
- The application pool in which the new site executes.
required: false
default: null
aliases: []
port:
description:
- The port to bind to / use for the new site.
required: false
default: null
aliases: []
ip:
description:
- The IP address to bind to / use for the new site.
required: false
default: null
aliases: []
hostname:
description:
- The host header to bind to / use for the new site.
required: false
default: null
aliases: []
ssl:
description:
- Enables HTTPS binding on the site..
required: false
default: null
aliases: []
parameters:
description:
- Custom site Parameters from string where properties are seperated by a pipe and property name/values by colon Ex. "foo:1|bar:2"
required: false
default: null
aliases: []
author: Henrik Wallström
'''
EXAMPLES = '''
# This return information about an existing host
$ ansible -i vagrant-inventory -m win_iis_website -a "name='Default Web Site'" window
host | success >> {
"changed": false,
"site": {
"ApplicationPool": "DefaultAppPool",
"Bindings": [
"*:80:"
],
"ID": 1,
"Name": "Default Web Site",
"PhysicalPath": "%SystemDrive%\\inetpub\\wwwroot",
"State": "Stopped"
}
}
# This stops an existing site.
$ ansible -i hosts -m win_iis_website -a "name='Default Web Site' state=stopped" host
# This creates a new site.
$ ansible -i hosts -m win_iis_website -a "name=acme physical_path=c:\\sites\\acme" host
# Change logfile .
$ ansible -i hosts -m win_iis_website -a "name=acme physical_path=c:\\sites\\acme" host
# Playbook example
---
- name: Acme IIS site
win_iis_website:
name: "Acme"
state: started
port: 80
ip: 127.0.0.1
hostname: acme.local
application_pool: "acme"
physical_path: 'c:\\sites\\acme'
parameters: 'logfile.directory:c:\\sites\\logs'
register: website
'''
|
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,
20855,
25844,
644,
452,
495,
14614,
77,
665,
16800,
25844,
32,
7567,
31672,
83,
14,
4850,
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,
4747,
63,
73,
374,
63,
7360,
199,
1023,
63,
3270,
26,
298,
18,
14,
16,
2,
199,
3612,
63,
1802,
26,
4094,
1482,
282,
473,
1311,
6001,
4770,
14,
199,
1802,
26,
1362,
446,
10560,
12,
23169,
436,
1101,
1482,
282,
473,
1311,
6001,
4770,
199,
1419,
26,
523,
536,
26,
272,
1369,
26,
489,
446,
23923,
402,
3330,
4770,
272,
1415,
26,
2549,
272,
849,
26,
2973,
272,
5481,
26,
942,
523,
1174,
26,
272,
1369,
26,
489,
446,
8511,
402,
314,
3330,
4770,
272,
3415,
26,
489,
446,
8239,
489,
446,
32277,
489,
446,
15248,
489,
446,
9552,
272,
1415,
26,
3055,
272,
849,
26,
2973,
272,
5481,
26,
942,
523,
14095,
63,
515,
26,
272,
1369,
26,
489,
446,
710,
14095,
931,
641,
314,
3982,
1591,
370,
675,
367,
314,
892,
4770,
14,
710,
2013,
4922,
1471,
2575,
2187,
14,
272,
1415,
26,
3055,
272,
849,
26,
2973,
272,
5481,
26,
942,
523,
4223,
63,
2293,
26,
272,
1369,
26,
489,
446,
710,
4223,
4203,
315,
1314,
314,
892,
4770,
24956,
14,
272,
1415,
26,
3055,
272,
849,
26,
2973,
272,
5481,
26,
942,
523,
1844,
26,
272,
1369,
26,
489,
446,
710,
1844,
370,
5398,
370,
1182,
675,
367,
314,
892,
4770,
14,
272,
1415,
26,
3055,
272,
849,
26,
2973,
272,
5481,
26,
942,
523,
3384,
26,
272,
1369,
26,
489,
446,
710,
3531,
2287,
370,
5398,
370,
1182,
675,
367,
314,
892,
4770,
14,
272,
1415,
26,
3055,
272,
849,
26,
2973,
272,
5481,
26,
942,
523,
6246,
26,
272,
1369,
26,
489,
446,
710,
1591,
1406,
370,
5398,
370,
1182,
675,
367,
314,
892,
4770,
14,
272,
1415,
26,
3055,
272,
849,
26,
2973,
272,
5481,
26,
942,
523,
6149,
26,
272,
1369,
26,
489,
446,
3447,
5921,
14147,
11696,
641,
314,
4770,
703,
272,
1415,
26,
3055,
272,
849,
26,
2973,
272,
5481,
26,
942,
523,
2633,
26,
272,
1369,
26,
489,
446,
8388,
4770,
3897,
687,
1059,
2382,
4382,
787,
542,
529,
972,
701,
282,
5200,
436,
3324,
536,
15,
1459,
701,
18307,
1316,
14,
298,
1421,
26,
17,
92,
1700,
26,
18,
2,
272,
1415,
26,
3055,
272,
849,
26,
2973,
272,
5481,
26,
942,
199,
2502,
26,
20855,
25844,
644,
452,
495,
14614,
77,
199,
2344,
199,
199,
8918,
275,
1449,
199,
3,
961,
372,
2556,
3595,
376,
3411,
1591,
199,
4,
3242,
446,
73,
373,
643,
17633,
13,
7212,
446,
77,
4747,
63,
73,
374,
63,
7360,
446,
65,
298,
354,
534,
2698,
6001,
11666,
4065,
4353,
199,
1102,
1204,
3182,
4331,
469,
272,
298,
2489,
582,
3055,
12,
272,
298,
2124,
582,
469,
267,
298,
5039,
5453,
582,
298,
2698,
2640,
5453,
401,
267,
298,
8198,
780,
582,
359,
288,
8969,
26,
1257,
5424,
267,
2156,
267,
298,
998,
582,
413,
12,
267,
298,
985,
582,
298,
2698,
6001,
11666,
401,
267,
298,
20303,
2042,
582,
2071,
3989,
24276,
5,
1103,
10811,
5645,
1103,
1544,
1231,
401,
267,
298,
2223,
582,
298,
28500,
2,
272,
789,
199,
93,
199,
199,
3,
961,
20922,
376,
3411,
4770,
14,
199,
4,
3242,
446,
73,
7057,
446,
77,
4747,
63,
73,
374,
63,
7360,
446,
65,
298,
354,
534,
2698,
6001,
11666,
7,
1174,
29,
14661,
2,
1591,
199,
199,
3,
961,
8491,
282,
892,
4770,
14,
199,
4,
3242,
446,
73,
7057,
446,
77,
4747,
63,
73,
374,
63,
7360,
446,
65,
298,
354,
29,
18107,
14095,
63,
515,
29,
67,
18589,
8619,
1103,
18107,
2,
1591,
199,
199,
3,
7743,
17251,
1275,
199,
4,
3242,
446,
73,
7057,
446,
77,
4747,
63,
73,
374,
63,
7360,
446,
65,
298,
354,
29,
18107,
14095,
63,
515,
29,
67,
18589,
8619,
1103,
18107,
2,
1591,
421,
199,
3,
16527,
2706,
2893,
199,
2595,
199,
199,
13,
536,
26,
4473,
278,
473,
1311,
4770,
523,
4747,
63,
73,
374,
63,
7360,
26,
272,
536,
26,
298,
1945,
278,
2,
272,
1174,
26,
8239,
272,
1844,
26,
5939,
272,
3384,
26,
12792,
14,
16,
14,
16,
14,
17,
272,
6246,
26,
32433,
14,
1832,
272,
4223,
63,
2293,
26,
298,
18107,
2,
272,
14095,
63,
515,
26,
283,
67,
18589,
8619,
1103,
18107,
7,
272,
2633,
26,
283,
12804,
14,
3619,
26,
67,
18589,
8619,
1103,
7270,
7,
523,
2274,
26,
10691,
199,
199,
2344,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
2647,
15,
1393,
15,
1548,
199,
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
199,
3,
334,
67,
9,
6900,
12,
20855,
25844,
644,
452,
495,
14614,
77,
665,
16800,
25844,
32,
7567,
31672,
83,
14,
4850,
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,
4747,
63,
73,
374,
63,
7360,
199,
1023,
63,
3270,
26,
298,
18,
14,
16,
2,
199,
3612,
63,
1802,
26,
4094,
1482,
282,
473,
1311,
6001,
4770,
14,
199,
1802,
26,
1362,
446,
10560,
12,
23169,
436,
1101,
1482,
282,
473,
1311,
6001,
4770,
199,
1419,
26,
523,
536,
26,
272,
1369,
26,
489,
446,
23923,
402,
3330,
4770,
272,
1415,
26,
2549,
272,
849,
26,
2973,
272,
5481,
26,
942,
523,
1174,
26,
272,
1369,
26,
489,
446,
8511,
402,
314,
3330,
4770,
272,
3415,
26,
489,
446,
8239,
489,
446,
32277,
489,
446,
15248,
489,
446,
9552,
272,
1415,
26,
3055,
272,
849,
26,
2973,
272,
5481,
26,
942,
523,
14095,
63,
515,
26,
272,
1369,
26,
489,
446,
710,
14095,
931,
641,
314,
3982,
1591,
370,
675,
367,
314,
892,
4770,
14,
710,
2013,
4922,
1471,
2575,
2187,
14,
272,
1415,
26,
3055,
272,
849,
26,
2973,
272,
5481,
26,
942,
523,
4223,
63,
2293,
26,
272,
1369,
26,
489,
446,
710,
4223,
4203,
315,
1314,
314,
892,
4770,
24956,
14,
272,
1415,
26,
3055,
272,
849,
26,
2973,
272,
5481,
26,
942,
523,
1844,
26,
272,
1369,
26,
489,
446,
710,
1844,
370,
5398,
370,
1182,
675,
367,
314,
892,
4770,
14,
272,
1415,
26,
3055,
272,
849,
26,
2973,
272,
5481,
26,
942,
523,
3384,
26,
272,
1369,
26,
489,
446,
710,
3531,
2287,
370,
5398,
370,
1182,
675,
367,
314,
892,
4770,
14,
272,
1415,
26,
3055,
272,
849,
26,
2973,
272,
5481,
26,
942,
523,
6246,
26,
272,
1369,
26,
489,
446,
710,
1591,
1406,
370,
5398,
370,
1182,
675,
367,
314,
892,
4770,
14,
272,
1415,
26,
3055,
272,
849,
26,
2973,
272,
5481,
26,
942,
523,
6149,
26,
272,
1369,
26,
489,
446,
3447,
5921,
14147,
11696,
641,
314,
4770,
703,
272,
1415,
26,
3055,
272,
849,
26,
2973,
272,
5481,
26,
942,
523,
2633,
26,
272,
1369,
26,
489,
446,
8388,
4770,
3897,
687,
1059,
2382,
4382,
787,
542,
529,
972,
701,
282,
5200,
436,
3324,
536,
15,
1459,
701,
18307,
1316,
14,
298,
1421,
26,
17,
92,
1700,
26,
18,
2,
272,
1415,
26,
3055,
272,
849,
26,
2973,
272,
5481,
26,
942,
199,
2502,
26,
20855,
25844,
644,
452,
495,
14614,
77,
199,
2344,
199,
199,
8918,
275,
1449,
199,
3,
961,
372,
2556,
3595,
376,
3411,
1591,
199,
4,
3242,
446,
73,
373,
643,
17633,
13,
7212,
446,
77,
4747,
63,
73,
374,
63,
7360,
446,
65,
298,
354,
534,
2698,
6001,
11666,
4065,
4353,
199,
1102,
1204,
3182,
4331,
469,
272,
298,
2489,
582,
3055,
12,
272,
298,
2124,
582,
469,
267,
298,
5039,
5453,
582,
298,
2698,
2640,
5453,
401,
267,
298,
8198,
780,
582,
359,
288,
8969,
26,
1257,
5424,
267,
2156,
267,
298,
998,
582,
413,
12,
267,
298,
985,
582,
298,
2698,
6001,
11666,
401,
267,
298,
20303,
2042,
582,
2071,
3989,
24276,
5,
1103,
10811,
5645,
1103,
1544,
1231,
401,
267,
298,
2223,
582,
298,
28500,
2,
272,
789,
199,
93,
199,
199,
3,
961,
20922,
376,
3411,
4770,
14,
199,
4,
3242,
446,
73,
7057,
446,
77,
4747,
63,
73,
374,
63,
7360,
446,
65,
298,
354,
534,
2698,
6001,
11666,
7,
1174,
29,
14661,
2,
1591,
199,
199,
3,
961,
8491,
282,
892,
4770,
14,
199,
4,
3242,
446,
73,
7057,
446,
77,
4747,
63,
73,
374,
63,
7360,
446,
65,
298,
354,
29,
18107,
14095,
63,
515,
29,
67,
18589,
8619,
1103,
18107,
2,
1591,
199,
199,
3,
7743,
17251,
1275,
199,
4,
3242,
446,
73,
7057,
446,
77,
4747,
63,
73,
374,
63,
7360,
446,
65,
298,
354,
29,
18107,
14095,
63,
515,
29,
67,
18589,
8619,
1103,
18107,
2,
1591,
421,
199,
3,
16527,
2706,
2893,
199,
2595,
199,
199,
13,
536,
26,
4473,
278,
473,
1311,
4770,
523,
4747,
63,
73,
374,
63,
7360,
26,
272,
536,
26,
298,
1945,
278,
2,
272,
1174,
26,
8239,
272,
1844,
26,
5939,
272,
3384,
26,
12792,
14,
16,
14,
16,
14,
17,
272,
6246,
26,
32433,
14,
1832,
272,
4223,
63,
2293,
26,
298,
18107,
2,
272,
14095,
63,
515,
26,
283,
67,
18589,
8619,
1103,
18107,
7,
272,
2633,
26,
283,
12804,
14,
3619,
26,
67,
18589,
8619,
1103,
7270,
7,
523,
2274,
26,
10691,
199,
199,
2344,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
c0hen/django-venv
|
lib/python3.4/site-packages/django/contrib/contenttypes/forms.py
|
116
|
3620
|
from __future__ import unicode_literals
from django.contrib.contenttypes.models import ContentType
from django.db import models
from django.forms import ModelForm, modelformset_factory
from django.forms.models import BaseModelFormSet
class BaseGenericInlineFormSet(BaseModelFormSet):
"""
A formset for generic inline objects to a parent.
"""
def __init__(self, data=None, files=None, instance=None, save_as_new=None,
prefix=None, queryset=None, **kwargs):
opts = self.model._meta
self.instance = instance
self.rel_name = '-'.join((
opts.app_label, opts.model_name,
self.ct_field.name, self.ct_fk_field.name,
))
if self.instance is None or self.instance.pk is None:
qs = self.model._default_manager.none()
else:
if queryset is None:
queryset = self.model._default_manager
qs = queryset.filter(**{
self.ct_field.name: ContentType.objects.get_for_model(
self.instance, for_concrete_model=self.for_concrete_model),
self.ct_fk_field.name: self.instance.pk,
})
super(BaseGenericInlineFormSet, self).__init__(
queryset=qs, data=data, files=files,
prefix=prefix,
**kwargs
)
@classmethod
def get_default_prefix(cls):
opts = cls.model._meta
return '-'.join((opts.app_label, opts.model_name, cls.ct_field.name, cls.ct_fk_field.name))
def save_new(self, form, commit=True):
setattr(form.instance, self.ct_field.get_attname(), ContentType.objects.get_for_model(self.instance).pk)
setattr(form.instance, self.ct_fk_field.get_attname(), self.instance.pk)
return form.save(commit=commit)
def generic_inlineformset_factory(model, form=ModelForm,
formset=BaseGenericInlineFormSet,
ct_field="content_type", fk_field="object_id",
fields=None, exclude=None,
extra=3, can_order=False, can_delete=True,
max_num=None, formfield_callback=None,
validate_max=False, for_concrete_model=True,
min_num=None, validate_min=False):
"""
Returns a ``GenericInlineFormSet`` for the given kwargs.
You must provide ``ct_field`` and ``fk_field`` if they are different from
the defaults ``content_type`` and ``object_id`` respectively.
"""
opts = model._meta
# if there is no field called `ct_field` let the exception propagate
ct_field = opts.get_field(ct_field)
if not isinstance(ct_field, models.ForeignKey) or ct_field.remote_field.model != ContentType:
raise Exception("fk_name '%s' is not a ForeignKey to ContentType" % ct_field)
fk_field = opts.get_field(fk_field) # let the exception propagate
if exclude is not None:
exclude = list(exclude)
exclude.extend([ct_field.name, fk_field.name])
else:
exclude = [ct_field.name, fk_field.name]
FormSet = modelformset_factory(
model, form=form, formfield_callback=formfield_callback,
formset=formset, extra=extra, can_delete=can_delete,
can_order=can_order, fields=fields, exclude=exclude, max_num=max_num,
validate_max=validate_max, min_num=min_num, validate_min=validate_min,
)
FormSet.ct_field = ct_field
FormSet.ct_fk_field = fk_field
FormSet.for_concrete_model = for_concrete_model
return FormSet
|
gpl-3.0
|
[
504,
636,
2443,
363,
492,
2649,
63,
5955,
199,
199,
504,
1639,
14,
2828,
14,
10778,
14,
992,
492,
14501,
199,
504,
1639,
14,
697,
492,
1709,
199,
504,
1639,
14,
3351,
492,
28455,
12,
29312,
409,
63,
3702,
199,
504,
1639,
14,
3351,
14,
992,
492,
3523,
1685,
14736,
421,
199,
533,
3523,
9417,
10307,
14736,
8,
27687,
14736,
304,
272,
408,
272,
437,
11068,
367,
7809,
8308,
2251,
370,
282,
1676,
14,
272,
408,
339,
347,
636,
826,
721,
277,
12,
666,
29,
403,
12,
1584,
29,
403,
12,
1256,
29,
403,
12,
3354,
63,
305,
63,
1222,
29,
403,
12,
326,
2403,
29,
403,
12,
7594,
29,
403,
12,
1011,
958,
304,
267,
3999,
275,
291,
14,
1238,
423,
2024,
267,
291,
14,
842,
275,
1256,
267,
291,
14,
3369,
63,
354,
275,
2475,
1370,
904,
1332,
288,
3999,
14,
571,
63,
1302,
12,
3999,
14,
1238,
63,
354,
12,
288,
291,
14,
319,
63,
698,
14,
354,
12,
291,
14,
319,
63,
9010,
63,
698,
14,
354,
12,
267,
5082,
267,
340,
291,
14,
842,
365,
488,
503,
291,
14,
842,
14,
2051,
365,
488,
26,
288,
6377,
275,
291,
14,
1238,
423,
885,
63,
2609,
14,
3592,
342,
267,
587,
26,
288,
340,
7594,
365,
488,
26,
355,
7594,
275,
291,
14,
1238,
423,
885,
63,
2609,
288,
6377,
275,
7594,
14,
1541,
25679,
355,
291,
14,
319,
63,
698,
14,
354,
26,
14501,
14,
1462,
14,
362,
63,
509,
63,
1238,
8,
490,
291,
14,
842,
12,
367,
63,
13455,
63,
1238,
29,
277,
14,
509,
63,
13455,
63,
1238,
395,
355,
291,
14,
319,
63,
9010,
63,
698,
14,
354,
26,
291,
14,
842,
14,
2051,
12,
288,
3828,
267,
1613,
8,
1563,
9417,
10307,
14736,
12,
291,
2843,
826,
721,
288,
7594,
29,
6177,
12,
666,
29,
576,
12,
1584,
29,
1725,
12,
288,
2403,
29,
1861,
12,
288,
1011,
958,
267,
776,
339,
768,
3744,
272,
347,
664,
63,
885,
63,
1861,
8,
1886,
304,
267,
3999,
275,
843,
14,
1238,
423,
2024,
267,
372,
2475,
1370,
904,
1332,
3291,
14,
571,
63,
1302,
12,
3999,
14,
1238,
63,
354,
12,
843,
14,
319,
63,
698,
14,
354,
12,
843,
14,
319,
63,
9010,
63,
698,
14,
354,
430,
339,
347,
3354,
63,
1222,
8,
277,
12,
1824,
12,
5532,
29,
549,
304,
267,
5371,
8,
964,
14,
842,
12,
291,
14,
319,
63,
698,
14,
362,
63,
13651,
1062,
14501,
14,
1462,
14,
362,
63,
509,
63,
1238,
8,
277,
14,
842,
680,
2051,
9,
267,
5371,
8,
964,
14,
842,
12,
291,
14,
319,
63,
9010,
63,
698,
14,
362,
63,
13651,
1062,
291,
14,
842,
14,
2051,
9,
267,
372,
1824,
14,
2117,
8,
3543,
29,
3543,
9,
421,
199,
318,
7809,
63,
6460,
10724,
63,
3702,
8,
1238,
12,
1824,
29,
15937,
12,
3303,
11068,
29,
1563,
9417,
10307,
14736,
12,
3303,
9428,
63,
698,
628,
1317,
63,
466,
401,
14830,
63,
698,
628,
785,
63,
344,
401,
3303,
1504,
29,
403,
12,
5760,
29,
403,
12,
3303,
2402,
29,
19,
12,
883,
63,
1648,
29,
797,
12,
883,
63,
1807,
29,
549,
12,
3303,
1390,
63,
1507,
29,
403,
12,
21388,
63,
3058,
29,
403,
12,
3303,
4107,
63,
988,
29,
797,
12,
367,
63,
13455,
63,
1238,
29,
549,
12,
3303,
1748,
63,
1507,
29,
403,
12,
4107,
63,
827,
29,
797,
304,
272,
408,
272,
1803,
282,
1124,
9417,
10307,
14736,
1040,
367,
314,
1627,
2074,
14,
339,
2047,
1471,
5647,
1124,
319,
63,
698,
1040,
436,
1124,
9010,
63,
698,
1040,
340,
2985,
787,
3365,
687,
272,
314,
4243,
1124,
1317,
63,
466,
1040,
436,
1124,
785,
63,
344,
1040,
17342,
14,
272,
408,
272,
3999,
275,
1402,
423,
2024,
272,
327,
340,
2337,
365,
949,
901,
2797,
658,
319,
63,
698,
64,
4691,
314,
1919,
19843,
272,
9428,
63,
698,
275,
3999,
14,
362,
63,
698,
8,
319,
63,
698,
9,
272,
340,
440,
1228,
8,
319,
63,
698,
12,
1709,
14,
3190,
9,
503,
9428,
63,
698,
14,
3846,
63,
698,
14,
1238,
1137,
14501,
26,
267,
746,
2186,
480,
9010,
63,
354,
1543,
83,
7,
365,
440,
282,
12718,
370,
14501,
2,
450,
9428,
63,
698,
9,
272,
14830,
63,
698,
275,
3999,
14,
362,
63,
698,
8,
9010,
63,
698,
9,
221,
327,
4691,
314,
1919,
19843,
272,
340,
5760,
365,
440,
488,
26,
267,
5760,
275,
769,
8,
5473,
9,
267,
5760,
14,
2880,
779,
319,
63,
698,
14,
354,
12,
14830,
63,
698,
14,
354,
566,
272,
587,
26,
267,
5760,
275,
359,
319,
63,
698,
14,
354,
12,
14830,
63,
698,
14,
354,
61,
272,
25260,
275,
29312,
409,
63,
3702,
8,
267,
1402,
12,
1824,
29,
964,
12,
21388,
63,
3058,
29,
20015,
63,
3058,
12,
267,
11068,
29,
10724,
12,
2402,
29,
2911,
12,
883,
63,
1807,
29,
2425,
63,
1807,
12,
267,
883,
63,
1648,
29,
2425,
63,
1648,
12,
1504,
29,
955,
12,
5760,
29,
5473,
12,
1390,
63,
1507,
29,
988,
63,
1507,
12,
267,
4107,
63,
988,
29,
3502,
63,
988,
12,
1748,
63,
1507,
29,
827,
63,
1507,
12,
4107,
63,
827,
29,
3502,
63,
827,
12,
272,
776,
272,
25260,
14,
319,
63,
698,
275,
9428,
63,
698,
272,
25260,
14,
319,
63,
9010,
63,
698,
275,
14830,
63,
698,
272,
25260,
14,
509,
63,
13455,
63,
1238,
275,
367,
63,
13455,
63,
1238,
272,
372,
25260,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
636,
2443,
363,
492,
2649,
63,
5955,
199,
199,
504,
1639,
14,
2828,
14,
10778,
14,
992,
492,
14501,
199,
504,
1639,
14,
697,
492,
1709,
199,
504,
1639,
14,
3351,
492,
28455,
12,
29312,
409,
63,
3702,
199,
504,
1639,
14,
3351,
14,
992,
492,
3523,
1685,
14736,
421,
199,
533,
3523,
9417,
10307,
14736,
8,
27687,
14736,
304,
272,
408,
272,
437,
11068,
367,
7809,
8308,
2251,
370,
282,
1676,
14,
272,
408,
339,
347,
636,
826,
721,
277,
12,
666,
29,
403,
12,
1584,
29,
403,
12,
1256,
29,
403,
12,
3354,
63,
305,
63,
1222,
29,
403,
12,
326,
2403,
29,
403,
12,
7594,
29,
403,
12,
1011,
958,
304,
267,
3999,
275,
291,
14,
1238,
423,
2024,
267,
291,
14,
842,
275,
1256,
267,
291,
14,
3369,
63,
354,
275,
2475,
1370,
904,
1332,
288,
3999,
14,
571,
63,
1302,
12,
3999,
14,
1238,
63,
354,
12,
288,
291,
14,
319,
63,
698,
14,
354,
12,
291,
14,
319,
63,
9010,
63,
698,
14,
354,
12,
267,
5082,
267,
340,
291,
14,
842,
365,
488,
503,
291,
14,
842,
14,
2051,
365,
488,
26,
288,
6377,
275,
291,
14,
1238,
423,
885,
63,
2609,
14,
3592,
342,
267,
587,
26,
288,
340,
7594,
365,
488,
26,
355,
7594,
275,
291,
14,
1238,
423,
885,
63,
2609,
288,
6377,
275,
7594,
14,
1541,
25679,
355,
291,
14,
319,
63,
698,
14,
354,
26,
14501,
14,
1462,
14,
362,
63,
509,
63,
1238,
8,
490,
291,
14,
842,
12,
367,
63,
13455,
63,
1238,
29,
277,
14,
509,
63,
13455,
63,
1238,
395,
355,
291,
14,
319,
63,
9010,
63,
698,
14,
354,
26,
291,
14,
842,
14,
2051,
12,
288,
3828,
267,
1613,
8,
1563,
9417,
10307,
14736,
12,
291,
2843,
826,
721,
288,
7594,
29,
6177,
12,
666,
29,
576,
12,
1584,
29,
1725,
12,
288,
2403,
29,
1861,
12,
288,
1011,
958,
267,
776,
339,
768,
3744,
272,
347,
664,
63,
885,
63,
1861,
8,
1886,
304,
267,
3999,
275,
843,
14,
1238,
423,
2024,
267,
372,
2475,
1370,
904,
1332,
3291,
14,
571,
63,
1302,
12,
3999,
14,
1238,
63,
354,
12,
843,
14,
319,
63,
698,
14,
354,
12,
843,
14,
319,
63,
9010,
63,
698,
14,
354,
430,
339,
347,
3354,
63,
1222,
8,
277,
12,
1824,
12,
5532,
29,
549,
304,
267,
5371,
8,
964,
14,
842,
12,
291,
14,
319,
63,
698,
14,
362,
63,
13651,
1062,
14501,
14,
1462,
14,
362,
63,
509,
63,
1238,
8,
277,
14,
842,
680,
2051,
9,
267,
5371,
8,
964,
14,
842,
12,
291,
14,
319,
63,
9010,
63,
698,
14,
362,
63,
13651,
1062,
291,
14,
842,
14,
2051,
9,
267,
372,
1824,
14,
2117,
8,
3543,
29,
3543,
9,
421,
199,
318,
7809,
63,
6460,
10724,
63,
3702,
8,
1238,
12,
1824,
29,
15937,
12,
3303,
11068,
29,
1563,
9417,
10307,
14736,
12,
3303,
9428,
63,
698,
628,
1317,
63,
466,
401,
14830,
63,
698,
628,
785,
63,
344,
401,
3303,
1504,
29,
403,
12,
5760,
29,
403,
12,
3303,
2402,
29,
19,
12,
883,
63,
1648,
29,
797,
12,
883,
63,
1807,
29,
549,
12,
3303,
1390,
63,
1507,
29,
403,
12,
21388,
63,
3058,
29,
403,
12,
3303,
4107,
63,
988,
29,
797,
12,
367,
63,
13455,
63,
1238,
29,
549,
12,
3303,
1748,
63,
1507,
29,
403,
12,
4107,
63,
827,
29,
797,
304,
272,
408,
272,
1803,
282,
1124,
9417,
10307,
14736,
1040,
367,
314,
1627,
2074,
14,
339,
2047,
1471,
5647,
1124,
319,
63,
698,
1040,
436,
1124,
9010,
63,
698,
1040,
340,
2985,
787,
3365,
687,
272,
314,
4243,
1124,
1317,
63,
466,
1040,
436,
1124,
785,
63,
344,
1040,
17342,
14,
272,
408,
272,
3999,
275,
1402,
423,
2024,
272,
327,
340,
2337,
365,
949,
901,
2797,
658,
319,
63,
698,
64,
4691,
314,
1919,
19843,
272,
9428,
63,
698,
275,
3999,
14,
362,
63,
698,
8,
319,
63,
698,
9,
272,
340,
440,
1228,
8,
319,
63,
698,
12,
1709,
14,
3190,
9,
503,
9428,
63,
698,
14,
3846,
63,
698,
14,
1238,
1137,
14501,
26,
267,
746,
2186,
480,
9010,
63,
354,
1543,
83,
7,
365,
440,
282,
12718,
370,
14501,
2,
450,
9428,
63,
698,
9,
272,
14830,
63,
698,
275,
3999,
14,
362,
63,
698,
8,
9010,
63,
698,
9,
221,
327,
4691,
314,
1919,
19843,
272,
340,
5760,
365,
440,
488,
26,
267,
5760,
275,
769,
8,
5473,
9,
267,
5760,
14,
2880,
779,
319,
63,
698,
14,
354,
12,
14830,
63,
698,
14,
354,
566,
272,
587,
26,
267,
5760,
275,
359,
319,
63,
698,
14,
354,
12,
14830,
63,
698,
14,
354,
61,
272,
25260,
275,
29312,
409,
63,
3702,
8,
267,
1402,
12,
1824,
29,
964,
12,
21388,
63,
3058,
29,
20015,
63,
3058,
12,
267,
11068,
29,
10724,
12,
2402,
29,
2911,
12,
883,
63,
1807,
29,
2425,
63,
1807,
12,
267,
883,
63,
1648,
29,
2425,
63,
1648,
12,
1504,
29,
955,
12,
5760,
29,
5473,
12,
1390,
63,
1507,
29,
988,
63,
1507,
12,
267,
4107,
63,
988,
29,
3502,
63,
988,
12,
1748,
63,
1507,
29,
827,
63,
1507,
12,
4107,
63,
827,
29,
3502,
63,
827,
12,
272,
776,
272,
25260,
14,
319,
63,
698,
275,
9428,
63,
698,
272,
25260,
14,
319,
63,
9010,
63,
698,
275,
14830,
63,
698,
272,
25260,
14,
509,
63,
13455,
63,
1238,
275,
367,
63,
13455,
63,
1238,
272,
372,
25260,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,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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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
dcrozier/PyTest
|
IT Management/ssfusd_speaker_finder.py
|
1
|
3343
|
import yaml
import os
import sys
import re
import library
import csv
from collections import defaultdict
import netaddr
from multiprocessing.pool import ThreadPool
print("Post Deployment - South San Francisco")
# Checks for site yaml file
if not os.path.isfile('yamls\\SSFUSD.yml'):
sys.exit('Site not setup, run setup_site.py')
# Loads access info
with open('yamls\\SSFUSD.yml', 'r+') as f:
saved_data = yaml.load(f)
with open('saved data\\oui_discovery.yml', 'r') as f:
oui_discovery = yaml.load(f)
for ip in saved_data.iplist:
print(ip.format())
# ID Device
print("Discovering Device")
sysName = library.get(saved_data.community_string, ip.format(), 'SNMPv2-MIB', 'sysDescr')
if not sysName:
continue
# Checks if Cisco Device
if 'cisco' in sysName[0][0].lower():
print('Skipping cisco device')
continue
chan, ssh = library.login(ip.format(), saved_data.username, saved_data.psk)
if ssh == 0:
continue
running_config = library.get_running_config(chan, saved_data.enable)
# Loads MAC-Table
print("Loading MAC Table"),
cam_table = library.get(saved_data.community_string, ip.format(), 'BRIDGE-MIB', 'dot1dTpFdbPort')
print("MAC Table Loaded")
# Loads Interface Index table
print("Loading interface index"),
ifIndex = library.get(saved_data.community_string, ip.format(), 'IF-MIB', 'ifIndex')
ifName = library.get(saved_data.community_string, ip.format(), 'IF-MIB', 'ifName')
print("Interface index Loaded")
# Initialize interface class
print("Organizing data")
interface_record = {}
for i in range(len(ifIndex[0])):
interface_record[ifIndex[0][i]] = library.Interface(ifIndex[0][i], ifName[0][i])
# Appends MAC addresses table to the interface class
for i in range(len(cam_table[0])):
mac = re.search(r'[0-9:a-fA-F]{17}', cam_table[1][i]).group()
interface_record[cam_table[0][i]].mac_table.append(netaddr.EUI(mac))
library.send_command('flow-control', chan=chan, configure=True)
interface_configs = running_config.find_objects(r'interface.*')
# Searches for live mac address and configures based on spreadsheet
print("Searching interfaces for devices")
for interface in sorted(interface_record):
for mac in interface_record[interface].mac_table:
for search in oui_discovery.items():
try:
if mac.oui in search[1]:
if interface_record[interface].flag is 'switch':
continue
interface_record[interface].flag = search[0].lower()
print("Interface {0}: MAC {1}: Flag: {2}".format(
interface_record[interface].ifName, str(mac), interface_record[interface].flag)
)
except netaddr.NotRegisteredError:
pass
for interface in sorted(interface_record):
if interface_record[interface].flag == 'ip_speaker':
library.send_command(interface_record[interface].command_name, 'port-name **** SPEAKER ****', chan=chan, configure=True)
library.send_command(interface_record[interface].command_name, 'inline power power-by-class 3', chan=chan, configure=True)
print("Wait")
|
apache-2.0
|
[
646,
8864,
199,
646,
747,
199,
646,
984,
199,
646,
295,
199,
646,
3555,
199,
646,
7392,
199,
504,
5055,
492,
10018,
199,
646,
25798,
199,
504,
12866,
14,
2293,
492,
11086,
5453,
421,
199,
1361,
480,
6564,
21588,
7775,
446,
23150,
29359,
481,
1312,
19597,
531,
199,
199,
3,
13813,
367,
4770,
8864,
570,
199,
692,
440,
747,
14,
515,
14,
6292,
360,
89,
455,
478,
1103,
2300,
38,
1668,
36,
14,
11714,
735,
272,
984,
14,
2224,
360,
8972,
440,
3272,
12,
1255,
3272,
63,
2124,
14,
647,
358,
199,
199,
3,
30367,
2879,
2256,
199,
1045,
1551,
360,
89,
455,
478,
1103,
2300,
38,
1668,
36,
14,
11714,
297,
283,
82,
13854,
465,
289,
26,
272,
6290,
63,
576,
275,
8864,
14,
912,
8,
70,
9,
199,
199,
1045,
1551,
360,
8420,
666,
1103,
810,
73,
63,
14859,
14,
11714,
297,
283,
82,
358,
465,
289,
26,
272,
312,
1907,
63,
14859,
275,
8864,
14,
912,
8,
70,
9,
199,
199,
509,
3384,
315,
6290,
63,
576,
14,
711,
513,
26,
339,
870,
8,
711,
14,
908,
1012,
339,
327,
2870,
12272,
272,
870,
480,
2825,
5899,
316,
12272,
531,
272,
984,
985,
275,
3555,
14,
362,
8,
8420,
63,
576,
14,
9387,
63,
875,
12,
3384,
14,
908,
1062,
283,
30919,
86,
18,
13,
10535,
297,
283,
1274,
28782,
358,
272,
340,
440,
984,
985,
26,
267,
1980,
339,
327,
13813,
340,
28356,
12272,
272,
340,
283,
19597,
7,
315,
984,
985,
59,
16,
1527,
16,
1055,
2325,
837,
267,
870,
360,
18297,
286,
10081,
2243,
358,
267,
1980,
339,
15985,
12,
8635,
275,
3555,
14,
2886,
8,
711,
14,
908,
1062,
6290,
63,
576,
14,
2473,
12,
6290,
63,
576,
14,
30333,
9,
272,
340,
8635,
508,
378,
26,
267,
1980,
339,
3879,
63,
888,
275,
3555,
14,
362,
63,
5720,
63,
888,
8,
11984,
12,
6290,
63,
576,
14,
4296,
9,
339,
327,
30367,
13347,
13,
3186,
272,
870,
480,
19236,
13347,
6957,
1288,
272,
27570,
63,
1224,
275,
3555,
14,
362,
8,
8420,
63,
576,
14,
9387,
63,
875,
12,
3384,
14,
908,
1062,
283,
7184,
998,
4962,
13,
10535,
297,
283,
3287,
17,
19772,
80,
38,
697,
4313,
358,
272,
870,
480,
9410,
6957,
3835,
3074,
531,
339,
327,
30367,
14816,
5499,
1817,
272,
870,
480,
19236,
3217,
1478,
1288,
272,
340,
2681,
275,
3555,
14,
362,
8,
8420,
63,
576,
14,
9387,
63,
875,
12,
3384,
14,
908,
1062,
283,
4656,
13,
10535,
297,
283,
692,
2681,
358,
272,
340,
985,
275,
3555,
14,
362,
8,
8420,
63,
576,
14,
9387,
63,
875,
12,
3384,
14,
908,
1062,
283,
4656,
13,
10535,
297,
283,
692,
985,
358,
272,
870,
480,
4267,
1478,
3835,
3074,
531,
339,
327,
11578,
3217,
1021,
272,
870,
480,
11014,
290,
9147,
666,
531,
272,
3217,
63,
3059,
275,
1052,
272,
367,
284,
315,
1425,
8,
552,
8,
692,
2681,
59,
16,
18710,
267,
3217,
63,
3059,
59,
692,
2681,
59,
16,
1527,
73,
2677,
275,
3555,
14,
4267,
8,
692,
2681,
59,
16,
1527,
73,
467,
340,
985,
59,
16,
1527,
73,
566,
339,
327,
4693,
3198,
13347,
7149,
1817,
370,
314,
3217,
1021,
272,
367,
284,
315,
1425,
8,
552,
8,
15176,
63,
1224,
59,
16,
18710,
267,
4497,
275,
295,
14,
1733,
8,
82,
3894,
16,
13,
25,
26,
65,
13,
13753,
13,
38,
8194,
1196,
7293,
27570,
63,
1224,
59,
17,
1527,
73,
6575,
923,
342,
267,
3217,
63,
3059,
59,
15176,
63,
1224,
59,
16,
1527,
73,
20230,
3088,
63,
1224,
14,
740,
8,
846,
2697,
14,
37,
6379,
8,
3088,
430,
339,
3555,
14,
2254,
63,
1531,
360,
1659,
13,
2785,
297,
15985,
29,
11984,
12,
7908,
29,
549,
9,
339,
3217,
63,
7532,
275,
3879,
63,
888,
14,
1623,
63,
1462,
8,
82,
7,
3266,
24915,
339,
327,
8730,
397,
367,
12166,
4497,
2287,
436,
1101,
1482,
4079,
641,
27076,
272,
870,
480,
5278,
316,
8386,
367,
7256,
531,
272,
367,
3217,
315,
3355,
8,
3266,
63,
3059,
304,
267,
367,
4497,
315,
3217,
63,
3059,
59,
3266,
1055,
3088,
63,
1224,
26,
288,
367,
2754,
315,
312,
1907,
63,
14859,
14,
1744,
837,
355,
862,
26,
490,
340,
4497,
14,
810,
73,
315,
2754,
59,
17,
2189,
717,
340,
3217,
63,
3059,
59,
3266,
1055,
4173,
365,
283,
5656,
356,
1169,
1980,
717,
3217,
63,
3059,
59,
3266,
1055,
4173,
275,
2754,
59,
16,
1055,
2325,
342,
717,
870,
480,
4267,
469,
16,
9160,
13347,
469,
17,
9160,
18241,
26,
469,
18,
5469,
908,
8,
1169,
3217,
63,
3059,
59,
3266,
1055,
692,
985,
12,
620,
8,
3088,
395,
3217,
63,
3059,
59,
3266,
1055,
4173,
9,
717,
776,
355,
871,
25798,
14,
1763,
20341,
547,
26,
490,
986,
339,
367,
3217,
315,
3355,
8,
3266,
63,
3059,
304,
267,
340,
3217,
63,
3059,
59,
3266,
1055,
4173,
508,
283,
711,
63,
32263,
356,
288,
3555,
14,
2254,
63,
1531,
8,
3266,
63,
3059,
59,
3266,
1055,
1531,
63,
354,
12,
283,
719,
13,
354,
1011,
538,
428,
1510,
7872,
540,
1011,
538,
297,
15985,
29,
11984,
12,
7908,
29,
549,
9,
288,
3555,
14,
2254,
63,
1531,
8,
3266,
63,
3059,
59,
3266,
1055,
1531,
63,
354,
12,
283,
6460,
7074,
7074,
13,
991,
13,
533,
650,
297,
15985,
29,
11984,
12,
7908,
29,
549,
9,
339,
870,
480,
7536,
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
] |
[
8864,
199,
646,
747,
199,
646,
984,
199,
646,
295,
199,
646,
3555,
199,
646,
7392,
199,
504,
5055,
492,
10018,
199,
646,
25798,
199,
504,
12866,
14,
2293,
492,
11086,
5453,
421,
199,
1361,
480,
6564,
21588,
7775,
446,
23150,
29359,
481,
1312,
19597,
531,
199,
199,
3,
13813,
367,
4770,
8864,
570,
199,
692,
440,
747,
14,
515,
14,
6292,
360,
89,
455,
478,
1103,
2300,
38,
1668,
36,
14,
11714,
735,
272,
984,
14,
2224,
360,
8972,
440,
3272,
12,
1255,
3272,
63,
2124,
14,
647,
358,
199,
199,
3,
30367,
2879,
2256,
199,
1045,
1551,
360,
89,
455,
478,
1103,
2300,
38,
1668,
36,
14,
11714,
297,
283,
82,
13854,
465,
289,
26,
272,
6290,
63,
576,
275,
8864,
14,
912,
8,
70,
9,
199,
199,
1045,
1551,
360,
8420,
666,
1103,
810,
73,
63,
14859,
14,
11714,
297,
283,
82,
358,
465,
289,
26,
272,
312,
1907,
63,
14859,
275,
8864,
14,
912,
8,
70,
9,
199,
199,
509,
3384,
315,
6290,
63,
576,
14,
711,
513,
26,
339,
870,
8,
711,
14,
908,
1012,
339,
327,
2870,
12272,
272,
870,
480,
2825,
5899,
316,
12272,
531,
272,
984,
985,
275,
3555,
14,
362,
8,
8420,
63,
576,
14,
9387,
63,
875,
12,
3384,
14,
908,
1062,
283,
30919,
86,
18,
13,
10535,
297,
283,
1274,
28782,
358,
272,
340,
440,
984,
985,
26,
267,
1980,
339,
327,
13813,
340,
28356,
12272,
272,
340,
283,
19597,
7,
315,
984,
985,
59,
16,
1527,
16,
1055,
2325,
837,
267,
870,
360,
18297,
286,
10081,
2243,
358,
267,
1980,
339,
15985,
12,
8635,
275,
3555,
14,
2886,
8,
711,
14,
908,
1062,
6290,
63,
576,
14,
2473,
12,
6290,
63,
576,
14,
30333,
9,
272,
340,
8635,
508,
378,
26,
267,
1980,
339,
3879,
63,
888,
275,
3555,
14,
362,
63,
5720,
63,
888,
8,
11984,
12,
6290,
63,
576,
14,
4296,
9,
339,
327,
30367,
13347,
13,
3186,
272,
870,
480,
19236,
13347,
6957,
1288,
272,
27570,
63,
1224,
275,
3555,
14,
362,
8,
8420,
63,
576,
14,
9387,
63,
875,
12,
3384,
14,
908,
1062,
283,
7184,
998,
4962,
13,
10535,
297,
283,
3287,
17,
19772,
80,
38,
697,
4313,
358,
272,
870,
480,
9410,
6957,
3835,
3074,
531,
339,
327,
30367,
14816,
5499,
1817,
272,
870,
480,
19236,
3217,
1478,
1288,
272,
340,
2681,
275,
3555,
14,
362,
8,
8420,
63,
576,
14,
9387,
63,
875,
12,
3384,
14,
908,
1062,
283,
4656,
13,
10535,
297,
283,
692,
2681,
358,
272,
340,
985,
275,
3555,
14,
362,
8,
8420,
63,
576,
14,
9387,
63,
875,
12,
3384,
14,
908,
1062,
283,
4656,
13,
10535,
297,
283,
692,
985,
358,
272,
870,
480,
4267,
1478,
3835,
3074,
531,
339,
327,
11578,
3217,
1021,
272,
870,
480,
11014,
290,
9147,
666,
531,
272,
3217,
63,
3059,
275,
1052,
272,
367,
284,
315,
1425,
8,
552,
8,
692,
2681,
59,
16,
18710,
267,
3217,
63,
3059,
59,
692,
2681,
59,
16,
1527,
73,
2677,
275,
3555,
14,
4267,
8,
692,
2681,
59,
16,
1527,
73,
467,
340,
985,
59,
16,
1527,
73,
566,
339,
327,
4693,
3198,
13347,
7149,
1817,
370,
314,
3217,
1021,
272,
367,
284,
315,
1425,
8,
552,
8,
15176,
63,
1224,
59,
16,
18710,
267,
4497,
275,
295,
14,
1733,
8,
82,
3894,
16,
13,
25,
26,
65,
13,
13753,
13,
38,
8194,
1196,
7293,
27570,
63,
1224,
59,
17,
1527,
73,
6575,
923,
342,
267,
3217,
63,
3059,
59,
15176,
63,
1224,
59,
16,
1527,
73,
20230,
3088,
63,
1224,
14,
740,
8,
846,
2697,
14,
37,
6379,
8,
3088,
430,
339,
3555,
14,
2254,
63,
1531,
360,
1659,
13,
2785,
297,
15985,
29,
11984,
12,
7908,
29,
549,
9,
339,
3217,
63,
7532,
275,
3879,
63,
888,
14,
1623,
63,
1462,
8,
82,
7,
3266,
24915,
339,
327,
8730,
397,
367,
12166,
4497,
2287,
436,
1101,
1482,
4079,
641,
27076,
272,
870,
480,
5278,
316,
8386,
367,
7256,
531,
272,
367,
3217,
315,
3355,
8,
3266,
63,
3059,
304,
267,
367,
4497,
315,
3217,
63,
3059,
59,
3266,
1055,
3088,
63,
1224,
26,
288,
367,
2754,
315,
312,
1907,
63,
14859,
14,
1744,
837,
355,
862,
26,
490,
340,
4497,
14,
810,
73,
315,
2754,
59,
17,
2189,
717,
340,
3217,
63,
3059,
59,
3266,
1055,
4173,
365,
283,
5656,
356,
1169,
1980,
717,
3217,
63,
3059,
59,
3266,
1055,
4173,
275,
2754,
59,
16,
1055,
2325,
342,
717,
870,
480,
4267,
469,
16,
9160,
13347,
469,
17,
9160,
18241,
26,
469,
18,
5469,
908,
8,
1169,
3217,
63,
3059,
59,
3266,
1055,
692,
985,
12,
620,
8,
3088,
395,
3217,
63,
3059,
59,
3266,
1055,
4173,
9,
717,
776,
355,
871,
25798,
14,
1763,
20341,
547,
26,
490,
986,
339,
367,
3217,
315,
3355,
8,
3266,
63,
3059,
304,
267,
340,
3217,
63,
3059,
59,
3266,
1055,
4173,
508,
283,
711,
63,
32263,
356,
288,
3555,
14,
2254,
63,
1531,
8,
3266,
63,
3059,
59,
3266,
1055,
1531,
63,
354,
12,
283,
719,
13,
354,
1011,
538,
428,
1510,
7872,
540,
1011,
538,
297,
15985,
29,
11984,
12,
7908,
29,
549,
9,
288,
3555,
14,
2254,
63,
1531,
8,
3266,
63,
3059,
59,
3266,
1055,
1531,
63,
354,
12,
283,
6460,
7074,
7074,
13,
991,
13,
533,
650,
297,
15985,
29,
11984,
12,
7908,
29,
549,
9,
339,
870,
480,
7536,
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,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
petterreinholdtsen/frikanalen
|
fkbeta/fk/admin.py
|
1
|
2538
|
# Copyright (c) 2012-2013 Benjamin Bruheim <grolgh@gmail.com>
# This file is covered by the LGPLv3 or later, read COPYING for details.
from django.contrib import admin
from django.contrib.auth.models import User
from django.contrib.auth.admin import UserAdmin
from fk.models import FileFormat
from fk.models import Organization
from fk.models import UserProfile
from fk.models import Video, Category, Scheduleitem
from fk.models import VideoFile
from fk.models import SchedulePurpose, WeeklySlot
# In order to display the userprofile on
admin.site.unregister(User)
class UserProfileInline(admin.StackedInline):
model = UserProfile
class UserProfileAdmin(UserAdmin):
inlines = [ UserProfileInline, ]
class VideoFileInline(admin.StackedInline):
fields = ('format', 'filename', 'old_filename')
#readonly_fields = ['format', 'filename']
model = VideoFile
extra = 0
class VideoAdmin(admin.ModelAdmin):
list_display = ('name', 'editor', 'organization')
inlines = [VideoFileInline]
search_fields = ["name", "description", "organization__name", "header", "editor__username"]
list_filter = ("proper_import", "is_filler", "publish_on_web", "has_tono_records")
class OrganizationAdmin(admin.ModelAdmin):
list_display = ('name', 'fkmember', 'orgnr')
filter_horizontal = ("members",)
list_filter = ('fkmember',)
ordering = ('name',)
class ScheduleitemAdmin(admin.ModelAdmin):
list_filter = ("starttime", )
list_display = ('__str__',
'video',
'schedulereason',
'starttime',
'duration')
#list_display_links = ('starttime', 'video',)
#inlines = [VideoInline]
#exclude = ('video',)
search_fields = ["video__name", "video__organization__name"]
ordering = ('starttime',)
class SchedulePurposeAdmin(admin.ModelAdmin):
list_display = (
'__str__',
'videos_str',
)
filter_horizontal = ('direct_videos',)
class WeeklySlotAdmin(admin.ModelAdmin):
list_display = (
'__str__',
'day',
'start_time',
'duration',
'purpose',
)
admin.site.register(Category)
admin.site.register(FileFormat)
admin.site.register(Organization, OrganizationAdmin)
admin.site.register(SchedulePurpose, SchedulePurposeAdmin)
admin.site.register(Scheduleitem, ScheduleitemAdmin)
admin.site.register(User, UserProfileAdmin)
admin.site.register(Video, VideoAdmin)
admin.site.register(VideoFile)
admin.site.register(WeeklySlot, WeeklySlotAdmin)
|
lgpl-3.0
|
[
3,
1898,
334,
67,
9,
6029,
13,
6965,
26844,
16997,
262,
699,
6558,
426,
1017,
665,
71,
8459,
3561,
32,
6799,
14,
957,
30,
199,
3,
961,
570,
365,
24295,
701,
314,
491,
28863,
19,
503,
2945,
12,
1586,
9685,
367,
2436,
14,
199,
504,
1639,
14,
2828,
492,
4628,
199,
504,
1639,
14,
2828,
14,
1178,
14,
992,
492,
2876,
199,
504,
1639,
14,
2828,
14,
1178,
14,
2113,
492,
2876,
4880,
199,
199,
504,
14830,
14,
992,
492,
3814,
3484,
199,
504,
14830,
14,
992,
492,
18863,
199,
504,
14830,
14,
992,
492,
19037,
199,
504,
14830,
14,
992,
492,
15709,
12,
13573,
12,
24317,
1053,
199,
504,
14830,
14,
992,
492,
15709,
1173,
199,
504,
14830,
14,
992,
492,
24317,
14959,
4070,
12,
31072,
590,
15183,
199,
199,
3,
1010,
1865,
370,
2929,
314,
922,
2913,
641,
199,
2113,
14,
2124,
14,
18408,
8,
1899,
9,
199,
199,
533,
19037,
10307,
8,
2113,
14,
4851,
379,
10307,
304,
272,
1402,
275,
19037,
199,
199,
533,
19037,
4880,
8,
1899,
4880,
304,
272,
29177,
275,
359,
19037,
10307,
12,
1622,
199,
199,
533,
15709,
1173,
10307,
8,
2113,
14,
4851,
379,
10307,
304,
272,
1504,
275,
661,
908,
297,
283,
1501,
297,
283,
1753,
63,
1501,
358,
272,
327,
6753,
63,
955,
275,
788,
908,
297,
283,
1501,
418,
272,
1402,
275,
15709,
1173,
272,
2402,
275,
378,
199,
199,
533,
15709,
4880,
8,
2113,
14,
12976,
304,
272,
769,
63,
2918,
275,
661,
354,
297,
283,
7515,
297,
283,
9071,
358,
272,
29177,
275,
359,
9166,
1173,
10307,
61,
272,
2754,
63,
955,
275,
2097,
354,
401,
298,
1802,
401,
298,
9071,
363,
354,
401,
298,
1291,
401,
298,
7515,
363,
2473,
937,
272,
769,
63,
1541,
275,
1689,
28314,
63,
646,
401,
298,
374,
63,
1289,
1435,
401,
298,
4763,
63,
265,
63,
2520,
401,
298,
1989,
63,
1860,
79,
63,
6502,
531,
199,
199,
533,
18863,
4880,
8,
2113,
14,
12976,
304,
272,
769,
63,
2918,
275,
661,
354,
297,
283,
9010,
1114,
297,
283,
269,
784,
82,
358,
272,
2457,
63,
11392,
275,
1689,
6334,
26360,
272,
769,
63,
1541,
275,
661,
9010,
1114,
9538,
272,
7794,
275,
661,
354,
9538,
421,
199,
533,
24317,
1053,
4880,
8,
2113,
14,
12976,
304,
272,
769,
63,
1541,
275,
1689,
32183,
401,
776,
272,
769,
63,
2918,
275,
25038,
495,
7500,
490,
283,
3722,
297,
490,
283,
7211,
5764,
297,
490,
283,
32183,
297,
490,
283,
5553,
358,
272,
327,
513,
63,
2918,
63,
4614,
275,
661,
32183,
297,
283,
3722,
9538,
272,
327,
26739,
275,
359,
9166,
10307,
61,
272,
327,
5473,
275,
661,
3722,
9538,
272,
2754,
63,
955,
275,
2097,
3722,
363,
354,
401,
298,
3722,
363,
9071,
363,
354,
937,
272,
7794,
275,
661,
32183,
9538,
199,
199,
533,
24317,
14959,
4070,
4880,
8,
2113,
14,
12976,
304,
272,
769,
63,
2918,
275,
334,
267,
2560,
495,
7500,
267,
283,
11418,
63,
495,
297,
272,
776,
272,
2457,
63,
11392,
275,
661,
2275,
63,
11418,
9538,
199,
199,
533,
31072,
590,
15183,
4880,
8,
2113,
14,
12976,
304,
272,
769,
63,
2918,
275,
334,
267,
2560,
495,
7500,
267,
283,
2977,
297,
267,
283,
928,
63,
521,
297,
267,
283,
5553,
297,
267,
283,
22615,
297,
272,
776,
199,
199,
2113,
14,
2124,
14,
2683,
8,
7841,
9,
199,
2113,
14,
2124,
14,
2683,
8,
1173,
3484,
9,
199,
2113,
14,
2124,
14,
2683,
8,
15928,
12,
18863,
4880,
9,
199,
2113,
14,
2124,
14,
2683,
8,
15535,
14959,
4070,
12,
24317,
14959,
4070,
4880,
9,
199,
2113,
14,
2124,
14,
2683,
8,
15535,
1053,
12,
24317,
1053,
4880,
9,
199,
2113,
14,
2124,
14,
2683,
8,
1899,
12,
19037,
4880,
9,
199,
2113,
14,
2124,
14,
2683,
8,
9166,
12,
15709,
4880,
9,
199,
2113,
14,
2124,
14,
2683,
8,
9166,
1173,
9,
199,
2113,
14,
2124,
14,
2683,
8,
20995,
590,
15183,
12,
31072,
590,
15183,
4880,
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
] |
[
1898,
334,
67,
9,
6029,
13,
6965,
26844,
16997,
262,
699,
6558,
426,
1017,
665,
71,
8459,
3561,
32,
6799,
14,
957,
30,
199,
3,
961,
570,
365,
24295,
701,
314,
491,
28863,
19,
503,
2945,
12,
1586,
9685,
367,
2436,
14,
199,
504,
1639,
14,
2828,
492,
4628,
199,
504,
1639,
14,
2828,
14,
1178,
14,
992,
492,
2876,
199,
504,
1639,
14,
2828,
14,
1178,
14,
2113,
492,
2876,
4880,
199,
199,
504,
14830,
14,
992,
492,
3814,
3484,
199,
504,
14830,
14,
992,
492,
18863,
199,
504,
14830,
14,
992,
492,
19037,
199,
504,
14830,
14,
992,
492,
15709,
12,
13573,
12,
24317,
1053,
199,
504,
14830,
14,
992,
492,
15709,
1173,
199,
504,
14830,
14,
992,
492,
24317,
14959,
4070,
12,
31072,
590,
15183,
199,
199,
3,
1010,
1865,
370,
2929,
314,
922,
2913,
641,
199,
2113,
14,
2124,
14,
18408,
8,
1899,
9,
199,
199,
533,
19037,
10307,
8,
2113,
14,
4851,
379,
10307,
304,
272,
1402,
275,
19037,
199,
199,
533,
19037,
4880,
8,
1899,
4880,
304,
272,
29177,
275,
359,
19037,
10307,
12,
1622,
199,
199,
533,
15709,
1173,
10307,
8,
2113,
14,
4851,
379,
10307,
304,
272,
1504,
275,
661,
908,
297,
283,
1501,
297,
283,
1753,
63,
1501,
358,
272,
327,
6753,
63,
955,
275,
788,
908,
297,
283,
1501,
418,
272,
1402,
275,
15709,
1173,
272,
2402,
275,
378,
199,
199,
533,
15709,
4880,
8,
2113,
14,
12976,
304,
272,
769,
63,
2918,
275,
661,
354,
297,
283,
7515,
297,
283,
9071,
358,
272,
29177,
275,
359,
9166,
1173,
10307,
61,
272,
2754,
63,
955,
275,
2097,
354,
401,
298,
1802,
401,
298,
9071,
363,
354,
401,
298,
1291,
401,
298,
7515,
363,
2473,
937,
272,
769,
63,
1541,
275,
1689,
28314,
63,
646,
401,
298,
374,
63,
1289,
1435,
401,
298,
4763,
63,
265,
63,
2520,
401,
298,
1989,
63,
1860,
79,
63,
6502,
531,
199,
199,
533,
18863,
4880,
8,
2113,
14,
12976,
304,
272,
769,
63,
2918,
275,
661,
354,
297,
283,
9010,
1114,
297,
283,
269,
784,
82,
358,
272,
2457,
63,
11392,
275,
1689,
6334,
26360,
272,
769,
63,
1541,
275,
661,
9010,
1114,
9538,
272,
7794,
275,
661,
354,
9538,
421,
199,
533,
24317,
1053,
4880,
8,
2113,
14,
12976,
304,
272,
769,
63,
1541,
275,
1689,
32183,
401,
776,
272,
769,
63,
2918,
275,
25038,
495,
7500,
490,
283,
3722,
297,
490,
283,
7211,
5764,
297,
490,
283,
32183,
297,
490,
283,
5553,
358,
272,
327,
513,
63,
2918,
63,
4614,
275,
661,
32183,
297,
283,
3722,
9538,
272,
327,
26739,
275,
359,
9166,
10307,
61,
272,
327,
5473,
275,
661,
3722,
9538,
272,
2754,
63,
955,
275,
2097,
3722,
363,
354,
401,
298,
3722,
363,
9071,
363,
354,
937,
272,
7794,
275,
661,
32183,
9538,
199,
199,
533,
24317,
14959,
4070,
4880,
8,
2113,
14,
12976,
304,
272,
769,
63,
2918,
275,
334,
267,
2560,
495,
7500,
267,
283,
11418,
63,
495,
297,
272,
776,
272,
2457,
63,
11392,
275,
661,
2275,
63,
11418,
9538,
199,
199,
533,
31072,
590,
15183,
4880,
8,
2113,
14,
12976,
304,
272,
769,
63,
2918,
275,
334,
267,
2560,
495,
7500,
267,
283,
2977,
297,
267,
283,
928,
63,
521,
297,
267,
283,
5553,
297,
267,
283,
22615,
297,
272,
776,
199,
199,
2113,
14,
2124,
14,
2683,
8,
7841,
9,
199,
2113,
14,
2124,
14,
2683,
8,
1173,
3484,
9,
199,
2113,
14,
2124,
14,
2683,
8,
15928,
12,
18863,
4880,
9,
199,
2113,
14,
2124,
14,
2683,
8,
15535,
14959,
4070,
12,
24317,
14959,
4070,
4880,
9,
199,
2113,
14,
2124,
14,
2683,
8,
15535,
1053,
12,
24317,
1053,
4880,
9,
199,
2113,
14,
2124,
14,
2683,
8,
1899,
12,
19037,
4880,
9,
199,
2113,
14,
2124,
14,
2683,
8,
9166,
12,
15709,
4880,
9,
199,
2113,
14,
2124,
14,
2683,
8,
9166,
1173,
9,
199,
2113,
14,
2124,
14,
2683,
8,
20995,
590,
15183,
12,
31072,
590,
15183,
4880,
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,
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0,
0,
0,
0,
0,
0,
0,
0,
0
] |
dimagol/trex-core
|
scripts/external_libs/urllib3/urllib3/packages/six.py
|
2715
|
30098
|
"""Utilities for writing code that runs on Python 2 and 3"""
# Copyright (c) 2010-2015 Benjamin Peterson
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
from __future__ import absolute_import
import functools
import itertools
import operator
import sys
import types
__author__ = "Benjamin Peterson <benjamin@python.org>"
__version__ = "1.10.0"
# Useful for very coarse version differentiation.
PY2 = sys.version_info[0] == 2
PY3 = sys.version_info[0] == 3
PY34 = sys.version_info[0:2] >= (3, 4)
if PY3:
string_types = str,
integer_types = int,
class_types = type,
text_type = str
binary_type = bytes
MAXSIZE = sys.maxsize
else:
string_types = basestring,
integer_types = (int, long)
class_types = (type, types.ClassType)
text_type = unicode
binary_type = str
if sys.platform.startswith("java"):
# Jython always uses 32 bits.
MAXSIZE = int((1 << 31) - 1)
else:
# It's possible to have sizeof(long) != sizeof(Py_ssize_t).
class X(object):
def __len__(self):
return 1 << 31
try:
len(X())
except OverflowError:
# 32-bit
MAXSIZE = int((1 << 31) - 1)
else:
# 64-bit
MAXSIZE = int((1 << 63) - 1)
del X
def _add_doc(func, doc):
"""Add documentation to a function."""
func.__doc__ = doc
def _import_module(name):
"""Import module, returning the module after the last dot."""
__import__(name)
return sys.modules[name]
class _LazyDescr(object):
def __init__(self, name):
self.name = name
def __get__(self, obj, tp):
result = self._resolve()
setattr(obj, self.name, result) # Invokes __set__.
try:
# This is a bit ugly, but it avoids running this again by
# removing this descriptor.
delattr(obj.__class__, self.name)
except AttributeError:
pass
return result
class MovedModule(_LazyDescr):
def __init__(self, name, old, new=None):
super(MovedModule, self).__init__(name)
if PY3:
if new is None:
new = name
self.mod = new
else:
self.mod = old
def _resolve(self):
return _import_module(self.mod)
def __getattr__(self, attr):
_module = self._resolve()
value = getattr(_module, attr)
setattr(self, attr, value)
return value
class _LazyModule(types.ModuleType):
def __init__(self, name):
super(_LazyModule, self).__init__(name)
self.__doc__ = self.__class__.__doc__
def __dir__(self):
attrs = ["__doc__", "__name__"]
attrs += [attr.name for attr in self._moved_attributes]
return attrs
# Subclasses should override this
_moved_attributes = []
class MovedAttribute(_LazyDescr):
def __init__(self, name, old_mod, new_mod, old_attr=None, new_attr=None):
super(MovedAttribute, self).__init__(name)
if PY3:
if new_mod is None:
new_mod = name
self.mod = new_mod
if new_attr is None:
if old_attr is None:
new_attr = name
else:
new_attr = old_attr
self.attr = new_attr
else:
self.mod = old_mod
if old_attr is None:
old_attr = name
self.attr = old_attr
def _resolve(self):
module = _import_module(self.mod)
return getattr(module, self.attr)
class _SixMetaPathImporter(object):
"""
A meta path importer to import six.moves and its submodules.
This class implements a PEP302 finder and loader. It should be compatible
with Python 2.5 and all existing versions of Python3
"""
def __init__(self, six_module_name):
self.name = six_module_name
self.known_modules = {}
def _add_module(self, mod, *fullnames):
for fullname in fullnames:
self.known_modules[self.name + "." + fullname] = mod
def _get_module(self, fullname):
return self.known_modules[self.name + "." + fullname]
def find_module(self, fullname, path=None):
if fullname in self.known_modules:
return self
return None
def __get_module(self, fullname):
try:
return self.known_modules[fullname]
except KeyError:
raise ImportError("This loader does not know module " + fullname)
def load_module(self, fullname):
try:
# in case of a reload
return sys.modules[fullname]
except KeyError:
pass
mod = self.__get_module(fullname)
if isinstance(mod, MovedModule):
mod = mod._resolve()
else:
mod.__loader__ = self
sys.modules[fullname] = mod
return mod
def is_package(self, fullname):
"""
Return true, if the named module is a package.
We need this method to get correct spec objects with
Python 3.4 (see PEP451)
"""
return hasattr(self.__get_module(fullname), "__path__")
def get_code(self, fullname):
"""Return None
Required, if is_package is implemented"""
self.__get_module(fullname) # eventually raises ImportError
return None
get_source = get_code # same as get_code
_importer = _SixMetaPathImporter(__name__)
class _MovedItems(_LazyModule):
"""Lazy loading of moved objects"""
__path__ = [] # mark as package
_moved_attributes = [
MovedAttribute("cStringIO", "cStringIO", "io", "StringIO"),
MovedAttribute("filter", "itertools", "builtins", "ifilter", "filter"),
MovedAttribute("filterfalse", "itertools", "itertools", "ifilterfalse", "filterfalse"),
MovedAttribute("input", "__builtin__", "builtins", "raw_input", "input"),
MovedAttribute("intern", "__builtin__", "sys"),
MovedAttribute("map", "itertools", "builtins", "imap", "map"),
MovedAttribute("getcwd", "os", "os", "getcwdu", "getcwd"),
MovedAttribute("getcwdb", "os", "os", "getcwd", "getcwdb"),
MovedAttribute("range", "__builtin__", "builtins", "xrange", "range"),
MovedAttribute("reload_module", "__builtin__", "importlib" if PY34 else "imp", "reload"),
MovedAttribute("reduce", "__builtin__", "functools"),
MovedAttribute("shlex_quote", "pipes", "shlex", "quote"),
MovedAttribute("StringIO", "StringIO", "io"),
MovedAttribute("UserDict", "UserDict", "collections"),
MovedAttribute("UserList", "UserList", "collections"),
MovedAttribute("UserString", "UserString", "collections"),
MovedAttribute("xrange", "__builtin__", "builtins", "xrange", "range"),
MovedAttribute("zip", "itertools", "builtins", "izip", "zip"),
MovedAttribute("zip_longest", "itertools", "itertools", "izip_longest", "zip_longest"),
MovedModule("builtins", "__builtin__"),
MovedModule("configparser", "ConfigParser"),
MovedModule("copyreg", "copy_reg"),
MovedModule("dbm_gnu", "gdbm", "dbm.gnu"),
MovedModule("_dummy_thread", "dummy_thread", "_dummy_thread"),
MovedModule("http_cookiejar", "cookielib", "http.cookiejar"),
MovedModule("http_cookies", "Cookie", "http.cookies"),
MovedModule("html_entities", "htmlentitydefs", "html.entities"),
MovedModule("html_parser", "HTMLParser", "html.parser"),
MovedModule("http_client", "httplib", "http.client"),
MovedModule("email_mime_multipart", "email.MIMEMultipart", "email.mime.multipart"),
MovedModule("email_mime_nonmultipart", "email.MIMENonMultipart", "email.mime.nonmultipart"),
MovedModule("email_mime_text", "email.MIMEText", "email.mime.text"),
MovedModule("email_mime_base", "email.MIMEBase", "email.mime.base"),
MovedModule("BaseHTTPServer", "BaseHTTPServer", "http.server"),
MovedModule("CGIHTTPServer", "CGIHTTPServer", "http.server"),
MovedModule("SimpleHTTPServer", "SimpleHTTPServer", "http.server"),
MovedModule("cPickle", "cPickle", "pickle"),
MovedModule("queue", "Queue"),
MovedModule("reprlib", "repr"),
MovedModule("socketserver", "SocketServer"),
MovedModule("_thread", "thread", "_thread"),
MovedModule("tkinter", "Tkinter"),
MovedModule("tkinter_dialog", "Dialog", "tkinter.dialog"),
MovedModule("tkinter_filedialog", "FileDialog", "tkinter.filedialog"),
MovedModule("tkinter_scrolledtext", "ScrolledText", "tkinter.scrolledtext"),
MovedModule("tkinter_simpledialog", "SimpleDialog", "tkinter.simpledialog"),
MovedModule("tkinter_tix", "Tix", "tkinter.tix"),
MovedModule("tkinter_ttk", "ttk", "tkinter.ttk"),
MovedModule("tkinter_constants", "Tkconstants", "tkinter.constants"),
MovedModule("tkinter_dnd", "Tkdnd", "tkinter.dnd"),
MovedModule("tkinter_colorchooser", "tkColorChooser",
"tkinter.colorchooser"),
MovedModule("tkinter_commondialog", "tkCommonDialog",
"tkinter.commondialog"),
MovedModule("tkinter_tkfiledialog", "tkFileDialog", "tkinter.filedialog"),
MovedModule("tkinter_font", "tkFont", "tkinter.font"),
MovedModule("tkinter_messagebox", "tkMessageBox", "tkinter.messagebox"),
MovedModule("tkinter_tksimpledialog", "tkSimpleDialog",
"tkinter.simpledialog"),
MovedModule("urllib_parse", __name__ + ".moves.urllib_parse", "urllib.parse"),
MovedModule("urllib_error", __name__ + ".moves.urllib_error", "urllib.error"),
MovedModule("urllib", __name__ + ".moves.urllib", __name__ + ".moves.urllib"),
MovedModule("urllib_robotparser", "robotparser", "urllib.robotparser"),
MovedModule("xmlrpc_client", "xmlrpclib", "xmlrpc.client"),
MovedModule("xmlrpc_server", "SimpleXMLRPCServer", "xmlrpc.server"),
]
# Add windows specific modules.
if sys.platform == "win32":
_moved_attributes += [
MovedModule("winreg", "_winreg"),
]
for attr in _moved_attributes:
setattr(_MovedItems, attr.name, attr)
if isinstance(attr, MovedModule):
_importer._add_module(attr, "moves." + attr.name)
del attr
_MovedItems._moved_attributes = _moved_attributes
moves = _MovedItems(__name__ + ".moves")
_importer._add_module(moves, "moves")
class Module_six_moves_urllib_parse(_LazyModule):
"""Lazy loading of moved objects in six.moves.urllib_parse"""
_urllib_parse_moved_attributes = [
MovedAttribute("ParseResult", "urlparse", "urllib.parse"),
MovedAttribute("SplitResult", "urlparse", "urllib.parse"),
MovedAttribute("parse_qs", "urlparse", "urllib.parse"),
MovedAttribute("parse_qsl", "urlparse", "urllib.parse"),
MovedAttribute("urldefrag", "urlparse", "urllib.parse"),
MovedAttribute("urljoin", "urlparse", "urllib.parse"),
MovedAttribute("urlparse", "urlparse", "urllib.parse"),
MovedAttribute("urlsplit", "urlparse", "urllib.parse"),
MovedAttribute("urlunparse", "urlparse", "urllib.parse"),
MovedAttribute("urlunsplit", "urlparse", "urllib.parse"),
MovedAttribute("quote", "urllib", "urllib.parse"),
MovedAttribute("quote_plus", "urllib", "urllib.parse"),
MovedAttribute("unquote", "urllib", "urllib.parse"),
MovedAttribute("unquote_plus", "urllib", "urllib.parse"),
MovedAttribute("urlencode", "urllib", "urllib.parse"),
MovedAttribute("splitquery", "urllib", "urllib.parse"),
MovedAttribute("splittag", "urllib", "urllib.parse"),
MovedAttribute("splituser", "urllib", "urllib.parse"),
MovedAttribute("uses_fragment", "urlparse", "urllib.parse"),
MovedAttribute("uses_netloc", "urlparse", "urllib.parse"),
MovedAttribute("uses_params", "urlparse", "urllib.parse"),
MovedAttribute("uses_query", "urlparse", "urllib.parse"),
MovedAttribute("uses_relative", "urlparse", "urllib.parse"),
]
for attr in _urllib_parse_moved_attributes:
setattr(Module_six_moves_urllib_parse, attr.name, attr)
del attr
Module_six_moves_urllib_parse._moved_attributes = _urllib_parse_moved_attributes
_importer._add_module(Module_six_moves_urllib_parse(__name__ + ".moves.urllib_parse"),
"moves.urllib_parse", "moves.urllib.parse")
class Module_six_moves_urllib_error(_LazyModule):
"""Lazy loading of moved objects in six.moves.urllib_error"""
_urllib_error_moved_attributes = [
MovedAttribute("URLError", "urllib2", "urllib.error"),
MovedAttribute("HTTPError", "urllib2", "urllib.error"),
MovedAttribute("ContentTooShortError", "urllib", "urllib.error"),
]
for attr in _urllib_error_moved_attributes:
setattr(Module_six_moves_urllib_error, attr.name, attr)
del attr
Module_six_moves_urllib_error._moved_attributes = _urllib_error_moved_attributes
_importer._add_module(Module_six_moves_urllib_error(__name__ + ".moves.urllib.error"),
"moves.urllib_error", "moves.urllib.error")
class Module_six_moves_urllib_request(_LazyModule):
"""Lazy loading of moved objects in six.moves.urllib_request"""
_urllib_request_moved_attributes = [
MovedAttribute("urlopen", "urllib2", "urllib.request"),
MovedAttribute("install_opener", "urllib2", "urllib.request"),
MovedAttribute("build_opener", "urllib2", "urllib.request"),
MovedAttribute("pathname2url", "urllib", "urllib.request"),
MovedAttribute("url2pathname", "urllib", "urllib.request"),
MovedAttribute("getproxies", "urllib", "urllib.request"),
MovedAttribute("Request", "urllib2", "urllib.request"),
MovedAttribute("OpenerDirector", "urllib2", "urllib.request"),
MovedAttribute("HTTPDefaultErrorHandler", "urllib2", "urllib.request"),
MovedAttribute("HTTPRedirectHandler", "urllib2", "urllib.request"),
MovedAttribute("HTTPCookieProcessor", "urllib2", "urllib.request"),
MovedAttribute("ProxyHandler", "urllib2", "urllib.request"),
MovedAttribute("BaseHandler", "urllib2", "urllib.request"),
MovedAttribute("HTTPPasswordMgr", "urllib2", "urllib.request"),
MovedAttribute("HTTPPasswordMgrWithDefaultRealm", "urllib2", "urllib.request"),
MovedAttribute("AbstractBasicAuthHandler", "urllib2", "urllib.request"),
MovedAttribute("HTTPBasicAuthHandler", "urllib2", "urllib.request"),
MovedAttribute("ProxyBasicAuthHandler", "urllib2", "urllib.request"),
MovedAttribute("AbstractDigestAuthHandler", "urllib2", "urllib.request"),
MovedAttribute("HTTPDigestAuthHandler", "urllib2", "urllib.request"),
MovedAttribute("ProxyDigestAuthHandler", "urllib2", "urllib.request"),
MovedAttribute("HTTPHandler", "urllib2", "urllib.request"),
MovedAttribute("HTTPSHandler", "urllib2", "urllib.request"),
MovedAttribute("FileHandler", "urllib2", "urllib.request"),
MovedAttribute("FTPHandler", "urllib2", "urllib.request"),
MovedAttribute("CacheFTPHandler", "urllib2", "urllib.request"),
MovedAttribute("UnknownHandler", "urllib2", "urllib.request"),
MovedAttribute("HTTPErrorProcessor", "urllib2", "urllib.request"),
MovedAttribute("urlretrieve", "urllib", "urllib.request"),
MovedAttribute("urlcleanup", "urllib", "urllib.request"),
MovedAttribute("URLopener", "urllib", "urllib.request"),
MovedAttribute("FancyURLopener", "urllib", "urllib.request"),
MovedAttribute("proxy_bypass", "urllib", "urllib.request"),
]
for attr in _urllib_request_moved_attributes:
setattr(Module_six_moves_urllib_request, attr.name, attr)
del attr
Module_six_moves_urllib_request._moved_attributes = _urllib_request_moved_attributes
_importer._add_module(Module_six_moves_urllib_request(__name__ + ".moves.urllib.request"),
"moves.urllib_request", "moves.urllib.request")
class Module_six_moves_urllib_response(_LazyModule):
"""Lazy loading of moved objects in six.moves.urllib_response"""
_urllib_response_moved_attributes = [
MovedAttribute("addbase", "urllib", "urllib.response"),
MovedAttribute("addclosehook", "urllib", "urllib.response"),
MovedAttribute("addinfo", "urllib", "urllib.response"),
MovedAttribute("addinfourl", "urllib", "urllib.response"),
]
for attr in _urllib_response_moved_attributes:
setattr(Module_six_moves_urllib_response, attr.name, attr)
del attr
Module_six_moves_urllib_response._moved_attributes = _urllib_response_moved_attributes
_importer._add_module(Module_six_moves_urllib_response(__name__ + ".moves.urllib.response"),
"moves.urllib_response", "moves.urllib.response")
class Module_six_moves_urllib_robotparser(_LazyModule):
"""Lazy loading of moved objects in six.moves.urllib_robotparser"""
_urllib_robotparser_moved_attributes = [
MovedAttribute("RobotFileParser", "robotparser", "urllib.robotparser"),
]
for attr in _urllib_robotparser_moved_attributes:
setattr(Module_six_moves_urllib_robotparser, attr.name, attr)
del attr
Module_six_moves_urllib_robotparser._moved_attributes = _urllib_robotparser_moved_attributes
_importer._add_module(Module_six_moves_urllib_robotparser(__name__ + ".moves.urllib.robotparser"),
"moves.urllib_robotparser", "moves.urllib.robotparser")
class Module_six_moves_urllib(types.ModuleType):
"""Create a six.moves.urllib namespace that resembles the Python 3 namespace"""
__path__ = [] # mark as package
parse = _importer._get_module("moves.urllib_parse")
error = _importer._get_module("moves.urllib_error")
request = _importer._get_module("moves.urllib_request")
response = _importer._get_module("moves.urllib_response")
robotparser = _importer._get_module("moves.urllib_robotparser")
def __dir__(self):
return ['parse', 'error', 'request', 'response', 'robotparser']
_importer._add_module(Module_six_moves_urllib(__name__ + ".moves.urllib"),
"moves.urllib")
def add_move(move):
"""Add an item to six.moves."""
setattr(_MovedItems, move.name, move)
def remove_move(name):
"""Remove item from six.moves."""
try:
delattr(_MovedItems, name)
except AttributeError:
try:
del moves.__dict__[name]
except KeyError:
raise AttributeError("no such move, %r" % (name,))
if PY3:
_meth_func = "__func__"
_meth_self = "__self__"
_func_closure = "__closure__"
_func_code = "__code__"
_func_defaults = "__defaults__"
_func_globals = "__globals__"
else:
_meth_func = "im_func"
_meth_self = "im_self"
_func_closure = "func_closure"
_func_code = "func_code"
_func_defaults = "func_defaults"
_func_globals = "func_globals"
try:
advance_iterator = next
except NameError:
def advance_iterator(it):
return it.next()
next = advance_iterator
try:
callable = callable
except NameError:
def callable(obj):
return any("__call__" in klass.__dict__ for klass in type(obj).__mro__)
if PY3:
def get_unbound_function(unbound):
return unbound
create_bound_method = types.MethodType
def create_unbound_method(func, cls):
return func
Iterator = object
else:
def get_unbound_function(unbound):
return unbound.im_func
def create_bound_method(func, obj):
return types.MethodType(func, obj, obj.__class__)
def create_unbound_method(func, cls):
return types.MethodType(func, None, cls)
class Iterator(object):
def next(self):
return type(self).__next__(self)
callable = callable
_add_doc(get_unbound_function,
"""Get the function out of a possibly unbound function""")
get_method_function = operator.attrgetter(_meth_func)
get_method_self = operator.attrgetter(_meth_self)
get_function_closure = operator.attrgetter(_func_closure)
get_function_code = operator.attrgetter(_func_code)
get_function_defaults = operator.attrgetter(_func_defaults)
get_function_globals = operator.attrgetter(_func_globals)
if PY3:
def iterkeys(d, **kw):
return iter(d.keys(**kw))
def itervalues(d, **kw):
return iter(d.values(**kw))
def iteritems(d, **kw):
return iter(d.items(**kw))
def iterlists(d, **kw):
return iter(d.lists(**kw))
viewkeys = operator.methodcaller("keys")
viewvalues = operator.methodcaller("values")
viewitems = operator.methodcaller("items")
else:
def iterkeys(d, **kw):
return d.iterkeys(**kw)
def itervalues(d, **kw):
return d.itervalues(**kw)
def iteritems(d, **kw):
return d.iteritems(**kw)
def iterlists(d, **kw):
return d.iterlists(**kw)
viewkeys = operator.methodcaller("viewkeys")
viewvalues = operator.methodcaller("viewvalues")
viewitems = operator.methodcaller("viewitems")
_add_doc(iterkeys, "Return an iterator over the keys of a dictionary.")
_add_doc(itervalues, "Return an iterator over the values of a dictionary.")
_add_doc(iteritems,
"Return an iterator over the (key, value) pairs of a dictionary.")
_add_doc(iterlists,
"Return an iterator over the (key, [values]) pairs of a dictionary.")
if PY3:
def b(s):
return s.encode("latin-1")
def u(s):
return s
unichr = chr
import struct
int2byte = struct.Struct(">B").pack
del struct
byte2int = operator.itemgetter(0)
indexbytes = operator.getitem
iterbytes = iter
import io
StringIO = io.StringIO
BytesIO = io.BytesIO
_assertCountEqual = "assertCountEqual"
if sys.version_info[1] <= 1:
_assertRaisesRegex = "assertRaisesRegexp"
_assertRegex = "assertRegexpMatches"
else:
_assertRaisesRegex = "assertRaisesRegex"
_assertRegex = "assertRegex"
else:
def b(s):
return s
# Workaround for standalone backslash
def u(s):
return unicode(s.replace(r'\\', r'\\\\'), "unicode_escape")
unichr = unichr
int2byte = chr
def byte2int(bs):
return ord(bs[0])
def indexbytes(buf, i):
return ord(buf[i])
iterbytes = functools.partial(itertools.imap, ord)
import StringIO
StringIO = BytesIO = StringIO.StringIO
_assertCountEqual = "assertItemsEqual"
_assertRaisesRegex = "assertRaisesRegexp"
_assertRegex = "assertRegexpMatches"
_add_doc(b, """Byte literal""")
_add_doc(u, """Text literal""")
def assertCountEqual(self, *args, **kwargs):
return getattr(self, _assertCountEqual)(*args, **kwargs)
def assertRaisesRegex(self, *args, **kwargs):
return getattr(self, _assertRaisesRegex)(*args, **kwargs)
def assertRegex(self, *args, **kwargs):
return getattr(self, _assertRegex)(*args, **kwargs)
if PY3:
exec_ = getattr(moves.builtins, "exec")
def reraise(tp, value, tb=None):
if value is None:
value = tp()
if value.__traceback__ is not tb:
raise value.with_traceback(tb)
raise value
else:
def exec_(_code_, _globs_=None, _locs_=None):
"""Execute code in a namespace."""
if _globs_ is None:
frame = sys._getframe(1)
_globs_ = frame.f_globals
if _locs_ is None:
_locs_ = frame.f_locals
del frame
elif _locs_ is None:
_locs_ = _globs_
exec("""exec _code_ in _globs_, _locs_""")
exec_("""def reraise(tp, value, tb=None):
raise tp, value, tb
""")
if sys.version_info[:2] == (3, 2):
exec_("""def raise_from(value, from_value):
if from_value is None:
raise value
raise value from from_value
""")
elif sys.version_info[:2] > (3, 2):
exec_("""def raise_from(value, from_value):
raise value from from_value
""")
else:
def raise_from(value, from_value):
raise value
print_ = getattr(moves.builtins, "print", None)
if print_ is None:
def print_(*args, **kwargs):
"""The new-style print function for Python 2.4 and 2.5."""
fp = kwargs.pop("file", sys.stdout)
if fp is None:
return
def write(data):
if not isinstance(data, basestring):
data = str(data)
# If the file has an encoding, encode unicode with it.
if (isinstance(fp, file) and
isinstance(data, unicode) and
fp.encoding is not None):
errors = getattr(fp, "errors", None)
if errors is None:
errors = "strict"
data = data.encode(fp.encoding, errors)
fp.write(data)
want_unicode = False
sep = kwargs.pop("sep", None)
if sep is not None:
if isinstance(sep, unicode):
want_unicode = True
elif not isinstance(sep, str):
raise TypeError("sep must be None or a string")
end = kwargs.pop("end", None)
if end is not None:
if isinstance(end, unicode):
want_unicode = True
elif not isinstance(end, str):
raise TypeError("end must be None or a string")
if kwargs:
raise TypeError("invalid keyword arguments to print()")
if not want_unicode:
for arg in args:
if isinstance(arg, unicode):
want_unicode = True
break
if want_unicode:
newline = unicode("\n")
space = unicode(" ")
else:
newline = "\n"
space = " "
if sep is None:
sep = space
if end is None:
end = newline
for i, arg in enumerate(args):
if i:
write(sep)
write(arg)
write(end)
if sys.version_info[:2] < (3, 3):
_print = print_
def print_(*args, **kwargs):
fp = kwargs.get("file", sys.stdout)
flush = kwargs.pop("flush", False)
_print(*args, **kwargs)
if flush and fp is not None:
fp.flush()
_add_doc(reraise, """Reraise an exception.""")
if sys.version_info[0:2] < (3, 4):
def wraps(wrapped, assigned=functools.WRAPPER_ASSIGNMENTS,
updated=functools.WRAPPER_UPDATES):
def wrapper(f):
f = functools.wraps(wrapped, assigned, updated)(f)
f.__wrapped__ = wrapped
return f
return wrapper
else:
wraps = functools.wraps
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', (), {})
def add_metaclass(metaclass):
"""Class decorator for creating a class with a metaclass."""
def wrapper(cls):
orig_vars = cls.__dict__.copy()
slots = orig_vars.get('__slots__')
if slots is not None:
if isinstance(slots, str):
slots = [slots]
for slots_var in slots:
orig_vars.pop(slots_var)
orig_vars.pop('__dict__', None)
orig_vars.pop('__weakref__', None)
return metaclass(cls.__name__, cls.__bases__, orig_vars)
return wrapper
def python_2_unicode_compatible(klass):
"""
A decorator that defines __unicode__ and __str__ methods under Python 2.
Under Python 3 it does nothing.
To support Python 2 and 3 with a single code base, define a __str__ method
returning text and apply this decorator to the class.
"""
if PY2:
if '__str__' not in klass.__dict__:
raise ValueError("@python_2_unicode_compatible cannot be applied "
"to %s because it doesn't define __str__()." %
klass.__name__)
klass.__unicode__ = klass.__str__
klass.__str__ = lambda self: self.__unicode__().encode('utf-8')
return klass
# Complete the moves implementation.
# This code is at the end of this module to speed up module loading.
# Turn this module into a package.
__path__ = [] # required for PEP 302 and PEP 451
__package__ = __name__ # see PEP 366 @ReservedAssignment
if globals().get("__spec__") is not None:
__spec__.submodule_search_locations = [] # PEP 451 @UndefinedVariable
# Remove other six meta path importers, since they cause problems. This can
# happen if six is removed from sys.modules and then reloaded. (Setuptools does
# this for some reason.)
if sys.meta_path:
for i, importer in enumerate(sys.meta_path):
# Here's some real nastiness: Another "instance" of the six module might
# be floating around. Therefore, we can't use isinstance() to check for
# the six meta path importer, since the other six instance will have
# inserted an importer with different class.
if (type(importer).__name__ == "_SixMetaPathImporter" and
importer.name == __name__):
del sys.meta_path[i]
break
del i, importer
# Finally, add the importer to the meta path import hook.
sys.meta_path.append(_importer)
|
apache-2.0
|
[
624,
22905,
367,
3575,
1233,
626,
7858,
641,
2018,
499,
436,
650,
624,
199,
199,
3,
1898,
334,
67,
9,
7129,
13,
7806,
26844,
16997,
262,
22912,
834,
199,
3,
199,
3,
8779,
365,
11882,
10009,
12,
2867,
402,
11204,
12,
370,
1263,
4954,
12408,
282,
1331,
199,
3,
402,
642,
2032,
436,
4568,
3794,
1584,
334,
1589,
298,
10337,
1288,
370,
7962,
199,
3,
315,
314,
2290,
1928,
10588,
12,
5893,
1928,
12305,
314,
4481,
199,
3,
370,
675,
12,
1331,
12,
2811,
12,
5389,
12,
2780,
12,
11207,
12,
13473,
12,
436,
15,
269,
12743,
199,
3,
6866,
402,
314,
2290,
12,
436,
370,
11291,
12103,
370,
12676,
314,
2290,
365,
199,
3,
13985,
370,
886,
880,
12,
5420,
370,
314,
2569,
3704,
26,
199,
3,
199,
3,
710,
3432,
4248,
4245,
436,
642,
4983,
4245,
10989,
506,
5120,
315,
1006,
199,
3,
6866,
503,
13393,
12468,
402,
314,
2290,
14,
199,
3,
199,
3,
2334,
4141,
2281,
7049,
298,
1179,
2281,
401,
2428,
3408,
1634,
1821,
3826,
12,
7168,
1549,
199,
3,
5292,
12,
6931,
5400,
2845,
5471,
2296,
2334,
2990,
1634,
3169,
12,
199,
3,
3092,
2381,
437,
3115,
3104,
2401,
13229,
14,
1621,
4825,
6461,
7000,
2334,
199,
3,
10610,
1549,
5877,
8164,
6262,
7024,
2381,
1821,
13140,
12,
6736,
1549,
5010,
199,
3,
5603,
12,
7061,
1621,
1261,
9612,
1634,
7066,
12,
7056,
1549,
7334,
12,
7043,
4442,
12,
199,
3,
5738,
1634,
1549,
1621,
11287,
1663,
2334,
4141,
1549,
2334,
4815,
1549,
5010,
13198,
1621,
2334,
199,
3,
4141,
14,
199,
199,
504,
636,
2443,
363,
492,
3679,
63,
646,
199,
199,
646,
9143,
199,
646,
7975,
199,
646,
4182,
199,
646,
984,
199,
646,
2943,
199,
199,
363,
2502,
363,
275,
298,
31231,
16997,
262,
22912,
834,
665,
18486,
16997,
262,
32,
1548,
14,
1308,
4335,
199,
363,
1023,
363,
275,
298,
17,
14,
709,
14,
16,
2,
421,
199,
3,
18491,
367,
7437,
512,
30672,
1015,
26796,
425,
14,
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,
4521,
1082,
275,
984,
14,
1023,
63,
815,
59,
16,
26,
18,
61,
2356,
334,
19,
12,
841,
9,
199,
199,
692,
7843,
19,
26,
272,
1059,
63,
1313,
275,
620,
12,
272,
3000,
63,
1313,
275,
1109,
12,
272,
1021,
63,
1313,
275,
730,
12,
272,
1318,
63,
466,
275,
620,
272,
3366,
63,
466,
275,
2783,
339,
9141,
4305,
275,
984,
14,
13634,
199,
2836,
26,
272,
1059,
63,
1313,
275,
7116,
12,
272,
3000,
63,
1313,
275,
334,
442,
12,
1846,
9,
272,
1021,
63,
1313,
275,
334,
466,
12,
2943,
14,
31165,
9,
272,
1318,
63,
466,
275,
2649,
272,
3366,
63,
466,
275,
620,
339,
340,
984,
14,
3246,
14,
2460,
480,
6138,
2349,
267,
327,
25333,
3544,
4440,
4337,
5821,
14,
267,
9141,
4305,
275,
1109,
1332,
17,
5213,
7105,
9,
446,
413,
9,
272,
587,
26,
267,
327,
2779,
1159,
3962,
370,
1172,
13855,
8,
2809,
9,
1137,
13855,
8,
2713,
63,
30104,
63,
84,
680,
267,
1021,
1323,
8,
785,
304,
953,
347,
636,
552,
721,
277,
304,
355,
372,
413,
5213,
7105,
267,
862,
26,
288,
822,
8,
56,
1012,
267,
871,
23870,
26,
288,
327,
4337,
13,
2075,
288,
9141,
4305,
275,
1109,
1332,
17,
5213,
7105,
9,
446,
413,
9,
267,
587,
26,
288,
327,
5049,
13,
2075,
288,
9141,
4305,
275,
1109,
1332,
17,
5213,
13668,
9,
446,
413,
9,
267,
2150,
1323,
421,
199,
318,
485,
525,
63,
1301,
8,
1532,
12,
1382,
304,
272,
408,
1123,
3794,
370,
282,
805,
1041,
272,
2562,
855,
1301,
363,
275,
1382,
421,
199,
318,
485,
646,
63,
578,
8,
354,
304,
272,
408,
6295,
859,
12,
8152,
314,
859,
2410,
314,
2061,
6308,
1041,
272,
636,
646,
721,
354,
9,
272,
372,
984,
14,
3112,
59,
354,
61,
421,
199,
533,
485,
14269,
28782,
8,
785,
304,
339,
347,
636,
826,
721,
277,
12,
536,
304,
267,
291,
14,
354,
275,
536,
339,
347,
636,
362,
721,
277,
12,
1559,
12,
9253,
304,
267,
754,
275,
291,
423,
6983,
342,
267,
5371,
8,
1113,
12,
291,
14,
354,
12,
754,
9,
221,
327,
30110,
22652,
636,
409,
4343,
267,
862,
26,
288,
327,
961,
365,
282,
4546,
23761,
12,
1325,
652,
23674,
3879,
642,
4020,
701,
288,
327,
12881,
642,
5872,
14,
288,
24358,
8,
1113,
855,
533,
3108,
291,
14,
354,
9,
267,
871,
4281,
26,
288,
986,
267,
372,
754,
421,
199,
533,
11147,
1547,
14269,
28782,
304,
339,
347,
636,
826,
721,
277,
12,
536,
12,
2269,
12,
892,
29,
403,
304,
267,
1613,
8,
20774,
2377,
12,
291,
2843,
826,
721,
354,
9,
267,
340,
7843,
19,
26,
288,
340,
892,
365,
488,
26,
355,
892,
275,
536,
288,
291,
14,
1494,
275,
892,
267,
587,
26,
288,
291,
14,
1494,
275,
2269,
339,
347,
485,
6983,
8,
277,
304,
267,
372,
485,
646,
63,
578,
8,
277,
14,
1494,
9,
339,
347,
636,
5675,
721,
277,
12,
1921,
304,
267,
485,
578,
275,
291,
423,
6983,
342,
267,
574,
275,
2519,
1547,
578,
12,
1921,
9,
267,
5371,
8,
277,
12,
1921,
12,
574,
9,
267,
372,
574,
421,
199,
533,
485,
14269,
2377,
8,
1313,
14,
21820,
304,
339,
347,
636,
826,
721,
277,
12,
536,
304,
267,
1613,
1547,
14269,
2377,
12,
291,
2843,
826,
721,
354,
9,
267,
291,
855,
1301,
363,
275,
291,
855,
533,
4914,
1301,
363,
339,
347,
636,
694,
721,
277,
304,
267,
3290,
275,
2097,
363,
1301,
13915,
4396,
354,
363,
937,
267,
3290,
847,
359,
962,
14,
354,
367,
1921,
315,
291,
423,
3539,
63,
2987,
61,
267,
372,
3290,
339,
327,
20196,
1077,
4278,
642,
272,
485,
3539,
63,
2987,
275,
942,
421,
199,
533,
8863,
1547,
14269,
28782,
304,
339,
347,
636,
826,
721,
277,
12,
536,
12,
2269,
63,
1494,
12,
892,
63,
1494,
12,
2269,
63,
962,
29,
403,
12,
892,
63,
962,
29,
403,
304,
267,
1613,
8,
20774,
1646,
12,
291,
2843,
826,
721,
354,
9
] |
[
22905,
367,
3575,
1233,
626,
7858,
641,
2018,
499,
436,
650,
624,
199,
199,
3,
1898,
334,
67,
9,
7129,
13,
7806,
26844,
16997,
262,
22912,
834,
199,
3,
199,
3,
8779,
365,
11882,
10009,
12,
2867,
402,
11204,
12,
370,
1263,
4954,
12408,
282,
1331,
199,
3,
402,
642,
2032,
436,
4568,
3794,
1584,
334,
1589,
298,
10337,
1288,
370,
7962,
199,
3,
315,
314,
2290,
1928,
10588,
12,
5893,
1928,
12305,
314,
4481,
199,
3,
370,
675,
12,
1331,
12,
2811,
12,
5389,
12,
2780,
12,
11207,
12,
13473,
12,
436,
15,
269,
12743,
199,
3,
6866,
402,
314,
2290,
12,
436,
370,
11291,
12103,
370,
12676,
314,
2290,
365,
199,
3,
13985,
370,
886,
880,
12,
5420,
370,
314,
2569,
3704,
26,
199,
3,
199,
3,
710,
3432,
4248,
4245,
436,
642,
4983,
4245,
10989,
506,
5120,
315,
1006,
199,
3,
6866,
503,
13393,
12468,
402,
314,
2290,
14,
199,
3,
199,
3,
2334,
4141,
2281,
7049,
298,
1179,
2281,
401,
2428,
3408,
1634,
1821,
3826,
12,
7168,
1549,
199,
3,
5292,
12,
6931,
5400,
2845,
5471,
2296,
2334,
2990,
1634,
3169,
12,
199,
3,
3092,
2381,
437,
3115,
3104,
2401,
13229,
14,
1621,
4825,
6461,
7000,
2334,
199,
3,
10610,
1549,
5877,
8164,
6262,
7024,
2381,
1821,
13140,
12,
6736,
1549,
5010,
199,
3,
5603,
12,
7061,
1621,
1261,
9612,
1634,
7066,
12,
7056,
1549,
7334,
12,
7043,
4442,
12,
199,
3,
5738,
1634,
1549,
1621,
11287,
1663,
2334,
4141,
1549,
2334,
4815,
1549,
5010,
13198,
1621,
2334,
199,
3,
4141,
14,
199,
199,
504,
636,
2443,
363,
492,
3679,
63,
646,
199,
199,
646,
9143,
199,
646,
7975,
199,
646,
4182,
199,
646,
984,
199,
646,
2943,
199,
199,
363,
2502,
363,
275,
298,
31231,
16997,
262,
22912,
834,
665,
18486,
16997,
262,
32,
1548,
14,
1308,
4335,
199,
363,
1023,
363,
275,
298,
17,
14,
709,
14,
16,
2,
421,
199,
3,
18491,
367,
7437,
512,
30672,
1015,
26796,
425,
14,
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,
4521,
1082,
275,
984,
14,
1023,
63,
815,
59,
16,
26,
18,
61,
2356,
334,
19,
12,
841,
9,
199,
199,
692,
7843,
19,
26,
272,
1059,
63,
1313,
275,
620,
12,
272,
3000,
63,
1313,
275,
1109,
12,
272,
1021,
63,
1313,
275,
730,
12,
272,
1318,
63,
466,
275,
620,
272,
3366,
63,
466,
275,
2783,
339,
9141,
4305,
275,
984,
14,
13634,
199,
2836,
26,
272,
1059,
63,
1313,
275,
7116,
12,
272,
3000,
63,
1313,
275,
334,
442,
12,
1846,
9,
272,
1021,
63,
1313,
275,
334,
466,
12,
2943,
14,
31165,
9,
272,
1318,
63,
466,
275,
2649,
272,
3366,
63,
466,
275,
620,
339,
340,
984,
14,
3246,
14,
2460,
480,
6138,
2349,
267,
327,
25333,
3544,
4440,
4337,
5821,
14,
267,
9141,
4305,
275,
1109,
1332,
17,
5213,
7105,
9,
446,
413,
9,
272,
587,
26,
267,
327,
2779,
1159,
3962,
370,
1172,
13855,
8,
2809,
9,
1137,
13855,
8,
2713,
63,
30104,
63,
84,
680,
267,
1021,
1323,
8,
785,
304,
953,
347,
636,
552,
721,
277,
304,
355,
372,
413,
5213,
7105,
267,
862,
26,
288,
822,
8,
56,
1012,
267,
871,
23870,
26,
288,
327,
4337,
13,
2075,
288,
9141,
4305,
275,
1109,
1332,
17,
5213,
7105,
9,
446,
413,
9,
267,
587,
26,
288,
327,
5049,
13,
2075,
288,
9141,
4305,
275,
1109,
1332,
17,
5213,
13668,
9,
446,
413,
9,
267,
2150,
1323,
421,
199,
318,
485,
525,
63,
1301,
8,
1532,
12,
1382,
304,
272,
408,
1123,
3794,
370,
282,
805,
1041,
272,
2562,
855,
1301,
363,
275,
1382,
421,
199,
318,
485,
646,
63,
578,
8,
354,
304,
272,
408,
6295,
859,
12,
8152,
314,
859,
2410,
314,
2061,
6308,
1041,
272,
636,
646,
721,
354,
9,
272,
372,
984,
14,
3112,
59,
354,
61,
421,
199,
533,
485,
14269,
28782,
8,
785,
304,
339,
347,
636,
826,
721,
277,
12,
536,
304,
267,
291,
14,
354,
275,
536,
339,
347,
636,
362,
721,
277,
12,
1559,
12,
9253,
304,
267,
754,
275,
291,
423,
6983,
342,
267,
5371,
8,
1113,
12,
291,
14,
354,
12,
754,
9,
221,
327,
30110,
22652,
636,
409,
4343,
267,
862,
26,
288,
327,
961,
365,
282,
4546,
23761,
12,
1325,
652,
23674,
3879,
642,
4020,
701,
288,
327,
12881,
642,
5872,
14,
288,
24358,
8,
1113,
855,
533,
3108,
291,
14,
354,
9,
267,
871,
4281,
26,
288,
986,
267,
372,
754,
421,
199,
533,
11147,
1547,
14269,
28782,
304,
339,
347,
636,
826,
721,
277,
12,
536,
12,
2269,
12,
892,
29,
403,
304,
267,
1613,
8,
20774,
2377,
12,
291,
2843,
826,
721,
354,
9,
267,
340,
7843,
19,
26,
288,
340,
892,
365,
488,
26,
355,
892,
275,
536,
288,
291,
14,
1494,
275,
892,
267,
587,
26,
288,
291,
14,
1494,
275,
2269,
339,
347,
485,
6983,
8,
277,
304,
267,
372,
485,
646,
63,
578,
8,
277,
14,
1494,
9,
339,
347,
636,
5675,
721,
277,
12,
1921,
304,
267,
485,
578,
275,
291,
423,
6983,
342,
267,
574,
275,
2519,
1547,
578,
12,
1921,
9,
267,
5371,
8,
277,
12,
1921,
12,
574,
9,
267,
372,
574,
421,
199,
533,
485,
14269,
2377,
8,
1313,
14,
21820,
304,
339,
347,
636,
826,
721,
277,
12,
536,
304,
267,
1613,
1547,
14269,
2377,
12,
291,
2843,
826,
721,
354,
9,
267,
291,
855,
1301,
363,
275,
291,
855,
533,
4914,
1301,
363,
339,
347,
636,
694,
721,
277,
304,
267,
3290,
275,
2097,
363,
1301,
13915,
4396,
354,
363,
937,
267,
3290,
847,
359,
962,
14,
354,
367,
1921,
315,
291,
423,
3539,
63,
2987,
61,
267,
372,
3290,
339,
327,
20196,
1077,
4278,
642,
272,
485,
3539,
63,
2987,
275,
942,
421,
199,
533,
8863,
1547,
14269,
28782,
304,
339,
347,
636,
826,
721,
277,
12,
536,
12,
2269,
63,
1494,
12,
892,
63,
1494,
12,
2269,
63,
962,
29,
403,
12,
892,
63,
962,
29,
403,
304,
267,
1613,
8,
20774,
1646,
12,
291,
2843,
826,
721,
354,
9,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
janusnic/ecommerce
|
ecommerce/settings/local.py
|
1
|
4047
|
"""Development settings and globals."""
from __future__ import absolute_import
import os
from os.path import join, normpath
from ecommerce.settings.base import *
from ecommerce.settings.logger import get_logger_config
# DEBUG CONFIGURATION
# See: https://docs.djangoproject.com/en/dev/ref/settings/#debug
DEBUG = True
# See: https://docs.djangoproject.com/en/dev/ref/settings/#template-debug
TEMPLATE_DEBUG = DEBUG
# END DEBUG CONFIGURATION
# EMAIL CONFIGURATION
# See: https://docs.djangoproject.com/en/dev/ref/settings/#email-backend
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
# END EMAIL CONFIGURATION
# DATABASE CONFIGURATION
# See: https://docs.djangoproject.com/en/dev/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': normpath(join(DJANGO_ROOT, 'default.db')),
'USER': '',
'PASSWORD': '',
'HOST': '',
'PORT': '',
'ATOMIC_REQUESTS': True,
}
}
# END DATABASE CONFIGURATION
# CACHE CONFIGURATION
# See: https://docs.djangoproject.com/en/dev/ref/settings/#caches
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
}
}
# END CACHE CONFIGURATION
# TOOLBAR CONFIGURATION
# See: http://django-debug-toolbar.readthedocs.org/en/latest/installation.html#explicit-setup
if os.environ.get('ENABLE_DJANGO_TOOLBAR', False):
INSTALLED_APPS += (
'debug_toolbar',
)
MIDDLEWARE_CLASSES += (
'debug_toolbar.middleware.DebugToolbarMiddleware',
)
DEBUG_TOOLBAR_PATCH_SETTINGS = False
# http://django-debug-toolbar.readthedocs.org/en/latest/installation.html
INTERNAL_IPS = ('127.0.0.1',)
# END TOOLBAR CONFIGURATION
# URL CONFIGURATION
ECOMMERCE_URL_ROOT = 'http://localhost:8002'
LMS_URL_ROOT = 'http://127.0.0.1:8000'
# The location of the LMS heartbeat page
LMS_HEARTBEAT_URL = get_lms_url('/heartbeat')
# The location of the LMS student dashboard
LMS_DASHBOARD_URL = get_lms_url('/dashboard')
OAUTH2_PROVIDER_URL = get_lms_url('/oauth2')
COMMERCE_API_URL = get_lms_url('/api/commerce/v1/')
# END URL CONFIGURATION
# AUTHENTICATION
# Set these to the correct values for your OAuth2/OpenID Connect provider (e.g., devstack)
SOCIAL_AUTH_EDX_OIDC_KEY = 'replace-me'
SOCIAL_AUTH_EDX_OIDC_SECRET = 'replace-me'
SOCIAL_AUTH_EDX_OIDC_URL_ROOT = OAUTH2_PROVIDER_URL
SOCIAL_AUTH_EDX_OIDC_ID_TOKEN_DECRYPTION_KEY = SOCIAL_AUTH_EDX_OIDC_SECRET
JWT_AUTH.update({
'JWT_SECRET_KEY': 'insecure-secret-key',
'JWT_ISSUER': OAUTH2_PROVIDER_URL
})
# END AUTHENTICATION
# ORDER PROCESSING
ENROLLMENT_API_URL = get_lms_url('/api/enrollment/v1/enrollment')
ENROLLMENT_FULFILLMENT_TIMEOUT = 15 # devstack is slow!
EDX_API_KEY = 'replace-me'
# END ORDER PROCESSING
# PAYMENT PROCESSING
PAYMENT_PROCESSOR_CONFIG = {
'cybersource': {
'soap_api_url': 'https://ics2wstest.ic3.com/commerce/1.x/transactionProcessor/CyberSourceTransaction_1.115.wsdl',
'merchant_id': 'fake-merchant-id',
'transaction_key': 'fake-transaction-key',
'profile_id': 'fake-profile-id',
'access_key': 'fake-access-key',
'secret_key': 'fake-secret-key',
'payment_page_url': 'https://testsecureacceptance.cybersource.com/pay',
'receipt_page_url': get_lms_url('/commerce/checkout/receipt/'),
'cancel_page_url': get_lms_url('/commerce/checkout/cancel/'),
},
'paypal': {
'mode': 'sandbox',
'client_id': 'fake-client-id',
'client_secret': 'fake-client-secret',
'receipt_url': get_lms_url('/commerce/checkout/receipt/'),
'cancel_url': get_lms_url('/commerce/checkout/cancel/'),
},
}
# END PAYMENT PROCESSING
ENABLE_AUTO_AUTH = True
LOGGING = get_logger_config(debug=DEBUG, dev_env=True, local_loglevel='DEBUG')
#####################################################################
# Lastly, see if the developer has any local overrides.
try:
from .private import * # pylint: disable=import-error
except ImportError:
pass
|
agpl-3.0
|
[
624,
23753,
2202,
436,
7992,
1041,
199,
504,
636,
2443,
363,
492,
3679,
63,
646,
199,
199,
646,
747,
199,
504,
747,
14,
515,
492,
4263,
12,
25962,
199,
199,
504,
325,
32711,
14,
1751,
14,
1095,
492,
627,
199,
504,
325,
32711,
14,
1751,
14,
2921,
492,
664,
63,
2921,
63,
888,
421,
199,
3,
10990,
15869,
15301,
199,
3,
1666,
26,
4178,
921,
4757,
14,
14013,
14,
957,
15,
287,
15,
2374,
15,
1121,
15,
1751,
12645,
1757,
199,
5287,
275,
715,
199,
199,
3,
1666,
26,
4178,
921,
4757,
14,
14013,
14,
957,
15,
287,
15,
2374,
15,
1121,
15,
1751,
12645,
1160,
13,
1757,
199,
7433,
63,
5287,
275,
10990,
199,
3,
7729,
10990,
15869,
15301,
199,
199,
3,
32320,
15869,
15301,
199,
3,
1666,
26,
4178,
921,
4757,
14,
14013,
14,
957,
15,
287,
15,
2374,
15,
1121,
15,
1751,
12645,
2123,
13,
4620,
199,
10089,
63,
18145,
275,
283,
1176,
14,
1018,
14,
1198,
14,
7765,
14,
6614,
14,
7035,
8447,
7,
199,
3,
7729,
32320,
15869,
15301,
421,
199,
3,
31705,
15869,
15301,
199,
3,
1666,
26,
4178,
921,
4757,
14,
14013,
14,
957,
15,
287,
15,
2374,
15,
1121,
15,
1751,
12645,
17439,
199,
27260,
275,
469,
272,
283,
885,
356,
469,
267,
283,
15956,
356,
283,
1176,
14,
697,
14,
7765,
14,
10659,
19,
297,
267,
283,
2339,
356,
25962,
8,
904,
8,
22848,
63,
5441,
12,
283,
885,
14,
697,
3855,
267,
283,
3791,
356,
3260,
267,
283,
9032,
356,
3260,
267,
283,
5449,
356,
3260,
267,
283,
3657,
356,
3260,
267,
283,
22479,
948,
63,
6780,
51,
356,
715,
12,
272,
789,
199,
93,
199,
3,
7729,
31705,
15869,
15301,
421,
199,
3,
7240,
4576,
15869,
15301,
199,
3,
1666,
26,
4178,
921,
4757,
14,
14013,
14,
957,
15,
287,
15,
2374,
15,
1121,
15,
1751,
12645,
17595,
199,
3263,
1244,
654,
275,
469,
272,
283,
885,
356,
469,
267,
283,
18145,
356,
283,
1176,
14,
1018,
14,
1637,
14,
7765,
14,
2102,
5286,
14,
3040,
14169,
4437,
297,
272,
789,
199,
93,
199,
3,
7729,
7240,
4576,
15869,
15301,
421,
199,
3,
2296,
2228,
13895,
15869,
15301,
199,
3,
1666,
26,
1455,
921,
1176,
13,
1757,
13,
13951,
14,
25085,
14,
1308,
15,
287,
15,
7410,
15,
23048,
14,
1360,
3,
10306,
13,
2758,
199,
692,
747,
14,
2314,
14,
362,
360,
8898,
63,
22848,
63,
9731,
13895,
297,
756,
304,
272,
31061,
63,
14219,
847,
334,
267,
283,
1757,
63,
13951,
297,
272,
776,
339,
30718,
63,
13748,
847,
334,
267,
283,
1757,
63,
13951,
14,
5754,
14,
7084,
29630,
6608,
297,
272,
776,
339,
10990,
63,
9731,
13895,
63,
17073,
63,
13931,
275,
756,
199,
199,
3,
1455,
921,
1176,
13,
1757,
13,
13951,
14,
25085,
14,
1308,
15,
287,
15,
7410,
15,
23048,
14,
1360,
199,
17681,
63,
12346,
275,
661,
4195,
14,
16,
14,
16,
14,
17,
9538,
199,
3,
7729,
2296,
2228,
13895,
15869,
15301,
421,
199,
3,
2851,
15869,
15301,
199,
37,
5378,
540,
2089,
63,
2632,
63,
5441,
275,
283,
1014,
921,
5967,
26,
6718,
18,
7,
199,
199,
44,
3053,
63,
2632,
63,
5441,
275,
283,
1014,
921,
4195,
14,
16,
14,
16,
14,
17,
26,
15214,
7,
199,
199,
3,
710,
2909,
402,
314,
27540,
32015,
2034,
199,
44,
3053,
63,
1645,
2294,
6773,
619,
63,
2632,
275,
664,
63,
15807,
63,
633,
2336,
22685,
358,
199,
199,
3,
710,
2909,
402,
314,
27540,
6474,
17216,
199,
44,
3053,
63,
29019,
23368,
63,
2632,
275,
664,
63,
15807,
63,
633,
2336,
9743,
358,
199,
199,
24041,
18,
63,
30600,
63,
2632,
275,
664,
63,
15807,
63,
633,
2336,
6126,
18,
358,
199,
199,
5378,
540,
2089,
63,
3735,
63,
2632,
275,
664,
63,
15807,
63,
633,
2336,
1246,
15,
32711,
15,
86,
17,
6217,
199,
3,
7729,
2851,
15869,
15301,
421,
199,
3,
7560,
20987,
2594,
199,
3,
2494,
3520,
370,
314,
3211,
1338,
367,
2195,
11715,
18,
15,
30244,
15175,
5022,
334,
69,
14,
71,
2020,
4866,
2340,
9,
199,
4118,
21212,
63,
5580,
63,
1149,
56,
63,
16337,
35,
63,
3078,
275,
283,
1814,
13,
278,
7,
199,
4118,
21212,
63,
5580,
63,
1149,
56,
63,
16337,
35,
63,
12961,
275,
283,
1814,
13,
278,
7,
199,
4118,
21212,
63,
5580,
63,
1149,
56,
63,
16337,
35,
63,
2632,
63,
5441,
275,
593,
5580,
18,
63,
30600,
63,
2632,
199,
4118,
21212,
63,
5580,
63,
1149,
56,
63,
16337,
35,
63,
998,
63,
8803,
63,
1093,
19079,
1075,
63,
3078,
275,
3562,
21212,
63,
5580,
63,
1149,
56,
63,
16337,
35,
63,
12961,
199,
199,
42,
21283,
63,
5580,
14,
873,
2561,
272,
283,
42,
21283,
63,
12961,
63,
3078,
356,
283,
24824,
13,
4731,
13,
498,
297,
272,
283,
42,
21283,
63,
1311,
6195,
540,
356,
593,
5580,
18,
63,
30600,
63,
2632,
199,
1552,
199,
3,
7729,
7560,
20987,
2594,
421,
199,
3,
16044,
3611,
35,
1608,
1206,
199,
742,
14881,
4479,
63,
3735,
63,
2632,
275,
664,
63,
15807,
63,
633,
2336,
1246,
15,
12214,
15,
86,
17,
15,
12214,
358,
199,
742,
14881,
4479,
63,
38,
1293,
5110,
44,
4479,
63,
8899,
275,
4114,
221,
327,
4866,
2340,
365,
11999,
1,
199,
199,
1149,
56,
63,
3735,
63,
3078,
275,
283,
1814,
13,
278,
7,
199,
3,
7729,
16044,
3611,
35,
1608,
1206,
421,
199,
3,
510,
3448,
4479,
3611,
35,
1608,
1206,
199,
17698,
4479,
63,
24341,
63,
5569,
275,
469,
272,
283,
1480,
605,
1365,
356,
469,
267,
283,
21818,
63,
1246,
63,
633,
356,
283,
2859,
921,
2932,
18,
3569,
396,
14,
530,
19,
14,
957,
15,
32711,
15,
17,
14,
88,
15,
5945,
10438,
15,
9156,
605,
2980,
10161,
63,
17,
14,
7680,
14,
21452,
297,
267,
283,
2626,
26938,
63,
344,
356,
283,
3183,
13,
2626,
26938,
13,
344,
297,
267,
283,
5945,
63,
498,
356,
283,
3183,
13,
5945,
13,
498,
297,
267,
283,
2913,
63,
344,
356,
283,
3183,
13,
2913,
13,
344,
297,
267,
283,
2732,
63,
498,
356,
283,
3183,
13,
2732,
13,
498,
297,
267,
283,
4731,
63,
498,
356,
283,
3183,
13,
4731,
13,
498,
297
] |
[
23753,
2202,
436,
7992,
1041,
199,
504,
636,
2443,
363,
492,
3679,
63,
646,
199,
199,
646,
747,
199,
504,
747,
14,
515,
492,
4263,
12,
25962,
199,
199,
504,
325,
32711,
14,
1751,
14,
1095,
492,
627,
199,
504,
325,
32711,
14,
1751,
14,
2921,
492,
664,
63,
2921,
63,
888,
421,
199,
3,
10990,
15869,
15301,
199,
3,
1666,
26,
4178,
921,
4757,
14,
14013,
14,
957,
15,
287,
15,
2374,
15,
1121,
15,
1751,
12645,
1757,
199,
5287,
275,
715,
199,
199,
3,
1666,
26,
4178,
921,
4757,
14,
14013,
14,
957,
15,
287,
15,
2374,
15,
1121,
15,
1751,
12645,
1160,
13,
1757,
199,
7433,
63,
5287,
275,
10990,
199,
3,
7729,
10990,
15869,
15301,
199,
199,
3,
32320,
15869,
15301,
199,
3,
1666,
26,
4178,
921,
4757,
14,
14013,
14,
957,
15,
287,
15,
2374,
15,
1121,
15,
1751,
12645,
2123,
13,
4620,
199,
10089,
63,
18145,
275,
283,
1176,
14,
1018,
14,
1198,
14,
7765,
14,
6614,
14,
7035,
8447,
7,
199,
3,
7729,
32320,
15869,
15301,
421,
199,
3,
31705,
15869,
15301,
199,
3,
1666,
26,
4178,
921,
4757,
14,
14013,
14,
957,
15,
287,
15,
2374,
15,
1121,
15,
1751,
12645,
17439,
199,
27260,
275,
469,
272,
283,
885,
356,
469,
267,
283,
15956,
356,
283,
1176,
14,
697,
14,
7765,
14,
10659,
19,
297,
267,
283,
2339,
356,
25962,
8,
904,
8,
22848,
63,
5441,
12,
283,
885,
14,
697,
3855,
267,
283,
3791,
356,
3260,
267,
283,
9032,
356,
3260,
267,
283,
5449,
356,
3260,
267,
283,
3657,
356,
3260,
267,
283,
22479,
948,
63,
6780,
51,
356,
715,
12,
272,
789,
199,
93,
199,
3,
7729,
31705,
15869,
15301,
421,
199,
3,
7240,
4576,
15869,
15301,
199,
3,
1666,
26,
4178,
921,
4757,
14,
14013,
14,
957,
15,
287,
15,
2374,
15,
1121,
15,
1751,
12645,
17595,
199,
3263,
1244,
654,
275,
469,
272,
283,
885,
356,
469,
267,
283,
18145,
356,
283,
1176,
14,
1018,
14,
1637,
14,
7765,
14,
2102,
5286,
14,
3040,
14169,
4437,
297,
272,
789,
199,
93,
199,
3,
7729,
7240,
4576,
15869,
15301,
421,
199,
3,
2296,
2228,
13895,
15869,
15301,
199,
3,
1666,
26,
1455,
921,
1176,
13,
1757,
13,
13951,
14,
25085,
14,
1308,
15,
287,
15,
7410,
15,
23048,
14,
1360,
3,
10306,
13,
2758,
199,
692,
747,
14,
2314,
14,
362,
360,
8898,
63,
22848,
63,
9731,
13895,
297,
756,
304,
272,
31061,
63,
14219,
847,
334,
267,
283,
1757,
63,
13951,
297,
272,
776,
339,
30718,
63,
13748,
847,
334,
267,
283,
1757,
63,
13951,
14,
5754,
14,
7084,
29630,
6608,
297,
272,
776,
339,
10990,
63,
9731,
13895,
63,
17073,
63,
13931,
275,
756,
199,
199,
3,
1455,
921,
1176,
13,
1757,
13,
13951,
14,
25085,
14,
1308,
15,
287,
15,
7410,
15,
23048,
14,
1360,
199,
17681,
63,
12346,
275,
661,
4195,
14,
16,
14,
16,
14,
17,
9538,
199,
3,
7729,
2296,
2228,
13895,
15869,
15301,
421,
199,
3,
2851,
15869,
15301,
199,
37,
5378,
540,
2089,
63,
2632,
63,
5441,
275,
283,
1014,
921,
5967,
26,
6718,
18,
7,
199,
199,
44,
3053,
63,
2632,
63,
5441,
275,
283,
1014,
921,
4195,
14,
16,
14,
16,
14,
17,
26,
15214,
7,
199,
199,
3,
710,
2909,
402,
314,
27540,
32015,
2034,
199,
44,
3053,
63,
1645,
2294,
6773,
619,
63,
2632,
275,
664,
63,
15807,
63,
633,
2336,
22685,
358,
199,
199,
3,
710,
2909,
402,
314,
27540,
6474,
17216,
199,
44,
3053,
63,
29019,
23368,
63,
2632,
275,
664,
63,
15807,
63,
633,
2336,
9743,
358,
199,
199,
24041,
18,
63,
30600,
63,
2632,
275,
664,
63,
15807,
63,
633,
2336,
6126,
18,
358,
199,
199,
5378,
540,
2089,
63,
3735,
63,
2632,
275,
664,
63,
15807,
63,
633,
2336,
1246,
15,
32711,
15,
86,
17,
6217,
199,
3,
7729,
2851,
15869,
15301,
421,
199,
3,
7560,
20987,
2594,
199,
3,
2494,
3520,
370,
314,
3211,
1338,
367,
2195,
11715,
18,
15,
30244,
15175,
5022,
334,
69,
14,
71,
2020,
4866,
2340,
9,
199,
4118,
21212,
63,
5580,
63,
1149,
56,
63,
16337,
35,
63,
3078,
275,
283,
1814,
13,
278,
7,
199,
4118,
21212,
63,
5580,
63,
1149,
56,
63,
16337,
35,
63,
12961,
275,
283,
1814,
13,
278,
7,
199,
4118,
21212,
63,
5580,
63,
1149,
56,
63,
16337,
35,
63,
2632,
63,
5441,
275,
593,
5580,
18,
63,
30600,
63,
2632,
199,
4118,
21212,
63,
5580,
63,
1149,
56,
63,
16337,
35,
63,
998,
63,
8803,
63,
1093,
19079,
1075,
63,
3078,
275,
3562,
21212,
63,
5580,
63,
1149,
56,
63,
16337,
35,
63,
12961,
199,
199,
42,
21283,
63,
5580,
14,
873,
2561,
272,
283,
42,
21283,
63,
12961,
63,
3078,
356,
283,
24824,
13,
4731,
13,
498,
297,
272,
283,
42,
21283,
63,
1311,
6195,
540,
356,
593,
5580,
18,
63,
30600,
63,
2632,
199,
1552,
199,
3,
7729,
7560,
20987,
2594,
421,
199,
3,
16044,
3611,
35,
1608,
1206,
199,
742,
14881,
4479,
63,
3735,
63,
2632,
275,
664,
63,
15807,
63,
633,
2336,
1246,
15,
12214,
15,
86,
17,
15,
12214,
358,
199,
742,
14881,
4479,
63,
38,
1293,
5110,
44,
4479,
63,
8899,
275,
4114,
221,
327,
4866,
2340,
365,
11999,
1,
199,
199,
1149,
56,
63,
3735,
63,
3078,
275,
283,
1814,
13,
278,
7,
199,
3,
7729,
16044,
3611,
35,
1608,
1206,
421,
199,
3,
510,
3448,
4479,
3611,
35,
1608,
1206,
199,
17698,
4479,
63,
24341,
63,
5569,
275,
469,
272,
283,
1480,
605,
1365,
356,
469,
267,
283,
21818,
63,
1246,
63,
633,
356,
283,
2859,
921,
2932,
18,
3569,
396,
14,
530,
19,
14,
957,
15,
32711,
15,
17,
14,
88,
15,
5945,
10438,
15,
9156,
605,
2980,
10161,
63,
17,
14,
7680,
14,
21452,
297,
267,
283,
2626,
26938,
63,
344,
356,
283,
3183,
13,
2626,
26938,
13,
344,
297,
267,
283,
5945,
63,
498,
356,
283,
3183,
13,
5945,
13,
498,
297,
267,
283,
2913,
63,
344,
356,
283,
3183,
13,
2913,
13,
344,
297,
267,
283,
2732,
63,
498,
356,
283,
3183,
13,
2732,
13,
498,
297,
267,
283,
4731,
63,
498,
356,
283,
3183,
13,
4731,
13,
498,
297,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
mmasaki/trove
|
trove/tests/tempest/tests/api/versions/test_versions.py
|
1
|
1650
|
# Copyright 2014 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 tempest.lib import decorators
from testtools import testcase as testtools
from trove.tests.tempest.tests.api import base
class DatabaseVersionsTest(base.BaseDatabaseTest):
@classmethod
def setup_clients(cls):
super(DatabaseVersionsTest, cls).setup_clients()
cls.client = cls.database_versions_client
@testtools.attr('smoke')
@decorators.idempotent_id('6952cd77-90cd-4dca-bb60-8e2c797940cf')
def test_list_db_versions(self):
versions = self.client.list_db_versions()['versions']
self.assertTrue(len(versions) > 0, "No database versions found")
# List of all versions should contain the current version, and there
# should only be one 'current' version
current_versions = list()
for version in versions:
if 'CURRENT' == version['status']:
current_versions.append(version['id'])
self.assertEqual(1, len(current_versions))
self.assertIn(self.db_current_version, current_versions)
|
apache-2.0
|
[
3,
1898,
6927,
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,
24076,
14,
773,
492,
20419,
199,
504,
30741,
492,
16228,
465,
30741,
199,
199,
504,
307,
11750,
14,
2219,
14,
808,
597,
14,
2219,
14,
1246,
492,
1300,
421,
199,
533,
8692,
21167,
774,
8,
1095,
14,
1563,
7243,
774,
304,
339,
768,
3744,
272,
347,
3272,
63,
14555,
8,
1886,
304,
267,
1613,
8,
7243,
21167,
774,
12,
843,
680,
2758,
63,
14555,
342,
267,
843,
14,
1258,
275,
843,
14,
4659,
63,
6234,
63,
1258,
339,
768,
396,
2537,
14,
962,
360,
30697,
358,
272,
768,
11582,
14,
21307,
63,
344,
360,
1876,
2528,
2866,
1138,
13,
2710,
2866,
13,
20,
30296,
13,
2501,
2259,
13,
24,
69,
18,
67,
1965,
1965,
2167,
2177,
358,
272,
347,
511,
63,
513,
63,
697,
63,
6234,
8,
277,
304,
267,
5459,
275,
291,
14,
1258,
14,
513,
63,
697,
63,
6234,
12047,
6234,
418,
267,
291,
14,
1815,
8,
552,
8,
6234,
9,
690,
378,
12,
298,
1944,
3050,
5459,
1911,
531,
267,
327,
3820,
402,
1006,
5459,
1077,
1395,
314,
1453,
1015,
12,
436,
2337,
267,
327,
1077,
1454,
506,
1373,
283,
1818,
7,
1015,
267,
1453,
63,
6234,
275,
769,
342,
267,
367,
1015,
315,
5459,
26,
288,
340,
283,
14211,
7,
508,
1015,
459,
1205,
2565,
355,
1453,
63,
6234,
14,
740,
8,
1023,
459,
344,
1105,
267,
291,
14,
629,
8,
17,
12,
822,
8,
1818,
63,
6234,
430,
267,
291,
14,
4080,
8,
277,
14,
697,
63,
1818,
63,
1023,
12,
1453,
63,
6234,
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
] |
[
1898,
6927,
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,
24076,
14,
773,
492,
20419,
199,
504,
30741,
492,
16228,
465,
30741,
199,
199,
504,
307,
11750,
14,
2219,
14,
808,
597,
14,
2219,
14,
1246,
492,
1300,
421,
199,
533,
8692,
21167,
774,
8,
1095,
14,
1563,
7243,
774,
304,
339,
768,
3744,
272,
347,
3272,
63,
14555,
8,
1886,
304,
267,
1613,
8,
7243,
21167,
774,
12,
843,
680,
2758,
63,
14555,
342,
267,
843,
14,
1258,
275,
843,
14,
4659,
63,
6234,
63,
1258,
339,
768,
396,
2537,
14,
962,
360,
30697,
358,
272,
768,
11582,
14,
21307,
63,
344,
360,
1876,
2528,
2866,
1138,
13,
2710,
2866,
13,
20,
30296,
13,
2501,
2259,
13,
24,
69,
18,
67,
1965,
1965,
2167,
2177,
358,
272,
347,
511,
63,
513,
63,
697,
63,
6234,
8,
277,
304,
267,
5459,
275,
291,
14,
1258,
14,
513,
63,
697,
63,
6234,
12047,
6234,
418,
267,
291,
14,
1815,
8,
552,
8,
6234,
9,
690,
378,
12,
298,
1944,
3050,
5459,
1911,
531,
267,
327,
3820,
402,
1006,
5459,
1077,
1395,
314,
1453,
1015,
12,
436,
2337,
267,
327,
1077,
1454,
506,
1373,
283,
1818,
7,
1015,
267,
1453,
63,
6234,
275,
769,
342,
267,
367,
1015,
315,
5459,
26,
288,
340,
283,
14211,
7,
508,
1015,
459,
1205,
2565,
355,
1453,
63,
6234,
14,
740,
8,
1023,
459,
344,
1105,
267,
291,
14,
629,
8,
17,
12,
822,
8,
1818,
63,
6234,
430,
267,
291,
14,
4080,
8,
277,
14,
697,
63,
1818,
63,
1023,
12,
1453,
63,
6234,
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,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
felipenaselva/repo.felipe
|
plugin.video.velocity/scrapers/putlocker_both.py
|
1
|
15716
|
import urllib2,urllib,re,os
import random
import urlparse
import sys
import xbmcplugin,xbmcgui,xbmc, xbmcaddon, downloader, extract, time
import tools
from libs import kodi
from tm_libs import dom_parser
from libs import log_utils
import tools
from libs import cloudflare
from libs import log_utils
from tm_libs import dom_parser
import cookielib
from StringIO import StringIO
import gzip
import main_scrape
import base64
addon_id = kodi.addon_id
timeout = int(kodi.get_setting('scraper_timeout'))
tools.create_directory(tools.AOPATH, "All_Cookies/Putlocker")
cookiepath = xbmc.translatePath(os.path.join('special://home','addons',addon_id,'All_Cookies','Putlocker/'))
cookiejar = os.path.join(cookiepath,'cookies.lwp')
cj = cookielib.LWPCookieJar()
cookie_file = os.path.join(cookiepath,'cookies.lwp')
def __enum(**enums):
return type('Enum', (), enums)
MAX_RESPONSE = 1024 * 1024 * 2
FORCE_NO_MATCH = '***FORCE_NO_MATCH***'
QUALITIES = __enum(LOW='Low', MEDIUM='Medium', HIGH='High', HD720='HD720', HD1080='HD1080')
XHR = {'X-Requested-With': 'XMLHttpRequest'}
USER_AGENT = "Mozilla/5.0 (compatible, MSIE 11, Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko"
BR_VERS = [
['%s.0' % i for i in xrange(18, 43)],
['37.0.2062.103', '37.0.2062.120', '37.0.2062.124', '38.0.2125.101', '38.0.2125.104', '38.0.2125.111', '39.0.2171.71', '39.0.2171.95', '39.0.2171.99', '40.0.2214.93', '40.0.2214.111',
'40.0.2214.115', '42.0.2311.90', '42.0.2311.135', '42.0.2311.152', '43.0.2357.81', '43.0.2357.124', '44.0.2403.155', '44.0.2403.157', '45.0.2454.101', '45.0.2454.85', '46.0.2490.71',
'46.0.2490.80', '46.0.2490.86', '47.0.2526.73', '47.0.2526.80'],
['11.0']]
WIN_VERS = ['Windows NT 10.0', 'Windows NT 7.0', 'Windows NT 6.3', 'Windows NT 6.2', 'Windows NT 6.1', 'Windows NT 6.0', 'Windows NT 5.1', 'Windows NT 5.0']
FEATURES = ['; WOW64', '; Win64; IA64', '; Win64; x64', '']
RAND_UAS = ['Mozilla/5.0 ({win_ver}{feature}; rv:{br_ver}) Gecko/20100101 Firefox/{br_ver}',
'Mozilla/5.0 ({win_ver}{feature}) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/{br_ver} Safari/537.36',
'Mozilla/5.0 ({win_ver}{feature}; Trident/7.0; rv:{br_ver}) like Gecko']
HOST_Q = {}
HOST_Q[QUALITIES.LOW] = ['youwatch', 'allmyvideos', 'played.to', 'gorillavid']
HOST_Q[QUALITIES.MEDIUM] = ['primeshare', 'exashare', 'bestreams', 'flashx', 'vidto', 'vodlocker', 'thevideo', 'vidzi', 'vidbull',
'realvid', 'nosvideo', 'daclips', 'sharerepo', 'zalaa', 'filehoot', 'vshare']
HOST_Q[QUALITIES.HIGH] = ['vidspot', 'mrfile', 'divxstage', 'streamcloud', 'mooshare', 'novamov', 'mail.ru', 'vid.ag']
HOST_Q[QUALITIES.HD720] = ['thefile', 'sharesix', 'filenuke', 'vidxden', 'movshare', 'nowvideo', 'vidbux', 'streamin.to', 'allvid.ch']
HOST_Q[QUALITIES.HD1080] = ['hugefiles', '180upload', 'mightyupload', 'videomega', 'allmyvideos']
Q_ORDER = {QUALITIES.LOW: 1, QUALITIES.MEDIUM: 2, QUALITIES.HIGH: 3, QUALITIES.HD720: 4, QUALITIES.HD1080: 5}
# base_url = 'http://www.santaseries.com'
base_url = kodi.get_setting('putlocker_base_url')
def format_source_label( item):
if 'label' in item:
return '[%s] %s (%s)' % (item['quality'], item['host'], item['label'])
else:
return '[%s] %s' % (item['quality'], item['host'])
def _http_get(url, cookies=None, data=None, multipart_data=None, headers=None, allow_redirect=True, cache_limit=8):
return get_cooked_url(url, base_url, timeout, cookies=cookies, data=data, multipart_data=multipart_data,
headers=headers, allow_redirect=allow_redirect, cache_limit=cache_limit)
def get_cooked_url(url, base_url, timeout, cookies=None, data=None, multipart_data=None, headers=None, allow_redirect=True, cache_limit=8):
if cookies is None: cookies = {}
if timeout == 0: timeout = None
if headers is None: headers = {}
referer = headers['Referer'] if 'Referer' in headers else url
if kodi.get_setting('debug') == "true":
log_utils.log('Getting Url: %s cookie=|%s| data=|%s| extra headers=|%s|' % (url, cookies, data, headers))
if data is not None:
if isinstance(data, basestring):
data = data
else:
data = urllib.urlencode(data, True)
if multipart_data is not None:
headers['Content-Type'] = 'multipart/form-data; boundary=X-X-X'
data = multipart_data
try:
cj = _set_cookies(base_url, cookies)
request = urllib2.Request(url, data=data)
request.add_header('User-Agent', _get_ua())
#request.add_unredirected_header('Host', base_url)
request.add_unredirected_header('Referer', referer)
for key in headers: request.add_header(key, headers[key])
cj.add_cookie_header(request)
if not allow_redirect:
opener = urllib2.build_opener(NoRedirection)
urllib2.install_opener(opener)
else:
opener = urllib2.build_opener(urllib2.HTTPRedirectHandler)
urllib2.install_opener(opener)
opener2 = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
urllib2.install_opener(opener2)
response = urllib2.urlopen(request, timeout=timeout)
cj.extract_cookies(response, request)
if kodi.get_setting('debug') == "true":
print 'Response Cookies: %s - %s' % (url, cookies_as_str(cj))
__fix_bad_cookies()
cj.save(ignore_discard=True)
if not allow_redirect and (response.getcode() in [301, 302, 303, 307] or response.info().getheader('Refresh')):
if response.info().getheader('Refresh') is not None:
refresh = response.info().getheader('Refresh')
return refresh.split(';')[-1].split('url=')[-1]
else:
return response.info().getheader('Location')
content_length = response.info().getheader('Content-Length', 0)
if int(content_length) > MAX_RESPONSE:
print 'Response exceeded allowed size. %s => %s / %s' % (url, content_length, MAX_RESPONSE)
if response.info().get('Content-Encoding') == 'gzip':
buf = StringIO(response.read(MAX_RESPONSE))
f = gzip.GzipFile(fileobj=buf)
html = f.read()
else:
html = response.read(MAX_RESPONSE)
except urllib2.HTTPError as e:
if e.code == 503 and 'cf-browser-verification' in e.read():
print "WAS ERROR"
html = cloudflare.solve(url, cj, _get_ua())
if not html:
return ''
else:
print 'Error (%s) during THE scraper http get: %s' % (str(e), url)
return ''
except Exception as e:
print 'Error (%s) during scraper http get: %s' % (str(e), url)
return ''
return html
def get_url(url):
request=urllib2.Request(url)
request.add_header('User-Agent', 'Mozilla/5.0 (Windows NT 6.2; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1667.0 Safari/537.36')
response=urllib2.urlopen(request)
link=response.read()
cj.save(cookie_file, ignore_discard=True)
response.close()
return link
def _get_ua():
index = random.randrange(len(RAND_UAS))
user_agent = RAND_UAS[index].format(win_ver=random.choice(WIN_VERS), feature=random.choice(FEATURES), br_ver=random.choice(BR_VERS[index]))
print 'Creating New User Agent: %s' % (user_agent)
return user_agent
def _pathify_url(url):
url = url.replace('\/', '/')
pieces = urlparse.urlparse(url)
if pieces.scheme:
strip = pieces.scheme + ':'
else:
strip = ''
strip += '//' + pieces.netloc
url = url.replace(strip, '')
if not url.startswith('/'): url = '/' + url
url = url.replace('/./', '/')
print "returning pathify "+ url
return url
def _default_get_episode_url(show_url, video, episode_pattern, title_pattern='', airdate_pattern='', data=None, headers=None):
if 'http://' not in show_url:
url = urlparse.urljoin(base_url, show_url)
else:
url = base_url+show_url
html = get_url(url)
if html:
match = re.search(episode_pattern, html, re.DOTALL)
if match:
return _pathify_url(match.group(1))
else:
log_utils.log('Skipping as Episode not found: %s' % (url), log_utils.LOGDEBUG)
def make_vid_params(video_type, title, year, season, episode, ep_title, ep_airdate):
return '|%s|%s|%s|%s|%s|%s|%s|' % (video_type, title, year, season, episode, ep_title, ep_airdate)
def _set_cookies(base_url, cookies):
cj = cookielib.LWPCookieJar(cookie_file)
try: cj.load(ignore_discard=True)
except: pass
if kodi.get_setting('debug') == "true":
print 'Before Cookies: %s' % (cookies_as_str(cj))
domain = urlparse.urlsplit(base_url).hostname
for key in cookies:
c = cookielib.Cookie(0, key, str(cookies[key]), port=None, port_specified=False, domain=domain, domain_specified=True,
domain_initial_dot=False, path='/', path_specified=True, secure=False, expires=None, discard=False, comment=None,
comment_url=None, rest={})
cj.set_cookie(c)
cj.save(ignore_discard=True)
if kodi.get_setting('debug') == "true":
print 'After Cookies: %s' % (cookies_as_str(cj))
return cj
def cookies_as_str(cj):
s = ''
c = cj._cookies
for domain in c:
s += '{%s: ' % (domain)
for path in c[domain]:
s += '{%s: ' % (path)
for cookie in c[domain][path]:
s += '{%s=%s}' % (cookie, c[domain][path][cookie].value)
s += '}'
s += '} '
return s
def __fix_bad_cookies():
c = cj._cookies
for domain in c:
for path in c[domain]:
for key in c[domain][path]:
cookie = c[domain][path][key]
if cookie.expires > sys.maxint:
print 'Fixing cookie expiration for %s: was: %s now: %s' % (key, cookie.expires, sys.maxint)
cookie.expires = sys.maxint
def get_quality(video, host, base_quality=None):
host = host.lower()
# Assume movies are low quality, tv shows are high quality
if base_quality is None:
if video.video_type == "movies":
quality = QUALITIES.LOW
else:
quality = QUALITIES.HIGH
else:
quality = base_quality
host_quality = None
if host:
for key in HOST_Q:
if any(hostname in host for hostname in HOST_Q[key]):
host_quality = key
break
if host_quality is not None and Q_ORDER[host_quality] < Q_ORDER[quality]:
quality = host_quality
return quality
################ Below is custome Changes per Scraper#################
def _get_episode_url(show_url, video,season,episode):
episode_pattern = 'href="([^"]+season-%s-episode-%s-[^"]+)' % (season, episode)
title_pattern = 'href="(?P<url>[^"]+season-\d+-episode-\d+-[^"]+).*? \s+(?P<title>.*?)</td>'
return _default_get_episode_url(show_url, video, episode_pattern, title_pattern)
def search(video_type, title, year):
search_url = urlparse.urljoin(base_url, '/search/advanced_search.php?q=%s' % (urllib.quote_plus(title)))
if not year: year = 'Year'
search_url += '&year_from=%s&year_to=%s' % (year, year)
if video_type == "shows":
search_url += '§ion=2'
else:
search_url += '§ion=1'
html = _http_get(search_url, cache_limit=.25)
results = []
if not re.search('Sorry.*?find.*?looking\s+for', html, re.I):
r = re.search('Search Results For: "(.*?)</table>', html, re.DOTALL)
if r:
fragment = r.group(1)
pattern = r'<a\s+href="([^"]+)"\s+title="([^"]+)'
for match in re.finditer(pattern, fragment):
url, title_year = match.groups('')
match = re.search('(.*)\s+\((\d{4})\)', title_year)
if match:
match_title, match_year = match.groups()
else:
match_title = title_year
match_year = ''
result = {'url': _pathify_url(url), 'title': match_title, 'year': match_year}
results.append(result)
results = dict((result['url'], result) for result in results).values()
return results
def get_sources(video):
source_url = urlparse.urljoin(base_url, video)
#source_url = get_url(video)
hosters = []
if source_url and source_url != FORCE_NO_MATCH:
url = urlparse.urljoin(base_url, source_url)
html = _http_get(url, cache_limit=.5)
for match in re.finditer('<a[^>]+href="([^"]+)[^>]+>(Version \d+)<', html):
url, version = match.groups()
host = urlparse.urlsplit(url).hostname.replace('embed.', '')
hoster = {'hostname':'Putlocker','multi-part': False, 'host': host, 'quality': get_quality(video, host, QUALITIES.HIGH), 'views': None, 'rating': None, 'url': url, 'direct': False}
hoster['version'] = version
hosters.append(hoster)
return hosters
def putlocker_tv(name,movie_title):
try:
title = movie_title[:-7]
movie_year = movie_title[-6:]
year = movie_year.replace('(','').replace(')','')
video_type = 'shows'
show_url = search(video_type,title,year)
for e in show_url:
url = e['url']
newseas=re.compile('S(.+?)E(.+?) (?P<name>[A-Za-z\t .]+)').findall(name)
print newseas
for sea,epi,epi_title in newseas:
video = make_vid_params('Episode',title,year,sea,epi,epi_title,'')
ep_url = _get_episode_url(url, video,sea,epi)
hosters=get_sources(ep_url)
hosters = main_scrape.apply_urlresolver(hosters)
return hosters
except Exception as e:
hosters =[]
log_utils.log('Error [%s] %s' % (str(e), ''), xbmc.LOGERROR)
if kodi.get_setting('error_notify') == "true":
kodi.notify(header='Putlocker TV',msg='(error) %s %s' % (str(e), ''),duration=5000,sound=None)
return hosters
def putlocker_movies(movie_title):
try:
title = movie_title[:-7]
movie_year = movie_title[-6:]
year = movie_year.replace('(','').replace(')','')
video_type = 'movies'
show_url = search(video_type,title,year)
for e in show_url:
url = e['url']
hosters=get_sources(url)
print "HOSTERS ARE " + str(hosters)
hosters = main_scrape.apply_urlresolver(hosters)
return hosters
except Exception as e:
hosters =[]
log_utils.log('Error [%s] %s' % (str(e), ''), xbmc.LOGERROR)
if kodi.get_setting('error_notify') == "true":
kodi.notify(header='Putlocker Movies',msg='(error) %s %s' % (str(e), ''),duration=5000,sound=None)
return hosters
|
gpl-2.0
|
[
646,
4011,
18,
12,
4078,
12,
264,
12,
736,
199,
646,
2196,
199,
646,
7097,
199,
646,
984,
199,
646,
11709,
2718,
12,
21382,
5885,
12,
21382,
12,
11709,
9291,
12,
3224,
3422,
12,
5536,
12,
900,
199,
646,
7249,
199,
504,
20314,
492,
20817,
328,
199,
504,
7352,
63,
8450,
492,
8266,
63,
2087,
199,
504,
20314,
492,
943,
63,
1208,
199,
646,
7249,
199,
504,
20314,
492,
8002,
14163,
264,
199,
504,
20314,
492,
943,
63,
1208,
199,
504,
7352,
63,
8450,
492,
8266,
63,
2087,
199,
646,
26234,
199,
504,
5228,
492,
5228,
199,
646,
11756,
199,
646,
2446,
63,
12865,
321,
199,
646,
1300,
772,
199,
9291,
63,
344,
275,
20817,
328,
14,
9291,
63,
344,
421,
199,
2593,
275,
1109,
8,
7697,
328,
14,
362,
63,
6031,
360,
12865,
529,
63,
2593,
1333,
421,
199,
2537,
14,
981,
63,
3619,
8,
2537,
14,
33,
1938,
11695,
12,
298,
2422,
63,
967,
5635,
15,
18989,
831,
281,
531,
199,
5306,
515,
275,
11709,
14,
5275,
2042,
8,
736,
14,
515,
14,
904,
360,
6664,
921,
4219,
1673,
10788,
297,
9291,
63,
344,
2584,
2422,
63,
967,
5635,
1673,
18989,
831,
281,
15,
1333,
199,
30552,
275,
747,
14,
515,
14,
904,
8,
5306,
515,
2584,
7792,
14,
76,
14649,
358,
199,
24862,
275,
26234,
14,
20145,
48,
21315,
342,
199,
5306,
63,
493,
275,
747,
14,
515,
14,
904,
8,
5306,
515,
2584,
7792,
14,
76,
14649,
358,
4388,
199,
318,
636,
4869,
3682,
19921,
304,
272,
372,
730,
360,
5081,
297,
11969,
28441,
9,
199,
199,
4283,
63,
12801,
275,
6619,
627,
6619,
627,
499,
199,
27240,
63,
2826,
63,
14747,
275,
283,
9153,
27240,
63,
2826,
63,
14747,
9153,
7,
199,
9283,
19144,
275,
636,
4869,
8,
5896,
534,
10281,
297,
22650,
534,
26139,
297,
869,
13454,
534,
11688,
297,
869,
36,
18386,
534,
14903,
18386,
297,
869,
36,
23514,
534,
14903,
23514,
358,
421,
199,
56,
14784,
275,
791,
56,
13,
17935,
13,
3007,
356,
283,
4317,
10441,
936,
199,
3791,
63,
14565,
275,
298,
22285,
15,
21,
14,
16,
334,
6490,
12,
603,
2684,
37,
4119,
12,
5417,
23350,
1227,
14,
19,
27,
12480,
1326,
15,
23,
14,
16,
27,
4336,
26,
845,
14,
16,
9,
2839,
30506,
2,
199,
7184,
63,
17223,
275,
359,
272,
15926,
83,
14,
16,
7,
450,
284,
367,
284,
315,
4945,
8,
1085,
12,
11851,
4360,
272,
788,
1401,
14,
16,
14,
1165,
2789,
14,
8845,
297,
283,
1401,
14,
16,
14,
1165,
2789,
14,
6708,
297,
283,
1401,
14,
16,
14,
1165,
2789,
14,
7214,
297,
283,
1703,
14,
16,
14,
18,
6889,
14,
4893,
297,
283,
1703,
14,
16,
14,
18,
6889,
14,
6785,
297,
283,
1703,
14,
16,
14,
18,
6889,
14,
6673,
297,
283,
1355,
14,
16,
14,
9335,
17,
14,
3172,
297,
283,
1355,
14,
16,
14,
9335,
17,
14,
2720,
297,
283,
1355,
14,
16,
14,
9335,
17,
14,
1020,
297,
283,
2167,
14,
16,
14,
1081,
1079,
14,
3129,
297,
283,
2167,
14,
16,
14,
1081,
1079,
14,
6673,
297,
1362,
283,
2167,
14,
16,
14,
1081,
1079,
14,
7680,
297,
283,
2260,
14,
16,
14,
1789,
845,
14,
2710,
297,
283,
2260,
14,
16,
14,
1789,
845,
14,
8312,
297,
283,
2260,
14,
16,
14,
1789,
845,
14,
11024,
297,
283,
2824,
14,
16,
14,
8276,
23,
14,
2835,
297,
283,
2824,
14,
16,
14,
8276,
23,
14,
7214,
297,
283,
1602,
14,
16,
14,
1194,
1644,
14,
11520,
297,
283,
1602,
14,
16,
14,
1194,
1644,
14,
10823,
297,
283,
2322,
14,
16,
14,
1194,
1477,
14,
4893,
297,
283,
2322,
14,
16,
14,
1194,
1477,
14,
2426,
297,
283,
2466,
14,
16,
14,
1194,
2710,
14,
3172,
297,
1362,
283,
2466,
14,
16,
14,
1194,
2710,
14,
1257,
297,
283,
2466,
14,
16,
14,
1194,
2710,
14,
1184,
297,
283,
2417,
14,
16,
14,
821,
1479,
14,
2898,
297,
283,
2417,
14,
16,
14,
821,
1479,
14,
1257,
995,
272,
788,
845,
14,
16,
6538,
199,
199,
7941,
63,
17223,
275,
788,
8647,
23350,
1616,
14,
16,
297,
283,
8647,
23350,
1520,
14,
16,
297,
283,
8647,
23350,
1227,
14,
19,
297,
283,
8647,
23350,
1227,
14,
18,
297,
283,
8647,
23350,
1227,
14,
17,
297,
283,
8647,
23350,
1227,
14,
16,
297,
283,
8647,
23350,
959,
14,
17,
297,
283,
8647,
23350,
959,
14,
16,
418,
199,
13313,
275,
788,
27,
644,
19716,
772,
297,
14289,
13036,
772,
27,
473,
33,
772,
297,
14289,
13036,
772,
27,
671,
772,
297,
28696,
199,
50,
3649,
63,
53,
1179,
275,
788,
22285,
15,
21,
14,
16,
11459,
2676,
63,
422,
8847,
4445,
12084,
4336,
14534,
3289,
63,
422,
1552,
30506,
15,
1797,
4587,
614,
24584,
5321,
3289,
63,
422,
7293,
288,
283,
22285,
15,
21,
14,
16,
11459,
2676,
63,
422,
8847,
4445,
1552,
21257,
21666,
15,
24416,
14,
1344,
334,
43,
4943,
12,
2839,
30506,
9,
16776,
5321,
3289,
63,
422,
93,
428,
2756,
759,
15,
24416,
14,
1344,
297,
288,
283,
22285,
15,
21,
14,
16,
11459,
2676,
63,
422,
8847,
4445,
12084,
12480,
1326,
15,
23,
14,
16,
27,
4336,
14534,
3289,
63,
422,
1552,
2839,
30506,
418,
421,
199,
5449,
63,
49,
275,
1052,
199,
5449,
63,
49,
59,
9283,
19144,
14,
5896,
61,
275,
788,
13297,
6821,
297,
283,
452,
1662,
11418,
297,
283,
2802,
379,
14,
475,
297,
283,
2904,
382,
3783,
344,
418,
199,
5449,
63,
49,
59,
9283,
19144,
14,
9754,
2639,
61,
275,
788,
12446,
6251,
297,
283,
476,
1119,
1530,
297,
283,
7010,
1091,
83,
297,
283,
11331,
88,
297,
283,
5017,
475,
297,
283,
86,
364,
831,
281,
297,
283,
1589,
3722,
297,
283,
5017,
16079,
297,
283,
5017,
66,
979,
297,
1169,
283,
3093,
5017,
297,
283,
12712,
3722,
297,
283,
31811,
317,
1190,
297,
283,
6251,
3417,
297,
283,
90,
279,
2158,
297,
283,
493,
526,
357,
297,
283,
86,
6251,
418,
199,
5449,
63,
49,
59,
9283,
19144,
14,
17624,
61,
275,
788,
5017,
15185,
297,
283,
13118,
493,
297,
283,
3015,
88,
8614,
297,
283,
1745,
4091,
297,
283,
9273,
6251,
297,
283,
30442,
4393,
86
] |
[
4011,
18,
12,
4078,
12,
264,
12,
736,
199,
646,
2196,
199,
646,
7097,
199,
646,
984,
199,
646,
11709,
2718,
12,
21382,
5885,
12,
21382,
12,
11709,
9291,
12,
3224,
3422,
12,
5536,
12,
900,
199,
646,
7249,
199,
504,
20314,
492,
20817,
328,
199,
504,
7352,
63,
8450,
492,
8266,
63,
2087,
199,
504,
20314,
492,
943,
63,
1208,
199,
646,
7249,
199,
504,
20314,
492,
8002,
14163,
264,
199,
504,
20314,
492,
943,
63,
1208,
199,
504,
7352,
63,
8450,
492,
8266,
63,
2087,
199,
646,
26234,
199,
504,
5228,
492,
5228,
199,
646,
11756,
199,
646,
2446,
63,
12865,
321,
199,
646,
1300,
772,
199,
9291,
63,
344,
275,
20817,
328,
14,
9291,
63,
344,
421,
199,
2593,
275,
1109,
8,
7697,
328,
14,
362,
63,
6031,
360,
12865,
529,
63,
2593,
1333,
421,
199,
2537,
14,
981,
63,
3619,
8,
2537,
14,
33,
1938,
11695,
12,
298,
2422,
63,
967,
5635,
15,
18989,
831,
281,
531,
199,
5306,
515,
275,
11709,
14,
5275,
2042,
8,
736,
14,
515,
14,
904,
360,
6664,
921,
4219,
1673,
10788,
297,
9291,
63,
344,
2584,
2422,
63,
967,
5635,
1673,
18989,
831,
281,
15,
1333,
199,
30552,
275,
747,
14,
515,
14,
904,
8,
5306,
515,
2584,
7792,
14,
76,
14649,
358,
199,
24862,
275,
26234,
14,
20145,
48,
21315,
342,
199,
5306,
63,
493,
275,
747,
14,
515,
14,
904,
8,
5306,
515,
2584,
7792,
14,
76,
14649,
358,
4388,
199,
318,
636,
4869,
3682,
19921,
304,
272,
372,
730,
360,
5081,
297,
11969,
28441,
9,
199,
199,
4283,
63,
12801,
275,
6619,
627,
6619,
627,
499,
199,
27240,
63,
2826,
63,
14747,
275,
283,
9153,
27240,
63,
2826,
63,
14747,
9153,
7,
199,
9283,
19144,
275,
636,
4869,
8,
5896,
534,
10281,
297,
22650,
534,
26139,
297,
869,
13454,
534,
11688,
297,
869,
36,
18386,
534,
14903,
18386,
297,
869,
36,
23514,
534,
14903,
23514,
358,
421,
199,
56,
14784,
275,
791,
56,
13,
17935,
13,
3007,
356,
283,
4317,
10441,
936,
199,
3791,
63,
14565,
275,
298,
22285,
15,
21,
14,
16,
334,
6490,
12,
603,
2684,
37,
4119,
12,
5417,
23350,
1227,
14,
19,
27,
12480,
1326,
15,
23,
14,
16,
27,
4336,
26,
845,
14,
16,
9,
2839,
30506,
2,
199,
7184,
63,
17223,
275,
359,
272,
15926,
83,
14,
16,
7,
450,
284,
367,
284,
315,
4945,
8,
1085,
12,
11851,
4360,
272,
788,
1401,
14,
16,
14,
1165,
2789,
14,
8845,
297,
283,
1401,
14,
16,
14,
1165,
2789,
14,
6708,
297,
283,
1401,
14,
16,
14,
1165,
2789,
14,
7214,
297,
283,
1703,
14,
16,
14,
18,
6889,
14,
4893,
297,
283,
1703,
14,
16,
14,
18,
6889,
14,
6785,
297,
283,
1703,
14,
16,
14,
18,
6889,
14,
6673,
297,
283,
1355,
14,
16,
14,
9335,
17,
14,
3172,
297,
283,
1355,
14,
16,
14,
9335,
17,
14,
2720,
297,
283,
1355,
14,
16,
14,
9335,
17,
14,
1020,
297,
283,
2167,
14,
16,
14,
1081,
1079,
14,
3129,
297,
283,
2167,
14,
16,
14,
1081,
1079,
14,
6673,
297,
1362,
283,
2167,
14,
16,
14,
1081,
1079,
14,
7680,
297,
283,
2260,
14,
16,
14,
1789,
845,
14,
2710,
297,
283,
2260,
14,
16,
14,
1789,
845,
14,
8312,
297,
283,
2260,
14,
16,
14,
1789,
845,
14,
11024,
297,
283,
2824,
14,
16,
14,
8276,
23,
14,
2835,
297,
283,
2824,
14,
16,
14,
8276,
23,
14,
7214,
297,
283,
1602,
14,
16,
14,
1194,
1644,
14,
11520,
297,
283,
1602,
14,
16,
14,
1194,
1644,
14,
10823,
297,
283,
2322,
14,
16,
14,
1194,
1477,
14,
4893,
297,
283,
2322,
14,
16,
14,
1194,
1477,
14,
2426,
297,
283,
2466,
14,
16,
14,
1194,
2710,
14,
3172,
297,
1362,
283,
2466,
14,
16,
14,
1194,
2710,
14,
1257,
297,
283,
2466,
14,
16,
14,
1194,
2710,
14,
1184,
297,
283,
2417,
14,
16,
14,
821,
1479,
14,
2898,
297,
283,
2417,
14,
16,
14,
821,
1479,
14,
1257,
995,
272,
788,
845,
14,
16,
6538,
199,
199,
7941,
63,
17223,
275,
788,
8647,
23350,
1616,
14,
16,
297,
283,
8647,
23350,
1520,
14,
16,
297,
283,
8647,
23350,
1227,
14,
19,
297,
283,
8647,
23350,
1227,
14,
18,
297,
283,
8647,
23350,
1227,
14,
17,
297,
283,
8647,
23350,
1227,
14,
16,
297,
283,
8647,
23350,
959,
14,
17,
297,
283,
8647,
23350,
959,
14,
16,
418,
199,
13313,
275,
788,
27,
644,
19716,
772,
297,
14289,
13036,
772,
27,
473,
33,
772,
297,
14289,
13036,
772,
27,
671,
772,
297,
28696,
199,
50,
3649,
63,
53,
1179,
275,
788,
22285,
15,
21,
14,
16,
11459,
2676,
63,
422,
8847,
4445,
12084,
4336,
14534,
3289,
63,
422,
1552,
30506,
15,
1797,
4587,
614,
24584,
5321,
3289,
63,
422,
7293,
288,
283,
22285,
15,
21,
14,
16,
11459,
2676,
63,
422,
8847,
4445,
1552,
21257,
21666,
15,
24416,
14,
1344,
334,
43,
4943,
12,
2839,
30506,
9,
16776,
5321,
3289,
63,
422,
93,
428,
2756,
759,
15,
24416,
14,
1344,
297,
288,
283,
22285,
15,
21,
14,
16,
11459,
2676,
63,
422,
8847,
4445,
12084,
12480,
1326,
15,
23,
14,
16,
27,
4336,
14534,
3289,
63,
422,
1552,
2839,
30506,
418,
421,
199,
5449,
63,
49,
275,
1052,
199,
5449,
63,
49,
59,
9283,
19144,
14,
5896,
61,
275,
788,
13297,
6821,
297,
283,
452,
1662,
11418,
297,
283,
2802,
379,
14,
475,
297,
283,
2904,
382,
3783,
344,
418,
199,
5449,
63,
49,
59,
9283,
19144,
14,
9754,
2639,
61,
275,
788,
12446,
6251,
297,
283,
476,
1119,
1530,
297,
283,
7010,
1091,
83,
297,
283,
11331,
88,
297,
283,
5017,
475,
297,
283,
86,
364,
831,
281,
297,
283,
1589,
3722,
297,
283,
5017,
16079,
297,
283,
5017,
66,
979,
297,
1169,
283,
3093,
5017,
297,
283,
12712,
3722,
297,
283,
31811,
317,
1190,
297,
283,
6251,
3417,
297,
283,
90,
279,
2158,
297,
283,
493,
526,
357,
297,
283,
86,
6251,
418,
199,
5449,
63,
49,
59,
9283,
19144,
14,
17624,
61,
275,
788,
5017,
15185,
297,
283,
13118,
493,
297,
283,
3015,
88,
8614,
297,
283,
1745,
4091,
297,
283,
9273,
6251,
297,
283,
30442,
4393,
86,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
melodous/designate
|
designate/sqlalchemy/models.py
|
1
|
1881
|
# Copyright 2012 Hewlett-Packard Development Company, L.P.
#
# Author: Patrick Galbraith <patg@hp.com>
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from oslo.db.sqlalchemy import models
from oslo.db import exception as oslo_db_exc
from sqlalchemy import Column, DateTime
from sqlalchemy.exc import IntegrityError
from sqlalchemy.types import CHAR
from designate.openstack.common import timeutils
from designate import exceptions
class Base(models.ModelBase):
# TODO(ekarlso): Remove me when o.db patch lands for this.
def save(self, session):
"""Save this object"""
session.add(self)
try:
session.flush()
except oslo_db_exc.DBDuplicateEntry as e:
raise exceptions.Duplicate(str(e))
except IntegrityError:
raise
def delete(self, session):
session.delete(self)
session.flush()
# TODO(ekarlso): Get this into o.db?
class SoftDeleteMixin(object):
deleted = Column(CHAR(32), nullable=False, default="0", server_default="0")
deleted_at = Column(DateTime, nullable=True, default=None)
def soft_delete(self, session):
"""Mark this object as deleted."""
self.deleted = self.id.replace('-', '')
self.deleted_at = timeutils.utcnow()
if hasattr(self, 'status'):
self.status = "DELETED"
self.save(session=session)
|
apache-2.0
|
[
3,
1898,
6029,
27849,
13,
29471,
15290,
15878,
12,
491,
14,
48,
14,
199,
3,
199,
3,
6529,
26,
510,
292,
27091,
598,
279,
7828,
448,
665,
10853,
71,
32,
12025,
14,
957,
30,
199,
3,
199,
3,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
1265,
1443,
199,
3,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
2047,
1443,
3332,
199,
3,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
420,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
2428,
199,
3,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
1666,
314,
199,
3,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
4204,
199,
3,
1334,
314,
844,
14,
199,
504,
11258,
14,
697,
14,
14536,
492,
1709,
199,
504,
11258,
14,
697,
492,
1919,
465,
11258,
63,
697,
63,
2804,
199,
504,
8335,
492,
4996,
12,
13686,
199,
504,
8335,
14,
2804,
492,
26864,
199,
504,
8335,
14,
1313,
492,
8518,
199,
199,
504,
12899,
323,
14,
8512,
14,
2330,
492,
23011,
199,
504,
12899,
323,
492,
4967,
421,
199,
533,
3523,
8,
992,
14,
1685,
1563,
304,
272,
327,
3254,
8,
5711,
285,
5770,
304,
5852,
562,
1380,
312,
14,
697,
3371,
634,
5915,
367,
642,
14,
272,
347,
3354,
8,
277,
12,
2351,
304,
267,
408,
8229,
642,
909,
624,
267,
2351,
14,
525,
8,
277,
9,
398,
862,
26,
288,
2351,
14,
4939,
342,
267,
871,
11258,
63,
697,
63,
2804,
14,
2846,
14773,
3900,
465,
325,
26,
288,
746,
4967,
14,
14773,
8,
495,
8,
69,
430,
267,
871,
26864,
26,
288,
746,
339,
347,
3145,
8,
277,
12,
2351,
304,
267,
2351,
14,
1807,
8,
277,
9,
267,
2351,
14,
4939,
342,
421,
199,
3,
3254,
8,
5711,
285,
5770,
304,
2372,
642,
1901,
312,
14,
697,
31,
199,
533,
27238,
5392,
4256,
8,
785,
304,
272,
5463,
275,
4996,
8,
5901,
8,
708,
395,
7854,
29,
797,
12,
849,
628,
16,
401,
1654,
63,
885,
628,
16,
531,
272,
5463,
63,
292,
275,
4996,
8,
3926,
12,
7854,
29,
549,
12,
849,
29,
403,
9,
339,
347,
11620,
63,
1807,
8,
277,
12,
2351,
304,
267,
408,
6470,
642,
909,
465,
5463,
1041,
267,
291,
14,
6062,
275,
291,
14,
344,
14,
1814,
13858,
4074,
267,
291,
14,
6062,
63,
292,
275,
23011,
14,
10779,
342,
398,
340,
2688,
8,
277,
12,
283,
1205,
735,
288,
291,
14,
1205,
275,
298,
27408,
2,
398,
291,
14,
2117,
8,
1730,
29,
1730,
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
] |
[
1898,
6029,
27849,
13,
29471,
15290,
15878,
12,
491,
14,
48,
14,
199,
3,
199,
3,
6529,
26,
510,
292,
27091,
598,
279,
7828,
448,
665,
10853,
71,
32,
12025,
14,
957,
30,
199,
3,
199,
3,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
1265,
1443,
199,
3,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
2047,
1443,
3332,
199,
3,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
420,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
2428,
199,
3,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
1666,
314,
199,
3,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
4204,
199,
3,
1334,
314,
844,
14,
199,
504,
11258,
14,
697,
14,
14536,
492,
1709,
199,
504,
11258,
14,
697,
492,
1919,
465,
11258,
63,
697,
63,
2804,
199,
504,
8335,
492,
4996,
12,
13686,
199,
504,
8335,
14,
2804,
492,
26864,
199,
504,
8335,
14,
1313,
492,
8518,
199,
199,
504,
12899,
323,
14,
8512,
14,
2330,
492,
23011,
199,
504,
12899,
323,
492,
4967,
421,
199,
533,
3523,
8,
992,
14,
1685,
1563,
304,
272,
327,
3254,
8,
5711,
285,
5770,
304,
5852,
562,
1380,
312,
14,
697,
3371,
634,
5915,
367,
642,
14,
272,
347,
3354,
8,
277,
12,
2351,
304,
267,
408,
8229,
642,
909,
624,
267,
2351,
14,
525,
8,
277,
9,
398,
862,
26,
288,
2351,
14,
4939,
342,
267,
871,
11258,
63,
697,
63,
2804,
14,
2846,
14773,
3900,
465,
325,
26,
288,
746,
4967,
14,
14773,
8,
495,
8,
69,
430,
267,
871,
26864,
26,
288,
746,
339,
347,
3145,
8,
277,
12,
2351,
304,
267,
2351,
14,
1807,
8,
277,
9,
267,
2351,
14,
4939,
342,
421,
199,
3,
3254,
8,
5711,
285,
5770,
304,
2372,
642,
1901,
312,
14,
697,
31,
199,
533,
27238,
5392,
4256,
8,
785,
304,
272,
5463,
275,
4996,
8,
5901,
8,
708,
395,
7854,
29,
797,
12,
849,
628,
16,
401,
1654,
63,
885,
628,
16,
531,
272,
5463,
63,
292,
275,
4996,
8,
3926,
12,
7854,
29,
549,
12,
849,
29,
403,
9,
339,
347,
11620,
63,
1807,
8,
277,
12,
2351,
304,
267,
408,
6470,
642,
909,
465,
5463,
1041,
267,
291,
14,
6062,
275,
291,
14,
344,
14,
1814,
13858,
4074,
267,
291,
14,
6062,
63,
292,
275,
23011,
14,
10779,
342,
398,
340,
2688,
8,
277,
12,
283,
1205,
735,
288,
291,
14,
1205,
275,
298,
27408,
2,
398,
291,
14,
2117,
8,
1730,
29,
1730,
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,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
LiaoPan/scikit-learn
|
sklearn/cluster/tests/test_dbscan.py
|
114
|
11393
|
"""
Tests for DBSCAN clustering algorithm
"""
import pickle
import numpy as np
from scipy.spatial import distance
from scipy import sparse
from sklearn.utils.testing import assert_equal
from sklearn.utils.testing import assert_array_equal
from sklearn.utils.testing import assert_raises
from sklearn.utils.testing import assert_in
from sklearn.utils.testing import assert_not_in
from sklearn.cluster.dbscan_ import DBSCAN
from sklearn.cluster.dbscan_ import dbscan
from sklearn.cluster.tests.common import generate_clustered_data
from sklearn.metrics.pairwise import pairwise_distances
n_clusters = 3
X = generate_clustered_data(n_clusters=n_clusters)
def test_dbscan_similarity():
# Tests the DBSCAN algorithm with a similarity array.
# Parameters chosen specifically for this task.
eps = 0.15
min_samples = 10
# Compute similarities
D = distance.squareform(distance.pdist(X))
D /= np.max(D)
# Compute DBSCAN
core_samples, labels = dbscan(D, metric="precomputed", eps=eps,
min_samples=min_samples)
# number of clusters, ignoring noise if present
n_clusters_1 = len(set(labels)) - (1 if -1 in labels else 0)
assert_equal(n_clusters_1, n_clusters)
db = DBSCAN(metric="precomputed", eps=eps, min_samples=min_samples)
labels = db.fit(D).labels_
n_clusters_2 = len(set(labels)) - int(-1 in labels)
assert_equal(n_clusters_2, n_clusters)
def test_dbscan_feature():
# Tests the DBSCAN algorithm with a feature vector array.
# Parameters chosen specifically for this task.
# Different eps to other test, because distance is not normalised.
eps = 0.8
min_samples = 10
metric = 'euclidean'
# Compute DBSCAN
# parameters chosen for task
core_samples, labels = dbscan(X, metric=metric, eps=eps,
min_samples=min_samples)
# number of clusters, ignoring noise if present
n_clusters_1 = len(set(labels)) - int(-1 in labels)
assert_equal(n_clusters_1, n_clusters)
db = DBSCAN(metric=metric, eps=eps, min_samples=min_samples)
labels = db.fit(X).labels_
n_clusters_2 = len(set(labels)) - int(-1 in labels)
assert_equal(n_clusters_2, n_clusters)
def test_dbscan_sparse():
core_sparse, labels_sparse = dbscan(sparse.lil_matrix(X), eps=.8,
min_samples=10)
core_dense, labels_dense = dbscan(X, eps=.8, min_samples=10)
assert_array_equal(core_dense, core_sparse)
assert_array_equal(labels_dense, labels_sparse)
def test_dbscan_no_core_samples():
rng = np.random.RandomState(0)
X = rng.rand(40, 10)
X[X < .8] = 0
for X_ in [X, sparse.csr_matrix(X)]:
db = DBSCAN(min_samples=6).fit(X_)
assert_array_equal(db.components_, np.empty((0, X_.shape[1])))
assert_array_equal(db.labels_, -1)
assert_equal(db.core_sample_indices_.shape, (0,))
def test_dbscan_callable():
# Tests the DBSCAN algorithm with a callable metric.
# Parameters chosen specifically for this task.
# Different eps to other test, because distance is not normalised.
eps = 0.8
min_samples = 10
# metric is the function reference, not the string key.
metric = distance.euclidean
# Compute DBSCAN
# parameters chosen for task
core_samples, labels = dbscan(X, metric=metric, eps=eps,
min_samples=min_samples,
algorithm='ball_tree')
# number of clusters, ignoring noise if present
n_clusters_1 = len(set(labels)) - int(-1 in labels)
assert_equal(n_clusters_1, n_clusters)
db = DBSCAN(metric=metric, eps=eps, min_samples=min_samples,
algorithm='ball_tree')
labels = db.fit(X).labels_
n_clusters_2 = len(set(labels)) - int(-1 in labels)
assert_equal(n_clusters_2, n_clusters)
def test_dbscan_balltree():
# Tests the DBSCAN algorithm with balltree for neighbor calculation.
eps = 0.8
min_samples = 10
D = pairwise_distances(X)
core_samples, labels = dbscan(D, metric="precomputed", eps=eps,
min_samples=min_samples)
# number of clusters, ignoring noise if present
n_clusters_1 = len(set(labels)) - int(-1 in labels)
assert_equal(n_clusters_1, n_clusters)
db = DBSCAN(p=2.0, eps=eps, min_samples=min_samples, algorithm='ball_tree')
labels = db.fit(X).labels_
n_clusters_2 = len(set(labels)) - int(-1 in labels)
assert_equal(n_clusters_2, n_clusters)
db = DBSCAN(p=2.0, eps=eps, min_samples=min_samples, algorithm='kd_tree')
labels = db.fit(X).labels_
n_clusters_3 = len(set(labels)) - int(-1 in labels)
assert_equal(n_clusters_3, n_clusters)
db = DBSCAN(p=1.0, eps=eps, min_samples=min_samples, algorithm='ball_tree')
labels = db.fit(X).labels_
n_clusters_4 = len(set(labels)) - int(-1 in labels)
assert_equal(n_clusters_4, n_clusters)
db = DBSCAN(leaf_size=20, eps=eps, min_samples=min_samples,
algorithm='ball_tree')
labels = db.fit(X).labels_
n_clusters_5 = len(set(labels)) - int(-1 in labels)
assert_equal(n_clusters_5, n_clusters)
def test_input_validation():
# DBSCAN.fit should accept a list of lists.
X = [[1., 2.], [3., 4.]]
DBSCAN().fit(X) # must not raise exception
def test_dbscan_badargs():
# Test bad argument values: these should all raise ValueErrors
assert_raises(ValueError,
dbscan,
X, eps=-1.0)
assert_raises(ValueError,
dbscan,
X, algorithm='blah')
assert_raises(ValueError,
dbscan,
X, metric='blah')
assert_raises(ValueError,
dbscan,
X, leaf_size=-1)
assert_raises(ValueError,
dbscan,
X, p=-1)
def test_pickle():
obj = DBSCAN()
s = pickle.dumps(obj)
assert_equal(type(pickle.loads(s)), obj.__class__)
def test_boundaries():
# ensure min_samples is inclusive of core point
core, _ = dbscan([[0], [1]], eps=2, min_samples=2)
assert_in(0, core)
# ensure eps is inclusive of circumference
core, _ = dbscan([[0], [1], [1]], eps=1, min_samples=2)
assert_in(0, core)
core, _ = dbscan([[0], [1], [1]], eps=.99, min_samples=2)
assert_not_in(0, core)
def test_weighted_dbscan():
# ensure sample_weight is validated
assert_raises(ValueError, dbscan, [[0], [1]], sample_weight=[2])
assert_raises(ValueError, dbscan, [[0], [1]], sample_weight=[2, 3, 4])
# ensure sample_weight has an effect
assert_array_equal([], dbscan([[0], [1]], sample_weight=None,
min_samples=6)[0])
assert_array_equal([], dbscan([[0], [1]], sample_weight=[5, 5],
min_samples=6)[0])
assert_array_equal([0], dbscan([[0], [1]], sample_weight=[6, 5],
min_samples=6)[0])
assert_array_equal([0, 1], dbscan([[0], [1]], sample_weight=[6, 6],
min_samples=6)[0])
# points within eps of each other:
assert_array_equal([0, 1], dbscan([[0], [1]], eps=1.5,
sample_weight=[5, 1], min_samples=6)[0])
# and effect of non-positive and non-integer sample_weight:
assert_array_equal([], dbscan([[0], [1]], sample_weight=[5, 0],
eps=1.5, min_samples=6)[0])
assert_array_equal([0, 1], dbscan([[0], [1]], sample_weight=[5.9, 0.1],
eps=1.5, min_samples=6)[0])
assert_array_equal([0, 1], dbscan([[0], [1]], sample_weight=[6, 0],
eps=1.5, min_samples=6)[0])
assert_array_equal([], dbscan([[0], [1]], sample_weight=[6, -1],
eps=1.5, min_samples=6)[0])
# for non-negative sample_weight, cores should be identical to repetition
rng = np.random.RandomState(42)
sample_weight = rng.randint(0, 5, X.shape[0])
core1, label1 = dbscan(X, sample_weight=sample_weight)
assert_equal(len(label1), len(X))
X_repeated = np.repeat(X, sample_weight, axis=0)
core_repeated, label_repeated = dbscan(X_repeated)
core_repeated_mask = np.zeros(X_repeated.shape[0], dtype=bool)
core_repeated_mask[core_repeated] = True
core_mask = np.zeros(X.shape[0], dtype=bool)
core_mask[core1] = True
assert_array_equal(np.repeat(core_mask, sample_weight), core_repeated_mask)
# sample_weight should work with precomputed distance matrix
D = pairwise_distances(X)
core3, label3 = dbscan(D, sample_weight=sample_weight,
metric='precomputed')
assert_array_equal(core1, core3)
assert_array_equal(label1, label3)
# sample_weight should work with estimator
est = DBSCAN().fit(X, sample_weight=sample_weight)
core4 = est.core_sample_indices_
label4 = est.labels_
assert_array_equal(core1, core4)
assert_array_equal(label1, label4)
est = DBSCAN()
label5 = est.fit_predict(X, sample_weight=sample_weight)
core5 = est.core_sample_indices_
assert_array_equal(core1, core5)
assert_array_equal(label1, label5)
assert_array_equal(label1, est.labels_)
def test_dbscan_core_samples_toy():
X = [[0], [2], [3], [4], [6], [8], [10]]
n_samples = len(X)
for algorithm in ['brute', 'kd_tree', 'ball_tree']:
# Degenerate case: every sample is a core sample, either with its own
# cluster or including other close core samples.
core_samples, labels = dbscan(X, algorithm=algorithm, eps=1,
min_samples=1)
assert_array_equal(core_samples, np.arange(n_samples))
assert_array_equal(labels, [0, 1, 1, 1, 2, 3, 4])
# With eps=1 and min_samples=2 only the 3 samples from the denser area
# are core samples. All other points are isolated and considered noise.
core_samples, labels = dbscan(X, algorithm=algorithm, eps=1,
min_samples=2)
assert_array_equal(core_samples, [1, 2, 3])
assert_array_equal(labels, [-1, 0, 0, 0, -1, -1, -1])
# Only the sample in the middle of the dense area is core. Its two
# neighbors are edge samples. Remaining samples are noise.
core_samples, labels = dbscan(X, algorithm=algorithm, eps=1,
min_samples=3)
assert_array_equal(core_samples, [2])
assert_array_equal(labels, [-1, 0, 0, 0, -1, -1, -1])
# It's no longer possible to extract core samples with eps=1:
# everything is noise.
core_samples, labels = dbscan(X, algorithm=algorithm, eps=1,
min_samples=4)
assert_array_equal(core_samples, [])
assert_array_equal(labels, -np.ones(n_samples))
def test_dbscan_precomputed_metric_with_degenerate_input_arrays():
# see https://github.com/scikit-learn/scikit-learn/issues/4641 for
# more details
X = np.ones((10, 2))
labels = DBSCAN(eps=0.5, metric='precomputed').fit(X).labels_
assert_equal(len(set(labels)), 1)
X = np.zeros((10, 2))
labels = DBSCAN(eps=0.5, metric='precomputed').fit(X).labels_
assert_equal(len(set(labels)), 1)
|
bsd-3-clause
|
[
624,
199,
2925,
367,
6249,
24078,
19454,
5563,
199,
624,
199,
199,
646,
5927,
199,
199,
646,
2680,
465,
980,
199,
199,
504,
7026,
14,
11679,
492,
6033,
199,
504,
7026,
492,
5178,
199,
199,
504,
6357,
14,
1208,
14,
4776,
492,
702,
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,
262,
199,
504,
6357,
14,
1208,
14,
4776,
492,
702,
63,
1397,
63,
262,
199,
504,
6357,
14,
4201,
14,
697,
6282,
63,
492,
6249,
24078,
199,
504,
6357,
14,
4201,
14,
697,
6282,
63,
492,
1592,
6282,
199,
504,
6357,
14,
4201,
14,
2219,
14,
2330,
492,
3550,
63,
429,
527,
3014,
63,
576,
199,
504,
6357,
14,
6759,
14,
25069,
492,
24859,
63,
15482,
421,
199,
78,
63,
9170,
275,
650,
199,
56,
275,
3550,
63,
429,
527,
3014,
63,
576,
8,
78,
63,
9170,
29,
78,
63,
9170,
9,
421,
199,
318,
511,
63,
697,
6282,
63,
21965,
837,
272,
327,
6496,
314,
6249,
24078,
5563,
543,
282,
22838,
1625,
14,
272,
327,
3897,
12414,
22543,
367,
642,
2120,
14,
272,
10245,
275,
378,
14,
1046,
272,
1748,
63,
3356,
275,
1616,
272,
327,
8354,
4389,
382,
27894,
272,
577,
275,
6033,
14,
9646,
964,
8,
5590,
14,
29528,
8,
56,
430,
272,
577,
12257,
980,
14,
988,
8,
36,
9,
272,
327,
8354,
6249,
24078,
272,
6170,
63,
3356,
12,
3628,
275,
1592,
6282,
8,
36,
12,
6370,
628,
26596,
401,
10245,
29,
8277,
12,
3303,
1748,
63,
3356,
29,
827,
63,
3356,
9,
272,
327,
1329,
402,
13865,
12,
17289,
11145,
340,
3451,
272,
302,
63,
9170,
63,
17,
275,
822,
8,
409,
8,
3512,
430,
446,
334,
17,
340,
446,
17,
315,
3628,
587,
378,
9,
339,
702,
63,
1452,
8,
78,
63,
9170,
63,
17,
12,
302,
63,
9170,
9,
339,
1592,
275,
6249,
24078,
8,
5165,
628,
26596,
401,
10245,
29,
8277,
12,
1748,
63,
3356,
29,
827,
63,
3356,
9,
272,
3628,
275,
1592,
14,
3269,
8,
36,
680,
3512,
63,
339,
302,
63,
9170,
63,
18,
275,
822,
8,
409,
8,
3512,
430,
446,
1109,
2801,
17,
315,
3628,
9,
272,
702,
63,
1452,
8,
78,
63,
9170,
63,
18,
12,
302,
63,
9170,
9,
421,
199,
318,
511,
63,
697,
6282,
63,
4445,
837,
272,
327,
6496,
314,
6249,
24078,
5563,
543,
282,
3878,
5477,
1625,
14,
272,
327,
3897,
12414,
22543,
367,
642,
2120,
14,
272,
327,
18029,
640,
10245,
370,
1163,
511,
12,
2952,
6033,
365,
440,
3293,
9096,
14,
272,
10245,
275,
378,
14,
24,
272,
1748,
63,
3356,
275,
1616,
272,
6370,
275,
283,
26479,
7,
272,
327,
8354,
6249,
24078,
272,
327,
2633,
12414,
367,
2120,
272,
6170,
63,
3356,
12,
3628,
275,
1592,
6282,
8,
56,
12,
6370,
29,
5165,
12,
10245,
29,
8277,
12,
3303,
1748,
63,
3356,
29,
827,
63,
3356,
9,
339,
327,
1329,
402,
13865,
12,
17289,
11145,
340,
3451,
272,
302,
63,
9170,
63,
17,
275,
822,
8,
409,
8,
3512,
430,
446,
1109,
2801,
17,
315,
3628,
9,
272,
702,
63,
1452,
8,
78,
63,
9170,
63,
17,
12,
302,
63,
9170,
9,
339,
1592,
275,
6249,
24078,
8,
5165,
29,
5165,
12,
10245,
29,
8277,
12,
1748,
63,
3356,
29,
827,
63,
3356,
9,
272,
3628,
275,
1592,
14,
3269,
8,
56,
680,
3512,
63,
339,
302,
63,
9170,
63,
18,
275,
822,
8,
409,
8,
3512,
430,
446,
1109,
2801,
17,
315,
3628,
9,
272,
702,
63,
1452,
8,
78,
63,
9170,
63,
18,
12,
302,
63,
9170,
9,
421,
199,
318,
511,
63,
697,
6282,
63,
4421,
837,
272,
6170,
63,
4421,
12,
3628,
63,
4421,
275,
1592,
6282,
8,
4421,
14,
317,
76,
63,
3642,
8,
56,
395,
10245,
15856,
24,
12,
3147,
1748,
63,
3356,
29,
709,
9,
272,
6170,
63,
7253,
12,
3628,
63,
7253,
275,
1592,
6282,
8,
56,
12,
10245,
15856,
24,
12,
1748,
63,
3356,
29,
709,
9,
272,
702,
63,
1144,
63,
1452,
8,
1018,
63,
7253,
12,
6170,
63,
4421,
9,
272,
702,
63,
1144,
63,
1452,
8,
3512,
63,
7253,
12,
3628,
63,
4421,
9,
421,
199,
318,
511,
63,
697,
6282,
63,
889,
63,
1018,
63,
3356,
837,
272,
9038,
275,
980,
14,
2355,
14,
15726,
8,
16,
9,
272,
1323,
275,
9038,
14,
3759,
8,
2167,
12,
1616,
9,
272,
1323,
59,
56,
665,
1275,
24,
61,
275,
378,
339,
367,
1323,
63,
315,
359,
56,
12,
5178,
14,
10101,
63,
3642,
8,
56,
19532,
267,
1592,
275,
6249,
24078,
8,
827,
63,
3356,
29,
22,
680,
3269,
8,
56,
4602,
267,
702,
63,
1144,
63,
1452,
8,
697,
14,
4608,
3131,
980,
14,
1667,
1332,
16,
12,
1323,
3754,
1392,
59,
17,
11845,
267,
702,
63,
1144,
63,
1452,
8,
697,
14,
3512,
3131,
446,
17,
9,
267,
702,
63,
1452,
8,
697,
14,
1018,
63,
3271,
63,
4108,
3754,
1392,
12,
334,
16,
4641,
421,
199,
318,
511,
63,
697,
6282,
63,
8296,
837,
272,
327,
6496,
314,
6249,
24078,
5563,
543,
282,
4550,
6370,
14,
272,
327,
3897,
12414,
22543,
367,
642,
2120,
14,
272,
327,
18029,
640,
10245,
370,
1163,
511,
12,
2952,
6033,
365,
440,
3293,
9096,
14,
272,
10245,
275,
378,
14,
24,
272,
1748,
63,
3356,
275,
1616,
272,
327,
6370,
365,
314,
805,
3659,
12,
440,
314,
1059,
790,
14,
272,
6370,
275,
6033,
14,
26479,
272,
327,
8354,
6249,
24078,
272,
327,
2633,
12414,
367,
2120,
272,
6170,
63,
3356,
12,
3628,
275,
1592,
6282,
8,
56,
12,
6370,
29,
5165,
12,
10245,
29,
8277,
12,
3303,
1748,
63,
3356,
29,
827,
63,
3356,
12,
3303,
5563,
534,
8571,
63,
2350,
358,
339,
327,
1329,
402,
13865,
12,
17289,
11145,
340,
3451,
272,
302,
63,
9170,
63,
17,
275,
822,
8,
409,
8,
3512,
430,
446,
1109,
2801,
17,
315,
3628,
9,
272,
702,
63,
1452,
8,
78,
63,
9170,
63,
17,
12,
302,
63,
9170,
9,
339,
1592,
275,
6249,
24078,
8,
5165,
29,
5165,
12,
10245,
29
] |
[
199,
2925,
367,
6249,
24078,
19454,
5563,
199,
624,
199,
199,
646,
5927,
199,
199,
646,
2680,
465,
980,
199,
199,
504,
7026,
14,
11679,
492,
6033,
199,
504,
7026,
492,
5178,
199,
199,
504,
6357,
14,
1208,
14,
4776,
492,
702,
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,
262,
199,
504,
6357,
14,
1208,
14,
4776,
492,
702,
63,
1397,
63,
262,
199,
504,
6357,
14,
4201,
14,
697,
6282,
63,
492,
6249,
24078,
199,
504,
6357,
14,
4201,
14,
697,
6282,
63,
492,
1592,
6282,
199,
504,
6357,
14,
4201,
14,
2219,
14,
2330,
492,
3550,
63,
429,
527,
3014,
63,
576,
199,
504,
6357,
14,
6759,
14,
25069,
492,
24859,
63,
15482,
421,
199,
78,
63,
9170,
275,
650,
199,
56,
275,
3550,
63,
429,
527,
3014,
63,
576,
8,
78,
63,
9170,
29,
78,
63,
9170,
9,
421,
199,
318,
511,
63,
697,
6282,
63,
21965,
837,
272,
327,
6496,
314,
6249,
24078,
5563,
543,
282,
22838,
1625,
14,
272,
327,
3897,
12414,
22543,
367,
642,
2120,
14,
272,
10245,
275,
378,
14,
1046,
272,
1748,
63,
3356,
275,
1616,
272,
327,
8354,
4389,
382,
27894,
272,
577,
275,
6033,
14,
9646,
964,
8,
5590,
14,
29528,
8,
56,
430,
272,
577,
12257,
980,
14,
988,
8,
36,
9,
272,
327,
8354,
6249,
24078,
272,
6170,
63,
3356,
12,
3628,
275,
1592,
6282,
8,
36,
12,
6370,
628,
26596,
401,
10245,
29,
8277,
12,
3303,
1748,
63,
3356,
29,
827,
63,
3356,
9,
272,
327,
1329,
402,
13865,
12,
17289,
11145,
340,
3451,
272,
302,
63,
9170,
63,
17,
275,
822,
8,
409,
8,
3512,
430,
446,
334,
17,
340,
446,
17,
315,
3628,
587,
378,
9,
339,
702,
63,
1452,
8,
78,
63,
9170,
63,
17,
12,
302,
63,
9170,
9,
339,
1592,
275,
6249,
24078,
8,
5165,
628,
26596,
401,
10245,
29,
8277,
12,
1748,
63,
3356,
29,
827,
63,
3356,
9,
272,
3628,
275,
1592,
14,
3269,
8,
36,
680,
3512,
63,
339,
302,
63,
9170,
63,
18,
275,
822,
8,
409,
8,
3512,
430,
446,
1109,
2801,
17,
315,
3628,
9,
272,
702,
63,
1452,
8,
78,
63,
9170,
63,
18,
12,
302,
63,
9170,
9,
421,
199,
318,
511,
63,
697,
6282,
63,
4445,
837,
272,
327,
6496,
314,
6249,
24078,
5563,
543,
282,
3878,
5477,
1625,
14,
272,
327,
3897,
12414,
22543,
367,
642,
2120,
14,
272,
327,
18029,
640,
10245,
370,
1163,
511,
12,
2952,
6033,
365,
440,
3293,
9096,
14,
272,
10245,
275,
378,
14,
24,
272,
1748,
63,
3356,
275,
1616,
272,
6370,
275,
283,
26479,
7,
272,
327,
8354,
6249,
24078,
272,
327,
2633,
12414,
367,
2120,
272,
6170,
63,
3356,
12,
3628,
275,
1592,
6282,
8,
56,
12,
6370,
29,
5165,
12,
10245,
29,
8277,
12,
3303,
1748,
63,
3356,
29,
827,
63,
3356,
9,
339,
327,
1329,
402,
13865,
12,
17289,
11145,
340,
3451,
272,
302,
63,
9170,
63,
17,
275,
822,
8,
409,
8,
3512,
430,
446,
1109,
2801,
17,
315,
3628,
9,
272,
702,
63,
1452,
8,
78,
63,
9170,
63,
17,
12,
302,
63,
9170,
9,
339,
1592,
275,
6249,
24078,
8,
5165,
29,
5165,
12,
10245,
29,
8277,
12,
1748,
63,
3356,
29,
827,
63,
3356,
9,
272,
3628,
275,
1592,
14,
3269,
8,
56,
680,
3512,
63,
339,
302,
63,
9170,
63,
18,
275,
822,
8,
409,
8,
3512,
430,
446,
1109,
2801,
17,
315,
3628,
9,
272,
702,
63,
1452,
8,
78,
63,
9170,
63,
18,
12,
302,
63,
9170,
9,
421,
199,
318,
511,
63,
697,
6282,
63,
4421,
837,
272,
6170,
63,
4421,
12,
3628,
63,
4421,
275,
1592,
6282,
8,
4421,
14,
317,
76,
63,
3642,
8,
56,
395,
10245,
15856,
24,
12,
3147,
1748,
63,
3356,
29,
709,
9,
272,
6170,
63,
7253,
12,
3628,
63,
7253,
275,
1592,
6282,
8,
56,
12,
10245,
15856,
24,
12,
1748,
63,
3356,
29,
709,
9,
272,
702,
63,
1144,
63,
1452,
8,
1018,
63,
7253,
12,
6170,
63,
4421,
9,
272,
702,
63,
1144,
63,
1452,
8,
3512,
63,
7253,
12,
3628,
63,
4421,
9,
421,
199,
318,
511,
63,
697,
6282,
63,
889,
63,
1018,
63,
3356,
837,
272,
9038,
275,
980,
14,
2355,
14,
15726,
8,
16,
9,
272,
1323,
275,
9038,
14,
3759,
8,
2167,
12,
1616,
9,
272,
1323,
59,
56,
665,
1275,
24,
61,
275,
378,
339,
367,
1323,
63,
315,
359,
56,
12,
5178,
14,
10101,
63,
3642,
8,
56,
19532,
267,
1592,
275,
6249,
24078,
8,
827,
63,
3356,
29,
22,
680,
3269,
8,
56,
4602,
267,
702,
63,
1144,
63,
1452,
8,
697,
14,
4608,
3131,
980,
14,
1667,
1332,
16,
12,
1323,
3754,
1392,
59,
17,
11845,
267,
702,
63,
1144,
63,
1452,
8,
697,
14,
3512,
3131,
446,
17,
9,
267,
702,
63,
1452,
8,
697,
14,
1018,
63,
3271,
63,
4108,
3754,
1392,
12,
334,
16,
4641,
421,
199,
318,
511,
63,
697,
6282,
63,
8296,
837,
272,
327,
6496,
314,
6249,
24078,
5563,
543,
282,
4550,
6370,
14,
272,
327,
3897,
12414,
22543,
367,
642,
2120,
14,
272,
327,
18029,
640,
10245,
370,
1163,
511,
12,
2952,
6033,
365,
440,
3293,
9096,
14,
272,
10245,
275,
378,
14,
24,
272,
1748,
63,
3356,
275,
1616,
272,
327,
6370,
365,
314,
805,
3659,
12,
440,
314,
1059,
790,
14,
272,
6370,
275,
6033,
14,
26479,
272,
327,
8354,
6249,
24078,
272,
327,
2633,
12414,
367,
2120,
272,
6170,
63,
3356,
12,
3628,
275,
1592,
6282,
8,
56,
12,
6370,
29,
5165,
12,
10245,
29,
8277,
12,
3303,
1748,
63,
3356,
29,
827,
63,
3356,
12,
3303,
5563,
534,
8571,
63,
2350,
358,
339,
327,
1329,
402,
13865,
12,
17289,
11145,
340,
3451,
272,
302,
63,
9170,
63,
17,
275,
822,
8,
409,
8,
3512,
430,
446,
1109,
2801,
17,
315,
3628,
9,
272,
702,
63,
1452,
8,
78,
63,
9170,
63,
17,
12,
302,
63,
9170,
9,
339,
1592,
275,
6249,
24078,
8,
5165,
29,
5165,
12,
10245,
29,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
ShassAro/ShassAro
|
Bl_project/blVirtualEnv/lib/python2.7/site-packages/pip/_vendor/requests/packages/chardet/universaldetector.py
|
744
|
6831
|
######################## BEGIN LICENSE BLOCK ########################
# The Original Code is Mozilla Universal charset detector code.
#
# The Initial Developer of the Original Code is
# Netscape Communications Corporation.
# Portions created by the Initial Developer are Copyright (C) 2001
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
# Mark Pilgrim - port to Python
# Shy Shalom - original C code
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
# 02110-1301 USA
######################### END LICENSE BLOCK #########################
from . import constants
import sys
import codecs
from .latin1prober import Latin1Prober # windows-1252
from .mbcsgroupprober import MBCSGroupProber # multi-byte character sets
from .sbcsgroupprober import SBCSGroupProber # single-byte character sets
from .escprober import EscCharSetProber # ISO-2122, etc.
import re
MINIMUM_THRESHOLD = 0.20
ePureAscii = 0
eEscAscii = 1
eHighbyte = 2
class UniversalDetector:
def __init__(self):
self._highBitDetector = re.compile(b'[\x80-\xFF]')
self._escDetector = re.compile(b'(\033|~{)')
self._mEscCharSetProber = None
self._mCharSetProbers = []
self.reset()
def reset(self):
self.result = {'encoding': None, 'confidence': 0.0}
self.done = False
self._mStart = True
self._mGotData = False
self._mInputState = ePureAscii
self._mLastChar = b''
if self._mEscCharSetProber:
self._mEscCharSetProber.reset()
for prober in self._mCharSetProbers:
prober.reset()
def feed(self, aBuf):
if self.done:
return
aLen = len(aBuf)
if not aLen:
return
if not self._mGotData:
# If the data starts with BOM, we know it is UTF
if aBuf[:3] == codecs.BOM:
# EF BB BF UTF-8 with BOM
self.result = {'encoding': "UTF-8", 'confidence': 1.0}
elif aBuf[:4] == codecs.BOM_UTF32_LE:
# FF FE 00 00 UTF-32, little-endian BOM
self.result = {'encoding': "UTF-32LE", 'confidence': 1.0}
elif aBuf[:4] == codecs.BOM_UTF32_BE:
# 00 00 FE FF UTF-32, big-endian BOM
self.result = {'encoding': "UTF-32BE", 'confidence': 1.0}
elif aBuf[:4] == b'\xFE\xFF\x00\x00':
# FE FF 00 00 UCS-4, unusual octet order BOM (3412)
self.result = {
'encoding': "X-ISO-10646-UCS-4-3412",
'confidence': 1.0
}
elif aBuf[:4] == b'\x00\x00\xFF\xFE':
# 00 00 FF FE UCS-4, unusual octet order BOM (2143)
self.result = {
'encoding': "X-ISO-10646-UCS-4-2143",
'confidence': 1.0
}
elif aBuf[:2] == codecs.BOM_LE:
# FF FE UTF-16, little endian BOM
self.result = {'encoding': "UTF-16LE", 'confidence': 1.0}
elif aBuf[:2] == codecs.BOM_BE:
# FE FF UTF-16, big endian BOM
self.result = {'encoding': "UTF-16BE", 'confidence': 1.0}
self._mGotData = True
if self.result['encoding'] and (self.result['confidence'] > 0.0):
self.done = True
return
if self._mInputState == ePureAscii:
if self._highBitDetector.search(aBuf):
self._mInputState = eHighbyte
elif ((self._mInputState == ePureAscii) and
self._escDetector.search(self._mLastChar + aBuf)):
self._mInputState = eEscAscii
self._mLastChar = aBuf[-1:]
if self._mInputState == eEscAscii:
if not self._mEscCharSetProber:
self._mEscCharSetProber = EscCharSetProber()
if self._mEscCharSetProber.feed(aBuf) == constants.eFoundIt:
self.result = {'encoding': self._mEscCharSetProber.get_charset_name(),
'confidence': self._mEscCharSetProber.get_confidence()}
self.done = True
elif self._mInputState == eHighbyte:
if not self._mCharSetProbers:
self._mCharSetProbers = [MBCSGroupProber(), SBCSGroupProber(),
Latin1Prober()]
for prober in self._mCharSetProbers:
if prober.feed(aBuf) == constants.eFoundIt:
self.result = {'encoding': prober.get_charset_name(),
'confidence': prober.get_confidence()}
self.done = True
break
def close(self):
if self.done:
return
if not self._mGotData:
if constants._debug:
sys.stderr.write('no data received!\n')
return
self.done = True
if self._mInputState == ePureAscii:
self.result = {'encoding': 'ascii', 'confidence': 1.0}
return self.result
if self._mInputState == eHighbyte:
proberConfidence = None
maxProberConfidence = 0.0
maxProber = None
for prober in self._mCharSetProbers:
if not prober:
continue
proberConfidence = prober.get_confidence()
if proberConfidence > maxProberConfidence:
maxProberConfidence = proberConfidence
maxProber = prober
if maxProber and (maxProberConfidence > MINIMUM_THRESHOLD):
self.result = {'encoding': maxProber.get_charset_name(),
'confidence': maxProber.get_confidence()}
return self.result
if constants._debug:
sys.stderr.write('no probers hit minimum threshhold\n')
for prober in self._mCharSetProbers[0].mProbers:
if not prober:
continue
sys.stderr.write('%s confidence = %s\n' %
(prober.get_charset_name(),
prober.get_confidence()))
|
gpl-2.0
|
[
6565,
16427,
5113,
8068,
11945,
199,
3,
710,
12769,
5495,
365,
17728,
29347,
5960,
17842,
1233,
14,
199,
3,
199,
3,
710,
6026,
9607,
402,
314,
12769,
5495,
365,
199,
3,
20433,
18686,
11098,
14,
199,
3,
20825,
2737,
701,
314,
6026,
9607,
787,
1898,
334,
35,
9,
12521,
199,
3,
314,
6026,
9607,
14,
2900,
5924,
5702,
14,
199,
3,
199,
3,
17636,
8,
83,
304,
199,
3,
257,
7173,
19641,
446,
1844,
370,
2018,
199,
3,
257,
428,
3577,
5244,
279,
676,
446,
3379,
445,
1233,
199,
3,
199,
3,
961,
3555,
365,
2867,
2032,
27,
1265,
883,
3604,
652,
436,
15,
269,
199,
3,
2811,
652,
1334,
314,
2895,
402,
314,
1664,
6401,
1696,
1684,
199,
3,
844,
465,
3267,
701,
314,
2868,
2290,
2752,
27,
1902,
199,
3,
1015,
499,
14,
17,
402,
314,
844,
12,
503,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
961,
3555,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
1664,
199,
3,
6401,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
6401,
1696,
1684,
199,
3,
844,
3180,
543,
642,
3555,
27,
340,
440,
12,
2218,
370,
314,
2868,
2290,
199,
3,
2752,
12,
3277,
2020,
8026,
11236,
1933,
12,
12066,
11844,
12,
8226,
12,
4828,
199,
3,
11315,
13,
10067,
221,
8217,
199,
19054,
7729,
5113,
8068,
21186,
199,
199,
504,
1275,
492,
5262,
199,
646,
984,
199,
646,
6010,
199,
504,
1275,
10378,
17,
19903,
492,
23864,
17,
8029,
221,
327,
10061,
13,
19364,
199,
504,
1275,
887,
1259,
923,
19903,
492,
19487,
3298,
2448,
8029,
221,
327,
3510,
13,
4414,
4528,
5951,
199,
504,
1275,
9264,
1259,
923,
19903,
492,
26811,
3298,
2448,
8029,
221,
327,
2849,
13,
4414,
4528,
5951,
199,
504,
1275,
19303,
19903,
492,
662,
551,
15159,
221,
327,
9055,
13,
18,
7507,
12,
5423,
14,
199,
646,
295,
199,
199,
4896,
27078,
63,
19307,
275,
378,
14,
1165,
199,
69,
28928,
11129,
275,
378,
199,
20565,
551,
11129,
275,
413,
199,
69,
11688,
4414,
275,
499,
421,
199,
533,
29347,
24402,
26,
272,
347,
636,
826,
721,
277,
304,
267,
291,
423,
6260,
4734,
24402,
275,
295,
14,
2014,
8,
66,
22123,
88,
1257,
2696,
9039,
10374,
267,
291,
423,
19303,
24402,
275,
295,
14,
2014,
8,
66,
13445,
8762,
92,
94,
91,
5942,
267,
291,
423,
77,
37,
551,
15159,
275,
488,
267,
291,
423,
77,
15159,
83,
275,
942,
267,
291,
14,
3958,
342,
339,
347,
5305,
8,
277,
304,
267,
291,
14,
1099,
275,
791,
2991,
356,
488,
12,
283,
13969,
356,
378,
14,
16,
93,
267,
291,
14,
4456,
275,
756,
267,
291,
423,
77,
3162,
275,
715,
267,
291,
423,
77,
13662,
1451,
275,
756,
267,
291,
423,
77,
3205,
2223,
275,
325,
28928,
11129,
267,
291,
423,
30875,
275,
330,
891,
267,
340,
291,
423,
77,
37,
551,
15159,
26,
288,
291,
423,
77,
37,
551,
15159,
14,
3958,
342,
267,
367,
16118,
315,
291,
423,
77,
15159,
83,
26,
288,
16118,
14,
3958,
342,
339,
347,
4733,
8,
277,
12,
17407,
304,
267,
340,
291,
14,
4456,
26,
288,
372,
398,
282,
3166,
275,
822,
8,
22353,
9,
267,
340,
440,
282,
3166,
26,
288,
372,
398,
340,
440,
291,
423,
77,
13662,
1451,
26,
288,
327,
982,
314,
666,
9174,
543,
17720,
12,
781,
5715,
652,
365,
9094,
288,
340,
17407,
1491,
19,
61,
508,
6010,
14,
19550,
26,
355,
327,
662,
38,
699,
34,
699,
38,
221,
9094,
13,
24,
543,
17720,
355,
291,
14,
1099,
275,
791,
2991,
356,
298,
6610,
13,
24,
401,
283,
13969,
356,
413,
14,
16,
93,
288,
916,
17407,
1491,
20,
61,
508,
6010,
14,
19550,
63,
6610,
708,
63,
906,
26,
355,
327,
25046,
16012,
8733,
8733,
221,
9094,
13,
708,
12,
12050,
13,
15009,
17720,
355,
291,
14,
1099,
275,
791,
2991,
356,
298,
6610,
13,
708,
906,
401,
283,
13969,
356,
413,
14,
16,
93,
288,
916,
17407,
1491,
20,
61,
508,
6010,
14,
19550,
63,
6610,
708,
63,
6773,
26,
355,
327,
8733,
8733,
16012,
25046,
221,
9094,
13,
708,
12,
7282,
13,
15009,
17720,
355,
291,
14,
1099,
275,
791,
2991,
356,
298,
6610,
13,
708,
6773,
401,
283,
13969,
356,
413,
14,
16,
93,
288,
916,
17407,
1491,
20,
61,
508,
330,
1154,
20981,
60,
9039,
60,
88,
383,
60,
88,
383,
356,
355,
327,
16012,
25046,
8733,
8733,
221,
21884,
13,
20,
12,
625,
527,
1061,
30974,
1865,
17720,
334,
1082,
713,
9,
355,
291,
14,
1099,
275,
469,
490,
283,
2991,
356,
298,
56,
13,
7336,
13,
709,
11387,
13,
21269,
13,
20,
13,
1082,
713,
401,
490,
283,
13969,
356,
413,
14,
16,
355,
789,
288,
916,
17407,
1491,
20,
61,
508,
330,
1154,
88,
383,
60,
88,
383,
60,
9039,
60,
20981,
356,
355,
327,
8733,
8733,
25046,
16012,
221,
21884,
13,
20,
12,
625,
527,
1061,
30974,
1865,
17720,
334,
6886,
19,
9,
355,
291,
14,
1099,
275,
469,
490,
283,
2991,
356,
298,
56,
13,
7336,
13,
709,
11387,
13,
21269,
13,
20,
13,
6886,
19,
401,
490,
283,
13969,
356,
413,
14,
16,
355,
789,
288,
916,
17407,
1491,
18,
61,
508,
6010,
14,
19550,
63,
906,
26,
355,
327,
25046,
16012,
221,
9094,
13,
975,
12,
12050,
17638,
17720,
355,
291,
14,
1099,
275,
791,
2991,
356,
298,
6610,
13,
975,
906,
401,
283,
13969,
356,
413,
14,
16,
93,
288,
916,
17407,
1491,
18,
61,
508,
6010,
14,
19550,
63,
6773,
26,
355,
327,
16012,
25046,
221,
9094,
13,
975,
12,
7282,
17638,
17720,
355,
291,
14,
1099,
275,
791,
2991,
356,
298,
6610,
13,
975,
6773,
401,
283,
13969,
356,
413,
14,
16,
93,
398,
291,
423,
77,
13662,
1451,
275,
715,
267,
340,
291,
14,
1099,
459,
2991,
418,
436,
334,
277,
14,
1099,
459,
13969,
418,
690,
378,
14,
16,
304,
288,
291,
14,
4456,
275,
715,
288
] |
[
16427,
5113,
8068,
11945,
199,
3,
710,
12769,
5495,
365,
17728,
29347,
5960,
17842,
1233,
14,
199,
3,
199,
3,
710,
6026,
9607,
402,
314,
12769,
5495,
365,
199,
3,
20433,
18686,
11098,
14,
199,
3,
20825,
2737,
701,
314,
6026,
9607,
787,
1898,
334,
35,
9,
12521,
199,
3,
314,
6026,
9607,
14,
2900,
5924,
5702,
14,
199,
3,
199,
3,
17636,
8,
83,
304,
199,
3,
257,
7173,
19641,
446,
1844,
370,
2018,
199,
3,
257,
428,
3577,
5244,
279,
676,
446,
3379,
445,
1233,
199,
3,
199,
3,
961,
3555,
365,
2867,
2032,
27,
1265,
883,
3604,
652,
436,
15,
269,
199,
3,
2811,
652,
1334,
314,
2895,
402,
314,
1664,
6401,
1696,
1684,
199,
3,
844,
465,
3267,
701,
314,
2868,
2290,
2752,
27,
1902,
199,
3,
1015,
499,
14,
17,
402,
314,
844,
12,
503,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
961,
3555,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
1664,
199,
3,
6401,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
6401,
1696,
1684,
199,
3,
844,
3180,
543,
642,
3555,
27,
340,
440,
12,
2218,
370,
314,
2868,
2290,
199,
3,
2752,
12,
3277,
2020,
8026,
11236,
1933,
12,
12066,
11844,
12,
8226,
12,
4828,
199,
3,
11315,
13,
10067,
221,
8217,
199,
19054,
7729,
5113,
8068,
21186,
199,
199,
504,
1275,
492,
5262,
199,
646,
984,
199,
646,
6010,
199,
504,
1275,
10378,
17,
19903,
492,
23864,
17,
8029,
221,
327,
10061,
13,
19364,
199,
504,
1275,
887,
1259,
923,
19903,
492,
19487,
3298,
2448,
8029,
221,
327,
3510,
13,
4414,
4528,
5951,
199,
504,
1275,
9264,
1259,
923,
19903,
492,
26811,
3298,
2448,
8029,
221,
327,
2849,
13,
4414,
4528,
5951,
199,
504,
1275,
19303,
19903,
492,
662,
551,
15159,
221,
327,
9055,
13,
18,
7507,
12,
5423,
14,
199,
646,
295,
199,
199,
4896,
27078,
63,
19307,
275,
378,
14,
1165,
199,
69,
28928,
11129,
275,
378,
199,
20565,
551,
11129,
275,
413,
199,
69,
11688,
4414,
275,
499,
421,
199,
533,
29347,
24402,
26,
272,
347,
636,
826,
721,
277,
304,
267,
291,
423,
6260,
4734,
24402,
275,
295,
14,
2014,
8,
66,
22123,
88,
1257,
2696,
9039,
10374,
267,
291,
423,
19303,
24402,
275,
295,
14,
2014,
8,
66,
13445,
8762,
92,
94,
91,
5942,
267,
291,
423,
77,
37,
551,
15159,
275,
488,
267,
291,
423,
77,
15159,
83,
275,
942,
267,
291,
14,
3958,
342,
339,
347,
5305,
8,
277,
304,
267,
291,
14,
1099,
275,
791,
2991,
356,
488,
12,
283,
13969,
356,
378,
14,
16,
93,
267,
291,
14,
4456,
275,
756,
267,
291,
423,
77,
3162,
275,
715,
267,
291,
423,
77,
13662,
1451,
275,
756,
267,
291,
423,
77,
3205,
2223,
275,
325,
28928,
11129,
267,
291,
423,
30875,
275,
330,
891,
267,
340,
291,
423,
77,
37,
551,
15159,
26,
288,
291,
423,
77,
37,
551,
15159,
14,
3958,
342,
267,
367,
16118,
315,
291,
423,
77,
15159,
83,
26,
288,
16118,
14,
3958,
342,
339,
347,
4733,
8,
277,
12,
17407,
304,
267,
340,
291,
14,
4456,
26,
288,
372,
398,
282,
3166,
275,
822,
8,
22353,
9,
267,
340,
440,
282,
3166,
26,
288,
372,
398,
340,
440,
291,
423,
77,
13662,
1451,
26,
288,
327,
982,
314,
666,
9174,
543,
17720,
12,
781,
5715,
652,
365,
9094,
288,
340,
17407,
1491,
19,
61,
508,
6010,
14,
19550,
26,
355,
327,
662,
38,
699,
34,
699,
38,
221,
9094,
13,
24,
543,
17720,
355,
291,
14,
1099,
275,
791,
2991,
356,
298,
6610,
13,
24,
401,
283,
13969,
356,
413,
14,
16,
93,
288,
916,
17407,
1491,
20,
61,
508,
6010,
14,
19550,
63,
6610,
708,
63,
906,
26,
355,
327,
25046,
16012,
8733,
8733,
221,
9094,
13,
708,
12,
12050,
13,
15009,
17720,
355,
291,
14,
1099,
275,
791,
2991,
356,
298,
6610,
13,
708,
906,
401,
283,
13969,
356,
413,
14,
16,
93,
288,
916,
17407,
1491,
20,
61,
508,
6010,
14,
19550,
63,
6610,
708,
63,
6773,
26,
355,
327,
8733,
8733,
16012,
25046,
221,
9094,
13,
708,
12,
7282,
13,
15009,
17720,
355,
291,
14,
1099,
275,
791,
2991,
356,
298,
6610,
13,
708,
6773,
401,
283,
13969,
356,
413,
14,
16,
93,
288,
916,
17407,
1491,
20,
61,
508,
330,
1154,
20981,
60,
9039,
60,
88,
383,
60,
88,
383,
356,
355,
327,
16012,
25046,
8733,
8733,
221,
21884,
13,
20,
12,
625,
527,
1061,
30974,
1865,
17720,
334,
1082,
713,
9,
355,
291,
14,
1099,
275,
469,
490,
283,
2991,
356,
298,
56,
13,
7336,
13,
709,
11387,
13,
21269,
13,
20,
13,
1082,
713,
401,
490,
283,
13969,
356,
413,
14,
16,
355,
789,
288,
916,
17407,
1491,
20,
61,
508,
330,
1154,
88,
383,
60,
88,
383,
60,
9039,
60,
20981,
356,
355,
327,
8733,
8733,
25046,
16012,
221,
21884,
13,
20,
12,
625,
527,
1061,
30974,
1865,
17720,
334,
6886,
19,
9,
355,
291,
14,
1099,
275,
469,
490,
283,
2991,
356,
298,
56,
13,
7336,
13,
709,
11387,
13,
21269,
13,
20,
13,
6886,
19,
401,
490,
283,
13969,
356,
413,
14,
16,
355,
789,
288,
916,
17407,
1491,
18,
61,
508,
6010,
14,
19550,
63,
906,
26,
355,
327,
25046,
16012,
221,
9094,
13,
975,
12,
12050,
17638,
17720,
355,
291,
14,
1099,
275,
791,
2991,
356,
298,
6610,
13,
975,
906,
401,
283,
13969,
356,
413,
14,
16,
93,
288,
916,
17407,
1491,
18,
61,
508,
6010,
14,
19550,
63,
6773,
26,
355,
327,
16012,
25046,
221,
9094,
13,
975,
12,
7282,
17638,
17720,
355,
291,
14,
1099,
275,
791,
2991,
356,
298,
6610,
13,
975,
6773,
401,
283,
13969,
356,
413,
14,
16,
93,
398,
291,
423,
77,
13662,
1451,
275,
715,
267,
340,
291,
14,
1099,
459,
2991,
418,
436,
334,
277,
14,
1099,
459,
13969,
418,
690,
378,
14,
16,
304,
288,
291,
14,
4456,
275,
715,
288,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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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.
"""Cloud Pub/Sub topics list command."""
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.pubsub import util
from googlecloudsdk.core.resource import resource_printer_base
from googlecloudsdk.core.resource import resource_projector
class List(base.ListCommand):
"""Lists Cloud Pub/Sub topics within a project.
Lists all of the Cloud Pub/Sub topics that exist in a given project that
match the given topic name filter.
"""
detailed_help = {
'EXAMPLES': """\
To filter results by topic name (ie. only show topic 'mytopic'), run:
$ {command} --filter=topicId:mytopic
To combine multiple filters (with AND or OR), run:
$ {command} --filter="topicId:mytopic AND topicId:myothertopic"
To filter topics that match an expression:
$ {command} --filter="topicId:mytopic_*"
""",
}
def Run(self, args):
"""This is what gets called when the user runs this command.
Args:
args: an argparse namespace. All the arguments that were provided to this
command invocation.
Yields:
Topic paths that match the regular expression in args.name_filter.
"""
msgs = self.context['pubsub_msgs']
pubsub = self.context['pubsub']
page_size = None
page_token = None
if args.page_size:
page_size = min(args.page_size, util.MAX_LIST_RESULTS)
if not args.filter and args.limit:
page_size = min(args.limit, page_size or util.MAX_LIST_RESULTS)
while True:
list_topics_request = msgs.PubsubProjectsTopicsListRequest(
project=util.ProjectFormat(),
pageToken=page_token,
pageSize=page_size)
list_topics_response = pubsub.projects_topics.List(
list_topics_request)
for topic in list_topics_response.topics:
yield TopicDict(topic)
page_token = list_topics_response.nextPageToken
if not page_token:
break
yield resource_printer_base.PageMarker()
def TopicDict(topic):
topic_dict = resource_projector.MakeSerializable(topic)
topic_info = util.TopicIdentifier(topic.name)
topic_dict['topic'] = topic.name
topic_dict['topicId'] = topic_info.resource_name
del topic_dict['name']
return topic_dict
|
apache-2.0
|
[
3,
1898,
6900,
4475,
3277,
14,
2900,
5924,
5702,
14,
199,
3,
199,
3,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
199,
3,
1265,
1443,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
199,
3,
2047,
1443,
3332,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
259,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
199,
3,
2428,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
199,
3,
1666,
314,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
199,
3,
4204,
1334,
314,
844,
14,
199,
624,
9089,
510,
456,
15,
2610,
17398,
769,
1414,
1041,
199,
504,
6233,
29691,
6341,
14,
915,
317,
13458,
492,
1300,
199,
504,
6233,
29691,
6341,
14,
1531,
63,
773,
14,
20213,
492,
4884,
199,
504,
6233,
29691,
6341,
14,
1018,
14,
1927,
492,
2073,
63,
11835,
63,
1095,
199,
504,
6233,
29691,
6341,
14,
1018,
14,
1927,
492,
2073,
63,
1715,
269,
421,
199,
533,
3820,
8,
1095,
14,
1296,
3110,
304,
523,
408,
15116,
8142,
510,
456,
15,
2610,
17398,
4453,
282,
2199,
14,
819,
31289,
1006,
402,
314,
8142,
510,
456,
15,
2610,
17398,
626,
2187,
315,
282,
1627,
2199,
626,
523,
1336,
314,
1627,
7482,
536,
2457,
14,
523,
408,
819,
16212,
63,
3437,
275,
469,
489,
283,
8918,
356,
9638,
881,
4005,
2457,
2058,
701,
7482,
536,
334,
1873,
14,
1454,
2498,
7482,
283,
1662,
5746,
659,
1255,
26,
953,
2672,
469,
1531,
93,
1553,
1541,
29,
5746,
1304,
26,
1662,
5746,
8592,
4005,
13323,
3663,
4766,
334,
1045,
2401,
503,
1549,
395,
1255,
26,
953,
2672,
469,
1531,
93,
1553,
1541,
628,
5746,
1304,
26,
1662,
5746,
2401,
7482,
1304,
26,
1662,
1848,
5746,
2,
8592,
4005,
2457,
17398,
626,
1336,
376,
3965,
26,
953,
2672,
469,
1531,
93,
1553,
1541,
628,
5746,
1304,
26,
1662,
5746,
63,
12469,
881,
10327,
523,
789,
819,
347,
3378,
8,
277,
12,
1249,
304,
272,
408,
2765,
365,
4052,
7545,
2797,
1380,
314,
922,
7858,
642,
1414,
14,
339,
3033,
26,
489,
1249,
26,
376,
7534,
3231,
14,
2900,
314,
2368,
626,
4898,
2741,
370,
642,
267,
1414,
19569,
14,
339,
23771,
83,
26,
489,
32166,
3792,
626,
1336,
314,
5578,
3965,
315,
1249,
14,
354,
63,
1541,
14,
272,
408,
272,
17599,
275,
291,
14,
1100,
459,
20213,
63,
13429,
418,
272,
7974,
954,
275,
291,
14,
1100,
459,
20213,
418,
339,
2034,
63,
890,
275,
488,
272,
2034,
63,
1418,
275,
488,
339,
340,
1249,
14,
1606,
63,
890,
26,
489,
2034,
63,
890,
275,
1748,
8,
589,
14,
1606,
63,
890,
12,
4884,
14,
4283,
63,
4924,
63,
23545,
9,
339,
340,
440,
1249,
14,
1541,
436,
1249,
14,
3097,
26,
489,
2034,
63,
890,
275,
1748,
8,
589,
14,
3097,
12,
2034,
63,
890,
503,
4884,
14,
4283,
63,
4924,
63,
23545,
9,
339,
1830,
715,
26,
489,
769,
63,
11299,
63,
1069,
275,
17599,
14,
18060,
954,
24286,
6105,
2932,
1296,
2017,
8,
881,
2199,
29,
1974,
14,
4761,
3484,
1062,
881,
2034,
3264,
29,
1606,
63,
1418,
12,
881,
2034,
2320,
29,
1606,
63,
890,
9,
2541,
769,
63,
11299,
63,
1310,
275,
7974,
954,
14,
6776,
63,
11299,
14,
1296,
8,
881,
769,
63,
11299,
63,
1069,
9,
2541,
367,
7482,
315,
769,
63,
11299,
63,
1310,
14,
11299,
26,
267,
1995,
32166,
2141,
8,
5746,
9,
2541,
2034,
63,
1418,
275,
769,
63,
11299,
63,
1310,
14,
2184,
3276,
3264,
489,
340,
440,
2034,
63,
1418,
26,
267,
2059,
489,
1995,
2073,
63,
11835,
63,
1095,
14,
3276,
12825,
342,
421,
199,
318,
32166,
2141,
8,
5746,
304,
523,
7482,
63,
807,
275,
2073,
63,
1715,
269,
14,
5483,
3571,
14065,
8,
5746,
9,
523,
7482,
63,
815,
275,
4884,
14,
12157,
7544,
8,
5746,
14,
354,
9,
523,
7482,
63,
807,
459,
5746,
418,
275,
7482,
14,
354,
523,
7482,
63,
807,
459,
5746,
1304,
418,
275,
7482,
63,
815,
14,
1927,
63,
354,
523,
2150,
7482,
63,
807,
459,
354,
418,
523,
372,
7482,
63,
807,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
1898,
6900,
4475,
3277,
14,
2900,
5924,
5702,
14,
199,
3,
199,
3,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
199,
3,
1265,
1443,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
199,
3,
2047,
1443,
3332,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
259,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
199,
3,
2428,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
199,
3,
1666,
314,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
199,
3,
4204,
1334,
314,
844,
14,
199,
624,
9089,
510,
456,
15,
2610,
17398,
769,
1414,
1041,
199,
504,
6233,
29691,
6341,
14,
915,
317,
13458,
492,
1300,
199,
504,
6233,
29691,
6341,
14,
1531,
63,
773,
14,
20213,
492,
4884,
199,
504,
6233,
29691,
6341,
14,
1018,
14,
1927,
492,
2073,
63,
11835,
63,
1095,
199,
504,
6233,
29691,
6341,
14,
1018,
14,
1927,
492,
2073,
63,
1715,
269,
421,
199,
533,
3820,
8,
1095,
14,
1296,
3110,
304,
523,
408,
15116,
8142,
510,
456,
15,
2610,
17398,
4453,
282,
2199,
14,
819,
31289,
1006,
402,
314,
8142,
510,
456,
15,
2610,
17398,
626,
2187,
315,
282,
1627,
2199,
626,
523,
1336,
314,
1627,
7482,
536,
2457,
14,
523,
408,
819,
16212,
63,
3437,
275,
469,
489,
283,
8918,
356,
9638,
881,
4005,
2457,
2058,
701,
7482,
536,
334,
1873,
14,
1454,
2498,
7482,
283,
1662,
5746,
659,
1255,
26,
953,
2672,
469,
1531,
93,
1553,
1541,
29,
5746,
1304,
26,
1662,
5746,
8592,
4005,
13323,
3663,
4766,
334,
1045,
2401,
503,
1549,
395,
1255,
26,
953,
2672,
469,
1531,
93,
1553,
1541,
628,
5746,
1304,
26,
1662,
5746,
2401,
7482,
1304,
26,
1662,
1848,
5746,
2,
8592,
4005,
2457,
17398,
626,
1336,
376,
3965,
26,
953,
2672,
469,
1531,
93,
1553,
1541,
628,
5746,
1304,
26,
1662,
5746,
63,
12469,
881,
10327,
523,
789,
819,
347,
3378,
8,
277,
12,
1249,
304,
272,
408,
2765,
365,
4052,
7545,
2797,
1380,
314,
922,
7858,
642,
1414,
14,
339,
3033,
26,
489,
1249,
26,
376,
7534,
3231,
14,
2900,
314,
2368,
626,
4898,
2741,
370,
642,
267,
1414,
19569,
14,
339,
23771,
83,
26,
489,
32166,
3792,
626,
1336,
314,
5578,
3965,
315,
1249,
14,
354,
63,
1541,
14,
272,
408,
272,
17599,
275,
291,
14,
1100,
459,
20213,
63,
13429,
418,
272,
7974,
954,
275,
291,
14,
1100,
459,
20213,
418,
339,
2034,
63,
890,
275,
488,
272,
2034,
63,
1418,
275,
488,
339,
340,
1249,
14,
1606,
63,
890,
26,
489,
2034,
63,
890,
275,
1748,
8,
589,
14,
1606,
63,
890,
12,
4884,
14,
4283,
63,
4924,
63,
23545,
9,
339,
340,
440,
1249,
14,
1541,
436,
1249,
14,
3097,
26,
489,
2034,
63,
890,
275,
1748,
8,
589,
14,
3097,
12,
2034,
63,
890,
503,
4884,
14,
4283,
63,
4924,
63,
23545,
9,
339,
1830,
715,
26,
489,
769,
63,
11299,
63,
1069,
275,
17599,
14,
18060,
954,
24286,
6105,
2932,
1296,
2017,
8,
881,
2199,
29,
1974,
14,
4761,
3484,
1062,
881,
2034,
3264,
29,
1606,
63,
1418,
12,
881,
2034,
2320,
29,
1606,
63,
890,
9,
2541,
769,
63,
11299,
63,
1310,
275,
7974,
954,
14,
6776,
63,
11299,
14,
1296,
8,
881,
769,
63,
11299,
63,
1069,
9,
2541,
367,
7482,
315,
769,
63,
11299,
63,
1310,
14,
11299,
26,
267,
1995,
32166,
2141,
8,
5746,
9,
2541,
2034,
63,
1418,
275,
769,
63,
11299,
63,
1310,
14,
2184,
3276,
3264,
489,
340,
440,
2034,
63,
1418,
26,
267,
2059,
489,
1995,
2073,
63,
11835,
63,
1095,
14,
3276,
12825,
342,
421,
199,
318,
32166,
2141,
8,
5746,
304,
523,
7482,
63,
807,
275,
2073,
63,
1715,
269,
14,
5483,
3571,
14065,
8,
5746,
9,
523,
7482,
63,
815,
275,
4884,
14,
12157,
7544,
8,
5746,
14,
354,
9,
523,
7482,
63,
807,
459,
5746,
418,
275,
7482,
14,
354,
523,
7482,
63,
807,
459,
5746,
1304,
418,
275,
7482,
63,
815,
14,
1927,
63,
354,
523,
2150,
7482,
63,
807,
459,
354,
418,
523,
372,
7482,
63,
807,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,
0
] |
tejal29/pants
|
src/python/pants/backend/core/tasks/listtargets.py
|
8
|
3316
|
# coding=utf-8
# Copyright 2014 Pants project contributors (see CONTRIBUTORS.md).
# Licensed under the Apache License, Version 2.0 (see LICENSE).
from __future__ import (absolute_import, division, generators, nested_scopes, print_function,
unicode_literals, with_statement)
from pants.backend.core.tasks.console_task import ConsoleTask
from pants.base.exceptions import TaskError
class ListTargets(ConsoleTask):
"""Lists all targets matching the target specs.
If no targets are specified, lists all targets in the workspace.
"""
@classmethod
def register_options(cls, register):
super(ListTargets, cls).register_options(register)
register('--provides', action='store_true', default=False,
help='List only targets that provide an artifact, displaying the columns specified by '
'--provides-columns.')
register('--provides-columns', default='address,artifact_id',
help='Display these columns when --provides is specified. Available columns are: '
'address, artifact_id, repo_name, repo_url, push_db_basedir')
register('--documented', action='store_true', default=False,
help='Print only targets that are documented with a description.')
def __init__(self, *args, **kwargs):
super(ListTargets, self).__init__(*args, **kwargs)
self._provides = self.get_options().provides
self._provides_columns = self.get_options().provides_columns
self._documented = self.get_options().documented
def console_output(self, targets):
if self._provides:
def extract_artifact_id(target):
provided_jar, _, _ = target.get_artifact_info()
return '{0}#{1}'.format(provided_jar.org, provided_jar.name)
extractors = dict(
address=lambda target: target.address.spec,
artifact_id=extract_artifact_id,
repo_name=lambda target: target.provides.repo.name,
repo_url=lambda target: target.provides.repo.url,
push_db_basedir=lambda target: target.provides.repo.push_db_basedir,
)
def print_provides(column_extractors, target):
if target.is_exported:
return ' '.join(extractor(target) for extractor in column_extractors)
try:
column_extractors = [extractors[col] for col in (self._provides_columns.split(','))]
except KeyError:
raise TaskError('Invalid columns specified: {0}. Valid columns are: address, artifact_id, '
'repo_name, repo_url, push_db_basedir.'.format(self._provides_columns))
print_fn = lambda target: print_provides(column_extractors, target)
elif self._documented:
def print_documented(target):
if target.description:
return '{0}\n {1}'.format(target.address.spec,
'\n '.join(target.description.strip().split('\n')))
print_fn = print_documented
else:
print_fn = lambda target: target.address.spec
visited = set()
for target in self._targets():
result = print_fn(target)
if result and result not in visited:
visited.add(result)
yield result
def _targets(self):
if self.context.target_roots:
return self.context.target_roots
else:
return self.context.scan().targets()
|
apache-2.0
|
[
3,
2803,
29,
1624,
13,
24,
199,
3,
1898,
6927,
510,
2285,
2199,
8417,
334,
3239,
6483,
14,
1064,
680,
199,
3,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
3239,
5113,
680,
199,
199,
504,
636,
2443,
363,
492,
334,
6116,
63,
646,
12,
4629,
12,
16952,
12,
6032,
63,
14129,
12,
870,
63,
1593,
12,
717,
2649,
63,
5955,
12,
543,
63,
6242,
9,
199,
199,
504,
18081,
14,
4620,
14,
1018,
14,
5054,
14,
6614,
63,
1765,
492,
19809,
4476,
199,
504,
18081,
14,
1095,
14,
3924,
492,
8495,
547,
421,
199,
533,
3820,
14126,
8,
9270,
4476,
304,
523,
408,
15116,
1006,
4545,
4877,
314,
1347,
15941,
14,
819,
982,
949,
4545,
787,
2013,
12,
5548,
1006,
4545,
315,
314,
14466,
14,
523,
408,
523,
768,
3744,
523,
347,
2274,
63,
1419,
8,
1886,
12,
2274,
304,
272,
1613,
8,
1296,
14126,
12,
843,
680,
2683,
63,
1419,
8,
2683,
9,
272,
2274,
4517,
20121,
297,
1595,
534,
1617,
63,
2052,
297,
849,
29,
797,
12,
1467,
1720,
534,
1296,
1454,
4545,
626,
5647,
376,
18115,
12,
20589,
314,
4362,
2013,
701,
283,
2116,
2850,
20121,
13,
3406,
2659,
272,
2274,
4517,
20121,
13,
3406,
297,
849,
534,
1562,
12,
16154,
63,
344,
297,
1467,
1720,
534,
7687,
3520,
4362,
1380,
1553,
20121,
365,
2013,
14,
23840,
4362,
787,
26,
283,
2116,
283,
1562,
12,
18115,
63,
344,
12,
3831,
63,
354,
12,
3831,
63,
633,
12,
6675,
63,
697,
63,
12484,
358,
272,
2274,
4517,
29383,
297,
1595,
534,
1617,
63,
2052,
297,
849,
29,
797,
12,
1467,
1720,
534,
5375,
1454,
4545,
626,
787,
22751,
543,
282,
1369,
2659,
819,
347,
636,
826,
721,
277,
12,
627,
589,
12,
1011,
958,
304,
272,
1613,
8,
1296,
14126,
12,
291,
2843,
826,
9308,
589,
12,
1011,
958,
9,
339,
291,
423,
20121,
275,
291,
14,
362,
63,
1419,
1252,
20121,
272,
291,
423,
20121,
63,
3406,
275,
291,
14,
362,
63,
1419,
1252,
20121,
63,
3406,
272,
291,
423,
29383,
275,
291,
14,
362,
63,
1419,
1252,
29383,
819,
347,
8559,
63,
1199,
8,
277,
12,
4545,
304,
272,
340,
291,
423,
20121,
26,
489,
347,
5536,
63,
16154,
63,
344,
8,
1375,
304,
267,
2741,
63,
7338,
12,
5501,
485,
275,
1347,
14,
362,
63,
16154,
63,
815,
342,
267,
372,
5041,
16,
93,
3,
91,
17,
5285,
908,
8,
16929,
63,
7338,
14,
1308,
12,
2741,
63,
7338,
14,
354,
9,
2541,
2402,
13451,
275,
1211,
8,
881,
2287,
29,
2734,
1347,
26,
1347,
14,
1562,
14,
1650,
12,
881,
18115,
63,
344,
29,
5005,
63,
16154,
63,
344,
12,
881,
3831,
63,
354,
29,
2734,
1347,
26,
1347,
14,
20121,
14,
3417,
14,
354,
12,
881,
3831,
63,
633,
29,
2734,
1347,
26,
1347,
14,
20121,
14,
3417,
14,
633,
12,
881,
6675,
63,
697,
63,
12484,
29,
2734,
1347,
26,
1347,
14,
20121,
14,
3417,
14,
5335,
63,
697,
63,
12484,
12,
489,
776,
2541,
347,
870,
63,
20121,
8,
2301,
63,
2911,
13451,
12,
1347,
304,
267,
340,
1347,
14,
374,
63,
23028,
26,
881,
372,
283,
1987,
904,
8,
22677,
8,
1375,
9,
367,
31295,
315,
2763,
63,
2911,
13451,
9,
2541,
862,
26,
267,
2763,
63,
2911,
13451,
275,
359,
2911,
13451,
59,
761,
61,
367,
1048,
315,
334,
277,
423,
20121,
63,
3406,
14,
1294,
5102,
27738,
489,
871,
4067,
26,
267,
746,
8495,
547,
360,
3364,
4362,
2013,
26,
469,
16,
5565,
4821,
4362,
787,
26,
2287,
12,
18115,
63,
344,
12,
283,
717,
283,
3417,
63,
354,
12,
3831,
63,
633,
12,
6675,
63,
697,
63,
12484,
17374,
908,
8,
277,
423,
20121,
63,
3406,
430,
2541,
870,
63,
2324,
275,
2400,
1347,
26,
870,
63,
20121,
8,
2301,
63,
2911,
13451,
12,
1347,
9,
272,
916,
291,
423,
29383,
26,
489,
347,
870,
63,
29383,
8,
1375,
304,
267,
340,
1347,
14,
1802,
26,
881,
372,
5041,
16,
4988,
78,
221,
469,
17,
5285,
908,
8,
1375,
14,
1562,
14,
1650,
12,
3660,
1557,
78,
221,
1987,
904,
8,
1375,
14,
1802,
14,
1913,
1252,
1294,
2258,
78,
7058,
489,
870,
63,
2324,
275,
870,
63,
29383,
272,
587,
26,
489,
870,
63,
2324,
275,
2400,
1347,
26,
1347,
14,
1562,
14,
1650,
339,
15867,
275,
663,
342,
272,
367,
1347,
315,
291,
423,
4684,
837,
489,
754,
275,
870,
63,
2324,
8,
1375,
9,
489,
340,
754,
436,
754,
440,
315,
15867,
26,
267,
15867,
14,
525,
8,
1099,
9,
267,
1995,
754,
819,
347,
485,
4684,
8,
277,
304,
272,
340,
291,
14,
1100,
14,
1375,
63,
12065,
26,
489,
372,
291,
14,
1100,
14,
1375,
63,
12065,
272,
587,
26,
489,
372,
291,
14,
1100,
14,
6282,
1252,
4684,
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
] |
[
2803,
29,
1624,
13,
24,
199,
3,
1898,
6927,
510,
2285,
2199,
8417,
334,
3239,
6483,
14,
1064,
680,
199,
3,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
3239,
5113,
680,
199,
199,
504,
636,
2443,
363,
492,
334,
6116,
63,
646,
12,
4629,
12,
16952,
12,
6032,
63,
14129,
12,
870,
63,
1593,
12,
717,
2649,
63,
5955,
12,
543,
63,
6242,
9,
199,
199,
504,
18081,
14,
4620,
14,
1018,
14,
5054,
14,
6614,
63,
1765,
492,
19809,
4476,
199,
504,
18081,
14,
1095,
14,
3924,
492,
8495,
547,
421,
199,
533,
3820,
14126,
8,
9270,
4476,
304,
523,
408,
15116,
1006,
4545,
4877,
314,
1347,
15941,
14,
819,
982,
949,
4545,
787,
2013,
12,
5548,
1006,
4545,
315,
314,
14466,
14,
523,
408,
523,
768,
3744,
523,
347,
2274,
63,
1419,
8,
1886,
12,
2274,
304,
272,
1613,
8,
1296,
14126,
12,
843,
680,
2683,
63,
1419,
8,
2683,
9,
272,
2274,
4517,
20121,
297,
1595,
534,
1617,
63,
2052,
297,
849,
29,
797,
12,
1467,
1720,
534,
1296,
1454,
4545,
626,
5647,
376,
18115,
12,
20589,
314,
4362,
2013,
701,
283,
2116,
2850,
20121,
13,
3406,
2659,
272,
2274,
4517,
20121,
13,
3406,
297,
849,
534,
1562,
12,
16154,
63,
344,
297,
1467,
1720,
534,
7687,
3520,
4362,
1380,
1553,
20121,
365,
2013,
14,
23840,
4362,
787,
26,
283,
2116,
283,
1562,
12,
18115,
63,
344,
12,
3831,
63,
354,
12,
3831,
63,
633,
12,
6675,
63,
697,
63,
12484,
358,
272,
2274,
4517,
29383,
297,
1595,
534,
1617,
63,
2052,
297,
849,
29,
797,
12,
1467,
1720,
534,
5375,
1454,
4545,
626,
787,
22751,
543,
282,
1369,
2659,
819,
347,
636,
826,
721,
277,
12,
627,
589,
12,
1011,
958,
304,
272,
1613,
8,
1296,
14126,
12,
291,
2843,
826,
9308,
589,
12,
1011,
958,
9,
339,
291,
423,
20121,
275,
291,
14,
362,
63,
1419,
1252,
20121,
272,
291,
423,
20121,
63,
3406,
275,
291,
14,
362,
63,
1419,
1252,
20121,
63,
3406,
272,
291,
423,
29383,
275,
291,
14,
362,
63,
1419,
1252,
29383,
819,
347,
8559,
63,
1199,
8,
277,
12,
4545,
304,
272,
340,
291,
423,
20121,
26,
489,
347,
5536,
63,
16154,
63,
344,
8,
1375,
304,
267,
2741,
63,
7338,
12,
5501,
485,
275,
1347,
14,
362,
63,
16154,
63,
815,
342,
267,
372,
5041,
16,
93,
3,
91,
17,
5285,
908,
8,
16929,
63,
7338,
14,
1308,
12,
2741,
63,
7338,
14,
354,
9,
2541,
2402,
13451,
275,
1211,
8,
881,
2287,
29,
2734,
1347,
26,
1347,
14,
1562,
14,
1650,
12,
881,
18115,
63,
344,
29,
5005,
63,
16154,
63,
344,
12,
881,
3831,
63,
354,
29,
2734,
1347,
26,
1347,
14,
20121,
14,
3417,
14,
354,
12,
881,
3831,
63,
633,
29,
2734,
1347,
26,
1347,
14,
20121,
14,
3417,
14,
633,
12,
881,
6675,
63,
697,
63,
12484,
29,
2734,
1347,
26,
1347,
14,
20121,
14,
3417,
14,
5335,
63,
697,
63,
12484,
12,
489,
776,
2541,
347,
870,
63,
20121,
8,
2301,
63,
2911,
13451,
12,
1347,
304,
267,
340,
1347,
14,
374,
63,
23028,
26,
881,
372,
283,
1987,
904,
8,
22677,
8,
1375,
9,
367,
31295,
315,
2763,
63,
2911,
13451,
9,
2541,
862,
26,
267,
2763,
63,
2911,
13451,
275,
359,
2911,
13451,
59,
761,
61,
367,
1048,
315,
334,
277,
423,
20121,
63,
3406,
14,
1294,
5102,
27738,
489,
871,
4067,
26,
267,
746,
8495,
547,
360,
3364,
4362,
2013,
26,
469,
16,
5565,
4821,
4362,
787,
26,
2287,
12,
18115,
63,
344,
12,
283,
717,
283,
3417,
63,
354,
12,
3831,
63,
633,
12,
6675,
63,
697,
63,
12484,
17374,
908,
8,
277,
423,
20121,
63,
3406,
430,
2541,
870,
63,
2324,
275,
2400,
1347,
26,
870,
63,
20121,
8,
2301,
63,
2911,
13451,
12,
1347,
9,
272,
916,
291,
423,
29383,
26,
489,
347,
870,
63,
29383,
8,
1375,
304,
267,
340,
1347,
14,
1802,
26,
881,
372,
5041,
16,
4988,
78,
221,
469,
17,
5285,
908,
8,
1375,
14,
1562,
14,
1650,
12,
3660,
1557,
78,
221,
1987,
904,
8,
1375,
14,
1802,
14,
1913,
1252,
1294,
2258,
78,
7058,
489,
870,
63,
2324,
275,
870,
63,
29383,
272,
587,
26,
489,
870,
63,
2324,
275,
2400,
1347,
26,
1347,
14,
1562,
14,
1650,
339,
15867,
275,
663,
342,
272,
367,
1347,
315,
291,
423,
4684,
837,
489,
754,
275,
870,
63,
2324,
8,
1375,
9,
489,
340,
754,
436,
754,
440,
315,
15867,
26,
267,
15867,
14,
525,
8,
1099,
9,
267,
1995,
754,
819,
347,
485,
4684,
8,
277,
304,
272,
340,
291,
14,
1100,
14,
1375,
63,
12065,
26,
489,
372,
291,
14,
1100,
14,
1375,
63,
12065,
272,
587,
26,
489,
372,
291,
14,
1100,
14,
6282,
1252,
4684,
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,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
lumig242/Hue-Integration-with-CDAP
|
desktop/core/ext-py/requests-2.10.0/requests/auth.py
|
149
|
8075
|
# -*- coding: utf-8 -*-
"""
requests.auth
~~~~~~~~~~~~~
This module contains the authentication handlers for Requests.
"""
import os
import re
import time
import hashlib
import threading
from base64 import b64encode
from .compat import urlparse, str
from .cookies import extract_cookies_to_jar
from .utils import parse_dict_header, to_native_string
from .status_codes import codes
CONTENT_TYPE_FORM_URLENCODED = 'application/x-www-form-urlencoded'
CONTENT_TYPE_MULTI_PART = 'multipart/form-data'
def _basic_auth_str(username, password):
"""Returns a Basic Auth string."""
authstr = 'Basic ' + to_native_string(
b64encode(('%s:%s' % (username, password)).encode('latin1')).strip()
)
return authstr
class AuthBase(object):
"""Base class that all auth implementations derive from"""
def __call__(self, r):
raise NotImplementedError('Auth hooks must be callable.')
class HTTPBasicAuth(AuthBase):
"""Attaches HTTP Basic Authentication to the given Request object."""
def __init__(self, username, password):
self.username = username
self.password = password
def __eq__(self, other):
return all([
self.username == getattr(other, 'username', None),
self.password == getattr(other, 'password', None)
])
def __ne__(self, other):
return not self == other
def __call__(self, r):
r.headers['Authorization'] = _basic_auth_str(self.username, self.password)
return r
class HTTPProxyAuth(HTTPBasicAuth):
"""Attaches HTTP Proxy Authentication to a given Request object."""
def __call__(self, r):
r.headers['Proxy-Authorization'] = _basic_auth_str(self.username, self.password)
return r
class HTTPDigestAuth(AuthBase):
"""Attaches HTTP Digest Authentication to the given Request object."""
def __init__(self, username, password):
self.username = username
self.password = password
# Keep state in per-thread local storage
self._thread_local = threading.local()
def init_per_thread_state(self):
# Ensure state is initialized just once per-thread
if not hasattr(self._thread_local, 'init'):
self._thread_local.init = True
self._thread_local.last_nonce = ''
self._thread_local.nonce_count = 0
self._thread_local.chal = {}
self._thread_local.pos = None
self._thread_local.num_401_calls = None
def build_digest_header(self, method, url):
realm = self._thread_local.chal['realm']
nonce = self._thread_local.chal['nonce']
qop = self._thread_local.chal.get('qop')
algorithm = self._thread_local.chal.get('algorithm')
opaque = self._thread_local.chal.get('opaque')
hash_utf8 = None
if algorithm is None:
_algorithm = 'MD5'
else:
_algorithm = algorithm.upper()
# lambdas assume digest modules are imported at the top level
if _algorithm == 'MD5' or _algorithm == 'MD5-SESS':
def md5_utf8(x):
if isinstance(x, str):
x = x.encode('utf-8')
return hashlib.md5(x).hexdigest()
hash_utf8 = md5_utf8
elif _algorithm == 'SHA':
def sha_utf8(x):
if isinstance(x, str):
x = x.encode('utf-8')
return hashlib.sha1(x).hexdigest()
hash_utf8 = sha_utf8
KD = lambda s, d: hash_utf8("%s:%s" % (s, d))
if hash_utf8 is None:
return None
# XXX not implemented yet
entdig = None
p_parsed = urlparse(url)
#: path is request-uri defined in RFC 2616 which should not be empty
path = p_parsed.path or "/"
if p_parsed.query:
path += '?' + p_parsed.query
A1 = '%s:%s:%s' % (self.username, realm, self.password)
A2 = '%s:%s' % (method, path)
HA1 = hash_utf8(A1)
HA2 = hash_utf8(A2)
if nonce == self._thread_local.last_nonce:
self._thread_local.nonce_count += 1
else:
self._thread_local.nonce_count = 1
ncvalue = '%08x' % self._thread_local.nonce_count
s = str(self._thread_local.nonce_count).encode('utf-8')
s += nonce.encode('utf-8')
s += time.ctime().encode('utf-8')
s += os.urandom(8)
cnonce = (hashlib.sha1(s).hexdigest()[:16])
if _algorithm == 'MD5-SESS':
HA1 = hash_utf8('%s:%s:%s' % (HA1, nonce, cnonce))
if not qop:
respdig = KD(HA1, "%s:%s" % (nonce, HA2))
elif qop == 'auth' or 'auth' in qop.split(','):
noncebit = "%s:%s:%s:%s:%s" % (
nonce, ncvalue, cnonce, 'auth', HA2
)
respdig = KD(HA1, noncebit)
else:
# XXX handle auth-int.
return None
self._thread_local.last_nonce = nonce
# XXX should the partial digests be encoded too?
base = 'username="%s", realm="%s", nonce="%s", uri="%s", ' \
'response="%s"' % (self.username, realm, nonce, path, respdig)
if opaque:
base += ', opaque="%s"' % opaque
if algorithm:
base += ', algorithm="%s"' % algorithm
if entdig:
base += ', digest="%s"' % entdig
if qop:
base += ', qop="auth", nc=%s, cnonce="%s"' % (ncvalue, cnonce)
return 'Digest %s' % (base)
def handle_redirect(self, r, **kwargs):
"""Reset num_401_calls counter on redirects."""
if r.is_redirect:
self._thread_local.num_401_calls = 1
def handle_401(self, r, **kwargs):
"""Takes the given response and tries digest-auth, if needed."""
if self._thread_local.pos is not None:
# Rewind the file position indicator of the body to where
# it was to resend the request.
r.request.body.seek(self._thread_local.pos)
s_auth = r.headers.get('www-authenticate', '')
if 'digest' in s_auth.lower() and self._thread_local.num_401_calls < 2:
self._thread_local.num_401_calls += 1
pat = re.compile(r'digest ', flags=re.IGNORECASE)
self._thread_local.chal = parse_dict_header(pat.sub('', s_auth, count=1))
# Consume content and release the original connection
# to allow our new request to reuse the same one.
r.content
r.close()
prep = r.request.copy()
extract_cookies_to_jar(prep._cookies, r.request, r.raw)
prep.prepare_cookies(prep._cookies)
prep.headers['Authorization'] = self.build_digest_header(
prep.method, prep.url)
_r = r.connection.send(prep, **kwargs)
_r.history.append(r)
_r.request = prep
return _r
self._thread_local.num_401_calls = 1
return r
def __call__(self, r):
# Initialize per-thread state, if needed
self.init_per_thread_state()
# If we have a saved nonce, skip the 401
if self._thread_local.last_nonce:
r.headers['Authorization'] = self.build_digest_header(r.method, r.url)
try:
self._thread_local.pos = r.body.tell()
except AttributeError:
# In the case of HTTPDigestAuth being reused and the body of
# the previous request was a file-like object, pos has the
# file position of the previous body. Ensure it's set to
# None.
self._thread_local.pos = None
r.register_hook('response', self.handle_401)
r.register_hook('response', self.handle_redirect)
self._thread_local.num_401_calls = 1
return r
def __eq__(self, other):
return all([
self.username == getattr(other, 'username', None),
self.password == getattr(other, 'password', None)
])
def __ne__(self, other):
return not self == other
|
apache-2.0
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
199,
624,
199,
6615,
14,
1178,
199,
22935,
94,
199,
199,
2765,
859,
3509,
314,
6299,
8297,
367,
20260,
14,
199,
624,
199,
199,
646,
747,
199,
646,
295,
199,
646,
900,
199,
646,
8337,
199,
646,
5796,
199,
199,
504,
1300,
772,
492,
330,
772,
2143,
199,
199,
504,
1275,
5819,
492,
7097,
12,
620,
199,
504,
1275,
7792,
492,
5536,
63,
7792,
63,
475,
63,
7338,
199,
504,
1275,
1208,
492,
2198,
63,
807,
63,
1291,
12,
370,
63,
6106,
63,
875,
199,
504,
1275,
1205,
63,
6021,
492,
9479,
199,
199,
9663,
63,
2711,
63,
3516,
63,
2632,
742,
6012,
36,
275,
283,
3578,
15,
88,
13,
1544,
13,
964,
13,
21886,
7,
199,
9663,
63,
2711,
63,
21389,
63,
14848,
275,
283,
10123,
15,
964,
13,
576,
7,
421,
199,
318,
485,
4316,
63,
1178,
63,
495,
8,
2473,
12,
2505,
304,
272,
408,
3407,
282,
10082,
3590,
1059,
1041,
339,
1790,
495,
275,
283,
6845,
283,
435,
370,
63,
6106,
63,
875,
8,
267,
330,
772,
2143,
8,
3508,
83,
2689,
83,
7,
450,
334,
2473,
12,
2505,
4992,
2143,
360,
10378,
17,
11103,
1913,
342,
272,
776,
339,
372,
1790,
495,
421,
199,
533,
3590,
1563,
8,
785,
304,
272,
408,
1563,
1021,
626,
1006,
1790,
12591,
23519,
687,
624,
339,
347,
636,
1250,
721,
277,
12,
519,
304,
267,
746,
4279,
360,
2817,
12604,
1471,
506,
4550,
2659,
421,
199,
533,
3101,
6845,
2817,
8,
2817,
1563,
304,
272,
408,
13240,
397,
3101,
10082,
15995,
370,
314,
1627,
4784,
909,
1041,
272,
347,
636,
826,
721,
277,
12,
3434,
12,
2505,
304,
267,
291,
14,
2473,
275,
3434,
267,
291,
14,
2060,
275,
2505,
339,
347,
636,
4077,
721,
277,
12,
1163,
304,
267,
372,
1006,
779,
288,
291,
14,
2473,
508,
2519,
8,
1848,
12,
283,
2473,
297,
488,
395,
288,
291,
14,
2060,
508,
2519,
8,
1848,
12,
283,
2060,
297,
488,
9,
267,
4794,
339,
347,
636,
685,
721,
277,
12,
1163,
304,
267,
372,
440,
291,
508,
1163,
339,
347,
636,
1250,
721,
277,
12,
519,
304,
267,
519,
14,
2139,
459,
11626,
418,
275,
485,
4316,
63,
1178,
63,
495,
8,
277,
14,
2473,
12,
291,
14,
2060,
9,
267,
372,
519,
421,
199,
533,
3101,
4936,
2817,
8,
2856,
6845,
2817,
304,
272,
408,
13240,
397,
3101,
12373,
15995,
370,
282,
1627,
4784,
909,
1041,
272,
347,
636,
1250,
721,
277,
12,
519,
304,
267,
519,
14,
2139,
459,
4936,
13,
11626,
418,
275,
485,
4316,
63,
1178,
63,
495,
8,
277,
14,
2473,
12,
291,
14,
2060,
9,
267,
372,
519,
421,
199,
533,
3101,
18541,
2817,
8,
2817,
1563,
304,
272,
408,
13240,
397,
3101,
3757,
3199,
15995,
370,
314,
1627,
4784,
909,
1041,
272,
347,
636,
826,
721,
277,
12,
3434,
12,
2505,
304,
267,
291,
14,
2473,
275,
3434,
267,
291,
14,
2060,
275,
2505,
267,
327,
14797,
1174,
315,
1126,
13,
2671,
2257,
4887,
267,
291,
423,
2671,
63,
1832,
275,
5796,
14,
1832,
342,
339,
347,
4205,
63,
529,
63,
2671,
63,
929,
8,
277,
304,
267,
327,
7523,
1174,
365,
10038,
2951,
5403,
1126,
13,
2671,
267,
340,
440,
2688,
8,
277,
423,
2671,
63,
1832,
12,
283,
826,
735,
288,
291,
423,
2671,
63,
1832,
14,
826,
275,
715,
288,
291,
423,
2671,
63,
1832,
14,
2019,
63,
10667,
275,
2125,
288,
291,
423,
2671,
63,
1832,
14,
10667,
63,
835,
275,
378,
288,
291,
423,
2671,
63,
1832,
14,
335,
279,
275,
1052,
288,
291,
423,
2671,
63,
1832,
14,
1712,
275,
488,
288,
291,
423,
2671,
63,
1832,
14,
1507,
63,
8854,
63,
5352,
275,
488,
339,
347,
1900,
63,
5671,
63,
1291,
8,
277,
12,
1083,
12,
1166,
304,
398,
10482,
275,
291,
423,
2671,
63,
1832,
14,
335,
279,
459,
7728,
418,
267,
13711,
275,
291,
423,
2671,
63,
1832,
14,
335,
279,
459,
10667,
418,
267,
1894,
411,
275,
291,
423,
2671,
63,
1832,
14,
335,
279,
14,
362,
360,
81,
411,
358,
267,
5563,
275,
291,
423,
2671,
63,
1832,
14,
335,
279,
14,
362,
360,
8833,
358,
267,
15058,
275,
291,
423,
2671,
63,
1832,
14,
335,
279,
14,
362,
360,
21669,
358,
267,
2631,
63,
1624,
24,
275,
488,
398,
340,
5563,
365,
488,
26,
288,
485,
8833,
275,
283,
5127,
21,
7,
267,
587,
26,
288,
485,
8833,
275,
5563,
14,
4142,
342,
267,
327,
27593,
24315,
5534,
10017,
4621,
787,
8439,
737,
314,
2746,
2166,
267,
340,
485,
8833,
508,
283,
5127,
21,
7,
503,
485,
8833,
508,
283,
5127,
21,
13,
51,
1608,
356,
288,
347,
6128,
21,
63,
1624,
24,
8,
88,
304,
355,
340,
1228,
8,
88,
12,
620,
304,
490,
671,
275,
671,
14,
2143,
360,
1624,
13,
24,
358,
355,
372,
8337,
14,
1064,
21,
8,
88,
680,
11453,
342,
288,
2631,
63,
1624,
24,
275,
6128,
21,
63,
1624,
24,
267,
916,
485,
8833,
508,
283,
8461,
356,
288,
347,
7793,
63,
1624,
24,
8,
88,
304,
355,
340,
1228,
8,
88,
12,
620,
304,
490,
671,
275,
671,
14,
2143,
360,
1624,
13,
24,
358,
355,
372,
8337,
14,
4835,
17,
8,
88,
680,
11453,
342,
288,
2631,
63,
1624,
24,
275,
7793,
63,
1624,
24,
398,
31368,
275,
2400,
308,
12,
366,
26,
2631,
63,
1624,
24,
3647,
83,
2689,
83,
2,
450,
334,
83,
12,
366,
430,
398,
340,
2631,
63,
1624,
24,
365,
488,
26,
288,
372,
488,
398,
327,
5787,
440,
6366,
5966,
267,
15992,
18367,
275,
488,
267,
299,
63,
6751,
275,
7097,
8,
633,
9,
267,
6079,
931,
365,
1056,
13,
2302,
3247,
315,
7329,
7875,
975,
1314,
1077,
440,
506,
2701,
267,
931,
275,
299,
63,
6751,
14,
515,
503,
10609,
267,
340,
299,
63,
6751,
14,
1131,
26,
288,
931,
847,
15539,
435,
299,
63,
6751,
14,
1131,
398,
437,
17,
275,
1543,
83,
2689,
83,
2689,
83,
7,
450,
334,
277,
14,
2473,
12,
10482,
12,
291,
14,
2060,
9,
267,
437,
18,
275,
1543,
83,
2689,
83,
7,
450,
334,
765,
12,
931,
9,
398,
16100,
17
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
199,
624,
199,
6615,
14,
1178,
199,
22935,
94,
199,
199,
2765,
859,
3509,
314,
6299,
8297,
367,
20260,
14,
199,
624,
199,
199,
646,
747,
199,
646,
295,
199,
646,
900,
199,
646,
8337,
199,
646,
5796,
199,
199,
504,
1300,
772,
492,
330,
772,
2143,
199,
199,
504,
1275,
5819,
492,
7097,
12,
620,
199,
504,
1275,
7792,
492,
5536,
63,
7792,
63,
475,
63,
7338,
199,
504,
1275,
1208,
492,
2198,
63,
807,
63,
1291,
12,
370,
63,
6106,
63,
875,
199,
504,
1275,
1205,
63,
6021,
492,
9479,
199,
199,
9663,
63,
2711,
63,
3516,
63,
2632,
742,
6012,
36,
275,
283,
3578,
15,
88,
13,
1544,
13,
964,
13,
21886,
7,
199,
9663,
63,
2711,
63,
21389,
63,
14848,
275,
283,
10123,
15,
964,
13,
576,
7,
421,
199,
318,
485,
4316,
63,
1178,
63,
495,
8,
2473,
12,
2505,
304,
272,
408,
3407,
282,
10082,
3590,
1059,
1041,
339,
1790,
495,
275,
283,
6845,
283,
435,
370,
63,
6106,
63,
875,
8,
267,
330,
772,
2143,
8,
3508,
83,
2689,
83,
7,
450,
334,
2473,
12,
2505,
4992,
2143,
360,
10378,
17,
11103,
1913,
342,
272,
776,
339,
372,
1790,
495,
421,
199,
533,
3590,
1563,
8,
785,
304,
272,
408,
1563,
1021,
626,
1006,
1790,
12591,
23519,
687,
624,
339,
347,
636,
1250,
721,
277,
12,
519,
304,
267,
746,
4279,
360,
2817,
12604,
1471,
506,
4550,
2659,
421,
199,
533,
3101,
6845,
2817,
8,
2817,
1563,
304,
272,
408,
13240,
397,
3101,
10082,
15995,
370,
314,
1627,
4784,
909,
1041,
272,
347,
636,
826,
721,
277,
12,
3434,
12,
2505,
304,
267,
291,
14,
2473,
275,
3434,
267,
291,
14,
2060,
275,
2505,
339,
347,
636,
4077,
721,
277,
12,
1163,
304,
267,
372,
1006,
779,
288,
291,
14,
2473,
508,
2519,
8,
1848,
12,
283,
2473,
297,
488,
395,
288,
291,
14,
2060,
508,
2519,
8,
1848,
12,
283,
2060,
297,
488,
9,
267,
4794,
339,
347,
636,
685,
721,
277,
12,
1163,
304,
267,
372,
440,
291,
508,
1163,
339,
347,
636,
1250,
721,
277,
12,
519,
304,
267,
519,
14,
2139,
459,
11626,
418,
275,
485,
4316,
63,
1178,
63,
495,
8,
277,
14,
2473,
12,
291,
14,
2060,
9,
267,
372,
519,
421,
199,
533,
3101,
4936,
2817,
8,
2856,
6845,
2817,
304,
272,
408,
13240,
397,
3101,
12373,
15995,
370,
282,
1627,
4784,
909,
1041,
272,
347,
636,
1250,
721,
277,
12,
519,
304,
267,
519,
14,
2139,
459,
4936,
13,
11626,
418,
275,
485,
4316,
63,
1178,
63,
495,
8,
277,
14,
2473,
12,
291,
14,
2060,
9,
267,
372,
519,
421,
199,
533,
3101,
18541,
2817,
8,
2817,
1563,
304,
272,
408,
13240,
397,
3101,
3757,
3199,
15995,
370,
314,
1627,
4784,
909,
1041,
272,
347,
636,
826,
721,
277,
12,
3434,
12,
2505,
304,
267,
291,
14,
2473,
275,
3434,
267,
291,
14,
2060,
275,
2505,
267,
327,
14797,
1174,
315,
1126,
13,
2671,
2257,
4887,
267,
291,
423,
2671,
63,
1832,
275,
5796,
14,
1832,
342,
339,
347,
4205,
63,
529,
63,
2671,
63,
929,
8,
277,
304,
267,
327,
7523,
1174,
365,
10038,
2951,
5403,
1126,
13,
2671,
267,
340,
440,
2688,
8,
277,
423,
2671,
63,
1832,
12,
283,
826,
735,
288,
291,
423,
2671,
63,
1832,
14,
826,
275,
715,
288,
291,
423,
2671,
63,
1832,
14,
2019,
63,
10667,
275,
2125,
288,
291,
423,
2671,
63,
1832,
14,
10667,
63,
835,
275,
378,
288,
291,
423,
2671,
63,
1832,
14,
335,
279,
275,
1052,
288,
291,
423,
2671,
63,
1832,
14,
1712,
275,
488,
288,
291,
423,
2671,
63,
1832,
14,
1507,
63,
8854,
63,
5352,
275,
488,
339,
347,
1900,
63,
5671,
63,
1291,
8,
277,
12,
1083,
12,
1166,
304,
398,
10482,
275,
291,
423,
2671,
63,
1832,
14,
335,
279,
459,
7728,
418,
267,
13711,
275,
291,
423,
2671,
63,
1832,
14,
335,
279,
459,
10667,
418,
267,
1894,
411,
275,
291,
423,
2671,
63,
1832,
14,
335,
279,
14,
362,
360,
81,
411,
358,
267,
5563,
275,
291,
423,
2671,
63,
1832,
14,
335,
279,
14,
362,
360,
8833,
358,
267,
15058,
275,
291,
423,
2671,
63,
1832,
14,
335,
279,
14,
362,
360,
21669,
358,
267,
2631,
63,
1624,
24,
275,
488,
398,
340,
5563,
365,
488,
26,
288,
485,
8833,
275,
283,
5127,
21,
7,
267,
587,
26,
288,
485,
8833,
275,
5563,
14,
4142,
342,
267,
327,
27593,
24315,
5534,
10017,
4621,
787,
8439,
737,
314,
2746,
2166,
267,
340,
485,
8833,
508,
283,
5127,
21,
7,
503,
485,
8833,
508,
283,
5127,
21,
13,
51,
1608,
356,
288,
347,
6128,
21,
63,
1624,
24,
8,
88,
304,
355,
340,
1228,
8,
88,
12,
620,
304,
490,
671,
275,
671,
14,
2143,
360,
1624,
13,
24,
358,
355,
372,
8337,
14,
1064,
21,
8,
88,
680,
11453,
342,
288,
2631,
63,
1624,
24,
275,
6128,
21,
63,
1624,
24,
267,
916,
485,
8833,
508,
283,
8461,
356,
288,
347,
7793,
63,
1624,
24,
8,
88,
304,
355,
340,
1228,
8,
88,
12,
620,
304,
490,
671,
275,
671,
14,
2143,
360,
1624,
13,
24,
358,
355,
372,
8337,
14,
4835,
17,
8,
88,
680,
11453,
342,
288,
2631,
63,
1624,
24,
275,
7793,
63,
1624,
24,
398,
31368,
275,
2400,
308,
12,
366,
26,
2631,
63,
1624,
24,
3647,
83,
2689,
83,
2,
450,
334,
83,
12,
366,
430,
398,
340,
2631,
63,
1624,
24,
365,
488,
26,
288,
372,
488,
398,
327,
5787,
440,
6366,
5966,
267,
15992,
18367,
275,
488,
267,
299,
63,
6751,
275,
7097,
8,
633,
9,
267,
6079,
931,
365,
1056,
13,
2302,
3247,
315,
7329,
7875,
975,
1314,
1077,
440,
506,
2701,
267,
931,
275,
299,
63,
6751,
14,
515,
503,
10609,
267,
340,
299,
63,
6751,
14,
1131,
26,
288,
931,
847,
15539,
435,
299,
63,
6751,
14,
1131,
398,
437,
17,
275,
1543,
83,
2689,
83,
2689,
83,
7,
450,
334,
277,
14,
2473,
12,
10482,
12,
291,
14,
2060,
9,
267,
437,
18,
275,
1543,
83,
2689,
83,
7,
450,
334,
765,
12,
931,
9,
398,
16100,
17,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
chouseknecht/ansible
|
lib/ansible/modules/cloud/xenserver/xenserver_guest_info.py
|
10
|
7682
|
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# Copyright: (c) 2018, Bojan Vitnik <bvitnik@mainstream.rs>
# 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 = r'''
---
module: xenserver_guest_info
short_description: Gathers information for virtual machines running on Citrix XenServer host or pool
description: >
This module can be used to gather essential VM facts.
version_added: '2.8'
author:
- Bojan Vitnik (@bvitnik) <bvitnik@mainstream.rs>
notes:
- Minimal supported version of XenServer is 5.6.
- Module was tested with XenServer 6.5, 7.1 and 7.2.
- 'XenAPI Python library can be acquired from XenServer SDK (downloadable from Citrix website) or by running C(pip install XenAPI) (possibly very old
version, not compatible with Python 3.x). Latest version can also be acquired from GitHub:
https://raw.githubusercontent.com/xapi-project/xen-api/master/scripts/examples/python/XenAPI.py'
- 'If no scheme is specified in C(hostname), module defaults to C(http://) because C(https://) is problematic in most setups. Make sure you are
accessing XenServer host in trusted environment or use C(https://) scheme explicitly.'
- 'To use C(https://) scheme for C(hostname) you have to either import host certificate to your OS certificate store or use C(validate_certs: no)
which requires XenAPI library from XenServer 7.2 SDK or newer and Python 2.7.9 or newer.'
- This module was called C(xenserver_guest_facts) before Ansible 2.9. The usage did not change.
requirements:
- python >= 2.6
- XenAPI
options:
name:
description:
- Name of the VM to gather facts from.
- VMs running on XenServer do not necessarily have unique names. The module will fail if multiple VMs with same name are found.
- In case of multiple VMs with same name, use C(uuid) to uniquely specify VM to manage.
- This parameter is case sensitive.
type: str
required: yes
aliases: [ name_label ]
uuid:
description:
- UUID of the VM to gather fact of. This is XenServer's unique identifier.
- It is required if name is not unique.
type: str
extends_documentation_fragment: xenserver.documentation
'''
EXAMPLES = r'''
- name: Gather facts
xenserver_guest_info:
hostname: "{{ xenserver_hostname }}"
username: "{{ xenserver_username }}"
password: "{{ xenserver_password }}"
name: testvm_11
delegate_to: localhost
register: facts
'''
RETURN = r'''
instance:
description: Metadata about the VM
returned: always
type: dict
sample: {
"cdrom": {
"type": "none"
},
"customization_agent": "native",
"disks": [
{
"name": "testvm_11-0",
"name_desc": "",
"os_device": "xvda",
"size": 42949672960,
"sr": "Local storage",
"sr_uuid": "0af1245e-bdb0-ba33-1446-57a962ec4075",
"vbd_userdevice": "0"
},
{
"name": "testvm_11-1",
"name_desc": "",
"os_device": "xvdb",
"size": 42949672960,
"sr": "Local storage",
"sr_uuid": "0af1245e-bdb0-ba33-1446-57a962ec4075",
"vbd_userdevice": "1"
}
],
"domid": "56",
"folder": "",
"hardware": {
"memory_mb": 8192,
"num_cpu_cores_per_socket": 2,
"num_cpus": 4
},
"home_server": "",
"is_template": false,
"name": "testvm_11",
"name_desc": "",
"networks": [
{
"gateway": "192.168.0.254",
"gateway6": "fc00::fffe",
"ip": "192.168.0.200",
"ip6": [
"fe80:0000:0000:0000:e9cb:625a:32c5:c291",
"fc00:0000:0000:0000:0000:0000:0000:0001"
],
"mac": "ba:91:3a:48:20:76",
"mtu": "1500",
"name": "Pool-wide network associated with eth1",
"netmask": "255.255.255.128",
"prefix": "25",
"prefix6": "64",
"vif_device": "0"
}
],
"other_config": {
"base_template_name": "Windows Server 2016 (64-bit)",
"import_task": "OpaqueRef:e43eb71c-45d6-5351-09ff-96e4fb7d0fa5",
"install-methods": "cdrom",
"instant": "true",
"mac_seed": "f83e8d8a-cfdc-b105-b054-ef5cb416b77e"
},
"platform": {
"acpi": "1",
"apic": "true",
"cores-per-socket": "2",
"device_id": "0002",
"hpet": "true",
"nx": "true",
"pae": "true",
"timeoffset": "-25200",
"vga": "std",
"videoram": "8",
"viridian": "true",
"viridian_reference_tsc": "true",
"viridian_time_ref_count": "true"
},
"state": "poweredon",
"uuid": "e3c0b2d5-5f05-424e-479c-d3df8b3e7cda",
"xenstore_data": {
"vm-data": ""
}
}
'''
HAS_XENAPI = False
try:
import XenAPI
HAS_XENAPI = True
except ImportError:
pass
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.xenserver import (xenserver_common_argument_spec, XAPI, XenServerObject, get_object_ref,
gather_vm_params, gather_vm_facts)
class XenServerVM(XenServerObject):
"""Class for managing XenServer VM.
Attributes:
vm_ref (str): XAPI reference to VM.
vm_params (dict): A dictionary with VM parameters as returned
by gather_vm_params() function.
"""
def __init__(self, module):
"""Inits XenServerVM using module parameters.
Args:
module: Reference to AnsibleModule object.
"""
super(XenServerVM, self).__init__(module)
self.vm_ref = get_object_ref(self.module, self.module.params['name'], self.module.params['uuid'], obj_type="VM", fail=True, msg_prefix="VM search: ")
self.gather_params()
def gather_params(self):
"""Gathers all VM parameters available in XAPI database."""
self.vm_params = gather_vm_params(self.module, self.vm_ref)
def gather_facts(self):
"""Gathers and returns VM facts."""
return gather_vm_facts(self.module, self.vm_params)
def main():
argument_spec = xenserver_common_argument_spec()
argument_spec.update(
name=dict(type='str', aliases=['name_label']),
uuid=dict(type='str'),
)
module = AnsibleModule(argument_spec=argument_spec,
supports_check_mode=True,
required_one_of=[
['name', 'uuid'],
],
)
if module._name == 'xenserver_guest_facts':
module.deprecate("The 'xenserver_guest_facts' module has been renamed to 'xenserver_guest_info'", version='2.13')
result = {'failed': False, 'changed': False}
# Module will exit with an error message if no VM is found.
vm = XenServerVM(module)
# Gather facts.
result['instance'] = vm.gather_facts()
if result['failed']:
module.fail_json(**result)
else:
module.exit_json(**result)
if __name__ == '__main__':
main()
|
gpl-3.0
|
[
3381,
2647,
15,
1393,
15,
1548,
199,
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
199,
3,
1898,
26,
334,
67,
9,
14894,
12,
5088,
24418,
812,
390,
22998,
665,
23064,
390,
22998,
32,
973,
1745,
14,
2393,
30,
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,
199,
199,
8490,
63,
8314,
275,
791,
2343,
63,
1023,
356,
283,
17,
14,
17,
297,
490,
283,
1205,
356,
788,
7780,
995,
490,
283,
4946,
63,
991,
356,
283,
9387,
936,
199,
199,
8948,
275,
519,
2344,
199,
2595,
199,
578,
26,
20388,
1000,
63,
10409,
63,
815,
199,
3612,
63,
1802,
26,
19634,
83,
2556,
367,
5791,
20601,
3879,
641,
445,
390,
1904,
30211,
3120,
1591,
503,
4203,
199,
1802,
26,
690,
2043,
961,
859,
883,
506,
1202,
370,
13082,
22829,
1009,
7525,
9036,
14,
199,
1023,
63,
3270,
26,
283,
18,
14,
24,
7,
199,
2502,
26,
199,
13,
5088,
24418,
812,
390,
22998,
8593,
23064,
390,
22998,
9,
665,
23064,
390,
22998,
32,
973,
1745,
14,
2393,
30,
199,
5983,
26,
199,
13,
10195,
7265,
3748,
1015,
402,
30211,
3120,
365,
959,
14,
22,
14,
199,
13,
5673,
1990,
12470,
543,
30211,
3120,
1227,
14,
21,
12,
1520,
14,
17,
436,
1520,
14,
18,
14,
199,
13,
283,
30643,
3735,
2018,
3555,
883,
506,
28320,
687,
30211,
3120,
15610,
334,
4249,
461,
687,
445,
390,
1904,
10691,
9,
503,
701,
3879,
445,
8,
9983,
3907,
30211,
3735,
9,
334,
19614,
7437,
2269,
2043,
1015,
12,
440,
9025,
543,
2018,
650,
14,
88,
680,
491,
27126,
1015,
883,
2597,
506,
28320,
687,
25141,
26,
2043,
4178,
921,
1773,
14,
5031,
751,
1317,
14,
957,
15,
32751,
13,
1715,
15,
13615,
13,
1246,
15,
4133,
15,
6429,
15,
8589,
15,
1548,
15,
30643,
3735,
14,
647,
7,
199,
13,
283,
3917,
949,
5687,
365,
2013,
315,
445,
8,
4269,
395,
859,
4243,
370,
445,
8,
1014,
921,
9,
2952,
445,
8,
2859,
921,
9,
365,
557,
31197,
315,
4750,
3272,
83,
14,
4155,
3238,
1265,
787,
2043,
18549,
30211,
3120,
1591,
315,
19427,
3734,
503,
675,
445,
8,
2859,
921,
9,
5687,
7662,
3530,
199,
13,
283,
1378,
675,
445,
8,
2859,
921,
9,
5687,
367,
445,
8,
4269,
9,
1265,
1172,
370,
1902,
492,
1591,
5897,
370,
2195,
4403,
5897,
3877,
503,
675,
445,
8,
3502,
63,
8356,
26,
949,
9,
2043,
1314,
5074,
30211,
3735,
3555,
687,
30211,
3120,
1520,
14,
18,
15610,
503,
15666,
436,
2018,
499,
14,
23,
14,
25,
503,
15666,
3530,
199,
13,
961,
859,
1990,
2797,
445,
8,
13615,
1000,
63,
10409,
63,
5047,
9,
2544,
2622,
499,
14,
25,
14,
710,
4503,
8103,
440,
1570,
14,
199,
7538,
26,
199,
13,
2366,
2356,
499,
14,
22,
199,
13,
30211,
3735,
199,
1419,
26,
523,
536,
26,
272,
1369,
26,
272,
446,
2812,
402,
314,
7525,
370,
13082,
9036,
687,
14,
272,
446,
30641,
3879,
641,
30211,
3120,
886,
440,
20513,
1172,
3747,
1561,
14,
710,
859,
911,
2449,
340,
3663,
30641,
543,
2011,
536,
787,
1911,
14,
272,
446,
1010,
1930,
402,
3663,
30641,
543,
2011,
536,
12,
675,
445,
8,
2580,
9,
370,
28727,
4165,
7525,
370,
9635,
14,
272,
446,
961,
2725,
365,
1930,
18423,
14,
272,
730,
26,
620,
272,
1415,
26,
9456,
272,
5481,
26,
359,
536,
63,
1302,
1622,
523,
5377,
26,
272,
1369,
26,
272,
446,
11134,
402,
314,
7525,
370,
13082,
10572,
402,
14,
961,
365,
30211,
3120,
1159,
3747,
5148,
14,
272,
446,
2779,
365,
1415,
340,
536,
365,
440,
3747,
14,
272,
730,
26,
620,
199,
11036,
63,
9970,
63,
7677,
26,
20388,
1000,
14,
9970,
199,
2344,
199,
199,
8918,
275,
519,
2344,
199,
13,
536,
26,
19634,
9036,
523,
20388,
1000,
63,
10409,
63,
815,
26,
272,
6246,
26,
7370,
20388,
1000,
63,
4269,
7820,
272,
3434,
26,
7370,
20388,
1000,
63,
2473,
7820,
272,
2505,
26,
7370,
20388,
1000,
63,
2060,
7820,
272,
536,
26,
511,
2611,
63,
845,
523,
13080,
63,
475,
26,
11667,
523,
2274,
26,
9036,
199,
2344,
199,
199,
9677,
275,
519,
2344,
199,
842,
26,
272,
1369,
26,
16160,
3595,
314,
7525,
272,
2138,
26,
3544,
272,
730,
26,
1211,
272,
2690,
26,
469,
267,
298,
2866,
417,
582,
469,
288,
298,
466,
582,
298,
3592,
2,
267,
1660,
267,
298,
4229,
2072,
63,
4054,
582,
298,
6106,
401,
267,
298,
16203,
582,
359,
288,
469,
355,
298,
354,
582,
298,
396,
2611,
63,
845,
13,
16,
401,
355,
298,
354,
63,
3257,
582,
4873,
355,
298,
736,
63,
1782,
582,
298,
25466,
983,
401,
355,
298,
890,
582,
21504,
1398,
2259,
12,
355,
298,
5474,
582,
298,
5339,
4887,
401,
355,
298,
5474,
63,
2580,
582,
298,
16,
2756,
713,
2322,
69,
13,
27178,
16,
13,
2470,
1153,
13,
1079,
2466,
13,
1641,
65,
28039,
825,
12641,
21,
401,
355,
298,
32505,
63,
751,
1782,
582,
298,
16,
2,
288,
1660,
288,
469,
355,
298,
354,
582,
298,
396,
2611,
63,
845,
13,
17,
401,
355,
298,
354,
63,
3257,
582,
4873,
355,
298,
736,
63,
1782,
582,
298,
25466,
697,
401,
355,
298,
890,
582,
21504,
1398,
2259,
12,
355,
298,
5474,
582,
298,
5339,
4887,
401,
355,
298,
5474,
63,
2580,
582,
298,
16,
2756,
713,
2322,
69,
13,
27178,
16,
13,
2470,
1153,
13,
1079,
2466,
13,
1641,
65,
28039,
825,
12641,
21,
401,
355,
298,
32505,
63,
751,
1782,
582,
298,
17,
2,
288,
789,
267,
2156,
267,
298,
4556,
344,
582,
298,
1367,
401,
267,
298,
3741,
582,
4873,
267,
298,
16529,
582,
469,
288,
298,
4844,
63,
887,
582,
28828,
12,
288,
298,
1507,
63,
3541,
63,
4630,
63,
529,
63,
3450,
582,
499,
12,
288,
298,
1507,
63,
8896,
582,
841,
267,
1660,
267,
298,
4219,
63,
1000,
582,
4873,
267,
298,
374,
63,
1160,
582,
3055,
12,
267,
298,
354,
582,
298
] |
[
2647,
15,
1393,
15,
1548,
199,
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
199,
3,
1898,
26,
334,
67,
9,
14894,
12,
5088,
24418,
812,
390,
22998,
665,
23064,
390,
22998,
32,
973,
1745,
14,
2393,
30,
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,
199,
199,
8490,
63,
8314,
275,
791,
2343,
63,
1023,
356,
283,
17,
14,
17,
297,
490,
283,
1205,
356,
788,
7780,
995,
490,
283,
4946,
63,
991,
356,
283,
9387,
936,
199,
199,
8948,
275,
519,
2344,
199,
2595,
199,
578,
26,
20388,
1000,
63,
10409,
63,
815,
199,
3612,
63,
1802,
26,
19634,
83,
2556,
367,
5791,
20601,
3879,
641,
445,
390,
1904,
30211,
3120,
1591,
503,
4203,
199,
1802,
26,
690,
2043,
961,
859,
883,
506,
1202,
370,
13082,
22829,
1009,
7525,
9036,
14,
199,
1023,
63,
3270,
26,
283,
18,
14,
24,
7,
199,
2502,
26,
199,
13,
5088,
24418,
812,
390,
22998,
8593,
23064,
390,
22998,
9,
665,
23064,
390,
22998,
32,
973,
1745,
14,
2393,
30,
199,
5983,
26,
199,
13,
10195,
7265,
3748,
1015,
402,
30211,
3120,
365,
959,
14,
22,
14,
199,
13,
5673,
1990,
12470,
543,
30211,
3120,
1227,
14,
21,
12,
1520,
14,
17,
436,
1520,
14,
18,
14,
199,
13,
283,
30643,
3735,
2018,
3555,
883,
506,
28320,
687,
30211,
3120,
15610,
334,
4249,
461,
687,
445,
390,
1904,
10691,
9,
503,
701,
3879,
445,
8,
9983,
3907,
30211,
3735,
9,
334,
19614,
7437,
2269,
2043,
1015,
12,
440,
9025,
543,
2018,
650,
14,
88,
680,
491,
27126,
1015,
883,
2597,
506,
28320,
687,
25141,
26,
2043,
4178,
921,
1773,
14,
5031,
751,
1317,
14,
957,
15,
32751,
13,
1715,
15,
13615,
13,
1246,
15,
4133,
15,
6429,
15,
8589,
15,
1548,
15,
30643,
3735,
14,
647,
7,
199,
13,
283,
3917,
949,
5687,
365,
2013,
315,
445,
8,
4269,
395,
859,
4243,
370,
445,
8,
1014,
921,
9,
2952,
445,
8,
2859,
921,
9,
365,
557,
31197,
315,
4750,
3272,
83,
14,
4155,
3238,
1265,
787,
2043,
18549,
30211,
3120,
1591,
315,
19427,
3734,
503,
675,
445,
8,
2859,
921,
9,
5687,
7662,
3530,
199,
13,
283,
1378,
675,
445,
8,
2859,
921,
9,
5687,
367,
445,
8,
4269,
9,
1265,
1172,
370,
1902,
492,
1591,
5897,
370,
2195,
4403,
5897,
3877,
503,
675,
445,
8,
3502,
63,
8356,
26,
949,
9,
2043,
1314,
5074,
30211,
3735,
3555,
687,
30211,
3120,
1520,
14,
18,
15610,
503,
15666,
436,
2018,
499,
14,
23,
14,
25,
503,
15666,
3530,
199,
13,
961,
859,
1990,
2797,
445,
8,
13615,
1000,
63,
10409,
63,
5047,
9,
2544,
2622,
499,
14,
25,
14,
710,
4503,
8103,
440,
1570,
14,
199,
7538,
26,
199,
13,
2366,
2356,
499,
14,
22,
199,
13,
30211,
3735,
199,
1419,
26,
523,
536,
26,
272,
1369,
26,
272,
446,
2812,
402,
314,
7525,
370,
13082,
9036,
687,
14,
272,
446,
30641,
3879,
641,
30211,
3120,
886,
440,
20513,
1172,
3747,
1561,
14,
710,
859,
911,
2449,
340,
3663,
30641,
543,
2011,
536,
787,
1911,
14,
272,
446,
1010,
1930,
402,
3663,
30641,
543,
2011,
536,
12,
675,
445,
8,
2580,
9,
370,
28727,
4165,
7525,
370,
9635,
14,
272,
446,
961,
2725,
365,
1930,
18423,
14,
272,
730,
26,
620,
272,
1415,
26,
9456,
272,
5481,
26,
359,
536,
63,
1302,
1622,
523,
5377,
26,
272,
1369,
26,
272,
446,
11134,
402,
314,
7525,
370,
13082,
10572,
402,
14,
961,
365,
30211,
3120,
1159,
3747,
5148,
14,
272,
446,
2779,
365,
1415,
340,
536,
365,
440,
3747,
14,
272,
730,
26,
620,
199,
11036,
63,
9970,
63,
7677,
26,
20388,
1000,
14,
9970,
199,
2344,
199,
199,
8918,
275,
519,
2344,
199,
13,
536,
26,
19634,
9036,
523,
20388,
1000,
63,
10409,
63,
815,
26,
272,
6246,
26,
7370,
20388,
1000,
63,
4269,
7820,
272,
3434,
26,
7370,
20388,
1000,
63,
2473,
7820,
272,
2505,
26,
7370,
20388,
1000,
63,
2060,
7820,
272,
536,
26,
511,
2611,
63,
845,
523,
13080,
63,
475,
26,
11667,
523,
2274,
26,
9036,
199,
2344,
199,
199,
9677,
275,
519,
2344,
199,
842,
26,
272,
1369,
26,
16160,
3595,
314,
7525,
272,
2138,
26,
3544,
272,
730,
26,
1211,
272,
2690,
26,
469,
267,
298,
2866,
417,
582,
469,
288,
298,
466,
582,
298,
3592,
2,
267,
1660,
267,
298,
4229,
2072,
63,
4054,
582,
298,
6106,
401,
267,
298,
16203,
582,
359,
288,
469,
355,
298,
354,
582,
298,
396,
2611,
63,
845,
13,
16,
401,
355,
298,
354,
63,
3257,
582,
4873,
355,
298,
736,
63,
1782,
582,
298,
25466,
983,
401,
355,
298,
890,
582,
21504,
1398,
2259,
12,
355,
298,
5474,
582,
298,
5339,
4887,
401,
355,
298,
5474,
63,
2580,
582,
298,
16,
2756,
713,
2322,
69,
13,
27178,
16,
13,
2470,
1153,
13,
1079,
2466,
13,
1641,
65,
28039,
825,
12641,
21,
401,
355,
298,
32505,
63,
751,
1782,
582,
298,
16,
2,
288,
1660,
288,
469,
355,
298,
354,
582,
298,
396,
2611,
63,
845,
13,
17,
401,
355,
298,
354,
63,
3257,
582,
4873,
355,
298,
736,
63,
1782,
582,
298,
25466,
697,
401,
355,
298,
890,
582,
21504,
1398,
2259,
12,
355,
298,
5474,
582,
298,
5339,
4887,
401,
355,
298,
5474,
63,
2580,
582,
298,
16,
2756,
713,
2322,
69,
13,
27178,
16,
13,
2470,
1153,
13,
1079,
2466,
13,
1641,
65,
28039,
825,
12641,
21,
401,
355,
298,
32505,
63,
751,
1782,
582,
298,
17,
2,
288,
789,
267,
2156,
267,
298,
4556,
344,
582,
298,
1367,
401,
267,
298,
3741,
582,
4873,
267,
298,
16529,
582,
469,
288,
298,
4844,
63,
887,
582,
28828,
12,
288,
298,
1507,
63,
3541,
63,
4630,
63,
529,
63,
3450,
582,
499,
12,
288,
298,
1507,
63,
8896,
582,
841,
267,
1660,
267,
298,
4219,
63,
1000,
582,
4873,
267,
298,
374,
63,
1160,
582,
3055,
12,
267,
298,
354,
582,
298,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
biocore/verman
|
verman/__init__.py
|
1
|
9290
|
#!/usr/bin/env python
#-----------------------------------------------------------------------------
# Copyright (c) 2013, The BiPy Development Team.
#
# Distributed under the terms of the Modified BSD License.
#
# The full license is in the file COPYING.txt, distributed with this software.
#-----------------------------------------------------------------------------
__credits__ = ["Daniel McDonald", "Jai Ram Rideout", "Yoshiki Vazquez Baeza"]
import os
import subprocess
class Version(object):
"""Represent module version information
This is inspired by Python's sys.version_info
"""
def __init__(self, package, major, minor, micro=None, releaselevel=None, init_file=None):
if not isinstance(package, str):
raise TypeError("Package must be a string")
if not isinstance(major, int):
raise TypeError("Major version must be an integer")
if not isinstance(minor, int):
raise TypeError("Minor version must be an integer")
if micro is not None and not isinstance(micro, int):
raise TypeError("Micro version must be an integer")
if releaselevel is not None and not isinstance(releaselevel, str):
raise TypeError("Releaselevel must be a string")
if init_file is not None and not os.path.exists(init_file):
raise ValueError("init_file must exist if provided")
self.package = package
self.major = major
self.minor = minor
self.micro = micro
self.releaselevel = releaselevel
self.init_file = init_file
@property
def mmm(self):
"""major.minor.micro version string"""
if self.micro is None:
return "%d.%d" % (self.major, self.minor)
else:
return "%d.%d.%d" % (self.major, self.minor, self.micro)
def __str__(self):
"""Return a version string"""
if self.micro is None:
base = "%d.%d" % (self.major, self.minor)
else:
base = "%d.%d.%d" % (self.major, self.minor, self.micro)
if self.releaselevel is not None:
base = "%s-%s" % (base, self.releaselevel)
git_branch = self.git_branch()
git_sha1 = self.git_sha1()
if git_branch is not None:
return "%s, %s@%s" % (base, git_branch, git_sha1)
else:
return base
def __repr__(self):
"""Return version information similar to Python's sys.version_info"""
name = "%s_version" % self.package
major = "major=%d" % self.major
minor = "minor=%d" % self.minor
items = [major, minor]
if self.micro is not None:
items.append("micro=%s" % self.micro)
if self.releaselevel is not None:
items.append("releaselevel='%s'" % self.releaselevel)
git_branch = self.git_branch()
git_sha1 = self.git_sha1(truncate=False)
if git_branch is not None:
git_branch = "git_branch='%s'" % git_branch
git_sha1 = "git_sha1='%s'" % git_sha1
items.append(git_branch)
items.append(git_sha1)
return "%s(%s)" % (name, ', '.join(items))
def git_branch(self):
"""Get the current branch (if applicable)
This code was adapted from QIIME. The author, Yoshiki Vazquez Baeza has
given explicit permission for this code to be licensed under BSD. The
discussion can be found here https://github.com/wasade/verman/issues/1
"""
if self.init_file is None:
return None
pkg_dir = self.package_dir()
branch_cmd = 'git --git-dir %s/.git rev-parse --abbrev-ref HEAD' %\
(pkg_dir)
branch_o, branch_e, branch_r = self.verman_system_call(branch_cmd)
git_branch = branch_o.strip()
if self._is_valid_git_refname(git_branch):
return git_branch
else:
return None
def git_sha1(self, truncate=True):
"""Get the current git SHA1 (if applicable)
This code was adapted from QIIME. The author, Yoshiki Vazquez Baeza has
given explicit permission for this code to be licensed under BSD. The
discussion can be found here https://github.com/wasade/verman/issues/1
"""
if self.init_file is None:
return None
pkg_dir = self.package_dir()
sha_cmd = 'git --git-dir %s/.git rev-parse HEAD' % (pkg_dir)
sha_o, sha_e, sha_r = self.verman_system_call(sha_cmd)
git_sha = sha_o.strip()
if self._is_valid_git_sha1(git_sha):
if truncate:
return git_sha[0:7]
else:
return git_sha
else:
return None
def _is_valid_git_refname(self, refname):
"""check if a string is a valid branch-name/ref-name for git
Input:
refname: string to validate
Output:
True if 'refname' is a valid branch name in git. False if it fails to
meet any of the criteria described in the man page for
'git check-ref-format', also see:
http://www.kernel.org/pub/software/scm/git/docs/git-check-ref-format.html
This code was adapted from QIIME. The author, Yoshiki Vazquez Baeza has
given explicit permission for this code to be licensed under BSD. The
discussion can be found here https://github.com/wasade/verman/issues/1
"""
if len(refname) == 0:
return False
# git imposes a few requirements to accept a string as a
# refname/branch-name
# They can include slash / for hierarchical (directory) grouping, but no
# slash-separated component can begin with a dot . or end with the
# sequence .lock
if (len([True for element in refname.split('/')
if element.startswith('.') or element.endswith('.lock')]) != 0):
return False
# They cannot have two consecutive dots .. anywhere
if '..' in refname:
return False
# They cannot have ASCII control characters (i.e. bytes whose values are
# lower than \040, or \177 DEL), space, tilde, caret ^, or colon :
# anywhere
if len([True for refname_char in refname if ord(refname_char) < 40 or
ord(refname_char) == 177]) != 0:
return False
if ' ' in refname or '~' in refname or '^' in refname or ':' in refname:
return False
# They cannot have question-mark ?, asterisk *, or open bracket [
# anywhere
if '?' in refname or '*' in refname or '[' in refname:
return False
# They cannot begin or end with a slash / or contain multiple
# consecutive slashes
if refname.startswith('/') or refname.endswith('/') or '//' in refname:
return False
# They cannot end with a dot ..
if refname.endswith('.'):
return False
# They cannot contain a sequence @{
if '@{' in refname:
return False
# They cannot contain a \
if '\\' in refname:
return False
return True
def _is_valid_git_sha1(self, possible_hash):
"""check if a string is a valid git sha1 string
Input:
possible_hash: string to validate
Output:
True if the string has 40 characters and is an hexadecimal number, False
otherwise.
This code was adapted from QIIME. The author, Yoshiki Vazquez Baeza has
given explicit permission for this code to be licensed under BSD. The
discussion can be found here https://github.com/wasade/verman/issues/1
"""
if len(possible_hash) != 40:
return False
try:
_ = int(possible_hash, 16)
except ValueError:
return False
return True
def package_dir(self):
"""Returns the top-level package directory
This code was adapted from QIIME. The author, Greg Caporaso, has given
explicit permission for this code to be licensed under BSD. The
discussion can be found here: https://github.com/wasade/verman/issues/1
"""
# Get the full path of the module containing an instance of Version
if self.init_file is None:
return None
current_file_path = os.path.abspath(self.init_file)
# Get the directory
current_dir_path = os.path.dirname(current_file_path)
# Return the directory containing the directory containing the instance
return os.path.dirname(current_dir_path)
def verman_system_call(self, cmd):
"""Issue a system call
This code is based off of pyqi's pyqi_system_call
"""
proc = subprocess.Popen(cmd, shell=True, universal_newlines=True,
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
# communicate pulls all stdout/stderr from the PIPEs to
# avoid blocking -- don't remove this line!
stdout, stderr = proc.communicate()
return_value = proc.returncode
return stdout, stderr, return_value
verman_version = Version("verman", 1, 1, 1, init_file=__file__)
__version__ = verman_version.mmm
|
bsd-3-clause
|
[
3381,
2647,
15,
1393,
15,
1813,
2366,
199,
199,
18045,
199,
3,
1898,
334,
67,
9,
6171,
12,
710,
31012,
2713,
15290,
11682,
14,
199,
3,
199,
3,
17484,
1334,
314,
2895,
402,
314,
22016,
6289,
844,
14,
199,
3,
199,
3,
710,
2615,
4190,
365,
315,
314,
570,
9685,
14,
2424,
12,
1854,
543,
642,
2032,
14,
199,
18045,
199,
199,
363,
22461,
363,
275,
2097,
29336,
14769,
22895,
36,
8125,
68,
401,
298,
42,
5789,
820,
455,
820,
2655,
548,
401,
298,
57,
22267,
11545,
812,
4651,
544,
90,
699,
3624,
8076,
937,
199,
199,
646,
747,
199,
646,
3873,
199,
199,
533,
3394,
8,
785,
304,
272,
408,
10755,
859,
1015,
2556,
2286,
961,
365,
315,
8721,
581,
701,
2018,
1159,
984,
14,
1023,
63,
815,
272,
408,
272,
347,
636,
826,
721,
277,
12,
2559,
12,
12160,
12,
12612,
12,
9967,
29,
403,
12,
4683,
1896,
29,
403,
12,
4205,
63,
493,
29,
403,
304,
267,
340,
440,
1228,
8,
2491,
12,
620,
304,
288,
746,
3146,
480,
8599,
1471,
506,
282,
1059,
531,
398,
340,
440,
1228,
8,
8452,
12,
1109,
304,
288,
746,
3146,
480,
21657,
1015,
1471,
506,
376,
3000,
531,
398,
340,
440,
1228,
8,
11067,
12,
1109,
304,
288,
746,
3146,
480,
23094,
1015,
1471,
506,
376,
3000,
531,
398,
340,
9967,
365,
440,
488,
436,
440,
1228,
8,
6453,
12,
1109,
304,
288,
746,
3146,
480,
23990,
1015,
1471,
506,
376,
3000,
531,
398,
340,
4683,
1896,
365,
440,
488,
436,
440,
1228,
8,
3221,
1896,
12,
620,
304,
288,
746,
3146,
480,
9625,
1896,
1471,
506,
282,
1059,
531,
398,
340,
4205,
63,
493,
365,
440,
488,
436,
440,
747,
14,
515,
14,
2444,
8,
826,
63,
493,
304,
288,
746,
1722,
480,
826,
63,
493,
1471,
2187,
340,
2741,
531,
398,
291,
14,
2491,
275,
2559,
267,
291,
14,
8452,
275,
12160,
267,
291,
14,
11067,
275,
12612,
267,
291,
14,
6453,
275,
9967,
267,
291,
14,
3221,
1896,
275,
4683,
1896,
267,
291,
14,
826,
63,
493,
275,
4205,
63,
493,
339,
768,
1829,
272,
347,
333,
596,
8,
277,
304,
267,
408,
8452,
14,
11067,
14,
6453,
1015,
1059,
624,
267,
340,
291,
14,
6453,
365,
488,
26,
288,
372,
2071,
68,
4111,
68,
2,
450,
334,
277,
14,
8452,
12,
291,
14,
11067,
9,
267,
587,
26,
288,
372,
2071,
68,
4111,
68,
4111,
68,
2,
450,
334,
277,
14,
8452,
12,
291,
14,
11067,
12,
291,
14,
6453,
9,
339,
347,
636,
495,
721,
277,
304,
267,
408,
1767,
282,
1015,
1059,
624,
267,
340,
291,
14,
6453,
365,
488,
26,
288,
1300,
275,
2071,
68,
4111,
68,
2,
450,
334,
277,
14,
8452,
12,
291,
14,
11067,
9,
267,
587,
26,
288,
1300,
275,
2071,
68,
4111,
68,
4111,
68,
2,
450,
334,
277,
14,
8452,
12,
291,
14,
11067,
12,
291,
14,
6453,
9,
398,
340,
291,
14,
3221,
1896,
365,
440,
488,
26,
288,
1300,
275,
2071,
83,
3295,
83,
2,
450,
334,
1095,
12,
291,
14,
3221,
1896,
9,
398,
6135,
63,
4694,
275,
291,
14,
3187,
63,
4694,
342,
267,
6135,
63,
4835,
17,
275,
291,
14,
3187,
63,
4835,
17,
342,
398,
340,
6135,
63,
4694,
365,
440,
488,
26,
288,
372,
2071,
83,
12,
450,
83,
19437,
83,
2,
450,
334,
1095,
12,
6135,
63,
4694,
12,
6135,
63,
4835,
17,
9,
267,
587,
26,
288,
372,
1300,
339,
347,
636,
2722,
721,
277,
304,
267,
408,
1767,
1015,
2556,
8545,
370,
2018,
1159,
984,
14,
1023,
63,
815,
624,
267,
536,
275,
2071,
83,
63,
1023,
2,
450,
291,
14,
2491,
398,
12160,
275,
298,
8452,
2458,
68,
2,
450,
291,
14,
8452,
267,
12612,
275,
298,
11067,
2458,
68,
2,
450,
291,
14,
11067,
398,
2974,
275,
359,
8452,
12,
12612,
61,
267,
340,
291,
14,
6453,
365,
440,
488,
26,
288,
2974,
14,
740,
480,
6453,
2458,
83,
2,
450,
291,
14,
6453,
9,
398,
340,
291,
14,
3221,
1896,
365,
440,
488,
26,
288,
2974,
14,
740,
480,
3221,
1896,
9569,
83,
4065,
450,
291,
14,
3221,
1896,
9,
398,
6135,
63,
4694,
275,
291,
14,
3187,
63,
4694,
342,
267,
6135,
63,
4835,
17,
275,
291,
14,
3187,
63,
4835,
17,
8,
12517,
29,
797,
9,
398,
340,
6135,
63,
4694,
365,
440,
488,
26,
288,
6135,
63,
4694,
275,
298,
3187,
63,
4694,
9569,
83,
4065,
450,
6135,
63,
4694,
288,
6135,
63,
4835,
17,
275,
298,
3187,
63,
4835,
17,
9569,
83,
4065,
450,
6135,
63,
4835,
17,
288,
2974,
14,
740,
8,
3187,
63,
4694,
9,
288,
2974,
14,
740,
8,
3187,
63,
4835,
17,
9,
398,
372,
2071,
83,
4042,
83,
2924,
450,
334,
354,
12,
1656,
1987,
904,
8,
1744,
430,
339,
347,
6135,
63,
4694,
8,
277,
304,
267,
408,
1002,
314,
1453,
5246,
334,
692,
3964,
9,
398,
961,
1233,
1990,
26266,
687,
1413,
41,
3465,
14,
710,
4132,
12,
1488,
22267,
11545,
812,
4651,
544,
90,
699,
3624,
8076,
965,
267,
1627,
5027,
4983,
367,
642,
1233,
370,
506,
18233,
1334,
6289,
14,
710,
267,
16582,
883,
506,
1911,
2348,
4178,
921,
5031,
14,
957,
15,
10274,
9587,
15,
422,
1237,
15,
10115,
15,
17,
267,
408,
267,
340,
291,
14,
826,
63,
493,
365,
488,
26,
288,
372,
488,
398,
5496,
63,
694,
275,
291,
14,
2491,
63,
694,
342,
2728,
5246,
63,
1760,
275,
283,
3187,
1553,
3187,
13,
694,
450,
83,
8083,
3187,
6822,
13,
1122,
1553,
31349,
13,
1121,
13053,
7,
450,
60,
288,
334,
4600,
63,
694,
9,
267,
5246,
63,
79,
12,
5246,
63,
69,
12,
5246,
63,
82,
275,
291,
14,
422,
1237,
63,
2253,
63,
1250,
8,
4694,
63,
1760,
9,
267,
6135,
63,
4694,
275,
5246,
63,
79,
14,
1913,
342,
398,
340,
291,
423,
374,
63,
1078,
63,
3187,
63,
29124,
8,
3187,
63,
4694,
304,
288,
372,
6135,
63,
4694,
267,
587,
26,
288,
372,
488,
339,
347,
6135,
63,
4835,
17,
8,
277,
12,
14547,
29,
549,
304,
267,
408,
1002,
314,
1453,
6135,
12002,
17,
334,
692,
3964,
9,
398,
961,
1233,
1990,
26266,
687
] |
[
2647,
15,
1393,
15,
1813,
2366,
199,
199,
18045,
199,
3,
1898,
334,
67,
9,
6171,
12,
710,
31012,
2713,
15290,
11682,
14,
199,
3,
199,
3,
17484,
1334,
314,
2895,
402,
314,
22016,
6289,
844,
14,
199,
3,
199,
3,
710,
2615,
4190,
365,
315,
314,
570,
9685,
14,
2424,
12,
1854,
543,
642,
2032,
14,
199,
18045,
199,
199,
363,
22461,
363,
275,
2097,
29336,
14769,
22895,
36,
8125,
68,
401,
298,
42,
5789,
820,
455,
820,
2655,
548,
401,
298,
57,
22267,
11545,
812,
4651,
544,
90,
699,
3624,
8076,
937,
199,
199,
646,
747,
199,
646,
3873,
199,
199,
533,
3394,
8,
785,
304,
272,
408,
10755,
859,
1015,
2556,
2286,
961,
365,
315,
8721,
581,
701,
2018,
1159,
984,
14,
1023,
63,
815,
272,
408,
272,
347,
636,
826,
721,
277,
12,
2559,
12,
12160,
12,
12612,
12,
9967,
29,
403,
12,
4683,
1896,
29,
403,
12,
4205,
63,
493,
29,
403,
304,
267,
340,
440,
1228,
8,
2491,
12,
620,
304,
288,
746,
3146,
480,
8599,
1471,
506,
282,
1059,
531,
398,
340,
440,
1228,
8,
8452,
12,
1109,
304,
288,
746,
3146,
480,
21657,
1015,
1471,
506,
376,
3000,
531,
398,
340,
440,
1228,
8,
11067,
12,
1109,
304,
288,
746,
3146,
480,
23094,
1015,
1471,
506,
376,
3000,
531,
398,
340,
9967,
365,
440,
488,
436,
440,
1228,
8,
6453,
12,
1109,
304,
288,
746,
3146,
480,
23990,
1015,
1471,
506,
376,
3000,
531,
398,
340,
4683,
1896,
365,
440,
488,
436,
440,
1228,
8,
3221,
1896,
12,
620,
304,
288,
746,
3146,
480,
9625,
1896,
1471,
506,
282,
1059,
531,
398,
340,
4205,
63,
493,
365,
440,
488,
436,
440,
747,
14,
515,
14,
2444,
8,
826,
63,
493,
304,
288,
746,
1722,
480,
826,
63,
493,
1471,
2187,
340,
2741,
531,
398,
291,
14,
2491,
275,
2559,
267,
291,
14,
8452,
275,
12160,
267,
291,
14,
11067,
275,
12612,
267,
291,
14,
6453,
275,
9967,
267,
291,
14,
3221,
1896,
275,
4683,
1896,
267,
291,
14,
826,
63,
493,
275,
4205,
63,
493,
339,
768,
1829,
272,
347,
333,
596,
8,
277,
304,
267,
408,
8452,
14,
11067,
14,
6453,
1015,
1059,
624,
267,
340,
291,
14,
6453,
365,
488,
26,
288,
372,
2071,
68,
4111,
68,
2,
450,
334,
277,
14,
8452,
12,
291,
14,
11067,
9,
267,
587,
26,
288,
372,
2071,
68,
4111,
68,
4111,
68,
2,
450,
334,
277,
14,
8452,
12,
291,
14,
11067,
12,
291,
14,
6453,
9,
339,
347,
636,
495,
721,
277,
304,
267,
408,
1767,
282,
1015,
1059,
624,
267,
340,
291,
14,
6453,
365,
488,
26,
288,
1300,
275,
2071,
68,
4111,
68,
2,
450,
334,
277,
14,
8452,
12,
291,
14,
11067,
9,
267,
587,
26,
288,
1300,
275,
2071,
68,
4111,
68,
4111,
68,
2,
450,
334,
277,
14,
8452,
12,
291,
14,
11067,
12,
291,
14,
6453,
9,
398,
340,
291,
14,
3221,
1896,
365,
440,
488,
26,
288,
1300,
275,
2071,
83,
3295,
83,
2,
450,
334,
1095,
12,
291,
14,
3221,
1896,
9,
398,
6135,
63,
4694,
275,
291,
14,
3187,
63,
4694,
342,
267,
6135,
63,
4835,
17,
275,
291,
14,
3187,
63,
4835,
17,
342,
398,
340,
6135,
63,
4694,
365,
440,
488,
26,
288,
372,
2071,
83,
12,
450,
83,
19437,
83,
2,
450,
334,
1095,
12,
6135,
63,
4694,
12,
6135,
63,
4835,
17,
9,
267,
587,
26,
288,
372,
1300,
339,
347,
636,
2722,
721,
277,
304,
267,
408,
1767,
1015,
2556,
8545,
370,
2018,
1159,
984,
14,
1023,
63,
815,
624,
267,
536,
275,
2071,
83,
63,
1023,
2,
450,
291,
14,
2491,
398,
12160,
275,
298,
8452,
2458,
68,
2,
450,
291,
14,
8452,
267,
12612,
275,
298,
11067,
2458,
68,
2,
450,
291,
14,
11067,
398,
2974,
275,
359,
8452,
12,
12612,
61,
267,
340,
291,
14,
6453,
365,
440,
488,
26,
288,
2974,
14,
740,
480,
6453,
2458,
83,
2,
450,
291,
14,
6453,
9,
398,
340,
291,
14,
3221,
1896,
365,
440,
488,
26,
288,
2974,
14,
740,
480,
3221,
1896,
9569,
83,
4065,
450,
291,
14,
3221,
1896,
9,
398,
6135,
63,
4694,
275,
291,
14,
3187,
63,
4694,
342,
267,
6135,
63,
4835,
17,
275,
291,
14,
3187,
63,
4835,
17,
8,
12517,
29,
797,
9,
398,
340,
6135,
63,
4694,
365,
440,
488,
26,
288,
6135,
63,
4694,
275,
298,
3187,
63,
4694,
9569,
83,
4065,
450,
6135,
63,
4694,
288,
6135,
63,
4835,
17,
275,
298,
3187,
63,
4835,
17,
9569,
83,
4065,
450,
6135,
63,
4835,
17,
288,
2974,
14,
740,
8,
3187,
63,
4694,
9,
288,
2974,
14,
740,
8,
3187,
63,
4835,
17,
9,
398,
372,
2071,
83,
4042,
83,
2924,
450,
334,
354,
12,
1656,
1987,
904,
8,
1744,
430,
339,
347,
6135,
63,
4694,
8,
277,
304,
267,
408,
1002,
314,
1453,
5246,
334,
692,
3964,
9,
398,
961,
1233,
1990,
26266,
687,
1413,
41,
3465,
14,
710,
4132,
12,
1488,
22267,
11545,
812,
4651,
544,
90,
699,
3624,
8076,
965,
267,
1627,
5027,
4983,
367,
642,
1233,
370,
506,
18233,
1334,
6289,
14,
710,
267,
16582,
883,
506,
1911,
2348,
4178,
921,
5031,
14,
957,
15,
10274,
9587,
15,
422,
1237,
15,
10115,
15,
17,
267,
408,
267,
340,
291,
14,
826,
63,
493,
365,
488,
26,
288,
372,
488,
398,
5496,
63,
694,
275,
291,
14,
2491,
63,
694,
342,
2728,
5246,
63,
1760,
275,
283,
3187,
1553,
3187,
13,
694,
450,
83,
8083,
3187,
6822,
13,
1122,
1553,
31349,
13,
1121,
13053,
7,
450,
60,
288,
334,
4600,
63,
694,
9,
267,
5246,
63,
79,
12,
5246,
63,
69,
12,
5246,
63,
82,
275,
291,
14,
422,
1237,
63,
2253,
63,
1250,
8,
4694,
63,
1760,
9,
267,
6135,
63,
4694,
275,
5246,
63,
79,
14,
1913,
342,
398,
340,
291,
423,
374,
63,
1078,
63,
3187,
63,
29124,
8,
3187,
63,
4694,
304,
288,
372,
6135,
63,
4694,
267,
587,
26,
288,
372,
488,
339,
347,
6135,
63,
4835,
17,
8,
277,
12,
14547,
29,
549,
304,
267,
408,
1002,
314,
1453,
6135,
12002,
17,
334,
692,
3964,
9,
398,
961,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,
1,
1,
1,
1,
1,
1,
1
] |
guijomatos/SickRage
|
lib/github/tests/Github_.py
|
39
|
17733
|
# -*- coding: utf-8 -*-
# ########################## Copyrights and license ############################
# #
# Copyright 2012 Vincent Jacques <vincent@vincent-jacques.net> #
# Copyright 2012 Zearin <zearin@gonk.net> #
# Copyright 2013 Vincent Jacques <vincent@vincent-jacques.net> #
# #
# This file is part of PyGithub. http://jacquev6.github.com/PyGithub/ #
# #
# PyGithub is free software: you can redistribute it and/or modify it under #
# the terms of the GNU Lesser General Public License as published by the Free #
# Software Foundation, either version 3 of the License, or (at your option) #
# any later version. #
# #
# PyGithub 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 PyGithub. If not, see <http://www.gnu.org/licenses/>. #
# #
# ##############################################################################
import datetime
import Framework
import github
class Github(Framework.TestCase):
def testGetGists(self):
self.assertListKeyBegin(self.g.get_gists(), lambda g: g.id, ["2729695", "2729656", "2729597", "2729584", "2729569", "2729554", "2729543", "2729537", "2729536", "2729533", "2729525", "2729522", "2729519", "2729515", "2729506", "2729487", "2729484", "2729482", "2729441", "2729432", "2729420", "2729398", "2729372", "2729371", "2729351", "2729346", "2729316", "2729304", "2729296", "2729276", "2729272", "2729265", "2729195", "2729160", "2729143", "2729127", "2729119", "2729113", "2729103", "2729069", "2729059", "2729051", "2729029", "2729027", "2729026", "2729022", "2729002", "2728985", "2728979", "2728964", "2728937", "2728933", "2728884", "2728869", "2728866", "2728855", "2728854", "2728853", "2728846", "2728825", "2728814", "2728813", "2728812", "2728805", "2728802", "2728800", "2728798", "2728797", "2728796", "2728793", "2728758", "2728754", "2728751", "2728748", "2728721", "2728716", "2728715", "2728705", "2728701", "2728699", "2728697", "2728688", "2728683", "2728677", "2728649", "2728640", "2728625", "2728620", "2728615", "2728614", "2728565", "2728564", "2728554", "2728523", "2728519", "2728511", "2728497", "2728496", "2728495", "2728487"])
def testLegacySearchRepos(self):
repos = self.g.legacy_search_repos("github api v3")
self.assertListKeyBegin(repos, lambda r: r.name, ["github", "octonode", "PyGithub"])
self.assertEqual(repos[0].full_name, "peter-murach/github")
# Attributes retrieved from legacy API without lazy completion call
self.assertEqual(repos[2].created_at, datetime.datetime(2012, 2, 25, 12, 53, 47))
self.assertEqual(repos[2].name, "PyGithub")
self.assertEqual(repos[2].watchers, 365)
self.assertTrue(repos[2].has_downloads)
self.assertEqual(repos[2].homepage, "http://jacquev6.github.io/PyGithub")
self.assertEqual(repos[2].url, "/repos/jacquev6/PyGithub")
self.assertFalse(repos[2].fork)
self.assertTrue(repos[2].has_issues)
self.assertFalse(repos[2].has_wiki)
self.assertEqual(repos[2].forks, 102)
self.assertEqual(repos[2].size, 11373)
self.assertFalse(repos[2].private)
self.assertEqual(repos[2].open_issues, 14)
self.assertEqual(repos[2].pushed_at, datetime.datetime(2014, 3, 16, 17, 1, 56))
self.assertEqual(repos[2].description, "Python library implementing the full Github API v3")
self.assertEqual(repos[2].language, "Python")
self.assertEqual(repos[2].owner.login, "jacquev6")
self.assertEqual(repos[2].owner.url, "/users/jacquev6")
def testLegacySearchReposPagination(self):
repos = self.g.legacy_search_repos("document")
self.assertListKeyBegin(repos, lambda r: r.name, ["git", "nimbus", "kss", "sstoolkit", "lawnchair", "appledoc", "jQ.Mobi", "ipython", "mongoengine", "ravendb", "substance", "symfony-docs", "JavaScript-Garden", "DocSets-for-iOS", "yard", "phpDocumentor2", "phpsh", "Tangle", "Ingredients", "documentjs", "xhp", "couchdb-lucene", "dox", "magento2", "javascriptmvc", "FastPdfKit", "roar", "DocumentUp", "NoRM", "jsdoc", "tagger", "mongodb-csharp", "php-github-api", "beautiful-docs", "mongodb-odm", "iodocs", "seesaw", "bcx-api", "developer.github.com", "amqp", "docsplit", "pycco", "standards-and-practices", "tidy-html5", "redis-doc", "tomdoc", "docs", "flourish", "userguide", "swagger-ui", "rfc", "Weasel-Diesel", "yuidoc", "apigen", "document-viewer", "develop.github.com", "Shanty-Mongo", "PTShowcaseViewController", "gravatar_image_tag", "api-wow-docs", "mongoid-tree", "safari-json-formatter", "mayan", "orm-documentation", "jsfiddle-docs-alpha", "core", "documentcloud", "flexible-nav", "writeCapture", "readium", "xmldocument", "Documentation-Examples", "grails-doc", "stdeb", "aws-autoscaling", "voteable_mongo", "review", "spreadsheet_on_rails", "UKSyntaxColoredTextDocument", "mandango", "bdoc", "Documentation", "documents.com", "rghost", "ticket_mule", "vendo", "khan-api", "spring-data-document-examples", "rspec_api_documentation", "axlsx", "phpdox", "documentation", "Sami", "innershiv", "doxyclean", "documents", "rvm-site", "jqapi", "documentation", "hadoopy", "VichUploaderBundle", "pdoc", "documentation", "wii-js", "oss-docs", "scala-maven-plugin", "Documents", "documenter", "behemoth", "documentation", "documentation", "propelorm.github.com", "Kobold2D", "AutoObjectDocumentation", "php-mongodb-admin", "django-mongokit", "puppet-docs", "docs", "Document", "vendorer", "symfony1-docs", "shocco", "documentation", "jog", "docs", "documentation", "documentation", "documentation", "documentation", "Documentation", "documentation", "documentation", "phpunit-documentation", "ADCtheme", "NelmioApiDocBundle", "iCloud-Singleton-CloudMe", "Documentation", "document", "document_mapper", "heroku-docs", "couchdb-odm", "documentation", "documentation", "document", "documentation", "NanoStore", "documentation", "Documentation", "documentation", "Documentation", "documentation", "document", "documentation", "documentation", "Documentation", "Documentation", "grendel", "ceylon-compiler", "mbtiles-spec", "documentation", "documents", "documents", "Documents", "Documentation", "documentation", "Documentation", "documentation", "documents", "Documentation", "documentation", "documentation", "documents", "Documentation", "documentation", "documenter", "documentation", "documents", "Documents", "documents", "documents", "documentation", "Document", "document", "rdoc", "mongoid_token", "travis-ci.github.com", "Documents", "Documents", "documents", "Document", "Documentation", "documents", "Documents", "Documentation", "documents", "documents", "documents", "documentation", "Documents", "Document", "documents", "documents", "Documentation", "Documentation", "Document", "documents", "Documents", "Documents", "Documentation", "Documents", "documents", "Documents", "document", "documents", "Documentation", "Documents", "documents", "documents", "Documents", "documents", "Documentation", "documentation", "Document", "Documents", "documents", "documents", "documents", "Documentation", "Documentation", "Documents", "Documents", "Documents", "Documenter", "document", "Documentation", "Documents", "Documents", "documentation", "documentation", "Document", "Documents", "Documentation", "Documentation", "Documents", "documents", "Documents", "document", "documentation", "Documents", "documentation", "documentation", "documentation", "Documentation", "Documents", "Documents", "documentation", "Documents", "Documents", "documentation", "documentation", "documents", "Documentation", "documents", "documentation", "Documentation", "Documents", "documentation", "documentation", "documents", "documentation", "Umbraco5Docs", "documents", "Documents", "Documentation", "documents", "document", "documents", "document", "documents", "documentation", "Documents", "documents", "document", "Documents", "Documentation", "Documentation", "documentation", "Documentation", "document", "documentation", "documents", "documents", "Documentations", "document", "documentation", "Documentation", "Document", "Documents", "Documents", "Document"])
def testLegacySearchReposExplicitPagination(self):
repos = self.g.legacy_search_repos("python")
self.assertEqual([r.name for r in repos.get_page(4)], ["assetic", "cartodb", "cuisine", "gae-sessions", "geoalchemy2", "Multicorn", "wmfr-timeline", "redis-rdb-tools", "applet-workflows", "TweetBuff", "groovy-core", "StarTrekGame", "Nuevo", "Cupid", "node-sqlserver", "Magnet2Torrent", "GroundControl", "mock-django", "4bit", "mock-django", "Fabulous", "SFML", "pydicas", "flixel", "up", "mongrel2", "SimpleHTTPServerJs", "ultimos", "Archipel", "JSbooks", "nova", "nodebox", "simplehttp", "dablooms", "solarized", "landslide", "jQuery-File-Upload", "jQuery-File-Upload", "jQuery-File-Upload", "password-manager", "electrum", "twitter_nlp", "djangbone", "pyxfst", "node-gyp", "flare", "www.gittip.com", "wymeditor", "Kokobox", "MyCQ", "runwalk", "git-sweep", "HPCPythonSC2012", "sundown", "node2dm", "statirator", "fantastic-futures", "chainsaw", "itcursos-gerenciador-tarefas", "TideSDK", "genmaybot", "melpa", "ConnectedWire", "tarantool", "anserindicus_sn", "luvit", "Minecraft-Overviewer", "Iconic", "pyist.net", "wikibok", "mejorenvo-scraper", "NewsBlur", "SocketRocket", "spf13-vim", "IWantToWorkAtGloboCom", "ruby-style-guide", "aery32-refguide", "fafsite", "compsense_demo", "enaml", "mpi4py", "fi.pycon.org", "scikits-image", "scikits-image", "uni", "mako.vim", "mako.vim", "slumber", "de-composer", "nvm", "helloshopply", "Alianza", "vimfiles", "socorro-crashstats", "menu", "analytics", "elFinder", "riak_wiki", "livestreamer", "git-goggles"])
def testLegacySearchReposWithLanguage(self):
repos = self.g.legacy_search_repos("document", language="Python")
self.assertListKeyBegin(repos, lambda r: r.name, ["ipython", "mongoengine", "tagger"])
self.assertEqual(repos[0].full_name, "ipython/ipython")
def testLegacySearchUsers(self):
users = self.g.legacy_search_users("vincent")
self.assertListKeyBegin(users, lambda u: u.login, ["nvie", "obra", "lusis"])
# Attributes retrieved from legacy API without lazy completion call
self.assertEqual(users[0].gravatar_id, "c5a7f21b46df698f3db31c37ed0cf55a")
self.assertEqual(users[0].name, "Vincent Driessen")
self.assertEqual(users[0].created_at, datetime.datetime(2009, 5, 12, 21, 19, 38))
self.assertEqual(users[0].location, "Netherlands")
self.assertEqual(users[0].followers, 310)
self.assertEqual(users[0].public_repos, 63)
self.assertEqual(users[0].login, "nvie")
def testLegacySearchUsersPagination(self):
self.assertEqual(len(list(self.g.legacy_search_users("Lucy"))), 146)
def testLegacySearchUsersExplicitPagination(self):
users = self.g.legacy_search_users("Lucy")
self.assertEqual([u.login for u in users.get_page(1)], ["lucievh", "lucyim", "Lucief", "RevolverUpstairs", "seriousprogramming", "reicul", "davincidubai", "LucianaNascimentodoPrado", "lucia-huenchunao", "kraji20", "Lucywolo", "Luciel", "sunnysummer", "elush", "oprealuci", "Flika", "lsher", "datadrivenjournalism", "nill2020", "doobi", "lucilu", "deldeldel", "lucianacocca", "lucyli-sfdc", "lucysatchell", "UBM", "kolousek", "lucyzhang", "lmegia", "luisolivo", "Lucyzhen", "Luhzinha", "beautifly", "lucybm96", "BuonocoreL", "lucywilliams", "ZxOxZ", "Motwinb", "johnlucy", "Aquanimation", "alaltaieri", "lucylin", "lucychambers", "JuanSesma", "cdwwebware", "ZachWills"])
def testLegacySearchUserByEmail(self):
user = self.g.legacy_search_user_by_email("vincent@vincent-jacques.net")
self.assertEqual(user.login, "jacquev6")
self.assertEqual(user.followers, 13)
def testGetHooks(self):
hooks = self.g.get_hooks()
hook = hooks[0]
self.assertEqual(hook.name, "activecollab")
self.assertEqual(hook.supported_events, ["push"])
self.assertEqual(hook.events, ["push"])
self.assertEqual(hook.schema, [["string", "url"], ["string", "token"], ["string", "project_id"], ["string", "milestone_id"], ["string", "category_id"]])
def testGetEmojis(self):
emojis = self.g.get_emojis()
first = emojis.get("+1")
self.assertEqual(first, "https://github.global.ssl.fastly.net/images/icons/emoji/+1.png?v5")
def testGetHook(self):
hook = self.g.get_hook("activecollab")
self.assertEqual(hook.name, "activecollab")
self.assertEqual(hook.supported_events, ["push"])
self.assertEqual(hook.events, ["push"])
self.assertEqual(hook.schema, [["string", "url"], ["string", "token"], ["string", "project_id"], ["string", "milestone_id"], ["string", "category_id"]])
def testGetRepoFromFullName(self):
self.assertEqual(self.g.get_repo("jacquev6/PyGithub").description, "Python library implementing the full Github API v3")
def testGetRepoFromId(self):
self.assertEqual(self.g.get_repo(3544490).description, "Python library implementing the full Github API v3")
def testGetGitignoreTemplates(self):
self.assertEqual(self.g.get_gitignore_templates(), ["Actionscript", "Android", "AppceleratorTitanium", "Autotools", "Bancha", "C", "C++", "CFWheels", "CMake", "CSharp", "CakePHP", "Clojure", "CodeIgniter", "Compass", "Concrete5", "Coq", "Delphi", "Django", "Drupal", "Erlang", "ExpressionEngine", "Finale", "ForceDotCom", "FuelPHP", "GWT", "Go", "Grails", "Haskell", "Java", "Jboss", "Jekyll", "Joomla", "Jython", "Kohana", "LaTeX", "Leiningen", "LemonStand", "Lilypond", "Lithium", "Magento", "Maven", "Node", "OCaml", "Objective-C", "Opa", "OracleForms", "Perl", "PlayFramework", "Python", "Qooxdoo", "Qt", "R", "Rails", "RhodesRhomobile", "Ruby", "Scala", "Sdcc", "SeamGen", "SketchUp", "SugarCRM", "Symfony", "Symfony2", "SymphonyCMS", "Target3001", "Tasm", "Textpattern", "TurboGears2", "Unity", "VB.Net", "Waf", "Wordpress", "Yii", "ZendFramework", "gcov", "nanoc", "opencart"])
def testGetGitignoreTemplate(self):
t = self.g.get_gitignore_template("Python")
self.assertEqual(t.name, "Python")
self.assertEqual(t.source, "*.py[cod]\n\n# C extensions\n*.so\n\n# Packages\n*.egg\n*.egg-info\ndist\nbuild\neggs\nparts\nbin\nvar\nsdist\ndevelop-eggs\n.installed.cfg\nlib\nlib64\n\n# Installer logs\npip-log.txt\n\n# Unit test / coverage reports\n.coverage\n.tox\nnosetests.xml\n\n# Translations\n*.mo\n\n# Mr Developer\n.mr.developer.cfg\n.project\n.pydevproject\n")
t = self.g.get_gitignore_template("C++")
self.assertEqual(t.name, "C++")
self.assertEqual(t.source, "# Compiled Object files\n*.slo\n*.lo\n*.o\n\n# Compiled Dynamic libraries\n*.so\n*.dylib\n\n# Compiled Static libraries\n*.lai\n*.la\n*.a\n")
def testStringOfNotSet(self):
self.assertEqual(str(github.GithubObject.NotSet), "NotSet")
def testGetUsers(self):
self.assertListKeyBegin(self.g.get_users(), lambda u: u.login, ["mojombo", "defunkt", "pjhyett", "wycats", "ezmobius", "ivey", "evanphx", "vanpelt", "wayneeseguin", "brynary", "kevinclark", "technoweenie", "macournoyer", "takeo", "Caged", "topfunky", "anotherjesse", "roland", "lukas", "fanvsfan", "tomtt", "railsjitsu", "nitay", "kevwil", "KirinDave", "jamesgolick", "atmos", "errfree", "mojodna", "bmizerany", "jnewland", "joshknowles", "hornbeck", "jwhitmire", "elbowdonkey", "reinh", "timocratic", "bs", "rsanheim", "schacon", "uggedal", "bruce", "sam", "mmower", "abhay", "rabble", "benburkert", "indirect", "fearoffish", "ry", "engineyard", "jsierles", "tweibley", "peimei", "brixen", "tmornini", "outerim", "daksis", "sr", "lifo", "rsl", "imownbey", "dylanegan", "jm", "willcodeforfoo", "jvantuyl", "BrianTheCoder", "freeformz", "hassox", "automatthew", "queso", "lancecarlson", "drnic", "lukesutton", "danwrong", "hcatlin", "jfrost", "mattetti", "ctennis", "lawrencepit", "marcjeanson", "grempe", "peterc", "ministrycentered", "afarnham", "up_the_irons", "evilchelu", "heavysixer", "brosner", "danielmorrison", "danielharan", "kvnsmth", "collectiveidea", "canadaduane", "nate", "dstrelau", "sunny", "dkubb", "jnicklas", "richcollins", "simonjefford"])
def testGetUsersSince(self):
self.assertListKeyBegin(self.g.get_users(since=1000), lambda u: u.login, ["sbecker"])
def testGetRepos(self):
self.assertListKeyBegin(self.g.get_repos(), lambda r: r.name, ["grit", "merb-core", "rubinius", "god", "jsawesome", "jspec", "exception_logger", "ambition"])
def testGetReposSince(self):
self.assertListKeyBegin(self.g.get_repos(since=1000), lambda r: r.name, ["jquery-humanize-messages-plugin", "4slicer", "fixture-scenarios", "mongrel_proctitle", "rails-plugins"])
|
gpl-3.0
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
199,
3,
11945,
309,
1898,
83,
436,
4190,
11945,
381,
199,
3,
26209,
327,
199,
3,
1898,
6029,
28882,
2946,
1603,
645,
19658,
665,
11908,
2946,
32,
11908,
2946,
13,
9299,
19658,
14,
846,
30,
463,
327,
199,
3,
1898,
6029,
3107,
2210,
262,
665,
806,
285,
262,
32,
27719,
75,
14,
846,
30,
32543,
327,
199,
3,
1898,
6171,
28882,
2946,
1603,
645,
19658,
665,
11908,
2946,
32,
11908,
2946,
13,
9299,
19658,
14,
846,
30,
463,
327,
199,
3,
26209,
327,
199,
3,
961,
570,
365,
1777,
402,
1611,
14772,
14,
1455,
921,
9299,
544,
86,
22,
14,
5031,
14,
957,
15,
2713,
14772,
15,
3515,
327,
199,
3,
26209,
327,
199,
3,
1611,
14772,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
652,
1334,
259,
327,
199,
3,
314,
2895,
402,
314,
1664,
6401,
1696,
1684,
844,
465,
3267,
701,
314,
2868,
221,
327,
199,
3,
2290,
2752,
12,
1902,
1015,
650,
402,
314,
844,
12,
503,
334,
292,
2195,
945,
9,
259,
327,
199,
3,
1263,
2945,
1015,
14,
2476,
13235,
327,
199,
3,
26209,
327,
199,
3,
1611,
14772,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
1325,
2428,
1821,
221,
327,
199,
3,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
3169,
503,
3092,
259,
327,
199,
3,
2381,
437,
3115,
3104,
14,
1666,
314,
1664,
6401,
1696,
1684,
844,
367,
1655,
327,
199,
3,
2436,
14,
6208,
258,
327,
199,
3,
26209,
327,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
6401,
1696,
1684,
844,
258,
327,
199,
3,
3180,
543,
1611,
14772,
14,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
3777,
327,
199,
3,
26209,
327,
199,
3,
221,
4605,
199,
199,
646,
2197,
199,
199,
646,
22545,
199,
199,
646,
12869,
421,
199,
533,
598,
4049,
8,
16442,
14,
1746,
304,
272,
347,
19970,
39,
1670,
8,
277,
304,
267,
291,
14,
16201,
1197,
5595,
8,
277,
14,
71,
14,
362,
63,
71,
1670,
1062,
2400,
486,
26,
486,
14,
344,
12,
2097,
1465,
1398,
20017,
401,
298,
1465,
11700,
1367,
401,
298,
1465,
1398,
15459,
401,
298,
1465,
11405,
1349,
401,
298,
1465,
1398,
15143,
401,
298,
1465,
1398,
19264,
401,
298,
1465,
1398,
20103,
401,
298,
1465,
11405,
1401,
401,
298,
1465,
11405,
1344,
401,
298,
1465,
11405,
1153,
401,
298,
1465,
11405,
821,
401,
298,
1465,
11405,
1081,
401,
298,
1465,
11405,
1167,
401,
298,
1465,
11405,
1046,
401,
298,
1465,
1398,
13725,
401,
298,
1465,
10693,
1555,
401,
298,
1465,
10693,
1349,
401,
298,
1465,
1398,
25270,
401,
298,
1465,
1398,
24284,
401,
298,
1465,
1398,
10657,
401,
298,
1465,
10693,
1165,
401,
298,
1465,
1398,
13944,
401,
298,
1465,
1398,
15541,
401,
298,
1465,
1398,
16124,
401,
298,
1465,
1398,
16860,
401,
298,
1465,
1398,
12583,
401,
298,
1465,
16417,
975,
401,
298,
1465,
1398,
8533,
401,
298,
1465,
1398,
11700,
401,
298,
1465,
1398,
13319,
401,
298,
1465,
1398,
12900,
401,
298,
1465,
1398,
13730,
401,
298,
1465,
1398,
11874,
401,
298,
1465,
1398,
8488,
401,
298,
1465,
1398,
12289,
401,
298,
1465,
1398,
4195,
401,
298,
1465,
1398,
7119,
401,
298,
1465,
1398,
9225,
401,
298,
1465,
1398,
8845,
401,
298,
1465,
1398,
18264,
401,
298,
1465,
15117,
1427,
401,
298,
1465,
1398,
21101,
401,
298,
1465,
1398,
13996,
401,
298,
1465,
1398,
14218,
401,
298,
1465,
1398,
14842,
401,
298,
1465,
1398,
16348,
401,
298,
1465,
1398,
7432,
401,
298,
12900,
1407,
2426,
401,
298,
12900,
1407,
1965,
401,
298,
12900,
1407,
772,
401,
298,
12900,
1407,
1401,
401,
298,
12900,
1407,
1153,
401,
298,
1465,
10740,
1349,
401,
298,
1465,
1651,
13254,
401,
298,
1465,
1651,
13465,
401,
298,
1465,
10740,
1229,
401,
298,
1465,
10740,
1477,
401,
298,
1465,
10740,
2481,
401,
298,
1465,
10740,
2466,
401,
298,
1465,
10740,
821,
401,
298,
1465,
10740,
1079,
401,
298,
1465,
10740,
969,
401,
298,
1465,
10740,
713,
401,
298,
1465,
1651,
13027,
401,
298,
1465,
10740,
996,
401,
298,
1465,
10740,
383,
401,
298,
1465,
11884,
2905,
401,
298,
1465,
11884,
2576,
401,
298,
1465,
11884,
2534,
401,
298,
1465,
11884,
3129,
401,
298,
1465,
11884,
2010,
401,
298,
1465,
11884,
1477,
401,
298,
1465,
11884,
2869,
401,
298,
1465,
1651,
18770,
401,
298,
1465,
11884,
2025,
401,
298,
1465,
11884,
975,
401,
298,
1465,
11884,
1046,
401,
298,
1465,
11884,
1717,
401,
298,
1465,
11884,
614,
401,
298,
1465,
11125,
1020,
401,
298,
1465,
11125,
2576,
401,
298,
1465,
11125,
1299,
401,
298,
1465,
11125,
2658,
401,
298,
1465,
11125,
1138,
401,
298,
1465,
1651,
11228,
401,
298,
1465,
1651,
12021,
401,
298,
1465,
11125,
821,
401,
298,
1465,
11125,
1165,
401,
298,
12900,
6973,
401,
298,
1465,
11125,
1079,
401,
298,
1465,
1651,
15670,
401,
298,
1465,
14523,
772,
401,
298,
1465,
1651,
19264,
401,
298,
1465,
14523,
1789,
401,
298,
1465,
14523,
1167,
401,
298,
1465,
14523,
845,
401,
298,
1465,
10681,
2576,
401,
298,
1465,
10681,
2534,
401,
298,
1465,
10681,
2720,
401,
298,
1465,
10681,
1555,
3135,
339,
347,
511,
22628,
5278,
497,
1712,
8,
277,
304,
267,
20416,
275,
291,
14,
71,
14,
10000,
63,
1733,
63,
11857,
480,
5031,
2986,
373,
19,
531,
267,
291,
14,
16201,
1197,
5595,
8,
11857,
12,
2400,
519,
26,
519,
14,
354,
12,
2097,
5031,
401,
298,
15560,
29118,
401,
298,
2713,
14772,
3135,
267,
291,
14,
629,
8,
11857,
59,
16,
1055,
2861,
63,
354,
12,
298,
321,
351,
13,
77,
300,
1225,
15,
5031,
531,
398,
327,
9382,
12396,
687,
12139,
3261,
1928,
9617,
13659,
1240,
267,
291,
14,
629,
8,
11857,
59,
18,
1055,
3966,
63,
292,
12,
2197,
14,
2083,
8,
7409,
12,
499,
12,
5661,
12,
3144,
12,
13564,
12,
10954,
430,
267,
291,
14,
629,
8,
11857,
59,
18,
1055,
354,
12,
298,
2713,
14772,
531,
267,
291,
14,
629,
8,
11857,
59,
18,
1055,
6821,
1192,
12,
28046,
9,
267,
291,
14,
1815,
8,
11857,
59,
18,
1055,
1989,
63,
20373,
9,
267,
291,
14,
629,
8,
11857,
59
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
199,
3,
11945,
309,
1898,
83,
436,
4190,
11945,
381,
199,
3,
26209,
327,
199,
3,
1898,
6029,
28882,
2946,
1603,
645,
19658,
665,
11908,
2946,
32,
11908,
2946,
13,
9299,
19658,
14,
846,
30,
463,
327,
199,
3,
1898,
6029,
3107,
2210,
262,
665,
806,
285,
262,
32,
27719,
75,
14,
846,
30,
32543,
327,
199,
3,
1898,
6171,
28882,
2946,
1603,
645,
19658,
665,
11908,
2946,
32,
11908,
2946,
13,
9299,
19658,
14,
846,
30,
463,
327,
199,
3,
26209,
327,
199,
3,
961,
570,
365,
1777,
402,
1611,
14772,
14,
1455,
921,
9299,
544,
86,
22,
14,
5031,
14,
957,
15,
2713,
14772,
15,
3515,
327,
199,
3,
26209,
327,
199,
3,
1611,
14772,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
652,
1334,
259,
327,
199,
3,
314,
2895,
402,
314,
1664,
6401,
1696,
1684,
844,
465,
3267,
701,
314,
2868,
221,
327,
199,
3,
2290,
2752,
12,
1902,
1015,
650,
402,
314,
844,
12,
503,
334,
292,
2195,
945,
9,
259,
327,
199,
3,
1263,
2945,
1015,
14,
2476,
13235,
327,
199,
3,
26209,
327,
199,
3,
1611,
14772,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
1325,
2428,
1821,
221,
327,
199,
3,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
3169,
503,
3092,
259,
327,
199,
3,
2381,
437,
3115,
3104,
14,
1666,
314,
1664,
6401,
1696,
1684,
844,
367,
1655,
327,
199,
3,
2436,
14,
6208,
258,
327,
199,
3,
26209,
327,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
6401,
1696,
1684,
844,
258,
327,
199,
3,
3180,
543,
1611,
14772,
14,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
3777,
327,
199,
3,
26209,
327,
199,
3,
221,
4605,
199,
199,
646,
2197,
199,
199,
646,
22545,
199,
199,
646,
12869,
421,
199,
533,
598,
4049,
8,
16442,
14,
1746,
304,
272,
347,
19970,
39,
1670,
8,
277,
304,
267,
291,
14,
16201,
1197,
5595,
8,
277,
14,
71,
14,
362,
63,
71,
1670,
1062,
2400,
486,
26,
486,
14,
344,
12,
2097,
1465,
1398,
20017,
401,
298,
1465,
11700,
1367,
401,
298,
1465,
1398,
15459,
401,
298,
1465,
11405,
1349,
401,
298,
1465,
1398,
15143,
401,
298,
1465,
1398,
19264,
401,
298,
1465,
1398,
20103,
401,
298,
1465,
11405,
1401,
401,
298,
1465,
11405,
1344,
401,
298,
1465,
11405,
1153,
401,
298,
1465,
11405,
821,
401,
298,
1465,
11405,
1081,
401,
298,
1465,
11405,
1167,
401,
298,
1465,
11405,
1046,
401,
298,
1465,
1398,
13725,
401,
298,
1465,
10693,
1555,
401,
298,
1465,
10693,
1349,
401,
298,
1465,
1398,
25270,
401,
298,
1465,
1398,
24284,
401,
298,
1465,
1398,
10657,
401,
298,
1465,
10693,
1165,
401,
298,
1465,
1398,
13944,
401,
298,
1465,
1398,
15541,
401,
298,
1465,
1398,
16124,
401,
298,
1465,
1398,
16860,
401,
298,
1465,
1398,
12583,
401,
298,
1465,
16417,
975,
401,
298,
1465,
1398,
8533,
401,
298,
1465,
1398,
11700,
401,
298,
1465,
1398,
13319,
401,
298,
1465,
1398,
12900,
401,
298,
1465,
1398,
13730,
401,
298,
1465,
1398,
11874,
401,
298,
1465,
1398,
8488,
401,
298,
1465,
1398,
12289,
401,
298,
1465,
1398,
4195,
401,
298,
1465,
1398,
7119,
401,
298,
1465,
1398,
9225,
401,
298,
1465,
1398,
8845,
401,
298,
1465,
1398,
18264,
401,
298,
1465,
15117,
1427,
401,
298,
1465,
1398,
21101,
401,
298,
1465,
1398,
13996,
401,
298,
1465,
1398,
14218,
401,
298,
1465,
1398,
14842,
401,
298,
1465,
1398,
16348,
401,
298,
1465,
1398,
7432,
401,
298,
12900,
1407,
2426,
401,
298,
12900,
1407,
1965,
401,
298,
12900,
1407,
772,
401,
298,
12900,
1407,
1401,
401,
298,
12900,
1407,
1153,
401,
298,
1465,
10740,
1349,
401,
298,
1465,
1651,
13254,
401,
298,
1465,
1651,
13465,
401,
298,
1465,
10740,
1229,
401,
298,
1465,
10740,
1477,
401,
298,
1465,
10740,
2481,
401,
298,
1465,
10740,
2466,
401,
298,
1465,
10740,
821,
401,
298,
1465,
10740,
1079,
401,
298,
1465,
10740,
969,
401,
298,
1465,
10740,
713,
401,
298,
1465,
1651,
13027,
401,
298,
1465,
10740,
996,
401,
298,
1465,
10740,
383,
401,
298,
1465,
11884,
2905,
401,
298,
1465,
11884,
2576,
401,
298,
1465,
11884,
2534,
401,
298,
1465,
11884,
3129,
401,
298,
1465,
11884,
2010,
401,
298,
1465,
11884,
1477,
401,
298,
1465,
11884,
2869,
401,
298,
1465,
1651,
18770,
401,
298,
1465,
11884,
2025,
401,
298,
1465,
11884,
975,
401,
298,
1465,
11884,
1046,
401,
298,
1465,
11884,
1717,
401,
298,
1465,
11884,
614,
401,
298,
1465,
11125,
1020,
401,
298,
1465,
11125,
2576,
401,
298,
1465,
11125,
1299,
401,
298,
1465,
11125,
2658,
401,
298,
1465,
11125,
1138,
401,
298,
1465,
1651,
11228,
401,
298,
1465,
1651,
12021,
401,
298,
1465,
11125,
821,
401,
298,
1465,
11125,
1165,
401,
298,
12900,
6973,
401,
298,
1465,
11125,
1079,
401,
298,
1465,
1651,
15670,
401,
298,
1465,
14523,
772,
401,
298,
1465,
1651,
19264,
401,
298,
1465,
14523,
1789,
401,
298,
1465,
14523,
1167,
401,
298,
1465,
14523,
845,
401,
298,
1465,
10681,
2576,
401,
298,
1465,
10681,
2534,
401,
298,
1465,
10681,
2720,
401,
298,
1465,
10681,
1555,
3135,
339,
347,
511,
22628,
5278,
497,
1712,
8,
277,
304,
267,
20416,
275,
291,
14,
71,
14,
10000,
63,
1733,
63,
11857,
480,
5031,
2986,
373,
19,
531,
267,
291,
14,
16201,
1197,
5595,
8,
11857,
12,
2400,
519,
26,
519,
14,
354,
12,
2097,
5031,
401,
298,
15560,
29118,
401,
298,
2713,
14772,
3135,
267,
291,
14,
629,
8,
11857,
59,
16,
1055,
2861,
63,
354,
12,
298,
321,
351,
13,
77,
300,
1225,
15,
5031,
531,
398,
327,
9382,
12396,
687,
12139,
3261,
1928,
9617,
13659,
1240,
267,
291,
14,
629,
8,
11857,
59,
18,
1055,
3966,
63,
292,
12,
2197,
14,
2083,
8,
7409,
12,
499,
12,
5661,
12,
3144,
12,
13564,
12,
10954,
430,
267,
291,
14,
629,
8,
11857,
59,
18,
1055,
354,
12,
298,
2713,
14772,
531,
267,
291,
14,
629,
8,
11857,
59,
18,
1055,
6821,
1192,
12,
28046,
9,
267,
291,
14,
1815,
8,
11857,
59,
18,
1055,
1989,
63,
20373,
9,
267,
291,
14,
629,
8,
11857,
59,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
pwmarcz/django
|
tests/model_regress/test_pickle.py
|
31
|
2132
|
import pickle
import warnings
from django.db import models, DJANGO_VERSION_PICKLE_KEY
from django.test import TestCase
from django.utils.encoding import force_text
from django.utils.version import get_major_version, get_version
class ModelPickleTestCase(TestCase):
def test_missing_django_version_unpickling(self):
"""
#21430 -- Verifies a warning is raised for models that are
unpickled without a Django version
"""
class MissingDjangoVersion(models.Model):
title = models.CharField(max_length=10)
def __reduce__(self):
reduce_list = super(MissingDjangoVersion, self).__reduce__()
data = reduce_list[-1]
del data[DJANGO_VERSION_PICKLE_KEY]
return reduce_list
p = MissingDjangoVersion(title="FooBar")
with warnings.catch_warnings(record=True) as recorded:
pickle.loads(pickle.dumps(p))
msg = force_text(recorded.pop().message)
self.assertEqual(msg,
"Pickled model instance's Django version is not specified.")
def test_unsupported_unpickle(self):
"""
#21430 -- Verifies a warning is raised for models that are
unpickled with a different Django version than the current
"""
class DifferentDjangoVersion(models.Model):
title = models.CharField(max_length=10)
def __reduce__(self):
reduce_list = super(DifferentDjangoVersion, self).__reduce__()
data = reduce_list[-1]
data[DJANGO_VERSION_PICKLE_KEY] = str(float(get_major_version()) - 0.1)
return reduce_list
p = DifferentDjangoVersion(title="FooBar")
with warnings.catch_warnings(record=True) as recorded:
pickle.loads(pickle.dumps(p))
msg = force_text(recorded.pop().message)
self.assertEqual(msg,
"Pickled model instance's Django version %s does not "
"match the current version %s."
% (str(float(get_major_version()) - 0.1), get_version()))
|
bsd-3-clause
|
[
646,
5927,
199,
646,
3598,
199,
199,
504,
1639,
14,
697,
492,
1709,
12,
577,
42,
18822,
63,
4612,
63,
48,
13884,
906,
63,
3078,
199,
504,
1639,
14,
396,
492,
7640,
199,
504,
1639,
14,
1208,
14,
2991,
492,
3542,
63,
505,
199,
504,
1639,
14,
1208,
14,
1023,
492,
664,
63,
8452,
63,
1023,
12,
664,
63,
1023,
421,
199,
533,
5822,
12755,
1746,
8,
1746,
304,
272,
347,
511,
63,
4752,
63,
1176,
63,
1023,
63,
324,
24773,
8,
277,
304,
267,
408,
267,
327,
6886,
1216,
1553,
26114,
282,
5721,
365,
4915,
367,
1709,
626,
787,
267,
625,
20428,
1928,
282,
5634,
1015,
267,
408,
267,
1021,
15626,
9323,
3353,
8,
992,
14,
1685,
304,
288,
2538,
275,
1709,
14,
2183,
8,
988,
63,
1267,
29,
709,
9,
953,
347,
636,
5270,
721,
277,
304,
355,
7114,
63,
513,
275,
1613,
8,
7718,
9323,
3353,
12,
291,
2843,
5270,
4533,
355,
666,
275,
7114,
63,
513,
1988,
17,
61,
355,
2150,
666,
59,
22848,
63,
4612,
63,
48,
13884,
906,
63,
3078,
61,
355,
372,
7114,
63,
513,
398,
299,
275,
15626,
9323,
3353,
8,
1213,
628,
5686,
5281,
531,
267,
543,
3598,
14,
9341,
63,
5451,
8,
3059,
29,
549,
9,
465,
18894,
26,
288,
5927,
14,
3640,
8,
8092,
14,
4180,
8,
80,
430,
288,
1499,
275,
3542,
63,
505,
8,
264,
15402,
14,
1935,
1252,
1188,
9,
288,
291,
14,
629,
8,
1328,
12,
355,
298,
8587,
1146,
1402,
1256,
1159,
5634,
1015,
365,
440,
2013,
2685,
339,
347,
511,
63,
15267,
63,
324,
8092,
8,
277,
304,
267,
408,
267,
327,
6886,
1216,
1553,
26114,
282,
5721,
365,
4915,
367,
1709,
626,
787,
267,
625,
20428,
543,
282,
3365,
5634,
1015,
2419,
314,
1453,
267,
408,
267,
1021,
18029,
640,
9323,
3353,
8,
992,
14,
1685,
304,
288,
2538,
275,
1709,
14,
2183,
8,
988,
63,
1267,
29,
709,
9,
953,
347,
636,
5270,
721,
277,
304,
355,
7114,
63,
513,
275,
1613,
8,
31409,
9323,
3353,
12,
291,
2843,
5270,
4533,
355,
666,
275,
7114,
63,
513,
1988,
17,
61,
355,
666,
59,
22848,
63,
4612,
63,
48,
13884,
906,
63,
3078,
61,
275,
620,
8,
1609,
8,
362,
63,
8452,
63,
1023,
1012,
446,
378,
14,
17,
9,
355,
372,
7114,
63,
513,
398,
299,
275,
18029,
640,
9323,
3353,
8,
1213,
628,
5686,
5281,
531,
267,
543,
3598,
14,
9341,
63,
5451,
8,
3059,
29,
549,
9,
465,
18894,
26,
288,
5927,
14,
3640,
8,
8092,
14,
4180,
8,
80,
430,
288,
1499,
275,
3542,
63,
505,
8,
264,
15402,
14,
1935,
1252,
1188,
9,
288,
291,
14,
629,
8,
1328,
12,
355,
298,
8587,
1146,
1402,
1256,
1159,
5634,
1015,
450,
83,
1630,
440,
298,
355,
298,
1431,
314,
1453,
1015,
450,
83,
2122,
355,
450,
334,
495,
8,
1609,
8,
362,
63,
8452,
63,
1023,
1012,
446,
378,
14,
17,
395,
664,
63,
1023,
4059,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
5927,
199,
646,
3598,
199,
199,
504,
1639,
14,
697,
492,
1709,
12,
577,
42,
18822,
63,
4612,
63,
48,
13884,
906,
63,
3078,
199,
504,
1639,
14,
396,
492,
7640,
199,
504,
1639,
14,
1208,
14,
2991,
492,
3542,
63,
505,
199,
504,
1639,
14,
1208,
14,
1023,
492,
664,
63,
8452,
63,
1023,
12,
664,
63,
1023,
421,
199,
533,
5822,
12755,
1746,
8,
1746,
304,
272,
347,
511,
63,
4752,
63,
1176,
63,
1023,
63,
324,
24773,
8,
277,
304,
267,
408,
267,
327,
6886,
1216,
1553,
26114,
282,
5721,
365,
4915,
367,
1709,
626,
787,
267,
625,
20428,
1928,
282,
5634,
1015,
267,
408,
267,
1021,
15626,
9323,
3353,
8,
992,
14,
1685,
304,
288,
2538,
275,
1709,
14,
2183,
8,
988,
63,
1267,
29,
709,
9,
953,
347,
636,
5270,
721,
277,
304,
355,
7114,
63,
513,
275,
1613,
8,
7718,
9323,
3353,
12,
291,
2843,
5270,
4533,
355,
666,
275,
7114,
63,
513,
1988,
17,
61,
355,
2150,
666,
59,
22848,
63,
4612,
63,
48,
13884,
906,
63,
3078,
61,
355,
372,
7114,
63,
513,
398,
299,
275,
15626,
9323,
3353,
8,
1213,
628,
5686,
5281,
531,
267,
543,
3598,
14,
9341,
63,
5451,
8,
3059,
29,
549,
9,
465,
18894,
26,
288,
5927,
14,
3640,
8,
8092,
14,
4180,
8,
80,
430,
288,
1499,
275,
3542,
63,
505,
8,
264,
15402,
14,
1935,
1252,
1188,
9,
288,
291,
14,
629,
8,
1328,
12,
355,
298,
8587,
1146,
1402,
1256,
1159,
5634,
1015,
365,
440,
2013,
2685,
339,
347,
511,
63,
15267,
63,
324,
8092,
8,
277,
304,
267,
408,
267,
327,
6886,
1216,
1553,
26114,
282,
5721,
365,
4915,
367,
1709,
626,
787,
267,
625,
20428,
543,
282,
3365,
5634,
1015,
2419,
314,
1453,
267,
408,
267,
1021,
18029,
640,
9323,
3353,
8,
992,
14,
1685,
304,
288,
2538,
275,
1709,
14,
2183,
8,
988,
63,
1267,
29,
709,
9,
953,
347,
636,
5270,
721,
277,
304,
355,
7114,
63,
513,
275,
1613,
8,
31409,
9323,
3353,
12,
291,
2843,
5270,
4533,
355,
666,
275,
7114,
63,
513,
1988,
17,
61,
355,
666,
59,
22848,
63,
4612,
63,
48,
13884,
906,
63,
3078,
61,
275,
620,
8,
1609,
8,
362,
63,
8452,
63,
1023,
1012,
446,
378,
14,
17,
9,
355,
372,
7114,
63,
513,
398,
299,
275,
18029,
640,
9323,
3353,
8,
1213,
628,
5686,
5281,
531,
267,
543,
3598,
14,
9341,
63,
5451,
8,
3059,
29,
549,
9,
465,
18894,
26,
288,
5927,
14,
3640,
8,
8092,
14,
4180,
8,
80,
430,
288,
1499,
275,
3542,
63,
505,
8,
264,
15402,
14,
1935,
1252,
1188,
9,
288,
291,
14,
629,
8,
1328,
12,
355,
298,
8587,
1146,
1402,
1256,
1159,
5634,
1015,
450,
83,
1630,
440,
298,
355,
298,
1431,
314,
1453,
1015,
450,
83,
2122,
355,
450,
334,
495,
8,
1609,
8,
362,
63,
8452,
63,
1023,
1012,
446,
378,
14,
17,
395,
664,
63,
1023,
4059,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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
] |
ybellavance/python-for-android
|
python3-alpha/python3-src/Lib/test/test_xmlrpc_net.py
|
49
|
1962
|
#!/usr/bin/env python3
import collections
import errno
import socket
import sys
import unittest
from test import support
import xmlrpc.client as xmlrpclib
class CurrentTimeTest(unittest.TestCase):
def test_current_time(self):
# Get the current time from xmlrpc.com. This code exercises
# the minimal HTTP functionality in xmlrpclib.
server = xmlrpclib.ServerProxy("http://time.xmlrpc.com/RPC2")
try:
t0 = server.currentTime.getCurrentTime()
except socket.error as e:
self.skipTest("network error: %s" % e)
return
# Perform a minimal sanity check on the result, just to be sure
# the request means what we think it means.
t1 = xmlrpclib.DateTime()
dt0 = xmlrpclib._datetime_type(t0.value)
dt1 = xmlrpclib._datetime_type(t1.value)
if dt0 > dt1:
delta = dt0 - dt1
else:
delta = dt1 - dt0
# The difference between the system time here and the system
# time on the server should not be too big.
self.assertTrue(delta.days <= 1)
def test_python_builders(self):
# Get the list of builders from the XMLRPC buildbot interface at
# python.org.
self.skipTest("XMLRPC interface removed in Buildbot 0.8.2")
server = xmlrpclib.ServerProxy("http://www.python.org/dev/buildbot/all/xmlrpc/")
try:
builders = server.getAllBuilders()
except socket.error as e:
self.skipTest("network error: %s" % e)
return
# Perform a minimal sanity check on the result, just to be sure
# the request means what we think it means.
self.assertIsInstance(builders, collections.Sequence)
self.assertTrue([x for x in builders if "3.x" in x], builders)
def test_main():
support.requires("network")
support.run_unittest(CurrentTimeTest)
if __name__ == "__main__":
test_main()
|
apache-2.0
|
[
3381,
2647,
15,
1393,
15,
1813,
2366,
19,
199,
199,
646,
5055,
199,
646,
7554,
199,
646,
2838,
199,
646,
984,
199,
646,
2882,
199,
504,
511,
492,
2291,
199,
199,
646,
15432,
14,
1258,
465,
19122,
199,
199,
533,
9338,
1366,
774,
8,
2796,
14,
1746,
304,
339,
347,
511,
63,
1818,
63,
521,
8,
277,
304,
267,
327,
2372,
314,
1453,
900,
687,
15432,
14,
957,
14,
221,
961,
1233,
444,
281,
559,
874,
267,
327,
314,
13460,
3101,
9330,
315,
19122,
14,
267,
1654,
275,
19122,
14,
3120,
4936,
480,
1014,
921,
521,
14,
17596,
14,
957,
15,
8171,
18,
531,
267,
862,
26,
288,
307,
16,
275,
1654,
14,
1818,
1366,
14,
16662,
1366,
342,
267,
871,
2838,
14,
705,
465,
325,
26,
288,
291,
14,
23809,
480,
1200,
1125,
26,
450,
83,
2,
450,
325,
9,
288,
372,
398,
327,
14795,
282,
13460,
16740,
1104,
641,
314,
754,
12,
2951,
370,
506,
3238,
267,
327,
314,
1056,
4910,
4052,
781,
13516,
652,
4910,
14,
267,
307,
17,
275,
19122,
14,
3926,
342,
398,
4487,
16,
275,
19122,
423,
2083,
63,
466,
8,
84,
16,
14,
585,
9,
267,
4487,
17,
275,
19122,
423,
2083,
63,
466,
8,
84,
17,
14,
585,
9,
267,
340,
4487,
16,
690,
4487,
17,
26,
288,
5762,
275,
4487,
16,
446,
4487,
17,
267,
587,
26,
288,
5762,
275,
4487,
17,
446,
4487,
16,
267,
327,
710,
8865,
3382,
314,
2656,
900,
2348,
436,
314,
2656,
267,
327,
900,
641,
314,
1654,
1077,
440,
506,
4634,
7282,
14,
267,
291,
14,
1815,
8,
3136,
14,
4899,
2695,
413,
9,
339,
347,
511,
63,
1548,
63,
20968,
8,
277,
304,
267,
327,
2372,
314,
769,
402,
27378,
687,
314,
4692,
8171,
21306,
3217,
737,
267,
327,
2366,
14,
1308,
14,
267,
291,
14,
23809,
480,
27026,
3217,
4829,
315,
6516,
3018,
378,
14,
24,
14,
18,
531,
267,
1654,
275,
19122,
14,
3120,
4936,
480,
1014,
921,
1544,
14,
1548,
14,
1308,
15,
2374,
15,
25497,
15,
452,
15,
17596,
13589,
267,
862,
26,
288,
27378,
275,
1654,
14,
31359,
6437,
83,
342,
267,
871,
2838,
14,
705,
465,
325,
26,
288,
291,
14,
23809,
480,
1200,
1125,
26,
450,
83,
2,
450,
325,
9,
288,
372,
398,
327,
14795,
282,
13460,
16740,
1104,
641,
314,
754,
12,
2951,
370,
506,
3238,
267,
327,
314,
1056,
4910,
4052,
781,
13516,
652,
4910,
14,
267,
291,
14,
6926,
8,
20968,
12,
5055,
14,
5826,
9,
267,
291,
14,
1815,
779,
88,
367,
671,
315,
27378,
340,
298,
19,
14,
88,
2,
315,
671,
467,
27378,
9,
421,
199,
318,
511,
63,
973,
837,
272,
2291,
14,
6537,
480,
1200,
531,
272,
2291,
14,
1065,
63,
2796,
8,
5639,
1366,
774,
9,
199,
199,
692,
636,
354,
363,
508,
4396,
973,
5727,
272,
511,
63,
973,
342,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,
19,
199,
199,
646,
5055,
199,
646,
7554,
199,
646,
2838,
199,
646,
984,
199,
646,
2882,
199,
504,
511,
492,
2291,
199,
199,
646,
15432,
14,
1258,
465,
19122,
199,
199,
533,
9338,
1366,
774,
8,
2796,
14,
1746,
304,
339,
347,
511,
63,
1818,
63,
521,
8,
277,
304,
267,
327,
2372,
314,
1453,
900,
687,
15432,
14,
957,
14,
221,
961,
1233,
444,
281,
559,
874,
267,
327,
314,
13460,
3101,
9330,
315,
19122,
14,
267,
1654,
275,
19122,
14,
3120,
4936,
480,
1014,
921,
521,
14,
17596,
14,
957,
15,
8171,
18,
531,
267,
862,
26,
288,
307,
16,
275,
1654,
14,
1818,
1366,
14,
16662,
1366,
342,
267,
871,
2838,
14,
705,
465,
325,
26,
288,
291,
14,
23809,
480,
1200,
1125,
26,
450,
83,
2,
450,
325,
9,
288,
372,
398,
327,
14795,
282,
13460,
16740,
1104,
641,
314,
754,
12,
2951,
370,
506,
3238,
267,
327,
314,
1056,
4910,
4052,
781,
13516,
652,
4910,
14,
267,
307,
17,
275,
19122,
14,
3926,
342,
398,
4487,
16,
275,
19122,
423,
2083,
63,
466,
8,
84,
16,
14,
585,
9,
267,
4487,
17,
275,
19122,
423,
2083,
63,
466,
8,
84,
17,
14,
585,
9,
267,
340,
4487,
16,
690,
4487,
17,
26,
288,
5762,
275,
4487,
16,
446,
4487,
17,
267,
587,
26,
288,
5762,
275,
4487,
17,
446,
4487,
16,
267,
327,
710,
8865,
3382,
314,
2656,
900,
2348,
436,
314,
2656,
267,
327,
900,
641,
314,
1654,
1077,
440,
506,
4634,
7282,
14,
267,
291,
14,
1815,
8,
3136,
14,
4899,
2695,
413,
9,
339,
347,
511,
63,
1548,
63,
20968,
8,
277,
304,
267,
327,
2372,
314,
769,
402,
27378,
687,
314,
4692,
8171,
21306,
3217,
737,
267,
327,
2366,
14,
1308,
14,
267,
291,
14,
23809,
480,
27026,
3217,
4829,
315,
6516,
3018,
378,
14,
24,
14,
18,
531,
267,
1654,
275,
19122,
14,
3120,
4936,
480,
1014,
921,
1544,
14,
1548,
14,
1308,
15,
2374,
15,
25497,
15,
452,
15,
17596,
13589,
267,
862,
26,
288,
27378,
275,
1654,
14,
31359,
6437,
83,
342,
267,
871,
2838,
14,
705,
465,
325,
26,
288,
291,
14,
23809,
480,
1200,
1125,
26,
450,
83,
2,
450,
325,
9,
288,
372,
398,
327,
14795,
282,
13460,
16740,
1104,
641,
314,
754,
12,
2951,
370,
506,
3238,
267,
327,
314,
1056,
4910,
4052,
781,
13516,
652,
4910,
14,
267,
291,
14,
6926,
8,
20968,
12,
5055,
14,
5826,
9,
267,
291,
14,
1815,
779,
88,
367,
671,
315,
27378,
340,
298,
19,
14,
88,
2,
315,
671,
467,
27378,
9,
421,
199,
318,
511,
63,
973,
837,
272,
2291,
14,
6537,
480,
1200,
531,
272,
2291,
14,
1065,
63,
2796,
8,
5639,
1366,
774,
9,
199,
199,
692,
636,
354,
363,
508,
4396,
973,
5727,
272,
511,
63,
973,
342,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
marble/Toolchain_RenderDocumentation
|
12-Get-ready-for-the-project/run_35-Define-general-values.py
|
1
|
8699
|
#!/usr/bin/env python
# coding: utf-8
from __future__ import print_function
from __future__ import absolute_import
import os
import sys
import tct
from tct import deepget
ospj = os.path.join
params = tct.readjson(sys.argv[1])
facts = tct.readjson(params['factsfile'])
milestones = tct.readjson(params['milestonesfile'])
reason = ''
resultfile = params['resultfile']
result = tct.readjson(resultfile)
toolname = params['toolname']
toolname_pure = params['toolname_pure']
toolchain_name = facts['toolchain_name']
workdir = params['workdir']
loglist = result['loglist'] = result.get('loglist', [])
exitcode = CONTINUE = 0
# ==================================================
# Make a copy of milestones for later inspection?
# --------------------------------------------------
if 0 or milestones.get('debug_always_make_milestones_snapshot'):
tct.make_snapshot_of_milestones(params['milestonesfile'], sys.argv[1])
# ==================================================
# Helper functions
# --------------------------------------------------
def firstNotNone(*args):
for arg in args:
if arg is not None:
return arg
else:
return None
def lookup(D, *keys, **kwdargs):
result = deepget(D, *keys, **kwdargs)
loglist.append((keys, result))
return result
def findRunParameter(key, default=None, D=None):
result = firstNotNone(
deepget(milestones, key, default=None),
deepget(facts, 'run_command', key, default=None),
deepget(milestones, 'jobfile_data', 'tctconfig', key, default=None),
deepget(facts, 'tctconfig', configset, key, default=None),
default,
None)
# deliberate side effect
if isinstance(D, dict):
D[key] = result
return result
ATNM = all_the_new_milestones = {}
# ==================================================
# define
# --------------------------------------------------
# buildsettings_builddir_root = /ALL/dummy_webroot
buildsettings_builddir = ''
checksum_ttl_seconds = 86400 * 7 # render if last checksum calculation is older
gitdir_must_start_with = '/home/mbless/HTDOCS/:/home/marble/Repositories/:/tmp/'
lockfile_ttl_seconds = 1800
relative_part_of_builddir = ''
TheProjectCacheDir = None
url_of_webroot = 'https://docs.typo3.org/'
webroot_abspath = '/ALL/dummy_webroot'
xeq_name_cnt = 0
email_user_do_not_send = 0
email_user_receivers_exlude_list = [
'documentation@typo3.org',
'info@typo3.org',
'kasperYYYY@typo3.com',
'kasperYYYY@typo3.org',
]
general_string_options = (
('conf_py_masterfile', ''),
('email_admin', 'martin.bless@gmail.com'),
('email_user_bcc', ''),
('email_user_cc', ''),
('email_user_to_instead', ''),
('oo_parser', 'dl'), # dl | flt
)
general_int_options = (
('email_admin_send_extra_mail', 0),
('email_user_do_not_send', 0),
('make_latex', 1),
('make_package', 1),
('make_pdf', 1),
('make_singlehtml', 1),
('rebuild_needed', 0),
('replace_static_in_html', 0),
)
general_csvlist_options = (
('email_user_receivers_exlude_list', ''),
)
SYMLINK_THE_MAKEDIR = None
SYMLINK_THE_OUTPUT = None
SYMLINK_THE_PROJECT = None
# ==================================================
# Check params
# --------------------------------------------------
if exitcode == CONTINUE:
loglist.append('CHECK PARAMS')
# relative_part_of_builddir = lookup(facts, 'tctconfig', configset, 'relative_part_of_builddir', default=relative_part_of_builddir)
buildsettings_builddir = lookup(milestones, 'buildsettings', 'builddir', default=buildsettings_builddir)
configset = lookup(milestones, 'configset')
makedir_abspath = lookup(milestones, 'makedir_abspath')
url_of_webroot = lookup(facts, 'tctconfig', 'configset', 'url_of_webroot', default=url_of_webroot)
webroot_abspath = lookup(facts, 'tctconfig', 'configset', 'webroot_abspath', default=webroot_abspath)
if not (1
and buildsettings_builddir
and configset
and makedir_abspath
and url_of_webroot
and webroot_abspath
):
exitcode = 22
reason = 'Bad PARAMS or nothing to do'
if exitcode == CONTINUE:
loglist.append('PARAMS are ok')
else:
loglist.append('Bad PARAMS or nothing to do')
# ==================================================
# work
# --------------------------------------------------
if exitcode == CONTINUE:
resultdir = lookup(milestones, 'resultdir')
if resultdir:
TheProjectCacheDir = ospj(resultdir, 'Cache')
if exitcode == CONTINUE:
for option, default in general_int_options:
v = findRunParameter(option, default)
if v is not None:
result['MILESTONES'].append({option: int(v)})
for option, default in general_string_options:
v = findRunParameter(option, default)
if v is not None:
result['MILESTONES'].append({option: v})
for option, default in general_csvlist_options:
v = findRunParameter(option, default)
if v is not None:
v = v.replace(' ', ',').split(',')
v = [item for item in v if item]
result['MILESTONES'].append({option: v})
if exitcode == CONTINUE:
# Determine relative_part_of_builddir.
# Example: typo3cms/Project/default/0.0.0
if not relative_part_of_builddir:
if buildsettings_builddir.startswith(webroot_abspath):
relative_part_of_builddir = buildsettings_builddir[len(webroot_abspath):]
else:
relative_part_of_builddir = buildsettings_builddir
relative_part_of_builddir = relative_part_of_builddir.strip('/')
SYMLINK_THE_MAKEDIR = ospj(makedir_abspath, 'SYMLINK_THE_MAKEDIR')
SYMLINK_THE_OUTPUT = ospj(makedir_abspath, 'SYMLINK_THE_OUTPUT')
SYMLINK_THE_PROJECT = ospj(makedir_abspath, 'SYMLINK_THE_PROJECT')
# ==================================================
# Set MILESTONE
# --------------------------------------------------
if buildsettings_builddir:
result['MILESTONES'].append({'buildsettings_builddir': buildsettings_builddir})
if checksum_ttl_seconds:
result['MILESTONES'].append({'checksum_ttl_seconds': checksum_ttl_seconds})
if email_user_do_not_send:
result['MILESTONES'].append({'email_user_do_not_send': email_user_do_not_send})
if email_user_receivers_exlude_list:
result['MILESTONES'].append({'email_user_receivers_exlude_list': email_user_receivers_exlude_list})
if lockfile_ttl_seconds:
result['MILESTONES'].append({'lockfile_ttl_seconds': lockfile_ttl_seconds})
if TheProjectCacheDir:
result['MILESTONES'].append({'TheProjectCacheDir': TheProjectCacheDir})
if relative_part_of_builddir:
result['MILESTONES'].append({'relative_part_of_builddir': relative_part_of_builddir})
if url_of_webroot:
result['MILESTONES'].append({'url_of_webroot': url_of_webroot})
if webroot_abspath:
result['MILESTONES'].append({'webroot_abspath': webroot_abspath})
if gitdir_must_start_with:
result['MILESTONES'].append({'gitdir_must_start_with': gitdir_must_start_with})
if SYMLINK_THE_MAKEDIR:
result['MILESTONES'].append({'SYMLINK_THE_MAKEDIR': SYMLINK_THE_MAKEDIR})
if SYMLINK_THE_OUTPUT:
result['MILESTONES'].append({'SYMLINK_THE_OUTPUT': SYMLINK_THE_OUTPUT})
if SYMLINK_THE_PROJECT:
result['MILESTONES'].append({'SYMLINK_THE_PROJECT': SYMLINK_THE_PROJECT})
# ==================================================
# save result
# --------------------------------------------------
tct.save_the_result(result, resultfile, params, facts, milestones, exitcode, CONTINUE, reason)
# ==================================================
# Return with proper exitcode
# --------------------------------------------------
sys.exit(exitcode)
"""
[general]
temp_home = /tmp
toolchains_home = /ALL/Toolchains/
[default]
buildsettings_builddir_root = /ALL/dummy_webroot
webroot_part_of_builddir = /ALL/dummy_webroot
webroot_abspath = /ALL/dummy_webroot
htaccess_template_show_latest = /ALL/Makedir/_htaccess
conf_py_masterfile = /ALL/Makedir/conf.py
repositories_rootfolder = /tmp/T3REPOS
extensions_rootfolder = /tmp/T3EXTENSIONS
extensions_builddir_relpath = typo3cms/extensions
drafts_builddir_relpath = typo3cms/drafts
# override these on the commandline
force_rebuild_needed = 1
make_latex = 0
make_package = 0
make_pdf = 0
make_singlehtml = 0
rebuild_needed = 1
replace_static_in_html = 0
talk = 1
# others
email_admin =
email_user_cc =
email_user_bcc =
lockfile_name = lockfile.json
url_of_webroot = https://docs.typo3.org/
latex_contrib_typo3_folder = /ALL/Downloads/latex.typo3
email_user_send_to_admin_too = 0
email_user_to =
email_user_do_not_send = 0
email_user_receivers_exlude_list = ,
smtp_host=
"""
|
mit
|
[
3381,
2647,
15,
1393,
15,
1813,
2366,
199,
3,
2803,
26,
2774,
13,
24,
199,
199,
504,
636,
2443,
363,
492,
870,
63,
1593,
199,
504,
636,
2443,
363,
492,
3679,
63,
646,
199,
199,
646,
747,
199,
646,
984,
199,
646,
307,
319,
199,
199,
504,
307,
319,
492,
13217,
362,
199,
199,
79,
681,
74,
275,
747,
14,
515,
14,
904,
199,
199,
1162,
275,
307,
319,
14,
739,
1001,
8,
1274,
14,
3020,
59,
17,
566,
199,
5047,
275,
307,
319,
14,
739,
1001,
8,
1162,
459,
5047,
493,
1105,
199,
77,
24156,
275,
307,
319,
14,
739,
1001,
8,
1162,
459,
77,
24156,
493,
1105,
199,
5764,
275,
2125,
199,
1099,
493,
275,
1862,
459,
1099,
493,
418,
199,
1099,
275,
307,
319,
14,
739,
1001,
8,
1099,
493,
9,
199,
3557,
354,
275,
1862,
459,
3557,
354,
418,
199,
3557,
354,
63,
5115,
275,
1862,
459,
3557,
354,
63,
5115,
418,
199,
22572,
63,
354,
275,
9036,
459,
22572,
63,
354,
418,
199,
19132,
275,
1862,
459,
19132,
418,
199,
793,
513,
275,
754,
459,
793,
513,
418,
275,
754,
14,
362,
360,
793,
513,
297,
3073,
199,
2224,
600,
275,
7408,
568,
4187,
275,
378,
421,
199,
3,
19691,
29,
199,
3,
4155,
282,
1331,
402,
333,
24156,
367,
2945,
5261,
10303,
31,
199,
3,
23271,
199,
199,
692,
378,
503,
333,
24156,
14,
362,
360,
1757,
63,
9223,
63,
1875,
63,
77,
24156,
63,
4753,
735,
272,
307,
319,
14,
1875,
63,
4753,
63,
1618,
63,
77,
24156,
8,
1162,
459,
77,
24156,
493,
995,
984,
14,
3020,
59,
17,
566,
421,
199,
3,
19691,
29,
199,
3,
11642,
3423,
199,
3,
23271,
199,
199,
318,
1642,
1763,
403,
2031,
589,
304,
272,
367,
1680,
315,
1249,
26,
267,
340,
1680,
365,
440,
488,
26,
288,
372,
1680,
272,
587,
26,
267,
372,
488,
199,
199,
318,
4237,
8,
36,
12,
627,
1612,
12,
1011,
829,
31895,
304,
272,
754,
275,
13217,
362,
8,
36,
12,
627,
1612,
12,
1011,
829,
31895,
9,
272,
943,
513,
14,
740,
1332,
1612,
12,
754,
430,
272,
372,
754,
199,
199,
318,
2342,
2540,
4720,
8,
498,
12,
849,
29,
403,
12,
577,
29,
403,
304,
272,
754,
275,
1642,
1763,
403,
8,
267,
13217,
362,
8,
77,
24156,
12,
790,
12,
849,
29,
403,
395,
267,
13217,
362,
8,
5047,
12,
283,
1065,
63,
1531,
297,
790,
12,
849,
29,
403,
395,
267,
13217,
362,
8,
77,
24156,
12,
283,
2423,
493,
63,
576,
297,
283,
84,
319,
888,
297,
790,
12,
849,
29,
403,
395,
267,
13217,
362,
8,
5047,
12,
283,
84,
319,
888,
297,
1101,
409,
12,
790,
12,
849,
29,
403,
395,
267,
849,
12,
267,
488,
9,
272,
327,
9122,
605,
323,
5366,
7763,
272,
340,
1228,
8,
36,
12,
1211,
304,
267,
577,
59,
498,
61,
275,
754,
272,
372,
754,
199,
199,
619,
21942,
275,
1006,
63,
1589,
63,
1222,
63,
77,
24156,
275,
1052,
421,
199,
3,
19691,
29,
199,
3,
5627,
199,
3,
23271,
199,
199,
3,
1900,
1751,
63,
21728,
63,
1231,
275,
1182,
1761,
15,
5869,
63,
2520,
1231,
199,
1506,
1751,
63,
21728,
275,
2125,
199,
8928,
63,
12130,
63,
4515,
275,
31200,
627,
1520,
221,
327,
3795,
340,
2061,
9040,
15232,
365,
12731,
199,
3187,
694,
63,
7790,
63,
928,
63,
1045,
275,
1994,
4219,
15,
7195,
385,
15,
2148,
30072,
15,
11254,
4219,
15,
4584,
830,
15,
11334,
15529,
15,
11254,
2791,
4805,
199,
26204,
63,
12130,
63,
4515,
275,
6155,
383,
199,
6188,
63,
2064,
63,
1618,
63,
21728,
275,
2125,
199,
1918,
4761,
4437,
3567,
275,
488,
199,
633,
63,
1618,
63,
2520,
1231,
275,
283,
2859,
921,
4757,
14,
369,
555,
19,
14,
1308,
4805,
199,
2520,
1231,
63,
4832,
275,
1994,
1761,
15,
5869,
63,
2520,
1231,
7,
199,
1845,
81,
63,
354,
63,
6507,
275,
378,
199,
199,
2123,
63,
751,
63,
1117,
63,
1397,
63,
2254,
275,
378,
199,
2123,
63,
751,
63,
29494,
63,
476,
76,
3786,
63,
513,
275,
359,
272,
283,
9970,
32,
369,
555,
19,
14,
1308,
297,
272,
283,
815,
32,
369,
555,
19,
14,
1308,
297,
272,
283,
75,
305,
529,
15703,
32,
369,
555,
19,
14,
957,
297,
272,
283,
75,
305,
529,
15703,
32,
369,
555,
19,
14,
1308,
297,
199,
61,
199,
199,
10706,
63,
875,
63,
1419,
275,
334,
272,
661,
2190,
63,
647,
63,
4133,
493,
297,
9929,
272,
661,
2123,
63,
2113,
297,
283,
77,
26788,
14,
830,
385,
32,
6799,
14,
957,
659,
272,
661,
2123,
63,
751,
63,
21976,
297,
9929,
272,
661,
2123,
63,
751,
63,
2055,
297,
9929,
272,
661,
2123,
63,
751,
63,
475,
63,
23145,
297,
9929,
272,
661,
1534,
63,
2087,
297,
283,
5030,
659,
221,
327,
15396,
1204,
17166,
199,
9,
199,
10706,
63,
442,
63,
1419,
275,
334,
272,
661,
2123,
63,
2113,
63,
2254,
63,
2911,
63,
1198,
297,
378,
395,
272,
661,
2123,
63,
751,
63,
1117,
63,
1397,
63,
2254,
297,
378,
395,
272,
661,
1875,
63,
7572,
297,
413,
395,
272,
661,
1875,
63,
2491,
297,
413,
395,
272,
661,
1875,
63,
5607,
297,
413,
395,
272,
661,
1875,
63,
4780,
1360,
297,
413,
395,
272,
661,
19278,
63,
11368,
297,
378,
395,
272,
661,
1814,
63,
1986,
63,
262,
63,
1360,
297,
378,
395,
199,
9,
199,
199,
10706,
63,
4737,
513,
63,
1419,
275,
334,
272,
661,
2123,
63,
751,
63,
29494,
63,
476,
76,
3786,
63,
513,
297,
9929,
199,
9,
199,
199,
4669,
1698,
12394,
63,
18061,
63,
2054,
43,
1149,
3927,
275,
488,
199,
4669,
1698,
12394,
63,
18061,
63,
8414,
275,
488,
199,
4669,
1698,
12394,
63,
18061,
63,
10797,
275,
488,
421,
199,
3,
19691,
29,
199,
3,
2670,
1862,
199,
3,
23271,
199,
199,
692,
4458,
600,
508,
7408,
568,
4187,
26,
272,
943,
513,
14,
740,
360,
8936,
16565,
51,
358,
339,
327,
3847,
63,
2064,
63,
1618,
63,
21728,
275,
4237,
8,
5047,
12,
283,
84,
319,
888,
297,
1101,
409,
12,
283,
6188,
63,
2064,
63,
1618,
63,
21728,
297,
849,
29,
6188
] |
[
2647,
15,
1393,
15,
1813,
2366,
199,
3,
2803,
26,
2774,
13,
24,
199,
199,
504,
636,
2443,
363,
492,
870,
63,
1593,
199,
504,
636,
2443,
363,
492,
3679,
63,
646,
199,
199,
646,
747,
199,
646,
984,
199,
646,
307,
319,
199,
199,
504,
307,
319,
492,
13217,
362,
199,
199,
79,
681,
74,
275,
747,
14,
515,
14,
904,
199,
199,
1162,
275,
307,
319,
14,
739,
1001,
8,
1274,
14,
3020,
59,
17,
566,
199,
5047,
275,
307,
319,
14,
739,
1001,
8,
1162,
459,
5047,
493,
1105,
199,
77,
24156,
275,
307,
319,
14,
739,
1001,
8,
1162,
459,
77,
24156,
493,
1105,
199,
5764,
275,
2125,
199,
1099,
493,
275,
1862,
459,
1099,
493,
418,
199,
1099,
275,
307,
319,
14,
739,
1001,
8,
1099,
493,
9,
199,
3557,
354,
275,
1862,
459,
3557,
354,
418,
199,
3557,
354,
63,
5115,
275,
1862,
459,
3557,
354,
63,
5115,
418,
199,
22572,
63,
354,
275,
9036,
459,
22572,
63,
354,
418,
199,
19132,
275,
1862,
459,
19132,
418,
199,
793,
513,
275,
754,
459,
793,
513,
418,
275,
754,
14,
362,
360,
793,
513,
297,
3073,
199,
2224,
600,
275,
7408,
568,
4187,
275,
378,
421,
199,
3,
19691,
29,
199,
3,
4155,
282,
1331,
402,
333,
24156,
367,
2945,
5261,
10303,
31,
199,
3,
23271,
199,
199,
692,
378,
503,
333,
24156,
14,
362,
360,
1757,
63,
9223,
63,
1875,
63,
77,
24156,
63,
4753,
735,
272,
307,
319,
14,
1875,
63,
4753,
63,
1618,
63,
77,
24156,
8,
1162,
459,
77,
24156,
493,
995,
984,
14,
3020,
59,
17,
566,
421,
199,
3,
19691,
29,
199,
3,
11642,
3423,
199,
3,
23271,
199,
199,
318,
1642,
1763,
403,
2031,
589,
304,
272,
367,
1680,
315,
1249,
26,
267,
340,
1680,
365,
440,
488,
26,
288,
372,
1680,
272,
587,
26,
267,
372,
488,
199,
199,
318,
4237,
8,
36,
12,
627,
1612,
12,
1011,
829,
31895,
304,
272,
754,
275,
13217,
362,
8,
36,
12,
627,
1612,
12,
1011,
829,
31895,
9,
272,
943,
513,
14,
740,
1332,
1612,
12,
754,
430,
272,
372,
754,
199,
199,
318,
2342,
2540,
4720,
8,
498,
12,
849,
29,
403,
12,
577,
29,
403,
304,
272,
754,
275,
1642,
1763,
403,
8,
267,
13217,
362,
8,
77,
24156,
12,
790,
12,
849,
29,
403,
395,
267,
13217,
362,
8,
5047,
12,
283,
1065,
63,
1531,
297,
790,
12,
849,
29,
403,
395,
267,
13217,
362,
8,
77,
24156,
12,
283,
2423,
493,
63,
576,
297,
283,
84,
319,
888,
297,
790,
12,
849,
29,
403,
395,
267,
13217,
362,
8,
5047,
12,
283,
84,
319,
888,
297,
1101,
409,
12,
790,
12,
849,
29,
403,
395,
267,
849,
12,
267,
488,
9,
272,
327,
9122,
605,
323,
5366,
7763,
272,
340,
1228,
8,
36,
12,
1211,
304,
267,
577,
59,
498,
61,
275,
754,
272,
372,
754,
199,
199,
619,
21942,
275,
1006,
63,
1589,
63,
1222,
63,
77,
24156,
275,
1052,
421,
199,
3,
19691,
29,
199,
3,
5627,
199,
3,
23271,
199,
199,
3,
1900,
1751,
63,
21728,
63,
1231,
275,
1182,
1761,
15,
5869,
63,
2520,
1231,
199,
1506,
1751,
63,
21728,
275,
2125,
199,
8928,
63,
12130,
63,
4515,
275,
31200,
627,
1520,
221,
327,
3795,
340,
2061,
9040,
15232,
365,
12731,
199,
3187,
694,
63,
7790,
63,
928,
63,
1045,
275,
1994,
4219,
15,
7195,
385,
15,
2148,
30072,
15,
11254,
4219,
15,
4584,
830,
15,
11334,
15529,
15,
11254,
2791,
4805,
199,
26204,
63,
12130,
63,
4515,
275,
6155,
383,
199,
6188,
63,
2064,
63,
1618,
63,
21728,
275,
2125,
199,
1918,
4761,
4437,
3567,
275,
488,
199,
633,
63,
1618,
63,
2520,
1231,
275,
283,
2859,
921,
4757,
14,
369,
555,
19,
14,
1308,
4805,
199,
2520,
1231,
63,
4832,
275,
1994,
1761,
15,
5869,
63,
2520,
1231,
7,
199,
1845,
81,
63,
354,
63,
6507,
275,
378,
199,
199,
2123,
63,
751,
63,
1117,
63,
1397,
63,
2254,
275,
378,
199,
2123,
63,
751,
63,
29494,
63,
476,
76,
3786,
63,
513,
275,
359,
272,
283,
9970,
32,
369,
555,
19,
14,
1308,
297,
272,
283,
815,
32,
369,
555,
19,
14,
1308,
297,
272,
283,
75,
305,
529,
15703,
32,
369,
555,
19,
14,
957,
297,
272,
283,
75,
305,
529,
15703,
32,
369,
555,
19,
14,
1308,
297,
199,
61,
199,
199,
10706,
63,
875,
63,
1419,
275,
334,
272,
661,
2190,
63,
647,
63,
4133,
493,
297,
9929,
272,
661,
2123,
63,
2113,
297,
283,
77,
26788,
14,
830,
385,
32,
6799,
14,
957,
659,
272,
661,
2123,
63,
751,
63,
21976,
297,
9929,
272,
661,
2123,
63,
751,
63,
2055,
297,
9929,
272,
661,
2123,
63,
751,
63,
475,
63,
23145,
297,
9929,
272,
661,
1534,
63,
2087,
297,
283,
5030,
659,
221,
327,
15396,
1204,
17166,
199,
9,
199,
10706,
63,
442,
63,
1419,
275,
334,
272,
661,
2123,
63,
2113,
63,
2254,
63,
2911,
63,
1198,
297,
378,
395,
272,
661,
2123,
63,
751,
63,
1117,
63,
1397,
63,
2254,
297,
378,
395,
272,
661,
1875,
63,
7572,
297,
413,
395,
272,
661,
1875,
63,
2491,
297,
413,
395,
272,
661,
1875,
63,
5607,
297,
413,
395,
272,
661,
1875,
63,
4780,
1360,
297,
413,
395,
272,
661,
19278,
63,
11368,
297,
378,
395,
272,
661,
1814,
63,
1986,
63,
262,
63,
1360,
297,
378,
395,
199,
9,
199,
199,
10706,
63,
4737,
513,
63,
1419,
275,
334,
272,
661,
2123,
63,
751,
63,
29494,
63,
476,
76,
3786,
63,
513,
297,
9929,
199,
9,
199,
199,
4669,
1698,
12394,
63,
18061,
63,
2054,
43,
1149,
3927,
275,
488,
199,
4669,
1698,
12394,
63,
18061,
63,
8414,
275,
488,
199,
4669,
1698,
12394,
63,
18061,
63,
10797,
275,
488,
421,
199,
3,
19691,
29,
199,
3,
2670,
1862,
199,
3,
23271,
199,
199,
692,
4458,
600,
508,
7408,
568,
4187,
26,
272,
943,
513,
14,
740,
360,
8936,
16565,
51,
358,
339,
327,
3847,
63,
2064,
63,
1618,
63,
21728,
275,
4237,
8,
5047,
12,
283,
84,
319,
888,
297,
1101,
409,
12,
283,
6188,
63,
2064,
63,
1618,
63,
21728,
297,
849,
29,
6188,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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.py
|
134
|
2089
|
# Copyright (c) 2010 Google Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following disclaimer
# in the documentation and/or other materials provided with the
# distribution.
# * Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import threading
class ThreadedMessageQueue(object):
def __init__(self):
self._messages = []
self._is_running = True
self._lock = threading.Lock()
def post(self, message):
with self._lock:
self._messages.append(message)
def stop(self):
with self._lock:
self._is_running = False
def take_all(self):
with self._lock:
messages = self._messages
is_running = self._is_running
self._messages = []
return (messages, is_running)
|
bsd-3-clause
|
[
3,
1898,
334,
67,
9,
7129,
4475,
3277,
14,
2900,
4481,
4644,
14,
199,
3,
199,
3,
10114,
436,
675,
315,
1350,
436,
3366,
4513,
12,
543,
503,
1928,
199,
3,
7100,
12,
787,
8211,
2741,
626,
314,
2569,
3704,
787,
199,
3,
7647,
26,
199,
3,
199,
3,
258,
627,
6823,
402,
1350,
1233,
1471,
8074,
314,
3432,
4248,
199,
3,
4245,
12,
642,
769,
402,
3704,
436,
314,
2569,
6450,
14,
199,
3,
258,
627,
6823,
315,
3366,
1824,
1471,
9172,
314,
3432,
199,
3,
4248,
4245,
12,
642,
769,
402,
3704,
436,
314,
2569,
6450,
199,
3,
315,
314,
3794,
436,
15,
269,
1163,
8418,
2741,
543,
314,
199,
3,
4084,
14,
199,
3,
258,
627,
11443,
314,
536,
402,
4475,
3277,
14,
6590,
314,
1561,
402,
2399,
199,
3,
8417,
1443,
506,
1202,
370,
10692,
503,
10016,
7585,
7131,
687,
199,
3,
642,
2032,
1928,
2488,
6791,
5313,
4983,
14,
199,
3,
199,
3,
5749,
4141,
2281,
7049,
6515,
2334,
5877,
8164,
2401,
6483,
199,
3,
298,
1179,
2281,
2,
2401,
1821,
7168,
1549,
5292,
2990,
12,
6931,
12,
5400,
2845,
199,
3,
5471,
2296,
12,
2334,
5292,
2990,
1634,
3169,
2401,
3092,
2381,
199,
3,
437,
3115,
3104,
9315,
9706,
14,
1621,
4825,
6461,
7000,
2334,
5877,
199,
3,
11489,
1549,
6483,
6262,
7024,
2381,
1821,
8703,
12,
9168,
12,
9716,
12,
199,
3,
8820,
12,
9836,
12,
1549,
9110,
6736,
334,
6446,
12,
5400,
2845,
199,
3,
5471,
2296,
12,
9838,
1634,
9103,
9764,
1549,
9714,
27,
9102,
1634,
4815,
12,
199,
3,
7126,
12,
1549,
9206,
27,
1549,
9748,
9831,
9,
9802,
9817,
2401,
5258,
1821,
199,
3,
9815,
1634,
5603,
12,
7061,
1621,
7066,
12,
9644,
5603,
12,
1549,
7056,
199,
3,
334,
6446,
9254,
1549,
7334,
9,
7043,
1621,
1821,
9683,
5738,
1634,
2334,
4815,
199,
3,
1634,
5749,
4141,
12,
9704,
8036,
9691,
1634,
2334,
9726,
1634,
9712,
9784,
14,
199,
199,
646,
5796,
421,
199,
533,
3868,
11698,
2209,
3737,
8,
785,
304,
272,
347,
636,
826,
721,
277,
304,
267,
291,
423,
3431,
275,
942,
267,
291,
423,
374,
63,
5720,
275,
715,
267,
291,
423,
831,
275,
5796,
14,
6432,
342,
339,
347,
2963,
8,
277,
12,
1245,
304,
267,
543,
291,
423,
831,
26,
288,
291,
423,
3431,
14,
740,
8,
1188,
9,
339,
347,
3631,
8,
277,
304,
267,
543,
291,
423,
831,
26,
288,
291,
423,
374,
63,
5720,
275,
756,
339,
347,
5452,
63,
452,
8,
277,
304,
267,
543,
291,
423,
831,
26,
288,
3788,
275,
291,
423,
3431,
288,
365,
63,
5720,
275,
291,
423,
374,
63,
5720,
288,
291,
423,
3431,
275,
942,
267,
372,
334,
3431,
12,
365,
63,
5720,
9,
421,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
1898,
334,
67,
9,
7129,
4475,
3277,
14,
2900,
4481,
4644,
14,
199,
3,
199,
3,
10114,
436,
675,
315,
1350,
436,
3366,
4513,
12,
543,
503,
1928,
199,
3,
7100,
12,
787,
8211,
2741,
626,
314,
2569,
3704,
787,
199,
3,
7647,
26,
199,
3,
199,
3,
258,
627,
6823,
402,
1350,
1233,
1471,
8074,
314,
3432,
4248,
199,
3,
4245,
12,
642,
769,
402,
3704,
436,
314,
2569,
6450,
14,
199,
3,
258,
627,
6823,
315,
3366,
1824,
1471,
9172,
314,
3432,
199,
3,
4248,
4245,
12,
642,
769,
402,
3704,
436,
314,
2569,
6450,
199,
3,
315,
314,
3794,
436,
15,
269,
1163,
8418,
2741,
543,
314,
199,
3,
4084,
14,
199,
3,
258,
627,
11443,
314,
536,
402,
4475,
3277,
14,
6590,
314,
1561,
402,
2399,
199,
3,
8417,
1443,
506,
1202,
370,
10692,
503,
10016,
7585,
7131,
687,
199,
3,
642,
2032,
1928,
2488,
6791,
5313,
4983,
14,
199,
3,
199,
3,
5749,
4141,
2281,
7049,
6515,
2334,
5877,
8164,
2401,
6483,
199,
3,
298,
1179,
2281,
2,
2401,
1821,
7168,
1549,
5292,
2990,
12,
6931,
12,
5400,
2845,
199,
3,
5471,
2296,
12,
2334,
5292,
2990,
1634,
3169,
2401,
3092,
2381,
199,
3,
437,
3115,
3104,
9315,
9706,
14,
1621,
4825,
6461,
7000,
2334,
5877,
199,
3,
11489,
1549,
6483,
6262,
7024,
2381,
1821,
8703,
12,
9168,
12,
9716,
12,
199,
3,
8820,
12,
9836,
12,
1549,
9110,
6736,
334,
6446,
12,
5400,
2845,
199,
3,
5471,
2296,
12,
9838,
1634,
9103,
9764,
1549,
9714,
27,
9102,
1634,
4815,
12,
199,
3,
7126,
12,
1549,
9206,
27,
1549,
9748,
9831,
9,
9802,
9817,
2401,
5258,
1821,
199,
3,
9815,
1634,
5603,
12,
7061,
1621,
7066,
12,
9644,
5603,
12,
1549,
7056,
199,
3,
334,
6446,
9254,
1549,
7334,
9,
7043,
1621,
1821,
9683,
5738,
1634,
2334,
4815,
199,
3,
1634,
5749,
4141,
12,
9704,
8036,
9691,
1634,
2334,
9726,
1634,
9712,
9784,
14,
199,
199,
646,
5796,
421,
199,
533,
3868,
11698,
2209,
3737,
8,
785,
304,
272,
347,
636,
826,
721,
277,
304,
267,
291,
423,
3431,
275,
942,
267,
291,
423,
374,
63,
5720,
275,
715,
267,
291,
423,
831,
275,
5796,
14,
6432,
342,
339,
347,
2963,
8,
277,
12,
1245,
304,
267,
543,
291,
423,
831,
26,
288,
291,
423,
3431,
14,
740,
8,
1188,
9,
339,
347,
3631,
8,
277,
304,
267,
543,
291,
423,
831,
26,
288,
291,
423,
374,
63,
5720,
275,
756,
339,
347,
5452,
63,
452,
8,
277,
304,
267,
543,
291,
423,
831,
26,
288,
3788,
275,
291,
423,
3431,
288,
365,
63,
5720,
275,
291,
423,
374,
63,
5720,
288,
291,
423,
3431,
275,
942,
267,
372,
334,
3431,
12,
365,
63,
5720,
9,
421,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
tesidroni/mp
|
Lib/site-packages/numpy/distutils/command/install.py
|
95
|
3008
|
import sys
if 'setuptools' in sys.modules:
import setuptools.command.install as old_install_mod
have_setuptools = True
else:
import distutils.command.install as old_install_mod
have_setuptools = False
old_install = old_install_mod.install
from distutils.file_util import write_file
class install(old_install):
# Always run install_clib - the command is cheap, so no need to bypass it;
# but it's not run by setuptools -- so it's run again in install_data
sub_commands = old_install.sub_commands + [
('install_clib', lambda x: True)
]
def finalize_options (self):
old_install.finalize_options(self)
self.install_lib = self.install_libbase
def setuptools_run(self):
""" The setuptools version of the .run() method.
We must pull in the entire code so we can override the level used in the
_getframe() call since we wrap this call by one more level.
"""
# Explicit request for old-style install? Just do it
if self.old_and_unmanageable or self.single_version_externally_managed:
return old_install_mod._install.run(self)
# Attempt to detect whether we were called from setup() or by another
# command. If we were called by setup(), our caller will be the
# 'run_command' method in 'distutils.dist', and *its* caller will be
# the 'run_commands' method. If we were called any other way, our
# immediate caller *might* be 'run_command', but it won't have been
# called by 'run_commands'. This is slightly kludgy, but seems to
# work.
#
caller = sys._getframe(3)
caller_module = caller.f_globals.get('__name__','')
caller_name = caller.f_code.co_name
if caller_module != 'distutils.dist' or caller_name!='run_commands':
# We weren't called from the command line or setup(), so we
# should run in backward-compatibility mode to support bdist_*
# commands.
old_install_mod._install.run(self)
else:
self.do_egg_install()
def run(self):
if not have_setuptools:
r = old_install.run(self)
else:
r = self.setuptools_run()
if self.record:
# bdist_rpm fails when INSTALLED_FILES contains
# paths with spaces. Such paths must be enclosed
# with double-quotes.
f = open(self.record,'r')
lines = []
need_rewrite = False
for l in f.readlines():
l = l.rstrip()
if ' ' in l:
need_rewrite = True
l = '"%s"' % (l)
lines.append(l)
f.close()
if need_rewrite:
self.execute(write_file,
(self.record, lines),
"re-writing list of installed files to '%s'" %
self.record)
return r
|
gpl-3.0
|
[
646,
984,
199,
692,
283,
13623,
7,
315,
984,
14,
3112,
26,
272,
492,
9116,
14,
1531,
14,
3174,
465,
2269,
63,
3174,
63,
1494,
272,
1172,
63,
13623,
275,
715,
199,
2836,
26,
272,
492,
7065,
14,
1531,
14,
3174,
465,
2269,
63,
3174,
63,
1494,
272,
1172,
63,
13623,
275,
756,
199,
1753,
63,
3174,
275,
2269,
63,
3174,
63,
1494,
14,
3174,
199,
504,
7065,
14,
493,
63,
1974,
492,
2218,
63,
493,
199,
199,
533,
3907,
8,
1753,
63,
3174,
304,
339,
327,
16763,
1255,
3907,
63,
32534,
446,
314,
1414,
365,
286,
12492,
12,
880,
949,
1929,
370,
21115,
652,
27,
272,
327,
1325,
652,
1159,
440,
1255,
701,
9116,
1553,
880,
652,
1159,
1255,
4020,
315,
3907,
63,
576,
272,
1007,
63,
4405,
275,
2269,
63,
3174,
14,
954,
63,
4405,
435,
359,
267,
661,
3174,
63,
32534,
297,
2400,
671,
26,
715,
9,
272,
1622,
339,
347,
17284,
63,
1419,
334,
277,
304,
267,
2269,
63,
3174,
14,
14450,
63,
1419,
8,
277,
9,
267,
291,
14,
3174,
63,
773,
275,
291,
14,
3174,
63,
773,
1095,
339,
347,
9116,
63,
1065,
8,
277,
304,
267,
408,
710,
9116,
1015,
402,
314,
1275,
1065,
342,
1083,
14,
398,
2136,
1471,
10299,
315,
314,
8039,
1233,
880,
781,
883,
4278,
314,
2166,
1202,
315,
314,
267,
485,
20912,
342,
1240,
3967,
781,
4816,
642,
1240,
701,
1373,
1655,
2166,
14,
267,
408,
267,
327,
23872,
1056,
367,
2269,
13,
2487,
3907,
31,
221,
13870,
886,
652,
267,
340,
291,
14,
1753,
63,
460,
63,
324,
9053,
461,
503,
291,
14,
4780,
63,
1023,
63,
18587,
1183,
63,
11122,
26,
288,
372,
2269,
63,
3174,
63,
1494,
423,
3174,
14,
1065,
8,
277,
9,
398,
327,
23115,
370,
9696,
3775,
781,
4898,
2797,
687,
3272,
342,
503,
701,
4573,
267,
327,
1414,
14,
221,
982,
781,
4898,
2797,
701,
3272,
1062,
4154,
8025,
911,
506,
314,
267,
327,
283,
1065,
63,
1531,
7,
1083,
315,
283,
13350,
14,
2686,
297,
436,
627,
1405,
10,
8025,
911,
506,
267,
327,
314,
283,
1065,
63,
4405,
7,
1083,
14,
221,
982,
781,
4898,
2797,
1263,
1163,
4340,
12,
4154,
267,
327,
8569,
8025,
627,
77,
1070,
10,
506,
283,
1065,
63,
1531,
297,
1325,
652,
7859,
1133,
1172,
2757,
267,
327,
2797,
701,
283,
1065,
63,
4405,
1370,
221,
961,
365,
18023,
26151,
1181,
4312,
12,
1325,
12237,
370,
267,
327,
1736,
14,
267,
327,
267,
8025,
275,
984,
423,
20912,
8,
19,
9,
267,
8025,
63,
578,
275,
8025,
14,
70,
63,
8473,
14,
362,
10714,
354,
363,
20944,
267,
8025,
63,
354,
275,
8025,
14,
70,
63,
600,
14,
331,
63,
354,
398,
340,
8025,
63,
578,
1137,
283,
13350,
14,
2686,
7,
503,
8025,
63,
354,
27909,
1065,
63,
4405,
356,
288,
327,
2136,
781,
828,
1133,
2797,
687,
314,
1414,
1004,
503,
3272,
1062,
880,
781,
288,
327,
1077,
1255,
315,
13388,
13,
15390,
818,
370,
2291,
26308,
15192,
288,
327,
3718,
14,
288,
2269,
63,
3174,
63,
1494,
423,
3174,
14,
1065,
8,
277,
9,
267,
587,
26,
288,
291,
14,
1117,
63,
5799,
63,
3174,
342,
339,
347,
1255,
8,
277,
304,
267,
340,
440,
1172,
63,
13623,
26,
288,
519,
275,
2269,
63,
3174,
14,
1065,
8,
277,
9,
267,
587,
26,
288,
519,
275,
291,
14,
13623,
63,
1065,
342,
267,
340,
291,
14,
3059,
26,
288,
327,
26308,
63,
14191,
6918,
1380,
31061,
63,
9472,
3509,
288,
327,
3792,
543,
7883,
14,
32753,
3792,
1471,
506,
27828,
288,
327,
543,
4270,
13,
14005,
14,
288,
289,
275,
1551,
8,
277,
14,
3059,
2584,
82,
358,
288,
2385,
275,
942,
288,
1929,
63,
14366,
275,
756,
288,
367,
634,
315,
289,
14,
9684,
837,
355,
634,
275,
634,
14,
6735,
342,
355,
340,
283,
283,
315,
634,
26,
490,
1929,
63,
14366,
275,
715,
490,
634,
275,
18253,
83,
4507,
450,
334,
76,
9,
355,
2385,
14,
740,
8,
76,
9,
288,
289,
14,
1600,
342,
288,
340,
1929,
63,
14366,
26,
355,
291,
14,
2526,
8,
952,
63,
493,
12,
2490,
334,
277,
14,
3059,
12,
2385,
395,
2490,
298,
264,
13,
14827,
769,
402,
4903,
1584,
370,
1543,
83,
4065,
450,
2490,
291,
14,
3059,
9,
267,
372,
519,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,
692,
283,
13623,
7,
315,
984,
14,
3112,
26,
272,
492,
9116,
14,
1531,
14,
3174,
465,
2269,
63,
3174,
63,
1494,
272,
1172,
63,
13623,
275,
715,
199,
2836,
26,
272,
492,
7065,
14,
1531,
14,
3174,
465,
2269,
63,
3174,
63,
1494,
272,
1172,
63,
13623,
275,
756,
199,
1753,
63,
3174,
275,
2269,
63,
3174,
63,
1494,
14,
3174,
199,
504,
7065,
14,
493,
63,
1974,
492,
2218,
63,
493,
199,
199,
533,
3907,
8,
1753,
63,
3174,
304,
339,
327,
16763,
1255,
3907,
63,
32534,
446,
314,
1414,
365,
286,
12492,
12,
880,
949,
1929,
370,
21115,
652,
27,
272,
327,
1325,
652,
1159,
440,
1255,
701,
9116,
1553,
880,
652,
1159,
1255,
4020,
315,
3907,
63,
576,
272,
1007,
63,
4405,
275,
2269,
63,
3174,
14,
954,
63,
4405,
435,
359,
267,
661,
3174,
63,
32534,
297,
2400,
671,
26,
715,
9,
272,
1622,
339,
347,
17284,
63,
1419,
334,
277,
304,
267,
2269,
63,
3174,
14,
14450,
63,
1419,
8,
277,
9,
267,
291,
14,
3174,
63,
773,
275,
291,
14,
3174,
63,
773,
1095,
339,
347,
9116,
63,
1065,
8,
277,
304,
267,
408,
710,
9116,
1015,
402,
314,
1275,
1065,
342,
1083,
14,
398,
2136,
1471,
10299,
315,
314,
8039,
1233,
880,
781,
883,
4278,
314,
2166,
1202,
315,
314,
267,
485,
20912,
342,
1240,
3967,
781,
4816,
642,
1240,
701,
1373,
1655,
2166,
14,
267,
408,
267,
327,
23872,
1056,
367,
2269,
13,
2487,
3907,
31,
221,
13870,
886,
652,
267,
340,
291,
14,
1753,
63,
460,
63,
324,
9053,
461,
503,
291,
14,
4780,
63,
1023,
63,
18587,
1183,
63,
11122,
26,
288,
372,
2269,
63,
3174,
63,
1494,
423,
3174,
14,
1065,
8,
277,
9,
398,
327,
23115,
370,
9696,
3775,
781,
4898,
2797,
687,
3272,
342,
503,
701,
4573,
267,
327,
1414,
14,
221,
982,
781,
4898,
2797,
701,
3272,
1062,
4154,
8025,
911,
506,
314,
267,
327,
283,
1065,
63,
1531,
7,
1083,
315,
283,
13350,
14,
2686,
297,
436,
627,
1405,
10,
8025,
911,
506,
267,
327,
314,
283,
1065,
63,
4405,
7,
1083,
14,
221,
982,
781,
4898,
2797,
1263,
1163,
4340,
12,
4154,
267,
327,
8569,
8025,
627,
77,
1070,
10,
506,
283,
1065,
63,
1531,
297,
1325,
652,
7859,
1133,
1172,
2757,
267,
327,
2797,
701,
283,
1065,
63,
4405,
1370,
221,
961,
365,
18023,
26151,
1181,
4312,
12,
1325,
12237,
370,
267,
327,
1736,
14,
267,
327,
267,
8025,
275,
984,
423,
20912,
8,
19,
9,
267,
8025,
63,
578,
275,
8025,
14,
70,
63,
8473,
14,
362,
10714,
354,
363,
20944,
267,
8025,
63,
354,
275,
8025,
14,
70,
63,
600,
14,
331,
63,
354,
398,
340,
8025,
63,
578,
1137,
283,
13350,
14,
2686,
7,
503,
8025,
63,
354,
27909,
1065,
63,
4405,
356,
288,
327,
2136,
781,
828,
1133,
2797,
687,
314,
1414,
1004,
503,
3272,
1062,
880,
781,
288,
327,
1077,
1255,
315,
13388,
13,
15390,
818,
370,
2291,
26308,
15192,
288,
327,
3718,
14,
288,
2269,
63,
3174,
63,
1494,
423,
3174,
14,
1065,
8,
277,
9,
267,
587,
26,
288,
291,
14,
1117,
63,
5799,
63,
3174,
342,
339,
347,
1255,
8,
277,
304,
267,
340,
440,
1172,
63,
13623,
26,
288,
519,
275,
2269,
63,
3174,
14,
1065,
8,
277,
9,
267,
587,
26,
288,
519,
275,
291,
14,
13623,
63,
1065,
342,
267,
340,
291,
14,
3059,
26,
288,
327,
26308,
63,
14191,
6918,
1380,
31061,
63,
9472,
3509,
288,
327,
3792,
543,
7883,
14,
32753,
3792,
1471,
506,
27828,
288,
327,
543,
4270,
13,
14005,
14,
288,
289,
275,
1551,
8,
277,
14,
3059,
2584,
82,
358,
288,
2385,
275,
942,
288,
1929,
63,
14366,
275,
756,
288,
367,
634,
315,
289,
14,
9684,
837,
355,
634,
275,
634,
14,
6735,
342,
355,
340,
283,
283,
315,
634,
26,
490,
1929,
63,
14366,
275,
715,
490,
634,
275,
18253,
83,
4507,
450,
334,
76,
9,
355,
2385,
14,
740,
8,
76,
9,
288,
289,
14,
1600,
342,
288,
340,
1929,
63,
14366,
26,
355,
291,
14,
2526,
8,
952,
63,
493,
12,
2490,
334,
277,
14,
3059,
12,
2385,
395,
2490,
298,
264,
13,
14827,
769,
402,
4903,
1584,
370,
1543,
83,
4065,
450,
2490,
291,
14,
3059,
9,
267,
372,
519,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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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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
] |
chenc10/Spark-PAF
|
ec2/lib/boto-2.34.0/boto/beanstalk/__init__.py
|
145
|
1680
|
# Copyright (c) 2013 Amazon.com, Inc. or its affiliates.
# All Rights Reserved
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish, dis-
# tribute, sublicense, and/or sell copies of the Software, and to permit
# persons to whom the Software is furnished to do so, subject to the fol-
# lowing conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
# ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
# SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.
#
from boto.regioninfo import RegionInfo, get_regions
def regions():
"""
Get all available regions for the AWS Elastic Beanstalk service.
:rtype: list
:return: A list of :class:`boto.regioninfo.RegionInfo`
"""
import boto.beanstalk.layer1
return get_regions(
'elasticbeanstalk',
connection_cls=boto.beanstalk.layer1.Layer1
)
def connect_to_region(region_name, **kw_params):
for region in regions():
if region.name == region_name:
return region.connect(**kw_params)
return None
|
apache-2.0
|
[
3,
1898,
334,
67,
9,
6171,
14347,
14,
957,
12,
3277,
14,
503,
2399,
29172,
2335,
14,
199,
3,
2900,
5924,
5702,
199,
3,
199,
3,
8779,
365,
11882,
10009,
12,
2867,
402,
11204,
12,
370,
1263,
4954,
12408,
282,
199,
3,
1331,
402,
642,
2032,
436,
4568,
3794,
1584,
334,
1589,
199,
3,
298,
10337,
1288,
370,
7962,
315,
314,
2290,
1928,
10588,
12,
5893,
199,
3,
1928,
12305,
314,
4481,
370,
675,
12,
1331,
12,
2811,
12,
5389,
12,
2780,
12,
2153,
13,
199,
3,
28420,
12,
13473,
12,
436,
15,
269,
12743,
6866,
402,
314,
2290,
12,
436,
370,
11291,
199,
3,
12103,
370,
12676,
314,
2290,
365,
13985,
370,
886,
880,
12,
5420,
370,
314,
1699,
13,
199,
3,
28486,
3704,
26,
199,
3,
199,
3,
710,
3432,
4248,
4245,
436,
642,
4983,
4245,
10989,
506,
5120,
199,
3,
315,
1006,
6866,
503,
13393,
12468,
402,
314,
2290,
14,
199,
3,
199,
3,
2334,
4141,
2281,
7049,
298,
1179,
2281,
401,
2428,
3408,
1634,
1821,
3826,
12,
7168,
199,
3,
1549,
5292,
12,
6931,
5400,
2845,
5471,
2296,
2334,
2990,
1634,
28471,
13,
199,
3,
28463,
12,
3092,
2381,
437,
3115,
3104,
2401,
13229,
14,
1621,
4825,
6461,
199,
3,
7000,
2334,
17632,
6262,
7024,
2381,
1821,
13140,
12,
6736,
1549,
5010,
5603,
12,
199,
3,
7061,
1621,
1261,
9612,
1634,
7066,
12,
7056,
1549,
7334,
12,
7043,
4442,
12,
199,
3,
5738,
1634,
1549,
1621,
11287,
1663,
2334,
4141,
1549,
2334,
4815,
1549,
5010,
13198,
199,
3,
1621,
2334,
4141,
14,
199,
3,
199,
504,
6055,
14,
4551,
815,
492,
22240,
2354,
12,
664,
63,
11963,
421,
199,
318,
16150,
837,
272,
408,
272,
2372,
1006,
2808,
16150,
367,
314,
10168,
19509,
6423,
290,
270,
4878,
2435,
14,
339,
520,
4500,
26,
769,
272,
520,
1107,
26,
437,
769,
402,
520,
533,
1705,
10914,
14,
4551,
815,
14,
10708,
2354,
64,
272,
408,
272,
492,
6055,
14,
28142,
270,
4878,
14,
1897,
17,
272,
372,
664,
63,
11963,
8,
267,
283,
15565,
28142,
270,
4878,
297,
267,
1950,
63,
1886,
29,
10914,
14,
28142,
270,
4878,
14,
1897,
17,
14,
5003,
17,
272,
776,
421,
199,
318,
4907,
63,
475,
63,
4551,
8,
4551,
63,
354,
12,
1011,
829,
63,
1162,
304,
272,
367,
4897,
315,
16150,
837,
267,
340,
4897,
14,
354,
508,
4897,
63,
354,
26,
288,
372,
4897,
14,
2242,
3682,
829,
63,
1162,
9,
272,
372,
488,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
1898,
334,
67,
9,
6171,
14347,
14,
957,
12,
3277,
14,
503,
2399,
29172,
2335,
14,
199,
3,
2900,
5924,
5702,
199,
3,
199,
3,
8779,
365,
11882,
10009,
12,
2867,
402,
11204,
12,
370,
1263,
4954,
12408,
282,
199,
3,
1331,
402,
642,
2032,
436,
4568,
3794,
1584,
334,
1589,
199,
3,
298,
10337,
1288,
370,
7962,
315,
314,
2290,
1928,
10588,
12,
5893,
199,
3,
1928,
12305,
314,
4481,
370,
675,
12,
1331,
12,
2811,
12,
5389,
12,
2780,
12,
2153,
13,
199,
3,
28420,
12,
13473,
12,
436,
15,
269,
12743,
6866,
402,
314,
2290,
12,
436,
370,
11291,
199,
3,
12103,
370,
12676,
314,
2290,
365,
13985,
370,
886,
880,
12,
5420,
370,
314,
1699,
13,
199,
3,
28486,
3704,
26,
199,
3,
199,
3,
710,
3432,
4248,
4245,
436,
642,
4983,
4245,
10989,
506,
5120,
199,
3,
315,
1006,
6866,
503,
13393,
12468,
402,
314,
2290,
14,
199,
3,
199,
3,
2334,
4141,
2281,
7049,
298,
1179,
2281,
401,
2428,
3408,
1634,
1821,
3826,
12,
7168,
199,
3,
1549,
5292,
12,
6931,
5400,
2845,
5471,
2296,
2334,
2990,
1634,
28471,
13,
199,
3,
28463,
12,
3092,
2381,
437,
3115,
3104,
2401,
13229,
14,
1621,
4825,
6461,
199,
3,
7000,
2334,
17632,
6262,
7024,
2381,
1821,
13140,
12,
6736,
1549,
5010,
5603,
12,
199,
3,
7061,
1621,
1261,
9612,
1634,
7066,
12,
7056,
1549,
7334,
12,
7043,
4442,
12,
199,
3,
5738,
1634,
1549,
1621,
11287,
1663,
2334,
4141,
1549,
2334,
4815,
1549,
5010,
13198,
199,
3,
1621,
2334,
4141,
14,
199,
3,
199,
504,
6055,
14,
4551,
815,
492,
22240,
2354,
12,
664,
63,
11963,
421,
199,
318,
16150,
837,
272,
408,
272,
2372,
1006,
2808,
16150,
367,
314,
10168,
19509,
6423,
290,
270,
4878,
2435,
14,
339,
520,
4500,
26,
769,
272,
520,
1107,
26,
437,
769,
402,
520,
533,
1705,
10914,
14,
4551,
815,
14,
10708,
2354,
64,
272,
408,
272,
492,
6055,
14,
28142,
270,
4878,
14,
1897,
17,
272,
372,
664,
63,
11963,
8,
267,
283,
15565,
28142,
270,
4878,
297,
267,
1950,
63,
1886,
29,
10914,
14,
28142,
270,
4878,
14,
1897,
17,
14,
5003,
17,
272,
776,
421,
199,
318,
4907,
63,
475,
63,
4551,
8,
4551,
63,
354,
12,
1011,
829,
63,
1162,
304,
272,
367,
4897,
315,
16150,
837,
267,
340,
4897,
14,
354,
508,
4897,
63,
354,
26,
288,
372,
4897,
14,
2242,
3682,
829,
63,
1162,
9,
272,
372,
488,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
vvv1559/intellij-community
|
python/helpers/py3only/docutils/parsers/rst/directives/body.py
|
44
|
9232
|
# $Id: body.py 7267 2011-12-20 14:14:21Z milde $
# Author: David Goodger <goodger@python.org>
# Copyright: This module has been placed in the public domain.
"""
Directives for additional body elements.
See `docutils.parsers.rst.directives` for API details.
"""
__docformat__ = 'reStructuredText'
from docutils import nodes
from docutils.parsers.rst import Directive
from docutils.parsers.rst import directives
from docutils.parsers.rst.roles import set_classes
from docutils.utils.code_analyzer import Lexer, LexerError, NumberLines
class BasePseudoSection(Directive):
required_arguments = 1
optional_arguments = 0
final_argument_whitespace = True
option_spec = {'class': directives.class_option,
'name': directives.unchanged}
has_content = True
node_class = None
"""Node class to be used (must be set in subclasses)."""
def run(self):
if not (self.state_machine.match_titles
or isinstance(self.state_machine.node, nodes.sidebar)):
raise self.error('The "%s" directive may not be used within '
'topics or body elements.' % self.name)
self.assert_has_content()
title_text = self.arguments[0]
textnodes, messages = self.state.inline_text(title_text, self.lineno)
titles = [nodes.title(title_text, '', *textnodes)]
# Sidebar uses this code.
if 'subtitle' in self.options:
textnodes, more_messages = self.state.inline_text(
self.options['subtitle'], self.lineno)
titles.append(nodes.subtitle(self.options['subtitle'], '',
*textnodes))
messages.extend(more_messages)
text = '\n'.join(self.content)
node = self.node_class(text, *(titles + messages))
node['classes'] += self.options.get('class', [])
self.add_name(node)
if text:
self.state.nested_parse(self.content, self.content_offset, node)
return [node]
class Topic(BasePseudoSection):
node_class = nodes.topic
class Sidebar(BasePseudoSection):
node_class = nodes.sidebar
option_spec = BasePseudoSection.option_spec.copy()
option_spec['subtitle'] = directives.unchanged_required
def run(self):
if isinstance(self.state_machine.node, nodes.sidebar):
raise self.error('The "%s" directive may not be used within a '
'sidebar element.' % self.name)
return BasePseudoSection.run(self)
class LineBlock(Directive):
option_spec = {'class': directives.class_option,
'name': directives.unchanged}
has_content = True
def run(self):
self.assert_has_content()
block = nodes.line_block(classes=self.options.get('class', []))
self.add_name(block)
node_list = [block]
for line_text in self.content:
text_nodes, messages = self.state.inline_text(
line_text.strip(), self.lineno + self.content_offset)
line = nodes.line(line_text, '', *text_nodes)
if line_text.strip():
line.indent = len(line_text) - len(line_text.lstrip())
block += line
node_list.extend(messages)
self.content_offset += 1
self.state.nest_line_block_lines(block)
return node_list
class ParsedLiteral(Directive):
option_spec = {'class': directives.class_option,
'name': directives.unchanged}
has_content = True
def run(self):
set_classes(self.options)
self.assert_has_content()
text = '\n'.join(self.content)
text_nodes, messages = self.state.inline_text(text, self.lineno)
node = nodes.literal_block(text, '', *text_nodes, **self.options)
node.line = self.content_offset + 1
self.add_name(node)
return [node] + messages
class CodeBlock(Directive):
"""Parse and mark up content of a code block.
Configuration setting: syntax_highlight
Highlight Code content with Pygments?
Possible values: ('long', 'short', 'none')
"""
optional_arguments = 1
option_spec = {'class': directives.class_option,
'name': directives.unchanged,
'number-lines': directives.unchanged # integer or None
}
has_content = True
def run(self):
self.assert_has_content()
if self.arguments:
language = self.arguments[0]
else:
language = ''
set_classes(self.options)
classes = ['code']
if language:
classes.append(language)
if 'classes' in self.options:
classes.extend(self.options['classes'])
# set up lexical analyzer
try:
tokens = Lexer('\n'.join(self.content), language,
self.state.document.settings.syntax_highlight)
except LexerError as error:
raise self.warning(error)
if 'number-lines' in self.options:
# optional argument `startline`, defaults to 1
try:
startline = int(self.options['number-lines'] or 1)
except ValueError:
raise self.error(':number-lines: with non-integer start value')
endline = startline + len(self.content)
# add linenumber filter:
tokens = NumberLines(tokens, startline, endline)
node = nodes.literal_block('\n'.join(self.content), classes=classes)
self.add_name(node)
# if called from "include", set the source
if 'source' in self.options:
node.attributes['source'] = self.options['source']
# analyze content and add nodes for every token
for classes, value in tokens:
# print (classes, value)
if classes:
node += nodes.inline(value, value, classes=classes)
else:
# insert as Text to decrease the verbosity of the output
node += nodes.Text(value, value)
return [node]
class MathBlock(Directive):
option_spec = {'class': directives.class_option,
'name': directives.unchanged}
## TODO: Add Sphinx' ``mathbase.py`` option 'nowrap'?
# 'nowrap': directives.flag,
has_content = True
def run(self):
set_classes(self.options)
self.assert_has_content()
# join lines, separate blocks
content = '\n'.join(self.content).split('\n\n')
_nodes = []
for block in content:
if not block:
continue
node = nodes.math_block(self.block_text, block, **self.options)
node.line = self.content_offset + 1
self.add_name(node)
_nodes.append(node)
return _nodes
class Rubric(Directive):
required_arguments = 1
optional_arguments = 0
final_argument_whitespace = True
option_spec = {'class': directives.class_option,
'name': directives.unchanged}
def run(self):
set_classes(self.options)
rubric_text = self.arguments[0]
textnodes, messages = self.state.inline_text(rubric_text, self.lineno)
rubric = nodes.rubric(rubric_text, '', *textnodes, **self.options)
self.add_name(rubric)
return [rubric] + messages
class BlockQuote(Directive):
has_content = True
classes = []
def run(self):
self.assert_has_content()
elements = self.state.block_quote(self.content, self.content_offset)
for element in elements:
if isinstance(element, nodes.block_quote):
element['classes'] += self.classes
return elements
class Epigraph(BlockQuote):
classes = ['epigraph']
class Highlights(BlockQuote):
classes = ['highlights']
class PullQuote(BlockQuote):
classes = ['pull-quote']
class Compound(Directive):
option_spec = {'class': directives.class_option,
'name': directives.unchanged}
has_content = True
def run(self):
self.assert_has_content()
text = '\n'.join(self.content)
node = nodes.compound(text)
node['classes'] += self.options.get('class', [])
self.add_name(node)
self.state.nested_parse(self.content, self.content_offset, node)
return [node]
class Container(Directive):
optional_arguments = 1
final_argument_whitespace = True
option_spec = {'name': directives.unchanged}
has_content = True
def run(self):
self.assert_has_content()
text = '\n'.join(self.content)
try:
if self.arguments:
classes = directives.class_option(self.arguments[0])
else:
classes = []
except ValueError:
raise self.error(
'Invalid class attribute value for "%s" directive: "%s".'
% (self.name, self.arguments[0]))
node = nodes.container(text)
node['classes'].extend(classes)
self.add_name(node)
self.state.nested_parse(self.content, self.content_offset, node)
return [node]
|
apache-2.0
|
[
3,
2672,
1304,
26,
2396,
14,
647,
1520,
13406,
7760,
13,
713,
13,
1165,
4329,
26,
1079,
26,
2025,
58,
333,
24446,
2672,
199,
3,
6529,
26,
20232,
22311,
836,
665,
8302,
836,
32,
1548,
14,
1308,
30,
199,
3,
1898,
26,
961,
859,
965,
2757,
15090,
315,
314,
4575,
2881,
14,
199,
199,
624,
199,
1341,
10624,
367,
4722,
2396,
4008,
14,
199,
199,
9295,
658,
27114,
14,
11531,
14,
8332,
14,
23216,
64,
367,
3261,
2436,
14,
199,
624,
199,
199,
363,
21841,
363,
275,
283,
264,
27486,
1872,
7,
199,
199,
504,
18382,
492,
3380,
199,
504,
18382,
14,
11531,
14,
8332,
492,
3757,
8374,
199,
504,
18382,
14,
11531,
14,
8332,
492,
13502,
199,
504,
18382,
14,
11531,
14,
8332,
14,
8050,
492,
663,
63,
2888,
199,
504,
18382,
14,
1208,
14,
600,
63,
17965,
492,
21125,
12,
21125,
547,
12,
4860,
9863,
199,
199,
533,
3523,
23414,
8660,
8,
29489,
304,
339,
1415,
63,
4958,
275,
413,
272,
2716,
63,
4958,
275,
378,
272,
4242,
63,
2094,
63,
8506,
275,
715,
272,
945,
63,
1650,
275,
791,
533,
356,
13502,
14,
533,
63,
1422,
12,
673,
283,
354,
356,
13502,
14,
16914,
93,
272,
965,
63,
1317,
275,
715,
339,
1031,
63,
533,
275,
488,
272,
408,
1716,
1021,
370,
506,
1202,
334,
7790,
506,
663,
315,
9180,
10477,
339,
347,
1255,
8,
277,
304,
267,
340,
440,
334,
277,
14,
929,
63,
6744,
14,
1431,
63,
8916,
355,
503,
1228,
8,
277,
14,
929,
63,
6744,
14,
932,
12,
3380,
14,
27372,
2298,
288,
746,
291,
14,
705,
360,
1918,
2071,
83,
2,
13613,
1443,
440,
506,
1202,
4453,
283,
2490,
283,
11299,
503,
2396,
4008,
3530,
450,
291,
14,
354,
9,
267,
291,
14,
479,
63,
1989,
63,
1317,
342,
267,
2538,
63,
505,
275,
291,
14,
4958,
59,
16,
61,
267,
1318,
2415,
12,
3788,
275,
291,
14,
929,
14,
6460,
63,
505,
8,
1213,
63,
505,
12,
291,
14,
3469,
9,
267,
16194,
275,
359,
2415,
14,
1213,
8,
1213,
63,
505,
12,
3260,
627,
505,
2415,
1874,
267,
327,
428,
2655,
1700,
4440,
642,
1233,
14,
267,
340,
283,
14348,
7,
315,
291,
14,
1419,
26,
288,
1318,
2415,
12,
1655,
63,
3431,
275,
291,
14,
929,
14,
6460,
63,
505,
8,
355,
291,
14,
1419,
459,
14348,
995,
291,
14,
3469,
9,
288,
16194,
14,
740,
8,
2415,
14,
14348,
8,
277,
14,
1419,
459,
14348,
995,
3260,
1460,
627,
505,
2415,
430,
288,
3788,
14,
2880,
8,
6878,
63,
3431,
9,
267,
1318,
275,
1557,
78,
1370,
904,
8,
277,
14,
1317,
9,
267,
1031,
275,
291,
14,
932,
63,
533,
8,
505,
12,
26534,
8916,
435,
3788,
430,
267,
1031,
459,
2888,
418,
847,
291,
14,
1419,
14,
362,
360,
533,
297,
3073,
267,
291,
14,
525,
63,
354,
8,
932,
9,
267,
340,
1318,
26,
288,
291,
14,
929,
14,
6376,
63,
1122,
8,
277,
14,
1317,
12,
291,
14,
1317,
63,
2743,
12,
1031,
9,
267,
372,
359,
932,
61,
421,
199,
533,
32166,
8,
1563,
23414,
8660,
304,
339,
1031,
63,
533,
275,
3380,
14,
5746,
421,
199,
533,
428,
2655,
1700,
8,
1563,
23414,
8660,
304,
339,
1031,
63,
533,
275,
3380,
14,
27372,
339,
945,
63,
1650,
275,
3523,
23414,
8660,
14,
1422,
63,
1650,
14,
1574,
342,
272,
945,
63,
1650,
459,
14348,
418,
275,
13502,
14,
16914,
63,
2427,
339,
347,
1255,
8,
277,
304,
267,
340,
1228,
8,
277,
14,
929,
63,
6744,
14,
932,
12,
3380,
14,
27372,
304,
288,
746,
291,
14,
705,
360,
1918,
2071,
83,
2,
13613,
1443,
440,
506,
1202,
4453,
282,
283,
2490,
283,
27372,
1819,
3530,
450,
291,
14,
354,
9,
267,
372,
3523,
23414,
8660,
14,
1065,
8,
277,
9,
421,
199,
533,
7030,
3142,
8,
29489,
304,
339,
945,
63,
1650,
275,
791,
533,
356,
13502,
14,
533,
63,
1422,
12,
673,
283,
354,
356,
13502,
14,
16914,
93,
272,
965,
63,
1317,
275,
715,
339,
347,
1255,
8,
277,
304,
267,
291,
14,
479,
63,
1989,
63,
1317,
342,
267,
1853,
275,
3380,
14,
604,
63,
1457,
8,
2888,
29,
277,
14,
1419,
14,
362,
360,
533,
297,
15927,
267,
291,
14,
525,
63,
354,
8,
1457,
9,
267,
1031,
63,
513,
275,
359,
1457,
61,
267,
367,
1004,
63,
505,
315,
291,
14,
1317,
26,
288,
1318,
63,
2415,
12,
3788,
275,
291,
14,
929,
14,
6460,
63,
505,
8,
355,
1004,
63,
505,
14,
1913,
1062,
291,
14,
3469,
435,
291,
14,
1317,
63,
2743,
9,
288,
1004,
275,
3380,
14,
604,
8,
604,
63,
505,
12,
3260,
627,
505,
63,
2415,
9,
288,
340,
1004,
63,
505,
14,
1913,
837,
355,
1004,
14,
3724,
275,
822,
8,
604,
63,
505,
9,
446,
822,
8,
604,
63,
505,
14,
10124,
1012,
288,
1853,
847,
1004,
288,
1031,
63,
513,
14,
2880,
8,
3431,
9,
288,
291,
14,
1317,
63,
2743,
847,
413,
267,
291,
14,
929,
14,
15272,
63,
604,
63,
1457,
63,
1278,
8,
1457,
9,
267,
372,
1031,
63,
513,
421,
199,
533,
2235,
939,
7621,
8,
29489,
304,
339,
945,
63,
1650,
275,
791,
533,
356,
13502,
14,
533,
63,
1422,
12,
673,
283,
354,
356,
13502,
14,
16914,
93,
272,
965,
63,
1317,
275,
715,
339,
347,
1255,
8,
277,
304,
267,
663,
63,
2888,
8,
277,
14,
1419,
9,
267,
291,
14,
479,
63,
1989,
63,
1317,
342,
267,
1318,
275,
1557,
78,
1370,
904,
8,
277,
14,
1317,
9,
267,
1318,
63,
2415,
12,
3788,
275,
291,
14,
929,
14,
6460,
63,
505,
8,
505,
12,
291,
14,
3469,
9,
267,
1031,
275,
3380,
14,
8939,
63,
1457,
8,
505,
12,
3260,
627,
505,
63,
2415,
12,
1011,
277,
14,
1419,
9,
267,
1031,
14,
604,
275,
291,
14,
1317,
63,
2743,
435,
413,
267,
291,
14,
525,
63,
354,
8,
932,
9,
267,
372,
359,
932,
61,
435,
3788,
421,
199,
533,
5495,
3142,
8,
29489,
304,
272,
408,
4003,
436,
2216,
1536,
1564,
402,
282,
1233,
1853,
14,
339,
11595,
4260,
26,
6302,
63,
14337,
2126,
16332,
4040,
5495,
1564,
543,
14493,
31
] |
[
2672,
1304,
26,
2396,
14,
647,
1520,
13406,
7760,
13,
713,
13,
1165,
4329,
26,
1079,
26,
2025,
58,
333,
24446,
2672,
199,
3,
6529,
26,
20232,
22311,
836,
665,
8302,
836,
32,
1548,
14,
1308,
30,
199,
3,
1898,
26,
961,
859,
965,
2757,
15090,
315,
314,
4575,
2881,
14,
199,
199,
624,
199,
1341,
10624,
367,
4722,
2396,
4008,
14,
199,
199,
9295,
658,
27114,
14,
11531,
14,
8332,
14,
23216,
64,
367,
3261,
2436,
14,
199,
624,
199,
199,
363,
21841,
363,
275,
283,
264,
27486,
1872,
7,
199,
199,
504,
18382,
492,
3380,
199,
504,
18382,
14,
11531,
14,
8332,
492,
3757,
8374,
199,
504,
18382,
14,
11531,
14,
8332,
492,
13502,
199,
504,
18382,
14,
11531,
14,
8332,
14,
8050,
492,
663,
63,
2888,
199,
504,
18382,
14,
1208,
14,
600,
63,
17965,
492,
21125,
12,
21125,
547,
12,
4860,
9863,
199,
199,
533,
3523,
23414,
8660,
8,
29489,
304,
339,
1415,
63,
4958,
275,
413,
272,
2716,
63,
4958,
275,
378,
272,
4242,
63,
2094,
63,
8506,
275,
715,
272,
945,
63,
1650,
275,
791,
533,
356,
13502,
14,
533,
63,
1422,
12,
673,
283,
354,
356,
13502,
14,
16914,
93,
272,
965,
63,
1317,
275,
715,
339,
1031,
63,
533,
275,
488,
272,
408,
1716,
1021,
370,
506,
1202,
334,
7790,
506,
663,
315,
9180,
10477,
339,
347,
1255,
8,
277,
304,
267,
340,
440,
334,
277,
14,
929,
63,
6744,
14,
1431,
63,
8916,
355,
503,
1228,
8,
277,
14,
929,
63,
6744,
14,
932,
12,
3380,
14,
27372,
2298,
288,
746,
291,
14,
705,
360,
1918,
2071,
83,
2,
13613,
1443,
440,
506,
1202,
4453,
283,
2490,
283,
11299,
503,
2396,
4008,
3530,
450,
291,
14,
354,
9,
267,
291,
14,
479,
63,
1989,
63,
1317,
342,
267,
2538,
63,
505,
275,
291,
14,
4958,
59,
16,
61,
267,
1318,
2415,
12,
3788,
275,
291,
14,
929,
14,
6460,
63,
505,
8,
1213,
63,
505,
12,
291,
14,
3469,
9,
267,
16194,
275,
359,
2415,
14,
1213,
8,
1213,
63,
505,
12,
3260,
627,
505,
2415,
1874,
267,
327,
428,
2655,
1700,
4440,
642,
1233,
14,
267,
340,
283,
14348,
7,
315,
291,
14,
1419,
26,
288,
1318,
2415,
12,
1655,
63,
3431,
275,
291,
14,
929,
14,
6460,
63,
505,
8,
355,
291,
14,
1419,
459,
14348,
995,
291,
14,
3469,
9,
288,
16194,
14,
740,
8,
2415,
14,
14348,
8,
277,
14,
1419,
459,
14348,
995,
3260,
1460,
627,
505,
2415,
430,
288,
3788,
14,
2880,
8,
6878,
63,
3431,
9,
267,
1318,
275,
1557,
78,
1370,
904,
8,
277,
14,
1317,
9,
267,
1031,
275,
291,
14,
932,
63,
533,
8,
505,
12,
26534,
8916,
435,
3788,
430,
267,
1031,
459,
2888,
418,
847,
291,
14,
1419,
14,
362,
360,
533,
297,
3073,
267,
291,
14,
525,
63,
354,
8,
932,
9,
267,
340,
1318,
26,
288,
291,
14,
929,
14,
6376,
63,
1122,
8,
277,
14,
1317,
12,
291,
14,
1317,
63,
2743,
12,
1031,
9,
267,
372,
359,
932,
61,
421,
199,
533,
32166,
8,
1563,
23414,
8660,
304,
339,
1031,
63,
533,
275,
3380,
14,
5746,
421,
199,
533,
428,
2655,
1700,
8,
1563,
23414,
8660,
304,
339,
1031,
63,
533,
275,
3380,
14,
27372,
339,
945,
63,
1650,
275,
3523,
23414,
8660,
14,
1422,
63,
1650,
14,
1574,
342,
272,
945,
63,
1650,
459,
14348,
418,
275,
13502,
14,
16914,
63,
2427,
339,
347,
1255,
8,
277,
304,
267,
340,
1228,
8,
277,
14,
929,
63,
6744,
14,
932,
12,
3380,
14,
27372,
304,
288,
746,
291,
14,
705,
360,
1918,
2071,
83,
2,
13613,
1443,
440,
506,
1202,
4453,
282,
283,
2490,
283,
27372,
1819,
3530,
450,
291,
14,
354,
9,
267,
372,
3523,
23414,
8660,
14,
1065,
8,
277,
9,
421,
199,
533,
7030,
3142,
8,
29489,
304,
339,
945,
63,
1650,
275,
791,
533,
356,
13502,
14,
533,
63,
1422,
12,
673,
283,
354,
356,
13502,
14,
16914,
93,
272,
965,
63,
1317,
275,
715,
339,
347,
1255,
8,
277,
304,
267,
291,
14,
479,
63,
1989,
63,
1317,
342,
267,
1853,
275,
3380,
14,
604,
63,
1457,
8,
2888,
29,
277,
14,
1419,
14,
362,
360,
533,
297,
15927,
267,
291,
14,
525,
63,
354,
8,
1457,
9,
267,
1031,
63,
513,
275,
359,
1457,
61,
267,
367,
1004,
63,
505,
315,
291,
14,
1317,
26,
288,
1318,
63,
2415,
12,
3788,
275,
291,
14,
929,
14,
6460,
63,
505,
8,
355,
1004,
63,
505,
14,
1913,
1062,
291,
14,
3469,
435,
291,
14,
1317,
63,
2743,
9,
288,
1004,
275,
3380,
14,
604,
8,
604,
63,
505,
12,
3260,
627,
505,
63,
2415,
9,
288,
340,
1004,
63,
505,
14,
1913,
837,
355,
1004,
14,
3724,
275,
822,
8,
604,
63,
505,
9,
446,
822,
8,
604,
63,
505,
14,
10124,
1012,
288,
1853,
847,
1004,
288,
1031,
63,
513,
14,
2880,
8,
3431,
9,
288,
291,
14,
1317,
63,
2743,
847,
413,
267,
291,
14,
929,
14,
15272,
63,
604,
63,
1457,
63,
1278,
8,
1457,
9,
267,
372,
1031,
63,
513,
421,
199,
533,
2235,
939,
7621,
8,
29489,
304,
339,
945,
63,
1650,
275,
791,
533,
356,
13502,
14,
533,
63,
1422,
12,
673,
283,
354,
356,
13502,
14,
16914,
93,
272,
965,
63,
1317,
275,
715,
339,
347,
1255,
8,
277,
304,
267,
663,
63,
2888,
8,
277,
14,
1419,
9,
267,
291,
14,
479,
63,
1989,
63,
1317,
342,
267,
1318,
275,
1557,
78,
1370,
904,
8,
277,
14,
1317,
9,
267,
1318,
63,
2415,
12,
3788,
275,
291,
14,
929,
14,
6460,
63,
505,
8,
505,
12,
291,
14,
3469,
9,
267,
1031,
275,
3380,
14,
8939,
63,
1457,
8,
505,
12,
3260,
627,
505,
63,
2415,
12,
1011,
277,
14,
1419,
9,
267,
1031,
14,
604,
275,
291,
14,
1317,
63,
2743,
435,
413,
267,
291,
14,
525,
63,
354,
8,
932,
9,
267,
372,
359,
932,
61,
435,
3788,
421,
199,
533,
5495,
3142,
8,
29489,
304,
272,
408,
4003,
436,
2216,
1536,
1564,
402,
282,
1233,
1853,
14,
339,
11595,
4260,
26,
6302,
63,
14337,
2126,
16332,
4040,
5495,
1564,
543,
14493,
31,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
hasteur/wikipedia_bot_tasks
|
families/uncyclopedia_family.py
|
4
|
76001
|
# -*- coding: utf-8 -*-
import config, family, urllib
__version__ = '$Id$'
#
# The Uncyclomedia family, assorted encyclopedi.as from the Uncyclopedia series.
# This file contains a full set of (currently) fifty languages, excluding forks,
# redirects and mirrors.
#
# Note that some of the wikia in this set are known to have badly incomplete,
# missing or incorrect interwiki maps. Do *not* attempt to invoke interwiki.py
# on Uncyclopedia-related wikis unless you have verified availability of
# links for all language pairs that you will plan to use as interwikis.
#
class Family(family.Family):
def __init__(self):
family.Family.__init__(self)
self.name = 'uncyclopedia'
self.langs = {
'af': 'niesiklopedia.org',
'ar': 'beidipedia.wikia.com',
'ast': 'nunyepedia.wikia.com',
'bar': 'www.stupidedia.org',
'be': 'paudurapedyja.org',
'bg': 'bg.oxypedia.net',
'bn': 'bn.uncyc.org',
'bs': 'bs.neciklopedija.org',
'ca': 'valenciclopedia.wikia.com',
'common': 'commons.uncyclomedia.org',
'cs': 'necyklopedie.wikia.com',
'cy': 'cy.uncyclopedia.org.uk',
'da': 'spademanns.wikia.com',
'de': 'de.uncyclopedia.org',
'dlm': 'dlm.neciklopedija.org',
'el': 'frikipaideia.wikia.com',
'en': 'uncyclopedia.wikia.com',
'eo': 'neciklopedio.wikia.com',
'es': 'inciclopedia.wikia.com',
'et': 'ebatsuklopeedia.org',
'fa': 'fa.uncyc.org',
'fi': 'hiki.pedia.ws',
'fo': 'www.fo.ikkepedia.org',
'fr': 'desencyclopedie.wikia.com',
'fy': 'unsyklopedy.org',
'ga': 'ga.uncyc.org',
'gl': 'desgalipedia.org',
'got': 'unsaiklopedia.org',
'grc': 'kakapedia.org',
'he': 'eincyclopedia.wikia.com',
'hr': 'hr.neciklopedija.org',
'hu': 'unciklopedia.org',
'hy': 'angragitaran.org',
'id': 'tolololpedia.wikia.com',
'ie': 'ninciclopedia.org',
'info': 'uncyclopedia.info',
'io': 'io.neciklopedio.org',
'is': 'is.ikkepedia.org',
'it': 'nonciclopedia.wikia.com',
'ja': 'ansaikuropedia.org',
'jv': 'ndhablek.wikia.com',
'ka': 'anciklopedia.org',
'km': 'km.uncyclopedia.info',
'ko': 'uncyclopedia.kr',
'la': 'uncapaedia.org',
'lb': 'kengencyclopedia.org',
'li': 'kwatsjpedia.org',
'lo': 'lo.uncyclopedia.info',
'lt': 'juokopedija.org',
'lv': 'lv.neciklopedija.org',
'meta': 'uncyclomedia.org',
'mg': 'hatsiklopedia.org',
'mk': 'mk.neciklopedija.org',
'mo': 'uichipedia.net',
'ms': 'bodohpedia.org',
'mwl': 'cciclopedia.org',
'nl': 'oncyclopedia.net',
'nn': 'ikkjepedia.org',
'no': 'ikkepedia.org',
'oc': 'oisquipedia.org',
'pl': 'nonsensopedia.wikia.com',
'pt': 'desciclopedia.org',
'ro': 'neciclopedie.org',
'ru': 'absurdopedia.net',
'sco': 'scotypedia.org',
'simple': 'simple.uncyc.org',
'sk': 'necyklopedia.wikia.com',
'sl': 'butalopedija.org',
'sr': 'sr.neciklopedija.org',
'su': 'su.goblogpedia.wikia.com',
'sv': 'psyklopedin.org',
'th': 'th.uncyclopedia.info',
'tl': 'pekepedia.net',
'tlh': 'tlh.uncyc.org',
'tr': 'yansiklopedi.org',
'uk': 'inciklopedia.org',
'vls': 'kweenipedia.org',
'yi': 'keinziklopedie.wikia.com',
'zh': 'cn.uncyclopedia.wikia.com',
'zh-hk': 'uncyclopedia.hk',
'zh-tw': 'uncyclopedia.tw',
'zombie': 'zombie.pedia.ws',
}
#
# project namespaces & custom namespace lists
#
self.namespaces[-2] = {
'_default': u'Media',
'ar': u'ميديا',
'bar': u'Medium',
'be': u'Мультымедыя',
'bg': u'Медия',
'bn': u'মিডিয়া',
'bs': u'Mediji',
'cs': u'Média',
'el': u'Μέσο',
'et': u'Meedia',
'fa': u'مدیا',
'fo': u'Miðil',
'fr': u'Média',
'ga': u'Meán',
'he': u'מדיה',
'hr': u'Mediji',
'hu': u'Média',
'hy': u'Մեդիա',
'is': u'Miðill',
'ja': u'メディア',
'ka': u'მედია',
'km': u'មេឌា',
'ko': u'미디어',
'lo': u'ສື່',
'lt': u'Medija',
'mg': u'Rakitra',
'mk': u'Медија',
'nn': u'Filpeikar',
'no': u'Medium',
'oc': u'Mèdia',
'pt': u'Mídia',
'ru': u'Медиа',
'sk': u'Médiá',
'sl': u'Datoteka',
'sr': u'Медија',
'su': u'Média',
'th': u'สื่อ',
'tl': u'Midya',
'tlh': u'Doch',
'tr': u'Medya',
'uk': u'Медіа',
'yi': u'מעדיע',
'zh-hk': u'媒體',
'zh-tw': u'媒體',
}
self.namespaces[-1] = {
'_default': u'Special',
'af': u'Spesiaal',
'ar': u'خاص',
'ast': u'Especial',
'bar': u'Spezial',
'be': u'Адмысловае',
'bg': u'Специални',
'bn': u'বিশেষ',
'bs': u'Posebno',
'ca': u'Especial',
'cs': u'Speciální',
'cy': u'Arbennig',
'da': u'Speciel',
'de': u'Spezial',
'el': u'Ειδικό',
'eo': u'Speciala',
'es': u'Especial',
'et': u'Eri',
'fa': u'ویژه',
'fi': u'Toiminnot',
'fo': u'Serstakt',
'fr': u'Spécial',
'fy': u'Wiki',
'ga': u'Speisialta',
'gl': u'Especial',
'he': u'מיוחד',
'hr': u'Posebno',
'hu': u'Speciális',
'hy': u'Սպասարկող',
'id': u'Istimewa',
'io': u'Specala',
'is': u'Kerfissíða',
'it': u'Speciale',
'ja': u'特別',
'jv': u'Astamiwa',
'ka': u'სპეციალური',
'km': u'ពិសេស',
'ko': u'특수기능',
'la': u'Specialis',
'lb': u'Spezial',
'li': u'Speciaal',
'lo': u'ພິເສດ',
'lt': u'Specialus',
'mg': u'Manokana',
'mk': u'Специјални',
'ms': u'Khas',
'nl': u'Speciaal',
'nn': u'Spesial',
'no': u'Spesial',
'oc': u'Especial',
'pl': u'Specjalna',
'pt': u'Especial',
'ru': u'Служебная',
'sk': u'Špeciálne',
'sl': u'Posebno',
'sr': u'Посебно',
'su': u'Husus',
'th': u'พิเศษ',
'tl': u'Natatangi',
'tlh': u'le\'',
'tr': u'Özel',
'uk': u'Спеціальна',
'vls': u'Specioal',
'yi': u'באַזונדער',
'zh-hk': u'特殊',
'zh-tw': u'特殊',
}
self.namespaces[1] = {
'_default': u'Talk',
'af': u'Bespreking',
'ar': u'نقاش',
'ast': u'Alderique',
'bar': u'Diskussion',
'be': u'Размовы',
'bg': u'Беседа',
'bn': u'আলাপ',
'bs': u'Razgovor',
'ca': u'Discussió',
'cs': u'Diskuse',
'cy': u'Sgwrs',
'da': u'Diskussion',
'de': u'Diskussion',
'el': u'Συζήτηση',
'eo': u'Diskuto',
'es': u'Discusión',
'et': u'Arutelu',
'fa': u'بحث',
'fi': u'Keskustelu',
'fo': u'Kjak',
'fr': u'Discussion',
'fy': u'Oerlis',
'ga': u'Plé',
'gl': u'Conversa',
'he': u'שיחה',
'hr': u'Razgovor',
'hu': u'Vita',
'hy': u'Քննարկում',
'id': u'Pembicaraan',
'io': u'Debato',
'is': u'Spjall',
'it': u'Discussione',
'ja': u'トーク',
'jv': u'Dhiskusi',
'ka': u'განხილვა',
'km': u'ការពិភាក្សា',
'ko': u'토론',
'la': u'Disputatio',
'lb': u'Diskussioun',
'li': u'Euverlèk',
'lo': u'ສົນທະນາ',
'lt': u'Aptarimas',
'lv': u'Diskusija',
'mg': u'Dinika',
'mk': u'Разговор',
'mo': u'Discuție',
'ms': u'Perbincangan',
'mwl': u'Cumbersa',
'nl': u'Overleg',
'nn': u'Diskusjon',
'no': u'Diskusjon',
'oc': u'Discutir',
'pl': u'Dyskusja',
'pt': u'Discussão',
'ro': u'Discuție',
'ru': u'Обсуждение',
'sk': u'Diskusia',
'sl': u'Pogovor',
'sr': u'Разговор',
'su': u'Obrolan',
'sv': u'Diskussion',
'th': u'พูดคุย',
'tl': u'Usapan',
'tlh': u'ja\'chuq',
'tr': u'Tartışma',
'uk': u'Обговорення',
'vls': u'Discuusje',
'yi': u'רעדן',
'zh-hk': u'討論',
'zh-tw': u'討論',
}
self.namespaces[2] = {
'_default': u'User',
'af': u'Gebruiker',
'ar': u'مستخدم',
'ast': u'Usuariu',
'bar': u'Benutzer',
'be': u'Удзельнік',
'bg': u'Потребител',
'bn': u'ব্যবহারকারী',
'bs': u'Korisnik',
'ca': u'Usuari',
'cs': u'Uživatel',
'cy': u'Defnyddiwr',
'da': u'Bruger',
'de': u'Benutzer',
'el': u'Χρήστης',
'eo': u'Vikipediisto',
'es': u'Usuario',
'et': u'Kasutaja',
'fa': u'کاربر',
'fi': u'Käyttäjä',
'fo': u'Brúkari',
'fr': u'Utilisateur',
'fy': u'Meidogger',
'ga': u'Úsáideoir',
'gl': u'Usuario',
'he': u'משתמש',
'hr': u'Suradnik',
'hu': u'Szerkesztő',
'hy': u'Մասնակից',
'id': u'Pengguna',
'io': u'Uzanto',
'is': u'Notandi',
'it': u'Utente',
'ja': u'利用者',
'jv': u'Panganggo',
'ka': u'მომხმარებელი',
'km': u'អ្នកប្រើប្រាស់',
'ko': u'사용자',
'la': u'Usor',
'lb': u'Benotzer',
'li': u'Gebroeker',
'lo': u'ຜູ້ໃຊ້',
'lt': u'Naudotojas',
'lv': u'Lietotājs',
'mg': u'Mpikambana',
'mk': u'Корисник',
'mo': u'Utilizator',
'ms': u'Pengguna',
'mwl': u'Outelizador',
'nl': u'Gebruiker',
'nn': u'Brukar',
'no': u'Bruker',
'oc': u'Utilizaire',
'pl': u'Użytkownik',
'pt': u'Usuário',
'ro': u'Utilizator',
'ru': u'Участник',
'sk': u'Redaktor',
'sl': u'Uporabnik',
'sr': u'Корисник',
'su': u'Pamaké',
'sv': u'Användare',
'th': u'ผู้ใช้',
'tl': u'Tagagamit',
'tlh': u'lo\'wI\'',
'tr': u'Kullanıcı',
'uk': u'Користувач',
'vls': u'Gebruker',
'yi': u'באַניצער',
'zh-hk': u'用戶',
'zh-tw': u'用戶',
}
self.namespaces[3] = {
'_default': u'User talk',
'af': u'Gebruikerbespreking',
'ar': u'نقاش المستخدم',
'ast': u'Usuariu alderique',
'bar': u'Benutzer Diskussion',
'be': u'Размовы з удзельнікам',
'bg': u'Потребител беседа',
'bn': u'ব্যবহারকারী আলাপ',
'bs': u'Razgovor sa korisnikom',
'ca': u'Usuari Discussió',
'cs': u'Uživatel diskuse',
'cy': u'Sgwrs Defnyddiwr',
'da': u'Brugerdiskussion',
'de': u'Benutzer Diskussion',
'el': u'Συζήτηση χρήστη',
'eo': u'Vikipediista diskuto',
'es': u'Usuario Discusión',
'et': u'Kasutaja arutelu',
'fa': u'بحث کاربر',
'fi': u'Keskustelu käyttäjästä',
'fo': u'Brúkarakjak',
'fr': u'Discussion utilisateur',
'fy': u'Meidogger oerlis',
'ga': u'Plé úsáideora',
'gl': u'Conversa usuario',
'he': u'שיחת משתמש',
'hr': u'Razgovor sa suradnikom',
'hu': u'Szerkesztővita',
'hy': u'Մասնակցի քննարկում',
'id': u'Pembicaraan Pengguna',
'io': u'Uzanto Debato',
'is': u'Notandaspjall',
'it': u'Discussioni utente',
'ja': u'利用者・トーク',
'jv': u'Dhiskusi Panganggo',
'ka': u'მომხმარებლის განხილვა',
'km': u'ការពិភាក្សារបស់អ្នកប្រើប្រាស់',
'ko': u'사용자토론',
'la': u'Disputatio Usoris',
'lb': u'Benotzer Diskussioun',
'li': u'Euverlèk gebroeker',
'lo': u'ສົນທະນາຂອງຜູ້ໃຊ້',
'lt': u'Naudotojo aptarimas',
'lv': u'Lietotāja diskusija',
'mg': u'Dinika amin\'ny mpikambana',
'mk': u'Разговор со корисник',
'mo': u'Discuție Utilizator',
'ms': u'Perbincangan Pengguna',
'mwl': u'Cumbersa outelizador',
'nl': u'Overleg gebruiker',
'nn': u'Brukardiskusjon',
'no': u'Brukerdiskusjon',
'oc': u'Discussion Utilizaire',
'pl': u'Dyskusja użytkownika',
'pt': u'Usuário Discussão',
'ro': u'Discuție Utilizator',
'ru': u'Обсуждение участника',
'sk': u'Diskusia s redaktorom',
'sl': u'Uporabniški pogovor',
'sr': u'Разговор са корисником',
'su': u'Obrolan pamaké',
'sv': u'Användardiskussion',
'th': u'คุยกับผู้ใช้',
'tl': u'Usapang tagagamit',
'tlh': u'lo\'wI\' ja\'chuq',
'tr': u'Kullanıcı mesaj',
'uk': u'Обговорення користувача',
'vls': u'Discuusje gebruker',
'yi': u'באַניצער רעדן',
'zh-hk': u'用戶討論',
'zh-tw': u'用戶討論',
}
self.namespaces[4] = {
'_default': u'Project',
'af': u'Niesiklopedia',
'ar': u'بيضيپيديا',
'ast': u'Nunyepedia',
'bar': u'Stupidedia',
'be': u'Паўдурапедыя',
'bg': u'Oxypedia',
'bn': u'আনসাইক্লোপিডিয়া',
'bs': u'Neciklopedija',
'ca': u'Valenciclopèdia',
'common': u'UnCommons',
'cs': u'Necyklopedie',
'cy': u'Celwyddoniadur',
'da': u'Spademanns Leksikon',
'de': u'Uncyclopedia',
'dlm': u'Neciklopedija',
'el': u'Φρικηπαίδεια',
'en': u'Uncyclopedia',
'eo': u'Neciklopedio',
'es': u'Inciclopedia',
'et': u'Ebatsüklopeedia',
'fa': u'نانشنامه',
'fi': u'Hikipedia',
'fo': u'Wikkepedia',
'fr': u'Désencyclopédie',
'fy': u'Unsyklopedy',
'ga': u'Frithchiclipéid',
'gl': u'Desgalipedia',
'got': u'Unsaiklopedia',
'grc': u'Κακαπαιδεια',
'he': u'איןציקלופדיה',
'hr': u'Neciklopedija',
'hu': u'Unciklopédia',
'hy': u'Angragitaran',
'id': u'Tolololpedia',
'ie': u'Ninciclopedia',
'info': u'Uncyclopaedia',
'io': u'Neciklopedio',
'is': u'Ekkipedia',
'it': u'Nonciclopedia',
'ja': u'Uncyclopedia',
'jv': u'Ndhablek',
'ka': u'Anciklopedia',
'km': u'Uncyclopedia',
'ko': u'백괴사전',
'la': u'Necyclopaedia',
'lb': u'Kengencyclopedia',
'li': u'Kwatsjpedia',
'lo': u'Uncyclopedia',
'lt': u'Juokopediją',
'lv': u'Neciklopēdija',
'meta': u'UnMeta',
'mg': u'Hatsiklopedia',
'mk': u'Нециклопедий',
'mo': u'Neciclopedia',
'ms': u'Bodohpedia',
'mwl': u'Çciclopédia',
'nl': u'Oncyclopedia',
'nn': u'Ikkjepedia',
'no': u'Ikkepedia',
'oc': u'Oisquipedia',
'pl': u'Nonsensopedia',
'pt': u'Desciclopédia',
'ro': u'Neciclopedie',
'ru': u'Абсурдопедия',
'sco': u'Scotypedia',
'simple': u'Uncyclopedia',
'sk': u'Necyklopédia',
'sl': u'Butalopedija',
'sr': u'Нециклопедија',
'su': u'Goblogpedia Wiki',
'sv': u'Psyklopedin',
'th': u'ไร้สาระนุกรม',
'tl': u'Pekepedia',
'tlh': u'ghItlh\'a\'pedia',
'tr': u'Yansiklopedi',
'uk': u'Інциклопедія',
'vls': u'Kweenipedia',
'yi': u'קיינציקלאָפעדיע',
'zh': u'伪基百科',
'zh-hk': u'偽基百科',
'zh-tw': u'偽基百科',
'zombie': u'Zombiepedia',
}
self.namespaces[5] = {
'_default': u'Project talk',
'af': u'Niesiklopediabespreking',
'ar': u'نقاش بيضيپيديا',
'ast': u'Nunyepedia alderique',
'bar': u'Stupidedia Diskussion',
'be': u'Паўдурапедыя размовы',
'bg': u'Oxypedia беседа',
'bn': u'আনসাইক্লোপিডিয়া আলোচনা',
'bs': u'Razgovor s Neciklopedija',
'ca': u'Valenciclopèdia Discussió',
'common': u'UnCommons talk',
'cs': u'Necyklopedie diskuse',
'cy': u'Sgwrs Celwyddoniadur',
'da': u'Spademanns Leksikon-diskussion',
'de': u'Uncyclopedia Diskussion',
'dlm': u'Neciklopedija talk',
'el': u'Φρικηπαίδεια συζήτηση',
'en': u'Uncyclopedia talk',
'eo': u'Neciklopedio diskuto',
'es': u'Inciclopedia Discusión',
'et': u'Ebatsüklopeedia arutelu',
'fa': u'بحث نانشنامه',
'fi': u'Keskustelu Hikipediasta',
'fo': u'Wikkepedia-kjak',
'fr': u'Discussion Désencyclopédie',
'fy': u'Unsyklopedy oerlis',
'ga': u'Plé Frithchiclipéid',
'gl': u'Conversa Desgalipedia',
'got': u'Unsaiklopedia talk',
'grc': u'Κακαπαιδεια talk',
'he': u'שיחת איןציקלופדיה',
'hr': u'Razgovor Neciklopedija',
'hu': u'Unciklopédia-vita',
'hy': u'Angragitaran քննարկում',
'id': u'Pembicaraan Tolololpedia',
'ie': u'Ninciclopedia talk',
'info': u'Uncyclopaedia talk',
'io': u'Neciklopedio Debato',
'is': u'Ekkipediaspjall',
'it': u'Discussioni Nonciclopedia',
'ja': u'Uncyclopedia・トーク',
'jv': u'Dhiskusi Ndhablek',
'ka': u'Anciklopedia განხილვა',
'km': u'ការពិភាក្សាអំពីUncyclopedia',
'ko': u'백괴사전토론',
'la': u'Disputatio Necyclopaediae',
'lb': u'Kengencyclopedia Diskussioun',
'li': u'Euverlèk Kwatsjpedia',
'lo': u'ສົນທະນາກ່ຽວກັບUncyclopedia',
'lt': u'Juokopediją aptarimas',
'lv': u'Neciklopēdija diskusija',
'meta': u'UnMeta talk',
'mg': u'Dinika amin\'ny Hatsiklopedia',
'mk': u'Разговор за Нециклопедий',
'mo': u'Discuție Neciclopedia',
'ms': u'Perbincangan Bodohpedia',
'mwl': u'Çciclopédia cumbersa',
'nl': u'Overleg Oncyclopedia',
'nn': u'Ikkjepedia-diskusjon',
'no': u'Ikkepedia-diskusjon',
'oc': u'Discussion Oisquipedia',
'pl': u'Dyskusja Nonsensopedia',
'pt': u'Desciclopédia Discussão',
'ro': u'Discuție Neciclopedie',
'ru': u'Обсуждение Абсурдопедии',
'sco': u'Scotypedia talk',
'simple': u'Uncyclopedia talk',
'sk': u'Diskusia k Necyklopédia',
'sl': u'Pogovor o Butalopedija',
'sr': u'Разговор о Нециклопедија',
'su': u'Obrolan Goblogpedia Wiki',
'sv': u'Psyklopedindiskussion',
'th': u'คุยเรื่องไร้สาระนุกรม',
'tl': u'Usapang Pekepedia',
'tlh': u'ghItlh\'a\'pedia ja\'chuq',
'tr': u'Yansiklopedi tartışma',
'uk': u'Обговорення Інциклопедії',
'vls': u'Discuusje Kweenipedia',
'yi': u'קיינציקלאָפעדיע רעדן',
'zh': u'伪基百科 talk',
'zh-hk': u'偽基百科討論',
'zh-tw': u'偽基百科討論',
'zombie': u'Zombiepedia talk',
}
self.namespaces[6] = {
'_default': u'File',
'af': u'Lêer',
'ar': u'ملف',
'ast': u'Archivu',
'bar': u'Datei',
'be': u'Выява',
'bg': u'Файл',
'bn': u'চিত্র',
'bs': u'Datoteka',
'ca': u'Fitxer',
'common': u'Image',
'cs': u'Soubor',
'cy': u'Delwedd',
'da': u'Fil',
'de': u'Datei',
'el': u'Αρχείο',
'eo': u'Dosiero',
'es': u'Archivo',
'et': u'Pilt',
'fa': u'پرونده',
'fi': u'Tiedosto',
'fo': u'Mynd',
'fr': u'Fichier',
'fy': u'Ofbyld',
'ga': u'Íomhá',
'gl': u'Ficheiro',
'he': u'קובץ',
'hr': u'Datoteka',
'hu': u'Fájl',
'hy': u'Պատկեր',
'id': u'Berkas',
'io': u'Arkivo',
'is': u'Mynd',
'ja': u'ファイル',
'jv': u'Gambar',
'ka': u'ფაილი',
'km': u'ឯកសារ',
'ko': u'파일',
'la': u'Fasciculus',
'lb': u'Fichier',
'li': u'Plaetje',
'lo': u'ຮູບ',
'lt': u'Vaizdas',
'lv': u'Attēls',
'mg': u'Sary',
'mk': u'Податотека',
'mo': u'Fișier',
'ms': u'Fail',
'mwl': u'Fexeiro',
'nl': u'Bestand',
'nn': u'Fil',
'no': u'Fil',
'oc': u'Fichièr',
'pl': u'Plik',
'pt': u'Imagem',
'ro': u'Fișier',
'ru': u'Файл',
'sk': u'Súbor',
'sl': u'Slika',
'sr': u'Слика',
'su': u'Gambar',
'sv': u'Fil',
'th': u'ไฟล์',
'tl': u'Talaksan',
'tlh': u'nagh beQ',
'tr': u'Dosya',
'uk': u'Файл',
'vls': u'Ofbeeldienge',
'yi': u'טעקע',
'zh-hk': u'圖像',
'zh-tw': u'圖像',
}
self.namespaces[7] = {
'_default': u'File talk',
'af': u'Lêerbespreking',
'ar': u'نقاش الملف',
'ast': u'Archivu alderique',
'bar': u'Datei Diskussion',
'be': u'Размовы пра выяву',
'bg': u'Файл беседа',
'bn': u'চিত্র আলোচনা',
'bs': u'Razgovor o datoteci',
'ca': u'Fitxer Discussió',
'common': u'Image talk',
'cs': u'Soubor diskuse',
'cy': u'Sgwrs Delwedd',
'da': u'Fildiskussion',
'de': u'Datei Diskussion',
'el': u'Συζήτηση αρχείου',
'eo': u'Dosiera diskuto',
'es': u'Archivo Discusión',
'et': u'Pildi arutelu',
'fa': u'بحث پرونده',
'fi': u'Keskustelu tiedostosta',
'fo': u'Myndakjak',
'fr': u'Discussion fichier',
'fy': u'Ofbyld oerlis',
'ga': u'Plé íomhá',
'gl': u'Conversa ficheiro',
'he': u'שיחת קובץ',
'hr': u'Razgovor o datoteci',
'hu': u'Fájlvita',
'hy': u'Պատկերի քննարկում',
'id': u'Pembicaraan Berkas',
'io': u'Arkivo Debato',
'is': u'Myndaspjall',
'it': u'Discussioni file',
'ja': u'ファイル・トーク',
'jv': u'Dhiskusi Gambar',
'ka': u'ფაილის განხილვა',
'km': u'ការពិភាក្សាអំពីឯកសារ',
'ko': u'파일토론',
'la': u'Disputatio Fasciculi',
'lb': u'Fichier Diskussioun',
'li': u'Euverlèk plaetje',
'lo': u'ສົນທະນາກ່ຽວກັບຮູບ',
'lt': u'Vaizdo aptarimas',
'lv': u'Attēla diskusija',
'mg': u'Dinika amin\'ny sary',
'mk': u'Разговор за податотека',
'mo': u'Discuție Fișier',
'ms': u'Perbincangan Fail',
'mwl': u'Cumbersa fexeiro',
'nl': u'Overleg bestand',
'nn': u'Fildiskusjon',
'no': u'Fildiskusjon',
'oc': u'Discussion Fichièr',
'pl': u'Dyskusja pliku',
'pt': u'Imagem Discussão',
'ro': u'Discuție Fișier',
'ru': u'Обсуждение файла',
'sk': u'Diskusia k súboru',
'sl': u'Pogovor o sliki',
'sr': u'Разговор о слици',
'su': u'Obrolan gambar',
'sv': u'Fildiskussion',
'th': u'คุยเรื่องไฟล์',
'tl': u'Usapang talaksan',
'tlh': u'nagh beQ ja\'chuq',
'tr': u'Dosya tartışma',
'uk': u'Обговорення файлу',
'vls': u'Discuusje ofbeeldienge',
'yi': u'טעקע רעדן',
'zh-hk': u'圖像討論',
'zh-tw': u'圖像討論',
}
self.namespaces[8] = {
'_default': u'MediaWiki',
'ar': u'ميدياويكي',
'bg': u'МедияУики',
'bn': u'মিডিয়াউইকি',
'cy': u'MediaWici',
'fa': u'مدیاویکی',
'fi': u'Järjestelmäviesti',
'he': u'מדיה ויקי',
'is': u'Melding',
'ka': u'მედიავიკი',
'km': u'មេឌាវិគី',
'ko': u'미디어위키',
'lo': u'ມີເດຍວິກິ',
'mk': u'МедијаВики',
'mwl': u'Biqui',
'sr': u'МедијаВики',
'su': u'MédiaWiki',
'th': u'มีเดียวิกิ',
'yi': u'מעדיעװיקי',
'zh-hk': u'媒體偽基',
'zh-tw': u'媒體偽基',
}
self.namespaces[9] = {
'_default': u'MediaWiki talk',
'af': u'MediaWikibespreking',
'ar': u'نقاش ميدياويكي',
'ast': u'MediaWiki alderique',
'bar': u'MediaWiki Diskussion',
'be': u'Размовы пра MediaWiki',
'bg': u'МедияУики беседа',
'bn': u'মিডিয়াউইকি আলোচনা',
'bs': u'MediaWiki razgovor',
'ca': u'MediaWiki Discussió',
'cs': u'MediaWiki diskuse',
'cy': u'Sgwrs MediaWici',
'da': u'MediaWiki-diskussion',
'de': u'MediaWiki Diskussion',
'el': u'Συζήτηση MediaWiki',
'eo': u'MediaWiki diskuto',
'es': u'MediaWiki Discusión',
'et': u'MediaWiki arutelu',
'fa': u'بحث مدیاویکی',
'fi': u'Keskustelu järjestelmäviestistä',
'fo': u'MediaWiki-kjak',
'fr': u'Discussion MediaWiki',
'fy': u'MediaWiki oerlis',
'ga': u'Plé MediaWiki',
'gl': u'Conversa MediaWiki',
'he': u'שיחת מדיה ויקי',
'hr': u'MediaWiki razgovor',
'hu': u'MediaWiki-vita',
'hy': u'MediaWiki քննարկում',
'id': u'Pembicaraan MediaWiki',
'io': u'MediaWiki Debato',
'is': u'Meldingarspjall',
'it': u'Discussioni MediaWiki',
'ja': u'MediaWiki・トーク',
'jv': u'Dhiskusi MediaWiki',
'ka': u'მედიავიკის განხილვა',
'km': u'ការពិភាក្សាអំពីមេឌាវិគី',
'ko': u'미디어위키토론',
'la': u'Disputatio MediaWiki',
'lb': u'MediaWiki Diskussioun',
'li': u'Euverlèk MediaWiki',
'lo': u'ສົນທະນາກ່ຽວກັບມີເດຍວິກິ',
'lt': u'MediaWiki aptarimas',
'lv': u'MediaWiki diskusija',
'mg': u'Dinika amin\'ny MediaWiki',
'mk': u'Разговор за МедијаВики',
'mo': u'Discuție MediaWiki',
'ms': u'Perbincangan MediaWiki',
'mwl': u'Cumbersa Biqui',
'nl': u'Overleg MediaWiki',
'nn': u'MediaWiki-diskusjon',
'no': u'MediaWiki-diskusjon',
'oc': u'Discussion MediaWiki',
'pl': u'Dyskusja MediaWiki',
'pt': u'MediaWiki Discussão',
'ro': u'Discuție MediaWiki',
'ru': u'Обсуждение MediaWiki',
'sk': u'Diskusia k MediaWiki',
'sl': u'Pogovor o MediaWiki',
'sr': u'Разговор о МедијаВикију',
'su': u'Obrolan MédiaWiki',
'sv': u'MediaWiki-diskussion',
'th': u'คุยเรื่องมีเดียวิกิ',
'tl': u'Usapang MediaWiki',
'tlh': u'MediaWiki ja\'chuq',
'tr': u'MediaWiki tartışma',
'uk': u'Обговорення MediaWiki',
'vls': u'Discuusje MediaWiki',
'yi': u'מעדיעװיקי רעדן',
'zh-hk': u'媒體偽基討論',
'zh-tw': u'媒體偽基討論',
}
self.namespaces[10] = {
'_default': u'Template',
'af': u'Sjabloon',
'ar': u'قالب',
'ast': u'Plantía',
'bar': u'Vorlage',
'be': u'Шаблон',
'bg': u'Шаблон',
'bn': u'টেমপ্লেট',
'bs': u'Šablon',
'ca': u'Plantilla',
'cs': u'Šablona',
'cy': u'Nodyn',
'da': u'Skabelon',
'de': u'Vorlage',
'el': u'Πρότυπο',
'eo': u'Ŝablono',
'es': u'Plantilla',
'et': u'Mall',
'fa': u'الگو',
'fi': u'Malline',
'fo': u'Fyrimynd',
'fr': u'Modèle',
'fy': u'Berjocht',
'ga': u'Teimpléad',
'gl': u'Modelo',
'he': u'תבנית',
'hr': u'Predložak',
'hu': u'Sablon',
'hy': u'Կաղապար',
'id': u'Templat',
'io': u'Shablono',
'is': u'Snið',
'ja': u'テンプレート',
'jv': u'Cithakan',
'ka': u'თარგი',
'km': u'ទំព័រគំរូ',
'ko': u'틀',
'la': u'Formula',
'lb': u'Schabloun',
'li': u'Sjabloon',
'lo': u'ແມ່ແບບ',
'lt': u'Šablonas',
'lv': u'Veidne',
'mg': u'Endrika',
'mk': u'Шаблон',
'mo': u'Format',
'ms': u'Templat',
'mwl': u'Modelo',
'nl': u'Sjabloon',
'nn': u'Mal',
'no': u'Mal',
'oc': u'Modèl',
'pl': u'Szablon',
'pt': u'Predefinição',
'ro': u'Format',
'ru': u'Шаблон',
'sk': u'Šablóna',
'sl': u'Predloga',
'sr': u'Шаблон',
'su': u'Citakan',
'sv': u'Mall',
'th': u'แม่แบบ',
'tl': u'Suleras',
'tlh': u'chen\'ay\'',
'tr': u'Şablon',
'uk': u'Шаблон',
'vls': u'Patrôon',
'yi': u'מוסטער',
'zh-hk': u'範本',
'zh-tw': u'範本',
}
self.namespaces[11] = {
'_default': u'Template talk',
'af': u'Sjabloonbespreking',
'ar': u'نقاش القالب',
'ast': u'Plantía alderique',
'bar': u'Vorlage Diskussion',
'be': u'Размовы пра шаблон',
'bg': u'Шаблон беседа',
'bn': u'টেমপ্লেট আলোচনা',
'bs': u'Razgovor o šablonu',
'ca': u'Plantilla Discussió',
'cs': u'Šablona diskuse',
'cy': u'Sgwrs Nodyn',
'da': u'Skabelondiskussion',
'de': u'Vorlage Diskussion',
'el': u'Συζήτηση προτύπου',
'eo': u'Ŝablona diskuto',
'es': u'Plantilla Discusión',
'et': u'Malli arutelu',
'fa': u'بحث الگو',
'fi': u'Keskustelu mallineesta',
'fo': u'Fyrimyndakjak',
'fr': u'Discussion modèle',
'fy': u'Berjocht oerlis',
'ga': u'Plé teimpléid',
'gl': u'Conversa modelo',
'he': u'שיחת תבנית',
'hr': u'Razgovor o predlošku',
'hu': u'Sablonvita',
'hy': u'Կաղապարի քննարկում',
'id': u'Pembicaraan Templat',
'io': u'Shablono Debato',
'is': u'Sniðaspjall',
'it': u'Discussioni template',
'ja': u'テンプレート・トーク',
'jv': u'Dhiskusi Cithakan',
'ka': u'თარგის განხილვა',
'km': u'ការពិភាក្សាអំពីទំព័រគំរូ',
'ko': u'틀토론',
'la': u'Disputatio Formulae',
'lb': u'Schabloun Diskussioun',
'li': u'Euverlèk sjabloon',
'lo': u'ສົນທະນາກ່ຽວກັບແມ່ແບບ',
'lt': u'Šablono aptarimas',
'lv': u'Veidnes diskusija',
'mg': u'Dinika amin\'ny endrika',
'mk': u'Разговор за шаблон',
'mo': u'Discuție Format',
'ms': u'Perbincangan Templat',
'mwl': u'Cumbersa Modelo',
'nl': u'Overleg sjabloon',
'nn': u'Maldiskusjon',
'no': u'Maldiskusjon',
'oc': u'Discussion Modèl',
'pl': u'Dyskusja szablonu',
'pt': u'Predefinição Discussão',
'ro': u'Discuție Format',
'ru': u'Обсуждение шаблона',
'sk': u'Diskusia k šablóne',
'sl': u'Pogovor o predlogi',
'sr': u'Разговор о шаблону',
'su': u'Obrolan citakan',
'sv': u'Malldiskussion',
'th': u'คุยเรื่องแม่แบบ',
'tl': u'Usapang suleras',
'tlh': u'chen\'ay\' ja\'chuq',
'tr': u'Şablon tartışma',
'uk': u'Обговорення шаблону',
'vls': u'Discuusje patrôon',
'yi': u'מוסטער רעדן',
'zh-hk': u'範本討論',
'zh-tw': u'範本討論',
}
self.namespaces[12] = {
'_default': u'Help',
'af': u'Hulp',
'ar': u'مساعدة',
'ast': u'Aida',
'bar': u'Hilfe',
'be': u'Даведка',
'bg': u'Помощ',
'bn': u'সাহায্য',
'bs': u'Pomoć',
'ca': u'Ajuda',
'cs': u'Nápověda',
'cy': u'Cymorth',
'da': u'Hjælp',
'de': u'Hilfe',
'el': u'Βοήθεια',
'eo': u'Helpo',
'es': u'Ayuda',
'et': u'Juhend',
'fa': u'راهنما',
'fi': u'Ohje',
'fo': u'Hjálp',
'fr': u'Aide',
'fy': u'Hulp',
'ga': u'Cabhair',
'gl': u'Axuda',
'he': u'מדריך',
'hr': u'Pomoć',
'hu': u'Segítség',
'hy': u'Օգնություն',
'id': u'Bantuan',
'io': u'Helpo',
'is': u'Hjálp',
'it': u'Aiuto',
'ja': u'ヘルプ',
'jv': u'Pitulung',
'ka': u'დახმარება',
'km': u'ជំនួយ',
'ko': u'도움말',
'la': u'Auxilium',
'lb': u'Hëllef',
'lo': u'ຊ່ວຍເຫຼືອ',
'lt': u'Pagalba',
'lv': u'Palīdzība',
'mg': u'Fanoroana',
'mk': u'Помош',
'mo': u'Ajutor',
'ms': u'Bantuan',
'mwl': u'Ajuda',
'nn': u'Hjelp',
'no': u'Hjelp',
'oc': u'Ajuda',
'pl': u'Pomoc',
'pt': u'Ajuda',
'ro': u'Ajutor',
'ru': u'Справка',
'sk': u'Pomoc',
'sl': u'Pomoč',
'sr': u'Помоћ',
'su': u'Pitulung',
'sv': u'Hjälp',
'th': u'วิธีใช้',
'tl': u'Tulong',
'tlh': u'QaH',
'tr': u'Yardım',
'uk': u'Довідка',
'vls': u'Ulpe',
'yi': u'הילף',
'zh-hk': u'協助',
'zh-tw': u'協助',
}
self.namespaces[13] = {
'_default': u'Help talk',
'af': u'Hulpbespreking',
'ar': u'نقاش المساعدة',
'ast': u'Aida alderique',
'bar': u'Hilfe Diskussion',
'be': u'Размовы пра даведку',
'bg': u'Помощ беседа',
'bn': u'সাহায্য আলোচনা',
'bs': u'Razgovor o pomoći',
'ca': u'Ajuda Discussió',
'cs': u'Nápověda diskuse',
'cy': u'Sgwrs Cymorth',
'da': u'Hjælp-diskussion',
'de': u'Hilfe Diskussion',
'el': u'Συζήτηση βοήθειας',
'eo': u'Helpa diskuto',
'es': u'Ayuda Discusión',
'et': u'Juhendi arutelu',
'fa': u'بحث راهنما',
'fi': u'Keskustelu ohjeesta',
'fo': u'Hjálparkjak',
'fr': u'Discussion aide',
'fy': u'Hulp oerlis',
'ga': u'Plé cabhrach',
'gl': u'Conversa axuda',
'he': u'שיחת מדריך',
'hr': u'Razgovor o pomoći',
'hu': u'Segítségvita',
'hy': u'Օգնության քննարկում',
'id': u'Pembicaraan Bantuan',
'io': u'Helpo Debato',
'is': u'Hjálparspjall',
'it': u'Discussioni aiuto',
'ja': u'ヘルプ・トーク',
'jv': u'Dhiskusi Pitulung',
'ka': u'დახმარების განხილვა',
'km': u'ការពិភាក្សាអំពីជំនួយ',
'ko': u'도움말토론',
'la': u'Disputatio Auxilii',
'lb': u'Hëllef Diskussioun',
'li': u'Euverlèk help',
'lo': u'ສົນທະນາກ່ຽວກັບຊ່ວຍເຫຼືອ',
'lt': u'Pagalbos aptarimas',
'lv': u'Palīdzības diskusija',
'mg': u'Dinika amin\'ny fanoroana',
'mk': u'Разговор за помош',
'mo': u'Discuție Ajutor',
'ms': u'Perbincangan Bantuan',
'mwl': u'Cumbersa ajuda',
'nl': u'Overleg help',
'nn': u'Hjelpdiskusjon',
'no': u'Hjelpdiskusjon',
'oc': u'Discussion Ajuda',
'pl': u'Dyskusja pomocy',
'pt': u'Ajuda Discussão',
'ro': u'Discuție Ajutor',
'ru': u'Обсуждение справки',
'sk': u'Diskusia k pomoci',
'sl': u'Pogovor o pomoči',
'sr': u'Разговор о помоћи',
'su': u'Obrolan pitulung',
'sv': u'Hjälpdiskussion',
'th': u'คุยเรื่องวิธีใช้',
'tl': u'Usapang tulong',
'tlh': u'QaH ja\'chuq',
'tr': u'Yardım tartışma',
'uk': u'Обговорення довідки',
'vls': u'Discuusje ulpe',
'yi': u'הילף רעדן',
'zh-hk': u'協助討論',
'zh-tw': u'協助討論',
}
self.namespaces[14] = {
'_default': u'Category',
'af': u'Kategorie',
'ar': u'تصنيف',
'ast': u'Categoría',
'bar': u'Kategorie',
'be': u'Катэгорыя',
'bg': u'Категория',
'bn': u'বিষয়শ্রেণী',
'bs': u'Kategorija',
'ca': u'Categoria',
'cs': u'Kategorie',
'cy': u'Categori',
'da': u'Kategori',
'de': u'Kategorie',
'el': u'Κατηγορία',
'eo': u'Kategorio',
'es': u'Categoría',
'et': u'Kategooria',
'fa': u'رده',
'fi': u'Luokka',
'fo': u'Bólkur',
'fr': u'Catégorie',
'fy': u'Kategory',
'ga': u'Catagóir',
'gl': u'Categoría',
'he': u'קטגוריה',
'hr': u'Kategorija',
'hu': u'Kategória',
'hy': u'Կատեգորիա',
'id': u'Kategori',
'io': u'Kategorio',
'is': u'Flokkur',
'it': u'Categoria',
'ja': u'カテゴリ',
'jv': u'Kategori',
'ka': u'კატეგორია',
'km': u'ចំនាត់ថ្នាក់ក្រុម',
'ko': u'분류',
'la': u'Categoria',
'lb': u'Kategorie',
'li': u'Categorie',
'lo': u'ໝວດ',
'lt': u'Kategorija',
'lv': u'Kategorija',
'mg': u'Sokajy',
'mk': u'Категорија',
'mo': u'Categorie',
'ms': u'Kategori',
'mwl': u'Catadorie',
'nl': u'Categorie',
'nn': u'Kategori',
'no': u'Kategori',
'oc': u'Categoria',
'pl': u'Kategoria',
'pt': u'Categoria',
'ro': u'Categorie',
'ru': u'Категория',
'sk': u'Kategória',
'sl': u'Kategorija',
'sr': u'Категорија',
'su': u'Kategori',
'sv': u'Kategori',
'th': u'หมวดหมู่',
'tl': u'Kaurian',
'tlh': u'Segh',
'tr': u'Kategori',
'uk': u'Категорія',
'vls': u'Categorie',
'yi': u'קאַטעגאָריע',
'zh-hk': u'分類',
'zh-tw': u'分類',
}
self.namespaces[15] = {
'_default': u'Category talk',
'af': u'Kategoriebespreking',
'ar': u'نقاش التصنيف',
'ast': u'Categoría alderique',
'bar': u'Kategorie Diskussion',
'be': u'Размовы пра катэгорыю',
'bg': u'Категория беседа',
'bn': u'বিষয়শ্রেণী আলোচনা',
'bs': u'Razgovor o kategoriji',
'ca': u'Categoria Discussió',
'cs': u'Kategorie diskuse',
'cy': u'Sgwrs Categori',
'da': u'Kategoridiskussion',
'de': u'Kategorie Diskussion',
'el': u'Συζήτηση κατηγορίας',
'eo': u'Kategoria diskuto',
'es': u'Categoría Discusión',
'et': u'Kategooria arutelu',
'fa': u'بحث رده',
'fi': u'Keskustelu luokasta',
'fo': u'Bólkakjak',
'fr': u'Discussion catégorie',
'fy': u'Kategory oerlis',
'ga': u'Plé catagóire',
'gl': u'Conversa categoría',
'he': u'שיחת קטגוריה',
'hr': u'Razgovor o kategoriji',
'hu': u'Kategóriavita',
'hy': u'Կատեգորիայի քննարկում',
'id': u'Pembicaraan Kategori',
'io': u'Kategorio Debato',
'is': u'Flokkaspjall',
'it': u'Discussioni categoria',
'ja': u'カテゴリ・トーク',
'jv': u'Dhiskusi Kategori',
'ka': u'კატეგორიის განხილვა',
'km': u'ការពិភាក្សាអំពីចំនាត់ថ្នាក់ក្រុម',
'ko': u'분류토론',
'la': u'Disputatio Categoriae',
'lb': u'Kategorie Diskussioun',
'li': u'Euverlèk categorie',
'lo': u'ສົນທະນາກ່ຽວກັບໝວດ',
'lt': u'Kategorijos aptarimas',
'lv': u'Kategorijas diskusija',
'mg': u'Dinika amin\'ny sokajy',
'mk': u'Разговор за категорија',
'mo': u'Discuție Categorie',
'ms': u'Perbincangan Kategori',
'mwl': u'Cumbersa catadorie',
'nl': u'Overleg categorie',
'nn': u'Kategoridiskusjon',
'no': u'Kategoridiskusjon',
'oc': u'Discussion Categoria',
'pl': u'Dyskusja kategorii',
'pt': u'Categoria Discussão',
'ro': u'Discuție Categorie',
'ru': u'Обсуждение категории',
'sk': u'Diskusia ku kategórii',
'sl': u'Pogovor o kategoriji',
'sr': u'Разговор о категорији',
'su': u'Obrolan kategori',
'sv': u'Kategoridiskussion',
'th': u'คุยเรื่องหมวดหมู่',
'tl': u'Usapang kaurian',
'tlh': u'Segh ja\'chuq',
'tr': u'Kategori tartışma',
'uk': u'Обговорення категорії',
'vls': u'Discuusje categorie',
'yi': u'קאַטעגאָריע רעדן',
'zh-hk': u'分類討論',
'zh-tw': u'分類討論',
}
self.namespaces[16] = {
'dlm': u'Necikloparaula',
'et': u'Foorum',
'fi': u'Foorumi',
'got': u'Forum',
'info': u'Game',
'meta': u'UnSource',
'mo': u'Necţionar',
'nl': u'Portaal',
'simple': u'HowTo',
'th': u'อันไซโคลพีเดีย',
'zh-hk': u'偽基新聞',
'zh-tw': u'偽基新聞',
}
self.namespaces[17] = {
'dlm': u'Necikloparaula talk',
'fi': u'Keskustelu foorumista',
'got': u'Forum gawaurdja',
'info': u'Game talk',
'meta': u'UnSource talk',
'mo': u'Discuție Necţionar',
'nl': u'Overleg portaal',
'simple': u'HowTo talk',
'th': u'คุยเรื่องอันไซโคลพีเดีย',
'zh-hk': u'偽基新聞討論',
'zh-tw': u'偽基新聞討論',
}
self.namespaces[18] = {
'fi': u'Hikinews',
'got': u'𐌰𐍂𐌼𐌰𐌹𐍉',
'meta': u'UnSpecies',
'nl': u'OnNieuws',
'pt': u'Fatos',
'simple': u'Undex',
'th': u'ไร้ข่าว',
'zh-hk': u'偽基辭典',
'zh-tw': u'偽基辭典',
}
self.namespaces[19] = {
'fi': u'Keskustelu Hikinewseistä',
'got': u'𐌰𐍂𐌼𐌰𐌹𐍉 𐌲𐌰𐍅𐌰𐌿𐍂𐌳𐌾𐌰',
'meta': u'UnSpecies talk',
'nl': u'Overleg OnNieuws',
'pt': u'Fatos Discussão',
'simple': u'Undex talk',
'th': u'คุยเรื่องไร้ข่าว',
'zh-hk': u'偽基辭典討論',
'zh-tw': u'偽基辭典討論',
}
self.namespaces[20] = {
'fi': u'Hiktionary',
'got': u'𐍆𐌰𐌹𐌰𐌽𐍅𐌰𐍂𐌳𐌰𐌱𐍉𐌺𐌰',
'nl': u'Onwoordenboek',
'pt': u'Forum',
'simple': u'Userbox',
'th': u'ไร้วิทยาลัย',
'zh-hk': u'動漫遊戲',
'zh-tw': u'動漫遊戲',
}
self.namespaces[21] = {
'fi': u'Keskustelu Hiktionarysta',
'got': u'𐍆𐌰𐌹𐌰𐌽𐍅𐌰𐍂𐌳𐌰𐌱𐍉𐌺𐌰 𐌲𐌰𐍅𐌰𐌿𐍂𐌳𐌾𐌰',
'nl': u'Overleg Onwoordenboek',
'pt': u'Forum Discussão',
'simple': u'Userbox talk',
'th': u'คุยเรื่องไร้วิทยาลัย',
'zh-hk': u'動漫遊戲討論',
'zh-tw': u'動漫遊戲討論',
}
self.namespaces[22] = {
'fi': u'Hikikirjasto',
'meta': u'UnN',
'nl': u'OnBoeken',
'pt': u'Descitações',
'simple': u'Disambiguation',
'th': u'ไร้พจนานุกรม',
'zh-hk': u'偽基文庫',
'zh-tw': u'偽基文庫',
}
self.namespaces[23] = {
'fi': u'Keskustelu hikikirjasta',
'meta': u'UnN talk',
'nl': u'Overleg OnBoeken',
'pt': u'Descitações Discussão',
'simple': u'Disambiguation talk',
'th': u'คุยเรื่องไร้พจนานุกรม',
'zh-hk': u'偽基文庫討論',
'zh-tw': u'偽基文庫討論',
}
self.namespaces[24] = {
'fi': u'Hikisitaatit',
'meta': u'Forum',
'ro': u'Forum',
'simple': u'Forum',
'th': u'ไร้ชีวประวัติ',
'zh-hk': u'主題展館',
'zh-tw': u'主題展館',
}
self.namespaces[25] = {
'fi': u'Keskustelu hikisitaatista',
'meta': u'Forum talk',
'ro': u'Discuție Forum',
'simple': u'Forum talk',
'th': u'คุยเรื่องไร้ชีวประวัติ',
'zh-hk': u'主題展館討論',
'zh-tw': u'主題展館討論',
}
self.namespaces[26] = {
'meta': u'Babel',
'nl': u'OnZinnen',
'ro': u'Necimanuale',
'simple': u'UnNews',
'th': u'สภาน้ำชา',
'zh-hk': u'論壇',
'zh-tw': u'論壇',
}
self.namespaces[27] = {
'meta': u'Babel talk',
'nl': u'Overleg OnZinnen',
'ro': u'Discuție Necimanuale',
'simple': u'UnNews talk',
'th': u'คุยเรื่องสภาน้ำชา',
}
self.namespaces[28] = {
'fi': u'Hikipeli',
'meta': u'UnRecipes',
'nl': u'Ongerijmd',
'simple': u'UnBooks',
'th': u'บอร์ด',
'zh-hk': u'詞意分道',
'zh-tw': u'詞意分道',
}
self.namespaces[29] = {
'fi': u'Hihitys Hikipelistä',
'meta': u'UnRecipes talk',
'nl': u'Overleg Ongerijmd',
'simple': u'UnBooks talk',
'th': u'คุยเรื่องบอร์ด',
'zh-hk': u'詞意分道討論',
'zh-tw': u'詞意分道討論',
}
self.namespaces[30] = {
'fi': u'Hikiopisto',
'meta': u'UnLeaks',
'nl': u'Oncycloversiteit',
'pt': u'Deslivros',
'ro': u'Necikţionar',
'simple': u'UnDictionary',
'th': u'ไร้ซอร์ซ',
'zh-hk': u'臺語',
'zh-tw': u'臺語',
}
self.namespaces[31] = {
'fi': u'Keskustelu hikikurssista',
'meta': u'UnLeaks talk',
'nl': u'Overleg Oncycloversiteit',
'pt': u'Deslivros Discussão',
'ro': u'Discuție Necikţionar',
'simple': u'UnDictionary talk',
'th': u'คุยเรื่องไร้ซอร์ซ',
'zh-hk': u'臺語討論',
'zh-tw': u'臺語討論',
}
self.namespaces[32] = {
'fi': u'Hikiaineisto',
'ja': u'Portal',
'meta': u'UnMD',
'nl': u'Unsyklopedy',
'pt': u'Desentrevistas',
'ro': u'Necicitat',
'th': u'ไร้คำคม',
'zh-hk': u'香港語',
'zh-tw': u'香港語',
}
self.namespaces[33] = {
'fi': u'Keskustelu hikiaineistosta',
'ja': u'Portal talk',
'meta': u'UnMD talk',
'nl': u'Overleg Unsyklopedy',
'pt': u'Desentrevistas Discussão',
'ro': u'Discuție Necicitat',
'th': u'คุยเรื่องไร้คำคม',
'zh-hk': u'香港語討論',
'zh-tw': u'香港語討論',
}
self.namespaces[34] = {
'meta': u'Ezentziklopedia',
'nl': u'Niesiklopedia',
'pt': u'Despoesias',
'th': u'ไร้ภาพ',
'zh-hk': u'UnTunes',
'zh-tw': u'UnTunes',
}
self.namespaces[35] = {
'meta': u'Ezentziklopedia talk',
'nl': u'Overleg Niesiklopedia',
'pt': u'Despoesias Discussão',
'th': u'คุยเรื่องไร้ภาพ',
'zh-hk': u'UnTunes討論',
'zh-tw': u'UnTunes討論',
}
self.namespaces[36] = {
'meta': u'Nociclopeya',
'pt': u'Interno',
'th': u'สถานีย่อย',
}
self.namespaces[37] = {
'meta': u'Nociclopeya talk',
'pt': u'Interno Discussão',
'th': u'คุยเรื่องสถานีย่อย',
}
self.namespaces[38] = {
'meta': u'Venciclopedia',
'pt': u'Descifras',
'th': u'ไร้นวนิยาย',
}
self.namespaces[39] = {
'meta': u'Venciclopedia talk',
'pt': u'Descifras Discussão',
'th': u'คุยเรื่องไร้นวนิยาย',
}
self.namespaces[40] = {
'meta': u'Nunciclopedia',
}
self.namespaces[41] = {
'meta': u'Nunciclopedia talk',
}
self.namespaces[100] = {
'bar': u'Portal',
'de': u'UnNews',
'fa': u'درگاه',
'gl': u'Desgalicitas',
'he': u'איןציטוט',
'ko': u'구백괴게임',
'no': u'Ikkenytt',
'pl': u'Cytaty',
'ru': u'Портал',
'sv': u'PsykNyheter',
'tr': u'YanSözlük',
'uk': u'Форум',
}
self.namespaces[101] = {
'bar': u'Portal Diskussion',
'de': u'UnNews Diskussion',
'fa': u'بحث درگاه',
'gl': u'Conversa Desgalicitas',
'he': u'שיחת איןציטוט',
'ko': u'구백괴게임토론',
'no': u'Ikkenytt-diskusjon',
'pl': u'Dyskusja cytatów',
'ru': u'Обсуждение портала',
'sv': u'PsykNyheter diskussion',
'tr': u'YanSözlük tartışma',
'uk': u'Обговорення форуму',
}
self.namespaces[102] = {
'bar': u'Diverses',
'de': u'Undictionary',
'en': u'UnNews',
'gl': u'Desgalilibros',
'ja': u'UnNews',
'ko': u'포럼',
'no': u'Ikktionary',
'pl': u'NonNews',
'sv': u'Forum',
'tr': u'YanHaber',
}
self.namespaces[103] = {
'bar': u'Diverses Diskussion',
'de': u'Undictionary Diskussion',
'en': u'UnNews talk',
'gl': u'Conversa Desgalilibros',
'ja': u'UnNews talk',
'ko': u'포럼토론',
'no': u'Ikktionary-diskusjon',
'pl': u'Dyskusja NonNews',
'sv': u'Forumdiskussion',
'tr': u'YanHaber tartışma',
}
self.namespaces[104] = {
'bar': u'Sub',
'de': u'UnBooks',
'en': u'Undictionary',
'gl': u'Desgalinews',
'ja': u'Undictionary',
'ko': u'백괴뉴스',
'pl': u'Nonźródła',
'sv': u'Psyktionary',
}
self.namespaces[105] = {
'bar': u'Sub Diskussion',
'de': u'UnBooks Diskussion',
'en': u'Undictionary talk',
'gl': u'Conversa Desgalinews',
'ja': u'Undictionary talk',
'ko': u'백괴뉴스토론',
'pl': u'Dyskusja nonźródeł',
'sv': u'Psyktionary diskussion',
}
self.namespaces[106] = {
'bar': u'Spiegelwelten',
'en': u'Game',
'gl': u'Desgalizionario',
'ja': u'Game',
'ko': u'백괴낱말사전',
'pl': u'Słownik',
'pt': u'Desnotícias',
'sv': u'PsykCitat',
'tlh': u'GhItNews',
}
self.namespaces[107] = {
'bar': u'Spiegelwelten Diskussion',
'en': u'Game talk',
'gl': u'Conversa Desgalizionario',
'ja': u'Game talk',
'ko': u'백괴낱말사전토론',
'pl': u'Dyskusja słownika',
'pt': u'Desnotícias Discussão',
'sv': u'PsykCitat diskussion',
'tlh': u'GhItNews ja\'chuq',
}
self.namespaces[108] = {
'en': u'Babel',
'ko': u'해설',
'pl': u'Gra',
'sv': u'Spel',
'tlh': u'Forum',
}
self.namespaces[109] = {
'en': u'Babel talk',
'ko': u'해설토론',
'pl': u'Dyskusja gry',
'sv': u'Speldiskussion',
'tlh': u'Forum ja\'chuq',
}
self.namespaces[110] = {
'af': u'Forum',
'ar': u'Forum',
'ast': u'Forum',
'ca': u'Forum',
'cs': u'Forum',
'da': u'Forum',
'de': u'Forum',
'el': u'Forum',
'en': u'Forum',
'eo': u'Forum',
'es': u'Foro',
'fo': u'Forum',
'fr': u'Forum',
'fy': u'Forum',
'gl': u'Forum',
'he': u'בית קפה',
'id': u'Forum',
'ie': u'Forum',
'io': u'Forum',
'is': u'Forum',
'it': u'Forum',
'ja': u'Forum',
'jv': u'Forum',
'mwl': u'Forum',
'no': u'Forum',
'pl': u'Forum',
'pt': u'Descionário',
'ru': u'Форум',
'sk': u'Forum',
'su': u'Forum',
'sv': u'PsykBöcker',
'tlh': u'Holdictionary',
'tr': u'Astroloji',
'vls': u'Forum',
'yi': u'Forum',
'zh': u'Forum',
}
self.namespaces[111] = {
'af': u'Forum talk',
'ar': u'Forum talk',
'ast': u'Forum talk',
'ca': u'Forum talk',
'cs': u'Forum talk',
'da': u'Forumdiskussion',
'de': u'Forum talk',
'el': u'Forum talk',
'en': u'Forum talk',
'eo': u'Forum talk',
'es': u'Foro Discusión',
'fo': u'Forum talk',
'fr': u'Discussion Forum',
'fy': u'Forum talk',
'gl': u'Conversa Forum',
'he': u'שיחת בית קפה',
'id': u'Forum talk',
'ie': u'Forum talk',
'io': u'Forum talk',
'is': u'Forum talk',
'it': u'Forum talk',
'ja': u'Forum talk',
'jv': u'Forum talk',
'mwl': u'Forum talk',
'pl': u'Dyskusja forum',
'pt': u'Descionário Discussão',
'ru': u'Обсуждение форума',
'sk': u'Forum talk',
'su': u'Forum talk',
'sv': u'PsykBöckerdiskussion',
'tlh': u'Holdictionary ja\'chuq',
'tr': u'Astroloji tartışma',
'vls': u'Forum talk',
'yi': u'Forum talk',
'zh': u'Forum talk',
}
self.namespaces[112] = {
'cs': u'Regál',
'en': u'UnTunes',
'es': u'Incinoticias',
'fr': u'Désinformation',
'gl': u'Çciclopédia',
'he': u'איןספר',
'it': u'NonNotizie',
'ja': u'UnTunes',
'ko': u'세계관',
'no': u'Hvordan',
'pl': u'Portal',
'ru': u'Абсурдилище',
'tlh': u'Tlhbooks',
'tr': u'Forum',
'zh': u'伪基新闻',
}
self.namespaces[113] = {
'cs': u'Regál diskuse',
'en': u'UnTunes talk',
'es': u'Incinoticias Discusión',
'fr': u'Discussion Désinformation',
'gl': u'Conversa Çciclopédia',
'he': u'שיחת איןספר',
'it': u'Discussioni NonNotizie',
'ja': u'UnTunes talk',
'ko': u'세계관토론',
'no': u'Hvordan-diskusjon',
'pl': u'Dyskusja portalu',
'ru': u'Обсуждение в Абсурдилище',
'tlh': u'Tlhbooks ja\'chuq',
'tr': u'Forum tartışma',
'zh': u'伪基新闻 talk',
}
self.namespaces[114] = {
'cs': u'Necykloverzita',
'es': u'Incitables',
'fr': u'Portail',
'he': u'איןחדש',
'ko': u'백괴대학',
'no': u'Hvorfor',
'pl': u'Poradnik',
'ru': u'Как правильно',
'tlh': u'Ninciclopedia',
'zh': u'伪基文库',
}
self.namespaces[115] = {
'cs': u'Necykloverzita diskuse',
'es': u'Incitables Discusión',
'fr': u'Discussion Portail',
'he': u'שיחת איןחדש',
'ko': u'백괴대학토론',
'no': u'Hvorfor-diskusjon',
'pl': u'Dyskusja poradnika',
'ru': u'Обсуждение руководства',
'tlh': u'Ninciclopedia Discussion',
'zh': u'伪基文库 talk',
}
self.namespaces[116] = {
'es': u'Incijuegos',
'he': u'איןטקסט',
'ja': u'UnBooks',
'ko': u'백괴인용집',
'no': u'Ikkeratur',
'ru': u'Абсурдотека',
'tlh': u'GhItSpecies',
'zh': u'伪基音乐',
}
self.namespaces[117] = {
'es': u'Incijuegos Discusión',
'he': u'שיחת איןטקסט',
'ja': u'UnBooks talk',
'ko': u'백괴인용집토론',
'no': u'Ikkeratur-Diskusjon',
'ru': u'Обсуждение Абсурдотеки',
'tlh': u'GhItSpecies ja\'chuq',
'zh': u'伪基音乐 talk',
}
self.namespaces[118] = {
'he': u'בית קפה',
'it': u'Giochi',
'ko': u'백괴책',
'no': u'Ikkeprosjekt',
'ru': u'Несловарь',
'tlh': u'Holfacts',
'zh': u'伪基词典',
}
self.namespaces[119] = {
'he': u'בית קפה שיחת',
'it': u'Discussioni Giochi',
'ko': u'백괴책토론',
'no': u'Ikkeprosjekt-diskusjon',
'ru': u'Обсуждение Несловаря',
'tlh': u'Holfacts ja\'chuq',
'zh': u'伪基词典 talk',
}
self.namespaces[120] = {
'he': u'איןמילון',
'it': u'NonCitazioni',
'ko': u'백괴대본',
'pt': u'Privado',
'ru': u'Абсурдоцитатник',
'tlh': u'Tlhconversations',
'tr': u'YanMagazin',
}
self.namespaces[121] = {
'he': u'שיחת איןמילון',
'it': u'Discussioni NonCitazioni',
'ko': u'백괴대본토론',
'pt': u'Privado Discussão',
'ru': u'Обсуждение Абсурдоцитатника',
'tlh': u'Tlhconversations ja\'chuq',
'tr': u'YanMagazin tartışma',
}
self.namespaces[122] = {
'he': u'איןמינים',
'it': u'NonDizionario',
'ko': u'방법',
'pt': u'Regra',
}
self.namespaces[123] = {
'he': u'שיחת איןמינים',
'it': u'Discussioni NonDizionario',
'ko': u'방법토론',
'pt': u'Regra Discussão',
}
self.namespaces[124] = {
'it': u'Test',
'pt': u'Desinopses',
}
self.namespaces[125] = {
'it': u'Discussioni test',
'pt': u'Desinopses Discussão',
}
self.namespaces[126] = {
'it': u'NonLibri',
}
self.namespaces[127] = {
'it': u'Discussioni NonLibri',
}
self.namespaces[128] = {
'it': u'Manuali',
}
self.namespaces[129] = {
'it': u'Discussioni manuali',
}
self.namespaces[130] = {
'it': u'Portale',
}
self.namespaces[131] = {
'it': u'Discussioni portale',
}
self.namespaces[150] = {
'pt': u'Deslistas',
}
self.namespaces[151] = {
'pt': u'Deslistas Discussão',
}
self.namespaces[400] = {
'ar': u'Video',
'ast': u'Video',
'ca': u'Video',
'cs': u'Video',
'da': u'Video',
'de': u'Video',
'el': u'Video',
'eo': u'Video',
'es': u'Video',
'fr': u'Video',
'he': u'Video',
'id': u'Video',
'it': u'Video',
'jv': u'Video',
'pl': u'Video',
'sk': u'Video',
'su': u'Video',
'yi': u'Video',
'zh': u'Video',
}
self.namespaces[401] = {
'ar': u'Video talk',
'ast': u'Video talk',
'ca': u'Video talk',
'cs': u'Video talk',
'da': u'Video talk',
'de': u'Video Diskussion',
'el': u'Video talk',
'eo': u'Video talk',
'es': u'Video talk',
'fr': u'Video talk',
'he': u'Video talk',
'id': u'Video talk',
'it': u'Video talk',
'jv': u'Video talk',
'pl': u'Dyskusja Video',
'sk': u'Video talk',
'su': u'Video talk',
'yi': u'Video talk',
'zh': u'Video talk',
}
self.namespaces[420] = {
'af': u'Layer',
'mwl': u'Layer',
}
self.namespaces[421] = {
'af': u'Layer talk',
'mwl': u'Layer talk',
}
self.namespaces[500] = {
'ar': u'User blog',
'ast': u'User blog',
'ca': u'User blog',
'cs': u'User blog',
'da': u'User blog',
'de': u'Benutzer Blog',
'el': u'User blog',
'eo': u'User blog',
'es': u'Usuario Blog',
'fr': u'Blog utilisateur',
'he': u'User blog',
'id': u'User blog',
'jv': u'User blog',
'pl': u'User blog',
'sk': u'User blog',
'su': u'User blog',
'yi': u'User blog',
'zh': u'User blog',
}
self.namespaces[501] = {
'ar': u'User blog comment',
'ast': u'User blog comment',
'ca': u'User blog comment',
'cs': u'User blog comment',
'da': u'User blog comment',
'de': u'Benutzer Blog Kommentare',
'el': u'User blog comment',
'eo': u'User blog comment',
'es': u'Usuario Blog Comentario',
'fr': u'Commentaire blog utilisateur',
'he': u'User blog comment',
'id': u'User blog comment',
'jv': u'User blog comment',
'pl': u'User blog comment',
'sk': u'User blog comment',
'su': u'User blog comment',
'yi': u'User blog comment',
'zh': u'User blog comment',
}
self.namespaces[502] = {
'ar': u'Blog',
'ast': u'Blog',
'ca': u'Blog',
'cs': u'Blog',
'da': u'Blog',
'de': u'Blog',
'el': u'Blog',
'eo': u'Blog',
'es': u'Blog',
'fr': u'Blog',
'he': u'Blog',
'id': u'Blog',
'jv': u'Blog',
'pl': u'Blog',
'sk': u'Blog',
'su': u'Blog',
'yi': u'Blog',
'zh': u'Blog',
}
self.namespaces[503] = {
'ar': u'Blog talk',
'ast': u'Blog talk',
'ca': u'Blog talk',
'cs': u'Blog talk',
'da': u'Blog talk',
'de': u'Blog Diskussion',
'el': u'Blog talk',
'eo': u'Blog talk',
'es': u'Blog Discusión',
'fr': u'Blog talk',
'he': u'Blog talk',
'id': u'Blog talk',
'jv': u'Blog talk',
'pl': u'Blog talk',
'sk': u'Blog talk',
'su': u'Blog talk',
'yi': u'Blog talk',
'zh': u'Blog talk',
}
# A few selected big languages for things that we do not want to loop over
# all languages. This is only needed by the titletranslate.py module, so
# if you carefully avoid the options, you could get away without these
# for another wiki family.
self.languages_by_size = [
'pt', 'en', 'it', 'bar', 'es', 'fr', 'ja', 'pl', 'zh-tw', 'zh-hk',
'fi', 'ko', 'no', 'th', 'ru', 'he', 'nl', 'zh', 'de', 'da', 'cs',
'el', 'id', 'eo', 'sk', 'hu', 'sv', 'tr', 'gl', 'uk', 'ar', 'nn',
'fa', 'sr', 'hr', 'ca', 'ast', 'tl', 'mg', 'la', 'ro', 'lt',
'simple', 'bg', 'lv', 'ms', 'et', 'tlh', 'mo', 'mk', 'lb', 'lo',
'got', 'oc', 'sl', 'li', 'ka', 'mwl', 'cy', 'zombie', 'hy', 'bn',
'dlm', 'bs', 'km', 'yi', 'be', 'vls', 'sco', 'su', 'jv', 'af',
'grc', 'ga', 'ie', 'io', 'fy', 'is', 'fo',
]
self.alphabetic_revised = [
'af', 'ar', 'ast', 'bar', 'be', 'bg', 'bn', 'bs', 'ca', 'common',
'cs', 'cy', 'da', 'de', 'dlm', 'el', 'en', 'eo', 'es', 'et', 'fa',
'fi', 'fo', 'fr', 'fy', 'ga', 'gl', 'got', 'grc', 'he', 'hr', 'hu',
'hy', 'id', 'ie', 'info', 'io', 'is', 'it', 'ja', 'jv', 'ka', 'km',
'ko', 'la', 'lb', 'li', 'lo', 'lt', 'lv', 'meta', 'mg', 'mk', 'mo',
'ms', 'mwl', 'nl', 'nn', 'no', 'oc', 'pl', 'pt', 'ro', 'ru', 'sco',
'simple', 'sk', 'sl', 'sr', 'su', 'sv', 'th', 'tl', 'tlh', 'tr',
'uk', 'vls', 'yi', 'zh', 'zh-hk', 'zh-tw', 'zombie',
]
def scriptpath(self, code):
if code == 'ko':
return '/w'
return ''
def version(self, code):
if code == 'ru':
return '1.16.0'
if code in ['ar', 'ast', 'ca', 'cs', 'da', 'de', 'el', 'en', 'eo', 'es',
'fr', 'he', 'id', 'it', 'jv', 'pl', 'sk', 'su', 'yi', 'zh']:
return '1.16.5'
if code in ['bar', 'ko']:
return '1.17.0'
if code in ['af', 'fo', 'fy', 'ie', 'io', 'is', 'mwl', 'vls']:
return '1.19'
return '1.17alpha'
def code2encoding(self,code):
return 'utf-8'
def shared_image_repository(self, code):
return ('common', 'common')
|
gpl-2.0
|
[
3,
1882,
2803,
26,
2774,
13,
24,
221,
1882,
199,
646,
1101,
12,
9614,
12,
4011,
199,
199,
363,
1023,
363,
275,
4505,
1304,
12913,
199,
199,
3,
199,
3,
710,
1910,
1480,
1251,
4603,
9614,
12,
2661,
1376,
655,
1480,
1251,
321,
328,
14,
305,
687,
314,
1910,
1480,
1251,
321,
2391,
6779,
14,
199,
3,
961,
570,
3509,
282,
2615,
663,
402,
334,
19767,
9,
289,
692,
369,
10815,
12,
28529,
367,
6080,
12,
199,
3,
17784,
436,
15216,
83,
14,
199,
3,
199,
3,
3390,
626,
2005,
402,
314,
336,
3258,
4674,
315,
642,
663,
787,
6040,
370,
1172,
4875,
590,
17110,
12,
199,
3,
4124,
503,
8927,
1640,
6797,
9033,
14,
4226,
627,
1397,
10,
7427,
370,
12677,
1640,
6797,
14,
647,
199,
3,
641,
1910,
1480,
1251,
321,
2391,
13,
2407,
336,
3258,
374,
7444,
1265,
1172,
16317,
14962,
402,
199,
3,
6220,
367,
1006,
2637,
6342,
626,
1265,
911,
8683,
370,
675,
465,
1640,
5319,
374,
14,
199,
3,
199,
199,
533,
481,
4632,
8,
6606,
14,
16345,
304,
272,
347,
636,
826,
721,
277,
304,
267,
9614,
14,
16345,
855,
826,
721,
277,
9,
267,
291,
14,
354,
275,
283,
1097,
89,
1251,
321,
2391,
7,
398,
291,
14,
28182,
275,
469,
288,
283,
2756,
356,
283,
78,
1873,
338,
75,
14363,
2391,
14,
1308,
297,
288,
283,
285,
356,
283,
1235,
9897,
321,
2391,
14,
5319,
4674,
14,
957,
297,
288,
283,
1810,
356,
283,
78,
324,
8048,
321,
2391,
14,
5319,
4674,
14,
957,
297,
288,
283,
1700,
356,
283,
1544,
14,
270,
384,
2655,
2391,
14,
1308,
297,
288,
283,
1235,
356,
283,
387,
1181,
300,
924,
8161,
3387,
14,
1308,
297,
288,
283,
6856,
356,
283,
6856,
14,
19131,
514,
2391,
14,
846,
297,
288,
283,
10472,
356,
283,
10472,
14,
1097,
29874,
14,
1308,
297,
288,
283,
1533,
356,
283,
1533,
14,
685,
559,
75,
14363,
328,
3387,
14,
1308,
297,
288,
283,
696,
356,
283,
3042,
552,
67,
530,
14363,
2391,
14,
5319,
4674,
14,
957,
297,
288,
283,
2330,
356,
283,
2330,
83,
14,
1097,
89,
1251,
4603,
14,
1308,
297,
288,
283,
1259,
356,
283,
685,
1480,
75,
14363,
15130,
14,
5319,
4674,
14,
957,
297,
288,
283,
1480,
356,
283,
1480,
14,
1097,
89,
1251,
321,
2391,
14,
1308,
14,
3210,
297,
288,
283,
983,
356,
283,
3770,
271,
1237,
561,
14,
5319,
4674,
14,
957,
297,
288,
283,
271,
356,
283,
271,
14,
1097,
89,
1251,
321,
2391,
14,
1308,
297,
288,
283,
5030,
77,
356,
283,
5030,
77,
14,
685,
559,
75,
14363,
328,
3387,
14,
1308,
297,
288,
283,
352,
356,
283,
25876,
8810,
387,
2655,
4674,
14,
5319,
4674,
14,
957,
297,
288,
283,
287,
356,
283,
1097,
89,
1251,
321,
2391,
14,
5319,
4674,
14,
957,
297,
288,
283,
20805,
356,
283,
685,
559,
75,
14363,
3006,
14,
5319,
4674,
14,
957,
297,
288,
283,
397,
356,
283,
6559,
530,
14363,
2391,
14,
5319,
4674,
14,
957,
297,
288,
283,
386,
356,
283,
2871,
1956,
3210,
14363,
69,
2391,
14,
1308,
297,
288,
283,
667,
356,
283,
667,
14,
1097,
29874,
14,
1308,
297,
288,
283,
329,
356,
283,
72,
11545,
14,
321,
2391,
14,
3569,
297,
288,
283,
545,
356,
283,
1544,
14,
545,
14,
3258,
415,
321,
2391,
14,
1308,
297,
288,
283,
4391,
356,
283,
271,
2464,
1480,
1251,
321,
15130,
14,
5319,
4674,
14,
957,
297,
288,
283,
1399,
356,
283,
324,
1786,
75,
320,
1915,
89,
14,
1308,
297,
288,
283,
5294,
356,
283,
5294,
14,
1097,
29874,
14,
1308,
297,
288,
283,
3528,
356,
283,
271,
1226,
279,
12085,
14,
1308,
297,
288,
283,
7808,
356,
283,
324,
2231,
3258,
14363,
2391,
14,
1308,
297,
288,
283,
71,
1195,
356,
283,
75,
1151,
924,
2391,
14,
1308,
297,
288,
283,
426,
356,
283,
69,
262,
1480,
1251,
321,
2391,
14,
5319,
4674,
14,
957,
297,
288,
283,
6271,
356,
283,
6271,
14,
685,
559,
75,
14363,
328,
3387,
14,
1308,
297,
288,
283,
10616,
356,
283,
324,
559,
75,
14363,
2391,
14,
1308,
297,
288,
283,
3577,
356,
283,
621,
2527,
390,
285,
290,
14,
1308,
297,
288,
283,
344,
356,
283,
475,
320,
320,
76,
321,
2391,
14,
5319,
4674,
14,
957,
297,
288,
283,
1873,
356,
283,
78,
6559,
530,
14363,
2391,
14,
1308,
297,
288,
283,
815,
356,
283,
1097,
89,
1251,
321,
2391,
14,
815,
297,
288,
283,
2308,
356,
283,
2308,
14,
685,
559,
75,
14363,
3006,
14,
1308,
297,
288,
283,
374,
356,
283,
374,
14,
3258,
415,
321,
2391,
14,
1308,
297,
288,
283,
390,
356,
283,
2865,
67,
530,
14363,
2391,
14,
5319,
4674,
14,
957,
297,
288,
283,
3387,
356,
283,
796,
65,
3258,
12646,
2391,
14,
1308,
297,
288,
283,
24989,
356,
283,
977,
72,
461,
75,
14,
5319,
4674,
14,
957,
297,
288,
283,
7351,
356,
283,
290,
559,
75,
14363,
2391,
14,
1308,
297,
288,
283,
14595,
356,
283,
14595,
14,
1097,
89,
1251,
321,
2391,
14,
815,
297,
288,
283,
7697,
356,
283,
1097,
89,
1251,
321,
2391,
14,
16779,
297,
288,
283,
416,
356,
283,
324,
18182,
69,
2391,
14,
1308,
297,
288,
283,
6374,
356,
283,
917,
27798,
1251,
321,
2391,
14,
1308,
297,
288,
283,
317,
356,
283,
829,
1956,
74,
321,
2391,
14,
1308,
297,
288,
283,
320,
356,
283,
320,
14,
1097,
89,
1251,
321,
2391,
14,
815,
297,
288,
283,
4116,
356,
283,
27764,
745,
13458,
328,
3387,
14,
1308,
297,
288,
283,
6371,
356,
283,
6371,
14,
685,
559,
75,
14363,
328,
3387,
14,
1308,
297,
288,
283,
2024,
356,
283,
1097,
89,
1251,
4603,
14,
1308,
297,
288,
283,
6649,
356,
283,
8554,
338,
75,
14363,
2391,
14,
1308,
297,
288,
283,
3880,
356,
283,
3880,
14,
685,
559,
75,
14363,
328,
3387,
14,
1308,
297,
288,
283,
573,
356,
283,
85,
1158,
12085,
14,
846,
297,
288,
283,
706,
356,
283,
66,
364,
19194,
321,
2391,
14,
1308,
297,
288,
283,
14716,
76,
356,
283,
2055,
530,
14363,
2391,
14,
1308,
297,
288,
283,
7530,
356,
283,
265,
1480,
1251,
321,
2391,
14,
846,
297
] |
[
1882,
2803,
26,
2774,
13,
24,
221,
1882,
199,
646,
1101,
12,
9614,
12,
4011,
199,
199,
363,
1023,
363,
275,
4505,
1304,
12913,
199,
199,
3,
199,
3,
710,
1910,
1480,
1251,
4603,
9614,
12,
2661,
1376,
655,
1480,
1251,
321,
328,
14,
305,
687,
314,
1910,
1480,
1251,
321,
2391,
6779,
14,
199,
3,
961,
570,
3509,
282,
2615,
663,
402,
334,
19767,
9,
289,
692,
369,
10815,
12,
28529,
367,
6080,
12,
199,
3,
17784,
436,
15216,
83,
14,
199,
3,
199,
3,
3390,
626,
2005,
402,
314,
336,
3258,
4674,
315,
642,
663,
787,
6040,
370,
1172,
4875,
590,
17110,
12,
199,
3,
4124,
503,
8927,
1640,
6797,
9033,
14,
4226,
627,
1397,
10,
7427,
370,
12677,
1640,
6797,
14,
647,
199,
3,
641,
1910,
1480,
1251,
321,
2391,
13,
2407,
336,
3258,
374,
7444,
1265,
1172,
16317,
14962,
402,
199,
3,
6220,
367,
1006,
2637,
6342,
626,
1265,
911,
8683,
370,
675,
465,
1640,
5319,
374,
14,
199,
3,
199,
199,
533,
481,
4632,
8,
6606,
14,
16345,
304,
272,
347,
636,
826,
721,
277,
304,
267,
9614,
14,
16345,
855,
826,
721,
277,
9,
267,
291,
14,
354,
275,
283,
1097,
89,
1251,
321,
2391,
7,
398,
291,
14,
28182,
275,
469,
288,
283,
2756,
356,
283,
78,
1873,
338,
75,
14363,
2391,
14,
1308,
297,
288,
283,
285,
356,
283,
1235,
9897,
321,
2391,
14,
5319,
4674,
14,
957,
297,
288,
283,
1810,
356,
283,
78,
324,
8048,
321,
2391,
14,
5319,
4674,
14,
957,
297,
288,
283,
1700,
356,
283,
1544,
14,
270,
384,
2655,
2391,
14,
1308,
297,
288,
283,
1235,
356,
283,
387,
1181,
300,
924,
8161,
3387,
14,
1308,
297,
288,
283,
6856,
356,
283,
6856,
14,
19131,
514,
2391,
14,
846,
297,
288,
283,
10472,
356,
283,
10472,
14,
1097,
29874,
14,
1308,
297,
288,
283,
1533,
356,
283,
1533,
14,
685,
559,
75,
14363,
328,
3387,
14,
1308,
297,
288,
283,
696,
356,
283,
3042,
552,
67,
530,
14363,
2391,
14,
5319,
4674,
14,
957,
297,
288,
283,
2330,
356,
283,
2330,
83,
14,
1097,
89,
1251,
4603,
14,
1308,
297,
288,
283,
1259,
356,
283,
685,
1480,
75,
14363,
15130,
14,
5319,
4674,
14,
957,
297,
288,
283,
1480,
356,
283,
1480,
14,
1097,
89,
1251,
321,
2391,
14,
1308,
14,
3210,
297,
288,
283,
983,
356,
283,
3770,
271,
1237,
561,
14,
5319,
4674,
14,
957,
297,
288,
283,
271,
356,
283,
271,
14,
1097,
89,
1251,
321,
2391,
14,
1308,
297,
288,
283,
5030,
77,
356,
283,
5030,
77,
14,
685,
559,
75,
14363,
328,
3387,
14,
1308,
297,
288,
283,
352,
356,
283,
25876,
8810,
387,
2655,
4674,
14,
5319,
4674,
14,
957,
297,
288,
283,
287,
356,
283,
1097,
89,
1251,
321,
2391,
14,
5319,
4674,
14,
957,
297,
288,
283,
20805,
356,
283,
685,
559,
75,
14363,
3006,
14,
5319,
4674,
14,
957,
297,
288,
283,
397,
356,
283,
6559,
530,
14363,
2391,
14,
5319,
4674,
14,
957,
297,
288,
283,
386,
356,
283,
2871,
1956,
3210,
14363,
69,
2391,
14,
1308,
297,
288,
283,
667,
356,
283,
667,
14,
1097,
29874,
14,
1308,
297,
288,
283,
329,
356,
283,
72,
11545,
14,
321,
2391,
14,
3569,
297,
288,
283,
545,
356,
283,
1544,
14,
545,
14,
3258,
415,
321,
2391,
14,
1308,
297,
288,
283,
4391,
356,
283,
271,
2464,
1480,
1251,
321,
15130,
14,
5319,
4674,
14,
957,
297,
288,
283,
1399,
356,
283,
324,
1786,
75,
320,
1915,
89,
14,
1308,
297,
288,
283,
5294,
356,
283,
5294,
14,
1097,
29874,
14,
1308,
297,
288,
283,
3528,
356,
283,
271,
1226,
279,
12085,
14,
1308,
297,
288,
283,
7808,
356,
283,
324,
2231,
3258,
14363,
2391,
14,
1308,
297,
288,
283,
71,
1195,
356,
283,
75,
1151,
924,
2391,
14,
1308,
297,
288,
283,
426,
356,
283,
69,
262,
1480,
1251,
321,
2391,
14,
5319,
4674,
14,
957,
297,
288,
283,
6271,
356,
283,
6271,
14,
685,
559,
75,
14363,
328,
3387,
14,
1308,
297,
288,
283,
10616,
356,
283,
324,
559,
75,
14363,
2391,
14,
1308,
297,
288,
283,
3577,
356,
283,
621,
2527,
390,
285,
290,
14,
1308,
297,
288,
283,
344,
356,
283,
475,
320,
320,
76,
321,
2391,
14,
5319,
4674,
14,
957,
297,
288,
283,
1873,
356,
283,
78,
6559,
530,
14363,
2391,
14,
1308,
297,
288,
283,
815,
356,
283,
1097,
89,
1251,
321,
2391,
14,
815,
297,
288,
283,
2308,
356,
283,
2308,
14,
685,
559,
75,
14363,
3006,
14,
1308,
297,
288,
283,
374,
356,
283,
374,
14,
3258,
415,
321,
2391,
14,
1308,
297,
288,
283,
390,
356,
283,
2865,
67,
530,
14363,
2391,
14,
5319,
4674,
14,
957,
297,
288,
283,
3387,
356,
283,
796,
65,
3258,
12646,
2391,
14,
1308,
297,
288,
283,
24989,
356,
283,
977,
72,
461,
75,
14,
5319,
4674,
14,
957,
297,
288,
283,
7351,
356,
283,
290,
559,
75,
14363,
2391,
14,
1308,
297,
288,
283,
14595,
356,
283,
14595,
14,
1097,
89,
1251,
321,
2391,
14,
815,
297,
288,
283,
7697,
356,
283,
1097,
89,
1251,
321,
2391,
14,
16779,
297,
288,
283,
416,
356,
283,
324,
18182,
69,
2391,
14,
1308,
297,
288,
283,
6374,
356,
283,
917,
27798,
1251,
321,
2391,
14,
1308,
297,
288,
283,
317,
356,
283,
829,
1956,
74,
321,
2391,
14,
1308,
297,
288,
283,
320,
356,
283,
320,
14,
1097,
89,
1251,
321,
2391,
14,
815,
297,
288,
283,
4116,
356,
283,
27764,
745,
13458,
328,
3387,
14,
1308,
297,
288,
283,
6371,
356,
283,
6371,
14,
685,
559,
75,
14363,
328,
3387,
14,
1308,
297,
288,
283,
2024,
356,
283,
1097,
89,
1251,
4603,
14,
1308,
297,
288,
283,
6649,
356,
283,
8554,
338,
75,
14363,
2391,
14,
1308,
297,
288,
283,
3880,
356,
283,
3880,
14,
685,
559,
75,
14363,
328,
3387,
14,
1308,
297,
288,
283,
573,
356,
283,
85,
1158,
12085,
14,
846,
297,
288,
283,
706,
356,
283,
66,
364,
19194,
321,
2391,
14,
1308,
297,
288,
283,
14716,
76,
356,
283,
2055,
530,
14363,
2391,
14,
1308,
297,
288,
283,
7530,
356,
283,
265,
1480,
1251,
321,
2391,
14,
846,
297,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
foss-transportationmodeling/rettina-server
|
.env/local/lib/python2.7/site-packages/distribute-0.6.24-py2.7.egg/setuptools/dist.py
|
64
|
30309
|
__all__ = ['Distribution']
import re
from distutils.core import Distribution as _Distribution
from setuptools.depends import Require
from setuptools.command.install import install
from setuptools.command.sdist import sdist
from setuptools.command.install_lib import install_lib
from distutils.errors import DistutilsOptionError, DistutilsPlatformError
from distutils.errors import DistutilsSetupError
import setuptools, pkg_resources, distutils.core, distutils.dist, distutils.cmd
import os, distutils.log
def _get_unpatched(cls):
"""Protect against re-patching the distutils if reloaded
Also ensures that no other distutils extension monkeypatched the distutils
first.
"""
while cls.__module__.startswith('setuptools'):
cls, = cls.__bases__
if not cls.__module__.startswith('distutils'):
raise AssertionError(
"distutils has already been patched by %r" % cls
)
return cls
_Distribution = _get_unpatched(_Distribution)
sequence = tuple, list
def check_importable(dist, attr, value):
try:
ep = pkg_resources.EntryPoint.parse('x='+value)
assert not ep.extras
except (TypeError,ValueError,AttributeError,AssertionError):
raise DistutilsSetupError(
"%r must be importable 'module:attrs' string (got %r)"
% (attr,value)
)
def assert_string_list(dist, attr, value):
"""Verify that value is a string list or None"""
try:
assert ''.join(value)!=value
except (TypeError,ValueError,AttributeError,AssertionError):
raise DistutilsSetupError(
"%r must be a list of strings (got %r)" % (attr,value)
)
def check_nsp(dist, attr, value):
"""Verify that namespace packages are valid"""
assert_string_list(dist,attr,value)
for nsp in value:
if not dist.has_contents_for(nsp):
raise DistutilsSetupError(
"Distribution contains no modules or packages for " +
"namespace package %r" % nsp
)
if '.' in nsp:
parent = '.'.join(nsp.split('.')[:-1])
if parent not in value:
distutils.log.warn(
"%r is declared as a package namespace, but %r is not:"
" please correct this in setup.py", nsp, parent
)
def check_extras(dist, attr, value):
"""Verify that extras_require mapping is valid"""
try:
for k,v in value.items():
list(pkg_resources.parse_requirements(v))
except (TypeError,ValueError,AttributeError):
raise DistutilsSetupError(
"'extras_require' must be a dictionary whose values are "
"strings or lists of strings containing valid project/version "
"requirement specifiers."
)
def assert_bool(dist, attr, value):
"""Verify that value is True, False, 0, or 1"""
if bool(value) != value:
raise DistutilsSetupError(
"%r must be a boolean value (got %r)" % (attr,value)
)
def check_requirements(dist, attr, value):
"""Verify that install_requires is a valid requirements list"""
try:
list(pkg_resources.parse_requirements(value))
except (TypeError,ValueError):
raise DistutilsSetupError(
"%r must be a string or list of strings "
"containing valid project/version requirement specifiers" % (attr,)
)
def check_entry_points(dist, attr, value):
"""Verify that entry_points map is parseable"""
try:
pkg_resources.EntryPoint.parse_map(value)
except ValueError, e:
raise DistutilsSetupError(e)
def check_test_suite(dist, attr, value):
if not isinstance(value,basestring):
raise DistutilsSetupError("test_suite must be a string")
def check_package_data(dist, attr, value):
"""Verify that value is a dictionary of package names to glob lists"""
if isinstance(value,dict):
for k,v in value.items():
if not isinstance(k,str): break
try: iter(v)
except TypeError:
break
else:
return
raise DistutilsSetupError(
attr+" must be a dictionary mapping package names to lists of "
"wildcard patterns"
)
class Distribution(_Distribution):
"""Distribution with support for features, tests, and package data
This is an enhanced version of 'distutils.dist.Distribution' that
effectively adds the following new optional keyword arguments to 'setup()':
'install_requires' -- a string or sequence of strings specifying project
versions that the distribution requires when installed, in the format
used by 'pkg_resources.require()'. They will be installed
automatically when the package is installed. If you wish to use
packages that are not available in PyPI, or want to give your users an
alternate download location, you can add a 'find_links' option to the
'[easy_install]' section of your project's 'setup.cfg' file, and then
setuptools will scan the listed web pages for links that satisfy the
requirements.
'extras_require' -- a dictionary mapping names of optional "extras" to the
additional requirement(s) that using those extras incurs. For example,
this::
extras_require = dict(reST = ["docutils>=0.3", "reSTedit"])
indicates that the distribution can optionally provide an extra
capability called "reST", but it can only be used if docutils and
reSTedit are installed. If the user installs your package using
EasyInstall and requests one of your extras, the corresponding
additional requirements will be installed if needed.
'features' -- a dictionary mapping option names to 'setuptools.Feature'
objects. Features are a portion of the distribution that can be
included or excluded based on user options, inter-feature dependencies,
and availability on the current system. Excluded features are omitted
from all setup commands, including source and binary distributions, so
you can create multiple distributions from the same source tree.
Feature names should be valid Python identifiers, except that they may
contain the '-' (minus) sign. Features can be included or excluded
via the command line options '--with-X' and '--without-X', where 'X' is
the name of the feature. Whether a feature is included by default, and
whether you are allowed to control this from the command line, is
determined by the Feature object. See the 'Feature' class for more
information.
'test_suite' -- the name of a test suite to run for the 'test' command.
If the user runs 'python setup.py test', the package will be installed,
and the named test suite will be run. The format is the same as
would be used on a 'unittest.py' command line. That is, it is the
dotted name of an object to import and call to generate a test suite.
'package_data' -- a dictionary mapping package names to lists of filenames
or globs to use to find data files contained in the named packages.
If the dictionary has filenames or globs listed under '""' (the empty
string), those names will be searched for in every package, in addition
to any names for the specific package. Data files found using these
names/globs will be installed along with the package, in the same
location as the package. Note that globs are allowed to reference
the contents of non-package subdirectories, as long as you use '/' as
a path separator. (Globs are automatically converted to
platform-specific paths at runtime.)
In addition to these new keywords, this class also has several new methods
for manipulating the distribution's contents. For example, the 'include()'
and 'exclude()' methods can be thought of as in-place add and subtract
commands that add or remove packages, modules, extensions, and so on from
the distribution. They are used by the feature subsystem to configure the
distribution for the included and excluded features.
"""
_patched_dist = None
def patch_missing_pkg_info(self, attrs):
# Fake up a replacement for the data that would normally come from
# PKG-INFO, but which might not yet be built if this is a fresh
# checkout.
#
if not attrs or 'name' not in attrs or 'version' not in attrs:
return
key = pkg_resources.safe_name(str(attrs['name'])).lower()
dist = pkg_resources.working_set.by_key.get(key)
if dist is not None and not dist.has_metadata('PKG-INFO'):
dist._version = pkg_resources.safe_version(str(attrs['version']))
self._patched_dist = dist
def __init__ (self, attrs=None):
have_package_data = hasattr(self, "package_data")
if not have_package_data:
self.package_data = {}
self.require_features = []
self.features = {}
self.dist_files = []
self.src_root = attrs and attrs.pop("src_root", None)
self.patch_missing_pkg_info(attrs)
# Make sure we have any eggs needed to interpret 'attrs'
if attrs is not None:
self.dependency_links = attrs.pop('dependency_links', [])
assert_string_list(self,'dependency_links',self.dependency_links)
if attrs and 'setup_requires' in attrs:
self.fetch_build_eggs(attrs.pop('setup_requires'))
for ep in pkg_resources.iter_entry_points('distutils.setup_keywords'):
if not hasattr(self,ep.name):
setattr(self,ep.name,None)
_Distribution.__init__(self,attrs)
if isinstance(self.metadata.version, (int,long,float)):
# Some people apparently take "version number" too literally :)
self.metadata.version = str(self.metadata.version)
def parse_command_line(self):
"""Process features after parsing command line options"""
result = _Distribution.parse_command_line(self)
if self.features:
self._finalize_features()
return result
def _feature_attrname(self,name):
"""Convert feature name to corresponding option attribute name"""
return 'with_'+name.replace('-','_')
def fetch_build_eggs(self, requires):
"""Resolve pre-setup requirements"""
from pkg_resources import working_set, parse_requirements
for dist in working_set.resolve(
parse_requirements(requires), installer=self.fetch_build_egg
):
working_set.add(dist)
def finalize_options(self):
_Distribution.finalize_options(self)
if self.features:
self._set_global_opts_from_features()
for ep in pkg_resources.iter_entry_points('distutils.setup_keywords'):
value = getattr(self,ep.name,None)
if value is not None:
ep.require(installer=self.fetch_build_egg)
ep.load()(self, ep.name, value)
if getattr(self, 'convert_2to3_doctests', None):
# XXX may convert to set here when we can rely on set being builtin
self.convert_2to3_doctests = [os.path.abspath(p) for p in self.convert_2to3_doctests]
else:
self.convert_2to3_doctests = []
def fetch_build_egg(self, req):
"""Fetch an egg needed for building"""
try:
cmd = self._egg_fetcher
cmd.package_index.to_scan = []
except AttributeError:
from setuptools.command.easy_install import easy_install
dist = self.__class__({'script_args':['easy_install']})
dist.parse_config_files()
opts = dist.get_option_dict('easy_install')
keep = (
'find_links', 'site_dirs', 'index_url', 'optimize',
'site_dirs', 'allow_hosts'
)
for key in opts.keys():
if key not in keep:
del opts[key] # don't use any other settings
if self.dependency_links:
links = self.dependency_links[:]
if 'find_links' in opts:
links = opts['find_links'][1].split() + links
opts['find_links'] = ('setup', links)
cmd = easy_install(
dist, args=["x"], install_dir=os.curdir, exclude_scripts=True,
always_copy=False, build_directory=None, editable=False,
upgrade=False, multi_version=True, no_report = True
)
cmd.ensure_finalized()
self._egg_fetcher = cmd
return cmd.easy_install(req)
def _set_global_opts_from_features(self):
"""Add --with-X/--without-X options based on optional features"""
go = []
no = self.negative_opt.copy()
for name,feature in self.features.items():
self._set_feature(name,None)
feature.validate(self)
if feature.optional:
descr = feature.description
incdef = ' (default)'
excdef=''
if not feature.include_by_default():
excdef, incdef = incdef, excdef
go.append(('with-'+name, None, 'include '+descr+incdef))
go.append(('without-'+name, None, 'exclude '+descr+excdef))
no['without-'+name] = 'with-'+name
self.global_options = self.feature_options = go + self.global_options
self.negative_opt = self.feature_negopt = no
def _finalize_features(self):
"""Add/remove features and resolve dependencies between them"""
# First, flag all the enabled items (and thus their dependencies)
for name,feature in self.features.items():
enabled = self.feature_is_included(name)
if enabled or (enabled is None and feature.include_by_default()):
feature.include_in(self)
self._set_feature(name,1)
# Then disable the rest, so that off-by-default features don't
# get flagged as errors when they're required by an enabled feature
for name,feature in self.features.items():
if not self.feature_is_included(name):
feature.exclude_from(self)
self._set_feature(name,0)
def get_command_class(self, command):
"""Pluggable version of get_command_class()"""
if command in self.cmdclass:
return self.cmdclass[command]
for ep in pkg_resources.iter_entry_points('distutils.commands',command):
ep.require(installer=self.fetch_build_egg)
self.cmdclass[command] = cmdclass = ep.load()
return cmdclass
else:
return _Distribution.get_command_class(self, command)
def print_commands(self):
for ep in pkg_resources.iter_entry_points('distutils.commands'):
if ep.name not in self.cmdclass:
cmdclass = ep.load(False) # don't require extras, we're not running
self.cmdclass[ep.name] = cmdclass
return _Distribution.print_commands(self)
def _set_feature(self,name,status):
"""Set feature's inclusion status"""
setattr(self,self._feature_attrname(name),status)
def feature_is_included(self,name):
"""Return 1 if feature is included, 0 if excluded, 'None' if unknown"""
return getattr(self,self._feature_attrname(name))
def include_feature(self,name):
"""Request inclusion of feature named 'name'"""
if self.feature_is_included(name)==0:
descr = self.features[name].description
raise DistutilsOptionError(
descr + " is required, but was excluded or is not available"
)
self.features[name].include_in(self)
self._set_feature(name,1)
def include(self,**attrs):
"""Add items to distribution that are named in keyword arguments
For example, 'dist.exclude(py_modules=["x"])' would add 'x' to
the distribution's 'py_modules' attribute, if it was not already
there.
Currently, this method only supports inclusion for attributes that are
lists or tuples. If you need to add support for adding to other
attributes in this or a subclass, you can add an '_include_X' method,
where 'X' is the name of the attribute. The method will be called with
the value passed to 'include()'. So, 'dist.include(foo={"bar":"baz"})'
will try to call 'dist._include_foo({"bar":"baz"})', which can then
handle whatever special inclusion logic is needed.
"""
for k,v in attrs.items():
include = getattr(self, '_include_'+k, None)
if include:
include(v)
else:
self._include_misc(k,v)
def exclude_package(self,package):
"""Remove packages, modules, and extensions in named package"""
pfx = package+'.'
if self.packages:
self.packages = [
p for p in self.packages
if p != package and not p.startswith(pfx)
]
if self.py_modules:
self.py_modules = [
p for p in self.py_modules
if p != package and not p.startswith(pfx)
]
if self.ext_modules:
self.ext_modules = [
p for p in self.ext_modules
if p.name != package and not p.name.startswith(pfx)
]
def has_contents_for(self,package):
"""Return true if 'exclude_package(package)' would do something"""
pfx = package+'.'
for p in self.iter_distribution_names():
if p==package or p.startswith(pfx):
return True
def _exclude_misc(self,name,value):
"""Handle 'exclude()' for list/tuple attrs without a special handler"""
if not isinstance(value,sequence):
raise DistutilsSetupError(
"%s: setting must be a list or tuple (%r)" % (name, value)
)
try:
old = getattr(self,name)
except AttributeError:
raise DistutilsSetupError(
"%s: No such distribution setting" % name
)
if old is not None and not isinstance(old,sequence):
raise DistutilsSetupError(
name+": this setting cannot be changed via include/exclude"
)
elif old:
setattr(self,name,[item for item in old if item not in value])
def _include_misc(self,name,value):
"""Handle 'include()' for list/tuple attrs without a special handler"""
if not isinstance(value,sequence):
raise DistutilsSetupError(
"%s: setting must be a list (%r)" % (name, value)
)
try:
old = getattr(self,name)
except AttributeError:
raise DistutilsSetupError(
"%s: No such distribution setting" % name
)
if old is None:
setattr(self,name,value)
elif not isinstance(old,sequence):
raise DistutilsSetupError(
name+": this setting cannot be changed via include/exclude"
)
else:
setattr(self,name,old+[item for item in value if item not in old])
def exclude(self,**attrs):
"""Remove items from distribution that are named in keyword arguments
For example, 'dist.exclude(py_modules=["x"])' would remove 'x' from
the distribution's 'py_modules' attribute. Excluding packages uses
the 'exclude_package()' method, so all of the package's contained
packages, modules, and extensions are also excluded.
Currently, this method only supports exclusion from attributes that are
lists or tuples. If you need to add support for excluding from other
attributes in this or a subclass, you can add an '_exclude_X' method,
where 'X' is the name of the attribute. The method will be called with
the value passed to 'exclude()'. So, 'dist.exclude(foo={"bar":"baz"})'
will try to call 'dist._exclude_foo({"bar":"baz"})', which can then
handle whatever special exclusion logic is needed.
"""
for k,v in attrs.items():
exclude = getattr(self, '_exclude_'+k, None)
if exclude:
exclude(v)
else:
self._exclude_misc(k,v)
def _exclude_packages(self,packages):
if not isinstance(packages,sequence):
raise DistutilsSetupError(
"packages: setting must be a list or tuple (%r)" % (packages,)
)
map(self.exclude_package, packages)
def _parse_command_opts(self, parser, args):
# Remove --with-X/--without-X options when processing command args
self.global_options = self.__class__.global_options
self.negative_opt = self.__class__.negative_opt
# First, expand any aliases
command = args[0]
aliases = self.get_option_dict('aliases')
while command in aliases:
src,alias = aliases[command]
del aliases[command] # ensure each alias can expand only once!
import shlex
args[:1] = shlex.split(alias,True)
command = args[0]
nargs = _Distribution._parse_command_opts(self, parser, args)
# Handle commands that want to consume all remaining arguments
cmd_class = self.get_command_class(command)
if getattr(cmd_class,'command_consumes_arguments',None):
self.get_option_dict(command)['args'] = ("command line", nargs)
if nargs is not None:
return []
return nargs
def get_cmdline_options(self):
"""Return a '{cmd: {opt:val}}' map of all command-line options
Option names are all long, but do not include the leading '--', and
contain dashes rather than underscores. If the option doesn't take
an argument (e.g. '--quiet'), the 'val' is 'None'.
Note that options provided by config files are intentionally excluded.
"""
d = {}
for cmd,opts in self.command_options.items():
for opt,(src,val) in opts.items():
if src != "command line":
continue
opt = opt.replace('_','-')
if val==0:
cmdobj = self.get_command_obj(cmd)
neg_opt = self.negative_opt.copy()
neg_opt.update(getattr(cmdobj,'negative_opt',{}))
for neg,pos in neg_opt.items():
if pos==opt:
opt=neg
val=None
break
else:
raise AssertionError("Shouldn't be able to get here")
elif val==1:
val = None
d.setdefault(cmd,{})[opt] = val
return d
def iter_distribution_names(self):
"""Yield all packages, modules, and extension names in distribution"""
for pkg in self.packages or ():
yield pkg
for module in self.py_modules or ():
yield module
for ext in self.ext_modules or ():
if isinstance(ext,tuple):
name, buildinfo = ext
else:
name = ext.name
if name.endswith('module'):
name = name[:-6]
yield name
# Install it throughout the distutils
for module in distutils.dist, distutils.core, distutils.cmd:
module.Distribution = Distribution
class Feature:
"""A subset of the distribution that can be excluded if unneeded/wanted
Features are created using these keyword arguments:
'description' -- a short, human readable description of the feature, to
be used in error messages, and option help messages.
'standard' -- if true, the feature is included by default if it is
available on the current system. Otherwise, the feature is only
included if requested via a command line '--with-X' option, or if
another included feature requires it. The default setting is 'False'.
'available' -- if true, the feature is available for installation on the
current system. The default setting is 'True'.
'optional' -- if true, the feature's inclusion can be controlled from the
command line, using the '--with-X' or '--without-X' options. If
false, the feature's inclusion status is determined automatically,
based on 'availabile', 'standard', and whether any other feature
requires it. The default setting is 'True'.
'require_features' -- a string or sequence of strings naming features
that should also be included if this feature is included. Defaults to
empty list. May also contain 'Require' objects that should be
added/removed from the distribution.
'remove' -- a string or list of strings naming packages to be removed
from the distribution if this feature is *not* included. If the
feature *is* included, this argument is ignored. This argument exists
to support removing features that "crosscut" a distribution, such as
defining a 'tests' feature that removes all the 'tests' subpackages
provided by other features. The default for this argument is an empty
list. (Note: the named package(s) or modules must exist in the base
distribution when the 'setup()' function is initially called.)
other keywords -- any other keyword arguments are saved, and passed to
the distribution's 'include()' and 'exclude()' methods when the
feature is included or excluded, respectively. So, for example, you
could pass 'packages=["a","b"]' to cause packages 'a' and 'b' to be
added or removed from the distribution as appropriate.
A feature must include at least one 'requires', 'remove', or other
keyword argument. Otherwise, it can't affect the distribution in any way.
Note also that you can subclass 'Feature' to create your own specialized
feature types that modify the distribution in other ways when included or
excluded. See the docstrings for the various methods here for more detail.
Aside from the methods, the only feature attributes that distributions look
at are 'description' and 'optional'.
"""
def __init__(self, description, standard=False, available=True,
optional=True, require_features=(), remove=(), **extras
):
self.description = description
self.standard = standard
self.available = available
self.optional = optional
if isinstance(require_features,(str,Require)):
require_features = require_features,
self.require_features = [
r for r in require_features if isinstance(r,str)
]
er = [r for r in require_features if not isinstance(r,str)]
if er: extras['require_features'] = er
if isinstance(remove,str):
remove = remove,
self.remove = remove
self.extras = extras
if not remove and not require_features and not extras:
raise DistutilsSetupError(
"Feature %s: must define 'require_features', 'remove', or at least one"
" of 'packages', 'py_modules', etc."
)
def include_by_default(self):
"""Should this feature be included by default?"""
return self.available and self.standard
def include_in(self,dist):
"""Ensure feature and its requirements are included in distribution
You may override this in a subclass to perform additional operations on
the distribution. Note that this method may be called more than once
per feature, and so should be idempotent.
"""
if not self.available:
raise DistutilsPlatformError(
self.description+" is required,"
"but is not available on this platform"
)
dist.include(**self.extras)
for f in self.require_features:
dist.include_feature(f)
def exclude_from(self,dist):
"""Ensure feature is excluded from distribution
You may override this in a subclass to perform additional operations on
the distribution. This method will be called at most once per
feature, and only after all included features have been asked to
include themselves.
"""
dist.exclude(**self.extras)
if self.remove:
for item in self.remove:
dist.exclude_package(item)
def validate(self,dist):
"""Verify that feature makes sense in context of distribution
This method is called by the distribution just before it parses its
command line. It checks to ensure that the 'remove' attribute, if any,
contains only valid package/module names that are present in the base
distribution when 'setup()' is called. You may override it in a
subclass to perform any other required validation of the feature
against a target distribution.
"""
for item in self.remove:
if not dist.has_contents_for(item):
raise DistutilsSetupError(
"%s wants to be able to remove %s, but the distribution"
" doesn't contain any packages or modules under %s"
% (self.description, item, item)
)
def check_packages(dist, attr, value):
for pkgname in value:
if not re.match(r'\w+(\.\w+)*', pkgname):
distutils.log.warn(
"WARNING: %r not a valid package name; please use only"
".-separated package names in setup.py", pkgname
)
|
apache-2.0
|
[
363,
452,
363,
275,
788,
8580,
418,
199,
199,
646,
295,
199,
504,
7065,
14,
1018,
492,
11839,
465,
485,
8580,
199,
504,
9116,
14,
8912,
492,
18513,
199,
504,
9116,
14,
1531,
14,
3174,
492,
3907,
199,
504,
9116,
14,
1531,
14,
25147,
492,
26644,
199,
504,
9116,
14,
1531,
14,
3174,
63,
773,
492,
3907,
63,
773,
199,
504,
7065,
14,
2550,
492,
31484,
12,
12577,
10397,
547,
199,
504,
7065,
14,
2550,
492,
12577,
30221,
199,
646,
9116,
12,
5496,
63,
4435,
12,
7065,
14,
1018,
12,
7065,
14,
2686,
12,
7065,
14,
1760,
199,
646,
747,
12,
7065,
14,
793,
199,
199,
318,
485,
362,
63,
324,
22631,
8,
1886,
304,
272,
408,
919,
5302,
6169,
295,
13,
2068,
316,
314,
7065,
340,
31848,
339,
6121,
15620,
626,
949,
1163,
7065,
3329,
17309,
379,
314,
7065,
272,
1642,
14,
272,
408,
272,
1830,
843,
855,
578,
4343,
2460,
360,
13623,
735,
267,
843,
12,
275,
843,
855,
12087,
363,
272,
340,
440,
843,
855,
578,
4343,
2460,
360,
13350,
735,
267,
746,
9070,
8,
288,
298,
13350,
965,
2575,
2757,
19483,
701,
450,
82,
2,
450,
843,
267,
776,
272,
372,
843,
199,
199,
63,
8580,
275,
485,
362,
63,
324,
22631,
1547,
8580,
9,
199,
199,
4041,
275,
2008,
12,
769,
199,
199,
318,
1104,
63,
646,
461,
8,
2686,
12,
1921,
12,
574,
304,
272,
862,
26,
267,
5442,
275,
5496,
63,
4435,
14,
30485,
14,
1122,
360,
88,
22078,
585,
9,
267,
702,
440,
5442,
14,
9975,
272,
871,
334,
4333,
12,
3393,
12,
10227,
12,
14844,
304,
267,
746,
12577,
30221,
8,
288,
2071,
82,
1471,
506,
492,
461,
283,
578,
26,
3288,
7,
1059,
334,
7808,
450,
82,
2924,
288,
450,
334,
962,
12,
585,
9,
267,
776,
421,
199,
318,
702,
63,
875,
63,
513,
8,
2686,
12,
1921,
12,
574,
304,
272,
408,
7496,
626,
574,
365,
282,
1059,
769,
503,
488,
624,
272,
862,
26,
267,
702,
6522,
904,
8,
585,
9,
1111,
585,
272,
871,
334,
4333,
12,
3393,
12,
10227,
12,
14844,
304,
267,
746,
12577,
30221,
8,
288,
2071,
82,
1471,
506,
282,
769,
402,
3326,
334,
7808,
450,
82,
2924,
450,
334,
962,
12,
585,
9,
267,
776,
199,
199,
318,
1104,
63,
561,
80,
8,
2686,
12,
1921,
12,
574,
304,
272,
408,
7496,
626,
3231,
6117,
787,
1686,
624,
272,
702,
63,
875,
63,
513,
8,
2686,
12,
962,
12,
585,
9,
272,
367,
302,
681,
315,
574,
26,
267,
340,
440,
2917,
14,
1989,
63,
4407,
63,
509,
8,
561,
80,
304,
288,
746,
12577,
30221,
8,
355,
298,
8580,
3509,
949,
4621,
503,
6117,
367,
298,
435,
355,
298,
3251,
2559,
450,
82,
2,
450,
302,
681,
288,
776,
267,
340,
7815,
315,
302,
681,
26,
288,
1676,
275,
15671,
904,
8,
561,
80,
14,
1294,
7563,
4439,
17,
566,
288,
340,
1676,
440,
315,
574,
26,
355,
7065,
14,
793,
14,
4050,
8,
490,
2071,
82,
365,
14290,
465,
282,
2559,
3231,
12,
1325,
450,
82,
365,
440,
5424,
490,
298,
8749,
3211,
642,
315,
3272,
14,
647,
401,
302,
681,
12,
1676,
355,
776,
199,
199,
318,
1104,
63,
9975,
8,
2686,
12,
1921,
12,
574,
304,
272,
408,
7496,
626,
13751,
63,
4365,
4412,
365,
1686,
624,
272,
862,
26,
267,
367,
1022,
12,
86,
315,
574,
14,
1744,
837,
288,
769,
8,
4600,
63,
4435,
14,
1122,
63,
7538,
8,
86,
430,
272,
871,
334,
4333,
12,
3393,
12,
10227,
304,
267,
746,
12577,
30221,
8,
288,
3546,
9975,
63,
4365,
7,
1471,
506,
282,
2600,
7447,
1338,
787,
298,
288,
298,
5465,
503,
5548,
402,
3326,
3035,
1686,
2199,
15,
1023,
298,
288,
298,
12434,
29558,
2122,
267,
776,
6905,
199,
318,
702,
63,
2245,
8,
2686,
12,
1921,
12,
574,
304,
272,
408,
7496,
626,
574,
365,
715,
12,
756,
12,
378,
12,
503,
413,
624,
272,
340,
2155,
8,
585,
9,
1137,
574,
26,
267,
746,
12577,
30221,
8,
288,
2071,
82,
1471,
506,
282,
5046,
574,
334,
7808,
450,
82,
2924,
450,
334,
962,
12,
585,
9,
267,
776,
199,
318,
1104,
63,
7538,
8,
2686,
12,
1921,
12,
574,
304,
272,
408,
7496,
626,
3907,
63,
6537,
365,
282,
1686,
9760,
769,
624,
272,
862,
26,
267,
769,
8,
4600,
63,
4435,
14,
1122,
63,
7538,
8,
585,
430,
272,
871,
334,
4333,
12,
3393,
304,
267,
746,
12577,
30221,
8,
288,
2071,
82,
1471,
506,
282,
1059,
503,
769,
402,
3326,
298,
288,
298,
16133,
1686,
2199,
15,
1023,
10685,
29558,
2,
450,
334,
962,
4258,
267,
776,
199,
318,
1104,
63,
2373,
63,
3438,
8,
2686,
12,
1921,
12,
574,
304,
272,
408,
7496,
626,
2397,
63,
3438,
2341,
365,
2198,
461,
624,
272,
862,
26,
267,
5496,
63,
4435,
14,
30485,
14,
1122,
63,
1130,
8,
585,
9,
272,
871,
1722,
12,
325,
26,
267,
746,
12577,
30221,
8,
69,
9,
199,
199,
318,
1104,
63,
396,
63,
5768,
8,
2686,
12,
1921,
12,
574,
304,
272,
340,
440,
1228,
8,
585,
12,
17628,
304,
267,
746,
12577,
30221,
480,
396,
63,
5768,
1471,
506,
282,
1059,
531,
199,
199,
318,
1104,
63,
2491,
63,
576,
8,
2686,
12,
1921,
12,
574,
304,
272,
408,
7496,
626,
574,
365,
282,
2600,
402,
2559,
1561,
370,
5739,
5548,
624,
272,
340,
1228,
8,
585,
12,
807,
304,
267,
367,
1022,
12,
86,
315,
574,
14,
1744,
837,
288,
340,
440,
1228,
8,
75,
12,
495,
304,
2059,
288,
862,
26,
2740,
8,
86,
9,
288,
871,
3146,
26,
355,
2059,
267,
587,
26,
288,
372,
272,
746,
12577,
30221,
8,
267,
1921,
5207,
1471,
506,
282,
2600,
4412,
2559,
1561,
370,
5548,
402,
298,
267,
298,
16692,
7970,
2,
272,
776,
199,
199,
533,
11839,
1547,
8580,
304,
272,
408,
8580,
543,
2291,
367,
4534,
12,
2295,
12,
436,
2559,
666,
339,
961,
365,
376,
655,
24384,
1015,
402,
283,
13350,
14,
2686,
14,
8580,
7,
626,
272,
27881,
9584,
314,
2569,
892,
2716,
4252,
2368,
370,
283,
2758,
342,
356,
10813,
283,
3174,
63,
6537,
7,
1553,
282,
1059,
503,
3414,
402
] |
[
452,
363,
275,
788,
8580,
418,
199,
199,
646,
295,
199,
504,
7065,
14,
1018,
492,
11839,
465,
485,
8580,
199,
504,
9116,
14,
8912,
492,
18513,
199,
504,
9116,
14,
1531,
14,
3174,
492,
3907,
199,
504,
9116,
14,
1531,
14,
25147,
492,
26644,
199,
504,
9116,
14,
1531,
14,
3174,
63,
773,
492,
3907,
63,
773,
199,
504,
7065,
14,
2550,
492,
31484,
12,
12577,
10397,
547,
199,
504,
7065,
14,
2550,
492,
12577,
30221,
199,
646,
9116,
12,
5496,
63,
4435,
12,
7065,
14,
1018,
12,
7065,
14,
2686,
12,
7065,
14,
1760,
199,
646,
747,
12,
7065,
14,
793,
199,
199,
318,
485,
362,
63,
324,
22631,
8,
1886,
304,
272,
408,
919,
5302,
6169,
295,
13,
2068,
316,
314,
7065,
340,
31848,
339,
6121,
15620,
626,
949,
1163,
7065,
3329,
17309,
379,
314,
7065,
272,
1642,
14,
272,
408,
272,
1830,
843,
855,
578,
4343,
2460,
360,
13623,
735,
267,
843,
12,
275,
843,
855,
12087,
363,
272,
340,
440,
843,
855,
578,
4343,
2460,
360,
13350,
735,
267,
746,
9070,
8,
288,
298,
13350,
965,
2575,
2757,
19483,
701,
450,
82,
2,
450,
843,
267,
776,
272,
372,
843,
199,
199,
63,
8580,
275,
485,
362,
63,
324,
22631,
1547,
8580,
9,
199,
199,
4041,
275,
2008,
12,
769,
199,
199,
318,
1104,
63,
646,
461,
8,
2686,
12,
1921,
12,
574,
304,
272,
862,
26,
267,
5442,
275,
5496,
63,
4435,
14,
30485,
14,
1122,
360,
88,
22078,
585,
9,
267,
702,
440,
5442,
14,
9975,
272,
871,
334,
4333,
12,
3393,
12,
10227,
12,
14844,
304,
267,
746,
12577,
30221,
8,
288,
2071,
82,
1471,
506,
492,
461,
283,
578,
26,
3288,
7,
1059,
334,
7808,
450,
82,
2924,
288,
450,
334,
962,
12,
585,
9,
267,
776,
421,
199,
318,
702,
63,
875,
63,
513,
8,
2686,
12,
1921,
12,
574,
304,
272,
408,
7496,
626,
574,
365,
282,
1059,
769,
503,
488,
624,
272,
862,
26,
267,
702,
6522,
904,
8,
585,
9,
1111,
585,
272,
871,
334,
4333,
12,
3393,
12,
10227,
12,
14844,
304,
267,
746,
12577,
30221,
8,
288,
2071,
82,
1471,
506,
282,
769,
402,
3326,
334,
7808,
450,
82,
2924,
450,
334,
962,
12,
585,
9,
267,
776,
199,
199,
318,
1104,
63,
561,
80,
8,
2686,
12,
1921,
12,
574,
304,
272,
408,
7496,
626,
3231,
6117,
787,
1686,
624,
272,
702,
63,
875,
63,
513,
8,
2686,
12,
962,
12,
585,
9,
272,
367,
302,
681,
315,
574,
26,
267,
340,
440,
2917,
14,
1989,
63,
4407,
63,
509,
8,
561,
80,
304,
288,
746,
12577,
30221,
8,
355,
298,
8580,
3509,
949,
4621,
503,
6117,
367,
298,
435,
355,
298,
3251,
2559,
450,
82,
2,
450,
302,
681,
288,
776,
267,
340,
7815,
315,
302,
681,
26,
288,
1676,
275,
15671,
904,
8,
561,
80,
14,
1294,
7563,
4439,
17,
566,
288,
340,
1676,
440,
315,
574,
26,
355,
7065,
14,
793,
14,
4050,
8,
490,
2071,
82,
365,
14290,
465,
282,
2559,
3231,
12,
1325,
450,
82,
365,
440,
5424,
490,
298,
8749,
3211,
642,
315,
3272,
14,
647,
401,
302,
681,
12,
1676,
355,
776,
199,
199,
318,
1104,
63,
9975,
8,
2686,
12,
1921,
12,
574,
304,
272,
408,
7496,
626,
13751,
63,
4365,
4412,
365,
1686,
624,
272,
862,
26,
267,
367,
1022,
12,
86,
315,
574,
14,
1744,
837,
288,
769,
8,
4600,
63,
4435,
14,
1122,
63,
7538,
8,
86,
430,
272,
871,
334,
4333,
12,
3393,
12,
10227,
304,
267,
746,
12577,
30221,
8,
288,
3546,
9975,
63,
4365,
7,
1471,
506,
282,
2600,
7447,
1338,
787,
298,
288,
298,
5465,
503,
5548,
402,
3326,
3035,
1686,
2199,
15,
1023,
298,
288,
298,
12434,
29558,
2122,
267,
776,
6905,
199,
318,
702,
63,
2245,
8,
2686,
12,
1921,
12,
574,
304,
272,
408,
7496,
626,
574,
365,
715,
12,
756,
12,
378,
12,
503,
413,
624,
272,
340,
2155,
8,
585,
9,
1137,
574,
26,
267,
746,
12577,
30221,
8,
288,
2071,
82,
1471,
506,
282,
5046,
574,
334,
7808,
450,
82,
2924,
450,
334,
962,
12,
585,
9,
267,
776,
199,
318,
1104,
63,
7538,
8,
2686,
12,
1921,
12,
574,
304,
272,
408,
7496,
626,
3907,
63,
6537,
365,
282,
1686,
9760,
769,
624,
272,
862,
26,
267,
769,
8,
4600,
63,
4435,
14,
1122,
63,
7538,
8,
585,
430,
272,
871,
334,
4333,
12,
3393,
304,
267,
746,
12577,
30221,
8,
288,
2071,
82,
1471,
506,
282,
1059,
503,
769,
402,
3326,
298,
288,
298,
16133,
1686,
2199,
15,
1023,
10685,
29558,
2,
450,
334,
962,
4258,
267,
776,
199,
318,
1104,
63,
2373,
63,
3438,
8,
2686,
12,
1921,
12,
574,
304,
272,
408,
7496,
626,
2397,
63,
3438,
2341,
365,
2198,
461,
624,
272,
862,
26,
267,
5496,
63,
4435,
14,
30485,
14,
1122,
63,
1130,
8,
585,
9,
272,
871,
1722,
12,
325,
26,
267,
746,
12577,
30221,
8,
69,
9,
199,
199,
318,
1104,
63,
396,
63,
5768,
8,
2686,
12,
1921,
12,
574,
304,
272,
340,
440,
1228,
8,
585,
12,
17628,
304,
267,
746,
12577,
30221,
480,
396,
63,
5768,
1471,
506,
282,
1059,
531,
199,
199,
318,
1104,
63,
2491,
63,
576,
8,
2686,
12,
1921,
12,
574,
304,
272,
408,
7496,
626,
574,
365,
282,
2600,
402,
2559,
1561,
370,
5739,
5548,
624,
272,
340,
1228,
8,
585,
12,
807,
304,
267,
367,
1022,
12,
86,
315,
574,
14,
1744,
837,
288,
340,
440,
1228,
8,
75,
12,
495,
304,
2059,
288,
862,
26,
2740,
8,
86,
9,
288,
871,
3146,
26,
355,
2059,
267,
587,
26,
288,
372,
272,
746,
12577,
30221,
8,
267,
1921,
5207,
1471,
506,
282,
2600,
4412,
2559,
1561,
370,
5548,
402,
298,
267,
298,
16692,
7970,
2,
272,
776,
199,
199,
533,
11839,
1547,
8580,
304,
272,
408,
8580,
543,
2291,
367,
4534,
12,
2295,
12,
436,
2559,
666,
339,
961,
365,
376,
655,
24384,
1015,
402,
283,
13350,
14,
2686,
14,
8580,
7,
626,
272,
27881,
9584,
314,
2569,
892,
2716,
4252,
2368,
370,
283,
2758,
342,
356,
10813,
283,
3174,
63,
6537,
7,
1553,
282,
1059,
503,
3414,
402,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
brosner/django-avatar
|
avatar/views.py
|
5
|
7562
|
from django.http import HttpResponseRedirect
from django.shortcuts import render_to_response
from django.template import RequestContext
from django.utils.translation import ugettext as _
from django.conf import settings
from django.contrib.auth.decorators import login_required
from avatar import AVATAR_MAX_AVATARS_PER_USER
from avatar.models import Avatar
from avatar.util import get_primary_avatar, get_default_avatar_url
from avatar.forms import PrimaryAvatarForm, DeleteAvatarForm, UploadAvatarForm
notification = False
if 'notification' in settings.INSTALLED_APPS:
from notification import models as notification
friends = False
if 'friends' in settings.INSTALLED_APPS:
friends = True
from friends.models import Friendship
def _get_next(request):
"""
The part that's the least straightforward about views in this module is how they
determine their redirects after they have finished computation.
In short, they will try and determine the next place to go in the following order:
1. If there is a variable named ``next`` in the *POST* parameters, the view will
redirect to that variable's value.
2. If there is a variable named ``next`` in the *GET* parameters, the view will
redirect to that variable's value.
3. If Django can determine the previous page from the HTTP headers, the view will
redirect to that previous page.
"""
next = request.POST.get('next', request.GET.get('next',
request.META.get('HTTP_REFERER', None)))
if not next:
next = request.path
return next
def _notification_updated(request, avatar):
notification.send([request.user], "avatar_updated",
{"user": request.user, "avatar": avatar})
if friends:
notification.send((x['friend'] for x in
Friendship.objects.friends_for_user(request.user)),
"avatar_friend_updated",
{"user": request.user, "avatar": avatar}
)
def _get_avatars(user):
# Default set. Needs to be sliced, but that's it. Keep the natural order.
avatars = user.avatar_set.all()
# Current avatar
primary_avatar = avatars.order_by('-primary')[:1]
if primary_avatar:
avatar = primary_avatar[0]
else:
avatar = None
if AVATAR_MAX_AVATARS_PER_USER == 1:
avatars = primary_avatar
else:
# Slice the default set now that we used the queryset for the primary avatar
avatars = avatars[:AVATAR_MAX_AVATARS_PER_USER]
return (avatar, avatars)
@login_required
def add(request, extra_context=None, next_override=None,
upload_form=UploadAvatarForm, *args, **kwargs):
if extra_context is None:
extra_context = {}
avatar, avatars = _get_avatars(request.user)
upload_avatar_form = upload_form(request.POST or None,
request.FILES or None, user=request.user)
if request.method == "POST" and 'avatar' in request.FILES:
if upload_avatar_form.is_valid():
avatar = Avatar(
user = request.user,
primary = True,
)
image_file = request.FILES['avatar']
avatar.avatar.save(image_file.name, image_file)
avatar.save()
updated = True
request.user.message_set.create(
message=_("Successfully uploaded a new avatar."))
if notification:
_notification_updated(request, avatar)
return render_to_response(
'avatar/add.html',
extra_context,
context_instance = RequestContext(
request,
{ 'avatar': avatar,
'avatars': avatars,
'upload_avatar_form': upload_avatar_form,
'next': next_override or _get_next(request), }
)
)
@login_required
def change(request, extra_context=None, next_override=None,
upload_form=UploadAvatarForm, primary_form=PrimaryAvatarForm,
*args, **kwargs):
if extra_context is None:
extra_context = {}
avatar, avatars = _get_avatars(request.user)
if avatar:
kwargs = {'initial': {'choice': avatar.id}}
else:
kwargs = {}
upload_avatar_form = upload_form(user=request.user, **kwargs)
primary_avatar_form = primary_form(request.POST or None,
user=request.user, avatars=avatars, **kwargs)
if request.method == "POST":
updated = False
if 'choice' in request.POST and primary_avatar_form.is_valid():
avatar = Avatar.objects.get(id=
primary_avatar_form.cleaned_data['choice'])
avatar.primary = True
avatar.save()
updated = True
request.user.message_set.create(
message=_("Successfully updated your avatar."))
if updated and notification:
_notification_updated(request, avatar)
return HttpResponseRedirect(next_override or _get_next(request))
return render_to_response(
'avatar/change.html',
extra_context,
context_instance = RequestContext(
request,
{ 'avatar': avatar,
'avatars': avatars,
'upload_avatar_form': upload_avatar_form,
'primary_avatar_form': primary_avatar_form,
'next': next_override or _get_next(request), }
)
)
@login_required
def delete(request, extra_context=None, next_override=None, *args, **kwargs):
if extra_context is None:
extra_context = {}
avatar, avatars = _get_avatars(request.user)
delete_avatar_form = DeleteAvatarForm(request.POST or None,
user=request.user, avatars=avatars)
if request.method == 'POST':
if delete_avatar_form.is_valid():
ids = delete_avatar_form.cleaned_data['choices']
if unicode(avatar.id) in ids and avatars.count() > len(ids):
# Find the next best avatar, and set it as the new primary
for a in avatars:
if unicode(a.id) not in ids:
a.primary = True
a.save()
if notification:
_notification_updated(request, a)
break
Avatar.objects.filter(id__in=ids).delete()
request.user.message_set.create(
message=_("Successfully deleted the requested avatars."))
return HttpResponseRedirect(next_override or _get_next(request))
return render_to_response(
'avatar/confirm_delete.html',
extra_context,
context_instance = RequestContext(
request,
{ 'avatar': avatar,
'avatars': avatars,
'delete_avatar_form': delete_avatar_form,
'next': next_override or _get_next(request), }
)
)
def render_primary(request, extra_context={}, user=None, size=80, *args, **kwargs):
size = int(size)
avatar = get_primary_avatar(user, size=size)
if avatar:
# FIXME: later, add an option to render the resized avatar dynamically
# instead of redirecting to an already created static file. This could
# be useful in certain situations, particulary if there is a CDN and
# we want to minimize the storage usage on our static server, letting
# the CDN store those files instead
return HttpResponseRedirect(avatar.avatar_url(size))
else:
url = get_default_avatar_url()
return HttpResponseRedirect(url)
|
bsd-3-clause
|
[
504,
1639,
14,
1014,
492,
14935,
199,
504,
1639,
14,
17469,
492,
3795,
63,
475,
63,
1310,
199,
504,
1639,
14,
1160,
492,
22538,
199,
504,
1639,
14,
1208,
14,
6893,
492,
10366,
465,
485,
199,
504,
1639,
14,
2190,
492,
2202,
199,
199,
504,
1639,
14,
2828,
14,
1178,
14,
11582,
492,
4676,
63,
2427,
199,
199,
504,
20913,
492,
437,
54,
619,
689,
63,
4283,
63,
6087,
619,
689,
51,
63,
4227,
63,
3791,
199,
504,
20913,
14,
992,
492,
16599,
8535,
199,
504,
20913,
14,
1974,
492,
664,
63,
3327,
63,
14584,
12,
664,
63,
885,
63,
14584,
63,
633,
199,
504,
20913,
14,
3351,
492,
26710,
24916,
2821,
12,
8496,
24916,
2821,
12,
19149,
24916,
2821,
199,
199,
6761,
275,
756,
199,
692,
283,
6761,
7,
315,
2202,
14,
15942,
63,
14219,
26,
272,
687,
6955,
492,
1709,
465,
6955,
199,
199,
18024,
275,
756,
199,
692,
283,
18024,
7,
315,
2202,
14,
15942,
63,
14219,
26,
272,
26157,
275,
715,
272,
687,
26157,
14,
992,
492,
481,
8528,
3319,
199,
199,
318,
485,
362,
63,
2184,
8,
1069,
304,
272,
408,
272,
710,
1777,
626,
1159,
314,
5210,
23669,
6688,
3595,
6858,
315,
642,
859,
365,
4212,
2985,
5591,
6705,
3932,
17784,
2410,
2985,
1172,
9158,
14009,
14,
339,
1010,
3974,
12,
2985,
911,
862,
436,
6705,
314,
2163,
4192,
370,
2621,
315,
314,
2569,
1865,
26,
339,
413,
14,
982,
2337,
365,
282,
1750,
4310,
1124,
2184,
1040,
315,
314,
627,
4030,
10,
2633,
12,
314,
2455,
911,
272,
4660,
370,
626,
1750,
1159,
574,
14,
272,
499,
14,
982,
2337,
365,
282,
1750,
4310,
1124,
2184,
1040,
315,
314,
627,
2970,
10,
2633,
12,
314,
2455,
911,
272,
4660,
370,
626,
1750,
1159,
574,
14,
272,
650,
14,
982,
5634,
883,
6705,
314,
4136,
2034,
687,
314,
3101,
2323,
12,
314,
2455,
911,
272,
4660,
370,
626,
4136,
2034,
14,
272,
408,
272,
2163,
275,
1056,
14,
4030,
14,
362,
360,
2184,
297,
1056,
14,
2970,
14,
362,
360,
2184,
297,
267,
1056,
14,
10614,
14,
362,
360,
2856,
63,
19494,
540,
297,
488,
1724,
272,
340,
440,
2163,
26,
267,
2163,
275,
1056,
14,
515,
272,
372,
2163,
1362,
199,
318,
485,
6761,
63,
5334,
8,
1069,
12,
20913,
304,
272,
6955,
14,
2254,
779,
1069,
14,
751,
467,
298,
14584,
63,
5334,
401,
267,
2420,
751,
582,
1056,
14,
751,
12,
298,
14584,
582,
20913,
1552,
272,
340,
26157,
26,
267,
6955,
14,
2254,
1332,
88,
459,
23472,
418,
367,
671,
315,
355,
481,
8528,
3319,
14,
1462,
14,
18024,
63,
509,
63,
751,
8,
1069,
14,
751,
1826,
288,
298,
14584,
63,
23472,
63,
5334,
401,
288,
2420,
751,
582,
1056,
14,
751,
12,
298,
14584,
582,
20913,
93,
267,
776,
199,
199,
318,
485,
362,
63,
1214,
292,
4291,
8,
751,
304,
272,
327,
3758,
663,
14,
29613,
370,
506,
6014,
68,
12,
1325,
626,
1159,
652,
14,
14797,
314,
19981,
1865,
14,
272,
2289,
292,
4291,
275,
922,
14,
14584,
63,
409,
14,
452,
342,
2286,
327,
9338,
20913,
272,
5062,
63,
14584,
275,
2289,
292,
4291,
14,
1648,
63,
991,
3654,
3327,
358,
1491,
17,
61,
272,
340,
5062,
63,
14584,
26,
267,
20913,
275,
5062,
63,
14584,
59,
16,
61,
272,
587,
26,
267,
20913,
275,
488,
2286,
340,
437,
54,
619,
689,
63,
4283,
63,
6087,
619,
689,
51,
63,
4227,
63,
3791,
508,
413,
26,
267,
2289,
292,
4291,
275,
5062,
63,
14584,
272,
587,
26,
267,
327,
30823,
314,
849,
663,
3063,
626,
781,
1202,
314,
7594,
367,
314,
5062,
20913,
267,
2289,
292,
4291,
275,
2289,
292,
4291,
1491,
6087,
619,
689,
63,
4283,
63,
6087,
619,
689,
51,
63,
4227,
63,
3791,
61,
272,
372,
334,
14584,
12,
2289,
292,
4291,
9,
258,
199,
199,
32,
2886,
63,
2427,
199,
318,
1050,
8,
1069,
12,
2402,
63,
1100,
29,
403,
12,
2163,
63,
4415,
29,
403,
12,
267,
5802,
63,
964,
29,
10301,
24916,
2821,
12,
627,
589,
12,
1011,
958,
304,
272,
340,
2402,
63,
1100,
365,
488,
26,
267,
2402,
63,
1100,
275,
1052,
272,
20913,
12,
2289,
292,
4291,
275,
485,
362,
63,
1214,
292,
4291,
8,
1069,
14,
751,
9,
272,
5802,
63,
14584,
63,
964,
275,
5802,
63,
964,
8,
1069,
14,
4030,
503,
488,
12,
267,
1056,
14,
9472,
503,
488,
12,
922,
29,
1069,
14,
751,
9,
272,
340,
1056,
14,
765,
508,
298,
4030,
2,
436,
283,
14584,
7,
315,
1056,
14,
9472,
26,
267,
340,
5802,
63,
14584,
63,
964,
14,
374,
63,
1078,
837,
288,
20913,
275,
16599,
8535,
8,
355,
922,
275,
1056,
14,
751,
12,
355,
5062,
275,
715,
12,
288,
776,
288,
1834,
63,
493,
275,
1056,
14,
9472,
459,
14584,
418,
288,
20913,
14,
14584,
14,
2117,
8,
1569,
63,
493,
14,
354,
12,
1834,
63,
493,
9,
288,
20913,
14,
2117,
342,
288,
4588,
275,
715,
288,
1056,
14,
751,
14,
1188,
63,
409,
14,
981,
8,
355,
1245,
9384,
25001,
14238,
282,
892,
20913,
13853,
288,
340,
6955,
26,
355,
485,
6761,
63,
5334,
8,
1069,
12,
20913,
9,
272,
372,
3795,
63,
475,
63,
1310,
8,
288,
283,
14584,
15,
525,
14,
1360,
297,
288,
2402,
63,
1100,
12,
288,
1067,
63,
842,
275,
22538,
8,
355,
1056,
12,
355,
469,
283,
14584,
356,
20913,
12,
20177,
283,
1214,
292,
4291,
356,
2289,
292,
4291,
12,
20177,
283,
5064,
63,
14584,
63,
964,
356,
5802,
63,
14584,
63,
964,
12,
2116,
283,
2184,
356,
2163,
63,
4415,
503,
485,
362,
63,
2184,
8,
1069,
395,
789,
288,
776,
267,
776,
199,
199,
32,
2886,
63,
2427,
199,
318,
1570,
8,
1069,
12,
2402,
63,
1100,
29,
403,
12,
2163,
63,
4415,
29,
403,
12,
267,
5802,
63,
964,
29,
10301,
24916,
2821,
12,
5062,
63,
964,
29,
14908,
24916,
2821,
12,
267,
627,
589,
12,
1011,
958,
304,
272,
340,
2402,
63,
1100,
365,
488,
26,
267,
2402,
63,
1100,
275,
1052,
272,
20913,
12,
2289,
292,
4291,
275,
485,
362,
63,
1214,
292,
4291,
8,
1069,
14,
751,
9,
272,
340,
20913,
26,
267,
2074,
275,
791
] |
[
1639,
14,
1014,
492,
14935,
199,
504,
1639,
14,
17469,
492,
3795,
63,
475,
63,
1310,
199,
504,
1639,
14,
1160,
492,
22538,
199,
504,
1639,
14,
1208,
14,
6893,
492,
10366,
465,
485,
199,
504,
1639,
14,
2190,
492,
2202,
199,
199,
504,
1639,
14,
2828,
14,
1178,
14,
11582,
492,
4676,
63,
2427,
199,
199,
504,
20913,
492,
437,
54,
619,
689,
63,
4283,
63,
6087,
619,
689,
51,
63,
4227,
63,
3791,
199,
504,
20913,
14,
992,
492,
16599,
8535,
199,
504,
20913,
14,
1974,
492,
664,
63,
3327,
63,
14584,
12,
664,
63,
885,
63,
14584,
63,
633,
199,
504,
20913,
14,
3351,
492,
26710,
24916,
2821,
12,
8496,
24916,
2821,
12,
19149,
24916,
2821,
199,
199,
6761,
275,
756,
199,
692,
283,
6761,
7,
315,
2202,
14,
15942,
63,
14219,
26,
272,
687,
6955,
492,
1709,
465,
6955,
199,
199,
18024,
275,
756,
199,
692,
283,
18024,
7,
315,
2202,
14,
15942,
63,
14219,
26,
272,
26157,
275,
715,
272,
687,
26157,
14,
992,
492,
481,
8528,
3319,
199,
199,
318,
485,
362,
63,
2184,
8,
1069,
304,
272,
408,
272,
710,
1777,
626,
1159,
314,
5210,
23669,
6688,
3595,
6858,
315,
642,
859,
365,
4212,
2985,
5591,
6705,
3932,
17784,
2410,
2985,
1172,
9158,
14009,
14,
339,
1010,
3974,
12,
2985,
911,
862,
436,
6705,
314,
2163,
4192,
370,
2621,
315,
314,
2569,
1865,
26,
339,
413,
14,
982,
2337,
365,
282,
1750,
4310,
1124,
2184,
1040,
315,
314,
627,
4030,
10,
2633,
12,
314,
2455,
911,
272,
4660,
370,
626,
1750,
1159,
574,
14,
272,
499,
14,
982,
2337,
365,
282,
1750,
4310,
1124,
2184,
1040,
315,
314,
627,
2970,
10,
2633,
12,
314,
2455,
911,
272,
4660,
370,
626,
1750,
1159,
574,
14,
272,
650,
14,
982,
5634,
883,
6705,
314,
4136,
2034,
687,
314,
3101,
2323,
12,
314,
2455,
911,
272,
4660,
370,
626,
4136,
2034,
14,
272,
408,
272,
2163,
275,
1056,
14,
4030,
14,
362,
360,
2184,
297,
1056,
14,
2970,
14,
362,
360,
2184,
297,
267,
1056,
14,
10614,
14,
362,
360,
2856,
63,
19494,
540,
297,
488,
1724,
272,
340,
440,
2163,
26,
267,
2163,
275,
1056,
14,
515,
272,
372,
2163,
1362,
199,
318,
485,
6761,
63,
5334,
8,
1069,
12,
20913,
304,
272,
6955,
14,
2254,
779,
1069,
14,
751,
467,
298,
14584,
63,
5334,
401,
267,
2420,
751,
582,
1056,
14,
751,
12,
298,
14584,
582,
20913,
1552,
272,
340,
26157,
26,
267,
6955,
14,
2254,
1332,
88,
459,
23472,
418,
367,
671,
315,
355,
481,
8528,
3319,
14,
1462,
14,
18024,
63,
509,
63,
751,
8,
1069,
14,
751,
1826,
288,
298,
14584,
63,
23472,
63,
5334,
401,
288,
2420,
751,
582,
1056,
14,
751,
12,
298,
14584,
582,
20913,
93,
267,
776,
199,
199,
318,
485,
362,
63,
1214,
292,
4291,
8,
751,
304,
272,
327,
3758,
663,
14,
29613,
370,
506,
6014,
68,
12,
1325,
626,
1159,
652,
14,
14797,
314,
19981,
1865,
14,
272,
2289,
292,
4291,
275,
922,
14,
14584,
63,
409,
14,
452,
342,
2286,
327,
9338,
20913,
272,
5062,
63,
14584,
275,
2289,
292,
4291,
14,
1648,
63,
991,
3654,
3327,
358,
1491,
17,
61,
272,
340,
5062,
63,
14584,
26,
267,
20913,
275,
5062,
63,
14584,
59,
16,
61,
272,
587,
26,
267,
20913,
275,
488,
2286,
340,
437,
54,
619,
689,
63,
4283,
63,
6087,
619,
689,
51,
63,
4227,
63,
3791,
508,
413,
26,
267,
2289,
292,
4291,
275,
5062,
63,
14584,
272,
587,
26,
267,
327,
30823,
314,
849,
663,
3063,
626,
781,
1202,
314,
7594,
367,
314,
5062,
20913,
267,
2289,
292,
4291,
275,
2289,
292,
4291,
1491,
6087,
619,
689,
63,
4283,
63,
6087,
619,
689,
51,
63,
4227,
63,
3791,
61,
272,
372,
334,
14584,
12,
2289,
292,
4291,
9,
258,
199,
199,
32,
2886,
63,
2427,
199,
318,
1050,
8,
1069,
12,
2402,
63,
1100,
29,
403,
12,
2163,
63,
4415,
29,
403,
12,
267,
5802,
63,
964,
29,
10301,
24916,
2821,
12,
627,
589,
12,
1011,
958,
304,
272,
340,
2402,
63,
1100,
365,
488,
26,
267,
2402,
63,
1100,
275,
1052,
272,
20913,
12,
2289,
292,
4291,
275,
485,
362,
63,
1214,
292,
4291,
8,
1069,
14,
751,
9,
272,
5802,
63,
14584,
63,
964,
275,
5802,
63,
964,
8,
1069,
14,
4030,
503,
488,
12,
267,
1056,
14,
9472,
503,
488,
12,
922,
29,
1069,
14,
751,
9,
272,
340,
1056,
14,
765,
508,
298,
4030,
2,
436,
283,
14584,
7,
315,
1056,
14,
9472,
26,
267,
340,
5802,
63,
14584,
63,
964,
14,
374,
63,
1078,
837,
288,
20913,
275,
16599,
8535,
8,
355,
922,
275,
1056,
14,
751,
12,
355,
5062,
275,
715,
12,
288,
776,
288,
1834,
63,
493,
275,
1056,
14,
9472,
459,
14584,
418,
288,
20913,
14,
14584,
14,
2117,
8,
1569,
63,
493,
14,
354,
12,
1834,
63,
493,
9,
288,
20913,
14,
2117,
342,
288,
4588,
275,
715,
288,
1056,
14,
751,
14,
1188,
63,
409,
14,
981,
8,
355,
1245,
9384,
25001,
14238,
282,
892,
20913,
13853,
288,
340,
6955,
26,
355,
485,
6761,
63,
5334,
8,
1069,
12,
20913,
9,
272,
372,
3795,
63,
475,
63,
1310,
8,
288,
283,
14584,
15,
525,
14,
1360,
297,
288,
2402,
63,
1100,
12,
288,
1067,
63,
842,
275,
22538,
8,
355,
1056,
12,
355,
469,
283,
14584,
356,
20913,
12,
20177,
283,
1214,
292,
4291,
356,
2289,
292,
4291,
12,
20177,
283,
5064,
63,
14584,
63,
964,
356,
5802,
63,
14584,
63,
964,
12,
2116,
283,
2184,
356,
2163,
63,
4415,
503,
485,
362,
63,
2184,
8,
1069,
395,
789,
288,
776,
267,
776,
199,
199,
32,
2886,
63,
2427,
199,
318,
1570,
8,
1069,
12,
2402,
63,
1100,
29,
403,
12,
2163,
63,
4415,
29,
403,
12,
267,
5802,
63,
964,
29,
10301,
24916,
2821,
12,
5062,
63,
964,
29,
14908,
24916,
2821,
12,
267,
627,
589,
12,
1011,
958,
304,
272,
340,
2402,
63,
1100,
365,
488,
26,
267,
2402,
63,
1100,
275,
1052,
272,
20913,
12,
2289,
292,
4291,
275,
485,
362,
63,
1214,
292,
4291,
8,
1069,
14,
751,
9,
272,
340,
20913,
26,
267,
2074,
275,
791,
0
] |
[
1,
1,
1,
1,
1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for-android
|
python-build/python-libs/gdata/tests/gdata_tests/photos/service_test.py
|
128
|
2928
|
#!/usr/bin/python
#
# Copyright (C) 2007 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.
__author__ = 'api.jscudder (Jeffrey Scudder)'
import getpass
import time
import unittest
import StringIO
import gdata.photos.service
import gdata.photos
import atom
username = ''
password = ''
test_image_location = '../../testimage.jpg'
test_image_name = 'testimage.jpg'
class PhotosServiceTest(unittest.TestCase):
def setUp(self):
# Initialize the client and create a new album for testing.
self.client = gdata.photos.service.PhotosService()
self.client.email = username
self.client.password = password
self.client.source = 'Photos Client Unit Tests'
self.client.ProgrammaticLogin()
# Give the album a unique title by appending the current time.
self.test_album = self.client.InsertAlbum(
'Python library test' + str(time.time()),
'A temporary test album.')
def testUploadGetAndDeletePhoto(self):
image_entry = self.client.InsertPhotoSimple(self.test_album,
'test', 'a pretty testing picture', test_image_location)
self.assert_(image_entry.title.text == 'test')
results_feed = self.client.SearchUserPhotos('test')
self.assert_(len(results_feed.entry) > 0)
self.client.Delete(image_entry)
def testInsertPhotoUpdateBlobAndDelete(self):
new_entry = gdata.photos.PhotoEntry()
new_entry.title = atom.Title(text='a_test_image')
new_entry.summary = atom.Summary(text='Just a test.')
new_entry.category.append(atom.Category(
scheme='http://schemas.google.com/g/2005#kind',
term='http://schemas.google.com/photos/2007#photo'))
entry = self.client.InsertPhoto(self.test_album, new_entry,
test_image_location, content_type='image/jpeg')
self.assert_(entry.id.text)
updated_entry = self.client.UpdatePhotoBlob(entry, test_image_location)
self.assert_(entry.GetEditLink().href != updated_entry.GetEditLink().href)
self.client.Delete(updated_entry)
def tearDown(self):
# Delete the test album.
test_album = self.client.GetEntry(self.test_album.GetSelfLink().href)
self.client.Delete(test_album)
if __name__ == '__main__':
print ('Google Photos test\nNOTE: Please run these tests only with a test '
'account. The tests may delete or update your data.')
username = raw_input('Please enter your username: ')
password = getpass.getpass()
unittest.main()
|
apache-2.0
|
[
3381,
2647,
15,
1393,
15,
1548,
199,
3,
199,
3,
1898,
334,
35,
9,
10219,
4475,
3277,
14,
199,
3,
199,
3,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
199,
3,
1265,
1443,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
199,
3,
2047,
1443,
3332,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
420,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
199,
3,
2428,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
199,
3,
1666,
314,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
199,
3,
4204,
1334,
314,
844,
14,
199,
199,
363,
2502,
363,
275,
283,
1246,
14,
74,
551,
1181,
424,
334,
42,
3609,
17885,
13916,
1181,
424,
3171,
199,
199,
646,
18354,
199,
646,
900,
199,
646,
2882,
199,
646,
5228,
199,
646,
11006,
14,
25211,
14,
1364,
199,
646,
11006,
14,
25211,
199,
646,
6222,
421,
199,
2473,
275,
2125,
199,
2060,
275,
2125,
199,
396,
63,
1569,
63,
1985,
275,
283,
9707,
396,
1569,
14,
8476,
7,
199,
396,
63,
1569,
63,
354,
275,
283,
396,
1569,
14,
8476,
7,
421,
199,
533,
510,
8885,
736,
3167,
774,
8,
2796,
14,
1746,
304,
819,
347,
3613,
8,
277,
304,
272,
327,
11578,
314,
1890,
436,
1218,
282,
892,
16379,
367,
5343,
14,
272,
291,
14,
1258,
275,
11006,
14,
25211,
14,
1364,
14,
5663,
17278,
3167,
342,
272,
291,
14,
1258,
14,
2123,
275,
3434,
272,
291,
14,
1258,
14,
2060,
275,
2505,
272,
291,
14,
1258,
14,
1365,
275,
283,
5663,
17278,
6810,
12008,
6496,
7,
272,
291,
14,
1258,
14,
9184,
3889,
8880,
342,
339,
327,
25495,
314,
16379,
282,
3747,
2538,
701,
24373,
314,
1453,
900,
14,
272,
291,
14,
396,
63,
12110,
275,
291,
14,
1258,
14,
9971,
26369,
8,
267,
283,
4718,
3555,
511,
7,
435,
620,
8,
521,
14,
521,
4000,
4960,
283,
33,
7937,
511,
16379,
2659,
819,
347,
511,
10301,
1002,
3325,
5392,
21258,
8,
277,
304,
272,
1834,
63,
2373,
275,
291,
14,
1258,
14,
9971,
21258,
3184,
8,
277,
14,
396,
63,
12110,
12,
267,
283,
396,
297,
283,
65,
7268,
5343,
24945,
297,
511,
63,
1569,
63,
1985,
9,
272,
291,
14,
479,
2531,
1569,
63,
2373,
14,
1213,
14,
505,
508,
283,
396,
358,
272,
2058,
63,
3871,
275,
291,
14,
1258,
14,
5278,
1899,
5663,
17278,
360,
396,
358,
272,
291,
14,
479,
2531,
552,
8,
2604,
63,
3871,
14,
2373,
9,
690,
378,
9,
272,
291,
14,
1258,
14,
5392,
8,
1569,
63,
2373,
9,
819,
347,
511,
9971,
21258,
4152,
16799,
3325,
5392,
8,
277,
304,
272,
892,
63,
2373,
275,
11006,
14,
25211,
14,
21258,
3900,
342,
272,
892,
63,
2373,
14,
1213,
275,
6222,
14,
6888,
8,
505,
534,
65,
63,
396,
63,
1569,
358,
272,
892,
63,
2373,
14,
4705,
275,
6222,
14,
10407,
8,
505,
534,
22850,
282,
511,
2659,
272,
892,
63,
2373,
14,
3710,
14,
740,
8,
4188,
14,
7841,
8,
267,
5687,
534,
1014,
921,
9482,
14,
3098,
14,
957,
15,
71,
15,
9397,
3,
5091,
297,
4960,
6707,
534,
1014,
921,
9482,
14,
3098,
14,
957,
15,
25211,
15,
9488,
3,
13834,
1333,
272,
2397,
275,
291,
14,
1258,
14,
9971,
21258,
8,
277,
14,
396,
63,
12110,
12,
892,
63,
2373,
12,
4960,
511,
63,
1569,
63,
1985,
12,
1564,
63,
466,
534,
1569,
15,
14230,
358,
272,
291,
14,
479,
2531,
2373,
14,
344,
14,
505,
9,
272,
4588,
63,
2373,
275,
291,
14,
1258,
14,
4152,
21258,
16799,
8,
2373,
12,
511,
63,
1569,
63,
1985,
9,
272,
291,
14,
479,
2531,
2373,
14,
1002,
4685,
3834,
1252,
6399,
1137,
4588,
63,
2373,
14,
1002,
4685,
3834,
1252,
6399,
9,
272,
291,
14,
1258,
14,
5392,
8,
5334,
63,
2373,
9,
819,
347,
6766,
8,
277,
304,
272,
327,
8496,
314,
511,
16379,
14,
272,
511,
63,
12110,
275,
291,
14,
1258,
14,
1002,
3900,
8,
277,
14,
396,
63,
12110,
14,
1002,
12887,
3834,
1252,
6399,
9,
272,
291,
14,
1258,
14,
5392,
8,
396,
63,
12110,
9,
2043,
199,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
523,
870,
661,
13266,
510,
8885,
736,
511,
60,
78,
19855,
26,
7754,
1255,
3520,
2295,
1454,
543,
282,
511,
283,
268,
283,
2048,
14,
710,
2295,
1443,
3145,
503,
1678,
2195,
666,
2659,
523,
3434,
275,
3066,
63,
1210,
360,
8254,
9509,
2195,
3434,
26,
5320,
523,
2505,
275,
18354,
14,
27481,
342,
523,
2882,
14,
973,
342,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
2647,
15,
1393,
15,
1548,
199,
3,
199,
3,
1898,
334,
35,
9,
10219,
4475,
3277,
14,
199,
3,
199,
3,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
199,
3,
1265,
1443,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
199,
3,
2047,
1443,
3332,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
420,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
199,
3,
2428,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
199,
3,
1666,
314,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
199,
3,
4204,
1334,
314,
844,
14,
199,
199,
363,
2502,
363,
275,
283,
1246,
14,
74,
551,
1181,
424,
334,
42,
3609,
17885,
13916,
1181,
424,
3171,
199,
199,
646,
18354,
199,
646,
900,
199,
646,
2882,
199,
646,
5228,
199,
646,
11006,
14,
25211,
14,
1364,
199,
646,
11006,
14,
25211,
199,
646,
6222,
421,
199,
2473,
275,
2125,
199,
2060,
275,
2125,
199,
396,
63,
1569,
63,
1985,
275,
283,
9707,
396,
1569,
14,
8476,
7,
199,
396,
63,
1569,
63,
354,
275,
283,
396,
1569,
14,
8476,
7,
421,
199,
533,
510,
8885,
736,
3167,
774,
8,
2796,
14,
1746,
304,
819,
347,
3613,
8,
277,
304,
272,
327,
11578,
314,
1890,
436,
1218,
282,
892,
16379,
367,
5343,
14,
272,
291,
14,
1258,
275,
11006,
14,
25211,
14,
1364,
14,
5663,
17278,
3167,
342,
272,
291,
14,
1258,
14,
2123,
275,
3434,
272,
291,
14,
1258,
14,
2060,
275,
2505,
272,
291,
14,
1258,
14,
1365,
275,
283,
5663,
17278,
6810,
12008,
6496,
7,
272,
291,
14,
1258,
14,
9184,
3889,
8880,
342,
339,
327,
25495,
314,
16379,
282,
3747,
2538,
701,
24373,
314,
1453,
900,
14,
272,
291,
14,
396,
63,
12110,
275,
291,
14,
1258,
14,
9971,
26369,
8,
267,
283,
4718,
3555,
511,
7,
435,
620,
8,
521,
14,
521,
4000,
4960,
283,
33,
7937,
511,
16379,
2659,
819,
347,
511,
10301,
1002,
3325,
5392,
21258,
8,
277,
304,
272,
1834,
63,
2373,
275,
291,
14,
1258,
14,
9971,
21258,
3184,
8,
277,
14,
396,
63,
12110,
12,
267,
283,
396,
297,
283,
65,
7268,
5343,
24945,
297,
511,
63,
1569,
63,
1985,
9,
272,
291,
14,
479,
2531,
1569,
63,
2373,
14,
1213,
14,
505,
508,
283,
396,
358,
272,
2058,
63,
3871,
275,
291,
14,
1258,
14,
5278,
1899,
5663,
17278,
360,
396,
358,
272,
291,
14,
479,
2531,
552,
8,
2604,
63,
3871,
14,
2373,
9,
690,
378,
9,
272,
291,
14,
1258,
14,
5392,
8,
1569,
63,
2373,
9,
819,
347,
511,
9971,
21258,
4152,
16799,
3325,
5392,
8,
277,
304,
272,
892,
63,
2373,
275,
11006,
14,
25211,
14,
21258,
3900,
342,
272,
892,
63,
2373,
14,
1213,
275,
6222,
14,
6888,
8,
505,
534,
65,
63,
396,
63,
1569,
358,
272,
892,
63,
2373,
14,
4705,
275,
6222,
14,
10407,
8,
505,
534,
22850,
282,
511,
2659,
272,
892,
63,
2373,
14,
3710,
14,
740,
8,
4188,
14,
7841,
8,
267,
5687,
534,
1014,
921,
9482,
14,
3098,
14,
957,
15,
71,
15,
9397,
3,
5091,
297,
4960,
6707,
534,
1014,
921,
9482,
14,
3098,
14,
957,
15,
25211,
15,
9488,
3,
13834,
1333,
272,
2397,
275,
291,
14,
1258,
14,
9971,
21258,
8,
277,
14,
396,
63,
12110,
12,
892,
63,
2373,
12,
4960,
511,
63,
1569,
63,
1985,
12,
1564,
63,
466,
534,
1569,
15,
14230,
358,
272,
291,
14,
479,
2531,
2373,
14,
344,
14,
505,
9,
272,
4588,
63,
2373,
275,
291,
14,
1258,
14,
4152,
21258,
16799,
8,
2373,
12,
511,
63,
1569,
63,
1985,
9,
272,
291,
14,
479,
2531,
2373,
14,
1002,
4685,
3834,
1252,
6399,
1137,
4588,
63,
2373,
14,
1002,
4685,
3834,
1252,
6399,
9,
272,
291,
14,
1258,
14,
5392,
8,
5334,
63,
2373,
9,
819,
347,
6766,
8,
277,
304,
272,
327,
8496,
314,
511,
16379,
14,
272,
511,
63,
12110,
275,
291,
14,
1258,
14,
1002,
3900,
8,
277,
14,
396,
63,
12110,
14,
1002,
12887,
3834,
1252,
6399,
9,
272,
291,
14,
1258,
14,
5392,
8,
396,
63,
12110,
9,
2043,
199,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
523,
870,
661,
13266,
510,
8885,
736,
511,
60,
78,
19855,
26,
7754,
1255,
3520,
2295,
1454,
543,
282,
511,
283,
268,
283,
2048,
14,
710,
2295,
1443,
3145,
503,
1678,
2195,
666,
2659,
523,
3434,
275,
3066,
63,
1210,
360,
8254,
9509,
2195,
3434,
26,
5320,
523,
2505,
275,
18354,
14,
27481,
342,
523,
2882,
14,
973,
342,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
ephes/scikit-learn
|
examples/decomposition/plot_faces_decomposition.py
|
204
|
4452
|
"""
============================
Faces dataset decompositions
============================
This example applies to :ref:`olivetti_faces` different unsupervised
matrix decomposition (dimension reduction) methods from the module
:py:mod:`sklearn.decomposition` (see the documentation chapter
:ref:`decompositions`) .
"""
print(__doc__)
# Authors: Vlad Niculae, Alexandre Gramfort
# License: BSD 3 clause
import logging
from time import time
from numpy.random import RandomState
import matplotlib.pyplot as plt
from sklearn.datasets import fetch_olivetti_faces
from sklearn.cluster import MiniBatchKMeans
from sklearn import decomposition
# Display progress logs on stdout
logging.basicConfig(level=logging.INFO,
format='%(asctime)s %(levelname)s %(message)s')
n_row, n_col = 2, 3
n_components = n_row * n_col
image_shape = (64, 64)
rng = RandomState(0)
###############################################################################
# Load faces data
dataset = fetch_olivetti_faces(shuffle=True, random_state=rng)
faces = dataset.data
n_samples, n_features = faces.shape
# global centering
faces_centered = faces - faces.mean(axis=0)
# local centering
faces_centered -= faces_centered.mean(axis=1).reshape(n_samples, -1)
print("Dataset consists of %d faces" % n_samples)
###############################################################################
def plot_gallery(title, images, n_col=n_col, n_row=n_row):
plt.figure(figsize=(2. * n_col, 2.26 * n_row))
plt.suptitle(title, size=16)
for i, comp in enumerate(images):
plt.subplot(n_row, n_col, i + 1)
vmax = max(comp.max(), -comp.min())
plt.imshow(comp.reshape(image_shape), cmap=plt.cm.gray,
interpolation='nearest',
vmin=-vmax, vmax=vmax)
plt.xticks(())
plt.yticks(())
plt.subplots_adjust(0.01, 0.05, 0.99, 0.93, 0.04, 0.)
###############################################################################
# List of the different estimators, whether to center and transpose the
# problem, and whether the transformer uses the clustering API.
estimators = [
('Eigenfaces - RandomizedPCA',
decomposition.RandomizedPCA(n_components=n_components, whiten=True),
True),
('Non-negative components - NMF',
decomposition.NMF(n_components=n_components, init='nndsvda', beta=5.0,
tol=5e-3, sparseness='components'),
False),
('Independent components - FastICA',
decomposition.FastICA(n_components=n_components, whiten=True),
True),
('Sparse comp. - MiniBatchSparsePCA',
decomposition.MiniBatchSparsePCA(n_components=n_components, alpha=0.8,
n_iter=100, batch_size=3,
random_state=rng),
True),
('MiniBatchDictionaryLearning',
decomposition.MiniBatchDictionaryLearning(n_components=15, alpha=0.1,
n_iter=50, batch_size=3,
random_state=rng),
True),
('Cluster centers - MiniBatchKMeans',
MiniBatchKMeans(n_clusters=n_components, tol=1e-3, batch_size=20,
max_iter=50, random_state=rng),
True),
('Factor Analysis components - FA',
decomposition.FactorAnalysis(n_components=n_components, max_iter=2),
True),
]
###############################################################################
# Plot a sample of the input data
plot_gallery("First centered Olivetti faces", faces_centered[:n_components])
###############################################################################
# Do the estimation and plot it
for name, estimator, center in estimators:
print("Extracting the top %d %s..." % (n_components, name))
t0 = time()
data = faces
if center:
data = faces_centered
estimator.fit(data)
train_time = (time() - t0)
print("done in %0.3fs" % train_time)
if hasattr(estimator, 'cluster_centers_'):
components_ = estimator.cluster_centers_
else:
components_ = estimator.components_
if hasattr(estimator, 'noise_variance_'):
plot_gallery("Pixelwise variance",
estimator.noise_variance_.reshape(1, -1), n_col=1,
n_row=1)
plot_gallery('%s - Train time %.1fs' % (name, train_time),
components_[:n_components])
plt.show()
|
bsd-3-clause
|
[
624,
199,
1280,
5769,
199,
1906,
823,
4789,
477,
7784,
6150,
199,
1280,
5769,
199,
199,
2765,
2893,
12966,
370,
520,
1121,
1705,
23711,
28350,
280,
63,
4309,
64,
3365,
625,
4792,
17311,
199,
3642,
22706,
334,
7430,
16773,
9,
3102,
687,
314,
859,
199,
26,
647,
26,
1494,
1705,
27993,
14,
31384,
64,
334,
3239,
314,
3794,
17044,
199,
26,
1121,
1705,
271,
7784,
6150,
10522,
1275,
199,
199,
624,
199,
1361,
3460,
1301,
3368,
199,
199,
3,
6642,
26,
812,
76,
350,
653,
530,
348,
3624,
12,
22986,
28547,
27211,
10279,
199,
3,
844,
26,
6289,
650,
8502,
199,
199,
646,
2050,
199,
504,
900,
492,
900,
199,
199,
504,
2680,
14,
2355,
492,
22233,
199,
646,
8027,
14,
13563,
465,
4488,
199,
199,
504,
6357,
14,
12281,
492,
5267,
63,
23711,
28350,
280,
63,
4309,
199,
504,
6357,
14,
4201,
492,
24954,
8842,
43,
21190,
199,
504,
6357,
492,
22706,
199,
199,
3,
12175,
6696,
9610,
641,
3839,
199,
4806,
14,
19602,
8,
1896,
29,
4806,
14,
4531,
12,
490,
1475,
29342,
18331,
9,
83,
2818,
20056,
9,
83,
2818,
1188,
9,
83,
358,
199,
78,
63,
1143,
12,
302,
63,
761,
275,
499,
12,
650,
199,
78,
63,
4608,
275,
302,
63,
1143,
627,
302,
63,
761,
199,
1569,
63,
1392,
275,
334,
772,
12,
5049,
9,
199,
12686,
275,
22233,
8,
16,
9,
199,
199,
11490,
199,
3,
7190,
21143,
666,
199,
5214,
275,
5267,
63,
23711,
28350,
280,
63,
4309,
8,
11777,
29,
549,
12,
2196,
63,
929,
29,
12686,
9,
199,
4309,
275,
4789,
14,
576,
199,
199,
78,
63,
3356,
12,
302,
63,
3179,
275,
21143,
14,
1392,
199,
199,
3,
2288,
8126,
316,
199,
4309,
63,
20080,
275,
21143,
446,
21143,
14,
3670,
8,
3127,
29,
16,
9,
199,
199,
3,
2257,
8126,
316,
199,
4309,
63,
20080,
4862,
21143,
63,
20080,
14,
3670,
8,
3127,
29,
17,
680,
5217,
8,
78,
63,
3356,
12,
446,
17,
9,
199,
199,
1361,
480,
9271,
18581,
402,
450,
68,
21143,
2,
450,
302,
63,
3356,
9,
421,
199,
11490,
199,
318,
5137,
63,
25372,
8,
1213,
12,
5935,
12,
302,
63,
761,
29,
78,
63,
761,
12,
302,
63,
1143,
29,
78,
63,
1143,
304,
272,
4488,
14,
8941,
8,
23899,
2687,
18,
14,
627,
302,
63,
761,
12,
499,
14,
1479,
627,
302,
63,
1143,
430,
272,
4488,
14,
1961,
1213,
8,
1213,
12,
1568,
29,
975,
9,
272,
367,
284,
12,
1013,
315,
3874,
8,
4782,
304,
267,
4488,
14,
13334,
8,
78,
63,
1143,
12,
302,
63,
761,
12,
284,
435,
413,
9,
267,
23349,
275,
1390,
8,
863,
14,
988,
1062,
446,
863,
14,
827,
1012,
267,
4488,
14,
20413,
8,
863,
14,
5217,
8,
1569,
63,
1392,
395,
14920,
29,
6003,
14,
4400,
14,
12150,
12,
673,
14046,
534,
16615,
297,
673,
25221,
4022,
30609,
12,
23349,
29,
30609,
9,
267,
4488,
14,
26217,
30812,
267,
4488,
14,
30588,
30812,
272,
4488,
14,
21430,
63,
10917,
8,
16,
14,
614,
12,
378,
14,
1717,
12,
378,
14,
1020,
12,
378,
14,
3129,
12,
378,
14,
966,
12,
378,
4959,
199,
199,
11490,
199,
3,
3820,
402,
314,
3365,
23155,
12,
3775,
370,
8126,
436,
16992,
314,
199,
3,
5160,
12,
436,
3775,
314,
21484,
4440,
314,
19454,
3261,
14,
199,
10646,
275,
359,
272,
661,
37,
8478,
4309,
446,
9571,
1759,
23852,
297,
1362,
22706,
14,
3883,
1759,
23852,
8,
78,
63,
4608,
29,
78,
63,
4608,
12,
704,
25840,
29,
549,
395,
1362,
715,
395,
339,
661,
6932,
13,
7371,
7323,
446,
653,
13463,
297,
1362,
22706,
14,
46,
13463,
8,
78,
63,
4608,
29,
78,
63,
4608,
12,
4205,
534,
4411,
795,
86,
983,
297,
8201,
29,
21,
14,
16,
12,
2432,
9561,
29,
21,
69,
13,
19,
12,
5178,
4171,
534,
4608,
659,
1362,
756,
395,
339,
661,
607,
7106,
7323,
446,
22613,
948,
33,
297,
1362,
22706,
14,
16976,
948,
33,
8,
78,
63,
4608,
29,
78,
63,
4608,
12,
704,
25840,
29,
549,
395,
1362,
715,
395,
339,
661,
8629,
1013,
14,
446,
24954,
8842,
8629,
23852,
297,
1362,
22706,
14,
26822,
8842,
8629,
23852,
8,
78,
63,
4608,
29,
78,
63,
4608,
12,
5131,
29,
16,
14,
24,
12,
4228,
302,
63,
1661,
29,
1960,
12,
3522,
63,
890,
29,
19,
12,
4228,
2196,
63,
929,
29,
12686,
395,
1362,
715,
395,
339,
661,
26822,
8842,
11728,
25519,
297,
267,
22706,
14,
26822,
8842,
11728,
25519,
8,
78,
63,
4608,
29,
1046,
12,
5131,
29,
16,
14,
17,
12,
8179,
302,
63,
1661,
29,
1400,
12,
3522,
63,
890,
29,
19,
12,
8179,
2196,
63,
929,
29,
12686,
395,
1362,
715,
395,
339,
661,
9581,
19190,
446,
24954,
8842,
43,
21190,
297,
267,
24954,
8842,
43,
21190,
8,
78,
63,
9170,
29,
78,
63,
4608,
12,
9561,
29,
17,
69,
13,
19,
12,
3522,
63,
890,
29,
1165,
12,
717,
1390,
63,
1661,
29,
1400,
12,
2196,
63,
929,
29,
12686,
395,
1362,
715,
395,
339,
661,
12666,
21916,
7323,
446,
481,
33,
297,
1362,
22706,
14,
12666,
13182,
8,
78,
63,
4608,
29,
78,
63,
4608,
12,
1390,
63,
1661,
29,
18,
395,
1362,
715,
395,
199,
61,
421,
199,
11490,
199,
3,
14794,
282,
2690,
402,
314,
1324,
666,
199,
199,
2798,
63,
25372,
480,
7147,
23903,
593,
317,
28350,
280,
21143,
401,
21143,
63,
20080,
1491,
78,
63,
4608,
566,
199,
199,
11490,
199,
3,
4226,
314,
27156,
436,
5137,
652,
199,
199,
509,
536,
12,
8943,
12,
8126,
315,
23155,
26,
272,
870,
480,
12147,
316,
314,
2746,
450,
68,
450,
83,
11500,
450,
334,
78,
63,
4608,
12,
536,
430,
272,
307,
16,
275,
900,
342,
272,
666,
275,
21143,
272,
340,
8126,
26,
267,
666,
275,
21143,
63,
20080,
272,
8943,
14,
3269,
8,
576,
9,
272,
3560,
63,
521,
275,
334,
521,
342,
446,
307,
16,
9,
272,
870,
480,
4456,
315,
450,
16,
14,
19,
2319,
2,
450,
3560,
63,
521,
9,
272,
340,
2688,
8,
8627,
12,
283,
4201,
63,
15660,
25865,
267,
7323,
63,
275,
8943,
14,
4201,
63,
15660,
63,
272,
587,
26,
267,
7323
] |
[
199,
1280,
5769,
199,
1906,
823,
4789,
477,
7784,
6150,
199,
1280,
5769,
199,
199,
2765,
2893,
12966,
370,
520,
1121,
1705,
23711,
28350,
280,
63,
4309,
64,
3365,
625,
4792,
17311,
199,
3642,
22706,
334,
7430,
16773,
9,
3102,
687,
314,
859,
199,
26,
647,
26,
1494,
1705,
27993,
14,
31384,
64,
334,
3239,
314,
3794,
17044,
199,
26,
1121,
1705,
271,
7784,
6150,
10522,
1275,
199,
199,
624,
199,
1361,
3460,
1301,
3368,
199,
199,
3,
6642,
26,
812,
76,
350,
653,
530,
348,
3624,
12,
22986,
28547,
27211,
10279,
199,
3,
844,
26,
6289,
650,
8502,
199,
199,
646,
2050,
199,
504,
900,
492,
900,
199,
199,
504,
2680,
14,
2355,
492,
22233,
199,
646,
8027,
14,
13563,
465,
4488,
199,
199,
504,
6357,
14,
12281,
492,
5267,
63,
23711,
28350,
280,
63,
4309,
199,
504,
6357,
14,
4201,
492,
24954,
8842,
43,
21190,
199,
504,
6357,
492,
22706,
199,
199,
3,
12175,
6696,
9610,
641,
3839,
199,
4806,
14,
19602,
8,
1896,
29,
4806,
14,
4531,
12,
490,
1475,
29342,
18331,
9,
83,
2818,
20056,
9,
83,
2818,
1188,
9,
83,
358,
199,
78,
63,
1143,
12,
302,
63,
761,
275,
499,
12,
650,
199,
78,
63,
4608,
275,
302,
63,
1143,
627,
302,
63,
761,
199,
1569,
63,
1392,
275,
334,
772,
12,
5049,
9,
199,
12686,
275,
22233,
8,
16,
9,
199,
199,
11490,
199,
3,
7190,
21143,
666,
199,
5214,
275,
5267,
63,
23711,
28350,
280,
63,
4309,
8,
11777,
29,
549,
12,
2196,
63,
929,
29,
12686,
9,
199,
4309,
275,
4789,
14,
576,
199,
199,
78,
63,
3356,
12,
302,
63,
3179,
275,
21143,
14,
1392,
199,
199,
3,
2288,
8126,
316,
199,
4309,
63,
20080,
275,
21143,
446,
21143,
14,
3670,
8,
3127,
29,
16,
9,
199,
199,
3,
2257,
8126,
316,
199,
4309,
63,
20080,
4862,
21143,
63,
20080,
14,
3670,
8,
3127,
29,
17,
680,
5217,
8,
78,
63,
3356,
12,
446,
17,
9,
199,
199,
1361,
480,
9271,
18581,
402,
450,
68,
21143,
2,
450,
302,
63,
3356,
9,
421,
199,
11490,
199,
318,
5137,
63,
25372,
8,
1213,
12,
5935,
12,
302,
63,
761,
29,
78,
63,
761,
12,
302,
63,
1143,
29,
78,
63,
1143,
304,
272,
4488,
14,
8941,
8,
23899,
2687,
18,
14,
627,
302,
63,
761,
12,
499,
14,
1479,
627,
302,
63,
1143,
430,
272,
4488,
14,
1961,
1213,
8,
1213,
12,
1568,
29,
975,
9,
272,
367,
284,
12,
1013,
315,
3874,
8,
4782,
304,
267,
4488,
14,
13334,
8,
78,
63,
1143,
12,
302,
63,
761,
12,
284,
435,
413,
9,
267,
23349,
275,
1390,
8,
863,
14,
988,
1062,
446,
863,
14,
827,
1012,
267,
4488,
14,
20413,
8,
863,
14,
5217,
8,
1569,
63,
1392,
395,
14920,
29,
6003,
14,
4400,
14,
12150,
12,
673,
14046,
534,
16615,
297,
673,
25221,
4022,
30609,
12,
23349,
29,
30609,
9,
267,
4488,
14,
26217,
30812,
267,
4488,
14,
30588,
30812,
272,
4488,
14,
21430,
63,
10917,
8,
16,
14,
614,
12,
378,
14,
1717,
12,
378,
14,
1020,
12,
378,
14,
3129,
12,
378,
14,
966,
12,
378,
4959,
199,
199,
11490,
199,
3,
3820,
402,
314,
3365,
23155,
12,
3775,
370,
8126,
436,
16992,
314,
199,
3,
5160,
12,
436,
3775,
314,
21484,
4440,
314,
19454,
3261,
14,
199,
10646,
275,
359,
272,
661,
37,
8478,
4309,
446,
9571,
1759,
23852,
297,
1362,
22706,
14,
3883,
1759,
23852,
8,
78,
63,
4608,
29,
78,
63,
4608,
12,
704,
25840,
29,
549,
395,
1362,
715,
395,
339,
661,
6932,
13,
7371,
7323,
446,
653,
13463,
297,
1362,
22706,
14,
46,
13463,
8,
78,
63,
4608,
29,
78,
63,
4608,
12,
4205,
534,
4411,
795,
86,
983,
297,
8201,
29,
21,
14,
16,
12,
2432,
9561,
29,
21,
69,
13,
19,
12,
5178,
4171,
534,
4608,
659,
1362,
756,
395,
339,
661,
607,
7106,
7323,
446,
22613,
948,
33,
297,
1362,
22706,
14,
16976,
948,
33,
8,
78,
63,
4608,
29,
78,
63,
4608,
12,
704,
25840,
29,
549,
395,
1362,
715,
395,
339,
661,
8629,
1013,
14,
446,
24954,
8842,
8629,
23852,
297,
1362,
22706,
14,
26822,
8842,
8629,
23852,
8,
78,
63,
4608,
29,
78,
63,
4608,
12,
5131,
29,
16,
14,
24,
12,
4228,
302,
63,
1661,
29,
1960,
12,
3522,
63,
890,
29,
19,
12,
4228,
2196,
63,
929,
29,
12686,
395,
1362,
715,
395,
339,
661,
26822,
8842,
11728,
25519,
297,
267,
22706,
14,
26822,
8842,
11728,
25519,
8,
78,
63,
4608,
29,
1046,
12,
5131,
29,
16,
14,
17,
12,
8179,
302,
63,
1661,
29,
1400,
12,
3522,
63,
890,
29,
19,
12,
8179,
2196,
63,
929,
29,
12686,
395,
1362,
715,
395,
339,
661,
9581,
19190,
446,
24954,
8842,
43,
21190,
297,
267,
24954,
8842,
43,
21190,
8,
78,
63,
9170,
29,
78,
63,
4608,
12,
9561,
29,
17,
69,
13,
19,
12,
3522,
63,
890,
29,
1165,
12,
717,
1390,
63,
1661,
29,
1400,
12,
2196,
63,
929,
29,
12686,
395,
1362,
715,
395,
339,
661,
12666,
21916,
7323,
446,
481,
33,
297,
1362,
22706,
14,
12666,
13182,
8,
78,
63,
4608,
29,
78,
63,
4608,
12,
1390,
63,
1661,
29,
18,
395,
1362,
715,
395,
199,
61,
421,
199,
11490,
199,
3,
14794,
282,
2690,
402,
314,
1324,
666,
199,
199,
2798,
63,
25372,
480,
7147,
23903,
593,
317,
28350,
280,
21143,
401,
21143,
63,
20080,
1491,
78,
63,
4608,
566,
199,
199,
11490,
199,
3,
4226,
314,
27156,
436,
5137,
652,
199,
199,
509,
536,
12,
8943,
12,
8126,
315,
23155,
26,
272,
870,
480,
12147,
316,
314,
2746,
450,
68,
450,
83,
11500,
450,
334,
78,
63,
4608,
12,
536,
430,
272,
307,
16,
275,
900,
342,
272,
666,
275,
21143,
272,
340,
8126,
26,
267,
666,
275,
21143,
63,
20080,
272,
8943,
14,
3269,
8,
576,
9,
272,
3560,
63,
521,
275,
334,
521,
342,
446,
307,
16,
9,
272,
870,
480,
4456,
315,
450,
16,
14,
19,
2319,
2,
450,
3560,
63,
521,
9,
272,
340,
2688,
8,
8627,
12,
283,
4201,
63,
15660,
25865,
267,
7323,
63,
275,
8943,
14,
4201,
63,
15660,
63,
272,
587,
26,
267,
7323,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
trnewman/VT-USRP-daughterboard-drivers_python
|
gr-usrp/src/qa_usrp.py
|
1
|
1235
|
#!/usr/bin/env python
#
# Copyright 2005 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
# GNU Radio is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
# GNU Radio is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GNU Radio; see the file COPYING. If not, write to
# the Free Software Foundation, Inc., 51 Franklin Street,
# Boston, MA 02110-1301, USA.
#
from gnuradio import gr, gr_unittest
import usrp1
class qa_usrp (gr_unittest.TestCase):
def setUp (self):
self.fg = gr.flow_graph ()
def tearDown (self):
self.fg = None
def test_000_nop (self):
"""Just see if we can import the module...
They may not have a USRP connected, etc. Don't try to run anything"""
pass
if __name__ == '__main__':
gr_unittest.main ()
|
gpl-3.0
|
[
3381,
2647,
15,
1393,
15,
1813,
2366,
199,
3,
199,
3,
1898,
11811,
2868,
2290,
2752,
12,
3277,
14,
199,
3,
221,
199,
3,
961,
570,
365,
1777,
402,
1664,
13514,
199,
3,
221,
199,
3,
1664,
13514,
365,
2867,
2032,
27,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
652,
1334,
314,
2895,
402,
314,
1664,
1696,
1684,
844,
465,
3267,
701,
199,
3,
314,
2868,
2290,
2752,
27,
1902,
1015,
650,
12,
503,
334,
292,
2195,
945,
9,
199,
3,
1263,
2945,
1015,
14,
199,
3,
221,
199,
3,
1664,
13514,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
199,
3,
1664,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
221,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
1696,
1684,
844,
199,
3,
3180,
543,
1664,
13514,
27,
1937,
314,
570,
9685,
14,
221,
982,
440,
12,
2218,
370,
199,
3,
314,
2868,
2290,
2752,
12,
3277,
2020,
8026,
11236,
14259,
12,
199,
3,
8226,
12,
4828,
11315,
13,
10067,
12,
8217,
14,
199,
3,
9948,
199,
504,
24526,
492,
7192,
12,
7192,
63,
2796,
199,
646,
2739,
4599,
17,
199,
199,
533,
31879,
63,
2647,
80,
334,
2587,
63,
2796,
14,
1746,
304,
339,
347,
3613,
334,
277,
304,
267,
291,
14,
9681,
275,
7192,
14,
1659,
63,
2180,
6248,
339,
347,
6766,
334,
277,
304,
267,
291,
14,
9681,
275,
488,
339,
347,
511,
63,
1493,
63,
20443,
334,
277,
304,
267,
408,
22850,
1937,
340,
781,
883,
492,
314,
859,
1396,
267,
9322,
1443,
440,
1172,
282,
738,
32527,
8539,
12,
5423,
14,
221,
7529,
1133,
862,
370,
1255,
7003,
624,
267,
986,
1362,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
272,
7192,
63,
2796,
14,
973,
6248,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
2647,
15,
1393,
15,
1813,
2366,
199,
3,
199,
3,
1898,
11811,
2868,
2290,
2752,
12,
3277,
14,
199,
3,
221,
199,
3,
961,
570,
365,
1777,
402,
1664,
13514,
199,
3,
221,
199,
3,
1664,
13514,
365,
2867,
2032,
27,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
652,
1334,
314,
2895,
402,
314,
1664,
1696,
1684,
844,
465,
3267,
701,
199,
3,
314,
2868,
2290,
2752,
27,
1902,
1015,
650,
12,
503,
334,
292,
2195,
945,
9,
199,
3,
1263,
2945,
1015,
14,
199,
3,
221,
199,
3,
1664,
13514,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
199,
3,
1664,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
221,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
1696,
1684,
844,
199,
3,
3180,
543,
1664,
13514,
27,
1937,
314,
570,
9685,
14,
221,
982,
440,
12,
2218,
370,
199,
3,
314,
2868,
2290,
2752,
12,
3277,
2020,
8026,
11236,
14259,
12,
199,
3,
8226,
12,
4828,
11315,
13,
10067,
12,
8217,
14,
199,
3,
9948,
199,
504,
24526,
492,
7192,
12,
7192,
63,
2796,
199,
646,
2739,
4599,
17,
199,
199,
533,
31879,
63,
2647,
80,
334,
2587,
63,
2796,
14,
1746,
304,
339,
347,
3613,
334,
277,
304,
267,
291,
14,
9681,
275,
7192,
14,
1659,
63,
2180,
6248,
339,
347,
6766,
334,
277,
304,
267,
291,
14,
9681,
275,
488,
339,
347,
511,
63,
1493,
63,
20443,
334,
277,
304,
267,
408,
22850,
1937,
340,
781,
883,
492,
314,
859,
1396,
267,
9322,
1443,
440,
1172,
282,
738,
32527,
8539,
12,
5423,
14,
221,
7529,
1133,
862,
370,
1255,
7003,
624,
267,
986,
1362,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
272,
7192,
63,
2796,
14,
973,
6248,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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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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
] |
alexcrichton/gyp
|
pylib/gyp/MSVSSettings.py
|
437
|
43606
|
# 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.
"""Code to validate and convert settings of the Microsoft build tools.
This file contains code to validate and convert settings of the Microsoft
build tools. The function ConvertToMSBuildSettings(), ValidateMSVSSettings(),
and ValidateMSBuildSettings() are the entry points.
This file was created by comparing the projects created by Visual Studio 2008
and Visual Studio 2010 for all available settings through the user interface.
The MSBuild schemas were also considered. They are typically found in the
MSBuild install directory, e.g. c:\Program Files (x86)\MSBuild
"""
import sys
import re
# Dictionaries of settings validators. The key is the tool name, the value is
# a dictionary mapping setting names to validation functions.
_msvs_validators = {}
_msbuild_validators = {}
# A dictionary of settings converters. The key is the tool name, the value is
# a dictionary mapping setting names to conversion functions.
_msvs_to_msbuild_converters = {}
# Tool name mapping from MSVS to MSBuild.
_msbuild_name_of_tool = {}
class _Tool(object):
"""Represents a tool used by MSVS or MSBuild.
Attributes:
msvs_name: The name of the tool in MSVS.
msbuild_name: The name of the tool in MSBuild.
"""
def __init__(self, msvs_name, msbuild_name):
self.msvs_name = msvs_name
self.msbuild_name = msbuild_name
def _AddTool(tool):
"""Adds a tool to the four dictionaries used to process settings.
This only defines the tool. Each setting also needs to be added.
Args:
tool: The _Tool object to be added.
"""
_msvs_validators[tool.msvs_name] = {}
_msbuild_validators[tool.msbuild_name] = {}
_msvs_to_msbuild_converters[tool.msvs_name] = {}
_msbuild_name_of_tool[tool.msvs_name] = tool.msbuild_name
def _GetMSBuildToolSettings(msbuild_settings, tool):
"""Returns an MSBuild tool dictionary. Creates it if needed."""
return msbuild_settings.setdefault(tool.msbuild_name, {})
class _Type(object):
"""Type of settings (Base class)."""
def ValidateMSVS(self, value):
"""Verifies that the value is legal for MSVS.
Args:
value: the value to check for this type.
Raises:
ValueError if value is not valid for MSVS.
"""
def ValidateMSBuild(self, value):
"""Verifies that the value is legal for MSBuild.
Args:
value: the value to check for this type.
Raises:
ValueError if value is not valid for MSBuild.
"""
def ConvertToMSBuild(self, value):
"""Returns the MSBuild equivalent of the MSVS value given.
Args:
value: the MSVS value to convert.
Returns:
the MSBuild equivalent.
Raises:
ValueError if value is not valid.
"""
return value
class _String(_Type):
"""A setting that's just a string."""
def ValidateMSVS(self, value):
if not isinstance(value, basestring):
raise ValueError('expected string; got %r' % value)
def ValidateMSBuild(self, value):
if not isinstance(value, basestring):
raise ValueError('expected string; got %r' % value)
def ConvertToMSBuild(self, value):
# Convert the macros
return ConvertVCMacrosToMSBuild(value)
class _StringList(_Type):
"""A settings that's a list of strings."""
def ValidateMSVS(self, value):
if not isinstance(value, basestring) and not isinstance(value, list):
raise ValueError('expected string list; got %r' % value)
def ValidateMSBuild(self, value):
if not isinstance(value, basestring) and not isinstance(value, list):
raise ValueError('expected string list; got %r' % value)
def ConvertToMSBuild(self, value):
# Convert the macros
if isinstance(value, list):
return [ConvertVCMacrosToMSBuild(i) for i in value]
else:
return ConvertVCMacrosToMSBuild(value)
class _Boolean(_Type):
"""Boolean settings, can have the values 'false' or 'true'."""
def _Validate(self, value):
if value != 'true' and value != 'false':
raise ValueError('expected bool; got %r' % value)
def ValidateMSVS(self, value):
self._Validate(value)
def ValidateMSBuild(self, value):
self._Validate(value)
def ConvertToMSBuild(self, value):
self._Validate(value)
return value
class _Integer(_Type):
"""Integer settings."""
def __init__(self, msbuild_base=10):
_Type.__init__(self)
self._msbuild_base = msbuild_base
def ValidateMSVS(self, value):
# Try to convert, this will raise ValueError if invalid.
self.ConvertToMSBuild(value)
def ValidateMSBuild(self, value):
# Try to convert, this will raise ValueError if invalid.
int(value, self._msbuild_base)
def ConvertToMSBuild(self, value):
msbuild_format = (self._msbuild_base == 10) and '%d' or '0x%04x'
return msbuild_format % int(value)
class _Enumeration(_Type):
"""Type of settings that is an enumeration.
In MSVS, the values are indexes like '0', '1', and '2'.
MSBuild uses text labels that are more representative, like 'Win32'.
Constructor args:
label_list: an array of MSBuild labels that correspond to the MSVS index.
In the rare cases where MSVS has skipped an index value, None is
used in the array to indicate the unused spot.
new: an array of labels that are new to MSBuild.
"""
def __init__(self, label_list, new=None):
_Type.__init__(self)
self._label_list = label_list
self._msbuild_values = set(value for value in label_list
if value is not None)
if new is not None:
self._msbuild_values.update(new)
def ValidateMSVS(self, value):
# Try to convert. It will raise an exception if not valid.
self.ConvertToMSBuild(value)
def ValidateMSBuild(self, value):
if value not in self._msbuild_values:
raise ValueError('unrecognized enumerated value %s' % value)
def ConvertToMSBuild(self, value):
index = int(value)
if index < 0 or index >= len(self._label_list):
raise ValueError('index value (%d) not in expected range [0, %d)' %
(index, len(self._label_list)))
label = self._label_list[index]
if label is None:
raise ValueError('converted value for %s not specified.' % value)
return label
# Instantiate the various generic types.
_boolean = _Boolean()
_integer = _Integer()
# For now, we don't do any special validation on these types:
_string = _String()
_file_name = _String()
_folder_name = _String()
_file_list = _StringList()
_folder_list = _StringList()
_string_list = _StringList()
# Some boolean settings went from numerical values to boolean. The
# mapping is 0: default, 1: false, 2: true.
_newly_boolean = _Enumeration(['', 'false', 'true'])
def _Same(tool, name, setting_type):
"""Defines a setting that has the same name in MSVS and MSBuild.
Args:
tool: a dictionary that gives the names of the tool for MSVS and MSBuild.
name: the name of the setting.
setting_type: the type of this setting.
"""
_Renamed(tool, name, name, setting_type)
def _Renamed(tool, msvs_name, msbuild_name, setting_type):
"""Defines a setting for which the name has changed.
Args:
tool: a dictionary that gives the names of the tool for MSVS and MSBuild.
msvs_name: the name of the MSVS setting.
msbuild_name: the name of the MSBuild setting.
setting_type: the type of this setting.
"""
def _Translate(value, msbuild_settings):
msbuild_tool_settings = _GetMSBuildToolSettings(msbuild_settings, tool)
msbuild_tool_settings[msbuild_name] = setting_type.ConvertToMSBuild(value)
_msvs_validators[tool.msvs_name][msvs_name] = setting_type.ValidateMSVS
_msbuild_validators[tool.msbuild_name][msbuild_name] = (
setting_type.ValidateMSBuild)
_msvs_to_msbuild_converters[tool.msvs_name][msvs_name] = _Translate
def _Moved(tool, settings_name, msbuild_tool_name, setting_type):
_MovedAndRenamed(tool, settings_name, msbuild_tool_name, settings_name,
setting_type)
def _MovedAndRenamed(tool, msvs_settings_name, msbuild_tool_name,
msbuild_settings_name, setting_type):
"""Defines a setting that may have moved to a new section.
Args:
tool: a dictionary that gives the names of the tool for MSVS and MSBuild.
msvs_settings_name: the MSVS name of the setting.
msbuild_tool_name: the name of the MSBuild tool to place the setting under.
msbuild_settings_name: the MSBuild name of the setting.
setting_type: the type of this setting.
"""
def _Translate(value, msbuild_settings):
tool_settings = msbuild_settings.setdefault(msbuild_tool_name, {})
tool_settings[msbuild_settings_name] = setting_type.ConvertToMSBuild(value)
_msvs_validators[tool.msvs_name][msvs_settings_name] = (
setting_type.ValidateMSVS)
validator = setting_type.ValidateMSBuild
_msbuild_validators[msbuild_tool_name][msbuild_settings_name] = validator
_msvs_to_msbuild_converters[tool.msvs_name][msvs_settings_name] = _Translate
def _MSVSOnly(tool, name, setting_type):
"""Defines a setting that is only found in MSVS.
Args:
tool: a dictionary that gives the names of the tool for MSVS and MSBuild.
name: the name of the setting.
setting_type: the type of this setting.
"""
def _Translate(unused_value, unused_msbuild_settings):
# Since this is for MSVS only settings, no translation will happen.
pass
_msvs_validators[tool.msvs_name][name] = setting_type.ValidateMSVS
_msvs_to_msbuild_converters[tool.msvs_name][name] = _Translate
def _MSBuildOnly(tool, name, setting_type):
"""Defines a setting that is only found in MSBuild.
Args:
tool: a dictionary that gives the names of the tool for MSVS and MSBuild.
name: the name of the setting.
setting_type: the type of this setting.
"""
_msbuild_validators[tool.msbuild_name][name] = setting_type.ValidateMSBuild
def _ConvertedToAdditionalOption(tool, msvs_name, flag):
"""Defines a setting that's handled via a command line option in MSBuild.
Args:
tool: a dictionary that gives the names of the tool for MSVS and MSBuild.
msvs_name: the name of the MSVS setting that if 'true' becomes a flag
flag: the flag to insert at the end of the AdditionalOptions
"""
def _Translate(value, msbuild_settings):
if value == 'true':
tool_settings = _GetMSBuildToolSettings(msbuild_settings, tool)
if 'AdditionalOptions' in tool_settings:
new_flags = '%s %s' % (tool_settings['AdditionalOptions'], flag)
else:
new_flags = flag
tool_settings['AdditionalOptions'] = new_flags
_msvs_validators[tool.msvs_name][msvs_name] = _boolean.ValidateMSVS
_msvs_to_msbuild_converters[tool.msvs_name][msvs_name] = _Translate
def _CustomGeneratePreprocessedFile(tool, msvs_name):
def _Translate(value, msbuild_settings):
tool_settings = _GetMSBuildToolSettings(msbuild_settings, tool)
if value == '0':
tool_settings['PreprocessToFile'] = 'false'
tool_settings['PreprocessSuppressLineNumbers'] = 'false'
elif value == '1': # /P
tool_settings['PreprocessToFile'] = 'true'
tool_settings['PreprocessSuppressLineNumbers'] = 'false'
elif value == '2': # /EP /P
tool_settings['PreprocessToFile'] = 'true'
tool_settings['PreprocessSuppressLineNumbers'] = 'true'
else:
raise ValueError('value must be one of [0, 1, 2]; got %s' % value)
# Create a bogus validator that looks for '0', '1', or '2'
msvs_validator = _Enumeration(['a', 'b', 'c']).ValidateMSVS
_msvs_validators[tool.msvs_name][msvs_name] = msvs_validator
msbuild_validator = _boolean.ValidateMSBuild
msbuild_tool_validators = _msbuild_validators[tool.msbuild_name]
msbuild_tool_validators['PreprocessToFile'] = msbuild_validator
msbuild_tool_validators['PreprocessSuppressLineNumbers'] = msbuild_validator
_msvs_to_msbuild_converters[tool.msvs_name][msvs_name] = _Translate
fix_vc_macro_slashes_regex_list = ('IntDir', 'OutDir')
fix_vc_macro_slashes_regex = re.compile(
r'(\$\((?:%s)\))(?:[\\/]+)' % "|".join(fix_vc_macro_slashes_regex_list)
)
def FixVCMacroSlashes(s):
"""Replace macros which have excessive following slashes.
These macros are known to have a built-in trailing slash. Furthermore, many
scripts hiccup on processing paths with extra slashes in the middle.
This list is probably not exhaustive. Add as needed.
"""
if '$' in s:
s = fix_vc_macro_slashes_regex.sub(r'\1', s)
return s
def ConvertVCMacrosToMSBuild(s):
"""Convert the the MSVS macros found in the string to the MSBuild equivalent.
This list is probably not exhaustive. Add as needed.
"""
if '$' in s:
replace_map = {
'$(ConfigurationName)': '$(Configuration)',
'$(InputDir)': '%(RootDir)%(Directory)',
'$(InputExt)': '%(Extension)',
'$(InputFileName)': '%(Filename)%(Extension)',
'$(InputName)': '%(Filename)',
'$(InputPath)': '%(FullPath)',
'$(ParentName)': '$(ProjectFileName)',
'$(PlatformName)': '$(Platform)',
'$(SafeInputName)': '%(Filename)',
}
for old, new in replace_map.iteritems():
s = s.replace(old, new)
s = FixVCMacroSlashes(s)
return s
def ConvertToMSBuildSettings(msvs_settings, stderr=sys.stderr):
"""Converts MSVS settings (VS2008 and earlier) to MSBuild settings (VS2010+).
Args:
msvs_settings: A dictionary. The key is the tool name. The values are
themselves dictionaries of settings and their values.
stderr: The stream receiving the error messages.
Returns:
A dictionary of MSBuild settings. The key is either the MSBuild tool name
or the empty string (for the global settings). The values are themselves
dictionaries of settings and their values.
"""
msbuild_settings = {}
for msvs_tool_name, msvs_tool_settings in msvs_settings.iteritems():
if msvs_tool_name in _msvs_to_msbuild_converters:
msvs_tool = _msvs_to_msbuild_converters[msvs_tool_name]
for msvs_setting, msvs_value in msvs_tool_settings.iteritems():
if msvs_setting in msvs_tool:
# Invoke the translation function.
try:
msvs_tool[msvs_setting](msvs_value, msbuild_settings)
except ValueError, e:
print >> stderr, ('Warning: while converting %s/%s to MSBuild, '
'%s' % (msvs_tool_name, msvs_setting, e))
else:
# We don't know this setting. Give a warning.
print >> stderr, ('Warning: unrecognized setting %s/%s '
'while converting to MSBuild.' %
(msvs_tool_name, msvs_setting))
else:
print >> stderr, ('Warning: unrecognized tool %s while converting to '
'MSBuild.' % msvs_tool_name)
return msbuild_settings
def ValidateMSVSSettings(settings, stderr=sys.stderr):
"""Validates that the names of the settings are valid for MSVS.
Args:
settings: A dictionary. The key is the tool name. The values are
themselves dictionaries of settings and their values.
stderr: The stream receiving the error messages.
"""
_ValidateSettings(_msvs_validators, settings, stderr)
def ValidateMSBuildSettings(settings, stderr=sys.stderr):
"""Validates that the names of the settings are valid for MSBuild.
Args:
settings: A dictionary. The key is the tool name. The values are
themselves dictionaries of settings and their values.
stderr: The stream receiving the error messages.
"""
_ValidateSettings(_msbuild_validators, settings, stderr)
def _ValidateSettings(validators, settings, stderr):
"""Validates that the settings are valid for MSBuild or MSVS.
We currently only validate the names of the settings, not their values.
Args:
validators: A dictionary of tools and their validators.
settings: A dictionary. The key is the tool name. The values are
themselves dictionaries of settings and their values.
stderr: The stream receiving the error messages.
"""
for tool_name in settings:
if tool_name in validators:
tool_validators = validators[tool_name]
for setting, value in settings[tool_name].iteritems():
if setting in tool_validators:
try:
tool_validators[setting](value)
except ValueError, e:
print >> stderr, ('Warning: for %s/%s, %s' %
(tool_name, setting, e))
else:
print >> stderr, ('Warning: unrecognized setting %s/%s' %
(tool_name, setting))
else:
print >> stderr, ('Warning: unrecognized tool %s' % tool_name)
# MSVS and MBuild names of the tools.
_compile = _Tool('VCCLCompilerTool', 'ClCompile')
_link = _Tool('VCLinkerTool', 'Link')
_midl = _Tool('VCMIDLTool', 'Midl')
_rc = _Tool('VCResourceCompilerTool', 'ResourceCompile')
_lib = _Tool('VCLibrarianTool', 'Lib')
_manifest = _Tool('VCManifestTool', 'Manifest')
_AddTool(_compile)
_AddTool(_link)
_AddTool(_midl)
_AddTool(_rc)
_AddTool(_lib)
_AddTool(_manifest)
# Add sections only found in the MSBuild settings.
_msbuild_validators[''] = {}
_msbuild_validators['ProjectReference'] = {}
_msbuild_validators['ManifestResourceCompile'] = {}
# Descriptions of the compiler options, i.e. VCCLCompilerTool in MSVS and
# ClCompile in MSBuild.
# See "c:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\1033\cl.xml" for
# the schema of the MSBuild ClCompile settings.
# Options that have the same name in MSVS and MSBuild
_Same(_compile, 'AdditionalIncludeDirectories', _folder_list) # /I
_Same(_compile, 'AdditionalOptions', _string_list)
_Same(_compile, 'AdditionalUsingDirectories', _folder_list) # /AI
_Same(_compile, 'AssemblerListingLocation', _file_name) # /Fa
_Same(_compile, 'BrowseInformationFile', _file_name)
_Same(_compile, 'BufferSecurityCheck', _boolean) # /GS
_Same(_compile, 'DisableLanguageExtensions', _boolean) # /Za
_Same(_compile, 'DisableSpecificWarnings', _string_list) # /wd
_Same(_compile, 'EnableFiberSafeOptimizations', _boolean) # /GT
_Same(_compile, 'EnablePREfast', _boolean) # /analyze Visible='false'
_Same(_compile, 'ExpandAttributedSource', _boolean) # /Fx
_Same(_compile, 'FloatingPointExceptions', _boolean) # /fp:except
_Same(_compile, 'ForceConformanceInForLoopScope', _boolean) # /Zc:forScope
_Same(_compile, 'ForcedIncludeFiles', _file_list) # /FI
_Same(_compile, 'ForcedUsingFiles', _file_list) # /FU
_Same(_compile, 'GenerateXMLDocumentationFiles', _boolean) # /doc
_Same(_compile, 'IgnoreStandardIncludePath', _boolean) # /X
_Same(_compile, 'MinimalRebuild', _boolean) # /Gm
_Same(_compile, 'OmitDefaultLibName', _boolean) # /Zl
_Same(_compile, 'OmitFramePointers', _boolean) # /Oy
_Same(_compile, 'PreprocessorDefinitions', _string_list) # /D
_Same(_compile, 'ProgramDataBaseFileName', _file_name) # /Fd
_Same(_compile, 'RuntimeTypeInfo', _boolean) # /GR
_Same(_compile, 'ShowIncludes', _boolean) # /showIncludes
_Same(_compile, 'SmallerTypeCheck', _boolean) # /RTCc
_Same(_compile, 'StringPooling', _boolean) # /GF
_Same(_compile, 'SuppressStartupBanner', _boolean) # /nologo
_Same(_compile, 'TreatWChar_tAsBuiltInType', _boolean) # /Zc:wchar_t
_Same(_compile, 'UndefineAllPreprocessorDefinitions', _boolean) # /u
_Same(_compile, 'UndefinePreprocessorDefinitions', _string_list) # /U
_Same(_compile, 'UseFullPaths', _boolean) # /FC
_Same(_compile, 'WholeProgramOptimization', _boolean) # /GL
_Same(_compile, 'XMLDocumentationFileName', _file_name)
_Same(_compile, 'AssemblerOutput',
_Enumeration(['NoListing',
'AssemblyCode', # /FA
'All', # /FAcs
'AssemblyAndMachineCode', # /FAc
'AssemblyAndSourceCode'])) # /FAs
_Same(_compile, 'BasicRuntimeChecks',
_Enumeration(['Default',
'StackFrameRuntimeCheck', # /RTCs
'UninitializedLocalUsageCheck', # /RTCu
'EnableFastChecks'])) # /RTC1
_Same(_compile, 'BrowseInformation',
_Enumeration(['false',
'true', # /FR
'true'])) # /Fr
_Same(_compile, 'CallingConvention',
_Enumeration(['Cdecl', # /Gd
'FastCall', # /Gr
'StdCall'])) # /Gz
_Same(_compile, 'CompileAs',
_Enumeration(['Default',
'CompileAsC', # /TC
'CompileAsCpp'])) # /TP
_Same(_compile, 'DebugInformationFormat',
_Enumeration(['', # Disabled
'OldStyle', # /Z7
None,
'ProgramDatabase', # /Zi
'EditAndContinue'])) # /ZI
_Same(_compile, 'EnableEnhancedInstructionSet',
_Enumeration(['NotSet',
'StreamingSIMDExtensions', # /arch:SSE
'StreamingSIMDExtensions2'])) # /arch:SSE2
_Same(_compile, 'ErrorReporting',
_Enumeration(['None', # /errorReport:none
'Prompt', # /errorReport:prompt
'Queue'], # /errorReport:queue
new=['Send'])) # /errorReport:send"
_Same(_compile, 'ExceptionHandling',
_Enumeration(['false',
'Sync', # /EHsc
'Async'], # /EHa
new=['SyncCThrow'])) # /EHs
_Same(_compile, 'FavorSizeOrSpeed',
_Enumeration(['Neither',
'Speed', # /Ot
'Size'])) # /Os
_Same(_compile, 'FloatingPointModel',
_Enumeration(['Precise', # /fp:precise
'Strict', # /fp:strict
'Fast'])) # /fp:fast
_Same(_compile, 'InlineFunctionExpansion',
_Enumeration(['Default',
'OnlyExplicitInline', # /Ob1
'AnySuitable'], # /Ob2
new=['Disabled'])) # /Ob0
_Same(_compile, 'Optimization',
_Enumeration(['Disabled', # /Od
'MinSpace', # /O1
'MaxSpeed', # /O2
'Full'])) # /Ox
_Same(_compile, 'RuntimeLibrary',
_Enumeration(['MultiThreaded', # /MT
'MultiThreadedDebug', # /MTd
'MultiThreadedDLL', # /MD
'MultiThreadedDebugDLL'])) # /MDd
_Same(_compile, 'StructMemberAlignment',
_Enumeration(['Default',
'1Byte', # /Zp1
'2Bytes', # /Zp2
'4Bytes', # /Zp4
'8Bytes', # /Zp8
'16Bytes'])) # /Zp16
_Same(_compile, 'WarningLevel',
_Enumeration(['TurnOffAllWarnings', # /W0
'Level1', # /W1
'Level2', # /W2
'Level3', # /W3
'Level4'], # /W4
new=['EnableAllWarnings'])) # /Wall
# Options found in MSVS that have been renamed in MSBuild.
_Renamed(_compile, 'EnableFunctionLevelLinking', 'FunctionLevelLinking',
_boolean) # /Gy
_Renamed(_compile, 'EnableIntrinsicFunctions', 'IntrinsicFunctions',
_boolean) # /Oi
_Renamed(_compile, 'KeepComments', 'PreprocessKeepComments', _boolean) # /C
_Renamed(_compile, 'ObjectFile', 'ObjectFileName', _file_name) # /Fo
_Renamed(_compile, 'OpenMP', 'OpenMPSupport', _boolean) # /openmp
_Renamed(_compile, 'PrecompiledHeaderThrough', 'PrecompiledHeaderFile',
_file_name) # Used with /Yc and /Yu
_Renamed(_compile, 'PrecompiledHeaderFile', 'PrecompiledHeaderOutputFile',
_file_name) # /Fp
_Renamed(_compile, 'UsePrecompiledHeader', 'PrecompiledHeader',
_Enumeration(['NotUsing', # VS recognized '' for this value too.
'Create', # /Yc
'Use'])) # /Yu
_Renamed(_compile, 'WarnAsError', 'TreatWarningAsError', _boolean) # /WX
_ConvertedToAdditionalOption(_compile, 'DefaultCharIsUnsigned', '/J')
# MSVS options not found in MSBuild.
_MSVSOnly(_compile, 'Detect64BitPortabilityProblems', _boolean)
_MSVSOnly(_compile, 'UseUnicodeResponseFiles', _boolean)
# MSBuild options not found in MSVS.
_MSBuildOnly(_compile, 'BuildingInIDE', _boolean)
_MSBuildOnly(_compile, 'CompileAsManaged',
_Enumeration([], new=['false',
'true', # /clr
'Pure', # /clr:pure
'Safe', # /clr:safe
'OldSyntax'])) # /clr:oldSyntax
_MSBuildOnly(_compile, 'CreateHotpatchableImage', _boolean) # /hotpatch
_MSBuildOnly(_compile, 'MultiProcessorCompilation', _boolean) # /MP
_MSBuildOnly(_compile, 'PreprocessOutputPath', _string) # /Fi
_MSBuildOnly(_compile, 'ProcessorNumber', _integer) # the number of processors
_MSBuildOnly(_compile, 'TrackerLogDirectory', _folder_name)
_MSBuildOnly(_compile, 'TreatSpecificWarningsAsErrors', _string_list) # /we
_MSBuildOnly(_compile, 'UseUnicodeForAssemblerListing', _boolean) # /FAu
# Defines a setting that needs very customized processing
_CustomGeneratePreprocessedFile(_compile, 'GeneratePreprocessedFile')
# Directives for converting MSVS VCLinkerTool to MSBuild Link.
# See "c:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\1033\link.xml" for
# the schema of the MSBuild Link settings.
# Options that have the same name in MSVS and MSBuild
_Same(_link, 'AdditionalDependencies', _file_list)
_Same(_link, 'AdditionalLibraryDirectories', _folder_list) # /LIBPATH
# /MANIFESTDEPENDENCY:
_Same(_link, 'AdditionalManifestDependencies', _file_list)
_Same(_link, 'AdditionalOptions', _string_list)
_Same(_link, 'AddModuleNamesToAssembly', _file_list) # /ASSEMBLYMODULE
_Same(_link, 'AllowIsolation', _boolean) # /ALLOWISOLATION
_Same(_link, 'AssemblyLinkResource', _file_list) # /ASSEMBLYLINKRESOURCE
_Same(_link, 'BaseAddress', _string) # /BASE
_Same(_link, 'CLRUnmanagedCodeCheck', _boolean) # /CLRUNMANAGEDCODECHECK
_Same(_link, 'DelayLoadDLLs', _file_list) # /DELAYLOAD
_Same(_link, 'DelaySign', _boolean) # /DELAYSIGN
_Same(_link, 'EmbedManagedResourceFile', _file_list) # /ASSEMBLYRESOURCE
_Same(_link, 'EnableUAC', _boolean) # /MANIFESTUAC
_Same(_link, 'EntryPointSymbol', _string) # /ENTRY
_Same(_link, 'ForceSymbolReferences', _file_list) # /INCLUDE
_Same(_link, 'FunctionOrder', _file_name) # /ORDER
_Same(_link, 'GenerateDebugInformation', _boolean) # /DEBUG
_Same(_link, 'GenerateMapFile', _boolean) # /MAP
_Same(_link, 'HeapCommitSize', _string)
_Same(_link, 'HeapReserveSize', _string) # /HEAP
_Same(_link, 'IgnoreAllDefaultLibraries', _boolean) # /NODEFAULTLIB
_Same(_link, 'IgnoreEmbeddedIDL', _boolean) # /IGNOREIDL
_Same(_link, 'ImportLibrary', _file_name) # /IMPLIB
_Same(_link, 'KeyContainer', _file_name) # /KEYCONTAINER
_Same(_link, 'KeyFile', _file_name) # /KEYFILE
_Same(_link, 'ManifestFile', _file_name) # /ManifestFile
_Same(_link, 'MapExports', _boolean) # /MAPINFO:EXPORTS
_Same(_link, 'MapFileName', _file_name)
_Same(_link, 'MergedIDLBaseFileName', _file_name) # /IDLOUT
_Same(_link, 'MergeSections', _string) # /MERGE
_Same(_link, 'MidlCommandFile', _file_name) # /MIDL
_Same(_link, 'ModuleDefinitionFile', _file_name) # /DEF
_Same(_link, 'OutputFile', _file_name) # /OUT
_Same(_link, 'PerUserRedirection', _boolean)
_Same(_link, 'Profile', _boolean) # /PROFILE
_Same(_link, 'ProfileGuidedDatabase', _file_name) # /PGD
_Same(_link, 'ProgramDatabaseFile', _file_name) # /PDB
_Same(_link, 'RegisterOutput', _boolean)
_Same(_link, 'SetChecksum', _boolean) # /RELEASE
_Same(_link, 'StackCommitSize', _string)
_Same(_link, 'StackReserveSize', _string) # /STACK
_Same(_link, 'StripPrivateSymbols', _file_name) # /PDBSTRIPPED
_Same(_link, 'SupportUnloadOfDelayLoadedDLL', _boolean) # /DELAY:UNLOAD
_Same(_link, 'SuppressStartupBanner', _boolean) # /NOLOGO
_Same(_link, 'SwapRunFromCD', _boolean) # /SWAPRUN:CD
_Same(_link, 'TurnOffAssemblyGeneration', _boolean) # /NOASSEMBLY
_Same(_link, 'TypeLibraryFile', _file_name) # /TLBOUT
_Same(_link, 'TypeLibraryResourceID', _integer) # /TLBID
_Same(_link, 'UACUIAccess', _boolean) # /uiAccess='true'
_Same(_link, 'Version', _string) # /VERSION
_Same(_link, 'EnableCOMDATFolding', _newly_boolean) # /OPT:ICF
_Same(_link, 'FixedBaseAddress', _newly_boolean) # /FIXED
_Same(_link, 'LargeAddressAware', _newly_boolean) # /LARGEADDRESSAWARE
_Same(_link, 'OptimizeReferences', _newly_boolean) # /OPT:REF
_Same(_link, 'RandomizedBaseAddress', _newly_boolean) # /DYNAMICBASE
_Same(_link, 'TerminalServerAware', _newly_boolean) # /TSAWARE
_subsystem_enumeration = _Enumeration(
['NotSet',
'Console', # /SUBSYSTEM:CONSOLE
'Windows', # /SUBSYSTEM:WINDOWS
'Native', # /SUBSYSTEM:NATIVE
'EFI Application', # /SUBSYSTEM:EFI_APPLICATION
'EFI Boot Service Driver', # /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER
'EFI ROM', # /SUBSYSTEM:EFI_ROM
'EFI Runtime', # /SUBSYSTEM:EFI_RUNTIME_DRIVER
'WindowsCE'], # /SUBSYSTEM:WINDOWSCE
new=['POSIX']) # /SUBSYSTEM:POSIX
_target_machine_enumeration = _Enumeration(
['NotSet',
'MachineX86', # /MACHINE:X86
None,
'MachineARM', # /MACHINE:ARM
'MachineEBC', # /MACHINE:EBC
'MachineIA64', # /MACHINE:IA64
None,
'MachineMIPS', # /MACHINE:MIPS
'MachineMIPS16', # /MACHINE:MIPS16
'MachineMIPSFPU', # /MACHINE:MIPSFPU
'MachineMIPSFPU16', # /MACHINE:MIPSFPU16
None,
None,
None,
'MachineSH4', # /MACHINE:SH4
None,
'MachineTHUMB', # /MACHINE:THUMB
'MachineX64']) # /MACHINE:X64
_Same(_link, 'AssemblyDebug',
_Enumeration(['',
'true', # /ASSEMBLYDEBUG
'false'])) # /ASSEMBLYDEBUG:DISABLE
_Same(_link, 'CLRImageType',
_Enumeration(['Default',
'ForceIJWImage', # /CLRIMAGETYPE:IJW
'ForcePureILImage', # /Switch="CLRIMAGETYPE:PURE
'ForceSafeILImage'])) # /Switch="CLRIMAGETYPE:SAFE
_Same(_link, 'CLRThreadAttribute',
_Enumeration(['DefaultThreadingAttribute', # /CLRTHREADATTRIBUTE:NONE
'MTAThreadingAttribute', # /CLRTHREADATTRIBUTE:MTA
'STAThreadingAttribute'])) # /CLRTHREADATTRIBUTE:STA
_Same(_link, 'DataExecutionPrevention',
_Enumeration(['',
'false', # /NXCOMPAT:NO
'true'])) # /NXCOMPAT
_Same(_link, 'Driver',
_Enumeration(['NotSet',
'Driver', # /Driver
'UpOnly', # /DRIVER:UPONLY
'WDM'])) # /DRIVER:WDM
_Same(_link, 'LinkTimeCodeGeneration',
_Enumeration(['Default',
'UseLinkTimeCodeGeneration', # /LTCG
'PGInstrument', # /LTCG:PGInstrument
'PGOptimization', # /LTCG:PGOptimize
'PGUpdate'])) # /LTCG:PGUpdate
_Same(_link, 'ShowProgress',
_Enumeration(['NotSet',
'LinkVerbose', # /VERBOSE
'LinkVerboseLib'], # /VERBOSE:Lib
new=['LinkVerboseICF', # /VERBOSE:ICF
'LinkVerboseREF', # /VERBOSE:REF
'LinkVerboseSAFESEH', # /VERBOSE:SAFESEH
'LinkVerboseCLR'])) # /VERBOSE:CLR
_Same(_link, 'SubSystem', _subsystem_enumeration)
_Same(_link, 'TargetMachine', _target_machine_enumeration)
_Same(_link, 'UACExecutionLevel',
_Enumeration(['AsInvoker', # /level='asInvoker'
'HighestAvailable', # /level='highestAvailable'
'RequireAdministrator'])) # /level='requireAdministrator'
_Same(_link, 'MinimumRequiredVersion', _string)
_Same(_link, 'TreatLinkerWarningAsErrors', _boolean) # /WX
# Options found in MSVS that have been renamed in MSBuild.
_Renamed(_link, 'ErrorReporting', 'LinkErrorReporting',
_Enumeration(['NoErrorReport', # /ERRORREPORT:NONE
'PromptImmediately', # /ERRORREPORT:PROMPT
'QueueForNextLogin'], # /ERRORREPORT:QUEUE
new=['SendErrorReport'])) # /ERRORREPORT:SEND
_Renamed(_link, 'IgnoreDefaultLibraryNames', 'IgnoreSpecificDefaultLibraries',
_file_list) # /NODEFAULTLIB
_Renamed(_link, 'ResourceOnlyDLL', 'NoEntryPoint', _boolean) # /NOENTRY
_Renamed(_link, 'SwapRunFromNet', 'SwapRunFromNET', _boolean) # /SWAPRUN:NET
_Moved(_link, 'GenerateManifest', '', _boolean)
_Moved(_link, 'IgnoreImportLibrary', '', _boolean)
_Moved(_link, 'LinkIncremental', '', _newly_boolean)
_Moved(_link, 'LinkLibraryDependencies', 'ProjectReference', _boolean)
_Moved(_link, 'UseLibraryDependencyInputs', 'ProjectReference', _boolean)
# MSVS options not found in MSBuild.
_MSVSOnly(_link, 'OptimizeForWindows98', _newly_boolean)
_MSVSOnly(_link, 'UseUnicodeResponseFiles', _boolean)
# These settings generate correctly in the MSVS output files when using
# e.g. DelayLoadDLLs! or AdditionalDependencies! to exclude files from
# configuration entries, but result in spurious artifacts which can be
# safely ignored here. See crbug.com/246570
_MSVSOnly(_link, 'AdditionalLibraryDirectories_excluded', _folder_list)
_MSVSOnly(_link, 'DelayLoadDLLs_excluded', _file_list)
_MSVSOnly(_link, 'AdditionalDependencies_excluded', _file_list)
# MSBuild options not found in MSVS.
_MSBuildOnly(_link, 'BuildingInIDE', _boolean)
_MSBuildOnly(_link, 'ImageHasSafeExceptionHandlers', _boolean) # /SAFESEH
_MSBuildOnly(_link, 'LinkDLL', _boolean) # /DLL Visible='false'
_MSBuildOnly(_link, 'LinkStatus', _boolean) # /LTCG:STATUS
_MSBuildOnly(_link, 'PreventDllBinding', _boolean) # /ALLOWBIND
_MSBuildOnly(_link, 'SupportNobindOfDelayLoadedDLL', _boolean) # /DELAY:NOBIND
_MSBuildOnly(_link, 'TrackerLogDirectory', _folder_name)
_MSBuildOnly(_link, 'MSDOSStubFileName', _file_name) # /STUB Visible='false'
_MSBuildOnly(_link, 'SectionAlignment', _integer) # /ALIGN
_MSBuildOnly(_link, 'SpecifySectionAttributes', _string) # /SECTION
_MSBuildOnly(_link, 'ForceFileOutput',
_Enumeration([], new=['Enabled', # /FORCE
# /FORCE:MULTIPLE
'MultiplyDefinedSymbolOnly',
'UndefinedSymbolOnly'])) # /FORCE:UNRESOLVED
_MSBuildOnly(_link, 'CreateHotPatchableImage',
_Enumeration([], new=['Enabled', # /FUNCTIONPADMIN
'X86Image', # /FUNCTIONPADMIN:5
'X64Image', # /FUNCTIONPADMIN:6
'ItaniumImage'])) # /FUNCTIONPADMIN:16
_MSBuildOnly(_link, 'CLRSupportLastError',
_Enumeration([], new=['Enabled', # /CLRSupportLastError
'Disabled', # /CLRSupportLastError:NO
# /CLRSupportLastError:SYSTEMDLL
'SystemDlls']))
# Directives for converting VCResourceCompilerTool to ResourceCompile.
# See "c:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\1033\rc.xml" for
# the schema of the MSBuild ResourceCompile settings.
_Same(_rc, 'AdditionalOptions', _string_list)
_Same(_rc, 'AdditionalIncludeDirectories', _folder_list) # /I
_Same(_rc, 'Culture', _Integer(msbuild_base=16))
_Same(_rc, 'IgnoreStandardIncludePath', _boolean) # /X
_Same(_rc, 'PreprocessorDefinitions', _string_list) # /D
_Same(_rc, 'ResourceOutputFileName', _string) # /fo
_Same(_rc, 'ShowProgress', _boolean) # /v
# There is no UI in VisualStudio 2008 to set the following properties.
# However they are found in CL and other tools. Include them here for
# completeness, as they are very likely to have the same usage pattern.
_Same(_rc, 'SuppressStartupBanner', _boolean) # /nologo
_Same(_rc, 'UndefinePreprocessorDefinitions', _string_list) # /u
# MSBuild options not found in MSVS.
_MSBuildOnly(_rc, 'NullTerminateStrings', _boolean) # /n
_MSBuildOnly(_rc, 'TrackerLogDirectory', _folder_name)
# Directives for converting VCMIDLTool to Midl.
# See "c:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\1033\midl.xml" for
# the schema of the MSBuild Midl settings.
_Same(_midl, 'AdditionalIncludeDirectories', _folder_list) # /I
_Same(_midl, 'AdditionalOptions', _string_list)
_Same(_midl, 'CPreprocessOptions', _string) # /cpp_opt
_Same(_midl, 'ErrorCheckAllocations', _boolean) # /error allocation
_Same(_midl, 'ErrorCheckBounds', _boolean) # /error bounds_check
_Same(_midl, 'ErrorCheckEnumRange', _boolean) # /error enum
_Same(_midl, 'ErrorCheckRefPointers', _boolean) # /error ref
_Same(_midl, 'ErrorCheckStubData', _boolean) # /error stub_data
_Same(_midl, 'GenerateStublessProxies', _boolean) # /Oicf
_Same(_midl, 'GenerateTypeLibrary', _boolean)
_Same(_midl, 'HeaderFileName', _file_name) # /h
_Same(_midl, 'IgnoreStandardIncludePath', _boolean) # /no_def_idir
_Same(_midl, 'InterfaceIdentifierFileName', _file_name) # /iid
_Same(_midl, 'MkTypLibCompatible', _boolean) # /mktyplib203
_Same(_midl, 'OutputDirectory', _string) # /out
_Same(_midl, 'PreprocessorDefinitions', _string_list) # /D
_Same(_midl, 'ProxyFileName', _file_name) # /proxy
_Same(_midl, 'RedirectOutputAndErrors', _file_name) # /o
_Same(_midl, 'SuppressStartupBanner', _boolean) # /nologo
_Same(_midl, 'TypeLibraryName', _file_name) # /tlb
_Same(_midl, 'UndefinePreprocessorDefinitions', _string_list) # /U
_Same(_midl, 'WarnAsError', _boolean) # /WX
_Same(_midl, 'DefaultCharType',
_Enumeration(['Unsigned', # /char unsigned
'Signed', # /char signed
'Ascii'])) # /char ascii7
_Same(_midl, 'TargetEnvironment',
_Enumeration(['NotSet',
'Win32', # /env win32
'Itanium', # /env ia64
'X64'])) # /env x64
_Same(_midl, 'EnableErrorChecks',
_Enumeration(['EnableCustom',
'None', # /error none
'All'])) # /error all
_Same(_midl, 'StructMemberAlignment',
_Enumeration(['NotSet',
'1', # Zp1
'2', # Zp2
'4', # Zp4
'8'])) # Zp8
_Same(_midl, 'WarningLevel',
_Enumeration(['0', # /W0
'1', # /W1
'2', # /W2
'3', # /W3
'4'])) # /W4
_Renamed(_midl, 'DLLDataFileName', 'DllDataFileName', _file_name) # /dlldata
_Renamed(_midl, 'ValidateParameters', 'ValidateAllParameters',
_boolean) # /robust
# MSBuild options not found in MSVS.
_MSBuildOnly(_midl, 'ApplicationConfigurationMode', _boolean) # /app_config
_MSBuildOnly(_midl, 'ClientStubFile', _file_name) # /cstub
_MSBuildOnly(_midl, 'GenerateClientFiles',
_Enumeration([], new=['Stub', # /client stub
'None'])) # /client none
_MSBuildOnly(_midl, 'GenerateServerFiles',
_Enumeration([], new=['Stub', # /client stub
'None'])) # /client none
_MSBuildOnly(_midl, 'LocaleID', _integer) # /lcid DECIMAL
_MSBuildOnly(_midl, 'ServerStubFile', _file_name) # /sstub
_MSBuildOnly(_midl, 'SuppressCompilerWarnings', _boolean) # /no_warn
_MSBuildOnly(_midl, 'TrackerLogDirectory', _folder_name)
_MSBuildOnly(_midl, 'TypeLibFormat',
_Enumeration([], new=['NewFormat', # /newtlb
'OldFormat'])) # /oldtlb
# Directives for converting VCLibrarianTool to Lib.
# See "c:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\1033\lib.xml" for
# the schema of the MSBuild Lib settings.
_Same(_lib, 'AdditionalDependencies', _file_list)
_Same(_lib, 'AdditionalLibraryDirectories', _folder_list) # /LIBPATH
_Same(_lib, 'AdditionalOptions', _string_list)
_Same(_lib, 'ExportNamedFunctions', _string_list) # /EXPORT
_Same(_lib, 'ForceSymbolReferences', _string) # /INCLUDE
_Same(_lib, 'IgnoreAllDefaultLibraries', _boolean) # /NODEFAULTLIB
_Same(_lib, 'IgnoreSpecificDefaultLibraries', _file_list) # /NODEFAULTLIB
_Same(_lib, 'ModuleDefinitionFile', _file_name) # /DEF
_Same(_lib, 'OutputFile', _file_name) # /OUT
_Same(_lib, 'SuppressStartupBanner', _boolean) # /NOLOGO
_Same(_lib, 'UseUnicodeResponseFiles', _boolean)
_Same(_lib, 'LinkTimeCodeGeneration', _boolean) # /LTCG
_Same(_lib, 'TargetMachine', _target_machine_enumeration)
# TODO(jeanluc) _link defines the same value that gets moved to
# ProjectReference. We may want to validate that they are consistent.
_Moved(_lib, 'LinkLibraryDependencies', 'ProjectReference', _boolean)
# TODO(jeanluc) I don't think these are genuine settings but byproducts of Gyp.
_MSVSOnly(_lib, 'AdditionalLibraryDirectories_excluded', _folder_list)
_MSBuildOnly(_lib, 'DisplayLibrary', _string) # /LIST Visible='false'
_MSBuildOnly(_lib, 'ErrorReporting',
_Enumeration([], new=['PromptImmediately', # /ERRORREPORT:PROMPT
'QueueForNextLogin', # /ERRORREPORT:QUEUE
'SendErrorReport', # /ERRORREPORT:SEND
'NoErrorReport'])) # /ERRORREPORT:NONE
_MSBuildOnly(_lib, 'MinimumRequiredVersion', _string)
_MSBuildOnly(_lib, 'Name', _file_name) # /NAME
_MSBuildOnly(_lib, 'RemoveObjects', _file_list) # /REMOVE
_MSBuildOnly(_lib, 'SubSystem', _subsystem_enumeration)
_MSBuildOnly(_lib, 'TrackerLogDirectory', _folder_name)
_MSBuildOnly(_lib, 'TreatLibWarningAsErrors', _boolean) # /WX
_MSBuildOnly(_lib, 'Verbose', _boolean)
# Directives for converting VCManifestTool to Mt.
# See "c:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\1033\mt.xml" for
# the schema of the MSBuild Lib settings.
# Options that have the same name in MSVS and MSBuild
_Same(_manifest, 'AdditionalManifestFiles', _file_list) # /manifest
_Same(_manifest, 'AdditionalOptions', _string_list)
_Same(_manifest, 'AssemblyIdentity', _string) # /identity:
_Same(_manifest, 'ComponentFileName', _file_name) # /dll
_Same(_manifest, 'GenerateCatalogFiles', _boolean) # /makecdfs
_Same(_manifest, 'InputResourceManifests', _string) # /inputresource
_Same(_manifest, 'OutputManifestFile', _file_name) # /out
_Same(_manifest, 'RegistrarScriptFile', _file_name) # /rgs
_Same(_manifest, 'ReplacementsFile', _file_name) # /replacements
_Same(_manifest, 'SuppressStartupBanner', _boolean) # /nologo
_Same(_manifest, 'TypeLibraryFile', _file_name) # /tlb:
_Same(_manifest, 'UpdateFileHashes', _boolean) # /hashupdate
_Same(_manifest, 'UpdateFileHashesSearchPath', _file_name)
_Same(_manifest, 'VerboseOutput', _boolean) # /verbose
# Options that have moved location.
_MovedAndRenamed(_manifest, 'ManifestResourceFile',
'ManifestResourceCompile',
'ResourceOutputFileName',
_file_name)
_Moved(_manifest, 'EmbedManifest', '', _boolean)
# MSVS options not found in MSBuild.
_MSVSOnly(_manifest, 'DependencyInformationFile', _file_name)
_MSVSOnly(_manifest, 'UseFAT32Workaround', _boolean)
_MSVSOnly(_manifest, 'UseUnicodeResponseFiles', _boolean)
# MSBuild options not found in MSVS.
_MSBuildOnly(_manifest, 'EnableDPIAwareness', _boolean)
_MSBuildOnly(_manifest, 'GenerateCategoryTags', _boolean) # /category
_MSBuildOnly(_manifest, 'ManifestFromManagedAssembly',
_file_name) # /managedassemblyname
_MSBuildOnly(_manifest, 'OutputResourceManifests', _string) # /outputresource
_MSBuildOnly(_manifest, 'SuppressDependencyElement', _boolean) # /nodependency
_MSBuildOnly(_manifest, 'TrackerLogDirectory', _folder_name)
|
bsd-3-clause
|
[
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,
3034,
370,
4107,
436,
3957,
2202,
402,
314,
15332,
1900,
7249,
14,
199,
199,
2765,
570,
3509,
1233,
370,
4107,
436,
3957,
2202,
402,
314,
15332,
199,
1506,
7249,
14,
221,
710,
805,
7905,
28361,
5268,
1062,
12134,
14206,
5268,
1062,
199,
460,
12134,
10733,
5268,
342,
787,
314,
2397,
4501,
14,
199,
199,
2765,
570,
1990,
2737,
701,
20234,
314,
11336,
2737,
701,
14702,
13225,
9079,
199,
460,
14702,
13225,
7129,
367,
1006,
2808,
2202,
4012,
314,
922,
3217,
14,
199,
1918,
21374,
32536,
4898,
2597,
8652,
14,
221,
9322,
787,
13609,
1911,
315,
314,
199,
10733,
3907,
2082,
12,
325,
14,
71,
14,
286,
3427,
9184,
16920,
334,
88,
1184,
2862,
10733,
199,
624,
199,
199,
646,
984,
199,
646,
295,
199,
199,
3,
3757,
10150,
402,
2202,
14370,
14,
710,
790,
365,
314,
4744,
536,
12,
314,
574,
365,
199,
3,
282,
2600,
4412,
4260,
1561,
370,
6411,
3423,
14,
199,
63,
8338,
63,
11346,
275,
1052,
199,
63,
14087,
63,
11346,
275,
1052,
421,
199,
3,
437,
2600,
402,
2202,
23172,
14,
710,
790,
365,
314,
4744,
536,
12,
314,
574,
365,
199,
3,
282,
2600,
4412,
4260,
1561,
370,
8603,
3423,
14,
199,
63,
8338,
63,
475,
63,
14087,
63,
17911,
275,
1052,
421,
199,
3,
15650,
536,
4412,
687,
13828,
370,
21374,
14,
199,
63,
14087,
63,
354,
63,
1618,
63,
3557,
275,
1052,
421,
199,
533,
485,
5157,
8,
785,
304,
523,
408,
18089,
282,
4744,
1202,
701,
13828,
503,
21374,
14,
819,
9382,
26,
489,
13795,
63,
354,
26,
710,
536,
402,
314,
4744,
315,
13828,
14,
489,
14835,
63,
354,
26,
710,
536,
402,
314,
4744,
315,
21374,
14,
523,
408,
819,
347,
636,
826,
721,
277,
12,
13795,
63,
354,
12,
14835,
63,
354,
304,
272,
291,
14,
8338,
63,
354,
275,
13795,
63,
354,
272,
291,
14,
14087,
63,
354,
275,
14835,
63,
354,
421,
199,
318,
485,
1123,
5157,
8,
3557,
304,
523,
408,
14995,
282,
4744,
370,
314,
11648,
11196,
1202,
370,
2112,
2202,
14,
819,
961,
1454,
7890,
314,
4744,
14,
221,
7048,
4260,
2597,
4839,
370,
506,
3483,
14,
819,
3033,
26,
272,
4744,
26,
710,
485,
5157,
909,
370,
506,
3483,
14,
523,
408,
523,
485,
8338,
63,
11346,
59,
3557,
14,
8338,
63,
354,
61,
275,
1052,
523,
485,
14087,
63,
11346,
59,
3557,
14,
14087,
63,
354,
61,
275,
1052,
523,
485,
8338,
63,
475,
63,
14087,
63,
17911,
59,
3557,
14,
8338,
63,
354,
61,
275,
1052,
523,
485,
14087,
63,
354,
63,
1618,
63,
3557,
59,
3557,
14,
8338,
63,
354,
61,
275,
4744,
14,
14087,
63,
354,
421,
199,
318,
485,
26772,
5157,
5268,
8,
14087,
63,
1751,
12,
4744,
304,
523,
408,
3407,
376,
21374,
4744,
2600,
14,
221,
10560,
652,
340,
4346,
1041,
523,
372,
14835,
63,
1751,
14,
5486,
8,
3557,
14,
14087,
63,
354,
12,
5009,
421,
199,
533,
485,
804,
8,
785,
304,
523,
408,
804,
402,
2202,
334,
1563,
1021,
10477,
819,
347,
12134,
14206,
8,
277,
12,
574,
304,
272,
408,
21168,
626,
314,
574,
365,
18393,
367,
13828,
14,
339,
3033,
26,
489,
574,
26,
314,
574,
370,
1104,
367,
642,
730,
14,
339,
6218,
26,
489,
1722,
340,
574,
365,
440,
1686,
367,
13828,
14,
272,
408,
819,
347,
12134,
10733,
8,
277,
12,
574,
304,
272,
408,
21168,
626,
314,
574,
365,
18393,
367,
21374,
14,
339,
3033,
26,
489,
574,
26,
314,
574,
370,
1104,
367,
642,
730,
14,
339,
6218,
26,
489,
1722,
340,
574,
365,
440,
1686,
367,
21374,
14,
272,
408,
819,
347,
7905,
28361,
8,
277,
12,
574,
304,
272,
408,
3407,
314,
21374,
7353,
402,
314,
13828,
574,
1627,
14,
339,
3033,
26,
489,
574,
26,
314,
13828,
574,
370,
3957,
14,
339,
1803,
26,
489,
314,
21374,
7353,
14,
339,
6218,
26,
489,
1722,
340,
574,
365,
440,
1686,
14,
272,
408,
272,
372,
574,
421,
199,
533,
485,
1558,
1547,
804,
304,
523,
408,
33,
4260,
626,
1159,
2951,
282,
1059,
1041,
819,
347,
12134,
14206,
8,
277,
12,
574,
304,
272,
340,
440,
1228,
8,
585,
12,
7116,
304,
489,
746,
1722,
360,
2062,
1059,
27,
4788,
450,
82,
7,
450,
574,
9,
819,
347,
12134,
10733,
8,
277,
12,
574,
304,
272,
340,
440,
1228,
8,
585,
12,
7116,
304,
489,
746,
1722,
360,
2062,
1059,
27,
4788,
450,
82,
7,
450,
574,
9,
819,
347,
7905,
28361,
8,
277,
12,
574,
304,
272,
327,
7905,
314,
16954,
272,
372,
7905,
9454,
25402,
28361,
8,
585,
9,
421,
199,
533,
485,
32216,
1547,
804,
304,
523,
408,
33,
2202,
626,
1159,
282,
769,
402,
3326,
1041,
819,
347,
12134,
14206,
8,
277,
12,
574,
304,
272,
340,
440,
1228,
8,
585,
12,
7116,
9,
436,
440,
1228,
8,
585,
12,
769,
304,
489,
746,
1722,
360,
2062,
1059,
769,
27,
4788,
450,
82,
7,
450,
574,
9,
819,
347,
12134,
10733,
8,
277,
12,
574,
304,
272,
340,
440,
1228,
8,
585,
12,
7116,
9,
436,
440,
1228,
8,
585,
12,
769,
304,
489,
746,
1722,
360,
2062,
1059,
769,
27,
4788,
450,
82,
7,
450,
574,
9,
819,
347,
7905,
28361,
8,
277,
12,
574,
304,
272,
327,
7905,
314,
16954,
272,
340,
1228,
8,
585,
12,
769,
304,
489,
372,
359,
7306,
9454,
25402,
28361,
8,
73,
9,
367,
284,
315,
574,
61,
272,
587,
26,
489,
372,
7905,
9454,
25402,
28361,
8,
585,
9,
421,
199,
533,
485,
4082,
1547,
804,
304,
523,
408,
4082,
2202,
12,
883,
1172,
314,
1338,
283,
3910,
7,
503,
283,
2052,
23690,
819,
347,
485,
12584,
8,
277,
12,
574,
304,
272,
340,
574,
1137,
283,
2052,
7,
436,
574,
1137,
283,
3910,
356,
489,
746,
1722,
360,
2062,
2155,
27,
4788,
450,
82,
7,
450,
574,
9,
819,
347,
12134,
14206,
8,
277,
12,
574,
304,
272,
291,
423,
12584,
8
] |
[
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,
3034,
370,
4107,
436,
3957,
2202,
402,
314,
15332,
1900,
7249,
14,
199,
199,
2765,
570,
3509,
1233,
370,
4107,
436,
3957,
2202,
402,
314,
15332,
199,
1506,
7249,
14,
221,
710,
805,
7905,
28361,
5268,
1062,
12134,
14206,
5268,
1062,
199,
460,
12134,
10733,
5268,
342,
787,
314,
2397,
4501,
14,
199,
199,
2765,
570,
1990,
2737,
701,
20234,
314,
11336,
2737,
701,
14702,
13225,
9079,
199,
460,
14702,
13225,
7129,
367,
1006,
2808,
2202,
4012,
314,
922,
3217,
14,
199,
1918,
21374,
32536,
4898,
2597,
8652,
14,
221,
9322,
787,
13609,
1911,
315,
314,
199,
10733,
3907,
2082,
12,
325,
14,
71,
14,
286,
3427,
9184,
16920,
334,
88,
1184,
2862,
10733,
199,
624,
199,
199,
646,
984,
199,
646,
295,
199,
199,
3,
3757,
10150,
402,
2202,
14370,
14,
710,
790,
365,
314,
4744,
536,
12,
314,
574,
365,
199,
3,
282,
2600,
4412,
4260,
1561,
370,
6411,
3423,
14,
199,
63,
8338,
63,
11346,
275,
1052,
199,
63,
14087,
63,
11346,
275,
1052,
421,
199,
3,
437,
2600,
402,
2202,
23172,
14,
710,
790,
365,
314,
4744,
536,
12,
314,
574,
365,
199,
3,
282,
2600,
4412,
4260,
1561,
370,
8603,
3423,
14,
199,
63,
8338,
63,
475,
63,
14087,
63,
17911,
275,
1052,
421,
199,
3,
15650,
536,
4412,
687,
13828,
370,
21374,
14,
199,
63,
14087,
63,
354,
63,
1618,
63,
3557,
275,
1052,
421,
199,
533,
485,
5157,
8,
785,
304,
523,
408,
18089,
282,
4744,
1202,
701,
13828,
503,
21374,
14,
819,
9382,
26,
489,
13795,
63,
354,
26,
710,
536,
402,
314,
4744,
315,
13828,
14,
489,
14835,
63,
354,
26,
710,
536,
402,
314,
4744,
315,
21374,
14,
523,
408,
819,
347,
636,
826,
721,
277,
12,
13795,
63,
354,
12,
14835,
63,
354,
304,
272,
291,
14,
8338,
63,
354,
275,
13795,
63,
354,
272,
291,
14,
14087,
63,
354,
275,
14835,
63,
354,
421,
199,
318,
485,
1123,
5157,
8,
3557,
304,
523,
408,
14995,
282,
4744,
370,
314,
11648,
11196,
1202,
370,
2112,
2202,
14,
819,
961,
1454,
7890,
314,
4744,
14,
221,
7048,
4260,
2597,
4839,
370,
506,
3483,
14,
819,
3033,
26,
272,
4744,
26,
710,
485,
5157,
909,
370,
506,
3483,
14,
523,
408,
523,
485,
8338,
63,
11346,
59,
3557,
14,
8338,
63,
354,
61,
275,
1052,
523,
485,
14087,
63,
11346,
59,
3557,
14,
14087,
63,
354,
61,
275,
1052,
523,
485,
8338,
63,
475,
63,
14087,
63,
17911,
59,
3557,
14,
8338,
63,
354,
61,
275,
1052,
523,
485,
14087,
63,
354,
63,
1618,
63,
3557,
59,
3557,
14,
8338,
63,
354,
61,
275,
4744,
14,
14087,
63,
354,
421,
199,
318,
485,
26772,
5157,
5268,
8,
14087,
63,
1751,
12,
4744,
304,
523,
408,
3407,
376,
21374,
4744,
2600,
14,
221,
10560,
652,
340,
4346,
1041,
523,
372,
14835,
63,
1751,
14,
5486,
8,
3557,
14,
14087,
63,
354,
12,
5009,
421,
199,
533,
485,
804,
8,
785,
304,
523,
408,
804,
402,
2202,
334,
1563,
1021,
10477,
819,
347,
12134,
14206,
8,
277,
12,
574,
304,
272,
408,
21168,
626,
314,
574,
365,
18393,
367,
13828,
14,
339,
3033,
26,
489,
574,
26,
314,
574,
370,
1104,
367,
642,
730,
14,
339,
6218,
26,
489,
1722,
340,
574,
365,
440,
1686,
367,
13828,
14,
272,
408,
819,
347,
12134,
10733,
8,
277,
12,
574,
304,
272,
408,
21168,
626,
314,
574,
365,
18393,
367,
21374,
14,
339,
3033,
26,
489,
574,
26,
314,
574,
370,
1104,
367,
642,
730,
14,
339,
6218,
26,
489,
1722,
340,
574,
365,
440,
1686,
367,
21374,
14,
272,
408,
819,
347,
7905,
28361,
8,
277,
12,
574,
304,
272,
408,
3407,
314,
21374,
7353,
402,
314,
13828,
574,
1627,
14,
339,
3033,
26,
489,
574,
26,
314,
13828,
574,
370,
3957,
14,
339,
1803,
26,
489,
314,
21374,
7353,
14,
339,
6218,
26,
489,
1722,
340,
574,
365,
440,
1686,
14,
272,
408,
272,
372,
574,
421,
199,
533,
485,
1558,
1547,
804,
304,
523,
408,
33,
4260,
626,
1159,
2951,
282,
1059,
1041,
819,
347,
12134,
14206,
8,
277,
12,
574,
304,
272,
340,
440,
1228,
8,
585,
12,
7116,
304,
489,
746,
1722,
360,
2062,
1059,
27,
4788,
450,
82,
7,
450,
574,
9,
819,
347,
12134,
10733,
8,
277,
12,
574,
304,
272,
340,
440,
1228,
8,
585,
12,
7116,
304,
489,
746,
1722,
360,
2062,
1059,
27,
4788,
450,
82,
7,
450,
574,
9,
819,
347,
7905,
28361,
8,
277,
12,
574,
304,
272,
327,
7905,
314,
16954,
272,
372,
7905,
9454,
25402,
28361,
8,
585,
9,
421,
199,
533,
485,
32216,
1547,
804,
304,
523,
408,
33,
2202,
626,
1159,
282,
769,
402,
3326,
1041,
819,
347,
12134,
14206,
8,
277,
12,
574,
304,
272,
340,
440,
1228,
8,
585,
12,
7116,
9,
436,
440,
1228,
8,
585,
12,
769,
304,
489,
746,
1722,
360,
2062,
1059,
769,
27,
4788,
450,
82,
7,
450,
574,
9,
819,
347,
12134,
10733,
8,
277,
12,
574,
304,
272,
340,
440,
1228,
8,
585,
12,
7116,
9,
436,
440,
1228,
8,
585,
12,
769,
304,
489,
746,
1722,
360,
2062,
1059,
769,
27,
4788,
450,
82,
7,
450,
574,
9,
819,
347,
7905,
28361,
8,
277,
12,
574,
304,
272,
327,
7905,
314,
16954,
272,
340,
1228,
8,
585,
12,
769,
304,
489,
372,
359,
7306,
9454,
25402,
28361,
8,
73,
9,
367,
284,
315,
574,
61,
272,
587,
26,
489,
372,
7905,
9454,
25402,
28361,
8,
585,
9,
421,
199,
533,
485,
4082,
1547,
804,
304,
523,
408,
4082,
2202,
12,
883,
1172,
314,
1338,
283,
3910,
7,
503,
283,
2052,
23690,
819,
347,
485,
12584,
8,
277,
12,
574,
304,
272,
340,
574,
1137,
283,
2052,
7,
436,
574,
1137,
283,
3910,
356,
489,
746,
1722,
360,
2062,
2155,
27,
4788,
450,
82,
7,
450,
574,
9,
819,
347,
12134,
14206,
8,
277,
12,
574,
304,
272,
291,
423,
12584,
8,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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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
] |
cgimenop/Excel2Testlink
|
ExcelParser/lib/openpyxl/utils/tests/test_indexed_list.py
|
2
|
1046
|
import pytest
@pytest.fixture
def list():
from ..indexed_list import IndexedList
return IndexedList
def test_ctor(list):
l = list(['b', 'a'])
assert l == ['b', 'a']
assert l.clean is False
def test_allow_duplicate_ctor(list):
l = list(['b', 'a', 'b'])
assert l == ['b', 'a', 'b']
l.append('a')
assert l == ['b', 'a', 'b']
def test_function(list):
l = list()
l.append('b')
l.append('a')
assert l == ['b', 'a']
def test_contains(list):
l = list(['a', 'b', 'a'])
assert l.clean is False
assert 'a' in l
assert l.clean is True
def test_index(list):
l = list(['a', 'b'])
l.append('a')
assert l == ['a', 'b']
l.append('c')
assert l.index('c') == 2
assert l.clean is True
def test_table_builder(list):
sb = list()
result = {'a':0, 'b':1, 'c':2, 'd':3}
for letter in sorted(result.keys()):
for x in range(5):
sb.append(letter)
assert sb.index(letter) == result[letter]
assert sb == ['a', 'b', 'c', 'd']
|
mit
|
[
646,
4613,
421,
199,
32,
4462,
14,
5997,
199,
318,
769,
837,
272,
687,
2508,
16821,
63,
513,
492,
26437,
1296,
272,
372,
26437,
1296,
421,
199,
318,
511,
63,
630,
8,
513,
304,
272,
634,
275,
769,
2941,
66,
297,
283,
65,
1105,
272,
702,
634,
508,
788,
66,
297,
283,
65,
418,
272,
702,
634,
14,
3118,
365,
756,
421,
199,
318,
511,
63,
3306,
63,
11081,
63,
630,
8,
513,
304,
272,
634,
275,
769,
2941,
66,
297,
283,
65,
297,
283,
66,
1105,
272,
702,
634,
508,
788,
66,
297,
283,
65,
297,
283,
66,
418,
272,
634,
14,
740,
360,
65,
358,
272,
702,
634,
508,
788,
66,
297,
283,
65,
297,
283,
66,
418,
421,
199,
318,
511,
63,
1593,
8,
513,
304,
272,
634,
275,
769,
342,
272,
634,
14,
740,
360,
66,
358,
272,
634,
14,
740,
360,
65,
358,
272,
702,
634,
508,
788,
66,
297,
283,
65,
418,
421,
199,
318,
511,
63,
6134,
8,
513,
304,
272,
634,
275,
769,
2941,
65,
297,
283,
66,
297,
283,
65,
1105,
272,
702,
634,
14,
3118,
365,
756,
272,
702,
283,
65,
7,
315,
634,
272,
702,
634,
14,
3118,
365,
715,
421,
199,
318,
511,
63,
1080,
8,
513,
304,
272,
634,
275,
769,
2941,
65,
297,
283,
66,
1105,
272,
634,
14,
740,
360,
65,
358,
272,
702,
634,
508,
788,
65,
297,
283,
66,
418,
272,
634,
14,
740,
360,
67,
358,
272,
702,
634,
14,
1080,
360,
67,
358,
508,
499,
272,
702,
634,
14,
3118,
365,
715,
421,
199,
318,
511,
63,
1224,
63,
5649,
8,
513,
304,
272,
20088,
275,
769,
342,
272,
754,
275,
791,
65,
356,
16,
12,
283,
66,
356,
17,
12,
283,
67,
356,
18,
12,
283,
68,
356,
19,
93,
339,
367,
8082,
315,
3355,
8,
1099,
14,
1612,
5109,
267,
367,
671,
315,
1425,
8,
21,
304,
288,
20088,
14,
740,
8,
9269,
9,
267,
702,
20088,
14,
1080,
8,
9269,
9,
508,
754,
59,
9269,
61,
272,
702,
20088,
508,
788,
65,
297,
283,
66,
297,
283,
67,
297,
283,
68,
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,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
4613,
421,
199,
32,
4462,
14,
5997,
199,
318,
769,
837,
272,
687,
2508,
16821,
63,
513,
492,
26437,
1296,
272,
372,
26437,
1296,
421,
199,
318,
511,
63,
630,
8,
513,
304,
272,
634,
275,
769,
2941,
66,
297,
283,
65,
1105,
272,
702,
634,
508,
788,
66,
297,
283,
65,
418,
272,
702,
634,
14,
3118,
365,
756,
421,
199,
318,
511,
63,
3306,
63,
11081,
63,
630,
8,
513,
304,
272,
634,
275,
769,
2941,
66,
297,
283,
65,
297,
283,
66,
1105,
272,
702,
634,
508,
788,
66,
297,
283,
65,
297,
283,
66,
418,
272,
634,
14,
740,
360,
65,
358,
272,
702,
634,
508,
788,
66,
297,
283,
65,
297,
283,
66,
418,
421,
199,
318,
511,
63,
1593,
8,
513,
304,
272,
634,
275,
769,
342,
272,
634,
14,
740,
360,
66,
358,
272,
634,
14,
740,
360,
65,
358,
272,
702,
634,
508,
788,
66,
297,
283,
65,
418,
421,
199,
318,
511,
63,
6134,
8,
513,
304,
272,
634,
275,
769,
2941,
65,
297,
283,
66,
297,
283,
65,
1105,
272,
702,
634,
14,
3118,
365,
756,
272,
702,
283,
65,
7,
315,
634,
272,
702,
634,
14,
3118,
365,
715,
421,
199,
318,
511,
63,
1080,
8,
513,
304,
272,
634,
275,
769,
2941,
65,
297,
283,
66,
1105,
272,
634,
14,
740,
360,
65,
358,
272,
702,
634,
508,
788,
65,
297,
283,
66,
418,
272,
634,
14,
740,
360,
67,
358,
272,
702,
634,
14,
1080,
360,
67,
358,
508,
499,
272,
702,
634,
14,
3118,
365,
715,
421,
199,
318,
511,
63,
1224,
63,
5649,
8,
513,
304,
272,
20088,
275,
769,
342,
272,
754,
275,
791,
65,
356,
16,
12,
283,
66,
356,
17,
12,
283,
67,
356,
18,
12,
283,
68,
356,
19,
93,
339,
367,
8082,
315,
3355,
8,
1099,
14,
1612,
5109,
267,
367,
671,
315,
1425,
8,
21,
304,
288,
20088,
14,
740,
8,
9269,
9,
267,
702,
20088,
14,
1080,
8,
9269,
9,
508,
754,
59,
9269,
61,
272,
702,
20088,
508,
788,
65,
297,
283,
66,
297,
283,
67,
297,
283,
68,
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,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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
] |
nfunato/scrapy
|
scrapy/commands/startproject.py
|
26
|
2611
|
from __future__ import print_function
import re
import shutil
import string
from importlib import import_module
from os.path import join, exists, abspath
from shutil import copytree, ignore_patterns
import scrapy
from scrapy.commands import ScrapyCommand
from scrapy.utils.template import render_templatefile, string_camelcase
from scrapy.exceptions import UsageError
TEMPLATES_PATH = join(scrapy.__path__[0], 'templates', 'project')
TEMPLATES_TO_RENDER = (
('scrapy.cfg',),
('${project_name}', 'settings.py.tmpl'),
('${project_name}', 'items.py.tmpl'),
('${project_name}', 'pipelines.py.tmpl'),
)
IGNORE = ignore_patterns('*.pyc', '.svn')
class Command(ScrapyCommand):
requires_project = False
default_settings = {'LOG_ENABLED': False}
def syntax(self):
return "<project_name>"
def short_desc(self):
return "Create new project"
def _is_valid_name(self, project_name):
def _module_exists(module_name):
try:
import_module(module_name)
return True
except ImportError:
return False
if not re.search(r'^[_a-zA-Z]\w*$', project_name):
print('Error: Project names must begin with a letter and contain'\
' only\nletters, numbers and underscores')
elif exists(project_name):
print('Error: Directory %r already exists' % project_name)
elif _module_exists(project_name):
print('Error: Module %r already exists' % project_name)
else:
return True
return False
def run(self, args, opts):
if len(args) != 1:
raise UsageError()
project_name = args[0]
if not self._is_valid_name(project_name):
self.exitcode = 1
return
moduletpl = join(TEMPLATES_PATH, 'module')
copytree(moduletpl, join(project_name, project_name), ignore=IGNORE)
shutil.copy(join(TEMPLATES_PATH, 'scrapy.cfg'), project_name)
for paths in TEMPLATES_TO_RENDER:
path = join(*paths)
tplfile = join(project_name,
string.Template(path).substitute(project_name=project_name))
render_templatefile(tplfile, project_name=project_name,
ProjectName=string_camelcase(project_name))
print("New Scrapy project %r created in:" % project_name)
print(" %s\n" % abspath(project_name))
print("You can start your first spider with:")
print(" cd %s" % project_name)
print(" scrapy genspider example example.com")
|
bsd-3-clause
|
[
504,
636,
2443,
363,
492,
870,
63,
1593,
199,
646,
295,
199,
646,
5145,
199,
646,
1059,
199,
504,
14802,
492,
492,
63,
578,
199,
504,
747,
14,
515,
492,
4263,
12,
3495,
12,
19529,
199,
504,
5145,
492,
1331,
2350,
12,
3686,
63,
7435,
199,
199,
646,
18918,
199,
504,
18918,
14,
4405,
492,
13916,
345,
647,
3110,
199,
504,
18918,
14,
1208,
14,
1160,
492,
3795,
63,
1160,
493,
12,
1059,
63,
22997,
2546,
199,
504,
18918,
14,
3924,
492,
11028,
547,
421,
199,
25437,
63,
3243,
275,
4263,
8,
26442,
855,
515,
12298,
16,
467,
283,
5876,
297,
283,
1715,
358,
199,
199,
25437,
63,
2566,
63,
31587,
275,
334,
272,
661,
26442,
14,
4128,
5529,
272,
661,
10545,
1715,
63,
354,
7293,
283,
1751,
14,
647,
14,
11510,
659,
272,
661,
10545,
1715,
63,
354,
7293,
283,
1744,
14,
647,
14,
11510,
659,
272,
661,
10545,
1715,
63,
354,
7293,
283,
4990,
1278,
14,
647,
14,
11510,
659,
199,
9,
199,
199,
11209,
275,
3686,
63,
7435,
360,
4856,
11357,
297,
1987,
6836,
358,
421,
199,
533,
5817,
8,
7181,
345,
647,
3110,
304,
339,
5074,
63,
1715,
275,
756,
272,
849,
63,
1751,
275,
791,
4947,
63,
15704,
356,
756,
93,
339,
347,
6302,
8,
277,
304,
267,
372,
3886,
1715,
63,
354,
4335,
339,
347,
3974,
63,
3257,
8,
277,
304,
267,
372,
298,
2499,
892,
2199,
2,
339,
347,
485,
374,
63,
1078,
63,
354,
8,
277,
12,
2199,
63,
354,
304,
267,
347,
485,
578,
63,
2444,
8,
578,
63,
354,
304,
288,
862,
26,
355,
492,
63,
578,
8,
578,
63,
354,
9,
355,
372,
715,
288,
871,
3545,
26,
355,
372,
756,
398,
340,
440,
295,
14,
1733,
8,
82,
4289,
13040,
65,
13,
6353,
13,
58,
7272,
87,
32125,
2199,
63,
354,
304,
288,
870,
360,
547,
26,
7290,
1561,
1471,
5386,
543,
282,
8082,
436,
1395,
1154,
490,
283,
1454,
60,
78,
16415,
12,
5579,
436,
23998,
358,
267,
916,
3495,
8,
1715,
63,
354,
304,
288,
870,
360,
547,
26,
15191,
450,
82,
2575,
3495,
7,
450,
2199,
63,
354,
9,
267,
916,
485,
578,
63,
2444,
8,
1715,
63,
354,
304,
288,
870,
360,
547,
26,
5673,
450,
82,
2575,
3495,
7,
450,
2199,
63,
354,
9,
267,
587,
26,
288,
372,
715,
267,
372,
756,
339,
347,
1255,
8,
277,
12,
1249,
12,
3999,
304,
267,
340,
822,
8,
589,
9,
1137,
413,
26,
288,
746,
11028,
547,
342,
267,
2199,
63,
354,
275,
1249,
59,
16,
61,
398,
340,
440,
291,
423,
374,
63,
1078,
63,
354,
8,
1715,
63,
354,
304,
288,
291,
14,
2224,
600,
275,
413,
288,
372,
398,
859,
15436,
275,
4263,
8,
25437,
63,
3243,
12,
283,
578,
358,
267,
1331,
2350,
8,
578,
15436,
12,
4263,
8,
1715,
63,
354,
12,
2199,
63,
354,
395,
3686,
29,
11209,
9,
267,
5145,
14,
1574,
8,
904,
8,
25437,
63,
3243,
12,
283,
26442,
14,
4128,
659,
2199,
63,
354,
9,
267,
367,
3792,
315,
377,
9358,
16601,
63,
2566,
63,
31587,
26,
288,
931,
275,
4263,
2031,
3771,
9,
288,
9253,
12059,
275,
4263,
8,
1715,
63,
354,
12,
355,
1059,
14,
4231,
8,
515,
680,
20374,
8,
1715,
63,
354,
29,
1715,
63,
354,
430,
288,
3795,
63,
1160,
493,
8,
683,
12059,
12,
2199,
63,
354,
29,
1715,
63,
354,
12,
355,
7290,
985,
29,
875,
63,
22997,
2546,
8,
1715,
63,
354,
430,
267,
870,
480,
4665,
13916,
345,
647,
2199,
450,
82,
2737,
315,
5424,
450,
2199,
63,
354,
9,
267,
870,
480,
259,
450,
83,
60,
78,
2,
450,
19529,
8,
1715,
63,
354,
430,
267,
870,
480,
5556,
883,
1343,
2195,
1642,
18094,
543,
9107,
267,
870,
480,
259,
12829,
450,
83,
2,
450,
2199,
63,
354,
9,
267,
870,
480,
259,
18918,
3805,
12856,
2893,
2893,
14,
957,
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
] |
[
636,
2443,
363,
492,
870,
63,
1593,
199,
646,
295,
199,
646,
5145,
199,
646,
1059,
199,
504,
14802,
492,
492,
63,
578,
199,
504,
747,
14,
515,
492,
4263,
12,
3495,
12,
19529,
199,
504,
5145,
492,
1331,
2350,
12,
3686,
63,
7435,
199,
199,
646,
18918,
199,
504,
18918,
14,
4405,
492,
13916,
345,
647,
3110,
199,
504,
18918,
14,
1208,
14,
1160,
492,
3795,
63,
1160,
493,
12,
1059,
63,
22997,
2546,
199,
504,
18918,
14,
3924,
492,
11028,
547,
421,
199,
25437,
63,
3243,
275,
4263,
8,
26442,
855,
515,
12298,
16,
467,
283,
5876,
297,
283,
1715,
358,
199,
199,
25437,
63,
2566,
63,
31587,
275,
334,
272,
661,
26442,
14,
4128,
5529,
272,
661,
10545,
1715,
63,
354,
7293,
283,
1751,
14,
647,
14,
11510,
659,
272,
661,
10545,
1715,
63,
354,
7293,
283,
1744,
14,
647,
14,
11510,
659,
272,
661,
10545,
1715,
63,
354,
7293,
283,
4990,
1278,
14,
647,
14,
11510,
659,
199,
9,
199,
199,
11209,
275,
3686,
63,
7435,
360,
4856,
11357,
297,
1987,
6836,
358,
421,
199,
533,
5817,
8,
7181,
345,
647,
3110,
304,
339,
5074,
63,
1715,
275,
756,
272,
849,
63,
1751,
275,
791,
4947,
63,
15704,
356,
756,
93,
339,
347,
6302,
8,
277,
304,
267,
372,
3886,
1715,
63,
354,
4335,
339,
347,
3974,
63,
3257,
8,
277,
304,
267,
372,
298,
2499,
892,
2199,
2,
339,
347,
485,
374,
63,
1078,
63,
354,
8,
277,
12,
2199,
63,
354,
304,
267,
347,
485,
578,
63,
2444,
8,
578,
63,
354,
304,
288,
862,
26,
355,
492,
63,
578,
8,
578,
63,
354,
9,
355,
372,
715,
288,
871,
3545,
26,
355,
372,
756,
398,
340,
440,
295,
14,
1733,
8,
82,
4289,
13040,
65,
13,
6353,
13,
58,
7272,
87,
32125,
2199,
63,
354,
304,
288,
870,
360,
547,
26,
7290,
1561,
1471,
5386,
543,
282,
8082,
436,
1395,
1154,
490,
283,
1454,
60,
78,
16415,
12,
5579,
436,
23998,
358,
267,
916,
3495,
8,
1715,
63,
354,
304,
288,
870,
360,
547,
26,
15191,
450,
82,
2575,
3495,
7,
450,
2199,
63,
354,
9,
267,
916,
485,
578,
63,
2444,
8,
1715,
63,
354,
304,
288,
870,
360,
547,
26,
5673,
450,
82,
2575,
3495,
7,
450,
2199,
63,
354,
9,
267,
587,
26,
288,
372,
715,
267,
372,
756,
339,
347,
1255,
8,
277,
12,
1249,
12,
3999,
304,
267,
340,
822,
8,
589,
9,
1137,
413,
26,
288,
746,
11028,
547,
342,
267,
2199,
63,
354,
275,
1249,
59,
16,
61,
398,
340,
440,
291,
423,
374,
63,
1078,
63,
354,
8,
1715,
63,
354,
304,
288,
291,
14,
2224,
600,
275,
413,
288,
372,
398,
859,
15436,
275,
4263,
8,
25437,
63,
3243,
12,
283,
578,
358,
267,
1331,
2350,
8,
578,
15436,
12,
4263,
8,
1715,
63,
354,
12,
2199,
63,
354,
395,
3686,
29,
11209,
9,
267,
5145,
14,
1574,
8,
904,
8,
25437,
63,
3243,
12,
283,
26442,
14,
4128,
659,
2199,
63,
354,
9,
267,
367,
3792,
315,
377,
9358,
16601,
63,
2566,
63,
31587,
26,
288,
931,
275,
4263,
2031,
3771,
9,
288,
9253,
12059,
275,
4263,
8,
1715,
63,
354,
12,
355,
1059,
14,
4231,
8,
515,
680,
20374,
8,
1715,
63,
354,
29,
1715,
63,
354,
430,
288,
3795,
63,
1160,
493,
8,
683,
12059,
12,
2199,
63,
354,
29,
1715,
63,
354,
12,
355,
7290,
985,
29,
875,
63,
22997,
2546,
8,
1715,
63,
354,
430,
267,
870,
480,
4665,
13916,
345,
647,
2199,
450,
82,
2737,
315,
5424,
450,
2199,
63,
354,
9,
267,
870,
480,
259,
450,
83,
60,
78,
2,
450,
19529,
8,
1715,
63,
354,
430,
267,
870,
480,
5556,
883,
1343,
2195,
1642,
18094,
543,
9107,
267,
870,
480,
259,
12829,
450,
83,
2,
450,
2199,
63,
354,
9,
267,
870,
480,
259,
18918,
3805,
12856,
2893,
2893,
14,
957,
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,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
VillageAlliance/django-cms
|
cms/tests/reversion_tests.py
|
2
|
6776
|
# -*- coding: utf-8 -*-
from __future__ import with_statement
from cms.models import Page
from cms.models.pluginmodel import CMSPlugin
from cms.plugins.text.models import Text
from cms.test_utils.testcases import (CMSTestCase, URL_CMS_PAGE,
URL_CMS_PAGE_CHANGE, URL_CMS_PAGE_ADD, URL_CMS_PLUGIN_ADD,
URL_CMS_PLUGIN_EDIT)
from django.conf import settings
from django.contrib.auth.models import User
from django.contrib.contenttypes.models import ContentType
from django.core.files.uploadedfile import SimpleUploadedFile
from os.path import join
from project.fileapp.models import FileModel
from reversion.models import Revision, Version
from reversion import revision as revision_manager
import shutil
class ReversionTestCase(CMSTestCase):
def setUp(self):
u = User(username="test", is_staff=True, is_active=True,
is_superuser=True)
u.set_password("test")
u.save()
with self.login_user_context(u):
# add a new text plugin
self.page_data = self.get_new_page_data()
response = self.client.post(URL_CMS_PAGE_ADD, self.page_data)
self.assertRedirects(response, URL_CMS_PAGE)
page = Page.objects.all()[0]
placeholderpk = page.placeholders.get(slot="body").pk
plugin_data = {
'plugin_type':"TextPlugin",
'page_id':page.pk,
'language':settings.LANGUAGES[0][0],
'placeholder':placeholderpk,
}
response = self.client.post(URL_CMS_PLUGIN_ADD, plugin_data)
self.assertEquals(response.status_code, 200)
self.assertEquals(int(response.content),
CMSPlugin.objects.all()[0].pk)
# now edit the plugin
edit_url = URL_CMS_PLUGIN_EDIT + response.content + "/"
response = self.client.get(edit_url)
self.assertEquals(response.status_code, 200)
response = self.client.post(edit_url, {"body":"Hello World"})
self.assertEquals(response.status_code, 200)
txt = Text.objects.all()[0]
self.assertEquals("Hello World", txt.body)
# change the content
response = self.client.post(edit_url, {"body":"Bye Bye World"})
self.assertEquals(response.status_code, 200)
txt = Text.objects.all()[0]
self.assertEquals("Bye Bye World", txt.body)
p_data = self.page_data.copy()
p_data['published'] = True
response = self.client.post(URL_CMS_PAGE_CHANGE % page.pk, p_data)
self.assertRedirects(response, URL_CMS_PAGE)
def test_revert(self):
"""
Test that you can revert a plugin
"""
with self.login_user_context(User.objects.get(username="test")):
self.assertEquals(Page.objects.all().count(), 2)
self.assertEquals(CMSPlugin.objects.all().count(), 2)
self.assertEquals(Revision.objects.all().count(), 5)
ctype = ContentType.objects.get_for_model(Page)
revision = Revision.objects.all()[2]
version = Version.objects.get(content_type=ctype, revision=revision)
page = Page.objects.all()[0]
history_url = URL_CMS_PAGE_CHANGE % (page.pk) + "history/"
response = self.client.get(history_url)
self.assertEquals(response.status_code, 200)
revert_url = history_url + "%s/" % version.pk
response = self.client.get(revert_url)
self.assertEquals(response.status_code, 200)
response = self.client.post(revert_url, self.page_data)
self.assertRedirects(response, URL_CMS_PAGE_CHANGE % page.pk)
# test for publisher_is_draft, published is set for both draft and
# published page
self.assertEquals(Page.objects.all()[0].publisher_is_draft, True)
self.assertEquals(CMSPlugin.objects.all().count(), 2)
# test that CMSPlugin subclasses are reverted
self.assertEquals(Text.objects.all().count(), 2)
self.assertEquals(Revision.objects.all().count(), 6)
def test_recover(self):
"""
Test that you can recover a page
"""
with self.login_user_context(User.objects.get(username="test")):
self.assertEquals(Revision.objects.all().count(), 5)
ctype = ContentType.objects.get_for_model(Page)
revision = Revision.objects.all()[4]
version = Version.objects.get(content_type=ctype, revision=revision)
self.assertEquals(Page.objects.all().count(), 2)
self.assertEquals(CMSPlugin.objects.all().count(), 2)
self.assertEquals(Text.objects.all().count(), 2)
page = Page.objects.all()[0]
page_pk = page.pk
page.delete_with_public()
self.assertEquals(Page.objects.all().count(), 0)
self.assertEquals(CMSPlugin.objects.all().count(), 0)
self.assertEquals(Text.objects.all().count(), 0)
recover_url = URL_CMS_PAGE + "recover/"
response = self.client.get(recover_url)
self.assertEquals(response.status_code, 200)
recover_url += "%s/" % version.pk
response = self.client.get(recover_url)
self.assertEquals(response.status_code, 200)
response = self.client.post(recover_url, self.page_data)
self.assertRedirects(response, URL_CMS_PAGE_CHANGE % page_pk)
self.assertEquals(Page.objects.all().count(), 1)
self.assertEquals(CMSPlugin.objects.all().count(), 1)
# test that CMSPlugin subclasses are recovered
self.assertEquals(Text.objects.all().count(), 1)
class ReversionFileFieldTests(CMSTestCase):
def tearDown(self):
shutil.rmtree(join(settings.MEDIA_ROOT, 'fileapp'))
def test_file_persistence(self):
with revision_manager:
# add a file instance
file1 = FileModel()
file1.test_file.save('file1.txt',
SimpleUploadedFile('file1.txt', 'content1'), False)
file1.save()
# manually add a revision because we use the explicit way
# django-cms uses too.
revision_manager.add(file1)
# reload the instance from db
file2 = FileModel.objects.all()[0]
# delete the instance.
file2.delete()
# revert the old version
file_version = Version.objects.get_for_object(file1)[0]
file_version.revert()
# reload the reverted instance and check for its content
file1 = FileModel.objects.all()[0]
self.assertEqual(file1.test_file.file.read(), 'content1')
|
bsd-3-clause
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
504,
636,
2443,
363,
492,
543,
63,
6242,
199,
504,
19240,
14,
992,
492,
10331,
199,
504,
19240,
14,
992,
14,
2718,
1238,
492,
29554,
5061,
199,
504,
19240,
14,
5265,
14,
505,
14,
992,
492,
4516,
199,
504,
19240,
14,
396,
63,
1208,
14,
396,
9403,
492,
334,
17834,
1746,
12,
2851,
63,
17834,
63,
12898,
12,
272,
2851,
63,
17834,
63,
12898,
63,
16062,
12,
2851,
63,
17834,
63,
12898,
63,
9732,
12,
2851,
63,
17834,
63,
19108,
63,
9732,
12,
272,
2851,
63,
17834,
63,
19108,
63,
17929,
9,
199,
504,
1639,
14,
2190,
492,
2202,
199,
504,
1639,
14,
2828,
14,
1178,
14,
992,
492,
2876,
199,
504,
1639,
14,
2828,
14,
10778,
14,
992,
492,
14501,
199,
504,
1639,
14,
1018,
14,
1725,
14,
19044,
493,
492,
5870,
24665,
199,
504,
747,
14,
515,
492,
4263,
199,
504,
2199,
14,
493,
571,
14,
992,
492,
3814,
1685,
199,
504,
295,
1023,
14,
992,
492,
27095,
12,
3394,
199,
504,
295,
1023,
492,
6974,
465,
6974,
63,
2609,
199,
646,
5145,
199,
199,
533,
799,
1023,
1746,
8,
17834,
1746,
304,
272,
347,
3613,
8,
277,
304,
267,
399,
275,
2876,
8,
2473,
628,
396,
401,
365,
63,
7018,
29,
549,
12,
365,
63,
2682,
29,
549,
12,
288,
365,
63,
11434,
29,
549,
9,
267,
399,
14,
409,
63,
2060,
480,
396,
531,
267,
399,
14,
2117,
342,
398,
543,
291,
14,
2886,
63,
751,
63,
1100,
8,
85,
304,
288,
327,
1050,
282,
892,
1318,
3589,
288,
291,
14,
1606,
63,
576,
275,
291,
14,
362,
63,
1222,
63,
1606,
63,
576,
342,
288,
1177,
275,
291,
14,
1258,
14,
1932,
8,
2632,
63,
17834,
63,
12898,
63,
9732,
12,
291,
14,
1606,
63,
576,
9,
288,
291,
14,
17466,
8,
1310,
12,
2851,
63,
17834,
63,
12898,
9,
953,
2034,
275,
10331,
14,
1462,
14,
452,
3430,
16,
61,
288,
10069,
2051,
275,
2034,
14,
22100,
14,
362,
8,
7998,
628,
2030,
3471,
2051,
288,
3589,
63,
576,
275,
469,
355,
283,
2718,
63,
466,
27182,
1872,
5061,
401,
355,
283,
1606,
63,
344,
356,
1606,
14,
2051,
12,
355,
283,
3671,
356,
1751,
14,
26886,
59,
16,
1527,
16,
467,
355,
283,
6199,
356,
6199,
2051,
12,
288,
789,
288,
1177,
275,
291,
14,
1258,
14,
1932,
8,
2632,
63,
17834,
63,
19108,
63,
9732,
12,
3589,
63,
576,
9,
288,
291,
14,
2947,
8,
1310,
14,
1205,
63,
600,
12,
1926,
9,
288,
291,
14,
2947,
8,
442,
8,
1310,
14,
1317,
395,
355,
29554,
5061,
14,
1462,
14,
452,
3430,
16,
1055,
2051,
9,
953,
327,
3063,
5283,
314,
3589,
288,
5283,
63,
633,
275,
2851,
63,
17834,
63,
19108,
63,
17929,
435,
1177,
14,
1317,
435,
10609,
288,
1177,
275,
291,
14,
1258,
14,
362,
8,
3773,
63,
633,
9,
288,
291,
14,
2947,
8,
1310,
14,
1205,
63,
600,
12,
1926,
9,
288,
1177,
275,
291,
14,
1258,
14,
1932,
8,
3773,
63,
633,
12,
2420,
2030,
5122,
6257,
13064,
5984,
288,
291,
14,
2947,
8,
1310,
14,
1205,
63,
600,
12,
1926,
9,
288,
9444,
275,
4516,
14,
1462,
14,
452,
3430,
16,
61,
288,
291,
14,
2947,
480,
6257,
13064,
401,
9444,
14,
2030,
9,
953,
327,
1570,
314,
1564,
288,
1177,
275,
291,
14,
1258,
14,
1932,
8,
3773,
63,
633,
12,
2420,
2030,
5122,
2175,
69,
4885,
69,
13064,
5984,
288,
291,
14,
2947,
8,
1310,
14,
1205,
63,
600,
12,
1926,
9,
288,
9444,
275,
4516,
14,
1462,
14,
452,
3430,
16,
61,
288,
291,
14,
2947,
480,
2175,
69,
4885,
69,
13064,
401,
9444,
14,
2030,
9,
288,
299,
63,
576,
275,
291,
14,
1606,
63,
576,
14,
1574,
342,
288,
299,
63,
576,
459,
8987,
418,
275,
715,
288,
1177,
275,
291,
14,
1258,
14,
1932,
8,
2632,
63,
17834,
63,
12898,
63,
16062,
450,
2034,
14,
2051,
12,
299,
63,
576,
9,
288,
291,
14,
17466,
8,
1310,
12,
2851,
63,
17834,
63,
12898,
9,
339,
347,
511,
63,
19092,
8,
277,
304,
267,
408,
267,
1379,
626,
1265,
883,
23347,
282,
3589,
267,
408,
267,
543,
291,
14,
2886,
63,
751,
63,
1100,
8,
1899,
14,
1462,
14,
362,
8,
2473,
628,
396,
14150,
288,
291,
14,
2947,
8,
3276,
14,
1462,
14,
452,
1252,
835,
1062,
499,
9,
288,
291,
14,
2947,
8,
17834,
5061,
14,
1462,
14,
452,
1252,
835,
1062,
499,
9,
288,
291,
14,
2947,
8,
12714,
14,
1462,
14,
452,
1252,
835,
1062,
959,
9,
953,
16360,
275,
14501,
14,
1462,
14,
362,
63,
509,
63,
1238,
8,
3276,
9,
288,
6974,
275,
27095,
14,
1462,
14,
452,
3430,
18,
61,
288,
1015,
275,
3394,
14,
1462,
14,
362,
8,
1317,
63,
466,
29,
3667,
12,
6974,
29,
5792,
9,
288,
2034,
275,
10331,
14,
1462,
14,
452,
3430,
16,
61,
953,
7994,
63,
633,
275,
2851,
63,
17834,
63,
12898,
63,
16062,
450,
334,
1606,
14,
2051,
9,
435,
298,
5570,
6687,
288,
1177,
275,
291,
14,
1258,
14,
362,
8,
5570,
63,
633,
9,
288,
291,
14,
2947,
8,
1310,
14,
1205,
63,
600,
12,
1926,
9,
953,
23347,
63,
633,
275,
7994,
63,
633,
435,
2071,
83,
6687,
450,
1015,
14,
2051,
288,
1177,
275,
291,
14,
1258,
14,
362,
8,
19092,
63,
633,
9,
288,
291,
14,
2947,
8,
1310,
14,
1205,
63,
600,
12,
1926,
9,
953,
1177,
275,
291,
14,
1258,
14,
1932,
8,
19092,
63,
633,
12,
291,
14,
1606,
63,
576,
9,
288,
291,
14,
17466,
8,
1310,
12,
2851,
63,
17834,
63,
12898,
63,
16062,
450,
2034,
14,
2051,
9,
953,
327,
511,
367,
19704,
63,
374,
63,
7185,
12,
3267,
365,
663,
367,
3865,
11872,
436,
288,
327,
3267,
2034,
288,
291,
14,
2947,
8,
3276,
14,
1462,
14,
452,
3430,
16,
1055,
12789,
63,
374,
63,
7185,
12,
715,
9,
288,
291,
14,
2947,
8,
17834,
5061,
14,
1462,
14,
452,
1252,
835,
1062,
499,
9,
953,
327,
511,
626,
29554,
5061,
9180,
787,
295,
16542,
288,
291,
14,
2947,
8,
1872,
14,
1462,
14,
452,
1252,
835
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
504,
636,
2443,
363,
492,
543,
63,
6242,
199,
504,
19240,
14,
992,
492,
10331,
199,
504,
19240,
14,
992,
14,
2718,
1238,
492,
29554,
5061,
199,
504,
19240,
14,
5265,
14,
505,
14,
992,
492,
4516,
199,
504,
19240,
14,
396,
63,
1208,
14,
396,
9403,
492,
334,
17834,
1746,
12,
2851,
63,
17834,
63,
12898,
12,
272,
2851,
63,
17834,
63,
12898,
63,
16062,
12,
2851,
63,
17834,
63,
12898,
63,
9732,
12,
2851,
63,
17834,
63,
19108,
63,
9732,
12,
272,
2851,
63,
17834,
63,
19108,
63,
17929,
9,
199,
504,
1639,
14,
2190,
492,
2202,
199,
504,
1639,
14,
2828,
14,
1178,
14,
992,
492,
2876,
199,
504,
1639,
14,
2828,
14,
10778,
14,
992,
492,
14501,
199,
504,
1639,
14,
1018,
14,
1725,
14,
19044,
493,
492,
5870,
24665,
199,
504,
747,
14,
515,
492,
4263,
199,
504,
2199,
14,
493,
571,
14,
992,
492,
3814,
1685,
199,
504,
295,
1023,
14,
992,
492,
27095,
12,
3394,
199,
504,
295,
1023,
492,
6974,
465,
6974,
63,
2609,
199,
646,
5145,
199,
199,
533,
799,
1023,
1746,
8,
17834,
1746,
304,
272,
347,
3613,
8,
277,
304,
267,
399,
275,
2876,
8,
2473,
628,
396,
401,
365,
63,
7018,
29,
549,
12,
365,
63,
2682,
29,
549,
12,
288,
365,
63,
11434,
29,
549,
9,
267,
399,
14,
409,
63,
2060,
480,
396,
531,
267,
399,
14,
2117,
342,
398,
543,
291,
14,
2886,
63,
751,
63,
1100,
8,
85,
304,
288,
327,
1050,
282,
892,
1318,
3589,
288,
291,
14,
1606,
63,
576,
275,
291,
14,
362,
63,
1222,
63,
1606,
63,
576,
342,
288,
1177,
275,
291,
14,
1258,
14,
1932,
8,
2632,
63,
17834,
63,
12898,
63,
9732,
12,
291,
14,
1606,
63,
576,
9,
288,
291,
14,
17466,
8,
1310,
12,
2851,
63,
17834,
63,
12898,
9,
953,
2034,
275,
10331,
14,
1462,
14,
452,
3430,
16,
61,
288,
10069,
2051,
275,
2034,
14,
22100,
14,
362,
8,
7998,
628,
2030,
3471,
2051,
288,
3589,
63,
576,
275,
469,
355,
283,
2718,
63,
466,
27182,
1872,
5061,
401,
355,
283,
1606,
63,
344,
356,
1606,
14,
2051,
12,
355,
283,
3671,
356,
1751,
14,
26886,
59,
16,
1527,
16,
467,
355,
283,
6199,
356,
6199,
2051,
12,
288,
789,
288,
1177,
275,
291,
14,
1258,
14,
1932,
8,
2632,
63,
17834,
63,
19108,
63,
9732,
12,
3589,
63,
576,
9,
288,
291,
14,
2947,
8,
1310,
14,
1205,
63,
600,
12,
1926,
9,
288,
291,
14,
2947,
8,
442,
8,
1310,
14,
1317,
395,
355,
29554,
5061,
14,
1462,
14,
452,
3430,
16,
1055,
2051,
9,
953,
327,
3063,
5283,
314,
3589,
288,
5283,
63,
633,
275,
2851,
63,
17834,
63,
19108,
63,
17929,
435,
1177,
14,
1317,
435,
10609,
288,
1177,
275,
291,
14,
1258,
14,
362,
8,
3773,
63,
633,
9,
288,
291,
14,
2947,
8,
1310,
14,
1205,
63,
600,
12,
1926,
9,
288,
1177,
275,
291,
14,
1258,
14,
1932,
8,
3773,
63,
633,
12,
2420,
2030,
5122,
6257,
13064,
5984,
288,
291,
14,
2947,
8,
1310,
14,
1205,
63,
600,
12,
1926,
9,
288,
9444,
275,
4516,
14,
1462,
14,
452,
3430,
16,
61,
288,
291,
14,
2947,
480,
6257,
13064,
401,
9444,
14,
2030,
9,
953,
327,
1570,
314,
1564,
288,
1177,
275,
291,
14,
1258,
14,
1932,
8,
3773,
63,
633,
12,
2420,
2030,
5122,
2175,
69,
4885,
69,
13064,
5984,
288,
291,
14,
2947,
8,
1310,
14,
1205,
63,
600,
12,
1926,
9,
288,
9444,
275,
4516,
14,
1462,
14,
452,
3430,
16,
61,
288,
291,
14,
2947,
480,
2175,
69,
4885,
69,
13064,
401,
9444,
14,
2030,
9,
288,
299,
63,
576,
275,
291,
14,
1606,
63,
576,
14,
1574,
342,
288,
299,
63,
576,
459,
8987,
418,
275,
715,
288,
1177,
275,
291,
14,
1258,
14,
1932,
8,
2632,
63,
17834,
63,
12898,
63,
16062,
450,
2034,
14,
2051,
12,
299,
63,
576,
9,
288,
291,
14,
17466,
8,
1310,
12,
2851,
63,
17834,
63,
12898,
9,
339,
347,
511,
63,
19092,
8,
277,
304,
267,
408,
267,
1379,
626,
1265,
883,
23347,
282,
3589,
267,
408,
267,
543,
291,
14,
2886,
63,
751,
63,
1100,
8,
1899,
14,
1462,
14,
362,
8,
2473,
628,
396,
14150,
288,
291,
14,
2947,
8,
3276,
14,
1462,
14,
452,
1252,
835,
1062,
499,
9,
288,
291,
14,
2947,
8,
17834,
5061,
14,
1462,
14,
452,
1252,
835,
1062,
499,
9,
288,
291,
14,
2947,
8,
12714,
14,
1462,
14,
452,
1252,
835,
1062,
959,
9,
953,
16360,
275,
14501,
14,
1462,
14,
362,
63,
509,
63,
1238,
8,
3276,
9,
288,
6974,
275,
27095,
14,
1462,
14,
452,
3430,
18,
61,
288,
1015,
275,
3394,
14,
1462,
14,
362,
8,
1317,
63,
466,
29,
3667,
12,
6974,
29,
5792,
9,
288,
2034,
275,
10331,
14,
1462,
14,
452,
3430,
16,
61,
953,
7994,
63,
633,
275,
2851,
63,
17834,
63,
12898,
63,
16062,
450,
334,
1606,
14,
2051,
9,
435,
298,
5570,
6687,
288,
1177,
275,
291,
14,
1258,
14,
362,
8,
5570,
63,
633,
9,
288,
291,
14,
2947,
8,
1310,
14,
1205,
63,
600,
12,
1926,
9,
953,
23347,
63,
633,
275,
7994,
63,
633,
435,
2071,
83,
6687,
450,
1015,
14,
2051,
288,
1177,
275,
291,
14,
1258,
14,
362,
8,
19092,
63,
633,
9,
288,
291,
14,
2947,
8,
1310,
14,
1205,
63,
600,
12,
1926,
9,
953,
1177,
275,
291,
14,
1258,
14,
1932,
8,
19092,
63,
633,
12,
291,
14,
1606,
63,
576,
9,
288,
291,
14,
17466,
8,
1310,
12,
2851,
63,
17834,
63,
12898,
63,
16062,
450,
2034,
14,
2051,
9,
953,
327,
511,
367,
19704,
63,
374,
63,
7185,
12,
3267,
365,
663,
367,
3865,
11872,
436,
288,
327,
3267,
2034,
288,
291,
14,
2947,
8,
3276,
14,
1462,
14,
452,
3430,
16,
1055,
12789,
63,
374,
63,
7185,
12,
715,
9,
288,
291,
14,
2947,
8,
17834,
5061,
14,
1462,
14,
452,
1252,
835,
1062,
499,
9,
953,
327,
511,
626,
29554,
5061,
9180,
787,
295,
16542,
288,
291,
14,
2947,
8,
1872,
14,
1462,
14,
452,
1252,
835,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
devanshdalal/scikit-learn
|
examples/ensemble/plot_isolation_forest.py
|
39
|
2361
|
"""
==========================================
IsolationForest example
==========================================
An example using IsolationForest for anomaly detection.
The IsolationForest 'isolates' observations by randomly selecting a feature
and then randomly selecting a split value between the maximum and minimum
values of the selected feature.
Since recursive partitioning can be represented by a tree structure, the
number of splittings required to isolate a sample is equivalent to the path
length from the root node to the terminating node.
This path length, averaged over a forest of such random trees, is a measure
of normality and our decision function.
Random partitioning produces noticeable shorter paths for anomalies.
Hence, when a forest of random trees collectively produce shorter path lengths
for particular samples, they are highly likely to be anomalies.
.. [1] Liu, Fei Tony, Ting, Kai Ming and Zhou, Zhi-Hua. "Isolation forest."
Data Mining, 2008. ICDM'08. Eighth IEEE International Conference on.
"""
print(__doc__)
import numpy as np
import matplotlib.pyplot as plt
from sklearn.ensemble import IsolationForest
rng = np.random.RandomState(42)
# Generate train data
X = 0.3 * rng.randn(100, 2)
X_train = np.r_[X + 2, X - 2]
# Generate some regular novel observations
X = 0.3 * rng.randn(20, 2)
X_test = np.r_[X + 2, X - 2]
# Generate some abnormal novel observations
X_outliers = rng.uniform(low=-4, high=4, size=(20, 2))
# fit the model
clf = IsolationForest(max_samples=100, random_state=rng)
clf.fit(X_train)
y_pred_train = clf.predict(X_train)
y_pred_test = clf.predict(X_test)
y_pred_outliers = clf.predict(X_outliers)
# plot the line, the samples, and the nearest vectors to the plane
xx, yy = np.meshgrid(np.linspace(-5, 5, 50), np.linspace(-5, 5, 50))
Z = clf.decision_function(np.c_[xx.ravel(), yy.ravel()])
Z = Z.reshape(xx.shape)
plt.title("IsolationForest")
plt.contourf(xx, yy, Z, cmap=plt.cm.Blues_r)
b1 = plt.scatter(X_train[:, 0], X_train[:, 1], c='white')
b2 = plt.scatter(X_test[:, 0], X_test[:, 1], c='green')
c = plt.scatter(X_outliers[:, 0], X_outliers[:, 1], c='red')
plt.axis('tight')
plt.xlim((-5, 5))
plt.ylim((-5, 5))
plt.legend([b1, b2, c],
["training observations",
"new regular observations", "new abnormal observations"],
loc="upper left")
plt.show()
|
bsd-3-clause
|
[
624,
199,
2486,
17575,
199,
1831,
10410,
21668,
2893,
199,
2486,
17575,
199,
199,
2493,
2893,
1808,
6596,
10410,
21668,
367,
28813,
15212,
14,
199,
199,
1918,
6596,
10410,
21668,
283,
374,
393,
2335,
7,
19739,
701,
19311,
30090,
282,
3878,
199,
460,
2066,
19311,
30090,
282,
3715,
574,
3382,
314,
5696,
436,
7481,
199,
1459,
402,
314,
4895,
3878,
14,
199,
199,
24430,
9133,
6484,
316,
883,
506,
11159,
701,
282,
3123,
5523,
12,
314,
199,
1955,
402,
3715,
1161,
1415,
370,
365,
16288,
282,
2690,
365,
7353,
370,
314,
931,
199,
1267,
687,
314,
1738,
1031,
370,
314,
5537,
1958,
1031,
14,
199,
199,
2765,
931,
2582,
12,
8095,
68,
1806,
282,
27882,
402,
4066,
2196,
14416,
12,
365,
282,
9775,
199,
1618,
3293,
1209,
436,
4154,
14692,
805,
14,
199,
199,
3883,
6484,
316,
16904,
4245,
461,
18299,
3792,
367,
376,
676,
279,
1500,
14,
199,
40,
4894,
12,
1380,
282,
27882,
402,
2196,
14416,
1048,
10251,
9462,
7389,
18299,
931,
17464,
199,
509,
6770,
5845,
12,
2985,
787,
4721,
590,
12060,
370,
506,
376,
676,
279,
1500,
14,
199,
199,
703,
359,
17,
61,
24157,
85,
12,
7949,
73,
377,
5220,
12,
377,
316,
12,
1804,
5789,
603,
316,
436,
3107,
11586,
12,
3107,
5812,
13,
40,
1458,
14,
298,
1831,
10410,
27882,
2122,
272,
3918,
603,
7969,
12,
9079,
14,
473,
7695,
45,
7,
2036,
14,
662,
2056,
273,
473,
29146,
28220,
1448,
1769,
641,
14,
199,
199,
624,
199,
1361,
3460,
1301,
3368,
199,
199,
646,
2680,
465,
980,
199,
646,
8027,
14,
13563,
465,
4488,
199,
504,
6357,
14,
15628,
492,
6596,
10410,
21668,
199,
199,
12686,
275,
980,
14,
2355,
14,
15726,
8,
2260,
9,
199,
199,
3,
7958,
3560,
666,
199,
56,
275,
378,
14,
19,
627,
9038,
14,
10843,
8,
1960,
12,
499,
9,
199,
56,
63,
2834,
275,
980,
14,
82,
9925,
56,
435,
499,
12,
1323,
446,
499,
61,
199,
3,
7958,
2005,
5578,
949,
1090,
19739,
199,
56,
275,
378,
14,
19,
627,
9038,
14,
10843,
8,
1165,
12,
499,
9,
199,
56,
63,
396,
275,
980,
14,
82,
9925,
56,
435,
499,
12,
1323,
446,
499,
61,
199,
3,
7958,
2005,
2236,
3302,
949,
1090,
19739,
199,
56,
63,
28622,
275,
9038,
14,
8830,
8,
674,
4022,
20,
12,
4721,
29,
20,
12,
1568,
2687,
1165,
12,
499,
430,
199,
199,
3,
5542,
314,
1402,
199,
9694,
275,
6596,
10410,
21668,
8,
988,
63,
3356,
29,
1960,
12,
2196,
63,
929,
29,
12686,
9,
199,
9694,
14,
3269,
8,
56,
63,
2834,
9,
199,
89,
63,
5991,
63,
2834,
275,
6975,
14,
6892,
8,
56,
63,
2834,
9,
199,
89,
63,
5991,
63,
396,
275,
6975,
14,
6892,
8,
56,
63,
396,
9,
199,
89,
63,
5991,
63,
28622,
275,
6975,
14,
6892,
8,
56,
63,
28622,
9,
199,
199,
3,
5137,
314,
1004,
12,
314,
5845,
12,
436,
314,
17173,
11102,
370,
314,
16388,
199,
2154,
12,
20435,
275,
980,
14,
6480,
3825,
8,
1590,
14,
11649,
2801,
21,
12,
959,
12,
5238,
395,
980,
14,
11649,
2801,
21,
12,
959,
12,
5238,
430,
199,
58,
275,
6975,
14,
16622,
63,
1593,
8,
1590,
14,
67,
9925,
2154,
14,
11186,
1062,
20435,
14,
11186,
9383,
199,
58,
275,
3107,
14,
5217,
8,
2154,
14,
1392,
9,
199,
199,
6003,
14,
1213,
480,
1831,
10410,
21668,
531,
199,
6003,
14,
17798,
70,
8,
2154,
12,
20435,
12,
3107,
12,
14920,
29,
6003,
14,
4400,
14,
24613,
10138,
63,
82,
9,
199,
199,
66,
17,
275,
4488,
14,
13512,
8,
56,
63,
2834,
3981,
378,
467,
1323,
63,
2834,
3981,
413,
467,
286,
534,
7510,
358,
199,
66,
18,
275,
4488,
14,
13512,
8,
56,
63,
396,
3981,
378,
467,
1323,
63,
396,
3981,
413,
467,
286,
534,
7731,
358,
199,
67,
275,
4488,
14,
13512,
8,
56,
63,
28622,
3981,
378,
467,
1323,
63,
28622,
3981,
413,
467,
286,
534,
581,
358,
199,
6003,
14,
3127,
360,
23787,
358,
199,
6003,
14,
18512,
18138,
21,
12,
959,
430,
199,
6003,
14,
18123,
18138,
21,
12,
959,
430,
199,
6003,
14,
10231,
779,
66,
17,
12,
330,
18,
12,
286,
467,
1779,
2097,
7588,
19739,
401,
288,
298,
1222,
5578,
19739,
401,
298,
1222,
2236,
3302,
19739,
2255,
1779,
4355,
628,
4142,
3602,
531,
199,
6003,
14,
2384,
342,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
199,
2486,
17575,
199,
1831,
10410,
21668,
2893,
199,
2486,
17575,
199,
199,
2493,
2893,
1808,
6596,
10410,
21668,
367,
28813,
15212,
14,
199,
199,
1918,
6596,
10410,
21668,
283,
374,
393,
2335,
7,
19739,
701,
19311,
30090,
282,
3878,
199,
460,
2066,
19311,
30090,
282,
3715,
574,
3382,
314,
5696,
436,
7481,
199,
1459,
402,
314,
4895,
3878,
14,
199,
199,
24430,
9133,
6484,
316,
883,
506,
11159,
701,
282,
3123,
5523,
12,
314,
199,
1955,
402,
3715,
1161,
1415,
370,
365,
16288,
282,
2690,
365,
7353,
370,
314,
931,
199,
1267,
687,
314,
1738,
1031,
370,
314,
5537,
1958,
1031,
14,
199,
199,
2765,
931,
2582,
12,
8095,
68,
1806,
282,
27882,
402,
4066,
2196,
14416,
12,
365,
282,
9775,
199,
1618,
3293,
1209,
436,
4154,
14692,
805,
14,
199,
199,
3883,
6484,
316,
16904,
4245,
461,
18299,
3792,
367,
376,
676,
279,
1500,
14,
199,
40,
4894,
12,
1380,
282,
27882,
402,
2196,
14416,
1048,
10251,
9462,
7389,
18299,
931,
17464,
199,
509,
6770,
5845,
12,
2985,
787,
4721,
590,
12060,
370,
506,
376,
676,
279,
1500,
14,
199,
199,
703,
359,
17,
61,
24157,
85,
12,
7949,
73,
377,
5220,
12,
377,
316,
12,
1804,
5789,
603,
316,
436,
3107,
11586,
12,
3107,
5812,
13,
40,
1458,
14,
298,
1831,
10410,
27882,
2122,
272,
3918,
603,
7969,
12,
9079,
14,
473,
7695,
45,
7,
2036,
14,
662,
2056,
273,
473,
29146,
28220,
1448,
1769,
641,
14,
199,
199,
624,
199,
1361,
3460,
1301,
3368,
199,
199,
646,
2680,
465,
980,
199,
646,
8027,
14,
13563,
465,
4488,
199,
504,
6357,
14,
15628,
492,
6596,
10410,
21668,
199,
199,
12686,
275,
980,
14,
2355,
14,
15726,
8,
2260,
9,
199,
199,
3,
7958,
3560,
666,
199,
56,
275,
378,
14,
19,
627,
9038,
14,
10843,
8,
1960,
12,
499,
9,
199,
56,
63,
2834,
275,
980,
14,
82,
9925,
56,
435,
499,
12,
1323,
446,
499,
61,
199,
3,
7958,
2005,
5578,
949,
1090,
19739,
199,
56,
275,
378,
14,
19,
627,
9038,
14,
10843,
8,
1165,
12,
499,
9,
199,
56,
63,
396,
275,
980,
14,
82,
9925,
56,
435,
499,
12,
1323,
446,
499,
61,
199,
3,
7958,
2005,
2236,
3302,
949,
1090,
19739,
199,
56,
63,
28622,
275,
9038,
14,
8830,
8,
674,
4022,
20,
12,
4721,
29,
20,
12,
1568,
2687,
1165,
12,
499,
430,
199,
199,
3,
5542,
314,
1402,
199,
9694,
275,
6596,
10410,
21668,
8,
988,
63,
3356,
29,
1960,
12,
2196,
63,
929,
29,
12686,
9,
199,
9694,
14,
3269,
8,
56,
63,
2834,
9,
199,
89,
63,
5991,
63,
2834,
275,
6975,
14,
6892,
8,
56,
63,
2834,
9,
199,
89,
63,
5991,
63,
396,
275,
6975,
14,
6892,
8,
56,
63,
396,
9,
199,
89,
63,
5991,
63,
28622,
275,
6975,
14,
6892,
8,
56,
63,
28622,
9,
199,
199,
3,
5137,
314,
1004,
12,
314,
5845,
12,
436,
314,
17173,
11102,
370,
314,
16388,
199,
2154,
12,
20435,
275,
980,
14,
6480,
3825,
8,
1590,
14,
11649,
2801,
21,
12,
959,
12,
5238,
395,
980,
14,
11649,
2801,
21,
12,
959,
12,
5238,
430,
199,
58,
275,
6975,
14,
16622,
63,
1593,
8,
1590,
14,
67,
9925,
2154,
14,
11186,
1062,
20435,
14,
11186,
9383,
199,
58,
275,
3107,
14,
5217,
8,
2154,
14,
1392,
9,
199,
199,
6003,
14,
1213,
480,
1831,
10410,
21668,
531,
199,
6003,
14,
17798,
70,
8,
2154,
12,
20435,
12,
3107,
12,
14920,
29,
6003,
14,
4400,
14,
24613,
10138,
63,
82,
9,
199,
199,
66,
17,
275,
4488,
14,
13512,
8,
56,
63,
2834,
3981,
378,
467,
1323,
63,
2834,
3981,
413,
467,
286,
534,
7510,
358,
199,
66,
18,
275,
4488,
14,
13512,
8,
56,
63,
396,
3981,
378,
467,
1323,
63,
396,
3981,
413,
467,
286,
534,
7731,
358,
199,
67,
275,
4488,
14,
13512,
8,
56,
63,
28622,
3981,
378,
467,
1323,
63,
28622,
3981,
413,
467,
286,
534,
581,
358,
199,
6003,
14,
3127,
360,
23787,
358,
199,
6003,
14,
18512,
18138,
21,
12,
959,
430,
199,
6003,
14,
18123,
18138,
21,
12,
959,
430,
199,
6003,
14,
10231,
779,
66,
17,
12,
330,
18,
12,
286,
467,
1779,
2097,
7588,
19739,
401,
288,
298,
1222,
5578,
19739,
401,
298,
1222,
2236,
3302,
19739,
2255,
1779,
4355,
628,
4142,
3602,
531,
199,
6003,
14,
2384,
342,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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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/>.
#
##############################################################################
# Why doing some multi-thread instead of using OSE capabilities ?
# For progress bar.
#
# Add a transparant multi-thread layer to all report rendering layers
#
# TODO: method to stock on the disk
class render(object):
""" Represents a report job being rendered.
@param bin_datas a dictionary of name:<binary content> of images etc.
@param path the path in which binary files can be discovered, useful
for components (images) of the report. It can be:
- a string, relative or absolute path to images
- a list, containing strings of paths.
If a string is absolute path, it will be opened as such, else
it will be passed to tools.file_open() which also considers zip
addons.
Reporting classes must subclass this class and redefine the __init__ and
_render methods (not the other methods).
"""
def __init__(self, bin_datas=None, path='.'):
self.done = False
if bin_datas is None:
self.bin_datas = {}
else:
self.bin_datas = bin_datas
self.path = path
def _render(self):
return None
def render(self):
self.done = False
self._result = self._render()
self.done = True
return True
def is_done(self):
return self.done
def get(self):
if self.is_done():
return self._result
else:
return None
# 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,
3,
6827,
9689,
2005,
3510,
13,
2671,
3140,
402,
1808,
593,
899,
14918,
5805,
199,
3,
2104,
6696,
4681,
14,
199,
199,
3,
199,
3,
2654,
282,
1752,
462,
867,
3510,
13,
2671,
4045,
370,
1006,
3622,
14066,
9393,
199,
3,
199,
199,
3,
3254,
26,
1083,
370,
10952,
641,
314,
4543,
199,
533,
3795,
8,
785,
304,
272,
408,
21591,
282,
3622,
3906,
3769,
8018,
14,
2286,
768,
635,
2517,
63,
11563,
282,
2600,
402,
536,
16875,
3008,
1564,
30,
402,
5935,
5423,
14,
272,
768,
635,
931,
314,
931,
315,
1314,
3366,
1584,
883,
506,
24983,
12,
2997,
288,
367,
7323,
334,
4782,
9,
402,
314,
3622,
14,
2779,
883,
506,
26,
2049,
446,
282,
1059,
12,
3847,
503,
3679,
931,
370,
5935,
2049,
446,
282,
769,
12,
3035,
3326,
402,
3792,
14,
288,
982,
282,
1059,
365,
3679,
931,
12,
652,
911,
506,
12123,
465,
4066,
12,
587,
288,
652,
911,
506,
3032,
370,
7249,
14,
493,
63,
1490,
342,
1314,
2597,
7399,
7735,
3482,
288,
21293,
14,
339,
11774,
316,
3992,
1471,
5516,
642,
1021,
436,
295,
4640,
314,
636,
826,
363,
436,
272,
485,
3352,
3102,
334,
1397,
314,
1163,
3102,
680,
339,
408,
272,
347,
636,
826,
721,
277,
12,
2517,
63,
11563,
29,
403,
12,
931,
15637,
735,
267,
291,
14,
4456,
275,
756,
267,
340,
2517,
63,
11563,
365,
488,
26,
288,
291,
14,
1393,
63,
11563,
275,
1052,
267,
587,
26,
288,
291,
14,
1393,
63,
11563,
275,
2517,
63,
11563,
267,
291,
14,
515,
275,
931,
2286,
347,
485,
3352,
8,
277,
304,
267,
372,
488,
339,
347,
3795,
8,
277,
304,
267,
291,
14,
4456,
275,
756,
267,
291,
423,
1099,
275,
291,
423,
3352,
342,
267,
291,
14,
4456,
275,
715,
267,
372,
715,
2286,
347,
365,
63,
4456,
8,
277,
304,
267,
372,
291,
14,
4456,
339,
347,
664,
8,
277,
304,
267,
340,
291,
14,
374,
63,
4456,
837,
288,
372,
291,
423,
1099,
267,
587,
26,
288,
372,
488,
421,
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
] |
[
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,
3,
6827,
9689,
2005,
3510,
13,
2671,
3140,
402,
1808,
593,
899,
14918,
5805,
199,
3,
2104,
6696,
4681,
14,
199,
199,
3,
199,
3,
2654,
282,
1752,
462,
867,
3510,
13,
2671,
4045,
370,
1006,
3622,
14066,
9393,
199,
3,
199,
199,
3,
3254,
26,
1083,
370,
10952,
641,
314,
4543,
199,
533,
3795,
8,
785,
304,
272,
408,
21591,
282,
3622,
3906,
3769,
8018,
14,
2286,
768,
635,
2517,
63,
11563,
282,
2600,
402,
536,
16875,
3008,
1564,
30,
402,
5935,
5423,
14,
272,
768,
635,
931,
314,
931,
315,
1314,
3366,
1584,
883,
506,
24983,
12,
2997,
288,
367,
7323,
334,
4782,
9,
402,
314,
3622,
14,
2779,
883,
506,
26,
2049,
446,
282,
1059,
12,
3847,
503,
3679,
931,
370,
5935,
2049,
446,
282,
769,
12,
3035,
3326,
402,
3792,
14,
288,
982,
282,
1059,
365,
3679,
931,
12,
652,
911,
506,
12123,
465,
4066,
12,
587,
288,
652,
911,
506,
3032,
370,
7249,
14,
493,
63,
1490,
342,
1314,
2597,
7399,
7735,
3482,
288,
21293,
14,
339,
11774,
316,
3992,
1471,
5516,
642,
1021,
436,
295,
4640,
314,
636,
826,
363,
436,
272,
485,
3352,
3102,
334,
1397,
314,
1163,
3102,
680,
339,
408,
272,
347,
636,
826,
721,
277,
12,
2517,
63,
11563,
29,
403,
12,
931,
15637,
735,
267,
291,
14,
4456,
275,
756,
267,
340,
2517,
63,
11563,
365,
488,
26,
288,
291,
14,
1393,
63,
11563,
275,
1052,
267,
587,
26,
288,
291,
14,
1393,
63,
11563,
275,
2517,
63,
11563,
267,
291,
14,
515,
275,
931,
2286,
347,
485,
3352,
8,
277,
304,
267,
372,
488,
339,
347,
3795,
8,
277,
304,
267,
291,
14,
4456,
275,
756,
267,
291,
423,
1099,
275,
291,
423,
3352,
342,
267,
291,
14,
4456,
275,
715,
267,
372,
715,
2286,
347,
365,
63,
4456,
8,
277,
304,
267,
372,
291,
14,
4456,
339,
347,
664,
8,
277,
304,
267,
340,
291,
14,
374,
63,
4456,
837,
288,
372,
291,
423,
1099,
267,
587,
26,
288,
372,
488,
421,
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,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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
CCSS-CZ/layman
|
server/tests/layedtest.py
|
1
|
3969
|
import os,sys
import unittest
import ConfigParser
TEST_DIR = os.path.dirname(os.path.abspath(__file__))
INSTALL_DIR = os.path.abspath(os.path.join(TEST_DIR,".."))
sys.path.append(os.path.join(INSTALL_DIR))
import json
from layman.layed import LayEd
from layman.layed import GsRest
class LayEdTestCase(unittest.TestCase):
"""Test of the auth module"""
le = None # LayEd
workdir = None
cfg = None
def setUp(self):
cfg = ConfigParser.SafeConfigParser()
cfg.read((os.path.join(TEST_DIR,"tests.cfg")))
cfg.set("FileMan","testdir",TEST_DIR)
self.le = LayEd(cfg)
self.gsr = GsRest(cfg)
self.config = cfg
self.workdir = os.path.abspath(os.path.join(TEST_DIR,"workdir","data"))
# TODO: add tests for POST /layed?myLayer
def test_01_publish(self):
# ff = "world_cities_point.shp" # file
# ll = "world_cities_point" # layer
# st = "world_cities_point" # style
# ff = "pest.shp" # file
# ll = "pest" # layer
# st = "pest" # style
ff = "line_crs.shp" # file
ll = "line_crs" # layer
st = "line_crs" # style
ws = "mis" # workspace
ds = "testschema" # datastore
sch = "testschema" # schema
# Check #
# Check if the layer is not already there
(head, cont) = self.gsr.getLayer(ws, ll)
self.assertNotEquals("200", head["status"], "The layer already exists. Please, remove it manually." )
# Check if the style is not already there
(head, cont) = self.gsr.getStyle(ws, st)
self.assertNotEquals("200", head["status"], "The style already exists. Please, remove it manually." )
# Publish #
self.le.publish(fsUserDir=self.workdir, fsGroupDir="", dbSchema=ds, gsWorkspace=ws, fileName=ff)
# Test #
# Check if the layer is there
(head, cont) = self.gsr.getLayer(ws, ll)
self.assertEquals("200", head["status"], "The layer is not there. Was it created under another name?")
# Check the style of the layer
layerJson = json.loads(cont)
styleName = layerJson["layer"]["defaultStyle"]["name"]
self.assertEquals(st, styleName, "The layer is there, but it has wrong style assinged.")
# Check if the style is there
(head, cont) = self.gsr.getStyle(ws, st)
self.assertEquals("200", head["status"], "The style is not there." )
#def test_02_delete(self):
# Checks #
# Check that the layer is there
#(head, cont) = self.gsr.getLayer("dragouni", "line_crs")
#self.assertEquals("200", head["status"], "The layer line_crs is not there. Was it created under another name?")
# Check that the style is there
#(head, cont) = self.gsr.getStyle("dragouni", "line_crs")
#self.assertEquals("200", head["status"], "The style line_crs is not there." )
# Delete #
# Delete layer (including feature type, style and datastore)
#self.le.deleteLayer(workspace="dragouni", layer="line_crs", deleteStore=True)
# Test #
# Check that the layer is not there
#(head, cont) = self.gsr.getLayer("dragouni", "line_crs")
#self.assertNotEquals("200", head["status"], "The layer line_crs still exists, should be already deleted." )
# Check that the style is not there
#(head, cont) = self.gsr.getStyle("dragouni", "line_crs")
#self.assertNotEquals("200", head["status"], "The style line_crs already exists, should be already deleted." )
# Check that the data store is not there
#(head, cont) = self.gsr.getDataStore("dragouni", "line_crs")
#self.assertNotEquals("200", head["status"], "The data store line_crs already exists, should be already deleted." )
if __name__ == "__main__":
suite = unittest.TestLoader().loadTestsFromTestCase(LayEdTestCase)
unittest.TextTestRunner(verbosity=2).run(suite)
|
gpl-3.0
|
[
646,
747,
12,
1274,
199,
646,
2882,
199,
646,
14196,
199,
199,
2864,
63,
3022,
275,
747,
14,
515,
14,
3475,
8,
736,
14,
515,
14,
4832,
3460,
493,
8964,
199,
16811,
63,
3022,
275,
747,
14,
515,
14,
4832,
8,
736,
14,
515,
14,
904,
8,
2864,
63,
3022,
4589,
703,
2237,
199,
1274,
14,
515,
14,
740,
8,
736,
14,
515,
14,
904,
8,
16811,
63,
3022,
430,
199,
199,
646,
2022,
199,
504,
27305,
1237,
14,
817,
379,
492,
9366,
8751,
199,
504,
27305,
1237,
14,
817,
379,
492,
598,
83,
13726,
199,
199,
533,
9366,
8751,
1746,
8,
2796,
14,
1746,
304,
272,
408,
774,
402,
314,
1790,
859,
624,
339,
1026,
275,
488,
327,
9366,
8751,
272,
1736,
694,
275,
488,
272,
4810,
275,
488,
339,
347,
3613,
8,
277,
304,
267,
4810,
275,
14196,
14,
11090,
15218,
342,
267,
4810,
14,
739,
1332,
736,
14,
515,
14,
904,
8,
2864,
63,
3022,
4589,
2219,
14,
4128,
13324,
267,
4810,
14,
409,
480,
1173,
2395,
2266,
16634,
401,
2864,
63,
3022,
9,
267,
291,
14,
274,
275,
9366,
8751,
8,
4128,
9,
267,
291,
14,
458,
82,
275,
598,
83,
13726,
8,
4128,
9,
267,
291,
14,
888,
275,
4810,
267,
291,
14,
19132,
275,
747,
14,
515,
14,
4832,
8,
736,
14,
515,
14,
904,
8,
2864,
63,
3022,
4589,
19132,
2266,
576,
2237,
339,
327,
3254,
26,
1050,
2295,
367,
8761,
1182,
817,
379,
31,
1662,
5003,
339,
347,
511,
63,
614,
63,
4763,
8,
277,
304,
199,
199,
3,
263,
16328,
275,
298,
7617,
63,
18207,
63,
1403,
14,
17299,
2,
327,
570,
199,
3,
263,
18338,
275,
298,
7617,
63,
18207,
63,
1403,
2,
327,
4045,
199,
3,
263,
410,
275,
298,
7617,
63,
18207,
63,
1403,
2,
327,
3449,
199,
3,
263,
16328,
275,
298,
321,
270,
14,
17299,
2,
327,
570,
199,
3,
263,
18338,
275,
298,
321,
270,
2,
327,
4045,
199,
3,
263,
410,
275,
298,
321,
270,
2,
327,
3449,
267,
16328,
275,
298,
604,
63,
19034,
14,
17299,
2,
327,
570,
267,
18338,
275,
298,
604,
63,
19034,
2,
327,
4045,
267,
410,
275,
298,
604,
63,
19034,
2,
327,
3449,
267,
10900,
275,
298,
1292,
2,
327,
14466,
267,
6364,
275,
298,
2219,
2095,
2,
327,
12007,
267,
308,
335,
275,
298,
2219,
2095,
2,
327,
4177,
260,
398,
327,
2670,
327,
398,
327,
2670,
340,
314,
4045,
365,
440,
2575,
2337,
267,
334,
2993,
12,
13770,
9,
275,
291,
14,
458,
82,
14,
362,
5003,
8,
3569,
12,
18338,
9,
267,
291,
14,
7418,
83,
480,
1840,
401,
4854,
905,
1205,
2255,
298,
1918,
4045,
2575,
3495,
14,
7754,
12,
2813,
652,
10250,
2122,
776,
398,
327,
2670,
340,
314,
3449,
365,
440,
2575,
2337,
267,
334,
2993,
12,
13770,
9,
275,
291,
14,
458,
82,
14,
362,
6609,
8,
3569,
12,
410,
9,
267,
291,
14,
7418,
83,
480,
1840,
401,
4854,
905,
1205,
2255,
298,
1918,
3449,
2575,
3495,
14,
7754,
12,
2813,
652,
10250,
2122,
776,
398,
327,
19952,
327,
398,
291,
14,
274,
14,
4763,
8,
2319,
1899,
3567,
29,
277,
14,
19132,
12,
7449,
2448,
3567,
8772,
1592,
6700,
29,
795,
12,
8763,
21058,
29,
3569,
12,
18305,
29,
556,
9,
398,
327,
1379,
327,
398,
327,
2670,
340,
314,
4045,
365,
2337,
267,
334,
2993,
12,
13770,
9,
275,
291,
14,
458,
82,
14,
362,
5003,
8,
3569,
12,
18338,
9,
267,
291,
14,
2947,
480,
1840,
401,
4854,
905,
1205,
2255,
298,
1918,
4045,
365,
440,
2337,
14,
644,
305,
652,
2737,
1334,
4573,
536,
18582,
398,
327,
2670,
314,
3449,
402,
314,
4045,
267,
4045,
9653,
275,
2022,
14,
3640,
8,
11096,
9,
267,
3449,
985,
275,
4045,
9653,
905,
1897,
6611,
885,
6609,
6611,
354,
937,
267,
291,
14,
2947,
8,
270,
12,
3449,
985,
12,
298,
1918,
4045,
365,
2337,
12,
1325,
652,
965,
6835,
3449,
2661,
262,
3046,
2685,
398,
327,
2670,
340,
314,
3449,
365,
2337,
267,
334,
2993,
12,
13770,
9,
275,
291,
14,
458,
82,
14,
362,
6609,
8,
3569,
12,
410,
9,
267,
291,
14,
2947,
480,
1840,
401,
4854,
905,
1205,
2255,
298,
1918,
3449,
365,
440,
2337,
2122,
776,
339,
327,
318,
511,
63,
996,
63,
1807,
8,
277,
304,
398,
327,
13813,
327,
398,
327,
2670,
626,
314,
4045,
365,
2337,
267,
21571,
2993,
12,
13770,
9,
275,
291,
14,
458,
82,
14,
362,
5003,
480,
28385,
1939,
5411,
401,
298,
604,
63,
19034,
531,
267,
327,
277,
14,
2947,
480,
1840,
401,
4854,
905,
1205,
2255,
298,
1918,
4045,
1004,
63,
19034,
365,
440,
2337,
14,
644,
305,
652,
2737,
1334,
4573,
536,
18582,
398,
327,
2670,
626,
314,
3449,
365,
2337,
267,
21571,
2993,
12,
13770,
9,
275,
291,
14,
458,
82,
14,
362,
6609,
480,
28385,
1939,
5411,
401,
298,
604,
63,
19034,
531,
267,
327,
277,
14,
2947,
480,
1840,
401,
4854,
905,
1205,
2255,
298,
1918,
3449,
1004,
63,
19034,
365,
440,
2337,
2122,
776,
398,
327,
8496,
327,
398,
327,
8496,
4045,
334,
15768,
3878,
730,
12,
3449,
436,
12007,
9,
267,
327,
277,
14,
274,
14,
1807,
5003,
8,
13249,
628,
28385,
1939,
5411,
401,
4045,
628,
604,
63,
19034,
401,
3145,
5502,
29,
549,
9,
398,
327,
1379,
327,
398,
327,
2670,
626,
314,
4045,
365,
440,
2337,
267,
21571,
2993,
12,
13770,
9,
275,
291,
14,
458,
82,
14,
362,
5003,
480,
28385,
1939,
5411,
401,
298,
604,
63,
19034,
531,
267,
327,
277,
14,
7418,
83,
480,
1840,
401,
4854,
905,
1205,
2255,
298,
1918,
4045,
1004,
63,
19034,
5139,
3495,
12,
1077,
506,
2575,
5463,
2122,
776,
398,
327,
2670,
626,
314,
3449,
365,
440,
2337,
267,
21571,
2993,
12,
13770,
9,
275,
291,
14,
458,
82,
14,
362,
6609,
480,
28385,
1939,
5411,
401,
298,
604,
63,
19034,
531,
267,
327,
277,
14,
7418,
83,
480,
1840,
401,
4854,
905,
1205,
2255,
298,
1918,
3449,
1004,
63,
19034,
2575,
3495,
12,
1077,
506,
2575,
5463,
2122,
776,
398,
327,
2670,
626,
314,
666,
3877,
365,
440,
2337,
267,
21571,
2993,
12,
13770,
9,
275,
291,
14,
458
] |
[
747,
12,
1274,
199,
646,
2882,
199,
646,
14196,
199,
199,
2864,
63,
3022,
275,
747,
14,
515,
14,
3475,
8,
736,
14,
515,
14,
4832,
3460,
493,
8964,
199,
16811,
63,
3022,
275,
747,
14,
515,
14,
4832,
8,
736,
14,
515,
14,
904,
8,
2864,
63,
3022,
4589,
703,
2237,
199,
1274,
14,
515,
14,
740,
8,
736,
14,
515,
14,
904,
8,
16811,
63,
3022,
430,
199,
199,
646,
2022,
199,
504,
27305,
1237,
14,
817,
379,
492,
9366,
8751,
199,
504,
27305,
1237,
14,
817,
379,
492,
598,
83,
13726,
199,
199,
533,
9366,
8751,
1746,
8,
2796,
14,
1746,
304,
272,
408,
774,
402,
314,
1790,
859,
624,
339,
1026,
275,
488,
327,
9366,
8751,
272,
1736,
694,
275,
488,
272,
4810,
275,
488,
339,
347,
3613,
8,
277,
304,
267,
4810,
275,
14196,
14,
11090,
15218,
342,
267,
4810,
14,
739,
1332,
736,
14,
515,
14,
904,
8,
2864,
63,
3022,
4589,
2219,
14,
4128,
13324,
267,
4810,
14,
409,
480,
1173,
2395,
2266,
16634,
401,
2864,
63,
3022,
9,
267,
291,
14,
274,
275,
9366,
8751,
8,
4128,
9,
267,
291,
14,
458,
82,
275,
598,
83,
13726,
8,
4128,
9,
267,
291,
14,
888,
275,
4810,
267,
291,
14,
19132,
275,
747,
14,
515,
14,
4832,
8,
736,
14,
515,
14,
904,
8,
2864,
63,
3022,
4589,
19132,
2266,
576,
2237,
339,
327,
3254,
26,
1050,
2295,
367,
8761,
1182,
817,
379,
31,
1662,
5003,
339,
347,
511,
63,
614,
63,
4763,
8,
277,
304,
199,
199,
3,
263,
16328,
275,
298,
7617,
63,
18207,
63,
1403,
14,
17299,
2,
327,
570,
199,
3,
263,
18338,
275,
298,
7617,
63,
18207,
63,
1403,
2,
327,
4045,
199,
3,
263,
410,
275,
298,
7617,
63,
18207,
63,
1403,
2,
327,
3449,
199,
3,
263,
16328,
275,
298,
321,
270,
14,
17299,
2,
327,
570,
199,
3,
263,
18338,
275,
298,
321,
270,
2,
327,
4045,
199,
3,
263,
410,
275,
298,
321,
270,
2,
327,
3449,
267,
16328,
275,
298,
604,
63,
19034,
14,
17299,
2,
327,
570,
267,
18338,
275,
298,
604,
63,
19034,
2,
327,
4045,
267,
410,
275,
298,
604,
63,
19034,
2,
327,
3449,
267,
10900,
275,
298,
1292,
2,
327,
14466,
267,
6364,
275,
298,
2219,
2095,
2,
327,
12007,
267,
308,
335,
275,
298,
2219,
2095,
2,
327,
4177,
260,
398,
327,
2670,
327,
398,
327,
2670,
340,
314,
4045,
365,
440,
2575,
2337,
267,
334,
2993,
12,
13770,
9,
275,
291,
14,
458,
82,
14,
362,
5003,
8,
3569,
12,
18338,
9,
267,
291,
14,
7418,
83,
480,
1840,
401,
4854,
905,
1205,
2255,
298,
1918,
4045,
2575,
3495,
14,
7754,
12,
2813,
652,
10250,
2122,
776,
398,
327,
2670,
340,
314,
3449,
365,
440,
2575,
2337,
267,
334,
2993,
12,
13770,
9,
275,
291,
14,
458,
82,
14,
362,
6609,
8,
3569,
12,
410,
9,
267,
291,
14,
7418,
83,
480,
1840,
401,
4854,
905,
1205,
2255,
298,
1918,
3449,
2575,
3495,
14,
7754,
12,
2813,
652,
10250,
2122,
776,
398,
327,
19952,
327,
398,
291,
14,
274,
14,
4763,
8,
2319,
1899,
3567,
29,
277,
14,
19132,
12,
7449,
2448,
3567,
8772,
1592,
6700,
29,
795,
12,
8763,
21058,
29,
3569,
12,
18305,
29,
556,
9,
398,
327,
1379,
327,
398,
327,
2670,
340,
314,
4045,
365,
2337,
267,
334,
2993,
12,
13770,
9,
275,
291,
14,
458,
82,
14,
362,
5003,
8,
3569,
12,
18338,
9,
267,
291,
14,
2947,
480,
1840,
401,
4854,
905,
1205,
2255,
298,
1918,
4045,
365,
440,
2337,
14,
644,
305,
652,
2737,
1334,
4573,
536,
18582,
398,
327,
2670,
314,
3449,
402,
314,
4045,
267,
4045,
9653,
275,
2022,
14,
3640,
8,
11096,
9,
267,
3449,
985,
275,
4045,
9653,
905,
1897,
6611,
885,
6609,
6611,
354,
937,
267,
291,
14,
2947,
8,
270,
12,
3449,
985,
12,
298,
1918,
4045,
365,
2337,
12,
1325,
652,
965,
6835,
3449,
2661,
262,
3046,
2685,
398,
327,
2670,
340,
314,
3449,
365,
2337,
267,
334,
2993,
12,
13770,
9,
275,
291,
14,
458,
82,
14,
362,
6609,
8,
3569,
12,
410,
9,
267,
291,
14,
2947,
480,
1840,
401,
4854,
905,
1205,
2255,
298,
1918,
3449,
365,
440,
2337,
2122,
776,
339,
327,
318,
511,
63,
996,
63,
1807,
8,
277,
304,
398,
327,
13813,
327,
398,
327,
2670,
626,
314,
4045,
365,
2337,
267,
21571,
2993,
12,
13770,
9,
275,
291,
14,
458,
82,
14,
362,
5003,
480,
28385,
1939,
5411,
401,
298,
604,
63,
19034,
531,
267,
327,
277,
14,
2947,
480,
1840,
401,
4854,
905,
1205,
2255,
298,
1918,
4045,
1004,
63,
19034,
365,
440,
2337,
14,
644,
305,
652,
2737,
1334,
4573,
536,
18582,
398,
327,
2670,
626,
314,
3449,
365,
2337,
267,
21571,
2993,
12,
13770,
9,
275,
291,
14,
458,
82,
14,
362,
6609,
480,
28385,
1939,
5411,
401,
298,
604,
63,
19034,
531,
267,
327,
277,
14,
2947,
480,
1840,
401,
4854,
905,
1205,
2255,
298,
1918,
3449,
1004,
63,
19034,
365,
440,
2337,
2122,
776,
398,
327,
8496,
327,
398,
327,
8496,
4045,
334,
15768,
3878,
730,
12,
3449,
436,
12007,
9,
267,
327,
277,
14,
274,
14,
1807,
5003,
8,
13249,
628,
28385,
1939,
5411,
401,
4045,
628,
604,
63,
19034,
401,
3145,
5502,
29,
549,
9,
398,
327,
1379,
327,
398,
327,
2670,
626,
314,
4045,
365,
440,
2337,
267,
21571,
2993,
12,
13770,
9,
275,
291,
14,
458,
82,
14,
362,
5003,
480,
28385,
1939,
5411,
401,
298,
604,
63,
19034,
531,
267,
327,
277,
14,
7418,
83,
480,
1840,
401,
4854,
905,
1205,
2255,
298,
1918,
4045,
1004,
63,
19034,
5139,
3495,
12,
1077,
506,
2575,
5463,
2122,
776,
398,
327,
2670,
626,
314,
3449,
365,
440,
2337,
267,
21571,
2993,
12,
13770,
9,
275,
291,
14,
458,
82,
14,
362,
6609,
480,
28385,
1939,
5411,
401,
298,
604,
63,
19034,
531,
267,
327,
277,
14,
7418,
83,
480,
1840,
401,
4854,
905,
1205,
2255,
298,
1918,
3449,
1004,
63,
19034,
2575,
3495,
12,
1077,
506,
2575,
5463,
2122,
776,
398,
327,
2670,
626,
314,
666,
3877,
365,
440,
2337,
267,
21571,
2993,
12,
13770,
9,
275,
291,
14,
458,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
nzavagli/UnrealPy
|
UnrealPyEmbed/Development/Python/2015.08.07-Python2710-x64-Source-vs2015/Python27/Source/Python-2.7.10/Lib/test/test_curses.py
|
44
|
9518
|
#
# Test script for the curses module
#
# This script doesn't actually display anything very coherent. but it
# does call every method and function.
#
# Functions not tested: {def,reset}_{shell,prog}_mode, getch(), getstr(),
# init_color()
# Only called, not tested: getmouse(), ungetmouse()
#
import sys, tempfile, os
# Optionally test curses module. This currently requires that the
# 'curses' resource be given on the regrtest command line using the -u
# option. If not available, nothing after this line will be executed.
import unittest
from test.test_support import requires, import_module
requires('curses')
curses = import_module('curses')
curses.panel = import_module('curses.panel')
# XXX: if newterm was supported we could use it instead of initscr and not exit
term = os.environ.get('TERM')
if not term or term == 'unknown':
raise unittest.SkipTest, "$TERM=%r, calling initscr() may cause exit" % term
if sys.platform == "cygwin":
raise unittest.SkipTest("cygwin's curses mostly just hangs")
def window_funcs(stdscr):
"Test the methods of windows"
win = curses.newwin(10,10)
win = curses.newwin(5,5, 5,5)
win2 = curses.newwin(15,15, 5,5)
for meth in [stdscr.addch, stdscr.addstr]:
for args in [('a'), ('a', curses.A_BOLD),
(4,4, 'a'), (5,5, 'a', curses.A_BOLD)]:
meth(*args)
for meth in [stdscr.box, stdscr.clear, stdscr.clrtobot,
stdscr.clrtoeol, stdscr.cursyncup, stdscr.delch,
stdscr.deleteln, stdscr.erase, stdscr.getbegyx,
stdscr.getbkgd, stdscr.getkey, stdscr.getmaxyx,
stdscr.getparyx, stdscr.getyx, stdscr.inch,
stdscr.insertln, stdscr.instr, stdscr.is_wintouched,
win.noutrefresh, stdscr.redrawwin, stdscr.refresh,
stdscr.standout, stdscr.standend, stdscr.syncdown,
stdscr.syncup, stdscr.touchwin, stdscr.untouchwin]:
meth()
stdscr.addnstr('1234', 3)
stdscr.addnstr('1234', 3, curses.A_BOLD)
stdscr.addnstr(4,4, '1234', 3)
stdscr.addnstr(5,5, '1234', 3, curses.A_BOLD)
stdscr.attron(curses.A_BOLD)
stdscr.attroff(curses.A_BOLD)
stdscr.attrset(curses.A_BOLD)
stdscr.bkgd(' ')
stdscr.bkgd(' ', curses.A_REVERSE)
stdscr.bkgdset(' ')
stdscr.bkgdset(' ', curses.A_REVERSE)
win.border(65, 66, 67, 68,
69, 70, 71, 72)
win.border('|', '!', '-', '_',
'+', '\\', '#', '/')
try:
win.border(65, 66, 67, 68,
69, [], 71, 72)
except TypeError:
pass
else:
raise RuntimeError, "Expected win.border() to raise TypeError"
stdscr.clearok(1)
win4 = stdscr.derwin(2,2)
win4 = stdscr.derwin(1,1, 5,5)
win4.mvderwin(9,9)
stdscr.echochar('a')
stdscr.echochar('a', curses.A_BOLD)
stdscr.hline('-', 5)
stdscr.hline('-', 5, curses.A_BOLD)
stdscr.hline(1,1,'-', 5)
stdscr.hline(1,1,'-', 5, curses.A_BOLD)
stdscr.idcok(1)
stdscr.idlok(1)
stdscr.immedok(1)
stdscr.insch('c')
stdscr.insdelln(1)
stdscr.insnstr('abc', 3)
stdscr.insnstr('abc', 3, curses.A_BOLD)
stdscr.insnstr(5, 5, 'abc', 3)
stdscr.insnstr(5, 5, 'abc', 3, curses.A_BOLD)
stdscr.insstr('def')
stdscr.insstr('def', curses.A_BOLD)
stdscr.insstr(5, 5, 'def')
stdscr.insstr(5, 5, 'def', curses.A_BOLD)
stdscr.is_linetouched(0)
stdscr.keypad(1)
stdscr.leaveok(1)
stdscr.move(3,3)
win.mvwin(2,2)
stdscr.nodelay(1)
stdscr.notimeout(1)
win2.overlay(win)
win2.overwrite(win)
win2.overlay(win, 1, 2, 3, 3, 2, 1)
win2.overwrite(win, 1, 2, 3, 3, 2, 1)
stdscr.redrawln(1,2)
stdscr.scrollok(1)
stdscr.scroll()
stdscr.scroll(2)
stdscr.scroll(-3)
stdscr.move(12, 2)
stdscr.setscrreg(10,15)
win3 = stdscr.subwin(10,10)
win3 = stdscr.subwin(10,10, 5,5)
stdscr.syncok(1)
stdscr.timeout(5)
stdscr.touchline(5,5)
stdscr.touchline(5,5,0)
stdscr.vline('a', 3)
stdscr.vline('a', 3, curses.A_STANDOUT)
stdscr.chgat(5, 2, 3, curses.A_BLINK)
stdscr.chgat(3, curses.A_BOLD)
stdscr.chgat(5, 8, curses.A_UNDERLINE)
stdscr.chgat(curses.A_BLINK)
stdscr.refresh()
stdscr.vline(1,1, 'a', 3)
stdscr.vline(1,1, 'a', 3, curses.A_STANDOUT)
if hasattr(curses, 'resize'):
stdscr.resize()
if hasattr(curses, 'enclose'):
stdscr.enclose()
def module_funcs(stdscr):
"Test module-level functions"
for func in [curses.baudrate, curses.beep, curses.can_change_color,
curses.cbreak, curses.def_prog_mode, curses.doupdate,
curses.filter, curses.flash, curses.flushinp,
curses.has_colors, curses.has_ic, curses.has_il,
curses.isendwin, curses.killchar, curses.longname,
curses.nocbreak, curses.noecho, curses.nonl,
curses.noqiflush, curses.noraw,
curses.reset_prog_mode, curses.termattrs,
curses.termname, curses.erasechar, curses.getsyx]:
func()
# Functions that actually need arguments
if curses.tigetstr("cnorm"):
curses.curs_set(1)
curses.delay_output(1)
curses.echo() ; curses.echo(1)
f = tempfile.TemporaryFile()
stdscr.putwin(f)
f.seek(0)
curses.getwin(f)
f.close()
curses.halfdelay(1)
curses.intrflush(1)
curses.meta(1)
curses.napms(100)
curses.newpad(50,50)
win = curses.newwin(5,5)
win = curses.newwin(5,5, 1,1)
curses.nl() ; curses.nl(1)
curses.putp('abc')
curses.qiflush()
curses.raw() ; curses.raw(1)
curses.setsyx(5,5)
curses.tigetflag('hc')
curses.tigetnum('co')
curses.tigetstr('cr')
curses.tparm('cr')
curses.typeahead(sys.__stdin__.fileno())
curses.unctrl('a')
curses.ungetch('a')
curses.use_env(1)
# Functions only available on a few platforms
if curses.has_colors():
curses.start_color()
curses.init_pair(2, 1,1)
curses.color_content(1)
curses.color_pair(2)
curses.pair_content(curses.COLOR_PAIRS - 1)
curses.pair_number(0)
if hasattr(curses, 'use_default_colors'):
curses.use_default_colors()
if hasattr(curses, 'keyname'):
curses.keyname(13)
if hasattr(curses, 'has_key'):
curses.has_key(13)
if hasattr(curses, 'getmouse'):
(availmask, oldmask) = curses.mousemask(curses.BUTTON1_PRESSED)
# availmask indicates that mouse stuff not available.
if availmask != 0:
curses.mouseinterval(10)
# just verify these don't cause errors
curses.ungetmouse(0, 0, 0, 0, curses.BUTTON1_PRESSED)
m = curses.getmouse()
if hasattr(curses, 'is_term_resized'):
curses.is_term_resized(*stdscr.getmaxyx())
if hasattr(curses, 'resizeterm'):
curses.resizeterm(*stdscr.getmaxyx())
if hasattr(curses, 'resize_term'):
curses.resize_term(*stdscr.getmaxyx())
def unit_tests():
from curses import ascii
for ch, expected in [('a', 'a'), ('A', 'A'),
(';', ';'), (' ', ' '),
('\x7f', '^?'), ('\n', '^J'), ('\0', '^@'),
# Meta-bit characters
('\x8a', '!^J'), ('\xc1', '!A'),
]:
if ascii.unctrl(ch) != expected:
print 'curses.unctrl fails on character', repr(ch)
def test_userptr_without_set(stdscr):
w = curses.newwin(10, 10)
p = curses.panel.new_panel(w)
# try to access userptr() before calling set_userptr() -- segfaults
try:
p.userptr()
raise RuntimeError, 'userptr should fail since not set'
except curses.panel.error:
pass
def test_userptr_memory_leak(stdscr):
w = curses.newwin(10, 10)
p = curses.panel.new_panel(w)
obj = object()
nrefs = sys.getrefcount(obj)
for i in range(100):
p.set_userptr(obj)
p.set_userptr(None)
if sys.getrefcount(obj) != nrefs:
raise RuntimeError, "set_userptr leaked references"
def test_userptr_segfault(stdscr):
panel = curses.panel.new_panel(stdscr)
class A:
def __del__(self):
panel.set_userptr(None)
panel.set_userptr(A())
panel.set_userptr(None)
def test_resize_term(stdscr):
if hasattr(curses, 'resizeterm'):
lines, cols = curses.LINES, curses.COLS
curses.resizeterm(lines - 1, cols + 1)
if curses.LINES != lines - 1 or curses.COLS != cols + 1:
raise RuntimeError, "Expected resizeterm to update LINES and COLS"
def test_issue6243(stdscr):
curses.ungetch(1025)
stdscr.getkey()
def main(stdscr):
curses.savetty()
try:
module_funcs(stdscr)
window_funcs(stdscr)
test_userptr_without_set(stdscr)
test_userptr_memory_leak(stdscr)
test_userptr_segfault(stdscr)
test_resize_term(stdscr)
test_issue6243(stdscr)
finally:
curses.resetty()
if __name__ == '__main__':
curses.wrapper(main)
unit_tests()
else:
if not sys.__stdout__.isatty():
raise unittest.SkipTest("sys.__stdout__ is not a tty")
# testing setupterm() inside initscr/endwin
# causes terminal breakage
curses.setupterm(fd=sys.__stdout__.fileno())
try:
stdscr = curses.initscr()
main(stdscr)
finally:
curses.endwin()
unit_tests()
|
mit
|
[
3,
199,
3,
1379,
2884,
367,
314,
15429,
859,
199,
3,
199,
3,
961,
2884,
3181,
1133,
5965,
2929,
7003,
7437,
512,
426,
640,
14,
1325,
652,
199,
3,
1630,
1240,
4036,
1083,
436,
805,
14,
199,
3,
199,
3,
17471,
440,
12470,
26,
469,
318,
12,
3958,
26738,
5641,
12,
6595,
12585,
632,
12,
664,
335,
1062,
664,
495,
1062,
199,
3,
4205,
63,
2326,
342,
199,
3,
5972,
2797,
12,
440,
12470,
26,
664,
10544,
1062,
625,
362,
10544,
342,
199,
3,
199,
199,
646,
984,
12,
5549,
12,
747,
199,
199,
3,
22383,
511,
15429,
859,
14,
221,
961,
5544,
5074,
626,
314,
199,
3,
283,
12026,
7,
2073,
506,
1627,
641,
314,
1295,
82,
396,
1414,
1004,
1808,
314,
446,
85,
199,
3,
945,
14,
221,
982,
440,
2808,
12,
6548,
2410,
642,
1004,
911,
506,
7934,
14,
199,
199,
646,
2882,
199,
504,
511,
14,
396,
63,
4058,
492,
5074,
12,
492,
63,
578,
199,
6537,
360,
12026,
358,
199,
12026,
275,
492,
63,
578,
360,
12026,
358,
199,
12026,
14,
7885,
275,
492,
63,
578,
360,
12026,
14,
7885,
358,
421,
199,
3,
5787,
26,
340,
892,
5125,
1990,
3748,
781,
4293,
675,
652,
3140,
402,
4205,
11047,
436,
440,
4458,
199,
5125,
275,
747,
14,
2314,
14,
362,
360,
16718,
358,
199,
692,
440,
6707,
503,
6707,
508,
283,
5187,
356,
272,
746,
2882,
14,
25755,
12,
7880,
16718,
2458,
82,
12,
6358,
4205,
11047,
342,
1443,
7675,
4458,
2,
450,
6707,
199,
199,
692,
984,
14,
3246,
508,
298,
16680,
582,
272,
746,
2882,
14,
25755,
480,
16680,
1159,
15429,
19762,
2951,
394,
20068,
531,
199,
199,
318,
4353,
63,
9204,
8,
1516,
11047,
304,
272,
298,
774,
314,
3102,
402,
10061,
2,
272,
4747,
275,
15429,
14,
1222,
2676,
8,
709,
12,
709,
9,
272,
4747,
275,
15429,
14,
1222,
2676,
8,
21,
12,
21,
12,
959,
12,
21,
9,
272,
4747,
18,
275,
15429,
14,
1222,
2676,
8,
1046,
12,
1046,
12,
959,
12,
21,
9,
339,
367,
12750,
315,
359,
1516,
11047,
14,
525,
335,
12,
2418,
11047,
14,
525,
495,
2189,
267,
367,
1249,
315,
4274,
65,
659,
661,
65,
297,
15429,
14,
33,
63,
30144,
395,
2151,
334,
20,
12,
20,
12,
283,
65,
659,
334,
21,
12,
21,
12,
283,
65,
297,
15429,
14,
33,
63,
30144,
19532,
288,
12750,
2031,
589,
9,
339,
367,
12750,
315,
359,
1516,
11047,
14,
1977,
12,
2418,
11047,
14,
3584,
12,
2418,
11047,
14,
31553,
475,
3018,
12,
326,
2418,
11047,
14,
31553,
475,
20470,
12,
2418,
11047,
14,
895,
5186,
384,
12,
2418,
11047,
14,
2264,
335,
12,
326,
2418,
11047,
14,
1807,
6066,
12,
2418,
11047,
14,
22087,
12,
2418,
11047,
14,
362,
1235,
4312,
88,
12,
326,
2418,
11047,
14,
362,
18314,
7136,
12,
2418,
11047,
14,
362,
498,
12,
2418,
11047,
14,
362,
988,
20937,
12,
326,
2418,
11047,
14,
362,
462,
20937,
12,
2418,
11047,
14,
362,
20937,
12,
2418,
11047,
14,
28494,
12,
326,
2418,
11047,
14,
3176,
6066,
12,
2418,
11047,
14,
21309,
12,
2418,
11047,
14,
374,
63,
87,
442,
810,
1809,
12,
326,
4747,
14,
78,
548,
6635,
12,
2418,
11047,
14,
581,
345,
978,
262,
12,
2418,
11047,
14,
6635,
12,
326,
2418,
11047,
14,
7935,
548,
12,
2418,
11047,
14,
9746,
32588,
12,
2418,
11047,
14,
5186,
2110,
12,
326,
2418,
11047,
14,
5186,
384,
12,
2418,
11047,
14,
12376,
2676,
12,
2418,
11047,
14,
324,
12376,
2676,
2189,
267,
12750,
342,
339,
2418,
11047,
14,
525,
26838,
360,
4321,
297,
650,
9,
272,
2418,
11047,
14,
525,
26838,
360,
4321,
297,
650,
12,
15429,
14,
33,
63,
30144,
9,
272,
2418,
11047,
14,
525,
26838,
8,
20,
12,
20,
12,
283,
4321,
297,
650,
9,
272,
2418,
11047,
14,
525,
26838,
8,
21,
12,
21,
12,
283,
4321,
297,
650,
12,
15429,
14,
33,
63,
30144,
9,
339,
2418,
11047,
14,
962,
265,
8,
12026,
14,
33,
63,
30144,
9,
272,
2418,
11047,
14,
292,
1374,
556,
8,
12026,
14,
33,
63,
30144,
9,
272,
2418,
11047,
14,
962,
409,
8,
12026,
14,
33,
63,
30144,
9,
272,
2418,
11047,
14,
18314,
7136,
360,
5320,
272,
2418,
11047,
14,
18314,
7136,
360,
1656,
15429,
14,
33,
63,
907,
21233,
9,
272,
2418,
11047,
14,
18314,
7136,
409,
360,
5320,
272,
2418,
11047,
14,
18314,
7136,
409,
360,
1656,
15429,
14,
33,
63,
907,
21233,
9,
339,
4747,
14,
8665,
8,
2182,
12,
14157,
12,
13296,
12,
10851,
12,
2049,
14610,
12,
10045,
12,
17245,
12,
15323,
9,
272,
4747,
14,
8665,
20137,
297,
283,
12389,
17525,
25469,
2049,
32278,
6468,
297,
3943,
297,
15107,
272,
862,
26,
267,
4747,
14,
8665,
8,
2182,
12,
14157,
12,
13296,
12,
10851,
12,
673,
14610,
12,
990,
17245,
12,
15323,
9,
272,
871,
3146,
26,
267,
986,
272,
587,
26,
267,
746,
6064,
12,
298,
6964,
4747,
14,
8665,
342,
370,
746,
3146,
2,
339,
2418,
11047,
14,
3584,
745,
8,
17,
9,
339,
4747,
20,
275,
2418,
11047,
14,
424,
2676,
8,
18,
12,
18,
9,
272,
4747,
20,
275,
2418,
11047,
14,
424,
2676,
8,
17,
12,
17,
12,
959,
12,
21,
9,
272,
4747,
20,
14,
12393,
424,
2676,
8,
25,
12,
25,
9,
339,
2418,
11047,
14,
7878,
1560,
360,
65,
358,
272,
2418,
11047,
14,
7878,
1560,
360,
65,
297,
15429,
14,
33,
63,
30144,
9,
272,
2418,
11047,
14,
32625,
13858,
959,
9,
272,
2418,
11047,
14,
32625,
13858,
959,
12,
15429,
14,
33,
63,
30144,
9,
272,
2418,
11047,
14,
32625,
8,
17,
12,
17,
2584,
14382,
959,
9,
272,
2418,
11047,
14,
32625,
8,
17,
12,
17,
2584,
14382,
959,
12,
15429,
14,
33,
63,
30144,
9,
339,
2418,
11047,
14,
344,
331,
75,
8,
17,
9,
272,
2418,
11047,
14,
344,
320,
75,
8,
17,
9,
272,
2418,
11047,
14,
1017,
3594,
745,
8,
17,
9,
272,
2418,
11047,
14,
3617,
335,
360,
67,
358,
272,
2418,
11047,
14,
3617,
271,
914,
78,
8,
17,
9,
272,
2418,
11047,
14,
15738,
495,
360,
3175,
297,
650,
9,
272,
2418,
11047,
14,
15738,
495,
360,
3175
] |
[
199,
3,
1379,
2884,
367,
314,
15429,
859,
199,
3,
199,
3,
961,
2884,
3181,
1133,
5965,
2929,
7003,
7437,
512,
426,
640,
14,
1325,
652,
199,
3,
1630,
1240,
4036,
1083,
436,
805,
14,
199,
3,
199,
3,
17471,
440,
12470,
26,
469,
318,
12,
3958,
26738,
5641,
12,
6595,
12585,
632,
12,
664,
335,
1062,
664,
495,
1062,
199,
3,
4205,
63,
2326,
342,
199,
3,
5972,
2797,
12,
440,
12470,
26,
664,
10544,
1062,
625,
362,
10544,
342,
199,
3,
199,
199,
646,
984,
12,
5549,
12,
747,
199,
199,
3,
22383,
511,
15429,
859,
14,
221,
961,
5544,
5074,
626,
314,
199,
3,
283,
12026,
7,
2073,
506,
1627,
641,
314,
1295,
82,
396,
1414,
1004,
1808,
314,
446,
85,
199,
3,
945,
14,
221,
982,
440,
2808,
12,
6548,
2410,
642,
1004,
911,
506,
7934,
14,
199,
199,
646,
2882,
199,
504,
511,
14,
396,
63,
4058,
492,
5074,
12,
492,
63,
578,
199,
6537,
360,
12026,
358,
199,
12026,
275,
492,
63,
578,
360,
12026,
358,
199,
12026,
14,
7885,
275,
492,
63,
578,
360,
12026,
14,
7885,
358,
421,
199,
3,
5787,
26,
340,
892,
5125,
1990,
3748,
781,
4293,
675,
652,
3140,
402,
4205,
11047,
436,
440,
4458,
199,
5125,
275,
747,
14,
2314,
14,
362,
360,
16718,
358,
199,
692,
440,
6707,
503,
6707,
508,
283,
5187,
356,
272,
746,
2882,
14,
25755,
12,
7880,
16718,
2458,
82,
12,
6358,
4205,
11047,
342,
1443,
7675,
4458,
2,
450,
6707,
199,
199,
692,
984,
14,
3246,
508,
298,
16680,
582,
272,
746,
2882,
14,
25755,
480,
16680,
1159,
15429,
19762,
2951,
394,
20068,
531,
199,
199,
318,
4353,
63,
9204,
8,
1516,
11047,
304,
272,
298,
774,
314,
3102,
402,
10061,
2,
272,
4747,
275,
15429,
14,
1222,
2676,
8,
709,
12,
709,
9,
272,
4747,
275,
15429,
14,
1222,
2676,
8,
21,
12,
21,
12,
959,
12,
21,
9,
272,
4747,
18,
275,
15429,
14,
1222,
2676,
8,
1046,
12,
1046,
12,
959,
12,
21,
9,
339,
367,
12750,
315,
359,
1516,
11047,
14,
525,
335,
12,
2418,
11047,
14,
525,
495,
2189,
267,
367,
1249,
315,
4274,
65,
659,
661,
65,
297,
15429,
14,
33,
63,
30144,
395,
2151,
334,
20,
12,
20,
12,
283,
65,
659,
334,
21,
12,
21,
12,
283,
65,
297,
15429,
14,
33,
63,
30144,
19532,
288,
12750,
2031,
589,
9,
339,
367,
12750,
315,
359,
1516,
11047,
14,
1977,
12,
2418,
11047,
14,
3584,
12,
2418,
11047,
14,
31553,
475,
3018,
12,
326,
2418,
11047,
14,
31553,
475,
20470,
12,
2418,
11047,
14,
895,
5186,
384,
12,
2418,
11047,
14,
2264,
335,
12,
326,
2418,
11047,
14,
1807,
6066,
12,
2418,
11047,
14,
22087,
12,
2418,
11047,
14,
362,
1235,
4312,
88,
12,
326,
2418,
11047,
14,
362,
18314,
7136,
12,
2418,
11047,
14,
362,
498,
12,
2418,
11047,
14,
362,
988,
20937,
12,
326,
2418,
11047,
14,
362,
462,
20937,
12,
2418,
11047,
14,
362,
20937,
12,
2418,
11047,
14,
28494,
12,
326,
2418,
11047,
14,
3176,
6066,
12,
2418,
11047,
14,
21309,
12,
2418,
11047,
14,
374,
63,
87,
442,
810,
1809,
12,
326,
4747,
14,
78,
548,
6635,
12,
2418,
11047,
14,
581,
345,
978,
262,
12,
2418,
11047,
14,
6635,
12,
326,
2418,
11047,
14,
7935,
548,
12,
2418,
11047,
14,
9746,
32588,
12,
2418,
11047,
14,
5186,
2110,
12,
326,
2418,
11047,
14,
5186,
384,
12,
2418,
11047,
14,
12376,
2676,
12,
2418,
11047,
14,
324,
12376,
2676,
2189,
267,
12750,
342,
339,
2418,
11047,
14,
525,
26838,
360,
4321,
297,
650,
9,
272,
2418,
11047,
14,
525,
26838,
360,
4321,
297,
650,
12,
15429,
14,
33,
63,
30144,
9,
272,
2418,
11047,
14,
525,
26838,
8,
20,
12,
20,
12,
283,
4321,
297,
650,
9,
272,
2418,
11047,
14,
525,
26838,
8,
21,
12,
21,
12,
283,
4321,
297,
650,
12,
15429,
14,
33,
63,
30144,
9,
339,
2418,
11047,
14,
962,
265,
8,
12026,
14,
33,
63,
30144,
9,
272,
2418,
11047,
14,
292,
1374,
556,
8,
12026,
14,
33,
63,
30144,
9,
272,
2418,
11047,
14,
962,
409,
8,
12026,
14,
33,
63,
30144,
9,
272,
2418,
11047,
14,
18314,
7136,
360,
5320,
272,
2418,
11047,
14,
18314,
7136,
360,
1656,
15429,
14,
33,
63,
907,
21233,
9,
272,
2418,
11047,
14,
18314,
7136,
409,
360,
5320,
272,
2418,
11047,
14,
18314,
7136,
409,
360,
1656,
15429,
14,
33,
63,
907,
21233,
9,
339,
4747,
14,
8665,
8,
2182,
12,
14157,
12,
13296,
12,
10851,
12,
2049,
14610,
12,
10045,
12,
17245,
12,
15323,
9,
272,
4747,
14,
8665,
20137,
297,
283,
12389,
17525,
25469,
2049,
32278,
6468,
297,
3943,
297,
15107,
272,
862,
26,
267,
4747,
14,
8665,
8,
2182,
12,
14157,
12,
13296,
12,
10851,
12,
673,
14610,
12,
990,
17245,
12,
15323,
9,
272,
871,
3146,
26,
267,
986,
272,
587,
26,
267,
746,
6064,
12,
298,
6964,
4747,
14,
8665,
342,
370,
746,
3146,
2,
339,
2418,
11047,
14,
3584,
745,
8,
17,
9,
339,
4747,
20,
275,
2418,
11047,
14,
424,
2676,
8,
18,
12,
18,
9,
272,
4747,
20,
275,
2418,
11047,
14,
424,
2676,
8,
17,
12,
17,
12,
959,
12,
21,
9,
272,
4747,
20,
14,
12393,
424,
2676,
8,
25,
12,
25,
9,
339,
2418,
11047,
14,
7878,
1560,
360,
65,
358,
272,
2418,
11047,
14,
7878,
1560,
360,
65,
297,
15429,
14,
33,
63,
30144,
9,
272,
2418,
11047,
14,
32625,
13858,
959,
9,
272,
2418,
11047,
14,
32625,
13858,
959,
12,
15429,
14,
33,
63,
30144,
9,
272,
2418,
11047,
14,
32625,
8,
17,
12,
17,
2584,
14382,
959,
9,
272,
2418,
11047,
14,
32625,
8,
17,
12,
17,
2584,
14382,
959,
12,
15429,
14,
33,
63,
30144,
9,
339,
2418,
11047,
14,
344,
331,
75,
8,
17,
9,
272,
2418,
11047,
14,
344,
320,
75,
8,
17,
9,
272,
2418,
11047,
14,
1017,
3594,
745,
8,
17,
9,
272,
2418,
11047,
14,
3617,
335,
360,
67,
358,
272,
2418,
11047,
14,
3617,
271,
914,
78,
8,
17,
9,
272,
2418,
11047,
14,
15738,
495,
360,
3175,
297,
650,
9,
272,
2418,
11047,
14,
15738,
495,
360,
3175,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
NuttamonW/Archaeological
|
ElectricalConductivity/test/test_electrical_conductivity_dialog.py
|
1
|
1580
|
# coding=utf-8
"""Dialog test.
.. 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__ = 'p.pointt@hotmail.com'
__date__ = '2015-08-04'
__copyright__ = 'Copyright 2015, Point & June'
import unittest
from PyQt4.QtGui import QDialogButtonBox, QDialog
from electrical_conductivity_dialog import ElectricalConductivityDialog
from utilities import get_qgis_app
QGIS_APP = get_qgis_app()
class ElectricalConductivityDialogTest(unittest.TestCase):
"""Test dialog works."""
def setUp(self):
"""Runs before each test."""
self.dialog = ElectricalConductivityDialog(None)
def tearDown(self):
"""Runs after each test."""
self.dialog = None
def test_dialog_ok(self):
"""Test we can click OK."""
button = self.dialog.button_box.button(QDialogButtonBox.Ok)
button.click()
result = self.dialog.result()
self.assertEqual(result, QDialog.Accepted)
def test_dialog_cancel(self):
"""Test we can click cancel."""
button = self.dialog.button_box.button(QDialogButtonBox.Cancel)
button.click()
result = self.dialog.result()
self.assertEqual(result, QDialog.Rejected)
if __name__ == "__main__":
suite = unittest.makeSuite(ElectricalConductivityDialogTest)
runner = unittest.TextTestRunner(verbosity=2)
runner.run(suite)
|
gpl-3.0
|
[
3,
2803,
29,
1624,
13,
24,
199,
624,
5619,
511,
14,
199,
199,
703,
5317,
447,
961,
2240,
365,
2867,
2032,
27,
1265,
883,
3604,
652,
436,
15,
269,
2811,
1362,
652,
1334,
314,
2895,
402,
314,
1664,
1696,
1684,
844,
465,
3267,
701,
1362,
314,
2868,
2290,
2752,
27,
1902,
1015,
499,
402,
314,
844,
12,
503,
1362,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
199,
624,
199,
199,
363,
2502,
363,
275,
283,
80,
14,
1403,
84,
32,
8885,
1198,
14,
957,
7,
199,
363,
602,
363,
275,
283,
7806,
13,
2036,
13,
966,
7,
199,
363,
7307,
363,
275,
283,
7384,
6900,
12,
7584,
1253,
1603,
11474,
7,
199,
199,
646,
2882,
199,
199,
504,
14084,
20,
14,
10604,
492,
1413,
5619,
4259,
3532,
12,
1413,
5619,
199,
199,
504,
28933,
8825,
63,
2067,
947,
4191,
63,
7196,
492,
662,
1264,
8825,
714,
5905,
4191,
5619,
199,
199,
504,
15841,
492,
664,
63,
25325,
63,
571,
199,
31329,
63,
7121,
275,
664,
63,
25325,
63,
571,
342,
421,
199,
533,
662,
1264,
8825,
714,
5905,
4191,
5619,
774,
8,
2796,
14,
1746,
304,
272,
408,
774,
9592,
5419,
1041,
339,
347,
3613,
8,
277,
304,
267,
408,
16291,
2544,
1924,
511,
1041,
267,
291,
14,
7196,
275,
662,
1264,
8825,
714,
5905,
4191,
5619,
8,
403,
9,
339,
347,
6766,
8,
277,
304,
267,
408,
16291,
2410,
1924,
511,
1041,
267,
291,
14,
7196,
275,
488,
339,
347,
511,
63,
7196,
63,
745,
8,
277,
304,
267,
408,
774,
781,
883,
8968,
9949,
1041,
398,
5528,
275,
291,
14,
7196,
14,
3887,
63,
1977,
14,
3887,
8,
30983,
4259,
3532,
14,
11622,
9,
267,
5528,
14,
4891,
342,
267,
754,
275,
291,
14,
7196,
14,
1099,
342,
267,
291,
14,
629,
8,
1099,
12,
1413,
5619,
14,
1945,
7203,
9,
339,
347,
511,
63,
7196,
63,
6406,
8,
277,
304,
267,
408,
774,
781,
883,
8968,
9311,
1041,
267,
5528,
275,
291,
14,
7196,
14,
3887,
63,
1977,
14,
3887,
8,
30983,
4259,
3532,
14,
9083,
9,
267,
5528,
14,
4891,
342,
267,
754,
275,
291,
14,
7196,
14,
1099,
342,
267,
291,
14,
629,
8,
1099,
12,
1413,
5619,
14,
497,
8553,
9,
199,
199,
692,
636,
354,
363,
508,
4396,
973,
5727,
272,
5241,
275,
2882,
14,
18275,
8,
37,
1264,
8825,
714,
5905,
4191,
5619,
774,
9,
272,
7876,
275,
2882,
14,
24285,
8,
9833,
29,
18,
9,
272,
7876,
14,
1065,
8,
5768,
9,
421,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
2803,
29,
1624,
13,
24,
199,
624,
5619,
511,
14,
199,
199,
703,
5317,
447,
961,
2240,
365,
2867,
2032,
27,
1265,
883,
3604,
652,
436,
15,
269,
2811,
1362,
652,
1334,
314,
2895,
402,
314,
1664,
1696,
1684,
844,
465,
3267,
701,
1362,
314,
2868,
2290,
2752,
27,
1902,
1015,
499,
402,
314,
844,
12,
503,
1362,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
199,
624,
199,
199,
363,
2502,
363,
275,
283,
80,
14,
1403,
84,
32,
8885,
1198,
14,
957,
7,
199,
363,
602,
363,
275,
283,
7806,
13,
2036,
13,
966,
7,
199,
363,
7307,
363,
275,
283,
7384,
6900,
12,
7584,
1253,
1603,
11474,
7,
199,
199,
646,
2882,
199,
199,
504,
14084,
20,
14,
10604,
492,
1413,
5619,
4259,
3532,
12,
1413,
5619,
199,
199,
504,
28933,
8825,
63,
2067,
947,
4191,
63,
7196,
492,
662,
1264,
8825,
714,
5905,
4191,
5619,
199,
199,
504,
15841,
492,
664,
63,
25325,
63,
571,
199,
31329,
63,
7121,
275,
664,
63,
25325,
63,
571,
342,
421,
199,
533,
662,
1264,
8825,
714,
5905,
4191,
5619,
774,
8,
2796,
14,
1746,
304,
272,
408,
774,
9592,
5419,
1041,
339,
347,
3613,
8,
277,
304,
267,
408,
16291,
2544,
1924,
511,
1041,
267,
291,
14,
7196,
275,
662,
1264,
8825,
714,
5905,
4191,
5619,
8,
403,
9,
339,
347,
6766,
8,
277,
304,
267,
408,
16291,
2410,
1924,
511,
1041,
267,
291,
14,
7196,
275,
488,
339,
347,
511,
63,
7196,
63,
745,
8,
277,
304,
267,
408,
774,
781,
883,
8968,
9949,
1041,
398,
5528,
275,
291,
14,
7196,
14,
3887,
63,
1977,
14,
3887,
8,
30983,
4259,
3532,
14,
11622,
9,
267,
5528,
14,
4891,
342,
267,
754,
275,
291,
14,
7196,
14,
1099,
342,
267,
291,
14,
629,
8,
1099,
12,
1413,
5619,
14,
1945,
7203,
9,
339,
347,
511,
63,
7196,
63,
6406,
8,
277,
304,
267,
408,
774,
781,
883,
8968,
9311,
1041,
267,
5528,
275,
291,
14,
7196,
14,
3887,
63,
1977,
14,
3887,
8,
30983,
4259,
3532,
14,
9083,
9,
267,
5528,
14,
4891,
342,
267,
754,
275,
291,
14,
7196,
14,
1099,
342,
267,
291,
14,
629,
8,
1099,
12,
1413,
5619,
14,
497,
8553,
9,
199,
199,
692,
636,
354,
363,
508,
4396,
973,
5727,
272,
5241,
275,
2882,
14,
18275,
8,
37,
1264,
8825,
714,
5905,
4191,
5619,
774,
9,
272,
7876,
275,
2882,
14,
24285,
8,
9833,
29,
18,
9,
272,
7876,
14,
1065,
8,
5768,
9,
421,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
nthiep/global-ssh-server
|
lib/python2.7/site-packages/django/contrib/gis/geos/tests/test_mutable_list.py
|
102
|
15029
|
# Copyright (c) 2008-2009 Aryeh Leib Taurog, http://www.aryehleib.com
# All rights reserved.
#
# Modified from original contribution by Aryeh Leib Taurog, which was
# released under the New BSD license.
from django.contrib.gis.geos.mutable_list import ListMixin
from django.utils import six
from django.utils import unittest
class UserListA(ListMixin):
_mytype = tuple
def __init__(self, i_list, *args, **kwargs):
self._list = self._mytype(i_list)
super(UserListA, self).__init__(*args, **kwargs)
def __len__(self): return len(self._list)
def __str__(self): return str(self._list)
def __repr__(self): return repr(self._list)
def _set_list(self, length, items):
# this would work:
# self._list = self._mytype(items)
# but then we wouldn't be testing length parameter
itemList = ['x'] * length
for i, v in enumerate(items):
itemList[i] = v
self._list = self._mytype(itemList)
def _get_single_external(self, index):
return self._list[index]
class UserListB(UserListA):
_mytype = list
def _set_single(self, index, value):
self._list[index] = value
def nextRange(length):
nextRange.start += 100
return range(nextRange.start, nextRange.start + length)
nextRange.start = 0
class ListMixinTest(unittest.TestCase):
"""
Tests base class ListMixin by comparing a list clone which is
a ListMixin subclass with a real Python list.
"""
limit = 3
listType = UserListA
def lists_of_len(self, length=None):
if length is None: length = self.limit
pl = list(range(length))
return pl, self.listType(pl)
def limits_plus(self, b):
return range(-self.limit - b, self.limit + b)
def step_range(self):
return list(range(-1 - self.limit, 0)) + list(range(1, 1 + self.limit))
def test01_getslice(self):
'Slice retrieval'
pl, ul = self.lists_of_len()
for i in self.limits_plus(1):
self.assertEqual(pl[i:], ul[i:], 'slice [%d:]' % (i))
self.assertEqual(pl[:i], ul[:i], 'slice [:%d]' % (i))
for j in self.limits_plus(1):
self.assertEqual(pl[i:j], ul[i:j], 'slice [%d:%d]' % (i,j))
for k in self.step_range():
self.assertEqual(pl[i:j:k], ul[i:j:k], 'slice [%d:%d:%d]' % (i,j,k))
for k in self.step_range():
self.assertEqual(pl[i::k], ul[i::k], 'slice [%d::%d]' % (i,k))
self.assertEqual(pl[:i:k], ul[:i:k], 'slice [:%d:%d]' % (i,k))
for k in self.step_range():
self.assertEqual(pl[::k], ul[::k], 'slice [::%d]' % (k))
def test02_setslice(self):
'Slice assignment'
def setfcn(x,i,j,k,L): x[i:j:k] = range(L)
pl, ul = self.lists_of_len()
for slen in range(self.limit + 1):
ssl = nextRange(slen)
ul[:] = ssl
pl[:] = ssl
self.assertEqual(pl, ul[:], 'set slice [:]')
for i in self.limits_plus(1):
ssl = nextRange(slen)
ul[i:] = ssl
pl[i:] = ssl
self.assertEqual(pl, ul[:], 'set slice [%d:]' % (i))
ssl = nextRange(slen)
ul[:i] = ssl
pl[:i] = ssl
self.assertEqual(pl, ul[:], 'set slice [:%d]' % (i))
for j in self.limits_plus(1):
ssl = nextRange(slen)
ul[i:j] = ssl
pl[i:j] = ssl
self.assertEqual(pl, ul[:], 'set slice [%d:%d]' % (i, j))
for k in self.step_range():
ssl = nextRange( len(ul[i:j:k]) )
ul[i:j:k] = ssl
pl[i:j:k] = ssl
self.assertEqual(pl, ul[:], 'set slice [%d:%d:%d]' % (i, j, k))
sliceLen = len(ul[i:j:k])
self.assertRaises(ValueError, setfcn, ul, i, j, k, sliceLen + 1)
if sliceLen > 2:
self.assertRaises(ValueError, setfcn, ul, i, j, k, sliceLen - 1)
for k in self.step_range():
ssl = nextRange( len(ul[i::k]) )
ul[i::k] = ssl
pl[i::k] = ssl
self.assertEqual(pl, ul[:], 'set slice [%d::%d]' % (i, k))
ssl = nextRange( len(ul[:i:k]) )
ul[:i:k] = ssl
pl[:i:k] = ssl
self.assertEqual(pl, ul[:], 'set slice [:%d:%d]' % (i, k))
for k in self.step_range():
ssl = nextRange(len(ul[::k]))
ul[::k] = ssl
pl[::k] = ssl
self.assertEqual(pl, ul[:], 'set slice [::%d]' % (k))
def test03_delslice(self):
'Delete slice'
for Len in range(self.limit):
pl, ul = self.lists_of_len(Len)
del pl[:]
del ul[:]
self.assertEqual(pl[:], ul[:], 'del slice [:]')
for i in range(-Len - 1, Len + 1):
pl, ul = self.lists_of_len(Len)
del pl[i:]
del ul[i:]
self.assertEqual(pl[:], ul[:], 'del slice [%d:]' % (i))
pl, ul = self.lists_of_len(Len)
del pl[:i]
del ul[:i]
self.assertEqual(pl[:], ul[:], 'del slice [:%d]' % (i))
for j in range(-Len - 1, Len + 1):
pl, ul = self.lists_of_len(Len)
del pl[i:j]
del ul[i:j]
self.assertEqual(pl[:], ul[:], 'del slice [%d:%d]' % (i,j))
for k in list(range(-Len - 1, 0)) + list(range(1, Len)):
pl, ul = self.lists_of_len(Len)
del pl[i:j:k]
del ul[i:j:k]
self.assertEqual(pl[:], ul[:], 'del slice [%d:%d:%d]' % (i,j,k))
for k in list(range(-Len - 1, 0)) + list(range(1, Len)):
pl, ul = self.lists_of_len(Len)
del pl[:i:k]
del ul[:i:k]
self.assertEqual(pl[:], ul[:], 'del slice [:%d:%d]' % (i,k))
pl, ul = self.lists_of_len(Len)
del pl[i::k]
del ul[i::k]
self.assertEqual(pl[:], ul[:], 'del slice [%d::%d]' % (i,k))
for k in list(range(-Len - 1, 0)) + list(range(1, Len)):
pl, ul = self.lists_of_len(Len)
del pl[::k]
del ul[::k]
self.assertEqual(pl[:], ul[:], 'del slice [::%d]' % (k))
def test04_get_set_del_single(self):
'Get/set/delete single item'
pl, ul = self.lists_of_len()
for i in self.limits_plus(0):
self.assertEqual(pl[i], ul[i], 'get single item [%d]' % i)
for i in self.limits_plus(0):
pl, ul = self.lists_of_len()
pl[i] = 100
ul[i] = 100
self.assertEqual(pl[:], ul[:], 'set single item [%d]' % i)
for i in self.limits_plus(0):
pl, ul = self.lists_of_len()
del pl[i]
del ul[i]
self.assertEqual(pl[:], ul[:], 'del single item [%d]' % i)
def test05_out_of_range_exceptions(self):
'Out of range exceptions'
def setfcn(x, i): x[i] = 20
def getfcn(x, i): return x[i]
def delfcn(x, i): del x[i]
pl, ul = self.lists_of_len()
for i in (-1 - self.limit, self.limit):
self.assertRaises(IndexError, setfcn, ul, i) # 'set index %d' % i)
self.assertRaises(IndexError, getfcn, ul, i) # 'get index %d' % i)
self.assertRaises(IndexError, delfcn, ul, i) # 'del index %d' % i)
def test06_list_methods(self):
'List methods'
pl, ul = self.lists_of_len()
pl.append(40)
ul.append(40)
self.assertEqual(pl[:], ul[:], 'append')
pl.extend(range(50,55))
ul.extend(range(50,55))
self.assertEqual(pl[:], ul[:], 'extend')
pl.reverse()
ul.reverse()
self.assertEqual(pl[:], ul[:], 'reverse')
for i in self.limits_plus(1):
pl, ul = self.lists_of_len()
pl.insert(i,50)
ul.insert(i,50)
self.assertEqual(pl[:], ul[:], 'insert at %d' % i)
for i in self.limits_plus(0):
pl, ul = self.lists_of_len()
self.assertEqual(pl.pop(i), ul.pop(i), 'popped value at %d' % i)
self.assertEqual(pl[:], ul[:], 'after pop at %d' % i)
pl, ul = self.lists_of_len()
self.assertEqual(pl.pop(), ul.pop(i), 'popped value')
self.assertEqual(pl[:], ul[:], 'after pop')
pl, ul = self.lists_of_len()
def popfcn(x, i): x.pop(i)
self.assertRaises(IndexError, popfcn, ul, self.limit)
self.assertRaises(IndexError, popfcn, ul, -1 - self.limit)
pl, ul = self.lists_of_len()
for val in range(self.limit):
self.assertEqual(pl.index(val), ul.index(val), 'index of %d' % val)
for val in self.limits_plus(2):
self.assertEqual(pl.count(val), ul.count(val), 'count %d' % val)
for val in range(self.limit):
pl, ul = self.lists_of_len()
pl.remove(val)
ul.remove(val)
self.assertEqual(pl[:], ul[:], 'after remove val %d' % val)
def indexfcn(x, v): return x.index(v)
def removefcn(x, v): return x.remove(v)
self.assertRaises(ValueError, indexfcn, ul, 40)
self.assertRaises(ValueError, removefcn, ul, 40)
def test07_allowed_types(self):
'Type-restricted list'
pl, ul = self.lists_of_len()
ul._allowed = six.integer_types
ul[1] = 50
ul[:2] = [60, 70, 80]
def setfcn(x, i, v): x[i] = v
self.assertRaises(TypeError, setfcn, ul, 2, 'hello')
self.assertRaises(TypeError, setfcn, ul, slice(0,3,2), ('hello','goodbye'))
def test08_min_length(self):
'Length limits'
pl, ul = self.lists_of_len()
ul._minlength = 1
def delfcn(x,i): del x[:i]
def setfcn(x,i): x[:i] = []
for i in range(self.limit - ul._minlength + 1, self.limit + 1):
self.assertRaises(ValueError, delfcn, ul, i)
self.assertRaises(ValueError, setfcn, ul, i)
del ul[:ul._minlength]
ul._maxlength = 4
for i in range(0, ul._maxlength - len(ul)):
ul.append(i)
self.assertRaises(ValueError, ul.append, 10)
def test09_iterable_check(self):
'Error on assigning non-iterable to slice'
pl, ul = self.lists_of_len(self.limit + 1)
def setfcn(x, i, v): x[i] = v
self.assertRaises(TypeError, setfcn, ul, slice(0,3,2), 2)
def test10_checkindex(self):
'Index check'
pl, ul = self.lists_of_len()
for i in self.limits_plus(0):
if i < 0:
self.assertEqual(ul._checkindex(i), i + self.limit, '_checkindex(neg index)')
else:
self.assertEqual(ul._checkindex(i), i, '_checkindex(pos index)')
for i in (-self.limit - 1, self.limit):
self.assertRaises(IndexError, ul._checkindex, i)
ul._IndexError = TypeError
self.assertRaises(TypeError, ul._checkindex, -self.limit - 1)
def test_11_sorting(self):
'Sorting'
pl, ul = self.lists_of_len()
pl.insert(0, pl.pop())
ul.insert(0, ul.pop())
pl.sort()
ul.sort()
self.assertEqual(pl[:], ul[:], 'sort')
mid = pl[len(pl) // 2]
pl.sort(key=lambda x: (mid-x)**2)
ul.sort(key=lambda x: (mid-x)**2)
self.assertEqual(pl[:], ul[:], 'sort w/ key')
pl.insert(0, pl.pop())
ul.insert(0, ul.pop())
pl.sort(reverse=True)
ul.sort(reverse=True)
self.assertEqual(pl[:], ul[:], 'sort w/ reverse')
mid = pl[len(pl) // 2]
pl.sort(key=lambda x: (mid-x)**2)
ul.sort(key=lambda x: (mid-x)**2)
self.assertEqual(pl[:], ul[:], 'sort w/ key')
def test_12_arithmetic(self):
'Arithmetic'
pl, ul = self.lists_of_len()
al = list(range(10,14))
self.assertEqual(list(pl + al), list(ul + al), 'add')
self.assertEqual(type(ul), type(ul + al), 'type of add result')
self.assertEqual(list(al + pl), list(al + ul), 'radd')
self.assertEqual(type(al), type(al + ul), 'type of radd result')
objid = id(ul)
pl += al
ul += al
self.assertEqual(pl[:], ul[:], 'in-place add')
self.assertEqual(objid, id(ul), 'in-place add id')
for n in (-1,0,1,3):
pl, ul = self.lists_of_len()
self.assertEqual(list(pl * n), list(ul * n), 'mul by %d' % n)
self.assertEqual(type(ul), type(ul * n), 'type of mul by %d result' % n)
self.assertEqual(list(n * pl), list(n * ul), 'rmul by %d' % n)
self.assertEqual(type(ul), type(n * ul), 'type of rmul by %d result' % n)
objid = id(ul)
pl *= n
ul *= n
self.assertEqual(pl[:], ul[:], 'in-place mul by %d' % n)
self.assertEqual(objid, id(ul), 'in-place mul by %d id' % n)
pl, ul = self.lists_of_len()
self.assertEqual(pl, ul, 'cmp for equal')
self.assertFalse(ul == pl + [2], 'cmp for not equal')
self.assertTrue(pl >= ul, 'cmp for gte self')
self.assertTrue(pl <= ul, 'cmp for lte self')
self.assertTrue(ul >= pl, 'cmp for self gte')
self.assertTrue(ul <= pl, 'cmp for self lte')
self.assertTrue(pl + [5] > ul, 'cmp')
self.assertTrue(pl + [5] >= ul, 'cmp')
self.assertTrue(pl < ul + [2], 'cmp')
self.assertTrue(pl <= ul + [2], 'cmp')
self.assertTrue(ul + [5] > pl, 'cmp')
self.assertTrue(ul + [5] >= pl, 'cmp')
self.assertTrue(ul < pl + [2], 'cmp')
self.assertTrue(ul <= pl + [2], 'cmp')
# Also works with a custom IndexError
ul_longer = ul + [2]
ul_longer._IndexError = TypeError
ul._IndexError = TypeError
self.assertFalse(ul_longer == pl)
self.assertFalse(ul == ul_longer)
self.assertTrue(ul_longer > ul)
pl[1] = 20
self.assertTrue(pl > ul, 'cmp for gt self')
self.assertTrue(ul < pl, 'cmp for self lt')
pl[1] = -20
self.assertTrue(pl < ul, 'cmp for lt self')
self.assertTrue(pl < ul, 'cmp for lt self')
class ListMixinTestSingle(ListMixinTest):
listType = UserListB
def suite():
s = unittest.TestSuite()
s.addTest(unittest.makeSuite(ListMixinTest))
s.addTest(unittest.makeSuite(ListMixinTestSingle))
return s
def run(verbosity=2):
unittest.TextTestRunner(verbosity=verbosity).run(suite())
if __name__ == '__main__':
run()
|
agpl-3.0
|
[
3,
1898,
334,
67,
9,
9079,
13,
8664,
437,
651,
24528,
7005,
1892,
377,
3844,
19029,
12,
1455,
921,
1544,
14,
695,
24528,
274,
1892,
14,
957,
199,
3,
2900,
4481,
4644,
14,
199,
3,
199,
3,
22016,
687,
3379,
406,
15980,
701,
437,
651,
24528,
7005,
1892,
377,
3844,
19029,
12,
1314,
1990,
199,
3,
14286,
1334,
314,
7053,
6289,
4190,
14,
199,
504,
1639,
14,
2828,
14,
5668,
14,
12151,
14,
17404,
63,
513,
492,
3820,
4256,
199,
504,
1639,
14,
1208,
492,
3816,
199,
504,
1639,
14,
1208,
492,
2882,
421,
199,
533,
28639,
33,
8,
1296,
4256,
304,
272,
485,
1662,
466,
275,
2008,
272,
347,
636,
826,
721,
277,
12,
284,
63,
513,
12,
627,
589,
12,
1011,
958,
304,
267,
291,
423,
513,
275,
291,
423,
1662,
466,
8,
73,
63,
513,
9,
267,
1613,
8,
1899,
1296,
33,
12,
291,
2843,
826,
9308,
589,
12,
1011,
958,
9,
339,
347,
636,
552,
721,
277,
304,
221,
372,
822,
8,
277,
423,
513,
9,
339,
347,
636,
495,
721,
277,
304,
221,
372,
620,
8,
277,
423,
513,
9,
339,
347,
636,
2722,
721,
277,
304,
372,
4700,
8,
277,
423,
513,
9,
339,
347,
485,
409,
63,
513,
8,
277,
12,
2582,
12,
2974,
304,
267,
327,
642,
3955,
1736,
26,
267,
327,
291,
423,
513,
275,
291,
423,
1662,
466,
8,
1744,
9,
267,
327,
1325,
2066,
781,
3955,
78,
1133,
506,
5343,
2582,
2725,
267,
1242,
1296,
275,
788,
88,
418,
627,
2582,
267,
367,
284,
12,
373,
315,
3874,
8,
1744,
304,
288,
1242,
1296,
59,
73,
61,
275,
373,
398,
291,
423,
513,
275,
291,
423,
1662,
466,
8,
1053,
1296,
9,
339,
347,
485,
362,
63,
4780,
63,
5159,
8,
277,
12,
1478,
304,
267,
372,
291,
423,
513,
59,
1080,
61,
199,
199,
533,
28639,
34,
8,
1899,
1296,
33,
304,
272,
485,
1662,
466,
275,
769,
339,
347,
485,
409,
63,
4780,
8,
277,
12,
1478,
12,
574,
304,
267,
291,
423,
513,
59,
1080,
61,
275,
574,
199,
199,
318,
2163,
4709,
8,
1267,
304,
272,
2163,
4709,
14,
928,
847,
2948,
272,
372,
1425,
8,
2184,
4709,
14,
928,
12,
2163,
4709,
14,
928,
435,
2582,
9,
199,
199,
2184,
4709,
14,
928,
275,
378,
199,
199,
533,
3820,
4256,
774,
8,
2796,
14,
1746,
304,
272,
408,
272,
6496,
1300,
1021,
3820,
4256,
701,
20234,
282,
769,
7289,
1314,
365,
272,
282,
3820,
4256,
5516,
543,
282,
3363,
2018,
769,
14,
272,
408,
272,
2304,
275,
650,
272,
769,
804,
275,
28639,
33,
339,
347,
5548,
63,
1618,
63,
552,
8,
277,
12,
2582,
29,
403,
304,
267,
340,
2582,
365,
488,
26,
2582,
275,
291,
14,
3097,
267,
1620,
275,
769,
8,
1842,
8,
1267,
430,
267,
372,
1620,
12,
291,
14,
513,
804,
8,
1168,
9,
339,
347,
10976,
63,
6666,
8,
277,
12,
330,
304,
267,
372,
1425,
2801,
277,
14,
3097,
446,
330,
12,
291,
14,
3097,
435,
330,
9,
339,
347,
3650,
63,
1842,
8,
277,
304,
267,
372,
769,
8,
1842,
2801,
17,
446,
291,
14,
3097,
12,
378,
430,
435,
769,
8,
1842,
8,
17,
12,
413,
435,
291,
14,
3097,
430,
339,
347,
511,
614,
63,
32131,
8,
277,
304,
267,
283,
14034,
27157,
7,
267,
1620,
12,
12581,
275,
291,
14,
6717,
63,
1618,
63,
552,
342,
267,
367,
284,
315,
291,
14,
9368,
63,
6666,
8,
17,
304,
288,
291,
14,
629,
8,
1168,
59,
73,
8429,
12581,
59,
73,
8429,
283,
5224,
8978,
68,
2938,
7,
450,
334,
73,
430,
288,
291,
14,
629,
8,
1168,
1491,
73,
467,
12581,
1491,
73,
467,
283,
5224,
359,
2689,
68,
6616,
450,
334,
73,
430,
953,
367,
1335,
315,
291,
14,
9368,
63,
6666,
8,
17,
304,
355,
291,
14,
629,
8,
1168,
59,
73,
26,
74,
467,
12581,
59,
73,
26,
74,
467,
283,
5224,
8978,
68,
2689,
68,
6616,
450,
334,
73,
12,
74,
430,
355,
367,
1022,
315,
291,
14,
2926,
63,
1842,
837,
490,
291,
14,
629,
8,
1168,
59,
73,
26,
74,
26,
75,
467,
12581,
59,
73,
26,
74,
26,
75,
467,
283,
5224,
8978,
68,
2689,
68,
2689,
68,
6616,
450,
334,
73,
12,
74,
12,
75,
430,
953,
367,
1022,
315,
291,
14,
2926,
63,
1842,
837,
355,
291,
14,
629,
8,
1168,
59,
73,
447,
75,
467,
12581,
59,
73,
447,
75,
467,
283,
5224,
8978,
68,
447,
5,
68,
6616,
450,
334,
73,
12,
75,
430,
355,
291,
14,
629,
8,
1168,
1491,
73,
26,
75,
467,
12581,
1491,
73,
26,
75,
467,
283,
5224,
359,
2689,
68,
2689,
68,
6616,
450,
334,
73,
12,
75,
430,
398,
367,
1022,
315,
291,
14,
2926,
63,
1842,
837,
288,
291,
14,
629,
8,
1168,
10345,
75,
467,
12581,
10345,
75,
467,
283,
5224,
359,
447,
5,
68,
6616,
450,
334,
75,
430,
339,
347,
511,
996,
63,
2193,
3037,
8,
277,
304,
267,
283,
14034,
9801,
7,
267,
347,
663,
26554,
8,
88,
12,
73,
12,
74,
12,
75,
12,
44,
304,
671,
59,
73,
26,
74,
26,
75,
61,
275,
1425,
8,
44,
9,
267,
1620,
12,
12581,
275,
291,
14,
6717,
63,
1618,
63,
552,
342,
267,
367,
308,
552,
315,
1425,
8,
277,
14,
3097,
435,
413,
304,
288,
6149,
275,
2163,
4709,
8,
83,
552,
9,
288,
12581,
5873,
275,
6149,
288,
1620,
5873,
275,
6149,
288,
291,
14,
629,
8,
1168,
12,
12581,
23315,
283,
409,
6014,
359,
2938,
358,
953,
367,
284,
315,
291,
14,
9368,
63,
6666,
8,
17,
304,
355,
6149,
275,
2163,
4709,
8,
83,
552,
9,
355,
12581,
59,
73,
2938,
275,
6149,
355,
1620,
59,
73,
2938,
275,
6149,
355,
291,
14,
629,
8,
1168,
12,
12581,
23315,
283,
409,
6014,
8978,
68,
2938,
7,
450,
334,
73,
430,
2234,
6149,
275,
2163,
4709,
8,
83,
552,
9,
355,
12581,
1491,
73,
61,
275,
6149,
355,
1620,
1491,
73,
61,
275,
6149,
355,
291,
14,
629,
8,
1168,
12,
12581,
23315,
283,
409,
6014,
359,
2689,
68,
6616,
450,
334,
73,
430,
2234,
367,
1335,
315,
291,
14
] |
[
1898,
334,
67,
9,
9079,
13,
8664,
437,
651,
24528,
7005,
1892,
377,
3844,
19029,
12,
1455,
921,
1544,
14,
695,
24528,
274,
1892,
14,
957,
199,
3,
2900,
4481,
4644,
14,
199,
3,
199,
3,
22016,
687,
3379,
406,
15980,
701,
437,
651,
24528,
7005,
1892,
377,
3844,
19029,
12,
1314,
1990,
199,
3,
14286,
1334,
314,
7053,
6289,
4190,
14,
199,
504,
1639,
14,
2828,
14,
5668,
14,
12151,
14,
17404,
63,
513,
492,
3820,
4256,
199,
504,
1639,
14,
1208,
492,
3816,
199,
504,
1639,
14,
1208,
492,
2882,
421,
199,
533,
28639,
33,
8,
1296,
4256,
304,
272,
485,
1662,
466,
275,
2008,
272,
347,
636,
826,
721,
277,
12,
284,
63,
513,
12,
627,
589,
12,
1011,
958,
304,
267,
291,
423,
513,
275,
291,
423,
1662,
466,
8,
73,
63,
513,
9,
267,
1613,
8,
1899,
1296,
33,
12,
291,
2843,
826,
9308,
589,
12,
1011,
958,
9,
339,
347,
636,
552,
721,
277,
304,
221,
372,
822,
8,
277,
423,
513,
9,
339,
347,
636,
495,
721,
277,
304,
221,
372,
620,
8,
277,
423,
513,
9,
339,
347,
636,
2722,
721,
277,
304,
372,
4700,
8,
277,
423,
513,
9,
339,
347,
485,
409,
63,
513,
8,
277,
12,
2582,
12,
2974,
304,
267,
327,
642,
3955,
1736,
26,
267,
327,
291,
423,
513,
275,
291,
423,
1662,
466,
8,
1744,
9,
267,
327,
1325,
2066,
781,
3955,
78,
1133,
506,
5343,
2582,
2725,
267,
1242,
1296,
275,
788,
88,
418,
627,
2582,
267,
367,
284,
12,
373,
315,
3874,
8,
1744,
304,
288,
1242,
1296,
59,
73,
61,
275,
373,
398,
291,
423,
513,
275,
291,
423,
1662,
466,
8,
1053,
1296,
9,
339,
347,
485,
362,
63,
4780,
63,
5159,
8,
277,
12,
1478,
304,
267,
372,
291,
423,
513,
59,
1080,
61,
199,
199,
533,
28639,
34,
8,
1899,
1296,
33,
304,
272,
485,
1662,
466,
275,
769,
339,
347,
485,
409,
63,
4780,
8,
277,
12,
1478,
12,
574,
304,
267,
291,
423,
513,
59,
1080,
61,
275,
574,
199,
199,
318,
2163,
4709,
8,
1267,
304,
272,
2163,
4709,
14,
928,
847,
2948,
272,
372,
1425,
8,
2184,
4709,
14,
928,
12,
2163,
4709,
14,
928,
435,
2582,
9,
199,
199,
2184,
4709,
14,
928,
275,
378,
199,
199,
533,
3820,
4256,
774,
8,
2796,
14,
1746,
304,
272,
408,
272,
6496,
1300,
1021,
3820,
4256,
701,
20234,
282,
769,
7289,
1314,
365,
272,
282,
3820,
4256,
5516,
543,
282,
3363,
2018,
769,
14,
272,
408,
272,
2304,
275,
650,
272,
769,
804,
275,
28639,
33,
339,
347,
5548,
63,
1618,
63,
552,
8,
277,
12,
2582,
29,
403,
304,
267,
340,
2582,
365,
488,
26,
2582,
275,
291,
14,
3097,
267,
1620,
275,
769,
8,
1842,
8,
1267,
430,
267,
372,
1620,
12,
291,
14,
513,
804,
8,
1168,
9,
339,
347,
10976,
63,
6666,
8,
277,
12,
330,
304,
267,
372,
1425,
2801,
277,
14,
3097,
446,
330,
12,
291,
14,
3097,
435,
330,
9,
339,
347,
3650,
63,
1842,
8,
277,
304,
267,
372,
769,
8,
1842,
2801,
17,
446,
291,
14,
3097,
12,
378,
430,
435,
769,
8,
1842,
8,
17,
12,
413,
435,
291,
14,
3097,
430,
339,
347,
511,
614,
63,
32131,
8,
277,
304,
267,
283,
14034,
27157,
7,
267,
1620,
12,
12581,
275,
291,
14,
6717,
63,
1618,
63,
552,
342,
267,
367,
284,
315,
291,
14,
9368,
63,
6666,
8,
17,
304,
288,
291,
14,
629,
8,
1168,
59,
73,
8429,
12581,
59,
73,
8429,
283,
5224,
8978,
68,
2938,
7,
450,
334,
73,
430,
288,
291,
14,
629,
8,
1168,
1491,
73,
467,
12581,
1491,
73,
467,
283,
5224,
359,
2689,
68,
6616,
450,
334,
73,
430,
953,
367,
1335,
315,
291,
14,
9368,
63,
6666,
8,
17,
304,
355,
291,
14,
629,
8,
1168,
59,
73,
26,
74,
467,
12581,
59,
73,
26,
74,
467,
283,
5224,
8978,
68,
2689,
68,
6616,
450,
334,
73,
12,
74,
430,
355,
367,
1022,
315,
291,
14,
2926,
63,
1842,
837,
490,
291,
14,
629,
8,
1168,
59,
73,
26,
74,
26,
75,
467,
12581,
59,
73,
26,
74,
26,
75,
467,
283,
5224,
8978,
68,
2689,
68,
2689,
68,
6616,
450,
334,
73,
12,
74,
12,
75,
430,
953,
367,
1022,
315,
291,
14,
2926,
63,
1842,
837,
355,
291,
14,
629,
8,
1168,
59,
73,
447,
75,
467,
12581,
59,
73,
447,
75,
467,
283,
5224,
8978,
68,
447,
5,
68,
6616,
450,
334,
73,
12,
75,
430,
355,
291,
14,
629,
8,
1168,
1491,
73,
26,
75,
467,
12581,
1491,
73,
26,
75,
467,
283,
5224,
359,
2689,
68,
2689,
68,
6616,
450,
334,
73,
12,
75,
430,
398,
367,
1022,
315,
291,
14,
2926,
63,
1842,
837,
288,
291,
14,
629,
8,
1168,
10345,
75,
467,
12581,
10345,
75,
467,
283,
5224,
359,
447,
5,
68,
6616,
450,
334,
75,
430,
339,
347,
511,
996,
63,
2193,
3037,
8,
277,
304,
267,
283,
14034,
9801,
7,
267,
347,
663,
26554,
8,
88,
12,
73,
12,
74,
12,
75,
12,
44,
304,
671,
59,
73,
26,
74,
26,
75,
61,
275,
1425,
8,
44,
9,
267,
1620,
12,
12581,
275,
291,
14,
6717,
63,
1618,
63,
552,
342,
267,
367,
308,
552,
315,
1425,
8,
277,
14,
3097,
435,
413,
304,
288,
6149,
275,
2163,
4709,
8,
83,
552,
9,
288,
12581,
5873,
275,
6149,
288,
1620,
5873,
275,
6149,
288,
291,
14,
629,
8,
1168,
12,
12581,
23315,
283,
409,
6014,
359,
2938,
358,
953,
367,
284,
315,
291,
14,
9368,
63,
6666,
8,
17,
304,
355,
6149,
275,
2163,
4709,
8,
83,
552,
9,
355,
12581,
59,
73,
2938,
275,
6149,
355,
1620,
59,
73,
2938,
275,
6149,
355,
291,
14,
629,
8,
1168,
12,
12581,
23315,
283,
409,
6014,
8978,
68,
2938,
7,
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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
] |
thjashin/tensorflow
|
tensorflow/python/ops/image_grad_test.py
|
83
|
12139
|
# Copyright 2015 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
"""Tests for Python ops defined in image_grad.py."""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import numpy as np
from tensorflow.python.framework import constant_op
from tensorflow.python.ops import gradient_checker
from tensorflow.python.ops import gradients_impl
from tensorflow.python.ops import image_ops
from tensorflow.python.platform import test
class ResizeNearestNeighborOpTest(test.TestCase):
TYPES = [np.float32, np.float64]
def testShapeIsCorrectAfterOp(self):
in_shape = [1, 2, 2, 1]
out_shape = [1, 4, 6, 1]
for nptype in self.TYPES:
x = np.arange(0, 4).reshape(in_shape).astype(nptype)
with self.test_session(use_gpu=True) as sess:
input_tensor = constant_op.constant(x, shape=in_shape)
resize_out = image_ops.resize_nearest_neighbor(input_tensor,
out_shape[1:3])
self.assertEqual(out_shape, list(resize_out.get_shape()))
resize_out = sess.run(resize_out)
self.assertEqual(out_shape, list(resize_out.shape))
def testGradFromResizeToLargerInBothDims(self):
in_shape = [1, 2, 3, 1]
out_shape = [1, 4, 6, 1]
for nptype in self.TYPES:
x = np.arange(0, 6).reshape(in_shape).astype(nptype)
with self.test_session(use_gpu=True):
input_tensor = constant_op.constant(x, shape=in_shape)
resize_out = image_ops.resize_nearest_neighbor(input_tensor,
out_shape[1:3])
err = gradient_checker.compute_gradient_error(
input_tensor, in_shape, resize_out, out_shape, x_init_value=x)
self.assertLess(err, 1e-3)
def testGradFromResizeToSmallerInBothDims(self):
in_shape = [1, 4, 6, 1]
out_shape = [1, 2, 3, 1]
for nptype in self.TYPES:
x = np.arange(0, 24).reshape(in_shape).astype(nptype)
with self.test_session(use_gpu=True):
input_tensor = constant_op.constant(x, shape=in_shape)
resize_out = image_ops.resize_nearest_neighbor(input_tensor,
out_shape[1:3])
err = gradient_checker.compute_gradient_error(
input_tensor, in_shape, resize_out, out_shape, x_init_value=x)
self.assertLess(err, 1e-3)
def testCompareGpuVsCpu(self):
in_shape = [1, 4, 6, 3]
out_shape = [1, 8, 16, 3]
for nptype in self.TYPES:
x = np.arange(0, np.prod(in_shape)).reshape(in_shape).astype(nptype)
for align_corners in [True, False]:
with self.test_session(use_gpu=False):
input_tensor = constant_op.constant(x, shape=in_shape)
resize_out = image_ops.resize_nearest_neighbor(
input_tensor, out_shape[1:3], align_corners=align_corners)
grad_cpu = gradient_checker.compute_gradient(
input_tensor, in_shape, resize_out, out_shape, x_init_value=x)
with self.test_session(use_gpu=True):
input_tensor = constant_op.constant(x, shape=in_shape)
resize_out = image_ops.resize_nearest_neighbor(
input_tensor, out_shape[1:3], align_corners=align_corners)
grad_gpu = gradient_checker.compute_gradient(
input_tensor, in_shape, resize_out, out_shape, x_init_value=x)
self.assertAllClose(grad_cpu, grad_gpu, rtol=1e-5, atol=1e-5)
class ResizeBilinearOpTest(test.TestCase):
def testShapeIsCorrectAfterOp(self):
in_shape = [1, 2, 2, 1]
out_shape = [1, 4, 6, 1]
x = np.arange(0, 4).reshape(in_shape).astype(np.float32)
with self.test_session() as sess:
input_tensor = constant_op.constant(x, shape=in_shape)
resize_out = image_ops.resize_bilinear(input_tensor, out_shape[1:3])
self.assertEqual(out_shape, list(resize_out.get_shape()))
resize_out = sess.run(resize_out)
self.assertEqual(out_shape, list(resize_out.shape))
def testGradFromResizeToLargerInBothDims(self):
in_shape = [1, 2, 3, 1]
out_shape = [1, 4, 6, 1]
x = np.arange(0, 6).reshape(in_shape).astype(np.float32)
with self.test_session():
input_tensor = constant_op.constant(x, shape=in_shape)
resize_out = image_ops.resize_bilinear(input_tensor, out_shape[1:3])
err = gradient_checker.compute_gradient_error(
input_tensor, in_shape, resize_out, out_shape, x_init_value=x)
self.assertLess(err, 1e-3)
def testGradFromResizeToSmallerInBothDims(self):
in_shape = [1, 4, 6, 1]
out_shape = [1, 2, 3, 1]
x = np.arange(0, 24).reshape(in_shape).astype(np.float32)
with self.test_session():
input_tensor = constant_op.constant(x, shape=in_shape)
resize_out = image_ops.resize_bilinear(input_tensor, out_shape[1:3])
err = gradient_checker.compute_gradient_error(
input_tensor, in_shape, resize_out, out_shape, x_init_value=x)
self.assertLess(err, 1e-3)
def testGradOnUnsupportedType(self):
in_shape = [1, 4, 6, 1]
out_shape = [1, 2, 3, 1]
x = np.arange(0, 24).reshape(in_shape).astype(np.uint8)
with self.test_session():
input_tensor = constant_op.constant(x, shape=in_shape)
resize_out = image_ops.resize_bilinear(input_tensor, out_shape[1:3])
grad = gradients_impl.gradients(input_tensor, [resize_out])
self.assertEqual([None], grad)
def testCompareGpuVsCpu(self):
in_shape = [2, 4, 6, 3]
out_shape = [2, 8, 16, 3]
size = np.prod(in_shape)
x = 1.0 / size * np.arange(0, size).reshape(in_shape).astype(np.float32)
for align_corners in [True, False]:
grad = {}
for use_gpu in [False, True]:
with self.test_session(use_gpu=use_gpu):
input_tensor = constant_op.constant(x, shape=in_shape)
resized_tensor = image_ops.resize_bilinear(
input_tensor, out_shape[1:3], align_corners=align_corners)
grad[use_gpu] = gradient_checker.compute_gradient(
input_tensor, in_shape, resized_tensor, out_shape, x_init_value=x)
self.assertAllClose(grad[False], grad[True], rtol=1e-4, atol=1e-4)
class CropAndResizeOpTest(test.TestCase):
def testShapeIsCorrectAfterOp(self):
batch = 2
image_height = 3
image_width = 4
crop_height = 4
crop_width = 5
depth = 2
num_boxes = 2
image_shape = [batch, image_height, image_width, depth]
crop_size = [crop_height, crop_width]
crops_shape = [num_boxes, crop_height, crop_width, depth]
image = np.arange(0, batch * image_height * image_width *
depth).reshape(image_shape).astype(np.float32)
boxes = np.array([[0, 0, 1, 1], [.1, .2, .7, .8]], dtype=np.float32)
box_ind = np.array([0, 1], dtype=np.int32)
with self.test_session(use_gpu=True) as sess:
crops = image_ops.crop_and_resize(
constant_op.constant(
image, shape=image_shape),
constant_op.constant(
boxes, shape=[num_boxes, 4]),
constant_op.constant(
box_ind, shape=[num_boxes]),
constant_op.constant(
crop_size, shape=[2]))
self.assertEqual(crops_shape, list(crops.get_shape()))
crops = sess.run(crops)
self.assertEqual(crops_shape, list(crops.shape))
def _randomUniformAvoidAnchors(self, low, high, anchors, radius, num_samples):
"""Generate samples that are far enough from a set of anchor points.
We generate uniform samples in [low, high], then reject those that are less
than radius away from any point in anchors. We stop after we have accepted
num_samples samples.
Args:
low: The lower end of the interval.
high: The upper end of the interval.
anchors: A list of length num_crops with anchor points to avoid.
radius: Distance threshold for the samples from the anchors.
num_samples: How many samples to produce.
Returns:
samples: A list of length num_samples with the accepted samples.
"""
self.assertTrue(low < high)
self.assertTrue(radius >= 0)
num_anchors = len(anchors)
# Make sure that at least half of the interval is not forbidden.
self.assertTrue(2 * radius * num_anchors < 0.5 * (high - low))
anchors = np.reshape(anchors, num_anchors)
samples = []
while len(samples) < num_samples:
sample = np.random.uniform(low, high)
if np.all(np.fabs(sample - anchors) > radius):
samples.append(sample)
return samples
def testGradRandomBoxes(self):
"""Test that the gradient is correct for randomly generated boxes.
The mapping is piecewise differentiable with respect to the box coordinates.
The points where the function is not differentiable are those which are
mapped to image pixels, i.e., the normalized y coordinates in
np.linspace(0, 1, image_height) and normalized x coordinates in
np.linspace(0, 1, image_width). Make sure that the box coordinates are
sufficiently far away from those rectangular grid centers that are points of
discontinuity, so that the finite difference Jacobian is close to the
computed one.
"""
np.random.seed(1) # Make it reproducible.
delta = 1e-3
radius = 2 * delta
low, high = -0.5, 1.5 # Also covers the case of extrapolation.
image_height = 4
for image_width in range(1, 3):
for crop_height in range(1, 3):
for crop_width in range(2, 4):
for depth in range(1, 3):
for num_boxes in range(1, 3):
batch = num_boxes
image_shape = [batch, image_height, image_width, depth]
crop_size = [crop_height, crop_width]
crops_shape = [num_boxes, crop_height, crop_width, depth]
boxes_shape = [num_boxes, 4]
image = np.arange(0, batch * image_height * image_width *
depth).reshape(image_shape).astype(np.float32)
boxes = []
for _ in range(num_boxes):
# pylint: disable=unbalanced-tuple-unpacking
y1, y2 = self._randomUniformAvoidAnchors(
low, high, np.linspace(0, 1, image_height), radius, 2)
x1, x2 = self._randomUniformAvoidAnchors(
low, high, np.linspace(0, 1, image_width), radius, 2)
# pylint: enable=unbalanced-tuple-unpacking
boxes.append([y1, x1, y2, x2])
boxes = np.array(boxes, dtype=np.float32)
box_ind = np.arange(batch, dtype=np.int32)
with self.test_session(use_gpu=True):
image_tensor = constant_op.constant(image, shape=image_shape)
boxes_tensor = constant_op.constant(boxes, shape=[num_boxes, 4])
box_ind_tensor = constant_op.constant(
box_ind, shape=[num_boxes])
crops = image_ops.crop_and_resize(
image_tensor,
boxes_tensor,
box_ind_tensor,
constant_op.constant(
crop_size, shape=[2]))
err = gradient_checker.compute_gradient_error(
[image_tensor, boxes_tensor], [image_shape, boxes_shape],
crops,
crops_shape,
delta=delta,
x_init_value=[image, boxes])
self.assertLess(err, 2e-3)
if __name__ == "__main__":
test.main()
|
apache-2.0
|
[
3,
1898,
6900,
710,
9134,
6642,
14,
2900,
5924,
5702,
14,
199,
3,
199,
3,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
199,
3,
1265,
1443,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
199,
3,
2047,
1443,
3332,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
258,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
199,
3,
2428,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
199,
3,
1666,
314,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
199,
3,
4204,
1334,
314,
844,
14,
199,
3,
11148,
199,
624,
2925,
367,
2018,
4156,
3247,
315,
1834,
63,
6017,
14,
647,
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,
2680,
465,
980,
199,
199,
504,
3228,
14,
1548,
14,
4857,
492,
4413,
63,
411,
199,
504,
3228,
14,
1548,
14,
1483,
492,
6709,
63,
6743,
199,
504,
3228,
14,
1548,
14,
1483,
492,
12661,
63,
5472,
199,
504,
3228,
14,
1548,
14,
1483,
492,
1834,
63,
1483,
199,
504,
3228,
14,
1548,
14,
3246,
492,
511,
421,
199,
533,
799,
890,
4698,
9540,
13779,
4619,
774,
8,
396,
14,
1746,
304,
819,
32317,
275,
359,
1590,
14,
1609,
708,
12,
980,
14,
1609,
772,
61,
819,
347,
511,
7238,
1831,
19993,
10881,
4619,
8,
277,
304,
272,
315,
63,
1392,
275,
359,
17,
12,
499,
12,
499,
12,
413,
61,
272,
734,
63,
1392,
275,
359,
17,
12,
841,
12,
1227,
12,
413,
61,
339,
367,
980,
466,
315,
291,
14,
7893,
26,
489,
671,
275,
980,
14,
5605,
8,
16,
12,
841,
680,
5217,
8,
262,
63,
1392,
680,
6041,
8,
1590,
466,
9,
2541,
543,
291,
14,
396,
63,
1730,
8,
1180,
63,
6477,
29,
549,
9,
465,
4043,
26,
267,
1324,
63,
3128,
275,
4413,
63,
411,
14,
4083,
8,
88,
12,
2215,
29,
262,
63,
1392,
9,
267,
15210,
63,
548,
275,
1834,
63,
1483,
14,
8709,
63,
16615,
63,
13881,
8,
1210,
63,
3128,
12,
10940,
734,
63,
1392,
59,
17,
26,
19,
566,
267,
291,
14,
629,
8,
548,
63,
1392,
12,
769,
8,
8709,
63,
548,
14,
362,
63,
1392,
4059,
398,
15210,
63,
548,
275,
4043,
14,
1065,
8,
8709,
63,
548,
9,
489,
291,
14,
629,
8,
548,
63,
1392,
12,
769,
8,
8709,
63,
548,
14,
1392,
430,
819,
347,
511,
14812,
2532,
24559,
1378,
44,
285,
836,
607,
18088,
1341,
706,
8,
277,
304,
272,
315,
63,
1392,
275,
359,
17,
12,
499,
12,
650,
12,
413,
61,
272,
734,
63,
1392,
275,
359,
17,
12,
841,
12,
1227,
12,
413,
61,
339,
367,
980,
466,
315,
291,
14,
7893,
26,
489,
671,
275,
980,
14,
5605,
8,
16,
12,
1227,
680,
5217,
8,
262,
63,
1392,
680,
6041,
8,
1590,
466,
9,
2541,
543,
291,
14,
396,
63,
1730,
8,
1180,
63,
6477,
29,
549,
304,
267,
1324,
63,
3128,
275,
4413,
63,
411,
14,
4083,
8,
88,
12,
2215,
29,
262,
63,
1392,
9,
267,
15210,
63,
548,
275,
1834,
63,
1483,
14,
8709,
63,
16615,
63,
13881,
8,
1210,
63,
3128,
12,
10940,
734,
63,
1392,
59,
17,
26,
19,
566,
267,
2329,
275,
6709,
63,
6743,
14,
3357,
63,
7490,
63,
705,
8,
288,
1324,
63,
3128,
12,
315,
63,
1392,
12,
15210,
63,
548,
12,
734,
63,
1392,
12,
671,
63,
826,
63,
585,
29,
88,
9,
489,
291,
14,
15625,
8,
1508,
12,
413,
69,
13,
19,
9,
819,
347,
511,
14812,
2532,
24559,
1378,
51,
2174,
1435,
607,
18088,
1341,
706,
8,
277,
304,
272,
315,
63,
1392,
275,
359,
17,
12,
841,
12,
1227,
12,
413,
61,
272,
734,
63,
1392,
275,
359,
17,
12,
499,
12,
650,
12,
413,
61,
339,
367,
980,
466,
315,
291,
14,
7893,
26,
489,
671,
275,
980,
14,
5605,
8,
16,
12,
5504,
680,
5217,
8,
262,
63,
1392,
680,
6041,
8,
1590,
466,
9,
2541,
543,
291,
14,
396,
63,
1730,
8,
1180,
63,
6477,
29,
549,
304,
267,
1324,
63,
3128,
275,
4413,
63,
411,
14,
4083,
8,
88,
12,
2215,
29,
262,
63,
1392,
9,
267,
15210,
63,
548,
275,
1834,
63,
1483,
14,
8709,
63,
16615,
63,
13881,
8,
1210,
63,
3128,
12,
10940,
734,
63,
1392,
59,
17,
26,
19,
566,
267,
2329,
275,
6709,
63,
6743,
14,
3357,
63,
7490,
63,
705,
8,
288,
1324,
63,
3128,
12,
315,
63,
1392,
12,
15210,
63,
548,
12,
734,
63,
1392,
12,
671,
63,
826,
63,
585,
29,
88,
9,
489,
291,
14,
15625,
8,
1508,
12,
413,
69,
13,
19,
9,
819,
347,
511,
16051,
39,
3165,
20343,
23214,
8,
277,
304,
272,
315,
63,
1392,
275,
359,
17,
12,
841,
12,
1227,
12,
650,
61,
272,
734,
63,
1392,
275,
359,
17,
12,
1695,
12,
3193,
12,
650,
61,
339,
367,
980,
466,
315,
291,
14,
7893,
26,
489,
671,
275,
980,
14,
5605,
8,
16,
12,
980,
14,
8788,
8,
262,
63,
1392,
4992,
5217,
8,
262,
63,
1392,
680,
6041,
8,
1590,
466,
9,
489,
367,
6998,
63,
30652,
315,
359,
549,
12,
756,
2189,
267,
543,
291,
14,
396,
63,
1730,
8,
1180,
63,
6477,
29,
797,
304,
881,
1324,
63,
3128,
275,
4413,
63,
411,
14,
4083,
8,
88,
12,
2215,
29,
262,
63,
1392,
9,
881,
15210,
63,
548,
275,
1834,
63,
1483,
14,
8709,
63,
16615,
63,
13881,
8,
1598,
1324,
63,
3128,
12,
734,
63,
1392,
59,
17,
26,
19,
467,
6998,
63,
30652,
29,
5743,
63,
30652,
9,
881,
7659,
63,
3541,
275,
6709,
63,
6743,
14,
3357,
63,
7490,
8,
1598,
1324,
63,
3128,
12,
315,
63,
1392,
12,
15210,
63,
548,
12,
734,
63,
1392,
12,
671,
63,
826,
63,
585,
29,
88
] |
[
1898,
6900,
710,
9134,
6642,
14,
2900,
5924,
5702,
14,
199,
3,
199,
3,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
199,
3,
1265,
1443,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
199,
3,
2047,
1443,
3332,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
258,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
199,
3,
2428,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
199,
3,
1666,
314,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
199,
3,
4204,
1334,
314,
844,
14,
199,
3,
11148,
199,
624,
2925,
367,
2018,
4156,
3247,
315,
1834,
63,
6017,
14,
647,
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,
2680,
465,
980,
199,
199,
504,
3228,
14,
1548,
14,
4857,
492,
4413,
63,
411,
199,
504,
3228,
14,
1548,
14,
1483,
492,
6709,
63,
6743,
199,
504,
3228,
14,
1548,
14,
1483,
492,
12661,
63,
5472,
199,
504,
3228,
14,
1548,
14,
1483,
492,
1834,
63,
1483,
199,
504,
3228,
14,
1548,
14,
3246,
492,
511,
421,
199,
533,
799,
890,
4698,
9540,
13779,
4619,
774,
8,
396,
14,
1746,
304,
819,
32317,
275,
359,
1590,
14,
1609,
708,
12,
980,
14,
1609,
772,
61,
819,
347,
511,
7238,
1831,
19993,
10881,
4619,
8,
277,
304,
272,
315,
63,
1392,
275,
359,
17,
12,
499,
12,
499,
12,
413,
61,
272,
734,
63,
1392,
275,
359,
17,
12,
841,
12,
1227,
12,
413,
61,
339,
367,
980,
466,
315,
291,
14,
7893,
26,
489,
671,
275,
980,
14,
5605,
8,
16,
12,
841,
680,
5217,
8,
262,
63,
1392,
680,
6041,
8,
1590,
466,
9,
2541,
543,
291,
14,
396,
63,
1730,
8,
1180,
63,
6477,
29,
549,
9,
465,
4043,
26,
267,
1324,
63,
3128,
275,
4413,
63,
411,
14,
4083,
8,
88,
12,
2215,
29,
262,
63,
1392,
9,
267,
15210,
63,
548,
275,
1834,
63,
1483,
14,
8709,
63,
16615,
63,
13881,
8,
1210,
63,
3128,
12,
10940,
734,
63,
1392,
59,
17,
26,
19,
566,
267,
291,
14,
629,
8,
548,
63,
1392,
12,
769,
8,
8709,
63,
548,
14,
362,
63,
1392,
4059,
398,
15210,
63,
548,
275,
4043,
14,
1065,
8,
8709,
63,
548,
9,
489,
291,
14,
629,
8,
548,
63,
1392,
12,
769,
8,
8709,
63,
548,
14,
1392,
430,
819,
347,
511,
14812,
2532,
24559,
1378,
44,
285,
836,
607,
18088,
1341,
706,
8,
277,
304,
272,
315,
63,
1392,
275,
359,
17,
12,
499,
12,
650,
12,
413,
61,
272,
734,
63,
1392,
275,
359,
17,
12,
841,
12,
1227,
12,
413,
61,
339,
367,
980,
466,
315,
291,
14,
7893,
26,
489,
671,
275,
980,
14,
5605,
8,
16,
12,
1227,
680,
5217,
8,
262,
63,
1392,
680,
6041,
8,
1590,
466,
9,
2541,
543,
291,
14,
396,
63,
1730,
8,
1180,
63,
6477,
29,
549,
304,
267,
1324,
63,
3128,
275,
4413,
63,
411,
14,
4083,
8,
88,
12,
2215,
29,
262,
63,
1392,
9,
267,
15210,
63,
548,
275,
1834,
63,
1483,
14,
8709,
63,
16615,
63,
13881,
8,
1210,
63,
3128,
12,
10940,
734,
63,
1392,
59,
17,
26,
19,
566,
267,
2329,
275,
6709,
63,
6743,
14,
3357,
63,
7490,
63,
705,
8,
288,
1324,
63,
3128,
12,
315,
63,
1392,
12,
15210,
63,
548,
12,
734,
63,
1392,
12,
671,
63,
826,
63,
585,
29,
88,
9,
489,
291,
14,
15625,
8,
1508,
12,
413,
69,
13,
19,
9,
819,
347,
511,
14812,
2532,
24559,
1378,
51,
2174,
1435,
607,
18088,
1341,
706,
8,
277,
304,
272,
315,
63,
1392,
275,
359,
17,
12,
841,
12,
1227,
12,
413,
61,
272,
734,
63,
1392,
275,
359,
17,
12,
499,
12,
650,
12,
413,
61,
339,
367,
980,
466,
315,
291,
14,
7893,
26,
489,
671,
275,
980,
14,
5605,
8,
16,
12,
5504,
680,
5217,
8,
262,
63,
1392,
680,
6041,
8,
1590,
466,
9,
2541,
543,
291,
14,
396,
63,
1730,
8,
1180,
63,
6477,
29,
549,
304,
267,
1324,
63,
3128,
275,
4413,
63,
411,
14,
4083,
8,
88,
12,
2215,
29,
262,
63,
1392,
9,
267,
15210,
63,
548,
275,
1834,
63,
1483,
14,
8709,
63,
16615,
63,
13881,
8,
1210,
63,
3128,
12,
10940,
734,
63,
1392,
59,
17,
26,
19,
566,
267,
2329,
275,
6709,
63,
6743,
14,
3357,
63,
7490,
63,
705,
8,
288,
1324,
63,
3128,
12,
315,
63,
1392,
12,
15210,
63,
548,
12,
734,
63,
1392,
12,
671,
63,
826,
63,
585,
29,
88,
9,
489,
291,
14,
15625,
8,
1508,
12,
413,
69,
13,
19,
9,
819,
347,
511,
16051,
39,
3165,
20343,
23214,
8,
277,
304,
272,
315,
63,
1392,
275,
359,
17,
12,
841,
12,
1227,
12,
650,
61,
272,
734,
63,
1392,
275,
359,
17,
12,
1695,
12,
3193,
12,
650,
61,
339,
367,
980,
466,
315,
291,
14,
7893,
26,
489,
671,
275,
980,
14,
5605,
8,
16,
12,
980,
14,
8788,
8,
262,
63,
1392,
4992,
5217,
8,
262,
63,
1392,
680,
6041,
8,
1590,
466,
9,
489,
367,
6998,
63,
30652,
315,
359,
549,
12,
756,
2189,
267,
543,
291,
14,
396,
63,
1730,
8,
1180,
63,
6477,
29,
797,
304,
881,
1324,
63,
3128,
275,
4413,
63,
411,
14,
4083,
8,
88,
12,
2215,
29,
262,
63,
1392,
9,
881,
15210,
63,
548,
275,
1834,
63,
1483,
14,
8709,
63,
16615,
63,
13881,
8,
1598,
1324,
63,
3128,
12,
734,
63,
1392,
59,
17,
26,
19,
467,
6998,
63,
30652,
29,
5743,
63,
30652,
9,
881,
7659,
63,
3541,
275,
6709,
63,
6743,
14,
3357,
63,
7490,
8,
1598,
1324,
63,
3128,
12,
315,
63,
1392,
12,
15210,
63,
548,
12,
734,
63,
1392,
12,
671,
63,
826,
63,
585,
29,
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,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
lookout/dd-agent
|
tests/core/test_win32_agent.py
|
7
|
2436
|
# stdlib
import time
import unittest
# 3p
from mock import Mock
class MockProcess(Mock):
"""
A mocked process.
"""
def __init__(self, agentConfig=None, hostname=None, **options):
super(MockProcess, self).__init__()
self.config = agentConfig
self.hostname = hostname
self.options = options
self._foo = options.get('foo')
class TestWin32Agent(unittest.TestCase):
"""
Test for Windows `agent.py`.
"""
def setUp(self):
"""
Mock Windows related Python packages, so it can be tested on any environment.
"""
import sys
global ProcessWatchDog
sys.modules['servicemanager'] = Mock()
sys.modules['win32event'] = Mock()
sys.modules['win32service'] = Mock()
sys.modules['win32serviceutil'] = Mock()
from win32.agent import ProcessWatchDog # noqa
def test_watchdog_max_restarts(self):
"""
WatchDog does not exceed a maximum number of restarts per timeframe.
"""
# Limit the restart timeframe for test purpose
ProcessWatchDog._RESTART_TIMEFRAME = 1 # noqa
# Create a WatchDog with a mock process
process = MockProcess("MyConfig", "MyHostname", foo="bar")
process_watchdog = ProcessWatchDog("MyProcess", process, max_restarts=2) # noqa
# Can restart 2 times
for x in xrange(0, 2):
self.assertTrue(process_watchdog._can_restart())
process_watchdog.restart()
# Not 3
self.assertFalse(process_watchdog._can_restart())
# Can restart after the timeframe is expired
time.sleep(1)
self.assertTrue(process_watchdog._can_restart())
def test_watchdog_restart(self):
"""
WatchDog restarts processes with the original arguments.
"""
# Create a WatchDog with a mock process
process = MockProcess("MyConfig", "MyHostname", foo="bar")
process_watchdog = ProcessWatchDog("MyProcess", process) # noqa
# Restart the process
process_watchdog.restart()
new_process = process_watchdog._process
# A new process was created with the same attributes
self.assertNotEquals(process, new_process)
self.assertEquals(new_process.config, "MyConfig")
self.assertEquals(new_process.hostname, "MyHostname")
self.assertEquals(new_process._foo, "bar")
|
bsd-3-clause
|
[
3,
26678,
199,
646,
900,
199,
646,
2882,
199,
199,
3,
650,
80,
199,
504,
1683,
492,
4420,
421,
199,
533,
4420,
3498,
8,
3346,
304,
272,
408,
272,
437,
16991,
2112,
14,
272,
408,
272,
347,
636,
826,
721,
277,
12,
6631,
2028,
29,
403,
12,
6246,
29,
403,
12,
1011,
1419,
304,
267,
1613,
8,
3346,
3498,
12,
291,
2843,
826,
4533,
267,
291,
14,
888,
275,
6631,
2028,
267,
291,
14,
4269,
275,
6246,
267,
291,
14,
1419,
275,
1511,
267,
291,
423,
1421,
275,
1511,
14,
362,
360,
1421,
358,
421,
199,
533,
1379,
8886,
708,
7788,
8,
2796,
14,
1746,
304,
272,
408,
272,
1379,
367,
5417,
658,
4054,
14,
647,
2313,
272,
408,
272,
347,
3613,
8,
277,
304,
267,
408,
267,
4420,
5417,
4048,
2018,
6117,
12,
880,
652,
883,
506,
12470,
641,
1263,
3734,
14,
267,
408,
267,
492,
984,
267,
2288,
7132,
13978,
36,
974,
398,
984,
14,
3112,
459,
1364,
2609,
418,
275,
4420,
342,
267,
984,
14,
3112,
459,
2676,
708,
1430,
418,
275,
4420,
342,
267,
984,
14,
3112,
459,
2676,
708,
1364,
418,
275,
4420,
342,
267,
984,
14,
3112,
459,
2676,
708,
1364,
1974,
418,
275,
4420,
342,
398,
687,
4747,
708,
14,
4054,
492,
7132,
13978,
36,
974,
221,
327,
8151,
339,
347,
511,
63,
6821,
13889,
63,
988,
63,
10506,
83,
8,
277,
304,
267,
408,
267,
29075,
36,
974,
1630,
440,
24068,
282,
5696,
1329,
402,
11004,
83,
1126,
900,
1943,
14,
267,
408,
267,
327,
22672,
314,
11004,
900,
1943,
367,
511,
12016,
267,
7132,
13978,
36,
974,
423,
15740,
2294,
63,
4961,
12683,
275,
413,
221,
327,
8151,
398,
327,
2790,
282,
29075,
36,
974,
543,
282,
1683,
2112,
267,
2112,
275,
4420,
3498,
480,
5713,
2028,
401,
298,
5713,
25680,
401,
3925,
628,
1700,
531,
267,
2112,
63,
6821,
13889,
275,
7132,
13978,
36,
974,
480,
5713,
3498,
401,
2112,
12,
1390,
63,
10506,
83,
29,
18,
9,
221,
327,
8151,
398,
327,
6855,
11004,
499,
5431,
267,
367,
671,
315,
4945,
8,
16,
12,
499,
304,
288,
291,
14,
1815,
8,
1412,
63,
6821,
13889,
423,
2425,
63,
10506,
1012,
288,
2112,
63,
6821,
13889,
14,
10506,
342,
398,
327,
2832,
650,
267,
291,
14,
3334,
8,
1412,
63,
6821,
13889,
423,
2425,
63,
10506,
1012,
398,
327,
6855,
11004,
2410,
314,
900,
1943,
365,
14721,
267,
900,
14,
4532,
8,
17,
9,
267,
291,
14,
1815,
8,
1412,
63,
6821,
13889,
423,
2425,
63,
10506,
1012,
339,
347,
511,
63,
6821,
13889,
63,
10506,
8,
277,
304,
267,
408,
267,
29075,
36,
974,
11004,
83,
10358,
543,
314,
3379,
2368,
14,
267,
408,
267,
327,
2790,
282,
29075,
36,
974,
543,
282,
1683,
2112,
267,
2112,
275,
4420,
3498,
480,
5713,
2028,
401,
298,
5713,
25680,
401,
3925,
628,
1700,
531,
267,
2112,
63,
6821,
13889,
275,
7132,
13978,
36,
974,
480,
5713,
3498,
401,
2112,
9,
221,
327,
8151,
398,
327,
799,
928,
314,
2112,
267,
2112,
63,
6821,
13889,
14,
10506,
342,
267,
892,
63,
1412,
275,
2112,
63,
6821,
13889,
423,
1412,
398,
327,
437,
892,
2112,
1990,
2737,
543,
314,
2011,
3004,
267,
291,
14,
7418,
83,
8,
1412,
12,
892,
63,
1412,
9,
267,
291,
14,
2947,
8,
1222,
63,
1412,
14,
888,
12,
298,
5713,
2028,
531,
267,
291,
14,
2947,
8,
1222,
63,
1412,
14,
4269,
12,
298,
5713,
25680,
531,
267,
291,
14,
2947,
8,
1222,
63,
1412,
423,
1421,
12,
298,
1700,
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
] |
[
26678,
199,
646,
900,
199,
646,
2882,
199,
199,
3,
650,
80,
199,
504,
1683,
492,
4420,
421,
199,
533,
4420,
3498,
8,
3346,
304,
272,
408,
272,
437,
16991,
2112,
14,
272,
408,
272,
347,
636,
826,
721,
277,
12,
6631,
2028,
29,
403,
12,
6246,
29,
403,
12,
1011,
1419,
304,
267,
1613,
8,
3346,
3498,
12,
291,
2843,
826,
4533,
267,
291,
14,
888,
275,
6631,
2028,
267,
291,
14,
4269,
275,
6246,
267,
291,
14,
1419,
275,
1511,
267,
291,
423,
1421,
275,
1511,
14,
362,
360,
1421,
358,
421,
199,
533,
1379,
8886,
708,
7788,
8,
2796,
14,
1746,
304,
272,
408,
272,
1379,
367,
5417,
658,
4054,
14,
647,
2313,
272,
408,
272,
347,
3613,
8,
277,
304,
267,
408,
267,
4420,
5417,
4048,
2018,
6117,
12,
880,
652,
883,
506,
12470,
641,
1263,
3734,
14,
267,
408,
267,
492,
984,
267,
2288,
7132,
13978,
36,
974,
398,
984,
14,
3112,
459,
1364,
2609,
418,
275,
4420,
342,
267,
984,
14,
3112,
459,
2676,
708,
1430,
418,
275,
4420,
342,
267,
984,
14,
3112,
459,
2676,
708,
1364,
418,
275,
4420,
342,
267,
984,
14,
3112,
459,
2676,
708,
1364,
1974,
418,
275,
4420,
342,
398,
687,
4747,
708,
14,
4054,
492,
7132,
13978,
36,
974,
221,
327,
8151,
339,
347,
511,
63,
6821,
13889,
63,
988,
63,
10506,
83,
8,
277,
304,
267,
408,
267,
29075,
36,
974,
1630,
440,
24068,
282,
5696,
1329,
402,
11004,
83,
1126,
900,
1943,
14,
267,
408,
267,
327,
22672,
314,
11004,
900,
1943,
367,
511,
12016,
267,
7132,
13978,
36,
974,
423,
15740,
2294,
63,
4961,
12683,
275,
413,
221,
327,
8151,
398,
327,
2790,
282,
29075,
36,
974,
543,
282,
1683,
2112,
267,
2112,
275,
4420,
3498,
480,
5713,
2028,
401,
298,
5713,
25680,
401,
3925,
628,
1700,
531,
267,
2112,
63,
6821,
13889,
275,
7132,
13978,
36,
974,
480,
5713,
3498,
401,
2112,
12,
1390,
63,
10506,
83,
29,
18,
9,
221,
327,
8151,
398,
327,
6855,
11004,
499,
5431,
267,
367,
671,
315,
4945,
8,
16,
12,
499,
304,
288,
291,
14,
1815,
8,
1412,
63,
6821,
13889,
423,
2425,
63,
10506,
1012,
288,
2112,
63,
6821,
13889,
14,
10506,
342,
398,
327,
2832,
650,
267,
291,
14,
3334,
8,
1412,
63,
6821,
13889,
423,
2425,
63,
10506,
1012,
398,
327,
6855,
11004,
2410,
314,
900,
1943,
365,
14721,
267,
900,
14,
4532,
8,
17,
9,
267,
291,
14,
1815,
8,
1412,
63,
6821,
13889,
423,
2425,
63,
10506,
1012,
339,
347,
511,
63,
6821,
13889,
63,
10506,
8,
277,
304,
267,
408,
267,
29075,
36,
974,
11004,
83,
10358,
543,
314,
3379,
2368,
14,
267,
408,
267,
327,
2790,
282,
29075,
36,
974,
543,
282,
1683,
2112,
267,
2112,
275,
4420,
3498,
480,
5713,
2028,
401,
298,
5713,
25680,
401,
3925,
628,
1700,
531,
267,
2112,
63,
6821,
13889,
275,
7132,
13978,
36,
974,
480,
5713,
3498,
401,
2112,
9,
221,
327,
8151,
398,
327,
799,
928,
314,
2112,
267,
2112,
63,
6821,
13889,
14,
10506,
342,
267,
892,
63,
1412,
275,
2112,
63,
6821,
13889,
423,
1412,
398,
327,
437,
892,
2112,
1990,
2737,
543,
314,
2011,
3004,
267,
291,
14,
7418,
83,
8,
1412,
12,
892,
63,
1412,
9,
267,
291,
14,
2947,
8,
1222,
63,
1412,
14,
888,
12,
298,
5713,
2028,
531,
267,
291,
14,
2947,
8,
1222,
63,
1412,
14,
4269,
12,
298,
5713,
25680,
531,
267,
291,
14,
2947,
8,
1222,
63,
1412,
423,
1421,
12,
298,
1700,
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,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
madjam/mxnet
|
example/ssd/tools/caffe_converter/compare_layers.py
|
54
|
14536
|
# 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.
"""Test converted models layer by layer
"""
import os
import argparse
import logging
import mxnet as mx
import cv2
import numpy as np
logging.basicConfig(level=logging.INFO)
def read_image(img_path, image_dims=None, mean=None):
"""
Reads an image from file path or URL, optionally resizing to given image dimensions and
subtracting mean.
:param img_path: path to file, or url to download
:param image_dims: image dimensions to resize to, or None
:param mean: mean file to subtract, or None
:return: loaded image, in RGB format
"""
import urllib
filename = img_path.split("/")[-1]
if img_path.startswith('http'):
urllib.urlretrieve(img_path, filename)
img = cv2.imread(filename)
else:
img = cv2.imread(img_path)
img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
if image_dims is not None:
img = cv2.resize(img, image_dims) # resize to image_dims to fit model
img = np.rollaxis(img, 2) # change to (c, h, w) order
img = img[np.newaxis, :] # extend to (n, c, h, w)
if mean is not None:
mean = np.array(mean)
if mean.shape == (3,):
mean = mean[np.newaxis, :, np.newaxis, np.newaxis] # extend to (n, c, 1, 1)
img = img.astype(np.float32) - mean # subtract mean
return img
def _ch_dev(arg_params, aux_params, ctx):
"""
Changes device of given mxnet arguments
:param arg_params: arguments
:param aux_params: auxiliary parameters
:param ctx: new device context
:return: arguments and auxiliary parameters on new device
"""
new_args = dict()
new_auxs = dict()
for k, v in arg_params.items():
new_args[k] = v.as_in_context(ctx)
for k, v in aux_params.items():
new_auxs[k] = v.as_in_context(ctx)
return new_args, new_auxs
def convert_and_compare_caffe_to_mxnet(image_url, gpu, caffe_prototxt_path, caffe_model_path,
caffe_mean, mean_diff_allowed, max_diff_allowed):
"""
Run the layer comparison on a caffe model, given its prototxt, weights and mean.
The comparison is done by inferring on a given image using both caffe and mxnet model
:param image_url: image file or url to run inference on
:param gpu: gpu to use, -1 for cpu
:param caffe_prototxt_path: path to caffe prototxt
:param caffe_model_path: path to caffe weights
:param caffe_mean: path to caffe mean file
"""
import caffe
from caffe_proto_utils import read_network_dag, process_network_proto, read_caffe_mean
from convert_model import convert_model
if isinstance(caffe_mean, str):
caffe_mean = read_caffe_mean(caffe_mean)
elif caffe_mean is None:
pass
elif len(caffe_mean) == 3:
# swap channels from Caffe BGR to RGB
caffe_mean = caffe_mean[::-1]
# get caffe root location, this is needed to run the upgrade network utility, so we only need
# to support parsing of latest caffe
caffe_root = os.path.dirname(os.path.dirname(caffe.__path__[0]))
caffe_prototxt_path = process_network_proto(caffe_root, caffe_prototxt_path)
_, layer_name_to_record, top_to_layers = read_network_dag(caffe_prototxt_path)
caffe.set_mode_cpu()
caffe_net = caffe.Net(caffe_prototxt_path, caffe_model_path, caffe.TEST)
image_dims = tuple(caffe_net.blobs['data'].shape)[2:4]
logging.info('getting image %s', image_url)
img_rgb = read_image(image_url, image_dims, caffe_mean)
img_bgr = img_rgb[:, ::-1, :, :]
caffe_net.blobs['data'].reshape(*img_bgr.shape)
caffe_net.blobs['data'].data[...] = img_bgr
_ = caffe_net.forward()
# read sym and add all outputs
sym, arg_params, aux_params, _ = convert_model(caffe_prototxt_path, caffe_model_path)
sym = sym.get_internals()
# now mxnet
if gpu < 0:
ctx = mx.cpu(0)
else:
ctx = mx.gpu(gpu)
arg_params, aux_params = _ch_dev(arg_params, aux_params, ctx)
arg_params["data"] = mx.nd.array(img_rgb, ctx)
arg_params["prob_label"] = mx.nd.empty((1,), ctx)
exe = sym.bind(ctx, arg_params, args_grad=None, grad_req="null", aux_states=aux_params)
exe.forward(is_train=False)
compare_layers_from_nets(caffe_net, arg_params, aux_params, exe, layer_name_to_record,
top_to_layers, mean_diff_allowed, max_diff_allowed)
return
def _bfs(root_node, process_node):
"""
Implementation of Breadth-first search (BFS) on caffe network DAG
:param root_node: root node of caffe network DAG
:param process_node: function to run on each node
"""
from collections import deque
seen_nodes = set()
next_nodes = deque()
seen_nodes.add(root_node)
next_nodes.append(root_node)
while next_nodes:
current_node = next_nodes.popleft()
# process current node
process_node(current_node)
for child_node in current_node.children:
if child_node not in seen_nodes:
seen_nodes.add(child_node)
next_nodes.append(child_node)
def compare_layers_from_nets(caffe_net, arg_params, aux_params, exe, layer_name_to_record,
top_to_layers, mean_diff_allowed, max_diff_allowed):
"""
Compare layer by layer of a caffe network with mxnet network
:param caffe_net: loaded caffe network
:param arg_params: arguments
:param aux_params: auxiliary parameters
:param exe: mxnet model
:param layer_name_to_record: map between caffe layer and information record
:param top_to_layers: map between caffe blob name to layers which outputs it (including inplace)
:param mean_diff_allowed: mean difference allowed between caffe blob and mxnet blob
:param max_diff_allowed: max difference allowed between caffe blob and mxnet blob
"""
import re
log_format = ' {0:<40} {1:<40} {2:<8} {3:>10} {4:>10} {5:<1}'
compare_layers_from_nets.is_first_convolution = True
def _compare_blob(caf_blob, mx_blob, caf_name, mx_name, blob_type, note):
diff = np.abs(mx_blob - caf_blob)
diff_mean = diff.mean()
diff_max = diff.max()
logging.info(log_format.format(caf_name, mx_name, blob_type, '%4.5f' % diff_mean,
'%4.5f' % diff_max, note))
assert diff_mean < mean_diff_allowed
assert diff_max < max_diff_allowed
def _process_layer_parameters(layer):
logging.debug('processing layer %s of type %s', layer.name, layer.type)
normalized_layer_name = re.sub('[-/]', '_', layer.name)
# handle weight and bias of convolution and fully-connected layers
if layer.name in caffe_net.params and layer.type in ['Convolution', 'InnerProduct',
'Deconvolution']:
has_bias = len(caffe_net.params[layer.name]) > 1
mx_name_weight = '{}_weight'.format(normalized_layer_name)
mx_beta = arg_params[mx_name_weight].asnumpy()
# first convolution should change from BGR to RGB
if layer.type == 'Convolution' and compare_layers_from_nets.is_first_convolution:
compare_layers_from_nets.is_first_convolution = False
# if RGB or RGBA
if mx_beta.shape[1] == 3 or mx_beta.shape[1] == 4:
# Swapping BGR of caffe into RGB in mxnet
mx_beta[:, [0, 2], :, :] = mx_beta[:, [2, 0], :, :]
caf_beta = caffe_net.params[layer.name][0].data
_compare_blob(caf_beta, mx_beta, layer.name, mx_name_weight, 'weight', '')
if has_bias:
mx_name_bias = '{}_bias'.format(normalized_layer_name)
mx_gamma = arg_params[mx_name_bias].asnumpy()
caf_gamma = caffe_net.params[layer.name][1].data
_compare_blob(caf_gamma, mx_gamma, layer.name, mx_name_bias, 'bias', '')
elif layer.name in caffe_net.params and layer.type == 'Scale':
if 'scale' in normalized_layer_name:
bn_name = normalized_layer_name.replace('scale', 'bn')
elif 'sc' in normalized_layer_name:
bn_name = normalized_layer_name.replace('sc', 'bn')
else:
assert False, 'Unknown name convention for bn/scale'
beta_name = '{}_beta'.format(bn_name)
gamma_name = '{}_gamma'.format(bn_name)
mx_beta = arg_params[beta_name].asnumpy()
caf_beta = caffe_net.params[layer.name][1].data
_compare_blob(caf_beta, mx_beta, layer.name, beta_name, 'mov_mean', '')
mx_gamma = arg_params[gamma_name].asnumpy()
caf_gamma = caffe_net.params[layer.name][0].data
_compare_blob(caf_gamma, mx_gamma, layer.name, gamma_name, 'mov_var', '')
elif layer.name in caffe_net.params and layer.type == 'BatchNorm':
mean_name = '{}_moving_mean'.format(normalized_layer_name)
var_name = '{}_moving_var'.format(normalized_layer_name)
caf_rescale_factor = caffe_net.params[layer.name][2].data
mx_mean = aux_params[mean_name].asnumpy()
caf_mean = caffe_net.params[layer.name][0].data / caf_rescale_factor
_compare_blob(caf_mean, mx_mean, layer.name, mean_name, 'mean', '')
mx_var = aux_params[var_name].asnumpy()
caf_var = caffe_net.params[layer.name][1].data / caf_rescale_factor
_compare_blob(caf_var, mx_var, layer.name, var_name, 'var',
'expect 1e-04 change due to cudnn eps')
elif layer.type in ['Input', 'Pooling', 'ReLU', 'Eltwise', 'Softmax', 'LRN', 'Concat',
'Dropout', 'Crop']:
# no parameters to check for these layers
pass
else:
logging.warn('No handling for layer %s of type %s, should we ignore it?', layer.name,
layer.type)
return
def _process_layer_output(caffe_blob_name):
logging.debug('processing blob %s', caffe_blob_name)
# skip blobs not originating from actual layers, e.g. artificial split layers added by caffe
if caffe_blob_name not in top_to_layers:
return
caf_blob = caffe_net.blobs[caffe_blob_name].data
# data should change from BGR to RGB
if caffe_blob_name == 'data':
# if RGB or RGBA
if caf_blob.shape[1] == 3 or caf_blob.shape[1] == 4:
# Swapping BGR of caffe into RGB in mxnet
caf_blob[:, [0, 2], :, :] = caf_blob[:, [2, 0], :, :]
mx_name = 'data'
else:
# get last layer name which outputs this blob name
last_layer_name = top_to_layers[caffe_blob_name][-1]
normalized_last_layer_name = re.sub('[-/]', '_', last_layer_name)
mx_name = '{}_output'.format(normalized_last_layer_name)
if 'scale' in mx_name:
mx_name = mx_name.replace('scale', 'bn')
elif 'sc' in mx_name:
mx_name = mx_name.replace('sc', 'bn')
if mx_name not in exe.output_dict:
logging.error('mxnet blob %s is missing, time to extend the compare tool..', mx_name)
return
mx_blob = exe.output_dict[mx_name].asnumpy()
_compare_blob(caf_blob, mx_blob, caffe_blob_name, mx_name, 'output', '')
return
# check layer parameters
logging.info('\n***** Network Parameters '.ljust(140, '*'))
logging.info(log_format.format('CAFFE', 'MXNET', 'Type', 'Mean(diff)', 'Max(diff)', 'Note'))
first_layer_name = layer_name_to_record.keys()[0]
_bfs(layer_name_to_record[first_layer_name], _process_layer_parameters)
# check layer output
logging.info('\n***** Network Outputs '.ljust(140, '*'))
logging.info(log_format.format('CAFFE', 'MXNET', 'Type', 'Mean(diff)', 'Max(diff)', 'Note'))
for caffe_blob_name in caffe_net.blobs.keys():
_process_layer_output(caffe_blob_name)
return
def main():
"""Entrypoint for compare_layers"""
parser = argparse.ArgumentParser(
description='Tool for testing caffe to mxnet conversion layer by layer')
parser.add_argument('--image_url', type=str,
default='http://writm.com/wp-content/uploads/2016/08/Cat-hd-wallpapers.jpg',
help='input image to test inference, can be either file path or url')
parser.add_argument('--caffe_prototxt_path', type=str,
default='./model.prototxt',
help='path to caffe prototxt')
parser.add_argument('--caffe_model_path', type=str,
default='./model.caffemodel',
help='path to caffe weights')
parser.add_argument('--caffe_mean', type=str,
default='./model_mean.binaryproto',
help='path to caffe mean file')
parser.add_argument('--mean_diff_allowed', type=int, default=1e-03,
help='mean difference allowed between caffe blob and mxnet blob')
parser.add_argument('--max_diff_allowed', type=int, default=1e-01,
help='max difference allowed between caffe blob and mxnet blob')
parser.add_argument('--gpu', type=int, default=-1, help='the gpu id used for predict')
args = parser.parse_args()
convert_and_compare_caffe_to_mxnet(args.image_url, args.gpu, args.caffe_prototxt_path,
args.caffe_model_path, args.caffe_mean,
args.mean_diff_allowed, args.max_diff_allowed)
if __name__ == '__main__':
main()
|
apache-2.0
|
[
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,
199,
624,
774,
6702,
1709,
4045,
701,
4045,
199,
624,
199,
646,
747,
199,
646,
7534,
199,
646,
2050,
199,
646,
8728,
846,
465,
8728,
199,
646,
6277,
18,
199,
646,
2680,
465,
980,
199,
199,
4806,
14,
19602,
8,
1896,
29,
4806,
14,
4531,
9,
421,
199,
318,
1586,
63,
1569,
8,
4060,
63,
515,
12,
1834,
63,
5380,
29,
403,
12,
4615,
29,
403,
304,
272,
408,
272,
26129,
376,
1834,
687,
570,
931,
503,
2851,
12,
14190,
295,
30639,
370,
1627,
1834,
7365,
436,
272,
24129,
316,
4615,
14,
272,
520,
635,
6050,
63,
515,
26,
931,
370,
570,
12,
503,
1166,
370,
5235,
272,
520,
635,
1834,
63,
5380,
26,
1834,
7365,
370,
15210,
370,
12,
503,
488,
272,
520,
635,
4615,
26,
4615,
570,
370,
24129,
12,
503,
488,
272,
520,
1107,
26,
6511,
1834,
12,
315,
19013,
1475,
272,
408,
339,
492,
4011,
339,
1788,
275,
6050,
63,
515,
14,
1294,
19031,
1988,
17,
61,
272,
340,
6050,
63,
515,
14,
2460,
360,
1014,
735,
267,
4011,
14,
633,
14270,
8,
4060,
63,
515,
12,
1788,
9,
267,
6050,
275,
6277,
18,
14,
1017,
739,
8,
1501,
9,
272,
587,
26,
267,
6050,
275,
6277,
18,
14,
1017,
739,
8,
4060,
63,
515,
9,
339,
6050,
275,
6277,
18,
14,
5107,
84,
4117,
8,
4060,
12,
6277,
18,
14,
7134,
63,
34,
3975,
18,
12067,
9,
339,
340,
1834,
63,
5380,
365,
440,
488,
26,
267,
6050,
275,
6277,
18,
14,
8709,
8,
4060,
12,
1834,
63,
5380,
9,
221,
327,
15210,
370,
1834,
63,
5380,
370,
5542,
1402,
272,
6050,
275,
980,
14,
8459,
416,
7291,
8,
4060,
12,
499,
9,
327,
1570,
370,
334,
67,
12,
394,
12,
336,
9,
1865,
272,
6050,
275,
6050,
59,
1590,
14,
14483,
12,
12228,
221,
327,
12247,
370,
334,
78,
12,
286,
12,
394,
12,
336,
9,
272,
340,
4615,
365,
440,
488,
26,
267,
4615,
275,
980,
14,
1144,
8,
3670,
9,
267,
340,
4615,
14,
1392,
508,
334,
19,
16095,
288,
4615,
275,
4615,
59,
1590,
14,
14483,
12,
13785,
980,
14,
14483,
12,
980,
14,
14483,
61,
221,
327,
12247,
370,
334,
78,
12,
286,
12,
413,
12,
413,
9,
267,
6050,
275,
6050,
14,
6041,
8,
1590,
14,
1609,
708,
9,
446,
4615,
327,
24129,
4615,
339,
372,
6050,
421,
199,
318,
485,
335,
63,
2374,
8,
1273,
63,
1162,
12,
11593,
63,
1162,
12,
4027,
304,
272,
408,
272,
18784,
2243,
402,
1627,
8728,
846,
2368,
272,
520,
635,
1680,
63,
1162,
26,
2368,
272,
520,
635,
11593,
63,
1162,
26,
31407,
2633,
272,
520,
635,
4027,
26,
892,
2243,
1067,
272,
520,
1107,
26,
2368,
436,
31407,
2633,
641,
892,
2243,
272,
408,
272,
892,
63,
589,
275,
1211,
342,
272,
892,
63,
10962,
83,
275,
1211,
342,
272,
367,
1022,
12,
373,
315,
1680,
63,
1162,
14,
1744,
837,
267,
892,
63,
589,
59,
75,
61,
275,
373,
14,
305,
63,
262,
63,
1100,
8,
3799,
9,
272,
367,
1022,
12,
373,
315,
11593,
63,
1162,
14,
1744,
837,
267,
892,
63,
10962,
83,
59,
75,
61,
275,
373,
14,
305,
63,
262,
63,
1100,
8,
3799,
9,
272,
372,
892,
63,
589,
12,
892,
63,
10962,
83,
421,
199,
318,
3957,
63,
460,
63,
5785,
63,
18260,
63,
475,
63,
9457,
846,
8,
1569,
63,
633,
12,
21758,
12,
1704,
2026,
63,
2745,
357,
400,
63,
515,
12,
1704,
2026,
63,
1238,
63,
515,
12,
4318,
1704,
2026,
63,
3670,
12,
4615,
63,
3028,
63,
6541,
12,
1390,
63,
3028,
63,
6541,
304,
272,
408,
272,
3378,
314,
4045,
9132,
641,
282,
1704,
2026,
1402,
12,
1627,
2399,
557,
13280,
400,
12,
4931,
436,
4615,
14,
272,
710,
9132,
365,
4224,
701,
10739,
17756,
641,
282,
1627,
1834,
1808,
3865,
1704,
2026,
436,
8728,
846,
1402,
272,
520,
635,
1834,
63,
633,
26,
1834,
570,
503,
1166,
370,
1255,
17353,
641,
272,
520,
635,
21758,
26,
21758,
370,
675,
12,
446,
17,
367,
5033,
272,
520,
635,
1704,
2026,
63,
2745,
357,
400,
63,
515,
26,
931,
370,
1704,
2026,
557,
13280,
400,
272,
520,
635,
1704,
2026,
63,
1238,
63,
515,
26,
931,
370,
1704,
2026,
4931,
272,
520,
635,
1704,
2026,
63,
3670,
26,
931,
370,
1704,
2026,
4615,
570,
272,
408,
339,
492,
1704,
2026,
272,
687,
1704,
2026,
63,
2625,
63,
1208,
492,
1586,
63,
1200,
63,
7406,
12,
2112,
63,
1200,
63,
2625,
12,
1586,
63,
18260,
63,
3670,
272,
687,
3957,
63,
1238,
492,
3957,
63,
1238,
339,
340,
1228,
8,
18260,
63,
3670,
12,
620,
304,
267,
1704,
2026,
63,
3670,
275,
1586,
63,
18260,
63,
3670,
8,
18260,
63,
3670,
9,
272,
916,
1704,
2026,
63,
3670,
365,
488,
26,
267,
986,
272,
916,
822,
8,
18260,
63,
3670,
9,
508,
650,
26,
267,
327,
11413,
9245,
687,
8790,
2026,
699,
3975,
370,
19013,
267,
1704,
2026,
63,
3670,
275,
1704,
2026,
63,
3670,
14172,
17,
61,
339,
327,
664,
1704,
2026,
1738,
2909,
12,
642,
365,
4346,
370,
1255,
314,
10754
] |
[
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,
199,
624,
774,
6702,
1709,
4045,
701,
4045,
199,
624,
199,
646,
747,
199,
646,
7534,
199,
646,
2050,
199,
646,
8728,
846,
465,
8728,
199,
646,
6277,
18,
199,
646,
2680,
465,
980,
199,
199,
4806,
14,
19602,
8,
1896,
29,
4806,
14,
4531,
9,
421,
199,
318,
1586,
63,
1569,
8,
4060,
63,
515,
12,
1834,
63,
5380,
29,
403,
12,
4615,
29,
403,
304,
272,
408,
272,
26129,
376,
1834,
687,
570,
931,
503,
2851,
12,
14190,
295,
30639,
370,
1627,
1834,
7365,
436,
272,
24129,
316,
4615,
14,
272,
520,
635,
6050,
63,
515,
26,
931,
370,
570,
12,
503,
1166,
370,
5235,
272,
520,
635,
1834,
63,
5380,
26,
1834,
7365,
370,
15210,
370,
12,
503,
488,
272,
520,
635,
4615,
26,
4615,
570,
370,
24129,
12,
503,
488,
272,
520,
1107,
26,
6511,
1834,
12,
315,
19013,
1475,
272,
408,
339,
492,
4011,
339,
1788,
275,
6050,
63,
515,
14,
1294,
19031,
1988,
17,
61,
272,
340,
6050,
63,
515,
14,
2460,
360,
1014,
735,
267,
4011,
14,
633,
14270,
8,
4060,
63,
515,
12,
1788,
9,
267,
6050,
275,
6277,
18,
14,
1017,
739,
8,
1501,
9,
272,
587,
26,
267,
6050,
275,
6277,
18,
14,
1017,
739,
8,
4060,
63,
515,
9,
339,
6050,
275,
6277,
18,
14,
5107,
84,
4117,
8,
4060,
12,
6277,
18,
14,
7134,
63,
34,
3975,
18,
12067,
9,
339,
340,
1834,
63,
5380,
365,
440,
488,
26,
267,
6050,
275,
6277,
18,
14,
8709,
8,
4060,
12,
1834,
63,
5380,
9,
221,
327,
15210,
370,
1834,
63,
5380,
370,
5542,
1402,
272,
6050,
275,
980,
14,
8459,
416,
7291,
8,
4060,
12,
499,
9,
327,
1570,
370,
334,
67,
12,
394,
12,
336,
9,
1865,
272,
6050,
275,
6050,
59,
1590,
14,
14483,
12,
12228,
221,
327,
12247,
370,
334,
78,
12,
286,
12,
394,
12,
336,
9,
272,
340,
4615,
365,
440,
488,
26,
267,
4615,
275,
980,
14,
1144,
8,
3670,
9,
267,
340,
4615,
14,
1392,
508,
334,
19,
16095,
288,
4615,
275,
4615,
59,
1590,
14,
14483,
12,
13785,
980,
14,
14483,
12,
980,
14,
14483,
61,
221,
327,
12247,
370,
334,
78,
12,
286,
12,
413,
12,
413,
9,
267,
6050,
275,
6050,
14,
6041,
8,
1590,
14,
1609,
708,
9,
446,
4615,
327,
24129,
4615,
339,
372,
6050,
421,
199,
318,
485,
335,
63,
2374,
8,
1273,
63,
1162,
12,
11593,
63,
1162,
12,
4027,
304,
272,
408,
272,
18784,
2243,
402,
1627,
8728,
846,
2368,
272,
520,
635,
1680,
63,
1162,
26,
2368,
272,
520,
635,
11593,
63,
1162,
26,
31407,
2633,
272,
520,
635,
4027,
26,
892,
2243,
1067,
272,
520,
1107,
26,
2368,
436,
31407,
2633,
641,
892,
2243,
272,
408,
272,
892,
63,
589,
275,
1211,
342,
272,
892,
63,
10962,
83,
275,
1211,
342,
272,
367,
1022,
12,
373,
315,
1680,
63,
1162,
14,
1744,
837,
267,
892,
63,
589,
59,
75,
61,
275,
373,
14,
305,
63,
262,
63,
1100,
8,
3799,
9,
272,
367,
1022,
12,
373,
315,
11593,
63,
1162,
14,
1744,
837,
267,
892,
63,
10962,
83,
59,
75,
61,
275,
373,
14,
305,
63,
262,
63,
1100,
8,
3799,
9,
272,
372,
892,
63,
589,
12,
892,
63,
10962,
83,
421,
199,
318,
3957,
63,
460,
63,
5785,
63,
18260,
63,
475,
63,
9457,
846,
8,
1569,
63,
633,
12,
21758,
12,
1704,
2026,
63,
2745,
357,
400,
63,
515,
12,
1704,
2026,
63,
1238,
63,
515,
12,
4318,
1704,
2026,
63,
3670,
12,
4615,
63,
3028,
63,
6541,
12,
1390,
63,
3028,
63,
6541,
304,
272,
408,
272,
3378,
314,
4045,
9132,
641,
282,
1704,
2026,
1402,
12,
1627,
2399,
557,
13280,
400,
12,
4931,
436,
4615,
14,
272,
710,
9132,
365,
4224,
701,
10739,
17756,
641,
282,
1627,
1834,
1808,
3865,
1704,
2026,
436,
8728,
846,
1402,
272,
520,
635,
1834,
63,
633,
26,
1834,
570,
503,
1166,
370,
1255,
17353,
641,
272,
520,
635,
21758,
26,
21758,
370,
675,
12,
446,
17,
367,
5033,
272,
520,
635,
1704,
2026,
63,
2745,
357,
400,
63,
515,
26,
931,
370,
1704,
2026,
557,
13280,
400,
272,
520,
635,
1704,
2026,
63,
1238,
63,
515,
26,
931,
370,
1704,
2026,
4931,
272,
520,
635,
1704,
2026,
63,
3670,
26,
931,
370,
1704,
2026,
4615,
570,
272,
408,
339,
492,
1704,
2026,
272,
687,
1704,
2026,
63,
2625,
63,
1208,
492,
1586,
63,
1200,
63,
7406,
12,
2112,
63,
1200,
63,
2625,
12,
1586,
63,
18260,
63,
3670,
272,
687,
3957,
63,
1238,
492,
3957,
63,
1238,
339,
340,
1228,
8,
18260,
63,
3670,
12,
620,
304,
267,
1704,
2026,
63,
3670,
275,
1586,
63,
18260,
63,
3670,
8,
18260,
63,
3670,
9,
272,
916,
1704,
2026,
63,
3670,
365,
488,
26,
267,
986,
272,
916,
822,
8,
18260,
63,
3670,
9,
508,
650,
26,
267,
327,
11413,
9245,
687,
8790,
2026,
699,
3975,
370,
19013,
267,
1704,
2026,
63,
3670,
275,
1704,
2026,
63,
3670,
14172,
17,
61,
339,
327,
664,
1704,
2026,
1738,
2909,
12,
642,
365,
4346,
370,
1255,
314,
10754,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
thaumos/ansible
|
lib/ansible/modules/net_tools/netbox/netbox_site.py
|
34
|
9840
|
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Copyright: (c) 2018, Mikhail Yohman (@FragmentedPacket) <mikhail.yohman@gmail.com>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import absolute_import, division, print_function
__metaclass__ = type
ANSIBLE_METADATA = {"metadata_version": "1.1",
"status": ["preview"],
"supported_by": "community"}
DOCUMENTATION = r"""
---
module: netbox_site
short_description: Creates or removes sites from Netbox
description:
- Creates or removes sites from Netbox
notes:
- Tags should be defined as a YAML list
- This should be ran with connection C(local) and hosts C(localhost)
author:
- Mikhail Yohman (@FragmentedPacket)
requirements:
- pynetbox
version_added: "2.8"
options:
netbox_url:
description:
- URL of the Netbox instance resolvable by Ansible control host
required: true
type: str
netbox_token:
description:
- The token created within Netbox to authorize API access
required: true
type: str
data:
description:
- Defines the site configuration
suboptions:
name:
description:
- Name of the site to be created
required: true
type: str
status:
description:
- Status of the site
choices:
- Active
- Planned
- Retired
type: str
region:
description:
- The region that the site should be associated with
type: str
tenant:
description:
- The tenant the site will be assigned to
type: str
facility:
description:
- Data center provider or facility, ex. Equinix NY7
type: str
asn:
description:
- The ASN associated with the site
type: int
time_zone:
description:
- Timezone associated with the site, ex. America/Denver
type: str
description:
description:
- The description of the prefix
type: str
physical_address:
description:
- Physical address of site
type: str
shipping_address:
description:
- Shipping address of site
type: str
latitude:
description:
- Latitude in decimal format
type: int
longitude:
description:
- Longitude in decimal format
type: int
contact_name:
description:
- Name of contact for site
type: str
contact_phone:
description:
- Contact phone number for site
type: str
contact_email:
description:
- Contact email for site
type: str
comments:
description:
- Comments for the site. This can be markdown syntax
type: str
tags:
description:
- Any tags that the prefix may need to be associated with
type: list
custom_fields:
description:
- must exist in Netbox
type: dict
required: true
state:
description:
- Use C(present) or C(absent) for adding or removing.
choices: [ absent, present ]
default: present
type: str
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.
default: "yes"
type: bool
"""
EXAMPLES = r"""
- name: "Test Netbox site module"
connection: local
hosts: localhost
gather_facts: False
tasks:
- name: Create site within Netbox with only required information
netbox_site:
netbox_url: http://netbox.local
netbox_token: thisIsMyToken
data:
name: Test - Colorado
state: present
- name: Delete site within netbox
netbox_site:
netbox_url: http://netbox.local
netbox_token: thisIsMyToken
data:
name: Test - Colorado
state: absent
- name: Create site with all parameters
netbox_site:
netbox_url: http://netbox.local
netbox_token: thisIsMyToken
data:
name: Test - California
status: Planned
region: Test Region
tenant: Test Tenant
facility: EquinoxCA7
asn: 65001
time_zone: America/Los Angeles
description: This is a test description
physical_address: Hollywood, CA, 90210
shipping_address: Hollywood, CA, 90210
latitude: 10.100000
longitude: 12.200000
contact_name: Jenny
contact_phone: 867-5309
contact_email: jenny@changednumber.com
comments: ### Placeholder
state: present
"""
RETURN = r"""
site:
description: Serialized object as created or already existent within Netbox
returned: on creation
type: dict
msg:
description: Message indicating failure or info about what has been achieved
returned: always
type: str
"""
import json
import traceback
from ansible.module_utils.basic import AnsibleModule, missing_required_lib
from ansible.module_utils.net_tools.netbox.netbox_utils import (
find_ids,
normalize_data,
create_netbox_object,
delete_netbox_object,
update_netbox_object,
SITE_STATUS,
)
from ansible.module_utils.compat import ipaddress
from ansible.module_utils._text import to_text
PYNETBOX_IMP_ERR = None
try:
import pynetbox
HAS_PYNETBOX = True
except ImportError:
PYNETBOX_IMP_ERR = traceback.format_exc()
HAS_PYNETBOX = False
def main():
"""
Main entry point for module execution
"""
argument_spec = dict(
netbox_url=dict(type="str", required=True),
netbox_token=dict(type="str", required=True, no_log=True),
data=dict(type="dict", required=True),
state=dict(required=False, default="present", choices=["present", "absent"]),
validate_certs=dict(type="bool", default=True)
)
global module
module = AnsibleModule(argument_spec=argument_spec,
supports_check_mode=True)
# Fail module if pynetbox is not installed
if not HAS_PYNETBOX:
module.fail_json(msg=missing_required_lib('pynetbox'), exception=PYNETBOX_IMP_ERR)
# Assign variables to be used with module
app = "dcim"
endpoint = "sites"
url = module.params["netbox_url"]
token = module.params["netbox_token"]
data = module.params["data"]
state = module.params["state"]
validate_certs = module.params["validate_certs"]
# Attempt to create Netbox API object
try:
nb = pynetbox.api(url, token=token, ssl_verify=validate_certs)
except Exception:
module.fail_json(msg="Failed to establish connection to Netbox API")
try:
nb_app = getattr(nb, app)
except AttributeError:
module.fail_json(msg="Incorrect application specified: %s" % (app))
nb_endpoint = getattr(nb_app, endpoint)
norm_data = normalize_data(data)
try:
norm_data = _check_and_adapt_data(nb, norm_data)
if "present" in state:
return module.exit_json(
**ensure_site_present(nb, nb_endpoint, norm_data)
)
else:
return module.exit_json(
**ensure_site_absent(nb, nb_endpoint, norm_data)
)
except pynetbox.RequestError as e:
return module.fail_json(msg=json.loads(e.error))
except ValueError as e:
return module.fail_json(msg=str(e))
except AttributeError as e:
return module.fail_json(msg=str(e))
def _check_and_adapt_data(nb, data):
data = find_ids(nb, data)
if data.get("status"):
data["status"] = SITE_STATUS.get(data["status"].lower())
if "-" in data["name"]:
site_slug = data["name"].replace(" ", "").lower()
elif " " in data["name"]:
site_slug = data["name"].replace(" ", "-").lower()
else:
site_slug = data["name"].lower()
data["slug"] = site_slug
return data
def ensure_site_present(nb, nb_endpoint, data):
"""
:returns dict(interface, msg, changed): dictionary resulting of the request,
where 'site' is the serialized interface fetched or newly created in Netbox
"""
if not isinstance(data, dict):
changed = False
return {"msg": data, "changed": changed}
nb_site = nb_endpoint.get(slug=data["slug"])
result = dict()
if not nb_site:
site, diff = create_netbox_object(nb_endpoint, data, module.check_mode)
changed = True
msg = "Site %s created" % (data["name"])
result["diff"] = diff
else:
site, diff = update_netbox_object(nb_site, data, module.check_mode)
if site is False:
module.fail_json(
msg="Request failed, couldn't update device: %s" % (data["name"])
)
if diff:
msg = "Site %s updated" % (data["name"])
changed = True
result["diff"] = diff
else:
msg = "Site %s already exists" % (data["name"])
changed = False
result.update({"site": site, "msg": msg, "changed": changed})
return result
def ensure_site_absent(nb, nb_endpoint, data):
"""
:returns dict(msg, changed)
"""
nb_site = nb_endpoint.get(slug=data["slug"])
result = dict()
if nb_site:
dummy, diff = delete_netbox_object(nb_site, module.check_mode)
changed = True
msg = "Site %s deleted" % (data["name"])
result["diff"] = diff
else:
msg = "Site %s already absent" % (data["name"])
changed = False
result.update({"msg": msg, "changed": changed})
return result
if __name__ == "__main__":
main()
|
gpl-3.0
|
[
3381,
2647,
15,
1393,
15,
1548,
199,
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
199,
3,
1898,
26,
334,
67,
9,
14894,
12,
603,
3258,
72,
1054,
1488,
19194,
1237,
8593,
24552,
2509,
2726,
9,
665,
2664,
21889,
1054,
14,
16540,
72,
1237,
32,
6799,
14,
957,
30,
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,
199,
199,
8490,
63,
8314,
275,
2420,
2343,
63,
1023,
582,
298,
17,
14,
17,
401,
490,
298,
1205,
582,
2097,
7780,
2255,
490,
298,
4946,
63,
991,
582,
298,
9387,
3570,
199,
199,
8948,
275,
519,
624,
199,
2595,
199,
578,
26,
1851,
1977,
63,
2124,
199,
3612,
63,
1802,
26,
10560,
503,
14185,
15424,
687,
5365,
1977,
199,
1802,
26,
523,
446,
10560,
503,
14185,
15424,
687,
5365,
1977,
199,
5983,
26,
523,
446,
25204,
1077,
506,
3247,
465,
282,
18916,
769,
523,
446,
961,
1077,
506,
21471,
543,
1950,
445,
8,
1832,
9,
436,
7057,
445,
8,
5967,
9,
199,
2502,
26,
523,
446,
603,
3258,
72,
1054,
1488,
19194,
1237,
8593,
24552,
2509,
2726,
9,
199,
7538,
26,
523,
446,
1134,
846,
1977,
199,
1023,
63,
3270,
26,
298,
18,
14,
24,
2,
199,
1419,
26,
523,
1851,
1977,
63,
633,
26,
272,
1369,
26,
489,
446,
2851,
402,
314,
5365,
1977,
1256,
17416,
30456,
701,
2622,
3304,
1591,
272,
1415,
26,
2549,
272,
730,
26,
620,
523,
1851,
1977,
63,
1418,
26,
272,
1369,
26,
489,
446,
710,
1526,
2737,
4453,
5365,
1977,
370,
20210,
3261,
2879,
272,
1415,
26,
2549,
272,
730,
26,
620,
523,
666,
26,
272,
1369,
26,
489,
446,
25022,
314,
4770,
2897,
272,
26265,
26,
489,
536,
26,
267,
1369,
26,
881,
446,
2812,
402,
314,
4770,
370,
506,
2737,
267,
1415,
26,
2549,
267,
730,
26,
620,
489,
2004,
26,
267,
1369,
26,
881,
446,
9795,
402,
314,
4770,
267,
3415,
26,
881,
446,
23241,
881,
446,
7497,
9386,
881,
446,
799,
280,
581,
267,
730,
26,
620,
489,
4897,
26,
267,
1369,
26,
881,
446,
710,
4897,
626,
314,
4770,
1077,
506,
4568,
543,
267,
730,
26,
620,
489,
8261,
26,
267,
1369,
26,
881,
446,
710,
8261,
314,
4770,
911,
506,
7943,
370,
267,
730,
26,
620,
489,
21395,
26,
267,
1369,
26,
881,
446,
3918,
8126,
5022,
503,
21395,
12,
444,
14,
662,
392,
262,
1148,
653,
57,
23,
267,
730,
26,
620,
489,
16723,
26,
267,
1369,
26,
881,
446,
710,
31139,
4568,
543,
314,
4770,
267,
730,
26,
1109,
489,
900,
63,
2619,
26,
267,
1369,
26,
881,
446,
4703,
2619,
4568,
543,
314,
4770,
12,
444,
14,
437,
8534,
15,
10655,
422,
267,
730,
26,
620,
489,
1369,
26,
267,
1369,
26,
881,
446,
710,
1369,
402,
314,
2403,
267,
730,
26,
620,
489,
14095,
63,
1562,
26,
267,
1369,
26,
881,
446,
24309,
7476,
2287,
402,
4770,
267,
730,
26,
620,
489,
27490,
63,
1562,
26,
267,
1369,
26,
881,
446,
5244,
711,
4073,
2287,
402,
4770,
267,
730,
26,
620,
489,
18896,
26,
267,
1369,
26,
881,
446,
491,
31429,
3786,
315,
6107,
1475,
267,
730,
26,
1109,
489,
18154,
26,
267,
1369,
26,
881,
446,
19944,
7779,
315,
6107,
1475,
267,
730,
26,
1109,
489,
8966,
63,
354,
26,
267,
1369,
26,
881,
446,
2812,
402,
8966,
367,
4770,
267,
730,
26,
620,
489,
8966,
63,
9339,
26,
267,
1369,
26,
881,
446,
18684,
14617,
1329,
367,
4770,
267,
730,
26,
620,
489,
8966,
63,
2123,
26,
267,
1369,
26,
881,
446,
18684,
3031,
367,
4770,
267,
730,
26,
620,
489,
6786,
26,
267,
1369,
26,
881,
446,
5429,
1470,
367,
314,
4770,
14,
961,
883,
506,
18502,
6302,
267,
730,
26,
620,
489,
3762,
26,
267,
1369,
26,
881,
446,
6184,
3762,
626,
314,
2403,
1443,
1929,
370,
506,
4568,
543,
267,
730,
26,
769,
489,
3537,
63,
955,
26,
267,
1369,
26,
881,
446,
1471,
2187,
315,
5365,
1977,
267,
730,
26,
1211,
272,
1415,
26,
2549,
523,
1174,
26,
272,
1369,
26,
489,
446,
3645,
445,
8,
1881,
9,
503,
445,
8,
5575,
9,
367,
7791,
503,
12881,
14,
272,
3415,
26,
359,
9552,
12,
3451,
1622,
272,
849,
26,
3451,
272,
730,
26,
620,
523,
4107,
63,
8356,
26,
272,
1369,
26,
489,
446,
1204,
267,
982,
445,
8,
889,
395,
7799,
14512,
911,
440,
506,
16468,
14,
267,
961,
1077,
1454,
506,
1202,
641,
4954,
1183,
22284,
15424,
1808,
291,
13,
1737,
14512,
14,
272,
849,
26,
298,
5066,
2,
272,
730,
26,
2155,
199,
624,
199,
199,
8918,
275,
519,
624,
199,
13,
536,
26,
298,
774,
5365,
1977,
4770,
859,
2,
523,
1950,
26,
2257,
523,
7057,
26,
11667,
523,
13082,
63,
5047,
26,
756,
523,
6527,
26,
272,
446,
536,
26,
2790,
4770,
4453,
5365,
1977,
543,
1454,
1415,
2556,
489,
1851,
1977,
63,
2124,
26,
267,
1851,
1977,
63,
633,
26,
1455,
921,
846,
1977,
14,
1832,
267,
1851,
1977,
63,
1418,
26,
642,
1831,
5713,
3264,
267,
666,
26,
881,
536,
26,
1379,
446,
11581,
5129,
267,
1174,
26,
3451,
339,
446,
536,
26,
8496,
4770,
4453,
1851,
1977,
489,
1851,
1977,
63,
2124,
26,
267,
1851,
1977,
63,
633,
26,
1455,
921,
846,
1977,
14,
1832,
267,
1851,
1977,
63,
1418,
26,
642,
1831,
5713,
3264,
267,
666,
26,
881,
536,
26,
1379,
446,
11581,
5129,
267,
1174,
26,
9552,
339,
446,
536,
26,
2790,
4770,
543,
1006,
2633,
489,
1851,
1977,
63,
2124,
26,
267,
1851,
1977,
63,
633,
26,
1455,
921,
846,
1977,
14,
1832,
267,
1851,
1977,
63,
1418,
26,
642,
1831,
5713,
3264,
267,
666,
26,
881,
536,
26,
1379,
446,
8256,
73,
509,
22042,
881,
2004,
26,
7497,
9386,
881,
4897,
26,
1379,
22240,
881,
8261,
26,
1379,
377,
287,
867,
881,
21395,
26,
662,
392,
10175,
88,
3263,
23,
881,
16723,
26,
11738,
4587,
881,
900,
63,
2619,
26,
437,
8534,
15
] |
[
2647,
15,
1393,
15,
1548,
199,
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
199,
3,
1898,
26,
334,
67,
9,
14894,
12,
603,
3258,
72,
1054,
1488,
19194,
1237,
8593,
24552,
2509,
2726,
9,
665,
2664,
21889,
1054,
14,
16540,
72,
1237,
32,
6799,
14,
957,
30,
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,
199,
199,
8490,
63,
8314,
275,
2420,
2343,
63,
1023,
582,
298,
17,
14,
17,
401,
490,
298,
1205,
582,
2097,
7780,
2255,
490,
298,
4946,
63,
991,
582,
298,
9387,
3570,
199,
199,
8948,
275,
519,
624,
199,
2595,
199,
578,
26,
1851,
1977,
63,
2124,
199,
3612,
63,
1802,
26,
10560,
503,
14185,
15424,
687,
5365,
1977,
199,
1802,
26,
523,
446,
10560,
503,
14185,
15424,
687,
5365,
1977,
199,
5983,
26,
523,
446,
25204,
1077,
506,
3247,
465,
282,
18916,
769,
523,
446,
961,
1077,
506,
21471,
543,
1950,
445,
8,
1832,
9,
436,
7057,
445,
8,
5967,
9,
199,
2502,
26,
523,
446,
603,
3258,
72,
1054,
1488,
19194,
1237,
8593,
24552,
2509,
2726,
9,
199,
7538,
26,
523,
446,
1134,
846,
1977,
199,
1023,
63,
3270,
26,
298,
18,
14,
24,
2,
199,
1419,
26,
523,
1851,
1977,
63,
633,
26,
272,
1369,
26,
489,
446,
2851,
402,
314,
5365,
1977,
1256,
17416,
30456,
701,
2622,
3304,
1591,
272,
1415,
26,
2549,
272,
730,
26,
620,
523,
1851,
1977,
63,
1418,
26,
272,
1369,
26,
489,
446,
710,
1526,
2737,
4453,
5365,
1977,
370,
20210,
3261,
2879,
272,
1415,
26,
2549,
272,
730,
26,
620,
523,
666,
26,
272,
1369,
26,
489,
446,
25022,
314,
4770,
2897,
272,
26265,
26,
489,
536,
26,
267,
1369,
26,
881,
446,
2812,
402,
314,
4770,
370,
506,
2737,
267,
1415,
26,
2549,
267,
730,
26,
620,
489,
2004,
26,
267,
1369,
26,
881,
446,
9795,
402,
314,
4770,
267,
3415,
26,
881,
446,
23241,
881,
446,
7497,
9386,
881,
446,
799,
280,
581,
267,
730,
26,
620,
489,
4897,
26,
267,
1369,
26,
881,
446,
710,
4897,
626,
314,
4770,
1077,
506,
4568,
543,
267,
730,
26,
620,
489,
8261,
26,
267,
1369,
26,
881,
446,
710,
8261,
314,
4770,
911,
506,
7943,
370,
267,
730,
26,
620,
489,
21395,
26,
267,
1369,
26,
881,
446,
3918,
8126,
5022,
503,
21395,
12,
444,
14,
662,
392,
262,
1148,
653,
57,
23,
267,
730,
26,
620,
489,
16723,
26,
267,
1369,
26,
881,
446,
710,
31139,
4568,
543,
314,
4770,
267,
730,
26,
1109,
489,
900,
63,
2619,
26,
267,
1369,
26,
881,
446,
4703,
2619,
4568,
543,
314,
4770,
12,
444,
14,
437,
8534,
15,
10655,
422,
267,
730,
26,
620,
489,
1369,
26,
267,
1369,
26,
881,
446,
710,
1369,
402,
314,
2403,
267,
730,
26,
620,
489,
14095,
63,
1562,
26,
267,
1369,
26,
881,
446,
24309,
7476,
2287,
402,
4770,
267,
730,
26,
620,
489,
27490,
63,
1562,
26,
267,
1369,
26,
881,
446,
5244,
711,
4073,
2287,
402,
4770,
267,
730,
26,
620,
489,
18896,
26,
267,
1369,
26,
881,
446,
491,
31429,
3786,
315,
6107,
1475,
267,
730,
26,
1109,
489,
18154,
26,
267,
1369,
26,
881,
446,
19944,
7779,
315,
6107,
1475,
267,
730,
26,
1109,
489,
8966,
63,
354,
26,
267,
1369,
26,
881,
446,
2812,
402,
8966,
367,
4770,
267,
730,
26,
620,
489,
8966,
63,
9339,
26,
267,
1369,
26,
881,
446,
18684,
14617,
1329,
367,
4770,
267,
730,
26,
620,
489,
8966,
63,
2123,
26,
267,
1369,
26,
881,
446,
18684,
3031,
367,
4770,
267,
730,
26,
620,
489,
6786,
26,
267,
1369,
26,
881,
446,
5429,
1470,
367,
314,
4770,
14,
961,
883,
506,
18502,
6302,
267,
730,
26,
620,
489,
3762,
26,
267,
1369,
26,
881,
446,
6184,
3762,
626,
314,
2403,
1443,
1929,
370,
506,
4568,
543,
267,
730,
26,
769,
489,
3537,
63,
955,
26,
267,
1369,
26,
881,
446,
1471,
2187,
315,
5365,
1977,
267,
730,
26,
1211,
272,
1415,
26,
2549,
523,
1174,
26,
272,
1369,
26,
489,
446,
3645,
445,
8,
1881,
9,
503,
445,
8,
5575,
9,
367,
7791,
503,
12881,
14,
272,
3415,
26,
359,
9552,
12,
3451,
1622,
272,
849,
26,
3451,
272,
730,
26,
620,
523,
4107,
63,
8356,
26,
272,
1369,
26,
489,
446,
1204,
267,
982,
445,
8,
889,
395,
7799,
14512,
911,
440,
506,
16468,
14,
267,
961,
1077,
1454,
506,
1202,
641,
4954,
1183,
22284,
15424,
1808,
291,
13,
1737,
14512,
14,
272,
849,
26,
298,
5066,
2,
272,
730,
26,
2155,
199,
624,
199,
199,
8918,
275,
519,
624,
199,
13,
536,
26,
298,
774,
5365,
1977,
4770,
859,
2,
523,
1950,
26,
2257,
523,
7057,
26,
11667,
523,
13082,
63,
5047,
26,
756,
523,
6527,
26,
272,
446,
536,
26,
2790,
4770,
4453,
5365,
1977,
543,
1454,
1415,
2556,
489,
1851,
1977,
63,
2124,
26,
267,
1851,
1977,
63,
633,
26,
1455,
921,
846,
1977,
14,
1832,
267,
1851,
1977,
63,
1418,
26,
642,
1831,
5713,
3264,
267,
666,
26,
881,
536,
26,
1379,
446,
11581,
5129,
267,
1174,
26,
3451,
339,
446,
536,
26,
8496,
4770,
4453,
1851,
1977,
489,
1851,
1977,
63,
2124,
26,
267,
1851,
1977,
63,
633,
26,
1455,
921,
846,
1977,
14,
1832,
267,
1851,
1977,
63,
1418,
26,
642,
1831,
5713,
3264,
267,
666,
26,
881,
536,
26,
1379,
446,
11581,
5129,
267,
1174,
26,
9552,
339,
446,
536,
26,
2790,
4770,
543,
1006,
2633,
489,
1851,
1977,
63,
2124,
26,
267,
1851,
1977,
63,
633,
26,
1455,
921,
846,
1977,
14,
1832,
267,
1851,
1977,
63,
1418,
26,
642,
1831,
5713,
3264,
267,
666,
26,
881,
536,
26,
1379,
446,
8256,
73,
509,
22042,
881,
2004,
26,
7497,
9386,
881,
4897,
26,
1379,
22240,
881,
8261,
26,
1379,
377,
287,
867,
881,
21395,
26,
662,
392,
10175,
88,
3263,
23,
881,
16723,
26,
11738,
4587,
881,
900,
63,
2619,
26,
437,
8534,
15,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
sassoftware/rmake3
|
rmake/plugins/plugin.py
|
2
|
3024
|
#
# Copyright (c) SAS Institute 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.
#
"""
Definition of plugins available for rmake plugins.
Plugin writers should derive from one of these classes.
The plugin will be called with the hooks described here, if the
correct program is being run. For example, when running rmake-server,
the server hooks will be run.
"""
from rmake.lib.pluginlib import Plugin
TYPE_CLIENT = 0
TYPE_SERVER = 1
TYPE_SUBSCRIBER = 2
TYPE_LIBRARY = 3
class ClientPlugin(Plugin):
types = [TYPE_CLIENT]
def client_preInit(self, main, argv):
"""
Called right after plugins have been loaded.
"""
pass
def client_preCommand(self, main, thisCommand, (buildConfig, conaryConfig),
argSet, args):
pass
def client_preCommand2(self, main, client, command):
"""
Called after the command-line client has instantiated,
but before the command has been executed.
"""
pass
class ServerPlugin(Plugin):
types = [TYPE_SERVER]
def server_preConfig(self, main):
"""
Called before the configuration file has been read in.
"""
pass
def server_preInit(self, main, argv):
"""
Called before the server has been instantiated.
"""
pass
def server_postInit(self, server):
"""
Called after the server has been instantiated but before
serving is done.
"""
pass
def server_pidDied(self, server, pid, status):
"""
Called when the server collects a child process that has died.
"""
pass
def server_loop(self, server):
"""
Called once per server loop, between requests.
"""
pass
def server_builderInit(self, server, builder):
"""
Called when the server instantiates a builder for a job.
"""
pass
def server_shutDown(self, server):
"""
Called when the server is halting.
"""
pass
class SubscriberPlugin(Plugin):
types = [TYPE_SUBSCRIBER]
protocol = None
def subscriber_get(self, uri, name):
"""
Should return a child of the StatusSubscirber class.
"""
pass
class LibraryPlugin(Plugin):
types = [TYPE_LIBRARY]
protocol = None
def library_init(self):
"""
Called when using rmake as a library.
"""
|
apache-2.0
|
[
3,
199,
3,
1898,
334,
67,
9,
26124,
1010,
25585,
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,
3,
421,
199,
624,
199,
10701,
402,
8963,
2808,
367,
519,
1875,
8963,
14,
199,
199,
5061,
2211,
878,
1077,
23519,
687,
1373,
402,
3520,
3992,
14,
199,
199,
1918,
3589,
911,
506,
2797,
543,
314,
12604,
11736,
2348,
12,
340,
314,
199,
4525,
2240,
365,
3769,
1255,
14,
221,
2104,
2893,
12,
1380,
3879,
519,
1875,
13,
1000,
12,
199,
1589,
1654,
12604,
911,
506,
1255,
14,
199,
624,
199,
504,
519,
1875,
14,
773,
14,
2718,
773,
492,
11349,
199,
199,
2711,
63,
9901,
275,
378,
199,
2711,
63,
6613,
275,
413,
199,
2711,
63,
6348,
51,
27448,
540,
275,
499,
199,
2711,
63,
16983,
275,
650,
199,
199,
533,
6810,
5061,
8,
5061,
304,
339,
2943,
275,
359,
2711,
63,
9901,
61,
339,
347,
1890,
63,
657,
9346,
8,
277,
12,
2446,
12,
9238,
304,
267,
408,
288,
12295,
2451,
2410,
8963,
1172,
2757,
6511,
14,
267,
408,
267,
986,
339,
347,
1890,
63,
657,
3110,
8,
277,
12,
2446,
12,
642,
3110,
12,
334,
1506,
2028,
12,
406,
695,
2028,
395,
586,
1680,
1084,
12,
1249,
304,
267,
986,
339,
347,
1890,
63,
657,
3110,
18,
8,
277,
12,
2446,
12,
1890,
12,
1414,
304,
267,
408,
288,
12295,
2410,
314,
1414,
13,
604,
1890,
965,
17544,
12,
7205,
1325,
2544,
314,
1414,
965,
2757,
7934,
14,
267,
408,
267,
986,
199,
199,
533,
7146,
5061,
8,
5061,
304,
339,
2943,
275,
359,
2711,
63,
6613,
61,
339,
347,
1654,
63,
657,
2028,
8,
277,
12,
2446,
304,
267,
408,
288,
12295,
2544,
314,
2897,
570,
965,
2757,
1586,
315,
14,
267,
408,
267,
986,
339,
347,
1654,
63,
657,
9346,
8,
277,
12,
2446,
12,
9238,
304,
267,
408,
288,
12295,
2544,
314,
1654,
965,
2757,
17544,
14,
267,
408,
267,
986,
339,
347,
1654,
63,
1932,
9346,
8,
277,
12,
1654,
304,
267,
408,
288,
12295,
2410,
314,
1654,
965,
2757,
17544,
1325,
2544,
288,
22701,
365,
4224,
14,
267,
408,
267,
986,
339,
347,
1654,
63,
3150,
1341,
379,
8,
277,
12,
1654,
12,
4422,
12,
2004,
304,
267,
408,
288,
12295,
1380,
314,
1654,
8775,
83,
282,
1982,
2112,
626,
965,
487,
379,
14,
267,
408,
267,
986,
339,
347,
1654,
63,
3813,
8,
277,
12,
1654,
304,
267,
408,
288,
12295,
5403,
1126,
1654,
4438,
12,
3382,
4145,
14,
267,
408,
267,
986,
339,
347,
1654,
63,
5649,
9346,
8,
277,
12,
1654,
12,
6545,
304,
267,
408,
288,
12295,
1380,
314,
1654,
9034,
2335,
282,
6545,
367,
282,
3906,
14,
267,
408,
267,
986,
339,
347,
1654,
63,
609,
337,
3514,
8,
277,
12,
1654,
304,
267,
408,
288,
12295,
1380,
314,
1654,
365,
22939,
1337,
14,
267,
408,
267,
986,
199,
199,
533,
4804,
10979,
5061,
8,
5061,
304,
339,
2943,
275,
359,
2711,
63,
6348,
51,
27448,
540,
61,
272,
4113,
275,
488,
339,
347,
22148,
63,
362,
8,
277,
12,
5108,
12,
536,
304,
267,
408,
288,
7719,
372,
282,
1982,
402,
314,
9795,
2610,
551,
723,
605,
1021,
14,
267,
408,
267,
986,
421,
199,
533,
11243,
5061,
8,
5061,
304,
339,
2943,
275,
359,
2711,
63,
16983,
61,
272,
4113,
275,
488,
339,
347,
3555,
63,
826,
8,
277,
304,
267,
408,
288,
12295,
1380,
1808,
519,
1875,
465,
282,
3555,
14,
267,
408,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
199,
3,
1898,
334,
67,
9,
26124,
1010,
25585,
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,
3,
421,
199,
624,
199,
10701,
402,
8963,
2808,
367,
519,
1875,
8963,
14,
199,
199,
5061,
2211,
878,
1077,
23519,
687,
1373,
402,
3520,
3992,
14,
199,
199,
1918,
3589,
911,
506,
2797,
543,
314,
12604,
11736,
2348,
12,
340,
314,
199,
4525,
2240,
365,
3769,
1255,
14,
221,
2104,
2893,
12,
1380,
3879,
519,
1875,
13,
1000,
12,
199,
1589,
1654,
12604,
911,
506,
1255,
14,
199,
624,
199,
504,
519,
1875,
14,
773,
14,
2718,
773,
492,
11349,
199,
199,
2711,
63,
9901,
275,
378,
199,
2711,
63,
6613,
275,
413,
199,
2711,
63,
6348,
51,
27448,
540,
275,
499,
199,
2711,
63,
16983,
275,
650,
199,
199,
533,
6810,
5061,
8,
5061,
304,
339,
2943,
275,
359,
2711,
63,
9901,
61,
339,
347,
1890,
63,
657,
9346,
8,
277,
12,
2446,
12,
9238,
304,
267,
408,
288,
12295,
2451,
2410,
8963,
1172,
2757,
6511,
14,
267,
408,
267,
986,
339,
347,
1890,
63,
657,
3110,
8,
277,
12,
2446,
12,
642,
3110,
12,
334,
1506,
2028,
12,
406,
695,
2028,
395,
586,
1680,
1084,
12,
1249,
304,
267,
986,
339,
347,
1890,
63,
657,
3110,
18,
8,
277,
12,
2446,
12,
1890,
12,
1414,
304,
267,
408,
288,
12295,
2410,
314,
1414,
13,
604,
1890,
965,
17544,
12,
7205,
1325,
2544,
314,
1414,
965,
2757,
7934,
14,
267,
408,
267,
986,
199,
199,
533,
7146,
5061,
8,
5061,
304,
339,
2943,
275,
359,
2711,
63,
6613,
61,
339,
347,
1654,
63,
657,
2028,
8,
277,
12,
2446,
304,
267,
408,
288,
12295,
2544,
314,
2897,
570,
965,
2757,
1586,
315,
14,
267,
408,
267,
986,
339,
347,
1654,
63,
657,
9346,
8,
277,
12,
2446,
12,
9238,
304,
267,
408,
288,
12295,
2544,
314,
1654,
965,
2757,
17544,
14,
267,
408,
267,
986,
339,
347,
1654,
63,
1932,
9346,
8,
277,
12,
1654,
304,
267,
408,
288,
12295,
2410,
314,
1654,
965,
2757,
17544,
1325,
2544,
288,
22701,
365,
4224,
14,
267,
408,
267,
986,
339,
347,
1654,
63,
3150,
1341,
379,
8,
277,
12,
1654,
12,
4422,
12,
2004,
304,
267,
408,
288,
12295,
1380,
314,
1654,
8775,
83,
282,
1982,
2112,
626,
965,
487,
379,
14,
267,
408,
267,
986,
339,
347,
1654,
63,
3813,
8,
277,
12,
1654,
304,
267,
408,
288,
12295,
5403,
1126,
1654,
4438,
12,
3382,
4145,
14,
267,
408,
267,
986,
339,
347,
1654,
63,
5649,
9346,
8,
277,
12,
1654,
12,
6545,
304,
267,
408,
288,
12295,
1380,
314,
1654,
9034,
2335,
282,
6545,
367,
282,
3906,
14,
267,
408,
267,
986,
339,
347,
1654,
63,
609,
337,
3514,
8,
277,
12,
1654,
304,
267,
408,
288,
12295,
1380,
314,
1654,
365,
22939,
1337,
14,
267,
408,
267,
986,
199,
199,
533,
4804,
10979,
5061,
8,
5061,
304,
339,
2943,
275,
359,
2711,
63,
6348,
51,
27448,
540,
61,
272,
4113,
275,
488,
339,
347,
22148,
63,
362,
8,
277,
12,
5108,
12,
536,
304,
267,
408,
288,
7719,
372,
282,
1982,
402,
314,
9795,
2610,
551,
723,
605,
1021,
14,
267,
408,
267,
986,
421,
199,
533,
11243,
5061,
8,
5061,
304,
339,
2943,
275,
359,
2711,
63,
16983,
61,
272,
4113,
275,
488,
339,
347,
3555,
63,
826,
8,
277,
304,
267,
408,
288,
12295,
1380,
1808,
519,
1875,
465,
282,
3555,
14,
267,
408,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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ogBase:
title = "Search Dialog"
icon = "Search"
needwrapbutton = 1
def __init__(self, root, engine):
self.root = root
self.engine = engine
self.top = None
def open(self, text, searchphrase=None):
self.text = text
if not self.top:
self.create_widgets()
else:
self.top.deiconify()
self.top.tkraise()
if searchphrase:
self.ent.delete(0,"end")
self.ent.insert("end",searchphrase)
self.ent.focus_set()
self.ent.selection_range(0, "end")
self.ent.icursor(0)
self.top.grab_set()
def close(self, event=None):
if self.top:
self.top.grab_release()
self.top.withdraw()
def create_widgets(self):
top = Toplevel(self.root)
top.bind("<Return>", self.default_command)
top.bind("<Escape>", self.close)
top.protocol("WM_DELETE_WINDOW", self.close)
top.wm_title(self.title)
top.wm_iconname(self.icon)
self.top = top
self.row = 0
self.top.grid_columnconfigure(0, pad=2, weight=0)
self.top.grid_columnconfigure(1, pad=2, minsize=100, weight=100)
self.create_entries()
self.create_option_buttons()
self.create_other_buttons()
return self.create_command_buttons()
def make_entry(self, label, var):
l = Label(self.top, text=label)
l.grid(row=self.row, column=0, sticky="nw")
e = Entry(self.top, textvariable=var, exportselection=0)
e.grid(row=self.row, column=1, sticky="nwe")
self.row = self.row + 1
return e
def make_frame(self,labeltext=None):
if labeltext:
l = Label(self.top, text=labeltext)
l.grid(row=self.row, column=0, sticky="nw")
f = Frame(self.top)
f.grid(row=self.row, column=1, columnspan=1, sticky="nwe")
self.row = self.row + 1
return f
def make_button(self, label, command, isdef=0):
b = Button(self.buttonframe,
text=label, command=command,
default=isdef and "active" or "normal")
cols,rows=self.buttonframe.grid_size()
b.grid(pady=1,row=rows,column=0,sticky="ew")
self.buttonframe.grid(rowspan=rows+1)
return b
def create_entries(self):
self.ent = self.make_entry("Find:", self.engine.patvar)
def create_option_buttons(self):
f = self.make_frame("Options")
btn = Checkbutton(f, anchor="w",
variable=self.engine.revar,
text="Regular expression")
btn.pack(side="left", fill="both")
if self.engine.isre():
btn.select()
btn = Checkbutton(f, anchor="w",
variable=self.engine.casevar,
text="Match case")
btn.pack(side="left", fill="both")
if self.engine.iscase():
btn.select()
btn = Checkbutton(f, anchor="w",
variable=self.engine.wordvar,
text="Whole word")
btn.pack(side="left", fill="both")
if self.engine.isword():
btn.select()
if self.needwrapbutton:
btn = Checkbutton(f, anchor="w",
variable=self.engine.wrapvar,
text="Wrap around")
btn.pack(side="left", fill="both")
if self.engine.iswrap():
btn.select()
def create_other_buttons(self):
f = self.make_frame("Direction")
#lbl = Label(f, text="Direction: ")
#lbl.pack(side="left")
btn = Radiobutton(f, anchor="w",
variable=self.engine.backvar, value=1,
text="Up")
btn.pack(side="left", fill="both")
if self.engine.isback():
btn.select()
btn = Radiobutton(f, anchor="w",
variable=self.engine.backvar, value=0,
text="Down")
btn.pack(side="left", fill="both")
if not self.engine.isback():
btn.select()
def create_command_buttons(self):
#
# place button frame on the right
f = self.buttonframe = Frame(self.top)
f.grid(row=0,column=2,padx=2,pady=2,ipadx=2,ipady=2)
b = self.make_button("close", self.close)
b.lower()
|
mit
|
[
504,
22171,
492,
627,
199,
199,
533,
8730,
5619,
1563,
26,
339,
2538,
275,
298,
5278,
30631,
2,
272,
7016,
275,
298,
5278,
2,
272,
1929,
3823,
3887,
275,
413,
339,
347,
636,
826,
721,
277,
12,
1738,
12,
6869,
304,
267,
291,
14,
1231,
275,
1738,
267,
291,
14,
3908,
275,
6869,
267,
291,
14,
2119,
275,
488,
339,
347,
1551,
8,
277,
12,
1318,
12,
2754,
10906,
29,
403,
304,
267,
291,
14,
505,
275,
1318,
267,
340,
440,
291,
14,
2119,
26,
288,
291,
14,
981,
63,
8583,
342,
267,
587,
26,
288,
291,
14,
2119,
14,
271,
4677,
2021,
342,
288,
291,
14,
2119,
14,
2663,
3730,
342,
267,
340,
2754,
10906,
26,
288,
291,
14,
484,
14,
1807,
8,
16,
4589,
500,
531,
288,
291,
14,
484,
14,
3176,
480,
500,
401,
1733,
10906,
9,
267,
291,
14,
484,
14,
12283,
63,
409,
342,
267,
291,
14,
484,
14,
5592,
63,
1842,
8,
16,
12,
298,
500,
531,
267,
291,
14,
484,
14,
530,
300,
1509,
8,
16,
9,
267,
291,
14,
2119,
14,
22090,
63,
409,
342,
339,
347,
4002,
8,
277,
12,
1566,
29,
403,
304,
267,
340,
291,
14,
2119,
26,
288,
291,
14,
2119,
14,
22090,
63,
3221,
342,
288,
291,
14,
2119,
14,
1045,
5485,
342,
339,
347,
1218,
63,
8583,
8,
277,
304,
267,
2746,
275,
14132,
1896,
8,
277,
14,
1231,
9,
267,
2746,
14,
3409,
6757,
1767,
7166,
291,
14,
885,
63,
1531,
9,
267,
2746,
14,
3409,
6757,
10260,
7166,
291,
14,
1600,
9,
267,
2746,
14,
3922,
480,
13073,
63,
7014,
63,
15480,
401,
291,
14,
1600,
9,
267,
2746,
14,
16240,
63,
1213,
8,
277,
14,
1213,
9,
267,
2746,
14,
16240,
63,
4677,
354,
8,
277,
14,
4677,
9,
267,
291,
14,
2119,
275,
2746,
398,
291,
14,
1143,
275,
378,
267,
291,
14,
2119,
14,
3825,
63,
2301,
6472,
8,
16,
12,
6567,
29,
18,
12,
5401,
29,
16,
9,
267,
291,
14,
2119,
14,
3825,
63,
2301,
6472,
8,
17,
12,
6567,
29,
18,
12,
1748,
890,
29,
1960,
12,
5401,
29,
1960,
9,
398,
291,
14,
981,
63,
3189,
342,
267,
291,
14,
981,
63,
1422,
63,
15687,
342,
267,
291,
14,
981,
63,
1848,
63,
15687,
342,
267,
372,
291,
14,
981,
63,
1531,
63,
15687,
342,
339,
347,
1852,
63,
2373,
8,
277,
12,
1768,
12,
2729,
304,
267,
634,
275,
10354,
8,
277,
14,
2119,
12,
1318,
29,
1302,
9,
267,
634,
14,
3825,
8,
1143,
29,
277,
14,
1143,
12,
2763,
29,
16,
12,
17870,
628,
13100,
531,
267,
325,
275,
11855,
8,
277,
14,
2119,
12,
1318,
1975,
29,
1391,
12,
4843,
5592,
29,
16,
9,
267,
325,
14,
3825,
8,
1143,
29,
277,
14,
1143,
12,
2763,
29,
17,
12,
17870,
628,
78,
1129,
531,
267,
291,
14,
1143,
275,
291,
14,
1143,
435,
413,
267,
372,
325,
339,
347,
1852,
63,
1943,
8,
277,
12,
1302,
505,
29,
403,
304,
267,
340,
1768,
505,
26,
288,
634,
275,
10354,
8,
277,
14,
2119,
12,
1318,
29,
1302,
505,
9,
288,
634,
14,
3825,
8,
1143,
29,
277,
14,
1143,
12,
2763,
29,
16,
12,
17870,
628,
13100,
531,
267,
289,
275,
11726,
8,
277,
14,
2119,
9,
267,
289,
14,
3825,
8,
1143,
29,
277,
14,
1143,
12,
2763,
29,
17,
12,
4362,
10384,
29,
17,
12,
17870,
628,
78,
1129,
531,
267,
291,
14,
1143,
275,
291,
14,
1143,
435,
413,
267,
372,
289,
339,
347,
1852,
63,
3887,
8,
277,
12,
1768,
12,
1414,
12,
365,
318,
29,
16,
304,
267,
330,
275,
16005,
8,
277,
14,
3887,
1943,
12,
673,
1318,
29,
1302,
12,
1414,
29,
1531,
12,
673,
849,
29,
374,
318,
436,
298,
2682,
2,
503,
298,
3302,
531,
267,
8850,
12,
3838,
29,
277,
14,
3887,
1943,
14,
3825,
63,
890,
342,
267,
330,
14,
3825,
8,
6226,
89,
29,
17,
12,
1143,
29,
3838,
12,
2301,
29,
16,
12,
27364,
628,
546,
531,
267,
291,
14,
3887,
1943,
14,
3825,
8,
1143,
3751,
29,
3838,
11,
17,
9,
267,
372,
330,
339,
347,
1218,
63,
3189,
8,
277,
304,
267,
291,
14,
484,
275,
291,
14,
1875,
63,
2373,
480,
6591,
6783,
291,
14,
3908,
14,
10853,
1391,
9,
339,
347,
1218,
63,
1422,
63,
15687,
8,
277,
304,
267,
289,
275,
291,
14,
1875,
63,
1943,
480,
4558,
531,
398,
19368,
275,
2670,
3887,
8,
70,
12,
12514,
628,
87,
401,
355,
1750,
29,
277,
14,
3908,
14,
264,
1391,
12,
355,
1318,
628,
16038,
3965,
531,
267,
19368,
14,
1389,
8,
2441,
628,
3039,
401,
5554,
628,
10727,
531,
267,
340,
291,
14,
3908,
14,
374,
264,
837,
288,
19368,
14,
2416,
342,
398,
19368,
275,
2670,
3887,
8,
70,
12,
12514,
628,
87,
401,
355,
1750,
29,
277,
14,
3908,
14,
2546,
1391,
12,
355,
1318,
628,
4486,
1930,
531,
267,
19368,
14,
1389,
8,
2441,
628,
3039,
401,
5554,
628,
10727,
531,
267,
340,
291,
14,
3908,
14,
374,
2546,
837,
288,
19368,
14,
2416,
342,
398,
19368,
275,
2670,
3887,
8,
70,
12,
12514,
628,
87,
401,
355,
1750,
29,
277,
14,
3908,
14,
1027,
1391,
12,
355,
1318,
628,
55,
16668,
4349,
531,
267,
19368,
14,
1389,
8,
2441,
628,
3039,
401,
5554,
628,
10727,
531,
267,
340,
291,
14,
3908,
14,
374,
1027,
837,
288,
19368,
14,
2416,
342,
398,
340,
291,
14,
9321,
3823,
3887,
26,
288,
19368,
275,
2670,
3887,
8,
70,
12,
12514,
628,
87,
401,
490,
1750,
29,
277,
14,
3908,
14,
3823,
1391,
12,
490,
1318,
628,
15991,
6818,
531,
288,
19368,
14,
1389,
8,
2441,
628,
3039,
401,
5554,
628,
10727,
531,
288,
340,
291,
14,
3908,
14,
374,
3823,
837,
355,
19368,
14,
2416,
342,
339,
347,
1218,
63,
1848,
63,
15687,
8,
277,
304,
267,
289,
275,
291,
14,
1875,
63,
1943,
480,
17015,
531,
398,
327,
18842,
275,
10354,
8,
70,
12,
1318,
628,
17015,
26,
6099,
267,
327,
18842,
14,
1389,
8,
2441,
628,
3039,
531,
398,
19368,
275,
3898,
328,
2873,
2471,
8,
70,
12,
12514,
628,
87,
401,
355,
1750,
29
] |
[
22171,
492,
627,
199,
199,
533,
8730,
5619,
1563,
26,
339,
2538,
275,
298,
5278,
30631,
2,
272,
7016,
275,
298,
5278,
2,
272,
1929,
3823,
3887,
275,
413,
339,
347,
636,
826,
721,
277,
12,
1738,
12,
6869,
304,
267,
291,
14,
1231,
275,
1738,
267,
291,
14,
3908,
275,
6869,
267,
291,
14,
2119,
275,
488,
339,
347,
1551,
8,
277,
12,
1318,
12,
2754,
10906,
29,
403,
304,
267,
291,
14,
505,
275,
1318,
267,
340,
440,
291,
14,
2119,
26,
288,
291,
14,
981,
63,
8583,
342,
267,
587,
26,
288,
291,
14,
2119,
14,
271,
4677,
2021,
342,
288,
291,
14,
2119,
14,
2663,
3730,
342,
267,
340,
2754,
10906,
26,
288,
291,
14,
484,
14,
1807,
8,
16,
4589,
500,
531,
288,
291,
14,
484,
14,
3176,
480,
500,
401,
1733,
10906,
9,
267,
291,
14,
484,
14,
12283,
63,
409,
342,
267,
291,
14,
484,
14,
5592,
63,
1842,
8,
16,
12,
298,
500,
531,
267,
291,
14,
484,
14,
530,
300,
1509,
8,
16,
9,
267,
291,
14,
2119,
14,
22090,
63,
409,
342,
339,
347,
4002,
8,
277,
12,
1566,
29,
403,
304,
267,
340,
291,
14,
2119,
26,
288,
291,
14,
2119,
14,
22090,
63,
3221,
342,
288,
291,
14,
2119,
14,
1045,
5485,
342,
339,
347,
1218,
63,
8583,
8,
277,
304,
267,
2746,
275,
14132,
1896,
8,
277,
14,
1231,
9,
267,
2746,
14,
3409,
6757,
1767,
7166,
291,
14,
885,
63,
1531,
9,
267,
2746,
14,
3409,
6757,
10260,
7166,
291,
14,
1600,
9,
267,
2746,
14,
3922,
480,
13073,
63,
7014,
63,
15480,
401,
291,
14,
1600,
9,
267,
2746,
14,
16240,
63,
1213,
8,
277,
14,
1213,
9,
267,
2746,
14,
16240,
63,
4677,
354,
8,
277,
14,
4677,
9,
267,
291,
14,
2119,
275,
2746,
398,
291,
14,
1143,
275,
378,
267,
291,
14,
2119,
14,
3825,
63,
2301,
6472,
8,
16,
12,
6567,
29,
18,
12,
5401,
29,
16,
9,
267,
291,
14,
2119,
14,
3825,
63,
2301,
6472,
8,
17,
12,
6567,
29,
18,
12,
1748,
890,
29,
1960,
12,
5401,
29,
1960,
9,
398,
291,
14,
981,
63,
3189,
342,
267,
291,
14,
981,
63,
1422,
63,
15687,
342,
267,
291,
14,
981,
63,
1848,
63,
15687,
342,
267,
372,
291,
14,
981,
63,
1531,
63,
15687,
342,
339,
347,
1852,
63,
2373,
8,
277,
12,
1768,
12,
2729,
304,
267,
634,
275,
10354,
8,
277,
14,
2119,
12,
1318,
29,
1302,
9,
267,
634,
14,
3825,
8,
1143,
29,
277,
14,
1143,
12,
2763,
29,
16,
12,
17870,
628,
13100,
531,
267,
325,
275,
11855,
8,
277,
14,
2119,
12,
1318,
1975,
29,
1391,
12,
4843,
5592,
29,
16,
9,
267,
325,
14,
3825,
8,
1143,
29,
277,
14,
1143,
12,
2763,
29,
17,
12,
17870,
628,
78,
1129,
531,
267,
291,
14,
1143,
275,
291,
14,
1143,
435,
413,
267,
372,
325,
339,
347,
1852,
63,
1943,
8,
277,
12,
1302,
505,
29,
403,
304,
267,
340,
1768,
505,
26,
288,
634,
275,
10354,
8,
277,
14,
2119,
12,
1318,
29,
1302,
505,
9,
288,
634,
14,
3825,
8,
1143,
29,
277,
14,
1143,
12,
2763,
29,
16,
12,
17870,
628,
13100,
531,
267,
289,
275,
11726,
8,
277,
14,
2119,
9,
267,
289,
14,
3825,
8,
1143,
29,
277,
14,
1143,
12,
2763,
29,
17,
12,
4362,
10384,
29,
17,
12,
17870,
628,
78,
1129,
531,
267,
291,
14,
1143,
275,
291,
14,
1143,
435,
413,
267,
372,
289,
339,
347,
1852,
63,
3887,
8,
277,
12,
1768,
12,
1414,
12,
365,
318,
29,
16,
304,
267,
330,
275,
16005,
8,
277,
14,
3887,
1943,
12,
673,
1318,
29,
1302,
12,
1414,
29,
1531,
12,
673,
849,
29,
374,
318,
436,
298,
2682,
2,
503,
298,
3302,
531,
267,
8850,
12,
3838,
29,
277,
14,
3887,
1943,
14,
3825,
63,
890,
342,
267,
330,
14,
3825,
8,
6226,
89,
29,
17,
12,
1143,
29,
3838,
12,
2301,
29,
16,
12,
27364,
628,
546,
531,
267,
291,
14,
3887,
1943,
14,
3825,
8,
1143,
3751,
29,
3838,
11,
17,
9,
267,
372,
330,
339,
347,
1218,
63,
3189,
8,
277,
304,
267,
291,
14,
484,
275,
291,
14,
1875,
63,
2373,
480,
6591,
6783,
291,
14,
3908,
14,
10853,
1391,
9,
339,
347,
1218,
63,
1422,
63,
15687,
8,
277,
304,
267,
289,
275,
291,
14,
1875,
63,
1943,
480,
4558,
531,
398,
19368,
275,
2670,
3887,
8,
70,
12,
12514,
628,
87,
401,
355,
1750,
29,
277,
14,
3908,
14,
264,
1391,
12,
355,
1318,
628,
16038,
3965,
531,
267,
19368,
14,
1389,
8,
2441,
628,
3039,
401,
5554,
628,
10727,
531,
267,
340,
291,
14,
3908,
14,
374,
264,
837,
288,
19368,
14,
2416,
342,
398,
19368,
275,
2670,
3887,
8,
70,
12,
12514,
628,
87,
401,
355,
1750,
29,
277,
14,
3908,
14,
2546,
1391,
12,
355,
1318,
628,
4486,
1930,
531,
267,
19368,
14,
1389,
8,
2441,
628,
3039,
401,
5554,
628,
10727,
531,
267,
340,
291,
14,
3908,
14,
374,
2546,
837,
288,
19368,
14,
2416,
342,
398,
19368,
275,
2670,
3887,
8,
70,
12,
12514,
628,
87,
401,
355,
1750,
29,
277,
14,
3908,
14,
1027,
1391,
12,
355,
1318,
628,
55,
16668,
4349,
531,
267,
19368,
14,
1389,
8,
2441,
628,
3039,
401,
5554,
628,
10727,
531,
267,
340,
291,
14,
3908,
14,
374,
1027,
837,
288,
19368,
14,
2416,
342,
398,
340,
291,
14,
9321,
3823,
3887,
26,
288,
19368,
275,
2670,
3887,
8,
70,
12,
12514,
628,
87,
401,
490,
1750,
29,
277,
14,
3908,
14,
3823,
1391,
12,
490,
1318,
628,
15991,
6818,
531,
288,
19368,
14,
1389,
8,
2441,
628,
3039,
401,
5554,
628,
10727,
531,
288,
340,
291,
14,
3908,
14,
374,
3823,
837,
355,
19368,
14,
2416,
342,
339,
347,
1218,
63,
1848,
63,
15687,
8,
277,
304,
267,
289,
275,
291,
14,
1875,
63,
1943,
480,
17015,
531,
398,
327,
18842,
275,
10354,
8,
70,
12,
1318,
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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
] |
gunchleoc/django
|
tests/migrations/test_optimizer.py
|
118
|
22678
|
# -*- coding: utf-8 -*-
from django.db import migrations, models
from django.db.migrations.optimizer import MigrationOptimizer
from django.test import SimpleTestCase
from .models import CustomModelBase, EmptyManager
class OptimizerTests(SimpleTestCase):
"""
Tests the migration autodetector.
"""
def optimize(self, operations):
"""
Handy shortcut for getting results + number of loops
"""
optimizer = MigrationOptimizer()
return optimizer.optimize(operations), optimizer._iterations
def assertOptimizesTo(self, operations, expected, exact=None, less_than=None):
result, iterations = self.optimize(operations)
result = [repr(f.deconstruct()) for f in result]
expected = [repr(f.deconstruct()) for f in expected]
self.assertEqual(expected, result)
if exact is not None and iterations != exact:
raise self.failureException(
"Optimization did not take exactly %s iterations (it took %s)" % (exact, iterations)
)
if less_than is not None and iterations >= less_than:
raise self.failureException(
"Optimization did not take less than %s iterations (it took %s)" % (less_than, iterations)
)
def assertDoesNotOptimize(self, operations):
self.assertOptimizesTo(operations, operations)
def test_single(self):
"""
Tests that the optimizer does nothing on a single operation,
and that it does it in just one pass.
"""
self.assertOptimizesTo(
[migrations.DeleteModel("Foo")],
[migrations.DeleteModel("Foo")],
exact=1,
)
def test_create_delete_model(self):
"""
CreateModel and DeleteModel should collapse into nothing.
"""
self.assertOptimizesTo(
[
migrations.CreateModel("Foo", [("name", models.CharField(max_length=255))]),
migrations.DeleteModel("Foo"),
],
[],
)
def test_create_rename_model(self):
"""
CreateModel should absorb RenameModels.
"""
managers = [('objects', EmptyManager())]
self.assertOptimizesTo(
[
migrations.CreateModel(
name="Foo",
fields=[("name", models.CharField(max_length=255))],
options={'verbose_name': 'Foo'},
bases=(CustomModelBase),
managers=managers,
),
migrations.RenameModel("Foo", "Bar"),
],
[
migrations.CreateModel(
"Bar",
[("name", models.CharField(max_length=255))],
options={'verbose_name': 'Foo'},
bases=(CustomModelBase),
managers=managers,
)
],
)
def test_rename_model_self(self):
"""
RenameModels should absorb themselves.
"""
self.assertOptimizesTo(
[
migrations.RenameModel("Foo", "Baa"),
migrations.RenameModel("Baa", "Bar"),
],
[
migrations.RenameModel("Foo", "Bar"),
],
)
def _test_create_alter_foo_delete_model(self, alter_foo):
"""
CreateModel, AlterModelTable, AlterUniqueTogether/AlterIndexTogether/
AlterOrderWithRespectTo, and DeleteModel should collapse into nothing.
"""
self.assertOptimizesTo(
[
migrations.CreateModel("Foo", [("name", models.CharField(max_length=255))]),
migrations.AlterModelTable("Foo", "woohoo"),
alter_foo,
migrations.DeleteModel("Foo"),
],
[],
)
def test_create_alter_unique_delete_model(self):
self._test_create_alter_foo_delete_model(migrations.AlterUniqueTogether("Foo", [["a", "b"]]))
def test_create_alter_index_delete_model(self):
self._test_create_alter_foo_delete_model(migrations.AlterIndexTogether("Foo", [["a", "b"]]))
def test_create_alter_owrt_delete_model(self):
self._test_create_alter_foo_delete_model(migrations.AlterOrderWithRespectTo("Foo", "a"))
def _test_alter_alter_model(self, alter_foo, alter_bar):
"""
Two AlterUniqueTogether/AlterIndexTogether/AlterOrderWithRespectTo
should collapse into the second.
"""
self.assertOptimizesTo(
[
alter_foo,
alter_bar,
],
[
alter_bar,
],
)
def test_alter_alter_table_model(self):
self._test_alter_alter_model(
migrations.AlterModelTable("Foo", "a"),
migrations.AlterModelTable("Foo", "b"),
)
def test_alter_alter_unique_model(self):
self._test_alter_alter_model(
migrations.AlterUniqueTogether("Foo", [["a", "b"]]),
migrations.AlterUniqueTogether("Foo", [["a", "c"]]),
)
def test_alter_alter_index_model(self):
self._test_alter_alter_model(
migrations.AlterIndexTogether("Foo", [["a", "b"]]),
migrations.AlterIndexTogether("Foo", [["a", "c"]]),
)
def test_alter_alter_owrt_model(self):
self._test_alter_alter_model(
migrations.AlterOrderWithRespectTo("Foo", "a"),
migrations.AlterOrderWithRespectTo("Foo", "b"),
)
def test_optimize_through_create(self):
"""
We should be able to optimize away create/delete through a create or delete
of a different model, but only if the create operation does not mention the model
at all.
"""
# These should work
self.assertOptimizesTo(
[
migrations.CreateModel("Foo", [("name", models.CharField(max_length=255))]),
migrations.CreateModel("Bar", [("size", models.IntegerField())]),
migrations.DeleteModel("Foo"),
],
[
migrations.CreateModel("Bar", [("size", models.IntegerField())]),
],
)
self.assertOptimizesTo(
[
migrations.CreateModel("Foo", [("name", models.CharField(max_length=255))]),
migrations.CreateModel("Bar", [("size", models.IntegerField())]),
migrations.DeleteModel("Bar"),
migrations.DeleteModel("Foo"),
],
[],
)
self.assertOptimizesTo(
[
migrations.CreateModel("Foo", [("name", models.CharField(max_length=255))]),
migrations.CreateModel("Bar", [("size", models.IntegerField())]),
migrations.DeleteModel("Foo"),
migrations.DeleteModel("Bar"),
],
[],
)
# This should not work - FK should block it
self.assertOptimizesTo(
[
migrations.CreateModel("Foo", [("name", models.CharField(max_length=255))]),
migrations.CreateModel("Bar", [("other", models.ForeignKey("testapp.Foo", models.CASCADE))]),
migrations.DeleteModel("Foo"),
],
[
migrations.CreateModel("Foo", [("name", models.CharField(max_length=255))]),
migrations.CreateModel("Bar", [("other", models.ForeignKey("testapp.Foo", models.CASCADE))]),
migrations.DeleteModel("Foo"),
],
)
# This should not work - bases should block it
self.assertOptimizesTo(
[
migrations.CreateModel("Foo", [("name", models.CharField(max_length=255))]),
migrations.CreateModel("Bar", [("size", models.IntegerField())], bases=("testapp.Foo", )),
migrations.DeleteModel("Foo"),
],
[
migrations.CreateModel("Foo", [("name", models.CharField(max_length=255))]),
migrations.CreateModel("Bar", [("size", models.IntegerField())], bases=("testapp.Foo", )),
migrations.DeleteModel("Foo"),
],
)
def test_create_model_add_field(self):
"""
AddField should optimize into CreateModel.
"""
managers = [('objects', EmptyManager())]
self.assertOptimizesTo(
[
migrations.CreateModel(
name="Foo",
fields=[("name", models.CharField(max_length=255))],
options={'verbose_name': 'Foo'},
bases=(CustomModelBase),
managers=managers,
),
migrations.AddField("Foo", "age", models.IntegerField()),
],
[
migrations.CreateModel(
name="Foo",
fields=[
("name", models.CharField(max_length=255)),
("age", models.IntegerField()),
],
options={'verbose_name': 'Foo'},
bases=(CustomModelBase),
managers=managers,
),
],
)
def test_create_model_add_field_not_through_fk(self):
"""
AddField should NOT optimize into CreateModel if it's an FK to a model
that's between them.
"""
self.assertOptimizesTo(
[
migrations.CreateModel("Foo", [("name", models.CharField(max_length=255))]),
migrations.CreateModel("Link", [("url", models.TextField())]),
migrations.AddField("Foo", "link", models.ForeignKey("migrations.Link", models.CASCADE)),
],
[
migrations.CreateModel("Foo", [("name", models.CharField(max_length=255))]),
migrations.CreateModel("Link", [("url", models.TextField())]),
migrations.AddField("Foo", "link", models.ForeignKey("migrations.Link", models.CASCADE)),
],
)
def test_create_model_add_field_not_through_m2m_through(self):
"""
AddField should NOT optimize into CreateModel if it's an M2M using a
through that's created between them.
"""
# Note: The middle model is not actually a valid through model,
# but that doesn't matter, as we never render it.
self.assertOptimizesTo(
[
migrations.CreateModel("Foo", [("name", models.CharField(max_length=255))]),
migrations.CreateModel("LinkThrough", []),
migrations.AddField(
"Foo", "link", models.ManyToManyField("migrations.Link", through="migrations.LinkThrough")
),
],
[
migrations.CreateModel("Foo", [("name", models.CharField(max_length=255))]),
migrations.CreateModel("LinkThrough", []),
migrations.AddField(
"Foo", "link", models.ManyToManyField("migrations.Link", through="migrations.LinkThrough")
),
],
)
def test_create_model_alter_field(self):
"""
AlterField should optimize into CreateModel.
"""
managers = [('objects', EmptyManager())]
self.assertOptimizesTo(
[
migrations.CreateModel(
name="Foo",
fields=[("name", models.CharField(max_length=255))],
options={'verbose_name': 'Foo'},
bases=(CustomModelBase),
managers=managers,
),
migrations.AlterField("Foo", "name", models.IntegerField()),
],
[
migrations.CreateModel(
name="Foo",
fields=[
("name", models.IntegerField()),
],
options={'verbose_name': 'Foo'},
bases=(CustomModelBase),
managers=managers,
),
],
)
def test_create_model_rename_field(self):
"""
RenameField should optimize into CreateModel.
"""
managers = [('objects', EmptyManager())]
self.assertOptimizesTo(
[
migrations.CreateModel(
name="Foo",
fields=[("name", models.CharField(max_length=255))],
options={'verbose_name': 'Foo'},
bases=(CustomModelBase),
managers=managers,
),
migrations.RenameField("Foo", "name", "title"),
],
[
migrations.CreateModel(
name="Foo",
fields=[
("title", models.CharField(max_length=255)),
],
options={'verbose_name': 'Foo'},
bases=(CustomModelBase),
managers=managers,
),
],
)
def test_add_field_rename_field(self):
"""
RenameField should optimize into AddField
"""
self.assertOptimizesTo(
[
migrations.AddField("Foo", "name", models.CharField(max_length=255)),
migrations.RenameField("Foo", "name", "title"),
],
[
migrations.AddField("Foo", "title", models.CharField(max_length=255)),
],
)
def test_alter_field_rename_field(self):
"""
RenameField should optimize to the other side of AlterField,
and into itself.
"""
self.assertOptimizesTo(
[
migrations.AlterField("Foo", "name", models.CharField(max_length=255)),
migrations.RenameField("Foo", "name", "title"),
migrations.RenameField("Foo", "title", "nom"),
],
[
migrations.RenameField("Foo", "name", "nom"),
migrations.AlterField("Foo", "nom", models.CharField(max_length=255)),
],
)
def test_create_model_remove_field(self):
"""
RemoveField should optimize into CreateModel.
"""
managers = [('objects', EmptyManager())]
self.assertOptimizesTo(
[
migrations.CreateModel(
name="Foo",
fields=[
("name", models.CharField(max_length=255)),
("age", models.IntegerField()),
],
options={'verbose_name': 'Foo'},
bases=(CustomModelBase),
managers=managers,
),
migrations.RemoveField("Foo", "age"),
],
[
migrations.CreateModel(
name="Foo",
fields=[
("name", models.CharField(max_length=255)),
],
options={'verbose_name': 'Foo'},
bases=(CustomModelBase),
managers=managers,
),
],
)
def test_add_field_alter_field(self):
"""
AlterField should optimize into AddField.
"""
self.assertOptimizesTo(
[
migrations.AddField("Foo", "age", models.IntegerField()),
migrations.AlterField("Foo", "age", models.FloatField(default=2.4)),
],
[
migrations.AddField("Foo", name="age", field=models.FloatField(default=2.4)),
],
)
def test_add_field_delete_field(self):
"""
RemoveField should cancel AddField
"""
self.assertOptimizesTo(
[
migrations.AddField("Foo", "age", models.IntegerField()),
migrations.RemoveField("Foo", "age"),
],
[],
)
def test_alter_field_delete_field(self):
"""
RemoveField should absorb AlterField
"""
self.assertOptimizesTo(
[
migrations.AlterField("Foo", "age", models.IntegerField()),
migrations.RemoveField("Foo", "age"),
],
[
migrations.RemoveField("Foo", "age"),
],
)
def _test_create_alter_foo_field(self, alter):
"""
CreateModel, AlterFooTogether/AlterOrderWithRespectTo followed by an
add/alter/rename field should optimize to CreateModel and the Alter*
"""
# AddField
self.assertOptimizesTo(
[
migrations.CreateModel("Foo", [
("a", models.IntegerField()),
("b", models.IntegerField()),
]),
alter,
migrations.AddField("Foo", "c", models.IntegerField()),
],
[
migrations.CreateModel("Foo", [
("a", models.IntegerField()),
("b", models.IntegerField()),
("c", models.IntegerField()),
]),
alter,
],
)
# AlterField
self.assertDoesNotOptimize(
[
migrations.CreateModel("Foo", [
("a", models.IntegerField()),
("b", models.IntegerField()),
]),
alter,
migrations.AlterField("Foo", "b", models.CharField(max_length=255)),
],
)
self.assertOptimizesTo(
[
migrations.CreateModel("Foo", [
("a", models.IntegerField()),
("b", models.IntegerField()),
("c", models.IntegerField()),
]),
alter,
migrations.AlterField("Foo", "c", models.CharField(max_length=255)),
],
[
migrations.CreateModel("Foo", [
("a", models.IntegerField()),
("b", models.IntegerField()),
("c", models.CharField(max_length=255)),
]),
alter,
],
)
# RenameField
self.assertDoesNotOptimize(
[
migrations.CreateModel("Foo", [
("a", models.IntegerField()),
("b", models.IntegerField()),
]),
alter,
migrations.RenameField("Foo", "b", "c"),
],
)
self.assertOptimizesTo(
[
migrations.CreateModel("Foo", [
("a", models.IntegerField()),
("b", models.IntegerField()),
]),
alter,
migrations.RenameField("Foo", "b", "x"),
migrations.RenameField("Foo", "x", "c"),
],
[
migrations.CreateModel("Foo", [
("a", models.IntegerField()),
("b", models.IntegerField()),
]),
alter,
migrations.RenameField("Foo", "b", "c"),
],
)
self.assertOptimizesTo(
[
migrations.CreateModel("Foo", [
("a", models.IntegerField()),
("b", models.IntegerField()),
("c", models.IntegerField()),
]),
alter,
migrations.RenameField("Foo", "c", "d"),
],
[
migrations.CreateModel("Foo", [
("a", models.IntegerField()),
("b", models.IntegerField()),
("d", models.IntegerField()),
]),
alter,
],
)
# RemoveField
self.assertDoesNotOptimize(
[
migrations.CreateModel("Foo", [
("a", models.IntegerField()),
("b", models.IntegerField()),
]),
alter,
migrations.RemoveField("Foo", "b"),
],
)
self.assertOptimizesTo(
[
migrations.CreateModel("Foo", [
("a", models.IntegerField()),
("b", models.IntegerField()),
("c", models.IntegerField()),
]),
alter,
migrations.RemoveField("Foo", "c"),
],
[
migrations.CreateModel("Foo", [
("a", models.IntegerField()),
("b", models.IntegerField()),
]),
alter,
],
)
def test_create_alter_unique_field(self):
self._test_create_alter_foo_field(migrations.AlterUniqueTogether("Foo", [["a", "b"]]))
def test_create_alter_index_field(self):
self._test_create_alter_foo_field(migrations.AlterIndexTogether("Foo", [["a", "b"]]))
def test_create_alter_owrt_field(self):
self._test_create_alter_foo_field(migrations.AlterOrderWithRespectTo("Foo", "b"))
def test_optimize_through_fields(self):
"""
Checks that field-level through checking is working.
This should manage to collapse model Foo to nonexistence,
and model Bar to a single IntegerField called "width".
"""
self.assertOptimizesTo(
[
migrations.CreateModel("Foo", [("name", models.CharField(max_length=255))]),
migrations.CreateModel("Bar", [("size", models.IntegerField())]),
migrations.AddField("Foo", "age", models.IntegerField()),
migrations.AddField("Bar", "width", models.IntegerField()),
migrations.AlterField("Foo", "age", models.IntegerField()),
migrations.RenameField("Bar", "size", "dimensions"),
migrations.RemoveField("Foo", "age"),
migrations.RenameModel("Foo", "Phou"),
migrations.RemoveField("Bar", "dimensions"),
migrations.RenameModel("Phou", "Fou"),
migrations.DeleteModel("Fou"),
],
[
migrations.CreateModel("Bar", [("width", models.IntegerField())]),
],
)
|
bsd-3-clause
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
199,
504,
1639,
14,
697,
492,
6180,
12,
1709,
199,
504,
1639,
14,
697,
14,
7685,
14,
12290,
492,
12090,
13946,
199,
504,
1639,
14,
396,
492,
24424,
199,
199,
504,
1275,
992,
492,
8388,
1685,
1563,
12,
9630,
2988,
421,
199,
533,
19246,
1793,
2925,
8,
17968,
304,
272,
408,
272,
6496,
314,
8367,
28537,
9119,
14,
272,
408,
339,
347,
13497,
8,
277,
12,
5331,
304,
267,
408,
267,
18405,
89,
17522,
367,
10232,
2058,
435,
1329,
402,
17222,
267,
408,
267,
10736,
275,
12090,
13946,
342,
267,
372,
10736,
14,
13416,
8,
8170,
395,
10736,
423,
13570,
339,
347,
702,
9867,
6491,
1378,
8,
277,
12,
5331,
12,
1420,
12,
5835,
29,
403,
12,
6656,
63,
13797,
29,
403,
304,
267,
754,
12,
10615,
275,
291,
14,
13416,
8,
8170,
9,
267,
754,
275,
359,
2722,
8,
70,
14,
23693,
1012,
367,
289,
315,
754,
61,
267,
1420,
275,
359,
2722,
8,
70,
14,
23693,
1012,
367,
289,
315,
1420,
61,
267,
291,
14,
629,
8,
2062,
12,
754,
9,
267,
340,
5835,
365,
440,
488,
436,
10615,
1137,
5835,
26,
288,
746,
291,
14,
15935,
8,
355,
298,
30661,
8103,
440,
5452,
8840,
450,
83,
10615,
334,
390,
27221,
450,
83,
2924,
450,
334,
7327,
12,
10615,
9,
288,
776,
267,
340,
6656,
63,
13797,
365,
440,
488,
436,
10615,
2356,
6656,
63,
13797,
26,
288,
746,
291,
14,
15935,
8,
355,
298,
30661,
8103,
440,
5452,
6656,
2419,
450,
83,
10615,
334,
390,
27221,
450,
83,
2924,
450,
334,
2003,
63,
13797,
12,
10615,
9,
288,
776,
339,
347,
702,
7193,
30474,
8,
277,
12,
5331,
304,
267,
291,
14,
479,
9867,
6491,
1378,
8,
8170,
12,
5331,
9,
339,
347,
511,
63,
4780,
8,
277,
304,
267,
408,
267,
6496,
626,
314,
10736,
1630,
6548,
641,
282,
2849,
3439,
12,
267,
436,
626,
652,
1630,
652,
315,
2951,
1373,
986,
14,
267,
408,
267,
291,
14,
479,
9867,
6491,
1378,
8,
288,
359,
7685,
14,
5392,
1685,
480,
5686,
17857,
288,
359,
7685,
14,
5392,
1685,
480,
5686,
17857,
288,
5835,
29,
17,
12,
267,
776,
339,
347,
511,
63,
981,
63,
1807,
63,
1238,
8,
277,
304,
267,
408,
267,
2790,
1685,
436,
8496,
1685,
1077,
24311,
1901,
6548,
14,
267,
408,
267,
291,
14,
479,
9867,
6491,
1378,
8,
288,
359,
355,
6180,
14,
14907,
480,
5686,
401,
10003,
354,
401,
1709,
14,
2183,
8,
988,
63,
1267,
29,
2299,
430,
2522,
355,
6180,
14,
5392,
1685,
480,
5686,
1288,
288,
2156,
288,
990,
267,
776,
339,
347,
511,
63,
981,
63,
8165,
63,
1238,
8,
277,
304,
267,
408,
267,
2790,
1685,
1077,
2236,
1509,
66,
22756,
20474,
14,
267,
408,
267,
19680,
275,
4274,
1462,
297,
9630,
2988,
24821,
267,
291,
14,
479,
9867,
6491,
1378,
8,
288,
359,
355,
6180,
14,
14907,
8,
490,
536,
628,
5686,
401,
490,
1504,
1524,
480,
354,
401,
1709,
14,
2183,
8,
988,
63,
1267,
29,
2299,
25106,
490,
1511,
3713,
3832,
63,
354,
356,
283,
5686,
2267,
490,
9768,
2687,
7223,
1685,
1563,
395,
490,
19680,
29,
16259,
12,
355,
2318,
355,
6180,
14,
16843,
1685,
480,
5686,
401,
298,
5281,
1288,
288,
2156,
288,
359,
355,
6180,
14,
14907,
8,
490,
298,
5281,
401,
490,
10003,
354,
401,
1709,
14,
2183,
8,
988,
63,
1267,
29,
2299,
25106,
490,
1511,
3713,
3832,
63,
354,
356,
283,
5686,
2267,
490,
9768,
2687,
7223,
1685,
1563,
395,
490,
19680,
29,
16259,
12,
355,
776,
288,
2156,
267,
776,
339,
347,
511,
63,
8165,
63,
1238,
63,
277,
8,
277,
304,
267,
408,
267,
22756,
20474,
1077,
2236,
1509,
66,
17279,
14,
267,
408,
267,
291,
14,
479,
9867,
6491,
1378,
8,
288,
359,
355,
6180,
14,
16843,
1685,
480,
5686,
401,
298,
34,
2158,
1288,
355,
6180,
14,
16843,
1685,
480,
34,
2158,
401,
298,
5281,
1288,
288,
2156,
288,
359,
355,
6180,
14,
16843,
1685,
480,
5686,
401,
298,
5281,
1288,
288,
2156,
267,
776,
339,
347,
485,
396,
63,
981,
63,
11858,
63,
1421,
63,
1807,
63,
1238,
8,
277,
12,
17355,
63,
1421,
304,
267,
408,
267,
2790,
1685,
12,
4580,
351,
1685,
3186,
12,
4580,
351,
11427,
1378,
4920,
15,
14364,
2681,
1378,
4920,
15,
267,
4580,
351,
4738,
3007,
1322,
1764,
1378,
12,
436,
8496,
1685,
1077,
24311,
1901,
6548,
14,
267,
408,
267,
291,
14,
479,
9867,
6491,
1378,
8,
288,
359,
355,
6180,
14,
14907,
480,
5686,
401,
10003,
354,
401,
1709,
14,
2183,
8,
988,
63,
1267,
29,
2299,
430,
2522,
355,
6180,
14,
14364,
1685,
3186,
480,
5686,
401,
298,
87,
1534,
19112,
1288,
355,
17355,
63,
1421,
12,
355,
6180,
14,
5392,
1685,
480,
5686,
1288,
288,
2156,
288,
990,
267,
776,
339,
347,
511,
63,
981,
63,
11858,
63,
3235,
63,
1807,
63,
1238,
8,
277,
304,
267,
291,
423,
396,
63,
981,
63,
11858,
63,
1421,
63,
1807,
63,
1238,
8,
7685,
14,
14364,
11427,
1378,
4920,
480,
5686,
401,
24212,
65,
401,
298,
66,
937,
2459,
339,
347,
511,
63,
981,
63,
11858,
63,
1080,
63,
1807,
63,
1238,
8,
277,
304,
267,
291,
423,
396,
63,
981,
63,
11858,
63,
1421,
63,
1807,
63,
1238,
8,
7685,
14,
14364,
2681,
1378,
4920,
480,
5686,
401,
24212,
65,
401,
298,
66,
937,
2459,
339,
347,
511,
63,
981,
63,
11858,
63,
583,
2591,
63,
1807,
63,
1238,
8,
277,
304,
267,
291,
423,
396,
63,
981,
63,
11858,
63,
1421,
63,
1807,
63,
1238,
8,
7685,
14,
14364,
4738,
3007,
1322,
1764,
1378,
480,
5686,
401,
298,
65,
2237,
339,
347,
485,
396,
63,
11858,
63,
11858,
63,
1238,
8,
277,
12,
17355,
63,
1421,
12,
17355,
63,
1700,
304,
267,
408,
267,
16853,
4580,
351,
11427,
1378,
4920,
15,
14364,
2681,
1378,
4920,
15,
14364,
4738,
3007,
1322,
1764,
1378,
267,
1077,
24311,
1901,
314,
3499,
14,
267,
408,
267,
291,
14,
479,
9867,
6491,
1378,
8,
288,
359,
355,
17355,
63,
1421,
12,
355,
17355,
63,
1700,
12,
288,
2156,
288,
359,
355,
17355,
63,
1700,
12,
288,
2156,
267,
776,
339,
347
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
199,
504,
1639,
14,
697,
492,
6180,
12,
1709,
199,
504,
1639,
14,
697,
14,
7685,
14,
12290,
492,
12090,
13946,
199,
504,
1639,
14,
396,
492,
24424,
199,
199,
504,
1275,
992,
492,
8388,
1685,
1563,
12,
9630,
2988,
421,
199,
533,
19246,
1793,
2925,
8,
17968,
304,
272,
408,
272,
6496,
314,
8367,
28537,
9119,
14,
272,
408,
339,
347,
13497,
8,
277,
12,
5331,
304,
267,
408,
267,
18405,
89,
17522,
367,
10232,
2058,
435,
1329,
402,
17222,
267,
408,
267,
10736,
275,
12090,
13946,
342,
267,
372,
10736,
14,
13416,
8,
8170,
395,
10736,
423,
13570,
339,
347,
702,
9867,
6491,
1378,
8,
277,
12,
5331,
12,
1420,
12,
5835,
29,
403,
12,
6656,
63,
13797,
29,
403,
304,
267,
754,
12,
10615,
275,
291,
14,
13416,
8,
8170,
9,
267,
754,
275,
359,
2722,
8,
70,
14,
23693,
1012,
367,
289,
315,
754,
61,
267,
1420,
275,
359,
2722,
8,
70,
14,
23693,
1012,
367,
289,
315,
1420,
61,
267,
291,
14,
629,
8,
2062,
12,
754,
9,
267,
340,
5835,
365,
440,
488,
436,
10615,
1137,
5835,
26,
288,
746,
291,
14,
15935,
8,
355,
298,
30661,
8103,
440,
5452,
8840,
450,
83,
10615,
334,
390,
27221,
450,
83,
2924,
450,
334,
7327,
12,
10615,
9,
288,
776,
267,
340,
6656,
63,
13797,
365,
440,
488,
436,
10615,
2356,
6656,
63,
13797,
26,
288,
746,
291,
14,
15935,
8,
355,
298,
30661,
8103,
440,
5452,
6656,
2419,
450,
83,
10615,
334,
390,
27221,
450,
83,
2924,
450,
334,
2003,
63,
13797,
12,
10615,
9,
288,
776,
339,
347,
702,
7193,
30474,
8,
277,
12,
5331,
304,
267,
291,
14,
479,
9867,
6491,
1378,
8,
8170,
12,
5331,
9,
339,
347,
511,
63,
4780,
8,
277,
304,
267,
408,
267,
6496,
626,
314,
10736,
1630,
6548,
641,
282,
2849,
3439,
12,
267,
436,
626,
652,
1630,
652,
315,
2951,
1373,
986,
14,
267,
408,
267,
291,
14,
479,
9867,
6491,
1378,
8,
288,
359,
7685,
14,
5392,
1685,
480,
5686,
17857,
288,
359,
7685,
14,
5392,
1685,
480,
5686,
17857,
288,
5835,
29,
17,
12,
267,
776,
339,
347,
511,
63,
981,
63,
1807,
63,
1238,
8,
277,
304,
267,
408,
267,
2790,
1685,
436,
8496,
1685,
1077,
24311,
1901,
6548,
14,
267,
408,
267,
291,
14,
479,
9867,
6491,
1378,
8,
288,
359,
355,
6180,
14,
14907,
480,
5686,
401,
10003,
354,
401,
1709,
14,
2183,
8,
988,
63,
1267,
29,
2299,
430,
2522,
355,
6180,
14,
5392,
1685,
480,
5686,
1288,
288,
2156,
288,
990,
267,
776,
339,
347,
511,
63,
981,
63,
8165,
63,
1238,
8,
277,
304,
267,
408,
267,
2790,
1685,
1077,
2236,
1509,
66,
22756,
20474,
14,
267,
408,
267,
19680,
275,
4274,
1462,
297,
9630,
2988,
24821,
267,
291,
14,
479,
9867,
6491,
1378,
8,
288,
359,
355,
6180,
14,
14907,
8,
490,
536,
628,
5686,
401,
490,
1504,
1524,
480,
354,
401,
1709,
14,
2183,
8,
988,
63,
1267,
29,
2299,
25106,
490,
1511,
3713,
3832,
63,
354,
356,
283,
5686,
2267,
490,
9768,
2687,
7223,
1685,
1563,
395,
490,
19680,
29,
16259,
12,
355,
2318,
355,
6180,
14,
16843,
1685,
480,
5686,
401,
298,
5281,
1288,
288,
2156,
288,
359,
355,
6180,
14,
14907,
8,
490,
298,
5281,
401,
490,
10003,
354,
401,
1709,
14,
2183,
8,
988,
63,
1267,
29,
2299,
25106,
490,
1511,
3713,
3832,
63,
354,
356,
283,
5686,
2267,
490,
9768,
2687,
7223,
1685,
1563,
395,
490,
19680,
29,
16259,
12,
355,
776,
288,
2156,
267,
776,
339,
347,
511,
63,
8165,
63,
1238,
63,
277,
8,
277,
304,
267,
408,
267,
22756,
20474,
1077,
2236,
1509,
66,
17279,
14,
267,
408,
267,
291,
14,
479,
9867,
6491,
1378,
8,
288,
359,
355,
6180,
14,
16843,
1685,
480,
5686,
401,
298,
34,
2158,
1288,
355,
6180,
14,
16843,
1685,
480,
34,
2158,
401,
298,
5281,
1288,
288,
2156,
288,
359,
355,
6180,
14,
16843,
1685,
480,
5686,
401,
298,
5281,
1288,
288,
2156,
267,
776,
339,
347,
485,
396,
63,
981,
63,
11858,
63,
1421,
63,
1807,
63,
1238,
8,
277,
12,
17355,
63,
1421,
304,
267,
408,
267,
2790,
1685,
12,
4580,
351,
1685,
3186,
12,
4580,
351,
11427,
1378,
4920,
15,
14364,
2681,
1378,
4920,
15,
267,
4580,
351,
4738,
3007,
1322,
1764,
1378,
12,
436,
8496,
1685,
1077,
24311,
1901,
6548,
14,
267,
408,
267,
291,
14,
479,
9867,
6491,
1378,
8,
288,
359,
355,
6180,
14,
14907,
480,
5686,
401,
10003,
354,
401,
1709,
14,
2183,
8,
988,
63,
1267,
29,
2299,
430,
2522,
355,
6180,
14,
14364,
1685,
3186,
480,
5686,
401,
298,
87,
1534,
19112,
1288,
355,
17355,
63,
1421,
12,
355,
6180,
14,
5392,
1685,
480,
5686,
1288,
288,
2156,
288,
990,
267,
776,
339,
347,
511,
63,
981,
63,
11858,
63,
3235,
63,
1807,
63,
1238,
8,
277,
304,
267,
291,
423,
396,
63,
981,
63,
11858,
63,
1421,
63,
1807,
63,
1238,
8,
7685,
14,
14364,
11427,
1378,
4920,
480,
5686,
401,
24212,
65,
401,
298,
66,
937,
2459,
339,
347,
511,
63,
981,
63,
11858,
63,
1080,
63,
1807,
63,
1238,
8,
277,
304,
267,
291,
423,
396,
63,
981,
63,
11858,
63,
1421,
63,
1807,
63,
1238,
8,
7685,
14,
14364,
2681,
1378,
4920,
480,
5686,
401,
24212,
65,
401,
298,
66,
937,
2459,
339,
347,
511,
63,
981,
63,
11858,
63,
583,
2591,
63,
1807,
63,
1238,
8,
277,
304,
267,
291,
423,
396,
63,
981,
63,
11858,
63,
1421,
63,
1807,
63,
1238,
8,
7685,
14,
14364,
4738,
3007,
1322,
1764,
1378,
480,
5686,
401,
298,
65,
2237,
339,
347,
485,
396,
63,
11858,
63,
11858,
63,
1238,
8,
277,
12,
17355,
63,
1421,
12,
17355,
63,
1700,
304,
267,
408,
267,
16853,
4580,
351,
11427,
1378,
4920,
15,
14364,
2681,
1378,
4920,
15,
14364,
4738,
3007,
1322,
1764,
1378,
267,
1077,
24311,
1901,
314,
3499,
14,
267,
408,
267,
291,
14,
479,
9867,
6491,
1378,
8,
288,
359,
355,
17355,
63,
1421,
12,
355,
17355,
63,
1700,
12,
288,
2156,
288,
359,
355,
17355,
63,
1700,
12,
288,
2156,
267,
776,
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,
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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
] |
Tatsh-ansible/ansible
|
lib/ansible/plugins/terminal/aireos.py
|
101
|
1999
|
#
# (c) 2016 Red Hat Inc.
#
# 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/>.
#
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
import json
import re
import time
from ansible.errors import AnsibleConnectionFailure
from ansible.plugins.terminal import TerminalBase
class TerminalModule(TerminalBase):
terminal_stdout_re = [
re.compile(br"[\r\n]?[\w]*\(.+\)?[>#\$](?:\s*)$"),
re.compile(br"User:")
]
terminal_stderr_re = [
re.compile(br"% ?Error"),
re.compile(br"% ?Bad secret"),
re.compile(br"invalid input", re.I),
re.compile(br"incorrect usage", re.I),
re.compile(br"(?:incomplete|ambiguous) command", re.I),
re.compile(br"connection timed out", re.I),
re.compile(br"[^\r\n]+ not found", re.I),
re.compile(br"'[^']' +returned error code: ?\d+"),
]
def on_open_shell(self):
try:
commands = ('{"command": "' + self._connection._play_context.remote_user + '", "prompt": "Password:", "answer": "' +
self._connection._play_context.password + '"}',
'{"command": "config paging disable"}')
for cmd in commands:
self._exec_cli_command(cmd)
except AnsibleConnectionFailure:
raise AnsibleConnectionFailure('unable to set terminal parameters')
|
gpl-3.0
|
[
3,
199,
3,
334,
67,
9,
7800,
9572,
13002,
3277,
14,
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,
3,
199,
504,
636,
2443,
363,
492,
334,
6116,
63,
646,
12,
4629,
12,
870,
63,
1593,
9,
199,
363,
6577,
363,
275,
730,
199,
199,
646,
2022,
199,
646,
295,
199,
646,
900,
199,
199,
504,
3242,
14,
2550,
492,
2622,
3225,
6782,
199,
504,
3242,
14,
5265,
14,
12010,
492,
20429,
279,
1563,
421,
199,
533,
20429,
279,
2377,
8,
22015,
1563,
304,
339,
11167,
63,
2703,
63,
264,
275,
359,
267,
295,
14,
2014,
8,
3289,
29354,
82,
60,
78,
11843,
7023,
87,
3672,
24805,
6977,
60,
5547,
59,
30,
20262,
4,
61,
15840,
83,
13278,
4,
1288,
267,
295,
14,
2014,
8,
3289,
2,
1899,
9107,
272,
1622,
339,
11167,
63,
3083,
63,
264,
275,
359,
267,
295,
14,
2014,
8,
3289,
6808,
5805,
547,
1288,
267,
295,
14,
2014,
8,
3289,
6808,
5805,
5725,
7565,
1288,
267,
295,
14,
2014,
8,
3289,
2,
3197,
1324,
401,
295,
14,
41,
395,
267,
295,
14,
2014,
8,
3289,
2,
15448,
4503,
401,
295,
14,
41,
395,
267,
295,
14,
2014,
8,
3289,
2,
5169,
24575,
92,
26465,
9,
1414,
401,
295,
14,
41,
395,
267,
295,
14,
2014,
8,
3289,
2,
2105,
18590,
734,
401,
295,
14,
41,
395,
267,
295,
14,
2014,
8,
3289,
2,
16045,
82,
60,
78,
2807,
440,
1911,
401,
295,
14,
41,
395,
267,
295,
14,
2014,
8,
3289,
2,
16122,
418,
7,
435,
19065,
1125,
1233,
26,
5805,
60,
68,
11,
1288,
272,
1622,
339,
347,
641,
63,
1490,
63,
5641,
8,
277,
304,
267,
862,
26,
288,
3718,
275,
661,
6641,
1531,
582,
3546,
435,
291,
423,
2105,
423,
2802,
63,
1100,
14,
3846,
63,
751,
435,
283,
401,
298,
7650,
582,
298,
6139,
6783,
298,
5934,
582,
3546,
435,
717,
291,
423,
2105,
423,
2802,
63,
1100,
14,
2060,
435,
283,
3570,
297,
717,
17137,
1531,
582,
298,
888,
299,
7407,
3507,
3570,
358,
288,
367,
2088,
315,
3718,
26,
355,
291,
423,
1628,
63,
2764,
63,
1531,
8,
1760,
9,
267,
871,
2622,
3225,
6782,
26,
288,
746,
2622,
3225,
6782,
360,
17200,
370,
663,
11167,
2633,
358,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
199,
3,
334,
67,
9,
7800,
9572,
13002,
3277,
14,
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,
3,
199,
504,
636,
2443,
363,
492,
334,
6116,
63,
646,
12,
4629,
12,
870,
63,
1593,
9,
199,
363,
6577,
363,
275,
730,
199,
199,
646,
2022,
199,
646,
295,
199,
646,
900,
199,
199,
504,
3242,
14,
2550,
492,
2622,
3225,
6782,
199,
504,
3242,
14,
5265,
14,
12010,
492,
20429,
279,
1563,
421,
199,
533,
20429,
279,
2377,
8,
22015,
1563,
304,
339,
11167,
63,
2703,
63,
264,
275,
359,
267,
295,
14,
2014,
8,
3289,
29354,
82,
60,
78,
11843,
7023,
87,
3672,
24805,
6977,
60,
5547,
59,
30,
20262,
4,
61,
15840,
83,
13278,
4,
1288,
267,
295,
14,
2014,
8,
3289,
2,
1899,
9107,
272,
1622,
339,
11167,
63,
3083,
63,
264,
275,
359,
267,
295,
14,
2014,
8,
3289,
6808,
5805,
547,
1288,
267,
295,
14,
2014,
8,
3289,
6808,
5805,
5725,
7565,
1288,
267,
295,
14,
2014,
8,
3289,
2,
3197,
1324,
401,
295,
14,
41,
395,
267,
295,
14,
2014,
8,
3289,
2,
15448,
4503,
401,
295,
14,
41,
395,
267,
295,
14,
2014,
8,
3289,
2,
5169,
24575,
92,
26465,
9,
1414,
401,
295,
14,
41,
395,
267,
295,
14,
2014,
8,
3289,
2,
2105,
18590,
734,
401,
295,
14,
41,
395,
267,
295,
14,
2014,
8,
3289,
2,
16045,
82,
60,
78,
2807,
440,
1911,
401,
295,
14,
41,
395,
267,
295,
14,
2014,
8,
3289,
2,
16122,
418,
7,
435,
19065,
1125,
1233,
26,
5805,
60,
68,
11,
1288,
272,
1622,
339,
347,
641,
63,
1490,
63,
5641,
8,
277,
304,
267,
862,
26,
288,
3718,
275,
661,
6641,
1531,
582,
3546,
435,
291,
423,
2105,
423,
2802,
63,
1100,
14,
3846,
63,
751,
435,
283,
401,
298,
7650,
582,
298,
6139,
6783,
298,
5934,
582,
3546,
435,
717,
291,
423,
2105,
423,
2802,
63,
1100,
14,
2060,
435,
283,
3570,
297,
717,
17137,
1531,
582,
298,
888,
299,
7407,
3507,
3570,
358,
288,
367,
2088,
315,
3718,
26,
355,
291,
423,
1628,
63,
2764,
63,
1531,
8,
1760,
9,
267,
871,
2622,
3225,
6782,
26,
288,
746,
2622,
3225,
6782,
360,
17200,
370,
663,
11167,
2633,
358,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
krafczyk/spack
|
lib/spack/spack/util/crypto.py
|
2
|
6514
|
##############################################################################
# Copyright (c) 2013-2018, Lawrence Livermore National Security, LLC.
# Produced at the Lawrence Livermore National Laboratory.
#
# This file is part of Spack.
# Created by Todd Gamblin, tgamblin@llnl.gov, All rights reserved.
# LLNL-CODE-647188
#
# For details, see https://github.com/spack/spack
# Please also see the NOTICE and LICENSE files for our notice and the LGPL.
#
# This program 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) version 2.1, February 1999.
#
# 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 terms and
# conditions of 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 program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
##############################################################################
import sys
import hashlib
import llnl.util.tty as tty
#: Set of hash algorithms that Spack can use, mapped to digest size in bytes
hashes = {
'md5': 16,
'sha1': 20,
'sha224': 28,
'sha256': 32,
'sha384': 48,
'sha512': 64
}
#: size of hash digests in bytes, mapped to algoritm names
_size_to_hash = dict((v, k) for k, v in hashes.items())
#: List of deprecated hash functions. On some systems, these cannot be
#: used without special options to hashlib.
_deprecated_hash_algorithms = ['md5']
#: cache of hash functions generated
_hash_functions = {}
class DeprecatedHash(object):
def __init__(self, hash_alg, alert_fn, disable_security_check):
self.hash_alg = hash_alg
self.alert_fn = alert_fn
self.disable_security_check = disable_security_check
def __call__(self, disable_alert=False):
if not disable_alert:
self.alert_fn("Deprecation warning: {0} checksums will not be"
" supported in future Spack releases."
.format(self.hash_alg))
if self.disable_security_check:
return hashlib.new(self.hash_alg, usedforsecurity=False)
else:
return hashlib.new(self.hash_alg)
def hash_fun_for_algo(algo):
"""Get a function that can perform the specified hash algorithm."""
hash_gen = _hash_functions.get(algo)
if hash_gen is None:
if algo in _deprecated_hash_algorithms:
try:
hash_gen = DeprecatedHash(
algo, tty.debug, disable_security_check=False)
# call once to get a ValueError if usedforsecurity is needed
hash_gen(disable_alert=True)
except ValueError:
# Some systems may support the 'usedforsecurity' option
# so try with that (but display a warning when it is used)
hash_gen = DeprecatedHash(
algo, tty.warn, disable_security_check=True)
else:
hash_gen = getattr(hashlib, algo)
_hash_functions[algo] = hash_gen
return hash_gen
def hash_algo_for_digest(hexdigest):
"""Gets name of the hash algorithm for a hex digest."""
bytes = len(hexdigest) / 2
if bytes not in _size_to_hash:
raise ValueError(
'Spack knows no hash algorithm for this digest: %s' % hexdigest)
return _size_to_hash[bytes]
def hash_fun_for_digest(hexdigest):
"""Gets a hash function corresponding to a hex digest."""
return hash_fun_for_algo(hash_algo_for_digest(hexdigest))
def checksum(hashlib_algo, filename, **kwargs):
"""Returns a hex digest of the filename generated using an
algorithm from hashlib.
"""
block_size = kwargs.get('block_size', 2**20)
hasher = hashlib_algo()
with open(filename, 'rb') as file:
while True:
data = file.read(block_size)
if not data:
break
hasher.update(data)
return hasher.hexdigest()
class Checker(object):
"""A checker checks files against one particular hex digest.
It will automatically determine what hashing algorithm
to used based on the length of the digest it's initialized
with. e.g., if the digest is 32 hex characters long this will
use md5.
Example: know your tarball should hash to 'abc123'. You want
to check files against this. You would use this class like so::
hexdigest = 'abc123'
checker = Checker(hexdigest)
success = checker.check('downloaded.tar.gz')
After the call to check, the actual checksum is available in
checker.sum, in case it's needed for error output.
You can trade read performance and memory usage by
adjusting the block_size optional arg. By default it's
a 1MB (2**20 bytes) buffer.
"""
def __init__(self, hexdigest, **kwargs):
self.block_size = kwargs.get('block_size', 2**20)
self.hexdigest = hexdigest
self.sum = None
self.hash_fun = hash_fun_for_digest(hexdigest)
@property
def hash_name(self):
"""Get the name of the hash function this Checker is using."""
return self.hash_fun().name
def check(self, filename):
"""Read the file with the specified name and check its checksum
against self.hexdigest. Return True if they match, False
otherwise. Actual checksum is stored in self.sum.
"""
self.sum = checksum(
self.hash_fun, filename, block_size=self.block_size)
return self.sum == self.hexdigest
def prefix_bits(byte_array, bits):
"""Return the first <bits> bits of a byte array as an integer."""
if sys.version_info < (3,):
b2i = ord # In Python 2, indexing byte_array gives str
else:
b2i = lambda b: b # In Python 3, indexing byte_array gives int
result = 0
n = 0
for i, b in enumerate(byte_array):
n += 8
result = (result << 8) | b2i(b)
if n >= bits:
break
result >>= (n - bits)
return result
def bit_length(num):
"""Number of bits required to represent an integer in binary."""
s = bin(num)
s = s.lstrip('-0b')
return len(s)
|
lgpl-2.1
|
[
4605,
199,
3,
1898,
334,
67,
9,
6171,
13,
12682,
12,
7964,
29590,
491,
4380,
6878,
20548,
13863,
12,
20376,
14,
199,
3,
2165,
16584,
737,
314,
7964,
29590,
491,
4380,
6878,
20548,
16871,
31671,
14,
199,
3,
199,
3,
961,
570,
365,
1777,
402,
428,
1389,
14,
199,
3,
18208,
701,
377,
16216,
598,
11020,
472,
12,
22387,
11020,
472,
32,
914,
7530,
14,
16294,
12,
2900,
4481,
4644,
14,
199,
3,
491,
44,
14176,
13,
6012,
13,
8557,
11501,
199,
3,
199,
3,
2104,
2436,
12,
1937,
4178,
921,
5031,
14,
957,
15,
83,
1389,
15,
83,
1389,
199,
3,
7754,
2597,
1937,
314,
12840,
436,
5113,
1584,
367,
4154,
4245,
436,
314,
32426,
14,
199,
3,
199,
3,
961,
2240,
365,
2867,
2032,
27,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
652,
1334,
314,
2895,
402,
314,
1664,
6401,
1696,
1684,
844,
334,
305,
199,
3,
3267,
701,
314,
2868,
2290,
2752,
9,
1015,
499,
14,
17,
12,
21141,
26709,
21300,
14,
199,
3,
199,
3,
961,
2240,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
1325,
199,
3,
2428,
1821,
3408,
27,
1928,
2755,
314,
5292,
3408,
1634,
199,
3,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
1666,
314,
2895,
436,
199,
3,
3704,
402,
314,
1664,
6401,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
6401,
1696,
1684,
199,
3,
844,
3180,
543,
642,
2240,
27,
340,
440,
12,
2218,
370,
314,
2868,
2290,
199,
3,
2752,
12,
3277,
2020,
8155,
15630,
10902,
12,
14453,
13540,
12,
8226,
12,
4828,
15673,
13,
13421,
8217,
199,
4605,
199,
646,
984,
199,
646,
8337,
199,
199,
646,
634,
6066,
76,
14,
1974,
14,
4707,
465,
21862,
421,
199,
12573,
2494,
402,
2631,
18036,
626,
428,
1389,
883,
675,
12,
9994,
370,
10017,
1568,
315,
2783,
199,
12428,
275,
469,
272,
283,
1064,
21,
356,
3193,
12,
272,
283,
4835,
17,
356,
3388,
12,
272,
283,
4835,
8731,
356,
7294,
12,
272,
283,
4835,
3912,
356,
4337,
12,
272,
283,
4835,
8188,
356,
9615,
12,
272,
283,
4835,
7736,
356,
5049,
199,
93,
421,
199,
12573,
1568,
402,
2631,
10017,
83,
315,
2783,
12,
9994,
370,
741,
2904,
10737,
1561,
199,
63,
890,
63,
475,
63,
2227,
275,
1211,
1332,
86,
12,
1022,
9,
367,
1022,
12,
373,
315,
14647,
14,
1744,
1012,
421,
199,
12573,
3820,
402,
5906,
2631,
3423,
14,
4068,
2005,
10460,
12,
3520,
3913,
506,
199,
12573,
1202,
1928,
4539,
1511,
370,
8337,
14,
199,
63,
6667,
63,
2227,
63,
24365,
275,
788,
1064,
21,
418,
421,
199,
12573,
2581,
402,
2631,
3423,
4046,
199,
63,
2227,
63,
5777,
275,
1052,
421,
199,
533,
17993,
3476,
8,
785,
304,
272,
347,
636,
826,
721,
277,
12,
2631,
63,
6731,
12,
10459,
63,
2324,
12,
3507,
63,
4416,
63,
1074,
304,
267,
291,
14,
2227,
63,
6731,
275,
2631,
63,
6731,
267,
291,
14,
9241,
63,
2324,
275,
10459,
63,
2324,
267,
291,
14,
5993,
63,
4416,
63,
1074,
275,
3507,
63,
4416,
63,
1074,
339,
347,
636,
1250,
721,
277,
12,
3507,
63,
9241,
29,
797,
304,
267,
340,
440,
3507,
63,
9241,
26,
288,
291,
14,
9241,
63,
2324,
480,
872,
6444,
5721,
26,
469,
16,
93,
9040,
83,
911,
440,
506,
2,
2079,
298,
3748,
315,
6466,
428,
1389,
19015,
2122,
2079,
1275,
908,
8,
277,
14,
2227,
63,
6731,
430,
267,
340,
291,
14,
5993,
63,
4416,
63,
1074,
26,
288,
372,
8337,
14,
1222,
8,
277,
14,
2227,
63,
6731,
12,
1202,
509,
4416,
29,
797,
9,
267,
587,
26,
288,
372,
8337,
14,
1222,
8,
277,
14,
2227,
63,
6731,
9,
421,
199,
318,
2631,
63,
7036,
63,
509,
63,
21734,
8,
21734,
304,
272,
408,
1002,
282,
805,
626,
883,
5147,
314,
2013,
2631,
5563,
1041,
272,
2631,
63,
2268,
275,
485,
2227,
63,
5777,
14,
362,
8,
21734,
9,
272,
340,
2631,
63,
2268,
365,
488,
26,
267,
340,
24633,
315,
485,
6667,
63,
2227,
63,
24365,
26,
288,
862,
26,
355,
2631,
63,
2268,
275,
17993,
3476,
8,
490,
24633,
12,
21862,
14,
1757,
12,
3507,
63,
4416,
63,
1074,
29,
797,
9,
2234,
327,
1240,
5403,
370,
664,
282,
1722,
340,
1202,
509,
4416,
365,
4346,
355,
2631,
63,
2268,
8,
5993,
63,
9241,
29,
549,
9,
288,
871,
1722,
26,
355,
327,
6601,
10460,
1443,
2291,
314,
283,
2972,
509,
4416,
7,
945,
355,
327,
880,
862,
543,
626,
334,
7911,
2929,
282,
5721,
1380,
652,
365,
1202,
9,
355,
2631,
63,
2268,
275,
17993,
3476,
8,
490,
24633,
12,
21862,
14,
4050,
12,
3507,
63,
4416,
63,
1074,
29,
549,
9,
267,
587,
26,
288,
2631,
63,
2268,
275,
2519,
8,
24722,
12,
24633,
9,
267,
485,
2227,
63,
5777,
59,
21734,
61,
275,
2631,
63,
2268,
339,
372,
2631,
63,
2268,
421,
199,
318,
2631,
63,
21734,
63,
509,
63,
5671,
8,
11453,
304,
272,
408,
14426,
536,
402,
314,
2631,
5563,
367,
282,
6318,
10017,
1041,
272,
2783,
275,
822,
8,
11453,
9,
1182,
499,
272,
340,
2783,
440,
315,
485,
890,
63,
475,
63,
2227,
26,
267,
746,
1722,
8,
288,
283,
51,
1389,
19428,
949,
2631,
5563,
367,
642,
10017,
26,
450,
83,
7,
450,
6318,
5671,
9,
272,
372,
485,
890,
63,
475,
63,
2227,
59,
2394,
61,
421,
199,
318,
2631,
63,
7036,
63,
509,
63,
5671,
8,
11453,
304,
272,
408,
14426,
282,
2631,
805,
5226,
370,
282,
6318,
10017,
1041,
272,
372,
2631,
63,
7036,
63,
509,
63,
21734,
8,
2227,
63,
21734,
63,
509,
63,
5671,
8,
11453,
430,
421,
199,
318,
9040,
8,
24722,
63,
21734,
12,
1788,
12,
1011,
958,
304,
272,
408,
3407,
282,
6318,
10017,
402,
314,
1788,
4046,
1808,
376,
2126,
5563,
687,
8337,
14,
272,
408,
272,
1853,
63,
890,
275,
2074,
14,
362,
360,
1457,
63,
890,
297,
499,
538,
1165,
9,
272,
19009,
275,
8337,
63,
21734,
342,
272,
543,
1551,
8,
1501,
12,
283,
4848,
358,
465,
570,
26,
267,
1830,
715,
26,
288,
666,
275,
570,
14,
739,
8
] |
[
199,
3,
1898,
334,
67,
9,
6171,
13,
12682,
12,
7964,
29590,
491,
4380,
6878,
20548,
13863,
12,
20376,
14,
199,
3,
2165,
16584,
737,
314,
7964,
29590,
491,
4380,
6878,
20548,
16871,
31671,
14,
199,
3,
199,
3,
961,
570,
365,
1777,
402,
428,
1389,
14,
199,
3,
18208,
701,
377,
16216,
598,
11020,
472,
12,
22387,
11020,
472,
32,
914,
7530,
14,
16294,
12,
2900,
4481,
4644,
14,
199,
3,
491,
44,
14176,
13,
6012,
13,
8557,
11501,
199,
3,
199,
3,
2104,
2436,
12,
1937,
4178,
921,
5031,
14,
957,
15,
83,
1389,
15,
83,
1389,
199,
3,
7754,
2597,
1937,
314,
12840,
436,
5113,
1584,
367,
4154,
4245,
436,
314,
32426,
14,
199,
3,
199,
3,
961,
2240,
365,
2867,
2032,
27,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
652,
1334,
314,
2895,
402,
314,
1664,
6401,
1696,
1684,
844,
334,
305,
199,
3,
3267,
701,
314,
2868,
2290,
2752,
9,
1015,
499,
14,
17,
12,
21141,
26709,
21300,
14,
199,
3,
199,
3,
961,
2240,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
1325,
199,
3,
2428,
1821,
3408,
27,
1928,
2755,
314,
5292,
3408,
1634,
199,
3,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
1666,
314,
2895,
436,
199,
3,
3704,
402,
314,
1664,
6401,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
6401,
1696,
1684,
199,
3,
844,
3180,
543,
642,
2240,
27,
340,
440,
12,
2218,
370,
314,
2868,
2290,
199,
3,
2752,
12,
3277,
2020,
8155,
15630,
10902,
12,
14453,
13540,
12,
8226,
12,
4828,
15673,
13,
13421,
8217,
199,
4605,
199,
646,
984,
199,
646,
8337,
199,
199,
646,
634,
6066,
76,
14,
1974,
14,
4707,
465,
21862,
421,
199,
12573,
2494,
402,
2631,
18036,
626,
428,
1389,
883,
675,
12,
9994,
370,
10017,
1568,
315,
2783,
199,
12428,
275,
469,
272,
283,
1064,
21,
356,
3193,
12,
272,
283,
4835,
17,
356,
3388,
12,
272,
283,
4835,
8731,
356,
7294,
12,
272,
283,
4835,
3912,
356,
4337,
12,
272,
283,
4835,
8188,
356,
9615,
12,
272,
283,
4835,
7736,
356,
5049,
199,
93,
421,
199,
12573,
1568,
402,
2631,
10017,
83,
315,
2783,
12,
9994,
370,
741,
2904,
10737,
1561,
199,
63,
890,
63,
475,
63,
2227,
275,
1211,
1332,
86,
12,
1022,
9,
367,
1022,
12,
373,
315,
14647,
14,
1744,
1012,
421,
199,
12573,
3820,
402,
5906,
2631,
3423,
14,
4068,
2005,
10460,
12,
3520,
3913,
506,
199,
12573,
1202,
1928,
4539,
1511,
370,
8337,
14,
199,
63,
6667,
63,
2227,
63,
24365,
275,
788,
1064,
21,
418,
421,
199,
12573,
2581,
402,
2631,
3423,
4046,
199,
63,
2227,
63,
5777,
275,
1052,
421,
199,
533,
17993,
3476,
8,
785,
304,
272,
347,
636,
826,
721,
277,
12,
2631,
63,
6731,
12,
10459,
63,
2324,
12,
3507,
63,
4416,
63,
1074,
304,
267,
291,
14,
2227,
63,
6731,
275,
2631,
63,
6731,
267,
291,
14,
9241,
63,
2324,
275,
10459,
63,
2324,
267,
291,
14,
5993,
63,
4416,
63,
1074,
275,
3507,
63,
4416,
63,
1074,
339,
347,
636,
1250,
721,
277,
12,
3507,
63,
9241,
29,
797,
304,
267,
340,
440,
3507,
63,
9241,
26,
288,
291,
14,
9241,
63,
2324,
480,
872,
6444,
5721,
26,
469,
16,
93,
9040,
83,
911,
440,
506,
2,
2079,
298,
3748,
315,
6466,
428,
1389,
19015,
2122,
2079,
1275,
908,
8,
277,
14,
2227,
63,
6731,
430,
267,
340,
291,
14,
5993,
63,
4416,
63,
1074,
26,
288,
372,
8337,
14,
1222,
8,
277,
14,
2227,
63,
6731,
12,
1202,
509,
4416,
29,
797,
9,
267,
587,
26,
288,
372,
8337,
14,
1222,
8,
277,
14,
2227,
63,
6731,
9,
421,
199,
318,
2631,
63,
7036,
63,
509,
63,
21734,
8,
21734,
304,
272,
408,
1002,
282,
805,
626,
883,
5147,
314,
2013,
2631,
5563,
1041,
272,
2631,
63,
2268,
275,
485,
2227,
63,
5777,
14,
362,
8,
21734,
9,
272,
340,
2631,
63,
2268,
365,
488,
26,
267,
340,
24633,
315,
485,
6667,
63,
2227,
63,
24365,
26,
288,
862,
26,
355,
2631,
63,
2268,
275,
17993,
3476,
8,
490,
24633,
12,
21862,
14,
1757,
12,
3507,
63,
4416,
63,
1074,
29,
797,
9,
2234,
327,
1240,
5403,
370,
664,
282,
1722,
340,
1202,
509,
4416,
365,
4346,
355,
2631,
63,
2268,
8,
5993,
63,
9241,
29,
549,
9,
288,
871,
1722,
26,
355,
327,
6601,
10460,
1443,
2291,
314,
283,
2972,
509,
4416,
7,
945,
355,
327,
880,
862,
543,
626,
334,
7911,
2929,
282,
5721,
1380,
652,
365,
1202,
9,
355,
2631,
63,
2268,
275,
17993,
3476,
8,
490,
24633,
12,
21862,
14,
4050,
12,
3507,
63,
4416,
63,
1074,
29,
549,
9,
267,
587,
26,
288,
2631,
63,
2268,
275,
2519,
8,
24722,
12,
24633,
9,
267,
485,
2227,
63,
5777,
59,
21734,
61,
275,
2631,
63,
2268,
339,
372,
2631,
63,
2268,
421,
199,
318,
2631,
63,
21734,
63,
509,
63,
5671,
8,
11453,
304,
272,
408,
14426,
536,
402,
314,
2631,
5563,
367,
282,
6318,
10017,
1041,
272,
2783,
275,
822,
8,
11453,
9,
1182,
499,
272,
340,
2783,
440,
315,
485,
890,
63,
475,
63,
2227,
26,
267,
746,
1722,
8,
288,
283,
51,
1389,
19428,
949,
2631,
5563,
367,
642,
10017,
26,
450,
83,
7,
450,
6318,
5671,
9,
272,
372,
485,
890,
63,
475,
63,
2227,
59,
2394,
61,
421,
199,
318,
2631,
63,
7036,
63,
509,
63,
5671,
8,
11453,
304,
272,
408,
14426,
282,
2631,
805,
5226,
370,
282,
6318,
10017,
1041,
272,
372,
2631,
63,
7036,
63,
509,
63,
21734,
8,
2227,
63,
21734,
63,
509,
63,
5671,
8,
11453,
430,
421,
199,
318,
9040,
8,
24722,
63,
21734,
12,
1788,
12,
1011,
958,
304,
272,
408,
3407,
282,
6318,
10017,
402,
314,
1788,
4046,
1808,
376,
2126,
5563,
687,
8337,
14,
272,
408,
272,
1853,
63,
890,
275,
2074,
14,
362,
360,
1457,
63,
890,
297,
499,
538,
1165,
9,
272,
19009,
275,
8337,
63,
21734,
342,
272,
543,
1551,
8,
1501,
12,
283,
4848,
358,
465,
570,
26,
267,
1830,
715,
26,
288,
666,
275,
570,
14,
739,
8,
0
] |
[
1,
1,
1,
1,
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
|
pyanaconda/modules/network/firewall/__init__.py
|
7
|
1057
|
#
# Copyright (C) 2018 Red Hat, Inc.
#
# This copyrighted material is made available to anyone wishing to use,
# modify, copy, or redistribute it subject to the terms and conditions of
# the GNU General Public License v.2, or (at your option) any later version.
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY expressed or implied, including the implied warranties of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details. You should have received a copy of the
# GNU General Public License along with this program; if not, write to the
# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA. Any Red Hat trademarks that are incorporated in the
# source code or documentation are not subject to the GNU General Public
# License and may only be used or replicated with the express permission of
# Red Hat, Inc.
#
from pyanaconda.modules.network.firewall.firewall import FirewallModule
__all__ = ["FirewallModule"]
|
gpl-2.0
|
[
3,
199,
3,
1898,
334,
35,
9,
14894,
9572,
13002,
12,
3277,
14,
199,
3,
199,
3,
961,
1331,
31816,
471,
6285,
365,
6326,
2808,
370,
29165,
13809,
316,
370,
675,
12,
199,
3,
2811,
12,
1331,
12,
503,
3604,
652,
5420,
370,
314,
2895,
436,
3704,
402,
199,
3,
314,
1664,
1696,
1684,
844,
373,
14,
18,
12,
503,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
961,
2240,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
1325,
2428,
199,
3,
1821,
3408,
19147,
503,
2478,
12,
5893,
314,
2478,
3712,
1417,
402,
199,
3,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
1664,
1696,
199,
3,
1684,
844,
367,
1655,
2436,
14,
221,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
199,
3,
1664,
1696,
1684,
844,
3180,
543,
642,
2240,
27,
340,
440,
12,
2218,
370,
314,
199,
3,
2868,
2290,
2752,
12,
3277,
2020,
8026,
11236,
14259,
12,
12066,
11844,
12,
8226,
12,
4828,
199,
3,
11315,
13,
10067,
12,
8217,
14,
221,
6184,
9572,
13002,
21032,
10375,
626,
787,
30147,
972,
315,
314,
199,
3,
1350,
1233,
503,
3794,
787,
440,
5420,
370,
314,
1664,
1696,
1684,
199,
3,
844,
436,
1443,
1454,
506,
1202,
503,
32436,
543,
314,
4056,
4983,
402,
199,
3,
9572,
13002,
12,
3277,
14,
199,
3,
199,
504,
1134,
28299,
14,
3112,
14,
1200,
14,
10794,
14,
10794,
492,
15967,
7567,
2377,
199,
363,
452,
363,
275,
2097,
24260,
2377,
937,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
199,
3,
1898,
334,
35,
9,
14894,
9572,
13002,
12,
3277,
14,
199,
3,
199,
3,
961,
1331,
31816,
471,
6285,
365,
6326,
2808,
370,
29165,
13809,
316,
370,
675,
12,
199,
3,
2811,
12,
1331,
12,
503,
3604,
652,
5420,
370,
314,
2895,
436,
3704,
402,
199,
3,
314,
1664,
1696,
1684,
844,
373,
14,
18,
12,
503,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
961,
2240,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
1325,
2428,
199,
3,
1821,
3408,
19147,
503,
2478,
12,
5893,
314,
2478,
3712,
1417,
402,
199,
3,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
1664,
1696,
199,
3,
1684,
844,
367,
1655,
2436,
14,
221,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
199,
3,
1664,
1696,
1684,
844,
3180,
543,
642,
2240,
27,
340,
440,
12,
2218,
370,
314,
199,
3,
2868,
2290,
2752,
12,
3277,
2020,
8026,
11236,
14259,
12,
12066,
11844,
12,
8226,
12,
4828,
199,
3,
11315,
13,
10067,
12,
8217,
14,
221,
6184,
9572,
13002,
21032,
10375,
626,
787,
30147,
972,
315,
314,
199,
3,
1350,
1233,
503,
3794,
787,
440,
5420,
370,
314,
1664,
1696,
1684,
199,
3,
844,
436,
1443,
1454,
506,
1202,
503,
32436,
543,
314,
4056,
4983,
402,
199,
3,
9572,
13002,
12,
3277,
14,
199,
3,
199,
504,
1134,
28299,
14,
3112,
14,
1200,
14,
10794,
14,
10794,
492,
15967,
7567,
2377,
199,
363,
452,
363,
275,
2097,
24260,
2377,
937,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
start-jsk/jsk_apc
|
demos/instance_occlsegm/examples/instance_occlsegm/instance_occlusion_segmentation/demo.py
|
2
|
4895
|
#!/usr/bin/env python
from __future__ import print_function
import argparse
import os.path as osp
import pprint
import chainer
import numpy as np
import yaml
import chainer_mask_rcnn as cmr
import instance_occlsegm_lib
from instance_occlsegm_lib.contrib import instance_occlsegm
from instance_occlsegm_lib.contrib import synthetic2d
def main():
parser = argparse.ArgumentParser(
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
)
parser.add_argument('log_dir', help='log dir')
parser.add_argument('--gpu', '-g', type=int, default=0, help='gpu id')
args = parser.parse_args()
# XXX: see also evaluate.py
# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
# param
params = yaml.load(open(osp.join(args.log_dir, 'params.yaml')))
print('Training config:')
print('# ' + '-' * 77)
pprint.pprint(params)
print('# ' + '-' * 77)
# dataset
if 'class_names' in params:
class_names = params['class_names']
elif params['dataset'] == 'voc':
test_data = cmr.datasets.SBDInstanceSegmentationDataset('val')
class_names = test_data.class_names
elif params['dataset'] == 'coco':
test_data = cmr.datasets.COCOInstanceSegmentationDataset('minival')
class_names = test_data.class_names
else:
raise ValueError
# model
if params['dataset'] == 'voc':
if 'min_size' not in params:
params['min_size'] = 600
if 'max_size' not in params:
params['max_size'] = 1000
if 'anchor_scales' not in params:
params['anchor_scales'] = (4, 8, 16, 32)
elif params['dataset'] == 'coco':
if 'min_size' not in params:
params['min_size'] = 800
if 'max_size' not in params:
params['max_size'] = 1333
if 'anchor_scales' not in params:
params['anchor_scales'] = (2, 4, 8, 16, 32)
else:
assert 'min_size' in params
assert 'max_size' in params
assert 'anchor_scales' in params
if params['pooling_func'] == 'align':
pooling_func = cmr.functions.roi_align_2d
elif params['pooling_func'] == 'pooling':
pooling_func = cmr.functions.roi_pooling_2d
elif params['pooling_func'] == 'resize':
pooling_func = cmr.functions.crop_and_resize
else:
raise ValueError(
'Unsupported pooling_func: {}'.format(params['pooling_func'])
)
pretrained_model = osp.join(args.log_dir, 'snapshot_model.npz')
print('Using pretrained_model: %s' % pretrained_model)
model = params['model']
mask_rcnn = instance_occlsegm.models.MaskRCNNResNet(
n_layers=int(model.lstrip('resnet')),
n_fg_class=len(class_names),
pretrained_model=pretrained_model,
pooling_func=pooling_func,
anchor_scales=params['anchor_scales'],
mean=params.get('mean', (123.152, 115.903, 103.063)),
min_size=params['min_size'],
max_size=params['max_size'],
roi_size=params.get('roi_size', 7),
rpn_dim=params.get('rpn_dim', 1024),
)
mask_rcnn.nms_thresh = 0
mask_rcnn.score_thresh = 0
if args.gpu >= 0:
chainer.cuda.get_device_from_id(args.gpu).use()
mask_rcnn.to_gpu()
# <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
dataset = synthetic2d.datasets.ARC2017OcclusionDataset(split='test')
# dataset = instance_occlsegm_lib.datasets.apc.\
# ARC2017InstanceSegmentationDataset('test')
# img = dataset[2][0]
imgs = [dataset[2][0], dataset[3][0]]
imgs_chw = [img.transpose(2, 0, 1) for img in imgs]
del dataset
bboxes, masks, labels, scores = mask_rcnn.predict(imgs_chw)
# thresh_proba = 0.7
thresh_proba = 0.5
for i in range(len(imgs)):
show(
imgs[i],
bboxes[i],
masks[i],
labels[i],
scores[i],
thresh_proba,
class_names,
)
def show(img, bbox, mask, label, score, thresh_proba, class_names):
keep = score >= thresh_proba
bbox_ = bbox[keep]
mask_ = mask[keep]
label_ = label[keep]
score_ = score[keep]
indices = np.argsort(score_)
bbox_ = bbox_[indices]
mask_ = mask_[indices]
label_ = label_[indices]
score_ = score_[indices]
captions = [
'{:s}: {:.1%}'.format(class_names[l], s)
for l, s in zip(label_, score_)
]
print('# ' + '-' * 77)
for caption in captions:
print(caption)
print('# ' + '-' * 77)
viz_ins = cmr.utils.draw_instance_bboxes(
img,
bbox_,
label_ + 1,
n_class=len(class_names) + 1,
masks=mask_ == 1,
captions=captions,
)
instance_occlsegm_lib.io.imshow(viz_ins)
instance_occlsegm_lib.io.waitkey()
if __name__ == '__main__':
main()
|
bsd-3-clause
|
[
3381,
2647,
15,
1393,
15,
1813,
2366,
199,
199,
504,
636,
2443,
363,
492,
870,
63,
1593,
199,
199,
646,
7534,
199,
646,
747,
14,
515,
465,
312,
681,
199,
646,
10933,
199,
199,
646,
20333,
199,
646,
2680,
465,
980,
199,
646,
8864,
199,
199,
646,
20333,
63,
2629,
63,
1195,
4411,
465,
6904,
82,
199,
199,
646,
1256,
63,
679,
429,
8359,
77,
63,
773,
199,
504,
1256,
63,
679,
429,
8359,
77,
63,
773,
14,
2828,
492,
1256,
63,
679,
429,
8359,
77,
199,
504,
1256,
63,
679,
429,
8359,
77,
63,
773,
14,
2828,
492,
9560,
21231,
18,
68,
421,
199,
318,
2446,
837,
272,
1798,
275,
7534,
14,
10730,
8,
267,
9698,
63,
533,
29,
18978,
14,
5201,
16986,
22779,
12,
272,
776,
272,
1798,
14,
525,
63,
2094,
360,
793,
63,
694,
297,
1720,
534,
793,
2935,
358,
272,
1798,
14,
525,
63,
2094,
4517,
6477,
297,
2475,
71,
297,
730,
29,
442,
12,
849,
29,
16,
12,
1720,
534,
6477,
1305,
358,
272,
1249,
275,
1798,
14,
1122,
63,
589,
342,
339,
327,
5787,
26,
1937,
2597,
9352,
14,
647,
272,
327,
1306,
28375,
28375,
28375,
28375,
28375,
28375,
28375,
28375,
28375,
28375,
28375,
28375,
28375,
28375,
28375,
28375,
28375,
1140,
272,
327,
1215,
272,
1862,
275,
8864,
14,
912,
8,
1490,
8,
79,
681,
14,
904,
8,
589,
14,
793,
63,
694,
12,
283,
1162,
14,
5963,
7058,
272,
870,
360,
20463,
1101,
10993,
272,
870,
7863,
283,
435,
10791,
627,
8375,
9,
272,
10933,
14,
15380,
8,
1162,
9,
272,
870,
7863,
283,
435,
10791,
627,
8375,
9,
339,
327,
4789,
272,
340,
283,
533,
63,
1247,
7,
315,
1862,
26,
267,
1021,
63,
1247,
275,
1862,
459,
533,
63,
1247,
418,
272,
916,
1862,
459,
5214,
418,
508,
283,
86,
679,
356,
267,
511,
63,
576,
275,
6904,
82,
14,
12281,
14,
51,
11156,
3244,
19689,
3117,
9271,
360,
637,
358,
267,
1021,
63,
1247,
275,
511,
63,
576,
14,
533,
63,
1247,
272,
916,
1862,
459,
5214,
418,
508,
283,
331,
331,
356,
267,
511,
63,
576,
275,
6904,
82,
14,
12281,
14,
1439,
1439,
3244,
19689,
3117,
9271,
360,
18000,
637,
358,
267,
1021,
63,
1247,
275,
511,
63,
576,
14,
533,
63,
1247,
272,
587,
26,
267,
746,
1722,
339,
327,
1402,
339,
340,
1862,
459,
5214,
418,
508,
283,
86,
679,
356,
267,
340,
283,
827,
63,
890,
7,
440,
315,
1862,
26,
288,
1862,
459,
827,
63,
890,
418,
275,
11624,
267,
340,
283,
988,
63,
890,
7,
440,
315,
1862,
26,
288,
1862,
459,
988,
63,
890,
418,
275,
5198,
267,
340,
283,
11498,
63,
30832,
7,
440,
315,
1862,
26,
288,
1862,
459,
11498,
63,
30832,
418,
275,
334,
20,
12,
1695,
12,
3193,
12,
4337,
9,
272,
916,
1862,
459,
5214,
418,
508,
283,
331,
331,
356,
267,
340,
283,
827,
63,
890,
7,
440,
315,
1862,
26,
288,
1862,
459,
827,
63,
890,
418,
275,
23466,
267,
340,
283,
988,
63,
890,
7,
440,
315,
1862,
26,
288,
1862,
459,
988,
63,
890,
418,
275,
413,
11769,
267,
340,
283,
11498,
63,
30832,
7,
440,
315,
1862,
26,
288,
1862,
459,
11498,
63,
30832,
418,
275,
334,
18,
12,
841,
12,
1695,
12,
3193,
12,
4337,
9,
272,
587,
26,
267,
702,
283,
827,
63,
890,
7,
315,
1862,
267,
702,
283,
988,
63,
890,
7,
315,
1862,
267,
702,
283,
11498,
63,
30832,
7,
315,
1862,
339,
340,
1862,
459,
28624,
63,
1532,
418,
508,
283,
5743,
356,
267,
20699,
63,
1532,
275,
6904,
82,
14,
5777,
14,
20581,
63,
5743,
63,
18,
68,
272,
916,
1862,
459,
28624,
63,
1532,
418,
508,
283,
28624,
356,
267,
20699,
63,
1532,
275,
6904,
82,
14,
5777,
14,
20581,
63,
28624,
63,
18,
68,
272,
916,
1862,
459,
28624,
63,
1532,
418,
508,
283,
8709,
356,
267,
20699,
63,
1532,
275,
6904,
82,
14,
5777,
14,
15816,
63,
460,
63,
8709,
272,
587,
26,
267,
746,
1722,
8,
288,
283,
12647,
20699,
63,
1532,
26,
9499,
908,
8,
1162,
459,
28624,
63,
1532,
1105,
267,
776,
339,
876,
23782,
63,
1238,
275,
312,
681,
14,
904,
8,
589,
14,
793,
63,
694,
12,
283,
4753,
63,
1238,
14,
1590,
90,
358,
272,
870,
360,
10369,
876,
23782,
63,
1238,
26,
450,
83,
7,
450,
876,
23782,
63,
1238,
9,
339,
1402,
275,
1862,
459,
1238,
418,
272,
3656,
63,
1195,
4411,
275,
1256,
63,
679,
429,
8359,
77,
14,
992,
14,
5144,
8205,
7178,
1322,
2480,
8,
267,
302,
63,
4359,
29,
442,
8,
1238,
14,
10124,
360,
28998,
3855,
267,
302,
63,
9681,
63,
533,
29,
552,
8,
533,
63,
1247,
395,
267,
876,
23782,
63,
1238,
29,
657,
23782,
63,
1238,
12,
267,
20699,
63,
1532,
29,
28624,
63,
1532,
12,
267,
12514,
63,
30832,
29,
1162,
459,
11498,
63,
30832,
995,
267,
4615,
29,
1162,
14,
362,
360,
3670,
297,
334,
4288,
14,
11024,
12,
22560,
14,
25,
1644,
12,
22363,
14,
22653,
1826,
267,
1748,
63,
890,
29,
1162,
459,
827,
63,
890,
995,
267,
1390,
63,
890,
29,
1162,
459,
988,
63,
890,
995,
267,
30240,
63,
890,
29,
1162,
14,
362,
360,
20581,
63,
890,
297,
1520,
395,
267,
519,
4812,
63,
3572,
29,
1162,
14,
362,
360,
4599,
78,
63,
3572,
297,
6619,
395,
272,
776,
272,
3656,
63,
1195,
4411,
14,
78,
706,
63,
14898,
275,
378,
272,
3656,
63,
1195,
4411,
14,
3397,
63,
14898,
275,
378,
272,
340,
1249,
14,
6477,
2356,
378,
26,
267,
20333,
14,
16309,
14,
362,
63,
1782,
63,
504,
63,
344,
8,
589,
14,
6477,
680,
1180,
342,
267,
3656,
63,
1195,
4411,
14,
475,
63,
6477,
342,
272,
327,
5213,
31275,
31275,
31275,
31275,
31275,
31275,
31275,
31275,
31275,
31275,
31275,
31275,
31275,
31275,
31275,
31275,
31275,
8999,
28,
339,
4789,
275,
9560,
21231,
18,
68,
14,
12281,
14,
24028,
10680,
16184,
10248,
9271,
8,
1294,
534,
396,
358,
272,
327,
4789,
275,
1256,
63,
679,
429,
8359,
77,
63,
773,
14,
12281,
14,
439,
67,
3134,
272,
327,
259,
4160,
35,
10680,
3244,
19689,
3117,
9271,
360,
396,
358
] |
[
2647,
15,
1393,
15,
1813,
2366,
199,
199,
504,
636,
2443,
363,
492,
870,
63,
1593,
199,
199,
646,
7534,
199,
646,
747,
14,
515,
465,
312,
681,
199,
646,
10933,
199,
199,
646,
20333,
199,
646,
2680,
465,
980,
199,
646,
8864,
199,
199,
646,
20333,
63,
2629,
63,
1195,
4411,
465,
6904,
82,
199,
199,
646,
1256,
63,
679,
429,
8359,
77,
63,
773,
199,
504,
1256,
63,
679,
429,
8359,
77,
63,
773,
14,
2828,
492,
1256,
63,
679,
429,
8359,
77,
199,
504,
1256,
63,
679,
429,
8359,
77,
63,
773,
14,
2828,
492,
9560,
21231,
18,
68,
421,
199,
318,
2446,
837,
272,
1798,
275,
7534,
14,
10730,
8,
267,
9698,
63,
533,
29,
18978,
14,
5201,
16986,
22779,
12,
272,
776,
272,
1798,
14,
525,
63,
2094,
360,
793,
63,
694,
297,
1720,
534,
793,
2935,
358,
272,
1798,
14,
525,
63,
2094,
4517,
6477,
297,
2475,
71,
297,
730,
29,
442,
12,
849,
29,
16,
12,
1720,
534,
6477,
1305,
358,
272,
1249,
275,
1798,
14,
1122,
63,
589,
342,
339,
327,
5787,
26,
1937,
2597,
9352,
14,
647,
272,
327,
1306,
28375,
28375,
28375,
28375,
28375,
28375,
28375,
28375,
28375,
28375,
28375,
28375,
28375,
28375,
28375,
28375,
28375,
1140,
272,
327,
1215,
272,
1862,
275,
8864,
14,
912,
8,
1490,
8,
79,
681,
14,
904,
8,
589,
14,
793,
63,
694,
12,
283,
1162,
14,
5963,
7058,
272,
870,
360,
20463,
1101,
10993,
272,
870,
7863,
283,
435,
10791,
627,
8375,
9,
272,
10933,
14,
15380,
8,
1162,
9,
272,
870,
7863,
283,
435,
10791,
627,
8375,
9,
339,
327,
4789,
272,
340,
283,
533,
63,
1247,
7,
315,
1862,
26,
267,
1021,
63,
1247,
275,
1862,
459,
533,
63,
1247,
418,
272,
916,
1862,
459,
5214,
418,
508,
283,
86,
679,
356,
267,
511,
63,
576,
275,
6904,
82,
14,
12281,
14,
51,
11156,
3244,
19689,
3117,
9271,
360,
637,
358,
267,
1021,
63,
1247,
275,
511,
63,
576,
14,
533,
63,
1247,
272,
916,
1862,
459,
5214,
418,
508,
283,
331,
331,
356,
267,
511,
63,
576,
275,
6904,
82,
14,
12281,
14,
1439,
1439,
3244,
19689,
3117,
9271,
360,
18000,
637,
358,
267,
1021,
63,
1247,
275,
511,
63,
576,
14,
533,
63,
1247,
272,
587,
26,
267,
746,
1722,
339,
327,
1402,
339,
340,
1862,
459,
5214,
418,
508,
283,
86,
679,
356,
267,
340,
283,
827,
63,
890,
7,
440,
315,
1862,
26,
288,
1862,
459,
827,
63,
890,
418,
275,
11624,
267,
340,
283,
988,
63,
890,
7,
440,
315,
1862,
26,
288,
1862,
459,
988,
63,
890,
418,
275,
5198,
267,
340,
283,
11498,
63,
30832,
7,
440,
315,
1862,
26,
288,
1862,
459,
11498,
63,
30832,
418,
275,
334,
20,
12,
1695,
12,
3193,
12,
4337,
9,
272,
916,
1862,
459,
5214,
418,
508,
283,
331,
331,
356,
267,
340,
283,
827,
63,
890,
7,
440,
315,
1862,
26,
288,
1862,
459,
827,
63,
890,
418,
275,
23466,
267,
340,
283,
988,
63,
890,
7,
440,
315,
1862,
26,
288,
1862,
459,
988,
63,
890,
418,
275,
413,
11769,
267,
340,
283,
11498,
63,
30832,
7,
440,
315,
1862,
26,
288,
1862,
459,
11498,
63,
30832,
418,
275,
334,
18,
12,
841,
12,
1695,
12,
3193,
12,
4337,
9,
272,
587,
26,
267,
702,
283,
827,
63,
890,
7,
315,
1862,
267,
702,
283,
988,
63,
890,
7,
315,
1862,
267,
702,
283,
11498,
63,
30832,
7,
315,
1862,
339,
340,
1862,
459,
28624,
63,
1532,
418,
508,
283,
5743,
356,
267,
20699,
63,
1532,
275,
6904,
82,
14,
5777,
14,
20581,
63,
5743,
63,
18,
68,
272,
916,
1862,
459,
28624,
63,
1532,
418,
508,
283,
28624,
356,
267,
20699,
63,
1532,
275,
6904,
82,
14,
5777,
14,
20581,
63,
28624,
63,
18,
68,
272,
916,
1862,
459,
28624,
63,
1532,
418,
508,
283,
8709,
356,
267,
20699,
63,
1532,
275,
6904,
82,
14,
5777,
14,
15816,
63,
460,
63,
8709,
272,
587,
26,
267,
746,
1722,
8,
288,
283,
12647,
20699,
63,
1532,
26,
9499,
908,
8,
1162,
459,
28624,
63,
1532,
1105,
267,
776,
339,
876,
23782,
63,
1238,
275,
312,
681,
14,
904,
8,
589,
14,
793,
63,
694,
12,
283,
4753,
63,
1238,
14,
1590,
90,
358,
272,
870,
360,
10369,
876,
23782,
63,
1238,
26,
450,
83,
7,
450,
876,
23782,
63,
1238,
9,
339,
1402,
275,
1862,
459,
1238,
418,
272,
3656,
63,
1195,
4411,
275,
1256,
63,
679,
429,
8359,
77,
14,
992,
14,
5144,
8205,
7178,
1322,
2480,
8,
267,
302,
63,
4359,
29,
442,
8,
1238,
14,
10124,
360,
28998,
3855,
267,
302,
63,
9681,
63,
533,
29,
552,
8,
533,
63,
1247,
395,
267,
876,
23782,
63,
1238,
29,
657,
23782,
63,
1238,
12,
267,
20699,
63,
1532,
29,
28624,
63,
1532,
12,
267,
12514,
63,
30832,
29,
1162,
459,
11498,
63,
30832,
995,
267,
4615,
29,
1162,
14,
362,
360,
3670,
297,
334,
4288,
14,
11024,
12,
22560,
14,
25,
1644,
12,
22363,
14,
22653,
1826,
267,
1748,
63,
890,
29,
1162,
459,
827,
63,
890,
995,
267,
1390,
63,
890,
29,
1162,
459,
988,
63,
890,
995,
267,
30240,
63,
890,
29,
1162,
14,
362,
360,
20581,
63,
890,
297,
1520,
395,
267,
519,
4812,
63,
3572,
29,
1162,
14,
362,
360,
4599,
78,
63,
3572,
297,
6619,
395,
272,
776,
272,
3656,
63,
1195,
4411,
14,
78,
706,
63,
14898,
275,
378,
272,
3656,
63,
1195,
4411,
14,
3397,
63,
14898,
275,
378,
272,
340,
1249,
14,
6477,
2356,
378,
26,
267,
20333,
14,
16309,
14,
362,
63,
1782,
63,
504,
63,
344,
8,
589,
14,
6477,
680,
1180,
342,
267,
3656,
63,
1195,
4411,
14,
475,
63,
6477,
342,
272,
327,
5213,
31275,
31275,
31275,
31275,
31275,
31275,
31275,
31275,
31275,
31275,
31275,
31275,
31275,
31275,
31275,
31275,
31275,
8999,
28,
339,
4789,
275,
9560,
21231,
18,
68,
14,
12281,
14,
24028,
10680,
16184,
10248,
9271,
8,
1294,
534,
396,
358,
272,
327,
4789,
275,
1256,
63,
679,
429,
8359,
77,
63,
773,
14,
12281,
14,
439,
67,
3134,
272,
327,
259,
4160,
35,
10680,
3244,
19689,
3117,
9271,
360,
396,
358,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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8 -*-
#Copyright (c) Vincent Cardon <vincent.cardon@tranquil-it-systems.fr>
# Denis Cardon <denis.cardon@tranquilitsystems.com> and Emmanuel RICHARD.
#Ingenieur fondateur
#Tranquil IT Systems
from __future__ import with_statement
from openerp.osv import fields, osv
from openerp import pooler
from openerp import tools
from openerp.tools.translate import _
from openerp.report.render import render
from openerp.report.interface import report_int
from openerp import addons
import tempfile
import os
class external_pdf(render):
def __init__(self, pdf):
render.__init__(self)
self.pdf = pdf
self.output_type='pdf'
def _render(self):
return self.pdf
class report_custom(report_int):
def create(self, cr, uid, ids, datas, context=None):
pool = pooler.get_pool(cr.dbname)
taxobj = pool.get('account.tax.code')
if context is None:
context = {}
code_ids = taxobj.search(cr, uid, [('parent_id','child_of',[datas['form']['tax_code_id']])])
result = {}
for t in taxobj.browse(cr, uid, code_ids, {'period_id': datas['form']['period_id']}):
if str(t.code):
result['case_'+str(t.code)] = '%.2f' % (t.sum_period or 0.0, )
user = pool.get('res.users').browse(cr, uid, uid, context)
# Not Clean, to be changed
partner = user.company_id.partner_id
result['info_name'] = user.company_id.name
result['info_vatnum'] = partner.vat
if partner:
result['info_address'] = partner.street
result['info_address2'] = (partner.zip or '') + ' ' + (partner.city or '')
try:
tmp_file = tempfile.mkstemp(".pdf")[1]
try:
tools.pdf_utils.fill_pdf(addons.get_module_resource('l10n_lu','wizard', '2008_DECL_F_M10.pdf'), tmp_file, result)
with open(tmp_file, "r") as ofile:
self.obj = external_pdf(ofile.read())
finally:
try:
os.remove(tmp_file)
except:
pass # nothing to do
self.obj.render()
return (self.obj.pdf, 'pdf')
except Exception:
raise osv.except_osv(_('PDF Not Created!'), _('Please check if package pdftk is installed!'))
report_custom('report.l10n_lu.tax.report.print')
class vat_declaration_report(osv.osv_memory):
_name = 'vat.declaration.report'
_description = 'VAT Declaration Report'
_columns = {
'tax_code_id': fields.many2one('account.tax.code', 'Company', readonly=False, required=True, domain=[('parent_id','=',False)]),
'type': fields.selection([('monthly','Monthly'),('quarterly','Quaterly'),('yearly','Yearly')], 'Type', required=True),
'period_id' : fields.many2one('account.period', 'From Period', required=True),
'to_period_id': fields.many2one('account.period', 'To Period', required=True),
}
_defaults = {
'type': 'monthly',
}
def print_vat_declaration_report(self, cr, uid, ids, context=None):
active_ids = context.get('active_ids',[])
data = {}
data['form'] = {}
data['ids'] = active_ids
data['form']['tax_code_id'] = self.browse(cr, uid, ids)[0].tax_code_id.id
data['form']['period_id'] = self.browse(cr, uid, ids)[0].period_id.id
return { 'type': 'ir.actions.report.xml', 'report_name': 'l10n_lu.tax.report.print', 'datas': data}
vat_declaration_report()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
agpl-3.0
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
7384,
334,
67,
9,
28882,
2946,
445,
1005,
265,
665,
11908,
2946,
14,
5841,
265,
32,
3936,
392,
382,
13,
390,
13,
19135,
14,
4391,
30,
199,
3,
25187,
374,
445,
1005,
265,
665,
848,
374,
14,
5841,
265,
32,
3936,
783,
1051,
19135,
14,
957,
30,
436,
662,
596,
290,
13086,
820,
948,
30322,
14,
199,
3,
607,
2268,
1873,
300,
289,
265,
602,
300,
199,
3,
14612,
392,
382,
473,
52,
15285,
199,
199,
504,
636,
2443,
363,
492,
543,
63,
6242,
199,
504,
5166,
14,
4795,
492,
1504,
12,
9506,
199,
504,
5166,
492,
1115,
79,
1435,
199,
504,
5166,
492,
7249,
199,
504,
5166,
14,
2537,
14,
5275,
492,
485,
199,
504,
5166,
14,
3070,
14,
3352,
492,
3795,
199,
504,
5166,
14,
3070,
14,
3266,
492,
3622,
63,
442,
199,
504,
5166,
492,
21293,
199,
646,
5549,
199,
646,
747,
199,
199,
533,
5957,
63,
5607,
8,
3352,
304,
339,
347,
636,
826,
721,
277,
12,
11249,
304,
267,
3795,
855,
826,
721,
277,
9,
267,
291,
14,
5607,
275,
11249,
267,
291,
14,
1199,
63,
466,
534,
5607,
7,
339,
347,
485,
3352,
8,
277,
304,
267,
372,
291,
14,
5607,
421,
199,
533,
3622,
63,
4229,
8,
3070,
63,
442,
304,
339,
347,
1218,
8,
277,
12,
2467,
12,
1747,
12,
2762,
12,
15012,
12,
1067,
29,
403,
304,
398,
4203,
275,
1115,
79,
1435,
14,
362,
63,
2293,
8,
1556,
14,
13238,
9,
267,
9067,
1113,
275,
4203,
14,
362,
360,
2048,
14,
5530,
14,
600,
358,
398,
340,
1067,
365,
488,
26,
288,
1067,
275,
1052,
267,
1233,
63,
1580,
275,
9067,
1113,
14,
1733,
8,
1556,
12,
1747,
12,
4274,
1708,
63,
344,
1673,
1739,
63,
1618,
23993,
11563,
459,
964,
2545,
5530,
63,
600,
63,
344,
12121,
566,
267,
754,
275,
1052,
267,
367,
307,
315,
9067,
1113,
14,
4570,
8,
1556,
12,
1747,
12,
1233,
63,
1580,
12,
791,
5191,
63,
344,
356,
15012,
459,
964,
2545,
5191,
63,
344,
12074,
304,
288,
340,
620,
8,
84,
14,
600,
304,
355,
754,
459,
2546,
20013,
495,
8,
84,
14,
600,
1874,
275,
22769,
18,
70,
7,
450,
334,
84,
14,
1838,
63,
5191,
503,
378,
14,
16,
12,
776,
267,
922,
275,
4203,
14,
362,
360,
470,
14,
3707,
1959,
4570,
8,
1556,
12,
1747,
12,
1747,
12,
1067,
9,
398,
327,
2832,
12762,
12,
370,
506,
2896,
267,
5854,
275,
922,
14,
4627,
63,
344,
14,
3899,
63,
344,
267,
754,
459,
815,
63,
354,
418,
275,
922,
14,
4627,
63,
344,
14,
354,
267,
754,
459,
815,
63,
16305,
1507,
418,
275,
5854,
14,
16305,
267,
340,
5854,
26,
288,
754,
459,
815,
63,
1562,
418,
275,
5854,
14,
20451,
288,
754,
459,
815,
63,
1562,
18,
418,
275,
334,
3899,
14,
3065,
503,
4074,
435,
283,
283,
435,
334,
3899,
14,
3690,
503,
4074,
267,
862,
26,
288,
3529,
63,
493,
275,
5549,
14,
17721,
9520,
5607,
9981,
17,
61,
288,
862,
26,
355,
7249,
14,
5607,
63,
1208,
14,
4498,
63,
5607,
8,
10788,
14,
362,
63,
578,
63,
1927,
360,
76,
709,
78,
63,
10836,
1673,
9819,
297,
283,
9300,
63,
27402,
63,
38,
63,
45,
709,
14,
5607,
659,
3529,
63,
493,
12,
754,
9,
355,
543,
1551,
8,
2791,
63,
493,
12,
298,
82,
531,
465,
312,
493,
26,
490,
291,
14,
1113,
275,
5957,
63,
5607,
8,
79,
493,
14,
739,
1012,
288,
3753,
26,
355,
862,
26,
490,
747,
14,
2168,
8,
2791,
63,
493,
9,
355,
871,
26,
490,
986,
327,
6548,
370,
886,
288,
291,
14,
1113,
14,
3352,
342,
288,
372,
334,
277,
14,
1113,
14,
5607,
12,
283,
5607,
358,
267,
871,
2186,
26,
288,
746,
9506,
14,
2590,
63,
4795,
6723,
7638,
2832,
18208,
15659,
4018,
8254,
1104,
340,
2559,
6454,
856,
75,
365,
4903,
1,
1333,
199,
199,
3070,
63,
4229,
360,
3070,
14,
76,
709,
78,
63,
10836,
14,
5530,
14,
3070,
14,
1361,
358,
199,
199,
533,
373,
292,
63,
15477,
63,
3070,
8,
4795,
14,
4795,
63,
4844,
304,
272,
485,
354,
275,
283,
16305,
14,
15477,
14,
3070,
7,
272,
485,
1802,
275,
283,
54,
619,
1487,
7456,
11774,
7,
339,
485,
3406,
275,
469,
268,
283,
5530,
63,
600,
63,
344,
356,
1504,
14,
3479,
18,
368,
360,
2048,
14,
5530,
14,
600,
297,
283,
16063,
297,
6863,
29,
797,
12,
1415,
29,
549,
12,
2881,
11699,
1708,
63,
344,
18937,
797,
16636,
268,
283,
466,
356,
1504,
14,
5592,
8318,
30517,
1673,
14306,
590,
8157,
25985,
590,
1673,
2371,
6618,
590,
8157,
16785,
1673,
15731,
590,
2665,
283,
804,
297,
1415,
29,
549,
395,
268,
283,
5191,
63,
344,
7,
520,
1504,
14,
3479,
18,
368,
360,
2048,
14,
5191,
297,
283,
2532,
16532,
297,
1415,
29,
549,
395,
268,
283,
475,
63,
5191,
63,
344,
356,
1504,
14,
3479,
18,
368,
360,
2048,
14,
5191,
297,
283,
1378,
16532,
297,
1415,
29,
549,
395,
272,
789,
339,
485,
4322,
275,
469,
267,
283,
466,
356,
283,
30517,
297,
272,
789,
339,
347,
870,
63,
16305,
63,
15477,
63,
3070,
8,
277,
12,
2467,
12,
1747,
12,
2762,
12,
1067,
29,
403,
304,
267,
4702,
63,
1580,
275,
1067,
14,
362,
360,
2682,
63,
1580,
23993,
566,
267,
666,
275,
1052,
267,
666,
459,
964,
418,
275,
1052,
267,
666,
459,
1580,
418,
275,
4702,
63,
1580,
267,
666,
459,
964,
2545,
5530,
63,
600,
63,
344,
418,
275,
291,
14,
4570,
8,
1556,
12,
1747,
12,
2762,
2788,
16,
1055,
5530,
63,
600,
63,
344,
14,
344,
267,
666,
459,
964,
2545,
5191,
63,
344,
418,
275,
291,
14,
4570,
8,
1556,
12,
1747,
12,
2762,
2788,
16,
1055,
5191,
63,
344,
14,
344,
267,
372,
469,
283,
466,
356,
283,
723,
14,
3723,
14,
3070,
14,
1652,
297,
283,
3070,
63,
354,
356,
283,
76,
709,
78,
63,
10836,
14,
5530,
14,
3070,
14,
1361,
297,
283,
11563,
356,
666,
93,
199,
199,
16305,
63,
15477,
63,
3070,
342,
199,
199,
3,
6695,
26,
10379,
26,
10558,
26,
6492
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
7384,
334,
67,
9,
28882,
2946,
445,
1005,
265,
665,
11908,
2946,
14,
5841,
265,
32,
3936,
392,
382,
13,
390,
13,
19135,
14,
4391,
30,
199,
3,
25187,
374,
445,
1005,
265,
665,
848,
374,
14,
5841,
265,
32,
3936,
783,
1051,
19135,
14,
957,
30,
436,
662,
596,
290,
13086,
820,
948,
30322,
14,
199,
3,
607,
2268,
1873,
300,
289,
265,
602,
300,
199,
3,
14612,
392,
382,
473,
52,
15285,
199,
199,
504,
636,
2443,
363,
492,
543,
63,
6242,
199,
504,
5166,
14,
4795,
492,
1504,
12,
9506,
199,
504,
5166,
492,
1115,
79,
1435,
199,
504,
5166,
492,
7249,
199,
504,
5166,
14,
2537,
14,
5275,
492,
485,
199,
504,
5166,
14,
3070,
14,
3352,
492,
3795,
199,
504,
5166,
14,
3070,
14,
3266,
492,
3622,
63,
442,
199,
504,
5166,
492,
21293,
199,
646,
5549,
199,
646,
747,
199,
199,
533,
5957,
63,
5607,
8,
3352,
304,
339,
347,
636,
826,
721,
277,
12,
11249,
304,
267,
3795,
855,
826,
721,
277,
9,
267,
291,
14,
5607,
275,
11249,
267,
291,
14,
1199,
63,
466,
534,
5607,
7,
339,
347,
485,
3352,
8,
277,
304,
267,
372,
291,
14,
5607,
421,
199,
533,
3622,
63,
4229,
8,
3070,
63,
442,
304,
339,
347,
1218,
8,
277,
12,
2467,
12,
1747,
12,
2762,
12,
15012,
12,
1067,
29,
403,
304,
398,
4203,
275,
1115,
79,
1435,
14,
362,
63,
2293,
8,
1556,
14,
13238,
9,
267,
9067,
1113,
275,
4203,
14,
362,
360,
2048,
14,
5530,
14,
600,
358,
398,
340,
1067,
365,
488,
26,
288,
1067,
275,
1052,
267,
1233,
63,
1580,
275,
9067,
1113,
14,
1733,
8,
1556,
12,
1747,
12,
4274,
1708,
63,
344,
1673,
1739,
63,
1618,
23993,
11563,
459,
964,
2545,
5530,
63,
600,
63,
344,
12121,
566,
267,
754,
275,
1052,
267,
367,
307,
315,
9067,
1113,
14,
4570,
8,
1556,
12,
1747,
12,
1233,
63,
1580,
12,
791,
5191,
63,
344,
356,
15012,
459,
964,
2545,
5191,
63,
344,
12074,
304,
288,
340,
620,
8,
84,
14,
600,
304,
355,
754,
459,
2546,
20013,
495,
8,
84,
14,
600,
1874,
275,
22769,
18,
70,
7,
450,
334,
84,
14,
1838,
63,
5191,
503,
378,
14,
16,
12,
776,
267,
922,
275,
4203,
14,
362,
360,
470,
14,
3707,
1959,
4570,
8,
1556,
12,
1747,
12,
1747,
12,
1067,
9,
398,
327,
2832,
12762,
12,
370,
506,
2896,
267,
5854,
275,
922,
14,
4627,
63,
344,
14,
3899,
63,
344,
267,
754,
459,
815,
63,
354,
418,
275,
922,
14,
4627,
63,
344,
14,
354,
267,
754,
459,
815,
63,
16305,
1507,
418,
275,
5854,
14,
16305,
267,
340,
5854,
26,
288,
754,
459,
815,
63,
1562,
418,
275,
5854,
14,
20451,
288,
754,
459,
815,
63,
1562,
18,
418,
275,
334,
3899,
14,
3065,
503,
4074,
435,
283,
283,
435,
334,
3899,
14,
3690,
503,
4074,
267,
862,
26,
288,
3529,
63,
493,
275,
5549,
14,
17721,
9520,
5607,
9981,
17,
61,
288,
862,
26,
355,
7249,
14,
5607,
63,
1208,
14,
4498,
63,
5607,
8,
10788,
14,
362,
63,
578,
63,
1927,
360,
76,
709,
78,
63,
10836,
1673,
9819,
297,
283,
9300,
63,
27402,
63,
38,
63,
45,
709,
14,
5607,
659,
3529,
63,
493,
12,
754,
9,
355,
543,
1551,
8,
2791,
63,
493,
12,
298,
82,
531,
465,
312,
493,
26,
490,
291,
14,
1113,
275,
5957,
63,
5607,
8,
79,
493,
14,
739,
1012,
288,
3753,
26,
355,
862,
26,
490,
747,
14,
2168,
8,
2791,
63,
493,
9,
355,
871,
26,
490,
986,
327,
6548,
370,
886,
288,
291,
14,
1113,
14,
3352,
342,
288,
372,
334,
277,
14,
1113,
14,
5607,
12,
283,
5607,
358,
267,
871,
2186,
26,
288,
746,
9506,
14,
2590,
63,
4795,
6723,
7638,
2832,
18208,
15659,
4018,
8254,
1104,
340,
2559,
6454,
856,
75,
365,
4903,
1,
1333,
199,
199,
3070,
63,
4229,
360,
3070,
14,
76,
709,
78,
63,
10836,
14,
5530,
14,
3070,
14,
1361,
358,
199,
199,
533,
373,
292,
63,
15477,
63,
3070,
8,
4795,
14,
4795,
63,
4844,
304,
272,
485,
354,
275,
283,
16305,
14,
15477,
14,
3070,
7,
272,
485,
1802,
275,
283,
54,
619,
1487,
7456,
11774,
7,
339,
485,
3406,
275,
469,
268,
283,
5530,
63,
600,
63,
344,
356,
1504,
14,
3479,
18,
368,
360,
2048,
14,
5530,
14,
600,
297,
283,
16063,
297,
6863,
29,
797,
12,
1415,
29,
549,
12,
2881,
11699,
1708,
63,
344,
18937,
797,
16636,
268,
283,
466,
356,
1504,
14,
5592,
8318,
30517,
1673,
14306,
590,
8157,
25985,
590,
1673,
2371,
6618,
590,
8157,
16785,
1673,
15731,
590,
2665,
283,
804,
297,
1415,
29,
549,
395,
268,
283,
5191,
63,
344,
7,
520,
1504,
14,
3479,
18,
368,
360,
2048,
14,
5191,
297,
283,
2532,
16532,
297,
1415,
29,
549,
395,
268,
283,
475,
63,
5191,
63,
344,
356,
1504,
14,
3479,
18,
368,
360,
2048,
14,
5191,
297,
283,
1378,
16532,
297,
1415,
29,
549,
395,
272,
789,
339,
485,
4322,
275,
469,
267,
283,
466,
356,
283,
30517,
297,
272,
789,
339,
347,
870,
63,
16305,
63,
15477,
63,
3070,
8,
277,
12,
2467,
12,
1747,
12,
2762,
12,
1067,
29,
403,
304,
267,
4702,
63,
1580,
275,
1067,
14,
362,
360,
2682,
63,
1580,
23993,
566,
267,
666,
275,
1052,
267,
666,
459,
964,
418,
275,
1052,
267,
666,
459,
1580,
418,
275,
4702,
63,
1580,
267,
666,
459,
964,
2545,
5530,
63,
600,
63,
344,
418,
275,
291,
14,
4570,
8,
1556,
12,
1747,
12,
2762,
2788,
16,
1055,
5530,
63,
600,
63,
344,
14,
344,
267,
666,
459,
964,
2545,
5191,
63,
344,
418,
275,
291,
14,
4570,
8,
1556,
12,
1747,
12,
2762,
2788,
16,
1055,
5191,
63,
344,
14,
344,
267,
372,
469,
283,
466,
356,
283,
723,
14,
3723,
14,
3070,
14,
1652,
297,
283,
3070,
63,
354,
356,
283,
76,
709,
78,
63,
10836,
14,
5530,
14,
3070,
14,
1361,
297,
283,
11563,
356,
666,
93,
199,
199,
16305,
63,
15477,
63,
3070,
342,
199,
199,
3,
6695,
26,
10379,
26,
10558,
26,
6492,
0
] |
[
1,
1,
1,
1,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onaccio
|
web2py/gluon/widget.py
|
4
|
46175
|
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
| This file is part of the web2py Web Framework
| Copyrighted by Massimo Di Pierro <mdipierro@cs.depaul.edu>
| License: LGPLv3 (http://www.gnu.org/licenses/lgpl.html)
The widget is called from web2py
----------------------------------
"""
import datetime
import sys
import cStringIO
import time
import thread
import threading
import os
import socket
import signal
import math
import logging
import newcron
import getpass
import gluon.main as main
from gluon.fileutils import read_file, write_file, create_welcome_w2p
from gluon.settings import global_settings
from gluon.shell import run, test
from gluon.utils import is_valid_ip_address, is_loopback_ip_address, getipaddrinfo
ProgramName = 'web2py Web Framework'
ProgramAuthor = 'Created by Massimo Di Pierro, Copyright 2007-' + str(
datetime.datetime.now().year)
ProgramVersion = read_file('VERSION').strip()
ProgramInfo = '''%s
%s
%s''' % (ProgramName, ProgramAuthor, ProgramVersion)
if not sys.version[:3] in ['2.5', '2.6', '2.7']:
msg = 'Warning: web2py requires Python 2.5, 2.6 or 2.7 but you are running:\n%s'
msg = msg % sys.version
sys.stderr.write(msg)
logger = logging.getLogger("web2py")
def run_system_tests(options):
"""
Runs unittests for gluon.tests
"""
import subprocess
major_version = sys.version_info[0]
minor_version = sys.version_info[1]
if major_version == 2:
if minor_version in (5, 6):
sys.stderr.write("Python 2.5 or 2.6\n")
ret = subprocess.call(['unit2', '-v', 'gluon.tests'])
elif minor_version in (7,):
call_args = [sys.executable, '-m', 'unittest', '-v', 'gluon.tests']
if options.with_coverage:
try:
import coverage
coverage_config = os.environ.get(
"COVERAGE_PROCESS_START",
os.path.join('gluon', 'tests', 'coverage.ini'))
call_args = ['coverage', 'run', '--rcfile=%s' %
coverage_config,
'-m', 'unittest', '-v', 'gluon.tests']
except:
sys.stderr.write('Coverage was not installed, skipping\n')
sys.stderr.write("Python 2.7\n")
ret = subprocess.call(call_args)
else:
sys.stderr.write("unknown python 2.x version\n")
ret = 256
else:
sys.stderr.write("Only Python 2.x supported.\n")
ret = 256
sys.exit(ret and 1)
class IO(object):
""" """
def __init__(self):
""" """
self.buffer = cStringIO.StringIO()
def write(self, data):
""" """
sys.__stdout__.write(data)
if hasattr(self, 'callback'):
self.callback(data)
else:
self.buffer.write(data)
def get_url(host, path='/', proto='http', port=80):
if ':' in host:
host = '[%s]' % host
else:
host = host.replace('0.0.0.0', '127.0.0.1')
if path.startswith('/'):
path = path[1:]
if proto.endswith(':'):
proto = proto[:-1]
if not port or port == 80:
port = ''
else:
port = ':%s' % port
return '%s://%s%s/%s' % (proto, host, port, path)
def start_browser(url, startup=False):
if startup:
print 'please visit:'
print '\t', url
print 'starting browser...'
try:
import webbrowser
webbrowser.open(url)
except:
print 'warning: unable to detect your browser'
class web2pyDialog(object):
""" Main window dialog """
def __init__(self, root, options):
""" web2pyDialog constructor """
import Tkinter
import tkMessageBox
bg_color = 'white'
root.withdraw()
self.root = Tkinter.Toplevel(root, bg=bg_color)
self.root.resizable(0, 0)
self.root.title(ProgramName)
self.options = options
self.scheduler_processes = {}
self.menu = Tkinter.Menu(self.root)
servermenu = Tkinter.Menu(self.menu, tearoff=0)
httplog = os.path.join(self.options.folder, 'httpserver.log')
iconphoto = os.path.join('extras', 'icons', 'web2py.gif')
if os.path.exists(iconphoto):
img = Tkinter.PhotoImage(file=iconphoto)
self.root.tk.call('wm', 'iconphoto', self.root._w, img)
# Building the Menu
item = lambda: start_browser(httplog)
servermenu.add_command(label='View httpserver.log',
command=item)
servermenu.add_command(label='Quit (pid:%i)' % os.getpid(),
command=self.quit)
self.menu.add_cascade(label='Server', menu=servermenu)
self.pagesmenu = Tkinter.Menu(self.menu, tearoff=0)
self.menu.add_cascade(label='Pages', menu=self.pagesmenu)
#scheduler menu
self.schedmenu = Tkinter.Menu(self.menu, tearoff=0)
self.menu.add_cascade(label='Scheduler', menu=self.schedmenu)
#start and register schedulers from options
self.update_schedulers(start=True)
helpmenu = Tkinter.Menu(self.menu, tearoff=0)
# Home Page
item = lambda: start_browser('http://www.web2py.com/')
helpmenu.add_command(label='Home Page',
command=item)
# About
item = lambda: tkMessageBox.showinfo('About web2py', ProgramInfo)
helpmenu.add_command(label='About',
command=item)
self.menu.add_cascade(label='Info', menu=helpmenu)
self.root.config(menu=self.menu)
if options.taskbar:
self.root.protocol('WM_DELETE_WINDOW',
lambda: self.quit(True))
else:
self.root.protocol('WM_DELETE_WINDOW', self.quit)
sticky = Tkinter.NW
# Prepare the logo area
self.logoarea = Tkinter.Canvas(self.root,
background=bg_color,
width=300,
height=300)
self.logoarea.grid(row=0, column=0, columnspan=4, sticky=sticky)
self.logoarea.after(1000, self.update_canvas)
logo = os.path.join('extras', 'icons', 'splashlogo.gif')
if os.path.exists(logo):
img = Tkinter.PhotoImage(file=logo)
pnl = Tkinter.Label(self.logoarea, image=img, background=bg_color, bd=0)
pnl.pack(side='top', fill='both', expand='yes')
# Prevent garbage collection of img
pnl.image = img
# Prepare the banner area
self.bannerarea = Tkinter.Canvas(self.root,
bg=bg_color,
width=300,
height=300)
self.bannerarea.grid(row=1, column=1, columnspan=2, sticky=sticky)
Tkinter.Label(self.bannerarea, anchor=Tkinter.N,
text=str(ProgramVersion + "\n" + ProgramAuthor),
font=('Helvetica', 11), justify=Tkinter.CENTER,
foreground='#195866', background=bg_color,
height=3).pack( side='top',
fill='both',
expand='yes')
self.bannerarea.after(1000, self.update_canvas)
# IP
Tkinter.Label(self.root,
text='Server IP:', bg=bg_color,
justify=Tkinter.RIGHT).grid(row=4,
column=1,
sticky=sticky)
self.ips = {}
self.selected_ip = Tkinter.StringVar()
row = 4
ips = [('127.0.0.1', 'Local (IPv4)')] + \
([('::1', 'Local (IPv6)')] if socket.has_ipv6 else []) + \
[(ip, 'Public') for ip in options.ips] + \
[('0.0.0.0', 'Public')]
for ip, legend in ips:
self.ips[ip] = Tkinter.Radiobutton(
self.root, bg=bg_color, highlightthickness=0,
selectcolor='light grey', width=30,
anchor=Tkinter.W, text='%s (%s)' % (legend, ip),
justify=Tkinter.LEFT,
variable=self.selected_ip, value=ip)
self.ips[ip].grid(row=row, column=2, sticky=sticky)
if row == 4:
self.ips[ip].select()
row += 1
shift = row
# Port
Tkinter.Label(self.root,
text='Server Port:', bg=bg_color,
justify=Tkinter.RIGHT).grid(row=shift,
column=1, pady=10,
sticky=sticky)
self.port_number = Tkinter.Entry(self.root)
self.port_number.insert(Tkinter.END, self.options.port)
self.port_number.grid(row=shift, column=2, sticky=sticky, pady=10)
# Password
Tkinter.Label(self.root,
text='Choose Password:', bg=bg_color,
justify=Tkinter.RIGHT).grid(row=shift + 1,
column=1,
sticky=sticky)
self.password = Tkinter.Entry(self.root, show='*')
self.password.bind('<Return>', lambda e: self.start())
self.password.focus_force()
self.password.grid(row=shift + 1, column=2, sticky=sticky)
# Prepare the canvas
self.canvas = Tkinter.Canvas(self.root,
width=400,
height=100,
bg='black')
self.canvas.grid(row=shift + 2, column=1, columnspan=2, pady=5,
sticky=sticky)
self.canvas.after(1000, self.update_canvas)
# Prepare the frame
frame = Tkinter.Frame(self.root)
frame.grid(row=shift + 3, column=1, columnspan=2, pady=5,
sticky=sticky)
# Start button
self.button_start = Tkinter.Button(frame,
text='start server',
command=self.start)
self.button_start.grid(row=0, column=0, sticky=sticky)
# Stop button
self.button_stop = Tkinter.Button(frame,
text='stop server',
command=self.stop)
self.button_stop.grid(row=0, column=1, sticky=sticky)
self.button_stop.configure(state='disabled')
if options.taskbar:
import gluon.contrib.taskbar_widget
self.tb = gluon.contrib.taskbar_widget.TaskBarIcon()
self.checkTaskBar()
if options.password != '<ask>':
self.password.insert(0, options.password)
self.start()
self.root.withdraw()
else:
self.tb = None
def update_schedulers(self, start=False):
apps = []
available_apps = [arq for arq in os.listdir('applications/')]
available_apps = [arq for arq in available_apps
if os.path.exists(
'applications/%s/models/scheduler.py' % arq)]
if start:
# the widget takes care of starting the scheduler
if self.options.scheduler and self.options.with_scheduler:
apps = [app.strip() for app
in self.options.scheduler.split(',')
if app in available_apps]
for app in apps:
self.try_start_scheduler(app)
# reset the menu
self.schedmenu.delete(0, len(available_apps))
for arq in available_apps:
if arq not in self.scheduler_processes:
item = lambda u = arq: self.try_start_scheduler(u)
self.schedmenu.add_command(label="start %s" % arq,
command=item)
if arq in self.scheduler_processes:
item = lambda u = arq: self.try_stop_scheduler(u)
self.schedmenu.add_command(label="stop %s" % arq,
command=item)
def start_schedulers(self, app):
try:
from multiprocessing import Process
except:
sys.stderr.write('Sorry, -K only supported for python 2.6-2.7\n')
return
code = "from gluon import current;current._scheduler.loop()"
print 'starting scheduler from widget for "%s"...' % app
args = (app, True, True, None, False, code)
logging.getLogger().setLevel(self.options.debuglevel)
p = Process(target=run, args=args)
self.scheduler_processes[app] = p
self.update_schedulers()
print "Currently running %s scheduler processes" % (
len(self.scheduler_processes))
p.start()
print "Processes started"
def try_stop_scheduler(self, app):
if app in self.scheduler_processes:
p = self.scheduler_processes[app]
del self.scheduler_processes[app]
p.terminate()
p.join()
self.update_schedulers()
def try_start_scheduler(self, app):
if app not in self.scheduler_processes:
t = threading.Thread(target=self.start_schedulers, args=(app,))
t.start()
def checkTaskBar(self):
""" Checks taskbar status """
if self.tb.status:
if self.tb.status[0] == self.tb.EnumStatus.QUIT:
self.quit()
elif self.tb.status[0] == self.tb.EnumStatus.TOGGLE:
if self.root.state() == 'withdrawn':
self.root.deiconify()
else:
self.root.withdraw()
elif self.tb.status[0] == self.tb.EnumStatus.STOP:
self.stop()
elif self.tb.status[0] == self.tb.EnumStatus.START:
self.start()
elif self.tb.status[0] == self.tb.EnumStatus.RESTART:
self.stop()
self.start()
del self.tb.status[0]
self.root.after(1000, self.checkTaskBar)
def update(self, text):
""" Updates app text """
try:
self.text.configure(state='normal')
self.text.insert('end', text)
self.text.configure(state='disabled')
except:
pass # ## this should only happen in case app is destroyed
def connect_pages(self):
""" Connects pages """
# reset the menu
available_apps = [arq for arq in os.listdir('applications/')
if os.path.exists(
'applications/%s/__init__.py' % arq)]
self.pagesmenu.delete(0, len(available_apps))
for arq in available_apps:
url = self.url + arq
self.pagesmenu.add_command(
label=url, command=lambda u=url: start_browser(u))
def quit(self, justHide=False):
""" Finishes the program execution """
if justHide:
self.root.withdraw()
else:
try:
scheds = self.scheduler_processes.keys()
for t in scheds:
self.try_stop_scheduler(t)
except:
pass
try:
newcron.stopcron()
except:
pass
try:
self.server.stop()
except:
pass
try:
self.tb.Destroy()
except:
pass
self.root.destroy()
sys.exit(0)
def error(self, message):
""" Shows error message """
import tkMessageBox
tkMessageBox.showerror('web2py start server', message)
def start(self):
""" Starts web2py server """
password = self.password.get()
if not password:
self.error('no password, no web admin interface')
ip = self.selected_ip.get()
if not is_valid_ip_address(ip):
return self.error('invalid host ip address')
try:
port = int(self.port_number.get())
except:
return self.error('invalid port number')
# Check for non default value for ssl inputs
if (len(self.options.ssl_certificate) > 0 or
len(self.options.ssl_private_key) > 0):
proto = 'https'
else:
proto = 'http'
self.url = get_url(ip, proto=proto, port=port)
self.connect_pages()
self.button_start.configure(state='disabled')
try:
options = self.options
req_queue_size = options.request_queue_size
self.server = main.HttpServer(
ip,
port,
password,
pid_filename=options.pid_filename,
log_filename=options.log_filename,
profiler_dir=options.profiler_dir,
ssl_certificate=options.ssl_certificate,
ssl_private_key=options.ssl_private_key,
ssl_ca_certificate=options.ssl_ca_certificate,
min_threads=options.minthreads,
max_threads=options.maxthreads,
server_name=options.server_name,
request_queue_size=req_queue_size,
timeout=options.timeout,
shutdown_timeout=options.shutdown_timeout,
path=options.folder,
interfaces=options.interfaces)
thread.start_new_thread(self.server.start, ())
except Exception, e:
self.button_start.configure(state='normal')
return self.error(str(e))
if not self.server_ready():
self.button_start.configure(state='normal')
return
self.button_stop.configure(state='normal')
if not options.taskbar:
thread.start_new_thread(
start_browser, (get_url(ip, proto=proto, port=port), True))
self.password.configure(state='readonly')
[ip.configure(state='disabled') for ip in self.ips.values()]
self.port_number.configure(state='readonly')
if self.tb:
self.tb.SetServerRunning()
def server_ready(self):
for listener in self.server.server.listeners:
if listener.ready:
return True
return False
def stop(self):
""" Stops web2py server """
self.button_start.configure(state='normal')
self.button_stop.configure(state='disabled')
self.password.configure(state='normal')
[ip.configure(state='normal') for ip in self.ips.values()]
self.port_number.configure(state='normal')
self.server.stop()
if self.tb:
self.tb.SetServerStopped()
def update_canvas(self):
""" Updates canvas """
try:
t1 = os.path.getsize('httpserver.log')
except:
self.canvas.after(1000, self.update_canvas)
return
try:
fp = open('httpserver.log', 'r')
fp.seek(self.t0)
data = fp.read(t1 - self.t0)
fp.close()
value = self.p0[1:] + [10 + 90.0 / math.sqrt(1 + data.count('\n'))]
self.p0 = value
for i in xrange(len(self.p0) - 1):
c = self.canvas.coords(self.q0[i])
self.canvas.coords(self.q0[i],
(c[0],
self.p0[i],
c[2],
self.p0[i + 1]))
self.t0 = t1
except BaseException:
self.t0 = time.time()
self.t0 = t1
self.p0 = [100] * 400
self.q0 = [self.canvas.create_line(i, 100, i + 1, 100,
fill='green') for i in xrange(len(self.p0) - 1)]
self.canvas.after(1000, self.update_canvas)
def console():
""" Defines the behavior of the console web2py execution """
import optparse
import textwrap
usage = "python web2py.py"
description = """\
web2py Web Framework startup script.
ATTENTION: unless a password is specified (-a 'passwd') web2py will
attempt to run a GUI. In this case command line options are ignored."""
description = textwrap.dedent(description)
parser = optparse.OptionParser(
usage, None, optparse.Option, ProgramVersion)
parser.description = description
msg = ('IP address of the server (e.g., 127.0.0.1 or ::1); '
'Note: This value is ignored when using the \'interfaces\' option.')
parser.add_option('-i',
'--ip',
default='127.0.0.1',
dest='ip',
help=msg)
parser.add_option('-p',
'--port',
default='8000',
dest='port',
type='int',
help='port of server (8000)')
parser.add_option('-G',
'--GAE',
default=None,
dest='gae',
help="'-G configure' will create app.yaml and gaehandler.py")
msg = ('password to be used for administration '
'(use -a "<recycle>" to reuse the last password))')
parser.add_option('-a',
'--password',
default='<ask>',
dest='password',
help=msg)
parser.add_option('-c',
'--ssl_certificate',
default='',
dest='ssl_certificate',
help='file that contains ssl certificate')
parser.add_option('-k',
'--ssl_private_key',
default='',
dest='ssl_private_key',
help='file that contains ssl private key')
msg = ('Use this file containing the CA certificate to validate X509 '
'certificates from clients')
parser.add_option('--ca-cert',
action='store',
dest='ssl_ca_certificate',
default=None,
help=msg)
parser.add_option('-d',
'--pid_filename',
default='httpserver.pid',
dest='pid_filename',
help='file to store the pid of the server')
parser.add_option('-l',
'--log_filename',
default='httpserver.log',
dest='log_filename',
help='file to log connections')
parser.add_option('-n',
'--numthreads',
default=None,
type='int',
dest='numthreads',
help='number of threads (deprecated)')
parser.add_option('--minthreads',
default=None,
type='int',
dest='minthreads',
help='minimum number of server threads')
parser.add_option('--maxthreads',
default=None,
type='int',
dest='maxthreads',
help='maximum number of server threads')
parser.add_option('-s',
'--server_name',
default=socket.gethostname(),
dest='server_name',
help='server name for the web server')
msg = 'max number of queued requests when server unavailable'
parser.add_option('-q',
'--request_queue_size',
default='5',
type='int',
dest='request_queue_size',
help=msg)
parser.add_option('-o',
'--timeout',
default='10',
type='int',
dest='timeout',
help='timeout for individual request (10 seconds)')
parser.add_option('-z',
'--shutdown_timeout',
default='5',
type='int',
dest='shutdown_timeout',
help='timeout on shutdown of server (5 seconds)')
parser.add_option('--socket-timeout',
default=5,
type='int',
dest='socket_timeout',
help='timeout for socket (5 second)')
parser.add_option('-f',
'--folder',
default=os.getcwd(),
dest='folder',
help='folder from which to run web2py')
parser.add_option('-v',
'--verbose',
action='store_true',
dest='verbose',
default=False,
help='increase --test verbosity')
parser.add_option('-Q',
'--quiet',
action='store_true',
dest='quiet',
default=False,
help='disable all output')
parser.add_option('-e',
'--errors_to_console',
action='store_true',
dest='print_errors',
default=False,
help='log all errors to console')
msg = ('set debug output level (0-100, 0 means all, 100 means none; '
'default is 30)')
parser.add_option('-D',
'--debug',
dest='debuglevel',
default=30,
type='int',
help=msg)
msg = ('run web2py in interactive shell or IPython (if installed) with '
'specified appname (if app does not exist it will be created). '
'APPNAME like a/c/f (c,f optional)')
parser.add_option('-S',
'--shell',
dest='shell',
metavar='APPNAME',
help=msg)
msg = ('run web2py in interactive shell or bpython (if installed) with '
'specified appname (if app does not exist it will be created).\n'
'Use combined with --shell')
parser.add_option('-B',
'--bpython',
action='store_true',
default=False,
dest='bpython',
help=msg)
msg = 'only use plain python shell; should be used with --shell option'
parser.add_option('-P',
'--plain',
action='store_true',
default=False,
dest='plain',
help=msg)
msg = ('auto import model files; default is False; should be used '
'with --shell option')
parser.add_option('-M',
'--import_models',
action='store_true',
default=False,
dest='import_models',
help=msg)
msg = ('run PYTHON_FILE in web2py environment; '
'should be used with --shell option')
parser.add_option('-R',
'--run',
dest='run',
metavar='PYTHON_FILE',
default='',
help=msg)
msg = ('run scheduled tasks for the specified apps: expects a list of '
'app names as -K app1,app2,app3 '
'or a list of app:groups as -K app1:group1:group2,app2:group1 '
'to override specific group_names. (only strings, no spaces '
'allowed. Requires a scheduler defined in the models')
parser.add_option('-K',
'--scheduler',
dest='scheduler',
default=None,
help=msg)
msg = 'run schedulers alongside webserver, needs -K app1 and -a too'
parser.add_option('-X',
'--with-scheduler',
action='store_true',
default=False,
dest='with_scheduler',
help=msg)
msg = ('run doctests in web2py environment; '
'TEST_PATH like a/c/f (c,f optional)')
parser.add_option('-T',
'--test',
dest='test',
metavar='TEST_PATH',
default=None,
help=msg)
msg = 'trigger a cron run manually; usually invoked from a system crontab'
parser.add_option('-C',
'--cron',
action='store_true',
dest='extcron',
default=False,
help=msg)
msg = 'triggers the use of softcron'
parser.add_option('--softcron',
action='store_true',
dest='softcron',
default=False,
help=msg)
parser.add_option('-Y',
'--run-cron',
action='store_true',
dest='runcron',
default=False,
help='start the background cron process')
parser.add_option('-J',
'--cronjob',
action='store_true',
dest='cronjob',
default=False,
help='identify cron-initiated command')
parser.add_option('-L',
'--config',
dest='config',
default='',
help='config file')
parser.add_option('-F',
'--profiler',
dest='profiler_dir',
default=None,
help='profiler dir')
parser.add_option('-t',
'--taskbar',
action='store_true',
dest='taskbar',
default=False,
help='use web2py gui and run in taskbar (system tray)')
parser.add_option('',
'--nogui',
action='store_true',
default=False,
dest='nogui',
help='text-only, no GUI')
msg = ('should be followed by a list of arguments to be passed to script, '
'to be used with -S, -A must be the last option')
parser.add_option('-A',
'--args',
action='store',
dest='args',
default=None,
help=msg)
parser.add_option('--no-banner',
action='store_true',
default=False,
dest='nobanner',
help='Do not print header banner')
msg = ('listen on multiple addresses: '
'"ip1:port1:key1:cert1:ca_cert1;ip2:port2:key2:cert2:ca_cert2;..." '
'(:key:cert:ca_cert optional; no spaces; IPv6 addresses must be in '
'square [] brackets)')
parser.add_option('--interfaces',
action='store',
dest='interfaces',
default=None,
help=msg)
msg = 'runs web2py tests'
parser.add_option('--run_system_tests',
action='store_true',
dest='run_system_tests',
default=False,
help=msg)
msg = ('adds coverage reporting (needs --run_system_tests), '
'python 2.7 and the coverage module installed. '
'You can alter the default path setting the environmental '
'var "COVERAGE_PROCESS_START". '
'By default it takes gluon/tests/coverage.ini')
parser.add_option('--with_coverage',
action='store_true',
dest='with_coverage',
default=False,
help=msg)
if '-A' in sys.argv:
k = sys.argv.index('-A')
elif '--args' in sys.argv:
k = sys.argv.index('--args')
else:
k = len(sys.argv)
sys.argv, other_args = sys.argv[:k], sys.argv[k + 1:]
(options, args) = parser.parse_args()
options.args = [options.run] + other_args
global_settings.cmd_options = options
global_settings.cmd_args = args
if options.gae:
if not os.path.exists('app.yaml'):
name = raw_input("Your GAE app name: ")
content = open(os.path.join('examples', 'app.example.yaml'), 'rb').read()
open('app.yaml', 'wb').write(content.replace("yourappname", name))
else:
print "app.yaml alreday exists in the web2py folder"
if not os.path.exists('gaehandler.py'):
content = open(os.path.join('handlers', 'gaehandler.py'), 'rb').read()
open('gaehandler.py', 'wb').write(content)
else:
print "gaehandler.py alreday exists in the web2py folder"
sys.exit(0)
try:
options.ips = list(set( # no duplicates
[addrinfo[4][0] for addrinfo in getipaddrinfo(socket.getfqdn())
if not is_loopback_ip_address(addrinfo=addrinfo)]))
except socket.gaierror:
options.ips = []
if options.run_system_tests:
run_system_tests(options)
if options.quiet:
capture = cStringIO.StringIO()
sys.stdout = capture
logger.setLevel(logging.CRITICAL + 1)
else:
logger.setLevel(options.debuglevel)
if options.config[-3:] == '.py':
options.config = options.config[:-3]
if options.cronjob:
global_settings.cronjob = True # tell the world
options.plain = True # cronjobs use a plain shell
options.nobanner = True
options.nogui = True
options.folder = os.path.abspath(options.folder)
# accept --interfaces in the form
# "ip1:port1:key1:cert1:ca_cert1;[ip2]:port2;ip3:port3:key3:cert3"
# (no spaces; optional key:cert indicate SSL)
if isinstance(options.interfaces, str):
interfaces = options.interfaces.split(';')
options.interfaces = []
for interface in interfaces:
if interface.startswith('['): # IPv6
ip, if_remainder = interface.split(']', 1)
ip = ip[1:]
if_remainder = if_remainder[1:].split(':')
if_remainder[0] = int(if_remainder[0]) # numeric port
options.interfaces.append(tuple([ip] + if_remainder))
else: # IPv4
interface = interface.split(':')
interface[1] = int(interface[1]) # numeric port
options.interfaces.append(tuple(interface))
# accepts --scheduler in the form
# "app:group1,group2,app2:group1"
scheduler = []
options.scheduler_groups = None
if isinstance(options.scheduler, str):
if ':' in options.scheduler:
for opt in options.scheduler.split(','):
scheduler.append(opt.split(':'))
options.scheduler = ','.join([app[0] for app in scheduler])
options.scheduler_groups = scheduler
if options.numthreads is not None and options.minthreads is None:
options.minthreads = options.numthreads # legacy
create_welcome_w2p()
if not options.cronjob:
# If we have the applications package or if we should upgrade
if not os.path.exists('applications/__init__.py'):
write_file('applications/__init__.py', '')
return options, args
def check_existent_app(options, appname):
if os.path.isdir(os.path.join(options.folder, 'applications', appname)):
return True
def get_code_for_scheduler(app, options):
if len(app) == 1 or app[1] is None:
code = "from gluon import current;current._scheduler.loop()"
else:
code = "from gluon import current;current._scheduler.group_names = ['%s'];"
code += "current._scheduler.loop()"
code = code % ("','".join(app[1:]))
app_ = app[0]
if not check_existent_app(options, app_):
print "Application '%s' doesn't exist, skipping" % app_
return None, None
return app_, code
def start_schedulers(options):
try:
from multiprocessing import Process
except:
sys.stderr.write('Sorry, -K only supported for python 2.6-2.7\n')
return
processes = []
apps = [(app.strip(), None) for app in options.scheduler.split(',')]
if options.scheduler_groups:
apps = options.scheduler_groups
code = "from gluon import current;current._scheduler.loop()"
logging.getLogger().setLevel(options.debuglevel)
if len(apps) == 1 and not options.with_scheduler:
app_, code = get_code_for_scheduler(apps[0], options)
if not app_:
return
print 'starting single-scheduler for "%s"...' % app_
run(app_, True, True, None, False, code)
return
# Work around OS X problem: http://bugs.python.org/issue9405
import urllib
urllib.getproxies()
for app in apps:
app_, code = get_code_for_scheduler(app, options)
if not app_:
continue
print 'starting scheduler for "%s"...' % app_
args = (app_, True, True, None, False, code)
p = Process(target=run, args=args)
processes.append(p)
print "Currently running %s scheduler processes" % (len(processes))
p.start()
##to avoid bashing the db at the same time
time.sleep(0.7)
print "Processes started"
for p in processes:
try:
p.join()
except (KeyboardInterrupt, SystemExit):
print "Processes stopped"
except:
p.terminate()
p.join()
def start(cron=True):
""" Starts server """
# ## get command line arguments
(options, args) = console()
if not options.nobanner:
print ProgramName
print ProgramAuthor
print ProgramVersion
from pydal.drivers import DRIVERS
if not options.nobanner:
print 'Database drivers available: %s' % ', '.join(DRIVERS)
# ## if -L load options from options.config file
if options.config:
try:
options2 = __import__(options.config, {}, {}, '')
except Exception:
try:
# Jython doesn't like the extra stuff
options2 = __import__(options.config)
except Exception:
print 'Cannot import config file [%s]' % options.config
sys.exit(1)
for key in dir(options2):
if hasattr(options, key):
setattr(options, key, getattr(options2, key))
logfile0 = os.path.join('extras', 'examples', 'logging.example.conf')
if not os.path.exists('logging.conf') and os.path.exists(logfile0):
import shutil
sys.stdout.write("Copying logging.conf.example to logging.conf ... ")
shutil.copyfile('logging.example.conf', logfile0)
sys.stdout.write("OK\n")
# ## if -T run doctests (no cron)
if hasattr(options, 'test') and options.test:
test(options.test, verbose=options.verbose)
return
# ## if -S start interactive shell (also no cron)
if options.shell:
if options.folder:
os.chdir(options.folder)
if not options.args is None:
sys.argv[:] = options.args
run(options.shell, plain=options.plain, bpython=options.bpython,
import_models=options.import_models, startfile=options.run,
cronjob=options.cronjob)
return
# ## if -C start cron run (extcron) and exit
# ## -K specifies optional apps list (overloading scheduler)
if options.extcron:
logger.debug('Starting extcron...')
global_settings.web2py_crontype = 'external'
if options.scheduler: # -K
apps = [app.strip() for app in options.scheduler.split(
',') if check_existent_app(options, app.strip())]
else:
apps = None
extcron = newcron.extcron(options.folder, apps=apps)
extcron.start()
extcron.join()
return
# ## if -K
if options.scheduler and not options.with_scheduler:
try:
start_schedulers(options)
except KeyboardInterrupt:
pass
return
# ## if -H cron is enabled in this *process*
# ## if --softcron use softcron
# ## use hardcron in all other cases
if cron and options.runcron and options.softcron:
print 'Using softcron (but this is not very efficient)'
global_settings.web2py_crontype = 'soft'
elif cron and options.runcron:
logger.debug('Starting hardcron...')
global_settings.web2py_crontype = 'hard'
newcron.hardcron(options.folder).start()
# ## if no password provided and havetk start Tk interface
# ## or start interface if we want to put in taskbar (system tray)
try:
options.taskbar
except:
options.taskbar = False
if options.taskbar and os.name != 'nt':
print 'Error: taskbar not supported on this platform'
sys.exit(1)
root = None
if not options.nogui and options.password == '<ask>':
try:
import Tkinter
havetk = True
try:
root = Tkinter.Tk()
except:
pass
except (ImportError, OSError):
logger.warn(
'GUI not available because Tk library is not installed')
havetk = False
options.nogui = True
if root:
root.focus_force()
# Mac OS X - make the GUI window rise to the top
if os.path.exists("/usr/bin/osascript"):
applescript = """
tell application "System Events"
set proc to first process whose unix id is %d
set frontmost of proc to true
end tell
""" % (os.getpid())
os.system("/usr/bin/osascript -e '%s'" % applescript)
master = web2pyDialog(root, options)
signal.signal(signal.SIGTERM, lambda a, b: master.quit())
try:
root.mainloop()
except:
master.quit()
sys.exit()
# ## if no tk and no password, ask for a password
if not root and options.password == '<ask>':
options.password = getpass.getpass('choose a password:')
if not options.password and not options.nobanner:
print 'no password, no admin interface'
# ##-X (if no tk, the widget takes care of it himself)
if not root and options.scheduler and options.with_scheduler:
t = threading.Thread(target=start_schedulers, args=(options,))
t.start()
# ## start server
# Use first interface IP and port if interfaces specified, since the
# interfaces option overrides the IP (and related) options.
if not options.interfaces:
(ip, port) = (options.ip, int(options.port))
else:
first_if = options.interfaces[0]
(ip, port) = first_if[0], first_if[1]
# Check for non default value for ssl inputs
if (len(options.ssl_certificate) > 0) or (len(options.ssl_private_key) > 0):
proto = 'https'
else:
proto = 'http'
url = get_url(ip, proto=proto, port=port)
if not options.nobanner:
message = '\nplease visit:\n\t%s\n' % url
if sys.platform.startswith('win'):
message += 'use "taskkill /f /pid %i" to shutdown the web2py server\n\n' % os.getpid()
else:
message += 'use "kill -SIGTERM %i" to shutdown the web2py server\n\n' % os.getpid()
print message
# enhance linecache.getline (used by debugger) to look at the source file
# if the line was not found (under py2exe & when file was modified)
import linecache
py2exe_getline = linecache.getline
def getline(filename, lineno, *args, **kwargs):
line = py2exe_getline(filename, lineno, *args, **kwargs)
if not line:
try:
f = open(filename, "r")
try:
for i, line in enumerate(f):
if lineno == i + 1:
break
else:
line = None
finally:
f.close()
except (IOError, OSError):
line = None
return line
linecache.getline = getline
server = main.HttpServer(ip=ip,
port=port,
password=options.password,
pid_filename=options.pid_filename,
log_filename=options.log_filename,
profiler_dir=options.profiler_dir,
ssl_certificate=options.ssl_certificate,
ssl_private_key=options.ssl_private_key,
ssl_ca_certificate=options.ssl_ca_certificate,
min_threads=options.minthreads,
max_threads=options.maxthreads,
server_name=options.server_name,
request_queue_size=options.request_queue_size,
timeout=options.timeout,
socket_timeout=options.socket_timeout,
shutdown_timeout=options.shutdown_timeout,
path=options.folder,
interfaces=options.interfaces)
try:
server.start()
except KeyboardInterrupt:
server.stop()
try:
t.join()
except:
pass
logging.shutdown()
|
gpl-2.0
|
[
3381,
2647,
15,
1393,
15,
1813,
2366,
199,
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
199,
624,
199,
92,
961,
570,
365,
1777,
402,
314,
3330,
18,
647,
6001,
22545,
199,
92,
11247,
31816,
471,
701,
603,
2608,
573,
3757,
510,
4446,
293,
665,
20208,
1038,
281,
293,
32,
1259,
14,
271,
387,
348,
14,
8654,
30,
199,
92,
844,
26,
491,
28863,
19,
334,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
15,
9783,
1168,
14,
1360,
9,
199,
199,
1918,
3938,
365,
2797,
687,
3330,
18,
647,
199,
1444,
306,
199,
624,
199,
199,
646,
2197,
199,
646,
984,
199,
646,
15073,
199,
646,
900,
199,
646,
2462,
199,
646,
5796,
199,
646,
747,
199,
646,
2838,
199,
646,
4673,
199,
646,
3473,
199,
646,
2050,
199,
646,
892,
14829,
199,
646,
18354,
199,
646,
26752,
14,
973,
465,
2446,
199,
199,
504,
26752,
14,
493,
1208,
492,
1586,
63,
493,
12,
2218,
63,
493,
12,
1218,
63,
28508,
63,
87,
18,
80,
199,
504,
26752,
14,
1751,
492,
2288,
63,
1751,
199,
504,
26752,
14,
5641,
492,
1255,
12,
511,
199,
504,
26752,
14,
1208,
492,
365,
63,
1078,
63,
711,
63,
1562,
12,
365,
63,
23983,
63,
711,
63,
1562,
12,
2312,
8996,
2697,
815,
421,
199,
9184,
985,
275,
283,
2520,
18,
647,
6001,
22545,
7,
199,
9184,
5949,
275,
283,
10502,
701,
603,
2608,
573,
3757,
510,
4446,
293,
12,
1898,
10219,
15668,
435,
620,
8,
272,
2197,
14,
2083,
14,
2131,
1252,
3403,
9,
199,
9184,
3353,
275,
1586,
63,
493,
360,
4612,
1959,
1913,
342,
199,
199,
9184,
2354,
275,
1449,
5,
83,
326,
450,
83,
326,
450,
83,
2344,
450,
334,
9184,
985,
12,
18841,
5949,
12,
18841,
3353,
9,
199,
199,
692,
440,
984,
14,
1023,
1491,
19,
61,
315,
788,
18,
14,
21,
297,
283,
18,
14,
22,
297,
283,
18,
14,
23,
2565,
272,
1499,
275,
283,
3849,
26,
3330,
18,
647,
5074,
2018,
499,
14,
21,
12,
499,
14,
22,
503,
499,
14,
23,
1325,
1265,
787,
3879,
3427,
78,
5,
83,
7,
272,
1499,
275,
1499,
450,
984,
14,
1023,
272,
984,
14,
3083,
14,
952,
8,
1328,
9,
199,
199,
2921,
275,
2050,
14,
5572,
480,
2520,
18,
647,
531,
421,
199,
318,
1255,
63,
2253,
63,
2219,
8,
1419,
304,
272,
408,
272,
23773,
2882,
83,
367,
26752,
14,
2219,
272,
408,
272,
492,
3873,
272,
12160,
63,
1023,
275,
984,
14,
1023,
63,
815,
59,
16,
61,
272,
12612,
63,
1023,
275,
984,
14,
1023,
63,
815,
59,
17,
61,
272,
340,
12160,
63,
1023,
508,
499,
26,
267,
340,
12612,
63,
1023,
315,
334,
21,
12,
1227,
304,
288,
984,
14,
3083,
14,
952,
480,
4718,
499,
14,
21,
503,
499,
14,
22,
60,
78,
531,
288,
2203,
275,
3873,
14,
1250,
2941,
3248,
18,
297,
2475,
86,
297,
283,
3528,
21615,
14,
2219,
1105,
267,
916,
12612,
63,
1023,
315,
334,
23,
16095,
288,
1240,
63,
589,
275,
359,
1274,
14,
5904,
12,
2475,
77,
297,
283,
2796,
297,
2475,
86,
297,
283,
3528,
21615,
14,
2219,
418,
288,
340,
1511,
14,
1045,
63,
10828,
26,
355,
862,
26,
490,
492,
11745,
490,
11745,
63,
888,
275,
747,
14,
2314,
14,
362,
8,
717,
298,
19052,
2962,
63,
10494,
63,
7363,
401,
717,
747,
14,
515,
14,
904,
360,
3528,
21615,
297,
283,
2219,
297,
283,
10828,
14,
2730,
1333,
4951,
1240,
63,
589,
275,
788,
10828,
297,
283,
1065,
297,
2850,
1195,
493,
2458,
83,
7,
450,
639,
11745,
63,
888,
12,
639,
2475,
77,
297,
283,
2796,
297,
2475,
86,
297,
283,
3528,
21615,
14,
2219,
418,
355,
871,
26,
490,
984,
14,
3083,
14,
952,
360,
27444,
1990,
440,
4903,
12,
16068,
60,
78,
358,
288,
984,
14,
3083,
14,
952,
480,
4718,
499,
14,
23,
60,
78,
531,
288,
2203,
275,
3873,
14,
1250,
8,
1250,
63,
589,
9,
267,
587,
26,
288,
984,
14,
3083,
14,
952,
480,
5187,
2366,
499,
14,
88,
1015,
60,
78,
531,
288,
2203,
275,
7633,
272,
587,
26,
267,
984,
14,
3083,
14,
952,
480,
5903,
2018,
499,
14,
88,
3748,
3134,
78,
531,
267,
2203,
275,
7633,
272,
984,
14,
2224,
8,
3292,
436,
413,
9,
421,
199,
533,
5004,
8,
785,
304,
272,
408,
257,
408,
339,
347,
636,
826,
721,
277,
304,
267,
408,
257,
408,
398,
291,
14,
2738,
275,
15073,
14,
6424,
342,
339,
347,
2218,
8,
277,
12,
666,
304,
267,
408,
257,
408,
398,
984,
855,
2703,
4343,
952,
8,
576,
9,
267,
340,
2688,
8,
277,
12,
283,
3058,
735,
288,
291,
14,
3058,
8,
576,
9,
267,
587,
26,
288,
291,
14,
2738,
14,
952,
8,
576,
9,
421,
199,
318,
664,
63,
633,
8,
1102,
12,
931,
25412,
4104,
534,
1014,
297,
1844,
29,
1257,
304,
272,
340,
10871,
315,
1591,
26,
267,
1591,
275,
30423,
83,
6616,
450,
1591,
272,
587,
26,
267,
1591,
275,
1591,
14,
1814,
360,
16,
14,
16,
14,
16,
14,
16,
297,
283,
4195,
14,
16,
14,
16,
14,
17,
358,
272,
340,
931,
14,
2460,
18265,
267,
931,
275,
931,
59,
17,
2938,
272,
340,
4104,
14,
4130,
6176,
735,
267,
4104,
275,
4104,
4439,
17,
61,
272,
340,
440,
1844,
503,
1844,
508,
5939,
26,
267,
1844,
275,
2125,
272,
587,
26,
267,
1844,
275,
283,
2689,
83,
7,
450,
1844,
272,
372,
1543,
83,
13827,
83,
5,
83,
3149,
83,
7,
450,
334,
2625,
12,
1591,
12,
1844,
12,
931,
9,
421,
199,
318,
1343,
63,
5750,
8,
633,
12,
14210,
29,
797,
304,
272,
340,
14210,
26,
267,
870,
283,
27567,
5684,
4881,
267,
870,
1557,
84,
297,
1166,
267,
870,
283,
15769,
7042,
13698,
272,
862,
26,
267,
492,
781,
29063,
267,
781,
29063,
14,
1490,
8,
633,
9,
272,
871,
26,
267,
870,
283,
3764,
26,
17329,
370,
9696,
2195,
7042,
7,
421,
199,
533,
3330,
18,
647,
5619,
8,
785,
304,
272,
408,
11298,
4353,
9592,
408,
339,
347,
636,
826,
721,
277,
12,
1738,
12,
1511,
304,
267,
408,
3330,
18,
647,
5619,
3787,
221,
408,
398
] |
[
2647,
15,
1393,
15,
1813,
2366,
199,
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
199,
624,
199,
92,
961,
570,
365,
1777,
402,
314,
3330,
18,
647,
6001,
22545,
199,
92,
11247,
31816,
471,
701,
603,
2608,
573,
3757,
510,
4446,
293,
665,
20208,
1038,
281,
293,
32,
1259,
14,
271,
387,
348,
14,
8654,
30,
199,
92,
844,
26,
491,
28863,
19,
334,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
15,
9783,
1168,
14,
1360,
9,
199,
199,
1918,
3938,
365,
2797,
687,
3330,
18,
647,
199,
1444,
306,
199,
624,
199,
199,
646,
2197,
199,
646,
984,
199,
646,
15073,
199,
646,
900,
199,
646,
2462,
199,
646,
5796,
199,
646,
747,
199,
646,
2838,
199,
646,
4673,
199,
646,
3473,
199,
646,
2050,
199,
646,
892,
14829,
199,
646,
18354,
199,
646,
26752,
14,
973,
465,
2446,
199,
199,
504,
26752,
14,
493,
1208,
492,
1586,
63,
493,
12,
2218,
63,
493,
12,
1218,
63,
28508,
63,
87,
18,
80,
199,
504,
26752,
14,
1751,
492,
2288,
63,
1751,
199,
504,
26752,
14,
5641,
492,
1255,
12,
511,
199,
504,
26752,
14,
1208,
492,
365,
63,
1078,
63,
711,
63,
1562,
12,
365,
63,
23983,
63,
711,
63,
1562,
12,
2312,
8996,
2697,
815,
421,
199,
9184,
985,
275,
283,
2520,
18,
647,
6001,
22545,
7,
199,
9184,
5949,
275,
283,
10502,
701,
603,
2608,
573,
3757,
510,
4446,
293,
12,
1898,
10219,
15668,
435,
620,
8,
272,
2197,
14,
2083,
14,
2131,
1252,
3403,
9,
199,
9184,
3353,
275,
1586,
63,
493,
360,
4612,
1959,
1913,
342,
199,
199,
9184,
2354,
275,
1449,
5,
83,
326,
450,
83,
326,
450,
83,
2344,
450,
334,
9184,
985,
12,
18841,
5949,
12,
18841,
3353,
9,
199,
199,
692,
440,
984,
14,
1023,
1491,
19,
61,
315,
788,
18,
14,
21,
297,
283,
18,
14,
22,
297,
283,
18,
14,
23,
2565,
272,
1499,
275,
283,
3849,
26,
3330,
18,
647,
5074,
2018,
499,
14,
21,
12,
499,
14,
22,
503,
499,
14,
23,
1325,
1265,
787,
3879,
3427,
78,
5,
83,
7,
272,
1499,
275,
1499,
450,
984,
14,
1023,
272,
984,
14,
3083,
14,
952,
8,
1328,
9,
199,
199,
2921,
275,
2050,
14,
5572,
480,
2520,
18,
647,
531,
421,
199,
318,
1255,
63,
2253,
63,
2219,
8,
1419,
304,
272,
408,
272,
23773,
2882,
83,
367,
26752,
14,
2219,
272,
408,
272,
492,
3873,
272,
12160,
63,
1023,
275,
984,
14,
1023,
63,
815,
59,
16,
61,
272,
12612,
63,
1023,
275,
984,
14,
1023,
63,
815,
59,
17,
61,
272,
340,
12160,
63,
1023,
508,
499,
26,
267,
340,
12612,
63,
1023,
315,
334,
21,
12,
1227,
304,
288,
984,
14,
3083,
14,
952,
480,
4718,
499,
14,
21,
503,
499,
14,
22,
60,
78,
531,
288,
2203,
275,
3873,
14,
1250,
2941,
3248,
18,
297,
2475,
86,
297,
283,
3528,
21615,
14,
2219,
1105,
267,
916,
12612,
63,
1023,
315,
334,
23,
16095,
288,
1240,
63,
589,
275,
359,
1274,
14,
5904,
12,
2475,
77,
297,
283,
2796,
297,
2475,
86,
297,
283,
3528,
21615,
14,
2219,
418,
288,
340,
1511,
14,
1045,
63,
10828,
26,
355,
862,
26,
490,
492,
11745,
490,
11745,
63,
888,
275,
747,
14,
2314,
14,
362,
8,
717,
298,
19052,
2962,
63,
10494,
63,
7363,
401,
717,
747,
14,
515,
14,
904,
360,
3528,
21615,
297,
283,
2219,
297,
283,
10828,
14,
2730,
1333,
4951,
1240,
63,
589,
275,
788,
10828,
297,
283,
1065,
297,
2850,
1195,
493,
2458,
83,
7,
450,
639,
11745,
63,
888,
12,
639,
2475,
77,
297,
283,
2796,
297,
2475,
86,
297,
283,
3528,
21615,
14,
2219,
418,
355,
871,
26,
490,
984,
14,
3083,
14,
952,
360,
27444,
1990,
440,
4903,
12,
16068,
60,
78,
358,
288,
984,
14,
3083,
14,
952,
480,
4718,
499,
14,
23,
60,
78,
531,
288,
2203,
275,
3873,
14,
1250,
8,
1250,
63,
589,
9,
267,
587,
26,
288,
984,
14,
3083,
14,
952,
480,
5187,
2366,
499,
14,
88,
1015,
60,
78,
531,
288,
2203,
275,
7633,
272,
587,
26,
267,
984,
14,
3083,
14,
952,
480,
5903,
2018,
499,
14,
88,
3748,
3134,
78,
531,
267,
2203,
275,
7633,
272,
984,
14,
2224,
8,
3292,
436,
413,
9,
421,
199,
533,
5004,
8,
785,
304,
272,
408,
257,
408,
339,
347,
636,
826,
721,
277,
304,
267,
408,
257,
408,
398,
291,
14,
2738,
275,
15073,
14,
6424,
342,
339,
347,
2218,
8,
277,
12,
666,
304,
267,
408,
257,
408,
398,
984,
855,
2703,
4343,
952,
8,
576,
9,
267,
340,
2688,
8,
277,
12,
283,
3058,
735,
288,
291,
14,
3058,
8,
576,
9,
267,
587,
26,
288,
291,
14,
2738,
14,
952,
8,
576,
9,
421,
199,
318,
664,
63,
633,
8,
1102,
12,
931,
25412,
4104,
534,
1014,
297,
1844,
29,
1257,
304,
272,
340,
10871,
315,
1591,
26,
267,
1591,
275,
30423,
83,
6616,
450,
1591,
272,
587,
26,
267,
1591,
275,
1591,
14,
1814,
360,
16,
14,
16,
14,
16,
14,
16,
297,
283,
4195,
14,
16,
14,
16,
14,
17,
358,
272,
340,
931,
14,
2460,
18265,
267,
931,
275,
931,
59,
17,
2938,
272,
340,
4104,
14,
4130,
6176,
735,
267,
4104,
275,
4104,
4439,
17,
61,
272,
340,
440,
1844,
503,
1844,
508,
5939,
26,
267,
1844,
275,
2125,
272,
587,
26,
267,
1844,
275,
283,
2689,
83,
7,
450,
1844,
272,
372,
1543,
83,
13827,
83,
5,
83,
3149,
83,
7,
450,
334,
2625,
12,
1591,
12,
1844,
12,
931,
9,
421,
199,
318,
1343,
63,
5750,
8,
633,
12,
14210,
29,
797,
304,
272,
340,
14210,
26,
267,
870,
283,
27567,
5684,
4881,
267,
870,
1557,
84,
297,
1166,
267,
870,
283,
15769,
7042,
13698,
272,
862,
26,
267,
492,
781,
29063,
267,
781,
29063,
14,
1490,
8,
633,
9,
272,
871,
26,
267,
870,
283,
3764,
26,
17329,
370,
9696,
2195,
7042,
7,
421,
199,
533,
3330,
18,
647,
5619,
8,
785,
304,
272,
408,
11298,
4353,
9592,
408,
339,
347,
636,
826,
721,
277,
12,
1738,
12,
1511,
304,
267,
408,
3330,
18,
647,
5619,
3787,
221,
408,
398,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
alexgulida/cloudapp-mp2
|
internal_use/CourseraSubmission.py
|
61
|
5689
|
#! /usr/bin/env python -u
# coding=utf-8
__author__ = 'Sayed Hadi Hashemi'
import json
import urllib
import urllib2
import hashlib
import email
import email.message
import email.encoders
class CourseraSubmission(object):
def __init__(self, **kwargs):
self.email = ""
self.password = ""
self.course_id = ""
self.part_ids = []
self.part_names = []
self.__dict__.update(kwargs)
def _login_prompt(self):
"""Prompt the user for login credentials. Returns a tuple (login, password)."""
(login, password) = self._basic_prompt()
return login, password
@staticmethod
def _basic_prompt():
"""Prompt the user for login credentials. Returns a tuple (login, password)."""
login = raw_input('Login (Email address): ')
password = raw_input('One-time Password (from the assignment page. This is NOT your own account\'s password): ')
return login, password
def _auth_get_challenge(self, sid):
"""Gets the challenge salt from the server. Returns (email,ch,state,ch_aux)."""
url = self._auth_get_challenge_url()
values = {'email_address': self.email, 'assignment_part_sid': sid, 'response_encoding': 'delim'}
data = urllib.urlencode(values)
req = urllib2.Request(url, data)
response = urllib2.urlopen(req)
text = response.read().strip()
# text is of the form email|ch|signature
splits = text.split('|')
if len(splits) != 9:
print 'Badly formatted challenge response: %s' % text
return None
return splits[2], splits[4], splits[6], splits[8]
def _auth_challenge_response(self, challenge):
sha1 = hashlib.sha1()
sha1.update("".join([challenge, self.password])) # hash the first elements
digest = sha1.hexdigest()
str_answer = ''
for i in range(0, len(digest)):
str_answer = str_answer + digest[i]
return str_answer
def _auth_get_challenge_url(self):
"""Returns the challenge url."""
return "https://class.coursera.org/" + self.course_id + "/assignment/challenge"
def _get_submission_url(self):
"""Returns the submission url."""
return "https://class.coursera.org/" + self.course_id + "/assignment/submit"
def _submit_solution(self, ch_resp, sid, output, source, state, ch_aux):
"""Submits a solution to the server. Returns (result, string)."""
source_64_msg = email.message.Message()
source_64_msg.set_payload(source)
email.encoders.encode_base64(source_64_msg)
output_64_msg = email.message.Message()
output_64_msg.set_payload(output)
email.encoders.encode_base64(output_64_msg)
values = {'assignment_part_sid': sid,
'email_address': self.email,
'submission': output_64_msg.get_payload(),
'submission_aux': source_64_msg.get_payload(),
'challenge_response': ch_resp,
'state': state
}
url = self._get_submission_url()
data = urllib.urlencode(values)
req = urllib2.Request(url, data)
response = urllib2.urlopen(req)
string = response.read().strip()
result = 0
return result, string
@staticmethod
def get_file_content(file_name):
with open(file_name, "r") as fp:
return fp.read()
def submit(self):
print '\n== Connecting to Coursera ... '
for part_index, part_id in enumerate(self.part_ids):
ret = self._auth_get_challenge(part_id)
if not ret:
print '\n!! Error: %s\n' % self.email
return False
(login, ch, state, ch_aux) = ret
if (not self.email) or (not ch) or (not state):
print '\n!! Error: %s\n' % self.email
return
ch_resp = self._auth_challenge_response(ch)
(result, string) = self._submit_solution(ch_resp, part_id, self.output(part_index), self.aux(part_index),
state, ch_aux)
print '== (%s) %s' % (self.part_names[part_index], string.strip())
if "We could not verify your username / password" in string:
return False
return True
def aux(self, part_index):
return json.dumps({})
def output(self, part_index):
pass
def run(self):
pass
def init(self):
print '==\n== [sandbox] Submitting Solutions \n=='
(self.email, self.password) = self._login_prompt()
if not self.email:
print '!! Submission Cancelled'
return False
if len(self.part_ids) > 0:
sid = self.part_ids[0]
ret = self._auth_get_challenge(sid)
if not ret:
print '\n!! Error: %s\n' % self.email
return False
(login, ch, state, ch_aux) = ret
if (not login) or (not ch) or (not state):
print '\n!! Error: %s\n' % login
return False
else:
return False
return True
def make_sumbission(self):
if self.init():
self.run()
while not self.submit():
ret = raw_input('Try Again? (Y/N)')
if len(ret.strip()) > 0 and ret.strip().lower()[0] == 'y':
self.password = raw_input(
'One-time Password (from the assignment page. This is NOT your own account\'s password): ')
else:
break
|
apache-2.0
|
[
3168,
1182,
2647,
15,
1393,
15,
1813,
2366,
446,
85,
199,
3,
2803,
29,
1624,
13,
24,
199,
199,
363,
2502,
363,
275,
283,
51,
1187,
379,
869,
65,
328,
13481,
426,
2664,
7,
199,
199,
646,
2022,
199,
646,
4011,
199,
646,
4011,
18,
199,
646,
8337,
199,
646,
3031,
199,
646,
3031,
14,
1188,
199,
646,
3031,
14,
9347,
83,
421,
199,
533,
445,
567,
332,
65,
2610,
2250,
8,
785,
304,
272,
347,
636,
826,
721,
277,
12,
1011,
958,
304,
267,
291,
14,
2123,
275,
3087,
267,
291,
14,
2060,
275,
3087,
267,
291,
14,
1972,
63,
344,
275,
3087,
267,
291,
14,
2064,
63,
1580,
275,
942,
267,
291,
14,
2064,
63,
1247,
275,
942,
398,
291,
855,
807,
4343,
873,
8,
958,
9,
339,
347,
485,
2886,
63,
7650,
8,
277,
304,
267,
408,
20430,
314,
922,
367,
4676,
6235,
14,
1803,
282,
2008,
334,
2886,
12,
2505,
10477,
267,
334,
2886,
12,
2505,
9,
275,
291,
423,
4316,
63,
7650,
342,
267,
372,
4676,
12,
2505,
339,
768,
4639,
272,
347,
485,
4316,
63,
7650,
837,
267,
408,
20430,
314,
922,
367,
4676,
6235,
14,
1803,
282,
2008,
334,
2886,
12,
2505,
10477,
267,
4676,
275,
3066,
63,
1210,
360,
8880,
334,
7035,
2287,
304,
5320,
267,
2505,
275,
3066,
63,
1210,
360,
4395,
13,
521,
13635,
334,
504,
314,
9801,
2034,
14,
961,
365,
2845,
2195,
5705,
2933,
3985,
83,
2505,
304,
5320,
267,
372,
4676,
12,
2505,
339,
347,
485,
1178,
63,
362,
63,
13911,
8,
277,
12,
15764,
304,
267,
408,
14426,
314,
14929,
10105,
687,
314,
1654,
14,
1803,
334,
2123,
12,
335,
12,
929,
12,
335,
63,
10962,
10477,
267,
1166,
275,
291,
423,
1178,
63,
362,
63,
13911,
63,
633,
342,
267,
1338,
275,
791,
2123,
63,
1562,
356,
291,
14,
2123,
12,
283,
10861,
63,
2064,
63,
4148,
356,
15764,
12,
283,
1310,
63,
2991,
356,
283,
15966,
936,
267,
666,
275,
4011,
14,
10738,
8,
1459,
9,
267,
2648,
275,
4011,
18,
14,
2017,
8,
633,
12,
666,
9,
267,
1177,
275,
4011,
18,
14,
10890,
8,
2103,
9,
267,
1318,
275,
1177,
14,
739,
1252,
1913,
342,
398,
327,
1318,
365,
402,
314,
1824,
3031,
92,
335,
92,
5233,
267,
19115,
275,
1318,
14,
1294,
20137,
358,
267,
340,
822,
8,
16508,
9,
1137,
1749,
26,
288,
870,
283,
5725,
590,
7871,
14929,
1177,
26,
450,
83,
7,
450,
1318,
288,
372,
488,
267,
372,
19115,
59,
18,
467,
19115,
59,
20,
467,
19115,
59,
22,
467,
19115,
59,
24,
61,
339,
347,
485,
1178,
63,
13911,
63,
1310,
8,
277,
12,
14929,
304,
267,
7793,
17,
275,
8337,
14,
4835,
17,
342,
267,
7793,
17,
14,
873,
31059,
904,
779,
13911,
12,
291,
14,
2060,
2459,
221,
327,
2631,
314,
1642,
4008,
267,
10017,
275,
7793,
17,
14,
11453,
342,
267,
620,
63,
5934,
275,
2125,
267,
367,
284,
315,
1425,
8,
16,
12,
822,
8,
5671,
2298,
288,
620,
63,
5934,
275,
620,
63,
5934,
435,
10017,
59,
73,
61,
267,
372,
620,
63,
5934,
339,
347,
485,
1178,
63,
362,
63,
13911,
63,
633,
8,
277,
304,
267,
408,
3407,
314,
14929,
1166,
1041,
267,
372,
298,
2859,
921,
533,
14,
25715,
332,
65,
14,
1308,
6687,
435,
291,
14,
1972,
63,
344,
435,
3286,
10861,
15,
13911,
2,
339,
347,
485,
362,
63,
12542,
63,
633,
8,
277,
304,
267,
408,
3407,
314,
13071,
1166,
1041,
267,
372,
298,
2859,
921,
533,
14,
25715,
332,
65,
14,
1308,
6687,
435,
291,
14,
1972,
63,
344,
435,
3286,
10861,
15,
7275,
2,
339,
347,
485,
7275,
63,
14458,
8,
277,
12,
682,
63,
4518,
12,
15764,
12,
1072,
12,
1350,
12,
1174,
12,
682,
63,
10962,
304,
267,
408,
17187,
83,
282,
8744,
370,
314,
1654,
14,
1803,
334,
1099,
12,
1059,
10477,
267,
1350,
63,
772,
63,
1328,
275,
3031,
14,
1188,
14,
2209,
342,
267,
1350,
63,
772,
63,
1328,
14,
409,
63,
4749,
8,
1365,
9,
267,
3031,
14,
9347,
83,
14,
2143,
63,
1095,
772,
8,
1365,
63,
772,
63,
1328,
9,
398,
1072,
63,
772,
63,
1328,
275,
3031,
14,
1188,
14,
2209,
342,
267,
1072,
63,
772,
63,
1328,
14,
409,
63,
4749,
8,
1199,
9,
267,
3031,
14,
9347,
83,
14,
2143,
63,
1095,
772,
8,
1199,
63,
772,
63,
1328,
9,
267,
1338,
275,
791,
10861,
63,
2064,
63,
4148,
356,
15764,
12,
2116,
283,
2123,
63,
1562,
356,
291,
14,
2123,
12,
2116,
283,
12542,
356,
1072,
63,
772,
63,
1328,
14,
362,
63,
4749,
1062,
2116,
283,
12542,
63,
10962,
356,
1350,
63,
772,
63,
1328,
14,
362,
63,
4749,
1062,
2116,
283,
13911,
63,
1310,
356,
682,
63,
4518,
12,
2116,
283,
929,
356,
1174,
2116,
789,
267,
1166,
275,
291,
423,
362,
63,
12542,
63,
633,
342,
267,
666,
275,
4011,
14,
10738,
8,
1459,
9,
267,
2648,
275,
4011,
18,
14,
2017,
8,
633,
12,
666,
9,
267,
1177,
275,
4011,
18,
14,
10890,
8,
2103,
9,
267,
1059,
275,
1177,
14,
739,
1252,
1913,
342,
267,
754,
275,
378,
267,
372,
754,
12,
1059,
339,
768,
4639,
272,
347,
664,
63,
493,
63,
1317,
8,
493,
63,
354,
304,
267,
543,
1551,
8,
493,
63,
354,
12,
298,
82,
531,
465,
4090,
26,
288,
372,
4090,
14,
739,
342,
339,
347,
11482,
8,
277,
304,
267,
870,
1557,
78,
389,
15175,
316,
370,
445,
567,
332,
65,
2263,
283,
267,
367,
1777,
63,
1080,
12,
1777,
63,
344,
315,
3874,
8,
277,
14,
2064,
63,
1580,
304,
288,
2203,
275,
291,
423,
1178,
63,
362,
63,
13911,
8,
2064,
63,
344,
9,
288,
340,
440,
2203,
26,
355,
870,
1557,
78,
3480,
4520,
26,
450,
83,
60,
78,
7,
450,
291,
14,
2123,
355,
372,
756,
953,
334,
2886,
12,
682,
12,
1174,
12,
682,
63,
10962,
9,
275,
2203,
288,
340,
334,
1397,
291,
14,
2123,
9,
503,
334,
1397,
682,
9,
503,
334,
1397,
1174,
304,
355,
870,
1557,
78,
3480,
4520,
26,
450,
83,
60,
78,
7,
450,
291,
14,
2123,
355,
372,
953,
682,
63,
4518,
275
] |
[
1182,
2647,
15,
1393,
15,
1813,
2366,
446,
85,
199,
3,
2803,
29,
1624,
13,
24,
199,
199,
363,
2502,
363,
275,
283,
51,
1187,
379,
869,
65,
328,
13481,
426,
2664,
7,
199,
199,
646,
2022,
199,
646,
4011,
199,
646,
4011,
18,
199,
646,
8337,
199,
646,
3031,
199,
646,
3031,
14,
1188,
199,
646,
3031,
14,
9347,
83,
421,
199,
533,
445,
567,
332,
65,
2610,
2250,
8,
785,
304,
272,
347,
636,
826,
721,
277,
12,
1011,
958,
304,
267,
291,
14,
2123,
275,
3087,
267,
291,
14,
2060,
275,
3087,
267,
291,
14,
1972,
63,
344,
275,
3087,
267,
291,
14,
2064,
63,
1580,
275,
942,
267,
291,
14,
2064,
63,
1247,
275,
942,
398,
291,
855,
807,
4343,
873,
8,
958,
9,
339,
347,
485,
2886,
63,
7650,
8,
277,
304,
267,
408,
20430,
314,
922,
367,
4676,
6235,
14,
1803,
282,
2008,
334,
2886,
12,
2505,
10477,
267,
334,
2886,
12,
2505,
9,
275,
291,
423,
4316,
63,
7650,
342,
267,
372,
4676,
12,
2505,
339,
768,
4639,
272,
347,
485,
4316,
63,
7650,
837,
267,
408,
20430,
314,
922,
367,
4676,
6235,
14,
1803,
282,
2008,
334,
2886,
12,
2505,
10477,
267,
4676,
275,
3066,
63,
1210,
360,
8880,
334,
7035,
2287,
304,
5320,
267,
2505,
275,
3066,
63,
1210,
360,
4395,
13,
521,
13635,
334,
504,
314,
9801,
2034,
14,
961,
365,
2845,
2195,
5705,
2933,
3985,
83,
2505,
304,
5320,
267,
372,
4676,
12,
2505,
339,
347,
485,
1178,
63,
362,
63,
13911,
8,
277,
12,
15764,
304,
267,
408,
14426,
314,
14929,
10105,
687,
314,
1654,
14,
1803,
334,
2123,
12,
335,
12,
929,
12,
335,
63,
10962,
10477,
267,
1166,
275,
291,
423,
1178,
63,
362,
63,
13911,
63,
633,
342,
267,
1338,
275,
791,
2123,
63,
1562,
356,
291,
14,
2123,
12,
283,
10861,
63,
2064,
63,
4148,
356,
15764,
12,
283,
1310,
63,
2991,
356,
283,
15966,
936,
267,
666,
275,
4011,
14,
10738,
8,
1459,
9,
267,
2648,
275,
4011,
18,
14,
2017,
8,
633,
12,
666,
9,
267,
1177,
275,
4011,
18,
14,
10890,
8,
2103,
9,
267,
1318,
275,
1177,
14,
739,
1252,
1913,
342,
398,
327,
1318,
365,
402,
314,
1824,
3031,
92,
335,
92,
5233,
267,
19115,
275,
1318,
14,
1294,
20137,
358,
267,
340,
822,
8,
16508,
9,
1137,
1749,
26,
288,
870,
283,
5725,
590,
7871,
14929,
1177,
26,
450,
83,
7,
450,
1318,
288,
372,
488,
267,
372,
19115,
59,
18,
467,
19115,
59,
20,
467,
19115,
59,
22,
467,
19115,
59,
24,
61,
339,
347,
485,
1178,
63,
13911,
63,
1310,
8,
277,
12,
14929,
304,
267,
7793,
17,
275,
8337,
14,
4835,
17,
342,
267,
7793,
17,
14,
873,
31059,
904,
779,
13911,
12,
291,
14,
2060,
2459,
221,
327,
2631,
314,
1642,
4008,
267,
10017,
275,
7793,
17,
14,
11453,
342,
267,
620,
63,
5934,
275,
2125,
267,
367,
284,
315,
1425,
8,
16,
12,
822,
8,
5671,
2298,
288,
620,
63,
5934,
275,
620,
63,
5934,
435,
10017,
59,
73,
61,
267,
372,
620,
63,
5934,
339,
347,
485,
1178,
63,
362,
63,
13911,
63,
633,
8,
277,
304,
267,
408,
3407,
314,
14929,
1166,
1041,
267,
372,
298,
2859,
921,
533,
14,
25715,
332,
65,
14,
1308,
6687,
435,
291,
14,
1972,
63,
344,
435,
3286,
10861,
15,
13911,
2,
339,
347,
485,
362,
63,
12542,
63,
633,
8,
277,
304,
267,
408,
3407,
314,
13071,
1166,
1041,
267,
372,
298,
2859,
921,
533,
14,
25715,
332,
65,
14,
1308,
6687,
435,
291,
14,
1972,
63,
344,
435,
3286,
10861,
15,
7275,
2,
339,
347,
485,
7275,
63,
14458,
8,
277,
12,
682,
63,
4518,
12,
15764,
12,
1072,
12,
1350,
12,
1174,
12,
682,
63,
10962,
304,
267,
408,
17187,
83,
282,
8744,
370,
314,
1654,
14,
1803,
334,
1099,
12,
1059,
10477,
267,
1350,
63,
772,
63,
1328,
275,
3031,
14,
1188,
14,
2209,
342,
267,
1350,
63,
772,
63,
1328,
14,
409,
63,
4749,
8,
1365,
9,
267,
3031,
14,
9347,
83,
14,
2143,
63,
1095,
772,
8,
1365,
63,
772,
63,
1328,
9,
398,
1072,
63,
772,
63,
1328,
275,
3031,
14,
1188,
14,
2209,
342,
267,
1072,
63,
772,
63,
1328,
14,
409,
63,
4749,
8,
1199,
9,
267,
3031,
14,
9347,
83,
14,
2143,
63,
1095,
772,
8,
1199,
63,
772,
63,
1328,
9,
267,
1338,
275,
791,
10861,
63,
2064,
63,
4148,
356,
15764,
12,
2116,
283,
2123,
63,
1562,
356,
291,
14,
2123,
12,
2116,
283,
12542,
356,
1072,
63,
772,
63,
1328,
14,
362,
63,
4749,
1062,
2116,
283,
12542,
63,
10962,
356,
1350,
63,
772,
63,
1328,
14,
362,
63,
4749,
1062,
2116,
283,
13911,
63,
1310,
356,
682,
63,
4518,
12,
2116,
283,
929,
356,
1174,
2116,
789,
267,
1166,
275,
291,
423,
362,
63,
12542,
63,
633,
342,
267,
666,
275,
4011,
14,
10738,
8,
1459,
9,
267,
2648,
275,
4011,
18,
14,
2017,
8,
633,
12,
666,
9,
267,
1177,
275,
4011,
18,
14,
10890,
8,
2103,
9,
267,
1059,
275,
1177,
14,
739,
1252,
1913,
342,
267,
754,
275,
378,
267,
372,
754,
12,
1059,
339,
768,
4639,
272,
347,
664,
63,
493,
63,
1317,
8,
493,
63,
354,
304,
267,
543,
1551,
8,
493,
63,
354,
12,
298,
82,
531,
465,
4090,
26,
288,
372,
4090,
14,
739,
342,
339,
347,
11482,
8,
277,
304,
267,
870,
1557,
78,
389,
15175,
316,
370,
445,
567,
332,
65,
2263,
283,
267,
367,
1777,
63,
1080,
12,
1777,
63,
344,
315,
3874,
8,
277,
14,
2064,
63,
1580,
304,
288,
2203,
275,
291,
423,
1178,
63,
362,
63,
13911,
8,
2064,
63,
344,
9,
288,
340,
440,
2203,
26,
355,
870,
1557,
78,
3480,
4520,
26,
450,
83,
60,
78,
7,
450,
291,
14,
2123,
355,
372,
756,
953,
334,
2886,
12,
682,
12,
1174,
12,
682,
63,
10962,
9,
275,
2203,
288,
340,
334,
1397,
291,
14,
2123,
9,
503,
334,
1397,
682,
9,
503,
334,
1397,
1174,
304,
355,
870,
1557,
78,
3480,
4520,
26,
450,
83,
60,
78,
7,
450,
291,
14,
2123,
355,
372,
953,
682,
63,
4518,
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,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moen', # 0x00
'moenj', # 0x01
'moenh', # 0x02
'moed', # 0x03
'moel', # 0x04
'moelg', # 0x05
'moelm', # 0x06
'moelb', # 0x07
'moels', # 0x08
'moelt', # 0x09
'moelp', # 0x0a
'moelh', # 0x0b
'moem', # 0x0c
'moeb', # 0x0d
'moebs', # 0x0e
'moes', # 0x0f
'moess', # 0x10
'moeng', # 0x11
'moej', # 0x12
'moec', # 0x13
'moek', # 0x14
'moet', # 0x15
'moep', # 0x16
'moeh', # 0x17
'myo', # 0x18
'myog', # 0x19
'myogg', # 0x1a
'myogs', # 0x1b
'myon', # 0x1c
'myonj', # 0x1d
'myonh', # 0x1e
'myod', # 0x1f
'myol', # 0x20
'myolg', # 0x21
'myolm', # 0x22
'myolb', # 0x23
'myols', # 0x24
'myolt', # 0x25
'myolp', # 0x26
'myolh', # 0x27
'myom', # 0x28
'myob', # 0x29
'myobs', # 0x2a
'myos', # 0x2b
'myoss', # 0x2c
'myong', # 0x2d
'myoj', # 0x2e
'myoc', # 0x2f
'myok', # 0x30
'myot', # 0x31
'myop', # 0x32
'myoh', # 0x33
'mu', # 0x34
'mug', # 0x35
'mugg', # 0x36
'mugs', # 0x37
'mun', # 0x38
'munj', # 0x39
'munh', # 0x3a
'mud', # 0x3b
'mul', # 0x3c
'mulg', # 0x3d
'mulm', # 0x3e
'mulb', # 0x3f
'muls', # 0x40
'mult', # 0x41
'mulp', # 0x42
'mulh', # 0x43
'mum', # 0x44
'mub', # 0x45
'mubs', # 0x46
'mus', # 0x47
'muss', # 0x48
'mung', # 0x49
'muj', # 0x4a
'muc', # 0x4b
'muk', # 0x4c
'mut', # 0x4d
'mup', # 0x4e
'muh', # 0x4f
'mweo', # 0x50
'mweog', # 0x51
'mweogg', # 0x52
'mweogs', # 0x53
'mweon', # 0x54
'mweonj', # 0x55
'mweonh', # 0x56
'mweod', # 0x57
'mweol', # 0x58
'mweolg', # 0x59
'mweolm', # 0x5a
'mweolb', # 0x5b
'mweols', # 0x5c
'mweolt', # 0x5d
'mweolp', # 0x5e
'mweolh', # 0x5f
'mweom', # 0x60
'mweob', # 0x61
'mweobs', # 0x62
'mweos', # 0x63
'mweoss', # 0x64
'mweong', # 0x65
'mweoj', # 0x66
'mweoc', # 0x67
'mweok', # 0x68
'mweot', # 0x69
'mweop', # 0x6a
'mweoh', # 0x6b
'mwe', # 0x6c
'mweg', # 0x6d
'mwegg', # 0x6e
'mwegs', # 0x6f
'mwen', # 0x70
'mwenj', # 0x71
'mwenh', # 0x72
'mwed', # 0x73
'mwel', # 0x74
'mwelg', # 0x75
'mwelm', # 0x76
'mwelb', # 0x77
'mwels', # 0x78
'mwelt', # 0x79
'mwelp', # 0x7a
'mwelh', # 0x7b
'mwem', # 0x7c
'mweb', # 0x7d
'mwebs', # 0x7e
'mwes', # 0x7f
'mwess', # 0x80
'mweng', # 0x81
'mwej', # 0x82
'mwec', # 0x83
'mwek', # 0x84
'mwet', # 0x85
'mwep', # 0x86
'mweh', # 0x87
'mwi', # 0x88
'mwig', # 0x89
'mwigg', # 0x8a
'mwigs', # 0x8b
'mwin', # 0x8c
'mwinj', # 0x8d
'mwinh', # 0x8e
'mwid', # 0x8f
'mwil', # 0x90
'mwilg', # 0x91
'mwilm', # 0x92
'mwilb', # 0x93
'mwils', # 0x94
'mwilt', # 0x95
'mwilp', # 0x96
'mwilh', # 0x97
'mwim', # 0x98
'mwib', # 0x99
'mwibs', # 0x9a
'mwis', # 0x9b
'mwiss', # 0x9c
'mwing', # 0x9d
'mwij', # 0x9e
'mwic', # 0x9f
'mwik', # 0xa0
'mwit', # 0xa1
'mwip', # 0xa2
'mwih', # 0xa3
'myu', # 0xa4
'myug', # 0xa5
'myugg', # 0xa6
'myugs', # 0xa7
'myun', # 0xa8
'myunj', # 0xa9
'myunh', # 0xaa
'myud', # 0xab
'myul', # 0xac
'myulg', # 0xad
'myulm', # 0xae
'myulb', # 0xaf
'myuls', # 0xb0
'myult', # 0xb1
'myulp', # 0xb2
'myulh', # 0xb3
'myum', # 0xb4
'myub', # 0xb5
'myubs', # 0xb6
'myus', # 0xb7
'myuss', # 0xb8
'myung', # 0xb9
'myuj', # 0xba
'myuc', # 0xbb
'myuk', # 0xbc
'myut', # 0xbd
'myup', # 0xbe
'myuh', # 0xbf
'meu', # 0xc0
'meug', # 0xc1
'meugg', # 0xc2
'meugs', # 0xc3
'meun', # 0xc4
'meunj', # 0xc5
'meunh', # 0xc6
'meud', # 0xc7
'meul', # 0xc8
'meulg', # 0xc9
'meulm', # 0xca
'meulb', # 0xcb
'meuls', # 0xcc
'meult', # 0xcd
'meulp', # 0xce
'meulh', # 0xcf
'meum', # 0xd0
'meub', # 0xd1
'meubs', # 0xd2
'meus', # 0xd3
'meuss', # 0xd4
'meung', # 0xd5
'meuj', # 0xd6
'meuc', # 0xd7
'meuk', # 0xd8
'meut', # 0xd9
'meup', # 0xda
'meuh', # 0xdb
'myi', # 0xdc
'myig', # 0xdd
'myigg', # 0xde
'myigs', # 0xdf
'myin', # 0xe0
'myinj', # 0xe1
'myinh', # 0xe2
'myid', # 0xe3
'myil', # 0xe4
'myilg', # 0xe5
'myilm', # 0xe6
'myilb', # 0xe7
'myils', # 0xe8
'myilt', # 0xe9
'myilp', # 0xea
'myilh', # 0xeb
'myim', # 0xec
'myib', # 0xed
'myibs', # 0xee
'myis', # 0xef
'myiss', # 0xf0
'mying', # 0xf1
'myij', # 0xf2
'myic', # 0xf3
'myik', # 0xf4
'myit', # 0xf5
'myip', # 0xf6
'myih', # 0xf7
'mi', # 0xf8
'mig', # 0xf9
'migg', # 0xfa
'migs', # 0xfb
'min', # 0xfc
'minj', # 0xfd
'minh', # 0xfe
'mid', # 0xff
)
|
gpl-2.0
|
[
576,
275,
334,
199,
6704,
79,
287,
297,
259,
327,
378,
88,
383,
199,
6704,
79,
287,
74,
297,
259,
327,
378,
88,
614,
199,
6704,
79,
287,
72,
297,
259,
327,
378,
88,
996,
199,
6704,
79,
379,
297,
259,
327,
378,
88,
1644,
199,
6704,
79,
352,
297,
259,
327,
378,
88,
966,
199,
6704,
79,
352,
71,
297,
259,
327,
378,
88,
1717,
199,
6704,
79,
21226,
297,
259,
327,
378,
88,
1690,
199,
6704,
79,
17778,
297,
259,
327,
378,
88,
1780,
199,
6704,
79,
18099,
297,
259,
327,
378,
88,
2036,
199,
6704,
79,
15330,
297,
259,
327,
378,
88,
1643,
199,
6704,
79,
1357,
297,
259,
327,
378,
88,
16,
65,
199,
6704,
79,
352,
72,
297,
259,
327,
378,
88,
16,
66,
199,
6704,
79,
5633,
297,
259,
327,
378,
88,
16,
67,
199,
6704,
79,
2871,
297,
259,
327,
378,
88,
16,
68,
199,
6704,
13361,
1533,
297,
259,
327,
378,
88,
16,
69,
199,
6704,
79,
397,
297,
259,
327,
378,
88,
16,
70,
199,
6704,
13361,
385,
297,
259,
327,
378,
88,
709,
199,
6704,
79,
7420,
297,
259,
327,
378,
88,
845,
199,
6704,
13361,
74,
297,
259,
327,
378,
88,
713,
199,
6704,
79,
825,
297,
259,
327,
378,
88,
969,
199,
6704,
79,
5711,
297,
259,
327,
378,
88,
1079,
199,
6704,
79,
386,
297,
259,
327,
378,
88,
1046,
199,
6704,
79,
1545,
297,
259,
327,
378,
88,
975,
199,
6704,
13361,
72,
297,
259,
327,
378,
88,
1196,
199,
6704,
16540,
297,
259,
327,
378,
88,
1085,
199,
6704,
89,
974,
297,
259,
327,
378,
88,
1167,
199,
6704,
89,
24798,
297,
259,
327,
378,
88,
17,
65,
199,
6704,
16540,
458,
297,
259,
327,
378,
88,
17,
66,
199,
6704,
89,
265,
297,
259,
327,
378,
88,
17,
67,
199,
6704,
89,
265,
74,
297,
259,
327,
378,
88,
17,
68,
199,
6704,
89,
265,
72,
297,
259,
327,
378,
88,
17,
69,
199,
6704,
89,
364,
297,
259,
327,
378,
88,
17,
70,
199,
6704,
89,
393,
297,
259,
327,
378,
88,
1165,
199,
6704,
89,
393,
71,
297,
259,
327,
378,
88,
2025,
199,
6704,
89,
393,
77,
297,
259,
327,
378,
88,
1081,
199,
6704,
89,
393,
66,
297,
259,
327,
378,
88,
1789,
199,
6704,
89,
1446,
297,
259,
327,
378,
88,
1194,
199,
6704,
89,
28934,
297,
259,
327,
378,
88,
821,
199,
6704,
89,
393,
80,
297,
259,
327,
378,
88,
1479,
199,
6704,
89,
393,
72,
297,
259,
327,
378,
88,
1465,
199,
6704,
89,
676,
297,
259,
327,
378,
88,
1651,
199,
6704,
89,
2873,
297,
259,
327,
378,
88,
1398,
199,
6704,
89,
11226,
297,
259,
327,
378,
88,
18,
65,
199,
6704,
89,
736,
297,
259,
327,
378,
88,
18,
66,
199,
6704,
16540,
385,
297,
259,
327,
378,
88,
18,
67,
199,
6704,
89,
951,
297,
259,
327,
378,
88,
18,
68,
199,
6704,
16540,
74,
297,
259,
327,
378,
88,
18,
69,
199,
6704,
89,
679,
297,
259,
327,
378,
88,
18,
70,
199,
6704,
89,
745,
297,
259,
327,
378,
88,
1216,
199,
6704,
89,
357,
297,
259,
327,
378,
88,
2192,
199,
6704,
89,
411,
297,
259,
327,
378,
88,
708,
199,
6704,
16540,
72,
297,
259,
327,
378,
88,
1153,
199,
6704,
85,
297,
259,
327,
378,
88,
1082,
199,
6704,
1518,
297,
259,
327,
378,
88,
1276,
199,
6704,
1518,
71,
297,
259,
327,
378,
88,
1344,
199,
6704,
85,
458,
297,
259,
327,
378,
88,
1401,
199,
6704,
324,
297,
259,
327,
378,
88,
1703,
199,
6704,
324,
74,
297,
259,
327,
378,
88,
1355,
199,
6704,
324,
72,
297,
259,
327,
378,
88,
19,
65,
199,
6704,
1181,
297,
259,
327,
378,
88,
19,
66,
199,
6704,
348,
297,
259,
327,
378,
88,
19,
67,
199,
6704,
27092,
297,
259,
327,
378,
88,
19,
68,
199,
6704,
348,
77,
297,
259,
327,
378,
88,
19,
69,
199,
6704,
348,
66,
297,
259,
327,
378,
88,
19,
70,
199,
6704,
348,
83,
297,
259,
327,
378,
88,
2167,
199,
6704,
427,
297,
259,
327,
378,
88,
2953,
199,
6704,
15513,
297,
259,
327,
378,
88,
2260,
199,
6704,
348,
72,
297,
259,
327,
378,
88,
2824,
199,
6704,
453,
297,
259,
327,
378,
88,
1602,
199,
6704,
456,
297,
259,
327,
378,
88,
2322,
199,
6704,
30327,
297,
259,
327,
378,
88,
2466,
199,
6704,
527,
297,
259,
327,
378,
88,
2417,
199,
6704,
27678,
297,
259,
327,
378,
88,
2006,
199,
6704,
10335,
297,
259,
327,
378,
88,
1887,
199,
6704,
17189,
297,
259,
327,
378,
88,
20,
65,
199,
6704,
947,
297,
259,
327,
378,
88,
20,
66,
199,
6704,
3210,
297,
259,
327,
378,
88,
20,
67,
199,
6704,
337,
297,
259,
327,
378,
88,
20,
68,
199,
6704,
384,
297,
259,
327,
378,
88,
20,
69,
199,
6704,
22451,
297,
259,
327,
378,
88,
20,
70,
199,
6704,
1129,
79,
297,
259,
327,
378,
88,
1400,
199,
6704,
1129,
974,
297,
259,
327,
378,
88,
2869,
199,
6704,
1129,
24798,
297,
259,
327,
378,
88,
2528,
199,
6704,
1129,
79,
458,
297,
259,
327,
378,
88,
2481,
199,
6704,
1129,
265,
297,
259,
327,
378,
88,
1477,
199,
6704,
1129,
265,
74,
297,
259,
327,
378,
88,
1229,
199,
6704,
1129,
265,
72,
297,
259,
327,
378,
88,
1367,
199,
6704,
1129,
364,
297,
259,
327,
378,
88,
1641,
199,
6704,
1129,
393,
297,
259,
327,
378,
88,
2010,
199,
6704,
1129,
393,
71,
297,
259,
327,
378,
88,
1427,
199,
6704,
1129,
393,
77,
297,
259,
327,
378,
88,
21,
65,
199,
6704,
1129,
393,
66,
297,
259,
327,
378,
88,
21,
66,
199,
6704,
1129,
1446,
297,
259,
327,
378,
88,
21,
67,
199,
6704,
1129,
28934,
297,
259,
327,
378,
88,
21,
68,
199,
6704,
1129,
393,
80,
297,
259,
327,
378,
88,
21,
69,
199,
6704,
1129,
393,
72,
297,
259,
327,
378,
88,
21,
70,
199,
6704,
1129,
676,
297,
259,
327,
378,
88,
2259,
199,
6704,
1129,
2873,
297,
259,
327,
378,
88,
2976,
199,
6704,
1129,
11226,
297,
259,
327
] |
[
275,
334,
199,
6704,
79,
287,
297,
259,
327,
378,
88,
383,
199,
6704,
79,
287,
74,
297,
259,
327,
378,
88,
614,
199,
6704,
79,
287,
72,
297,
259,
327,
378,
88,
996,
199,
6704,
79,
379,
297,
259,
327,
378,
88,
1644,
199,
6704,
79,
352,
297,
259,
327,
378,
88,
966,
199,
6704,
79,
352,
71,
297,
259,
327,
378,
88,
1717,
199,
6704,
79,
21226,
297,
259,
327,
378,
88,
1690,
199,
6704,
79,
17778,
297,
259,
327,
378,
88,
1780,
199,
6704,
79,
18099,
297,
259,
327,
378,
88,
2036,
199,
6704,
79,
15330,
297,
259,
327,
378,
88,
1643,
199,
6704,
79,
1357,
297,
259,
327,
378,
88,
16,
65,
199,
6704,
79,
352,
72,
297,
259,
327,
378,
88,
16,
66,
199,
6704,
79,
5633,
297,
259,
327,
378,
88,
16,
67,
199,
6704,
79,
2871,
297,
259,
327,
378,
88,
16,
68,
199,
6704,
13361,
1533,
297,
259,
327,
378,
88,
16,
69,
199,
6704,
79,
397,
297,
259,
327,
378,
88,
16,
70,
199,
6704,
13361,
385,
297,
259,
327,
378,
88,
709,
199,
6704,
79,
7420,
297,
259,
327,
378,
88,
845,
199,
6704,
13361,
74,
297,
259,
327,
378,
88,
713,
199,
6704,
79,
825,
297,
259,
327,
378,
88,
969,
199,
6704,
79,
5711,
297,
259,
327,
378,
88,
1079,
199,
6704,
79,
386,
297,
259,
327,
378,
88,
1046,
199,
6704,
79,
1545,
297,
259,
327,
378,
88,
975,
199,
6704,
13361,
72,
297,
259,
327,
378,
88,
1196,
199,
6704,
16540,
297,
259,
327,
378,
88,
1085,
199,
6704,
89,
974,
297,
259,
327,
378,
88,
1167,
199,
6704,
89,
24798,
297,
259,
327,
378,
88,
17,
65,
199,
6704,
16540,
458,
297,
259,
327,
378,
88,
17,
66,
199,
6704,
89,
265,
297,
259,
327,
378,
88,
17,
67,
199,
6704,
89,
265,
74,
297,
259,
327,
378,
88,
17,
68,
199,
6704,
89,
265,
72,
297,
259,
327,
378,
88,
17,
69,
199,
6704,
89,
364,
297,
259,
327,
378,
88,
17,
70,
199,
6704,
89,
393,
297,
259,
327,
378,
88,
1165,
199,
6704,
89,
393,
71,
297,
259,
327,
378,
88,
2025,
199,
6704,
89,
393,
77,
297,
259,
327,
378,
88,
1081,
199,
6704,
89,
393,
66,
297,
259,
327,
378,
88,
1789,
199,
6704,
89,
1446,
297,
259,
327,
378,
88,
1194,
199,
6704,
89,
28934,
297,
259,
327,
378,
88,
821,
199,
6704,
89,
393,
80,
297,
259,
327,
378,
88,
1479,
199,
6704,
89,
393,
72,
297,
259,
327,
378,
88,
1465,
199,
6704,
89,
676,
297,
259,
327,
378,
88,
1651,
199,
6704,
89,
2873,
297,
259,
327,
378,
88,
1398,
199,
6704,
89,
11226,
297,
259,
327,
378,
88,
18,
65,
199,
6704,
89,
736,
297,
259,
327,
378,
88,
18,
66,
199,
6704,
16540,
385,
297,
259,
327,
378,
88,
18,
67,
199,
6704,
89,
951,
297,
259,
327,
378,
88,
18,
68,
199,
6704,
16540,
74,
297,
259,
327,
378,
88,
18,
69,
199,
6704,
89,
679,
297,
259,
327,
378,
88,
18,
70,
199,
6704,
89,
745,
297,
259,
327,
378,
88,
1216,
199,
6704,
89,
357,
297,
259,
327,
378,
88,
2192,
199,
6704,
89,
411,
297,
259,
327,
378,
88,
708,
199,
6704,
16540,
72,
297,
259,
327,
378,
88,
1153,
199,
6704,
85,
297,
259,
327,
378,
88,
1082,
199,
6704,
1518,
297,
259,
327,
378,
88,
1276,
199,
6704,
1518,
71,
297,
259,
327,
378,
88,
1344,
199,
6704,
85,
458,
297,
259,
327,
378,
88,
1401,
199,
6704,
324,
297,
259,
327,
378,
88,
1703,
199,
6704,
324,
74,
297,
259,
327,
378,
88,
1355,
199,
6704,
324,
72,
297,
259,
327,
378,
88,
19,
65,
199,
6704,
1181,
297,
259,
327,
378,
88,
19,
66,
199,
6704,
348,
297,
259,
327,
378,
88,
19,
67,
199,
6704,
27092,
297,
259,
327,
378,
88,
19,
68,
199,
6704,
348,
77,
297,
259,
327,
378,
88,
19,
69,
199,
6704,
348,
66,
297,
259,
327,
378,
88,
19,
70,
199,
6704,
348,
83,
297,
259,
327,
378,
88,
2167,
199,
6704,
427,
297,
259,
327,
378,
88,
2953,
199,
6704,
15513,
297,
259,
327,
378,
88,
2260,
199,
6704,
348,
72,
297,
259,
327,
378,
88,
2824,
199,
6704,
453,
297,
259,
327,
378,
88,
1602,
199,
6704,
456,
297,
259,
327,
378,
88,
2322,
199,
6704,
30327,
297,
259,
327,
378,
88,
2466,
199,
6704,
527,
297,
259,
327,
378,
88,
2417,
199,
6704,
27678,
297,
259,
327,
378,
88,
2006,
199,
6704,
10335,
297,
259,
327,
378,
88,
1887,
199,
6704,
17189,
297,
259,
327,
378,
88,
20,
65,
199,
6704,
947,
297,
259,
327,
378,
88,
20,
66,
199,
6704,
3210,
297,
259,
327,
378,
88,
20,
67,
199,
6704,
337,
297,
259,
327,
378,
88,
20,
68,
199,
6704,
384,
297,
259,
327,
378,
88,
20,
69,
199,
6704,
22451,
297,
259,
327,
378,
88,
20,
70,
199,
6704,
1129,
79,
297,
259,
327,
378,
88,
1400,
199,
6704,
1129,
974,
297,
259,
327,
378,
88,
2869,
199,
6704,
1129,
24798,
297,
259,
327,
378,
88,
2528,
199,
6704,
1129,
79,
458,
297,
259,
327,
378,
88,
2481,
199,
6704,
1129,
265,
297,
259,
327,
378,
88,
1477,
199,
6704,
1129,
265,
74,
297,
259,
327,
378,
88,
1229,
199,
6704,
1129,
265,
72,
297,
259,
327,
378,
88,
1367,
199,
6704,
1129,
364,
297,
259,
327,
378,
88,
1641,
199,
6704,
1129,
393,
297,
259,
327,
378,
88,
2010,
199,
6704,
1129,
393,
71,
297,
259,
327,
378,
88,
1427,
199,
6704,
1129,
393,
77,
297,
259,
327,
378,
88,
21,
65,
199,
6704,
1129,
393,
66,
297,
259,
327,
378,
88,
21,
66,
199,
6704,
1129,
1446,
297,
259,
327,
378,
88,
21,
67,
199,
6704,
1129,
28934,
297,
259,
327,
378,
88,
21,
68,
199,
6704,
1129,
393,
80,
297,
259,
327,
378,
88,
21,
69,
199,
6704,
1129,
393,
72,
297,
259,
327,
378,
88,
21,
70,
199,
6704,
1129,
676,
297,
259,
327,
378,
88,
2259,
199,
6704,
1129,
2873,
297,
259,
327,
378,
88,
2976,
199,
6704,
1129,
11226,
297,
259,
327,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
alexmorozov/django
|
django/core/management/commands/loaddata.py
|
13
|
13333
|
from __future__ import unicode_literals
import glob
import gzip
import os
import warnings
import zipfile
from itertools import product
from django.apps import apps
from django.conf import settings
from django.core import serializers
from django.core.exceptions import ImproperlyConfigured
from django.core.management.base import BaseCommand, CommandError
from django.core.management.color import no_style
from django.db import (
DEFAULT_DB_ALIAS, DatabaseError, IntegrityError, connections, router,
transaction,
)
from django.utils import lru_cache
from django.utils._os import upath
from django.utils.encoding import force_text
from django.utils.functional import cached_property
from django.utils.glob import glob_escape
try:
import bz2
has_bz2 = True
except ImportError:
has_bz2 = False
class Command(BaseCommand):
help = 'Installs the named fixture(s) in the database.'
missing_args_message = ("No database fixture specified. Please provide the "
"path of at least one fixture in the command line.")
def add_arguments(self, parser):
parser.add_argument('args', metavar='fixture', nargs='+',
help='Fixture labels.')
parser.add_argument('--database', action='store', dest='database',
default=DEFAULT_DB_ALIAS, help='Nominates a specific database to load '
'fixtures into. Defaults to the "default" database.')
parser.add_argument('--app', action='store', dest='app_label',
default=None, help='Only look for fixtures in the specified app.')
parser.add_argument('--ignorenonexistent', '-i', action='store_true',
dest='ignore', default=False,
help='Ignores entries in the serialized data for fields that do not '
'currently exist on the model.')
def handle(self, *fixture_labels, **options):
self.ignore = options.get('ignore')
self.using = options.get('database')
self.app_label = options.get('app_label')
self.hide_empty = options.get('hide_empty', False)
self.verbosity = options.get('verbosity')
with transaction.atomic(using=self.using):
self.loaddata(fixture_labels)
# Close the DB connection -- unless we're still in a transaction. This
# is required as a workaround for an edge case in MySQL: if the same
# connection is used to create tables, load data, and query, the query
# can return incorrect results. See Django #7572, MySQL #37735.
if transaction.get_autocommit(self.using):
connections[self.using].close()
def loaddata(self, fixture_labels):
connection = connections[self.using]
# Keep a count of the installed objects and fixtures
self.fixture_count = 0
self.loaded_object_count = 0
self.fixture_object_count = 0
self.models = set()
self.serialization_formats = serializers.get_public_serializer_formats()
# Forcing binary mode may be revisited after dropping Python 2 support (see #22399)
self.compression_formats = {
None: (open, 'rb'),
'gz': (gzip.GzipFile, 'rb'),
'zip': (SingleZipReader, 'r'),
}
if has_bz2:
self.compression_formats['bz2'] = (bz2.BZ2File, 'r')
# Django's test suite repeatedly tries to load initial_data fixtures
# from apps that don't have any fixtures. Because disabling constraint
# checks can be expensive on some database (especially MSSQL), bail
# out early if no fixtures are found.
for fixture_label in fixture_labels:
if self.find_fixtures(fixture_label):
break
else:
return
with connection.constraint_checks_disabled():
for fixture_label in fixture_labels:
self.load_label(fixture_label)
# Since we disabled constraint checks, we must manually check for
# any invalid keys that might have been added
table_names = [model._meta.db_table for model in self.models]
try:
connection.check_constraints(table_names=table_names)
except Exception as e:
e.args = ("Problem installing fixtures: %s" % e,)
raise
# If we found even one object in a fixture, we need to reset the
# database sequences.
if self.loaded_object_count > 0:
sequence_sql = connection.ops.sequence_reset_sql(no_style(), self.models)
if sequence_sql:
if self.verbosity >= 2:
self.stdout.write("Resetting sequences\n")
with connection.cursor() as cursor:
for line in sequence_sql:
cursor.execute(line)
if self.verbosity >= 1:
if self.fixture_count == 0 and self.hide_empty:
pass
elif self.fixture_object_count == self.loaded_object_count:
self.stdout.write("Installed %d object(s) from %d fixture(s)" %
(self.loaded_object_count, self.fixture_count))
else:
self.stdout.write("Installed %d object(s) (of %d) from %d fixture(s)" %
(self.loaded_object_count, self.fixture_object_count, self.fixture_count))
def load_label(self, fixture_label):
"""
Loads fixtures files for a given label.
"""
show_progress = self.verbosity >= 3
for fixture_file, fixture_dir, fixture_name in self.find_fixtures(fixture_label):
_, ser_fmt, cmp_fmt = self.parse_name(os.path.basename(fixture_file))
open_method, mode = self.compression_formats[cmp_fmt]
fixture = open_method(fixture_file, mode)
try:
self.fixture_count += 1
objects_in_fixture = 0
loaded_objects_in_fixture = 0
if self.verbosity >= 2:
self.stdout.write("Installing %s fixture '%s' from %s." %
(ser_fmt, fixture_name, humanize(fixture_dir)))
objects = serializers.deserialize(ser_fmt, fixture,
using=self.using, ignorenonexistent=self.ignore)
for obj in objects:
objects_in_fixture += 1
if router.allow_migrate_model(self.using, obj.object.__class__):
loaded_objects_in_fixture += 1
self.models.add(obj.object.__class__)
try:
obj.save(using=self.using)
if show_progress:
self.stdout.write(
'\rProcessed %i object(s).' % loaded_objects_in_fixture,
ending=''
)
except (DatabaseError, IntegrityError) as e:
e.args = ("Could not load %(app_label)s.%(object_name)s(pk=%(pk)s): %(error_msg)s" % {
'app_label': obj.object._meta.app_label,
'object_name': obj.object._meta.object_name,
'pk': obj.object.pk,
'error_msg': force_text(e)
},)
raise
if objects and show_progress:
self.stdout.write('') # add a newline after progress indicator
self.loaded_object_count += loaded_objects_in_fixture
self.fixture_object_count += objects_in_fixture
except Exception as e:
if not isinstance(e, CommandError):
e.args = ("Problem installing fixture '%s': %s" % (fixture_file, e),)
raise
finally:
fixture.close()
# Warn if the fixture we loaded contains 0 objects.
if objects_in_fixture == 0:
warnings.warn(
"No fixture data found for '%s'. (File format may be "
"invalid.)" % fixture_name,
RuntimeWarning
)
@lru_cache.lru_cache(maxsize=None)
def find_fixtures(self, fixture_label):
"""
Finds fixture files for a given label.
"""
fixture_name, ser_fmt, cmp_fmt = self.parse_name(fixture_label)
databases = [self.using, None]
cmp_fmts = list(self.compression_formats.keys()) if cmp_fmt is None else [cmp_fmt]
ser_fmts = serializers.get_public_serializer_formats() if ser_fmt is None else [ser_fmt]
if self.verbosity >= 2:
self.stdout.write("Loading '%s' fixtures..." % fixture_name)
if os.path.isabs(fixture_name):
fixture_dirs = [os.path.dirname(fixture_name)]
fixture_name = os.path.basename(fixture_name)
else:
fixture_dirs = self.fixture_dirs
if os.path.sep in os.path.normpath(fixture_name):
fixture_dirs = [os.path.join(dir_, os.path.dirname(fixture_name))
for dir_ in fixture_dirs]
fixture_name = os.path.basename(fixture_name)
suffixes = ('.'.join(ext for ext in combo if ext)
for combo in product(databases, ser_fmts, cmp_fmts))
targets = set('.'.join((fixture_name, suffix)) for suffix in suffixes)
fixture_files = []
for fixture_dir in fixture_dirs:
if self.verbosity >= 2:
self.stdout.write("Checking %s for fixtures..." % humanize(fixture_dir))
fixture_files_in_dir = []
path = os.path.join(fixture_dir, fixture_name)
for candidate in glob.iglob(glob_escape(path) + '*'):
if os.path.basename(candidate) in targets:
# Save the fixture_dir and fixture_name for future error messages.
fixture_files_in_dir.append((candidate, fixture_dir, fixture_name))
if self.verbosity >= 2 and not fixture_files_in_dir:
self.stdout.write("No fixture '%s' in %s." %
(fixture_name, humanize(fixture_dir)))
# Check kept for backwards-compatibility; it isn't clear why
# duplicates are only allowed in different directories.
if len(fixture_files_in_dir) > 1:
raise CommandError(
"Multiple fixtures named '%s' in %s. Aborting." %
(fixture_name, humanize(fixture_dir)))
fixture_files.extend(fixture_files_in_dir)
if not fixture_files:
raise CommandError("No fixture named '%s' found." % fixture_name)
return fixture_files
@cached_property
def fixture_dirs(self):
"""
Return a list of fixture directories.
The list contains the 'fixtures' subdirectory of each installed
application, if it exists, the directories in FIXTURE_DIRS, and the
current directory.
"""
dirs = []
fixture_dirs = settings.FIXTURE_DIRS
if len(fixture_dirs) != len(set(fixture_dirs)):
raise ImproperlyConfigured("settings.FIXTURE_DIRS contains duplicates.")
for app_config in apps.get_app_configs():
app_label = app_config.label
app_dir = os.path.join(app_config.path, 'fixtures')
if app_dir in fixture_dirs:
raise ImproperlyConfigured(
"'%s' is a default fixture directory for the '%s' app "
"and cannot be listed in settings.FIXTURE_DIRS." % (app_dir, app_label)
)
if self.app_label and app_label != self.app_label:
continue
if os.path.isdir(app_dir):
dirs.append(app_dir)
dirs.extend(list(fixture_dirs))
dirs.append('')
dirs = [upath(os.path.abspath(os.path.realpath(d))) for d in dirs]
return dirs
def parse_name(self, fixture_name):
"""
Splits fixture name in name, serialization format, compression format.
"""
parts = fixture_name.rsplit('.', 2)
if len(parts) > 1 and parts[-1] in self.compression_formats:
cmp_fmt = parts[-1]
parts = parts[:-1]
else:
cmp_fmt = None
if len(parts) > 1:
if parts[-1] in self.serialization_formats:
ser_fmt = parts[-1]
parts = parts[:-1]
else:
raise CommandError(
"Problem installing fixture '%s': %s is not a known "
"serialization format." % (''.join(parts[:-1]), parts[-1]))
else:
ser_fmt = None
name = '.'.join(parts)
return name, ser_fmt, cmp_fmt
class SingleZipReader(zipfile.ZipFile):
def __init__(self, *args, **kwargs):
zipfile.ZipFile.__init__(self, *args, **kwargs)
if len(self.namelist()) != 1:
raise ValueError("Zip-compressed fixtures must contain one file.")
def read(self):
return zipfile.ZipFile.read(self, self.namelist()[0])
def humanize(dirname):
return "'%s'" % dirname if dirname else 'absolute path'
|
bsd-3-clause
|
[
504,
636,
2443,
363,
492,
2649,
63,
5955,
199,
199,
646,
5739,
199,
646,
11756,
199,
646,
747,
199,
646,
3598,
199,
646,
10392,
199,
504,
7975,
492,
3336,
199,
199,
504,
1639,
14,
5181,
492,
8686,
199,
504,
1639,
14,
2190,
492,
2202,
199,
504,
1639,
14,
1018,
492,
12506,
199,
504,
1639,
14,
1018,
14,
3924,
492,
11897,
199,
504,
1639,
14,
1018,
14,
8110,
14,
1095,
492,
22239,
12,
14393,
199,
504,
1639,
14,
1018,
14,
8110,
14,
2326,
492,
949,
63,
2487,
199,
504,
1639,
14,
697,
492,
334,
272,
6186,
63,
2846,
63,
12644,
12,
27728,
12,
26864,
12,
6947,
12,
6197,
12,
272,
6008,
12,
199,
9,
199,
504,
1639,
14,
1208,
492,
634,
6558,
63,
1637,
199,
504,
1639,
14,
1208,
423,
736,
492,
1536,
1619,
199,
504,
1639,
14,
1208,
14,
2991,
492,
3542,
63,
505,
199,
504,
1639,
14,
1208,
14,
15481,
492,
6328,
63,
1829,
199,
504,
1639,
14,
1208,
14,
6463,
492,
5739,
63,
3765,
199,
199,
893,
26,
272,
492,
15055,
18,
272,
965,
63,
10582,
18,
275,
715,
199,
2590,
3545,
26,
272,
965,
63,
10582,
18,
275,
756,
421,
199,
533,
5817,
8,
25150,
304,
272,
1720,
275,
283,
8154,
83,
314,
4310,
10949,
8,
83,
9,
315,
314,
3050,
3530,
272,
4124,
63,
589,
63,
1188,
275,
1689,
1944,
3050,
10949,
2013,
14,
7754,
5647,
314,
298,
1169,
298,
515,
402,
737,
5210,
1373,
10949,
315,
314,
1414,
1004,
2685,
339,
347,
1050,
63,
4958,
8,
277,
12,
1798,
304,
267,
1798,
14,
525,
63,
2094,
360,
589,
297,
8214,
534,
5997,
297,
9237,
534,
7386,
288,
1720,
534,
12812,
3628,
2659,
267,
1798,
14,
525,
63,
2094,
4517,
4659,
297,
1595,
534,
1617,
297,
2053,
534,
4659,
297,
288,
849,
29,
3472,
63,
2846,
63,
12644,
12,
1720,
534,
46,
676,
262,
2335,
282,
2488,
3050,
370,
2248,
283,
288,
283,
8769,
1901,
14,
7827,
370,
314,
298,
885,
2,
3050,
2659,
267,
1798,
14,
525,
63,
2094,
4517,
571,
297,
1595,
534,
1617,
297,
2053,
534,
571,
63,
1302,
297,
288,
849,
29,
403,
12,
1720,
534,
5903,
3648,
367,
15188,
315,
314,
2013,
1145,
2659,
267,
1798,
14,
525,
63,
2094,
4517,
4247,
21573,
297,
2475,
73,
297,
1595,
534,
1617,
63,
2052,
297,
288,
2053,
534,
4247,
297,
849,
29,
797,
12,
288,
1720,
534,
19399,
7944,
4811,
315,
314,
6380,
666,
367,
1504,
626,
886,
440,
283,
288,
283,
19767,
2187,
641,
314,
1402,
2659,
339,
347,
2429,
8,
277,
12,
627,
5997,
63,
3512,
12,
1011,
1419,
304,
398,
291,
14,
4247,
275,
1511,
14,
362,
360,
4247,
358,
267,
291,
14,
4941,
275,
1511,
14,
362,
360,
4659,
358,
267,
291,
14,
571,
63,
1302,
275,
1511,
14,
362,
360,
571,
63,
1302,
358,
267,
291,
14,
8191,
63,
1667,
275,
1511,
14,
362,
360,
8191,
63,
1667,
297,
756,
9,
267,
291,
14,
9833,
275,
1511,
14,
362,
360,
9833,
358,
398,
543,
6008,
14,
10910,
8,
4941,
29,
277,
14,
4941,
304,
288,
291,
14,
320,
525,
419,
8,
5997,
63,
3512,
9,
398,
327,
15524,
314,
6249,
1950,
1553,
7444,
781,
3984,
5139,
315,
282,
6008,
14,
961,
267,
327,
365,
1415,
465,
282,
18092,
367,
376,
221,
6275,
1930,
315,
11200,
26,
340,
314,
2011,
267,
327,
1950,
365,
1202,
370,
1218,
6716,
12,
2248,
666,
12,
436,
1827,
12,
314,
1827,
267,
327,
883,
372,
8927,
2058,
14,
1666,
5634,
327,
23,
17802,
12,
11200,
327,
7332,
1276,
14,
267,
340,
6008,
14,
362,
63,
17881,
8,
277,
14,
4941,
304,
288,
6947,
59,
277,
14,
4941,
1055,
1600,
342,
339,
347,
560,
525,
419,
8,
277,
12,
10949,
63,
3512,
304,
267,
1950,
275,
6947,
59,
277,
14,
4941,
61,
398,
327,
14797,
282,
2338,
402,
314,
4903,
2251,
436,
15188,
267,
291,
14,
5997,
63,
835,
275,
378,
267,
291,
14,
4591,
63,
785,
63,
835,
275,
378,
267,
291,
14,
5997,
63,
785,
63,
835,
275,
378,
267,
291,
14,
992,
275,
663,
342,
398,
291,
14,
12161,
63,
6321,
275,
12506,
14,
362,
63,
3455,
63,
8349,
63,
6321,
342,
267,
327,
2104,
4477,
3366,
818,
1443,
506,
295,
21736,
2410,
366,
20148,
2018,
499,
2291,
334,
3239,
327,
1081,
10936,
9,
267,
291,
14,
12849,
63,
6321,
275,
469,
288,
488,
26,
334,
1490,
12,
283,
4848,
659,
288,
283,
6838,
356,
334,
12256,
14,
29827,
12,
283,
4848,
659,
288,
283,
3065,
356,
334,
7200,
8674,
5929,
12,
283,
82,
659,
267,
789,
267,
340,
965,
63,
10582,
18,
26,
288,
291,
14,
12849,
63,
6321,
459,
10582,
18,
418,
275,
334,
10582,
18,
14,
21338,
18,
1173,
12,
283,
82,
358,
398,
327,
5634,
1159,
511,
5241,
27714,
11275,
370,
2248,
2536,
63,
576,
15188,
267,
327,
687,
8686,
626,
2793,
1133,
1172,
1263,
15188,
14,
13821,
30723,
5828,
267,
327,
5920,
883,
506,
23133,
641,
2005,
3050,
334,
397,
910,
1183,
603,
2300,
2940,
395,
31571,
267,
327,
734,
14670,
340,
949,
15188,
787,
1911,
14,
267,
367,
10949,
63,
1302,
315,
10949,
63,
3512,
26,
288,
340,
291,
14,
1623,
63,
8769,
8,
5997,
63,
1302,
304,
355,
2059,
267,
587,
26,
288,
372,
398,
543,
1950,
14,
5631,
63,
8625,
63,
7011,
837,
288,
367,
10949,
63,
1302,
315,
10949,
63,
3512,
26,
355,
291,
14,
912,
63,
1302,
8,
5997,
63,
1302,
9,
398,
327,
9336,
781,
6980,
5828,
5920,
12,
781,
1471,
10250,
1104,
367,
267,
327,
1263,
3866,
2883,
626,
5594,
1172,
2757,
3483,
267,
1817,
63,
1247,
275,
359,
1238,
423,
2024,
14,
697,
63,
1224,
367,
1402,
315,
291,
14,
992,
61,
267,
862,
26,
288,
1950,
14,
1074,
63,
9882,
8,
1224,
63,
1247,
29,
1224,
63,
1247,
9,
267,
871,
2186,
465,
325,
26,
288,
325,
14,
589,
275,
1689,
16467,
22200,
15188,
26,
450,
83,
2,
450,
325,
4258,
288,
746,
398,
327,
982,
781,
1911,
2755,
1373,
909,
315,
282,
10949,
12,
781,
1929,
370,
5305,
314,
267,
327,
3050,
8013,
14,
267,
340,
291,
14,
4591,
63,
785,
63,
835,
690,
378,
26,
288,
3414,
63,
3009
] |
[
636,
2443,
363,
492,
2649,
63,
5955,
199,
199,
646,
5739,
199,
646,
11756,
199,
646,
747,
199,
646,
3598,
199,
646,
10392,
199,
504,
7975,
492,
3336,
199,
199,
504,
1639,
14,
5181,
492,
8686,
199,
504,
1639,
14,
2190,
492,
2202,
199,
504,
1639,
14,
1018,
492,
12506,
199,
504,
1639,
14,
1018,
14,
3924,
492,
11897,
199,
504,
1639,
14,
1018,
14,
8110,
14,
1095,
492,
22239,
12,
14393,
199,
504,
1639,
14,
1018,
14,
8110,
14,
2326,
492,
949,
63,
2487,
199,
504,
1639,
14,
697,
492,
334,
272,
6186,
63,
2846,
63,
12644,
12,
27728,
12,
26864,
12,
6947,
12,
6197,
12,
272,
6008,
12,
199,
9,
199,
504,
1639,
14,
1208,
492,
634,
6558,
63,
1637,
199,
504,
1639,
14,
1208,
423,
736,
492,
1536,
1619,
199,
504,
1639,
14,
1208,
14,
2991,
492,
3542,
63,
505,
199,
504,
1639,
14,
1208,
14,
15481,
492,
6328,
63,
1829,
199,
504,
1639,
14,
1208,
14,
6463,
492,
5739,
63,
3765,
199,
199,
893,
26,
272,
492,
15055,
18,
272,
965,
63,
10582,
18,
275,
715,
199,
2590,
3545,
26,
272,
965,
63,
10582,
18,
275,
756,
421,
199,
533,
5817,
8,
25150,
304,
272,
1720,
275,
283,
8154,
83,
314,
4310,
10949,
8,
83,
9,
315,
314,
3050,
3530,
272,
4124,
63,
589,
63,
1188,
275,
1689,
1944,
3050,
10949,
2013,
14,
7754,
5647,
314,
298,
1169,
298,
515,
402,
737,
5210,
1373,
10949,
315,
314,
1414,
1004,
2685,
339,
347,
1050,
63,
4958,
8,
277,
12,
1798,
304,
267,
1798,
14,
525,
63,
2094,
360,
589,
297,
8214,
534,
5997,
297,
9237,
534,
7386,
288,
1720,
534,
12812,
3628,
2659,
267,
1798,
14,
525,
63,
2094,
4517,
4659,
297,
1595,
534,
1617,
297,
2053,
534,
4659,
297,
288,
849,
29,
3472,
63,
2846,
63,
12644,
12,
1720,
534,
46,
676,
262,
2335,
282,
2488,
3050,
370,
2248,
283,
288,
283,
8769,
1901,
14,
7827,
370,
314,
298,
885,
2,
3050,
2659,
267,
1798,
14,
525,
63,
2094,
4517,
571,
297,
1595,
534,
1617,
297,
2053,
534,
571,
63,
1302,
297,
288,
849,
29,
403,
12,
1720,
534,
5903,
3648,
367,
15188,
315,
314,
2013,
1145,
2659,
267,
1798,
14,
525,
63,
2094,
4517,
4247,
21573,
297,
2475,
73,
297,
1595,
534,
1617,
63,
2052,
297,
288,
2053,
534,
4247,
297,
849,
29,
797,
12,
288,
1720,
534,
19399,
7944,
4811,
315,
314,
6380,
666,
367,
1504,
626,
886,
440,
283,
288,
283,
19767,
2187,
641,
314,
1402,
2659,
339,
347,
2429,
8,
277,
12,
627,
5997,
63,
3512,
12,
1011,
1419,
304,
398,
291,
14,
4247,
275,
1511,
14,
362,
360,
4247,
358,
267,
291,
14,
4941,
275,
1511,
14,
362,
360,
4659,
358,
267,
291,
14,
571,
63,
1302,
275,
1511,
14,
362,
360,
571,
63,
1302,
358,
267,
291,
14,
8191,
63,
1667,
275,
1511,
14,
362,
360,
8191,
63,
1667,
297,
756,
9,
267,
291,
14,
9833,
275,
1511,
14,
362,
360,
9833,
358,
398,
543,
6008,
14,
10910,
8,
4941,
29,
277,
14,
4941,
304,
288,
291,
14,
320,
525,
419,
8,
5997,
63,
3512,
9,
398,
327,
15524,
314,
6249,
1950,
1553,
7444,
781,
3984,
5139,
315,
282,
6008,
14,
961,
267,
327,
365,
1415,
465,
282,
18092,
367,
376,
221,
6275,
1930,
315,
11200,
26,
340,
314,
2011,
267,
327,
1950,
365,
1202,
370,
1218,
6716,
12,
2248,
666,
12,
436,
1827,
12,
314,
1827,
267,
327,
883,
372,
8927,
2058,
14,
1666,
5634,
327,
23,
17802,
12,
11200,
327,
7332,
1276,
14,
267,
340,
6008,
14,
362,
63,
17881,
8,
277,
14,
4941,
304,
288,
6947,
59,
277,
14,
4941,
1055,
1600,
342,
339,
347,
560,
525,
419,
8,
277,
12,
10949,
63,
3512,
304,
267,
1950,
275,
6947,
59,
277,
14,
4941,
61,
398,
327,
14797,
282,
2338,
402,
314,
4903,
2251,
436,
15188,
267,
291,
14,
5997,
63,
835,
275,
378,
267,
291,
14,
4591,
63,
785,
63,
835,
275,
378,
267,
291,
14,
5997,
63,
785,
63,
835,
275,
378,
267,
291,
14,
992,
275,
663,
342,
398,
291,
14,
12161,
63,
6321,
275,
12506,
14,
362,
63,
3455,
63,
8349,
63,
6321,
342,
267,
327,
2104,
4477,
3366,
818,
1443,
506,
295,
21736,
2410,
366,
20148,
2018,
499,
2291,
334,
3239,
327,
1081,
10936,
9,
267,
291,
14,
12849,
63,
6321,
275,
469,
288,
488,
26,
334,
1490,
12,
283,
4848,
659,
288,
283,
6838,
356,
334,
12256,
14,
29827,
12,
283,
4848,
659,
288,
283,
3065,
356,
334,
7200,
8674,
5929,
12,
283,
82,
659,
267,
789,
267,
340,
965,
63,
10582,
18,
26,
288,
291,
14,
12849,
63,
6321,
459,
10582,
18,
418,
275,
334,
10582,
18,
14,
21338,
18,
1173,
12,
283,
82,
358,
398,
327,
5634,
1159,
511,
5241,
27714,
11275,
370,
2248,
2536,
63,
576,
15188,
267,
327,
687,
8686,
626,
2793,
1133,
1172,
1263,
15188,
14,
13821,
30723,
5828,
267,
327,
5920,
883,
506,
23133,
641,
2005,
3050,
334,
397,
910,
1183,
603,
2300,
2940,
395,
31571,
267,
327,
734,
14670,
340,
949,
15188,
787,
1911,
14,
267,
367,
10949,
63,
1302,
315,
10949,
63,
3512,
26,
288,
340,
291,
14,
1623,
63,
8769,
8,
5997,
63,
1302,
304,
355,
2059,
267,
587,
26,
288,
372,
398,
543,
1950,
14,
5631,
63,
8625,
63,
7011,
837,
288,
367,
10949,
63,
1302,
315,
10949,
63,
3512,
26,
355,
291,
14,
912,
63,
1302,
8,
5997,
63,
1302,
9,
398,
327,
9336,
781,
6980,
5828,
5920,
12,
781,
1471,
10250,
1104,
367,
267,
327,
1263,
3866,
2883,
626,
5594,
1172,
2757,
3483,
267,
1817,
63,
1247,
275,
359,
1238,
423,
2024,
14,
697,
63,
1224,
367,
1402,
315,
291,
14,
992,
61,
267,
862,
26,
288,
1950,
14,
1074,
63,
9882,
8,
1224,
63,
1247,
29,
1224,
63,
1247,
9,
267,
871,
2186,
465,
325,
26,
288,
325,
14,
589,
275,
1689,
16467,
22200,
15188,
26,
450,
83,
2,
450,
325,
4258,
288,
746,
398,
327,
982,
781,
1911,
2755,
1373,
909,
315,
282,
10949,
12,
781,
1929,
370,
5305,
314,
267,
327,
3050,
8013,
14,
267,
340,
291,
14,
4591,
63,
785,
63,
835,
690,
378,
26,
288,
3414,
63,
3009,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
dosiecki/NewsBlur
|
vendor/paypal/pro/models.py
|
18
|
5131
|
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from django.conf import settings
from django.db import models
from django.utils.http import urlencode
from django.forms.models import model_to_dict
try:
from idmapper.models import SharedMemoryModel as Model
except ImportError:
Model = models.Model
class PayPalNVP(Model):
"""Record of a NVP interaction with PayPal."""
TIMESTAMP_FORMAT = "%Y-%m-%dT%H:%M:%SZ" # 2009-02-03T17:47:41Z
RESTRICTED_FIELDS = ["expdate",
"cvv2",
"acct",
]
ADMIN_FIELDS = ['id',
'user',
'flag',
'flag_code',
'flag_info',
'query',
'response',
'created_at',
'updated_at',
]
ITEM_FIELDS = ["amt",
"custom",
"invnum",
]
DIRECT_FIELDS = ["firstname",
"lastname",
"street",
"city",
"state",
"countrycode",
"zip",
]
# Response fields
method = models.CharField(max_length=64, blank=True)
ack = models.CharField(max_length=32, blank=True)
profilestatus = models.CharField(max_length=32, blank=True)
timestamp = models.DateTimeField(blank=True, null=True)
profileid = models.CharField(max_length=32, blank=True) # I-E596DFUSD882
profilereference = models.CharField(max_length=128, blank=True) # PROFILEREFERENCE
correlationid = models.CharField(max_length=32, blank=True) # 25b380cda7a21
token = models.CharField(max_length=64, blank=True)
payerid = models.CharField(max_length=64, blank=True)
# Transaction Fields
firstname = models.CharField("First Name", max_length=255, blank=True)
lastname = models.CharField("Last Name", max_length=255, blank=True)
street = models.CharField("Street Address", max_length=255, blank=True)
city = models.CharField("City", max_length=255, blank=True)
state = models.CharField("State", max_length=255, blank=True)
countrycode = models.CharField("Country", max_length=2, blank=True)
zip = models.CharField("Postal / Zip Code", max_length=32, blank=True)
# Custom fields
invnum = models.CharField(max_length=255, blank=True)
custom = models.CharField(max_length=255, blank=True)
# Admin fields
user = models.ForeignKey(getattr(settings, 'AUTH_USER_MODEL', 'auth.User'),
blank=True, null=True)
flag = models.BooleanField(default=False, blank=True)
flag_code = models.CharField(max_length=32, blank=True)
flag_info = models.TextField(blank=True)
ipaddress = models.IPAddressField(blank=True)
query = models.TextField(blank=True)
response = models.TextField(blank=True)
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
class Meta:
db_table = "paypal_nvp"
verbose_name = "PayPal NVP"
def init(self, request, paypal_request, paypal_response):
"""Initialize a PayPalNVP instance from a HttpRequest."""
if request is not None:
self.ipaddress = request.META.get('REMOTE_ADDR', '').split(':')[0]
if hasattr(request, "user") and request.user.is_authenticated():
self.user = request.user
else:
self.ipaddress = ''
# No storing credit card info.
query_data = dict((k, v) for k, v in paypal_request.items() if k not in self.RESTRICTED_FIELDS)
self.query = urlencode(query_data)
self.response = urlencode(paypal_response)
# Was there a flag on the play?
ack = paypal_response.get('ack', False)
if ack != "Success":
if ack == "SuccessWithWarning":
self.flag_info = paypal_response.get('l_longmessage0', '')
else:
self.set_flag(paypal_response.get('l_longmessage0', ''), paypal_response.get('l_errorcode', ''))
def set_flag(self, info, code=None):
"""Flag this instance for investigation."""
self.flag = True
self.flag_info += info
if code is not None:
self.flag_code = code
def process(self, request, item):
"""Do a direct payment."""
from paypal.pro.helpers import PayPalWPP
wpp = PayPalWPP(request)
# Change the model information into a dict that PayPal can understand.
params = model_to_dict(self, exclude=self.ADMIN_FIELDS)
params['acct'] = self.acct
params['creditcardtype'] = self.creditcardtype
params['expdate'] = self.expdate
params['cvv2'] = self.cvv2
params.update(item)
# Create recurring payment:
if 'billingperiod' in params:
return wpp.createRecurringPaymentsProfile(params, direct=True)
# Create single payment:
else:
return wpp.doDirectPayment(params)
|
mit
|
[
3381,
2647,
15,
1393,
15,
1813,
2366,
199,
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
504,
1639,
14,
2190,
492,
2202,
199,
504,
1639,
14,
697,
492,
1709,
199,
504,
1639,
14,
1208,
14,
1014,
492,
16511,
199,
504,
1639,
14,
3351,
14,
992,
492,
1402,
63,
475,
63,
807,
199,
199,
893,
26,
272,
687,
1305,
7153,
14,
992,
492,
23752,
8628,
1685,
465,
5822,
199,
2590,
3545,
26,
272,
5822,
275,
1709,
14,
1685,
421,
199,
533,
15911,
24666,
7312,
48,
8,
1685,
304,
272,
408,
5433,
402,
282,
653,
14159,
18752,
543,
15911,
24666,
1041,
272,
32745,
63,
4807,
275,
2071,
57,
3295,
77,
3295,
19772,
5,
40,
2689,
45,
2689,
18101,
2,
221,
327,
8937,
13,
996,
13,
1644,
52,
1196,
26,
2417,
26,
2953,
58,
272,
14880,
50,
6196,
1149,
63,
12767,
275,
2097,
1474,
602,
401,
586,
298,
5107,
86,
18,
401,
586,
298,
23015,
401,
586,
1622,
272,
29948,
63,
12767,
275,
788,
344,
297,
490,
283,
751,
297,
490,
283,
4173,
297,
490,
283,
4173,
63,
600,
297,
490,
283,
4173,
63,
815,
297,
490,
283,
1131,
297,
490,
283,
1310,
297,
490,
283,
3966,
63,
292,
297,
490,
283,
5334,
63,
292,
297,
490,
1622,
272,
473,
22057,
63,
12767,
275,
2097,
19582,
401,
673,
298,
4229,
401,
673,
298,
5350,
1507,
401,
673,
1622,
272,
8703,
63,
12767,
275,
2097,
25603,
401,
2151,
298,
31164,
401,
2151,
298,
20451,
401,
2151,
298,
3690,
401,
2151,
298,
929,
401,
2151,
298,
6063,
600,
401,
2151,
298,
3065,
401,
2151,
1622,
339,
327,
7232,
1504,
272,
1083,
275,
1709,
14,
2183,
8,
988,
63,
1267,
29,
772,
12,
4596,
29,
549,
9,
272,
19807,
275,
1709,
14,
2183,
8,
988,
63,
1267,
29,
708,
12,
4596,
29,
549,
9,
272,
4690,
1205,
275,
1709,
14,
2183,
8,
988,
63,
1267,
29,
708,
12,
4596,
29,
549,
9,
272,
4913,
275,
1709,
14,
4626,
8,
2500,
29,
549,
12,
2973,
29,
549,
9,
272,
4690,
344,
275,
1709,
14,
2183,
8,
988,
63,
1267,
29,
708,
12,
4596,
29,
549,
9,
221,
327,
473,
13,
37,
15112,
3888,
1668,
36,
19119,
272,
4690,
4443,
275,
1709,
14,
2183,
8,
988,
63,
1267,
29,
3933,
12,
4596,
29,
549,
9,
221,
327,
3611,
5110,
540,
14153,
540,
6013,
272,
21280,
344,
275,
1709,
14,
2183,
8,
988,
63,
1267,
29,
708,
12,
4596,
29,
549,
9,
327,
5661,
66,
23281,
67,
983,
23,
65,
2025,
272,
1526,
275,
1709,
14,
2183,
8,
988,
63,
1267,
29,
772,
12,
4596,
29,
549,
9,
272,
8633,
281,
344,
275,
1709,
14,
2183,
8,
988,
63,
1267,
29,
772,
12,
4596,
29,
549,
9,
339,
327,
18244,
16424,
272,
1642,
354,
275,
1709,
14,
2183,
480,
7147,
2812,
401,
1390,
63,
1267,
29,
2299,
12,
4596,
29,
549,
9,
272,
2061,
354,
275,
1709,
14,
2183,
480,
6090,
2812,
401,
1390,
63,
1267,
29,
2299,
12,
4596,
29,
549,
9,
272,
410,
7936,
275,
1709,
14,
2183,
480,
933,
7936,
9906,
401,
1390,
63,
1267,
29,
2299,
12,
4596,
29,
549,
9,
272,
14492,
275,
1709,
14,
2183,
480,
17024,
401,
1390,
63,
1267,
29,
2299,
12,
4596,
29,
549,
9,
272,
1174,
275,
1709,
14,
2183,
480,
2223,
401,
1390,
63,
1267,
29,
2299,
12,
4596,
29,
549,
9,
272,
9023,
600,
275,
1709,
14,
2183,
480,
17393,
401,
1390,
63,
1267,
29,
18,
12,
4596,
29,
549,
9,
272,
3482,
275,
1709,
14,
2183,
480,
6564,
279,
1182,
16688,
5495,
401,
1390,
63,
1267,
29,
708,
12,
4596,
29,
549,
9,
339,
327,
8388,
1504,
272,
4572,
1507,
275,
1709,
14,
2183,
8,
988,
63,
1267,
29,
2299,
12,
4596,
29,
549,
9,
272,
3537,
275,
1709,
14,
2183,
8,
988,
63,
1267,
29,
2299,
12,
4596,
29,
549,
9,
339,
327,
9516,
1504,
272,
922,
275,
1709,
14,
3190,
8,
5675,
8,
1751,
12,
283,
5580,
63,
3791,
63,
11429,
297,
283,
1178,
14,
1899,
659,
2490,
4596,
29,
549,
12,
2973,
29,
549,
9,
272,
3305,
275,
1709,
14,
5036,
8,
885,
29,
797,
12,
4596,
29,
549,
9,
272,
3305,
63,
600,
275,
1709,
14,
2183,
8,
988,
63,
1267,
29,
708,
12,
4596,
29,
549,
9,
272,
3305,
63,
815,
275,
1709,
14,
6254,
8,
2500,
29,
549,
9,
272,
20617,
275,
1709,
14,
26969,
8,
2500,
29,
549,
9,
272,
1827,
275,
1709,
14,
6254,
8,
2500,
29,
549,
9,
272,
1177,
275,
1709,
14,
6254,
8,
2500,
29,
549,
9,
272,
2737,
63,
292,
275,
1709,
14,
4626,
8,
2495,
63,
2131,
63,
525,
29,
549,
9,
272,
4588,
63,
292,
275,
1709,
14,
4626,
8,
2495,
63,
2131,
29,
549,
9,
339,
1021,
6288,
26,
267,
1592,
63,
1224,
275,
298,
25170,
63,
78,
11702,
2,
267,
3376,
63,
354,
275,
298,
10517,
24666,
653,
14159,
2,
339,
347,
4205,
8,
277,
12,
1056,
12,
691,
22006,
63,
1069,
12,
691,
22006,
63,
1310,
304,
267,
408,
9345,
282,
15911,
24666,
7312,
48,
1256,
687,
282,
20730,
1041,
267,
340,
1056,
365,
440,
488,
26,
288,
291,
14,
21809,
275,
1056,
14,
10614,
14,
362,
360,
16058,
63,
7803,
297,
12548,
1294,
24050,
16,
61,
288,
340,
2688,
8,
1069,
12,
298,
751,
531,
436,
1056,
14,
751,
14,
374,
63,
12177,
837,
355,
291,
14,
751,
275,
1056,
14,
751,
267,
587,
26,
288,
291,
14,
21809,
275,
2125,
398,
327,
3091,
16915,
16630,
12564,
2256,
14,
267,
1827,
63,
576,
275,
1211,
1332,
75,
12,
373,
9,
367,
1022,
12,
373,
315,
691,
22006,
63,
1069,
14,
1744,
342,
340,
1022,
440,
315,
291,
14,
15740,
50,
6196,
1149,
63,
12767,
9,
267,
291,
14,
1131,
275,
16511,
8,
1131,
63,
576,
9,
267,
291,
14,
1310,
275,
16511,
8,
25170,
63,
1310,
9,
398,
327,
644,
305,
2337,
282,
3305,
641,
314,
5232,
31,
18418,
19807,
275,
691,
22006,
63,
1310,
14,
362,
360,
564,
297,
756,
9,
267,
340,
19807,
1137,
298,
8300,
582,
288,
340,
19807,
508,
298,
8300,
3007,
3849,
582,
355,
291,
14,
4173,
63,
815,
275,
691,
22006,
63,
1310,
14,
362
] |
[
2647,
15,
1393,
15,
1813,
2366,
199,
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
504,
1639,
14,
2190,
492,
2202,
199,
504,
1639,
14,
697,
492,
1709,
199,
504,
1639,
14,
1208,
14,
1014,
492,
16511,
199,
504,
1639,
14,
3351,
14,
992,
492,
1402,
63,
475,
63,
807,
199,
199,
893,
26,
272,
687,
1305,
7153,
14,
992,
492,
23752,
8628,
1685,
465,
5822,
199,
2590,
3545,
26,
272,
5822,
275,
1709,
14,
1685,
421,
199,
533,
15911,
24666,
7312,
48,
8,
1685,
304,
272,
408,
5433,
402,
282,
653,
14159,
18752,
543,
15911,
24666,
1041,
272,
32745,
63,
4807,
275,
2071,
57,
3295,
77,
3295,
19772,
5,
40,
2689,
45,
2689,
18101,
2,
221,
327,
8937,
13,
996,
13,
1644,
52,
1196,
26,
2417,
26,
2953,
58,
272,
14880,
50,
6196,
1149,
63,
12767,
275,
2097,
1474,
602,
401,
586,
298,
5107,
86,
18,
401,
586,
298,
23015,
401,
586,
1622,
272,
29948,
63,
12767,
275,
788,
344,
297,
490,
283,
751,
297,
490,
283,
4173,
297,
490,
283,
4173,
63,
600,
297,
490,
283,
4173,
63,
815,
297,
490,
283,
1131,
297,
490,
283,
1310,
297,
490,
283,
3966,
63,
292,
297,
490,
283,
5334,
63,
292,
297,
490,
1622,
272,
473,
22057,
63,
12767,
275,
2097,
19582,
401,
673,
298,
4229,
401,
673,
298,
5350,
1507,
401,
673,
1622,
272,
8703,
63,
12767,
275,
2097,
25603,
401,
2151,
298,
31164,
401,
2151,
298,
20451,
401,
2151,
298,
3690,
401,
2151,
298,
929,
401,
2151,
298,
6063,
600,
401,
2151,
298,
3065,
401,
2151,
1622,
339,
327,
7232,
1504,
272,
1083,
275,
1709,
14,
2183,
8,
988,
63,
1267,
29,
772,
12,
4596,
29,
549,
9,
272,
19807,
275,
1709,
14,
2183,
8,
988,
63,
1267,
29,
708,
12,
4596,
29,
549,
9,
272,
4690,
1205,
275,
1709,
14,
2183,
8,
988,
63,
1267,
29,
708,
12,
4596,
29,
549,
9,
272,
4913,
275,
1709,
14,
4626,
8,
2500,
29,
549,
12,
2973,
29,
549,
9,
272,
4690,
344,
275,
1709,
14,
2183,
8,
988,
63,
1267,
29,
708,
12,
4596,
29,
549,
9,
221,
327,
473,
13,
37,
15112,
3888,
1668,
36,
19119,
272,
4690,
4443,
275,
1709,
14,
2183,
8,
988,
63,
1267,
29,
3933,
12,
4596,
29,
549,
9,
221,
327,
3611,
5110,
540,
14153,
540,
6013,
272,
21280,
344,
275,
1709,
14,
2183,
8,
988,
63,
1267,
29,
708,
12,
4596,
29,
549,
9,
327,
5661,
66,
23281,
67,
983,
23,
65,
2025,
272,
1526,
275,
1709,
14,
2183,
8,
988,
63,
1267,
29,
772,
12,
4596,
29,
549,
9,
272,
8633,
281,
344,
275,
1709,
14,
2183,
8,
988,
63,
1267,
29,
772,
12,
4596,
29,
549,
9,
339,
327,
18244,
16424,
272,
1642,
354,
275,
1709,
14,
2183,
480,
7147,
2812,
401,
1390,
63,
1267,
29,
2299,
12,
4596,
29,
549,
9,
272,
2061,
354,
275,
1709,
14,
2183,
480,
6090,
2812,
401,
1390,
63,
1267,
29,
2299,
12,
4596,
29,
549,
9,
272,
410,
7936,
275,
1709,
14,
2183,
480,
933,
7936,
9906,
401,
1390,
63,
1267,
29,
2299,
12,
4596,
29,
549,
9,
272,
14492,
275,
1709,
14,
2183,
480,
17024,
401,
1390,
63,
1267,
29,
2299,
12,
4596,
29,
549,
9,
272,
1174,
275,
1709,
14,
2183,
480,
2223,
401,
1390,
63,
1267,
29,
2299,
12,
4596,
29,
549,
9,
272,
9023,
600,
275,
1709,
14,
2183,
480,
17393,
401,
1390,
63,
1267,
29,
18,
12,
4596,
29,
549,
9,
272,
3482,
275,
1709,
14,
2183,
480,
6564,
279,
1182,
16688,
5495,
401,
1390,
63,
1267,
29,
708,
12,
4596,
29,
549,
9,
339,
327,
8388,
1504,
272,
4572,
1507,
275,
1709,
14,
2183,
8,
988,
63,
1267,
29,
2299,
12,
4596,
29,
549,
9,
272,
3537,
275,
1709,
14,
2183,
8,
988,
63,
1267,
29,
2299,
12,
4596,
29,
549,
9,
339,
327,
9516,
1504,
272,
922,
275,
1709,
14,
3190,
8,
5675,
8,
1751,
12,
283,
5580,
63,
3791,
63,
11429,
297,
283,
1178,
14,
1899,
659,
2490,
4596,
29,
549,
12,
2973,
29,
549,
9,
272,
3305,
275,
1709,
14,
5036,
8,
885,
29,
797,
12,
4596,
29,
549,
9,
272,
3305,
63,
600,
275,
1709,
14,
2183,
8,
988,
63,
1267,
29,
708,
12,
4596,
29,
549,
9,
272,
3305,
63,
815,
275,
1709,
14,
6254,
8,
2500,
29,
549,
9,
272,
20617,
275,
1709,
14,
26969,
8,
2500,
29,
549,
9,
272,
1827,
275,
1709,
14,
6254,
8,
2500,
29,
549,
9,
272,
1177,
275,
1709,
14,
6254,
8,
2500,
29,
549,
9,
272,
2737,
63,
292,
275,
1709,
14,
4626,
8,
2495,
63,
2131,
63,
525,
29,
549,
9,
272,
4588,
63,
292,
275,
1709,
14,
4626,
8,
2495,
63,
2131,
29,
549,
9,
339,
1021,
6288,
26,
267,
1592,
63,
1224,
275,
298,
25170,
63,
78,
11702,
2,
267,
3376,
63,
354,
275,
298,
10517,
24666,
653,
14159,
2,
339,
347,
4205,
8,
277,
12,
1056,
12,
691,
22006,
63,
1069,
12,
691,
22006,
63,
1310,
304,
267,
408,
9345,
282,
15911,
24666,
7312,
48,
1256,
687,
282,
20730,
1041,
267,
340,
1056,
365,
440,
488,
26,
288,
291,
14,
21809,
275,
1056,
14,
10614,
14,
362,
360,
16058,
63,
7803,
297,
12548,
1294,
24050,
16,
61,
288,
340,
2688,
8,
1069,
12,
298,
751,
531,
436,
1056,
14,
751,
14,
374,
63,
12177,
837,
355,
291,
14,
751,
275,
1056,
14,
751,
267,
587,
26,
288,
291,
14,
21809,
275,
2125,
398,
327,
3091,
16915,
16630,
12564,
2256,
14,
267,
1827,
63,
576,
275,
1211,
1332,
75,
12,
373,
9,
367,
1022,
12,
373,
315,
691,
22006,
63,
1069,
14,
1744,
342,
340,
1022,
440,
315,
291,
14,
15740,
50,
6196,
1149,
63,
12767,
9,
267,
291,
14,
1131,
275,
16511,
8,
1131,
63,
576,
9,
267,
291,
14,
1310,
275,
16511,
8,
25170,
63,
1310,
9,
398,
327,
644,
305,
2337,
282,
3305,
641,
314,
5232,
31,
18418,
19807,
275,
691,
22006,
63,
1310,
14,
362,
360,
564,
297,
756,
9,
267,
340,
19807,
1137,
298,
8300,
582,
288,
340,
19807,
508,
298,
8300,
3007,
3849,
582,
355,
291,
14,
4173,
63,
815,
275,
691,
22006,
63,
1310,
14,
362,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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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
] |
garrettcap/Bulletproof-Backup
|
wx/tools/Editra/src/ed_msg.py
|
2
|
17021
|
###############################################################################
# Name: ed_msg.py #
# Purpose: Provide a messaging/notification system for actions performed in #
# the editor. #
# Author: Cody Precord <cprecord@editra.org> #
# Copyright: (c) 2008 Cody Precord <staff@editra.org> #
# License: wxWindows License #
###############################################################################
"""
This module provides a light wrapping of a slightly modified pubsub module
to give it a lighter and simpler syntax for usage. It exports three main
methods. The first L{PostMessage} which is used to post a message for all
interested listeners. The second L{Subscribe} which allows an object to
subscribe its own listener function for a particular message type, all of
Editra's core message types are defined in this module using a naming
convention that starts each identifier with I{EDMSG_}. These identifier
constants can be used to identify the message type by comparing them with the
value of msg.GetType in a listener method. The third method is L{Unsubscribe}
which can be used to remove a listener from recieving messages.
@summary: Message system api and message type definitions
"""
__author__ = "Cody Precord <cprecord@editra.org>"
__svnid__ = "$Id: ed_msg.py 71697 2012-06-08 15:20:22Z CJP $"
__revision__ = "$Revision: 71697 $"
__all__ = ['PostMessage', 'Subscribe', 'Unsubscribe']
#--------------------------------------------------------------------------#
# Imports
from wx import PyDeadObjectError
from extern.pubsub import Publisher
#--------------------------------------------------------------------------#
# Message Type Definitions
#---- General Messages ----#
# Listen to all messages
EDMSG_ALL = ('editra',)
#---- End General Messages ----#
#---- Log Messages ----#
# Used internally by the log system. Listed by priority lowest -> highest
# All message data from these functions are a LogMsg object which is a
# container object for the message string / timestamp / type
#
# Using these message types with the PostMessage method is not suggested for
# use in user code instead use the logging facilities (wx.GetApp().GetLog() or
# util.Getlog() ) as they will handle the formatting that is expected by the
# log messaging listeners.
# Recieve all log messages (i.e anything put on the logging system)
EDMSG_LOG_ALL = EDMSG_ALL + ('log',)
# Recieve all messages that have been labled (info, events, warnings, errors)
EDMSG_LOG_INFO = EDMSG_LOG_ALL + ('info',)
# Messages generated by ui events
EDMSG_LOG_EVENT = EDMSG_LOG_INFO + ('evt',)
# Recieve only warning messages
EDMSG_LOG_WARN = EDMSG_LOG_INFO + ('warn',)
# Recieve only error messages
EDMSG_LOG_ERROR = EDMSG_LOG_INFO + ('err',)
#---- End Log Messages ----#
#---- Configuration Messages ----#
# These messages will be sent when there are configuration
# changes in the current user profile. Messages will be in
# the format of (editra,config,PROFILE_KEY)
# mdata == Profile[PROFILE_KEY]
EDMSG_PROFILE_CHANGE = EDMSG_ALL + ('config',)
#---- End Configuration Messages ----#
#---- File Action Messages ----#
# Recieve notification of all file actions
EDMSG_FILE_ALL = EDMSG_ALL + ('file',)
# File open was just requested / msgdata == file path
EDMSG_FILE_OPENING = EDMSG_FILE_ALL + ('opening',)
# File was just opened / msgdata == file path
# context == MainWindows ID
EDMSG_FILE_OPENED = EDMSG_FILE_ALL + ('opened',)
# Get a list of all opened files
# msgdata == list of file paths (out param)
EDMSG_FILE_GET_OPENED = EDMSG_FILE_ALL + ('allopened',)
# TODO: using MainWindow as context for now, but may make more sense to use
# the buffer instead.
# File save requested / msgdata == (filename, filetypeId)
# context == MainWindows ID
# Note: All listeners of this message are processed *before* the save takes
# place. Meaning the listeners block the save action until they are
# finished.
EDMSG_FILE_SAVE = EDMSG_FILE_ALL + ('save',)
# File just written to disk / msgdata == (filename, filetypeId)
# context == MainWindows ID
EDMSG_FILE_SAVED = EDMSG_FILE_ALL + ('saved',)
#---- End File Action Messages ----#
#---- UI Action Messages ----#
# Recieve notification of all ui typed messages
EDMSG_UI_ALL = EDMSG_ALL + ('ui',)
#- Receive all Main Notebook Messages
EDMSG_UI_NB = EDMSG_UI_ALL + ('mnotebook',)
# MainWindow Activated
# msgdata == dict(active=bool)
# context = MainWindow ID
EDMSG_UI_MW_ACTIVATE = EDMSG_UI_ALL + ('mwactivate',)
# Notebook page changing
# msgdata == (ref to notebook,
# index of previous selection,
# index of current selection)
# context == MainWindow ID
EDMSG_UI_NB_CHANGING = EDMSG_UI_NB + ('pgchanging',)
# Notebook page changed
# msgdata == (ref to notebook, index of currently selected page)
# context == MainWindow ID
EDMSG_UI_NB_CHANGED = EDMSG_UI_NB + ('pgchanged',)
# Page is about to close
# msgdata == (ref to notebook, index of page that is closing)
# context == MainWindow ID
EDMSG_UI_NB_CLOSING = EDMSG_UI_NB + ('pgclosing',)
# Page has just been closed
# msgdata == (ref to notebook, index of page that is now selected)
# context == MainWindow ID
EDMSG_UI_NB_CLOSED = EDMSG_UI_NB + ('pgclosed',)
# Tab Menu requested
# msgdata == ContextMenuManager
# menu = ContextMenuManager.GetMenu()
# ContextMenuManager.AddHandler(ID_MENU_ID, handler(buffer, event))
# page = ContextMenuManager.GetUserData("page")
EDMSG_UI_NB_TABMENU = EDMSG_UI_NB + ('tabmenu',)
# Post message to show the progress indicator of the MainWindow
# msgdata == (frame id, True / False)
EDMSG_PROGRESS_SHOW = EDMSG_UI_ALL + ('statbar', 'progbar', 'show')
# Post this message to manipulate the state of the MainWindows status bar
# progress indicator. The message data should be a three tuple of the recipient
# frames id, current progress and the total range (current, total). If both
# values are 0 then the bar will be hidden. If both are negative the bar will
# be set into pulse mode. This message can safely be sent from background
# threads.
EDMSG_PROGRESS_STATE = EDMSG_UI_ALL + ('statbar', 'progbar', 'state')
# Set the status text
# msgdata == (field id, text)
EDMSG_UI_SB_TXT = EDMSG_UI_ALL + ('statbar', 'text')
## Text Buffer ##
# Root message for the text buffer
EDMSG_UI_STC_ALL = EDMSG_UI_ALL + ('stc',)
# msgdata == ((x, y), keycode)
# context == MainWindows ID
EDMSG_UI_STC_KEYUP = EDMSG_UI_STC_ALL + ('keyup',)
# msgdata == dict(lnum=line, cnum=column)
# context == MainWindows ID
EDMSG_UI_STC_POS_CHANGED = EDMSG_UI_STC_ALL + ('position',)
# msgdata == dict(fname=fname,
# prepos=pos, preline=line,
# lnum=cline, pos=cpos)
# context == MainWindow ID
EDMSG_UI_STC_POS_JUMPED = EDMSG_UI_STC_ALL + ('jump',)
# Editor control size restored (msgdata == None)
EDMSG_UI_STC_RESTORE = EDMSG_UI_STC_ALL + ('restore',)
# Lexer Changed
# msgdata == (filename, filetype id)
# context == MainWindows ID
EDMSG_UI_STC_LEXER = EDMSG_UI_STC_ALL + ('lexer',)
# Buffer Changed
# NOTE: this gets called ALOT so be very efficient in any handlers of it!
# msgdata == None
EDMSG_UI_STC_CHANGED = EDMSG_UI_STC_ALL + ('changed',)
# Customize Context Menu
# Add custom menu items and handlers to the buffers right click menu
# msgdata = ContextMenuManager
# ContextMenuManager.AddHandler(menu_id, handler)
# menu = ContextMenuManager.GetMenu()
# def handler(buffer, event_obj)
# ContextMenuManager.GetData('buffer')
EDMSG_UI_STC_CONTEXT_MENU = EDMSG_UI_STC_ALL + ('custommenu',)
# UserList Selection
# msgdata == dict(ltype=int, text=string, stc=EditraStc)
EDMSG_UI_STC_USERLIST_SEL = EDMSG_UI_STC_ALL + ('userlistsel',)
# Mouse Dwell Start
# mdata = dict(stc=self, pos=position,
# line=line_number,
# word=word_under_cursor
# rdata="")
# If the handler for this method wants to show a calltip
# it should set the rdata value
EDMSG_UI_STC_DWELL_START = EDMSG_UI_STC_ALL + ('dwellstart',)
# Mouse Dwell End
# mdata = None
EDMSG_UI_STC_DWELL_END = EDMSG_UI_STC_ALL + ('dwellend',)
# Bookmark (added/deleted)
# mdata = dict(stc=EditraStc, added=bool, line=line, handle=bookmarkhandle)
# NOTE: if line < 0, then all bookmarks removed
EDMSG_UI_STC_BOOKMARK = EDMSG_UI_STC_ALL + ('bookmark',)
# Margin Click
# mdata = dict(stc=EditraStc, line=line, handled=bool)
# handled is an out param in the message data. Set to True
# to indicate that the click was handled.
EDMSG_UI_STC_MARGIN_CLICK = EDMSG_UI_STC_ALL + ('marginclick',)
#---- End UI Action Messages ----#
#---- Menu Messages ----#
EDMSG_MENU = EDMSG_ALL + ('menu',)
# Signal to all windows to update keybindings (msgdata == None)
EDMSG_MENU_REBIND = EDMSG_MENU + ('rebind',)
# Message to set key profile
# msgdata == keyprofile name
EDMSG_MENU_LOADPROFILE = EDMSG_MENU + ('load',)
# Message to recreate the lexer menu
# msgdata == None
EDMSG_CREATE_LEXER_MENU = EDMSG_MENU + ('lexer',)
#---- End Menu Messages ----#
#---- Find Actions ----#
EDMSG_FIND_ALL = EDMSG_ALL + ('find',)
# Show or modify an existing find dialog
# msgdata = dict(mw, lookin, searchtxt, replacetxt)
EDMSG_FIND_SHOW_DLG = EDMSG_FIND_ALL + ('show',)
# Message to request a search job
# msgdata == (callable, args, kwargs)
# msgdata == (callable)
EDMSG_START_SEARCH = EDMSG_FIND_ALL + ('results',)
#---- End Find Actions ----#
#---- Session Related Actions ----#
# Root Session Message
EDMSG_SESSION_ALL = ('session',)
# Initiate a Session Save to save current session under new name.
# Note: This invokes a UI action to prompt the user on what to name
# the session. DO NOT call from background threads.
# send(msgdata == None) | context - MainWindow
EDMSG_SESSION_DO_SAVE = EDMSG_SESSION_ALL + ('dosave',)
# Initiate loading a session
# Causes all currently open files to be closed and the files from the
# specified session to be loaded. Not thread safe.
# send(msgdata == session_name)
EDMSG_SESSION_DO_LOAD = EDMSG_SESSION_ALL + ('doload',)
#---- End Session Related Actions ----#
#---- Misc Messages ----#
# Signal that the icon theme has changed. Respond to this to update icon
# resources from the ArtProvider.
EDMSG_THEME_CHANGED = EDMSG_ALL + ('theme',) # All theme listeners
# Update the theme the notebook specifically to the current preferences
EDMSG_THEME_NOTEBOOK = EDMSG_ALL + ('nb', 'theme')
# Signal that the font preferences for the ui have changed (msgdata == font)
EDMSG_DSP_FONT = EDMSG_ALL + ('dfont',)
# Add file to file history
# msgdata == filename
EDMSG_ADD_FILE_HISTORY = EDMSG_ALL + ('filehistory',)
#---- End Misc Messages ----#
#--------------------------------------------------------------------------#
# Public Api
_ThePublisher = Publisher()
def PostMessage(msgtype, msgdata=None, context=None):
"""Post a message containing the msgdata to all listeners that are
interested in the given msgtype from the given context. If context
is None than default context is assumed.
Message is always propagated to the default context.
@param msgtype: Message Type EDMSG_*
@keyword msgdata: Message data to pass to listener (can be anything)
@keyword context: Context of the message.
"""
_ThePublisher.sendMessage(msgtype, msgdata, context=context)
def Subscribe(callback, msgtype=EDMSG_ALL):
"""Subscribe your listener function to listen for an action of type msgtype.
The callback must be a function or a _bound_ method that accepts one
parameter for the actions message. The message that is sent to the callback
is a class object that has two attributes, one for the message type and the
other for the message data. See below example for how these two values can
be accessed.
>>> def MyCallback(msg):
print "Msg Type: ", msg.GetType(), "Msg Data: ", msg.GetData()
>>> class Foo:
def MyCallbackMeth(self, msg):
print "Msg Type: ", msg.GetType(), "Msg Data: ", msg.GetData()
>>> Subscribe(MyCallback, EDMSG_SOMETHING)
>>> myfoo = Foo()
>>> Subscribe(myfoo.MyCallBackMeth, EDMSG_SOMETHING)
@param callback: Callable function or bound method
@keyword msgtype: Message to subscribe to (default to all)
"""
_ThePublisher.subscribe(callback, msgtype)
def Unsubscribe(callback, messages=None):
"""Remove a listener so that it doesn't get sent messages for msgtype. If
msgtype is not specified the listener will be removed for all msgtypes that
it is associated with.
@param callback: Function or bound method to remove subscription for
@keyword messages: EDMSG_* val or list of EDMSG_* vals
"""
Publisher().unsubscribe(callback, messages)
#---- Helper Decorators ----#
def mwcontext(func):
"""Helper decorator for checking if the message is in context of the
main window. Class that uses this to wrap its message handlers must
have a GetMainWindow method that returns a reference to the MainWindow
instance that owns the object.
@param funct: callable(self, msg)
"""
def ContextWrap(self, msg):
"""Check and only call the method if the message is in the
context of the main window or no context was specified.
"""
if hasattr(self, 'GetMainWindow'):
mw = self.GetMainWindow()
elif hasattr(self, 'MainWindow'):
mw = self.MainWindow
else:
assert False, "Must declare a GetMainWindow method"
context = msg.GetContext()
if context is None or mw.GetId() == context:
func(self, msg)
ContextWrap.__name__ = func.__name__
ContextWrap.__doc__ = func.__doc__
return ContextWrap
def wincontext(funct):
"""Decorator to filter messages based on a window. Class must declare
a GetWindow method that returns the window that the messages context
should be filtered on.
@param funct: callable(self, msg)
"""
def ContextWrap(self, msg):
assert hasattr(self, 'GetWindow'), "Must define a GetWindow method"
context = msg.GetContext()
if isinstance(context, wx.Window) and context is self.GetWindow():
funct(self, msg)
ContextWrap.__name__ = funct.__name__
ContextWrap.__doc__ = funct.__doc__
return ContextWrap
#-----------------------------------------------------------------------------#
# Request Messages
EDREQ_ALL = ('editra', 'req')
EDREQ_DOCPOINTER = EDREQ_ALL + ('docpointer',)
#-----------------------------------------------------------------------------#
class NullValue:
"""Null value to signify that a callback method should be skipped or that
no callback could answer the request.
"""
def __int__(self):
return 0
def __nonzero__(self):
return False
def RegisterCallback(callback, msgtype):
"""Register a callback method for the given message type
@param callback: callable
@param msgtype: message type
"""
if isinstance(msgtype, tuple):
mtype = '.'.join(msgtype)
else:
mtype = msgtype
if mtype not in _CALLBACK_REGISTRY:
_CALLBACK_REGISTRY[mtype] = list()
if callback not in _CALLBACK_REGISTRY[mtype]:
_CALLBACK_REGISTRY[mtype].append(callback)
def RequestResult(msgtype, args=list()):
"""Request a return value result from a registered function/method.
If multiple callbacks have been registered for the given msgtype, the
first callback to return a non-NullValue will be used for the return
value. If L{NullValue} is returned then no callback could answer the
call.
@param msgtype: Request message
@keyword args: Arguments to pass to the callback
"""
if isinstance(msgtype, tuple):
mtype = '.'.join(msgtype)
else:
mtype = msgtype
to_remove = list()
rval = NullValue()
for idx, meth in enumerate(_CALLBACK_REGISTRY.get(mtype, list())):
try:
if len(args):
rval = meth(args)
else:
rval = meth()
except PyDeadObjectError:
to_remove.append(meth)
if not isinstance(rval, NullValue):
break
# Remove any dead objects that may have been found
for val in reversed(to_remove):
try:
_CALLBACK_REGISTRY.get(mtype, list()).pop(val)
except:
pass
return rval
def UnRegisterCallback(callback):
"""Un-Register a callback method
@param callback: callable
"""
for key, val in _CALLBACK_REGISTRY.iteritems():
if callback in val:
_CALLBACK_REGISTRY[key].remove(callback)
# Callback Registry for storing the methods sent in with RegisterCallback
_CALLBACK_REGISTRY = {}
#-----------------------------------------------------------------------------#
|
gpl-2.0
|
[
11490,
199,
3,
2812,
26,
3988,
63,
1328,
14,
647,
2476,
17907,
327,
199,
3,
23177,
4070,
26,
22896,
282,
30429,
15,
6761,
2656,
367,
5445,
10585,
315,
257,
327,
199,
3,
3515,
314,
8823,
14,
2476,
12788,
327,
199,
3,
6529,
26,
445,
1351,
510,
3059,
665,
67,
657,
1577,
32,
6297,
1239,
14,
1308,
30,
22456,
327,
199,
3,
1898,
26,
334,
67,
9,
9079,
445,
1351,
510,
3059,
665,
7018,
32,
6297,
1239,
14,
1308,
30,
12793,
327,
199,
3,
844,
26,
4818,
8647,
844,
2476,
8295,
327,
199,
11490,
199,
199,
624,
199,
2765,
859,
6571,
282,
10540,
19696,
402,
282,
18023,
6042,
7974,
954,
859,
199,
475,
8120,
652,
282,
1212,
3561,
351,
436,
28293,
6302,
367,
4503,
14,
2779,
22609,
7795,
2446,
199,
2474,
14,
710,
1642,
491,
91,
6564,
2209,
93,
1314,
365,
1202,
370,
2963,
282,
1245,
367,
1006,
199,
5707,
20032,
19946,
14,
710,
3499,
491,
91,
2610,
5355,
93,
1314,
6127,
376,
909,
370,
199,
10108,
2399,
5705,
11647,
805,
367,
282,
6770,
1245,
730,
12,
1006,
402,
199,
20957,
1239,
1159,
6170,
1245,
2943,
787,
3247,
315,
642,
859,
1808,
282,
19720,
199,
388,
18803,
626,
9174,
1924,
5148,
543,
473,
91,
1149,
9740,
63,
5565,
5723,
5148,
199,
5559,
883,
506,
1202,
370,
10405,
314,
1245,
730,
701,
20234,
3062,
543,
314,
199,
585,
402,
1499,
14,
24770,
315,
282,
11647,
1083,
14,
710,
10919,
1083,
365,
491,
91,
9251,
456,
5355,
93,
199,
6777,
883,
506,
1202,
370,
2813,
282,
11647,
687,
295,
559,
69,
4007,
3788,
14,
199,
199,
32,
4705,
26,
6430,
2656,
2986,
436,
1245,
730,
10269,
199,
199,
624,
199,
199,
363,
2502,
363,
275,
298,
35,
1351,
510,
3059,
665,
67,
657,
1577,
32,
6297,
1239,
14,
1308,
4335,
199,
363,
6836,
344,
363,
275,
7880,
1304,
26,
3988,
63,
1328,
14,
647,
1520,
975,
2576,
6029,
13,
1690,
13,
2036,
4114,
26,
1165,
26,
1081,
58,
445,
15819,
2672,
2,
199,
363,
5792,
363,
275,
7880,
12714,
26,
1520,
975,
2576,
2672,
2,
199,
199,
363,
452,
363,
275,
788,
6564,
2209,
297,
283,
2610,
5355,
297,
283,
9251,
456,
5355,
418,
199,
199,
7656,
9460,
3,
199,
3,
24339,
199,
504,
4818,
492,
1611,
22147,
1692,
547,
199,
504,
21815,
14,
20213,
492,
19952,
281,
199,
199,
7656,
9460,
3,
199,
3,
6430,
2434,
22659,
852,
199,
199,
3,
375,
1696,
27377,
4099,
3,
199,
199,
3,
491,
7938,
370,
1006,
3788,
199,
1149,
9740,
63,
1761,
275,
661,
6297,
1239,
9538,
199,
199,
3,
375,
9599,
1696,
27377,
4099,
3,
199,
199,
3,
375,
5297,
27377,
4099,
3,
199,
3,
8051,
14448,
701,
314,
943,
2656,
14,
491,
4957,
701,
7464,
18966,
1035,
15356,
199,
3,
2900,
1245,
666,
687,
3520,
3423,
787,
282,
5297,
6173,
909,
1314,
365,
282,
199,
3,
3970,
909,
367,
314,
1245,
1059,
1182,
4913,
1182,
730,
199,
3,
199,
3,
11719,
3520,
1245,
2943,
543,
314,
7711,
2209,
1083,
365,
440,
25697,
367,
199,
3,
675,
315,
922,
1233,
3140,
675,
314,
2050,
30242,
7999,
334,
6323,
14,
1002,
2640,
1252,
1002,
2445,
342,
503,
199,
3,
4884,
14,
1002,
793,
342,
776,
465,
2985,
911,
2429,
314,
10803,
626,
365,
1420,
701,
314,
221,
199,
3,
943,
30429,
19946,
14,
199,
199,
3,
799,
559,
4754,
1006,
943,
3788,
334,
73,
14,
69,
7003,
5324,
641,
314,
2050,
2656,
9,
199,
1149,
9740,
63,
4947,
63,
1761,
275,
662,
36,
9740,
63,
1761,
435,
661,
793,
9538,
199,
199,
3,
799,
559,
4754,
1006,
3788,
626,
1172,
2757,
634,
1909,
334,
815,
12,
4474,
12,
3598,
12,
2552,
9,
199,
1149,
9740,
63,
4947,
63,
4531,
275,
662,
36,
9740,
63,
4947,
63,
1761,
435,
661,
815,
9538,
199,
199,
3,
27377,
4046,
701,
8574,
4474,
199,
1149,
9740,
63,
4947,
63,
8193,
275,
662,
36,
9740,
63,
4947,
63,
4531,
435,
661,
19296,
9538,
199,
199,
3,
799,
559,
4754,
1454,
5721,
3788,
199,
1149,
9740,
63,
4947,
63,
17449,
275,
662,
36,
9740,
63,
4947,
63,
4531,
435,
661,
4050,
9538,
199,
199,
3,
799,
559,
4754,
1454,
1125,
3788,
199,
1149,
9740,
63,
4947,
63,
3170,
275,
662,
36,
9740,
63,
4947,
63,
4531,
435,
661,
1508,
9538,
199,
199,
3,
375,
9599,
5297,
27377,
4099,
3,
199,
199,
3,
375,
11595,
27377,
4099,
3,
199,
199,
3,
5723,
3788,
911,
506,
4847,
1380,
2337,
787,
2897,
199,
3,
4493,
315,
314,
1453,
922,
4690,
14,
27377,
911,
506,
315,
199,
3,
314,
1475,
402,
334,
6297,
1239,
12,
888,
12,
16632,
63,
3078,
9,
199,
3,
333,
576,
508,
14386,
59,
16632,
63,
3078,
61,
199,
1149,
9740,
63,
16632,
63,
16062,
275,
662,
36,
9740,
63,
1761,
435,
661,
888,
9538,
199,
199,
3,
375,
9599,
11595,
27377,
4099,
3,
199,
199,
3,
375,
3814,
10033,
27377,
4099,
3,
199,
199,
3,
799,
559,
4754,
6955,
402,
1006,
570,
5445,
199,
1149,
9740,
63,
3817,
63,
1761,
275,
662,
36,
9740,
63,
1761,
435,
661,
493,
9538,
199,
199,
3,
3814,
1551,
1990,
2951,
5839,
1182,
1499,
576,
508,
570,
931,
199,
1149,
9740,
63,
3817,
63,
9935,
1206,
275,
662,
36,
9740,
63,
3817,
63,
1761,
435,
661,
21849,
9538,
199,
199,
3,
3814,
1990,
2951,
12123,
1182,
1499,
576,
508,
570,
931,
199,
3,
1067,
508,
11298,
8647,
2870,
199,
1149,
9740,
63,
3817,
63,
9935,
1149,
275,
662,
36,
9740,
63,
3817,
63,
1761,
435,
661,
19234,
9538,
199,
199,
3,
2372,
282,
769,
402,
1006,
12123,
1584,
199,
3,
1499,
576,
508,
769,
402,
570,
3792,
334,
548,
1215,
9,
199,
1149,
9740,
63,
3817,
63,
2970,
63,
9935,
1149,
275,
662,
36,
9740,
63,
3817,
63,
1761,
435,
661,
279,
8329,
379,
9538,
199,
199,
3,
3254,
26,
1808,
11298,
4301,
465,
1067,
367,
3063,
12,
1325,
1443,
1852,
1655,
12249,
370,
675,
199,
3,
755,
314,
3335,
3140,
14,
199,
199,
3,
3814,
3354,
5839,
1182,
1499,
576,
508,
334,
1501,
12,
26245,
1304,
9,
199,
3,
1067,
508,
11298,
8647,
2870,
199,
3,
3390,
26,
2900,
19946,
402,
642,
1245,
787,
7686,
627,
5182
] |
[
199,
3,
2812,
26,
3988,
63,
1328,
14,
647,
2476,
17907,
327,
199,
3,
23177,
4070,
26,
22896,
282,
30429,
15,
6761,
2656,
367,
5445,
10585,
315,
257,
327,
199,
3,
3515,
314,
8823,
14,
2476,
12788,
327,
199,
3,
6529,
26,
445,
1351,
510,
3059,
665,
67,
657,
1577,
32,
6297,
1239,
14,
1308,
30,
22456,
327,
199,
3,
1898,
26,
334,
67,
9,
9079,
445,
1351,
510,
3059,
665,
7018,
32,
6297,
1239,
14,
1308,
30,
12793,
327,
199,
3,
844,
26,
4818,
8647,
844,
2476,
8295,
327,
199,
11490,
199,
199,
624,
199,
2765,
859,
6571,
282,
10540,
19696,
402,
282,
18023,
6042,
7974,
954,
859,
199,
475,
8120,
652,
282,
1212,
3561,
351,
436,
28293,
6302,
367,
4503,
14,
2779,
22609,
7795,
2446,
199,
2474,
14,
710,
1642,
491,
91,
6564,
2209,
93,
1314,
365,
1202,
370,
2963,
282,
1245,
367,
1006,
199,
5707,
20032,
19946,
14,
710,
3499,
491,
91,
2610,
5355,
93,
1314,
6127,
376,
909,
370,
199,
10108,
2399,
5705,
11647,
805,
367,
282,
6770,
1245,
730,
12,
1006,
402,
199,
20957,
1239,
1159,
6170,
1245,
2943,
787,
3247,
315,
642,
859,
1808,
282,
19720,
199,
388,
18803,
626,
9174,
1924,
5148,
543,
473,
91,
1149,
9740,
63,
5565,
5723,
5148,
199,
5559,
883,
506,
1202,
370,
10405,
314,
1245,
730,
701,
20234,
3062,
543,
314,
199,
585,
402,
1499,
14,
24770,
315,
282,
11647,
1083,
14,
710,
10919,
1083,
365,
491,
91,
9251,
456,
5355,
93,
199,
6777,
883,
506,
1202,
370,
2813,
282,
11647,
687,
295,
559,
69,
4007,
3788,
14,
199,
199,
32,
4705,
26,
6430,
2656,
2986,
436,
1245,
730,
10269,
199,
199,
624,
199,
199,
363,
2502,
363,
275,
298,
35,
1351,
510,
3059,
665,
67,
657,
1577,
32,
6297,
1239,
14,
1308,
4335,
199,
363,
6836,
344,
363,
275,
7880,
1304,
26,
3988,
63,
1328,
14,
647,
1520,
975,
2576,
6029,
13,
1690,
13,
2036,
4114,
26,
1165,
26,
1081,
58,
445,
15819,
2672,
2,
199,
363,
5792,
363,
275,
7880,
12714,
26,
1520,
975,
2576,
2672,
2,
199,
199,
363,
452,
363,
275,
788,
6564,
2209,
297,
283,
2610,
5355,
297,
283,
9251,
456,
5355,
418,
199,
199,
7656,
9460,
3,
199,
3,
24339,
199,
504,
4818,
492,
1611,
22147,
1692,
547,
199,
504,
21815,
14,
20213,
492,
19952,
281,
199,
199,
7656,
9460,
3,
199,
3,
6430,
2434,
22659,
852,
199,
199,
3,
375,
1696,
27377,
4099,
3,
199,
199,
3,
491,
7938,
370,
1006,
3788,
199,
1149,
9740,
63,
1761,
275,
661,
6297,
1239,
9538,
199,
199,
3,
375,
9599,
1696,
27377,
4099,
3,
199,
199,
3,
375,
5297,
27377,
4099,
3,
199,
3,
8051,
14448,
701,
314,
943,
2656,
14,
491,
4957,
701,
7464,
18966,
1035,
15356,
199,
3,
2900,
1245,
666,
687,
3520,
3423,
787,
282,
5297,
6173,
909,
1314,
365,
282,
199,
3,
3970,
909,
367,
314,
1245,
1059,
1182,
4913,
1182,
730,
199,
3,
199,
3,
11719,
3520,
1245,
2943,
543,
314,
7711,
2209,
1083,
365,
440,
25697,
367,
199,
3,
675,
315,
922,
1233,
3140,
675,
314,
2050,
30242,
7999,
334,
6323,
14,
1002,
2640,
1252,
1002,
2445,
342,
503,
199,
3,
4884,
14,
1002,
793,
342,
776,
465,
2985,
911,
2429,
314,
10803,
626,
365,
1420,
701,
314,
221,
199,
3,
943,
30429,
19946,
14,
199,
199,
3,
799,
559,
4754,
1006,
943,
3788,
334,
73,
14,
69,
7003,
5324,
641,
314,
2050,
2656,
9,
199,
1149,
9740,
63,
4947,
63,
1761,
275,
662,
36,
9740,
63,
1761,
435,
661,
793,
9538,
199,
199,
3,
799,
559,
4754,
1006,
3788,
626,
1172,
2757,
634,
1909,
334,
815,
12,
4474,
12,
3598,
12,
2552,
9,
199,
1149,
9740,
63,
4947,
63,
4531,
275,
662,
36,
9740,
63,
4947,
63,
1761,
435,
661,
815,
9538,
199,
199,
3,
27377,
4046,
701,
8574,
4474,
199,
1149,
9740,
63,
4947,
63,
8193,
275,
662,
36,
9740,
63,
4947,
63,
4531,
435,
661,
19296,
9538,
199,
199,
3,
799,
559,
4754,
1454,
5721,
3788,
199,
1149,
9740,
63,
4947,
63,
17449,
275,
662,
36,
9740,
63,
4947,
63,
4531,
435,
661,
4050,
9538,
199,
199,
3,
799,
559,
4754,
1454,
1125,
3788,
199,
1149,
9740,
63,
4947,
63,
3170,
275,
662,
36,
9740,
63,
4947,
63,
4531,
435,
661,
1508,
9538,
199,
199,
3,
375,
9599,
5297,
27377,
4099,
3,
199,
199,
3,
375,
11595,
27377,
4099,
3,
199,
199,
3,
5723,
3788,
911,
506,
4847,
1380,
2337,
787,
2897,
199,
3,
4493,
315,
314,
1453,
922,
4690,
14,
27377,
911,
506,
315,
199,
3,
314,
1475,
402,
334,
6297,
1239,
12,
888,
12,
16632,
63,
3078,
9,
199,
3,
333,
576,
508,
14386,
59,
16632,
63,
3078,
61,
199,
1149,
9740,
63,
16632,
63,
16062,
275,
662,
36,
9740,
63,
1761,
435,
661,
888,
9538,
199,
199,
3,
375,
9599,
11595,
27377,
4099,
3,
199,
199,
3,
375,
3814,
10033,
27377,
4099,
3,
199,
199,
3,
799,
559,
4754,
6955,
402,
1006,
570,
5445,
199,
1149,
9740,
63,
3817,
63,
1761,
275,
662,
36,
9740,
63,
1761,
435,
661,
493,
9538,
199,
199,
3,
3814,
1551,
1990,
2951,
5839,
1182,
1499,
576,
508,
570,
931,
199,
1149,
9740,
63,
3817,
63,
9935,
1206,
275,
662,
36,
9740,
63,
3817,
63,
1761,
435,
661,
21849,
9538,
199,
199,
3,
3814,
1990,
2951,
12123,
1182,
1499,
576,
508,
570,
931,
199,
3,
1067,
508,
11298,
8647,
2870,
199,
1149,
9740,
63,
3817,
63,
9935,
1149,
275,
662,
36,
9740,
63,
3817,
63,
1761,
435,
661,
19234,
9538,
199,
199,
3,
2372,
282,
769,
402,
1006,
12123,
1584,
199,
3,
1499,
576,
508,
769,
402,
570,
3792,
334,
548,
1215,
9,
199,
1149,
9740,
63,
3817,
63,
2970,
63,
9935,
1149,
275,
662,
36,
9740,
63,
3817,
63,
1761,
435,
661,
279,
8329,
379,
9538,
199,
199,
3,
3254,
26,
1808,
11298,
4301,
465,
1067,
367,
3063,
12,
1325,
1443,
1852,
1655,
12249,
370,
675,
199,
3,
755,
314,
3335,
3140,
14,
199,
199,
3,
3814,
3354,
5839,
1182,
1499,
576,
508,
334,
1501,
12,
26245,
1304,
9,
199,
3,
1067,
508,
11298,
8647,
2870,
199,
3,
3390,
26,
2900,
19946,
402,
642,
1245,
787,
7686,
627,
5182,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
hujiajie/pa-chromium
|
tools/telemetry/telemetry/core/extension_dict.py
|
35
|
1135
|
# 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.
from telemetry.core import extension_to_load
class ExtensionDict(object):
"""Dictionary of ExtensionPage instances, with extension_id as key"""
def __init__(self, extension_dict_backend):
self._extension_dict_backend = extension_dict_backend
def __getitem__(self, load_extension):
"""Given an ExtensionToLoad instance, returns the corresponding
ExtensionPage instance."""
if not isinstance(load_extension, extension_to_load.ExtensionToLoad):
raise Exception("Input param must be of type ExtensionToLoad")
return self._extension_dict_backend.__getitem__(
load_extension.extension_id)
def __contains__(self, load_extension):
"""Checks if this ExtensionToLoad instance has been loaded"""
if not isinstance(load_extension, extension_to_load.ExtensionToLoad):
raise Exception("Input param must be of type ExtensionToLoad")
return self._extension_dict_backend.__contains__(
load_extension.extension_id)
|
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,
504,
17298,
14,
1018,
492,
3329,
63,
475,
63,
912,
199,
199,
533,
13282,
2141,
8,
785,
304,
523,
408,
11728,
402,
13282,
3276,
4454,
12,
543,
3329,
63,
344,
465,
790,
624,
819,
347,
636,
826,
721,
277,
12,
3329,
63,
807,
63,
4620,
304,
272,
291,
423,
3435,
63,
807,
63,
4620,
275,
3329,
63,
807,
63,
4620,
819,
347,
636,
6095,
721,
277,
12,
2248,
63,
3435,
304,
272,
408,
13735,
376,
13282,
1378,
6200,
1256,
12,
2529,
314,
5226,
272,
13282,
3276,
1256,
1041,
272,
340,
440,
1228,
8,
912,
63,
3435,
12,
3329,
63,
475,
63,
912,
14,
6382,
1378,
6200,
304,
489,
746,
2186,
480,
3205,
1215,
1471,
506,
402,
730,
13282,
1378,
6200,
531,
272,
372,
291,
423,
3435,
63,
807,
63,
4620,
855,
6095,
721,
267,
2248,
63,
3435,
14,
3435,
63,
344,
9,
819,
347,
636,
6134,
721,
277,
12,
2248,
63,
3435,
304,
272,
408,
11834,
340,
642,
13282,
1378,
6200,
1256,
965,
2757,
6511,
624,
272,
340,
440,
1228,
8,
912,
63,
3435,
12,
3329,
63,
475,
63,
912,
14,
6382,
1378,
6200,
304,
489,
746,
2186,
480,
3205,
1215,
1471,
506,
402,
730,
13282,
1378,
6200,
531,
272,
372,
291,
423,
3435,
63,
807,
63,
4620,
855,
6134,
721,
267,
2248,
63,
3435,
14,
3435,
63,
344,
9,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,
504,
17298,
14,
1018,
492,
3329,
63,
475,
63,
912,
199,
199,
533,
13282,
2141,
8,
785,
304,
523,
408,
11728,
402,
13282,
3276,
4454,
12,
543,
3329,
63,
344,
465,
790,
624,
819,
347,
636,
826,
721,
277,
12,
3329,
63,
807,
63,
4620,
304,
272,
291,
423,
3435,
63,
807,
63,
4620,
275,
3329,
63,
807,
63,
4620,
819,
347,
636,
6095,
721,
277,
12,
2248,
63,
3435,
304,
272,
408,
13735,
376,
13282,
1378,
6200,
1256,
12,
2529,
314,
5226,
272,
13282,
3276,
1256,
1041,
272,
340,
440,
1228,
8,
912,
63,
3435,
12,
3329,
63,
475,
63,
912,
14,
6382,
1378,
6200,
304,
489,
746,
2186,
480,
3205,
1215,
1471,
506,
402,
730,
13282,
1378,
6200,
531,
272,
372,
291,
423,
3435,
63,
807,
63,
4620,
855,
6095,
721,
267,
2248,
63,
3435,
14,
3435,
63,
344,
9,
819,
347,
636,
6134,
721,
277,
12,
2248,
63,
3435,
304,
272,
408,
11834,
340,
642,
13282,
1378,
6200,
1256,
965,
2757,
6511,
624,
272,
340,
440,
1228,
8,
912,
63,
3435,
12,
3329,
63,
475,
63,
912,
14,
6382,
1378,
6200,
304,
489,
746,
2186,
480,
3205,
1215,
1471,
506,
402,
730,
13282,
1378,
6200,
531,
272,
372,
291,
423,
3435,
63,
807,
63,
4620,
855,
6134,
721,
267,
2248,
63,
3435,
14,
3435,
63,
344,
9,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,
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