max_stars_repo_path
stringlengths
4
237
max_stars_repo_name
stringlengths
6
117
max_stars_count
int64
0
95.2k
id
stringlengths
1
7
content
stringlengths
12
593k
input_ids
sequencelengths
7
549k
IAFNNESTA.py
JonathanAlis/IAFNNESTA
3
4124
def help(): return ''' Isotropic-Anisotropic Filtering Norm Nesterov Algorithm Solves the filtering norm minimization + quadratic term problem Nesterov algorithm, with continuation: argmin_x || iaFN(x) ||_1/2 subjected to ||b - Ax||_2^2 < delta If no filter is provided, solves the L1. Continuation is performed by sequentially applying Nesterov's algorithm with a decreasing sequence of values of mu0 >= mu >= muf The observation matrix A must be a projector (non projector not implemented yet) Inputs: IAFNNESTA(b, #Observed data, a m x 1 array A=identity,At=identity, # measurement matrix and adjoint (either a matrix, function handles) muf=0.0001, #final mu value, smaller leads to higher accuracy delta, #l2 error bound. This enforces how close the variable #must fit the observations b, i.e. || y - Ax ||_2 <= delta #If delta = 0, enforces y = Ax #delta = sqrt(m + 2*sqrt(2*m))*sigma, where sigma=std(noise). L1w=1,L2w=0, #weights of L1 (anisotropic) and L2(isotropic) norms verbose=0, #whether to print internal steps maxit=1000, #maximum iterations at the inner loop x0=[], #initial solution, if not provided, will be At(b) U=identity,Ut=identity, #Analysis/Synthesis operators stopTest=1, #stopTest == 1 : stop when the relative change in the objective function is less than TolVar stopTest == 2 : stop with the l_infinity norm of difference in the xk variable is less than TolVar TolVar = 1e-5, #tolerance for the stopping criteria AAtinv=[], #not implemented normU=1, #if U is provided, this should be norm(U) H=[],Ht=[]): #filter operations in sparse matrix form #also accepts the string 'tv' as input, #in that case, calculates the tv norm Outputs: return xk, #estimated x reconstructed signal niter, #number of iterations residuals #first column is the residual at every step, #second column is the value of f_mu at every step ''' import IAFNNesterov import numpy as np from scipy import sparse import fil2mat def identity(x): return x def IAFNNESTA(b,sig_size=0,A=identity,At=identity,muf=0.0001,delta=0,L1w=1,L2w=0,verbose=0,MaxIntIter=5,maxit=1000,x0=[],U=identity,Ut=identity,stopTest=1,TolVar = 1e-5,AAtinv=[],normU=1,H=[]): if delta<0: raise Exception('Delta must not be negative') if not callable(A): #If not function A=lambda x:np.matmul(A,x) At=lambda x:np.matmul(np.transpose(A),x) b=b.reshape((-1,1)) Atb=At(b) if sig_size==0: sig_size=Atb.shape if callable(AAtinv): AtAAtb = At( AAtinv(b) ) else: if len(AAtinv)>0: AAtinv=lambda x: np.matmul(AAtinv,x) AtAAtb = At( AAtinv(b) ) else: #default AtAAtb = Atb AAtinv=identity if len(x0)==0: x0 = AtAAtb if len(H)==0: Hf=identity Hft=identity else: if not sparse.issparse(H): if isinstance(H, str): if H=='tv': hs=[] hs.append(np.array([[1,-1]])) hs.append(np.array([[1],[-1]])) H,_,_,_=fil2mat.fil2mat(hs,sig_size) else: print('H not recognized. Must be a sparse matrix, a list of filters or the string tv') else: #list of filters: H,_,_,_=fil2mat.fil2mat(H,sig_size) #print(H.shape) #print(H) #print(type(H)) Ht=H.transpose() Hf=lambda x: H@x Hft=lambda x: Ht@x HU=lambda x: Hf(U(x)) UtHt=lambda x: Ut(Hft(x)) typemin='' if L1w>0: typemin+="iso" if L2w>0: typemin+="aniso" typemin+='tropic ' if callable(H): typemin+='filtering norm ' mu0=0 if L1w>0: mu0+=L1w*0.9*np.max(np.linalg.norm(HU(x0),1)) if L2w>0: mu0+=L2w*0.9*np.max(np.linalg.norm(HU(x0),2)) niter = 0 Gamma = np.power(muf/mu0,1/MaxIntIter) mu = mu0 Gammat= np.power(TolVar/0.1,1/MaxIntIter) TolVar = 0.1 for i in range(MaxIntIter): mu = mu*Gamma TolVar=TolVar*Gammat; if verbose>0: #if k%verbose==0: print("\tBeginning %s Minimization; mu = %g\n" %(typemin,mu)) xk,niter_int,res = IAFNNesterov.IAFNNesterov(b,A=A,At=At,mu=mu,delta=delta,L1w=L1w,L2w=L2w,verbose=verbose,maxit=maxit,x0=x0,U=U,Ut=Ut,stopTest=stopTest,TolVar = TolVar,AAtinv=AAtinv,normU=normU,H=Hf,Ht=Hft) xplug = xk niter = niter_int + niter if i==0: residuals=res else: residuals = np.vstack((residuals, res)) return xk.reshape(sig_size) if __name__ == "__main__": print(help())
[ 1, 822, 1371, 7295, 13, 1678, 736, 14550, 13, 3624, 28467, 293, 29899, 2744, 275, 28467, 293, 19916, 292, 5655, 405, 4156, 586, 29068, 13, 13, 13296, 1960, 278, 21166, 6056, 6260, 2133, 718, 25904, 1840, 1108, 13, 29940, 4156, 586, 5687, 29892, 411, 3133, 362, 29901, 13, 13, 268, 1852, 1195, 29918, 29916, 3830, 259, 423, 29943, 29940, 29898, 29916, 29897, 3830, 29918, 29896, 29914, 29906, 4967, 287, 304, 3830, 29890, 448, 22523, 8876, 29918, 29906, 29985, 29906, 529, 19471, 13, 13, 3644, 694, 4175, 338, 4944, 29892, 24307, 278, 365, 29896, 29889, 13, 13, 1323, 8675, 362, 338, 8560, 491, 8617, 9247, 15399, 405, 4156, 586, 29915, 29879, 5687, 13, 2541, 263, 9263, 5832, 5665, 310, 1819, 310, 29871, 3887, 29900, 6736, 3887, 6736, 286, 1137, 13, 13, 1576, 15500, 4636, 319, 1818, 367, 263, 2060, 272, 313, 5464, 2060, 272, 451, 8762, 3447, 29897, 13, 13, 4290, 29879, 29901, 13, 29902, 5098, 29940, 8186, 1254, 29909, 29898, 29890, 29892, 462, 418, 396, 6039, 643, 1490, 848, 29892, 263, 286, 921, 29871, 29896, 1409, 13, 9651, 319, 29922, 22350, 29892, 4178, 29922, 22350, 29892, 268, 396, 20039, 4636, 322, 594, 12090, 313, 29872, 2121, 263, 4636, 29892, 740, 17766, 29897, 462, 13, 9651, 286, 1137, 29922, 29900, 29889, 29900, 29900, 29900, 29896, 29892, 462, 396, 8394, 3887, 995, 29892, 7968, 11981, 304, 6133, 13600, 13, 9651, 19471, 29892, 462, 418, 396, 29880, 29906, 1059, 3216, 29889, 910, 24555, 778, 920, 3802, 278, 2286, 13, 462, 462, 4706, 396, 21969, 6216, 278, 13917, 289, 29892, 474, 29889, 29872, 29889, 3830, 343, 448, 22523, 3830, 29918, 29906, 5277, 19471, 13, 462, 462, 4706, 396, 3644, 19471, 353, 29871, 29900, 29892, 24555, 778, 343, 353, 22523, 13, 462, 462, 4706, 396, 4181, 353, 18074, 2273, 29898, 29885, 718, 29871, 29906, 29930, 3676, 29898, 29906, 29930, 29885, 876, 29930, 3754, 29892, 988, 269, 2934, 29922, 4172, 29898, 1217, 895, 467, 13, 9651, 365, 29896, 29893, 29922, 29896, 29892, 29931, 29906, 29893, 29922, 29900, 29892, 18884, 396, 705, 5861, 310, 365, 29896, 313, 273, 275, 28467, 293, 29897, 322, 365, 29906, 29898, 275, 28467, 293, 29897, 6056, 29879, 13, 9651, 26952, 29922, 29900, 29892, 462, 29871, 396, 1332, 1979, 304, 1596, 7463, 6576, 29871, 13, 9651, 4236, 277, 29922, 29896, 29900, 29900, 29900, 29892, 462, 396, 27525, 398, 24372, 472, 278, 6426, 2425, 13, 9651, 921, 29900, 11759, 1402, 462, 418, 396, 11228, 1650, 29892, 565, 451, 4944, 29892, 674, 367, 2180, 29898, 29890, 29897, 13, 9651, 501, 29922, 22350, 29892, 29965, 29873, 29922, 22350, 29892, 268, 396, 21067, 4848, 29914, 29216, 26533, 12768, 13, 9651, 5040, 3057, 29922, 29896, 29892, 462, 396, 9847, 3057, 1275, 29871, 29896, 584, 5040, 746, 278, 6198, 1735, 297, 278, 12091, 29871, 13, 462, 462, 4706, 740, 338, 3109, 1135, 16977, 9037, 13, 462, 462, 4706, 5040, 3057, 1275, 29871, 29906, 584, 5040, 411, 278, 301, 29918, 262, 4951, 537, 6056, 310, 4328, 297, 29871, 13, 462, 462, 4706, 278, 921, 29895, 2286, 338, 3109, 1135, 16977, 9037, 29871, 13, 9651, 16977, 9037, 353, 29871, 29896, 29872, 29899, 29945, 29892, 795, 396, 25027, 261, 749, 363, 278, 25480, 16614, 13, 9651, 319, 4178, 11569, 11759, 1402, 462, 29871, 396, 1333, 8762, 13, 9651, 6056, 29965, 29922, 29896, 29892, 462, 1678, 396, 361, 501, 338, 4944, 29892, 445, 881, 367, 6056, 29898, 29965, 29897, 13, 9651, 379, 11759, 1402, 29950, 29873, 29922, 2636, 1125, 18884, 396, 4572, 6931, 297, 29234, 4636, 883, 13, 462, 462, 4706, 396, 15189, 21486, 278, 1347, 525, 12427, 29915, 408, 1881, 29892, 29871, 13, 462, 462, 4706, 396, 262, 393, 1206, 29892, 3408, 1078, 278, 9631, 6056, 13, 6466, 29879, 29901, 13, 2457, 29871, 921, 29895, 29892, 462, 632, 396, 342, 326, 630, 921, 337, 11433, 287, 7182, 13, 4706, 302, 1524, 29892, 462, 3986, 396, 4537, 310, 24372, 13, 4706, 10995, 27101, 462, 539, 396, 4102, 1897, 338, 278, 10995, 950, 472, 1432, 4331, 29892, 13, 462, 462, 4706, 396, 7496, 1897, 338, 278, 995, 310, 285, 29918, 2589, 472, 1432, 4331, 13, 13, 13, 12008, 13, 13, 5215, 306, 5098, 10262, 4156, 586, 13, 5215, 12655, 408, 7442, 13, 3166, 4560, 2272, 1053, 29234, 13, 5215, 977, 29906, 2922, 13, 1753, 10110, 29898, 29916, 1125, 13, 1678, 736, 921, 13, 13, 1753, 306, 5098, 29940, 8186, 1254, 29909, 29898, 29890, 29892, 18816, 29918, 2311, 29922, 29900, 29892, 29909, 29922, 22350, 29892, 4178, 29922, 22350, 29892, 29885, 1137, 29922, 29900, 29889, 29900, 29900, 29900, 29896, 29892, 4181, 29922, 29900, 29892, 29931, 29896, 29893, 29922, 29896, 29892, 29931, 29906, 29893, 29922, 29900, 29892, 369, 15828, 29922, 29900, 29892, 7976, 2928, 13463, 29922, 29945, 29892, 3317, 277, 29922, 29896, 29900, 29900, 29900, 29892, 29916, 29900, 11759, 1402, 29965, 29922, 22350, 29892, 29965, 29873, 29922, 22350, 29892, 9847, 3057, 29922, 29896, 29892, 29911, 324, 9037, 353, 29871, 29896, 29872, 29899, 29945, 29892, 29909, 4178, 11569, 11759, 1402, 12324, 29965, 29922, 29896, 29892, 29950, 29922, 2636, 1125, 13, 13, 1678, 565, 19471, 29966, 29900, 29901, 13, 4706, 12020, 8960, 877, 5268, 1818, 451, 367, 8178, 1495, 13, 13, 1678, 565, 451, 1246, 519, 29898, 29909, 1125, 396, 3644, 451, 740, 13, 4706, 319, 29922, 2892, 921, 29901, 9302, 29889, 2922, 16109, 29898, 29909, 29892, 29916, 29897, 13, 4706, 2180, 29922, 2892, 921, 29901, 9302, 29889, 2922, 16109, 29898, 9302, 29889, 3286, 4220, 29898, 29909, 511, 29916, 29897, 13, 268, 13, 1678, 289, 29922, 29890, 29889, 690, 14443, 3552, 29899, 29896, 29892, 29896, 876, 13, 1678, 2180, 29890, 29922, 4178, 29898, 29890, 29897, 13, 1678, 565, 4365, 29918, 2311, 1360, 29900, 29901, 13, 4706, 4365, 29918, 2311, 29922, 4178, 29890, 29889, 12181, 13, 308, 13, 1678, 565, 1246, 519, 29898, 29909, 4178, 11569, 1125, 13, 4706, 2180, 29909, 4178, 29890, 353, 2180, 29898, 319, 4178, 11569, 29898, 29890, 29897, 1723, 13, 1678, 1683, 29901, 13, 4706, 565, 7431, 29898, 29909, 4178, 11569, 15410, 29900, 29901, 13, 9651, 319, 4178, 11569, 29922, 2892, 921, 29901, 7442, 29889, 2922, 16109, 29898, 29909, 4178, 11569, 29892, 29916, 29897, 13, 9651, 2180, 29909, 4178, 29890, 353, 2180, 29898, 319, 4178, 11569, 29898, 29890, 29897, 1723, 13, 4706, 1683, 29901, 396, 4381, 13, 9651, 2180, 29909, 4178, 29890, 353, 2180, 29890, 13, 9651, 319, 4178, 11569, 29922, 22350, 13, 268, 13, 1678, 565, 7431, 29898, 29916, 29900, 29897, 1360, 29900, 29901, 13, 4706, 921, 29900, 353, 2180, 29909, 4178, 29890, 29871, 13, 13, 1678, 565, 7431, 29898, 29950, 29897, 1360, 29900, 29901, 13, 4706, 379, 29888, 29922, 22350, 13, 4706, 379, 615, 29922, 22350, 13, 1678, 1683, 29901, 632, 13, 4706, 565, 451, 29234, 29889, 790, 5510, 29898, 29950, 1125, 13, 9651, 565, 338, 8758, 29898, 29950, 29892, 851, 1125, 13, 18884, 565, 379, 1360, 29915, 12427, 2396, 13, 462, 1678, 298, 29879, 29922, 2636, 13, 462, 1678, 298, 29879, 29889, 4397, 29898, 9302, 29889, 2378, 4197, 29961, 29896, 6653, 29896, 5262, 876, 13, 462, 1678, 298, 29879, 29889, 4397, 29898, 9302, 29889, 2378, 4197, 29961, 29896, 1402, 14352, 29896, 5262, 876, 13, 462, 1678, 379, 29892, 3383, 3383, 29918, 29922, 1777, 29906, 2922, 29889, 1777, 29906, 2922, 29898, 9499, 29892, 18816, 29918, 2311, 29897, 13, 18884, 1683, 29901, 13, 462, 1678, 1596, 877, 29950, 451, 14831, 29889, 19928, 367, 263, 29234, 4636, 29892, 263, 1051, 310, 18094, 470, 278, 1347, 9631, 1495, 632, 13, 9651, 1683, 29901, 308, 13, 18884, 396, 1761, 310, 18094, 29901, 13, 18884, 379, 29892, 3383, 3383, 29918, 29922, 1777, 29906, 2922, 29889, 1777, 29906, 2922, 29898, 29950, 29892, 18816, 29918, 2311, 29897, 29871, 13, 4706, 396, 2158, 29898, 29950, 29889, 12181, 29897, 13, 4706, 396, 2158, 29898, 29950, 29897, 13, 4706, 396, 2158, 29898, 1853, 29898, 29950, 876, 13, 4706, 379, 29873, 29922, 29950, 29889, 3286, 4220, 580, 13, 4706, 379, 29888, 29922, 2892, 921, 29901, 379, 29992, 29916, 13, 4706, 379, 615, 29922, 2892, 921, 29901, 379, 29873, 29992, 29916, 13, 13, 1678, 379, 29965, 29922, 2892, 921, 29901, 379, 29888, 29898, 29965, 29898, 29916, 876, 13, 1678, 14950, 29950, 29873, 29922, 2892, 921, 29901, 14950, 29898, 29950, 615, 29898, 29916, 876, 13, 268, 13, 268, 13, 13, 268, 13, 308, 13, 1678, 2393, 331, 262, 2433, 29915, 13, 1678, 565, 365, 29896, 29893, 29958, 29900, 29901, 13, 4706, 2393, 331, 262, 29974, 543, 10718, 29908, 13, 1678, 565, 365, 29906, 29893, 29958, 29900, 29901, 13, 4706, 2393, 331, 262, 29974, 543, 273, 10718, 29908, 13, 1678, 2393, 331, 262, 29974, 2433, 29873, 1336, 293, 525, 13, 1678, 565, 1246, 519, 29898, 29950, 1125, 13, 4706, 2393, 331, 262, 29974, 2433, 4572, 292, 6056, 525, 268, 13, 13, 1678, 3887, 29900, 29922, 29900, 13, 1678, 565, 365, 29896, 29893, 29958, 29900, 29901, 13, 4706, 3887, 29900, 23661, 29931, 29896, 29893, 29930, 29900, 29889, 29929, 29930, 9302, 29889, 3317, 29898, 9302, 29889, 29880, 979, 29887, 29889, 12324, 29898, 29950, 29965, 29898, 29916, 29900, 511, 29896, 876, 13, 1678, 565, 365, 29906, 29893, 29958, 29900, 29901, 13, 4706, 3887, 29900, 23661, 29931, 29906, 29893, 29930, 29900, 29889, 29929, 29930, 9302, 29889, 3317, 29898, 9302, 29889, 29880, 979, 29887, 29889, 12324, 29898, 29950, 29965, 29898, 29916, 29900, 511, 29906, 876, 13, 13, 1678, 302, 1524, 353, 29871, 29900, 13, 1678, 402, 2735, 353, 7442, 29889, 13519, 29898, 29885, 1137, 29914, 2589, 29900, 29892, 29896, 29914, 7976, 2928, 13463, 29897, 13, 1678, 3887, 353, 3887, 29900, 13, 1678, 28011, 2922, 29922, 7442, 29889, 13519, 29898, 29911, 324, 9037, 29914, 29900, 29889, 29896, 29892, 29896, 29914, 7976, 2928, 13463, 29897, 13, 1678, 16977, 9037, 353, 29871, 29900, 29889, 29896, 13, 268, 13, 1678, 363, 474, 297, 3464, 29898, 7976, 2928, 13463, 1125, 268, 13, 4706, 3887, 353, 3887, 29930, 6642, 13, 4706, 16977, 9037, 29922, 29911, 324, 9037, 29930, 29954, 314, 2922, 29936, 268, 13, 4706, 565, 26952, 29958, 29900, 29901, 13, 9651, 396, 361, 413, 29995, 369, 15828, 1360, 29900, 29901, 13, 9651, 1596, 14182, 29873, 17946, 1076, 1273, 29879, 3080, 326, 2133, 29936, 3887, 353, 1273, 29887, 29905, 29876, 29908, 1273, 29898, 22449, 331, 262, 29892, 2589, 876, 13, 632, 13, 13, 4706, 921, 29895, 29892, 29876, 1524, 29918, 524, 29892, 690, 353, 306, 5098, 10262, 4156, 586, 29889, 29902, 5098, 10262, 4156, 586, 29898, 29890, 29892, 29909, 29922, 29909, 29892, 4178, 29922, 4178, 29892, 2589, 29922, 2589, 29892, 4181, 29922, 4181, 29892, 29931, 29896, 29893, 29922, 29931, 29896, 29893, 29892, 29931, 29906, 29893, 29922, 29931, 29906, 29893, 29892, 369, 15828, 29922, 369, 15828, 29892, 3317, 277, 29922, 3317, 277, 29892, 29916, 29900, 29922, 29916, 29900, 29892, 29965, 29922, 29965, 29892, 29965, 29873, 29922, 29965, 29873, 29892, 9847, 3057, 29922, 9847, 3057, 29892, 29911, 324, 9037, 353, 16977, 9037, 29892, 29909, 4178, 11569, 29922, 29909, 4178, 11569, 29892, 12324, 29965, 29922, 12324, 29965, 29892, 29950, 29922, 29950, 29888, 29892, 29950, 29873, 29922, 29950, 615, 29897, 13, 308, 13, 4706, 921, 572, 688, 353, 921, 29895, 13, 4706, 302, 1524, 353, 302, 1524, 29918, 524, 718, 302, 1524, 13, 4706, 565, 474, 1360, 29900, 29901, 13, 9651, 10995, 27101, 29922, 690, 13, 4706, 1683, 29901, 13, 9651, 10995, 27101, 353, 7442, 29889, 29894, 1429, 3552, 690, 333, 27101, 29892, 620, 876, 13, 268, 13, 1678, 736, 921, 29895, 29889, 690, 14443, 29898, 18816, 29918, 2311, 29897, 13, 13, 13, 361, 4770, 978, 1649, 1275, 376, 1649, 3396, 1649, 1115, 13, 13, 1678, 1596, 29898, 8477, 3101, 13, 2 ]
src/main.py
Merk0ff/PicRandomFromImgur
0
46128
import urllib.request import random import time import os from bs4 import BeautifulSoup chars = ["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","0","1","2","3","4","5","6","7","8","9"] def GenerateUrl_postfix(): return random.choice(chars) + random.choice(chars) + random.choice(chars) + random.choice(chars) \ + random.choice(chars) def GenerateUrl(): url = 'https://imgur.com/' + GenerateUrl_postfix() try: urllib.request.urlopen(url, timeout=1) except urllib.error.URLError as e: print(url + " : " + str(e)) return -1 return url def GetImg( url ): try: html = urllib.request.urlopen(url, timeout=1) except urllib.error.URLError as e: print(url + ' : ' + str(e)) return soup = BeautifulSoup(html, "html.parser") img_src = soup.img['src'] if len(img_src) > 0: ex = img_src[14:] try: urllib.request.urlretrieve("https:" + img_src, "img/file_" + ex) except urllib.error.URLError as e: print("Some hell is going on: " + str(e)) def LoadProxy(): list = [] with open("./src/proxy.list", "r") as file: for line in file: list.append(line[0:-2]) return list def ConnectToProxy( proxy ): proxy = urllib.request.ProxyHandler({'http': proxy}) opener = urllib.request.build_opener(proxy) urllib.request.install_opener(opener) print("Proxy changed") def main(): i = 0 elem = 1 Plist = LoadProxy() ConnectToProxy(Plist[0]) while not False: if i >= 10: ConnectToProxy(Plist[elem]) elem += 1 if elem >= len(Plist): elem = 0 i = 0 url = GenerateUrl() if url != -1: GetImg(url) with open("log.txt", "a") as file: file.write(url + "\n") i += 1 time.sleep(0.1) if not os.path.exists("img"): os.makedirs("img") main()
[ 1, 1053, 3142, 1982, 29889, 3827, 13, 5215, 4036, 13, 5215, 931, 13, 5215, 2897, 13, 3166, 24512, 29946, 1053, 25685, 29903, 1132, 13, 13, 305, 1503, 353, 6796, 29909, 3284, 29933, 3284, 29907, 3284, 29928, 3284, 29923, 3284, 29943, 3284, 29954, 3284, 29950, 3284, 29902, 3284, 29967, 3284, 29968, 3284, 29931, 3284, 29924, 3284, 29940, 3284, 29949, 3284, 29925, 3284, 29984, 3284, 29934, 3284, 29903, 3284, 29911, 3284, 29965, 3284, 29963, 3284, 29956, 3284, 29990, 3284, 29979, 3284, 29999, 3284, 29874, 3284, 29890, 3284, 29883, 3284, 29881, 3284, 29872, 3284, 29888, 3284, 29887, 3284, 29882, 3284, 29875, 3284, 29926, 3284, 29895, 3284, 29880, 3284, 29885, 3284, 29876, 3284, 29877, 3284, 29886, 3284, 29939, 3284, 29878, 3284, 29879, 3284, 29873, 3284, 29884, 3284, 29894, 3284, 29893, 3284, 29916, 3284, 29891, 3284, 29920, 3284, 29900, 3284, 29896, 3284, 29906, 3284, 29941, 3284, 29946, 3284, 29945, 3284, 29953, 3284, 29955, 3284, 29947, 3284, 29929, 3108, 13, 13, 1753, 3251, 403, 5983, 29918, 2490, 5878, 7295, 13, 1678, 736, 4036, 29889, 16957, 29898, 305, 1503, 29897, 718, 4036, 29889, 16957, 29898, 305, 1503, 29897, 718, 4036, 29889, 16957, 29898, 305, 1503, 29897, 718, 4036, 29889, 16957, 29898, 305, 1503, 29897, 320, 13, 965, 718, 4036, 29889, 16957, 29898, 305, 1503, 29897, 13, 13, 1753, 3251, 403, 5983, 7295, 13, 13, 1678, 3142, 353, 525, 991, 597, 3320, 29889, 510, 22208, 718, 3251, 403, 5983, 29918, 2490, 5878, 580, 13, 13, 1678, 1018, 29901, 13, 4706, 3142, 1982, 29889, 3827, 29889, 332, 417, 2238, 29898, 2271, 29892, 11815, 29922, 29896, 29897, 13, 1678, 5174, 3142, 1982, 29889, 2704, 29889, 4574, 1307, 24616, 408, 321, 29901, 13, 4706, 1596, 29898, 2271, 718, 376, 584, 376, 718, 851, 29898, 29872, 876, 13, 4706, 736, 448, 29896, 13, 13, 1678, 736, 3142, 13, 13, 13, 1753, 3617, 25518, 29898, 3142, 29871, 1125, 13, 13, 1678, 1018, 29901, 13, 4706, 3472, 353, 3142, 1982, 29889, 3827, 29889, 332, 417, 2238, 29898, 2271, 29892, 11815, 29922, 29896, 29897, 13, 1678, 5174, 3142, 1982, 29889, 2704, 29889, 4574, 1307, 24616, 408, 321, 29901, 13, 4706, 1596, 29898, 2271, 718, 525, 584, 525, 718, 851, 29898, 29872, 876, 13, 4706, 736, 13, 13, 1678, 22300, 353, 25685, 29903, 1132, 29898, 1420, 29892, 376, 1420, 29889, 16680, 1159, 13, 13, 1678, 10153, 29918, 4351, 353, 22300, 29889, 2492, 1839, 4351, 2033, 13, 13, 1678, 565, 7431, 29898, 2492, 29918, 4351, 29897, 1405, 29871, 29900, 29901, 13, 4706, 429, 353, 10153, 29918, 4351, 29961, 29896, 29946, 17531, 13, 4706, 1018, 29901, 13, 9651, 3142, 1982, 29889, 3827, 29889, 2271, 276, 509, 2418, 703, 991, 6160, 718, 10153, 29918, 4351, 29892, 376, 2492, 29914, 1445, 27508, 718, 429, 29897, 13, 4706, 5174, 3142, 1982, 29889, 2704, 29889, 4574, 1307, 24616, 408, 321, 29901, 13, 9651, 1596, 703, 9526, 23927, 338, 2675, 373, 29901, 376, 718, 851, 29898, 29872, 876, 13, 13, 1753, 16012, 14048, 7295, 13, 1678, 1051, 353, 5159, 13, 13, 1678, 411, 1722, 703, 6904, 4351, 29914, 14701, 29889, 1761, 613, 376, 29878, 1159, 408, 934, 29901, 13, 4706, 363, 1196, 297, 934, 29901, 13, 9651, 1051, 29889, 4397, 29898, 1220, 29961, 29900, 13018, 29906, 2314, 13, 13, 1678, 736, 1051, 13, 13, 1753, 14971, 1762, 14048, 29898, 10166, 29871, 1125, 13, 1678, 10166, 353, 3142, 1982, 29889, 3827, 29889, 14048, 4598, 3319, 29915, 1124, 2396, 10166, 1800, 13, 1678, 1015, 759, 353, 3142, 1982, 29889, 3827, 29889, 4282, 29918, 459, 759, 29898, 14701, 29897, 13, 1678, 3142, 1982, 29889, 3827, 29889, 6252, 29918, 459, 759, 29898, 459, 759, 29897, 13, 1678, 1596, 703, 14048, 3939, 1159, 13, 13, 1753, 1667, 7295, 13, 1678, 474, 353, 29871, 29900, 13, 1678, 21268, 353, 29871, 29896, 13, 13, 1678, 349, 1761, 353, 16012, 14048, 580, 13, 1678, 14971, 1762, 14048, 29898, 29925, 1761, 29961, 29900, 2314, 13, 13, 1678, 1550, 451, 7700, 29901, 13, 13, 4706, 565, 474, 6736, 29871, 29896, 29900, 29901, 13, 9651, 14971, 1762, 14048, 29898, 29925, 1761, 29961, 20461, 2314, 13, 9651, 21268, 4619, 29871, 29896, 13, 13, 9651, 565, 21268, 6736, 7431, 29898, 29925, 1761, 1125, 13, 18884, 21268, 353, 29871, 29900, 13, 13, 9651, 474, 353, 29871, 29900, 13, 13, 4706, 3142, 353, 3251, 403, 5983, 580, 13, 13, 4706, 565, 3142, 2804, 448, 29896, 29901, 13, 9651, 3617, 25518, 29898, 2271, 29897, 13, 9651, 411, 1722, 703, 1188, 29889, 3945, 613, 376, 29874, 1159, 408, 934, 29901, 13, 18884, 934, 29889, 3539, 29898, 2271, 718, 6634, 29876, 1159, 13, 13, 4706, 474, 4619, 29871, 29896, 13, 4706, 931, 29889, 17059, 29898, 29900, 29889, 29896, 29897, 13, 13, 13, 361, 451, 2897, 29889, 2084, 29889, 9933, 703, 2492, 29908, 1125, 13, 1678, 2897, 29889, 29885, 12535, 12935, 703, 2492, 1159, 13, 13, 3396, 580, 13, 2 ]
tests/test_successful_registration.py
jg-725/IS219-FlaskAppProject
0
158118
"""This test's if user successfully registered """ def test_successful_register(successful_registration): assert successful_registration.email == '<EMAIL>' assert successful_registration.password == 'Password' assert successful_registration.confirm == 'Password' response = successful_registration.get("/dashboard") assert response.status_code == 302 assert b'Congrats, registration success' in response.data
[ 1, 9995, 4013, 1243, 29915, 29879, 565, 1404, 8472, 15443, 9995, 13, 13, 1753, 1243, 29918, 8698, 1319, 29918, 9573, 29898, 8698, 1319, 29918, 1727, 8306, 1125, 13, 1678, 4974, 9150, 29918, 1727, 8306, 29889, 5269, 1275, 12801, 26862, 6227, 16299, 13, 1678, 4974, 9150, 29918, 1727, 8306, 29889, 5630, 1275, 525, 10048, 29915, 13, 1678, 4974, 9150, 29918, 1727, 8306, 29889, 26897, 1275, 525, 10048, 29915, 13, 1678, 2933, 353, 9150, 29918, 1727, 8306, 29889, 657, 11974, 14592, 3377, 1159, 13, 1678, 4974, 2933, 29889, 4882, 29918, 401, 1275, 29871, 29941, 29900, 29906, 13, 1678, 4974, 289, 29915, 29907, 549, 29878, 1446, 29892, 22583, 2551, 29915, 297, 2933, 29889, 1272, 2 ]
Utils/Matrix.py
valavanisleonidas/Machine_Learning_Toolkit
0
10763
<reponame>valavanisleonidas/Machine_Learning_Toolkit import os import platform import numpy class Matrix: def __init__(self): if platform.system() == "Windows": self.delimiterForPath = "\\" else: self.delimiterForPath = "/" self.labelsDType = numpy.int32 self.imagesDType = numpy.float32 def deleteRows(self, array, rows, axis): return numpy.delete(array, rows, axis) def swapAxes(self, array, axe1, axe2): return numpy.swapaxes(array, axe1, axe2) def getImageCategoryFromPath(self, imagePath): # path in format : ..\\Category\\ImageName return numpy.array(imagePath.split(self.delimiterForPath, len(imagePath))[ len(imagePath.split(self.delimiterForPath, len(imagePath))) - 2], dtype=self.labelsDType) def getNumberOfClasses(self, array): return len(numpy.unique(array)) def getImagesInDirectory(self, folderPath, extensions=('.jpg', '.jpeg', '.png', '.bmp', '.gif')): imagesList = [] assert os.path.isdir(folderPath), 'No folder with that name exists : %r ' % folderPath # for all images in folder path for root, dirs, files in os.walk(folderPath): for name in files: if name.endswith(extensions): imagesList.append(root + self.delimiterForPath + name) return imagesList def addDimension(self, array, axis): return numpy.expand_dims(a=array, axis=axis) def ExtractImages(self, folderPath, image_size=(256, 256), convertion=None, imageChannels=3, preprocessImages=False ,normalize=True ,normalizeRange=(0,1) ): from Images.ImageProcessing import ImageProcessing imageList = self.getImagesInDirectory(folderPath=folderPath) assert len(imageList) > 0, 'No images in folder : %r' % folderPath if convertion != "Grayscale" and imageChannels != 3: if convertion == None: convertion = "RGB" raise ValueError(' %r supports only 3 image channels!' % convertion) images_list = [] labels_list = [] # for all images in folder path for imagePath in imageList: # get category of image and add category to array labels_list.append( self.getImageCategoryFromPath(imagePath=imagePath)) # get image array and add image to array images_list.append( ImageProcessing().getImageArray(imagePath=imagePath, imageSize=image_size, convertion=convertion, imageChannels=imageChannels,preprocessImages=preprocessImages, Normalize=normalize,NormalizeRange=normalizeRange)) # convert lists to numpy array allLabelsArray = numpy.array(labels_list).reshape(len(labels_list)) allImagesArray = numpy.array(images_list).reshape(len(imageList), imageChannels, image_size[0], image_size[1]) return [allImagesArray, allLabelsArray] # returns batches from data with size batchSize def chunker(self,data, batchSize): return (data[pos:pos + batchSize] for pos in xrange(0, len(data), batchSize)) def shuffleMatrix(self,array): numpy.random.shuffle(array) def shuffleMatrixAlongWithLabels(self, array1, array2): # shuffle array1 (images) with corresponding labels array2 from random import shuffle array1_shuf = [] array2_shuf = [] index_shuf = range(len(array1)) shuffle(index_shuf) for i in index_shuf: array1_shuf.append(array1[i]) array2_shuf.append(array2[i]) return [numpy.array(array1_shuf, dtype=self.imagesDType).astype('float32'), numpy.array(array2_shuf, dtype=self.labelsDType).astype('float32')] def TakeExamplesFromEachCategory(self,features,labels,maxImagesPerCategory=10): import gc import os validationArray = [] validation_labels=[] # for 0 to number of output classes for index in range(0,self.getNumberOfClasses(labels)): print ('mpika 1') # find indexes of category index indexes = numpy.where(labels == index) # if train has 1 instance don't take it for validation if len(indexes[0]) in [ 0 , 1 ]: continue # if instances are less than max categories given if len(indexes[0]) <= maxImagesPerCategory: # take half for validation maxImagesPerCategory= len(indexes[0])/2 print ('mpika 2') assert len(indexes[0]) >= maxImagesPerCategory ,\ "Error : Validation examples per category more than train instances. Category: {0}" \ " validation pes category : {1} , training examples : {2} ".format(index,maxImagesPerCategory,len(indexes[0]),) count = 0 # for indexes in category for catIndex in indexes[0]: print ('mpika 3') count +=1 if count > maxImagesPerCategory: print ('mpika 3.1') break print ('mpika 3.2') validationArray.append(features[catIndex]) print ('mpika 3.3') validation_labels.append(labels[catIndex ]) print ('mpika 3.4 catIndex' , catIndex) features = numpy.delete(features,catIndex,axis=0) print ('mpika 3.5') labels = numpy.delete(labels,catIndex,axis=0) print ('mpika 3.6') gc.collect() print ('mpika 4') return [features, numpy.array(validationArray,dtype=self.imagesDType).astype('float32'), labels, numpy.array(validation_labels,dtype=self.labelsDType).astype('int32')] def takeLastExamples(self,trainArray, train_labels, validationPercentage=.2): # take validationPercentage of training data for validation validationExamples = int(validationPercentage * len(trainArray)) # We reserve the last validationExamples training examples for validation. trainArray, validationArray = trainArray[:-validationExamples], trainArray[-validationExamples:] train_labels, validation_labels = train_labels[:-validationExamples], train_labels[-validationExamples:] return [trainArray, validationArray, train_labels, validation_labels] def SplitTrainValidation(self, trainArray, train_labels, validationPercentage=.2,takeLastExamples=False,maxImagesPerCategory=10): if takeLastExamples: return self.takeLastExamples(trainArray, train_labels, validationPercentage) else: return self.TakeExamplesFromEachCategory(trainArray, train_labels,maxImagesPerCategory) def moveFile(self, src, dest): import shutil shutil.move(src, dest) if __name__ == '__main__': trainFolder = 'C:\Users\l.valavanis\Desktop\Clef2013\TrainSet' testFolder = 'C:\Users\l.valavanis\Desktop\Clef2013\TestSet' # # trainFolder = 'C:\Users\l.valavanis\Desktop\Clef2013\SampleImages - Copy' # testFolder = 'C:\Users\l.valavanis\Desktop\Clef2013\SampleImages - Copy - Copy' # # # trainFolder = '/home/leonidas/Desktop/images/train' # # testFolder = '/home/leonidas/Desktop/images/test' # # [trainArray, train_labels, testArray, test_labels, validationArray, validation_labels, outputClasses] = \ # load_dataset(trainFolder, testFolder,imageSize=(3,3),convertion='L',imageChannels=1) # # print trainArray.shape # print trainArray # # print validation_labels # # print train_labels # # print trainArray # # print trainArray.shape # print train_labels.shape # print testArray.shape # print test_labels.shape # print validationArray.shape # print validation_labels.shape # # trainPath = 'C:\\Users\\l.valavanis\\Desktop\\Clef2013\\GBoC\Features\\train_2x2_CIELab_512.txt' # testPath = 'C:\\Users\\l.valavanis\\Desktop\\Clef2013\\GBoC\Features\\test_2x2_CIELab_512.txt' # trainLabelPath = 'C:\\Users\\l.valavanis\\Desktop\\Clef2013\\GBoC\Features\\train_2x2_CIELab_512_labels.txt' # testLabelPath = 'C:\\Users\\l.valavanis\\Desktop\\Clef2013\\GBoC\Features\\test_2x2_CIELab_512_labels.txt' # [trainArray, train_labels, testArray, test_labels, validationArray, validation_labels, # outputClasses] = loadFeatures(trainPath=trainPath, trainLabels=trainLabelPath, testPath=testPath, # testLabels=testLabelPath); i=0; for trainArray,train_labels in Matrix().getArrayOfImagesUsingMiniBatches(folderPath=trainFolder,image_size=(100,100),batch_size=15): print (trainArray.shape) print (train_labels.shape) i+=len(trainArray) print "aaasdasdas d : ",i # # print validation_labels # # print train_labels # # print trainArray # # print trainArray.shape # print train_labels.shape # print testArray.shape # print test_labels.shape # print validationArray.shape # print validation_labels.shape
[ 1, 529, 276, 1112, 420, 29958, 791, 29080, 275, 280, 265, 8817, 29914, 29076, 29918, 29931, 799, 1076, 29918, 12229, 7354, 13, 5215, 2897, 13, 5215, 7481, 13, 5215, 12655, 13, 13, 13, 1990, 22513, 29901, 13, 1678, 822, 4770, 2344, 12035, 1311, 1125, 13, 4706, 565, 7481, 29889, 5205, 580, 1275, 376, 7685, 1115, 13, 9651, 1583, 29889, 6144, 19657, 2831, 2605, 353, 376, 1966, 29908, 13, 4706, 1683, 29901, 13, 9651, 1583, 29889, 6144, 19657, 2831, 2605, 353, 5591, 29908, 13, 13, 4706, 1583, 29889, 21134, 29928, 1542, 353, 12655, 29889, 524, 29941, 29906, 13, 4706, 1583, 29889, 8346, 29928, 1542, 353, 12655, 29889, 7411, 29941, 29906, 13, 13, 1678, 822, 5217, 10661, 29898, 1311, 29892, 1409, 29892, 4206, 29892, 9685, 1125, 13, 4706, 736, 12655, 29889, 8143, 29898, 2378, 29892, 4206, 29892, 9685, 29897, 13, 13, 1678, 822, 17945, 29909, 9100, 29898, 1311, 29892, 1409, 29892, 4853, 29872, 29896, 29892, 4853, 29872, 29906, 1125, 13, 4706, 736, 12655, 29889, 26276, 1165, 267, 29898, 2378, 29892, 4853, 29872, 29896, 29892, 4853, 29872, 29906, 29897, 13, 13, 1678, 822, 679, 2940, 10900, 4591, 2605, 29898, 1311, 29892, 1967, 2605, 1125, 13, 4706, 396, 2224, 297, 3402, 584, 6317, 1966, 10900, 1966, 2940, 1170, 13, 13, 4706, 736, 12655, 29889, 2378, 29898, 3027, 2605, 29889, 5451, 29898, 1311, 29889, 6144, 19657, 2831, 2605, 29892, 7431, 29898, 3027, 2605, 876, 29961, 13, 462, 1669, 7431, 29898, 3027, 2605, 29889, 5451, 29898, 1311, 29889, 6144, 19657, 2831, 2605, 29892, 7431, 29898, 3027, 2605, 4961, 448, 29871, 29906, 1402, 26688, 29922, 1311, 29889, 21134, 29928, 1542, 29897, 13, 13, 1678, 822, 679, 4557, 2776, 27403, 29898, 1311, 29892, 1409, 1125, 13, 4706, 736, 7431, 29898, 23749, 29889, 13092, 29898, 2378, 876, 13, 13, 1678, 822, 679, 20163, 797, 9882, 29898, 1311, 29892, 4138, 2605, 29892, 17752, 29922, 12839, 6173, 742, 15300, 26568, 742, 15300, 2732, 742, 15300, 29890, 1526, 742, 15300, 18660, 8785, 29901, 13, 4706, 4558, 1293, 353, 5159, 13, 4706, 4974, 2897, 29889, 2084, 29889, 275, 3972, 29898, 12083, 2605, 511, 525, 3782, 4138, 411, 393, 1024, 4864, 584, 1273, 29878, 525, 1273, 4138, 2605, 13, 4706, 396, 363, 599, 4558, 297, 4138, 2224, 13, 4706, 363, 3876, 29892, 4516, 29879, 29892, 2066, 297, 2897, 29889, 20919, 29898, 12083, 2605, 1125, 13, 9651, 363, 1024, 297, 2066, 29901, 13, 18884, 565, 1024, 29889, 1975, 2541, 29898, 24299, 1125, 13, 462, 1678, 4558, 1293, 29889, 4397, 29898, 4632, 718, 1583, 29889, 6144, 19657, 2831, 2605, 718, 1024, 29897, 13, 4706, 736, 4558, 1293, 13, 13, 1678, 822, 788, 16142, 2673, 29898, 1311, 29892, 1409, 29892, 9685, 1125, 13, 4706, 736, 12655, 29889, 18837, 29918, 6229, 29879, 29898, 29874, 29922, 2378, 29892, 9685, 29922, 8990, 29897, 13, 13, 1678, 822, 7338, 1461, 20163, 29898, 1311, 29892, 4138, 2605, 29892, 1967, 29918, 2311, 7607, 29906, 29945, 29953, 29892, 29871, 29906, 29945, 29953, 511, 3588, 291, 29922, 8516, 29892, 1967, 1451, 12629, 29922, 29941, 29892, 13, 462, 29871, 758, 5014, 20163, 29922, 8824, 1919, 8945, 675, 29922, 5574, 1919, 8945, 675, 6069, 7607, 29900, 29892, 29896, 29897, 29871, 1125, 13, 4706, 515, 1954, 1179, 29889, 2940, 7032, 292, 1053, 7084, 7032, 292, 13, 13, 4706, 1967, 1293, 353, 1583, 29889, 657, 20163, 797, 9882, 29898, 12083, 2605, 29922, 12083, 2605, 29897, 13, 4706, 4974, 7431, 29898, 3027, 1293, 29897, 1405, 29871, 29900, 29892, 525, 3782, 4558, 297, 4138, 584, 1273, 29878, 29915, 1273, 4138, 2605, 13, 4706, 565, 3588, 291, 2804, 376, 29954, 764, 7052, 29908, 322, 1967, 1451, 12629, 2804, 29871, 29941, 29901, 13, 9651, 565, 3588, 291, 1275, 6213, 29901, 13, 18884, 3588, 291, 353, 376, 28212, 29908, 13, 9651, 12020, 7865, 2392, 877, 1273, 29878, 11286, 871, 29871, 29941, 1967, 18196, 20714, 1273, 3588, 291, 29897, 13, 13, 4706, 4558, 29918, 1761, 353, 5159, 13, 4706, 11073, 29918, 1761, 353, 5159, 13, 4706, 396, 363, 599, 4558, 297, 4138, 2224, 13, 4706, 363, 1967, 2605, 297, 1967, 1293, 29901, 13, 9651, 396, 679, 7663, 310, 1967, 322, 788, 7663, 304, 1409, 13, 9651, 11073, 29918, 1761, 29889, 4397, 29898, 13, 18884, 1583, 29889, 657, 2940, 10900, 4591, 2605, 29898, 3027, 2605, 29922, 3027, 2605, 876, 13, 9651, 396, 679, 1967, 1409, 322, 788, 1967, 304, 1409, 13, 9651, 4558, 29918, 1761, 29889, 4397, 29898, 13, 18884, 7084, 7032, 292, 2141, 657, 2940, 2588, 29898, 3027, 2605, 29922, 3027, 2605, 29892, 1967, 3505, 29922, 3027, 29918, 2311, 29892, 3588, 291, 29922, 13441, 291, 29892, 13, 462, 462, 18884, 1967, 1451, 12629, 29922, 3027, 1451, 12629, 29892, 1457, 5014, 20163, 29922, 1457, 5014, 20163, 29892, 13, 462, 462, 18884, 21981, 675, 29922, 8945, 675, 29892, 19077, 675, 6069, 29922, 8945, 675, 6069, 876, 13, 13, 4706, 396, 3588, 8857, 304, 12655, 1409, 13, 4706, 599, 4775, 29879, 2588, 353, 12655, 29889, 2378, 29898, 21134, 29918, 1761, 467, 690, 14443, 29898, 2435, 29898, 21134, 29918, 1761, 876, 13, 4706, 599, 20163, 2588, 353, 12655, 29889, 2378, 29898, 8346, 29918, 1761, 467, 690, 14443, 29898, 2435, 29898, 3027, 1293, 511, 1967, 1451, 12629, 29892, 1967, 29918, 2311, 29961, 29900, 1402, 1967, 29918, 2311, 29961, 29896, 2314, 13, 13, 4706, 736, 518, 497, 20163, 2588, 29892, 599, 4775, 29879, 2588, 29962, 13, 13, 1678, 396, 3639, 9853, 267, 515, 848, 411, 2159, 9853, 3505, 13, 1678, 822, 19875, 261, 29898, 1311, 29892, 1272, 29892, 9853, 3505, 1125, 13, 4706, 736, 313, 1272, 29961, 1066, 29901, 1066, 718, 9853, 3505, 29962, 363, 926, 297, 921, 3881, 29898, 29900, 29892, 7431, 29898, 1272, 511, 9853, 3505, 876, 13, 13, 1678, 822, 528, 21897, 14609, 29898, 1311, 29892, 2378, 1125, 13, 4706, 12655, 29889, 8172, 29889, 845, 21897, 29898, 2378, 29897, 13, 13, 1678, 822, 528, 21897, 14609, 2499, 549, 3047, 4775, 29879, 29898, 1311, 29892, 1409, 29896, 29892, 1409, 29906, 1125, 13, 4706, 396, 528, 21897, 1409, 29896, 313, 8346, 29897, 411, 6590, 11073, 1409, 29906, 13, 4706, 515, 4036, 1053, 528, 21897, 13, 13, 4706, 1409, 29896, 29918, 845, 1137, 353, 5159, 13, 4706, 1409, 29906, 29918, 845, 1137, 353, 5159, 13, 4706, 2380, 29918, 845, 1137, 353, 3464, 29898, 2435, 29898, 2378, 29896, 876, 13, 4706, 528, 21897, 29898, 2248, 29918, 845, 1137, 29897, 13, 4706, 363, 474, 297, 2380, 29918, 845, 1137, 29901, 13, 9651, 1409, 29896, 29918, 845, 1137, 29889, 4397, 29898, 2378, 29896, 29961, 29875, 2314, 13, 9651, 1409, 29906, 29918, 845, 1137, 29889, 4397, 29898, 2378, 29906, 29961, 29875, 2314, 13, 4706, 736, 518, 23749, 29889, 2378, 29898, 2378, 29896, 29918, 845, 1137, 29892, 26688, 29922, 1311, 29889, 8346, 29928, 1542, 467, 579, 668, 877, 7411, 29941, 29906, 5477, 12655, 29889, 2378, 29898, 2378, 29906, 29918, 845, 1137, 29892, 26688, 29922, 1311, 29889, 21134, 29928, 1542, 467, 579, 668, 877, 7411, 29941, 29906, 1495, 29962, 13, 13, 1678, 822, 11190, 1252, 9422, 4591, 9760, 10900, 29898, 1311, 29892, 22100, 29892, 21134, 29892, 3317, 20163, 5894, 10900, 29922, 29896, 29900, 1125, 13, 4706, 1053, 330, 29883, 13, 4706, 1053, 2897, 13, 13, 4706, 8845, 2588, 353, 5159, 13, 4706, 8845, 29918, 21134, 29922, 2636, 13, 4706, 396, 363, 29871, 29900, 304, 1353, 310, 1962, 4413, 13, 4706, 363, 2380, 297, 3464, 29898, 29900, 29892, 1311, 29889, 657, 4557, 2776, 27403, 29898, 21134, 22164, 13, 9651, 1596, 6702, 1526, 4106, 29871, 29896, 1495, 13, 9651, 396, 1284, 18111, 310, 7663, 2380, 13, 9651, 18111, 353, 12655, 29889, 3062, 29898, 21134, 1275, 2380, 29897, 13, 9651, 396, 565, 7945, 756, 29871, 29896, 2777, 1016, 29915, 29873, 2125, 372, 363, 8845, 13, 9651, 565, 7431, 29898, 2248, 267, 29961, 29900, 2314, 297, 518, 29871, 29900, 1919, 29871, 29896, 4514, 29901, 13, 18884, 6773, 13, 9651, 396, 565, 8871, 526, 3109, 1135, 4236, 13997, 2183, 13, 9651, 565, 7431, 29898, 2248, 267, 29961, 29900, 2314, 5277, 4236, 20163, 5894, 10900, 29901, 13, 18884, 396, 2125, 4203, 363, 8845, 13, 18884, 4236, 20163, 5894, 10900, 29922, 7431, 29898, 2248, 267, 29961, 29900, 2314, 29914, 29906, 13, 9651, 1596, 6702, 1526, 4106, 29871, 29906, 1495, 13, 9651, 4974, 7431, 29898, 2248, 267, 29961, 29900, 2314, 6736, 4236, 20163, 5894, 10900, 1919, 29905, 13, 18884, 376, 2392, 584, 15758, 362, 6455, 639, 7663, 901, 1135, 7945, 8871, 29889, 17943, 29901, 426, 29900, 5038, 320, 13, 18884, 376, 8845, 8928, 7663, 584, 426, 29896, 29913, 1919, 6694, 6455, 584, 426, 29906, 29913, 11393, 4830, 29898, 2248, 29892, 3317, 20163, 5894, 10900, 29892, 2435, 29898, 2248, 267, 29961, 29900, 11724, 29897, 13, 13, 9651, 2302, 353, 29871, 29900, 13, 9651, 396, 363, 18111, 297, 7663, 13, 9651, 363, 6635, 3220, 297, 18111, 29961, 29900, 5387, 13, 18884, 1596, 6702, 1526, 4106, 29871, 29941, 1495, 13, 18884, 2302, 4619, 29896, 13, 18884, 565, 2302, 1405, 4236, 20163, 5894, 10900, 29901, 13, 462, 1678, 1596, 6702, 1526, 4106, 29871, 29941, 29889, 29896, 1495, 13, 462, 1678, 2867, 13, 18884, 1596, 6702, 1526, 4106, 29871, 29941, 29889, 29906, 1495, 13, 18884, 8845, 2588, 29889, 4397, 29898, 22100, 29961, 4117, 3220, 2314, 13, 18884, 1596, 6702, 1526, 4106, 29871, 29941, 29889, 29941, 1495, 13, 18884, 8845, 29918, 21134, 29889, 4397, 29898, 21134, 29961, 4117, 3220, 29871, 2314, 13, 18884, 1596, 6702, 1526, 4106, 29871, 29941, 29889, 29946, 6635, 3220, 29915, 1919, 6635, 3220, 29897, 13, 18884, 5680, 353, 12655, 29889, 8143, 29898, 22100, 29892, 4117, 3220, 29892, 8990, 29922, 29900, 29897, 13, 18884, 1596, 6702, 1526, 4106, 29871, 29941, 29889, 29945, 1495, 13, 18884, 11073, 353, 12655, 29889, 8143, 29898, 21134, 29892, 4117, 3220, 29892, 8990, 29922, 29900, 29897, 13, 18884, 1596, 6702, 1526, 4106, 29871, 29941, 29889, 29953, 1495, 13, 18884, 330, 29883, 29889, 15914, 580, 13, 4706, 1596, 6702, 1526, 4106, 29871, 29946, 1495, 13, 4706, 736, 518, 22100, 29892, 12655, 29889, 2378, 29898, 18157, 2588, 29892, 29881, 1853, 29922, 1311, 29889, 8346, 29928, 1542, 467, 579, 668, 877, 7411, 29941, 29906, 5477, 11073, 29892, 13, 18884, 12655, 29889, 2378, 29898, 18157, 29918, 21134, 29892, 29881, 1853, 29922, 1311, 29889, 21134, 29928, 1542, 467, 579, 668, 877, 524, 29941, 29906, 1495, 29962, 13, 13, 1678, 822, 2125, 8897, 1252, 9422, 29898, 1311, 29892, 14968, 2588, 29892, 7945, 29918, 21134, 29892, 8845, 27933, 482, 21098, 29906, 1125, 13, 4706, 396, 2125, 8845, 27933, 482, 310, 6694, 848, 363, 8845, 13, 4706, 8845, 1252, 9422, 353, 938, 29898, 18157, 27933, 482, 334, 7431, 29898, 14968, 2588, 876, 13, 13, 4706, 396, 1334, 23986, 278, 1833, 8845, 1252, 9422, 6694, 6455, 363, 8845, 29889, 13, 4706, 7945, 2588, 29892, 8845, 2588, 353, 7945, 2588, 7503, 29899, 18157, 1252, 9422, 1402, 7945, 2588, 14352, 18157, 1252, 9422, 17531, 13, 4706, 7945, 29918, 21134, 29892, 8845, 29918, 21134, 353, 7945, 29918, 21134, 7503, 29899, 18157, 1252, 9422, 1402, 7945, 29918, 21134, 14352, 18157, 1252, 9422, 17531, 13, 13, 4706, 736, 518, 14968, 2588, 29892, 8845, 2588, 29892, 7945, 29918, 21134, 29892, 8845, 29918, 21134, 29962, 13, 13, 1678, 822, 26178, 5323, 262, 19448, 29898, 1311, 29892, 7945, 2588, 29892, 7945, 29918, 21134, 29892, 8845, 27933, 482, 21098, 29906, 29892, 19730, 8897, 1252, 9422, 29922, 8824, 29892, 3317, 20163, 5894, 10900, 29922, 29896, 29900, 1125, 13, 4706, 565, 2125, 8897, 1252, 9422, 29901, 13, 9651, 736, 1583, 29889, 19730, 8897, 1252, 9422, 29898, 14968, 2588, 29892, 7945, 29918, 21134, 29892, 8845, 27933, 482, 29897, 13, 4706, 1683, 29901, 13, 9651, 736, 1583, 29889, 26772, 1252, 9422, 4591, 9760, 10900, 29898, 14968, 2588, 29892, 7945, 29918, 21134, 29892, 3317, 20163, 5894, 10900, 29897, 13, 13, 1678, 822, 4337, 2283, 29898, 1311, 29892, 4765, 29892, 2731, 1125, 13, 4706, 1053, 528, 4422, 13, 4706, 528, 4422, 29889, 11631, 29898, 4351, 29892, 2731, 29897, 13, 13, 361, 4770, 978, 1649, 1275, 525, 1649, 3396, 1649, 2396, 13, 13, 1678, 7945, 12924, 353, 525, 29907, 3583, 5959, 29905, 29880, 29889, 791, 29080, 275, 29905, 17600, 29905, 29907, 25874, 29906, 29900, 29896, 29941, 29905, 5323, 262, 2697, 29915, 13, 1678, 1243, 12924, 353, 525, 29907, 3583, 5959, 29905, 29880, 29889, 791, 29080, 275, 29905, 17600, 29905, 29907, 25874, 29906, 29900, 29896, 29941, 29905, 3057, 2697, 29915, 13, 1678, 396, 13, 1678, 396, 7945, 12924, 353, 525, 29907, 3583, 5959, 29905, 29880, 29889, 791, 29080, 275, 29905, 17600, 29905, 29907, 25874, 29906, 29900, 29896, 29941, 29905, 17708, 20163, 448, 14187, 29915, 13, 1678, 396, 1243, 12924, 353, 525, 29907, 3583, 5959, 29905, 29880, 29889, 791, 29080, 275, 29905, 17600, 29905, 29907, 25874, 29906, 29900, 29896, 29941, 29905, 17708, 20163, 448, 14187, 448, 14187, 29915, 13, 1678, 396, 13, 1678, 396, 396, 7945, 12924, 353, 8207, 5184, 29914, 280, 265, 8817, 29914, 17600, 29914, 8346, 29914, 14968, 29915, 13, 1678, 396, 396, 1243, 12924, 353, 8207, 5184, 29914, 280, 265, 8817, 29914, 17600, 29914, 8346, 29914, 1688, 29915, 13, 1678, 396, 13, 1678, 396, 518, 14968, 2588, 29892, 7945, 29918, 21134, 29892, 1243, 2588, 29892, 1243, 29918, 21134, 29892, 8845, 2588, 29892, 8845, 29918, 21134, 29892, 1962, 27403, 29962, 353, 320, 13, 1678, 396, 2254, 29918, 24713, 29898, 14968, 12924, 29892, 1243, 12924, 29892, 3027, 3505, 7607, 29941, 29892, 29941, 511, 13441, 291, 2433, 29931, 742, 3027, 1451, 12629, 29922, 29896, 29897, 13, 1678, 396, 13, 1678, 396, 1596, 7945, 2588, 29889, 12181, 13, 1678, 396, 1596, 7945, 2588, 13, 1678, 396, 396, 1596, 8845, 29918, 21134, 13, 1678, 396, 396, 1596, 7945, 29918, 21134, 13, 1678, 396, 396, 1596, 7945, 2588, 13, 1678, 396, 13, 1678, 396, 1596, 7945, 2588, 29889, 12181, 13, 1678, 396, 1596, 7945, 29918, 21134, 29889, 12181, 13, 1678, 396, 1596, 1243, 2588, 29889, 12181, 13, 1678, 396, 1596, 1243, 29918, 21134, 29889, 12181, 13, 1678, 396, 1596, 8845, 2588, 29889, 12181, 13, 1678, 396, 1596, 8845, 29918, 21134, 29889, 12181, 13, 1678, 396, 13, 1678, 396, 7945, 2605, 353, 525, 29907, 22298, 5959, 1966, 29880, 29889, 791, 29080, 275, 1966, 17600, 1966, 29907, 25874, 29906, 29900, 29896, 29941, 1966, 7210, 29877, 29907, 29905, 8263, 3698, 1966, 14968, 29918, 29906, 29916, 29906, 29918, 8426, 6670, 370, 29918, 29945, 29896, 29906, 29889, 3945, 29915, 13, 1678, 396, 1243, 2605, 353, 525, 29907, 22298, 5959, 1966, 29880, 29889, 791, 29080, 275, 1966, 17600, 1966, 29907, 25874, 29906, 29900, 29896, 29941, 1966, 7210, 29877, 29907, 29905, 8263, 3698, 1966, 1688, 29918, 29906, 29916, 29906, 29918, 8426, 6670, 370, 29918, 29945, 29896, 29906, 29889, 3945, 29915, 13, 1678, 396, 7945, 4775, 2605, 353, 525, 29907, 22298, 5959, 1966, 29880, 29889, 791, 29080, 275, 1966, 17600, 1966, 29907, 25874, 29906, 29900, 29896, 29941, 1966, 7210, 29877, 29907, 29905, 8263, 3698, 1966, 14968, 29918, 29906, 29916, 29906, 29918, 8426, 6670, 370, 29918, 29945, 29896, 29906, 29918, 21134, 29889, 3945, 29915, 13, 1678, 396, 1243, 4775, 2605, 353, 525, 29907, 22298, 5959, 1966, 29880, 29889, 791, 29080, 275, 1966, 17600, 1966, 29907, 25874, 29906, 29900, 29896, 29941, 1966, 7210, 29877, 29907, 29905, 8263, 3698, 1966, 1688, 29918, 29906, 29916, 29906, 29918, 8426, 6670, 370, 29918, 29945, 29896, 29906, 29918, 21134, 29889, 3945, 29915, 13, 13, 1678, 396, 518, 14968, 2588, 29892, 7945, 29918, 21134, 29892, 1243, 2588, 29892, 1243, 29918, 21134, 29892, 8845, 2588, 29892, 8845, 29918, 21134, 29892, 13, 1678, 396, 1962, 27403, 29962, 353, 2254, 8263, 3698, 29898, 14968, 2605, 29922, 14968, 2605, 29892, 7945, 4775, 29879, 29922, 14968, 4775, 2605, 29892, 1243, 2605, 29922, 1688, 2605, 29892, 13, 1678, 396, 462, 18884, 1243, 4775, 29879, 29922, 1688, 4775, 2605, 416, 13, 1678, 474, 29922, 29900, 29936, 13, 1678, 363, 7945, 2588, 29892, 14968, 29918, 21134, 297, 22513, 2141, 657, 2588, 2776, 20163, 15156, 29924, 2172, 23145, 267, 29898, 12083, 2605, 29922, 14968, 12924, 29892, 3027, 29918, 2311, 7607, 29896, 29900, 29900, 29892, 29896, 29900, 29900, 511, 16175, 29918, 2311, 29922, 29896, 29945, 1125, 13, 4706, 1596, 313, 14968, 2588, 29889, 12181, 29897, 13, 4706, 1596, 313, 14968, 29918, 21134, 29889, 12181, 29897, 13, 4706, 474, 23661, 2435, 29898, 14968, 2588, 29897, 13, 13, 1678, 1596, 376, 7340, 294, 17370, 17370, 270, 29871, 584, 9162, 29875, 13, 1678, 396, 396, 1596, 8845, 29918, 21134, 13, 1678, 396, 396, 1596, 7945, 29918, 21134, 13, 1678, 396, 396, 1596, 7945, 2588, 13, 1678, 396, 13, 1678, 396, 1596, 7945, 2588, 29889, 12181, 13, 1678, 396, 1596, 7945, 29918, 21134, 29889, 12181, 13, 1678, 396, 1596, 1243, 2588, 29889, 12181, 13, 1678, 396, 1596, 1243, 29918, 21134, 29889, 12181, 13, 1678, 396, 1596, 8845, 2588, 29889, 12181, 13, 1678, 396, 1596, 8845, 29918, 21134, 29889, 12181, 13, 13, 2 ]
tests/test_wsgi.py
invenio-toaster/invenio-base
3
121959
<reponame>invenio-toaster/invenio-base # -*- coding: utf-8 -*- # # This file is part of Invenio. # Copyright (C) 2015-2018 CERN. # # Invenio is free software; you can redistribute it and/or modify it # under the terms of the MIT License; see LICENSE file for more details. """Test wsgi application.""" from __future__ import absolute_import, print_function import json import pytest from flask import Flask, jsonify, request from packaging import version from werkzeug import __version__ as werkzeug_version from invenio_base.wsgi import create_wsgi_factory, wsgi_proxyfix def test_create_wsgi_factory(): """Test wsgi factory creation.""" api = Flask('api') @api.route('/') def apiview(): return 'api' app = Flask('app') @app.route('/') def appview(): return 'app' # Test factory creation factory = create_wsgi_factory({'/api': lambda **kwargs: api}) app.wsgi_app = factory(app) with app.test_client() as client: assert client.get('/').status_code == 200 assert b'app' in client.get('/').data assert client.get('/api/').status_code == 200 assert b'api' in client.get('/api/').data @pytest.mark.parametrize('proxies,data', [ (2, b'4.3.2.1'), (None, b'1.2.3.4') ]) def test_proxyfix_wsgi_proxies(proxies, data): """Test wsgi factory creation.""" app = Flask('app') app.config['WSGI_PROXIES'] = proxies @app.route('/') def appview(): return str(request.remote_addr) # Test factory creation app.wsgi_app = wsgi_proxyfix()(app) e = {'REMOTE_ADDR': '1.2.3.4'} with app.test_client() as client: h = {'X-Forwarded-For': '5.6.7.8, 4.3.2.1, 8.7.6.5'} assert client.get('/', headers=h, environ_base=e).data == data @pytest.mark.parametrize( 'num_proxies,proxy_config', [ (n, {'x_for': n, 'x_proto': n, 'x_host': n, 'x_port': n, 'x_prefix': n}) for n in range(2)]) def test_proxyfix_wsgi_config(num_proxies, proxy_config): """Test wsgi factory creation with APP_WSGI_CONFIG set.""" if version.parse(werkzeug_version) < version.parse('0.15.0'): pytest.skip("Unsupported configuration for Werkzeug<0.15.0") app = Flask('app') app.config['PROXYFIX_CONFIG'] = proxy_config data = [ # application instance { 'x_for': '1.2.3.4', 'x_proto': 'http', 'x_host': 'localhost', 'x_port': '80', 'x_prefix': '', }, # proxy number 1 { 'x_for': '5.6.7.8', 'x_proto': 'https', 'x_host': 'host.external', 'x_port': '443', 'x_prefix': 'prefix.external', } ] @app.route('/') def appview(): data = { 'x_for': request.environ.get('REMOTE_ADDR'), 'x_proto': request.environ.get('wsgi.url_scheme'), 'x_host': request.environ.get('SERVER_NAME'), 'x_port': request.environ.get('SERVER_PORT'), 'x_prefix': request.environ.get('SCRIPT_NAME') } return jsonify(data) # Test factory creation app.wsgi_app = wsgi_proxyfix()(app) e = { 'REMOTE_ADDR': data[0].get('x_for'), 'wsgi.url_scheme': data[0].get('x_proto'), 'HTTP_HOST': data[0].get('x_host'), 'SERVER_PORT': data[0].get('x_port'), 'SCRIPT_NAME': data[0].get('x_prefix'), } with app.test_client() as client: h = { 'X-Forwarded-For': data[1].get('x_for'), 'X-Forwarded-Proto': data[1].get('x_proto'), 'X-Forwarded-Host': data[1].get('x_host'), 'X-Forwarded-Port': data[1].get('x_port'), 'X-Forwarded-Prefix': data[1].get('x_prefix'), } res = client.get('/', headers=h, environ_base=e) assert json.loads(res.get_data(as_text=True)) == data[num_proxies]
[ 1, 529, 276, 1112, 420, 29958, 262, 854, 601, 29899, 517, 1901, 29914, 262, 854, 601, 29899, 3188, 13, 29937, 448, 29930, 29899, 14137, 29901, 23616, 29899, 29947, 448, 29930, 29899, 13, 29937, 13, 29937, 910, 934, 338, 760, 310, 512, 854, 601, 29889, 13, 29937, 14187, 1266, 313, 29907, 29897, 29871, 29906, 29900, 29896, 29945, 29899, 29906, 29900, 29896, 29947, 315, 1001, 29940, 29889, 13, 29937, 13, 29937, 512, 854, 601, 338, 3889, 7047, 29936, 366, 508, 2654, 391, 2666, 372, 322, 29914, 272, 6623, 372, 13, 29937, 1090, 278, 4958, 310, 278, 341, 1806, 19245, 29936, 1074, 365, 2965, 1430, 1660, 934, 363, 901, 4902, 29889, 13, 13, 15945, 29908, 3057, 16904, 3146, 2280, 1213, 15945, 13, 13, 3166, 4770, 29888, 9130, 1649, 1053, 8380, 29918, 5215, 29892, 1596, 29918, 2220, 13, 13, 5215, 4390, 13, 13, 5215, 11451, 1688, 13, 3166, 29784, 1053, 2379, 1278, 29892, 4390, 1598, 29892, 2009, 13, 3166, 4870, 6751, 1053, 1873, 13, 3166, 23085, 13289, 1053, 4770, 3259, 1649, 408, 23085, 13289, 29918, 3259, 13, 13, 3166, 297, 854, 601, 29918, 3188, 29889, 5652, 3146, 1053, 1653, 29918, 5652, 3146, 29918, 14399, 29892, 16904, 3146, 29918, 14701, 5878, 13, 13, 13, 1753, 1243, 29918, 3258, 29918, 5652, 3146, 29918, 14399, 7295, 13, 1678, 9995, 3057, 16904, 3146, 12529, 11265, 1213, 15945, 13, 1678, 7882, 353, 2379, 1278, 877, 2754, 1495, 13, 13, 1678, 732, 2754, 29889, 13134, 11219, 1495, 13, 1678, 822, 3095, 440, 646, 7295, 13, 4706, 736, 525, 2754, 29915, 13, 13, 1678, 623, 353, 2379, 1278, 877, 932, 1495, 13, 13, 1678, 732, 932, 29889, 13134, 11219, 1495, 13, 1678, 822, 623, 1493, 7295, 13, 4706, 736, 525, 932, 29915, 13, 13, 1678, 396, 4321, 12529, 11265, 13, 1678, 12529, 353, 1653, 29918, 5652, 3146, 29918, 14399, 3319, 29915, 29914, 2754, 2396, 14013, 3579, 19290, 29901, 7882, 1800, 13, 1678, 623, 29889, 5652, 3146, 29918, 932, 353, 12529, 29898, 932, 29897, 13, 13, 1678, 411, 623, 29889, 1688, 29918, 4645, 580, 408, 3132, 29901, 13, 4706, 4974, 3132, 29889, 657, 11219, 2824, 4882, 29918, 401, 1275, 29871, 29906, 29900, 29900, 13, 4706, 4974, 289, 29915, 932, 29915, 297, 3132, 29889, 657, 11219, 2824, 1272, 13, 4706, 4974, 3132, 29889, 657, 11219, 2754, 29914, 2824, 4882, 29918, 401, 1275, 29871, 29906, 29900, 29900, 13, 4706, 4974, 289, 29915, 2754, 29915, 297, 3132, 29889, 657, 11219, 2754, 29914, 2824, 1272, 13, 13, 13, 29992, 2272, 1688, 29889, 3502, 29889, 3207, 300, 374, 911, 877, 771, 29916, 583, 29892, 1272, 742, 518, 13, 1678, 313, 29906, 29892, 289, 29915, 29946, 29889, 29941, 29889, 29906, 29889, 29896, 5477, 313, 8516, 29892, 289, 29915, 29896, 29889, 29906, 29889, 29941, 29889, 29946, 1495, 13, 2314, 13, 1753, 1243, 29918, 14701, 5878, 29918, 5652, 3146, 29918, 771, 29916, 583, 29898, 771, 29916, 583, 29892, 848, 1125, 13, 1678, 9995, 3057, 16904, 3146, 12529, 11265, 1213, 15945, 13, 1678, 623, 353, 2379, 1278, 877, 932, 1495, 13, 1678, 623, 29889, 2917, 1839, 7811, 29954, 29902, 29918, 8618, 29990, 29059, 2033, 353, 410, 29916, 583, 13, 13, 1678, 732, 932, 29889, 13134, 11219, 1495, 13, 1678, 822, 623, 1493, 7295, 13, 4706, 736, 851, 29898, 3827, 29889, 16674, 29918, 10030, 29897, 13, 13, 1678, 396, 4321, 12529, 11265, 13, 1678, 623, 29889, 5652, 3146, 29918, 932, 353, 16904, 3146, 29918, 14701, 5878, 580, 29898, 932, 29897, 13, 1678, 321, 353, 11117, 1525, 29924, 2891, 29923, 29918, 3035, 8353, 2396, 525, 29896, 29889, 29906, 29889, 29941, 29889, 29946, 10827, 13, 13, 1678, 411, 623, 29889, 1688, 29918, 4645, 580, 408, 3132, 29901, 13, 4706, 298, 353, 11117, 29990, 29899, 2831, 1328, 287, 29899, 2831, 2396, 525, 29945, 29889, 29953, 29889, 29955, 29889, 29947, 29892, 29871, 29946, 29889, 29941, 29889, 29906, 29889, 29896, 29892, 29871, 29947, 29889, 29955, 29889, 29953, 29889, 29945, 10827, 13, 4706, 4974, 3132, 29889, 657, 11219, 742, 9066, 29922, 29882, 29892, 12471, 29918, 3188, 29922, 29872, 467, 1272, 1275, 848, 13, 13, 13, 29992, 2272, 1688, 29889, 3502, 29889, 3207, 300, 374, 911, 29898, 13, 1678, 525, 1949, 29918, 771, 29916, 583, 29892, 14701, 29918, 2917, 742, 518, 13, 4706, 313, 29876, 29892, 11117, 29916, 29918, 1454, 2396, 302, 29892, 525, 29916, 29918, 17529, 2396, 302, 29892, 525, 29916, 29918, 3069, 2396, 302, 29892, 525, 29916, 29918, 637, 2396, 302, 29892, 13, 632, 525, 29916, 29918, 13506, 2396, 302, 1800, 363, 302, 297, 3464, 29898, 29906, 29897, 2314, 13, 1753, 1243, 29918, 14701, 5878, 29918, 5652, 3146, 29918, 2917, 29898, 1949, 29918, 771, 29916, 583, 29892, 10166, 29918, 2917, 1125, 13, 1678, 9995, 3057, 16904, 3146, 12529, 11265, 411, 12279, 29925, 29918, 7811, 29954, 29902, 29918, 25903, 731, 1213, 15945, 13, 1678, 565, 1873, 29889, 5510, 29898, 9888, 13289, 29918, 3259, 29897, 529, 1873, 29889, 5510, 877, 29900, 29889, 29896, 29945, 29889, 29900, 29374, 13, 4706, 11451, 1688, 29889, 11014, 703, 25807, 29884, 3016, 287, 5285, 363, 15492, 13289, 29966, 29900, 29889, 29896, 29945, 29889, 29900, 1159, 13, 13, 1678, 623, 353, 2379, 1278, 877, 932, 1495, 13, 1678, 623, 29889, 2917, 1839, 8618, 18454, 25634, 29918, 25903, 2033, 353, 10166, 29918, 2917, 13, 13, 1678, 848, 353, 518, 13, 4706, 396, 2280, 2777, 13, 4706, 426, 13, 9651, 525, 29916, 29918, 1454, 2396, 525, 29896, 29889, 29906, 29889, 29941, 29889, 29946, 742, 13, 9651, 525, 29916, 29918, 17529, 2396, 525, 1124, 742, 13, 9651, 525, 29916, 29918, 3069, 2396, 525, 7640, 742, 13, 9651, 525, 29916, 29918, 637, 2396, 525, 29947, 29900, 742, 13, 9651, 525, 29916, 29918, 13506, 2396, 15516, 13, 4706, 2981, 13, 4706, 396, 10166, 1353, 29871, 29896, 13, 4706, 426, 13, 9651, 525, 29916, 29918, 1454, 2396, 525, 29945, 29889, 29953, 29889, 29955, 29889, 29947, 742, 13, 9651, 525, 29916, 29918, 17529, 2396, 525, 991, 742, 13, 9651, 525, 29916, 29918, 3069, 2396, 525, 3069, 29889, 23176, 742, 13, 9651, 525, 29916, 29918, 637, 2396, 525, 29946, 29946, 29941, 742, 13, 9651, 525, 29916, 29918, 13506, 2396, 525, 13506, 29889, 23176, 742, 13, 4706, 500, 13, 1678, 4514, 13, 13, 1678, 732, 932, 29889, 13134, 11219, 1495, 13, 1678, 822, 623, 1493, 7295, 13, 4706, 848, 353, 426, 13, 9651, 525, 29916, 29918, 1454, 2396, 2009, 29889, 21813, 29889, 657, 877, 1525, 29924, 2891, 29923, 29918, 3035, 8353, 5477, 13, 9651, 525, 29916, 29918, 17529, 2396, 2009, 29889, 21813, 29889, 657, 877, 5652, 3146, 29889, 2271, 29918, 816, 2004, 5477, 13, 9651, 525, 29916, 29918, 3069, 2396, 2009, 29889, 21813, 29889, 657, 877, 18603, 29918, 5813, 5477, 13, 9651, 525, 29916, 29918, 637, 2396, 2009, 29889, 21813, 29889, 657, 877, 18603, 29918, 15082, 5477, 13, 9651, 525, 29916, 29918, 13506, 2396, 2009, 29889, 21813, 29889, 657, 877, 7187, 24290, 29918, 5813, 1495, 13, 4706, 500, 13, 4706, 736, 4390, 1598, 29898, 1272, 29897, 13, 13, 1678, 396, 4321, 12529, 11265, 13, 1678, 623, 29889, 5652, 3146, 29918, 932, 353, 16904, 3146, 29918, 14701, 5878, 580, 29898, 932, 29897, 13, 1678, 321, 353, 426, 13, 4706, 525, 1525, 29924, 2891, 29923, 29918, 3035, 8353, 2396, 848, 29961, 29900, 1822, 657, 877, 29916, 29918, 1454, 5477, 13, 4706, 525, 5652, 3146, 29889, 2271, 29918, 816, 2004, 2396, 848, 29961, 29900, 1822, 657, 877, 29916, 29918, 17529, 5477, 13, 4706, 525, 10493, 29918, 20832, 2396, 848, 29961, 29900, 1822, 657, 877, 29916, 29918, 3069, 5477, 13, 4706, 525, 18603, 29918, 15082, 2396, 848, 29961, 29900, 1822, 657, 877, 29916, 29918, 637, 5477, 13, 4706, 525, 7187, 24290, 29918, 5813, 2396, 848, 29961, 29900, 1822, 657, 877, 29916, 29918, 13506, 5477, 13, 1678, 500, 13, 13, 1678, 411, 623, 29889, 1688, 29918, 4645, 580, 408, 3132, 29901, 13, 4706, 298, 353, 426, 13, 9651, 525, 29990, 29899, 2831, 1328, 287, 29899, 2831, 2396, 848, 29961, 29896, 1822, 657, 877, 29916, 29918, 1454, 5477, 13, 9651, 525, 29990, 29899, 2831, 1328, 287, 29899, 1184, 517, 2396, 848, 29961, 29896, 1822, 657, 877, 29916, 29918, 17529, 5477, 13, 9651, 525, 29990, 29899, 2831, 1328, 287, 29899, 8514, 2396, 848, 29961, 29896, 1822, 657, 877, 29916, 29918, 3069, 5477, 13, 9651, 525, 29990, 29899, 2831, 1328, 287, 29899, 2290, 2396, 848, 29961, 29896, 1822, 657, 877, 29916, 29918, 637, 5477, 13, 9651, 525, 29990, 29899, 2831, 1328, 287, 29899, 23095, 2396, 848, 29961, 29896, 1822, 657, 877, 29916, 29918, 13506, 5477, 13, 4706, 500, 13, 4706, 620, 353, 3132, 29889, 657, 11219, 742, 9066, 29922, 29882, 29892, 12471, 29918, 3188, 29922, 29872, 29897, 13, 4706, 4974, 4390, 29889, 18132, 29898, 690, 29889, 657, 29918, 1272, 29898, 294, 29918, 726, 29922, 5574, 876, 1275, 848, 29961, 1949, 29918, 771, 29916, 583, 29962, 13, 2 ]
tests/test_utils.py
marianoleonardo/device-manager
14
1608219
<reponame>marianoleonardo/device-manager import pytest import json import unittest from flask import Flask from DeviceManager.utils import format_response, get_pagination, get_allowed_service, decrypt, retrieve_auth_token from DeviceManager.utils import HTTPRequestError from .token_test_generator import generate_token class Request: def __init__(self, data): self.headers = data['headers'] self.args = data['args'] self.data = data['body'] class TestUtils(unittest.TestCase): app = Flask(__name__) def test_format_response(self): with self.app.test_request_context(): result = format_response(200, 'Unity test of message formatter') self.assertEqual(result.status, '200 OK') self.assertEqual(json.loads(result.response[0])[ 'message'], 'Unity test of message formatter') result = format_response(202) self.assertEqual(result.status, '202 ACCEPTED') self.assertEqual(json.loads(result.response[0])['message'], 'ok') result = format_response(404) self.assertEqual(result.status, '404 NOT FOUND') self.assertEqual(json.loads(result.response[0])[ 'message'], 'Request failed') def test_get_pagination(self): args = {'page_size': 10,'page_num': 1} req = {'headers': {'authorization': generate_token()},'args': args,'body': ''} page, per_page = get_pagination(Request(req)) self.assertEqual(page, 1) self.assertEqual(per_page, 10) with self.assertRaises(HTTPRequestError): args = {'page_size': 10,'page_num': 0} req = {'headers': {'authorization': generate_token()},'args': args,'body': ''} page, per_page = get_pagination(Request(req)) with self.assertRaises(HTTPRequestError): args = {'page_size': 0,'page_num': 2} req = {'headers': {'authorization': generate_token()},'args': args,'body': ''} page, per_page = get_pagination(Request(req)) def test_get_allowed_service(self): token = generate_token() with self.assertRaises(ValueError): get_allowed_service(None) result = get_allowed_service(token) self.assertIsNotNone(result) self.assertEqual(result, 'admin') with self.assertRaises(ValueError): get_allowed_service('Is.Not_A_Valid_Token') def test_decrypt(self): result = decrypt(b"\xa97\xa4o\xba\xddx\xe0\xe9\x8f\xe2\xc4V\x85\xf7'") self.assertEqual(result, b'') with self.assertRaises(ValueError): result = decrypt('12345678') def test_retrieve_auth_token(self): token = generate_token() req = {'headers': {'authorization': token},'args': '','body': ''} result = retrieve_auth_token(Request(req)) self.assertIsNotNone(result) self.assertEqual(result, token) with self.assertRaises(HTTPRequestError): req = {'headers': {},'args': '','body': ''} result = retrieve_auth_token(Request(req))
[ 1, 529, 276, 1112, 420, 29958, 3034, 713, 1772, 265, 6491, 29914, 10141, 29899, 12847, 13, 5215, 11451, 1688, 13, 5215, 4390, 13, 5215, 443, 27958, 13, 13, 3166, 29784, 1053, 2379, 1278, 13, 3166, 21830, 3260, 29889, 13239, 1053, 3402, 29918, 5327, 29892, 679, 29918, 13573, 3381, 29892, 679, 29918, 24622, 29918, 5509, 29892, 1602, 4641, 29892, 10563, 29918, 5150, 29918, 6979, 13, 3166, 21830, 3260, 29889, 13239, 1053, 7331, 3089, 2392, 13, 13, 3166, 869, 6979, 29918, 1688, 29918, 27959, 1053, 5706, 29918, 6979, 13, 13, 13, 1990, 10729, 29901, 13, 1678, 822, 4770, 2344, 12035, 1311, 29892, 848, 1125, 13, 4706, 1583, 29889, 13662, 353, 848, 1839, 13662, 2033, 13, 4706, 1583, 29889, 5085, 353, 848, 1839, 5085, 2033, 13, 4706, 1583, 29889, 1272, 353, 848, 1839, 2587, 2033, 13, 13, 13, 1990, 4321, 12177, 29898, 348, 27958, 29889, 3057, 8259, 1125, 13, 13, 1678, 623, 353, 2379, 1278, 22168, 978, 1649, 29897, 13, 13, 1678, 822, 1243, 29918, 4830, 29918, 5327, 29898, 1311, 1125, 13, 4706, 411, 1583, 29889, 932, 29889, 1688, 29918, 3827, 29918, 4703, 7295, 13, 9651, 1121, 353, 3402, 29918, 5327, 29898, 29906, 29900, 29900, 29892, 525, 2525, 537, 1243, 310, 2643, 883, 2620, 1495, 13, 9651, 1583, 29889, 9294, 9843, 29898, 2914, 29889, 4882, 29892, 525, 29906, 29900, 29900, 9280, 1495, 13, 9651, 1583, 29889, 9294, 9843, 29898, 3126, 29889, 18132, 29898, 2914, 29889, 5327, 29961, 29900, 2314, 29961, 13, 462, 632, 525, 4906, 7464, 525, 2525, 537, 1243, 310, 2643, 883, 2620, 1495, 13, 13, 9651, 1121, 353, 3402, 29918, 5327, 29898, 29906, 29900, 29906, 29897, 13, 9651, 1583, 29889, 9294, 9843, 29898, 2914, 29889, 4882, 29892, 525, 29906, 29900, 29906, 319, 19043, 7982, 3352, 1495, 13, 9651, 1583, 29889, 9294, 9843, 29898, 3126, 29889, 18132, 29898, 2914, 29889, 5327, 29961, 29900, 2314, 1839, 4906, 7464, 525, 554, 1495, 13, 13, 9651, 1121, 353, 3402, 29918, 5327, 29898, 29946, 29900, 29946, 29897, 13, 9651, 1583, 29889, 9294, 9843, 29898, 2914, 29889, 4882, 29892, 525, 29946, 29900, 29946, 6058, 18322, 18783, 1495, 13, 9651, 1583, 29889, 9294, 9843, 29898, 3126, 29889, 18132, 29898, 2914, 29889, 5327, 29961, 29900, 2314, 29961, 13, 462, 632, 525, 4906, 7464, 525, 3089, 5229, 1495, 13, 13, 1678, 822, 1243, 29918, 657, 29918, 13573, 3381, 29898, 1311, 1125, 13, 13, 4706, 6389, 353, 11117, 3488, 29918, 2311, 2396, 29871, 29896, 29900, 5501, 3488, 29918, 1949, 2396, 29871, 29896, 29913, 13, 4706, 12428, 353, 11117, 13662, 2396, 11117, 8921, 2133, 2396, 5706, 29918, 6979, 580, 1118, 29915, 5085, 2396, 6389, 5501, 2587, 2396, 6629, 29913, 13, 13, 4706, 1813, 29892, 639, 29918, 3488, 353, 679, 29918, 13573, 3381, 29898, 3089, 29898, 7971, 876, 13, 4706, 1583, 29889, 9294, 9843, 29898, 3488, 29892, 29871, 29896, 29897, 13, 4706, 1583, 29889, 9294, 9843, 29898, 546, 29918, 3488, 29892, 29871, 29896, 29900, 29897, 13, 13, 4706, 411, 1583, 29889, 9294, 29934, 1759, 267, 29898, 10493, 3089, 2392, 1125, 13, 9651, 6389, 353, 11117, 3488, 29918, 2311, 2396, 29871, 29896, 29900, 5501, 3488, 29918, 1949, 2396, 29871, 29900, 29913, 13, 9651, 12428, 353, 11117, 13662, 2396, 11117, 8921, 2133, 2396, 5706, 29918, 6979, 580, 1118, 29915, 5085, 2396, 6389, 5501, 2587, 2396, 6629, 29913, 13, 9651, 1813, 29892, 639, 29918, 3488, 353, 679, 29918, 13573, 3381, 29898, 3089, 29898, 7971, 876, 13, 13, 4706, 411, 1583, 29889, 9294, 29934, 1759, 267, 29898, 10493, 3089, 2392, 1125, 13, 9651, 6389, 353, 11117, 3488, 29918, 2311, 2396, 29871, 29900, 5501, 3488, 29918, 1949, 2396, 29871, 29906, 29913, 13, 9651, 12428, 353, 11117, 13662, 2396, 11117, 8921, 2133, 2396, 5706, 29918, 6979, 580, 1118, 29915, 5085, 2396, 6389, 5501, 2587, 2396, 6629, 29913, 13, 9651, 1813, 29892, 639, 29918, 3488, 353, 679, 29918, 13573, 3381, 29898, 3089, 29898, 7971, 876, 13, 13, 1678, 822, 1243, 29918, 657, 29918, 24622, 29918, 5509, 29898, 1311, 1125, 13, 4706, 5993, 353, 5706, 29918, 6979, 580, 13, 13, 4706, 411, 1583, 29889, 9294, 29934, 1759, 267, 29898, 1917, 2392, 1125, 13, 9651, 679, 29918, 24622, 29918, 5509, 29898, 8516, 29897, 13, 308, 13, 4706, 1121, 353, 679, 29918, 24622, 29918, 5509, 29898, 6979, 29897, 13, 4706, 1583, 29889, 9294, 3624, 3664, 8516, 29898, 2914, 29897, 13, 4706, 1583, 29889, 9294, 9843, 29898, 2914, 29892, 525, 6406, 1495, 13, 13, 4706, 411, 1583, 29889, 9294, 29934, 1759, 267, 29898, 1917, 2392, 1125, 13, 9651, 679, 29918, 24622, 29918, 5509, 877, 3624, 29889, 3664, 29918, 29909, 29918, 7211, 29918, 6066, 1495, 13, 13, 13, 1678, 822, 1243, 29918, 7099, 4641, 29898, 1311, 1125, 13, 4706, 1121, 353, 1602, 4641, 29898, 29890, 26732, 17367, 29929, 29955, 29905, 17367, 29946, 29877, 29905, 29916, 2291, 29905, 29916, 1289, 29916, 29905, 17115, 29900, 29905, 17115, 29929, 29905, 29916, 29947, 29888, 29905, 17115, 29906, 29905, 21791, 29946, 29963, 29905, 29916, 29947, 29945, 29905, 24660, 29955, 29915, 1159, 13, 4706, 1583, 29889, 9294, 9843, 29898, 2914, 29892, 289, 29915, 1495, 13, 13, 4706, 411, 1583, 29889, 9294, 29934, 1759, 267, 29898, 1917, 2392, 1125, 13, 9651, 1121, 353, 1602, 4641, 877, 29896, 29906, 29941, 29946, 29945, 29953, 29955, 29947, 1495, 13, 13, 1678, 822, 1243, 29918, 276, 509, 2418, 29918, 5150, 29918, 6979, 29898, 1311, 1125, 13, 4706, 5993, 353, 5706, 29918, 6979, 580, 13, 4706, 12428, 353, 11117, 13662, 2396, 11117, 8921, 2133, 2396, 5993, 1118, 29915, 5085, 2396, 525, 3788, 2587, 2396, 6629, 29913, 13, 13, 4706, 1121, 353, 10563, 29918, 5150, 29918, 6979, 29898, 3089, 29898, 7971, 876, 13, 4706, 1583, 29889, 9294, 3624, 3664, 8516, 29898, 2914, 29897, 13, 4706, 1583, 29889, 9294, 9843, 29898, 2914, 29892, 5993, 29897, 13, 13, 4706, 411, 1583, 29889, 9294, 29934, 1759, 267, 29898, 10493, 3089, 2392, 1125, 13, 9651, 12428, 353, 11117, 13662, 2396, 24335, 29915, 5085, 2396, 525, 3788, 2587, 2396, 6629, 29913, 13, 9651, 1121, 353, 10563, 29918, 5150, 29918, 6979, 29898, 3089, 29898, 7971, 876, 13, 2 ]
tests/serve/test_metadata.py
outerbounds/tempo
75
33100
<reponame>outerbounds/tempo import pytest from tempo.serve.metadata import KubernetesRuntimeOptions @pytest.mark.parametrize( "runtime, replicas", [ ({"replicas": 2}, 2), ({}, 1), ], ) def test_runtime_options(runtime, replicas): r = KubernetesRuntimeOptions(**runtime) assert r.replicas == replicas
[ 1, 529, 276, 1112, 420, 29958, 5561, 23687, 29914, 1356, 1129, 13, 5215, 11451, 1688, 13, 13, 3166, 11413, 29889, 16349, 29889, 19635, 1053, 476, 17547, 7944, 5856, 13, 13, 13, 29992, 2272, 1688, 29889, 3502, 29889, 3207, 300, 374, 911, 29898, 13, 1678, 376, 15634, 29892, 1634, 506, 294, 613, 13, 1678, 518, 13, 4706, 313, 6377, 3445, 506, 294, 1115, 29871, 29906, 1118, 29871, 29906, 511, 13, 4706, 21313, 1118, 29871, 29896, 511, 13, 1678, 21251, 13, 29897, 13, 1753, 1243, 29918, 15634, 29918, 6768, 29898, 15634, 29892, 1634, 506, 294, 1125, 13, 1678, 364, 353, 476, 17547, 7944, 5856, 29898, 1068, 15634, 29897, 13, 1678, 4974, 364, 29889, 3445, 506, 294, 1275, 1634, 506, 294, 13, 2 ]
ubi_api/api/models.py
rzhang74/Ubi
0
127996
from django.db import models from django.utils import timezone from django.contrib.auth.models import User # Create your models here. class Tag(models.Model): tid = models.AutoField(primary_key=True) name = models.CharField(max_length=100) class Video(models.Model): vid = models.AutoField(primary_key=True) name = models.CharField(max_length=100) address = models.CharField(max_length=300) thumbnail_address = models.CharField(max_length=300, default='/video.jpg') description = models.TextField(null=True) category = models.CharField(max_length=50) user = models.ForeignKey(User, on_delete=models.CASCADE, db_column="user") like = models.ManyToManyField(User, related_name="userLikeVideos") dislike = models.ManyToManyField(User, related_name="userDislikeVideos") tag = models.ManyToManyField(Tag, related_name="tagVideos") class Comment(models.Model): cid = models.AutoField(primary_key=True) vid = models.ForeignKey(Video, on_delete=models.CASCADE, db_column="vid") user = models.ForeignKey(User, on_delete=models.CASCADE, db_column="user") content = models.TextField() datetime = models.DateTimeField(auto_now_add=True) parent = models.ForeignKey("Comment", on_delete=models.CASCADE, db_column="p_cid", null=True) like = models.ManyToManyField(User, related_name="userLikeComments") dislike = models.ManyToManyField(User, related_name="userDisLikeComments") class Follow(models.Model): fid = models.AutoField(primary_key=True) follower = models.ForeignKey(User, on_delete=models.CASCADE, db_column="follower", related_name="user") user = models.ForeignKey(User, on_delete=models.CASCADE, db_column="user", related_name="follower") class Meta: unique_together = ('user', 'follower',) class CommunityMessage(models.Model): cmid = models.AutoField(primary_key=True) user = models.ForeignKey(User, on_delete=models.CASCADE, db_column="user") message = models.TextField(null=False) datetime = models.DateTimeField(auto_now_add=True) imageAddr = models.CharField(max_length=300, null=True) videoAddr = models.CharField(max_length=300, null=True) like = models.ManyToManyField(User, related_name="userLikeMessages") dislike = models.ManyToManyField(User, related_name="userDislikeMessages") class PlayList(models.Model): pid = models.AutoField(primary_key=True) user = models.ForeignKey(User, on_delete=models.CASCADE, db_column="user") name = models.CharField(max_length=100) vid = models.ManyToManyField(Video, related_name="videoPlayists")
[ 1, 515, 9557, 29889, 2585, 1053, 4733, 13, 3166, 9557, 29889, 13239, 1053, 29431, 13, 3166, 9557, 29889, 21570, 29889, 5150, 29889, 9794, 1053, 4911, 13, 13, 29937, 6204, 596, 4733, 1244, 29889, 13, 1990, 10522, 29898, 9794, 29889, 3195, 1125, 13, 1678, 10668, 353, 4733, 29889, 12300, 3073, 29898, 16072, 29918, 1989, 29922, 5574, 29897, 13, 1678, 1024, 353, 4733, 29889, 27890, 29898, 3317, 29918, 2848, 29922, 29896, 29900, 29900, 29897, 13, 13, 1990, 13987, 29898, 9794, 29889, 3195, 1125, 13, 1678, 7840, 353, 4733, 29889, 12300, 3073, 29898, 16072, 29918, 1989, 29922, 5574, 29897, 13, 1678, 1024, 353, 4733, 29889, 27890, 29898, 3317, 29918, 2848, 29922, 29896, 29900, 29900, 29897, 13, 1678, 3211, 353, 4733, 29889, 27890, 29898, 3317, 29918, 2848, 29922, 29941, 29900, 29900, 29897, 13, 1678, 266, 21145, 29918, 7328, 353, 4733, 29889, 27890, 29898, 3317, 29918, 2848, 29922, 29941, 29900, 29900, 29892, 2322, 2433, 29914, 9641, 29889, 6173, 1495, 13, 1678, 6139, 353, 4733, 29889, 15778, 29898, 4304, 29922, 5574, 29897, 13, 1678, 7663, 353, 4733, 29889, 27890, 29898, 3317, 29918, 2848, 29922, 29945, 29900, 29897, 13, 1678, 1404, 353, 4733, 29889, 27755, 2558, 29898, 2659, 29892, 373, 29918, 8143, 29922, 9794, 29889, 29907, 3289, 5454, 2287, 29892, 4833, 29918, 4914, 543, 1792, 1159, 13, 13, 1678, 763, 353, 4733, 29889, 14804, 1762, 14804, 3073, 29898, 2659, 29892, 4475, 29918, 978, 543, 1792, 27552, 29963, 7958, 1159, 13, 1678, 766, 4561, 353, 4733, 29889, 14804, 1762, 14804, 3073, 29898, 2659, 29892, 4475, 29918, 978, 543, 1792, 4205, 4561, 29963, 7958, 1159, 13, 1678, 4055, 353, 4733, 29889, 14804, 1762, 14804, 3073, 29898, 8176, 29892, 4475, 29918, 978, 543, 4039, 29963, 7958, 1159, 13, 13, 1990, 461, 29898, 9794, 29889, 3195, 1125, 13, 1678, 274, 333, 353, 4733, 29889, 12300, 3073, 29898, 16072, 29918, 1989, 29922, 5574, 29897, 13, 1678, 7840, 353, 4733, 29889, 27755, 2558, 29898, 15167, 29892, 373, 29918, 8143, 29922, 9794, 29889, 29907, 3289, 5454, 2287, 29892, 4833, 29918, 4914, 543, 8590, 1159, 13, 1678, 1404, 353, 4733, 29889, 27755, 2558, 29898, 2659, 29892, 373, 29918, 8143, 29922, 9794, 29889, 29907, 3289, 5454, 2287, 29892, 4833, 29918, 4914, 543, 1792, 1159, 13, 1678, 2793, 353, 4733, 29889, 15778, 580, 13, 1678, 12865, 353, 4733, 29889, 11384, 3073, 29898, 6921, 29918, 3707, 29918, 1202, 29922, 5574, 29897, 13, 268, 13, 1678, 3847, 353, 4733, 29889, 27755, 2558, 703, 20001, 613, 373, 29918, 8143, 29922, 9794, 29889, 29907, 3289, 5454, 2287, 29892, 4833, 29918, 4914, 543, 29886, 29918, 25232, 613, 1870, 29922, 5574, 29897, 13, 1678, 763, 353, 4733, 29889, 14804, 1762, 14804, 3073, 29898, 2659, 29892, 4475, 29918, 978, 543, 1792, 27552, 1523, 1860, 1159, 13, 1678, 766, 4561, 353, 4733, 29889, 14804, 1762, 14804, 3073, 29898, 2659, 29892, 4475, 29918, 978, 543, 1792, 4205, 27552, 1523, 1860, 1159, 13, 13, 1990, 10306, 29898, 9794, 29889, 3195, 1125, 13, 1678, 25947, 353, 4733, 29889, 12300, 3073, 29898, 16072, 29918, 1989, 29922, 5574, 29897, 13, 1678, 1101, 261, 353, 4733, 29889, 27755, 2558, 29898, 2659, 29892, 373, 29918, 8143, 29922, 9794, 29889, 29907, 3289, 5454, 2287, 29892, 4833, 29918, 4914, 543, 23031, 261, 613, 4475, 29918, 978, 543, 1792, 1159, 13, 1678, 1404, 353, 4733, 29889, 27755, 2558, 29898, 2659, 29892, 373, 29918, 8143, 29922, 9794, 29889, 29907, 3289, 5454, 2287, 29892, 4833, 29918, 4914, 543, 1792, 613, 4475, 29918, 978, 543, 23031, 261, 1159, 13, 13, 1678, 770, 20553, 29901, 13, 4706, 5412, 29918, 29873, 12966, 353, 6702, 1792, 742, 525, 23031, 261, 742, 29897, 13, 13, 1990, 19184, 3728, 29898, 9794, 29889, 3195, 1125, 13, 1678, 274, 6563, 353, 4733, 29889, 12300, 3073, 29898, 16072, 29918, 1989, 29922, 5574, 29897, 13, 1678, 1404, 353, 4733, 29889, 27755, 2558, 29898, 2659, 29892, 373, 29918, 8143, 29922, 9794, 29889, 29907, 3289, 5454, 2287, 29892, 4833, 29918, 4914, 543, 1792, 1159, 13, 1678, 2643, 353, 4733, 29889, 15778, 29898, 4304, 29922, 8824, 29897, 13, 1678, 12865, 353, 4733, 29889, 11384, 3073, 29898, 6921, 29918, 3707, 29918, 1202, 29922, 5574, 29897, 13, 1678, 1967, 2528, 29878, 353, 4733, 29889, 27890, 29898, 3317, 29918, 2848, 29922, 29941, 29900, 29900, 29892, 1870, 29922, 5574, 29897, 13, 1678, 4863, 2528, 29878, 353, 4733, 29889, 27890, 29898, 3317, 29918, 2848, 29922, 29941, 29900, 29900, 29892, 1870, 29922, 5574, 29897, 13, 13, 1678, 763, 353, 4733, 29889, 14804, 1762, 14804, 3073, 29898, 2659, 29892, 4475, 29918, 978, 543, 1792, 27552, 25510, 1159, 13, 1678, 766, 4561, 353, 4733, 29889, 14804, 1762, 14804, 3073, 29898, 2659, 29892, 4475, 29918, 978, 543, 1792, 4205, 4561, 25510, 1159, 13, 13, 1990, 7412, 1293, 29898, 9794, 29889, 3195, 1125, 13, 1678, 23107, 353, 4733, 29889, 12300, 3073, 29898, 16072, 29918, 1989, 29922, 5574, 29897, 13, 1678, 1404, 353, 4733, 29889, 27755, 2558, 29898, 2659, 29892, 373, 29918, 8143, 29922, 9794, 29889, 29907, 3289, 5454, 2287, 29892, 4833, 29918, 4914, 543, 1792, 1159, 13, 1678, 1024, 353, 4733, 29889, 27890, 29898, 3317, 29918, 2848, 29922, 29896, 29900, 29900, 29897, 13, 13, 1678, 7840, 353, 4733, 29889, 14804, 1762, 14804, 3073, 29898, 15167, 29892, 4475, 29918, 978, 543, 9641, 13454, 2879, 1159, 2 ]
examples/incremental_learning/helmet_detection/training/eval.py
lidongen/sedna
1
1611164
<reponame>lidongen/sedna<gh_stars>1-10 # Copyright 2021 The KubeEdge Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import logging import sedna from validate_utils import validate LOG = logging.getLogger(__name__) max_epochs = 1 def main(): # load dataset. test_data = sedna.load_test_dataset(data_format='txt', with_image=False) # read parameters from deployment config. class_names = sedna.context.get_parameters("class_names") class_names = [label.strip() for label in class_names.split(',')] input_shape = sedna.context.get_parameters("input_shape") input_shape = tuple(int(shape) for shape in input_shape.split(',')) model = validate sedna.incremental_learning.evaluate(model=model, test_data=test_data, class_names=class_names, input_shape=input_shape) if __name__ == '__main__': main()
[ 1, 529, 276, 1112, 420, 29958, 29880, 333, 549, 264, 29914, 8485, 1056, 29966, 12443, 29918, 303, 1503, 29958, 29896, 29899, 29896, 29900, 13, 29937, 14187, 1266, 29871, 29906, 29900, 29906, 29896, 450, 476, 4003, 23894, 13189, 943, 29889, 13, 29937, 13, 29937, 10413, 21144, 1090, 278, 13380, 19245, 29892, 10079, 29871, 29906, 29889, 29900, 313, 1552, 376, 29931, 293, 1947, 1496, 13, 29937, 366, 1122, 451, 671, 445, 934, 5174, 297, 752, 13036, 411, 278, 19245, 29889, 13, 29937, 887, 1122, 4017, 263, 3509, 310, 278, 19245, 472, 13, 29937, 13, 29937, 268, 1732, 597, 1636, 29889, 4288, 29889, 990, 29914, 506, 11259, 29914, 27888, 1430, 1660, 29899, 29906, 29889, 29900, 13, 29937, 13, 29937, 25870, 3734, 491, 22903, 4307, 470, 15502, 304, 297, 5007, 29892, 7047, 13, 29937, 13235, 1090, 278, 19245, 338, 13235, 373, 385, 376, 3289, 8519, 29908, 350, 3289, 3235, 29892, 13, 29937, 399, 1806, 8187, 2692, 399, 1718, 29934, 13566, 29059, 6323, 8707, 29928, 22122, 29903, 8079, 13764, 29979, 476, 22255, 29892, 2845, 4653, 470, 2411, 2957, 29889, 13, 29937, 2823, 278, 19245, 363, 278, 2702, 4086, 14765, 1076, 11239, 322, 13, 29937, 27028, 1090, 278, 19245, 29889, 13, 13, 5215, 12183, 13, 13, 5215, 7048, 1056, 13, 3166, 12725, 29918, 13239, 1053, 12725, 13, 13, 14480, 353, 12183, 29889, 657, 16363, 22168, 978, 1649, 29897, 13, 3317, 29918, 1022, 2878, 29879, 353, 29871, 29896, 13, 13, 13, 1753, 1667, 7295, 13, 1678, 396, 2254, 8783, 29889, 13, 1678, 1243, 29918, 1272, 353, 7048, 1056, 29889, 1359, 29918, 1688, 29918, 24713, 29898, 1272, 29918, 4830, 2433, 3945, 742, 411, 29918, 3027, 29922, 8824, 29897, 13, 13, 1678, 396, 1303, 4128, 515, 18209, 2295, 29889, 13, 1678, 770, 29918, 7039, 353, 7048, 1056, 29889, 4703, 29889, 657, 29918, 16744, 703, 1990, 29918, 7039, 1159, 13, 1678, 770, 29918, 7039, 353, 518, 1643, 29889, 17010, 580, 363, 3858, 297, 770, 29918, 7039, 29889, 5451, 29317, 1495, 29962, 13, 1678, 1881, 29918, 12181, 353, 7048, 1056, 29889, 4703, 29889, 657, 29918, 16744, 703, 2080, 29918, 12181, 1159, 13, 1678, 1881, 29918, 12181, 353, 18761, 29898, 524, 29898, 12181, 29897, 363, 8267, 297, 1881, 29918, 12181, 29889, 5451, 29898, 3788, 876, 13, 13, 1678, 1904, 353, 12725, 13, 13, 1678, 7048, 1056, 29889, 25629, 284, 29918, 21891, 29889, 24219, 403, 29898, 4299, 29922, 4299, 29892, 13, 462, 462, 3986, 1243, 29918, 1272, 29922, 1688, 29918, 1272, 29892, 13, 462, 462, 3986, 770, 29918, 7039, 29922, 1990, 29918, 7039, 29892, 13, 462, 462, 3986, 1881, 29918, 12181, 29922, 2080, 29918, 12181, 29897, 13, 13, 13, 361, 4770, 978, 1649, 1275, 525, 1649, 3396, 1649, 2396, 13, 1678, 1667, 580, 13, 2 ]
changestream_insert.py
thekitp/python-mongodb-changestream
0
122411
import os import pymongo import time import random client = pymongo.MongoClient(os.environ['CHANGE_STREAM_DB']) while True: print(client.changestream.collection.insert_one({"temperature": random.random() * 100}).inserted_id) time.sleep(0.050)
[ 1, 1053, 2897, 13, 5215, 282, 962, 7443, 13, 5215, 931, 13, 5215, 4036, 13, 13, 4645, 353, 282, 962, 7443, 29889, 29924, 7443, 4032, 29898, 359, 29889, 21813, 1839, 3210, 24336, 29918, 1254, 1525, 5194, 29918, 4051, 11287, 13, 8000, 5852, 29901, 13, 1678, 1596, 29898, 4645, 29889, 305, 574, 342, 1633, 29889, 10855, 29889, 7851, 29918, 650, 3319, 29908, 12863, 1535, 1115, 4036, 29889, 8172, 580, 334, 29871, 29896, 29900, 29900, 7690, 7851, 287, 29918, 333, 29897, 13, 1678, 931, 29889, 17059, 29898, 29900, 29889, 29900, 29945, 29900, 29897, 13, 2 ]
config.py
Zloklun/telepot-monitor-bot
0
1614614
<filename>config.py #!/usr/bin/python3 # -*- coding: utf-8 *-* import asyncio as aio from os.path import join, dirname from telepot.aio.delegate import exception def sync_exec(coro): aio.ensure_future(coro) DEBUG = True DIR = dirname(__file__) TOKEN_FILE = join(DIR, 'TOKEN') WHITELIST_FILE = join(DIR, 'whitelist_ids') ADMINS_FILE = join(DIR, 'admin_ids') def log(*args, **kwargs): """Placeholder for log()""" pass if DEBUG: from sys import stderr def log(*args, **kwargs): """Print debug messages""" if 'category' in kwargs: tag = '[{}]'.format(kwargs['category']) del kwargs['category'] print(tag, *args, file=stderr) else: print(*args, file=stderr) # Filling whitelist WHITELIST = None try: with open(WHITELIST_FILE) as f: WHITELIST = list(map(int, f.read().split())) log('Whitelist:', WHITELIST, category='Misc') except IOError: log('Whitelist not found. Filtering is off') # Filling admin list ADMINS_LIST = None try: with open(ADMINS_FILE) as f: ADMINS_LIST = list(map(int, f.read().split())) log('Admins:', ADMINS_LIST, category='Misc') except IOError: log('Admins list have not found. No admins supported') # Some seeder functions def _wrap_none(fn): """ Stolen from telepot.aio.delegate.py :param fn: function to wrap :return: wrapped function """ def w(*args, **kwargs): try: return fn(*args, **kwargs) except (KeyError, exception.BadFlavor): return None return w def per_admin(): """ :return: a seeder function that returns the from id only if the from id is in the ``ADMINS_LIST``. If ADMINS_LIST is None, returns None. """ if ADMINS_LIST is not None: return _wrap_none(lambda msg: None) else: return _wrap_none(lambda msg: 1 # msg['from']['id'] if msg['from']['id'] in ADMINS_LIST else None)
[ 1, 529, 9507, 29958, 2917, 29889, 2272, 13, 29937, 14708, 4855, 29914, 2109, 29914, 4691, 29941, 13, 29937, 448, 29930, 29899, 14137, 29901, 23616, 29899, 29947, 334, 29899, 29930, 13, 13, 5215, 408, 948, 3934, 408, 263, 601, 13, 13, 3166, 2897, 29889, 2084, 1053, 5988, 29892, 4516, 978, 13, 3166, 4382, 17765, 29889, 29874, 601, 29889, 21234, 1053, 3682, 13, 13, 13, 1753, 16523, 29918, 4258, 29898, 2616, 29877, 1125, 13, 1678, 263, 601, 29889, 7469, 29918, 29888, 9130, 29898, 2616, 29877, 29897, 13, 13, 13, 18525, 353, 5852, 13, 9464, 353, 4516, 978, 22168, 1445, 1649, 29897, 13, 4986, 29968, 1430, 29918, 7724, 353, 5988, 29898, 9464, 29892, 525, 4986, 29968, 1430, 1495, 13, 25039, 9094, 24360, 29918, 7724, 353, 5988, 29898, 9464, 29892, 525, 1332, 7454, 391, 29918, 4841, 1495, 13, 3035, 16173, 29903, 29918, 7724, 353, 5988, 29898, 9464, 29892, 525, 6406, 29918, 4841, 1495, 13, 13, 13, 1753, 1480, 10456, 5085, 29892, 3579, 19290, 1125, 13, 1678, 9995, 22150, 7694, 363, 1480, 580, 15945, 29908, 13, 1678, 1209, 13, 13, 13, 361, 21681, 29901, 13, 1678, 515, 10876, 1053, 380, 20405, 13, 13, 1678, 822, 1480, 10456, 5085, 29892, 3579, 19290, 1125, 13, 4706, 9995, 11816, 4744, 7191, 15945, 29908, 13, 4706, 565, 525, 7320, 29915, 297, 9049, 5085, 29901, 13, 9651, 4055, 353, 525, 19660, 6525, 4286, 4830, 29898, 19290, 1839, 7320, 11287, 13, 9651, 628, 9049, 5085, 1839, 7320, 2033, 13, 9651, 1596, 29898, 4039, 29892, 334, 5085, 29892, 934, 29922, 303, 20405, 29897, 13, 4706, 1683, 29901, 13, 9651, 1596, 10456, 5085, 29892, 934, 29922, 303, 20405, 29897, 13, 13, 13, 29937, 383, 8873, 377, 7454, 391, 13, 25039, 9094, 24360, 353, 6213, 13, 2202, 29901, 13, 1678, 411, 1722, 29898, 25039, 9094, 24360, 29918, 7724, 29897, 408, 285, 29901, 13, 4706, 12317, 9094, 24360, 353, 1051, 29898, 1958, 29898, 524, 29892, 285, 29889, 949, 2141, 5451, 22130, 13, 4706, 1480, 877, 8809, 7454, 391, 29901, 742, 12317, 9094, 24360, 29892, 7663, 2433, 29924, 10669, 1495, 13, 19499, 10663, 2392, 29901, 13, 1678, 1480, 877, 8809, 7454, 391, 451, 1476, 29889, 19916, 292, 338, 1283, 1495, 13, 13, 13, 29937, 383, 8873, 4113, 1051, 13, 3035, 16173, 29903, 29918, 24360, 353, 6213, 13, 2202, 29901, 13, 1678, 411, 1722, 29898, 3035, 16173, 29903, 29918, 7724, 29897, 408, 285, 29901, 13, 4706, 11033, 16173, 29903, 29918, 24360, 353, 1051, 29898, 1958, 29898, 524, 29892, 285, 29889, 949, 2141, 5451, 22130, 13, 4706, 1480, 877, 3253, 29885, 1144, 29901, 742, 11033, 16173, 29903, 29918, 24360, 29892, 7663, 2433, 29924, 10669, 1495, 13, 19499, 10663, 2392, 29901, 13, 1678, 1480, 877, 3253, 29885, 1144, 1051, 505, 451, 1476, 29889, 1939, 7336, 1144, 6969, 1495, 13, 13, 13, 29937, 3834, 409, 2447, 3168, 13, 13, 1753, 903, 6312, 29918, 9290, 29898, 9144, 1125, 13, 1678, 9995, 13, 1678, 624, 18975, 515, 4382, 17765, 29889, 29874, 601, 29889, 21234, 29889, 2272, 13, 1678, 584, 3207, 7876, 29901, 740, 304, 12244, 13, 1678, 584, 2457, 29901, 21021, 740, 13, 1678, 9995, 13, 1678, 822, 281, 10456, 5085, 29892, 3579, 19290, 1125, 13, 4706, 1018, 29901, 13, 9651, 736, 7876, 10456, 5085, 29892, 3579, 19290, 29897, 13, 4706, 5174, 313, 2558, 2392, 29892, 3682, 29889, 22050, 29943, 4112, 272, 1125, 13, 9651, 736, 6213, 13, 1678, 736, 281, 13, 13, 13, 1753, 639, 29918, 6406, 7295, 13, 1678, 9995, 13, 1678, 584, 2457, 29901, 13, 4706, 263, 409, 2447, 740, 393, 3639, 278, 515, 1178, 871, 565, 278, 515, 1178, 338, 297, 13, 4706, 278, 4954, 3035, 16173, 29903, 29918, 24360, 29952, 1412, 960, 11033, 16173, 29903, 29918, 24360, 338, 6213, 29892, 3639, 6213, 29889, 13, 1678, 9995, 13, 1678, 565, 11033, 16173, 29903, 29918, 24360, 338, 451, 6213, 29901, 13, 4706, 736, 903, 6312, 29918, 9290, 29898, 2892, 10191, 29901, 6213, 29897, 13, 1678, 1683, 29901, 13, 4706, 736, 903, 6312, 29918, 9290, 29898, 2892, 10191, 29901, 13, 462, 965, 29896, 29871, 396, 10191, 1839, 3166, 16215, 333, 2033, 13, 462, 3986, 565, 10191, 1839, 3166, 16215, 333, 2033, 297, 11033, 16173, 29903, 29918, 24360, 13, 462, 3986, 1683, 6213, 29897, 13, 2 ]
operations/subtraction.py
anon-cand/nexpreval
0
159225
<filename>operations/subtraction.py from operations.operation import Operation class Subtraction(Operation): """ Representing an operation to perform Subtraction """ TAG = 'subtraction' __slots__ = ('minuend', 'subtrahend') def __init__(self): self.minuend = None self.subtrahend = None def __hash__(self): return hash(self.minuend) ^ hash(self.subtrahend) def __call__(self): """ Perform the operation on operands :return: a number representing the outcome of operation or NaN """ if self.minuend is not None and self.subtrahend is not None: return self.minuend() - self.subtrahend() return self.NAN def add_operand(self, operand, tag): """ Add an operand for this operation """ if not isinstance(operand, Operation): raise TypeError("Operand of type Operator is expected") if tag not in self.__slots__: raise ValueError("Tag value cannot only be one of following: ", *self.__slots__) if tag == 'minuend': self.minuend = operand elif tag == 'subtrahend': self.subtrahend = operand
[ 1, 529, 9507, 29958, 3372, 800, 29914, 1491, 3018, 428, 29889, 2272, 13, 3166, 6931, 29889, 16453, 1053, 20462, 13, 13, 13, 1990, 3323, 3018, 428, 29898, 10925, 1125, 13, 1678, 9995, 13, 1678, 16314, 292, 385, 5858, 304, 2189, 3323, 3018, 428, 13, 1678, 9995, 13, 1678, 323, 10051, 353, 525, 1491, 3018, 428, 29915, 13, 1678, 4770, 2536, 1862, 1649, 353, 6702, 1195, 29884, 355, 742, 525, 1491, 3018, 29882, 355, 1495, 13, 13, 1678, 822, 4770, 2344, 12035, 1311, 1125, 13, 4706, 1583, 29889, 1195, 29884, 355, 353, 6213, 13, 4706, 1583, 29889, 1491, 3018, 29882, 355, 353, 6213, 13, 13, 1678, 822, 4770, 8568, 12035, 1311, 1125, 13, 4706, 736, 6608, 29898, 1311, 29889, 1195, 29884, 355, 29897, 6228, 6608, 29898, 1311, 29889, 1491, 3018, 29882, 355, 29897, 13, 13, 1678, 822, 4770, 4804, 12035, 1311, 1125, 13, 4706, 9995, 13, 4706, 27313, 278, 5858, 373, 1751, 4167, 13, 4706, 584, 2457, 29901, 263, 1353, 15783, 278, 21957, 310, 5858, 470, 18780, 13, 4706, 9995, 13, 4706, 565, 1583, 29889, 1195, 29884, 355, 338, 451, 6213, 322, 1583, 29889, 1491, 3018, 29882, 355, 338, 451, 6213, 29901, 13, 9651, 736, 1583, 29889, 1195, 29884, 355, 580, 448, 1583, 29889, 1491, 3018, 29882, 355, 580, 13, 4706, 736, 1583, 29889, 29940, 2190, 13, 13, 1678, 822, 788, 29918, 3372, 392, 29898, 1311, 29892, 1751, 392, 29892, 4055, 1125, 13, 4706, 9995, 3462, 385, 1751, 392, 363, 445, 5858, 9995, 13, 4706, 565, 451, 338, 8758, 29898, 3372, 392, 29892, 20462, 1125, 13, 9651, 12020, 20948, 703, 7094, 392, 310, 1134, 6607, 1061, 338, 3806, 1159, 13, 4706, 565, 4055, 451, 297, 1583, 17255, 2536, 1862, 1649, 29901, 13, 9651, 12020, 7865, 2392, 703, 8176, 995, 2609, 871, 367, 697, 310, 1494, 29901, 9162, 334, 1311, 17255, 2536, 1862, 1649, 29897, 13, 4706, 565, 4055, 1275, 525, 1195, 29884, 355, 2396, 13, 9651, 1583, 29889, 1195, 29884, 355, 353, 1751, 392, 13, 4706, 25342, 4055, 1275, 525, 1491, 3018, 29882, 355, 2396, 13, 9651, 1583, 29889, 1491, 3018, 29882, 355, 353, 1751, 392, 13, 13, 2 ]
models/TF/VAE.py
sankhaMukherjee/vae
0
66456
import os os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3' import tensorflow as tf from tensorflow.keras.layers import Dense, Input from tensorflow.keras import Model, layers class Encoder(layers.Layer): def __init__(self, nLatent, layers, activations, name='encoder'): super(Encoder, self).__init__(name=name) self.layers = [ Dense(l, activation=a) for l, a in zip(layers, activations) ] self.mean = Dense(nLatent) self.logVar = Dense(nLatent) def call(self, inputs): # Go through the Dense layers x = inputs * 1 for dl in self.layers: x = dl(x) # Create the latent layer (z) zMean = self.mean(x) zLogVar = self.logVar(x) epsilon = tf.random.normal( shape=zMean.shape, mean=0, stddev=1 ) z = zMean + tf.exp( 0.5 * zLogVar )*epsilon return zMean, zLogVar, z class Decoder(layers.Layer): def __init__(self, nInp, layers, activations, name='encoder'): super(Decoder, self).__init__(name=name) layers = list(reversed(layers)) activations = list(reversed(activations)) self.layers = [ Dense(l, activation=a) for l, a in zip(layers, activations) ] self.result = Dense(nInp, activation=None) def call(self, inputs): # Go through the Dense layers x = inputs * 1 for dl in self.layers: x = dl(x) result = self.result(x) return result class VAE(Model): def __init__(self, nInp, layers, activations, nLatent, lr = 1e-3, name='vae'): super(VAE, self).__init__(name=name) self.nInp = nInp self.nLatent = nLatent self.encoder = Encoder(nLatent=nLatent, layers=layers, activations=activations) self.decoder = Decoder(nInp, layers=layers, activations=activations) self.optimizer = tf.keras.optimizers.Adam(learning_rate = lr) def call(self, inputs): zMean, zLogVar, z = self.encoder(inputs) reconstructed = self.decoder(z) return reconstructed def step(self, x): with tf.GradientTape() as tape: zMean, zLogVar, z = self.encoder(x) xHat = self.decoder( z ) # Reconstruction Loss reconLoss = tf.nn.sigmoid_cross_entropy_with_logits( x, xHat ) reconLoss = tf.reduce_sum( reconLoss, 1 ) reconLoss = tf.reduce_mean( reconLoss ) reconLoss = reconLoss # KL - divergence loss klLoss = - 0.5 * tf.reduce_sum(zLogVar - tf.square(zMean) - tf.exp(zLogVar) + 1, 1) klLoss = tf.reduce_mean( klLoss ) klLoss = klLoss # Calculate the total loss loss = reconLoss + 1e1*klLoss # Optimize grads = tape.gradient(loss, self.trainable_weights) self.optimizer.apply_gradients(zip(grads, self.trainable_weights)) return reconLoss.numpy(), klLoss.numpy(), loss.numpy() def checkpoint(self, folder): folder = os.path.join( folder, 'model', 'modelData' ) os.makedirs( folder, exist_ok=True ) self.save_weights( folder ) return
[ 1, 1053, 2897, 13, 359, 29889, 21813, 1839, 8969, 29918, 6271, 29925, 29918, 16173, 29918, 14480, 29918, 1307, 29963, 6670, 2033, 353, 525, 29941, 29915, 29871, 13, 5215, 26110, 408, 15886, 13, 13, 3166, 26110, 29889, 3946, 294, 29889, 29277, 1053, 360, 1947, 29892, 10567, 13, 3166, 26110, 29889, 3946, 294, 1053, 8125, 29892, 15359, 13, 13, 13, 1990, 11346, 6119, 29898, 29277, 29889, 14420, 1125, 13, 13, 1678, 822, 4770, 2344, 12035, 1311, 29892, 302, 13992, 296, 29892, 15359, 29892, 5039, 800, 29892, 1024, 2433, 3977, 6119, 29374, 13, 13, 4706, 2428, 29898, 8566, 6119, 29892, 1583, 467, 1649, 2344, 12035, 978, 29922, 978, 29897, 13, 13, 4706, 1583, 29889, 29277, 29871, 353, 518, 360, 1947, 29898, 29880, 29892, 26229, 29922, 29874, 29897, 363, 301, 29892, 263, 297, 14319, 29898, 29277, 29892, 5039, 800, 29897, 4514, 13, 4706, 1583, 29889, 12676, 1678, 353, 360, 1947, 29898, 29876, 13992, 296, 29897, 13, 4706, 1583, 29889, 1188, 9037, 29871, 353, 360, 1947, 29898, 29876, 13992, 296, 29897, 13, 13, 1678, 822, 1246, 29898, 1311, 29892, 10970, 1125, 13, 13, 4706, 396, 2921, 1549, 278, 360, 1947, 15359, 13, 4706, 921, 353, 10970, 334, 29871, 29896, 13, 4706, 363, 270, 29880, 297, 1583, 29889, 29277, 29901, 13, 9651, 921, 353, 270, 29880, 29898, 29916, 29897, 13, 308, 13, 4706, 396, 6204, 278, 3405, 296, 7546, 313, 29920, 29897, 13, 4706, 503, 6816, 273, 259, 353, 1583, 29889, 12676, 29898, 29916, 29897, 13, 4706, 503, 3403, 9037, 353, 1583, 29889, 1188, 9037, 29898, 29916, 29897, 13, 4706, 321, 3232, 353, 15886, 29889, 8172, 29889, 8945, 29898, 8267, 29922, 29920, 6816, 273, 29889, 12181, 29892, 2099, 29922, 29900, 29892, 3659, 3359, 29922, 29896, 1723, 13, 4706, 503, 539, 353, 503, 6816, 273, 718, 15886, 29889, 4548, 29898, 29871, 29900, 29889, 29945, 334, 503, 3403, 9037, 1723, 29930, 5463, 13, 13, 4706, 736, 503, 6816, 273, 29892, 503, 3403, 9037, 29892, 503, 13, 13, 1990, 3826, 6119, 29898, 29277, 29889, 14420, 1125, 13, 13, 1678, 822, 4770, 2344, 12035, 1311, 29892, 302, 797, 29886, 29892, 15359, 29892, 5039, 800, 29892, 1024, 2433, 3977, 6119, 29374, 13, 13, 4706, 2428, 29898, 6185, 6119, 29892, 1583, 467, 1649, 2344, 12035, 978, 29922, 978, 29897, 13, 13, 4706, 15359, 418, 353, 1051, 29898, 276, 874, 287, 29898, 29277, 876, 13, 4706, 5039, 800, 353, 1051, 29898, 276, 874, 287, 29898, 11236, 800, 876, 13, 13, 4706, 1583, 29889, 29277, 29871, 353, 518, 360, 1947, 29898, 29880, 29892, 26229, 29922, 29874, 29897, 363, 301, 29892, 263, 297, 14319, 29898, 29277, 29892, 5039, 800, 29897, 4514, 13, 4706, 1583, 29889, 2914, 29871, 353, 360, 1947, 29898, 29876, 797, 29886, 29892, 26229, 29922, 8516, 29897, 13, 13, 1678, 822, 1246, 29898, 1311, 29892, 10970, 1125, 13, 13, 13, 4706, 396, 2921, 1549, 278, 360, 1947, 15359, 13, 4706, 921, 353, 10970, 334, 29871, 29896, 13, 4706, 363, 270, 29880, 297, 1583, 29889, 29277, 29901, 13, 9651, 921, 353, 270, 29880, 29898, 29916, 29897, 13, 308, 13, 4706, 1121, 353, 1583, 29889, 2914, 29898, 29916, 29897, 13, 13, 4706, 736, 1121, 13, 13, 1990, 478, 16036, 29898, 3195, 1125, 13, 13, 1678, 822, 4770, 2344, 12035, 1311, 29892, 302, 797, 29886, 29892, 15359, 29892, 5039, 800, 29892, 302, 13992, 296, 29892, 301, 29878, 353, 29871, 29896, 29872, 29899, 29941, 29892, 1024, 2433, 1564, 29872, 29374, 13, 308, 13, 4706, 2428, 29898, 29963, 16036, 29892, 1583, 467, 1649, 2344, 12035, 978, 29922, 978, 29897, 13, 308, 13, 4706, 1583, 29889, 29876, 797, 29886, 1678, 353, 302, 797, 29886, 13, 4706, 1583, 29889, 29876, 13992, 296, 353, 302, 13992, 296, 13, 4706, 1583, 29889, 3977, 6119, 353, 11346, 6119, 29898, 29876, 13992, 296, 29922, 29876, 13992, 296, 29892, 15359, 29922, 29277, 29892, 5039, 800, 29922, 11236, 800, 29897, 13, 4706, 1583, 29889, 7099, 6119, 353, 3826, 6119, 29898, 29876, 797, 29886, 29892, 15359, 29922, 29277, 29892, 5039, 800, 29922, 11236, 800, 29897, 13, 13, 4706, 1583, 29889, 20640, 3950, 353, 15886, 29889, 3946, 294, 29889, 20640, 19427, 29889, 3253, 314, 29898, 21891, 29918, 10492, 353, 301, 29878, 29897, 13, 13, 1678, 822, 1246, 29898, 1311, 29892, 10970, 1125, 13, 13, 4706, 503, 6816, 273, 29892, 503, 3403, 9037, 29892, 503, 353, 1583, 29889, 3977, 6119, 29898, 2080, 29879, 29897, 13, 4706, 337, 11433, 287, 268, 353, 1583, 29889, 7099, 6119, 29898, 29920, 29897, 13, 308, 13, 4706, 736, 337, 11433, 287, 13, 13, 1678, 822, 4331, 29898, 1311, 29892, 921, 1125, 13, 13, 4706, 411, 15886, 29889, 25584, 993, 29911, 4085, 580, 408, 260, 4085, 29901, 13, 13, 9651, 503, 6816, 273, 29892, 503, 3403, 9037, 29892, 503, 353, 1583, 29889, 3977, 6119, 29898, 29916, 29897, 13, 9651, 921, 29950, 271, 353, 1583, 29889, 7099, 6119, 29898, 503, 1723, 13, 13, 9651, 396, 830, 3075, 4080, 365, 2209, 13, 9651, 8265, 29931, 2209, 353, 15886, 29889, 15755, 29889, 18816, 29885, 3398, 29918, 19128, 29918, 296, 14441, 29918, 2541, 29918, 1188, 1169, 29898, 921, 29892, 921, 29950, 271, 1723, 13, 9651, 8265, 29931, 2209, 353, 15886, 29889, 17469, 29918, 2083, 29898, 8265, 29931, 2209, 29892, 29871, 29896, 1723, 13, 9651, 8265, 29931, 2209, 353, 15886, 29889, 17469, 29918, 12676, 29898, 8265, 29931, 2209, 1723, 13, 9651, 8265, 29931, 2209, 353, 8265, 29931, 2209, 13, 13, 9651, 396, 476, 29931, 448, 17089, 10238, 6410, 13, 9651, 9489, 29931, 2209, 1678, 353, 448, 29871, 29900, 29889, 29945, 334, 15886, 29889, 17469, 29918, 2083, 29898, 29920, 3403, 9037, 448, 15886, 29889, 17619, 29898, 29920, 6816, 273, 29897, 448, 15886, 29889, 4548, 29898, 29920, 3403, 9037, 29897, 718, 29871, 29896, 29892, 29871, 29896, 29897, 13, 9651, 9489, 29931, 2209, 1678, 353, 15886, 29889, 17469, 29918, 12676, 29898, 9489, 29931, 2209, 1723, 13, 9651, 9489, 29931, 2209, 1678, 353, 9489, 29931, 2209, 13, 13, 9651, 396, 20535, 403, 278, 3001, 6410, 13, 9651, 6410, 418, 353, 8265, 29931, 2209, 718, 29871, 29896, 29872, 29896, 29930, 6321, 29931, 2209, 13, 13, 9651, 396, 20693, 326, 675, 13, 9651, 4656, 29879, 268, 353, 260, 4085, 29889, 24970, 29898, 6758, 29892, 1583, 29889, 14968, 519, 29918, 705, 5861, 29897, 13, 9651, 1583, 29889, 20640, 3950, 29889, 7302, 29918, 5105, 10070, 29898, 7554, 29898, 5105, 29879, 29892, 1583, 29889, 14968, 519, 29918, 705, 5861, 876, 13, 13, 4706, 736, 8265, 29931, 2209, 29889, 23749, 3285, 9489, 29931, 2209, 29889, 23749, 3285, 6410, 29889, 23749, 580, 13, 13, 1678, 822, 1423, 3149, 29898, 1311, 29892, 4138, 1125, 13, 13, 4706, 4138, 353, 2897, 29889, 2084, 29889, 7122, 29898, 4138, 29892, 525, 4299, 742, 525, 4299, 1469, 29915, 1723, 13, 4706, 2897, 29889, 29885, 12535, 12935, 29898, 4138, 29892, 1863, 29918, 554, 29922, 5574, 1723, 13, 4706, 1583, 29889, 7620, 29918, 705, 5861, 29898, 4138, 1723, 13, 4706, 736, 13, 2 ]
src/focus/api.py
RogerRueegg/lvw-young-talents
1
22514
from . import models from . import serializers from rest_framework import viewsets, permissions class CompetitionViewSet(viewsets.ModelViewSet): """ViewSet for the Competition class""" queryset = models.Competition.objects.all() serializer_class = serializers.CompetitionSerializer permission_classes = [permissions.IsAuthenticated] class TrainingViewSet(viewsets.ModelViewSet): """ViewSet for the Training class""" queryset = models.Training.objects.all() serializer_class = serializers.TrainingSerializer permission_classes = [permissions.IsAuthenticated] class CompetitorViewSet(viewsets.ModelViewSet): """ViewSet for the Competitor class""" queryset = models.Competitor.objects.all() serializer_class = serializers.CompetitorSerializer permission_classes = [permissions.IsAuthenticated] class TrainingpresenceViewSet(viewsets.ModelViewSet): """ViewSet for the Trainingpresence class""" queryset = models.Trainingpresence.objects.all() serializer_class = serializers.TrainingpresenceSerializer permission_classes = [permissions.IsAuthenticated] class DriverViewSet(viewsets.ModelViewSet): """ViewSet for the Driver class""" queryset = models.Driver.objects.all() serializer_class = serializers.DriverSerializer permission_classes = [permissions.IsAuthenticated] class EventViewSet(viewsets.ModelViewSet): """ViewSet for the Event class""" queryset = models.Event.objects.all() serializer_class = serializers.EventSerializer permission_classes = [permissions.IsAuthenticated] class ResultViewSet(viewsets.ModelViewSet): """ViewSet for the Result class""" queryset = models.Result.objects.all() serializer_class = serializers.ResultSerializer permission_classes = [permissions.IsAuthenticated] class LocationViewSet(viewsets.ModelViewSet): """ViewSet for the Location class""" queryset = models.Location.objects.all() serializer_class = serializers.LocationSerializer permission_classes = [permissions.IsAuthenticated]
[ 1, 515, 869, 1053, 4733, 13, 3166, 869, 1053, 7797, 19427, 13, 3166, 1791, 29918, 4468, 1053, 1776, 7224, 29892, 11239, 13, 13, 13, 1990, 24620, 654, 1043, 2697, 29898, 1493, 7224, 29889, 3195, 1043, 2697, 1125, 13, 1678, 9995, 1043, 2697, 363, 278, 24620, 654, 770, 15945, 29908, 13, 13, 1678, 2346, 842, 353, 4733, 29889, 6843, 300, 654, 29889, 12650, 29889, 497, 580, 13, 1678, 7797, 3950, 29918, 1990, 353, 7797, 19427, 29889, 6843, 300, 654, 17679, 13, 1678, 10751, 29918, 13203, 353, 518, 17858, 6847, 29889, 3624, 6444, 4173, 630, 29962, 13, 13, 13, 1990, 26101, 1043, 2697, 29898, 1493, 7224, 29889, 3195, 1043, 2697, 1125, 13, 1678, 9995, 1043, 2697, 363, 278, 26101, 770, 15945, 29908, 13, 13, 1678, 2346, 842, 353, 4733, 29889, 5323, 2827, 29889, 12650, 29889, 497, 580, 13, 1678, 7797, 3950, 29918, 1990, 353, 7797, 19427, 29889, 5323, 2827, 17679, 13, 1678, 10751, 29918, 13203, 353, 518, 17858, 6847, 29889, 3624, 6444, 4173, 630, 29962, 13, 13, 13, 1990, 24620, 2105, 1043, 2697, 29898, 1493, 7224, 29889, 3195, 1043, 2697, 1125, 13, 1678, 9995, 1043, 2697, 363, 278, 24620, 2105, 770, 15945, 29908, 13, 13, 1678, 2346, 842, 353, 4733, 29889, 6843, 300, 2105, 29889, 12650, 29889, 497, 580, 13, 1678, 7797, 3950, 29918, 1990, 353, 7797, 19427, 29889, 6843, 300, 2105, 17679, 13, 1678, 10751, 29918, 13203, 353, 518, 17858, 6847, 29889, 3624, 6444, 4173, 630, 29962, 13, 13, 13, 1990, 26101, 4569, 663, 1043, 2697, 29898, 1493, 7224, 29889, 3195, 1043, 2697, 1125, 13, 1678, 9995, 1043, 2697, 363, 278, 26101, 4569, 663, 770, 15945, 29908, 13, 13, 1678, 2346, 842, 353, 4733, 29889, 5323, 2827, 4569, 663, 29889, 12650, 29889, 497, 580, 13, 1678, 7797, 3950, 29918, 1990, 353, 7797, 19427, 29889, 5323, 2827, 4569, 663, 17679, 13, 1678, 10751, 29918, 13203, 353, 518, 17858, 6847, 29889, 3624, 6444, 4173, 630, 29962, 13, 13, 13, 1990, 26391, 1043, 2697, 29898, 1493, 7224, 29889, 3195, 1043, 2697, 1125, 13, 1678, 9995, 1043, 2697, 363, 278, 26391, 770, 15945, 29908, 13, 13, 1678, 2346, 842, 353, 4733, 29889, 12376, 29889, 12650, 29889, 497, 580, 13, 1678, 7797, 3950, 29918, 1990, 353, 7797, 19427, 29889, 12376, 17679, 13, 1678, 10751, 29918, 13203, 353, 518, 17858, 6847, 29889, 3624, 6444, 4173, 630, 29962, 13, 13, 13, 1990, 6864, 1043, 2697, 29898, 1493, 7224, 29889, 3195, 1043, 2697, 1125, 13, 1678, 9995, 1043, 2697, 363, 278, 6864, 770, 15945, 29908, 13, 13, 1678, 2346, 842, 353, 4733, 29889, 2624, 29889, 12650, 29889, 497, 580, 13, 1678, 7797, 3950, 29918, 1990, 353, 7797, 19427, 29889, 2624, 17679, 13, 1678, 10751, 29918, 13203, 353, 518, 17858, 6847, 29889, 3624, 6444, 4173, 630, 29962, 13, 13, 13, 1990, 7867, 1043, 2697, 29898, 1493, 7224, 29889, 3195, 1043, 2697, 1125, 13, 1678, 9995, 1043, 2697, 363, 278, 7867, 770, 15945, 29908, 13, 13, 1678, 2346, 842, 353, 4733, 29889, 3591, 29889, 12650, 29889, 497, 580, 13, 1678, 7797, 3950, 29918, 1990, 353, 7797, 19427, 29889, 3591, 17679, 13, 1678, 10751, 29918, 13203, 353, 518, 17858, 6847, 29889, 3624, 6444, 4173, 630, 29962, 13, 13, 13, 1990, 17015, 1043, 2697, 29898, 1493, 7224, 29889, 3195, 1043, 2697, 1125, 13, 1678, 9995, 1043, 2697, 363, 278, 17015, 770, 15945, 29908, 13, 13, 1678, 2346, 842, 353, 4733, 29889, 6508, 29889, 12650, 29889, 497, 580, 13, 1678, 7797, 3950, 29918, 1990, 353, 7797, 19427, 29889, 6508, 17679, 13, 1678, 10751, 29918, 13203, 353, 518, 17858, 6847, 29889, 3624, 6444, 4173, 630, 29962, 13, 13, 13, 2 ]
PyPoll/main.py
laquita44/python-challenge
0
102910
import os import csv import collections from collections import Counter # variables in list candidate_votes = [] candidate_selection = [] # set File path file_path = os.path.join("..", "Resources", "election_data.csv") # set path for reader with open(file_path) as csvfile: csv_reader = csv.reader(csvfile, delimiter=",") # read the header row first csv_header = next(csv_reader) # loop through each row for row in csv_reader: candidate_votes.append(row[2]) # change list to ascending order list = sorted(candidate_votes) # arrange the sorted list arrange_list = list # count votes per candidate in ascending order to append to list candidate_count = Counter (arrange_list) candidate_selection.append(candidate_count.most_common()) # calculate the percentage of votes per candidate for choice in candidate_selection: holder_one = format((choice[0][1])*100/(sum(candidate_count.values())),'.3f') holder_two = format((choice[1][1])*100/(sum(candidate_count.values())),'.3f') holder_three = format((choice[2][1])*100/(sum(candidate_count.values())),'.3f') holder_four = format((choice[3][1])*100/(sum(candidate_count.values())),'.3f') # Print values, sum, and percentages position print("Election Results") print("-------------------------") print(f"Total Votes: {sum(candidate_count.values())}") print("-------------------------") print(f"{candidate_selection[0][0][0]}: {holder_one}% ({candidate_selection[0][0][1]})") print(f"{candidate_selection[0][1][0]}: {holder_two}% ({candidate_selection[0][1][1]})") print(f"{candidate_selection[0][2][0]}: {holder_three}% ({candidate_selection[0][2][1]})") print(f"{candidate_selection[0][3][0]}: {holder_four}% ({candidate_selection[0][3][1]})") print("-------------------------") print(f"Winner: {candidate_selection[0][0][0]}") print("-------------------------") # -->> Export results to text file voter_info_file = os.path.join("out_pypoll.txt") with open(voter_info_file, "w") as outfile: outfile.write("Election Results\n") outfile.write("-------------------------\n") outfile.write(f"Total Votes: {sum(candidate_count.values())}\n") outfile.write("-------------------------\n") outfile.write(f"{candidate_selection[0][0][0]}: {holder_one}% ({candidate_selection[0][0][1]})\n") outfile.write(f"{candidate_selection[0][1][0]}: {holder_two}% ({candidate_selection[0][1][1]})\n") outfile.write(f"{candidate_selection[0][2][0]}: {holder_three}% ({candidate_selection[0][2][1]})\n") outfile.write(f"{candidate_selection[0][3][0]}: {holder_four}% ({candidate_selection[0][3][1]})\n") outfile.write("-------------------------\n") outfile.write(f"Winner: {candidate_selection[0][0][0]}\n") outfile.write("-------------------------\n")
[ 1, 1053, 2897, 30004, 13, 5215, 11799, 30004, 13, 5215, 16250, 30004, 13, 3166, 16250, 1053, 315, 5336, 30004, 13, 30004, 13, 29937, 3651, 297, 1051, 30004, 13, 29883, 5380, 403, 29918, 29894, 4769, 353, 5159, 30004, 13, 29883, 5380, 403, 29918, 21731, 353, 5159, 30004, 13, 30004, 13, 30004, 13, 29937, 731, 3497, 2224, 30004, 13, 1445, 29918, 2084, 353, 2897, 29889, 2084, 29889, 7122, 703, 636, 613, 376, 13770, 613, 376, 29872, 1464, 29918, 1272, 29889, 7638, 1159, 30004, 13, 30004, 13, 29937, 731, 2224, 363, 9591, 30004, 13, 2541, 1722, 29898, 1445, 29918, 2084, 29897, 408, 11799, 1445, 29901, 30004, 13, 1678, 11799, 29918, 16950, 353, 11799, 29889, 16950, 29898, 7638, 1445, 29892, 28552, 543, 29892, 1159, 30004, 13, 259, 396, 1303, 278, 4839, 1948, 937, 30004, 13, 1678, 11799, 29918, 6672, 353, 2446, 29898, 7638, 29918, 16950, 8443, 13, 259, 6756, 13, 1678, 396, 2425, 1549, 1269, 1948, 6756, 13, 1678, 363, 1948, 297, 11799, 29918, 16950, 29901, 30004, 13, 4706, 14020, 29918, 29894, 4769, 29889, 4397, 29898, 798, 29961, 29906, 2314, 30004, 13, 30004, 13, 30004, 13, 1678, 396, 1735, 1051, 304, 12066, 2548, 1797, 30004, 13, 1678, 1051, 353, 12705, 29898, 29883, 5380, 403, 29918, 29894, 4769, 8443, 13, 4706, 6756, 13, 1678, 396, 564, 3881, 278, 12705, 1051, 30004, 13, 1678, 564, 3881, 29918, 1761, 353, 1051, 30004, 13, 30004, 13, 30004, 13, 1678, 396, 2302, 18952, 639, 14020, 297, 12066, 2548, 1797, 304, 9773, 304, 1051, 30004, 13, 1678, 14020, 29918, 2798, 353, 315, 5336, 313, 279, 3881, 29918, 1761, 29897, 6756, 13, 1678, 14020, 29918, 21731, 29889, 4397, 29898, 29883, 5380, 403, 29918, 2798, 29889, 3242, 29918, 9435, 3101, 30004, 13, 30004, 13, 30004, 13, 1678, 396, 8147, 278, 19649, 310, 18952, 639, 14020, 30004, 13, 1678, 363, 7348, 297, 14020, 29918, 21731, 29901, 30004, 13, 539, 6756, 13, 4706, 19464, 29918, 650, 353, 3402, 3552, 16957, 29961, 29900, 3816, 29896, 2314, 29930, 29896, 29900, 29900, 14571, 2083, 29898, 29883, 5380, 403, 29918, 2798, 29889, 5975, 3101, 511, 4286, 29941, 29888, 1495, 30004, 13, 4706, 19464, 29918, 10184, 353, 3402, 3552, 16957, 29961, 29896, 3816, 29896, 2314, 29930, 29896, 29900, 29900, 14571, 2083, 29898, 29883, 5380, 403, 29918, 2798, 29889, 5975, 3101, 511, 4286, 29941, 29888, 1495, 30004, 13, 4706, 19464, 29918, 17536, 353, 3402, 3552, 16957, 29961, 29906, 3816, 29896, 2314, 29930, 29896, 29900, 29900, 14571, 2083, 29898, 29883, 5380, 403, 29918, 2798, 29889, 5975, 3101, 511, 4286, 29941, 29888, 1495, 30004, 13, 4706, 19464, 29918, 17823, 353, 3402, 3552, 16957, 29961, 29941, 3816, 29896, 2314, 29930, 29896, 29900, 29900, 14571, 2083, 29898, 29883, 5380, 403, 29918, 2798, 29889, 5975, 3101, 511, 4286, 29941, 29888, 1495, 30004, 13, 30004, 13, 30004, 13, 418, 6756, 13, 29937, 259, 13905, 1819, 29892, 2533, 29892, 322, 10151, 1179, 2602, 30004, 13, 2158, 703, 29923, 1464, 17212, 1159, 30004, 13, 2158, 703, 2683, 1378, 29899, 1159, 30004, 13, 2158, 29898, 29888, 29908, 11536, 478, 4769, 29901, 29871, 426, 2083, 29898, 29883, 5380, 403, 29918, 2798, 29889, 5975, 580, 2915, 1159, 30004, 13, 2158, 703, 2683, 1378, 29899, 1159, 30004, 13, 2158, 29898, 29888, 29908, 29912, 29883, 5380, 403, 29918, 21731, 29961, 29900, 3816, 29900, 3816, 29900, 29962, 6177, 426, 7694, 29918, 650, 10560, 21313, 29883, 5380, 403, 29918, 21731, 29961, 29900, 3816, 29900, 3816, 29896, 29962, 1800, 1159, 30004, 13, 2158, 29898, 29888, 29908, 29912, 29883, 5380, 403, 29918, 21731, 29961, 29900, 3816, 29896, 3816, 29900, 29962, 6177, 426, 7694, 29918, 10184, 10560, 21313, 29883, 5380, 403, 29918, 21731, 29961, 29900, 3816, 29896, 3816, 29896, 29962, 1800, 1159, 30004, 13, 2158, 29898, 29888, 29908, 29912, 29883, 5380, 403, 29918, 21731, 29961, 29900, 3816, 29906, 3816, 29900, 29962, 6177, 426, 7694, 29918, 17536, 10560, 21313, 29883, 5380, 403, 29918, 21731, 29961, 29900, 3816, 29906, 3816, 29896, 29962, 1800, 1159, 30004, 13, 2158, 29898, 29888, 29908, 29912, 29883, 5380, 403, 29918, 21731, 29961, 29900, 3816, 29941, 3816, 29900, 29962, 6177, 426, 7694, 29918, 17823, 10560, 21313, 29883, 5380, 403, 29918, 21731, 29961, 29900, 3816, 29941, 3816, 29896, 29962, 1800, 1159, 30004, 13, 2158, 703, 2683, 1378, 29899, 1159, 30004, 13, 2158, 29898, 29888, 29908, 29956, 3993, 29901, 29871, 426, 29883, 5380, 403, 29918, 21731, 29961, 29900, 3816, 29900, 3816, 29900, 12258, 1159, 30004, 13, 2158, 703, 2683, 1378, 29899, 1159, 30004, 13, 30004, 13, 29937, 6660, 29958, 29871, 1222, 637, 2582, 304, 1426, 934, 6756, 13, 29894, 17084, 29918, 3888, 29918, 1445, 353, 2897, 29889, 2084, 29889, 7122, 703, 449, 29918, 29886, 1478, 3028, 29889, 3945, 1159, 30004, 13, 2541, 1722, 29898, 29894, 17084, 29918, 3888, 29918, 1445, 29892, 376, 29893, 1159, 408, 714, 1445, 29901, 30004, 13, 30004, 13, 1678, 714, 1445, 29889, 3539, 703, 29923, 1464, 17212, 29905, 29876, 1159, 30004, 13, 1678, 714, 1445, 29889, 3539, 703, 2683, 1378, 2612, 29876, 1159, 30004, 13, 1678, 714, 1445, 29889, 3539, 29898, 29888, 29908, 11536, 478, 4769, 29901, 29871, 426, 2083, 29898, 29883, 5380, 403, 29918, 2798, 29889, 5975, 3101, 1012, 29876, 1159, 30004, 13, 1678, 714, 1445, 29889, 3539, 703, 2683, 1378, 2612, 29876, 1159, 30004, 13, 1678, 714, 1445, 29889, 3539, 29898, 29888, 29908, 29912, 29883, 5380, 403, 29918, 21731, 29961, 29900, 3816, 29900, 3816, 29900, 29962, 6177, 426, 7694, 29918, 650, 10560, 21313, 29883, 5380, 403, 29918, 21731, 29961, 29900, 3816, 29900, 3816, 29896, 29962, 11606, 29876, 1159, 30004, 13, 1678, 714, 1445, 29889, 3539, 29898, 29888, 29908, 29912, 29883, 5380, 403, 29918, 21731, 29961, 29900, 3816, 29896, 3816, 29900, 29962, 6177, 426, 7694, 29918, 10184, 10560, 21313, 29883, 5380, 403, 29918, 21731, 29961, 29900, 3816, 29896, 3816, 29896, 29962, 11606, 29876, 1159, 30004, 13, 1678, 714, 1445, 29889, 3539, 29898, 29888, 29908, 29912, 29883, 5380, 403, 29918, 21731, 29961, 29900, 3816, 29906, 3816, 29900, 29962, 6177, 426, 7694, 29918, 17536, 10560, 21313, 29883, 5380, 403, 29918, 21731, 29961, 29900, 3816, 29906, 3816, 29896, 29962, 11606, 29876, 1159, 30004, 13, 1678, 714, 1445, 29889, 3539, 29898, 29888, 29908, 29912, 29883, 5380, 403, 29918, 21731, 29961, 29900, 3816, 29941, 3816, 29900, 29962, 6177, 426, 7694, 29918, 17823, 10560, 21313, 29883, 5380, 403, 29918, 21731, 29961, 29900, 3816, 29941, 3816, 29896, 29962, 11606, 29876, 1159, 30004, 13, 1678, 714, 1445, 29889, 3539, 703, 2683, 1378, 2612, 29876, 1159, 30004, 13, 1678, 714, 1445, 29889, 3539, 29898, 29888, 29908, 29956, 3993, 29901, 29871, 426, 29883, 5380, 403, 29918, 21731, 29961, 29900, 3816, 29900, 3816, 29900, 29962, 1012, 29876, 1159, 30004, 13, 1678, 714, 1445, 29889, 3539, 703, 2683, 1378, 2612, 29876, 1159, 1678, 6756, 13, 2 ]
ar_app/scripts/renamefiles.py
osetr/ar-opencv-python
1
46276
import os from natsort import natsorted path_to_directory = input("Enter path to directory: ") + "/" new_name = input("Enter new name for files: ") try: i = 0 list_of_files = natsorted(os.listdir(path_to_directory)) for file in list_of_files: i += 1 extension = file.split(".")[1] os.rename( path_to_directory + file, path_to_directory + new_name + str(i) + "." + extension, ) except FileNotFoundError: print("Got unccorect directory path")
[ 1, 1053, 2897, 13, 3166, 302, 1446, 441, 1053, 302, 1446, 18054, 13, 13, 2084, 29918, 517, 29918, 12322, 353, 1881, 703, 10399, 2224, 304, 3884, 29901, 16521, 718, 5591, 29908, 13, 1482, 29918, 978, 353, 1881, 703, 10399, 716, 1024, 363, 2066, 29901, 16521, 13, 13, 2202, 29901, 13, 1678, 474, 353, 29871, 29900, 13, 1678, 1051, 29918, 974, 29918, 5325, 353, 302, 1446, 18054, 29898, 359, 29889, 1761, 3972, 29898, 2084, 29918, 517, 29918, 12322, 876, 13, 1678, 363, 934, 297, 1051, 29918, 974, 29918, 5325, 29901, 13, 4706, 474, 4619, 29871, 29896, 13, 4706, 6081, 353, 934, 29889, 5451, 17350, 1159, 29961, 29896, 29962, 13, 4706, 2897, 29889, 1267, 420, 29898, 13, 9651, 2224, 29918, 517, 29918, 12322, 718, 934, 29892, 13, 9651, 2224, 29918, 517, 29918, 12322, 718, 716, 29918, 978, 718, 851, 29898, 29875, 29897, 718, 376, 1213, 718, 6081, 29892, 13, 4706, 1723, 13, 19499, 3497, 17413, 2392, 29901, 13, 1678, 1596, 703, 29954, 327, 443, 617, 487, 312, 3884, 2224, 1159, 13, 2 ]
mayan/apps/document_comments/search.py
wan1869/dushuhu
1
53608
from django.utils.translation import ugettext_lazy as _ from mayan.apps.documents.search import document_page_search, document_search document_page_search.add_model_field( field='document_version__document__comments__comment', label=_('Comments') ) document_search.add_model_field( field='comments__comment', label=_('Comments') )
[ 1, 515, 9557, 29889, 13239, 29889, 3286, 18411, 1053, 318, 657, 726, 29918, 433, 1537, 408, 903, 13, 13, 3166, 1122, 273, 29889, 13371, 29889, 3225, 29879, 29889, 4478, 1053, 1842, 29918, 3488, 29918, 4478, 29892, 1842, 29918, 4478, 13, 13, 3225, 29918, 3488, 29918, 4478, 29889, 1202, 29918, 4299, 29918, 2671, 29898, 13, 1678, 1746, 2433, 3225, 29918, 3259, 1649, 3225, 1649, 21032, 1649, 9342, 742, 13, 1678, 3858, 29922, 29918, 877, 1523, 1860, 1495, 13, 29897, 13, 3225, 29918, 4478, 29889, 1202, 29918, 4299, 29918, 2671, 29898, 13, 1678, 1746, 2433, 21032, 1649, 9342, 742, 13, 1678, 3858, 29922, 29918, 877, 1523, 1860, 1495, 13, 29897, 13, 2 ]
cachex/caches/__init__.py
malversoft/cachex
0
61655
<reponame>malversoft/cachex # -*- coding: utf-8 -*- """Memoizing cache classes.""" import sys from .Helper import Helper # Setup module as caches pool. this_module = sys.modules[__name__] Helper.setup_pool(this_module) # Expose all properties and methods a pool has. __all__ = list(this_module.add().__dict__) # Convert and expose all cache classes. from .. import standard Helper.with_module_cache_classes(standard, ( add, lambda kls: __all__.append(kls.__name__), )) del sys, Helper, this_module, standard
[ 1, 529, 276, 1112, 420, 29958, 5156, 369, 2695, 29914, 29883, 496, 735, 13, 29937, 448, 29930, 29899, 14137, 29901, 23616, 29899, 29947, 448, 29930, 29899, 13, 15945, 29908, 11442, 29877, 5281, 7090, 4413, 1213, 15945, 13, 13, 13, 5215, 10876, 13, 13, 3166, 869, 10739, 1053, 6162, 546, 13, 13, 13, 29937, 3789, 786, 3883, 408, 274, 14520, 11565, 29889, 13, 1366, 29918, 5453, 353, 10876, 29889, 7576, 29961, 1649, 978, 1649, 29962, 13, 10739, 29889, 14669, 29918, 10109, 29898, 1366, 29918, 5453, 29897, 13, 13, 29937, 1222, 4220, 599, 4426, 322, 3519, 263, 11565, 756, 29889, 13, 1649, 497, 1649, 353, 1051, 29898, 1366, 29918, 5453, 29889, 1202, 2141, 1649, 8977, 1649, 29897, 13, 13, 29937, 14806, 322, 24396, 599, 7090, 4413, 29889, 13, 3166, 6317, 1053, 3918, 13, 10739, 29889, 2541, 29918, 5453, 29918, 8173, 29918, 13203, 29898, 15770, 29892, 313, 13, 12, 1202, 29892, 13, 12, 2892, 413, 3137, 29901, 4770, 497, 26914, 4397, 29898, 29895, 3137, 17255, 978, 1649, 511, 13, 876, 13, 13, 6144, 10876, 29892, 6162, 546, 29892, 445, 29918, 5453, 29892, 3918, 13, 2 ]
app/middlewares/apikey_auth.py
meongbego/IOT_ADRINI
1
38940
<reponame>meongbego/IOT_ADRINI<filename>app/middlewares/apikey_auth.py<gh_stars>1-10 from functools import wraps from app.helpers.rest import * from app import redis_store from flask import request from app.models import model as db import hashlib def apikey_required(f): @wraps(f) def decorated_function(*args, **kwargs): if 'apikey' not in request.headers: return response(400, message=" Invalid access apikey ") else: access_token = db.get_by_id( table="tb_channels", field="channels_key", value=request.headers['apikey'] ) if not access_token: return response(400, message=" Invalid access apikey ") return f(*args, **kwargs) return decorated_function
[ 1, 529, 276, 1112, 420, 29958, 1004, 549, 29890, 2412, 29914, 29902, 2891, 29918, 3035, 29934, 1177, 29902, 29966, 9507, 29958, 932, 29914, 17662, 4495, 267, 29914, 2754, 1989, 29918, 5150, 29889, 2272, 29966, 12443, 29918, 303, 1503, 29958, 29896, 29899, 29896, 29900, 13, 3166, 2090, 312, 8789, 1053, 11463, 567, 13, 3166, 623, 29889, 3952, 6774, 29889, 5060, 1053, 334, 13, 3166, 623, 1053, 29825, 29918, 8899, 13, 3166, 29784, 1053, 2009, 13, 3166, 623, 29889, 9794, 1053, 1904, 408, 4833, 13, 5215, 6608, 1982, 13, 13, 13, 13, 1753, 7882, 1989, 29918, 12403, 29898, 29888, 1125, 13, 1678, 732, 29893, 336, 567, 29898, 29888, 29897, 13, 1678, 822, 10200, 630, 29918, 2220, 10456, 5085, 29892, 3579, 19290, 1125, 13, 4706, 565, 525, 2754, 1989, 29915, 451, 297, 2009, 29889, 13662, 29901, 13, 9651, 736, 2933, 29898, 29946, 29900, 29900, 29892, 2643, 543, 21403, 2130, 7882, 1989, 16521, 13, 4706, 1683, 29901, 13, 9651, 2130, 29918, 6979, 353, 4833, 29889, 657, 29918, 1609, 29918, 333, 29898, 13, 462, 1678, 1591, 543, 22625, 29918, 305, 12629, 613, 13, 462, 1678, 1746, 543, 305, 12629, 29918, 1989, 613, 13, 462, 1678, 995, 29922, 3827, 29889, 13662, 1839, 2754, 1989, 2033, 13, 18884, 1723, 13, 9651, 565, 451, 2130, 29918, 6979, 29901, 13, 18884, 736, 2933, 29898, 29946, 29900, 29900, 29892, 2643, 543, 21403, 2130, 7882, 1989, 16521, 13, 13, 4706, 736, 285, 10456, 5085, 29892, 3579, 19290, 29897, 13, 1678, 736, 10200, 630, 29918, 2220, 2 ]
cuda/bench.py
wsmoses/XSBench-Enzyme
0
194483
<filename>cuda/bench.py import os import subprocess def run(OPTIMIZE, FORWARD, INLINE, NEWCACHE, AA, PHISTRUCT, TEMPLATIZE, VERIFY, runs): comp = subprocess.run(f'OPTIMIZE={OPTIMIZE} FORWARD={FORWARD} INLINE={INLINE} NEWCACHE={NEWCACHE} AA={AA} PHISTRUCT={PHISTRUCT} TEMPLATIZE={TEMPLATIZE} VERIFY={VERIFY} make -B -j', shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) print(f'OPTIMIZE={OPTIMIZE} FORWARD={FORWARD} INLINE={INLINE} NEWCACHE={NEWCACHE} AA={AA} PHISTRUCT={PHISTRUCT} TEMPLATIZE={TEMPLATIZE} VERIFY={VERIFY} make -B -j') # comp = subprocess.run(f'OPTIMIZE={OPTIMIZE} FORWARD={FORWARD} INLINE={INLINE} NEWCACHE={NEWCACHE} AA={AA} PHISTRUCT={PHISTRUCT} TEMPLATIZE={TEMPLATIZE} VERIFY={VERIFY} make -B -j', shell=True) assert (comp.returncode == 0) out = {} for s in range(1, 2): size = 17000000 * s res = [] for i in range(runs): res.append(os.popen("CUDA_VISIBLE_DEVICES=1 ./XSBench -m event -k 0 -l " + str(size) + "| grep \"Runtime\" | grep -e \"[0-9\.]*\" -o").read().strip()) out[size] = res print(f'OPTIMIZE={OPTIMIZE} FORWARD={FORWARD} INLINE={INLINE} NEWCACHE={NEWCACHE} AA={AA} PHISTRUCT={PHISTRUCT} TEMPLATIZE={TEMPLATIZE}', "\t", "\t".join(res), flush=True) return res vars = ["OPTIMIZE", "INLINE", "NEWCACHE", "AA", "PHISTRUCT", "TEMPLATIZE" , "FORWARD"] def do(remain, set): if len(remain) == 0: print(set) run(**set) else: strue = set.copy() strue[remain[0]] = "yes" do(remain[1:], strue) sfalse = set.copy() sfalse[remain[0]] = "no" do(remain[1:], sfalse) do(vars[0:], {"runs":5, "VERIFY":"no"})
[ 1, 529, 9507, 29958, 29883, 6191, 29914, 1785, 305, 29889, 2272, 13, 5215, 2897, 13, 5215, 1014, 5014, 29871, 13, 13, 1753, 1065, 29898, 14094, 7833, 29902, 10721, 29892, 15842, 29956, 17011, 29892, 2672, 18521, 29892, 29091, 29907, 2477, 9606, 29892, 22704, 29892, 349, 29950, 9047, 28283, 1783, 29892, 17067, 3580, 29931, 1299, 29902, 10721, 29892, 478, 1001, 6545, 29979, 29892, 6057, 1125, 13, 1678, 752, 353, 1014, 5014, 29889, 3389, 29898, 29888, 29915, 14094, 7833, 29902, 10721, 3790, 14094, 7833, 29902, 10721, 29913, 15842, 29956, 17011, 3790, 22051, 29956, 17011, 29913, 2672, 18521, 3790, 1177, 18521, 29913, 29091, 29907, 2477, 9606, 3790, 28577, 29907, 2477, 9606, 29913, 22704, 3790, 6344, 29913, 349, 29950, 9047, 28283, 1783, 3790, 19689, 9047, 28283, 1783, 29913, 17067, 3580, 29931, 1299, 29902, 10721, 3790, 4330, 3580, 29931, 1299, 29902, 10721, 29913, 478, 1001, 6545, 29979, 3790, 5348, 6545, 29979, 29913, 1207, 448, 29933, 448, 29926, 742, 6473, 29922, 5574, 29892, 27591, 29922, 1491, 5014, 29889, 2287, 29963, 10074, 29892, 380, 20405, 29922, 1491, 5014, 29889, 2287, 29963, 10074, 29897, 13, 1678, 1596, 29898, 29888, 29915, 14094, 7833, 29902, 10721, 3790, 14094, 7833, 29902, 10721, 29913, 15842, 29956, 17011, 3790, 22051, 29956, 17011, 29913, 2672, 18521, 3790, 1177, 18521, 29913, 29091, 29907, 2477, 9606, 3790, 28577, 29907, 2477, 9606, 29913, 22704, 3790, 6344, 29913, 349, 29950, 9047, 28283, 1783, 3790, 19689, 9047, 28283, 1783, 29913, 17067, 3580, 29931, 1299, 29902, 10721, 3790, 4330, 3580, 29931, 1299, 29902, 10721, 29913, 478, 1001, 6545, 29979, 3790, 5348, 6545, 29979, 29913, 1207, 448, 29933, 448, 29926, 1495, 13, 1678, 396, 752, 353, 1014, 5014, 29889, 3389, 29898, 29888, 29915, 14094, 7833, 29902, 10721, 3790, 14094, 7833, 29902, 10721, 29913, 15842, 29956, 17011, 3790, 22051, 29956, 17011, 29913, 2672, 18521, 3790, 1177, 18521, 29913, 29091, 29907, 2477, 9606, 3790, 28577, 29907, 2477, 9606, 29913, 22704, 3790, 6344, 29913, 349, 29950, 9047, 28283, 1783, 3790, 19689, 9047, 28283, 1783, 29913, 17067, 3580, 29931, 1299, 29902, 10721, 3790, 4330, 3580, 29931, 1299, 29902, 10721, 29913, 478, 1001, 6545, 29979, 3790, 5348, 6545, 29979, 29913, 1207, 448, 29933, 448, 29926, 742, 6473, 29922, 5574, 29897, 13, 13, 1678, 4974, 313, 2388, 29889, 2457, 401, 1275, 29871, 29900, 29897, 13, 1678, 714, 353, 6571, 13, 1678, 363, 269, 297, 3464, 29898, 29896, 29892, 29871, 29906, 1125, 13, 4706, 2159, 353, 29871, 29896, 29955, 29900, 29900, 29900, 29900, 29900, 29900, 334, 269, 13, 4706, 620, 353, 5159, 13, 4706, 363, 474, 297, 3464, 29898, 3389, 29879, 1125, 13, 9651, 620, 29889, 4397, 29898, 359, 29889, 29886, 3150, 703, 29907, 29965, 7698, 29918, 28607, 8979, 1307, 29918, 2287, 29963, 2965, 2890, 29922, 29896, 11431, 29990, 1744, 264, 305, 448, 29885, 1741, 448, 29895, 29871, 29900, 448, 29880, 376, 718, 851, 29898, 2311, 29897, 718, 376, 29989, 12680, 13218, 7944, 5931, 891, 12680, 448, 29872, 13218, 29961, 29900, 29899, 29929, 29905, 5586, 29930, 5931, 448, 29877, 2564, 949, 2141, 17010, 3101, 13, 4706, 714, 29961, 2311, 29962, 353, 620, 13, 4706, 1596, 29898, 29888, 29915, 14094, 7833, 29902, 10721, 3790, 14094, 7833, 29902, 10721, 29913, 15842, 29956, 17011, 3790, 22051, 29956, 17011, 29913, 2672, 18521, 3790, 1177, 18521, 29913, 29091, 29907, 2477, 9606, 3790, 28577, 29907, 2477, 9606, 29913, 22704, 3790, 6344, 29913, 349, 29950, 9047, 28283, 1783, 3790, 19689, 9047, 28283, 1783, 29913, 17067, 3580, 29931, 1299, 29902, 10721, 3790, 4330, 3580, 29931, 1299, 29902, 10721, 29913, 742, 6634, 29873, 613, 6634, 29873, 1642, 7122, 29898, 690, 511, 28371, 29922, 5574, 29897, 13, 1678, 736, 620, 13, 13, 16908, 353, 6796, 14094, 7833, 29902, 10721, 613, 376, 1177, 18521, 613, 376, 28577, 29907, 2477, 9606, 613, 376, 6344, 613, 376, 19689, 9047, 28283, 1783, 613, 376, 4330, 3580, 29931, 1299, 29902, 10721, 29908, 1919, 376, 22051, 29956, 17011, 3108, 13, 13, 1753, 437, 29898, 1745, 475, 29892, 731, 1125, 13, 1678, 565, 7431, 29898, 1745, 475, 29897, 1275, 29871, 29900, 29901, 13, 4706, 1596, 29898, 842, 29897, 13, 4706, 1065, 29898, 1068, 842, 29897, 13, 1678, 1683, 29901, 13, 4706, 851, 434, 353, 731, 29889, 8552, 580, 13, 4706, 851, 434, 29961, 1745, 475, 29961, 29900, 5262, 353, 376, 3582, 29908, 13, 4706, 437, 29898, 1745, 475, 29961, 29896, 29901, 1402, 851, 434, 29897, 13, 4706, 269, 4541, 353, 731, 29889, 8552, 580, 13, 4706, 269, 4541, 29961, 1745, 475, 29961, 29900, 5262, 353, 376, 1217, 29908, 13, 4706, 437, 29898, 1745, 475, 29961, 29896, 29901, 1402, 269, 4541, 29897, 13, 13, 1867, 29898, 16908, 29961, 29900, 29901, 1402, 8853, 3389, 29879, 1115, 29945, 29892, 376, 5348, 6545, 29979, 4710, 1217, 29908, 1800, 13, 2 ]
scripts/portal/map915020100_PT.py
Snewmy/swordie
9
87766
<filename>scripts/portal/map915020100_PT.py<gh_stars>1-10 # Ariant Treasure Vault Entrance (915020100) => Ariant Treasure Vault if 2400 <= chr.getJob() <= 2412 and not sm.hasMobsInField(): sm.warp(915020101, 1) elif sm.hasMobsInField(): sm.chat("Eliminate all of the intruders first.")
[ 1, 529, 9507, 29958, 16713, 29914, 25089, 29914, 1958, 29929, 29896, 29945, 29900, 29906, 29900, 29896, 29900, 29900, 29918, 7982, 29889, 2272, 29966, 12443, 29918, 303, 1503, 29958, 29896, 29899, 29896, 29900, 13, 29937, 25775, 424, 6479, 3745, 478, 1292, 1174, 509, 749, 313, 29929, 29896, 29945, 29900, 29906, 29900, 29896, 29900, 29900, 29897, 1149, 25775, 424, 6479, 3745, 478, 1292, 13, 13, 361, 29871, 29906, 29946, 29900, 29900, 5277, 18460, 29889, 657, 11947, 580, 5277, 29871, 29906, 29946, 29896, 29906, 322, 451, 1560, 29889, 5349, 29924, 26290, 797, 3073, 7295, 13, 1678, 1560, 29889, 4495, 29886, 29898, 29929, 29896, 29945, 29900, 29906, 29900, 29896, 29900, 29896, 29892, 29871, 29896, 29897, 13, 23681, 1560, 29889, 5349, 29924, 26290, 797, 3073, 7295, 13, 1678, 1560, 29889, 13496, 703, 29923, 2576, 16976, 599, 310, 278, 11158, 566, 414, 937, 23157, 2 ]
ops.py
taki0112/CIPS-Tensorflow
6
158570
from cuda.upfirdn_2d import * from cuda.fused_bias_act import fused_bias_act ################################################################################## # Layers ################################################################################## class Conv2D(tf.keras.layers.Layer): def __init__(self, fmaps, kernel, resample_kernel, up, down, gain, lrmul, **kwargs): super(Conv2D, self).__init__(**kwargs) self.fmaps = fmaps self.kernel = kernel self.gain = gain self.lrmul = lrmul self.up = up self.down = down self.k, self.pad0, self.pad1 = compute_paddings(resample_kernel, self.kernel, up, down, is_conv=True) def build(self, input_shape): weight_shape = [self.kernel, self.kernel, input_shape[1], self.fmaps] init_std, self.runtime_coef = compute_runtime_coef(weight_shape, self.gain, self.lrmul) # [kernel, kernel, fmaps_in, fmaps_out] w_init = tf.random.normal(shape=weight_shape, mean=0.0, stddev=init_std) self.w = tf.Variable(w_init, name='w', trainable=True) def call(self, inputs, training=None, mask=None): x = inputs w = self.runtime_coef * self.w # actual conv if self.up: x = upsample_conv_2d(x, w, self.kernel, self.kernel, self.pad0, self.pad1, self.k) elif self.down: x = conv_downsample_2d(x, w, self.kernel, self.kernel, self.pad0, self.pad1, self.k) else: x = tf.nn.conv2d(x, w, data_format='NCHW', strides=[1, 1, 1, 1], padding='SAME') return x class ModulatedConv2D(tf.keras.layers.Layer): def __init__(self, fmaps, style_fmaps, kernel, resample_kernel, up, down, demodulate, fused_modconv, gain, lrmul, **kwargs): super(ModulatedConv2D, self).__init__(**kwargs) assert not (up and down) self.fmaps = fmaps self.style_fmaps = style_fmaps self.kernel = kernel self.demodulate = demodulate self.up = up self.down = down self.fused_modconv = fused_modconv self.gain = gain self.lrmul = lrmul self.k, self.pad0, self.pad1 = compute_paddings(resample_kernel, self.kernel, up, down, is_conv=True) # self.factor = 2 self.mod_dense = Dense(self.style_fmaps, gain=1.0, lrmul=1.0, name='mod_dense') self.mod_bias = BiasAct(lrmul=1.0, act='linear', name='mod_bias') def build(self, input_shape): x_shape, w_shape = input_shape[0], input_shape[1] in_fmaps = x_shape[1] weight_shape = [self.kernel, self.kernel, in_fmaps, self.fmaps] init_std, self.runtime_coef = compute_runtime_coef(weight_shape, self.gain, self.lrmul) # [kkIO] w_init = tf.random.normal(shape=weight_shape, mean=0.0, stddev=init_std) self.w = tf.Variable(w_init, name='w', trainable=True) def scale_conv_weights(self, w): # convolution kernel weights for fused conv weight = self.runtime_coef * self.w # [kkIO] weight = weight[np.newaxis] # [BkkIO] # modulation style = self.mod_dense(w) # [BI] style = self.mod_bias(style) + 1.0 # [BI] weight *= style[:, np.newaxis, np.newaxis, :, np.newaxis] # [BkkIO] # demodulation d = None if self.demodulate: d = tf.math.rsqrt(tf.reduce_sum(tf.square(weight), axis=[1, 2, 3]) + 1e-8) # [BO] weight *= d[:, np.newaxis, np.newaxis, np.newaxis, :] # [BkkIO] return weight, style, d def call(self, inputs, training=None, mask=None): x, y = inputs # height, width = tf.shape(x)[2], tf.shape(x)[3] # prepare weights: [BkkIO] Introduce minibatch dimension # prepare convoultuon kernel weights weight, style, d = self.scale_conv_weights(y) if self.fused_modconv: # Fused => reshape minibatch to convolution groups x = tf.reshape(x, [1, -1, x.shape[2], x.shape[3]]) # weight: reshape, prepare for fused operation new_weight_shape = [tf.shape(weight)[1], tf.shape(weight)[2], tf.shape(weight)[3], -1] # [kkI(BO)] weight = tf.transpose(weight, [1, 2, 3, 0, 4]) # [kkIBO] weight = tf.reshape(weight, shape=new_weight_shape) # [kkI(BO)] else: # [BIhw] Not fused => scale input activations x *= style[:, :, tf.newaxis, tf.newaxis] # Convolution with optional up/downsampling. if self.up: x = upsample_conv_2d(x, weight, self.kernel, self.kernel, self.pad0, self.pad1, self.k) elif self.down: x = conv_downsample_2d(x, weight, self.kernel, self.kernel, self.pad0, self.pad1, self.k) else: x = tf.nn.conv2d(x, weight, data_format='NCHW', strides=[1, 1, 1, 1], padding='SAME') # Reshape/scale output if self.fused_modconv: # Fused => reshape convolution groups back to minibatch x_shape = tf.shape(x) x = tf.reshape(x, [-1, self.fmaps, x_shape[2], x_shape[3]]) elif self.demodulate: # [BOhw] Not fused => scale output activations x *= d[:, :, tf.newaxis, tf.newaxis] return x class Dense(tf.keras.layers.Layer): def __init__(self, fmaps, gain=1.0, lrmul=1.0, **kwargs): super(Dense, self).__init__(**kwargs) self.fmaps = fmaps self.gain = gain self.lrmul = lrmul def build(self, input_shape): fan_in = tf.reduce_prod(input_shape[1:]) weight_shape = [fan_in, self.fmaps] init_std, self.runtime_coef = compute_runtime_coef(weight_shape, self.gain, self.lrmul) w_init = tf.random.normal(shape=weight_shape, mean=0.0, stddev=init_std) self.w = tf.Variable(w_init, name='w', trainable=True) def call(self, inputs, training=None, mask=None): weight = self.runtime_coef * self.w c = tf.reduce_prod(tf.shape(inputs)[1:]) x = tf.reshape(inputs, shape=[-1, c]) x = tf.matmul(x, weight) return x class LabelEmbedding(tf.keras.layers.Layer): def __init__(self, embed_dim, **kwargs): super(LabelEmbedding, self).__init__(**kwargs) self.embed_dim = embed_dim def build(self, input_shape): weight_shape = [input_shape[1], self.embed_dim] # tf 1.15 mean(0.0), std(1.0) default value of tf.initializers.random_normal() w_init = tf.random.normal(shape=weight_shape, mean=0.0, stddev=1.0) self.w = tf.Variable(w_init, name='w', trainable=True) def call(self, inputs, training=None, mask=None): x = tf.matmul(inputs, self.w) return x ################################################################################## # etc ################################################################################## class PixelNorm(tf.keras.layers.Layer): def __init__(self, **kwargs): super(PixelNorm, self).__init__(**kwargs) def call(self, inputs, training=None, mask=None): x = inputs * tf.math.rsqrt(tf.reduce_mean(tf.square(inputs), axis=1, keepdims=True) + 1e-8) return x class BiasAct(tf.keras.layers.Layer): def __init__(self, lrmul, act, **kwargs): super(BiasAct, self).__init__(**kwargs) self.lrmul = lrmul self.act = act def build(self, input_shape): b_init = tf.zeros(shape=(input_shape[1],), dtype=tf.float32) self.b = tf.Variable(b_init, name='b', trainable=True) def call(self, inputs, training=None, mask=None): b = self.lrmul * self.b x = fused_bias_act(inputs, b=b, act=self.act, alpha=None, gain=None) return x class Noise(tf.keras.layers.Layer): def __init__(self, **kwargs): super(Noise, self).__init__(**kwargs) def build(self, input_shape): self.noise_strength = tf.Variable(initial_value=0.0, dtype=tf.float32, trainable=True, name='w') def call(self, inputs, noise=None, training=None, mask=None): x_shape = tf.shape(inputs) # noise: [1, 1, x_shape[2], x_shape[3]] or None if noise is None: noise = tf.random.normal(shape=(x_shape[0], 1, x_shape[2], x_shape[3]), dtype=tf.float32) x = inputs + noise * self.noise_strength return x class MinibatchStd(tf.keras.layers.Layer): def __init__(self, group_size, num_new_features, **kwargs): super(MinibatchStd, self).__init__(**kwargs) self.group_size = group_size self.num_new_features = num_new_features def call(self, inputs, training=None, mask=None): s = tf.shape(inputs) group_size = tf.minimum(self.group_size, s[0]) y = tf.reshape(inputs, [group_size, -1, self.num_new_features, s[1] // self.num_new_features, s[2], s[3]]) y = tf.cast(y, tf.float32) y -= tf.reduce_mean(y, axis=0, keepdims=True) y = tf.reduce_mean(tf.square(y), axis=0) y = tf.sqrt(y + 1e-8) y = tf.reduce_mean(y, axis=[2, 3, 4], keepdims=True) y = tf.reduce_mean(y, axis=[2]) y = tf.cast(y, inputs.dtype) y = tf.tile(y, [group_size, 1, s[2], s[3]]) x = tf.concat([inputs, y], axis=1) return x def compute_runtime_coef(weight_shape, gain, lrmul): fan_in = tf.reduce_prod(weight_shape[:-1]) # [kernel, kernel, fmaps_in, fmaps_out] or [in, out] fan_in = tf.cast(fan_in, dtype=tf.float32) he_std = gain / tf.sqrt(fan_in) init_std = 1.0 / lrmul runtime_coef = he_std * lrmul return init_std, runtime_coef def lerp(a, b, t): out = a + (b - a) * t return out def lerp_clip(a, b, t): out = a + (b - a) * tf.clip_by_value(t, 0.0, 1.0) return out def get_coords(batch_size, height, width): x = tf.linspace(-1, 1, width) x = tf.reshape(x, shape=[1, 1, width, 1]) x = tf.tile(x, multiples=[batch_size, width, 1, 1]) y = tf.linspace(-1, 1, height) y = tf.reshape(y, shape=[1, height, 1, 1]) y = tf.tile(y, multiples=[batch_size, 1, height, 1]) coords = tf.concat([x, y], axis=-1) coords = tf.transpose(coords, perm=[0, 3, 1, 2]) coords = tf.cast(coords, tf.float32) return coords def grid_sample_tf(img, coords, align_corners=False, padding='border'): """ :param img: [B, C, H, W] :param coords: [B, C, H, W] :return: [B, C, H, W] """ def get_pixel_value(img, x, y): """ Utility function to get pixel value for coordinate vectors x and y from a 4D tensor image. Input ----- - img: tensor of shape (B, H, W, C) - x: flattened tensor of shape (B*H*W,) - y: flattened tensor of shape (B*H*W,) Returns ------- - output: tensor of shape (B, H, W, C) """ shape = tf.shape(x) batch_size = shape[0] height = shape[1] width = shape[2] batch_idx = tf.range(0, batch_size) batch_idx = tf.reshape(batch_idx, (batch_size, 1, 1)) b = tf.tile(batch_idx, (1, height, width)) indices = tf.stack([b, y, x], 3) return tf.gather_nd(img, indices) # rescale x and y to [0, W-1/H-1] img = tf.transpose(img, perm=[0, 2, 3, 1]) # -> [N, H, W, C] coords = tf.transpose(coords, perm=[0, 2, 3, 1]) # -> [N, H, W, C] x, y = coords[:, ..., 0], coords[:, ..., 1] x = tf.cast(x, 'float32') y = tf.cast(y, 'float32') side = tf.cast(tf.shape(img)[1], tf.int32) side_f = tf.cast(side, tf.float32) if align_corners: x = ((x + 1) / 2) * (side_f - 1) y = ((y + 1) / 2) * (side_f - 1) else: x = 0.5 * ((x + 1.0) * side_f - 1) y = 0.5 * ((y + 1.0) * side_f - 1) if padding == 'border': x = tf.clip_by_value(x, 0, side_f - 1) y = tf.clip_by_value(y, 0, side_f - 1) # -------------- Changes above -------------------- # grab 4 nearest corner points for each (x_i, y_i) x0 = tf.floor(x) x1 = x0 + 1 y0 = tf.floor(y) y1 = y0 + 1 # recast as float for delta calculation x0 = tf.cast(x0, 'float32') x1 = tf.cast(x1, 'float32') y0 = tf.cast(y0, 'float32') y1 = tf.cast(y1, 'float32') # calculate deltas wa = (x1 - x) * (y1 - y) wb = (x1 - x) * (y - y0) wc = (x - x0) * (y1 - y) wd = (x - x0) * (y - y0) # recast as int for img boundaries x0 = tf.cast(x0, 'int32') x1 = tf.cast(x1, 'int32') y0 = tf.cast(y0, 'int32') y1 = tf.cast(y1, 'int32') # clip to range [0, H-1/W-1] to not violate img boundaries x0 = tf.clip_by_value(x0, 0, side-1) x1 = tf.clip_by_value(x1, 0, side-1) y0 = tf.clip_by_value(y0, 0, side-1) y1 = tf.clip_by_value(y1, 0, side-1) # get pixel value at corner coords Ia = get_pixel_value(img, x0, y0) Ib = get_pixel_value(img, x0, y1) Ic = get_pixel_value(img, x1, y0) Id = get_pixel_value(img, x1, y1) # add dimension for addition wa = tf.expand_dims(wa, axis=3) wb = tf.expand_dims(wb, axis=3) wc = tf.expand_dims(wc, axis=3) wd = tf.expand_dims(wd, axis=3) # compute output out = wa * Ia + wb * Ib + wc * Ic + wd * Id # [N, H, W, C] out = tf.transpose(out, perm=[0, 3, 1, 2]) return out def torch_normalization(x): x /= 255. r, g, b = tf.split(axis=-1, num_or_size_splits=3, value=x) mean = [0.485, 0.456, 0.406] std = [0.229, 0.224, 0.225] x = tf.concat(axis=-1, values=[ (r - mean[0]) / std[0], (g - mean[1]) / std[1], (b - mean[2]) / std[2] ]) return x def inception_processing(filename): x = tf.io.read_file(filename) img = tf.image.decode_jpeg(x, channels=3, dct_method='INTEGER_ACCURATE') img = tf.image.resize(img, [256, 256], antialias=True, method=tf.image.ResizeMethod.BICUBIC) img = tf.image.resize(img, [299, 299], antialias=True, method=tf.image.ResizeMethod.BICUBIC) img = torch_normalization(img) # img = tf.transpose(img, [2, 0, 1]) return img
[ 1, 515, 274, 6191, 29889, 786, 29888, 1823, 29876, 29918, 29906, 29881, 1053, 334, 13, 3166, 274, 6191, 29889, 29888, 3880, 29918, 29890, 3173, 29918, 627, 1053, 285, 3880, 29918, 29890, 3173, 29918, 627, 13, 13, 13383, 13383, 13383, 13383, 13383, 2277, 13, 29937, 365, 388, 414, 13, 13383, 13383, 13383, 13383, 13383, 2277, 13, 13, 1990, 1281, 29894, 29906, 29928, 29898, 13264, 29889, 3946, 294, 29889, 29277, 29889, 14420, 1125, 13, 1678, 822, 4770, 2344, 12035, 1311, 29892, 285, 10339, 29892, 8466, 29892, 620, 981, 29918, 17460, 29892, 701, 29892, 1623, 29892, 11581, 29892, 301, 1758, 352, 29892, 3579, 19290, 1125, 13, 4706, 2428, 29898, 1168, 29894, 29906, 29928, 29892, 1583, 467, 1649, 2344, 12035, 1068, 19290, 29897, 13, 4706, 1583, 29889, 29888, 10339, 353, 285, 10339, 13, 4706, 1583, 29889, 17460, 353, 8466, 13, 4706, 1583, 29889, 29887, 475, 353, 11581, 13, 4706, 1583, 29889, 29880, 1758, 352, 353, 301, 1758, 352, 13, 4706, 1583, 29889, 786, 353, 701, 13, 4706, 1583, 29889, 3204, 353, 1623, 13, 13, 4706, 1583, 29889, 29895, 29892, 1583, 29889, 8305, 29900, 29892, 1583, 29889, 8305, 29896, 353, 10272, 29918, 29886, 1202, 886, 29898, 690, 981, 29918, 17460, 29892, 1583, 29889, 17460, 29892, 701, 29892, 1623, 29892, 338, 29918, 20580, 29922, 5574, 29897, 13, 13, 1678, 822, 2048, 29898, 1311, 29892, 1881, 29918, 12181, 1125, 13, 4706, 7688, 29918, 12181, 353, 518, 1311, 29889, 17460, 29892, 1583, 29889, 17460, 29892, 1881, 29918, 12181, 29961, 29896, 1402, 1583, 29889, 29888, 10339, 29962, 13, 4706, 2069, 29918, 4172, 29892, 1583, 29889, 15634, 29918, 1111, 1389, 353, 10272, 29918, 15634, 29918, 1111, 1389, 29898, 7915, 29918, 12181, 29892, 1583, 29889, 29887, 475, 29892, 1583, 29889, 29880, 1758, 352, 29897, 13, 13, 4706, 396, 518, 17460, 29892, 8466, 29892, 285, 10339, 29918, 262, 29892, 285, 10339, 29918, 449, 29962, 13, 4706, 281, 29918, 2344, 353, 15886, 29889, 8172, 29889, 8945, 29898, 12181, 29922, 7915, 29918, 12181, 29892, 2099, 29922, 29900, 29889, 29900, 29892, 3659, 3359, 29922, 2344, 29918, 4172, 29897, 13, 4706, 1583, 29889, 29893, 353, 15886, 29889, 16174, 29898, 29893, 29918, 2344, 29892, 1024, 2433, 29893, 742, 7945, 519, 29922, 5574, 29897, 13, 13, 1678, 822, 1246, 29898, 1311, 29892, 10970, 29892, 6694, 29922, 8516, 29892, 11105, 29922, 8516, 1125, 13, 4706, 921, 353, 10970, 13, 4706, 281, 353, 1583, 29889, 15634, 29918, 1111, 1389, 334, 1583, 29889, 29893, 13, 13, 4706, 396, 3935, 7602, 13, 4706, 565, 1583, 29889, 786, 29901, 13, 9651, 921, 353, 24081, 981, 29918, 20580, 29918, 29906, 29881, 29898, 29916, 29892, 281, 29892, 1583, 29889, 17460, 29892, 1583, 29889, 17460, 29892, 1583, 29889, 8305, 29900, 29892, 1583, 29889, 8305, 29896, 29892, 1583, 29889, 29895, 29897, 13, 4706, 25342, 1583, 29889, 3204, 29901, 13, 9651, 921, 353, 7602, 29918, 3204, 11249, 29918, 29906, 29881, 29898, 29916, 29892, 281, 29892, 1583, 29889, 17460, 29892, 1583, 29889, 17460, 29892, 1583, 29889, 8305, 29900, 29892, 1583, 29889, 8305, 29896, 29892, 1583, 29889, 29895, 29897, 13, 4706, 1683, 29901, 13, 9651, 921, 353, 15886, 29889, 15755, 29889, 20580, 29906, 29881, 29898, 29916, 29892, 281, 29892, 848, 29918, 4830, 2433, 29940, 3210, 29956, 742, 851, 2247, 11759, 29896, 29892, 29871, 29896, 29892, 29871, 29896, 29892, 29871, 29896, 1402, 7164, 2433, 8132, 2303, 1495, 13, 4706, 736, 921, 13, 13, 1990, 3382, 7964, 1168, 29894, 29906, 29928, 29898, 13264, 29889, 3946, 294, 29889, 29277, 29889, 14420, 1125, 13, 1678, 822, 4770, 2344, 12035, 1311, 29892, 285, 10339, 29892, 3114, 29918, 29888, 10339, 29892, 8466, 29892, 620, 981, 29918, 17460, 29892, 701, 29892, 1623, 29892, 1261, 397, 5987, 29892, 285, 3880, 29918, 1545, 20580, 29892, 11581, 29892, 301, 1758, 352, 29892, 3579, 19290, 1125, 13, 4706, 2428, 29898, 2111, 7964, 1168, 29894, 29906, 29928, 29892, 1583, 467, 1649, 2344, 12035, 1068, 19290, 29897, 13, 4706, 4974, 451, 313, 786, 322, 1623, 29897, 13, 13, 4706, 1583, 29889, 29888, 10339, 353, 285, 10339, 13, 4706, 1583, 29889, 3293, 29918, 29888, 10339, 353, 3114, 29918, 29888, 10339, 13, 4706, 1583, 29889, 17460, 353, 8466, 13, 4706, 1583, 29889, 311, 1545, 5987, 353, 1261, 397, 5987, 13, 4706, 1583, 29889, 786, 353, 701, 13, 4706, 1583, 29889, 3204, 353, 1623, 13, 4706, 1583, 29889, 29888, 3880, 29918, 1545, 20580, 353, 285, 3880, 29918, 1545, 20580, 13, 4706, 1583, 29889, 29887, 475, 353, 11581, 13, 4706, 1583, 29889, 29880, 1758, 352, 353, 301, 1758, 352, 13, 13, 4706, 1583, 29889, 29895, 29892, 1583, 29889, 8305, 29900, 29892, 1583, 29889, 8305, 29896, 353, 10272, 29918, 29886, 1202, 886, 29898, 690, 981, 29918, 17460, 29892, 1583, 29889, 17460, 29892, 701, 29892, 1623, 29892, 338, 29918, 20580, 29922, 5574, 29897, 13, 13, 4706, 396, 1583, 29889, 19790, 353, 29871, 29906, 13, 4706, 1583, 29889, 1545, 29918, 1145, 344, 353, 360, 1947, 29898, 1311, 29889, 3293, 29918, 29888, 10339, 29892, 11581, 29922, 29896, 29889, 29900, 29892, 301, 1758, 352, 29922, 29896, 29889, 29900, 29892, 1024, 2433, 1545, 29918, 1145, 344, 1495, 13, 4706, 1583, 29889, 1545, 29918, 29890, 3173, 353, 350, 3173, 2865, 29898, 29880, 1758, 352, 29922, 29896, 29889, 29900, 29892, 1044, 2433, 10660, 742, 1024, 2433, 1545, 29918, 29890, 3173, 1495, 13, 13, 1678, 822, 2048, 29898, 1311, 29892, 1881, 29918, 12181, 1125, 13, 4706, 921, 29918, 12181, 29892, 281, 29918, 12181, 353, 1881, 29918, 12181, 29961, 29900, 1402, 1881, 29918, 12181, 29961, 29896, 29962, 13, 4706, 297, 29918, 29888, 10339, 353, 921, 29918, 12181, 29961, 29896, 29962, 13, 4706, 7688, 29918, 12181, 353, 518, 1311, 29889, 17460, 29892, 1583, 29889, 17460, 29892, 297, 29918, 29888, 10339, 29892, 1583, 29889, 29888, 10339, 29962, 13, 4706, 2069, 29918, 4172, 29892, 1583, 29889, 15634, 29918, 1111, 1389, 353, 10272, 29918, 15634, 29918, 1111, 1389, 29898, 7915, 29918, 12181, 29892, 1583, 29889, 29887, 475, 29892, 1583, 29889, 29880, 1758, 352, 29897, 13, 13, 4706, 396, 518, 6859, 5971, 29962, 13, 4706, 281, 29918, 2344, 353, 15886, 29889, 8172, 29889, 8945, 29898, 12181, 29922, 7915, 29918, 12181, 29892, 2099, 29922, 29900, 29889, 29900, 29892, 3659, 3359, 29922, 2344, 29918, 4172, 29897, 13, 4706, 1583, 29889, 29893, 353, 15886, 29889, 16174, 29898, 29893, 29918, 2344, 29892, 1024, 2433, 29893, 742, 7945, 519, 29922, 5574, 29897, 13, 13, 1678, 822, 6287, 29918, 20580, 29918, 705, 5861, 29898, 1311, 29892, 281, 1125, 13, 4706, 396, 26851, 8466, 18177, 363, 285, 3880, 7602, 13, 4706, 7688, 353, 1583, 29889, 15634, 29918, 1111, 1389, 334, 1583, 29889, 29893, 29871, 396, 518, 6859, 5971, 29962, 13, 4706, 7688, 353, 7688, 29961, 9302, 29889, 1482, 8990, 29962, 29871, 396, 518, 29933, 6859, 5971, 29962, 13, 13, 4706, 396, 878, 2785, 13, 4706, 3114, 353, 1583, 29889, 1545, 29918, 1145, 344, 29898, 29893, 29897, 29871, 396, 518, 12809, 29962, 13, 4706, 3114, 353, 1583, 29889, 1545, 29918, 29890, 3173, 29898, 3293, 29897, 718, 29871, 29896, 29889, 29900, 29871, 396, 518, 12809, 29962, 13, 4706, 7688, 334, 29922, 3114, 7503, 29892, 7442, 29889, 1482, 8990, 29892, 7442, 29889, 1482, 8990, 29892, 584, 29892, 7442, 29889, 1482, 8990, 29962, 29871, 396, 518, 29933, 6859, 5971, 29962, 13, 13, 4706, 396, 1261, 397, 2785, 13, 4706, 270, 353, 6213, 13, 4706, 565, 1583, 29889, 311, 1545, 5987, 29901, 13, 9651, 270, 353, 15886, 29889, 755, 29889, 2288, 29939, 2273, 29898, 13264, 29889, 17469, 29918, 2083, 29898, 13264, 29889, 17619, 29898, 7915, 511, 9685, 11759, 29896, 29892, 29871, 29906, 29892, 29871, 29941, 2314, 718, 29871, 29896, 29872, 29899, 29947, 29897, 29871, 396, 518, 8456, 29962, 13, 9651, 7688, 334, 29922, 270, 7503, 29892, 7442, 29889, 1482, 8990, 29892, 7442, 29889, 1482, 8990, 29892, 7442, 29889, 1482, 8990, 29892, 584, 29962, 29871, 396, 518, 29933, 6859, 5971, 29962, 13, 13, 4706, 736, 7688, 29892, 3114, 29892, 270, 13, 13, 1678, 822, 1246, 29898, 1311, 29892, 10970, 29892, 6694, 29922, 8516, 29892, 11105, 29922, 8516, 1125, 13, 4706, 921, 29892, 343, 353, 10970, 13, 4706, 396, 3171, 29892, 2920, 353, 15886, 29889, 12181, 29898, 29916, 9601, 29906, 1402, 15886, 29889, 12181, 29898, 29916, 9601, 29941, 29962, 13, 13, 4706, 396, 19012, 18177, 29901, 518, 29933, 6859, 5971, 29962, 3159, 3518, 346, 1375, 747, 905, 9927, 13, 4706, 396, 19012, 7602, 283, 1896, 29884, 265, 8466, 18177, 13, 4706, 7688, 29892, 3114, 29892, 270, 353, 1583, 29889, 7052, 29918, 20580, 29918, 705, 5861, 29898, 29891, 29897, 13, 13, 4706, 565, 1583, 29889, 29888, 3880, 29918, 1545, 20580, 29901, 13, 9651, 396, 383, 3880, 1149, 620, 14443, 1375, 747, 905, 304, 26851, 6471, 13, 9651, 921, 353, 15886, 29889, 690, 14443, 29898, 29916, 29892, 518, 29896, 29892, 448, 29896, 29892, 921, 29889, 12181, 29961, 29906, 1402, 921, 29889, 12181, 29961, 29941, 24960, 13, 13, 9651, 396, 7688, 29901, 620, 14443, 29892, 19012, 363, 285, 3880, 5858, 13, 9651, 716, 29918, 7915, 29918, 12181, 353, 518, 13264, 29889, 12181, 29898, 7915, 9601, 29896, 1402, 15886, 29889, 12181, 29898, 7915, 9601, 29906, 1402, 15886, 29889, 12181, 29898, 7915, 9601, 29941, 1402, 448, 29896, 29962, 29871, 396, 518, 6859, 29902, 29898, 8456, 4638, 13, 9651, 7688, 353, 15886, 29889, 3286, 4220, 29898, 7915, 29892, 518, 29896, 29892, 29871, 29906, 29892, 29871, 29941, 29892, 29871, 29900, 29892, 29871, 29946, 2314, 29871, 396, 518, 6859, 29902, 8456, 29962, 13, 9651, 7688, 353, 15886, 29889, 690, 14443, 29898, 7915, 29892, 8267, 29922, 1482, 29918, 7915, 29918, 12181, 29897, 29871, 396, 518, 6859, 29902, 29898, 8456, 4638, 13, 4706, 1683, 29901, 13, 9651, 396, 518, 12809, 26828, 29962, 2216, 285, 3880, 1149, 6287, 1881, 5039, 800, 13, 9651, 921, 334, 29922, 3114, 7503, 29892, 584, 29892, 15886, 29889, 1482, 8990, 29892, 15886, 29889, 1482, 8990, 29962, 13, 13, 4706, 396, 1281, 4068, 411, 13136, 701, 29914, 3204, 13445, 10335, 29889, 13, 4706, 565, 1583, 29889, 786, 29901, 13, 9651, 921, 353, 24081, 981, 29918, 20580, 29918, 29906, 29881, 29898, 29916, 29892, 7688, 29892, 1583, 29889, 17460, 29892, 1583, 29889, 17460, 29892, 1583, 29889, 8305, 29900, 29892, 1583, 29889, 8305, 29896, 29892, 1583, 29889, 29895, 29897, 13, 4706, 25342, 1583, 29889, 3204, 29901, 13, 9651, 921, 353, 7602, 29918, 3204, 11249, 29918, 29906, 29881, 29898, 29916, 29892, 7688, 29892, 1583, 29889, 17460, 29892, 1583, 29889, 17460, 29892, 1583, 29889, 8305, 29900, 29892, 1583, 29889, 8305, 29896, 29892, 1583, 29889, 29895, 29897, 13, 4706, 1683, 29901, 13, 9651, 921, 353, 15886, 29889, 15755, 29889, 20580, 29906, 29881, 29898, 29916, 29892, 7688, 29892, 848, 29918, 4830, 2433, 29940, 3210, 29956, 742, 851, 2247, 11759, 29896, 29892, 29871, 29896, 29892, 29871, 29896, 29892, 29871, 29896, 1402, 7164, 2433, 8132, 2303, 1495, 13, 13, 4706, 396, 2538, 14443, 29914, 7052, 1962, 13, 4706, 565, 1583, 29889, 29888, 3880, 29918, 1545, 20580, 29901, 13, 9651, 396, 383, 3880, 1149, 620, 14443, 26851, 6471, 1250, 304, 1375, 747, 905, 13, 9651, 921, 29918, 12181, 353, 15886, 29889, 12181, 29898, 29916, 29897, 13, 9651, 921, 353, 15886, 29889, 690, 14443, 29898, 29916, 29892, 21069, 29896, 29892, 1583, 29889, 29888, 10339, 29892, 921, 29918, 12181, 29961, 29906, 1402, 921, 29918, 12181, 29961, 29941, 24960, 13, 4706, 25342, 1583, 29889, 311, 1545, 5987, 29901, 13, 9651, 396, 518, 8456, 26828, 29962, 2216, 285, 3880, 1149, 6287, 1962, 5039, 800, 13, 9651, 921, 334, 29922, 270, 7503, 29892, 584, 29892, 15886, 29889, 1482, 8990, 29892, 15886, 29889, 1482, 8990, 29962, 13, 13, 4706, 736, 921, 13, 13, 13, 1990, 360, 1947, 29898, 13264, 29889, 3946, 294, 29889, 29277, 29889, 14420, 1125, 13, 1678, 822, 4770, 2344, 12035, 1311, 29892, 285, 10339, 29892, 11581, 29922, 29896, 29889, 29900, 29892, 301, 1758, 352, 29922, 29896, 29889, 29900, 29892, 3579, 19290, 1125, 13, 4706, 2428, 29898, 29928, 1947, 29892, 1583, 467, 1649, 2344, 12035, 1068, 19290, 29897, 13, 4706, 1583, 29889, 29888, 10339, 353, 285, 10339, 13, 4706, 1583, 29889, 29887, 475, 353, 11581, 13, 4706, 1583, 29889, 29880, 1758, 352, 353, 301, 1758, 352, 13, 13, 1678, 822, 2048, 29898, 1311, 29892, 1881, 29918, 12181, 1125, 13, 4706, 13524, 29918, 262, 353, 15886, 29889, 17469, 29918, 10633, 29898, 2080, 29918, 12181, 29961, 29896, 29901, 2314, 13, 4706, 7688, 29918, 12181, 353, 518, 12963, 29918, 262, 29892, 1583, 29889, 29888, 10339, 29962, 13, 4706, 2069, 29918, 4172, 29892, 1583, 29889, 15634, 29918, 1111, 1389, 353, 10272, 29918, 15634, 29918, 1111, 1389, 29898, 7915, 29918, 12181, 29892, 1583, 29889, 29887, 475, 29892, 1583, 29889, 29880, 1758, 352, 29897, 13, 13, 4706, 281, 29918, 2344, 353, 15886, 29889, 8172, 29889, 8945, 29898, 12181, 29922, 7915, 29918, 12181, 29892, 2099, 29922, 29900, 29889, 29900, 29892, 3659, 3359, 29922, 2344, 29918, 4172, 29897, 13, 4706, 1583, 29889, 29893, 353, 15886, 29889, 16174, 29898, 29893, 29918, 2344, 29892, 1024, 2433, 29893, 742, 7945, 519, 29922, 5574, 29897, 13, 13, 1678, 822, 1246, 29898, 1311, 29892, 10970, 29892, 6694, 29922, 8516, 29892, 11105, 29922, 8516, 1125, 13, 4706, 7688, 353, 1583, 29889, 15634, 29918, 1111, 1389, 334, 1583, 29889, 29893, 13, 13, 4706, 274, 353, 15886, 29889, 17469, 29918, 10633, 29898, 13264, 29889, 12181, 29898, 2080, 29879, 9601, 29896, 29901, 2314, 13, 4706, 921, 353, 15886, 29889, 690, 14443, 29898, 2080, 29879, 29892, 8267, 11759, 29899, 29896, 29892, 274, 2314, 13, 4706, 921, 353, 15886, 29889, 2922, 16109, 29898, 29916, 29892, 7688, 29897, 13, 4706, 736, 921, 13, 13, 1990, 15796, 6026, 2580, 8497, 29898, 13264, 29889, 3946, 294, 29889, 29277, 29889, 14420, 1125, 13, 1678, 822, 4770, 2344, 12035, 1311, 29892, 8297, 29918, 6229, 29892, 3579, 19290, 1125, 13, 4706, 2428, 29898, 4775, 6026, 2580, 8497, 29892, 1583, 467, 1649, 2344, 12035, 1068, 19290, 29897, 13, 4706, 1583, 29889, 17987, 29918, 6229, 353, 8297, 29918, 6229, 13, 13, 1678, 822, 2048, 29898, 1311, 29892, 1881, 29918, 12181, 1125, 13, 4706, 7688, 29918, 12181, 353, 518, 2080, 29918, 12181, 29961, 29896, 1402, 1583, 29889, 17987, 29918, 6229, 29962, 13, 4706, 396, 15886, 29871, 29896, 29889, 29896, 29945, 2099, 29898, 29900, 29889, 29900, 511, 3659, 29898, 29896, 29889, 29900, 29897, 2322, 995, 310, 15886, 29889, 11228, 19427, 29889, 8172, 29918, 8945, 580, 13, 4706, 281, 29918, 2344, 353, 15886, 29889, 8172, 29889, 8945, 29898, 12181, 29922, 7915, 29918, 12181, 29892, 2099, 29922, 29900, 29889, 29900, 29892, 3659, 3359, 29922, 29896, 29889, 29900, 29897, 13, 4706, 1583, 29889, 29893, 353, 15886, 29889, 16174, 29898, 29893, 29918, 2344, 29892, 1024, 2433, 29893, 742, 7945, 519, 29922, 5574, 29897, 13, 13, 1678, 822, 1246, 29898, 1311, 29892, 10970, 29892, 6694, 29922, 8516, 29892, 11105, 29922, 8516, 1125, 13, 4706, 921, 353, 15886, 29889, 2922, 16109, 29898, 2080, 29879, 29892, 1583, 29889, 29893, 29897, 13, 4706, 736, 921, 13, 13, 13383, 13383, 13383, 13383, 13383, 2277, 13, 29937, 2992, 13, 13383, 13383, 13383, 13383, 13383, 2277, 13, 1990, 349, 15711, 29940, 555, 29898, 13264, 29889, 3946, 294, 29889, 29277, 29889, 14420, 1125, 13, 1678, 822, 4770, 2344, 12035, 1311, 29892, 3579, 19290, 1125, 13, 4706, 2428, 29898, 29637, 29940, 555, 29892, 1583, 467, 1649, 2344, 12035, 1068, 19290, 29897, 13, 13, 1678, 822, 1246, 29898, 1311, 29892, 10970, 29892, 6694, 29922, 8516, 29892, 11105, 29922, 8516, 1125, 13, 4706, 921, 353, 10970, 334, 15886, 29889, 755, 29889, 2288, 29939, 2273, 29898, 13264, 29889, 17469, 29918, 12676, 29898, 13264, 29889, 17619, 29898, 2080, 29879, 511, 9685, 29922, 29896, 29892, 3013, 6229, 29879, 29922, 5574, 29897, 718, 29871, 29896, 29872, 29899, 29947, 29897, 13, 4706, 736, 921, 13, 13, 1990, 350, 3173, 2865, 29898, 13264, 29889, 3946, 294, 29889, 29277, 29889, 14420, 1125, 13, 1678, 822, 4770, 2344, 12035, 1311, 29892, 301, 1758, 352, 29892, 1044, 29892, 3579, 19290, 1125, 13, 4706, 2428, 29898, 29933, 3173, 2865, 29892, 1583, 467, 1649, 2344, 12035, 1068, 19290, 29897, 13, 4706, 1583, 29889, 29880, 1758, 352, 353, 301, 1758, 352, 13, 4706, 1583, 29889, 627, 353, 1044, 13, 13, 1678, 822, 2048, 29898, 1311, 29892, 1881, 29918, 12181, 1125, 13, 4706, 289, 29918, 2344, 353, 15886, 29889, 3298, 359, 29898, 12181, 7607, 2080, 29918, 12181, 29961, 29896, 1402, 511, 26688, 29922, 13264, 29889, 7411, 29941, 29906, 29897, 13, 4706, 1583, 29889, 29890, 353, 15886, 29889, 16174, 29898, 29890, 29918, 2344, 29892, 1024, 2433, 29890, 742, 7945, 519, 29922, 5574, 29897, 13, 13, 1678, 822, 1246, 29898, 1311, 29892, 10970, 29892, 6694, 29922, 8516, 29892, 11105, 29922, 8516, 1125, 13, 4706, 289, 353, 1583, 29889, 29880, 1758, 352, 334, 1583, 29889, 29890, 13, 4706, 921, 353, 285, 3880, 29918, 29890, 3173, 29918, 627, 29898, 2080, 29879, 29892, 289, 29922, 29890, 29892, 1044, 29922, 1311, 29889, 627, 29892, 15595, 29922, 8516, 29892, 11581, 29922, 8516, 29897, 13, 4706, 736, 921, 13, 13, 1990, 1939, 895, 29898, 13264, 29889, 3946, 294, 29889, 29277, 29889, 14420, 1125, 13, 1678, 822, 4770, 2344, 12035, 1311, 29892, 3579, 19290, 1125, 13, 4706, 2428, 29898, 3782, 895, 29892, 1583, 467, 1649, 2344, 12035, 1068, 19290, 29897, 13, 13, 1678, 822, 2048, 29898, 1311, 29892, 1881, 29918, 12181, 1125, 13, 4706, 1583, 29889, 1217, 895, 29918, 710, 1477, 353, 15886, 29889, 16174, 29898, 11228, 29918, 1767, 29922, 29900, 29889, 29900, 29892, 26688, 29922, 13264, 29889, 7411, 29941, 29906, 29892, 7945, 519, 29922, 5574, 29892, 1024, 2433, 29893, 1495, 13, 13, 13, 1678, 822, 1246, 29898, 1311, 29892, 10970, 29892, 11462, 29922, 8516, 29892, 6694, 29922, 8516, 29892, 11105, 29922, 8516, 1125, 13, 4706, 921, 29918, 12181, 353, 15886, 29889, 12181, 29898, 2080, 29879, 29897, 13, 13, 4706, 396, 11462, 29901, 518, 29896, 29892, 29871, 29896, 29892, 921, 29918, 12181, 29961, 29906, 1402, 921, 29918, 12181, 29961, 29941, 5262, 470, 6213, 13, 4706, 565, 11462, 338, 6213, 29901, 13, 9651, 11462, 353, 15886, 29889, 8172, 29889, 8945, 29898, 12181, 7607, 29916, 29918, 12181, 29961, 29900, 1402, 29871, 29896, 29892, 921, 29918, 12181, 29961, 29906, 1402, 921, 29918, 12181, 29961, 29941, 11724, 26688, 29922, 13264, 29889, 7411, 29941, 29906, 29897, 13, 13, 4706, 921, 353, 10970, 718, 11462, 334, 1583, 29889, 1217, 895, 29918, 710, 1477, 13, 4706, 736, 921, 13, 13, 1990, 3080, 747, 905, 855, 29881, 29898, 13264, 29889, 3946, 294, 29889, 29277, 29889, 14420, 1125, 13, 1678, 822, 4770, 2344, 12035, 1311, 29892, 2318, 29918, 2311, 29892, 954, 29918, 1482, 29918, 22100, 29892, 3579, 19290, 1125, 13, 4706, 2428, 29898, 8140, 747, 905, 855, 29881, 29892, 1583, 467, 1649, 2344, 12035, 1068, 19290, 29897, 13, 4706, 1583, 29889, 2972, 29918, 2311, 353, 2318, 29918, 2311, 13, 4706, 1583, 29889, 1949, 29918, 1482, 29918, 22100, 353, 954, 29918, 1482, 29918, 22100, 13, 13, 1678, 822, 1246, 29898, 1311, 29892, 10970, 29892, 6694, 29922, 8516, 29892, 11105, 29922, 8516, 1125, 13, 4706, 269, 353, 15886, 29889, 12181, 29898, 2080, 29879, 29897, 13, 4706, 2318, 29918, 2311, 353, 15886, 29889, 1195, 12539, 29898, 1311, 29889, 2972, 29918, 2311, 29892, 269, 29961, 29900, 2314, 13, 13, 4706, 343, 353, 15886, 29889, 690, 14443, 29898, 2080, 29879, 29892, 518, 2972, 29918, 2311, 29892, 448, 29896, 29892, 1583, 29889, 1949, 29918, 1482, 29918, 22100, 29892, 269, 29961, 29896, 29962, 849, 1583, 29889, 1949, 29918, 1482, 29918, 22100, 29892, 269, 29961, 29906, 1402, 269, 29961, 29941, 24960, 13, 4706, 343, 353, 15886, 29889, 4384, 29898, 29891, 29892, 15886, 29889, 7411, 29941, 29906, 29897, 13, 4706, 343, 22361, 15886, 29889, 17469, 29918, 12676, 29898, 29891, 29892, 9685, 29922, 29900, 29892, 3013, 6229, 29879, 29922, 5574, 29897, 13, 4706, 343, 353, 15886, 29889, 17469, 29918, 12676, 29898, 13264, 29889, 17619, 29898, 29891, 511, 9685, 29922, 29900, 29897, 13, 4706, 343, 353, 15886, 29889, 3676, 29898, 29891, 718, 29871, 29896, 29872, 29899, 29947, 29897, 13, 4706, 343, 353, 15886, 29889, 17469, 29918, 12676, 29898, 29891, 29892, 9685, 11759, 29906, 29892, 29871, 29941, 29892, 29871, 29946, 1402, 3013, 6229, 29879, 29922, 5574, 29897, 13, 4706, 343, 353, 15886, 29889, 17469, 29918, 12676, 29898, 29891, 29892, 9685, 11759, 29906, 2314, 13, 4706, 343, 353, 15886, 29889, 4384, 29898, 29891, 29892, 10970, 29889, 29881, 1853, 29897, 13, 4706, 343, 353, 15886, 29889, 29873, 488, 29898, 29891, 29892, 518, 2972, 29918, 2311, 29892, 29871, 29896, 29892, 269, 29961, 29906, 1402, 269, 29961, 29941, 24960, 13, 13, 4706, 921, 353, 15886, 29889, 17685, 4197, 2080, 29879, 29892, 343, 1402, 9685, 29922, 29896, 29897, 13, 4706, 736, 921, 13, 13, 1753, 10272, 29918, 15634, 29918, 1111, 1389, 29898, 7915, 29918, 12181, 29892, 11581, 29892, 301, 1758, 352, 1125, 13, 1678, 13524, 29918, 262, 353, 15886, 29889, 17469, 29918, 10633, 29898, 7915, 29918, 12181, 7503, 29899, 29896, 2314, 29871, 396, 518, 17460, 29892, 8466, 29892, 285, 10339, 29918, 262, 29892, 285, 10339, 29918, 449, 29962, 470, 518, 262, 29892, 714, 29962, 13, 1678, 13524, 29918, 262, 353, 15886, 29889, 4384, 29898, 12963, 29918, 262, 29892, 26688, 29922, 13264, 29889, 7411, 29941, 29906, 29897, 13, 1678, 540, 29918, 4172, 353, 11581, 847, 15886, 29889, 3676, 29898, 12963, 29918, 262, 29897, 13, 1678, 2069, 29918, 4172, 353, 29871, 29896, 29889, 29900, 847, 301, 1758, 352, 13, 1678, 10073, 29918, 1111, 1389, 353, 540, 29918, 4172, 334, 301, 1758, 352, 13, 1678, 736, 2069, 29918, 4172, 29892, 10073, 29918, 1111, 1389, 13, 13, 1753, 301, 261, 29886, 29898, 29874, 29892, 289, 29892, 260, 1125, 13, 1678, 714, 353, 263, 718, 313, 29890, 448, 263, 29897, 334, 260, 13, 1678, 736, 714, 13, 13, 1753, 301, 261, 29886, 29918, 24049, 29898, 29874, 29892, 289, 29892, 260, 1125, 13, 1678, 714, 353, 263, 718, 313, 29890, 448, 263, 29897, 334, 15886, 29889, 24049, 29918, 1609, 29918, 1767, 29898, 29873, 29892, 29871, 29900, 29889, 29900, 29892, 29871, 29896, 29889, 29900, 29897, 13, 1678, 736, 714, 13, 13, 13, 1753, 679, 29918, 1111, 4339, 29898, 16175, 29918, 2311, 29892, 3171, 29892, 2920, 1125, 13, 13, 1678, 921, 353, 15886, 29889, 1915, 3493, 6278, 29896, 29892, 29871, 29896, 29892, 2920, 29897, 13, 1678, 921, 353, 15886, 29889, 690, 14443, 29898, 29916, 29892, 8267, 11759, 29896, 29892, 29871, 29896, 29892, 2920, 29892, 29871, 29896, 2314, 13, 1678, 921, 353, 15886, 29889, 29873, 488, 29898, 29916, 29892, 2473, 2701, 11759, 16175, 29918, 2311, 29892, 2920, 29892, 29871, 29896, 29892, 29871, 29896, 2314, 13, 13, 1678, 343, 353, 15886, 29889, 1915, 3493, 6278, 29896, 29892, 29871, 29896, 29892, 3171, 29897, 13, 1678, 343, 353, 15886, 29889, 690, 14443, 29898, 29891, 29892, 8267, 11759, 29896, 29892, 3171, 29892, 29871, 29896, 29892, 29871, 29896, 2314, 13, 1678, 343, 353, 15886, 29889, 29873, 488, 29898, 29891, 29892, 2473, 2701, 11759, 16175, 29918, 2311, 29892, 29871, 29896, 29892, 3171, 29892, 29871, 29896, 2314, 13, 13, 1678, 1302, 4339, 353, 15886, 29889, 17685, 4197, 29916, 29892, 343, 1402, 9685, 10457, 29896, 29897, 13, 1678, 1302, 4339, 353, 15886, 29889, 3286, 4220, 29898, 1111, 4339, 29892, 3635, 11759, 29900, 29892, 29871, 29941, 29892, 29871, 29896, 29892, 29871, 29906, 2314, 13, 1678, 1302, 4339, 353, 15886, 29889, 4384, 29898, 1111, 4339, 29892, 15886, 29889, 7411, 29941, 29906, 29897, 13, 13, 1678, 736, 1302, 4339, 13, 13, 1753, 6856, 29918, 11249, 29918, 13264, 29898, 2492, 29892, 1302, 4339, 29892, 7595, 29918, 29883, 1398, 414, 29922, 8824, 29892, 7164, 2433, 11466, 29374, 13, 1678, 9995, 13, 13, 1678, 584, 3207, 10153, 29901, 518, 29933, 29892, 315, 29892, 379, 29892, 399, 29962, 13, 1678, 584, 3207, 1302, 4339, 29901, 518, 29933, 29892, 315, 29892, 379, 29892, 399, 29962, 13, 1678, 584, 2457, 29901, 518, 29933, 29892, 315, 29892, 379, 29892, 399, 29962, 13, 1678, 9995, 13, 1678, 822, 679, 29918, 29886, 15711, 29918, 1767, 29898, 2492, 29892, 921, 29892, 343, 1125, 13, 4706, 9995, 13, 4706, 22310, 537, 740, 304, 679, 15526, 995, 363, 14821, 13, 4706, 12047, 921, 322, 343, 515, 263, 259, 29946, 29928, 12489, 1967, 29889, 13, 4706, 10567, 13, 4706, 448, 807, 13, 4706, 448, 10153, 29901, 12489, 310, 8267, 313, 29933, 29892, 379, 29892, 399, 29892, 315, 29897, 13, 4706, 448, 921, 29901, 1652, 8606, 287, 12489, 310, 8267, 313, 29933, 29930, 29950, 29930, 29956, 29892, 29897, 13, 4706, 448, 343, 29901, 1652, 8606, 287, 12489, 310, 8267, 313, 29933, 29930, 29950, 29930, 29956, 29892, 29897, 13, 4706, 16969, 13, 4706, 448, 22158, 13, 4706, 448, 1962, 29901, 12489, 310, 8267, 313, 29933, 29892, 379, 29892, 399, 29892, 315, 29897, 13, 4706, 9995, 13, 4706, 8267, 353, 15886, 29889, 12181, 29898, 29916, 29897, 13, 4706, 9853, 29918, 2311, 353, 8267, 29961, 29900, 29962, 13, 4706, 3171, 353, 8267, 29961, 29896, 29962, 13, 4706, 2920, 353, 8267, 29961, 29906, 29962, 13, 13, 4706, 9853, 29918, 13140, 353, 15886, 29889, 3881, 29898, 29900, 29892, 9853, 29918, 2311, 29897, 13, 4706, 9853, 29918, 13140, 353, 15886, 29889, 690, 14443, 29898, 16175, 29918, 13140, 29892, 313, 16175, 29918, 2311, 29892, 29871, 29896, 29892, 29871, 29896, 876, 13, 4706, 289, 353, 15886, 29889, 29873, 488, 29898, 16175, 29918, 13140, 29892, 313, 29896, 29892, 3171, 29892, 2920, 876, 13, 13, 4706, 16285, 353, 15886, 29889, 1429, 4197, 29890, 29892, 343, 29892, 921, 1402, 29871, 29941, 29897, 13, 13, 4706, 736, 15886, 29889, 29887, 1624, 29918, 299, 29898, 2492, 29892, 16285, 29897, 13, 13, 1678, 396, 620, 29883, 744, 921, 322, 343, 304, 518, 29900, 29892, 399, 29899, 29896, 29914, 29950, 29899, 29896, 29962, 13, 1678, 10153, 353, 15886, 29889, 3286, 4220, 29898, 2492, 29892, 3635, 11759, 29900, 29892, 29871, 29906, 29892, 29871, 29941, 29892, 29871, 29896, 2314, 396, 1599, 518, 29940, 29892, 379, 29892, 399, 29892, 315, 29962, 13, 1678, 1302, 4339, 353, 15886, 29889, 3286, 4220, 29898, 1111, 4339, 29892, 3635, 11759, 29900, 29892, 29871, 29906, 29892, 29871, 29941, 29892, 29871, 29896, 2314, 396, 1599, 518, 29940, 29892, 379, 29892, 399, 29892, 315, 29962, 13, 13, 1678, 921, 29892, 343, 353, 1302, 4339, 7503, 29892, 2023, 29892, 29871, 29900, 1402, 1302, 4339, 7503, 29892, 2023, 29892, 29871, 29896, 29962, 13, 1678, 921, 353, 15886, 29889, 4384, 29898, 29916, 29892, 525, 7411, 29941, 29906, 1495, 13, 1678, 343, 353, 15886, 29889, 4384, 29898, 29891, 29892, 525, 7411, 29941, 29906, 1495, 13, 13, 1678, 2625, 353, 15886, 29889, 4384, 29898, 13264, 29889, 12181, 29898, 2492, 9601, 29896, 1402, 15886, 29889, 524, 29941, 29906, 29897, 13, 1678, 2625, 29918, 29888, 353, 15886, 29889, 4384, 29898, 2975, 29892, 15886, 29889, 7411, 29941, 29906, 29897, 13, 13, 1678, 565, 7595, 29918, 29883, 1398, 414, 29901, 13, 4706, 921, 353, 5135, 29916, 718, 29871, 29896, 29897, 847, 29871, 29906, 29897, 334, 313, 2975, 29918, 29888, 448, 29871, 29896, 29897, 13, 4706, 343, 353, 5135, 29891, 718, 29871, 29896, 29897, 847, 29871, 29906, 29897, 334, 313, 2975, 29918, 29888, 448, 29871, 29896, 29897, 13, 1678, 1683, 29901, 13, 4706, 921, 353, 29871, 29900, 29889, 29945, 334, 5135, 29916, 718, 29871, 29896, 29889, 29900, 29897, 334, 2625, 29918, 29888, 448, 29871, 29896, 29897, 13, 4706, 343, 353, 29871, 29900, 29889, 29945, 334, 5135, 29891, 718, 29871, 29896, 29889, 29900, 29897, 334, 2625, 29918, 29888, 448, 29871, 29896, 29897, 13, 13, 1678, 565, 7164, 1275, 525, 11466, 2396, 13, 4706, 921, 353, 15886, 29889, 24049, 29918, 1609, 29918, 1767, 29898, 29916, 29892, 29871, 29900, 29892, 2625, 29918, 29888, 448, 29871, 29896, 29897, 13, 4706, 343, 353, 15886, 29889, 24049, 29918, 1609, 29918, 1767, 29898, 29891, 29892, 29871, 29900, 29892, 2625, 29918, 29888, 448, 29871, 29896, 29897, 13, 13, 1678, 396, 448, 9072, 29899, 678, 6916, 2038, 448, 2683, 5634, 13, 1678, 396, 17229, 29871, 29946, 20471, 11155, 3291, 363, 1269, 313, 29916, 29918, 29875, 29892, 343, 29918, 29875, 29897, 13, 1678, 921, 29900, 353, 15886, 29889, 14939, 29898, 29916, 29897, 13, 1678, 921, 29896, 353, 921, 29900, 718, 29871, 29896, 13, 1678, 343, 29900, 353, 15886, 29889, 14939, 29898, 29891, 29897, 13, 1678, 343, 29896, 353, 343, 29900, 718, 29871, 29896, 13, 13, 1678, 396, 1162, 579, 408, 5785, 363, 19471, 13944, 13, 1678, 921, 29900, 353, 15886, 29889, 4384, 29898, 29916, 29900, 29892, 525, 7411, 29941, 29906, 1495, 13, 1678, 921, 29896, 353, 15886, 29889, 4384, 29898, 29916, 29896, 29892, 525, 7411, 29941, 29906, 1495, 13, 1678, 343, 29900, 353, 15886, 29889, 4384, 29898, 29891, 29900, 29892, 525, 7411, 29941, 29906, 1495, 13, 1678, 343, 29896, 353, 15886, 29889, 4384, 29898, 29891, 29896, 29892, 525, 7411, 29941, 29906, 1495, 13, 13, 1678, 396, 8147, 628, 29873, 294, 13, 1678, 11324, 353, 313, 29916, 29896, 448, 921, 29897, 334, 313, 29891, 29896, 448, 343, 29897, 13, 1678, 281, 29890, 353, 313, 29916, 29896, 448, 921, 29897, 334, 313, 29891, 448, 343, 29900, 29897, 13, 1678, 28678, 353, 313, 29916, 448, 921, 29900, 29897, 334, 313, 29891, 29896, 448, 343, 29897, 13, 1678, 281, 29881, 353, 313, 29916, 448, 921, 29900, 29897, 334, 313, 29891, 448, 343, 29900, 29897, 13, 13, 1678, 396, 1162, 579, 408, 938, 363, 10153, 24371, 13, 1678, 921, 29900, 353, 15886, 29889, 4384, 29898, 29916, 29900, 29892, 525, 524, 29941, 29906, 1495, 13, 1678, 921, 29896, 353, 15886, 29889, 4384, 29898, 29916, 29896, 29892, 525, 524, 29941, 29906, 1495, 13, 1678, 343, 29900, 353, 15886, 29889, 4384, 29898, 29891, 29900, 29892, 525, 524, 29941, 29906, 1495, 13, 1678, 343, 29896, 353, 15886, 29889, 4384, 29898, 29891, 29896, 29892, 525, 524, 29941, 29906, 1495, 13, 13, 1678, 396, 20102, 304, 3464, 518, 29900, 29892, 379, 29899, 29896, 29914, 29956, 29899, 29896, 29962, 304, 451, 5537, 403, 10153, 24371, 13, 1678, 921, 29900, 353, 15886, 29889, 24049, 29918, 1609, 29918, 1767, 29898, 29916, 29900, 29892, 29871, 29900, 29892, 2625, 29899, 29896, 29897, 13, 1678, 921, 29896, 353, 15886, 29889, 24049, 29918, 1609, 29918, 1767, 29898, 29916, 29896, 29892, 29871, 29900, 29892, 2625, 29899, 29896, 29897, 13, 1678, 343, 29900, 353, 15886, 29889, 24049, 29918, 1609, 29918, 1767, 29898, 29891, 29900, 29892, 29871, 29900, 29892, 2625, 29899, 29896, 29897, 13, 1678, 343, 29896, 353, 15886, 29889, 24049, 29918, 1609, 29918, 1767, 29898, 29891, 29896, 29892, 29871, 29900, 29892, 2625, 29899, 29896, 29897, 13, 13, 1678, 396, 679, 15526, 995, 472, 11155, 1302, 4339, 13, 1678, 306, 29874, 353, 679, 29918, 29886, 15711, 29918, 1767, 29898, 2492, 29892, 921, 29900, 29892, 343, 29900, 29897, 13, 1678, 29739, 353, 679, 29918, 29886, 15711, 29918, 1767, 29898, 2492, 29892, 921, 29900, 29892, 343, 29896, 29897, 13, 1678, 306, 29883, 353, 679, 29918, 29886, 15711, 29918, 1767, 29898, 2492, 29892, 921, 29896, 29892, 343, 29900, 29897, 13, 1678, 5163, 353, 679, 29918, 29886, 15711, 29918, 1767, 29898, 2492, 29892, 921, 29896, 29892, 343, 29896, 29897, 13, 13, 1678, 396, 788, 9927, 363, 6124, 13, 1678, 11324, 353, 15886, 29889, 18837, 29918, 6229, 29879, 29898, 2766, 29892, 9685, 29922, 29941, 29897, 13, 1678, 281, 29890, 353, 15886, 29889, 18837, 29918, 6229, 29879, 29898, 29893, 29890, 29892, 9685, 29922, 29941, 29897, 13, 1678, 28678, 353, 15886, 29889, 18837, 29918, 6229, 29879, 29898, 29893, 29883, 29892, 9685, 29922, 29941, 29897, 13, 1678, 281, 29881, 353, 15886, 29889, 18837, 29918, 6229, 29879, 29898, 9970, 29892, 9685, 29922, 29941, 29897, 13, 13, 1678, 396, 10272, 1962, 13, 1678, 714, 353, 11324, 334, 306, 29874, 718, 281, 29890, 334, 29739, 718, 28678, 334, 306, 29883, 718, 281, 29881, 334, 5163, 396, 518, 29940, 29892, 379, 29892, 399, 29892, 315, 29962, 13, 1678, 714, 353, 15886, 29889, 3286, 4220, 29898, 449, 29892, 3635, 11759, 29900, 29892, 29871, 29941, 29892, 29871, 29896, 29892, 29871, 29906, 2314, 13, 13, 1678, 736, 714, 13, 13, 1753, 4842, 305, 29918, 8945, 2133, 29898, 29916, 1125, 13, 1678, 921, 847, 29922, 29871, 29906, 29945, 29945, 29889, 13, 13, 1678, 364, 29892, 330, 29892, 289, 353, 15886, 29889, 5451, 29898, 8990, 10457, 29896, 29892, 954, 29918, 272, 29918, 2311, 29918, 23579, 1169, 29922, 29941, 29892, 995, 29922, 29916, 29897, 13, 13, 1678, 2099, 353, 518, 29900, 29889, 29946, 29947, 29945, 29892, 29871, 29900, 29889, 29946, 29945, 29953, 29892, 29871, 29900, 29889, 29946, 29900, 29953, 29962, 13, 1678, 3659, 353, 518, 29900, 29889, 29906, 29906, 29929, 29892, 29871, 29900, 29889, 29906, 29906, 29946, 29892, 29871, 29900, 29889, 29906, 29906, 29945, 29962, 13, 13, 1678, 921, 353, 15886, 29889, 17685, 29898, 8990, 10457, 29896, 29892, 1819, 11759, 13, 4706, 313, 29878, 448, 2099, 29961, 29900, 2314, 847, 3659, 29961, 29900, 1402, 13, 4706, 313, 29887, 448, 2099, 29961, 29896, 2314, 847, 3659, 29961, 29896, 1402, 13, 4706, 313, 29890, 448, 2099, 29961, 29906, 2314, 847, 3659, 29961, 29906, 29962, 13, 268, 2314, 13, 13, 1678, 736, 921, 13, 13, 13, 1753, 297, 1441, 29918, 19170, 29898, 9507, 1125, 13, 1678, 921, 353, 15886, 29889, 601, 29889, 949, 29918, 1445, 29898, 9507, 29897, 13, 1678, 10153, 353, 15886, 29889, 3027, 29889, 13808, 29918, 26568, 29898, 29916, 29892, 18196, 29922, 29941, 29892, 270, 312, 29918, 5696, 2433, 1177, 4330, 17070, 29918, 2477, 22484, 3040, 1495, 13, 1678, 10153, 353, 15886, 29889, 3027, 29889, 21476, 29898, 2492, 29892, 518, 29906, 29945, 29953, 29892, 29871, 29906, 29945, 29953, 1402, 3677, 616, 3173, 29922, 5574, 29892, 1158, 29922, 13264, 29889, 3027, 29889, 1666, 675, 4062, 29889, 29933, 2965, 7466, 2965, 29897, 13, 1678, 10153, 353, 15886, 29889, 3027, 29889, 21476, 29898, 2492, 29892, 518, 29906, 29929, 29929, 29892, 29871, 29906, 29929, 29929, 1402, 3677, 616, 3173, 29922, 5574, 29892, 1158, 29922, 13264, 29889, 3027, 29889, 1666, 675, 4062, 29889, 29933, 2965, 7466, 2965, 29897, 13, 13, 1678, 10153, 353, 4842, 305, 29918, 8945, 2133, 29898, 2492, 29897, 13, 1678, 396, 10153, 353, 15886, 29889, 3286, 4220, 29898, 2492, 29892, 518, 29906, 29892, 29871, 29900, 29892, 29871, 29896, 2314, 13, 1678, 736, 10153, 2 ]
pyrap/utils.py
danielnyga/pyrap
9
81366
<filename>pyrap/utils.py ''' Created on Nov 10, 2015 @author: nyga ''' import datetime import email import os import sys import collections from dnutils import edict # # case-insensitive dict taken from requests # class CaseInsensitiveDict(collections.MutableMapping): """ A case-insensitive ``dict``-like object. Implements all methods and operations of ``collections.MutableMapping`` as well as dict's ``copy``. Also provides ``lower_items``. All keys are expected to be strings. The structure remembers the case of the last key to be set, and ``iter(instance)``, ``keys()``, ``items()``, ``iterkeys()``, and ``iteritems()`` will contain case-sensitive keys. However, querying and contains testing is case insensitive:: cid = CaseInsensitiveDict() cid['Accept'] = 'application/json' cid['aCCEPT'] == 'application/json' # True list(cid) == ['Accept'] # True For example, ``headers['content-encoding']`` will return the value of a ``'Content-Encoding'`` response header, regardless of how the header name was originally stored. If the constructor, ``.update``, or equality comparison operations are given keys that have equal ``.lower()``s, the behavior is undefined. """ def __init__(self, data=None, **kwargs): self._store = dict() if data is None: data = {} self.update(data, **kwargs) def __setitem__(self, key, value): # Use the lowercased key for lookups, but store the actual # key alongside the value. self._store[key.lower()] = (key, value) def __getitem__(self, key): return self._store[key.lower()][1] def __delitem__(self, key): del self._store[key.lower()] def __iter__(self): return (casedkey for casedkey, mappedvalue in self._store.values()) def __len__(self): return len(self._store) def lower_items(self): """Like iteritems(), but with all lowercase keys.""" return ( (lowerkey, keyval[1]) for (lowerkey, keyval) in self._store.items() ) def __eq__(self, other): if isinstance(other, collections.Mapping): other = CaseInsensitiveDict(other) else: return NotImplemented # Compare insensitively return dict(self.lower_items()) == dict(other.lower_items()) # Copy is required def copy(self): return CaseInsensitiveDict(self._store.values()) def __repr__(self): return str(dict(self.items())) class RStorage(dict): ''' Recursive extension of web.util.Storage that applies the Storage constructor recursively to all value elements that are dicts. ''' __slots__ = [] def __init__(self, d=None): if d is not None: for k, v in d.items(): self[k] = v def __setattr__(self, key, value): if key in self.__slots__: self.__dict__[key] = value else: self[key] = value def __setitem__(self, key, value): dict.__setitem__(self, key, rstorify(value)) def __getattr__(self, key): if key in type(self).__slots__: return self.__dict__[key] else: try: return self[key] except KeyError as k: raise AttributeError(k) def __delattr__(self, key): try: del self[key] except KeyError as k: raise AttributeError(k) def __repr__(self): return ('<%s ' % type(self).__name__) + dict.__repr__(self) + '>' def rstorify(e): if type(e) is dict: return RStorage(d=e) elif type(e) in (list, tuple): return [rstorify(i) for i in e] else: return e def jsonify(o): if hasattr(o, 'json'): return o.json elif isinstance(o, dict): return {str(k): jsonify(v) for k, v in o.items()} elif type(o) in (list, tuple, map): return [jsonify(e) for e in o] elif isinstance(o, (int, float, bool, str, type(None))): return o else: raise TypeError('object of type "%s" is not jsonifiable: %s' % (type(o), repr(o))) class BiMap: ''' Bi-directional mapping. ''' def __init__(self, values=None): self._fwd = {} self._bwd = {} self += values self.__iter__ = self._fwd.__iter__ self.items = self._fwd.items self.keys = self._fwd.keys self.values = self._fwd.values def __iadd__(self, values): if type(values) in (list, tuple): for f, b in values: self[f:b] elif isinstance(values, (dict, BiMap)): for f, b in values.items(): self[f:b] return self def __add__(self, values): newmap = BiMap(self) newmap += values return newmap def __getitem__(self, s): if type(s) is slice: if not s.start and s.stop: return self._bwd[s.stop] if s.start and not s.stop: return self._fwd[s.start] if s.start and s.stop: self._fwd[s.start] = s.stop self._bwd[s.stop] = s.start else: raise AttributeError('Slice argument for BiMap cannot be empty') else: return self._fwd[s] def __contains__(self, e): return e in self._fwd or e in self._bwd def __str__(self): return ';'.join([str(e) for e in list(self._fwd.items())]) class BitMask(BiMap): def __init__(self, *values): BiMap.__init__(self) self._count = 0 for v in values: numval = 1 << self._count setattr(self, v, numval) self._count += 1 self[numval:v] def pparti(number, proportions): ''' Partition a number into a sum of n integers, proportionally to the ratios given in proportions. The result is guaranteed to sun up to ``number``, so it is cleaned wrt. to numerical instabilities. ''' Z = sum(proportions) percents = [float(p) / Z for p in proportions] result = [max(0, int(round(p * number))) for p in percents[:-1]] return result + [number - sum(result)] def bind(**kwargs): def wrap_f(function): def probeFunc(frame, event, arg): if event == 'call': frame.f_locals.update(kwargs) frame.f_globals.update(kwargs) elif event == 'return': for key in kwargs: kwargs[key] = frame.f_locals[key] sys.settrace(None) return probeFunc def traced(*args, **kwargs): sys.settrace(probeFunc) function(*args, **kwargs) return traced return wrap_f def parse_datetime(dt): return datetime.datetime.utcfromtimestamp(email.utils.mktime_tz(email.utils.parsedate_tz(dt))) def format_datetime(dt): return email.utils.formatdate(dt.timestamp(), True) if __name__ == '__main__': print(pparti(10, [.2, .2, .1, .5]))
[ 1, 529, 9507, 29958, 2272, 2390, 29914, 13239, 29889, 2272, 13, 12008, 13, 20399, 373, 2864, 29871, 29896, 29900, 29892, 29871, 29906, 29900, 29896, 29945, 13, 13, 29992, 8921, 29901, 7098, 3249, 13, 12008, 13, 5215, 12865, 13, 5215, 4876, 13, 5215, 2897, 13, 5215, 10876, 13, 13, 5215, 16250, 13, 3166, 270, 29876, 13239, 1053, 1226, 919, 13, 13, 29937, 13, 29937, 1206, 29899, 1144, 575, 3321, 9657, 4586, 515, 7274, 13, 29937, 13, 1990, 11733, 797, 23149, 3321, 21533, 29898, 29027, 29889, 15211, 15845, 1125, 13, 1678, 9995, 13, 1678, 319, 1206, 29899, 1144, 575, 3321, 4954, 8977, 16159, 29899, 4561, 1203, 29889, 13, 1678, 1954, 9711, 599, 3519, 322, 6931, 310, 13, 1678, 4954, 29027, 29889, 15211, 15845, 16159, 408, 1532, 408, 9657, 29915, 29879, 4954, 8552, 29952, 1412, 3115, 13, 1678, 8128, 4954, 13609, 29918, 7076, 29952, 1412, 13, 1678, 2178, 6611, 526, 3806, 304, 367, 6031, 29889, 450, 3829, 1083, 13415, 278, 13, 1678, 1206, 310, 278, 1833, 1820, 304, 367, 731, 29892, 322, 4954, 1524, 29898, 8758, 3569, 1673, 13, 1678, 4954, 8149, 2555, 1673, 4954, 7076, 2555, 1673, 4954, 1524, 8149, 2555, 1673, 322, 4954, 1524, 7076, 2555, 29952, 13, 1678, 674, 1712, 1206, 29899, 23149, 3321, 6611, 29889, 2398, 29892, 2346, 292, 322, 3743, 13, 1678, 6724, 338, 1206, 1663, 575, 3321, 1057, 13, 4706, 274, 333, 353, 11733, 797, 23149, 3321, 21533, 580, 13, 4706, 274, 333, 1839, 23965, 2033, 353, 525, 6214, 29914, 3126, 29915, 13, 4706, 274, 333, 1839, 29874, 19043, 7982, 2033, 1275, 525, 6214, 29914, 3126, 29915, 29871, 396, 5852, 13, 4706, 1051, 29898, 25232, 29897, 1275, 6024, 23965, 2033, 29871, 396, 5852, 13, 1678, 1152, 1342, 29892, 4954, 13662, 1839, 3051, 29899, 22331, 2033, 16159, 674, 736, 278, 13, 1678, 995, 310, 263, 4954, 29915, 3916, 29899, 14934, 11120, 29952, 2933, 4839, 29892, 17126, 13, 1678, 310, 920, 278, 4839, 1024, 471, 10437, 6087, 29889, 13, 1678, 960, 278, 5823, 29892, 421, 1412, 5504, 29952, 1673, 470, 17193, 10230, 13, 1678, 6931, 526, 2183, 6611, 393, 505, 5186, 421, 1412, 13609, 2555, 29952, 29879, 29892, 278, 13, 1678, 6030, 338, 7580, 29889, 13, 1678, 9995, 13, 1678, 822, 4770, 2344, 12035, 1311, 29892, 848, 29922, 8516, 29892, 3579, 19290, 1125, 13, 4706, 1583, 3032, 8899, 353, 9657, 580, 13, 4706, 565, 848, 338, 6213, 29901, 13, 9651, 848, 353, 6571, 13, 4706, 1583, 29889, 5504, 29898, 1272, 29892, 3579, 19290, 29897, 13, 13, 1678, 822, 4770, 842, 667, 12035, 1311, 29892, 1820, 29892, 995, 1125, 13, 4706, 396, 4803, 278, 5224, 29883, 1463, 1820, 363, 1106, 14340, 29892, 541, 3787, 278, 3935, 13, 4706, 396, 1820, 19963, 278, 995, 29889, 13, 4706, 1583, 3032, 8899, 29961, 1989, 29889, 13609, 580, 29962, 353, 313, 1989, 29892, 995, 29897, 13, 13, 1678, 822, 4770, 657, 667, 12035, 1311, 29892, 1820, 1125, 13, 4706, 736, 1583, 3032, 8899, 29961, 1989, 29889, 13609, 580, 3816, 29896, 29962, 13, 13, 1678, 822, 4770, 6144, 667, 12035, 1311, 29892, 1820, 1125, 13, 4706, 628, 1583, 3032, 8899, 29961, 1989, 29889, 13609, 580, 29962, 13, 13, 1678, 822, 4770, 1524, 12035, 1311, 1125, 13, 4706, 736, 313, 29883, 1463, 1989, 363, 274, 1463, 1989, 29892, 20545, 1767, 297, 1583, 3032, 8899, 29889, 5975, 3101, 13, 13, 1678, 822, 4770, 2435, 12035, 1311, 1125, 13, 4706, 736, 7431, 29898, 1311, 3032, 8899, 29897, 13, 13, 1678, 822, 5224, 29918, 7076, 29898, 1311, 1125, 13, 4706, 9995, 27552, 4256, 7076, 3285, 541, 411, 599, 5224, 4878, 6611, 1213, 15945, 13, 4706, 736, 313, 13, 9651, 313, 13609, 1989, 29892, 1820, 791, 29961, 29896, 2314, 13, 9651, 363, 313, 13609, 1989, 29892, 1820, 791, 29897, 13, 9651, 297, 1583, 3032, 8899, 29889, 7076, 580, 13, 4706, 1723, 13, 13, 1678, 822, 4770, 1837, 12035, 1311, 29892, 916, 1125, 13, 4706, 565, 338, 8758, 29898, 1228, 29892, 16250, 29889, 15845, 1125, 13, 9651, 916, 353, 11733, 797, 23149, 3321, 21533, 29898, 1228, 29897, 13, 4706, 1683, 29901, 13, 9651, 736, 2216, 1888, 2037, 287, 13, 4706, 396, 3831, 598, 1663, 575, 277, 3598, 13, 4706, 736, 9657, 29898, 1311, 29889, 13609, 29918, 7076, 3101, 1275, 9657, 29898, 1228, 29889, 13609, 29918, 7076, 3101, 13, 13, 1678, 396, 14187, 338, 3734, 13, 1678, 822, 3509, 29898, 1311, 1125, 13, 4706, 736, 11733, 797, 23149, 3321, 21533, 29898, 1311, 3032, 8899, 29889, 5975, 3101, 13, 13, 1678, 822, 4770, 276, 558, 12035, 1311, 1125, 13, 4706, 736, 851, 29898, 8977, 29898, 1311, 29889, 7076, 22130, 13, 13, 13, 1990, 390, 10486, 29898, 8977, 1125, 13, 1678, 14550, 13, 1678, 3599, 25397, 6081, 310, 1856, 29889, 4422, 29889, 10486, 393, 16058, 278, 26162, 5823, 13, 1678, 8304, 3598, 304, 599, 995, 3161, 393, 526, 9657, 29879, 29889, 13, 1678, 14550, 13, 1678, 4770, 2536, 1862, 1649, 353, 5159, 13, 13, 1678, 822, 4770, 2344, 12035, 1311, 29892, 270, 29922, 8516, 1125, 13, 4706, 565, 270, 338, 451, 6213, 29901, 13, 9651, 363, 413, 29892, 325, 297, 270, 29889, 7076, 7295, 1583, 29961, 29895, 29962, 353, 325, 13, 268, 13, 1678, 822, 4770, 842, 5552, 12035, 1311, 29892, 1820, 29892, 995, 1125, 13, 4706, 565, 1820, 297, 1583, 17255, 2536, 1862, 1649, 29901, 13, 9651, 1583, 17255, 8977, 1649, 29961, 1989, 29962, 353, 995, 13, 4706, 1683, 29901, 29871, 13, 9651, 1583, 29961, 1989, 29962, 353, 995, 13, 632, 13, 1678, 822, 4770, 842, 667, 12035, 1311, 29892, 1820, 29892, 995, 1125, 13, 4706, 9657, 17255, 842, 667, 12035, 1311, 29892, 1820, 29892, 364, 28957, 1598, 29898, 1767, 876, 13, 632, 13, 1678, 822, 4770, 657, 5552, 12035, 1311, 29892, 1820, 1125, 13, 4706, 565, 1820, 297, 1134, 29898, 1311, 467, 1649, 2536, 1862, 1649, 29901, 29871, 13, 9651, 736, 1583, 17255, 8977, 1649, 29961, 1989, 29962, 13, 4706, 1683, 29901, 13, 9651, 1018, 29901, 13, 18884, 736, 1583, 29961, 1989, 29962, 13, 9651, 5174, 7670, 2392, 408, 413, 29901, 13, 18884, 12020, 23833, 2392, 29898, 29895, 29897, 13, 632, 13, 1678, 822, 4770, 6144, 5552, 12035, 1311, 29892, 1820, 1125, 13, 4706, 1018, 29901, 13, 9651, 628, 1583, 29961, 1989, 29962, 13, 4706, 5174, 7670, 2392, 408, 413, 29901, 13, 9651, 12020, 23833, 2392, 29898, 29895, 29897, 13, 632, 13, 1678, 822, 4770, 276, 558, 12035, 1311, 1125, 418, 13, 4706, 736, 6702, 29966, 29995, 29879, 525, 1273, 1134, 29898, 1311, 467, 1649, 978, 1649, 29897, 718, 9657, 17255, 276, 558, 12035, 1311, 29897, 718, 525, 16299, 13, 308, 13, 308, 13, 1753, 364, 28957, 1598, 29898, 29872, 1125, 13, 1678, 565, 1134, 29898, 29872, 29897, 338, 9657, 29901, 13, 4706, 736, 390, 10486, 29898, 29881, 29922, 29872, 29897, 13, 1678, 25342, 1134, 29898, 29872, 29897, 297, 313, 1761, 29892, 18761, 1125, 13, 4706, 736, 518, 29878, 28957, 1598, 29898, 29875, 29897, 363, 474, 297, 321, 29962, 13, 1678, 1683, 29901, 736, 321, 13, 308, 13, 1753, 4390, 1598, 29898, 29877, 1125, 13, 1678, 565, 756, 5552, 29898, 29877, 29892, 525, 3126, 29374, 29871, 13, 4706, 736, 288, 29889, 3126, 13, 1678, 25342, 338, 8758, 29898, 29877, 29892, 9657, 1125, 13, 4706, 736, 426, 710, 29898, 29895, 1125, 4390, 1598, 29898, 29894, 29897, 363, 413, 29892, 325, 297, 288, 29889, 7076, 28296, 13, 1678, 25342, 1134, 29898, 29877, 29897, 297, 313, 1761, 29892, 18761, 29892, 2910, 1125, 13, 4706, 736, 518, 3126, 1598, 29898, 29872, 29897, 363, 321, 297, 288, 29962, 13, 1678, 25342, 338, 8758, 29898, 29877, 29892, 313, 524, 29892, 5785, 29892, 6120, 29892, 851, 29892, 1134, 29898, 8516, 876, 1125, 13, 4706, 736, 288, 13, 1678, 1683, 29901, 13, 4706, 12020, 20948, 877, 3318, 310, 1134, 11860, 29879, 29908, 338, 451, 4390, 28677, 29901, 1273, 29879, 29915, 1273, 313, 1853, 29898, 29877, 511, 2062, 29898, 29877, 4961, 13, 268, 13, 308, 13, 1990, 3457, 3388, 29901, 13, 1678, 14550, 13, 1678, 3457, 29899, 20845, 284, 10417, 29889, 13, 1678, 14550, 13, 268, 13, 1678, 822, 4770, 2344, 12035, 1311, 29892, 1819, 29922, 8516, 1125, 13, 4706, 1583, 3032, 29888, 9970, 353, 6571, 13, 4706, 1583, 3032, 29890, 9970, 353, 6571, 13, 4706, 1583, 4619, 1819, 13, 4706, 1583, 17255, 1524, 1649, 353, 1583, 3032, 29888, 9970, 17255, 1524, 1649, 13, 4706, 1583, 29889, 7076, 353, 1583, 3032, 29888, 9970, 29889, 7076, 13, 4706, 1583, 29889, 8149, 353, 1583, 3032, 29888, 9970, 29889, 8149, 13, 4706, 1583, 29889, 5975, 353, 1583, 3032, 29888, 9970, 29889, 5975, 13, 308, 13, 1678, 822, 4770, 29875, 1202, 12035, 1311, 29892, 1819, 1125, 13, 4706, 565, 1134, 29898, 5975, 29897, 297, 313, 1761, 29892, 18761, 1125, 13, 9651, 363, 285, 29892, 289, 297, 1819, 29901, 1583, 29961, 29888, 29901, 29890, 29962, 13, 4706, 25342, 338, 8758, 29898, 5975, 29892, 313, 8977, 29892, 3457, 3388, 22164, 13, 9651, 363, 285, 29892, 289, 297, 1819, 29889, 7076, 7295, 13, 18884, 1583, 29961, 29888, 29901, 29890, 29962, 13, 4706, 736, 1583, 13, 268, 13, 1678, 822, 4770, 1202, 12035, 1311, 29892, 1819, 1125, 13, 4706, 716, 1958, 353, 3457, 3388, 29898, 1311, 29897, 13, 4706, 716, 1958, 4619, 1819, 13, 4706, 736, 716, 1958, 13, 418, 13, 1678, 822, 4770, 657, 667, 12035, 1311, 29892, 269, 1125, 13, 4706, 565, 1134, 29898, 29879, 29897, 338, 22780, 29901, 13, 9651, 565, 451, 269, 29889, 2962, 322, 269, 29889, 9847, 29901, 736, 1583, 3032, 29890, 9970, 29961, 29879, 29889, 9847, 29962, 13, 9651, 565, 269, 29889, 2962, 322, 451, 269, 29889, 9847, 29901, 736, 1583, 3032, 29888, 9970, 29961, 29879, 29889, 2962, 29962, 13, 9651, 565, 269, 29889, 2962, 322, 269, 29889, 9847, 29901, 13, 18884, 1583, 3032, 29888, 9970, 29961, 29879, 29889, 2962, 29962, 353, 269, 29889, 9847, 13, 18884, 1583, 3032, 29890, 9970, 29961, 29879, 29889, 9847, 29962, 353, 269, 29889, 2962, 13, 9651, 1683, 29901, 12020, 23833, 2392, 877, 29903, 5897, 2980, 363, 3457, 3388, 2609, 367, 4069, 1495, 13, 4706, 1683, 29901, 736, 1583, 3032, 29888, 9970, 29961, 29879, 29962, 13, 13, 1678, 822, 4770, 11516, 12035, 1311, 29892, 321, 1125, 13, 4706, 736, 321, 297, 1583, 3032, 29888, 9970, 470, 321, 297, 1583, 3032, 29890, 9970, 13, 13, 1678, 822, 4770, 710, 12035, 1311, 1125, 13, 4706, 736, 21921, 4286, 7122, 4197, 710, 29898, 29872, 29897, 363, 321, 297, 1051, 29898, 1311, 3032, 29888, 9970, 29889, 7076, 3101, 2314, 13, 13, 13, 1990, 18531, 19832, 29898, 20517, 3388, 1125, 13, 1678, 822, 4770, 2344, 12035, 1311, 29892, 334, 5975, 1125, 13, 4706, 3457, 3388, 17255, 2344, 12035, 1311, 29897, 13, 4706, 1583, 3032, 2798, 353, 29871, 29900, 13, 4706, 363, 325, 297, 1819, 29901, 13, 9651, 954, 791, 353, 29871, 29896, 3532, 1583, 3032, 2798, 13, 9651, 731, 5552, 29898, 1311, 29892, 325, 29892, 954, 791, 29897, 13, 9651, 1583, 3032, 2798, 4619, 29871, 29896, 13, 9651, 1583, 29961, 1949, 791, 29901, 29894, 29962, 13, 13, 13, 1753, 282, 1595, 29875, 29898, 4537, 29892, 12098, 1080, 1125, 13, 1678, 14550, 13, 1678, 3455, 654, 263, 1353, 964, 263, 2533, 310, 302, 11920, 29892, 18618, 635, 304, 278, 364, 2219, 359, 2183, 297, 29871, 13, 1678, 12098, 1080, 29889, 29871, 13, 268, 13, 1678, 450, 1121, 338, 22688, 304, 6575, 701, 304, 4954, 4537, 29952, 1673, 577, 372, 338, 5941, 287, 281, 2273, 29889, 13, 1678, 304, 16259, 832, 11614, 29889, 13, 1678, 14550, 13, 1678, 796, 353, 2533, 29898, 771, 637, 1080, 29897, 13, 1678, 639, 29883, 1237, 353, 518, 7411, 29898, 29886, 29897, 847, 796, 363, 282, 297, 12098, 1080, 29962, 13, 1678, 1121, 353, 518, 3317, 29898, 29900, 29892, 938, 29898, 14486, 29898, 29886, 334, 1353, 4961, 363, 282, 297, 639, 29883, 1237, 7503, 29899, 29896, 5262, 13, 1678, 736, 1121, 718, 518, 4537, 448, 2533, 29898, 2914, 4638, 13, 268, 13, 13, 1753, 7868, 29898, 1068, 19290, 1125, 13, 1678, 822, 12244, 29918, 29888, 29898, 2220, 1125, 13, 4706, 822, 410, 915, 14400, 29898, 2557, 29892, 1741, 29892, 1852, 1125, 13, 9651, 565, 1741, 1275, 525, 4804, 2396, 13, 18884, 3515, 29889, 29888, 29918, 2997, 29879, 29889, 5504, 29898, 19290, 29897, 13, 18884, 3515, 29889, 29888, 29918, 23705, 1338, 29889, 5504, 29898, 19290, 29897, 13, 9651, 25342, 1741, 1275, 525, 2457, 2396, 13, 18884, 363, 1820, 297, 9049, 5085, 29901, 13, 462, 1678, 9049, 5085, 29961, 1989, 29962, 353, 3515, 29889, 29888, 29918, 2997, 29879, 29961, 1989, 29962, 13, 18884, 10876, 29889, 842, 15003, 29898, 8516, 29897, 13, 9651, 736, 410, 915, 14400, 13, 4706, 822, 16703, 287, 10456, 5085, 29892, 3579, 19290, 1125, 13, 9651, 10876, 29889, 842, 15003, 29898, 771, 915, 14400, 29897, 13, 9651, 740, 10456, 5085, 29892, 3579, 19290, 29897, 13, 4706, 736, 16703, 287, 13, 1678, 736, 12244, 29918, 29888, 13, 13, 13, 1753, 6088, 29918, 12673, 29898, 6008, 1125, 13, 1678, 736, 12865, 29889, 12673, 29889, 329, 29883, 3166, 16394, 29898, 5269, 29889, 13239, 29889, 29885, 1193, 603, 29918, 17559, 29898, 5269, 29889, 13239, 29889, 862, 8485, 403, 29918, 17559, 29898, 6008, 4961, 13, 13, 13, 1753, 3402, 29918, 12673, 29898, 6008, 1125, 13, 1678, 736, 4876, 29889, 13239, 29889, 4830, 1256, 29898, 6008, 29889, 16394, 3285, 5852, 29897, 13, 13, 13, 361, 4770, 978, 1649, 1275, 525, 1649, 3396, 1649, 2396, 13, 1678, 1596, 29898, 407, 442, 29875, 29898, 29896, 29900, 29892, 518, 29889, 29906, 29892, 869, 29906, 29892, 869, 29896, 29892, 869, 29945, 12622, 13, 2 ]
jet_bridge/serializers/sql.py
BradyBromley/jet-bridge
2
129013
from sqlalchemy import text from sqlalchemy.exc import SQLAlchemyError from jet_bridge import fields from jet_bridge.db import Session from jet_bridge.exceptions.sql import SqlError from jet_bridge.exceptions.validation_error import ValidationError from jet_bridge.fields.sql_params import SqlParamsSerializers from jet_bridge.serializers.serializer import Serializer class SqlSerializer(Serializer): query = fields.CharField() params = SqlParamsSerializers(required=False) class Meta: fields = ( 'query', 'params', ) def validate_query(self, value): forbidden = ['insert', 'update', 'delete', 'grant', 'show'] for i in range(len(forbidden)): forbidden.append('({}'.format(forbidden[i])) if any(map(lambda x: ' {} '.format(value.lower()).find(' {} '.format(x)) != -1, forbidden)): raise ValidationError('forbidden query') i = 0 while value.find('%s') != -1: value = value.replace('%s', ':param_{}'.format(i), 1) i += 1 return value def execute(self, data): session = Session() query = data['query'] params = data.get('params', []) try: result = session.execute( text(query), params ) rows = list(map(lambda x: x.itervalues(), result)) def map_column(x): if x == '?column?': return return x return {'data': rows, 'columns': map(map_column, result.keys())} except (SQLAlchemyError, TypeError) as e: raise SqlError(e) finally: session.close() class SqlsSerializer(Serializer): queries = SqlSerializer(many=True) def execute(self, data): serializer = SqlSerializer() return map(lambda x: serializer.execute(x), data['queries'])
[ 1, 515, 4576, 284, 305, 6764, 1053, 1426, 13, 3166, 4576, 284, 305, 6764, 29889, 735, 29883, 1053, 3758, 2499, 305, 6764, 2392, 13, 13, 3166, 22588, 29918, 18419, 1053, 4235, 13, 3166, 22588, 29918, 18419, 29889, 2585, 1053, 16441, 13, 3166, 22588, 29918, 18419, 29889, 11739, 29879, 29889, 2850, 1053, 13093, 2392, 13, 3166, 22588, 29918, 18419, 29889, 11739, 29879, 29889, 18157, 29918, 2704, 1053, 15758, 362, 2392, 13, 3166, 22588, 29918, 18419, 29889, 9621, 29889, 2850, 29918, 7529, 1053, 13093, 9629, 9125, 19427, 13, 3166, 22588, 29918, 18419, 29889, 15550, 19427, 29889, 15550, 3950, 1053, 18896, 3950, 13, 13, 13, 1990, 13093, 17679, 29898, 17679, 1125, 13, 1678, 2346, 353, 4235, 29889, 27890, 580, 13, 1678, 8636, 353, 13093, 9629, 9125, 19427, 29898, 12403, 29922, 8824, 29897, 13, 13, 1678, 770, 20553, 29901, 13, 4706, 4235, 353, 313, 13, 9651, 525, 1972, 742, 13, 9651, 525, 7529, 742, 13, 4706, 1723, 13, 13, 1678, 822, 12725, 29918, 1972, 29898, 1311, 29892, 995, 1125, 13, 4706, 19752, 4215, 353, 6024, 7851, 742, 525, 5504, 742, 525, 8143, 742, 525, 629, 424, 742, 525, 4294, 2033, 13, 4706, 363, 474, 297, 3464, 29898, 2435, 29898, 1454, 29890, 4215, 22164, 13, 9651, 19752, 4215, 29889, 4397, 877, 3319, 29913, 4286, 4830, 29898, 1454, 29890, 4215, 29961, 29875, 12622, 13, 4706, 565, 738, 29898, 1958, 29898, 2892, 921, 29901, 525, 6571, 15300, 4830, 29898, 1767, 29889, 13609, 16655, 2886, 877, 6571, 15300, 4830, 29898, 29916, 876, 2804, 448, 29896, 29892, 19752, 4215, 22164, 13, 9651, 12020, 15758, 362, 2392, 877, 1454, 29890, 4215, 2346, 1495, 13, 13, 4706, 474, 353, 29871, 29900, 13, 4706, 1550, 995, 29889, 2886, 877, 29995, 29879, 1495, 2804, 448, 29896, 29901, 13, 9651, 995, 353, 995, 29889, 6506, 877, 29995, 29879, 742, 525, 29901, 3207, 648, 29913, 4286, 4830, 29898, 29875, 511, 29871, 29896, 29897, 13, 9651, 474, 4619, 29871, 29896, 13, 13, 4706, 736, 995, 13, 13, 1678, 822, 6222, 29898, 1311, 29892, 848, 1125, 13, 4706, 4867, 353, 16441, 580, 13, 13, 4706, 2346, 353, 848, 1839, 1972, 2033, 13, 4706, 8636, 353, 848, 29889, 657, 877, 7529, 742, 518, 2314, 13, 13, 4706, 1018, 29901, 13, 9651, 1121, 353, 4867, 29889, 7978, 29898, 13, 18884, 1426, 29898, 1972, 511, 13, 18884, 8636, 13, 9651, 1723, 13, 13, 9651, 4206, 353, 1051, 29898, 1958, 29898, 2892, 921, 29901, 921, 29889, 1524, 5975, 3285, 1121, 876, 13, 13, 9651, 822, 2910, 29918, 4914, 29898, 29916, 1125, 13, 18884, 565, 921, 1275, 525, 29973, 4914, 29973, 2396, 13, 462, 1678, 736, 13, 18884, 736, 921, 13, 13, 9651, 736, 11117, 1272, 2396, 4206, 29892, 525, 13099, 2396, 2910, 29898, 1958, 29918, 4914, 29892, 1121, 29889, 8149, 580, 2915, 13, 4706, 5174, 313, 4176, 2499, 305, 6764, 2392, 29892, 20948, 29897, 408, 321, 29901, 13, 9651, 12020, 13093, 2392, 29898, 29872, 29897, 13, 4706, 7146, 29901, 13, 9651, 4867, 29889, 5358, 580, 13, 13, 13, 1990, 13093, 29879, 17679, 29898, 17679, 1125, 13, 1678, 9365, 353, 13093, 17679, 29898, 13011, 29922, 5574, 29897, 13, 13, 1678, 822, 6222, 29898, 1311, 29892, 848, 1125, 13, 4706, 7797, 3950, 353, 13093, 17679, 580, 13, 4706, 736, 2910, 29898, 2892, 921, 29901, 7797, 3950, 29889, 7978, 29898, 29916, 511, 848, 1839, 339, 6358, 11287, 13, 2 ]
res/011-json.py
leialbert/keep-learning-python
0
107315
import json person = {'name':'John','age':28,'city':'New York','hasChildren':False} personJson = json.dumps(person,indent=4,separators=(':','='),sort_keys=True) print(personJson) with open('res/person.json', 'w') as f: json.dump(person,f,indent=4) person = {'name':'John','age':28,'city':'New York','hasChildren':False} personJson = json.dumps(person) person_new = json.loads(personJson) print(person_new) with open('res/person.json', 'r') as f: person = json.load(f) print(json) class User: def __init__(self,name,age): self.name = name self.age = age user = User('albert',29) def encode_user(o): if isinstance(o,User): return {'name':o.name,'age':o.age,o.__class__.__name__:True} else: raise TypeError('is not JSON serializable') userJSON = json.dumps(user,default=encode_user) print(userJSON) from json import JSONEncoder class UserEncoder(JSONEncoder): def default(self,o): if isinstance(o,User): return {'name':o.name,'age':o.age,o.__class__.__name__:True} userJSON = json.dumps(user,cls=UserEncoder) print(userJSON) userJSON2 = UserEncoder().encode(user) print(userJSON2) def decode_user(dct): if User.__name__ in dct: return User(name=dct['name'],age=dct['age']) return dct user = json.loads(userJSON,object_hook=decode_user) print(type(user)) print(user.name)
[ 1, 1053, 4390, 13, 10532, 353, 11117, 978, 22099, 11639, 3788, 482, 2396, 29906, 29947, 5501, 12690, 22099, 4373, 3088, 3788, 5349, 19334, 2396, 8824, 29913, 13, 13, 10532, 8148, 353, 4390, 29889, 29881, 17204, 29898, 10532, 29892, 12860, 29922, 29946, 29892, 25048, 4097, 29922, 877, 29901, 3788, 2433, 511, 6605, 29918, 8149, 29922, 5574, 29897, 13, 2158, 29898, 10532, 8148, 29897, 13, 13, 2541, 1722, 877, 690, 29914, 10532, 29889, 3126, 742, 525, 29893, 1495, 408, 285, 29901, 13, 1678, 4390, 29889, 15070, 29898, 10532, 29892, 29888, 29892, 12860, 29922, 29946, 29897, 13, 13, 13, 10532, 353, 11117, 978, 22099, 11639, 3788, 482, 2396, 29906, 29947, 5501, 12690, 22099, 4373, 3088, 3788, 5349, 19334, 2396, 8824, 29913, 13, 13, 10532, 8148, 353, 4390, 29889, 29881, 17204, 29898, 10532, 29897, 13, 10532, 29918, 1482, 353, 4390, 29889, 18132, 29898, 10532, 8148, 29897, 13, 2158, 29898, 10532, 29918, 1482, 29897, 13, 13, 13, 2541, 1722, 877, 690, 29914, 10532, 29889, 3126, 742, 525, 29878, 1495, 408, 285, 29901, 13, 1678, 2022, 353, 4390, 29889, 1359, 29898, 29888, 29897, 13, 1678, 1596, 29898, 3126, 29897, 29871, 13, 13, 13, 1990, 4911, 29901, 13, 1678, 822, 4770, 2344, 12035, 1311, 29892, 978, 29892, 482, 1125, 13, 4706, 1583, 29889, 978, 353, 1024, 13, 4706, 1583, 29889, 482, 353, 5046, 13, 1792, 353, 4911, 877, 284, 2151, 742, 29906, 29929, 29897, 13, 1753, 19750, 29918, 1792, 29898, 29877, 1125, 13, 1678, 565, 338, 8758, 29898, 29877, 29892, 2659, 1125, 13, 4706, 736, 11117, 978, 2396, 29877, 29889, 978, 5501, 482, 2396, 29877, 29889, 482, 29892, 29877, 17255, 1990, 1649, 17255, 978, 1649, 29901, 5574, 29913, 13, 1678, 1683, 29901, 13, 4706, 12020, 20948, 877, 275, 451, 4663, 7797, 13902, 1495, 13, 1792, 7249, 353, 4390, 29889, 29881, 17204, 29898, 1792, 29892, 4381, 29922, 12508, 29918, 1792, 29897, 13, 2158, 29898, 1792, 7249, 29897, 13, 13, 3166, 4390, 1053, 4663, 8566, 6119, 13, 1990, 4911, 8566, 6119, 29898, 7249, 8566, 6119, 1125, 13, 1678, 822, 2322, 29898, 1311, 29892, 29877, 1125, 13, 4706, 565, 338, 8758, 29898, 29877, 29892, 2659, 1125, 13, 9651, 736, 11117, 978, 2396, 29877, 29889, 978, 5501, 482, 2396, 29877, 29889, 482, 29892, 29877, 17255, 1990, 1649, 17255, 978, 1649, 29901, 5574, 29913, 13, 13, 1792, 7249, 353, 4390, 29889, 29881, 17204, 29898, 1792, 29892, 25932, 29922, 2659, 8566, 6119, 29897, 13, 2158, 29898, 1792, 7249, 29897, 13, 13, 1792, 7249, 29906, 353, 4911, 8566, 6119, 2141, 12508, 29898, 1792, 29897, 13, 2158, 29898, 1792, 7249, 29906, 29897, 13, 13, 1753, 21822, 29918, 1792, 29898, 29881, 312, 1125, 13, 1678, 565, 4911, 17255, 978, 1649, 297, 270, 312, 29901, 13, 4706, 736, 4911, 29898, 978, 29922, 29881, 312, 1839, 978, 7464, 482, 29922, 29881, 312, 1839, 482, 11287, 13, 1678, 736, 270, 312, 13, 1792, 353, 4390, 29889, 18132, 29898, 1792, 7249, 29892, 3318, 29918, 20849, 29922, 13808, 29918, 1792, 29897, 13, 2158, 29898, 1853, 29898, 1792, 876, 13, 2158, 29898, 1792, 29889, 978, 29897, 2 ]
tutorial/core/sockets.py
mburst/gevent-socketio-starterkit
6
164424
from socketio.namespace import BaseNamespace from socketio.mixins import RoomsMixin, BroadcastMixin from socketio.sdjango import namespace from collections import defaultdict import redis from gevent import Greenlet def home_redis_worker(): r = redis.StrictRedis(host='localhost', port=6379, db=0) tacosub = r.pubsub() tacosub.subscribe('tacos') for item in tacosub.listen(): if item['type'] == "message": for socket in HomeNamespace.sockets: socket.emit('taco', item['data']) home_greenlet = Greenlet.spawn(home_redis_worker) @namespace('/home') class HomeNamespace(BaseNamespace): sockets = set([]) def initialize(self): HomeNamespace.sockets.add(self) def recv_disconnect(self): HomeNamespace.sockets.discard(self) self.disconnect(silent=True) ########################### def user_redis_worker(): r = redis.StrictRedis(host='localhost', port=6379, db=0) usersub = r.pubsub() usersub.psubscribe('user_*') for item in usersub.listen(): if item['type'] == "pmessage": user = item['channel'][5:] for socket in UserNamespace.sockets[user]: socket.emit('taco', item['data']) user_greenlet = Greenlet.spawn(user_redis_worker) @namespace('/user') class UserNamespace(BaseNamespace): sockets = defaultdict(set) def on_set_user(self, username): self.username = username UserNamespace.sockets[username].add(self) def recv_disconnect(self): UserNamespace.sockets[self.username].discard(self) self.disconnect(silent=True)
[ 1, 515, 9909, 601, 29889, 22377, 1053, 7399, 23335, 30004, 13, 3166, 9909, 601, 29889, 28084, 1144, 1053, 1528, 4835, 29924, 861, 262, 29892, 25484, 29924, 861, 262, 30004, 13, 3166, 9909, 601, 29889, 4928, 5364, 1053, 7397, 30004, 13, 30004, 13, 3166, 16250, 1053, 2322, 8977, 30004, 13, 5215, 29825, 30004, 13, 30004, 13, 3166, 1737, 794, 1053, 7646, 1026, 30004, 13, 30004, 13, 1753, 3271, 29918, 1127, 275, 29918, 24602, 7295, 30004, 13, 1678, 364, 353, 29825, 29889, 5015, 919, 9039, 275, 29898, 3069, 2433, 7640, 742, 2011, 29922, 29953, 29941, 29955, 29929, 29892, 4833, 29922, 29900, 8443, 13, 1678, 260, 562, 359, 431, 353, 364, 29889, 5467, 1491, 26471, 13, 1678, 260, 562, 359, 431, 29889, 19496, 877, 21229, 359, 1495, 30004, 13, 1678, 363, 2944, 297, 260, 562, 359, 431, 29889, 20631, 7295, 30004, 13, 4706, 565, 2944, 1839, 1853, 2033, 29871, 1275, 376, 4906, 1115, 30004, 13, 9651, 363, 9909, 297, 8778, 23335, 29889, 578, 9737, 29901, 30004, 13, 18884, 9909, 29889, 21976, 877, 29873, 11216, 742, 2944, 1839, 1272, 2033, 8443, 13, 9651, 6756, 13, 9651, 6756, 13, 5184, 29918, 12692, 1026, 353, 7646, 1026, 29889, 1028, 18101, 29898, 5184, 29918, 1127, 275, 29918, 24602, 8443, 13, 30004, 13, 30004, 13, 29992, 22377, 11219, 5184, 1495, 30004, 13, 1990, 8778, 23335, 29898, 5160, 23335, 1125, 30004, 13, 1678, 577, 9737, 353, 731, 4197, 2314, 30004, 13, 1678, 6756, 13, 1678, 822, 11905, 29898, 1311, 1125, 30004, 13, 4706, 8778, 23335, 29889, 578, 9737, 29889, 1202, 29898, 1311, 8443, 13, 4706, 6756, 13, 1678, 822, 1162, 29894, 29918, 2218, 6915, 29898, 1311, 1125, 30004, 13, 4706, 8778, 23335, 29889, 578, 9737, 29889, 2218, 7543, 29898, 1311, 8443, 13, 4706, 1583, 29889, 2218, 6915, 29898, 25590, 296, 29922, 5574, 8443, 13, 13383, 7346, 2277, 29937, 539, 6756, 13, 1753, 1404, 29918, 1127, 275, 29918, 24602, 7295, 30004, 13, 1678, 364, 353, 29825, 29889, 5015, 919, 9039, 275, 29898, 3069, 2433, 7640, 742, 2011, 29922, 29953, 29941, 29955, 29929, 29892, 4833, 29922, 29900, 8443, 13, 1678, 4160, 431, 353, 364, 29889, 5467, 1491, 26471, 13, 1678, 4160, 431, 29889, 567, 431, 13086, 877, 1792, 24563, 1495, 30004, 13, 1678, 363, 2944, 297, 4160, 431, 29889, 20631, 7295, 30004, 13, 4706, 565, 2944, 1839, 1853, 2033, 29871, 1275, 376, 3358, 1448, 1115, 30004, 13, 9651, 1404, 353, 2944, 1839, 12719, 2033, 29961, 29945, 17531, 30004, 13, 9651, 363, 9909, 297, 4911, 23335, 29889, 578, 9737, 29961, 1792, 5387, 30004, 13, 18884, 9909, 29889, 21976, 877, 29873, 11216, 742, 2944, 1839, 1272, 2033, 8443, 13, 9651, 6756, 13, 9651, 6756, 13, 1792, 29918, 12692, 1026, 353, 7646, 1026, 29889, 1028, 18101, 29898, 1792, 29918, 1127, 275, 29918, 24602, 8443, 13, 30004, 13, 30004, 13, 29992, 22377, 11219, 1792, 1495, 30004, 13, 1990, 4911, 23335, 29898, 5160, 23335, 1125, 30004, 13, 1678, 577, 9737, 353, 2322, 8977, 29898, 842, 8443, 13, 1678, 6756, 13, 1678, 822, 373, 29918, 842, 29918, 1792, 29898, 1311, 29892, 8952, 1125, 1678, 6756, 13, 4706, 1583, 29889, 6786, 353, 8952, 30004, 13, 4706, 4911, 23335, 29889, 578, 9737, 29961, 6786, 1822, 1202, 29898, 1311, 8443, 13, 4706, 6756, 13, 1678, 822, 1162, 29894, 29918, 2218, 6915, 29898, 1311, 1125, 30004, 13, 4706, 4911, 23335, 29889, 578, 9737, 29961, 1311, 29889, 6786, 1822, 2218, 7543, 29898, 1311, 8443, 13, 4706, 1583, 29889, 2218, 6915, 29898, 25590, 296, 29922, 5574, 29897, 2 ]
ptxt/mur/commonmark.py
mvasilkov/scrapheap
2
112865
<filename>ptxt/mur/commonmark.py<gh_stars>1-10 from collections import namedtuple from ctypes import CDLL, c_char_p, c_size_t, c_int from pathlib import WindowsPath import platform def _libcmark(): system = platform.system() if system == 'Darwin': return 'libcmark.dylib' if system == 'Windows': binary_dependencies = WindowsPath(__file__).parents[1] / 'binary_dependencies' return str(binary_dependencies / 'cmark.dll') return 'libcmark.so' cmark = CDLL(_libcmark()) cmark_markdown_to_html = cmark.cmark_markdown_to_html cmark_markdown_to_html.argtypes = (c_char_p, c_size_t, c_int) cmark_markdown_to_html.restype = c_char_p cmark_version = cmark.cmark_version cmark_version.restype = c_int Version = namedtuple('Version', 'major minor patchlevel') def commonmark(string): b = string.encode('utf-8') return cmark_markdown_to_html(b, len(b), 0).decode('utf-8') def version(): return Version(*cmark_version().to_bytes(3, byteorder='big'))
[ 1, 529, 9507, 29958, 415, 486, 29914, 29885, 332, 29914, 9435, 3502, 29889, 2272, 29966, 12443, 29918, 303, 1503, 29958, 29896, 29899, 29896, 29900, 13, 3166, 16250, 1053, 4257, 23583, 13, 3166, 274, 8768, 1053, 7307, 2208, 29892, 274, 29918, 3090, 29918, 29886, 29892, 274, 29918, 2311, 29918, 29873, 29892, 274, 29918, 524, 13, 3166, 2224, 1982, 1053, 3852, 2605, 13, 5215, 7481, 13, 13, 13, 1753, 903, 1982, 29883, 3502, 7295, 13, 1678, 1788, 353, 7481, 29889, 5205, 580, 13, 13, 1678, 565, 1788, 1275, 525, 29928, 279, 5080, 2396, 13, 4706, 736, 525, 1982, 29883, 3502, 29889, 4518, 1982, 29915, 13, 13, 1678, 565, 1788, 1275, 525, 7685, 2396, 13, 4706, 7581, 29918, 22594, 353, 3852, 2605, 22168, 1445, 1649, 467, 862, 1237, 29961, 29896, 29962, 847, 525, 19541, 29918, 22594, 29915, 13, 4706, 736, 851, 29898, 19541, 29918, 22594, 847, 525, 29883, 3502, 29889, 12396, 1495, 13, 13, 1678, 736, 525, 1982, 29883, 3502, 29889, 578, 29915, 13, 13, 13, 29883, 3502, 353, 7307, 2208, 7373, 1982, 29883, 3502, 3101, 13, 13, 29883, 3502, 29918, 3502, 3204, 29918, 517, 29918, 1420, 353, 274, 3502, 29889, 29883, 3502, 29918, 3502, 3204, 29918, 517, 29918, 1420, 13, 29883, 3502, 29918, 3502, 3204, 29918, 517, 29918, 1420, 29889, 1191, 8768, 353, 313, 29883, 29918, 3090, 29918, 29886, 29892, 274, 29918, 2311, 29918, 29873, 29892, 274, 29918, 524, 29897, 13, 29883, 3502, 29918, 3502, 3204, 29918, 517, 29918, 1420, 29889, 5060, 668, 353, 274, 29918, 3090, 29918, 29886, 13, 13, 29883, 3502, 29918, 3259, 353, 274, 3502, 29889, 29883, 3502, 29918, 3259, 13, 29883, 3502, 29918, 3259, 29889, 5060, 668, 353, 274, 29918, 524, 13, 13, 6594, 353, 4257, 23583, 877, 6594, 742, 525, 21355, 9461, 13261, 5563, 1495, 13, 13, 13, 1753, 3619, 3502, 29898, 1807, 1125, 13, 1678, 289, 353, 1347, 29889, 12508, 877, 9420, 29899, 29947, 1495, 13, 1678, 736, 274, 3502, 29918, 3502, 3204, 29918, 517, 29918, 1420, 29898, 29890, 29892, 7431, 29898, 29890, 511, 29871, 29900, 467, 13808, 877, 9420, 29899, 29947, 1495, 13, 13, 13, 1753, 1873, 7295, 13, 1678, 736, 10079, 10456, 29883, 3502, 29918, 3259, 2141, 517, 29918, 13193, 29898, 29941, 29892, 7023, 2098, 2433, 3752, 8785, 13, 2 ]
frappe/core/doctype/prepared_report/test_prepared_report.py
oryxsolutions/frappe
0
194784
# -*- coding: utf-8 -*- # Copyright (c) 2018, Frappe Technologies and Contributors # License: MIT. See LICENSE import json import unittest import frappe class TestPreparedReport(unittest.TestCase): def setUp(self): self.report = frappe.get_doc({"doctype": "Report", "name": "Permitted Documents For User"}) self.filters = {"user": "Administrator", "doctype": "Role"} self.prepared_report_doc = frappe.get_doc( { "doctype": "Prepared Report", "report_name": self.report.name, "filters": json.dumps(self.filters), "ref_report_doctype": self.report.name, } ).insert() def tearDown(self): frappe.set_user("Administrator") self.prepared_report_doc.delete() def test_for_creation(self): self.assertTrue("QUEUED" == self.prepared_report_doc.status.upper()) self.assertTrue(self.prepared_report_doc.report_start_time)
[ 1, 396, 448, 29930, 29899, 14137, 29901, 23616, 29899, 29947, 448, 29930, 29899, 13, 29937, 14187, 1266, 313, 29883, 29897, 29871, 29906, 29900, 29896, 29947, 29892, 7347, 4798, 8364, 11763, 322, 2866, 1091, 29560, 13, 29937, 19245, 29901, 341, 1806, 29889, 2823, 365, 2965, 1430, 1660, 13, 5215, 4390, 13, 5215, 443, 27958, 13, 13, 5215, 5227, 4798, 13, 13, 13, 1990, 4321, 29925, 3445, 1965, 13020, 29898, 348, 27958, 29889, 3057, 8259, 1125, 13, 12, 1753, 731, 3373, 29898, 1311, 1125, 13, 12, 12, 1311, 29889, 12276, 353, 5227, 4798, 29889, 657, 29918, 1514, 3319, 29908, 1867, 312, 668, 1115, 376, 13020, 613, 376, 978, 1115, 376, 15737, 4430, 10854, 29879, 1152, 4911, 29908, 1800, 13, 12, 12, 1311, 29889, 26705, 353, 8853, 1792, 1115, 376, 12754, 2132, 1061, 613, 376, 1867, 312, 668, 1115, 376, 16727, 9092, 13, 12, 12, 1311, 29889, 15287, 1965, 29918, 12276, 29918, 1514, 353, 5227, 4798, 29889, 657, 29918, 1514, 29898, 13, 12, 12, 12, 29912, 13, 12, 12, 12, 12, 29908, 1867, 312, 668, 1115, 376, 29925, 3445, 1965, 13969, 613, 13, 12, 12, 12, 12, 29908, 12276, 29918, 978, 1115, 1583, 29889, 12276, 29889, 978, 29892, 13, 12, 12, 12, 12, 29908, 26705, 1115, 4390, 29889, 29881, 17204, 29898, 1311, 29889, 26705, 511, 13, 12, 12, 12, 12, 29908, 999, 29918, 12276, 29918, 1867, 312, 668, 1115, 1583, 29889, 12276, 29889, 978, 29892, 13, 12, 12, 12, 29913, 13, 12, 12, 467, 7851, 580, 13, 13, 12, 1753, 734, 279, 6767, 29898, 1311, 1125, 13, 12, 12, 20910, 4798, 29889, 842, 29918, 1792, 703, 12754, 2132, 1061, 1159, 13, 12, 12, 1311, 29889, 15287, 1965, 29918, 12276, 29918, 1514, 29889, 8143, 580, 13, 13, 12, 1753, 1243, 29918, 1454, 29918, 1037, 362, 29898, 1311, 1125, 13, 12, 12, 1311, 29889, 9294, 5574, 703, 11144, 29965, 3352, 29908, 1275, 1583, 29889, 15287, 1965, 29918, 12276, 29918, 1514, 29889, 4882, 29889, 21064, 3101, 13, 12, 12, 1311, 29889, 9294, 5574, 29898, 1311, 29889, 15287, 1965, 29918, 12276, 29918, 1514, 29889, 12276, 29918, 2962, 29918, 2230, 29897, 13, 2 ]
python/client.py
JonathanSchmalhofer/SelfDrivingRLCarGodot
10
188646
#!/usr/bin/env python import socket import time def DoEpisode(): s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.settimeout(1) # 1 second s.connect((TCP_IP, TCP_PORT)) #print(" REGISTER"); s.send("(HEAD:10)(REGISTER)".encode('utf-8')) data = s.recv(BUFFER_SIZE) print(" RESPONSE: {}".format(data)) for i in range(0, 100): s.send("(HEAD:22)(CONTROL:0.3;0.1;-0.1)".encode('utf-8')) data = s.recv(BUFFER_SIZE).decode('utf-8').split(';') print(" RESPONSE: {}".format(data)) print("{} {} {} {} {}".format(data[2],data[3],data[4],data[5],data[6])) if data[1] == "True": print("Crash") break for i in range(0, 100): s.send("(HEAD:22)(CONTROL:0.6;0.15;0.4)".encode('utf-8')) data = s.recv(BUFFER_SIZE).decode('utf-8').split(';') if data[1] == "True": print("Crash") break #print(" RESPONSE: {}".format(data)) s.send("(HEAD:7)(CLOSE)".encode('utf-8')) s.close() s = None TCP_IP = '127.0.0.1' TCP_PORT = 42424 BUFFER_SIZE = 1024 for i in range(0, 100): print("Episode {}".format(i)) DoEpisode()
[ 1, 18787, 4855, 29914, 2109, 29914, 6272, 3017, 13, 13, 5215, 9909, 13, 5215, 931, 13, 13, 1753, 1938, 29923, 12907, 7295, 13, 1678, 269, 353, 9909, 29889, 11514, 29898, 11514, 29889, 5098, 29918, 1177, 2544, 29892, 9909, 29889, 6156, 7077, 29918, 1254, 1525, 5194, 29897, 13, 1678, 269, 29889, 842, 15619, 29898, 29896, 29897, 396, 29871, 29896, 1473, 13, 1678, 269, 29889, 6915, 3552, 29911, 6271, 29918, 5690, 29892, 19374, 29918, 15082, 876, 13, 13, 1678, 396, 2158, 703, 259, 5195, 29954, 9047, 1001, 1496, 13, 1678, 269, 29889, 6717, 703, 29898, 23252, 29901, 29896, 29900, 5033, 18166, 9047, 1001, 29897, 1642, 12508, 877, 9420, 29899, 29947, 8785, 13, 1678, 848, 353, 269, 29889, 3757, 29894, 29898, 7838, 28483, 29918, 14226, 29897, 13, 1678, 1596, 703, 259, 390, 2890, 29925, 1164, 1660, 29901, 6571, 1642, 4830, 29898, 1272, 876, 13, 1678, 363, 474, 297, 3464, 29898, 29900, 29892, 29871, 29896, 29900, 29900, 1125, 13, 4706, 269, 29889, 6717, 703, 29898, 23252, 29901, 29906, 29906, 5033, 22412, 1672, 29931, 29901, 29900, 29889, 29941, 29936, 29900, 29889, 29896, 29936, 29899, 29900, 29889, 29896, 29897, 1642, 12508, 877, 9420, 29899, 29947, 8785, 13, 4706, 848, 353, 269, 29889, 3757, 29894, 29898, 7838, 28483, 29918, 14226, 467, 13808, 877, 9420, 29899, 29947, 2824, 5451, 877, 29936, 1495, 13, 4706, 1596, 703, 259, 390, 2890, 29925, 1164, 1660, 29901, 6571, 1642, 4830, 29898, 1272, 876, 13, 4706, 1596, 703, 8875, 6571, 6571, 6571, 6571, 1642, 4830, 29898, 1272, 29961, 29906, 1402, 1272, 29961, 29941, 1402, 1272, 29961, 29946, 1402, 1272, 29961, 29945, 1402, 1272, 29961, 29953, 12622, 13, 4706, 565, 848, 29961, 29896, 29962, 1275, 376, 5574, 1115, 13, 9651, 1596, 703, 20647, 1161, 1159, 13, 9651, 2867, 13, 1678, 363, 474, 297, 3464, 29898, 29900, 29892, 29871, 29896, 29900, 29900, 1125, 13, 4706, 269, 29889, 6717, 703, 29898, 23252, 29901, 29906, 29906, 5033, 22412, 1672, 29931, 29901, 29900, 29889, 29953, 29936, 29900, 29889, 29896, 29945, 29936, 29900, 29889, 29946, 29897, 1642, 12508, 877, 9420, 29899, 29947, 8785, 13, 4706, 848, 353, 269, 29889, 3757, 29894, 29898, 7838, 28483, 29918, 14226, 467, 13808, 877, 9420, 29899, 29947, 2824, 5451, 877, 29936, 1495, 13, 4706, 565, 848, 29961, 29896, 29962, 1275, 376, 5574, 1115, 13, 9651, 1596, 703, 20647, 1161, 1159, 13, 9651, 2867, 13, 4706, 396, 2158, 703, 259, 390, 2890, 29925, 1164, 1660, 29901, 6571, 1642, 4830, 29898, 1272, 876, 13, 1678, 269, 29889, 6717, 703, 29898, 23252, 29901, 29955, 5033, 29907, 3927, 1660, 29897, 1642, 12508, 877, 9420, 29899, 29947, 8785, 13, 1678, 269, 29889, 5358, 580, 13, 1678, 269, 353, 6213, 13, 13, 29911, 6271, 29918, 5690, 353, 525, 29896, 29906, 29955, 29889, 29900, 29889, 29900, 29889, 29896, 29915, 13, 29911, 6271, 29918, 15082, 353, 29871, 29946, 29906, 29946, 29906, 29946, 13, 7838, 28483, 29918, 14226, 353, 29871, 29896, 29900, 29906, 29946, 13, 13, 1454, 474, 297, 3464, 29898, 29900, 29892, 29871, 29896, 29900, 29900, 1125, 13, 1678, 1596, 703, 29923, 12907, 6571, 1642, 4830, 29898, 29875, 876, 13, 1678, 1938, 29923, 12907, 580, 13, 2 ]
dogpile/__init__.py
dhellmann/dogpile.cache
0
30256
__version__ = '0.9.3' from .lock import Lock # noqa from .lock import NeedRegenerationException # noqa
[ 1, 4770, 3259, 1649, 353, 525, 29900, 29889, 29929, 29889, 29941, 29915, 13, 13, 3166, 869, 908, 1053, 18199, 29871, 396, 694, 25621, 13, 3166, 869, 908, 1053, 20768, 4597, 759, 362, 2451, 29871, 396, 694, 25621, 13, 2 ]
raiden/transfer/channel.py
gcarq/raiden
0
60259
# -*- coding: utf-8 -*- # pylint: disable=too-many-lines import heapq from binascii import hexlify from collections import namedtuple from raiden.encoding.signing import recover_publickey from raiden.transfer.architecture import TransitionResult from raiden.transfer.balance_proof import signing_data from raiden.transfer.events import ( ContractSendChannelClose, ContractSendChannelSettle, ContractSendChannelUpdateTransfer, ContractSendChannelWithdraw, EventTransferReceivedInvalidDirectTransfer, EventTransferReceivedSuccess, EventTransferSentFailed, SendDirectTransfer, ) from raiden.transfer.mediated_transfer.state import LockedTransferUnsignedState from raiden.transfer.mediated_transfer.events import ( refund_from_sendmediated, SendBalanceProof, SendMediatedTransfer, ) from raiden.transfer.merkle_tree import ( LEAVES, merkleroot, compute_layers, compute_merkleproof_for, ) from raiden.transfer.state import ( CHANNEL_STATE_CLOSED, CHANNEL_STATE_CLOSING, CHANNEL_STATE_OPENED, CHANNEL_STATE_SETTLED, CHANNEL_STATE_SETTLING, CHANNEL_STATES_PRIOR_TO_CLOSED, CHANNEL_STATE_UNUSABLE, EMPTY_MERKLE_ROOT, EMPTY_MERKLE_TREE, BalanceProofUnsignedState, HashTimeLockState, MerkleTreeState, TransactionExecutionStatus, UnlockPartialProofState, UnlockProofState, ) from raiden.transfer.state_change import ( ActionChannelClose, ActionTransferDirect, Block, ContractReceiveChannelClosed, ContractReceiveChannelNewBalance, ContractReceiveChannelSettled, ContractReceiveChannelWithdraw, ReceiveTransferDirect, ) from raiden.utils import publickey_to_address, typing from raiden.settings import DEFAULT_NUMBER_OF_CONFIRMATIONS_BLOCK TransactionOrder = namedtuple( 'TransactionOrder', ('block_number', 'transaction') ) def is_known(end_state, hashlock): """True if the `hashlock` corresponds to a known lock.""" return ( hashlock in end_state.hashlocks_to_pendinglocks or hashlock in end_state.hashlocks_to_unclaimedlocks ) def is_deposit_confirmed(channel_state, block_number): if not channel_state.deposit_transaction_queue: return False return is_transaction_confirmed( channel_state.deposit_transaction_queue[0].block_number, block_number, ) def is_locked(end_state, hashlock): """True if the `hashlock` is known and the correspoding secret is not.""" return hashlock in end_state.hashlocks_to_pendinglocks def is_secret_known(end_state, hashlock): """True if the `hashlock` is for a lock with a known secret.""" return hashlock in end_state.hashlocks_to_unclaimedlocks def is_transaction_confirmed(transaction_block_number, blockchain_block_number): confirmation_block = transaction_block_number + DEFAULT_NUMBER_OF_CONFIRMATIONS_BLOCK return blockchain_block_number > confirmation_block def is_valid_signature(balance_proof, sender_address): data_that_was_signed = signing_data( balance_proof.nonce, balance_proof.transferred_amount, balance_proof.channel_address, balance_proof.locksroot, balance_proof.message_hash, ) try: # ValueError is raised if the PublicKey instantiation failed, let it # propagate because it's a memory pressure problem publickey = recover_publickey( data_that_was_signed, balance_proof.signature, ) except Exception: # pylint: disable=broad-except # secp256k1 is using bare Exception classes # raised if the recovery failed msg = 'Signature invalid, could not be recovered.' return (False, msg) is_correct_sender = sender_address == publickey_to_address(publickey) if is_correct_sender: return (True, None) msg = 'Signature was valid but the expected address does not match.' return (False, msg) def is_valid_directtransfer(direct_transfer, channel_state, sender_state, receiver_state): received_balance_proof = direct_transfer.balance_proof current_balance_proof = get_current_balanceproof(sender_state) current_locksroot, _, current_transferred_amount = current_balance_proof distributable = get_distributable(sender_state, receiver_state) expected_nonce = get_next_nonce(sender_state) amount = received_balance_proof.transferred_amount - current_transferred_amount is_valid, signature_msg = is_valid_signature( received_balance_proof, sender_state.address, ) if get_status(channel_state) != CHANNEL_STATE_OPENED: msg = 'Invalid direct message. The channel is already closed.' result = (False, msg) elif not is_valid: # The signature must be valid, otherwise the balance proof cannot be # used onchain. msg = 'Invalid DirectTransfer message. {}'.format(signature_msg) result = (False, msg) elif received_balance_proof.nonce != expected_nonce: # The nonces must increase sequentially, otherwise there is a # synchronization problem. msg = ( 'Invalid DirectTransfer message. ' 'Nonce did not change sequentially, expected: {} got: {}.' ).format( expected_nonce, received_balance_proof.nonce, ) result = (False, msg) elif received_balance_proof.locksroot != current_locksroot: # Direct transfers do not use hash time lock, so it cannot change the # locksroot, otherwise a lock could be removed. msg = ( "Invalid DirectTransfer message. " "Balance proof's locksroot changed, expected: {} got: {}." ).format( hexlify(current_locksroot).decode(), hexlify(received_balance_proof.locksroot).decode(), ) result = (False, msg) elif received_balance_proof.transferred_amount <= current_transferred_amount: # Direct transfers must increase the transferred_amount, otherwise the # sender is trying to play the protocol and steal token. msg = ( "Invalid DirectTransfer message. " "Balance proof's transferred_amount decreased, expected larger than: {} got: {}." ).format( current_transferred_amount, received_balance_proof.transferred_amount, ) result = (False, msg) elif received_balance_proof.channel_address != channel_state.identifier: # The balance proof must be tied to this channel, otherwise the # on-chain contract would be sucesstible to replay attacks across # channels. msg = ( 'Invalid DirectTransfer message. ' 'Balance proof is tied to the wrong channel, expected: {} got: {}' ).format( hexlify(channel_state.identifier).decode(), hexlify(received_balance_proof.channel_address).decode(), ) result = (False, msg) elif amount > distributable: # Direct transfer are limited to the current available balance, # otherwise the sender is doing a trying to play the protocol and do a # double spend. msg = ( 'Invalid DirectTransfer message. ' 'Transfer amount larger than the available distributable, ' 'transfer amount: {} maximum distributable: {}' ).format( amount, distributable, ) result = (False, msg) else: result = (True, None) return result def is_valid_mediatedtransfer(mediated_transfer, channel_state, sender_state, receiver_state): received_balance_proof = mediated_transfer.balance_proof current_balance_proof = get_current_balanceproof(sender_state) _, _, current_transferred_amount = current_balance_proof distributable = get_distributable(sender_state, receiver_state) expected_nonce = get_next_nonce(sender_state) lock = mediated_transfer.lock merkletree = compute_merkletree_with(sender_state.merkletree, lock.lockhash) if get_status(channel_state) != CHANNEL_STATE_OPENED: msg = 'Invalid direct message. The channel is already closed.' result = (False, msg, None) if merkletree is None: msg = 'Invalid MediatedTransfer message. Same lockhash handled twice.' result = (False, msg, None) else: locksroot_with_lock = merkleroot(merkletree) (is_valid, signature_msg) = is_valid_signature( received_balance_proof, sender_state.address, ) if not is_valid: # The signature must be valid, otherwise the balance proof cannot be # used onchain msg = 'Invalid MediatedTransfer message. {}'.format(signature_msg) result = (False, msg, None) elif received_balance_proof.nonce != expected_nonce: # The nonces must increase sequentially, otherwise there is a # synchronization problem msg = ( 'Invalid MediatedTransfer message. ' 'Nonce did not change sequentially, expected: {} got: {}.' ).format( expected_nonce, received_balance_proof.nonce, ) result = (False, msg, None) elif received_balance_proof.locksroot != locksroot_with_lock: # The locksroot must be updated to include the new lock msg = ( "Invalid MediatedTransfer message. " "Balance proof's locksroot didn't match, expected: {} got: {}." ).format( hexlify(locksroot_with_lock).decode(), hexlify(received_balance_proof.locksroot).decode(), ) result = (False, msg, None) elif received_balance_proof.transferred_amount != current_transferred_amount: # Mediated transfers must not change transferred_amount msg = ( "Invalid MediatedTransfer message. " "Balance proof's transferred_amount changed, expected: {} got: {}." ).format( current_transferred_amount, received_balance_proof.transferred_amount, ) result = (False, msg, None) elif received_balance_proof.channel_address != channel_state.identifier: # The balance proof must be tied to this channel, otherwise the # on-chain contract would be sucesstible to replay attacks across # channels. msg = ( 'Invalid MediatedTransfer message. ' 'Balance proof is tied to the wrong channel, expected: {} got: {}' ).format( hexlify(channel_state.identifier).decode(), hexlify(received_balance_proof.channel_address).decode(), ) result = (False, msg, None) # the locked amount is limited to the current available balance, otherwise # the sender is doing a trying to play the protocol and do a double spend elif lock.amount > distributable: msg = ( 'Invalid MediatedTransfer message. ' 'Lock amount larger than the available distributable, ' 'lock amount: {} maximum distributable: {}' ).format( lock.amount, distributable, ) result = (False, msg, None) else: result = (True, None, merkletree) return result def is_valid_unlock(unlock, channel_state, sender_state): received_balance_proof = unlock.balance_proof current_balance_proof = get_current_balanceproof(sender_state) lock = get_lock(sender_state, unlock.hashlock) if lock is not None: new_merkletree = compute_merkletree_without(sender_state.merkletree, lock.lockhash) locksroot_without_lock = merkleroot(new_merkletree) _, _, current_transferred_amount = current_balance_proof expected_nonce = get_next_nonce(sender_state) expected_transferred_amount = current_transferred_amount + lock.amount is_valid, signature_msg = is_valid_signature( received_balance_proof, sender_state.address, ) # TODO: Accept unlock messages if the node has not yet sent a transaction # with the balance proof to the blockchain, this will save one call to # withdraw on-chain for the non-closing party. if get_status(channel_state) != CHANNEL_STATE_OPENED: msg = 'Invalid Unlock message for {}. The channel is already closed.'.format( hexlify(unlock.hashlock).decode(), ) result = (False, msg, None) elif lock is None: msg = 'Invalid Secret message. There is no correspoding lock for {}'.format( hexlify(unlock.hashlock).decode(), ) result = (False, msg, None) elif not is_valid: # The signature must be valid, otherwise the balance proof cannot be # used onchain. msg = 'Invalid Secret message. {}'.format(signature_msg) result = (False, msg, None) elif received_balance_proof.nonce != expected_nonce: # The nonces must increase sequentially, otherwise there is a # synchronization problem. msg = ( 'Invalid Secret message. ' 'Nonce did not change sequentially, expected: {} got: {}.' ).format( expected_nonce, received_balance_proof.nonce, ) result = (False, msg, None) elif received_balance_proof.locksroot != locksroot_without_lock: # Secret messages remove a known lock, the new locksroot must have only # that lock removed, otherwise the sender may be trying to remove # additional locks. msg = ( "Invalid Secret message. " "Balance proof's locksroot didn't match, expected: {} got: {}." ).format( hexlify(locksroot_without_lock).decode(), hexlify(received_balance_proof.locksroot).decode(), ) result = (False, msg, None) elif received_balance_proof.transferred_amount != expected_transferred_amount: # Secret messages must increase the transferred_amount by lock amount, # otherwise the sender is trying to play the protocol and steal token. msg = ( "Invalid Secret message. " "Balance proof's wrong transferred_amount, expected: {} got: {}." ).format( expected_transferred_amount, received_balance_proof.transferred_amount, ) result = (False, msg, None) elif received_balance_proof.channel_address != channel_state.identifier: # The balance proof must be tied to this channel, otherwise the # on-chain contract would be sucesstible to replay attacks across # channels. msg = ( 'Invalid Secret message. ' 'Balance proof is tied to the wrong channel, expected: {} got: {}' ).format( channel_state.identifier, hexlify(received_balance_proof.channel_address).decode(), ) result = (False, msg, None) else: result = (True, None, new_merkletree) return result def get_amount_locked(end_state): total_pending = sum( lock.amount for lock in end_state.hashlocks_to_pendinglocks.values() ) total_unclaimed = sum( unlock.lock.amount for unlock in end_state.hashlocks_to_unclaimedlocks.values() ) return total_pending + total_unclaimed def get_balance(sender, receiver): sender_transferred_amount = 0 receiver_transferred_amount = 0 if sender.balance_proof: sender_transferred_amount = sender.balance_proof.transferred_amount if receiver.balance_proof: receiver_transferred_amount = receiver.balance_proof.transferred_amount return ( sender.contract_balance - sender_transferred_amount + receiver_transferred_amount ) def get_current_balanceproof(end_state): balance_proof = end_state.balance_proof if balance_proof: locksroot = balance_proof.locksroot nonce = balance_proof.nonce transferred_amount = balance_proof.transferred_amount else: locksroot = EMPTY_MERKLE_ROOT nonce = 0 transferred_amount = 0 return (locksroot, nonce, transferred_amount) def get_distributable(sender, receiver): return get_balance(sender, receiver) - get_amount_locked(sender) def get_known_unlocks(end_state): """Generate unlocking proofs for the known secrets.""" return [ compute_proof_for_lock( end_state, partialproof.secret, partialproof.lock, ) for partialproof in end_state.hashlocks_to_unclaimedlocks.values() ] def get_lock( end_state: 'NettingChannelEndState', hashlock: typing.Keccak256, ) -> HashTimeLockState: """Return the lock correspoding to `hashlock` or None if the lock is unknown. """ lock = end_state.hashlocks_to_pendinglocks.get(hashlock) if not lock: partial_unlock = end_state.hashlocks_to_unclaimedlocks.get(hashlock) if partial_unlock: lock = partial_unlock.lock assert isinstance(lock, HashTimeLockState) or lock is None return lock def get_next_nonce(end_state): if end_state.balance_proof: return end_state.balance_proof.nonce + 1 # 0 must not be used since in the netting contract it represents null. return 1 def get_status(channel_state): if channel_state.settle_transaction: finished_sucessfully = ( channel_state.settle_transaction.result == TransactionExecutionStatus.SUCCESS ) running = channel_state.settle_transaction.finished_block_number is None if finished_sucessfully: result = CHANNEL_STATE_SETTLED elif running: result = CHANNEL_STATE_SETTLING else: result = CHANNEL_STATE_UNUSABLE elif channel_state.close_transaction: finished_sucessfully = ( channel_state.close_transaction.result == TransactionExecutionStatus.SUCCESS ) running = channel_state.close_transaction.finished_block_number is None if finished_sucessfully: result = CHANNEL_STATE_CLOSED elif running: result = CHANNEL_STATE_CLOSING else: result = CHANNEL_STATE_UNUSABLE else: result = CHANNEL_STATE_OPENED return result def del_lock(end_state, hashlock): assert is_known(end_state, hashlock) if hashlock in end_state.hashlocks_to_pendinglocks: del end_state.hashlocks_to_pendinglocks[hashlock] if hashlock in end_state.hashlocks_to_unclaimedlocks: del end_state.hashlocks_to_unclaimedlocks[hashlock] def set_closed(channel_state, block_number): if not channel_state.close_transaction: channel_state.close_transaction = TransactionExecutionStatus( None, block_number, TransactionExecutionStatus.SUCCESS, ) elif not channel_state.close_transaction.finished_block_number: channel_state.close_transaction.finished_block_number = block_number channel_state.close_transaction.result = TransactionExecutionStatus.SUCCESS def set_settled(channel_state, block_number): if not channel_state.settle_transaction: channel_state.settle_transaction = TransactionExecutionStatus( None, block_number, TransactionExecutionStatus.SUCCESS, ) elif not channel_state.settle_transaction.finished_block_number: channel_state.settle_transaction.finished_block_number = block_number channel_state.settle_transaction.result = TransactionExecutionStatus.SUCCESS def update_contract_balance(end_state: 'NettingChannelEndState', contract_balance): if contract_balance > end_state.contract_balance: end_state.contract_balance = contract_balance def compute_proof_for_lock( end_state: 'NettingChannelEndState', secret: typing.Secret, lock: HashTimeLockState ) -> UnlockProofState: # forcing bytes because ethereum.abi doesn't work with bytearray merkle_proof = compute_merkleproof_for(end_state.merkletree, lock.lockhash) return UnlockProofState( merkle_proof, lock.encoded, secret, ) def compute_merkletree_with( merkletree: MerkleTreeState, lockhash: typing.Keccak256, ) -> typing.Optional[MerkleTreeState]: """Register the given lockhash with the existing merkle tree.""" # Use None to inform the caller the lockshash is already known result = None leaves = merkletree.layers[LEAVES] if lockhash not in leaves: leaves = list(leaves) leaves.append(lockhash) result = MerkleTreeState(compute_layers(leaves)) return result def compute_merkletree_without(merkletree, lockhash): # Use None to inform the caller the lockshash is unknown result = None leaves = merkletree.layers[LEAVES] if lockhash in leaves: leaves = list(leaves) leaves.remove(lockhash) if leaves: result = MerkleTreeState(compute_layers(leaves)) else: result = EMPTY_MERKLE_TREE return result def create_senddirecttransfer(channel_state, amount, identifier): our_balance_proof = channel_state.our_state.balance_proof if our_balance_proof: transferred_amount = amount + our_balance_proof.transferred_amount locksroot = our_balance_proof.locksroot else: transferred_amount = amount locksroot = EMPTY_MERKLE_ROOT nonce = get_next_nonce(channel_state.our_state) token = channel_state.token_address recipient = channel_state.partner_state.address balance_proof = BalanceProofUnsignedState( nonce, transferred_amount, locksroot, channel_state.identifier, ) direct_transfer = SendDirectTransfer( identifier, balance_proof, token, recipient, ) return direct_transfer def create_sendmediatedtransfer( channel_state, initiator, target, amount, identifier, expiration, hashlock): our_state = channel_state.our_state partner_state = channel_state.partner_state our_balance_proof = our_state.balance_proof # The caller must check the capacity prior to the call msg = 'caller must make sure there is enough balance' assert amount <= get_distributable(our_state, partner_state), msg lock = HashTimeLockState( amount, expiration, hashlock, ) merkletree = compute_merkletree_with( channel_state.our_state.merkletree, lock.lockhash, ) # The caller must ensure the same lock is not being used twice assert merkletree, 'lock is already registered' locksroot = merkleroot(merkletree) if our_balance_proof: transferred_amount = our_balance_proof.transferred_amount else: transferred_amount = 0 token = channel_state.token_address nonce = get_next_nonce(channel_state.our_state) recipient = channel_state.partner_state.address balance_proof = BalanceProofUnsignedState( nonce, transferred_amount, locksroot, channel_state.identifier, ) locked_transfer = LockedTransferUnsignedState( identifier, token, balance_proof, lock, initiator, target, ) mediatedtransfer = SendMediatedTransfer( locked_transfer, recipient, ) return mediatedtransfer, merkletree def create_unlock(channel_state, identifier, secret, lock): msg = 'caller must make sure the lock is known' assert is_known(channel_state.our_state, lock.hashlock), msg our_balance_proof = channel_state.our_state.balance_proof if our_balance_proof: transferred_amount = lock.amount + our_balance_proof.transferred_amount else: transferred_amount = lock.amount merkletree = compute_merkletree_without( channel_state.our_state.merkletree, lock.lockhash, ) locksroot = merkleroot(merkletree) token = channel_state.token_address nonce = get_next_nonce(channel_state.our_state) recipient = channel_state.partner_state.address balance_proof = BalanceProofUnsignedState( nonce, transferred_amount, locksroot, channel_state.identifier, ) unlock_lock = SendBalanceProof( identifier, token, recipient, secret, balance_proof, ) return unlock_lock, merkletree def send_directtransfer(channel_state, amount, identifier): direct_transfer = create_senddirecttransfer( channel_state, amount, identifier, ) channel_state.our_state.balance_proof = direct_transfer.balance_proof return direct_transfer def send_mediatedtransfer( channel_state, initiator, target, amount, identifier, expiration, hashlock): send_event, merkletree = create_sendmediatedtransfer( channel_state, initiator, target, amount, identifier, expiration, hashlock, ) transfer = send_event.transfer lock = transfer.lock channel_state.our_state.balance_proof = transfer.balance_proof channel_state.our_state.merkletree = merkletree channel_state.our_state.hashlocks_to_pendinglocks[lock.hashlock] = lock return send_event def send_refundtransfer( channel_state, initiator, target, amount, identifier, expiration, hashlock): msg = 'Refunds are only valid for *know and pending* transfers' assert hashlock in channel_state.partner_state.hashlocks_to_pendinglocks, msg send_mediated_transfer, merkletree = create_sendmediatedtransfer( channel_state, initiator, target, amount, identifier, expiration, hashlock, ) mediated_transfer = send_mediated_transfer.transfer lock = mediated_transfer.lock channel_state.our_state.balance_proof = mediated_transfer.balance_proof channel_state.our_state.merkletree = merkletree channel_state.our_state.hashlocks_to_pendinglocks[lock.hashlock] = lock refund_transfer = refund_from_sendmediated(send_mediated_transfer) return refund_transfer def send_unlock(channel_state, identifier, secret, hashlock): lock = get_lock(channel_state.our_state, hashlock) assert lock unlock_lock, merkletree = create_unlock( channel_state, identifier, secret, lock, ) channel_state.our_state.balance_proof = unlock_lock.balance_proof channel_state.our_state.merkletree = merkletree del_lock(channel_state.our_state, lock.hashlock) return unlock_lock def events_for_close(channel_state, block_number): events = list() if get_status(channel_state) in CHANNEL_STATES_PRIOR_TO_CLOSED: channel_state.close_transaction = TransactionExecutionStatus( block_number, None, None ) close_event = ContractSendChannelClose( channel_state.identifier, channel_state.token_address, channel_state.partner_state.balance_proof, ) events.append(close_event) return events def register_secret_endstate(end_state, secret, hashlock): if is_locked(end_state, hashlock): pendinglock = end_state.hashlocks_to_pendinglocks[hashlock] del end_state.hashlocks_to_pendinglocks[hashlock] end_state.hashlocks_to_unclaimedlocks[hashlock] = UnlockPartialProofState( pendinglock, secret, ) def register_secret(channel_state, secret, hashlock): """This will register the secret and set the lock to the unlocked stated. Even though the lock is unlock it's is *not* claimed. The capacity will increase once the next balance proof is received. """ our_state = channel_state.our_state partner_state = channel_state.partner_state register_secret_endstate(our_state, secret, hashlock) register_secret_endstate(partner_state, secret, hashlock) def handle_send_directtransfer(channel_state, state_change): events = list() amount = state_change.amount identifier = state_change.identifier distributable_amount = get_distributable(channel_state.our_state, channel_state.partner_state) is_open = get_status(channel_state) == CHANNEL_STATE_OPENED is_valid = amount > 0 can_pay = amount <= distributable_amount if is_open and is_valid and can_pay: direct_transfer = send_directtransfer( channel_state, amount, identifier, ) events.append(direct_transfer) else: if not is_open: failure = EventTransferSentFailed( state_change.identifier, 'Channel is not opened', ) events.append(failure) elif not is_valid: msg = 'Transfer amount is invalid. Transfer: {}'.format(amount) failure = EventTransferSentFailed(state_change.identifier, msg) events.append(failure) elif not can_pay: msg = ( 'Transfer amount exceeds the available capacity. ' 'Capacity: {}, Transfer: {}' ).format( distributable_amount, amount, ) failure = EventTransferSentFailed(state_change.identifier, msg) events.append(failure) return TransitionResult(channel_state, events) def handle_action_close(channel_state, close, block_number): msg = 'caller must make sure the ids match' assert channel_state.identifier == close.channel_identifier, msg events = events_for_close(channel_state, block_number) return TransitionResult(channel_state, events) def handle_receive_directtransfer(channel_state, direct_transfer): is_valid, msg = is_valid_directtransfer( direct_transfer, channel_state, channel_state.partner_state, channel_state.our_state, ) if is_valid: _, _, previous_transferred_amount = get_current_balanceproof(channel_state.partner_state) new_transferred_amount = direct_transfer.balance_proof.transferred_amount transfer_amount = new_transferred_amount - previous_transferred_amount channel_state.partner_state.balance_proof = direct_transfer.balance_proof event = EventTransferReceivedSuccess( direct_transfer.transfer_identifier, transfer_amount, channel_state.partner_state.address, ) events = [event] else: event = EventTransferReceivedInvalidDirectTransfer( direct_transfer.transfer_identifier, reason=msg, ) events = [event] return TransitionResult(channel_state, events) def handle_receive_mediatedtransfer( channel_state: 'NettingChannelState', mediated_transfer: 'LockedTransferSignedState' ): """Register the latest known transfer. The receiver needs to use this method to update the container with a _valid_ transfer, otherwise the locksroot will not contain the pending transfer. The receiver needs to ensure that the merkle root has the hashlock included, otherwise it won't be able to claim it. """ is_valid, msg, merkletree = is_valid_mediatedtransfer( mediated_transfer, channel_state, channel_state.partner_state, channel_state.our_state, ) if is_valid: channel_state.partner_state.balance_proof = mediated_transfer.balance_proof channel_state.partner_state.merkletree = merkletree lock = mediated_transfer.lock channel_state.partner_state.hashlocks_to_pendinglocks[lock.hashlock] = lock return is_valid, msg def handle_receive_refundtransfer(channel_state, refund_transfer): return handle_receive_mediatedtransfer(channel_state, refund_transfer) def handle_receive_secretreveal(channel_state, state_change): secret = state_change.secret hashlock = state_change.hashlock register_secret(channel_state, secret, hashlock) def handle_unlock(channel_state, unlock): is_valid, msg, unlocked_merkletree = is_valid_unlock( unlock, channel_state, channel_state.partner_state, ) if is_valid: channel_state.partner_state.balance_proof = unlock.balance_proof channel_state.partner_state.merkletree = unlocked_merkletree del_lock(channel_state.partner_state, unlock.hashlock) return is_valid, msg def handle_block(channel_state, state_change, block_number): assert state_change.block_number == block_number events = list() if get_status(channel_state) == CHANNEL_STATE_CLOSED: closed_block_number = channel_state.close_transaction.finished_block_number settlement_end = closed_block_number + channel_state.settle_timeout if state_change.block_number > settlement_end: channel_state.settle_transaction = TransactionExecutionStatus( state_change.block_number, None, None ) event = ContractSendChannelSettle(channel_state.identifier) events.append(event) while is_deposit_confirmed(channel_state, block_number): order_deposit_transaction = heapq.heappop(channel_state.deposit_transaction_queue) apply_channel_newbalance( channel_state, order_deposit_transaction.transaction, ) return TransitionResult(channel_state, events) def handle_channel_closed(channel_state, state_change): events = list() just_closed = ( state_change.channel_identifier == channel_state.identifier and get_status(channel_state) in CHANNEL_STATES_PRIOR_TO_CLOSED ) if just_closed: set_closed(channel_state, state_change.closed_block_number) balance_proof = channel_state.partner_state.balance_proof call_update = ( state_change.closing_address != channel_state.our_state.address and balance_proof ) if call_update: # The channel was closed by our partner, if there is a balance # proof available update this node half of the state update = ContractSendChannelUpdateTransfer( channel_state.identifier, balance_proof, ) events.append(update) unlock_proofs = get_known_unlocks(channel_state.partner_state) if unlock_proofs: withdraw = ContractSendChannelWithdraw( channel_state.identifier, unlock_proofs, ) events.append(withdraw) return TransitionResult(channel_state, events) def handle_channel_settled(channel_state, state_change): events = list() if state_change.channel_identifier == channel_state.identifier: set_settled(channel_state, state_change.settle_block_number) return TransitionResult(channel_state, events) def handle_channel_newbalance(channel_state, state_change, block_number): deposit_transaction = state_change.deposit_transaction if is_transaction_confirmed(deposit_transaction.deposit_block_number, block_number): apply_channel_newbalance(channel_state, state_change.deposit_transaction) else: order = TransactionOrder( deposit_transaction.deposit_block_number, deposit_transaction, ) heapq.heappush(channel_state.deposit_transaction_queue, order) events = list() return TransitionResult(channel_state, events) def apply_channel_newbalance(channel_state, deposit_transaction): participant_address = deposit_transaction.participant_address if participant_address == channel_state.our_state.address: new_balance = max( channel_state.our_state.contract_balance, deposit_transaction.contract_balance, ) channel_state.our_state.contract_balance = new_balance elif participant_address == channel_state.partner_state.address: new_balance = max( channel_state.partner_state.contract_balance, deposit_transaction.contract_balance, ) channel_state.partner_state.contract_balance = new_balance def handle_channel_withdraw(channel_state, state_change): hashlock = state_change.hashlock secret = state_change.secret our_withdraw = ( state_change.receiver == channel_state.our_state.address and is_locked(channel_state.partner_state, hashlock) ) # FIXME: must not remove the lock, otherwise a new unlock proof cannot be # made if our_withdraw: del_lock(channel_state.partner_state, hashlock) partner_withdraw = ( state_change.receiver == channel_state.partner_state.address and is_locked(channel_state.our_state, hashlock) ) if partner_withdraw: del_lock(channel_state.our_state, hashlock) # Withdraw is required if there was a refund in this channel, and the # secret is learned from the withdraw event. events = [] if is_locked(channel_state.our_state, hashlock): lock = get_lock(channel_state.our_state, hashlock) proof = compute_proof_for_lock(channel_state.our_state, secret, lock) withdraw = ContractSendChannelWithdraw(channel_state.identifier, [proof]) events.append(withdraw) register_secret(channel_state, secret, hashlock) return TransitionResult(channel_state, events) def state_transition(channel_state, state_change, block_number): # pylint: disable=too-many-branches,unidiomatic-typecheck events = list() iteration = TransitionResult(channel_state, events) if type(state_change) == Block: iteration = handle_block(channel_state, state_change, block_number) elif type(state_change) == ActionChannelClose: iteration = handle_action_close(channel_state, state_change, block_number) elif type(state_change) == ActionTransferDirect: iteration = handle_send_directtransfer(channel_state, state_change) elif type(state_change) == ContractReceiveChannelClosed: iteration = handle_channel_closed(channel_state, state_change) elif type(state_change) == ContractReceiveChannelSettled: iteration = handle_channel_settled(channel_state, state_change) elif type(state_change) == ContractReceiveChannelNewBalance: iteration = handle_channel_newbalance(channel_state, state_change, block_number) elif type(state_change) == ContractReceiveChannelWithdraw: iteration = handle_channel_withdraw(channel_state, state_change) elif type(state_change) == ReceiveTransferDirect: iteration = handle_receive_directtransfer(channel_state, state_change) return iteration
[ 1, 396, 448, 29930, 29899, 14137, 29901, 23616, 29899, 29947, 448, 29930, 29899, 13, 29937, 282, 2904, 524, 29901, 11262, 29922, 517, 29877, 29899, 13011, 29899, 9012, 13, 5215, 16947, 29939, 13, 3166, 9016, 294, 18869, 1053, 15090, 29880, 1598, 13, 3166, 16250, 1053, 4257, 23583, 13, 13, 3166, 1153, 3615, 29889, 22331, 29889, 4530, 292, 1053, 9792, 29918, 3597, 1989, 13, 3166, 1153, 3615, 29889, 3286, 571, 29889, 25428, 1053, 4103, 654, 3591, 13, 3166, 1153, 3615, 29889, 3286, 571, 29889, 5521, 749, 29918, 8017, 1053, 26188, 29918, 1272, 13, 3166, 1153, 3615, 29889, 3286, 571, 29889, 13604, 1053, 313, 13, 1678, 2866, 1461, 12600, 13599, 11123, 29892, 13, 1678, 2866, 1461, 12600, 13599, 29903, 1803, 280, 29892, 13, 1678, 2866, 1461, 12600, 13599, 6422, 4300, 571, 29892, 13, 1678, 2866, 1461, 12600, 13599, 3047, 4012, 29892, 13, 1678, 6864, 4300, 571, 29816, 13919, 17392, 4300, 571, 29892, 13, 1678, 6864, 4300, 571, 29816, 14191, 29892, 13, 1678, 6864, 4300, 571, 29903, 296, 17776, 29892, 13, 1678, 15076, 17392, 4300, 571, 29892, 13, 29897, 13, 3166, 1153, 3615, 29889, 3286, 571, 29889, 4210, 630, 29918, 3286, 571, 29889, 3859, 1053, 18199, 287, 4300, 571, 25807, 12961, 2792, 13, 3166, 1153, 3615, 29889, 3286, 571, 29889, 4210, 630, 29918, 3286, 571, 29889, 13604, 1053, 313, 13, 1678, 2143, 870, 29918, 3166, 29918, 6717, 4210, 630, 29892, 13, 1678, 15076, 22031, 749, 28116, 29892, 13, 1678, 15076, 29924, 15844, 630, 4300, 571, 29892, 13, 29897, 13, 3166, 1153, 3615, 29889, 3286, 571, 29889, 28150, 280, 29918, 8336, 1053, 313, 13, 1678, 11060, 7520, 2890, 29892, 13, 1678, 2778, 29895, 1358, 3155, 29892, 13, 1678, 10272, 29918, 29277, 29892, 13, 1678, 10272, 29918, 28150, 280, 8017, 29918, 1454, 29892, 13, 29897, 13, 3166, 1153, 3615, 29889, 3286, 571, 29889, 3859, 1053, 313, 13, 1678, 5868, 2190, 29940, 6670, 29918, 19713, 29918, 29907, 3927, 1660, 29928, 29892, 13, 1678, 5868, 2190, 29940, 6670, 29918, 19713, 29918, 6154, 3267, 4214, 29892, 13, 1678, 5868, 2190, 29940, 6670, 29918, 19713, 29918, 4590, 1430, 3352, 29892, 13, 1678, 5868, 2190, 29940, 6670, 29918, 19713, 29918, 10490, 29911, 20566, 29892, 13, 1678, 5868, 2190, 29940, 6670, 29918, 19713, 29918, 10490, 14632, 4214, 29892, 13, 1678, 5868, 2190, 29940, 6670, 29918, 17816, 2890, 29918, 29829, 1955, 29918, 4986, 29918, 29907, 3927, 1660, 29928, 29892, 13, 1678, 5868, 2190, 29940, 6670, 29918, 19713, 29918, 3904, 3308, 6181, 29892, 13, 1678, 382, 3580, 15631, 29918, 29924, 1001, 29968, 1307, 29918, 21289, 29892, 13, 1678, 382, 3580, 15631, 29918, 29924, 1001, 29968, 1307, 29918, 29911, 21661, 29892, 13, 1678, 7392, 749, 28116, 25807, 12961, 2792, 29892, 13, 1678, 11874, 2481, 16542, 2792, 29892, 13, 1678, 4702, 29895, 280, 9643, 2792, 29892, 13, 1678, 4103, 2467, 20418, 5709, 29892, 13, 1678, 853, 908, 7439, 616, 28116, 2792, 29892, 13, 1678, 853, 908, 28116, 2792, 29892, 13, 29897, 13, 3166, 1153, 3615, 29889, 3286, 571, 29889, 3859, 29918, 3167, 1053, 313, 13, 1678, 9123, 13599, 11123, 29892, 13, 1678, 9123, 4300, 571, 17392, 29892, 13, 1678, 15658, 29892, 13, 1678, 2866, 1461, 24131, 13599, 6821, 2662, 29892, 13, 1678, 2866, 1461, 24131, 13599, 4373, 22031, 749, 29892, 13, 1678, 2866, 1461, 24131, 13599, 29903, 1803, 839, 29892, 13, 1678, 2866, 1461, 24131, 13599, 3047, 4012, 29892, 13, 1678, 24328, 573, 4300, 571, 17392, 29892, 13, 29897, 13, 3166, 1153, 3615, 29889, 13239, 1053, 970, 1989, 29918, 517, 29918, 7328, 29892, 19229, 13, 3166, 1153, 3615, 29889, 11027, 1053, 22236, 29918, 23207, 29918, 9800, 29918, 6007, 3738, 29934, 29924, 8098, 29903, 29918, 29933, 21339, 13, 13, 13, 12460, 7514, 353, 4257, 23583, 29898, 13, 1678, 525, 12460, 7514, 742, 13, 1678, 6702, 1271, 29918, 4537, 742, 525, 20736, 1495, 13, 29897, 13, 13, 13, 1753, 338, 29918, 5203, 29898, 355, 29918, 3859, 29892, 6608, 908, 1125, 13, 1678, 9995, 5574, 565, 278, 421, 8568, 908, 29952, 16161, 304, 263, 2998, 7714, 1213, 15945, 13, 1678, 736, 313, 13, 4706, 6608, 908, 297, 1095, 29918, 3859, 29889, 8568, 908, 29879, 29918, 517, 29918, 29886, 2548, 908, 29879, 470, 13, 4706, 6608, 908, 297, 1095, 29918, 3859, 29889, 8568, 908, 29879, 29918, 517, 29918, 4661, 13190, 908, 29879, 13, 1678, 1723, 13, 13, 13, 1753, 338, 29918, 311, 1066, 277, 29918, 5527, 381, 2168, 29898, 12719, 29918, 3859, 29892, 2908, 29918, 4537, 1125, 13, 1678, 565, 451, 8242, 29918, 3859, 29889, 311, 1066, 277, 29918, 20736, 29918, 9990, 29901, 13, 4706, 736, 7700, 13, 13, 1678, 736, 338, 29918, 20736, 29918, 5527, 381, 2168, 29898, 13, 4706, 8242, 29918, 3859, 29889, 311, 1066, 277, 29918, 20736, 29918, 9990, 29961, 29900, 1822, 1271, 29918, 4537, 29892, 13, 4706, 2908, 29918, 4537, 29892, 13, 1678, 1723, 13, 13, 13, 1753, 338, 29918, 29113, 29898, 355, 29918, 3859, 29892, 6608, 908, 1125, 13, 1678, 9995, 5574, 565, 278, 421, 8568, 908, 29952, 338, 2998, 322, 278, 1034, 13713, 3689, 7035, 338, 451, 1213, 15945, 13, 1678, 736, 6608, 908, 297, 1095, 29918, 3859, 29889, 8568, 908, 29879, 29918, 517, 29918, 29886, 2548, 908, 29879, 13, 13, 13, 1753, 338, 29918, 19024, 29918, 5203, 29898, 355, 29918, 3859, 29892, 6608, 908, 1125, 13, 1678, 9995, 5574, 565, 278, 421, 8568, 908, 29952, 338, 363, 263, 7714, 411, 263, 2998, 7035, 1213, 15945, 13, 1678, 736, 6608, 908, 297, 1095, 29918, 3859, 29889, 8568, 908, 29879, 29918, 517, 29918, 4661, 13190, 908, 29879, 13, 13, 13, 1753, 338, 29918, 20736, 29918, 5527, 381, 2168, 29898, 20736, 29918, 1271, 29918, 4537, 29892, 2908, 14153, 29918, 1271, 29918, 4537, 1125, 13, 1678, 9659, 362, 29918, 1271, 353, 10804, 29918, 1271, 29918, 4537, 718, 22236, 29918, 23207, 29918, 9800, 29918, 6007, 3738, 29934, 29924, 8098, 29903, 29918, 29933, 21339, 13, 1678, 736, 2908, 14153, 29918, 1271, 29918, 4537, 1405, 9659, 362, 29918, 1271, 13, 13, 13, 1753, 338, 29918, 3084, 29918, 4530, 1535, 29898, 5521, 749, 29918, 8017, 29892, 10004, 29918, 7328, 1125, 13, 1678, 848, 29918, 5747, 29918, 11102, 29918, 7433, 353, 26188, 29918, 1272, 29898, 13, 4706, 17346, 29918, 8017, 29889, 5464, 346, 29892, 13, 4706, 17346, 29918, 8017, 29889, 3286, 14373, 29918, 14506, 29892, 13, 4706, 17346, 29918, 8017, 29889, 12719, 29918, 7328, 29892, 13, 4706, 17346, 29918, 8017, 29889, 908, 29879, 4632, 29892, 13, 4706, 17346, 29918, 8017, 29889, 4906, 29918, 8568, 29892, 13, 1678, 1723, 13, 13, 1678, 1018, 29901, 13, 4706, 396, 7865, 2392, 338, 10425, 565, 278, 5236, 2558, 13213, 362, 5229, 29892, 1235, 372, 13, 4706, 396, 13089, 403, 1363, 372, 29915, 29879, 263, 3370, 12959, 1108, 13, 4706, 970, 1989, 353, 9792, 29918, 3597, 1989, 29898, 13, 9651, 848, 29918, 5747, 29918, 11102, 29918, 7433, 29892, 13, 9651, 17346, 29918, 8017, 29889, 4530, 1535, 29892, 13, 4706, 1723, 13, 1678, 5174, 8960, 29901, 29871, 396, 282, 2904, 524, 29901, 11262, 29922, 6729, 328, 29899, 19499, 13, 4706, 396, 5226, 29886, 29906, 29945, 29953, 29895, 29896, 338, 773, 16079, 8960, 4413, 13, 4706, 396, 10425, 565, 278, 24205, 5229, 13, 4706, 10191, 353, 525, 10140, 1535, 8340, 29892, 1033, 451, 367, 24776, 6169, 13, 4706, 736, 313, 8824, 29892, 10191, 29897, 13, 13, 1678, 338, 29918, 15728, 29918, 15452, 353, 10004, 29918, 7328, 1275, 970, 1989, 29918, 517, 29918, 7328, 29898, 3597, 1989, 29897, 13, 1678, 565, 338, 29918, 15728, 29918, 15452, 29901, 13, 4706, 736, 313, 5574, 29892, 6213, 29897, 13, 13, 1678, 10191, 353, 525, 10140, 1535, 471, 2854, 541, 278, 3806, 3211, 947, 451, 1993, 6169, 13, 1678, 736, 313, 8824, 29892, 10191, 29897, 13, 13, 13, 1753, 338, 29918, 3084, 29918, 11851, 3286, 571, 29898, 11851, 29918, 3286, 571, 29892, 8242, 29918, 3859, 29892, 10004, 29918, 3859, 29892, 19870, 29918, 3859, 1125, 13, 1678, 4520, 29918, 5521, 749, 29918, 8017, 353, 1513, 29918, 3286, 571, 29889, 5521, 749, 29918, 8017, 13, 1678, 1857, 29918, 5521, 749, 29918, 8017, 353, 679, 29918, 3784, 29918, 5521, 749, 8017, 29898, 15452, 29918, 3859, 29897, 13, 13, 1678, 1857, 29918, 908, 29879, 4632, 29892, 17117, 1857, 29918, 3286, 14373, 29918, 14506, 353, 1857, 29918, 5521, 749, 29918, 8017, 13, 1678, 22965, 9246, 353, 679, 29918, 5721, 1091, 9246, 29898, 15452, 29918, 3859, 29892, 19870, 29918, 3859, 29897, 13, 1678, 3806, 29918, 5464, 346, 353, 679, 29918, 4622, 29918, 5464, 346, 29898, 15452, 29918, 3859, 29897, 13, 13, 1678, 5253, 353, 4520, 29918, 5521, 749, 29918, 8017, 29889, 3286, 14373, 29918, 14506, 448, 1857, 29918, 3286, 14373, 29918, 14506, 13, 13, 1678, 338, 29918, 3084, 29892, 12608, 29918, 7645, 353, 338, 29918, 3084, 29918, 4530, 1535, 29898, 13, 4706, 4520, 29918, 5521, 749, 29918, 8017, 29892, 13, 4706, 10004, 29918, 3859, 29889, 7328, 29892, 13, 1678, 1723, 13, 13, 1678, 565, 679, 29918, 4882, 29898, 12719, 29918, 3859, 29897, 2804, 5868, 2190, 29940, 6670, 29918, 19713, 29918, 4590, 1430, 3352, 29901, 13, 4706, 10191, 353, 525, 13919, 1513, 2643, 29889, 450, 8242, 338, 2307, 5764, 6169, 13, 4706, 1121, 353, 313, 8824, 29892, 10191, 29897, 13, 13, 1678, 25342, 451, 338, 29918, 3084, 29901, 13, 4706, 396, 450, 12608, 1818, 367, 2854, 29892, 6467, 278, 17346, 5296, 2609, 367, 13, 4706, 396, 1304, 373, 14153, 29889, 13, 4706, 10191, 353, 525, 13919, 8797, 4300, 571, 2643, 29889, 6571, 4286, 4830, 29898, 4530, 1535, 29918, 7645, 29897, 13, 13, 4706, 1121, 353, 313, 8824, 29892, 10191, 29897, 13, 13, 1678, 25342, 4520, 29918, 5521, 749, 29918, 8017, 29889, 5464, 346, 2804, 3806, 29918, 5464, 346, 29901, 13, 4706, 396, 450, 1661, 778, 1818, 7910, 8617, 9247, 29892, 6467, 727, 338, 263, 13, 4706, 396, 12231, 2133, 1108, 29889, 13, 4706, 10191, 353, 313, 13, 9651, 525, 13919, 8797, 4300, 571, 2643, 29889, 525, 13, 9651, 525, 29940, 10646, 1258, 451, 1735, 8617, 9247, 29892, 3806, 29901, 6571, 2355, 29901, 426, 1836, 29915, 13, 4706, 13742, 4830, 29898, 13, 9651, 3806, 29918, 5464, 346, 29892, 13, 9651, 4520, 29918, 5521, 749, 29918, 8017, 29889, 5464, 346, 29892, 13, 4706, 1723, 13, 13, 4706, 1121, 353, 313, 8824, 29892, 10191, 29897, 13, 13, 1678, 25342, 4520, 29918, 5521, 749, 29918, 8017, 29889, 908, 29879, 4632, 2804, 1857, 29918, 908, 29879, 4632, 29901, 13, 4706, 396, 8797, 1301, 25534, 437, 451, 671, 6608, 931, 7714, 29892, 577, 372, 2609, 1735, 278, 13, 4706, 396, 658, 4684, 4632, 29892, 6467, 263, 7714, 1033, 367, 6206, 29889, 13, 4706, 10191, 353, 313, 13, 9651, 376, 13919, 8797, 4300, 571, 2643, 29889, 376, 13, 9651, 376, 22031, 749, 5296, 29915, 29879, 658, 4684, 4632, 3939, 29892, 3806, 29901, 6571, 2355, 29901, 6571, 1213, 13, 4706, 13742, 4830, 29898, 13, 9651, 15090, 29880, 1598, 29898, 3784, 29918, 908, 29879, 4632, 467, 13808, 3285, 13, 9651, 15090, 29880, 1598, 29898, 13556, 2347, 29918, 5521, 749, 29918, 8017, 29889, 908, 29879, 4632, 467, 13808, 3285, 13, 4706, 1723, 13, 13, 4706, 1121, 353, 313, 8824, 29892, 10191, 29897, 13, 13, 1678, 25342, 4520, 29918, 5521, 749, 29918, 8017, 29889, 3286, 14373, 29918, 14506, 5277, 1857, 29918, 3286, 14373, 29918, 14506, 29901, 13, 4706, 396, 8797, 1301, 25534, 1818, 7910, 278, 18440, 29918, 14506, 29892, 6467, 278, 13, 4706, 396, 10004, 338, 1811, 304, 1708, 278, 9608, 322, 1886, 284, 5993, 29889, 13, 4706, 10191, 353, 313, 13, 9651, 376, 13919, 8797, 4300, 571, 2643, 29889, 376, 13, 9651, 376, 22031, 749, 5296, 29915, 29879, 18440, 29918, 14506, 9263, 1463, 29892, 3806, 7200, 1135, 29901, 6571, 2355, 29901, 6571, 1213, 13, 4706, 13742, 4830, 29898, 13, 9651, 1857, 29918, 3286, 14373, 29918, 14506, 29892, 13, 9651, 4520, 29918, 5521, 749, 29918, 8017, 29889, 3286, 14373, 29918, 14506, 29892, 13, 4706, 1723, 13, 13, 4706, 1121, 353, 313, 8824, 29892, 10191, 29897, 13, 13, 1678, 25342, 4520, 29918, 5521, 749, 29918, 8017, 29889, 12719, 29918, 7328, 2804, 8242, 29918, 3859, 29889, 25378, 29901, 13, 4706, 396, 450, 17346, 5296, 1818, 367, 21351, 304, 445, 8242, 29892, 6467, 278, 13, 4706, 396, 373, 29899, 14153, 8078, 723, 367, 480, 778, 303, 1821, 304, 337, 1456, 16661, 4822, 13, 4706, 396, 18196, 29889, 13, 4706, 10191, 353, 313, 13, 9651, 525, 13919, 8797, 4300, 571, 2643, 29889, 525, 13, 9651, 525, 22031, 749, 5296, 338, 21351, 304, 278, 2743, 8242, 29892, 3806, 29901, 6571, 2355, 29901, 6571, 29915, 13, 4706, 13742, 4830, 29898, 13, 9651, 15090, 29880, 1598, 29898, 12719, 29918, 3859, 29889, 25378, 467, 13808, 3285, 13, 9651, 15090, 29880, 1598, 29898, 13556, 2347, 29918, 5521, 749, 29918, 8017, 29889, 12719, 29918, 7328, 467, 13808, 3285, 13, 4706, 1723, 13, 4706, 1121, 353, 313, 8824, 29892, 10191, 29897, 13, 13, 1678, 25342, 5253, 1405, 22965, 9246, 29901, 13, 4706, 396, 8797, 6782, 526, 9078, 304, 278, 1857, 3625, 17346, 29892, 13, 4706, 396, 6467, 278, 10004, 338, 2599, 263, 1811, 304, 1708, 278, 9608, 322, 437, 263, 13, 4706, 396, 3765, 18864, 29889, 13, 4706, 10191, 353, 313, 13, 9651, 525, 13919, 8797, 4300, 571, 2643, 29889, 525, 13, 9651, 525, 4300, 571, 5253, 7200, 1135, 278, 3625, 22965, 9246, 29892, 525, 13, 9651, 525, 3286, 571, 5253, 29901, 6571, 7472, 22965, 9246, 29901, 6571, 29915, 13, 4706, 13742, 4830, 29898, 13, 9651, 5253, 29892, 13, 9651, 22965, 9246, 29892, 13, 4706, 1723, 13, 13, 4706, 1121, 353, 313, 8824, 29892, 10191, 29897, 13, 13, 1678, 1683, 29901, 13, 4706, 1121, 353, 313, 5574, 29892, 6213, 29897, 13, 13, 1678, 736, 1121, 13, 13, 13, 1753, 338, 29918, 3084, 29918, 4210, 630, 3286, 571, 29898, 4210, 630, 29918, 3286, 571, 29892, 8242, 29918, 3859, 29892, 10004, 29918, 3859, 29892, 19870, 29918, 3859, 1125, 13, 1678, 4520, 29918, 5521, 749, 29918, 8017, 353, 14457, 630, 29918, 3286, 571, 29889, 5521, 749, 29918, 8017, 13, 1678, 1857, 29918, 5521, 749, 29918, 8017, 353, 679, 29918, 3784, 29918, 5521, 749, 8017, 29898, 15452, 29918, 3859, 29897, 13, 13, 1678, 17117, 17117, 1857, 29918, 3286, 14373, 29918, 14506, 353, 1857, 29918, 5521, 749, 29918, 8017, 13, 1678, 22965, 9246, 353, 679, 29918, 5721, 1091, 9246, 29898, 15452, 29918, 3859, 29892, 19870, 29918, 3859, 29897, 13, 1678, 3806, 29918, 5464, 346, 353, 679, 29918, 4622, 29918, 5464, 346, 29898, 15452, 29918, 3859, 29897, 13, 13, 1678, 7714, 353, 14457, 630, 29918, 3286, 571, 29889, 908, 13, 1678, 2778, 29895, 1026, 929, 353, 10272, 29918, 28150, 1026, 929, 29918, 2541, 29898, 15452, 29918, 3859, 29889, 28150, 1026, 929, 29892, 7714, 29889, 908, 8568, 29897, 13, 13, 1678, 565, 679, 29918, 4882, 29898, 12719, 29918, 3859, 29897, 2804, 5868, 2190, 29940, 6670, 29918, 19713, 29918, 4590, 1430, 3352, 29901, 13, 4706, 10191, 353, 525, 13919, 1513, 2643, 29889, 450, 8242, 338, 2307, 5764, 6169, 13, 4706, 1121, 353, 313, 8824, 29892, 10191, 29892, 6213, 29897, 13, 13, 1678, 565, 2778, 29895, 1026, 929, 338, 6213, 29901, 13, 4706, 10191, 353, 525, 13919, 22855, 630, 4300, 571, 2643, 29889, 19491, 7714, 8568, 16459, 8951, 6169, 13, 4706, 1121, 353, 313, 8824, 29892, 10191, 29892, 6213, 29897, 13, 13, 1678, 1683, 29901, 13, 4706, 658, 4684, 4632, 29918, 2541, 29918, 908, 353, 2778, 29895, 1358, 3155, 29898, 28150, 1026, 929, 29897, 13, 13, 4706, 313, 275, 29918, 3084, 29892, 12608, 29918, 7645, 29897, 353, 338, 29918, 3084, 29918, 4530, 1535, 29898, 13, 9651, 4520, 29918, 5521, 749, 29918, 8017, 29892, 13, 9651, 10004, 29918, 3859, 29889, 7328, 29892, 13, 4706, 1723, 13, 13, 4706, 565, 451, 338, 29918, 3084, 29901, 13, 9651, 396, 450, 12608, 1818, 367, 2854, 29892, 6467, 278, 17346, 5296, 2609, 367, 13, 9651, 396, 1304, 373, 14153, 13, 9651, 10191, 353, 525, 13919, 22855, 630, 4300, 571, 2643, 29889, 6571, 4286, 4830, 29898, 4530, 1535, 29918, 7645, 29897, 13, 13, 9651, 1121, 353, 313, 8824, 29892, 10191, 29892, 6213, 29897, 13, 13, 4706, 25342, 4520, 29918, 5521, 749, 29918, 8017, 29889, 5464, 346, 2804, 3806, 29918, 5464, 346, 29901, 13, 9651, 396, 450, 1661, 778, 1818, 7910, 8617, 9247, 29892, 6467, 727, 338, 263, 13, 9651, 396, 12231, 2133, 1108, 13, 9651, 10191, 353, 313, 13, 18884, 525, 13919, 22855, 630, 4300, 571, 2643, 29889, 525, 13, 18884, 525, 29940, 10646, 1258, 451, 1735, 8617, 9247, 29892, 3806, 29901, 6571, 2355, 29901, 426, 1836, 29915, 13, 9651, 13742, 4830, 29898, 13, 18884, 3806, 29918, 5464, 346, 29892, 13, 18884, 4520, 29918, 5521, 749, 29918, 8017, 29889, 5464, 346, 29892, 13, 9651, 1723, 13, 13, 9651, 1121, 353, 313, 8824, 29892, 10191, 29892, 6213, 29897, 13, 13, 4706, 25342, 4520, 29918, 5521, 749, 29918, 8017, 29889, 908, 29879, 4632, 2804, 658, 4684, 4632, 29918, 2541, 29918, 908, 29901, 13, 9651, 396, 450, 658, 4684, 4632, 1818, 367, 4784, 304, 3160, 278, 716, 7714, 13, 9651, 10191, 353, 313, 13, 18884, 376, 13919, 22855, 630, 4300, 571, 2643, 29889, 376, 13, 18884, 376, 22031, 749, 5296, 29915, 29879, 658, 4684, 4632, 3282, 29915, 29873, 1993, 29892, 3806, 29901, 6571, 2355, 29901, 6571, 1213, 13, 9651, 13742, 4830, 29898, 13, 18884, 15090, 29880, 1598, 29898, 908, 29879, 4632, 29918, 2541, 29918, 908, 467, 13808, 3285, 13, 18884, 15090, 29880, 1598, 29898, 13556, 2347, 29918, 5521, 749, 29918, 8017, 29889, 908, 29879, 4632, 467, 13808, 3285, 13, 9651, 1723, 13, 13, 9651, 1121, 353, 313, 8824, 29892, 10191, 29892, 6213, 29897, 13, 13, 4706, 25342, 4520, 29918, 5521, 749, 29918, 8017, 29889, 3286, 14373, 29918, 14506, 2804, 1857, 29918, 3286, 14373, 29918, 14506, 29901, 13, 9651, 396, 22855, 630, 1301, 25534, 1818, 451, 1735, 18440, 29918, 14506, 13, 9651, 10191, 353, 313, 13, 18884, 376, 13919, 22855, 630, 4300, 571, 2643, 29889, 376, 13, 18884, 376, 22031, 749, 5296, 29915, 29879, 18440, 29918, 14506, 3939, 29892, 3806, 29901, 6571, 2355, 29901, 6571, 1213, 13, 9651, 13742, 4830, 29898, 13, 18884, 1857, 29918, 3286, 14373, 29918, 14506, 29892, 13, 18884, 4520, 29918, 5521, 749, 29918, 8017, 29889, 3286, 14373, 29918, 14506, 29892, 13, 9651, 1723, 13, 13, 9651, 1121, 353, 313, 8824, 29892, 10191, 29892, 6213, 29897, 13, 13, 4706, 25342, 4520, 29918, 5521, 749, 29918, 8017, 29889, 12719, 29918, 7328, 2804, 8242, 29918, 3859, 29889, 25378, 29901, 13, 9651, 396, 450, 17346, 5296, 1818, 367, 21351, 304, 445, 8242, 29892, 6467, 278, 13, 9651, 396, 373, 29899, 14153, 8078, 723, 367, 480, 778, 303, 1821, 304, 337, 1456, 16661, 4822, 13, 9651, 396, 18196, 29889, 13, 9651, 10191, 353, 313, 13, 18884, 525, 13919, 22855, 630, 4300, 571, 2643, 29889, 525, 13, 18884, 525, 22031, 749, 5296, 338, 21351, 304, 278, 2743, 8242, 29892, 3806, 29901, 6571, 2355, 29901, 6571, 29915, 13, 9651, 13742, 4830, 29898, 13, 18884, 15090, 29880, 1598, 29898, 12719, 29918, 3859, 29889, 25378, 467, 13808, 3285, 13, 18884, 15090, 29880, 1598, 29898, 13556, 2347, 29918, 5521, 749, 29918, 8017, 29889, 12719, 29918, 7328, 467, 13808, 3285, 13, 9651, 1723, 13, 9651, 1121, 353, 313, 8824, 29892, 10191, 29892, 6213, 29897, 13, 13, 4706, 396, 278, 22822, 5253, 338, 9078, 304, 278, 1857, 3625, 17346, 29892, 6467, 13, 4706, 396, 278, 10004, 338, 2599, 263, 1811, 304, 1708, 278, 9608, 322, 437, 263, 3765, 18864, 13, 4706, 25342, 7714, 29889, 14506, 1405, 22965, 9246, 29901, 13, 9651, 10191, 353, 313, 13, 18884, 525, 13919, 22855, 630, 4300, 571, 2643, 29889, 525, 13, 18884, 525, 16542, 5253, 7200, 1135, 278, 3625, 22965, 9246, 29892, 525, 13, 18884, 525, 908, 5253, 29901, 6571, 7472, 22965, 9246, 29901, 6571, 29915, 13, 9651, 13742, 4830, 29898, 13, 18884, 7714, 29889, 14506, 29892, 13, 18884, 22965, 9246, 29892, 13, 9651, 1723, 13, 13, 9651, 1121, 353, 313, 8824, 29892, 10191, 29892, 6213, 29897, 13, 13, 4706, 1683, 29901, 13, 9651, 1121, 353, 313, 5574, 29892, 6213, 29892, 2778, 29895, 1026, 929, 29897, 13, 13, 1678, 736, 1121, 13, 13, 13, 1753, 338, 29918, 3084, 29918, 348, 908, 29898, 348, 908, 29892, 8242, 29918, 3859, 29892, 10004, 29918, 3859, 1125, 13, 1678, 4520, 29918, 5521, 749, 29918, 8017, 353, 443, 908, 29889, 5521, 749, 29918, 8017, 13, 1678, 1857, 29918, 5521, 749, 29918, 8017, 353, 679, 29918, 3784, 29918, 5521, 749, 8017, 29898, 15452, 29918, 3859, 29897, 13, 13, 1678, 7714, 353, 679, 29918, 908, 29898, 15452, 29918, 3859, 29892, 443, 908, 29889, 8568, 908, 29897, 13, 13, 1678, 565, 7714, 338, 451, 6213, 29901, 13, 4706, 716, 29918, 28150, 1026, 929, 353, 10272, 29918, 28150, 1026, 929, 29918, 14037, 29898, 15452, 29918, 3859, 29889, 28150, 1026, 929, 29892, 7714, 29889, 908, 8568, 29897, 13, 4706, 658, 4684, 4632, 29918, 14037, 29918, 908, 353, 2778, 29895, 1358, 3155, 29898, 1482, 29918, 28150, 1026, 929, 29897, 13, 13, 4706, 17117, 17117, 1857, 29918, 3286, 14373, 29918, 14506, 353, 1857, 29918, 5521, 749, 29918, 8017, 13, 4706, 3806, 29918, 5464, 346, 353, 679, 29918, 4622, 29918, 5464, 346, 29898, 15452, 29918, 3859, 29897, 13, 13, 4706, 3806, 29918, 3286, 14373, 29918, 14506, 353, 1857, 29918, 3286, 14373, 29918, 14506, 718, 7714, 29889, 14506, 13, 13, 4706, 338, 29918, 3084, 29892, 12608, 29918, 7645, 353, 338, 29918, 3084, 29918, 4530, 1535, 29898, 13, 9651, 4520, 29918, 5521, 749, 29918, 8017, 29892, 13, 9651, 10004, 29918, 3859, 29889, 7328, 29892, 13, 4706, 1723, 13, 13, 1678, 396, 14402, 29901, 29848, 443, 908, 7191, 565, 278, 2943, 756, 451, 3447, 2665, 263, 10804, 13, 1678, 396, 411, 278, 17346, 5296, 304, 278, 2908, 14153, 29892, 445, 674, 4078, 697, 1246, 304, 13, 1678, 396, 28679, 373, 29899, 14153, 363, 278, 1661, 29899, 11291, 292, 6263, 29889, 13, 1678, 565, 679, 29918, 4882, 29898, 12719, 29918, 3859, 29897, 2804, 5868, 2190, 29940, 6670, 29918, 19713, 29918, 4590, 1430, 3352, 29901, 13, 4706, 10191, 353, 525, 13919, 853, 908, 2643, 363, 426, 1836, 450, 8242, 338, 2307, 5764, 29889, 4286, 4830, 29898, 13, 9651, 15090, 29880, 1598, 29898, 348, 908, 29889, 8568, 908, 467, 13808, 3285, 13, 4706, 1723, 13, 13, 4706, 1121, 353, 313, 8824, 29892, 10191, 29892, 6213, 29897, 13, 13, 1678, 25342, 7714, 338, 6213, 29901, 13, 4706, 10191, 353, 525, 13919, 10213, 2643, 29889, 1670, 338, 694, 1034, 13713, 3689, 7714, 363, 6571, 4286, 4830, 29898, 13, 9651, 15090, 29880, 1598, 29898, 348, 908, 29889, 8568, 908, 467, 13808, 3285, 13, 4706, 1723, 13, 13, 4706, 1121, 353, 313, 8824, 29892, 10191, 29892, 6213, 29897, 13, 13, 1678, 25342, 451, 338, 29918, 3084, 29901, 13, 4706, 396, 450, 12608, 1818, 367, 2854, 29892, 6467, 278, 17346, 5296, 2609, 367, 13, 4706, 396, 1304, 373, 14153, 29889, 13, 4706, 10191, 353, 525, 13919, 10213, 2643, 29889, 6571, 4286, 4830, 29898, 4530, 1535, 29918, 7645, 29897, 13, 13, 4706, 1121, 353, 313, 8824, 29892, 10191, 29892, 6213, 29897, 13, 13, 1678, 25342, 4520, 29918, 5521, 749, 29918, 8017, 29889, 5464, 346, 2804, 3806, 29918, 5464, 346, 29901, 13, 4706, 396, 450, 1661, 778, 1818, 7910, 8617, 9247, 29892, 6467, 727, 338, 263, 13, 4706, 396, 12231, 2133, 1108, 29889, 13, 4706, 10191, 353, 313, 13, 9651, 525, 13919, 10213, 2643, 29889, 525, 13, 9651, 525, 29940, 10646, 1258, 451, 1735, 8617, 9247, 29892, 3806, 29901, 6571, 2355, 29901, 426, 1836, 29915, 13, 4706, 13742, 4830, 29898, 13, 9651, 3806, 29918, 5464, 346, 29892, 13, 9651, 4520, 29918, 5521, 749, 29918, 8017, 29889, 5464, 346, 29892, 13, 4706, 1723, 13, 13, 4706, 1121, 353, 313, 8824, 29892, 10191, 29892, 6213, 29897, 13, 13, 1678, 25342, 4520, 29918, 5521, 749, 29918, 8017, 29889, 908, 29879, 4632, 2804, 658, 4684, 4632, 29918, 14037, 29918, 908, 29901, 13, 4706, 396, 10213, 7191, 3349, 263, 2998, 7714, 29892, 278, 716, 658, 4684, 4632, 1818, 505, 871, 13, 4706, 396, 393, 7714, 6206, 29892, 6467, 278, 10004, 1122, 367, 1811, 304, 3349, 13, 4706, 396, 5684, 658, 4684, 29889, 13, 4706, 10191, 353, 313, 13, 9651, 376, 13919, 10213, 2643, 29889, 376, 13, 9651, 376, 22031, 749, 5296, 29915, 29879, 658, 4684, 4632, 3282, 29915, 29873, 1993, 29892, 3806, 29901, 6571, 2355, 29901, 6571, 1213, 13, 4706, 13742, 4830, 29898, 13, 9651, 15090, 29880, 1598, 29898, 908, 29879, 4632, 29918, 14037, 29918, 908, 467, 13808, 3285, 13, 9651, 15090, 29880, 1598, 29898, 13556, 2347, 29918, 5521, 749, 29918, 8017, 29889, 908, 29879, 4632, 467, 13808, 3285, 13, 4706, 1723, 13, 13, 4706, 1121, 353, 313, 8824, 29892, 10191, 29892, 6213, 29897, 13, 13, 1678, 25342, 4520, 29918, 5521, 749, 29918, 8017, 29889, 3286, 14373, 29918, 14506, 2804, 3806, 29918, 3286, 14373, 29918, 14506, 29901, 13, 4706, 396, 10213, 7191, 1818, 7910, 278, 18440, 29918, 14506, 491, 7714, 5253, 29892, 13, 4706, 396, 6467, 278, 10004, 338, 1811, 304, 1708, 278, 9608, 322, 1886, 284, 5993, 29889, 13, 4706, 10191, 353, 313, 13, 9651, 376, 13919, 10213, 2643, 29889, 376, 13, 9651, 376, 22031, 749, 5296, 29915, 29879, 2743, 18440, 29918, 14506, 29892, 3806, 29901, 6571, 2355, 29901, 6571, 1213, 13, 4706, 13742, 4830, 29898, 13, 9651, 3806, 29918, 3286, 14373, 29918, 14506, 29892, 13, 9651, 4520, 29918, 5521, 749, 29918, 8017, 29889, 3286, 14373, 29918, 14506, 29892, 13, 4706, 1723, 13, 13, 4706, 1121, 353, 313, 8824, 29892, 10191, 29892, 6213, 29897, 13, 13, 1678, 25342, 4520, 29918, 5521, 749, 29918, 8017, 29889, 12719, 29918, 7328, 2804, 8242, 29918, 3859, 29889, 25378, 29901, 13, 4706, 396, 450, 17346, 5296, 1818, 367, 21351, 304, 445, 8242, 29892, 6467, 278, 13, 4706, 396, 373, 29899, 14153, 8078, 723, 367, 480, 778, 303, 1821, 304, 337, 1456, 16661, 4822, 13, 4706, 396, 18196, 29889, 13, 4706, 10191, 353, 313, 13, 9651, 525, 13919, 10213, 2643, 29889, 525, 13, 9651, 525, 22031, 749, 5296, 338, 21351, 304, 278, 2743, 8242, 29892, 3806, 29901, 6571, 2355, 29901, 6571, 29915, 13, 4706, 13742, 4830, 29898, 13, 9651, 8242, 29918, 3859, 29889, 25378, 29892, 13, 9651, 15090, 29880, 1598, 29898, 13556, 2347, 29918, 5521, 749, 29918, 8017, 29889, 12719, 29918, 7328, 467, 13808, 3285, 13, 4706, 1723, 13, 4706, 1121, 353, 313, 8824, 29892, 10191, 29892, 6213, 29897, 13, 13, 1678, 1683, 29901, 13, 4706, 1121, 353, 313, 5574, 29892, 6213, 29892, 716, 29918, 28150, 1026, 929, 29897, 13, 13, 1678, 736, 1121, 13, 13, 13, 1753, 679, 29918, 14506, 29918, 29113, 29898, 355, 29918, 3859, 1125, 13, 1678, 3001, 29918, 29886, 2548, 353, 2533, 29898, 13, 4706, 7714, 29889, 14506, 13, 4706, 363, 7714, 297, 1095, 29918, 3859, 29889, 8568, 908, 29879, 29918, 517, 29918, 29886, 2548, 908, 29879, 29889, 5975, 580, 13, 1678, 1723, 13, 13, 1678, 3001, 29918, 4661, 13190, 353, 2533, 29898, 13, 4706, 443, 908, 29889, 908, 29889, 14506, 13, 4706, 363, 443, 908, 297, 1095, 29918, 3859, 29889, 8568, 908, 29879, 29918, 517, 29918, 4661, 13190, 908, 29879, 29889, 5975, 580, 13, 1678, 1723, 13, 13, 1678, 736, 3001, 29918, 29886, 2548, 718, 3001, 29918, 4661, 13190, 13, 13, 13, 1753, 679, 29918, 5521, 749, 29898, 15452, 29892, 19870, 1125, 13, 1678, 10004, 29918, 3286, 14373, 29918, 14506, 353, 29871, 29900, 13, 1678, 19870, 29918, 3286, 14373, 29918, 14506, 353, 29871, 29900, 13, 13, 1678, 565, 10004, 29889, 5521, 749, 29918, 8017, 29901, 13, 4706, 10004, 29918, 3286, 14373, 29918, 14506, 353, 10004, 29889, 5521, 749, 29918, 8017, 29889, 3286, 14373, 29918, 14506, 13, 13, 1678, 565, 19870, 29889, 5521, 749, 29918, 8017, 29901, 13, 4706, 19870, 29918, 3286, 14373, 29918, 14506, 353, 19870, 29889, 5521, 749, 29918, 8017, 29889, 3286, 14373, 29918, 14506, 13, 13, 1678, 736, 313, 13, 4706, 10004, 29889, 1285, 1461, 29918, 5521, 749, 448, 13, 4706, 10004, 29918, 3286, 14373, 29918, 14506, 718, 13, 4706, 19870, 29918, 3286, 14373, 29918, 14506, 13, 1678, 1723, 13, 13, 13, 1753, 679, 29918, 3784, 29918, 5521, 749, 8017, 29898, 355, 29918, 3859, 1125, 13, 1678, 17346, 29918, 8017, 353, 1095, 29918, 3859, 29889, 5521, 749, 29918, 8017, 13, 13, 1678, 565, 17346, 29918, 8017, 29901, 13, 4706, 658, 4684, 4632, 353, 17346, 29918, 8017, 29889, 908, 29879, 4632, 13, 4706, 1661, 346, 353, 17346, 29918, 8017, 29889, 5464, 346, 13, 4706, 18440, 29918, 14506, 353, 17346, 29918, 8017, 29889, 3286, 14373, 29918, 14506, 13, 1678, 1683, 29901, 13, 4706, 658, 4684, 4632, 353, 382, 3580, 15631, 29918, 29924, 1001, 29968, 1307, 29918, 21289, 13, 4706, 1661, 346, 353, 29871, 29900, 13, 4706, 18440, 29918, 14506, 353, 29871, 29900, 13, 13, 1678, 736, 313, 908, 29879, 4632, 29892, 1661, 346, 29892, 18440, 29918, 14506, 29897, 13, 13, 13, 1753, 679, 29918, 5721, 1091, 9246, 29898, 15452, 29892, 19870, 1125, 13, 1678, 736, 679, 29918, 5521, 749, 29898, 15452, 29892, 19870, 29897, 448, 679, 29918, 14506, 29918, 29113, 29898, 15452, 29897, 13, 13, 13, 1753, 679, 29918, 5203, 29918, 348, 908, 29879, 29898, 355, 29918, 3859, 1125, 13, 1678, 9995, 5631, 403, 443, 908, 292, 29828, 363, 278, 2998, 22183, 1372, 1213, 15945, 13, 13, 1678, 736, 518, 13, 4706, 10272, 29918, 8017, 29918, 1454, 29918, 908, 29898, 13, 9651, 1095, 29918, 3859, 29892, 13, 9651, 7687, 8017, 29889, 19024, 29892, 13, 9651, 7687, 8017, 29889, 908, 29892, 13, 4706, 1723, 13, 4706, 363, 7687, 8017, 297, 1095, 29918, 3859, 29889, 8568, 908, 29879, 29918, 517, 29918, 4661, 13190, 908, 29879, 29889, 5975, 580, 13, 1678, 4514, 13, 13, 13, 1753, 679, 29918, 908, 29898, 13, 4706, 1095, 29918, 3859, 29901, 525, 6779, 1259, 13599, 5044, 2792, 742, 13, 4706, 6608, 908, 29901, 19229, 29889, 9598, 617, 557, 29906, 29945, 29953, 29892, 13, 29897, 1599, 11874, 2481, 16542, 2792, 29901, 13, 1678, 9995, 11609, 278, 7714, 1034, 13713, 3689, 304, 421, 8568, 908, 29952, 470, 6213, 565, 278, 7714, 338, 13, 1678, 9815, 29889, 13, 1678, 9995, 13, 1678, 7714, 353, 1095, 29918, 3859, 29889, 8568, 908, 29879, 29918, 517, 29918, 29886, 2548, 908, 29879, 29889, 657, 29898, 8568, 908, 29897, 13, 13, 1678, 565, 451, 7714, 29901, 13, 4706, 7687, 29918, 348, 908, 353, 1095, 29918, 3859, 29889, 8568, 908, 29879, 29918, 517, 29918, 4661, 13190, 908, 29879, 29889, 657, 29898, 8568, 908, 29897, 13, 13, 4706, 565, 7687, 29918, 348, 908, 29901, 13, 9651, 7714, 353, 7687, 29918, 348, 908, 29889, 908, 13, 13, 1678, 4974, 338, 8758, 29898, 908, 29892, 11874, 2481, 16542, 2792, 29897, 470, 7714, 338, 6213, 13, 1678, 736, 7714, 13, 13, 13, 1753, 679, 29918, 4622, 29918, 5464, 346, 29898, 355, 29918, 3859, 1125, 13, 1678, 565, 1095, 29918, 3859, 29889, 5521, 749, 29918, 8017, 29901, 13, 4706, 736, 1095, 29918, 3859, 29889, 5521, 749, 29918, 8017, 29889, 5464, 346, 718, 29871, 29896, 13, 13, 1678, 396, 29871, 29900, 1818, 451, 367, 1304, 1951, 297, 278, 7787, 1259, 8078, 372, 11524, 1870, 29889, 13, 1678, 736, 29871, 29896, 13, 13, 13, 1753, 679, 29918, 4882, 29898, 12719, 29918, 3859, 1125, 13, 1678, 565, 8242, 29918, 3859, 29889, 9915, 280, 29918, 20736, 29901, 13, 4706, 7743, 29918, 2146, 985, 3730, 353, 313, 13, 9651, 8242, 29918, 3859, 29889, 9915, 280, 29918, 20736, 29889, 2914, 1275, 4103, 2467, 20418, 5709, 29889, 14605, 26925, 13, 4706, 1723, 13, 4706, 2734, 353, 8242, 29918, 3859, 29889, 9915, 280, 29918, 20736, 29889, 4951, 3276, 29918, 1271, 29918, 4537, 338, 6213, 13, 13, 4706, 565, 7743, 29918, 2146, 985, 3730, 29901, 13, 9651, 1121, 353, 5868, 2190, 29940, 6670, 29918, 19713, 29918, 10490, 29911, 20566, 13, 4706, 25342, 2734, 29901, 13, 9651, 1121, 353, 5868, 2190, 29940, 6670, 29918, 19713, 29918, 10490, 14632, 4214, 13, 4706, 1683, 29901, 13, 9651, 1121, 353, 5868, 2190, 29940, 6670, 29918, 19713, 29918, 3904, 3308, 6181, 13, 13, 1678, 25342, 8242, 29918, 3859, 29889, 5358, 29918, 20736, 29901, 13, 4706, 7743, 29918, 2146, 985, 3730, 353, 313, 13, 9651, 8242, 29918, 3859, 29889, 5358, 29918, 20736, 29889, 2914, 1275, 4103, 2467, 20418, 5709, 29889, 14605, 26925, 13, 4706, 1723, 13, 4706, 2734, 353, 8242, 29918, 3859, 29889, 5358, 29918, 20736, 29889, 4951, 3276, 29918, 1271, 29918, 4537, 338, 6213, 13, 13, 4706, 565, 7743, 29918, 2146, 985, 3730, 29901, 13, 9651, 1121, 353, 5868, 2190, 29940, 6670, 29918, 19713, 29918, 29907, 3927, 1660, 29928, 13, 4706, 25342, 2734, 29901, 13, 9651, 1121, 353, 5868, 2190, 29940, 6670, 29918, 19713, 29918, 6154, 3267, 4214, 13, 4706, 1683, 29901, 13, 9651, 1121, 353, 5868, 2190, 29940, 6670, 29918, 19713, 29918, 3904, 3308, 6181, 13, 13, 1678, 1683, 29901, 13, 4706, 1121, 353, 5868, 2190, 29940, 6670, 29918, 19713, 29918, 4590, 1430, 3352, 13, 13, 1678, 736, 1121, 13, 13, 13, 1753, 628, 29918, 908, 29898, 355, 29918, 3859, 29892, 6608, 908, 1125, 13, 1678, 4974, 338, 29918, 5203, 29898, 355, 29918, 3859, 29892, 6608, 908, 29897, 13, 13, 1678, 565, 6608, 908, 297, 1095, 29918, 3859, 29889, 8568, 908, 29879, 29918, 517, 29918, 29886, 2548, 908, 29879, 29901, 13, 4706, 628, 1095, 29918, 3859, 29889, 8568, 908, 29879, 29918, 517, 29918, 29886, 2548, 908, 29879, 29961, 8568, 908, 29962, 13, 13, 1678, 565, 6608, 908, 297, 1095, 29918, 3859, 29889, 8568, 908, 29879, 29918, 517, 29918, 4661, 13190, 908, 29879, 29901, 13, 4706, 628, 1095, 29918, 3859, 29889, 8568, 908, 29879, 29918, 517, 29918, 4661, 13190, 908, 29879, 29961, 8568, 908, 29962, 13, 13, 13, 1753, 731, 29918, 15603, 29898, 12719, 29918, 3859, 29892, 2908, 29918, 4537, 1125, 13, 1678, 565, 451, 8242, 29918, 3859, 29889, 5358, 29918, 20736, 29901, 13, 4706, 8242, 29918, 3859, 29889, 5358, 29918, 20736, 353, 4103, 2467, 20418, 5709, 29898, 13, 9651, 6213, 29892, 13, 9651, 2908, 29918, 4537, 29892, 13, 9651, 4103, 2467, 20418, 5709, 29889, 14605, 26925, 29892, 13, 4706, 1723, 13, 13, 1678, 25342, 451, 8242, 29918, 3859, 29889, 5358, 29918, 20736, 29889, 4951, 3276, 29918, 1271, 29918, 4537, 29901, 13, 4706, 8242, 29918, 3859, 29889, 5358, 29918, 20736, 29889, 4951, 3276, 29918, 1271, 29918, 4537, 353, 2908, 29918, 4537, 13, 4706, 8242, 29918, 3859, 29889, 5358, 29918, 20736, 29889, 2914, 353, 4103, 2467, 20418, 5709, 29889, 14605, 26925, 13, 13, 13, 1753, 731, 29918, 9915, 839, 29898, 12719, 29918, 3859, 29892, 2908, 29918, 4537, 1125, 13, 1678, 565, 451, 8242, 29918, 3859, 29889, 9915, 280, 29918, 20736, 29901, 13, 4706, 8242, 29918, 3859, 29889, 9915, 280, 29918, 20736, 353, 4103, 2467, 20418, 5709, 29898, 13, 9651, 6213, 29892, 13, 9651, 2908, 29918, 4537, 29892, 13, 9651, 4103, 2467, 20418, 5709, 29889, 14605, 26925, 29892, 13, 4706, 1723, 13, 13, 1678, 25342, 451, 8242, 29918, 3859, 29889, 9915, 280, 29918, 20736, 29889, 4951, 3276, 29918, 1271, 29918, 4537, 29901, 13, 4706, 8242, 29918, 3859, 29889, 9915, 280, 29918, 20736, 29889, 4951, 3276, 29918, 1271, 29918, 4537, 353, 2908, 29918, 4537, 13, 4706, 8242, 29918, 3859, 29889, 9915, 280, 29918, 20736, 29889, 2914, 353, 4103, 2467, 20418, 5709, 29889, 14605, 26925, 13, 13, 13, 1753, 2767, 29918, 1285, 1461, 29918, 5521, 749, 29898, 355, 29918, 3859, 29901, 525, 6779, 1259, 13599, 5044, 2792, 742, 8078, 29918, 5521, 749, 1125, 13, 1678, 565, 8078, 29918, 5521, 749, 1405, 1095, 29918, 3859, 29889, 1285, 1461, 29918, 5521, 749, 29901, 13, 4706, 1095, 29918, 3859, 29889, 1285, 1461, 29918, 5521, 749, 353, 8078, 29918, 5521, 749, 13, 13, 13, 1753, 10272, 29918, 8017, 29918, 1454, 29918, 908, 29898, 13, 4706, 1095, 29918, 3859, 29901, 525, 6779, 1259, 13599, 5044, 2792, 742, 13, 4706, 7035, 29901, 19229, 29889, 28459, 29892, 13, 4706, 7714, 29901, 11874, 2481, 16542, 2792, 13, 29897, 1599, 853, 908, 28116, 2792, 29901, 13, 1678, 396, 28172, 6262, 1363, 11314, 406, 398, 29889, 19266, 1838, 29915, 29873, 664, 411, 7023, 2378, 13, 1678, 2778, 29895, 280, 29918, 8017, 353, 10272, 29918, 28150, 280, 8017, 29918, 1454, 29898, 355, 29918, 3859, 29889, 28150, 1026, 929, 29892, 7714, 29889, 908, 8568, 29897, 13, 13, 1678, 736, 853, 908, 28116, 2792, 29898, 13, 4706, 2778, 29895, 280, 29918, 8017, 29892, 13, 4706, 7714, 29889, 26716, 29892, 13, 4706, 7035, 29892, 13, 1678, 1723, 13, 13, 13, 1753, 10272, 29918, 28150, 1026, 929, 29918, 2541, 29898, 13, 4706, 2778, 29895, 1026, 929, 29901, 4702, 29895, 280, 9643, 2792, 29892, 13, 4706, 7714, 8568, 29901, 19229, 29889, 9598, 617, 557, 29906, 29945, 29953, 29892, 13, 29897, 1599, 19229, 29889, 27636, 29961, 29924, 5968, 280, 9643, 2792, 5387, 13, 1678, 9995, 15213, 278, 2183, 7714, 8568, 411, 278, 5923, 2778, 29895, 280, 5447, 1213, 15945, 13, 1678, 396, 4803, 6213, 304, 1871, 278, 24959, 278, 7714, 845, 1161, 338, 2307, 2998, 13, 1678, 1121, 353, 6213, 13, 13, 1678, 11308, 353, 2778, 29895, 1026, 929, 29889, 29277, 29961, 1307, 7520, 2890, 29962, 13, 1678, 565, 7714, 8568, 451, 297, 11308, 29901, 13, 4706, 11308, 353, 1051, 29898, 280, 5989, 29897, 13, 4706, 11308, 29889, 4397, 29898, 908, 8568, 29897, 13, 4706, 1121, 353, 4702, 29895, 280, 9643, 2792, 29898, 26017, 29918, 29277, 29898, 280, 5989, 876, 13, 13, 1678, 736, 1121, 13, 13, 13, 1753, 10272, 29918, 28150, 1026, 929, 29918, 14037, 29898, 28150, 1026, 929, 29892, 7714, 8568, 1125, 13, 1678, 396, 4803, 6213, 304, 1871, 278, 24959, 278, 7714, 845, 1161, 338, 9815, 13, 1678, 1121, 353, 6213, 13, 13, 1678, 11308, 353, 2778, 29895, 1026, 929, 29889, 29277, 29961, 1307, 7520, 2890, 29962, 13, 1678, 565, 7714, 8568, 297, 11308, 29901, 13, 4706, 11308, 353, 1051, 29898, 280, 5989, 29897, 13, 4706, 11308, 29889, 5992, 29898, 908, 8568, 29897, 13, 13, 4706, 565, 11308, 29901, 13, 9651, 1121, 353, 4702, 29895, 280, 9643, 2792, 29898, 26017, 29918, 29277, 29898, 280, 5989, 876, 13, 4706, 1683, 29901, 13, 9651, 1121, 353, 382, 3580, 15631, 29918, 29924, 1001, 29968, 1307, 29918, 29911, 21661, 13, 13, 1678, 736, 1121, 13, 13, 13, 1753, 1653, 29918, 6717, 11851, 3286, 571, 29898, 12719, 29918, 3859, 29892, 5253, 29892, 15882, 1125, 13, 1678, 1749, 29918, 5521, 749, 29918, 8017, 353, 8242, 29918, 3859, 29889, 473, 29918, 3859, 29889, 5521, 749, 29918, 8017, 13, 13, 1678, 565, 1749, 29918, 5521, 749, 29918, 8017, 29901, 13, 4706, 18440, 29918, 14506, 353, 5253, 718, 1749, 29918, 5521, 749, 29918, 8017, 29889, 3286, 14373, 29918, 14506, 13, 4706, 658, 4684, 4632, 353, 1749, 29918, 5521, 749, 29918, 8017, 29889, 908, 29879, 4632, 13, 1678, 1683, 29901, 13, 4706, 18440, 29918, 14506, 353, 5253, 13, 4706, 658, 4684, 4632, 353, 382, 3580, 15631, 29918, 29924, 1001, 29968, 1307, 29918, 21289, 13, 13, 1678, 1661, 346, 353, 679, 29918, 4622, 29918, 5464, 346, 29898, 12719, 29918, 3859, 29889, 473, 29918, 3859, 29897, 13, 1678, 5993, 353, 8242, 29918, 3859, 29889, 6979, 29918, 7328, 13, 1678, 23957, 993, 353, 8242, 29918, 3859, 29889, 1595, 1089, 29918, 3859, 29889, 7328, 13, 13, 1678, 17346, 29918, 8017, 353, 7392, 749, 28116, 25807, 12961, 2792, 29898, 13, 4706, 1661, 346, 29892, 13, 4706, 18440, 29918, 14506, 29892, 13, 4706, 658, 4684, 4632, 29892, 13, 4706, 8242, 29918, 3859, 29889, 25378, 29892, 13, 1678, 1723, 13, 13, 1678, 1513, 29918, 3286, 571, 353, 15076, 17392, 4300, 571, 29898, 13, 4706, 15882, 29892, 13, 4706, 17346, 29918, 8017, 29892, 13, 4706, 5993, 29892, 13, 4706, 23957, 993, 29892, 13, 1678, 1723, 13, 13, 1678, 736, 1513, 29918, 3286, 571, 13, 13, 13, 1753, 1653, 29918, 6717, 4210, 630, 3286, 571, 29898, 13, 4706, 8242, 29918, 3859, 29892, 13, 4706, 14511, 1061, 29892, 13, 4706, 3646, 29892, 13, 4706, 5253, 29892, 13, 4706, 15882, 29892, 13, 4706, 1518, 12232, 29892, 13, 4706, 6608, 908, 1125, 13, 13, 1678, 1749, 29918, 3859, 353, 8242, 29918, 3859, 29889, 473, 29918, 3859, 13, 1678, 18096, 29918, 3859, 353, 8242, 29918, 3859, 29889, 1595, 1089, 29918, 3859, 13, 1678, 1749, 29918, 5521, 749, 29918, 8017, 353, 1749, 29918, 3859, 29889, 5521, 749, 29918, 8017, 13, 13, 1678, 396, 450, 24959, 1818, 1423, 278, 13284, 7536, 304, 278, 1246, 13, 1678, 10191, 353, 525, 4804, 261, 1818, 1207, 1854, 727, 338, 3307, 17346, 29915, 13, 1678, 4974, 5253, 5277, 679, 29918, 5721, 1091, 9246, 29898, 473, 29918, 3859, 29892, 18096, 29918, 3859, 511, 10191, 13, 13, 1678, 7714, 353, 11874, 2481, 16542, 2792, 29898, 13, 4706, 5253, 29892, 13, 4706, 1518, 12232, 29892, 13, 4706, 6608, 908, 29892, 13, 1678, 1723, 13, 13, 1678, 2778, 29895, 1026, 929, 353, 10272, 29918, 28150, 1026, 929, 29918, 2541, 29898, 13, 4706, 8242, 29918, 3859, 29889, 473, 29918, 3859, 29889, 28150, 1026, 929, 29892, 13, 4706, 7714, 29889, 908, 8568, 29892, 13, 1678, 1723, 13, 1678, 396, 450, 24959, 1818, 9801, 278, 1021, 7714, 338, 451, 1641, 1304, 8951, 13, 1678, 4974, 2778, 29895, 1026, 929, 29892, 525, 908, 338, 2307, 15443, 29915, 13, 13, 1678, 658, 4684, 4632, 353, 2778, 29895, 1358, 3155, 29898, 28150, 1026, 929, 29897, 13, 13, 1678, 565, 1749, 29918, 5521, 749, 29918, 8017, 29901, 13, 4706, 18440, 29918, 14506, 353, 1749, 29918, 5521, 749, 29918, 8017, 29889, 3286, 14373, 29918, 14506, 13, 1678, 1683, 29901, 13, 4706, 18440, 29918, 14506, 353, 29871, 29900, 13, 13, 1678, 5993, 353, 8242, 29918, 3859, 29889, 6979, 29918, 7328, 13, 1678, 1661, 346, 353, 679, 29918, 4622, 29918, 5464, 346, 29898, 12719, 29918, 3859, 29889, 473, 29918, 3859, 29897, 13, 1678, 23957, 993, 353, 8242, 29918, 3859, 29889, 1595, 1089, 29918, 3859, 29889, 7328, 13, 13, 1678, 17346, 29918, 8017, 353, 7392, 749, 28116, 25807, 12961, 2792, 29898, 13, 4706, 1661, 346, 29892, 13, 4706, 18440, 29918, 14506, 29892, 13, 4706, 658, 4684, 4632, 29892, 13, 4706, 8242, 29918, 3859, 29889, 25378, 29892, 13, 1678, 1723, 13, 13, 1678, 22822, 29918, 3286, 571, 353, 18199, 287, 4300, 571, 25807, 12961, 2792, 29898, 13, 4706, 15882, 29892, 13, 4706, 5993, 29892, 13, 4706, 17346, 29918, 8017, 29892, 13, 4706, 7714, 29892, 13, 4706, 14511, 1061, 29892, 13, 4706, 3646, 29892, 13, 1678, 1723, 13, 13, 1678, 14457, 630, 3286, 571, 353, 15076, 29924, 15844, 630, 4300, 571, 29898, 13, 4706, 22822, 29918, 3286, 571, 29892, 13, 4706, 23957, 993, 29892, 13, 1678, 1723, 13, 13, 1678, 736, 14457, 630, 3286, 571, 29892, 2778, 29895, 1026, 929, 13, 13, 13, 1753, 1653, 29918, 348, 908, 29898, 12719, 29918, 3859, 29892, 15882, 29892, 7035, 29892, 7714, 1125, 13, 1678, 10191, 353, 525, 4804, 261, 1818, 1207, 1854, 278, 7714, 338, 2998, 29915, 13, 1678, 4974, 338, 29918, 5203, 29898, 12719, 29918, 3859, 29889, 473, 29918, 3859, 29892, 7714, 29889, 8568, 908, 511, 10191, 13, 13, 1678, 1749, 29918, 5521, 749, 29918, 8017, 353, 8242, 29918, 3859, 29889, 473, 29918, 3859, 29889, 5521, 749, 29918, 8017, 13, 1678, 565, 1749, 29918, 5521, 749, 29918, 8017, 29901, 13, 4706, 18440, 29918, 14506, 353, 7714, 29889, 14506, 718, 1749, 29918, 5521, 749, 29918, 8017, 29889, 3286, 14373, 29918, 14506, 13, 1678, 1683, 29901, 13, 4706, 18440, 29918, 14506, 353, 7714, 29889, 14506, 13, 13, 1678, 2778, 29895, 1026, 929, 353, 10272, 29918, 28150, 1026, 929, 29918, 14037, 29898, 13, 4706, 8242, 29918, 3859, 29889, 473, 29918, 3859, 29889, 28150, 1026, 929, 29892, 13, 4706, 7714, 29889, 908, 8568, 29892, 13, 1678, 1723, 13, 1678, 658, 4684, 4632, 353, 2778, 29895, 1358, 3155, 29898, 28150, 1026, 929, 29897, 13, 13, 1678, 5993, 353, 8242, 29918, 3859, 29889, 6979, 29918, 7328, 13, 1678, 1661, 346, 353, 679, 29918, 4622, 29918, 5464, 346, 29898, 12719, 29918, 3859, 29889, 473, 29918, 3859, 29897, 13, 1678, 23957, 993, 353, 8242, 29918, 3859, 29889, 1595, 1089, 29918, 3859, 29889, 7328, 13, 13, 1678, 17346, 29918, 8017, 353, 7392, 749, 28116, 25807, 12961, 2792, 29898, 13, 4706, 1661, 346, 29892, 13, 4706, 18440, 29918, 14506, 29892, 13, 4706, 658, 4684, 4632, 29892, 13, 4706, 8242, 29918, 3859, 29889, 25378, 29892, 13, 1678, 1723, 13, 13, 1678, 443, 908, 29918, 908, 353, 15076, 22031, 749, 28116, 29898, 13, 4706, 15882, 29892, 13, 4706, 5993, 29892, 13, 4706, 23957, 993, 29892, 13, 4706, 7035, 29892, 13, 4706, 17346, 29918, 8017, 29892, 13, 1678, 1723, 13, 13, 1678, 736, 443, 908, 29918, 908, 29892, 2778, 29895, 1026, 929, 13, 13, 13, 1753, 3638, 29918, 11851, 3286, 571, 29898, 12719, 29918, 3859, 29892, 5253, 29892, 15882, 1125, 13, 1678, 1513, 29918, 3286, 571, 353, 1653, 29918, 6717, 11851, 3286, 571, 29898, 13, 4706, 8242, 29918, 3859, 29892, 13, 4706, 5253, 29892, 13, 4706, 15882, 29892, 13, 1678, 1723, 13, 13, 1678, 8242, 29918, 3859, 29889, 473, 29918, 3859, 29889, 5521, 749, 29918, 8017, 353, 1513, 29918, 3286, 571, 29889, 5521, 749, 29918, 8017, 13, 13, 1678, 736, 1513, 29918, 3286, 571, 13, 13, 13, 1753, 3638, 29918, 4210, 630, 3286, 571, 29898, 13, 4706, 8242, 29918, 3859, 29892, 13, 4706, 14511, 1061, 29892, 13, 4706, 3646, 29892, 13, 4706, 5253, 29892, 13, 4706, 15882, 29892, 13, 4706, 1518, 12232, 29892, 13, 4706, 6608, 908, 1125, 13, 13, 1678, 3638, 29918, 3696, 29892, 2778, 29895, 1026, 929, 353, 1653, 29918, 6717, 4210, 630, 3286, 571, 29898, 13, 4706, 8242, 29918, 3859, 29892, 13, 4706, 14511, 1061, 29892, 13, 4706, 3646, 29892, 13, 4706, 5253, 29892, 13, 4706, 15882, 29892, 13, 4706, 1518, 12232, 29892, 13, 4706, 6608, 908, 29892, 13, 1678, 1723, 13, 13, 1678, 6782, 353, 3638, 29918, 3696, 29889, 3286, 571, 13, 1678, 7714, 353, 6782, 29889, 908, 13, 1678, 8242, 29918, 3859, 29889, 473, 29918, 3859, 29889, 5521, 749, 29918, 8017, 353, 6782, 29889, 5521, 749, 29918, 8017, 13, 1678, 8242, 29918, 3859, 29889, 473, 29918, 3859, 29889, 28150, 1026, 929, 353, 2778, 29895, 1026, 929, 13, 1678, 8242, 29918, 3859, 29889, 473, 29918, 3859, 29889, 8568, 908, 29879, 29918, 517, 29918, 29886, 2548, 908, 29879, 29961, 908, 29889, 8568, 908, 29962, 353, 7714, 13, 13, 1678, 736, 3638, 29918, 3696, 13, 13, 13, 1753, 3638, 29918, 999, 870, 3286, 571, 29898, 13, 4706, 8242, 29918, 3859, 29892, 13, 4706, 14511, 1061, 29892, 13, 4706, 3646, 29892, 13, 4706, 5253, 29892, 13, 4706, 15882, 29892, 13, 4706, 1518, 12232, 29892, 13, 4706, 6608, 908, 1125, 13, 13, 1678, 10191, 353, 525, 5620, 870, 29879, 526, 871, 2854, 363, 334, 28385, 322, 28235, 29930, 1301, 25534, 29915, 13, 1678, 4974, 6608, 908, 297, 8242, 29918, 3859, 29889, 1595, 1089, 29918, 3859, 29889, 8568, 908, 29879, 29918, 517, 29918, 29886, 2548, 908, 29879, 29892, 10191, 13, 13, 1678, 3638, 29918, 4210, 630, 29918, 3286, 571, 29892, 2778, 29895, 1026, 929, 353, 1653, 29918, 6717, 4210, 630, 3286, 571, 29898, 13, 4706, 8242, 29918, 3859, 29892, 13, 4706, 14511, 1061, 29892, 13, 4706, 3646, 29892, 13, 4706, 5253, 29892, 13, 4706, 15882, 29892, 13, 4706, 1518, 12232, 29892, 13, 4706, 6608, 908, 29892, 13, 1678, 1723, 13, 13, 1678, 14457, 630, 29918, 3286, 571, 353, 3638, 29918, 4210, 630, 29918, 3286, 571, 29889, 3286, 571, 13, 1678, 7714, 353, 14457, 630, 29918, 3286, 571, 29889, 908, 13, 13, 1678, 8242, 29918, 3859, 29889, 473, 29918, 3859, 29889, 5521, 749, 29918, 8017, 353, 14457, 630, 29918, 3286, 571, 29889, 5521, 749, 29918, 8017, 13, 1678, 8242, 29918, 3859, 29889, 473, 29918, 3859, 29889, 28150, 1026, 929, 353, 2778, 29895, 1026, 929, 13, 1678, 8242, 29918, 3859, 29889, 473, 29918, 3859, 29889, 8568, 908, 29879, 29918, 517, 29918, 29886, 2548, 908, 29879, 29961, 908, 29889, 8568, 908, 29962, 353, 7714, 13, 13, 1678, 2143, 870, 29918, 3286, 571, 353, 2143, 870, 29918, 3166, 29918, 6717, 4210, 630, 29898, 6717, 29918, 4210, 630, 29918, 3286, 571, 29897, 13, 1678, 736, 2143, 870, 29918, 3286, 571, 13, 13, 13, 1753, 3638, 29918, 348, 908, 29898, 12719, 29918, 3859, 29892, 15882, 29892, 7035, 29892, 6608, 908, 1125, 13, 1678, 7714, 353, 679, 29918, 908, 29898, 12719, 29918, 3859, 29889, 473, 29918, 3859, 29892, 6608, 908, 29897, 13, 1678, 4974, 7714, 13, 13, 1678, 443, 908, 29918, 908, 29892, 2778, 29895, 1026, 929, 353, 1653, 29918, 348, 908, 29898, 13, 4706, 8242, 29918, 3859, 29892, 13, 4706, 15882, 29892, 13, 4706, 7035, 29892, 13, 4706, 7714, 29892, 13, 1678, 1723, 13, 13, 1678, 8242, 29918, 3859, 29889, 473, 29918, 3859, 29889, 5521, 749, 29918, 8017, 353, 443, 908, 29918, 908, 29889, 5521, 749, 29918, 8017, 13, 1678, 8242, 29918, 3859, 29889, 473, 29918, 3859, 29889, 28150, 1026, 929, 353, 2778, 29895, 1026, 929, 13, 13, 1678, 628, 29918, 908, 29898, 12719, 29918, 3859, 29889, 473, 29918, 3859, 29892, 7714, 29889, 8568, 908, 29897, 13, 13, 1678, 736, 443, 908, 29918, 908, 13, 13, 13, 1753, 4959, 29918, 1454, 29918, 5358, 29898, 12719, 29918, 3859, 29892, 2908, 29918, 4537, 1125, 13, 1678, 4959, 353, 1051, 580, 13, 13, 1678, 565, 679, 29918, 4882, 29898, 12719, 29918, 3859, 29897, 297, 5868, 2190, 29940, 6670, 29918, 17816, 2890, 29918, 29829, 1955, 29918, 4986, 29918, 29907, 3927, 1660, 29928, 29901, 13, 4706, 8242, 29918, 3859, 29889, 5358, 29918, 20736, 353, 4103, 2467, 20418, 5709, 29898, 13, 9651, 2908, 29918, 4537, 29892, 13, 9651, 6213, 29892, 13, 9651, 6213, 13, 4706, 1723, 13, 13, 4706, 3802, 29918, 3696, 353, 2866, 1461, 12600, 13599, 11123, 29898, 13, 9651, 8242, 29918, 3859, 29889, 25378, 29892, 13, 9651, 8242, 29918, 3859, 29889, 6979, 29918, 7328, 29892, 13, 9651, 8242, 29918, 3859, 29889, 1595, 1089, 29918, 3859, 29889, 5521, 749, 29918, 8017, 29892, 13, 4706, 1723, 13, 13, 4706, 4959, 29889, 4397, 29898, 5358, 29918, 3696, 29897, 13, 13, 1678, 736, 4959, 13, 13, 13, 1753, 6036, 29918, 19024, 29918, 355, 3859, 29898, 355, 29918, 3859, 29892, 7035, 29892, 6608, 908, 1125, 13, 1678, 565, 338, 29918, 29113, 29898, 355, 29918, 3859, 29892, 6608, 908, 1125, 13, 4706, 28235, 908, 353, 1095, 29918, 3859, 29889, 8568, 908, 29879, 29918, 517, 29918, 29886, 2548, 908, 29879, 29961, 8568, 908, 29962, 13, 4706, 628, 1095, 29918, 3859, 29889, 8568, 908, 29879, 29918, 517, 29918, 29886, 2548, 908, 29879, 29961, 8568, 908, 29962, 13, 13, 4706, 1095, 29918, 3859, 29889, 8568, 908, 29879, 29918, 517, 29918, 4661, 13190, 908, 29879, 29961, 8568, 908, 29962, 353, 853, 908, 7439, 616, 28116, 2792, 29898, 13, 9651, 28235, 908, 29892, 13, 9651, 7035, 29892, 13, 4706, 1723, 13, 13, 13, 1753, 6036, 29918, 19024, 29898, 12719, 29918, 3859, 29892, 7035, 29892, 6608, 908, 1125, 13, 1678, 9995, 4013, 674, 6036, 278, 7035, 322, 731, 278, 7714, 304, 278, 443, 29113, 8703, 29889, 13, 13, 1678, 7753, 2466, 278, 7714, 338, 443, 908, 372, 29915, 29879, 338, 334, 1333, 29930, 17049, 29889, 450, 13284, 674, 13, 1678, 7910, 2748, 278, 2446, 17346, 5296, 338, 4520, 29889, 13, 1678, 9995, 13, 1678, 1749, 29918, 3859, 353, 8242, 29918, 3859, 29889, 473, 29918, 3859, 13, 1678, 18096, 29918, 3859, 353, 8242, 29918, 3859, 29889, 1595, 1089, 29918, 3859, 13, 13, 1678, 6036, 29918, 19024, 29918, 355, 3859, 29898, 473, 29918, 3859, 29892, 7035, 29892, 6608, 908, 29897, 13, 1678, 6036, 29918, 19024, 29918, 355, 3859, 29898, 1595, 1089, 29918, 3859, 29892, 7035, 29892, 6608, 908, 29897, 13, 13, 13, 1753, 4386, 29918, 6717, 29918, 11851, 3286, 571, 29898, 12719, 29918, 3859, 29892, 2106, 29918, 3167, 1125, 13, 1678, 4959, 353, 1051, 580, 13, 13, 1678, 5253, 353, 2106, 29918, 3167, 29889, 14506, 13, 1678, 15882, 353, 2106, 29918, 3167, 29889, 25378, 13, 1678, 22965, 9246, 29918, 14506, 353, 679, 29918, 5721, 1091, 9246, 29898, 12719, 29918, 3859, 29889, 473, 29918, 3859, 29892, 8242, 29918, 3859, 29889, 1595, 1089, 29918, 3859, 29897, 13, 13, 1678, 338, 29918, 3150, 353, 679, 29918, 4882, 29898, 12719, 29918, 3859, 29897, 1275, 5868, 2190, 29940, 6670, 29918, 19713, 29918, 4590, 1430, 3352, 13, 1678, 338, 29918, 3084, 353, 5253, 1405, 29871, 29900, 13, 1678, 508, 29918, 10472, 353, 5253, 5277, 22965, 9246, 29918, 14506, 13, 13, 1678, 565, 338, 29918, 3150, 322, 338, 29918, 3084, 322, 508, 29918, 10472, 29901, 13, 4706, 1513, 29918, 3286, 571, 353, 3638, 29918, 11851, 3286, 571, 29898, 13, 9651, 8242, 29918, 3859, 29892, 13, 9651, 5253, 29892, 13, 9651, 15882, 29892, 13, 4706, 1723, 13, 4706, 4959, 29889, 4397, 29898, 11851, 29918, 3286, 571, 29897, 13, 1678, 1683, 29901, 13, 4706, 565, 451, 338, 29918, 3150, 29901, 13, 9651, 10672, 353, 6864, 4300, 571, 29903, 296, 17776, 29898, 13, 18884, 2106, 29918, 3167, 29889, 25378, 29892, 13, 18884, 525, 13599, 338, 451, 6496, 742, 13, 9651, 1723, 13, 9651, 4959, 29889, 4397, 29898, 14057, 545, 29897, 13, 13, 4706, 25342, 451, 338, 29918, 3084, 29901, 13, 9651, 10191, 353, 525, 4300, 571, 5253, 338, 8340, 29889, 17934, 29901, 6571, 4286, 4830, 29898, 14506, 29897, 13, 13, 9651, 10672, 353, 6864, 4300, 571, 29903, 296, 17776, 29898, 3859, 29918, 3167, 29889, 25378, 29892, 10191, 29897, 13, 9651, 4959, 29889, 4397, 29898, 14057, 545, 29897, 13, 13, 4706, 25342, 451, 508, 29918, 10472, 29901, 13, 9651, 10191, 353, 313, 13, 18884, 525, 4300, 571, 5253, 13461, 29879, 278, 3625, 13284, 29889, 525, 13, 18884, 525, 12415, 5946, 29901, 24335, 17934, 29901, 6571, 29915, 13, 9651, 13742, 4830, 29898, 13, 18884, 22965, 9246, 29918, 14506, 29892, 13, 18884, 5253, 29892, 13, 9651, 1723, 13, 13, 9651, 10672, 353, 6864, 4300, 571, 29903, 296, 17776, 29898, 3859, 29918, 3167, 29889, 25378, 29892, 10191, 29897, 13, 9651, 4959, 29889, 4397, 29898, 14057, 545, 29897, 13, 13, 1678, 736, 4103, 654, 3591, 29898, 12719, 29918, 3859, 29892, 4959, 29897, 13, 13, 13, 1753, 4386, 29918, 2467, 29918, 5358, 29898, 12719, 29918, 3859, 29892, 3802, 29892, 2908, 29918, 4537, 1125, 13, 1678, 10191, 353, 525, 4804, 261, 1818, 1207, 1854, 278, 18999, 1993, 29915, 13, 1678, 4974, 8242, 29918, 3859, 29889, 25378, 1275, 3802, 29889, 12719, 29918, 25378, 29892, 10191, 13, 13, 1678, 4959, 353, 4959, 29918, 1454, 29918, 5358, 29898, 12719, 29918, 3859, 29892, 2908, 29918, 4537, 29897, 13, 1678, 736, 4103, 654, 3591, 29898, 12719, 29918, 3859, 29892, 4959, 29897, 13, 13, 13, 1753, 4386, 29918, 13556, 573, 29918, 11851, 3286, 571, 29898, 12719, 29918, 3859, 29892, 1513, 29918, 3286, 571, 1125, 13, 1678, 338, 29918, 3084, 29892, 10191, 353, 338, 29918, 3084, 29918, 11851, 3286, 571, 29898, 13, 4706, 1513, 29918, 3286, 571, 29892, 13, 4706, 8242, 29918, 3859, 29892, 13, 4706, 8242, 29918, 3859, 29889, 1595, 1089, 29918, 3859, 29892, 13, 4706, 8242, 29918, 3859, 29889, 473, 29918, 3859, 29892, 13, 1678, 1723, 13, 13, 1678, 565, 338, 29918, 3084, 29901, 13, 4706, 17117, 17117, 3517, 29918, 3286, 14373, 29918, 14506, 353, 679, 29918, 3784, 29918, 5521, 749, 8017, 29898, 12719, 29918, 3859, 29889, 1595, 1089, 29918, 3859, 29897, 13, 4706, 716, 29918, 3286, 14373, 29918, 14506, 353, 1513, 29918, 3286, 571, 29889, 5521, 749, 29918, 8017, 29889, 3286, 14373, 29918, 14506, 13, 4706, 6782, 29918, 14506, 353, 716, 29918, 3286, 14373, 29918, 14506, 448, 3517, 29918, 3286, 14373, 29918, 14506, 13, 13, 4706, 8242, 29918, 3859, 29889, 1595, 1089, 29918, 3859, 29889, 5521, 749, 29918, 8017, 353, 1513, 29918, 3286, 571, 29889, 5521, 749, 29918, 8017, 13, 4706, 1741, 353, 6864, 4300, 571, 29816, 14191, 29898, 13, 9651, 1513, 29918, 3286, 571, 29889, 3286, 571, 29918, 25378, 29892, 13, 9651, 6782, 29918, 14506, 29892, 13, 9651, 8242, 29918, 3859, 29889, 1595, 1089, 29918, 3859, 29889, 7328, 29892, 13, 4706, 1723, 13, 4706, 4959, 353, 518, 3696, 29962, 13, 1678, 1683, 29901, 13, 4706, 1741, 353, 6864, 4300, 571, 29816, 13919, 17392, 4300, 571, 29898, 13, 9651, 1513, 29918, 3286, 571, 29889, 3286, 571, 29918, 25378, 29892, 13, 9651, 2769, 29922, 7645, 29892, 13, 4706, 1723, 13, 4706, 4959, 353, 518, 3696, 29962, 13, 13, 1678, 736, 4103, 654, 3591, 29898, 12719, 29918, 3859, 29892, 4959, 29897, 13, 13, 13, 1753, 4386, 29918, 13556, 573, 29918, 4210, 630, 3286, 571, 29898, 13, 4706, 8242, 29918, 3859, 29901, 525, 6779, 1259, 13599, 2792, 742, 13, 4706, 14457, 630, 29918, 3286, 571, 29901, 525, 16542, 287, 4300, 571, 10140, 287, 2792, 29915, 13, 1125, 13, 1678, 9995, 15213, 278, 9281, 2998, 6782, 29889, 13, 13, 1678, 450, 19870, 4225, 304, 671, 445, 1158, 304, 2767, 278, 5639, 411, 263, 13, 1678, 903, 3084, 29918, 6782, 29892, 6467, 278, 658, 4684, 4632, 674, 451, 1712, 278, 28235, 13, 1678, 6782, 29889, 450, 19870, 4225, 304, 9801, 393, 278, 2778, 29895, 280, 3876, 756, 278, 13, 1678, 6608, 908, 5134, 29892, 6467, 372, 2113, 29915, 29873, 367, 2221, 304, 5995, 372, 29889, 13, 1678, 9995, 13, 1678, 338, 29918, 3084, 29892, 10191, 29892, 2778, 29895, 1026, 929, 353, 338, 29918, 3084, 29918, 4210, 630, 3286, 571, 29898, 13, 4706, 14457, 630, 29918, 3286, 571, 29892, 13, 4706, 8242, 29918, 3859, 29892, 13, 4706, 8242, 29918, 3859, 29889, 1595, 1089, 29918, 3859, 29892, 13, 4706, 8242, 29918, 3859, 29889, 473, 29918, 3859, 29892, 13, 1678, 1723, 13, 13, 1678, 565, 338, 29918, 3084, 29901, 13, 4706, 8242, 29918, 3859, 29889, 1595, 1089, 29918, 3859, 29889, 5521, 749, 29918, 8017, 353, 14457, 630, 29918, 3286, 571, 29889, 5521, 749, 29918, 8017, 13, 4706, 8242, 29918, 3859, 29889, 1595, 1089, 29918, 3859, 29889, 28150, 1026, 929, 353, 2778, 29895, 1026, 929, 13, 13, 4706, 7714, 353, 14457, 630, 29918, 3286, 571, 29889, 908, 13, 4706, 8242, 29918, 3859, 29889, 1595, 1089, 29918, 3859, 29889, 8568, 908, 29879, 29918, 517, 29918, 29886, 2548, 908, 29879, 29961, 908, 29889, 8568, 908, 29962, 353, 7714, 13, 13, 1678, 736, 338, 29918, 3084, 29892, 10191, 13, 13, 13, 1753, 4386, 29918, 13556, 573, 29918, 999, 870, 3286, 571, 29898, 12719, 29918, 3859, 29892, 2143, 870, 29918, 3286, 571, 1125, 13, 1678, 736, 4386, 29918, 13556, 573, 29918, 4210, 630, 3286, 571, 29898, 12719, 29918, 3859, 29892, 2143, 870, 29918, 3286, 571, 29897, 13, 13, 13, 1753, 4386, 29918, 13556, 573, 29918, 344, 1037, 2484, 345, 284, 29898, 12719, 29918, 3859, 29892, 2106, 29918, 3167, 1125, 13, 1678, 7035, 353, 2106, 29918, 3167, 29889, 19024, 13, 1678, 6608, 908, 353, 2106, 29918, 3167, 29889, 8568, 908, 13, 13, 1678, 6036, 29918, 19024, 29898, 12719, 29918, 3859, 29892, 7035, 29892, 6608, 908, 29897, 13, 13, 13, 1753, 4386, 29918, 348, 908, 29898, 12719, 29918, 3859, 29892, 443, 908, 1125, 13, 1678, 338, 29918, 3084, 29892, 10191, 29892, 443, 29113, 29918, 28150, 1026, 929, 353, 338, 29918, 3084, 29918, 348, 908, 29898, 13, 4706, 443, 908, 29892, 13, 4706, 8242, 29918, 3859, 29892, 13, 4706, 8242, 29918, 3859, 29889, 1595, 1089, 29918, 3859, 29892, 13, 1678, 1723, 13, 13, 1678, 565, 338, 29918, 3084, 29901, 13, 4706, 8242, 29918, 3859, 29889, 1595, 1089, 29918, 3859, 29889, 5521, 749, 29918, 8017, 353, 443, 908, 29889, 5521, 749, 29918, 8017, 13, 4706, 8242, 29918, 3859, 29889, 1595, 1089, 29918, 3859, 29889, 28150, 1026, 929, 353, 443, 29113, 29918, 28150, 1026, 929, 13, 13, 4706, 628, 29918, 908, 29898, 12719, 29918, 3859, 29889, 1595, 1089, 29918, 3859, 29892, 443, 908, 29889, 8568, 908, 29897, 13, 13, 1678, 736, 338, 29918, 3084, 29892, 10191, 13, 13, 13, 1753, 4386, 29918, 1271, 29898, 12719, 29918, 3859, 29892, 2106, 29918, 3167, 29892, 2908, 29918, 4537, 1125, 13, 1678, 4974, 2106, 29918, 3167, 29889, 1271, 29918, 4537, 1275, 2908, 29918, 4537, 13, 13, 1678, 4959, 353, 1051, 580, 13, 13, 1678, 565, 679, 29918, 4882, 29898, 12719, 29918, 3859, 29897, 1275, 5868, 2190, 29940, 6670, 29918, 19713, 29918, 29907, 3927, 1660, 29928, 29901, 13, 4706, 5764, 29918, 1271, 29918, 4537, 353, 8242, 29918, 3859, 29889, 5358, 29918, 20736, 29889, 4951, 3276, 29918, 1271, 29918, 4537, 13, 4706, 16493, 29918, 355, 353, 5764, 29918, 1271, 29918, 4537, 718, 8242, 29918, 3859, 29889, 9915, 280, 29918, 15619, 13, 13, 4706, 565, 2106, 29918, 3167, 29889, 1271, 29918, 4537, 1405, 16493, 29918, 355, 29901, 13, 9651, 8242, 29918, 3859, 29889, 9915, 280, 29918, 20736, 353, 4103, 2467, 20418, 5709, 29898, 13, 18884, 2106, 29918, 3167, 29889, 1271, 29918, 4537, 29892, 13, 18884, 6213, 29892, 13, 18884, 6213, 13, 9651, 1723, 13, 9651, 1741, 353, 2866, 1461, 12600, 13599, 29903, 1803, 280, 29898, 12719, 29918, 3859, 29889, 25378, 29897, 13, 9651, 4959, 29889, 4397, 29898, 3696, 29897, 13, 13, 1678, 1550, 338, 29918, 311, 1066, 277, 29918, 5527, 381, 2168, 29898, 12719, 29918, 3859, 29892, 2908, 29918, 4537, 1125, 13, 4706, 1797, 29918, 311, 1066, 277, 29918, 20736, 353, 16947, 29939, 29889, 354, 932, 459, 29898, 12719, 29918, 3859, 29889, 311, 1066, 277, 29918, 20736, 29918, 9990, 29897, 13, 4706, 3394, 29918, 12719, 29918, 1482, 5521, 749, 29898, 13, 9651, 8242, 29918, 3859, 29892, 13, 9651, 1797, 29918, 311, 1066, 277, 29918, 20736, 29889, 20736, 29892, 13, 4706, 1723, 13, 13, 1678, 736, 4103, 654, 3591, 29898, 12719, 29918, 3859, 29892, 4959, 29897, 13, 13, 13, 1753, 4386, 29918, 12719, 29918, 15603, 29898, 12719, 29918, 3859, 29892, 2106, 29918, 3167, 1125, 13, 1678, 4959, 353, 1051, 580, 13, 13, 1678, 925, 29918, 15603, 353, 313, 13, 4706, 2106, 29918, 3167, 29889, 12719, 29918, 25378, 1275, 8242, 29918, 3859, 29889, 25378, 322, 13, 4706, 679, 29918, 4882, 29898, 12719, 29918, 3859, 29897, 297, 5868, 2190, 29940, 6670, 29918, 17816, 2890, 29918, 29829, 1955, 29918, 4986, 29918, 29907, 3927, 1660, 29928, 13, 1678, 1723, 13, 13, 1678, 565, 925, 29918, 15603, 29901, 13, 4706, 731, 29918, 15603, 29898, 12719, 29918, 3859, 29892, 2106, 29918, 3167, 29889, 15603, 29918, 1271, 29918, 4537, 29897, 13, 13, 4706, 17346, 29918, 8017, 353, 8242, 29918, 3859, 29889, 1595, 1089, 29918, 3859, 29889, 5521, 749, 29918, 8017, 13, 4706, 1246, 29918, 5504, 353, 313, 13, 9651, 2106, 29918, 3167, 29889, 11291, 292, 29918, 7328, 2804, 8242, 29918, 3859, 29889, 473, 29918, 3859, 29889, 7328, 322, 13, 9651, 17346, 29918, 8017, 13, 4706, 1723, 13, 4706, 565, 1246, 29918, 5504, 29901, 13, 9651, 396, 450, 8242, 471, 5764, 491, 1749, 18096, 29892, 565, 727, 338, 263, 17346, 13, 9651, 396, 5296, 3625, 2767, 445, 2943, 4203, 310, 278, 2106, 13, 9651, 2767, 353, 2866, 1461, 12600, 13599, 6422, 4300, 571, 29898, 13, 18884, 8242, 29918, 3859, 29889, 25378, 29892, 13, 18884, 17346, 29918, 8017, 29892, 13, 9651, 1723, 13, 9651, 4959, 29889, 4397, 29898, 5504, 29897, 13, 13, 4706, 443, 908, 29918, 8017, 29879, 353, 679, 29918, 5203, 29918, 348, 908, 29879, 29898, 12719, 29918, 3859, 29889, 1595, 1089, 29918, 3859, 29897, 13, 4706, 565, 443, 908, 29918, 8017, 29879, 29901, 13, 9651, 28679, 353, 2866, 1461, 12600, 13599, 3047, 4012, 29898, 13, 18884, 8242, 29918, 3859, 29889, 25378, 29892, 13, 18884, 443, 908, 29918, 8017, 29879, 29892, 13, 9651, 1723, 13, 9651, 4959, 29889, 4397, 29898, 2541, 4012, 29897, 13, 13, 1678, 736, 4103, 654, 3591, 29898, 12719, 29918, 3859, 29892, 4959, 29897, 13, 13, 13, 1753, 4386, 29918, 12719, 29918, 9915, 839, 29898, 12719, 29918, 3859, 29892, 2106, 29918, 3167, 1125, 13, 1678, 4959, 353, 1051, 580, 13, 13, 1678, 565, 2106, 29918, 3167, 29889, 12719, 29918, 25378, 1275, 8242, 29918, 3859, 29889, 25378, 29901, 13, 4706, 731, 29918, 9915, 839, 29898, 12719, 29918, 3859, 29892, 2106, 29918, 3167, 29889, 9915, 280, 29918, 1271, 29918, 4537, 29897, 13, 13, 1678, 736, 4103, 654, 3591, 29898, 12719, 29918, 3859, 29892, 4959, 29897, 13, 13, 13, 1753, 4386, 29918, 12719, 29918, 1482, 5521, 749, 29898, 12719, 29918, 3859, 29892, 2106, 29918, 3167, 29892, 2908, 29918, 4537, 1125, 13, 1678, 19754, 277, 29918, 20736, 353, 2106, 29918, 3167, 29889, 311, 1066, 277, 29918, 20736, 13, 13, 1678, 565, 338, 29918, 20736, 29918, 5527, 381, 2168, 29898, 311, 1066, 277, 29918, 20736, 29889, 311, 1066, 277, 29918, 1271, 29918, 4537, 29892, 2908, 29918, 4537, 1125, 13, 4706, 3394, 29918, 12719, 29918, 1482, 5521, 749, 29898, 12719, 29918, 3859, 29892, 2106, 29918, 3167, 29889, 311, 1066, 277, 29918, 20736, 29897, 13, 1678, 1683, 29901, 13, 4706, 1797, 353, 4103, 2467, 7514, 29898, 13, 9651, 19754, 277, 29918, 20736, 29889, 311, 1066, 277, 29918, 1271, 29918, 4537, 29892, 13, 9651, 19754, 277, 29918, 20736, 29892, 13, 4706, 1723, 13, 4706, 16947, 29939, 29889, 354, 932, 1878, 29898, 12719, 29918, 3859, 29889, 311, 1066, 277, 29918, 20736, 29918, 9990, 29892, 1797, 29897, 13, 13, 1678, 4959, 353, 1051, 580, 13, 1678, 736, 4103, 654, 3591, 29898, 12719, 29918, 3859, 29892, 4959, 29897, 13, 13, 13, 1753, 3394, 29918, 12719, 29918, 1482, 5521, 749, 29898, 12719, 29918, 3859, 29892, 19754, 277, 29918, 20736, 1125, 13, 1678, 5221, 424, 29918, 7328, 353, 19754, 277, 29918, 20736, 29889, 1595, 12654, 424, 29918, 7328, 13, 13, 1678, 565, 5221, 424, 29918, 7328, 1275, 8242, 29918, 3859, 29889, 473, 29918, 3859, 29889, 7328, 29901, 13, 4706, 716, 29918, 5521, 749, 353, 4236, 29898, 13, 9651, 8242, 29918, 3859, 29889, 473, 29918, 3859, 29889, 1285, 1461, 29918, 5521, 749, 29892, 13, 9651, 19754, 277, 29918, 20736, 29889, 1285, 1461, 29918, 5521, 749, 29892, 13, 4706, 1723, 13, 4706, 8242, 29918, 3859, 29889, 473, 29918, 3859, 29889, 1285, 1461, 29918, 5521, 749, 353, 716, 29918, 5521, 749, 13, 13, 1678, 25342, 5221, 424, 29918, 7328, 1275, 8242, 29918, 3859, 29889, 1595, 1089, 29918, 3859, 29889, 7328, 29901, 13, 4706, 716, 29918, 5521, 749, 353, 4236, 29898, 13, 9651, 8242, 29918, 3859, 29889, 1595, 1089, 29918, 3859, 29889, 1285, 1461, 29918, 5521, 749, 29892, 13, 9651, 19754, 277, 29918, 20736, 29889, 1285, 1461, 29918, 5521, 749, 29892, 13, 4706, 1723, 13, 4706, 8242, 29918, 3859, 29889, 1595, 1089, 29918, 3859, 29889, 1285, 1461, 29918, 5521, 749, 353, 716, 29918, 5521, 749, 13, 13, 13, 1753, 4386, 29918, 12719, 29918, 2541, 4012, 29898, 12719, 29918, 3859, 29892, 2106, 29918, 3167, 1125, 13, 1678, 6608, 908, 353, 2106, 29918, 3167, 29889, 8568, 908, 13, 1678, 7035, 353, 2106, 29918, 3167, 29889, 19024, 13, 13, 1678, 1749, 29918, 2541, 4012, 353, 313, 13, 4706, 2106, 29918, 3167, 29889, 13556, 2147, 1275, 8242, 29918, 3859, 29889, 473, 29918, 3859, 29889, 7328, 322, 13, 4706, 338, 29918, 29113, 29898, 12719, 29918, 3859, 29889, 1595, 1089, 29918, 3859, 29892, 6608, 908, 29897, 13, 1678, 1723, 13, 1678, 396, 383, 6415, 2303, 29901, 1818, 451, 3349, 278, 7714, 29892, 6467, 263, 716, 443, 908, 5296, 2609, 367, 13, 1678, 396, 1754, 13, 1678, 565, 1749, 29918, 2541, 4012, 29901, 13, 4706, 628, 29918, 908, 29898, 12719, 29918, 3859, 29889, 1595, 1089, 29918, 3859, 29892, 6608, 908, 29897, 13, 13, 1678, 18096, 29918, 2541, 4012, 353, 313, 13, 4706, 2106, 29918, 3167, 29889, 13556, 2147, 1275, 8242, 29918, 3859, 29889, 1595, 1089, 29918, 3859, 29889, 7328, 322, 13, 4706, 338, 29918, 29113, 29898, 12719, 29918, 3859, 29889, 473, 29918, 3859, 29892, 6608, 908, 29897, 13, 1678, 1723, 13, 1678, 565, 18096, 29918, 2541, 4012, 29901, 13, 4706, 628, 29918, 908, 29898, 12719, 29918, 3859, 29889, 473, 29918, 3859, 29892, 6608, 908, 29897, 13, 13, 1678, 396, 2973, 4012, 338, 3734, 565, 727, 471, 263, 2143, 870, 297, 445, 8242, 29892, 322, 278, 13, 1678, 396, 7035, 338, 10972, 515, 278, 28679, 1741, 29889, 13, 1678, 4959, 353, 5159, 13, 1678, 565, 338, 29918, 29113, 29898, 12719, 29918, 3859, 29889, 473, 29918, 3859, 29892, 6608, 908, 1125, 13, 4706, 7714, 353, 679, 29918, 908, 29898, 12719, 29918, 3859, 29889, 473, 29918, 3859, 29892, 6608, 908, 29897, 13, 4706, 5296, 353, 10272, 29918, 8017, 29918, 1454, 29918, 908, 29898, 12719, 29918, 3859, 29889, 473, 29918, 3859, 29892, 7035, 29892, 7714, 29897, 13, 4706, 28679, 353, 2866, 1461, 12600, 13599, 3047, 4012, 29898, 12719, 29918, 3859, 29889, 25378, 29892, 518, 8017, 2314, 13, 4706, 4959, 29889, 4397, 29898, 2541, 4012, 29897, 13, 13, 1678, 6036, 29918, 19024, 29898, 12719, 29918, 3859, 29892, 7035, 29892, 6608, 908, 29897, 13, 13, 1678, 736, 4103, 654, 3591, 29898, 12719, 29918, 3859, 29892, 4959, 29897, 13, 13, 13, 1753, 2106, 29918, 20543, 29898, 12719, 29918, 3859, 29892, 2106, 29918, 3167, 29892, 2908, 29918, 4537, 1125, 13, 1678, 396, 282, 2904, 524, 29901, 11262, 29922, 517, 29877, 29899, 13011, 29899, 17519, 267, 29892, 348, 8819, 290, 2454, 29899, 1853, 3198, 13, 13, 1678, 4959, 353, 1051, 580, 13, 1678, 12541, 353, 4103, 654, 3591, 29898, 12719, 29918, 3859, 29892, 4959, 29897, 13, 13, 1678, 565, 1134, 29898, 3859, 29918, 3167, 29897, 1275, 15658, 29901, 13, 4706, 12541, 353, 4386, 29918, 1271, 29898, 12719, 29918, 3859, 29892, 2106, 29918, 3167, 29892, 2908, 29918, 4537, 29897, 13, 13, 1678, 25342, 1134, 29898, 3859, 29918, 3167, 29897, 1275, 9123, 13599, 11123, 29901, 13, 4706, 12541, 353, 4386, 29918, 2467, 29918, 5358, 29898, 12719, 29918, 3859, 29892, 2106, 29918, 3167, 29892, 2908, 29918, 4537, 29897, 13, 13, 1678, 25342, 1134, 29898, 3859, 29918, 3167, 29897, 1275, 9123, 4300, 571, 17392, 29901, 13, 4706, 12541, 353, 4386, 29918, 6717, 29918, 11851, 3286, 571, 29898, 12719, 29918, 3859, 29892, 2106, 29918, 3167, 29897, 13, 13, 1678, 25342, 1134, 29898, 3859, 29918, 3167, 29897, 1275, 2866, 1461, 24131, 13599, 6821, 2662, 29901, 13, 4706, 12541, 353, 4386, 29918, 12719, 29918, 15603, 29898, 12719, 29918, 3859, 29892, 2106, 29918, 3167, 29897, 13, 13, 1678, 25342, 1134, 29898, 3859, 29918, 3167, 29897, 1275, 2866, 1461, 24131, 13599, 29903, 1803, 839, 29901, 13, 4706, 12541, 353, 4386, 29918, 12719, 29918, 9915, 839, 29898, 12719, 29918, 3859, 29892, 2106, 29918, 3167, 29897, 13, 13, 1678, 25342, 1134, 29898, 3859, 29918, 3167, 29897, 1275, 2866, 1461, 24131, 13599, 4373, 22031, 749, 29901, 13, 4706, 12541, 353, 4386, 29918, 12719, 29918, 1482, 5521, 749, 29898, 12719, 29918, 3859, 29892, 2106, 29918, 3167, 29892, 2908, 29918, 4537, 29897, 13, 13, 1678, 25342, 1134, 29898, 3859, 29918, 3167, 29897, 1275, 2866, 1461, 24131, 13599, 3047, 4012, 29901, 13, 4706, 12541, 353, 4386, 29918, 12719, 29918, 2541, 4012, 29898, 12719, 29918, 3859, 29892, 2106, 29918, 3167, 29897, 13, 13, 1678, 25342, 1134, 29898, 3859, 29918, 3167, 29897, 1275, 24328, 573, 4300, 571, 17392, 29901, 13, 4706, 12541, 353, 4386, 29918, 13556, 573, 29918, 11851, 3286, 571, 29898, 12719, 29918, 3859, 29892, 2106, 29918, 3167, 29897, 13, 13, 1678, 736, 12541, 13, 2 ]
script_example.py
op8867555/BGmi
0
20340
import datetime from bgmi.script import ScriptBase from bgmi.utils import parse_episode class Script(ScriptBase): class Model(ScriptBase.Model): bangumi_name = "TEST_BANGUMI" cover = "" update_time = "Mon" due_date = datetime.datetime(2017, 9, 30) def get_download_url(self): # fetch and return dict # ignore they are not same bangumi. resp = [ { "title": "[c.c动漫][4月新番][影之诗][ShadowVerse][01][简日][HEVC][1080P][MP4]", "link": "http://example.com/Bangumi/1/1.torrent", }, { "title": "[YMDR][慕留人 -火影忍者新时代-][2017][2][AVC][JAP][BIG5][MP4][1080P]", "link": "http://example.com/Bangumi/1/2.torrent", }, { "title": "[ZXSUB仲夏动漫字幕组][博人传-火影忍者次世代][03][720P繁体][MP4]", "link": "magnet:?xt=urn:btih:233", }, ] ret = {} for item in resp: e = parse_episode(item["title"]) if e: ret[e] = item["link"] return ret if __name__ == "__main__": s = Script() print(s.get_download_url())
[ 1, 1053, 12865, 13, 13, 3166, 25989, 2460, 29889, 2154, 1053, 14415, 5160, 13, 3166, 25989, 2460, 29889, 13239, 1053, 6088, 29918, 1022, 275, 356, 13, 13, 13, 1990, 14415, 29898, 4081, 5160, 1125, 13, 1678, 770, 8125, 29898, 4081, 5160, 29889, 3195, 1125, 13, 4706, 289, 574, 15547, 29918, 978, 353, 376, 18267, 29918, 29933, 19453, 5005, 29902, 29908, 13, 4706, 4612, 353, 5124, 13, 4706, 2767, 29918, 2230, 353, 376, 7185, 29908, 13, 4706, 2861, 29918, 1256, 353, 12865, 29889, 12673, 29898, 29906, 29900, 29896, 29955, 29892, 29871, 29929, 29892, 29871, 29941, 29900, 29897, 13, 13, 1678, 822, 679, 29918, 10382, 29918, 2271, 29898, 1311, 1125, 13, 4706, 396, 6699, 322, 736, 9657, 13, 4706, 396, 11455, 896, 526, 451, 1021, 289, 574, 15547, 29889, 13, 4706, 4613, 353, 518, 13, 9651, 426, 13, 18884, 376, 3257, 1115, 14704, 29883, 29889, 29883, 30846, 233, 191, 174, 3816, 29946, 30534, 30374, 31982, 3816, 31619, 30577, 235, 178, 154, 3816, 2713, 6986, 6565, 344, 3816, 29900, 29896, 3816, 234, 177, 131, 30325, 3816, 9606, 8257, 3816, 29896, 29900, 29947, 29900, 29925, 3816, 3580, 29946, 29962, 613, 13, 18884, 376, 2324, 1115, 376, 1124, 597, 4773, 29889, 510, 29914, 29933, 574, 15547, 29914, 29896, 29914, 29896, 29889, 7345, 7771, 613, 13, 9651, 2981, 13, 9651, 426, 13, 18884, 376, 3257, 1115, 14704, 29979, 5773, 29934, 3816, 233, 136, 152, 234, 152, 156, 30313, 448, 31313, 31619, 232, 194, 144, 30767, 30374, 30594, 30690, 29899, 3816, 29906, 29900, 29896, 29955, 3816, 29906, 3816, 7520, 29907, 3816, 29967, 3301, 3816, 29933, 6259, 29945, 3816, 3580, 29946, 3816, 29896, 29900, 29947, 29900, 29925, 29962, 613, 13, 18884, 376, 2324, 1115, 376, 1124, 597, 4773, 29889, 510, 29914, 29933, 574, 15547, 29914, 29896, 29914, 29906, 29889, 7345, 7771, 613, 13, 9651, 2981, 13, 9651, 426, 13, 18884, 376, 3257, 1115, 14704, 29999, 29990, 20633, 231, 190, 181, 31241, 30846, 233, 191, 174, 30578, 232, 188, 152, 31263, 3816, 31196, 30313, 31471, 29899, 31313, 31619, 232, 194, 144, 30767, 30936, 30793, 30690, 3816, 29900, 29941, 3816, 29955, 29906, 29900, 29925, 234, 188, 132, 30988, 3816, 3580, 29946, 29962, 613, 13, 18884, 376, 2324, 1115, 376, 11082, 1212, 29901, 29973, 486, 29922, 595, 29901, 29890, 2034, 29882, 29901, 29906, 29941, 29941, 613, 13, 9651, 2981, 13, 4706, 4514, 13, 13, 4706, 3240, 353, 6571, 13, 4706, 363, 2944, 297, 4613, 29901, 13, 9651, 321, 353, 6088, 29918, 1022, 275, 356, 29898, 667, 3366, 3257, 20068, 13, 9651, 565, 321, 29901, 13, 18884, 3240, 29961, 29872, 29962, 353, 2944, 3366, 2324, 3108, 13, 13, 4706, 736, 3240, 13, 13, 13, 361, 4770, 978, 1649, 1275, 376, 1649, 3396, 1649, 1115, 13, 1678, 269, 353, 14415, 580, 13, 1678, 1596, 29898, 29879, 29889, 657, 29918, 10382, 29918, 2271, 3101, 13, 2 ]
src/streamlink/plugins/clubbingtv.py
code-review-doctor/streamlink
0
92117
""" $url clubbingtv.com $type live, vod $account Login required """ import logging import re from streamlink.plugin import Plugin, PluginArgument, PluginArguments, pluginmatcher from streamlink.stream.hls import HLSStream log = logging.getLogger(__name__) @pluginmatcher(re.compile( r"https?://(www\.)?clubbingtv\.com/" )) class ClubbingTV(Plugin): _login_url = "https://www.clubbingtv.com/user/login" _live_re = re.compile( r'playerInstance\.setup\({\s*"file"\s*:\s*"(?P<stream_url>.+?)"', re.DOTALL, ) _vod_re = re.compile(r'<iframe src="(?P<stream_url>.+?)"') arguments = PluginArguments( PluginArgument( "username", required=True, requires=["password"], help="The username used to register with Clubbing TV.", ), PluginArgument( "password", required=True, sensitive=True, help="A Clubbing TV account password to use with --clubbingtv-username.", ), ) def login(self): username = self.get_option("username") password = self.get_option("password") res = self.session.http.post( self._login_url, data={"val[login]": username, "val[password]": password}, ) if "Invalid Email/User Name" in res.text: log.error( "Failed to login to Clubbing TV, incorrect email/password combination" ) return False log.info("Successfully logged in") return True def _get_live_streams(self, content): match = self._live_re.search(content) if not match: return stream_url = match.group("stream_url") yield from HLSStream.parse_variant_playlist(self.session, stream_url).items() def _get_vod_streams(self, content): match = self._vod_re.search(content) if not match: return stream_url = match.group("stream_url") log.info( "Fetching external stream from URL {0}".format(stream_url) ) return self.session.streams(stream_url) def _get_streams(self): if not self.login(): return self.session.http.headers.update({"Referer": self.url}) res = self.session.http.get(self.url) if "clubbingtv.com/live" in self.url: log.debug("Live stream detected") return self._get_live_streams(res.text) log.debug("VOD stream detected") return self._get_vod_streams(res.text) __plugin__ = ClubbingTV
[ 1, 9995, 13, 29938, 2271, 4402, 10549, 12427, 29889, 510, 13, 29938, 1853, 5735, 29892, 325, 397, 13, 29938, 10149, 19130, 3734, 13, 15945, 29908, 13, 13, 5215, 12183, 13, 5215, 337, 13, 13, 3166, 4840, 2324, 29889, 8582, 1053, 1858, 3851, 29892, 1858, 3851, 15730, 29892, 1858, 3851, 26915, 29892, 7079, 4352, 261, 13, 3166, 4840, 2324, 29889, 5461, 29889, 29882, 3137, 1053, 379, 8547, 3835, 13, 13, 1188, 353, 12183, 29889, 657, 16363, 22168, 978, 1649, 29897, 13, 13, 13, 29992, 8582, 4352, 261, 29898, 276, 29889, 12198, 29898, 13, 1678, 364, 29908, 991, 29973, 597, 29898, 1636, 29905, 1846, 29973, 29066, 10549, 12427, 23301, 510, 12975, 13, 876, 13, 1990, 5977, 10549, 8050, 29898, 16288, 1125, 13, 1678, 903, 7507, 29918, 2271, 353, 376, 991, 597, 1636, 29889, 29066, 10549, 12427, 29889, 510, 29914, 1792, 29914, 7507, 29908, 13, 13, 1678, 903, 9258, 29918, 276, 353, 337, 29889, 12198, 29898, 13, 4706, 364, 29915, 9106, 4998, 23301, 14669, 29905, 13670, 29879, 20605, 1445, 26732, 29879, 29930, 3583, 29879, 20605, 10780, 29925, 29966, 5461, 29918, 2271, 15513, 29974, 29973, 5513, 742, 13, 4706, 337, 29889, 29928, 2891, 9818, 29892, 13, 1678, 1723, 13, 1678, 903, 14091, 29918, 276, 353, 337, 29889, 12198, 29898, 29878, 29915, 29966, 22000, 4765, 543, 10780, 29925, 29966, 5461, 29918, 2271, 15513, 29974, 29973, 5513, 1495, 13, 13, 1678, 6273, 353, 1858, 3851, 26915, 29898, 13, 4706, 1858, 3851, 15730, 29898, 13, 9651, 376, 6786, 613, 13, 9651, 3734, 29922, 5574, 29892, 13, 9651, 6858, 29922, 3366, 5630, 12436, 13, 9651, 1371, 543, 1576, 8952, 1304, 304, 6036, 411, 5977, 10549, 5648, 19602, 13, 4706, 10353, 13, 4706, 1858, 3851, 15730, 29898, 13, 9651, 376, 5630, 613, 13, 9651, 3734, 29922, 5574, 29892, 13, 9651, 20502, 29922, 5574, 29892, 13, 9651, 1371, 543, 29909, 5977, 10549, 5648, 3633, 4800, 304, 671, 411, 1192, 29066, 10549, 12427, 29899, 6786, 19602, 13, 4706, 10353, 13, 1678, 1723, 13, 13, 1678, 822, 6464, 29898, 1311, 1125, 13, 4706, 8952, 353, 1583, 29889, 657, 29918, 3385, 703, 6786, 1159, 13, 4706, 4800, 353, 1583, 29889, 657, 29918, 3385, 703, 5630, 1159, 13, 4706, 620, 353, 1583, 29889, 7924, 29889, 1124, 29889, 2490, 29898, 13, 9651, 1583, 3032, 7507, 29918, 2271, 29892, 13, 9651, 848, 3790, 29908, 791, 29961, 7507, 29962, 1115, 8952, 29892, 376, 791, 29961, 5630, 29962, 1115, 4800, 1118, 13, 4706, 1723, 13, 13, 4706, 565, 376, 13919, 22608, 29914, 2659, 4408, 29908, 297, 620, 29889, 726, 29901, 13, 9651, 1480, 29889, 2704, 29898, 13, 18884, 376, 17776, 304, 6464, 304, 5977, 10549, 5648, 29892, 10240, 4876, 29914, 5630, 10296, 29908, 13, 9651, 1723, 13, 9651, 736, 7700, 13, 13, 4706, 1480, 29889, 3888, 703, 14191, 3730, 13817, 297, 1159, 13, 4706, 736, 5852, 13, 13, 1678, 822, 903, 657, 29918, 9258, 29918, 5461, 29879, 29898, 1311, 29892, 2793, 1125, 13, 4706, 1993, 353, 1583, 3032, 9258, 29918, 276, 29889, 4478, 29898, 3051, 29897, 13, 4706, 565, 451, 1993, 29901, 13, 9651, 736, 13, 4706, 4840, 29918, 2271, 353, 1993, 29889, 2972, 703, 5461, 29918, 2271, 1159, 13, 13, 4706, 7709, 515, 379, 8547, 3835, 29889, 5510, 29918, 19365, 29918, 1456, 1761, 29898, 1311, 29889, 7924, 29892, 4840, 29918, 2271, 467, 7076, 580, 13, 13, 1678, 822, 903, 657, 29918, 14091, 29918, 5461, 29879, 29898, 1311, 29892, 2793, 1125, 13, 4706, 1993, 353, 1583, 3032, 14091, 29918, 276, 29889, 4478, 29898, 3051, 29897, 13, 4706, 565, 451, 1993, 29901, 13, 9651, 736, 13, 13, 4706, 4840, 29918, 2271, 353, 1993, 29889, 2972, 703, 5461, 29918, 2271, 1159, 13, 4706, 1480, 29889, 3888, 29898, 13, 9651, 376, 20927, 292, 7029, 4840, 515, 3988, 426, 29900, 29913, 1642, 4830, 29898, 5461, 29918, 2271, 29897, 13, 4706, 1723, 13, 4706, 736, 1583, 29889, 7924, 29889, 5461, 29879, 29898, 5461, 29918, 2271, 29897, 13, 13, 1678, 822, 903, 657, 29918, 5461, 29879, 29898, 1311, 1125, 13, 4706, 565, 451, 1583, 29889, 7507, 7295, 13, 9651, 736, 13, 13, 4706, 1583, 29889, 7924, 29889, 1124, 29889, 13662, 29889, 5504, 3319, 29908, 1123, 571, 261, 1115, 1583, 29889, 2271, 1800, 13, 13, 4706, 620, 353, 1583, 29889, 7924, 29889, 1124, 29889, 657, 29898, 1311, 29889, 2271, 29897, 13, 13, 4706, 565, 376, 29066, 10549, 12427, 29889, 510, 29914, 9258, 29908, 297, 1583, 29889, 2271, 29901, 13, 9651, 1480, 29889, 8382, 703, 23859, 4840, 17809, 1159, 13, 9651, 736, 1583, 3032, 657, 29918, 9258, 29918, 5461, 29879, 29898, 690, 29889, 726, 29897, 13, 13, 4706, 1480, 29889, 8382, 703, 29963, 13668, 4840, 17809, 1159, 13, 4706, 736, 1583, 3032, 657, 29918, 14091, 29918, 5461, 29879, 29898, 690, 29889, 726, 29897, 13, 13, 13, 1649, 8582, 1649, 353, 5977, 10549, 8050, 13, 2 ]
sjb/actions/deprovision.py
brenton/aos-cd-jobs
45
96180
from __future__ import absolute_import, print_function, unicode_literals from .interface import Action from .named_shell_task import render_task _DEPROVISION_TITLE = "DEPROVISION CLOUD RESOURCES" _DEPROVISION_ACTION = "oct deprovision" class DeprovisionAction(Action): """ A DeprovisionAction generates a post-build step that deprovisions the remote host. """ def generate_post_build_steps(self): return [render_task( title=_DEPROVISION_TITLE, command=_DEPROVISION_ACTION, output_format=self.output_format )]
[ 1, 515, 4770, 29888, 9130, 1649, 1053, 8380, 29918, 5215, 29892, 1596, 29918, 2220, 29892, 29104, 29918, 20889, 1338, 13, 13, 3166, 869, 13248, 1053, 9123, 13, 3166, 869, 17514, 29918, 15903, 29918, 7662, 1053, 4050, 29918, 7662, 13, 13, 29918, 2287, 8618, 28607, 2725, 29918, 29911, 1806, 1307, 353, 376, 2287, 8618, 28607, 2725, 315, 3927, 15789, 390, 2890, 22970, 27266, 29908, 13, 29918, 2287, 8618, 28607, 2725, 29918, 24705, 353, 376, 20082, 316, 771, 4924, 29908, 13, 13, 13, 1990, 897, 771, 4924, 4276, 29898, 4276, 1125, 13, 1678, 9995, 13, 1678, 319, 897, 771, 4924, 4276, 16785, 263, 1400, 29899, 4282, 13, 1678, 4331, 393, 316, 771, 1730, 1080, 278, 7592, 3495, 29889, 13, 1678, 9995, 13, 13, 1678, 822, 5706, 29918, 2490, 29918, 4282, 29918, 24530, 29898, 1311, 1125, 13, 4706, 736, 518, 9482, 29918, 7662, 29898, 13, 9651, 3611, 29922, 29918, 2287, 8618, 28607, 2725, 29918, 29911, 1806, 1307, 29892, 13, 9651, 1899, 29922, 29918, 2287, 8618, 28607, 2725, 29918, 24705, 29892, 13, 9651, 1962, 29918, 4830, 29922, 1311, 29889, 4905, 29918, 4830, 13, 4706, 1723, 29962, 13, 2 ]
okdata/sdk/permission/user_types.py
oslokommune/okdata-sdk-python
2
109431
# TODO: Use these simplified dataclasses once support for Python 3.6 is # dropped. Meanwhile we'll use the "polyfill" classes defined below. # # from dataclasses import dataclass, field # # @dataclass # class Client: # user_id: str # user_type: str = field(default="client", init=False) # # # @dataclass # class Team: # user_id: str # user_type: str = field(default="team", init=False) # # # @dataclass # class User: # user_id: str # user_type: str = field(default="user", init=False) class Client: user_id: str user_type: str def __init__(self, user_id): self.user_id = user_id self.user_type = "client" class Team: user_id: str user_type: str def __init__(self, user_id): self.user_id = user_id self.user_type = "team" class User: user_id: str user_type: str def __init__(self, user_id): self.user_id = user_id self.user_type = "user" def asdict(obj): return obj.__dict__
[ 1, 396, 14402, 29901, 4803, 1438, 20875, 848, 13203, 2748, 2304, 363, 5132, 29871, 29941, 29889, 29953, 338, 13, 29937, 13700, 29889, 25065, 591, 29915, 645, 671, 278, 376, 22678, 5589, 29908, 4413, 3342, 2400, 29889, 13, 29937, 13, 29937, 515, 848, 13203, 1053, 848, 1990, 29892, 1746, 13, 29937, 13, 29937, 732, 1272, 1990, 13, 29937, 770, 12477, 29901, 13, 29937, 268, 1404, 29918, 333, 29901, 851, 13, 29937, 268, 1404, 29918, 1853, 29901, 851, 353, 1746, 29898, 4381, 543, 4645, 613, 2069, 29922, 8824, 29897, 13, 29937, 13, 29937, 13, 29937, 732, 1272, 1990, 13, 29937, 770, 8583, 29901, 13, 29937, 268, 1404, 29918, 333, 29901, 851, 13, 29937, 268, 1404, 29918, 1853, 29901, 851, 353, 1746, 29898, 4381, 543, 14318, 613, 2069, 29922, 8824, 29897, 13, 29937, 13, 29937, 13, 29937, 732, 1272, 1990, 13, 29937, 770, 4911, 29901, 13, 29937, 268, 1404, 29918, 333, 29901, 851, 13, 29937, 268, 1404, 29918, 1853, 29901, 851, 353, 1746, 29898, 4381, 543, 1792, 613, 2069, 29922, 8824, 29897, 13, 13, 13, 1990, 12477, 29901, 13, 1678, 1404, 29918, 333, 29901, 851, 13, 1678, 1404, 29918, 1853, 29901, 851, 13, 13, 1678, 822, 4770, 2344, 12035, 1311, 29892, 1404, 29918, 333, 1125, 13, 4706, 1583, 29889, 1792, 29918, 333, 353, 1404, 29918, 333, 13, 4706, 1583, 29889, 1792, 29918, 1853, 353, 376, 4645, 29908, 13, 13, 13, 1990, 8583, 29901, 13, 1678, 1404, 29918, 333, 29901, 851, 13, 1678, 1404, 29918, 1853, 29901, 851, 13, 13, 1678, 822, 4770, 2344, 12035, 1311, 29892, 1404, 29918, 333, 1125, 13, 4706, 1583, 29889, 1792, 29918, 333, 353, 1404, 29918, 333, 13, 4706, 1583, 29889, 1792, 29918, 1853, 353, 376, 14318, 29908, 13, 13, 13, 1990, 4911, 29901, 13, 1678, 1404, 29918, 333, 29901, 851, 13, 1678, 1404, 29918, 1853, 29901, 851, 13, 13, 1678, 822, 4770, 2344, 12035, 1311, 29892, 1404, 29918, 333, 1125, 13, 4706, 1583, 29889, 1792, 29918, 333, 353, 1404, 29918, 333, 13, 4706, 1583, 29889, 1792, 29918, 1853, 353, 376, 1792, 29908, 13, 13, 13, 1753, 408, 8977, 29898, 5415, 1125, 13, 1678, 736, 5446, 17255, 8977, 1649, 13, 2 ]
scripts/kmer/get_kmer_list.py
mahajrod/MAVR
10
196439
#!/usr/bin/env python __author__ = '<NAME>' import os import argparse from Bio import SeqIO os.environ['MPLCONFIGDIR'] = '/tmp/' import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as plt plt.ioff() from RouToolPa.GeneralRoutines.File import make_list_of_path_to_files from RouToolPa.Tools.Kmers import Jellyfish from RouToolPa.Routines.Sequence import rev_com_generator parser = argparse.ArgumentParser() parser.add_argument("-i", "--input_file", action="store", dest="input", type=lambda s: s.split(","), help="Comma-separated list of fasta or fastq files or directories containing them.") parser.add_argument("-m", "--kmer_length", action="store", dest="kmer_length", type=int, default=23, help="Length of kmers") parser.add_argument("-s", "--hash_size", action="store", dest="hash_size", type=str, default="10G", help="Size of hash. Estimation of hash size: for short reads S=(G + k*n)/0.8, " "G - genome size, k - kmer length, n - number of reads, for assembled sequences " "S=Sum(L)") parser.add_argument("-a", "--base_prefix", action="store", dest="base_prefix", default="jellyfish_db", help="Name of kmer database. Default: jellyfish_db") parser.add_argument("-t", "--threads", action="store", dest="threads", type=int, default=1, help="Number of threads") parser.add_argument("-b", "--count_both_strands", action="store_true", dest="count_both_strands", help="Count kmers in both strands. NOTICE: only mer or its reverse-complement, whichever " "comes first lexicographically, is stored and the count value is the number of " "occurrences of both. So this option is not suitable for generating sets of forward " "and reverse-complement kmers. For this case use -r/--add_reverse_complement option. " "Not compatible with -r/--add_reverse_complement option.") parser.add_argument("-r", "--add_reverse_complement", action="store_true", dest="add_rev_com", help="Add reverse-complement sequences before counting kmers. " "Works only for fasta sequences. " "Not compatible with -b/--count_both_strands option") parser.add_argument("-d", "--draw_distribution", action="store_true", dest="draw_distribution", help="Draw distribution of kmers") parser.add_argument("-j", "--jellyfish_path", action="store", dest="jellyfish_path", help="Path to jellyfish") parser.add_argument("-n", "--dont_extract_kmer_list", action="store_true", dest="dont_extract_kmer_list", help="Don't extract kmer list") args = parser.parse_args() args.input = make_list_of_path_to_files(args.input) if args.count_both_strands and args.add_rev_com: raise ValueError("Options -b/--count_both_strands and -r/--add_reverse_complement are not compatible") if args.add_rev_com: file_with_rev_com = args.base_prefix + "_with_rev_com.fasta" record_dict = SeqIO.index_db("temp_index.idx", args.input, format="fasta") SeqIO.write(rev_com_generator(record_dict, yield_original_record=True), file_with_rev_com, "fasta") args.base_prefix += "_with_rev_com" base_file = "%s_%i_mer.jf" % (args.base_prefix, args.kmer_length) kmer_table_file = "%s_%i_mer.counts" % (args.base_prefix, args.kmer_length) kmer_file = "%s_%i_mer.kmer" % (args.base_prefix, args.kmer_length) Jellyfish.threads = args.threads Jellyfish.path = args.jellyfish_path if args.jellyfish_path else "" Jellyfish.count(args.input if not args.add_rev_com else file_with_rev_com, base_file, kmer_length=args.kmer_length, hash_size=args.hash_size, count_both_strands=args.count_both_strands) if not args.dont_extract_kmer_list: Jellyfish.dump(base_file, kmer_table_file) sed_string = 'sed -e "s/\t.*//" %s > %s' % (kmer_table_file, kmer_file) os.system(sed_string) if args.draw_distribution: histo_file = "%s_%i_mer.histo" % (args.base_prefix, args.kmer_length) picture_prefix = "%s_%i_mer_histogram" % (args.base_prefix, args.kmer_length) Jellyfish.histo(base_file, histo_file, upper_count=10000000) counts = [] bins = [] with open(histo_file, "r") as histo_fd: for line in histo_fd: entry = line.strip().split() counts.append(entry[1]) bins.append(entry[0]) figure = plt.figure(1, figsize=(8, 8), dpi=300) subplot = plt.subplot(1, 1, 1) plt.suptitle("Distribution of %i-mers" % args.kmer_length, fontweight='bold') plt.plot(bins, counts) plt.xlabel("Multiplicity") plt.ylabel("Number of distinct kmers") subplot.set_yscale('log', basey=10) subplot.set_xscale('log', basex=10) for extension in ["png", "svg"]: plt.savefig("%s.%s" % (picture_prefix, extension)) if args.add_rev_com: os.remove("temp_index.idx")
[ 1, 18787, 4855, 29914, 2109, 29914, 6272, 3017, 13, 1649, 8921, 1649, 353, 12801, 5813, 16299, 13, 13, 5215, 2897, 13, 5215, 1852, 5510, 13, 3166, 21184, 1053, 25981, 5971, 13, 13, 359, 29889, 21813, 1839, 3580, 29931, 25903, 9464, 2033, 353, 8207, 7050, 22208, 13, 5215, 22889, 13, 2922, 17357, 29889, 1509, 877, 29909, 1505, 1495, 13, 5215, 22889, 29889, 2272, 5317, 408, 14770, 13, 572, 29873, 29889, 601, 600, 580, 13, 13, 3166, 15915, 12229, 11868, 29889, 15263, 24254, 1475, 29889, 2283, 1053, 1207, 29918, 1761, 29918, 974, 29918, 2084, 29918, 517, 29918, 5325, 13, 3166, 15915, 12229, 11868, 29889, 24183, 29889, 29968, 13269, 1053, 435, 14112, 15161, 13, 3166, 15915, 12229, 11868, 29889, 24254, 1475, 29889, 20529, 1053, 6664, 29918, 510, 29918, 27959, 13, 13, 16680, 353, 1852, 5510, 29889, 15730, 11726, 580, 13, 13, 16680, 29889, 1202, 29918, 23516, 703, 29899, 29875, 613, 376, 489, 2080, 29918, 1445, 613, 3158, 543, 8899, 613, 2731, 543, 2080, 613, 1134, 29922, 2892, 269, 29901, 269, 29889, 5451, 29898, 3284, 511, 13, 462, 1678, 1371, 543, 1523, 655, 29899, 25048, 630, 1051, 310, 5172, 29874, 470, 5172, 29939, 2066, 470, 17525, 6943, 963, 23157, 13, 16680, 29889, 1202, 29918, 23516, 703, 29899, 29885, 613, 376, 489, 29895, 1050, 29918, 2848, 613, 3158, 543, 8899, 613, 2731, 543, 29895, 1050, 29918, 2848, 613, 1134, 29922, 524, 29892, 2322, 29922, 29906, 29941, 29892, 13, 462, 1678, 1371, 543, 6513, 310, 2383, 414, 1159, 13, 16680, 29889, 1202, 29918, 23516, 703, 29899, 29879, 613, 376, 489, 8568, 29918, 2311, 613, 3158, 543, 8899, 613, 2731, 543, 8568, 29918, 2311, 613, 1134, 29922, 710, 29892, 2322, 543, 29896, 29900, 29954, 613, 13, 462, 1678, 1371, 543, 3505, 310, 6608, 29889, 2661, 7715, 310, 6608, 2159, 29901, 363, 3273, 13623, 317, 7607, 29954, 718, 413, 29930, 29876, 6802, 29900, 29889, 29947, 29892, 376, 13, 462, 1678, 376, 29954, 448, 2531, 608, 2159, 29892, 413, 448, 413, 1050, 3309, 29892, 302, 448, 1353, 310, 13623, 29892, 363, 24940, 29881, 15602, 376, 13, 462, 1678, 376, 29903, 29922, 11139, 29898, 29931, 25760, 13, 16680, 29889, 1202, 29918, 23516, 703, 29899, 29874, 613, 376, 489, 3188, 29918, 13506, 613, 3158, 543, 8899, 613, 2731, 543, 3188, 29918, 13506, 613, 2322, 543, 29926, 14112, 15161, 29918, 2585, 613, 13, 462, 1678, 1371, 543, 1170, 310, 413, 1050, 2566, 29889, 13109, 29901, 12736, 368, 15161, 29918, 2585, 1159, 13, 16680, 29889, 1202, 29918, 23516, 703, 29899, 29873, 613, 376, 489, 28993, 613, 3158, 543, 8899, 613, 2731, 543, 28993, 613, 1134, 29922, 524, 29892, 2322, 29922, 29896, 29892, 13, 462, 1678, 1371, 543, 4557, 310, 9717, 1159, 13, 16680, 29889, 1202, 29918, 23516, 703, 29899, 29890, 613, 376, 489, 2798, 29918, 20313, 29918, 710, 4167, 613, 3158, 543, 8899, 29918, 3009, 613, 2731, 543, 2798, 29918, 20313, 29918, 710, 4167, 613, 13, 462, 1678, 1371, 543, 3981, 2383, 414, 297, 1716, 851, 4167, 29889, 6058, 12107, 29901, 871, 2778, 470, 967, 11837, 29899, 510, 2037, 29892, 377, 4070, 369, 376, 13, 462, 308, 376, 26807, 937, 19566, 293, 1946, 1711, 29892, 338, 6087, 322, 278, 2302, 995, 338, 278, 1353, 310, 376, 13, 462, 308, 376, 15693, 1038, 2063, 310, 1716, 29889, 1105, 445, 2984, 338, 451, 13907, 363, 14655, 6166, 310, 6375, 376, 13, 462, 308, 376, 392, 11837, 29899, 510, 2037, 2383, 414, 29889, 1152, 445, 1206, 671, 448, 29878, 29914, 489, 1202, 29918, 24244, 29918, 510, 2037, 2984, 29889, 376, 13, 462, 308, 376, 3664, 15878, 411, 448, 29878, 29914, 489, 1202, 29918, 24244, 29918, 510, 2037, 2984, 23157, 13, 16680, 29889, 1202, 29918, 23516, 703, 29899, 29878, 613, 376, 489, 1202, 29918, 24244, 29918, 510, 2037, 613, 3158, 543, 8899, 29918, 3009, 613, 2731, 543, 1202, 29918, 13478, 29918, 510, 613, 13, 462, 1678, 1371, 543, 2528, 11837, 29899, 510, 2037, 15602, 1434, 21248, 2383, 414, 29889, 376, 13, 462, 308, 376, 5531, 29879, 871, 363, 5172, 29874, 15602, 29889, 376, 13, 462, 308, 376, 3664, 15878, 411, 448, 29890, 29914, 489, 2798, 29918, 20313, 29918, 710, 4167, 2984, 1159, 13, 16680, 29889, 1202, 29918, 23516, 703, 29899, 29881, 613, 376, 489, 4012, 29918, 27691, 613, 3158, 543, 8899, 29918, 3009, 613, 2731, 543, 4012, 29918, 27691, 613, 13, 462, 1678, 1371, 543, 8537, 4978, 310, 2383, 414, 1159, 13, 16680, 29889, 1202, 29918, 23516, 703, 29899, 29926, 613, 376, 489, 29926, 14112, 15161, 29918, 2084, 613, 3158, 543, 8899, 613, 2731, 543, 29926, 14112, 15161, 29918, 2084, 613, 13, 462, 1678, 1371, 543, 2605, 304, 12736, 368, 15161, 1159, 13, 16680, 29889, 1202, 29918, 23516, 703, 29899, 29876, 613, 376, 489, 29881, 609, 29918, 21111, 29918, 29895, 1050, 29918, 1761, 613, 3158, 543, 8899, 29918, 3009, 613, 2731, 543, 29881, 609, 29918, 21111, 29918, 29895, 1050, 29918, 1761, 613, 13, 462, 1678, 1371, 543, 10310, 29915, 29873, 6597, 413, 1050, 1051, 1159, 13, 13, 5085, 353, 13812, 29889, 5510, 29918, 5085, 580, 13, 13, 5085, 29889, 2080, 353, 1207, 29918, 1761, 29918, 974, 29918, 2084, 29918, 517, 29918, 5325, 29898, 5085, 29889, 2080, 29897, 13, 361, 6389, 29889, 2798, 29918, 20313, 29918, 710, 4167, 322, 6389, 29889, 1202, 29918, 13478, 29918, 510, 29901, 13, 1678, 12020, 7865, 2392, 703, 5856, 448, 29890, 29914, 489, 2798, 29918, 20313, 29918, 710, 4167, 322, 448, 29878, 29914, 489, 1202, 29918, 24244, 29918, 510, 2037, 526, 451, 15878, 1159, 13, 13, 361, 6389, 29889, 1202, 29918, 13478, 29918, 510, 29901, 13, 1678, 934, 29918, 2541, 29918, 13478, 29918, 510, 353, 6389, 29889, 3188, 29918, 13506, 718, 11119, 2541, 29918, 13478, 29918, 510, 29889, 29888, 5427, 29908, 13, 1678, 2407, 29918, 8977, 353, 25981, 5971, 29889, 2248, 29918, 2585, 703, 7382, 29918, 2248, 29889, 13140, 613, 6389, 29889, 2080, 29892, 3402, 543, 29888, 5427, 1159, 13, 1678, 25981, 5971, 29889, 3539, 29898, 13478, 29918, 510, 29918, 27959, 29898, 11651, 29918, 8977, 29892, 7709, 29918, 13492, 29918, 11651, 29922, 5574, 511, 934, 29918, 2541, 29918, 13478, 29918, 510, 29892, 376, 29888, 5427, 1159, 13, 1678, 6389, 29889, 3188, 29918, 13506, 4619, 11119, 2541, 29918, 13478, 29918, 510, 29908, 13, 13, 3188, 29918, 1445, 353, 11860, 29879, 29918, 29995, 29875, 29918, 1050, 29889, 29926, 29888, 29908, 1273, 313, 5085, 29889, 3188, 29918, 13506, 29892, 6389, 29889, 29895, 1050, 29918, 2848, 29897, 13, 29895, 1050, 29918, 2371, 29918, 1445, 353, 11860, 29879, 29918, 29995, 29875, 29918, 1050, 29889, 2798, 29879, 29908, 1273, 313, 5085, 29889, 3188, 29918, 13506, 29892, 6389, 29889, 29895, 1050, 29918, 2848, 29897, 13, 29895, 1050, 29918, 1445, 353, 11860, 29879, 29918, 29995, 29875, 29918, 1050, 29889, 29895, 1050, 29908, 1273, 313, 5085, 29889, 3188, 29918, 13506, 29892, 6389, 29889, 29895, 1050, 29918, 2848, 29897, 13, 13, 29967, 14112, 15161, 29889, 28993, 353, 6389, 29889, 28993, 13, 29967, 14112, 15161, 29889, 2084, 353, 6389, 29889, 29926, 14112, 15161, 29918, 2084, 565, 6389, 29889, 29926, 14112, 15161, 29918, 2084, 1683, 5124, 13, 29967, 14112, 15161, 29889, 2798, 29898, 5085, 29889, 2080, 565, 451, 6389, 29889, 1202, 29918, 13478, 29918, 510, 1683, 934, 29918, 2541, 29918, 13478, 29918, 510, 29892, 2967, 29918, 1445, 29892, 13, 18884, 413, 1050, 29918, 2848, 29922, 5085, 29889, 29895, 1050, 29918, 2848, 29892, 6608, 29918, 2311, 29922, 5085, 29889, 8568, 29918, 2311, 29892, 13, 18884, 2302, 29918, 20313, 29918, 710, 4167, 29922, 5085, 29889, 2798, 29918, 20313, 29918, 710, 4167, 29897, 13, 361, 451, 6389, 29889, 29881, 609, 29918, 21111, 29918, 29895, 1050, 29918, 1761, 29901, 13, 1678, 435, 14112, 15161, 29889, 15070, 29898, 3188, 29918, 1445, 29892, 413, 1050, 29918, 2371, 29918, 1445, 29897, 13, 1678, 7048, 29918, 1807, 353, 525, 8485, 448, 29872, 376, 29879, 7998, 29873, 5575, 458, 29908, 1273, 29879, 1405, 1273, 29879, 29915, 1273, 313, 29895, 1050, 29918, 2371, 29918, 1445, 29892, 413, 1050, 29918, 1445, 29897, 13, 1678, 2897, 29889, 5205, 29898, 8485, 29918, 1807, 29897, 13, 13, 361, 6389, 29889, 4012, 29918, 27691, 29901, 13, 1678, 298, 5137, 29918, 1445, 353, 11860, 29879, 29918, 29995, 29875, 29918, 1050, 29889, 29882, 5137, 29908, 1273, 313, 5085, 29889, 3188, 29918, 13506, 29892, 6389, 29889, 29895, 1050, 29918, 2848, 29897, 13, 1678, 7623, 29918, 13506, 353, 11860, 29879, 29918, 29995, 29875, 29918, 1050, 29918, 29882, 391, 13342, 29908, 1273, 313, 5085, 29889, 3188, 29918, 13506, 29892, 6389, 29889, 29895, 1050, 29918, 2848, 29897, 13, 1678, 435, 14112, 15161, 29889, 29882, 5137, 29898, 3188, 29918, 1445, 29892, 298, 5137, 29918, 1445, 29892, 7568, 29918, 2798, 29922, 29896, 29900, 29900, 29900, 29900, 29900, 29900, 29900, 29897, 13, 13, 1678, 18139, 353, 5159, 13, 1678, 289, 1144, 353, 5159, 13, 13, 1678, 411, 1722, 29898, 29882, 5137, 29918, 1445, 29892, 376, 29878, 1159, 408, 298, 5137, 29918, 11512, 29901, 13, 4706, 363, 1196, 297, 298, 5137, 29918, 11512, 29901, 13, 9651, 6251, 353, 1196, 29889, 17010, 2141, 5451, 580, 13, 9651, 18139, 29889, 4397, 29898, 8269, 29961, 29896, 2314, 13, 9651, 289, 1144, 29889, 4397, 29898, 8269, 29961, 29900, 2314, 13, 13, 1678, 4377, 353, 14770, 29889, 4532, 29898, 29896, 29892, 2537, 2311, 7607, 29947, 29892, 29871, 29947, 511, 270, 1631, 29922, 29941, 29900, 29900, 29897, 13, 1678, 1014, 5317, 353, 14770, 29889, 1491, 5317, 29898, 29896, 29892, 29871, 29896, 29892, 29871, 29896, 29897, 13, 1678, 14770, 29889, 2146, 415, 1740, 703, 13398, 3224, 310, 1273, 29875, 29899, 13269, 29908, 1273, 6389, 29889, 29895, 1050, 29918, 2848, 29892, 13, 462, 4079, 7915, 2433, 8934, 1495, 13, 1678, 14770, 29889, 5317, 29898, 29890, 1144, 29892, 18139, 29897, 13, 13, 1678, 14770, 29889, 29916, 1643, 703, 6857, 666, 17024, 1159, 13, 1678, 14770, 29889, 29891, 1643, 703, 4557, 310, 8359, 2383, 414, 1159, 13, 1678, 1014, 5317, 29889, 842, 29918, 952, 29883, 744, 877, 1188, 742, 2967, 29891, 29922, 29896, 29900, 29897, 13, 1678, 1014, 5317, 29889, 842, 29918, 29916, 7052, 877, 1188, 742, 2967, 29916, 29922, 29896, 29900, 29897, 13, 1678, 363, 6081, 297, 6796, 2732, 613, 376, 15120, 3108, 29901, 13, 4706, 14770, 29889, 7620, 1003, 11702, 29879, 29889, 29995, 29879, 29908, 1273, 313, 12095, 29918, 13506, 29892, 6081, 876, 13, 13, 361, 6389, 29889, 1202, 29918, 13478, 29918, 510, 29901, 13, 1678, 2897, 29889, 5992, 703, 7382, 29918, 2248, 29889, 13140, 1159, 13, 2 ]
front_end/app.py
ofbennett/sentiment-analysis-app
2
174590
import dash import dash_core_components as dcc import dash_bootstrap_components as dbc import dash_html_components as html from dash.dependencies import Input, Output import config import requests from markdown import md1, md2 colors = {'background': 'lightcyan'} app = dash.Dash(__name__, external_stylesheets=[dbc.themes.BOOTSTRAP], meta_tags=[{"name": "viewport", "content": "width=device-width, initial-scale=1"}]) app.title = "Sentiment Analyser" sentiment_analysis_layout = html.Div( [ html.H1("Sentiment Analyzer", style={'padding-top':'20px','margin-bottom':'30px', 'text-decoration': 'underline'}), # html.Div(children="<NAME>, October 2020", style={'textAlign':'right', 'margin-right':'20px'}), html.Div(id="text-area", children=[ dcc.Textarea(id="text", placeholder="Write something here...", style={'width': '100%', 'height': 180}), dbc.Progress(id="bar", value=50, color='info') ]), html.Div(id="result", children="Sentiment Prediction", style={'margin': '10px', 'height': '1em'}), html.Div(id="markdown-area", children=[dcc.Markdown(md1, id="markdown1"), html.Img(src="assets/system_diagram.png",style = {"width": "75%", "display": "block", "margin-left": "auto", "margin-right": "auto"}), dcc.Markdown(md2, id="markdown2"),]) ], style={'textAlign':'center', 'backgroundColor': colors['background']}) app.layout = sentiment_analysis_layout @app.callback([Output('result', 'children'), Output('bar','value'), Output('bar','color')], [Input('text','value')], prevent_initial_call=True) def update_result(text): if text.strip() != '': json_data = {'text': text, 'pred_type': 'soft'} response = requests.post(config.API_URL, json=json_data) if response.status_code == 200: response_json_data = response.json() pred_val = response_json_data['pred'] pred_val = float(pred_val) if pred_val < 0.2: pred = 'Negative' bar_color = 'danger' elif 0.2 <= pred_val < 0.4: pred = 'Lean Negative' bar_color = 'info' elif 0.4 <= pred_val < 0.6: pred = 'Neutral' bar_color = 'info' elif 0.6 <= pred_val < 0.8: pred = 'Lean Positive' bar_color = 'info' else: pred = 'Positive' bar_color = 'success' return [pred, pred_val*100, bar_color] else: print(f"Error response from API. Code: {response.status_code}") return ['Sentiment Prediction', 50, 'info'] else: return ['Sentiment Prediction', 50, 'info'] server = app.server if __name__ == '__main__': app.run_server(debug=config.DEBUG, host=config.HOST)
[ 1, 1053, 12569, 13, 5215, 12569, 29918, 3221, 29918, 14036, 408, 270, 617, 13, 5215, 12569, 29918, 8704, 29918, 14036, 408, 4833, 29883, 13, 5215, 12569, 29918, 1420, 29918, 14036, 408, 3472, 13, 3166, 12569, 29889, 22594, 1053, 10567, 29892, 10604, 13, 5215, 2295, 13, 5215, 7274, 13, 3166, 2791, 3204, 1053, 22821, 29896, 29892, 22821, 29906, 13, 13, 27703, 353, 11117, 7042, 2396, 525, 4366, 1270, 273, 10827, 13, 13, 932, 353, 12569, 29889, 29928, 1161, 22168, 978, 1649, 29892, 13, 18884, 7029, 29918, 9783, 354, 1691, 11759, 11140, 29889, 386, 13826, 29889, 8456, 2891, 10810, 3301, 1402, 13, 18884, 12700, 29918, 11338, 11759, 6377, 978, 1115, 376, 1493, 637, 613, 376, 3051, 1115, 376, 2103, 29922, 10141, 29899, 2103, 29892, 2847, 29899, 7052, 29922, 29896, 9092, 2314, 13, 932, 29889, 3257, 353, 376, 29903, 296, 2073, 11597, 29891, 643, 29908, 13, 13, 18616, 2073, 29918, 15916, 29918, 2680, 353, 3472, 29889, 12596, 29898, 13, 1678, 518, 13, 4706, 3472, 29889, 29950, 29896, 703, 29903, 296, 2073, 11597, 29891, 3298, 613, 3114, 3790, 29915, 12791, 29899, 3332, 22099, 29906, 29900, 1756, 3788, 9264, 29899, 8968, 22099, 29941, 29900, 1756, 742, 525, 726, 29899, 19557, 362, 2396, 525, 15614, 29915, 9594, 13, 4706, 396, 3472, 29889, 12596, 29898, 11991, 543, 29966, 5813, 10202, 5533, 29871, 29906, 29900, 29906, 29900, 613, 3114, 3790, 29915, 726, 2499, 647, 22099, 1266, 742, 525, 9264, 29899, 1266, 22099, 29906, 29900, 1756, 29915, 9594, 13, 4706, 3472, 29889, 12596, 29898, 333, 543, 726, 29899, 6203, 613, 4344, 11759, 13, 9651, 270, 617, 29889, 1626, 6203, 29898, 333, 543, 726, 613, 12983, 543, 6113, 1554, 1244, 856, 613, 3114, 3790, 29915, 2103, 2396, 525, 29896, 29900, 29900, 29995, 742, 525, 3545, 2396, 29871, 29896, 29947, 29900, 9594, 13, 9651, 4833, 29883, 29889, 14470, 29898, 333, 543, 1646, 613, 995, 29922, 29945, 29900, 29892, 2927, 2433, 3888, 1495, 13, 4706, 4514, 511, 13, 4706, 3472, 29889, 12596, 29898, 333, 543, 2914, 613, 4344, 543, 29903, 296, 2073, 21099, 2463, 613, 3114, 3790, 29915, 9264, 2396, 525, 29896, 29900, 1756, 742, 525, 3545, 2396, 525, 29896, 331, 29915, 9594, 13, 4706, 3472, 29889, 12596, 29898, 333, 543, 3502, 3204, 29899, 6203, 613, 4344, 11759, 29881, 617, 29889, 9802, 3204, 29898, 3487, 29896, 29892, 1178, 543, 3502, 3204, 29896, 4968, 13, 462, 462, 1669, 3472, 29889, 25518, 29898, 4351, 543, 16596, 29914, 5205, 29918, 6051, 14442, 29889, 2732, 613, 3293, 353, 8853, 2103, 1115, 376, 29955, 29945, 29995, 613, 29871, 13, 462, 462, 462, 462, 462, 462, 1678, 376, 4990, 1115, 376, 1271, 613, 13, 462, 462, 462, 462, 462, 462, 1678, 376, 9264, 29899, 1563, 1115, 376, 6921, 613, 13, 462, 462, 462, 462, 462, 462, 1678, 376, 9264, 29899, 1266, 1115, 376, 6921, 9092, 511, 13, 462, 462, 1669, 270, 617, 29889, 9802, 3204, 29898, 3487, 29906, 29892, 1178, 543, 3502, 3204, 29906, 4968, 2314, 13, 1678, 21251, 3114, 3790, 29915, 726, 2499, 647, 22099, 5064, 742, 525, 29605, 2396, 11955, 1839, 7042, 2033, 1800, 13, 13, 932, 29889, 2680, 353, 19688, 29918, 15916, 29918, 2680, 13, 13, 29992, 932, 29889, 14035, 4197, 6466, 877, 2914, 742, 525, 11991, 5477, 10604, 877, 1646, 3788, 1767, 5477, 10604, 877, 1646, 3788, 2780, 1495, 1402, 13, 795, 518, 4290, 877, 726, 3788, 1767, 1495, 1402, 13, 795, 5557, 29918, 11228, 29918, 4804, 29922, 5574, 29897, 13, 1753, 2767, 29918, 2914, 29898, 726, 1125, 13, 1678, 565, 1426, 29889, 17010, 580, 2804, 525, 2396, 13, 4706, 4390, 29918, 1272, 353, 11117, 726, 2396, 1426, 29892, 525, 11965, 29918, 1853, 2396, 525, 2695, 10827, 13, 4706, 2933, 353, 7274, 29889, 2490, 29898, 2917, 29889, 8787, 29918, 4219, 29892, 4390, 29922, 3126, 29918, 1272, 29897, 13, 4706, 565, 2933, 29889, 4882, 29918, 401, 1275, 29871, 29906, 29900, 29900, 29901, 13, 9651, 2933, 29918, 3126, 29918, 1272, 353, 2933, 29889, 3126, 580, 13, 9651, 4450, 29918, 791, 353, 2933, 29918, 3126, 29918, 1272, 1839, 11965, 2033, 13, 9651, 4450, 29918, 791, 353, 5785, 29898, 11965, 29918, 791, 29897, 13, 9651, 565, 4450, 29918, 791, 529, 29871, 29900, 29889, 29906, 29901, 13, 18884, 4450, 353, 525, 29940, 387, 1230, 29915, 13, 18884, 2594, 29918, 2780, 353, 525, 29881, 4600, 29915, 13, 9651, 25342, 29871, 29900, 29889, 29906, 5277, 4450, 29918, 791, 529, 29871, 29900, 29889, 29946, 29901, 13, 18884, 4450, 353, 525, 3226, 273, 12610, 1230, 29915, 13, 18884, 2594, 29918, 2780, 353, 525, 3888, 29915, 13, 9651, 25342, 29871, 29900, 29889, 29946, 5277, 4450, 29918, 791, 529, 29871, 29900, 29889, 29953, 29901, 13, 18884, 4450, 353, 525, 8139, 329, 1705, 29915, 13, 18884, 2594, 29918, 2780, 353, 525, 3888, 29915, 13, 9651, 25342, 29871, 29900, 29889, 29953, 5277, 4450, 29918, 791, 529, 29871, 29900, 29889, 29947, 29901, 13, 18884, 4450, 353, 525, 3226, 273, 10321, 3321, 29915, 13, 18884, 2594, 29918, 2780, 353, 525, 3888, 29915, 13, 9651, 1683, 29901, 13, 18884, 4450, 353, 525, 9135, 3321, 29915, 13, 18884, 2594, 29918, 2780, 353, 525, 8698, 29915, 13, 9651, 736, 518, 11965, 29892, 4450, 29918, 791, 29930, 29896, 29900, 29900, 29892, 2594, 29918, 2780, 29962, 13, 4706, 1683, 29901, 13, 9651, 1596, 29898, 29888, 29908, 2392, 2933, 515, 3450, 29889, 5920, 29901, 426, 5327, 29889, 4882, 29918, 401, 27195, 13, 9651, 736, 6024, 29903, 296, 2073, 21099, 2463, 742, 29871, 29945, 29900, 29892, 525, 3888, 2033, 13, 1678, 1683, 29901, 13, 4706, 736, 6024, 29903, 296, 2073, 21099, 2463, 742, 29871, 29945, 29900, 29892, 525, 3888, 2033, 13, 13, 2974, 353, 623, 29889, 2974, 13, 361, 4770, 978, 1649, 1275, 525, 1649, 3396, 1649, 2396, 13, 1678, 623, 29889, 3389, 29918, 2974, 29898, 8382, 29922, 2917, 29889, 18525, 29892, 3495, 29922, 2917, 29889, 20832, 29897, 2 ]
jina/drivers/convert.py
shivam-raj/jina
0
1616282
__copyright__ = "Copyright (c) 2020 Jina AI Limited. All rights reserved." __license__ = "Apache-2.0" import base64 import os import struct import urllib.parse import urllib.request import zlib import numpy as np from . import BaseDriver from .helper import guess_mime, array2pb, pb2array class BaseConvertDriver(BaseDriver): def __init__(self, target: str, override: bool = False, *args, **kwargs): """ Set a target attribute of the document by another attribute :param target: attribute to set :param override: override the target value even when exits :param args: :param kwargs: """ super().__init__(*args, **kwargs) self.override = override self.target = target def __call__(self, *args, **kwargs): for d in self.docs: if getattr(d, self.target) and not self.override: continue self.convert(d) def convert(self, d): raise NotImplementedError class MIMEDriver(BaseConvertDriver): """Guessing the MIME type based on the doc content Can be used before/after :class:`DocCraftDriver` to fill MIME type """ def __init__(self, target='mime', default_mime: str = 'application/octet-stream', *args, **kwargs): """ :param default_mime: for text documents without a specific subtype, text/plain should be used. Similarly, for binary documents without a specific or known subtype, application/octet-stream should be used. """ super().__init__(target, *args, **kwargs) self.default_mime = default_mime self.buffer_sniff = False try: import magic self.buffer_sniff = True except (ImportError, ModuleNotFoundError): self.logger.warning(f'can not sniff the MIME type ' f'MIME sniffing requires pip install "jina[http]" ' f'and brew install libmagic (Mac)/ apt-get install libmagic1 (Linux)') def convert(self, d): import mimetypes m_type = d.mime_type if m_type and (m_type not in mimetypes.types_map.values()): m_type = mimetypes.guess_type(f'*.{m_type}')[0] if not m_type: # for ClientInputType=PROTO, d_type could be empty d_type = d.WhichOneof('content') if d_type == 'buffer': d_content = getattr(d, d_type) if self.buffer_sniff: try: import magic m_type = magic.from_buffer(d_content, mime=True) except Exception as ex: self.logger.warning(f'can not sniff the MIME type due to the exception {ex}') if d.uri: m_type = guess_mime(d.uri) if m_type: d.mime_type = m_type else: d.mime_type = self.default_mime self.logger.warning(f'can not determine the MIME type, set to default {self.default_mime}') class Buffer2NdArray(BaseConvertDriver): """Convert buffer to numpy array""" def __init__(self, target='blob', *args, **kwargs): super().__init__(target, *args, **kwargs) def convert(self, d): d.blob.CopyFrom(array2pb(np.frombuffer(d.buffer))) class Blob2PngURI(BaseConvertDriver): """Simple DocCrafter used in :command:`jina hello-world`, it reads ``buffer`` into base64 png and stored in ``uri``""" def __init__(self, target='uri', width: int = 28, height: int = 28, *args, **kwargs): super().__init__(target, *args, **kwargs) self.width = width self.height = height def convert(self, d): arr = pb2array(d.blob) pixels = [] for p in arr[::-1]: pixels.extend([255 - int(p), 255 - int(p), 255 - int(p), 255]) buf = bytearray(pixels) # reverse the vertical line order and add null bytes at the start width_byte_4 = self.width * 4 raw_data = b''.join( b'\x00' + buf[span:span + width_byte_4] for span in range((self.height - 1) * width_byte_4, -1, - width_byte_4)) def png_pack(png_tag, data): chunk_head = png_tag + data return (struct.pack('!I', len(data)) + chunk_head + struct.pack('!I', 0xFFFFFFFF & zlib.crc32(chunk_head))) png_bytes = b''.join([ b'\x89PNG\r\n\x1a\n', png_pack(b'IHDR', struct.pack('!2I5B', self.width, self.height, 8, 6, 0, 0, 0)), png_pack(b'IDAT', zlib.compress(raw_data, 9)), png_pack(b'IEND', b'')]) d.uri = 'data:image/png;base64,' + base64.b64encode(png_bytes).decode() class URI2Buffer(BaseConvertDriver): """ Convert local file path, remote URL doc to a buffer doc. """ def __init__(self, target='buffer', *args, **kwargs): super().__init__(target, *args, **kwargs) def convert(self, d): if urllib.parse.urlparse(d.uri).scheme in {'http', 'https', 'data'}: page = urllib.request.Request(d.uri, headers={'User-Agent': 'Mozilla/5.0'}) tmp = urllib.request.urlopen(page) d.buffer = tmp.read() elif os.path.exists(d.uri): with open(d.uri, 'rb') as fp: d.buffer = fp.read() else: raise FileNotFoundError(f'{d.uri} is not a URL or a valid local path') class URI2DataURI(URI2Buffer): def __init__(self, target='uri', charset: str = 'utf-8', base64: bool = False, *args, **kwargs): """ Convert file path doc to data uri doc. Internally it first reads into buffer and then converts it to data URI. :param charset: charset may be any character set registered with IANA :param base64: used to encode arbitrary octet sequences into a form that satisfies the rules of 7bit. Designed to be efficient for non-text 8 bit and binary data. Sometimes used for text data that frequently uses non-US-ASCII characters. :param args: :param kwargs: """ super().__init__(target, *args, **kwargs) self.charset = charset self.base64 = base64 def __call__(self, *args, **kwargs): super().__call__() for d in self.docs: if d.uri and not self.override: continue if d.uri and urllib.parse.urlparse(d.uri).scheme == 'data': pass else: d.uri = self.make_datauri(d.mime_type, d.buffer) def make_datauri(self, mimetype, data, binary=True): parts = ['data:', mimetype] if self.charset is not None: parts.extend([';charset=', self.charset]) if self.base64: parts.append(';base64') from base64 import encodebytes as encode64 if binary: encoded_data = encode64(data).decode(self.charset).replace('\n', '').strip() else: encoded_data = encode64(data).strip() else: from urllib.parse import quote_from_bytes, quote if binary: encoded_data = quote_from_bytes(data) else: encoded_data = quote(data) parts.extend([',', encoded_data]) return ''.join(parts) class Buffer2URI(URI2DataURI): """Convert buffer to data URI""" def convert(self, d): if urllib.parse.urlparse(d.uri).scheme == 'data': pass else: d.uri = self.make_datauri(d.mime_type, d.buffer) class Text2URI(URI2DataURI): """Convert text to data URI""" def convert(self, d): d.uri = self.make_datauri(d.mime_type, d.text, binary=False) class All2URI(Text2URI, Buffer2URI): def convert(self, d): if d.text: Text2URI.convert(self, d) elif d.buffer: Buffer2URI.convert(self, d) else: raise NotImplementedError
[ 1, 4770, 8552, 1266, 1649, 353, 376, 11882, 1266, 313, 29883, 29897, 29871, 29906, 29900, 29906, 29900, 435, 1099, 319, 29902, 28873, 29889, 2178, 10462, 21676, 1213, 13, 1649, 506, 1947, 1649, 353, 376, 17396, 1829, 29899, 29906, 29889, 29900, 29908, 13, 13, 5215, 2967, 29953, 29946, 13, 5215, 2897, 13, 5215, 2281, 13, 5215, 3142, 1982, 29889, 5510, 13, 5215, 3142, 1982, 29889, 3827, 13, 5215, 503, 1982, 13, 13, 5215, 12655, 408, 7442, 13, 13, 3166, 869, 1053, 7399, 12376, 13, 3166, 869, 20907, 1053, 4140, 29918, 29885, 603, 29892, 1409, 29906, 24381, 29892, 282, 29890, 29906, 2378, 13, 13, 13, 1990, 7399, 18455, 12376, 29898, 5160, 12376, 1125, 13, 13, 1678, 822, 4770, 2344, 12035, 1311, 29892, 3646, 29901, 851, 29892, 5712, 29901, 6120, 353, 7700, 29892, 334, 5085, 29892, 3579, 19290, 1125, 13, 4706, 9995, 3789, 263, 3646, 5352, 310, 278, 1842, 491, 1790, 5352, 13, 13, 4706, 584, 3207, 3646, 29901, 5352, 304, 731, 13, 4706, 584, 3207, 5712, 29901, 5712, 278, 3646, 995, 1584, 746, 429, 1169, 13, 4706, 584, 3207, 6389, 29901, 13, 4706, 584, 3207, 9049, 5085, 29901, 13, 4706, 9995, 13, 4706, 2428, 2141, 1649, 2344, 1649, 10456, 5085, 29892, 3579, 19290, 29897, 13, 4706, 1583, 29889, 15752, 353, 5712, 13, 4706, 1583, 29889, 5182, 353, 3646, 13, 13, 1678, 822, 4770, 4804, 12035, 1311, 29892, 334, 5085, 29892, 3579, 19290, 1125, 13, 4706, 363, 270, 297, 1583, 29889, 2640, 29901, 13, 9651, 565, 679, 5552, 29898, 29881, 29892, 1583, 29889, 5182, 29897, 322, 451, 1583, 29889, 15752, 29901, 13, 18884, 6773, 13, 9651, 1583, 29889, 13441, 29898, 29881, 29897, 13, 13, 1678, 822, 3588, 29898, 1311, 29892, 270, 1125, 13, 4706, 12020, 2216, 1888, 2037, 287, 2392, 13, 13, 13, 1990, 341, 8890, 12376, 29898, 5160, 18455, 12376, 1125, 13, 1678, 9995, 9485, 404, 292, 278, 341, 8890, 1134, 2729, 373, 278, 1574, 2793, 13, 13, 1678, 1815, 367, 1304, 1434, 29914, 7045, 584, 1990, 18078, 14526, 29907, 4154, 12376, 29952, 304, 5445, 341, 8890, 1134, 13, 1678, 9995, 13, 13, 1678, 822, 4770, 2344, 12035, 1311, 29892, 3646, 2433, 29885, 603, 742, 2322, 29918, 29885, 603, 29901, 851, 353, 525, 6214, 29914, 20082, 300, 29899, 5461, 742, 334, 5085, 29892, 3579, 19290, 1125, 13, 4706, 9995, 13, 13, 4706, 584, 3207, 2322, 29918, 29885, 603, 29901, 363, 1426, 10701, 1728, 263, 2702, 1014, 1853, 29892, 1426, 29914, 24595, 881, 367, 1304, 29889, 13, 9651, 20175, 29892, 363, 7581, 10701, 1728, 263, 2702, 470, 2998, 1014, 1853, 29892, 2280, 29914, 20082, 300, 29899, 5461, 881, 367, 1304, 29889, 13, 4706, 9995, 13, 4706, 2428, 2141, 1649, 2344, 12035, 5182, 29892, 334, 5085, 29892, 3579, 19290, 29897, 13, 4706, 1583, 29889, 4381, 29918, 29885, 603, 353, 2322, 29918, 29885, 603, 13, 4706, 1583, 29889, 9040, 29918, 16586, 2593, 353, 7700, 13, 4706, 1018, 29901, 13, 9651, 1053, 15709, 13, 9651, 1583, 29889, 9040, 29918, 16586, 2593, 353, 5852, 13, 4706, 5174, 313, 17518, 2392, 29892, 15591, 17413, 2392, 1125, 13, 9651, 1583, 29889, 21707, 29889, 27392, 29898, 29888, 29915, 3068, 451, 5807, 2593, 278, 341, 8890, 1134, 525, 13, 462, 18884, 285, 29915, 29924, 8890, 5807, 2593, 292, 6858, 8450, 2601, 376, 29926, 1099, 29961, 1124, 18017, 525, 13, 462, 18884, 285, 29915, 392, 2078, 29893, 2601, 4303, 11082, 293, 313, 15735, 6802, 10882, 29899, 657, 2601, 4303, 11082, 293, 29896, 313, 24085, 29897, 1495, 13, 13, 1678, 822, 3588, 29898, 1311, 29892, 270, 1125, 13, 4706, 1053, 286, 17528, 7384, 13, 4706, 286, 29918, 1853, 353, 270, 29889, 29885, 603, 29918, 1853, 13, 4706, 565, 286, 29918, 1853, 322, 313, 29885, 29918, 1853, 451, 297, 286, 17528, 7384, 29889, 8768, 29918, 1958, 29889, 5975, 580, 1125, 13, 9651, 286, 29918, 1853, 353, 286, 17528, 7384, 29889, 2543, 404, 29918, 1853, 29898, 29888, 29915, 10521, 29912, 29885, 29918, 1853, 29913, 29861, 29900, 29962, 13, 13, 4706, 565, 451, 286, 29918, 1853, 29901, 29871, 396, 363, 12477, 4290, 1542, 29922, 8618, 4986, 29892, 270, 29918, 1853, 1033, 367, 4069, 13, 9651, 270, 29918, 1853, 353, 270, 29889, 8809, 436, 6716, 974, 877, 3051, 1495, 13, 9651, 565, 270, 29918, 1853, 1275, 525, 9040, 2396, 13, 18884, 270, 29918, 3051, 353, 679, 5552, 29898, 29881, 29892, 270, 29918, 1853, 29897, 13, 18884, 565, 1583, 29889, 9040, 29918, 16586, 2593, 29901, 13, 462, 1678, 1018, 29901, 13, 462, 4706, 1053, 15709, 13, 462, 4706, 286, 29918, 1853, 353, 15709, 29889, 3166, 29918, 9040, 29898, 29881, 29918, 3051, 29892, 286, 603, 29922, 5574, 29897, 13, 462, 1678, 5174, 8960, 408, 429, 29901, 13, 462, 4706, 1583, 29889, 21707, 29889, 27392, 29898, 29888, 29915, 3068, 451, 5807, 2593, 278, 341, 8890, 1134, 2861, 304, 278, 3682, 426, 735, 29913, 1495, 13, 9651, 565, 270, 29889, 5338, 29901, 13, 18884, 286, 29918, 1853, 353, 4140, 29918, 29885, 603, 29898, 29881, 29889, 5338, 29897, 13, 13, 4706, 565, 286, 29918, 1853, 29901, 13, 9651, 270, 29889, 29885, 603, 29918, 1853, 353, 286, 29918, 1853, 13, 4706, 1683, 29901, 13, 9651, 270, 29889, 29885, 603, 29918, 1853, 353, 1583, 29889, 4381, 29918, 29885, 603, 13, 9651, 1583, 29889, 21707, 29889, 27392, 29898, 29888, 29915, 3068, 451, 8161, 278, 341, 8890, 1134, 29892, 731, 304, 2322, 426, 1311, 29889, 4381, 29918, 29885, 603, 29913, 1495, 13, 13, 13, 1990, 16534, 29906, 29940, 29881, 2588, 29898, 5160, 18455, 12376, 1125, 13, 1678, 9995, 18455, 6835, 304, 12655, 1409, 15945, 29908, 13, 13, 1678, 822, 4770, 2344, 12035, 1311, 29892, 3646, 2433, 10054, 742, 334, 5085, 29892, 3579, 19290, 1125, 13, 4706, 2428, 2141, 1649, 2344, 12035, 5182, 29892, 334, 5085, 29892, 3579, 19290, 29897, 13, 13, 1678, 822, 3588, 29898, 1311, 29892, 270, 1125, 13, 4706, 270, 29889, 10054, 29889, 11882, 4591, 29898, 2378, 29906, 24381, 29898, 9302, 29889, 3166, 9040, 29898, 29881, 29889, 9040, 4961, 13, 13, 13, 1990, 350, 2127, 29906, 29925, 865, 15551, 29898, 5160, 18455, 12376, 1125, 13, 1678, 9995, 15427, 28197, 29907, 336, 906, 1304, 297, 584, 6519, 18078, 29926, 1099, 22172, 29899, 11526, 1673, 13, 4706, 372, 13623, 4954, 9040, 16159, 964, 2967, 29953, 29946, 282, 865, 322, 6087, 297, 4954, 5338, 16159, 15945, 29908, 13, 13, 1678, 822, 4770, 2344, 12035, 1311, 29892, 3646, 2433, 5338, 742, 2920, 29901, 938, 353, 29871, 29906, 29947, 29892, 3171, 29901, 938, 353, 29871, 29906, 29947, 29892, 334, 5085, 29892, 3579, 19290, 1125, 13, 4706, 2428, 2141, 1649, 2344, 12035, 5182, 29892, 334, 5085, 29892, 3579, 19290, 29897, 13, 4706, 1583, 29889, 2103, 353, 2920, 13, 4706, 1583, 29889, 3545, 353, 3171, 13, 13, 1678, 822, 3588, 29898, 1311, 29892, 270, 1125, 13, 4706, 3948, 353, 282, 29890, 29906, 2378, 29898, 29881, 29889, 10054, 29897, 13, 4706, 17036, 353, 5159, 13, 4706, 363, 282, 297, 3948, 29961, 1057, 29899, 29896, 5387, 13, 9651, 17036, 29889, 21843, 4197, 29906, 29945, 29945, 448, 938, 29898, 29886, 511, 29871, 29906, 29945, 29945, 448, 938, 29898, 29886, 511, 29871, 29906, 29945, 29945, 448, 938, 29898, 29886, 511, 29871, 29906, 29945, 29945, 2314, 13, 4706, 18392, 353, 7023, 2378, 29898, 29886, 861, 1379, 29897, 13, 13, 4706, 396, 11837, 278, 11408, 1196, 1797, 322, 788, 1870, 6262, 472, 278, 1369, 13, 4706, 2920, 29918, 10389, 29918, 29946, 353, 1583, 29889, 2103, 334, 29871, 29946, 13, 4706, 10650, 29918, 1272, 353, 289, 29915, 4286, 7122, 29898, 13, 9651, 289, 12764, 29916, 29900, 29900, 29915, 718, 18392, 29961, 9653, 29901, 9653, 718, 2920, 29918, 10389, 29918, 29946, 29962, 13, 9651, 363, 10638, 297, 3464, 3552, 1311, 29889, 3545, 448, 29871, 29896, 29897, 334, 2920, 29918, 10389, 29918, 29946, 29892, 448, 29896, 29892, 448, 2920, 29918, 10389, 29918, 29946, 876, 13, 13, 4706, 822, 282, 865, 29918, 4058, 29898, 2732, 29918, 4039, 29892, 848, 1125, 13, 9651, 19875, 29918, 2813, 353, 282, 865, 29918, 4039, 718, 848, 13, 9651, 736, 313, 4984, 29889, 4058, 877, 29991, 29902, 742, 7431, 29898, 1272, 876, 718, 13, 462, 1678, 19875, 29918, 2813, 718, 13, 462, 1678, 2281, 29889, 4058, 877, 29991, 29902, 742, 29871, 29900, 29916, 22098, 22098, 669, 503, 1982, 29889, 29883, 2214, 29941, 29906, 29898, 29812, 29918, 2813, 4961, 13, 13, 4706, 282, 865, 29918, 13193, 353, 289, 29915, 4286, 7122, 4197, 13, 9651, 289, 12764, 29916, 29947, 29929, 29925, 9312, 29905, 29878, 29905, 29876, 29905, 29916, 29896, 29874, 29905, 29876, 742, 13, 9651, 282, 865, 29918, 4058, 29898, 29890, 29915, 29902, 29950, 8353, 742, 2281, 29889, 4058, 877, 29991, 29906, 29902, 29945, 29933, 742, 1583, 29889, 2103, 29892, 1583, 29889, 3545, 29892, 29871, 29947, 29892, 29871, 29953, 29892, 29871, 29900, 29892, 29871, 29900, 29892, 29871, 29900, 8243, 13, 9651, 282, 865, 29918, 4058, 29898, 29890, 29915, 1367, 1299, 742, 503, 1982, 29889, 510, 2139, 29898, 1610, 29918, 1272, 29892, 29871, 29929, 8243, 13, 9651, 282, 865, 29918, 4058, 29898, 29890, 29915, 29902, 11794, 742, 289, 29915, 1495, 2314, 13, 4706, 270, 29889, 5338, 353, 525, 1272, 29901, 3027, 29914, 2732, 29936, 3188, 29953, 29946, 5501, 718, 2967, 29953, 29946, 29889, 29890, 29953, 29946, 12508, 29898, 2732, 29918, 13193, 467, 13808, 580, 13, 13, 13, 1990, 23539, 29906, 7701, 29898, 5160, 18455, 12376, 1125, 13, 1678, 9995, 14806, 1887, 934, 2224, 29892, 7592, 3988, 1574, 304, 263, 6835, 1574, 29889, 13, 1678, 9995, 13, 13, 1678, 822, 4770, 2344, 12035, 1311, 29892, 3646, 2433, 9040, 742, 334, 5085, 29892, 3579, 19290, 1125, 13, 4706, 2428, 2141, 1649, 2344, 12035, 5182, 29892, 334, 5085, 29892, 3579, 19290, 29897, 13, 13, 1678, 822, 3588, 29898, 1311, 29892, 270, 1125, 13, 4706, 565, 3142, 1982, 29889, 5510, 29889, 2271, 5510, 29898, 29881, 29889, 5338, 467, 816, 2004, 297, 11117, 1124, 742, 525, 991, 742, 525, 1272, 29915, 6177, 13, 9651, 1813, 353, 3142, 1982, 29889, 3827, 29889, 3089, 29898, 29881, 29889, 5338, 29892, 9066, 3790, 29915, 2659, 29899, 19661, 2396, 525, 29924, 2112, 2911, 29914, 29945, 29889, 29900, 29915, 1800, 13, 9651, 13128, 353, 3142, 1982, 29889, 3827, 29889, 332, 417, 2238, 29898, 3488, 29897, 13, 9651, 270, 29889, 9040, 353, 13128, 29889, 949, 580, 13, 4706, 25342, 2897, 29889, 2084, 29889, 9933, 29898, 29881, 29889, 5338, 1125, 13, 9651, 411, 1722, 29898, 29881, 29889, 5338, 29892, 525, 6050, 1495, 408, 285, 29886, 29901, 13, 18884, 270, 29889, 9040, 353, 285, 29886, 29889, 949, 580, 13, 4706, 1683, 29901, 13, 9651, 12020, 3497, 17413, 2392, 29898, 29888, 29915, 29912, 29881, 29889, 5338, 29913, 338, 451, 263, 3988, 470, 263, 2854, 1887, 2224, 1495, 13, 13, 13, 1990, 23539, 29906, 1469, 15551, 29898, 15551, 29906, 7701, 1125, 13, 1678, 822, 4770, 2344, 12035, 1311, 29892, 3646, 2433, 5338, 742, 17425, 29901, 851, 353, 525, 9420, 29899, 29947, 742, 2967, 29953, 29946, 29901, 6120, 353, 7700, 29892, 334, 5085, 29892, 3579, 19290, 1125, 13, 4706, 9995, 14806, 934, 2224, 1574, 304, 848, 21333, 1574, 29889, 2422, 635, 372, 937, 13623, 964, 6835, 322, 769, 29436, 372, 304, 848, 23539, 29889, 13, 13, 4706, 584, 3207, 17425, 29901, 17425, 1122, 367, 738, 2931, 731, 15443, 411, 306, 2190, 29909, 13, 4706, 584, 3207, 2967, 29953, 29946, 29901, 1304, 304, 19750, 11472, 4725, 300, 15602, 964, 263, 883, 393, 17150, 278, 6865, 310, 29871, 29955, 2966, 29889, 12037, 287, 304, 367, 8543, 363, 1661, 29899, 726, 29871, 29947, 2586, 322, 7581, 848, 29889, 18512, 1304, 363, 1426, 848, 393, 13672, 3913, 1661, 29899, 3308, 29899, 28599, 2687, 4890, 29889, 13, 4706, 584, 3207, 6389, 29901, 13, 4706, 584, 3207, 9049, 5085, 29901, 13, 4706, 9995, 13, 4706, 2428, 2141, 1649, 2344, 12035, 5182, 29892, 334, 5085, 29892, 3579, 19290, 29897, 13, 4706, 1583, 29889, 3090, 842, 353, 17425, 13, 4706, 1583, 29889, 3188, 29953, 29946, 353, 2967, 29953, 29946, 13, 13, 1678, 822, 4770, 4804, 12035, 1311, 29892, 334, 5085, 29892, 3579, 19290, 1125, 13, 4706, 2428, 2141, 1649, 4804, 1649, 580, 13, 4706, 363, 270, 297, 1583, 29889, 2640, 29901, 13, 9651, 565, 270, 29889, 5338, 322, 451, 1583, 29889, 15752, 29901, 13, 18884, 6773, 13, 13, 9651, 565, 270, 29889, 5338, 322, 3142, 1982, 29889, 5510, 29889, 2271, 5510, 29898, 29881, 29889, 5338, 467, 816, 2004, 1275, 525, 1272, 2396, 13, 18884, 1209, 13, 9651, 1683, 29901, 13, 18884, 270, 29889, 5338, 353, 1583, 29889, 5675, 29918, 1272, 5338, 29898, 29881, 29889, 29885, 603, 29918, 1853, 29892, 270, 29889, 9040, 29897, 13, 13, 1678, 822, 1207, 29918, 1272, 5338, 29898, 1311, 29892, 286, 17528, 668, 29892, 848, 29892, 7581, 29922, 5574, 1125, 13, 4706, 5633, 353, 6024, 1272, 29901, 742, 286, 17528, 668, 29962, 13, 4706, 565, 1583, 29889, 3090, 842, 338, 451, 6213, 29901, 13, 9651, 5633, 29889, 21843, 18959, 29936, 3090, 842, 29922, 742, 1583, 29889, 3090, 842, 2314, 13, 4706, 565, 1583, 29889, 3188, 29953, 29946, 29901, 13, 9651, 5633, 29889, 4397, 877, 29936, 3188, 29953, 29946, 1495, 13, 9651, 515, 2967, 29953, 29946, 1053, 19750, 13193, 408, 19750, 29953, 29946, 13, 9651, 565, 7581, 29901, 13, 18884, 18511, 29918, 1272, 353, 19750, 29953, 29946, 29898, 1272, 467, 13808, 29898, 1311, 29889, 3090, 842, 467, 6506, 28909, 29876, 742, 525, 2824, 17010, 580, 13, 9651, 1683, 29901, 13, 18884, 18511, 29918, 1272, 353, 19750, 29953, 29946, 29898, 1272, 467, 17010, 580, 13, 4706, 1683, 29901, 13, 9651, 515, 3142, 1982, 29889, 5510, 1053, 14978, 29918, 3166, 29918, 13193, 29892, 14978, 13, 9651, 565, 7581, 29901, 13, 18884, 18511, 29918, 1272, 353, 14978, 29918, 3166, 29918, 13193, 29898, 1272, 29897, 13, 9651, 1683, 29901, 13, 18884, 18511, 29918, 1272, 353, 14978, 29898, 1272, 29897, 13, 4706, 5633, 29889, 21843, 4197, 742, 742, 18511, 29918, 1272, 2314, 13, 4706, 736, 525, 4286, 7122, 29898, 20895, 29897, 13, 13, 13, 1990, 16534, 29906, 15551, 29898, 15551, 29906, 1469, 15551, 1125, 13, 1678, 9995, 18455, 6835, 304, 848, 23539, 15945, 29908, 13, 13, 1678, 822, 3588, 29898, 1311, 29892, 270, 1125, 13, 4706, 565, 3142, 1982, 29889, 5510, 29889, 2271, 5510, 29898, 29881, 29889, 5338, 467, 816, 2004, 1275, 525, 1272, 2396, 13, 9651, 1209, 13, 4706, 1683, 29901, 13, 9651, 270, 29889, 5338, 353, 1583, 29889, 5675, 29918, 1272, 5338, 29898, 29881, 29889, 29885, 603, 29918, 1853, 29892, 270, 29889, 9040, 29897, 13, 13, 13, 1990, 3992, 29906, 15551, 29898, 15551, 29906, 1469, 15551, 1125, 13, 1678, 9995, 18455, 1426, 304, 848, 23539, 15945, 29908, 13, 13, 1678, 822, 3588, 29898, 1311, 29892, 270, 1125, 13, 4706, 270, 29889, 5338, 353, 1583, 29889, 5675, 29918, 1272, 5338, 29898, 29881, 29889, 29885, 603, 29918, 1853, 29892, 270, 29889, 726, 29892, 7581, 29922, 8824, 29897, 13, 13, 13, 1990, 2178, 29906, 15551, 29898, 1626, 29906, 15551, 29892, 16534, 29906, 15551, 1125, 13, 13, 1678, 822, 3588, 29898, 1311, 29892, 270, 1125, 13, 4706, 565, 270, 29889, 726, 29901, 13, 9651, 3992, 29906, 15551, 29889, 13441, 29898, 1311, 29892, 270, 29897, 13, 4706, 25342, 270, 29889, 9040, 29901, 13, 9651, 16534, 29906, 15551, 29889, 13441, 29898, 1311, 29892, 270, 29897, 13, 4706, 1683, 29901, 13, 9651, 12020, 2216, 1888, 2037, 287, 2392, 13, 2 ]
Chapter08/lecture02.py
ee06b056/IntoToProgramInPython
0
48797
import datetime class Person(object): def __init__(self, name): self.name = name try: lastBlank = name.rindex(' ') self.lastName = name[lastBlank+1:] except: self.lastName = name self.birthday = None def getName(self): return self.name def getLastName(self): return self.lastName def setBirthday(self, birthday): self.birthday = birthday def getAge(self): if self.birthday == None: raise ValueError return (datetime.date.today() - self.birthday).days def __lt__(self, other): if self.lastName == other.lastName: return self.name < other.name return self.lastName < other.lastName def __str__(self): return self.name class MITPerson(Person): nextIdNum = 0 def __init__(self,name): Person.__init__(self, name) self.idNum = MITPerson.nextIdNum MITPerson.nextIdNum += 1 def getIdNum(self): return self.idNum def __lt__(self, other): return self.idNum < other.idNum class Student(MITPerson): pass class UG(Student): def __init__(self, name, classYear): Student.__init__(self, name) self.year = classYear def getClass(self): return self.year class Grad(Student): pass class TransferStudent(Student): def __init__(self, name, fromSchool): Student.__init__(self, name) self.fromSchool = fromSchool def getOldSchool(self): return self.fromSchool class Grades(object): def __init__(self): self.students = [] p5 = Grad('<NAME>') p6 = UG('<NAME>', 1984) print(p5) print(type(p5)==Grad) print(p6, type(p6) == UG) print(UG) me = Person('<NAME>') him = Person('<NAME>') her = Person('Madonna') print(him.getLastName()) him.setBirthday(datetime.date(1961,8,4)) her.setBirthday(datetime.date(1958, 8, 16)) p1 = MITPerson('<NAME>') print(str(p1) + '\'s id number is ' + str(p1.getIdNum()))
[ 1, 1053, 12865, 13, 13, 1990, 5196, 29898, 3318, 1125, 13, 268, 13, 1678, 822, 4770, 2344, 12035, 1311, 29892, 1024, 1125, 13, 4706, 1583, 29889, 978, 353, 1024, 13, 4706, 1018, 29901, 13, 9651, 1833, 10358, 804, 353, 1024, 29889, 29878, 2248, 877, 25710, 13, 9651, 1583, 29889, 4230, 1170, 353, 1024, 29961, 4230, 10358, 804, 29974, 29896, 17531, 13, 4706, 5174, 29901, 13, 9651, 1583, 29889, 4230, 1170, 353, 1024, 13, 4706, 1583, 29889, 29890, 7515, 3250, 353, 6213, 13, 13, 1678, 822, 679, 1170, 29898, 1311, 1125, 13, 4706, 736, 1583, 29889, 978, 13, 13, 1678, 822, 679, 8897, 1170, 29898, 1311, 1125, 13, 4706, 736, 1583, 29889, 4230, 1170, 13, 13, 1678, 822, 731, 29933, 7515, 3250, 29898, 1311, 29892, 12060, 3250, 1125, 13, 4706, 1583, 29889, 29890, 7515, 3250, 353, 12060, 3250, 13, 13, 1678, 822, 679, 22406, 29898, 1311, 1125, 13, 4706, 565, 1583, 29889, 29890, 7515, 3250, 1275, 6213, 29901, 13, 9651, 12020, 7865, 2392, 13, 4706, 736, 313, 12673, 29889, 1256, 29889, 27765, 580, 448, 1583, 29889, 29890, 7515, 3250, 467, 16700, 13, 13, 1678, 822, 4770, 1896, 12035, 1311, 29892, 916, 1125, 13, 4706, 565, 1583, 29889, 4230, 1170, 1275, 916, 29889, 4230, 1170, 29901, 13, 9651, 736, 1583, 29889, 978, 529, 916, 29889, 978, 13, 4706, 736, 1583, 29889, 4230, 1170, 529, 916, 29889, 4230, 1170, 13, 268, 13, 1678, 822, 4770, 710, 12035, 1311, 1125, 13, 4706, 736, 1583, 29889, 978, 13, 13, 1990, 341, 1806, 7435, 29898, 7435, 1125, 13, 1678, 2446, 1204, 8009, 353, 29871, 29900, 13, 13, 1678, 822, 4770, 2344, 12035, 1311, 29892, 978, 1125, 13, 4706, 5196, 17255, 2344, 12035, 1311, 29892, 1024, 29897, 13, 4706, 1583, 29889, 333, 8009, 353, 341, 1806, 7435, 29889, 4622, 1204, 8009, 13, 4706, 341, 1806, 7435, 29889, 4622, 1204, 8009, 4619, 29871, 29896, 13, 268, 13, 1678, 822, 679, 1204, 8009, 29898, 1311, 1125, 13, 4706, 736, 1583, 29889, 333, 8009, 13, 268, 13, 1678, 822, 4770, 1896, 12035, 1311, 29892, 916, 1125, 13, 4706, 736, 1583, 29889, 333, 8009, 529, 916, 29889, 333, 8009, 13, 13, 1990, 15740, 29898, 26349, 7435, 1125, 13, 1678, 1209, 13, 13, 1990, 501, 29954, 29898, 20791, 1125, 13, 1678, 822, 4770, 2344, 12035, 1311, 29892, 1024, 29892, 770, 12883, 1125, 13, 4706, 15740, 17255, 2344, 12035, 1311, 29892, 1024, 29897, 13, 4706, 1583, 29889, 6360, 353, 770, 12883, 13, 268, 13, 1678, 822, 679, 2385, 29898, 1311, 1125, 13, 4706, 736, 1583, 29889, 6360, 13, 268, 13, 1990, 19295, 29898, 20791, 1125, 13, 1678, 1209, 13, 13, 1990, 17934, 20791, 29898, 20791, 1125, 13, 1678, 822, 4770, 2344, 12035, 1311, 29892, 1024, 29892, 515, 4504, 1507, 1125, 13, 4706, 15740, 17255, 2344, 12035, 1311, 29892, 1024, 29897, 13, 4706, 1583, 29889, 3166, 4504, 1507, 353, 515, 4504, 1507, 13, 13, 1678, 822, 679, 21648, 4504, 1507, 29898, 1311, 1125, 13, 4706, 736, 1583, 29889, 3166, 4504, 1507, 13, 13, 1990, 1632, 3076, 29898, 3318, 1125, 13, 1678, 822, 4770, 2344, 12035, 1311, 1125, 13, 4706, 1583, 29889, 18082, 1237, 353, 5159, 13, 308, 13, 13, 13, 13, 29886, 29945, 353, 19295, 877, 29966, 5813, 29958, 1495, 13, 29886, 29953, 353, 501, 29954, 877, 29966, 5813, 29958, 742, 29871, 29896, 29929, 29947, 29946, 29897, 13, 2158, 29898, 29886, 29945, 29897, 13, 2158, 29898, 1853, 29898, 29886, 29945, 29897, 1360, 25584, 29897, 13, 2158, 29898, 29886, 29953, 29892, 1134, 29898, 29886, 29953, 29897, 1275, 501, 29954, 29897, 13, 13, 2158, 29898, 23338, 29897, 13, 13, 13, 13, 1004, 353, 5196, 877, 29966, 5813, 29958, 1495, 13, 26994, 353, 5196, 877, 29966, 5813, 29958, 1495, 13, 2276, 353, 5196, 877, 21878, 11586, 1495, 13, 13, 2158, 29898, 26994, 29889, 657, 8897, 1170, 3101, 13, 13, 26994, 29889, 842, 29933, 7515, 3250, 29898, 12673, 29889, 1256, 29898, 29896, 29929, 29953, 29896, 29892, 29947, 29892, 29946, 876, 13, 2276, 29889, 842, 29933, 7515, 3250, 29898, 12673, 29889, 1256, 29898, 29896, 29929, 29945, 29947, 29892, 29871, 29947, 29892, 29871, 29896, 29953, 876, 13, 13, 29886, 29896, 353, 341, 1806, 7435, 877, 29966, 5813, 29958, 1495, 13, 2158, 29898, 710, 29898, 29886, 29896, 29897, 718, 11297, 29915, 29879, 1178, 1353, 338, 525, 718, 851, 29898, 29886, 29896, 29889, 657, 1204, 8009, 22130, 2 ]
Game.py
RHorton97/Hangman-Game
0
148477
<reponame>RHorton97/Hangman-Game import random as rand class Game(): """Holds setup functions and key gameplay data such as the word being guessed""" def __init__(self): self.name = input("What is your name? ") self.guesses = 5 self.word = self.wordSelect() self.wordLength = len(self.word) self.unguessedLetters = self.wordLength self.wordWithGuesses = self.wordForGuesses(self.word) self.playerWins = False self.guessWrong = False self.gameOver = False def beginGame(self): """Begins the game by stating the length of the word and showing a blank space with underscores to represent each letter of the word""" print("You have " + str(self.guesses) + " wrong guesses") print("\nThe word is " + str(self.wordLength) + " letters long") print(self.unguessedLetters * "_ " + "\n") def resetGame(self): self.gameOver = False self.guesses = 5 self.word = self.wordSelect() self.wordLength = len(self.word) self.unguessedLetters = self.wordLength self.wordWithGuesses = self.wordForGuesses(self.word) def guessDown(self): """Remove one guess from total remaining guesses""" self.guesses = self.guesses - 1 def wordSelect(self): """Selects a word from the wordList file and stores it to be used in the game""" # wordNum range starts from 1 to ensuure that the source URL in the # wordList file is never selected as the word wordNum = rand.randint(1, 1000) wordList = open("wordList.txt", "r") for i in range(wordNum + 1): if i == wordNum: word = wordList.readline() word = word[:-1] else: wordList.readline() wordList.close() return word def wordForGuesses(self, word): """Creates a list containing one underscore as an element for each letter of the chosen word which is taken as input to the function""" wordListed = [] for letter in word: wordListed.append("_") return wordListed def wordGuess(self): """Allows the user to input a word as a guess, if the word is correct then the player wins the game, if the word is not correct then the player is told and the list of guessed and unguessed letters is printed so that it is visible to the player""" wordGuessed = input("What is your guess? ") if wordGuessed == self.word: self.playerWins = True print("Congratulations! You guessed correctly, the word was " + self.word + "!") self.gameWon() else: print("Sorry, that isn't the word") self.guessDown() self.lifeCheck() def letterGuess(self): """Allows the user to input a letter as a guess, if the letter is in the word then it replaces the appropriate characters in the list created by wordForGuesses, if the letter is not in the word then the player is told that they were wrong. The list containing underscores and letters is displayed at the end of the function each time in order to ensure it is visible to the player at all times""" letterGuessed = input("What is your guess? ") if letterGuessed in self.word: i = 0 for letter in self.word: if letter == letterGuessed: self.wordWithGuesses[i] = letterGuessed i = i + 1 else: print("Sorry, that letter isn't in the word") self.guessDown() self.lifeCheck() self.allLettersCheck() if self.playerWins == False: if self.unguessedLetters == 1: print("There is " + str(self.unguessedLetters) + " letter left to guess\n") else: print("There are " + str(self.unguessedLetters) + " letters left to guess\n") showWordGuesses = "" for letter in self.wordWithGuesses: showWordGuesses = showWordGuesses + letter + " " print(showWordGuesses + "\n") def allLettersCheck(self): """Checks if the player has guessed all the letters in the word correctly, if they have then the player wins the game, if not the function determines how many letters are left to be guessed and updates the unguessed letters value""" if "_" not in self.wordWithGuesses: self.playerWins = True self.gameWon() else: i = 0 for letter in self.wordWithGuesses: if letter == "_": i = i + 1 else: continue self.unguessedLetters = i def lifeCheck(self): if self.guesses <= 0: print("You have no wrong guesses remaining") self.gameLost() else: print("You have " + str(self.guesses) + " wrong guesses left") def gameWon(self): """This function tells the player they have won""" self.gameOver = True print("\nCongratulations " + self.name + "! You Win!") def gameLost(self): """This function tells the player they have lost""" self.gameOver = True print("\nThe word was " + self.word) print("\nSorry " + self.name + ". You Lose!")
[ 1, 529, 276, 1112, 420, 29958, 29934, 29950, 26342, 29929, 29955, 29914, 29950, 574, 1171, 29899, 14199, 13, 5215, 4036, 408, 20088, 13, 13, 13, 1990, 8448, 7295, 13, 1678, 9995, 29950, 3361, 6230, 3168, 322, 1820, 3748, 1456, 848, 1316, 408, 278, 1734, 1641, 13, 539, 4140, 287, 15945, 29908, 13, 13, 1678, 822, 4770, 2344, 12035, 1311, 1125, 13, 4706, 1583, 29889, 978, 353, 1881, 703, 5618, 338, 596, 1024, 29973, 16521, 13, 4706, 1583, 29889, 2543, 15322, 353, 29871, 29945, 13, 4706, 1583, 29889, 1742, 353, 1583, 29889, 1742, 3549, 580, 13, 4706, 1583, 29889, 1742, 6513, 353, 7431, 29898, 1311, 29889, 1742, 29897, 13, 4706, 1583, 29889, 686, 29884, 11517, 12024, 2153, 353, 1583, 29889, 1742, 6513, 13, 4706, 1583, 29889, 1742, 3047, 9485, 15322, 353, 1583, 29889, 1742, 2831, 9485, 15322, 29898, 1311, 29889, 1742, 29897, 13, 4706, 1583, 29889, 9106, 29956, 1144, 353, 7700, 13, 4706, 1583, 29889, 2543, 404, 29956, 29373, 353, 7700, 13, 4706, 1583, 29889, 11802, 3563, 353, 7700, 13, 13, 1678, 822, 3380, 14199, 29898, 1311, 1125, 13, 4706, 9995, 17946, 29879, 278, 3748, 491, 23659, 278, 3309, 310, 278, 1734, 322, 6445, 263, 9654, 2913, 411, 23400, 29883, 2361, 304, 2755, 13, 965, 1269, 5497, 310, 278, 1734, 15945, 29908, 13, 4706, 1596, 703, 3492, 505, 376, 718, 851, 29898, 1311, 29889, 2543, 15322, 29897, 718, 376, 2743, 4140, 267, 1159, 13, 4706, 1596, 14182, 29876, 1576, 1734, 338, 376, 718, 851, 29898, 1311, 29889, 1742, 6513, 29897, 718, 376, 8721, 1472, 1159, 13, 4706, 1596, 29898, 1311, 29889, 686, 29884, 11517, 12024, 2153, 334, 11119, 376, 718, 6634, 29876, 1159, 13, 13, 1678, 822, 10092, 14199, 29898, 1311, 1125, 13, 4706, 1583, 29889, 11802, 3563, 353, 7700, 13, 4706, 1583, 29889, 2543, 15322, 353, 29871, 29945, 13, 4706, 1583, 29889, 1742, 353, 1583, 29889, 1742, 3549, 580, 13, 4706, 1583, 29889, 1742, 6513, 353, 7431, 29898, 1311, 29889, 1742, 29897, 13, 4706, 1583, 29889, 686, 29884, 11517, 12024, 2153, 353, 1583, 29889, 1742, 6513, 13, 4706, 1583, 29889, 1742, 3047, 9485, 15322, 353, 1583, 29889, 1742, 2831, 9485, 15322, 29898, 1311, 29889, 1742, 29897, 13, 13, 1678, 822, 4140, 6767, 29898, 1311, 1125, 13, 4706, 9995, 15941, 697, 4140, 515, 3001, 9886, 4140, 267, 15945, 29908, 13, 4706, 1583, 29889, 2543, 15322, 353, 1583, 29889, 2543, 15322, 448, 29871, 29896, 13, 13, 1678, 822, 1734, 3549, 29898, 1311, 1125, 13, 4706, 9995, 3549, 29879, 263, 1734, 515, 278, 1734, 1293, 934, 322, 14422, 372, 304, 367, 1304, 297, 13, 965, 278, 3748, 15945, 29908, 13, 13, 4706, 396, 1734, 8009, 3464, 8665, 515, 29871, 29896, 304, 427, 2146, 545, 393, 278, 2752, 3988, 297, 278, 13, 4706, 396, 1734, 1293, 934, 338, 2360, 4629, 408, 278, 1734, 13, 4706, 1734, 8009, 353, 20088, 29889, 9502, 524, 29898, 29896, 29892, 29871, 29896, 29900, 29900, 29900, 29897, 13, 4706, 1734, 1293, 353, 1722, 703, 1742, 1293, 29889, 3945, 613, 376, 29878, 1159, 13, 13, 4706, 363, 474, 297, 3464, 29898, 1742, 8009, 718, 29871, 29896, 1125, 13, 9651, 565, 474, 1275, 1734, 8009, 29901, 13, 18884, 1734, 353, 1734, 1293, 29889, 949, 1220, 580, 13, 18884, 1734, 353, 1734, 7503, 29899, 29896, 29962, 13, 9651, 1683, 29901, 13, 18884, 1734, 1293, 29889, 949, 1220, 580, 13, 13, 4706, 1734, 1293, 29889, 5358, 580, 13, 4706, 736, 1734, 13, 13, 1678, 822, 1734, 2831, 9485, 15322, 29898, 1311, 29892, 1734, 1125, 13, 4706, 9995, 9832, 1078, 263, 1051, 6943, 697, 23400, 3221, 408, 385, 1543, 363, 1269, 5497, 310, 278, 10434, 1734, 607, 338, 4586, 408, 13, 965, 1881, 304, 278, 740, 15945, 29908, 13, 4706, 1734, 1293, 287, 353, 5159, 13, 4706, 363, 5497, 297, 1734, 29901, 13, 9651, 1734, 1293, 287, 29889, 4397, 703, 29918, 1159, 13, 13, 4706, 736, 1734, 1293, 287, 13, 13, 1678, 822, 1734, 9485, 404, 29898, 1311, 1125, 13, 4706, 9995, 3596, 1242, 278, 1404, 304, 1881, 263, 1734, 408, 263, 4140, 29892, 565, 278, 1734, 338, 1959, 769, 278, 4847, 21614, 278, 3748, 29892, 565, 278, 13, 965, 1734, 338, 451, 1959, 769, 278, 4847, 338, 5429, 322, 278, 1051, 310, 4140, 287, 322, 443, 2543, 11517, 8721, 338, 13350, 577, 393, 13, 965, 372, 338, 7962, 304, 278, 4847, 15945, 29908, 13, 4706, 1734, 9485, 11517, 353, 1881, 703, 5618, 338, 596, 4140, 29973, 16521, 13, 4706, 565, 1734, 9485, 11517, 1275, 1583, 29889, 1742, 29901, 13, 9651, 1583, 29889, 9106, 29956, 1144, 353, 5852, 13, 9651, 1596, 703, 29907, 549, 3605, 8250, 29991, 887, 4140, 287, 5149, 29892, 278, 1734, 471, 376, 718, 1583, 29889, 1742, 718, 376, 29991, 1159, 13, 9651, 1583, 29889, 11802, 29956, 265, 580, 13, 4706, 1683, 29901, 13, 9651, 1596, 703, 29903, 3818, 29892, 393, 3508, 29915, 29873, 278, 1734, 1159, 13, 9651, 1583, 29889, 2543, 404, 6767, 580, 13, 9651, 1583, 29889, 19264, 5596, 580, 13, 13, 1678, 822, 5497, 9485, 404, 29898, 1311, 1125, 13, 4706, 9995, 3596, 1242, 278, 1404, 304, 1881, 263, 5497, 408, 263, 4140, 29892, 565, 278, 5497, 338, 297, 278, 1734, 769, 372, 1634, 6048, 278, 8210, 13, 965, 4890, 297, 278, 1051, 2825, 491, 1734, 2831, 9485, 15322, 29892, 565, 278, 5497, 338, 451, 297, 278, 1734, 769, 278, 4847, 338, 5429, 13, 965, 393, 896, 892, 2743, 29889, 450, 1051, 6943, 23400, 29883, 2361, 322, 8721, 338, 8833, 472, 278, 1095, 310, 278, 740, 13, 965, 1269, 931, 297, 1797, 304, 9801, 372, 338, 7962, 304, 278, 4847, 472, 599, 3064, 15945, 29908, 13, 4706, 5497, 9485, 11517, 353, 1881, 703, 5618, 338, 596, 4140, 29973, 16521, 13, 4706, 565, 5497, 9485, 11517, 297, 1583, 29889, 1742, 29901, 13, 9651, 474, 353, 29871, 29900, 13, 9651, 363, 5497, 297, 1583, 29889, 1742, 29901, 13, 18884, 565, 5497, 1275, 5497, 9485, 11517, 29901, 13, 462, 1678, 1583, 29889, 1742, 3047, 9485, 15322, 29961, 29875, 29962, 353, 5497, 9485, 11517, 13, 13, 18884, 474, 353, 474, 718, 29871, 29896, 13, 4706, 1683, 29901, 13, 9651, 1596, 703, 29903, 3818, 29892, 393, 5497, 3508, 29915, 29873, 297, 278, 1734, 1159, 13, 9651, 1583, 29889, 2543, 404, 6767, 580, 13, 9651, 1583, 29889, 19264, 5596, 580, 13, 13, 4706, 1583, 29889, 497, 12024, 2153, 5596, 580, 13, 13, 4706, 565, 1583, 29889, 9106, 29956, 1144, 1275, 7700, 29901, 13, 9651, 565, 1583, 29889, 686, 29884, 11517, 12024, 2153, 1275, 29871, 29896, 29901, 13, 18884, 1596, 703, 8439, 338, 376, 718, 851, 29898, 1311, 29889, 686, 29884, 11517, 12024, 2153, 29897, 718, 376, 5497, 2175, 304, 4140, 29905, 29876, 1159, 13, 9651, 1683, 29901, 13, 18884, 1596, 703, 8439, 526, 376, 718, 851, 29898, 1311, 29889, 686, 29884, 11517, 12024, 2153, 29897, 718, 376, 8721, 2175, 304, 4140, 29905, 29876, 1159, 13, 13, 9651, 1510, 14463, 9485, 15322, 353, 5124, 13, 9651, 363, 5497, 297, 1583, 29889, 1742, 3047, 9485, 15322, 29901, 13, 18884, 1510, 14463, 9485, 15322, 353, 1510, 14463, 9485, 15322, 718, 5497, 718, 376, 376, 13, 13, 9651, 1596, 29898, 4294, 14463, 9485, 15322, 718, 6634, 29876, 1159, 13, 13, 1678, 822, 599, 12024, 2153, 5596, 29898, 1311, 1125, 13, 4706, 9995, 5596, 29879, 565, 278, 4847, 756, 4140, 287, 599, 278, 8721, 297, 278, 1734, 5149, 29892, 565, 896, 505, 769, 278, 4847, 21614, 13, 965, 278, 3748, 29892, 565, 451, 278, 740, 3683, 1475, 920, 1784, 8721, 526, 2175, 304, 367, 4140, 287, 322, 11217, 278, 443, 2543, 11517, 13, 965, 8721, 995, 15945, 29908, 13, 4706, 565, 11119, 29908, 451, 297, 1583, 29889, 1742, 3047, 9485, 15322, 29901, 13, 9651, 1583, 29889, 9106, 29956, 1144, 353, 5852, 13, 9651, 1583, 29889, 11802, 29956, 265, 580, 13, 4706, 1683, 29901, 13, 9651, 474, 353, 29871, 29900, 13, 9651, 363, 5497, 297, 1583, 29889, 1742, 3047, 9485, 15322, 29901, 13, 18884, 565, 5497, 1275, 11119, 1115, 13, 462, 1678, 474, 353, 474, 718, 29871, 29896, 13, 18884, 1683, 29901, 13, 462, 1678, 6773, 13, 9651, 1583, 29889, 686, 29884, 11517, 12024, 2153, 353, 474, 13, 13, 1678, 822, 2834, 5596, 29898, 1311, 1125, 13, 4706, 565, 1583, 29889, 2543, 15322, 5277, 29871, 29900, 29901, 13, 9651, 1596, 703, 3492, 505, 694, 2743, 4140, 267, 9886, 1159, 13, 9651, 1583, 29889, 11802, 29931, 520, 580, 13, 4706, 1683, 29901, 13, 9651, 1596, 703, 3492, 505, 376, 718, 851, 29898, 1311, 29889, 2543, 15322, 29897, 718, 376, 2743, 4140, 267, 2175, 1159, 13, 13, 1678, 822, 3748, 29956, 265, 29898, 1311, 1125, 13, 4706, 9995, 4013, 740, 10603, 278, 4847, 896, 505, 2113, 15945, 29908, 13, 4706, 1583, 29889, 11802, 3563, 353, 5852, 13, 4706, 1596, 14182, 29876, 29907, 549, 3605, 8250, 376, 718, 1583, 29889, 978, 718, 376, 29991, 887, 8892, 29991, 1159, 13, 13, 1678, 822, 3748, 29931, 520, 29898, 1311, 1125, 13, 4706, 9995, 4013, 740, 10603, 278, 4847, 896, 505, 5714, 15945, 29908, 13, 4706, 1583, 29889, 11802, 3563, 353, 5852, 13, 4706, 1596, 14182, 29876, 1576, 1734, 471, 376, 718, 1583, 29889, 1742, 29897, 13, 4706, 1596, 14182, 29876, 29903, 3818, 376, 718, 1583, 29889, 978, 718, 11393, 887, 365, 852, 29991, 1159, 13, 2 ]
State.py
hhojatansari/DatasetDecoder
1
111179
import datetime as dt ClassLabel = { "NoLabel": "0", "Meal_Preparation": "1", "Relax": "2", "Eating": "3", "Work": "4", "Sleeping": "5", "Wash_Dishes": "6", "Bed_to_Toilet": "7", "Enter_Home": "8", "Leave_Home": "9", "Housekeeping": "10", "Respirate": "11" } class State: def __init__(self): self.overloaded = False self.counter = 0 self.datetime = dt.datetime.now() self.data = { "date": "00-00-00", "time": "00:00:00", "M001": "0", "M002": "0", "M003": "0", "M004": "0", "M005": "0", "M006": "0", "M007": "0", "M008": "0", "M009": "0", "M010": "0", "M011": "0", "M012": "0", "M013": "0", "M014": "0", "M015": "0", "M016": "0", "M017": "0", "M018": "0", "M019": "0", "M020": "0", "M021": "0", "M022": "0", "M023": "0", "M024": "0", "M025": "0", "M026": "0", "M027": "0", "M028": "0", "M029": "0", "M030": "0", "M031": "0", "T001": "20.0", "T002": "20.0", "T003": "20.0", "T004": "20.0", "T005": "20.0", "D001": "0", "D002": "0", "D003": "0", "D004": "0", "Label": "NoLabel" } def __eq__(self, other): if (self.data["date"] == other.data["date"] and self.data["time"] == other.data["time"]): return True def __sub__(self, other): dis = self.datetime - other.datetime return dis.days * 24 * 60 * 60 + dis.seconds - 1 def textParser(self, string): year, month, day = string.split()[0].split("-") hour, minute, second = string.split()[1].split(":") year = int(year) month = int(month) day = int(day) hour = int(hour) minute = int(minute) if(round(float(second), 0) > 59): second = int(eval(second)) self.overloaded = True else: second = int(round(float(second), 0)) self.datetime = dt.datetime(year, month, day, hour, minute, second) if(self.overloaded): self.incrementTime() self.data["date"] = str(self.datetime.year) + "-" + "{0:0=2d}".format(self.datetime.month) + \ "-" + "{0:0=2d}".format(self.datetime.day) self.data["time"] = "{0:0=2d}".format(self.datetime.hour) + ":" + "{0:0=2d}".format(self.datetime.minute) + \ ":" + "{0:0=2d}".format(self.datetime.second) if (len(string.split()) == 6 or len(string.split()) == 4): if (string.split()[3] == "ON" or string.split()[3] == "OPEN"): self.data[string.split()[2]] = "1" elif (string.split()[3] == "OFF" or string.split()[3] == "CLOSE"): self.data[string.split()[2]] = "0" else: self.data[string.split()[2]] = string.split()[3] if (len(string.split()) == 6): if (string.split()[5] == "begin"): self.data["Label"] = ClassLabel[string.split()[4]] elif (string.split()[5] == "end"): self.data["Label"] = ClassLabel["NoLabel"] else: print("Error:", "len of line is " + str(len(string.split()))) def writeState(self, file): file.write( self.data["date"] + " " + self.data["time"] + " " + self.data["M001"] + " " + self.data["M002"] + " " + self.data["M003"] + " " + self.data["M004"] + " " + self.data["M005"] + " " + self.data["M006"] + " " + self.data["M007"] + " " + self.data["M008"] + " " + self.data["M009"] + " " + self.data["M010"] + " " + self.data["M011"] + " " + self.data["M012"] + " " + self.data["M013"] + " " + self.data["M014"] + " " + self.data["M015"] + " " + self.data["M016"] + " " + self.data["M017"] + " " + self.data["M018"] + " " + self.data["M019"] + " " + self.data["M020"] + " " + self.data["M021"] + " " + self.data["M022"] + " " + self.data["M023"] + " " + self.data["M024"] + " " + self.data["M025"] + " " + self.data["M026"] + " " + self.data["M027"] + " " + self.data["M028"] + " " + self.data["M029"] + " " + self.data["M030"] + " " + self.data["M031"] + " " + self.data["T001"] + " " + self.data["T002"] + " " + self.data["T003"] + " " + self.data["T004"] + " " + self.data["T005"] + " " + self.data["D001"] + " " + self.data["D002"] + " " + self.data["D003"] + " " + self.data["D004"] + " " + self.data["Label"] + "\n") self.counter += 1 def printState(self): print(self.data["date"], self.data["time"], self.data["M001"], self.data["M002"], self.data["M003"], self.data["M004"], self.data["M005"], self.data["M006"], self.data["M007"], self.data["M008"], self.data["M009"], self.data["M010"], self.data["M011"], self.data["M012"], self.data["M013"], self.data["M014"], self.data["M015"], self.data["M016"], self.data["M017"], self.data["M018"], self.data["M019"], self.data["M020"], self.data["M021"], self.data["M022"], self.data["M023"], self.data["M024"], self.data["M025"], self.data["M026"], self.data["M027"], self.data["M028"], self.data["M029"], self.data["M030"], self.data["M031"], self.data["T001"], self.data["T002"], self.data["T003"], self.data["T004"], self.data["T005"], self.data["D001"], self.data["D002"], self.data["D003"], self.data["D004"], self.data["Label"]) def incrementTime(self): self.datetime = self.datetime + dt.timedelta(0, 1) self.data["date"] = str(self.datetime).split()[0] self.data["time"] = str(self.datetime).split()[1]
[ 1, 1053, 12865, 408, 11636, 13, 13, 2385, 4775, 353, 426, 13, 1678, 376, 3782, 4775, 1115, 376, 29900, 613, 13, 1678, 376, 6816, 284, 29918, 6572, 862, 362, 1115, 376, 29896, 613, 13, 1678, 376, 9662, 1165, 1115, 376, 29906, 613, 13, 1678, 376, 29923, 1218, 1115, 376, 29941, 613, 13, 1678, 376, 5531, 1115, 376, 29946, 613, 13, 1678, 376, 29903, 5436, 292, 1115, 376, 29945, 613, 13, 1678, 376, 29956, 1161, 29918, 29928, 17006, 1115, 376, 29953, 613, 13, 1678, 376, 29933, 287, 29918, 517, 29918, 1762, 488, 29873, 1115, 376, 29955, 613, 13, 1678, 376, 10399, 29918, 11184, 1115, 376, 29947, 613, 13, 1678, 376, 3226, 1351, 29918, 11184, 1115, 376, 29929, 613, 13, 1678, 376, 29950, 1709, 17462, 292, 1115, 376, 29896, 29900, 613, 13, 1678, 376, 1666, 29886, 381, 403, 1115, 376, 29896, 29896, 29908, 13, 29913, 13, 13, 1990, 4306, 29901, 13, 13, 1678, 822, 4770, 2344, 12035, 1311, 1125, 13, 4706, 1583, 29889, 957, 15638, 353, 7700, 13, 4706, 1583, 29889, 11808, 353, 29871, 29900, 13, 4706, 1583, 29889, 12673, 353, 11636, 29889, 12673, 29889, 3707, 580, 13, 4706, 1583, 29889, 1272, 353, 426, 13, 9651, 376, 1256, 1115, 376, 29900, 29900, 29899, 29900, 29900, 29899, 29900, 29900, 613, 376, 2230, 1115, 376, 29900, 29900, 29901, 29900, 29900, 29901, 29900, 29900, 613, 376, 29924, 29900, 29900, 29896, 1115, 376, 29900, 613, 376, 29924, 29900, 29900, 29906, 1115, 376, 29900, 613, 376, 29924, 29900, 29900, 29941, 1115, 376, 29900, 613, 376, 29924, 29900, 29900, 29946, 1115, 376, 29900, 613, 376, 29924, 29900, 29900, 29945, 1115, 376, 29900, 613, 13, 9651, 376, 29924, 29900, 29900, 29953, 1115, 376, 29900, 613, 376, 29924, 29900, 29900, 29955, 1115, 376, 29900, 613, 376, 29924, 29900, 29900, 29947, 1115, 376, 29900, 613, 376, 29924, 29900, 29900, 29929, 1115, 376, 29900, 613, 376, 29924, 29900, 29896, 29900, 1115, 376, 29900, 613, 376, 29924, 29900, 29896, 29896, 1115, 376, 29900, 613, 376, 29924, 29900, 29896, 29906, 1115, 376, 29900, 613, 376, 29924, 29900, 29896, 29941, 1115, 376, 29900, 613, 13, 9651, 376, 29924, 29900, 29896, 29946, 1115, 376, 29900, 613, 13, 9651, 376, 29924, 29900, 29896, 29945, 1115, 376, 29900, 613, 376, 29924, 29900, 29896, 29953, 1115, 376, 29900, 613, 376, 29924, 29900, 29896, 29955, 1115, 376, 29900, 613, 376, 29924, 29900, 29896, 29947, 1115, 376, 29900, 613, 376, 29924, 29900, 29896, 29929, 1115, 376, 29900, 613, 376, 29924, 29900, 29906, 29900, 1115, 376, 29900, 613, 376, 29924, 29900, 29906, 29896, 1115, 376, 29900, 613, 376, 29924, 29900, 29906, 29906, 1115, 376, 29900, 613, 13, 9651, 376, 29924, 29900, 29906, 29941, 1115, 376, 29900, 613, 376, 29924, 29900, 29906, 29946, 1115, 376, 29900, 613, 13, 9651, 376, 29924, 29900, 29906, 29945, 1115, 376, 29900, 613, 376, 29924, 29900, 29906, 29953, 1115, 376, 29900, 613, 376, 29924, 29900, 29906, 29955, 1115, 376, 29900, 613, 376, 29924, 29900, 29906, 29947, 1115, 376, 29900, 613, 376, 29924, 29900, 29906, 29929, 1115, 376, 29900, 613, 376, 29924, 29900, 29941, 29900, 1115, 376, 29900, 613, 376, 29924, 29900, 29941, 29896, 1115, 376, 29900, 613, 376, 29911, 29900, 29900, 29896, 1115, 376, 29906, 29900, 29889, 29900, 613, 13, 9651, 376, 29911, 29900, 29900, 29906, 1115, 376, 29906, 29900, 29889, 29900, 613, 13, 9651, 376, 29911, 29900, 29900, 29941, 1115, 376, 29906, 29900, 29889, 29900, 613, 376, 29911, 29900, 29900, 29946, 1115, 376, 29906, 29900, 29889, 29900, 613, 376, 29911, 29900, 29900, 29945, 1115, 376, 29906, 29900, 29889, 29900, 613, 376, 29928, 29900, 29900, 29896, 1115, 376, 29900, 613, 376, 29928, 29900, 29900, 29906, 1115, 376, 29900, 613, 376, 29928, 29900, 29900, 29941, 1115, 376, 29900, 613, 376, 29928, 29900, 29900, 29946, 1115, 376, 29900, 613, 13, 9651, 376, 4775, 1115, 376, 3782, 4775, 29908, 13, 4706, 500, 13, 13, 1678, 822, 4770, 1837, 12035, 1311, 29892, 916, 1125, 13, 4706, 565, 313, 1311, 29889, 1272, 3366, 1256, 3108, 1275, 916, 29889, 1272, 3366, 1256, 3108, 322, 1583, 29889, 1272, 3366, 2230, 3108, 1275, 916, 29889, 1272, 3366, 2230, 3108, 1125, 13, 9651, 736, 5852, 13, 13, 1678, 822, 4770, 1491, 12035, 1311, 29892, 916, 1125, 13, 4706, 766, 353, 1583, 29889, 12673, 448, 916, 29889, 12673, 13, 4706, 736, 766, 29889, 16700, 334, 29871, 29906, 29946, 334, 29871, 29953, 29900, 334, 29871, 29953, 29900, 718, 766, 29889, 23128, 448, 29871, 29896, 13, 13, 1678, 822, 1426, 11726, 29898, 1311, 29892, 1347, 1125, 13, 4706, 1629, 29892, 4098, 29892, 2462, 353, 1347, 29889, 5451, 580, 29961, 29900, 1822, 5451, 703, 29899, 1159, 13, 4706, 7234, 29892, 11015, 29892, 1473, 353, 1347, 29889, 5451, 580, 29961, 29896, 1822, 5451, 703, 29901, 1159, 13, 13, 4706, 1629, 353, 938, 29898, 6360, 29897, 13, 4706, 4098, 353, 938, 29898, 10874, 29897, 13, 4706, 2462, 353, 938, 29898, 3250, 29897, 13, 4706, 7234, 353, 938, 29898, 18721, 29897, 13, 4706, 11015, 353, 938, 29898, 1195, 1082, 29897, 13, 13, 4706, 565, 29898, 14486, 29898, 7411, 29898, 7496, 511, 29871, 29900, 29897, 1405, 29871, 29945, 29929, 1125, 13, 9651, 1473, 353, 938, 29898, 14513, 29898, 7496, 876, 13, 9651, 1583, 29889, 957, 15638, 353, 5852, 13, 4706, 1683, 29901, 13, 9651, 1473, 353, 938, 29898, 14486, 29898, 7411, 29898, 7496, 511, 29871, 29900, 876, 13, 4706, 1583, 29889, 12673, 353, 11636, 29889, 12673, 29898, 6360, 29892, 4098, 29892, 2462, 29892, 7234, 29892, 11015, 29892, 1473, 29897, 13, 4706, 565, 29898, 1311, 29889, 957, 15638, 1125, 13, 9651, 1583, 29889, 25629, 2481, 580, 13, 13, 4706, 1583, 29889, 1272, 3366, 1256, 3108, 353, 851, 29898, 1311, 29889, 12673, 29889, 6360, 29897, 718, 11663, 29908, 718, 29850, 29900, 29901, 29900, 29922, 29906, 29881, 29913, 1642, 4830, 29898, 1311, 29889, 12673, 29889, 10874, 29897, 718, 320, 13, 462, 9651, 11663, 29908, 718, 29850, 29900, 29901, 29900, 29922, 29906, 29881, 29913, 1642, 4830, 29898, 1311, 29889, 12673, 29889, 3250, 29897, 13, 4706, 1583, 29889, 1272, 3366, 2230, 3108, 353, 29850, 29900, 29901, 29900, 29922, 29906, 29881, 29913, 1642, 4830, 29898, 1311, 29889, 12673, 29889, 18721, 29897, 718, 376, 6160, 718, 29850, 29900, 29901, 29900, 29922, 29906, 29881, 29913, 1642, 4830, 29898, 1311, 29889, 12673, 29889, 1195, 1082, 29897, 718, 320, 13, 462, 9651, 376, 6160, 718, 29850, 29900, 29901, 29900, 29922, 29906, 29881, 29913, 1642, 4830, 29898, 1311, 29889, 12673, 29889, 7496, 29897, 13, 13, 4706, 565, 313, 2435, 29898, 1807, 29889, 5451, 3101, 1275, 29871, 29953, 470, 7431, 29898, 1807, 29889, 5451, 3101, 1275, 29871, 29946, 1125, 13, 9651, 565, 313, 1807, 29889, 5451, 580, 29961, 29941, 29962, 1275, 376, 1164, 29908, 470, 1347, 29889, 5451, 580, 29961, 29941, 29962, 1275, 376, 4590, 1430, 29908, 1125, 13, 18884, 1583, 29889, 1272, 29961, 1807, 29889, 5451, 580, 29961, 29906, 5262, 353, 376, 29896, 29908, 13, 9651, 25342, 313, 1807, 29889, 5451, 580, 29961, 29941, 29962, 1275, 376, 27681, 29908, 470, 1347, 29889, 5451, 580, 29961, 29941, 29962, 1275, 376, 29907, 3927, 1660, 29908, 1125, 13, 18884, 1583, 29889, 1272, 29961, 1807, 29889, 5451, 580, 29961, 29906, 5262, 353, 376, 29900, 29908, 13, 9651, 1683, 29901, 13, 18884, 1583, 29889, 1272, 29961, 1807, 29889, 5451, 580, 29961, 29906, 5262, 353, 1347, 29889, 5451, 580, 29961, 29941, 29962, 13, 13, 9651, 565, 313, 2435, 29898, 1807, 29889, 5451, 3101, 1275, 29871, 29953, 1125, 13, 18884, 565, 313, 1807, 29889, 5451, 580, 29961, 29945, 29962, 1275, 376, 463, 29908, 1125, 13, 462, 1678, 1583, 29889, 1272, 3366, 4775, 3108, 353, 4134, 4775, 29961, 1807, 29889, 5451, 580, 29961, 29946, 5262, 13, 18884, 25342, 313, 1807, 29889, 5451, 580, 29961, 29945, 29962, 1275, 376, 355, 29908, 1125, 13, 462, 1678, 1583, 29889, 1272, 3366, 4775, 3108, 353, 4134, 4775, 3366, 3782, 4775, 3108, 13, 4706, 1683, 29901, 13, 9651, 1596, 703, 2392, 29901, 613, 376, 2435, 310, 1196, 338, 376, 718, 851, 29898, 2435, 29898, 1807, 29889, 5451, 580, 4961, 13, 13, 1678, 822, 2436, 2792, 29898, 1311, 29892, 934, 1125, 13, 4706, 934, 29889, 3539, 29898, 13, 9651, 1583, 29889, 1272, 3366, 1256, 3108, 718, 376, 376, 718, 1583, 29889, 1272, 3366, 2230, 3108, 718, 376, 376, 718, 1583, 29889, 1272, 3366, 29924, 29900, 29900, 29896, 3108, 718, 376, 376, 718, 1583, 29889, 1272, 3366, 29924, 29900, 29900, 29906, 3108, 718, 376, 376, 718, 13, 9651, 1583, 29889, 1272, 3366, 29924, 29900, 29900, 29941, 3108, 718, 376, 376, 718, 13, 9651, 1583, 29889, 1272, 3366, 29924, 29900, 29900, 29946, 3108, 718, 376, 376, 718, 1583, 29889, 1272, 3366, 29924, 29900, 29900, 29945, 3108, 718, 376, 376, 718, 1583, 29889, 1272, 3366, 29924, 29900, 29900, 29953, 3108, 718, 376, 376, 718, 1583, 29889, 1272, 3366, 29924, 29900, 29900, 29955, 3108, 718, 376, 376, 718, 13, 9651, 1583, 29889, 1272, 3366, 29924, 29900, 29900, 29947, 3108, 718, 376, 376, 718, 13, 9651, 1583, 29889, 1272, 3366, 29924, 29900, 29900, 29929, 3108, 718, 376, 376, 718, 1583, 29889, 1272, 3366, 29924, 29900, 29896, 29900, 3108, 718, 376, 376, 718, 1583, 29889, 1272, 3366, 29924, 29900, 29896, 29896, 3108, 718, 376, 376, 718, 1583, 29889, 1272, 3366, 29924, 29900, 29896, 29906, 3108, 718, 376, 376, 718, 13, 9651, 1583, 29889, 1272, 3366, 29924, 29900, 29896, 29941, 3108, 718, 376, 376, 718, 13, 9651, 1583, 29889, 1272, 3366, 29924, 29900, 29896, 29946, 3108, 718, 376, 376, 718, 1583, 29889, 1272, 3366, 29924, 29900, 29896, 29945, 3108, 718, 376, 376, 718, 1583, 29889, 1272, 3366, 29924, 29900, 29896, 29953, 3108, 718, 376, 376, 718, 1583, 29889, 1272, 3366, 29924, 29900, 29896, 29955, 3108, 718, 376, 376, 718, 13, 9651, 1583, 29889, 1272, 3366, 29924, 29900, 29896, 29947, 3108, 718, 376, 376, 718, 13, 9651, 1583, 29889, 1272, 3366, 29924, 29900, 29896, 29929, 3108, 718, 376, 376, 718, 1583, 29889, 1272, 3366, 29924, 29900, 29906, 29900, 3108, 718, 376, 376, 718, 1583, 29889, 1272, 3366, 29924, 29900, 29906, 29896, 3108, 718, 376, 376, 718, 1583, 29889, 1272, 3366, 29924, 29900, 29906, 29906, 3108, 718, 376, 376, 718, 13, 9651, 1583, 29889, 1272, 3366, 29924, 29900, 29906, 29941, 3108, 718, 376, 376, 718, 13, 9651, 1583, 29889, 1272, 3366, 29924, 29900, 29906, 29946, 3108, 718, 376, 376, 718, 1583, 29889, 1272, 3366, 29924, 29900, 29906, 29945, 3108, 718, 376, 376, 718, 1583, 29889, 1272, 3366, 29924, 29900, 29906, 29953, 3108, 718, 376, 376, 718, 1583, 29889, 1272, 3366, 29924, 29900, 29906, 29955, 3108, 718, 376, 376, 718, 13, 9651, 1583, 29889, 1272, 3366, 29924, 29900, 29906, 29947, 3108, 718, 376, 376, 718, 13, 9651, 1583, 29889, 1272, 3366, 29924, 29900, 29906, 29929, 3108, 718, 376, 376, 718, 1583, 29889, 1272, 3366, 29924, 29900, 29941, 29900, 3108, 718, 376, 376, 718, 1583, 29889, 1272, 3366, 29924, 29900, 29941, 29896, 3108, 718, 376, 376, 718, 1583, 29889, 1272, 3366, 29911, 29900, 29900, 29896, 3108, 718, 376, 376, 718, 13, 9651, 1583, 29889, 1272, 3366, 29911, 29900, 29900, 29906, 3108, 718, 376, 376, 718, 13, 9651, 1583, 29889, 1272, 3366, 29911, 29900, 29900, 29941, 3108, 718, 376, 376, 718, 1583, 29889, 1272, 3366, 29911, 29900, 29900, 29946, 3108, 718, 376, 376, 718, 1583, 29889, 1272, 3366, 29911, 29900, 29900, 29945, 3108, 718, 376, 376, 718, 1583, 29889, 1272, 3366, 29928, 29900, 29900, 29896, 3108, 718, 376, 376, 718, 13, 9651, 1583, 29889, 1272, 3366, 29928, 29900, 29900, 29906, 3108, 718, 376, 376, 718, 13, 9651, 1583, 29889, 1272, 3366, 29928, 29900, 29900, 29941, 3108, 718, 376, 376, 718, 1583, 29889, 1272, 3366, 29928, 29900, 29900, 29946, 3108, 718, 376, 376, 718, 1583, 29889, 1272, 3366, 4775, 3108, 718, 6634, 29876, 1159, 13, 4706, 1583, 29889, 11808, 4619, 29871, 29896, 13, 13, 1678, 822, 1596, 2792, 29898, 1311, 1125, 13, 4706, 1596, 29898, 1311, 29889, 1272, 3366, 1256, 12436, 1583, 29889, 1272, 3366, 2230, 12436, 1583, 29889, 1272, 3366, 29924, 29900, 29900, 29896, 12436, 1583, 29889, 1272, 3366, 29924, 29900, 29900, 29906, 12436, 1583, 29889, 1272, 3366, 29924, 29900, 29900, 29941, 12436, 13, 795, 1583, 29889, 1272, 3366, 29924, 29900, 29900, 29946, 12436, 1583, 29889, 1272, 3366, 29924, 29900, 29900, 29945, 12436, 1583, 29889, 1272, 3366, 29924, 29900, 29900, 29953, 12436, 1583, 29889, 1272, 3366, 29924, 29900, 29900, 29955, 12436, 1583, 29889, 1272, 3366, 29924, 29900, 29900, 29947, 12436, 13, 795, 1583, 29889, 1272, 3366, 29924, 29900, 29900, 29929, 12436, 1583, 29889, 1272, 3366, 29924, 29900, 29896, 29900, 12436, 1583, 29889, 1272, 3366, 29924, 29900, 29896, 29896, 12436, 1583, 29889, 1272, 3366, 29924, 29900, 29896, 29906, 12436, 1583, 29889, 1272, 3366, 29924, 29900, 29896, 29941, 12436, 13, 795, 1583, 29889, 1272, 3366, 29924, 29900, 29896, 29946, 12436, 1583, 29889, 1272, 3366, 29924, 29900, 29896, 29945, 12436, 1583, 29889, 1272, 3366, 29924, 29900, 29896, 29953, 12436, 1583, 29889, 1272, 3366, 29924, 29900, 29896, 29955, 12436, 1583, 29889, 1272, 3366, 29924, 29900, 29896, 29947, 12436, 13, 795, 1583, 29889, 1272, 3366, 29924, 29900, 29896, 29929, 12436, 1583, 29889, 1272, 3366, 29924, 29900, 29906, 29900, 12436, 1583, 29889, 1272, 3366, 29924, 29900, 29906, 29896, 12436, 1583, 29889, 1272, 3366, 29924, 29900, 29906, 29906, 12436, 1583, 29889, 1272, 3366, 29924, 29900, 29906, 29941, 12436, 13, 795, 1583, 29889, 1272, 3366, 29924, 29900, 29906, 29946, 12436, 1583, 29889, 1272, 3366, 29924, 29900, 29906, 29945, 12436, 1583, 29889, 1272, 3366, 29924, 29900, 29906, 29953, 12436, 1583, 29889, 1272, 3366, 29924, 29900, 29906, 29955, 12436, 1583, 29889, 1272, 3366, 29924, 29900, 29906, 29947, 12436, 13, 795, 1583, 29889, 1272, 3366, 29924, 29900, 29906, 29929, 12436, 1583, 29889, 1272, 3366, 29924, 29900, 29941, 29900, 12436, 1583, 29889, 1272, 3366, 29924, 29900, 29941, 29896, 12436, 1583, 29889, 1272, 3366, 29911, 29900, 29900, 29896, 12436, 1583, 29889, 1272, 3366, 29911, 29900, 29900, 29906, 12436, 13, 795, 1583, 29889, 1272, 3366, 29911, 29900, 29900, 29941, 12436, 1583, 29889, 1272, 3366, 29911, 29900, 29900, 29946, 12436, 1583, 29889, 1272, 3366, 29911, 29900, 29900, 29945, 12436, 1583, 29889, 1272, 3366, 29928, 29900, 29900, 29896, 12436, 1583, 29889, 1272, 3366, 29928, 29900, 29900, 29906, 12436, 13, 795, 1583, 29889, 1272, 3366, 29928, 29900, 29900, 29941, 12436, 1583, 29889, 1272, 3366, 29928, 29900, 29900, 29946, 12436, 1583, 29889, 1272, 3366, 4775, 20068, 13, 13, 1678, 822, 11924, 2481, 29898, 1311, 1125, 13, 4706, 1583, 29889, 12673, 353, 1583, 29889, 12673, 718, 11636, 29889, 9346, 287, 2554, 29898, 29900, 29892, 29871, 29896, 29897, 13, 4706, 1583, 29889, 1272, 3366, 1256, 3108, 353, 851, 29898, 1311, 29889, 12673, 467, 5451, 580, 29961, 29900, 29962, 13, 4706, 1583, 29889, 1272, 3366, 2230, 3108, 353, 851, 29898, 1311, 29889, 12673, 467, 5451, 580, 29961, 29896, 29962, 13, 2 ]
app.py
abdulrasol/loly-ocr
0
137269
<reponame>abdulrasol/loly-ocr<gh_stars>0 from flask import Flask, redirect, request, render_template, send_file, send_from_directory from flask_session import Session from tempfile import mkdtemp import helpers, time, os app = Flask(__name__) # App Configs app.config["TEMPLATES_AUTO_RELOAD"] = True app.config["DEBUG"] = True app.config['UPLOAD_FOLDER'] = helpers.UPLOAD_FOLDER app.config['FILES_DIR'] = helpers.FILES_DIR app.config["SESSION_FILE_DIR"] = mkdtemp() app.config["SESSION_PERMANENT"] = False app.config["SESSION_TYPE"] = "filesystem" # utitize app.secret_key = 'super secret key' # Home def @app.route('/') def home(msg = None): if msg == None: msg = False return render_template('home.html', action='/editing', langs=helpers.langs, msg=msg, title='Loly | Upload file to extract text') # Editing Def @app.route('/editing', methods=["GET", "POST"]) def editing(msg = None): if request.method == 'POST': if request.form.get('lang') == None: return home('Selcet language!') if not(request.files['camera']): file = request.files['file'] else: file = request.files['camera'] get = helpers.ocr(file, language=request.form.get('lang')) if get['CODE'] == 0: return render_template('editing.html', action='/downloading', text = get['MSG'], title='Loly | editing extracted text') else: print(get) return home(get['MSG']) return home('Selcet file first!') # downloading file after editing @app.route('/downloading', methods=["GET", "POST"]) def downloading(): if request.method == 'POST': # save file as user request filename = time.strftime(f"%y%m%d%H%M%S.{request.form.get('get')}") with open(os.path.join(helpers.FILES_DIR,filename),'a') as file: file.write(request.form.get('text')) for file in os.listdir(helpers.FILES_DIR): file = os.path.join(helpers.FILES_DIR, file) if os.stat(file).st_mtime < time.time() - 900: os.remove(file) url = f'{request.url_root}{helpers.FILES_DIR}/{filename}' return render_template('downloading.html', url=url, title=f"Loly | download extracted text as{request.form.get('get')}") return home('Start by uploading file first!') # setup PWA app @app.route('/service-worker.js') def sw(): return app.send_static_file('js/service-worker.js'), 200, {'Content-Type': 'text/javascript'}
[ 1, 529, 276, 1112, 420, 29958, 370, 29881, 352, 3417, 324, 29914, 29880, 18333, 29899, 8415, 29966, 12443, 29918, 303, 1503, 29958, 29900, 13, 3166, 29784, 1053, 2379, 1278, 29892, 6684, 29892, 2009, 29892, 4050, 29918, 6886, 29892, 3638, 29918, 1445, 29892, 3638, 29918, 3166, 29918, 12322, 13, 3166, 29784, 29918, 7924, 1053, 16441, 13, 3166, 5694, 1445, 1053, 14690, 29881, 7382, 13, 5215, 1371, 414, 29892, 931, 29892, 2897, 13, 13, 13, 13, 932, 353, 2379, 1278, 22168, 978, 1649, 29897, 13, 13, 13, 29937, 2401, 12782, 29879, 13, 932, 29889, 2917, 3366, 4330, 3580, 29931, 1299, 2890, 29918, 20656, 29949, 29918, 1525, 29428, 3108, 353, 5852, 13, 932, 29889, 2917, 3366, 18525, 3108, 353, 5852, 13, 932, 29889, 2917, 1839, 4897, 29428, 29918, 29943, 5607, 8032, 2033, 353, 1371, 414, 29889, 4897, 29428, 29918, 29943, 5607, 8032, 13, 932, 29889, 2917, 1839, 24483, 29918, 9464, 2033, 353, 1371, 414, 29889, 24483, 29918, 9464, 13, 932, 29889, 2917, 3366, 17493, 29918, 7724, 29918, 9464, 3108, 353, 14690, 29881, 7382, 580, 13, 932, 29889, 2917, 3366, 17493, 29918, 13171, 27616, 3919, 3108, 353, 7700, 13, 932, 29889, 2917, 3366, 17493, 29918, 11116, 3108, 353, 376, 5325, 973, 29908, 13, 13, 29937, 3477, 277, 675, 13, 932, 29889, 19024, 29918, 1989, 353, 525, 9136, 7035, 1820, 29915, 13, 13, 29937, 8778, 822, 13, 29992, 932, 29889, 13134, 11219, 1495, 13, 1753, 3271, 29898, 7645, 353, 6213, 1125, 13, 1678, 565, 10191, 1275, 6213, 29901, 13, 4706, 10191, 353, 7700, 13, 1678, 736, 4050, 29918, 6886, 877, 5184, 29889, 1420, 742, 3158, 2433, 29914, 5628, 292, 742, 6361, 29879, 29922, 3952, 6774, 29889, 3893, 29879, 29892, 10191, 29922, 7645, 29892, 3611, 2433, 29931, 18333, 891, 5020, 1359, 934, 304, 6597, 1426, 1495, 13, 13, 29937, 7641, 292, 5282, 13, 29992, 932, 29889, 13134, 11219, 5628, 292, 742, 3519, 29922, 3366, 7194, 613, 376, 5438, 20068, 13, 1753, 16278, 29898, 7645, 353, 6213, 1125, 13, 1678, 565, 2009, 29889, 5696, 1275, 525, 5438, 2396, 13, 308, 13, 4706, 565, 2009, 29889, 689, 29889, 657, 877, 3893, 1495, 1275, 6213, 29901, 13, 9651, 736, 3271, 877, 29903, 295, 29883, 300, 4086, 29991, 1495, 13, 308, 13, 4706, 565, 451, 29898, 3827, 29889, 5325, 1839, 26065, 2033, 1125, 13, 9651, 934, 353, 2009, 29889, 5325, 1839, 1445, 2033, 13, 4706, 1683, 29901, 13, 9651, 934, 353, 2009, 29889, 5325, 1839, 26065, 2033, 13, 632, 13, 4706, 679, 353, 1371, 414, 29889, 8415, 29898, 1445, 29892, 4086, 29922, 3827, 29889, 689, 29889, 657, 877, 3893, 8785, 13, 4706, 565, 679, 1839, 16524, 2033, 1275, 29871, 29900, 29901, 13, 9651, 736, 4050, 29918, 6886, 877, 5628, 292, 29889, 1420, 742, 3158, 2433, 29914, 10382, 292, 742, 1426, 353, 679, 1839, 4345, 29954, 7464, 3611, 2433, 29931, 18333, 891, 16278, 23892, 1426, 1495, 13, 4706, 1683, 29901, 13, 9651, 1596, 29898, 657, 29897, 13, 9651, 736, 3271, 29898, 657, 1839, 4345, 29954, 11287, 13, 1678, 736, 3271, 877, 29903, 295, 29883, 300, 934, 937, 29991, 1495, 13, 13, 29937, 28536, 934, 1156, 16278, 13, 29992, 932, 29889, 13134, 11219, 10382, 292, 742, 3519, 29922, 3366, 7194, 613, 376, 5438, 20068, 13, 1753, 28536, 7295, 13, 1678, 565, 2009, 29889, 5696, 1275, 525, 5438, 2396, 13, 4706, 396, 4078, 934, 408, 1404, 2009, 13, 4706, 10422, 353, 931, 29889, 710, 615, 603, 29898, 29888, 29908, 29995, 29891, 29995, 29885, 29995, 29881, 29995, 29950, 29995, 29924, 29995, 29903, 29889, 29912, 3827, 29889, 689, 29889, 657, 877, 657, 1495, 27195, 13, 4706, 411, 1722, 29898, 359, 29889, 2084, 29889, 7122, 29898, 3952, 6774, 29889, 24483, 29918, 9464, 29892, 9507, 511, 29915, 29874, 1495, 408, 934, 29901, 13, 9651, 934, 29889, 3539, 29898, 3827, 29889, 689, 29889, 657, 877, 726, 8785, 13, 9651, 363, 934, 297, 2897, 29889, 1761, 3972, 29898, 3952, 6774, 29889, 24483, 29918, 9464, 1125, 13, 18884, 934, 353, 2897, 29889, 2084, 29889, 7122, 29898, 3952, 6774, 29889, 24483, 29918, 9464, 29892, 934, 29897, 13, 18884, 565, 2897, 29889, 6112, 29898, 1445, 467, 303, 29918, 29885, 2230, 529, 931, 29889, 2230, 580, 448, 29871, 29929, 29900, 29900, 29901, 13, 462, 1678, 2897, 29889, 5992, 29898, 1445, 29897, 13, 4706, 3142, 353, 285, 29915, 29912, 3827, 29889, 2271, 29918, 4632, 1157, 3952, 6774, 29889, 24483, 29918, 9464, 6822, 29912, 9507, 10162, 13, 4706, 736, 4050, 29918, 6886, 877, 10382, 292, 29889, 1420, 742, 3142, 29922, 2271, 29892, 3611, 29922, 29888, 29908, 29931, 18333, 891, 5142, 23892, 1426, 408, 29912, 3827, 29889, 689, 29889, 657, 877, 657, 1495, 27195, 13, 1678, 736, 3271, 877, 4763, 491, 6441, 292, 934, 937, 29991, 1495, 13, 13, 29937, 6230, 349, 12982, 623, 13, 29992, 932, 29889, 13134, 11219, 5509, 29899, 24602, 29889, 1315, 1495, 13, 1753, 2381, 7295, 13, 1678, 736, 623, 29889, 6717, 29918, 7959, 29918, 1445, 877, 1315, 29914, 5509, 29899, 24602, 29889, 1315, 5477, 29871, 29906, 29900, 29900, 29892, 11117, 3916, 29899, 1542, 2396, 525, 726, 29914, 7729, 10827, 2 ]
dxtbx/tests/model/test_detector.py
jbeilstenedmands/cctbx_project
0
158090
from __future__ import absolute_import, division, print_function import six.moves.cPickle as pickle from dxtbx.model import Detector, Panel from libtbx.test_utils import approx_equal from scitbx.array_family import flex def tst_get_gain(detector): detector[0].set_gain(2.0) assert abs(detector[0].get_gain() - 2.0) < 1e-7 def tst_get_identifier(detector): detector[0].set_identifier("HELLO") assert detector[0].get_identifier() == "HELLO" detector2 = pickle.loads(pickle.dumps(detector)) assert detector[0].get_identifier() == detector2[0].get_identifier() def tst_get_pixel_lab_coord(detector): from scitbx import matrix eps = 1e-7 # Check lab coordinates at the origin orig = detector[0].get_pixel_lab_coord((0, 0)) dorig = abs(matrix.col(orig) - matrix.col(detector[0].get_origin())) assert(dorig < eps) # Check lab coordinate at the opposite corner corner = detector[0].get_pixel_lab_coord((512, 512)) corner2 = (512 * 0.172, 512 * 0.172, 200) dcorner = abs(matrix.col(corner) - matrix.col(corner)) assert(dcorner < eps) def tst_get_image_size_mm(detector): from scitbx import matrix eps = 1e-7 size = detector[0].get_image_size_mm() size2 = (512 * 0.172, 512 * 0.172) dsize = abs(matrix.col(size) - matrix.col(size2)) assert(dsize < eps) def tst_is_value_in_trusted_range(detector): """Check values are either inside or outside trusted range.""" assert(detector[0].is_value_in_trusted_range(-1) == False) assert(detector[0].is_value_in_trusted_range(0) == True) assert(detector[0].is_value_in_trusted_range(999) == True) assert(detector[0].is_value_in_trusted_range(1000) == False) def tst_is_coord_valid(detector): """Check points are either inside or outside detector range.""" assert(detector[0].is_coord_valid((-1, 256)) == False) assert(detector[0].is_coord_valid((256, 256)) == True) assert(detector[0].is_coord_valid((512, 256)) == False) assert(detector[0].is_coord_valid((256, -1)) == False) assert(detector[0].is_coord_valid((256, 256)) == True) assert(detector[0].is_coord_valid((256, 513)) == False) def tst_pixel_to_millimeter_to_pixel(detector): from scitbx import matrix from random import random eps = 1e-7 # Pick some random pixels and check that px -> mm -> px give px == px w, h = detector[0].get_image_size() random_pixel = lambda: (random() * w, random() * h) pixels = flex.vec2_double(random_pixel() for i in range(100)) xy_mm = detector[0].pixel_to_millimeter(pixels) xy_px = detector[0].millimeter_to_pixel(xy_mm) assert approx_equal(xy_px, pixels, eps=eps) for xy in pixels: xy_mm = detector[0].pixel_to_millimeter(xy) xy_px = detector[0].millimeter_to_pixel(xy_mm) assert(abs(matrix.col(xy_px) - matrix.col(xy)) < eps) def tst_parallax_correction(detector): from random import uniform from scitbx import matrix random_coord = lambda: ( uniform(-1000, 1000), uniform(-1000, 1000)) for i in range(10000): mm = random_coord() px = detector[0].millimeter_to_pixel(mm) mm2 = detector[0].pixel_to_millimeter(px) assert(abs(matrix.col(mm) - matrix.col(mm2)) < 1e-3) def tst_get_names(detector): names = detector.get_names() assert(len(names) == 1) assert(names[0] == 'Panel') def tst_get_thickness(detector): for panel in detector: assert(panel.get_thickness() == 0.1) def tst_get_material(detector): for panel in detector: assert(panel.get_material() == 'Si') def tst_set_mosflm_beam_centre(detector): from scitbx import matrix from dxtbx.model import Beam wavelength = 1 panel = detector[0] detector_normal = matrix.col(panel.get_normal()) origin = matrix.col(panel.get_origin()) fast_axis = matrix.col(panel.get_fast_axis()) slow_axis = matrix.col(panel.get_slow_axis()) image_size = panel.get_image_size_mm() s0 = (1.0/wavelength) * detector_normal beam = Beam(-s0.normalize(), wavelength) beam_centre = matrix.col(panel.get_beam_centre(beam.get_s0())) origin_shift = matrix.col((1, 0.5)) new_beam_centre = beam_centre + origin_shift new_mosflm_beam_centre = tuple(reversed(new_beam_centre)) from dxtbx.model.detector_helpers import set_mosflm_beam_centre set_mosflm_beam_centre(detector, beam, new_mosflm_beam_centre) assert (matrix.col(panel.get_beam_centre(beam.get_s0())) - matrix.col(tuple(reversed(new_mosflm_beam_centre)))).length() < 1e-6 def tst_detectors_are_same(detA, detB): '''Equality operator on detector objects must identify identical detectors''' assert(detA == detB) def tst_detectors_are_different(detA, detB): '''Equality operator on detector objects must find differences in origin''' assert(detA != detB) def tst_resolution(detector): from dxtbx.model import Beam beam = Beam(direction=(0,0,1), wavelength=1.0) d_min1 = detector.get_max_resolution(beam.get_s0()) d_min2 = detector.get_max_inscribed_resolution(beam.get_s0()) assert d_min1 < d_min2 def tst_panel_mask(): from dxtbx.model import Panel panel = Panel() panel.set_image_size((100, 100)) panel.add_mask(40,0,60,100) panel.add_mask(0,40,100,60) panel.set_trusted_range((-1, 10)) data = flex.double(flex.grid(100,100)) data[10,10] = -1 data[20,20] = 10 data[30,30] = 100 data[40,40] = -10 m1 = panel.get_untrusted_rectangle_mask() m2 = panel.get_trusted_range_mask(data) count = 0 for j in range(100): for i in range(40,60): assert(m1[j,i] == False) count += 1 for i in range(100): for j in range(40,60): if i >= 40 and i < 60: continue assert(m1[j,i] == False) count += 1 assert m1.count(False) == count, "%d, %d" % (m1.count(False), count) assert m2.count(False) == 4 assert m2[10,10] == False assert m2[20,20] == False assert m2[30,30] == False assert m2[40,40] == False def test_detector(): from dxtbx.model import ParallaxCorrectedPxMmStrategy def create_detector(offset = 0): # Create the detector detector = Detector(Panel( "", # Type "Panel", # Name (10, 0, 0), # Fast axis (0, 10, 0), # Slow axis (0 + offset, 0 + offset, 200 - offset), # Origin (0.172, 0.172), # Pixel size (512, 512), # Image size (0, 1000), # Trusted range 0.1, # Thickness "Si", # Material identifier="123")) # Identifier return detector detector = create_detector() # Perform some tests tst_get_identifier(detector) tst_get_gain(detector) tst_set_mosflm_beam_centre(detector) tst_get_pixel_lab_coord(detector) tst_get_image_size_mm(detector) tst_is_value_in_trusted_range(detector) tst_is_coord_valid(detector) tst_pixel_to_millimeter_to_pixel(detector) tst_get_names(detector) tst_get_thickness(detector) tst_get_material(detector) tst_resolution(detector) tst_panel_mask() # Attenuation length from cctbx.eltbx import attenuation_coefficient table = attenuation_coefficient.get_table("Si") mu = table.mu_at_angstrom(1) / 10.0 t0 = 0.320 # Create another detector with different origin detector_moved = create_detector(offset=100) tst_detectors_are_different(detector, detector_moved) detector_moved_copy = create_detector(offset=100) tst_detectors_are_same(detector_moved, detector_moved_copy) # Create the detector detector = Detector(Panel( "", # Type "", # Name (10, 0, 0), # Fast axis (0, 10, 0), # Slow axis (0, 0, 200), # Origin (0.172, 0.172), # Pixel size (512, 512), # Image size (0, 1000), # Trusted range 0.0, # Thickness "", # Material ParallaxCorrectedPxMmStrategy(mu, t0))) tst_parallax_correction(detector)
[ 1, 515, 4770, 29888, 9130, 1649, 1053, 8380, 29918, 5215, 29892, 8542, 29892, 1596, 29918, 2220, 13, 13, 5215, 4832, 29889, 13529, 267, 29889, 29883, 29925, 860, 280, 408, 5839, 280, 13, 3166, 270, 486, 29890, 29916, 29889, 4299, 1053, 5953, 3019, 29892, 349, 3870, 13, 3166, 619, 3116, 29890, 29916, 29889, 1688, 29918, 13239, 1053, 2134, 29916, 29918, 11745, 13, 3166, 885, 277, 29890, 29916, 29889, 2378, 29918, 11922, 1053, 8525, 13, 13, 1753, 260, 303, 29918, 657, 29918, 29887, 475, 29898, 4801, 3019, 1125, 13, 29871, 1439, 3019, 29961, 29900, 1822, 842, 29918, 29887, 475, 29898, 29906, 29889, 29900, 29897, 13, 29871, 4974, 6425, 29898, 4801, 3019, 29961, 29900, 1822, 657, 29918, 29887, 475, 580, 448, 29871, 29906, 29889, 29900, 29897, 529, 29871, 29896, 29872, 29899, 29955, 13, 13, 1753, 260, 303, 29918, 657, 29918, 25378, 29898, 4801, 3019, 1125, 13, 29871, 1439, 3019, 29961, 29900, 1822, 842, 29918, 25378, 703, 9606, 2208, 29949, 1159, 13, 29871, 4974, 1439, 3019, 29961, 29900, 1822, 657, 29918, 25378, 580, 1275, 376, 9606, 2208, 29949, 29908, 13, 29871, 1439, 3019, 29906, 353, 5839, 280, 29889, 18132, 29898, 23945, 280, 29889, 29881, 17204, 29898, 4801, 3019, 876, 13, 29871, 4974, 1439, 3019, 29961, 29900, 1822, 657, 29918, 25378, 580, 1275, 1439, 3019, 29906, 29961, 29900, 1822, 657, 29918, 25378, 580, 13, 13, 1753, 260, 303, 29918, 657, 29918, 29886, 15711, 29918, 8205, 29918, 1111, 536, 29898, 4801, 3019, 1125, 13, 29871, 515, 885, 277, 29890, 29916, 1053, 4636, 13, 29871, 321, 567, 353, 29871, 29896, 29872, 29899, 29955, 13, 13, 29871, 396, 5399, 9775, 10350, 472, 278, 3978, 13, 29871, 1677, 353, 1439, 3019, 29961, 29900, 1822, 657, 29918, 29886, 15711, 29918, 8205, 29918, 1111, 536, 3552, 29900, 29892, 29871, 29900, 876, 13, 29871, 270, 12683, 353, 6425, 29898, 5344, 29889, 1054, 29898, 12683, 29897, 448, 4636, 29889, 1054, 29898, 4801, 3019, 29961, 29900, 1822, 657, 29918, 12574, 22130, 13, 29871, 4974, 29898, 29881, 12683, 529, 321, 567, 29897, 13, 13, 29871, 396, 5399, 9775, 14821, 472, 278, 11564, 11155, 13, 29871, 11155, 353, 1439, 3019, 29961, 29900, 1822, 657, 29918, 29886, 15711, 29918, 8205, 29918, 1111, 536, 3552, 29945, 29896, 29906, 29892, 29871, 29945, 29896, 29906, 876, 13, 29871, 11155, 29906, 353, 313, 29945, 29896, 29906, 334, 29871, 29900, 29889, 29896, 29955, 29906, 29892, 29871, 29945, 29896, 29906, 334, 29871, 29900, 29889, 29896, 29955, 29906, 29892, 29871, 29906, 29900, 29900, 29897, 13, 29871, 270, 2616, 1089, 353, 6425, 29898, 5344, 29889, 1054, 29898, 2616, 1089, 29897, 448, 4636, 29889, 1054, 29898, 2616, 1089, 876, 13, 29871, 4974, 29898, 29881, 2616, 1089, 529, 321, 567, 29897, 13, 13, 1753, 260, 303, 29918, 657, 29918, 3027, 29918, 2311, 29918, 4317, 29898, 4801, 3019, 1125, 13, 29871, 515, 885, 277, 29890, 29916, 1053, 4636, 13, 29871, 321, 567, 353, 29871, 29896, 29872, 29899, 29955, 13, 29871, 2159, 353, 1439, 3019, 29961, 29900, 1822, 657, 29918, 3027, 29918, 2311, 29918, 4317, 580, 13, 29871, 2159, 29906, 353, 313, 29945, 29896, 29906, 334, 29871, 29900, 29889, 29896, 29955, 29906, 29892, 29871, 29945, 29896, 29906, 334, 29871, 29900, 29889, 29896, 29955, 29906, 29897, 13, 29871, 270, 2311, 353, 6425, 29898, 5344, 29889, 1054, 29898, 2311, 29897, 448, 4636, 29889, 1054, 29898, 2311, 29906, 876, 13, 29871, 4974, 29898, 29881, 2311, 529, 321, 567, 29897, 13, 13, 1753, 260, 303, 29918, 275, 29918, 1767, 29918, 262, 29918, 509, 16656, 29918, 3881, 29898, 4801, 3019, 1125, 13, 29871, 9995, 5596, 1819, 526, 2845, 2768, 470, 5377, 9311, 287, 3464, 1213, 15945, 13, 29871, 4974, 29898, 4801, 3019, 29961, 29900, 1822, 275, 29918, 1767, 29918, 262, 29918, 509, 16656, 29918, 3881, 6278, 29896, 29897, 1275, 7700, 29897, 13, 29871, 4974, 29898, 4801, 3019, 29961, 29900, 1822, 275, 29918, 1767, 29918, 262, 29918, 509, 16656, 29918, 3881, 29898, 29900, 29897, 1275, 5852, 29897, 13, 29871, 4974, 29898, 4801, 3019, 29961, 29900, 1822, 275, 29918, 1767, 29918, 262, 29918, 509, 16656, 29918, 3881, 29898, 29929, 29929, 29929, 29897, 1275, 5852, 29897, 13, 29871, 4974, 29898, 4801, 3019, 29961, 29900, 1822, 275, 29918, 1767, 29918, 262, 29918, 509, 16656, 29918, 3881, 29898, 29896, 29900, 29900, 29900, 29897, 1275, 7700, 29897, 13, 13, 1753, 260, 303, 29918, 275, 29918, 1111, 536, 29918, 3084, 29898, 4801, 3019, 1125, 13, 29871, 9995, 5596, 3291, 526, 2845, 2768, 470, 5377, 1439, 3019, 3464, 1213, 15945, 13, 29871, 4974, 29898, 4801, 3019, 29961, 29900, 1822, 275, 29918, 1111, 536, 29918, 3084, 3552, 29899, 29896, 29892, 29871, 29906, 29945, 29953, 876, 1275, 7700, 29897, 13, 29871, 4974, 29898, 4801, 3019, 29961, 29900, 1822, 275, 29918, 1111, 536, 29918, 3084, 3552, 29906, 29945, 29953, 29892, 29871, 29906, 29945, 29953, 876, 1275, 5852, 29897, 13, 29871, 4974, 29898, 4801, 3019, 29961, 29900, 1822, 275, 29918, 1111, 536, 29918, 3084, 3552, 29945, 29896, 29906, 29892, 29871, 29906, 29945, 29953, 876, 1275, 7700, 29897, 13, 29871, 4974, 29898, 4801, 3019, 29961, 29900, 1822, 275, 29918, 1111, 536, 29918, 3084, 3552, 29906, 29945, 29953, 29892, 448, 29896, 876, 1275, 7700, 29897, 13, 29871, 4974, 29898, 4801, 3019, 29961, 29900, 1822, 275, 29918, 1111, 536, 29918, 3084, 3552, 29906, 29945, 29953, 29892, 29871, 29906, 29945, 29953, 876, 1275, 5852, 29897, 13, 29871, 4974, 29898, 4801, 3019, 29961, 29900, 1822, 275, 29918, 1111, 536, 29918, 3084, 3552, 29906, 29945, 29953, 29892, 29871, 29945, 29896, 29941, 876, 1275, 7700, 29897, 13, 13, 1753, 260, 303, 29918, 29886, 15711, 29918, 517, 29918, 19958, 14772, 29918, 517, 29918, 29886, 15711, 29898, 4801, 3019, 1125, 13, 29871, 515, 885, 277, 29890, 29916, 1053, 4636, 13, 29871, 515, 4036, 1053, 4036, 13, 29871, 321, 567, 353, 29871, 29896, 29872, 29899, 29955, 13, 13, 29871, 396, 23868, 777, 4036, 17036, 322, 1423, 393, 282, 29916, 1599, 5654, 1599, 282, 29916, 2367, 282, 29916, 1275, 282, 29916, 13, 29871, 281, 29892, 298, 353, 1439, 3019, 29961, 29900, 1822, 657, 29918, 3027, 29918, 2311, 580, 13, 29871, 4036, 29918, 29886, 15711, 353, 14013, 29901, 313, 8172, 580, 334, 281, 29892, 4036, 580, 334, 298, 29897, 13, 29871, 17036, 353, 8525, 29889, 2003, 29906, 29918, 8896, 29898, 8172, 29918, 29886, 15711, 580, 363, 474, 297, 3464, 29898, 29896, 29900, 29900, 876, 13, 29871, 921, 29891, 29918, 4317, 353, 1439, 3019, 29961, 29900, 1822, 29886, 15711, 29918, 517, 29918, 19958, 14772, 29898, 29886, 861, 1379, 29897, 13, 29871, 921, 29891, 29918, 1756, 353, 1439, 3019, 29961, 29900, 1822, 19958, 14772, 29918, 517, 29918, 29886, 15711, 29898, 3594, 29918, 4317, 29897, 13, 29871, 4974, 2134, 29916, 29918, 11745, 29898, 3594, 29918, 1756, 29892, 17036, 29892, 321, 567, 29922, 8961, 29897, 13, 29871, 363, 921, 29891, 297, 17036, 29901, 13, 1678, 921, 29891, 29918, 4317, 353, 1439, 3019, 29961, 29900, 1822, 29886, 15711, 29918, 517, 29918, 19958, 14772, 29898, 3594, 29897, 13, 1678, 921, 29891, 29918, 1756, 353, 1439, 3019, 29961, 29900, 1822, 19958, 14772, 29918, 517, 29918, 29886, 15711, 29898, 3594, 29918, 4317, 29897, 13, 1678, 4974, 29898, 6897, 29898, 5344, 29889, 1054, 29898, 3594, 29918, 1756, 29897, 448, 4636, 29889, 1054, 29898, 3594, 876, 529, 321, 567, 29897, 13, 13, 1753, 260, 303, 29918, 862, 9864, 29916, 29918, 2616, 276, 428, 29898, 4801, 3019, 1125, 13, 29871, 515, 4036, 1053, 9090, 13, 29871, 515, 885, 277, 29890, 29916, 1053, 4636, 13, 29871, 4036, 29918, 1111, 536, 353, 14013, 29901, 313, 13, 418, 9090, 6278, 29896, 29900, 29900, 29900, 29892, 29871, 29896, 29900, 29900, 29900, 511, 13, 418, 9090, 6278, 29896, 29900, 29900, 29900, 29892, 29871, 29896, 29900, 29900, 29900, 876, 13, 29871, 363, 474, 297, 3464, 29898, 29896, 29900, 29900, 29900, 29900, 1125, 13, 1678, 5654, 353, 4036, 29918, 1111, 536, 580, 13, 1678, 282, 29916, 353, 1439, 3019, 29961, 29900, 1822, 19958, 14772, 29918, 517, 29918, 29886, 15711, 29898, 4317, 29897, 13, 1678, 5654, 29906, 353, 1439, 3019, 29961, 29900, 1822, 29886, 15711, 29918, 517, 29918, 19958, 14772, 29898, 1756, 29897, 13, 1678, 4974, 29898, 6897, 29898, 5344, 29889, 1054, 29898, 4317, 29897, 448, 4636, 29889, 1054, 29898, 4317, 29906, 876, 529, 29871, 29896, 29872, 29899, 29941, 29897, 13, 13, 1753, 260, 303, 29918, 657, 29918, 7039, 29898, 4801, 3019, 1125, 13, 29871, 2983, 353, 1439, 3019, 29889, 657, 29918, 7039, 580, 13, 29871, 4974, 29898, 2435, 29898, 7039, 29897, 1275, 29871, 29896, 29897, 13, 29871, 4974, 29898, 7039, 29961, 29900, 29962, 1275, 525, 7490, 1495, 13, 13, 1753, 260, 303, 29918, 657, 29918, 27996, 2264, 29898, 4801, 3019, 1125, 13, 29871, 363, 9451, 297, 1439, 3019, 29901, 13, 1678, 4974, 29898, 15119, 29889, 657, 29918, 27996, 2264, 580, 1275, 29871, 29900, 29889, 29896, 29897, 13, 13, 1753, 260, 303, 29918, 657, 29918, 15388, 29898, 4801, 3019, 1125, 13, 29871, 363, 9451, 297, 1439, 3019, 29901, 13, 1678, 4974, 29898, 15119, 29889, 657, 29918, 15388, 580, 1275, 525, 25598, 1495, 13, 13, 1753, 260, 303, 29918, 842, 29918, 7681, 1579, 29885, 29918, 915, 314, 29918, 1760, 276, 29898, 4801, 3019, 1125, 13, 29871, 515, 885, 277, 29890, 29916, 1053, 4636, 13, 29871, 515, 270, 486, 29890, 29916, 29889, 4299, 1053, 1522, 314, 13, 29871, 281, 6447, 1477, 353, 29871, 29896, 13, 29871, 9451, 353, 1439, 3019, 29961, 29900, 29962, 13, 29871, 1439, 3019, 29918, 8945, 353, 4636, 29889, 1054, 29898, 15119, 29889, 657, 29918, 8945, 3101, 13, 29871, 3978, 353, 4636, 29889, 1054, 29898, 15119, 29889, 657, 29918, 12574, 3101, 13, 29871, 5172, 29918, 8990, 353, 4636, 29889, 1054, 29898, 15119, 29889, 657, 29918, 11255, 29918, 8990, 3101, 13, 29871, 5232, 29918, 8990, 353, 4636, 29889, 1054, 29898, 15119, 29889, 657, 29918, 28544, 29918, 8990, 3101, 13, 29871, 1967, 29918, 2311, 353, 9451, 29889, 657, 29918, 3027, 29918, 2311, 29918, 4317, 580, 13, 13, 29871, 269, 29900, 353, 313, 29896, 29889, 29900, 29914, 29893, 6447, 1477, 29897, 334, 1439, 3019, 29918, 8945, 13, 29871, 22913, 353, 1522, 314, 6278, 29879, 29900, 29889, 8945, 675, 3285, 281, 6447, 1477, 29897, 13, 13, 29871, 22913, 29918, 1760, 276, 353, 4636, 29889, 1054, 29898, 15119, 29889, 657, 29918, 915, 314, 29918, 1760, 276, 29898, 915, 314, 29889, 657, 29918, 29879, 29900, 22130, 13, 29871, 3978, 29918, 10889, 353, 4636, 29889, 1054, 3552, 29896, 29892, 29871, 29900, 29889, 29945, 876, 13, 29871, 716, 29918, 915, 314, 29918, 1760, 276, 353, 22913, 29918, 1760, 276, 718, 3978, 29918, 10889, 13, 13, 29871, 716, 29918, 7681, 1579, 29885, 29918, 915, 314, 29918, 1760, 276, 353, 18761, 29898, 276, 874, 287, 29898, 1482, 29918, 915, 314, 29918, 1760, 276, 876, 13, 13, 29871, 515, 270, 486, 29890, 29916, 29889, 4299, 29889, 4801, 3019, 29918, 3952, 6774, 1053, 731, 29918, 7681, 1579, 29885, 29918, 915, 314, 29918, 1760, 276, 13, 29871, 731, 29918, 7681, 1579, 29885, 29918, 915, 314, 29918, 1760, 276, 29898, 4801, 3019, 29892, 22913, 29892, 716, 29918, 7681, 1579, 29885, 29918, 915, 314, 29918, 1760, 276, 29897, 13, 13, 29871, 4974, 313, 5344, 29889, 1054, 29898, 15119, 29889, 657, 29918, 915, 314, 29918, 1760, 276, 29898, 915, 314, 29889, 657, 29918, 29879, 29900, 22130, 448, 13, 3986, 4636, 29889, 1054, 29898, 23583, 29898, 276, 874, 287, 29898, 1482, 29918, 7681, 1579, 29885, 29918, 915, 314, 29918, 1760, 276, 4961, 467, 2848, 580, 529, 29871, 29896, 29872, 29899, 29953, 13, 13, 1753, 260, 303, 29918, 4801, 11142, 29918, 598, 29918, 17642, 29898, 4801, 29909, 29892, 1439, 29933, 1125, 13, 29871, 14550, 6108, 2877, 5455, 373, 1439, 3019, 3618, 1818, 12439, 13557, 6459, 943, 12008, 13, 29871, 4974, 29898, 4801, 29909, 1275, 1439, 29933, 29897, 13, 13, 1753, 260, 303, 29918, 4801, 11142, 29918, 598, 29918, 29881, 15622, 29898, 4801, 29909, 29892, 1439, 29933, 1125, 13, 29871, 14550, 6108, 2877, 5455, 373, 1439, 3019, 3618, 1818, 1284, 12651, 297, 3978, 12008, 13, 29871, 4974, 29898, 4801, 29909, 2804, 1439, 29933, 29897, 13, 13, 1753, 260, 303, 29918, 9778, 918, 29898, 4801, 3019, 1125, 13, 29871, 515, 270, 486, 29890, 29916, 29889, 4299, 1053, 1522, 314, 13, 29871, 22913, 353, 1522, 314, 29898, 20845, 7607, 29900, 29892, 29900, 29892, 29896, 511, 281, 6447, 1477, 29922, 29896, 29889, 29900, 29897, 13, 29871, 270, 29918, 1195, 29896, 353, 1439, 3019, 29889, 657, 29918, 3317, 29918, 9778, 918, 29898, 915, 314, 29889, 657, 29918, 29879, 29900, 3101, 13, 29871, 270, 29918, 1195, 29906, 353, 1439, 3019, 29889, 657, 29918, 3317, 29918, 1144, 23059, 29918, 9778, 918, 29898, 915, 314, 29889, 657, 29918, 29879, 29900, 3101, 13, 29871, 4974, 270, 29918, 1195, 29896, 529, 270, 29918, 1195, 29906, 13, 13, 1753, 260, 303, 29918, 15119, 29918, 13168, 7295, 13, 29871, 515, 270, 486, 29890, 29916, 29889, 4299, 1053, 349, 3870, 13, 13, 29871, 9451, 353, 349, 3870, 580, 13, 29871, 9451, 29889, 842, 29918, 3027, 29918, 2311, 3552, 29896, 29900, 29900, 29892, 29871, 29896, 29900, 29900, 876, 13, 29871, 9451, 29889, 1202, 29918, 13168, 29898, 29946, 29900, 29892, 29900, 29892, 29953, 29900, 29892, 29896, 29900, 29900, 29897, 13, 29871, 9451, 29889, 1202, 29918, 13168, 29898, 29900, 29892, 29946, 29900, 29892, 29896, 29900, 29900, 29892, 29953, 29900, 29897, 13, 29871, 9451, 29889, 842, 29918, 509, 16656, 29918, 3881, 3552, 29899, 29896, 29892, 29871, 29896, 29900, 876, 13, 13, 29871, 848, 353, 8525, 29889, 8896, 29898, 16041, 29889, 7720, 29898, 29896, 29900, 29900, 29892, 29896, 29900, 29900, 876, 13, 29871, 848, 29961, 29896, 29900, 29892, 29896, 29900, 29962, 353, 448, 29896, 13, 29871, 848, 29961, 29906, 29900, 29892, 29906, 29900, 29962, 353, 29871, 29896, 29900, 13, 29871, 848, 29961, 29941, 29900, 29892, 29941, 29900, 29962, 353, 29871, 29896, 29900, 29900, 13, 29871, 848, 29961, 29946, 29900, 29892, 29946, 29900, 29962, 353, 448, 29896, 29900, 13, 13, 29871, 286, 29896, 353, 9451, 29889, 657, 29918, 348, 509, 16656, 29918, 1621, 2521, 29918, 13168, 580, 13, 29871, 286, 29906, 353, 9451, 29889, 657, 29918, 509, 16656, 29918, 3881, 29918, 13168, 29898, 1272, 29897, 13, 13, 29871, 2302, 353, 29871, 29900, 13, 29871, 363, 432, 297, 3464, 29898, 29896, 29900, 29900, 1125, 13, 1678, 363, 474, 297, 3464, 29898, 29946, 29900, 29892, 29953, 29900, 1125, 13, 418, 4974, 29898, 29885, 29896, 29961, 29926, 29892, 29875, 29962, 1275, 7700, 29897, 13, 418, 2302, 4619, 29871, 29896, 13, 29871, 363, 474, 297, 3464, 29898, 29896, 29900, 29900, 1125, 13, 1678, 363, 432, 297, 3464, 29898, 29946, 29900, 29892, 29953, 29900, 1125, 13, 418, 565, 474, 6736, 29871, 29946, 29900, 322, 474, 529, 29871, 29953, 29900, 29901, 13, 4706, 6773, 13, 418, 4974, 29898, 29885, 29896, 29961, 29926, 29892, 29875, 29962, 1275, 7700, 29897, 13, 418, 2302, 4619, 29871, 29896, 13, 29871, 4974, 286, 29896, 29889, 2798, 29898, 8824, 29897, 1275, 2302, 29892, 11860, 29881, 29892, 1273, 29881, 29908, 1273, 313, 29885, 29896, 29889, 2798, 29898, 8824, 511, 2302, 29897, 13, 13, 29871, 4974, 286, 29906, 29889, 2798, 29898, 8824, 29897, 1275, 29871, 29946, 13, 29871, 4974, 286, 29906, 29961, 29896, 29900, 29892, 29896, 29900, 29962, 1275, 7700, 13, 29871, 4974, 286, 29906, 29961, 29906, 29900, 29892, 29906, 29900, 29962, 1275, 7700, 13, 29871, 4974, 286, 29906, 29961, 29941, 29900, 29892, 29941, 29900, 29962, 1275, 7700, 13, 29871, 4974, 286, 29906, 29961, 29946, 29900, 29892, 29946, 29900, 29962, 1275, 7700, 13, 13, 1753, 1243, 29918, 4801, 3019, 7295, 13, 29871, 515, 270, 486, 29890, 29916, 29889, 4299, 1053, 1459, 9864, 29916, 12521, 1621, 287, 29925, 29916, 29924, 29885, 26910, 13, 13, 29871, 822, 1653, 29918, 4801, 3019, 29898, 10289, 353, 29871, 29900, 1125, 13, 1678, 396, 6204, 278, 1439, 3019, 13, 1678, 1439, 3019, 353, 5953, 3019, 29898, 7490, 29898, 13, 418, 12633, 462, 396, 5167, 13, 418, 376, 7490, 613, 9651, 396, 4408, 13, 418, 313, 29896, 29900, 29892, 29871, 29900, 29892, 29871, 29900, 511, 308, 396, 23786, 9685, 13, 418, 313, 29900, 29892, 29871, 29896, 29900, 29892, 29871, 29900, 511, 308, 396, 317, 677, 9685, 13, 418, 313, 29900, 718, 9210, 29892, 29871, 29900, 718, 9210, 29892, 29871, 29906, 29900, 29900, 448, 9210, 511, 13, 462, 3986, 396, 22118, 13, 418, 313, 29900, 29889, 29896, 29955, 29906, 29892, 29871, 29900, 29889, 29896, 29955, 29906, 511, 268, 396, 349, 15711, 2159, 13, 418, 313, 29945, 29896, 29906, 29892, 29871, 29945, 29896, 29906, 511, 308, 396, 7084, 2159, 13, 418, 313, 29900, 29892, 29871, 29896, 29900, 29900, 29900, 511, 3986, 396, 1605, 16656, 3464, 13, 539, 29900, 29889, 29896, 29892, 18884, 396, 498, 860, 2264, 13, 418, 376, 25598, 613, 1669, 396, 17582, 13, 418, 15882, 543, 29896, 29906, 29941, 5783, 29871, 396, 20286, 13, 1678, 736, 1439, 3019, 13, 13, 29871, 1439, 3019, 353, 1653, 29918, 4801, 3019, 580, 13, 13, 29871, 396, 27313, 777, 6987, 13, 29871, 260, 303, 29918, 657, 29918, 25378, 29898, 4801, 3019, 29897, 13, 29871, 260, 303, 29918, 657, 29918, 29887, 475, 29898, 4801, 3019, 29897, 13, 29871, 260, 303, 29918, 842, 29918, 7681, 1579, 29885, 29918, 915, 314, 29918, 1760, 276, 29898, 4801, 3019, 29897, 13, 29871, 260, 303, 29918, 657, 29918, 29886, 15711, 29918, 8205, 29918, 1111, 536, 29898, 4801, 3019, 29897, 13, 29871, 260, 303, 29918, 657, 29918, 3027, 29918, 2311, 29918, 4317, 29898, 4801, 3019, 29897, 13, 29871, 260, 303, 29918, 275, 29918, 1767, 29918, 262, 29918, 509, 16656, 29918, 3881, 29898, 4801, 3019, 29897, 13, 29871, 260, 303, 29918, 275, 29918, 1111, 536, 29918, 3084, 29898, 4801, 3019, 29897, 13, 29871, 260, 303, 29918, 29886, 15711, 29918, 517, 29918, 19958, 14772, 29918, 517, 29918, 29886, 15711, 29898, 4801, 3019, 29897, 13, 29871, 260, 303, 29918, 657, 29918, 7039, 29898, 4801, 3019, 29897, 13, 29871, 260, 303, 29918, 657, 29918, 27996, 2264, 29898, 4801, 3019, 29897, 13, 29871, 260, 303, 29918, 657, 29918, 15388, 29898, 4801, 3019, 29897, 13, 29871, 260, 303, 29918, 9778, 918, 29898, 4801, 3019, 29897, 13, 29871, 260, 303, 29918, 15119, 29918, 13168, 580, 13, 13, 29871, 396, 6212, 4814, 362, 3309, 13, 29871, 515, 274, 312, 29890, 29916, 29889, 2152, 29890, 29916, 1053, 472, 841, 29884, 362, 29918, 1111, 8462, 13, 29871, 1591, 353, 472, 841, 29884, 362, 29918, 1111, 8462, 29889, 657, 29918, 2371, 703, 25598, 1159, 13, 29871, 3887, 353, 1591, 29889, 2589, 29918, 271, 29918, 574, 303, 456, 29898, 29896, 29897, 847, 29871, 29896, 29900, 29889, 29900, 13, 29871, 260, 29900, 353, 29871, 29900, 29889, 29941, 29906, 29900, 13, 13, 29871, 396, 6204, 1790, 1439, 3019, 411, 1422, 3978, 13, 29871, 1439, 3019, 29918, 29885, 8238, 353, 1653, 29918, 4801, 3019, 29898, 10289, 29922, 29896, 29900, 29900, 29897, 13, 29871, 260, 303, 29918, 4801, 11142, 29918, 598, 29918, 29881, 15622, 29898, 4801, 3019, 29892, 1439, 3019, 29918, 29885, 8238, 29897, 13, 13, 29871, 1439, 3019, 29918, 29885, 8238, 29918, 8552, 353, 1653, 29918, 4801, 3019, 29898, 10289, 29922, 29896, 29900, 29900, 29897, 13, 29871, 260, 303, 29918, 4801, 11142, 29918, 598, 29918, 17642, 29898, 4801, 3019, 29918, 29885, 8238, 29892, 1439, 3019, 29918, 29885, 8238, 29918, 8552, 29897, 13, 13, 29871, 396, 6204, 278, 1439, 3019, 13, 29871, 1439, 3019, 353, 5953, 3019, 29898, 7490, 29898, 13, 418, 12633, 462, 396, 5167, 13, 418, 12633, 462, 396, 4408, 13, 418, 313, 29896, 29900, 29892, 29871, 29900, 29892, 29871, 29900, 511, 308, 396, 23786, 9685, 13, 418, 313, 29900, 29892, 29871, 29896, 29900, 29892, 29871, 29900, 511, 308, 396, 317, 677, 9685, 13, 418, 313, 29900, 29892, 29871, 29900, 29892, 29871, 29906, 29900, 29900, 511, 4706, 396, 22118, 13, 418, 313, 29900, 29889, 29896, 29955, 29906, 29892, 29871, 29900, 29889, 29896, 29955, 29906, 511, 268, 396, 349, 15711, 2159, 13, 418, 313, 29945, 29896, 29906, 29892, 29871, 29945, 29896, 29906, 511, 308, 396, 7084, 2159, 13, 418, 313, 29900, 29892, 29871, 29896, 29900, 29900, 29900, 511, 3986, 396, 1605, 16656, 3464, 13, 539, 29900, 29889, 29900, 29892, 18884, 396, 498, 860, 2264, 13, 418, 12633, 462, 396, 17582, 13, 418, 1459, 9864, 29916, 12521, 1621, 287, 29925, 29916, 29924, 29885, 26910, 29898, 2589, 29892, 260, 29900, 4961, 13, 13, 29871, 260, 303, 29918, 862, 9864, 29916, 29918, 2616, 276, 428, 29898, 4801, 3019, 29897, 13, 2 ]
setup.py
hanase/developer
3
68278
<gh_stars>1-10 # Install setuptools if not installed. try: import setuptools except ImportError: from ez_setup import use_setuptools use_setuptools() from setuptools import setup, find_packages setup( name='developer', version='0.3.0', description='UrbanSim developer model', author='<NAME>.', author_email='<EMAIL>', license='BSD', url='https://github.com/udst/developer', classifiers=[ 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3.5' ], packages=find_packages(exclude=['*.tests']), install_requires=[ 'numpy >= 1.1.0', 'pandas >= 0.16.0', 'orca >= 1.3.0', 'urbansim >= 0.1.1', ], extras_require={ 'pandana': ['pandana>=0.1'] } )
[ 1, 529, 12443, 29918, 303, 1503, 29958, 29896, 29899, 29896, 29900, 13, 29937, 16052, 731, 21245, 8789, 565, 451, 5130, 29889, 13, 2202, 29901, 13, 1678, 1053, 731, 21245, 8789, 13, 19499, 16032, 2392, 29901, 13, 1678, 515, 20803, 29918, 14669, 1053, 671, 29918, 842, 21245, 8789, 13, 1678, 671, 29918, 842, 21245, 8789, 580, 13, 13, 3166, 731, 21245, 8789, 1053, 6230, 29892, 1284, 29918, 8318, 13, 13, 14669, 29898, 13, 1678, 1024, 2433, 6734, 742, 13, 1678, 1873, 2433, 29900, 29889, 29941, 29889, 29900, 742, 13, 1678, 6139, 2433, 29965, 29878, 2571, 8942, 13897, 1904, 742, 13, 1678, 4148, 2433, 29966, 5813, 15513, 742, 13, 1678, 4148, 29918, 5269, 2433, 29966, 26862, 6227, 29958, 742, 13, 1678, 19405, 2433, 29933, 7230, 742, 13, 1678, 3142, 2433, 991, 597, 3292, 29889, 510, 29914, 566, 303, 29914, 6734, 742, 13, 1678, 770, 14903, 11759, 13, 4706, 525, 9283, 4056, 17088, 4761, 5132, 4761, 29871, 29906, 29889, 29955, 742, 13, 4706, 525, 9283, 4056, 17088, 4761, 5132, 4761, 29871, 29941, 29889, 29945, 29915, 13, 1678, 21251, 13, 1678, 9741, 29922, 2886, 29918, 8318, 29898, 735, 2325, 29922, 1839, 10521, 21150, 2033, 511, 13, 1678, 2601, 29918, 276, 339, 2658, 11759, 13, 4706, 525, 23749, 6736, 29871, 29896, 29889, 29896, 29889, 29900, 742, 13, 4706, 525, 15112, 6736, 29871, 29900, 29889, 29896, 29953, 29889, 29900, 742, 13, 4706, 525, 272, 1113, 6736, 29871, 29896, 29889, 29941, 29889, 29900, 742, 13, 4706, 525, 9265, 550, 326, 6736, 29871, 29900, 29889, 29896, 29889, 29896, 742, 13, 1678, 21251, 13, 1678, 429, 10678, 29918, 12277, 3790, 13, 4706, 525, 29886, 392, 1648, 2396, 6024, 29886, 392, 1648, 18572, 29900, 29889, 29896, 2033, 13, 1678, 500, 13, 29897, 13, 2 ]
plotting/plotly.py
TPei/jawbone_visualizer
0
37868
<gh_stars>0 __author__ = 'TPei' from plotting.plotly.graph_objs import * from data.DataHandler import get_all_the_data """ Working with the plotly api to create more interactive diagrams """ def sleep(): data = get_all_the_data() traces = [] categories = ['bed', 'sleep', 'sound', 'light', 'awake', 'averages'] sleep_data = [[], [], [], [], [], []] for date in data: entry = data[date] for i in range(0, len(categories)-1): sleep_data[i].append(entry[categories[i]]) total_sleep = 0 averages = [] for i in range(0, len(sleep_data[1])): total_sleep += sleep_data[1][i] averages.append(total_sleep / float(i+1)) sleep_data[5] = averages for i in range(0, len(sleep_data)): traces.append(Scatter(y=sleep_data[i], name=categories[i])) data = Data(traces) unique_url = py.plot(data, filename='sleep') ''' trace0 = Scatter( #x=[1, 2, 3, 4], y=sleep ) trace1 = Scatter( #x=[1, 2, 3, 4], y=[16, 5, 11, 9] ) data = Data([trace0, trace1]) unique_url = py.plot(data, filename = 'basic-line')''' def coffee_vs_sleep(): data = get_all_the_data() categories = ['0 cups', '1 or 2 cups', '3 or 4 cups', '5+ cups'] count = [0, 0, 0, 0] average_counter = [0, 0, 0, 0] average = [0, 0, 0, 0] import collections od = collections.OrderedDict(sorted(data.items())) print(od) category = 'sleep' for day in od: if 'coffee' in od[day] and category in od[day]: #coffee.append(od[day]['coffee']) if od[day]['coffee'] == 0: count[0] += od[day][category] average_counter[0] += 1 elif od[day]['coffee'] < 3: count[1] += od[day][category] average_counter[1] += 1 elif od[day]['coffee'] < 5: count[2] += od[day][category] average_counter[2] += 1 else: count[3] += od[day][category] average_counter[3] += 1 else: count[0] += od[day][category] average_counter[0] += 1 #calculate average for i in range(0, len(count)): if average_counter[i] == 0: average[i] = 0 else: average[i] = (count[i] / float(average_counter[i])) trace = Bar(y=average, x=categories) data = Data([trace]) unique_url = py.plot(data, filename='coffee_vs_sleep') if __name__ == '__main__': #sleep() coffee_vs_sleep()
[ 1, 529, 12443, 29918, 303, 1503, 29958, 29900, 13, 1649, 8921, 1649, 353, 525, 3557, 10096, 29915, 13, 3166, 6492, 1259, 29889, 5317, 368, 29889, 4262, 29918, 711, 1315, 1053, 334, 13, 13, 3166, 848, 29889, 1469, 4598, 1053, 679, 29918, 497, 29918, 1552, 29918, 1272, 13, 13, 13, 15945, 29908, 13, 5531, 292, 411, 278, 6492, 368, 7882, 304, 1653, 901, 28923, 7936, 25402, 13, 15945, 29908, 13, 13, 13, 1753, 8709, 7295, 13, 13, 1678, 848, 353, 679, 29918, 497, 29918, 1552, 29918, 1272, 580, 13, 13, 1678, 26695, 353, 5159, 13, 13, 1678, 13997, 353, 6024, 2580, 742, 525, 17059, 742, 525, 29802, 742, 525, 4366, 742, 525, 1450, 1296, 742, 525, 12483, 1179, 2033, 13, 13, 1678, 8709, 29918, 1272, 353, 5519, 1402, 19997, 19997, 19997, 19997, 5159, 29962, 13, 13, 1678, 363, 2635, 297, 848, 29901, 13, 4706, 6251, 353, 848, 29961, 1256, 29962, 13, 4706, 363, 474, 297, 3464, 29898, 29900, 29892, 7431, 29898, 20683, 6817, 29896, 1125, 13, 9651, 8709, 29918, 1272, 29961, 29875, 1822, 4397, 29898, 8269, 29961, 20683, 29961, 29875, 24960, 13, 13, 1678, 3001, 29918, 17059, 353, 29871, 29900, 13, 1678, 4759, 1179, 353, 5159, 13, 1678, 363, 474, 297, 3464, 29898, 29900, 29892, 7431, 29898, 17059, 29918, 1272, 29961, 29896, 12622, 29901, 13, 4706, 3001, 29918, 17059, 4619, 8709, 29918, 1272, 29961, 29896, 3816, 29875, 29962, 13, 4706, 4759, 1179, 29889, 4397, 29898, 7827, 29918, 17059, 847, 5785, 29898, 29875, 29974, 29896, 876, 13, 13, 1678, 8709, 29918, 1272, 29961, 29945, 29962, 353, 4759, 1179, 13, 13, 13, 1678, 363, 474, 297, 3464, 29898, 29900, 29892, 7431, 29898, 17059, 29918, 1272, 22164, 13, 4706, 26695, 29889, 4397, 29898, 4421, 2620, 29898, 29891, 29922, 17059, 29918, 1272, 29961, 29875, 1402, 1024, 29922, 20683, 29961, 29875, 12622, 13, 13, 1678, 848, 353, 3630, 29898, 3018, 778, 29897, 13, 13, 1678, 5412, 29918, 2271, 353, 11451, 29889, 5317, 29898, 1272, 29892, 10422, 2433, 17059, 1495, 13, 13, 1678, 14550, 13, 1678, 9637, 29900, 353, 2522, 2620, 29898, 13, 4706, 396, 29916, 11759, 29896, 29892, 29871, 29906, 29892, 29871, 29941, 29892, 29871, 29946, 1402, 13, 4706, 343, 29922, 17059, 13, 1678, 1723, 13, 1678, 9637, 29896, 353, 2522, 2620, 29898, 13, 4706, 396, 29916, 11759, 29896, 29892, 29871, 29906, 29892, 29871, 29941, 29892, 29871, 29946, 1402, 13, 4706, 343, 11759, 29896, 29953, 29892, 29871, 29945, 29892, 29871, 29896, 29896, 29892, 29871, 29929, 29962, 13, 1678, 1723, 13, 1678, 848, 353, 3630, 4197, 15003, 29900, 29892, 9637, 29896, 2314, 13, 13, 1678, 5412, 29918, 2271, 353, 11451, 29889, 5317, 29898, 1272, 29892, 10422, 353, 525, 16121, 29899, 1220, 1495, 12008, 13, 13, 1753, 26935, 29918, 4270, 29918, 17059, 7295, 13, 1678, 848, 353, 679, 29918, 497, 29918, 1552, 29918, 1272, 580, 13, 1678, 13997, 353, 6024, 29900, 2723, 567, 742, 525, 29896, 470, 29871, 29906, 2723, 567, 742, 525, 29941, 470, 29871, 29946, 2723, 567, 742, 525, 29945, 29974, 2723, 567, 2033, 13, 1678, 2302, 353, 518, 29900, 29892, 29871, 29900, 29892, 29871, 29900, 29892, 29871, 29900, 29962, 13, 1678, 6588, 29918, 11808, 353, 518, 29900, 29892, 29871, 29900, 29892, 29871, 29900, 29892, 29871, 29900, 29962, 13, 1678, 6588, 353, 518, 29900, 29892, 29871, 29900, 29892, 29871, 29900, 29892, 29871, 29900, 29962, 13, 13, 1678, 1053, 16250, 13, 13, 1678, 2413, 353, 16250, 29889, 7514, 287, 21533, 29898, 24582, 29898, 1272, 29889, 7076, 22130, 13, 13, 1678, 1596, 29898, 397, 29897, 13, 13, 1678, 7663, 353, 525, 17059, 29915, 13, 13, 1678, 363, 2462, 297, 2413, 29901, 13, 13, 4706, 565, 525, 1111, 600, 3905, 29915, 297, 2413, 29961, 3250, 29962, 322, 7663, 297, 2413, 29961, 3250, 5387, 13, 9651, 396, 1111, 600, 3905, 29889, 4397, 29898, 397, 29961, 3250, 22322, 1111, 600, 3905, 11287, 13, 9651, 565, 2413, 29961, 3250, 22322, 1111, 600, 3905, 2033, 1275, 29871, 29900, 29901, 13, 18884, 2302, 29961, 29900, 29962, 4619, 2413, 29961, 3250, 3816, 7320, 29962, 13, 18884, 6588, 29918, 11808, 29961, 29900, 29962, 4619, 29871, 29896, 13, 9651, 25342, 2413, 29961, 3250, 22322, 1111, 600, 3905, 2033, 529, 29871, 29941, 29901, 13, 18884, 2302, 29961, 29896, 29962, 4619, 2413, 29961, 3250, 3816, 7320, 29962, 13, 18884, 6588, 29918, 11808, 29961, 29896, 29962, 4619, 29871, 29896, 13, 9651, 25342, 2413, 29961, 3250, 22322, 1111, 600, 3905, 2033, 529, 29871, 29945, 29901, 13, 18884, 2302, 29961, 29906, 29962, 4619, 2413, 29961, 3250, 3816, 7320, 29962, 13, 18884, 6588, 29918, 11808, 29961, 29906, 29962, 4619, 29871, 29896, 13, 9651, 1683, 29901, 13, 18884, 2302, 29961, 29941, 29962, 4619, 2413, 29961, 3250, 3816, 7320, 29962, 13, 18884, 6588, 29918, 11808, 29961, 29941, 29962, 4619, 29871, 29896, 13, 4706, 1683, 29901, 13, 9651, 2302, 29961, 29900, 29962, 4619, 2413, 29961, 3250, 3816, 7320, 29962, 13, 9651, 6588, 29918, 11808, 29961, 29900, 29962, 4619, 29871, 29896, 13, 13, 1678, 396, 15807, 403, 6588, 13, 1678, 363, 474, 297, 3464, 29898, 29900, 29892, 7431, 29898, 2798, 22164, 13, 4706, 565, 6588, 29918, 11808, 29961, 29875, 29962, 1275, 29871, 29900, 29901, 13, 9651, 6588, 29961, 29875, 29962, 353, 29871, 29900, 13, 4706, 1683, 29901, 13, 9651, 6588, 29961, 29875, 29962, 353, 313, 2798, 29961, 29875, 29962, 847, 5785, 29898, 12483, 482, 29918, 11808, 29961, 29875, 12622, 13, 13, 1678, 9637, 353, 2261, 29898, 29891, 29922, 12483, 482, 29892, 921, 29922, 20683, 29897, 13, 13, 1678, 848, 353, 3630, 4197, 15003, 2314, 13, 13, 1678, 5412, 29918, 2271, 353, 11451, 29889, 5317, 29898, 1272, 29892, 10422, 2433, 1111, 600, 3905, 29918, 4270, 29918, 17059, 1495, 13, 13, 361, 4770, 978, 1649, 1275, 525, 1649, 3396, 1649, 2396, 13, 1678, 396, 17059, 580, 13, 1678, 26935, 29918, 4270, 29918, 17059, 580, 2 ]
backend/backend/views.py
AurelienGasser/substra-backend
37
134325
<reponame>AurelienGasser/substra-backend import os from rest_framework.authtoken.views import ObtainAuthToken from rest_framework.throttling import AnonRateThrottle from rest_framework.authtoken.models import Token from rest_framework.response import Response from libs.expiry_token_authentication import token_expire_handler, expires_at from libs.user_login_throttle import UserLoginThrottle from rest_framework.views import APIView from substrapp.views.utils import get_channel_name from django.conf import settings class ExpiryObtainAuthToken(ObtainAuthToken): authentication_classes = [] throttle_classes = [AnonRateThrottle, UserLoginThrottle] def post(self, request, *args, **kwargs): serializer = self.serializer_class(data=request.data, context={'request': request}) serializer.is_valid(raise_exception=True) user = serializer.validated_data['user'] if os.environ.get('TOKEN_STRATEGY', 'unique') == 'reuse': token, created = Token.objects.get_or_create(user=user) # token_expire_handler will check, if the token is expired it will generate new one is_expired, token = token_expire_handler(token) else: # token should be new each time, remove the old one Token.objects.filter(user=user).delete() token = Token.objects.create(user=user) return Response({ 'token': token.key, 'expires_at': expires_at(token) }) class Info(APIView): def get(self, request, *args, **kwargs): channel_name = get_channel_name(request) channel = settings.LEDGER_CHANNELS[channel_name] return Response({ 'host': settings.DEFAULT_DOMAIN, 'channel': channel_name, 'config': { 'model_export_enabled': channel['model_export_enabled'], } }) obtain_auth_token = ExpiryObtainAuthToken.as_view() info_view = Info.as_view()
[ 1, 529, 276, 1112, 420, 29958, 29909, 545, 492, 264, 29954, 9498, 29914, 1491, 4151, 29899, 27852, 13, 5215, 2897, 13, 3166, 1791, 29918, 4468, 29889, 1300, 400, 4476, 29889, 7406, 1053, 4250, 2408, 6444, 6066, 13, 3166, 1791, 29918, 4468, 29889, 386, 26970, 1847, 1053, 530, 265, 19907, 1349, 26970, 280, 13, 13, 3166, 1791, 29918, 4468, 29889, 1300, 400, 4476, 29889, 9794, 1053, 25159, 13, 3166, 1791, 29918, 4468, 29889, 5327, 1053, 13291, 13, 13, 3166, 4303, 29879, 29889, 4548, 16129, 29918, 6979, 29918, 23055, 1053, 5993, 29918, 4548, 533, 29918, 13789, 29892, 1518, 2658, 29918, 271, 13, 3166, 4303, 29879, 29889, 1792, 29918, 7507, 29918, 386, 26970, 280, 1053, 4911, 11049, 1349, 26970, 280, 13, 13, 3166, 1791, 29918, 4468, 29889, 7406, 1053, 3450, 1043, 13, 3166, 1014, 4151, 407, 29889, 7406, 29889, 13239, 1053, 679, 29918, 12719, 29918, 978, 13, 3166, 9557, 29889, 5527, 1053, 6055, 13, 13, 13, 1990, 12027, 16129, 6039, 2408, 6444, 6066, 29898, 6039, 2408, 6444, 6066, 1125, 13, 1678, 10760, 29918, 13203, 353, 5159, 13, 1678, 20961, 698, 280, 29918, 13203, 353, 518, 2744, 265, 19907, 1349, 26970, 280, 29892, 4911, 11049, 1349, 26970, 280, 29962, 13, 13, 1678, 822, 1400, 29898, 1311, 29892, 2009, 29892, 334, 5085, 29892, 3579, 19290, 1125, 13, 4706, 7797, 3950, 353, 1583, 29889, 15550, 3950, 29918, 1990, 29898, 1272, 29922, 3827, 29889, 1272, 29892, 13, 462, 462, 965, 3030, 3790, 29915, 3827, 2396, 2009, 1800, 13, 4706, 7797, 3950, 29889, 275, 29918, 3084, 29898, 22692, 29918, 11739, 29922, 5574, 29897, 13, 4706, 1404, 353, 7797, 3950, 29889, 3084, 630, 29918, 1272, 1839, 1792, 2033, 13, 13, 4706, 565, 2897, 29889, 21813, 29889, 657, 877, 4986, 29968, 1430, 29918, 10810, 3040, 29954, 29979, 742, 525, 13092, 1495, 1275, 525, 276, 1509, 2396, 13, 9651, 5993, 29892, 2825, 353, 25159, 29889, 12650, 29889, 657, 29918, 272, 29918, 3258, 29898, 1792, 29922, 1792, 29897, 13, 13, 9651, 396, 5993, 29918, 4548, 533, 29918, 13789, 674, 1423, 29892, 565, 278, 5993, 338, 1518, 2859, 372, 674, 5706, 716, 697, 13, 9651, 338, 29918, 4548, 2859, 29892, 5993, 353, 5993, 29918, 4548, 533, 29918, 13789, 29898, 6979, 29897, 13, 13, 4706, 1683, 29901, 13, 9651, 396, 5993, 881, 367, 716, 1269, 931, 29892, 3349, 278, 2030, 697, 13, 9651, 25159, 29889, 12650, 29889, 4572, 29898, 1792, 29922, 1792, 467, 8143, 580, 13, 9651, 5993, 353, 25159, 29889, 12650, 29889, 3258, 29898, 1792, 29922, 1792, 29897, 13, 13, 4706, 736, 13291, 3319, 13, 9651, 525, 6979, 2396, 5993, 29889, 1989, 29892, 13, 9651, 525, 4548, 2658, 29918, 271, 2396, 1518, 2658, 29918, 271, 29898, 6979, 29897, 13, 4706, 5615, 13, 13, 13, 1990, 22140, 29898, 8787, 1043, 1125, 13, 13, 1678, 822, 679, 29898, 1311, 29892, 2009, 29892, 334, 5085, 29892, 3579, 19290, 1125, 13, 4706, 8242, 29918, 978, 353, 679, 29918, 12719, 29918, 978, 29898, 3827, 29897, 13, 4706, 8242, 353, 6055, 29889, 20566, 17070, 29918, 3210, 2190, 29940, 6670, 29903, 29961, 12719, 29918, 978, 29962, 13, 4706, 736, 13291, 3319, 13, 9651, 525, 3069, 2396, 6055, 29889, 23397, 29918, 3970, 29032, 29892, 13, 9651, 525, 12719, 2396, 8242, 29918, 978, 29892, 13, 9651, 525, 2917, 2396, 426, 13, 18884, 525, 4299, 29918, 15843, 29918, 17590, 2396, 8242, 1839, 4299, 29918, 15843, 29918, 17590, 7464, 13, 9651, 500, 13, 4706, 5615, 13, 13, 13, 711, 2408, 29918, 5150, 29918, 6979, 353, 12027, 16129, 6039, 2408, 6444, 6066, 29889, 294, 29918, 1493, 580, 13, 3888, 29918, 1493, 353, 22140, 29889, 294, 29918, 1493, 580, 13, 2 ]
Qcover/backends/__init__.py
BAQIS-Quantum/Qcover
38
22799
from .backend import Backend from .circuitbyqiskit import CircuitByQiskit from .circuitbyprojectq import CircuitByProjectq from .circuitbycirq import CircuitByCirq from .circuitbyqulacs import CircuitByQulacs # from .circuitbytket import CircuitByTket from .circuitbytensor import CircuitByTensor from .circuitbyqton import CircuitByQton import warnings warnings.filterwarnings("ignore") __all__ = [ 'Backend', 'CircuitByCirq', 'CircuitByQiskit', 'CircuitByProjectq', 'CircuitByTensor', 'CircuitByQulacs', 'CircuitByQton' ]
[ 1, 515, 869, 27852, 1053, 7437, 355, 30004, 13, 3166, 869, 6034, 3121, 1609, 29939, 3873, 277, 1053, 12594, 3121, 2059, 29984, 3873, 277, 30004, 13, 3166, 869, 6034, 3121, 1609, 4836, 29939, 1053, 12594, 3121, 2059, 7653, 29939, 30004, 13, 3166, 869, 6034, 3121, 1609, 19052, 29939, 1053, 12594, 3121, 2059, 29907, 381, 29939, 30004, 13, 3166, 869, 6034, 3121, 1609, 339, 433, 2395, 1053, 12594, 3121, 2059, 29984, 352, 16815, 30004, 13, 29937, 515, 869, 6034, 3121, 1609, 29873, 7873, 1053, 12594, 3121, 2059, 29911, 7873, 30004, 13, 3166, 869, 6034, 3121, 1609, 20158, 1053, 12594, 3121, 2059, 29911, 6073, 30004, 13, 3166, 869, 6034, 3121, 1609, 29939, 880, 1053, 12594, 3121, 2059, 29984, 880, 30004, 13, 5215, 18116, 30004, 13, 25442, 886, 29889, 4572, 25442, 886, 703, 17281, 1159, 30004, 13, 30004, 13, 1649, 497, 1649, 353, 518, 30004, 13, 1678, 525, 5841, 355, 23592, 13, 1678, 525, 23495, 3121, 2059, 29907, 381, 29939, 23592, 13, 1678, 525, 23495, 3121, 2059, 29984, 3873, 277, 23592, 13, 1678, 525, 23495, 3121, 2059, 7653, 29939, 23592, 13, 1678, 525, 23495, 3121, 2059, 29911, 6073, 23592, 13, 1678, 525, 23495, 3121, 2059, 29984, 352, 16815, 23592, 13, 1678, 525, 23495, 3121, 2059, 29984, 880, 29915, 30004, 13, 29962, 30004, 13, 2 ]
fq2sam.py
IRRI-Bioinformatics/variant-calling-pipeline
0
143565
#fq2sam.py: Align fastq read pairs to reference genome. #created by: <NAME> #!/usr/bin/python import sys, getopt, re, os, subprocess def main(argv): #define variables bwa_threads = '' reference = '' read_pair1 = '' output_dir = '' genome_dir = '' #get arguments try: opts, args = getopt.getopt( argv, "hr:p:o:t:", ["ref=","read1=","out=","thread="]) except getopt.GetoptError: print 'fq2sam.py ' + \ '-r <reference> ' + \ '-p <read_pair1> ' + \ '-o <output_dir> ' + \ '-t <bwa_threads>' sys.exit(2) for opt, arg in opts: if opt == '-h': print 'fq2sam.py ' + \ '-r <reference> ' + \ '-p <read_pair1> ' + \ '-o <output_dir> ' + \ '-t <bwa_threads>' sys.exit() elif opt in ("-r", "--ref"): reference = arg elif opt in ("-p", "--read1"): read_pair1 = arg elif opt in ("-o", "--output_dir"): output_dir = arg elif opt in ("-t", "--bwa_threads"): bwa_threads = arg #get read pair names and sam assignment fq_file = ".fq.gz" if fq_file in read_pair1: read_pair2 = read_pair1.replace("1.fq.gz", "2.fq.gz") sam = read_pair1.replace("_1.fq.gz", ".sam") else: read_pair2 = read_pair1.replace("1.fastq.gz", "2.fastq.gz") sam = read_pair1.replace("_1.fastq.gz", ".sam") #extract directories and sam filename split_dir = re.search(r'(.*)/(.*)/(.*sam)', sam, re.M) if split_dir: input_dir = split_dir.group(1) genome_dir = split_dir.group(2) sam = split_dir.group(3) else: print "Nothing found!" #output directory check output_path = output_dir + '/' + genome_dir #output_path = output_dir #if not os.path.exists(output_path): # os.makedirs(output_path) #command for alignment align = 'bwa mem -M -t ' + \ bwa_threads + ' ' + \ reference + ' ' + \ read_pair1 + ' ' + \ read_pair2 + ' ' + \ '>' + ' ' + \ output_path + \ '/' + \ sam #execute command os.system(align) if __name__ == "__main__": main(sys.argv[1:])
[ 1, 396, 29888, 29939, 29906, 13445, 29889, 2272, 29901, 838, 647, 5172, 29939, 1303, 11000, 304, 3407, 2531, 608, 29889, 13, 29937, 11600, 491, 29901, 529, 5813, 29958, 13, 13, 29937, 14708, 4855, 29914, 2109, 29914, 4691, 13, 13, 5215, 10876, 29892, 679, 3670, 29892, 337, 29892, 2897, 29892, 1014, 5014, 13, 13, 1753, 1667, 29898, 19218, 1125, 13, 13, 1678, 396, 7922, 3651, 13, 1678, 289, 2766, 29918, 28993, 353, 6629, 13, 1678, 3407, 353, 6629, 13, 1678, 1303, 29918, 18784, 29896, 353, 6629, 13, 1678, 1962, 29918, 3972, 353, 6629, 13, 1678, 2531, 608, 29918, 3972, 353, 6629, 13, 29871, 13, 1678, 396, 657, 6273, 13, 1678, 1018, 29901, 13, 4706, 29111, 29892, 6389, 353, 679, 3670, 29889, 657, 3670, 29898, 13, 9651, 1852, 29894, 29892, 13, 9651, 376, 1092, 29901, 29886, 29901, 29877, 29901, 29873, 29901, 613, 13, 9651, 6796, 999, 543, 1699, 949, 29896, 543, 1699, 449, 543, 1699, 7097, 543, 2314, 13, 1678, 5174, 679, 3670, 29889, 2577, 3670, 2392, 29901, 13, 4706, 1596, 525, 29888, 29939, 29906, 13445, 29889, 2272, 525, 718, 320, 13, 18884, 17411, 29878, 529, 5679, 29958, 525, 718, 320, 13, 18884, 17411, 29886, 529, 949, 29918, 18784, 29896, 29958, 525, 718, 320, 13, 18884, 17411, 29877, 529, 4905, 29918, 3972, 29958, 525, 718, 320, 13, 18884, 17411, 29873, 529, 29890, 2766, 29918, 28993, 16299, 13, 4706, 10876, 29889, 13322, 29898, 29906, 29897, 13, 1678, 363, 3523, 29892, 1852, 297, 29111, 29901, 13, 4706, 565, 3523, 1275, 17411, 29882, 2396, 13, 9651, 1596, 525, 29888, 29939, 29906, 13445, 29889, 2272, 525, 718, 320, 13, 462, 1678, 17411, 29878, 529, 5679, 29958, 525, 718, 320, 13, 462, 1678, 17411, 29886, 529, 949, 29918, 18784, 29896, 29958, 525, 718, 320, 13, 462, 1678, 17411, 29877, 529, 4905, 29918, 3972, 29958, 525, 718, 320, 13, 462, 1678, 17411, 29873, 529, 29890, 2766, 29918, 28993, 16299, 29871, 13, 9651, 10876, 29889, 13322, 580, 13, 4706, 25342, 3523, 297, 4852, 29899, 29878, 613, 376, 489, 999, 29908, 1125, 13, 9651, 3407, 353, 1852, 13, 4706, 25342, 3523, 297, 4852, 29899, 29886, 613, 376, 489, 949, 29896, 29908, 1125, 13, 9651, 1303, 29918, 18784, 29896, 353, 1852, 13, 4706, 25342, 3523, 297, 4852, 29899, 29877, 613, 376, 489, 4905, 29918, 3972, 29908, 1125, 13, 9651, 1962, 29918, 3972, 353, 1852, 13, 4706, 25342, 3523, 297, 4852, 29899, 29873, 613, 376, 489, 29890, 2766, 29918, 28993, 29908, 1125, 13, 9651, 289, 2766, 29918, 28993, 353, 1852, 13, 13, 1678, 396, 657, 1303, 5101, 2983, 322, 3514, 12827, 13, 1678, 285, 29939, 29918, 1445, 353, 11393, 29888, 29939, 29889, 18828, 29908, 13, 1678, 565, 285, 29939, 29918, 1445, 297, 1303, 29918, 18784, 29896, 29901, 13, 4706, 1303, 29918, 18784, 29906, 353, 1303, 29918, 18784, 29896, 29889, 6506, 703, 29896, 29889, 29888, 29939, 29889, 18828, 613, 376, 29906, 29889, 29888, 29939, 29889, 18828, 1159, 13, 4706, 3514, 353, 1303, 29918, 18784, 29896, 29889, 6506, 703, 29918, 29896, 29889, 29888, 29939, 29889, 18828, 613, 11393, 13445, 1159, 13, 1678, 1683, 29901, 13, 4706, 1303, 29918, 18784, 29906, 353, 1303, 29918, 18784, 29896, 29889, 6506, 703, 29896, 29889, 11255, 29939, 29889, 18828, 613, 376, 29906, 29889, 11255, 29939, 29889, 18828, 1159, 13, 4706, 3514, 353, 1303, 29918, 18784, 29896, 29889, 6506, 703, 29918, 29896, 29889, 11255, 29939, 29889, 18828, 613, 11393, 13445, 1159, 13, 13, 1678, 396, 21111, 17525, 322, 3514, 10422, 13, 1678, 6219, 29918, 3972, 353, 337, 29889, 4478, 29898, 29878, 12215, 5575, 6802, 28104, 6802, 28104, 13445, 29897, 742, 3514, 29892, 337, 29889, 29924, 29897, 13, 1678, 565, 6219, 29918, 3972, 29901, 13, 4706, 1881, 29918, 3972, 353, 6219, 29918, 3972, 29889, 2972, 29898, 29896, 29897, 13, 4706, 2531, 608, 29918, 3972, 353, 6219, 29918, 3972, 29889, 2972, 29898, 29906, 29897, 13, 4706, 3514, 353, 6219, 29918, 3972, 29889, 2972, 29898, 29941, 29897, 13, 1678, 1683, 29901, 13, 4706, 1596, 376, 26521, 1476, 3850, 13, 13, 1678, 396, 4905, 3884, 1423, 13, 1678, 1962, 29918, 2084, 353, 1962, 29918, 3972, 718, 8207, 29915, 718, 2531, 608, 29918, 3972, 13, 1678, 396, 4905, 29918, 2084, 353, 1962, 29918, 3972, 13, 1678, 396, 361, 451, 2897, 29889, 2084, 29889, 9933, 29898, 4905, 29918, 2084, 1125, 13, 1678, 396, 1678, 2897, 29889, 29885, 12535, 12935, 29898, 4905, 29918, 2084, 29897, 13, 13, 1678, 396, 6519, 363, 22239, 13, 1678, 7595, 353, 525, 29890, 2766, 2626, 448, 29924, 448, 29873, 525, 718, 320, 13, 9651, 289, 2766, 29918, 28993, 718, 525, 525, 718, 320, 13, 9651, 3407, 718, 525, 525, 718, 320, 13, 9651, 1303, 29918, 18784, 29896, 718, 525, 525, 718, 320, 13, 9651, 1303, 29918, 18784, 29906, 718, 525, 525, 718, 320, 13, 9651, 525, 16299, 718, 525, 525, 718, 320, 13, 9651, 1962, 29918, 2084, 718, 320, 13, 9651, 8207, 29915, 718, 320, 13, 9651, 3514, 13, 13, 1678, 396, 7978, 1899, 13, 1678, 2897, 29889, 5205, 29898, 2520, 29897, 13, 13, 361, 4770, 978, 1649, 1275, 376, 1649, 3396, 1649, 1115, 13, 1678, 1667, 29898, 9675, 29889, 19218, 29961, 29896, 29901, 2314, 13, 2 ]
failures/mapper2_try.py
ALaks96/MapReduce_Pyspark_Large_Matrix_Multiplication
0
58512
#!/usr/bin/python import sys import numpy as np # We know the dimensions of A and B! length = int(200) + 1 width = int(200) + 1 # Initializing A_list and B_list to deal with sparsity A = [0]*(length*width) B = [0]*(length*width) for line in sys.stdin: # Retrieving elements of (key,value) pair of our map output lines = line.strip() element = lines.split("\t") # The provenance of the element and its row/column origin = element[0] # The intermediate index to keep the order within the original matrix index = int(element[1]) # The value associated to that element: val = int(element[2]) for i in range(0,201): if origin == "A" + str(i): A[length*i + index] = val print '%s\t%s' % (origin,val) if origin == "B" + str(i): B[width*i + index] = val print '%s\t%s' % (origin,val)
[ 1, 18787, 4855, 29914, 2109, 29914, 4691, 13, 13, 5215, 10876, 13, 5215, 12655, 408, 7442, 13, 13, 29937, 1334, 1073, 278, 13391, 310, 319, 322, 350, 29991, 13, 2848, 353, 938, 29898, 29906, 29900, 29900, 29897, 718, 29871, 29896, 13, 2103, 353, 938, 29898, 29906, 29900, 29900, 29897, 718, 29871, 29896, 13, 13, 29937, 17250, 5281, 319, 29918, 1761, 322, 350, 29918, 1761, 304, 5376, 411, 805, 1503, 537, 13, 29909, 353, 518, 29900, 14178, 29898, 2848, 29930, 2103, 29897, 13, 29933, 353, 518, 29900, 14178, 29898, 2848, 29930, 2103, 29897, 13, 13, 1454, 1196, 297, 10876, 29889, 4172, 262, 29901, 13, 268, 13, 1678, 396, 19338, 1747, 3161, 310, 313, 1989, 29892, 1767, 29897, 5101, 310, 1749, 2910, 1962, 13, 1678, 3454, 353, 1196, 29889, 17010, 580, 13, 1678, 1543, 353, 3454, 29889, 5451, 14182, 29873, 1159, 13, 268, 13, 1678, 396, 450, 16413, 749, 310, 278, 1543, 322, 967, 1948, 29914, 4914, 13, 1678, 3978, 353, 1543, 29961, 29900, 29962, 13, 268, 13, 1678, 396, 450, 19697, 2380, 304, 3013, 278, 1797, 2629, 278, 2441, 4636, 13, 1678, 2380, 353, 938, 29898, 5029, 29961, 29896, 2314, 13, 268, 13, 1678, 396, 450, 995, 6942, 304, 393, 1543, 29901, 13, 1678, 659, 353, 938, 29898, 5029, 29961, 29906, 2314, 13, 268, 13, 1678, 363, 474, 297, 3464, 29898, 29900, 29892, 29906, 29900, 29896, 1125, 13, 4706, 565, 3978, 1275, 376, 29909, 29908, 718, 851, 29898, 29875, 1125, 13, 9651, 319, 29961, 2848, 29930, 29875, 718, 2380, 29962, 353, 659, 13, 9651, 1596, 14210, 29879, 29905, 29873, 29995, 29879, 29915, 1273, 313, 12574, 29892, 791, 29897, 13, 462, 13, 4706, 565, 3978, 1275, 376, 29933, 29908, 718, 851, 29898, 29875, 1125, 13, 9651, 350, 29961, 2103, 29930, 29875, 718, 2380, 29962, 353, 659, 13, 9651, 1596, 14210, 29879, 29905, 29873, 29995, 29879, 29915, 1273, 313, 12574, 29892, 791, 29897, 13, 2 ]
dracoon/public_models.py
Quirinwierer/dracoon-python-api
3
33768
from dataclasses import dataclass from typing import List @dataclass class SystemInfo: languageDefault: str hideLoginPinputFields: bool s3Hosts: List[str] s3EnforceDirectUpload: bool useS3Storage: bool @dataclass class ActiveDirectoryInfoItem: id: int alias: str isGlobalAvailable: bool @dataclass class ActiveDirectoryInfo: items: List[ActiveDirectoryInfoItem] @dataclass class OpenIdInfoItem: id: int issuer: str alias: str isGlobalAvailable: bool @dataclass class OpenIdInfo: items: List[OpenIdInfoItem]
[ 1, 515, 848, 13203, 1053, 848, 1990, 13, 3166, 19229, 1053, 2391, 13, 13, 29992, 1272, 1990, 13, 1990, 2184, 3401, 29901, 13, 1678, 4086, 4592, 29901, 851, 13, 1678, 9563, 11049, 29925, 2080, 14256, 29901, 6120, 13, 1678, 269, 29941, 8514, 29879, 29901, 2391, 29961, 710, 29962, 13, 1678, 269, 29941, 2369, 10118, 17392, 17553, 29901, 6120, 13, 1678, 671, 29903, 29941, 10486, 29901, 6120, 13, 13, 29992, 1272, 1990, 13, 1990, 10731, 9882, 3401, 2001, 29901, 13, 1678, 1178, 29901, 938, 13, 1678, 13995, 29901, 851, 13, 1678, 338, 12756, 27635, 29901, 6120, 13, 13, 29992, 1272, 1990, 259, 13, 1990, 10731, 9882, 3401, 29901, 13, 1678, 4452, 29901, 2391, 29961, 9966, 9882, 3401, 2001, 29962, 13, 13, 29992, 1272, 1990, 13, 1990, 4673, 1204, 3401, 2001, 29901, 13, 1678, 1178, 29901, 938, 13, 1678, 1721, 2853, 29901, 851, 13, 1678, 13995, 29901, 851, 13, 1678, 338, 12756, 27635, 29901, 6120, 13, 13, 29992, 1272, 1990, 259, 13, 1990, 4673, 1204, 3401, 29901, 13, 1678, 4452, 29901, 2391, 29961, 6585, 1204, 3401, 2001, 29962, 13, 13, 2 ]
4-ManipulandoTexto/des24.py
FelipeTellini/Python
0
159107
<gh_stars>0 print('\nVerificando as primeiras letras de um texto\n') cid = str(input('Que cidade você nasceu ? ')).strip() print(cid[:5].lower() == 'santo') fim = input('\nCurso de Python no YouTube, canal CURSO EM VIDEO.')
[ 1, 529, 12443, 29918, 303, 1503, 29958, 29900, 13, 2158, 28909, 29876, 6565, 928, 1743, 408, 6019, 20138, 454, 10678, 316, 1922, 1426, 29877, 29905, 29876, 1495, 13, 13, 25232, 353, 851, 29898, 2080, 877, 8654, 17931, 7931, 30037, 8281, 22541, 1577, 525, 8106, 17010, 580, 13, 2158, 29898, 25232, 7503, 29945, 1822, 13609, 580, 1275, 525, 29879, 5361, 1495, 13, 13, 29888, 326, 353, 1881, 28909, 29876, 23902, 578, 316, 5132, 694, 14711, 29892, 18643, 315, 4574, 6156, 27295, 478, 22027, 29949, 29889, 1495, 2 ]
server/webdriver_tests/shared.py
suhana13/website
0
140877
# Copyright 2020 Google LLC # # 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 selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.common.by import By from selenium.webdriver.support import expected_conditions as EC LOADING_WAIT_TIME_SEC = 3 MAX_NUM_SPINNERS = 3 """Common library for functions used by multiple webdriver tests""" def wait_for_loading(driver): """ Wait for loading spinners to appear then disappear. Sometimes, more than one spinner will appear and disappear, so wait for MAX_NUM_SPINNERS spinners to appear and disappear. Or finish waiting if it takes more than LOADING_WAIT_TIME_SEC seconds for the next spinner to appear. """ screen_present = EC.visibility_of_element_located((By.ID, 'screen')) screen_hidden = EC.invisibility_of_element_located((By.ID, 'screen')) num_tries = 0 while (num_tries < MAX_NUM_SPINNERS): try: WebDriverWait(driver, LOADING_WAIT_TIME_SEC).until(screen_present) WebDriverWait(driver, LOADING_WAIT_TIME_SEC).until(screen_hidden) num_tries += 1 except: break def click_sv_group(driver, svg_name): """ In the stat var widget, click on the stat var group titled svg_name """ sv_groups = driver.find_elements_by_class_name('node-title') for group in sv_groups: if svg_name in group.text: group.click() break
[ 1, 396, 14187, 1266, 29871, 29906, 29900, 29906, 29900, 5087, 365, 12182, 13, 29937, 13, 29937, 10413, 21144, 1090, 278, 13380, 19245, 29892, 10079, 29871, 29906, 29889, 29900, 313, 1552, 376, 29931, 293, 1947, 1496, 13, 29937, 366, 1122, 451, 671, 445, 934, 5174, 297, 752, 13036, 411, 278, 19245, 29889, 13, 29937, 887, 1122, 4017, 263, 3509, 310, 278, 19245, 472, 13, 29937, 13, 29937, 418, 1732, 597, 1636, 29889, 4288, 29889, 990, 29914, 506, 11259, 29914, 27888, 1430, 1660, 29899, 29906, 29889, 29900, 13, 29937, 13, 29937, 25870, 3734, 491, 22903, 4307, 470, 15502, 304, 297, 5007, 29892, 7047, 13, 29937, 13235, 1090, 278, 19245, 338, 13235, 373, 385, 376, 3289, 8519, 29908, 350, 3289, 3235, 29892, 13, 29937, 399, 1806, 8187, 2692, 399, 1718, 29934, 13566, 29059, 6323, 8707, 29928, 22122, 29903, 8079, 13764, 29979, 476, 22255, 29892, 2845, 4653, 470, 2411, 2957, 29889, 13, 29937, 2823, 278, 19245, 363, 278, 2702, 4086, 14765, 1076, 11239, 322, 13, 29937, 27028, 1090, 278, 19245, 29889, 13, 13, 3166, 18866, 29889, 29813, 29889, 5924, 29889, 1481, 1053, 2563, 12376, 15716, 13, 3166, 18866, 29889, 29813, 29889, 9435, 29889, 1609, 1053, 2648, 13, 3166, 18866, 29889, 29813, 29889, 5924, 1053, 3806, 29918, 1116, 2187, 408, 17522, 13, 13, 29428, 4214, 29918, 12982, 1806, 29918, 15307, 29918, 1660, 29907, 353, 29871, 29941, 13, 12648, 29918, 13967, 29918, 5550, 1177, 13865, 29903, 353, 29871, 29941, 13, 15945, 29908, 18877, 3489, 363, 3168, 1304, 491, 2999, 1856, 9465, 6987, 15945, 29908, 13, 13, 13, 1753, 4480, 29918, 1454, 29918, 13234, 29898, 9465, 1125, 13, 1678, 9995, 13, 1678, 20340, 363, 8363, 805, 16697, 304, 2615, 769, 25417, 29889, 18512, 29892, 901, 13, 1678, 1135, 697, 805, 3993, 674, 2615, 322, 25417, 29892, 577, 4480, 363, 18134, 29918, 13967, 29918, 5550, 1177, 13865, 29903, 13, 1678, 805, 16697, 304, 2615, 322, 25417, 29889, 1394, 8341, 10534, 565, 372, 4893, 901, 1135, 13, 1678, 11247, 3035, 4214, 29918, 12982, 1806, 29918, 15307, 29918, 1660, 29907, 6923, 363, 278, 2446, 805, 3993, 304, 2615, 29889, 13, 1678, 9995, 13, 1678, 4315, 29918, 6338, 353, 17522, 29889, 28814, 29918, 974, 29918, 5029, 29918, 28809, 3552, 2059, 29889, 1367, 29892, 525, 10525, 8785, 13, 1678, 4315, 29918, 10892, 353, 17522, 29889, 262, 28814, 29918, 974, 29918, 5029, 29918, 28809, 3552, 2059, 29889, 1367, 29892, 525, 10525, 8785, 13, 1678, 954, 29918, 29873, 2722, 353, 29871, 29900, 13, 1678, 1550, 313, 1949, 29918, 29873, 2722, 529, 18134, 29918, 13967, 29918, 5550, 1177, 13865, 29903, 1125, 13, 4706, 1018, 29901, 13, 9651, 2563, 12376, 15716, 29898, 9465, 29892, 11247, 3035, 4214, 29918, 12982, 1806, 29918, 15307, 29918, 1660, 29907, 467, 29305, 29898, 10525, 29918, 6338, 29897, 13, 9651, 2563, 12376, 15716, 29898, 9465, 29892, 11247, 3035, 4214, 29918, 12982, 1806, 29918, 15307, 29918, 1660, 29907, 467, 29305, 29898, 10525, 29918, 10892, 29897, 13, 9651, 954, 29918, 29873, 2722, 4619, 29871, 29896, 13, 4706, 5174, 29901, 13, 9651, 2867, 13, 13, 13, 1753, 2828, 29918, 4501, 29918, 2972, 29898, 9465, 29892, 25773, 29918, 978, 1125, 13, 1678, 9995, 13, 1678, 512, 278, 1002, 722, 11109, 29892, 2828, 373, 278, 1002, 722, 2318, 25278, 25773, 29918, 978, 13, 1678, 9995, 13, 1678, 3731, 29918, 13155, 353, 7156, 29889, 2886, 29918, 17664, 29918, 1609, 29918, 1990, 29918, 978, 877, 3177, 29899, 3257, 1495, 13, 1678, 363, 2318, 297, 3731, 29918, 13155, 29901, 13, 4706, 565, 25773, 29918, 978, 297, 2318, 29889, 726, 29901, 13, 9651, 2318, 29889, 3808, 580, 13, 9651, 2867, 2 ]
golpy/util.py
Zeta611/py-game-of-life
5
83827
<filename>golpy/util.py import time from functools import wraps from typing import Dict class timeit: records: Dict[str, float] = {} on = False def __call__(self, func): @wraps(func) def wrapper(*args, **kwargs): if not self.on: return func(*args, **kwargs) name = func.__name__ start = time.perf_counter() result = func(*args, **kwargs) end = time.perf_counter() elapsed = end - start if name in self.records: self.records[name] += elapsed else: self.records[name] = elapsed return result return wrapper
[ 1, 529, 9507, 29958, 29887, 324, 2272, 29914, 4422, 29889, 2272, 13, 5215, 931, 13, 3166, 2090, 312, 8789, 1053, 11463, 567, 13, 3166, 19229, 1053, 360, 919, 13, 13, 13, 1990, 931, 277, 29901, 13, 1678, 6475, 29901, 360, 919, 29961, 710, 29892, 5785, 29962, 353, 6571, 13, 1678, 373, 353, 7700, 13, 13, 1678, 822, 4770, 4804, 12035, 1311, 29892, 3653, 1125, 13, 4706, 732, 29893, 336, 567, 29898, 9891, 29897, 13, 4706, 822, 14476, 10456, 5085, 29892, 3579, 19290, 1125, 13, 9651, 565, 451, 1583, 29889, 265, 29901, 13, 18884, 736, 3653, 10456, 5085, 29892, 3579, 19290, 29897, 13, 13, 9651, 1024, 353, 3653, 17255, 978, 1649, 13, 13, 9651, 1369, 353, 931, 29889, 546, 29888, 29918, 11808, 580, 13, 9651, 1121, 353, 3653, 10456, 5085, 29892, 3579, 19290, 29897, 13, 9651, 1095, 353, 931, 29889, 546, 29888, 29918, 11808, 580, 13, 13, 9651, 560, 28170, 353, 1095, 448, 1369, 13, 9651, 565, 1024, 297, 1583, 29889, 3757, 4339, 29901, 13, 18884, 1583, 29889, 3757, 4339, 29961, 978, 29962, 4619, 560, 28170, 13, 9651, 1683, 29901, 13, 18884, 1583, 29889, 3757, 4339, 29961, 978, 29962, 353, 560, 28170, 13, 9651, 736, 1121, 13, 13, 4706, 736, 14476, 13, 2 ]
PyFlowPackages/PyFlowFreeCAD/Nodes/FreeCAD_Object.py
awgrover/NodeEditor
53
46861
<reponame>awgrover/NodeEditor ''' all still not categorized nodes ''' from PyFlow.Packages.PyFlowFreeCAD.Nodes import * from PyFlow.Packages.PyFlowFreeCAD.Nodes.FreeCAD_Base import timer, FreeCadNodeBase, FreeCadNodeBase2 class FreeCAD_Tube(FreeCadNodeBase2): ''' calculate the points for a parametric tube along a backbone curve ''' dok = 4 def __init__(self, name="MyToy"): super(self.__class__, self).__init__(name) self.inExec = self.createInputPin(DEFAULT_IN_EXEC_NAME, 'ExecPin', None, self.compute) self.outExec = self.createOutputPin(DEFAULT_OUT_EXEC_NAME, 'ExecPin') a=self.createInputPin('backbone', 'ShapePin') a.description="backbone curve for the tube" a=self.createInputPin('parameter', 'Float',structure=StructureType.Array) a.description="u parameter of the position of the ribs" a=self.createInputPin('radius', 'Float',structure=StructureType.Array) a.description="radius/size of the rib rings" a=self.createOutputPin('points', 'VectorPin',structure=StructureType.Array) a.description="array of poles for the postprocessing bspline surface" @staticmethod def description(): return FreeCAD_Tube.__doc__ @staticmethod def category(): return 'Object' def nodelist(): return [ FreeCAD_Tube, ] # hack wird irgendwo geladen warun #+# # muss wieder raus, weil schon in information !!! class FreeCAD_Object(FreeCadNodeBase2): def __init__(self, name="MyToy"): super(self.__class__, self).__init__(name) self.inExec = self.createInputPin(DEFAULT_IN_EXEC_NAME, 'ExecPin', None, self.compute) self.outExec = self.createOutputPin(DEFAULT_OUT_EXEC_NAME, 'ExecPin') pass
[ 1, 529, 276, 1112, 420, 29958, 1450, 17170, 369, 29914, 4247, 15280, 13, 12008, 13, 497, 1603, 451, 11608, 1891, 7573, 13, 12008, 13, 3166, 10772, 17907, 29889, 16638, 1179, 29889, 19737, 17907, 20475, 29907, 3035, 29889, 20284, 1053, 334, 13, 3166, 10772, 17907, 29889, 16638, 1179, 29889, 19737, 17907, 20475, 29907, 3035, 29889, 20284, 29889, 20475, 29907, 3035, 29918, 5160, 1053, 12237, 29892, 12362, 29907, 328, 4247, 5160, 29892, 12362, 29907, 328, 4247, 5160, 29906, 13, 13, 13, 13, 1990, 12362, 29907, 3035, 29918, 13425, 29898, 20475, 29907, 328, 4247, 5160, 29906, 1125, 13, 1678, 14550, 13, 1678, 8147, 278, 3291, 363, 263, 25011, 2200, 260, 4003, 3412, 263, 1250, 15933, 11672, 13, 1678, 14550, 13, 13, 1678, 18004, 353, 29871, 29946, 13, 1678, 822, 4770, 2344, 12035, 1311, 29892, 1024, 543, 3421, 1762, 29891, 29908, 1125, 13, 13, 4706, 2428, 29898, 1311, 17255, 1990, 1649, 29892, 1583, 467, 1649, 2344, 12035, 978, 29897, 13, 4706, 1583, 29889, 262, 5379, 353, 1583, 29889, 3258, 4290, 29925, 262, 29898, 23397, 29918, 1177, 29918, 5746, 11206, 29918, 5813, 29892, 525, 5379, 29925, 262, 742, 6213, 29892, 1583, 29889, 26017, 29897, 13, 4706, 1583, 29889, 449, 5379, 353, 1583, 29889, 3258, 6466, 29925, 262, 29898, 23397, 29918, 12015, 29918, 5746, 11206, 29918, 5813, 29892, 525, 5379, 29925, 262, 1495, 13, 13, 4706, 263, 29922, 1311, 29889, 3258, 4290, 29925, 262, 877, 1627, 15933, 742, 525, 24111, 29925, 262, 1495, 13, 4706, 263, 29889, 8216, 543, 1627, 15933, 11672, 363, 278, 260, 4003, 29908, 13, 4706, 263, 29922, 1311, 29889, 3258, 4290, 29925, 262, 877, 15501, 742, 525, 11031, 742, 23905, 29922, 5015, 12425, 1542, 29889, 2588, 29897, 13, 4706, 263, 29889, 8216, 543, 29884, 3443, 310, 278, 2602, 310, 278, 18130, 29879, 29908, 13, 4706, 263, 29922, 1311, 29889, 3258, 4290, 29925, 262, 877, 13471, 742, 525, 11031, 742, 23905, 29922, 5015, 12425, 1542, 29889, 2588, 29897, 13, 4706, 263, 29889, 8216, 543, 13471, 29914, 2311, 310, 278, 18130, 28774, 29908, 13, 4706, 263, 29922, 1311, 29889, 3258, 6466, 29925, 262, 877, 9748, 742, 525, 12877, 29925, 262, 742, 23905, 29922, 5015, 12425, 1542, 29889, 2588, 29897, 13, 4706, 263, 29889, 8216, 543, 2378, 310, 1248, 267, 363, 278, 1400, 19170, 289, 23579, 457, 7101, 29908, 13, 13, 1678, 732, 7959, 5696, 13, 1678, 822, 6139, 7295, 13, 4706, 736, 12362, 29907, 3035, 29918, 13425, 17255, 1514, 1649, 13, 13, 1678, 732, 7959, 5696, 13, 1678, 822, 7663, 7295, 13, 4706, 736, 525, 2061, 29915, 13, 13, 13, 13, 1753, 18778, 295, 391, 7295, 13, 1678, 736, 518, 13, 13, 18884, 12362, 29907, 3035, 29918, 13425, 29892, 13, 462, 13, 4706, 4514, 13, 13, 13, 29937, 15833, 4296, 3805, 29887, 355, 827, 9127, 4858, 1370, 348, 396, 29974, 29937, 13, 29937, 23885, 7518, 1153, 375, 29892, 24107, 15002, 297, 2472, 1738, 6824, 13, 1990, 12362, 29907, 3035, 29918, 2061, 29898, 20475, 29907, 328, 4247, 5160, 29906, 1125, 13, 1678, 822, 4770, 2344, 12035, 1311, 29892, 1024, 543, 3421, 1762, 29891, 29908, 1125, 13, 13, 9651, 2428, 29898, 1311, 17255, 1990, 1649, 29892, 1583, 467, 1649, 2344, 12035, 978, 29897, 13, 9651, 1583, 29889, 262, 5379, 353, 1583, 29889, 3258, 4290, 29925, 262, 29898, 23397, 29918, 1177, 29918, 5746, 11206, 29918, 5813, 29892, 525, 5379, 29925, 262, 742, 6213, 29892, 1583, 29889, 26017, 29897, 13, 9651, 1583, 29889, 449, 5379, 353, 1583, 29889, 3258, 6466, 29925, 262, 29898, 23397, 29918, 12015, 29918, 5746, 11206, 29918, 5813, 29892, 525, 5379, 29925, 262, 1495, 13, 4706, 13, 268, 13, 268, 13, 1678, 1209, 13, 268, 13, 268, 13, 2 ]
ephemeral/baseline_autocorrelation_parcellated.py
BorgwardtLab/fMRI_Cubical_Persistence
10
156501
#!/usr/bin/env python # # Baseline calculation script for NIfTI data sets. After specifying such # a data set and an optional brain mask, converts each participant to an # autocorrelation-based matrix representation. # # The goal is to summarise each participant as a voxel-by-voxel matrix. # # This script is specifically built for handling parcellated data. Other # data sources are not possible right now, as they would probably exceed # computational resources quickly. import argparse import math import os import warnings import numpy as np import numpy.ma as ma from tqdm import tqdm def basename(filename): """Calculate basename of a file. Removes all extensions from a filename and returns the basename of the file. This function is required to handle filenames with *two* or more extensions. """ filename = os.path.basename(filename) def _split_extension(filename): return os.path.splitext(filename) filename, extension = _split_extension(filename) while extension: filename, extension = _split_extension(filename) return filename if __name__ == '__main__': parser = argparse.ArgumentParser() default_file = \ '../results/parcellated_data/shaefer_masked_subject_data_shifted.npy' parser.add_argument( '-i', '--input', type=str, help='Input file', default=default_file, ) parser.add_argument( '-o', '--output', type=str, help='Output directory. If not set, will default to the current ' 'directory.', default='.' ) args = parser.parse_args() data = np.load(args.input) n_participants = data.shape[0] + 1 # Used to generate nice output files that follow the naming # convention in the remainder of the paper. n_digits = int(math.log10(n_participants) + 1) for index, X in tqdm(enumerate(data), desc='Subject'): filename = f'{index+1:0{n_digits}d}.npz' filename = os.path.join(args.output, filename) # Make sure that we only calculate correlations with valid # voxels. This is only be relevant for the data sets which # actually include a certain brain mask. X = ma.corrcoef(ma.masked_invalid(X.T)) X = np.nan_to_num(X) assert np.isnan(X).sum() == 0 # Nothing should be overwritten. Else, the script might be used # incorrectly, so we refuse to do anything. if os.path.exists(filename): warnings.warn(f'File {filename} already exists. Refusing to ' f'overwrite it and moving on.') continue np.savez(filename, X=X)
[ 1, 18787, 4855, 29914, 2109, 29914, 6272, 3017, 13, 29937, 13, 29937, 4886, 5570, 13944, 2471, 363, 405, 3644, 24301, 848, 6166, 29889, 2860, 22146, 1316, 13, 29937, 263, 848, 731, 322, 385, 13136, 17294, 11105, 29892, 29436, 1269, 5221, 424, 304, 385, 13, 29937, 1120, 542, 272, 23445, 29899, 6707, 4636, 8954, 29889, 13, 29937, 13, 29937, 450, 7306, 338, 304, 19138, 895, 1269, 5221, 424, 408, 263, 992, 29916, 295, 29899, 1609, 29899, 1365, 29916, 295, 4636, 29889, 13, 29937, 13, 29937, 910, 2471, 338, 10816, 4240, 363, 11415, 610, 3729, 630, 848, 29889, 5901, 13, 29937, 848, 8974, 526, 451, 1950, 1492, 1286, 29892, 408, 896, 723, 3117, 13461, 13, 29937, 26845, 7788, 9098, 29889, 13, 13, 5215, 1852, 5510, 13, 5215, 5844, 13, 5215, 2897, 13, 5215, 18116, 13, 13, 5215, 12655, 408, 7442, 13, 5215, 12655, 29889, 655, 408, 611, 13, 13, 3166, 260, 29939, 18933, 1053, 260, 29939, 18933, 13, 13, 13, 1753, 2362, 3871, 29898, 9507, 1125, 13, 1678, 9995, 27065, 403, 2362, 3871, 310, 263, 934, 29889, 13, 13, 1678, 5240, 586, 267, 599, 17752, 515, 263, 10422, 322, 3639, 278, 2362, 3871, 310, 13, 1678, 278, 934, 29889, 910, 740, 338, 3734, 304, 4386, 977, 264, 1280, 411, 334, 10184, 29930, 13, 1678, 470, 901, 17752, 29889, 13, 1678, 9995, 13, 1678, 10422, 353, 2897, 29889, 2084, 29889, 6500, 3871, 29898, 9507, 29897, 13, 13, 1678, 822, 903, 5451, 29918, 17588, 29898, 9507, 1125, 13, 4706, 736, 2897, 29889, 2084, 29889, 23579, 568, 486, 29898, 9507, 29897, 13, 13, 1678, 10422, 29892, 6081, 353, 903, 5451, 29918, 17588, 29898, 9507, 29897, 13, 13, 1678, 1550, 6081, 29901, 13, 4706, 10422, 29892, 6081, 353, 903, 5451, 29918, 17588, 29898, 9507, 29897, 13, 13, 1678, 736, 10422, 13, 13, 13, 361, 4770, 978, 1649, 1275, 525, 1649, 3396, 1649, 2396, 13, 13, 1678, 13812, 353, 1852, 5510, 29889, 15730, 11726, 580, 13, 13, 1678, 2322, 29918, 1445, 353, 320, 13, 4706, 525, 6995, 9902, 29914, 862, 3729, 630, 29918, 1272, 29914, 845, 3660, 571, 29918, 13168, 287, 29918, 16009, 29918, 1272, 29918, 10889, 287, 29889, 29876, 2272, 29915, 13, 13, 1678, 13812, 29889, 1202, 29918, 23516, 29898, 13, 4706, 17411, 29875, 742, 525, 489, 2080, 742, 13, 4706, 1134, 29922, 710, 29892, 13, 4706, 1371, 2433, 4290, 934, 742, 13, 4706, 2322, 29922, 4381, 29918, 1445, 29892, 13, 1678, 1723, 13, 13, 1678, 13812, 29889, 1202, 29918, 23516, 29898, 13, 4706, 17411, 29877, 742, 525, 489, 4905, 742, 13, 4706, 1134, 29922, 710, 29892, 13, 4706, 1371, 2433, 6466, 3884, 29889, 960, 451, 731, 29892, 674, 2322, 304, 278, 1857, 525, 13, 632, 525, 12322, 29889, 742, 13, 4706, 2322, 2433, 6169, 13, 1678, 1723, 13, 13, 1678, 6389, 353, 13812, 29889, 5510, 29918, 5085, 580, 13, 13, 1678, 848, 353, 7442, 29889, 1359, 29898, 5085, 29889, 2080, 29897, 13, 13, 1678, 302, 29918, 1595, 12654, 1934, 353, 848, 29889, 12181, 29961, 29900, 29962, 718, 29871, 29896, 13, 13, 1678, 396, 501, 8485, 304, 5706, 7575, 1962, 2066, 393, 1101, 278, 22006, 13, 1678, 396, 15687, 297, 278, 21162, 310, 278, 5650, 29889, 13, 1678, 302, 29918, 7501, 1169, 353, 938, 29898, 755, 29889, 1188, 29896, 29900, 29898, 29876, 29918, 1595, 12654, 1934, 29897, 718, 29871, 29896, 29897, 13, 13, 1678, 363, 2380, 29892, 1060, 297, 260, 29939, 18933, 29898, 15172, 29898, 1272, 511, 5153, 2433, 20622, 29374, 13, 13, 4706, 10422, 353, 285, 29915, 29912, 2248, 29974, 29896, 29901, 29900, 29912, 29876, 29918, 7501, 1169, 29913, 29881, 1836, 9302, 29920, 29915, 13, 4706, 10422, 353, 2897, 29889, 2084, 29889, 7122, 29898, 5085, 29889, 4905, 29892, 10422, 29897, 13, 13, 4706, 396, 8561, 1854, 393, 591, 871, 8147, 8855, 800, 411, 2854, 13, 4706, 396, 992, 29916, 1379, 29889, 910, 338, 871, 367, 8018, 363, 278, 848, 6166, 607, 13, 4706, 396, 2869, 3160, 263, 3058, 17294, 11105, 29889, 13, 4706, 1060, 353, 611, 29889, 29725, 1111, 1389, 29898, 655, 29889, 13168, 287, 29918, 20965, 29898, 29990, 29889, 29911, 876, 13, 4706, 1060, 353, 7442, 29889, 13707, 29918, 517, 29918, 1949, 29898, 29990, 29897, 13, 13, 4706, 4974, 7442, 29889, 275, 13707, 29898, 29990, 467, 2083, 580, 1275, 29871, 29900, 13, 13, 4706, 396, 9531, 881, 367, 975, 17625, 29889, 15785, 29892, 278, 2471, 1795, 367, 1304, 13, 4706, 396, 29676, 29892, 577, 591, 26506, 304, 437, 3099, 29889, 13, 4706, 565, 2897, 29889, 2084, 29889, 9933, 29898, 9507, 1125, 13, 9651, 18116, 29889, 25442, 29898, 29888, 29915, 2283, 426, 9507, 29913, 2307, 4864, 29889, 9897, 4746, 304, 525, 13, 462, 3986, 285, 29915, 957, 3539, 372, 322, 8401, 373, 29889, 1495, 13, 13, 9651, 6773, 13, 13, 4706, 7442, 29889, 7620, 29920, 29898, 9507, 29892, 1060, 29922, 29990, 29897, 13, 2 ]
goofycoin.py
Shriyanshagro/goofycoins
0
114853
<reponame>Shriyanshagro/goofycoins #implementation of goofycoins from datetime import datetime import hashlib from random import randint # privatekey of goofy global goofykey global initcoin global inituser initcoin = 100 inituser = 5 # A class to catch error and exceptions class GoofycoinError(Exception): def __init__(self, message): self.message = message def __str__(self): return repr(self.message) class User(object): # mapping # {PrivateKey: PublicKey} def __init__(self): global goofykey self.user = {} self.keymap = {} key = hashlib.sha256() key.update("goofy") num = "privatekey" + str(randint(0,999999999)) key.update(num) goofykey = key.hexdigest() key = hashlib.sha256() key.update(goofykey) key.update("publickey") goofypublickey = key.hexdigest() self.user[goofykey] = {'publickey': goofypublickey, 'holdings':[]} self.keymap[goofypublickey] = goofykey print "privatekey==",goofykey, "\npublickey==", goofypublickey print "Goofy Created!!" def createuser(self): key = hashlib.sha256() key.update(self.user.keys()[-1]) num = "privatekey" + str(randint(0,999999999)) key.update(num) privatekey = key.hexdigest() key = hashlib.sha256() key.update(privatekey) key.update("publickey") publickey = key.hexdigest() holdings = [] self.user[privatekey] = {'publickey': publickey, 'holdings':holdings} self.keymap[publickey] = privatekey return privatekey, publickey, holdings # return list of all public keys def getPublicKeys(self): publickey = [] for value in self.user.values(): publickey.append(value['publickey']) return publickey # return publickey of provided privatekey def getPublicKey(self, privatekey): if not self.user.get(privatekey): raise GoofycoinError("Invalid privatekey") return self.user.get(privatekey)['publickey'] # return coin holdings of provided privatekey def getHolding(self, privatekey): if not self.user.get(privatekey): raise GoofycoinError("Invalid privatekey") return self.user.get(privatekey)['holdings'] def getPrivateKey(self, publickey): if not self.keymap.get(publickey): raise GoofycoinError("Invalid publickey") return self.keymap.get(publickey) class Coin(object): def __init__(self, User): self.coin = {} self.user = User self.ledger = [] # returns new id for coin creation def getnewid(self): return (len(self.coin) + 1) # cid = unique id of coin # pid = private key of creator def createCoin(self, cid, pid): global goofykey # creation is only allowed for goofy if pid==goofykey and cid==self.getnewid(): self.coin[cid] = [] # first transaction of cid ; transaction ledger is a list self.coin[cid].append(self.user.getPublicKey(pid)) transaction = {"creator": self.user.getPublicKey(pid), "Coinid": cid, "Timestamp": datetime.now().isoformat(), } # update ledger self.ledger.append(transaction) # update holding of user self.user.user[pid]['holdings'].append(cid) print "Successfull coin creation with id {}".format(cid) else: raise GoofycoinError("Sorry only Goofy is allowed to create\ new coins with unique id.") # rid = reciever's public key # pid = sender's private key def passcoin(self, cid, rid, pid): # validate coin's existence if cid not in self.coin.keys(): raise GoofycoinError("No such coin exist. Ask Gooofy to create \ one") if rid not in self.user.getPublicKeys(): raise GoofycoinError("Cross-Check reciever's public key") # validate whether user owns that coin? if not self.getOwner(cid) == self.user.getPublicKey(pid): raise GoofycoinError("Sorry, you doesn't owe coin {0}".format(cid)) # append coin's blockchain self.coin[cid].append(rid) # update holding of user self.user.user[pid]['holdings'].remove(cid) self.user.user[self.user.getPrivateKey(rid)]['holdings'].append(cid) transaction = {"sender": self.user.getPublicKey(pid), "reciever": rid, "Coinid": cid, "Timestamp": datetime.now().isoformat(), } # update ledger self.ledger.append(transaction) print "Transaction Successfull" def getOwner(self, cid): if cid not in self.coin.keys(): raise GoofycoinError("No such coin exist. Ask Gooofy to create \ one ") return self.coin[cid][-1] def getledger(self): return self.ledger def checkvalidy(self, cid): if cid not in self.coin.keys(): raise GoofycoinError("No such coin exist. Ask Gooofy to create \ one ") chain = "" for users in self.coin.get(cid): chain = chain + users + "--->>" return chain # dummy transctions def dummy(user, coin): global goofykey global initcoin global inituser initialcoins = initcoin # dummy creation of coins for i in range(0, initialcoins): coin.createCoin(coin.getnewid(), goofykey) i += 1 # number of coins to be divided among users coinequality = initialcoins/(inituser*2) # dummy users and distribution of coins for i in range(0, inituser): privatekey, publickey, holdings = user.createuser() print "privatekey==",privatekey, "\npublickey==", publickey for j in range(0, coinequality): coin.passcoin(initialcoins, publickey, goofykey) initialcoins -= 1 if __name__ == "__main__": user = User() coin = Coin(user) dummy(user, coin) while True: print "u: create user \n p:passcoin \n c:createcoin\n l:transaction \ ledger \n h: get your holding \n v: verify validy of coin" cmd = raw_input("Your command?") try: if cmd == 'u': privatekey, publickey, holdings = user.createuser() print "privatekey==",privatekey, "\npublickey==", publickey elif cmd== 'p': cid = int(raw_input("coin id?")) rid = raw_input("reciever's public key?") pid = raw_input("Your privatekey?") coin.passcoin(cid, rid, pid) elif cmd=='c': pid = raw_input("Your privatekey?") coin.createCoin(coin.getnewid(), pid) elif cmd=='l': print coin.getledger() elif cmd=='h': pid = raw_input("Your privatekey?") print user.getHolding(pid) elif cmd=='v': cid = int(raw_input("coin id?")) print coin.checkvalidy(cid) else: print "Provide valid command" print except GoofycoinError as e: print e.message
[ 1, 529, 276, 1112, 420, 29958, 2713, 374, 29891, 550, 29882, 351, 307, 29914, 1484, 974, 29891, 1111, 1144, 13, 29937, 21382, 310, 748, 974, 29891, 1111, 1144, 13, 13, 3166, 12865, 1053, 12865, 13, 5215, 6608, 1982, 13, 3166, 4036, 1053, 20088, 524, 13, 13, 29937, 2024, 1989, 310, 748, 974, 29891, 13, 10945, 748, 974, 29891, 1989, 13, 10945, 2069, 1111, 262, 13, 10945, 2069, 1792, 13, 13, 2344, 1111, 262, 353, 29871, 29896, 29900, 29900, 13, 2344, 1792, 353, 29871, 29945, 13, 13, 29937, 319, 770, 304, 4380, 1059, 322, 15283, 13, 1990, 2921, 974, 29891, 1111, 262, 2392, 29898, 2451, 1125, 13, 13, 1678, 822, 4770, 2344, 12035, 1311, 29892, 2643, 1125, 13, 4706, 1583, 29889, 4906, 353, 2643, 13, 13, 1678, 822, 4770, 710, 12035, 1311, 1125, 13, 4706, 736, 2062, 29898, 1311, 29889, 4906, 29897, 13, 13, 1990, 4911, 29898, 3318, 1125, 13, 13, 1678, 396, 10417, 13, 1678, 396, 426, 25207, 2558, 29901, 5236, 2558, 29913, 13, 13, 1678, 822, 4770, 2344, 12035, 1311, 1125, 13, 4706, 5534, 748, 974, 29891, 1989, 13, 4706, 1583, 29889, 1792, 353, 6571, 13, 4706, 1583, 29889, 446, 962, 481, 353, 6571, 13, 4706, 1820, 353, 6608, 1982, 29889, 17051, 29906, 29945, 29953, 580, 13, 4706, 1820, 29889, 5504, 703, 1484, 974, 29891, 1159, 13, 4706, 954, 353, 376, 9053, 1989, 29908, 718, 851, 29898, 9502, 524, 29898, 29900, 29892, 29929, 29929, 29929, 29929, 29929, 29929, 29929, 29929, 29929, 876, 13, 4706, 1820, 29889, 5504, 29898, 1949, 29897, 13, 4706, 748, 974, 29891, 1989, 353, 1820, 29889, 20970, 7501, 342, 580, 13, 4706, 1820, 353, 6608, 1982, 29889, 17051, 29906, 29945, 29953, 580, 13, 4706, 1820, 29889, 5504, 29898, 1484, 974, 29891, 1989, 29897, 13, 4706, 1820, 29889, 5504, 703, 3597, 1989, 1159, 13, 4706, 748, 974, 1478, 803, 1989, 353, 1820, 29889, 20970, 7501, 342, 580, 13, 4706, 1583, 29889, 1792, 29961, 1484, 974, 29891, 1989, 29962, 353, 11117, 3597, 1989, 2396, 748, 974, 1478, 803, 1989, 29892, 525, 8948, 886, 2396, 2636, 29913, 13, 4706, 1583, 29889, 446, 962, 481, 29961, 1484, 974, 1478, 803, 1989, 29962, 353, 748, 974, 29891, 1989, 13, 4706, 1596, 376, 9053, 1989, 26359, 29892, 1484, 974, 29891, 1989, 29892, 6634, 29876, 3597, 1989, 26359, 29892, 748, 974, 1478, 803, 1989, 13, 4706, 1596, 376, 8120, 974, 29891, 6760, 630, 29991, 3850, 13, 13, 1678, 822, 1653, 1792, 29898, 1311, 1125, 13, 13, 4706, 1820, 353, 6608, 1982, 29889, 17051, 29906, 29945, 29953, 580, 13, 4706, 1820, 29889, 5504, 29898, 1311, 29889, 1792, 29889, 8149, 580, 14352, 29896, 2314, 13, 4706, 954, 353, 376, 9053, 1989, 29908, 718, 851, 29898, 9502, 524, 29898, 29900, 29892, 29929, 29929, 29929, 29929, 29929, 29929, 29929, 29929, 29929, 876, 13, 4706, 1820, 29889, 5504, 29898, 1949, 29897, 13, 4706, 2024, 1989, 353, 1820, 29889, 20970, 7501, 342, 580, 13, 4706, 1820, 353, 6608, 1982, 29889, 17051, 29906, 29945, 29953, 580, 13, 4706, 1820, 29889, 5504, 29898, 9053, 1989, 29897, 13, 4706, 1820, 29889, 5504, 703, 3597, 1989, 1159, 13, 4706, 970, 1989, 353, 1820, 29889, 20970, 7501, 342, 580, 13, 4706, 4808, 886, 353, 5159, 13, 4706, 1583, 29889, 1792, 29961, 9053, 1989, 29962, 353, 11117, 3597, 1989, 2396, 970, 1989, 29892, 525, 8948, 886, 2396, 8948, 886, 29913, 13, 4706, 1583, 29889, 446, 962, 481, 29961, 3597, 1989, 29962, 353, 2024, 1989, 13, 4706, 736, 2024, 1989, 29892, 970, 1989, 29892, 4808, 886, 13, 13, 1678, 396, 736, 1051, 310, 599, 970, 6611, 13, 1678, 822, 679, 19858, 15506, 29898, 1311, 1125, 13, 4706, 970, 1989, 353, 5159, 13, 4706, 363, 995, 297, 1583, 29889, 1792, 29889, 5975, 7295, 13, 9651, 970, 1989, 29889, 4397, 29898, 1767, 1839, 3597, 1989, 11287, 13, 4706, 736, 970, 1989, 13, 13, 1678, 396, 736, 970, 1989, 310, 4944, 2024, 1989, 13, 1678, 822, 679, 19858, 2558, 29898, 1311, 29892, 2024, 1989, 1125, 13, 4706, 565, 451, 1583, 29889, 1792, 29889, 657, 29898, 9053, 1989, 1125, 13, 9651, 12020, 2921, 974, 29891, 1111, 262, 2392, 703, 13919, 2024, 1989, 1159, 13, 4706, 736, 1583, 29889, 1792, 29889, 657, 29898, 9053, 1989, 29897, 1839, 3597, 1989, 2033, 13, 13, 1678, 396, 736, 19480, 4808, 886, 310, 4944, 2024, 1989, 13, 1678, 822, 679, 29144, 292, 29898, 1311, 29892, 2024, 1989, 1125, 13, 4706, 565, 451, 1583, 29889, 1792, 29889, 657, 29898, 9053, 1989, 1125, 13, 9651, 12020, 2921, 974, 29891, 1111, 262, 2392, 703, 13919, 2024, 1989, 1159, 13, 4706, 736, 1583, 29889, 1792, 29889, 657, 29898, 9053, 1989, 29897, 1839, 8948, 886, 2033, 13, 13, 1678, 822, 679, 25207, 2558, 29898, 1311, 29892, 970, 1989, 1125, 13, 4706, 565, 451, 1583, 29889, 446, 962, 481, 29889, 657, 29898, 3597, 1989, 1125, 13, 9651, 12020, 2921, 974, 29891, 1111, 262, 2392, 703, 13919, 970, 1989, 1159, 13, 4706, 736, 1583, 29889, 446, 962, 481, 29889, 657, 29898, 3597, 1989, 29897, 13, 13, 1990, 3189, 262, 29898, 3318, 1125, 13, 13, 1678, 822, 4770, 2344, 12035, 1311, 29892, 4911, 1125, 13, 4706, 1583, 29889, 1111, 262, 353, 6571, 13, 4706, 1583, 29889, 1792, 353, 4911, 13, 4706, 1583, 29889, 839, 914, 353, 5159, 13, 13, 1678, 396, 3639, 716, 1178, 363, 19480, 11265, 13, 1678, 822, 679, 1482, 333, 29898, 1311, 1125, 13, 4706, 736, 313, 2435, 29898, 1311, 29889, 1111, 262, 29897, 718, 29871, 29896, 29897, 13, 13, 1678, 396, 274, 333, 353, 5412, 1178, 310, 19480, 13, 1678, 396, 23107, 353, 29871, 2024, 1820, 310, 907, 1061, 13, 1678, 822, 1653, 7967, 262, 29898, 1311, 29892, 274, 333, 29892, 23107, 1125, 13, 4706, 5534, 748, 974, 29891, 1989, 13, 13, 4706, 396, 11265, 338, 871, 6068, 363, 748, 974, 29891, 13, 4706, 565, 23107, 1360, 1484, 974, 29891, 1989, 322, 274, 333, 1360, 1311, 29889, 657, 1482, 333, 7295, 13, 9651, 1583, 29889, 1111, 262, 29961, 25232, 29962, 353, 5159, 13, 9651, 396, 937, 10804, 310, 274, 333, 2056, 10804, 5331, 914, 338, 263, 1051, 13, 9651, 1583, 29889, 1111, 262, 29961, 25232, 1822, 4397, 29898, 1311, 29889, 1792, 29889, 657, 19858, 2558, 29898, 5935, 876, 13, 13, 9651, 10804, 353, 8853, 1037, 1061, 1115, 1583, 29889, 1792, 29889, 657, 19858, 2558, 29898, 5935, 511, 13, 462, 1678, 376, 7967, 262, 333, 1115, 274, 333, 29892, 13, 462, 1678, 376, 27939, 1115, 12865, 29889, 3707, 2141, 10718, 4830, 3285, 13, 9651, 500, 13, 13, 9651, 396, 2767, 5331, 914, 13, 9651, 1583, 29889, 839, 914, 29889, 4397, 29898, 20736, 29897, 13, 13, 9651, 396, 2767, 13587, 310, 1404, 13, 9651, 1583, 29889, 1792, 29889, 1792, 29961, 5935, 22322, 8948, 886, 13359, 4397, 29898, 25232, 29897, 13, 9651, 1596, 376, 14191, 8159, 19480, 11265, 411, 1178, 6571, 1642, 4830, 29898, 25232, 29897, 13, 13, 4706, 1683, 29901, 13, 9651, 12020, 2921, 974, 29891, 1111, 262, 2392, 703, 29903, 3818, 871, 2921, 974, 29891, 338, 6068, 304, 1653, 29905, 13, 632, 716, 1302, 1144, 411, 5412, 1178, 23157, 13, 13, 1678, 396, 8177, 353, 1162, 347, 369, 29915, 29879, 970, 1820, 13, 1678, 396, 23107, 353, 10004, 29915, 29879, 2024, 1820, 13, 1678, 822, 1209, 1111, 262, 29898, 1311, 29892, 274, 333, 29892, 8177, 29892, 23107, 1125, 13, 13, 4706, 396, 12725, 19480, 29915, 29879, 10379, 13, 4706, 565, 274, 333, 451, 297, 1583, 29889, 1111, 262, 29889, 8149, 7295, 13, 9651, 12020, 2921, 974, 29891, 1111, 262, 2392, 703, 3782, 1316, 19480, 1863, 29889, 26579, 2921, 29877, 974, 29891, 304, 1653, 320, 13, 9651, 697, 1159, 13, 13, 4706, 565, 8177, 451, 297, 1583, 29889, 1792, 29889, 657, 19858, 15506, 7295, 13, 9651, 12020, 2921, 974, 29891, 1111, 262, 2392, 703, 29907, 2124, 29899, 5596, 1162, 347, 369, 29915, 29879, 970, 1820, 1159, 13, 13, 4706, 396, 12725, 3692, 1404, 1914, 29879, 393, 19480, 29973, 13, 4706, 565, 451, 1583, 29889, 657, 28213, 29898, 25232, 29897, 1275, 1583, 29889, 1792, 29889, 657, 19858, 2558, 29898, 5935, 1125, 13, 9651, 12020, 2921, 974, 29891, 1111, 262, 2392, 703, 29903, 3818, 29892, 366, 1838, 29915, 29873, 288, 705, 19480, 426, 29900, 29913, 1642, 4830, 29898, 25232, 876, 13, 13, 4706, 396, 9773, 19480, 29915, 29879, 2908, 14153, 13, 4706, 1583, 29889, 1111, 262, 29961, 25232, 1822, 4397, 29898, 2429, 29897, 13, 13, 4706, 396, 2767, 13587, 310, 1404, 13, 4706, 1583, 29889, 1792, 29889, 1792, 29961, 5935, 22322, 8948, 886, 13359, 5992, 29898, 25232, 29897, 13, 13, 4706, 1583, 29889, 1792, 29889, 1792, 29961, 1311, 29889, 1792, 29889, 657, 25207, 2558, 29898, 2429, 4638, 1839, 8948, 886, 13359, 4397, 29898, 25232, 29897, 13, 13, 4706, 10804, 353, 8853, 15452, 1115, 1583, 29889, 1792, 29889, 657, 19858, 2558, 29898, 5935, 511, 13, 18884, 376, 3757, 347, 369, 1115, 8177, 29892, 13, 18884, 376, 7967, 262, 333, 1115, 274, 333, 29892, 13, 18884, 376, 27939, 1115, 12865, 29889, 3707, 2141, 10718, 4830, 3285, 13, 4706, 500, 13, 13, 4706, 396, 2767, 5331, 914, 13, 4706, 1583, 29889, 839, 914, 29889, 4397, 29898, 20736, 29897, 13, 4706, 1596, 376, 12460, 21397, 8159, 29908, 13, 13, 1678, 822, 679, 28213, 29898, 1311, 29892, 274, 333, 1125, 13, 13, 4706, 565, 274, 333, 451, 297, 1583, 29889, 1111, 262, 29889, 8149, 7295, 13, 9651, 12020, 2921, 974, 29891, 1111, 262, 2392, 703, 3782, 1316, 19480, 1863, 29889, 26579, 2921, 29877, 974, 29891, 304, 1653, 320, 13, 9651, 697, 16521, 13, 13, 4706, 736, 1583, 29889, 1111, 262, 29961, 25232, 3816, 29899, 29896, 29962, 13, 13, 1678, 822, 679, 839, 914, 29898, 1311, 1125, 13, 4706, 736, 1583, 29889, 839, 914, 13, 13, 1678, 822, 1423, 3084, 29891, 29898, 1311, 29892, 274, 333, 1125, 13, 13, 4706, 565, 274, 333, 451, 297, 1583, 29889, 1111, 262, 29889, 8149, 7295, 13, 9651, 12020, 2921, 974, 29891, 1111, 262, 2392, 703, 3782, 1316, 19480, 1863, 29889, 26579, 2921, 29877, 974, 29891, 304, 1653, 320, 13, 9651, 697, 16521, 13, 13, 4706, 9704, 353, 5124, 13, 4706, 363, 4160, 297, 1583, 29889, 1111, 262, 29889, 657, 29898, 25232, 1125, 13, 9651, 9704, 353, 9704, 718, 4160, 718, 376, 489, 976, 11903, 13, 13, 4706, 736, 9704, 13, 13, 29937, 20254, 1301, 1953, 13, 1753, 20254, 29898, 1792, 29892, 19480, 1125, 13, 1678, 5534, 748, 974, 29891, 1989, 13, 1678, 5534, 2069, 1111, 262, 13, 1678, 5534, 2069, 1792, 13, 13, 1678, 2847, 1111, 1144, 353, 2069, 1111, 262, 13, 13, 1678, 396, 20254, 11265, 310, 1302, 1144, 13, 1678, 363, 474, 297, 3464, 29898, 29900, 29892, 2847, 1111, 1144, 1125, 13, 4706, 19480, 29889, 3258, 7967, 262, 29898, 1111, 262, 29889, 657, 1482, 333, 3285, 748, 974, 29891, 1989, 29897, 13, 4706, 474, 4619, 29871, 29896, 13, 13, 1678, 396, 1353, 310, 1302, 1144, 304, 367, 13931, 4249, 4160, 13, 1678, 1302, 457, 29567, 353, 2847, 1111, 1144, 14571, 2344, 1792, 29930, 29906, 29897, 13, 13, 1678, 396, 20254, 4160, 322, 4978, 310, 1302, 1144, 13, 1678, 363, 474, 297, 3464, 29898, 29900, 29892, 2069, 1792, 1125, 13, 4706, 2024, 1989, 29892, 970, 1989, 29892, 4808, 886, 353, 1404, 29889, 3258, 1792, 580, 13, 4706, 1596, 376, 9053, 1989, 26359, 29892, 9053, 1989, 29892, 6634, 29876, 3597, 1989, 26359, 29892, 970, 1989, 13, 4706, 363, 432, 297, 3464, 29898, 29900, 29892, 1302, 457, 29567, 1125, 13, 9651, 19480, 29889, 3364, 1111, 262, 29898, 11228, 1111, 1144, 29892, 970, 1989, 29892, 748, 974, 29891, 1989, 29897, 13, 9651, 2847, 1111, 1144, 22361, 29871, 29896, 13, 13, 361, 4770, 978, 1649, 1275, 376, 1649, 3396, 1649, 1115, 13, 1678, 1404, 353, 4911, 580, 13, 1678, 19480, 353, 3189, 262, 29898, 1792, 29897, 13, 1678, 20254, 29898, 1792, 29892, 19480, 29897, 13, 1678, 1550, 5852, 29901, 13, 4706, 1596, 376, 29884, 29901, 1653, 1404, 320, 29876, 282, 29901, 3364, 1111, 262, 320, 29876, 274, 29901, 3258, 1111, 262, 29905, 29876, 301, 29901, 20736, 320, 13, 4706, 5331, 914, 320, 29876, 298, 29901, 679, 596, 13587, 320, 29876, 325, 29901, 11539, 2854, 29891, 310, 19480, 29908, 13, 13, 4706, 9920, 353, 10650, 29918, 2080, 703, 10858, 1899, 29973, 1159, 13, 13, 4706, 1018, 29901, 13, 9651, 565, 9920, 1275, 525, 29884, 2396, 13, 18884, 2024, 1989, 29892, 970, 1989, 29892, 4808, 886, 353, 1404, 29889, 3258, 1792, 580, 13, 18884, 1596, 376, 9053, 1989, 26359, 29892, 9053, 1989, 29892, 6634, 29876, 3597, 1989, 26359, 29892, 970, 1989, 13, 13, 9651, 25342, 9920, 1360, 525, 29886, 2396, 13, 18884, 274, 333, 353, 938, 29898, 1610, 29918, 2080, 703, 1111, 262, 1178, 3026, 876, 13, 18884, 8177, 353, 10650, 29918, 2080, 703, 3757, 347, 369, 29915, 29879, 970, 1820, 29973, 1159, 13, 18884, 23107, 353, 10650, 29918, 2080, 703, 10858, 2024, 1989, 29973, 1159, 13, 13, 18884, 19480, 29889, 3364, 1111, 262, 29898, 25232, 29892, 8177, 29892, 23107, 29897, 13, 13, 9651, 25342, 9920, 1360, 29915, 29883, 2396, 13, 18884, 23107, 353, 10650, 29918, 2080, 703, 10858, 2024, 1989, 29973, 1159, 13, 13, 18884, 19480, 29889, 3258, 7967, 262, 29898, 1111, 262, 29889, 657, 1482, 333, 3285, 23107, 29897, 13, 13, 9651, 25342, 9920, 1360, 29915, 29880, 2396, 13, 18884, 1596, 19480, 29889, 657, 839, 914, 580, 13, 13, 9651, 25342, 9920, 1360, 29915, 29882, 2396, 13, 18884, 23107, 353, 10650, 29918, 2080, 703, 10858, 2024, 1989, 29973, 1159, 13, 18884, 1596, 1404, 29889, 657, 29144, 292, 29898, 5935, 29897, 13, 13, 9651, 25342, 9920, 1360, 29915, 29894, 2396, 13, 18884, 274, 333, 353, 938, 29898, 1610, 29918, 2080, 703, 1111, 262, 1178, 3026, 876, 13, 18884, 1596, 19480, 29889, 3198, 3084, 29891, 29898, 25232, 29897, 13, 13, 9651, 1683, 29901, 13, 18884, 1596, 376, 1184, 29894, 680, 2854, 1899, 29908, 13, 13, 9651, 1596, 13, 4706, 5174, 2921, 974, 29891, 1111, 262, 2392, 408, 321, 29901, 13, 9651, 1596, 321, 29889, 4906, 13, 2 ]
SScriptCompiler/examples/caseTest.py
alklasil/SScript
0
82240
"""Simple if-else / swicth-case test.""" from src.SProgram import SProgram as program from src.conf.SStd import SStd def get_programData(): return { "confs": [ SStd ], "variableNameValuePairs": [ "i" ], "states": [ ("main", [ # synchronous execution [ # store state "case" into tmp # execute tmp (=="case") as a state "$=(const)=", "tmp", "@case", "$executeState", "tmp", # print i "$printInt_ln", "i" ], # The switch-case statement (state) can also be executed asynchronously: # (i.e., execute in the next loop.) # (may be good option if switch-case statement is more complex) # (There are multiple ways of executing the switch-case statement # asynchronously: below is one of them) # Set state=proxy, set proxyState=case, set returnState=main # (nextLoop) state::proxy::executeState(proxyState) # (nextLoop) state::proxy::set state=returnState ]), ("case", [ ["$=", "?", "i"], # case 0: i++ ["$if", "?", "0", [ "$+", "i", "1", "$return" ]], # case 1: i++, i++ ["$if", "?", "1", [ ["$+", "i", "1"]*2, "$return" ]], # default [ "$=", "i", "0", ] ]), ] } def main(argv=[], programData=get_programData()): # program p = program(**programData) # compile and print the program p.compile() if __name__ == "__main__": # execute only if run as a script main()
[ 1, 9995, 15427, 565, 29899, 2870, 847, 2381, 293, 386, 29899, 4878, 1243, 1213, 15945, 13, 3166, 4765, 29889, 29903, 9283, 1053, 317, 9283, 408, 1824, 13, 3166, 4765, 29889, 5527, 29889, 29903, 855, 29881, 1053, 317, 855, 29881, 13, 13, 13, 1753, 679, 29918, 8860, 1469, 7295, 13, 1678, 736, 426, 13, 4706, 376, 5527, 29879, 1115, 518, 13, 9651, 317, 855, 29881, 13, 4706, 21251, 13, 4706, 376, 11918, 1170, 1917, 29925, 7121, 1115, 518, 13, 9651, 376, 29875, 29908, 13, 4706, 21251, 13, 4706, 376, 28631, 1115, 518, 13, 9651, 4852, 3396, 613, 518, 13, 13, 18884, 396, 12231, 681, 8225, 13, 18884, 518, 13, 462, 1678, 396, 3787, 2106, 376, 4878, 29908, 964, 13128, 13, 462, 1678, 396, 6222, 13128, 11070, 543, 4878, 1159, 408, 263, 2106, 13, 462, 1678, 3908, 7607, 3075, 29897, 543, 29892, 376, 7050, 613, 17962, 4878, 613, 13, 462, 1678, 3908, 7978, 2792, 613, 376, 7050, 613, 13, 462, 1678, 396, 1596, 474, 13, 462, 1678, 3908, 2158, 2928, 29918, 3083, 613, 376, 29875, 29908, 13, 18884, 21251, 13, 13, 18884, 396, 450, 4607, 29899, 4878, 3229, 313, 3859, 29897, 508, 884, 367, 8283, 408, 9524, 5794, 29901, 13, 18884, 396, 313, 29875, 29889, 29872, 1696, 6222, 297, 278, 2446, 2425, 1846, 13, 18884, 396, 313, 13029, 367, 1781, 2984, 565, 4607, 29899, 4878, 3229, 338, 901, 4280, 29897, 13, 18884, 396, 313, 8439, 526, 2999, 5837, 310, 14012, 278, 4607, 29899, 4878, 3229, 13, 18884, 396, 29871, 408, 9524, 5794, 29901, 2400, 338, 697, 310, 963, 29897, 13, 18884, 396, 259, 3789, 2106, 29922, 14701, 29892, 731, 10166, 2792, 29922, 4878, 29892, 731, 736, 2792, 29922, 3396, 13, 18884, 396, 418, 313, 4622, 18405, 29897, 2106, 1057, 14701, 1057, 7978, 2792, 29898, 14701, 2792, 29897, 13, 18884, 396, 418, 313, 4622, 18405, 29897, 2106, 1057, 14701, 1057, 842, 2106, 29922, 2457, 2792, 13, 9651, 4514, 511, 13, 9651, 4852, 4878, 613, 518, 13, 18884, 6796, 29938, 543, 29892, 376, 29973, 613, 376, 29875, 12436, 13, 18884, 396, 1206, 29871, 29900, 29901, 474, 1817, 13, 18884, 6796, 29938, 361, 613, 376, 29973, 613, 376, 29900, 613, 518, 13, 462, 1678, 3908, 29974, 613, 376, 29875, 613, 376, 29896, 613, 13, 462, 1678, 3908, 2457, 29908, 13, 18884, 4514, 1402, 13, 18884, 396, 1206, 29871, 29896, 29901, 474, 10024, 474, 1817, 13, 18884, 6796, 29938, 361, 613, 376, 29973, 613, 376, 29896, 613, 518, 13, 462, 1678, 6796, 29938, 29974, 613, 376, 29875, 613, 376, 29896, 3108, 29930, 29906, 29892, 13, 462, 1678, 3908, 2457, 29908, 13, 18884, 4514, 1402, 13, 18884, 396, 2322, 13, 18884, 518, 13, 462, 1678, 3908, 543, 29892, 376, 29875, 613, 376, 29900, 613, 13, 18884, 4514, 13, 9651, 4514, 511, 13, 13, 4706, 4514, 13, 1678, 500, 13, 13, 13, 1753, 1667, 29898, 19218, 11759, 1402, 1824, 1469, 29922, 657, 29918, 8860, 1469, 580, 1125, 13, 1678, 396, 1824, 13, 1678, 282, 353, 1824, 29898, 1068, 8860, 1469, 29897, 13, 1678, 396, 6633, 322, 1596, 278, 1824, 13, 1678, 282, 29889, 12198, 580, 13, 13, 13, 361, 4770, 978, 1649, 1275, 376, 1649, 3396, 1649, 1115, 13, 1678, 396, 6222, 871, 565, 1065, 408, 263, 2471, 13, 1678, 1667, 580, 13, 2 ]
detectTrimPoints_woh.py
cilt-uct/TrimPointDetector
0
181145
#!/usr/bin/python ''' Detects the start and end trimpoints of an audio file. ''' import sys import numpy import sklearn.cluster import time import scipy import os import ConfigParser from pyAudioAnalysis import audioFeatureExtraction as aF from pyAudioAnalysis import audioTrainTest as aT from pyAudioAnalysis import audioBasicIO import matplotlib.pyplot as plt from scipy.spatial import distance import matplotlib.pyplot as plt import matplotlib.cm as cm import sklearn.discriminant_analysis from pyAudioAnalysis import audioSegmentation as aS import itertools as it import wave import contextlib import argparse class Segment(object): def __init__(self, start, end, classification): self.start = int(start) self.end = int(end) self.diff = int(end) - int(start) self.classification = str(classification) def get_model_path(wave_file): # model used to predict mic model (boundary or lapel) mic_model = "model/svmDetectMicTypeModel" # lapel speech model lapel_model = "model/svmLapelSpeechModel" # boundary speech model boundary_model = "model/svmNoLapelSpeechModel" # run the classification model on the audio file [Result, P, classNames] = aT.fileClassification(wave_file, mic_model, "svm") Result = int(Result) #return boundary_model # if the winner class is boundary_speech return # the path of the boundary speech model, otherwise # return the path of thelapel speech model if (classNames[Result] == "boundry_speech"): return boundary_model else: return lapel_model def ConfigSectionMap(section): dict1 = {} options = Config.options(section) for option in options: try: dict1[option] = Config.get(section, option) #if dict1[option] == -1: # DebugPrint("skip: %s" % option) except: print("exception on %s!" % option) dict1[option] = None return dict1 def PrintEmptyOutput(_file, _duration, _time): f = open(_file, 'w') f.write('audio_trim_duration={}\n'.format(_duration)) f.write('audio_trim_autotrim=false\n') f.write('audio_trim_ishour=false\n') f.write('audio_trim_lapel=false\n') f.write('audio_trim_model=none\n') f.write('audio_trim_exec_time={};{}\n'.format(0, _time)) f.close() return parser = argparse.ArgumentParser(description='Audio Trim point detector') parser.add_argument('--version', action='version', version='Audio Trim point detector build UCT May 14 2018 14:53') parser.add_argument('--venue', dest='venue', type=str, default='none', help='The venue of this recording used for venue specific models') parser.add_argument('-i', '--input', dest='inputWavFile', type=str, required=True, metavar="wav", help='The wav file to detect trimpoints from') parser.add_argument('-o', '--output', dest='outputTextFile', type=str, required=True, metavar="txt", help='The file to write the properties in') parser.add_argument('--start-speech', dest='theshold_speech_start', type=int, default=3, metavar="(seconds)", help='Threshold for speech at the start of the recording [sec] (default: 3, >=)') parser.add_argument('--end-speech', dest='threshold_speech_end', type=int, default=5, metavar="(seconds)", help='Threshold value for speech at the end of the recording [sec] (default: 5, >=)') parser.add_argument('--non-speech', dest='threshold', type=int, default=90, metavar="(seconds)", help='Threshold value for non-speech segments [sec] (default: 90 >=)') parser.add_argument('--start-adjust', dest='adjust_speech_start', type=int, default=-20, metavar="(seconds)", help='Adjust the first speech segment start time by a number of seconds [sec] (default: -20)') parser.add_argument('--end-adjust', dest='adjust_speech_end', type=int, default=30, metavar="(seconds)", help='Adjust the last speech segments end time by a number of seconds [sec] (default: 30)') parser.add_argument('--start-buffer', dest='buffer_start', type=int, default=3, metavar="(seconds)", help='If the start of the segment list is 0 then use this buffer [sec] (default: 3)') parser.add_argument('--end-buffer', dest='buffer_end', type=int, default=1, metavar="(seconds)", help='If the last segment ends at the end of the wav file adjust by this buffer [sec] (default: 1)') parser.add_argument('--good-start', dest='good_start', type=int, default=300, metavar="(seconds)", help='Does the first segment start within this number of seconds, if true then good start [sec] (default: 300 = 5min)') parser.add_argument('--good-end', dest='good_end', type=int, default=600, metavar="(seconds)", help='Does the last segment end within this number of seconds, if true then good end [sec] (default: 600 = 10min)') parser.add_argument('-d', '--debug', action='store_true', help='print debug messages') args = vars(parser.parse_args()) start_time = time.time() Config = ConfigParser.ConfigParser() Config.read("config.ini") if (args['debug']): print('Start processing...') if not os.path.isfile(args['inputWavFile']): print('Cannot locate audio file {}'.format(args['inputWavFile'])) default_modelName = "model/svmNoLapelSpeechModel" modelName = "model/noModel" # get the duration of the wave file duration = 0 audio_trim_duration = 0 audio_trim_hour = 0 auto_trim = 1 # optimistic - we want to auto_trim with contextlib.closing(wave.open(args['inputWavFile'],'r')) as f: frames = f.getnframes() rate = f.getframerate() duration = int(frames / float(rate)) audio_trim_duration = int(duration*1000) audio_trim_hour = 1 if (int(duration) < 3700) else 0 if (args['debug']): print('\tDuration: {} {}'.format(audio_trim_hour, audio_trim_duration)) my_segments = [] model_time = 0 if (audio_trim_hour == 1): if (args['debug']): print('\tDetecting model...') # ONLY do this for recordings that are less than an 60 min # so if there is a venue that we have mapped then we are going to use that model # else we will use the appropriate mic configuration if args['venue'] in ConfigSectionMap("Venues"): modelName = 'model/' + ConfigSectionMap("Venues")[ args['venue'] ] if not os.path.isfile(modelName): modelName = default_modelName if not os.path.isfile(modelName): print('Cannot locate model file {}'.format(modelName)) else: # detect mic configuration by analyzing input wav file modelName = get_model_path(args['inputWavFile']) if (args['debug']): print ('\tusing: {}'.format(modelName)) model_time = time.time() - start_time modelType = "svm" gtFile = "" returnVal = aS.mtFileClassification(args['inputWavFile'], modelName, modelType, False, gtFile) flagsInd = returnVal[0] classNames = returnVal[1] flags = [classNames[int(f)] for f in flagsInd] (segs, classes) = aS.flags2segs(flags, 1) for s in range(len(segs)): sg = segs[s] diff = int(sg[1]) - int(sg[0]) if (args['debug']): print('{:>6} - {:>6} ({:>6}) : {}').format(sg[0], sg[1], diff, classes[s]) my_segments.append(Segment(int(sg[0]), int(sg[1]), str(classes[s]))) # Speech and non speech lists final_list = [] detected_list = [] segments_non_speech = filter(lambda x: (x.diff >= int(args['threshold'])) and (x.classification == "non-speech"), my_segments) segments_non_speech.sort(key=lambda x: x.end) segments_speech = filter(lambda x: x.classification == "speech", my_segments) segments_speech.sort(key=lambda x: x.end) segments_speech_start = filter(lambda x: (x.start >= int(args['theshold_speech_start'])), segments_speech) segments_speech_start.sort(key=lambda x: x.end) segments_speech_end = filter(lambda x: (x.end <= duration - int(args['threshold_speech_end'])), segments_speech) segments_speech_end.sort(key=lambda x: x.end) segments_speech_useable = filter(lambda x: (x.start >= int(args['theshold_speech_start'])) and (x.end <= duration - int(args['threshold_speech_end'])), segments_speech) segments_speech_useable.sort(key=lambda x: x.end) if len(segments_speech) > 0: if (args['debug']): print('found {} segments, speech {} \n'.format(len(my_segments), len(segments_speech))) # default start/end as detected without threshold check detected_list.append(segments_speech[0].start) detected_list.append(segments_speech[-1].end) for c in segments_non_speech: if (args['debug']): print('{:>6} - {:>6} ({:>6}) : {}').format(c.start, c.end, c.diff, c.classification) final_list.append(c.start) detected_list.append(c.start) tmp_segment = filter(lambda x: x.start == c.end, segments_speech) if (len(tmp_segment) > 1): #print('\t{:>6} - {:>6} ({:>6}) : {}').format(tmp_segment.start, tmp_segment.end, tmp_segment.diff, tmp_segment.classification) print(tmp_segment) final_list.append(c.end) detected_list.append(c.end) if (len(segments_speech_start) > 1): final_list.append(segments_speech_start[0].start + int(args['adjust_speech_start'])) if (args['debug']): print('\n|{:>6}|{:>6}|{:>6} Start'.format(segments_speech_start[0].start, args['adjust_speech_start'], segments_speech_start[0].start + args['adjust_speech_start'])) else: final_list.append(int(args['buffer_start'])) auto_trim = 0 # start is at 0 - bad start if (len(segments_speech_end) > 1): final_list.append(segments_speech_end[-1].end + int(args['adjust_speech_end'])) if (args['debug']): print('|{:>6}|{:>6}|{:>6} End'.format(segments_speech_end[-1].end, args['adjust_speech_end'], segments_speech_end[-1].start + args['adjust_speech_end'])) else: final_list.append(duration) auto_trim = 0 # end is length of recording - bad end # remove duplicates detected_list = set(detected_list) detected_list = list(detected_list) detected_list.sort() final_list = set(final_list) final_list = list(final_list) final_list.sort() if (final_list[0] <= 0): final_list[0] = int(args['buffer_start']) auto_trim = 0 # start is at 0 - bad start if (final_list[-1] > duration): final_list[-1] = duration auto_trim = 0 # end is length of recording - bad end if (args['debug']): print('\n') print(detected_list) print(final_list) stats = { 'len': len(my_segments), 'hour': audio_trim_hour, 'duration': audio_trim_duration, 'speech_no': len(segments_speech), 'speech_ms': sum(c.diff for c in segments_speech), 'nonspeech_no': len(segments_non_speech), 'nonspeech_ms': sum(c.diff for c in segments_non_speech), 'nonspeech_used_no': len(segments_speech_useable), 'nonspeech_used_ms': sum(c.diff for c in segments_speech_useable) } # first segment is always a x no of seconds from the start... if (final_list[0] == 0): final_list[0] = args['buffer_start'] stats['good_start'] = 0 auto_trim = 0 # start is at 0 - bad start else: stats['good_start'] = final_list[0] < args['good_start'] if (final_list[-1] == duration): final_list[-1] = duration - args['buffer_end'] stats['good_end'] = 0 auto_trim = 0 # end is length of recording - bad end else: stats['good_end'] = final_list[-1] + args['good_end'] > int(audio_trim_duration / 1000) final_list = map(lambda x: x * 1000, final_list) result = '' d = '-' for e in final_list: result = result + str(e) + d if (d == '-'): d = ';' else: d = '-' if (args['debug']): print(stats) print('modelName: {}'.format(modelName)) print('audio_trim_autotrim={}'.format("true" if ((stats['hour'] == 1) and (stats['nonspeech_used_no'] == 0) and stats['good_start'] and stats['good_end']) else "false")) print(result) f = open(args['outputTextFile'], 'w') #f.write('audio_trim_file=' + args['inputWavFile'] +'\n') #f.write('audio_trim_out_file=' + args['outputTextFile'] +'\n') f.write('audio_trim_duration={}\n'.format(stats['duration'])) f.write('audio_trim_autotrim={}\n'.format("true" if ((stats['hour'] == 1) and (stats['nonspeech_used_no'] == 0) and stats['good_start'] and stats['good_end']) else "false")) f.write('audio_trim_ishour={}\n'.format("true" if (stats['hour'] == 1) else "false")) f.write('audio_trim_good_start={}\n'.format("true" if (stats['good_start']) else "false")) f.write('audio_trim_good_end={}\n'.format("true" if (stats['good_end']) else "false")) f.write('audio_trim_detected={}\n'.format('-'.join(str(x) for x in detected_list))) f.write('audio_trim_segments={}\n'.format(result)) f.write('audio_trim_segments_len={}\n'.format(stats['len'])) f.write('audio_trim_segments_speech={}\n'.format(stats['speech_no'])) f.write('audio_trim_segments_speech_ms={}\n'.format(int(stats['speech_ms']) * 1000)) f.write('audio_trim_segments_notspeech={}\n'.format(stats['nonspeech_no'])) f.write('audio_trim_segments_notspeech_ms={}\n'.format(int(stats['nonspeech_ms']) * 1000)) f.write('audio_trim_segments_notspeech_used={}\n'.format(stats['nonspeech_used_no'])) f.write('audio_trim_segments_notspeech_used_ms={}\n'.format(int(stats['nonspeech_used_ms']) * 1000)) f.write('audio_trim_threshold={}:{};{}\n'.format(args['theshold_speech_start'], args['threshold_speech_end'], args['threshold'])) f.write('audio_trim_adjust={}:{}\n'.format(args['adjust_speech_start'], args['adjust_speech_end'])) f.write('audio_trim_buffer={}:{}\n'.format(args['buffer_start'], args['buffer_end'])) f.write('audio_trim_good={}:{}\n'.format(args['good_start'], args['good_end'])) f.write('audio_trim_model={}\n'.format(modelName.replace("/","_"))) f.write('audio_trim_lapel={}\n'.format("true" if ("NoLapel" not in modelName) else "false")) f.write('audio_trim_exec_time={};{}\n'.format(round(model_time, 3), round(time.time() - start_time, 3))) f.close() else: PrintEmptyOutput(args['outputTextFile'], audio_trim_duration, round(time.time() - start_time, 3)) else: PrintEmptyOutput(args['outputTextFile'], audio_trim_duration, round(time.time() - start_time, 3)) sys.exit(os.EX_OK) # code 0, all ok
[ 1, 18787, 4855, 29914, 2109, 29914, 4691, 13, 12008, 5953, 522, 29879, 278, 1369, 322, 1095, 17151, 9748, 310, 385, 10348, 934, 29889, 14550, 13, 5215, 10876, 13, 5215, 12655, 13, 5215, 2071, 19668, 29889, 19594, 13, 5215, 931, 13, 5215, 4560, 2272, 13, 5215, 2897, 13, 5215, 12782, 11726, 13, 3166, 11451, 17111, 21067, 4848, 1053, 10348, 19132, 5647, 13857, 408, 263, 29943, 13, 3166, 11451, 17111, 21067, 4848, 1053, 10348, 5323, 262, 3057, 408, 263, 29911, 13, 3166, 11451, 17111, 21067, 4848, 1053, 10348, 16616, 5971, 13, 5215, 22889, 29889, 2272, 5317, 408, 14770, 13, 3166, 4560, 2272, 29889, 1028, 15238, 1053, 5418, 13, 5215, 22889, 29889, 2272, 5317, 408, 14770, 13, 5215, 22889, 29889, 4912, 408, 7477, 13, 5215, 2071, 19668, 29889, 2218, 29883, 20386, 424, 29918, 15916, 13, 3166, 11451, 17111, 21067, 4848, 1053, 10348, 17669, 358, 362, 408, 263, 29903, 13, 5215, 4256, 8504, 408, 372, 13, 5215, 10742, 13, 5215, 3030, 1982, 13, 5215, 1852, 5510, 13, 13, 1990, 6667, 358, 29898, 3318, 1125, 13, 13, 1678, 822, 4770, 2344, 12035, 1311, 29892, 1369, 29892, 1095, 29892, 12965, 1125, 13, 4706, 1583, 29889, 2962, 353, 938, 29898, 2962, 29897, 13, 4706, 1583, 29889, 355, 353, 938, 29898, 355, 29897, 13, 4706, 1583, 29889, 12765, 353, 938, 29898, 355, 29897, 448, 938, 29898, 2962, 29897, 13, 4706, 1583, 29889, 1990, 2450, 353, 851, 29898, 1990, 2450, 29897, 13, 13, 1753, 679, 29918, 4299, 29918, 2084, 29898, 27766, 29918, 1445, 1125, 13, 13, 1678, 396, 1904, 1304, 304, 8500, 20710, 1904, 313, 9917, 653, 470, 425, 13111, 29897, 13, 1678, 20710, 29918, 4299, 353, 376, 4299, 29914, 4501, 29885, 6362, 522, 29924, 293, 1542, 3195, 29908, 13, 1678, 396, 425, 13111, 12032, 1904, 13, 1678, 425, 13111, 29918, 4299, 353, 376, 4299, 29914, 4501, 29885, 29931, 481, 295, 10649, 5309, 3195, 29908, 13, 1678, 396, 10452, 12032, 1904, 13, 1678, 10452, 29918, 4299, 353, 376, 4299, 29914, 4501, 29885, 3782, 29931, 481, 295, 10649, 5309, 3195, 29908, 13, 13, 1678, 396, 1065, 278, 12965, 1904, 373, 278, 10348, 934, 13, 1678, 518, 3591, 29892, 349, 29892, 770, 8659, 29962, 353, 263, 29911, 29889, 1445, 2385, 2450, 29898, 27766, 29918, 1445, 29892, 20710, 29918, 4299, 29892, 376, 4501, 29885, 1159, 13, 1678, 7867, 353, 938, 29898, 3591, 29897, 13, 13, 1678, 396, 2457, 10452, 29918, 4299, 13, 1678, 396, 565, 278, 19576, 770, 338, 10452, 29918, 5965, 5309, 736, 13, 1678, 396, 278, 2224, 310, 278, 10452, 12032, 1904, 29892, 6467, 13, 1678, 396, 736, 278, 2224, 310, 278, 6984, 295, 12032, 1904, 13, 1678, 565, 313, 1990, 8659, 29961, 3591, 29962, 1275, 376, 9917, 719, 29918, 5965, 5309, 29908, 1125, 13, 4706, 736, 10452, 29918, 4299, 13, 1678, 1683, 29901, 13, 4706, 736, 425, 13111, 29918, 4299, 13, 13, 1753, 12782, 13438, 3388, 29898, 2042, 1125, 13, 1678, 9657, 29896, 353, 6571, 13, 1678, 3987, 353, 12782, 29889, 6768, 29898, 2042, 29897, 13, 1678, 363, 2984, 297, 3987, 29901, 13, 4706, 1018, 29901, 13, 9651, 9657, 29896, 29961, 3385, 29962, 353, 12782, 29889, 657, 29898, 2042, 29892, 2984, 29897, 13, 9651, 396, 361, 9657, 29896, 29961, 3385, 29962, 1275, 448, 29896, 29901, 13, 9651, 396, 1678, 16171, 11816, 703, 11014, 29901, 1273, 29879, 29908, 1273, 2984, 29897, 13, 4706, 5174, 29901, 13, 9651, 1596, 703, 11739, 373, 1273, 29879, 3850, 1273, 2984, 29897, 13, 9651, 9657, 29896, 29961, 3385, 29962, 353, 6213, 13, 1678, 736, 9657, 29896, 13, 13, 1753, 13905, 8915, 6466, 7373, 1445, 29892, 903, 19708, 29892, 903, 2230, 1125, 13, 13, 1678, 285, 353, 1722, 7373, 1445, 29892, 525, 29893, 1495, 13, 1678, 285, 29889, 3539, 877, 18494, 29918, 15450, 29918, 19708, 3790, 1012, 29876, 4286, 4830, 7373, 19708, 876, 13, 1678, 285, 29889, 3539, 877, 18494, 29918, 15450, 29918, 1300, 327, 5632, 29922, 4541, 29905, 29876, 1495, 13, 1678, 285, 29889, 3539, 877, 18494, 29918, 15450, 29918, 728, 473, 29922, 4541, 29905, 29876, 1495, 13, 1678, 285, 29889, 3539, 877, 18494, 29918, 15450, 29918, 6984, 295, 29922, 4541, 29905, 29876, 1495, 13, 1678, 285, 29889, 3539, 877, 18494, 29918, 15450, 29918, 4299, 29922, 9290, 29905, 29876, 1495, 13, 1678, 285, 29889, 3539, 877, 18494, 29918, 15450, 29918, 4258, 29918, 2230, 3790, 3400, 29912, 1012, 29876, 4286, 4830, 29898, 29900, 29892, 903, 2230, 876, 13, 1678, 285, 29889, 5358, 580, 13, 13, 1678, 736, 13, 13, 16680, 353, 1852, 5510, 29889, 15730, 11726, 29898, 8216, 2433, 17111, 1605, 326, 1298, 1439, 3019, 1495, 13, 16680, 29889, 1202, 29918, 23516, 877, 489, 3259, 742, 3158, 2433, 3259, 742, 1873, 2433, 17111, 1605, 326, 1298, 1439, 3019, 2048, 501, 1783, 2610, 29871, 29896, 29946, 29871, 29906, 29900, 29896, 29947, 29871, 29896, 29946, 29901, 29945, 29941, 1495, 13, 13, 16680, 29889, 1202, 29918, 23516, 877, 489, 9947, 742, 2731, 2433, 9947, 742, 1134, 29922, 710, 29892, 2322, 2433, 9290, 742, 13, 462, 1678, 1371, 2433, 1576, 6003, 434, 310, 445, 16867, 1304, 363, 6003, 434, 2702, 4733, 1495, 13, 13, 16680, 29889, 1202, 29918, 23516, 877, 29899, 29875, 742, 525, 489, 2080, 742, 2731, 2433, 2080, 29956, 485, 2283, 742, 1134, 29922, 710, 29892, 3734, 29922, 5574, 29892, 1539, 485, 279, 543, 29893, 485, 613, 13, 462, 1678, 1371, 2433, 1576, 281, 485, 934, 304, 6459, 17151, 9748, 515, 1495, 13, 16680, 29889, 1202, 29918, 23516, 877, 29899, 29877, 742, 525, 489, 4905, 742, 2731, 2433, 4905, 1626, 2283, 742, 1134, 29922, 710, 29892, 3734, 29922, 5574, 29892, 1539, 485, 279, 543, 3945, 613, 13, 462, 1678, 1371, 2433, 1576, 934, 304, 2436, 278, 4426, 297, 1495, 13, 13, 16680, 29889, 1202, 29918, 23516, 877, 489, 2962, 29899, 5965, 5309, 742, 2731, 2433, 26041, 8948, 29918, 5965, 5309, 29918, 2962, 742, 1134, 29922, 524, 29892, 2322, 29922, 29941, 29892, 1539, 485, 279, 543, 29898, 23128, 19123, 13, 462, 1678, 1371, 2433, 1349, 12268, 363, 12032, 472, 278, 1369, 310, 278, 16867, 518, 3471, 29962, 313, 4381, 29901, 29871, 29941, 29892, 6736, 29897, 1495, 13, 16680, 29889, 1202, 29918, 23516, 877, 489, 355, 29899, 5965, 5309, 742, 2731, 2433, 386, 12268, 29918, 5965, 5309, 29918, 355, 742, 1134, 29922, 524, 29892, 2322, 29922, 29945, 29892, 1539, 485, 279, 543, 29898, 23128, 19123, 13, 462, 1678, 1371, 2433, 1349, 12268, 995, 363, 12032, 472, 278, 1095, 310, 278, 16867, 518, 3471, 29962, 313, 4381, 29901, 29871, 29945, 29892, 6736, 29897, 1495, 13, 13, 16680, 29889, 1202, 29918, 23516, 877, 489, 5464, 29899, 5965, 5309, 742, 2731, 2433, 386, 12268, 742, 1134, 29922, 524, 29892, 2322, 29922, 29929, 29900, 29892, 1539, 485, 279, 543, 29898, 23128, 19123, 13, 462, 1678, 1371, 2433, 1349, 12268, 995, 363, 1661, 29899, 5965, 5309, 24611, 518, 3471, 29962, 313, 4381, 29901, 29871, 29929, 29900, 6736, 29897, 1495, 13, 13, 16680, 29889, 1202, 29918, 23516, 877, 489, 2962, 29899, 328, 5143, 742, 2731, 2433, 328, 5143, 29918, 5965, 5309, 29918, 2962, 742, 1134, 29922, 524, 29892, 2322, 10457, 29906, 29900, 29892, 1539, 485, 279, 543, 29898, 23128, 19123, 13, 462, 1678, 1371, 2433, 3253, 5143, 278, 937, 12032, 10768, 1369, 931, 491, 263, 1353, 310, 6923, 518, 3471, 29962, 313, 4381, 29901, 448, 29906, 29900, 29897, 1495, 13, 16680, 29889, 1202, 29918, 23516, 877, 489, 355, 29899, 328, 5143, 742, 2731, 2433, 328, 5143, 29918, 5965, 5309, 29918, 355, 742, 1134, 29922, 524, 29892, 2322, 29922, 29941, 29900, 29892, 1539, 485, 279, 543, 29898, 23128, 19123, 13, 462, 1678, 1371, 2433, 3253, 5143, 278, 1833, 12032, 24611, 1095, 931, 491, 263, 1353, 310, 6923, 518, 3471, 29962, 313, 4381, 29901, 29871, 29941, 29900, 29897, 1495, 13, 13, 16680, 29889, 1202, 29918, 23516, 877, 489, 2962, 29899, 9040, 742, 2731, 2433, 9040, 29918, 2962, 742, 1134, 29922, 524, 29892, 2322, 29922, 29941, 29892, 1539, 485, 279, 543, 29898, 23128, 19123, 13, 462, 1678, 1371, 2433, 3644, 278, 1369, 310, 278, 10768, 1051, 338, 29871, 29900, 769, 671, 445, 6835, 518, 3471, 29962, 313, 4381, 29901, 29871, 29941, 29897, 1495, 13, 16680, 29889, 1202, 29918, 23516, 877, 489, 355, 29899, 9040, 742, 2731, 2433, 9040, 29918, 355, 742, 1134, 29922, 524, 29892, 2322, 29922, 29896, 29892, 1539, 485, 279, 543, 29898, 23128, 19123, 13, 462, 1678, 1371, 2433, 3644, 278, 1833, 10768, 10614, 472, 278, 1095, 310, 278, 281, 485, 934, 10365, 491, 445, 6835, 518, 3471, 29962, 313, 4381, 29901, 29871, 29896, 29897, 1495, 13, 13, 16680, 29889, 1202, 29918, 23516, 877, 489, 16773, 29899, 2962, 742, 2731, 2433, 16773, 29918, 2962, 742, 1134, 29922, 524, 29892, 2322, 29922, 29941, 29900, 29900, 29892, 1539, 485, 279, 543, 29898, 23128, 19123, 13, 462, 1678, 1371, 2433, 25125, 278, 937, 10768, 1369, 2629, 445, 1353, 310, 6923, 29892, 565, 1565, 769, 1781, 1369, 518, 3471, 29962, 313, 4381, 29901, 29871, 29941, 29900, 29900, 353, 29871, 29945, 1195, 29897, 1495, 13, 16680, 29889, 1202, 29918, 23516, 877, 489, 16773, 29899, 355, 742, 2731, 2433, 16773, 29918, 355, 742, 1134, 29922, 524, 29892, 2322, 29922, 29953, 29900, 29900, 29892, 1539, 485, 279, 543, 29898, 23128, 19123, 13, 462, 1678, 1371, 2433, 25125, 278, 1833, 10768, 1095, 2629, 445, 1353, 310, 6923, 29892, 565, 1565, 769, 1781, 1095, 518, 3471, 29962, 313, 4381, 29901, 29871, 29953, 29900, 29900, 353, 29871, 29896, 29900, 1195, 29897, 1495, 13, 13, 16680, 29889, 1202, 29918, 23516, 877, 29899, 29881, 742, 525, 489, 8382, 742, 3158, 2433, 8899, 29918, 3009, 742, 1371, 2433, 2158, 4744, 7191, 1495, 13, 13, 5085, 353, 24987, 29898, 16680, 29889, 5510, 29918, 5085, 3101, 13, 2962, 29918, 2230, 353, 931, 29889, 2230, 580, 13, 13, 3991, 353, 12782, 11726, 29889, 3991, 11726, 580, 13, 3991, 29889, 949, 703, 2917, 29889, 2172, 1159, 13, 13, 361, 313, 5085, 1839, 8382, 2033, 1125, 13, 1678, 1596, 877, 4763, 9068, 856, 1495, 13, 13, 361, 451, 2897, 29889, 2084, 29889, 275, 1445, 29898, 5085, 1839, 2080, 29956, 485, 2283, 2033, 1125, 13, 1678, 1596, 877, 29089, 26694, 10348, 934, 6571, 4286, 4830, 29898, 5085, 1839, 2080, 29956, 485, 2283, 25901, 13, 13, 4381, 29918, 4299, 1170, 353, 376, 4299, 29914, 4501, 29885, 3782, 29931, 481, 295, 10649, 5309, 3195, 29908, 13, 4299, 1170, 353, 376, 4299, 29914, 1217, 3195, 29908, 13, 13, 29937, 679, 278, 14385, 310, 278, 10742, 934, 13, 19708, 353, 29871, 29900, 13, 18494, 29918, 15450, 29918, 19708, 353, 29871, 29900, 13, 18494, 29918, 15450, 29918, 18721, 353, 29871, 29900, 13, 6921, 29918, 15450, 353, 29871, 29896, 396, 5994, 4695, 448, 591, 864, 304, 4469, 29918, 15450, 13, 13, 2541, 3030, 1982, 29889, 11291, 292, 29898, 27766, 29889, 3150, 29898, 5085, 1839, 2080, 29956, 485, 2283, 7464, 29915, 29878, 8785, 408, 285, 29901, 13, 1678, 16608, 353, 285, 29889, 657, 29876, 19935, 580, 13, 1678, 6554, 353, 285, 29889, 657, 1341, 4183, 403, 580, 13, 1678, 14385, 353, 938, 29898, 19935, 847, 5785, 29898, 10492, 876, 13, 1678, 10348, 29918, 15450, 29918, 19708, 353, 938, 29898, 19708, 29930, 29896, 29900, 29900, 29900, 29897, 13, 1678, 10348, 29918, 15450, 29918, 18721, 353, 29871, 29896, 565, 313, 524, 29898, 19708, 29897, 529, 29871, 29941, 29955, 29900, 29900, 29897, 1683, 29871, 29900, 13, 13, 361, 313, 5085, 1839, 8382, 2033, 1125, 13, 1678, 1596, 28909, 29873, 18984, 29901, 6571, 6571, 4286, 4830, 29898, 18494, 29918, 15450, 29918, 18721, 29892, 10348, 29918, 15450, 29918, 19708, 876, 13, 13, 1357, 29918, 10199, 1860, 353, 5159, 13, 4299, 29918, 2230, 353, 29871, 29900, 13, 361, 313, 18494, 29918, 15450, 29918, 18721, 1275, 29871, 29896, 1125, 13, 13, 1678, 565, 313, 5085, 1839, 8382, 2033, 1125, 13, 4706, 1596, 28909, 29873, 6362, 522, 292, 1904, 856, 1495, 13, 13, 1678, 396, 6732, 16786, 437, 445, 363, 2407, 886, 393, 526, 3109, 1135, 385, 29871, 29953, 29900, 1375, 13, 1678, 396, 577, 565, 727, 338, 263, 6003, 434, 393, 591, 505, 20545, 769, 591, 526, 2675, 304, 671, 393, 1904, 13, 1678, 396, 1683, 591, 674, 671, 278, 8210, 20710, 5285, 13, 1678, 565, 6389, 1839, 9947, 2033, 297, 12782, 13438, 3388, 703, 29963, 264, 1041, 29908, 1125, 13, 4706, 1904, 1170, 353, 525, 4299, 22208, 718, 12782, 13438, 3388, 703, 29963, 264, 1041, 1159, 29961, 6389, 1839, 9947, 2033, 4514, 13, 13, 4706, 565, 451, 2897, 29889, 2084, 29889, 275, 1445, 29898, 4299, 1170, 1125, 13, 9651, 1904, 1170, 353, 2322, 29918, 4299, 1170, 13, 9651, 565, 451, 2897, 29889, 2084, 29889, 275, 1445, 29898, 4299, 1170, 1125, 13, 18884, 1596, 877, 29089, 26694, 1904, 934, 6571, 4286, 4830, 29898, 4299, 1170, 876, 13, 1678, 1683, 29901, 13, 4706, 396, 6459, 20710, 5285, 491, 29537, 292, 1881, 281, 485, 934, 13, 4706, 1904, 1170, 353, 679, 29918, 4299, 29918, 2084, 29898, 5085, 1839, 2080, 29956, 485, 2283, 11287, 13, 13, 1678, 565, 313, 5085, 1839, 8382, 2033, 1125, 13, 4706, 1596, 6702, 29905, 29873, 4746, 29901, 6571, 4286, 4830, 29898, 4299, 1170, 876, 13, 13, 1678, 1904, 29918, 2230, 353, 931, 29889, 2230, 580, 448, 1369, 29918, 2230, 13, 1678, 1904, 1542, 353, 376, 4501, 29885, 29908, 13, 1678, 330, 29873, 2283, 353, 5124, 13, 1678, 736, 1440, 353, 263, 29903, 29889, 4378, 2283, 2385, 2450, 29898, 5085, 1839, 2080, 29956, 485, 2283, 7464, 1904, 1170, 29892, 1904, 1542, 29892, 7700, 29892, 330, 29873, 2283, 29897, 13, 1678, 13449, 2568, 353, 736, 1440, 29961, 29900, 29962, 13, 1678, 770, 8659, 353, 736, 1440, 29961, 29896, 29962, 13, 13, 1678, 13449, 353, 518, 1990, 8659, 29961, 524, 29898, 29888, 4638, 363, 285, 297, 13449, 2568, 29962, 13, 1678, 313, 344, 3174, 29892, 4413, 29897, 353, 263, 29903, 29889, 15764, 29906, 344, 3174, 29898, 15764, 29892, 29871, 29896, 29897, 13, 13, 1678, 363, 269, 297, 3464, 29898, 2435, 29898, 344, 3174, 22164, 13, 4706, 269, 29887, 353, 2377, 29879, 29961, 29879, 29962, 13, 4706, 2923, 353, 938, 29898, 5311, 29961, 29896, 2314, 448, 938, 29898, 5311, 29961, 29900, 2314, 13, 4706, 565, 313, 5085, 1839, 8382, 2033, 1125, 13, 9651, 1596, 877, 25641, 29958, 29953, 29913, 448, 12365, 29958, 29953, 29913, 21313, 29901, 29958, 29953, 1800, 584, 6571, 2824, 4830, 29898, 5311, 29961, 29900, 1402, 269, 29887, 29961, 29896, 1402, 2923, 29892, 4413, 29961, 29879, 2314, 13, 4706, 590, 29918, 10199, 1860, 29889, 4397, 29898, 17669, 358, 29898, 524, 29898, 5311, 29961, 29900, 11724, 938, 29898, 5311, 29961, 29896, 11724, 851, 29898, 13203, 29961, 29879, 29962, 4961, 13, 13, 1678, 396, 5013, 5309, 322, 1661, 12032, 8857, 13, 1678, 2186, 29918, 1761, 353, 5159, 13, 1678, 17809, 29918, 1761, 353, 5159, 13, 13, 1678, 24611, 29918, 5464, 29918, 5965, 5309, 353, 4175, 29898, 2892, 921, 29901, 313, 29916, 29889, 12765, 6736, 938, 29898, 5085, 1839, 386, 12268, 25901, 322, 313, 29916, 29889, 1990, 2450, 1275, 376, 5464, 29899, 5965, 5309, 4968, 590, 29918, 10199, 1860, 29897, 13, 1678, 24611, 29918, 5464, 29918, 5965, 5309, 29889, 6605, 29898, 1989, 29922, 2892, 921, 29901, 921, 29889, 355, 29897, 13, 13, 1678, 24611, 29918, 5965, 5309, 353, 4175, 29898, 2892, 921, 29901, 921, 29889, 1990, 2450, 1275, 376, 5965, 5309, 613, 590, 29918, 10199, 1860, 29897, 13, 1678, 24611, 29918, 5965, 5309, 29889, 6605, 29898, 1989, 29922, 2892, 921, 29901, 921, 29889, 355, 29897, 13, 13, 1678, 24611, 29918, 5965, 5309, 29918, 2962, 353, 4175, 29898, 2892, 921, 29901, 313, 29916, 29889, 2962, 6736, 938, 29898, 5085, 1839, 26041, 8948, 29918, 5965, 5309, 29918, 2962, 2033, 8243, 24611, 29918, 5965, 5309, 29897, 13, 1678, 24611, 29918, 5965, 5309, 29918, 2962, 29889, 6605, 29898, 1989, 29922, 2892, 921, 29901, 921, 29889, 355, 29897, 13, 13, 1678, 24611, 29918, 5965, 5309, 29918, 355, 353, 4175, 29898, 2892, 921, 29901, 313, 29916, 29889, 355, 5277, 14385, 448, 938, 29898, 5085, 1839, 386, 12268, 29918, 5965, 5309, 29918, 355, 2033, 8243, 24611, 29918, 5965, 5309, 29897, 13, 1678, 24611, 29918, 5965, 5309, 29918, 355, 29889, 6605, 29898, 1989, 29922, 2892, 921, 29901, 921, 29889, 355, 29897, 13, 13, 1678, 24611, 29918, 5965, 5309, 29918, 1509, 519, 353, 4175, 29898, 2892, 921, 29901, 313, 29916, 29889, 2962, 6736, 938, 29898, 5085, 1839, 26041, 8948, 29918, 5965, 5309, 29918, 2962, 25901, 322, 313, 29916, 29889, 355, 5277, 14385, 448, 938, 29898, 5085, 1839, 386, 12268, 29918, 5965, 5309, 29918, 355, 2033, 8243, 24611, 29918, 5965, 5309, 29897, 13, 1678, 24611, 29918, 5965, 5309, 29918, 1509, 519, 29889, 6605, 29898, 1989, 29922, 2892, 921, 29901, 921, 29889, 355, 29897, 13, 13, 1678, 565, 7431, 29898, 10199, 1860, 29918, 5965, 5309, 29897, 1405, 29871, 29900, 29901, 13, 4706, 565, 313, 5085, 1839, 8382, 2033, 1125, 13, 9651, 1596, 877, 11940, 6571, 24611, 29892, 12032, 6571, 320, 29876, 4286, 4830, 29898, 2435, 29898, 1357, 29918, 10199, 1860, 511, 7431, 29898, 10199, 1860, 29918, 5965, 5309, 4961, 13, 13, 4706, 396, 2322, 1369, 29914, 355, 408, 17809, 1728, 16897, 1423, 13, 4706, 17809, 29918, 1761, 29889, 4397, 29898, 10199, 1860, 29918, 5965, 5309, 29961, 29900, 1822, 2962, 29897, 13, 4706, 17809, 29918, 1761, 29889, 4397, 29898, 10199, 1860, 29918, 5965, 5309, 14352, 29896, 1822, 355, 29897, 13, 4706, 363, 274, 297, 24611, 29918, 5464, 29918, 5965, 5309, 29901, 13, 9651, 565, 313, 5085, 1839, 8382, 2033, 1125, 13, 18884, 1596, 877, 25641, 29958, 29953, 29913, 448, 12365, 29958, 29953, 29913, 21313, 29901, 29958, 29953, 1800, 584, 6571, 2824, 4830, 29898, 29883, 29889, 2962, 29892, 274, 29889, 355, 29892, 274, 29889, 12765, 29892, 274, 29889, 1990, 2450, 29897, 13, 9651, 2186, 29918, 1761, 29889, 4397, 29898, 29883, 29889, 2962, 29897, 13, 9651, 17809, 29918, 1761, 29889, 4397, 29898, 29883, 29889, 2962, 29897, 13, 13, 9651, 13128, 29918, 28192, 353, 4175, 29898, 2892, 921, 29901, 921, 29889, 2962, 1275, 274, 29889, 355, 29892, 24611, 29918, 5965, 5309, 29897, 13, 9651, 565, 313, 2435, 29898, 7050, 29918, 28192, 29897, 1405, 29871, 29896, 1125, 13, 18884, 396, 2158, 28909, 29873, 25641, 29958, 29953, 29913, 448, 12365, 29958, 29953, 29913, 21313, 29901, 29958, 29953, 1800, 584, 6571, 2824, 4830, 29898, 7050, 29918, 28192, 29889, 2962, 29892, 13128, 29918, 28192, 29889, 355, 29892, 13128, 29918, 28192, 29889, 12765, 29892, 13128, 29918, 28192, 29889, 1990, 2450, 29897, 13, 18884, 1596, 29898, 7050, 29918, 28192, 29897, 13, 13, 9651, 2186, 29918, 1761, 29889, 4397, 29898, 29883, 29889, 355, 29897, 13, 9651, 17809, 29918, 1761, 29889, 4397, 29898, 29883, 29889, 355, 29897, 13, 13, 4706, 565, 313, 2435, 29898, 10199, 1860, 29918, 5965, 5309, 29918, 2962, 29897, 1405, 29871, 29896, 1125, 13, 9651, 2186, 29918, 1761, 29889, 4397, 29898, 10199, 1860, 29918, 5965, 5309, 29918, 2962, 29961, 29900, 1822, 2962, 718, 938, 29898, 5085, 1839, 328, 5143, 29918, 5965, 5309, 29918, 2962, 25901, 13, 9651, 565, 313, 5085, 1839, 8382, 2033, 1125, 13, 18884, 1596, 28909, 29876, 29989, 25641, 29958, 29953, 11079, 25641, 29958, 29953, 11079, 25641, 29958, 29953, 29913, 7370, 4286, 4830, 29898, 10199, 1860, 29918, 5965, 5309, 29918, 2962, 29961, 29900, 1822, 2962, 29892, 6389, 1839, 328, 5143, 29918, 5965, 5309, 29918, 2962, 7464, 24611, 29918, 5965, 5309, 29918, 2962, 29961, 29900, 1822, 2962, 718, 6389, 1839, 328, 5143, 29918, 5965, 5309, 29918, 2962, 25901, 13, 4706, 1683, 29901, 13, 9651, 2186, 29918, 1761, 29889, 4397, 29898, 524, 29898, 5085, 1839, 9040, 29918, 2962, 25901, 13, 9651, 4469, 29918, 15450, 353, 29871, 29900, 396, 1369, 338, 472, 29871, 29900, 448, 4319, 1369, 13, 13, 4706, 565, 313, 2435, 29898, 10199, 1860, 29918, 5965, 5309, 29918, 355, 29897, 1405, 29871, 29896, 1125, 13, 9651, 2186, 29918, 1761, 29889, 4397, 29898, 10199, 1860, 29918, 5965, 5309, 29918, 355, 14352, 29896, 1822, 355, 718, 938, 29898, 5085, 1839, 328, 5143, 29918, 5965, 5309, 29918, 355, 25901, 13, 9651, 565, 313, 5085, 1839, 8382, 2033, 1125, 13, 18884, 1596, 877, 29989, 25641, 29958, 29953, 11079, 25641, 29958, 29953, 11079, 25641, 29958, 29953, 29913, 2796, 4286, 4830, 29898, 10199, 1860, 29918, 5965, 5309, 29918, 355, 14352, 29896, 1822, 355, 29892, 6389, 1839, 328, 5143, 29918, 5965, 5309, 29918, 355, 7464, 24611, 29918, 5965, 5309, 29918, 355, 14352, 29896, 1822, 2962, 718, 6389, 1839, 328, 5143, 29918, 5965, 5309, 29918, 355, 25901, 13, 4706, 1683, 29901, 13, 9651, 2186, 29918, 1761, 29889, 4397, 29898, 19708, 29897, 13, 9651, 4469, 29918, 15450, 353, 29871, 29900, 396, 1095, 338, 3309, 310, 16867, 448, 4319, 1095, 13, 13, 4706, 396, 3349, 20955, 13, 4706, 17809, 29918, 1761, 353, 731, 29898, 4801, 26458, 29918, 1761, 29897, 13, 4706, 17809, 29918, 1761, 353, 1051, 29898, 4801, 26458, 29918, 1761, 29897, 13, 4706, 17809, 29918, 1761, 29889, 6605, 580, 13, 13, 4706, 2186, 29918, 1761, 353, 731, 29898, 8394, 29918, 1761, 29897, 13, 4706, 2186, 29918, 1761, 353, 1051, 29898, 8394, 29918, 1761, 29897, 13, 4706, 2186, 29918, 1761, 29889, 6605, 580, 13, 13, 4706, 565, 313, 8394, 29918, 1761, 29961, 29900, 29962, 5277, 29871, 29900, 1125, 13, 9651, 2186, 29918, 1761, 29961, 29900, 29962, 353, 938, 29898, 5085, 1839, 9040, 29918, 2962, 11287, 13, 9651, 4469, 29918, 15450, 353, 29871, 29900, 396, 1369, 338, 472, 29871, 29900, 448, 4319, 1369, 13, 13, 4706, 565, 313, 8394, 29918, 1761, 14352, 29896, 29962, 1405, 14385, 1125, 13, 9651, 2186, 29918, 1761, 14352, 29896, 29962, 353, 14385, 13, 9651, 4469, 29918, 15450, 353, 29871, 29900, 396, 1095, 338, 3309, 310, 16867, 448, 4319, 1095, 13, 13, 4706, 565, 313, 5085, 1839, 8382, 2033, 1125, 13, 9651, 1596, 28909, 29876, 1495, 13, 9651, 1596, 29898, 4801, 26458, 29918, 1761, 29897, 13, 9651, 1596, 29898, 8394, 29918, 1761, 29897, 13, 13, 4706, 22663, 353, 426, 13, 9651, 525, 2435, 2396, 7431, 29898, 1357, 29918, 10199, 1860, 511, 13, 9651, 525, 18721, 2396, 10348, 29918, 15450, 29918, 18721, 29892, 525, 19708, 2396, 10348, 29918, 15450, 29918, 19708, 29892, 13, 9651, 525, 5965, 5309, 29918, 1217, 2396, 7431, 29898, 10199, 1860, 29918, 5965, 5309, 511, 525, 5965, 5309, 29918, 1516, 2396, 2533, 29898, 29883, 29889, 12765, 363, 274, 297, 24611, 29918, 5965, 5309, 511, 13, 9651, 525, 29876, 787, 412, 5309, 29918, 1217, 2396, 7431, 29898, 10199, 1860, 29918, 5464, 29918, 5965, 5309, 511, 525, 29876, 787, 412, 5309, 29918, 1516, 2396, 2533, 29898, 29883, 29889, 12765, 363, 274, 297, 24611, 29918, 5464, 29918, 5965, 5309, 511, 13, 9651, 525, 29876, 787, 412, 5309, 29918, 3880, 29918, 1217, 2396, 7431, 29898, 10199, 1860, 29918, 5965, 5309, 29918, 1509, 519, 511, 525, 29876, 787, 412, 5309, 29918, 3880, 29918, 1516, 2396, 2533, 29898, 29883, 29889, 12765, 363, 274, 297, 24611, 29918, 5965, 5309, 29918, 1509, 519, 29897, 13, 4706, 500, 13, 13, 4706, 396, 937, 10768, 338, 2337, 263, 921, 694, 310, 6923, 515, 278, 1369, 856, 13, 4706, 565, 313, 8394, 29918, 1761, 29961, 29900, 29962, 1275, 29871, 29900, 1125, 13, 9651, 2186, 29918, 1761, 29961, 29900, 29962, 353, 6389, 1839, 9040, 29918, 2962, 2033, 13, 9651, 22663, 1839, 16773, 29918, 2962, 2033, 353, 29871, 29900, 13, 9651, 4469, 29918, 15450, 353, 29871, 29900, 396, 1369, 338, 472, 29871, 29900, 448, 4319, 1369, 13, 4706, 1683, 29901, 13, 9651, 22663, 1839, 16773, 29918, 2962, 2033, 353, 2186, 29918, 1761, 29961, 29900, 29962, 529, 6389, 1839, 16773, 29918, 2962, 2033, 13, 13, 4706, 565, 313, 8394, 29918, 1761, 14352, 29896, 29962, 1275, 14385, 1125, 13, 9651, 2186, 29918, 1761, 14352, 29896, 29962, 353, 14385, 448, 6389, 1839, 9040, 29918, 355, 2033, 13, 9651, 22663, 1839, 16773, 29918, 355, 2033, 353, 29871, 29900, 13, 9651, 4469, 29918, 15450, 353, 29871, 29900, 396, 1095, 338, 3309, 310, 16867, 448, 4319, 1095, 13, 4706, 1683, 29901, 13, 9651, 22663, 1839, 16773, 29918, 355, 2033, 353, 2186, 29918, 1761, 14352, 29896, 29962, 718, 6389, 1839, 16773, 29918, 355, 2033, 1405, 938, 29898, 18494, 29918, 15450, 29918, 19708, 847, 29871, 29896, 29900, 29900, 29900, 29897, 13, 13, 4706, 2186, 29918, 1761, 353, 2910, 29898, 2892, 921, 29901, 921, 334, 29871, 29896, 29900, 29900, 29900, 29892, 2186, 29918, 1761, 29897, 13, 13, 4706, 1121, 353, 6629, 13, 4706, 270, 353, 17411, 29915, 13, 4706, 363, 321, 297, 2186, 29918, 1761, 29901, 13, 9651, 1121, 353, 1121, 718, 851, 29898, 29872, 29897, 718, 270, 13, 9651, 565, 313, 29881, 1275, 17411, 29374, 13, 18884, 270, 353, 21921, 29915, 13, 9651, 1683, 29901, 13, 18884, 270, 353, 17411, 29915, 13, 13, 4706, 565, 313, 5085, 1839, 8382, 2033, 1125, 13, 9651, 1596, 29898, 16202, 29897, 13, 9651, 1596, 877, 4299, 1170, 29901, 6571, 4286, 4830, 29898, 4299, 1170, 876, 13, 9651, 1596, 877, 18494, 29918, 15450, 29918, 1300, 327, 5632, 3790, 29913, 4286, 4830, 703, 3009, 29908, 565, 5135, 16202, 1839, 18721, 2033, 1275, 29871, 29896, 29897, 322, 313, 16202, 1839, 29876, 787, 412, 5309, 29918, 3880, 29918, 1217, 2033, 1275, 29871, 29900, 29897, 322, 22663, 1839, 16773, 29918, 2962, 2033, 322, 22663, 1839, 16773, 29918, 355, 11287, 1683, 376, 4541, 5783, 13, 9651, 1596, 29898, 2914, 29897, 13, 13, 4706, 285, 353, 1722, 29898, 5085, 1839, 4905, 1626, 2283, 7464, 525, 29893, 1495, 13, 4706, 396, 29888, 29889, 3539, 877, 18494, 29918, 15450, 29918, 1445, 2433, 718, 6389, 1839, 2080, 29956, 485, 2283, 2033, 718, 12764, 29876, 1495, 13, 4706, 396, 29888, 29889, 3539, 877, 18494, 29918, 15450, 29918, 449, 29918, 1445, 2433, 718, 6389, 1839, 4905, 1626, 2283, 2033, 718, 12764, 29876, 1495, 13, 4706, 285, 29889, 3539, 877, 18494, 29918, 15450, 29918, 19708, 3790, 1012, 29876, 4286, 4830, 29898, 16202, 1839, 19708, 25901, 13, 4706, 285, 29889, 3539, 877, 18494, 29918, 15450, 29918, 1300, 327, 5632, 3790, 1012, 29876, 4286, 4830, 703, 3009, 29908, 565, 5135, 16202, 1839, 18721, 2033, 1275, 29871, 29896, 29897, 322, 313, 16202, 1839, 29876, 787, 412, 5309, 29918, 3880, 29918, 1217, 2033, 1275, 29871, 29900, 29897, 322, 22663, 1839, 16773, 29918, 2962, 2033, 322, 22663, 1839, 16773, 29918, 355, 11287, 1683, 376, 4541, 5783, 13, 4706, 285, 29889, 3539, 877, 18494, 29918, 15450, 29918, 728, 473, 3790, 1012, 29876, 4286, 4830, 703, 3009, 29908, 565, 313, 16202, 1839, 18721, 2033, 1275, 29871, 29896, 29897, 1683, 376, 4541, 5783, 13, 4706, 285, 29889, 3539, 877, 18494, 29918, 15450, 29918, 16773, 29918, 2962, 3790, 1012, 29876, 4286, 4830, 703, 3009, 29908, 565, 313, 16202, 1839, 16773, 29918, 2962, 11287, 1683, 376, 4541, 5783, 13, 4706, 285, 29889, 3539, 877, 18494, 29918, 15450, 29918, 16773, 29918, 355, 3790, 1012, 29876, 4286, 4830, 703, 3009, 29908, 565, 313, 16202, 1839, 16773, 29918, 355, 11287, 1683, 376, 4541, 5783, 13, 4706, 285, 29889, 3539, 877, 18494, 29918, 15450, 29918, 4801, 26458, 3790, 1012, 29876, 4286, 4830, 877, 29899, 4286, 7122, 29898, 710, 29898, 29916, 29897, 363, 921, 297, 17809, 29918, 1761, 4961, 13, 4706, 285, 29889, 3539, 877, 18494, 29918, 15450, 29918, 10199, 1860, 3790, 1012, 29876, 4286, 4830, 29898, 2914, 876, 13, 4706, 285, 29889, 3539, 877, 18494, 29918, 15450, 29918, 10199, 1860, 29918, 2435, 3790, 1012, 29876, 4286, 4830, 29898, 16202, 1839, 2435, 25901, 13, 4706, 285, 29889, 3539, 877, 18494, 29918, 15450, 29918, 10199, 1860, 29918, 5965, 5309, 3790, 1012, 29876, 4286, 4830, 29898, 16202, 1839, 5965, 5309, 29918, 1217, 25901, 13, 4706, 285, 29889, 3539, 877, 18494, 29918, 15450, 29918, 10199, 1860, 29918, 5965, 5309, 29918, 1516, 3790, 1012, 29876, 4286, 4830, 29898, 524, 29898, 16202, 1839, 5965, 5309, 29918, 1516, 11287, 334, 29871, 29896, 29900, 29900, 29900, 876, 13, 4706, 285, 29889, 3539, 877, 18494, 29918, 15450, 29918, 10199, 1860, 29918, 1333, 5965, 5309, 3790, 1012, 29876, 4286, 4830, 29898, 16202, 1839, 29876, 787, 412, 5309, 29918, 1217, 25901, 13, 4706, 285, 29889, 3539, 877, 18494, 29918, 15450, 29918, 10199, 1860, 29918, 1333, 5965, 5309, 29918, 1516, 3790, 1012, 29876, 4286, 4830, 29898, 524, 29898, 16202, 1839, 29876, 787, 412, 5309, 29918, 1516, 11287, 334, 29871, 29896, 29900, 29900, 29900, 876, 13, 4706, 285, 29889, 3539, 877, 18494, 29918, 15450, 29918, 10199, 1860, 29918, 1333, 5965, 5309, 29918, 3880, 3790, 1012, 29876, 4286, 4830, 29898, 16202, 1839, 29876, 787, 412, 5309, 29918, 3880, 29918, 1217, 25901, 13, 4706, 285, 29889, 3539, 877, 18494, 29918, 15450, 29918, 10199, 1860, 29918, 1333, 5965, 5309, 29918, 3880, 29918, 1516, 3790, 1012, 29876, 4286, 4830, 29898, 524, 29898, 16202, 1839, 29876, 787, 412, 5309, 29918, 3880, 29918, 1516, 11287, 334, 29871, 29896, 29900, 29900, 29900, 876, 13, 4706, 285, 29889, 3539, 877, 18494, 29918, 15450, 29918, 386, 12268, 3790, 6177, 29912, 3400, 29912, 1012, 29876, 4286, 4830, 29898, 5085, 1839, 26041, 8948, 29918, 5965, 5309, 29918, 2962, 7464, 6389, 1839, 386, 12268, 29918, 5965, 5309, 29918, 355, 7464, 6389, 1839, 386, 12268, 25901, 13, 4706, 285, 29889, 3539, 877, 18494, 29918, 15450, 29918, 328, 5143, 3790, 6177, 29912, 1012, 29876, 4286, 4830, 29898, 5085, 1839, 328, 5143, 29918, 5965, 5309, 29918, 2962, 7464, 6389, 1839, 328, 5143, 29918, 5965, 5309, 29918, 355, 25901, 13, 4706, 285, 29889, 3539, 877, 18494, 29918, 15450, 29918, 9040, 3790, 6177, 29912, 1012, 29876, 4286, 4830, 29898, 5085, 1839, 9040, 29918, 2962, 7464, 6389, 1839, 9040, 29918, 355, 25901, 13, 4706, 285, 29889, 3539, 877, 18494, 29918, 15450, 29918, 16773, 3790, 6177, 29912, 1012, 29876, 4286, 4830, 29898, 5085, 1839, 16773, 29918, 2962, 7464, 6389, 1839, 16773, 29918, 355, 25901, 13, 4706, 285, 29889, 3539, 877, 18494, 29918, 15450, 29918, 4299, 3790, 1012, 29876, 4286, 4830, 29898, 4299, 1170, 29889, 6506, 11974, 3284, 27508, 4961, 13, 4706, 285, 29889, 3539, 877, 18494, 29918, 15450, 29918, 6984, 295, 3790, 1012, 29876, 4286, 4830, 703, 3009, 29908, 565, 4852, 3782, 29931, 481, 295, 29908, 451, 297, 1904, 1170, 29897, 1683, 376, 4541, 5783, 13, 4706, 285, 29889, 3539, 877, 18494, 29918, 15450, 29918, 4258, 29918, 2230, 3790, 3400, 29912, 1012, 29876, 4286, 4830, 29898, 14486, 29898, 4299, 29918, 2230, 29892, 29871, 29941, 511, 4513, 29898, 2230, 29889, 2230, 580, 448, 1369, 29918, 2230, 29892, 29871, 29941, 4961, 13, 4706, 285, 29889, 5358, 580, 13, 1678, 1683, 29901, 13, 4706, 13905, 8915, 6466, 29898, 5085, 1839, 4905, 1626, 2283, 7464, 10348, 29918, 15450, 29918, 19708, 29892, 4513, 29898, 2230, 29889, 2230, 580, 448, 1369, 29918, 2230, 29892, 29871, 29941, 876, 13, 2870, 29901, 13, 1678, 13905, 8915, 6466, 29898, 5085, 1839, 4905, 1626, 2283, 7464, 10348, 29918, 15450, 29918, 19708, 29892, 4513, 29898, 2230, 29889, 2230, 580, 448, 1369, 29918, 2230, 29892, 29871, 29941, 876, 13, 13, 13, 9675, 29889, 13322, 29898, 359, 29889, 5746, 29918, 8949, 29897, 396, 775, 29871, 29900, 29892, 599, 3431, 13, 2 ]
demo/__main__.py
Dralan1912/HAICOR-demo
0
74926
# Copyright (c) 2020 <NAME> # # This software is released under the MIT License. # https://opensource.org/licenses/MIT from __future__ import annotations import argparse import csv import gzip import json import os import re import sqlite3 as sqlite from .app import database, APP_DIRECTORY from .models.assertions import Assertion, Dataset, License, Relation, Source from .models.concepts import Concept, Language, PartOfSpeech parser = argparse.ArgumentParser() parser.add_argument("conceptnet", action="store", type=str, help="Compiled ConceptNet assertions file (csv.gz)") parser.add_argument("description", action="store", type=str, help="Directory containing the description files (csv)") parser.add_argument("--commit-size", action="store", type=int, default=1000, help="The batch size of the database commit") INITIALIZATION_SQL = os.path.join(APP_DIRECTORY, "initialization.sql") TRANSFORMATION_SQL = os.path.join(APP_DIRECTORY, "transformation.sql") ENGLISH_REGEX = re.compile(r"^/a/\[/r/.+/,/c/en/.+/,/c/en/.+/\]$") CONCEPT_REGEX = re.compile(r"^/c/([^/]+)/([^/]+)/?([^/]+)?/?(.+)?$") if __name__ == "__main__": args = parser.parse_args() LANGUAGE = os.path.join(args.description, "languages.csv") RELATION = os.path.join(args.description, "relations.csv") PART_OF_SPEECH = os.path.join(args.description, "part-of-speeches.csv") # process data using in-memory database with sqlite.connect(":memory:") as temp_database: temp_database.row_factory = sqlite.Row cursor = temp_database.cursor() with open(INITIALIZATION_SQL, "r") as script: cursor.executescript(script.read()) temp_database.commit() with open(LANGUAGE, "r") as file: for language in csv.reader(file): cursor.execute( "INSERT INTO languages(code, name) VALUES(?,?)", language ) with open(RELATION, "r") as file: for relation, directed in csv.reader(file): cursor.execute( "INSERT INTO relations(relation, directed) VALUES(?,?)", (relation, directed == "directed") ) with open(PART_OF_SPEECH, "r") as file: for part_of_speech in csv.reader(file): cursor.execute( "INSERT INTO part_of_speeches(code, name) VALUES(?,?)", part_of_speech ) temp_database.commit() with gzip.open(args.conceptnet, "rt") as conceptnet: reader = csv.reader(conceptnet, delimiter='\t') filtered = filter(lambda x: re.match(ENGLISH_REGEX, x[0]), reader) for id, assertion in enumerate(filtered): print(f"{id + 1} English assertions processed", end='\r') assertion, relation, source, target, data = assertion if relation == "/r/ExternalURL": continue data = json.loads(data) cursor.execute( "INSERT INTO assertions VALUES(" + "?," * 18 + "?)", (id + 1, assertion, relation[3:], source, *re.match(CONCEPT_REGEX, source).groups(), target, *re.match(CONCEPT_REGEX, target).groups(), data["dataset"][3:], data["license"], data["weight"], data["surfaceText"] if "surfaceText" in data else None, data["surfaceStart"] if "surfaceStart" in data else None, data["surfaceEnd"] if "surfaceEnd" in data else None) ) for index, source in enumerate(data["sources"]): for field, value in source.items(): cursor.execute( ("INSERT INTO sources" "(assertion_id, [index], field, value) " "VALUES(?,?,?,?)"), (id + 1, index + 1, field, value) ) print() temp_database.commit() with open(TRANSFORMATION_SQL, "r") as script: cursor.executescript(script.read()) temp_database.commit() # populate app database database.drop_all() database.create_all() for r in cursor.execute("SELECT * FROM languages"): database.session.add(Language(**r)) for r in cursor.execute("SELECT * FROM relations"): database.session.add(Relation(**r)) for r in cursor.execute("SELECT * FROM part_of_speeches"): database.session.add(PartOfSpeech(**r)) for r in cursor.execute("SELECT * FROM datasets"): database.session.add(Dataset(**r)) for r in cursor.execute("SELECT * FROM licenses"): database.session.add(License(**r)) for i, r in enumerate(cursor.execute("SELECT * FROM concepts")): print(f"{i + 1} concepts inserted", end='\r') database.session.add(Concept(**r)) if (i + 1) % args.commit_size == 0: database.session.commit() print() for i, r in enumerate(cursor.execute("SELECT * FROM assertions")): print(f"{i + 1} assertions inserted", end='\r') database.session.add(Assertion(**r)) if (i + 1) % args.commit_size == 0: database.session.commit() print() for i, r in enumerate(cursor.execute("SELECT * FROM sources")): print(f"{i + 1} assertion source inserted", end='\r') database.session.add(Source(**r)) if (i + 1) % args.commit_size == 0: database.session.commit() print() database.session.commit()
[ 1, 396, 14187, 1266, 313, 29883, 29897, 29871, 29906, 29900, 29906, 29900, 529, 5813, 29958, 13, 29937, 13, 29937, 910, 7047, 338, 5492, 1090, 278, 341, 1806, 19245, 29889, 13, 29937, 2045, 597, 22156, 1167, 29889, 990, 29914, 506, 11259, 29914, 26349, 13, 13, 3166, 4770, 29888, 9130, 1649, 1053, 25495, 13, 13, 5215, 1852, 5510, 13, 5215, 11799, 13, 5215, 330, 7554, 13, 5215, 4390, 13, 5215, 2897, 13, 5215, 337, 13, 5215, 21120, 29941, 408, 21120, 13, 13, 3166, 869, 932, 1053, 2566, 29892, 12279, 29925, 29918, 4571, 26282, 18929, 13, 3166, 869, 9794, 29889, 9294, 1080, 1053, 16499, 291, 29892, 13373, 24541, 29892, 19245, 29892, 6376, 362, 29892, 7562, 13, 3166, 869, 9794, 29889, 535, 1547, 29879, 1053, 1281, 1547, 29892, 17088, 29892, 3455, 2776, 10649, 5309, 13, 13, 16680, 353, 1852, 5510, 29889, 15730, 11726, 580, 13, 13, 13, 16680, 29889, 1202, 29918, 23516, 703, 535, 1547, 1212, 613, 3158, 543, 8899, 613, 1134, 29922, 710, 29892, 13, 462, 1678, 1371, 543, 6843, 2356, 1281, 1547, 6779, 4974, 1080, 934, 313, 7638, 29889, 18828, 25760, 13, 16680, 29889, 1202, 29918, 23516, 703, 8216, 613, 3158, 543, 8899, 613, 1134, 29922, 710, 29892, 13, 462, 1678, 1371, 543, 9882, 6943, 278, 6139, 2066, 313, 7638, 25760, 13, 16680, 29889, 1202, 29918, 23516, 703, 489, 15060, 29899, 2311, 613, 3158, 543, 8899, 613, 1134, 29922, 524, 29892, 2322, 29922, 29896, 29900, 29900, 29900, 29892, 13, 462, 1678, 1371, 543, 1576, 9853, 2159, 310, 278, 2566, 9063, 1159, 13, 13, 26019, 25758, 26664, 8098, 29918, 4176, 353, 2897, 29889, 2084, 29889, 7122, 29898, 20576, 29918, 4571, 26282, 18929, 29892, 376, 11228, 2133, 29889, 2850, 1159, 13, 26813, 29903, 19094, 8098, 29918, 4176, 353, 2897, 29889, 2084, 29889, 7122, 29898, 20576, 29918, 4571, 26282, 18929, 29892, 376, 3286, 5404, 29889, 2850, 1159, 13, 13, 1430, 7239, 3235, 29950, 29918, 1525, 1692, 29990, 353, 337, 29889, 12198, 29898, 29878, 29908, 29985, 29914, 29874, 7998, 29961, 29914, 29878, 6294, 29974, 19637, 29914, 29883, 29914, 264, 6294, 29974, 19637, 29914, 29883, 29914, 264, 6294, 29974, 7998, 9341, 1159, 13, 6007, 4741, 7982, 29918, 1525, 1692, 29990, 353, 337, 29889, 12198, 29898, 29878, 29908, 29985, 29914, 29883, 29914, 4197, 29985, 29914, 10062, 6802, 4197, 29985, 29914, 10062, 6802, 29973, 4197, 29985, 29914, 10062, 6877, 13401, 11891, 29974, 6877, 29938, 1159, 13, 13, 361, 4770, 978, 1649, 1275, 376, 1649, 3396, 1649, 1115, 13, 1678, 6389, 353, 13812, 29889, 5510, 29918, 5085, 580, 13, 13, 1678, 365, 19453, 29965, 10461, 353, 2897, 29889, 2084, 29889, 7122, 29898, 5085, 29889, 8216, 29892, 376, 29880, 8737, 29889, 7638, 1159, 13, 1678, 5195, 29931, 8098, 353, 2897, 29889, 2084, 29889, 7122, 29898, 5085, 29889, 8216, 29892, 376, 2674, 800, 29889, 7638, 1159, 13, 1678, 349, 8322, 29918, 9800, 29918, 29903, 4162, 29923, 3210, 353, 2897, 29889, 2084, 29889, 7122, 29898, 5085, 29889, 8216, 29892, 376, 1595, 29899, 974, 29899, 5965, 5309, 267, 29889, 7638, 1159, 13, 13, 1678, 396, 1889, 848, 773, 297, 29899, 14834, 2566, 13, 1678, 411, 21120, 29889, 6915, 703, 29901, 14834, 29901, 1159, 408, 5694, 29918, 9803, 29901, 13, 4706, 5694, 29918, 9803, 29889, 798, 29918, 14399, 353, 21120, 29889, 4301, 13, 4706, 10677, 353, 5694, 29918, 9803, 29889, 18127, 580, 13, 13, 4706, 411, 1722, 29898, 26019, 25758, 26664, 8098, 29918, 4176, 29892, 376, 29878, 1159, 408, 2471, 29901, 13, 9651, 10677, 29889, 4258, 2667, 924, 29898, 2154, 29889, 949, 3101, 13, 9651, 5694, 29918, 9803, 29889, 15060, 580, 13, 13, 4706, 411, 1722, 29898, 29931, 19453, 29965, 10461, 29892, 376, 29878, 1159, 408, 934, 29901, 13, 9651, 363, 4086, 297, 11799, 29889, 16950, 29898, 1445, 1125, 13, 18884, 10677, 29889, 7978, 29898, 13, 462, 1678, 376, 19460, 11646, 10276, 29898, 401, 29892, 1024, 29897, 15673, 10780, 29892, 7897, 613, 13, 462, 1678, 4086, 13, 18884, 1723, 13, 13, 4706, 411, 1722, 29898, 1525, 29931, 8098, 29892, 376, 29878, 1159, 408, 934, 29901, 13, 9651, 363, 8220, 29892, 10624, 297, 11799, 29889, 16950, 29898, 1445, 1125, 13, 18884, 10677, 29889, 7978, 29898, 13, 462, 1678, 376, 19460, 11646, 5302, 29898, 23445, 29892, 10624, 29897, 15673, 10780, 29892, 7897, 613, 13, 462, 1678, 313, 23445, 29892, 10624, 1275, 376, 11851, 287, 1159, 13, 18884, 1723, 13, 13, 4706, 411, 1722, 29898, 26092, 29918, 9800, 29918, 29903, 4162, 29923, 3210, 29892, 376, 29878, 1159, 408, 934, 29901, 13, 9651, 363, 760, 29918, 974, 29918, 5965, 5309, 297, 11799, 29889, 16950, 29898, 1445, 1125, 13, 18884, 10677, 29889, 7978, 29898, 13, 462, 1678, 376, 19460, 11646, 760, 29918, 974, 29918, 5965, 5309, 267, 29898, 401, 29892, 1024, 29897, 15673, 10780, 29892, 7897, 613, 13, 462, 1678, 760, 29918, 974, 29918, 5965, 5309, 13, 18884, 1723, 13, 13, 4706, 5694, 29918, 9803, 29889, 15060, 580, 13, 13, 4706, 411, 330, 7554, 29889, 3150, 29898, 5085, 29889, 535, 1547, 1212, 29892, 376, 2273, 1159, 408, 6964, 1212, 29901, 13, 9651, 9591, 353, 11799, 29889, 16950, 29898, 535, 1547, 1212, 29892, 28552, 2433, 29905, 29873, 1495, 13, 9651, 22289, 353, 4175, 29898, 2892, 921, 29901, 337, 29889, 4352, 29898, 1430, 7239, 3235, 29950, 29918, 1525, 1692, 29990, 29892, 921, 29961, 29900, 11724, 9591, 29897, 13, 13, 9651, 363, 1178, 29892, 28306, 297, 26985, 29898, 4572, 287, 1125, 13, 18884, 1596, 29898, 29888, 29908, 29912, 333, 718, 29871, 29896, 29913, 4223, 4974, 1080, 19356, 613, 1095, 2433, 29905, 29878, 1495, 13, 13, 18884, 28306, 29892, 8220, 29892, 2752, 29892, 3646, 29892, 848, 353, 28306, 13, 13, 18884, 565, 8220, 1275, 5591, 29878, 29914, 25865, 4219, 1115, 13, 462, 1678, 6773, 13, 13, 18884, 848, 353, 4390, 29889, 18132, 29898, 1272, 29897, 13, 13, 18884, 10677, 29889, 7978, 29898, 13, 462, 1678, 376, 19460, 11646, 4974, 1080, 15673, 703, 718, 376, 29973, 1699, 334, 29871, 29896, 29947, 718, 376, 7897, 613, 13, 462, 1678, 313, 333, 718, 29871, 29896, 29892, 28306, 29892, 8220, 29961, 29941, 29901, 1402, 13, 462, 268, 2752, 29892, 334, 276, 29889, 4352, 29898, 6007, 4741, 7982, 29918, 1525, 1692, 29990, 29892, 2752, 467, 13155, 3285, 13, 462, 268, 3646, 29892, 334, 276, 29889, 4352, 29898, 6007, 4741, 7982, 29918, 1525, 1692, 29990, 29892, 3646, 467, 13155, 3285, 13, 462, 268, 848, 3366, 24713, 3108, 29961, 29941, 29901, 1402, 848, 3366, 506, 1947, 12436, 848, 3366, 7915, 12436, 13, 462, 268, 848, 3366, 7610, 2161, 1626, 3108, 565, 376, 7610, 2161, 1626, 29908, 297, 848, 1683, 6213, 29892, 13, 462, 268, 848, 3366, 7610, 2161, 4763, 3108, 565, 376, 7610, 2161, 4763, 29908, 297, 848, 1683, 6213, 29892, 13, 462, 268, 848, 3366, 7610, 2161, 5044, 3108, 565, 376, 7610, 2161, 5044, 29908, 297, 848, 1683, 6213, 29897, 13, 18884, 1723, 13, 13, 18884, 363, 2380, 29892, 2752, 297, 26985, 29898, 1272, 3366, 29879, 2863, 3108, 1125, 13, 462, 1678, 363, 1746, 29892, 995, 297, 2752, 29889, 7076, 7295, 13, 462, 4706, 10677, 29889, 7978, 29898, 13, 462, 9651, 4852, 19460, 11646, 8974, 29908, 13, 462, 632, 18227, 9294, 291, 29918, 333, 29892, 518, 2248, 1402, 1746, 29892, 995, 29897, 376, 13, 462, 632, 376, 8932, 12996, 10780, 29892, 14579, 14579, 7897, 4968, 13, 462, 9651, 313, 333, 718, 29871, 29896, 29892, 2380, 718, 29871, 29896, 29892, 1746, 29892, 995, 29897, 13, 462, 4706, 1723, 13, 13, 9651, 1596, 580, 13, 9651, 5694, 29918, 9803, 29889, 15060, 580, 13, 13, 4706, 411, 1722, 29898, 26813, 29903, 19094, 8098, 29918, 4176, 29892, 376, 29878, 1159, 408, 2471, 29901, 13, 9651, 10677, 29889, 4258, 2667, 924, 29898, 2154, 29889, 949, 3101, 13, 9651, 5694, 29918, 9803, 29889, 15060, 580, 13, 13, 4706, 396, 19450, 623, 2566, 13, 4706, 2566, 29889, 8865, 29918, 497, 580, 13, 4706, 2566, 29889, 3258, 29918, 497, 580, 13, 13, 4706, 363, 364, 297, 10677, 29889, 7978, 703, 6404, 334, 3895, 10276, 29908, 1125, 13, 9651, 2566, 29889, 7924, 29889, 1202, 29898, 21233, 29898, 1068, 29878, 876, 13, 13, 4706, 363, 364, 297, 10677, 29889, 7978, 703, 6404, 334, 3895, 5302, 29908, 1125, 13, 9651, 2566, 29889, 7924, 29889, 1202, 29898, 9662, 362, 29898, 1068, 29878, 876, 13, 13, 4706, 363, 364, 297, 10677, 29889, 7978, 703, 6404, 334, 3895, 760, 29918, 974, 29918, 5965, 5309, 267, 29908, 1125, 13, 9651, 2566, 29889, 7924, 29889, 1202, 29898, 7439, 2776, 10649, 5309, 29898, 1068, 29878, 876, 13, 13, 4706, 363, 364, 297, 10677, 29889, 7978, 703, 6404, 334, 3895, 20035, 29908, 1125, 13, 9651, 2566, 29889, 7924, 29889, 1202, 29898, 16390, 24541, 29898, 1068, 29878, 876, 13, 13, 4706, 363, 364, 297, 10677, 29889, 7978, 703, 6404, 334, 3895, 7794, 11259, 29908, 1125, 13, 9651, 2566, 29889, 7924, 29889, 1202, 29898, 29931, 293, 1947, 29898, 1068, 29878, 876, 13, 13, 4706, 363, 474, 29892, 364, 297, 26985, 29898, 18127, 29889, 7978, 703, 6404, 334, 3895, 22001, 5783, 29901, 13, 9651, 1596, 29898, 29888, 29908, 29912, 29875, 718, 29871, 29896, 29913, 22001, 15478, 613, 1095, 2433, 29905, 29878, 1495, 13, 9651, 2566, 29889, 7924, 29889, 1202, 29898, 1168, 1547, 29898, 1068, 29878, 876, 13, 13, 9651, 565, 313, 29875, 718, 29871, 29896, 29897, 1273, 6389, 29889, 15060, 29918, 2311, 1275, 29871, 29900, 29901, 13, 18884, 2566, 29889, 7924, 29889, 15060, 580, 13, 13, 4706, 1596, 580, 13, 13, 4706, 363, 474, 29892, 364, 297, 26985, 29898, 18127, 29889, 7978, 703, 6404, 334, 3895, 4974, 1080, 5783, 29901, 13, 9651, 1596, 29898, 29888, 29908, 29912, 29875, 718, 29871, 29896, 29913, 4974, 1080, 15478, 613, 1095, 2433, 29905, 29878, 1495, 13, 9651, 2566, 29889, 7924, 29889, 1202, 29898, 14697, 291, 29898, 1068, 29878, 876, 13, 13, 9651, 565, 313, 29875, 718, 29871, 29896, 29897, 1273, 6389, 29889, 15060, 29918, 2311, 1275, 29871, 29900, 29901, 13, 18884, 2566, 29889, 7924, 29889, 15060, 580, 13, 13, 4706, 1596, 580, 13, 13, 4706, 363, 474, 29892, 364, 297, 26985, 29898, 18127, 29889, 7978, 703, 6404, 334, 3895, 8974, 5783, 29901, 13, 9651, 1596, 29898, 29888, 29908, 29912, 29875, 718, 29871, 29896, 29913, 28306, 2752, 15478, 613, 1095, 2433, 29905, 29878, 1495, 13, 9651, 2566, 29889, 7924, 29889, 1202, 29898, 4435, 29898, 1068, 29878, 876, 13, 13, 9651, 565, 313, 29875, 718, 29871, 29896, 29897, 1273, 6389, 29889, 15060, 29918, 2311, 1275, 29871, 29900, 29901, 13, 18884, 2566, 29889, 7924, 29889, 15060, 580, 13, 13, 4706, 1596, 580, 13, 13, 4706, 2566, 29889, 7924, 29889, 15060, 580, 13, 2 ]
src/unicon/plugins/confd/csp/__init__.py
tahigash/unicon.plugins
1
936
__author__ = "<NAME> <<EMAIL>>" from unicon.plugins.confd import ConfdServiceList, ConfdConnection, ConfdConnectionProvider from .statemachine import CspStateMachine from .settings import CspSettings from . import service_implementation as csp_svc class CspServiceList(ConfdServiceList): def __init__(self): super().__init__() delattr(self, 'cli_style') self.reload = csp_svc.Reload class CspSingleRPConnection(ConfdConnection): os = 'confd' series = 'csp' chassis_type = 'single_rp' state_machine_class = CspStateMachine connection_provider_class = ConfdConnectionProvider subcommand_list = CspServiceList settings = CspSettings()
[ 1, 4770, 8921, 1649, 353, 9872, 5813, 29958, 3532, 26862, 6227, 6778, 29908, 13, 13, 13, 3166, 443, 4144, 29889, 12800, 29889, 5527, 29881, 1053, 10811, 29881, 3170, 1293, 29892, 10811, 29881, 5350, 29892, 10811, 29881, 5350, 6980, 13, 3166, 869, 6112, 331, 2945, 1053, 315, 1028, 2792, 29076, 13, 3166, 869, 11027, 1053, 315, 1028, 9585, 13, 3166, 869, 1053, 2669, 29918, 21382, 408, 274, 1028, 29918, 4501, 29883, 13, 13, 13, 1990, 315, 1028, 3170, 1293, 29898, 1168, 11512, 3170, 1293, 1125, 13, 1678, 822, 4770, 2344, 12035, 1311, 1125, 13, 4706, 2428, 2141, 1649, 2344, 1649, 580, 13, 4706, 628, 5552, 29898, 1311, 29892, 525, 11303, 29918, 3293, 1495, 13, 4706, 1583, 29889, 28120, 353, 274, 1028, 29918, 4501, 29883, 29889, 29934, 7078, 328, 13, 13, 13, 1990, 315, 1028, 15771, 29934, 29925, 5350, 29898, 1168, 11512, 5350, 1125, 13, 1678, 2897, 353, 525, 5527, 29881, 29915, 13, 1678, 3652, 353, 525, 29883, 1028, 29915, 13, 1678, 521, 465, 275, 29918, 1853, 353, 525, 14369, 29918, 19080, 29915, 13, 1678, 2106, 29918, 23523, 29918, 1990, 353, 315, 1028, 2792, 29076, 13, 1678, 3957, 29918, 18121, 29918, 1990, 353, 10811, 29881, 5350, 6980, 13, 1678, 1014, 6519, 29918, 1761, 353, 315, 1028, 3170, 1293, 13, 1678, 6055, 353, 315, 1028, 9585, 580, 13, 2 ]
nr_oai_pmh_harvester/rules/nusl/field998.py
Narodni-repozitar/oai-pmh-harvester
0
147562
from oarepo_oai_pmh_harvester.decorators import rule from oarepo_oai_pmh_harvester.transformer import OAITransformer from oarepo_taxonomies.utils import get_taxonomy_json @rule("nusl", "marcxml", "/998__/a", phase="pre") def call_provider(el, **kwargs): return provider(el, **kwargs) # pragma: no cover def provider(el, **kwargs): slug = provider_mapping().get(el) if not slug: # pragma: no cover return OAITransformer.PROCESSED return { "_administration": { "state": "new", "primaryCommunity": slug, "communities": [] }, "provider": get_taxonomy_json(code="institutions", slug=slug).paginated_data } def provider_mapping(): return { "agritec": "agritec", "agrotest_fyto": "agrotest_fyto", "akademie_muzickych_umeni_v_praze": "amu", "akademie_vytvarnych_umeni": "avu", "archeologicky_ustav_brno": "arub_cas", "archeologicky_ustav_praha": "arup_cas", "archip": "archip", "archiv_ing_arch_jana_moucky": "j_moucka", "archiv_doc_jiri_soucek": "j_soucek", "arnika": "arnika", "astronomicky_ustav": "asu_cas", "biofyzikalni_ustav": "bfu_cas", "biologicke_centrum": "bc_cas", "biotechnologicky_ustav": "ibt_cas", "botanicky_ustav": "ibot_cas", "cenia": "cenia", "centrum_dopravniho_vyzkumu": "cdv", "centrum_pro_dopravu_a_energetiku": "cde", "centrum_pro_regionalni_rozvoj": "crr", "centrum_pro_studium_vysokeho_skolstvi": "csvs", "centrum_pro_vyzkum_verejneho_mineni": "cvvm", "centrum_vyzkumu_globalni_zmeny": "cvgz_cas", "ceska_asociace_ergoterapeutu": "cae", "ceska_asociace_paraplegiku": "czepa", "ceska_narodni_banka": "cnb", "ceska_spolecnost_ornitologicka": "birdlife", "ceska_zemedelska_univerzita": "czu", "cesky_statisticky_urad": "csu", "chmelarsky_institut": "chizatec", "clovek_v_tisni": "clovek_v_tisni", "crdm": "crdm", "cvut": "cvut", "ekodomov": "ekodomov", "entomologicky_ustav": "entu_cas", "etnologicky_ustav": "eu_cas", "evropske_hodnoty": "evropske_hodnoty", "fairtrade_cz_sk": "fairtrade_cz_sk", "filosoficky_ustav": "flu_cas", "fyzikalni_ustav": "fzu_cas", "fyziologicky_ustav": "fgu_cas", "galerie_vytvarneho_umeni_v_ostrave": "gvuo", "gender_studies": "gender_studies", "geofyzikalni_ustav": "ig_cas", "geologicky_ustav": "gli_cas", "gle": "gle", "hestia": "hestia", "historicky_ustav": "hiu_cas", "hydrobiologicky_ustav": "hbu_cas", "institut_umeni": "idu", "iuridicum_remedium": "iure", "jihoceska_univerzita_v_ceskych_budejovicich": "jcu", "jihomoravske_muzeum_ve_znojme": "jmm_znojmo", "knihovna_av_cr": "knav", "masarykova_univerzita": "muni", "masarykuv_ustav_a_archiv": "mua_cas", "matematicky_ustav": "math_cas", "mendelova_univerzita_v_brne": "mendelu", "mikrobiologicky_ustav": "mbu_cas", "ministerstvo_obrany": "mo_cr", "ministerstvo_spravedlnosti": "ms_cr", "ministerstvo_zivotniho_prostredi": "mzp_cr", "moravska_galerie": "moravska_gal", "moravska_zemska_knihovna": "mzk", "muzeum_brnenska": "muz_brnenska", "muzeum_vychodnich_cech": "muzeumhk", "nacr": "nacr", "nadace_promeny": "nadace_promeny", "narodni_informacni_a_poradenske_stredisko_pro_kulturu": "nipos", "narodni_knihovna": "nk_cr", "narodni_lekarska_knihovna": "nlk", "narodni_muzeum": "nm", "narodni_muzeum_v_prirode": "nmvp", "narodni_pamatkovy_ustav": "npu", "narodni_technicka_knihovna": "ntk", "narodni_technicke_muzeum": "ntm", "narodni_zemedelske_muzeum": "nzm", "narodohospodarsky_ustav": "nhu_cas", "nulk": "nulk", "nuv": "nuv", "orientalni_ustav": "orient_cas", "oseva": "oseva", "ostravska_univerzita": "osu", "pamatnik_narodniho_pisemnictvi": "pamatnik_np", "parazitologicky_ustav": "paru_cas", "parlamentni_institut": "pi_psp", "prague_college": "prague_college", "psychologicky_ustav": "psu_cas", "sdruzeni_pro_integraci_a_migraci": "simi", "severoceske_muzeum_v_liberci": "muzeumlb", "siriri": "siriri", "slezske_zemske_muzeum": "szm", "slovansky_ustav": "slu_cas", "sociologicky_ustav": "soc_cas", "surao": "surao", "szpi": "szpi", "technologicke_centrum": "tc_cas", "ujep": "ujep", "umeleckoprumyslove_museum": "umprum_museum", "univerzita_karlova_v_praze": "uk", "upce": "upce", "urad_prumysloveho_vlastnictvi": "upv", "ustav_analyticke_chemie": "uiach_cas", "ustav_anorganicke_chemie": "uach_cas", "ustav_archeologicke_pamatkove_pece_severozapadnich_cech": "uappmost", "ustav_biologie_obratlovcu": "ivb_cas", "ustav_chemickych_procesu": "icpf_cas", "ustav_dejin_umeni": "udu_cas", "ustav_experimentalni_botaniky": "ueb_cas", "ustav_experimentalni_mediciny": "iem_cas", "ustav_fotoniky_a_elektroniky": "ufe_cas", "ustav_fyzikalni_chemie_j_heyrovskeho": "jh_inst_cas", "ustav_fyziky_atmosfery": "ufa_cas", "ustav_fyziky_materialu": "ipm_cas", "ustav_fyziky_plazmatu": "ipp_cas", "ustav_geoniky": "ugn_cas", "ustav_informatiky": "ics_cas", "ustav_jaderne_fyziky": "ujf_cas", "ustav_makromolekularni_chemie": "imc_cas", "ustav_molekularni_biologie_rostlin": "umbr_cas", "ustav_molekularni_genetiky": "img_cas", "ustav_organicke_chemie_a_biochemie": "uochb_cas", "ustav_pristrojove_techniky": "upt_cas", "ustav_pro_ceskou_literaturu": "ucl_cas", "ustav_pro_elektrotechniku": "ue_cas", "ustav_pro_hydrodynamiku": "ih_cas", "ustav_pro_jazyk_cesky": "ujc_cas", "ustav_pro_soudobe_dejiny": "usd_cas", "ustav_pro_studium_totalitnich_rezimu": "ustrcz", "ustav_pudni_biologie": "upb_cas", "ustav_statu_a_prava": "ilaw_cas", "ustav_struktury_a_mechaniky_hornin": "irsm_cas", "ustav_teoreticke_a_aplikovane_mechaniky": "itam_cas", "ustav_teorie_informace_a_automatizace": "utia_cas", "ustav_termomechaniky": "it_cas", "ustav_zivocisne_fyziologie_a_genetiky": "iapg_cas", "vscht": "vscht", "vugtk": "vugtk", "vutbr": "vutbr", "vuv_tgm": "vuv_tgm", "vvud": "vvud", "vysoka_skola_ekonomicka_v_praze": "vse", "vysoka_skola_evropskych_a_regionalnich_studii": "vsers", "vysoka_skola_financni_a_spravni": "vsfs", "vysoka_skola_manazerske_informatiky_a_ekonomiky": "vsmie", "vyzkumny_ustav_bezpecnosti_prace": "vubp", "vyzkumny_ustav_lesniho_hospodarstvi_a_myslivosti": "vulhm", "vyzkumny_ustav_potravinarsky": "vupp", "vyzkumny_ustav_prace_a_socialnich_veci": "vupsv", "vyzkumny_ustav_rostlinne_vyroby": "vurv", "vyzkumny_ustav_silva_taroucy": "vukoz", "woodexpert": "woodexpert", "zapadoceska_univerzita": "zcu", "zapadoceske_muzeum_v_plzni": "zcm" }
[ 1, 515, 288, 598, 1129, 29918, 29877, 1794, 29918, 3358, 29882, 29918, 8222, 29894, 4156, 29889, 19557, 4097, 1053, 5751, 13, 3166, 288, 598, 1129, 29918, 29877, 1794, 29918, 3358, 29882, 29918, 8222, 29894, 4156, 29889, 9067, 261, 1053, 438, 29909, 1806, 29878, 550, 24784, 13, 3166, 288, 598, 1129, 29918, 20725, 4917, 583, 29889, 13239, 1053, 679, 29918, 20725, 21926, 29918, 3126, 13, 13, 13, 29992, 7491, 703, 29876, 375, 29880, 613, 376, 3034, 29883, 3134, 613, 5591, 29929, 29929, 29947, 1649, 29914, 29874, 613, 8576, 543, 1457, 1159, 13, 1753, 1246, 29918, 18121, 29898, 295, 29892, 3579, 19290, 1125, 13, 1678, 736, 13113, 29898, 295, 29892, 3579, 19290, 29897, 29871, 396, 282, 23929, 29901, 694, 4612, 13, 13, 13, 1753, 13113, 29898, 295, 29892, 3579, 19290, 1125, 13, 1678, 2243, 688, 353, 13113, 29918, 20698, 2141, 657, 29898, 295, 29897, 13, 1678, 565, 451, 2243, 688, 29901, 29871, 396, 282, 23929, 29901, 694, 4612, 13, 4706, 736, 438, 29909, 1806, 29878, 550, 24784, 29889, 8618, 27266, 1660, 29928, 13, 1678, 736, 426, 13, 4706, 11119, 6406, 8306, 1115, 426, 13, 9651, 376, 3859, 1115, 376, 1482, 613, 13, 9651, 376, 16072, 5261, 6997, 1115, 2243, 688, 29892, 13, 9651, 376, 2055, 348, 1907, 1115, 5159, 13, 4706, 2981, 13, 4706, 376, 18121, 1115, 679, 29918, 20725, 21926, 29918, 3126, 29898, 401, 543, 2611, 5008, 29879, 613, 13, 462, 462, 418, 2243, 688, 29922, 29517, 467, 13573, 262, 630, 29918, 1272, 13, 1678, 500, 13, 13, 13, 1753, 13113, 29918, 20698, 7295, 13, 1678, 736, 426, 13, 4706, 376, 351, 1377, 29883, 1115, 376, 351, 1377, 29883, 613, 13, 4706, 376, 351, 307, 1688, 29918, 29888, 29891, 517, 1115, 376, 351, 307, 1688, 29918, 29888, 29891, 517, 613, 13, 4706, 376, 557, 18401, 347, 29918, 2589, 29920, 860, 3376, 29918, 398, 11344, 29918, 29894, 29918, 29886, 336, 911, 1115, 376, 314, 29884, 613, 13, 4706, 376, 557, 18401, 347, 29918, 29894, 3637, 1707, 5909, 29918, 398, 11344, 1115, 376, 485, 29884, 613, 13, 4706, 376, 279, 1173, 1189, 18219, 29918, 504, 485, 29918, 1182, 1217, 1115, 376, 279, 431, 29918, 9398, 613, 13, 4706, 376, 279, 1173, 1189, 18219, 29918, 504, 485, 29918, 29886, 336, 2350, 1115, 376, 279, 786, 29918, 9398, 613, 13, 4706, 376, 1279, 666, 1115, 376, 1279, 666, 613, 13, 4706, 376, 24121, 29918, 292, 29918, 1279, 29918, 29926, 1648, 29918, 29885, 283, 384, 29891, 1115, 376, 29926, 29918, 29885, 283, 384, 29874, 613, 13, 4706, 376, 24121, 29918, 1514, 29918, 2397, 374, 29918, 29879, 283, 346, 29895, 1115, 376, 29926, 29918, 29879, 283, 346, 29895, 613, 13, 4706, 376, 2753, 4106, 1115, 376, 2753, 4106, 613, 13, 4706, 376, 7614, 4917, 18219, 29918, 504, 485, 1115, 376, 294, 29884, 29918, 9398, 613, 13, 4706, 376, 24840, 29888, 12339, 23587, 1240, 29918, 504, 485, 1115, 376, 1635, 29884, 29918, 9398, 613, 13, 4706, 376, 5365, 1189, 293, 446, 29918, 1760, 5848, 1115, 376, 12328, 29918, 9398, 613, 13, 4706, 376, 5365, 866, 3049, 1189, 18219, 29918, 504, 485, 1115, 376, 9268, 29918, 9398, 613, 13, 4706, 376, 7451, 273, 18219, 29918, 504, 485, 1115, 376, 747, 327, 29918, 9398, 613, 13, 4706, 376, 10278, 423, 1115, 376, 10278, 423, 613, 13, 4706, 376, 1760, 5848, 29918, 29881, 459, 5705, 1240, 1251, 29918, 13308, 7730, 398, 29884, 1115, 376, 2252, 29894, 613, 13, 4706, 376, 1760, 5848, 29918, 771, 29918, 29881, 459, 5705, 29884, 29918, 29874, 29918, 759, 657, 18282, 1115, 376, 29883, 311, 613, 13, 4706, 376, 1760, 5848, 29918, 771, 29918, 1727, 1848, 1240, 29918, 16997, 17521, 1115, 376, 7283, 29878, 613, 13, 4706, 376, 1760, 5848, 29918, 771, 29918, 18082, 1974, 29918, 13308, 578, 446, 1251, 29918, 808, 324, 303, 1403, 1115, 376, 2395, 4270, 613, 13, 4706, 376, 1760, 5848, 29918, 771, 29918, 13308, 7730, 398, 29918, 9359, 29926, 484, 1251, 29918, 1195, 11344, 1115, 376, 11023, 6925, 613, 13, 4706, 376, 1760, 5848, 29918, 13308, 7730, 398, 29884, 29918, 10945, 1240, 29918, 29920, 1527, 29891, 1115, 376, 11023, 18828, 29918, 9398, 613, 13, 4706, 376, 778, 1335, 29918, 294, 10183, 346, 29918, 261, 7085, 1572, 412, 329, 29884, 1115, 376, 1113, 29872, 613, 13, 4706, 376, 778, 1335, 29918, 294, 10183, 346, 29918, 862, 481, 1397, 18282, 1115, 376, 18562, 3274, 613, 13, 4706, 376, 778, 1335, 29918, 29876, 11160, 1240, 29918, 9157, 29874, 1115, 376, 29883, 9877, 613, 13, 4706, 376, 778, 1335, 29918, 1028, 1772, 29883, 6582, 29918, 1398, 277, 1189, 860, 29874, 1115, 376, 18513, 19264, 613, 13, 4706, 376, 778, 1335, 29918, 10479, 287, 295, 4621, 29918, 348, 2147, 29920, 2028, 1115, 376, 2067, 29884, 613, 13, 4706, 376, 778, 3459, 29918, 6112, 391, 18219, 29918, 332, 328, 1115, 376, 29883, 2146, 613, 13, 4706, 376, 305, 12873, 279, 7912, 29918, 2611, 12937, 1115, 376, 305, 466, 403, 29883, 613, 13, 4706, 376, 15126, 19134, 29918, 29894, 29918, 28898, 1240, 1115, 376, 15126, 19134, 29918, 29894, 29918, 28898, 1240, 613, 13, 4706, 376, 29883, 5499, 29885, 1115, 376, 29883, 5499, 29885, 613, 13, 4706, 376, 11023, 329, 1115, 376, 11023, 329, 613, 13, 4706, 376, 1416, 397, 290, 586, 1115, 376, 1416, 397, 290, 586, 613, 13, 4706, 376, 296, 290, 1189, 18219, 29918, 504, 485, 1115, 376, 296, 29884, 29918, 9398, 613, 13, 4706, 376, 300, 29876, 1189, 18219, 29918, 504, 485, 1115, 376, 12932, 29918, 9398, 613, 13, 4706, 376, 5750, 307, 567, 446, 29918, 24008, 1333, 29891, 1115, 376, 5750, 307, 567, 446, 29918, 24008, 1333, 29891, 613, 13, 4706, 376, 29888, 1466, 3018, 311, 29918, 2067, 29918, 808, 1115, 376, 29888, 1466, 3018, 311, 29918, 2067, 29918, 808, 613, 13, 4706, 376, 1777, 17904, 18219, 29918, 504, 485, 1115, 376, 25044, 29918, 9398, 613, 13, 4706, 376, 29888, 12339, 23587, 1240, 29918, 504, 485, 1115, 376, 29888, 6951, 29918, 9398, 613, 13, 4706, 376, 29888, 29891, 2526, 1189, 18219, 29918, 504, 485, 1115, 376, 29888, 2543, 29918, 9398, 613, 13, 4706, 376, 23014, 10681, 29918, 29894, 3637, 1707, 484, 1251, 29918, 398, 11344, 29918, 29894, 29918, 520, 336, 345, 1115, 376, 29887, 24845, 29877, 613, 13, 4706, 376, 26098, 29918, 18082, 583, 1115, 376, 26098, 29918, 18082, 583, 613, 13, 4706, 376, 479, 974, 12339, 23587, 1240, 29918, 504, 485, 1115, 376, 335, 29918, 9398, 613, 13, 4706, 376, 479, 1189, 18219, 29918, 504, 485, 1115, 376, 29887, 492, 29918, 9398, 613, 13, 4706, 376, 6234, 1115, 376, 6234, 613, 13, 4706, 376, 29882, 342, 423, 1115, 376, 29882, 342, 423, 613, 13, 4706, 376, 16211, 18219, 29918, 504, 485, 1115, 376, 2918, 29884, 29918, 9398, 613, 13, 4706, 376, 29882, 11279, 5365, 1189, 18219, 29918, 504, 485, 1115, 376, 29882, 2423, 29918, 9398, 613, 13, 4706, 376, 2611, 12937, 29918, 398, 11344, 1115, 376, 333, 29884, 613, 13, 4706, 376, 29875, 332, 333, 29381, 29918, 1745, 287, 1974, 1115, 376, 29875, 545, 613, 13, 4706, 376, 27272, 542, 267, 1335, 29918, 348, 2147, 29920, 2028, 29918, 29894, 29918, 778, 29895, 3376, 29918, 29890, 1151, 29926, 586, 293, 436, 1115, 376, 29926, 4979, 613, 13, 4706, 376, 2397, 9706, 272, 485, 26050, 29918, 2589, 27919, 29918, 345, 29918, 29920, 1217, 29926, 1004, 1115, 376, 29926, 4317, 29918, 29920, 1217, 29926, 4346, 613, 13, 4706, 376, 29895, 13428, 586, 1056, 29918, 485, 29918, 7283, 1115, 376, 3959, 485, 613, 13, 4706, 376, 8247, 653, 29895, 4273, 29918, 348, 2147, 29920, 2028, 1115, 376, 29885, 3909, 613, 13, 4706, 376, 8247, 653, 2120, 29894, 29918, 504, 485, 29918, 29874, 29918, 24121, 1115, 376, 2589, 29874, 29918, 9398, 613, 13, 4706, 376, 2922, 4579, 18219, 29918, 504, 485, 1115, 376, 755, 29918, 9398, 613, 13, 4706, 376, 29885, 355, 295, 4273, 29918, 348, 2147, 29920, 2028, 29918, 29894, 29918, 1182, 484, 1115, 376, 29885, 355, 295, 29884, 613, 13, 4706, 376, 29885, 638, 307, 5365, 1189, 18219, 29918, 504, 485, 1115, 376, 29885, 2423, 29918, 9398, 613, 13, 4706, 376, 15962, 26225, 29918, 711, 661, 29891, 1115, 376, 4346, 29918, 7283, 613, 13, 4706, 376, 15962, 26225, 29918, 1028, 336, 1490, 3083, 16098, 1115, 376, 1516, 29918, 7283, 613, 13, 4706, 376, 15962, 26225, 29918, 29920, 11002, 1240, 1251, 29918, 771, 303, 1127, 29875, 1115, 376, 29885, 29920, 29886, 29918, 7283, 613, 13, 4706, 376, 12257, 485, 4621, 29918, 23014, 10681, 1115, 376, 12257, 485, 4621, 29918, 23014, 613, 13, 4706, 376, 12257, 485, 4621, 29918, 10479, 4621, 29918, 29895, 13428, 586, 1056, 1115, 376, 29885, 7730, 613, 13, 4706, 376, 2589, 27919, 29918, 1182, 29876, 24958, 1115, 376, 2589, 29920, 29918, 1182, 29876, 24958, 613, 13, 4706, 376, 2589, 27919, 29918, 29894, 3376, 22452, 436, 29918, 346, 305, 1115, 376, 2589, 27919, 29882, 29895, 613, 13, 4706, 376, 29876, 562, 29878, 1115, 376, 29876, 562, 29878, 613, 13, 4706, 376, 28486, 815, 29918, 14032, 15274, 1115, 376, 28486, 815, 29918, 14032, 15274, 613, 13, 4706, 376, 29876, 11160, 1240, 29918, 262, 689, 562, 1240, 29918, 29874, 29918, 1971, 328, 575, 446, 29918, 303, 1127, 28783, 29918, 771, 29918, 29895, 9730, 29884, 1115, 376, 29876, 666, 359, 613, 13, 4706, 376, 29876, 11160, 1240, 29918, 29895, 13428, 586, 1056, 1115, 376, 29876, 29895, 29918, 7283, 613, 13, 4706, 376, 29876, 11160, 1240, 29918, 280, 5689, 4621, 29918, 29895, 13428, 586, 1056, 1115, 376, 12938, 29895, 613, 13, 4706, 376, 29876, 11160, 1240, 29918, 2589, 27919, 1115, 376, 22882, 613, 13, 4706, 376, 29876, 11160, 1240, 29918, 2589, 27919, 29918, 29894, 29918, 29886, 374, 307, 311, 1115, 376, 22882, 29894, 29886, 613, 13, 4706, 376, 29876, 11160, 1240, 29918, 29886, 314, 271, 9756, 29891, 29918, 504, 485, 1115, 376, 29876, 3746, 613, 13, 4706, 376, 29876, 11160, 1240, 29918, 21695, 860, 29874, 29918, 29895, 13428, 586, 1056, 1115, 376, 593, 29895, 613, 13, 4706, 376, 29876, 11160, 1240, 29918, 21695, 293, 446, 29918, 2589, 27919, 1115, 376, 593, 29885, 613, 13, 4706, 376, 29876, 11160, 1240, 29918, 10479, 287, 1379, 446, 29918, 2589, 27919, 1115, 376, 29876, 14018, 613, 13, 4706, 376, 29876, 11160, 1148, 23245, 279, 7912, 29918, 504, 485, 1115, 376, 29876, 6905, 29918, 9398, 613, 13, 4706, 376, 29876, 24456, 1115, 376, 29876, 24456, 613, 13, 4706, 376, 3433, 29894, 1115, 376, 3433, 29894, 613, 13, 4706, 376, 12236, 284, 1240, 29918, 504, 485, 1115, 376, 12236, 29918, 9398, 613, 13, 4706, 376, 852, 1564, 1115, 376, 852, 1564, 613, 13, 4706, 376, 520, 5705, 4621, 29918, 348, 2147, 29920, 2028, 1115, 376, 359, 29884, 613, 13, 4706, 376, 29886, 314, 271, 5585, 29918, 29876, 11160, 1240, 1251, 29918, 3334, 331, 29876, 919, 1403, 1115, 376, 29886, 314, 271, 5585, 29918, 9302, 613, 13, 4706, 376, 862, 834, 277, 1189, 18219, 29918, 504, 485, 1115, 376, 862, 29884, 29918, 9398, 613, 13, 4706, 376, 862, 12598, 1240, 29918, 2611, 12937, 1115, 376, 1631, 29918, 567, 29886, 613, 13, 4706, 376, 29886, 1431, 434, 29918, 1054, 4424, 1115, 376, 29886, 1431, 434, 29918, 1054, 4424, 613, 13, 4706, 376, 567, 3376, 1189, 18219, 29918, 504, 485, 1115, 376, 567, 29884, 29918, 9398, 613, 13, 4706, 376, 4928, 582, 2256, 29875, 29918, 771, 29918, 6693, 3874, 455, 29918, 29874, 29918, 29885, 335, 336, 455, 1115, 376, 3601, 29875, 613, 13, 4706, 376, 344, 369, 542, 267, 446, 29918, 2589, 27919, 29918, 29894, 29918, 492, 495, 455, 1115, 376, 2589, 27919, 27728, 613, 13, 4706, 376, 1039, 374, 374, 1115, 376, 1039, 374, 374, 613, 13, 4706, 376, 29879, 11867, 26050, 29918, 29920, 1567, 446, 29918, 2589, 27919, 1115, 376, 3616, 29885, 613, 13, 4706, 376, 29879, 5590, 550, 3459, 29918, 504, 485, 1115, 376, 2536, 29884, 29918, 9398, 613, 13, 4706, 376, 2839, 1189, 18219, 29918, 504, 485, 1115, 376, 29879, 542, 29918, 9398, 613, 13, 4706, 376, 29879, 2002, 29877, 1115, 376, 29879, 2002, 29877, 613, 13, 4706, 376, 3616, 1631, 1115, 376, 3616, 1631, 613, 13, 4706, 376, 21695, 1189, 293, 446, 29918, 1760, 5848, 1115, 376, 14246, 29918, 9398, 613, 13, 4706, 376, 8016, 1022, 1115, 376, 8016, 1022, 613, 13, 4706, 376, 2017, 280, 384, 459, 5848, 952, 417, 345, 29918, 25360, 1115, 376, 398, 558, 398, 29918, 25360, 613, 13, 4706, 376, 348, 2147, 29920, 2028, 29918, 5689, 417, 1564, 29918, 29894, 29918, 29886, 336, 911, 1115, 376, 2679, 613, 13, 4706, 376, 786, 346, 1115, 376, 786, 346, 613, 13, 4706, 376, 332, 328, 29918, 558, 398, 952, 417, 345, 1251, 29918, 29894, 4230, 29876, 919, 1403, 1115, 376, 786, 29894, 613, 13, 4706, 376, 504, 485, 29918, 7054, 3637, 293, 446, 29918, 14969, 347, 1115, 376, 29884, 423, 305, 29918, 9398, 613, 13, 4706, 376, 504, 485, 29918, 273, 6388, 293, 446, 29918, 14969, 347, 1115, 376, 29884, 496, 29918, 9398, 613, 13, 4706, 376, 504, 485, 29918, 279, 1173, 1189, 293, 446, 29918, 29886, 314, 271, 29895, 994, 29918, 412, 346, 29918, 344, 369, 2112, 481, 328, 29876, 436, 29918, 346, 305, 1115, 376, 29884, 932, 3242, 613, 13, 4706, 376, 504, 485, 29918, 5365, 5458, 29918, 711, 3605, 5590, 4979, 1115, 376, 440, 29890, 29918, 9398, 613, 13, 4706, 376, 504, 485, 29918, 14969, 860, 3376, 29918, 771, 778, 29884, 1115, 376, 293, 7810, 29918, 9398, 613, 13, 4706, 376, 504, 485, 29918, 311, 28789, 29918, 398, 11344, 1115, 376, 566, 29884, 29918, 9398, 613, 13, 4706, 376, 504, 485, 29918, 735, 27910, 1240, 29918, 7451, 273, 638, 29891, 1115, 376, 434, 29890, 29918, 9398, 613, 13, 4706, 376, 504, 485, 29918, 735, 27910, 1240, 29918, 2168, 293, 4901, 1115, 376, 3768, 29918, 9398, 613, 13, 4706, 376, 504, 485, 29918, 29888, 327, 265, 638, 29891, 29918, 29874, 29918, 6146, 12947, 265, 638, 29891, 1115, 376, 29556, 29918, 9398, 613, 13, 4706, 376, 504, 485, 29918, 29888, 12339, 23587, 1240, 29918, 14969, 347, 29918, 29926, 29918, 354, 29891, 307, 4270, 446, 1251, 1115, 376, 29926, 29882, 29918, 2611, 29918, 9398, 613, 13, 4706, 376, 504, 485, 29918, 29888, 12339, 638, 29891, 29918, 271, 7681, 571, 29891, 1115, 376, 1137, 29874, 29918, 9398, 613, 13, 4706, 376, 504, 485, 29918, 29888, 12339, 638, 29891, 29918, 15388, 29884, 1115, 376, 666, 29885, 29918, 9398, 613, 13, 4706, 376, 504, 485, 29918, 29888, 12339, 638, 29891, 29918, 13974, 29920, 2922, 29884, 1115, 376, 8377, 29918, 9398, 613, 13, 4706, 376, 504, 485, 29918, 25339, 638, 29891, 1115, 376, 688, 29876, 29918, 9398, 613, 13, 4706, 376, 504, 485, 29918, 262, 4830, 638, 29891, 1115, 376, 1199, 29918, 9398, 613, 13, 4706, 376, 504, 485, 29918, 29926, 1664, 484, 29918, 29888, 12339, 638, 29891, 1115, 376, 8016, 29888, 29918, 9398, 613, 13, 4706, 376, 504, 485, 29918, 29885, 557, 456, 1772, 29895, 1070, 1240, 29918, 14969, 347, 1115, 376, 326, 29883, 29918, 9398, 613, 13, 4706, 376, 504, 485, 29918, 29885, 1772, 29895, 1070, 1240, 29918, 5365, 5458, 29918, 17627, 1915, 1115, 376, 398, 1182, 29918, 9398, 613, 13, 4706, 376, 504, 485, 29918, 29885, 1772, 29895, 1070, 1240, 29918, 1885, 300, 638, 29891, 1115, 376, 2492, 29918, 9398, 613, 13, 4706, 376, 504, 485, 29918, 6388, 293, 446, 29918, 14969, 347, 29918, 29874, 29918, 24840, 14969, 347, 1115, 376, 29884, 2878, 29890, 29918, 9398, 613, 13, 4706, 376, 504, 485, 29918, 558, 19150, 29926, 994, 29918, 21695, 638, 29891, 1115, 376, 21245, 29918, 9398, 613, 13, 4706, 376, 504, 485, 29918, 771, 29918, 778, 21147, 29918, 20889, 1337, 29884, 1115, 376, 29884, 695, 29918, 9398, 613, 13, 4706, 376, 504, 485, 29918, 771, 29918, 6146, 1193, 4859, 3049, 18282, 1115, 376, 434, 29918, 9398, 613, 13, 4706, 376, 504, 485, 29918, 771, 29918, 29882, 2941, 5964, 2926, 18282, 1115, 376, 4861, 29918, 9398, 613, 13, 4706, 376, 504, 485, 29918, 771, 29918, 29926, 834, 12072, 29918, 778, 3459, 1115, 376, 8016, 29883, 29918, 9398, 613, 13, 4706, 376, 504, 485, 29918, 771, 29918, 29879, 2736, 16945, 29918, 311, 29926, 4901, 1115, 376, 375, 29881, 29918, 9398, 613, 13, 4706, 376, 504, 485, 29918, 771, 29918, 18082, 1974, 29918, 7827, 277, 29876, 436, 29918, 15749, 326, 29884, 1115, 376, 4627, 2067, 613, 13, 4706, 376, 504, 485, 29918, 29886, 25113, 29918, 5365, 5458, 1115, 376, 786, 29890, 29918, 9398, 613, 13, 4706, 376, 504, 485, 29918, 6112, 29884, 29918, 29874, 29918, 29886, 336, 1564, 1115, 376, 309, 1450, 29918, 9398, 613, 13, 4706, 376, 504, 485, 29918, 10582, 1193, 2857, 29918, 29874, 29918, 1004, 5083, 638, 29891, 29918, 25031, 262, 1115, 376, 381, 3844, 29918, 9398, 613, 13, 4706, 376, 504, 485, 29918, 371, 272, 7492, 446, 29918, 29874, 29918, 481, 5081, 586, 1662, 29918, 1004, 5083, 638, 29891, 1115, 376, 277, 314, 29918, 9398, 613, 13, 4706, 376, 504, 485, 29918, 371, 7661, 29918, 262, 689, 815, 29918, 29874, 29918, 17405, 271, 466, 815, 1115, 376, 329, 423, 29918, 9398, 613, 13, 4706, 376, 504, 485, 29918, 8489, 608, 5083, 638, 29891, 1115, 376, 277, 29918, 9398, 613, 13, 4706, 376, 504, 485, 29918, 29920, 440, 542, 275, 484, 29918, 29888, 29891, 2526, 5458, 29918, 29874, 29918, 1885, 300, 638, 29891, 1115, 376, 423, 4061, 29918, 9398, 613, 13, 4706, 376, 29894, 816, 29873, 1115, 376, 29894, 816, 29873, 613, 13, 4706, 376, 29894, 688, 11178, 1115, 376, 29894, 688, 11178, 613, 13, 4706, 376, 29894, 329, 1182, 1115, 376, 29894, 329, 1182, 613, 13, 4706, 376, 29894, 4090, 29918, 29873, 29887, 29885, 1115, 376, 29894, 4090, 29918, 29873, 29887, 29885, 613, 13, 4706, 376, 29894, 29894, 566, 1115, 376, 29894, 29894, 566, 613, 13, 4706, 376, 29894, 952, 17029, 29918, 808, 2963, 29918, 1416, 4917, 860, 29874, 29918, 29894, 29918, 29886, 336, 911, 1115, 376, 29894, 344, 613, 13, 4706, 376, 29894, 952, 17029, 29918, 808, 2963, 29918, 5750, 307, 567, 29895, 3376, 29918, 29874, 29918, 1727, 1848, 29876, 436, 29918, 18082, 2236, 1115, 376, 29894, 4253, 613, 13, 4706, 376, 29894, 952, 17029, 29918, 808, 2963, 29918, 4951, 4564, 1240, 29918, 29874, 29918, 1028, 5705, 1240, 1115, 376, 4270, 5847, 613, 13, 4706, 376, 29894, 952, 17029, 29918, 808, 2963, 29918, 1171, 834, 414, 446, 29918, 262, 4830, 638, 29891, 29918, 29874, 29918, 1416, 4917, 638, 29891, 1115, 376, 29894, 3844, 347, 613, 13, 4706, 376, 13308, 7730, 1227, 29891, 29918, 504, 485, 29918, 15325, 3135, 13887, 29918, 29886, 25525, 1115, 376, 29894, 431, 29886, 613, 13, 4706, 376, 13308, 7730, 1227, 29891, 29918, 504, 485, 29918, 793, 1240, 1251, 29918, 29882, 23245, 279, 303, 1403, 29918, 29874, 29918, 5781, 17843, 16098, 1115, 376, 29894, 352, 7184, 613, 13, 4706, 376, 13308, 7730, 1227, 29891, 29918, 504, 485, 29918, 17765, 336, 3845, 279, 7912, 1115, 376, 29894, 14889, 613, 13, 4706, 376, 13308, 7730, 1227, 29891, 29918, 504, 485, 29918, 29886, 25525, 29918, 29874, 29918, 24911, 29876, 436, 29918, 345, 455, 1115, 376, 29894, 14340, 29894, 613, 13, 4706, 376, 13308, 7730, 1227, 29891, 29918, 504, 485, 29918, 17627, 1915, 484, 29918, 13308, 307, 1609, 1115, 376, 29894, 332, 29894, 613, 13, 4706, 376, 13308, 7730, 1227, 29891, 29918, 504, 485, 29918, 25590, 1564, 29918, 12637, 283, 1270, 1115, 376, 29894, 2679, 2112, 613, 13, 4706, 376, 827, 356, 29916, 10700, 1115, 376, 827, 356, 29916, 10700, 613, 13, 4706, 376, 29920, 481, 328, 542, 267, 1335, 29918, 348, 2147, 29920, 2028, 1115, 376, 29920, 4979, 613, 13, 4706, 376, 29920, 481, 328, 542, 267, 446, 29918, 2589, 27919, 29918, 29894, 29918, 572, 29920, 1240, 1115, 376, 29920, 4912, 29908, 13, 1678, 500, 13, 2 ]
server.py
drunkHatch/CMPUT404-assignment-webserver
0
12656
# coding: utf-8 import socketserver import re import socket import datetime import os import mimetypes as MT import sys # Copyright 2013 <NAME>, <NAME> # # 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. # # # Furthermore it is derived from the Python documentation examples thus # some of the code is Copyright © 2001-2013 Python Software # Foundation; All Rights Reserved # # http://docs.python.org/2/library/socketserver.html # # run: python freetests.py # try: curl -v -X GET http://127.0.0.1:8080/ # status codes could be handled STATUS_CODE_RESPONSE = { 0: " 0 Surprise!", 200: " 200 OK", 301: " 301 Moved Permanently", 404: " 404 Not Found", 405: " 405 Method Not Allowed" } # methods could be handled HTTP_REQUEST_METHODS = { "GET": 1, } # some hard coded text END_OF_LINE_RESPONSE = "\r\n" PROTOCOL_RESPONSE = "HTTP/1.1" DIRECTORY_TO_SERVE = "www" # open file error here GOODFILE = 1 ISADIRECTORY = 2 NOFILE = 3 # response generate class class MyServerResponse: def __init__(self, status=0, expire_time="-1", content_type="default", \ accept_ranges="none"): self.response_header = { "status_response": PROTOCOL_RESPONSE + STATUS_CODE_RESPONSE[status], "date_response": "Date: " + datetime.datetime.now().\ strftime('%A, %d %b %Y %X %Z'), "expires": "Expires: " + expire_time, "content_type": "Content-Type: " + content_type, "accept_ranges": "Accept-Ranges: " + accept_ranges, "redirect_address": "Location: http://", "allow_header": "ALlow: GET" } # send header via various status_code def send_header(self, conn, status_code): tmp = self.response_header["status_response"] + END_OF_LINE_RESPONSE conn.sendall(tmp.encode("utf-8")) if status_code == 200: tmp = self.response_header["expires"] + END_OF_LINE_RESPONSE conn.sendall(tmp.encode("utf-8")) tmp = self.response_header["content_type"] + END_OF_LINE_RESPONSE conn.sendall(tmp.encode("utf-8")) elif status_code == 301: tmp = self.response_header["redirect_address"] + \ END_OF_LINE_RESPONSE conn.sendall(tmp.encode("utf-8")) elif status_code == 405: tmp = self.response_header["allow_header"] + END_OF_LINE_RESPONSE conn.sendall(tmp.encode("utf-8")) def set_status_response(self, status_code): self.response_header["status_response"] = \ PROTOCOL_RESPONSE + STATUS_CODE_RESPONSE[status_code] # request for storing received request attributes class MyServerRequest: def __init__(self): self.method = None self.url = None def method_is_valid(self): if self.method in HTTP_REQUEST_METHODS: return True else: return False # add more implementation here def url_is_valid(self): return True class MyWebServer(socketserver.BaseRequestHandler): def handle(self): rest_protocol_flag = False standard_rest_cmd = "GET / HTTP/1.1" # init the socket self.request.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) full_data = b"" with self.request as conn: # declaration here new_request = MyServerRequest() status_code = 0 open_file = True file = None content_type = "void of magic" file_name = "none" type_of_file = "default" open_result = -100 new_response = MyServerResponse() # recv all data while True: data = conn.recv(1024) if not data: break full_data += data if b"\r\n" in data: break if b"utf" in full_data: print(full_data) pass str_full_data = full_data.decode("utf-8") splited_commands = re.split('[\r|\n]+', str_full_data) whole_request = splited_commands[0].split(' ') # if we can find request from recved data if len(whole_request) > 0: new_request.method = whole_request[0] # try to pick methods new_request.url = whole_request[1] # try to pick url # if method we get could not be handled if not new_request.method_is_valid(): status_code = 405 open_file = False content_type = "none" new_response.set_status_response(status_code) # if no errors occured and then try to open requested url if open_file: open_result, file, file_name = openRequestedFile(new_request.url) # try opening requested file, and return corresponding status_code status_code = checkErrorsOfOpenedFile\ (status_code, open_result, file, file_name) # SECURITY: check permission of opened file status_code = checkPermissionOfRequestedFile\ (status_code, open_result, file, file_name) new_response.set_status_response(status_code) if status_code == 200 and file_name != None: type_of_file = MT.guess_type(file_name, False)[0] elif status_code == 301: new_response.response_header["redirect_address"] += \ self.server.server_address[0] + ":" + \ str(self.server.server_address[1]) + \ new_request.url + "/" new_response.set_status_response(status_code) if open_result == GOODFILE and type_of_file != None: new_response.response_header["content_type"] = "Content-Type: " new_response.response_header["content_type"] += type_of_file new_response.send_header(conn, status_code) self.request.sendall(b"\r\n") # then open file/directory and send it if file: self.request.sendfile(file) #self.request.sendall(b"\r\n") conn.close() # argument: requested url # return value: open file result, opened file object, local path def openRequestedFile(client_request_url): cru = client_request_url if cru[-1] == r'/': cru += "index.html" complete_path = DIRECTORY_TO_SERVE + cru try: result = open(complete_path, 'rb') content_type = cru.split(".") return GOODFILE, result, cru except IsADirectoryError as e: return ISADIRECTORY, None, None except FileNotFoundError as n: return NOFILE, None, None # check type and error of opened file def checkErrorsOfOpenedFile(status_code,open_result, file, file_name): if open_result == GOODFILE: status_code = 200 type_of_file = MT.guess_type(file_name, False)[0] elif open_result == ISADIRECTORY: status_code = 301 elif open_result == NOFILE: status_code = 404 return status_code # SECURITY: check the permission of opened file def checkPermissionOfRequestedFile(status_code,open_result, file, file_name): if file_name == None: return status_code abs_path_of_serving_dir = os.getcwd() abs_path_of_serving_dir += "/www/" length_of_serving_dir = len(abs_path_of_serving_dir) abs_path_of_request = os.path.abspath(file.name) length_of_requested_object = len(abs_path_of_request) if length_of_serving_dir > length_of_requested_object: status_code = 404 elif abs_path_of_serving_dir != abs_path_of_request[:length_of_serving_dir]: status_code = 404 return status_code if __name__ == "__main__": HOST, PORT = "localhost", 8080 socketserver.TCPServer.allow_reuse_address = True # Create the server, binding to localhost on port 8080 server = socketserver.TCPServer((HOST, PORT), MyWebServer) # https://stackoverflow.com/questions/15260558/python-tcpserver-address-already-in-use-but-i-close-the-server-and-i-use-allow # Activate the server; this will keep running until you # interrupt the program with Ctrl-C try: server.serve_forever() except KeyboardInterrupt: # exit if ctrl+C sys.exit(0)
[ 1, 396, 29871, 14137, 29901, 23616, 29899, 29947, 13, 5215, 9909, 2974, 13, 5215, 337, 13, 5215, 9909, 13, 5215, 12865, 13, 5215, 2897, 13, 5215, 286, 17528, 7384, 408, 341, 29911, 13, 5215, 10876, 13, 13, 29937, 14187, 1266, 29871, 29906, 29900, 29896, 29941, 529, 5813, 10202, 529, 5813, 29958, 13, 29937, 13, 29937, 10413, 21144, 1090, 278, 13380, 19245, 29892, 10079, 29871, 29906, 29889, 29900, 313, 1552, 376, 29931, 293, 1947, 1496, 13, 29937, 366, 1122, 451, 671, 445, 934, 5174, 297, 752, 13036, 411, 278, 19245, 29889, 13, 29937, 887, 1122, 4017, 263, 3509, 310, 278, 19245, 472, 13, 29937, 13, 29937, 268, 1732, 597, 1636, 29889, 4288, 29889, 990, 29914, 506, 11259, 29914, 27888, 1430, 1660, 29899, 29906, 29889, 29900, 13, 29937, 13, 29937, 25870, 3734, 491, 22903, 4307, 470, 15502, 304, 297, 5007, 29892, 7047, 13, 29937, 13235, 1090, 278, 19245, 338, 13235, 373, 385, 376, 3289, 8519, 29908, 350, 3289, 3235, 29892, 13, 29937, 399, 1806, 8187, 2692, 399, 1718, 29934, 13566, 29059, 6323, 8707, 29928, 22122, 29903, 8079, 13764, 29979, 476, 22255, 29892, 2845, 4653, 470, 2411, 2957, 29889, 13, 29937, 2823, 278, 19245, 363, 278, 2702, 4086, 14765, 1076, 11239, 322, 13, 29937, 27028, 1090, 278, 19245, 29889, 13, 29937, 13, 29937, 13, 29937, 16478, 372, 338, 10723, 515, 278, 5132, 5106, 6455, 4550, 13, 29937, 777, 310, 278, 775, 338, 14187, 1266, 29871, 30211, 29871, 29906, 29900, 29900, 29896, 29899, 29906, 29900, 29896, 29941, 5132, 18540, 13, 29937, 10606, 29936, 2178, 26863, 2538, 9841, 13, 29937, 13, 29937, 1732, 597, 2640, 29889, 4691, 29889, 990, 29914, 29906, 29914, 5258, 29914, 11514, 2974, 29889, 1420, 13, 29937, 13, 29937, 1065, 29901, 3017, 3005, 300, 9197, 29889, 2272, 13, 13, 29937, 1018, 29901, 11051, 448, 29894, 448, 29990, 12354, 1732, 597, 29896, 29906, 29955, 29889, 29900, 29889, 29900, 29889, 29896, 29901, 29947, 29900, 29947, 29900, 29914, 13, 13, 29937, 4660, 11561, 1033, 367, 16459, 13, 27047, 29918, 16524, 29918, 1525, 5550, 1164, 1660, 353, 426, 13, 268, 29900, 29901, 376, 29871, 29900, 6298, 7734, 29991, 613, 13, 268, 29906, 29900, 29900, 29901, 376, 29871, 29906, 29900, 29900, 9280, 613, 13, 268, 29941, 29900, 29896, 29901, 376, 29871, 29941, 29900, 29896, 341, 8238, 349, 3504, 2705, 613, 13, 268, 29946, 29900, 29946, 29901, 376, 29871, 29946, 29900, 29946, 2216, 7460, 613, 13, 268, 29946, 29900, 29945, 29901, 376, 29871, 29946, 29900, 29945, 8108, 2216, 2178, 20937, 29908, 13, 29913, 13, 13, 29937, 3519, 1033, 367, 16459, 13, 10493, 29918, 16244, 29918, 2303, 4690, 29949, 8452, 353, 426, 13, 1678, 376, 7194, 1115, 29871, 29896, 29892, 13, 29913, 13, 13, 29937, 777, 2898, 274, 6797, 1426, 13, 11794, 29918, 9800, 29918, 18521, 29918, 1525, 5550, 1164, 1660, 353, 6634, 29878, 29905, 29876, 29908, 13, 8618, 4986, 15032, 29918, 1525, 5550, 1164, 1660, 353, 376, 10493, 29914, 29896, 29889, 29896, 29908, 13, 4571, 26282, 18929, 29918, 4986, 29918, 6304, 12064, 353, 376, 1636, 29908, 13, 13, 29937, 1722, 934, 1059, 1244, 13, 17080, 13668, 7724, 353, 29871, 29896, 13, 3235, 3035, 29902, 26282, 18929, 353, 29871, 29906, 13, 6632, 7724, 353, 29871, 29941, 13, 13, 29937, 2933, 5706, 770, 13, 1990, 1619, 6004, 5103, 29901, 13, 13, 1678, 822, 4770, 2344, 12035, 1311, 29892, 4660, 29922, 29900, 29892, 1518, 533, 29918, 2230, 543, 29899, 29896, 613, 2793, 29918, 1853, 543, 4381, 613, 320, 13, 1678, 3544, 29918, 29878, 6916, 543, 9290, 29908, 1125, 13, 4706, 1583, 29889, 5327, 29918, 6672, 353, 426, 13, 9651, 376, 4882, 29918, 5327, 1115, 13756, 4986, 15032, 29918, 1525, 5550, 1164, 1660, 718, 6850, 1299, 3308, 29918, 16524, 29918, 1525, 5550, 1164, 1660, 29961, 4882, 1402, 13, 9651, 376, 1256, 29918, 5327, 1115, 376, 2539, 29901, 376, 718, 12865, 29889, 12673, 29889, 3707, 2141, 29905, 13, 462, 462, 18884, 851, 615, 603, 877, 29995, 29909, 29892, 1273, 29881, 1273, 29890, 1273, 29979, 1273, 29990, 1273, 29999, 5477, 13, 9651, 376, 4548, 2658, 1115, 376, 9544, 2658, 29901, 376, 718, 1518, 533, 29918, 2230, 29892, 13, 9651, 376, 3051, 29918, 1853, 1115, 376, 3916, 29899, 1542, 29901, 376, 718, 2793, 29918, 1853, 29892, 13, 9651, 376, 16044, 29918, 29878, 6916, 1115, 376, 23965, 29899, 29934, 6916, 29901, 376, 718, 3544, 29918, 29878, 6916, 29892, 13, 9651, 376, 17886, 29918, 7328, 1115, 376, 6508, 29901, 1732, 597, 613, 13, 9651, 376, 9536, 29918, 6672, 1115, 376, 1964, 677, 29901, 12354, 29908, 13, 4706, 500, 13, 13, 1678, 396, 3638, 4839, 3025, 5164, 4660, 29918, 401, 13, 1678, 822, 3638, 29918, 6672, 29898, 1311, 29892, 11009, 29892, 4660, 29918, 401, 1125, 13, 4706, 13128, 353, 1583, 29889, 5327, 29918, 6672, 3366, 4882, 29918, 5327, 3108, 718, 11056, 29918, 9800, 29918, 18521, 29918, 1525, 5550, 1164, 1660, 13, 4706, 11009, 29889, 6717, 497, 29898, 7050, 29889, 12508, 703, 9420, 29899, 29947, 5783, 13, 13, 4706, 565, 4660, 29918, 401, 1275, 29871, 29906, 29900, 29900, 29901, 13, 9651, 13128, 353, 1583, 29889, 5327, 29918, 6672, 3366, 4548, 2658, 3108, 718, 11056, 29918, 9800, 29918, 18521, 29918, 1525, 5550, 1164, 1660, 13, 9651, 11009, 29889, 6717, 497, 29898, 7050, 29889, 12508, 703, 9420, 29899, 29947, 5783, 13, 13, 9651, 13128, 353, 1583, 29889, 5327, 29918, 6672, 3366, 3051, 29918, 1853, 3108, 718, 11056, 29918, 9800, 29918, 18521, 29918, 1525, 5550, 1164, 1660, 13, 9651, 11009, 29889, 6717, 497, 29898, 7050, 29889, 12508, 703, 9420, 29899, 29947, 5783, 13, 4706, 25342, 4660, 29918, 401, 1275, 29871, 29941, 29900, 29896, 29901, 13, 9651, 13128, 353, 1583, 29889, 5327, 29918, 6672, 3366, 17886, 29918, 7328, 3108, 718, 320, 13, 462, 462, 462, 1678, 11056, 29918, 9800, 29918, 18521, 29918, 1525, 5550, 1164, 1660, 13, 9651, 11009, 29889, 6717, 497, 29898, 7050, 29889, 12508, 703, 9420, 29899, 29947, 5783, 13, 4706, 25342, 4660, 29918, 401, 1275, 29871, 29946, 29900, 29945, 29901, 13, 9651, 13128, 353, 1583, 29889, 5327, 29918, 6672, 3366, 9536, 29918, 6672, 3108, 718, 11056, 29918, 9800, 29918, 18521, 29918, 1525, 5550, 1164, 1660, 13, 9651, 11009, 29889, 6717, 497, 29898, 7050, 29889, 12508, 703, 9420, 29899, 29947, 5783, 13, 13, 1678, 822, 731, 29918, 4882, 29918, 5327, 29898, 1311, 29892, 4660, 29918, 401, 1125, 13, 4706, 1583, 29889, 5327, 29918, 6672, 3366, 4882, 29918, 5327, 3108, 353, 320, 13, 462, 1678, 13756, 4986, 15032, 29918, 1525, 5550, 1164, 1660, 718, 6850, 1299, 3308, 29918, 16524, 29918, 1525, 5550, 1164, 1660, 29961, 4882, 29918, 401, 29962, 13, 13, 29937, 2009, 363, 15446, 4520, 2009, 8393, 13, 1990, 1619, 6004, 3089, 29901, 13, 13, 1678, 822, 4770, 2344, 12035, 1311, 1125, 13, 4706, 1583, 29889, 5696, 353, 6213, 13, 4706, 1583, 29889, 2271, 353, 6213, 13, 13, 1678, 822, 1158, 29918, 275, 29918, 3084, 29898, 1311, 1125, 13, 4706, 565, 1583, 29889, 5696, 297, 7331, 29918, 16244, 29918, 2303, 4690, 29949, 8452, 29901, 13, 9651, 736, 5852, 13, 4706, 1683, 29901, 13, 9651, 736, 7700, 13, 13, 1678, 396, 788, 901, 5314, 1244, 13, 1678, 822, 3142, 29918, 275, 29918, 3084, 29898, 1311, 1125, 13, 4706, 736, 5852, 13, 13, 1990, 1619, 3609, 6004, 29898, 11514, 2974, 29889, 5160, 3089, 4598, 1125, 13, 13, 1678, 822, 4386, 29898, 1311, 1125, 13, 4706, 1791, 29918, 20464, 29918, 15581, 353, 7700, 13, 4706, 3918, 29918, 5060, 29918, 9006, 353, 376, 7194, 847, 7331, 29914, 29896, 29889, 29896, 29908, 13, 4706, 396, 2069, 278, 9909, 13, 4706, 1583, 29889, 3827, 29889, 842, 21852, 3670, 29898, 11514, 29889, 29903, 5607, 29918, 6156, 7077, 2544, 29892, 9909, 29889, 6156, 29918, 1525, 17171, 3035, 8353, 29892, 29871, 29896, 29897, 13, 4706, 2989, 29918, 1272, 353, 289, 15945, 13, 4706, 411, 1583, 29889, 3827, 408, 11009, 29901, 13, 9651, 396, 12029, 1244, 13, 9651, 716, 29918, 3827, 353, 1619, 6004, 3089, 580, 13, 9651, 4660, 29918, 401, 353, 29871, 29900, 13, 9651, 1722, 29918, 1445, 353, 5852, 13, 9651, 934, 353, 6213, 13, 9651, 2793, 29918, 1853, 353, 376, 5405, 310, 15709, 29908, 13, 9651, 934, 29918, 978, 353, 376, 9290, 29908, 13, 9651, 1134, 29918, 974, 29918, 1445, 353, 376, 4381, 29908, 13, 9651, 1722, 29918, 2914, 353, 448, 29896, 29900, 29900, 13, 9651, 716, 29918, 5327, 353, 1619, 6004, 5103, 580, 13, 13, 9651, 396, 1162, 29894, 599, 848, 13, 9651, 1550, 5852, 29901, 13, 18884, 848, 353, 11009, 29889, 3757, 29894, 29898, 29896, 29900, 29906, 29946, 29897, 13, 18884, 565, 451, 848, 29901, 2867, 13, 18884, 2989, 29918, 1272, 4619, 848, 13, 18884, 565, 289, 26732, 29878, 29905, 29876, 29908, 297, 848, 29901, 13, 462, 1678, 2867, 13, 9651, 565, 289, 29908, 9420, 29908, 297, 2989, 29918, 1272, 29901, 13, 18884, 1596, 29898, 8159, 29918, 1272, 29897, 13, 18884, 1209, 13, 9651, 851, 29918, 8159, 29918, 1272, 353, 2989, 29918, 1272, 29889, 13808, 703, 9420, 29899, 29947, 1159, 13, 9651, 8536, 1573, 29918, 26381, 353, 337, 29889, 5451, 877, 7110, 29878, 4295, 29876, 10062, 742, 851, 29918, 8159, 29918, 1272, 29897, 13, 9651, 3353, 29918, 3827, 353, 8536, 1573, 29918, 26381, 29961, 29900, 1822, 5451, 877, 25710, 13, 9651, 396, 565, 591, 508, 1284, 2009, 515, 1162, 1490, 848, 13, 9651, 565, 7431, 29898, 15970, 280, 29918, 3827, 29897, 1405, 29871, 29900, 29901, 13, 18884, 716, 29918, 3827, 29889, 5696, 353, 3353, 29918, 3827, 29961, 29900, 29962, 396, 1018, 304, 5839, 3519, 13, 18884, 716, 29918, 3827, 29889, 2271, 353, 3353, 29918, 3827, 29961, 29896, 29962, 396, 1018, 304, 5839, 3142, 13, 13, 18884, 396, 565, 1158, 591, 679, 1033, 451, 367, 16459, 13, 18884, 565, 451, 716, 29918, 3827, 29889, 5696, 29918, 275, 29918, 3084, 7295, 13, 462, 1678, 4660, 29918, 401, 353, 29871, 29946, 29900, 29945, 13, 462, 1678, 1722, 29918, 1445, 353, 7700, 13, 462, 1678, 2793, 29918, 1853, 353, 376, 9290, 29908, 13, 9651, 716, 29918, 5327, 29889, 842, 29918, 4882, 29918, 5327, 29898, 4882, 29918, 401, 29897, 13, 13, 9651, 396, 565, 694, 4436, 2179, 2955, 322, 769, 1018, 304, 1722, 13877, 3142, 13, 9651, 565, 1722, 29918, 1445, 29901, 13, 18884, 1722, 29918, 2914, 29892, 934, 29892, 934, 29918, 978, 353, 1722, 3089, 287, 2283, 29898, 1482, 29918, 3827, 29889, 2271, 29897, 13, 13, 18884, 396, 1018, 8718, 13877, 934, 29892, 322, 736, 6590, 4660, 29918, 401, 13, 18884, 4660, 29918, 401, 353, 1423, 22463, 2776, 6585, 287, 2283, 29905, 13, 462, 462, 1678, 313, 4882, 29918, 401, 29892, 1722, 29918, 2914, 29892, 934, 29892, 934, 29918, 978, 29897, 13, 18884, 396, 3725, 22484, 11937, 29901, 1423, 10751, 310, 6496, 934, 13, 18884, 4660, 29918, 401, 353, 1423, 27293, 2776, 3089, 287, 2283, 29905, 13, 462, 18884, 313, 4882, 29918, 401, 29892, 1722, 29918, 2914, 29892, 934, 29892, 934, 29918, 978, 29897, 13, 18884, 716, 29918, 5327, 29889, 842, 29918, 4882, 29918, 5327, 29898, 4882, 29918, 401, 29897, 13, 13, 18884, 565, 4660, 29918, 401, 1275, 29871, 29906, 29900, 29900, 322, 934, 29918, 978, 2804, 6213, 29901, 13, 462, 1678, 1134, 29918, 974, 29918, 1445, 353, 341, 29911, 29889, 2543, 404, 29918, 1853, 29898, 1445, 29918, 978, 29892, 7700, 9601, 29900, 29962, 13, 18884, 25342, 4660, 29918, 401, 1275, 29871, 29941, 29900, 29896, 29901, 13, 462, 1678, 716, 29918, 5327, 29889, 5327, 29918, 6672, 3366, 17886, 29918, 7328, 3108, 4619, 320, 13, 462, 9651, 1583, 29889, 2974, 29889, 2974, 29918, 7328, 29961, 29900, 29962, 718, 376, 6160, 718, 320, 13, 462, 9651, 851, 29898, 1311, 29889, 2974, 29889, 2974, 29918, 7328, 29961, 29896, 2314, 718, 320, 13, 462, 9651, 716, 29918, 3827, 29889, 2271, 718, 5591, 29908, 13, 13, 9651, 716, 29918, 5327, 29889, 842, 29918, 4882, 29918, 5327, 29898, 4882, 29918, 401, 29897, 13, 9651, 565, 1722, 29918, 2914, 1275, 21947, 13668, 7724, 322, 1134, 29918, 974, 29918, 1445, 2804, 6213, 29901, 13, 18884, 716, 29918, 5327, 29889, 5327, 29918, 6672, 3366, 3051, 29918, 1853, 3108, 353, 376, 3916, 29899, 1542, 29901, 376, 13, 18884, 716, 29918, 5327, 29889, 5327, 29918, 6672, 3366, 3051, 29918, 1853, 3108, 4619, 1134, 29918, 974, 29918, 1445, 13, 9651, 716, 29918, 5327, 29889, 6717, 29918, 6672, 29898, 13082, 29892, 4660, 29918, 401, 29897, 13, 9651, 1583, 29889, 3827, 29889, 6717, 497, 29898, 29890, 26732, 29878, 29905, 29876, 1159, 13, 13, 13, 9651, 396, 769, 1722, 934, 29914, 12322, 322, 3638, 372, 13, 9651, 565, 934, 29901, 13, 18884, 1583, 29889, 3827, 29889, 6717, 1445, 29898, 1445, 29897, 13, 9651, 396, 1311, 29889, 3827, 29889, 6717, 497, 29898, 29890, 26732, 29878, 29905, 29876, 1159, 13, 13, 9651, 11009, 29889, 5358, 580, 13, 13, 29937, 2980, 29901, 13877, 3142, 13, 29937, 736, 995, 29901, 1722, 934, 1121, 29892, 6496, 934, 1203, 29892, 1887, 2224, 13, 1753, 1722, 3089, 287, 2283, 29898, 4645, 29918, 3827, 29918, 2271, 1125, 13, 13, 1678, 7618, 353, 3132, 29918, 3827, 29918, 2271, 13, 13, 1678, 565, 7618, 14352, 29896, 29962, 1275, 364, 29915, 29914, 2396, 13, 4706, 7618, 4619, 376, 2248, 29889, 1420, 29908, 13, 13, 1678, 4866, 29918, 2084, 353, 22471, 26282, 18929, 29918, 4986, 29918, 6304, 12064, 718, 7618, 13, 1678, 1018, 29901, 13, 4706, 1121, 353, 1722, 29898, 8835, 29918, 2084, 29892, 525, 6050, 1495, 13, 4706, 2793, 29918, 1853, 353, 7618, 29889, 5451, 17350, 1159, 13, 4706, 736, 21947, 13668, 7724, 29892, 1121, 29892, 7618, 13, 1678, 5174, 1317, 3035, 5554, 2392, 408, 321, 29901, 13, 4706, 736, 8519, 3035, 29902, 26282, 18929, 29892, 6213, 29892, 6213, 13, 1678, 5174, 3497, 17413, 2392, 408, 302, 29901, 13, 4706, 736, 11698, 7724, 29892, 6213, 29892, 6213, 13, 13, 29937, 1423, 1134, 322, 1059, 310, 6496, 934, 13, 1753, 1423, 22463, 2776, 6585, 287, 2283, 29898, 4882, 29918, 401, 29892, 3150, 29918, 2914, 29892, 934, 29892, 934, 29918, 978, 1125, 13, 1678, 565, 1722, 29918, 2914, 1275, 21947, 13668, 7724, 29901, 13, 4706, 4660, 29918, 401, 353, 29871, 29906, 29900, 29900, 13, 4706, 1134, 29918, 974, 29918, 1445, 353, 341, 29911, 29889, 2543, 404, 29918, 1853, 29898, 1445, 29918, 978, 29892, 7700, 9601, 29900, 29962, 13, 1678, 25342, 1722, 29918, 2914, 1275, 8519, 3035, 29902, 26282, 18929, 29901, 13, 4706, 4660, 29918, 401, 353, 29871, 29941, 29900, 29896, 13, 1678, 25342, 1722, 29918, 2914, 1275, 11698, 7724, 29901, 13, 4706, 4660, 29918, 401, 353, 29871, 29946, 29900, 29946, 13, 13, 1678, 736, 4660, 29918, 401, 13, 13, 29937, 3725, 22484, 11937, 29901, 1423, 278, 10751, 310, 6496, 934, 13, 1753, 1423, 27293, 2776, 3089, 287, 2283, 29898, 4882, 29918, 401, 29892, 3150, 29918, 2914, 29892, 934, 29892, 934, 29918, 978, 1125, 13, 13, 1678, 565, 934, 29918, 978, 1275, 6213, 29901, 13, 4706, 736, 4660, 29918, 401, 13, 13, 1678, 6425, 29918, 2084, 29918, 974, 29918, 643, 1747, 29918, 3972, 353, 2897, 29889, 657, 29883, 9970, 580, 13, 1678, 6425, 29918, 2084, 29918, 974, 29918, 643, 1747, 29918, 3972, 4619, 5591, 1636, 12975, 13, 1678, 3309, 29918, 974, 29918, 643, 1747, 29918, 3972, 353, 7431, 29898, 6897, 29918, 2084, 29918, 974, 29918, 643, 1747, 29918, 3972, 29897, 13, 1678, 6425, 29918, 2084, 29918, 974, 29918, 3827, 353, 2897, 29889, 2084, 29889, 370, 1028, 493, 29898, 1445, 29889, 978, 29897, 13, 1678, 3309, 29918, 974, 29918, 3827, 287, 29918, 3318, 353, 7431, 29898, 6897, 29918, 2084, 29918, 974, 29918, 3827, 29897, 13, 13, 1678, 565, 3309, 29918, 974, 29918, 643, 1747, 29918, 3972, 1405, 3309, 29918, 974, 29918, 3827, 287, 29918, 3318, 29901, 13, 4706, 4660, 29918, 401, 353, 29871, 29946, 29900, 29946, 13, 1678, 25342, 6425, 29918, 2084, 29918, 974, 29918, 643, 1747, 29918, 3972, 2804, 6425, 29918, 2084, 29918, 974, 29918, 3827, 7503, 2848, 29918, 974, 29918, 643, 1747, 29918, 3972, 5387, 13, 4706, 4660, 29918, 401, 353, 29871, 29946, 29900, 29946, 13, 13, 1678, 736, 4660, 29918, 401, 13, 13, 13, 361, 4770, 978, 1649, 1275, 376, 1649, 3396, 1649, 1115, 13, 1678, 379, 3718, 29892, 349, 8476, 353, 376, 7640, 613, 29871, 29947, 29900, 29947, 29900, 13, 13, 1678, 9909, 2974, 29889, 29911, 6271, 6004, 29889, 9536, 29918, 276, 1509, 29918, 7328, 353, 5852, 13, 1678, 396, 6204, 278, 1923, 29892, 9956, 304, 15683, 373, 2011, 29871, 29947, 29900, 29947, 29900, 13, 1678, 1923, 353, 9909, 2974, 29889, 29911, 6271, 6004, 3552, 20832, 29892, 349, 8476, 511, 1619, 3609, 6004, 29897, 13, 1678, 396, 2045, 597, 2417, 29889, 510, 29914, 2619, 29914, 29896, 29945, 29906, 29953, 29900, 29945, 29945, 29947, 29914, 4691, 29899, 14246, 567, 261, 369, 29899, 7328, 29899, 284, 2040, 29899, 262, 29899, 1509, 29899, 4187, 29899, 29875, 29899, 5358, 29899, 1552, 29899, 2974, 29899, 392, 29899, 29875, 29899, 1509, 29899, 9536, 13, 1678, 396, 21775, 403, 278, 1923, 29936, 445, 674, 3013, 2734, 2745, 366, 13, 1678, 396, 23754, 278, 1824, 411, 315, 11742, 29899, 29907, 13, 1678, 1018, 29901, 13, 4706, 1923, 29889, 16349, 29918, 1079, 369, 580, 13, 1678, 5174, 7670, 3377, 4074, 6685, 29901, 396, 6876, 565, 274, 11742, 29974, 29907, 13, 4706, 10876, 29889, 13322, 29898, 29900, 29897, 13, 2 ]
pred_shots/main.py
RasmusRynell/Predicting-NHL
1
127030
<filename>pred_shots/main.py from handler import * import json import os os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2' def print_help(): print("Current commands: ") print("1. help: Shows this") print("2. exit: Exits the process, nothing is saved") print("3. eval: ") print("4. und: Refreshes/Updates the local NHL database") print("5. and: Add nicknames to the database") print("6. ubd: Add \"old\" bets (from bookies that's located on a local file) to database") print("7. gen: Generate a CSV file containing all information for a player going back to 2017/09/15") print("8. pre: Perform preprocessing") if __name__ == "__main__": while True: arg_in = input(">>> ") # Initial commands if arg_in.lower() == 'help' or arg_in == '1' or arg_in == 'h': print_help() elif arg_in.lower() == 'exit' or arg_in == '2' or arg_in == 'e': print("Exiting...") break #elif arg_in.lower() == 'eval': # eval_bets() # Dev elif arg_in.lower() == 'und': update_nhl_db() print("Nhl database updated") elif arg_in.lower() == 'and': add_nicknames_nhl_db() print("Nicknames added") elif arg_in.lower() == 'ubd': print("What file do you want to add? (\"b\" for back) (EX: 2017-03-21.bet365) (Empty for all in folder)") f = input(">>> > ") if f == 'b': print("Back...") elif f == "": update_bets_db() print("Bets database updated") else: update_bets_db(f) print("Bets database updated") elif arg_in.lower() == 'gen': player_ids = [8471214]#, 8475167, 8478463, 8475744, 8477504, 8477492, 8480839, 8477499, 8476881] for player_id in player_ids: data = generate_csv(player_id) save_csv(data, str(player_id) + ".csv") elif arg_in.lower() == 'pred': bets = get_bets() # Remove all but last 5 bets in dict keys = list(bets.keys()) new_bets = {} for i in range(10, 15): new_bets[keys[i]] = bets[keys[i]] predictions = predict_games(new_bets) print("Predictions saved to file") print("Predictions: ") #print(json.dumps(predictions, indent=4)) # Save predictions dict to a file with open('./external/predictions/test.json', 'w') as f: json.dump(predictions, f) elif arg_in.lower() == 'eval': bets = {} # Read in bets from file with open('./external/predictions/test.json', 'r') as f: bets = json.load(f) evaluate_bets(bets) else: print(f"\"{arg_in}\" is no command")
[ 1, 529, 9507, 29958, 11965, 29918, 845, 1862, 29914, 3396, 29889, 2272, 13, 3166, 7834, 1053, 334, 13, 5215, 4390, 13, 5215, 2897, 13, 359, 29889, 21813, 1839, 8969, 29918, 6271, 29925, 29918, 16173, 29918, 14480, 29918, 1307, 29963, 6670, 2033, 353, 525, 29906, 29915, 13, 13, 1753, 1596, 29918, 8477, 7295, 13, 1678, 1596, 703, 7583, 8260, 29901, 16521, 13, 1678, 1596, 703, 29896, 29889, 1371, 29901, 1383, 1242, 445, 1159, 13, 1678, 1596, 703, 29906, 29889, 6876, 29901, 1222, 1169, 278, 1889, 29892, 3078, 338, 7160, 1159, 13, 1678, 1596, 703, 29941, 29889, 19745, 29901, 16521, 13, 1678, 1596, 703, 29946, 29889, 563, 29901, 9897, 3781, 267, 29914, 3373, 15190, 278, 1887, 405, 15444, 2566, 1159, 13, 1678, 1596, 703, 29945, 29889, 322, 29901, 3462, 25985, 7039, 304, 278, 2566, 1159, 13, 1678, 1596, 703, 29953, 29889, 318, 6448, 29901, 3462, 13218, 1025, 5931, 1010, 29879, 313, 3166, 3143, 583, 393, 29915, 29879, 5982, 373, 263, 1887, 934, 29897, 304, 2566, 1159, 13, 1678, 1596, 703, 29955, 29889, 2531, 29901, 3251, 403, 263, 16874, 934, 6943, 599, 2472, 363, 263, 4847, 2675, 1250, 304, 29871, 29906, 29900, 29896, 29955, 29914, 29900, 29929, 29914, 29896, 29945, 1159, 13, 1678, 1596, 703, 29947, 29889, 758, 29901, 27313, 758, 19170, 1159, 13, 13, 13, 13, 13, 361, 4770, 978, 1649, 1275, 376, 1649, 3396, 1649, 1115, 13, 1678, 1550, 5852, 29901, 13, 4706, 1852, 29918, 262, 353, 1881, 703, 6778, 29958, 16521, 13, 13, 4706, 396, 17250, 8260, 13, 4706, 565, 1852, 29918, 262, 29889, 13609, 580, 1275, 525, 8477, 29915, 470, 1852, 29918, 262, 1275, 525, 29896, 29915, 470, 1852, 29918, 262, 1275, 525, 29882, 2396, 13, 9651, 1596, 29918, 8477, 580, 13, 13, 4706, 25342, 1852, 29918, 262, 29889, 13609, 580, 1275, 525, 13322, 29915, 470, 1852, 29918, 262, 1275, 525, 29906, 29915, 470, 1852, 29918, 262, 1275, 525, 29872, 2396, 13, 9651, 1596, 703, 1252, 11407, 856, 1159, 13, 9651, 2867, 13, 13, 4706, 396, 23681, 1852, 29918, 262, 29889, 13609, 580, 1275, 525, 14513, 2396, 13, 4706, 396, 1678, 19745, 29918, 29890, 1691, 580, 13, 13, 4706, 396, 9481, 13, 4706, 25342, 1852, 29918, 262, 29889, 13609, 580, 1275, 525, 870, 2396, 13, 9651, 2767, 29918, 29876, 4415, 29918, 2585, 580, 13, 9651, 1596, 703, 29940, 4415, 2566, 4784, 1159, 13, 13, 4706, 25342, 1852, 29918, 262, 29889, 13609, 580, 1275, 525, 392, 2396, 13, 9651, 788, 29918, 19254, 7039, 29918, 29876, 4415, 29918, 2585, 580, 13, 9651, 1596, 703, 29940, 860, 7039, 2715, 1159, 13, 13, 4706, 25342, 1852, 29918, 262, 29889, 13609, 580, 1275, 525, 431, 29881, 2396, 13, 9651, 1596, 703, 5618, 934, 437, 366, 864, 304, 788, 29973, 3441, 29908, 29890, 5931, 363, 1250, 29897, 313, 5746, 29901, 29871, 29906, 29900, 29896, 29955, 29899, 29900, 29941, 29899, 29906, 29896, 29889, 6878, 29941, 29953, 29945, 29897, 313, 8915, 363, 599, 297, 4138, 25760, 13, 9651, 285, 353, 1881, 703, 6778, 29958, 1405, 16521, 13, 9651, 565, 285, 1275, 525, 29890, 2396, 13, 18884, 1596, 703, 5841, 856, 1159, 13, 9651, 25342, 285, 1275, 376, 1115, 13, 18884, 2767, 29918, 29890, 1691, 29918, 2585, 580, 13, 18884, 1596, 703, 29933, 1691, 2566, 4784, 1159, 13, 9651, 1683, 29901, 13, 18884, 2767, 29918, 29890, 1691, 29918, 2585, 29898, 29888, 29897, 13, 18884, 1596, 703, 29933, 1691, 2566, 4784, 1159, 13, 13, 4706, 25342, 1852, 29918, 262, 29889, 13609, 580, 1275, 525, 1885, 2396, 13, 9651, 4847, 29918, 4841, 353, 518, 29947, 29946, 29955, 29896, 29906, 29896, 29946, 29962, 6552, 29871, 29947, 29946, 29955, 29945, 29896, 29953, 29955, 29892, 29871, 29947, 29946, 29955, 29947, 29946, 29953, 29941, 29892, 29871, 29947, 29946, 29955, 29945, 29955, 29946, 29946, 29892, 29871, 29947, 29946, 29955, 29955, 29945, 29900, 29946, 29892, 29871, 29947, 29946, 29955, 29955, 29946, 29929, 29906, 29892, 29871, 29947, 29946, 29947, 29900, 29947, 29941, 29929, 29892, 29871, 29947, 29946, 29955, 29955, 29946, 29929, 29929, 29892, 29871, 29947, 29946, 29955, 29953, 29947, 29947, 29896, 29962, 13, 9651, 363, 4847, 29918, 333, 297, 4847, 29918, 4841, 29901, 13, 18884, 848, 353, 5706, 29918, 7638, 29898, 9106, 29918, 333, 29897, 13, 18884, 4078, 29918, 7638, 29898, 1272, 29892, 851, 29898, 9106, 29918, 333, 29897, 718, 11393, 7638, 1159, 13, 13, 13, 4706, 25342, 1852, 29918, 262, 29889, 13609, 580, 1275, 525, 11965, 2396, 13, 9651, 1010, 29879, 353, 679, 29918, 29890, 1691, 580, 13, 13, 9651, 396, 15154, 599, 541, 1833, 29871, 29945, 1010, 29879, 297, 9657, 13, 9651, 6611, 353, 1051, 29898, 29890, 1691, 29889, 8149, 3101, 13, 9651, 716, 29918, 29890, 1691, 353, 6571, 13, 9651, 363, 474, 297, 3464, 29898, 29896, 29900, 29892, 29871, 29896, 29945, 1125, 13, 18884, 716, 29918, 29890, 1691, 29961, 8149, 29961, 29875, 5262, 353, 1010, 29879, 29961, 8149, 29961, 29875, 5262, 13, 13, 13, 9651, 27303, 353, 8500, 29918, 29887, 1280, 29898, 1482, 29918, 29890, 1691, 29897, 13, 13, 9651, 1596, 703, 23084, 919, 1080, 7160, 304, 934, 1159, 13, 9651, 1596, 703, 23084, 919, 1080, 29901, 16521, 13, 9651, 396, 2158, 29898, 3126, 29889, 29881, 17204, 29898, 27711, 1080, 29892, 29536, 29922, 29946, 876, 13, 13, 9651, 396, 16913, 27303, 9657, 304, 263, 934, 13, 9651, 411, 1722, 877, 6904, 23176, 29914, 27711, 1080, 29914, 1688, 29889, 3126, 742, 525, 29893, 1495, 408, 285, 29901, 13, 18884, 4390, 29889, 15070, 29898, 27711, 1080, 29892, 285, 29897, 13, 462, 13, 13, 13, 13, 4706, 25342, 1852, 29918, 262, 29889, 13609, 580, 1275, 525, 14513, 2396, 13, 9651, 1010, 29879, 353, 6571, 13, 9651, 396, 7523, 297, 1010, 29879, 515, 934, 13, 9651, 411, 1722, 877, 6904, 23176, 29914, 27711, 1080, 29914, 1688, 29889, 3126, 742, 525, 29878, 1495, 408, 285, 29901, 13, 18884, 1010, 29879, 353, 4390, 29889, 1359, 29898, 29888, 29897, 13, 9651, 14707, 29918, 29890, 1691, 29898, 29890, 1691, 29897, 13, 632, 13, 13, 13, 4706, 1683, 29901, 13, 9651, 1596, 29898, 29888, 29908, 5931, 29912, 1191, 29918, 262, 1012, 29908, 338, 694, 1899, 1159, 2 ]
backend/project/posts/utils/PostAlbumUtil.py
winoutt/winoutt-django
0
151110
from project.posts.models import PostAlbum def create(post, photos): for photo in photos: PostAlbum.objects.create(post=post, photo=photo, photo_original=photo) def get_post_album(post): return PostAlbum.objects.filter(post=post)
[ 1, 515, 2060, 29889, 14080, 29889, 9794, 1053, 4918, 2499, 2404, 30004, 13, 30004, 13, 1753, 1653, 29898, 2490, 29892, 20612, 1125, 30004, 13, 1678, 363, 15373, 297, 20612, 29901, 30004, 13, 4706, 4918, 2499, 2404, 29889, 12650, 29889, 3258, 29898, 2490, 29922, 2490, 29892, 15373, 29922, 21596, 29892, 15373, 29918, 13492, 29922, 21596, 8443, 13, 30004, 13, 30004, 13, 1753, 679, 29918, 2490, 29918, 10336, 29898, 2490, 1125, 30004, 13, 1678, 736, 4918, 2499, 2404, 29889, 12650, 29889, 4572, 29898, 2490, 29922, 2490, 29897, 2 ]
tests/test_disk_cache/test_disk_general.py
SHIELD616416/hello-world
0
172702
#!/usr/bin/python # -*- coding: utf-8 -*- # DATE: 2022/1/19 # Author: <EMAIL> import os import sqlite3.dbapi2 as sqlite3 import threading import time from typing import NoReturn import pytest from cache3 import SimpleDiskCache from cache3.disk import SessionDescriptor # api >>> SessionDescriptor.__set__ def test__set__() -> NoReturn: cache = SimpleDiskCache() assert isinstance(cache.session, sqlite3.Connection) with pytest.raises(ValueError, match='Expected .* to be an sqlite3.Connection.'): cache.session = 1 cache.session = sqlite3.connect('test.sqlite') os.remove('test.sqlite') # api >>> SessionDescriptor.__delete__, _close def test__close__(): cache = SimpleDiskCache() origin: sqlite3.Connection = cache.session assert isinstance(cache.session, sqlite3.Connection) del cache.session assert origin != cache.session # api >>> def test_init(): file = 'test1.sqlite' def h(file): cache = SimpleDiskCache(name=file, configure={'timeout': 0.01}) with cache._transact() as sqlite: sqlite( 'CREATE TABLE test(id integer)' ) time.sleep(1) sqlite( 'DROP TABLE test' ) def f(file): cache = SimpleDiskCache(name=file, configure={'timeout': 0.01}) cache.set('name', 'monkey') threading.Thread(target=h, args=(file, )).start() threading.Thread(target=f, args=(file, )).start() if __name__ == '__main__': pytest.main(["-s", __file__])
[ 1, 18787, 4855, 29914, 2109, 29914, 4691, 13, 29937, 448, 29930, 29899, 14137, 29901, 23616, 29899, 29947, 448, 29930, 29899, 13, 29937, 20231, 29901, 29871, 29906, 29900, 29906, 29906, 29914, 29896, 29914, 29896, 29929, 13, 29937, 13361, 29901, 529, 26862, 6227, 29958, 13, 13, 5215, 2897, 13, 5215, 21120, 29941, 29889, 2585, 2754, 29906, 408, 21120, 29941, 13, 5215, 3244, 292, 13, 5215, 931, 13, 3166, 19229, 1053, 1939, 11609, 13, 13, 5215, 11451, 1688, 13, 13, 3166, 7090, 29941, 1053, 12545, 29928, 3873, 10408, 13, 3166, 7090, 29941, 29889, 20960, 1053, 16441, 19124, 13, 13, 13, 29937, 7882, 8653, 16441, 19124, 17255, 842, 1649, 13, 1753, 1243, 1649, 842, 1649, 580, 1599, 1939, 11609, 29901, 13, 13, 1678, 7090, 353, 12545, 29928, 3873, 10408, 580, 13, 1678, 4974, 338, 8758, 29898, 8173, 29889, 7924, 29892, 21120, 29941, 29889, 5350, 29897, 13, 1678, 411, 11451, 1688, 29889, 336, 4637, 29898, 1917, 2392, 29892, 1993, 2433, 1252, 6021, 869, 29930, 304, 367, 385, 21120, 29941, 29889, 5350, 6169, 1125, 13, 4706, 7090, 29889, 7924, 353, 29871, 29896, 13, 13, 1678, 7090, 29889, 7924, 353, 21120, 29941, 29889, 6915, 877, 1688, 29889, 22793, 1495, 13, 1678, 2897, 29889, 5992, 877, 1688, 29889, 22793, 1495, 13, 13, 13, 29937, 7882, 8653, 16441, 19124, 17255, 8143, 1649, 29892, 903, 5358, 13, 1753, 1243, 1649, 5358, 1649, 7295, 13, 13, 1678, 7090, 353, 12545, 29928, 3873, 10408, 580, 13, 1678, 3978, 29901, 21120, 29941, 29889, 5350, 353, 7090, 29889, 7924, 13, 1678, 4974, 338, 8758, 29898, 8173, 29889, 7924, 29892, 21120, 29941, 29889, 5350, 29897, 13, 1678, 628, 7090, 29889, 7924, 13, 1678, 4974, 3978, 2804, 7090, 29889, 7924, 13, 13, 13, 29937, 7882, 8653, 13, 1753, 1243, 29918, 2344, 7295, 13, 13, 1678, 934, 353, 525, 1688, 29896, 29889, 22793, 29915, 13, 13, 1678, 822, 298, 29898, 1445, 1125, 13, 4706, 7090, 353, 12545, 29928, 3873, 10408, 29898, 978, 29922, 1445, 29892, 10822, 3790, 29915, 15619, 2396, 29871, 29900, 29889, 29900, 29896, 1800, 13, 4706, 411, 7090, 3032, 3286, 627, 580, 408, 21120, 29901, 13, 9651, 21120, 29898, 13, 18884, 525, 27045, 10911, 1243, 29898, 333, 6043, 16029, 13, 9651, 1723, 13, 9651, 931, 29889, 17059, 29898, 29896, 29897, 13, 9651, 21120, 29898, 13, 18884, 525, 29928, 29366, 10911, 1243, 29915, 13, 9651, 1723, 13, 13, 1678, 822, 285, 29898, 1445, 1125, 13, 4706, 7090, 353, 12545, 29928, 3873, 10408, 29898, 978, 29922, 1445, 29892, 10822, 3790, 29915, 15619, 2396, 29871, 29900, 29889, 29900, 29896, 1800, 13, 4706, 7090, 29889, 842, 877, 978, 742, 525, 3712, 1989, 1495, 13, 13, 1678, 3244, 292, 29889, 4899, 29898, 5182, 29922, 29882, 29892, 6389, 7607, 1445, 29892, 1723, 467, 2962, 580, 13, 1678, 3244, 292, 29889, 4899, 29898, 5182, 29922, 29888, 29892, 6389, 7607, 1445, 29892, 1723, 467, 2962, 580, 13, 13, 13, 361, 4770, 978, 1649, 1275, 525, 1649, 3396, 1649, 2396, 13, 1678, 11451, 1688, 29889, 3396, 29898, 3366, 29899, 29879, 613, 4770, 1445, 1649, 2314, 13, 2 ]
check_constraints/models.py
theju/django-check-constraints
4
107384
# Dummy models.py file to allow for tests to run from django.db import models class CCTestModel(models.Model): name = models.CharField(max_length=10) age = models.IntegerField() gender = models.CharField(max_length=10) price = models.PositiveIntegerField() discount = models.PositiveIntegerField() mfg_date = models.DateField() class Meta: constraints = ()
[ 1, 396, 360, 11770, 4733, 29889, 2272, 934, 304, 2758, 363, 6987, 304, 1065, 13, 3166, 9557, 29889, 2585, 1053, 4733, 13, 13, 1990, 315, 1783, 342, 3195, 29898, 9794, 29889, 3195, 1125, 13, 1678, 1024, 353, 4733, 29889, 27890, 29898, 3317, 29918, 2848, 29922, 29896, 29900, 29897, 13, 1678, 5046, 29871, 353, 4733, 29889, 7798, 3073, 580, 13, 1678, 23346, 353, 4733, 29889, 27890, 29898, 3317, 29918, 2848, 29922, 29896, 29900, 29897, 13, 1678, 8666, 353, 4733, 29889, 9135, 3321, 7798, 3073, 580, 13, 1678, 2313, 792, 353, 4733, 29889, 9135, 3321, 7798, 3073, 580, 13, 1678, 286, 16434, 29918, 1256, 353, 4733, 29889, 2539, 3073, 580, 13, 13, 1678, 770, 20553, 29901, 13, 4706, 11938, 353, 3861, 13, 2 ]
tests/test_channel.py
rwilhelm/aiormq
176
3426
import asyncio import uuid import pytest from aiomisc_pytest.pytest_plugin import TCPProxy import aiormq async def test_simple(amqp_channel: aiormq.Channel): await amqp_channel.basic_qos(prefetch_count=1) assert amqp_channel.number queue = asyncio.Queue() deaclare_ok = await amqp_channel.queue_declare(auto_delete=True) consume_ok = await amqp_channel.basic_consume(deaclare_ok.queue, queue.put) await amqp_channel.basic_publish( b"foo", routing_key=deaclare_ok.queue, properties=aiormq.spec.Basic.Properties(message_id="123"), ) message = await queue.get() # type: DeliveredMessage assert message.body == b"foo" cancel_ok = await amqp_channel.basic_cancel(consume_ok.consumer_tag) assert cancel_ok.consumer_tag == consume_ok.consumer_tag assert cancel_ok.consumer_tag not in amqp_channel.consumers await amqp_channel.queue_delete(deaclare_ok.queue) deaclare_ok = await amqp_channel.queue_declare(auto_delete=True) await amqp_channel.basic_publish(b"foo bar", routing_key=deaclare_ok.queue) message = await amqp_channel.basic_get(deaclare_ok.queue, no_ack=True) assert message.body == b"foo bar" async def test_blank_body(amqp_channel: aiormq.Channel): await amqp_channel.basic_qos(prefetch_count=1) assert amqp_channel.number queue = asyncio.Queue() deaclare_ok = await amqp_channel.queue_declare(auto_delete=True) consume_ok = await amqp_channel.basic_consume(deaclare_ok.queue, queue.put) await amqp_channel.basic_publish( b"", routing_key=deaclare_ok.queue, properties=aiormq.spec.Basic.Properties(message_id="123"), ) message = await queue.get() # type: DeliveredMessage assert message.body == b"" cancel_ok = await amqp_channel.basic_cancel(consume_ok.consumer_tag) assert cancel_ok.consumer_tag == consume_ok.consumer_tag assert cancel_ok.consumer_tag not in amqp_channel.consumers await amqp_channel.queue_delete(deaclare_ok.queue) deaclare_ok = await amqp_channel.queue_declare(auto_delete=True) await amqp_channel.basic_publish(b"foo bar", routing_key=deaclare_ok.queue) message = await amqp_channel.basic_get(deaclare_ok.queue, no_ack=True) assert message.body == b"foo bar" @pytest.mark.no_catch_loop_exceptions async def test_bad_consumer(amqp_channel: aiormq.Channel, loop): channel = amqp_channel # type: aiormq.Channel await channel.basic_qos(prefetch_count=1) declare_ok = await channel.queue_declare() future = loop.create_future() await channel.basic_publish(b"urgent", routing_key=declare_ok.queue) consumer_tag = loop.create_future() async def bad_consumer(message): await channel.basic_cancel(await consumer_tag) future.set_result(message) raise Exception consume_ok = await channel.basic_consume( declare_ok.queue, bad_consumer, no_ack=False, ) consumer_tag.set_result(consume_ok.consumer_tag) message = await future await channel.basic_reject(message.delivery.delivery_tag, requeue=True) assert message.body == b"urgent" future = loop.create_future() await channel.basic_consume( declare_ok.queue, future.set_result, no_ack=True, ) message = await future assert message.body == b"urgent" async def test_ack_nack_reject(amqp_channel: aiormq.Channel): channel = amqp_channel # type: aiormq.Channel await channel.basic_qos(prefetch_count=1) declare_ok = await channel.queue_declare(auto_delete=True) queue = asyncio.Queue() await channel.basic_consume(declare_ok.queue, queue.put, no_ack=False) await channel.basic_publish(b"rejected", routing_key=declare_ok.queue) message = await queue.get() assert message.body == b"rejected" await channel.basic_reject(message.delivery.delivery_tag, requeue=False) await channel.basic_publish(b"nacked", routing_key=declare_ok.queue) message = await queue.get() assert message.body == b"nacked" await channel.basic_nack(message.delivery.delivery_tag, requeue=False) await channel.basic_publish(b"acked", routing_key=declare_ok.queue) message = await queue.get() assert message.body == b"acked" await channel.basic_ack(message.delivery.delivery_tag) async def test_confirm_multiple(amqp_channel: aiormq.Channel): """ RabbitMQ has been observed to send confirmations in a strange pattern when publishing simultaneously where only some messages are delivered to a queue. It sends acks like this 1 2 4 5(multiple, confirming also 3). This test is probably inconsequential without publisher_confirms This is a regression for https://github.com/mosquito/aiormq/issues/10 """ channel = amqp_channel # type: aiormq.Channel exchange = uuid.uuid4().hex await channel.exchange_declare(exchange, exchange_type="topic") try: declare_ok = await channel.queue_declare(exclusive=True) await channel.queue_bind( declare_ok.queue, exchange, routing_key="test.5", ) for i in range(10): messages = [ asyncio.ensure_future(channel.basic_publish( b"test", exchange=exchange, routing_key="test.{}".format(i), )) for i in range(10) ] _, pending = await asyncio.wait(messages, timeout=0.2) assert not pending, "not all publishes were completed (confirmed)" await asyncio.sleep(0.05) finally: await channel.exchange_delete(exchange) async def test_exclusive_queue_locked(amqp_connection): channel0 = await amqp_connection.channel() channel1 = await amqp_connection.channel() qname = str(uuid.uuid4()) await channel0.queue_declare(qname, exclusive=True) try: await channel0.basic_consume(qname, print, exclusive=True) with pytest.raises(aiormq.exceptions.ChannelLockedResource): await channel1.queue_declare(qname) await channel1.basic_consume(qname, print, exclusive=True) finally: await channel0.queue_delete(qname) async def test_remove_writer_when_closed(amqp_channel: aiormq.Channel): with pytest.raises(aiormq.exceptions.ChannelClosed): await amqp_channel.queue_declare( "amq.forbidden_queue_name", auto_delete=True, ) with pytest.raises(aiormq.exceptions.ChannelInvalidStateError): await amqp_channel.queue_delete("amq.forbidden_queue_name") async def test_proxy_connection(proxy_connection, proxy: TCPProxy): channel = await proxy_connection.channel() # type: aiormq.Channel await channel.queue_declare(auto_delete=True) async def test_declare_queue_timeout(proxy_connection, proxy: TCPProxy): for _ in range(3): channel = await proxy_connection.channel() # type: aiormq.Channel qname = str(uuid.uuid4()) with proxy.slowdown(read_delay=5, write_delay=0): with pytest.raises(asyncio.TimeoutError): await channel.queue_declare( qname, auto_delete=True, timeout=0.5 )
[ 1, 1053, 408, 948, 3934, 13, 5215, 318, 5416, 13, 13, 5215, 11451, 1688, 13, 3166, 7468, 290, 10669, 29918, 2272, 1688, 29889, 2272, 1688, 29918, 8582, 1053, 19374, 14048, 13, 13, 5215, 7468, 555, 29939, 13, 13, 13, 12674, 822, 1243, 29918, 12857, 29898, 314, 29939, 29886, 29918, 12719, 29901, 7468, 555, 29939, 29889, 13599, 1125, 13, 1678, 7272, 626, 29939, 29886, 29918, 12719, 29889, 16121, 29918, 29939, 359, 29898, 29886, 999, 3486, 29918, 2798, 29922, 29896, 29897, 13, 1678, 4974, 626, 29939, 29886, 29918, 12719, 29889, 4537, 13, 13, 1678, 9521, 353, 408, 948, 3934, 29889, 10620, 580, 13, 13, 1678, 316, 562, 8663, 29918, 554, 353, 7272, 626, 29939, 29886, 29918, 12719, 29889, 9990, 29918, 7099, 8663, 29898, 6921, 29918, 8143, 29922, 5574, 29897, 13, 1678, 29151, 29918, 554, 353, 7272, 626, 29939, 29886, 29918, 12719, 29889, 16121, 29918, 3200, 2017, 29898, 311, 562, 8663, 29918, 554, 29889, 9990, 29892, 9521, 29889, 649, 29897, 13, 1678, 7272, 626, 29939, 29886, 29918, 12719, 29889, 16121, 29918, 23679, 29898, 13, 4706, 289, 29908, 5431, 613, 13, 4706, 21398, 29918, 1989, 29922, 311, 562, 8663, 29918, 554, 29889, 9990, 29892, 13, 4706, 4426, 29922, 1794, 555, 29939, 29889, 6550, 29889, 16616, 29889, 11857, 29898, 4906, 29918, 333, 543, 29896, 29906, 29941, 4968, 13, 1678, 1723, 13, 13, 1678, 2643, 353, 7272, 9521, 29889, 657, 580, 29871, 396, 1134, 29901, 5556, 2147, 287, 3728, 13, 1678, 4974, 2643, 29889, 2587, 1275, 289, 29908, 5431, 29908, 13, 13, 1678, 12611, 29918, 554, 353, 7272, 626, 29939, 29886, 29918, 12719, 29889, 16121, 29918, 20713, 29898, 3200, 2017, 29918, 554, 29889, 25978, 261, 29918, 4039, 29897, 13, 1678, 4974, 12611, 29918, 554, 29889, 25978, 261, 29918, 4039, 1275, 29151, 29918, 554, 29889, 25978, 261, 29918, 4039, 13, 1678, 4974, 12611, 29918, 554, 29889, 25978, 261, 29918, 4039, 451, 297, 626, 29939, 29886, 29918, 12719, 29889, 25978, 414, 13, 1678, 7272, 626, 29939, 29886, 29918, 12719, 29889, 9990, 29918, 8143, 29898, 311, 562, 8663, 29918, 554, 29889, 9990, 29897, 13, 13, 1678, 316, 562, 8663, 29918, 554, 353, 7272, 626, 29939, 29886, 29918, 12719, 29889, 9990, 29918, 7099, 8663, 29898, 6921, 29918, 8143, 29922, 5574, 29897, 13, 1678, 7272, 626, 29939, 29886, 29918, 12719, 29889, 16121, 29918, 23679, 29898, 29890, 29908, 5431, 2594, 613, 21398, 29918, 1989, 29922, 311, 562, 8663, 29918, 554, 29889, 9990, 29897, 13, 13, 1678, 2643, 353, 7272, 626, 29939, 29886, 29918, 12719, 29889, 16121, 29918, 657, 29898, 311, 562, 8663, 29918, 554, 29889, 9990, 29892, 694, 29918, 547, 29922, 5574, 29897, 13, 1678, 4974, 2643, 29889, 2587, 1275, 289, 29908, 5431, 2594, 29908, 13, 13, 13, 12674, 822, 1243, 29918, 19465, 29918, 2587, 29898, 314, 29939, 29886, 29918, 12719, 29901, 7468, 555, 29939, 29889, 13599, 1125, 13, 1678, 7272, 626, 29939, 29886, 29918, 12719, 29889, 16121, 29918, 29939, 359, 29898, 29886, 999, 3486, 29918, 2798, 29922, 29896, 29897, 13, 1678, 4974, 626, 29939, 29886, 29918, 12719, 29889, 4537, 13, 13, 1678, 9521, 353, 408, 948, 3934, 29889, 10620, 580, 13, 13, 1678, 316, 562, 8663, 29918, 554, 353, 7272, 626, 29939, 29886, 29918, 12719, 29889, 9990, 29918, 7099, 8663, 29898, 6921, 29918, 8143, 29922, 5574, 29897, 13, 1678, 29151, 29918, 554, 353, 7272, 626, 29939, 29886, 29918, 12719, 29889, 16121, 29918, 3200, 2017, 29898, 311, 562, 8663, 29918, 554, 29889, 9990, 29892, 9521, 29889, 649, 29897, 13, 1678, 7272, 626, 29939, 29886, 29918, 12719, 29889, 16121, 29918, 23679, 29898, 13, 4706, 289, 29908, 613, 13, 4706, 21398, 29918, 1989, 29922, 311, 562, 8663, 29918, 554, 29889, 9990, 29892, 13, 4706, 4426, 29922, 1794, 555, 29939, 29889, 6550, 29889, 16616, 29889, 11857, 29898, 4906, 29918, 333, 543, 29896, 29906, 29941, 4968, 13, 1678, 1723, 13, 13, 1678, 2643, 353, 7272, 9521, 29889, 657, 580, 29871, 396, 1134, 29901, 5556, 2147, 287, 3728, 13, 1678, 4974, 2643, 29889, 2587, 1275, 289, 15945, 13, 13, 1678, 12611, 29918, 554, 353, 7272, 626, 29939, 29886, 29918, 12719, 29889, 16121, 29918, 20713, 29898, 3200, 2017, 29918, 554, 29889, 25978, 261, 29918, 4039, 29897, 13, 1678, 4974, 12611, 29918, 554, 29889, 25978, 261, 29918, 4039, 1275, 29151, 29918, 554, 29889, 25978, 261, 29918, 4039, 13, 1678, 4974, 12611, 29918, 554, 29889, 25978, 261, 29918, 4039, 451, 297, 626, 29939, 29886, 29918, 12719, 29889, 25978, 414, 13, 1678, 7272, 626, 29939, 29886, 29918, 12719, 29889, 9990, 29918, 8143, 29898, 311, 562, 8663, 29918, 554, 29889, 9990, 29897, 13, 13, 1678, 316, 562, 8663, 29918, 554, 353, 7272, 626, 29939, 29886, 29918, 12719, 29889, 9990, 29918, 7099, 8663, 29898, 6921, 29918, 8143, 29922, 5574, 29897, 13, 1678, 7272, 626, 29939, 29886, 29918, 12719, 29889, 16121, 29918, 23679, 29898, 29890, 29908, 5431, 2594, 613, 21398, 29918, 1989, 29922, 311, 562, 8663, 29918, 554, 29889, 9990, 29897, 13, 13, 1678, 2643, 353, 7272, 626, 29939, 29886, 29918, 12719, 29889, 16121, 29918, 657, 29898, 311, 562, 8663, 29918, 554, 29889, 9990, 29892, 694, 29918, 547, 29922, 5574, 29897, 13, 1678, 4974, 2643, 29889, 2587, 1275, 289, 29908, 5431, 2594, 29908, 13, 13, 13, 29992, 2272, 1688, 29889, 3502, 29889, 1217, 29918, 12510, 29918, 7888, 29918, 11739, 29879, 13, 12674, 822, 1243, 29918, 12313, 29918, 25978, 261, 29898, 314, 29939, 29886, 29918, 12719, 29901, 7468, 555, 29939, 29889, 13599, 29892, 2425, 1125, 13, 1678, 8242, 353, 626, 29939, 29886, 29918, 12719, 29871, 396, 1134, 29901, 7468, 555, 29939, 29889, 13599, 13, 1678, 7272, 8242, 29889, 16121, 29918, 29939, 359, 29898, 29886, 999, 3486, 29918, 2798, 29922, 29896, 29897, 13, 13, 1678, 9607, 29918, 554, 353, 7272, 8242, 29889, 9990, 29918, 7099, 8663, 580, 13, 13, 1678, 5434, 353, 2425, 29889, 3258, 29918, 29888, 9130, 580, 13, 13, 1678, 7272, 8242, 29889, 16121, 29918, 23679, 29898, 29890, 29908, 2007, 296, 613, 21398, 29918, 1989, 29922, 7099, 8663, 29918, 554, 29889, 9990, 29897, 13, 13, 1678, 21691, 29918, 4039, 353, 2425, 29889, 3258, 29918, 29888, 9130, 580, 13, 13, 1678, 7465, 822, 4319, 29918, 25978, 261, 29898, 4906, 1125, 13, 4706, 7272, 8242, 29889, 16121, 29918, 20713, 29898, 20675, 21691, 29918, 4039, 29897, 13, 4706, 5434, 29889, 842, 29918, 2914, 29898, 4906, 29897, 13, 4706, 12020, 8960, 13, 13, 1678, 29151, 29918, 554, 353, 7272, 8242, 29889, 16121, 29918, 3200, 2017, 29898, 13, 4706, 9607, 29918, 554, 29889, 9990, 29892, 4319, 29918, 25978, 261, 29892, 694, 29918, 547, 29922, 8824, 29892, 13, 1678, 1723, 13, 13, 1678, 21691, 29918, 4039, 29889, 842, 29918, 2914, 29898, 3200, 2017, 29918, 554, 29889, 25978, 261, 29918, 4039, 29897, 13, 13, 1678, 2643, 353, 7272, 5434, 13, 1678, 7272, 8242, 29889, 16121, 29918, 276, 622, 29898, 4906, 29889, 29881, 27657, 29889, 29881, 27657, 29918, 4039, 29892, 337, 9990, 29922, 5574, 29897, 13, 1678, 4974, 2643, 29889, 2587, 1275, 289, 29908, 2007, 296, 29908, 13, 13, 1678, 5434, 353, 2425, 29889, 3258, 29918, 29888, 9130, 580, 13, 13, 1678, 7272, 8242, 29889, 16121, 29918, 3200, 2017, 29898, 13, 4706, 9607, 29918, 554, 29889, 9990, 29892, 5434, 29889, 842, 29918, 2914, 29892, 694, 29918, 547, 29922, 5574, 29892, 13, 1678, 1723, 13, 13, 1678, 2643, 353, 7272, 5434, 13, 13, 1678, 4974, 2643, 29889, 2587, 1275, 289, 29908, 2007, 296, 29908, 13, 13, 13, 12674, 822, 1243, 29918, 547, 29918, 29876, 547, 29918, 276, 622, 29898, 314, 29939, 29886, 29918, 12719, 29901, 7468, 555, 29939, 29889, 13599, 1125, 13, 1678, 8242, 353, 626, 29939, 29886, 29918, 12719, 29871, 396, 1134, 29901, 7468, 555, 29939, 29889, 13599, 13, 1678, 7272, 8242, 29889, 16121, 29918, 29939, 359, 29898, 29886, 999, 3486, 29918, 2798, 29922, 29896, 29897, 13, 13, 1678, 9607, 29918, 554, 353, 7272, 8242, 29889, 9990, 29918, 7099, 8663, 29898, 6921, 29918, 8143, 29922, 5574, 29897, 13, 1678, 9521, 353, 408, 948, 3934, 29889, 10620, 580, 13, 13, 1678, 7272, 8242, 29889, 16121, 29918, 3200, 2017, 29898, 7099, 8663, 29918, 554, 29889, 9990, 29892, 9521, 29889, 649, 29892, 694, 29918, 547, 29922, 8824, 29897, 13, 13, 1678, 7272, 8242, 29889, 16121, 29918, 23679, 29898, 29890, 29908, 276, 622, 287, 613, 21398, 29918, 1989, 29922, 7099, 8663, 29918, 554, 29889, 9990, 29897, 13, 1678, 2643, 353, 7272, 9521, 29889, 657, 580, 13, 1678, 4974, 2643, 29889, 2587, 1275, 289, 29908, 276, 622, 287, 29908, 13, 1678, 7272, 8242, 29889, 16121, 29918, 276, 622, 29898, 4906, 29889, 29881, 27657, 29889, 29881, 27657, 29918, 4039, 29892, 337, 9990, 29922, 8824, 29897, 13, 13, 1678, 7272, 8242, 29889, 16121, 29918, 23679, 29898, 29890, 29908, 29876, 547, 287, 613, 21398, 29918, 1989, 29922, 7099, 8663, 29918, 554, 29889, 9990, 29897, 13, 1678, 2643, 353, 7272, 9521, 29889, 657, 580, 13, 1678, 4974, 2643, 29889, 2587, 1275, 289, 29908, 29876, 547, 287, 29908, 13, 1678, 7272, 8242, 29889, 16121, 29918, 29876, 547, 29898, 4906, 29889, 29881, 27657, 29889, 29881, 27657, 29918, 4039, 29892, 337, 9990, 29922, 8824, 29897, 13, 13, 1678, 7272, 8242, 29889, 16121, 29918, 23679, 29898, 29890, 29908, 547, 287, 613, 21398, 29918, 1989, 29922, 7099, 8663, 29918, 554, 29889, 9990, 29897, 13, 1678, 2643, 353, 7272, 9521, 29889, 657, 580, 13, 1678, 4974, 2643, 29889, 2587, 1275, 289, 29908, 547, 287, 29908, 13, 1678, 7272, 8242, 29889, 16121, 29918, 547, 29898, 4906, 29889, 29881, 27657, 29889, 29881, 27657, 29918, 4039, 29897, 13, 13, 13, 12674, 822, 1243, 29918, 26897, 29918, 20787, 29898, 314, 29939, 29886, 29918, 12719, 29901, 7468, 555, 29939, 29889, 13599, 1125, 13, 1678, 9995, 13, 1678, 16155, 2966, 25566, 756, 1063, 8900, 304, 3638, 9659, 800, 297, 263, 8515, 4766, 13, 1678, 746, 27256, 21699, 988, 871, 777, 7191, 526, 20115, 13, 1678, 304, 263, 9521, 29889, 739, 16003, 263, 4684, 763, 445, 29871, 29896, 29871, 29906, 29871, 29946, 29871, 29945, 29898, 20787, 29892, 9659, 292, 884, 29871, 29941, 467, 13, 1678, 910, 1243, 338, 3117, 22629, 6831, 2556, 1728, 9805, 261, 29918, 5527, 381, 1516, 13, 1678, 910, 338, 263, 17855, 363, 2045, 597, 3292, 29889, 510, 29914, 7681, 339, 2049, 29914, 1794, 555, 29939, 29914, 12175, 29914, 29896, 29900, 13, 1678, 9995, 13, 1678, 8242, 353, 626, 29939, 29886, 29918, 12719, 29871, 396, 1134, 29901, 7468, 555, 29939, 29889, 13599, 13, 1678, 14523, 353, 318, 5416, 29889, 25118, 29946, 2141, 20970, 13, 1678, 7272, 8242, 29889, 6543, 29918, 7099, 8663, 29898, 6543, 29892, 14523, 29918, 1853, 543, 13010, 1159, 13, 1678, 1018, 29901, 13, 4706, 9607, 29918, 554, 353, 7272, 8242, 29889, 9990, 29918, 7099, 8663, 29898, 735, 7009, 573, 29922, 5574, 29897, 13, 4706, 7272, 8242, 29889, 9990, 29918, 5355, 29898, 13, 9651, 9607, 29918, 554, 29889, 9990, 29892, 14523, 29892, 21398, 29918, 1989, 543, 1688, 29889, 29945, 613, 13, 4706, 1723, 13, 13, 4706, 363, 474, 297, 3464, 29898, 29896, 29900, 1125, 13, 9651, 7191, 353, 518, 13, 18884, 408, 948, 3934, 29889, 7469, 29918, 29888, 9130, 29898, 12719, 29889, 16121, 29918, 23679, 29898, 13, 462, 1678, 289, 29908, 1688, 613, 14523, 29922, 6543, 29892, 21398, 29918, 1989, 543, 1688, 29889, 8875, 1642, 4830, 29898, 29875, 511, 13, 462, 876, 13, 18884, 363, 474, 297, 3464, 29898, 29896, 29900, 29897, 13, 9651, 4514, 13, 9651, 17117, 28235, 353, 7272, 408, 948, 3934, 29889, 10685, 29898, 19158, 29892, 11815, 29922, 29900, 29889, 29906, 29897, 13, 9651, 4974, 451, 28235, 29892, 376, 1333, 599, 9805, 267, 892, 8676, 313, 5527, 381, 2168, 5513, 13, 9651, 7272, 408, 948, 3934, 29889, 17059, 29898, 29900, 29889, 29900, 29945, 29897, 13, 1678, 7146, 29901, 13, 4706, 7272, 8242, 29889, 6543, 29918, 8143, 29898, 6543, 29897, 13, 13, 13, 12674, 822, 1243, 29918, 735, 7009, 573, 29918, 9990, 29918, 29113, 29898, 314, 29939, 29886, 29918, 9965, 1125, 13, 1678, 8242, 29900, 353, 7272, 626, 29939, 29886, 29918, 9965, 29889, 12719, 580, 13, 1678, 8242, 29896, 353, 7272, 626, 29939, 29886, 29918, 9965, 29889, 12719, 580, 13, 13, 1678, 3855, 978, 353, 851, 29898, 25118, 29889, 25118, 29946, 3101, 13, 13, 1678, 7272, 8242, 29900, 29889, 9990, 29918, 7099, 8663, 29898, 29939, 978, 29892, 29192, 29922, 5574, 29897, 13, 13, 1678, 1018, 29901, 13, 4706, 7272, 8242, 29900, 29889, 16121, 29918, 3200, 2017, 29898, 29939, 978, 29892, 1596, 29892, 29192, 29922, 5574, 29897, 13, 13, 4706, 411, 11451, 1688, 29889, 336, 4637, 29898, 1794, 555, 29939, 29889, 11739, 29879, 29889, 13599, 16542, 287, 6848, 1125, 13, 9651, 7272, 8242, 29896, 29889, 9990, 29918, 7099, 8663, 29898, 29939, 978, 29897, 13, 9651, 7272, 8242, 29896, 29889, 16121, 29918, 3200, 2017, 29898, 29939, 978, 29892, 1596, 29892, 29192, 29922, 5574, 29897, 13, 1678, 7146, 29901, 13, 4706, 7272, 8242, 29900, 29889, 9990, 29918, 8143, 29898, 29939, 978, 29897, 13, 13, 13, 12674, 822, 1243, 29918, 5992, 29918, 13236, 29918, 8256, 29918, 15603, 29898, 314, 29939, 29886, 29918, 12719, 29901, 7468, 555, 29939, 29889, 13599, 1125, 13, 1678, 411, 11451, 1688, 29889, 336, 4637, 29898, 1794, 555, 29939, 29889, 11739, 29879, 29889, 13599, 6821, 2662, 1125, 13, 4706, 7272, 626, 29939, 29886, 29918, 12719, 29889, 9990, 29918, 7099, 8663, 29898, 13, 9651, 376, 314, 29939, 29889, 1454, 29890, 4215, 29918, 9990, 29918, 978, 613, 4469, 29918, 8143, 29922, 5574, 29892, 13, 4706, 1723, 13, 13, 1678, 411, 11451, 1688, 29889, 336, 4637, 29898, 1794, 555, 29939, 29889, 11739, 29879, 29889, 13599, 13919, 2792, 2392, 1125, 13, 4706, 7272, 626, 29939, 29886, 29918, 12719, 29889, 9990, 29918, 8143, 703, 314, 29939, 29889, 1454, 29890, 4215, 29918, 9990, 29918, 978, 1159, 13, 13, 13, 12674, 822, 1243, 29918, 14701, 29918, 9965, 29898, 14701, 29918, 9965, 29892, 10166, 29901, 19374, 14048, 1125, 13, 1678, 8242, 353, 7272, 10166, 29918, 9965, 29889, 12719, 580, 29871, 396, 1134, 29901, 7468, 555, 29939, 29889, 13599, 13, 1678, 7272, 8242, 29889, 9990, 29918, 7099, 8663, 29898, 6921, 29918, 8143, 29922, 5574, 29897, 13, 13, 13, 12674, 822, 1243, 29918, 7099, 8663, 29918, 9990, 29918, 15619, 29898, 14701, 29918, 9965, 29892, 10166, 29901, 19374, 14048, 1125, 13, 1678, 363, 903, 297, 3464, 29898, 29941, 1125, 13, 4706, 8242, 353, 7272, 10166, 29918, 9965, 29889, 12719, 580, 29871, 396, 1134, 29901, 7468, 555, 29939, 29889, 13599, 13, 13, 4706, 3855, 978, 353, 851, 29898, 25118, 29889, 25118, 29946, 3101, 13, 13, 4706, 411, 10166, 29889, 28544, 3204, 29898, 949, 29918, 18829, 29922, 29945, 29892, 2436, 29918, 18829, 29922, 29900, 1125, 13, 9651, 411, 11451, 1688, 29889, 336, 4637, 29898, 294, 948, 3934, 29889, 10851, 2392, 1125, 13, 18884, 7272, 8242, 29889, 9990, 29918, 7099, 8663, 29898, 13, 462, 1678, 3855, 978, 29892, 4469, 29918, 8143, 29922, 5574, 29892, 11815, 29922, 29900, 29889, 29945, 13, 18884, 1723, 13, 2 ]
sumo/tools/contributed/sumopy/agilepy/lib_wx/test_app.py
iltempe/osmosi
0
1614205
<filename>sumo/tools/contributed/sumopy/agilepy/lib_wx/test_app.py import os import sys import wx from wx.lib.wordwrap import wordwrap if __name__ == '__main__': try: APPDIR = os.path.dirname(os.path.abspath(__file__)) except: APPDIR = os.path.dirname(os.path.abspath(sys.argv[0])) AGILEDIR = os.path.join(APPDIR, '..') print 'APPDIR,AGILEDIR', APPDIR, AGILEDIR sys.path.append(AGILEDIR) libpaths = [AGILEDIR, os.path.join( AGILEDIR, "lib_base"), os.path.join(AGILEDIR, "lib_wx"), ] for libpath in libpaths: print ' libpath=', libpath lp = os.path.abspath(libpath) if not lp in sys.path: # print ' append',lp sys.path.append(lp) from mainframe import * # import corepackages #from test_glcanvas import * from ogleditor import * ## ##import wx ## # try: ## dirName = os.path.dirname(os.path.abspath(__file__)) # except: ## dirName = os.path.dirname(os.path.abspath(sys.argv[0])) ## # sys.path.append(os.path.split(dirName)[0]) IMAGEDIR = os.path.join(os.path.dirname(__file__), "images") ICONPATH = os.path.join(IMAGEDIR, 'icon_color_small.png') # None class MyApp(wx.App): def __init__(self, redirect=False, filename=None): wx.App.__init__(self, redirect, filename) #self.frame = wx.Frame(None, wx.ID_ANY, title='My Title') self.mainframe = AgileMainframe( title='MyApp', size_toolbaricons=(32, 32)) if ICONPATH != None: icon = wx.Icon(ICONPATH, wx.BITMAP_TYPE_PNG, 16, 16) self.mainframe.SetIcon(icon) self.gleditor = self.mainframe.add_view("OGleditor", OGleditor) self.mainframe.Show() self.on_test() self.make_menu() self.make_toolbar() #canvas = gleditor.get_canvas() # canvas.add_element(lines) # canvas.add_element(triangles) # canvas.add_element(rectangles) def make_toolbar(self): tsize = self.mainframe.get_size_toolbaricons() new_bmp = wx.ArtProvider.GetBitmap(wx.ART_NEW, wx.ART_TOOLBAR, tsize) open_bmp = wx.ArtProvider.GetBitmap( wx.ART_FILE_OPEN, wx.ART_TOOLBAR, tsize) save_bmp = wx.ArtProvider.GetBitmap( wx.ART_FILE_SAVE, wx.ART_TOOLBAR, tsize) #cut_bmp = wx.ArtProvider.GetBitmap(wx.ART_CUT, wx.ART_TOOLBAR, tsize) #copy_bmp = wx.ArtProvider.GetBitmap(wx.ART_COPY, wx.ART_TOOLBAR, tsize) #paste_bmp= wx.ArtProvider.GetBitmap(wx.ART_PASTE, wx.ART_TOOLBAR, tsize) self.mainframe.add_tool('new', self.on_open, new_bmp, 'create new doc') self.mainframe.add_tool('open', self.on_open, open_bmp, 'Open doc') self.mainframe.add_tool('save', self.on_save, save_bmp, 'Save doc') # self.toolbar.AddSeparator() # self.add_tool('cut',self.on_open,cut_bmp,'Cut') # self.add_tool('copy',self.on_open,copy_bmp,'Copy') # self.add_tool('paste',self.on_open,paste_bmp,'Paste') def make_menu(self): self.mainframe.menubar.append_menu('file') self.mainframe.menubar.append_menu('file/doc') self.mainframe.menubar.append_item('file/doc/open', self.on_open, shortkey='Ctrl+o', info='open it out') self.mainframe.menubar.append_item('file/doc/save', self.on_save, shortkey='Ctrl+s', info='save it out') def on_save(self, event): print 'save it!!' def on_open(self, event): """Open a document""" #wildcards = CreateWildCards() + "All files (*.*)|*.*" print 'open it!!' def on_test(self, event=None): print '\non_test' vertices = np.array([ [[0.0, 0.0, 0.0], [0.2, 0.0, 0.0]], # 0 green [[0.0, 0.0, 0.0], [0.0, 0.9, 0.0]], # 1 red ]) colors = np.array([ [0.0, 0.9, 0.0, 0.9], # 0 [0.9, 0.0, 0.0, 0.9], # 1 ]) colors2 = np.array([ [0.5, 0.9, 0.5, 0.5], # 0 [0.9, 0.5, 0.9, 0.5], # 1 ]) colors2o = np.array([ [0.8, 0.9, 0.8, 0.9], # 0 [0.9, 0.8, 0.9, 0.9], # 1 ]) drawing = OGLdrawing() #------------------------------------------------------------------------- if 0: lines = Lines('lines', drawing) lines.add_drawobjs(vertices, colors) drawing.add_drawobj(lines) #------------------------------------------------------------------------- if 0: fancylines = Fancylines('fancylines', drawing) vertices_fancy = np.array([ [[0.0, -1.0, 0.0], [2, -1.0, 0.0]], # 0 green [[0.0, -1.0, 0.0], [0.0, -5.0, 0.0]], # 1 red ]) widths = [0.5, 0.3, ] # print ' vertices_fancy\n',vertices_fancy # FLATHEAD = 0 #BEVELHEAD = 1 #TRIANGLEHEAD = 2 #ARROWHEAD = 3 fancylines.add_drawobjs(vertices_fancy, widths, # width colors, beginstyles=[TRIANGLEHEAD, TRIANGLEHEAD], endstyles=[ARROWHEAD, ARROWHEAD]) drawing.add_drawobj(fancylines) #------------------------------------------------------------------------- if 0: polylines = Polylines('polylines', drawing, joinstyle=BEVELHEAD) colors_poly = np.array([ [0.0, 0.8, 0.5, 0.9], # 0 [0.8, 0.0, 0.5, 0.9], # 1 ]) vertices_poly = np.array([ [[0.0, 2.0, 0.0], [5.0, 2.0, 0.0], [ 5.0, 7.0, 0.0], [0.0, 7.0, 0.0]], # 0 green [[0.0, -2.0, 0.0], [-2.0, -2.0, 0.0]], # 1 red ], np.object) widths = [0.5, 0.3, ] # print ' vertices_poly\n',vertices_poly polylines.add_drawobjs(vertices_poly, widths, # width colors_poly, beginstyles=[ARROWHEAD, ARROWHEAD], endstyles=[ARROWHEAD, ARROWHEAD]) drawing.add_drawobj(polylines) #------------------------------------------------------------------------- if 1: polygons = Polygons('polygons', drawing, linewidth=5) colors_poly = np.array([ [0.0, 0.9, 0.9, 0.9], # 0 [0.8, 0.2, 0.2, 0.9], # 1 ]) vertices_poly = np.array([ [[0.0, 2.0, 0.0], [5.0, 2.0, 0.0], [ 5.0, 7.0, 0.0], [0.0, 7.0, 0.0]], # 0 green [[0.0, -2.0, 0.0], [-2.0, -2.0, 0.0], [-2.0, 0.0, 0.0]], # 1 red ], np.object) print ' vertices_polygon\n', vertices_poly polygons.add_drawobjs(vertices_poly, colors_poly) drawing.add_drawobj(polygons) canvas = self.gleditor.get_canvas() canvas.set_drawing(drawing) #lines.add_drawobj([[0.0,0.0,0.0],[-0.2,-0.8,0.0]], [0.0,0.9,0.9,0.9]) #circles.add_drawobj([1.5,0.0,0.0],0.6,colors2o[0], colors2[0]) # canvas.zoom_tofit() wx.CallAfter(canvas.zoom_tofit) if __name__ == '__main__': # if len(sys.argv)==3: # ident = sys.argv[1] # dirpath = sys.argv[2] # else: # ident = None # dirpath = None myapp = MyApp(0) myapp.MainLoop()
[ 1, 529, 9507, 29958, 2083, 29877, 29914, 8504, 29914, 1285, 7541, 29914, 2083, 2270, 29914, 351, 488, 2272, 29914, 1982, 29918, 23310, 29914, 1688, 29918, 932, 29889, 2272, 13, 5215, 2897, 13, 5215, 10876, 13, 13, 5215, 26437, 13, 3166, 26437, 29889, 1982, 29889, 1742, 6312, 1053, 1734, 6312, 13, 13, 13, 361, 4770, 978, 1649, 1275, 525, 1649, 3396, 1649, 2396, 13, 1678, 1018, 29901, 13, 4706, 12279, 29925, 9464, 353, 2897, 29889, 2084, 29889, 25721, 29898, 359, 29889, 2084, 29889, 370, 1028, 493, 22168, 1445, 1649, 876, 13, 1678, 5174, 29901, 13, 4706, 12279, 29925, 9464, 353, 2897, 29889, 2084, 29889, 25721, 29898, 359, 29889, 2084, 29889, 370, 1028, 493, 29898, 9675, 29889, 19218, 29961, 29900, 12622, 13, 1678, 16369, 29902, 1307, 9464, 353, 2897, 29889, 2084, 29889, 7122, 29898, 20576, 9464, 29892, 525, 636, 1495, 13, 1678, 1596, 525, 20576, 9464, 29892, 10051, 29902, 1307, 9464, 742, 12279, 29925, 9464, 29892, 16369, 29902, 1307, 9464, 13, 1678, 10876, 29889, 2084, 29889, 4397, 29898, 10051, 29902, 1307, 9464, 29897, 13, 1678, 4303, 24772, 353, 518, 10051, 29902, 1307, 9464, 29892, 2897, 29889, 2084, 29889, 7122, 29898, 13, 4706, 16369, 29902, 1307, 9464, 29892, 376, 1982, 29918, 3188, 4968, 2897, 29889, 2084, 29889, 7122, 29898, 10051, 29902, 1307, 9464, 29892, 376, 1982, 29918, 23310, 4968, 4514, 13, 1678, 363, 4303, 2084, 297, 4303, 24772, 29901, 13, 4706, 1596, 525, 29871, 4303, 2084, 29922, 742, 4303, 2084, 13, 4706, 301, 29886, 353, 2897, 29889, 2084, 29889, 370, 1028, 493, 29898, 1982, 2084, 29897, 13, 4706, 565, 451, 301, 29886, 297, 10876, 29889, 2084, 29901, 13, 9651, 396, 1596, 525, 9773, 742, 22833, 13, 9651, 10876, 29889, 2084, 29889, 4397, 29898, 22833, 29897, 13, 13, 3166, 1667, 2557, 1053, 334, 13, 13, 29937, 1053, 7136, 8318, 13, 29937, 3166, 1243, 29918, 3820, 15257, 1053, 334, 13, 3166, 3671, 839, 2105, 1053, 334, 13, 2277, 13, 2277, 5215, 26437, 13, 2277, 13, 13, 29937, 1018, 29901, 13, 2277, 1678, 4516, 1170, 353, 2897, 29889, 2084, 29889, 25721, 29898, 359, 29889, 2084, 29889, 370, 1028, 493, 22168, 1445, 1649, 876, 13, 29937, 5174, 29901, 13, 2277, 1678, 4516, 1170, 353, 2897, 29889, 2084, 29889, 25721, 29898, 359, 29889, 2084, 29889, 370, 1028, 493, 29898, 9675, 29889, 19218, 29961, 29900, 12622, 13, 2277, 13, 29937, 10876, 29889, 2084, 29889, 4397, 29898, 359, 29889, 2084, 29889, 5451, 29898, 3972, 1170, 9601, 29900, 2314, 13, 13, 13, 2382, 9464, 353, 2897, 29889, 2084, 29889, 7122, 29898, 359, 29889, 2084, 29889, 25721, 22168, 1445, 1649, 511, 376, 8346, 1159, 13, 2965, 1164, 10145, 353, 2897, 29889, 2084, 29889, 7122, 29898, 2382, 9464, 29892, 525, 4144, 29918, 2780, 29918, 9278, 29889, 2732, 1495, 29871, 396, 6213, 13, 13, 13, 1990, 1619, 2052, 29898, 23310, 29889, 2052, 1125, 13, 13, 1678, 822, 4770, 2344, 12035, 1311, 29892, 6684, 29922, 8824, 29892, 10422, 29922, 8516, 1125, 13, 4706, 26437, 29889, 2052, 17255, 2344, 12035, 1311, 29892, 6684, 29892, 10422, 29897, 13, 4706, 396, 1311, 29889, 2557, 353, 26437, 29889, 4308, 29898, 8516, 29892, 26437, 29889, 1367, 29918, 2190, 29979, 29892, 3611, 2433, 3421, 18527, 1495, 13, 4706, 1583, 29889, 3396, 2557, 353, 4059, 488, 6330, 2557, 29898, 13, 9651, 3611, 2433, 3421, 2052, 742, 2159, 29918, 10154, 1646, 27078, 7607, 29941, 29906, 29892, 29871, 29941, 29906, 876, 13, 4706, 565, 306, 6007, 10145, 2804, 6213, 29901, 13, 9651, 9849, 353, 26437, 29889, 12492, 29898, 2965, 1164, 10145, 29892, 26437, 29889, 22698, 23827, 29918, 11116, 29918, 29925, 9312, 29892, 29871, 29896, 29953, 29892, 29871, 29896, 29953, 29897, 13, 9651, 1583, 29889, 3396, 2557, 29889, 2697, 12492, 29898, 4144, 29897, 13, 13, 4706, 1583, 29889, 29887, 839, 2105, 353, 1583, 29889, 3396, 2557, 29889, 1202, 29918, 1493, 703, 29949, 29954, 839, 2105, 613, 438, 29954, 839, 2105, 29897, 13, 13, 4706, 1583, 29889, 3396, 2557, 29889, 8964, 580, 13, 4706, 1583, 29889, 265, 29918, 1688, 580, 13, 4706, 1583, 29889, 5675, 29918, 6510, 580, 13, 4706, 1583, 29889, 5675, 29918, 10154, 1646, 580, 13, 4706, 396, 15257, 353, 330, 839, 2105, 29889, 657, 29918, 15257, 580, 13, 4706, 396, 10508, 29889, 1202, 29918, 5029, 29898, 9012, 29897, 13, 4706, 396, 10508, 29889, 1202, 29918, 5029, 29898, 3626, 19536, 29897, 13, 4706, 396, 10508, 29889, 1202, 29918, 5029, 29898, 1621, 19536, 29897, 13, 13, 1678, 822, 1207, 29918, 10154, 1646, 29898, 1311, 1125, 13, 4706, 260, 2311, 353, 1583, 29889, 3396, 2557, 29889, 657, 29918, 2311, 29918, 10154, 1646, 27078, 580, 13, 4706, 716, 29918, 29890, 1526, 353, 26437, 29889, 9986, 6980, 29889, 2577, 15184, 29898, 23310, 29889, 8322, 29918, 28577, 29892, 26437, 29889, 8322, 29918, 4986, 5607, 29933, 1718, 29892, 260, 2311, 29897, 13, 4706, 1722, 29918, 29890, 1526, 353, 26437, 29889, 9986, 6980, 29889, 2577, 15184, 29898, 13, 9651, 26437, 29889, 8322, 29918, 7724, 29918, 4590, 1430, 29892, 26437, 29889, 8322, 29918, 4986, 5607, 29933, 1718, 29892, 260, 2311, 29897, 13, 4706, 4078, 29918, 29890, 1526, 353, 26437, 29889, 9986, 6980, 29889, 2577, 15184, 29898, 13, 9651, 26437, 29889, 8322, 29918, 7724, 29918, 29903, 7520, 29923, 29892, 26437, 29889, 8322, 29918, 4986, 5607, 29933, 1718, 29892, 260, 2311, 29897, 13, 4706, 396, 7582, 29918, 29890, 1526, 353, 26437, 29889, 9986, 6980, 29889, 2577, 15184, 29898, 23310, 29889, 8322, 29918, 29907, 2692, 29892, 26437, 29889, 8322, 29918, 4986, 5607, 29933, 1718, 29892, 260, 2311, 29897, 13, 4706, 396, 8552, 29918, 29890, 1526, 353, 26437, 29889, 9986, 6980, 29889, 2577, 15184, 29898, 23310, 29889, 8322, 29918, 3217, 20055, 29892, 26437, 29889, 8322, 29918, 4986, 5607, 29933, 1718, 29892, 260, 2311, 29897, 13, 4706, 396, 16179, 29918, 29890, 1526, 29922, 26437, 29889, 9986, 6980, 29889, 2577, 15184, 29898, 23310, 29889, 8322, 29918, 7228, 1254, 29923, 29892, 26437, 29889, 8322, 29918, 4986, 5607, 29933, 1718, 29892, 260, 2311, 29897, 13, 13, 4706, 1583, 29889, 3396, 2557, 29889, 1202, 29918, 10154, 877, 1482, 742, 1583, 29889, 265, 29918, 3150, 29892, 716, 29918, 29890, 1526, 29892, 525, 3258, 716, 1574, 1495, 13, 4706, 1583, 29889, 3396, 2557, 29889, 1202, 29918, 10154, 877, 3150, 742, 1583, 29889, 265, 29918, 3150, 29892, 1722, 29918, 29890, 1526, 29892, 525, 6585, 1574, 1495, 13, 4706, 1583, 29889, 3396, 2557, 29889, 1202, 29918, 10154, 877, 7620, 742, 1583, 29889, 265, 29918, 7620, 29892, 4078, 29918, 29890, 1526, 29892, 525, 11371, 1574, 1495, 13, 4706, 396, 1583, 29889, 10154, 1646, 29889, 2528, 2008, 17954, 580, 13, 4706, 396, 1583, 29889, 1202, 29918, 10154, 877, 7582, 742, 1311, 29889, 265, 29918, 3150, 29892, 7582, 29918, 29890, 1526, 5501, 29907, 329, 1495, 13, 4706, 396, 1583, 29889, 1202, 29918, 10154, 877, 8552, 742, 1311, 29889, 265, 29918, 3150, 29892, 8552, 29918, 29890, 1526, 5501, 11882, 1495, 13, 4706, 396, 1583, 29889, 1202, 29918, 10154, 877, 16179, 742, 1311, 29889, 265, 29918, 3150, 29892, 16179, 29918, 29890, 1526, 5501, 29925, 4350, 1495, 13, 13, 1678, 822, 1207, 29918, 6510, 29898, 1311, 1125, 13, 4706, 1583, 29889, 3396, 2557, 29889, 1527, 431, 279, 29889, 4397, 29918, 6510, 877, 1445, 1495, 13, 4706, 1583, 29889, 3396, 2557, 29889, 1527, 431, 279, 29889, 4397, 29918, 6510, 877, 1445, 29914, 1514, 1495, 13, 13, 4706, 1583, 29889, 3396, 2557, 29889, 1527, 431, 279, 29889, 4397, 29918, 667, 877, 1445, 29914, 1514, 29914, 3150, 742, 1583, 29889, 265, 29918, 3150, 29892, 13, 462, 462, 965, 3273, 1989, 2433, 18069, 29974, 29877, 742, 5235, 2433, 3150, 372, 714, 1495, 13, 13, 4706, 1583, 29889, 3396, 2557, 29889, 1527, 431, 279, 29889, 4397, 29918, 667, 877, 1445, 29914, 1514, 29914, 7620, 742, 1583, 29889, 265, 29918, 7620, 29892, 13, 462, 462, 965, 3273, 1989, 2433, 18069, 29974, 29879, 742, 5235, 2433, 7620, 372, 714, 1495, 13, 13, 1678, 822, 373, 29918, 7620, 29898, 1311, 29892, 1741, 1125, 13, 4706, 1596, 525, 7620, 372, 6824, 29915, 13, 13, 1678, 822, 373, 29918, 3150, 29898, 1311, 29892, 1741, 1125, 13, 4706, 9995, 6585, 263, 1842, 15945, 29908, 13, 4706, 396, 29893, 789, 28160, 353, 6204, 29956, 789, 29907, 3163, 580, 718, 376, 3596, 2066, 3070, 5575, 10531, 29930, 5575, 29908, 13, 4706, 1596, 525, 3150, 372, 6824, 29915, 13, 13, 1678, 822, 373, 29918, 1688, 29898, 1311, 29892, 1741, 29922, 8516, 1125, 13, 4706, 1596, 11297, 5464, 29918, 1688, 29915, 13, 4706, 13791, 353, 7442, 29889, 2378, 4197, 13, 9651, 5519, 29900, 29889, 29900, 29892, 29871, 29900, 29889, 29900, 29892, 29871, 29900, 29889, 29900, 1402, 518, 29900, 29889, 29906, 29892, 29871, 29900, 29889, 29900, 29892, 29871, 29900, 29889, 29900, 20526, 29871, 396, 29871, 29900, 7933, 13, 9651, 5519, 29900, 29889, 29900, 29892, 29871, 29900, 29889, 29900, 29892, 29871, 29900, 29889, 29900, 1402, 518, 29900, 29889, 29900, 29892, 29871, 29900, 29889, 29929, 29892, 29871, 29900, 29889, 29900, 20526, 29871, 396, 29871, 29896, 2654, 13, 308, 2314, 13, 13, 4706, 11955, 353, 7442, 29889, 2378, 4197, 13, 9651, 518, 29900, 29889, 29900, 29892, 29871, 29900, 29889, 29929, 29892, 29871, 29900, 29889, 29900, 29892, 29871, 29900, 29889, 29929, 1402, 1678, 396, 29871, 29900, 13, 9651, 518, 29900, 29889, 29929, 29892, 29871, 29900, 29889, 29900, 29892, 29871, 29900, 29889, 29900, 29892, 29871, 29900, 29889, 29929, 1402, 1678, 396, 29871, 29896, 13, 308, 2314, 13, 13, 4706, 11955, 29906, 353, 7442, 29889, 2378, 4197, 13, 9651, 518, 29900, 29889, 29945, 29892, 29871, 29900, 29889, 29929, 29892, 29871, 29900, 29889, 29945, 29892, 29871, 29900, 29889, 29945, 1402, 1678, 396, 29871, 29900, 13, 9651, 518, 29900, 29889, 29929, 29892, 29871, 29900, 29889, 29945, 29892, 29871, 29900, 29889, 29929, 29892, 29871, 29900, 29889, 29945, 1402, 1678, 396, 29871, 29896, 13, 308, 2314, 13, 4706, 11955, 29906, 29877, 353, 7442, 29889, 2378, 4197, 13, 9651, 518, 29900, 29889, 29947, 29892, 29871, 29900, 29889, 29929, 29892, 29871, 29900, 29889, 29947, 29892, 29871, 29900, 29889, 29929, 1402, 1678, 396, 29871, 29900, 13, 9651, 518, 29900, 29889, 29929, 29892, 29871, 29900, 29889, 29947, 29892, 29871, 29900, 29889, 29929, 29892, 29871, 29900, 29889, 29929, 1402, 1678, 396, 29871, 29896, 13, 308, 2314, 13, 13, 4706, 11580, 353, 438, 7239, 4012, 292, 580, 13, 29937, 2683, 2683, 2683, 2683, 1378, 29899, 13, 13, 4706, 565, 29871, 29900, 29901, 13, 9651, 3454, 353, 365, 1475, 877, 9012, 742, 11580, 29897, 13, 9651, 3454, 29889, 1202, 29918, 4012, 711, 1315, 29898, 1765, 1575, 29892, 11955, 29897, 13, 9651, 11580, 29889, 1202, 29918, 4012, 5415, 29898, 9012, 29897, 13, 29937, 2683, 2683, 2683, 2683, 1378, 29899, 13, 4706, 565, 29871, 29900, 29901, 13, 9651, 19231, 9012, 353, 383, 6906, 9012, 877, 29888, 6906, 9012, 742, 11580, 29897, 13, 9651, 13791, 29918, 29888, 6906, 353, 7442, 29889, 2378, 4197, 13, 18884, 5519, 29900, 29889, 29900, 29892, 448, 29896, 29889, 29900, 29892, 29871, 29900, 29889, 29900, 1402, 518, 29906, 29892, 448, 29896, 29889, 29900, 29892, 29871, 29900, 29889, 29900, 20526, 29871, 396, 29871, 29900, 7933, 13, 18884, 5519, 29900, 29889, 29900, 29892, 448, 29896, 29889, 29900, 29892, 29871, 29900, 29889, 29900, 1402, 518, 29900, 29889, 29900, 29892, 448, 29945, 29889, 29900, 29892, 29871, 29900, 29889, 29900, 20526, 29871, 396, 29871, 29896, 2654, 13, 632, 2314, 13, 13, 9651, 2920, 29879, 353, 518, 29900, 29889, 29945, 29892, 13, 462, 539, 29900, 29889, 29941, 29892, 13, 462, 418, 4514, 13, 9651, 396, 1596, 525, 29871, 13791, 29918, 29888, 6906, 29905, 29876, 742, 1765, 1575, 29918, 29888, 6906, 13, 9651, 396, 383, 29931, 7534, 29923, 3035, 353, 29871, 29900, 13, 9651, 396, 15349, 29963, 6670, 23252, 353, 29871, 29896, 13, 9651, 396, 29911, 3960, 19453, 1307, 23252, 353, 29871, 29906, 13, 9651, 396, 1718, 25180, 23252, 353, 29871, 29941, 13, 9651, 19231, 9012, 29889, 1202, 29918, 4012, 711, 1315, 29898, 1765, 1575, 29918, 29888, 6906, 29892, 13, 462, 462, 1678, 2920, 29879, 29892, 29871, 396, 2920, 13, 462, 462, 1678, 11955, 29892, 13, 462, 462, 1678, 1812, 2611, 5577, 11759, 29911, 3960, 19453, 1307, 23252, 29892, 323, 3960, 19453, 1307, 23252, 1402, 13, 462, 462, 1678, 1095, 9783, 11759, 1718, 25180, 23252, 29892, 9033, 25180, 23252, 2314, 13, 9651, 11580, 29889, 1202, 29918, 4012, 5415, 29898, 29888, 6906, 9012, 29897, 13, 29937, 2683, 2683, 2683, 2683, 1378, 29899, 13, 4706, 565, 29871, 29900, 29901, 13, 9651, 1248, 2904, 1475, 353, 2043, 2904, 1475, 877, 3733, 2904, 1475, 742, 11580, 29892, 2958, 2611, 1508, 29922, 15349, 29963, 6670, 23252, 29897, 13, 9651, 11955, 29918, 22678, 353, 7442, 29889, 2378, 4197, 13, 18884, 518, 29900, 29889, 29900, 29892, 29871, 29900, 29889, 29947, 29892, 29871, 29900, 29889, 29945, 29892, 29871, 29900, 29889, 29929, 1402, 1678, 396, 29871, 29900, 13, 18884, 518, 29900, 29889, 29947, 29892, 29871, 29900, 29889, 29900, 29892, 29871, 29900, 29889, 29945, 29892, 29871, 29900, 29889, 29929, 1402, 1678, 396, 29871, 29896, 13, 632, 2314, 13, 13, 9651, 13791, 29918, 22678, 353, 7442, 29889, 2378, 4197, 13, 18884, 5519, 29900, 29889, 29900, 29892, 29871, 29906, 29889, 29900, 29892, 29871, 29900, 29889, 29900, 1402, 518, 29945, 29889, 29900, 29892, 29871, 29906, 29889, 29900, 29892, 29871, 29900, 29889, 29900, 1402, 518, 13, 462, 268, 29945, 29889, 29900, 29892, 29871, 29955, 29889, 29900, 29892, 29871, 29900, 29889, 29900, 1402, 518, 29900, 29889, 29900, 29892, 29871, 29955, 29889, 29900, 29892, 29871, 29900, 29889, 29900, 20526, 29871, 396, 29871, 29900, 7933, 13, 18884, 5519, 29900, 29889, 29900, 29892, 448, 29906, 29889, 29900, 29892, 29871, 29900, 29889, 29900, 1402, 21069, 29906, 29889, 29900, 29892, 448, 29906, 29889, 29900, 29892, 29871, 29900, 29889, 29900, 20526, 29871, 396, 29871, 29896, 2654, 13, 9651, 21251, 7442, 29889, 3318, 29897, 13, 13, 9651, 2920, 29879, 353, 518, 29900, 29889, 29945, 29892, 13, 462, 539, 29900, 29889, 29941, 29892, 13, 462, 418, 4514, 13, 9651, 396, 1596, 525, 29871, 13791, 29918, 22678, 29905, 29876, 742, 1765, 1575, 29918, 22678, 13, 9651, 1248, 2904, 1475, 29889, 1202, 29918, 4012, 711, 1315, 29898, 1765, 1575, 29918, 22678, 29892, 13, 462, 462, 259, 2920, 29879, 29892, 29871, 396, 2920, 13, 462, 462, 259, 11955, 29918, 22678, 29892, 13, 462, 462, 259, 1812, 2611, 5577, 11759, 1718, 25180, 23252, 29892, 9033, 25180, 23252, 1402, 13, 462, 462, 259, 1095, 9783, 11759, 1718, 25180, 23252, 29892, 9033, 25180, 23252, 2314, 13, 9651, 11580, 29889, 1202, 29918, 4012, 5415, 29898, 3733, 2904, 1475, 29897, 13, 13, 29937, 2683, 2683, 2683, 2683, 1378, 29899, 13, 4706, 565, 29871, 29896, 29901, 13, 9651, 1248, 4790, 787, 353, 2043, 4790, 787, 877, 3733, 4790, 787, 742, 11580, 29892, 1196, 2103, 29922, 29945, 29897, 13, 9651, 11955, 29918, 22678, 353, 7442, 29889, 2378, 4197, 13, 18884, 518, 29900, 29889, 29900, 29892, 29871, 29900, 29889, 29929, 29892, 29871, 29900, 29889, 29929, 29892, 29871, 29900, 29889, 29929, 1402, 1678, 396, 29871, 29900, 13, 18884, 518, 29900, 29889, 29947, 29892, 29871, 29900, 29889, 29906, 29892, 29871, 29900, 29889, 29906, 29892, 29871, 29900, 29889, 29929, 1402, 1678, 396, 29871, 29896, 13, 632, 2314, 13, 13, 9651, 13791, 29918, 22678, 353, 7442, 29889, 2378, 4197, 13, 18884, 5519, 29900, 29889, 29900, 29892, 29871, 29906, 29889, 29900, 29892, 29871, 29900, 29889, 29900, 1402, 518, 29945, 29889, 29900, 29892, 29871, 29906, 29889, 29900, 29892, 29871, 29900, 29889, 29900, 1402, 518, 13, 462, 268, 29945, 29889, 29900, 29892, 29871, 29955, 29889, 29900, 29892, 29871, 29900, 29889, 29900, 1402, 518, 29900, 29889, 29900, 29892, 29871, 29955, 29889, 29900, 29892, 29871, 29900, 29889, 29900, 20526, 29871, 396, 29871, 29900, 7933, 13, 18884, 5519, 29900, 29889, 29900, 29892, 448, 29906, 29889, 29900, 29892, 29871, 29900, 29889, 29900, 1402, 21069, 29906, 29889, 29900, 29892, 448, 29906, 29889, 29900, 29892, 29871, 29900, 29889, 29900, 1402, 13, 462, 21069, 29906, 29889, 29900, 29892, 29871, 29900, 29889, 29900, 29892, 29871, 29900, 29889, 29900, 20526, 29871, 396, 29871, 29896, 2654, 13, 9651, 21251, 7442, 29889, 3318, 29897, 13, 13, 9651, 1596, 525, 29871, 13791, 29918, 3733, 17125, 29905, 29876, 742, 13791, 29918, 22678, 13, 9651, 1248, 4790, 787, 29889, 1202, 29918, 4012, 711, 1315, 29898, 1765, 1575, 29918, 22678, 29892, 13, 462, 462, 29871, 11955, 29918, 22678, 29897, 13, 9651, 11580, 29889, 1202, 29918, 4012, 5415, 29898, 3733, 4790, 787, 29897, 13, 13, 4706, 10508, 353, 1583, 29889, 29887, 839, 2105, 29889, 657, 29918, 15257, 580, 13, 4706, 10508, 29889, 842, 29918, 4012, 292, 29898, 4012, 292, 29897, 13, 13, 4706, 396, 9012, 29889, 1202, 29918, 4012, 5415, 4197, 29961, 29900, 29889, 29900, 29892, 29900, 29889, 29900, 29892, 29900, 29889, 29900, 1402, 14352, 29900, 29889, 29906, 6653, 29900, 29889, 29947, 29892, 29900, 29889, 29900, 20526, 518, 29900, 29889, 29900, 29892, 29900, 29889, 29929, 29892, 29900, 29889, 29929, 29892, 29900, 29889, 29929, 2314, 13, 4706, 396, 19052, 7799, 29889, 1202, 29918, 4012, 5415, 4197, 29896, 29889, 29945, 29892, 29900, 29889, 29900, 29892, 29900, 29889, 29900, 1402, 29900, 29889, 29953, 29892, 27703, 29906, 29877, 29961, 29900, 1402, 11955, 29906, 29961, 29900, 2314, 13, 13, 4706, 396, 10508, 29889, 2502, 290, 29918, 517, 9202, 580, 13, 4706, 26437, 29889, 5594, 13555, 29898, 15257, 29889, 2502, 290, 29918, 517, 9202, 29897, 13, 13, 13, 361, 4770, 978, 1649, 1275, 525, 1649, 3396, 1649, 2396, 13, 1678, 396, 565, 7431, 29898, 9675, 29889, 19218, 29897, 1360, 29941, 29901, 13, 1678, 396, 1678, 2893, 353, 10876, 29889, 19218, 29961, 29896, 29962, 13, 1678, 396, 1678, 4516, 2084, 353, 10876, 29889, 19218, 29961, 29906, 29962, 13, 1678, 396, 1683, 29901, 13, 1678, 396, 1678, 2893, 353, 29871, 6213, 13, 1678, 396, 1678, 4516, 2084, 353, 6213, 13, 1678, 590, 932, 353, 1619, 2052, 29898, 29900, 29897, 13, 13, 1678, 590, 932, 29889, 6330, 18405, 580, 13, 2 ]
rubi/datasets/vqa2.py
abhipsabasu/rubi.bootstrap.pytorch
83
16521
<reponame>abhipsabasu/rubi.bootstrap.pytorch import os import csv import copy import json import torch import numpy as np from os import path as osp from bootstrap.lib.logger import Logger from bootstrap.lib.options import Options from block.datasets.vqa_utils import AbstractVQA from copy import deepcopy import random import tqdm import h5py class VQA2(AbstractVQA): def __init__(self, dir_data='data/vqa2', split='train', batch_size=10, nb_threads=4, pin_memory=False, shuffle=False, nans=1000, minwcount=10, nlp='mcb', proc_split='train', samplingans=False, dir_rcnn='data/coco/extract_rcnn', adversarial=False, dir_cnn=None ): super(VQA2, self).__init__( dir_data=dir_data, split=split, batch_size=batch_size, nb_threads=nb_threads, pin_memory=pin_memory, shuffle=shuffle, nans=nans, minwcount=minwcount, nlp=nlp, proc_split=proc_split, samplingans=samplingans, has_valset=True, has_testset=True, has_answers_occurence=True, do_tokenize_answers=False) self.dir_rcnn = dir_rcnn self.dir_cnn = dir_cnn self.load_image_features() # to activate manually in visualization context (notebo# to activate manually in visualization context (notebook) self.load_original_annotation = False def add_rcnn_to_item(self, item): path_rcnn = os.path.join(self.dir_rcnn, '{}.pth'.format(item['image_name'])) item_rcnn = torch.load(path_rcnn) item['visual'] = item_rcnn['pooled_feat'] item['coord'] = item_rcnn['rois'] item['norm_coord'] = item_rcnn.get('norm_rois', None) item['nb_regions'] = item['visual'].size(0) return item def add_cnn_to_item(self, item): image_name = item['image_name'] if image_name in self.image_names_to_index_train: index = self.image_names_to_index_train[image_name] image = torch.tensor(self.image_features_train['att'][index]) elif image_name in self.image_names_to_index_val: index = self.image_names_to_index_val[image_name] image = torch.tensor(self.image_features_val['att'][index]) image = image.permute(1, 2, 0).view(196, 2048) item['visual'] = image return item def load_image_features(self): if self.dir_cnn: filename_train = os.path.join(self.dir_cnn, 'trainset.hdf5') filename_val = os.path.join(self.dir_cnn, 'valset.hdf5') Logger()(f"Opening file {filename_train}, {filename_val}") self.image_features_train = h5py.File(filename_train, 'r', swmr=True) self.image_features_val = h5py.File(filename_val, 'r', swmr=True) # load txt with open(os.path.join(self.dir_cnn, 'trainset.txt'.format(self.split)), 'r') as f: self.image_names_to_index_train = {} for i, line in enumerate(f): self.image_names_to_index_train[line.strip()] = i with open(os.path.join(self.dir_cnn, 'valset.txt'.format(self.split)), 'r') as f: self.image_names_to_index_val = {} for i, line in enumerate(f): self.image_names_to_index_val[line.strip()] = i def __getitem__(self, index): item = {} item['index'] = index # Process Question (word token) question = self.dataset['questions'][index] if self.load_original_annotation: item['original_question'] = question item['question_id'] = question['question_id'] item['question'] = torch.tensor(question['question_wids'], dtype=torch.long) item['lengths'] = torch.tensor([len(question['question_wids'])], dtype=torch.long) item['image_name'] = question['image_name'] # Process Object, Attribut and Relational features # Process Object, Attribut and Relational features if self.dir_rcnn: item = self.add_rcnn_to_item(item) elif self.dir_cnn: item = self.add_cnn_to_item(item) # Process Answer if exists if 'annotations' in self.dataset: annotation = self.dataset['annotations'][index] if self.load_original_annotation: item['original_annotation'] = annotation if 'train' in self.split and self.samplingans: proba = annotation['answers_count'] proba = proba / np.sum(proba) item['answer_id'] = int(np.random.choice(annotation['answers_id'], p=proba)) else: item['answer_id'] = annotation['answer_id'] item['class_id'] = torch.tensor([item['answer_id']], dtype=torch.long) item['answer'] = annotation['answer'] item['question_type'] = annotation['question_type'] else: if item['question_id'] in self.is_qid_testdev: item['is_testdev'] = True else: item['is_testdev'] = False # if Options()['model.network.name'] == 'xmn_net': # num_feat = 36 # relation_mask = np.zeros((num_feat, num_feat)) # boxes = item['coord'] # for i in range(num_feat): # for j in range(i+1, num_feat): # # if there is no overlap between two bounding box # if boxes[0,i]>boxes[2,j] or boxes[0,j]>boxes[2,i] or boxes[1,i]>boxes[3,j] or boxes[1,j]>boxes[3,i]: # pass # else: # relation_mask[i,j] = relation_mask[j,i] = 1 # relation_mask = torch.from_numpy(relation_mask).byte() # item['relation_mask'] = relation_mask return item def download(self): dir_zip = osp.join(self.dir_raw, 'zip') os.system('mkdir -p '+dir_zip) dir_ann = osp.join(self.dir_raw, 'annotations') os.system('mkdir -p '+dir_ann) os.system('wget http://visualqa.org/data/mscoco/vqa/v2_Questions_Train_mscoco.zip -P '+dir_zip) os.system('wget http://visualqa.org/data/mscoco/vqa/v2_Questions_Val_mscoco.zip -P '+dir_zip) os.system('wget http://visualqa.org/data/mscoco/vqa/v2_Questions_Test_mscoco.zip -P '+dir_zip) os.system('wget http://visualqa.org/data/mscoco/vqa/v2_Annotations_Train_mscoco.zip -P '+dir_zip) os.system('wget http://visualqa.org/data/mscoco/vqa/v2_Annotations_Val_mscoco.zip -P '+dir_zip) os.system('unzip '+osp.join(dir_zip, 'v2_Questions_Train_mscoco.zip')+' -d '+dir_ann) os.system('unzip '+osp.join(dir_zip, 'v2_Questions_Val_mscoco.zip')+' -d '+dir_ann) os.system('unzip '+osp.join(dir_zip, 'v2_Questions_Test_mscoco.zip')+' -d '+dir_ann) os.system('unzip '+osp.join(dir_zip, 'v2_Annotations_Train_mscoco.zip')+' -d '+dir_ann) os.system('unzip '+osp.join(dir_zip, 'v2_Annotations_Val_mscoco.zip')+' -d '+dir_ann) os.system('mv '+osp.join(dir_ann, 'v2_mscoco_train2014_annotations.json')+' ' +osp.join(dir_ann, 'mscoco_train2014_annotations.json')) os.system('mv '+osp.join(dir_ann, 'v2_mscoco_val2014_annotations.json')+' ' +osp.join(dir_ann, 'mscoco_val2014_annotations.json')) os.system('mv '+osp.join(dir_ann, 'v2_OpenEnded_mscoco_train2014_questions.json')+' ' +osp.join(dir_ann, 'OpenEnded_mscoco_train2014_questions.json')) os.system('mv '+osp.join(dir_ann, 'v2_OpenEnded_mscoco_val2014_questions.json')+' ' +osp.join(dir_ann, 'OpenEnded_mscoco_val2014_questions.json')) os.system('mv '+osp.join(dir_ann, 'v2_OpenEnded_mscoco_test2015_questions.json')+' ' +osp.join(dir_ann, 'OpenEnded_mscoco_test2015_questions.json')) os.system('mv '+osp.join(dir_ann, 'v2_OpenEnded_mscoco_test-dev2015_questions.json')+' ' +osp.join(dir_ann, 'OpenEnded_mscoco_test-dev2015_questions.json'))
[ 1, 529, 276, 1112, 420, 29958, 370, 14587, 370, 294, 29884, 29914, 29878, 431, 29875, 29889, 8704, 29889, 2272, 7345, 305, 13, 5215, 2897, 13, 5215, 11799, 13, 5215, 3509, 13, 5215, 4390, 13, 5215, 4842, 305, 13, 5215, 12655, 408, 7442, 13, 3166, 2897, 1053, 2224, 408, 288, 1028, 13, 3166, 16087, 29889, 1982, 29889, 21707, 1053, 28468, 13, 3166, 16087, 29889, 1982, 29889, 6768, 1053, 25186, 13, 3166, 2908, 29889, 14538, 1691, 29889, 29894, 25621, 29918, 13239, 1053, 25513, 29963, 29984, 29909, 13, 3166, 3509, 1053, 6483, 8552, 13, 5215, 4036, 13, 5215, 260, 29939, 18933, 13, 5215, 298, 29945, 2272, 13, 13, 1990, 478, 29984, 29909, 29906, 29898, 9118, 29963, 29984, 29909, 1125, 13, 13, 1678, 822, 4770, 2344, 12035, 1311, 29892, 13, 9651, 4516, 29918, 1272, 2433, 1272, 29914, 29894, 25621, 29906, 742, 13, 9651, 6219, 2433, 14968, 742, 29871, 13, 9651, 9853, 29918, 2311, 29922, 29896, 29900, 29892, 13, 9651, 302, 29890, 29918, 28993, 29922, 29946, 29892, 13, 9651, 12534, 29918, 14834, 29922, 8824, 29892, 13, 9651, 528, 21897, 29922, 8824, 29892, 13, 9651, 302, 550, 29922, 29896, 29900, 29900, 29900, 29892, 13, 9651, 1375, 29893, 2798, 29922, 29896, 29900, 29892, 13, 9651, 302, 22833, 2433, 29885, 10702, 742, 13, 9651, 9580, 29918, 5451, 2433, 14968, 742, 13, 9651, 23460, 550, 29922, 8824, 29892, 13, 9651, 4516, 29918, 2214, 15755, 2433, 1272, 29914, 29883, 6235, 29914, 21111, 29918, 2214, 15755, 742, 13, 9651, 19901, 27521, 29922, 8824, 29892, 13, 9651, 4516, 29918, 29883, 15755, 29922, 8516, 13, 632, 1125, 13, 13, 4706, 2428, 29898, 29963, 29984, 29909, 29906, 29892, 1583, 467, 1649, 2344, 12035, 13, 9651, 4516, 29918, 1272, 29922, 3972, 29918, 1272, 29892, 13, 9651, 6219, 29922, 5451, 29892, 13, 9651, 9853, 29918, 2311, 29922, 16175, 29918, 2311, 29892, 13, 9651, 302, 29890, 29918, 28993, 29922, 9877, 29918, 28993, 29892, 13, 9651, 12534, 29918, 14834, 29922, 12687, 29918, 14834, 29892, 13, 9651, 528, 21897, 29922, 845, 21897, 29892, 13, 9651, 302, 550, 29922, 29876, 550, 29892, 13, 9651, 1375, 29893, 2798, 29922, 1195, 29893, 2798, 29892, 13, 9651, 302, 22833, 29922, 12938, 29886, 29892, 13, 9651, 9580, 29918, 5451, 29922, 15439, 29918, 5451, 29892, 13, 9651, 23460, 550, 29922, 13445, 10335, 550, 29892, 13, 9651, 756, 29918, 791, 842, 29922, 5574, 29892, 13, 9651, 756, 29918, 1688, 842, 29922, 5574, 29892, 13, 9651, 756, 29918, 550, 17538, 29918, 542, 2764, 663, 29922, 5574, 29892, 13, 9651, 437, 29918, 6979, 675, 29918, 550, 17538, 29922, 8824, 29897, 632, 13, 13, 4706, 1583, 29889, 3972, 29918, 2214, 15755, 353, 4516, 29918, 2214, 15755, 13, 4706, 1583, 29889, 3972, 29918, 29883, 15755, 353, 4516, 29918, 29883, 15755, 13, 4706, 1583, 29889, 1359, 29918, 3027, 29918, 22100, 580, 13, 4706, 396, 304, 5039, 403, 7522, 297, 7604, 2133, 3030, 313, 1333, 774, 29877, 29937, 304, 5039, 403, 7522, 297, 7604, 2133, 3030, 313, 1333, 19273, 29897, 13, 4706, 1583, 29889, 1359, 29918, 13492, 29918, 18317, 353, 7700, 13, 13, 1678, 822, 788, 29918, 2214, 15755, 29918, 517, 29918, 667, 29898, 1311, 29892, 2944, 1125, 13, 4706, 2224, 29918, 2214, 15755, 353, 2897, 29889, 2084, 29889, 7122, 29898, 1311, 29889, 3972, 29918, 2214, 15755, 29892, 22372, 1836, 29886, 386, 4286, 4830, 29898, 667, 1839, 3027, 29918, 978, 25901, 13, 4706, 2944, 29918, 2214, 15755, 353, 4842, 305, 29889, 1359, 29898, 2084, 29918, 2214, 15755, 29897, 13, 4706, 2944, 1839, 20119, 2033, 353, 2944, 29918, 2214, 15755, 1839, 1129, 29877, 839, 29918, 1725, 271, 2033, 13, 4706, 2944, 1839, 1111, 536, 2033, 353, 2944, 29918, 2214, 15755, 1839, 307, 275, 2033, 13, 4706, 2944, 1839, 12324, 29918, 1111, 536, 2033, 353, 2944, 29918, 2214, 15755, 29889, 657, 877, 12324, 29918, 307, 275, 742, 6213, 29897, 13, 4706, 2944, 1839, 9877, 29918, 1727, 1080, 2033, 353, 2944, 1839, 20119, 13359, 2311, 29898, 29900, 29897, 13, 4706, 736, 2944, 13, 13, 1678, 822, 788, 29918, 29883, 15755, 29918, 517, 29918, 667, 29898, 1311, 29892, 2944, 1125, 13, 4706, 1967, 29918, 978, 353, 2944, 1839, 3027, 29918, 978, 2033, 13, 4706, 565, 1967, 29918, 978, 297, 1583, 29889, 3027, 29918, 7039, 29918, 517, 29918, 2248, 29918, 14968, 29901, 13, 9651, 2380, 353, 1583, 29889, 3027, 29918, 7039, 29918, 517, 29918, 2248, 29918, 14968, 29961, 3027, 29918, 978, 29962, 13, 9651, 1967, 353, 4842, 305, 29889, 20158, 29898, 1311, 29889, 3027, 29918, 22100, 29918, 14968, 1839, 1131, 2033, 29961, 2248, 2314, 13, 4706, 25342, 1967, 29918, 978, 297, 1583, 29889, 3027, 29918, 7039, 29918, 517, 29918, 2248, 29918, 791, 29901, 13, 9651, 2380, 353, 1583, 29889, 3027, 29918, 7039, 29918, 517, 29918, 2248, 29918, 791, 29961, 3027, 29918, 978, 29962, 13, 9651, 1967, 353, 4842, 305, 29889, 20158, 29898, 1311, 29889, 3027, 29918, 22100, 29918, 791, 1839, 1131, 2033, 29961, 2248, 2314, 13, 4706, 1967, 353, 1967, 29889, 17858, 1082, 29898, 29896, 29892, 29871, 29906, 29892, 29871, 29900, 467, 1493, 29898, 29896, 29929, 29953, 29892, 29871, 29906, 29900, 29946, 29947, 29897, 13, 4706, 2944, 1839, 20119, 2033, 353, 1967, 13, 4706, 736, 2944, 13, 13, 1678, 822, 2254, 29918, 3027, 29918, 22100, 29898, 1311, 1125, 13, 4706, 565, 1583, 29889, 3972, 29918, 29883, 15755, 29901, 13, 9651, 10422, 29918, 14968, 353, 2897, 29889, 2084, 29889, 7122, 29898, 1311, 29889, 3972, 29918, 29883, 15755, 29892, 525, 14968, 842, 29889, 29882, 2176, 29945, 1495, 13, 9651, 10422, 29918, 791, 353, 2897, 29889, 2084, 29889, 7122, 29898, 1311, 29889, 3972, 29918, 29883, 15755, 29892, 525, 791, 842, 29889, 29882, 2176, 29945, 1495, 13, 9651, 28468, 580, 29898, 29888, 29908, 6585, 292, 934, 426, 9507, 29918, 14968, 1118, 426, 9507, 29918, 791, 27195, 13, 9651, 1583, 29889, 3027, 29918, 22100, 29918, 14968, 353, 298, 29945, 2272, 29889, 2283, 29898, 9507, 29918, 14968, 29892, 525, 29878, 742, 2381, 29885, 29878, 29922, 5574, 29897, 13, 9651, 1583, 29889, 3027, 29918, 22100, 29918, 791, 353, 298, 29945, 2272, 29889, 2283, 29898, 9507, 29918, 791, 29892, 525, 29878, 742, 2381, 29885, 29878, 29922, 5574, 29897, 13, 9651, 396, 2254, 13872, 13, 9651, 411, 1722, 29898, 359, 29889, 2084, 29889, 7122, 29898, 1311, 29889, 3972, 29918, 29883, 15755, 29892, 525, 14968, 842, 29889, 3945, 4286, 4830, 29898, 1311, 29889, 5451, 8243, 525, 29878, 1495, 408, 285, 29901, 13, 18884, 1583, 29889, 3027, 29918, 7039, 29918, 517, 29918, 2248, 29918, 14968, 353, 6571, 13, 18884, 363, 474, 29892, 1196, 297, 26985, 29898, 29888, 1125, 13, 462, 1678, 1583, 29889, 3027, 29918, 7039, 29918, 517, 29918, 2248, 29918, 14968, 29961, 1220, 29889, 17010, 580, 29962, 353, 474, 13, 9651, 411, 1722, 29898, 359, 29889, 2084, 29889, 7122, 29898, 1311, 29889, 3972, 29918, 29883, 15755, 29892, 525, 791, 842, 29889, 3945, 4286, 4830, 29898, 1311, 29889, 5451, 8243, 525, 29878, 1495, 408, 285, 29901, 13, 18884, 1583, 29889, 3027, 29918, 7039, 29918, 517, 29918, 2248, 29918, 791, 353, 6571, 13, 18884, 363, 474, 29892, 1196, 297, 26985, 29898, 29888, 1125, 13, 462, 1678, 1583, 29889, 3027, 29918, 7039, 29918, 517, 29918, 2248, 29918, 791, 29961, 1220, 29889, 17010, 580, 29962, 353, 474, 13, 13, 1678, 822, 4770, 657, 667, 12035, 1311, 29892, 2380, 1125, 13, 4706, 2944, 353, 6571, 13, 4706, 2944, 1839, 2248, 2033, 353, 2380, 13, 13, 4706, 396, 10554, 894, 313, 1742, 5993, 29897, 13, 4706, 1139, 353, 1583, 29889, 24713, 1839, 2619, 2033, 29961, 2248, 29962, 13, 4706, 565, 1583, 29889, 1359, 29918, 13492, 29918, 18317, 29901, 13, 9651, 2944, 1839, 13492, 29918, 12470, 2033, 353, 1139, 13, 13, 4706, 2944, 1839, 12470, 29918, 333, 2033, 353, 1139, 1839, 12470, 29918, 333, 2033, 13, 13, 4706, 2944, 1839, 12470, 2033, 353, 4842, 305, 29889, 20158, 29898, 12470, 1839, 12470, 29918, 29893, 4841, 7464, 26688, 29922, 7345, 305, 29889, 5426, 29897, 13, 4706, 2944, 1839, 2848, 29879, 2033, 353, 4842, 305, 29889, 20158, 4197, 2435, 29898, 12470, 1839, 12470, 29918, 29893, 4841, 11287, 1402, 26688, 29922, 7345, 305, 29889, 5426, 29897, 13, 4706, 2944, 1839, 3027, 29918, 978, 2033, 353, 1139, 1839, 3027, 29918, 978, 2033, 13, 13, 4706, 396, 10554, 4669, 29892, 6212, 1091, 329, 322, 6376, 1288, 5680, 13, 4706, 396, 10554, 4669, 29892, 6212, 1091, 329, 322, 6376, 1288, 5680, 13, 4706, 565, 1583, 29889, 3972, 29918, 2214, 15755, 29901, 13, 9651, 2944, 353, 1583, 29889, 1202, 29918, 2214, 15755, 29918, 517, 29918, 667, 29898, 667, 29897, 13, 4706, 25342, 1583, 29889, 3972, 29918, 29883, 15755, 29901, 13, 9651, 2944, 353, 1583, 29889, 1202, 29918, 29883, 15755, 29918, 517, 29918, 667, 29898, 667, 29897, 13, 13, 4706, 396, 10554, 673, 565, 4864, 13, 4706, 565, 525, 6735, 800, 29915, 297, 1583, 29889, 24713, 29901, 13, 9651, 17195, 353, 1583, 29889, 24713, 1839, 6735, 800, 2033, 29961, 2248, 29962, 13, 9651, 565, 1583, 29889, 1359, 29918, 13492, 29918, 18317, 29901, 13, 18884, 2944, 1839, 13492, 29918, 18317, 2033, 353, 17195, 13, 9651, 565, 525, 14968, 29915, 297, 1583, 29889, 5451, 322, 1583, 29889, 13445, 10335, 550, 29901, 13, 18884, 2070, 29874, 353, 17195, 1839, 550, 17538, 29918, 2798, 2033, 13, 18884, 2070, 29874, 353, 2070, 29874, 847, 7442, 29889, 2083, 29898, 771, 2291, 29897, 13, 18884, 2944, 1839, 12011, 29918, 333, 2033, 353, 938, 29898, 9302, 29889, 8172, 29889, 16957, 29898, 18317, 1839, 550, 17538, 29918, 333, 7464, 282, 29922, 771, 2291, 876, 13, 9651, 1683, 29901, 13, 18884, 2944, 1839, 12011, 29918, 333, 2033, 353, 17195, 1839, 12011, 29918, 333, 2033, 13, 9651, 2944, 1839, 1990, 29918, 333, 2033, 353, 4842, 305, 29889, 20158, 4197, 667, 1839, 12011, 29918, 333, 2033, 1402, 26688, 29922, 7345, 305, 29889, 5426, 29897, 13, 9651, 2944, 1839, 12011, 2033, 353, 17195, 1839, 12011, 2033, 13, 9651, 2944, 1839, 12470, 29918, 1853, 2033, 353, 17195, 1839, 12470, 29918, 1853, 2033, 13, 4706, 1683, 29901, 13, 9651, 565, 2944, 1839, 12470, 29918, 333, 2033, 297, 1583, 29889, 275, 29918, 29939, 333, 29918, 1688, 3359, 29901, 13, 18884, 2944, 1839, 275, 29918, 1688, 3359, 2033, 353, 5852, 13, 9651, 1683, 29901, 13, 18884, 2944, 1839, 275, 29918, 1688, 3359, 2033, 353, 7700, 13, 13, 4706, 396, 565, 25186, 580, 1839, 4299, 29889, 11618, 29889, 978, 2033, 1275, 525, 29916, 23521, 29918, 1212, 2396, 13, 4706, 396, 268, 954, 29918, 1725, 271, 353, 29871, 29941, 29953, 13, 4706, 396, 268, 8220, 29918, 13168, 353, 7442, 29889, 3298, 359, 3552, 1949, 29918, 1725, 271, 29892, 954, 29918, 1725, 271, 876, 13, 4706, 396, 268, 16273, 353, 2944, 1839, 1111, 536, 2033, 13, 4706, 396, 268, 363, 474, 297, 3464, 29898, 1949, 29918, 1725, 271, 1125, 13, 4706, 396, 308, 363, 432, 297, 3464, 29898, 29875, 29974, 29896, 29892, 954, 29918, 1725, 271, 1125, 13, 4706, 396, 632, 396, 565, 727, 338, 694, 25457, 1546, 1023, 3216, 292, 3800, 13, 4706, 396, 632, 565, 16273, 29961, 29900, 29892, 29875, 29962, 29958, 1884, 267, 29961, 29906, 29892, 29926, 29962, 470, 16273, 29961, 29900, 29892, 29926, 29962, 29958, 1884, 267, 29961, 29906, 29892, 29875, 29962, 470, 16273, 29961, 29896, 29892, 29875, 29962, 29958, 1884, 267, 29961, 29941, 29892, 29926, 29962, 470, 16273, 29961, 29896, 29892, 29926, 29962, 29958, 1884, 267, 29961, 29941, 29892, 29875, 5387, 13, 4706, 396, 462, 1209, 13, 4706, 396, 632, 1683, 29901, 13, 4706, 396, 462, 8220, 29918, 13168, 29961, 29875, 29892, 29926, 29962, 353, 8220, 29918, 13168, 29961, 29926, 29892, 29875, 29962, 353, 29871, 29896, 13, 4706, 396, 268, 8220, 29918, 13168, 353, 4842, 305, 29889, 3166, 29918, 23749, 29898, 23445, 29918, 13168, 467, 10389, 580, 13, 4706, 396, 268, 2944, 1839, 23445, 29918, 13168, 2033, 353, 8220, 29918, 13168, 13, 13, 4706, 736, 2944, 13, 13, 1678, 822, 5142, 29898, 1311, 1125, 13, 4706, 4516, 29918, 7554, 353, 288, 1028, 29889, 7122, 29898, 1311, 29889, 3972, 29918, 1610, 29892, 525, 7554, 1495, 13, 4706, 2897, 29889, 5205, 877, 11256, 3972, 448, 29886, 525, 29974, 3972, 29918, 7554, 29897, 13, 4706, 4516, 29918, 812, 353, 288, 1028, 29889, 7122, 29898, 1311, 29889, 3972, 29918, 1610, 29892, 525, 6735, 800, 1495, 13, 4706, 2897, 29889, 5205, 877, 11256, 3972, 448, 29886, 525, 29974, 3972, 29918, 812, 29897, 13, 4706, 2897, 29889, 5205, 877, 29893, 657, 1732, 597, 20119, 25621, 29889, 990, 29914, 1272, 29914, 1516, 29883, 6235, 29914, 29894, 25621, 29914, 29894, 29906, 29918, 2182, 2297, 29918, 5323, 262, 29918, 1516, 29883, 6235, 29889, 7554, 448, 29925, 525, 29974, 3972, 29918, 7554, 29897, 13, 4706, 2897, 29889, 5205, 877, 29893, 657, 1732, 597, 20119, 25621, 29889, 990, 29914, 1272, 29914, 1516, 29883, 6235, 29914, 29894, 25621, 29914, 29894, 29906, 29918, 2182, 2297, 29918, 1440, 29918, 1516, 29883, 6235, 29889, 7554, 448, 29925, 525, 29974, 3972, 29918, 7554, 29897, 13, 4706, 2897, 29889, 5205, 877, 29893, 657, 1732, 597, 20119, 25621, 29889, 990, 29914, 1272, 29914, 1516, 29883, 6235, 29914, 29894, 25621, 29914, 29894, 29906, 29918, 2182, 2297, 29918, 3057, 29918, 1516, 29883, 6235, 29889, 7554, 448, 29925, 525, 29974, 3972, 29918, 7554, 29897, 13, 4706, 2897, 29889, 5205, 877, 29893, 657, 1732, 597, 20119, 25621, 29889, 990, 29914, 1272, 29914, 1516, 29883, 6235, 29914, 29894, 25621, 29914, 29894, 29906, 29918, 2744, 1333, 800, 29918, 5323, 262, 29918, 1516, 29883, 6235, 29889, 7554, 448, 29925, 525, 29974, 3972, 29918, 7554, 29897, 13, 4706, 2897, 29889, 5205, 877, 29893, 657, 1732, 597, 20119, 25621, 29889, 990, 29914, 1272, 29914, 1516, 29883, 6235, 29914, 29894, 25621, 29914, 29894, 29906, 29918, 2744, 1333, 800, 29918, 1440, 29918, 1516, 29883, 6235, 29889, 7554, 448, 29925, 525, 29974, 3972, 29918, 7554, 29897, 13, 4706, 2897, 29889, 5205, 877, 348, 7554, 525, 29974, 4705, 29889, 7122, 29898, 3972, 29918, 7554, 29892, 525, 29894, 29906, 29918, 2182, 2297, 29918, 5323, 262, 29918, 1516, 29883, 6235, 29889, 7554, 1495, 23097, 448, 29881, 525, 29974, 3972, 29918, 812, 29897, 13, 4706, 2897, 29889, 5205, 877, 348, 7554, 525, 29974, 4705, 29889, 7122, 29898, 3972, 29918, 7554, 29892, 525, 29894, 29906, 29918, 2182, 2297, 29918, 1440, 29918, 1516, 29883, 6235, 29889, 7554, 1495, 23097, 448, 29881, 525, 29974, 3972, 29918, 812, 29897, 13, 4706, 2897, 29889, 5205, 877, 348, 7554, 525, 29974, 4705, 29889, 7122, 29898, 3972, 29918, 7554, 29892, 525, 29894, 29906, 29918, 2182, 2297, 29918, 3057, 29918, 1516, 29883, 6235, 29889, 7554, 1495, 23097, 448, 29881, 525, 29974, 3972, 29918, 812, 29897, 13, 4706, 2897, 29889, 5205, 877, 348, 7554, 525, 29974, 4705, 29889, 7122, 29898, 3972, 29918, 7554, 29892, 525, 29894, 29906, 29918, 2744, 1333, 800, 29918, 5323, 262, 29918, 1516, 29883, 6235, 29889, 7554, 1495, 23097, 448, 29881, 525, 29974, 3972, 29918, 812, 29897, 13, 4706, 2897, 29889, 5205, 877, 348, 7554, 525, 29974, 4705, 29889, 7122, 29898, 3972, 29918, 7554, 29892, 525, 29894, 29906, 29918, 2744, 1333, 800, 29918, 1440, 29918, 1516, 29883, 6235, 29889, 7554, 1495, 23097, 448, 29881, 525, 29974, 3972, 29918, 812, 29897, 13, 4706, 2897, 29889, 5205, 877, 29324, 525, 29974, 4705, 29889, 7122, 29898, 3972, 29918, 812, 29892, 525, 29894, 29906, 29918, 1516, 29883, 6235, 29918, 14968, 29906, 29900, 29896, 29946, 29918, 6735, 800, 29889, 3126, 1495, 23097, 525, 13, 462, 539, 718, 4705, 29889, 7122, 29898, 3972, 29918, 812, 29892, 525, 1516, 29883, 6235, 29918, 14968, 29906, 29900, 29896, 29946, 29918, 6735, 800, 29889, 3126, 8785, 13, 4706, 2897, 29889, 5205, 877, 29324, 525, 29974, 4705, 29889, 7122, 29898, 3972, 29918, 812, 29892, 525, 29894, 29906, 29918, 1516, 29883, 6235, 29918, 791, 29906, 29900, 29896, 29946, 29918, 6735, 800, 29889, 3126, 1495, 23097, 525, 13, 462, 539, 718, 4705, 29889, 7122, 29898, 3972, 29918, 812, 29892, 525, 1516, 29883, 6235, 29918, 791, 29906, 29900, 29896, 29946, 29918, 6735, 800, 29889, 3126, 8785, 13, 4706, 2897, 29889, 5205, 877, 29324, 525, 29974, 4705, 29889, 7122, 29898, 3972, 29918, 812, 29892, 525, 29894, 29906, 29918, 6585, 5044, 287, 29918, 1516, 29883, 6235, 29918, 14968, 29906, 29900, 29896, 29946, 29918, 2619, 29889, 3126, 1495, 23097, 525, 13, 462, 539, 718, 4705, 29889, 7122, 29898, 3972, 29918, 812, 29892, 525, 6585, 5044, 287, 29918, 1516, 29883, 6235, 29918, 14968, 29906, 29900, 29896, 29946, 29918, 2619, 29889, 3126, 8785, 13, 4706, 2897, 29889, 5205, 877, 29324, 525, 29974, 4705, 29889, 7122, 29898, 3972, 29918, 812, 29892, 525, 29894, 29906, 29918, 6585, 5044, 287, 29918, 1516, 29883, 6235, 29918, 791, 29906, 29900, 29896, 29946, 29918, 2619, 29889, 3126, 1495, 23097, 525, 13, 462, 539, 718, 4705, 29889, 7122, 29898, 3972, 29918, 812, 29892, 525, 6585, 5044, 287, 29918, 1516, 29883, 6235, 29918, 791, 29906, 29900, 29896, 29946, 29918, 2619, 29889, 3126, 8785, 13, 4706, 2897, 29889, 5205, 877, 29324, 525, 29974, 4705, 29889, 7122, 29898, 3972, 29918, 812, 29892, 525, 29894, 29906, 29918, 6585, 5044, 287, 29918, 1516, 29883, 6235, 29918, 1688, 29906, 29900, 29896, 29945, 29918, 2619, 29889, 3126, 1495, 23097, 525, 13, 462, 539, 718, 4705, 29889, 7122, 29898, 3972, 29918, 812, 29892, 525, 6585, 5044, 287, 29918, 1516, 29883, 6235, 29918, 1688, 29906, 29900, 29896, 29945, 29918, 2619, 29889, 3126, 8785, 13, 4706, 2897, 29889, 5205, 877, 29324, 525, 29974, 4705, 29889, 7122, 29898, 3972, 29918, 812, 29892, 525, 29894, 29906, 29918, 6585, 5044, 287, 29918, 1516, 29883, 6235, 29918, 1688, 29899, 3359, 29906, 29900, 29896, 29945, 29918, 2619, 29889, 3126, 1495, 23097, 525, 13, 462, 539, 718, 4705, 29889, 7122, 29898, 3972, 29918, 812, 29892, 525, 6585, 5044, 287, 29918, 1516, 29883, 6235, 29918, 1688, 29899, 3359, 29906, 29900, 29896, 29945, 29918, 2619, 29889, 3126, 8785, 13, 2 ]
riberry/policy/helpers.py
srafehi/riberry
2
100818
from .engine import Rule, AttributeContext, Policy class ShorthandRule(Rule): def __init__(self, func): self.func = func def target_clause(self, context: AttributeContext) -> bool: return True def condition(self, context: AttributeContext) -> bool: return self.func(context) class ShorthandPolicy(Policy): def __init__(self, func, *collection): super(ShorthandPolicy, self).__init__(*collection) self.func = func def target_clause(self, context: AttributeContext) -> bool: return True def condition(self, context: AttributeContext) -> bool: return self.func(context) class ShorthandPolicySet(Policy): def __init__(self, func, *collection): super(ShorthandPolicySet, self).__init__(*collection) self.func = func def target_clause(self, context: AttributeContext) -> bool: return True def condition(self, context: AttributeContext) -> bool: return self.func(context) def rule(func): return ShorthandRule(func) def policy(func): def builder(*collection): return ShorthandPolicy(func, *collection) return builder def policy_set(func): def builder(*collection): return ShorthandPolicySet(func, *collection) return builder
[ 1, 515, 869, 10599, 1053, 27308, 29892, 23833, 2677, 29892, 25219, 13, 13, 13, 1990, 1383, 2072, 392, 10740, 29898, 10740, 1125, 13, 13, 1678, 822, 4770, 2344, 12035, 1311, 29892, 3653, 1125, 13, 4706, 1583, 29889, 9891, 353, 3653, 13, 13, 1678, 822, 3646, 29918, 16398, 1509, 29898, 1311, 29892, 3030, 29901, 23833, 2677, 29897, 1599, 6120, 29901, 13, 4706, 736, 5852, 13, 13, 1678, 822, 4195, 29898, 1311, 29892, 3030, 29901, 23833, 2677, 29897, 1599, 6120, 29901, 13, 4706, 736, 1583, 29889, 9891, 29898, 4703, 29897, 13, 13, 13, 1990, 1383, 2072, 392, 15644, 29898, 15644, 1125, 13, 13, 1678, 822, 4770, 2344, 12035, 1311, 29892, 3653, 29892, 334, 10855, 1125, 13, 4706, 2428, 29898, 29903, 2015, 386, 392, 15644, 29892, 1583, 467, 1649, 2344, 1649, 10456, 10855, 29897, 13, 4706, 1583, 29889, 9891, 353, 3653, 13, 13, 1678, 822, 3646, 29918, 16398, 1509, 29898, 1311, 29892, 3030, 29901, 23833, 2677, 29897, 1599, 6120, 29901, 13, 4706, 736, 5852, 13, 13, 1678, 822, 4195, 29898, 1311, 29892, 3030, 29901, 23833, 2677, 29897, 1599, 6120, 29901, 13, 4706, 736, 1583, 29889, 9891, 29898, 4703, 29897, 13, 13, 13, 1990, 1383, 2072, 392, 15644, 2697, 29898, 15644, 1125, 13, 13, 1678, 822, 4770, 2344, 12035, 1311, 29892, 3653, 29892, 334, 10855, 1125, 13, 4706, 2428, 29898, 29903, 2015, 386, 392, 15644, 2697, 29892, 1583, 467, 1649, 2344, 1649, 10456, 10855, 29897, 13, 4706, 1583, 29889, 9891, 353, 3653, 13, 13, 1678, 822, 3646, 29918, 16398, 1509, 29898, 1311, 29892, 3030, 29901, 23833, 2677, 29897, 1599, 6120, 29901, 13, 4706, 736, 5852, 13, 13, 1678, 822, 4195, 29898, 1311, 29892, 3030, 29901, 23833, 2677, 29897, 1599, 6120, 29901, 13, 4706, 736, 1583, 29889, 9891, 29898, 4703, 29897, 13, 13, 13, 1753, 5751, 29898, 9891, 1125, 13, 1678, 736, 1383, 2072, 392, 10740, 29898, 9891, 29897, 13, 13, 13, 1753, 8898, 29898, 9891, 1125, 13, 13, 1678, 822, 12856, 10456, 10855, 1125, 13, 4706, 736, 1383, 2072, 392, 15644, 29898, 9891, 29892, 334, 10855, 29897, 13, 13, 1678, 736, 12856, 13, 13, 13, 1753, 8898, 29918, 842, 29898, 9891, 1125, 13, 13, 1678, 822, 12856, 10456, 10855, 1125, 13, 4706, 736, 1383, 2072, 392, 15644, 2697, 29898, 9891, 29892, 334, 10855, 29897, 13, 13, 1678, 736, 12856, 2 ]
djapi/authtoken/models.py
Suor/djapi
12
38104
<reponame>Suor/djapi<gh_stars>10-100 import binascii import os from django.conf import settings from django.db import models from django.utils.encoding import python_2_unicode_compatible from django.utils.translation import ugettext_lazy as _ @python_2_unicode_compatible class Token(models.Model): """ The default authorization token model. """ key = models.CharField(_("Key"), max_length=40, primary_key=True) user = models.OneToOneField( settings.AUTH_USER_MODEL, related_name='auth_token', on_delete=models.CASCADE, verbose_name=_("User") ) created = models.DateTimeField(_("Created"), auto_now_add=True) class Meta: verbose_name = _("Token") verbose_name_plural = _("Tokens") def save(self, *args, **kwargs): if not self.key: self.key = self.generate_key() return super(Token, self).save(*args, **kwargs) def generate_key(self): return binascii.hexlify(os.urandom(20)).decode() def __str__(self): return self.key
[ 1, 529, 276, 1112, 420, 29958, 5091, 272, 29914, 19776, 2754, 29966, 12443, 29918, 303, 1503, 29958, 29896, 29900, 29899, 29896, 29900, 29900, 13, 5215, 9016, 294, 18869, 13, 5215, 2897, 13, 13, 3166, 9557, 29889, 5527, 1053, 6055, 13, 3166, 9557, 29889, 2585, 1053, 4733, 13, 3166, 9557, 29889, 13239, 29889, 22331, 1053, 3017, 29918, 29906, 29918, 2523, 356, 29918, 23712, 13, 3166, 9557, 29889, 13239, 29889, 3286, 18411, 1053, 318, 657, 726, 29918, 433, 1537, 408, 903, 13, 13, 13, 29992, 4691, 29918, 29906, 29918, 2523, 356, 29918, 23712, 13, 1990, 25159, 29898, 9794, 29889, 3195, 1125, 13, 1678, 9995, 13, 1678, 450, 2322, 28733, 5993, 1904, 29889, 13, 1678, 9995, 13, 1678, 1820, 353, 4733, 29889, 27890, 7373, 703, 2558, 4968, 4236, 29918, 2848, 29922, 29946, 29900, 29892, 7601, 29918, 1989, 29922, 5574, 29897, 13, 1678, 1404, 353, 4733, 29889, 6716, 1762, 6716, 3073, 29898, 13, 4706, 6055, 29889, 20656, 29950, 29918, 11889, 29918, 20387, 29931, 29892, 4475, 29918, 978, 2433, 5150, 29918, 6979, 742, 13, 4706, 373, 29918, 8143, 29922, 9794, 29889, 29907, 3289, 5454, 2287, 29892, 26952, 29918, 978, 29922, 29918, 703, 2659, 1159, 13, 1678, 1723, 13, 1678, 2825, 353, 4733, 29889, 11384, 3073, 7373, 703, 20399, 4968, 4469, 29918, 3707, 29918, 1202, 29922, 5574, 29897, 13, 13, 1678, 770, 20553, 29901, 13, 4706, 26952, 29918, 978, 353, 903, 703, 6066, 1159, 13, 4706, 26952, 29918, 978, 29918, 572, 3631, 353, 903, 703, 29911, 554, 575, 1159, 13, 13, 1678, 822, 4078, 29898, 1311, 29892, 334, 5085, 29892, 3579, 19290, 1125, 13, 4706, 565, 451, 1583, 29889, 1989, 29901, 13, 9651, 1583, 29889, 1989, 353, 1583, 29889, 17158, 29918, 1989, 580, 13, 4706, 736, 2428, 29898, 6066, 29892, 1583, 467, 7620, 10456, 5085, 29892, 3579, 19290, 29897, 13, 13, 1678, 822, 5706, 29918, 1989, 29898, 1311, 1125, 13, 4706, 736, 9016, 294, 18869, 29889, 354, 15524, 1598, 29898, 359, 29889, 332, 2685, 29898, 29906, 29900, 8106, 13808, 580, 13, 13, 1678, 822, 4770, 710, 12035, 1311, 1125, 13, 4706, 736, 1583, 29889, 1989, 13, 2 ]
packages/pytest-simcore/src/pytest_simcore/minio_service.py
elisabettai/osparc-simcore
0
65001
<gh_stars>0 # pylint: disable=redefined-outer-name # pylint: disable=unused-argument # pylint: disable=unused-variable import logging from distutils.util import strtobool from typing import Dict, Iterator import pytest import tenacity from _pytest.monkeypatch import MonkeyPatch from minio import Minio from minio.datatypes import Object from minio.deleteobjects import DeleteError, DeleteObject from tenacity import Retrying from .helpers.utils_docker import get_localhost_ip, get_service_published_port log = logging.getLogger(__name__) def _ensure_remove_bucket(client: Minio, bucket_name: str): if client.bucket_exists(bucket_name): # remove content objs: Iterator[Object] = client.list_objects( bucket_name, prefix=None, recursive=True ) # FIXME: minio 7.1.0 does NOT remove all objects!? Added in requirements/constraints.txt to_delete = [DeleteObject(o.object_name) for o in objs] errors: Iterator[DeleteError] = client.remove_objects(bucket_name, to_delete) list_of_errors = list(errors) assert not any(list_of_errors), list(list_of_errors) # remove bucket client.remove_bucket(bucket_name) assert not client.bucket_exists(bucket_name) @pytest.fixture(scope="module") def minio_config( docker_stack: Dict, testing_environ_vars: Dict, monkeypatch_module: MonkeyPatch ) -> Dict[str, str]: assert "pytest-ops_minio" in docker_stack["services"] config = { "client": { "endpoint": f"{get_localhost_ip()}:{get_service_published_port('minio')}", "access_key": testing_environ_vars["S3_ACCESS_KEY"], "secret_key": testing_environ_vars["S3_SECRET_KEY"], "secure": strtobool(testing_environ_vars["S3_SECURE"]) != 0, }, "bucket_name": testing_environ_vars["S3_BUCKET_NAME"], } # nodeports takes its configuration from env variables for key, value in config["client"].items(): monkeypatch_module.setenv(f"S3_{key.upper()}", str(value)) monkeypatch_module.setenv("S3_SECURE", testing_environ_vars["S3_SECURE"]) monkeypatch_module.setenv("S3_BUCKET_NAME", config["bucket_name"]) return config @pytest.fixture(scope="module") def minio_service(minio_config: Dict[str, str]) -> Iterator[Minio]: client = Minio(**minio_config["client"]) for attempt in Retrying( wait=tenacity.wait_fixed(5), stop=tenacity.stop_after_attempt(60), before_sleep=tenacity.before_sleep_log(log, logging.WARNING), reraise=True, ): with attempt: # TODO: improve as https://docs.min.io/docs/minio-monitoring-guide.html if not client.bucket_exists("pytest"): client.make_bucket("pytest") client.remove_bucket("pytest") bucket_name = minio_config["bucket_name"] # cleans up in case a failing tests left this bucket _ensure_remove_bucket(client, bucket_name) client.make_bucket(bucket_name) assert client.bucket_exists(bucket_name) yield client # cleanup upon tear-down _ensure_remove_bucket(client, bucket_name) @pytest.fixture(scope="module") def bucket(minio_config: Dict[str, str], minio_service: Minio) -> Iterator[str]: bucket_name = minio_config["bucket_name"] _ensure_remove_bucket(minio_service, bucket_name) minio_service.make_bucket(bucket_name) yield bucket_name _ensure_remove_bucket(minio_service, bucket_name)
[ 1, 529, 12443, 29918, 303, 1503, 29958, 29900, 13, 29937, 282, 2904, 524, 29901, 11262, 29922, 276, 12119, 29899, 5561, 29899, 978, 30004, 13, 29937, 282, 2904, 524, 29901, 11262, 29922, 348, 3880, 29899, 23516, 30004, 13, 29937, 282, 2904, 524, 29901, 11262, 29922, 348, 3880, 29899, 11918, 30004, 13, 30004, 13, 5215, 12183, 30004, 13, 3166, 1320, 13239, 29889, 4422, 1053, 851, 517, 11227, 30004, 13, 3166, 19229, 1053, 360, 919, 29892, 20504, 1061, 30004, 13, 30004, 13, 5215, 11451, 1688, 30004, 13, 5215, 3006, 5946, 30004, 13, 3166, 903, 2272, 1688, 29889, 3712, 446, 1478, 905, 1053, 2598, 1989, 29925, 905, 30004, 13, 3166, 1375, 601, 1053, 3080, 601, 30004, 13, 3166, 1375, 601, 29889, 4130, 271, 7384, 1053, 4669, 30004, 13, 3166, 1375, 601, 29889, 8143, 12650, 1053, 21267, 2392, 29892, 21267, 2061, 30004, 13, 3166, 3006, 5946, 1053, 4649, 719, 292, 30004, 13, 30004, 13, 3166, 869, 3952, 6774, 29889, 13239, 29918, 14695, 1053, 679, 29918, 7640, 29918, 666, 29892, 679, 29918, 5509, 29918, 5467, 3726, 29918, 637, 30004, 13, 30004, 13, 1188, 353, 12183, 29889, 657, 16363, 22168, 978, 1649, 8443, 13, 30004, 13, 30004, 13, 1753, 903, 7469, 29918, 5992, 29918, 21454, 29898, 4645, 29901, 3080, 601, 29892, 20968, 29918, 978, 29901, 851, 1125, 30004, 13, 1678, 565, 3132, 29889, 21454, 29918, 9933, 29898, 21454, 29918, 978, 1125, 30004, 13, 4706, 396, 3349, 2793, 30004, 13, 4706, 704, 1315, 29901, 20504, 1061, 29961, 2061, 29962, 353, 3132, 29889, 1761, 29918, 12650, 29898, 30004, 13, 9651, 20968, 29918, 978, 29892, 10944, 29922, 8516, 29892, 16732, 29922, 5574, 30004, 13, 4706, 1723, 30004, 13, 30004, 13, 4706, 396, 383, 6415, 2303, 29901, 1375, 601, 29871, 29955, 29889, 29896, 29889, 29900, 947, 6058, 3349, 599, 3618, 29991, 29973, 25601, 297, 11780, 29914, 13646, 29879, 29889, 3945, 30004, 13, 4706, 304, 29918, 8143, 353, 518, 12498, 2061, 29898, 29877, 29889, 3318, 29918, 978, 29897, 363, 288, 297, 704, 1315, 29962, 30004, 13, 4706, 4436, 29901, 20504, 1061, 29961, 12498, 2392, 29962, 353, 3132, 29889, 5992, 29918, 12650, 29898, 21454, 29918, 978, 29892, 304, 29918, 8143, 8443, 13, 30004, 13, 4706, 1051, 29918, 974, 29918, 12523, 353, 1051, 29898, 12523, 8443, 13, 4706, 4974, 451, 738, 29898, 1761, 29918, 974, 29918, 12523, 511, 1051, 29898, 1761, 29918, 974, 29918, 12523, 8443, 13, 30004, 13, 4706, 396, 3349, 20968, 30004, 13, 4706, 3132, 29889, 5992, 29918, 21454, 29898, 21454, 29918, 978, 8443, 13, 30004, 13, 1678, 4974, 451, 3132, 29889, 21454, 29918, 9933, 29898, 21454, 29918, 978, 8443, 13, 30004, 13, 30004, 13, 29992, 2272, 1688, 29889, 7241, 15546, 29898, 6078, 543, 5453, 1159, 30004, 13, 1753, 1375, 601, 29918, 2917, 29898, 30004, 13, 1678, 10346, 29918, 1429, 29901, 360, 919, 29892, 6724, 29918, 21813, 29918, 16908, 29901, 360, 919, 29892, 1601, 446, 1478, 905, 29918, 5453, 29901, 2598, 1989, 29925, 905, 30004, 13, 29897, 1599, 360, 919, 29961, 710, 29892, 851, 5387, 30004, 13, 1678, 4974, 376, 2272, 1688, 29899, 3554, 29918, 1195, 601, 29908, 297, 10346, 29918, 1429, 3366, 9916, 3108, 30004, 13, 30004, 13, 1678, 2295, 353, 3336, 13, 4706, 376, 4645, 1115, 3336, 13, 9651, 376, 29734, 1115, 285, 29908, 29912, 657, 29918, 7640, 29918, 666, 580, 6177, 29912, 657, 29918, 5509, 29918, 5467, 3726, 29918, 637, 877, 1195, 601, 1495, 29913, 15231, 13, 9651, 376, 5943, 29918, 1989, 1115, 6724, 29918, 21813, 29918, 16908, 3366, 29903, 29941, 29918, 2477, 23524, 29918, 10818, 12436, 30004, 13, 9651, 376, 19024, 29918, 1989, 1115, 6724, 29918, 21813, 29918, 16908, 3366, 29903, 29941, 29918, 1660, 22245, 29911, 29918, 10818, 12436, 30004, 13, 9651, 376, 24216, 1115, 851, 517, 11227, 29898, 13424, 29918, 21813, 29918, 16908, 3366, 29903, 29941, 29918, 1660, 29907, 11499, 20068, 2804, 29871, 29900, 11167, 13, 4706, 2981, 30004, 13, 4706, 376, 21454, 29918, 978, 1115, 6724, 29918, 21813, 29918, 16908, 3366, 29903, 29941, 29918, 7838, 7077, 2544, 29918, 5813, 12436, 30004, 13, 1678, 4970, 13, 30004, 13, 1678, 396, 2943, 4011, 4893, 967, 5285, 515, 8829, 3651, 30004, 13, 1678, 363, 1820, 29892, 995, 297, 2295, 3366, 4645, 16862, 7076, 7295, 30004, 13, 4706, 1601, 446, 1478, 905, 29918, 5453, 29889, 842, 6272, 29898, 29888, 29908, 29903, 29941, 648, 1989, 29889, 21064, 580, 17671, 851, 29898, 1767, 876, 30004, 13, 30004, 13, 1678, 1601, 446, 1478, 905, 29918, 5453, 29889, 842, 6272, 703, 29903, 29941, 29918, 1660, 29907, 11499, 613, 6724, 29918, 21813, 29918, 16908, 3366, 29903, 29941, 29918, 1660, 29907, 11499, 20068, 30004, 13, 1678, 1601, 446, 1478, 905, 29918, 5453, 29889, 842, 6272, 703, 29903, 29941, 29918, 7838, 7077, 2544, 29918, 5813, 613, 2295, 3366, 21454, 29918, 978, 20068, 30004, 13, 30004, 13, 1678, 736, 2295, 30004, 13, 30004, 13, 30004, 13, 29992, 2272, 1688, 29889, 7241, 15546, 29898, 6078, 543, 5453, 1159, 30004, 13, 1753, 1375, 601, 29918, 5509, 29898, 1195, 601, 29918, 2917, 29901, 360, 919, 29961, 710, 29892, 851, 2314, 1599, 20504, 1061, 29961, 8140, 601, 5387, 30004, 13, 30004, 13, 1678, 3132, 353, 3080, 601, 29898, 1068, 1195, 601, 29918, 2917, 3366, 4645, 20068, 30004, 13, 30004, 13, 1678, 363, 4218, 297, 4649, 719, 292, 29898, 30004, 13, 4706, 4480, 29922, 841, 5946, 29889, 10685, 29918, 20227, 29898, 29945, 511, 30004, 13, 4706, 5040, 29922, 841, 5946, 29889, 9847, 29918, 7045, 29918, 1131, 3456, 29898, 29953, 29900, 511, 30004, 13, 4706, 1434, 29918, 17059, 29922, 841, 5946, 29889, 11083, 29918, 17059, 29918, 1188, 29898, 1188, 29892, 12183, 29889, 29956, 25614, 511, 30004, 13, 4706, 364, 1572, 895, 29922, 5574, 11167, 13, 268, 1125, 30004, 13, 4706, 411, 4218, 29901, 30004, 13, 9651, 396, 14402, 29901, 11157, 408, 2045, 597, 2640, 29889, 1195, 29889, 601, 29914, 2640, 29914, 1195, 601, 29899, 3712, 2105, 292, 29899, 13075, 29889, 1420, 30004, 13, 9651, 565, 451, 3132, 29889, 21454, 29918, 9933, 703, 2272, 1688, 29908, 1125, 30004, 13, 18884, 3132, 29889, 5675, 29918, 21454, 703, 2272, 1688, 1159, 30004, 13, 9651, 3132, 29889, 5992, 29918, 21454, 703, 2272, 1688, 1159, 30004, 13, 30004, 13, 1678, 20968, 29918, 978, 353, 1375, 601, 29918, 2917, 3366, 21454, 29918, 978, 3108, 30004, 13, 30004, 13, 1678, 396, 4531, 550, 701, 297, 1206, 263, 17581, 6987, 2175, 445, 20968, 30004, 13, 1678, 903, 7469, 29918, 5992, 29918, 21454, 29898, 4645, 29892, 20968, 29918, 978, 8443, 13, 30004, 13, 1678, 3132, 29889, 5675, 29918, 21454, 29898, 21454, 29918, 978, 8443, 13, 1678, 4974, 3132, 29889, 21454, 29918, 9933, 29898, 21454, 29918, 978, 8443, 13, 30004, 13, 1678, 7709, 3132, 30004, 13, 30004, 13, 1678, 396, 5941, 786, 2501, 734, 279, 29899, 3204, 30004, 13, 1678, 903, 7469, 29918, 5992, 29918, 21454, 29898, 4645, 29892, 20968, 29918, 978, 8443, 13, 30004, 13, 30004, 13, 29992, 2272, 1688, 29889, 7241, 15546, 29898, 6078, 543, 5453, 1159, 30004, 13, 1753, 20968, 29898, 1195, 601, 29918, 2917, 29901, 360, 919, 29961, 710, 29892, 851, 1402, 1375, 601, 29918, 5509, 29901, 3080, 601, 29897, 1599, 20504, 1061, 29961, 710, 5387, 30004, 13, 1678, 20968, 29918, 978, 353, 1375, 601, 29918, 2917, 3366, 21454, 29918, 978, 3108, 30004, 13, 30004, 13, 1678, 903, 7469, 29918, 5992, 29918, 21454, 29898, 1195, 601, 29918, 5509, 29892, 20968, 29918, 978, 8443, 13, 1678, 1375, 601, 29918, 5509, 29889, 5675, 29918, 21454, 29898, 21454, 29918, 978, 8443, 13, 30004, 13, 1678, 7709, 20968, 29918, 978, 30004, 13, 30004, 13, 1678, 903, 7469, 29918, 5992, 29918, 21454, 29898, 1195, 601, 29918, 5509, 29892, 20968, 29918, 978, 8443, 13, 2 ]
libs/enums.py
paulirish/covid-data-model
1
141237
import enum # Fips code chosen for all unknown fips values. # TODO: This should maybe be unique per state. UNKNOWN_FIPS = "99999" class Intervention(enum.Enum): NO_MITIGATION = 0 HIGH_MITIGATION = 1 # on the webiste, strictDistancingNow MODERATE_MITIGATION = 3 # weak distancingNow on the website SELECTED_MITIGATION = 4 # look at what the state is and get the file for that # We are using enum 2 for consistency with the website OBSERVED_MITIGATION = 2 # given the previous pattern, how do we predict going forward @classmethod def county_supported_interventions(cls): return [ Intervention.NO_MITIGATION, Intervention.HIGH_MITIGATION, Intervention.MODERATE_MITIGATION, Intervention.SELECTED_MITIGATION, ] @classmethod def from_webui_data_adaptor(cls, label): if label == "suppression_policy__no_intervention": return cls.NO_MITIGATION elif label == "suppression_policy__flatten_the_curve": return cls.HIGH_MITIGATION elif label == "suppression_policy__inferred": return cls.OBSERVED_MITIGATION elif label == "suppression_policy__social_distancing": return cls.MODERATE_MITIGATION raise Exception(f"Unexpected WebUI Data Adaptor label: {label}") @classmethod def from_str(cls, label): if label == "shelter_in_place": return cls.HIGH_MITIGATION elif label == "social_distancing": return cls.MODERATE_MITIGATION else: return cls.NO_MITIGATION
[ 1, 1053, 14115, 13, 13, 29937, 383, 4512, 775, 10434, 363, 599, 9815, 285, 4512, 1819, 29889, 13, 29937, 14402, 29901, 910, 881, 5505, 367, 5412, 639, 2106, 29889, 13, 3904, 29968, 6632, 16048, 29918, 3738, 7024, 353, 376, 29929, 29929, 29929, 29929, 29929, 29908, 13, 13, 1990, 4124, 7316, 29898, 18605, 29889, 16854, 1125, 13, 1678, 11698, 29918, 26349, 6259, 8098, 353, 29871, 29900, 13, 1678, 379, 6259, 29950, 29918, 26349, 6259, 8098, 353, 29871, 29896, 396, 373, 278, 1856, 2488, 29892, 9406, 29928, 9777, 3277, 10454, 13, 1678, 16999, 8032, 3040, 29918, 26349, 6259, 8098, 353, 29871, 29941, 396, 8062, 1320, 19985, 10454, 373, 278, 4700, 13, 1678, 5097, 3352, 29918, 26349, 6259, 8098, 353, 29871, 29946, 29871, 396, 1106, 472, 825, 278, 2106, 338, 322, 679, 278, 934, 363, 393, 13, 1678, 396, 1334, 526, 773, 14115, 29871, 29906, 363, 5718, 3819, 411, 278, 4700, 13, 1678, 438, 29933, 6304, 29963, 3352, 29918, 26349, 6259, 8098, 353, 29871, 29906, 396, 2183, 278, 3517, 4766, 29892, 920, 437, 591, 8500, 2675, 6375, 13, 13, 1678, 732, 1990, 5696, 13, 1678, 822, 15178, 29918, 23765, 29918, 1639, 794, 1080, 29898, 25932, 1125, 13, 4706, 736, 518, 13, 9651, 4124, 7316, 29889, 6632, 29918, 26349, 6259, 8098, 29892, 13, 9651, 4124, 7316, 29889, 29950, 6259, 29950, 29918, 26349, 6259, 8098, 29892, 13, 9651, 4124, 7316, 29889, 6720, 8032, 3040, 29918, 26349, 6259, 8098, 29892, 13, 9651, 4124, 7316, 29889, 6404, 3352, 29918, 26349, 6259, 8098, 29892, 13, 4706, 4514, 13, 13, 1678, 732, 1990, 5696, 13, 1678, 822, 515, 29918, 2676, 1481, 29918, 1272, 29918, 1114, 415, 272, 29898, 25932, 29892, 3858, 1125, 13, 4706, 565, 3858, 1275, 376, 19303, 23881, 29918, 22197, 1649, 1217, 29918, 1639, 7316, 1115, 13, 9651, 736, 1067, 29879, 29889, 6632, 29918, 26349, 6259, 8098, 13, 4706, 25342, 3858, 1275, 376, 19303, 23881, 29918, 22197, 1649, 1579, 8606, 29918, 1552, 29918, 2764, 345, 1115, 13, 9651, 736, 1067, 29879, 29889, 29950, 6259, 29950, 29918, 26349, 6259, 8098, 13, 4706, 25342, 3858, 1275, 376, 19303, 23881, 29918, 22197, 1649, 262, 14373, 1115, 13, 9651, 736, 1067, 29879, 29889, 14824, 6304, 29963, 3352, 29918, 26349, 6259, 8098, 13, 4706, 25342, 3858, 1275, 376, 19303, 23881, 29918, 22197, 1649, 24911, 29918, 5721, 19985, 1115, 13, 9651, 736, 1067, 29879, 29889, 6720, 8032, 3040, 29918, 26349, 6259, 8098, 13, 4706, 12020, 8960, 29898, 29888, 29908, 29965, 13996, 6021, 2563, 3120, 3630, 23255, 415, 272, 3858, 29901, 426, 1643, 27195, 13, 13, 1678, 732, 1990, 5696, 13, 1678, 822, 515, 29918, 710, 29898, 25932, 29892, 3858, 1125, 13, 4706, 565, 3858, 1275, 376, 845, 21883, 29918, 262, 29918, 6689, 1115, 13, 9651, 736, 1067, 29879, 29889, 29950, 6259, 29950, 29918, 26349, 6259, 8098, 13, 4706, 25342, 3858, 1275, 376, 24911, 29918, 5721, 19985, 1115, 13, 9651, 736, 1067, 29879, 29889, 6720, 8032, 3040, 29918, 26349, 6259, 8098, 13, 4706, 1683, 29901, 13, 9651, 736, 1067, 29879, 29889, 6632, 29918, 26349, 6259, 8098, 13, 2 ]
pywebcopy/schedulers.py
rajatomar788/pywebcopy7
5
83078
# Copyright 2020; <NAME> # See license for more details import logging import threading import weakref from requests import ConnectionError from six import PY3 from six import string_types from six.moves.urllib.parse import urlparse from .elements import VoidResource from .elements import CSSResource from .elements import JSResource from .elements import AbsoluteUrlResource from .elements import GenericResource from .elements import HTMLResource from .elements import UrlRemover from .helpers import RecentOrderedDict logger = logging.getLogger(__name__) class Index(RecentOrderedDict): """Files index dict. ..todo:: make it database synced """ def __init__(self, *args, **kwargs): super(Index, self).__init__(*args, **kwargs) self.lock = threading.Lock() def add_entry(self, k, v): with self.lock: self.__setitem__(k, v) def get_entry(self, k, default=None): return self.get(k, default=default) def add_resource(self, resource): location = resource.filepath self.add_entry(resource.context.url, location) if hasattr(resource.response, 'url'): self.add_entry(resource.response.url, location) if resource.response.history: for r in resource.response.history: self.add_entry(r.url, location) index_resource = add_resource class SchedulerBase(object): """A Synchronised resource processor. File paths would be based on the content-type header returned by the server but this would be slow because of being synchronous but is very reliable. """ style_tags = frozenset(['link', 'style']) img_tags = frozenset(['img']) script_tags = frozenset(['script']) meta_tags = frozenset(['meta']) internal_tags = (style_tags | img_tags | script_tags | meta_tags) external_tags = frozenset(['a', 'form', 'iframe']) tags = (internal_tags | external_tags) def __init__(self, default=None, **data): self.data = dict() self.data.update(data) self.default = default self.index = Index() self.block_external_domains = True self.logger = logger.getChild(self.__class__.__name__) def set_default(self, default): self.default = default self.logger.info("Set the scheduler default as: [%r]" % default) def register_handler(self, key, value): self.data.__setitem__(key, value) self.logger.info( "Set the scheduler handler for %s as: [%r]" % (key, value)) add_handler = register_handler def deregister_handler(self, key): self.data.__delitem__(key) self.logger.info("Removed the scheduler handler for: %s" % key) remove_handler = deregister_handler def get_handler(self, key, *args, **params): if key not in self.data: if self.default is None: raise KeyError(key) return self.default(*args, **params) else: return self.data[key](*args, **params) invalid_schemas = tuple([ 'data', 'javascript', 'mailto', ]) def validate_url(self, url): if not isinstance(url, string_types): self.logger.error( "Expected string type, got %r" % url) return False scheme, host, port, path, query, frag = urlparse(url) if scheme in self.invalid_schemas: self.logger.error( "Invalid url schema: [%s] for url: [%s]" % (scheme, url)) return False return True def validate_resource(self, resource): if not isinstance(resource, GenericResource): self.logger.error( "Expected GenericResource, got %r" % resource) return False if isinstance(resource, VoidResource): self.logger.error( "Skipping VoidResource: %r" % resource) return False if not isinstance(resource.url, string_types): self.logger.error( "Expected url of string type, got %r" % resource.url) return False if isinstance(resource, HTMLResource) and self.block_external_domains: # FIXME: Change the algorithm to evaluate redirects. # print(resource.url, resource.context) if not resource.url.startswith(resource.context.base_url): self.logger.error( "Blocked resource on external domain: %s" % resource.url) return False return self.validate_url(resource.url) def handle_resource(self, resource): indexed = self.index.get_entry(resource.url) if indexed: self.logger.debug( "[Cache] Resource Key: [%s] is available in the cache with value: [%s]" % (resource.url, indexed) ) # modify the resources path resolution mechanism. return resource.__dict__.__setitem__('filepath', indexed) #: Update the index before doing any processing so that later calls #: in index finds this entry without going in infinite recursion #: Response could have been already present on disk self.index.add_entry(resource.context.url, resource.filepath) if self.validate_resource(resource): self.logger.debug("Processing valid resource: %r" % resource) return self._handle_resource(resource) self.logger.error("Discarding invalid resource: %r" % resource) def _handle_resource(self, resource): raise NotImplementedError() class Collector(SchedulerBase): """A simple resource collector to use when debugging or requires manual collection of sub-files.""" def __init__(self, *args, **kwargs): super(Collector, self).__init__(*args, **kwargs) self.children = list() def _handle_resource(self, resource): self.children.append(resource) class Scheduler(SchedulerBase): def _handle_resource(self, resource): try: self.logger.debug('Scheduler trying to get resource at: [%s]' % resource.url) resource.get(resource.context.url) # NOTE :meth:`get` can change the :attr:`filepath` of the resource self.index.add_resource(resource) except ConnectionError: self.logger.error( "Scheduler ConnectionError Failed to retrieve resource from [%s]" % resource.url) # self.index.add_entry(resource.url, resource.filepath) except Exception as e: self.logger.exception(e) # self.index.add_entry(resource.url, resource.filepath) else: self.logger.debug('Scheduler running handler for: [%s]' % resource.url) resource.retrieve() self.index.add_resource(resource) class ThreadingScheduler(Scheduler): def __init__(self, *args, **kwargs): super(ThreadingScheduler, self).__init__(*args, **kwargs) self.threads = weakref.WeakSet() self.timeout = 1 def __del__(self): self.close() def close(self, timeout=None): if not timeout: timeout = self.timeout threads = self.threads self.threads = None for thread in threads: if thread.is_alive() and thread is not threading.current_thread(): thread.join(timeout) def _handle_resource(self, resource): def run(r): self.logger.debug('Scheduler trying to get resource at: [%s]' % r.url) # r.response = r.session.get(r.context.url) r.get(r.context.url) self.logger.debug('Scheduler running handler for: [%s]' % r.url) r.retrieve() return r.context.url, r.filepath thread = threading.Thread(target=run, args=(resource,)) thread.start() self.threads.add(thread) class GEventScheduler(Scheduler): def __init__(self, maxsize=None, *args, **kwargs): super(GEventScheduler, self).__init__(*args, **kwargs) try: from gevent.pool import Pool except ImportError: raise ImportError( "gevent module is not installed. " "Install it using pip: $ pip install gevent" ) self.pool = Pool(maxsize) def __del__(self): self.close() def close(self, timeout=None): self.pool.kill(timeout=timeout) def _handle_resource(self, resource): def run(r): self.logger.debug('Scheduler trying to get resource at: [%s]' % resource.url) r.response = r.session.get(r.context.url) self.logger.debug('Scheduler running retrieving process: [%s]' % resource.url) r.retrieve() return r.context.url, r.filepath g = self.pool.spawn(run, resource) g.link_value(lambda gl: logger.info("Written the file from <%s> to <%s>" % gl.value)) g.link_exception(lambda gl: logger.error(str(gl.exception))) if PY3: class ThreadPoolScheduler(Scheduler): def __init__(self, maxsize=None, *args, **kwargs): super(ThreadPoolScheduler, self).__init__(*args, **kwargs) import concurrent.futures self.pool = concurrent.futures.ThreadPoolExecutor(maxsize) def __del__(self): self.close() def close(self, wait=None): self.pool.shutdown(wait) def _handle_resource(self, resource): def run(r): self.logger.debug('Scheduler trying to get resource at: [%s]' % resource.url) r.response = r.session.get(r.context.url) self.logger.debug('Scheduler running retrieving process: [%s]' % resource.url) r.retrieve() return r.context.url, r.filepath def callback(ret): if ret.exception(): self.logger.error(str(ret.exception())) else: self.logger.info("Written the file from <%s> to <%s>" % ret.result()) g = self.pool.submit(run, resource) g.add_done_callback(callback) def thread_pool_default_scheduler(maxsize=4): ans = ThreadPoolScheduler(maxsize=maxsize) fac = default_scheduler() ans.default = fac.default ans.data = fac.data del fac return ans def thread_pool_crawler_scheduler(maxsize=4): ans = thread_pool_default_scheduler(maxsize=maxsize) for k in ans.meta_tags: ans.register_handler(k, HTMLResource) for k in ans.external_tags: ans.register_handler(k, HTMLResource) return ans else: class ThreadPoolScheduler(object): def __init__(self, *args, **kwargs): raise RuntimeError( "Python 2 does not have `futures` modules, " "hence you should use any other scheduler link gevent.!" ) def thread_pool_scheduler(maxsize=4): raise RuntimeError( "Python 2 does not have futures modules, " "hence you should use any other scheduler link gevent.!", maxsize ) def thread_pool_crawler_scheduler(maxsize=4): raise RuntimeError( "Python 2 does not have futures modules, " "hence you should use any other scheduler link gevent.!", maxsize ) def default_scheduler(): ans = Scheduler() ans.default = GenericResource for k in ans.style_tags: ans.register_handler(k, CSSResource) for k in ans.img_tags: ans.register_handler(k, GenericResource) for k in ans.script_tags: ans.register_handler(k, JSResource) for k in ans.meta_tags: ans.register_handler(k, GenericResource) for k in ans.external_tags: ans.register_handler(k, AbsoluteUrlResource) return ans def no_js_scheduler(): ans = default_scheduler() for k in ans.script_tags: ans.register_handler(k, UrlRemover) return ans def crawler_scheduler(): ans = default_scheduler() for k in ans.meta_tags: ans.register_handler(k, HTMLResource) for k in ans.external_tags: ans.register_handler(k, HTMLResource) return ans def threading_default_scheduler(): ans = ThreadingScheduler() fac = default_scheduler() ans.default = fac.default ans.data = fac.data del fac return ans def threading_crawler_scheduler(): ans = threading_default_scheduler() for k in ans.meta_tags: ans.register_handler(k, HTMLResource) for k in ans.external_tags: ans.register_handler(k, HTMLResource) return ans def gevent_default_scheduler(maxsize=4): ans = GEventScheduler(maxsize=maxsize) fac = default_scheduler() ans.default = fac.default ans.data = fac.data del fac return ans def gevent_crawler_scheduler(): ans = gevent_default_scheduler() for k in ans.meta_tags: ans.register_handler(k, HTMLResource) for k in ans.external_tags: ans.register_handler(k, HTMLResource) return ans def base64_scheduler(): raise NotImplemented
[ 1, 396, 14187, 1266, 29871, 29906, 29900, 29906, 29900, 29936, 529, 5813, 29958, 13, 29937, 2823, 19405, 363, 901, 4902, 13, 5215, 12183, 13, 5215, 3244, 292, 13, 5215, 8062, 999, 13, 13, 3166, 7274, 1053, 15160, 2392, 13, 3166, 4832, 1053, 349, 29979, 29941, 13, 3166, 4832, 1053, 1347, 29918, 8768, 13, 3166, 4832, 29889, 13529, 267, 29889, 2271, 1982, 29889, 5510, 1053, 3142, 5510, 13, 13, 3166, 869, 17664, 1053, 29434, 6848, 13, 3166, 869, 17664, 1053, 6783, 6848, 13, 3166, 869, 17664, 1053, 7649, 6848, 13, 3166, 869, 17664, 1053, 1976, 14977, 5983, 6848, 13, 3166, 869, 17664, 1053, 3251, 293, 6848, 13, 3166, 869, 17664, 1053, 4544, 6848, 13, 3166, 869, 17664, 1053, 501, 2096, 7301, 957, 13, 3166, 869, 3952, 6774, 1053, 3599, 296, 7514, 287, 21533, 13, 13, 21707, 353, 12183, 29889, 657, 16363, 22168, 978, 1649, 29897, 13, 13, 13, 1990, 11374, 29898, 4789, 296, 7514, 287, 21533, 1125, 13, 1678, 9995, 10547, 2380, 9657, 29889, 13, 13, 1678, 6317, 29873, 8144, 1057, 1207, 372, 2566, 5222, 1133, 13, 1678, 9995, 13, 1678, 822, 4770, 2344, 12035, 1311, 29892, 334, 5085, 29892, 3579, 19290, 1125, 13, 4706, 2428, 29898, 3220, 29892, 1583, 467, 1649, 2344, 1649, 10456, 5085, 29892, 3579, 19290, 29897, 13, 4706, 1583, 29889, 908, 353, 3244, 292, 29889, 16542, 580, 13, 13, 1678, 822, 788, 29918, 8269, 29898, 1311, 29892, 413, 29892, 325, 1125, 13, 4706, 411, 1583, 29889, 908, 29901, 13, 9651, 1583, 17255, 842, 667, 12035, 29895, 29892, 325, 29897, 13, 13, 1678, 822, 679, 29918, 8269, 29898, 1311, 29892, 413, 29892, 2322, 29922, 8516, 1125, 13, 4706, 736, 1583, 29889, 657, 29898, 29895, 29892, 2322, 29922, 4381, 29897, 13, 13, 1678, 822, 788, 29918, 10314, 29898, 1311, 29892, 6503, 1125, 13, 4706, 4423, 353, 6503, 29889, 1445, 2084, 13, 4706, 1583, 29889, 1202, 29918, 8269, 29898, 10314, 29889, 4703, 29889, 2271, 29892, 4423, 29897, 13, 4706, 565, 756, 5552, 29898, 10314, 29889, 5327, 29892, 525, 2271, 29374, 13, 9651, 1583, 29889, 1202, 29918, 8269, 29898, 10314, 29889, 5327, 29889, 2271, 29892, 4423, 29897, 13, 9651, 565, 6503, 29889, 5327, 29889, 18434, 29901, 13, 18884, 363, 364, 297, 6503, 29889, 5327, 29889, 18434, 29901, 13, 462, 1678, 1583, 29889, 1202, 29918, 8269, 29898, 29878, 29889, 2271, 29892, 4423, 29897, 13, 13, 1678, 2380, 29918, 10314, 353, 788, 29918, 10314, 13, 13, 13, 1990, 1102, 14952, 5160, 29898, 3318, 1125, 13, 1678, 9995, 29909, 317, 9524, 3368, 6503, 21433, 29889, 13, 13, 1678, 3497, 10898, 723, 367, 2729, 373, 278, 2793, 29899, 1853, 4839, 4133, 491, 278, 1923, 13, 1678, 541, 445, 723, 367, 5232, 1363, 310, 1641, 12231, 681, 541, 338, 1407, 23279, 29889, 13, 1678, 9995, 13, 1678, 3114, 29918, 11338, 353, 14671, 29920, 575, 300, 18959, 2324, 742, 525, 3293, 11287, 13, 1678, 10153, 29918, 11338, 353, 14671, 29920, 575, 300, 18959, 2492, 11287, 13, 1678, 2471, 29918, 11338, 353, 14671, 29920, 575, 300, 18959, 2154, 11287, 13, 1678, 12700, 29918, 11338, 353, 14671, 29920, 575, 300, 18959, 7299, 11287, 13, 1678, 7463, 29918, 11338, 353, 313, 3293, 29918, 11338, 891, 10153, 29918, 11338, 891, 2471, 29918, 11338, 891, 12700, 29918, 11338, 29897, 13, 1678, 7029, 29918, 11338, 353, 14671, 29920, 575, 300, 18959, 29874, 742, 525, 689, 742, 525, 22000, 11287, 13, 1678, 8282, 353, 313, 7564, 29918, 11338, 891, 7029, 29918, 11338, 29897, 13, 13, 1678, 822, 4770, 2344, 12035, 1311, 29892, 2322, 29922, 8516, 29892, 3579, 1272, 1125, 13, 4706, 1583, 29889, 1272, 353, 9657, 580, 13, 4706, 1583, 29889, 1272, 29889, 5504, 29898, 1272, 29897, 13, 4706, 1583, 29889, 4381, 353, 2322, 13, 4706, 1583, 29889, 2248, 353, 11374, 580, 13, 4706, 1583, 29889, 1271, 29918, 23176, 29918, 3129, 2708, 353, 5852, 13, 4706, 1583, 29889, 21707, 353, 17927, 29889, 657, 5938, 29898, 1311, 17255, 1990, 1649, 17255, 978, 1649, 29897, 13, 13, 1678, 822, 731, 29918, 4381, 29898, 1311, 29892, 2322, 1125, 13, 4706, 1583, 29889, 4381, 353, 2322, 13, 4706, 1583, 29889, 21707, 29889, 3888, 703, 2697, 278, 1364, 14952, 2322, 408, 29901, 518, 29995, 29878, 18017, 1273, 2322, 29897, 13, 13, 1678, 822, 6036, 29918, 13789, 29898, 1311, 29892, 1820, 29892, 995, 1125, 13, 4706, 1583, 29889, 1272, 17255, 842, 667, 12035, 1989, 29892, 995, 29897, 13, 4706, 1583, 29889, 21707, 29889, 3888, 29898, 13, 9651, 376, 2697, 278, 1364, 14952, 7834, 363, 1273, 29879, 408, 29901, 518, 29995, 29878, 18017, 1273, 313, 1989, 29892, 995, 876, 13, 13, 1678, 788, 29918, 13789, 353, 6036, 29918, 13789, 13, 13, 1678, 822, 589, 387, 1531, 29918, 13789, 29898, 1311, 29892, 1820, 1125, 13, 4706, 1583, 29889, 1272, 17255, 6144, 667, 12035, 1989, 29897, 13, 4706, 1583, 29889, 21707, 29889, 3888, 703, 7301, 8238, 278, 1364, 14952, 7834, 363, 29901, 1273, 29879, 29908, 1273, 1820, 29897, 13, 13, 1678, 3349, 29918, 13789, 353, 589, 387, 1531, 29918, 13789, 13, 13, 1678, 822, 679, 29918, 13789, 29898, 1311, 29892, 1820, 29892, 334, 5085, 29892, 3579, 7529, 1125, 13, 4706, 565, 1820, 451, 297, 1583, 29889, 1272, 29901, 13, 9651, 565, 1583, 29889, 4381, 338, 6213, 29901, 13, 18884, 12020, 7670, 2392, 29898, 1989, 29897, 13, 9651, 736, 1583, 29889, 4381, 10456, 5085, 29892, 3579, 7529, 29897, 13, 4706, 1683, 29901, 13, 9651, 736, 1583, 29889, 1272, 29961, 1989, 850, 29930, 5085, 29892, 3579, 7529, 29897, 13, 13, 1678, 8340, 29918, 11993, 353, 18761, 4197, 13, 4706, 525, 1272, 742, 525, 7729, 742, 525, 2549, 517, 742, 13, 268, 2314, 13, 13, 1678, 822, 12725, 29918, 2271, 29898, 1311, 29892, 3142, 1125, 13, 4706, 565, 451, 338, 8758, 29898, 2271, 29892, 1347, 29918, 8768, 1125, 13, 9651, 1583, 29889, 21707, 29889, 2704, 29898, 13, 18884, 376, 1252, 6021, 1347, 1134, 29892, 2355, 1273, 29878, 29908, 1273, 3142, 29897, 13, 9651, 736, 7700, 13, 4706, 11380, 29892, 3495, 29892, 2011, 29892, 2224, 29892, 2346, 29892, 13855, 353, 3142, 5510, 29898, 2271, 29897, 13, 4706, 565, 11380, 297, 1583, 29889, 20965, 29918, 11993, 29901, 13, 9651, 1583, 29889, 21707, 29889, 2704, 29898, 13, 18884, 376, 13919, 3142, 10938, 29901, 518, 29995, 29879, 29962, 363, 3142, 29901, 518, 29995, 29879, 18017, 13, 18884, 1273, 313, 816, 2004, 29892, 3142, 876, 13, 9651, 736, 7700, 13, 4706, 736, 5852, 13, 13, 1678, 822, 12725, 29918, 10314, 29898, 1311, 29892, 6503, 1125, 13, 4706, 565, 451, 338, 8758, 29898, 10314, 29892, 3251, 293, 6848, 1125, 13, 9651, 1583, 29889, 21707, 29889, 2704, 29898, 13, 18884, 376, 1252, 6021, 3251, 293, 6848, 29892, 2355, 1273, 29878, 29908, 1273, 6503, 29897, 13, 9651, 736, 7700, 13, 4706, 565, 338, 8758, 29898, 10314, 29892, 29434, 6848, 1125, 13, 9651, 1583, 29889, 21707, 29889, 2704, 29898, 13, 18884, 376, 29903, 1984, 3262, 29434, 6848, 29901, 1273, 29878, 29908, 1273, 6503, 29897, 13, 9651, 736, 7700, 13, 4706, 565, 451, 338, 8758, 29898, 10314, 29889, 2271, 29892, 1347, 29918, 8768, 1125, 13, 9651, 1583, 29889, 21707, 29889, 2704, 29898, 13, 18884, 376, 1252, 6021, 3142, 310, 1347, 1134, 29892, 2355, 1273, 29878, 29908, 1273, 6503, 29889, 2271, 29897, 13, 9651, 736, 7700, 13, 4706, 565, 338, 8758, 29898, 10314, 29892, 4544, 6848, 29897, 322, 1583, 29889, 1271, 29918, 23176, 29918, 3129, 2708, 29901, 13, 9651, 396, 383, 6415, 2303, 29901, 10726, 278, 5687, 304, 14707, 28937, 29889, 13, 9651, 396, 1596, 29898, 10314, 29889, 2271, 29892, 6503, 29889, 4703, 29897, 13, 9651, 565, 451, 6503, 29889, 2271, 29889, 27382, 2541, 29898, 10314, 29889, 4703, 29889, 3188, 29918, 2271, 1125, 13, 18884, 1583, 29889, 21707, 29889, 2704, 29898, 13, 462, 1678, 376, 7445, 287, 6503, 373, 7029, 5354, 29901, 1273, 29879, 29908, 1273, 6503, 29889, 2271, 29897, 13, 18884, 736, 7700, 13, 4706, 736, 1583, 29889, 15480, 29918, 2271, 29898, 10314, 29889, 2271, 29897, 13, 13, 1678, 822, 4386, 29918, 10314, 29898, 1311, 29892, 6503, 1125, 13, 4706, 27541, 353, 1583, 29889, 2248, 29889, 657, 29918, 8269, 29898, 10314, 29889, 2271, 29897, 13, 4706, 565, 27541, 29901, 13, 9651, 1583, 29889, 21707, 29889, 8382, 29898, 13, 18884, 14704, 10408, 29962, 18981, 7670, 29901, 518, 29995, 29879, 29962, 338, 3625, 297, 278, 7090, 411, 995, 29901, 518, 29995, 29879, 18017, 13, 18884, 1273, 313, 10314, 29889, 2271, 29892, 27541, 29897, 13, 9651, 1723, 13, 9651, 396, 6623, 278, 7788, 2224, 10104, 13336, 29889, 13, 9651, 736, 6503, 17255, 8977, 1649, 17255, 842, 667, 1649, 877, 1445, 2084, 742, 27541, 29897, 13, 13, 4706, 396, 29901, 10318, 278, 2380, 1434, 2599, 738, 9068, 577, 393, 2678, 5717, 13, 4706, 396, 29901, 297, 2380, 14061, 445, 6251, 1728, 2675, 297, 10362, 20437, 13, 4706, 396, 29901, 13291, 1033, 505, 1063, 2307, 2198, 373, 8086, 13, 4706, 1583, 29889, 2248, 29889, 1202, 29918, 8269, 29898, 10314, 29889, 4703, 29889, 2271, 29892, 6503, 29889, 1445, 2084, 29897, 13, 13, 4706, 565, 1583, 29889, 15480, 29918, 10314, 29898, 10314, 1125, 13, 9651, 1583, 29889, 21707, 29889, 8382, 703, 7032, 292, 2854, 6503, 29901, 1273, 29878, 29908, 1273, 6503, 29897, 13, 9651, 736, 1583, 3032, 8411, 29918, 10314, 29898, 10314, 29897, 13, 4706, 1583, 29889, 21707, 29889, 2704, 703, 4205, 7543, 292, 8340, 6503, 29901, 1273, 29878, 29908, 1273, 6503, 29897, 13, 13, 1678, 822, 903, 8411, 29918, 10314, 29898, 1311, 29892, 6503, 1125, 13, 4706, 12020, 2216, 1888, 2037, 287, 2392, 580, 13, 13, 13, 1990, 24930, 272, 29898, 4504, 14952, 5160, 1125, 13, 1678, 9995, 29909, 2560, 6503, 6314, 272, 304, 671, 746, 13490, 13, 1678, 470, 6858, 12219, 4333, 310, 1014, 29899, 5325, 1213, 15945, 13, 1678, 822, 4770, 2344, 12035, 1311, 29892, 334, 5085, 29892, 3579, 19290, 1125, 13, 4706, 2428, 29898, 28916, 272, 29892, 1583, 467, 1649, 2344, 1649, 10456, 5085, 29892, 3579, 19290, 29897, 13, 4706, 1583, 29889, 11991, 353, 1051, 580, 13, 13, 1678, 822, 903, 8411, 29918, 10314, 29898, 1311, 29892, 6503, 1125, 13, 4706, 1583, 29889, 11991, 29889, 4397, 29898, 10314, 29897, 13, 13, 13, 1990, 1102, 14952, 29898, 4504, 14952, 5160, 1125, 13, 1678, 822, 903, 8411, 29918, 10314, 29898, 1311, 29892, 6503, 1125, 13, 4706, 1018, 29901, 13, 9651, 1583, 29889, 21707, 29889, 8382, 877, 4504, 14952, 1811, 304, 679, 6503, 472, 29901, 518, 29995, 29879, 29962, 29915, 1273, 6503, 29889, 2271, 29897, 13, 9651, 6503, 29889, 657, 29898, 10314, 29889, 4703, 29889, 2271, 29897, 13, 9651, 396, 6058, 29923, 584, 29885, 621, 18078, 657, 29952, 508, 1735, 278, 584, 5552, 18078, 1445, 2084, 29952, 310, 278, 6503, 13, 9651, 1583, 29889, 2248, 29889, 1202, 29918, 10314, 29898, 10314, 29897, 13, 4706, 5174, 15160, 2392, 29901, 13, 9651, 1583, 29889, 21707, 29889, 2704, 29898, 13, 18884, 376, 4504, 14952, 15160, 2392, 18390, 304, 10563, 6503, 515, 518, 29995, 29879, 18017, 13, 18884, 1273, 6503, 29889, 2271, 29897, 13, 9651, 396, 1583, 29889, 2248, 29889, 1202, 29918, 8269, 29898, 10314, 29889, 2271, 29892, 6503, 29889, 1445, 2084, 29897, 13, 4706, 5174, 8960, 408, 321, 29901, 13, 9651, 1583, 29889, 21707, 29889, 11739, 29898, 29872, 29897, 13, 9651, 396, 1583, 29889, 2248, 29889, 1202, 29918, 8269, 29898, 10314, 29889, 2271, 29892, 6503, 29889, 1445, 2084, 29897, 13, 4706, 1683, 29901, 13, 9651, 1583, 29889, 21707, 29889, 8382, 877, 4504, 14952, 2734, 7834, 363, 29901, 518, 29995, 29879, 29962, 29915, 1273, 6503, 29889, 2271, 29897, 13, 9651, 6503, 29889, 276, 509, 2418, 580, 13, 4706, 1583, 29889, 2248, 29889, 1202, 29918, 10314, 29898, 10314, 29897, 13, 13, 13, 1990, 10480, 292, 4504, 14952, 29898, 4504, 14952, 1125, 13, 1678, 822, 4770, 2344, 12035, 1311, 29892, 334, 5085, 29892, 3579, 19290, 1125, 13, 4706, 2428, 29898, 4899, 292, 4504, 14952, 29892, 1583, 467, 1649, 2344, 1649, 10456, 5085, 29892, 3579, 19290, 29897, 13, 4706, 1583, 29889, 28993, 353, 8062, 999, 29889, 4806, 557, 2697, 580, 13, 4706, 1583, 29889, 15619, 353, 29871, 29896, 13, 13, 1678, 822, 4770, 6144, 12035, 1311, 1125, 13, 4706, 1583, 29889, 5358, 580, 13, 13, 1678, 822, 3802, 29898, 1311, 29892, 11815, 29922, 8516, 1125, 13, 4706, 565, 451, 11815, 29901, 13, 9651, 11815, 353, 1583, 29889, 15619, 13, 4706, 9717, 353, 1583, 29889, 28993, 13, 4706, 1583, 29889, 28993, 353, 6213, 13, 4706, 363, 3244, 297, 9717, 29901, 13, 9651, 565, 3244, 29889, 275, 29918, 284, 573, 580, 322, 3244, 338, 451, 3244, 292, 29889, 3784, 29918, 7097, 7295, 13, 18884, 3244, 29889, 7122, 29898, 15619, 29897, 13, 13, 1678, 822, 903, 8411, 29918, 10314, 29898, 1311, 29892, 6503, 1125, 13, 4706, 822, 1065, 29898, 29878, 1125, 13, 9651, 1583, 29889, 21707, 29889, 8382, 877, 4504, 14952, 1811, 304, 679, 6503, 472, 29901, 518, 29995, 29879, 29962, 29915, 1273, 364, 29889, 2271, 29897, 13, 9651, 396, 364, 29889, 5327, 353, 364, 29889, 7924, 29889, 657, 29898, 29878, 29889, 4703, 29889, 2271, 29897, 13, 9651, 364, 29889, 657, 29898, 29878, 29889, 4703, 29889, 2271, 29897, 13, 9651, 1583, 29889, 21707, 29889, 8382, 877, 4504, 14952, 2734, 7834, 363, 29901, 518, 29995, 29879, 29962, 29915, 1273, 364, 29889, 2271, 29897, 13, 9651, 364, 29889, 276, 509, 2418, 580, 13, 9651, 736, 364, 29889, 4703, 29889, 2271, 29892, 364, 29889, 1445, 2084, 13, 4706, 3244, 353, 3244, 292, 29889, 4899, 29898, 5182, 29922, 3389, 29892, 6389, 7607, 10314, 29892, 876, 13, 4706, 3244, 29889, 2962, 580, 13, 4706, 1583, 29889, 28993, 29889, 1202, 29898, 7097, 29897, 13, 13, 13, 1990, 402, 2624, 4504, 14952, 29898, 4504, 14952, 1125, 13, 1678, 822, 4770, 2344, 12035, 1311, 29892, 4236, 2311, 29922, 8516, 29892, 334, 5085, 29892, 3579, 19290, 1125, 13, 4706, 2428, 29898, 1692, 794, 4504, 14952, 29892, 1583, 467, 1649, 2344, 1649, 10456, 5085, 29892, 3579, 19290, 29897, 13, 4706, 1018, 29901, 13, 9651, 515, 1737, 794, 29889, 10109, 1053, 28625, 13, 4706, 5174, 16032, 2392, 29901, 13, 9651, 12020, 16032, 2392, 29898, 13, 18884, 376, 479, 794, 3883, 338, 451, 5130, 29889, 376, 13, 18884, 376, 23271, 372, 773, 8450, 29901, 395, 8450, 2601, 1737, 794, 29908, 13, 9651, 1723, 13, 4706, 1583, 29889, 10109, 353, 28625, 29898, 3317, 2311, 29897, 13, 13, 1678, 822, 4770, 6144, 12035, 1311, 1125, 13, 4706, 1583, 29889, 5358, 580, 13, 13, 1678, 822, 3802, 29898, 1311, 29892, 11815, 29922, 8516, 1125, 13, 4706, 1583, 29889, 10109, 29889, 21174, 29898, 15619, 29922, 15619, 29897, 13, 13, 1678, 822, 903, 8411, 29918, 10314, 29898, 1311, 29892, 6503, 1125, 13, 4706, 822, 1065, 29898, 29878, 1125, 13, 9651, 1583, 29889, 21707, 29889, 8382, 877, 4504, 14952, 1811, 304, 679, 6503, 472, 29901, 518, 29995, 29879, 29962, 29915, 1273, 6503, 29889, 2271, 29897, 13, 9651, 364, 29889, 5327, 353, 364, 29889, 7924, 29889, 657, 29898, 29878, 29889, 4703, 29889, 2271, 29897, 13, 9651, 1583, 29889, 21707, 29889, 8382, 877, 4504, 14952, 2734, 5663, 15387, 1889, 29901, 518, 29995, 29879, 29962, 29915, 1273, 6503, 29889, 2271, 29897, 13, 9651, 364, 29889, 276, 509, 2418, 580, 13, 9651, 736, 364, 29889, 4703, 29889, 2271, 29892, 364, 29889, 1445, 2084, 13, 13, 4706, 330, 353, 1583, 29889, 10109, 29889, 1028, 18101, 29898, 3389, 29892, 6503, 29897, 13, 4706, 330, 29889, 2324, 29918, 1767, 29898, 2892, 3144, 29901, 17927, 29889, 3888, 703, 29956, 20833, 278, 934, 515, 20577, 29879, 29958, 304, 20577, 29879, 11903, 1273, 3144, 29889, 1767, 876, 13, 4706, 330, 29889, 2324, 29918, 11739, 29898, 2892, 3144, 29901, 17927, 29889, 2704, 29898, 710, 29898, 3820, 29889, 11739, 4961, 13, 13, 13, 361, 349, 29979, 29941, 29901, 13, 1678, 770, 10480, 11426, 4504, 14952, 29898, 4504, 14952, 1125, 13, 4706, 822, 4770, 2344, 12035, 1311, 29892, 4236, 2311, 29922, 8516, 29892, 334, 5085, 29892, 3579, 19290, 1125, 13, 9651, 2428, 29898, 23574, 4504, 14952, 29892, 1583, 467, 1649, 2344, 1649, 10456, 5085, 29892, 3579, 19290, 29897, 13, 9651, 1053, 21984, 29889, 29888, 329, 1973, 13, 9651, 1583, 29889, 10109, 353, 21984, 29889, 29888, 329, 1973, 29889, 23574, 13366, 29898, 3317, 2311, 29897, 13, 13, 4706, 822, 4770, 6144, 12035, 1311, 1125, 13, 9651, 1583, 29889, 5358, 580, 13, 13, 4706, 822, 3802, 29898, 1311, 29892, 4480, 29922, 8516, 1125, 13, 9651, 1583, 29889, 10109, 29889, 845, 329, 3204, 29898, 10685, 29897, 13, 13, 4706, 822, 903, 8411, 29918, 10314, 29898, 1311, 29892, 6503, 1125, 13, 9651, 822, 1065, 29898, 29878, 1125, 13, 18884, 1583, 29889, 21707, 29889, 8382, 877, 4504, 14952, 1811, 304, 679, 6503, 472, 29901, 518, 29995, 29879, 29962, 29915, 1273, 6503, 29889, 2271, 29897, 13, 18884, 364, 29889, 5327, 353, 364, 29889, 7924, 29889, 657, 29898, 29878, 29889, 4703, 29889, 2271, 29897, 13, 18884, 1583, 29889, 21707, 29889, 8382, 877, 4504, 14952, 2734, 5663, 15387, 1889, 29901, 518, 29995, 29879, 29962, 29915, 1273, 6503, 29889, 2271, 29897, 13, 18884, 364, 29889, 276, 509, 2418, 580, 13, 18884, 736, 364, 29889, 4703, 29889, 2271, 29892, 364, 29889, 1445, 2084, 13, 13, 9651, 822, 6939, 29898, 2267, 1125, 13, 18884, 565, 3240, 29889, 11739, 7295, 13, 462, 1678, 1583, 29889, 21707, 29889, 2704, 29898, 710, 29898, 2267, 29889, 11739, 22130, 13, 18884, 1683, 29901, 13, 462, 1678, 1583, 29889, 21707, 29889, 3888, 703, 29956, 20833, 278, 934, 515, 20577, 29879, 29958, 304, 20577, 29879, 11903, 1273, 3240, 29889, 2914, 3101, 13, 13, 9651, 330, 353, 1583, 29889, 10109, 29889, 7892, 29898, 3389, 29892, 6503, 29897, 13, 9651, 330, 29889, 1202, 29918, 15091, 29918, 14035, 29898, 14035, 29897, 13, 13, 1678, 822, 3244, 29918, 10109, 29918, 4381, 29918, 816, 14952, 29898, 3317, 2311, 29922, 29946, 1125, 13, 4706, 6063, 353, 10480, 11426, 4504, 14952, 29898, 3317, 2311, 29922, 3317, 2311, 29897, 13, 4706, 4024, 353, 2322, 29918, 816, 14952, 580, 13, 4706, 6063, 29889, 4381, 353, 4024, 29889, 4381, 13, 4706, 6063, 29889, 1272, 353, 4024, 29889, 1272, 13, 4706, 628, 4024, 13, 4706, 736, 6063, 13, 13, 1678, 822, 3244, 29918, 10109, 29918, 29883, 1610, 1358, 29918, 816, 14952, 29898, 3317, 2311, 29922, 29946, 1125, 13, 4706, 6063, 353, 3244, 29918, 10109, 29918, 4381, 29918, 816, 14952, 29898, 3317, 2311, 29922, 3317, 2311, 29897, 13, 4706, 363, 413, 297, 6063, 29889, 7299, 29918, 11338, 29901, 13, 9651, 6063, 29889, 9573, 29918, 13789, 29898, 29895, 29892, 4544, 6848, 29897, 13, 4706, 363, 413, 297, 6063, 29889, 23176, 29918, 11338, 29901, 13, 9651, 6063, 29889, 9573, 29918, 13789, 29898, 29895, 29892, 4544, 6848, 29897, 13, 4706, 736, 6063, 13, 13, 2870, 29901, 13, 1678, 770, 10480, 11426, 4504, 14952, 29898, 3318, 1125, 13, 4706, 822, 4770, 2344, 12035, 1311, 29892, 334, 5085, 29892, 3579, 19290, 1125, 13, 9651, 12020, 24875, 2392, 29898, 13, 18884, 376, 11980, 29871, 29906, 947, 451, 505, 421, 29888, 329, 1973, 29952, 10585, 29892, 376, 13, 18884, 376, 29882, 663, 366, 881, 671, 738, 916, 1364, 14952, 1544, 1737, 794, 29889, 3850, 13, 9651, 1723, 13, 13, 1678, 822, 3244, 29918, 10109, 29918, 816, 14952, 29898, 3317, 2311, 29922, 29946, 1125, 13, 4706, 12020, 24875, 2392, 29898, 13, 9651, 376, 11980, 29871, 29906, 947, 451, 505, 3105, 1973, 10585, 29892, 376, 13, 9651, 376, 29882, 663, 366, 881, 671, 738, 916, 1364, 14952, 1544, 1737, 794, 29889, 29991, 613, 4236, 2311, 13, 4706, 1723, 13, 13, 1678, 822, 3244, 29918, 10109, 29918, 29883, 1610, 1358, 29918, 816, 14952, 29898, 3317, 2311, 29922, 29946, 1125, 13, 4706, 12020, 24875, 2392, 29898, 13, 9651, 376, 11980, 29871, 29906, 947, 451, 505, 3105, 1973, 10585, 29892, 376, 13, 9651, 376, 29882, 663, 366, 881, 671, 738, 916, 1364, 14952, 1544, 1737, 794, 29889, 29991, 613, 4236, 2311, 13, 4706, 1723, 13, 13, 13, 1753, 2322, 29918, 816, 14952, 7295, 13, 1678, 6063, 353, 1102, 14952, 580, 13, 1678, 6063, 29889, 4381, 353, 3251, 293, 6848, 13, 1678, 363, 413, 297, 6063, 29889, 3293, 29918, 11338, 29901, 13, 4706, 6063, 29889, 9573, 29918, 13789, 29898, 29895, 29892, 6783, 6848, 29897, 13, 1678, 363, 413, 297, 6063, 29889, 2492, 29918, 11338, 29901, 13, 4706, 6063, 29889, 9573, 29918, 13789, 29898, 29895, 29892, 3251, 293, 6848, 29897, 13, 1678, 363, 413, 297, 6063, 29889, 2154, 29918, 11338, 29901, 13, 4706, 6063, 29889, 9573, 29918, 13789, 29898, 29895, 29892, 7649, 6848, 29897, 13, 1678, 363, 413, 297, 6063, 29889, 7299, 29918, 11338, 29901, 13, 4706, 6063, 29889, 9573, 29918, 13789, 29898, 29895, 29892, 3251, 293, 6848, 29897, 13, 1678, 363, 413, 297, 6063, 29889, 23176, 29918, 11338, 29901, 13, 4706, 6063, 29889, 9573, 29918, 13789, 29898, 29895, 29892, 1976, 14977, 5983, 6848, 29897, 13, 1678, 736, 6063, 13, 13, 13, 1753, 694, 29918, 1315, 29918, 816, 14952, 7295, 13, 1678, 6063, 353, 2322, 29918, 816, 14952, 580, 13, 1678, 363, 413, 297, 6063, 29889, 2154, 29918, 11338, 29901, 13, 4706, 6063, 29889, 9573, 29918, 13789, 29898, 29895, 29892, 501, 2096, 7301, 957, 29897, 13, 1678, 736, 6063, 13, 13, 13, 1753, 29349, 1358, 29918, 816, 14952, 7295, 13, 1678, 6063, 353, 2322, 29918, 816, 14952, 580, 13, 1678, 363, 413, 297, 6063, 29889, 7299, 29918, 11338, 29901, 13, 4706, 6063, 29889, 9573, 29918, 13789, 29898, 29895, 29892, 4544, 6848, 29897, 13, 1678, 363, 413, 297, 6063, 29889, 23176, 29918, 11338, 29901, 13, 4706, 6063, 29889, 9573, 29918, 13789, 29898, 29895, 29892, 4544, 6848, 29897, 13, 1678, 736, 6063, 13, 13, 13, 1753, 3244, 292, 29918, 4381, 29918, 816, 14952, 7295, 13, 1678, 6063, 353, 10480, 292, 4504, 14952, 580, 13, 1678, 4024, 353, 2322, 29918, 816, 14952, 580, 13, 1678, 6063, 29889, 4381, 353, 4024, 29889, 4381, 13, 1678, 6063, 29889, 1272, 353, 4024, 29889, 1272, 13, 1678, 628, 4024, 13, 1678, 736, 6063, 13, 13, 13, 1753, 3244, 292, 29918, 29883, 1610, 1358, 29918, 816, 14952, 7295, 13, 1678, 6063, 353, 3244, 292, 29918, 4381, 29918, 816, 14952, 580, 13, 1678, 363, 413, 297, 6063, 29889, 7299, 29918, 11338, 29901, 13, 4706, 6063, 29889, 9573, 29918, 13789, 29898, 29895, 29892, 4544, 6848, 29897, 13, 1678, 363, 413, 297, 6063, 29889, 23176, 29918, 11338, 29901, 13, 4706, 6063, 29889, 9573, 29918, 13789, 29898, 29895, 29892, 4544, 6848, 29897, 13, 1678, 736, 6063, 13, 13, 13, 1753, 1737, 794, 29918, 4381, 29918, 816, 14952, 29898, 3317, 2311, 29922, 29946, 1125, 13, 1678, 6063, 353, 402, 2624, 4504, 14952, 29898, 3317, 2311, 29922, 3317, 2311, 29897, 13, 1678, 4024, 353, 2322, 29918, 816, 14952, 580, 13, 1678, 6063, 29889, 4381, 353, 4024, 29889, 4381, 13, 1678, 6063, 29889, 1272, 353, 4024, 29889, 1272, 13, 1678, 628, 4024, 13, 1678, 736, 6063, 13, 13, 13, 1753, 1737, 794, 29918, 29883, 1610, 1358, 29918, 816, 14952, 7295, 13, 1678, 6063, 353, 1737, 794, 29918, 4381, 29918, 816, 14952, 580, 13, 1678, 363, 413, 297, 6063, 29889, 7299, 29918, 11338, 29901, 13, 4706, 6063, 29889, 9573, 29918, 13789, 29898, 29895, 29892, 4544, 6848, 29897, 13, 1678, 363, 413, 297, 6063, 29889, 23176, 29918, 11338, 29901, 13, 4706, 6063, 29889, 9573, 29918, 13789, 29898, 29895, 29892, 4544, 6848, 29897, 13, 1678, 736, 6063, 13, 13, 13, 1753, 2967, 29953, 29946, 29918, 816, 14952, 7295, 13, 1678, 12020, 2216, 1888, 2037, 287, 13, 2 ]
kardioml/segmentation/teijeiro/model/interpretation.py
Seb-Good/physionet-challenge-2020
13
120358
<gh_stars>10-100 # -*- coding: utf-8 -*- # pylint: disable-msg=E0202, E0102, E1101, E1103, E1001 """ Created on Fri Jan 24 09:46:28 2014 This module contains the definition of the interpretation class, which is the basic unit of the search process which tries to solve interpretation problems. @author: <NAME> """ from .observable import Observable, EventObservable, between, overlap, end_cmp_key from .interval import Interval as Iv from .constraint_network import verify import kardioml.segmentation.teijeiro.knowledge.abstraction_patterns as ap import kardioml.segmentation.teijeiro.knowledge.constants as C import kardioml.segmentation.teijeiro.acquisition.obs_buffer as obsbuf import sortedcontainers import weakref import copy import numpy as np from collections import deque, namedtuple as nt ################################################## ## Utility functions to detect merge situations ## ################################################## def _pat_mergeable(p1, p2): """ Compare two *AbstractionPattern* instances for equality regarding an interpretation merging operation. Evidence and hypothesis comparison is assumed to be positive, so only the automata and the initial and final states are compared. """ if p1 is None or p2 is None: return p1 is p2 return p1.automata is p2.automata and p1.istate == p2.istate and p1.fstate == p2.fstate def _focus_mergeable(f1, f2): """ Compare two focuses of attention for equality regarding an interpretation merging operation. The length of the lists within the two focuses are assumed to be equal, but this has to be tested separately. """ return all( f1._lst[i][0] == f2._lst[i][0] and _pat_mergeable(f1._lst[i][1], f2._lst[i][1]) for i in range(len(f1._lst) - 1, -1, -1) ) class PastMetrics(nt('PastMetrics', 'time, abst, abstime, nhyp')): """ Tuple to store relevant information to evaluate an interpretation until a specific time, to allow discard old observations. """ __slots__ = () def diff(self, other): """ Obtains the difference between two PastMetrics tuples, returned as a numpy array with three components. *time* attribute is excluded from diff. """ return np.array((self.abst - other.abst, self.abstime - other.abstime, self.nhyp - other.nhyp)) def patch(self, patch): """ Obtains a new PastMetrics object by applying a difference array, obtained by the *diff* method. Parameters ---------- patch: Array, list or tuple with exactly three numerical values. """ return PastMetrics(self.time, *np.array(self[1:] + patch)) class Focus(object): """ This class represents the focus of attention of an interpretation, and it encapsulates all data and functionality related with its management. """ __slots__ = '_lst' def __init__(self, parent_focus=None): """ Initializes a new empty focus of attention, or a shallow copy of an existing focus. Instance Properties ------------------- _lst: Stack containing a number of tuples (observation_or_finding, pattern). If 'observation_or_finding' is a finding, then 'pattern' is the abstraction pattern generating such finding. If is an observation, then 'pattern' is the pattern for which the observation is its hypothesis, or None if it is an initial observation. """ if parent_focus is None: self._lst = [] else: self._lst = parent_focus._lst[:] def __len__(self): return len(self._lst) def __contains__(self, key): return any(key is v for v, _ in self._lst) def __nonzero__(self): return bool(self._lst) def push(self, obs, pattern): """ Inserts a new observation or finding in the focus of attention. """ self._lst.append((obs, pattern)) def pop(self, n=1): """Removes 'n' elements from the focus of attention (1 by default)""" del self._lst[-n] @property def top(self): """Obtains the element at the top of the focus of attention""" return self._lst[-1] @top.setter def top(self, value): """Modifies the element at the top of the focus of attention""" self._lst[-1] = value @property def patterns(self): """ Obtains an iterator over the patterns supporting the observations or findings in the focus of attention, starting at the top of the stack. """ return (p for _, p in reversed(self._lst)) @property def nhyp(self): """Returns the number of abstraction hypotheses in this focus""" return sum(1 for o, p in self._lst if p is not None and o is p.hypothesis) @property def earliest_time(self): """ Returns the minimum starting time of observations or findings in this focus of attention. """ return min(o.earlystart for o, _ in self._lst) def get_delayed_finding(self, observation): """ Obtains the finding that will be matched with an observation once the observation is fully observed, or None if the observation will not be matched with a finding. """ for i in range(len(self._lst) - 1, 0, -1): if self._lst[i][0] is observation: f, p = self._lst[i - 1] if p is not None and f is p.finding: return f break return None def match(self, finding, obs): """ Performs a matching operation between the finding at the top of the focus with a given observation, checking the time and value consistency of the matching. After consistency is checked, the finding is removed from the focus by means of a pop() operation. """ f, pat = self._lst[-1] assert finding is f verify( obs not in pat.evidence[pat.get_evidence_type(f)[0]], 'Observation {0} is already in the evidence of {1} pattern', (obs, pat), ) patcp = copy.copy(pat) patcp.match(f, obs) # The hypothesis generating the finding is updated self._lst[-2] = (patcp.hypothesis, patcp) # And the matched finding removed from the focus del self._lst[-1] class Interpretation(object): """ This class represents the interpretation entity, which is a consistent group of abstraction hypotheses combined by the knowledge expressed in abstraction patterns. It is the basic entity in our search process, and the result of an interpretation process. """ __slots__ = ( 'name', '_parent', 'child', 'observations', 'unintelligible', 'singletons', 'abstracted', 'nabd', 'focus', 'past_metrics', 'predinfo', '__weakref__', ) counter = 0 def __init__(self, parent=None): """ Creates a new empty interpretation, initializing its attributes as a shallow copy or a direct assigment of the attributes of the parent. If parent is None, the attributes will be empty. Instance Properties ------------------- name: Unique identificator of the interpretation. parent: Interpretation from which this one is derived, or None if this is a root interpretation. child: List of interpretations derived from this one. past_metrics: Summary of old information used for heuristics calculation. observations: Sortedlist containing all the observations in the interpretation, ordered by their start time. NOTE: This property is directly assigned from parent interpretation by default. singletons: Set with all Singleton hypotheses that are present in this interpretation. NOTE: This property is directly assigned from parent interpretation by default. abstracted: SortedList containing all the observations that are abstracted by some abstraction pattern in this interpretation. NOTE: This property is directly assigned from parent interpretation by default unintelligible: SortedList containing all the observations that cannot be abstracted by any abstraction pattern. NOTE: This property is directly assigned from parent interpretation by default. nabd: Number of hypotheses in the interpretation that can be abstracted by a higher-level hypothesis. This value is used for the evaluation of the interpretation. focus: Stack containing the focus of attention of the interpretation. Each element in this stack is an observation or a non-matched finding of a pattern. predinfo: Dictionary to store predecessor information for consecutive observations. Each entry is a 2-tuple (observation, type) with the predecessor observation and the type declared by the pattern for the consecutivity relation. NOTE: This property is directly assigned from parent interpretation by default. """ self.name = str(Interpretation.counter) if parent is None: self._parent = None self.child = [] self.observations = sortedcontainers.SortedList(key=end_cmp_key) self.singletons = set() self.abstracted = sortedcontainers.SortedList(key=end_cmp_key) self.unintelligible = sortedcontainers.SortedList(key=end_cmp_key) self.nabd = 0 self.past_metrics = PastMetrics(0, 0, 0, 0) self.focus = Focus() self.predinfo = {} else: self._parent = weakref.ref(parent, self._on_parent_deleted) self.child = [] self.parent.child.append(self) self.observations = parent.observations self.singletons = parent.singletons self.abstracted = parent.abstracted self.unintelligible = parent.unintelligible self.nabd = parent.nabd self.past_metrics = parent.past_metrics self.focus = Focus(parent.focus) self.predinfo = parent.predinfo Interpretation.counter += 1 def __str__(self): """ Obtains the representation of the interpretation as a character string. """ return self.name def __repr__(self): return self.name def _on_parent_deleted(self, _): """ Callback function called when the parent interpretation is deleted. """ self._parent = None def _get_types(self, obs): """ Obtains a tuple with the types that are used respect to an observation, both as hypothesis and as evidence of different patterns. """ types = {type(obs)}.union({p.get_evidence_type(obs)[0] for p in self.pat_map[obs][1]}) dmatch = self.get_delayed_finding(obs) if dmatch is not None: types = types.union( {type(dmatch)}, {p.get_evidence_type(dmatch)[0] for p in self.pat_map[dmatch][1]} ) return tuple(types) def _get_proper_obs(self, clazz=Observable, start=0, end=np.inf, filt=lambda obs: True, reverse=False): """ Obtains a list of observations matching the search criteria, ordered by the earliest time of the observation. Parameters ---------- clazz: Only instances of the *clazz* class (or any subclass) are returned. start: Only observations whose earlystart attribute is after or equal this parameter are returned. end: Only observations whose lateend attribute is lower or equal this parameter are returned. filt: General filter provided as a boolean function that accepts an observation as a parameter. Only the observations satisfying this filter are returned. reverse: Boolean parameter. If True, observations are returned in reversed order, from last to first. """ dummy = EventObservable() if start == 0: idx = 0 else: dummy.time.value = Iv(start, start) idx = self.observations.bisect_left(dummy) if end == np.inf: udx = len(self.observations) else: dummy.time.value = Iv(end, end) udx = self.observations.bisect_right(dummy) return ( obs for obs in self.observations.islice(idx, udx, reverse) if obs.earlystart >= start and isinstance(obs, clazz) and filt(obs) ) @property def is_firm(self): """ Checks if an interpretation is firm, that is, there are no unmatched findings and all the abstraction patterns involved have a sufficient set of evidence to support their hypothesis. """ return all(p is None or p.sufficient_evidence for p in self.focus.patterns) @property def time_point(self): """ Obtains the time point of an interpretation, that is, the end time value of the last base evidence being considered as evidence of any hypothesis in the interpretation. If there are no hypothesis in the interpretation, then the time point is just before the first available observation. """ lastfocus = max( 0, ( self.focus.top[0].earlystart - 1 if self.focus else next(self.get_observations()).earlystart - 1 ), ) return max(self.abstracted[-1].lateend, lastfocus) if self.abstracted else lastfocus @property def parent(self): """ Obtains the parent of an interpretation. """ return self._parent() if self._parent is not None else None @parent.setter def parent(self, interpretation): """ Establishes the parent of this interpretation, changing the corresponding references in the old and new parents. """ if self._parent is not None and self in self.parent.child: self.parent.child.remove(self) if interpretation is not None: self._parent = weakref.ref(interpretation, self._on_parent_deleted) self.parent.child.append(self) else: self._parent = None @property def ndescendants(self): """Obtains the number of descendants of this interpretation""" stack = [self] ctr = 0 while stack: ctr += 1 interp = stack.pop() stack.extend(interp.child) return ctr def is_mergeable(self, other): """ Checks if two interpretations can be merged, that is, they represent exactly the same interpretation from the time point in the past_metrics structure. """ nobs = len(self.observations) nabs = len(self.abstracted) nunint = len(self.unintelligible) nfocus = len(self.focus) return ( self is not other and len(other.observations) == nobs and len(other.abstracted) == nabs and len(other.unintelligible) == nunint and len(other.focus) == nfocus and self.singletons == other.singletons and _focus_mergeable(self.focus, other.focus) and all(self.unintelligible[i] == other.unintelligible[i] for i in range(nunint - 1, -1, -1)) and all(self.abstracted[i] == other.abstracted[i] for i in range(nabs - 1, -1, -1)) and all(self.observations[i] == other.observations[i] for i in range(nobs - 1, -1, -1)) ) def is_ancestor(self, interpretation): """ Checks if a given interpretation is an ancestor in the hierarchy of this interpretation. The same interpretation is not considered an ancestor. """ if int(self.name) < int(interpretation.name): return False parent = self.parent while True: if parent is interpretation: return True elif parent is None: return False parent = parent.parent def verify_exclusion(self, obs): """ Checks if an observation violates the exclusion relation in this interpretation. """ excluded = ap.get_excluded(type(obs)) other = obsbuf.find_overlapping(obs, excluded) verify(other is None, 'Exclusion relation violation between {0} and {1}', (other, obs)) dummy = EventObservable() dummy.end.value = Iv(obs.latestart, obs.latestart) idx = self.observations.bisect_right(dummy) while idx < len(self.observations): other = self.observations[idx] verify( other is obs or not isinstance(other, excluded) or not overlap(other, obs), 'Exclusion relation violation between {0} and {1}', (other, obs), ) idx += 1 def verify_consecutivity_violation(self, obs): """ Checks if an observation violates the consecutivity constraints in this interpretation. """ idx = self.observations.bisect_left(obs) for obs2 in ( o for o in self.observations[idx:] if o in self.predinfo and isinstance(obs, self.predinfo[o][1]) ): verify( not between(self.predinfo[obs2][0], obs, obs2), '{1} violates the consecutivity constraint between {0} and {2}', (self.predinfo[obs2][0], obs, obs2), ) def verify_consecutivity_satisfaction(self, obs1, obs2, clazz): """ Checks if a consecutivity constraint defined by two observations is violated by some observation in this interpretation or in the observations buffer. """ idx = self.observations.bisect_right(obs1) dummy = EventObservable() dummy.end.value = Iv(obs2.earlyend, obs2.earlyend) udx = self.observations.bisect_left(dummy) for obs in self.observations.islice(idx, udx): verify( obs is obs2 or not isinstance(obs, clazz), '{1} violates the consecutivity constraint between {0} and {2}', (obs1, obs, obs2), ) hole = Observable() hole.start.value = Iv(obs1.lateend, obs1.lateend) hole.end.value = Iv(obs2.earlystart, obs2.earlystart) other = obsbuf.find_overlapping(hole, clazz) verify( other is None, '{1} violates the consecutivity constraint between {0} and {2}', (obs1, other, obs2), ) def get_observations(self, clazz=Observable, start=0, end=np.inf, filt=lambda obs: True, reverse=False): """ Obtains a list of observations matching the search criteria, ordered by the earliest time of the observation. Parameters ---------- clazz: Only instances of the *clazz* class (or any subclass) are returned. start: Only observations whose earlystart attribute is after or equal this parameter are returned. end: Only observations whose lateend attribute is lower or equal this parameter are returned. filt: General filter provided as a boolean function that accepts an observation as a parameter. Only the observations satisfying this filter are returned. reverse: Boolean parameter. If True, observations are returned in reversed order, from last to first. """ # We perform a combination of the observations from the global buffer # and from the interpretation. geng = obsbuf.get_observations(clazz, start, end, filt, reverse) genl = self._get_proper_obs(clazz, start, end, filt, reverse) dummy = EventObservable() dummy.start.value = Iv(np.inf, np.inf) nxtg = next(geng, dummy) nxtl = next(genl, dummy) while True: nxt = min(nxtg, nxtl) if nxt is dummy: return elif nxt is nxtg: nxtg = next(geng, dummy) else: nxtl = next(genl, dummy) yield nxt def remove_old(self, time=None): """Removes old observations from the interpretation.""" if time is None: time = max(self.past_metrics.time, self.focus.earliest_time) - C.FORGET_TIMESPAN # A minimum number of observations is kept nmin = min(C.MIN_NOBS, len(self.observations)) if nmin > 0: time = max(self.past_metrics.time, min(time, self.observations[-nmin].lateend - 1)) dummy = EventObservable() dummy.end.value = Iv(time, time) nhyp = abst = abstime = 0.0 # Old observations are removed from all lists. for lstname in ('observations', 'abstracted', 'unintelligible'): lst = getattr(self, lstname) idx = lst.bisect_right(dummy) if idx > 0 and self.parent is not None and getattr(self.parent, lstname) is lst: lst = lst.copy() setattr(self, lstname, lst) if lstname == 'observations': nhyp = idx elif lstname == 'abstracted': abstime = sum( o.earlyend - o.latestart + 1 for o in lst[:idx] if ap.get_obs_level(type(o)) == 0 ) abst = idx del lst[:idx] self.past_metrics = PastMetrics( time, self.past_metrics.abst + abst, self.past_metrics.abstime + abstime, self.past_metrics.nhyp + nhyp, ) def recover_all(self): """ Recovers all observations from the ancestor interpretations, in order to have the full interpretation from the beginning of the process. Hypotheses in the focus of attention are also included in the *observations* attribute. """ allobs = set(self.observations) interp = self.parent while interp is not None: allobs |= set(interp.observations) interp = interp.parent allobs.update((o for o, p in self.focus._lst if p is not None and o is p.hypothesis)) allobs = sortedcontainers.SortedList(allobs) # Duplicate removal (set only prevents same references, not equality) i = 0 while i < len(allobs) - 1: obs = allobs[i] while allobs[i + 1] == obs: allobs.pop(i + 1) if i == len(allobs) - 1: break i += 1 self.observations = sortedcontainers.SortedList(allobs) def detach(self, reason=''): """ Detachs this interpretation from the interpretations tree, being from that moment a new root. """ # Uncomment to debug. # print str(self), reason if self.parent is not None: parent = self.parent parent.child.remove(self) self.parent = None def discard(self, reason=''): """ Discards this interpretation, and recursively all the descendant interpretations. """ self.detach(reason) stack = self.child[:] while stack: interp = stack.pop() interp.detach('Parent interpretation discarded') stack.extend(interp.child) def get_child(self, name): """ Obtains the child interpretation of this one with the given id. """ name = str(name) queue = deque([self]) while queue: head = queue.popleft() if head.name == name: return head for subbr in head.child: queue.append(subbr) raise ValueError('No child interpretation with such name')
[ 1, 529, 12443, 29918, 303, 1503, 29958, 29896, 29900, 29899, 29896, 29900, 29900, 13, 29937, 448, 29930, 29899, 14137, 29901, 23616, 29899, 29947, 448, 29930, 29899, 13, 29937, 282, 2904, 524, 29901, 11262, 29899, 7645, 29922, 29923, 29900, 29906, 29900, 29906, 29892, 382, 29900, 29896, 29900, 29906, 29892, 382, 29896, 29896, 29900, 29896, 29892, 382, 29896, 29896, 29900, 29941, 29892, 382, 29896, 29900, 29900, 29896, 13, 15945, 29908, 13, 20399, 373, 11169, 2627, 29871, 29906, 29946, 29871, 29900, 29929, 29901, 29946, 29953, 29901, 29906, 29947, 29871, 29906, 29900, 29896, 29946, 13, 13, 4013, 3883, 3743, 278, 5023, 310, 278, 19854, 770, 29892, 607, 338, 278, 13, 16121, 5190, 310, 278, 2740, 1889, 607, 14335, 304, 4505, 19854, 4828, 29889, 13, 13, 29992, 8921, 29901, 529, 5813, 29958, 13, 15945, 29908, 13, 3166, 869, 711, 12114, 1053, 20215, 29892, 6864, 27928, 29892, 1546, 29892, 25457, 29892, 1095, 29918, 21058, 29918, 1989, 13, 3166, 869, 19207, 1053, 4124, 791, 408, 306, 29894, 13, 3166, 869, 13646, 29918, 11618, 1053, 11539, 13, 5215, 413, 538, 14910, 29880, 29889, 28192, 362, 29889, 371, 7253, 3350, 29889, 28385, 5485, 29889, 370, 4151, 428, 29918, 11037, 29879, 408, 3095, 13, 5215, 413, 538, 14910, 29880, 29889, 28192, 362, 29889, 371, 7253, 3350, 29889, 28385, 5485, 29889, 3075, 1934, 408, 315, 13, 5215, 413, 538, 14910, 29880, 29889, 28192, 362, 29889, 371, 7253, 3350, 29889, 562, 23493, 29889, 26290, 29918, 9040, 408, 20881, 9721, 13, 5215, 12705, 1285, 475, 414, 13, 5215, 8062, 999, 13, 5215, 3509, 13, 5215, 12655, 408, 7442, 13, 3166, 16250, 1053, 316, 802, 29892, 4257, 23583, 408, 302, 29873, 13, 13, 13383, 13383, 13383, 2277, 13, 2277, 22310, 537, 3168, 304, 6459, 10366, 18845, 444, 13, 13383, 13383, 13383, 2277, 13, 13, 13, 1753, 903, 5031, 29918, 14634, 519, 29898, 29886, 29896, 29892, 282, 29906, 1125, 13, 1678, 9995, 13, 1678, 3831, 598, 1023, 334, 4920, 4151, 428, 17144, 29930, 8871, 363, 17193, 11211, 385, 13, 1678, 19854, 2778, 3460, 5858, 29889, 7298, 5084, 322, 20051, 10230, 338, 13, 1678, 12023, 304, 367, 6374, 29892, 577, 871, 278, 3345, 532, 322, 278, 2847, 322, 2186, 13, 1678, 5922, 526, 9401, 29889, 13, 1678, 9995, 13, 1678, 565, 282, 29896, 338, 6213, 470, 282, 29906, 338, 6213, 29901, 13, 4706, 736, 282, 29896, 338, 282, 29906, 13, 1678, 736, 282, 29896, 29889, 17405, 532, 338, 282, 29906, 29889, 17405, 532, 322, 282, 29896, 29889, 391, 403, 1275, 282, 29906, 29889, 391, 403, 322, 282, 29896, 29889, 29888, 3859, 1275, 282, 29906, 29889, 29888, 3859, 13, 13, 13, 1753, 903, 18037, 29918, 14634, 519, 29898, 29888, 29896, 29892, 285, 29906, 1125, 13, 1678, 9995, 13, 1678, 3831, 598, 1023, 8569, 267, 310, 8570, 363, 17193, 11211, 385, 19854, 13, 1678, 2778, 3460, 5858, 29889, 450, 3309, 310, 278, 8857, 2629, 278, 1023, 8569, 267, 526, 13, 1678, 12023, 304, 367, 5186, 29892, 541, 445, 756, 304, 367, 9528, 16949, 29889, 13, 1678, 9995, 13, 1678, 736, 599, 29898, 13, 4706, 285, 29896, 3032, 20155, 29961, 29875, 3816, 29900, 29962, 1275, 285, 29906, 3032, 20155, 29961, 29875, 3816, 29900, 29962, 322, 903, 5031, 29918, 14634, 519, 29898, 29888, 29896, 3032, 20155, 29961, 29875, 3816, 29896, 1402, 285, 29906, 3032, 20155, 29961, 29875, 3816, 29896, 2314, 13, 4706, 363, 474, 297, 3464, 29898, 2435, 29898, 29888, 29896, 3032, 20155, 29897, 448, 29871, 29896, 29892, 448, 29896, 29892, 448, 29896, 29897, 13, 1678, 1723, 13, 13, 13, 1990, 19793, 10095, 10817, 29898, 593, 877, 29925, 579, 10095, 10817, 742, 525, 2230, 29892, 633, 303, 29892, 633, 303, 603, 29892, 302, 29882, 1478, 8785, 29901, 13, 1678, 9995, 13, 1678, 12603, 552, 304, 3787, 8018, 2472, 304, 14707, 385, 19854, 2745, 13, 1678, 263, 2702, 931, 29892, 304, 2758, 2313, 538, 2030, 13917, 29889, 13, 1678, 9995, 13, 13, 1678, 4770, 2536, 1862, 1649, 353, 3861, 13, 13, 1678, 822, 2923, 29898, 1311, 29892, 916, 1125, 13, 4706, 9995, 13, 4706, 4250, 2408, 29879, 278, 4328, 1546, 1023, 19793, 10095, 10817, 5291, 2701, 29892, 4133, 13, 4706, 408, 263, 12655, 1409, 411, 2211, 7117, 29889, 334, 2230, 29930, 5352, 338, 429, 13347, 13, 4706, 515, 2923, 29889, 13, 4706, 9995, 13, 4706, 736, 7442, 29889, 2378, 3552, 1311, 29889, 370, 303, 448, 916, 29889, 370, 303, 29892, 1583, 29889, 370, 303, 603, 448, 916, 29889, 370, 303, 603, 29892, 1583, 29889, 29876, 29882, 1478, 448, 916, 29889, 29876, 29882, 1478, 876, 13, 13, 1678, 822, 13261, 29898, 1311, 29892, 13261, 1125, 13, 4706, 9995, 13, 4706, 4250, 2408, 29879, 263, 716, 19793, 10095, 10817, 1203, 491, 15399, 263, 4328, 1409, 29892, 13, 4706, 7625, 491, 278, 334, 12765, 29930, 1158, 29889, 13, 13, 4706, 12662, 2699, 13, 4706, 448, 1378, 29899, 13, 4706, 13261, 29901, 13, 9651, 4398, 29892, 1051, 470, 18761, 411, 3721, 2211, 16259, 1819, 29889, 13, 4706, 9995, 13, 4706, 736, 19793, 10095, 10817, 29898, 1311, 29889, 2230, 29892, 334, 9302, 29889, 2378, 29898, 1311, 29961, 29896, 17531, 718, 13261, 876, 13, 13, 13, 1990, 383, 5421, 29898, 3318, 1125, 13, 1678, 9995, 13, 1678, 910, 770, 11524, 278, 8569, 310, 8570, 310, 385, 19854, 29892, 322, 372, 13, 1678, 2094, 2547, 352, 1078, 599, 848, 322, 9863, 4475, 411, 967, 10643, 29889, 13, 1678, 9995, 13, 13, 1678, 4770, 2536, 1862, 1649, 353, 22868, 20155, 29915, 13, 13, 1678, 822, 4770, 2344, 12035, 1311, 29892, 3847, 29918, 18037, 29922, 8516, 1125, 13, 4706, 9995, 13, 4706, 17250, 7093, 263, 716, 4069, 8569, 310, 8570, 29892, 470, 263, 4091, 340, 3509, 310, 385, 13, 4706, 5923, 8569, 29889, 13, 13, 4706, 2799, 749, 21582, 13, 4706, 448, 2683, 489, 13, 4706, 903, 20155, 29901, 13, 9651, 10292, 6943, 263, 1353, 310, 5291, 2701, 313, 26739, 362, 29918, 272, 29918, 2886, 292, 29892, 13, 9651, 4766, 467, 960, 525, 26739, 362, 29918, 272, 29918, 2886, 292, 29915, 338, 263, 9138, 29892, 769, 525, 11037, 29915, 13, 9651, 338, 278, 27086, 428, 4766, 14655, 1316, 9138, 29889, 960, 338, 385, 13, 9651, 15500, 29892, 769, 525, 11037, 29915, 338, 278, 4766, 363, 607, 278, 13, 9651, 15500, 338, 967, 20051, 29892, 470, 6213, 565, 372, 338, 385, 2847, 13, 9651, 15500, 29889, 13, 4706, 9995, 13, 4706, 565, 3847, 29918, 18037, 338, 6213, 29901, 13, 9651, 1583, 3032, 20155, 353, 5159, 13, 4706, 1683, 29901, 13, 9651, 1583, 3032, 20155, 353, 3847, 29918, 18037, 3032, 20155, 7503, 29962, 13, 13, 1678, 822, 4770, 2435, 12035, 1311, 1125, 13, 4706, 736, 7431, 29898, 1311, 3032, 20155, 29897, 13, 13, 1678, 822, 4770, 11516, 12035, 1311, 29892, 1820, 1125, 13, 4706, 736, 738, 29898, 1989, 338, 325, 363, 325, 29892, 903, 297, 1583, 3032, 20155, 29897, 13, 13, 1678, 822, 4770, 5464, 9171, 12035, 1311, 1125, 13, 4706, 736, 6120, 29898, 1311, 3032, 20155, 29897, 13, 13, 1678, 822, 5503, 29898, 1311, 29892, 20881, 29892, 4766, 1125, 13, 4706, 9995, 13, 4706, 512, 643, 1372, 263, 716, 15500, 470, 9138, 297, 278, 8569, 310, 8570, 29889, 13, 4706, 9995, 13, 4706, 1583, 3032, 20155, 29889, 4397, 3552, 26290, 29892, 4766, 876, 13, 13, 1678, 822, 1835, 29898, 1311, 29892, 302, 29922, 29896, 1125, 13, 4706, 9995, 7301, 586, 267, 525, 29876, 29915, 3161, 515, 278, 8569, 310, 8570, 313, 29896, 491, 2322, 5513, 15945, 13, 4706, 628, 1583, 3032, 20155, 14352, 29876, 29962, 13, 13, 1678, 732, 6799, 13, 1678, 822, 2246, 29898, 1311, 1125, 13, 4706, 9995, 6039, 2408, 29879, 278, 1543, 472, 278, 2246, 310, 278, 8569, 310, 8570, 15945, 29908, 13, 4706, 736, 1583, 3032, 20155, 14352, 29896, 29962, 13, 13, 1678, 732, 3332, 29889, 842, 357, 13, 1678, 822, 2246, 29898, 1311, 29892, 995, 1125, 13, 4706, 9995, 2111, 11057, 278, 1543, 472, 278, 2246, 310, 278, 8569, 310, 8570, 15945, 29908, 13, 4706, 1583, 3032, 20155, 14352, 29896, 29962, 353, 995, 13, 13, 1678, 732, 6799, 13, 1678, 822, 15038, 29898, 1311, 1125, 13, 4706, 9995, 13, 4706, 4250, 2408, 29879, 385, 20380, 975, 278, 15038, 20382, 278, 13917, 470, 13, 4706, 1284, 886, 297, 278, 8569, 310, 8570, 29892, 6257, 472, 278, 2246, 310, 278, 5096, 29889, 13, 4706, 9995, 13, 4706, 736, 313, 29886, 363, 17117, 282, 297, 18764, 287, 29898, 1311, 3032, 20155, 876, 13, 13, 1678, 732, 6799, 13, 1678, 822, 302, 29882, 1478, 29898, 1311, 1125, 13, 4706, 9995, 11609, 29879, 278, 1353, 310, 27086, 428, 13752, 21523, 297, 445, 8569, 15945, 29908, 13, 4706, 736, 2533, 29898, 29896, 363, 288, 29892, 282, 297, 1583, 3032, 20155, 565, 282, 338, 451, 6213, 322, 288, 338, 282, 29889, 29882, 1478, 720, 6656, 29897, 13, 13, 1678, 732, 6799, 13, 1678, 822, 24577, 29918, 2230, 29898, 1311, 1125, 13, 4706, 9995, 13, 4706, 16969, 278, 9212, 6257, 931, 310, 13917, 470, 1284, 886, 297, 13, 4706, 445, 8569, 310, 8570, 29889, 13, 4706, 9995, 13, 4706, 736, 1375, 29898, 29877, 29889, 799, 368, 2962, 363, 288, 29892, 903, 297, 1583, 3032, 20155, 29897, 13, 13, 1678, 822, 679, 29918, 18829, 287, 29918, 2886, 292, 29898, 1311, 29892, 15500, 1125, 13, 4706, 9995, 13, 4706, 4250, 2408, 29879, 278, 9138, 393, 674, 367, 19228, 411, 385, 15500, 2748, 13, 4706, 278, 15500, 338, 8072, 8900, 29892, 470, 6213, 565, 278, 15500, 674, 13, 4706, 451, 367, 19228, 411, 263, 9138, 29889, 13, 4706, 9995, 13, 4706, 363, 474, 297, 3464, 29898, 2435, 29898, 1311, 3032, 20155, 29897, 448, 29871, 29896, 29892, 29871, 29900, 29892, 448, 29896, 1125, 13, 9651, 565, 1583, 3032, 20155, 29961, 29875, 3816, 29900, 29962, 338, 15500, 29901, 13, 18884, 285, 29892, 282, 353, 1583, 3032, 20155, 29961, 29875, 448, 29871, 29896, 29962, 13, 18884, 565, 282, 338, 451, 6213, 322, 285, 338, 282, 29889, 2886, 292, 29901, 13, 462, 1678, 736, 285, 13, 18884, 2867, 13, 4706, 736, 6213, 13, 13, 1678, 822, 1993, 29898, 1311, 29892, 9138, 29892, 20881, 1125, 13, 4706, 9995, 13, 4706, 2431, 9514, 263, 9686, 5858, 1546, 278, 9138, 472, 278, 2246, 310, 278, 13, 4706, 8569, 411, 263, 2183, 15500, 29892, 8454, 278, 931, 322, 995, 5718, 3819, 13, 4706, 310, 278, 9686, 29889, 2860, 5718, 3819, 338, 7120, 29892, 278, 9138, 338, 6206, 13, 4706, 515, 278, 8569, 491, 2794, 310, 263, 1835, 580, 5858, 29889, 13, 4706, 9995, 13, 4706, 285, 29892, 2373, 353, 1583, 3032, 20155, 14352, 29896, 29962, 13, 4706, 4974, 9138, 338, 285, 13, 4706, 11539, 29898, 13, 9651, 20881, 451, 297, 2373, 29889, 5750, 5084, 29961, 5031, 29889, 657, 29918, 5750, 5084, 29918, 1853, 29898, 29888, 9601, 29900, 20526, 13, 9651, 525, 6039, 2140, 362, 426, 29900, 29913, 338, 2307, 297, 278, 10757, 310, 426, 29896, 29913, 4766, 742, 13, 9651, 313, 26290, 29892, 2373, 511, 13, 4706, 1723, 13, 4706, 2373, 6814, 353, 3509, 29889, 8552, 29898, 5031, 29897, 13, 4706, 2373, 6814, 29889, 4352, 29898, 29888, 29892, 20881, 29897, 13, 4706, 396, 450, 20051, 14655, 278, 9138, 338, 4784, 13, 4706, 1583, 3032, 20155, 14352, 29906, 29962, 353, 313, 5031, 6814, 29889, 29882, 1478, 720, 6656, 29892, 2373, 6814, 29897, 13, 4706, 396, 1126, 278, 19228, 9138, 6206, 515, 278, 8569, 13, 4706, 628, 1583, 3032, 20155, 14352, 29896, 29962, 13, 13, 13, 1990, 4124, 19819, 362, 29898, 3318, 1125, 13, 1678, 9995, 13, 1678, 910, 770, 11524, 278, 19854, 7855, 29892, 607, 338, 263, 13747, 13, 1678, 2318, 310, 27086, 428, 13752, 21523, 12420, 491, 278, 7134, 13384, 297, 13, 1678, 27086, 428, 15038, 29889, 739, 338, 278, 6996, 7855, 297, 1749, 2740, 1889, 29892, 322, 13, 1678, 278, 1121, 310, 385, 19854, 1889, 29889, 13, 1678, 9995, 13, 13, 1678, 4770, 2536, 1862, 1649, 353, 313, 13, 4706, 525, 978, 742, 13, 4706, 22868, 3560, 742, 13, 4706, 525, 5145, 742, 13, 4706, 525, 26739, 800, 742, 13, 4706, 525, 348, 524, 9347, 1821, 742, 13, 4706, 525, 2976, 1026, 787, 742, 13, 4706, 525, 16595, 287, 742, 13, 4706, 525, 7183, 29881, 742, 13, 4706, 525, 18037, 742, 13, 4706, 525, 29886, 579, 29918, 2527, 10817, 742, 13, 4706, 525, 11965, 3888, 742, 13, 4706, 525, 1649, 25129, 999, 1649, 742, 13, 1678, 1723, 13, 13, 1678, 6795, 353, 29871, 29900, 13, 13, 1678, 822, 4770, 2344, 12035, 1311, 29892, 3847, 29922, 8516, 1125, 13, 4706, 9995, 13, 4706, 6760, 1078, 263, 716, 4069, 19854, 29892, 2847, 5281, 967, 8393, 408, 263, 13, 4706, 4091, 340, 3509, 470, 263, 1513, 1223, 335, 358, 310, 278, 8393, 310, 278, 3847, 29889, 960, 13, 4706, 3847, 338, 6213, 29892, 278, 8393, 674, 367, 4069, 29889, 13, 13, 4706, 2799, 749, 21582, 13, 4706, 448, 2683, 489, 13, 4706, 1024, 29901, 13, 9651, 853, 1387, 25907, 1061, 310, 278, 19854, 29889, 13, 4706, 3847, 29901, 13, 9651, 4124, 19819, 362, 515, 607, 445, 697, 338, 10723, 29892, 470, 6213, 565, 445, 338, 13, 9651, 263, 3876, 19854, 29889, 13, 4706, 2278, 29901, 13, 9651, 2391, 310, 6613, 800, 10723, 515, 445, 697, 29889, 13, 4706, 4940, 29918, 2527, 10817, 29901, 13, 9651, 6991, 5219, 310, 2030, 2472, 1304, 363, 540, 332, 6765, 13944, 29889, 13, 4706, 13917, 29901, 13, 9651, 317, 18054, 1761, 6943, 599, 278, 13917, 297, 278, 19854, 29892, 13, 9651, 10372, 491, 1009, 1369, 931, 29889, 6058, 29923, 29901, 910, 2875, 338, 4153, 13, 9651, 9859, 515, 3847, 19854, 491, 2322, 29889, 13, 4706, 1809, 1026, 787, 29901, 13, 9651, 3789, 411, 599, 6106, 11285, 13752, 21523, 393, 526, 2198, 297, 445, 13, 9651, 19854, 29889, 6058, 29923, 29901, 910, 2875, 338, 4153, 9859, 13, 9651, 515, 3847, 19854, 491, 2322, 29889, 13, 4706, 9846, 287, 29901, 13, 9651, 317, 18054, 1293, 6943, 599, 278, 13917, 393, 526, 9846, 287, 491, 13, 9651, 777, 27086, 428, 4766, 297, 445, 19854, 29889, 6058, 29923, 29901, 910, 13, 9651, 2875, 338, 4153, 9859, 515, 3847, 19854, 491, 2322, 13, 4706, 443, 524, 9347, 1821, 29901, 13, 9651, 317, 18054, 1293, 6943, 599, 278, 13917, 393, 2609, 367, 13, 9651, 9846, 287, 491, 738, 27086, 428, 4766, 29889, 6058, 29923, 29901, 910, 2875, 338, 13, 9651, 4153, 9859, 515, 3847, 19854, 491, 2322, 29889, 13, 4706, 26924, 29881, 29901, 13, 9651, 9681, 310, 13752, 21523, 297, 278, 19854, 393, 508, 367, 9846, 287, 13, 9651, 491, 263, 6133, 29899, 5563, 20051, 29889, 910, 995, 338, 1304, 363, 278, 17983, 13, 9651, 310, 278, 19854, 29889, 13, 4706, 8569, 29901, 13, 9651, 10292, 6943, 278, 8569, 310, 8570, 310, 278, 19854, 29889, 7806, 13, 9651, 1543, 297, 445, 5096, 338, 385, 15500, 470, 263, 1661, 29899, 4352, 287, 9138, 13, 9651, 310, 263, 4766, 29889, 13, 4706, 4450, 3888, 29901, 13, 9651, 13343, 304, 3787, 27978, 985, 272, 2472, 363, 18942, 13, 9651, 13917, 29889, 7806, 6251, 338, 263, 29871, 29906, 29899, 23583, 313, 26739, 362, 29892, 1134, 29897, 411, 13, 9651, 278, 27978, 985, 272, 15500, 322, 278, 1134, 8052, 491, 278, 4766, 13, 9651, 363, 278, 11888, 329, 2068, 8220, 29889, 6058, 29923, 29901, 910, 2875, 338, 4153, 13, 9651, 9859, 515, 3847, 19854, 491, 2322, 29889, 13, 4706, 9995, 13, 4706, 1583, 29889, 978, 353, 851, 29898, 4074, 19819, 362, 29889, 11808, 29897, 13, 4706, 565, 3847, 338, 6213, 29901, 13, 9651, 1583, 3032, 3560, 353, 6213, 13, 9651, 1583, 29889, 5145, 353, 5159, 13, 9651, 1583, 29889, 26739, 800, 353, 12705, 1285, 475, 414, 29889, 13685, 287, 1293, 29898, 1989, 29922, 355, 29918, 21058, 29918, 1989, 29897, 13, 9651, 1583, 29889, 2976, 1026, 787, 353, 731, 580, 13, 9651, 1583, 29889, 16595, 287, 353, 12705, 1285, 475, 414, 29889, 13685, 287, 1293, 29898, 1989, 29922, 355, 29918, 21058, 29918, 1989, 29897, 13, 9651, 1583, 29889, 348, 524, 9347, 1821, 353, 12705, 1285, 475, 414, 29889, 13685, 287, 1293, 29898, 1989, 29922, 355, 29918, 21058, 29918, 1989, 29897, 13, 9651, 1583, 29889, 7183, 29881, 353, 29871, 29900, 13, 9651, 1583, 29889, 29886, 579, 29918, 2527, 10817, 353, 19793, 10095, 10817, 29898, 29900, 29892, 29871, 29900, 29892, 29871, 29900, 29892, 29871, 29900, 29897, 13, 9651, 1583, 29889, 18037, 353, 383, 5421, 580, 13, 9651, 1583, 29889, 11965, 3888, 353, 6571, 13, 4706, 1683, 29901, 13, 9651, 1583, 3032, 3560, 353, 8062, 999, 29889, 999, 29898, 3560, 29892, 1583, 3032, 265, 29918, 3560, 29918, 311, 22742, 29897, 13, 9651, 1583, 29889, 5145, 353, 5159, 13, 9651, 1583, 29889, 3560, 29889, 5145, 29889, 4397, 29898, 1311, 29897, 13, 9651, 1583, 29889, 26739, 800, 353, 3847, 29889, 26739, 800, 13, 9651, 1583, 29889, 2976, 1026, 787, 353, 3847, 29889, 2976, 1026, 787, 13, 9651, 1583, 29889, 16595, 287, 353, 3847, 29889, 16595, 287, 13, 9651, 1583, 29889, 348, 524, 9347, 1821, 353, 3847, 29889, 348, 524, 9347, 1821, 13, 9651, 1583, 29889, 7183, 29881, 353, 3847, 29889, 7183, 29881, 13, 9651, 1583, 29889, 29886, 579, 29918, 2527, 10817, 353, 3847, 29889, 29886, 579, 29918, 2527, 10817, 13, 9651, 1583, 29889, 18037, 353, 383, 5421, 29898, 3560, 29889, 18037, 29897, 13, 9651, 1583, 29889, 11965, 3888, 353, 3847, 29889, 11965, 3888, 13, 4706, 4124, 19819, 362, 29889, 11808, 4619, 29871, 29896, 13, 13, 1678, 822, 4770, 710, 12035, 1311, 1125, 13, 4706, 9995, 13, 4706, 4250, 2408, 29879, 278, 8954, 310, 278, 19854, 408, 263, 2931, 1347, 29889, 13, 4706, 9995, 13, 4706, 736, 1583, 29889, 978, 13, 13, 1678, 822, 4770, 276, 558, 12035, 1311, 1125, 13, 4706, 736, 1583, 29889, 978, 13, 13, 1678, 822, 903, 265, 29918, 3560, 29918, 311, 22742, 29898, 1311, 29892, 903, 1125, 13, 4706, 9995, 13, 4706, 8251, 1627, 740, 2000, 746, 278, 3847, 19854, 338, 11132, 29889, 13, 4706, 9995, 13, 4706, 1583, 3032, 3560, 353, 6213, 13, 13, 1678, 822, 903, 657, 29918, 8768, 29898, 1311, 29892, 20881, 1125, 13, 4706, 9995, 13, 4706, 4250, 2408, 29879, 263, 18761, 411, 278, 4072, 393, 526, 1304, 3390, 304, 385, 15500, 29892, 13, 4706, 1716, 408, 20051, 322, 408, 10757, 310, 1422, 15038, 29889, 13, 4706, 9995, 13, 4706, 4072, 353, 426, 1853, 29898, 26290, 29512, 13094, 3319, 29886, 29889, 657, 29918, 5750, 5084, 29918, 1853, 29898, 26290, 9601, 29900, 29962, 363, 282, 297, 1583, 29889, 5031, 29918, 1958, 29961, 26290, 3816, 29896, 29962, 1800, 13, 4706, 270, 4352, 353, 1583, 29889, 657, 29918, 18829, 287, 29918, 2886, 292, 29898, 26290, 29897, 13, 4706, 565, 270, 4352, 338, 451, 6213, 29901, 13, 9651, 4072, 353, 4072, 29889, 13094, 29898, 13, 18884, 426, 1853, 29898, 29881, 4352, 19230, 426, 29886, 29889, 657, 29918, 5750, 5084, 29918, 1853, 29898, 29881, 4352, 9601, 29900, 29962, 363, 282, 297, 1583, 29889, 5031, 29918, 1958, 29961, 29881, 4352, 3816, 29896, 12258, 13, 9651, 1723, 13, 4706, 736, 18761, 29898, 8768, 29897, 13, 13, 1678, 822, 903, 657, 29918, 771, 546, 29918, 26290, 29898, 1311, 29892, 3711, 5617, 29922, 27928, 29892, 1369, 29922, 29900, 29892, 1095, 29922, 9302, 29889, 7192, 29892, 977, 29873, 29922, 2892, 20881, 29901, 5852, 29892, 11837, 29922, 8824, 1125, 13, 4706, 9995, 13, 4706, 4250, 2408, 29879, 263, 1051, 310, 13917, 9686, 278, 2740, 16614, 29892, 10372, 13, 4706, 491, 278, 24577, 931, 310, 278, 15500, 29889, 13, 13, 4706, 12662, 2699, 13, 4706, 448, 1378, 29899, 13, 4706, 3711, 5617, 29901, 13, 9651, 9333, 8871, 310, 278, 334, 16398, 5617, 29930, 770, 313, 272, 738, 19481, 29897, 526, 4133, 29889, 13, 4706, 1369, 29901, 13, 9651, 9333, 13917, 5069, 4688, 2962, 5352, 338, 1156, 470, 5186, 445, 13, 9651, 3443, 526, 4133, 29889, 13, 4706, 1095, 29901, 13, 9651, 9333, 13917, 5069, 5683, 355, 5352, 338, 5224, 470, 5186, 445, 13, 9651, 3443, 526, 4133, 29889, 13, 4706, 977, 29873, 29901, 13, 9651, 4593, 4175, 4944, 408, 263, 7223, 740, 393, 21486, 385, 13, 9651, 15500, 408, 263, 3443, 29889, 9333, 278, 13917, 24064, 445, 13, 9651, 4175, 526, 4133, 29889, 13, 4706, 11837, 29901, 13, 9651, 11185, 3443, 29889, 960, 5852, 29892, 13917, 526, 4133, 297, 18764, 287, 13, 9651, 1797, 29892, 515, 1833, 304, 937, 29889, 13, 4706, 9995, 13, 4706, 20254, 353, 6864, 27928, 580, 13, 4706, 565, 1369, 1275, 29871, 29900, 29901, 13, 9651, 22645, 353, 29871, 29900, 13, 4706, 1683, 29901, 13, 9651, 20254, 29889, 2230, 29889, 1767, 353, 306, 29894, 29898, 2962, 29892, 1369, 29897, 13, 9651, 22645, 353, 1583, 29889, 26739, 800, 29889, 18809, 522, 29918, 1563, 29898, 29881, 11770, 29897, 13, 4706, 565, 1095, 1275, 7442, 29889, 7192, 29901, 13, 9651, 318, 8235, 353, 7431, 29898, 1311, 29889, 26739, 800, 29897, 13, 4706, 1683, 29901, 13, 9651, 20254, 29889, 2230, 29889, 1767, 353, 306, 29894, 29898, 355, 29892, 1095, 29897, 13, 9651, 318, 8235, 353, 1583, 29889, 26739, 800, 29889, 18809, 522, 29918, 1266, 29898, 29881, 11770, 29897, 13, 4706, 736, 313, 13, 9651, 20881, 13, 9651, 363, 20881, 297, 1583, 29889, 26739, 800, 29889, 275, 5897, 29898, 13140, 29892, 318, 8235, 29892, 11837, 29897, 13, 9651, 565, 20881, 29889, 799, 368, 2962, 6736, 1369, 322, 338, 8758, 29898, 26290, 29892, 3711, 5617, 29897, 322, 977, 29873, 29898, 26290, 29897, 13, 4706, 1723, 13, 13, 1678, 732, 6799, 13, 1678, 822, 338, 29918, 29888, 3568, 29898, 1311, 1125, 13, 4706, 9995, 13, 4706, 5399, 29879, 565, 385, 19854, 338, 9226, 29892, 393, 338, 29892, 727, 526, 694, 443, 4352, 287, 13, 4706, 1284, 886, 322, 599, 278, 27086, 428, 15038, 9701, 505, 263, 8002, 13, 4706, 731, 310, 10757, 304, 2304, 1009, 20051, 29889, 13, 4706, 9995, 13, 4706, 736, 599, 29898, 29886, 338, 6213, 470, 282, 29889, 2146, 4543, 29918, 5750, 5084, 363, 282, 297, 1583, 29889, 18037, 29889, 11037, 29879, 29897, 13, 13, 1678, 732, 6799, 13, 1678, 822, 931, 29918, 3149, 29898, 1311, 1125, 13, 4706, 9995, 13, 4706, 4250, 2408, 29879, 278, 931, 1298, 310, 385, 19854, 29892, 393, 338, 29892, 278, 1095, 931, 13, 4706, 995, 310, 278, 1833, 2967, 10757, 1641, 5545, 408, 10757, 310, 738, 13, 4706, 20051, 297, 278, 19854, 29889, 960, 727, 526, 694, 20051, 297, 278, 13, 4706, 19854, 29892, 769, 278, 931, 1298, 338, 925, 1434, 278, 937, 3625, 13, 4706, 15500, 29889, 13, 4706, 9995, 13, 4706, 1833, 18037, 353, 4236, 29898, 13, 632, 29900, 29892, 13, 9651, 313, 13, 18884, 1583, 29889, 18037, 29889, 3332, 29961, 29900, 1822, 799, 368, 2962, 448, 29871, 29896, 13, 18884, 565, 1583, 29889, 18037, 13, 18884, 1683, 2446, 29898, 1311, 29889, 657, 29918, 26739, 800, 16655, 799, 368, 2962, 448, 29871, 29896, 13, 9651, 10353, 13, 4706, 1723, 13, 4706, 736, 4236, 29898, 1311, 29889, 16595, 287, 14352, 29896, 1822, 9632, 355, 29892, 1833, 18037, 29897, 565, 1583, 29889, 16595, 287, 1683, 1833, 18037, 13, 13, 1678, 732, 6799, 13, 1678, 822, 3847, 29898, 1311, 1125, 13, 4706, 9995, 13, 4706, 4250, 2408, 29879, 278, 3847, 310, 385, 19854, 29889, 13, 4706, 9995, 13, 4706, 736, 1583, 3032, 3560, 580, 565, 1583, 3032, 3560, 338, 451, 6213, 1683, 6213, 13, 13, 1678, 732, 3560, 29889, 842, 357, 13, 1678, 822, 3847, 29898, 1311, 29892, 19854, 1125, 13, 4706, 9995, 13, 4706, 2661, 370, 1674, 267, 278, 3847, 310, 445, 19854, 29892, 6480, 278, 13, 4706, 6590, 9282, 297, 278, 2030, 322, 716, 11825, 29889, 13, 4706, 9995, 13, 4706, 565, 1583, 3032, 3560, 338, 451, 6213, 322, 1583, 297, 1583, 29889, 3560, 29889, 5145, 29901, 13, 9651, 1583, 29889, 3560, 29889, 5145, 29889, 5992, 29898, 1311, 29897, 13, 4706, 565, 19854, 338, 451, 6213, 29901, 13, 9651, 1583, 3032, 3560, 353, 8062, 999, 29889, 999, 29898, 1639, 19819, 362, 29892, 1583, 3032, 265, 29918, 3560, 29918, 311, 22742, 29897, 13, 9651, 1583, 29889, 3560, 29889, 5145, 29889, 4397, 29898, 1311, 29897, 13, 4706, 1683, 29901, 13, 9651, 1583, 3032, 3560, 353, 6213, 13, 13, 1678, 732, 6799, 13, 1678, 822, 29871, 299, 9977, 355, 1934, 29898, 1311, 1125, 13, 4706, 9995, 6039, 2408, 29879, 278, 1353, 310, 17086, 1934, 310, 445, 19854, 15945, 29908, 13, 4706, 5096, 353, 518, 1311, 29962, 13, 4706, 274, 509, 353, 29871, 29900, 13, 4706, 1550, 5096, 29901, 13, 9651, 274, 509, 4619, 29871, 29896, 13, 9651, 1006, 29886, 353, 5096, 29889, 7323, 580, 13, 9651, 5096, 29889, 21843, 29898, 1639, 29886, 29889, 5145, 29897, 13, 4706, 736, 274, 509, 13, 13, 1678, 822, 338, 29918, 14634, 519, 29898, 1311, 29892, 916, 1125, 13, 4706, 9995, 13, 4706, 5399, 29879, 565, 1023, 6613, 800, 508, 367, 19412, 29892, 393, 338, 29892, 896, 2755, 13, 4706, 3721, 278, 1021, 19854, 515, 278, 931, 1298, 297, 278, 4940, 29918, 2527, 10817, 13, 4706, 3829, 29889, 13, 4706, 9995, 13, 4706, 694, 5824, 353, 7431, 29898, 1311, 29889, 26739, 800, 29897, 13, 4706, 302, 6897, 353, 7431, 29898, 1311, 29889, 16595, 287, 29897, 13, 4706, 11923, 524, 353, 7431, 29898, 1311, 29889, 348, 524, 9347, 1821, 29897, 13, 4706, 302, 18037, 353, 7431, 29898, 1311, 29889, 18037, 29897, 13, 4706, 736, 313, 13, 9651, 1583, 338, 451, 916, 13, 9651, 322, 7431, 29898, 1228, 29889, 26739, 800, 29897, 1275, 694, 5824, 13, 9651, 322, 7431, 29898, 1228, 29889, 16595, 287, 29897, 1275, 302, 6897, 13, 9651, 322, 7431, 29898, 1228, 29889, 348, 524, 9347, 1821, 29897, 1275, 11923, 524, 13, 9651, 322, 7431, 29898, 1228, 29889, 18037, 29897, 1275, 302, 18037, 13, 9651, 322, 1583, 29889, 2976, 1026, 787, 1275, 916, 29889, 2976, 1026, 787, 13, 9651, 322, 903, 18037, 29918, 14634, 519, 29898, 1311, 29889, 18037, 29892, 916, 29889, 18037, 29897, 13, 9651, 322, 599, 29898, 1311, 29889, 348, 524, 9347, 1821, 29961, 29875, 29962, 1275, 916, 29889, 348, 524, 9347, 1821, 29961, 29875, 29962, 363, 474, 297, 3464, 29898, 29876, 348, 524, 448, 29871, 29896, 29892, 448, 29896, 29892, 448, 29896, 876, 13, 9651, 322, 599, 29898, 1311, 29889, 16595, 287, 29961, 29875, 29962, 1275, 916, 29889, 16595, 287, 29961, 29875, 29962, 363, 474, 297, 3464, 29898, 29876, 6897, 448, 29871, 29896, 29892, 448, 29896, 29892, 448, 29896, 876, 13, 9651, 322, 599, 29898, 1311, 29889, 26739, 800, 29961, 29875, 29962, 1275, 916, 29889, 26739, 800, 29961, 29875, 29962, 363, 474, 297, 3464, 29898, 29876, 26290, 448, 29871, 29896, 29892, 448, 29896, 29892, 448, 29896, 876, 13, 4706, 1723, 13, 13, 1678, 822, 338, 29918, 4564, 342, 272, 29898, 1311, 29892, 19854, 1125, 13, 4706, 9995, 13, 4706, 5399, 29879, 565, 263, 2183, 19854, 338, 385, 19525, 272, 297, 278, 21277, 310, 13, 4706, 445, 19854, 29889, 450, 1021, 19854, 338, 451, 5545, 385, 13, 4706, 19525, 272, 29889, 13, 4706, 9995, 13, 4706, 565, 938, 29898, 1311, 29889, 978, 29897, 529, 938, 29898, 1639, 19819, 362, 29889, 978, 1125, 13, 9651, 736, 7700, 13, 4706, 3847, 353, 1583, 29889, 3560, 13, 4706, 1550, 5852, 29901, 13, 9651, 565, 3847, 338, 19854, 29901, 13, 18884, 736, 5852, 13, 9651, 25342, 3847, 338, 6213, 29901, 13, 18884, 736, 7700, 13, 9651, 3847, 353, 3847, 29889, 3560, 13, 13, 1678, 822, 11539, 29918, 735, 10085, 29898, 1311, 29892, 20881, 1125, 13, 4706, 9995, 13, 4706, 5399, 29879, 565, 385, 15500, 5537, 1078, 278, 429, 10085, 8220, 297, 445, 13, 4706, 19854, 29889, 13, 4706, 9995, 13, 4706, 429, 13347, 353, 3095, 29889, 657, 29918, 735, 13347, 29898, 1853, 29898, 26290, 876, 13, 4706, 916, 353, 20881, 9721, 29889, 2886, 29918, 957, 433, 3262, 29898, 26290, 29892, 429, 13347, 29897, 13, 4706, 11539, 29898, 1228, 338, 6213, 29892, 525, 1252, 10085, 8220, 5537, 362, 1546, 426, 29900, 29913, 322, 426, 29896, 29913, 742, 313, 1228, 29892, 20881, 876, 13, 4706, 20254, 353, 6864, 27928, 580, 13, 4706, 20254, 29889, 355, 29889, 1767, 353, 306, 29894, 29898, 26290, 29889, 12333, 442, 29892, 20881, 29889, 12333, 442, 29897, 13, 4706, 22645, 353, 1583, 29889, 26739, 800, 29889, 18809, 522, 29918, 1266, 29898, 29881, 11770, 29897, 13, 4706, 1550, 22645, 529, 7431, 29898, 1311, 29889, 26739, 800, 1125, 13, 9651, 916, 353, 1583, 29889, 26739, 800, 29961, 13140, 29962, 13, 9651, 11539, 29898, 13, 18884, 916, 338, 20881, 470, 451, 338, 8758, 29898, 1228, 29892, 429, 13347, 29897, 470, 451, 25457, 29898, 1228, 29892, 20881, 511, 13, 18884, 525, 1252, 10085, 8220, 5537, 362, 1546, 426, 29900, 29913, 322, 426, 29896, 29913, 742, 13, 18884, 313, 1228, 29892, 20881, 511, 13, 9651, 1723, 13, 9651, 22645, 4619, 29871, 29896, 13, 13, 1678, 822, 11539, 29918, 535, 3471, 329, 2068, 29918, 1403, 22671, 29898, 1311, 29892, 20881, 1125, 13, 4706, 9995, 13, 4706, 5399, 29879, 565, 385, 15500, 5537, 1078, 278, 11888, 329, 2068, 11938, 297, 445, 13, 4706, 19854, 29889, 13, 4706, 9995, 13, 4706, 22645, 353, 1583, 29889, 26739, 800, 29889, 18809, 522, 29918, 1563, 29898, 26290, 29897, 13, 4706, 363, 20881, 29906, 297, 313, 13, 9651, 288, 363, 288, 297, 1583, 29889, 26739, 800, 29961, 13140, 17531, 565, 288, 297, 1583, 29889, 11965, 3888, 322, 338, 8758, 29898, 26290, 29892, 1583, 29889, 11965, 3888, 29961, 29877, 3816, 29896, 2314, 13, 308, 1125, 13, 9651, 11539, 29898, 13, 18884, 451, 1546, 29898, 1311, 29889, 11965, 3888, 29961, 26290, 29906, 3816, 29900, 1402, 20881, 29892, 20881, 29906, 511, 13, 18884, 22372, 29896, 29913, 5537, 1078, 278, 11888, 329, 2068, 7276, 1546, 426, 29900, 29913, 322, 426, 29906, 29913, 742, 13, 18884, 313, 1311, 29889, 11965, 3888, 29961, 26290, 29906, 3816, 29900, 1402, 20881, 29892, 20881, 29906, 511, 13, 9651, 1723, 13, 13, 1678, 822, 11539, 29918, 535, 3471, 329, 2068, 29918, 29879, 27685, 2467, 29898, 1311, 29892, 20881, 29896, 29892, 20881, 29906, 29892, 3711, 5617, 1125, 13, 4706, 9995, 13, 4706, 5399, 29879, 565, 263, 11888, 329, 2068, 7276, 3342, 491, 1023, 13917, 338, 13, 4706, 5537, 630, 491, 777, 15500, 297, 445, 19854, 470, 297, 278, 13, 4706, 13917, 6835, 29889, 13, 4706, 9995, 13, 4706, 22645, 353, 1583, 29889, 26739, 800, 29889, 18809, 522, 29918, 1266, 29898, 26290, 29896, 29897, 13, 4706, 20254, 353, 6864, 27928, 580, 13, 4706, 20254, 29889, 355, 29889, 1767, 353, 306, 29894, 29898, 26290, 29906, 29889, 799, 368, 355, 29892, 20881, 29906, 29889, 799, 368, 355, 29897, 13, 4706, 318, 8235, 353, 1583, 29889, 26739, 800, 29889, 18809, 522, 29918, 1563, 29898, 29881, 11770, 29897, 13, 4706, 363, 20881, 297, 1583, 29889, 26739, 800, 29889, 275, 5897, 29898, 13140, 29892, 318, 8235, 1125, 13, 9651, 11539, 29898, 13, 18884, 20881, 338, 20881, 29906, 470, 451, 338, 8758, 29898, 26290, 29892, 3711, 5617, 511, 13, 18884, 22372, 29896, 29913, 5537, 1078, 278, 11888, 329, 2068, 7276, 1546, 426, 29900, 29913, 322, 426, 29906, 29913, 742, 13, 18884, 313, 26290, 29896, 29892, 20881, 29892, 20881, 29906, 511, 13, 9651, 1723, 13, 4706, 16188, 353, 20215, 580, 13, 4706, 16188, 29889, 2962, 29889, 1767, 353, 306, 29894, 29898, 26290, 29896, 29889, 9632, 355, 29892, 20881, 29896, 29889, 9632, 355, 29897, 13, 4706, 16188, 29889, 355, 29889, 1767, 353, 306, 29894, 29898, 26290, 29906, 29889, 799, 368, 2962, 29892, 20881, 29906, 29889, 799, 368, 2962, 29897, 13, 4706, 916, 353, 20881, 9721, 29889, 2886, 29918, 957, 433, 3262, 29898, 29716, 29892, 3711, 5617, 29897, 13, 4706, 11539, 29898, 13, 9651, 916, 338, 6213, 29892, 13, 9651, 22372, 29896, 29913, 5537, 1078, 278, 11888, 329, 2068, 7276, 1546, 426, 29900, 29913, 322, 426, 29906, 29913, 742, 13, 9651, 313, 26290, 29896, 29892, 916, 29892, 20881, 29906, 511, 13, 4706, 1723, 13, 13, 1678, 822, 679, 29918, 26739, 800, 29898, 1311, 29892, 3711, 5617, 29922, 27928, 29892, 1369, 29922, 29900, 29892, 1095, 29922, 9302, 29889, 7192, 29892, 977, 29873, 29922, 2892, 20881, 29901, 5852, 29892, 11837, 29922, 8824, 1125, 13, 4706, 9995, 13, 4706, 4250, 2408, 29879, 263, 1051, 310, 13917, 9686, 278, 2740, 16614, 29892, 10372, 13, 4706, 491, 278, 24577, 931, 310, 278, 15500, 29889, 13, 13, 4706, 12662, 2699, 13, 4706, 448, 1378, 29899, 13, 4706, 3711, 5617, 29901, 13, 9651, 9333, 8871, 310, 278, 334, 16398, 5617, 29930, 770, 313, 272, 738, 19481, 29897, 526, 4133, 29889, 13, 4706, 1369, 29901, 13, 9651, 9333, 13917, 5069, 4688, 2962, 5352, 338, 1156, 470, 5186, 445, 13, 9651, 3443, 526, 4133, 29889, 13, 4706, 1095, 29901, 13, 9651, 9333, 13917, 5069, 5683, 355, 5352, 338, 5224, 470, 5186, 445, 13, 9651, 3443, 526, 4133, 29889, 13, 4706, 977, 29873, 29901, 13, 9651, 4593, 4175, 4944, 408, 263, 7223, 740, 393, 21486, 385, 13, 9651, 15500, 408, 263, 3443, 29889, 9333, 278, 13917, 24064, 445, 13, 9651, 4175, 526, 4133, 29889, 13, 4706, 11837, 29901, 13, 9651, 11185, 3443, 29889, 960, 5852, 29892, 13917, 526, 4133, 297, 18764, 287, 13, 9651, 1797, 29892, 515, 1833, 304, 937, 29889, 13, 4706, 9995, 13, 4706, 396, 1334, 2189, 263, 10296, 310, 278, 13917, 515, 278, 5534, 6835, 13, 4706, 396, 322, 515, 278, 19854, 29889, 13, 4706, 330, 996, 353, 20881, 9721, 29889, 657, 29918, 26739, 800, 29898, 16398, 5617, 29892, 1369, 29892, 1095, 29892, 977, 29873, 29892, 11837, 29897, 13, 4706, 2531, 29880, 353, 1583, 3032, 657, 29918, 771, 546, 29918, 26290, 29898, 16398, 5617, 29892, 1369, 29892, 1095, 29892, 977, 29873, 29892, 11837, 29897, 13, 4706, 20254, 353, 6864, 27928, 580, 13, 4706, 20254, 29889, 2962, 29889, 1767, 353, 306, 29894, 29898, 9302, 29889, 7192, 29892, 7442, 29889, 7192, 29897, 13, 4706, 302, 486, 29887, 353, 2446, 29898, 29887, 996, 29892, 20254, 29897, 13, 4706, 302, 486, 29880, 353, 2446, 29898, 1885, 29880, 29892, 20254, 29897, 13, 4706, 1550, 5852, 29901, 13, 9651, 302, 486, 353, 1375, 29898, 29876, 486, 29887, 29892, 302, 486, 29880, 29897, 13, 9651, 565, 302, 486, 338, 20254, 29901, 13, 18884, 736, 13, 9651, 25342, 302, 486, 338, 302, 486, 29887, 29901, 13, 18884, 302, 486, 29887, 353, 2446, 29898, 29887, 996, 29892, 20254, 29897, 13, 9651, 1683, 29901, 13, 18884, 302, 486, 29880, 353, 2446, 29898, 1885, 29880, 29892, 20254, 29897, 13, 9651, 7709, 302, 486, 13, 13, 1678, 822, 3349, 29918, 1025, 29898, 1311, 29892, 931, 29922, 8516, 1125, 13, 4706, 9995, 7301, 586, 267, 2030, 13917, 515, 278, 19854, 1213, 15945, 13, 4706, 565, 931, 338, 6213, 29901, 13, 9651, 931, 353, 4236, 29898, 1311, 29889, 29886, 579, 29918, 2527, 10817, 29889, 2230, 29892, 1583, 29889, 18037, 29889, 799, 20409, 29918, 2230, 29897, 448, 315, 29889, 22051, 7194, 29918, 15307, 5550, 2190, 13, 4706, 396, 319, 9212, 1353, 310, 13917, 338, 8126, 13, 4706, 302, 1195, 353, 1375, 29898, 29907, 29889, 16173, 29918, 6632, 9851, 29892, 7431, 29898, 1311, 29889, 26739, 800, 876, 13, 4706, 565, 302, 1195, 1405, 29871, 29900, 29901, 13, 9651, 931, 353, 4236, 29898, 1311, 29889, 29886, 579, 29918, 2527, 10817, 29889, 2230, 29892, 1375, 29898, 2230, 29892, 1583, 29889, 26739, 800, 14352, 29876, 1195, 1822, 9632, 355, 448, 29871, 29896, 876, 13, 4706, 20254, 353, 6864, 27928, 580, 13, 4706, 20254, 29889, 355, 29889, 1767, 353, 306, 29894, 29898, 2230, 29892, 931, 29897, 13, 4706, 302, 29882, 1478, 353, 633, 303, 353, 633, 303, 603, 353, 29871, 29900, 29889, 29900, 13, 4706, 396, 8198, 13917, 526, 6206, 515, 599, 8857, 29889, 13, 4706, 363, 24471, 978, 297, 6702, 26739, 800, 742, 525, 16595, 287, 742, 525, 348, 524, 9347, 1821, 29374, 13, 9651, 24471, 353, 679, 5552, 29898, 1311, 29892, 24471, 978, 29897, 13, 9651, 22645, 353, 24471, 29889, 18809, 522, 29918, 1266, 29898, 29881, 11770, 29897, 13, 9651, 565, 22645, 1405, 29871, 29900, 322, 1583, 29889, 3560, 338, 451, 6213, 322, 679, 5552, 29898, 1311, 29889, 3560, 29892, 24471, 978, 29897, 338, 24471, 29901, 13, 18884, 24471, 353, 24471, 29889, 8552, 580, 13, 18884, 731, 5552, 29898, 1311, 29892, 24471, 978, 29892, 24471, 29897, 13, 9651, 565, 24471, 978, 1275, 525, 26739, 800, 2396, 13, 18884, 302, 29882, 1478, 353, 22645, 13, 9651, 25342, 24471, 978, 1275, 525, 16595, 287, 2396, 13, 18884, 633, 303, 603, 353, 2533, 29898, 13, 462, 1678, 288, 29889, 799, 368, 355, 448, 288, 29889, 12333, 442, 718, 29871, 29896, 363, 288, 297, 24471, 7503, 13140, 29962, 565, 3095, 29889, 657, 29918, 26290, 29918, 5563, 29898, 1853, 29898, 29877, 876, 1275, 29871, 29900, 13, 18884, 1723, 13, 18884, 633, 303, 353, 22645, 13, 9651, 628, 24471, 7503, 13140, 29962, 13, 4706, 1583, 29889, 29886, 579, 29918, 2527, 10817, 353, 19793, 10095, 10817, 29898, 13, 9651, 931, 29892, 13, 9651, 1583, 29889, 29886, 579, 29918, 2527, 10817, 29889, 370, 303, 718, 633, 303, 29892, 13, 9651, 1583, 29889, 29886, 579, 29918, 2527, 10817, 29889, 370, 303, 603, 718, 633, 303, 603, 29892, 13, 9651, 1583, 29889, 29886, 579, 29918, 2527, 10817, 29889, 29876, 29882, 1478, 718, 302, 29882, 1478, 29892, 13, 4706, 1723, 13, 13, 1678, 822, 9792, 29918, 497, 29898, 1311, 1125, 13, 4706, 9995, 13, 4706, 3599, 29877, 874, 599, 13917, 515, 278, 19525, 272, 6613, 800, 29892, 13, 4706, 297, 1797, 304, 505, 278, 2989, 19854, 515, 278, 6763, 310, 278, 13, 4706, 1889, 29889, 28984, 720, 21523, 297, 278, 8569, 310, 8570, 526, 884, 5134, 297, 278, 13, 4706, 334, 26739, 800, 29930, 5352, 29889, 13, 4706, 9995, 13, 4706, 394, 2127, 29879, 353, 731, 29898, 1311, 29889, 26739, 800, 29897, 13, 4706, 1006, 29886, 353, 1583, 29889, 3560, 13, 4706, 1550, 1006, 29886, 338, 451, 6213, 29901, 13, 9651, 394, 2127, 29879, 891, 29922, 731, 29898, 1639, 29886, 29889, 26739, 800, 29897, 13, 9651, 1006, 29886, 353, 1006, 29886, 29889, 3560, 13, 4706, 394, 2127, 29879, 29889, 5504, 3552, 29877, 363, 288, 29892, 282, 297, 1583, 29889, 18037, 3032, 20155, 565, 282, 338, 451, 6213, 322, 288, 338, 282, 29889, 29882, 1478, 720, 6656, 876, 13, 4706, 394, 2127, 29879, 353, 12705, 1285, 475, 414, 29889, 13685, 287, 1293, 29898, 284, 2127, 29879, 29897, 13, 4706, 396, 18733, 5926, 28744, 313, 842, 871, 28057, 1021, 9282, 29892, 451, 17193, 29897, 13, 4706, 474, 353, 29871, 29900, 13, 4706, 1550, 474, 529, 7431, 29898, 284, 2127, 29879, 29897, 448, 29871, 29896, 29901, 13, 9651, 20881, 353, 394, 2127, 29879, 29961, 29875, 29962, 13, 9651, 1550, 394, 2127, 29879, 29961, 29875, 718, 29871, 29896, 29962, 1275, 20881, 29901, 13, 18884, 394, 2127, 29879, 29889, 7323, 29898, 29875, 718, 29871, 29896, 29897, 13, 18884, 565, 474, 1275, 7431, 29898, 284, 2127, 29879, 29897, 448, 29871, 29896, 29901, 13, 462, 1678, 2867, 13, 9651, 474, 4619, 29871, 29896, 13, 4706, 1583, 29889, 26739, 800, 353, 12705, 1285, 475, 414, 29889, 13685, 287, 1293, 29898, 284, 2127, 29879, 29897, 13, 13, 1678, 822, 1439, 496, 29898, 1311, 29892, 2769, 2433, 29374, 13, 4706, 9995, 13, 4706, 5953, 496, 29879, 445, 19854, 515, 278, 6613, 800, 5447, 29892, 1641, 515, 13, 4706, 393, 3256, 263, 716, 3876, 29889, 13, 4706, 9995, 13, 4706, 396, 853, 9342, 304, 4744, 29889, 13, 4706, 396, 1596, 851, 29898, 1311, 511, 2769, 13, 4706, 565, 1583, 29889, 3560, 338, 451, 6213, 29901, 13, 9651, 3847, 353, 1583, 29889, 3560, 13, 9651, 3847, 29889, 5145, 29889, 5992, 29898, 1311, 29897, 13, 9651, 1583, 29889, 3560, 353, 6213, 13, 13, 1678, 822, 2313, 538, 29898, 1311, 29892, 2769, 2433, 29374, 13, 4706, 9995, 13, 4706, 8565, 3163, 445, 19854, 29892, 322, 8304, 3598, 599, 278, 5153, 5818, 13, 4706, 6613, 800, 29889, 13, 4706, 9995, 13, 4706, 1583, 29889, 4801, 496, 29898, 23147, 29897, 13, 4706, 5096, 353, 1583, 29889, 5145, 7503, 29962, 13, 4706, 1550, 5096, 29901, 13, 9651, 1006, 29886, 353, 5096, 29889, 7323, 580, 13, 9651, 1006, 29886, 29889, 4801, 496, 877, 9780, 19854, 2313, 25600, 1495, 13, 9651, 5096, 29889, 21843, 29898, 1639, 29886, 29889, 5145, 29897, 13, 13, 1678, 822, 679, 29918, 5145, 29898, 1311, 29892, 1024, 1125, 13, 4706, 9995, 13, 4706, 4250, 2408, 29879, 278, 2278, 19854, 310, 445, 697, 411, 278, 2183, 1178, 29889, 13, 4706, 9995, 13, 4706, 1024, 353, 851, 29898, 978, 29897, 13, 4706, 9521, 353, 316, 802, 4197, 1311, 2314, 13, 4706, 1550, 9521, 29901, 13, 9651, 2343, 353, 9521, 29889, 7323, 1563, 580, 13, 9651, 565, 2343, 29889, 978, 1275, 1024, 29901, 13, 18884, 736, 2343, 13, 9651, 363, 1014, 1182, 297, 2343, 29889, 5145, 29901, 13, 18884, 9521, 29889, 4397, 29898, 1491, 1182, 29897, 13, 4706, 12020, 7865, 2392, 877, 3782, 2278, 19854, 411, 1316, 1024, 1495, 13, 2 ]
extensions/log.py
MerelyServices/Merely-Framework
1
194403
<gh_stars>1-10 """ Log - User activity recording and error tracing Features: to file, to channel, command, responses to a command, errors, misc Recommended cogs: Error """ import traceback from types import TracebackType from typing import Union import disnake from disnake.ext import commands class Log(commands.Cog): """ Record messages, commands and errors to file or a discord channel """ def __init__(self, bot:commands.Bot): self.bot = bot self.logchannel = None # ensure config file has required data if not bot.config.has_section('log'): bot.config.add_section('log') if 'logchannel' not in bot.config['log']: bot.config['log']['logchannel'] = '' @commands.Cog.listener('on_ready') async def get_logchannel(self): """ Connect to the logging channel """ if self.bot.config['log']['logchannel'].isdigit(): self.logchannel = await self.bot.fetch_channel(int(self.bot.config['log']['logchannel'])) def truncate(self, string:str, maxlen:int=30): return string[:maxlen] + ('...' if len(string) > maxlen else '') def wrap(self, content:str, author:disnake.User, channel:disnake.abc.Messageable): """ Format log data consistently """ if isinstance(channel, disnake.TextChannel): return f"[{self.truncate(channel.guild.name, 10)}#{self.truncate(channel.name)}] {self.truncate(author.name, 10)}#{author.discriminator}: {self.truncate(content)}" elif isinstance(channel, disnake.DMChannel): if channel.recipient: return f"[DM({self.truncate(channel.recipient.name, 10)}#{channel.recipient.discriminator})] {author.name}#{author.discriminator}: {self.truncate(content)}" else: return f"[DM] {self.truncate(author.name, 10)}#{author.discriminator}: {self.truncate(content)}" elif isinstance(channel, disnake.Thread): return f"[Thread] {self.truncate(author.name, 10)}#{author.discriminator}: {self.truncate(content)}" else: return f"[Unknown] {self.truncate(author.name, 10)}#{author.discriminator}: {self.truncate(content)}" @commands.Cog.listener('on_command') async def log_command(self, ctx:commands.Context): """ Record any command calls """ logentry = self.wrap(ctx.message.content, ctx.message.author, ctx.message.channel) print(logentry) if self.logchannel: await self.logchannel.send(logentry, embed=ctx.message.embeds[0] if ctx.message.embeds else None) @commands.Cog.listener('on_command_completion') async def log_response(self, ctx:commands.Context): """ Record any replies to a command """ responses = [] async for msg in ctx.history(after=ctx.message): if msg.author == self.bot.user and msg.reference.message_id == ctx.message.id: responses.append(msg) for response in responses: logentry = self.wrap(response.content, response.author, response.channel) print(logentry) if self.logchannel: await self.logchannel.send(logentry, embed=response.embeds[0] if response.embeds else None) async def log_misc_message(self, msg:disnake.Message): """ Record a message that is in some way related to a command """ logentry = self.wrap(msg.content, msg.author, msg.channel) print(logentry) if self.logchannel: await self.logchannel.send(logentry, embed=msg.embeds[0] if msg.embeds else None) async def log_misc_str(self, ctx:Union[commands.Context, disnake.Interaction], content:str): """ Record a string and context separately """ logentry = self.wrap(content, ctx.author, ctx.channel) print(logentry) if self.logchannel: await self.logchannel.send(logentry) @commands.Cog.listener('on_command_error') async def report_error(self, _:commands.Context, error:Exception): """ Record errors """ ex = traceback.format_exception(type(error), error, error.__traceback__) logentry = f"caused an error:\n```\n{''.join(ex)}```" print(logentry) if self.logchannel: await self.logchannel.send(logentry) def setup(bot): """ Bind this cog to the bot """ bot.add_cog(Log(bot))
[ 1, 529, 12443, 29918, 303, 1503, 29958, 29896, 29899, 29896, 29900, 13, 15945, 29908, 13, 29871, 4522, 448, 4911, 6354, 16867, 322, 1059, 16703, 292, 13, 29871, 5169, 3698, 29901, 304, 934, 29892, 304, 8242, 29892, 1899, 29892, 20890, 304, 263, 1899, 29892, 4436, 29892, 3984, 29883, 13, 29871, 830, 2055, 2760, 274, 12099, 29901, 4829, 13, 15945, 29908, 13, 13, 5215, 9637, 1627, 13, 3166, 4072, 1053, 29243, 1542, 13, 3166, 19229, 1053, 7761, 13, 5215, 766, 21040, 13, 3166, 766, 21040, 29889, 1062, 1053, 8260, 13, 13, 1990, 4522, 29898, 26381, 29889, 29907, 468, 1125, 13, 29871, 9995, 14164, 7191, 29892, 8260, 322, 4436, 304, 934, 470, 263, 2313, 536, 8242, 9995, 13, 29871, 822, 4770, 2344, 12035, 1311, 29892, 9225, 29901, 26381, 29889, 29933, 327, 1125, 13, 1678, 1583, 29889, 7451, 353, 9225, 13, 1678, 1583, 29889, 1188, 12719, 353, 6213, 13, 1678, 396, 9801, 2295, 934, 756, 3734, 848, 13, 1678, 565, 451, 9225, 29889, 2917, 29889, 5349, 29918, 2042, 877, 1188, 29374, 13, 418, 9225, 29889, 2917, 29889, 1202, 29918, 2042, 877, 1188, 1495, 13, 1678, 565, 525, 1188, 12719, 29915, 451, 297, 9225, 29889, 2917, 1839, 1188, 2033, 29901, 13, 418, 9225, 29889, 2917, 1839, 1188, 16215, 1188, 12719, 2033, 353, 6629, 13, 13, 29871, 732, 26381, 29889, 29907, 468, 29889, 25894, 877, 265, 29918, 2040, 1495, 13, 29871, 7465, 822, 679, 29918, 1188, 12719, 29898, 1311, 1125, 13, 1678, 9995, 14971, 304, 278, 12183, 8242, 9995, 13, 1678, 565, 1583, 29889, 7451, 29889, 2917, 1839, 1188, 16215, 1188, 12719, 13359, 275, 26204, 7295, 13, 418, 1583, 29889, 1188, 12719, 353, 7272, 1583, 29889, 7451, 29889, 9155, 29918, 12719, 29898, 524, 29898, 1311, 29889, 7451, 29889, 2917, 1839, 1188, 16215, 1188, 12719, 25901, 13, 13, 29871, 822, 21022, 403, 29898, 1311, 29892, 1347, 29901, 710, 29892, 4236, 2435, 29901, 524, 29922, 29941, 29900, 1125, 13, 1678, 736, 1347, 7503, 3317, 2435, 29962, 718, 6702, 856, 29915, 565, 7431, 29898, 1807, 29897, 1405, 4236, 2435, 1683, 27255, 13, 13, 29871, 822, 12244, 29898, 1311, 29892, 2793, 29901, 710, 29892, 4148, 29901, 2218, 21040, 29889, 2659, 29892, 8242, 29901, 2218, 21040, 29889, 10736, 29889, 3728, 519, 1125, 13, 1678, 9995, 19191, 1480, 848, 5718, 2705, 9995, 13, 1678, 565, 338, 8758, 29898, 12719, 29892, 766, 21040, 29889, 1626, 13599, 1125, 13, 418, 736, 285, 29908, 19660, 1311, 29889, 509, 4661, 403, 29898, 12719, 29889, 2543, 789, 29889, 978, 29892, 29871, 29896, 29900, 2915, 26660, 1311, 29889, 509, 4661, 403, 29898, 12719, 29889, 978, 2915, 29962, 426, 1311, 29889, 509, 4661, 403, 29898, 8921, 29889, 978, 29892, 29871, 29896, 29900, 2915, 26660, 8921, 29889, 2218, 29883, 20386, 1061, 6177, 426, 1311, 29889, 509, 4661, 403, 29898, 3051, 2915, 29908, 13, 1678, 25342, 338, 8758, 29898, 12719, 29892, 766, 21040, 29889, 23560, 13599, 1125, 13, 418, 565, 8242, 29889, 4361, 29886, 993, 29901, 13, 4706, 736, 285, 29908, 29961, 23560, 3319, 1311, 29889, 509, 4661, 403, 29898, 12719, 29889, 4361, 29886, 993, 29889, 978, 29892, 29871, 29896, 29900, 2915, 26660, 12719, 29889, 4361, 29886, 993, 29889, 2218, 29883, 20386, 1061, 1800, 29962, 426, 8921, 29889, 978, 29913, 26660, 8921, 29889, 2218, 29883, 20386, 1061, 6177, 426, 1311, 29889, 509, 4661, 403, 29898, 3051, 2915, 29908, 13, 418, 1683, 29901, 13, 4706, 736, 285, 29908, 29961, 23560, 29962, 426, 1311, 29889, 509, 4661, 403, 29898, 8921, 29889, 978, 29892, 29871, 29896, 29900, 2915, 26660, 8921, 29889, 2218, 29883, 20386, 1061, 6177, 426, 1311, 29889, 509, 4661, 403, 29898, 3051, 2915, 29908, 13, 1678, 25342, 338, 8758, 29898, 12719, 29892, 766, 21040, 29889, 4899, 1125, 13, 418, 736, 285, 29908, 29961, 4899, 29962, 426, 1311, 29889, 509, 4661, 403, 29898, 8921, 29889, 978, 29892, 29871, 29896, 29900, 2915, 26660, 8921, 29889, 2218, 29883, 20386, 1061, 6177, 426, 1311, 29889, 509, 4661, 403, 29898, 3051, 2915, 29908, 13, 1678, 1683, 29901, 13, 418, 736, 285, 29908, 29961, 14148, 29962, 426, 1311, 29889, 509, 4661, 403, 29898, 8921, 29889, 978, 29892, 29871, 29896, 29900, 2915, 26660, 8921, 29889, 2218, 29883, 20386, 1061, 6177, 426, 1311, 29889, 509, 4661, 403, 29898, 3051, 2915, 29908, 13, 13, 29871, 732, 26381, 29889, 29907, 468, 29889, 25894, 877, 265, 29918, 6519, 1495, 13, 29871, 7465, 822, 1480, 29918, 6519, 29898, 1311, 29892, 12893, 29901, 26381, 29889, 2677, 1125, 13, 1678, 9995, 14164, 738, 1899, 5717, 9995, 13, 1678, 1480, 8269, 353, 1583, 29889, 6312, 29898, 13073, 29889, 4906, 29889, 3051, 29892, 12893, 29889, 4906, 29889, 8921, 29892, 12893, 29889, 4906, 29889, 12719, 29897, 13, 1678, 1596, 29898, 1188, 8269, 29897, 13, 1678, 565, 1583, 29889, 1188, 12719, 29901, 13, 418, 7272, 1583, 29889, 1188, 12719, 29889, 6717, 29898, 1188, 8269, 29892, 8297, 29922, 13073, 29889, 4906, 29889, 1590, 5779, 29961, 29900, 29962, 565, 12893, 29889, 4906, 29889, 1590, 5779, 1683, 6213, 29897, 13, 13, 29871, 732, 26381, 29889, 29907, 468, 29889, 25894, 877, 265, 29918, 6519, 29918, 5729, 12757, 1495, 13, 29871, 7465, 822, 1480, 29918, 5327, 29898, 1311, 29892, 12893, 29901, 26381, 29889, 2677, 1125, 13, 1678, 9995, 14164, 738, 1634, 3687, 304, 263, 1899, 9995, 13, 1678, 20890, 353, 5159, 13, 1678, 7465, 363, 10191, 297, 12893, 29889, 18434, 29898, 7045, 29922, 13073, 29889, 4906, 1125, 13, 418, 565, 10191, 29889, 8921, 1275, 1583, 29889, 7451, 29889, 1792, 322, 10191, 29889, 5679, 29889, 4906, 29918, 333, 1275, 12893, 29889, 4906, 29889, 333, 29901, 13, 4706, 20890, 29889, 4397, 29898, 7645, 29897, 13, 1678, 363, 2933, 297, 20890, 29901, 13, 418, 1480, 8269, 353, 1583, 29889, 6312, 29898, 5327, 29889, 3051, 29892, 2933, 29889, 8921, 29892, 2933, 29889, 12719, 29897, 13, 418, 1596, 29898, 1188, 8269, 29897, 13, 418, 565, 1583, 29889, 1188, 12719, 29901, 13, 4706, 7272, 1583, 29889, 1188, 12719, 29889, 6717, 29898, 1188, 8269, 29892, 8297, 29922, 5327, 29889, 1590, 5779, 29961, 29900, 29962, 565, 2933, 29889, 1590, 5779, 1683, 6213, 29897, 13, 13, 29871, 7465, 822, 1480, 29918, 29885, 10669, 29918, 4906, 29898, 1311, 29892, 10191, 29901, 2218, 21040, 29889, 3728, 1125, 13, 1678, 9995, 14164, 263, 2643, 393, 338, 297, 777, 982, 4475, 304, 263, 1899, 9995, 13, 1678, 1480, 8269, 353, 1583, 29889, 6312, 29898, 7645, 29889, 3051, 29892, 10191, 29889, 8921, 29892, 10191, 29889, 12719, 29897, 13, 1678, 1596, 29898, 1188, 8269, 29897, 13, 1678, 565, 1583, 29889, 1188, 12719, 29901, 13, 418, 7272, 1583, 29889, 1188, 12719, 29889, 6717, 29898, 1188, 8269, 29892, 8297, 29922, 7645, 29889, 1590, 5779, 29961, 29900, 29962, 565, 10191, 29889, 1590, 5779, 1683, 6213, 29897, 13, 13, 29871, 7465, 822, 1480, 29918, 29885, 10669, 29918, 710, 29898, 1311, 29892, 12893, 29901, 19986, 29961, 26381, 29889, 2677, 29892, 766, 21040, 29889, 4074, 2467, 1402, 2793, 29901, 710, 1125, 13, 1678, 9995, 14164, 263, 1347, 322, 3030, 16949, 9995, 13, 1678, 1480, 8269, 353, 1583, 29889, 6312, 29898, 3051, 29892, 12893, 29889, 8921, 29892, 12893, 29889, 12719, 29897, 13, 1678, 1596, 29898, 1188, 8269, 29897, 13, 1678, 565, 1583, 29889, 1188, 12719, 29901, 13, 418, 7272, 1583, 29889, 1188, 12719, 29889, 6717, 29898, 1188, 8269, 29897, 13, 13, 29871, 732, 26381, 29889, 29907, 468, 29889, 25894, 877, 265, 29918, 6519, 29918, 2704, 1495, 13, 29871, 7465, 822, 3461, 29918, 2704, 29898, 1311, 29892, 903, 29901, 26381, 29889, 2677, 29892, 1059, 29901, 2451, 1125, 13, 1678, 9995, 14164, 4436, 9995, 13, 1678, 429, 353, 9637, 1627, 29889, 4830, 29918, 11739, 29898, 1853, 29898, 2704, 511, 1059, 29892, 1059, 17255, 15003, 1627, 1649, 29897, 13, 1678, 1480, 8269, 353, 285, 29908, 1113, 3880, 385, 1059, 3583, 29876, 28956, 29905, 29876, 10998, 4286, 7122, 29898, 735, 2915, 28956, 29908, 13, 1678, 1596, 29898, 1188, 8269, 29897, 13, 1678, 565, 1583, 29889, 1188, 12719, 29901, 13, 418, 7272, 1583, 29889, 1188, 12719, 29889, 6717, 29898, 1188, 8269, 29897, 13, 13, 1753, 6230, 29898, 7451, 1125, 13, 29871, 9995, 29672, 445, 274, 468, 304, 278, 9225, 9995, 13, 29871, 9225, 29889, 1202, 29918, 29883, 468, 29898, 3403, 29898, 7451, 876, 13, 2 ]
0531 Binary Matrix Leftmost One.py
ansabgillani/binarysearchcomproblems
1
60450
<reponame>ansabgillani/binarysearchcomproblems<gh_stars>1-10 class Solution: def solve(self, matrix): return min((bisect_left(row,1) for row in matrix if row and bisect_left(row,1) < len(row) and row[bisect_left(row,1)] == 1), default=-1)
[ 1, 529, 276, 1112, 420, 29958, 550, 370, 29887, 453, 3270, 29914, 19541, 4478, 510, 17199, 29879, 29966, 12443, 29918, 303, 1503, 29958, 29896, 29899, 29896, 29900, 13, 1990, 24380, 29901, 13, 1678, 822, 4505, 29898, 1311, 29892, 4636, 1125, 13, 4706, 736, 1375, 3552, 18809, 522, 29918, 1563, 29898, 798, 29892, 29896, 29897, 363, 1948, 297, 4636, 565, 1948, 322, 2652, 522, 29918, 1563, 29898, 798, 29892, 29896, 29897, 529, 7431, 29898, 798, 29897, 322, 1948, 29961, 18809, 522, 29918, 1563, 29898, 798, 29892, 29896, 4638, 1275, 29871, 29896, 511, 2322, 10457, 29896, 29897, 13, 2 ]
5oop-data-type.py
syedmurad1/OOP-Python
0
102950
# Text Type: str # Numeric Types: int, float, complex # Sequence Types: list, tuple, range # Mapping Type: dict # Set Types: set, frozenset # Boolean Type: bool # Binary Types: bytes, bytearray, memoryview x = float(1) # x will be 1.0 y = float(2.8) # y will be 2.8 z = float("3") # z will be 3.0 w = float("4.2") # w will be 4.2 print("--------------------------------------------------------") num =6 print(num) print(str(num)+ " is my num") # print(num + "my num") # print(num + "my num") - will not work print("--------------------------------------------------------")
[ 1, 396, 3992, 5167, 29901, 12, 710, 13, 29937, 405, 25099, 28025, 29901, 12, 524, 29892, 5785, 29892, 4280, 13, 29937, 922, 3910, 28025, 29901, 12, 1761, 29892, 18761, 29892, 3464, 13, 29937, 341, 20304, 5167, 29901, 12, 8977, 13, 29937, 3789, 28025, 29901, 12, 842, 29892, 14671, 29920, 575, 300, 13, 29937, 11185, 5167, 29901, 12, 11227, 13, 29937, 29479, 28025, 29901, 12, 13193, 29892, 7023, 2378, 29892, 3370, 1493, 13, 13, 29916, 353, 5785, 29898, 29896, 29897, 268, 396, 921, 674, 367, 29871, 29896, 29889, 29900, 13, 29891, 353, 5785, 29898, 29906, 29889, 29947, 29897, 259, 396, 343, 674, 367, 29871, 29906, 29889, 29947, 13, 29920, 353, 5785, 703, 29941, 1159, 259, 396, 503, 674, 367, 29871, 29941, 29889, 29900, 13, 29893, 353, 5785, 703, 29946, 29889, 29906, 1159, 396, 281, 674, 367, 29871, 29946, 29889, 29906, 13, 13, 2158, 703, 2683, 2683, 2683, 1378, 1159, 13, 13, 1949, 353, 29953, 13, 2158, 29898, 1949, 29897, 13, 2158, 29898, 710, 29898, 1949, 7240, 376, 338, 590, 954, 1159, 13, 29937, 1596, 29898, 1949, 718, 376, 1357, 954, 1159, 29871, 13, 29937, 1596, 29898, 1949, 718, 376, 1357, 954, 1159, 448, 674, 451, 664, 29871, 13, 13, 2158, 703, 2683, 2683, 2683, 1378, 1159, 13, 13, 13, 2 ]
src/gfx/map.py
MartinKondor/leap-of-time
0
1604955
""" Map class for playable and useable maps. """ import os import pygame from src.config import CONFIG from src.gfx.tileset import Tileset from src.gfx.map_layer import MapLayer import lib.PAdLib.occluder as occluder import lib.PAdLib.shadow as shadow class Map: def __init__(self, file_name): self.tileset = None self.layers = [] self.layer_size = (0, 0,) # Load the map for the correct level map_file = open(file_name) layer_will_be_solid = False in_layer = False for line in map_file.read().splitlines(): if not line: continue for ch in line + '\n': if ch == '#': # Ignore comments break if (not ch or ch.isspace()) and ch != '\n': # Ignore whitespace continue if ch == '{': in_layer = True self.layers.append([]) continue if ch == '}': self.layers[-1] = MapLayer(self.layers[-1], is_solid=layer_will_be_solid) in_layer = False layer_will_be_solid = False continue if in_layer and not ch.isspace(): self.layers[-1].append([int(l.strip()) - 1 for l in line.strip().split(',') if l.strip()]) # Parse line break elif ch == '*': layer_will_be_solid = True continue elif ch == '=': key, value = self.parse_key_value(line) # Set the given key if key == 'tileset': # Load the tileset self.tileset = Tileset(CONFIG.BASE_FOLDER + 'tilesets/' + value) break map_file.close() self.layers = self.layers[::-1] self.layer_size = ( self.tileset.tile_size[0] * max([len(layer[0]) for layer in self.layers]), self.tileset.tile_size[1] * max([len(layer) for layer in self.layers]) ) def parse_key_value(self, line: str): key, value = line.split('=') key = key.strip() if '"' in value: value = value.strip().split('"')[1] else: value = value.strip() return key, value def display(self, screen: pygame.Surface, player, entities): """ Draw the tiles what the user can see. """ """ shad = shadow.Shadow() occluders = [] """ for layer in self.layers: start_x = player.camera_x / self.tileset.tile_size[0] - 1 start_y = player.camera_y / self.tileset.tile_size[1] - 1 end_x = (CONFIG.WINDOW_WIDTH + player.camera_x) / self.tileset.tile_size[0] end_y = (CONFIG.WINDOW_HEIGHT + player.camera_y) / self.tileset.tile_size[1] if start_x < 0: start_x = 0 if start_y < 0: start_y = 0 for y, tiles in enumerate(layer): if y < start_y: continue elif y > end_y: break for x, tile in enumerate(tiles): if tile == -1 or x < start_x: continue elif x > end_x: break """ if layer.is_solid: xp = x * self.tileset.tile_size[0] - player.camera_x yp = y * self.tileset.tile_size[1] - player.camera_y occluders.append( occluder.Occluder([[xp, yp], [xp + self.tileset.tile_size[0], yp], [xp + self.tileset.tile_size[0], yp + self.tileset.tile_size[1]], [xp, yp + self.tileset.tile_size[1]]]) ) """ screen.blit(self.tileset.tiles[tile], (x * self.tileset.tile_size[0] - player.camera_x, y * self.tileset.tile_size[1] - player.camera_y,)) """ surf_lighting = pygame.Surface(screen.get_size()) surf_falloff = pygame.image.load(CONFIG.BASE_FOLDER + '../lib/PAdLib/examples/light_falloff100.png').convert() shad.set_light_position((player.x_pos - player.camera_x + player.body.width / 2, player.y_pos - player.camera_y + player.body.height / 2,)) shad.set_occluders(occluders) shad.set_radius(100.0) mask, draw_pos = shad.get_mask_and_position(False) mask.blit(surf_falloff, (0, 0,), special_flags=pygame.locals.BLEND_MULT) surf_lighting.fill((90, 90, 90)) surf_lighting.blit(mask, draw_pos, special_flags=pygame.locals.BLEND_MAX) screen.blit(surf_lighting, (0, 0,), special_flags=pygame.locals.BLEND_MULT) """
[ 1, 9995, 13, 3388, 770, 363, 1708, 519, 322, 671, 519, 11053, 29889, 13, 15945, 29908, 13, 5215, 2897, 13, 13, 5215, 22028, 13, 13, 3166, 4765, 29889, 2917, 1053, 8707, 18667, 13, 3166, 4765, 29889, 29887, 11093, 29889, 1376, 267, 300, 1053, 323, 5475, 300, 13, 3166, 4765, 29889, 29887, 11093, 29889, 1958, 29918, 13148, 1053, 7315, 14420, 13, 13, 5215, 4303, 29889, 29925, 3253, 14868, 29889, 542, 5762, 261, 408, 2179, 29880, 18309, 13, 5215, 4303, 29889, 29925, 3253, 14868, 29889, 17505, 408, 15504, 13, 13, 13, 1990, 7315, 29901, 13, 13, 1678, 822, 4770, 2344, 12035, 1311, 29892, 934, 29918, 978, 1125, 13, 4706, 1583, 29889, 1376, 267, 300, 353, 6213, 13, 4706, 1583, 29889, 29277, 353, 5159, 13, 4706, 1583, 29889, 13148, 29918, 2311, 353, 313, 29900, 29892, 29871, 29900, 29892, 29897, 13, 13, 4706, 396, 16012, 278, 2910, 363, 278, 1959, 3233, 13, 4706, 2910, 29918, 1445, 353, 1722, 29898, 1445, 29918, 978, 29897, 13, 4706, 7546, 29918, 14043, 29918, 915, 29918, 2929, 333, 353, 7700, 13, 4706, 297, 29918, 13148, 353, 7700, 13, 13, 4706, 363, 1196, 297, 2910, 29918, 1445, 29889, 949, 2141, 5451, 9012, 7295, 13, 9651, 565, 451, 1196, 29901, 13, 18884, 6773, 13, 13, 9651, 363, 521, 297, 1196, 718, 11297, 29876, 2396, 13, 18884, 565, 521, 1275, 16321, 2396, 29871, 396, 18076, 487, 6589, 13, 462, 1678, 2867, 13, 18884, 565, 313, 1333, 521, 470, 521, 29889, 790, 3535, 3101, 322, 521, 2804, 11297, 29876, 2396, 29871, 396, 18076, 487, 24358, 13, 462, 1678, 6773, 13, 18884, 565, 521, 1275, 22372, 2396, 13, 462, 1678, 297, 29918, 13148, 353, 5852, 13, 462, 1678, 1583, 29889, 29277, 29889, 4397, 4197, 2314, 13, 462, 1678, 6773, 13, 18884, 565, 521, 1275, 525, 29913, 2396, 13, 462, 1678, 1583, 29889, 29277, 14352, 29896, 29962, 353, 7315, 14420, 29898, 1311, 29889, 29277, 14352, 29896, 1402, 338, 29918, 2929, 333, 29922, 13148, 29918, 14043, 29918, 915, 29918, 2929, 333, 29897, 13, 462, 1678, 297, 29918, 13148, 353, 7700, 13, 462, 1678, 7546, 29918, 14043, 29918, 915, 29918, 2929, 333, 353, 7700, 13, 462, 1678, 6773, 13, 13, 18884, 565, 297, 29918, 13148, 322, 451, 521, 29889, 790, 3535, 7295, 13, 462, 1678, 1583, 29889, 29277, 14352, 29896, 1822, 4397, 4197, 524, 29898, 29880, 29889, 17010, 3101, 448, 29871, 29896, 363, 301, 297, 1196, 29889, 17010, 2141, 5451, 29317, 1495, 565, 301, 29889, 17010, 580, 2314, 29871, 396, 20969, 1196, 13, 462, 1678, 2867, 13, 18884, 25342, 521, 1275, 525, 29930, 2396, 13, 462, 1678, 7546, 29918, 14043, 29918, 915, 29918, 2929, 333, 353, 5852, 13, 462, 1678, 6773, 13, 18884, 25342, 521, 1275, 525, 29922, 2396, 13, 462, 1678, 1820, 29892, 995, 353, 1583, 29889, 5510, 29918, 1989, 29918, 1767, 29898, 1220, 29897, 29871, 396, 3789, 278, 2183, 1820, 13, 462, 1678, 565, 1820, 1275, 525, 1376, 267, 300, 2396, 29871, 396, 16012, 278, 260, 5475, 300, 13, 462, 4706, 1583, 29889, 1376, 267, 300, 353, 323, 5475, 300, 29898, 25903, 29889, 25416, 29918, 29943, 5607, 8032, 718, 525, 1376, 267, 1691, 22208, 718, 995, 29897, 13, 462, 1678, 2867, 13, 13, 4706, 2910, 29918, 1445, 29889, 5358, 580, 13, 308, 13, 4706, 1583, 29889, 29277, 353, 1583, 29889, 29277, 29961, 1057, 29899, 29896, 29962, 13, 4706, 1583, 29889, 13148, 29918, 2311, 353, 313, 13, 9651, 1583, 29889, 1376, 267, 300, 29889, 29873, 488, 29918, 2311, 29961, 29900, 29962, 334, 4236, 4197, 2435, 29898, 13148, 29961, 29900, 2314, 363, 7546, 297, 1583, 29889, 29277, 11724, 13, 9651, 1583, 29889, 1376, 267, 300, 29889, 29873, 488, 29918, 2311, 29961, 29896, 29962, 334, 4236, 4197, 2435, 29898, 13148, 29897, 363, 7546, 297, 1583, 29889, 29277, 2314, 13, 4706, 1723, 13, 13, 1678, 822, 6088, 29918, 1989, 29918, 1767, 29898, 1311, 29892, 1196, 29901, 851, 1125, 13, 4706, 1820, 29892, 995, 353, 1196, 29889, 5451, 877, 29922, 1495, 13, 4706, 1820, 353, 1820, 29889, 17010, 580, 13, 13, 4706, 565, 18793, 29915, 297, 995, 29901, 13, 9651, 995, 353, 995, 29889, 17010, 2141, 5451, 877, 29908, 29861, 29896, 29962, 13, 4706, 1683, 29901, 13, 9651, 995, 353, 995, 29889, 17010, 580, 13, 308, 13, 4706, 736, 1820, 29892, 995, 13, 13, 1678, 822, 2479, 29898, 1311, 29892, 4315, 29901, 22028, 29889, 18498, 2161, 29892, 4847, 29892, 16212, 1125, 13, 4706, 9995, 13, 4706, 18492, 278, 260, 5475, 825, 278, 1404, 508, 1074, 29889, 13, 4706, 9995, 13, 4706, 9995, 13, 4706, 528, 328, 353, 15504, 29889, 2713, 6986, 580, 13, 4706, 2179, 29880, 566, 414, 353, 5159, 13, 4706, 9995, 13, 13, 4706, 363, 7546, 297, 1583, 29889, 29277, 29901, 13, 9651, 1369, 29918, 29916, 353, 4847, 29889, 26065, 29918, 29916, 847, 1583, 29889, 1376, 267, 300, 29889, 29873, 488, 29918, 2311, 29961, 29900, 29962, 448, 29871, 29896, 13, 9651, 1369, 29918, 29891, 353, 4847, 29889, 26065, 29918, 29891, 847, 1583, 29889, 1376, 267, 300, 29889, 29873, 488, 29918, 2311, 29961, 29896, 29962, 448, 29871, 29896, 13, 9651, 1095, 29918, 29916, 353, 313, 25903, 29889, 25152, 3970, 29956, 29918, 22574, 718, 4847, 29889, 26065, 29918, 29916, 29897, 847, 1583, 29889, 1376, 267, 300, 29889, 29873, 488, 29918, 2311, 29961, 29900, 29962, 13, 9651, 1095, 29918, 29891, 353, 313, 25903, 29889, 25152, 3970, 29956, 29918, 9606, 22530, 718, 4847, 29889, 26065, 29918, 29891, 29897, 847, 1583, 29889, 1376, 267, 300, 29889, 29873, 488, 29918, 2311, 29961, 29896, 29962, 13, 13, 9651, 565, 1369, 29918, 29916, 529, 29871, 29900, 29901, 13, 18884, 1369, 29918, 29916, 353, 29871, 29900, 13, 9651, 565, 1369, 29918, 29891, 529, 29871, 29900, 29901, 13, 18884, 1369, 29918, 29891, 353, 29871, 29900, 13, 13, 9651, 363, 343, 29892, 260, 5475, 297, 26985, 29898, 13148, 1125, 13, 18884, 565, 343, 529, 1369, 29918, 29891, 29901, 13, 462, 1678, 6773, 13, 18884, 25342, 343, 1405, 1095, 29918, 29891, 29901, 13, 462, 1678, 2867, 13, 13, 18884, 363, 921, 29892, 25900, 297, 26985, 29898, 1376, 267, 1125, 13, 462, 1678, 565, 25900, 1275, 448, 29896, 470, 921, 529, 1369, 29918, 29916, 29901, 13, 462, 4706, 6773, 13, 462, 1678, 25342, 921, 1405, 1095, 29918, 29916, 29901, 13, 462, 4706, 2867, 13, 13, 462, 1678, 9995, 13, 462, 1678, 565, 7546, 29889, 275, 29918, 2929, 333, 29901, 13, 462, 4706, 921, 29886, 353, 921, 334, 1583, 29889, 1376, 267, 300, 29889, 29873, 488, 29918, 2311, 29961, 29900, 29962, 448, 4847, 29889, 26065, 29918, 29916, 13, 462, 4706, 343, 29886, 353, 343, 334, 1583, 29889, 1376, 267, 300, 29889, 29873, 488, 29918, 2311, 29961, 29896, 29962, 448, 4847, 29889, 26065, 29918, 29891, 13, 462, 4706, 2179, 29880, 566, 414, 29889, 4397, 29898, 13, 462, 9651, 2179, 29880, 18309, 29889, 22034, 29880, 18309, 4197, 29961, 26330, 29892, 343, 29886, 1402, 518, 26330, 718, 1583, 29889, 1376, 267, 300, 29889, 29873, 488, 29918, 2311, 29961, 29900, 1402, 343, 29886, 1402, 518, 26330, 718, 1583, 29889, 1376, 267, 300, 29889, 29873, 488, 29918, 2311, 29961, 29900, 1402, 343, 29886, 718, 1583, 29889, 1376, 267, 300, 29889, 29873, 488, 29918, 2311, 29961, 29896, 20526, 518, 26330, 29892, 343, 29886, 718, 1583, 29889, 1376, 267, 300, 29889, 29873, 488, 29918, 2311, 29961, 29896, 5262, 2314, 13, 462, 4706, 1723, 13, 462, 1678, 9995, 13, 13, 462, 1678, 4315, 29889, 2204, 277, 29898, 1311, 29889, 1376, 267, 300, 29889, 1376, 267, 29961, 29873, 488, 1402, 313, 29916, 334, 1583, 29889, 1376, 267, 300, 29889, 29873, 488, 29918, 2311, 29961, 29900, 29962, 448, 4847, 29889, 26065, 29918, 29916, 29892, 343, 334, 1583, 29889, 1376, 267, 300, 29889, 29873, 488, 29918, 2311, 29961, 29896, 29962, 448, 4847, 29889, 26065, 29918, 29891, 29892, 876, 13, 13, 4706, 9995, 13, 4706, 1190, 29888, 29918, 4366, 292, 353, 22028, 29889, 18498, 2161, 29898, 10525, 29889, 657, 29918, 2311, 3101, 13, 4706, 1190, 29888, 29918, 18263, 417, 600, 353, 22028, 29889, 3027, 29889, 1359, 29898, 25903, 29889, 25416, 29918, 29943, 5607, 8032, 718, 525, 6995, 1982, 29914, 29925, 3253, 14868, 29914, 19057, 29914, 4366, 29918, 18263, 417, 600, 29896, 29900, 29900, 29889, 2732, 2824, 13441, 580, 13, 13, 4706, 528, 328, 29889, 842, 29918, 4366, 29918, 3283, 3552, 9106, 29889, 29916, 29918, 1066, 448, 4847, 29889, 26065, 29918, 29916, 718, 4847, 29889, 2587, 29889, 2103, 847, 29871, 29906, 29892, 4847, 29889, 29891, 29918, 1066, 448, 4847, 29889, 26065, 29918, 29891, 718, 4847, 29889, 2587, 29889, 3545, 847, 29871, 29906, 29892, 876, 13, 4706, 528, 328, 29889, 842, 29918, 542, 5762, 414, 29898, 542, 5762, 414, 29897, 13, 4706, 528, 328, 29889, 842, 29918, 13471, 29898, 29896, 29900, 29900, 29889, 29900, 29897, 13, 4706, 11105, 29892, 4216, 29918, 1066, 353, 528, 328, 29889, 657, 29918, 13168, 29918, 392, 29918, 3283, 29898, 8824, 29897, 13, 4706, 11105, 29889, 2204, 277, 29898, 7610, 29888, 29918, 18263, 417, 600, 29892, 313, 29900, 29892, 29871, 29900, 29892, 511, 4266, 29918, 15764, 29922, 2272, 11802, 29889, 2997, 29879, 29889, 29933, 1307, 2797, 29918, 29924, 8647, 29897, 13, 13, 4706, 1190, 29888, 29918, 4366, 292, 29889, 5589, 3552, 29929, 29900, 29892, 29871, 29929, 29900, 29892, 29871, 29929, 29900, 876, 13, 4706, 1190, 29888, 29918, 4366, 292, 29889, 2204, 277, 29898, 13168, 29892, 4216, 29918, 1066, 29892, 4266, 29918, 15764, 29922, 2272, 11802, 29889, 2997, 29879, 29889, 29933, 1307, 2797, 29918, 12648, 29897, 13, 4706, 4315, 29889, 2204, 277, 29898, 7610, 29888, 29918, 4366, 292, 29892, 313, 29900, 29892, 29871, 29900, 29892, 511, 4266, 29918, 15764, 29922, 2272, 11802, 29889, 2997, 29879, 29889, 29933, 1307, 2797, 29918, 29924, 8647, 29897, 13, 4706, 9995, 13, 2 ]
members/crm/migrations/0017_profile_qb_realm_id.py
ocwc/ocwc-members
0
49826
# -*- coding: utf-8 -*- # Generated by Django 1.11.14 on 2019-01-20 12:04 from __future__ import unicode_literals from django.db import migrations, models class Migration(migrations.Migration): dependencies = [("crm", "0016_profile")] operations = [ migrations.AddField( model_name="profile", name="qb_realm_id", field=models.TextField(blank=True, default=b""), ) ]
[ 1, 396, 448, 29930, 29899, 14137, 29901, 23616, 29899, 29947, 448, 29930, 29899, 13, 29937, 3251, 630, 491, 15337, 29871, 29896, 29889, 29896, 29896, 29889, 29896, 29946, 373, 29871, 29906, 29900, 29896, 29929, 29899, 29900, 29896, 29899, 29906, 29900, 29871, 29896, 29906, 29901, 29900, 29946, 13, 3166, 4770, 29888, 9130, 1649, 1053, 29104, 29918, 20889, 1338, 13, 13, 3166, 9557, 29889, 2585, 1053, 9725, 800, 29892, 4733, 13, 13, 13, 1990, 341, 16783, 29898, 26983, 800, 29889, 29924, 16783, 1125, 13, 13, 1678, 9962, 353, 518, 703, 29883, 1758, 613, 376, 29900, 29900, 29896, 29953, 29918, 10185, 13531, 13, 13, 1678, 6931, 353, 518, 13, 4706, 9725, 800, 29889, 2528, 3073, 29898, 13, 9651, 1904, 29918, 978, 543, 10185, 613, 13, 9651, 1024, 543, 29939, 29890, 29918, 6370, 29885, 29918, 333, 613, 13, 9651, 1746, 29922, 9794, 29889, 15778, 29898, 19465, 29922, 5574, 29892, 2322, 29922, 29890, 29908, 4968, 13, 4706, 1723, 13, 1678, 4514, 13, 2 ]
tests/person_api/__init__.py
DerPate/OpenSlides
1
162721
<gh_stars>1-10 # -*- coding: utf-8 -*- VERSION = (9999, 9999, 9999, 'alpha', 1)
[ 1, 529, 12443, 29918, 303, 1503, 29958, 29896, 29899, 29896, 29900, 13, 29937, 448, 29930, 29899, 14137, 29901, 23616, 29899, 29947, 448, 29930, 29899, 13, 13, 16358, 353, 313, 29929, 29929, 29929, 29929, 29892, 29871, 29929, 29929, 29929, 29929, 29892, 29871, 29929, 29929, 29929, 29929, 29892, 525, 2312, 742, 29871, 29896, 29897, 13, 2 ]
Py Apple Dynamics V7.3 SRC/PA-Dynamics V7.3/PA_ATTITUDE.py
musen142/py-apple-dynamics
1
31837
<reponame>musen142/py-apple-dynamics<filename>Py Apple Dynamics V7.3 SRC/PA-Dynamics V7.3/PA_ATTITUDE.py from math import sin,cos,pi def cal_ges(PIT,ROL,l,b,w,x,Hc): YA=0 P=PIT*pi/180 R=ROL*pi/180 Y=YA*pi/180 #腿1 ABl_x=l/2 - x -(l*cos(P)*cos(Y))/2 + (b*cos(P)*sin(Y))/2 ABl_y=w/2 - (b*(cos(R)*cos(Y) + sin(P)*sin(R)*sin(Y)))/2 - (l*(cos(R)*sin(Y) - cos(Y)*sin(P)*sin(R)))/2 ABl_z= - Hc - (b*(cos(Y)*sin(R) - cos(R)*sin(P)*sin(Y)))/2 - (l*(sin(R)*sin(Y) + cos(R)*cos(Y)*sin(P)))/2 #腿2 AB2_x=l/2 - x - (l*cos(P)*cos(Y))/2 - (b*cos(P)*sin(Y))/2 AB2_y=(b*(cos(R)*cos(Y) + sin(P)*sin(R)*sin(Y)))/2 - w/2 - (l*(cos(R)*sin(Y) - cos(Y)*sin(P)*sin(R)))/2 AB2_z=(b*(cos(Y)*sin(R) - cos(R)*sin(P)*sin(Y)))/2 - Hc - (l*(sin(R)*sin(Y) + cos(R)*cos(Y)*sin(P)))/2 #腿3 AB3_x=(l*cos(P)*cos(Y))/2 - x - l/2 + (b*cos(P)*sin(Y))/2 AB3_y=w/2 - (b*(cos(R)*cos(Y) + sin(P)*sin(R)*sin(Y)))/2 + (l*(cos(R)*sin(Y) - cos(Y)*sin(P)*sin(R)))/2 AB3_z=(l*(sin(R)*sin(Y) + cos(R)*cos(Y)*sin(P)))/2 - (b*(cos(Y)*sin(R) - cos(R)*sin(P)*sin(Y)))/2 - Hc #腿4 AB4_x=(l*cos(P)*cos(Y))/2 - x - l/2 - (b*cos(P)*sin(Y))/2 AB4_y=(b*(cos(R)*cos(Y) + sin(P)*sin(R)*sin(Y)))/2 - w/2 + (l*(cos(R)*sin(Y) - cos(Y)*sin(P)*sin(R)))/2 AB4_z=(b*(cos(Y)*sin(R) - cos(R)*sin(P)*sin(Y)))/2 - Hc + (l*(sin(R)*sin(Y) + cos(R)*cos(Y)*sin(P)))/2 x1=ABl_x y1=ABl_z x2=AB2_x y2=AB2_z x3=AB4_x y3=AB4_z x4=AB3_x y4=AB3_z return x1,x2,x3,x4,y1,y2,y3,y4
[ 1, 529, 276, 1112, 420, 29958, 8366, 264, 29896, 29946, 29906, 29914, 2272, 29899, 11548, 29899, 29881, 2926, 1199, 29966, 9507, 29958, 19737, 12113, 22554, 1199, 478, 29955, 29889, 29941, 317, 10363, 29914, 7228, 29899, 29928, 2926, 1199, 478, 29955, 29889, 29941, 29914, 7228, 29918, 1299, 29911, 1806, 29965, 2287, 29889, 2272, 13, 3166, 5844, 1053, 4457, 29892, 3944, 29892, 1631, 13, 13, 1753, 1208, 29918, 2710, 29898, 29925, 1806, 29892, 1672, 29931, 29892, 29880, 29892, 29890, 29892, 29893, 29892, 29916, 29892, 29950, 29883, 1125, 13, 1678, 612, 29909, 29922, 29900, 13, 1678, 349, 29922, 29925, 1806, 29930, 1631, 29914, 29896, 29947, 29900, 13, 1678, 390, 29922, 1672, 29931, 29930, 1631, 29914, 29896, 29947, 29900, 13, 1678, 612, 29922, 29979, 29909, 29930, 1631, 29914, 29896, 29947, 29900, 13, 1678, 396, 235, 136, 194, 29896, 13, 1678, 319, 10358, 29918, 29916, 29922, 29880, 29914, 29906, 448, 921, 19691, 29880, 29930, 3944, 29898, 29925, 11877, 3944, 29898, 29979, 876, 29914, 29906, 718, 313, 29890, 29930, 3944, 29898, 29925, 11877, 5223, 29898, 29979, 876, 29914, 29906, 13, 1678, 319, 10358, 29918, 29891, 29922, 29893, 29914, 29906, 448, 313, 29890, 16395, 3944, 29898, 29934, 11877, 3944, 29898, 29979, 29897, 718, 4457, 29898, 29925, 11877, 5223, 29898, 29934, 11877, 5223, 29898, 29979, 4961, 29914, 29906, 448, 313, 29880, 16395, 3944, 29898, 29934, 11877, 5223, 29898, 29979, 29897, 448, 6776, 29898, 29979, 11877, 5223, 29898, 29925, 11877, 5223, 29898, 29934, 4961, 29914, 29906, 13, 1678, 319, 10358, 29918, 29920, 29922, 448, 379, 29883, 448, 313, 29890, 16395, 3944, 29898, 29979, 11877, 5223, 29898, 29934, 29897, 448, 6776, 29898, 29934, 11877, 5223, 29898, 29925, 11877, 5223, 29898, 29979, 4961, 29914, 29906, 448, 313, 29880, 16395, 5223, 29898, 29934, 11877, 5223, 29898, 29979, 29897, 718, 6776, 29898, 29934, 11877, 3944, 29898, 29979, 11877, 5223, 29898, 29925, 4961, 29914, 29906, 13, 1678, 396, 235, 136, 194, 29906, 13, 1678, 17571, 29906, 29918, 29916, 29922, 29880, 29914, 29906, 448, 921, 448, 313, 29880, 29930, 3944, 29898, 29925, 11877, 3944, 29898, 29979, 876, 29914, 29906, 448, 313, 29890, 29930, 3944, 29898, 29925, 11877, 5223, 29898, 29979, 876, 29914, 29906, 13, 1678, 17571, 29906, 29918, 29891, 7607, 29890, 16395, 3944, 29898, 29934, 11877, 3944, 29898, 29979, 29897, 718, 4457, 29898, 29925, 11877, 5223, 29898, 29934, 11877, 5223, 29898, 29979, 4961, 29914, 29906, 448, 281, 29914, 29906, 448, 313, 29880, 16395, 3944, 29898, 29934, 11877, 5223, 29898, 29979, 29897, 448, 6776, 29898, 29979, 11877, 5223, 29898, 29925, 11877, 5223, 29898, 29934, 4961, 29914, 29906, 13, 1678, 17571, 29906, 29918, 29920, 7607, 29890, 16395, 3944, 29898, 29979, 11877, 5223, 29898, 29934, 29897, 448, 6776, 29898, 29934, 11877, 5223, 29898, 29925, 11877, 5223, 29898, 29979, 4961, 29914, 29906, 448, 379, 29883, 448, 313, 29880, 16395, 5223, 29898, 29934, 11877, 5223, 29898, 29979, 29897, 718, 6776, 29898, 29934, 11877, 3944, 29898, 29979, 11877, 5223, 29898, 29925, 4961, 29914, 29906, 13, 1678, 396, 235, 136, 194, 29941, 13, 1678, 17571, 29941, 29918, 29916, 7607, 29880, 29930, 3944, 29898, 29925, 11877, 3944, 29898, 29979, 876, 29914, 29906, 448, 921, 448, 301, 29914, 29906, 718, 313, 29890, 29930, 3944, 29898, 29925, 11877, 5223, 29898, 29979, 876, 29914, 29906, 13, 1678, 17571, 29941, 29918, 29891, 29922, 29893, 29914, 29906, 448, 313, 29890, 16395, 3944, 29898, 29934, 11877, 3944, 29898, 29979, 29897, 718, 4457, 29898, 29925, 11877, 5223, 29898, 29934, 11877, 5223, 29898, 29979, 4961, 29914, 29906, 718, 313, 29880, 16395, 3944, 29898, 29934, 11877, 5223, 29898, 29979, 29897, 448, 6776, 29898, 29979, 11877, 5223, 29898, 29925, 11877, 5223, 29898, 29934, 4961, 29914, 29906, 13, 1678, 17571, 29941, 29918, 29920, 7607, 29880, 16395, 5223, 29898, 29934, 11877, 5223, 29898, 29979, 29897, 718, 6776, 29898, 29934, 11877, 3944, 29898, 29979, 11877, 5223, 29898, 29925, 4961, 29914, 29906, 448, 313, 29890, 16395, 3944, 29898, 29979, 11877, 5223, 29898, 29934, 29897, 448, 6776, 29898, 29934, 11877, 5223, 29898, 29925, 11877, 5223, 29898, 29979, 4961, 29914, 29906, 448, 379, 29883, 13, 1678, 396, 235, 136, 194, 29946, 13, 1678, 17571, 29946, 29918, 29916, 7607, 29880, 29930, 3944, 29898, 29925, 11877, 3944, 29898, 29979, 876, 29914, 29906, 448, 921, 448, 301, 29914, 29906, 448, 313, 29890, 29930, 3944, 29898, 29925, 11877, 5223, 29898, 29979, 876, 29914, 29906, 13, 1678, 17571, 29946, 29918, 29891, 7607, 29890, 16395, 3944, 29898, 29934, 11877, 3944, 29898, 29979, 29897, 718, 4457, 29898, 29925, 11877, 5223, 29898, 29934, 11877, 5223, 29898, 29979, 4961, 29914, 29906, 448, 281, 29914, 29906, 718, 313, 29880, 16395, 3944, 29898, 29934, 11877, 5223, 29898, 29979, 29897, 448, 6776, 29898, 29979, 11877, 5223, 29898, 29925, 11877, 5223, 29898, 29934, 4961, 29914, 29906, 13, 1678, 17571, 29946, 29918, 29920, 7607, 29890, 16395, 3944, 29898, 29979, 11877, 5223, 29898, 29934, 29897, 448, 6776, 29898, 29934, 11877, 5223, 29898, 29925, 11877, 5223, 29898, 29979, 4961, 29914, 29906, 448, 379, 29883, 718, 313, 29880, 16395, 5223, 29898, 29934, 11877, 5223, 29898, 29979, 29897, 718, 6776, 29898, 29934, 11877, 3944, 29898, 29979, 11877, 5223, 29898, 29925, 4961, 29914, 29906, 13, 13, 1678, 921, 29896, 29922, 2882, 29880, 29918, 29916, 13, 1678, 343, 29896, 29922, 2882, 29880, 29918, 29920, 13, 13, 1678, 921, 29906, 29922, 2882, 29906, 29918, 29916, 13, 1678, 343, 29906, 29922, 2882, 29906, 29918, 29920, 13, 13, 1678, 921, 29941, 29922, 2882, 29946, 29918, 29916, 13, 1678, 343, 29941, 29922, 2882, 29946, 29918, 29920, 13, 13, 1678, 921, 29946, 29922, 2882, 29941, 29918, 29916, 13, 1678, 343, 29946, 29922, 2882, 29941, 29918, 29920, 13, 268, 13, 1678, 736, 921, 29896, 29892, 29916, 29906, 29892, 29916, 29941, 29892, 29916, 29946, 29892, 29891, 29896, 29892, 29891, 29906, 29892, 29891, 29941, 29892, 29891, 29946, 13, 13, 13, 13, 13, 13, 2 ]
torchtools/tensors/tensor_group.py
cjwcommuny/torch-tools
0
22494
<reponame>cjwcommuny/torch-tools from typing import Dict, Tuple import torch from torch import Tensor from torchtools.tensors.function import unsqueeze class TensorGroup: def __init__(self, tensors: Dict[str, Tensor], check_validity: bool=True): self.tensors = tensors if check_validity: assert self.check_tensors_len(), "tensors don't has same length" def check_tensors_len(self) -> bool: return len(set(map(lambda x: len(x), self.tensors.values()))) == 1 @property def columns(self): return self.tensors.keys() def __len__(self): return len(next(iter(self.tensors.values()))) def __getitem__(self, item): if isinstance(item, str): return self.tensors[item] else: return TensorGroup( {key: tensor[item] for key, tensor in self.tensors.items()}, check_validity=False ) def __setitem__(self, key, value): if isinstance(key, str): self.tensors[key] = value else: for k in self.tensors.keys(): self.tensors[k][key] = value def min(self, input: str) -> Tuple['TensorGroup', Tensor]: indices = self.tensors[input].argmin(dim=0, keepdim=True) return ( TensorGroup( {key: tensor[indices] for key, tensor in self.tensors.items()}, check_validity=False ), indices ) def max(self, input: str) -> Tuple['TensorGroup', Tensor]: indices = self.tensors[input].argmax(dim=0, keepdim=True) return ( TensorGroup( {key: tensor[indices] for key, tensor in self.tensors.items()}, check_validity=False ), indices ) def sort(self, input: str, descending: bool=False) -> Tuple['TensorGroup', Tensor]: indices = self.tensors[input].argsort(dim=0, descending=descending) return ( TensorGroup( {key: tensor[indices] for key, tensor in self.tensors.items()}, check_validity=False ), indices ) def topk(self, input: str, k: int, largest: bool=True, sorted: bool=True) -> Tuple['TensorGroup', Tensor]: _, indices = self.tensors[input].topk(k, largest=largest, sorted=sorted) return ( TensorGroup( {key: tensor[indices] for key, tensor in self.tensors.items()}, check_validity=False ), indices ) @staticmethod def __mask_reshape_to_broadcast(tensor: Tensor, mask: Tensor) -> Tensor: result = unsqueeze(mask, dim=1, num=tensor.dim() - 1) print(f"mask.shape: {result.shape}") return result def masked_select(self, mask: Tensor) -> 'TensorGroup': assert mask.dim() == 1 print(f"mask: {mask.shape}") print(f"features: {self.tensors['features'].shape}") print(f"frame_id: {self.tensors['frame_id'].shape}") return TensorGroup( {key: tensor.masked_select(self.__mask_reshape_to_broadcast(tensor, mask)) for key, tensor in self.tensors.items()}, check_validity=False ) def index_select(self, indices: Tensor) -> 'TensorGroup': assert indices.dim() == 1 return self[indices] def lt_select(self, input: str, other) -> 'TensorGroup': """ NOTE: tensor.dim() must all be 1 """ mask = torch.lt(self.tensors[input], other) return self.masked_select(mask) def le_select(self, input: str, other) -> 'TensorGroup': """ NOTE: tensor.dim() must all be 1 """ mask = torch.le(self.tensors[input], other) return self.masked_select(mask) def gt_select(self, input: str, other) -> 'TensorGroup': """ NOTE: tensor.dim() must all be 1 """ mask = torch.gt(self.tensors[input], other) return self.masked_select(mask) def ge_select(self, input: str, other) -> 'TensorGroup': """ NOTE: tensor.dim() must all be 1 """ mask = torch.ge(self.tensors[input], other) return self.masked_select(mask) def ne_select(self, input: str, other) -> 'TensorGroup': """ NOTE: tensor.dim() must all be 1 """ mask = torch.ne(self.tensors[input], other) return self.masked_select(mask) def eq_select(self, input: str, other) -> 'TensorGroup': """ NOTE: tensor.dim() must all be 1 """ mask = torch.eq(self.tensors[input], other) return self.masked_select(mask)
[ 1, 529, 276, 1112, 420, 29958, 29883, 29926, 29893, 2055, 348, 29891, 29914, 7345, 305, 29899, 8504, 13, 3166, 19229, 1053, 360, 919, 29892, 12603, 552, 13, 13, 5215, 4842, 305, 13, 3166, 4842, 305, 1053, 323, 6073, 13, 13, 3166, 4842, 305, 8504, 29889, 29873, 575, 943, 29889, 2220, 1053, 9644, 802, 29872, 911, 13, 13, 13, 1990, 323, 6073, 4782, 29901, 13, 1678, 822, 4770, 2344, 12035, 1311, 29892, 25187, 943, 29901, 360, 919, 29961, 710, 29892, 323, 6073, 1402, 1423, 29918, 3084, 537, 29901, 6120, 29922, 5574, 1125, 13, 4706, 1583, 29889, 29873, 575, 943, 353, 25187, 943, 13, 4706, 565, 1423, 29918, 3084, 537, 29901, 13, 9651, 4974, 1583, 29889, 3198, 29918, 29873, 575, 943, 29918, 2435, 3285, 376, 29873, 575, 943, 1016, 29915, 29873, 756, 1021, 3309, 29908, 13, 13, 13, 1678, 822, 1423, 29918, 29873, 575, 943, 29918, 2435, 29898, 1311, 29897, 1599, 6120, 29901, 13, 4706, 736, 7431, 29898, 842, 29898, 1958, 29898, 2892, 921, 29901, 7431, 29898, 29916, 511, 1583, 29889, 29873, 575, 943, 29889, 5975, 580, 4961, 1275, 29871, 29896, 13, 13, 1678, 732, 6799, 13, 1678, 822, 4341, 29898, 1311, 1125, 13, 4706, 736, 1583, 29889, 29873, 575, 943, 29889, 8149, 580, 13, 13, 1678, 822, 4770, 2435, 12035, 1311, 1125, 13, 4706, 736, 7431, 29898, 4622, 29898, 1524, 29898, 1311, 29889, 29873, 575, 943, 29889, 5975, 580, 4961, 13, 13, 1678, 822, 4770, 657, 667, 12035, 1311, 29892, 2944, 1125, 13, 4706, 565, 338, 8758, 29898, 667, 29892, 851, 1125, 13, 9651, 736, 1583, 29889, 29873, 575, 943, 29961, 667, 29962, 13, 4706, 1683, 29901, 13, 9651, 736, 323, 6073, 4782, 29898, 13, 18884, 426, 1989, 29901, 12489, 29961, 667, 29962, 363, 1820, 29892, 12489, 297, 1583, 29889, 29873, 575, 943, 29889, 7076, 580, 1118, 13, 18884, 1423, 29918, 3084, 537, 29922, 8824, 13, 9651, 1723, 13, 13, 1678, 822, 4770, 842, 667, 12035, 1311, 29892, 1820, 29892, 995, 1125, 13, 4706, 565, 338, 8758, 29898, 1989, 29892, 851, 1125, 13, 9651, 1583, 29889, 29873, 575, 943, 29961, 1989, 29962, 353, 995, 13, 4706, 1683, 29901, 13, 9651, 363, 413, 297, 1583, 29889, 29873, 575, 943, 29889, 8149, 7295, 13, 18884, 1583, 29889, 29873, 575, 943, 29961, 29895, 3816, 1989, 29962, 353, 995, 13, 13, 13, 1678, 822, 1375, 29898, 1311, 29892, 1881, 29901, 851, 29897, 1599, 12603, 552, 1839, 29911, 6073, 4782, 742, 323, 6073, 5387, 13, 4706, 16285, 353, 1583, 29889, 29873, 575, 943, 29961, 2080, 1822, 1191, 1195, 29898, 6229, 29922, 29900, 29892, 3013, 6229, 29922, 5574, 29897, 13, 4706, 736, 313, 13, 9651, 323, 6073, 4782, 29898, 13, 18884, 426, 1989, 29901, 12489, 29961, 513, 1575, 29962, 363, 1820, 29892, 12489, 297, 1583, 29889, 29873, 575, 943, 29889, 7076, 580, 1118, 13, 18884, 1423, 29918, 3084, 537, 29922, 8824, 13, 9651, 10353, 13, 9651, 16285, 13, 4706, 1723, 13, 13, 1678, 822, 4236, 29898, 1311, 29892, 1881, 29901, 851, 29897, 1599, 12603, 552, 1839, 29911, 6073, 4782, 742, 323, 6073, 5387, 13, 4706, 16285, 353, 1583, 29889, 29873, 575, 943, 29961, 2080, 1822, 1191, 3317, 29898, 6229, 29922, 29900, 29892, 3013, 6229, 29922, 5574, 29897, 13, 4706, 736, 313, 13, 9651, 323, 6073, 4782, 29898, 13, 18884, 426, 1989, 29901, 12489, 29961, 513, 1575, 29962, 363, 1820, 29892, 12489, 297, 1583, 29889, 29873, 575, 943, 29889, 7076, 580, 1118, 13, 18884, 1423, 29918, 3084, 537, 29922, 8824, 13, 9651, 10353, 13, 9651, 16285, 13, 4706, 1723, 13, 13, 13, 1678, 822, 2656, 29898, 1311, 29892, 1881, 29901, 851, 29892, 5153, 2548, 29901, 6120, 29922, 8824, 29897, 1599, 12603, 552, 1839, 29911, 6073, 4782, 742, 323, 6073, 5387, 13, 4706, 16285, 353, 1583, 29889, 29873, 575, 943, 29961, 2080, 1822, 5085, 441, 29898, 6229, 29922, 29900, 29892, 5153, 2548, 29922, 14273, 2548, 29897, 13, 4706, 736, 313, 13, 9651, 323, 6073, 4782, 29898, 13, 18884, 426, 1989, 29901, 12489, 29961, 513, 1575, 29962, 363, 1820, 29892, 12489, 297, 1583, 29889, 29873, 575, 943, 29889, 7076, 580, 1118, 13, 18884, 1423, 29918, 3084, 537, 29922, 8824, 13, 9651, 10353, 13, 9651, 16285, 13, 4706, 1723, 13, 13, 1678, 822, 2246, 29895, 29898, 1311, 29892, 1881, 29901, 851, 29892, 413, 29901, 938, 29892, 10150, 29901, 6120, 29922, 5574, 29892, 12705, 29901, 6120, 29922, 5574, 29897, 1599, 12603, 552, 1839, 29911, 6073, 4782, 742, 323, 6073, 5387, 13, 4706, 17117, 16285, 353, 1583, 29889, 29873, 575, 943, 29961, 2080, 1822, 3332, 29895, 29898, 29895, 29892, 10150, 29922, 27489, 342, 29892, 12705, 29922, 24582, 29897, 13, 4706, 736, 313, 13, 9651, 323, 6073, 4782, 29898, 13, 18884, 426, 1989, 29901, 12489, 29961, 513, 1575, 29962, 363, 1820, 29892, 12489, 297, 1583, 29889, 29873, 575, 943, 29889, 7076, 580, 1118, 13, 18884, 1423, 29918, 3084, 537, 29922, 8824, 13, 9651, 10353, 13, 9651, 16285, 13, 4706, 1723, 13, 13, 13, 1678, 732, 7959, 5696, 13, 1678, 822, 4770, 13168, 29918, 690, 14443, 29918, 517, 29918, 6729, 328, 4384, 29898, 20158, 29901, 323, 6073, 29892, 11105, 29901, 323, 6073, 29897, 1599, 323, 6073, 29901, 13, 4706, 1121, 353, 9644, 802, 29872, 911, 29898, 13168, 29892, 3964, 29922, 29896, 29892, 954, 29922, 20158, 29889, 6229, 580, 448, 29871, 29896, 29897, 13, 4706, 1596, 29898, 29888, 29908, 13168, 29889, 12181, 29901, 426, 2914, 29889, 12181, 27195, 13, 4706, 736, 1121, 13, 13, 1678, 822, 11105, 287, 29918, 2622, 29898, 1311, 29892, 11105, 29901, 323, 6073, 29897, 1599, 525, 29911, 6073, 4782, 2396, 13, 4706, 4974, 11105, 29889, 6229, 580, 1275, 29871, 29896, 13, 4706, 1596, 29898, 29888, 29908, 13168, 29901, 426, 13168, 29889, 12181, 27195, 13, 4706, 1596, 29898, 29888, 29908, 22100, 29901, 426, 1311, 29889, 29873, 575, 943, 1839, 22100, 13359, 12181, 27195, 13, 4706, 1596, 29898, 29888, 29908, 2557, 29918, 333, 29901, 426, 1311, 29889, 29873, 575, 943, 1839, 2557, 29918, 333, 13359, 12181, 27195, 13, 4706, 736, 323, 6073, 4782, 29898, 13, 9651, 426, 1989, 29901, 12489, 29889, 13168, 287, 29918, 2622, 29898, 1311, 17255, 13168, 29918, 690, 14443, 29918, 517, 29918, 6729, 328, 4384, 29898, 20158, 29892, 11105, 876, 363, 1820, 29892, 12489, 297, 1583, 29889, 29873, 575, 943, 29889, 7076, 580, 1118, 13, 9651, 1423, 29918, 3084, 537, 29922, 8824, 13, 4706, 1723, 13, 13, 1678, 822, 2380, 29918, 2622, 29898, 1311, 29892, 16285, 29901, 323, 6073, 29897, 1599, 525, 29911, 6073, 4782, 2396, 13, 4706, 4974, 16285, 29889, 6229, 580, 1275, 29871, 29896, 13, 4706, 736, 1583, 29961, 513, 1575, 29962, 13, 13, 1678, 822, 301, 29873, 29918, 2622, 29898, 1311, 29892, 1881, 29901, 851, 29892, 916, 29897, 1599, 525, 29911, 6073, 4782, 2396, 13, 4706, 9995, 13, 4706, 6058, 29923, 29901, 12489, 29889, 6229, 580, 1818, 599, 367, 29871, 29896, 13, 4706, 9995, 13, 4706, 11105, 353, 4842, 305, 29889, 1896, 29898, 1311, 29889, 29873, 575, 943, 29961, 2080, 1402, 916, 29897, 13, 4706, 736, 1583, 29889, 13168, 287, 29918, 2622, 29898, 13168, 29897, 13, 13, 1678, 822, 454, 29918, 2622, 29898, 1311, 29892, 1881, 29901, 851, 29892, 916, 29897, 1599, 525, 29911, 6073, 4782, 2396, 13, 4706, 9995, 13, 4706, 6058, 29923, 29901, 12489, 29889, 6229, 580, 1818, 599, 367, 29871, 29896, 13, 4706, 9995, 13, 4706, 11105, 353, 4842, 305, 29889, 280, 29898, 1311, 29889, 29873, 575, 943, 29961, 2080, 1402, 916, 29897, 13, 4706, 736, 1583, 29889, 13168, 287, 29918, 2622, 29898, 13168, 29897, 13, 13, 1678, 822, 330, 29873, 29918, 2622, 29898, 1311, 29892, 1881, 29901, 851, 29892, 916, 29897, 1599, 525, 29911, 6073, 4782, 2396, 13, 4706, 9995, 13, 4706, 6058, 29923, 29901, 12489, 29889, 6229, 580, 1818, 599, 367, 29871, 29896, 13, 4706, 9995, 13, 4706, 11105, 353, 4842, 305, 29889, 4141, 29898, 1311, 29889, 29873, 575, 943, 29961, 2080, 1402, 916, 29897, 13, 4706, 736, 1583, 29889, 13168, 287, 29918, 2622, 29898, 13168, 29897, 13, 13, 1678, 822, 1737, 29918, 2622, 29898, 1311, 29892, 1881, 29901, 851, 29892, 916, 29897, 1599, 525, 29911, 6073, 4782, 2396, 13, 4706, 9995, 13, 4706, 6058, 29923, 29901, 12489, 29889, 6229, 580, 1818, 599, 367, 29871, 29896, 13, 4706, 9995, 13, 4706, 11105, 353, 4842, 305, 29889, 479, 29898, 1311, 29889, 29873, 575, 943, 29961, 2080, 1402, 916, 29897, 13, 4706, 736, 1583, 29889, 13168, 287, 29918, 2622, 29898, 13168, 29897, 13, 13, 1678, 822, 452, 29918, 2622, 29898, 1311, 29892, 1881, 29901, 851, 29892, 916, 29897, 1599, 525, 29911, 6073, 4782, 2396, 13, 4706, 9995, 13, 4706, 6058, 29923, 29901, 12489, 29889, 6229, 580, 1818, 599, 367, 29871, 29896, 13, 4706, 9995, 13, 4706, 11105, 353, 4842, 305, 29889, 484, 29898, 1311, 29889, 29873, 575, 943, 29961, 2080, 1402, 916, 29897, 13, 4706, 736, 1583, 29889, 13168, 287, 29918, 2622, 29898, 13168, 29897, 13, 13, 1678, 822, 11594, 29918, 2622, 29898, 1311, 29892, 1881, 29901, 851, 29892, 916, 29897, 1599, 525, 29911, 6073, 4782, 2396, 13, 4706, 9995, 13, 4706, 6058, 29923, 29901, 12489, 29889, 6229, 580, 1818, 599, 367, 29871, 29896, 13, 4706, 9995, 13, 4706, 11105, 353, 4842, 305, 29889, 1837, 29898, 1311, 29889, 29873, 575, 943, 29961, 2080, 1402, 916, 29897, 13, 4706, 736, 1583, 29889, 13168, 287, 29918, 2622, 29898, 13168, 29897, 2 ]
dbs/dal/Whiteport.py
xinghejd/opencanary_web
633
24609
#!/usr/bin/env python # -*- coding:utf-8 -*- """ Author: pirogue Purpose: 白名单端口表操作 Site: http://pirogue.org Created: 2018-08-03 17:32:54 """ from dbs.initdb import DBSession from dbs.models.Whiteport import Whiteport from sqlalchemy import desc,asc from sqlalchemy.exc import InvalidRequestError # import sys # sys.path.append("..") class WhitePort: """增删改查""" def __init__(self): self.session=DBSession # 查询白名单表port数据 def select_white_port(self): try: white_port_res = self.session.query(Whiteport.dst_port).all() return white_port_res except InvalidRequestError: self.session.rollback() except Exception as e: print(e) finally: self.session.close() # 增加白名单 def insert_white_port(self, dst_port): try: wip_insert = Whiteport(dst_port=dst_port) self.session.merge(wip_insert) self.session.commit() except InvalidRequestError: self.session.rollback() except Exception as e: print(e) finally: self.session.close() # 删除白名单端口表数据 def delete_white_port(self): try: self.session.query(Whiteport).delete() self.session.commit() except InvalidRequestError: self.session.rollback() except Exception as e: print(e) finally: self.session.close()
[ 1, 18787, 4855, 29914, 2109, 29914, 6272, 3017, 13, 29937, 448, 29930, 29899, 14137, 29901, 9420, 29899, 29947, 448, 29930, 29899, 13, 15945, 29908, 13, 29871, 13361, 29901, 2930, 9102, 434, 29871, 13, 29871, 15247, 4220, 29901, 29871, 30868, 30548, 31166, 234, 174, 178, 30856, 30746, 31904, 30732, 13, 29871, 10781, 29901, 1732, 597, 1631, 9102, 434, 29889, 990, 29871, 13, 29871, 6760, 630, 29901, 29871, 29906, 29900, 29896, 29947, 29899, 29900, 29947, 29899, 29900, 29941, 29871, 29896, 29955, 29901, 29941, 29906, 29901, 29945, 29946, 13, 15945, 29908, 13, 13, 13, 3166, 4833, 29879, 29889, 2344, 2585, 1053, 6535, 7317, 13, 3166, 4833, 29879, 29889, 9794, 29889, 21823, 637, 1053, 8037, 637, 13, 3166, 4576, 284, 305, 6764, 1053, 5153, 29892, 6151, 13, 3166, 4576, 284, 305, 6764, 29889, 735, 29883, 1053, 21403, 3089, 2392, 13, 13, 13, 29937, 1053, 10876, 13, 29937, 10876, 29889, 2084, 29889, 4397, 703, 636, 1159, 13, 13, 1990, 8037, 2290, 29901, 13, 1678, 9995, 232, 165, 161, 31916, 31264, 31213, 15945, 29908, 13, 13, 1678, 822, 4770, 2344, 12035, 1311, 1125, 259, 13, 4706, 1583, 29889, 7924, 29922, 4051, 7317, 13, 13, 1678, 396, 29871, 31213, 235, 178, 165, 30868, 30548, 31166, 30746, 637, 30354, 30763, 13, 1678, 822, 1831, 29918, 10921, 29918, 637, 29898, 1311, 1125, 13, 4706, 1018, 29901, 13, 9651, 4796, 29918, 637, 29918, 690, 353, 1583, 29889, 7924, 29889, 1972, 29898, 21823, 637, 29889, 22992, 29918, 637, 467, 497, 580, 13, 9651, 736, 4796, 29918, 637, 29918, 690, 13, 4706, 5174, 21403, 3089, 2392, 29901, 13, 9651, 1583, 29889, 7924, 29889, 1245, 1627, 580, 13, 4706, 5174, 8960, 408, 321, 29901, 13, 9651, 1596, 29898, 29872, 29897, 13, 4706, 7146, 29901, 13, 9651, 1583, 29889, 7924, 29889, 5358, 580, 13, 268, 13, 1678, 396, 29871, 232, 165, 161, 30666, 30868, 30548, 31166, 13, 1678, 822, 4635, 29918, 10921, 29918, 637, 29898, 1311, 29892, 29743, 29918, 637, 1125, 13, 4706, 1018, 29901, 13, 9651, 281, 666, 29918, 7851, 353, 8037, 637, 29898, 22992, 29918, 637, 29922, 22992, 29918, 637, 29897, 13, 9651, 1583, 29889, 7924, 29889, 14634, 29898, 29893, 666, 29918, 7851, 29897, 13, 9651, 1583, 29889, 7924, 29889, 15060, 580, 13, 4706, 5174, 21403, 3089, 2392, 29901, 13, 9651, 1583, 29889, 7924, 29889, 1245, 1627, 580, 13, 4706, 5174, 8960, 408, 321, 29901, 13, 9651, 1596, 29898, 29872, 29897, 13, 4706, 7146, 29901, 13, 9651, 1583, 29889, 7924, 29889, 5358, 580, 13, 13, 1678, 396, 29871, 31916, 31152, 30868, 30548, 31166, 234, 174, 178, 30856, 30746, 30354, 30763, 13, 1678, 822, 5217, 29918, 10921, 29918, 637, 29898, 1311, 1125, 13, 4706, 1018, 29901, 13, 9651, 1583, 29889, 7924, 29889, 1972, 29898, 21823, 637, 467, 8143, 580, 13, 9651, 1583, 29889, 7924, 29889, 15060, 580, 13, 4706, 5174, 21403, 3089, 2392, 29901, 13, 9651, 1583, 29889, 7924, 29889, 1245, 1627, 580, 13, 4706, 5174, 8960, 408, 321, 29901, 13, 9651, 1596, 29898, 29872, 29897, 13, 4706, 7146, 29901, 13, 9651, 1583, 29889, 7924, 29889, 5358, 580, 2 ]
examples/multi_client_example.py
ondewo/ondewo-csi-client-python
0
32971
<reponame>ondewo/ondewo-csi-client-python<filename>examples/multi_client_example.py #!/usr/bin/env python # coding: utf-8 # # Copyright 2021 ONDEWO GmbH # # Licensed under the Apache License, Version 2.0 (the License); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an AS IS BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import ondewo.nlu.agent_pb2 as agent import ondewo.s2t.speech_to_text_pb2 as s2t import ondewo.t2s.text_to_speech_pb2 as t2s from ondewo.nlu.client import Client as NluClient from ondewo.nlu.client_config import ClientConfig as NluClientConfig from ondewo.s2t.client.client import Client as S2tClient from ondewo.t2s.client.client import Client as T2sClient from ondewo.csi.client.client import Client as CsiClient from ondewo.csi.client.client_config import ClientConfig with open("csi.json") as fi: config = ClientConfig.from_json(fi.read()) with open("csi.json") as fi: nlu_config = NluClientConfig.from_json(fi.read()) csi_client = CsiClient(config=config) s2t_client = S2tClient(config=config) t2s_client = T2sClient(config=config) nlu_client = NluClient(config=nlu_config) s2t_pipelines = s2t_client.services.speech_to_text.list_s2t_pipelines(request=s2t.ListS2tPipelinesRequest()) t2s_pipelines = t2s_client.services.text_to_speech.list_t2s_pipelines(request=t2s.ListT2sPipelinesRequest()) print(f"Speech to text pipelines: {[pipeline.id for pipeline in s2t_pipelines.pipeline_configs]}") print(f"Text to speech pipelines: {[pipeline.id for pipeline in t2s_pipelines.pipelines]}") agents = nlu_client.services.agents.list_agents(request=agent.ListAgentsRequest()) print(f"Nlu agents: {[agent.agent.parent for agent in agents.agents_with_owners]}")
[ 1, 529, 276, 1112, 420, 29958, 13469, 827, 29914, 13469, 827, 29899, 29883, 1039, 29899, 4645, 29899, 4691, 29966, 9507, 29958, 19057, 29914, 9910, 29918, 4645, 29918, 4773, 29889, 2272, 13, 29937, 14708, 4855, 29914, 2109, 29914, 6272, 3017, 13, 29937, 14137, 29901, 23616, 29899, 29947, 13, 29937, 13, 29937, 14187, 1266, 29871, 29906, 29900, 29906, 29896, 6732, 2287, 29956, 29949, 18156, 13, 29937, 13, 29937, 10413, 21144, 1090, 278, 13380, 19245, 29892, 10079, 29871, 29906, 29889, 29900, 313, 1552, 19245, 416, 13, 29937, 366, 1122, 451, 671, 445, 934, 5174, 297, 752, 13036, 411, 278, 19245, 29889, 13, 29937, 887, 1122, 4017, 263, 3509, 310, 278, 19245, 472, 13, 29937, 13, 29937, 268, 1732, 597, 1636, 29889, 4288, 29889, 990, 29914, 506, 11259, 29914, 27888, 1430, 1660, 29899, 29906, 29889, 29900, 13, 29937, 13, 29937, 25870, 3734, 491, 22903, 4307, 470, 15502, 304, 297, 5007, 29892, 7047, 13, 29937, 13235, 1090, 278, 19245, 338, 13235, 373, 385, 3339, 8519, 350, 3289, 3235, 29892, 13, 29937, 399, 1806, 8187, 2692, 399, 1718, 29934, 13566, 29059, 6323, 8707, 29928, 22122, 29903, 8079, 13764, 29979, 476, 22255, 29892, 2845, 4653, 470, 2411, 2957, 29889, 13, 29937, 2823, 278, 19245, 363, 278, 2702, 4086, 14765, 1076, 11239, 322, 13, 29937, 27028, 1090, 278, 19245, 29889, 13, 13, 5215, 16504, 827, 29889, 29876, 6092, 29889, 14748, 29918, 24381, 29906, 408, 10823, 13, 5215, 16504, 827, 29889, 29879, 29906, 29873, 29889, 5965, 5309, 29918, 517, 29918, 726, 29918, 24381, 29906, 408, 269, 29906, 29873, 13, 5215, 16504, 827, 29889, 29873, 29906, 29879, 29889, 726, 29918, 517, 29918, 5965, 5309, 29918, 24381, 29906, 408, 260, 29906, 29879, 13, 3166, 16504, 827, 29889, 29876, 6092, 29889, 4645, 1053, 12477, 408, 405, 6092, 4032, 13, 3166, 16504, 827, 29889, 29876, 6092, 29889, 4645, 29918, 2917, 1053, 12477, 3991, 408, 405, 6092, 4032, 3991, 13, 3166, 16504, 827, 29889, 29879, 29906, 29873, 29889, 4645, 29889, 4645, 1053, 12477, 408, 317, 29906, 29873, 4032, 13, 3166, 16504, 827, 29889, 29873, 29906, 29879, 29889, 4645, 29889, 4645, 1053, 12477, 408, 323, 29906, 29879, 4032, 13, 13, 3166, 16504, 827, 29889, 29883, 1039, 29889, 4645, 29889, 4645, 1053, 12477, 408, 315, 1039, 4032, 13, 3166, 16504, 827, 29889, 29883, 1039, 29889, 4645, 29889, 4645, 29918, 2917, 1053, 12477, 3991, 13, 13, 2541, 1722, 703, 29883, 1039, 29889, 3126, 1159, 408, 5713, 29901, 13, 1678, 2295, 353, 12477, 3991, 29889, 3166, 29918, 3126, 29898, 7241, 29889, 949, 3101, 13, 2541, 1722, 703, 29883, 1039, 29889, 3126, 1159, 408, 5713, 29901, 13, 1678, 302, 6092, 29918, 2917, 353, 405, 6092, 4032, 3991, 29889, 3166, 29918, 3126, 29898, 7241, 29889, 949, 3101, 13, 13, 29883, 1039, 29918, 4645, 353, 315, 1039, 4032, 29898, 2917, 29922, 2917, 29897, 13, 29879, 29906, 29873, 29918, 4645, 353, 317, 29906, 29873, 4032, 29898, 2917, 29922, 2917, 29897, 13, 29873, 29906, 29879, 29918, 4645, 353, 323, 29906, 29879, 4032, 29898, 2917, 29922, 2917, 29897, 13, 29876, 6092, 29918, 4645, 353, 405, 6092, 4032, 29898, 2917, 29922, 29876, 6092, 29918, 2917, 29897, 13, 13, 29879, 29906, 29873, 29918, 13096, 24210, 353, 269, 29906, 29873, 29918, 4645, 29889, 9916, 29889, 5965, 5309, 29918, 517, 29918, 726, 29889, 1761, 29918, 29879, 29906, 29873, 29918, 13096, 24210, 29898, 3827, 29922, 29879, 29906, 29873, 29889, 1293, 29903, 29906, 29873, 29925, 666, 24210, 3089, 3101, 13, 29873, 29906, 29879, 29918, 13096, 24210, 353, 260, 29906, 29879, 29918, 4645, 29889, 9916, 29889, 726, 29918, 517, 29918, 5965, 5309, 29889, 1761, 29918, 29873, 29906, 29879, 29918, 13096, 24210, 29898, 3827, 29922, 29873, 29906, 29879, 29889, 1293, 29911, 29906, 29879, 29925, 666, 24210, 3089, 3101, 13, 13, 2158, 29898, 29888, 29908, 10649, 5309, 304, 1426, 8450, 24210, 29901, 426, 29961, 13096, 5570, 29889, 333, 363, 16439, 297, 269, 29906, 29873, 29918, 13096, 24210, 29889, 13096, 5570, 29918, 2917, 29879, 12258, 1159, 13, 2158, 29898, 29888, 29908, 1626, 304, 12032, 8450, 24210, 29901, 426, 29961, 13096, 5570, 29889, 333, 363, 16439, 297, 260, 29906, 29879, 29918, 13096, 24210, 29889, 13096, 24210, 12258, 1159, 13, 13, 351, 1237, 353, 302, 6092, 29918, 4645, 29889, 9916, 29889, 351, 1237, 29889, 1761, 29918, 351, 1237, 29898, 3827, 29922, 14748, 29889, 1293, 14769, 1237, 3089, 3101, 13, 13, 2158, 29898, 29888, 29908, 29940, 6092, 19518, 29901, 426, 29961, 14748, 29889, 14748, 29889, 3560, 363, 10823, 297, 19518, 29889, 351, 1237, 29918, 2541, 29918, 776, 414, 12258, 1159, 13, 2 ]
audioroutines.py
jmcmellen/sameeas
17
70800
<reponame>jmcmellen/sameeas<filename>audioroutines.py import math, struct, random, array pi = math.pi def getFIRrectFilterCoeff(fc, sampRate, filterLen=20): 'Calculate FIR lowpass filter weights using hamming window' 'y(n) = w0 * x(n) + w1 * x(n-1) + ...' ft = float(fc) / sampRate #print ft m = float(filterLen - 1) weights = [] for n in range(filterLen): try: weight = math.sin( 2 * pi * ft * (n - (m / 2))) / (pi * (n - (m / 2))) hamming = 0.54 - 0.46 * math.cos( 2 * pi * n / m) weight = weight * hamming except: weight = 2 * ft hamming = 0.54 - 0.46 * math.cos( 2 * pi * n / m) weight = weight * hamming weights.append(weight) return weights def filterPCMaudio(fc, sampRate, filterLen, sampWidth, numCh, data): 'Run samples through a filter' samples = array.array('h', data) filtered = "" w = getFIRrectFilterCoeff(fc, sampRate, filterLen) for n in range(len(w), len(samples) - len(w)): acc = 0 for i in range(len(w)): acc += w[i] * samples[n - i] filtered += struct.pack('<h', int(math.floor(acc))) return filtered def recursiveFilterPCMaudio(fc, sampRate, sampWidth, numCh, data): 'Predefined filter values, Butterworth lowpass filter' a0 = 0.02008337 #0.01658193 a1 = 0.04016673 #0.03316386 a2 = a0 b1 = -1.56101808 #-1.60413018 b2 = 0.64135154 #0.67045791 samples = array.array('h', data) filtered = data[0:2] y = [0, 0, 0] for n in range(2, len(samples) - 2): sample = (a0 * samples[n] + a1 * samples[n -1] + a2 * samples[n-2] - b1 * y[1] - b2 * y[2]) y[2] = y[1] y[1] = sample filtered += struct.pack('<h', int(math.floor(sample))) return filtered def bpButterworthFilter6(fc, sampRate, sampWidth, numCh, data): a0 = 1 a1 = -4.16740087e+00 a2 = 9.56715918e+00 a3 = -1.52777374e+01 a4 = 1.88165959e+01 a5 = -1.84592133e+01 a6 = 1.46959044e+01 a7 = -9.50055587e+00 a8 = 4.97057565e+00 a9 = -2.04987349e+00 a10 = 6.42775774e-01 a11 = -1.38591530e-01 a12 = 1.72096260e-02 b0 = 3.36990647e-03 b1 = 0 b2 = -2.02194388e-02 b3 = 0 b4 = 5.05485971e-02 b5 = -2.15330343e-17 b6 = -6.73981294e-02 b7 = 2.15330343e-17 b8 = 5.05485971e-02 b9 = 0 b10 = -2.02194388e-02 b11 = 0 b12 = 3.36990647e-03 samples = array.array('h', data) print len(samples) filtered = data[0:12] y = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] for n in range(12, len(samples) - 12): sample = (a0 * samples[n] + a1 * samples[n -1] + a2 * samples[n-2] + a3 * samples[n-3] + a4 * samples[n-4] + a5 * samples[n-5] + a6 * samples[n-6] + a7 * samples[n-7] + a8 * samples[n-8] + a9 * samples[n-9] + a10 * samples[n-10] + a11 * samples[n-11] + a12 * samples[n-12] - b0 * y[0] - b1 * y[1] - b2 * y[2] - b3 * y[3] - b4 * y[4] - b5 * y[5] - b6 * y[6] - b7 * y[7] - b8 * y[8] - b9 * y[9] - b10 * y[10] - b11 * y[11] - b12 * y[12] ) y[12] = y[11] y[11] = y[10] y[10] = y[9] y[9] = y[8] y[8] = y[7] y[7] = y[6] y[6] = y[5] y[5] = y[4] y[4] = y[3] y[3] = y[2] y[2] = y[1] y[1] = sample filtered += struct.pack('<h', int(math.floor(sample))) return filtered def convertdbFStoInt( level, sampWidth): return math.pow(10, (float(level) / 20)) * 32767 def generateSimplePCMToneData(startfreq, endfreq, sampRate, duration, sampWidth, peakLevel, numCh): """Generate a string of binary data formatted as a PCM sample stream. Freq is in Hz, sampRate is in Samples per second, duration is in seconds, sampWidth is in bits, peakLevel is in dBFS, and numCh is either 1 or 2.""" phase = 0 * pi level = convertdbFStoInt(peakLevel, sampWidth) pcm_data = '' freq = startfreq slope = 0.5 * (endfreq - startfreq) / float(sampRate * duration) fade_len = int(0.001 * sampRate) * 0 numSamples = int( round( sampRate * duration)) #print duration * sampRate for i in range(0, numSamples): freq = slope * i + startfreq fade = 1.0 if i < fade_len: fade = 0.5 * (1 - math.cos(pi * i / (fade_len - 1))) elif i > (numSamples - fade_len): fade = 0.5 * (1 - math.cos(pi * (numSamples - i) / (fade_len - 1))) for ch in range(numCh): sample = int(( fade * level * math.sin( (freq * 2 * pi * i)/ sampRate + phase) )) #print sample pcm_data += struct.pack('<h', sample) return pcm_data def generateDualTonePCMData(freq1, freq2, sampRate, duration, sampWidth, peakLevel, numCh): """Generate a string of binary data formatted as a PCM sample stream. Mix two freq together such as in alert tones or DTMF""" phase = 0 * pi level = convertdbFStoInt(peakLevel, sampWidth) pcm_data = '' fade_len = int(0.001 * sampRate) * 0 numSamples = int( round( sampRate * duration)) #print duration * sampRate for i in range(0, numSamples): fade = 1.0 if i < fade_len: fade = 0.5 * (1 - math.cos(pi * i / (fade_len - 1))) elif i > (numSamples - fade_len): fade = 0.5 * (1 - math.cos(pi * (numSamples - i) / (fade_len - 1))) for ch in range(numCh): sample = int(( fade * level * (0.5 * math.sin( (freq1 * 2 * pi * i)/ sampRate + phase) + 0.5 * math.sin((freq2 * 2 * pi * i)/ sampRate + phase) ))) #print sample pcm_data += struct.pack('<h', sample) return pcm_data def main(): import wave numCh = 1 peakLevel = -10 sampWidth = 16 sampRate = 44100 file = wave.open('testchirp.wav', 'rb') samples = file.readframes( file.getnframes()) file.close() #data = generateDualTonePCMData(853, 960, sampRate, 8, sampWidth, peakLevel, numCh) data = bpButterworthFilter6(0, sampRate, sampWidth, numCh, samples) fileout = wave.open( 'test.wav', 'wb') fileout.setparams( (numCh, sampWidth/8, sampRate, sampRate, 'NONE', '') ) fileout.writeframes(data) fileout.close() if __name__ == "__main__": main()
[ 1, 529, 276, 1112, 420, 29958, 21231, 4912, 4919, 29914, 17642, 29872, 294, 29966, 9507, 29958, 15052, 1611, 449, 1475, 29889, 2272, 13, 5215, 5844, 29892, 2281, 29892, 4036, 29892, 1409, 30004, 13, 30004, 13, 1631, 353, 5844, 29889, 1631, 30004, 13, 30004, 13, 1753, 679, 3738, 29934, 1621, 5072, 29907, 7297, 600, 29898, 13801, 29892, 269, 1160, 19907, 29892, 4175, 21515, 29922, 29906, 29900, 1125, 30004, 13, 1678, 525, 27065, 403, 383, 8193, 4482, 3364, 4175, 18177, 773, 16366, 4056, 3474, 29915, 30004, 13, 1678, 525, 29891, 29898, 29876, 29897, 353, 281, 29900, 334, 921, 29898, 29876, 29897, 718, 281, 29896, 334, 921, 29898, 29876, 29899, 29896, 29897, 718, 2023, 29915, 30004, 13, 30004, 13, 1678, 11791, 353, 5785, 29898, 13801, 29897, 847, 269, 1160, 19907, 30004, 13, 1678, 396, 2158, 11791, 30004, 13, 1678, 286, 353, 5785, 29898, 4572, 21515, 448, 29871, 29896, 8443, 13, 30004, 13, 1678, 18177, 353, 5159, 30004, 13, 1678, 363, 302, 297, 3464, 29898, 4572, 21515, 1125, 30004, 13, 12, 2202, 29901, 30004, 13, 12, 1678, 7688, 353, 5844, 29889, 5223, 29898, 29871, 29906, 334, 2930, 334, 11791, 334, 313, 29876, 448, 313, 29885, 847, 29871, 29906, 4961, 847, 313, 1631, 334, 313, 29876, 448, 313, 29885, 847, 29871, 29906, 4961, 30004, 13, 12, 1678, 16366, 4056, 353, 29871, 29900, 29889, 29945, 29946, 448, 29871, 29900, 29889, 29946, 29953, 334, 5844, 29889, 3944, 29898, 29871, 29906, 334, 2930, 334, 302, 847, 286, 8443, 13, 12, 1678, 7688, 353, 7688, 334, 16366, 4056, 30004, 13, 12, 19499, 29901, 30004, 13, 12, 1678, 7688, 353, 29871, 29906, 334, 11791, 30004, 13, 12, 1678, 16366, 4056, 353, 29871, 29900, 29889, 29945, 29946, 448, 29871, 29900, 29889, 29946, 29953, 334, 5844, 29889, 3944, 29898, 29871, 29906, 334, 2930, 334, 302, 847, 286, 8443, 13, 12, 1678, 7688, 353, 7688, 334, 16366, 4056, 30004, 13, 12, 1678, 6756, 13, 12, 705, 5861, 29889, 4397, 29898, 7915, 8443, 13, 30004, 13, 1678, 736, 18177, 30004, 13, 30004, 13, 1753, 4175, 9026, 29924, 18494, 29898, 13801, 29892, 269, 1160, 19907, 29892, 4175, 21515, 29892, 269, 1160, 6110, 29892, 954, 1451, 29892, 848, 1125, 30004, 13, 1678, 525, 6558, 11916, 1549, 263, 4175, 29915, 30004, 13, 30004, 13, 1678, 11916, 353, 1409, 29889, 2378, 877, 29882, 742, 848, 8443, 13, 1678, 22289, 353, 5124, 30004, 13, 30004, 13, 1678, 281, 353, 679, 3738, 29934, 1621, 5072, 29907, 7297, 600, 29898, 13801, 29892, 269, 1160, 19907, 29892, 4175, 21515, 8443, 13, 30004, 13, 1678, 363, 302, 297, 3464, 29898, 2435, 29898, 29893, 511, 7431, 29898, 27736, 29897, 448, 7431, 29898, 29893, 22164, 30004, 13, 12, 5753, 353, 29871, 29900, 30004, 13, 12, 1454, 474, 297, 3464, 29898, 2435, 29898, 29893, 22164, 30004, 13, 12, 1678, 1035, 4619, 281, 29961, 29875, 29962, 334, 11916, 29961, 29876, 448, 474, 29962, 30004, 13, 12, 4572, 287, 4619, 2281, 29889, 4058, 877, 29966, 29882, 742, 938, 29898, 755, 29889, 14939, 29898, 5753, 4961, 30004, 13, 30004, 13, 1678, 736, 22289, 30004, 13, 30004, 13, 1753, 16732, 5072, 9026, 29924, 18494, 29898, 13801, 29892, 269, 1160, 19907, 29892, 269, 1160, 6110, 29892, 954, 1451, 29892, 848, 1125, 30004, 13, 1678, 525, 6572, 12119, 4175, 1819, 29892, 1205, 357, 12554, 4482, 3364, 4175, 29915, 30004, 13, 1678, 6756, 13, 1678, 263, 29900, 353, 29871, 29900, 29889, 29900, 29906, 29900, 29900, 29947, 29941, 29941, 29955, 396, 29900, 29889, 29900, 29896, 29953, 29945, 29947, 29896, 29929, 29941, 30004, 13, 1678, 263, 29896, 353, 29871, 29900, 29889, 29900, 29946, 29900, 29896, 29953, 29953, 29955, 29941, 396, 29900, 29889, 29900, 29941, 29941, 29896, 29953, 29941, 29947, 29953, 30004, 13, 1678, 263, 29906, 353, 263, 29900, 30004, 13, 1678, 289, 29896, 353, 448, 29896, 29889, 29945, 29953, 29896, 29900, 29896, 29947, 29900, 29947, 396, 29899, 29896, 29889, 29953, 29900, 29946, 29896, 29941, 29900, 29896, 29947, 30004, 13, 1678, 289, 29906, 353, 29871, 29900, 29889, 29953, 29946, 29896, 29941, 29945, 29896, 29945, 29946, 396, 29900, 29889, 29953, 29955, 29900, 29946, 29945, 29955, 29929, 29896, 30004, 13, 30004, 13, 1678, 11916, 353, 1409, 29889, 2378, 877, 29882, 742, 848, 8443, 13, 1678, 22289, 353, 848, 29961, 29900, 29901, 29906, 29962, 30004, 13, 1678, 343, 353, 518, 29900, 29892, 29871, 29900, 29892, 29871, 29900, 29962, 30004, 13, 30004, 13, 1678, 363, 302, 297, 3464, 29898, 29906, 29892, 7431, 29898, 27736, 29897, 448, 29871, 29906, 1125, 30004, 13, 12, 11249, 353, 313, 29874, 29900, 334, 11916, 29961, 29876, 29962, 718, 263, 29896, 334, 11916, 29961, 29876, 448, 29896, 29962, 718, 263, 29906, 334, 11916, 29961, 29876, 29899, 29906, 29962, 448, 30004, 13, 12, 12, 1678, 289, 29896, 334, 343, 29961, 29896, 29962, 448, 289, 29906, 334, 343, 29961, 29906, 2314, 30004, 13, 12, 29891, 29961, 29906, 29962, 353, 343, 29961, 29896, 29962, 30004, 13, 12, 29891, 29961, 29896, 29962, 353, 4559, 30004, 13, 12, 4572, 287, 4619, 2281, 29889, 4058, 877, 29966, 29882, 742, 938, 29898, 755, 29889, 14939, 29898, 11249, 4961, 30004, 13, 30004, 13, 1678, 736, 22289, 30004, 13, 30004, 13, 1753, 289, 29886, 6246, 357, 12554, 5072, 29953, 29898, 13801, 29892, 269, 1160, 19907, 29892, 269, 1160, 6110, 29892, 954, 1451, 29892, 848, 1125, 30004, 13, 1678, 263, 29900, 353, 29871, 29896, 30004, 13, 1678, 263, 29896, 353, 448, 29946, 29889, 29896, 29953, 29955, 29946, 29900, 29900, 29947, 29955, 29872, 29974, 29900, 29900, 30004, 13, 1678, 263, 29906, 353, 29871, 29929, 29889, 29945, 29953, 29955, 29896, 29945, 29929, 29896, 29947, 29872, 29974, 29900, 29900, 30004, 13, 1678, 263, 29941, 353, 448, 29896, 29889, 29945, 29906, 29955, 29955, 29955, 29941, 29955, 29946, 29872, 29974, 29900, 29896, 30004, 13, 1678, 263, 29946, 353, 29871, 29896, 29889, 29947, 29947, 29896, 29953, 29945, 29929, 29945, 29929, 29872, 29974, 29900, 29896, 30004, 13, 1678, 263, 29945, 353, 448, 29896, 29889, 29947, 29946, 29945, 29929, 29906, 29896, 29941, 29941, 29872, 29974, 29900, 29896, 30004, 13, 1678, 263, 29953, 353, 29871, 29896, 29889, 29946, 29953, 29929, 29945, 29929, 29900, 29946, 29946, 29872, 29974, 29900, 29896, 30004, 13, 1678, 263, 29955, 353, 448, 29929, 29889, 29945, 29900, 29900, 29945, 29945, 29945, 29947, 29955, 29872, 29974, 29900, 29900, 30004, 13, 1678, 263, 29947, 353, 29871, 29946, 29889, 29929, 29955, 29900, 29945, 29955, 29945, 29953, 29945, 29872, 29974, 29900, 29900, 30004, 13, 1678, 263, 29929, 353, 448, 29906, 29889, 29900, 29946, 29929, 29947, 29955, 29941, 29946, 29929, 29872, 29974, 29900, 29900, 30004, 13, 1678, 263, 29896, 29900, 353, 29871, 29953, 29889, 29946, 29906, 29955, 29955, 29945, 29955, 29955, 29946, 29872, 29899, 29900, 29896, 30004, 13, 1678, 263, 29896, 29896, 353, 448, 29896, 29889, 29941, 29947, 29945, 29929, 29896, 29945, 29941, 29900, 29872, 29899, 29900, 29896, 30004, 13, 1678, 263, 29896, 29906, 353, 29871, 29896, 29889, 29955, 29906, 29900, 29929, 29953, 29906, 29953, 29900, 29872, 29899, 29900, 29906, 30004, 13, 1678, 289, 29900, 353, 29871, 29941, 29889, 29941, 29953, 29929, 29929, 29900, 29953, 29946, 29955, 29872, 29899, 29900, 29941, 30004, 13, 1678, 289, 29896, 353, 29871, 29900, 30004, 13, 1678, 289, 29906, 353, 448, 29906, 29889, 29900, 29906, 29896, 29929, 29946, 29941, 29947, 29947, 29872, 29899, 29900, 29906, 30004, 13, 1678, 289, 29941, 353, 29871, 29900, 30004, 13, 1678, 289, 29946, 353, 29871, 29945, 29889, 29900, 29945, 29946, 29947, 29945, 29929, 29955, 29896, 29872, 29899, 29900, 29906, 30004, 13, 1678, 289, 29945, 353, 448, 29906, 29889, 29896, 29945, 29941, 29941, 29900, 29941, 29946, 29941, 29872, 29899, 29896, 29955, 30004, 13, 1678, 289, 29953, 353, 448, 29953, 29889, 29955, 29941, 29929, 29947, 29896, 29906, 29929, 29946, 29872, 29899, 29900, 29906, 30004, 13, 1678, 289, 29955, 353, 29871, 29906, 29889, 29896, 29945, 29941, 29941, 29900, 29941, 29946, 29941, 29872, 29899, 29896, 29955, 30004, 13, 1678, 289, 29947, 353, 29871, 29945, 29889, 29900, 29945, 29946, 29947, 29945, 29929, 29955, 29896, 29872, 29899, 29900, 29906, 30004, 13, 1678, 289, 29929, 353, 29871, 29900, 30004, 13, 1678, 289, 29896, 29900, 353, 448, 29906, 29889, 29900, 29906, 29896, 29929, 29946, 29941, 29947, 29947, 29872, 29899, 29900, 29906, 30004, 13, 1678, 289, 29896, 29896, 353, 29871, 29900, 30004, 13, 1678, 289, 29896, 29906, 353, 29871, 29941, 29889, 29941, 29953, 29929, 29929, 29900, 29953, 29946, 29955, 29872, 29899, 29900, 29941, 30004, 13, 30004, 13, 1678, 11916, 353, 1409, 29889, 2378, 877, 29882, 742, 848, 8443, 13, 1678, 1596, 7431, 29898, 27736, 8443, 13, 1678, 22289, 353, 848, 29961, 29900, 29901, 29896, 29906, 29962, 30004, 13, 1678, 343, 353, 518, 29900, 29892, 29871, 29900, 29892, 29871, 29900, 29892, 29871, 29900, 29892, 29871, 29900, 29892, 29871, 29900, 29892, 29871, 29900, 29892, 29871, 29900, 29892, 29871, 29900, 29892, 29871, 29900, 29892, 29871, 29900, 29892, 29871, 29900, 29892, 29871, 29900, 29962, 30004, 13, 30004, 13, 1678, 363, 302, 297, 3464, 29898, 29896, 29906, 29892, 7431, 29898, 27736, 29897, 448, 29871, 29896, 29906, 1125, 30004, 13, 12, 11249, 353, 313, 29874, 29900, 334, 11916, 29961, 29876, 29962, 718, 263, 29896, 334, 11916, 29961, 29876, 448, 29896, 29962, 718, 263, 29906, 334, 11916, 29961, 29876, 29899, 29906, 29962, 718, 263, 29941, 334, 11916, 29961, 29876, 29899, 29941, 29962, 718, 30004, 13, 12, 12, 29871, 263, 29946, 334, 11916, 29961, 29876, 29899, 29946, 29962, 718, 263, 29945, 334, 11916, 29961, 29876, 29899, 29945, 29962, 718, 263, 29953, 334, 11916, 29961, 29876, 29899, 29953, 29962, 718, 263, 29955, 334, 11916, 29961, 29876, 29899, 29955, 29962, 718, 6756, 13, 12, 12, 29871, 263, 29947, 334, 11916, 29961, 29876, 29899, 29947, 29962, 718, 263, 29929, 334, 11916, 29961, 29876, 29899, 29929, 29962, 718, 263, 29896, 29900, 334, 11916, 29961, 29876, 29899, 29896, 29900, 29962, 718, 263, 29896, 29896, 334, 11916, 29961, 29876, 29899, 29896, 29896, 29962, 718, 6756, 13, 12, 12, 29871, 263, 29896, 29906, 334, 11916, 29961, 29876, 29899, 29896, 29906, 29962, 448, 30004, 13, 12, 12, 29871, 289, 29900, 334, 343, 29961, 29900, 29962, 448, 289, 29896, 334, 343, 29961, 29896, 29962, 448, 289, 29906, 334, 343, 29961, 29906, 29962, 448, 289, 29941, 334, 343, 29961, 29941, 29962, 448, 289, 29946, 334, 343, 29961, 29946, 29962, 448, 289, 29945, 334, 343, 29961, 29945, 29962, 448, 30004, 13, 12, 12, 29871, 289, 29953, 334, 343, 29961, 29953, 29962, 448, 289, 29955, 334, 343, 29961, 29955, 29962, 448, 289, 29947, 334, 343, 29961, 29947, 29962, 448, 289, 29929, 334, 343, 29961, 29929, 29962, 448, 289, 29896, 29900, 334, 343, 29961, 29896, 29900, 29962, 448, 289, 29896, 29896, 334, 343, 29961, 29896, 29896, 29962, 448, 30004, 13, 12, 12, 29871, 289, 29896, 29906, 334, 343, 29961, 29896, 29906, 29962, 1723, 30004, 13, 12, 29891, 29961, 29896, 29906, 29962, 353, 343, 29961, 29896, 29896, 29962, 30004, 13, 12, 29891, 29961, 29896, 29896, 29962, 353, 343, 29961, 29896, 29900, 29962, 30004, 13, 12, 29891, 29961, 29896, 29900, 29962, 353, 343, 29961, 29929, 29962, 30004, 13, 12, 29891, 29961, 29929, 29962, 353, 343, 29961, 29947, 29962, 30004, 13, 12, 29891, 29961, 29947, 29962, 353, 343, 29961, 29955, 29962, 30004, 13, 12, 29891, 29961, 29955, 29962, 353, 343, 29961, 29953, 29962, 30004, 13, 12, 29891, 29961, 29953, 29962, 353, 343, 29961, 29945, 29962, 30004, 13, 12, 29891, 29961, 29945, 29962, 353, 343, 29961, 29946, 29962, 30004, 13, 12, 29891, 29961, 29946, 29962, 353, 343, 29961, 29941, 29962, 30004, 13, 12, 29891, 29961, 29941, 29962, 353, 343, 29961, 29906, 29962, 30004, 13, 12, 29891, 29961, 29906, 29962, 353, 343, 29961, 29896, 29962, 30004, 13, 12, 29891, 29961, 29896, 29962, 353, 4559, 30004, 13, 12, 4572, 287, 4619, 2281, 29889, 4058, 877, 29966, 29882, 742, 938, 29898, 755, 29889, 14939, 29898, 11249, 4961, 30004, 13, 30004, 13, 1678, 736, 22289, 30004, 13, 30004, 13, 1753, 5486, 1594, 29890, 9998, 517, 2928, 29898, 3233, 29892, 269, 1160, 6110, 1125, 30004, 13, 1678, 736, 5844, 29889, 12248, 29898, 29896, 29900, 29892, 313, 7411, 29898, 5563, 29897, 847, 29871, 29906, 29900, 876, 334, 29871, 29941, 29906, 29955, 29953, 29955, 30004, 13, 30004, 13, 1753, 5706, 15427, 9026, 11490, 650, 1469, 29898, 2962, 29888, 7971, 29892, 1095, 29888, 7971, 29892, 269, 1160, 19907, 29892, 14385, 29892, 269, 1160, 6110, 29892, 19224, 10108, 29892, 954, 1451, 1125, 30004, 13, 1678, 9995, 5631, 403, 263, 1347, 310, 7581, 848, 20917, 408, 263, 9609, 29924, 4559, 4840, 29889, 3878, 29939, 338, 297, 379, 29920, 11167, 13, 1678, 269, 1160, 19907, 338, 297, 3685, 2701, 639, 1473, 29892, 14385, 338, 297, 6923, 29892, 269, 1160, 6110, 338, 297, 9978, 29892, 6756, 13, 1678, 19224, 10108, 338, 297, 270, 29933, 9998, 29892, 322, 954, 1451, 338, 2845, 29871, 29896, 470, 29871, 29906, 1213, 15945, 30004, 13, 30004, 13, 1678, 8576, 353, 29871, 29900, 334, 2930, 30004, 13, 1678, 3233, 353, 5486, 1594, 29890, 9998, 517, 2928, 29898, 412, 557, 10108, 29892, 269, 1160, 6110, 8443, 13, 1678, 282, 4912, 29918, 1272, 353, 6629, 30004, 13, 1678, 3005, 29939, 353, 1369, 29888, 7971, 30004, 13, 1678, 24968, 353, 29871, 29900, 29889, 29945, 334, 313, 355, 29888, 7971, 448, 1369, 29888, 7971, 29897, 847, 5785, 29898, 29879, 1160, 19907, 334, 14385, 8443, 13, 1678, 28747, 29918, 2435, 353, 938, 29898, 29900, 29889, 29900, 29900, 29896, 334, 269, 1160, 19907, 29897, 334, 29871, 29900, 30004, 13, 1678, 954, 29903, 9422, 353, 938, 29898, 4513, 29898, 269, 1160, 19907, 334, 14385, 876, 30004, 13, 30004, 13, 1678, 396, 2158, 14385, 334, 269, 1160, 19907, 30004, 13, 30004, 13, 1678, 363, 474, 297, 3464, 29898, 29900, 29892, 954, 29903, 9422, 1125, 30004, 13, 12, 29888, 7971, 353, 24968, 334, 474, 718, 1369, 29888, 7971, 30004, 13, 12, 21675, 353, 29871, 29896, 29889, 29900, 30004, 13, 12, 361, 474, 529, 28747, 29918, 2435, 29901, 30004, 13, 12, 1678, 28747, 353, 29871, 29900, 29889, 29945, 334, 313, 29896, 448, 5844, 29889, 3944, 29898, 1631, 334, 474, 847, 313, 21675, 29918, 2435, 448, 29871, 29896, 4961, 30004, 13, 12, 23681, 474, 1405, 313, 1949, 29903, 9422, 448, 28747, 29918, 2435, 1125, 30004, 13, 12, 1678, 28747, 353, 29871, 29900, 29889, 29945, 334, 313, 29896, 448, 5844, 29889, 3944, 29898, 1631, 334, 313, 1949, 29903, 9422, 448, 474, 29897, 847, 313, 21675, 29918, 2435, 448, 29871, 29896, 4961, 6756, 13, 12, 1454, 521, 297, 3464, 29898, 1949, 1451, 1125, 30004, 13, 12, 1678, 4559, 353, 29871, 938, 3552, 28747, 334, 3233, 334, 5844, 29889, 5223, 29898, 30004, 13, 12, 462, 259, 313, 29888, 7971, 334, 29871, 29906, 334, 2930, 334, 474, 6802, 269, 1160, 19907, 718, 8576, 29897, 29871, 876, 30004, 13, 12, 1678, 396, 2158, 4559, 30004, 13, 12, 1678, 282, 4912, 29918, 1272, 4619, 2281, 29889, 4058, 877, 29966, 29882, 742, 4559, 8443, 13, 30004, 13, 1678, 736, 282, 4912, 29918, 1272, 30004, 13, 30004, 13, 1753, 5706, 29928, 950, 29911, 650, 9026, 29924, 1469, 29898, 29888, 7971, 29896, 29892, 3005, 29939, 29906, 29892, 269, 1160, 19907, 29892, 14385, 29892, 269, 1160, 6110, 29892, 19224, 10108, 29892, 954, 1451, 1125, 30004, 13, 1678, 9995, 5631, 403, 263, 1347, 310, 7581, 848, 20917, 408, 263, 9609, 29924, 4559, 4840, 29889, 23478, 1023, 3005, 29939, 30004, 13, 1678, 4208, 1316, 408, 297, 6655, 260, 2873, 470, 360, 23081, 29943, 15945, 19451, 13, 30004, 13, 1678, 8576, 353, 29871, 29900, 334, 2930, 30004, 13, 1678, 3233, 353, 5486, 1594, 29890, 9998, 517, 2928, 29898, 412, 557, 10108, 29892, 269, 1160, 6110, 8443, 13, 1678, 282, 4912, 29918, 1272, 353, 6629, 30004, 13, 1678, 28747, 29918, 2435, 353, 938, 29898, 29900, 29889, 29900, 29900, 29896, 334, 269, 1160, 19907, 29897, 334, 29871, 29900, 30004, 13, 1678, 954, 29903, 9422, 353, 938, 29898, 4513, 29898, 269, 1160, 19907, 334, 14385, 876, 30004, 13, 30004, 13, 1678, 396, 2158, 14385, 334, 269, 1160, 19907, 30004, 13, 30004, 13, 1678, 363, 474, 297, 3464, 29898, 29900, 29892, 954, 29903, 9422, 1125, 30004, 13, 12, 21675, 353, 29871, 29896, 29889, 29900, 30004, 13, 12, 361, 474, 529, 28747, 29918, 2435, 29901, 30004, 13, 12, 1678, 28747, 353, 29871, 29900, 29889, 29945, 334, 313, 29896, 448, 5844, 29889, 3944, 29898, 1631, 334, 474, 847, 313, 21675, 29918, 2435, 448, 29871, 29896, 4961, 30004, 13, 12, 23681, 474, 1405, 313, 1949, 29903, 9422, 448, 28747, 29918, 2435, 1125, 30004, 13, 12, 1678, 28747, 353, 29871, 29900, 29889, 29945, 334, 313, 29896, 448, 5844, 29889, 3944, 29898, 1631, 334, 313, 1949, 29903, 9422, 448, 474, 29897, 847, 313, 21675, 29918, 2435, 448, 29871, 29896, 4961, 6756, 13, 12, 1454, 521, 297, 3464, 29898, 1949, 1451, 1125, 30004, 13, 12, 1678, 4559, 353, 29871, 938, 3552, 28747, 334, 3233, 334, 313, 29900, 29889, 29945, 334, 5844, 29889, 5223, 29898, 30004, 13, 12, 462, 259, 313, 29888, 7971, 29896, 334, 29871, 29906, 334, 2930, 334, 474, 6802, 269, 1160, 19907, 718, 8576, 29897, 718, 30004, 13, 12, 12, 12, 1678, 29900, 29889, 29945, 334, 5844, 29889, 5223, 3552, 29888, 7971, 29906, 334, 29871, 29906, 334, 2930, 334, 474, 6802, 269, 1160, 19907, 718, 8576, 29897, 29871, 4961, 30004, 13, 12, 1678, 396, 2158, 4559, 30004, 13, 12, 1678, 282, 4912, 29918, 1272, 4619, 2281, 29889, 4058, 877, 29966, 29882, 742, 4559, 8443, 13, 30004, 13, 1678, 736, 282, 4912, 29918, 1272, 30004, 13, 30004, 13, 1753, 1667, 7295, 30004, 13, 1678, 1053, 10742, 30004, 13, 30004, 13, 1678, 954, 1451, 353, 29871, 29896, 30004, 13, 1678, 19224, 10108, 353, 448, 29896, 29900, 30004, 13, 1678, 269, 1160, 6110, 353, 29871, 29896, 29953, 30004, 13, 1678, 269, 1160, 19907, 353, 29871, 29946, 29946, 29896, 29900, 29900, 30004, 13, 30004, 13, 1678, 6756, 13, 1678, 934, 353, 10742, 29889, 3150, 877, 1688, 305, 381, 29886, 29889, 29893, 485, 742, 525, 6050, 1495, 30004, 13, 1678, 11916, 353, 934, 29889, 949, 19935, 29898, 934, 29889, 657, 29876, 19935, 3101, 30004, 13, 1678, 934, 29889, 5358, 26471, 13, 1678, 396, 1272, 353, 5706, 29928, 950, 29911, 650, 9026, 29924, 1469, 29898, 29947, 29945, 29941, 29892, 29871, 29929, 29953, 29900, 29892, 269, 1160, 19907, 29892, 29871, 29947, 29892, 269, 1160, 6110, 29892, 19224, 10108, 29892, 954, 1451, 8443, 13, 1678, 848, 353, 289, 29886, 6246, 357, 12554, 5072, 29953, 29898, 29900, 29892, 269, 1160, 19907, 29892, 269, 1160, 6110, 29892, 954, 1451, 29892, 11916, 8443, 13, 1678, 934, 449, 353, 10742, 29889, 3150, 29898, 525, 1688, 29889, 29893, 485, 742, 525, 29893, 29890, 1495, 30004, 13, 1678, 934, 449, 29889, 842, 7529, 29898, 313, 1949, 1451, 29892, 269, 1160, 6110, 29914, 29947, 29892, 269, 1160, 19907, 29892, 269, 1160, 19907, 29892, 525, 29940, 12413, 742, 27255, 1723, 30004, 13, 1678, 934, 449, 29889, 3539, 19935, 29898, 1272, 8443, 13, 1678, 934, 449, 29889, 5358, 26471, 13, 30004, 13, 361, 4770, 978, 1649, 1275, 376, 1649, 3396, 1649, 1115, 30004, 13, 1678, 1667, 26471, 13, 2 ]
src/AoC_2021/d12_paths_through_caves_bfs_adjacency_dict_networkx/cave_navigating_graph_with_networkx_vis.py
derailed-dash/Advent-of-Code
9
156494
<filename>src/AoC_2021/d12_paths_through_caves_bfs_adjacency_dict_networkx/cave_navigating_graph_with_networkx_vis.py<gh_stars>1-10 r""" Author: Darren Date: 12/12/2021 Solving https://adventofcode.com/2021/day/12 We need to find all the paths through a network of caves, and then determine the best path. The cave map is provided in the form of connected pairs (edges). E.g. start-A start-b start A-c / \ A-b c--A-----b--d b-d \ / A-end end b-end Caves can be connected to 0, 1 or more other caves. Lowercase is for small caves. Uppercase is for large caves. Solution 2: Still using a BFS, but using NetworkX to build the graph. This saves on having to manually create the nodes or the adjacency dictionaries. Also allows easy visualisation. Part 1: We want to find the number of distinct paths from start to end, where we can visit small caves once, but other caves any number of times. We wanted an undirected unweighted graph, and then to find number of distinct paths from start to end, only visiting small caves (lowercase) 0 or 1 times. Create an adjacency dictionary, so we can get all neighbours of any cave. Determine which are small and which are large. To find all the unique paths, do a BFS. Store (start, path) in the queue. While items in the queue: - Pop (cave, path) - If the cave is the end, we've determined a valid route, so store it and continue. - Otherwise, get all the neighbours. - If the neighbour is new or big cave, update the path and append to the queue. - If not new, then if start/end/small, then skip. Part 2: Now we want to be able to visit a single small cave twice. Update the BFS so that the queue tuple also contains an attribute for whether we've "visited_twice" for any cave. Now, if the neighbour is in the path, and the neighbour is a small cave, and we haven't yet visited twice, then we can enqueue with visited twice option. """ import logging from pathlib import Path import time from collections import deque import matplotlib.pyplot as plt import networkx as nx logging.basicConfig(format="%(asctime)s.%(msecs)03d:%(levelname)s:%(name)s:\t%(message)s", datefmt='%H:%M:%S') logger = logging.getLogger(__name__) logger.setLevel(level=logging.INFO) SCRIPT_DIR = Path(__file__).parent INPUT_FILE = "input/input.txt" # INPUT_FILE = "input/sample_input.txt" RENDER = True OUTPUT_DIR = Path(SCRIPT_DIR / "output/") OUTPUT_FILE = Path(OUTPUT_DIR / "cave_graph.png") # where we'll save the animation to class CaveGraph(): """ Stores pairs of connected caves, i.e. edges. Determines all caves from supplied edges. Determines which caves are small, and which are large. Creates a lookup to obtain all caves linked to a given cave. Finally, knows how to determine all unique paths from start to end, according to the rules given. """ START = "start" END = "end" def __init__(self, edges:set[tuple[str, str]]) -> None: """ Takes a set of edges, where each edge is in the form (a, b) """ self.start = CaveGraph.START self.end = CaveGraph.END self._graph = nx.Graph() # Internal implementation of the graph self._graph.add_edges_from(edges) # Build the graph self._small_caves: set[str] = set() self._large_caves: set[str] = set() self._categorise_caves() # populate the empty fields assert self.start in self._graph, "Start needs to be mapped" assert self.end in self._graph, "Finish needs to be mapped" def _categorise_caves(self): """ Build a set of all caves from the edges. This will also initialise small_caves and large_caves """ for edge in self.edges: for cave in edge: if cave not in (self.start, self.end): if cave.islower(): self._small_caves.add(cave) else: self._large_caves.add(cave) def render(self, file): _ = plt.subplot(121) pos = nx.spring_layout(self._graph) # set colours for each node in the array, in the same order as the nodes colours = [] for node in self.nodes: if node in (CaveGraph.START, CaveGraph.END): colours.append("green") elif node in self.large_caves: colours.append("blue") else: colours.append("red") nx.draw(self._graph, pos=pos, node_color=colours, with_labels=True) dir_path = Path(file).parent if not Path.exists(dir_path): Path.mkdir(dir_path) plt.savefig(file) @property def edges(self) -> tuple[str,str]: """ All the edges. An edge is one cave linked to another. """ return self._graph.edges @property def nodes(self): return self._graph.nodes @property def small_caves(self): """ Caves labelled lowercase. Subset of self.caves. """ return self._small_caves @property def large_caves(self): """ Caves labelled uppercase. Subset of self.caves. """ return self._large_caves def get_paths_through(self, small_cave_twice=False) -> set[tuple]: """ Get all unique paths through from start to end, using a BFS. Args: small_cave_twice (bool, optional): Whether we can visit a small cave more than once. Defaults to False. """ start = (self.start, [self.start], False) # (starting cave, [path with only start], used twice) queue = deque() queue.append(start) unique_paths: set[tuple] = set() # To store each path that goes from start to end while queue: # If we popleft(), we do a BFS. If we simply pop(), we're doing a DFS. # Since we need to discover all paths, it makes no difference to performance. cave, path, used_twice = queue.popleft() # current cave, paths visited, twice? if cave == self.end: # we've reached the end of a desired path unique_paths.add(tuple(path)) continue for neighbour in self._graph[cave]: new_path = path + [neighbour] # Need a new path object if neighbour in path: # big caves fall through and can be re-added to the path if neighbour in (self.start, self.end): continue # we can't revisit start and finish if neighbour in self.small_caves: if small_cave_twice and not used_twice: # If we've visited this small cave once before # Then add it again, but "use up" our used_twice queue.append((neighbour, new_path, True)) continue assert neighbour in self.large_caves # If we're here, it's either big caves or neighbours not in the path queue.append((neighbour, new_path, used_twice)) logger.debug(new_path) return unique_paths def main(): input_file = Path(SCRIPT_DIR, INPUT_FILE) with open(input_file, mode="rt") as f: edges = set(tuple(line.split("-")) for line in f.read().splitlines()) graph = CaveGraph(edges) # Create graph from edges supplied in input logger.debug("Nodes=%s", graph.nodes) logger.debug("Edges=%s", graph.edges) if RENDER: graph.render(OUTPUT_FILE) # Part 1 unique_paths = graph.get_paths_through() logger.info("Part 1: unique paths count=%d", len(unique_paths)) # Part 2 unique_paths = graph.get_paths_through(small_cave_twice=True) logger.info("Part 2: unique paths count=%d", len(unique_paths)) if __name__ == "__main__": t1 = time.perf_counter() main() t2 = time.perf_counter() logger.info("Execution time: %0.4f seconds", t2 - t1)
[ 1, 529, 9507, 29958, 4351, 29914, 29909, 29877, 29907, 29918, 29906, 29900, 29906, 29896, 29914, 29881, 29896, 29906, 29918, 24772, 29918, 20678, 29918, 29883, 5989, 29918, 1635, 29879, 29918, 26859, 562, 3819, 29918, 8977, 29918, 11618, 29916, 29914, 1113, 345, 29918, 29876, 3723, 1218, 29918, 4262, 29918, 2541, 29918, 11618, 29916, 29918, 1730, 29889, 2272, 29966, 12443, 29918, 303, 1503, 29958, 29896, 29899, 29896, 29900, 13, 29878, 15945, 29908, 13, 13720, 29901, 7335, 1267, 13, 2539, 29901, 29871, 29896, 29906, 29914, 29896, 29906, 29914, 29906, 29900, 29906, 29896, 13, 13, 13296, 1747, 2045, 597, 328, 794, 974, 401, 29889, 510, 29914, 29906, 29900, 29906, 29896, 29914, 3250, 29914, 29896, 29906, 13, 13, 4806, 817, 304, 1284, 599, 278, 10898, 1549, 263, 3564, 310, 274, 5989, 29892, 13, 392, 769, 8161, 278, 1900, 2224, 29889, 13, 1576, 24230, 2910, 338, 4944, 297, 278, 883, 310, 6631, 11000, 313, 287, 2710, 467, 382, 29889, 29887, 29889, 13, 2962, 29899, 29909, 13, 2962, 29899, 29890, 462, 268, 1369, 13, 29909, 29899, 29883, 462, 308, 847, 259, 320, 13, 29909, 29899, 29890, 462, 268, 274, 489, 29909, 23648, 29890, 489, 29881, 13, 29890, 29899, 29881, 462, 308, 320, 259, 847, 13, 29909, 29899, 355, 462, 4706, 1095, 13, 29890, 29899, 355, 13, 13, 29907, 5989, 508, 367, 6631, 304, 29871, 29900, 29892, 29871, 29896, 470, 901, 916, 274, 5989, 29889, 13, 19357, 4878, 338, 363, 2319, 274, 5989, 29889, 24929, 4878, 338, 363, 2919, 274, 5989, 29889, 13, 13, 13296, 918, 29871, 29906, 29901, 13, 1678, 12074, 773, 263, 350, 9998, 29892, 541, 773, 8527, 29990, 304, 2048, 278, 3983, 29889, 13, 1678, 910, 27401, 373, 2534, 304, 7522, 1653, 278, 7573, 470, 278, 12109, 562, 3819, 21503, 4314, 29889, 13, 1678, 3115, 6511, 4780, 7604, 4371, 29889, 13, 13, 7439, 29871, 29896, 29901, 13, 1678, 1334, 864, 304, 1284, 278, 1353, 310, 8359, 10898, 515, 1369, 304, 1095, 29892, 13, 1678, 988, 591, 508, 6493, 2319, 274, 5989, 2748, 29892, 541, 916, 274, 5989, 738, 1353, 310, 3064, 29889, 13, 268, 13, 1678, 1334, 5131, 385, 563, 1088, 287, 443, 7915, 287, 3983, 29892, 29871, 13, 1678, 322, 769, 304, 1284, 1353, 310, 8359, 10898, 515, 1369, 304, 1095, 29892, 13, 1678, 871, 6493, 292, 2319, 274, 5989, 313, 13609, 4878, 29897, 29871, 29900, 470, 29871, 29896, 3064, 29889, 13, 268, 13, 1678, 6204, 385, 12109, 562, 3819, 8600, 29892, 577, 591, 508, 679, 599, 22092, 2470, 310, 738, 24230, 29889, 13, 1678, 5953, 837, 457, 607, 526, 2319, 322, 607, 526, 2919, 29889, 13, 268, 13, 1678, 1763, 1284, 599, 278, 5412, 10898, 29892, 437, 263, 350, 9998, 29889, 13, 1678, 14491, 313, 2962, 29892, 2224, 29897, 297, 278, 9521, 29889, 13, 1678, 5806, 4452, 297, 278, 9521, 29901, 13, 1678, 448, 6977, 313, 1113, 345, 29892, 2224, 29897, 13, 1678, 448, 960, 278, 24230, 338, 278, 1095, 29892, 591, 29915, 345, 10087, 263, 2854, 5782, 29892, 577, 3787, 372, 322, 6773, 29889, 13, 1678, 448, 13466, 29892, 679, 599, 278, 22092, 2470, 29889, 13, 1678, 448, 960, 278, 17647, 338, 716, 470, 4802, 24230, 29892, 2767, 278, 2224, 322, 9773, 304, 278, 9521, 29889, 13, 1678, 448, 960, 451, 716, 29892, 769, 565, 1369, 29914, 355, 29914, 9278, 29892, 769, 14383, 29889, 13, 13, 7439, 29871, 29906, 29901, 13, 1678, 2567, 591, 864, 304, 367, 2221, 304, 6493, 263, 2323, 2319, 24230, 8951, 29889, 13, 268, 13, 1678, 10318, 278, 350, 9998, 577, 393, 278, 9521, 18761, 884, 3743, 385, 5352, 13, 1678, 363, 3692, 591, 29915, 345, 376, 1730, 1573, 29918, 7516, 625, 29908, 363, 738, 24230, 29889, 13, 1678, 2567, 29892, 565, 278, 17647, 338, 297, 278, 2224, 29892, 322, 278, 17647, 338, 263, 2319, 24230, 29892, 13, 1678, 322, 591, 7359, 29915, 29873, 3447, 16669, 8951, 29892, 769, 591, 508, 427, 9990, 411, 16669, 8951, 2984, 29889, 13, 15945, 29908, 13, 5215, 12183, 13, 3166, 2224, 1982, 1053, 10802, 13, 5215, 931, 13, 3166, 16250, 1053, 316, 802, 13, 5215, 22889, 29889, 2272, 5317, 408, 14770, 13, 5215, 3564, 29916, 408, 302, 29916, 13, 13, 21027, 29889, 16121, 3991, 29898, 4830, 543, 29995, 29898, 294, 312, 603, 29897, 29879, 29889, 29995, 29898, 29885, 344, 2395, 29897, 29900, 29941, 29881, 16664, 29898, 5563, 978, 29897, 29879, 16664, 29898, 978, 29897, 29879, 3583, 29873, 29995, 29898, 4906, 29897, 29879, 613, 29871, 13, 462, 1678, 2635, 23479, 2433, 29995, 29950, 16664, 29924, 16664, 29903, 1495, 13, 21707, 353, 12183, 29889, 657, 16363, 22168, 978, 1649, 29897, 13, 21707, 29889, 842, 10108, 29898, 5563, 29922, 21027, 29889, 11690, 29897, 13, 13, 7187, 24290, 29918, 9464, 353, 10802, 22168, 1445, 1649, 467, 3560, 13, 1177, 12336, 29918, 7724, 353, 376, 2080, 29914, 2080, 29889, 3945, 29908, 13, 29937, 2672, 12336, 29918, 7724, 353, 376, 2080, 29914, 11249, 29918, 2080, 29889, 3945, 29908, 13, 13, 29934, 1430, 8032, 353, 5852, 13, 12015, 12336, 29918, 9464, 353, 10802, 29898, 7187, 24290, 29918, 9464, 847, 376, 4905, 29914, 1159, 13, 12015, 12336, 29918, 7724, 353, 10802, 29898, 12015, 12336, 29918, 9464, 847, 376, 1113, 345, 29918, 4262, 29889, 2732, 1159, 29871, 396, 988, 591, 29915, 645, 4078, 278, 9612, 304, 13, 13, 1990, 315, 1351, 9527, 7295, 13, 1678, 9995, 624, 2361, 11000, 310, 6631, 274, 5989, 29892, 474, 29889, 29872, 29889, 12770, 29889, 29871, 13, 1678, 5953, 837, 1475, 599, 274, 5989, 515, 19056, 12770, 29889, 29871, 13, 1678, 5953, 837, 1475, 607, 274, 5989, 526, 2319, 29892, 322, 607, 526, 2919, 29889, 29871, 13, 1678, 6760, 1078, 263, 16280, 304, 4017, 599, 274, 5989, 9024, 304, 263, 2183, 24230, 29889, 29871, 13, 1678, 9788, 29892, 9906, 920, 304, 8161, 599, 5412, 10898, 515, 1369, 304, 1095, 29892, 29871, 13, 1678, 5034, 304, 278, 6865, 2183, 29889, 9995, 13, 268, 13, 1678, 6850, 8322, 353, 376, 2962, 29908, 13, 1678, 11056, 353, 376, 355, 29908, 13, 268, 13, 1678, 822, 4770, 2344, 12035, 1311, 29892, 12770, 29901, 842, 29961, 23583, 29961, 710, 29892, 851, 24960, 1599, 6213, 29901, 13, 4706, 9995, 323, 6926, 263, 731, 310, 12770, 29892, 988, 1269, 7636, 338, 297, 278, 883, 313, 29874, 29892, 289, 29897, 9995, 13, 4706, 1583, 29889, 2962, 353, 315, 1351, 9527, 29889, 25826, 13, 4706, 1583, 29889, 355, 353, 315, 1351, 9527, 29889, 11794, 13, 308, 13, 4706, 1583, 3032, 4262, 353, 302, 29916, 29889, 9527, 580, 1678, 396, 512, 1890, 5314, 310, 278, 3983, 13, 4706, 1583, 3032, 4262, 29889, 1202, 29918, 287, 2710, 29918, 3166, 29898, 287, 2710, 29897, 259, 396, 8878, 278, 3983, 13, 308, 13, 4706, 1583, 3032, 9278, 29918, 29883, 5989, 29901, 731, 29961, 710, 29962, 353, 731, 580, 13, 4706, 1583, 3032, 16961, 29918, 29883, 5989, 29901, 731, 29961, 710, 29962, 353, 731, 580, 13, 4706, 1583, 3032, 29883, 20440, 895, 29918, 29883, 5989, 580, 29871, 396, 19450, 278, 4069, 4235, 13, 632, 13, 4706, 4974, 1583, 29889, 2962, 297, 1583, 3032, 4262, 29892, 376, 4763, 4225, 304, 367, 20545, 29908, 13, 4706, 4974, 1583, 29889, 355, 297, 1583, 3032, 4262, 29892, 376, 12881, 728, 4225, 304, 367, 20545, 29908, 13, 13, 1678, 822, 903, 29883, 20440, 895, 29918, 29883, 5989, 29898, 1311, 1125, 13, 4706, 9995, 8878, 263, 731, 310, 599, 274, 5989, 515, 278, 12770, 29889, 13, 4706, 910, 674, 884, 2847, 895, 2319, 29918, 29883, 5989, 322, 2919, 29918, 29883, 5989, 9995, 13, 308, 13, 4706, 363, 7636, 297, 1583, 29889, 287, 2710, 29901, 13, 9651, 363, 24230, 297, 7636, 29901, 13, 18884, 565, 24230, 451, 297, 313, 1311, 29889, 2962, 29892, 1583, 29889, 355, 1125, 13, 462, 1678, 565, 24230, 29889, 275, 13609, 7295, 13, 462, 4706, 1583, 3032, 9278, 29918, 29883, 5989, 29889, 1202, 29898, 1113, 345, 29897, 13, 462, 1678, 1683, 29901, 29871, 13, 462, 4706, 1583, 3032, 16961, 29918, 29883, 5989, 29889, 1202, 29898, 1113, 345, 29897, 13, 268, 13, 1678, 822, 4050, 29898, 1311, 29892, 934, 1125, 13, 4706, 903, 353, 14770, 29889, 1491, 5317, 29898, 29896, 29906, 29896, 29897, 13, 4706, 926, 353, 302, 29916, 29889, 4278, 29918, 2680, 29898, 1311, 3032, 4262, 29897, 13, 308, 13, 4706, 396, 731, 28061, 363, 1269, 2943, 297, 278, 1409, 29892, 297, 278, 1021, 1797, 408, 278, 7573, 13, 4706, 28061, 353, 5159, 13, 4706, 363, 2943, 297, 1583, 29889, 18010, 29901, 13, 9651, 565, 2943, 297, 313, 29907, 1351, 9527, 29889, 25826, 29892, 315, 1351, 9527, 29889, 11794, 1125, 13, 18884, 28061, 29889, 4397, 703, 12692, 1159, 13, 9651, 25342, 2943, 297, 1583, 29889, 16961, 29918, 29883, 5989, 29901, 13, 18884, 28061, 29889, 4397, 703, 9539, 1159, 13, 9651, 1683, 29901, 13, 18884, 28061, 29889, 4397, 703, 1127, 1159, 13, 308, 13, 4706, 302, 29916, 29889, 4012, 29898, 1311, 3032, 4262, 29892, 926, 29922, 1066, 29892, 2943, 29918, 2780, 29922, 1054, 2470, 29892, 411, 29918, 21134, 29922, 5574, 29897, 13, 308, 13, 4706, 4516, 29918, 2084, 353, 10802, 29898, 1445, 467, 3560, 13, 4706, 565, 451, 10802, 29889, 9933, 29898, 3972, 29918, 2084, 1125, 13, 9651, 10802, 29889, 11256, 3972, 29898, 3972, 29918, 2084, 29897, 13, 4706, 14770, 29889, 7620, 1003, 29898, 1445, 29897, 13, 462, 29871, 13, 1678, 732, 6799, 13, 1678, 822, 12770, 29898, 1311, 29897, 1599, 18761, 29961, 710, 29892, 710, 5387, 13, 4706, 9995, 2178, 278, 12770, 29889, 29871, 530, 7636, 338, 697, 24230, 9024, 304, 1790, 29889, 9995, 13, 4706, 736, 1583, 3032, 4262, 29889, 287, 2710, 13, 268, 13, 1678, 732, 6799, 13, 1678, 822, 7573, 29898, 1311, 1125, 13, 4706, 736, 1583, 3032, 4262, 29889, 18010, 13, 13, 1678, 732, 6799, 13, 1678, 822, 2319, 29918, 29883, 5989, 29898, 1311, 1125, 13, 4706, 9995, 315, 5989, 3858, 839, 5224, 4878, 29889, 3323, 842, 310, 1583, 29889, 29883, 5989, 29889, 9995, 13, 4706, 736, 1583, 3032, 9278, 29918, 29883, 5989, 268, 13, 13, 1678, 732, 6799, 13, 1678, 822, 2919, 29918, 29883, 5989, 29898, 1311, 1125, 13, 4706, 9995, 315, 5989, 3858, 839, 7568, 4878, 29889, 3323, 842, 310, 1583, 29889, 29883, 5989, 29889, 9995, 308, 13, 4706, 736, 1583, 3032, 16961, 29918, 29883, 5989, 13, 462, 268, 13, 1678, 822, 679, 29918, 24772, 29918, 20678, 29898, 1311, 29892, 2319, 29918, 1113, 345, 29918, 7516, 625, 29922, 8824, 29897, 1599, 731, 29961, 23583, 5387, 13, 4706, 9995, 3617, 599, 5412, 10898, 1549, 515, 1369, 304, 1095, 29892, 773, 263, 350, 9998, 29889, 13, 13, 4706, 826, 3174, 29901, 13, 9651, 2319, 29918, 1113, 345, 29918, 7516, 625, 313, 11227, 29892, 13136, 1125, 26460, 591, 508, 29871, 13, 462, 1678, 6493, 263, 2319, 24230, 901, 1135, 2748, 29889, 13109, 29879, 304, 7700, 29889, 13, 4706, 9995, 13, 4706, 1369, 353, 313, 1311, 29889, 2962, 29892, 518, 1311, 29889, 2962, 1402, 7700, 29897, 29871, 396, 313, 2962, 292, 24230, 29892, 518, 2084, 411, 871, 1369, 1402, 1304, 8951, 29897, 13, 4706, 9521, 353, 316, 802, 580, 13, 4706, 9521, 29889, 4397, 29898, 2962, 29897, 259, 13, 13, 4706, 5412, 29918, 24772, 29901, 731, 29961, 23583, 29962, 353, 731, 580, 1678, 396, 1763, 3787, 1269, 2224, 393, 5771, 515, 1369, 304, 1095, 13, 308, 13, 4706, 1550, 9521, 29901, 13, 9651, 396, 960, 591, 1835, 1563, 3285, 591, 437, 263, 350, 9998, 29889, 29871, 960, 591, 3763, 1835, 3285, 591, 29915, 276, 2599, 263, 360, 9998, 29889, 13, 9651, 396, 4001, 591, 817, 304, 6523, 599, 10898, 29892, 372, 3732, 694, 4328, 304, 4180, 29889, 13, 9651, 24230, 29892, 2224, 29892, 1304, 29918, 7516, 625, 353, 9521, 29889, 7323, 1563, 580, 1678, 396, 1857, 24230, 29892, 10898, 16669, 29892, 8951, 29973, 13, 632, 13, 9651, 565, 24230, 1275, 1583, 29889, 355, 29901, 1678, 396, 591, 29915, 345, 7450, 278, 1095, 310, 263, 7429, 2224, 13, 18884, 5412, 29918, 24772, 29889, 1202, 29898, 23583, 29898, 2084, 876, 13, 18884, 6773, 13, 632, 13, 9651, 363, 17647, 297, 1583, 3032, 4262, 29961, 1113, 345, 5387, 13, 18884, 716, 29918, 2084, 353, 2224, 718, 518, 484, 1141, 6526, 29962, 259, 396, 20768, 263, 716, 2224, 1203, 13, 18884, 565, 17647, 297, 2224, 29901, 13, 462, 1678, 396, 4802, 274, 5989, 6416, 1549, 322, 508, 367, 337, 29899, 23959, 304, 278, 2224, 13, 462, 268, 13, 462, 1678, 565, 17647, 297, 313, 1311, 29889, 2962, 29892, 1583, 29889, 355, 1125, 13, 462, 4706, 6773, 396, 591, 508, 29915, 29873, 23484, 277, 1369, 322, 8341, 13, 462, 268, 13, 462, 1678, 565, 17647, 297, 1583, 29889, 9278, 29918, 29883, 5989, 29901, 13, 462, 4706, 565, 2319, 29918, 1113, 345, 29918, 7516, 625, 322, 451, 1304, 29918, 7516, 625, 29901, 13, 462, 9651, 396, 960, 591, 29915, 345, 16669, 445, 2319, 24230, 2748, 1434, 13, 462, 9651, 396, 1987, 788, 372, 1449, 29892, 541, 376, 1509, 701, 29908, 1749, 1304, 29918, 7516, 625, 13, 462, 9651, 9521, 29889, 4397, 3552, 484, 1141, 6526, 29892, 716, 29918, 2084, 29892, 5852, 876, 13, 462, 4706, 6773, 13, 462, 13, 462, 1678, 4974, 17647, 297, 1583, 29889, 16961, 29918, 29883, 5989, 13, 462, 268, 13, 18884, 396, 960, 591, 29915, 276, 1244, 29892, 372, 29915, 29879, 2845, 4802, 274, 5989, 470, 22092, 2470, 451, 297, 278, 2224, 13, 18884, 9521, 29889, 4397, 3552, 484, 1141, 6526, 29892, 716, 29918, 2084, 29892, 1304, 29918, 7516, 625, 876, 13, 18884, 17927, 29889, 8382, 29898, 1482, 29918, 2084, 29897, 13, 462, 13, 4706, 736, 5412, 29918, 24772, 13, 13, 1753, 1667, 7295, 13, 1678, 1881, 29918, 1445, 353, 10802, 29898, 7187, 24290, 29918, 9464, 29892, 2672, 12336, 29918, 7724, 29897, 13, 1678, 411, 1722, 29898, 2080, 29918, 1445, 29892, 4464, 543, 2273, 1159, 408, 285, 29901, 13, 4706, 12770, 353, 731, 29898, 23583, 29898, 1220, 29889, 5451, 703, 29899, 5783, 363, 1196, 297, 285, 29889, 949, 2141, 5451, 9012, 3101, 13, 308, 13, 1678, 3983, 353, 315, 1351, 9527, 29898, 287, 2710, 29897, 1678, 396, 6204, 3983, 515, 12770, 19056, 297, 1881, 13, 13, 1678, 17927, 29889, 8382, 703, 20284, 16328, 29879, 613, 3983, 29889, 18010, 29897, 13, 1678, 17927, 29889, 8382, 703, 3853, 2710, 16328, 29879, 613, 3983, 29889, 287, 2710, 29897, 13, 268, 13, 1678, 565, 390, 1430, 8032, 29901, 13, 4706, 3983, 29889, 9482, 29898, 12015, 12336, 29918, 7724, 29897, 13, 268, 13, 1678, 396, 3455, 29871, 29896, 13, 1678, 5412, 29918, 24772, 353, 3983, 29889, 657, 29918, 24772, 29918, 20678, 580, 13, 1678, 17927, 29889, 3888, 703, 7439, 29871, 29896, 29901, 5412, 10898, 2302, 16328, 29881, 613, 7431, 29898, 13092, 29918, 24772, 876, 13, 268, 13, 1678, 396, 3455, 29871, 29906, 13, 1678, 5412, 29918, 24772, 353, 3983, 29889, 657, 29918, 24772, 29918, 20678, 29898, 9278, 29918, 1113, 345, 29918, 7516, 625, 29922, 5574, 29897, 13, 1678, 17927, 29889, 3888, 703, 7439, 29871, 29906, 29901, 5412, 10898, 2302, 16328, 29881, 613, 7431, 29898, 13092, 29918, 24772, 876, 13, 4706, 13, 361, 4770, 978, 1649, 1275, 376, 1649, 3396, 1649, 1115, 13, 1678, 260, 29896, 353, 931, 29889, 546, 29888, 29918, 11808, 580, 13, 1678, 1667, 580, 13, 1678, 260, 29906, 353, 931, 29889, 546, 29888, 29918, 11808, 580, 13, 1678, 17927, 29889, 3888, 703, 20418, 931, 29901, 1273, 29900, 29889, 29946, 29888, 6923, 613, 260, 29906, 448, 260, 29896, 29897, 13, 2 ]
dustbin/py2app/.eggs/py2app-0.12-py2.7.egg/py2app/script_py2applet.py
orangeYao/twiOpinion
0
137678
""" Create an applet from a Python script. You can drag in packages, Info.plist files, icons, etc. It's expected that only one Python script is dragged in. """ from __future__ import print_function import os, sys from distutils.core import setup from plistlib import Plist import py2app import tempfile import shutil import imp import pprint from py2app.util import copy_tree from py2app import build_app try: set except NameError: from sets import Set as set if sys.version_info[0] == 3: raw_input = input HELP_TEXT = """ usage: py2applet --make-setup [options...] script.py [data files...] or: py2applet [options...] script.py [data files...] or: py2applet --help """ SETUP_TEMPLATE = '''""" This is a setup.py script generated by py2applet Usage: python setup.py py2app """ from setuptools import setup APP = %s DATA_FILES = %s OPTIONS = %s setup( app=APP, data_files=DATA_FILES, options={'py2app': OPTIONS}, setup_requires=['py2app'], ) ''' def get_option_map(): optmap = {} for option in build_app.py2app.user_options: opt_long, opt_short = option[:2] if opt_short: optmap['-' + opt_short] = opt_long.rstrip('=') return optmap def get_cmd_options(): options = set() for option in build_app.py2app.user_options: opt_long, opt_short = option[:2] if opt_long.endswith('=') and opt_short: options.add('-' + opt_short) return options def main(): if not sys.argv[1:]: print(HELP_TEXT) return scripts = [] data_files = [] packages = [] args = [] plist = {} iconfile = None parsing_options = True next_is_option = False cmd_options = get_cmd_options() is_make_setup = False for fn in sys.argv[1:]: if parsing_options: if next_is_option: args.append(fn) next_is_option = False continue elif fn == '--make-setup': is_make_setup = True continue elif fn.startswith('-'): args.append(fn) if fn in cmd_options: next_is_option = True continue parsing_options = False if not is_make_setup: fn = os.path.abspath(fn) if fn.endswith('.py'): if scripts: data_files.append(fn) else: scripts.append(fn) elif os.path.basename(fn) == 'Info.plist': plist = Plist.fromFile(fn) elif fn.endswith('.icns') and not iconfile: iconfile = os.path.abspath(fn) elif os.path.isdir(fn): sys.path.insert(0, [os.path.dirname(fn)]) try: path = imp.find_module(os.path.basename(fn))[0] except ImportError: path = '' del sys.path[0] if os.path.realpath(path) == os.path.realpath(fn): packages.append(os.path.basename(fn)) else: data_files.append(fn) else: data_files.append(fn) options = dict( packages=packages, plist=plist, iconfile=iconfile, ) for k,v in list(options.items()): if not v: del options[k] if is_make_setup: make_setup(args, scripts, data_files, options) else: build(args, scripts, data_files, options) def make_setup(args, scripts, data_files, options): optmap = get_option_map() cmd_options = get_cmd_options() while args: cmd = args.pop(0) if cmd in cmd_options: cmd = optmap[cmd] options[cmd.replace('-', '_')] = args.pop(0) elif '=' in cmd: cmd, val = cmd.split('=', 1) options[cmd.lstrip('-').replace('-', '_')] = val else: cmd = optmap.get(cmd, cmd) options[cmd.lstrip('-').replace('-', '_')] = True if os.path.exists('setup.py'): res = '' while res.lower() not in ('y', 'n'): res = raw_input('Existing setup.py detected, replace? [Y/n] ') if not res: break if res == 'n': print('aborted!') return f = open('setup.py', 'w') tvars = tuple(map(pprint.pformat, (scripts, data_files, options))) f.write(SETUP_TEMPLATE % tvars) f.flush() f.close() print('Wrote setup.py') def build(args, scripts, data_files, options): old_argv = sys.argv sys.argv = [sys.argv[0], 'py2app'] + args old_path = sys.path path_insert = set() for script in scripts: path_insert.add(os.path.dirname(script)) sys.path = list(path_insert) + old_path old_dir = os.getcwd() tempdir = tempfile.mkdtemp() os.chdir(tempdir) try: d = setup( app=scripts, data_files=data_files, options={'py2app': options}, ) for target in d.app: copy_tree( target.appdir, os.path.join( os.path.dirname(target.script), os.path.basename(target.appdir), ), preserve_symlinks=True, ) finally: os.chdir(old_dir) shutil.rmtree(tempdir, ignore_errors=True) sys.argv = old_argv sys.path = old_path if __name__ == '__main__': main()
[ 1, 9995, 13, 4391, 385, 623, 1026, 515, 263, 5132, 2471, 29889, 13, 13, 3492, 508, 8338, 297, 9741, 29892, 22140, 29889, 572, 391, 2066, 29892, 27673, 29892, 2992, 29889, 13, 13, 3112, 29915, 29879, 3806, 393, 871, 697, 5132, 2471, 338, 8338, 3192, 297, 29889, 13, 15945, 29908, 13, 3166, 4770, 29888, 9130, 1649, 1053, 1596, 29918, 2220, 13, 13, 5215, 2897, 29892, 10876, 13, 3166, 1320, 13239, 29889, 3221, 1053, 6230, 13, 3166, 715, 391, 1982, 1053, 349, 1761, 13, 5215, 11451, 29906, 932, 13, 5215, 5694, 1445, 13, 5215, 528, 4422, 13, 5215, 2411, 13, 5215, 282, 2158, 13, 3166, 11451, 29906, 932, 29889, 4422, 1053, 3509, 29918, 8336, 13, 3166, 11451, 29906, 932, 1053, 2048, 29918, 932, 13, 2202, 29901, 13, 1678, 731, 13, 19499, 4408, 2392, 29901, 13, 1678, 515, 6166, 1053, 3789, 408, 731, 13, 13, 361, 10876, 29889, 3259, 29918, 3888, 29961, 29900, 29962, 1275, 29871, 29941, 29901, 13, 1678, 10650, 29918, 2080, 353, 1881, 13, 13, 29950, 6670, 29925, 29918, 16975, 353, 9995, 13, 21125, 29901, 11451, 29906, 932, 1026, 1192, 5675, 29899, 14669, 518, 6768, 17361, 2471, 29889, 2272, 518, 1272, 2066, 17361, 13, 259, 470, 29901, 11451, 29906, 932, 1026, 518, 6768, 17361, 2471, 29889, 2272, 518, 1272, 2066, 17361, 13, 259, 470, 29901, 11451, 29906, 932, 1026, 1192, 8477, 13, 15945, 29908, 13, 13, 10490, 4897, 29918, 4330, 3580, 29931, 3040, 353, 14550, 15945, 29908, 13, 4013, 338, 263, 6230, 29889, 2272, 2471, 5759, 491, 11451, 29906, 932, 1026, 13, 13, 27573, 29901, 13, 1678, 3017, 6230, 29889, 2272, 11451, 29906, 932, 13, 15945, 29908, 13, 13, 3166, 731, 21245, 8789, 1053, 6230, 13, 13, 20576, 353, 1273, 29879, 13, 14573, 29918, 24483, 353, 1273, 29879, 13, 14094, 27946, 353, 1273, 29879, 13, 13, 14669, 29898, 13, 1678, 623, 29922, 20576, 29892, 13, 1678, 848, 29918, 5325, 29922, 14573, 29918, 24483, 29892, 13, 1678, 3987, 3790, 29915, 2272, 29906, 932, 2396, 6418, 29911, 27946, 1118, 13, 1678, 6230, 29918, 276, 339, 2658, 29922, 1839, 2272, 29906, 932, 7464, 13, 29897, 13, 12008, 13, 13, 1753, 679, 29918, 3385, 29918, 1958, 7295, 13, 1678, 3523, 1958, 353, 6571, 13, 1678, 363, 2984, 297, 2048, 29918, 932, 29889, 2272, 29906, 932, 29889, 1792, 29918, 6768, 29901, 13, 4706, 3523, 29918, 5426, 29892, 3523, 29918, 12759, 353, 2984, 7503, 29906, 29962, 13, 4706, 565, 3523, 29918, 12759, 29901, 13, 9651, 3523, 1958, 1839, 29899, 29915, 718, 3523, 29918, 12759, 29962, 353, 3523, 29918, 5426, 29889, 29878, 17010, 877, 29922, 1495, 13, 1678, 736, 3523, 1958, 13, 13, 1753, 679, 29918, 9006, 29918, 6768, 7295, 13, 1678, 3987, 353, 731, 580, 13, 1678, 363, 2984, 297, 2048, 29918, 932, 29889, 2272, 29906, 932, 29889, 1792, 29918, 6768, 29901, 13, 4706, 3523, 29918, 5426, 29892, 3523, 29918, 12759, 353, 2984, 7503, 29906, 29962, 13, 4706, 565, 3523, 29918, 5426, 29889, 1975, 2541, 877, 29922, 1495, 322, 3523, 29918, 12759, 29901, 13, 9651, 3987, 29889, 1202, 877, 29899, 29915, 718, 3523, 29918, 12759, 29897, 13, 1678, 736, 3987, 13, 13, 1753, 1667, 7295, 13, 1678, 565, 451, 10876, 29889, 19218, 29961, 29896, 29901, 5387, 13, 4706, 1596, 29898, 29950, 6670, 29925, 29918, 16975, 29897, 13, 4706, 736, 13, 13, 1678, 12078, 353, 5159, 13, 1678, 848, 29918, 5325, 353, 5159, 13, 1678, 9741, 353, 5159, 13, 1678, 6389, 353, 5159, 13, 1678, 715, 391, 353, 6571, 13, 1678, 9849, 1445, 353, 6213, 13, 1678, 13755, 29918, 6768, 353, 5852, 13, 1678, 2446, 29918, 275, 29918, 3385, 353, 7700, 13, 1678, 9920, 29918, 6768, 353, 679, 29918, 9006, 29918, 6768, 580, 13, 1678, 338, 29918, 5675, 29918, 14669, 353, 7700, 13, 1678, 363, 7876, 297, 10876, 29889, 19218, 29961, 29896, 29901, 5387, 13, 4706, 565, 13755, 29918, 6768, 29901, 13, 9651, 565, 2446, 29918, 275, 29918, 3385, 29901, 13, 18884, 6389, 29889, 4397, 29898, 9144, 29897, 13, 18884, 2446, 29918, 275, 29918, 3385, 353, 7700, 13, 18884, 6773, 13, 9651, 25342, 7876, 1275, 525, 489, 5675, 29899, 14669, 2396, 13, 18884, 338, 29918, 5675, 29918, 14669, 353, 5852, 13, 18884, 6773, 13, 9651, 25342, 7876, 29889, 27382, 2541, 877, 29899, 29374, 13, 18884, 6389, 29889, 4397, 29898, 9144, 29897, 13, 18884, 565, 7876, 297, 9920, 29918, 6768, 29901, 13, 462, 1678, 2446, 29918, 275, 29918, 3385, 353, 5852, 13, 18884, 6773, 13, 9651, 13755, 29918, 6768, 353, 7700, 13, 4706, 565, 451, 338, 29918, 5675, 29918, 14669, 29901, 13, 9651, 7876, 353, 2897, 29889, 2084, 29889, 370, 1028, 493, 29898, 9144, 29897, 13, 4706, 565, 7876, 29889, 1975, 2541, 12839, 2272, 29374, 13, 9651, 565, 12078, 29901, 13, 18884, 848, 29918, 5325, 29889, 4397, 29898, 9144, 29897, 13, 9651, 1683, 29901, 13, 18884, 12078, 29889, 4397, 29898, 9144, 29897, 13, 4706, 25342, 2897, 29889, 2084, 29889, 6500, 3871, 29898, 9144, 29897, 1275, 525, 3401, 29889, 572, 391, 2396, 13, 9651, 715, 391, 353, 349, 1761, 29889, 3166, 2283, 29898, 9144, 29897, 13, 4706, 25342, 7876, 29889, 1975, 2541, 12839, 293, 1983, 1495, 322, 451, 9849, 1445, 29901, 13, 9651, 9849, 1445, 353, 2897, 29889, 2084, 29889, 370, 1028, 493, 29898, 9144, 29897, 13, 4706, 25342, 2897, 29889, 2084, 29889, 275, 3972, 29898, 9144, 1125, 13, 9651, 10876, 29889, 2084, 29889, 7851, 29898, 29900, 29892, 518, 359, 29889, 2084, 29889, 25721, 29898, 9144, 29897, 2314, 13, 9651, 1018, 29901, 13, 18884, 2224, 353, 2411, 29889, 2886, 29918, 5453, 29898, 359, 29889, 2084, 29889, 6500, 3871, 29898, 9144, 876, 29961, 29900, 29962, 13, 9651, 5174, 16032, 2392, 29901, 13, 18884, 2224, 353, 6629, 13, 9651, 628, 10876, 29889, 2084, 29961, 29900, 29962, 13, 9651, 565, 2897, 29889, 2084, 29889, 6370, 2084, 29898, 2084, 29897, 1275, 2897, 29889, 2084, 29889, 6370, 2084, 29898, 9144, 1125, 13, 18884, 9741, 29889, 4397, 29898, 359, 29889, 2084, 29889, 6500, 3871, 29898, 9144, 876, 13, 9651, 1683, 29901, 13, 18884, 848, 29918, 5325, 29889, 4397, 29898, 9144, 29897, 13, 4706, 1683, 29901, 13, 9651, 848, 29918, 5325, 29889, 4397, 29898, 9144, 29897, 13, 13, 1678, 3987, 353, 9657, 29898, 13, 4706, 9741, 29922, 8318, 29892, 13, 4706, 715, 391, 29922, 572, 391, 29892, 13, 4706, 9849, 1445, 29922, 4144, 1445, 29892, 13, 1678, 1723, 13, 1678, 363, 413, 29892, 29894, 297, 1051, 29898, 6768, 29889, 7076, 580, 1125, 13, 4706, 565, 451, 325, 29901, 13, 9651, 628, 3987, 29961, 29895, 29962, 13, 1678, 565, 338, 29918, 5675, 29918, 14669, 29901, 13, 4706, 1207, 29918, 14669, 29898, 5085, 29892, 12078, 29892, 848, 29918, 5325, 29892, 3987, 29897, 13, 1678, 1683, 29901, 13, 4706, 2048, 29898, 5085, 29892, 12078, 29892, 848, 29918, 5325, 29892, 3987, 29897, 13, 13, 1753, 1207, 29918, 14669, 29898, 5085, 29892, 12078, 29892, 848, 29918, 5325, 29892, 3987, 1125, 13, 1678, 3523, 1958, 353, 679, 29918, 3385, 29918, 1958, 580, 13, 1678, 9920, 29918, 6768, 353, 679, 29918, 9006, 29918, 6768, 580, 13, 13, 1678, 1550, 6389, 29901, 13, 4706, 9920, 353, 6389, 29889, 7323, 29898, 29900, 29897, 13, 4706, 565, 9920, 297, 9920, 29918, 6768, 29901, 13, 9651, 9920, 353, 3523, 1958, 29961, 9006, 29962, 13, 9651, 3987, 29961, 9006, 29889, 6506, 877, 29899, 742, 22868, 1495, 29962, 353, 6389, 29889, 7323, 29898, 29900, 29897, 13, 4706, 25342, 525, 2433, 297, 9920, 29901, 13, 9651, 9920, 29892, 659, 353, 9920, 29889, 5451, 877, 29922, 742, 29871, 29896, 29897, 13, 9651, 3987, 29961, 9006, 29889, 29880, 17010, 877, 29899, 2824, 6506, 877, 29899, 742, 22868, 1495, 29962, 353, 659, 13, 4706, 1683, 29901, 13, 9651, 9920, 353, 3523, 1958, 29889, 657, 29898, 9006, 29892, 9920, 29897, 13, 9651, 3987, 29961, 9006, 29889, 29880, 17010, 877, 29899, 2824, 6506, 877, 29899, 742, 22868, 1495, 29962, 353, 5852, 13, 13, 1678, 565, 2897, 29889, 2084, 29889, 9933, 877, 14669, 29889, 2272, 29374, 13, 4706, 620, 353, 6629, 13, 4706, 1550, 620, 29889, 13609, 580, 451, 297, 6702, 29891, 742, 525, 29876, 29374, 13, 9651, 620, 353, 10650, 29918, 2080, 877, 1252, 15423, 6230, 29889, 2272, 17809, 29892, 5191, 29973, 518, 29979, 29914, 29876, 29962, 25710, 13, 9651, 565, 451, 620, 29901, 13, 18884, 2867, 13, 4706, 565, 620, 1275, 525, 29876, 2396, 13, 9651, 1596, 877, 370, 18054, 29991, 1495, 13, 9651, 736, 13, 1678, 285, 353, 1722, 877, 14669, 29889, 2272, 742, 525, 29893, 1495, 13, 1678, 9631, 1503, 353, 18761, 29898, 1958, 29898, 407, 29878, 524, 29889, 29886, 4830, 29892, 313, 16713, 29892, 848, 29918, 5325, 29892, 3987, 4961, 13, 1678, 285, 29889, 3539, 29898, 10490, 4897, 29918, 4330, 3580, 29931, 3040, 1273, 9631, 1503, 29897, 13, 1678, 285, 29889, 23126, 580, 13, 1678, 285, 29889, 5358, 580, 13, 1678, 1596, 877, 29956, 4859, 6230, 29889, 2272, 1495, 13, 13, 1753, 2048, 29898, 5085, 29892, 12078, 29892, 848, 29918, 5325, 29892, 3987, 1125, 13, 1678, 2030, 29918, 19218, 353, 10876, 29889, 19218, 13, 1678, 10876, 29889, 19218, 353, 518, 9675, 29889, 19218, 29961, 29900, 1402, 525, 2272, 29906, 932, 2033, 718, 6389, 13, 1678, 2030, 29918, 2084, 353, 10876, 29889, 2084, 13, 1678, 2224, 29918, 7851, 353, 731, 580, 13, 1678, 363, 2471, 297, 12078, 29901, 13, 4706, 2224, 29918, 7851, 29889, 1202, 29898, 359, 29889, 2084, 29889, 25721, 29898, 2154, 876, 13, 1678, 10876, 29889, 2084, 353, 1051, 29898, 2084, 29918, 7851, 29897, 718, 2030, 29918, 2084, 13, 1678, 2030, 29918, 3972, 353, 2897, 29889, 657, 29883, 9970, 580, 13, 1678, 5694, 3972, 353, 5694, 1445, 29889, 11256, 29881, 7382, 580, 13, 1678, 2897, 29889, 305, 3972, 29898, 7382, 3972, 29897, 13, 1678, 1018, 29901, 13, 4706, 270, 353, 6230, 29898, 13, 9651, 623, 29922, 16713, 29892, 13, 9651, 848, 29918, 5325, 29922, 1272, 29918, 5325, 29892, 13, 9651, 3987, 3790, 29915, 2272, 29906, 932, 2396, 3987, 1118, 13, 4706, 1723, 13, 4706, 363, 3646, 297, 270, 29889, 932, 29901, 13, 9651, 3509, 29918, 8336, 29898, 13, 18884, 3646, 29889, 932, 3972, 29892, 13, 18884, 2897, 29889, 2084, 29889, 7122, 29898, 13, 462, 1678, 2897, 29889, 2084, 29889, 25721, 29898, 5182, 29889, 2154, 511, 13, 462, 1678, 2897, 29889, 2084, 29889, 6500, 3871, 29898, 5182, 29889, 932, 3972, 511, 13, 18884, 10353, 13, 18884, 19905, 29918, 29879, 21053, 19363, 29922, 5574, 29892, 13, 9651, 1723, 13, 13, 1678, 7146, 29901, 13, 4706, 2897, 29889, 305, 3972, 29898, 1025, 29918, 3972, 29897, 13, 4706, 528, 4422, 29889, 1758, 8336, 29898, 7382, 3972, 29892, 11455, 29918, 12523, 29922, 5574, 29897, 13, 4706, 10876, 29889, 19218, 353, 2030, 29918, 19218, 13, 4706, 10876, 29889, 2084, 353, 2030, 29918, 2084, 13, 13, 361, 4770, 978, 1649, 1275, 525, 1649, 3396, 1649, 2396, 13, 1678, 1667, 580, 13, 2 ]
tests/test_bic.py
KayJay89/schwifty
0
71578
import pytest from schwifty import BIC def test_bic(): bic = BIC("GENODEM1GLS") assert bic.formatted == "GENO DE M1 GLS" assert bic.validate() def test_bic_allow_invalid(): bic = BIC("GENODXM1GLS", allow_invalid=True) assert bic assert bic.country_code == "DX" with pytest.raises(ValueError): bic.validate() def test_bic_no_branch_code(): bic = BIC("GENODEM1") assert bic.branch_code is None assert bic.formatted == "GENO DE M1" def test_bic_properties(): bic = BIC("GENODEM1GLS") assert bic.length == 11 assert bic.bank_code == "GENO" assert bic.country_code == "DE" assert bic.location_code == "M1" assert bic.branch_code == "GLS" assert bic.domestic_bank_codes == ["43060967", "43060988"] assert bic.bank_names == [ "GLS Gemeinschaftsbank", "GLS Gemeinschaftsbank (GAA)", ] assert bic.bank_short_names == [ "GLS Bank in Bochum (GAA)", "GLS Gemeinschaftsbk Bochum", ] with pytest.warns(DeprecationWarning): assert bic.bank_name == "GLS Gemeinschaftsbank" with pytest.warns(DeprecationWarning): assert bic.bank_short_name == "GLS Bank in Bochum (GAA)" assert bic.exists assert bic.type == "passive" def test_unknown_bic_properties(): bic = BIC("ABNAJPJTXXX") assert bic.length == 11 assert bic.bank_code == "ABNA" assert bic.country_code == "JP" assert bic.location_code == "JT" assert bic.branch_code == "XXX" assert bic.country_bank_code is None assert bic.domestic_bank_codes == [] assert bic.bank_name is None assert bic.bank_names == [] assert bic.bank_short_name is None assert bic.bank_short_names == [] assert not bic.exists assert bic.type == "default" @pytest.mark.parametrize( "code,type", [ ("GENODEM0GLS", "testing"), ("GENODEM1GLS", "passive"), ("GENODEM2GLS", "reverse billing"), ("GENODEMMGLS", "default"), ], ) def test_bic_type(code, type): bic = BIC(code) assert bic.type == type @pytest.mark.parametrize( "code", [ "AAAA", # Too short "AAAADEM1GLSX", # Too long "12ABDEM1GLS", # Wrong structure in banc-id "GENOD1M1GLS", # Wrong structure in country-code "GENOXXM1GLS", # Wrong country-code ], ) def test_invalid_bic(code): with pytest.raises(ValueError): BIC(code) def test_bic_from_bank_code(): bic = BIC.from_bank_code("DE", "43060967") assert bic.compact == "GENODEM1GLS" def test_bic_from_unknown_bank_code(): with pytest.raises(ValueError): BIC.from_bank_code("PO", "12345678") def test_bic_is_from_primary_bank_code(): bic = BIC.from_bank_code("DE", "20070024") assert bic.compact == "DEUTDEDBHAM" def test_magic_methods(): bic = BIC("GENODEM1GLS") assert bic == "GENODEM1GLS" assert bic == BIC("GENODEM1GLS") assert bic != BIC("GENODEMMXXX") assert bic != 12345 assert bic < "GENODEM1GLT" assert str(bic) == "GENODEM1GLS" assert hash(bic) == hash("GENODEM1GLS") assert repr(bic) == "<BIC=GENODEM1GLS>"
[ 1, 1053, 11451, 1688, 13, 13, 3166, 25184, 361, 1017, 1053, 350, 2965, 13, 13, 13, 1753, 1243, 29918, 29890, 293, 7295, 13, 1678, 289, 293, 353, 350, 2965, 703, 24647, 29949, 2287, 29924, 29896, 7239, 29903, 1159, 13, 1678, 4974, 289, 293, 29889, 689, 19667, 1275, 376, 24647, 29949, 5012, 341, 29896, 402, 8547, 29908, 13, 1678, 4974, 289, 293, 29889, 15480, 580, 13, 13, 13, 1753, 1243, 29918, 29890, 293, 29918, 9536, 29918, 20965, 7295, 13, 1678, 289, 293, 353, 350, 2965, 703, 24647, 13668, 29990, 29924, 29896, 7239, 29903, 613, 2758, 29918, 20965, 29922, 5574, 29897, 13, 1678, 4974, 289, 293, 13, 1678, 4974, 289, 293, 29889, 13509, 29918, 401, 1275, 376, 29928, 29990, 29908, 13, 1678, 411, 11451, 1688, 29889, 336, 4637, 29898, 1917, 2392, 1125, 13, 4706, 289, 293, 29889, 15480, 580, 13, 13, 13, 1753, 1243, 29918, 29890, 293, 29918, 1217, 29918, 17519, 29918, 401, 7295, 13, 1678, 289, 293, 353, 350, 2965, 703, 24647, 29949, 2287, 29924, 29896, 1159, 13, 1678, 4974, 289, 293, 29889, 17519, 29918, 401, 338, 6213, 13, 1678, 4974, 289, 293, 29889, 689, 19667, 1275, 376, 24647, 29949, 5012, 341, 29896, 29908, 13, 13, 13, 1753, 1243, 29918, 29890, 293, 29918, 11330, 7295, 13, 1678, 289, 293, 353, 350, 2965, 703, 24647, 29949, 2287, 29924, 29896, 7239, 29903, 1159, 13, 1678, 4974, 289, 293, 29889, 2848, 1275, 29871, 29896, 29896, 13, 1678, 4974, 289, 293, 29889, 9157, 29918, 401, 1275, 376, 24647, 29949, 29908, 13, 1678, 4974, 289, 293, 29889, 13509, 29918, 401, 1275, 376, 2287, 29908, 13, 1678, 4974, 289, 293, 29889, 5479, 29918, 401, 1275, 376, 29924, 29896, 29908, 13, 1678, 4974, 289, 293, 29889, 17519, 29918, 401, 1275, 376, 7239, 29903, 29908, 13, 1678, 4974, 289, 293, 29889, 3129, 15931, 29918, 9157, 29918, 18137, 1275, 6796, 29946, 29941, 29900, 29953, 29900, 29929, 29953, 29955, 613, 376, 29946, 29941, 29900, 29953, 29900, 29929, 29947, 29947, 3108, 13, 1678, 4974, 289, 293, 29889, 9157, 29918, 7039, 1275, 518, 13, 4706, 376, 7239, 29903, 402, 5452, 2809, 29879, 9157, 613, 13, 4706, 376, 7239, 29903, 402, 5452, 2809, 29879, 9157, 313, 29954, 6344, 19123, 13, 1678, 4514, 13, 1678, 4974, 289, 293, 29889, 9157, 29918, 12759, 29918, 7039, 1275, 518, 13, 4706, 376, 7239, 29903, 10253, 297, 1952, 305, 398, 313, 29954, 6344, 19123, 13, 4706, 376, 7239, 29903, 402, 5452, 2809, 20778, 29895, 1952, 305, 398, 613, 13, 1678, 4514, 13, 1678, 411, 11451, 1688, 29889, 4495, 1983, 29898, 8498, 3757, 362, 22709, 1125, 13, 4706, 4974, 289, 293, 29889, 9157, 29918, 978, 1275, 376, 7239, 29903, 402, 5452, 2809, 29879, 9157, 29908, 13, 1678, 411, 11451, 1688, 29889, 4495, 1983, 29898, 8498, 3757, 362, 22709, 1125, 13, 4706, 4974, 289, 293, 29889, 9157, 29918, 12759, 29918, 978, 1275, 376, 7239, 29903, 10253, 297, 1952, 305, 398, 313, 29954, 6344, 5513, 13, 1678, 4974, 289, 293, 29889, 9933, 13, 1678, 4974, 289, 293, 29889, 1853, 1275, 376, 3364, 573, 29908, 13, 13, 13, 1753, 1243, 29918, 26690, 29918, 29890, 293, 29918, 11330, 7295, 13, 1678, 289, 293, 353, 350, 2965, 703, 2882, 3521, 29967, 29925, 29967, 29911, 22791, 1159, 13, 1678, 4974, 289, 293, 29889, 2848, 1275, 29871, 29896, 29896, 13, 1678, 4974, 289, 293, 29889, 9157, 29918, 401, 1275, 376, 2882, 3521, 29908, 13, 1678, 4974, 289, 293, 29889, 13509, 29918, 401, 1275, 376, 29967, 29925, 29908, 13, 1678, 4974, 289, 293, 29889, 5479, 29918, 401, 1275, 376, 29967, 29911, 29908, 13, 1678, 4974, 289, 293, 29889, 17519, 29918, 401, 1275, 376, 22791, 29908, 13, 1678, 4974, 289, 293, 29889, 13509, 29918, 9157, 29918, 401, 338, 6213, 13, 1678, 4974, 289, 293, 29889, 3129, 15931, 29918, 9157, 29918, 18137, 1275, 5159, 13, 1678, 4974, 289, 293, 29889, 9157, 29918, 978, 338, 6213, 13, 1678, 4974, 289, 293, 29889, 9157, 29918, 7039, 1275, 5159, 13, 1678, 4974, 289, 293, 29889, 9157, 29918, 12759, 29918, 978, 338, 6213, 13, 1678, 4974, 289, 293, 29889, 9157, 29918, 12759, 29918, 7039, 1275, 5159, 13, 1678, 4974, 451, 289, 293, 29889, 9933, 13, 1678, 4974, 289, 293, 29889, 1853, 1275, 376, 4381, 29908, 13, 13, 13, 29992, 2272, 1688, 29889, 3502, 29889, 3207, 300, 374, 911, 29898, 13, 1678, 376, 401, 29892, 1853, 613, 13, 1678, 518, 13, 4706, 4852, 24647, 29949, 2287, 29924, 29900, 7239, 29903, 613, 376, 13424, 4968, 13, 4706, 4852, 24647, 29949, 2287, 29924, 29896, 7239, 29903, 613, 376, 3364, 573, 4968, 13, 4706, 4852, 24647, 29949, 2287, 29924, 29906, 7239, 29903, 613, 376, 24244, 289, 8873, 4968, 13, 4706, 4852, 24647, 29949, 2287, 7428, 7239, 29903, 613, 376, 4381, 4968, 13, 1678, 21251, 13, 29897, 13, 1753, 1243, 29918, 29890, 293, 29918, 1853, 29898, 401, 29892, 1134, 1125, 13, 1678, 289, 293, 353, 350, 2965, 29898, 401, 29897, 13, 1678, 4974, 289, 293, 29889, 1853, 1275, 1134, 13, 13, 13, 29992, 2272, 1688, 29889, 3502, 29889, 3207, 300, 374, 911, 29898, 13, 1678, 376, 401, 613, 13, 1678, 518, 13, 4706, 376, 23184, 613, 29871, 396, 1763, 29877, 3273, 13, 4706, 376, 23184, 2287, 29924, 29896, 7239, 29903, 29990, 613, 29871, 396, 1763, 29877, 1472, 13, 4706, 376, 29896, 29906, 2882, 2287, 29924, 29896, 7239, 29903, 613, 29871, 396, 399, 29373, 3829, 297, 289, 4564, 29899, 333, 13, 4706, 376, 24647, 13668, 29896, 29924, 29896, 7239, 29903, 613, 29871, 396, 399, 29373, 3829, 297, 4234, 29899, 401, 13, 4706, 376, 24647, 29949, 6247, 29924, 29896, 7239, 29903, 613, 29871, 396, 399, 29373, 4234, 29899, 401, 13, 1678, 21251, 13, 29897, 13, 1753, 1243, 29918, 20965, 29918, 29890, 293, 29898, 401, 1125, 13, 1678, 411, 11451, 1688, 29889, 336, 4637, 29898, 1917, 2392, 1125, 13, 4706, 350, 2965, 29898, 401, 29897, 13, 13, 13, 1753, 1243, 29918, 29890, 293, 29918, 3166, 29918, 9157, 29918, 401, 7295, 13, 1678, 289, 293, 353, 350, 2965, 29889, 3166, 29918, 9157, 29918, 401, 703, 2287, 613, 376, 29946, 29941, 29900, 29953, 29900, 29929, 29953, 29955, 1159, 13, 1678, 4974, 289, 293, 29889, 2388, 627, 1275, 376, 24647, 29949, 2287, 29924, 29896, 7239, 29903, 29908, 13, 13, 13, 1753, 1243, 29918, 29890, 293, 29918, 3166, 29918, 26690, 29918, 9157, 29918, 401, 7295, 13, 1678, 411, 11451, 1688, 29889, 336, 4637, 29898, 1917, 2392, 1125, 13, 4706, 350, 2965, 29889, 3166, 29918, 9157, 29918, 401, 703, 13152, 613, 376, 29896, 29906, 29941, 29946, 29945, 29953, 29955, 29947, 1159, 13, 13, 13, 1753, 1243, 29918, 29890, 293, 29918, 275, 29918, 3166, 29918, 16072, 29918, 9157, 29918, 401, 7295, 13, 1678, 289, 293, 353, 350, 2965, 29889, 3166, 29918, 9157, 29918, 401, 703, 2287, 613, 376, 29906, 29900, 29900, 29955, 29900, 29900, 29906, 29946, 1159, 13, 1678, 4974, 289, 293, 29889, 2388, 627, 1275, 376, 2287, 2692, 2287, 4051, 29950, 5194, 29908, 13, 13, 13, 1753, 1243, 29918, 11082, 293, 29918, 23515, 7295, 13, 1678, 289, 293, 353, 350, 2965, 703, 24647, 29949, 2287, 29924, 29896, 7239, 29903, 1159, 13, 1678, 4974, 289, 293, 1275, 376, 24647, 29949, 2287, 29924, 29896, 7239, 29903, 29908, 13, 1678, 4974, 289, 293, 1275, 350, 2965, 703, 24647, 29949, 2287, 29924, 29896, 7239, 29903, 1159, 13, 1678, 4974, 289, 293, 2804, 350, 2965, 703, 24647, 29949, 2287, 7428, 22791, 1159, 13, 1678, 4974, 289, 293, 2804, 29871, 29896, 29906, 29941, 29946, 29945, 13, 1678, 4974, 289, 293, 529, 376, 24647, 29949, 2287, 29924, 29896, 29954, 5850, 29908, 13, 13, 1678, 4974, 851, 29898, 29890, 293, 29897, 1275, 376, 24647, 29949, 2287, 29924, 29896, 7239, 29903, 29908, 13, 1678, 4974, 6608, 29898, 29890, 293, 29897, 1275, 6608, 703, 24647, 29949, 2287, 29924, 29896, 7239, 29903, 1159, 13, 1678, 4974, 2062, 29898, 29890, 293, 29897, 1275, 9872, 29933, 2965, 29922, 24647, 29949, 2287, 29924, 29896, 7239, 29903, 11903, 13, 2 ]
tests/test_request_body.py
jaraco/aspen
1
131724
<filename>tests/test_request_body.py from __future__ import absolute_import from __future__ import division from __future__ import print_function from __future__ import unicode_literals from pytest import raises from aspen.http.request import Headers import aspen.body_parsers as parsers from aspen.exceptions import MalformedBody, UnknownBodyType FORMDATA = object() WWWFORM = object() def make_body(raw, headers=None, content_type=WWWFORM): if isinstance(raw, unicode): raw = raw.encode('ascii') if headers is None: defaults = { FORMDATA: "multipart/form-data; boundary=AaB03x", WWWFORM: "application/x-www-form-urlencoded" } headers = {"Content-Type": defaults.get(content_type, content_type)} if not 'content-length' in headers: headers['Content-length'] = str(len(raw)) body_parsers = { "application/json": parsers.jsondata, "application/x-www-form-urlencoded": parsers.formdata, "multipart/form-data": parsers.formdata } headers['Host'] = 'Blah' return parsers.parse_body(raw, Headers(headers), body_parsers) def test_body_is_unparsed_for_empty_content_type(): raw = "cheese=yes" raises(UnknownBodyType, make_body, raw, headers={}) def test_body_barely_works(): body = make_body("cheese=yes") actual = body['cheese'] assert actual == "yes" UPLOAD = """\ --AaB03x Content-Disposition: form-data; name="submit-name" Larry --AaB03x Content-Disposition: form-data; name="files"; filename="file1.txt" Content-Type: text/plain ... contents of file1.txt ... --AaB03x-- """ def test_body_barely_works_for_form_data(): body = make_body(UPLOAD, content_type=FORMDATA) actual = body['files'].filename assert actual == "file1.txt" def test_simple_values_are_simple(): body = make_body(UPLOAD, content_type=FORMDATA) actual = body['submit-name'] assert actual == "Larry" def test_multiple_values_are_multiple(): body = make_body("cheese=yes&cheese=burger") assert body.all('cheese') == ["yes", "burger"] def test_params_doesnt_break_www_form(): body = make_body("statement=foo" , content_type="application/x-www-form-urlencoded; charset=UTF-8; cheese=yummy" ) actual = body['statement'] assert actual == "foo" def test_malformed_body_jsondata(): with raises(MalformedBody): make_body("foo", content_type="application/json") def test_malformed_body_formdata(): with raises(MalformedBody): make_body("", content_type="multipart/form-data; boundary=\0")
[ 1, 529, 9507, 29958, 21150, 29914, 1688, 29918, 3827, 29918, 2587, 29889, 2272, 13, 3166, 4770, 29888, 9130, 1649, 1053, 8380, 29918, 5215, 13, 3166, 4770, 29888, 9130, 1649, 1053, 8542, 13, 3166, 4770, 29888, 9130, 1649, 1053, 1596, 29918, 2220, 13, 3166, 4770, 29888, 9130, 1649, 1053, 29104, 29918, 20889, 1338, 13, 13, 3166, 11451, 1688, 1053, 1153, 4637, 13, 13, 3166, 408, 2238, 29889, 1124, 29889, 3827, 1053, 12252, 414, 13, 5215, 408, 2238, 29889, 2587, 29918, 862, 4253, 408, 610, 4253, 13, 3166, 408, 2238, 29889, 11739, 29879, 1053, 3792, 15628, 8434, 29892, 853, 5203, 8434, 1542, 13, 13, 13, 22051, 5773, 8254, 353, 1203, 580, 13, 29956, 29956, 29956, 19094, 353, 1203, 580, 13, 13, 1753, 1207, 29918, 2587, 29898, 1610, 29892, 9066, 29922, 8516, 29892, 2793, 29918, 1853, 29922, 29956, 29956, 29956, 19094, 1125, 13, 1678, 565, 338, 8758, 29898, 1610, 29892, 29104, 1125, 13, 4706, 10650, 353, 10650, 29889, 12508, 877, 294, 18869, 1495, 13, 1678, 565, 9066, 338, 6213, 29901, 13, 4706, 21274, 353, 426, 15842, 5773, 8254, 29901, 376, 18056, 442, 29914, 689, 29899, 1272, 29936, 10452, 29922, 29909, 29874, 29933, 29900, 29941, 29916, 613, 13, 462, 268, 399, 29956, 29956, 19094, 29901, 376, 6214, 29914, 29916, 29899, 1636, 29899, 689, 29899, 2271, 26716, 29908, 500, 13, 4706, 9066, 353, 8853, 3916, 29899, 1542, 1115, 21274, 29889, 657, 29898, 3051, 29918, 1853, 29892, 2793, 29918, 1853, 2915, 13, 1678, 565, 451, 525, 3051, 29899, 2848, 29915, 297, 9066, 29901, 13, 4706, 9066, 1839, 3916, 29899, 2848, 2033, 353, 851, 29898, 2435, 29898, 1610, 876, 13, 1678, 3573, 29918, 862, 4253, 353, 426, 13, 9651, 376, 6214, 29914, 3126, 1115, 610, 4253, 29889, 1315, 898, 532, 29892, 13, 9651, 376, 6214, 29914, 29916, 29899, 1636, 29899, 689, 29899, 2271, 26716, 1115, 610, 4253, 29889, 689, 1272, 29892, 13, 9651, 376, 18056, 442, 29914, 689, 29899, 1272, 1115, 610, 4253, 29889, 689, 1272, 13, 1678, 500, 13, 1678, 9066, 1839, 8514, 2033, 353, 525, 29933, 8083, 29915, 13, 1678, 736, 610, 4253, 29889, 5510, 29918, 2587, 29898, 1610, 29892, 12252, 414, 29898, 13662, 511, 3573, 29918, 862, 4253, 29897, 13, 13, 13, 1753, 1243, 29918, 2587, 29918, 275, 29918, 348, 862, 8485, 29918, 1454, 29918, 6310, 29918, 3051, 29918, 1853, 7295, 13, 1678, 10650, 353, 376, 1173, 968, 29922, 3582, 29908, 13, 1678, 1153, 4637, 29898, 14148, 8434, 1542, 29892, 1207, 29918, 2587, 29892, 10650, 29892, 9066, 3790, 1800, 13, 13, 1753, 1243, 29918, 2587, 29918, 18354, 368, 29918, 13129, 7295, 13, 1678, 3573, 353, 1207, 29918, 2587, 703, 1173, 968, 29922, 3582, 1159, 13, 1678, 3935, 353, 3573, 1839, 1173, 968, 2033, 13, 1678, 4974, 3935, 1275, 376, 3582, 29908, 13, 13, 13, 4897, 29428, 353, 9995, 29905, 13, 489, 29909, 29874, 29933, 29900, 29941, 29916, 13, 3916, 29899, 4205, 3283, 29901, 883, 29899, 1272, 29936, 1024, 543, 7892, 29899, 978, 29908, 13, 13, 24105, 719, 13, 489, 29909, 29874, 29933, 29900, 29941, 29916, 13, 3916, 29899, 4205, 3283, 29901, 883, 29899, 1272, 29936, 1024, 543, 5325, 1769, 10422, 543, 1445, 29896, 29889, 3945, 29908, 13, 3916, 29899, 1542, 29901, 1426, 29914, 24595, 13, 13, 856, 8118, 310, 934, 29896, 29889, 3945, 2023, 13, 489, 29909, 29874, 29933, 29900, 29941, 29916, 489, 13, 15945, 29908, 13, 13, 1753, 1243, 29918, 2587, 29918, 18354, 368, 29918, 13129, 29918, 1454, 29918, 689, 29918, 1272, 7295, 13, 1678, 3573, 353, 1207, 29918, 2587, 29898, 4897, 29428, 29892, 2793, 29918, 1853, 29922, 22051, 5773, 8254, 29897, 13, 1678, 3935, 353, 3573, 1839, 5325, 13359, 9507, 13, 1678, 4974, 3935, 1275, 376, 1445, 29896, 29889, 3945, 29908, 13, 13, 1753, 1243, 29918, 12857, 29918, 5975, 29918, 598, 29918, 12857, 7295, 13, 1678, 3573, 353, 1207, 29918, 2587, 29898, 4897, 29428, 29892, 2793, 29918, 1853, 29922, 22051, 5773, 8254, 29897, 13, 1678, 3935, 353, 3573, 1839, 7892, 29899, 978, 2033, 13, 1678, 4974, 3935, 1275, 376, 24105, 719, 29908, 13, 13, 1753, 1243, 29918, 20787, 29918, 5975, 29918, 598, 29918, 20787, 7295, 13, 1678, 3573, 353, 1207, 29918, 2587, 703, 1173, 968, 29922, 3582, 29987, 1173, 968, 29922, 21619, 1159, 13, 1678, 4974, 3573, 29889, 497, 877, 1173, 968, 1495, 1275, 6796, 3582, 613, 376, 21619, 3108, 13, 13, 1753, 1243, 29918, 7529, 29918, 13221, 593, 29918, 8690, 29918, 1636, 29918, 689, 7295, 13, 1678, 3573, 353, 1207, 29918, 2587, 703, 20788, 29922, 5431, 29908, 13, 462, 1678, 1919, 2793, 29918, 1853, 543, 6214, 29914, 29916, 29899, 1636, 29899, 689, 29899, 2271, 26716, 29936, 17425, 29922, 10496, 29899, 29947, 29936, 923, 968, 29922, 29891, 11770, 29908, 13, 462, 268, 1723, 13, 1678, 3935, 353, 3573, 1839, 20788, 2033, 13, 1678, 4974, 3935, 1275, 376, 5431, 29908, 13, 13, 1753, 1243, 29918, 5156, 15628, 29918, 2587, 29918, 1315, 898, 532, 7295, 13, 1678, 411, 1153, 4637, 29898, 22995, 15628, 8434, 1125, 13, 4706, 1207, 29918, 2587, 703, 5431, 613, 2793, 29918, 1853, 543, 6214, 29914, 3126, 1159, 13, 13, 1753, 1243, 29918, 5156, 15628, 29918, 2587, 29918, 689, 1272, 7295, 13, 1678, 411, 1153, 4637, 29898, 22995, 15628, 8434, 1125, 13, 4706, 1207, 29918, 2587, 703, 613, 2793, 29918, 1853, 543, 18056, 442, 29914, 689, 29899, 1272, 29936, 10452, 2013, 29900, 1159, 13, 2 ]
src/ppu.py
condector/pynes
2
190342
<filename>src/ppu.py import threading import multiprocessing import time from array import array from renderer import RendererManager class PPU: class VolatileMemory: def __init__(self, size): self.ram = array('B', [0x00] * size) def read(self, a=0x0): return self.ram[a] def write(self, a=0x0, v=0x0): self.ram[a] = v class VBlank: def __init__(self, console): self.status = False self._console = console def enter(self): if self._console.PPU.NMI: self._console.CPU.InterruptRequest = 0x4E # N self.status = True while True: try: self._console.PPU.renderer.display.blit() break except: pass def exit(self): self.status = False self._console.PPU.renderer.display.clear() def __init__(self, console=None): print("Initializing PPU...") self.console = console self.nameTableAddress = 0 self.incrementAddress = 1 self.spritePatternTable = 0 self.backgroundPatternTable = 0 self.spriteSize = 8 self.NMI = False self.colorMode = True self.clippingBackground = False self.clippingSprites = False self.showBackground = False self.showSprites = False self.colorIntensity = 0 self.spriteRamAddr = 0 self.vRamWrites = 0 self.scanlineSpriteCount = 0 self.sprite0Hit = 0 self.spriteHitOccured = False self.VRAMAddress = 0 self.VRAMBuffer = 0 self.firstWrite = True self.ppuScrollX = 0 self.ppuScrollY = 0 self.ppuStarted = 0 self.ppuMirroring = 0 self.addressMirroring = 0 self.colorPallete = [(0x75, 0x75, 0x75), (0x27, 0x1B, 0x8F), (0x00, 0x00, 0xAB), (0x47, 0x00, 0x9F), (0x8F, 0x00, 0x77), (0xAB, 0x00, 0x13), (0xA7, 0x00, 0x00), (0x7F, 0x0B, 0x00), (0x43, 0x2F, 0x00), (0x00, 0x47, 0x00), (0x00, 0x51, 0x00), (0x00, 0x3F, 0x17), (0x1B, 0x3F, 0x5F), (0x00, 0x00, 0x00), (0x00, 0x00, 0x00), (0x00, 0x00, 0x00), (0xBC, 0xBC, 0xBC), (0x00, 0x73, 0xEF), (0x23, 0x3B, 0xEF), (0x83, 0x00, 0xF3), (0xBF, 0x00, 0xBF), (0xE7, 0x00, 0x5B), (0xDB, 0x2B, 0x00), (0xCB, 0x4F, 0x0F), (0x8B, 0x73, 0x00), (0x00, 0x97, 0x00), (0x00, 0xAB, 0x00), (0x00, 0x93, 0x3B), (0x00, 0x83, 0x8B), (0x00, 0x00, 0x00), (0x00, 0x00, 0x00), (0x00, 0x00, 0x00), (0xFF, 0xFF, 0xFF), (0x3F, 0xBF, 0xFF), (0x5F, 0x97, 0xFF), (0xA7, 0x8B, 0xFD), (0xF7, 0x7B, 0xFF), (0xFF, 0x77, 0xB7), (0xFF, 0x77, 0x63), (0xFF, 0x9B, 0x3B), (0xF3, 0xBF, 0x3F), (0x83, 0xD3, 0x13), (0x4F, 0xDF, 0x4B), (0x58, 0xF8, 0x98), (0x00, 0xEB, 0xDB), (0x00, 0x00, 0x00), (0x00, 0x00, 0x00), (0x00, 0x00, 0x00), (0xFF, 0xFF, 0xFF), (0xAB, 0xE7, 0xFF), (0xC7, 0xD7, 0xFF), (0xD7, 0xCB, 0xFF), (0xFF, 0xC7, 0xFF), (0xFF, 0xC7, 0xDB), (0xFF, 0xBF, 0xB3), (0xFF, 0xDB, 0xAB), (0xFF, 0xE7, 0xA3), (0xE3, 0xFF, 0xA3), (0xAB, 0xF3, 0xBF), (0xB3, 0xFF, 0xCF), (0x9F, 0xFF, 0xF3), (0x00, 0x00, 0x00), (0x00, 0x00, 0x00), (0x00, 0x00, 0x00)] #try: self.renderer = RendererManager(self.console.RENDERER_TYPE) #except: # print ("Cannot initialize Renderer") self.VBLANK = self.VBlank(self.console) self.VRAM = self.VolatileMemory(0x10000) self.SPRRAM = self.VolatileMemory(0x100) self.load_vram_data() self.setMirroring(self.console.cartridge.mirror) super(PPU, self).__init__() def load_vram_data(self): maxdata = self.console.cartridge.chrRomData.__len__() k = 0 while k < maxdata: v = self.console.cartridge.chrRomData[k] self.VRAM.write(k, v) k += 1 self.renderer.display.reset() def setMirroring(self, mirroring): # 0 = horizontal mirroring # 1 = vertical mirroring self.ppuMirroring = mirroring self.addressMirroring = 0x400 << self.ppuMirroring def processControlReg1(self, value): # Check bits 0-1 aux = value & 0x3 if aux == 0: self.nameTableAddress = 0x2000 elif aux == 1: self.nameTableAddress = 0x2400 elif aux == 2: self.nameTableAddress = 0x2800 else: self.nameTableAddress = 0x2C00 # Check bit 2 if value & (1 << 2): self.incrementAddress = 32 else: self.incrementAddress = 1 # Check bit 3 if value & (1 << 3): self.spritePatternTable = 0x1000 else: self.spritePatternTable = 0x0000 # Check bit 4 if value & (1 << 4): self.backgroundPatternTable = 0x1000 else: self.backgroundPatternTable = 0x0000 # Check bit 5 if value & (1 << 5): self.spriteSize = 16 else: self.spriteSize = 8 # Bit 6 not used # Check bit 7 if value & (1 << 7): self.NMI = True else: self.NMI = False def processControlReg2(self, value): # Check bit 0 if value & 1: self.colorMode = True else: self.colorMode = False # Check bit 1 if value & (1 << 1): self.clippingBackground = True else: self.clippingBackground = False # Check bit 2 if value & (1 << 2): self.clippingSprites = True else: self.clippingSprites = False # Check bit 3 if value & (1 << 3): self.showBackground = True else: self.showBackground = False # Check bit 4 if value & (1 << 4): self.showSprites = True else: self.showSprites = False # Check bits 5-7 self.colorIntensity = value >> 5 # process register 0x2005 def processPPUSCROLL(self, value): if self.firstWrite: self.ppuScrollX = value self.firstWrite = False else: self.ppuScrollY = value self.firstWrite = True # process register 0x2006 def processPPUADDR(self, value): if self.firstWrite: self.VRAMAddress = (value & 0xFF) << 8 self.firstWrite = False else: self.VRAMAddress += (value & 0xFF) self.firstWrite = True # process register 0x2007 (write) def writeVRAM(self, value): #Todo: Verificar se esta certo # NameTable write mirroring. if self.VRAMAddress >= 0x2000 and self.VRAMAddress < 0x3F00: self.VRAM.write(self.VRAMAddress + self.addressMirroring, value) self.VRAM.write(self.VRAMAddress, value) # Color Pallete write mirroring. elif self.VRAMAddress >= 0x3F00 and self.VRAMAddress < 0x3F20: if self.VRAMAddress == 0x3F00 or self.VRAMAddress == 0x3F10: self.VRAM.write(0x3F00, value) self.VRAM.write(0x3F04, value) self.VRAM.write(0x3F08, value) self.VRAM.write(0x3F0C, value) self.VRAM.write(0x3F10, value) self.VRAM.write(0x3F14, value) self.VRAM.write(0x3F18, value) self.VRAM.write(0x3F1C, value) else: self.VRAM.write(self.VRAMAddress, value) self.VRAMAddress += self.incrementAddress # process register 0x2007 (read) def readVRAM(self): value = 0 address = self.VRAMAddress & 0x3FFF if address >= 0x3F00 and address < 0x4000: address = 0x3F00 + (address & 0xF) self.VRAMBuffer = self.VRAM.read(address) value = self.VRAM.read(address) elif address < 0x3F00: value = self.VRAMBuffer self.VRAMBuffer = self.VRAM.read(address) self.VRAMAddress += self.incrementAddress return value def writeSprRam(self, value): self.SPRRAM.write(self.spriteRamAddr,value) self.spriteRamAddr = (self.spriteRamAddr + 1) & 0xFF def writeSprRamDMA(self, value): address = value * 0x100 i = 0 while i < 256: self.SPRRAM.write(i, self.console.CPU.RAM.read(address)) address += 1 i += 1 def readStatusFlag(self): value = 0 value |= (self.vRamWrites << 4) value |= (self.scanlineSpriteCount << 5) value |= (self.sprite0Hit << 6) value |= (int(self.VBLANK.status) << 7) self.firstWrite = True self.VBLANK.exit() return value def doScanline(self): if self.showBackground: self.drawBackground(self.console.CPU.scanline) if self.showSprites: self.drawSprites(self.console.CPU.scanline) def drawBackground(self, scanline): tileY = int(scanline / 8) Y = int(scanline % 8) maxTiles = 32 if (self.ppuScrollX % 8) != 0: maxTiles = 33 currentTile = int(self.ppuScrollX / 8) v = int(self.nameTableAddress + currentTile) pixel = 0 first = 0 if self.clippingBackground else 1 tiles = array('B', list(range(first, maxTiles))) for i in tiles: fromByte = 0 toByte = 8 ppuScrollFlag = (self.ppuScrollX %8) if ppuScrollFlag != 0: if i == 0: toByte = 7 - (ppuScrollFlag) if i == (maxTiles - 1): fromByte = 8 - (ppuScrollFlag) ptrAddress = self.VRAM.read(v + int(tileY*0x20)) pattern1 = self.VRAM.read(self.backgroundPatternTable + (ptrAddress*16) + Y) pattern2 = self.VRAM.read(self.backgroundPatternTable + (ptrAddress*16) + Y + 8) # blockX e blockY sao as coordenadas em relacao ao block blockX = i % 4 blockY = tileY % 4 block = int(i / 4) + (int(tileY / 4) * 8) addressByte = int((v & ~0x001F) + 0x03C0 + block) byteAttributeTable = self.VRAM.read(addressByte) colorIndex = 0x3F00 if blockX < 2: if blockY >= 2: colorIndex |= ((byteAttributeTable & 0b110000) >> 4) << 2 else: colorIndex |= (byteAttributeTable & 0b11) << 2 elif blockX >= 2 and blockY < 2: colorIndex |= ((byteAttributeTable & 0b1100) >> 2) << 2 else: colorIndex |= ((byteAttributeTable & 0b11000000) >> 6) << 2 k = array('B', list(range(fromByte, toByte))) for j in k: bit1 = ((1 << j) & pattern1) >> j bit2 = ((1 << j) & pattern2) >> j colorIndexFinal = colorIndex colorIndexFinal |= ((bit2 << 1) | bit1) color = self.colorPallete[self.VRAM.read(colorIndexFinal)] x = (pixel + ((j * (-1)) + (toByte - fromByte) - 1)) y = scanline if (bytes(color) != self.renderer.display.LAYER_B.read(x, y)): self.renderer.display.LAYER_B.write(x, y, color) j += 1 pixel += toByte - fromByte if (v & 0x001f) == 31: v &= ~0x001F #v ^= self.addressMirroring v ^= 0x400 else: v += 1 del k del tiles def drawSprites(self, scanline): numberSpritesPerScanline = 0 Y = scanline % 8 secondaryOAM = array('B', [0xFF] * 32) indexSecondaryOAM = 0 k = array('B', list(range(0, 256, 4))) for currentSprite in k: spriteY = self.SPRRAM.read(currentSprite) if numberSpritesPerScanline == 8: break if spriteY <= scanline < spriteY + self.spriteSize: sprloop = array('B', list(range(4))) for i in sprloop: secondaryOAM[indexSecondaryOAM + i] = self.SPRRAM.read(currentSprite+i) indexSecondaryOAM += 4 numberSpritesPerScanline += 1 del sprloop del k k = array('B', list(range(28, -1, -4))) for currentSprite in k: spriteX = secondaryOAM[currentSprite + 3] spriteY = secondaryOAM[currentSprite] if spriteY >= 0xEF or spriteX >= 0xF9: continue currentSpriteAddress = currentSprite + 2 flipVertical = secondaryOAM[currentSpriteAddress] & 0x80 flipHorizontal = secondaryOAM[currentSpriteAddress] & 0x40 Y = scanline - spriteY ptrAddress = secondaryOAM[currentSprite + 1] patAddress = self.spritePatternTable + (ptrAddress * 16) + ((7 - Y) if flipVertical else Y) pattern1 = self.VRAM.read(patAddress) pattern2 = self.VRAM.read(patAddress + 8) colorIndex = 0x3F10 colorIndex |= ((secondaryOAM[currentSprite +2] & 0x3) << 2) sprloop = array('B', range(8)) for j in sprloop: if flipHorizontal: colorIndexFinal = (pattern1 >> j) & 0x1 colorIndexFinal |= ((pattern2 >> j) & 0x1 ) << 1 else: colorIndexFinal = (pattern1 >> (7 - j)) & 0x1 colorIndexFinal |= ((pattern2 >> (7 - j)) & 0x1) << 1 colorIndexFinal += colorIndex if (colorIndexFinal % 4) == 0: colorIndexFinal = 0x3F00 color = self.colorPallete[(self.VRAM.read(colorIndexFinal) & 0x3F)] # Add Transparency if color == self.colorPallete[self.VRAM.read(0x3F10)]: color += (0,) self.renderer.display.LAYER_A.write(spriteX + j, spriteY + Y, color) checkColor=self.renderer.display.LAYER_A.read(spriteX + j, spriteY + Y) if self.showBackground and not(self.spriteHitOccured) and currentSprite == 0 and checkColor == bytes(color): self.sprite0Hit = True self.spriteHitOccured = True del sprloop del k def run(self): print("PPU OK") if self.console.THREAD_MODE == "SINGLE": pass else: self.console.CPU = self.console.CPU while True: self.console.CPU.end.wait() self.console.CPU.end.clear() print(self.console.CPU.scanline) self.renderer.display.blit() self.console.CPU.scanline = 0
[ 1, 529, 9507, 29958, 4351, 29914, 407, 29884, 29889, 2272, 13, 5215, 3244, 292, 13, 5215, 6674, 307, 985, 292, 13, 5215, 931, 13, 3166, 1409, 1053, 1409, 13, 13, 3166, 4050, 261, 1053, 26000, 261, 3260, 13, 13, 1990, 349, 7056, 29901, 13, 13, 1678, 770, 3684, 24285, 16015, 29901, 13, 4706, 822, 4770, 2344, 12035, 1311, 29892, 2159, 1125, 13, 9651, 1583, 29889, 2572, 353, 1409, 877, 29933, 742, 518, 29900, 29916, 29900, 29900, 29962, 334, 2159, 29897, 13, 13, 4706, 822, 1303, 29898, 1311, 29892, 263, 29922, 29900, 29916, 29900, 1125, 13, 9651, 736, 1583, 29889, 2572, 29961, 29874, 29962, 13, 13, 4706, 822, 2436, 29898, 1311, 29892, 263, 29922, 29900, 29916, 29900, 29892, 325, 29922, 29900, 29916, 29900, 1125, 13, 9651, 1583, 29889, 2572, 29961, 29874, 29962, 353, 325, 13, 13, 1678, 770, 478, 10358, 804, 29901, 13, 4706, 822, 4770, 2344, 12035, 1311, 29892, 2991, 1125, 13, 9651, 1583, 29889, 4882, 353, 7700, 13, 9651, 1583, 3032, 11058, 353, 2991, 13, 308, 13, 4706, 822, 3896, 29898, 1311, 1125, 13, 9651, 565, 1583, 3032, 11058, 29889, 29925, 7056, 29889, 29940, 10403, 29901, 13, 18884, 1583, 3032, 11058, 29889, 6271, 29965, 29889, 4074, 6685, 3089, 353, 29871, 29900, 29916, 29946, 29923, 396, 405, 13, 9651, 1583, 29889, 4882, 353, 5852, 13, 9651, 1550, 5852, 29901, 13, 18884, 1018, 29901, 13, 462, 1678, 1583, 3032, 11058, 29889, 29925, 7056, 29889, 9482, 261, 29889, 4990, 29889, 2204, 277, 580, 13, 462, 1678, 2867, 13, 18884, 5174, 29901, 13, 462, 1678, 1209, 13, 13, 4706, 822, 6876, 29898, 1311, 1125, 13, 9651, 1583, 29889, 4882, 353, 7700, 13, 9651, 1583, 3032, 11058, 29889, 29925, 7056, 29889, 9482, 261, 29889, 4990, 29889, 8551, 580, 13, 13, 1678, 822, 4770, 2344, 12035, 1311, 29892, 2991, 29922, 8516, 1125, 13, 4706, 1596, 703, 15514, 5281, 349, 7056, 856, 1159, 13, 4706, 1583, 29889, 11058, 353, 2991, 13, 13, 4706, 1583, 29889, 978, 3562, 7061, 353, 29871, 29900, 13, 4706, 1583, 29889, 25629, 7061, 353, 29871, 29896, 13, 4706, 1583, 29889, 15099, 568, 17144, 3562, 353, 29871, 29900, 13, 4706, 1583, 29889, 7042, 17144, 3562, 353, 29871, 29900, 13, 4706, 1583, 29889, 15099, 568, 3505, 353, 29871, 29947, 13, 4706, 1583, 29889, 29940, 10403, 353, 7700, 13, 4706, 1583, 29889, 2780, 6818, 353, 5852, 13, 4706, 1583, 29889, 11303, 3262, 10581, 353, 7700, 13, 4706, 1583, 29889, 11303, 3262, 29903, 558, 3246, 353, 7700, 13, 4706, 1583, 29889, 4294, 10581, 353, 7700, 13, 4706, 1583, 29889, 4294, 29903, 558, 3246, 353, 7700, 13, 4706, 1583, 29889, 2780, 2928, 575, 537, 353, 29871, 29900, 13, 13, 4706, 1583, 29889, 15099, 568, 29934, 314, 2528, 29878, 353, 29871, 29900, 13, 4706, 1583, 29889, 29894, 29934, 314, 29956, 768, 267, 353, 29871, 29900, 13, 4706, 1583, 29889, 16192, 1220, 29903, 558, 568, 3981, 353, 29871, 29900, 13, 4706, 1583, 29889, 15099, 568, 29900, 29950, 277, 353, 29871, 29900, 13, 4706, 1583, 29889, 15099, 568, 29950, 277, 22034, 2955, 353, 7700, 13, 4706, 1583, 29889, 29963, 4717, 1529, 1289, 1253, 353, 29871, 29900, 13, 4706, 1583, 29889, 29963, 25058, 7701, 353, 29871, 29900, 13, 4706, 1583, 29889, 4102, 6113, 353, 5852, 13, 4706, 1583, 29889, 407, 29884, 10463, 29990, 353, 29871, 29900, 13, 4706, 1583, 29889, 407, 29884, 10463, 29979, 353, 29871, 29900, 13, 4706, 1583, 29889, 407, 29884, 4763, 287, 353, 29871, 29900, 13, 13, 4706, 1583, 29889, 407, 29884, 29924, 381, 729, 292, 353, 29871, 29900, 13, 4706, 1583, 29889, 7328, 29924, 381, 729, 292, 353, 29871, 29900, 13, 13, 4706, 1583, 29889, 2780, 18210, 2810, 353, 17288, 29900, 29916, 29955, 29945, 29892, 29871, 29900, 29916, 29955, 29945, 29892, 29871, 29900, 29916, 29955, 29945, 511, 13, 462, 632, 313, 29900, 29916, 29906, 29955, 29892, 29871, 29900, 29916, 29896, 29933, 29892, 29871, 29900, 29916, 29947, 29943, 511, 13, 462, 632, 313, 29900, 29916, 29900, 29900, 29892, 29871, 29900, 29916, 29900, 29900, 29892, 29871, 29900, 29916, 2882, 511, 13, 462, 632, 313, 29900, 29916, 29946, 29955, 29892, 29871, 29900, 29916, 29900, 29900, 29892, 29871, 29900, 29916, 29929, 29943, 511, 13, 462, 632, 313, 29900, 29916, 29947, 29943, 29892, 29871, 29900, 29916, 29900, 29900, 29892, 29871, 29900, 29916, 29955, 29955, 511, 13, 462, 632, 313, 29900, 29916, 2882, 29892, 29871, 29900, 29916, 29900, 29900, 29892, 29871, 29900, 29916, 29896, 29941, 511, 13, 462, 632, 313, 29900, 29916, 29909, 29955, 29892, 29871, 29900, 29916, 29900, 29900, 29892, 29871, 29900, 29916, 29900, 29900, 511, 13, 462, 632, 313, 29900, 29916, 29955, 29943, 29892, 29871, 29900, 29916, 29900, 29933, 29892, 29871, 29900, 29916, 29900, 29900, 511, 13, 462, 632, 313, 29900, 29916, 29946, 29941, 29892, 29871, 29900, 29916, 29906, 29943, 29892, 29871, 29900, 29916, 29900, 29900, 511, 13, 462, 632, 313, 29900, 29916, 29900, 29900, 29892, 29871, 29900, 29916, 29946, 29955, 29892, 29871, 29900, 29916, 29900, 29900, 511, 13, 462, 632, 313, 29900, 29916, 29900, 29900, 29892, 29871, 29900, 29916, 29945, 29896, 29892, 29871, 29900, 29916, 29900, 29900, 511, 13, 462, 632, 313, 29900, 29916, 29900, 29900, 29892, 29871, 29900, 29916, 29941, 29943, 29892, 29871, 29900, 29916, 29896, 29955, 511, 13, 462, 632, 313, 29900, 29916, 29896, 29933, 29892, 29871, 29900, 29916, 29941, 29943, 29892, 29871, 29900, 29916, 29945, 29943, 511, 13, 462, 632, 313, 29900, 29916, 29900, 29900, 29892, 29871, 29900, 29916, 29900, 29900, 29892, 29871, 29900, 29916, 29900, 29900, 511, 13, 462, 632, 313, 29900, 29916, 29900, 29900, 29892, 29871, 29900, 29916, 29900, 29900, 29892, 29871, 29900, 29916, 29900, 29900, 511, 13, 462, 632, 313, 29900, 29916, 29900, 29900, 29892, 29871, 29900, 29916, 29900, 29900, 29892, 29871, 29900, 29916, 29900, 29900, 511, 13, 462, 632, 313, 29900, 29916, 5371, 29892, 29871, 29900, 29916, 5371, 29892, 29871, 29900, 29916, 5371, 511, 13, 462, 632, 313, 29900, 29916, 29900, 29900, 29892, 29871, 29900, 29916, 29955, 29941, 29892, 29871, 29900, 29916, 29638, 511, 13, 462, 632, 313, 29900, 29916, 29906, 29941, 29892, 29871, 29900, 29916, 29941, 29933, 29892, 29871, 29900, 29916, 29638, 511, 13, 462, 632, 313, 29900, 29916, 29947, 29941, 29892, 29871, 29900, 29916, 29900, 29900, 29892, 29871, 29900, 29916, 29943, 29941, 511, 13, 462, 632, 313, 29900, 29916, 28062, 29892, 29871, 29900, 29916, 29900, 29900, 29892, 29871, 29900, 29916, 28062, 511, 13, 462, 632, 313, 29900, 29916, 29923, 29955, 29892, 29871, 29900, 29916, 29900, 29900, 29892, 29871, 29900, 29916, 29945, 29933, 511, 13, 462, 632, 313, 29900, 29916, 4051, 29892, 29871, 29900, 29916, 29906, 29933, 29892, 29871, 29900, 29916, 29900, 29900, 511, 13, 462, 632, 313, 29900, 29916, 21685, 29892, 29871, 29900, 29916, 29946, 29943, 29892, 29871, 29900, 29916, 29900, 29943, 511, 13, 462, 632, 313, 29900, 29916, 29947, 29933, 29892, 29871, 29900, 29916, 29955, 29941, 29892, 29871, 29900, 29916, 29900, 29900, 511, 13, 462, 632, 313, 29900, 29916, 29900, 29900, 29892, 29871, 29900, 29916, 29929, 29955, 29892, 29871, 29900, 29916, 29900, 29900, 511, 13, 462, 632, 313, 29900, 29916, 29900, 29900, 29892, 29871, 29900, 29916, 2882, 29892, 29871, 29900, 29916, 29900, 29900, 511, 13, 462, 632, 313, 29900, 29916, 29900, 29900, 29892, 29871, 29900, 29916, 29929, 29941, 29892, 29871, 29900, 29916, 29941, 29933, 511, 13, 462, 632, 313, 29900, 29916, 29900, 29900, 29892, 29871, 29900, 29916, 29947, 29941, 29892, 29871, 29900, 29916, 29947, 29933, 511, 13, 462, 632, 313, 29900, 29916, 29900, 29900, 29892, 29871, 29900, 29916, 29900, 29900, 29892, 29871, 29900, 29916, 29900, 29900, 511, 13, 462, 632, 313, 29900, 29916, 29900, 29900, 29892, 29871, 29900, 29916, 29900, 29900, 29892, 29871, 29900, 29916, 29900, 29900, 511, 13, 462, 632, 313, 29900, 29916, 29900, 29900, 29892, 29871, 29900, 29916, 29900, 29900, 29892, 29871, 29900, 29916, 29900, 29900, 511, 13, 462, 632, 313, 29900, 29916, 4198, 29892, 29871, 29900, 29916, 4198, 29892, 29871, 29900, 29916, 4198, 511, 13, 462, 632, 313, 29900, 29916, 29941, 29943, 29892, 29871, 29900, 29916, 28062, 29892, 29871, 29900, 29916, 4198, 511, 13, 462, 632, 313, 29900, 29916, 29945, 29943, 29892, 29871, 29900, 29916, 29929, 29955, 29892, 29871, 29900, 29916, 4198, 511, 13, 462, 632, 313, 29900, 29916, 29909, 29955, 29892, 29871, 29900, 29916, 29947, 29933, 29892, 29871, 29900, 29916, 26453, 511, 13, 462, 632, 313, 29900, 29916, 29943, 29955, 29892, 29871, 29900, 29916, 29955, 29933, 29892, 29871, 29900, 29916, 4198, 511, 13, 462, 632, 313, 29900, 29916, 4198, 29892, 29871, 29900, 29916, 29955, 29955, 29892, 29871, 29900, 29916, 29933, 29955, 511, 13, 462, 632, 313, 29900, 29916, 4198, 29892, 29871, 29900, 29916, 29955, 29955, 29892, 29871, 29900, 29916, 29953, 29941, 511, 13, 462, 632, 313, 29900, 29916, 4198, 29892, 29871, 29900, 29916, 29929, 29933, 29892, 29871, 29900, 29916, 29941, 29933, 511, 13, 462, 632, 313, 29900, 29916, 29943, 29941, 29892, 29871, 29900, 29916, 28062, 29892, 29871, 29900, 29916, 29941, 29943, 511, 13, 462, 632, 313, 29900, 29916, 29947, 29941, 29892, 29871, 29900, 29916, 29928, 29941, 29892, 29871, 29900, 29916, 29896, 29941, 511, 13, 462, 632, 313, 29900, 29916, 29946, 29943, 29892, 29871, 29900, 29916, 4037, 29892, 29871, 29900, 29916, 29946, 29933, 511, 13, 462, 632, 313, 29900, 29916, 29945, 29947, 29892, 29871, 29900, 29916, 29943, 29947, 29892, 29871, 29900, 29916, 29929, 29947, 511, 13, 462, 632, 313, 29900, 29916, 29900, 29900, 29892, 29871, 29900, 29916, 25752, 29892, 29871, 29900, 29916, 4051, 511, 13, 462, 632, 313, 29900, 29916, 29900, 29900, 29892, 29871, 29900, 29916, 29900, 29900, 29892, 29871, 29900, 29916, 29900, 29900, 511, 13, 462, 632, 313, 29900, 29916, 29900, 29900, 29892, 29871, 29900, 29916, 29900, 29900, 29892, 29871, 29900, 29916, 29900, 29900, 511, 13, 462, 632, 313, 29900, 29916, 29900, 29900, 29892, 29871, 29900, 29916, 29900, 29900, 29892, 29871, 29900, 29916, 29900, 29900, 511, 13, 462, 632, 313, 29900, 29916, 4198, 29892, 29871, 29900, 29916, 4198, 29892, 29871, 29900, 29916, 4198, 511, 13, 462, 632, 313, 29900, 29916, 2882, 29892, 29871, 29900, 29916, 29923, 29955, 29892, 29871, 29900, 29916, 4198, 511, 13, 462, 632, 313, 29900, 29916, 29907, 29955, 29892, 29871, 29900, 29916, 29928, 29955, 29892, 29871, 29900, 29916, 4198, 511, 13, 462, 632, 313, 29900, 29916, 29928, 29955, 29892, 29871, 29900, 29916, 21685, 29892, 29871, 29900, 29916, 4198, 511, 13, 462, 632, 313, 29900, 29916, 4198, 29892, 29871, 29900, 29916, 29907, 29955, 29892, 29871, 29900, 29916, 4198, 511, 13, 462, 632, 313, 29900, 29916, 4198, 29892, 29871, 29900, 29916, 29907, 29955, 29892, 29871, 29900, 29916, 4051, 511, 13, 462, 632, 313, 29900, 29916, 4198, 29892, 29871, 29900, 29916, 28062, 29892, 29871, 29900, 29916, 29933, 29941, 511, 13, 462, 632, 313, 29900, 29916, 4198, 29892, 29871, 29900, 29916, 4051, 29892, 29871, 29900, 29916, 2882, 511, 13, 462, 632, 313, 29900, 29916, 4198, 29892, 29871, 29900, 29916, 29923, 29955, 29892, 29871, 29900, 29916, 29909, 29941, 511, 13, 462, 632, 313, 29900, 29916, 29923, 29941, 29892, 29871, 29900, 29916, 4198, 29892, 29871, 29900, 29916, 29909, 29941, 511, 13, 462, 632, 313, 29900, 29916, 2882, 29892, 29871, 29900, 29916, 29943, 29941, 29892, 29871, 29900, 29916, 28062, 511, 13, 462, 632, 313, 29900, 29916, 29933, 29941, 29892, 29871, 29900, 29916, 4198, 29892, 29871, 29900, 29916, 9207, 511, 13, 462, 632, 313, 29900, 29916, 29929, 29943, 29892, 29871, 29900, 29916, 4198, 29892, 29871, 29900, 29916, 29943, 29941, 511, 13, 462, 632, 313, 29900, 29916, 29900, 29900, 29892, 29871, 29900, 29916, 29900, 29900, 29892, 29871, 29900, 29916, 29900, 29900, 511, 13, 462, 632, 313, 29900, 29916, 29900, 29900, 29892, 29871, 29900, 29916, 29900, 29900, 29892, 29871, 29900, 29916, 29900, 29900, 511, 13, 462, 632, 313, 29900, 29916, 29900, 29900, 29892, 29871, 29900, 29916, 29900, 29900, 29892, 29871, 29900, 29916, 29900, 29900, 4638, 13, 13, 4706, 396, 2202, 29901, 13, 4706, 1583, 29889, 9482, 261, 353, 26000, 261, 3260, 29898, 1311, 29889, 11058, 29889, 29934, 1430, 8032, 1001, 29918, 11116, 29897, 13, 4706, 396, 19499, 29901, 13, 4706, 396, 1678, 1596, 4852, 29089, 11905, 26000, 261, 1159, 13, 13, 4706, 1583, 29889, 29963, 13367, 2190, 29968, 353, 1583, 29889, 29963, 10358, 804, 29898, 1311, 29889, 11058, 29897, 13, 4706, 1583, 29889, 29963, 25058, 353, 1583, 29889, 13072, 24285, 16015, 29898, 29900, 29916, 29896, 29900, 29900, 29900, 29900, 29897, 13, 4706, 1583, 29889, 5550, 29934, 25058, 353, 1583, 29889, 13072, 24285, 16015, 29898, 29900, 29916, 29896, 29900, 29900, 29897, 13, 13, 4706, 1583, 29889, 1359, 29918, 29894, 2572, 29918, 1272, 580, 13, 4706, 1583, 29889, 842, 29924, 381, 729, 292, 29898, 1311, 29889, 11058, 29889, 13823, 8605, 29889, 11038, 729, 29897, 13, 13, 4706, 2428, 29898, 29925, 7056, 29892, 1583, 467, 1649, 2344, 1649, 580, 13, 13, 1678, 822, 2254, 29918, 29894, 2572, 29918, 1272, 29898, 1311, 1125, 13, 4706, 4236, 1272, 353, 1583, 29889, 11058, 29889, 13823, 8605, 29889, 22495, 29934, 290, 1469, 17255, 2435, 1649, 580, 13, 4706, 413, 353, 29871, 29900, 13, 4706, 1550, 413, 529, 4236, 1272, 29901, 13, 9651, 325, 353, 1583, 29889, 11058, 29889, 13823, 8605, 29889, 22495, 29934, 290, 1469, 29961, 29895, 29962, 13, 9651, 1583, 29889, 29963, 25058, 29889, 3539, 29898, 29895, 29892, 325, 29897, 13, 9651, 413, 4619, 29871, 29896, 13, 4706, 1583, 29889, 9482, 261, 29889, 4990, 29889, 12071, 580, 13, 13, 1678, 822, 731, 29924, 381, 729, 292, 29898, 1311, 29892, 19571, 292, 1125, 13, 4706, 396, 29871, 29900, 353, 14698, 19571, 292, 13, 4706, 396, 29871, 29896, 353, 11408, 19571, 292, 13, 4706, 1583, 29889, 407, 29884, 29924, 381, 729, 292, 353, 19571, 292, 13, 4706, 1583, 29889, 7328, 29924, 381, 729, 292, 353, 29871, 29900, 29916, 29946, 29900, 29900, 3532, 1583, 29889, 407, 29884, 29924, 381, 729, 292, 13, 13, 1678, 822, 1889, 4809, 4597, 29896, 29898, 1311, 29892, 995, 1125, 13, 4706, 396, 5399, 9978, 29871, 29900, 29899, 29896, 13, 4706, 3479, 353, 995, 669, 29871, 29900, 29916, 29941, 13, 4706, 565, 3479, 1275, 29871, 29900, 29901, 13, 9651, 1583, 29889, 978, 3562, 7061, 353, 29871, 29900, 29916, 29906, 29900, 29900, 29900, 13, 4706, 25342, 3479, 1275, 29871, 29896, 29901, 13, 9651, 1583, 29889, 978, 3562, 7061, 353, 29871, 29900, 29916, 29906, 29946, 29900, 29900, 13, 4706, 25342, 3479, 1275, 29871, 29906, 29901, 13, 9651, 1583, 29889, 978, 3562, 7061, 353, 29871, 29900, 29916, 29906, 29947, 29900, 29900, 13, 4706, 1683, 29901, 13, 9651, 1583, 29889, 978, 3562, 7061, 353, 29871, 29900, 29916, 29906, 29907, 29900, 29900, 13, 13, 4706, 396, 5399, 2586, 29871, 29906, 13, 4706, 565, 995, 669, 313, 29896, 3532, 29871, 29906, 1125, 13, 9651, 1583, 29889, 25629, 7061, 353, 29871, 29941, 29906, 13, 4706, 1683, 29901, 13, 9651, 1583, 29889, 25629, 7061, 353, 29871, 29896, 13, 13, 4706, 396, 5399, 2586, 29871, 29941, 13, 4706, 565, 995, 669, 313, 29896, 3532, 29871, 29941, 1125, 13, 9651, 1583, 29889, 15099, 568, 17144, 3562, 353, 29871, 29900, 29916, 29896, 29900, 29900, 29900, 13, 4706, 1683, 29901, 13, 9651, 1583, 29889, 15099, 568, 17144, 3562, 353, 29871, 29900, 29916, 29900, 29900, 29900, 29900, 13, 13, 4706, 396, 5399, 2586, 29871, 29946, 13, 4706, 565, 995, 669, 313, 29896, 3532, 29871, 29946, 1125, 13, 9651, 1583, 29889, 7042, 17144, 3562, 353, 29871, 29900, 29916, 29896, 29900, 29900, 29900, 13, 4706, 1683, 29901, 13, 9651, 1583, 29889, 7042, 17144, 3562, 353, 29871, 29900, 29916, 29900, 29900, 29900, 29900, 13, 13, 4706, 396, 5399, 2586, 29871, 29945, 13, 4706, 565, 995, 669, 313, 29896, 3532, 29871, 29945, 1125, 13, 9651, 1583, 29889, 15099, 568, 3505, 353, 29871, 29896, 29953, 13, 4706, 1683, 29901, 13, 9651, 1583, 29889, 15099, 568, 3505, 353, 29871, 29947, 13, 13, 4706, 396, 18531, 29871, 29953, 451, 1304, 13, 4706, 396, 5399, 2586, 29871, 29955, 13, 4706, 565, 995, 669, 313, 29896, 3532, 29871, 29955, 1125, 13, 9651, 1583, 29889, 29940, 10403, 353, 5852, 13, 4706, 1683, 29901, 13, 9651, 1583, 29889, 29940, 10403, 353, 7700, 13, 13, 1678, 822, 1889, 4809, 4597, 29906, 29898, 1311, 29892, 995, 1125, 13, 4706, 396, 5399, 2586, 29871, 29900, 13, 4706, 565, 995, 669, 29871, 29896, 29901, 13, 9651, 1583, 29889, 2780, 6818, 353, 5852, 13, 4706, 1683, 29901, 13, 9651, 1583, 29889, 2780, 6818, 353, 7700, 13, 13, 4706, 396, 5399, 2586, 29871, 29896, 13, 4706, 565, 995, 669, 313, 29896, 3532, 29871, 29896, 1125, 13, 9651, 1583, 29889, 11303, 3262, 10581, 353, 5852, 13, 4706, 1683, 29901, 13, 9651, 1583, 29889, 11303, 3262, 10581, 353, 7700, 13, 13, 4706, 396, 5399, 2586, 29871, 29906, 13, 4706, 565, 995, 669, 313, 29896, 3532, 29871, 29906, 1125, 13, 9651, 1583, 29889, 11303, 3262, 29903, 558, 3246, 353, 5852, 13, 4706, 1683, 29901, 13, 9651, 1583, 29889, 11303, 3262, 29903, 558, 3246, 353, 7700, 13, 13, 4706, 396, 5399, 2586, 29871, 29941, 13, 4706, 565, 995, 669, 313, 29896, 3532, 29871, 29941, 1125, 13, 9651, 1583, 29889, 4294, 10581, 353, 5852, 13, 4706, 1683, 29901, 13, 9651, 1583, 29889, 4294, 10581, 353, 7700, 13, 13, 4706, 396, 5399, 2586, 29871, 29946, 13, 4706, 565, 995, 669, 313, 29896, 3532, 29871, 29946, 1125, 13, 9651, 1583, 29889, 4294, 29903, 558, 3246, 353, 5852, 13, 4706, 1683, 29901, 13, 9651, 1583, 29889, 4294, 29903, 558, 3246, 353, 7700, 13, 13, 4706, 396, 5399, 9978, 29871, 29945, 29899, 29955, 13, 4706, 1583, 29889, 2780, 2928, 575, 537, 353, 995, 5099, 29871, 29945, 13, 13, 1678, 396, 1889, 6036, 29871, 29900, 29916, 29906, 29900, 29900, 29945, 13, 1678, 822, 1889, 18009, 3308, 29907, 1672, 2208, 29898, 1311, 29892, 995, 1125, 13, 4706, 565, 1583, 29889, 4102, 6113, 29901, 13, 9651, 1583, 29889, 407, 29884, 10463, 29990, 353, 995, 13, 9651, 1583, 29889, 4102, 6113, 353, 7700, 13, 4706, 1683, 29901, 13, 9651, 1583, 29889, 407, 29884, 10463, 29979, 353, 995, 13, 9651, 1583, 29889, 4102, 6113, 353, 5852, 13, 13, 1678, 396, 1889, 6036, 29871, 29900, 29916, 29906, 29900, 29900, 29953, 13, 1678, 822, 1889, 29925, 7056, 3035, 8353, 29898, 1311, 29892, 995, 1125, 13, 4706, 565, 1583, 29889, 4102, 6113, 29901, 13, 9651, 1583, 29889, 29963, 4717, 1529, 1289, 1253, 353, 313, 1767, 669, 29871, 29900, 29916, 4198, 29897, 3532, 29871, 29947, 13, 9651, 1583, 29889, 4102, 6113, 353, 7700, 13, 4706, 1683, 29901, 13, 9651, 1583, 29889, 29963, 4717, 1529, 1289, 1253, 4619, 313, 1767, 669, 29871, 29900, 29916, 4198, 29897, 13, 9651, 1583, 29889, 4102, 6113, 353, 5852, 13, 13, 1678, 396, 1889, 6036, 29871, 29900, 29916, 29906, 29900, 29900, 29955, 313, 3539, 29897, 13, 1678, 822, 2436, 29963, 25058, 29898, 1311, 29892, 995, 1125, 13, 4706, 396, 29911, 8144, 29901, 1798, 928, 279, 409, 7444, 5147, 517, 13, 4706, 396, 4408, 3562, 2436, 19571, 292, 29889, 13, 4706, 565, 1583, 29889, 29963, 4717, 1529, 1289, 1253, 6736, 29871, 29900, 29916, 29906, 29900, 29900, 29900, 322, 1583, 29889, 29963, 4717, 1529, 1289, 1253, 529, 29871, 29900, 29916, 29941, 29943, 29900, 29900, 29901, 13, 9651, 1583, 29889, 29963, 25058, 29889, 3539, 29898, 1311, 29889, 29963, 4717, 1529, 1289, 1253, 718, 1583, 29889, 7328, 29924, 381, 729, 292, 29892, 995, 29897, 13, 9651, 1583, 29889, 29963, 25058, 29889, 3539, 29898, 1311, 29889, 29963, 4717, 1529, 1289, 1253, 29892, 995, 29897, 13, 4706, 396, 9159, 3793, 2810, 2436, 19571, 292, 29889, 13, 4706, 25342, 1583, 29889, 29963, 4717, 1529, 1289, 1253, 6736, 29871, 29900, 29916, 29941, 29943, 29900, 29900, 322, 1583, 29889, 29963, 4717, 1529, 1289, 1253, 529, 29871, 29900, 29916, 29941, 29943, 29906, 29900, 29901, 13, 9651, 565, 1583, 29889, 29963, 4717, 1529, 1289, 1253, 1275, 29871, 29900, 29916, 29941, 29943, 29900, 29900, 470, 1583, 29889, 29963, 4717, 1529, 1289, 1253, 1275, 29871, 29900, 29916, 29941, 29943, 29896, 29900, 29901, 13, 18884, 1583, 29889, 29963, 25058, 29889, 3539, 29898, 29900, 29916, 29941, 29943, 29900, 29900, 29892, 995, 29897, 13, 18884, 1583, 29889, 29963, 25058, 29889, 3539, 29898, 29900, 29916, 29941, 29943, 29900, 29946, 29892, 995, 29897, 13, 18884, 1583, 29889, 29963, 25058, 29889, 3539, 29898, 29900, 29916, 29941, 29943, 29900, 29947, 29892, 995, 29897, 13, 18884, 1583, 29889, 29963, 25058, 29889, 3539, 29898, 29900, 29916, 29941, 29943, 29900, 29907, 29892, 995, 29897, 13, 18884, 1583, 29889, 29963, 25058, 29889, 3539, 29898, 29900, 29916, 29941, 29943, 29896, 29900, 29892, 995, 29897, 13, 18884, 1583, 29889, 29963, 25058, 29889, 3539, 29898, 29900, 29916, 29941, 29943, 29896, 29946, 29892, 995, 29897, 13, 18884, 1583, 29889, 29963, 25058, 29889, 3539, 29898, 29900, 29916, 29941, 29943, 29896, 29947, 29892, 995, 29897, 13, 18884, 1583, 29889, 29963, 25058, 29889, 3539, 29898, 29900, 29916, 29941, 29943, 29896, 29907, 29892, 995, 29897, 13, 9651, 1683, 29901, 13, 18884, 1583, 29889, 29963, 25058, 29889, 3539, 29898, 1311, 29889, 29963, 4717, 1529, 1289, 1253, 29892, 995, 29897, 13, 13, 4706, 1583, 29889, 29963, 4717, 1529, 1289, 1253, 4619, 1583, 29889, 25629, 7061, 13, 13, 1678, 396, 1889, 6036, 29871, 29900, 29916, 29906, 29900, 29900, 29955, 313, 949, 29897, 13, 1678, 822, 1303, 29963, 25058, 29898, 1311, 1125, 13, 4706, 995, 353, 29871, 29900, 13, 4706, 3211, 353, 1583, 29889, 29963, 4717, 1529, 1289, 1253, 669, 29871, 29900, 29916, 29941, 4198, 29943, 13, 4706, 565, 3211, 6736, 29871, 29900, 29916, 29941, 29943, 29900, 29900, 322, 3211, 529, 29871, 29900, 29916, 29946, 29900, 29900, 29900, 29901, 13, 9651, 3211, 353, 29871, 29900, 29916, 29941, 29943, 29900, 29900, 718, 313, 7328, 669, 29871, 29900, 29916, 29943, 29897, 13, 9651, 1583, 29889, 29963, 25058, 7701, 353, 1583, 29889, 29963, 25058, 29889, 949, 29898, 7328, 29897, 13, 9651, 995, 353, 1583, 29889, 29963, 25058, 29889, 949, 29898, 7328, 29897, 13, 4706, 25342, 3211, 529, 29871, 29900, 29916, 29941, 29943, 29900, 29900, 29901, 13, 9651, 995, 353, 1583, 29889, 29963, 25058, 7701, 13, 9651, 1583, 29889, 29963, 25058, 7701, 353, 1583, 29889, 29963, 25058, 29889, 949, 29898, 7328, 29897, 13, 4706, 1583, 29889, 29963, 4717, 1529, 1289, 1253, 4619, 1583, 29889, 25629, 7061, 13, 13, 4706, 736, 995, 13, 13, 1678, 822, 2436, 29903, 558, 29934, 314, 29898, 1311, 29892, 995, 1125, 13, 4706, 1583, 29889, 5550, 29934, 25058, 29889, 3539, 29898, 1311, 29889, 15099, 568, 29934, 314, 2528, 29878, 29892, 1767, 29897, 13, 4706, 1583, 29889, 15099, 568, 29934, 314, 2528, 29878, 353, 313, 1311, 29889, 15099, 568, 29934, 314, 2528, 29878, 718, 29871, 29896, 29897, 669, 29871, 29900, 29916, 4198, 13, 13, 1678, 822, 2436, 29903, 558, 29934, 314, 29928, 1529, 29898, 1311, 29892, 995, 1125, 13, 4706, 3211, 353, 995, 334, 29871, 29900, 29916, 29896, 29900, 29900, 13, 13, 4706, 474, 353, 29871, 29900, 13, 4706, 1550, 474, 529, 29871, 29906, 29945, 29953, 29901, 13, 9651, 1583, 29889, 5550, 29934, 25058, 29889, 3539, 29898, 29875, 29892, 1583, 29889, 11058, 29889, 6271, 29965, 29889, 25058, 29889, 949, 29898, 7328, 876, 13, 9651, 3211, 4619, 29871, 29896, 13, 9651, 474, 4619, 29871, 29896, 13, 13, 1678, 822, 1303, 5709, 21979, 29898, 1311, 1125, 13, 4706, 995, 353, 29871, 29900, 13, 4706, 995, 891, 29922, 313, 1311, 29889, 29894, 29934, 314, 29956, 768, 267, 3532, 29871, 29946, 29897, 13, 4706, 995, 891, 29922, 313, 1311, 29889, 16192, 1220, 29903, 558, 568, 3981, 3532, 29871, 29945, 29897, 13, 4706, 995, 891, 29922, 313, 1311, 29889, 15099, 568, 29900, 29950, 277, 3532, 29871, 29953, 29897, 13, 4706, 995, 891, 29922, 313, 524, 29898, 1311, 29889, 29963, 13367, 2190, 29968, 29889, 4882, 29897, 3532, 29871, 29955, 29897, 13, 13, 4706, 1583, 29889, 4102, 6113, 353, 5852, 13, 4706, 1583, 29889, 29963, 13367, 2190, 29968, 29889, 13322, 580, 13, 13, 4706, 736, 995, 13, 13, 1678, 822, 437, 29083, 1220, 29898, 1311, 1125, 13, 13, 4706, 565, 1583, 29889, 4294, 10581, 29901, 13, 9651, 1583, 29889, 4012, 10581, 29898, 1311, 29889, 11058, 29889, 6271, 29965, 29889, 16192, 1220, 29897, 13, 13, 4706, 565, 1583, 29889, 4294, 29903, 558, 3246, 29901, 13, 9651, 1583, 29889, 4012, 29903, 558, 3246, 29898, 1311, 29889, 11058, 29889, 6271, 29965, 29889, 16192, 1220, 29897, 13, 632, 13, 13, 1678, 822, 4216, 10581, 29898, 1311, 29892, 12812, 1220, 1125, 13, 4706, 25900, 29979, 353, 938, 29898, 16192, 1220, 847, 29871, 29947, 29897, 13, 4706, 612, 353, 938, 29898, 16192, 1220, 1273, 29871, 29947, 29897, 13, 13, 4706, 4236, 29911, 5475, 353, 29871, 29941, 29906, 13, 4706, 565, 313, 1311, 29889, 407, 29884, 10463, 29990, 1273, 29871, 29947, 29897, 2804, 29871, 29900, 29901, 13, 9651, 4236, 29911, 5475, 353, 29871, 29941, 29941, 13, 13, 4706, 1857, 29911, 488, 353, 938, 29898, 1311, 29889, 407, 29884, 10463, 29990, 847, 29871, 29947, 29897, 13, 4706, 325, 353, 938, 29898, 1311, 29889, 978, 3562, 7061, 718, 1857, 29911, 488, 29897, 13, 4706, 15526, 353, 29871, 29900, 13, 13, 4706, 937, 353, 29871, 29900, 565, 1583, 29889, 11303, 3262, 10581, 1683, 29871, 29896, 13, 4706, 260, 5475, 353, 1409, 877, 29933, 742, 1051, 29898, 3881, 29898, 4102, 29892, 4236, 29911, 5475, 4961, 13, 4706, 363, 474, 297, 260, 5475, 29901, 13, 13, 9651, 515, 12901, 353, 29871, 29900, 13, 9651, 304, 12901, 353, 29871, 29947, 13, 13, 9651, 282, 3746, 10463, 21979, 353, 313, 1311, 29889, 407, 29884, 10463, 29990, 1273, 29947, 29897, 13, 9651, 565, 282, 3746, 10463, 21979, 2804, 29871, 29900, 29901, 13, 18884, 565, 474, 1275, 29871, 29900, 29901, 13, 462, 1678, 304, 12901, 353, 29871, 29955, 448, 313, 407, 29884, 10463, 21979, 29897, 13, 18884, 565, 474, 1275, 313, 3317, 29911, 5475, 448, 29871, 29896, 1125, 13, 462, 1678, 515, 12901, 353, 29871, 29947, 448, 313, 407, 29884, 10463, 21979, 29897, 13, 13, 9651, 23246, 7061, 353, 1583, 29889, 29963, 25058, 29889, 949, 29898, 29894, 718, 938, 29898, 29873, 488, 29979, 29930, 29900, 29916, 29906, 29900, 876, 13, 9651, 4766, 29896, 353, 1583, 29889, 29963, 25058, 29889, 949, 29898, 1311, 29889, 7042, 17144, 3562, 718, 313, 7414, 7061, 29930, 29896, 29953, 29897, 718, 612, 29897, 13, 9651, 4766, 29906, 353, 1583, 29889, 29963, 25058, 29889, 949, 29898, 1311, 29889, 7042, 17144, 3562, 718, 313, 7414, 7061, 29930, 29896, 29953, 29897, 718, 612, 718, 29871, 29947, 29897, 13, 9651, 396, 2908, 29990, 321, 2908, 29979, 872, 29877, 408, 1302, 10934, 3922, 953, 10208, 1113, 29877, 5017, 2908, 13, 9651, 2908, 29990, 353, 474, 1273, 29871, 29946, 13, 9651, 2908, 29979, 353, 25900, 29979, 1273, 29871, 29946, 13, 9651, 2908, 353, 938, 29898, 29875, 847, 29871, 29946, 29897, 718, 313, 524, 29898, 29873, 488, 29979, 847, 29871, 29946, 29897, 334, 29871, 29947, 29897, 13, 9651, 3211, 12901, 353, 938, 3552, 29894, 669, 3695, 29900, 29916, 29900, 29900, 29896, 29943, 29897, 718, 29871, 29900, 29916, 29900, 29941, 29907, 29900, 718, 2908, 29897, 13, 9651, 7023, 6708, 3562, 353, 1583, 29889, 29963, 25058, 29889, 949, 29898, 7328, 12901, 29897, 13, 9651, 2927, 3220, 353, 29871, 29900, 29916, 29941, 29943, 29900, 29900, 13, 13, 9651, 565, 2908, 29990, 529, 29871, 29906, 29901, 13, 18884, 565, 2908, 29979, 6736, 29871, 29906, 29901, 13, 462, 1678, 2927, 3220, 891, 29922, 5135, 10389, 6708, 3562, 669, 29871, 29900, 29890, 29896, 29896, 29900, 29900, 29900, 29900, 29897, 5099, 29871, 29946, 29897, 3532, 29871, 29906, 13, 18884, 1683, 29901, 13, 462, 1678, 2927, 3220, 891, 29922, 313, 10389, 6708, 3562, 669, 29871, 29900, 29890, 29896, 29896, 29897, 3532, 29871, 29906, 13, 9651, 25342, 2908, 29990, 6736, 29871, 29906, 322, 2908, 29979, 529, 29871, 29906, 29901, 13, 18884, 2927, 3220, 891, 29922, 5135, 10389, 6708, 3562, 669, 29871, 29900, 29890, 29896, 29896, 29900, 29900, 29897, 5099, 29871, 29906, 29897, 3532, 29871, 29906, 13, 9651, 1683, 29901, 13, 18884, 2927, 3220, 891, 29922, 5135, 10389, 6708, 3562, 669, 29871, 29900, 29890, 29896, 29896, 29900, 29900, 29900, 29900, 29900, 29900, 29897, 5099, 29871, 29953, 29897, 3532, 29871, 29906, 13, 13, 9651, 413, 353, 1409, 877, 29933, 742, 1051, 29898, 3881, 29898, 3166, 12901, 29892, 304, 12901, 4961, 13, 9651, 363, 432, 297, 413, 29901, 13, 18884, 2586, 29896, 353, 5135, 29896, 3532, 432, 29897, 669, 4766, 29896, 29897, 5099, 432, 13, 18884, 2586, 29906, 353, 5135, 29896, 3532, 432, 29897, 669, 4766, 29906, 29897, 5099, 432, 13, 18884, 2927, 3220, 15790, 353, 2927, 3220, 13, 18884, 2927, 3220, 15790, 891, 29922, 5135, 2966, 29906, 3532, 29871, 29896, 29897, 891, 2586, 29896, 29897, 13, 13, 18884, 2927, 353, 1583, 29889, 2780, 18210, 2810, 29961, 1311, 29889, 29963, 25058, 29889, 949, 29898, 2780, 3220, 15790, 4638, 13, 18884, 921, 353, 313, 29886, 15711, 718, 5135, 29926, 334, 8521, 29896, 876, 718, 313, 517, 12901, 448, 515, 12901, 29897, 448, 29871, 29896, 876, 13, 18884, 343, 353, 12812, 1220, 13, 13, 18884, 565, 313, 13193, 29898, 2780, 29897, 2804, 1583, 29889, 9482, 261, 29889, 4990, 29889, 18799, 1001, 29918, 29933, 29889, 949, 29898, 29916, 29892, 343, 22164, 13, 462, 1678, 1583, 29889, 9482, 261, 29889, 4990, 29889, 18799, 1001, 29918, 29933, 29889, 3539, 29898, 29916, 29892, 343, 29892, 2927, 29897, 13, 18884, 432, 4619, 29871, 29896, 13, 13, 9651, 15526, 4619, 304, 12901, 448, 515, 12901, 13, 13, 9651, 565, 313, 29894, 669, 29871, 29900, 29916, 29900, 29900, 29896, 29888, 29897, 1275, 29871, 29941, 29896, 29901, 13, 18884, 325, 7878, 3695, 29900, 29916, 29900, 29900, 29896, 29943, 13, 18884, 396, 29894, 6228, 29922, 1583, 29889, 7328, 29924, 381, 729, 292, 13, 18884, 325, 6228, 29922, 29871, 29900, 29916, 29946, 29900, 29900, 13, 9651, 1683, 29901, 13, 18884, 325, 4619, 29871, 29896, 13, 9651, 628, 413, 13, 4706, 628, 260, 5475, 13, 13, 1678, 822, 4216, 29903, 558, 3246, 29898, 1311, 29892, 12812, 1220, 1125, 13, 4706, 1353, 29903, 558, 3246, 5894, 29083, 1220, 353, 29871, 29900, 13, 4706, 612, 353, 12812, 1220, 1273, 29871, 29947, 13, 4706, 16723, 29949, 5194, 353, 1409, 877, 29933, 742, 518, 29900, 29916, 4198, 29962, 334, 29871, 29941, 29906, 29897, 13, 4706, 2380, 11863, 653, 29949, 5194, 353, 29871, 29900, 13, 13, 4706, 413, 353, 1409, 877, 29933, 742, 1051, 29898, 3881, 29898, 29900, 29892, 29871, 29906, 29945, 29953, 29892, 29871, 29946, 4961, 13, 4706, 363, 1857, 29903, 558, 568, 297, 413, 29901, 13, 9651, 29227, 29979, 353, 1583, 29889, 5550, 29934, 25058, 29889, 949, 29898, 3784, 29903, 558, 568, 29897, 13, 13, 9651, 565, 1353, 29903, 558, 3246, 5894, 29083, 1220, 1275, 29871, 29947, 29901, 13, 18884, 2867, 13, 13, 9651, 565, 29227, 29979, 5277, 12812, 1220, 529, 29227, 29979, 718, 1583, 29889, 15099, 568, 3505, 29901, 13, 18884, 7689, 7888, 353, 1409, 877, 29933, 742, 1051, 29898, 3881, 29898, 29946, 4961, 13, 18884, 363, 474, 297, 7689, 7888, 29901, 13, 462, 1678, 16723, 29949, 5194, 29961, 2248, 11863, 653, 29949, 5194, 718, 474, 29962, 353, 1583, 29889, 5550, 29934, 25058, 29889, 949, 29898, 3784, 29903, 558, 568, 29974, 29875, 29897, 13, 18884, 2380, 11863, 653, 29949, 5194, 4619, 29871, 29946, 13, 18884, 1353, 29903, 558, 3246, 5894, 29083, 1220, 4619, 29871, 29896, 13, 18884, 628, 7689, 7888, 13, 4706, 628, 413, 13, 13, 4706, 413, 353, 1409, 877, 29933, 742, 1051, 29898, 3881, 29898, 29906, 29947, 29892, 448, 29896, 29892, 448, 29946, 4961, 13, 4706, 363, 1857, 29903, 558, 568, 297, 413, 29901, 13, 9651, 29227, 29990, 353, 16723, 29949, 5194, 29961, 3784, 29903, 558, 568, 718, 29871, 29941, 29962, 13, 9651, 29227, 29979, 353, 16723, 29949, 5194, 29961, 3784, 29903, 558, 568, 29962, 13, 13, 9651, 565, 29227, 29979, 6736, 29871, 29900, 29916, 29638, 470, 29227, 29990, 6736, 29871, 29900, 29916, 29943, 29929, 29901, 13, 18884, 6773, 13, 13, 9651, 1857, 29903, 558, 568, 7061, 353, 1857, 29903, 558, 568, 718, 29871, 29906, 13, 9651, 285, 3466, 29270, 353, 16723, 29949, 5194, 29961, 3784, 29903, 558, 568, 7061, 29962, 669, 29871, 29900, 29916, 29947, 29900, 13, 9651, 285, 3466, 24932, 353, 16723, 29949, 5194, 29961, 3784, 29903, 558, 568, 7061, 29962, 669, 29871, 29900, 29916, 29946, 29900, 13, 13, 9651, 612, 353, 12812, 1220, 448, 29227, 29979, 13, 13, 9651, 23246, 7061, 353, 16723, 29949, 5194, 29961, 3784, 29903, 558, 568, 718, 29871, 29896, 29962, 13, 9651, 2373, 7061, 353, 1583, 29889, 15099, 568, 17144, 3562, 718, 313, 7414, 7061, 334, 29871, 29896, 29953, 29897, 718, 5135, 29955, 448, 612, 29897, 565, 285, 3466, 29270, 1683, 612, 29897, 13, 9651, 4766, 29896, 353, 1583, 29889, 29963, 25058, 29889, 949, 29898, 5031, 7061, 29897, 13, 9651, 4766, 29906, 353, 1583, 29889, 29963, 25058, 29889, 949, 29898, 5031, 7061, 718, 29871, 29947, 29897, 13, 9651, 2927, 3220, 353, 29871, 29900, 29916, 29941, 29943, 29896, 29900, 13, 13, 9651, 2927, 3220, 891, 29922, 5135, 7496, 653, 29949, 5194, 29961, 3784, 29903, 558, 568, 718, 29906, 29962, 669, 29871, 29900, 29916, 29941, 29897, 3532, 29871, 29906, 29897, 13, 13, 9651, 7689, 7888, 353, 1409, 877, 29933, 742, 3464, 29898, 29947, 876, 13, 9651, 363, 432, 297, 7689, 7888, 29901, 13, 18884, 565, 285, 3466, 24932, 29901, 13, 462, 1678, 2927, 3220, 15790, 353, 313, 11037, 29896, 5099, 432, 29897, 669, 29871, 29900, 29916, 29896, 13, 462, 1678, 2927, 3220, 15790, 891, 29922, 5135, 11037, 29906, 5099, 432, 29897, 669, 29871, 29900, 29916, 29896, 1723, 3532, 29871, 29896, 13, 18884, 1683, 29901, 13, 462, 1678, 2927, 3220, 15790, 353, 313, 11037, 29896, 5099, 313, 29955, 448, 432, 876, 669, 29871, 29900, 29916, 29896, 13, 462, 1678, 2927, 3220, 15790, 891, 29922, 5135, 11037, 29906, 5099, 313, 29955, 448, 432, 876, 669, 29871, 29900, 29916, 29896, 29897, 3532, 29871, 29896, 13, 13, 18884, 2927, 3220, 15790, 4619, 2927, 3220, 13, 18884, 565, 313, 2780, 3220, 15790, 1273, 29871, 29946, 29897, 1275, 29871, 29900, 29901, 13, 462, 1678, 2927, 3220, 15790, 353, 29871, 29900, 29916, 29941, 29943, 29900, 29900, 13, 18884, 2927, 353, 1583, 29889, 2780, 18210, 2810, 15625, 1311, 29889, 29963, 25058, 29889, 949, 29898, 2780, 3220, 15790, 29897, 669, 29871, 29900, 29916, 29941, 29943, 4638, 13, 13, 18884, 396, 3462, 4103, 862, 3819, 13, 18884, 565, 2927, 1275, 1583, 29889, 2780, 18210, 2810, 29961, 1311, 29889, 29963, 25058, 29889, 949, 29898, 29900, 29916, 29941, 29943, 29896, 29900, 4638, 29901, 13, 462, 1678, 2927, 4619, 313, 29900, 29892, 29897, 13, 13, 18884, 1583, 29889, 9482, 261, 29889, 4990, 29889, 18799, 1001, 29918, 29909, 29889, 3539, 29898, 15099, 568, 29990, 718, 432, 29892, 29227, 29979, 718, 612, 29892, 2927, 29897, 13, 18884, 1423, 3306, 29922, 1311, 29889, 9482, 261, 29889, 4990, 29889, 18799, 1001, 29918, 29909, 29889, 949, 29898, 15099, 568, 29990, 718, 432, 29892, 29227, 29979, 718, 612, 29897, 13, 18884, 565, 1583, 29889, 4294, 10581, 322, 451, 29898, 1311, 29889, 15099, 568, 29950, 277, 22034, 2955, 29897, 322, 1857, 29903, 558, 568, 1275, 29871, 29900, 322, 1423, 3306, 1275, 6262, 29898, 2780, 1125, 13, 462, 1678, 1583, 29889, 15099, 568, 29900, 29950, 277, 353, 5852, 13, 462, 1678, 1583, 29889, 15099, 568, 29950, 277, 22034, 2955, 353, 5852, 13, 9651, 628, 7689, 7888, 13, 4706, 628, 413, 13, 13, 1678, 822, 1065, 29898, 1311, 1125, 13, 4706, 1596, 703, 29925, 7056, 9280, 1159, 13, 4706, 565, 1583, 29889, 11058, 29889, 4690, 16310, 29918, 20387, 1275, 376, 29903, 4214, 1307, 1115, 13, 9651, 1209, 13, 4706, 1683, 29901, 13, 9651, 1583, 29889, 11058, 29889, 6271, 29965, 353, 1583, 29889, 11058, 29889, 6271, 29965, 13, 9651, 1550, 5852, 29901, 13, 18884, 1583, 29889, 11058, 29889, 6271, 29965, 29889, 355, 29889, 10685, 580, 13, 18884, 1583, 29889, 11058, 29889, 6271, 29965, 29889, 355, 29889, 8551, 580, 13, 18884, 1596, 29898, 1311, 29889, 11058, 29889, 6271, 29965, 29889, 16192, 1220, 29897, 13, 18884, 1583, 29889, 9482, 261, 29889, 4990, 29889, 2204, 277, 580, 13, 18884, 1583, 29889, 11058, 29889, 6271, 29965, 29889, 16192, 1220, 353, 29871, 29900, 13, 2 ]
example/front_end_validator_example/views.py
johnfraney/django-front-end-validators
18
1606067
from django.views.generic import CreateView from .forms import SampleModelForm from .models import SampleModel class SampleModelCreate(CreateView): model = SampleModel form_class = SampleModelForm
[ 1, 515, 9557, 29889, 7406, 29889, 19206, 1053, 6204, 1043, 13, 3166, 869, 9514, 1053, 21029, 3195, 2500, 13, 3166, 869, 9794, 1053, 21029, 3195, 13, 13, 13, 1990, 21029, 3195, 4391, 29898, 4391, 1043, 1125, 13, 1678, 1904, 353, 21029, 3195, 13, 1678, 883, 29918, 1990, 353, 21029, 3195, 2500, 13, 2 ]
src/yellowdog_client/common/server_sent_events/sse4python/chained_thread.py
yellowdog/yellowdog-sdk-python-public
0
105562
<gh_stars>0 from threading import Thread class ChainedThread(Thread): def __init__(self, callback, target): # NOSONAR super(ChainedThread, self).__init__() self.__target = target self.__callback = callback def run(self): try: res = self.__target() finally: del self.__target self.__callback(res)
[ 1, 529, 12443, 29918, 303, 1503, 29958, 29900, 13, 3166, 3244, 292, 1053, 10480, 13, 13, 13, 1990, 678, 7114, 4899, 29898, 4899, 1125, 13, 1678, 822, 4770, 2344, 12035, 1311, 29892, 6939, 29892, 3646, 1125, 259, 396, 11698, 3094, 1718, 13, 4706, 2428, 29898, 1451, 7114, 4899, 29892, 1583, 467, 1649, 2344, 1649, 580, 13, 4706, 1583, 17255, 5182, 353, 3646, 13, 4706, 1583, 17255, 14035, 353, 6939, 13, 13, 1678, 822, 1065, 29898, 1311, 1125, 13, 4706, 1018, 29901, 13, 9651, 620, 353, 1583, 17255, 5182, 580, 13, 4706, 7146, 29901, 13, 9651, 628, 1583, 17255, 5182, 13, 4706, 1583, 17255, 14035, 29898, 690, 29897, 13, 2 ]
forum/migrations/0001_initial.py
michaelyou/One-piece-forum
1
70801
# -*- coding: utf-8 -*- from __future__ import unicode_literals from django.db import models, migrations import django.contrib.auth.models import django.utils.timezone from django.conf import settings import django.core.validators import forum.models class Migration(migrations.Migration): dependencies = [ ('auth', '0006_require_contenttypes_0002'), ] operations = [ migrations.CreateModel( name='ForumUser', fields=[ ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), ('password', models.CharField(max_length=128, verbose_name='password')), ('last_login', models.DateTimeField(null=True, verbose_name='last login', blank=True)), ('is_superuser', models.BooleanField(default=False, help_text='Designates that this user has all permissions without explicitly assigning them.', verbose_name='superuser status')), ('username', models.CharField(error_messages={'unique': 'A user with that username already exists.'}, max_length=30, validators=[django.core.validators.RegexValidator('^[\\w.@+-]+$', 'Enter a valid username. This value may contain only letters, numbers and @/./+/-/_ characters.', 'invalid')], help_text='Required. 30 characters or fewer. Letters, digits and @/./+/-/_ only.', unique=True, verbose_name='username')), ('first_name', models.CharField(max_length=30, verbose_name='first name', blank=True)), ('last_name', models.CharField(max_length=30, verbose_name='last name', blank=True)), ('email', models.EmailField(max_length=254, verbose_name='email address', blank=True)), ('is_staff', models.BooleanField(default=False, help_text='Designates whether the user can log into this admin site.', verbose_name='staff status')), ('is_active', models.BooleanField(default=True, help_text='Designates whether this user should be treated as active. Unselect this instead of deleting accounts.', verbose_name='active')), ('date_joined', models.DateTimeField(default=django.utils.timezone.now, verbose_name='date joined')), ('nickname', models.CharField(max_length=200, null=True, blank=True)), ('avatar', models.CharField(max_length=200, null=True, blank=True)), ('signature', models.CharField(max_length=500, null=True, blank=True)), ('location', models.CharField(max_length=200, null=True, blank=True)), ('website', models.URLField(null=True, blank=True)), ('company', models.CharField(max_length=200, null=True, blank=True)), ('role', models.IntegerField(null=True, blank=True)), ('balance', models.IntegerField(null=True, blank=True)), ('reputation', models.IntegerField(null=True, blank=True)), ('self_intro', models.CharField(max_length=500, null=True, blank=True)), ('updated', models.DateTimeField(null=True, blank=True)), ('twitter', models.CharField(max_length=200, null=True, blank=True)), ('github', models.CharField(max_length=200, null=True, blank=True)), ('douban', models.CharField(max_length=200, null=True, blank=True)), ('groups', models.ManyToManyField(related_query_name='user', related_name='user_set', to='auth.Group', blank=True, help_text='The groups this user belongs to. A user will get all permissions granted to each of their groups.', verbose_name='groups')), ('user_permissions', models.ManyToManyField(related_query_name='user', related_name='user_set', to='auth.Permission', blank=True, help_text='Specific permissions for this user.', verbose_name='user permissions')), ], options={ 'abstract': False, 'verbose_name': 'user', 'verbose_name_plural': 'users', }, managers=[ ('objects', django.contrib.auth.models.UserManager()), ], ), migrations.CreateModel( name='Favorite', fields=[ ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), ('involved_type', models.IntegerField(null=True, blank=True)), ('created', models.DateTimeField(null=True, blank=True)), ], ), migrations.CreateModel( name='Node', fields=[ ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), ('name', models.CharField(max_length=200, null=True, blank=True)), ('slug', models.SlugField(max_length=200, null=True, blank=True)), ('thumb', models.CharField(max_length=200, null=True, blank=True)), ('introduction', models.CharField(max_length=500, null=True, blank=True)), ('created', models.DateTimeField(null=True, blank=True)), ('updated', models.DateTimeField(null=True, blank=True)), ('topic_count', models.IntegerField(null=True, blank=True)), ('custom_style', forum.models.NormalTextField(null=True, blank=True)), ('limit_reputation', models.IntegerField(null=True, blank=True)), ], ), migrations.CreateModel( name='Notification', fields=[ ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), ('content', forum.models.NormalTextField(null=True, blank=True)), ('status', models.IntegerField(null=True, blank=True)), ('involved_type', models.IntegerField(null=True, blank=True)), ('occurrence_time', models.DateTimeField(null=True, blank=True)), ], ), migrations.CreateModel( name='Plane', fields=[ ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), ('name', models.CharField(max_length=200, null=True, blank=True)), ('created', models.DateTimeField(null=True, blank=True)), ('updated', models.DateTimeField(null=True, blank=True)), ], ), migrations.CreateModel( name='Reply', fields=[ ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), ('content', forum.models.NormalTextField(null=True, blank=True)), ('created', models.DateTimeField(null=True, blank=True)), ('updated', models.DateTimeField(null=True, blank=True)), ('up_vote', models.IntegerField(null=True, blank=True)), ('down_vote', models.IntegerField(null=True, blank=True)), ('last_touched', models.DateTimeField(null=True, blank=True)), ('author', models.ForeignKey(related_name='reply_author', blank=True, to=settings.AUTH_USER_MODEL, null=True)), ], ), migrations.CreateModel( name='Topic', fields=[ ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), ('title', models.CharField(max_length=200, null=True, blank=True)), ('slug', models.SlugField(max_length=200, null=True, blank=True)), ('content', forum.models.NormalTextField(null=True, blank=True)), ('status', models.IntegerField(null=True, blank=True)), ('hits', models.IntegerField(null=True, blank=True)), ('created', models.DateTimeField(null=True, blank=True)), ('updated', models.DateTimeField(null=True, blank=True)), ('reply_count', models.IntegerField(null=True, blank=True)), ('last_replied_time', models.DateTimeField(null=True, blank=True)), ('up_vote', models.IntegerField(null=True, blank=True)), ('down_vote', models.IntegerField(null=True, blank=True)), ('last_touched', models.DateTimeField(null=True, blank=True)), ('author', models.ForeignKey(related_name='topic_author', blank=True, to=settings.AUTH_USER_MODEL, null=True)), ('last_replied_by', models.ForeignKey(related_name='topic_last', blank=True, to=settings.AUTH_USER_MODEL, null=True)), ('node', models.ForeignKey(blank=True, to='forum.Node', null=True)), ], ), migrations.CreateModel( name='Transaction', fields=[ ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), ('type', models.IntegerField(null=True, blank=True)), ('reward', models.IntegerField(null=True, blank=True)), ('current_balance', models.IntegerField(null=True, blank=True)), ('occurrence_time', models.DateTimeField(null=True, blank=True)), ('involved_reply', models.ForeignKey(related_name='trans_reply', blank=True, to='forum.Reply', null=True)), ('involved_topic', models.ForeignKey(related_name='trans_topic', blank=True, to='forum.Topic', null=True)), ('involved_user', models.ForeignKey(related_name='trans_involved', blank=True, to=settings.AUTH_USER_MODEL, null=True)), ('user', models.ForeignKey(related_name='trans_user', blank=True, to=settings.AUTH_USER_MODEL, null=True)), ], ), migrations.CreateModel( name='Vote', fields=[ ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), ('status', models.IntegerField(null=True, blank=True)), ('involved_type', models.IntegerField(null=True, blank=True)), ('occurrence_time', models.DateTimeField(null=True, blank=True)), ('involved_reply', models.ForeignKey(related_name='vote_reply', blank=True, to='forum.Reply', null=True)), ('involved_topic', models.ForeignKey(related_name='vote_topic', blank=True, to='forum.Topic', null=True)), ('involved_user', models.ForeignKey(related_name='vote_user', blank=True, to=settings.AUTH_USER_MODEL, null=True)), ('trigger_user', models.ForeignKey(related_name='vote_trigger', blank=True, to=settings.AUTH_USER_MODEL, null=True)), ], ), migrations.AddField( model_name='reply', name='topic', field=models.ForeignKey(blank=True, to='forum.Topic', null=True), ), migrations.AddField( model_name='notification', name='involved_reply', field=models.ForeignKey(related_name='notify_reply', blank=True, to='forum.Reply', null=True), ), migrations.AddField( model_name='notification', name='involved_topic', field=models.ForeignKey(related_name='notify_topic', blank=True, to='forum.Topic', null=True), ), migrations.AddField( model_name='notification', name='involved_user', field=models.ForeignKey(related_name='notify_user', blank=True, to=settings.AUTH_USER_MODEL, null=True), ), migrations.AddField( model_name='notification', name='trigger_user', field=models.ForeignKey(related_name='notify_trigger', blank=True, to=settings.AUTH_USER_MODEL, null=True), ), migrations.AddField( model_name='node', name='plane', field=models.ForeignKey(blank=True, to='forum.Plane', null=True), ), migrations.AddField( model_name='favorite', name='involved_reply', field=models.ForeignKey(related_name='fav_reply', blank=True, to='forum.Reply', null=True), ), migrations.AddField( model_name='favorite', name='involved_topic', field=models.ForeignKey(related_name='fav_topic', blank=True, to='forum.Topic', null=True), ), migrations.AddField( model_name='favorite', name='owner_user', field=models.ForeignKey(related_name='fav_user', blank=True, to=settings.AUTH_USER_MODEL, null=True), ), ]
[ 1, 396, 448, 29930, 29899, 14137, 29901, 23616, 29899, 29947, 448, 29930, 29899, 13, 3166, 4770, 29888, 9130, 1649, 1053, 29104, 29918, 20889, 1338, 13, 13, 3166, 9557, 29889, 2585, 1053, 4733, 29892, 9725, 800, 13, 5215, 9557, 29889, 21570, 29889, 5150, 29889, 9794, 13, 5215, 9557, 29889, 13239, 29889, 2230, 8028, 13, 3166, 9557, 29889, 5527, 1053, 6055, 13, 5215, 9557, 29889, 3221, 29889, 3084, 4097, 13, 5215, 24179, 29889, 9794, 13, 13, 13, 1990, 341, 16783, 29898, 26983, 800, 29889, 29924, 16783, 1125, 13, 13, 1678, 9962, 353, 518, 13, 4706, 6702, 5150, 742, 525, 29900, 29900, 29900, 29953, 29918, 12277, 29918, 3051, 8768, 29918, 29900, 29900, 29900, 29906, 5477, 13, 1678, 4514, 13, 13, 1678, 6931, 353, 518, 13, 4706, 9725, 800, 29889, 4391, 3195, 29898, 13, 9651, 1024, 2433, 2831, 398, 2659, 742, 13, 9651, 4235, 11759, 13, 18884, 6702, 333, 742, 4733, 29889, 12300, 3073, 29898, 369, 15828, 29918, 978, 2433, 1367, 742, 28755, 29922, 8824, 29892, 4469, 29918, 11600, 29922, 5574, 29892, 7601, 29918, 1989, 29922, 5574, 8243, 13, 18884, 6702, 5630, 742, 4733, 29889, 27890, 29898, 3317, 29918, 2848, 29922, 29896, 29906, 29947, 29892, 26952, 29918, 978, 2433, 5630, 1495, 511, 13, 18884, 6702, 4230, 29918, 7507, 742, 4733, 29889, 11384, 3073, 29898, 4304, 29922, 5574, 29892, 26952, 29918, 978, 2433, 4230, 6464, 742, 9654, 29922, 5574, 8243, 13, 18884, 6702, 275, 29918, 9136, 1792, 742, 4733, 29889, 18146, 3073, 29898, 4381, 29922, 8824, 29892, 1371, 29918, 726, 2433, 4002, 647, 1078, 393, 445, 1404, 756, 599, 11239, 1728, 9479, 23188, 963, 29889, 742, 26952, 29918, 978, 2433, 9136, 1792, 4660, 1495, 511, 13, 18884, 6702, 6786, 742, 4733, 29889, 27890, 29898, 2704, 29918, 19158, 3790, 29915, 13092, 2396, 525, 29909, 1404, 411, 393, 8952, 2307, 4864, 6169, 1118, 4236, 29918, 2848, 29922, 29941, 29900, 29892, 2854, 4097, 11759, 14095, 29889, 3221, 29889, 3084, 4097, 29889, 4597, 735, 24204, 877, 29985, 29961, 1966, 29893, 21240, 29974, 29899, 10062, 29938, 742, 525, 10399, 263, 2854, 8952, 29889, 910, 995, 1122, 1712, 871, 8721, 29892, 3694, 322, 732, 6294, 29914, 29974, 24028, 19891, 4890, 29889, 742, 525, 20965, 1495, 1402, 1371, 29918, 726, 2433, 19347, 29889, 29871, 29941, 29900, 4890, 470, 28145, 29889, 2803, 2153, 29892, 13340, 322, 732, 6294, 29914, 29974, 24028, 19891, 871, 29889, 742, 5412, 29922, 5574, 29892, 26952, 29918, 978, 2433, 6786, 1495, 511, 13, 18884, 6702, 4102, 29918, 978, 742, 4733, 29889, 27890, 29898, 3317, 29918, 2848, 29922, 29941, 29900, 29892, 26952, 29918, 978, 2433, 4102, 1024, 742, 9654, 29922, 5574, 8243, 13, 18884, 6702, 4230, 29918, 978, 742, 4733, 29889, 27890, 29898, 3317, 29918, 2848, 29922, 29941, 29900, 29892, 26952, 29918, 978, 2433, 4230, 1024, 742, 9654, 29922, 5574, 8243, 13, 18884, 6702, 5269, 742, 4733, 29889, 9823, 3073, 29898, 3317, 29918, 2848, 29922, 29906, 29945, 29946, 29892, 26952, 29918, 978, 2433, 5269, 3211, 742, 9654, 29922, 5574, 8243, 13, 18884, 6702, 275, 29918, 303, 3470, 742, 4733, 29889, 18146, 3073, 29898, 4381, 29922, 8824, 29892, 1371, 29918, 726, 2433, 4002, 647, 1078, 3692, 278, 1404, 508, 1480, 964, 445, 4113, 3268, 29889, 742, 26952, 29918, 978, 2433, 303, 3470, 4660, 1495, 511, 13, 18884, 6702, 275, 29918, 4925, 742, 4733, 29889, 18146, 3073, 29898, 4381, 29922, 5574, 29892, 1371, 29918, 726, 2433, 4002, 647, 1078, 3692, 445, 1404, 881, 367, 14914, 408, 6136, 29889, 853, 2622, 445, 2012, 310, 21228, 15303, 29889, 742, 26952, 29918, 978, 2433, 4925, 1495, 511, 13, 18884, 6702, 1256, 29918, 2212, 1312, 742, 4733, 29889, 11384, 3073, 29898, 4381, 29922, 14095, 29889, 13239, 29889, 2230, 8028, 29889, 3707, 29892, 26952, 29918, 978, 2433, 1256, 8772, 1495, 511, 13, 18884, 6702, 19254, 978, 742, 4733, 29889, 27890, 29898, 3317, 29918, 2848, 29922, 29906, 29900, 29900, 29892, 1870, 29922, 5574, 29892, 9654, 29922, 5574, 8243, 13, 18884, 6702, 485, 14873, 742, 4733, 29889, 27890, 29898, 3317, 29918, 2848, 29922, 29906, 29900, 29900, 29892, 1870, 29922, 5574, 29892, 9654, 29922, 5574, 8243, 13, 18884, 6702, 4530, 1535, 742, 4733, 29889, 27890, 29898, 3317, 29918, 2848, 29922, 29945, 29900, 29900, 29892, 1870, 29922, 5574, 29892, 9654, 29922, 5574, 8243, 13, 18884, 6702, 5479, 742, 4733, 29889, 27890, 29898, 3317, 29918, 2848, 29922, 29906, 29900, 29900, 29892, 1870, 29922, 5574, 29892, 9654, 29922, 5574, 8243, 13, 18884, 6702, 22942, 742, 4733, 29889, 4219, 3073, 29898, 4304, 29922, 5574, 29892, 9654, 29922, 5574, 8243, 13, 18884, 6702, 14518, 742, 4733, 29889, 27890, 29898, 3317, 29918, 2848, 29922, 29906, 29900, 29900, 29892, 1870, 29922, 5574, 29892, 9654, 29922, 5574, 8243, 13, 18884, 6702, 12154, 742, 4733, 29889, 7798, 3073, 29898, 4304, 29922, 5574, 29892, 9654, 29922, 5574, 8243, 13, 18884, 6702, 5521, 749, 742, 4733, 29889, 7798, 3073, 29898, 4304, 29922, 5574, 29892, 9654, 29922, 5574, 8243, 13, 18884, 6702, 276, 14584, 742, 4733, 29889, 7798, 3073, 29898, 4304, 29922, 5574, 29892, 9654, 29922, 5574, 8243, 13, 18884, 6702, 1311, 29918, 23333, 742, 4733, 29889, 27890, 29898, 3317, 29918, 2848, 29922, 29945, 29900, 29900, 29892, 1870, 29922, 5574, 29892, 9654, 29922, 5574, 8243, 13, 18884, 6702, 21402, 742, 4733, 29889, 11384, 3073, 29898, 4304, 29922, 5574, 29892, 9654, 29922, 5574, 8243, 13, 18884, 6702, 24946, 742, 4733, 29889, 27890, 29898, 3317, 29918, 2848, 29922, 29906, 29900, 29900, 29892, 1870, 29922, 5574, 29892, 9654, 29922, 5574, 8243, 13, 18884, 6702, 3292, 742, 4733, 29889, 27890, 29898, 3317, 29918, 2848, 29922, 29906, 29900, 29900, 29892, 1870, 29922, 5574, 29892, 9654, 29922, 5574, 8243, 13, 18884, 6702, 29881, 283, 2571, 742, 4733, 29889, 27890, 29898, 3317, 29918, 2848, 29922, 29906, 29900, 29900, 29892, 1870, 29922, 5574, 29892, 9654, 29922, 5574, 8243, 13, 18884, 6702, 13155, 742, 4733, 29889, 14804, 1762, 14804, 3073, 29898, 12817, 29918, 1972, 29918, 978, 2433, 1792, 742, 4475, 29918, 978, 2433, 1792, 29918, 842, 742, 304, 2433, 5150, 29889, 4782, 742, 9654, 29922, 5574, 29892, 1371, 29918, 726, 2433, 1576, 6471, 445, 1404, 14393, 304, 29889, 319, 1404, 674, 679, 599, 11239, 16896, 304, 1269, 310, 1009, 6471, 29889, 742, 26952, 29918, 978, 2433, 13155, 1495, 511, 13, 18884, 6702, 1792, 29918, 17858, 6847, 742, 4733, 29889, 14804, 1762, 14804, 3073, 29898, 12817, 29918, 1972, 29918, 978, 2433, 1792, 742, 4475, 29918, 978, 2433, 1792, 29918, 842, 742, 304, 2433, 5150, 29889, 27293, 742, 9654, 29922, 5574, 29892, 1371, 29918, 726, 2433, 10299, 928, 11239, 363, 445, 1404, 29889, 742, 26952, 29918, 978, 2433, 1792, 11239, 1495, 511, 13, 9651, 21251, 13, 9651, 3987, 3790, 13, 18884, 525, 16595, 2396, 7700, 29892, 13, 18884, 525, 369, 15828, 29918, 978, 2396, 525, 1792, 742, 13, 18884, 525, 369, 15828, 29918, 978, 29918, 572, 3631, 2396, 525, 7193, 742, 13, 9651, 2981, 13, 9651, 767, 18150, 11759, 13, 18884, 6702, 12650, 742, 9557, 29889, 21570, 29889, 5150, 29889, 9794, 29889, 2659, 3260, 25739, 13, 9651, 21251, 13, 4706, 10353, 13, 4706, 9725, 800, 29889, 4391, 3195, 29898, 13, 9651, 1024, 2433, 29943, 17118, 568, 742, 13, 9651, 4235, 11759, 13, 18884, 6702, 333, 742, 4733, 29889, 12300, 3073, 29898, 369, 15828, 29918, 978, 2433, 1367, 742, 28755, 29922, 8824, 29892, 4469, 29918, 11600, 29922, 5574, 29892, 7601, 29918, 1989, 29922, 5574, 8243, 13, 18884, 6702, 262, 1555, 1490, 29918, 1853, 742, 4733, 29889, 7798, 3073, 29898, 4304, 29922, 5574, 29892, 9654, 29922, 5574, 8243, 13, 18884, 6702, 11600, 742, 4733, 29889, 11384, 3073, 29898, 4304, 29922, 5574, 29892, 9654, 29922, 5574, 8243, 13, 9651, 21251, 13, 4706, 10353, 13, 4706, 9725, 800, 29889, 4391, 3195, 29898, 13, 9651, 1024, 2433, 4247, 742, 13, 9651, 4235, 11759, 13, 18884, 6702, 333, 742, 4733, 29889, 12300, 3073, 29898, 369, 15828, 29918, 978, 2433, 1367, 742, 28755, 29922, 8824, 29892, 4469, 29918, 11600, 29922, 5574, 29892, 7601, 29918, 1989, 29922, 5574, 8243, 13, 18884, 6702, 978, 742, 4733, 29889, 27890, 29898, 3317, 29918, 2848, 29922, 29906, 29900, 29900, 29892, 1870, 29922, 5574, 29892, 9654, 29922, 5574, 8243, 13, 18884, 6702, 29517, 742, 4733, 29889, 16973, 688, 3073, 29898, 3317, 29918, 2848, 29922, 29906, 29900, 29900, 29892, 1870, 29922, 5574, 29892, 9654, 29922, 5574, 8243, 13, 18884, 6702, 386, 3774, 742, 4733, 29889, 27890, 29898, 3317, 29918, 2848, 29922, 29906, 29900, 29900, 29892, 1870, 29922, 5574, 29892, 9654, 29922, 5574, 8243, 13, 18884, 6702, 524, 13210, 742, 4733, 29889, 27890, 29898, 3317, 29918, 2848, 29922, 29945, 29900, 29900, 29892, 1870, 29922, 5574, 29892, 9654, 29922, 5574, 8243, 13, 18884, 6702, 11600, 742, 4733, 29889, 11384, 3073, 29898, 4304, 29922, 5574, 29892, 9654, 29922, 5574, 8243, 13, 18884, 6702, 21402, 742, 4733, 29889, 11384, 3073, 29898, 4304, 29922, 5574, 29892, 9654, 29922, 5574, 8243, 13, 18884, 6702, 13010, 29918, 2798, 742, 4733, 29889, 7798, 3073, 29898, 4304, 29922, 5574, 29892, 9654, 29922, 5574, 8243, 13, 18884, 6702, 6341, 29918, 3293, 742, 24179, 29889, 9794, 29889, 19077, 15778, 29898, 4304, 29922, 5574, 29892, 9654, 29922, 5574, 8243, 13, 18884, 6702, 13400, 29918, 276, 14584, 742, 4733, 29889, 7798, 3073, 29898, 4304, 29922, 5574, 29892, 9654, 29922, 5574, 8243, 13, 9651, 21251, 13, 4706, 10353, 13, 4706, 9725, 800, 29889, 4391, 3195, 29898, 13, 9651, 1024, 2433, 12958, 742, 13, 9651, 4235, 11759, 13, 18884, 6702, 333, 742, 4733, 29889, 12300, 3073, 29898, 369, 15828, 29918, 978, 2433, 1367, 742, 28755, 29922, 8824, 29892, 4469, 29918, 11600, 29922, 5574, 29892, 7601, 29918, 1989, 29922, 5574, 8243, 13, 18884, 6702, 3051, 742, 24179, 29889, 9794, 29889, 19077, 15778, 29898, 4304, 29922, 5574, 29892, 9654, 29922, 5574, 8243, 13, 18884, 6702, 4882, 742, 4733, 29889, 7798, 3073, 29898, 4304, 29922, 5574, 29892, 9654, 29922, 5574, 8243, 13, 18884, 6702, 262, 1555, 1490, 29918, 1853, 742, 4733, 29889, 7798, 3073, 29898, 4304, 29922, 5574, 29892, 9654, 29922, 5574, 8243, 13, 18884, 6702, 15693, 26841, 29918, 2230, 742, 4733, 29889, 11384, 3073, 29898, 4304, 29922, 5574, 29892, 9654, 29922, 5574, 8243, 13, 9651, 21251, 13, 4706, 10353, 13, 4706, 9725, 800, 29889, 4391, 3195, 29898, 13, 9651, 1024, 2433, 3247, 1662, 742, 13, 9651, 4235, 11759, 13, 18884, 6702, 333, 742, 4733, 29889, 12300, 3073, 29898, 369, 15828, 29918, 978, 2433, 1367, 742, 28755, 29922, 8824, 29892, 4469, 29918, 11600, 29922, 5574, 29892, 7601, 29918, 1989, 29922, 5574, 8243, 13, 18884, 6702, 978, 742, 4733, 29889, 27890, 29898, 3317, 29918, 2848, 29922, 29906, 29900, 29900, 29892, 1870, 29922, 5574, 29892, 9654, 29922, 5574, 8243, 13, 18884, 6702, 11600, 742, 4733, 29889, 11384, 3073, 29898, 4304, 29922, 5574, 29892, 9654, 29922, 5574, 8243, 13, 18884, 6702, 21402, 742, 4733, 29889, 11384, 3073, 29898, 4304, 29922, 5574, 29892, 9654, 29922, 5574, 8243, 13, 9651, 21251, 13, 4706, 10353, 13, 4706, 9725, 800, 29889, 4391, 3195, 29898, 13, 9651, 1024, 2433, 5612, 368, 742, 13, 9651, 4235, 11759, 13, 18884, 6702, 333, 742, 4733, 29889, 12300, 3073, 29898, 369, 15828, 29918, 978, 2433, 1367, 742, 28755, 29922, 8824, 29892, 4469, 29918, 11600, 29922, 5574, 29892, 7601, 29918, 1989, 29922, 5574, 8243, 13, 18884, 6702, 3051, 742, 24179, 29889, 9794, 29889, 19077, 15778, 29898, 4304, 29922, 5574, 29892, 9654, 29922, 5574, 8243, 13, 18884, 6702, 11600, 742, 4733, 29889, 11384, 3073, 29898, 4304, 29922, 5574, 29892, 9654, 29922, 5574, 8243, 13, 18884, 6702, 21402, 742, 4733, 29889, 11384, 3073, 29898, 4304, 29922, 5574, 29892, 9654, 29922, 5574, 8243, 13, 18884, 6702, 786, 29918, 15814, 742, 4733, 29889, 7798, 3073, 29898, 4304, 29922, 5574, 29892, 9654, 29922, 5574, 8243, 13, 18884, 6702, 3204, 29918, 15814, 742, 4733, 29889, 7798, 3073, 29898, 4304, 29922, 5574, 29892, 9654, 29922, 5574, 8243, 13, 18884, 6702, 4230, 29918, 16747, 287, 742, 4733, 29889, 11384, 3073, 29898, 4304, 29922, 5574, 29892, 9654, 29922, 5574, 8243, 13, 18884, 6702, 8921, 742, 4733, 29889, 27755, 2558, 29898, 12817, 29918, 978, 2433, 3445, 368, 29918, 8921, 742, 9654, 29922, 5574, 29892, 304, 29922, 11027, 29889, 20656, 29950, 29918, 11889, 29918, 20387, 29931, 29892, 1870, 29922, 5574, 8243, 13, 9651, 21251, 13, 4706, 10353, 13, 4706, 9725, 800, 29889, 4391, 3195, 29898, 13, 9651, 1024, 2433, 7031, 293, 742, 13, 9651, 4235, 11759, 13, 18884, 6702, 333, 742, 4733, 29889, 12300, 3073, 29898, 369, 15828, 29918, 978, 2433, 1367, 742, 28755, 29922, 8824, 29892, 4469, 29918, 11600, 29922, 5574, 29892, 7601, 29918, 1989, 29922, 5574, 8243, 13, 18884, 6702, 3257, 742, 4733, 29889, 27890, 29898, 3317, 29918, 2848, 29922, 29906, 29900, 29900, 29892, 1870, 29922, 5574, 29892, 9654, 29922, 5574, 8243, 13, 18884, 6702, 29517, 742, 4733, 29889, 16973, 688, 3073, 29898, 3317, 29918, 2848, 29922, 29906, 29900, 29900, 29892, 1870, 29922, 5574, 29892, 9654, 29922, 5574, 8243, 13, 18884, 6702, 3051, 742, 24179, 29889, 9794, 29889, 19077, 15778, 29898, 4304, 29922, 5574, 29892, 9654, 29922, 5574, 8243, 13, 18884, 6702, 4882, 742, 4733, 29889, 7798, 3073, 29898, 4304, 29922, 5574, 29892, 9654, 29922, 5574, 8243, 13, 18884, 6702, 29882, 1169, 742, 4733, 29889, 7798, 3073, 29898, 4304, 29922, 5574, 29892, 9654, 29922, 5574, 8243, 13, 18884, 6702, 11600, 742, 4733, 29889, 11384, 3073, 29898, 4304, 29922, 5574, 29892, 9654, 29922, 5574, 8243, 13, 18884, 6702, 21402, 742, 4733, 29889, 11384, 3073, 29898, 4304, 29922, 5574, 29892, 9654, 29922, 5574, 8243, 13, 18884, 6702, 3445, 368, 29918, 2798, 742, 4733, 29889, 7798, 3073, 29898, 4304, 29922, 5574, 29892, 9654, 29922, 5574, 8243, 13, 18884, 6702, 4230, 29918, 3445, 2957, 29918, 2230, 742, 4733, 29889, 11384, 3073, 29898, 4304, 29922, 5574, 29892, 9654, 29922, 5574, 8243, 13, 18884, 6702, 786, 29918, 15814, 742, 4733, 29889, 7798, 3073, 29898, 4304, 29922, 5574, 29892, 9654, 29922, 5574, 8243, 13, 18884, 6702, 3204, 29918, 15814, 742, 4733, 29889, 7798, 3073, 29898, 4304, 29922, 5574, 29892, 9654, 29922, 5574, 8243, 13, 18884, 6702, 4230, 29918, 16747, 287, 742, 4733, 29889, 11384, 3073, 29898, 4304, 29922, 5574, 29892, 9654, 29922, 5574, 8243, 13, 18884, 6702, 8921, 742, 4733, 29889, 27755, 2558, 29898, 12817, 29918, 978, 2433, 13010, 29918, 8921, 742, 9654, 29922, 5574, 29892, 304, 29922, 11027, 29889, 20656, 29950, 29918, 11889, 29918, 20387, 29931, 29892, 1870, 29922, 5574, 8243, 13, 18884, 6702, 4230, 29918, 3445, 2957, 29918, 1609, 742, 4733, 29889, 27755, 2558, 29898, 12817, 29918, 978, 2433, 13010, 29918, 4230, 742, 9654, 29922, 5574, 29892, 304, 29922, 11027, 29889, 20656, 29950, 29918, 11889, 29918, 20387, 29931, 29892, 1870, 29922, 5574, 8243, 13, 18884, 6702, 3177, 742, 4733, 29889, 27755, 2558, 29898, 19465, 29922, 5574, 29892, 304, 2433, 23343, 29889, 4247, 742, 1870, 29922, 5574, 8243, 13, 9651, 21251, 13, 4706, 10353, 13, 4706, 9725, 800, 29889, 4391, 3195, 29898, 13, 9651, 1024, 2433, 12460, 742, 13, 9651, 4235, 11759, 13, 18884, 6702, 333, 742, 4733, 29889, 12300, 3073, 29898, 369, 15828, 29918, 978, 2433, 1367, 742, 28755, 29922, 8824, 29892, 4469, 29918, 11600, 29922, 5574, 29892, 7601, 29918, 1989, 29922, 5574, 8243, 13, 18884, 6702, 1853, 742, 4733, 29889, 7798, 3073, 29898, 4304, 29922, 5574, 29892, 9654, 29922, 5574, 8243, 13, 18884, 6702, 276, 1328, 742, 4733, 29889, 7798, 3073, 29898, 4304, 29922, 5574, 29892, 9654, 29922, 5574, 8243, 13, 18884, 6702, 3784, 29918, 5521, 749, 742, 4733, 29889, 7798, 3073, 29898, 4304, 29922, 5574, 29892, 9654, 29922, 5574, 8243, 13, 18884, 6702, 15693, 26841, 29918, 2230, 742, 4733, 29889, 11384, 3073, 29898, 4304, 29922, 5574, 29892, 9654, 29922, 5574, 8243, 13, 18884, 6702, 262, 1555, 1490, 29918, 3445, 368, 742, 4733, 29889, 27755, 2558, 29898, 12817, 29918, 978, 2433, 3286, 29918, 3445, 368, 742, 9654, 29922, 5574, 29892, 304, 2433, 23343, 29889, 5612, 368, 742, 1870, 29922, 5574, 8243, 13, 18884, 6702, 262, 1555, 1490, 29918, 13010, 742, 4733, 29889, 27755, 2558, 29898, 12817, 29918, 978, 2433, 3286, 29918, 13010, 742, 9654, 29922, 5574, 29892, 304, 2433, 23343, 29889, 7031, 293, 742, 1870, 29922, 5574, 8243, 13, 18884, 6702, 262, 1555, 1490, 29918, 1792, 742, 4733, 29889, 27755, 2558, 29898, 12817, 29918, 978, 2433, 3286, 29918, 262, 1555, 1490, 742, 9654, 29922, 5574, 29892, 304, 29922, 11027, 29889, 20656, 29950, 29918, 11889, 29918, 20387, 29931, 29892, 1870, 29922, 5574, 8243, 13, 18884, 6702, 1792, 742, 4733, 29889, 27755, 2558, 29898, 12817, 29918, 978, 2433, 3286, 29918, 1792, 742, 9654, 29922, 5574, 29892, 304, 29922, 11027, 29889, 20656, 29950, 29918, 11889, 29918, 20387, 29931, 29892, 1870, 29922, 5574, 8243, 13, 9651, 21251, 13, 4706, 10353, 13, 4706, 9725, 800, 29889, 4391, 3195, 29898, 13, 9651, 1024, 2433, 29963, 866, 742, 13, 9651, 4235, 11759, 13, 18884, 6702, 333, 742, 4733, 29889, 12300, 3073, 29898, 369, 15828, 29918, 978, 2433, 1367, 742, 28755, 29922, 8824, 29892, 4469, 29918, 11600, 29922, 5574, 29892, 7601, 29918, 1989, 29922, 5574, 8243, 13, 18884, 6702, 4882, 742, 4733, 29889, 7798, 3073, 29898, 4304, 29922, 5574, 29892, 9654, 29922, 5574, 8243, 13, 18884, 6702, 262, 1555, 1490, 29918, 1853, 742, 4733, 29889, 7798, 3073, 29898, 4304, 29922, 5574, 29892, 9654, 29922, 5574, 8243, 13, 18884, 6702, 15693, 26841, 29918, 2230, 742, 4733, 29889, 11384, 3073, 29898, 4304, 29922, 5574, 29892, 9654, 29922, 5574, 8243, 13, 18884, 6702, 262, 1555, 1490, 29918, 3445, 368, 742, 4733, 29889, 27755, 2558, 29898, 12817, 29918, 978, 2433, 15814, 29918, 3445, 368, 742, 9654, 29922, 5574, 29892, 304, 2433, 23343, 29889, 5612, 368, 742, 1870, 29922, 5574, 8243, 13, 18884, 6702, 262, 1555, 1490, 29918, 13010, 742, 4733, 29889, 27755, 2558, 29898, 12817, 29918, 978, 2433, 15814, 29918, 13010, 742, 9654, 29922, 5574, 29892, 304, 2433, 23343, 29889, 7031, 293, 742, 1870, 29922, 5574, 8243, 13, 18884, 6702, 262, 1555, 1490, 29918, 1792, 742, 4733, 29889, 27755, 2558, 29898, 12817, 29918, 978, 2433, 15814, 29918, 1792, 742, 9654, 29922, 5574, 29892, 304, 29922, 11027, 29889, 20656, 29950, 29918, 11889, 29918, 20387, 29931, 29892, 1870, 29922, 5574, 8243, 13, 18884, 6702, 21001, 29918, 1792, 742, 4733, 29889, 27755, 2558, 29898, 12817, 29918, 978, 2433, 15814, 29918, 21001, 742, 9654, 29922, 5574, 29892, 304, 29922, 11027, 29889, 20656, 29950, 29918, 11889, 29918, 20387, 29931, 29892, 1870, 29922, 5574, 8243, 13, 9651, 21251, 13, 4706, 10353, 13, 4706, 9725, 800, 29889, 2528, 3073, 29898, 13, 9651, 1904, 29918, 978, 2433, 3445, 368, 742, 13, 9651, 1024, 2433, 13010, 742, 13, 9651, 1746, 29922, 9794, 29889, 27755, 2558, 29898, 19465, 29922, 5574, 29892, 304, 2433, 23343, 29889, 7031, 293, 742, 1870, 29922, 5574, 511, 13, 4706, 10353, 13, 4706, 9725, 800, 29889, 2528, 3073, 29898, 13, 9651, 1904, 29918, 978, 2433, 24671, 742, 13, 9651, 1024, 2433, 262, 1555, 1490, 29918, 3445, 368, 742, 13, 9651, 1746, 29922, 9794, 29889, 27755, 2558, 29898, 12817, 29918, 978, 2433, 25140, 29918, 3445, 368, 742, 9654, 29922, 5574, 29892, 304, 2433, 23343, 29889, 5612, 368, 742, 1870, 29922, 5574, 511, 13, 4706, 10353, 13, 4706, 9725, 800, 29889, 2528, 3073, 29898, 13, 9651, 1904, 29918, 978, 2433, 24671, 742, 13, 9651, 1024, 2433, 262, 1555, 1490, 29918, 13010, 742, 13, 9651, 1746, 29922, 9794, 29889, 27755, 2558, 29898, 12817, 29918, 978, 2433, 25140, 29918, 13010, 742, 9654, 29922, 5574, 29892, 304, 2433, 23343, 29889, 7031, 293, 742, 1870, 29922, 5574, 511, 13, 4706, 10353, 13, 4706, 9725, 800, 29889, 2528, 3073, 29898, 13, 9651, 1904, 29918, 978, 2433, 24671, 742, 13, 9651, 1024, 2433, 262, 1555, 1490, 29918, 1792, 742, 13, 9651, 1746, 29922, 9794, 29889, 27755, 2558, 29898, 12817, 29918, 978, 2433, 25140, 29918, 1792, 742, 9654, 29922, 5574, 29892, 304, 29922, 11027, 29889, 20656, 29950, 29918, 11889, 29918, 20387, 29931, 29892, 1870, 29922, 5574, 511, 13, 4706, 10353, 13, 4706, 9725, 800, 29889, 2528, 3073, 29898, 13, 9651, 1904, 29918, 978, 2433, 24671, 742, 13, 9651, 1024, 2433, 21001, 29918, 1792, 742, 13, 9651, 1746, 29922, 9794, 29889, 27755, 2558, 29898, 12817, 29918, 978, 2433, 25140, 29918, 21001, 742, 9654, 29922, 5574, 29892, 304, 29922, 11027, 29889, 20656, 29950, 29918, 11889, 29918, 20387, 29931, 29892, 1870, 29922, 5574, 511, 13, 4706, 10353, 13, 4706, 9725, 800, 29889, 2528, 3073, 29898, 13, 9651, 1904, 29918, 978, 2433, 3177, 742, 13, 9651, 1024, 2433, 22116, 742, 13, 9651, 1746, 29922, 9794, 29889, 27755, 2558, 29898, 19465, 29922, 5574, 29892, 304, 2433, 23343, 29889, 3247, 1662, 742, 1870, 29922, 5574, 511, 13, 4706, 10353, 13, 4706, 9725, 800, 29889, 2528, 3073, 29898, 13, 9651, 1904, 29918, 978, 2433, 29888, 17118, 568, 742, 13, 9651, 1024, 2433, 262, 1555, 1490, 29918, 3445, 368, 742, 13, 9651, 1746, 29922, 9794, 29889, 27755, 2558, 29898, 12817, 29918, 978, 2433, 29888, 485, 29918, 3445, 368, 742, 9654, 29922, 5574, 29892, 304, 2433, 23343, 29889, 5612, 368, 742, 1870, 29922, 5574, 511, 13, 4706, 10353, 13, 4706, 9725, 800, 29889, 2528, 3073, 29898, 13, 9651, 1904, 29918, 978, 2433, 29888, 17118, 568, 742, 13, 9651, 1024, 2433, 262, 1555, 1490, 29918, 13010, 742, 13, 9651, 1746, 29922, 9794, 29889, 27755, 2558, 29898, 12817, 29918, 978, 2433, 29888, 485, 29918, 13010, 742, 9654, 29922, 5574, 29892, 304, 2433, 23343, 29889, 7031, 293, 742, 1870, 29922, 5574, 511, 13, 4706, 10353, 13, 4706, 9725, 800, 29889, 2528, 3073, 29898, 13, 9651, 1904, 29918, 978, 2433, 29888, 17118, 568, 742, 13, 9651, 1024, 2433, 20348, 29918, 1792, 742, 13, 9651, 1746, 29922, 9794, 29889, 27755, 2558, 29898, 12817, 29918, 978, 2433, 29888, 485, 29918, 1792, 742, 9654, 29922, 5574, 29892, 304, 29922, 11027, 29889, 20656, 29950, 29918, 11889, 29918, 20387, 29931, 29892, 1870, 29922, 5574, 511, 13, 4706, 10353, 13, 1678, 4514, 13, 2 ]
edge-tool/cbor_converter.py
hckim-kornic/mbed-edge-kornic
0
16902
#!/usr/bin/env python # ---------------------------------------------------------------------------- # Copyright 2018 ARM Ltd. # # SPDX-License-Identifier: Apache-2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # ---------------------------------------------------------------------------- import os import cbor2 import struct from pyclibrary import CParser from collections import namedtuple CERTIFICATE_KEYS = ('MBED_CLOUD_DEV_BOOTSTRAP_DEVICE_CERTIFICATE', 'MBED_CLOUD_DEV_BOOTSTRAP_SERVER_ROOT_CA_CERTIFICATE', 'arm_uc_default_certificate') KEY_KEYS = ('MBED_CLOUD_DEV_BOOTSTRAP_DEVICE_PRIVATE_KEY') UPDATE_KEYS = ('arm_uc_default_certificate', 'arm_uc_class_id', 'arm_uc_vendor_id') KEY_MAP = { 'MBED_CLOUD_DEV_BOOTSTRAP_DEVICE_CERTIFICATE': 'mbed.BootstrapDeviceCert', 'MBED_CLOUD_DEV_BOOTSTRAP_SERVER_ROOT_CA_CERTIFICATE': 'mbed.BootstrapServerCACert', 'MBED_CLOUD_DEV_BOOTSTRAP_DEVICE_PRIVATE_KEY': 'mbed.BootstrapDevicePrivateKey', 'MBED_CLOUD_DEV_BOOTSTRAP_ENDPOINT_NAME': 'mbed.EndpointName', 'MBED_CLOUD_DEV_BOOTSTRAP_SERVER_URI': 'mbed.BootstrapServerURI', 'MBED_CLOUD_DEV_ACCOUNT_ID': 'mbed.AccountID', 'MBED_CLOUD_DEV_MANUFACTURER': 'mbed.Manufacturer', 'MBED_CLOUD_DEV_MODEL_NUMBER': 'mbed.ModelNumber', 'MBED_CLOUD_DEV_SERIAL_NUMBER': 'mbed.SerialNumber', 'MBED_CLOUD_DEV_DEVICE_TYPE': 'mbed.DeviceType', 'MBED_CLOUD_DEV_HARDWARE_VERSION': 'mbed.HardwareVersion', 'MBED_CLOUD_DEV_MEMORY_TOTAL_KB': 'mbed.MemoryTotalKB', 'arm_uc_default_certificate': 'mbed.UpdateAuthCert', 'arm_uc_class_id': 'mbed.ClassId', 'arm_uc_vendor_id': 'mbed.VendorId' } ConfigParam = namedtuple('ConfigParam', ['Data', 'Name']) Certificate = namedtuple('Certificate', ['Data', 'Format', 'Name']) Key = namedtuple('Key', ['Data', 'Format', 'Name', 'Type']) class CBORConverter(): def __init__(self, development_certificate, update_resource, cbor_file): self.development_certificate = development_certificate self.update_resource = update_resource self.cbor_file = cbor_file def __check_file_exists(self, path): if not os.path.isfile(path): print("File '%s' does not exist.") return False return True def parse_c_file(self): if not self.__check_file_exists(self.development_certificate) or \ not self.__check_file_exists(self.update_resource): return None values = {} values.update(CParser([self.development_certificate]).defs.get('values')) values.update(CParser([self.update_resource], macros={ 'MBED_CLOUD_DEV_UPDATE_ID' : 1, 'MBED_CLOUD_DEV_UPDATE_CERT' : 1 }).defs.get('values')) return values def create_cbor_data(self, vars): cbor_data = {'Certificates': [], 'Keys' : [], 'ConfigParams': [], 'SchemeVersion': '0.0.1'} use_bootstrap = 1 if 'MBED_CLOUD_DEV_BOOTSTRAP_SERVER_URI' in vars.keys() else 0 cbor_data['ConfigParams'].append(ConfigParam(use_bootstrap, 'mbed.UseBootstrap')._asdict()) for key in vars.keys(): var = vars.get(key) cbor_var_key = KEY_MAP.get(key, None) if cbor_var_key: if key in CERTIFICATE_KEYS: byte_data = struct.pack('%sB' % len(var), *var); certificate = Certificate(byte_data, 'der', cbor_var_key)._asdict() cbor_data['Certificates'].append(certificate) elif key in KEY_KEYS: byte_data = struct.pack('%sB' % len(var), *var); private_key = Key(byte_data, 'der', cbor_var_key, 'ECCPrivate')._asdict() cbor_data['Keys'].append(private_key) elif key in UPDATE_KEYS: byte_data = struct.pack('%sB' % len(var), *var) config_param = ConfigParam(byte_data, cbor_var_key)._asdict() cbor_data['ConfigParams'].append(config_param) else: config_param = ConfigParam(var, cbor_var_key)._asdict() cbor_data['ConfigParams'].append(config_param) else: print("Key %s not in KEY_MAP." % key) return cbor_data def convert_to_cbor(self): vars = self.parse_c_file() if not vars: print("No variables parsed.") else: cbor_data = self.create_cbor_data(vars) with open(self.cbor_file, 'wb') as out_file: cbor2.dump(cbor_data, out_file)
[ 1, 18787, 4855, 29914, 2109, 29914, 6272, 3017, 13, 13, 29937, 448, 2683, 2683, 2683, 2683, 1378, 5634, 13, 29937, 14187, 1266, 29871, 29906, 29900, 29896, 29947, 9033, 29924, 19806, 29889, 13, 29937, 13, 29937, 10937, 29928, 29990, 29899, 29931, 293, 1947, 29899, 12889, 29901, 13380, 29899, 29906, 29889, 29900, 13, 29937, 13, 29937, 10413, 21144, 1090, 278, 13380, 19245, 29892, 10079, 29871, 29906, 29889, 29900, 313, 1552, 376, 29931, 293, 1947, 1496, 13, 29937, 366, 1122, 451, 671, 445, 934, 5174, 297, 752, 13036, 411, 278, 19245, 29889, 13, 29937, 887, 1122, 4017, 263, 3509, 310, 278, 19245, 472, 13, 29937, 13, 29937, 268, 1732, 597, 1636, 29889, 4288, 29889, 990, 29914, 506, 11259, 29914, 27888, 1430, 1660, 29899, 29906, 29889, 29900, 13, 29937, 13, 29937, 25870, 3734, 491, 22903, 4307, 470, 15502, 304, 297, 5007, 29892, 7047, 13, 29937, 13235, 1090, 278, 19245, 338, 13235, 373, 385, 376, 3289, 8519, 29908, 350, 3289, 3235, 29892, 13, 29937, 399, 1806, 8187, 2692, 399, 1718, 29934, 13566, 29059, 6323, 8707, 29928, 22122, 29903, 8079, 13764, 29979, 476, 22255, 29892, 2845, 4653, 470, 2411, 2957, 29889, 13, 29937, 2823, 278, 19245, 363, 278, 2702, 4086, 14765, 1076, 11239, 322, 13, 29937, 27028, 1090, 278, 19245, 29889, 13, 29937, 448, 2683, 2683, 2683, 2683, 1378, 5634, 13, 13, 5215, 2897, 13, 5215, 274, 4089, 29906, 13, 5215, 2281, 13, 3166, 282, 11078, 5258, 1053, 315, 11726, 13, 3166, 16250, 1053, 4257, 23583, 13, 13, 29907, 20161, 6545, 2965, 3040, 29918, 10818, 29903, 353, 6702, 9486, 3352, 29918, 29907, 3927, 15789, 29918, 2287, 29963, 29918, 8456, 2891, 10810, 3301, 29918, 2287, 19059, 29918, 29907, 20161, 6545, 2965, 3040, 742, 13, 462, 1678, 525, 9486, 3352, 29918, 29907, 3927, 15789, 29918, 2287, 29963, 29918, 8456, 2891, 10810, 3301, 29918, 18603, 29918, 21289, 29918, 5454, 29918, 29907, 20161, 6545, 2965, 3040, 742, 13, 462, 1678, 525, 2817, 29918, 1682, 29918, 4381, 29918, 6327, 8021, 1495, 13, 13, 10818, 29918, 10818, 29903, 353, 6702, 9486, 3352, 29918, 29907, 3927, 15789, 29918, 2287, 29963, 29918, 8456, 2891, 10810, 3301, 29918, 2287, 19059, 29918, 29829, 29963, 3040, 29918, 10818, 1495, 13, 13, 14474, 29918, 10818, 29903, 353, 6702, 2817, 29918, 1682, 29918, 4381, 29918, 6327, 8021, 742, 13, 1669, 525, 2817, 29918, 1682, 29918, 1990, 29918, 333, 742, 13, 1669, 525, 2817, 29918, 1682, 29918, 19167, 29918, 333, 1495, 13, 13, 10818, 29918, 23827, 353, 426, 13, 1678, 525, 9486, 3352, 29918, 29907, 3927, 15789, 29918, 2287, 29963, 29918, 8456, 2891, 10810, 3301, 29918, 2287, 19059, 29918, 29907, 20161, 6545, 2965, 3040, 2396, 525, 29885, 2580, 29889, 20967, 5698, 11501, 20455, 742, 13, 1678, 525, 9486, 3352, 29918, 29907, 3927, 15789, 29918, 2287, 29963, 29918, 8456, 2891, 10810, 3301, 29918, 18603, 29918, 21289, 29918, 5454, 29918, 29907, 20161, 6545, 2965, 3040, 2396, 525, 29885, 2580, 29889, 20967, 5698, 6004, 29907, 2477, 814, 742, 13, 1678, 525, 9486, 3352, 29918, 29907, 3927, 15789, 29918, 2287, 29963, 29918, 8456, 2891, 10810, 3301, 29918, 2287, 19059, 29918, 29829, 29963, 3040, 29918, 10818, 2396, 525, 29885, 2580, 29889, 20967, 5698, 11501, 25207, 2558, 742, 13, 1678, 525, 9486, 3352, 29918, 29907, 3927, 15789, 29918, 2287, 29963, 29918, 8456, 2891, 10810, 3301, 29918, 1430, 11191, 6992, 29911, 29918, 5813, 2396, 525, 29885, 2580, 29889, 25602, 1170, 742, 13, 1678, 525, 9486, 3352, 29918, 29907, 3927, 15789, 29918, 2287, 29963, 29918, 8456, 2891, 10810, 3301, 29918, 18603, 29918, 15551, 2396, 525, 29885, 2580, 29889, 20967, 5698, 6004, 15551, 742, 13, 1678, 525, 9486, 3352, 29918, 29907, 3927, 15789, 29918, 2287, 29963, 29918, 2477, 18736, 29918, 1367, 2396, 525, 29885, 2580, 29889, 10601, 1367, 742, 13, 1678, 525, 9486, 3352, 29918, 29907, 3927, 15789, 29918, 2287, 29963, 29918, 1529, 11601, 4519, 1783, 4574, 1001, 2396, 525, 29885, 2580, 29889, 2517, 9765, 9945, 742, 13, 1678, 525, 9486, 3352, 29918, 29907, 3927, 15789, 29918, 2287, 29963, 29918, 20387, 29931, 29918, 23207, 2396, 525, 29885, 2580, 29889, 3195, 4557, 742, 13, 1678, 525, 9486, 3352, 29918, 29907, 3927, 15789, 29918, 2287, 29963, 29918, 6304, 25758, 29918, 23207, 2396, 525, 29885, 2580, 29889, 9125, 4557, 742, 13, 1678, 525, 9486, 3352, 29918, 29907, 3927, 15789, 29918, 2287, 29963, 29918, 2287, 19059, 29918, 11116, 2396, 525, 29885, 2580, 29889, 11501, 1542, 742, 13, 1678, 525, 9486, 3352, 29918, 29907, 3927, 15789, 29918, 2287, 29963, 29918, 29950, 17011, 12982, 1525, 29918, 16358, 2396, 525, 29885, 2580, 29889, 29950, 538, 2519, 6594, 742, 13, 1678, 525, 9486, 3352, 29918, 29907, 3927, 15789, 29918, 2287, 29963, 29918, 2303, 29924, 18929, 29918, 29911, 2891, 1964, 29918, 26067, 2396, 525, 29885, 2580, 29889, 16015, 11536, 26067, 742, 13, 1678, 525, 2817, 29918, 1682, 29918, 4381, 29918, 6327, 8021, 2396, 525, 29885, 2580, 29889, 6422, 6444, 20455, 742, 13, 1678, 525, 2817, 29918, 1682, 29918, 1990, 29918, 333, 2396, 525, 29885, 2580, 29889, 2385, 1204, 742, 13, 1678, 525, 2817, 29918, 1682, 29918, 19167, 29918, 333, 2396, 525, 29885, 2580, 29889, 29963, 12184, 1204, 29915, 13, 29913, 13, 13, 3991, 4736, 353, 4257, 23583, 877, 3991, 4736, 742, 6024, 1469, 742, 525, 1170, 11287, 13, 20455, 8021, 353, 4257, 23583, 877, 20455, 8021, 742, 6024, 1469, 742, 525, 5809, 742, 525, 1170, 11287, 13, 2558, 353, 4257, 23583, 877, 2558, 742, 6024, 1469, 742, 525, 5809, 742, 525, 1170, 742, 525, 1542, 11287, 13, 13, 1990, 315, 29933, 1955, 18545, 7295, 13, 13, 1678, 822, 4770, 2344, 12035, 1311, 29892, 5849, 29918, 6327, 8021, 29892, 2767, 29918, 10314, 29892, 274, 4089, 29918, 1445, 1125, 13, 4706, 1583, 29889, 25431, 29918, 6327, 8021, 353, 5849, 29918, 6327, 8021, 13, 4706, 1583, 29889, 5504, 29918, 10314, 353, 2767, 29918, 10314, 13, 4706, 1583, 29889, 29883, 4089, 29918, 1445, 353, 274, 4089, 29918, 1445, 13, 13, 13, 1678, 822, 4770, 3198, 29918, 1445, 29918, 9933, 29898, 1311, 29892, 2224, 1125, 13, 4706, 565, 451, 2897, 29889, 2084, 29889, 275, 1445, 29898, 2084, 1125, 13, 9651, 1596, 703, 2283, 14210, 29879, 29915, 947, 451, 1863, 23157, 13, 9651, 736, 7700, 13, 4706, 736, 5852, 13, 13, 1678, 822, 6088, 29918, 29883, 29918, 1445, 29898, 1311, 1125, 13, 4706, 565, 451, 1583, 17255, 3198, 29918, 1445, 29918, 9933, 29898, 1311, 29889, 25431, 29918, 6327, 8021, 29897, 470, 320, 13, 965, 451, 1583, 17255, 3198, 29918, 1445, 29918, 9933, 29898, 1311, 29889, 5504, 29918, 10314, 1125, 13, 9651, 736, 6213, 13, 13, 4706, 1819, 353, 6571, 13, 4706, 1819, 29889, 5504, 29898, 29907, 11726, 4197, 1311, 29889, 25431, 29918, 6327, 8021, 14664, 1753, 29879, 29889, 657, 877, 5975, 8785, 13, 4706, 1819, 29889, 5504, 29898, 29907, 11726, 4197, 1311, 29889, 5504, 29918, 10314, 1402, 13, 462, 795, 5825, 1883, 3790, 13, 462, 462, 29871, 525, 9486, 3352, 29918, 29907, 3927, 15789, 29918, 2287, 29963, 29918, 14474, 29918, 1367, 29915, 584, 29871, 29896, 29892, 13, 462, 462, 29871, 525, 9486, 3352, 29918, 29907, 3927, 15789, 29918, 2287, 29963, 29918, 14474, 29918, 29907, 20161, 29915, 584, 29871, 29896, 13, 462, 9651, 22719, 1753, 29879, 29889, 657, 877, 5975, 8785, 13, 4706, 736, 1819, 13, 13, 13, 1678, 822, 1653, 29918, 29883, 4089, 29918, 1272, 29898, 1311, 29892, 24987, 1125, 13, 4706, 274, 4089, 29918, 1272, 353, 11117, 20455, 928, 1078, 2396, 19997, 13, 462, 268, 525, 15506, 29915, 584, 19997, 13, 462, 268, 525, 3991, 9629, 2396, 19997, 13, 462, 268, 525, 4504, 2004, 6594, 2396, 525, 29900, 29889, 29900, 29889, 29896, 10827, 13, 13, 4706, 671, 29918, 8704, 353, 29871, 29896, 565, 525, 9486, 3352, 29918, 29907, 3927, 15789, 29918, 2287, 29963, 29918, 8456, 2891, 10810, 3301, 29918, 18603, 29918, 15551, 29915, 297, 24987, 29889, 8149, 580, 1683, 29871, 29900, 13, 4706, 274, 4089, 29918, 1272, 1839, 3991, 9629, 13359, 4397, 29898, 3991, 4736, 29898, 1509, 29918, 8704, 29892, 525, 29885, 2580, 29889, 11403, 20967, 5698, 2824, 29918, 294, 8977, 3101, 13, 13, 4706, 363, 1820, 297, 24987, 29889, 8149, 7295, 13, 9651, 722, 353, 24987, 29889, 657, 29898, 1989, 29897, 13, 9651, 274, 4089, 29918, 1707, 29918, 1989, 353, 14636, 29918, 23827, 29889, 657, 29898, 1989, 29892, 6213, 29897, 13, 9651, 565, 274, 4089, 29918, 1707, 29918, 1989, 29901, 13, 18884, 565, 1820, 297, 315, 20161, 6545, 2965, 3040, 29918, 10818, 29903, 29901, 13, 462, 1678, 7023, 29918, 1272, 353, 2281, 29889, 4058, 877, 29995, 29879, 29933, 29915, 1273, 7431, 29898, 1707, 511, 334, 1707, 416, 13, 462, 1678, 12289, 353, 18410, 8021, 29898, 10389, 29918, 1272, 29892, 525, 672, 742, 274, 4089, 29918, 1707, 29918, 1989, 467, 29918, 294, 8977, 580, 13, 462, 1678, 274, 4089, 29918, 1272, 1839, 20455, 928, 1078, 13359, 4397, 29898, 6327, 8021, 29897, 13, 18884, 25342, 1820, 297, 14636, 29918, 10818, 29903, 29901, 13, 462, 1678, 7023, 29918, 1272, 353, 2281, 29889, 4058, 877, 29995, 29879, 29933, 29915, 1273, 7431, 29898, 1707, 511, 334, 1707, 416, 13, 462, 1678, 2024, 29918, 1989, 353, 7670, 29898, 10389, 29918, 1272, 29892, 525, 672, 742, 274, 4089, 29918, 1707, 29918, 1989, 29892, 525, 29923, 4174, 25207, 2824, 29918, 294, 8977, 580, 13, 462, 1678, 274, 4089, 29918, 1272, 1839, 15506, 13359, 4397, 29898, 9053, 29918, 1989, 29897, 13, 18884, 25342, 1820, 297, 16924, 29918, 10818, 29903, 29901, 13, 462, 1678, 7023, 29918, 1272, 353, 2281, 29889, 4058, 877, 29995, 29879, 29933, 29915, 1273, 7431, 29898, 1707, 511, 334, 1707, 29897, 13, 462, 1678, 2295, 29918, 3207, 353, 12782, 4736, 29898, 10389, 29918, 1272, 29892, 274, 4089, 29918, 1707, 29918, 1989, 467, 29918, 294, 8977, 580, 13, 462, 1678, 274, 4089, 29918, 1272, 1839, 3991, 9629, 13359, 4397, 29898, 2917, 29918, 3207, 29897, 13, 18884, 1683, 29901, 13, 462, 1678, 2295, 29918, 3207, 353, 12782, 4736, 29898, 1707, 29892, 274, 4089, 29918, 1707, 29918, 1989, 467, 29918, 294, 8977, 580, 13, 462, 1678, 274, 4089, 29918, 1272, 1839, 3991, 9629, 13359, 4397, 29898, 2917, 29918, 3207, 29897, 13, 9651, 1683, 29901, 13, 18884, 1596, 703, 2558, 1273, 29879, 451, 297, 14636, 29918, 23827, 1213, 1273, 1820, 29897, 13, 13, 4706, 736, 274, 4089, 29918, 1272, 13, 13, 13, 1678, 822, 3588, 29918, 517, 29918, 29883, 4089, 29898, 1311, 1125, 13, 4706, 24987, 353, 1583, 29889, 5510, 29918, 29883, 29918, 1445, 580, 13, 4706, 565, 451, 24987, 29901, 13, 9651, 1596, 703, 3782, 3651, 21213, 23157, 13, 4706, 1683, 29901, 13, 9651, 274, 4089, 29918, 1272, 353, 1583, 29889, 3258, 29918, 29883, 4089, 29918, 1272, 29898, 16908, 29897, 13, 9651, 411, 1722, 29898, 1311, 29889, 29883, 4089, 29918, 1445, 29892, 525, 29893, 29890, 1495, 408, 714, 29918, 1445, 29901, 13, 18884, 274, 4089, 29906, 29889, 15070, 29898, 29883, 4089, 29918, 1272, 29892, 714, 29918, 1445, 29897, 13, 2 ]
distributed/deploy/adaptive_core.py
arpit1997/distributed
0
70888
<reponame>arpit1997/distributed import collections import math from tornado.ioloop import IOLoop import toolz from ..metrics import time from ..utils import parse_timedelta, PeriodicCallback class AdaptiveCore: """ The core logic for adaptive deployments, with none of the cluster details This class controls our adaptive scaling behavior. It is intended to be sued as a super-class or mixin. It expects the following state and methods: **State** plan: set A set of workers that we think should exist. Here and below worker is just a token, often an address or name string requested: set A set of workers that the cluster class has successfully requested from the resource manager. We expect that resource manager to work to make these exist. observed: set A set of workers that have successfully checked in with the scheduler These sets are not necessarily equivalent. Often plan and requested will be very similar (requesting is usually fast) but there may be a large delay between requested and observed (often resource managers don't give us what we want). **Functions** target : -> int Returns the target number of workers that should exist. This is often obtained by querying the scheduler workers_to_close : int -> Set[worker] Given a target number of workers, returns a set of workers that we should close when we're scaling down scale_up : int -> None Scales the cluster up to a target number of workers, presumably changing at least ``plan`` and hopefully eventually also ``requested`` scale_down : Set[worker] -> None Closes the provided set of workers Parameters ---------- minimum: int The minimum number of allowed workers maximum: int The maximum number of allowed workers wait_count: int The number of scale-down requests we should receive before actually scaling down interval: str The amount of time, like ``"1s"`` between checks """ def __init__( self, minimum: int = 0, maximum: int = math.inf, wait_count: int = 3, interval: str = "1s", ): self.minimum = minimum self.maximum = maximum self.wait_count = wait_count self.interval = parse_timedelta(interval, "seconds") if interval else interval self.periodic_callback = None def f(): self.periodic_callback = PeriodicCallback(self.adapt, self.interval * 1000) self.periodic_callback.start() if self.interval: try: self.loop.add_callback(f) except AttributeError: IOLoop.current().add_callback(f) try: self.plan = set() self.requested = set() self.observed = set() except Exception: pass # internal state self.close_counts = collections.defaultdict(int) self._adapting = False self.log = collections.deque(maxlen=10000) def stop(self): if self.periodic_callback: self.periodic_callback.stop() self.periodic_callback = None async def target(self) -> int: """ The target number of workers that should exist """ raise NotImplementedError() async def workers_to_close(self, target: int) -> list: """ Give a list of workers to close that brings us down to target workers """ # TODO, improve me with something that thinks about current load return list(self.observed)[target:] async def safe_target(self) -> int: """ Used internally, like target, but respects minimum/maximum """ n = await self.target() if n > self.maximum: n = self.maximum if n < self.minimum: n = self.minimum return n async def recommendations(self, target: int) -> dict: """ Make scale up/down recommendations based on current state and target """ plan = self.plan requested = self.requested observed = self.observed if target == len(plan): self.close_counts.clear() return {"status": "same"} elif target > len(plan): self.close_counts.clear() return {"status": "up", "n": target} elif target < len(plan): not_yet_arrived = requested - observed to_close = set() if not_yet_arrived: to_close.update((toolz.take(len(plan) - target, not_yet_arrived))) if target < len(plan) - len(to_close): L = await self.workers_to_close(target=target) to_close.update(L) firmly_close = set() for w in to_close: self.close_counts[w] += 1 if self.close_counts[w] >= self.wait_count: firmly_close.add(w) for k in list(self.close_counts): # clear out unseen keys if k in firmly_close or k not in to_close: del self.close_counts[k] if firmly_close: return {"status": "down", "workers": list(firmly_close)} else: return {"status": "same"} async def adapt(self) -> None: """ Check the current state, make recommendations, call scale This is the main event of the system """ if self._adapting: # Semaphore to avoid overlapping adapt calls return self._adapting = True try: target = await self.safe_target() recommendations = await self.recommendations(target) if recommendations["status"] != "same": self.log.append((time(), dict(recommendations))) status = recommendations.pop("status") if status == "same": return if status == "up": await self.scale_up(**recommendations) if status == "down": await self.scale_down(**recommendations) except OSError: self.stop() finally: self._adapting = False
[ 1, 529, 276, 1112, 420, 29958, 6834, 277, 29896, 29929, 29929, 29955, 29914, 5721, 7541, 13, 5215, 16250, 13, 5215, 5844, 13, 13, 3166, 10146, 912, 29889, 29875, 3543, 459, 1053, 10663, 18405, 13, 5215, 5780, 29920, 13, 13, 3166, 6317, 2527, 10817, 1053, 931, 13, 3166, 6317, 13239, 1053, 6088, 29918, 9346, 287, 2554, 29892, 29498, 293, 10717, 13, 13, 13, 1990, 23255, 415, 573, 9203, 29901, 13, 1678, 9995, 13, 1678, 450, 7136, 5900, 363, 7744, 573, 7246, 1860, 29892, 411, 5642, 310, 278, 9867, 4902, 13, 13, 1678, 910, 770, 11761, 1749, 7744, 573, 21640, 6030, 29889, 29871, 739, 338, 9146, 304, 367, 13, 1678, 480, 287, 408, 263, 2428, 29899, 1990, 470, 6837, 262, 29889, 29871, 739, 23347, 278, 1494, 2106, 322, 3519, 29901, 13, 13, 1678, 3579, 2792, 1068, 13, 13, 1678, 3814, 29901, 731, 13, 4706, 319, 731, 310, 17162, 393, 591, 1348, 881, 1863, 29889, 13, 4706, 2266, 322, 2400, 15645, 338, 925, 263, 5993, 29892, 4049, 385, 3211, 470, 1024, 1347, 13, 13, 1678, 13877, 29901, 731, 13, 4706, 319, 731, 310, 17162, 393, 278, 9867, 770, 756, 8472, 13877, 515, 13, 4706, 278, 6503, 8455, 29889, 29871, 1334, 2149, 393, 6503, 8455, 304, 664, 304, 1207, 13, 4706, 1438, 1863, 29889, 13, 13, 1678, 8900, 29901, 731, 13, 4706, 319, 731, 310, 17162, 393, 505, 8472, 7120, 297, 411, 278, 1364, 14952, 13, 13, 1678, 4525, 6166, 526, 451, 12695, 7126, 29889, 29871, 438, 15535, 3814, 322, 13877, 674, 13, 1678, 367, 1407, 2788, 313, 3827, 292, 338, 5491, 5172, 29897, 541, 727, 1122, 367, 263, 2919, 9055, 13, 1678, 1546, 13877, 322, 8900, 313, 29877, 15535, 6503, 767, 18150, 1016, 29915, 29873, 2367, 502, 825, 13, 1678, 591, 864, 467, 13, 13, 1678, 3579, 6678, 29879, 1068, 13, 13, 1678, 3646, 584, 1599, 938, 13, 4706, 16969, 278, 3646, 1353, 310, 17162, 393, 881, 1863, 29889, 13, 4706, 910, 338, 4049, 7625, 491, 2346, 292, 278, 1364, 14952, 13, 13, 1678, 17162, 29918, 517, 29918, 5358, 584, 938, 1599, 3789, 29961, 24602, 29962, 13, 4706, 11221, 263, 3646, 1353, 310, 17162, 29892, 13, 4706, 3639, 263, 731, 310, 17162, 393, 591, 881, 3802, 746, 591, 29915, 276, 21640, 1623, 13, 13, 1678, 6287, 29918, 786, 584, 938, 1599, 6213, 13, 4706, 317, 1052, 267, 278, 9867, 701, 304, 263, 3646, 1353, 310, 17162, 29892, 2225, 24873, 13, 4706, 6480, 472, 3203, 4954, 9018, 16159, 322, 27581, 10201, 884, 4954, 3827, 287, 16159, 13, 13, 1678, 6287, 29918, 3204, 584, 3789, 29961, 24602, 29962, 1599, 6213, 13, 4706, 2233, 15806, 278, 4944, 731, 310, 17162, 13, 13, 1678, 12662, 2699, 13, 1678, 448, 1378, 29899, 13, 1678, 9212, 29901, 938, 13, 4706, 450, 9212, 1353, 310, 6068, 17162, 13, 1678, 7472, 29901, 938, 13, 4706, 450, 7472, 1353, 310, 6068, 17162, 13, 1678, 4480, 29918, 2798, 29901, 938, 13, 4706, 450, 1353, 310, 6287, 29899, 3204, 7274, 591, 881, 7150, 1434, 2869, 13, 4706, 21640, 1623, 13, 1678, 7292, 29901, 851, 13, 4706, 450, 5253, 310, 931, 29892, 763, 4954, 29908, 29896, 29879, 6937, 29952, 1546, 12747, 13, 1678, 9995, 13, 13, 1678, 822, 4770, 2344, 12035, 13, 4706, 1583, 29892, 13, 4706, 9212, 29901, 938, 353, 29871, 29900, 29892, 13, 4706, 7472, 29901, 938, 353, 5844, 29889, 7192, 29892, 13, 4706, 4480, 29918, 2798, 29901, 938, 353, 29871, 29941, 29892, 13, 4706, 7292, 29901, 851, 353, 376, 29896, 29879, 613, 13, 268, 1125, 13, 4706, 1583, 29889, 1195, 12539, 353, 9212, 13, 4706, 1583, 29889, 27525, 398, 353, 7472, 13, 4706, 1583, 29889, 10685, 29918, 2798, 353, 4480, 29918, 2798, 13, 4706, 1583, 29889, 19207, 353, 6088, 29918, 9346, 287, 2554, 29898, 19207, 29892, 376, 23128, 1159, 565, 7292, 1683, 7292, 13, 4706, 1583, 29889, 19145, 293, 29918, 14035, 353, 6213, 13, 13, 4706, 822, 285, 7295, 13, 9651, 1583, 29889, 19145, 293, 29918, 14035, 353, 29498, 293, 10717, 29898, 1311, 29889, 1114, 415, 29892, 1583, 29889, 19207, 334, 29871, 29896, 29900, 29900, 29900, 29897, 13, 9651, 1583, 29889, 19145, 293, 29918, 14035, 29889, 2962, 580, 13, 13, 4706, 565, 1583, 29889, 19207, 29901, 13, 9651, 1018, 29901, 13, 18884, 1583, 29889, 7888, 29889, 1202, 29918, 14035, 29898, 29888, 29897, 13, 9651, 5174, 23833, 2392, 29901, 13, 18884, 10663, 18405, 29889, 3784, 2141, 1202, 29918, 14035, 29898, 29888, 29897, 13, 13, 4706, 1018, 29901, 13, 9651, 1583, 29889, 9018, 353, 731, 580, 13, 9651, 1583, 29889, 3827, 287, 353, 731, 580, 13, 9651, 1583, 29889, 711, 643, 1490, 353, 731, 580, 13, 4706, 5174, 8960, 29901, 13, 9651, 1209, 13, 13, 4706, 396, 7463, 2106, 13, 4706, 1583, 29889, 5358, 29918, 2798, 29879, 353, 16250, 29889, 4381, 8977, 29898, 524, 29897, 13, 4706, 1583, 3032, 1114, 415, 292, 353, 7700, 13, 4706, 1583, 29889, 1188, 353, 16250, 29889, 311, 802, 29898, 3317, 2435, 29922, 29896, 29900, 29900, 29900, 29900, 29897, 13, 13, 1678, 822, 5040, 29898, 1311, 1125, 13, 4706, 565, 1583, 29889, 19145, 293, 29918, 14035, 29901, 13, 9651, 1583, 29889, 19145, 293, 29918, 14035, 29889, 9847, 580, 13, 9651, 1583, 29889, 19145, 293, 29918, 14035, 353, 6213, 13, 13, 1678, 7465, 822, 3646, 29898, 1311, 29897, 1599, 938, 29901, 13, 4706, 9995, 450, 3646, 1353, 310, 17162, 393, 881, 1863, 9995, 13, 4706, 12020, 2216, 1888, 2037, 287, 2392, 580, 13, 13, 1678, 7465, 822, 17162, 29918, 517, 29918, 5358, 29898, 1311, 29892, 3646, 29901, 938, 29897, 1599, 1051, 29901, 13, 4706, 9995, 13, 4706, 25538, 263, 1051, 310, 17162, 304, 3802, 393, 23522, 502, 1623, 304, 3646, 17162, 13, 4706, 9995, 13, 4706, 396, 14402, 29892, 11157, 592, 411, 1554, 393, 22405, 1048, 1857, 2254, 13, 4706, 736, 1051, 29898, 1311, 29889, 711, 643, 1490, 9601, 5182, 17531, 13, 13, 1678, 7465, 822, 9109, 29918, 5182, 29898, 1311, 29897, 1599, 938, 29901, 13, 4706, 9995, 501, 8485, 25106, 29892, 763, 3646, 29892, 541, 3390, 29879, 9212, 29914, 27525, 398, 9995, 13, 4706, 302, 353, 7272, 1583, 29889, 5182, 580, 13, 4706, 565, 302, 1405, 1583, 29889, 27525, 398, 29901, 13, 9651, 302, 353, 1583, 29889, 27525, 398, 13, 13, 4706, 565, 302, 529, 1583, 29889, 1195, 12539, 29901, 13, 9651, 302, 353, 1583, 29889, 1195, 12539, 13, 13, 4706, 736, 302, 13, 13, 1678, 7465, 822, 6907, 800, 29898, 1311, 29892, 3646, 29901, 938, 29897, 1599, 9657, 29901, 13, 4706, 9995, 13, 4706, 8561, 6287, 701, 29914, 3204, 6907, 800, 2729, 373, 1857, 2106, 322, 3646, 13, 4706, 9995, 13, 4706, 3814, 353, 1583, 29889, 9018, 13, 4706, 13877, 353, 1583, 29889, 3827, 287, 13, 4706, 8900, 353, 1583, 29889, 711, 643, 1490, 13, 13, 4706, 565, 3646, 1275, 7431, 29898, 9018, 1125, 13, 9651, 1583, 29889, 5358, 29918, 2798, 29879, 29889, 8551, 580, 13, 9651, 736, 8853, 4882, 1115, 376, 17642, 9092, 13, 13, 4706, 25342, 3646, 1405, 7431, 29898, 9018, 1125, 13, 9651, 1583, 29889, 5358, 29918, 2798, 29879, 29889, 8551, 580, 13, 9651, 736, 8853, 4882, 1115, 376, 786, 613, 376, 29876, 1115, 3646, 29913, 13, 13, 4706, 25342, 3646, 529, 7431, 29898, 9018, 1125, 13, 9651, 451, 29918, 29891, 300, 29918, 279, 1150, 287, 353, 13877, 448, 8900, 13, 9651, 304, 29918, 5358, 353, 731, 580, 13, 9651, 565, 451, 29918, 29891, 300, 29918, 279, 1150, 287, 29901, 13, 18884, 304, 29918, 5358, 29889, 5504, 3552, 10154, 29920, 29889, 19730, 29898, 2435, 29898, 9018, 29897, 448, 3646, 29892, 451, 29918, 29891, 300, 29918, 279, 1150, 287, 4961, 13, 13, 9651, 565, 3646, 529, 7431, 29898, 9018, 29897, 448, 7431, 29898, 517, 29918, 5358, 1125, 13, 18884, 365, 353, 7272, 1583, 29889, 1287, 414, 29918, 517, 29918, 5358, 29898, 5182, 29922, 5182, 29897, 13, 18884, 304, 29918, 5358, 29889, 5504, 29898, 29931, 29897, 13, 13, 9651, 9226, 368, 29918, 5358, 353, 731, 580, 13, 9651, 363, 281, 297, 304, 29918, 5358, 29901, 13, 18884, 1583, 29889, 5358, 29918, 2798, 29879, 29961, 29893, 29962, 4619, 29871, 29896, 13, 18884, 565, 1583, 29889, 5358, 29918, 2798, 29879, 29961, 29893, 29962, 6736, 1583, 29889, 10685, 29918, 2798, 29901, 13, 462, 1678, 9226, 368, 29918, 5358, 29889, 1202, 29898, 29893, 29897, 13, 13, 9651, 363, 413, 297, 1051, 29898, 1311, 29889, 5358, 29918, 2798, 29879, 1125, 29871, 396, 2821, 714, 443, 28026, 6611, 13, 18884, 565, 413, 297, 9226, 368, 29918, 5358, 470, 413, 451, 297, 304, 29918, 5358, 29901, 13, 462, 1678, 628, 1583, 29889, 5358, 29918, 2798, 29879, 29961, 29895, 29962, 13, 13, 9651, 565, 9226, 368, 29918, 5358, 29901, 13, 18884, 736, 8853, 4882, 1115, 376, 3204, 613, 376, 1287, 414, 1115, 1051, 29898, 29888, 3568, 368, 29918, 5358, 2915, 13, 9651, 1683, 29901, 13, 18884, 736, 8853, 4882, 1115, 376, 17642, 9092, 13, 13, 1678, 7465, 822, 7744, 29898, 1311, 29897, 1599, 6213, 29901, 13, 4706, 9995, 13, 4706, 5399, 278, 1857, 2106, 29892, 1207, 6907, 800, 29892, 1246, 6287, 13, 13, 4706, 910, 338, 278, 1667, 1741, 310, 278, 1788, 13, 4706, 9995, 13, 4706, 565, 1583, 3032, 1114, 415, 292, 29901, 29871, 396, 9444, 12451, 487, 304, 4772, 975, 433, 3262, 7744, 5717, 13, 9651, 736, 13, 4706, 1583, 3032, 1114, 415, 292, 353, 5852, 13, 13, 4706, 1018, 29901, 13, 9651, 3646, 353, 7272, 1583, 29889, 11177, 29918, 5182, 580, 13, 9651, 6907, 800, 353, 7272, 1583, 29889, 276, 2055, 355, 800, 29898, 5182, 29897, 13, 13, 9651, 565, 6907, 800, 3366, 4882, 3108, 2804, 376, 17642, 1115, 13, 18884, 1583, 29889, 1188, 29889, 4397, 3552, 2230, 3285, 9657, 29898, 276, 2055, 355, 800, 4961, 13, 13, 9651, 4660, 353, 6907, 800, 29889, 7323, 703, 4882, 1159, 13, 9651, 565, 4660, 1275, 376, 17642, 1115, 13, 18884, 736, 13, 9651, 565, 4660, 1275, 376, 786, 1115, 13, 18884, 7272, 1583, 29889, 7052, 29918, 786, 29898, 1068, 276, 2055, 355, 800, 29897, 13, 9651, 565, 4660, 1275, 376, 3204, 1115, 13, 18884, 7272, 1583, 29889, 7052, 29918, 3204, 29898, 1068, 276, 2055, 355, 800, 29897, 13, 4706, 5174, 438, 29173, 29901, 13, 9651, 1583, 29889, 9847, 580, 13, 4706, 7146, 29901, 13, 9651, 1583, 3032, 1114, 415, 292, 353, 7700, 13, 2 ]
data_management/data.py
School-courses/covid19-forecast
0
95780
import os from functools import reduce import numpy as np import pandas as pd from sklearn.preprocessing import minmax_scale, scale class Data(): def __init__(self, no_hist_days, no_hist_weeks, target_label, root_dir="", begin_test_date=None, scale_data=None): data_daily = os.path.join(root_dir, "data/slovenia_daily.csv") data_weekly = os.path.join(root_dir, "data/slovenia_weekly.csv") self.df_daily = pd.read_csv(data_daily) self.df_weekly = pd.read_csv(data_weekly) self.df_daily['date'] = pd.to_datetime(self.df_daily['date']) self.df_weekly['date'] = pd.to_datetime(self.df_weekly['date']) self.target_label = target_label self.no_hist_days = no_hist_days self.no_hist_weeks = no_hist_weeks self.begin_test_date = begin_test_date self.scale_data = scale_data self.predictors_col_names = [] self.df_data_table = self._create_data_table() def _create_base_table(self): """ Create base table filled with daily values, target value and date""" list_hist_vals = [] for timestamp in self.df_weekly['date']: end_date = timestamp - pd.DateOffset(6) # 6 day (1 week) offset for week prediction start_date = end_date - pd.DateOffset(self.no_hist_days) mask_dates = (self.df_daily["date"] > start_date) & (self.df_daily["date"] <= end_date) predictors = self.df_daily[mask_dates].loc[:, self.target_label].to_numpy() list_hist_vals.append(predictors) bool_hist_vals = [len(hist_vals) == self.no_hist_days for hist_vals in list_hist_vals] num = len(list_hist_vals) - sum(bool_hist_vals) # remove num instances which are not equal to self.no_hist_vals target_df = self.df_weekly[self.target_label].loc[num:].reset_index(drop=True).to_frame("target") date_target_df = self.df_weekly["date"].loc[num:].reset_index(drop=True).to_frame() col_names = [f"d_{idx}" for idx in reversed(range(1, len(list_hist_vals[num])+1))] predictors_df = pd.DataFrame(list_hist_vals[num:], columns=col_names) self.predictors_col_names.extend(col_names) df_base_table = pd.concat([date_target_df, target_df, predictors_df], axis=1) return df_base_table def _create_weekly_table(self, df_base_table): """ Create table with weekly values""" list_hist_vals = [] for timestamp in df_base_table['date']: end_date = timestamp - pd.DateOffset(weeks=1) # 1 week offset for prediction start_date = end_date - pd.DateOffset(weeks=self.no_hist_weeks) mask_dates = (self.df_weekly["date"] > start_date) & (self.df_weekly["date"] <= end_date) predictors = self.df_weekly[mask_dates].loc[:, self.target_label].to_numpy() list_hist_vals.append(predictors) bool_hist_vals = [len(hist_vals) == self.no_hist_weeks for hist_vals in list_hist_vals] num = len(list_hist_vals) - sum(bool_hist_vals) date_target_df = df_base_table["date"].loc[num:].reset_index(drop=True).to_frame() col_names = [f"w_{idx}" for idx in reversed(range(1, len(list_hist_vals[num])+1))] predictors_df = pd.DataFrame(list_hist_vals[num:], columns=col_names) self.predictors_col_names.extend(col_names) df_weekly_table = pd.concat([date_target_df, predictors_df], axis=1) return df_weekly_table def _create_other_table(self): """ Create table with additional informations""" df_other = self.df_weekly.copy() df_other = df_other.drop(columns=["week", "new_cases", "new_deaths"]) df_other["date"] = df_other["date"].shift(-1) # predictions from last week df_other = df_other[:-1] col_names = df_other.drop(columns=["date"]).columns.to_list() self.predictors_col_names.extend(col_names) return df_other def _create_data_table(self): base_table = self._create_base_table() weekly_table = self._create_weekly_table(base_table) other_table = self._create_other_table() dfs = [base_table, weekly_table, other_table] data_table = reduce(lambda left, right: pd.merge(left, right, how="inner", on="date"), dfs) data_table = self._scale_data_table(data_table) return data_table def _scale_data_table(self, data_table): if self.scale_data == "scale": data_table[self.predictors_col_names] = scale(data_table[self.predictors_col_names]) elif self.scale_data == "minmax": data_table[self.predictors_col_names] = minmax_scale(data_table[self.predictors_col_names]) return data_table def get_data(self, save=False): if save: self.df_data_table.to_csv("data/data_table.csv", index=False) def convert_to_numpy(df): X = df.reindex(columns = self.predictors_col_names).to_numpy() y = df.loc[:, "target"].to_numpy() y = np.expand_dims(y, axis = 1) return X, y df_train = self.df_data_table[self.df_data_table["date"] < self.begin_test_date] df_test = self.df_data_table[self.df_data_table["date"] >= self.begin_test_date] X_train, y_train = convert_to_numpy(df_train) X_test, y_test = convert_to_numpy(df_test) return X_train, y_train, X_test, y_test if __name__ == "__main__": from skmultiflow.data import DataStream, RegressionGenerator target_label = "new_cases" no_hist_days = 0 no_hist_weeks = 2 begin_test_date = "2021-11-06" scale_data = None data = Data( no_hist_days=no_hist_days, no_hist_weeks=no_hist_weeks, target_label=target_label, begin_test_date=begin_test_date, scale_data=scale_data ) X_train, y_train, X_test_t, y_test_t = data.get_data() stream = DataStream(X_test_t, y_test_t)
[ 1, 1053, 2897, 13, 3166, 2090, 312, 8789, 1053, 10032, 13, 13, 5215, 12655, 408, 7442, 13, 5215, 11701, 408, 10518, 13, 3166, 2071, 19668, 29889, 1457, 19170, 1053, 1375, 3317, 29918, 7052, 29892, 6287, 13, 13, 13, 1990, 3630, 7295, 13, 1678, 822, 4770, 2344, 12035, 1311, 29892, 694, 29918, 29882, 391, 29918, 16700, 29892, 694, 29918, 29882, 391, 29918, 705, 14541, 29892, 3646, 29918, 1643, 29892, 3876, 29918, 3972, 543, 613, 3380, 29918, 1688, 29918, 1256, 29922, 8516, 29892, 6287, 29918, 1272, 29922, 8516, 1125, 13, 4706, 848, 29918, 29881, 8683, 353, 2897, 29889, 2084, 29889, 7122, 29898, 4632, 29918, 3972, 29892, 376, 1272, 29914, 29879, 417, 854, 423, 29918, 29881, 8683, 29889, 7638, 1159, 13, 4706, 848, 29918, 18448, 368, 353, 2897, 29889, 2084, 29889, 7122, 29898, 4632, 29918, 3972, 29892, 376, 1272, 29914, 29879, 417, 854, 423, 29918, 18448, 368, 29889, 7638, 1159, 13, 4706, 1583, 29889, 2176, 29918, 29881, 8683, 353, 10518, 29889, 949, 29918, 7638, 29898, 1272, 29918, 29881, 8683, 29897, 13, 4706, 1583, 29889, 2176, 29918, 18448, 368, 353, 10518, 29889, 949, 29918, 7638, 29898, 1272, 29918, 18448, 368, 29897, 13, 13, 4706, 1583, 29889, 2176, 29918, 29881, 8683, 1839, 1256, 2033, 353, 10518, 29889, 517, 29918, 12673, 29898, 1311, 29889, 2176, 29918, 29881, 8683, 1839, 1256, 11287, 13, 4706, 1583, 29889, 2176, 29918, 18448, 368, 1839, 1256, 2033, 353, 10518, 29889, 517, 29918, 12673, 29898, 1311, 29889, 2176, 29918, 18448, 368, 1839, 1256, 11287, 13, 13, 4706, 1583, 29889, 5182, 29918, 1643, 353, 3646, 29918, 1643, 13, 4706, 1583, 29889, 1217, 29918, 29882, 391, 29918, 16700, 353, 694, 29918, 29882, 391, 29918, 16700, 13, 4706, 1583, 29889, 1217, 29918, 29882, 391, 29918, 705, 14541, 353, 694, 29918, 29882, 391, 29918, 705, 14541, 13, 4706, 1583, 29889, 463, 29918, 1688, 29918, 1256, 353, 3380, 29918, 1688, 29918, 1256, 13, 4706, 1583, 29889, 7052, 29918, 1272, 353, 6287, 29918, 1272, 13, 4706, 1583, 29889, 27711, 943, 29918, 1054, 29918, 7039, 353, 5159, 13, 13, 4706, 1583, 29889, 2176, 29918, 1272, 29918, 2371, 353, 1583, 3032, 3258, 29918, 1272, 29918, 2371, 580, 13, 13, 13, 1678, 822, 903, 3258, 29918, 3188, 29918, 2371, 29898, 1311, 1125, 13, 4706, 9995, 6204, 2967, 1591, 10423, 411, 14218, 1819, 29892, 3646, 995, 322, 2635, 15945, 29908, 13, 4706, 1051, 29918, 29882, 391, 29918, 791, 29879, 353, 5159, 13, 4706, 363, 14334, 297, 1583, 29889, 2176, 29918, 18448, 368, 1839, 1256, 2033, 29901, 13, 9651, 1095, 29918, 1256, 353, 14334, 448, 10518, 29889, 2539, 10302, 29898, 29953, 29897, 396, 29871, 29953, 2462, 313, 29896, 4723, 29897, 9210, 363, 4723, 18988, 13, 9651, 1369, 29918, 1256, 353, 1095, 29918, 1256, 448, 10518, 29889, 2539, 10302, 29898, 1311, 29889, 1217, 29918, 29882, 391, 29918, 16700, 29897, 13, 9651, 11105, 29918, 15190, 353, 313, 1311, 29889, 2176, 29918, 29881, 8683, 3366, 1256, 3108, 1405, 1369, 29918, 1256, 29897, 669, 313, 1311, 29889, 2176, 29918, 29881, 8683, 3366, 1256, 3108, 5277, 1095, 29918, 1256, 29897, 13, 9651, 8500, 943, 353, 1583, 29889, 2176, 29918, 29881, 8683, 29961, 13168, 29918, 15190, 1822, 2029, 7503, 29892, 1583, 29889, 5182, 29918, 1643, 1822, 517, 29918, 23749, 580, 13, 9651, 1051, 29918, 29882, 391, 29918, 791, 29879, 29889, 4397, 29898, 27711, 943, 29897, 13, 13, 4706, 6120, 29918, 29882, 391, 29918, 791, 29879, 353, 518, 2435, 29898, 29882, 391, 29918, 791, 29879, 29897, 1275, 1583, 29889, 1217, 29918, 29882, 391, 29918, 16700, 363, 9825, 29918, 791, 29879, 297, 1051, 29918, 29882, 391, 29918, 791, 29879, 29962, 13, 4706, 954, 353, 7431, 29898, 1761, 29918, 29882, 391, 29918, 791, 29879, 29897, 448, 2533, 29898, 11227, 29918, 29882, 391, 29918, 791, 29879, 29897, 13, 13, 4706, 396, 3349, 954, 8871, 607, 526, 451, 5186, 304, 1583, 29889, 1217, 29918, 29882, 391, 29918, 791, 29879, 13, 4706, 3646, 29918, 2176, 353, 1583, 29889, 2176, 29918, 18448, 368, 29961, 1311, 29889, 5182, 29918, 1643, 1822, 2029, 29961, 1949, 29901, 1822, 12071, 29918, 2248, 29898, 8865, 29922, 5574, 467, 517, 29918, 2557, 703, 5182, 1159, 13, 4706, 2635, 29918, 5182, 29918, 2176, 353, 1583, 29889, 2176, 29918, 18448, 368, 3366, 1256, 16862, 2029, 29961, 1949, 29901, 1822, 12071, 29918, 2248, 29898, 8865, 29922, 5574, 467, 517, 29918, 2557, 580, 13, 13, 4706, 784, 29918, 7039, 353, 518, 29888, 29908, 29881, 648, 13140, 5038, 363, 22645, 297, 18764, 287, 29898, 3881, 29898, 29896, 29892, 7431, 29898, 1761, 29918, 29882, 391, 29918, 791, 29879, 29961, 1949, 2314, 29974, 29896, 28166, 13, 4706, 8500, 943, 29918, 2176, 353, 10518, 29889, 17271, 29898, 1761, 29918, 29882, 391, 29918, 791, 29879, 29961, 1949, 29901, 1402, 4341, 29922, 1054, 29918, 7039, 29897, 13, 4706, 1583, 29889, 27711, 943, 29918, 1054, 29918, 7039, 29889, 21843, 29898, 1054, 29918, 7039, 29897, 13, 13, 4706, 4489, 29918, 3188, 29918, 2371, 353, 10518, 29889, 17685, 4197, 1256, 29918, 5182, 29918, 2176, 29892, 3646, 29918, 2176, 29892, 8500, 943, 29918, 2176, 1402, 9685, 29922, 29896, 29897, 13, 4706, 736, 4489, 29918, 3188, 29918, 2371, 13, 13, 13, 1678, 822, 903, 3258, 29918, 18448, 368, 29918, 2371, 29898, 1311, 29892, 4489, 29918, 3188, 29918, 2371, 1125, 13, 4706, 9995, 6204, 1591, 411, 4723, 368, 1819, 15945, 29908, 13, 4706, 1051, 29918, 29882, 391, 29918, 791, 29879, 353, 5159, 13, 4706, 363, 14334, 297, 4489, 29918, 3188, 29918, 2371, 1839, 1256, 2033, 29901, 13, 9651, 1095, 29918, 1256, 353, 14334, 448, 10518, 29889, 2539, 10302, 29898, 705, 14541, 29922, 29896, 29897, 396, 29871, 29896, 4723, 9210, 363, 18988, 13, 9651, 1369, 29918, 1256, 353, 1095, 29918, 1256, 448, 10518, 29889, 2539, 10302, 29898, 705, 14541, 29922, 1311, 29889, 1217, 29918, 29882, 391, 29918, 705, 14541, 29897, 13, 9651, 11105, 29918, 15190, 353, 313, 1311, 29889, 2176, 29918, 18448, 368, 3366, 1256, 3108, 1405, 1369, 29918, 1256, 29897, 669, 313, 1311, 29889, 2176, 29918, 18448, 368, 3366, 1256, 3108, 5277, 1095, 29918, 1256, 29897, 13, 9651, 8500, 943, 353, 1583, 29889, 2176, 29918, 18448, 368, 29961, 13168, 29918, 15190, 1822, 2029, 7503, 29892, 1583, 29889, 5182, 29918, 1643, 1822, 517, 29918, 23749, 580, 13, 9651, 1051, 29918, 29882, 391, 29918, 791, 29879, 29889, 4397, 29898, 27711, 943, 29897, 13, 13, 4706, 6120, 29918, 29882, 391, 29918, 791, 29879, 353, 518, 2435, 29898, 29882, 391, 29918, 791, 29879, 29897, 1275, 1583, 29889, 1217, 29918, 29882, 391, 29918, 705, 14541, 363, 9825, 29918, 791, 29879, 297, 1051, 29918, 29882, 391, 29918, 791, 29879, 29962, 13, 4706, 954, 353, 7431, 29898, 1761, 29918, 29882, 391, 29918, 791, 29879, 29897, 448, 2533, 29898, 11227, 29918, 29882, 391, 29918, 791, 29879, 29897, 13, 4706, 2635, 29918, 5182, 29918, 2176, 353, 4489, 29918, 3188, 29918, 2371, 3366, 1256, 16862, 2029, 29961, 1949, 29901, 1822, 12071, 29918, 2248, 29898, 8865, 29922, 5574, 467, 517, 29918, 2557, 580, 13, 13, 4706, 784, 29918, 7039, 353, 518, 29888, 29908, 29893, 648, 13140, 5038, 363, 22645, 297, 18764, 287, 29898, 3881, 29898, 29896, 29892, 7431, 29898, 1761, 29918, 29882, 391, 29918, 791, 29879, 29961, 1949, 2314, 29974, 29896, 28166, 13, 4706, 8500, 943, 29918, 2176, 353, 10518, 29889, 17271, 29898, 1761, 29918, 29882, 391, 29918, 791, 29879, 29961, 1949, 29901, 1402, 4341, 29922, 1054, 29918, 7039, 29897, 13, 4706, 1583, 29889, 27711, 943, 29918, 1054, 29918, 7039, 29889, 21843, 29898, 1054, 29918, 7039, 29897, 13, 13, 4706, 4489, 29918, 18448, 368, 29918, 2371, 353, 10518, 29889, 17685, 4197, 1256, 29918, 5182, 29918, 2176, 29892, 8500, 943, 29918, 2176, 1402, 9685, 29922, 29896, 29897, 13, 4706, 736, 4489, 29918, 18448, 368, 29918, 2371, 13, 13, 13, 1678, 822, 903, 3258, 29918, 1228, 29918, 2371, 29898, 1311, 1125, 13, 4706, 9995, 6204, 1591, 411, 5684, 19313, 15945, 29908, 13, 4706, 4489, 29918, 1228, 353, 1583, 29889, 2176, 29918, 18448, 368, 29889, 8552, 580, 13, 4706, 4489, 29918, 1228, 353, 4489, 29918, 1228, 29889, 8865, 29898, 13099, 29922, 3366, 18448, 613, 376, 1482, 29918, 11436, 613, 376, 1482, 29918, 311, 493, 29879, 20068, 13, 4706, 4489, 29918, 1228, 3366, 1256, 3108, 353, 4489, 29918, 1228, 3366, 1256, 16862, 10889, 6278, 29896, 29897, 396, 27303, 515, 1833, 4723, 13, 4706, 4489, 29918, 1228, 353, 4489, 29918, 1228, 7503, 29899, 29896, 29962, 13, 4706, 784, 29918, 7039, 353, 4489, 29918, 1228, 29889, 8865, 29898, 13099, 29922, 3366, 1256, 3108, 467, 13099, 29889, 517, 29918, 1761, 580, 13, 4706, 1583, 29889, 27711, 943, 29918, 1054, 29918, 7039, 29889, 21843, 29898, 1054, 29918, 7039, 29897, 13, 4706, 736, 4489, 29918, 1228, 13, 13, 1678, 822, 903, 3258, 29918, 1272, 29918, 2371, 29898, 1311, 1125, 13, 4706, 2967, 29918, 2371, 353, 1583, 3032, 3258, 29918, 3188, 29918, 2371, 580, 13, 4706, 4723, 368, 29918, 2371, 353, 1583, 3032, 3258, 29918, 18448, 368, 29918, 2371, 29898, 3188, 29918, 2371, 29897, 13, 4706, 916, 29918, 2371, 353, 1583, 3032, 3258, 29918, 1228, 29918, 2371, 580, 13, 4706, 4489, 29879, 353, 518, 3188, 29918, 2371, 29892, 4723, 368, 29918, 2371, 29892, 916, 29918, 2371, 29962, 13, 4706, 848, 29918, 2371, 353, 10032, 29898, 2892, 2175, 29892, 1492, 29901, 10518, 29889, 14634, 29898, 1563, 29892, 1492, 29892, 920, 543, 3993, 613, 373, 543, 1256, 4968, 4489, 29879, 29897, 13, 4706, 848, 29918, 2371, 353, 1583, 3032, 7052, 29918, 1272, 29918, 2371, 29898, 1272, 29918, 2371, 29897, 13, 4706, 736, 848, 29918, 2371, 13, 13, 13, 1678, 822, 903, 7052, 29918, 1272, 29918, 2371, 29898, 1311, 29892, 848, 29918, 2371, 1125, 13, 4706, 565, 1583, 29889, 7052, 29918, 1272, 1275, 376, 7052, 1115, 13, 9651, 848, 29918, 2371, 29961, 1311, 29889, 27711, 943, 29918, 1054, 29918, 7039, 29962, 353, 6287, 29898, 1272, 29918, 2371, 29961, 1311, 29889, 27711, 943, 29918, 1054, 29918, 7039, 2314, 13, 4706, 25342, 1583, 29889, 7052, 29918, 1272, 1275, 376, 1195, 3317, 1115, 13, 9651, 848, 29918, 2371, 29961, 1311, 29889, 27711, 943, 29918, 1054, 29918, 7039, 29962, 353, 1375, 3317, 29918, 7052, 29898, 1272, 29918, 2371, 29961, 1311, 29889, 27711, 943, 29918, 1054, 29918, 7039, 2314, 13, 4706, 736, 848, 29918, 2371, 13, 13, 13, 1678, 822, 679, 29918, 1272, 29898, 1311, 29892, 4078, 29922, 8824, 1125, 13, 4706, 565, 4078, 29901, 13, 9651, 1583, 29889, 2176, 29918, 1272, 29918, 2371, 29889, 517, 29918, 7638, 703, 1272, 29914, 1272, 29918, 2371, 29889, 7638, 613, 2380, 29922, 8824, 29897, 13, 13, 4706, 822, 3588, 29918, 517, 29918, 23749, 29898, 2176, 1125, 13, 9651, 1060, 353, 4489, 29889, 276, 2248, 29898, 13099, 353, 1583, 29889, 27711, 943, 29918, 1054, 29918, 7039, 467, 517, 29918, 23749, 580, 13, 9651, 343, 353, 4489, 29889, 2029, 7503, 29892, 376, 5182, 16862, 517, 29918, 23749, 580, 13, 9651, 343, 353, 7442, 29889, 18837, 29918, 6229, 29879, 29898, 29891, 29892, 9685, 353, 29871, 29896, 29897, 13, 9651, 736, 1060, 29892, 343, 13, 13, 4706, 4489, 29918, 14968, 353, 1583, 29889, 2176, 29918, 1272, 29918, 2371, 29961, 1311, 29889, 2176, 29918, 1272, 29918, 2371, 3366, 1256, 3108, 529, 1583, 29889, 463, 29918, 1688, 29918, 1256, 29962, 13, 4706, 4489, 29918, 1688, 353, 1583, 29889, 2176, 29918, 1272, 29918, 2371, 29961, 1311, 29889, 2176, 29918, 1272, 29918, 2371, 3366, 1256, 3108, 6736, 1583, 29889, 463, 29918, 1688, 29918, 1256, 29962, 13, 13, 4706, 1060, 29918, 14968, 29892, 343, 29918, 14968, 353, 3588, 29918, 517, 29918, 23749, 29898, 2176, 29918, 14968, 29897, 13, 4706, 1060, 29918, 1688, 29892, 343, 29918, 1688, 353, 3588, 29918, 517, 29918, 23749, 29898, 2176, 29918, 1688, 29897, 13, 13, 4706, 736, 1060, 29918, 14968, 29892, 343, 29918, 14968, 29892, 1060, 29918, 1688, 29892, 343, 29918, 1688, 13, 13, 13, 361, 4770, 978, 1649, 1275, 376, 1649, 3396, 1649, 1115, 13, 13, 1678, 515, 2071, 4713, 361, 677, 29889, 1272, 1053, 3630, 3835, 29892, 2169, 23881, 21575, 13, 1678, 3646, 29918, 1643, 353, 376, 1482, 29918, 11436, 29908, 13, 1678, 694, 29918, 29882, 391, 29918, 16700, 353, 29871, 29900, 13, 1678, 694, 29918, 29882, 391, 29918, 705, 14541, 353, 29871, 29906, 13, 1678, 3380, 29918, 1688, 29918, 1256, 353, 376, 29906, 29900, 29906, 29896, 29899, 29896, 29896, 29899, 29900, 29953, 29908, 13, 1678, 6287, 29918, 1272, 353, 6213, 13, 13, 1678, 848, 353, 3630, 29898, 13, 4706, 694, 29918, 29882, 391, 29918, 16700, 29922, 1217, 29918, 29882, 391, 29918, 16700, 29892, 13, 4706, 694, 29918, 29882, 391, 29918, 705, 14541, 29922, 1217, 29918, 29882, 391, 29918, 705, 14541, 29892, 13, 4706, 3646, 29918, 1643, 29922, 5182, 29918, 1643, 29892, 13, 4706, 3380, 29918, 1688, 29918, 1256, 29922, 463, 29918, 1688, 29918, 1256, 29892, 13, 4706, 6287, 29918, 1272, 29922, 7052, 29918, 1272, 13, 1678, 1723, 13, 13, 1678, 1060, 29918, 14968, 29892, 343, 29918, 14968, 29892, 1060, 29918, 1688, 29918, 29873, 29892, 343, 29918, 1688, 29918, 29873, 353, 848, 29889, 657, 29918, 1272, 580, 13, 1678, 4840, 353, 3630, 3835, 29898, 29990, 29918, 1688, 29918, 29873, 29892, 343, 29918, 1688, 29918, 29873, 29897, 13, 2 ]
apps/accounts/conf.py
sotkonstantinidis/testcircle
3
192258
from django.conf import settings # noqa from appconf import AppConf class AccountConf(AppConf): """ Custom settings for the account module. Mainly settings required for the login on the remote system. """ PID = 3 LOGIN_TYPE = 'login' LOGIN_SUCCESS_URL = 'home' # The name of the UNCCD role as provided by the remote system. UNCCD_ROLE_NAME = 'UNCCD Focal Point'
[ 1, 515, 9557, 29889, 5527, 1053, 6055, 29871, 396, 694, 25621, 13, 3166, 623, 5527, 1053, 2401, 16376, 13, 13, 13, 1990, 16535, 16376, 29898, 2052, 16376, 1125, 13, 1678, 9995, 13, 1678, 8701, 6055, 363, 278, 3633, 3883, 29889, 4241, 368, 6055, 3734, 363, 13, 1678, 278, 6464, 373, 278, 7592, 1788, 29889, 13, 1678, 9995, 13, 1678, 349, 1367, 353, 29871, 29941, 13, 1678, 25401, 1177, 29918, 11116, 353, 525, 7507, 29915, 13, 1678, 25401, 1177, 29918, 14605, 26925, 29918, 4219, 353, 525, 5184, 29915, 13, 13, 1678, 396, 450, 1024, 310, 278, 8291, 4174, 29928, 6297, 408, 4944, 491, 278, 7592, 1788, 29889, 13, 1678, 8291, 4174, 29928, 29918, 1672, 1307, 29918, 5813, 353, 525, 3904, 4174, 29928, 383, 18642, 8984, 29915, 13, 2 ]
libs/raw_image.py
guatek/Dual-Mag-Data
0
172404
<filename>libs/raw_image.py # -*- coding: utf-8 -*- import os import cv2 import json import struct import datetime import numpy as np from tifffile import TiffWriter from psutil import virtual_memory from loguru import logger __author__ = "<NAME>" __copyright__ = "Copyright 2020 Guatek" __credits__ = ["Guatek"] __license__ = "MIT" __maintainer__ = "<NAME>" __email__ = "<EMAIL>" __doc__ = ''' Handle loading and exporting raw bin files from pcam-like cameras @author: __author__ @status: __status__ @license: __license__ ''' class RawImage: """Load, process and export raw bin files """ def __init__(self, filepath, output_path=None): self.filepath = filepath self.output_path = output_path self.file_header_format = '<iiQiQQ' self.file_header_params = [ 'file_type', 'frames_per_file', 'bits_per_pixel', 'pixel_format', 'image_width', 'image_height' ] self.frame_header_format = '<QQQQ' self.frame_header_params = [ 'marker', 'frame_id', 'frame_timestamp', 'system_timestamp', ] # exports self.tiff_exports = [] self.jpeg_exports = [] self.thumbnail_exports = [] self.image_items = [] self.can_do_ram = False self.file_fmt = 0 self.file_header_length = 36 self.frame_header_size = 32 self.file_header = None self.frame_headers = [] self.frame_data = [] self.field_correction = None self.background = None # actual image width and height with raw size and binning self.img_width = 0 self.img_height = 0 # Try to open the file and read try: self.file_handle = open(self.filepath, "rb") self.file_valid = True self.file_size = os.path.getsize(self.filepath) self.file_valid = self.file_size > 0 except FileNotFoundError as e: logger.error(e) self.file_valid = False if not self.file_valid: logger.error("Zero size file.") return # read the file header and set image sizes accordingly self.read_file_header() # check if we can load all frames into RAM self.ram_available = virtual_memory().available # Get the number of frames in the file self.frames_in_file = int((self.file_size - self.file_header_length) / self.frame_size_in_bytes()) logger.info('Found ' + str(self.frames_in_file) + ' frames in ' + self.filepath) def unpack(self, format_string, names, raw_data): output = {} if not self.file_valid: return try: logger.debug("Unpacking data in format: " + format_string) logger.debug("Expected header size in bytes: " + str(struct.calcsize(format_string))) data = struct.unpack(format_string, raw_data) for ind, d in enumerate(data): output[names[ind]] = d except struct.error as e: logger.error(e) return output def correct_flat_field(self, data): if not self.file_valid: return if self.field_correction is None: logger.info("Estimating flat field correction from images") data_array = None for i in range(0, self.frames_in_file): header, raw_data = self.read_frame(i) if data_array is None: data_array = np.zeros((data.shape[0],data.shape[1],self.frames_in_file)) data_array[:,:,i] = raw_data self.field_correction = np.median(data_array, 2) self.field_correction[self.field_correction < 1] = 1 self.field_correction = self.field_correction.astype('float') / np.min(self.field_correction) # remove color from the correction h, w = self.field_correction.shape self.field_correction = cv2.resize(self.field_correction, (int(w/2), int(h/2)), interpolation=cv2.INTER_AREA) self.field_correction = cv2.resize(self.field_correction, (w, h), interpolation=cv2.INTER_LINEAR) self.background = np.median(data_array, 2) / self.field_correction # apply the correction data = data / self.field_correction data = data - self.background data[data<0.0] = 0.0 if self.bpp == 2: data = data.astype('uint16') else: data = data.astype('uint8') return data def export_8bit_jpegs(self, output_path=None, bayer_pattern=cv2.COLOR_BayerRG2RGB, flat_field=True, gamma=1.0, thumbnails=True): if not self.file_valid: return file_info = {} file_info['file_header'] = self.file_header file_info['frame_headers'] = [] self.jpeg_exports = [] self.thumbnail_exports = [] for i in range(0, self.frames_in_file): image_item = {} header, data = self.read_frame(i) if flat_field: data = self.correct_flat_field(data) if bayer_pattern: logger.debug("Converting color...") data = cv2.cvtColor(data,bayer_pattern) # RGB needed to get RGB format in opencv # Clip any negative values if self.bpp == 2: data = data/256/256 else: data = data/256 data = data**(gamma) data=data*255 data[data>255] = 255 data = np.uint8(data) filename = os.path.basename(self.filepath)[:-4] + '-' + str(header['frame_id']) + '-' + str(header['system_timestamp']) +'.jpeg' if thumbnails: thumbnail_name = os.path.basename(self.filepath)[:-4] + '-' + str(header['frame_id']) + '-' + str(header['system_timestamp']) +'_thumb.jpeg' timestamp = int(header['system_timestamp']/1000000) subdir = str(int(timestamp/864)) if output_path is None: if self.output_path is None: output_path = os.path.dirname(self.filepath) output_subdir = os.path.join(os.path.dirname(self.filepath), subdir) else: output_path = self.output_path output_subdir = os.path.join(self.output_path, subdir) else: output_subdir = os.path.join(output_path, subdir) if not os.path.exists(output_subdir): try: os.makedirs(output_subdir) except FileExistsError as e: logger.warning(e) pass jpeg_path = os.path.join(output_subdir, filename) self.jpeg_exports.append(jpeg_path) cv2.imwrite(jpeg_path, data) image_item['src'] = os.path.basename(os.path.normpath(output_path)) + '/' + subdir + '/' + filename image_item['fullWidth'] = data.shape[1] image_item['fullHeight'] = data.shape[0] timestamp = datetime.datetime.fromtimestamp(float(header['system_timestamp'])/1000000) image_item['timestring'] = timestamp.isoformat() if thumbnails: thumbnail_size = (int(data.shape[1]/10), int(data.shape[0]/10)) jpeg_thumbnail_path = os.path.join(output_subdir, thumbnail_name) cv2.imwrite(jpeg_thumbnail_path, cv2.resize(data, thumbnail_size, interpolation=cv2.INTER_LINEAR)) self.thumbnail_exports.append(jpeg_thumbnail_path) image_item['thumbnailWidth'] = thumbnail_size[0] image_item['thumbnailHeight'] = thumbnail_size[1] image_item['thumbnail'] = os.path.basename(os.path.normpath(output_path)) + '/' + subdir + '/' + thumbnail_name else: image_item['thumbnailWidth'] = 0 image_item['thumbnailHeight'] = 0 image_item['thumbnail'] = '' self.image_items.append(image_item) def export_as_tiff(self, output_path=None, bayer_pattern=cv2.COLOR_BayerRG2BGR, flat_field=True): if not self.file_valid: return file_info = {} file_info['file_header'] = self.file_header file_info['frame_headers'] = [] self.tiff_exports = [] if output_path is None: if self.output_path is None: tiff_path = self.filepath[:-4] + '.tif' json_path = self.filepath[:-4] + '.json' else: tiff_path = os.path.join(self.output_path, os.path.basename(self.filepath)[:-4] + '.tif') json_path = os.path.join(self.output_path, os.path.basename(self.filepath)[:-4] + '.json') else: tiff_path = os.path.join(output_path, os.path.basename(self.filepath)[:-4]) + '.tif' json_path = os.path.join(output_path, os.path.basename(self.filepath)[:-4]) + '.json' self.tiff_exports.append(tiff_path) logger.info("Exporting headers to " + json_path) logger.info("Exporting frames to " + tiff_path) with TiffWriter(tiff_path, append=True) as tif: for i in range(0, self.frames_in_file): header, data = self.read_frame(i) if flat_field: data = self.correct_flat_field(data) if bayer_pattern: logger.debug("Converting color...") data = cv2.cvtColor(data,bayer_pattern) # BGR needed to get RGB format in TiffWriter timestamp = float(header['system_timestamp']) dt = datetime.datetime.fromtimestamp(timestamp/1000000.0) file_info['frame_headers'].append(header) frame_header_string = json.dumps(header) xtag = (65000, 's', 0, frame_header_string, False) tif.save( data, description=json.dumps(file_info), datetime=dt, extratags=[xtag] ) with open(json_path, "w") as f: json.dump(file_info, f, indent=4, sort_keys=True) def read_file_header(self): if self.file_valid: # read the rest of the header self.file_handle.seek(0) res = self.file_handle.read(self.file_header_length) logger.debug("Read file header of length: " + str(self.file_header_length)) self.file_header = self.unpack(self.file_header_format, self.file_header_params, res) self.file_fmt = self.file_header['file_type'] self.img_height = int(self.file_header['image_height']) self.img_width = int(self.file_header['image_width']) self.bpp = int(self.file_header['bits_per_pixel'] / 8) # in bytes-per-pixel from bits-per-pixel logger.debug(self.file_header) def frame_size_in_bytes(self): if self.file_valid: return self.frame_header_size + self.bpp * self.img_width * self.img_height else: return 0 def frame_pixels(self): if self.file_valid: return self.img_width*self.img_height else: return 0 def read_frame(self, index): if not self.file_valid: return frame_offset = self.file_header_length + index * self.frame_size_in_bytes() frame_pixels = self.frame_pixels() if self.file_valid: # seek to the start of the frame self.file_handle.seek(frame_offset, 0) # read the header frame_header = self.unpack( self.frame_header_format, self.frame_header_params, self.file_handle.read(self.frame_header_size) ) # read the frame pixels if self.bpp == 1: res = np.fromfile(self.file_handle, dtype='uint8', count=frame_pixels) else: res = np.fromfile(self.file_handle, dtype='uint16', count=frame_pixels) if len(res) <= 0: logger.error('Error reading frame ' + str(index) + " from file " + self.filepath) return None else: # reshape into image image = np.reshape(res, (self.img_height, self.img_width)) return frame_header, image
[ 1, 529, 9507, 29958, 10254, 29914, 1610, 29918, 3027, 29889, 2272, 13, 29937, 448, 29930, 29899, 14137, 29901, 23616, 29899, 29947, 448, 29930, 29899, 13, 5215, 2897, 13, 5215, 13850, 29906, 13, 5215, 4390, 13, 5215, 2281, 13, 5215, 12865, 13, 5215, 12655, 408, 7442, 13, 3166, 260, 361, 600, 488, 1053, 323, 2593, 10507, 13, 3166, 6529, 4422, 1053, 6901, 29918, 14834, 13, 3166, 1480, 20144, 1053, 17927, 13, 13, 1649, 8921, 1649, 353, 9872, 5813, 11903, 13, 1649, 8552, 1266, 1649, 353, 376, 11882, 1266, 29871, 29906, 29900, 29906, 29900, 2088, 403, 29895, 29908, 13, 1649, 11944, 1169, 1649, 353, 6796, 9485, 403, 29895, 3108, 13, 1649, 506, 1947, 1649, 353, 376, 26349, 29908, 13, 1649, 29885, 2365, 4008, 1649, 353, 9872, 5813, 11903, 13, 1649, 5269, 1649, 353, 9872, 26862, 6227, 11903, 13, 1649, 1514, 1649, 353, 14550, 13, 13, 13554, 8363, 322, 5609, 292, 10650, 9016, 2066, 515, 282, 11108, 29899, 4561, 3949, 18464, 13, 13, 29992, 8921, 29901, 4770, 8921, 1649, 13, 29992, 4882, 29901, 4770, 4882, 1649, 13, 29992, 506, 1947, 29901, 4770, 506, 1947, 1649, 13, 12008, 13, 13, 13, 1990, 22038, 2940, 29901, 13, 1678, 9995, 5896, 29892, 1889, 322, 5609, 10650, 9016, 2066, 13, 1678, 9995, 13, 13, 1678, 822, 4770, 2344, 12035, 1311, 29892, 934, 2084, 29892, 1962, 29918, 2084, 29922, 8516, 1125, 13, 13, 4706, 1583, 29889, 1445, 2084, 353, 934, 2084, 13, 4706, 1583, 29889, 4905, 29918, 2084, 353, 1962, 29918, 2084, 13, 4706, 1583, 29889, 1445, 29918, 6672, 29918, 4830, 353, 12801, 2236, 29984, 29875, 29984, 29984, 29915, 13, 4706, 1583, 29889, 1445, 29918, 6672, 29918, 7529, 353, 518, 13, 9651, 525, 1445, 29918, 1853, 742, 13, 9651, 525, 19935, 29918, 546, 29918, 1445, 742, 13, 9651, 525, 14836, 29918, 546, 29918, 29886, 15711, 742, 13, 9651, 525, 29886, 15711, 29918, 4830, 742, 13, 9651, 525, 3027, 29918, 2103, 742, 13, 9651, 525, 3027, 29918, 3545, 29915, 13, 4706, 4514, 13, 13, 4706, 1583, 29889, 2557, 29918, 6672, 29918, 4830, 353, 12801, 29984, 29984, 29984, 29984, 29915, 13, 4706, 1583, 29889, 2557, 29918, 6672, 29918, 7529, 353, 518, 13, 9651, 525, 22976, 742, 13, 9651, 525, 2557, 29918, 333, 742, 13, 9651, 525, 2557, 29918, 16394, 742, 13, 9651, 525, 5205, 29918, 16394, 742, 13, 4706, 4514, 13, 13, 4706, 396, 29586, 13, 4706, 1583, 29889, 29873, 2593, 29918, 26500, 353, 5159, 13, 4706, 1583, 29889, 26568, 29918, 26500, 353, 5159, 13, 4706, 1583, 29889, 386, 21145, 29918, 26500, 353, 5159, 13, 4706, 1583, 29889, 3027, 29918, 7076, 353, 5159, 13, 13, 4706, 1583, 29889, 3068, 29918, 1867, 29918, 2572, 353, 7700, 13, 13, 4706, 1583, 29889, 1445, 29918, 23479, 353, 29871, 29900, 13, 4706, 1583, 29889, 1445, 29918, 6672, 29918, 2848, 353, 29871, 29941, 29953, 13, 4706, 1583, 29889, 2557, 29918, 6672, 29918, 2311, 353, 29871, 29941, 29906, 13, 4706, 1583, 29889, 1445, 29918, 6672, 353, 6213, 13, 4706, 1583, 29889, 2557, 29918, 13662, 353, 5159, 13, 4706, 1583, 29889, 2557, 29918, 1272, 353, 5159, 13, 4706, 1583, 29889, 2671, 29918, 2616, 276, 428, 353, 6213, 13, 4706, 1583, 29889, 7042, 353, 6213, 13, 13, 4706, 396, 3935, 1967, 2920, 322, 3171, 411, 10650, 2159, 322, 9016, 1076, 13, 4706, 1583, 29889, 2492, 29918, 2103, 353, 29871, 29900, 13, 4706, 1583, 29889, 2492, 29918, 3545, 353, 29871, 29900, 13, 13, 4706, 396, 3967, 304, 1722, 278, 934, 322, 1303, 13, 4706, 1018, 29901, 13, 9651, 1583, 29889, 1445, 29918, 8411, 353, 1722, 29898, 1311, 29889, 1445, 2084, 29892, 376, 6050, 1159, 13, 9651, 1583, 29889, 1445, 29918, 3084, 353, 5852, 13, 9651, 1583, 29889, 1445, 29918, 2311, 353, 2897, 29889, 2084, 29889, 657, 2311, 29898, 1311, 29889, 1445, 2084, 29897, 13, 9651, 1583, 29889, 1445, 29918, 3084, 353, 1583, 29889, 1445, 29918, 2311, 1405, 29871, 29900, 13, 4706, 5174, 3497, 17413, 2392, 408, 321, 29901, 13, 9651, 17927, 29889, 2704, 29898, 29872, 29897, 13, 9651, 1583, 29889, 1445, 29918, 3084, 353, 7700, 13, 13, 4706, 565, 451, 1583, 29889, 1445, 29918, 3084, 29901, 13, 9651, 17927, 29889, 2704, 703, 24214, 2159, 934, 23157, 13, 9651, 736, 13, 13, 4706, 396, 1303, 278, 934, 4839, 322, 731, 1967, 15786, 16205, 13, 4706, 1583, 29889, 949, 29918, 1445, 29918, 6672, 580, 13, 13, 4706, 396, 1423, 565, 591, 508, 2254, 599, 16608, 964, 18113, 13, 4706, 1583, 29889, 2572, 29918, 16515, 353, 6901, 29918, 14834, 2141, 16515, 13, 13, 4706, 396, 3617, 278, 1353, 310, 16608, 297, 278, 934, 13, 4706, 1583, 29889, 19935, 29918, 262, 29918, 1445, 353, 938, 3552, 1311, 29889, 1445, 29918, 2311, 448, 1583, 29889, 1445, 29918, 6672, 29918, 2848, 29897, 847, 1583, 29889, 2557, 29918, 2311, 29918, 262, 29918, 13193, 3101, 13, 4706, 17927, 29889, 3888, 877, 9692, 525, 718, 851, 29898, 1311, 29889, 19935, 29918, 262, 29918, 1445, 29897, 718, 525, 16608, 297, 525, 718, 1583, 29889, 1445, 2084, 29897, 13, 13, 1678, 822, 443, 4058, 29898, 1311, 29892, 3402, 29918, 1807, 29892, 2983, 29892, 10650, 29918, 1272, 1125, 13, 13, 4706, 1962, 353, 6571, 13, 13, 4706, 565, 451, 1583, 29889, 1445, 29918, 3084, 29901, 13, 9651, 736, 13, 13, 4706, 1018, 29901, 13, 9651, 17927, 29889, 8382, 703, 2525, 4058, 292, 848, 297, 3402, 29901, 376, 718, 3402, 29918, 1807, 29897, 13, 9651, 17927, 29889, 8382, 703, 1252, 6021, 4839, 2159, 297, 6262, 29901, 376, 718, 851, 29898, 4984, 29889, 28667, 2311, 29898, 4830, 29918, 1807, 4961, 13, 9651, 848, 353, 2281, 29889, 348, 4058, 29898, 4830, 29918, 1807, 29892, 10650, 29918, 1272, 29897, 13, 13, 9651, 363, 1399, 29892, 270, 297, 26985, 29898, 1272, 1125, 13, 18884, 1962, 29961, 7039, 29961, 513, 5262, 353, 270, 13, 13, 4706, 5174, 2281, 29889, 2704, 408, 321, 29901, 13, 9651, 17927, 29889, 2704, 29898, 29872, 29897, 13, 13, 4706, 736, 1962, 13, 13, 1678, 822, 1959, 29918, 20620, 29918, 2671, 29898, 1311, 29892, 848, 1125, 13, 13, 4706, 565, 451, 1583, 29889, 1445, 29918, 3084, 29901, 13, 9651, 736, 13, 13, 4706, 565, 1583, 29889, 2671, 29918, 2616, 276, 428, 338, 6213, 29901, 13, 9651, 17927, 29889, 3888, 703, 12787, 326, 1218, 12151, 1746, 26385, 515, 4558, 1159, 13, 13, 9651, 848, 29918, 2378, 353, 6213, 13, 13, 9651, 363, 474, 297, 3464, 29898, 29900, 29892, 1583, 29889, 19935, 29918, 262, 29918, 1445, 1125, 13, 632, 13, 18884, 4839, 29892, 10650, 29918, 1272, 353, 1583, 29889, 949, 29918, 2557, 29898, 29875, 29897, 13, 13, 18884, 565, 848, 29918, 2378, 338, 6213, 29901, 13, 462, 1678, 848, 29918, 2378, 353, 7442, 29889, 3298, 359, 3552, 1272, 29889, 12181, 29961, 29900, 1402, 1272, 29889, 12181, 29961, 29896, 1402, 1311, 29889, 19935, 29918, 262, 29918, 1445, 876, 13, 462, 13, 18884, 848, 29918, 2378, 7503, 29892, 29901, 29892, 29875, 29962, 353, 10650, 29918, 1272, 13, 13, 9651, 1583, 29889, 2671, 29918, 2616, 276, 428, 353, 7442, 29889, 2168, 713, 29898, 1272, 29918, 2378, 29892, 29871, 29906, 29897, 13, 9651, 1583, 29889, 2671, 29918, 2616, 276, 428, 29961, 1311, 29889, 2671, 29918, 2616, 276, 428, 529, 29871, 29896, 29962, 353, 29871, 29896, 13, 9651, 1583, 29889, 2671, 29918, 2616, 276, 428, 353, 1583, 29889, 2671, 29918, 2616, 276, 428, 29889, 579, 668, 877, 7411, 1495, 847, 7442, 29889, 1195, 29898, 1311, 29889, 2671, 29918, 2616, 276, 428, 29897, 13, 13, 9651, 396, 3349, 2927, 515, 278, 26385, 13, 9651, 298, 29892, 281, 353, 1583, 29889, 2671, 29918, 2616, 276, 428, 29889, 12181, 13, 9651, 1583, 29889, 2671, 29918, 2616, 276, 428, 353, 13850, 29906, 29889, 21476, 29898, 1311, 29889, 2671, 29918, 2616, 276, 428, 29892, 313, 524, 29898, 29893, 29914, 29906, 511, 938, 29898, 29882, 29914, 29906, 8243, 29694, 29922, 11023, 29906, 29889, 23845, 29918, 29909, 1525, 29909, 29897, 13, 9651, 1583, 29889, 2671, 29918, 2616, 276, 428, 353, 13850, 29906, 29889, 21476, 29898, 1311, 29889, 2671, 29918, 2616, 276, 428, 29892, 313, 29893, 29892, 298, 511, 29694, 29922, 11023, 29906, 29889, 23845, 29918, 18521, 1718, 29897, 13, 9651, 1583, 29889, 7042, 353, 7442, 29889, 2168, 713, 29898, 1272, 29918, 2378, 29892, 29871, 29906, 29897, 847, 1583, 29889, 2671, 29918, 2616, 276, 428, 13, 308, 13, 4706, 396, 3394, 278, 26385, 13, 4706, 848, 353, 848, 847, 1583, 29889, 2671, 29918, 2616, 276, 428, 13, 4706, 848, 353, 848, 448, 1583, 29889, 7042, 13, 4706, 848, 29961, 1272, 29966, 29900, 29889, 29900, 29962, 353, 29871, 29900, 29889, 29900, 13, 13, 4706, 565, 1583, 29889, 29890, 407, 1275, 29871, 29906, 29901, 13, 9651, 848, 353, 848, 29889, 579, 668, 877, 13470, 29896, 29953, 1495, 13, 4706, 1683, 29901, 13, 9651, 848, 353, 848, 29889, 579, 668, 877, 13470, 29947, 1495, 13, 13, 4706, 736, 848, 13, 632, 13, 13, 268, 13, 1678, 822, 5609, 29918, 29947, 2966, 29918, 26568, 29879, 29898, 1311, 29892, 1962, 29918, 2084, 29922, 8516, 29892, 289, 2747, 29918, 11037, 29922, 11023, 29906, 29889, 15032, 1955, 29918, 29933, 2747, 29934, 29954, 29906, 28212, 29892, 12151, 29918, 2671, 29922, 5574, 29892, 330, 2735, 29922, 29896, 29889, 29900, 29892, 266, 17771, 2234, 29922, 5574, 1125, 13, 308, 13, 4706, 565, 451, 1583, 29889, 1445, 29918, 3084, 29901, 13, 9651, 736, 13, 308, 13, 4706, 934, 29918, 3888, 353, 6571, 13, 4706, 934, 29918, 3888, 1839, 1445, 29918, 6672, 2033, 353, 1583, 29889, 1445, 29918, 6672, 13, 4706, 934, 29918, 3888, 1839, 2557, 29918, 13662, 2033, 353, 5159, 13, 13, 4706, 1583, 29889, 26568, 29918, 26500, 353, 5159, 13, 4706, 1583, 29889, 386, 21145, 29918, 26500, 353, 5159, 13, 13, 4706, 363, 474, 297, 3464, 29898, 29900, 29892, 1583, 29889, 19935, 29918, 262, 29918, 1445, 1125, 13, 632, 13, 9651, 1967, 29918, 667, 353, 6571, 13, 13, 9651, 4839, 29892, 848, 353, 1583, 29889, 949, 29918, 2557, 29898, 29875, 29897, 13, 13, 9651, 565, 12151, 29918, 2671, 29901, 13, 18884, 848, 353, 1583, 29889, 15728, 29918, 20620, 29918, 2671, 29898, 1272, 29897, 13, 462, 13, 9651, 565, 289, 2747, 29918, 11037, 29901, 13, 18884, 17927, 29889, 8382, 703, 1168, 369, 1259, 2927, 856, 1159, 13, 18884, 848, 353, 13850, 29906, 29889, 11023, 29873, 3306, 29898, 1272, 29892, 29890, 2747, 29918, 11037, 29897, 396, 390, 7210, 4312, 304, 679, 390, 7210, 3402, 297, 1722, 11023, 13, 13, 9651, 396, 315, 3466, 738, 8178, 1819, 13, 9651, 565, 1583, 29889, 29890, 407, 1275, 29871, 29906, 29901, 13, 18884, 848, 353, 848, 29914, 29906, 29945, 29953, 29914, 29906, 29945, 29953, 13, 9651, 1683, 29901, 13, 18884, 848, 353, 848, 29914, 29906, 29945, 29953, 13, 632, 13, 9651, 848, 353, 848, 1068, 29898, 4283, 29897, 13, 9651, 848, 29922, 1272, 29930, 29906, 29945, 29945, 13, 9651, 848, 29961, 1272, 29958, 29906, 29945, 29945, 29962, 353, 29871, 29906, 29945, 29945, 13, 9651, 848, 353, 7442, 29889, 13470, 29947, 29898, 1272, 29897, 13, 13, 13, 9651, 10422, 353, 2897, 29889, 2084, 29889, 6500, 3871, 29898, 1311, 29889, 1445, 2084, 29897, 7503, 29899, 29946, 29962, 718, 17411, 29915, 718, 851, 29898, 6672, 1839, 2557, 29918, 333, 11287, 718, 17411, 29915, 718, 851, 29898, 6672, 1839, 5205, 29918, 16394, 11287, 718, 4286, 26568, 29915, 13, 9651, 565, 266, 17771, 2234, 29901, 13, 18884, 266, 21145, 29918, 978, 353, 2897, 29889, 2084, 29889, 6500, 3871, 29898, 1311, 29889, 1445, 2084, 29897, 7503, 29899, 29946, 29962, 718, 17411, 29915, 718, 851, 29898, 6672, 1839, 2557, 29918, 333, 11287, 718, 17411, 29915, 718, 851, 29898, 6672, 1839, 5205, 29918, 16394, 11287, 718, 15972, 386, 3774, 29889, 26568, 29915, 13, 13, 9651, 14334, 353, 938, 29898, 6672, 1839, 5205, 29918, 16394, 2033, 29914, 29896, 29900, 29900, 29900, 29900, 29900, 29900, 29897, 13, 9651, 1014, 3972, 353, 851, 29898, 524, 29898, 16394, 29914, 29947, 29953, 29946, 876, 13, 13, 9651, 565, 1962, 29918, 2084, 338, 6213, 29901, 13, 18884, 565, 1583, 29889, 4905, 29918, 2084, 338, 6213, 29901, 13, 462, 1678, 1962, 29918, 2084, 353, 2897, 29889, 2084, 29889, 25721, 29898, 1311, 29889, 1445, 2084, 29897, 13, 462, 1678, 1962, 29918, 1491, 3972, 353, 2897, 29889, 2084, 29889, 7122, 29898, 359, 29889, 2084, 29889, 25721, 29898, 1311, 29889, 1445, 2084, 511, 1014, 3972, 29897, 13, 18884, 1683, 29901, 13, 462, 1678, 1962, 29918, 2084, 353, 1583, 29889, 4905, 29918, 2084, 13, 462, 1678, 1962, 29918, 1491, 3972, 353, 2897, 29889, 2084, 29889, 7122, 29898, 1311, 29889, 4905, 29918, 2084, 29892, 1014, 3972, 29897, 13, 9651, 1683, 29901, 13, 18884, 1962, 29918, 1491, 3972, 353, 2897, 29889, 2084, 29889, 7122, 29898, 4905, 29918, 2084, 29892, 1014, 3972, 29897, 13, 13, 9651, 565, 451, 2897, 29889, 2084, 29889, 9933, 29898, 4905, 29918, 1491, 3972, 1125, 13, 18884, 1018, 29901, 13, 462, 1678, 2897, 29889, 29885, 12535, 12935, 29898, 4905, 29918, 1491, 3972, 29897, 13, 18884, 5174, 3497, 24217, 2392, 408, 321, 29901, 13, 462, 1678, 17927, 29889, 27392, 29898, 29872, 29897, 13, 462, 1678, 1209, 13, 13, 9651, 432, 29886, 387, 29918, 2084, 353, 2897, 29889, 2084, 29889, 7122, 29898, 4905, 29918, 1491, 3972, 29892, 10422, 29897, 13, 9651, 1583, 29889, 26568, 29918, 26500, 29889, 4397, 29898, 26568, 29918, 2084, 29897, 13, 9651, 13850, 29906, 29889, 326, 3539, 29898, 26568, 29918, 2084, 29892, 848, 29897, 13, 13, 9651, 1967, 29918, 667, 1839, 4351, 2033, 353, 2897, 29889, 2084, 29889, 6500, 3871, 29898, 359, 29889, 2084, 29889, 12324, 2084, 29898, 4905, 29918, 2084, 876, 718, 8207, 29915, 718, 1014, 3972, 718, 8207, 29915, 718, 10422, 13, 9651, 1967, 29918, 667, 1839, 8159, 6110, 2033, 353, 848, 29889, 12181, 29961, 29896, 29962, 13, 9651, 1967, 29918, 667, 1839, 8159, 7011, 2033, 353, 848, 29889, 12181, 29961, 29900, 29962, 13, 13, 9651, 14334, 353, 12865, 29889, 12673, 29889, 3166, 16394, 29898, 7411, 29898, 6672, 1839, 5205, 29918, 16394, 2033, 6802, 29896, 29900, 29900, 29900, 29900, 29900, 29900, 29897, 13, 9651, 1967, 29918, 667, 1839, 9346, 342, 5393, 2033, 353, 14334, 29889, 10718, 4830, 580, 13, 13, 9651, 565, 266, 17771, 2234, 29901, 13, 18884, 266, 21145, 29918, 2311, 353, 313, 524, 29898, 1272, 29889, 12181, 29961, 29896, 16261, 29896, 29900, 511, 938, 29898, 1272, 29889, 12181, 29961, 29900, 16261, 29896, 29900, 876, 13, 18884, 432, 29886, 387, 29918, 386, 21145, 29918, 2084, 353, 2897, 29889, 2084, 29889, 7122, 29898, 4905, 29918, 1491, 3972, 29892, 266, 21145, 29918, 978, 29897, 13, 18884, 13850, 29906, 29889, 326, 3539, 29898, 26568, 29918, 386, 21145, 29918, 2084, 29892, 13850, 29906, 29889, 21476, 29898, 1272, 29892, 266, 21145, 29918, 2311, 29892, 29694, 29922, 11023, 29906, 29889, 23845, 29918, 18521, 1718, 876, 13, 18884, 1583, 29889, 386, 21145, 29918, 26500, 29889, 4397, 29898, 26568, 29918, 386, 21145, 29918, 2084, 29897, 13, 18884, 1967, 29918, 667, 1839, 386, 21145, 6110, 2033, 353, 266, 21145, 29918, 2311, 29961, 29900, 29962, 13, 18884, 1967, 29918, 667, 1839, 386, 21145, 7011, 2033, 353, 266, 21145, 29918, 2311, 29961, 29896, 29962, 13, 18884, 1967, 29918, 667, 1839, 386, 21145, 2033, 353, 2897, 29889, 2084, 29889, 6500, 3871, 29898, 359, 29889, 2084, 29889, 12324, 2084, 29898, 4905, 29918, 2084, 876, 718, 8207, 29915, 718, 1014, 3972, 718, 8207, 29915, 718, 266, 21145, 29918, 978, 13, 9651, 1683, 29901, 13, 18884, 1967, 29918, 667, 1839, 386, 21145, 6110, 2033, 353, 29871, 29900, 13, 18884, 1967, 29918, 667, 1839, 386, 21145, 7011, 2033, 353, 29871, 29900, 13, 18884, 1967, 29918, 667, 1839, 386, 21145, 2033, 353, 6629, 13, 13, 9651, 1583, 29889, 3027, 29918, 7076, 29889, 4397, 29898, 3027, 29918, 667, 29897, 13, 13, 1678, 822, 5609, 29918, 294, 29918, 29873, 2593, 29898, 1311, 29892, 1962, 29918, 2084, 29922, 8516, 29892, 289, 2747, 29918, 11037, 29922, 11023, 29906, 29889, 15032, 1955, 29918, 29933, 2747, 29934, 29954, 29906, 29933, 14345, 29892, 12151, 29918, 2671, 29922, 5574, 1125, 13, 308, 13, 4706, 565, 451, 1583, 29889, 1445, 29918, 3084, 29901, 13, 9651, 736, 13, 13, 4706, 934, 29918, 3888, 353, 6571, 13, 4706, 934, 29918, 3888, 1839, 1445, 29918, 6672, 2033, 353, 1583, 29889, 1445, 29918, 6672, 13, 4706, 934, 29918, 3888, 1839, 2557, 29918, 13662, 2033, 353, 5159, 13, 13, 4706, 1583, 29889, 29873, 2593, 29918, 26500, 353, 5159, 13, 13, 4706, 565, 1962, 29918, 2084, 338, 6213, 29901, 13, 9651, 565, 1583, 29889, 4905, 29918, 2084, 338, 6213, 29901, 13, 18884, 260, 2593, 29918, 2084, 353, 1583, 29889, 1445, 2084, 7503, 29899, 29946, 29962, 718, 15300, 29873, 361, 29915, 13, 18884, 4390, 29918, 2084, 353, 1583, 29889, 1445, 2084, 7503, 29899, 29946, 29962, 718, 15300, 3126, 29915, 13, 9651, 1683, 29901, 13, 18884, 260, 2593, 29918, 2084, 353, 2897, 29889, 2084, 29889, 7122, 29898, 1311, 29889, 4905, 29918, 2084, 29892, 2897, 29889, 2084, 29889, 6500, 3871, 29898, 1311, 29889, 1445, 2084, 29897, 7503, 29899, 29946, 29962, 718, 15300, 29873, 361, 1495, 13, 18884, 4390, 29918, 2084, 353, 2897, 29889, 2084, 29889, 7122, 29898, 1311, 29889, 4905, 29918, 2084, 29892, 2897, 29889, 2084, 29889, 6500, 3871, 29898, 1311, 29889, 1445, 2084, 29897, 7503, 29899, 29946, 29962, 718, 15300, 3126, 1495, 13, 4706, 1683, 29901, 13, 9651, 260, 2593, 29918, 2084, 353, 2897, 29889, 2084, 29889, 7122, 29898, 4905, 29918, 2084, 29892, 2897, 29889, 2084, 29889, 6500, 3871, 29898, 1311, 29889, 1445, 2084, 29897, 7503, 29899, 29946, 2314, 718, 15300, 29873, 361, 29915, 13, 9651, 4390, 29918, 2084, 353, 2897, 29889, 2084, 29889, 7122, 29898, 4905, 29918, 2084, 29892, 2897, 29889, 2084, 29889, 6500, 3871, 29898, 1311, 29889, 1445, 2084, 29897, 7503, 29899, 29946, 2314, 718, 15300, 3126, 29915, 13, 13, 4706, 1583, 29889, 29873, 2593, 29918, 26500, 29889, 4397, 29898, 29873, 2593, 29918, 2084, 29897, 13, 13, 4706, 17927, 29889, 3888, 703, 26382, 292, 9066, 304, 376, 718, 4390, 29918, 2084, 29897, 13, 4706, 17927, 29889, 3888, 703, 26382, 292, 16608, 304, 376, 718, 260, 2593, 29918, 2084, 29897, 13, 13, 4706, 411, 323, 2593, 10507, 29898, 29873, 2593, 29918, 2084, 29892, 9773, 29922, 5574, 29897, 408, 260, 361, 29901, 13, 13, 9651, 363, 474, 297, 3464, 29898, 29900, 29892, 1583, 29889, 19935, 29918, 262, 29918, 1445, 1125, 13, 462, 13, 18884, 4839, 29892, 848, 353, 1583, 29889, 949, 29918, 2557, 29898, 29875, 29897, 13, 13, 18884, 565, 12151, 29918, 2671, 29901, 13, 462, 1678, 848, 353, 1583, 29889, 15728, 29918, 20620, 29918, 2671, 29898, 1272, 29897, 13, 13, 18884, 565, 289, 2747, 29918, 11037, 29901, 13, 462, 1678, 17927, 29889, 8382, 703, 1168, 369, 1259, 2927, 856, 1159, 13, 462, 1678, 848, 353, 13850, 29906, 29889, 11023, 29873, 3306, 29898, 1272, 29892, 29890, 2747, 29918, 11037, 29897, 396, 350, 14345, 4312, 304, 679, 390, 7210, 3402, 297, 323, 2593, 10507, 13, 13, 13, 18884, 14334, 353, 5785, 29898, 6672, 1839, 5205, 29918, 16394, 11287, 13, 18884, 11636, 353, 12865, 29889, 12673, 29889, 3166, 16394, 29898, 16394, 29914, 29896, 29900, 29900, 29900, 29900, 29900, 29900, 29889, 29900, 29897, 13, 18884, 934, 29918, 3888, 1839, 2557, 29918, 13662, 13359, 4397, 29898, 6672, 29897, 13, 18884, 3515, 29918, 6672, 29918, 1807, 353, 4390, 29889, 29881, 17204, 29898, 6672, 29897, 13, 462, 486, 351, 353, 313, 29953, 29945, 29900, 29900, 29900, 29892, 525, 29879, 742, 29871, 29900, 29892, 3515, 29918, 6672, 29918, 1807, 29892, 7700, 29897, 13, 18884, 260, 361, 29889, 7620, 29898, 13, 462, 1678, 848, 29892, 13, 462, 1678, 6139, 29922, 3126, 29889, 29881, 17204, 29898, 1445, 29918, 3888, 511, 13, 462, 1678, 12865, 29922, 6008, 29892, 13, 462, 1678, 17541, 271, 810, 11759, 486, 351, 29962, 13, 18884, 1723, 13, 13, 4706, 411, 1722, 29898, 3126, 29918, 2084, 29892, 376, 29893, 1159, 408, 285, 29901, 13, 9651, 4390, 29889, 15070, 29898, 1445, 29918, 3888, 29892, 285, 29892, 29536, 29922, 29946, 29892, 2656, 29918, 8149, 29922, 5574, 29897, 13, 13, 1678, 822, 1303, 29918, 1445, 29918, 6672, 29898, 1311, 1125, 13, 13, 4706, 565, 1583, 29889, 1445, 29918, 3084, 29901, 13, 13, 9651, 396, 1303, 278, 1791, 310, 278, 4839, 13, 9651, 1583, 29889, 1445, 29918, 8411, 29889, 344, 1416, 29898, 29900, 29897, 13, 9651, 620, 353, 1583, 29889, 1445, 29918, 8411, 29889, 949, 29898, 1311, 29889, 1445, 29918, 6672, 29918, 2848, 29897, 13, 9651, 17927, 29889, 8382, 703, 6359, 934, 4839, 310, 3309, 29901, 376, 718, 851, 29898, 1311, 29889, 1445, 29918, 6672, 29918, 2848, 876, 13, 9651, 1583, 29889, 1445, 29918, 6672, 353, 1583, 29889, 348, 4058, 29898, 1311, 29889, 1445, 29918, 6672, 29918, 4830, 29892, 1583, 29889, 1445, 29918, 6672, 29918, 7529, 29892, 620, 29897, 13, 13, 9651, 1583, 29889, 1445, 29918, 23479, 353, 1583, 29889, 1445, 29918, 6672, 1839, 1445, 29918, 1853, 2033, 13, 9651, 1583, 29889, 2492, 29918, 3545, 353, 938, 29898, 1311, 29889, 1445, 29918, 6672, 1839, 3027, 29918, 3545, 11287, 13, 9651, 1583, 29889, 2492, 29918, 2103, 353, 938, 29898, 1311, 29889, 1445, 29918, 6672, 1839, 3027, 29918, 2103, 11287, 13, 9651, 1583, 29889, 29890, 407, 353, 938, 29898, 1311, 29889, 1445, 29918, 6672, 1839, 14836, 29918, 546, 29918, 29886, 15711, 2033, 847, 29871, 29947, 29897, 396, 297, 6262, 29899, 546, 29899, 29886, 15711, 515, 9978, 29899, 546, 29899, 29886, 15711, 13, 13, 9651, 17927, 29889, 8382, 29898, 1311, 29889, 1445, 29918, 6672, 29897, 13, 13, 1678, 822, 3515, 29918, 2311, 29918, 262, 29918, 13193, 29898, 1311, 1125, 13, 13, 4706, 565, 1583, 29889, 1445, 29918, 3084, 29901, 13, 9651, 736, 1583, 29889, 2557, 29918, 6672, 29918, 2311, 718, 1583, 29889, 29890, 407, 334, 1583, 29889, 2492, 29918, 2103, 334, 1583, 29889, 2492, 29918, 3545, 13, 4706, 1683, 29901, 13, 9651, 736, 29871, 29900, 13, 13, 1678, 822, 3515, 29918, 29886, 861, 1379, 29898, 1311, 1125, 13, 308, 13, 4706, 565, 1583, 29889, 1445, 29918, 3084, 29901, 13, 9651, 736, 1583, 29889, 2492, 29918, 2103, 29930, 1311, 29889, 2492, 29918, 3545, 13, 4706, 1683, 29901, 13, 9651, 736, 29871, 29900, 13, 13, 1678, 822, 1303, 29918, 2557, 29898, 1311, 29892, 2380, 1125, 13, 13, 4706, 565, 451, 1583, 29889, 1445, 29918, 3084, 29901, 13, 9651, 736, 13, 13, 4706, 3515, 29918, 10289, 353, 1583, 29889, 1445, 29918, 6672, 29918, 2848, 718, 2380, 334, 1583, 29889, 2557, 29918, 2311, 29918, 262, 29918, 13193, 580, 13, 4706, 3515, 29918, 29886, 861, 1379, 353, 1583, 29889, 2557, 29918, 29886, 861, 1379, 580, 13, 13, 4706, 565, 1583, 29889, 1445, 29918, 3084, 29901, 13, 13, 9651, 396, 16508, 304, 278, 1369, 310, 278, 3515, 13, 9651, 1583, 29889, 1445, 29918, 8411, 29889, 344, 1416, 29898, 2557, 29918, 10289, 29892, 29871, 29900, 29897, 13, 13, 9651, 396, 1303, 278, 4839, 13, 9651, 3515, 29918, 6672, 353, 1583, 29889, 348, 4058, 29898, 13, 18884, 1583, 29889, 2557, 29918, 6672, 29918, 4830, 29892, 13, 18884, 1583, 29889, 2557, 29918, 6672, 29918, 7529, 29892, 13, 18884, 1583, 29889, 1445, 29918, 8411, 29889, 949, 29898, 1311, 29889, 2557, 29918, 6672, 29918, 2311, 29897, 13, 9651, 1723, 13, 13, 9651, 396, 1303, 278, 3515, 17036, 13, 9651, 565, 1583, 29889, 29890, 407, 1275, 29871, 29896, 29901, 13, 18884, 620, 353, 7442, 29889, 3166, 1445, 29898, 1311, 29889, 1445, 29918, 8411, 29892, 26688, 2433, 13470, 29947, 742, 2302, 29922, 2557, 29918, 29886, 861, 1379, 29897, 13, 9651, 1683, 29901, 13, 18884, 620, 353, 7442, 29889, 3166, 1445, 29898, 1311, 29889, 1445, 29918, 8411, 29892, 26688, 2433, 13470, 29896, 29953, 742, 2302, 29922, 2557, 29918, 29886, 861, 1379, 29897, 13, 9651, 565, 7431, 29898, 690, 29897, 5277, 29871, 29900, 29901, 13, 18884, 17927, 29889, 2704, 877, 2392, 5183, 3515, 525, 718, 851, 29898, 2248, 29897, 718, 376, 515, 934, 376, 718, 1583, 29889, 1445, 2084, 29897, 13, 18884, 736, 6213, 13, 9651, 1683, 29901, 13, 18884, 396, 620, 14443, 964, 1967, 13, 18884, 1967, 353, 7442, 29889, 690, 14443, 29898, 690, 29892, 313, 1311, 29889, 2492, 29918, 3545, 29892, 1583, 29889, 2492, 29918, 2103, 876, 13, 18884, 736, 3515, 29918, 6672, 29892, 1967, 2 ]
GUI.py
wtarimo/CFCScorePredictor
0
44723
""" <NAME> COSI 157 - Final Project: CFC Score Predictor This module manages instances of games 11/11/2012 """ from Game import * def userInputBox(win): """Creates and diplays graphical fields for user signing and registration""" Text(Point(55,50), "Full Name:").draw(win) rName = Entry(Point(245,50),30); rName.draw(win) Text(Point(55,75), "Username:").draw(win) rUsername = Entry(Point(200,75),20); rUsername.draw(win) Text(Point(56,100), "Password:").draw(win) rPassword1 = Entry(Point(200,100),20); rPassword1.draw(win) Text(Point(56,125), "Password:").draw(win) rPassword2 = Entry(Point(200,125),20); rPassword2.draw(win) Text(Point(55,225), "Username:").draw(win) lUsername = Entry(Point(200,225),20); lUsername.draw(win) Text(Point(56,250), "Password:").draw(win) lPassword = Entry(Point(200,250),20); lPassword.draw(win) rButton = Buttons(win,Point(230,160),120,25,"REGISTER"); rButton.Activate() lButton = Buttons(win,Point(230,285),120,25,"LOGIN"); lButton.Activate() def fixtureInputBox(win): """Creates and diplays graphical fields for fixture input""" Text(Point(113,50), "Game #:").draw(win) fgame = Entry(Point(240,50),20); fgame.draw(win) Text(Point(103,75), "Opponent:").draw(win) fopponent = Entry(Point(240,75),20); fopponent.draw(win) Text(Point(118,100), "Time:").draw(win) ftime = Entry(Point(240,100),20); ftime.draw(win) Text(Point(116,125), "Venue:").draw(win) fvenue = Entry(Point(240,125),20); fvenue.draw(win) Text(Point(116,150), "Result:").draw(win) fresult = Entry(Point(240,150),20); fresult.draw(win) Text(Point(100,175), "cfcScorers:").draw(win) fcfcScorers = Entry(Point(240,175),20); fcfcScorers.draw(win) Text(Point(75,200), "OppositionScorers:").draw(win) foppositionScorers = Entry(Point(240,200),20); foppositionScorers.draw(win) submitFButton = Buttons(win,Point(230,235),150,25,"SUBMIT FIXTURE"); submitFButton.Activate() Text(Point(113,300), "Game #:").draw(win) ugame = Entry(Point(240,300),20); ugame.draw(win) Text(Point(116,325), "Result:").draw(win) uresult = Entry(Point(240,325),20); uresult.draw(win) Text(Point(100,350), "cfcScorers:").draw(win) ucfcScorers = Entry(Point(240,350),20); ucfcScorers.draw(win) Text(Point(75,375), "OppositionScorers:").draw(win) uoppositionScorers = Entry(Point(240,375),20); uoppositionScorers.draw(win) updateFButton = Buttons(win,Point(230,415),150,25,"UPDATE RESULTS"); updateFButton.Activate() def predictionInputBox(win): """Creates and diplays graphical fields for prediction input""" Text(Point(111,50), "Game #:").draw(win) game = Entry(Point(240,50),20); game.draw(win) Text(Point(116,80), "Result:").draw(win) result = Entry(Point(240,80),20); result.draw(win) Text(Point(107,110), "Scoreline:").draw(win) scoreline = Entry(Point(240,110),20); scoreline.draw(win) Text(Point(100,140), "cfcScorers:").draw(win) cfcScorers = Entry(Point(240,140),20); cfcScorers.draw(win) Text(Point(75,170), "OppositionScorers:").draw(win) oppositionScorers = Entry(Point(240,170),20); oppositionScorers.draw(win) submitRButton = Buttons(win,Point(230,235),170,25,"SUBMIT RESULT"); submitRButton.Activate() def displayStandings(win,standings): """Displays the game standings on user points""" text = Text(Point(725,40),"GAME STANDINGS"); text.setFill('grey'); text.setStyle('bold');text.setSize(20); text.draw(win) #standings = registry.getStandings() if len(standings)>10: standings=standings[:10] Text(Point(700,70), " _________Name:__________ _Points:_ _Accuracy:_").draw(win) (x,y) = (600,95) for i in range(3): y = 95 x = [600,780,850][i] for record in standings: Text(Point(x,y),record[i]).draw(win) y+=20 def displaySchedule(win,fixtures,game): """Displays the schedule for the 5 recent fixtures by game #""" text = Text(Point(730,325),"FIXTURE SCHEDULE"); text.setFill('grey'); text.setStyle('bold');text.setSize(20); text.draw(win) #fixtures = schedule.fixtures if len(fixtures)>5: fixtures = fixtures[:5] fixtures = [[str(f.game),f.opponent.split()[0],f.time,str(f.result),str(f.cfcScorers),str(f.oppositionScorers)] for f in fixtures] Text(Point(710,350), "Game#: __Opponent:__ ____Time:____ _Result_ _cfcScorers_ _oppScorers_").draw(win) (x,y) = (470,375) for i in range(6): y = 375 x = [465,545,665,755,830,940][i] for record in fixtures: text = Text(Point(x,y),record[i]) if i==0 and int(record[0])>game: text = Text(Point(x,y),record[0]+" Future") elif i==0 and int(record[0])==game: text = Text(Point(x,y),record[0]+" Next") elif i==0 and int(record[0])<game: text = Text(Point(x,y),record[0]+" Played") text.setFill('blue') if int(record[0])>game else text.setFill('red') if int(record[0])==game: text.setFill('green4') text.setSize(10); text.draw(win) y+=20 def displayPredictions(win,pDB,username,game): """Diplays predictions sumbmitted by the user""" text = Text(Point(730,505),"YOUR PREDICTIONS"); text.setFill('grey'); text.setStyle('bold');text.setSize(20); text.draw(win) predictions = pDB.getPredictions(username) if len(predictions)>5: predictions = predictions[:5] predictions = [[str(p.game),str(p.result),str(p.scoreline),str(p.cfcScorers),str(p.oppositionScorers),str(p.points)] for p in predictions] Text(Point(700,530), "_Game#:_ _Result:_ _Scoreline:_ _cfcScorers_ _oppScorers_ _Points:_").draw(win) for i in range(6): y = 555 x = [475,550,640,740,830,920][i] for record in predictions: text = Text(Point(x,y),record[i]) text.setFill('blue') if int(record[0])>game else text.setFill('red') if int(record[0])==game: text.setFill('green4') text.setSize(11); text.draw(win) y+=20 def displayOutput(win,text): """Displays info to the user at the bottom left windows""" text = text.split(",") x,y = 215,485 for record in text: text = Text(Point(x,y),record); text.setFill('grey2') text.setSize(11); text.draw(win) y+=25
[ 1, 9995, 30004, 13, 29966, 5813, 3238, 13, 3217, 5425, 29871, 29896, 29945, 29955, 448, 9550, 8010, 29901, 315, 8610, 2522, 487, 21099, 919, 272, 30004, 13, 4013, 3883, 767, 1179, 8871, 310, 8090, 30004, 13, 29896, 29896, 29914, 29896, 29896, 29914, 29906, 29900, 29896, 29906, 30004, 13, 15945, 19451, 13, 30004, 13, 3166, 8448, 1053, 334, 30004, 13, 30004, 13, 30004, 13, 30004, 13, 30004, 13, 1753, 1404, 4290, 3313, 29898, 5080, 1125, 30004, 13, 1678, 9995, 9832, 1078, 322, 652, 12922, 3983, 936, 4235, 363, 1404, 26188, 322, 22583, 15945, 19451, 13, 30004, 13, 1678, 3992, 29898, 5228, 29898, 29945, 29945, 29892, 29945, 29900, 511, 376, 13658, 4408, 29901, 2564, 4012, 29898, 5080, 8443, 13, 1678, 364, 1170, 353, 28236, 29898, 5228, 29898, 29906, 29946, 29945, 29892, 29945, 29900, 511, 29941, 29900, 416, 364, 1170, 29889, 4012, 29898, 5080, 8443, 13, 1678, 3992, 29898, 5228, 29898, 29945, 29945, 29892, 29955, 29945, 511, 376, 20249, 29901, 2564, 4012, 29898, 5080, 8443, 13, 1678, 364, 20249, 353, 28236, 29898, 5228, 29898, 29906, 29900, 29900, 29892, 29955, 29945, 511, 29906, 29900, 416, 364, 20249, 29889, 4012, 29898, 5080, 8443, 13, 1678, 3992, 29898, 5228, 29898, 29945, 29953, 29892, 29896, 29900, 29900, 511, 376, 10048, 29901, 2564, 4012, 29898, 5080, 8443, 13, 1678, 364, 10048, 29896, 353, 28236, 29898, 5228, 29898, 29906, 29900, 29900, 29892, 29896, 29900, 29900, 511, 29906, 29900, 416, 364, 10048, 29896, 29889, 4012, 29898, 5080, 8443, 13, 1678, 3992, 29898, 5228, 29898, 29945, 29953, 29892, 29896, 29906, 29945, 511, 376, 10048, 29901, 2564, 4012, 29898, 5080, 8443, 13, 1678, 364, 10048, 29906, 353, 28236, 29898, 5228, 29898, 29906, 29900, 29900, 29892, 29896, 29906, 29945, 511, 29906, 29900, 416, 364, 10048, 29906, 29889, 4012, 29898, 5080, 8443, 13, 30004, 13, 1678, 3992, 29898, 5228, 29898, 29945, 29945, 29892, 29906, 29906, 29945, 511, 376, 20249, 29901, 2564, 4012, 29898, 5080, 8443, 13, 1678, 301, 20249, 353, 28236, 29898, 5228, 29898, 29906, 29900, 29900, 29892, 29906, 29906, 29945, 511, 29906, 29900, 416, 301, 20249, 29889, 4012, 29898, 5080, 8443, 13, 1678, 3992, 29898, 5228, 29898, 29945, 29953, 29892, 29906, 29945, 29900, 511, 376, 10048, 29901, 2564, 4012, 29898, 5080, 8443, 13, 1678, 301, 10048, 353, 28236, 29898, 5228, 29898, 29906, 29900, 29900, 29892, 29906, 29945, 29900, 511, 29906, 29900, 416, 301, 10048, 29889, 4012, 29898, 5080, 8443, 13, 30004, 13, 1678, 364, 3125, 353, 1205, 7453, 29898, 5080, 29892, 5228, 29898, 29906, 29941, 29900, 29892, 29896, 29953, 29900, 511, 29896, 29906, 29900, 29892, 29906, 29945, 1699, 18166, 9047, 1001, 1496, 364, 3125, 29889, 21786, 403, 26471, 13, 1678, 301, 3125, 353, 1205, 7453, 29898, 5080, 29892, 5228, 29898, 29906, 29941, 29900, 29892, 29906, 29947, 29945, 511, 29896, 29906, 29900, 29892, 29906, 29945, 1699, 14480, 1177, 1496, 301, 3125, 29889, 21786, 403, 26471, 13, 30004, 13, 1753, 5713, 15546, 4290, 3313, 29898, 5080, 1125, 30004, 13, 1678, 9995, 9832, 1078, 322, 652, 12922, 3983, 936, 4235, 363, 5713, 15546, 1881, 15945, 19451, 13, 1678, 3992, 29898, 5228, 29898, 29896, 29896, 29941, 29892, 29945, 29900, 511, 376, 14199, 396, 29901, 2564, 4012, 29898, 5080, 8443, 13, 1678, 285, 11802, 353, 28236, 29898, 5228, 29898, 29906, 29946, 29900, 29892, 29945, 29900, 511, 29906, 29900, 416, 285, 11802, 29889, 4012, 29898, 5080, 8443, 13, 1678, 3992, 29898, 5228, 29898, 29896, 29900, 29941, 29892, 29955, 29945, 511, 376, 29949, 407, 265, 296, 29901, 2564, 4012, 29898, 5080, 8443, 13, 1678, 1701, 407, 265, 296, 353, 28236, 29898, 5228, 29898, 29906, 29946, 29900, 29892, 29955, 29945, 511, 29906, 29900, 416, 1701, 407, 265, 296, 29889, 4012, 29898, 5080, 8443, 13, 1678, 3992, 29898, 5228, 29898, 29896, 29896, 29947, 29892, 29896, 29900, 29900, 511, 376, 2481, 29901, 2564, 4012, 29898, 5080, 8443, 13, 1678, 285, 2230, 353, 28236, 29898, 5228, 29898, 29906, 29946, 29900, 29892, 29896, 29900, 29900, 511, 29906, 29900, 416, 285, 2230, 29889, 4012, 29898, 5080, 8443, 13, 1678, 3992, 29898, 5228, 29898, 29896, 29896, 29953, 29892, 29896, 29906, 29945, 511, 376, 29963, 264, 434, 29901, 2564, 4012, 29898, 5080, 8443, 13, 1678, 285, 9947, 353, 28236, 29898, 5228, 29898, 29906, 29946, 29900, 29892, 29896, 29906, 29945, 511, 29906, 29900, 416, 285, 9947, 29889, 4012, 29898, 5080, 8443, 13, 1678, 3992, 29898, 5228, 29898, 29896, 29896, 29953, 29892, 29896, 29945, 29900, 511, 376, 3591, 29901, 2564, 4012, 29898, 5080, 8443, 13, 1678, 285, 2914, 353, 28236, 29898, 5228, 29898, 29906, 29946, 29900, 29892, 29896, 29945, 29900, 511, 29906, 29900, 416, 285, 2914, 29889, 4012, 29898, 5080, 8443, 13, 1678, 3992, 29898, 5228, 29898, 29896, 29900, 29900, 29892, 29896, 29955, 29945, 511, 376, 6854, 29883, 29903, 2616, 414, 29901, 2564, 4012, 29898, 5080, 8443, 13, 1678, 285, 6854, 29883, 29903, 2616, 414, 353, 28236, 29898, 5228, 29898, 29906, 29946, 29900, 29892, 29896, 29955, 29945, 511, 29906, 29900, 416, 285, 6854, 29883, 29903, 2616, 414, 29889, 4012, 29898, 5080, 8443, 13, 1678, 3992, 29898, 5228, 29898, 29955, 29945, 29892, 29906, 29900, 29900, 511, 376, 29949, 407, 4490, 29903, 2616, 414, 29901, 2564, 4012, 29898, 5080, 8443, 13, 1678, 1701, 407, 4490, 29903, 2616, 414, 353, 28236, 29898, 5228, 29898, 29906, 29946, 29900, 29892, 29906, 29900, 29900, 511, 29906, 29900, 416, 1701, 407, 4490, 29903, 2616, 414, 29889, 4012, 29898, 5080, 8443, 13, 1678, 6756, 13, 1678, 9752, 29943, 3125, 353, 1205, 7453, 29898, 5080, 29892, 5228, 29898, 29906, 29941, 29900, 29892, 29906, 29941, 29945, 511, 29896, 29945, 29900, 29892, 29906, 29945, 1699, 20633, 26349, 383, 6415, 29911, 11499, 1496, 9752, 29943, 3125, 29889, 21786, 403, 26471, 13, 30004, 13, 1678, 3992, 29898, 5228, 29898, 29896, 29896, 29941, 29892, 29941, 29900, 29900, 511, 376, 14199, 396, 29901, 2564, 4012, 29898, 5080, 8443, 13, 1678, 318, 11802, 353, 28236, 29898, 5228, 29898, 29906, 29946, 29900, 29892, 29941, 29900, 29900, 511, 29906, 29900, 416, 318, 11802, 29889, 4012, 29898, 5080, 8443, 13, 1678, 3992, 29898, 5228, 29898, 29896, 29896, 29953, 29892, 29941, 29906, 29945, 511, 376, 3591, 29901, 2564, 4012, 29898, 5080, 8443, 13, 1678, 318, 2914, 353, 28236, 29898, 5228, 29898, 29906, 29946, 29900, 29892, 29941, 29906, 29945, 511, 29906, 29900, 416, 318, 2914, 29889, 4012, 29898, 5080, 8443, 13, 1678, 3992, 29898, 5228, 29898, 29896, 29900, 29900, 29892, 29941, 29945, 29900, 511, 376, 6854, 29883, 29903, 2616, 414, 29901, 2564, 4012, 29898, 5080, 8443, 13, 1678, 318, 6854, 29883, 29903, 2616, 414, 353, 28236, 29898, 5228, 29898, 29906, 29946, 29900, 29892, 29941, 29945, 29900, 511, 29906, 29900, 416, 318, 6854, 29883, 29903, 2616, 414, 29889, 4012, 29898, 5080, 8443, 13, 1678, 3992, 29898, 5228, 29898, 29955, 29945, 29892, 29941, 29955, 29945, 511, 376, 29949, 407, 4490, 29903, 2616, 414, 29901, 2564, 4012, 29898, 5080, 8443, 13, 1678, 318, 9354, 4490, 29903, 2616, 414, 353, 28236, 29898, 5228, 29898, 29906, 29946, 29900, 29892, 29941, 29955, 29945, 511, 29906, 29900, 416, 318, 9354, 4490, 29903, 2616, 414, 29889, 4012, 29898, 5080, 8443, 13, 1678, 6756, 13, 1678, 2767, 29943, 3125, 353, 1205, 7453, 29898, 5080, 29892, 5228, 29898, 29906, 29941, 29900, 29892, 29946, 29896, 29945, 511, 29896, 29945, 29900, 29892, 29906, 29945, 1699, 14474, 390, 2890, 8647, 29903, 1496, 2767, 29943, 3125, 29889, 21786, 403, 26471, 13, 30004, 13, 1753, 18988, 4290, 3313, 29898, 5080, 1125, 30004, 13, 1678, 9995, 9832, 1078, 322, 652, 12922, 3983, 936, 4235, 363, 18988, 1881, 15945, 19451, 13, 1678, 3992, 29898, 5228, 29898, 29896, 29896, 29896, 29892, 29945, 29900, 511, 376, 14199, 396, 29901, 2564, 4012, 29898, 5080, 8443, 13, 1678, 3748, 353, 28236, 29898, 5228, 29898, 29906, 29946, 29900, 29892, 29945, 29900, 511, 29906, 29900, 416, 3748, 29889, 4012, 29898, 5080, 8443, 13, 1678, 3992, 29898, 5228, 29898, 29896, 29896, 29953, 29892, 29947, 29900, 511, 376, 3591, 29901, 2564, 4012, 29898, 5080, 8443, 13, 1678, 1121, 353, 28236, 29898, 5228, 29898, 29906, 29946, 29900, 29892, 29947, 29900, 511, 29906, 29900, 416, 1121, 29889, 4012, 29898, 5080, 8443, 13, 1678, 3992, 29898, 5228, 29898, 29896, 29900, 29955, 29892, 29896, 29896, 29900, 511, 376, 29903, 2616, 5570, 29901, 2564, 4012, 29898, 5080, 8443, 13, 1678, 885, 272, 5570, 353, 28236, 29898, 5228, 29898, 29906, 29946, 29900, 29892, 29896, 29896, 29900, 511, 29906, 29900, 416, 885, 272, 5570, 29889, 4012, 29898, 5080, 8443, 13, 1678, 3992, 29898, 5228, 29898, 29896, 29900, 29900, 29892, 29896, 29946, 29900, 511, 376, 6854, 29883, 29903, 2616, 414, 29901, 2564, 4012, 29898, 5080, 8443, 13, 1678, 274, 13801, 29903, 2616, 414, 353, 28236, 29898, 5228, 29898, 29906, 29946, 29900, 29892, 29896, 29946, 29900, 511, 29906, 29900, 416, 274, 13801, 29903, 2616, 414, 29889, 4012, 29898, 5080, 8443, 13, 1678, 3992, 29898, 5228, 29898, 29955, 29945, 29892, 29896, 29955, 29900, 511, 376, 29949, 407, 4490, 29903, 2616, 414, 29901, 2564, 4012, 29898, 5080, 8443, 13, 1678, 19626, 29903, 2616, 414, 353, 28236, 29898, 5228, 29898, 29906, 29946, 29900, 29892, 29896, 29955, 29900, 511, 29906, 29900, 416, 19626, 29903, 2616, 414, 29889, 4012, 29898, 5080, 8443, 13, 1678, 6756, 13, 1678, 9752, 29934, 3125, 353, 1205, 7453, 29898, 5080, 29892, 5228, 29898, 29906, 29941, 29900, 29892, 29906, 29941, 29945, 511, 29896, 29955, 29900, 29892, 29906, 29945, 1699, 20633, 26349, 390, 2890, 8647, 1496, 9752, 29934, 3125, 29889, 21786, 403, 26471, 13, 30004, 13, 1753, 2479, 11042, 886, 29898, 5080, 29892, 1689, 886, 1125, 30004, 13, 1678, 9995, 4205, 12922, 278, 3748, 2317, 886, 373, 1404, 3291, 15945, 19451, 13, 1678, 1426, 353, 3992, 29898, 5228, 29898, 29955, 29906, 29945, 29892, 29946, 29900, 511, 29908, 12739, 2303, 6850, 9468, 4214, 29903, 1496, 1426, 29889, 842, 20876, 877, 7979, 29891, 2157, 1426, 29889, 842, 5568, 877, 8934, 2157, 726, 29889, 842, 3505, 29898, 29906, 29900, 416, 1426, 29889, 4012, 29898, 5080, 8443, 13, 1678, 396, 1689, 886, 353, 21235, 29889, 657, 11042, 886, 26471, 13, 1678, 565, 7431, 29898, 1689, 886, 15410, 29896, 29900, 29901, 2317, 886, 29922, 1689, 886, 7503, 29896, 29900, 29962, 30004, 13, 1678, 3992, 29898, 5228, 29898, 29955, 29900, 29900, 29892, 29955, 29900, 511, 376, 903, 14365, 1170, 29901, 14365, 1649, 268, 903, 20325, 29901, 29918, 903, 7504, 332, 4135, 29901, 29918, 2564, 4012, 29898, 5080, 8443, 13, 1678, 313, 29916, 29892, 29891, 29897, 353, 313, 29953, 29900, 29900, 29892, 29929, 29945, 8443, 13, 1678, 363, 474, 297, 3464, 29898, 29941, 1125, 30004, 13, 4706, 343, 353, 29871, 29929, 29945, 30004, 13, 4706, 921, 353, 518, 29953, 29900, 29900, 29892, 29955, 29947, 29900, 29892, 29947, 29945, 29900, 3816, 29875, 29962, 30004, 13, 4706, 363, 2407, 297, 2317, 886, 29901, 30004, 13, 9651, 3992, 29898, 5228, 29898, 29916, 29892, 29891, 511, 11651, 29961, 29875, 14664, 4012, 29898, 5080, 8443, 13, 9651, 343, 23661, 29906, 29900, 30004, 13, 30004, 13, 1753, 2479, 4504, 11272, 29898, 5080, 29892, 7241, 486, 1973, 29892, 11802, 1125, 30004, 13, 1678, 9995, 4205, 12922, 278, 20410, 363, 278, 29871, 29945, 7786, 5713, 486, 1973, 491, 3748, 396, 15945, 19451, 13, 1678, 1426, 353, 3992, 29898, 5228, 29898, 29955, 29941, 29900, 29892, 29941, 29906, 29945, 511, 29908, 3738, 12188, 11499, 317, 3210, 3352, 29965, 1307, 1496, 1426, 29889, 842, 20876, 877, 7979, 29891, 2157, 1426, 29889, 842, 5568, 877, 8934, 2157, 726, 29889, 842, 3505, 29898, 29906, 29900, 416, 1426, 29889, 4012, 29898, 5080, 8443, 13, 1678, 396, 7241, 486, 1973, 353, 20410, 29889, 7241, 486, 1973, 30004, 13, 1678, 565, 7431, 29898, 7241, 486, 1973, 15410, 29945, 29901, 5713, 486, 1973, 353, 5713, 486, 1973, 7503, 29945, 29962, 30004, 13, 1678, 5713, 486, 1973, 353, 5519, 710, 29898, 29888, 29889, 11802, 511, 29888, 29889, 9354, 265, 296, 29889, 5451, 580, 29961, 29900, 1402, 29888, 29889, 2230, 29892, 710, 29898, 29888, 29889, 2914, 511, 710, 29898, 29888, 29889, 6854, 29883, 29903, 2616, 414, 511, 710, 29898, 29888, 29889, 9354, 4490, 29903, 2616, 414, 4638, 363, 285, 297, 5713, 486, 1973, 29962, 30004, 13, 1678, 3992, 29898, 5228, 29898, 29955, 29896, 29900, 29892, 29941, 29945, 29900, 511, 376, 14199, 29937, 29901, 4770, 29949, 407, 265, 296, 29901, 1649, 29871, 903, 22359, 2481, 29901, 7652, 29871, 903, 3591, 29918, 903, 6854, 29883, 29903, 2616, 414, 29918, 903, 9354, 29903, 2616, 414, 29918, 2564, 4012, 29898, 5080, 8443, 13, 1678, 313, 29916, 29892, 29891, 29897, 353, 313, 29946, 29955, 29900, 29892, 29941, 29955, 29945, 8443, 13, 1678, 363, 474, 297, 3464, 29898, 29953, 1125, 30004, 13, 4706, 343, 353, 29871, 29941, 29955, 29945, 30004, 13, 4706, 921, 353, 518, 29946, 29953, 29945, 29892, 29945, 29946, 29945, 29892, 29953, 29953, 29945, 29892, 29955, 29945, 29945, 29892, 29947, 29941, 29900, 29892, 29929, 29946, 29900, 3816, 29875, 29962, 30004, 13, 4706, 363, 2407, 297, 5713, 486, 1973, 29901, 30004, 13, 9651, 1426, 353, 3992, 29898, 5228, 29898, 29916, 29892, 29891, 511, 11651, 29961, 29875, 2314, 30004, 13, 9651, 565, 474, 1360, 29900, 322, 938, 29898, 11651, 29961, 29900, 2314, 29958, 11802, 29901, 1426, 353, 3992, 29898, 5228, 29898, 29916, 29892, 29891, 511, 11651, 29961, 29900, 10062, 29908, 16367, 1159, 30004, 13, 9651, 25342, 474, 1360, 29900, 322, 938, 29898, 11651, 29961, 29900, 2314, 1360, 11802, 29901, 1426, 353, 3992, 29898, 5228, 29898, 29916, 29892, 29891, 511, 11651, 29961, 29900, 10062, 29908, 8084, 1159, 30004, 13, 9651, 25342, 474, 1360, 29900, 322, 938, 29898, 11651, 29961, 29900, 2314, 29966, 11802, 29901, 1426, 353, 3992, 29898, 5228, 29898, 29916, 29892, 29891, 511, 11651, 29961, 29900, 10062, 29908, 7412, 287, 1159, 30004, 13, 9651, 1426, 29889, 842, 20876, 877, 9539, 1495, 565, 938, 29898, 11651, 29961, 29900, 2314, 29958, 11802, 1683, 1426, 29889, 842, 20876, 877, 1127, 1495, 30004, 13, 9651, 565, 938, 29898, 11651, 29961, 29900, 2314, 1360, 11802, 29901, 1426, 29889, 842, 20876, 877, 12692, 29946, 1495, 30004, 13, 9651, 1426, 29889, 842, 3505, 29898, 29896, 29900, 416, 1426, 29889, 4012, 29898, 5080, 8443, 13, 9651, 343, 23661, 29906, 29900, 30004, 13, 9651, 6756, 13, 1753, 2479, 23084, 919, 1080, 29898, 5080, 29892, 29886, 4051, 29892, 6786, 29892, 11802, 1125, 30004, 13, 1678, 9995, 12130, 12922, 27303, 2533, 5838, 4430, 491, 278, 1404, 15945, 19451, 13, 1678, 1426, 353, 3992, 29898, 5228, 29898, 29955, 29941, 29900, 29892, 29945, 29900, 29945, 511, 29908, 29979, 22970, 349, 1525, 4571, 9838, 29903, 1496, 1426, 29889, 842, 20876, 877, 7979, 29891, 2157, 1426, 29889, 842, 5568, 877, 8934, 2157, 726, 29889, 842, 3505, 29898, 29906, 29900, 416, 1426, 29889, 4012, 29898, 5080, 8443, 13, 1678, 27303, 353, 282, 4051, 29889, 657, 23084, 919, 1080, 29898, 6786, 8443, 13, 1678, 565, 7431, 29898, 27711, 1080, 15410, 29945, 29901, 27303, 353, 27303, 7503, 29945, 29962, 30004, 13, 1678, 27303, 353, 5519, 710, 29898, 29886, 29889, 11802, 511, 710, 29898, 29886, 29889, 2914, 511, 710, 29898, 29886, 29889, 1557, 272, 5570, 511, 710, 29898, 29886, 29889, 6854, 29883, 29903, 2616, 414, 511, 710, 29898, 29886, 29889, 9354, 4490, 29903, 2616, 414, 511, 710, 29898, 29886, 29889, 9748, 4638, 363, 282, 297, 27303, 29962, 30004, 13, 1678, 3992, 29898, 5228, 29898, 29955, 29900, 29900, 29892, 29945, 29941, 29900, 511, 11119, 14199, 29937, 29901, 29918, 903, 3591, 29901, 29918, 29871, 903, 29903, 2616, 5570, 29901, 29918, 903, 6854, 29883, 29903, 2616, 414, 29918, 903, 9354, 29903, 2616, 414, 29918, 903, 20325, 29901, 29918, 2564, 4012, 29898, 5080, 8443, 13, 1678, 363, 474, 297, 3464, 29898, 29953, 1125, 30004, 13, 4706, 343, 353, 29871, 29945, 29945, 29945, 30004, 13, 4706, 921, 353, 518, 29946, 29955, 29945, 29892, 29945, 29945, 29900, 29892, 29953, 29946, 29900, 29892, 29955, 29946, 29900, 29892, 29947, 29941, 29900, 29892, 29929, 29906, 29900, 3816, 29875, 29962, 30004, 13, 4706, 363, 2407, 297, 27303, 29901, 30004, 13, 9651, 1426, 353, 3992, 29898, 5228, 29898, 29916, 29892, 29891, 511, 11651, 29961, 29875, 2314, 30004, 13, 9651, 1426, 29889, 842, 20876, 877, 9539, 1495, 565, 938, 29898, 11651, 29961, 29900, 2314, 29958, 11802, 1683, 1426, 29889, 842, 20876, 877, 1127, 1495, 30004, 13, 9651, 565, 938, 29898, 11651, 29961, 29900, 2314, 1360, 11802, 29901, 1426, 29889, 842, 20876, 877, 12692, 29946, 1495, 30004, 13, 9651, 1426, 29889, 842, 3505, 29898, 29896, 29896, 416, 1426, 29889, 4012, 29898, 5080, 8443, 13, 9651, 343, 23661, 29906, 29900, 30004, 13, 30004, 13, 1753, 2479, 6466, 29898, 5080, 29892, 726, 1125, 30004, 13, 1678, 9995, 4205, 12922, 5235, 304, 278, 1404, 472, 278, 5970, 2175, 5417, 15945, 19451, 13, 1678, 1426, 353, 1426, 29889, 5451, 28165, 1159, 30004, 13, 1678, 921, 29892, 29891, 353, 29871, 29906, 29896, 29945, 29892, 29946, 29947, 29945, 30004, 13, 1678, 363, 2407, 297, 1426, 29901, 30004, 13, 9651, 1426, 353, 3992, 29898, 5228, 29898, 29916, 29892, 29891, 511, 11651, 416, 1426, 29889, 842, 20876, 877, 7979, 29891, 29906, 1495, 30004, 13, 9651, 1426, 29889, 842, 3505, 29898, 29896, 29896, 416, 1426, 29889, 4012, 29898, 5080, 8443, 13, 9651, 343, 23661, 29906, 29945, 6756, 13, 1678, 6756, 13, 1678, 6756, 13, 30004, 13, 2 ]