repo_name
stringlengths 6
100
| path
stringlengths 4
294
| copies
stringclasses 981
values | size
stringlengths 4
6
| content
stringlengths 606
896k
| license
stringclasses 15
values | input_ids
listlengths 1.02k
1.02k
| labels
listlengths 1.02k
1.02k
| attention_mask
listlengths 1.02k
1.02k
|
|---|---|---|---|---|---|---|---|---|
KECB/learn
|
computer_vision/12_rmv_salt_pepper_median_blur.py
|
1
|
1464
|
import numpy as np
import cv2
import matplotlib.pyplot as plt
# load in image and add Salt and pepper noise
moon = cv2.imread('images/moon.png', 0)
######################################################## ADD SALT & PEPPER NOISE
# salt and peppering manually (randomly assign coords as either white or black)
rows, cols = moon.shape
salt_vs_pepper_ratio = 0.5
amount = 0.01
moon_salted_and_peppered = moon.copy()
num_salt = np.ceil(amount * moon.size * salt_vs_pepper_ratio)
coords = [np.random.randint(0, i - 1, int(num_salt)) for i in moon.shape]
moon_salted_and_peppered[coords] = 255
num_pepper = np.ceil(amount * moon.size * (1 - salt_vs_pepper_ratio))
coords = [np.random.randint(0, i - 1, int(num_pepper)) for i in moon.shape]
moon_salted_and_peppered[coords] = 0
############################################ APPLY MEDIAN FILTER TO REMOVE NOISE
# The second argument is the aperture linear size; it must be odd and greater
# than 1, for example: 3, 5, 7
moon_median = cv2.medianBlur(moon, 3)
# show all three images using Matplotlib
plt.figure(figsize=(15, 6))
plt.subplot(1, 3, 1)
plt.imshow(moon, cmap='gray'), plt.title('Original')
plt.xticks([]), plt.yticks([])
plt.subplot(1, 3, 2)
plt.imshow(moon_salted_and_peppered, cmap='gray')
plt.title('Salted & Peppered'), plt.xticks([]), plt.yticks([])
plt.subplot(1, 3, 3)
plt.imshow(moon_median, cmap='gray'), plt.title('Median Blur on S&P')
plt.xticks([]), plt.yticks([])
plt.tight_layout()
plt.show()
|
mit
|
[
646,
2680,
465,
980,
199,
646,
6277,
18,
199,
646,
8027,
14,
13563,
465,
4488,
199,
199,
3,
2248,
315,
1834,
436,
1050,
428,
4478,
436,
22602,
529,
11145,
199,
573,
265,
275,
6277,
18,
14,
1017,
739,
360,
4782,
15,
573,
265,
14,
4524,
297,
378,
9,
199,
199,
26207,
21380,
428,
19600,
1253,
13663,
4227,
4825,
4971,
199,
3,
10105,
436,
22602,
529,
316,
10250,
334,
2355,
590,
5090,
13259,
465,
1902,
10424,
503,
12136,
9,
199,
3838,
12,
8850,
275,
1303,
265,
14,
1392,
199,
12597,
63,
3122,
63,
12636,
529,
63,
6884,
275,
378,
14,
21,
199,
4606,
275,
378,
14,
614,
199,
573,
265,
63,
6327,
471,
63,
460,
63,
12636,
321,
581,
275,
1303,
265,
14,
1574,
342,
199,
1507,
63,
12597,
275,
980,
14,
14085,
8,
4606,
627,
1303,
265,
14,
890,
627,
10105,
63,
3122,
63,
12636,
529,
63,
6884,
9,
199,
8032,
275,
359,
1590,
14,
2355,
14,
8393,
8,
16,
12,
284,
446,
413,
12,
1109,
8,
1507,
63,
12597,
430,
367,
284,
315,
1303,
265,
14,
1392,
61,
199,
573,
265,
63,
6327,
471,
63,
460,
63,
12636,
321,
581,
59,
8032,
61,
275,
5450,
199,
1507,
63,
12636,
529,
275,
980,
14,
14085,
8,
4606,
627,
1303,
265,
14,
890,
627,
334,
17,
446,
10105,
63,
3122,
63,
12636,
529,
63,
6884,
430,
199,
8032,
275,
359,
1590,
14,
2355,
14,
8393,
8,
16,
12,
284,
446,
413,
12,
1109,
8,
1507,
63,
12636,
529,
430,
367,
284,
315,
1303,
265,
14,
1392,
61,
199,
573,
265,
63,
6327,
471,
63,
460,
63,
12636,
321,
581,
59,
8032,
61,
275,
378,
199,
199,
26634,
381,
10319,
31370,
17424,
879,
23244,
2296,
5363,
16207,
4825,
4971,
199,
3,
710,
3499,
1423,
365,
314,
282,
529,
7603,
7798,
1568,
27,
652,
1471,
506,
16699,
436,
8932,
199,
3,
2419,
413,
12,
367,
2893,
26,
650,
12,
959,
12,
1520,
199,
573,
265,
63,
13106,
275,
6277,
18,
14,
13106,
24613,
300,
8,
573,
265,
12,
650,
9,
199,
199,
3,
2498,
1006,
7795,
5935,
1808,
18619,
6711,
199,
6003,
14,
8941,
8,
23899,
2687,
1046,
12,
1227,
430,
199,
6003,
14,
13334,
8,
17,
12,
650,
12,
413,
9,
199,
6003,
14,
20413,
8,
573,
265,
12,
14920,
534,
12150,
659,
4488,
14,
1213,
360,
17286,
358,
199,
6003,
14,
26217,
25550,
4488,
14,
30588,
4157,
199,
6003,
14,
13334,
8,
17,
12,
650,
12,
499,
9,
199,
6003,
14,
20413,
8,
573,
265,
63,
6327,
471,
63,
460,
63,
12636,
321,
581,
12,
14920,
534,
12150,
358,
199,
6003,
14,
1213,
360,
27177,
471,
1253,
510,
1545,
321,
581,
659,
4488,
14,
26217,
25550,
4488,
14,
30588,
4157,
199,
6003,
14,
13334,
8,
17,
12,
650,
12,
650,
9,
199,
6003,
14,
20413,
8,
573,
265,
63,
13106,
12,
14920,
534,
12150,
659,
4488,
14,
1213,
360,
1352,
6268,
699,
76,
300,
641,
428,
6,
48,
358,
199,
6003,
14,
26217,
25550,
4488,
14,
30588,
4157,
199,
199,
6003,
14,
23787,
63,
4209,
342,
199,
6003,
14,
2384,
342,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
2680,
465,
980,
199,
646,
6277,
18,
199,
646,
8027,
14,
13563,
465,
4488,
199,
199,
3,
2248,
315,
1834,
436,
1050,
428,
4478,
436,
22602,
529,
11145,
199,
573,
265,
275,
6277,
18,
14,
1017,
739,
360,
4782,
15,
573,
265,
14,
4524,
297,
378,
9,
199,
199,
26207,
21380,
428,
19600,
1253,
13663,
4227,
4825,
4971,
199,
3,
10105,
436,
22602,
529,
316,
10250,
334,
2355,
590,
5090,
13259,
465,
1902,
10424,
503,
12136,
9,
199,
3838,
12,
8850,
275,
1303,
265,
14,
1392,
199,
12597,
63,
3122,
63,
12636,
529,
63,
6884,
275,
378,
14,
21,
199,
4606,
275,
378,
14,
614,
199,
573,
265,
63,
6327,
471,
63,
460,
63,
12636,
321,
581,
275,
1303,
265,
14,
1574,
342,
199,
1507,
63,
12597,
275,
980,
14,
14085,
8,
4606,
627,
1303,
265,
14,
890,
627,
10105,
63,
3122,
63,
12636,
529,
63,
6884,
9,
199,
8032,
275,
359,
1590,
14,
2355,
14,
8393,
8,
16,
12,
284,
446,
413,
12,
1109,
8,
1507,
63,
12597,
430,
367,
284,
315,
1303,
265,
14,
1392,
61,
199,
573,
265,
63,
6327,
471,
63,
460,
63,
12636,
321,
581,
59,
8032,
61,
275,
5450,
199,
1507,
63,
12636,
529,
275,
980,
14,
14085,
8,
4606,
627,
1303,
265,
14,
890,
627,
334,
17,
446,
10105,
63,
3122,
63,
12636,
529,
63,
6884,
430,
199,
8032,
275,
359,
1590,
14,
2355,
14,
8393,
8,
16,
12,
284,
446,
413,
12,
1109,
8,
1507,
63,
12636,
529,
430,
367,
284,
315,
1303,
265,
14,
1392,
61,
199,
573,
265,
63,
6327,
471,
63,
460,
63,
12636,
321,
581,
59,
8032,
61,
275,
378,
199,
199,
26634,
381,
10319,
31370,
17424,
879,
23244,
2296,
5363,
16207,
4825,
4971,
199,
3,
710,
3499,
1423,
365,
314,
282,
529,
7603,
7798,
1568,
27,
652,
1471,
506,
16699,
436,
8932,
199,
3,
2419,
413,
12,
367,
2893,
26,
650,
12,
959,
12,
1520,
199,
573,
265,
63,
13106,
275,
6277,
18,
14,
13106,
24613,
300,
8,
573,
265,
12,
650,
9,
199,
199,
3,
2498,
1006,
7795,
5935,
1808,
18619,
6711,
199,
6003,
14,
8941,
8,
23899,
2687,
1046,
12,
1227,
430,
199,
6003,
14,
13334,
8,
17,
12,
650,
12,
413,
9,
199,
6003,
14,
20413,
8,
573,
265,
12,
14920,
534,
12150,
659,
4488,
14,
1213,
360,
17286,
358,
199,
6003,
14,
26217,
25550,
4488,
14,
30588,
4157,
199,
6003,
14,
13334,
8,
17,
12,
650,
12,
499,
9,
199,
6003,
14,
20413,
8,
573,
265,
63,
6327,
471,
63,
460,
63,
12636,
321,
581,
12,
14920,
534,
12150,
358,
199,
6003,
14,
1213,
360,
27177,
471,
1253,
510,
1545,
321,
581,
659,
4488,
14,
26217,
25550,
4488,
14,
30588,
4157,
199,
6003,
14,
13334,
8,
17,
12,
650,
12,
650,
9,
199,
6003,
14,
20413,
8,
573,
265,
63,
13106,
12,
14920,
534,
12150,
659,
4488,
14,
1213,
360,
1352,
6268,
699,
76,
300,
641,
428,
6,
48,
358,
199,
6003,
14,
26217,
25550,
4488,
14,
30588,
4157,
199,
199,
6003,
14,
23787,
63,
4209,
342,
199,
6003,
14,
2384,
342,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
latrop/sdss_downloader
|
sdss_downloader.py
|
1
|
22627
|
#! /usr/bin/env python
#
# Author: Sergey Savchenko (savchenko.s.s@gmail.com)
#
from threading import Thread
import subprocess
from math import hypot, log10, sqrt
from time import time, sleep
import urllib.request
import urllib
import sys
import os
import glob
import shutil
import argparse
import bz2
import numpy as np
from astropy.io import fits
try:
from astropy.wcs import WCS
wcsOK = True
except ImportError:
wcsOK = False
def move(src, dst):
if not os.path.isfile(src):
print("File %s not found and cannot be moved")
return
shutil.copy(src, dst)
os.remove(src)
def findField2(objRA, objDEC, radius):
request = "http://skyserver.sdss.org/dr16/en/tools/search/x_results.aspx?"
request += "searchtool=Radial&uband=&gband=&rband=&iband=&zband=&jband=&hband=&kband="
request += "&TaskName=Skyserver.Search.Radial&ReturnHtml=true&whichphotometry=optical&"
request += "coordtype=equatorial&ra=%1.5f&dec=%1.5f" % (objRA, objDEC)
if radius < 0.01:
request += "&radius=2"
else:
request += "&radius=%1.2f" % (radius)
request += "&min_u=0&max_u=20&min_g=0&max_g=20&min_r=0&max_r=20&min_i=0&max_i=20"
request += "&min_z=0&max_z=20&min_j=0&max_j=20&min_h=0&max_h=20&min_k=0&max_k=20"
request += "&format=csv&TableName=&limit=99999"
u = urllib.request.urlopen(request)
table = u.read().decode().split("\n")
optRun = None
optRerun = None
optCamcol = None
optField = None
optObjID = None
# Find the nearest object and the corresponding field
minDist = 1e10
for line in table:
# ignore comments, header and footer of table
if (len(line) == 0) or (not line[0].isdigit()):
continue
objParams = line.split(',')
objID = int(objParams[0])
run = int(objParams[1])
rerun = int(objParams[2])
camcol = int(objParams[3])
field = int(objParams[4])
ra = float(objParams[7])
dec = float(objParams[8])
dist = hypot(objRA - ra, objDEC - dec)
if dist < minDist:
minDist = dist
optObjID = objID
optRun = run
optRerun = rerun
optCamcol = camcol
optField = field
fList = [(optRun, optRerun, optCamcol, optField)]
if radius < 0.001:
return fList, optObjID
else:
for line in table:
# ignore comments, header and footer of table
if (len(line) == 0) or (not line[0].isdigit()):
continue
objParams = line.split(',')
run = int(objParams[1])
rerun = int(objParams[2])
camcol = int(objParams[3])
field = int(objParams[4])
if (run, rerun, camcol, field) not in fList:
fList.append((run, rerun, camcol, field))
return fList, optObjID
def getUrl(run, rerun, camcol, field, band):
u = "http://dr16.sdss.org/sas/dr16/eboss/photoObj/frames/"
u += "%s/%i/%i/frame-%s-%.6i-%i-%.4i.fits.bz2" % (rerun, run, camcol, band,
run, camcol, field)
return u
def testUrlExists(url):
try:
u = urllib.request.urlopen(url)
code = u.code
meta = u.info()
file_size = int(meta["Content-Length"])
if code == 200:
return file_size
return -1
except urllib.request.HTTPError:
return -1
def download(url, passband, file_name):
fName = "./downloads/%s_%s.fits" % (file_name, passband)
if passband != "ps": # PSF-files are not compressed on SDSS servers
fName += ".bz2"
try:
urllib.request.urlretrieve(url, fName)
except urllib.request.HTTPError:
print("")
return -1
def threadsAlive(listOfThreads):
for th in listOfThreads:
if th.is_alive():
return True
return False
# some sdss functions are below
def prep_ima(gal):
new_gal = "./prep_ima_tmp.fits"
# This function re-writes pixel values given in NMgy to ADU
hdulist = fits.open(gal, do_not_scale_image_data=True, mode='update')
img = hdulist[0].data
(dimy, dimx) = img.shape
cimg = np.zeros(shape=(dimy, dimx))
calib = hdulist[1].data
for i in range(dimy):
cimg[i] = calib
dn = img/cimg
shutil.copy(gal, new_gal)
hdulist1 = fits.open(new_gal, do_not_scale_image_data=True,
mode='update')
img_new = hdulist1[0].data
for i in range(dimy):
for k in range(dimx):
img_new[i, k] = dn[i, k] # new fits-file img_new with ADU
hdulist1.flush()
os.remove(gal)
move(new_gal, gal)
def change_m0(fitsName, oldM0Value, refM0):
# function changes value of magnitude zeropoint to a given one
hdulist = fits.open(fitsName)
data = hdulist[0].data
header = hdulist[0].header
deltaM0 = refM0 - oldM0Value
data = data * (10.0**(0.4*deltaM0))
outHDU = fits.PrimaryHDU(data=data, header=header)
outHDU.writeto("tmp.fits")
os.remove(fitsName)
move("tmp.fits", fitsName)
def gain_dark_SDSS(camcol, band, run):
if band == 'u':
if camcol == 1:
gaidark = [1.62, 9.61]
if camcol == 2:
if run < 1100:
gaidark = [1.595, 12.6025]
else:
gaidark = [1.825, 12.6025]
if camcol == 3:
gaidark = [1.59, 8.7025]
if camcol == 4:
gaidark = [1.6, 12.6025]
if camcol == 5:
gaidark = [1.47, 9.3025]
if camcol == 6:
gaidark = [2.17, 7.0225]
if band == 'g':
if camcol == 1:
gaidark = [3.32, 15.6025]
if camcol == 2:
gaidark = [3.855, 1.44]
if camcol == 3:
gaidark = [3.845, 1.3225]
if camcol == 4:
gaidark = [3.995, 1.96]
if camcol == 5:
gaidark = [4.05, 1.1025]
if camcol == 6:
gaidark = [4.035, 1.8225]
if band == 'r':
if camcol == 1:
gaidark = [4.71, 1.8225]
if camcol == 2:
gaidark = [4.6, 1.00]
if camcol == 3:
gaidark = [4.72, 1.3225]
if camcol == 4:
gaidark = [4.76, 1.3225]
if camcol == 5:
gaidark = [4.725, 0.81]
if camcol == 6:
gaidark = [4.895, 0.9025]
if band == 'i':
if camcol == 1:
gaidark = [5.165, 7.84]
if camcol == 2:
if run < 1500:
gaidark = [6.565, 5.76]
if run > 1500:
gaidark = [6.565, 6.25]
if camcol == 3:
gaidark = [4.86, 4.6225]
if camcol == 4:
if run < 1500:
gaidark = [4.885, 6.25]
if run > 1500:
gaidark = [4.885, 7.5625]
if camcol == 5:
gaidark = [4.64, 7.84]
if camcol == 6:
gaidark = [4.76, 5.0625]
if band == 'z':
if camcol == 1:
gaidark = [4.745, 0.81]
if camcol == 2:
gaidark = [5.155, 1.0]
if camcol == 3:
gaidark = [4.885, 1.0]
if camcol == 4:
if run < 1500:
gaidark = [4.775, 9.61]
if run > 1500:
gaidark = [4.775, 12.6025]
if camcol == 5:
if run < 1500:
gaidark = [3.48, 1.8225]
if run > 1500:
gaidark = [3.48, 2.1025]
if camcol == 6:
gaidark = [4.69, 1.21]
return gaidark[0], gaidark[1]
def SDSS_dr8(gal_image):
# http://data.sdss3.org/datamodel/files/BOSS_PHOTOOBJ/
# frames/RERUN/RUN/CAMCOL/frame.html
hdulist = fits.open(gal_image)
prihdr = hdulist[0].header
run = int(prihdr['RUN'])
band = str(prihdr['FILTER'])
camcol = int(prihdr['CAMCOL'])
kkk = prihdr['NMGY']
m0 = 22.5 - 2.5*log10(kkk)
GAIN, var = gain_dark_SDSS(camcol, band, run)
read_out_noise = sqrt(var)*GAIN # should be <~5 e
return GAIN, read_out_noise, m0
def bunzip(zipName):
bzipFile = bz2.BZ2File(zipName)
data = bzipFile.read()
outName = zipName[:-4]
if os.path.isfile(outName):
os.remove(outName)
outFile = open(outName, 'wb')
outFile.write(data)
outFile.close()
os.remove(zipName)
def reduce_to_same_m0(listOfImages):
GAINList = []
READOUTList = []
m0List = []
for i, fName in enumerate(listOfImages):
bunzip("%s.bz2" % fName)
prep_ima(fName)
GAIN, READOUT, m0 = SDSS_dr8(fName)
if i == 0:
refM0 = m0
else:
change_m0(fName, m0, refM0)
GAINList.append(GAIN)
READOUTList.append(READOUT)
hdu = fits.open(fName, do_not_scale_image_data=True,
mode="update")
header = hdu[0].header
header["M0"] = refM0
header["EXPTIME"] = 1.0
hdu.flush()
return GAINList, READOUTList, m0List, refM0
# parsing the argument line here
parser = argparse.ArgumentParser(description="Download fits-files of fields for specified coordinates")
parser.add_argument("filters", help="List of filters (for example gri or uiz)")
parser.add_argument("-i", "--input", default="coordinates.dat",
help="File with coordinates to download")
parser.add_argument("-a", "--adjacent", action="store_true", default=False,
help="Download adjacent fields if any exist")
parser.add_argument("-s", "--swarp", action="store_true", default=False,
help="Concatenate fields using SWarp package")
parser.add_argument("-c", "--convert", action="store_true", default=False,
help="Convert fields to the same photometry zeropoint")
parser.add_argument("-f", "--free", action="store_true", default=False,
help="Remove individual fields after concatenation")
parser.add_argument("-t", "--trim", action="store_true", default=False,
help="Crop image to galaxy size")
parser.add_argument("--scatter", action="store_true", default=False,
help="Put every object in a separate directory")
parser.add_argument("--add_urls", default=None,
help="File with additional urls of fields for objects")
parser.add_argument("--add_fields", default=None,
help="File wuth additional run,rerun,camcol,fields data for objects")
args = parser.parse_args()
bandlist = args.filters
# Make dirs for all bands and psf in case all files for the same
# colour are in the same directories (scatter option is turned off)
if not args.scatter:
for band in bandlist:
if not os.path.exists("./downloads/%s" % (band)):
os.makedirs("./downloads/%s" % (band))
else:
# if every object will be placed in the separate directory
# (scatter option is on) create just the main downloads directory for now
if not os.path.exists("./downloads/"):
os.makedirs("./downloads/")
if args.swarp:
# Check what name has SWarp package on this system
rCode = subprocess.call("which swarp >/dev/null", shell=True)
if rCode == 0:
swarpName = "swarp"
else:
rCode = subprocess.call("which SWarp >/dev/null", shell=True)
if rCode == 0:
swarpName = "SWarp"
else:
print("\033[31m Error: SWarp was not found on your system.\033[0m")
print("\033[31m The command has to be either 'swarp' or 'SWarp'\033[0m")
print("\033[31m Intall SWarp package or try to run this script without -s option.\033[0m")
exit(1)
listOfCoords = [lst for lst in open(args.input).readlines() if not lst.startswith("#")]
counter = 0
errFile = open("errors_404.dat", "w", buffering=1)
with open("fields.dat", "w", buffering=1) as outFile:
for line in listOfCoords:
counter += 1
params = line.split()
if (len(params) in (3, 4)) or ((len(params) == 4)
and (args.adjacent is True)):
galName = params[0]
ra = float(params[1])
dec = float(params[2])
if args.adjacent is True:
r_adj = float(params[3])
else:
r_adj = 0.0
msg = "\033[33m Downloading field for "
msg += "%1.5f %1.5f: '%s' (%i/%i) \033[0m" % (ra, dec,
galName, counter,
len(listOfCoords))
print(msg)
else:
print("Invalid number of columns in input file %s" % args.input)
sys.exit(1)
objFieldList, objID = findField2(ra, dec, r_adj)
if objID is None:
print("\033[31m Error! No object was found at given coordinates.\033[0m")
print("\033[31m This area is probably outside of the SDSS footprint.\033[0m")
errFile.write("%s %1.6f %1.6f \n" % (galName, ra, dec))
continue
if len(objFieldList) > 1:
print("There are %i files for this object" % (len(objFieldList)))
outFile.write("%s %1.6f %1.6f " % (galName, ra, dec))
for ifield in range(len(objFieldList)):
startTime = time()
if len(objFieldList) > 1:
print("Downloading (%i/%i)" % (ifield + 1, len(objFieldList)))
curGalName = galName + "_" + str(ifield)
else:
curGalName = galName + "_0"
run, rerun, camcol, field = objFieldList[ifield]
# Check if fits files exist for all filters:
print(" Checking file existense:")
allExist = True
urls = {}
for band in bandlist:
print(" %s" % (band), end="")
url = getUrl(run, rerun, camcol, field, band)
answer = testUrlExists(url)
if answer == -1:
allExist = False
print("\033[31m [Fail!] \033[0m\n")
break
print("\033[32m [OK] \033[0m (%i bytes)" % (answer))
urls[band] = url
if not allExist:
errFile.write("%s %1.6f %1.6f \n" % (galName, ra, dec))
continue
downloadThreads = []
# Downloading files in all passbands
for band in bandlist:
dth = Thread(target=download,
args=(urls[band], band, curGalName))
dth.daemon = True
dth.start()
downloadThreads.append(dth)
print(" Downloading", end="")
while threadsAlive(downloadThreads):
sys.stdout.write(".")
sys.stdout.flush()
sleep(0.333)
sys.stdout.write(".")
sys.stdout.flush()
sleep(0.333)
sys.stdout.write(".")
sys.stdout.flush()
sleep(0.333)
sys.stdout.write("\b\b\b \b\b\b")
sys.stdout.flush()
sleep(0.333)
msg = " \033[34m [DONE] \033[0m "
msg += "(%1.2f sec)\n\n" % (time()-startTime)
print(msg)
outFile.write(" %s.fits " % (curGalName))
outFile.write("\n")
# If there are additional urls
if (args.add_fields is not None) or (args.add_urls is not None):
addNames = {band: [] for band in bandlist}
else:
addNames = None
if args.add_urls is not None:
for line in open(args.add_urls):
if line.split()[0] == galName:
listOfAddUrls = line.split()[1:]
thereAreAddFields = True
for band in bandlist:
for url in listOfAddUrls:
urlBand = url.replace("*", band)
outNameAdd = "./downloads/%s_%s" % (galName, urlBand.split("/")[-1])
addNames[band].append(outNameAdd[:-4])
print("Downloading additional field %s" % (outNameAdd))
subprocess.call("wget -nv -O %s %s" % (outNameAdd, urlBand), shell=True)
break
if args.add_fields is not None:
for line in open(args.add_fields):
if line.split(":")[0] == galName:
listOfAddFields = line.split(":")[1]
for runData in listOfAddFields.split(";"):
run = int(runData.split()[0])
rerun = int(runData.split()[1])
camcol = int(runData.split()[2])
field = int(runData.split()[3])
for band in bandlist:
url = getUrl(run, rerun, camcol, field, band)
outNameAdd = "./downloads/%s_%s" % (galName, url.split("/")[-1])
addNames[band].append(outNameAdd[:-4])
print("Downloading additional field %s" % (outNameAdd))
subprocess.call("wget -nv -O %s %s" % (outNameAdd, url), shell=True)
# Concatenating fields
if args.swarp and ((len(objFieldList) > 1) or (addNames is not None)):
for band in bandlist:
listOfImages = ["./downloads/%s_%i_%s.fits" % (galName, i, band) for i in range(len(objFieldList))]
if (args.add_urls is not None) or (args.add_fields is not None):
listOfImages.extend(addNames[band])
if args.convert:
GAINList, READOUTList, m0List, refM0 = reduce_to_same_m0(listOfImages)
print("Running SWarp for %s band..." % (band))
callSt = "%s -verbose_type quiet -BACK_TYPE MANUAL " % (swarpName)
callSt += " ".join(["%s[0]" % (s) for s in listOfImages])
subprocess.call(callSt, shell="True")
move("./coadd.fits", "./downloads/%s_%s.fits" % (galName, band))
os.remove("coadd.weight.fits")
os.remove("swarp.xml")
if args.free:
for fN in listOfImages:
os.remove(fN)
# store mean keywords to coadded file
if args.convert:
hdu = fits.open("./downloads/%s_%s.fits" % (galName, band),
do_not_scale_image_data=True,
mode="update")
header = hdu[0].header
header["GAIN"] = np.mean(GAINList)
header["READOUT"] = np.mean(READOUTList)
header["M0"] = refM0
header["EXPTIME"] = 1.0
hdu.flush()
# Convert singlefield images
if args.convert and ((len(objFieldList) == 1) and (addNames is None)):
for band in bandlist:
fName = "./downloads/%s_0_%s.fits" % (galName, band)
bunzip("%s.bz2" % (fName))
prep_ima(fName)
GAIN, READOUT, m0 = SDSS_dr8(fName)
hdu = fits.open(fName, do_not_scale_image_data=True,
mode="update")
header = hdu[0].header
header["M0"] = m0
header["EXPTIME"] = 1.0
hdu.flush()
move("./downloads/%s_0_%s.fits" % (galName, band),
"./downloads/%s_%s.fits" % (galName, band))
# Crop images
if args.trim and (not wcsOK):
print("Astropy module was not found. Images cannot be trimmed")
elif args.trim and wcsOK:
print("Cropping...")
# At first determine the common size of cropping area
# (so all images will be of the same size)
pixelCoords = {}
cropSizes = []
for band in bandlist:
fName = "./downloads/%s_%s.fits" % (galName, band)
hdu = fits.open(fName)
data = hdu[0].data
wcs = WCS(fName)
xGalPix, yGalPix = wcs.wcs_world2pix([[ra, dec]], 1)[0]
size = min(r_adj*60.0/0.396127, xGalPix, yGalPix,
data.shape[1]-xGalPix, data.shape[0]-yGalPix)
hdu.close()
pixelCoords[band] = (int(xGalPix), int(yGalPix))
cropSizes.append(size)
commonCropSize = int(min(cropSizes))
for band in bandlist:
fName = "./downloads/%s_%s.fits" % (galName, band)
hdu = fits.open(fName)
data = hdu[0].data
header = hdu[0].header
xCropMin = pixelCoords[band][0] - commonCropSize
xCropMax = pixelCoords[band][0] + commonCropSize
yCropMin = pixelCoords[band][1] - commonCropSize
yCropMax = pixelCoords[band][1] + commonCropSize
data = data[yCropMin:yCropMax, xCropMin:xCropMax]
outHDU = fits.PrimaryHDU(data=data, header=header)
fOutName = "./downloads/%s_%s_trim.fits" % (galName, band)
if os.path.exists(fOutName):
os.remove(fOutName)
outHDU.writeto(fOutName)
hdu.close()
if args.free:
os.remove(fName)
# Downloading and processing are finished. Now we have to place files to folders
# according to scatter option
if args.scatter:
# every object has separate filder, where all files related to this object
# are located
fileList = glob.glob("./downloads/%s*.fits" % (galName))
dst = "./downloads/%s/" % (galName)
if not os.path.exists(dst):
os.mkdir(dst)
for src in fileList:
move(src, dst)
else:
# scatter option is off, so all images taken in the same passband
# will be in the same folder.
for band in bandlist:
fileList = glob.glob("./downloads/%s_*%s.fits" % (galName, band))
if args.trim:
fileList.append("./downloads/%s_%s_trim.fits" % (galName, band))
dst = "./downloads/%s/" % (band)
for src in fileList:
if os.path.exists(src):
move(src, dst)
|
gpl-3.0
|
[
3168,
1182,
2647,
15,
1393,
15,
1813,
2366,
199,
199,
3,
199,
3,
221,
6529,
26,
3739,
303,
89,
428,
1214,
24604,
7697,
334,
23374,
24604,
7697,
14,
83,
14,
83,
32,
6799,
14,
957,
9,
199,
3,
199,
199,
504,
5796,
492,
11086,
199,
646,
3873,
199,
504,
3473,
492,
30716,
357,
12,
943,
709,
12,
7452,
199,
504,
900,
492,
900,
12,
9435,
199,
646,
4011,
14,
1069,
199,
646,
4011,
199,
646,
984,
199,
646,
747,
199,
646,
5739,
199,
646,
5145,
199,
646,
7534,
199,
646,
15055,
18,
199,
199,
646,
2680,
465,
980,
199,
504,
28753,
14,
2308,
492,
20147,
199,
199,
893,
26,
272,
687,
28753,
14,
30394,
492,
644,
3298,
272,
336,
1259,
3593,
275,
715,
199,
2590,
3545,
26,
272,
336,
1259,
3593,
275,
756,
421,
199,
318,
4057,
8,
2164,
12,
5042,
304,
272,
340,
440,
747,
14,
515,
14,
6292,
8,
2164,
304,
267,
870,
480,
1173,
450,
83,
440,
1911,
436,
3913,
506,
12155,
531,
267,
372,
272,
5145,
14,
1574,
8,
2164,
12,
5042,
9,
272,
747,
14,
2168,
8,
2164,
9,
421,
199,
318,
2342,
792,
18,
8,
1113,
2847,
12,
1559,
16387,
12,
9362,
304,
272,
1056,
275,
298,
1014,
921,
12267,
1000,
14,
3893,
385,
14,
1308,
15,
5012,
975,
15,
287,
15,
2537,
15,
1733,
15,
88,
63,
2604,
14,
26146,
13472,
272,
1056,
847,
298,
1733,
3557,
29,
26647,
279,
6,
456,
460,
19167,
4908,
460,
19167,
4848,
460,
19167,
1892,
460,
19167,
90,
7877,
19167,
74,
7877,
19167,
72,
7877,
19167,
7862,
460,
628,
272,
1056,
847,
11746,
4476,
985,
29,
51,
10562,
1000,
14,
5278,
14,
26647,
279,
6,
1767,
12957,
29,
2052,
6,
6777,
838,
357,
2358,
29,
411,
3294,
6,
2,
272,
1056,
847,
298,
7988,
466,
29,
15788,
707,
2380,
6,
345,
2458,
17,
14,
21,
70,
6,
7778,
2458,
17,
14,
21,
70,
2,
450,
334,
1113,
2847,
12,
1559,
16387,
9,
272,
340,
9362,
665,
378,
14,
614,
26,
267,
1056,
847,
11746,
8017,
29,
18,
2,
272,
587,
26,
267,
1056,
847,
11746,
8017,
2458,
17,
14,
18,
70,
2,
450,
334,
8017,
9,
272,
1056,
847,
11746,
827,
63,
85,
29,
16,
6,
988,
63,
85,
29,
1165,
6,
827,
63,
71,
29,
16,
6,
988,
63,
71,
29,
1165,
6,
827,
63,
82,
29,
16,
6,
988,
63,
82,
29,
1165,
6,
827,
63,
73,
29,
16,
6,
988,
63,
73,
29,
1165,
2,
272,
1056,
847,
11746,
827,
63,
90,
29,
16,
6,
988,
63,
90,
29,
1165,
6,
827,
63,
74,
29,
16,
6,
988,
63,
74,
29,
1165,
6,
827,
63,
72,
29,
16,
6,
988,
63,
72,
29,
1165,
6,
827,
63,
75,
29,
16,
6,
988,
63,
75,
29,
1165,
2,
272,
1056,
847,
11746,
908,
29,
4737,
6,
3186,
985,
19167,
3097,
29,
27055,
2,
339,
399,
275,
4011,
14,
1069,
14,
10890,
8,
1069,
9,
272,
1817,
275,
399,
14,
739,
1252,
2708,
1252,
1294,
4582,
78,
531,
272,
2450,
2540,
275,
488,
272,
2450,
50,
281,
324,
275,
488,
272,
2450,
30524,
761,
275,
488,
272,
2450,
792,
275,
488,
272,
2450,
5665,
998,
275,
488,
272,
327,
6668,
314,
17173,
909,
436,
314,
5226,
901,
272,
1748,
12012,
275,
413,
69,
709,
272,
367,
1004,
315,
1817,
26,
267,
327,
3686,
6786,
12,
1406,
436,
14178,
402,
1817,
267,
340,
334,
552,
8,
604,
9,
508,
378,
9,
503,
334,
1397,
1004,
59,
16,
1055,
13896,
5109,
288,
1980,
267,
1559,
6007,
275,
1004,
14,
1294,
11917,
267,
1559,
998,
275,
1109,
8,
1113,
6007,
59,
16,
566,
267,
1255,
275,
1109,
8,
1113,
6007,
59,
17,
566,
267,
295,
1065,
275,
1109,
8,
1113,
6007,
59,
18,
566,
267,
27570,
761,
275,
1109,
8,
1113,
6007,
59,
19,
566,
267,
901,
275,
1109,
8,
1113,
6007,
59,
20,
566,
267,
660,
275,
2069,
8,
1113,
6007,
59,
23,
566,
267,
9700,
275,
2069,
8,
1113,
6007,
59,
24,
566,
267,
2917,
275,
30716,
357,
8,
1113,
2847,
446,
660,
12,
1559,
16387,
446,
9700,
9,
267,
340,
2917,
665,
1748,
12012,
26,
288,
1748,
12012,
275,
2917,
288,
2450,
5665,
998,
275,
1559,
998,
288,
2450,
2540,
275,
1255,
288,
2450,
50,
281,
324,
275,
295,
1065,
288,
2450,
30524,
761,
275,
27570,
761,
288,
2450,
792,
275,
901,
272,
289,
1296,
275,
3842,
2992,
2540,
12,
2450,
50,
281,
324,
12,
2450,
30524,
761,
12,
2450,
792,
1874,
272,
340,
9362,
665,
378,
14,
4587,
26,
267,
372,
289,
1296,
12,
2450,
5665,
998,
272,
587,
26,
267,
367,
1004,
315,
1817,
26,
288,
327,
3686,
6786,
12,
1406,
436,
14178,
402,
1817,
288,
340,
334,
552,
8,
604,
9,
508,
378,
9,
503,
334,
1397,
1004,
59,
16,
1055,
13896,
5109,
355,
1980,
288,
1559,
6007,
275,
1004,
14,
1294,
11917,
288,
1255,
275,
1109,
8,
1113,
6007,
59,
17,
566,
288,
295,
1065,
275,
1109,
8,
1113,
6007,
59,
18,
566,
288,
27570,
761,
275,
1109,
8,
1113,
6007,
59,
19,
566,
288,
901,
275,
1109,
8,
1113,
6007,
59,
20,
566,
288,
340,
334,
1065,
12,
295,
1065,
12,
27570,
761,
12,
901,
9,
440,
315,
289,
1296,
26,
355,
289,
1296,
14,
740,
1332,
1065,
12,
295,
1065,
12,
27570,
761,
12,
901,
430,
272,
372,
289,
1296,
12,
2450,
5665,
998,
421,
199,
318,
29937,
8,
1065,
12,
295,
1065,
12,
27570,
761,
12,
901,
12,
10981,
304,
272,
399,
275,
298,
1014,
921,
5012,
975,
14,
3893,
385,
14,
1308,
15,
22601,
15,
5012,
975,
15,
69,
25020,
15,
13834,
5665,
15,
8444,
6687,
272,
399,
847,
2071,
83,
3149,
73,
3149,
73,
15,
1943,
3295,
83,
3295,
14,
22,
73,
3295,
73,
3295,
14,
20,
73,
14,
14948,
14,
10582,
18,
2,
450,
334,
264,
1065,
12,
1255,
12,
27570,
761,
12,
10981,
12,
10028,
1255,
12,
27570,
761,
12,
901,
9,
272,
372,
399,
421,
199,
318,
511,
6417,
7965,
8,
633,
304,
272,
862,
26,
267,
399,
275,
4011,
14,
1069,
14,
10890,
8,
633,
9,
267,
1233,
275,
399,
14,
600,
267,
3404,
275,
399,
14
] |
[
1182,
2647,
15,
1393,
15,
1813,
2366,
199,
199,
3,
199,
3,
221,
6529,
26,
3739,
303,
89,
428,
1214,
24604,
7697,
334,
23374,
24604,
7697,
14,
83,
14,
83,
32,
6799,
14,
957,
9,
199,
3,
199,
199,
504,
5796,
492,
11086,
199,
646,
3873,
199,
504,
3473,
492,
30716,
357,
12,
943,
709,
12,
7452,
199,
504,
900,
492,
900,
12,
9435,
199,
646,
4011,
14,
1069,
199,
646,
4011,
199,
646,
984,
199,
646,
747,
199,
646,
5739,
199,
646,
5145,
199,
646,
7534,
199,
646,
15055,
18,
199,
199,
646,
2680,
465,
980,
199,
504,
28753,
14,
2308,
492,
20147,
199,
199,
893,
26,
272,
687,
28753,
14,
30394,
492,
644,
3298,
272,
336,
1259,
3593,
275,
715,
199,
2590,
3545,
26,
272,
336,
1259,
3593,
275,
756,
421,
199,
318,
4057,
8,
2164,
12,
5042,
304,
272,
340,
440,
747,
14,
515,
14,
6292,
8,
2164,
304,
267,
870,
480,
1173,
450,
83,
440,
1911,
436,
3913,
506,
12155,
531,
267,
372,
272,
5145,
14,
1574,
8,
2164,
12,
5042,
9,
272,
747,
14,
2168,
8,
2164,
9,
421,
199,
318,
2342,
792,
18,
8,
1113,
2847,
12,
1559,
16387,
12,
9362,
304,
272,
1056,
275,
298,
1014,
921,
12267,
1000,
14,
3893,
385,
14,
1308,
15,
5012,
975,
15,
287,
15,
2537,
15,
1733,
15,
88,
63,
2604,
14,
26146,
13472,
272,
1056,
847,
298,
1733,
3557,
29,
26647,
279,
6,
456,
460,
19167,
4908,
460,
19167,
4848,
460,
19167,
1892,
460,
19167,
90,
7877,
19167,
74,
7877,
19167,
72,
7877,
19167,
7862,
460,
628,
272,
1056,
847,
11746,
4476,
985,
29,
51,
10562,
1000,
14,
5278,
14,
26647,
279,
6,
1767,
12957,
29,
2052,
6,
6777,
838,
357,
2358,
29,
411,
3294,
6,
2,
272,
1056,
847,
298,
7988,
466,
29,
15788,
707,
2380,
6,
345,
2458,
17,
14,
21,
70,
6,
7778,
2458,
17,
14,
21,
70,
2,
450,
334,
1113,
2847,
12,
1559,
16387,
9,
272,
340,
9362,
665,
378,
14,
614,
26,
267,
1056,
847,
11746,
8017,
29,
18,
2,
272,
587,
26,
267,
1056,
847,
11746,
8017,
2458,
17,
14,
18,
70,
2,
450,
334,
8017,
9,
272,
1056,
847,
11746,
827,
63,
85,
29,
16,
6,
988,
63,
85,
29,
1165,
6,
827,
63,
71,
29,
16,
6,
988,
63,
71,
29,
1165,
6,
827,
63,
82,
29,
16,
6,
988,
63,
82,
29,
1165,
6,
827,
63,
73,
29,
16,
6,
988,
63,
73,
29,
1165,
2,
272,
1056,
847,
11746,
827,
63,
90,
29,
16,
6,
988,
63,
90,
29,
1165,
6,
827,
63,
74,
29,
16,
6,
988,
63,
74,
29,
1165,
6,
827,
63,
72,
29,
16,
6,
988,
63,
72,
29,
1165,
6,
827,
63,
75,
29,
16,
6,
988,
63,
75,
29,
1165,
2,
272,
1056,
847,
11746,
908,
29,
4737,
6,
3186,
985,
19167,
3097,
29,
27055,
2,
339,
399,
275,
4011,
14,
1069,
14,
10890,
8,
1069,
9,
272,
1817,
275,
399,
14,
739,
1252,
2708,
1252,
1294,
4582,
78,
531,
272,
2450,
2540,
275,
488,
272,
2450,
50,
281,
324,
275,
488,
272,
2450,
30524,
761,
275,
488,
272,
2450,
792,
275,
488,
272,
2450,
5665,
998,
275,
488,
272,
327,
6668,
314,
17173,
909,
436,
314,
5226,
901,
272,
1748,
12012,
275,
413,
69,
709,
272,
367,
1004,
315,
1817,
26,
267,
327,
3686,
6786,
12,
1406,
436,
14178,
402,
1817,
267,
340,
334,
552,
8,
604,
9,
508,
378,
9,
503,
334,
1397,
1004,
59,
16,
1055,
13896,
5109,
288,
1980,
267,
1559,
6007,
275,
1004,
14,
1294,
11917,
267,
1559,
998,
275,
1109,
8,
1113,
6007,
59,
16,
566,
267,
1255,
275,
1109,
8,
1113,
6007,
59,
17,
566,
267,
295,
1065,
275,
1109,
8,
1113,
6007,
59,
18,
566,
267,
27570,
761,
275,
1109,
8,
1113,
6007,
59,
19,
566,
267,
901,
275,
1109,
8,
1113,
6007,
59,
20,
566,
267,
660,
275,
2069,
8,
1113,
6007,
59,
23,
566,
267,
9700,
275,
2069,
8,
1113,
6007,
59,
24,
566,
267,
2917,
275,
30716,
357,
8,
1113,
2847,
446,
660,
12,
1559,
16387,
446,
9700,
9,
267,
340,
2917,
665,
1748,
12012,
26,
288,
1748,
12012,
275,
2917,
288,
2450,
5665,
998,
275,
1559,
998,
288,
2450,
2540,
275,
1255,
288,
2450,
50,
281,
324,
275,
295,
1065,
288,
2450,
30524,
761,
275,
27570,
761,
288,
2450,
792,
275,
901,
272,
289,
1296,
275,
3842,
2992,
2540,
12,
2450,
50,
281,
324,
12,
2450,
30524,
761,
12,
2450,
792,
1874,
272,
340,
9362,
665,
378,
14,
4587,
26,
267,
372,
289,
1296,
12,
2450,
5665,
998,
272,
587,
26,
267,
367,
1004,
315,
1817,
26,
288,
327,
3686,
6786,
12,
1406,
436,
14178,
402,
1817,
288,
340,
334,
552,
8,
604,
9,
508,
378,
9,
503,
334,
1397,
1004,
59,
16,
1055,
13896,
5109,
355,
1980,
288,
1559,
6007,
275,
1004,
14,
1294,
11917,
288,
1255,
275,
1109,
8,
1113,
6007,
59,
17,
566,
288,
295,
1065,
275,
1109,
8,
1113,
6007,
59,
18,
566,
288,
27570,
761,
275,
1109,
8,
1113,
6007,
59,
19,
566,
288,
901,
275,
1109,
8,
1113,
6007,
59,
20,
566,
288,
340,
334,
1065,
12,
295,
1065,
12,
27570,
761,
12,
901,
9,
440,
315,
289,
1296,
26,
355,
289,
1296,
14,
740,
1332,
1065,
12,
295,
1065,
12,
27570,
761,
12,
901,
430,
272,
372,
289,
1296,
12,
2450,
5665,
998,
421,
199,
318,
29937,
8,
1065,
12,
295,
1065,
12,
27570,
761,
12,
901,
12,
10981,
304,
272,
399,
275,
298,
1014,
921,
5012,
975,
14,
3893,
385,
14,
1308,
15,
22601,
15,
5012,
975,
15,
69,
25020,
15,
13834,
5665,
15,
8444,
6687,
272,
399,
847,
2071,
83,
3149,
73,
3149,
73,
15,
1943,
3295,
83,
3295,
14,
22,
73,
3295,
73,
3295,
14,
20,
73,
14,
14948,
14,
10582,
18,
2,
450,
334,
264,
1065,
12,
1255,
12,
27570,
761,
12,
10981,
12,
10028,
1255,
12,
27570,
761,
12,
901,
9,
272,
372,
399,
421,
199,
318,
511,
6417,
7965,
8,
633,
304,
272,
862,
26,
267,
399,
275,
4011,
14,
1069,
14,
10890,
8,
633,
9,
267,
1233,
275,
399,
14,
600,
267,
3404,
275,
399,
14,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
ohio813/python-registry
|
samples/regview.py
|
5
|
14041
|
#!/usr/bin/python
# This file is part of python-registry.
#
# Copyright 2011 Will Ballenthin <william.ballenthin@mandiant.com>
# while at Mandiant <http://www.mandiant.com>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from __future__ import print_function
from __future__ import unicode_literals
import sys
import os
import wx
from Registry import Registry
ID_FILE_OPEN = wx.NewId()
ID_FILE_SESSION_SAVE = wx.NewId()
ID_FILE_SESSION_OPEN = wx.NewId()
ID_TAB_CLOSE = wx.NewId()
ID_FILE_EXIT = wx.NewId()
ID_HELP_ABOUT = wx.NewId()
def nop(*args, **kwargs):
pass
def basename(path):
if "/" in path:
path = path.split("/")[-1]
if "\\" in path:
path = path.split("\\")[-1]
return path
def _expand_into(dest, src):
vbox = wx.BoxSizer(wx.VERTICAL)
vbox.Add(src, 1, wx.EXPAND | wx.ALL)
dest.SetSizer(vbox)
def _format_hex(data):
"""
see http://code.activestate.com/recipes/142812/
"""
byte_format = {}
for c in xrange(256):
if c > 126:
byte_format[c] = '.'
elif len(repr(chr(c))) == 3 and chr(c):
byte_format[c] = chr(c)
else:
byte_format[c] = '.'
def format_bytes(s):
return "".join([byte_format[ord(c)] for c in s])
def dump(src, length=16):
N = 0
result = ''
while src:
s, src = src[:length], src[length:]
hexa = ' '.join(["%02X" % ord(x) for x in s])
s = format_bytes(s)
result += "%04X %-*s %s\n" % (N, length * 3, hexa, s)
N += length
return result
return dump(data)
class DataPanel(wx.Panel):
"""
Displays the contents of a Registry value.
Shows a text string where appropriate, or a hex dump.
"""
def __init__(self, *args, **kwargs):
super(DataPanel, self).__init__(*args, **kwargs)
self._sizer = wx.BoxSizer(wx.VERTICAL)
self.SetSizer(self._sizer)
def display_value(self, value):
self._sizer.Clear()
data_type = value.value_type()
if data_type == Registry.RegSZ or \
data_type == Registry.RegExpandSZ or \
data_type == Registry.RegDWord or \
data_type == Registry.RegQWord:
view = wx.TextCtrl(self, style=wx.TE_MULTILINE)
view.SetValue(unicode(value.value()))
elif data_type == Registry.RegMultiSZ:
view = wx.ListCtrl(self, style=wx.LC_LIST)
for string in value.value():
view.InsertStringItem(view.GetItemCount(), string)
elif data_type == Registry.RegBin or \
data_type == Registry.RegNone:
view = wx.TextCtrl(self, style=wx.TE_MULTILINE)
font = wx.Font(8, wx.SWISS, wx.NORMAL, wx.NORMAL, False, u'Courier')
view.SetFont(font)
view.SetValue(_format_hex(value.value()))
else:
view = wx.TextCtrl(self, style=wx.TE_MULTILINE)
view.SetValue(unicode(value.value()))
self._sizer.Add(view, 1, wx.EXPAND)
self._sizer.Layout()
def clear_value(self):
self._sizer.Clear()
self._sizer.Add(wx.Panel(self, -1), 1, wx.EXPAND)
self._sizer.Layout()
class ValuesListCtrl(wx.ListCtrl):
"""
Shows a list of values associated with a Registry key.
"""
def __init__(self, *args, **kwargs):
super(ValuesListCtrl, self).__init__(*args, **kwargs)
self.InsertColumn(0, "Value name")
self.InsertColumn(1, "Value type")
self.SetColumnWidth(1, 100)
self.SetColumnWidth(0, 300)
self.values = {}
def clear_values(self):
self.DeleteAllItems()
self.values = {}
def add_value(self, value):
n = self.GetItemCount()
self.InsertStringItem(n, value.name())
self.SetStringItem(n, 1, value.value_type_str())
self.values[value.name()] = value
def get_value(self, valuename):
return self.values[valuename]
class RegistryTreeCtrl(wx.TreeCtrl):
"""
Treeview control that displays the Registry key structure.
"""
def __init__(self, *args, **kwargs):
super(RegistryTreeCtrl, self).__init__(*args, **kwargs)
self.Bind(wx.EVT_TREE_ITEM_EXPANDING, self.OnExpandKey)
def add_registry(self, registry):
"""
Add the registry to the control as the (a?) root element.
"""
root_key = registry.root()
root_item = self.AddRoot(root_key.name())
self.SetPyData(root_item, {"key": root_key,
"has_expanded": False})
if len(root_key.subkeys()) > 0:
self.SetItemHasChildren(root_item)
def delete_registry(self):
"""
Removes all elements from the control.
"""
self.DeleteAllItems()
def select_path(self, path):
"""
Take a Registry key path separated by back slashes and select
that key. The path should not contain the root key name.
If the key is not found, the most specific ancestor key is selected.
"""
parts = path.split("\\")
node = self.GetRootItem()
for part in parts:
self._extend(node)
(node, cookie) = self.GetFirstChild(node)
cont = True
while node and cont:
key = self.GetPyData(node)["key"]
if key.name() == part:
self.SelectItem(node)
cont = False
else:
node = self.GetNextSibling(node)
def _extend(self, item):
"""
Lazily parse and add children items to the tree.
"""
if self.GetPyData(item)["has_expanded"]:
return
key = self.GetPyData(item)["key"]
for subkey in key.subkeys():
subkey_item = self.AppendItem(item, subkey.name())
self.SetPyData(subkey_item, {"key": subkey,
"has_expanded": False})
if len(subkey.subkeys()) > 0:
self.SetItemHasChildren(subkey_item)
self.GetPyData(item)["has_expanded"] = True
def OnExpandKey(self, event):
item = event.GetItem()
if not item.IsOk():
item = self.GetSelection()
if not self.GetPyData(item)["has_expanded"]:
self._extend(item)
class RegistryFileView(wx.Panel):
"""
A three-paned display of the RegistryTreeCtrl, ValueListCtrl, and DataPanel.
"""
def __init__(self, parent, registry, filename):
super(RegistryFileView, self).__init__(parent, -1, size=(800, 600))
self._filename = filename
vsplitter = wx.SplitterWindow(self, -1)
panel_left = wx.Panel(vsplitter, -1)
self._tree = RegistryTreeCtrl(panel_left, -1)
_expand_into(panel_left, self._tree)
hsplitter = wx.SplitterWindow(vsplitter, -1)
panel_top = wx.Panel(hsplitter, -1)
panel_bottom = wx.Panel(hsplitter, -1)
self._value_list_view = ValuesListCtrl(panel_top, -1, style=wx.LC_REPORT)
self._data_view = DataPanel(panel_bottom, -1)
_expand_into(panel_top, self._value_list_view)
_expand_into(panel_bottom, self._data_view)
hsplitter.SplitHorizontally(panel_top, panel_bottom)
vsplitter.SplitVertically(panel_left, hsplitter)
# give enough space in the data display for the hex output
vsplitter.SetSashPosition(325, True)
_expand_into(self, vsplitter)
self.Centre()
self._value_list_view.Bind(wx.EVT_LIST_ITEM_SELECTED, self.OnValueSelected)
self._tree.Bind(wx.EVT_TREE_SEL_CHANGED, self.OnKeySelected)
self._tree.add_registry(registry)
def OnKeySelected(self, event):
item = event.GetItem()
if not item.IsOk():
item = self._tree.GetSelection()
key = self._tree.GetPyData(item)["key"]
parent = self.GetParent()
while parent:
try:
parent.SetStatusText(key.path())
except AttributeError:
pass
parent = parent.GetParent()
self._data_view.clear_value()
self._value_list_view.clear_values()
for value in key.values():
self._value_list_view.add_value(value)
def OnValueSelected(self, event):
item = event.GetItem()
value = self._value_list_view.get_value(item.GetText())
self._data_view.display_value(value)
def filename(self):
"""
Return the filename of the current Registry file as a string.
"""
return self._filename
def selected_path(self):
"""
Return the Registry key path of the currently selected item.
"""
item = self._tree.GetSelection()
if item:
return self._tree.GetPyData(item)["key"].path()
return False
def select_path(self, path):
"""
Select a Registry key path specified as a string in the relevant panes.
"""
self._tree.select_path(path)
class RegistryFileViewer(wx.Frame):
"""
The main RegView GUI application.
"""
def __init__(self, parent, files):
super(RegistryFileViewer, self).__init__(parent, -1, "Registry File Viewer", size=(800, 600))
self.CreateStatusBar()
menu_bar = wx.MenuBar()
file_menu = wx.Menu()
_open = file_menu.Append(ID_FILE_OPEN, '&Open File')
self.Bind(wx.EVT_MENU, self.menu_file_open, _open)
file_menu.AppendSeparator()
_session_save = file_menu.Append(ID_FILE_SESSION_SAVE, '&Save Session')
self.Bind(wx.EVT_MENU, self.menu_file_session_save, _session_save)
_session_open = file_menu.Append(ID_FILE_SESSION_OPEN, '&Open Session')
self.Bind(wx.EVT_MENU, self.menu_file_session_open, _session_open)
file_menu.AppendSeparator()
_exit = file_menu.Append(ID_FILE_EXIT, 'E&xit Program')
self.Bind(wx.EVT_MENU, self.menu_file_exit, _exit)
menu_bar.Append(file_menu, "&File")
tab_menu = wx.Menu()
_close = tab_menu.Append(ID_TAB_CLOSE, '&Close')
self.Bind(wx.EVT_MENU, self.menu_tab_close, _close)
menu_bar.Append(tab_menu, "&Tab")
help_menu = wx.Menu()
_about = help_menu.Append(ID_HELP_ABOUT, '&About')
self.Bind(wx.EVT_MENU, self.menu_help_about, _about)
menu_bar.Append(help_menu, "&Help")
self.SetMenuBar(menu_bar)
p = wx.Panel(self)
self._nb = wx.Notebook(p)
for filename in files:
self._open_registry_file(filename)
sizer = wx.BoxSizer(wx.VERTICAL)
sizer.Add(self._nb, 1, wx.EXPAND)
p.SetSizer(sizer)
self.Layout()
def _open_registry_file(self, filename):
"""
Open a Registry file by filename into a new tab and return the window.
"""
with open(filename, "rb") as f:
registry = Registry.Registry(f)
view = RegistryFileView(self._nb, registry=registry, filename=filename)
self._nb.AddPage(view, basename(filename))
return view
# TODO handle error
def menu_file_open(self, evt):
dialog = wx.FileDialog(None, "Choose Registry File", "", "", "*", wx.OPEN)
if dialog.ShowModal() != wx.ID_OK:
return
filename = os.path.join(dialog.GetDirectory(), dialog.GetFilename())
self._open_registry_file(filename)
def menu_file_exit(self, evt):
sys.exit(0)
def menu_file_session_open(self, evt):
self._nb.DeleteAllPages()
dialog = wx.FileDialog(None, "Open Session File", "", "", "*", wx.OPEN)
if dialog.ShowModal() != wx.ID_OK:
return
filename = os.path.join(dialog.GetDirectory(), dialog.GetFilename())
with open(filename, "rb") as f:
t = f.read()
lines = t.split("\n")
if len(lines) % 2 != 1: # there is a trailing newline
self.SetStatusText("Malformed session file!")
return
while len(lines) > 1:
filename = lines.pop(0)
path = lines.pop(0)
view = self._open_registry_file(filename)
view.select_path(path.partition("\\")[2])
self.SetStatusText("Opened session")
def menu_file_session_save(self, evt):
dialog = wx.FileDialog(None, "Save Session File", "", "", "*", wx.SAVE)
if dialog.ShowModal() != wx.ID_OK:
return
filename = os.path.join(dialog.GetDirectory(), dialog.GetFilename())
with open(filename, "wb") as f:
for i in range(0, self._nb.GetPageCount()):
page = self._nb.GetPage(i)
f.write(page.filename() + "\n")
path = page.selected_path()
if path:
f.write(path)
f.write("\n")
self.SetStatusText("Saved session")
# TODO handle error
def menu_tab_close(self, evt):
self._nb.RemovePage(self._nb.GetSelection())
def menu_help_about(self, evt):
wx.MessageBox("regview.py, a part of `python-registry`\n\nhttp://www.williballenthin.com/registry/", "info")
if __name__ == '__main__':
app = wx.App(False)
filenames = []
filenames = sys.argv[1:]
frame = RegistryFileViewer(None, filenames)
frame.Show()
app.MainLoop()
|
apache-2.0
|
[
3381,
2647,
15,
1393,
15,
1548,
199,
199,
3,
259,
961,
570,
365,
1777,
402,
2366,
13,
5189,
14,
199,
3,
199,
3,
257,
1898,
7760,
12823,
699,
7670,
24474,
665,
87,
8148,
455,
14,
4982,
552,
24474,
32,
1237,
328,
867,
14,
957,
30,
199,
3,
8540,
1830,
737,
4688,
328,
867,
665,
1014,
921,
1544,
14,
1237,
328,
867,
14,
957,
30,
199,
3,
199,
3,
257,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
199,
3,
257,
1265,
1443,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
199,
3,
257,
2047,
1443,
3332,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
755,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
257,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
257,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
199,
3,
257,
2428,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
199,
3,
257,
1666,
314,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
199,
3,
257,
4204,
1334,
314,
844,
14,
199,
504,
636,
2443,
363,
492,
870,
63,
1593,
199,
504,
636,
2443,
363,
492,
2649,
63,
5955,
199,
199,
646,
984,
199,
646,
747,
199,
646,
4818,
199,
504,
20738,
492,
20738,
199,
199,
998,
63,
3817,
63,
9935,
275,
4818,
14,
4665,
1304,
342,
199,
998,
63,
3817,
63,
12763,
63,
19318,
275,
4818,
14,
4665,
1304,
342,
199,
998,
63,
3817,
63,
12763,
63,
9935,
275,
4818,
14,
4665,
1304,
342,
199,
998,
63,
10129,
63,
18219,
275,
4818,
14,
4665,
1304,
342,
199,
998,
63,
3817,
63,
17219,
275,
4818,
14,
4665,
1304,
342,
199,
998,
63,
17930,
63,
1217,
1877,
275,
4818,
14,
4665,
1304,
342,
421,
199,
318,
302,
411,
2031,
589,
12,
1011,
958,
304,
272,
986,
421,
199,
318,
9593,
8,
515,
304,
272,
340,
10609,
315,
931,
26,
267,
931,
275,
931,
14,
1294,
19031,
1988,
17,
61,
272,
340,
9926,
2,
315,
931,
26,
267,
931,
275,
931,
14,
1294,
23236,
531,
1988,
17,
61,
272,
372,
931,
421,
199,
318,
485,
4441,
63,
9924,
8,
2614,
12,
2928,
304,
272,
20163,
275,
4818,
14,
28072,
8,
6323,
14,
22634,
9,
272,
20163,
14,
1123,
8,
2164,
12,
413,
12,
4818,
14,
20612,
1204,
4818,
14,
1761,
9,
272,
2053,
14,
1084,
12017,
8,
19508,
9,
421,
199,
318,
485,
908,
63,
4097,
8,
576,
304,
272,
408,
272,
1937,
1455,
921,
600,
14,
32595,
14,
957,
15,
25200,
15,
1079,
1651,
713,
15,
272,
408,
272,
3696,
63,
908,
275,
1052,
272,
367,
286,
315,
4945,
8,
3912,
304,
267,
340,
286,
690,
21572,
26,
288,
3696,
63,
908,
59,
67,
61,
275,
7815,
267,
916,
822,
8,
2722,
8,
10194,
8,
67,
1724,
508,
650,
436,
8678,
8,
67,
304,
288,
3696,
63,
908,
59,
67,
61,
275,
8678,
8,
67,
9,
267,
587,
26,
288,
3696,
63,
908,
59,
67,
61,
275,
7815,
339,
347,
1475,
63,
2394,
8,
83,
304,
267,
372,
10587,
904,
779,
4414,
63,
908,
59,
2181,
8,
67,
1874,
367,
286,
315,
308,
566,
339,
347,
5461,
8,
2164,
12,
2582,
29,
975,
304,
267,
653,
275,
378,
267,
754,
275,
2125,
267,
1830,
2928,
26,
288,
308,
12,
2928,
275,
2928,
1491,
1267,
467,
2928,
59,
1267,
2938,
288,
6318,
65,
275,
283,
1987,
904,
30387,
996,
56,
2,
450,
6206,
8,
88,
9,
367,
671,
315,
308,
566,
288,
308,
275,
1475,
63,
2394,
8,
83,
9,
288,
754,
847,
2071,
966,
56,
257,
19752,
10,
83,
257,
450,
83,
60,
78,
2,
450,
334,
46,
12,
2582,
627,
650,
12,
6318,
65,
12,
308,
9,
288,
653,
847,
2582,
267,
372,
754,
272,
372,
5461,
8,
576,
9,
421,
199,
533,
3918,
10185,
8,
6323,
14,
10185,
304,
272,
408,
272,
28750,
314,
4072,
402,
282,
20738,
574,
14,
272,
12968,
83,
282,
1318,
1059,
2382,
5827,
12,
503,
282,
6318,
5461,
14,
272,
408,
272,
347,
636,
826,
721,
277,
12,
627,
589,
12,
1011,
958,
304,
267,
1613,
8,
1451,
10185,
12,
291,
2843,
826,
9308,
589,
12,
1011,
958,
9,
267,
291,
423,
19158,
275,
4818,
14,
28072,
8,
6323,
14,
22634,
9,
267,
291,
14,
1084,
12017,
8,
277,
423,
19158,
9,
339,
347,
2929,
63,
585,
8,
277,
12,
574,
304,
267,
291,
423,
19158,
14,
9721,
342,
267,
666,
63,
466,
275,
574,
14,
585,
63,
466,
342,
398,
340,
666,
63,
466,
508,
20738,
14,
2872,
18101,
503,
971,
355,
666,
63,
466,
508,
20738,
14,
2872,
12839,
18101,
503,
971,
355,
666,
63,
466,
508,
20738,
14,
2872,
36,
10155,
503,
971,
355,
666,
63,
466,
508,
20738,
14,
2872,
49,
10155,
26,
288,
2455,
275,
4818,
14,
1872,
9778,
8,
277,
12,
3449,
29,
6323,
14,
3727,
63,
16661,
9,
288,
2455,
14,
21322,
8,
2975,
8,
585,
14,
585,
4059,
398,
916,
666,
63,
466,
508,
20738,
14,
2872,
3947,
18101,
26,
288,
2455,
275,
4818,
14,
1296,
9778,
8,
277,
12,
3449,
29,
6323,
14,
7027,
63,
4924,
9,
288,
367,
1059,
315,
574,
14,
585,
837,
355,
2455,
14,
9971,
1558,
2081,
8,
1345,
14,
32474,
2353,
1062,
1059,
9,
398,
916,
666,
63,
466,
508,
20738,
14,
2872,
13394,
503,
971,
355,
666,
63,
466,
508,
20738,
14,
2872,
403,
26,
288,
2455,
275,
4818,
14,
1872,
9778,
8,
277,
12,
3449,
29,
6323,
14,
3727,
63,
16661,
9,
288,
5023,
275,
4818,
14,
6986,
8,
24,
12,
4818,
14,
8745,
1311,
51,
12,
4818,
14,
10765,
12,
4818,
14,
10765,
12,
756,
12,
399,
7,
35,
567,
4446,
358,
288,
2455,
14,
1084,
6986,
8,
4246,
9,
288,
2455,
14,
21322,
1547,
908,
63,
4097,
8,
585,
14,
585,
4059,
398,
587,
26,
288,
2455,
275,
4818,
14,
1872,
9778,
8,
277,
12,
3449,
29,
6323,
14,
3727,
63,
16661,
9,
288,
2455,
14,
21322,
8,
2975,
8,
585,
14,
585,
4059,
398,
291,
423,
19158
] |
[
2647,
15,
1393,
15,
1548,
199,
199,
3,
259,
961,
570,
365,
1777,
402,
2366,
13,
5189,
14,
199,
3,
199,
3,
257,
1898,
7760,
12823,
699,
7670,
24474,
665,
87,
8148,
455,
14,
4982,
552,
24474,
32,
1237,
328,
867,
14,
957,
30,
199,
3,
8540,
1830,
737,
4688,
328,
867,
665,
1014,
921,
1544,
14,
1237,
328,
867,
14,
957,
30,
199,
3,
199,
3,
257,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
199,
3,
257,
1265,
1443,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
199,
3,
257,
2047,
1443,
3332,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
755,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
257,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
257,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
199,
3,
257,
2428,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
199,
3,
257,
1666,
314,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
199,
3,
257,
4204,
1334,
314,
844,
14,
199,
504,
636,
2443,
363,
492,
870,
63,
1593,
199,
504,
636,
2443,
363,
492,
2649,
63,
5955,
199,
199,
646,
984,
199,
646,
747,
199,
646,
4818,
199,
504,
20738,
492,
20738,
199,
199,
998,
63,
3817,
63,
9935,
275,
4818,
14,
4665,
1304,
342,
199,
998,
63,
3817,
63,
12763,
63,
19318,
275,
4818,
14,
4665,
1304,
342,
199,
998,
63,
3817,
63,
12763,
63,
9935,
275,
4818,
14,
4665,
1304,
342,
199,
998,
63,
10129,
63,
18219,
275,
4818,
14,
4665,
1304,
342,
199,
998,
63,
3817,
63,
17219,
275,
4818,
14,
4665,
1304,
342,
199,
998,
63,
17930,
63,
1217,
1877,
275,
4818,
14,
4665,
1304,
342,
421,
199,
318,
302,
411,
2031,
589,
12,
1011,
958,
304,
272,
986,
421,
199,
318,
9593,
8,
515,
304,
272,
340,
10609,
315,
931,
26,
267,
931,
275,
931,
14,
1294,
19031,
1988,
17,
61,
272,
340,
9926,
2,
315,
931,
26,
267,
931,
275,
931,
14,
1294,
23236,
531,
1988,
17,
61,
272,
372,
931,
421,
199,
318,
485,
4441,
63,
9924,
8,
2614,
12,
2928,
304,
272,
20163,
275,
4818,
14,
28072,
8,
6323,
14,
22634,
9,
272,
20163,
14,
1123,
8,
2164,
12,
413,
12,
4818,
14,
20612,
1204,
4818,
14,
1761,
9,
272,
2053,
14,
1084,
12017,
8,
19508,
9,
421,
199,
318,
485,
908,
63,
4097,
8,
576,
304,
272,
408,
272,
1937,
1455,
921,
600,
14,
32595,
14,
957,
15,
25200,
15,
1079,
1651,
713,
15,
272,
408,
272,
3696,
63,
908,
275,
1052,
272,
367,
286,
315,
4945,
8,
3912,
304,
267,
340,
286,
690,
21572,
26,
288,
3696,
63,
908,
59,
67,
61,
275,
7815,
267,
916,
822,
8,
2722,
8,
10194,
8,
67,
1724,
508,
650,
436,
8678,
8,
67,
304,
288,
3696,
63,
908,
59,
67,
61,
275,
8678,
8,
67,
9,
267,
587,
26,
288,
3696,
63,
908,
59,
67,
61,
275,
7815,
339,
347,
1475,
63,
2394,
8,
83,
304,
267,
372,
10587,
904,
779,
4414,
63,
908,
59,
2181,
8,
67,
1874,
367,
286,
315,
308,
566,
339,
347,
5461,
8,
2164,
12,
2582,
29,
975,
304,
267,
653,
275,
378,
267,
754,
275,
2125,
267,
1830,
2928,
26,
288,
308,
12,
2928,
275,
2928,
1491,
1267,
467,
2928,
59,
1267,
2938,
288,
6318,
65,
275,
283,
1987,
904,
30387,
996,
56,
2,
450,
6206,
8,
88,
9,
367,
671,
315,
308,
566,
288,
308,
275,
1475,
63,
2394,
8,
83,
9,
288,
754,
847,
2071,
966,
56,
257,
19752,
10,
83,
257,
450,
83,
60,
78,
2,
450,
334,
46,
12,
2582,
627,
650,
12,
6318,
65,
12,
308,
9,
288,
653,
847,
2582,
267,
372,
754,
272,
372,
5461,
8,
576,
9,
421,
199,
533,
3918,
10185,
8,
6323,
14,
10185,
304,
272,
408,
272,
28750,
314,
4072,
402,
282,
20738,
574,
14,
272,
12968,
83,
282,
1318,
1059,
2382,
5827,
12,
503,
282,
6318,
5461,
14,
272,
408,
272,
347,
636,
826,
721,
277,
12,
627,
589,
12,
1011,
958,
304,
267,
1613,
8,
1451,
10185,
12,
291,
2843,
826,
9308,
589,
12,
1011,
958,
9,
267,
291,
423,
19158,
275,
4818,
14,
28072,
8,
6323,
14,
22634,
9,
267,
291,
14,
1084,
12017,
8,
277,
423,
19158,
9,
339,
347,
2929,
63,
585,
8,
277,
12,
574,
304,
267,
291,
423,
19158,
14,
9721,
342,
267,
666,
63,
466,
275,
574,
14,
585,
63,
466,
342,
398,
340,
666,
63,
466,
508,
20738,
14,
2872,
18101,
503,
971,
355,
666,
63,
466,
508,
20738,
14,
2872,
12839,
18101,
503,
971,
355,
666,
63,
466,
508,
20738,
14,
2872,
36,
10155,
503,
971,
355,
666,
63,
466,
508,
20738,
14,
2872,
49,
10155,
26,
288,
2455,
275,
4818,
14,
1872,
9778,
8,
277,
12,
3449,
29,
6323,
14,
3727,
63,
16661,
9,
288,
2455,
14,
21322,
8,
2975,
8,
585,
14,
585,
4059,
398,
916,
666,
63,
466,
508,
20738,
14,
2872,
3947,
18101,
26,
288,
2455,
275,
4818,
14,
1296,
9778,
8,
277,
12,
3449,
29,
6323,
14,
7027,
63,
4924,
9,
288,
367,
1059,
315,
574,
14,
585,
837,
355,
2455,
14,
9971,
1558,
2081,
8,
1345,
14,
32474,
2353,
1062,
1059,
9,
398,
916,
666,
63,
466,
508,
20738,
14,
2872,
13394,
503,
971,
355,
666,
63,
466,
508,
20738,
14,
2872,
403,
26,
288,
2455,
275,
4818,
14,
1872,
9778,
8,
277,
12,
3449,
29,
6323,
14,
3727,
63,
16661,
9,
288,
5023,
275,
4818,
14,
6986,
8,
24,
12,
4818,
14,
8745,
1311,
51,
12,
4818,
14,
10765,
12,
4818,
14,
10765,
12,
756,
12,
399,
7,
35,
567,
4446,
358,
288,
2455,
14,
1084,
6986,
8,
4246,
9,
288,
2455,
14,
21322,
1547,
908,
63,
4097,
8,
585,
14,
585,
4059,
398,
587,
26,
288,
2455,
275,
4818,
14,
1872,
9778,
8,
277,
12,
3449,
29,
6323,
14,
3727,
63,
16661,
9,
288,
2455,
14,
21322,
8,
2975,
8,
585,
14,
585,
4059,
398,
291,
423,
19158,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
egraba/vbox_openbsd
|
VirtualBox-5.0.0/src/VBox/ValidationKit/testmanager/webui/wuibase.py
|
2
|
40904
|
# -*- coding: utf-8 -*-
# $Id: wuibase.py $
"""
Test Manager Web-UI - Base Classes.
"""
__copyright__ = \
"""
Copyright (C) 2012-2015 Oracle Corporation
This file is part of VirtualBox Open Source Edition (OSE), as
available from http://www.virtualbox.org. This file is free software;
you can redistribute it and/or modify it under the terms of the GNU
General Public License (GPL) as published by the Free Software
Foundation, in version 2 as it comes in the "COPYING" file of the
VirtualBox OSE distribution. VirtualBox OSE is distributed in the
hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
The contents of this file may alternatively be used under the terms
of the Common Development and Distribution License Version 1.0
(CDDL) only, as it comes in the "COPYING.CDDL" file of the
VirtualBox OSE distribution, in which case the provisions of the
CDDL are applicable instead of those of the GPL.
You may elect to license modified versions of this file under the
terms and conditions of either the GPL or the CDDL or both.
"""
__version__ = "$Revision: 100880 $"
# Standard python imports.
import os;
# Validation Kit imports.
from common import webutils, utils;
from testmanager import config;
from testmanager.core.base import ModelDataBase, TMExceptionBase;
from testmanager.core.db import TMDatabaseConnection;
from testmanager.core.systemlog import SystemLogLogic, SystemLogData;
from testmanager.core.useraccount import UserAccountLogic
class WuiException(TMExceptionBase):
"""
For exceptions raised by Web UI code.
"""
pass;
class WuiDispatcherBase(object):
"""
Base class for the Web User Interface (WUI) dispatchers.
The dispatcher class defines the basics of the page (like base template,
menu items, action). It is also responsible for parsing requests and
dispatching them to action (POST) or/and content generators (GET+POST).
The content returned by the generator is merged into the template and sent
back to the webserver glue.
"""
## @todo possible that this should all go into presentation.
## The action parameter.
ksParamAction = 'Action';
## The name of the default action.
ksActionDefault = 'default';
## The name of the current page number parameter used when displaying lists.
ksParamPageNo = 'PageNo';
## The name of the page length (list items) parameter when displaying lists.
ksParamItemsPerPage = 'ItemsPerPage';
## The name of the effective date (timestamp) parameter.
ksParamEffectiveDate = 'EffectiveDate';
## The name of the list-action parameter (WuiListContentWithActionBase).
ksParamListAction = 'ListAction';
## The name of the change log enabled/disabled parameter.
ksParamChangeLogEnabled = 'ChangeLogEnabled';
## The name of the parmaeter indicating the change log page number.
ksParamChangeLogPageNo = 'ChangeLogPageNo';
## The name of the parameter indicate number of change log entries per page.
ksParamChangeLogEntriesPerPage = 'ChangeLogEntriesPerPage';
## @name Dispatcher debugging parameters.
## {@
ksParamDbgSqlTrace = 'DbgSqlTrace';
ksParamDbgSqlExplain = 'DbgSqlExplain';
## List of all debugging parameters.
kasDbgParams = (ksParamDbgSqlTrace, ksParamDbgSqlExplain,);
## @}
## Special action return code for skipping _generatePage. Useful for
# download pages and the like that messes with the HTTP header and more.
ksDispatchRcAllDone = 'Done - Page has been rendered already';
def __init__(self, oSrvGlue, sScriptName):
self._oSrvGlue = oSrvGlue;
self._oDb = TMDatabaseConnection(self.dprint if config.g_kfWebUiSqlDebug else None, oSrvGlue = oSrvGlue);
self._asCheckedParams = [];
self._dParams = None; # Set by dispatchRequest.
self._sAction = None; # Set by dispatchRequest.
self._dDispatch = { self.ksActionDefault: self._actionDefault, };
# Template bits.
self._sTemplate = 'template-default.html';
self._sPageTitle = '$$TODO$$'; # The page title.
self._aaoMenus = []; # List of [sName, sLink, [ [sSideName, sLink], .. ] tuples.
self._sPageBody = '$$TODO$$'; # The body text.
self._sRedirectTo = None;
self._sDebug = '';
# Debugger bits.
self._fDbgSqlTrace = False;
self._fDbgSqlExplain = False;
self._dDbgParams = dict();
for sKey, sValue in oSrvGlue.getParameters().iteritems():
if sKey in self.kasDbgParams:
self._dDbgParams[sKey] = sValue;
if len(self._dDbgParams) > 0:
from testmanager.webui.wuicontentbase import WuiTmLink;
WuiTmLink.kdDbgParams = self._dDbgParams;
# Determine currently logged in user credentials
self._oCurUser = UserAccountLogic(self._oDb).tryFetchAccountByLoginName(oSrvGlue.getLoginName());
# Calc a couple of URL base strings for this dispatcher.
self._sUrlBase = sScriptName + '?';
if len(self._dDbgParams) > 0:
self._sUrlBase += webutils.encodeUrlParams(self._dDbgParams) + '&';
self._sActionUrlBase = self._sUrlBase + self.ksParamAction + '=';
def _redirectPage(self):
"""
Redirects the page to the URL given in self._sRedirectTo.
"""
assert self._sRedirectTo is not None;
assert len(self._sRedirectTo) > 0;
assert self._sPageBody is None;
assert self._sPageTitle is None;
self._oSrvGlue.setRedirect(self._sRedirectTo);
return True;
def _generateMenus(self):
"""
Generates the two menus, returning them as (sTopMenuItems, sSideMenuItems).
"""
#
# We use the action to locate the side menu.
#
aasSideMenu = None;
for cchAction in range(len(self._sAction), 1, -1):
sActionParam = '%s=%s' % (self.ksParamAction, self._sAction[:cchAction]);
for aoItem in self._aaoMenus:
if aoItem[1].find(sActionParam) > 0:
aasSideMenu = aoItem[2];
break;
for asSubItem in aoItem[2]:
if asSubItem[1].find(sActionParam) > 0:
aasSideMenu = aoItem[2];
break;
if aasSideMenu is not None:
break;
#
# Top menu first.
#
sTopMenuItems = '';
for aoItem in self._aaoMenus:
if aasSideMenu is aoItem[2]:
sTopMenuItems += '<li class="current_page_item">';
else:
sTopMenuItems += '<li>';
sTopMenuItems += '<a href="' + webutils.escapeAttr(aoItem[1]) + '">' \
+ webutils.escapeElem(aoItem[0]) + '</a></li>\n';
#
# Side menu (if found).
#
sActionParam = '%s=%s' % (self.ksParamAction, self._sAction);
sSideMenuItems = '';
if aasSideMenu is not None:
for asSubItem in aasSideMenu:
if asSubItem[1].find(sActionParam) > 0:
sSideMenuItems += '<li class="current_page_item">';
else:
sSideMenuItems += '<li>';
sSideMenuItems += '<a href="' + webutils.escapeAttr(asSubItem[1]) + '">' \
+ webutils.escapeElem(asSubItem[0]) + '</a></li>\n';
return (sTopMenuItems, sSideMenuItems);
def _generatePage(self):
"""
Generates the page using _sTemplate, _sPageTitle, _aaoMenus, and _sPageBody.
"""
assert self._sRedirectTo is None;
# Load the template.
oFile = open(os.path.join(self._oSrvGlue.pathTmWebUI(), self._sTemplate));
sTmpl = oFile.read();
oFile.close();
# Do replacements.
sTmpl = sTmpl.replace('@@PAGE_TITLE@@', self._sPageTitle);
sTmpl = sTmpl.replace('@@PAGE_BODY@@', self._sPageBody);
if self._oCurUser is not None:
sTmpl = sTmpl.replace('@@USER_NAME@@', self._oCurUser.sUsername);
else:
sTmpl = sTmpl.replace('@@USER_NAME@@', 'unauthorized user "' + self._oSrvGlue.getLoginName() + '"');
sTmpl = sTmpl.replace('@@TESTMANAGER_VERSION@@', config.g_ksVersion);
sTmpl = sTmpl.replace('@@TESTMANAGER_REVISION@@', config.g_ksRevision);
sTmpl = sTmpl.replace('@@BASE_URL@@', self._oSrvGlue.getBaseUrl());
(sTopMenuItems, sSideMenuItems) = self._generateMenus();
sTmpl = sTmpl.replace('@@TOP_MENU_ITEMS@@', sTopMenuItems);
sTmpl = sTmpl.replace('@@SIDE_MENU_ITEMS@@', sSideMenuItems);
# Provide basic auth log out for browsers that supports it.
sUserAgent = self._oSrvGlue.getUserAgent();
if (sUserAgent.startswith('Mozilla/') and sUserAgent.find('Firefox') > 0) \
or False:
# Log in as the logout user in the same realm, the browser forgets
# the old login and the job is done. (see apache sample conf)
sLogOut = ' (<a href="%s://logout:logout@%s%slogout.py">logout</a>)' \
% (self._oSrvGlue.getUrlScheme(), self._oSrvGlue.getUrlNetLoc(), self._oSrvGlue.getUrlBasePath());
elif (sUserAgent.startswith('Mozilla/') and sUserAgent.find('Safari') > 0) \
or False:
# For a 401, causing the browser to forget the old login. Works
# with safari as well as the two above. Since safari consider the
# above method a phishing attempt and displays a warning to that
# effect, which when taken seriously aborts the logout, this method
# is preferable, even if it throws logon boxes in the user's face
# till he/she/it hits escape, because it always works.
sLogOut = ' (<a href="logout2.py">logout</a>)'
elif (sUserAgent.startswith('Mozilla/') and sUserAgent.find('MSIE') > 0) \
or (sUserAgent.startswith('Mozilla/') and sUserAgent.find('Chrome') > 0) \
or False:
## There doesn't seem to be any way to make IE really log out
# without using a cookie and systematically 401 accesses based on
# some logout state associated with it. Not sure how secure that
# can be made and we really want to avoid cookies. So, perhaps,
# just avoid IE for now. :-)
## Chrome/21.0 doesn't want to log out either.
sLogOut = ''
else:
sLogOut = ''
sTmpl = sTmpl.replace('@@LOG_OUT@@', sLogOut)
# Debug section.
if self._sDebug == '':
if config.g_kfWebUiSqlTrace or self._fDbgSqlTrace or self._fDbgSqlExplain:
self._sDebug = '<h3>Processed in %s ns.</h3>\n%s\n' \
% ( utils.formatNumber(utils.timestampNano() - self._oSrvGlue.tsStart,),
self._oDb.debugHtmlReport(self._oSrvGlue.tsStart));
elif config.g_kfWebUiProcessedIn:
self._sDebug = '<h3>Processed in %s ns.</h3>\n' \
% ( utils.formatNumber(utils.timestampNano() - self._oSrvGlue.tsStart,), );
if config.g_kfWebUiDebugPanel:
self._sDebug += self._debugRenderPanel();
if self._sDebug != '':
sTmpl = sTmpl.replace('@@DEBUG@@', '<div id="debug"><br><br><hr/>' + \
unicode(self._sDebug, errors='ignore') if isinstance(self._sDebug, str) else self._sDebug + '</div>');
else:
sTmpl = sTmpl.replace('@@DEBUG@@', '');
# Output the result.
self._oSrvGlue.write(sTmpl);
return True;
#
# Interface for WuiContentBase classes.
#
def getParameters(self):
"""
Returns a (shallow) copy of the request parameter dictionary.
"""
return self._dParams.copy();
def getDb(self):
"""
Returns the database connection.
"""
return self._oDb;
#
# Parameter handling.
#
def getStringParam(self, sName, asValidValues = None, sDefault = None):
"""
Gets a string parameter.
Raises exception if not found and sDefault is None.
"""
if sName in self._dParams:
if sName not in self._asCheckedParams:
self._asCheckedParams.append(sName);
sValue = self._dParams[sName];
if isinstance(sValue, list):
raise WuiException('%s parameter "%s" is given multiple times: "%s"' % (self._sAction, sName, sValue));
sValue = sValue.strip();
elif sDefault is None:
raise WuiException('%s is missing parameters: "%s"' % (self._sAction, sName,));
else:
sValue = sDefault;
if asValidValues is not None and sValue not in asValidValues:
raise WuiException('%s parameter %s value "%s" not in %s '
% (self._sAction, sName, sValue, asValidValues));
return sValue;
def getBoolParam(self, sName, fDefault = None):
"""
Gets a boolean parameter.
Raises exception if not found and fDefault is None, or if not a valid boolean.
"""
sValue = self.getStringParam(sName, [ 'True', 'true', '1', 'False', 'false', '0'],
'0' if fDefault is None else str(fDefault));
# HACK: Checkboxes doesn't return a value when unchecked, so we always
# provide a default when dealing with boolean parameters.
return sValue == 'True' or sValue == 'true' or sValue == '1';
def getIntParam(self, sName, iMin = None, iMax = None, iDefault = None):
"""
Gets a integer parameter.
Raises exception if not found and iDefault is None, if not a valid int,
or if outside the range defined by iMin and iMax.
"""
if iDefault is not None and sName not in self._dParams:
return iDefault;
sValue = self.getStringParam(sName, None, None if iDefault is None else str(iDefault));
try:
iValue = int(sValue);
except:
raise WuiException('%s parameter %s value "%s" cannot be convert to an integer'
% (self._sAction, sName, sValue));
if (iMin is not None and iValue < iMin) \
or (iMax is not None and iValue > iMax):
raise WuiException('%s parameter %s value %d is out of range [%s..%s]'
% (self._sAction, sName, iValue, iMin, iMax));
return iValue;
def getLongParam(self, sName, lMin = None, lMax = None, lDefault = None):
"""
Gets a long integer parameter.
Raises exception if not found and lDefault is None, if not a valid long,
or if outside the range defined by lMin and lMax.
"""
if lDefault is not None and sName not in self._dParams:
return lDefault;
sValue = self.getStringParam(sName, None, None if lDefault is None else str(lDefault));
try:
lValue = long(sValue);
except:
raise WuiException('%s parameter %s value "%s" cannot be convert to an integer'
% (self._sAction, sName, sValue));
if (lMin is not None and lValue < lMin) \
or (lMax is not None and lValue > lMax):
raise WuiException('%s parameter %s value %d is out of range [%s..%s]'
% (self._sAction, sName, lValue, lMin, lMax));
return lValue;
def getTsParam(self, sName, tsDefault = None, fRequired = True):
"""
Gets a timestamp parameter.
Raises exception if not found and fRequired is True.
"""
if fRequired is False and sName not in self._dParams:
return tsDefault;
sValue = self.getStringParam(sName, None, None if tsDefault is None else str(tsDefault));
(sValue, sError) = ModelDataBase.validateTs(sValue);
if sError is not None:
raise WuiException('%s parameter %s value "%s": %s'
% (self._sAction, sName, sValue, sError));
return sValue;
def getListOfIntParams(self, sName, iMin = None, iMax = None, aiDefaults = None):
"""
Gets parameter list.
Raises exception if not found and aiDefaults is None, or if any of the
values are not valid integers or outside the range defined by iMin and iMax.
"""
if sName in self._dParams:
if sName not in self._asCheckedParams:
self._asCheckedParams.append(sName);
if isinstance(self._dParams[sName], list):
asValues = self._dParams[sName];
else:
asValues = [self._dParams[sName],];
aiValues = [];
for sValue in asValues:
try:
iValue = int(sValue);
except:
raise WuiException('%s parameter %s value "%s" cannot be convert to an integer'
% (self._sAction, sName, sValue));
if (iMin is not None and iValue < iMin) \
or (iMax is not None and iValue > iMax):
raise WuiException('%s parameter %s value %d is out of range [%s..%s]'
% (self._sAction, sName, iValue, iMin, iMax));
aiValues.append(iValue);
else:
aiValues = aiDefaults;
return aiValues;
def getListOfStrParams(self, sName, asDefaults = None):
"""
Gets parameter list.
Raises exception if not found and asDefaults is None.
"""
if sName in self._dParams:
if sName not in self._asCheckedParams:
self._asCheckedParams.append(sName);
if isinstance(self._dParams[sName], list):
asValues = [str(s).strip() for s in self._dParams[sName]];
else:
asValues = [str(self._dParams[sName]).strip(), ];
elif asDefaults is None:
raise WuiException('%s is missing parameters: "%s"' % (self._sAction, sName,));
else:
asValues = asDefaults;
return asValues;
def getListOfTestCasesParam(self, sName, asDefaults = None): # too many local vars - pylint: disable=R0914
"""Get list of test cases and their parameters"""
if sName in self._dParams:
if sName not in self._asCheckedParams:
self._asCheckedParams.append(sName)
aoListOfTestCases = []
aiSelectedTestCaseIds = self.getListOfIntParams('%s[asCheckedTestCases]' % sName, aiDefaults=[])
aiAllTestCases = self.getListOfIntParams('%s[asAllTestCases]' % sName, aiDefaults=[])
for idTestCase in aiAllTestCases:
aiCheckedTestCaseArgs = \
self.getListOfIntParams(
'%s[%d][asCheckedTestCaseArgs]' % (sName, idTestCase),
aiDefaults=[])
aiAllTestCaseArgs = \
self.getListOfIntParams(
'%s[%d][asAllTestCaseArgs]' % (sName, idTestCase),
aiDefaults=[])
oListEntryTestCaseArgs = []
for idTestCaseArgs in aiAllTestCaseArgs:
fArgsChecked = True if idTestCaseArgs in aiCheckedTestCaseArgs else False
# Dry run
sPrefix = '%s[%d][%d]' % (sName, idTestCase, idTestCaseArgs,);
self.getIntParam(sPrefix + '[idTestCaseArgs]', iDefault = -1,)
sArgs = self.getStringParam(sPrefix + '[sArgs]', sDefault = '')
cSecTimeout = self.getStringParam(sPrefix + '[cSecTimeout]', sDefault = '')
cGangMembers = self.getStringParam(sPrefix + '[cGangMembers]', sDefault = '')
cGangMembers = self.getStringParam(sPrefix + '[cGangMembers]', sDefault = '')
oListEntryTestCaseArgs.append((fArgsChecked, idTestCaseArgs, sArgs, cSecTimeout, cGangMembers))
sTestCaseName = self.getStringParam('%s[%d][sName]' % (sName, idTestCase), sDefault='')
oListEntryTestCase = \
(idTestCase,
True if idTestCase in aiSelectedTestCaseIds else False,
sTestCaseName,
oListEntryTestCaseArgs)
aoListOfTestCases.append(oListEntryTestCase)
if aoListOfTestCases == []:
if asDefaults is None:
raise WuiException('%s is missing parameters: "%s"' % (self._sAction, sName))
aoListOfTestCases = asDefaults
return aoListOfTestCases
def getEffectiveDateParam(self, sParamName=None):
"""
Gets the effective date parameter.
Returns a timestamp suitable for database and url parameters.
Returns None if not found or empty.
"""
sName = sParamName if sParamName is not None else WuiDispatcherBase.ksParamEffectiveDate
if sName not in self._dParams:
return None;
if sName not in self._asCheckedParams:
self._asCheckedParams.append(sName);
sValue = self._dParams[sName];
if isinstance(sValue, list):
raise WuiException('%s parameter "%s" is given multiple times: %s' % (self._sAction, sName, sValue));
sValue = sValue.strip();
if sValue == '':
return None;
#
# Timestamp, just validate it and return.
#
if sValue[0] not in ['-', '+']:
(sValue, sError) = ModelDataBase.validateTs(sValue);
if sError is not None:
raise WuiException('%s parameter "%s" ("%s") is invalid: %s' % (self._sAction, sName, sValue, sError));
return sValue;
#
# Relative timestamp. Validate and convert it to a fixed timestamp.
#
chSign = sValue[0];
(sValue, sError) = ModelDataBase.validateTs(sValue[1:]);
if sError is not None:
raise WuiException('%s parameter "%s" ("%s") is invalid: %s' % (self._sAction, sName, sValue, sError));
if sValue[-6] in ['-', '+']:
raise WuiException('%s parameter "%s" ("%s") is a relative timestamp but incorrectly includes a time zone.'
% (self._sAction, sName, sValue));
offTime = 11;
if sValue[offTime - 1] != ' ':
raise WuiException('%s parameter "%s" ("%s") incorrect format.' % (self._sAction, sName, sValue));
sInterval = 'P' + sValue[:(offTime - 1)] + 'T' + sValue[offTime:];
self._oDb.execute('SELECT CURRENT_TIMESTAMP ' + chSign + ' \'' + sInterval + '\'::INTERVAL');
oDate = self._oDb.fetchOne()[0];
return str(oDate);
def _checkForUnknownParameters(self):
"""
Check if we've handled all parameters, raises exception if anything
unknown was found.
"""
if len(self._asCheckedParams) != len(self._dParams):
sUnknownParams = '';
for sKey in self._dParams:
if sKey not in self._asCheckedParams:
sUnknownParams += ' ' + sKey + '=' + str(self._dParams[sKey]);
raise WuiException('Unknown parameters: ' + sUnknownParams);
return True;
def _assertPostRequest(self):
"""
Makes sure that the request we're dispatching is a POST request.
Raises an exception of not.
"""
if self._oSrvGlue.getMethod() != 'POST':
raise WuiException('Expected "POST" request, got "%s"' % (self._oSrvGlue.getMethod(),))
return True;
#
# Client browser type.
#
## @name Browser types.
## @{
ksBrowserFamily_Unknown = 0;
ksBrowserFamily_Gecko = 1;
ksBrowserFamily_Webkit = 2;
ksBrowserFamily_Trident = 3;
## @}
## @name Browser types.
## @{
ksBrowserType_FamilyMask = 0xff;
ksBrowserType_Unknown = 0;
ksBrowserType_Firefox = (1 << 8) | ksBrowserFamily_Gecko;
ksBrowserType_Chrome = (2 << 8) | ksBrowserFamily_Webkit;
ksBrowserType_Safari = (3 << 8) | ksBrowserFamily_Webkit;
ksBrowserType_IE = (4 << 8) | ksBrowserFamily_Trident;
## @}
def getBrowserType(self):
"""
Gets the browser type.
The browser family can be extracted from this using ksBrowserType_FamilyMask.
"""
sAgent = self._oSrvGlue.getUserAgent();
if sAgent.find('AppleWebKit/') > 0:
if sAgent.find('Chrome/') > 0:
return self.ksBrowserType_Chrome;
if sAgent.find('Safari/') > 0:
return self.ksBrowserType_Safari;
return self.ksBrowserType_Unknown | self.ksBrowserFamily_Webkit;
if sAgent.find('Gecko/') > 0:
if sAgent.find('Firefox/') > 0:
return self.ksBrowserType_Firefox;
return self.ksBrowserType_Unknown | self.ksBrowserFamily_Gecko;
return self.ksBrowserType_Unknown | self.ksBrowserFamily_Unknown;
def isBrowserGecko(self, sMinVersion = None):
""" Returns true if it's a gecko based browser. """
if (self.getBrowserType() & self.ksBrowserType_FamilyMask) != self.ksBrowserFamily_Gecko:
return False;
if sMinVersion is not None:
sAgent = self._oSrvGlue.getUserAgent();
sVersion = sAgent[sAgent.find('Gecko/')+6:].split()[0];
if sVersion < sMinVersion:
return False;
return True;
#
# Debugging
#
def _debugProcessDispatch(self):
"""
Processes any debugging parameters in the request and adds them to
_asCheckedParams so they won't cause trouble in the action handler.
"""
self._fDbgSqlTrace = self.getBoolParam(self.ksParamDbgSqlTrace, False);
self._fDbgSqlExplain = self.getBoolParam(self.ksParamDbgSqlExplain, False);
if self._fDbgSqlExplain:
self._oDb.debugEnableExplain();
return True;
def _debugRenderPanel(self):
"""
Renders a simple form for controlling WUI debugging.
Returns the HTML for it.
"""
sHtml = '<div id="debug-panel">\n' \
' <form id="debug-panel-form" type="get" action="#">\n';
for sKey, oValue in self._dParams.iteritems():
if sKey not in self.kasDbgParams:
sHtml += ' <input type="hidden" name="%s" value="%s"/>\n' \
% (webutils.escapeAttr(sKey), webutils.escapeAttrToStr(oValue),);
for aoCheckBox in (
[self.ksParamDbgSqlTrace, self._fDbgSqlTrace, 'SQL trace'],
[self.ksParamDbgSqlExplain, self._fDbgSqlExplain, 'SQL explain'], ):
sHtml += ' <input type="checkbox" name="%s" value="1"%s>%s</input>\n' \
% (aoCheckBox[0], ' checked' if aoCheckBox[1] else '', aoCheckBox[2]);
sHtml += ' <button type="submit">Apply</button>\n';
sHtml += ' </form>\n' \
'</div>\n';
return sHtml;
def _debugGetParameters(self):
"""
Gets a dictionary with the debug parameters.
For use when links are constructed from scratch instead of self._dParams.
"""
return self._dDbgParams;
#
# Dispatching
#
def _actionDefault(self):
"""The default action handler, always overridden. """
raise WuiException('The child class shall override WuiBase.actionDefault().')
def _actionGenericListing(self, oLogicType, oListContentType):
"""
Generic listing action.
oLogicType implements fetchForListing.
oListContentType is a child of WuiListContentBase.
"""
tsEffective = self.getEffectiveDateParam();
cItemsPerPage = self.getIntParam(self.ksParamItemsPerPage, iMin = 2, iMax = 9999, iDefault = 300);
iPage = self.getIntParam(self.ksParamPageNo, iMin = 0, iMax = 999999, iDefault = 0);
self._checkForUnknownParameters();
aoEntries = oLogicType(self._oDb).fetchForListing(iPage * cItemsPerPage, cItemsPerPage + 1, tsEffective);
oContent = oListContentType(aoEntries, iPage, cItemsPerPage, tsEffective,
fnDPrint = self._oSrvGlue.dprint, oDisp = self);
(self._sPageTitle, self._sPageBody) = oContent.show();
return True;
def _actionGenericFormAdd(self, oDataType, oFormType):
"""
Generic add something form display request handler.
oDataType is a ModelDataBase child class.
oFormType is a WuiFormContentBase child class.
"""
oData = oDataType().initFromParams(oDisp = self, fStrict = False);
self._checkForUnknownParameters();
oForm = oFormType(oData, oFormType.ksMode_Add, oDisp = self);
(self._sPageTitle, self._sPageBody) = oForm.showForm();
return True
def _actionGenericFormDetails(self, oDataType, oLogicType, oFormType, sIdAttr, sGenIdAttr = None): # pylint: disable=R0914
"""
Generic handler for showing a details form/page.
oDataType is a ModelDataBase child class.
oLogicType may implement fetchForChangeLog.
oFormType is a WuiFormContentBase child class.
sIdParamName is the name of the ID parameter (not idGen!).
"""
# Parameters.
idGenObject = -1;
if sGenIdAttr is not None:
idGenObject = self.getIntParam(getattr(oDataType, 'ksParam_' + sGenIdAttr), 0, 0x7ffffffe, -1);
if idGenObject != -1:
idObject = tsNow = None;
else:
idObject = self.getIntParam(getattr(oDataType, 'ksParam_' + sIdAttr), 0, 0x7ffffffe, -1);
tsNow = self.getEffectiveDateParam();
fChangeLog = self.getBoolParam(WuiDispatcherBase.ksParamChangeLogEnabled, True);
iChangeLogPageNo = self.getIntParam(WuiDispatcherBase.ksParamChangeLogPageNo, 0, 9999, 0);
cChangeLogEntriesPerPage = self.getIntParam(WuiDispatcherBase.ksParamChangeLogEntriesPerPage, 2, 9999, 4);
self._checkForUnknownParameters();
# Fetch item and display it.
if idGenObject == -1:
oData = oDataType().initFromDbWithId(self._oDb, idObject, tsNow);
else:
oData = oDataType().initFromDbWithGenId(self._oDb, idGenObject);
oContent = oFormType(oData, oFormType.ksMode_Show, oDisp = self);
(self._sPageTitle, self._sPageBody) = oContent.showForm();
# Add change log if supported.
if fChangeLog and hasattr(oLogicType, 'fetchForChangeLog'):
(aoEntries, fMore) = oLogicType(self._oDb).fetchForChangeLog(getattr(oData, sIdAttr),
iChangeLogPageNo * cChangeLogEntriesPerPage,
cChangeLogEntriesPerPage ,
tsNow);
self._sPageBody += oContent.showChangeLog(aoEntries, fMore, iChangeLogPageNo, cChangeLogEntriesPerPage, tsNow);
return True
def _actionGenericFormEdit(self, oDataType, oFormType, sIdParamName):
"""
Generic edit something form display request handler.
oDataType is a ModelDataBase child class.
oFormType is a WuiFormContentBase child class.
sIdParamName is the name of the ID parameter (not idGen!).
"""
idObject = self.getIntParam(sIdParamName, 0, 0x7ffffffe);
self._checkForUnknownParameters();
oData = oDataType().initFromDbWithId(self._oDb, idObject);
oContent = oFormType(oData, oFormType.ksMode_Edit, oDisp = self);
(self._sPageTitle, self._sPageBody) = oContent.showForm();
return True
def _actionGenericFormEditL(self, oCoreObjectLogic, sCoreObjectIdFieldName, oWuiObjectLogic):
"""
Generic modify something form display request handler.
@param oCoreObjectLogic A *Logic class
@param sCoreObjectIdFieldName Name of HTTP POST variable that
contains object ID information
@param oWuiObjectLogic Web interface renderer class
"""
iCoreDataObjectId = self.getIntParam(sCoreObjectIdFieldName, 0, 0x7ffffffe, -1)
self._checkForUnknownParameters();
## @todo r=bird: This will return a None object if the object wasn't found... Crash bang in the content generator
# code (that's not logic code btw.).
oData = oCoreObjectLogic(self._oDb).getById(iCoreDataObjectId)
# Instantiate and render the MODIFY dialog form
oContent = oWuiObjectLogic(oData, oWuiObjectLogic.ksMode_Edit, oDisp=self)
(self._sPageTitle, self._sPageBody) = oContent.showForm()
return True
def _actionGenericFormClone(self, oDataType, oFormType, sIdAttr, sGenIdAttr = None):
"""
Generic clone something form display request handler.
oDataType is a ModelDataBase child class.
oFormType is a WuiFormContentBase child class.
sIdParamName is the name of the ID parameter.
sGenIdParamName is the name of the generation ID parameter, None if not applicable.
"""
# Parameters.
idGenObject = -1;
if sGenIdAttr is not None:
idGenObject = self.getIntParam(getattr(oDataType, 'ksParam_' + sGenIdAttr), 0, 0x7ffffffe, -1);
if idGenObject != -1:
idObject = tsNow = None;
else:
idObject = self.getIntParam(getattr(oDataType, 'ksParam_' + sIdAttr), 0, 0x7ffffffe, -1);
tsNow = self.getEffectiveDateParam();
self._checkForUnknownParameters();
# Fetch data and clear identifying attributes not relevant to the clone.
if idGenObject != -1:
oData = oDataType().initFromDbWithGenId(self._oDb, idGenObject);
else:
oData = oDataType().initFromDbWithId(self._oDb, idObject, tsNow);
setattr(oData, sIdAttr, None);
if sGenIdAttr is not None:
setattr(oData, sGenIdAttr, None);
oData.tsEffective = None;
oData.tsExpire = None;
# Display form.
oContent = oFormType(oData, oFormType.ksMode_Add, oDisp = self);
(self._sPageTitle, self._sPageBody) = oContent.showForm()
return True
def _actionGenericFormPost(self, sMode, fnLogicAction, oDataType, oFormType, sRedirectTo, fStrict=True):
"""
Generic POST request handling from a WuiFormContentBase child.
oDataType is a ModelDataBase child class.
oFormType is a WuiFormContentBase child class.
fnLogicAction is a method taking a oDataType instance and uidAuthor as arguments.
"""
#
# Read and validate parameters.
#
oData = oDataType().initFromParams(oDisp = self, fStrict = fStrict);
self._checkForUnknownParameters();
self._assertPostRequest();
dErrors = oData.validateAndConvert(self._oDb);
if len(dErrors) == 0:
oData.convertFromParamNull();
#
# Try do the job.
#
try:
fnLogicAction(oData, self._oCurUser.uid, fCommit = True);
except Exception as oXcpt:
self._oDb.rollback();
oForm = oFormType(oData, sMode, oDisp = self);
sErrorMsg = str(oXcpt) if not config.g_kfDebugDbXcpt else '\n'.join(utils.getXcptInfo(4));
(self._sPageTitle, self._sPageBody) = oForm.showForm(sErrorMsg = sErrorMsg);
else:
#
# Worked, redirect to the specified page.
#
self._sPageTitle = None;
self._sPageBody = None;
self._sRedirectTo = sRedirectTo;
else:
oForm = oFormType(oData, sMode, oDisp = self);
(self._sPageTitle, self._sPageBody) = oForm.showForm(dErrors = dErrors);
return True;
def _actionGenericFormAddPost(self, oDataType, oLogicType, oFormType, sRedirAction, fStrict=True):
"""
Generic add entry POST request handling from a WuiFormContentBase child.
oDataType is a ModelDataBase child class.
oLogicType is a class that implements addEntry.
oFormType is a WuiFormContentBase child class.
sRedirAction is what action to redirect to on success.
"""
oLogic = oLogicType(self._oDb);
from testmanager.webui.wuicontentbase import WuiFormContentBase;
return self._actionGenericFormPost(WuiFormContentBase.ksMode_Add, oLogic.addEntry, oDataType, oFormType,
'?' + webutils.encodeUrlParams({self.ksParamAction: sRedirAction}), fStrict=fStrict)
def _actionGenericFormEditPost(self, oDataType, oLogicType, oFormType, sRedirAction, fStrict = True):
"""
Generic edit POST request handling from a WuiFormContentBase child.
oDataType is a ModelDataBase child class.
oLogicType is a class that implements addEntry.
oFormType is a WuiFormContentBase child class.
sRedirAction is what action to redirect to on success.
"""
oLogic = oLogicType(self._oDb);
from testmanager.webui.wuicontentbase import WuiFormContentBase;
return self._actionGenericFormPost(WuiFormContentBase.ksMode_Edit, oLogic.editEntry, oDataType, oFormType,
'?' + webutils.encodeUrlParams({self.ksParamAction: sRedirAction}),
fStrict = fStrict);
def _unauthorizedUser(self):
"""
Displays the unauthorized user message (corresponding record is not
present in DB).
"""
sLoginName = self._oSrvGlue.getLoginName();
# Report to system log
oSystemLogLogic = SystemLogLogic(self._oDb);
oSystemLogLogic.addEntry(SystemLogData.ksEvent_UserAccountUnknown,
'Unknown user (%s) attempts to access from %s'
% (sLoginName, self._oSrvGlue.getClientAddr()),
24, fCommit = True)
# Display message.
self._sPageTitle = 'User not authorized'
self._sPageBody = """
<p>Access denied for user <b>%s</b>.
Please contact an admin user to set up your access.</p>
""" % (sLoginName,)
return True;
def dispatchRequest(self):
"""
Dispatches a request.
"""
#
# Get the parameters and checks for duplicates.
#
try:
dParams = self._oSrvGlue.getParameters();
except Exception as oXcpt:
raise WuiException('Error retriving parameters: %s' % (oXcpt,));
for sKey in dParams.keys():
# Take care about strings which may contain unicode characters: convert percent-encoded symbols back to unicode.
for idxItem, _ in enumerate(dParams[sKey]):
dParams[sKey][idxItem] = dParams[sKey][idxItem].decode('utf-8')
if not len(dParams[sKey]) > 1:
dParams[sKey] = dParams[sKey][0];
self._dParams = dParams;
#
# Figure out the requested action and validate it.
#
if self.ksParamAction in self._dParams:
self._sAction = self._dParams[self.ksParamAction];
self._asCheckedParams.append(self.ksParamAction);
else:
self._sAction = self.ksActionDefault;
if self._sAction not in self._dDispatch:
raise WuiException('Unknown action "%s" requested' % (self._sAction,));
#
# Call action handler and generate the page (if necessary).
#
if self._oCurUser is not None:
self._debugProcessDispatch();
if self._dDispatch[self._sAction]() is self.ksDispatchRcAllDone:
return True;
else:
self._unauthorizedUser();
if self._sRedirectTo is None:
self._generatePage();
else:
self._redirectPage();
return True;
def dprint(self, sText):
""" Debug printing. """
if config.g_kfWebUiDebug and True:
self._oSrvGlue.dprint(sText);
|
mit
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
2672,
1304,
26,
336,
1907,
1095,
14,
647,
2672,
199,
199,
624,
199,
774,
13537,
6001,
13,
6379,
446,
3523,
27939,
14,
199,
624,
199,
199,
363,
7307,
363,
275,
971,
199,
624,
199,
7384,
334,
35,
9,
6029,
13,
7806,
15309,
11098,
199,
199,
2765,
570,
365,
1777,
402,
13311,
3532,
3232,
5800,
662,
1671,
334,
47,
899,
395,
465,
199,
4561,
687,
1455,
921,
1544,
14,
2065,
1977,
14,
1308,
14,
961,
570,
365,
2867,
2032,
27,
199,
13297,
883,
3604,
652,
436,
15,
269,
2811,
652,
1334,
314,
2895,
402,
314,
1664,
199,
14109,
1684,
844,
334,
12006,
9,
465,
3267,
701,
314,
2868,
2290,
199,
30216,
12,
315,
1015,
499,
465,
652,
12477,
315,
314,
298,
16188,
1206,
2,
570,
402,
314,
199,
8735,
3532,
593,
899,
4084,
14,
13311,
3532,
593,
899,
365,
1854,
315,
314,
199,
526,
321,
626,
652,
911,
506,
2997,
12,
1325,
2428,
1821,
3408,
402,
1263,
4928,
14,
199,
199,
1918,
4072,
402,
642,
570,
1443,
8679,
17330,
506,
1202,
1334,
314,
2895,
199,
1618,
314,
13964,
15290,
436,
11839,
844,
3394,
413,
14,
16,
199,
8,
35,
31868,
9,
1454,
12,
465,
652,
12477,
315,
314,
298,
16188,
1206,
14,
35,
31868,
2,
570,
402,
314,
199,
8735,
3532,
593,
899,
4084,
12,
315,
1314,
1930,
314,
1727,
1356,
402,
314,
199,
35,
31868,
787,
3964,
3140,
402,
5204,
402,
314,
14629,
14,
199,
199,
5556,
1443,
28933,
370,
4190,
6042,
5459,
402,
642,
570,
1334,
314,
199,
9187,
436,
3704,
402,
1902,
314,
14629,
503,
314,
445,
31868,
503,
3865,
14,
199,
624,
199,
363,
1023,
363,
275,
7880,
12714,
26,
2948,
30321,
2672,
2,
421,
199,
3,
9739,
2366,
8925,
14,
199,
646,
747,
27,
199,
199,
3,
19381,
1804,
390,
8925,
14,
199,
504,
2863,
9668,
492,
781,
464,
3024,
12,
3778,
27,
199,
504,
511,
2609,
8295,
492,
1101,
27,
199,
504,
511,
2609,
14,
1018,
14,
1095,
263,
492,
5822,
1451,
1563,
12,
377,
45,
1726,
1563,
27,
199,
504,
511,
2609,
14,
1018,
14,
697,
3515,
492,
377,
5127,
1963,
3225,
27,
199,
504,
511,
2609,
14,
1018,
14,
2253,
793,
257,
492,
6187,
2445,
32140,
12,
6187,
2445,
1451,
27,
199,
504,
511,
2609,
14,
1018,
14,
751,
2048,
492,
2876,
6009,
32140,
421,
199,
533,
644,
1907,
1726,
8,
20690,
1726,
1563,
304,
272,
408,
272,
2104,
4967,
4915,
701,
6001,
14041,
1233,
14,
272,
408,
272,
986,
27,
421,
199,
533,
644,
1907,
15461,
1563,
8,
785,
304,
272,
408,
272,
3523,
1021,
367,
314,
6001,
2876,
14816,
334,
55,
6379,
9,
7634,
1192,
14,
339,
710,
17475,
1021,
7890,
314,
5678,
83,
402,
314,
2034,
334,
2930,
1300,
1978,
12,
272,
6269,
2974,
12,
1595,
680,
221,
2779,
365,
2597,
17845,
367,
6057,
4145,
436,
272,
7634,
316,
3062,
370,
1595,
334,
4030,
9,
503,
15,
460,
1564,
16952,
334,
2970,
11,
4030,
680,
272,
710,
1564,
2138,
701,
314,
4306,
365,
9545,
1901,
314,
1978,
436,
4847,
272,
1771,
370,
314,
3330,
1000,
6482,
310,
14,
272,
408,
339,
925,
768,
11396,
3962,
626,
642,
1077,
1006,
2621,
1901,
3451,
425,
14,
339,
925,
710,
1595,
2725,
14,
272,
15357,
4098,
3310,
755,
275,
283,
3310,
13619,
272,
925,
710,
536,
402,
314,
849,
1595,
14,
272,
15357,
3310,
2698,
258,
275,
283,
885,
13619,
339,
925,
710,
536,
402,
314,
1453,
2034,
1329,
2725,
1202,
1380,
20589,
5548,
14,
272,
15357,
4098,
3276,
1944,
755,
275,
283,
3276,
1944,
13619,
272,
925,
710,
536,
402,
314,
2034,
2582,
334,
513,
2974,
9,
2725,
1380,
20589,
5548,
14,
272,
15357,
4098,
7412,
2623,
3276,
275,
283,
7412,
2623,
3276,
13619,
339,
925,
710,
536,
402,
314,
15826,
1434,
334,
3954,
9,
2725,
14,
272,
15357,
4098,
30754,
2506,
275,
283,
30754,
2506,
13619,
339,
925,
710,
536,
402,
314,
769,
13,
1287,
2725,
334,
55,
1907,
1296,
2714,
3007,
3310,
1563,
680,
272,
15357,
4098,
1296,
3310,
259,
275,
283,
1296,
3310,
13619,
339,
925,
710,
536,
402,
314,
1570,
943,
5223,
15,
7011,
2725,
14,
272,
15357,
4098,
4001,
2445,
6589,
260,
275,
283,
4001,
2445,
6589,
13619,
272,
925,
710,
536,
402,
314,
623,
391,
69,
351,
9297,
314,
1570,
943,
2034,
1329,
14,
272,
15357,
4098,
4001,
2445,
3276,
1944,
3515,
275,
283,
4001,
2445,
3276,
1944,
13619,
272,
925,
710,
536,
402,
314,
2725,
6623,
1329,
402,
1570,
943,
4811,
1126,
2034,
14,
272,
15357,
4098,
4001,
2445,
17816,
2623,
3276,
221,
275,
283,
4001,
2445,
17816,
2623,
3276,
13619,
339,
925,
768,
354,
5289,
11238,
10201,
2633,
14,
272,
925,
26939,
272,
15357,
4098,
36,
6856,
16790,
3921,
420,
275,
283,
36,
6856,
16790,
3921,
13619,
272,
15357,
4098,
36,
6856,
16790,
4527,
3993,
259,
275,
283,
36,
6856,
16790,
4527,
3993,
13619,
272,
925,
3820,
402,
1006,
10201,
2633,
14,
272,
1022,
305,
36,
6856,
6007,
275,
334,
6080,
4098,
36,
6856,
16790,
3921,
12,
15357,
4098,
36,
6856,
16790,
4527,
3993,
12,
2736,
272,
925,
768,
93,
339,
925,
12568,
1595,
372,
1233,
367,
16068,
485,
4208,
3276,
14,
18491,
367,
272,
327,
5235,
6497,
436,
314,
2839,
626,
26560,
874,
543,
314,
3101,
1406,
436,
1655,
14,
272,
15357,
20628,
19360,
2422,
10759,
275,
283,
10759,
446,
10331,
965,
2757,
8018,
2575,
13619,
2378,
347,
636,
826,
721,
277,
12,
312,
51,
6310,
39,
11322,
12,
308,
5229,
985,
304,
267,
291,
423,
79,
51,
6310,
39,
11322,
3515,
275,
312,
51,
6310,
39,
11322,
27,
267,
291,
423,
79,
8882,
5185,
275,
377,
5127,
1963,
3225,
8,
277,
14,
68,
1361,
340,
1101,
14,
71,
63,
16791,
5926,
18203,
16790,
7084,
587,
488,
12,
312,
51,
6310,
39,
11322,
275,
312,
51,
6310,
39,
11322,
2736,
267,
291,
423,
305,
14627,
6007,
257,
275,
22750,
267,
291,
423,
68,
6007,
3698,
275,
488,
27,
221,
327,
2494,
701,
7634,
2017,
14,
267,
291,
423,
83,
3310,
3698,
275,
488,
27,
221,
327,
2494,
701,
7634,
2017,
14,
267,
291,
423,
68,
20628,
260,
275,
469,
291,
14,
6080,
3310,
2698,
26,
291,
423
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
2672,
1304,
26,
336,
1907,
1095,
14,
647,
2672,
199,
199,
624,
199,
774,
13537,
6001,
13,
6379,
446,
3523,
27939,
14,
199,
624,
199,
199,
363,
7307,
363,
275,
971,
199,
624,
199,
7384,
334,
35,
9,
6029,
13,
7806,
15309,
11098,
199,
199,
2765,
570,
365,
1777,
402,
13311,
3532,
3232,
5800,
662,
1671,
334,
47,
899,
395,
465,
199,
4561,
687,
1455,
921,
1544,
14,
2065,
1977,
14,
1308,
14,
961,
570,
365,
2867,
2032,
27,
199,
13297,
883,
3604,
652,
436,
15,
269,
2811,
652,
1334,
314,
2895,
402,
314,
1664,
199,
14109,
1684,
844,
334,
12006,
9,
465,
3267,
701,
314,
2868,
2290,
199,
30216,
12,
315,
1015,
499,
465,
652,
12477,
315,
314,
298,
16188,
1206,
2,
570,
402,
314,
199,
8735,
3532,
593,
899,
4084,
14,
13311,
3532,
593,
899,
365,
1854,
315,
314,
199,
526,
321,
626,
652,
911,
506,
2997,
12,
1325,
2428,
1821,
3408,
402,
1263,
4928,
14,
199,
199,
1918,
4072,
402,
642,
570,
1443,
8679,
17330,
506,
1202,
1334,
314,
2895,
199,
1618,
314,
13964,
15290,
436,
11839,
844,
3394,
413,
14,
16,
199,
8,
35,
31868,
9,
1454,
12,
465,
652,
12477,
315,
314,
298,
16188,
1206,
14,
35,
31868,
2,
570,
402,
314,
199,
8735,
3532,
593,
899,
4084,
12,
315,
1314,
1930,
314,
1727,
1356,
402,
314,
199,
35,
31868,
787,
3964,
3140,
402,
5204,
402,
314,
14629,
14,
199,
199,
5556,
1443,
28933,
370,
4190,
6042,
5459,
402,
642,
570,
1334,
314,
199,
9187,
436,
3704,
402,
1902,
314,
14629,
503,
314,
445,
31868,
503,
3865,
14,
199,
624,
199,
363,
1023,
363,
275,
7880,
12714,
26,
2948,
30321,
2672,
2,
421,
199,
3,
9739,
2366,
8925,
14,
199,
646,
747,
27,
199,
199,
3,
19381,
1804,
390,
8925,
14,
199,
504,
2863,
9668,
492,
781,
464,
3024,
12,
3778,
27,
199,
504,
511,
2609,
8295,
492,
1101,
27,
199,
504,
511,
2609,
14,
1018,
14,
1095,
263,
492,
5822,
1451,
1563,
12,
377,
45,
1726,
1563,
27,
199,
504,
511,
2609,
14,
1018,
14,
697,
3515,
492,
377,
5127,
1963,
3225,
27,
199,
504,
511,
2609,
14,
1018,
14,
2253,
793,
257,
492,
6187,
2445,
32140,
12,
6187,
2445,
1451,
27,
199,
504,
511,
2609,
14,
1018,
14,
751,
2048,
492,
2876,
6009,
32140,
421,
199,
533,
644,
1907,
1726,
8,
20690,
1726,
1563,
304,
272,
408,
272,
2104,
4967,
4915,
701,
6001,
14041,
1233,
14,
272,
408,
272,
986,
27,
421,
199,
533,
644,
1907,
15461,
1563,
8,
785,
304,
272,
408,
272,
3523,
1021,
367,
314,
6001,
2876,
14816,
334,
55,
6379,
9,
7634,
1192,
14,
339,
710,
17475,
1021,
7890,
314,
5678,
83,
402,
314,
2034,
334,
2930,
1300,
1978,
12,
272,
6269,
2974,
12,
1595,
680,
221,
2779,
365,
2597,
17845,
367,
6057,
4145,
436,
272,
7634,
316,
3062,
370,
1595,
334,
4030,
9,
503,
15,
460,
1564,
16952,
334,
2970,
11,
4030,
680,
272,
710,
1564,
2138,
701,
314,
4306,
365,
9545,
1901,
314,
1978,
436,
4847,
272,
1771,
370,
314,
3330,
1000,
6482,
310,
14,
272,
408,
339,
925,
768,
11396,
3962,
626,
642,
1077,
1006,
2621,
1901,
3451,
425,
14,
339,
925,
710,
1595,
2725,
14,
272,
15357,
4098,
3310,
755,
275,
283,
3310,
13619,
272,
925,
710,
536,
402,
314,
849,
1595,
14,
272,
15357,
3310,
2698,
258,
275,
283,
885,
13619,
339,
925,
710,
536,
402,
314,
1453,
2034,
1329,
2725,
1202,
1380,
20589,
5548,
14,
272,
15357,
4098,
3276,
1944,
755,
275,
283,
3276,
1944,
13619,
272,
925,
710,
536,
402,
314,
2034,
2582,
334,
513,
2974,
9,
2725,
1380,
20589,
5548,
14,
272,
15357,
4098,
7412,
2623,
3276,
275,
283,
7412,
2623,
3276,
13619,
339,
925,
710,
536,
402,
314,
15826,
1434,
334,
3954,
9,
2725,
14,
272,
15357,
4098,
30754,
2506,
275,
283,
30754,
2506,
13619,
339,
925,
710,
536,
402,
314,
769,
13,
1287,
2725,
334,
55,
1907,
1296,
2714,
3007,
3310,
1563,
680,
272,
15357,
4098,
1296,
3310,
259,
275,
283,
1296,
3310,
13619,
339,
925,
710,
536,
402,
314,
1570,
943,
5223,
15,
7011,
2725,
14,
272,
15357,
4098,
4001,
2445,
6589,
260,
275,
283,
4001,
2445,
6589,
13619,
272,
925,
710,
536,
402,
314,
623,
391,
69,
351,
9297,
314,
1570,
943,
2034,
1329,
14,
272,
15357,
4098,
4001,
2445,
3276,
1944,
3515,
275,
283,
4001,
2445,
3276,
1944,
13619,
272,
925,
710,
536,
402,
314,
2725,
6623,
1329,
402,
1570,
943,
4811,
1126,
2034,
14,
272,
15357,
4098,
4001,
2445,
17816,
2623,
3276,
221,
275,
283,
4001,
2445,
17816,
2623,
3276,
13619,
339,
925,
768,
354,
5289,
11238,
10201,
2633,
14,
272,
925,
26939,
272,
15357,
4098,
36,
6856,
16790,
3921,
420,
275,
283,
36,
6856,
16790,
3921,
13619,
272,
15357,
4098,
36,
6856,
16790,
4527,
3993,
259,
275,
283,
36,
6856,
16790,
4527,
3993,
13619,
272,
925,
3820,
402,
1006,
10201,
2633,
14,
272,
1022,
305,
36,
6856,
6007,
275,
334,
6080,
4098,
36,
6856,
16790,
3921,
12,
15357,
4098,
36,
6856,
16790,
4527,
3993,
12,
2736,
272,
925,
768,
93,
339,
925,
12568,
1595,
372,
1233,
367,
16068,
485,
4208,
3276,
14,
18491,
367,
272,
327,
5235,
6497,
436,
314,
2839,
626,
26560,
874,
543,
314,
3101,
1406,
436,
1655,
14,
272,
15357,
20628,
19360,
2422,
10759,
275,
283,
10759,
446,
10331,
965,
2757,
8018,
2575,
13619,
2378,
347,
636,
826,
721,
277,
12,
312,
51,
6310,
39,
11322,
12,
308,
5229,
985,
304,
267,
291,
423,
79,
51,
6310,
39,
11322,
3515,
275,
312,
51,
6310,
39,
11322,
27,
267,
291,
423,
79,
8882,
5185,
275,
377,
5127,
1963,
3225,
8,
277,
14,
68,
1361,
340,
1101,
14,
71,
63,
16791,
5926,
18203,
16790,
7084,
587,
488,
12,
312,
51,
6310,
39,
11322,
275,
312,
51,
6310,
39,
11322,
2736,
267,
291,
423,
305,
14627,
6007,
257,
275,
22750,
267,
291,
423,
68,
6007,
3698,
275,
488,
27,
221,
327,
2494,
701,
7634,
2017,
14,
267,
291,
423,
83,
3310,
3698,
275,
488,
27,
221,
327,
2494,
701,
7634,
2017,
14,
267,
291,
423,
68,
20628,
260,
275,
469,
291,
14,
6080,
3310,
2698,
26,
291,
423,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
sevein/archivematica
|
src/dashboard/src/components/rights/views.py
|
1
|
27795
|
# This file is part of Archivematica.
#
# Copyright 2010-2013 Artefactual Systems Inc. <http://artefactual.com>
#
# Archivematica is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Archivematica is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Archivematica. If not, see <http://www.gnu.org/licenses/>.
import logging
import re
from django.core.urlresolvers import reverse
from django.forms.models import inlineformset_factory
from django.http import HttpResponse
from django.shortcuts import redirect, render
from django.template import RequestContext
from components import decorators
from components import helpers
from components.rights import forms
from contrib import utils
from main import models
LOGGER = logging.getLogger('archivematica.dashboard')
""" @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Rights-related
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ """
def transfer_rights_list(request, uuid):
return rights_list(request, uuid, 'transfer')
def transfer_rights_edit(request, uuid, id=None):
return rights_edit(request, uuid, id, 'transfer')
def transfer_rights_delete(request, uuid, id):
return rights_delete(request, uuid, id, 'transfer')
def transfer_grant_delete_context(request, uuid, id):
prompt = 'Delete rights grant?'
cancel_url = reverse("components.rights.views.transfer_rights_list", args=[uuid])
return RequestContext(request, {'action': 'Delete', 'prompt': prompt, 'cancel_url': cancel_url})
@decorators.confirm_required('simple_confirm.html', transfer_grant_delete_context)
def transfer_rights_grant_delete(request, uuid, id):
return rights_grant_delete(request, uuid, id, 'transfer')
def transfer_rights_grants_edit(request, uuid, id):
return rights_grants_edit(request, uuid, id, 'transfer')
def ingest_rights_list(request, uuid):
return rights_list(request, uuid, 'ingest')
def ingest_rights_edit(request, uuid, id=None):
return rights_edit(request, uuid, id, 'ingest')
def ingest_rights_delete(request, uuid, id):
return rights_delete(request, uuid, id, 'ingest')
def ingest_grant_delete_context(request, uuid, id):
prompt = 'Delete rights grant?'
cancel_url = reverse("components.rights.views.ingest_rights_list", args=[uuid])
return RequestContext(request, {'action': 'Delete', 'prompt': prompt, 'cancel_url': cancel_url})
@decorators.confirm_required('simple_confirm.html', ingest_grant_delete_context)
def ingest_rights_grant_delete(request, uuid, id):
return rights_grant_delete(request, uuid, id, 'ingest')
def ingest_rights_grants_edit(request, uuid, id):
return rights_grants_edit(request, uuid, id, 'ingest')
def rights_parse_agent_id(input):
return 0
if input == '':
agentId = 0
else:
agentRaw = input
try:
int(agentRaw)
agentId = int(agentRaw)
except ValueError:
agentRe = re.compile('(.*)\[(\d*)\]')
match = agentRe.match(agentRaw)
if match:
agentId = match.group(2)
else:
agentId = 0
return agentId
def rights_edit(request, uuid, id=None, section='ingest'):
jobs = models.Job.objects.filter(sipuuid=uuid, subjobof='')
name = utils.get_directory_name_from_job(jobs)
# flag indicating what kind of new content, if any, has been created
new_content_type_created = None
max_notes = 1
if id:
viewRights = models.RightsStatement.objects.get(pk=id)
agentId = None
if request.method == 'POST':
postData = request.POST.copy()
"""
agentId = rights_parse_agent_id(postData.get('rightsholder'))
if agentId == 0 and postData.get('rightsholder') != '0' and postData.get('rightsholder') != '':
agent = models.RightsStatementLinkingAgentIdentifier()
agent.rightsstatement = viewRights
agent.linkingagentidentifiervalue = postData.get('rightsholder')
agent.save()
agentId = agent.id
postData.__setitem__('rightsholder', agentId)
"""
form = forms.RightsForm(postData, instance=viewRights)
form.cleaned_data = postData
viewRights = form.save()
else:
form = forms.RightsForm(instance=viewRights)
form.cleaned_data = viewRights
form.save()
# determine how many empty forms should be shown for children
extra_copyright_forms = max_notes - models.RightsStatementCopyright.objects.filter(rightsstatement=viewRights).count()
extra_statute_forms = max_notes - models.RightsStatementStatuteInformation.objects.filter(rightsstatement=viewRights).count()
extra_license_forms = max_notes - models.RightsStatementLicense.objects.filter(rightsstatement=viewRights).count()
extra_other_forms = max_notes - models.RightsStatementOtherRightsInformation.objects.filter(rightsstatement=viewRights).count()
else:
if request.method == 'POST':
postData = request.POST.copy()
agentId = rights_parse_agent_id(postData.get('rightsholder'))
postData.__setitem__('rightsholder', agentId)
form = forms.RightsForm(postData)
else:
form = forms.RightsForm()
viewRights = models.RightsStatement()
extra_copyright_forms = max_notes
extra_statute_forms = max_notes
extra_license_forms = max_notes
extra_license_notes = max_notes
extra_other_forms = max_notes
# create inline formsets for child elements
CopyrightFormSet = inlineformset_factory(
models.RightsStatement,
models.RightsStatementCopyright,
extra=extra_copyright_forms,
can_delete=False,
form=forms.RightsCopyrightForm
)
StatuteFormSet = inlineformset_factory(
models.RightsStatement,
models.RightsStatementStatuteInformation,
extra=extra_statute_forms,
can_delete=False,
form=forms.RightsStatuteForm
)
LicenseFormSet = inlineformset_factory(
models.RightsStatement,
models.RightsStatementLicense,
extra=extra_license_forms,
can_delete=False,
form=forms.RightsLicenseForm
)
OtherFormSet = inlineformset_factory(
models.RightsStatement,
models.RightsStatementOtherRightsInformation,
extra=extra_other_forms,
can_delete=False,
form=forms.RightsOtherRightsForm
)
copyrightFormset = CopyrightFormSet()
statuteFormset = StatuteFormSet()
licenseFormset = LicenseFormSet()
otherFormset = OtherFormSet()
# handle form creation/saving
if request.method == 'POST':
if id:
createdRights = viewRights
else:
sectionTypeID = {'transfer': 'Transfer', 'ingest': 'SIP'}
type_id = helpers.get_metadata_type_id_by_description(sectionTypeID[section])
newRights = models.RightsStatement(metadataappliestotype=type_id, metadataappliestoidentifier=uuid)
form = forms.RightsForm(request.POST, instance=newRights)
createdRights = form.save()
copyrightFormset = CopyrightFormSet(request.POST, instance=createdRights)
if not copyrightFormset.is_valid():
return render(request, 'rights/rights_edit.html', locals())
createdCopyrightSet = copyrightFormset.save()
# establish whether or not there is a copyright information instance to use as a parent
if len(createdCopyrightSet) == 1:
createdCopyright = createdCopyrightSet[0]
else:
createdCopyright = False
# handle creation of new copyright notes, creating parent if necessary
if request.POST.get('copyright_note', '') != '':
# make new copyright record if it doesn't exist
if not createdCopyright:
try:
createdCopyright = models.RightsStatementCopyright.objects.get(rightsstatement=createdRights)
except:
createdCopyright = models.RightsStatementCopyright(rightsstatement=createdRights)
createdCopyright.save()
copyrightNote = models.RightsStatementCopyrightNote(rightscopyright=createdCopyright)
copyrightNote.copyrightnote = request.POST.get('copyright_note', '')
copyrightNote.save()
new_content_type_created = 'copyright'
# handle creation of new documentation identifiers
if request.POST.get('copyright_documentation_identifier_type', '') != '' or request.POST.get('copyright_documentation_identifier_value', '') != '' or request.POST.get('copyright_documentation_identifier_role', ''):
# make new copyright record if it doesn't exist
if not createdCopyright:
try:
createdCopyright = models.RightsStatementCopyright.objects.get(rightsstatement=createdRights)
except:
createdCopyright = models.RightsStatementCopyright(rightsstatement=createdRights)
createdCopyright.save()
copyrightDocIdentifier = models.RightsStatementCopyrightDocumentationIdentifier(rightscopyright=createdCopyright)
copyrightDocIdentifier.copyrightdocumentationidentifiertype = request.POST.get('copyright_documentation_identifier_type', '')
copyrightDocIdentifier.copyrightdocumentationidentifiervalue = request.POST.get('copyright_documentation_identifier_value', '')
copyrightDocIdentifier.copyrightdocumentationidentifierrole = request.POST.get('copyright_documentation_identifier_role', '')
copyrightDocIdentifier.save()
new_content_type_created = 'copyright'
licenseFormset = LicenseFormSet(request.POST, instance=createdRights)
if not licenseFormset.is_valid():
return render(request, 'rights/rights_edit.html', locals())
createdLicenseSet = licenseFormset.save()
# establish whether or not there is a license instance to use as a parent
if len(createdLicenseSet) == 1:
createdLicense = createdLicenseSet[0]
else:
createdLicense = False
# handle creation of new copyright notes, creating parent if necessary
if request.POST.get('license_note', '') != '':
# make new copyright record if it doesn't exist
if not createdLicense:
try:
createdLicense = models.RightsStatementLicense.objects.get(rightsstatement=createdRights)
except:
createdLicense = models.RightsStatementLicense(rightsstatement=createdRights)
createdLicense.save()
licenseNote = models.RightsStatementLicenseNote(rightsstatementlicense=createdLicense)
licenseNote.licensenote = request.POST.get('license_note', '')
licenseNote.save()
new_content_type_created = 'license'
# handle creation of new documentation identifiers
if request.POST.get('license_documentation_identifier_type', '') != '' or request.POST.get('license_documentation_identifier_value', '') != '' or request.POST.get('license_documentation_identifier_role', ''):
# make new license record if it doesn't exist
if not createdLicense:
try:
createdLicense = models.RightsStatementLicense.objects.get(rightsstatement=createdRights)
except:
createdLicense = models.RightsStatementLicense(rightsstatement=createdRights)
createdLicense.save()
licenseDocIdentifier = models.RightsStatementLicenseDocumentationIdentifier(rightsstatementlicense=createdLicense)
licenseDocIdentifier.licensedocumentationidentifiertype = request.POST.get('license_documentation_identifier_type', '')
licenseDocIdentifier.licensedocumentationidentifiervalue = request.POST.get('license_documentation_identifier_value', '')
licenseDocIdentifier.licensedocumentationidentifierrole = request.POST.get('license_documentation_identifier_role', '')
licenseDocIdentifier.save()
new_content_type_created = 'license'
statuteFormset = StatuteFormSet(request.POST, instance=createdRights)
if not statuteFormset.is_valid():
return render(request, 'rights/rights_edit.html', locals())
createdStatuteSet = statuteFormset.save()
if request.POST.get('statute_previous_pk', '') == 'None' and len(createdStatuteSet) == 1:
new_content_type_created = 'statute'
noteCreated = False
for form in statuteFormset.forms:
statuteCreated = False
# handle documentation identifier creation for a parent that's a blank statute
if (request.POST.get('statute_documentation_identifier_type_None', '') != '' or request.POST.get('statute_documentation_identifier_value_None', '') != '' or request.POST.get('statute_documentation_identifier_role_None', '') != ''):
if form.instance.pk:
statuteCreated = form.instance
else:
statuteCreated = models.RightsStatementStatuteInformation(rightsstatement=createdRights)
statuteCreated.save()
statuteDocIdentifier = models.RightsStatementStatuteDocumentationIdentifier(rightsstatementstatute=statuteCreated)
statuteDocIdentifier.statutedocumentationidentifiertype = request.POST.get('statute_documentation_identifier_type_None', '')
statuteDocIdentifier.statutedocumentationidentifiervalue = request.POST.get('statute_documentation_identifier_value_None', '')
statuteDocIdentifier.statutedocumentationidentifierrole = request.POST.get('statute_documentation_identifier_role_None', '')
statuteDocIdentifier.save()
new_content_type_created = 'statute'
else:
# handle documentation identifier creation for a parent statute that already exists
if request.POST.get('statute_documentation_identifier_type_' + str(form.instance.pk), '') != '' or request.POST.get('statute_documentation_identifier_value_' + str(form.instance.pk), '') or request.POST.get('statute_documentation_identifier_role_' + str(form.instance.pk), ''):
statuteDocIdentifier = models.RightsStatementStatuteDocumentationIdentifier(rightsstatementstatute=form.instance)
statuteDocIdentifier.statutedocumentationidentifiertype = request.POST.get('statute_documentation_identifier_type_' + str(form.instance.pk), '')
statuteDocIdentifier.statutedocumentationidentifiervalue = request.POST.get('statute_documentation_identifier_value_' + str(form.instance.pk), '')
statuteDocIdentifier.statutedocumentationidentifierrole = request.POST.get('statute_documentation_identifier_role_' + str(form.instance.pk), '')
statuteDocIdentifier.save()
new_content_type_created = 'statute'
# handle note creation for a parent that's a blank grant
if request.POST.get('new_statute_note_None', '') != '' and not form.instance.pk:
if not statuteCreated:
statuteCreated = models.RightsStatementStatuteInformation(rightsstatement=createdRights)
statuteCreated.save()
noteCreated = models.RightsStatementStatuteInformationNote(rightsstatementstatute=statuteCreated)
noteCreated.statutenote = request.POST.get('new_statute_note_None', '')
noteCreated.save()
new_content_type_created = 'statue'
else:
# handle note creation for a parent grant that already exists
if request.POST.get('new_statute_note_' + str(form.instance.pk), '') != '':
noteCreated = models.RightsStatementStatuteInformationNote(rightsstatementstatute=form.instance)
noteCreated.statutenote = request.POST.get('new_statute_note_' + str(form.instance.pk), '')
noteCreated.save()
new_content_type_created = 'statute'
# handle note creation for a parent that's just been created
if request.POST.get('new_statute_note_None', '') != '' and not noteCreated:
noteCreated = models.RightsStatementStatuteInformationNote(rightsstatementstatute=form.instance)
noteCreated.statutenote = request.POST.get('new_statute_note_None', '')
noteCreated.save()
# display (possibly revised) formset
statuteFormset = StatuteFormSet(instance=createdRights)
otherFormset = OtherFormSet(request.POST, instance=createdRights)
if not otherFormset.is_valid():
return render(request, 'rights/rights_edit.html', locals())
createdOtherSet = otherFormset.save()
# establish whether or not there is an "other" instance to use as a parent
if len(createdOtherSet) == 1:
createdOther = createdOtherSet[0]
else:
createdOther = False
# handle creation of new "other" notes, creating parent if necessary
if request.POST.get('otherrights_note', '') != '':
# make new "other" record if it doesn't exist
if not createdOther:
try:
createdOther = models.RightsStatementOtherRightsInformation.objects.get(rightsstatement=createdRights)
except:
createdOther = models.RightsStatementOtherRightsInformation(rightsstatement=createdRights)
createdOther.save()
otherNote = models.RightsStatementOtherRightsInformationNote(rightsstatementotherrights=createdOther)
otherNote.otherrightsnote = request.POST.get('otherrights_note', '')
otherNote.save()
new_content_type_created = 'other'
# handle creation of new documentation identifiers
if request.POST.get('other_documentation_identifier_type', '') != '' or request.POST.get('other_documentation_identifier_value', '') != '' or request.POST.get('other_documentation_identifier_role', ''):
# make new other record if it doesn't exist
if not createdOther:
try:
createdOther = models.RightsStatementOtherRightsInformation.objects.get(rightsstatement=createdRights)
except:
createdOther = models.RightsStatementOtherRightsInformation(rightsstatement=createdRights)
createdOther.save()
otherDocIdentifier = models.RightsStatementOtherRightsDocumentationIdentifier(rightsstatementotherrights=createdOther)
otherDocIdentifier.otherrightsdocumentationidentifiertype = request.POST.get('other_documentation_identifier_type', '')
otherDocIdentifier.otherrightsdocumentationidentifiervalue = request.POST.get('other_documentation_identifier_value', '')
otherDocIdentifier.otherrightsdocumentationidentifierrole = request.POST.get('other_documentation_identifier_role', '')
otherDocIdentifier.save()
new_content_type_created = 'other'
if request.POST.get('next_button', '') != None and request.POST.get('next_button', '') != '':
return redirect('components.rights.views.%s_rights_grants_edit' % section, uuid, createdRights.pk)
else:
url = reverse('components.rights.views.%s_rights_edit' % section, args=[uuid, createdRights.pk])
try:
url = url + '?created=' + new_content_type_created
except:
pass
return redirect(url)
else:
copyrightFormset = CopyrightFormSet(instance=viewRights)
statuteFormset = StatuteFormSet(instance=viewRights)
licenseFormset = LicenseFormSet(instance=viewRights)
otherFormset = OtherFormSet(instance=viewRights)
# show what content's been created after a redirect
if request.GET.get('created', '') != '':
new_content_type_created = request.GET.get('created', '')
return render(request, 'rights/rights_edit.html', locals())
def rights_grants_edit(request, uuid, id, section='ingest'):
jobs = models.Job.objects.filter(sipuuid=uuid, subjobof='')
name = utils.get_directory_name_from_job(jobs)
viewRights = models.RightsStatement.objects.get(pk=id)
# determine how many empty forms should be shown for children
extra_grant_forms = 1
# create inline formsets for child elements
GrantFormSet = inlineformset_factory(
models.RightsStatement,
models.RightsStatementRightsGranted,
extra=extra_grant_forms,
can_delete=False,
form=forms.RightsGrantedForm
)
# handle form creation/saving
if request.method == 'POST':
grantFormset = GrantFormSet(request.POST, instance=viewRights)
grantFormset.save()
restrictionCreated = False
noteCreated = False
for form in grantFormset.forms:
grantCreated = False
# handle restriction creation for a parent that's a blank grant
if request.POST.get('new_rights_restriction_None', '') != '' and not form.instance.pk:
grantCreated = models.RightsStatementRightsGranted(rightsstatement=viewRights)
grantCreated.save()
restrictionCreated = models.RightsStatementRightsGrantedRestriction(rightsgranted=grantCreated)
restrictionCreated.restriction = request.POST.get('new_rights_restriction_None', '')
restrictionCreated.save()
else:
# handle restriction creation for a parent grant that already exists
if request.POST.get('new_rights_restriction_' + str(form.instance.pk), '') != '':
restrictionCreated = models.RightsStatementRightsGrantedRestriction(rightsgranted=form.instance)
restrictionCreated.restriction = request.POST.get('new_rights_restriction_' + str(form.instance.pk), '')
restrictionCreated.save()
# handle note creation for a parent that's a blank grant
if request.POST.get('new_rights_note_None', '') != '' and not form.instance.pk:
if not grantCreated:
grantCreated = models.RightsStatementRightsGranted(rightsstatement=viewRights)
grantCreated.save()
noteCreated = models.RightsStatementRightsGrantedNote(rightsgranted=grantCreated)
noteCreated.rightsgrantednote = request.POST.get('new_rights_note_None', '')
noteCreated.save()
else:
# handle note creation for a parent grant that already exists
if request.POST.get('new_rights_note_' + str(form.instance.pk), '') != '':
noteCreated = models.RightsStatementRightsGrantedNote(rightsgranted=form.instance)
noteCreated.rightsgrantednote = request.POST.get('new_rights_note_' + str(form.instance.pk), '')
noteCreated.save()
# handle restriction creation for a parent that's just been created
if request.POST.get('new_rights_restriction_None', '') != '' and not restrictionCreated:
restrictionCreated = models.RightsStatementRightsGrantedRestriction(rightsgranted=form.instance)
restrictionCreated.restriction = request.POST.get('new_rights_restriction_None', '')
restrictionCreated.save()
# handle note creation for a parent that's just been created
if request.POST.get('new_rights_note_None', '') != '' and not noteCreated:
noteCreated = models.RightsStatementRightsGrantedNote(rightsgranted=form.instance)
noteCreated.rightsgrantednote = request.POST.get('new_rights_note_None', '')
noteCreated.save()
# display (possibly revised) formset
grantFormset = GrantFormSet(instance=viewRights)
if request.method == 'POST':
if request.POST.get('next_button', '') != None and request.POST.get('next_button', '') != '':
return redirect('components.rights.views.%s_rights_list' % section, uuid)
else:
url = reverse('components.rights.views.%s_rights_grants_edit' % section, args=[uuid, viewRights.pk])
return redirect(url)
else:
return render(request, 'rights/rights_grants_edit.html', locals())
def rights_delete(request, uuid, id, section):
models.RightsStatement.objects.get(pk=id).delete()
return redirect('components.rights.views.%s_rights_list' % section, uuid)
def rights_grant_delete(request, uuid, id, section):
models.RightsStatementRightsGranted.objects.get(pk=id).delete()
return redirect('components.rights.views.%s_rights_list' % section, uuid)
def rights_holders_lookup(request, id):
try:
agent = models.RightsStatementLinkingAgentIdentifier.objects.get(pk=id)
result = agent.linkingagentidentifiervalue + ' [' + str(agent.id) + ']'
except:
result = ''
return HttpResponse(result)
def rights_holders_autocomplete(request):
search_text = ''
try:
search_text = request.REQUEST['text']
except Exception: pass
response = {}
agents = models.RightsStatementLinkingAgentIdentifier.objects.filter(linkingagentidentifiervalue__icontains=search_text)
for agent in agents:
value = agent.linkingagentidentifiervalue + ' [' + str(agent.id) + ']'
response[value] = value
return helpers.json_response(response)
def rights_list(request, uuid, section):
jobs = models.Job.objects.filter(sipuuid=uuid, subjobof='')
name = utils.get_directory_name_from_job(jobs)
# See MetadataAppliesToTypes table
types = {'transfer': 'Transfer', 'ingest': 'SIP', 'file': 'File'}
type_id = helpers.get_metadata_type_id_by_description(types[section])
grants = models.RightsStatementRightsGranted.objects.filter(
rightsstatement__metadataappliestotype=type_id,
rightsstatement__metadataappliestoidentifier__exact=uuid
)
# When listing ingest rights we also want to show transfer rights
# The only way I've found to get the related transfer of a SIP is looking into the File table
transfer_grants = None
if section is "ingest":
try:
transfer_uuids = models.File.objects.filter(sip_id=uuid, removedtime__isnull=True, transfer_id__isnull=False).values_list('transfer', flat=True).distinct()
transfer_grants = models.RightsStatementRightsGranted.objects.filter(
rightsstatement__metadataappliestotype__description=types['transfer'],
rightsstatement__metadataappliestoidentifier__in=transfer_uuids
)
except Exception:
LOGGER.exception('Error fetching Transfer rights')
return render(request, 'rights/rights_list.html', {
'grants': grants,
'jobs': jobs,
'name': name,
'section': section,
'transfer_grants': transfer_grants,
'uuid': uuid,
})
|
agpl-3.0
|
[
3,
961,
570,
365,
1777,
402,
19521,
1912,
391,
15922,
14,
199,
3,
199,
3,
1898,
7129,
13,
6965,
1952,
266,
7783,
1061,
15285,
3277,
14,
665,
1014,
921,
285,
266,
7783,
1061,
14,
957,
30,
199,
3,
199,
3,
19521,
1912,
391,
15922,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
652,
1334,
314,
2895,
402,
314,
1664,
4265,
1696,
1684,
844,
465,
3267,
701,
199,
3,
314,
2868,
2290,
2752,
12,
1902,
1015,
650,
402,
314,
844,
12,
503,
199,
3,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
19521,
1912,
391,
15922,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
199,
3,
1664,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
1696,
1684,
844,
199,
3,
3180,
543,
19521,
1912,
391,
15922,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
199,
646,
2050,
199,
646,
295,
199,
199,
504,
1639,
14,
1018,
14,
16522,
492,
3837,
199,
504,
1639,
14,
3351,
14,
992,
492,
8308,
10724,
63,
3702,
199,
504,
1639,
14,
1014,
492,
6183,
199,
504,
1639,
14,
17469,
492,
4660,
12,
3795,
199,
504,
1639,
14,
1160,
492,
22538,
199,
199,
504,
7323,
492,
20419,
199,
504,
7323,
492,
10897,
199,
504,
7323,
14,
17307,
492,
4513,
199,
504,
5914,
492,
3778,
199,
504,
2446,
492,
1709,
199,
199,
10186,
275,
2050,
14,
5572,
360,
6404,
391,
15922,
14,
9743,
358,
199,
199,
624,
768,
23653,
23653,
23653,
23653,
23653,
23653,
23653,
23653,
7492,
489,
5924,
13,
2407,
272,
768,
23653,
23653,
23653,
23653,
23653,
23653,
23653,
23653,
7492,
408,
199,
199,
318,
9307,
63,
17307,
63,
513,
8,
1069,
12,
5377,
304,
272,
372,
4481,
63,
513,
8,
1069,
12,
5377,
12,
283,
9609,
358,
199,
199,
318,
9307,
63,
17307,
63,
3773,
8,
1069,
12,
5377,
12,
1305,
29,
403,
304,
272,
372,
4481,
63,
3773,
8,
1069,
12,
5377,
12,
1305,
12,
283,
9609,
358,
199,
199,
318,
9307,
63,
17307,
63,
1807,
8,
1069,
12,
5377,
12,
1305,
304,
272,
372,
4481,
63,
1807,
8,
1069,
12,
5377,
12,
1305,
12,
283,
9609,
358,
199,
199,
318,
9307,
63,
17362,
63,
1807,
63,
1100,
8,
1069,
12,
5377,
12,
1305,
304,
272,
8457,
275,
283,
5392,
4481,
16085,
14069,
272,
9311,
63,
633,
275,
3837,
480,
4608,
14,
17307,
14,
4196,
14,
9609,
63,
17307,
63,
513,
401,
1249,
1524,
2580,
566,
272,
372,
22538,
8,
1069,
12,
791,
1287,
356,
283,
5392,
297,
283,
7650,
356,
8457,
12,
283,
6406,
63,
633,
356,
9311,
63,
633,
1552,
199,
199,
32,
11582,
14,
9548,
63,
2427,
360,
4129,
63,
9548,
14,
1360,
297,
9307,
63,
17362,
63,
1807,
63,
1100,
9,
199,
318,
9307,
63,
17307,
63,
17362,
63,
1807,
8,
1069,
12,
5377,
12,
1305,
304,
272,
372,
4481,
63,
17362,
63,
1807,
8,
1069,
12,
5377,
12,
1305,
12,
283,
9609,
358,
199,
199,
318,
9307,
63,
17307,
63,
2587,
2285,
63,
3773,
8,
1069,
12,
5377,
12,
1305,
304,
272,
372,
4481,
63,
2587,
2285,
63,
3773,
8,
1069,
12,
5377,
12,
1305,
12,
283,
9609,
358,
199,
199,
318,
315,
3199,
63,
17307,
63,
513,
8,
1069,
12,
5377,
304,
272,
372,
4481,
63,
513,
8,
1069,
12,
5377,
12,
283,
262,
3199,
358,
199,
199,
318,
315,
3199,
63,
17307,
63,
3773,
8,
1069,
12,
5377,
12,
1305,
29,
403,
304,
272,
372,
4481,
63,
3773,
8,
1069,
12,
5377,
12,
1305,
12,
283,
262,
3199,
358,
199,
199,
318,
315,
3199,
63,
17307,
63,
1807,
8,
1069,
12,
5377,
12,
1305,
304,
272,
372,
4481,
63,
1807,
8,
1069,
12,
5377,
12,
1305,
12,
283,
262,
3199,
358,
199,
199,
318,
315,
3199,
63,
17362,
63,
1807,
63,
1100,
8,
1069,
12,
5377,
12,
1305,
304,
272,
8457,
275,
283,
5392,
4481,
16085,
14069,
272,
9311,
63,
633,
275,
3837,
480,
4608,
14,
17307,
14,
4196,
14,
262,
3199,
63,
17307,
63,
513,
401,
1249,
1524,
2580,
566,
272,
372,
22538,
8,
1069,
12,
791,
1287,
356,
283,
5392,
297,
283,
7650,
356,
8457,
12,
283,
6406,
63,
633,
356,
9311,
63,
633,
1552,
199,
199,
32,
11582,
14,
9548,
63,
2427,
360,
4129,
63,
9548,
14,
1360,
297,
315,
3199,
63,
17362,
63,
1807,
63,
1100,
9,
199,
318,
315,
3199,
63,
17307,
63,
17362,
63,
1807,
8,
1069,
12,
5377,
12,
1305,
304,
272,
372,
4481,
63,
17362,
63,
1807,
8,
1069,
12,
5377,
12,
1305,
12,
283,
262,
3199,
358,
199,
199,
318,
315,
3199,
63,
17307,
63,
2587,
2285,
63,
3773,
8,
1069,
12,
5377,
12,
1305,
304,
272,
372,
4481,
63,
2587,
2285,
63,
3773,
8,
1069,
12,
5377,
12,
1305,
12,
283,
262,
3199,
358,
199,
199,
318,
4481,
63,
1122,
63,
4054,
63,
344,
8,
1210,
304,
272,
372,
378,
272,
340,
1324,
508,
8061,
267,
6631,
1304,
275,
378,
272,
587,
26,
267,
6631,
7963,
275,
1324,
267,
862,
26,
288,
1109,
8,
4054,
7963,
9,
288,
6631,
1304,
275,
1109,
8,
4054,
7963,
9,
267,
871,
1722,
26,
288,
6631,
497,
275,
295,
14,
2014,
14097,
2795,
2862,
59,
2961,
68,
10,
2862,
10374,
288,
1336,
275,
6631,
497,
14,
1431,
8,
4054,
7963,
9,
288,
340,
1336,
26,
355,
6631,
1304,
275,
1336,
14,
923,
8,
18,
9,
288,
587,
26,
355,
6631,
1304,
275,
378,
272,
372,
6631,
1304,
199,
199,
318,
4481,
63,
3773,
8,
1069,
12,
5377,
12,
1305,
29,
403,
12,
3420,
534,
262,
3199,
735,
272,
9643,
275,
1709,
14,
6694,
14,
1462,
14,
1541,
8,
17839,
2580,
29,
2580,
12,
1007,
743,
656,
70,
13275,
272,
536,
275,
3778,
14,
362,
63,
3619,
63,
354,
63,
504,
63,
2423,
8,
6920,
9,
339,
327,
3305,
9297,
4052,
4928,
402,
892,
1564,
12,
340,
1263,
12,
965,
2757,
2737,
272,
892,
63
] |
[
961,
570,
365,
1777,
402,
19521,
1912,
391,
15922,
14,
199,
3,
199,
3,
1898,
7129,
13,
6965,
1952,
266,
7783,
1061,
15285,
3277,
14,
665,
1014,
921,
285,
266,
7783,
1061,
14,
957,
30,
199,
3,
199,
3,
19521,
1912,
391,
15922,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
652,
1334,
314,
2895,
402,
314,
1664,
4265,
1696,
1684,
844,
465,
3267,
701,
199,
3,
314,
2868,
2290,
2752,
12,
1902,
1015,
650,
402,
314,
844,
12,
503,
199,
3,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
19521,
1912,
391,
15922,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
199,
3,
1664,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
1696,
1684,
844,
199,
3,
3180,
543,
19521,
1912,
391,
15922,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
199,
646,
2050,
199,
646,
295,
199,
199,
504,
1639,
14,
1018,
14,
16522,
492,
3837,
199,
504,
1639,
14,
3351,
14,
992,
492,
8308,
10724,
63,
3702,
199,
504,
1639,
14,
1014,
492,
6183,
199,
504,
1639,
14,
17469,
492,
4660,
12,
3795,
199,
504,
1639,
14,
1160,
492,
22538,
199,
199,
504,
7323,
492,
20419,
199,
504,
7323,
492,
10897,
199,
504,
7323,
14,
17307,
492,
4513,
199,
504,
5914,
492,
3778,
199,
504,
2446,
492,
1709,
199,
199,
10186,
275,
2050,
14,
5572,
360,
6404,
391,
15922,
14,
9743,
358,
199,
199,
624,
768,
23653,
23653,
23653,
23653,
23653,
23653,
23653,
23653,
7492,
489,
5924,
13,
2407,
272,
768,
23653,
23653,
23653,
23653,
23653,
23653,
23653,
23653,
7492,
408,
199,
199,
318,
9307,
63,
17307,
63,
513,
8,
1069,
12,
5377,
304,
272,
372,
4481,
63,
513,
8,
1069,
12,
5377,
12,
283,
9609,
358,
199,
199,
318,
9307,
63,
17307,
63,
3773,
8,
1069,
12,
5377,
12,
1305,
29,
403,
304,
272,
372,
4481,
63,
3773,
8,
1069,
12,
5377,
12,
1305,
12,
283,
9609,
358,
199,
199,
318,
9307,
63,
17307,
63,
1807,
8,
1069,
12,
5377,
12,
1305,
304,
272,
372,
4481,
63,
1807,
8,
1069,
12,
5377,
12,
1305,
12,
283,
9609,
358,
199,
199,
318,
9307,
63,
17362,
63,
1807,
63,
1100,
8,
1069,
12,
5377,
12,
1305,
304,
272,
8457,
275,
283,
5392,
4481,
16085,
14069,
272,
9311,
63,
633,
275,
3837,
480,
4608,
14,
17307,
14,
4196,
14,
9609,
63,
17307,
63,
513,
401,
1249,
1524,
2580,
566,
272,
372,
22538,
8,
1069,
12,
791,
1287,
356,
283,
5392,
297,
283,
7650,
356,
8457,
12,
283,
6406,
63,
633,
356,
9311,
63,
633,
1552,
199,
199,
32,
11582,
14,
9548,
63,
2427,
360,
4129,
63,
9548,
14,
1360,
297,
9307,
63,
17362,
63,
1807,
63,
1100,
9,
199,
318,
9307,
63,
17307,
63,
17362,
63,
1807,
8,
1069,
12,
5377,
12,
1305,
304,
272,
372,
4481,
63,
17362,
63,
1807,
8,
1069,
12,
5377,
12,
1305,
12,
283,
9609,
358,
199,
199,
318,
9307,
63,
17307,
63,
2587,
2285,
63,
3773,
8,
1069,
12,
5377,
12,
1305,
304,
272,
372,
4481,
63,
2587,
2285,
63,
3773,
8,
1069,
12,
5377,
12,
1305,
12,
283,
9609,
358,
199,
199,
318,
315,
3199,
63,
17307,
63,
513,
8,
1069,
12,
5377,
304,
272,
372,
4481,
63,
513,
8,
1069,
12,
5377,
12,
283,
262,
3199,
358,
199,
199,
318,
315,
3199,
63,
17307,
63,
3773,
8,
1069,
12,
5377,
12,
1305,
29,
403,
304,
272,
372,
4481,
63,
3773,
8,
1069,
12,
5377,
12,
1305,
12,
283,
262,
3199,
358,
199,
199,
318,
315,
3199,
63,
17307,
63,
1807,
8,
1069,
12,
5377,
12,
1305,
304,
272,
372,
4481,
63,
1807,
8,
1069,
12,
5377,
12,
1305,
12,
283,
262,
3199,
358,
199,
199,
318,
315,
3199,
63,
17362,
63,
1807,
63,
1100,
8,
1069,
12,
5377,
12,
1305,
304,
272,
8457,
275,
283,
5392,
4481,
16085,
14069,
272,
9311,
63,
633,
275,
3837,
480,
4608,
14,
17307,
14,
4196,
14,
262,
3199,
63,
17307,
63,
513,
401,
1249,
1524,
2580,
566,
272,
372,
22538,
8,
1069,
12,
791,
1287,
356,
283,
5392,
297,
283,
7650,
356,
8457,
12,
283,
6406,
63,
633,
356,
9311,
63,
633,
1552,
199,
199,
32,
11582,
14,
9548,
63,
2427,
360,
4129,
63,
9548,
14,
1360,
297,
315,
3199,
63,
17362,
63,
1807,
63,
1100,
9,
199,
318,
315,
3199,
63,
17307,
63,
17362,
63,
1807,
8,
1069,
12,
5377,
12,
1305,
304,
272,
372,
4481,
63,
17362,
63,
1807,
8,
1069,
12,
5377,
12,
1305,
12,
283,
262,
3199,
358,
199,
199,
318,
315,
3199,
63,
17307,
63,
2587,
2285,
63,
3773,
8,
1069,
12,
5377,
12,
1305,
304,
272,
372,
4481,
63,
2587,
2285,
63,
3773,
8,
1069,
12,
5377,
12,
1305,
12,
283,
262,
3199,
358,
199,
199,
318,
4481,
63,
1122,
63,
4054,
63,
344,
8,
1210,
304,
272,
372,
378,
272,
340,
1324,
508,
8061,
267,
6631,
1304,
275,
378,
272,
587,
26,
267,
6631,
7963,
275,
1324,
267,
862,
26,
288,
1109,
8,
4054,
7963,
9,
288,
6631,
1304,
275,
1109,
8,
4054,
7963,
9,
267,
871,
1722,
26,
288,
6631,
497,
275,
295,
14,
2014,
14097,
2795,
2862,
59,
2961,
68,
10,
2862,
10374,
288,
1336,
275,
6631,
497,
14,
1431,
8,
4054,
7963,
9,
288,
340,
1336,
26,
355,
6631,
1304,
275,
1336,
14,
923,
8,
18,
9,
288,
587,
26,
355,
6631,
1304,
275,
378,
272,
372,
6631,
1304,
199,
199,
318,
4481,
63,
3773,
8,
1069,
12,
5377,
12,
1305,
29,
403,
12,
3420,
534,
262,
3199,
735,
272,
9643,
275,
1709,
14,
6694,
14,
1462,
14,
1541,
8,
17839,
2580,
29,
2580,
12,
1007,
743,
656,
70,
13275,
272,
536,
275,
3778,
14,
362,
63,
3619,
63,
354,
63,
504,
63,
2423,
8,
6920,
9,
339,
327,
3305,
9297,
4052,
4928,
402,
892,
1564,
12,
340,
1263,
12,
965,
2757,
2737,
272,
892,
63,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
brianmckenna/sci-wms
|
wms/migrations/0003_auto_20150302_1510.py
|
2
|
2289
|
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import os
from django.conf import settings
from django.db import migrations
def forwards(apps, schema_editor):
resource_path = os.path.join(settings.PROJECT_ROOT, '..', 'wms', 'resources')
Dataset = apps.get_model("wms", "Dataset")
d1 = Dataset(uri = os.path.join(resource_path, "nasa_scb20111015.nc"),
name = "CGridTest",
title = "CGrid Test dataset",
abstract = "CGrid Test data set for sci-wms",
display_all_timesteps = False,
keep_up_to_date = False,
test_layer = "u,v",
test_style = "facets_average_jet_None_None_grid_False" )
d1.save()
d2 = Dataset(uri = os.path.join(resource_path, "201220109.nc"),
name = "UGridTest",
title = "UGrid Test dataset",
abstract = "UGrid Test data set for sci-wms",
display_all_timesteps = False,
keep_up_to_date = False,
test_layer = "u,v",
test_style = "facets_average_jet_None_None_node_False" )
d2.save()
VirtualLayer = apps.get_model('wms', 'VirtualLayer')
uv = VirtualLayer(layer="U,V vectors", layer_expression="u,v")
uv.save()
uv.datasets.add(d1)
uv.datasets.add(d2)
uv.save()
bands = VirtualLayer(layer="RGB Band Images", layer_expression="Band1*Band2*Band3")
bands.save()
def backwards(apps, schema_editor):
Dataset = apps.get_model("wms", "Dataset")
Dataset.objects.filter(name='CGridTest').all().delete()
Dataset.objects.filter(name='UGridTest').all().delete()
VirtualLayer = apps.get_model('wms', 'VirtualLayer')
VirtualLayer.objects.filter(layer_expression='u,v').all().delete()
VirtualLayer.objects.filter(layer_expression="Band1*Band2*Band3").all().delete()
class Migration(migrations.Migration):
dependencies = [
('wms', '0002_auto_20150302_1106'),
]
operations = [
migrations.RunPython(forwards, reverse_code=backwards),
]
|
gpl-3.0
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
504,
636,
2443,
363,
492,
2649,
63,
5955,
199,
646,
747,
199,
199,
504,
1639,
14,
2190,
492,
2202,
199,
504,
1639,
14,
697,
492,
6180,
421,
199,
318,
17465,
8,
5181,
12,
4177,
63,
7515,
304,
272,
2073,
63,
515,
275,
747,
14,
515,
14,
904,
8,
1751,
14,
10797,
63,
5441,
12,
19155,
283,
30297,
297,
283,
4435,
358,
339,
20284,
275,
8686,
14,
362,
63,
1238,
480,
30297,
401,
298,
9271,
531,
272,
366,
17,
275,
20284,
8,
2302,
7861,
275,
747,
14,
515,
14,
904,
8,
1927,
63,
515,
12,
298,
24292,
65,
63,
551,
66,
1797,
845,
11164,
14,
7966,
1288,
326,
536,
8295,
275,
298,
4064,
1677,
774,
401,
326,
2538,
463,
275,
298,
4064,
1677,
1379,
4789,
401,
326,
9006,
4519,
275,
298,
4064,
1677,
1379,
666,
663,
367,
6276,
13,
30297,
401,
326,
2929,
63,
452,
63,
521,
5895,
275,
756,
12,
326,
4215,
63,
384,
63,
475,
63,
602,
755,
275,
756,
12,
326,
511,
63,
1897,
3322,
275,
298,
85,
12,
86,
401,
326,
511,
63,
2487,
3322,
275,
298,
1409,
1086,
63,
8536,
63,
74,
386,
63,
403,
63,
403,
63,
3825,
63,
797,
2,
776,
272,
366,
17,
14,
2117,
342,
339,
366,
18,
275,
20284,
8,
2302,
7861,
275,
747,
14,
515,
14,
904,
8,
1927,
63,
515,
12,
298,
1797,
1081,
614,
1643,
14,
7966,
1288,
326,
536,
8295,
275,
298,
53,
7900,
774,
401,
326,
2538,
463,
275,
298,
53,
7900,
1379,
4789,
401,
326,
9006,
4519,
275,
298,
53,
7900,
1379,
666,
663,
367,
6276,
13,
30297,
401,
326,
2929,
63,
452,
63,
521,
5895,
275,
756,
12,
326,
4215,
63,
384,
63,
475,
63,
602,
755,
275,
756,
12,
326,
511,
63,
1897,
3322,
275,
298,
85,
12,
86,
401,
326,
511,
63,
2487,
3322,
275,
298,
1409,
1086,
63,
8536,
63,
74,
386,
63,
403,
63,
403,
63,
932,
63,
797,
2,
776,
272,
366,
18,
14,
2117,
342,
339,
13311,
5003,
275,
8686,
14,
362,
63,
1238,
360,
30297,
297,
283,
8735,
5003,
358,
272,
20879,
275,
13311,
5003,
8,
1897,
628,
53,
12,
54,
11102,
401,
4045,
63,
5599,
628,
85,
12,
86,
531,
272,
20879,
14,
2117,
342,
272,
20879,
14,
12281,
14,
525,
8,
68,
17,
9,
272,
20879,
14,
12281,
14,
525,
8,
68,
18,
9,
272,
20879,
14,
2117,
342,
339,
30565,
275,
13311,
5003,
8,
1897,
628,
12067,
27709,
32658,
401,
4045,
63,
5599,
628,
11675,
17,
10,
11675,
18,
10,
11675,
19,
531,
272,
30565,
14,
2117,
342,
421,
199,
318,
8552,
8,
5181,
12,
4177,
63,
7515,
304,
272,
20284,
275,
8686,
14,
362,
63,
1238,
480,
30297,
401,
298,
9271,
531,
272,
20284,
14,
1462,
14,
1541,
8,
354,
534,
4064,
1677,
774,
1959,
452,
1252,
1807,
342,
272,
20284,
14,
1462,
14,
1541,
8,
354,
534,
53,
7900,
774,
1959,
452,
1252,
1807,
342,
339,
13311,
5003,
275,
8686,
14,
362,
63,
1238,
360,
30297,
297,
283,
8735,
5003,
358,
272,
13311,
5003,
14,
1462,
14,
1541,
8,
1897,
63,
5599,
534,
85,
12,
86,
1959,
452,
1252,
1807,
342,
272,
13311,
5003,
14,
1462,
14,
1541,
8,
1897,
63,
5599,
628,
11675,
17,
10,
11675,
18,
10,
11675,
19,
3471,
452,
1252,
1807,
342,
421,
199,
533,
12090,
8,
7685,
14,
9816,
304,
339,
5124,
275,
359,
267,
661,
30297,
297,
283,
9425,
63,
2495,
63,
1797,
1400,
8551,
63,
6019,
22,
659,
272,
1622,
339,
5331,
275,
359,
267,
6180,
14,
2540,
4718,
8,
19159,
12,
3837,
63,
600,
29,
22269,
395,
272,
1622,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
504,
636,
2443,
363,
492,
2649,
63,
5955,
199,
646,
747,
199,
199,
504,
1639,
14,
2190,
492,
2202,
199,
504,
1639,
14,
697,
492,
6180,
421,
199,
318,
17465,
8,
5181,
12,
4177,
63,
7515,
304,
272,
2073,
63,
515,
275,
747,
14,
515,
14,
904,
8,
1751,
14,
10797,
63,
5441,
12,
19155,
283,
30297,
297,
283,
4435,
358,
339,
20284,
275,
8686,
14,
362,
63,
1238,
480,
30297,
401,
298,
9271,
531,
272,
366,
17,
275,
20284,
8,
2302,
7861,
275,
747,
14,
515,
14,
904,
8,
1927,
63,
515,
12,
298,
24292,
65,
63,
551,
66,
1797,
845,
11164,
14,
7966,
1288,
326,
536,
8295,
275,
298,
4064,
1677,
774,
401,
326,
2538,
463,
275,
298,
4064,
1677,
1379,
4789,
401,
326,
9006,
4519,
275,
298,
4064,
1677,
1379,
666,
663,
367,
6276,
13,
30297,
401,
326,
2929,
63,
452,
63,
521,
5895,
275,
756,
12,
326,
4215,
63,
384,
63,
475,
63,
602,
755,
275,
756,
12,
326,
511,
63,
1897,
3322,
275,
298,
85,
12,
86,
401,
326,
511,
63,
2487,
3322,
275,
298,
1409,
1086,
63,
8536,
63,
74,
386,
63,
403,
63,
403,
63,
3825,
63,
797,
2,
776,
272,
366,
17,
14,
2117,
342,
339,
366,
18,
275,
20284,
8,
2302,
7861,
275,
747,
14,
515,
14,
904,
8,
1927,
63,
515,
12,
298,
1797,
1081,
614,
1643,
14,
7966,
1288,
326,
536,
8295,
275,
298,
53,
7900,
774,
401,
326,
2538,
463,
275,
298,
53,
7900,
1379,
4789,
401,
326,
9006,
4519,
275,
298,
53,
7900,
1379,
666,
663,
367,
6276,
13,
30297,
401,
326,
2929,
63,
452,
63,
521,
5895,
275,
756,
12,
326,
4215,
63,
384,
63,
475,
63,
602,
755,
275,
756,
12,
326,
511,
63,
1897,
3322,
275,
298,
85,
12,
86,
401,
326,
511,
63,
2487,
3322,
275,
298,
1409,
1086,
63,
8536,
63,
74,
386,
63,
403,
63,
403,
63,
932,
63,
797,
2,
776,
272,
366,
18,
14,
2117,
342,
339,
13311,
5003,
275,
8686,
14,
362,
63,
1238,
360,
30297,
297,
283,
8735,
5003,
358,
272,
20879,
275,
13311,
5003,
8,
1897,
628,
53,
12,
54,
11102,
401,
4045,
63,
5599,
628,
85,
12,
86,
531,
272,
20879,
14,
2117,
342,
272,
20879,
14,
12281,
14,
525,
8,
68,
17,
9,
272,
20879,
14,
12281,
14,
525,
8,
68,
18,
9,
272,
20879,
14,
2117,
342,
339,
30565,
275,
13311,
5003,
8,
1897,
628,
12067,
27709,
32658,
401,
4045,
63,
5599,
628,
11675,
17,
10,
11675,
18,
10,
11675,
19,
531,
272,
30565,
14,
2117,
342,
421,
199,
318,
8552,
8,
5181,
12,
4177,
63,
7515,
304,
272,
20284,
275,
8686,
14,
362,
63,
1238,
480,
30297,
401,
298,
9271,
531,
272,
20284,
14,
1462,
14,
1541,
8,
354,
534,
4064,
1677,
774,
1959,
452,
1252,
1807,
342,
272,
20284,
14,
1462,
14,
1541,
8,
354,
534,
53,
7900,
774,
1959,
452,
1252,
1807,
342,
339,
13311,
5003,
275,
8686,
14,
362,
63,
1238,
360,
30297,
297,
283,
8735,
5003,
358,
272,
13311,
5003,
14,
1462,
14,
1541,
8,
1897,
63,
5599,
534,
85,
12,
86,
1959,
452,
1252,
1807,
342,
272,
13311,
5003,
14,
1462,
14,
1541,
8,
1897,
63,
5599,
628,
11675,
17,
10,
11675,
18,
10,
11675,
19,
3471,
452,
1252,
1807,
342,
421,
199,
533,
12090,
8,
7685,
14,
9816,
304,
339,
5124,
275,
359,
267,
661,
30297,
297,
283,
9425,
63,
2495,
63,
1797,
1400,
8551,
63,
6019,
22,
659,
272,
1622,
339,
5331,
275,
359,
267,
6180,
14,
2540,
4718,
8,
19159,
12,
3837,
63,
600,
29,
22269,
395,
272,
1622,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
taedla01/MissionPlanner
|
Lib/xdrlib.py
|
55
|
5794
|
"""Implements (a subset of) Sun XDR -- eXternal Data Representation.
See: RFC 1014
"""
import struct
try:
from cStringIO import StringIO as _StringIO
except ImportError:
from StringIO import StringIO as _StringIO
__all__ = ["Error", "Packer", "Unpacker", "ConversionError"]
# exceptions
class Error(Exception):
"""Exception class for this module. Use:
except xdrlib.Error, var:
# var has the Error instance for the exception
Public ivars:
msg -- contains the message
"""
def __init__(self, msg):
self.msg = msg
def __repr__(self):
return repr(self.msg)
def __str__(self):
return str(self.msg)
class ConversionError(Error):
pass
class Packer:
"""Pack various data representations into a buffer."""
def __init__(self):
self.reset()
def reset(self):
self.__buf = _StringIO()
def get_buffer(self):
return self.__buf.getvalue()
# backwards compatibility
get_buf = get_buffer
def pack_uint(self, x):
self.__buf.write(struct.pack('>L', x))
def pack_int(self, x):
self.__buf.write(struct.pack('>l', x))
pack_enum = pack_int
def pack_bool(self, x):
if x: self.__buf.write('\0\0\0\1')
else: self.__buf.write('\0\0\0\0')
def pack_uhyper(self, x):
self.pack_uint(x>>32 & 0xffffffffL)
self.pack_uint(x & 0xffffffffL)
pack_hyper = pack_uhyper
def pack_float(self, x):
try: self.__buf.write(struct.pack('>f', x))
except struct.error, msg:
raise ConversionError, msg
def pack_double(self, x):
try: self.__buf.write(struct.pack('>d', x))
except struct.error, msg:
raise ConversionError, msg
def pack_fstring(self, n, s):
if n < 0:
raise ValueError, 'fstring size must be nonnegative'
data = s[:n]
n = ((n+3)//4)*4
data = data + (n - len(data)) * '\0'
self.__buf.write(data)
pack_fopaque = pack_fstring
def pack_string(self, s):
n = len(s)
self.pack_uint(n)
self.pack_fstring(n, s)
pack_opaque = pack_string
pack_bytes = pack_string
def pack_list(self, list, pack_item):
for item in list:
self.pack_uint(1)
pack_item(item)
self.pack_uint(0)
def pack_farray(self, n, list, pack_item):
if len(list) != n:
raise ValueError, 'wrong array size'
for item in list:
pack_item(item)
def pack_array(self, list, pack_item):
n = len(list)
self.pack_uint(n)
self.pack_farray(n, list, pack_item)
class Unpacker:
"""Unpacks various data representations from the given buffer."""
def __init__(self, data):
self.reset(data)
def reset(self, data):
self.__buf = data
self.__pos = 0
def get_position(self):
return self.__pos
def set_position(self, position):
self.__pos = position
def get_buffer(self):
return self.__buf
def done(self):
if self.__pos < len(self.__buf):
raise Error('unextracted data remains')
def unpack_uint(self):
i = self.__pos
self.__pos = j = i+4
data = self.__buf[i:j]
if len(data) < 4:
raise EOFError
x = struct.unpack('>L', data)[0]
try:
return int(x)
except OverflowError:
return x
def unpack_int(self):
i = self.__pos
self.__pos = j = i+4
data = self.__buf[i:j]
if len(data) < 4:
raise EOFError
return struct.unpack('>l', data)[0]
unpack_enum = unpack_int
def unpack_bool(self):
return bool(self.unpack_int())
def unpack_uhyper(self):
hi = self.unpack_uint()
lo = self.unpack_uint()
return long(hi)<<32 | lo
def unpack_hyper(self):
x = self.unpack_uhyper()
if x >= 0x8000000000000000L:
x = x - 0x10000000000000000L
return x
def unpack_float(self):
i = self.__pos
self.__pos = j = i+4
data = self.__buf[i:j]
if len(data) < 4:
raise EOFError
return struct.unpack('>f', data)[0]
def unpack_double(self):
i = self.__pos
self.__pos = j = i+8
data = self.__buf[i:j]
if len(data) < 8:
raise EOFError
return struct.unpack('>d', data)[0]
def unpack_fstring(self, n):
if n < 0:
raise ValueError, 'fstring size must be nonnegative'
i = self.__pos
j = i + (n+3)//4*4
if j > len(self.__buf):
raise EOFError
self.__pos = j
return self.__buf[i:i+n]
unpack_fopaque = unpack_fstring
def unpack_string(self):
n = self.unpack_uint()
return self.unpack_fstring(n)
unpack_opaque = unpack_string
unpack_bytes = unpack_string
def unpack_list(self, unpack_item):
list = []
while 1:
x = self.unpack_uint()
if x == 0: break
if x != 1:
raise ConversionError, '0 or 1 expected, got %r' % (x,)
item = unpack_item()
list.append(item)
return list
def unpack_farray(self, n, unpack_item):
list = []
for i in range(n):
list.append(unpack_item())
return list
def unpack_array(self, unpack_item):
n = self.unpack_uint()
return self.unpack_farray(n, unpack_item)
|
gpl-3.0
|
[
624,
29452,
334,
65,
10026,
402,
9,
25625,
1323,
4564,
1553,
325,
56,
2147,
3918,
17634,
425,
14,
2999,
199,
9295,
26,
7329,
413,
10752,
2999,
199,
624,
2999,
199,
646,
2702,
202,
199,
893,
26,
1128,
687,
15073,
492,
5228,
465,
485,
6424,
202,
199,
2590,
3545,
26,
1128,
687,
5228,
492,
5228,
465,
485,
6424,
2999,
199,
363,
452,
363,
275,
2097,
547,
401,
298,
2305,
281,
401,
298,
26472,
281,
401,
298,
20403,
547,
937,
2999,
199,
3,
4967,
202,
199,
533,
4520,
8,
1726,
304,
1128,
408,
1726,
1021,
367,
642,
859,
14,
3645,
26,
2958,
871,
671,
5012,
773,
14,
547,
12,
2729,
26,
1039,
327,
2729,
965,
314,
4520,
1256,
367,
314,
1919,
2958,
1684,
284,
2936,
26,
1039,
1499,
1553,
3509,
314,
1245,
2958,
408,
1128,
347,
636,
826,
721,
277,
12,
1499,
304,
1039,
291,
14,
1328,
275,
1499,
1128,
347,
636,
2722,
721,
277,
304,
1039,
372,
4700,
8,
277,
14,
1328,
9,
1128,
347,
636,
495,
721,
277,
304,
1039,
372,
620,
8,
277,
14,
1328,
9,
8065,
199,
533,
1448,
1023,
547,
8,
547,
304,
1128,
986,
1223,
8065,
199,
533,
9954,
281,
26,
1128,
408,
2305,
7750,
666,
30580,
1901,
282,
3335,
1041,
2958,
347,
636,
826,
721,
277,
304,
1039,
291,
14,
3958,
342,
2958,
347,
5305,
8,
277,
304,
1039,
291,
855,
1436,
275,
485,
6424,
342,
2958,
347,
664,
63,
2738,
8,
277,
304,
1039,
372,
291,
855,
1436,
14,
7150,
342,
1128,
327,
8552,
7163,
1128,
664,
63,
1436,
275,
664,
63,
2738,
2958,
347,
1706,
63,
1635,
8,
277,
12,
671,
304,
1039,
291,
855,
1436,
14,
952,
8,
1820,
14,
1389,
16099,
44,
297,
671,
430,
2958,
347,
1706,
63,
442,
8,
277,
12,
671,
304,
1039,
291,
855,
1436,
14,
952,
8,
1820,
14,
1389,
16099,
76,
297,
671,
430,
2958,
1706,
63,
4869,
275,
1706,
63,
442,
2958,
347,
1706,
63,
2245,
8,
277,
12,
671,
304,
1039,
340,
671,
26,
291,
855,
1436,
14,
952,
2258,
16,
60,
16,
60,
16,
60,
17,
358,
1039,
587,
26,
291,
855,
1436,
14,
952,
2258,
16,
60,
16,
60,
16,
60,
16,
358,
2958,
347,
1706,
63,
85,
9547,
8,
277,
12,
671,
304,
1039,
291,
14,
1389,
63,
1635,
8,
88,
1140,
708,
1253,
378,
21870,
44,
9,
1039,
291,
14,
1389,
63,
1635,
8,
88,
1253,
378,
21870,
44,
9,
2958,
1706,
63,
9547,
275,
1706,
63,
85,
9547,
2958,
347,
1706,
63,
1609,
8,
277,
12,
671,
304,
1039,
862,
26,
291,
855,
1436,
14,
952,
8,
1820,
14,
1389,
16099,
70,
297,
671,
430,
1039,
871,
2702,
14,
705,
12,
1499,
26,
1675,
746,
1448,
1023,
547,
12,
1499,
2958,
347,
1706,
63,
3157,
8,
277,
12,
671,
304,
1039,
862,
26,
291,
855,
1436,
14,
952,
8,
1820,
14,
1389,
16099,
68,
297,
671,
430,
1039,
871,
2702,
14,
705,
12,
1499,
26,
1675,
746,
1448,
1023,
547,
12,
1499,
2958,
347,
1706,
63,
70,
875,
8,
277,
12,
302,
12,
308,
304,
1039,
340,
302,
665,
378,
26,
1675,
746,
1722,
12,
283,
70,
875,
1568,
1471,
506,
2222,
7371,
7,
1039,
666,
275,
308,
1491,
78,
61,
1039,
302,
275,
3666,
78,
11,
19,
28428,
20,
3342,
20,
1039,
666,
275,
666,
435,
334,
78,
446,
822,
8,
576,
430,
627,
1557,
16,
7,
1039,
291,
855,
1436,
14,
952,
8,
576,
9,
2958,
1706,
63,
545,
10578,
275,
1706,
63,
70,
875,
2958,
347,
1706,
63,
875,
8,
277,
12,
308,
304,
1039,
302,
275,
822,
8,
83,
9,
1039,
291,
14,
1389,
63,
1635,
8,
78,
9,
1039,
291,
14,
1389,
63,
70,
875,
8,
78,
12,
308,
9,
2958,
1706,
63,
21669,
275,
1706,
63,
875,
1128,
1706,
63,
2394,
275,
1706,
63,
875,
2958,
347,
1706,
63,
513,
8,
277,
12,
769,
12,
1706,
63,
1053,
304,
1039,
367,
1242,
315,
769,
26,
1675,
291,
14,
1389,
63,
1635,
8,
17,
9,
1675,
1706,
63,
1053,
8,
1053,
9,
1039,
291,
14,
1389,
63,
1635,
8,
16,
9,
2958,
347,
1706,
63,
70,
1144,
8,
277,
12,
302,
12,
769,
12,
1706,
63,
1053,
304,
1039,
340,
822,
8,
513,
9,
1137,
302,
26,
1675,
746,
1722,
12,
283,
10603,
1625,
1568,
7,
1039,
367,
1242,
315,
769,
26,
1675,
1706,
63,
1053,
8,
1053,
9,
2958,
347,
1706,
63,
1144,
8,
277,
12,
769,
12,
1706,
63,
1053,
304,
1039,
302,
275,
822,
8,
513,
9,
1039,
291,
14,
1389,
63,
1635,
8,
78,
9,
1039,
291,
14,
1389,
63,
70,
1144,
8,
78,
12,
769,
12,
1706,
63,
1053,
9,
1223,
8065,
199,
533,
31017,
281,
26,
1128,
408,
26472,
83,
7750,
666,
30580,
687,
314,
1627,
3335,
1041,
2958,
347,
636,
826,
721,
277,
12,
666,
304,
1039,
291,
14,
3958,
8,
576,
9,
2958,
347,
5305,
8,
277,
12,
666,
304,
1039,
291,
855,
1436,
275,
666,
1039,
291,
855,
1712,
275,
378,
2958,
347,
664,
63,
3124,
8,
277,
304,
1039,
372,
291,
855,
1712,
2958,
347,
663,
63,
3124,
8,
277,
12,
3421,
304,
1039,
291,
855,
1712,
275,
3421,
2958,
347,
664,
63,
2738,
8,
277,
304,
1039,
372,
291,
855,
1436,
2958,
347,
4224,
8,
277,
304,
1039,
340,
291,
855,
1712,
665,
822,
8,
277,
855,
1436,
304,
1675,
746,
4520,
360,
324,
29939,
666,
25803,
358,
2958,
347,
7787,
63,
1635,
8,
277,
304,
1039,
284,
275,
291,
855,
1712,
1039,
291,
855,
1712,
275,
1335,
275,
284,
11,
20,
1039,
666,
275,
291,
855,
1436,
59,
73,
26,
74,
61,
1039,
340,
822,
8,
576,
9,
665,
841,
26,
1675,
746,
21157,
1039,
671,
275,
2702,
14,
5301,
16099,
44,
297,
666,
2788,
16,
61,
1039,
862,
26,
1675,
372,
1109,
8,
88,
9,
1039,
871,
23870,
26,
1675,
372,
671,
2958,
347,
7787,
63,
442,
8,
277,
304,
1039,
284,
275,
291,
855,
1712,
1039,
291,
855,
1712,
275,
1335,
275,
284,
11,
20,
1039,
666,
275,
291,
855,
1436,
59,
73,
26,
74,
61,
1039,
340,
822,
8,
576,
9,
665,
841,
26,
1675,
746,
21157,
1039,
372,
2702,
14,
5301
] |
[
29452,
334,
65,
10026,
402,
9,
25625,
1323,
4564,
1553,
325,
56,
2147,
3918,
17634,
425,
14,
2999,
199,
9295,
26,
7329,
413,
10752,
2999,
199,
624,
2999,
199,
646,
2702,
202,
199,
893,
26,
1128,
687,
15073,
492,
5228,
465,
485,
6424,
202,
199,
2590,
3545,
26,
1128,
687,
5228,
492,
5228,
465,
485,
6424,
2999,
199,
363,
452,
363,
275,
2097,
547,
401,
298,
2305,
281,
401,
298,
26472,
281,
401,
298,
20403,
547,
937,
2999,
199,
3,
4967,
202,
199,
533,
4520,
8,
1726,
304,
1128,
408,
1726,
1021,
367,
642,
859,
14,
3645,
26,
2958,
871,
671,
5012,
773,
14,
547,
12,
2729,
26,
1039,
327,
2729,
965,
314,
4520,
1256,
367,
314,
1919,
2958,
1684,
284,
2936,
26,
1039,
1499,
1553,
3509,
314,
1245,
2958,
408,
1128,
347,
636,
826,
721,
277,
12,
1499,
304,
1039,
291,
14,
1328,
275,
1499,
1128,
347,
636,
2722,
721,
277,
304,
1039,
372,
4700,
8,
277,
14,
1328,
9,
1128,
347,
636,
495,
721,
277,
304,
1039,
372,
620,
8,
277,
14,
1328,
9,
8065,
199,
533,
1448,
1023,
547,
8,
547,
304,
1128,
986,
1223,
8065,
199,
533,
9954,
281,
26,
1128,
408,
2305,
7750,
666,
30580,
1901,
282,
3335,
1041,
2958,
347,
636,
826,
721,
277,
304,
1039,
291,
14,
3958,
342,
2958,
347,
5305,
8,
277,
304,
1039,
291,
855,
1436,
275,
485,
6424,
342,
2958,
347,
664,
63,
2738,
8,
277,
304,
1039,
372,
291,
855,
1436,
14,
7150,
342,
1128,
327,
8552,
7163,
1128,
664,
63,
1436,
275,
664,
63,
2738,
2958,
347,
1706,
63,
1635,
8,
277,
12,
671,
304,
1039,
291,
855,
1436,
14,
952,
8,
1820,
14,
1389,
16099,
44,
297,
671,
430,
2958,
347,
1706,
63,
442,
8,
277,
12,
671,
304,
1039,
291,
855,
1436,
14,
952,
8,
1820,
14,
1389,
16099,
76,
297,
671,
430,
2958,
1706,
63,
4869,
275,
1706,
63,
442,
2958,
347,
1706,
63,
2245,
8,
277,
12,
671,
304,
1039,
340,
671,
26,
291,
855,
1436,
14,
952,
2258,
16,
60,
16,
60,
16,
60,
17,
358,
1039,
587,
26,
291,
855,
1436,
14,
952,
2258,
16,
60,
16,
60,
16,
60,
16,
358,
2958,
347,
1706,
63,
85,
9547,
8,
277,
12,
671,
304,
1039,
291,
14,
1389,
63,
1635,
8,
88,
1140,
708,
1253,
378,
21870,
44,
9,
1039,
291,
14,
1389,
63,
1635,
8,
88,
1253,
378,
21870,
44,
9,
2958,
1706,
63,
9547,
275,
1706,
63,
85,
9547,
2958,
347,
1706,
63,
1609,
8,
277,
12,
671,
304,
1039,
862,
26,
291,
855,
1436,
14,
952,
8,
1820,
14,
1389,
16099,
70,
297,
671,
430,
1039,
871,
2702,
14,
705,
12,
1499,
26,
1675,
746,
1448,
1023,
547,
12,
1499,
2958,
347,
1706,
63,
3157,
8,
277,
12,
671,
304,
1039,
862,
26,
291,
855,
1436,
14,
952,
8,
1820,
14,
1389,
16099,
68,
297,
671,
430,
1039,
871,
2702,
14,
705,
12,
1499,
26,
1675,
746,
1448,
1023,
547,
12,
1499,
2958,
347,
1706,
63,
70,
875,
8,
277,
12,
302,
12,
308,
304,
1039,
340,
302,
665,
378,
26,
1675,
746,
1722,
12,
283,
70,
875,
1568,
1471,
506,
2222,
7371,
7,
1039,
666,
275,
308,
1491,
78,
61,
1039,
302,
275,
3666,
78,
11,
19,
28428,
20,
3342,
20,
1039,
666,
275,
666,
435,
334,
78,
446,
822,
8,
576,
430,
627,
1557,
16,
7,
1039,
291,
855,
1436,
14,
952,
8,
576,
9,
2958,
1706,
63,
545,
10578,
275,
1706,
63,
70,
875,
2958,
347,
1706,
63,
875,
8,
277,
12,
308,
304,
1039,
302,
275,
822,
8,
83,
9,
1039,
291,
14,
1389,
63,
1635,
8,
78,
9,
1039,
291,
14,
1389,
63,
70,
875,
8,
78,
12,
308,
9,
2958,
1706,
63,
21669,
275,
1706,
63,
875,
1128,
1706,
63,
2394,
275,
1706,
63,
875,
2958,
347,
1706,
63,
513,
8,
277,
12,
769,
12,
1706,
63,
1053,
304,
1039,
367,
1242,
315,
769,
26,
1675,
291,
14,
1389,
63,
1635,
8,
17,
9,
1675,
1706,
63,
1053,
8,
1053,
9,
1039,
291,
14,
1389,
63,
1635,
8,
16,
9,
2958,
347,
1706,
63,
70,
1144,
8,
277,
12,
302,
12,
769,
12,
1706,
63,
1053,
304,
1039,
340,
822,
8,
513,
9,
1137,
302,
26,
1675,
746,
1722,
12,
283,
10603,
1625,
1568,
7,
1039,
367,
1242,
315,
769,
26,
1675,
1706,
63,
1053,
8,
1053,
9,
2958,
347,
1706,
63,
1144,
8,
277,
12,
769,
12,
1706,
63,
1053,
304,
1039,
302,
275,
822,
8,
513,
9,
1039,
291,
14,
1389,
63,
1635,
8,
78,
9,
1039,
291,
14,
1389,
63,
70,
1144,
8,
78,
12,
769,
12,
1706,
63,
1053,
9,
1223,
8065,
199,
533,
31017,
281,
26,
1128,
408,
26472,
83,
7750,
666,
30580,
687,
314,
1627,
3335,
1041,
2958,
347,
636,
826,
721,
277,
12,
666,
304,
1039,
291,
14,
3958,
8,
576,
9,
2958,
347,
5305,
8,
277,
12,
666,
304,
1039,
291,
855,
1436,
275,
666,
1039,
291,
855,
1712,
275,
378,
2958,
347,
664,
63,
3124,
8,
277,
304,
1039,
372,
291,
855,
1712,
2958,
347,
663,
63,
3124,
8,
277,
12,
3421,
304,
1039,
291,
855,
1712,
275,
3421,
2958,
347,
664,
63,
2738,
8,
277,
304,
1039,
372,
291,
855,
1436,
2958,
347,
4224,
8,
277,
304,
1039,
340,
291,
855,
1712,
665,
822,
8,
277,
855,
1436,
304,
1675,
746,
4520,
360,
324,
29939,
666,
25803,
358,
2958,
347,
7787,
63,
1635,
8,
277,
304,
1039,
284,
275,
291,
855,
1712,
1039,
291,
855,
1712,
275,
1335,
275,
284,
11,
20,
1039,
666,
275,
291,
855,
1436,
59,
73,
26,
74,
61,
1039,
340,
822,
8,
576,
9,
665,
841,
26,
1675,
746,
21157,
1039,
671,
275,
2702,
14,
5301,
16099,
44,
297,
666,
2788,
16,
61,
1039,
862,
26,
1675,
372,
1109,
8,
88,
9,
1039,
871,
23870,
26,
1675,
372,
671,
2958,
347,
7787,
63,
442,
8,
277,
304,
1039,
284,
275,
291,
855,
1712,
1039,
291,
855,
1712,
275,
1335,
275,
284,
11,
20,
1039,
666,
275,
291,
855,
1436,
59,
73,
26,
74,
61,
1039,
340,
822,
8,
576,
9,
665,
841,
26,
1675,
746,
21157,
1039,
372,
2702,
14,
5301,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
amunk/metagoofil
|
hachoir_parser/audio/itunesdb.py
|
72
|
20511
|
"""
iPod iTunesDB parser.
Documentation:
- http://ipodlinux.org/ITunesDB
Author: Romain HERAULT
Creation date: 19 august 2006
"""
from hachoir_parser import Parser
from hachoir_core.field import (FieldSet,
UInt8, UInt16, UInt32, Int32, UInt64, TimestampMac32,
String, Float32, NullBytes, Enum, RawBytes)
from hachoir_core.endian import LITTLE_ENDIAN
from hachoir_core.tools import humanDuration
from hachoir_core.text_handler import displayHandler, filesizeHandler
list_order={
1 : "playlist order (manual sort order)",
2 : "???",
3 : "songtitle",
4 : "album",
5 : "artist",
6 : "bitrate",
7 : "genre",
8 : "kind",
9 : "date modified",
10 : "track number",
11 : "size",
12 : "time",
13 : "year",
14 : "sample rate",
15 : "comment",
16 : "date added",
17 : "equalizer",
18 : "composer",
19 : "???",
20 : "play count",
21 : "last played",
22 : "disc number",
23 : "my rating",
24 : "release date",
25 : "BPM",
26 : "grouping",
27 : "category",
28 : "description",
29 : "show",
30 : "season",
31 : "episode number"
}
class DataObject(FieldSet):
type_name={
1:"Title",
2:"Location",
3:"Album",
4:"Artist",
5:"Genre",
6:"Filetype",
7:"EQ Setting",
8:"Comment",
9:"Category",
12:"Composer",
13:"Grouping",
14:"Description text",
15:"Podcast Enclosure URL",
16:"Podcast RSS URL",
17:"Chapter data",
18:"Subtitle",
19:"Show (for TV Shows only)",
20:"Episode",
21:"TV Network",
50:"Smart Playlist Data",
51:"Smart Playlist Rules",
52:"Library Playlist Index",
100:"Column info",
200:"Album name (for album descriptions)",
201:"Album artist (for album descriptions)",
202:"Album sort artist (for album descriptions)"
}
mhod52_sort_index_type_name={
3:"Title",
4:"Album, then Disk/Tracknumber, then Title",
5:"Artist, then Album, then Disc/Tracknumber, then Title",
7:"Genre, then Artist, then Album, then Disc/Tracknumber, then Title",
8:"Composer, then Title"
}
def __init__(self, *args, **kw):
FieldSet.__init__(self, *args, **kw)
self._size = self["entry_length"].value *8
def createFields(self):
yield String(self, "header_id", 4, "Data Object Header Markup (\"mhod\")", charset="ISO-8859-1")
yield UInt32(self, "header_length", "Header Length")
yield UInt32(self, "entry_length", "Entry Length")
yield Enum(UInt32(self, "type", "type"),self.type_name)
if(self["type"].value<15) or (self["type"].value >= 200):
yield UInt32(self, "unknown[]")
yield UInt32(self, "unknown[]")
yield UInt32(self, "position", "Position")
yield UInt32(self, "length", "String Length in bytes")
yield UInt32(self, "unknown[]")
yield UInt32(self, "unknown[]")
yield String(self, "string", self["length"].value, "String Data", charset="UTF-16-LE")
elif (self["type"].value<17):
yield UInt32(self, "unknown[]")
yield UInt32(self, "unknown[]")
yield String(self, "string", self._size/8-self["header_length"].value, "String Data", charset="UTF-8")
elif (self["type"].value == 52):
yield UInt32(self, "unknown[]", "unk1")
yield UInt32(self, "unknown[]", "unk2")
yield Enum(UInt32(self, "sort_index_type", "Sort Index Type"),self.mhod52_sort_index_type_name)
yield UInt32(self, "entry_count", "Entry Count")
indexes_size = self["entry_count"].value*4
padding_offset = self["entry_length"].value - indexes_size
padding = self.seekByte(padding_offset, "header padding")
if padding:
yield padding
for i in xrange(self["entry_count"].value):
yield UInt32(self, "index["+str(i)+"]", "Index of the "+str(i)+"nth mhit")
else:
padding = self.seekByte(self["header_length"].value, "header padding")
if padding:
yield padding
padding = self.seekBit(self._size, "entry padding")
if padding:
yield padding
class TrackItem(FieldSet):
x1_type_name={
0:"AAC or CBR MP3",
1:"VBR MP3"
}
x2_type_name={
0:"AAC",
1:"MP3"
}
media_type_name={
0x00:"Audio/Video",
0x01:"Audio",
0x02:"Video",
0x04:"Podcast",
0x06:"Video Podcast",
0x08:"Audiobook",
0x20:"Music Video",
0x40:"TV Show",
0X60:"TV Show (Music lists)",
}
def __init__(self, *args, **kw):
FieldSet.__init__(self, *args, **kw)
self._size = self["entry_length"].value *8
def createFields(self):
yield String(self, "header_id", 4, "Track Item Header Markup (\"mhit\")", charset="ISO-8859-1")
yield UInt32(self, "header_length", "Header Length")
yield UInt32(self, "entry_length", "Entry Length")
yield UInt32(self, "string_number", "Number of Strings")
yield UInt32(self, "unique_id", "Unique ID")
yield UInt32(self, "visible_tag", "Visible Tag")
yield String(self, "file_type", 4, "File Type")
yield Enum(UInt8(self, "x1_type", "Extended Type 1"),self.x1_type_name)
yield Enum(UInt8(self, "x2_type", "Extended type 2"),self.x2_type_name)
yield UInt8(self, "compilation_flag", "Compilation Flag")
yield UInt8(self, "rating", "Rating")
yield TimestampMac32(self, "last_modified", "Time of the last modification of the track")
yield filesizeHandler(UInt32(self, "size", "Track size in bytes"))
yield displayHandler(UInt32(self, "length", "Track length in milliseconds"), humanDuration)
yield UInt32(self, "track_number", "Number of this track")
yield UInt32(self, "total_track", "Total number of tracks")
yield UInt32(self, "year", "Year of the track")
yield UInt32(self, "bitrate", "Bitrate")
yield UInt32(self, "samplerate", "Sample Rate")
yield UInt32(self, "volume", "volume")
yield UInt32(self, "start_time", "Start playing at, in milliseconds")
yield UInt32(self, "stop_time", "Stop playing at, in milliseconds")
yield UInt32(self, "soundcheck", "SoundCheck preamp")
yield UInt32(self, "playcount_1", "Play count of the track")
yield UInt32(self, "playcount_2", "Play count of the track (identical to playcount_1)")
yield UInt32(self, "last_played_time", "Time the song was last played")
yield UInt32(self, "disc_number", "disc number in multi disc sets")
yield UInt32(self, "total_discs", "Total number of discs in the disc set")
yield UInt32(self, "userid", "User ID in the DRM scheme")
yield TimestampMac32(self, "added_date", "Date when the item was added")
yield UInt32(self, "bookmark_time", "Bookmark time for AudioBook")
yield UInt64(self, "dbid", "Unique DataBase ID for the song (identical in mhit and in mhii)")
yield UInt8(self, "checked", "song is checked")
yield UInt8(self, "application_rating", "Last Rating before change")
yield UInt16(self, "BPM", "BPM of the track")
yield UInt16(self, "artwork_count", "number of artworks for this item")
yield UInt16(self, "unknown[]")
yield UInt32(self, "artwork_size", "Total size of artworks in bytes")
yield UInt32(self, "unknown[]")
yield Float32(self, "sample_rate_2", "Sample Rate express in float")
yield UInt32(self, "released_date", "Date of release in Music Store or in Podcast")
yield UInt16(self, "unknown[]")
yield UInt16(self, "explicit_flag[]", "Explicit flag")
yield UInt32(self, "unknown[]")
yield UInt32(self, "unknown[]")
yield UInt32(self, "skip_count[]", "Skip Count")
yield TimestampMac32(self, "last_skipped", "Date when the item was last skipped")
yield UInt8(self, "has_artwork", "0x01 for track with artwork, 0x02 otherwise")
yield UInt8(self, "skip_wen_shuffling", "Skip that track when shuffling")
yield UInt8(self, "remember_playback_position", "Remember playback position")
yield UInt8(self, "flag4", "Flag 4")
yield UInt64(self, "dbid2", "Unique DataBase ID for the song (identical as above)")
yield UInt8(self, "lyrics_flag", "Lyrics Flag")
yield UInt8(self, "movie_file_flag", "Movie File Flag")
yield UInt8(self, "played_mark", "Track has been played")
yield UInt8(self, "unknown[]")
yield UInt32(self, "unknown[]")
yield UInt32(self, "pregap[]", "Number of samples of silence before the song starts")
yield UInt64(self, "sample_count", "Number of samples in the song (only for WAV and AAC files)")
yield UInt32(self, "unknown[]")
yield UInt32(self, "postgap[]", "Number of samples of silence at the end of the song")
yield UInt32(self, "unknown[]")
yield Enum(UInt32(self, "media_type", "Media Type for video iPod"),self.media_type_name)
yield UInt32(self, "season_number", "Season Number")
yield UInt32(self, "episode_number", "Episode Number")
yield UInt32(self, "unknown[]")
yield UInt32(self, "unknown[]")
yield UInt32(self, "unknown[]")
yield UInt32(self, "unknown[]")
yield UInt32(self, "unknown[]")
yield UInt32(self, "unknown[]")
yield UInt32(self, "unknown[]")
yield UInt32(self, "gapless_data[]","The size in bytes from first Sync Frame until the 8th before the last frame." )
yield UInt32(self, "unknown[]")
yield UInt16(self, "gaplessTrackFlag[]", "1 if track has gapless data")
yield UInt16(self, "gaplessAlbumFlag[]", "1 if track uses crossfading in iTunes")
yield RawBytes(self, "unknown[]", 20)
yield UInt32(self, "unknown[]")
yield UInt32(self, "unknown[]")
yield UInt32(self, "unknown[]")
yield UInt32(self, "unknown[]")
yield UInt16(self, "unknown[]")
yield UInt16(self, "album_id[]", "Album ID (used to link tracks with MHIAs)")
yield RawBytes(self, "unknown[]", 52)
yield UInt32(self, "mhii_link[]", "Artwork ID (used to link tracks with MHIIs)")
padding = self.seekByte(self["header_length"].value, "header padding")
if padding:
yield padding
#while ((self.stream.readBytes(0, 4) == 'mhod') and ((self.current_size/8) < self["entry_length"].value)):
for i in xrange(self["string_number"].value):
yield DataObject(self, "data[]")
padding = self.seekBit(self._size, "entry padding")
if padding:
yield padding
class TrackList(FieldSet):
def createFields(self):
yield String(self, "header_id", 4, "Track List Header Markup (\"mhlt\")", charset="ISO-8859-1")
yield UInt32(self, "header_length", "Header Length")
yield UInt32(self, "track_number", "Number of Tracks")
padding = self.seekByte(self["header_length"].value, "header padding")
if padding:
yield padding
for i in xrange(self["track_number"].value):
yield TrackItem(self, "track[]")
class PlaylistItem(FieldSet):
def __init__(self, *args, **kw):
FieldSet.__init__(self, *args, **kw)
self._size = self["entry_length"].value *8
def createFields(self):
yield String(self, "header_id", 4, "Playlist Item Header Markup (\"mhip\")", charset="ISO-8859-1")
yield UInt32(self, "header_length", "Header Length")
yield UInt32(self, "entry_length", "Entry Length")
yield UInt32(self, "data_object_child_count", "Number of Child Data Objects")
yield UInt32(self, "podcast_grouping_flag", "Podcast Grouping Flag")
yield UInt32(self, "group_id", "Group ID")
yield UInt32(self, "track_id", "Track ID")
yield TimestampMac32(self, "timestamp", "Song Timestamp")
yield UInt32(self, "podcast_grouping_ref", "Podcast Grouping Reference")
padding = self.seekByte(self["header_length"].value, "header padding")
if padding:
yield padding
for i in xrange(self["data_object_child_count"].value):
yield DataObject(self, "mhod[]")
class Playlist(FieldSet):
is_master_pl_name={
0:"Regular playlist",
1:"Master playlist"
}
is_podcast_name={
0:"Normal Playlist List",
1:"Podcast Playlist List"
}
list_sort_order_name={
1:"Manual Sort Order",
2:"???",
3:"Song Title",
4:"Album",
5:"Artist",
6:"Bitrate",
7:"Genre",
8:"Kind",
9:"Date Modified",
10:"Track Number",
11:"Size",
12:"Time",
13:"Year",
14:"Sample Rate",
15:"Comment",
16:"Date Added",
17:"Equalizer",
18:"Composer",
19:"???",
20:"Play Count",
21:"Last Played",
22:"Disc Number",
23:"My Rating",
24:"Release Date",
25:"BPM",
26:"Grouping",
27:"Category",
28:"Description",
29:"Show",
30:"Season",
31:"Episode Number"
}
def __init__(self, *args, **kw):
FieldSet.__init__(self, *args, **kw)
self._size = self["entry_length"].value *8
def createFields(self):
yield String(self, "header_id", 4, "Playlist Header Markup (\"mhyp\")", charset="ISO-8859-1")
yield UInt32(self, "header_length", "Header Length")
yield UInt32(self, "entry_length", "Entry Length")
yield UInt32(self, "data_object_child_count", "Number of Child Data Objects")
yield UInt32(self, "playlist_count", "Number of Playlist Items")
yield Enum(UInt8(self, "type", "Normal or master playlist?"), self.is_master_pl_name)
yield UInt8(self, "XXX1", "XXX1")
yield UInt8(self, "XXX2", "XXX2")
yield UInt8(self, "XXX3", "XXX3")
yield TimestampMac32(self, "creation_date", "Date when the playlist was created")
yield UInt64(self, "playlistid", "Persistent Playlist ID")
yield UInt32(self, "unk3", "unk3")
yield UInt16(self, "string_mhod_count", "Number of string MHODs for this playlist")
yield Enum(UInt16(self, "is_podcast", "Playlist or Podcast List?"), self.is_podcast_name)
yield Enum(UInt32(self, "sort_order", "Playlist Sort Order"), self.list_sort_order_name)
padding = self.seekByte(self["header_length"].value, "entry padding")
if padding:
yield padding
for i in xrange(self["data_object_child_count"].value):
yield DataObject(self, "mhod[]")
for i in xrange(self["playlist_count"].value):
yield PlaylistItem(self, "playlist_item[]")
class PlaylistList(FieldSet):
def createFields(self):
yield String(self, "header_id", 4, "Playlist List Header Markup (\"mhlp\")", charset="ISO-8859-1")
yield UInt32(self, "header_length", "Header Length")
yield UInt32(self, "playlist_number", "Number of Playlists")
padding = self.seekByte(self["header_length"].value, "header padding")
if padding:
yield padding
for i in xrange(self["playlist_number"].value):
yield Playlist(self, "playlist[]")
class Album(FieldSet):
def __init__(self, *args, **kw):
FieldSet.__init__(self, *args, **kw)
self._size = self["entry_length"].value *8
def createFields(self):
yield String(self, "header_id", 4, "Album Item Header Markup (\"mhia\")", charset="ISO-8859-1")
yield UInt32(self, "header_length", "Header Length")
yield UInt32(self, "entry_length", "Entry Length")
yield UInt32(self, "data_object_child_count", "Number of Child Data Objects")
yield UInt16(self, "unknow[]")
yield UInt16(self, "album_id[]", "Album ID")
yield UInt32(self, "unknow[]")
yield UInt32(self, "unknow[]")
yield UInt32(self, "unknow[]")
padding = self.seekByte(self["header_length"].value, "entry padding")
if padding:
yield padding
for i in xrange(self["data_object_child_count"].value):
yield DataObject(self, "mhod[]")
class AlbumList(FieldSet):
def createFields(self):
yield String(self, "header_id", 4, "Album List Header Markup (\"mhla\")", charset="ISO-8859-1")
yield UInt32(self, "header_length", "Header Length")
yield UInt32(self, "album_number", "Number of Albums")
padding = self.seekByte(self["header_length"].value, "header padding")
if padding:
yield padding
for i in xrange(self["album_number"].value):
yield Album(self, "album[]")
class DataSet(FieldSet):
type_name={
1:"Track List",
2:"Play List",
3:"Podcast List",
4:"Album List"
}
def __init__(self, *args, **kw):
FieldSet.__init__(self, *args, **kw)
self._size = self["entry_length"].value *8
def createFields(self):
yield String(self, "header_id", 4, "DataSet Header Markup (\"mhsd\")", charset="ISO-8859-1")
yield UInt32(self, "header_length", "Header Length")
yield UInt32(self, "entry_length", "Entry Length")
yield Enum(UInt32(self, "type", "type"),self.type_name)
padding = self.seekByte(self["header_length"].value, "header_raw")
if padding:
yield padding
if self["type"].value == 1:
yield TrackList(self, "tracklist[]")
if self["type"].value == 2:
yield PlaylistList(self, "playlist_list[]");
if self["type"].value == 3:
yield PlaylistList(self, "podcast_list[]");
if self["type"].value == 4:
yield AlbumList(self, "album_list[]");
padding = self.seekBit(self._size, "entry padding")
if padding:
yield padding
class DataBase(FieldSet):
def __init__(self, *args, **kw):
FieldSet.__init__(self, *args, **kw)
self._size = self["entry_length"].value *8
# def createFields(self):
class ITunesDBFile(Parser):
PARSER_TAGS = {
"id": "itunesdb",
"category": "audio",
"min_size": 44*8,
"magic": (('mhbd',0),),
"description": "iPod iTunesDB file"
}
endian = LITTLE_ENDIAN
def validate(self):
return self.stream.readBytes(0, 4) == 'mhbd'
def createFields(self):
yield String(self, "header_id", 4, "DataBase Header Markup (\"mhbd\")", charset="ISO-8859-1")
yield UInt32(self, "header_length", "Header Length")
yield UInt32(self, "entry_length", "Entry Length")
yield UInt32(self, "unknown[]")
yield UInt32(self, "version_number", "Version Number")
yield UInt32(self, "child_number", "Number of Children")
yield UInt64(self, "id", "ID for this database")
yield UInt16(self, "unknown[]")
yield UInt32(self, "unknown[]")
yield UInt64(self, "unknown[]")
yield UInt16(self, "unknown[]")
yield UInt16(self, "hashing_scheme[]", "Algorithm used to calculate the database hash")
yield NullBytes(self, "unknown[]", 20)
yield String(self, "language_id", 2, "Language ID")
yield UInt64(self, "persistent_id", "Library Persistent ID")
yield UInt32(self, "unknown[]")
yield UInt32(self, "unknown[]")
yield RawBytes(self, "hash[]", 20)
yield Int32(self, "timezone_offset[]", "Timezone offset in seconds")
yield UInt16(self, "unknown[]")
yield RawBytes(self, "iphone_hash[]", 45)
size = self["header_length"].value-self.current_size/ 8
if size>0:
yield NullBytes(self, "padding", size)
for i in xrange(self["child_number"].value):
yield DataSet(self, "dataset[]")
padding = self.seekByte(self["entry_length"].value, "entry padding")
if padding:
yield padding
def createContentSize(self):
return self["entry_length"].value * 8
|
gpl-2.0
|
[
624,
199,
73,
25928,
284,
22664,
397,
2846,
1798,
14,
199,
199,
17763,
26,
199,
13,
1455,
921,
711,
364,
5135,
14,
1308,
15,
649,
324,
397,
2846,
199,
199,
5949,
26,
6848,
973,
869,
540,
33,
2233,
199,
13921,
1434,
26,
5851,
18336,
833,
8315,
199,
624,
199,
199,
504,
394,
21301,
63,
2087,
492,
10191,
199,
504,
394,
21301,
63,
1018,
14,
698,
492,
334,
23532,
12,
272,
10666,
24,
12,
10666,
975,
12,
10666,
708,
12,
9805,
708,
12,
10666,
772,
12,
18267,
3399,
708,
12,
272,
2624,
12,
11140,
708,
12,
12119,
5571,
12,
11305,
12,
13480,
5571,
9,
199,
504,
394,
21301,
63,
1018,
14,
15009,
492,
491,
31783,
63,
21046,
199,
504,
394,
21301,
63,
1018,
14,
2537,
492,
11779,
13283,
199,
504,
394,
21301,
63,
1018,
14,
505,
63,
2232,
492,
2929,
2461,
12,
23858,
2461,
199,
199,
513,
63,
1648,
3126,
267,
413,
520,
298,
10411,
1865,
334,
9285,
4069,
1865,
4186,
267,
499,
520,
298,
10674,
15583,
267,
650,
520,
298,
19351,
1213,
401,
267,
841,
520,
298,
12110,
401,
267,
959,
520,
298,
11215,
401,
267,
1227,
520,
298,
24484,
401,
267,
1520,
520,
298,
23553,
401,
267,
1695,
520,
298,
5091,
401,
267,
1749,
520,
298,
602,
6042,
401,
267,
1616,
520,
298,
3885,
1329,
401,
267,
4119,
520,
298,
890,
401,
267,
3144,
520,
298,
521,
401,
267,
4944,
520,
298,
3403,
401,
267,
4329,
520,
298,
3271,
6634,
401,
267,
4114,
520,
298,
3349,
401,
267,
3193,
520,
298,
602,
3483,
401,
267,
5557,
520,
298,
1452,
1793,
401,
267,
6155,
520,
298,
7784,
332,
401,
267,
5851,
520,
298,
10674,
15583,
267,
3388,
520,
298,
2802,
2338,
401,
267,
7829,
520,
298,
2019,
5232,
379,
401,
267,
6928,
520,
298,
6409,
1329,
401,
267,
6546,
520,
298,
1662,
18360,
401,
267,
5504,
520,
298,
3221,
1434,
401,
267,
5661,
520,
298,
34,
10793,
401,
267,
7875,
520,
298,
22390,
401,
267,
8087,
520,
298,
3710,
401,
267,
7294,
520,
298,
1802,
401,
267,
7349,
520,
298,
2384,
401,
267,
4233,
520,
298,
12605,
401,
267,
7105,
520,
298,
9544,
1329,
2,
272,
789,
199,
199,
533,
3918,
1692,
8,
23532,
304,
272,
730,
63,
354,
3126,
267,
413,
5424,
6888,
401,
267,
499,
5424,
6592,
401,
267,
650,
5424,
26369,
401,
267,
841,
5424,
27711,
401,
267,
959,
5424,
8168,
264,
401,
267,
1227,
5424,
1173,
466,
401,
267,
1520,
5424,
17420,
13510,
401,
267,
1695,
5424,
7488,
401,
267,
1749,
5424,
7841,
401,
267,
3144,
5424,
32325,
401,
267,
4944,
5424,
2448,
316,
401,
267,
4329,
5424,
5831,
1318,
401,
267,
4114,
5424,
25928,
2931,
3447,
13008,
2851,
401,
267,
3193,
5424,
25928,
2931,
30331,
2851,
401,
267,
5557,
5424,
30791,
666,
401,
267,
6155,
5424,
29907,
401,
267,
5851,
5424,
6824,
334,
509,
26990,
12968,
83,
1454,
4186,
267,
3388,
5424,
22887,
401,
267,
7829,
5424,
12764,
7220,
401,
267,
5238,
5424,
29111,
16527,
513,
3918,
401,
267,
8026,
5424,
29111,
16527,
513,
24259,
401,
267,
14589,
5424,
7424,
16527,
513,
5499,
401,
267,
2948,
5424,
4547,
2256,
401,
267,
1926,
5424,
26369,
536,
334,
509,
16379,
18714,
4186,
267,
1784,
5424,
26369,
16459,
334,
509,
16379,
18714,
4186,
267,
19328,
5424,
26369,
4069,
16459,
334,
509,
16379,
18714,
2924,
272,
789,
339,
333,
72,
364,
2528,
63,
3191,
63,
1080,
63,
466,
63,
354,
3126,
267,
650,
5424,
6888,
401,
267,
841,
5424,
26369,
12,
2066,
26287,
15,
7927,
1955,
12,
2066,
16881,
401,
267,
959,
5424,
27711,
12,
2066,
4580,
7767,
12,
2066,
5289,
67,
15,
7927,
1955,
12,
2066,
16881,
401,
267,
1520,
5424,
8168,
264,
12,
2066,
1952,
5011,
12,
2066,
4580,
7767,
12,
2066,
5289,
67,
15,
7927,
1955,
12,
2066,
16881,
401,
267,
1695,
5424,
32325,
12,
2066,
16881,
2,
272,
789,
339,
347,
636,
826,
721,
277,
12,
627,
589,
12,
1011,
829,
304,
267,
5024,
1084,
855,
826,
721,
277,
12,
627,
589,
12,
1011,
829,
9,
267,
291,
423,
890,
275,
291,
905,
2373,
63,
1267,
4140,
585,
627,
24,
339,
347,
24828,
8,
277,
304,
267,
1995,
2624,
8,
277,
12,
298,
1291,
63,
344,
401,
841,
12,
298,
1451,
6935,
10240,
17504,
334,
4451,
17077,
364,
60,
531,
401,
5960,
628,
7336,
13,
4830,
13,
17,
531,
267,
1995,
10666,
708,
8,
277,
12,
298,
1291,
63,
1267,
401,
298,
2567,
19893,
531,
267,
1995,
10666,
708,
8,
277,
12,
298,
2373,
63,
1267,
401,
298,
3900,
19893,
531,
267,
1995,
11305,
8,
13304,
708,
8,
277,
12,
298,
466,
401,
298,
466,
1288,
277,
14,
466,
63,
354,
9,
267,
340,
8,
277,
905,
466,
4140,
585,
28,
1046,
9,
503,
334,
277,
905,
466,
4140,
585,
2356,
1926,
304,
288,
1995,
10666,
708,
8,
277,
12,
298,
5187,
31346,
288,
1995,
10666,
708,
8,
277,
12,
298,
5187,
31346,
288,
1995,
10666,
708,
8,
277,
12,
298,
3124,
401,
298,
5625,
531,
288,
1995,
10666,
708,
8,
277,
12,
298,
1267,
401,
298,
1558,
19893,
315,
2783,
531,
288,
1995,
10666,
708,
8,
277,
12,
298,
5187,
31346,
288,
1995,
10666,
708,
8,
277,
12,
298,
5187,
31346,
288,
1995,
2624,
8,
277,
12,
298,
875,
401,
291,
905,
1267,
4140,
585,
12,
298,
1558,
3918,
401,
5960,
628,
6610,
13,
975,
13,
906,
531,
267,
916,
334,
277,
905,
466,
4140,
585,
28,
1196,
304,
288,
1995,
10666,
708,
8,
277,
12,
298,
5187,
31346,
288,
1995,
10666,
708,
8,
277,
12,
298,
5187,
31346,
288,
1995,
2624,
8,
277,
12,
298,
875,
401,
291,
423,
890,
15,
24,
13,
277,
905,
1291,
63,
1267,
4140,
585,
12,
298,
1558,
3918,
401,
5960,
628,
6610,
13,
24,
531,
267,
916,
334,
277,
905,
466,
4140,
585,
508,
14589,
304,
288,
1995,
10666,
708,
8,
277,
12,
298,
5187,
20204,
298,
1778,
17,
531,
288,
1995,
10666,
708,
8,
277,
12,
298,
5187,
20204,
298,
1778,
18,
531,
288,
1995,
11305,
8,
13304,
708,
8,
277,
12,
298,
3191,
63,
1080,
63,
466,
401,
298,
14376,
5499,
2434,
1288,
277,
14,
17077,
364,
2528,
63,
3191,
63,
1080,
63,
466,
63,
354,
9,
288,
1995
] |
[
199,
73,
25928,
284,
22664,
397,
2846,
1798,
14,
199,
199,
17763,
26,
199,
13,
1455,
921,
711,
364,
5135,
14,
1308,
15,
649,
324,
397,
2846,
199,
199,
5949,
26,
6848,
973,
869,
540,
33,
2233,
199,
13921,
1434,
26,
5851,
18336,
833,
8315,
199,
624,
199,
199,
504,
394,
21301,
63,
2087,
492,
10191,
199,
504,
394,
21301,
63,
1018,
14,
698,
492,
334,
23532,
12,
272,
10666,
24,
12,
10666,
975,
12,
10666,
708,
12,
9805,
708,
12,
10666,
772,
12,
18267,
3399,
708,
12,
272,
2624,
12,
11140,
708,
12,
12119,
5571,
12,
11305,
12,
13480,
5571,
9,
199,
504,
394,
21301,
63,
1018,
14,
15009,
492,
491,
31783,
63,
21046,
199,
504,
394,
21301,
63,
1018,
14,
2537,
492,
11779,
13283,
199,
504,
394,
21301,
63,
1018,
14,
505,
63,
2232,
492,
2929,
2461,
12,
23858,
2461,
199,
199,
513,
63,
1648,
3126,
267,
413,
520,
298,
10411,
1865,
334,
9285,
4069,
1865,
4186,
267,
499,
520,
298,
10674,
15583,
267,
650,
520,
298,
19351,
1213,
401,
267,
841,
520,
298,
12110,
401,
267,
959,
520,
298,
11215,
401,
267,
1227,
520,
298,
24484,
401,
267,
1520,
520,
298,
23553,
401,
267,
1695,
520,
298,
5091,
401,
267,
1749,
520,
298,
602,
6042,
401,
267,
1616,
520,
298,
3885,
1329,
401,
267,
4119,
520,
298,
890,
401,
267,
3144,
520,
298,
521,
401,
267,
4944,
520,
298,
3403,
401,
267,
4329,
520,
298,
3271,
6634,
401,
267,
4114,
520,
298,
3349,
401,
267,
3193,
520,
298,
602,
3483,
401,
267,
5557,
520,
298,
1452,
1793,
401,
267,
6155,
520,
298,
7784,
332,
401,
267,
5851,
520,
298,
10674,
15583,
267,
3388,
520,
298,
2802,
2338,
401,
267,
7829,
520,
298,
2019,
5232,
379,
401,
267,
6928,
520,
298,
6409,
1329,
401,
267,
6546,
520,
298,
1662,
18360,
401,
267,
5504,
520,
298,
3221,
1434,
401,
267,
5661,
520,
298,
34,
10793,
401,
267,
7875,
520,
298,
22390,
401,
267,
8087,
520,
298,
3710,
401,
267,
7294,
520,
298,
1802,
401,
267,
7349,
520,
298,
2384,
401,
267,
4233,
520,
298,
12605,
401,
267,
7105,
520,
298,
9544,
1329,
2,
272,
789,
199,
199,
533,
3918,
1692,
8,
23532,
304,
272,
730,
63,
354,
3126,
267,
413,
5424,
6888,
401,
267,
499,
5424,
6592,
401,
267,
650,
5424,
26369,
401,
267,
841,
5424,
27711,
401,
267,
959,
5424,
8168,
264,
401,
267,
1227,
5424,
1173,
466,
401,
267,
1520,
5424,
17420,
13510,
401,
267,
1695,
5424,
7488,
401,
267,
1749,
5424,
7841,
401,
267,
3144,
5424,
32325,
401,
267,
4944,
5424,
2448,
316,
401,
267,
4329,
5424,
5831,
1318,
401,
267,
4114,
5424,
25928,
2931,
3447,
13008,
2851,
401,
267,
3193,
5424,
25928,
2931,
30331,
2851,
401,
267,
5557,
5424,
30791,
666,
401,
267,
6155,
5424,
29907,
401,
267,
5851,
5424,
6824,
334,
509,
26990,
12968,
83,
1454,
4186,
267,
3388,
5424,
22887,
401,
267,
7829,
5424,
12764,
7220,
401,
267,
5238,
5424,
29111,
16527,
513,
3918,
401,
267,
8026,
5424,
29111,
16527,
513,
24259,
401,
267,
14589,
5424,
7424,
16527,
513,
5499,
401,
267,
2948,
5424,
4547,
2256,
401,
267,
1926,
5424,
26369,
536,
334,
509,
16379,
18714,
4186,
267,
1784,
5424,
26369,
16459,
334,
509,
16379,
18714,
4186,
267,
19328,
5424,
26369,
4069,
16459,
334,
509,
16379,
18714,
2924,
272,
789,
339,
333,
72,
364,
2528,
63,
3191,
63,
1080,
63,
466,
63,
354,
3126,
267,
650,
5424,
6888,
401,
267,
841,
5424,
26369,
12,
2066,
26287,
15,
7927,
1955,
12,
2066,
16881,
401,
267,
959,
5424,
27711,
12,
2066,
4580,
7767,
12,
2066,
5289,
67,
15,
7927,
1955,
12,
2066,
16881,
401,
267,
1520,
5424,
8168,
264,
12,
2066,
1952,
5011,
12,
2066,
4580,
7767,
12,
2066,
5289,
67,
15,
7927,
1955,
12,
2066,
16881,
401,
267,
1695,
5424,
32325,
12,
2066,
16881,
2,
272,
789,
339,
347,
636,
826,
721,
277,
12,
627,
589,
12,
1011,
829,
304,
267,
5024,
1084,
855,
826,
721,
277,
12,
627,
589,
12,
1011,
829,
9,
267,
291,
423,
890,
275,
291,
905,
2373,
63,
1267,
4140,
585,
627,
24,
339,
347,
24828,
8,
277,
304,
267,
1995,
2624,
8,
277,
12,
298,
1291,
63,
344,
401,
841,
12,
298,
1451,
6935,
10240,
17504,
334,
4451,
17077,
364,
60,
531,
401,
5960,
628,
7336,
13,
4830,
13,
17,
531,
267,
1995,
10666,
708,
8,
277,
12,
298,
1291,
63,
1267,
401,
298,
2567,
19893,
531,
267,
1995,
10666,
708,
8,
277,
12,
298,
2373,
63,
1267,
401,
298,
3900,
19893,
531,
267,
1995,
11305,
8,
13304,
708,
8,
277,
12,
298,
466,
401,
298,
466,
1288,
277,
14,
466,
63,
354,
9,
267,
340,
8,
277,
905,
466,
4140,
585,
28,
1046,
9,
503,
334,
277,
905,
466,
4140,
585,
2356,
1926,
304,
288,
1995,
10666,
708,
8,
277,
12,
298,
5187,
31346,
288,
1995,
10666,
708,
8,
277,
12,
298,
5187,
31346,
288,
1995,
10666,
708,
8,
277,
12,
298,
3124,
401,
298,
5625,
531,
288,
1995,
10666,
708,
8,
277,
12,
298,
1267,
401,
298,
1558,
19893,
315,
2783,
531,
288,
1995,
10666,
708,
8,
277,
12,
298,
5187,
31346,
288,
1995,
10666,
708,
8,
277,
12,
298,
5187,
31346,
288,
1995,
2624,
8,
277,
12,
298,
875,
401,
291,
905,
1267,
4140,
585,
12,
298,
1558,
3918,
401,
5960,
628,
6610,
13,
975,
13,
906,
531,
267,
916,
334,
277,
905,
466,
4140,
585,
28,
1196,
304,
288,
1995,
10666,
708,
8,
277,
12,
298,
5187,
31346,
288,
1995,
10666,
708,
8,
277,
12,
298,
5187,
31346,
288,
1995,
2624,
8,
277,
12,
298,
875,
401,
291,
423,
890,
15,
24,
13,
277,
905,
1291,
63,
1267,
4140,
585,
12,
298,
1558,
3918,
401,
5960,
628,
6610,
13,
24,
531,
267,
916,
334,
277,
905,
466,
4140,
585,
508,
14589,
304,
288,
1995,
10666,
708,
8,
277,
12,
298,
5187,
20204,
298,
1778,
17,
531,
288,
1995,
10666,
708,
8,
277,
12,
298,
5187,
20204,
298,
1778,
18,
531,
288,
1995,
11305,
8,
13304,
708,
8,
277,
12,
298,
3191,
63,
1080,
63,
466,
401,
298,
14376,
5499,
2434,
1288,
277,
14,
17077,
364,
2528,
63,
3191,
63,
1080,
63,
466,
63,
354,
9,
288,
1995,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
hydroffice/hyo_ssp
|
hydroffice/ssp/drivers/saiv.py
|
1
|
6625
|
from __future__ import absolute_import, division, print_function, unicode_literals
import datetime as dt
import numpy as np
import logging
log = logging.getLogger(__name__)
from .base_format import BaseFormat, FormatError
from .. import __version__
from ..ssp_dicts import Dicts
class Saiv(BaseFormat):
def __init__(self, file_content):
super(Saiv, self).__init__(file_content=file_content)
self.name = "SAI"
self.driver = self.name + (".%s" % __version__)
self.header_token = 'Ser\tMeas'
self.depth_token = 'Press'
self.speed_token = 'S. vel.'
self.temp_token = 'Temp'
self.sal_token = 'Sal.'
self.date_token = 'Date'
self.time_token = 'Time'
self.probe_type_token = 'From file:'
log.info("reading ...")
lines = self.file_content.splitlines()
self._read_header(lines)
self._read_body(lines)
def _read_header(self, lines):
log.info("reading > header")
got_date = False
got_time = False
got_depth = False
got_speed = False
got_temperature = False
got_salinity = False
got_cast_header = False
probe_type = ''
self.samples_offset = 0
for line in lines:
if line[:len(self.header_token)] == self.header_token:
got_cast_header = True
log.info("header line for fields: %s" % line)
column = 0
for field_type in line.split('\t'):
self.data_index[field_type] = int(column)
if field_type == self.depth_token:
log.info('col for pressure: %s' % column)
got_depth = True
elif field_type == self.temp_token:
log.info('col for temperature: %s' % column)
got_temperature = True
elif field_type == self.sal_token:
log.info('col for salinity: %s' % column)
got_salinity = True
elif field_type == self.speed_token:
log.info('col for sound speed: %s' % column)
got_speed = True
elif field_type == self.date_token:
log.info('col for date: %s' % column)
got_date = True
elif field_type == self.time_token:
log.info('col for time: %s' % column)
got_time = True
column += 1
self.samples_offset += 2
break
elif line[:len(self.probe_type_token)] == self.probe_type_token:
try:
probe_type = line.split(':')[1].split()[0].strip()
log.info('probe type: %s' % probe_type)
except (IndexError, ValueError):
pass
self.samples_offset += 1
if not got_cast_header or \
not got_depth or not got_speed or not got_temperature or not got_salinity or \
not got_date or not got_time:
if not got_cast_header:
log.error("missing cast header")
if not got_depth:
log.error("missing depth field (need depth 'Depth' field)")
if not got_speed:
log.error("missing speed field (need speed 'Sound Velocity (calc)' field)")
if not got_temperature:
log.error("missing temperature field (need temperature 'Temperature' field)")
if not got_salinity:
log.error("missing salinity field (need salinity 'Salinity' field)")
if not got_date:
log.error("missing date field (need date 'Date' field)")
if not got_time:
log.error("missing time field (need time 'Time' field)")
return
self.num_samples = len(lines) - self.samples_offset
if self.num_samples == 0:
log.error('no data samples')
return
log.info('samples: %s' % self.num_samples)
if probe_type != 'S2':
log.info("unknown probe type: %s -> forcing S2" % probe_type)
probe_type = 'S2'
self.probe_type = Dicts.probe_types[probe_type]
self.sensor_type = Dicts.sensor_types["CTD"]
self.depth = np.zeros(self.num_samples)
self.speed = np.zeros(self.num_samples)
self.temperature = np.zeros(self.num_samples)
self.salinity = np.zeros(self.num_samples)
def _read_body(self, lines):
log.info("reading > body")
count = 0
valid_date = False
valid_time = False
for line in lines[self.samples_offset:len(lines)]:
try:
# In case an incomplete file comes through
data = line.split()
self.depth[count] = float(data[self.data_index[self.depth_token]])
self.speed[count] = float(data[self.data_index[self.speed_token]])
self.temperature[count] = float(data[self.data_index[self.temp_token]])
self.salinity[count] = float(data[self.data_index[self.sal_token]])
if not valid_date and not valid_time:
# date
date_string = data[self.data_index[self.date_token]]
month = int(date_string.split('/')[1])
day = int(date_string.split('/')[0])
year = int(date_string.split('/')[2])
valid_date = True
log.info('date: %s/%s/%s' % (day, month, year))
# time
time_string = data[self.data_index[self.time_token]]
valid_time = True
hour = int(time_string.split(':')[0])
minute = int(time_string.split(':')[1])
second = int(time_string.split(':')[2])
log.info('time: %s:%s:%s' % (hour, minute, second))
if (year is not None) and (hour is not None):
self.dg_time = dt.datetime(year, month, day, hour, minute, second)
except ValueError:
log.error("skipping line %s" % count)
continue
count += 1
if self.num_samples != count:
self.depth.resize(count)
self.speed.resize(count)
self.temperature.resize(count)
self.salinity.resize(count)
self.num_samples = count
|
lgpl-3.0
|
[
504,
636,
2443,
363,
492,
3679,
63,
646,
12,
4629,
12,
870,
63,
1593,
12,
2649,
63,
5955,
199,
199,
646,
2197,
465,
4487,
199,
646,
2680,
465,
980,
199,
646,
2050,
199,
199,
793,
275,
2050,
14,
5572,
3460,
354,
3368,
199,
199,
504,
1275,
1095,
63,
908,
492,
3523,
3484,
12,
9701,
547,
199,
504,
2508,
492,
636,
1023,
363,
199,
504,
2508,
385,
80,
63,
7892,
492,
3757,
3021,
421,
199,
533,
428,
65,
1003,
8,
1563,
3484,
304,
339,
347,
636,
826,
721,
277,
12,
570,
63,
1317,
304,
267,
1613,
8,
12226,
1003,
12,
291,
2843,
826,
721,
493,
63,
1317,
29,
493,
63,
1317,
9,
267,
291,
14,
354,
275,
298,
4251,
41,
2,
267,
291,
14,
3090,
275,
291,
14,
354,
435,
334,
1674,
5,
83,
2,
450,
636,
1023,
3368,
398,
291,
14,
1291,
63,
1418,
275,
283,
1505,
60,
84,
1352,
305,
7,
267,
291,
14,
4631,
63,
1418,
275,
283,
14414,
7,
267,
291,
14,
7625,
63,
1418,
275,
283,
51,
14,
373,
352,
3530,
267,
291,
14,
808,
63,
1418,
275,
283,
6530,
7,
267,
291,
14,
6327,
63,
1418,
275,
283,
27177,
3530,
267,
291,
14,
602,
63,
1418,
275,
283,
2506,
7,
267,
291,
14,
521,
63,
1418,
275,
283,
1366,
7,
267,
291,
14,
15944,
63,
466,
63,
1418,
275,
283,
2532,
570,
4881,
398,
943,
14,
815,
480,
19332,
2263,
531,
267,
2385,
275,
291,
14,
493,
63,
1317,
14,
7644,
342,
398,
291,
423,
739,
63,
1291,
8,
1278,
9,
267,
291,
423,
739,
63,
2030,
8,
1278,
9,
339,
347,
485,
739,
63,
1291,
8,
277,
12,
2385,
304,
267,
943,
14,
815,
480,
19332,
690,
1406,
531,
398,
4788,
63,
602,
275,
756,
267,
4788,
63,
521,
275,
756,
267,
4788,
63,
4631,
275,
756,
267,
4788,
63,
7625,
275,
756,
267,
4788,
63,
12954,
275,
756,
267,
4788,
63,
6327,
9624,
275,
756,
267,
4788,
63,
2931,
63,
1291,
275,
756,
398,
22362,
63,
466,
275,
2125,
398,
291,
14,
3356,
63,
2743,
275,
378,
398,
367,
1004,
315,
2385,
26,
953,
340,
1004,
1491,
552,
8,
277,
14,
1291,
63,
1418,
1874,
508,
291,
14,
1291,
63,
1418,
26,
355,
4788,
63,
2931,
63,
1291,
275,
715,
355,
943,
14,
815,
480,
1291,
1004,
367,
1504,
26,
450,
83,
2,
450,
1004,
9,
2234,
2763,
275,
378,
355,
367,
901,
63,
466,
315,
1004,
14,
1294,
2258,
84,
735,
490,
291,
14,
576,
63,
1080,
59,
698,
63,
466,
61,
275,
1109,
8,
2301,
9,
490,
340,
901,
63,
466,
508,
291,
14,
4631,
63,
1418,
26,
717,
943,
14,
815,
360,
761,
367,
25471,
26,
450,
83,
7,
450,
2763,
9,
717,
4788,
63,
4631,
275,
715,
490,
916,
901,
63,
466,
508,
291,
14,
808,
63,
1418,
26,
717,
943,
14,
815,
360,
761,
367,
14843,
26,
450,
83,
7,
450,
2763,
9,
717,
4788,
63,
12954,
275,
715,
490,
916,
901,
63,
466,
508,
291,
14,
6327,
63,
1418,
26,
717,
943,
14,
815,
360,
761,
367,
18641,
9624,
26,
450,
83,
7,
450,
2763,
9,
717,
4788,
63,
6327,
9624,
275,
715,
490,
916,
901,
63,
466,
508,
291,
14,
7625,
63,
1418,
26,
717,
943,
14,
815,
360,
761,
367,
20453,
8112,
26,
450,
83,
7,
450,
2763,
9,
717,
4788,
63,
7625,
275,
715,
490,
916,
901,
63,
466,
508,
291,
14,
602,
63,
1418,
26,
717,
943,
14,
815,
360,
761,
367,
1434,
26,
450,
83,
7,
450,
2763,
9,
717,
4788,
63,
602,
275,
715,
490,
916,
901,
63,
466,
508,
291,
14,
521,
63,
1418,
26,
717,
943,
14,
815,
360,
761,
367,
900,
26,
450,
83,
7,
450,
2763,
9,
717,
4788,
63,
521,
275,
715,
490,
2763,
847,
413,
2234,
291,
14,
3356,
63,
2743,
847,
499,
355,
2059,
953,
916,
1004,
1491,
552,
8,
277,
14,
15944,
63,
466,
63,
1418,
1874,
508,
291,
14,
15944,
63,
466,
63,
1418,
26,
355,
862,
26,
490,
22362,
63,
466,
275,
1004,
14,
1294,
24050,
17,
1055,
1294,
3430,
16,
1055,
1913,
342,
490,
943,
14,
815,
360,
15944,
730,
26,
450,
83,
7,
450,
22362,
63,
466,
9,
355,
871,
334,
12129,
12,
1722,
304,
490,
986,
953,
291,
14,
3356,
63,
2743,
847,
413,
398,
340,
440,
4788,
63,
2931,
63,
1291,
503,
971,
355,
440,
4788,
63,
4631,
503,
440,
4788,
63,
7625,
503,
440,
4788,
63,
12954,
503,
440,
4788,
63,
6327,
9624,
503,
971,
355,
440,
4788,
63,
602,
503,
440,
4788,
63,
521,
26,
288,
340,
440,
4788,
63,
2931,
63,
1291,
26,
355,
943,
14,
705,
480,
4752,
9106,
1406,
531,
288,
340,
440,
4788,
63,
4631,
26,
355,
943,
14,
705,
480,
4752,
5818,
901,
334,
9321,
5818,
283,
14125,
7,
901,
6320,
288,
340,
440,
4788,
63,
7625,
26,
355,
943,
14,
705,
480,
4752,
8112,
901,
334,
9321,
8112,
283,
18670,
25777,
14284,
334,
8104,
3171,
901,
6320,
288,
340,
440,
4788,
63,
12954,
26,
355,
943,
14,
705,
480,
4752,
14843,
901,
334,
9321,
14843,
283,
27409,
7,
901,
6320,
288,
340,
440,
4788,
63,
6327,
9624,
26,
355,
943,
14,
705,
480,
4752,
18641,
9624,
901,
334,
9321,
18641,
9624,
283,
27177,
9624,
7,
901,
6320,
288,
340,
440,
4788,
63,
602,
26,
355,
943,
14,
705,
480,
4752,
1434,
901,
334,
9321,
1434,
283,
2506,
7,
901,
6320,
288,
340,
440,
4788,
63,
521,
26,
355,
943,
14,
705,
480,
4752,
900,
901,
334,
9321,
900,
283,
1366,
7,
901,
6320,
288,
372,
398,
291,
14,
1507,
63,
3356,
275,
822,
8,
1278,
9,
446,
291,
14,
3356,
63,
2743,
267,
340,
291,
14,
1507,
63,
3356,
508,
378,
26,
288,
943,
14,
705,
360,
889,
666,
5845,
358,
288,
372,
267,
943,
14,
815,
360,
3356,
26,
450,
83,
7,
450,
291,
14,
1507,
63,
3356,
9,
398,
340,
22362,
63,
466,
1137,
283,
51,
18,
356,
288,
943,
14,
815,
480,
5187,
22362,
730,
26,
450,
83,
1035,
31070,
428,
18,
2,
450,
22362,
63,
466,
9,
288,
22362,
63,
466,
275,
283,
51,
18,
7,
267,
291,
14
] |
[
636,
2443,
363,
492,
3679,
63,
646,
12,
4629,
12,
870,
63,
1593,
12,
2649,
63,
5955,
199,
199,
646,
2197,
465,
4487,
199,
646,
2680,
465,
980,
199,
646,
2050,
199,
199,
793,
275,
2050,
14,
5572,
3460,
354,
3368,
199,
199,
504,
1275,
1095,
63,
908,
492,
3523,
3484,
12,
9701,
547,
199,
504,
2508,
492,
636,
1023,
363,
199,
504,
2508,
385,
80,
63,
7892,
492,
3757,
3021,
421,
199,
533,
428,
65,
1003,
8,
1563,
3484,
304,
339,
347,
636,
826,
721,
277,
12,
570,
63,
1317,
304,
267,
1613,
8,
12226,
1003,
12,
291,
2843,
826,
721,
493,
63,
1317,
29,
493,
63,
1317,
9,
267,
291,
14,
354,
275,
298,
4251,
41,
2,
267,
291,
14,
3090,
275,
291,
14,
354,
435,
334,
1674,
5,
83,
2,
450,
636,
1023,
3368,
398,
291,
14,
1291,
63,
1418,
275,
283,
1505,
60,
84,
1352,
305,
7,
267,
291,
14,
4631,
63,
1418,
275,
283,
14414,
7,
267,
291,
14,
7625,
63,
1418,
275,
283,
51,
14,
373,
352,
3530,
267,
291,
14,
808,
63,
1418,
275,
283,
6530,
7,
267,
291,
14,
6327,
63,
1418,
275,
283,
27177,
3530,
267,
291,
14,
602,
63,
1418,
275,
283,
2506,
7,
267,
291,
14,
521,
63,
1418,
275,
283,
1366,
7,
267,
291,
14,
15944,
63,
466,
63,
1418,
275,
283,
2532,
570,
4881,
398,
943,
14,
815,
480,
19332,
2263,
531,
267,
2385,
275,
291,
14,
493,
63,
1317,
14,
7644,
342,
398,
291,
423,
739,
63,
1291,
8,
1278,
9,
267,
291,
423,
739,
63,
2030,
8,
1278,
9,
339,
347,
485,
739,
63,
1291,
8,
277,
12,
2385,
304,
267,
943,
14,
815,
480,
19332,
690,
1406,
531,
398,
4788,
63,
602,
275,
756,
267,
4788,
63,
521,
275,
756,
267,
4788,
63,
4631,
275,
756,
267,
4788,
63,
7625,
275,
756,
267,
4788,
63,
12954,
275,
756,
267,
4788,
63,
6327,
9624,
275,
756,
267,
4788,
63,
2931,
63,
1291,
275,
756,
398,
22362,
63,
466,
275,
2125,
398,
291,
14,
3356,
63,
2743,
275,
378,
398,
367,
1004,
315,
2385,
26,
953,
340,
1004,
1491,
552,
8,
277,
14,
1291,
63,
1418,
1874,
508,
291,
14,
1291,
63,
1418,
26,
355,
4788,
63,
2931,
63,
1291,
275,
715,
355,
943,
14,
815,
480,
1291,
1004,
367,
1504,
26,
450,
83,
2,
450,
1004,
9,
2234,
2763,
275,
378,
355,
367,
901,
63,
466,
315,
1004,
14,
1294,
2258,
84,
735,
490,
291,
14,
576,
63,
1080,
59,
698,
63,
466,
61,
275,
1109,
8,
2301,
9,
490,
340,
901,
63,
466,
508,
291,
14,
4631,
63,
1418,
26,
717,
943,
14,
815,
360,
761,
367,
25471,
26,
450,
83,
7,
450,
2763,
9,
717,
4788,
63,
4631,
275,
715,
490,
916,
901,
63,
466,
508,
291,
14,
808,
63,
1418,
26,
717,
943,
14,
815,
360,
761,
367,
14843,
26,
450,
83,
7,
450,
2763,
9,
717,
4788,
63,
12954,
275,
715,
490,
916,
901,
63,
466,
508,
291,
14,
6327,
63,
1418,
26,
717,
943,
14,
815,
360,
761,
367,
18641,
9624,
26,
450,
83,
7,
450,
2763,
9,
717,
4788,
63,
6327,
9624,
275,
715,
490,
916,
901,
63,
466,
508,
291,
14,
7625,
63,
1418,
26,
717,
943,
14,
815,
360,
761,
367,
20453,
8112,
26,
450,
83,
7,
450,
2763,
9,
717,
4788,
63,
7625,
275,
715,
490,
916,
901,
63,
466,
508,
291,
14,
602,
63,
1418,
26,
717,
943,
14,
815,
360,
761,
367,
1434,
26,
450,
83,
7,
450,
2763,
9,
717,
4788,
63,
602,
275,
715,
490,
916,
901,
63,
466,
508,
291,
14,
521,
63,
1418,
26,
717,
943,
14,
815,
360,
761,
367,
900,
26,
450,
83,
7,
450,
2763,
9,
717,
4788,
63,
521,
275,
715,
490,
2763,
847,
413,
2234,
291,
14,
3356,
63,
2743,
847,
499,
355,
2059,
953,
916,
1004,
1491,
552,
8,
277,
14,
15944,
63,
466,
63,
1418,
1874,
508,
291,
14,
15944,
63,
466,
63,
1418,
26,
355,
862,
26,
490,
22362,
63,
466,
275,
1004,
14,
1294,
24050,
17,
1055,
1294,
3430,
16,
1055,
1913,
342,
490,
943,
14,
815,
360,
15944,
730,
26,
450,
83,
7,
450,
22362,
63,
466,
9,
355,
871,
334,
12129,
12,
1722,
304,
490,
986,
953,
291,
14,
3356,
63,
2743,
847,
413,
398,
340,
440,
4788,
63,
2931,
63,
1291,
503,
971,
355,
440,
4788,
63,
4631,
503,
440,
4788,
63,
7625,
503,
440,
4788,
63,
12954,
503,
440,
4788,
63,
6327,
9624,
503,
971,
355,
440,
4788,
63,
602,
503,
440,
4788,
63,
521,
26,
288,
340,
440,
4788,
63,
2931,
63,
1291,
26,
355,
943,
14,
705,
480,
4752,
9106,
1406,
531,
288,
340,
440,
4788,
63,
4631,
26,
355,
943,
14,
705,
480,
4752,
5818,
901,
334,
9321,
5818,
283,
14125,
7,
901,
6320,
288,
340,
440,
4788,
63,
7625,
26,
355,
943,
14,
705,
480,
4752,
8112,
901,
334,
9321,
8112,
283,
18670,
25777,
14284,
334,
8104,
3171,
901,
6320,
288,
340,
440,
4788,
63,
12954,
26,
355,
943,
14,
705,
480,
4752,
14843,
901,
334,
9321,
14843,
283,
27409,
7,
901,
6320,
288,
340,
440,
4788,
63,
6327,
9624,
26,
355,
943,
14,
705,
480,
4752,
18641,
9624,
901,
334,
9321,
18641,
9624,
283,
27177,
9624,
7,
901,
6320,
288,
340,
440,
4788,
63,
602,
26,
355,
943,
14,
705,
480,
4752,
1434,
901,
334,
9321,
1434,
283,
2506,
7,
901,
6320,
288,
340,
440,
4788,
63,
521,
26,
355,
943,
14,
705,
480,
4752,
900,
901,
334,
9321,
900,
283,
1366,
7,
901,
6320,
288,
372,
398,
291,
14,
1507,
63,
3356,
275,
822,
8,
1278,
9,
446,
291,
14,
3356,
63,
2743,
267,
340,
291,
14,
1507,
63,
3356,
508,
378,
26,
288,
943,
14,
705,
360,
889,
666,
5845,
358,
288,
372,
267,
943,
14,
815,
360,
3356,
26,
450,
83,
7,
450,
291,
14,
1507,
63,
3356,
9,
398,
340,
22362,
63,
466,
1137,
283,
51,
18,
356,
288,
943,
14,
815,
480,
5187,
22362,
730,
26,
450,
83,
1035,
31070,
428,
18,
2,
450,
22362,
63,
466,
9,
288,
22362,
63,
466,
275,
283,
51,
18,
7,
267,
291,
14,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
khughitt/ete
|
ete_dev/evol/control.py
|
2
|
10378
|
#!/usr/bin/python
"""
Parameters for running codeml
"""
__author__ = "Francois-Jose Serra"
__email__ = "francois@barrabin.org"
__licence__ = "GPLv3"
__version__ = "0.0"
PARAMS = {
'seqfile' : 'algn',
'treefile' : 'tree',
'outfile' : 'out',
'noisy' : 0,
'verbose' : 2,
'runmode' : 0,
'seqtype' : 1,
'CodonFreq' : 2,
'clock' : 0,
'aaDist' : 0,
'model' : 0,
'NSsites' : 2,
'icode' : 0,
'Mgene' : 0,
'fix_kappa' : 0,
'kappa' : 2,
'ndata' : '*10',
'fix_omega' : 0,
'omega' : 0.7,
'fix_alpha' : 1,
'alpha' : 0., # if 0 -> infinity
'Malpha' : 0,
'ncatG' : 8,
'getSE' : 0,
'RateAncestor' : 0,
'fix_blength' : 0,
'Small_Diff' : '1e-6',
'cleandata' : 0,
'method' : 0
}
AVAIL = {
'M0' : {'typ': 'null' , 'evol': 'negative-selection',
'exec': 'codeml',
'allow_mark': False,
'changes': [('NSsites' , 0),
('alpha' , '*'),
('method' , '*'),
('Malpha' , '*'),
('fix_alpha' , '*')]},
'M1' : {'typ': 'site' , 'evol': 'relaxation',
'exec': 'codeml',
'allow_mark': False,
'changes': [('NSsites' , 1),
('alpha' , '*'),
('method' , '*'),
('Malpha' , '*'),
('fix_alpha' , '*')]},
'M2' : {'typ': 'site' , 'evol': 'positive-selection',
'exec': 'codeml',
'allow_mark': False,
'changes': [('NSsites' , 2),
('omega' , 1.7),
('alpha' , '*'),
('method' , '*'),
('Malpha' , '*'),
('fix_alpha' , '*')]},
'M3' : {'typ': 'site' , 'evol': 'discrete',
'exec': 'codeml',
'allow_mark': False,
'changes': [('NSsites' , 3),
('omega' , .7),
('ncatG' , 3),
('alpha' , '*'),
('method' , '*'),
('Malpha' , '*'),
('fix_alpha' , '*')]},
'M4' : {'typ': 'site' , 'evol': 'frequencies',
'exec': 'codeml',
'allow_mark': False,
'changes': [('NSsites' , 4),
('omega' , .7),
('alpha' , '*'),
('method' , '*'),
('Malpha' , '*'),
('fix_alpha' , '*')]},
'M5' : {'typ': 'site' , 'evol': 'gamma',
'exec': 'codeml',
'allow_mark': False,
'changes': [('NSsites' , 5),
('omega' , .7),
('alpha' , '*'),
('method' , '*'),
('Malpha' , '*'),
('fix_alpha' , '*')]},
'M6' : {'typ': 'site' , 'evol': '2 gamma',
'exec': 'codeml',
'allow_mark': False,
'changes': [('NSsites' , 5),
('omega' , .7),
('alpha' , '*'),
('method' , '*'),
('Malpha' , '*'),
('fix_alpha' , '*')]},
'M7' : {'typ': 'site' , 'evol': 'relaxation',
'exec': 'codeml',
'allow_mark': False,
'changes': [('NSsites' , 7),
('alpha' , '*'),
('method' , '*'),
('Malpha' , '*'),
('fix_alpha' , '*')]},
'M8a' : {'typ': 'site' , 'evol': 'relaxation',
'exec': 'codeml',
'allow_mark': False,
'changes': [('NSsites' , 8),
('fix_omega' , 1),
('omega' , 1),
('alpha' , '*'),
('method' , '*'),
('Malpha' , '*'),
('fix_alpha' , '*')]},
'M8' : {'typ': 'site' , 'evol': 'positive-selection',
'exec': 'codeml',
'allow_mark': False,
'changes': [('NSsites' , 8),
('omega' , 1.7),
('alpha' , '*'),
('method' , '*'),
('Malpha' , '*'),
('fix_alpha' , '*')]},
'M9' : {'typ': 'site' , 'evol': 'beta and gamma',
'exec': 'codeml',
'allow_mark': False,
'changes': [('NSsites' , 9),
('alpha' , '*'),
('method' , '*'),
('Malpha' , '*'),
('fix_alpha' , '*')]},
'M10' : {'typ': 'site' , 'evol': 'beta and gamma + 1',
'exec': 'codeml',
'allow_mark': False,
'changes': [('NSsites' , 10),
('alpha' , '*'),
('method' , '*'),
('Malpha' , '*'),
('fix_alpha' , '*')]},
'M11' : {'typ': 'site' , 'evol': 'beta and normal > 1',
'exec': 'codeml',
'allow_mark': False,
'changes': [('NSsites' , 11),
('alpha' , '*'),
('method' , '*'),
('Malpha' , '*'),
('fix_alpha' , '*')]},
'M12' : {'typ': 'site' , 'evol': '0 and 2 normal > 2',
'exec': 'codeml',
'allow_mark': False,
'changes': [('NSsites' , 12),
('alpha' , '*'),
('method' , '*'),
('Malpha' , '*'),
('fix_alpha' , '*')]},
'M13' : {'typ': 'site' , 'evol': '3 normal > 0',
'exec': 'codeml',
'allow_mark': False,
'changes': [('NSsites' , 13),
('alpha' , '*'),
('method' , '*'),
('Malpha' , '*'),
('fix_alpha' , '*')]},
'fb' : {'typ': 'branch' , 'evol': 'free-ratios',
'exec': 'codeml',
'allow_mark': False ,
'changes': [('model' , 1),
('NSsites' , 0)]},
'fb_anc': {'typ': 'branch_ancestor' , 'evol': 'free-ratios',
'exec': 'codeml',
'allow_mark': False ,
'changes': [('model' , 1),
('RateAncestor', 1),
('NSsites' , 0)]},
'b_free': {'typ': 'branch' , 'evol': 'positive-selection',
'exec': 'codeml',
'allow_mark': True ,
'changes': [('model' , 2),
('NSsites' , 0)]},
'b_neut': {'typ': 'branch' , 'evol': 'relaxation',
'exec': 'codeml',
'allow_mark': True ,
'changes': [('model' , 2),
('NSsites' , 0),
('fix_omega' , 1),
('omega' , 1)]},
'bsA1' : {'typ': 'branch-site', 'evol': 'relaxation',
'exec': 'codeml',
'allow_mark': True ,
'changes': [('model' , 2),
('NSsites' , 2),
('fix_omega' , 1),
('omega' , 1),
('ncatG' , '*')]},
'bsA' : {'typ': 'branch-site', 'evol': 'positive-selection',
'exec': 'codeml',
'allow_mark': True ,
'changes': [('model' , 2),
('NSsites' , 2),
('omega' , 1.7),
('ncatG' , '*')]},
'bsB' : {'typ': 'branch-site', 'evol': 'positive-selection',
'exec': 'codeml',
'allow_mark': True ,
'changes': [('model' , 2),
('NSsites' , 3),
('omega' , 1.7),
('ncatG' , '*')]},
'bsC' : {'typ': 'branch-site', 'evol': 'different-ratios',
'exec': 'codeml',
'allow_mark': True ,
'changes': [('model' , 3),
('NSsites' , 2),
('ncatG' , 3)]},
'bsD' : {'typ': 'branch-site', 'evol': 'different-ratios',
'exec': 'codeml',
'allow_mark': True ,
'changes': [('model' , 3),
('NSsites' , 3),
('ncatG' , 3)]},
'SLR' : {'typ' : 'site', 'evol': 'positive/negative selection',
'exec': 'Slr',
'sep' : '= ',
'allow_mark': False ,
'changes': map (lambda x: (x[0], '*'),
filter (lambda x: 'file' not in x[0],
PARAMS.items())) + \
[('positive_only', '0')]}
}
|
gpl-3.0
|
[
3381,
2647,
15,
1393,
15,
1548,
199,
624,
199,
5976,
367,
3879,
1233,
757,
199,
624,
199,
199,
363,
2502,
363,
221,
275,
298,
38,
1312,
331,
374,
13,
42,
3362,
3739,
345,
2,
199,
363,
2123,
363,
257,
275,
298,
70,
1312,
331,
374,
32,
1700,
345,
1393,
14,
1308,
2,
199,
363,
606,
4894,
363,
275,
298,
28863,
19,
2,
199,
363,
1023,
363,
275,
298,
16,
14,
16,
2,
421,
199,
17978,
275,
469,
272,
283,
3610,
493,
7,
420,
520,
283,
279,
784,
297,
272,
283,
2350,
493,
7,
258,
520,
283,
2350,
297,
272,
283,
4984,
7,
420,
520,
283,
548,
297,
272,
283,
889,
19765,
7,
263,
520,
378,
12,
272,
283,
3832,
7,
420,
520,
499,
12,
272,
283,
1065,
632,
7,
420,
520,
378,
12,
272,
283,
3610,
466,
7,
420,
520,
413,
12,
272,
283,
35,
364,
265,
13875,
7,
259,
520,
499,
12,
272,
283,
9597,
7,
263,
520,
378,
12,
272,
283,
2158,
12012,
7,
755,
520,
378,
12,
272,
283,
1238,
7,
263,
520,
378,
12,
272,
283,
2709,
8619,
7,
420,
520,
499,
12,
272,
283,
1525,
7,
263,
520,
378,
12,
272,
283,
45,
10654,
7,
263,
520,
378,
12,
272,
283,
970,
63,
31918,
7,
259,
520,
378,
12,
272,
283,
31918,
7,
263,
520,
499,
12,
272,
283,
78,
576,
7,
263,
520,
6438,
709,
297,
272,
283,
970,
63,
23524,
7,
259,
520,
378,
12,
272,
283,
23524,
7,
263,
520,
378,
14,
23,
12,
272,
283,
970,
63,
4468,
7,
259,
520,
413,
12,
272,
283,
4468,
7,
263,
520,
378,
2020,
221,
327,
340,
378,
1035,
23573,
272,
283,
45,
4468,
7,
755,
520,
378,
12,
272,
283,
78,
3385,
39,
7,
263,
520,
1695,
12,
272,
283,
362,
899,
7,
263,
520,
378,
12,
272,
283,
6621,
28942,
8041,
7,
520,
378,
12,
272,
283,
970,
63,
66,
1267,
7,
221,
520,
378,
12,
272,
283,
10712,
63,
10746,
7,
257,
520,
283,
17,
69,
13,
22,
297,
272,
283,
2265,
460,
419,
7,
259,
520,
378,
12,
272,
283,
765,
7,
755,
520,
378,
272,
789,
199,
199,
15004,
275,
469,
272,
283,
45,
16,
7,
259,
520,
221,
791,
9749,
356,
283,
2307,
7,
755,
2360,
283,
69,
5650,
356,
283,
7371,
13,
5592,
297,
355,
283,
1628,
356,
283,
600,
757,
297,
355,
283,
3306,
63,
1657,
356,
756,
12,
355,
283,
6627,
356,
4274,
2709,
8619,
7,
258,
2360,
378,
395,
1169,
661,
4468,
7,
755,
2360,
6438,
659,
1169,
661,
765,
7,
420,
2360,
6438,
659,
1169,
661,
45,
4468,
7,
420,
2360,
6438,
659,
1169,
661,
970,
63,
4468,
7,
257,
2360,
6438,
5440,
1386,
272,
283,
45,
17,
7,
259,
520,
221,
791,
9749,
356,
283,
2124,
7,
755,
2360,
283,
69,
5650,
356,
283,
32676,
425,
297,
355,
283,
1628,
356,
283,
600,
757,
297,
355,
283,
3306,
63,
1657,
356,
756,
12,
355,
283,
6627,
356,
4274,
2709,
8619,
7,
258,
2360,
413,
395,
1169,
661,
4468,
7,
755,
2360,
6438,
659,
1169,
661,
765,
7,
420,
2360,
6438,
659,
1169,
661,
45,
4468,
7,
420,
2360,
6438,
659,
1169,
661,
970,
63,
4468,
7,
257,
2360,
6438,
5440,
1386,
272,
283,
45,
18,
7,
259,
520,
221,
791,
9749,
356,
283,
2124,
7,
755,
2360,
283,
69,
5650,
356,
283,
8965,
13,
5592,
297,
355,
283,
1628,
356,
283,
600,
757,
297,
355,
283,
3306,
63,
1657,
356,
756,
12,
355,
283,
6627,
356,
4274,
2709,
8619,
7,
258,
2360,
499,
395,
1169,
661,
23524,
7,
755,
2360,
413,
14,
23,
395,
1169,
661,
4468,
7,
755,
2360,
6438,
659,
1169,
661,
765,
7,
420,
2360,
6438,
659,
1169,
661,
45,
4468,
7,
420,
2360,
6438,
659,
1169,
661,
970,
63,
4468,
7,
257,
2360,
6438,
5440,
1386,
272,
283,
45,
19,
7,
259,
520,
221,
791,
9749,
356,
283,
2124,
7,
755,
2360,
283,
69,
5650,
356,
283,
23591,
297,
355,
283,
1628,
356,
283,
600,
757,
297,
355,
283,
3306,
63,
1657,
356,
756,
12,
355,
283,
6627,
356,
4274,
2709,
8619,
7,
258,
2360,
650,
395,
1169,
661,
23524,
7,
755,
2360,
1275,
23,
395,
1169,
661,
78,
3385,
39,
7,
755,
2360,
650,
395,
1169,
661,
4468,
7,
755,
2360,
6438,
659,
1169,
661,
765,
7,
420,
2360,
6438,
659,
1169,
661,
45,
4468,
7,
420,
2360,
6438,
659,
1169,
661,
970,
63,
4468,
7,
257,
2360,
6438,
5440,
1386,
272,
283,
45,
20,
7,
259,
520,
221,
791,
9749,
356,
283,
2124,
7,
755,
2360,
283,
69,
5650,
356,
283,
70,
17085,
297,
355,
283,
1628,
356,
283,
600,
757,
297,
355,
283,
3306,
63,
1657,
356,
756,
12,
355,
283,
6627,
356,
4274,
2709,
8619,
7,
258,
2360,
841,
395,
1169,
661,
23524,
7,
755,
2360,
1275,
23,
395,
1169,
661,
4468,
7,
755,
2360,
6438,
659,
1169,
661,
765,
7,
420,
2360,
6438,
659,
1169,
661,
45,
4468,
7,
420,
2360,
6438,
659,
1169,
661,
970,
63,
4468,
7,
257,
2360,
6438,
5440,
1386,
272,
283,
45,
21,
7,
259,
520,
221,
791,
9749,
356,
283,
2124,
7,
755,
2360,
283,
69,
5650,
356,
283,
7325,
297,
355,
283,
1628,
356,
283,
600,
757,
297,
355,
283,
3306,
63,
1657,
356,
756,
12,
355,
283,
6627,
356,
4274,
2709,
8619,
7,
258,
2360,
959,
395,
1169,
661,
23524,
7,
755,
2360,
1275,
23,
395,
1169,
661,
4468,
7,
755,
2360,
6438,
659,
1169,
661,
765,
7,
420,
2360,
6438,
659,
1169,
661,
45,
4468,
7,
420,
2360,
6438,
659,
1169,
661,
970,
63,
4468,
7,
257,
2360,
6438,
5440,
1386,
272,
283,
45,
22,
7,
259,
520,
221,
791,
9749,
356,
283,
2124,
7,
755,
2360,
283,
69,
5650,
356,
283,
18,
10169,
297,
355,
283,
1628,
356,
283,
600,
757,
297,
355,
283,
3306,
63,
1657,
356,
756,
12,
355,
283,
6627,
356,
4274,
2709,
8619,
7,
258,
2360,
959,
395,
1169,
661,
23524,
7,
755,
2360,
1275,
23,
395,
1169,
661,
4468,
7,
755,
2360,
6438,
659,
1169,
661,
765,
7,
420,
2360,
6438,
659,
1169,
661,
45,
4468,
7,
420,
2360,
6438,
659,
1169
] |
[
2647,
15,
1393,
15,
1548,
199,
624,
199,
5976,
367,
3879,
1233,
757,
199,
624,
199,
199,
363,
2502,
363,
221,
275,
298,
38,
1312,
331,
374,
13,
42,
3362,
3739,
345,
2,
199,
363,
2123,
363,
257,
275,
298,
70,
1312,
331,
374,
32,
1700,
345,
1393,
14,
1308,
2,
199,
363,
606,
4894,
363,
275,
298,
28863,
19,
2,
199,
363,
1023,
363,
275,
298,
16,
14,
16,
2,
421,
199,
17978,
275,
469,
272,
283,
3610,
493,
7,
420,
520,
283,
279,
784,
297,
272,
283,
2350,
493,
7,
258,
520,
283,
2350,
297,
272,
283,
4984,
7,
420,
520,
283,
548,
297,
272,
283,
889,
19765,
7,
263,
520,
378,
12,
272,
283,
3832,
7,
420,
520,
499,
12,
272,
283,
1065,
632,
7,
420,
520,
378,
12,
272,
283,
3610,
466,
7,
420,
520,
413,
12,
272,
283,
35,
364,
265,
13875,
7,
259,
520,
499,
12,
272,
283,
9597,
7,
263,
520,
378,
12,
272,
283,
2158,
12012,
7,
755,
520,
378,
12,
272,
283,
1238,
7,
263,
520,
378,
12,
272,
283,
2709,
8619,
7,
420,
520,
499,
12,
272,
283,
1525,
7,
263,
520,
378,
12,
272,
283,
45,
10654,
7,
263,
520,
378,
12,
272,
283,
970,
63,
31918,
7,
259,
520,
378,
12,
272,
283,
31918,
7,
263,
520,
499,
12,
272,
283,
78,
576,
7,
263,
520,
6438,
709,
297,
272,
283,
970,
63,
23524,
7,
259,
520,
378,
12,
272,
283,
23524,
7,
263,
520,
378,
14,
23,
12,
272,
283,
970,
63,
4468,
7,
259,
520,
413,
12,
272,
283,
4468,
7,
263,
520,
378,
2020,
221,
327,
340,
378,
1035,
23573,
272,
283,
45,
4468,
7,
755,
520,
378,
12,
272,
283,
78,
3385,
39,
7,
263,
520,
1695,
12,
272,
283,
362,
899,
7,
263,
520,
378,
12,
272,
283,
6621,
28942,
8041,
7,
520,
378,
12,
272,
283,
970,
63,
66,
1267,
7,
221,
520,
378,
12,
272,
283,
10712,
63,
10746,
7,
257,
520,
283,
17,
69,
13,
22,
297,
272,
283,
2265,
460,
419,
7,
259,
520,
378,
12,
272,
283,
765,
7,
755,
520,
378,
272,
789,
199,
199,
15004,
275,
469,
272,
283,
45,
16,
7,
259,
520,
221,
791,
9749,
356,
283,
2307,
7,
755,
2360,
283,
69,
5650,
356,
283,
7371,
13,
5592,
297,
355,
283,
1628,
356,
283,
600,
757,
297,
355,
283,
3306,
63,
1657,
356,
756,
12,
355,
283,
6627,
356,
4274,
2709,
8619,
7,
258,
2360,
378,
395,
1169,
661,
4468,
7,
755,
2360,
6438,
659,
1169,
661,
765,
7,
420,
2360,
6438,
659,
1169,
661,
45,
4468,
7,
420,
2360,
6438,
659,
1169,
661,
970,
63,
4468,
7,
257,
2360,
6438,
5440,
1386,
272,
283,
45,
17,
7,
259,
520,
221,
791,
9749,
356,
283,
2124,
7,
755,
2360,
283,
69,
5650,
356,
283,
32676,
425,
297,
355,
283,
1628,
356,
283,
600,
757,
297,
355,
283,
3306,
63,
1657,
356,
756,
12,
355,
283,
6627,
356,
4274,
2709,
8619,
7,
258,
2360,
413,
395,
1169,
661,
4468,
7,
755,
2360,
6438,
659,
1169,
661,
765,
7,
420,
2360,
6438,
659,
1169,
661,
45,
4468,
7,
420,
2360,
6438,
659,
1169,
661,
970,
63,
4468,
7,
257,
2360,
6438,
5440,
1386,
272,
283,
45,
18,
7,
259,
520,
221,
791,
9749,
356,
283,
2124,
7,
755,
2360,
283,
69,
5650,
356,
283,
8965,
13,
5592,
297,
355,
283,
1628,
356,
283,
600,
757,
297,
355,
283,
3306,
63,
1657,
356,
756,
12,
355,
283,
6627,
356,
4274,
2709,
8619,
7,
258,
2360,
499,
395,
1169,
661,
23524,
7,
755,
2360,
413,
14,
23,
395,
1169,
661,
4468,
7,
755,
2360,
6438,
659,
1169,
661,
765,
7,
420,
2360,
6438,
659,
1169,
661,
45,
4468,
7,
420,
2360,
6438,
659,
1169,
661,
970,
63,
4468,
7,
257,
2360,
6438,
5440,
1386,
272,
283,
45,
19,
7,
259,
520,
221,
791,
9749,
356,
283,
2124,
7,
755,
2360,
283,
69,
5650,
356,
283,
23591,
297,
355,
283,
1628,
356,
283,
600,
757,
297,
355,
283,
3306,
63,
1657,
356,
756,
12,
355,
283,
6627,
356,
4274,
2709,
8619,
7,
258,
2360,
650,
395,
1169,
661,
23524,
7,
755,
2360,
1275,
23,
395,
1169,
661,
78,
3385,
39,
7,
755,
2360,
650,
395,
1169,
661,
4468,
7,
755,
2360,
6438,
659,
1169,
661,
765,
7,
420,
2360,
6438,
659,
1169,
661,
45,
4468,
7,
420,
2360,
6438,
659,
1169,
661,
970,
63,
4468,
7,
257,
2360,
6438,
5440,
1386,
272,
283,
45,
20,
7,
259,
520,
221,
791,
9749,
356,
283,
2124,
7,
755,
2360,
283,
69,
5650,
356,
283,
70,
17085,
297,
355,
283,
1628,
356,
283,
600,
757,
297,
355,
283,
3306,
63,
1657,
356,
756,
12,
355,
283,
6627,
356,
4274,
2709,
8619,
7,
258,
2360,
841,
395,
1169,
661,
23524,
7,
755,
2360,
1275,
23,
395,
1169,
661,
4468,
7,
755,
2360,
6438,
659,
1169,
661,
765,
7,
420,
2360,
6438,
659,
1169,
661,
45,
4468,
7,
420,
2360,
6438,
659,
1169,
661,
970,
63,
4468,
7,
257,
2360,
6438,
5440,
1386,
272,
283,
45,
21,
7,
259,
520,
221,
791,
9749,
356,
283,
2124,
7,
755,
2360,
283,
69,
5650,
356,
283,
7325,
297,
355,
283,
1628,
356,
283,
600,
757,
297,
355,
283,
3306,
63,
1657,
356,
756,
12,
355,
283,
6627,
356,
4274,
2709,
8619,
7,
258,
2360,
959,
395,
1169,
661,
23524,
7,
755,
2360,
1275,
23,
395,
1169,
661,
4468,
7,
755,
2360,
6438,
659,
1169,
661,
765,
7,
420,
2360,
6438,
659,
1169,
661,
45,
4468,
7,
420,
2360,
6438,
659,
1169,
661,
970,
63,
4468,
7,
257,
2360,
6438,
5440,
1386,
272,
283,
45,
22,
7,
259,
520,
221,
791,
9749,
356,
283,
2124,
7,
755,
2360,
283,
69,
5650,
356,
283,
18,
10169,
297,
355,
283,
1628,
356,
283,
600,
757,
297,
355,
283,
3306,
63,
1657,
356,
756,
12,
355,
283,
6627,
356,
4274,
2709,
8619,
7,
258,
2360,
959,
395,
1169,
661,
23524,
7,
755,
2360,
1275,
23,
395,
1169,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
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
viralpandey/kivy
|
kivy/core/clipboard/clipboard_nspaste.py
|
59
|
1218
|
'''
Clipboard OsX: implementation of clipboard using Appkit
'''
__all__ = ('ClipboardNSPaste', )
from kivy.core.clipboard import ClipboardBase
from kivy.utils import platform
if platform != 'macosx':
raise SystemError('Unsupported platform for appkit clipboard.')
try:
from pyobjus import autoclass
from pyobjus.dylib_manager import load_framework, INCLUDE
load_framework(INCLUDE.AppKit)
except ImportError:
raise SystemError('Pyobjus not installed. Please run the following'
' command to install it. `pip install --user pyobjus`')
NSPasteboard = autoclass('NSPasteboard')
NSString = autoclass('NSString')
class ClipboardNSPaste(ClipboardBase):
def __init__(self):
super(ClipboardNSPaste, self).__init__()
self._clipboard = NSPasteboard.generalPasteboard()
def get(self, mimetype='text/plain'):
pb = self._clipboard
data = pb.stringForType_('public.utf8-plain-text')
if not data:
return ""
return data.UTF8String()
def put(self, data, mimetype='text/plain'):
pb = self._clipboard
pb.clearContents()
pb.writeObjects_([data])
def get_types(self):
return list('text/plain',)
|
mit
|
[
2344,
199,
28459,
593,
83,
56,
26,
4514,
402,
11353,
3576,
1808,
4693,
6065,
199,
2344,
199,
199,
363,
452,
363,
275,
661,
28459,
2709,
48,
9209,
297,
776,
199,
199,
504,
17227,
14,
1018,
14,
7548,
3576,
492,
445,
3587,
3576,
1563,
199,
504,
17227,
14,
1208,
492,
4298,
199,
199,
692,
4298,
1137,
283,
28546,
356,
272,
746,
6187,
547,
360,
12647,
4298,
367,
1145,
6065,
11353,
3576,
2659,
199,
893,
26,
272,
687,
1134,
1113,
527,
492,
2599,
533,
272,
687,
1134,
1113,
527,
14,
22305,
63,
2609,
492,
2248,
63,
4857,
12,
1621,
13958,
272,
2248,
63,
4857,
8,
18171,
14,
2640,
14591,
9,
199,
2590,
3545,
26,
272,
746,
6187,
547,
360,
2713,
1113,
527,
440,
4903,
14,
7754,
1255,
314,
2569,
7,
267,
283,
1414,
370,
3907,
652,
14,
658,
9983,
3907,
1553,
751,
1134,
1113,
527,
64,
358,
199,
199,
2709,
48,
9209,
3576,
275,
2599,
533,
360,
2709,
48,
9209,
3576,
358,
199,
2709,
1558,
275,
2599,
533,
360,
2709,
1558,
358,
421,
199,
533,
445,
3587,
3576,
2709,
48,
9209,
8,
28459,
1563,
304,
339,
347,
636,
826,
721,
277,
304,
267,
1613,
8,
28459,
2709,
48,
9209,
12,
291,
2843,
826,
4533,
267,
291,
423,
7548,
3576,
275,
653,
5763,
9209,
3576,
14,
10706,
48,
9209,
3576,
342,
339,
347,
664,
8,
277,
12,
12200,
534,
505,
15,
6104,
735,
267,
10446,
275,
291,
423,
7548,
3576,
267,
666,
275,
10446,
14,
875,
1858,
804,
11252,
3455,
14,
1624,
24,
13,
6104,
13,
505,
358,
267,
340,
440,
666,
26,
288,
372,
3087,
267,
372,
666,
14,
6610,
24,
1558,
342,
339,
347,
5324,
8,
277,
12,
666,
12,
12200,
534,
505,
15,
6104,
735,
267,
10446,
275,
291,
423,
7548,
3576,
267,
10446,
14,
3584,
11383,
342,
267,
10446,
14,
952,
11188,
63,
779,
576,
566,
339,
347,
664,
63,
1313,
8,
277,
304,
267,
372,
769,
360,
505,
15,
6104,
9538,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
199,
28459,
593,
83,
56,
26,
4514,
402,
11353,
3576,
1808,
4693,
6065,
199,
2344,
199,
199,
363,
452,
363,
275,
661,
28459,
2709,
48,
9209,
297,
776,
199,
199,
504,
17227,
14,
1018,
14,
7548,
3576,
492,
445,
3587,
3576,
1563,
199,
504,
17227,
14,
1208,
492,
4298,
199,
199,
692,
4298,
1137,
283,
28546,
356,
272,
746,
6187,
547,
360,
12647,
4298,
367,
1145,
6065,
11353,
3576,
2659,
199,
893,
26,
272,
687,
1134,
1113,
527,
492,
2599,
533,
272,
687,
1134,
1113,
527,
14,
22305,
63,
2609,
492,
2248,
63,
4857,
12,
1621,
13958,
272,
2248,
63,
4857,
8,
18171,
14,
2640,
14591,
9,
199,
2590,
3545,
26,
272,
746,
6187,
547,
360,
2713,
1113,
527,
440,
4903,
14,
7754,
1255,
314,
2569,
7,
267,
283,
1414,
370,
3907,
652,
14,
658,
9983,
3907,
1553,
751,
1134,
1113,
527,
64,
358,
199,
199,
2709,
48,
9209,
3576,
275,
2599,
533,
360,
2709,
48,
9209,
3576,
358,
199,
2709,
1558,
275,
2599,
533,
360,
2709,
1558,
358,
421,
199,
533,
445,
3587,
3576,
2709,
48,
9209,
8,
28459,
1563,
304,
339,
347,
636,
826,
721,
277,
304,
267,
1613,
8,
28459,
2709,
48,
9209,
12,
291,
2843,
826,
4533,
267,
291,
423,
7548,
3576,
275,
653,
5763,
9209,
3576,
14,
10706,
48,
9209,
3576,
342,
339,
347,
664,
8,
277,
12,
12200,
534,
505,
15,
6104,
735,
267,
10446,
275,
291,
423,
7548,
3576,
267,
666,
275,
10446,
14,
875,
1858,
804,
11252,
3455,
14,
1624,
24,
13,
6104,
13,
505,
358,
267,
340,
440,
666,
26,
288,
372,
3087,
267,
372,
666,
14,
6610,
24,
1558,
342,
339,
347,
5324,
8,
277,
12,
666,
12,
12200,
534,
505,
15,
6104,
735,
267,
10446,
275,
291,
423,
7548,
3576,
267,
10446,
14,
3584,
11383,
342,
267,
10446,
14,
952,
11188,
63,
779,
576,
566,
339,
347,
664,
63,
1313,
8,
277,
304,
267,
372,
769,
360,
505,
15,
6104,
9538,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
Chemcy/vnpy
|
vn.tutorial/tick2trade/vn.trader_t2t/riskManager/uiRmWidget.py
|
17
|
5075
|
# encoding: UTF-8
'''
风控模块相关的GUI控制组件
'''
from uiBasicWidget import QtGui, QtCore
from eventEngine import *
########################################################################
class RmSpinBox(QtGui.QSpinBox):
"""调整参数用的数值框"""
#----------------------------------------------------------------------
def __init__(self, value):
"""Constructor"""
super(RmSpinBox, self).__init__()
self.setMinimum(0)
self.setMaximum(1000000)
self.setValue(value)
########################################################################
class RmLine(QtGui.QFrame):
"""水平分割线"""
#----------------------------------------------------------------------
def __init__(self):
"""Constructor"""
super(RmLine, self).__init__()
self.setFrameShape(self.HLine)
self.setFrameShadow(self.Sunken)
########################################################################
class RmEngineManager(QtGui.QWidget):
"""风控引擎的管理组件"""
#----------------------------------------------------------------------
def __init__(self, rmEngine, eventEngine, parent=None):
"""Constructor"""
super(RmEngineManager, self).__init__(parent)
self.rmEngine = rmEngine
self.eventEngine = eventEngine
self.initUi()
self.updateEngineStatus()
#----------------------------------------------------------------------
def initUi(self):
"""初始化界面"""
self.setWindowTitle(u'风险管理')
# 设置界面
self.buttonSwitchEngineStatus = QtGui.QPushButton(u'风控模块未启动')
self.spinOrderFlowLimit = RmSpinBox(self.rmEngine.orderFlowLimit)
self.spinOrderFlowClear = RmSpinBox(self.rmEngine.orderFlowClear)
self.spinOrderSizeLimit = RmSpinBox(self.rmEngine.orderSizeLimit)
self.spinTradeLimit = RmSpinBox(self.rmEngine.tradeLimit)
self.spinWorkingOrderLimit = RmSpinBox(self.rmEngine.workingOrderLimit)
buttonClearOrderFlowCount = QtGui.QPushButton(u'清空流控计数')
buttonClearTradeCount = QtGui.QPushButton(u'清空总成交计数')
buttonSaveSetting = QtGui.QPushButton(u'保存设置')
Label = QtGui.QLabel
grid = QtGui.QGridLayout()
grid.addWidget(Label(u'工作状态'), 0, 0)
grid.addWidget(self.buttonSwitchEngineStatus, 0, 1)
grid.addWidget(RmLine(), 1, 0, 1, 2)
grid.addWidget(Label(u'流控上限'), 2, 0)
grid.addWidget(self.spinOrderFlowLimit, 2, 1)
grid.addWidget(Label(u'流控清空(秒)'), 3, 0)
grid.addWidget(self.spinOrderFlowClear, 3, 1)
grid.addWidget(RmLine(), 4, 0, 1, 2)
grid.addWidget(Label(u'单笔委托上限'), 5, 0)
grid.addWidget(self.spinOrderSizeLimit, 5, 1)
grid.addWidget(RmLine(), 6, 0, 1, 2)
grid.addWidget(Label(u'总成交上限'), 7, 0)
grid.addWidget(self.spinTradeLimit, 7, 1)
grid.addWidget(RmLine(), 8, 0, 1, 2)
grid.addWidget(Label(u'活动订单上限'), 9, 0)
grid.addWidget(self.spinWorkingOrderLimit, 9, 1)
hbox = QtGui.QHBoxLayout()
hbox.addWidget(buttonClearOrderFlowCount)
hbox.addWidget(buttonClearTradeCount)
hbox.addStretch()
hbox.addWidget(buttonSaveSetting)
vbox = QtGui.QVBoxLayout()
vbox.addLayout(grid)
vbox.addLayout(hbox)
self.setLayout(vbox)
# 连接组件信号
self.spinOrderFlowLimit.valueChanged.connect(self.rmEngine.setOrderFlowLimit)
self.spinOrderFlowClear.valueChanged.connect(self.rmEngine.setOrderFlowClear)
self.spinOrderSizeLimit.valueChanged.connect(self.rmEngine.setOrderSizeLimit)
self.spinTradeLimit.valueChanged.connect(self.rmEngine.setTradeLimit)
self.spinWorkingOrderLimit.valueChanged.connect(self.rmEngine.setWorkingOrderLimit)
self.buttonSwitchEngineStatus.clicked.connect(self.switchEngineSatus)
buttonClearOrderFlowCount.clicked.connect(self.rmEngine.clearOrderFlowCount)
buttonClearTradeCount.clicked.connect(self.rmEngine.clearTradeCount)
buttonSaveSetting.clicked.connect(self.rmEngine.saveSetting)
# 设为固定大小
self.setFixedSize(self.sizeHint())
#----------------------------------------------------------------------
def switchEngineSatus(self):
"""控制风控引擎开关"""
self.rmEngine.switchEngineStatus()
self.updateEngineStatus()
#----------------------------------------------------------------------
def updateEngineStatus(self):
"""更新引擎状态"""
if self.rmEngine.active:
self.buttonSwitchEngineStatus.setText(u'风控模块运行中')
else:
self.buttonSwitchEngineStatus.setText(u'风控模块未启动')
|
mit
|
[
3,
2644,
26,
9094,
13,
24,
199,
199,
2344,
199,
166,
97,
237,
17797,
101,
29887,
30899,
246,
15545,
117,
8379,
112,
8106,
14438,
17797,
101,
9051,
115,
32061,
15054,
199,
2344,
421,
199,
504,
8574,
6845,
3339,
492,
5928,
12,
10565,
199,
504,
1566,
8524,
492,
627,
421,
199,
3949,
199,
533,
820,
77,
27806,
8,
10604,
14,
49,
27806,
304,
272,
408,
165,
109,
226,
9221,
113,
32549,
12211,
11428,
8106,
12211,
32678,
31333,
229,
624,
339,
22526,
272,
347,
636,
826,
721,
277,
12,
574,
304,
267,
408,
11447,
624,
267,
1613,
8,
31330,
27806,
12,
291,
2843,
826,
4533,
398,
291,
14,
32608,
8,
16,
9,
267,
291,
14,
409,
10915,
8,
22589,
9,
2728,
291,
14,
14733,
8,
585,
9,
26339,
421,
199,
3949,
199,
533,
820,
77,
3049,
8,
10604,
14,
49,
3160,
304,
272,
408,
32226,
25274,
21514,
19642,
111,
13389,
124,
624,
339,
22526,
272,
347,
636,
826,
721,
277,
304,
267,
408,
11447,
624,
267,
1613,
8,
31330,
3049,
12,
291,
2843,
826,
4533,
267,
291,
14,
409,
3160,
7238,
8,
277,
14,
40,
3049,
9,
267,
291,
14,
409,
3160,
23574,
8,
277,
14,
22546,
917,
9,
26339,
2043,
199,
199,
3949,
199,
533,
820,
77,
8524,
2988,
8,
10604,
14,
23894,
304,
272,
408,
166,
97,
237,
17797,
101,
12586,
244,
24070,
237,
8106,
16716,
95,
24946,
32061,
15054,
624,
339,
22526,
272,
347,
636,
826,
721,
277,
12,
14267,
8524,
12,
1566,
8524,
12,
1676,
29,
403,
304,
267,
408,
11447,
624,
267,
1613,
8,
31330,
8524,
2988,
12,
291,
2843,
826,
721,
1708,
9,
2728,
291,
14,
5682,
8524,
275,
14267,
8524,
267,
291,
14,
1430,
8524,
275,
1566,
8524,
2728,
291,
14,
826,
18203,
342,
267,
291,
14,
873,
8524,
3694,
342,
339,
22526,
272,
347,
4205,
18203,
8,
277,
304,
267,
408,
9051,
252,
25712,
234,
21018,
245,
26546,
235,
26398,
96,
624,
267,
291,
14,
30601,
8,
85,
7,
166,
97,
237,
17087,
103,
16716,
95,
24946,
358,
2728,
327,
9065,
107,
123,
27029,
26546,
235,
26398,
96,
267,
291,
14,
3887,
10167,
8524,
3694,
275,
5928,
14,
29116,
8,
85,
7,
166,
97,
237,
17797,
101,
29887,
30899,
246,
6587,
104,
8197,
108,
31001,
358,
2728,
291,
14,
14809,
4738,
5060,
8407,
275,
820,
77,
27806,
8,
277,
14,
5682,
8524,
14,
1648,
5060,
8407,
9,
267,
291,
14,
14809,
4738,
5060,
9721,
275,
820,
77,
27806,
8,
277,
14,
5682,
8524,
14,
1648,
5060,
9721,
9,
267,
291,
14,
14809,
4738,
2320,
8407,
275,
820,
77,
27806,
8,
277,
14,
5682,
8524,
14,
1648,
2320,
8407,
9,
267,
291,
14,
14809,
17529,
8407,
275,
820,
77,
27806,
8,
277,
14,
5682,
8524,
14,
21697,
8407,
9,
267,
291,
14,
14809,
18356,
4738,
8407,
275,
820,
77,
27806,
8,
277,
14,
5682,
8524,
14,
9818,
4738,
8407,
9,
2728,
5528,
9721,
4738,
5060,
2353,
275,
5928,
14,
29116,
8,
85,
7,
163,
117,
228,
30413,
119,
31870,
17797,
101,
14082,
95,
12211,
358,
267,
5528,
9721,
17529,
2353,
275,
5928,
14,
29116,
8,
85,
7,
163,
117,
228,
30413,
119,
17182,
120,
16888,
11112,
14082,
95,
12211,
358,
267,
5528,
8229,
7776,
275,
5928,
14,
29116,
8,
85,
7,
22244,
29846,
14082,
123,
27029,
358,
2728,
10354,
275,
5928,
14,
19890,
267,
6068,
275,
5928,
14,
49,
7900,
4798,
342,
267,
6068,
14,
9475,
8,
4314,
8,
85,
7,
18189,
99,
21927,
30729,
659,
378,
12,
378,
9,
267,
6068,
14,
9475,
8,
277,
14,
3887,
10167,
8524,
3694,
12,
378,
12,
413,
9,
267,
6068,
14,
9475,
8,
31330,
3049,
1062,
413,
12,
378,
12,
413,
12,
499,
9,
267,
6068,
14,
9475,
8,
4314,
8,
85,
7,
31870,
17797,
101,
22661,
17087,
239,
659,
499,
12,
378,
9,
267,
6068,
14,
9475,
8,
277,
14,
14809,
4738,
5060,
8407,
12,
499,
12,
413,
9,
267,
6068,
14,
9475,
8,
4314,
8,
85,
7,
31870,
17797,
101,
163,
117,
228,
30413,
119,
8454,
231,
19012,
241,
8454,
232,
659,
650,
12,
378,
9,
267,
6068,
14,
9475,
8,
277,
14,
14809,
4738,
5060,
9721,
12,
650,
12,
413,
9,
267,
6068,
14,
9475,
8,
31330,
3049,
1062,
841,
12,
378,
12,
413,
12,
499,
9,
267,
6068,
14,
9475,
8,
4314,
8,
85,
7,
15582,
25238,
243,
25712,
243,
10862,
247,
22661,
17087,
239,
659,
959,
12,
378,
9,
267,
6068,
14,
9475,
8,
277,
14,
14809,
4738,
2320,
8407,
12,
959,
12,
413,
9,
267,
6068,
14,
9475,
8,
31330,
3049,
1062,
1227,
12,
378,
12,
413,
12,
499,
9,
267,
6068,
14,
9475,
8,
4314,
8,
85,
7,
17182,
120,
16888,
11112,
22661,
17087,
239,
659,
1520,
12,
378,
9,
267,
6068,
14,
9475,
8,
277,
14,
14809,
17529,
8407,
12,
1520,
12,
413,
9,
267,
6068,
14,
9475,
8,
31330,
3049,
1062,
1695,
12,
378,
12,
413,
12,
499,
9,
267,
6068,
14,
9475,
8,
4314,
8,
85,
7,
163,
113,
8698,
233,
102,
14082,
96,
15582,
22661,
17087,
239,
659,
1749,
12,
378,
9,
267,
6068,
14,
9475,
8,
277,
14,
14809,
18356,
4738,
8407,
12,
1749,
12,
413,
9,
2728,
24126,
275,
5928,
14,
27088,
18536,
342,
267,
24126,
14,
9475,
8,
3887,
9721,
4738,
5060,
2353,
9,
267,
24126,
14,
9475,
8,
3887,
9721,
17529,
2353,
9,
267,
24126,
14,
525,
21537,
342,
267,
24126,
14,
9475,
8,
3887,
8229,
7776,
9,
2728,
20163,
275,
5928,
14,
25527,
18536,
342,
267,
20163,
14,
30571,
8,
3825,
9,
267,
20163,
14,
30571,
8,
21453,
9,
267,
291,
14,
409,
4798,
8,
19508,
9,
2728,
327,
9065,
124,
253,
24586,
32061,
15054,
23305,
12937,
267,
291,
14,
14809,
4738,
5060,
8407,
14,
585,
6970,
14,
2242,
8,
277,
14,
5682,
8524,
14,
409,
4738,
5060,
8407,
9,
267,
291,
14,
14809,
4738,
5060,
9721,
14,
585,
6970,
14,
2242,
8,
277,
14,
5682,
8524,
14,
409,
4738,
5060,
9721,
9,
267,
291,
14,
14809,
4738,
2320,
8407,
14,
585,
6970,
14,
2242,
8,
277,
14,
5682,
8524,
14,
409,
4738,
2320,
8407,
9,
267,
291,
14,
14809,
17529,
8407,
14,
585,
6970,
14,
2242,
8,
277,
14,
5682,
8524,
14,
409,
17529
] |
[
2644,
26,
9094,
13,
24,
199,
199,
2344,
199,
166,
97,
237,
17797,
101,
29887,
30899,
246,
15545,
117,
8379,
112,
8106,
14438,
17797,
101,
9051,
115,
32061,
15054,
199,
2344,
421,
199,
504,
8574,
6845,
3339,
492,
5928,
12,
10565,
199,
504,
1566,
8524,
492,
627,
421,
199,
3949,
199,
533,
820,
77,
27806,
8,
10604,
14,
49,
27806,
304,
272,
408,
165,
109,
226,
9221,
113,
32549,
12211,
11428,
8106,
12211,
32678,
31333,
229,
624,
339,
22526,
272,
347,
636,
826,
721,
277,
12,
574,
304,
267,
408,
11447,
624,
267,
1613,
8,
31330,
27806,
12,
291,
2843,
826,
4533,
398,
291,
14,
32608,
8,
16,
9,
267,
291,
14,
409,
10915,
8,
22589,
9,
2728,
291,
14,
14733,
8,
585,
9,
26339,
421,
199,
3949,
199,
533,
820,
77,
3049,
8,
10604,
14,
49,
3160,
304,
272,
408,
32226,
25274,
21514,
19642,
111,
13389,
124,
624,
339,
22526,
272,
347,
636,
826,
721,
277,
304,
267,
408,
11447,
624,
267,
1613,
8,
31330,
3049,
12,
291,
2843,
826,
4533,
267,
291,
14,
409,
3160,
7238,
8,
277,
14,
40,
3049,
9,
267,
291,
14,
409,
3160,
23574,
8,
277,
14,
22546,
917,
9,
26339,
2043,
199,
199,
3949,
199,
533,
820,
77,
8524,
2988,
8,
10604,
14,
23894,
304,
272,
408,
166,
97,
237,
17797,
101,
12586,
244,
24070,
237,
8106,
16716,
95,
24946,
32061,
15054,
624,
339,
22526,
272,
347,
636,
826,
721,
277,
12,
14267,
8524,
12,
1566,
8524,
12,
1676,
29,
403,
304,
267,
408,
11447,
624,
267,
1613,
8,
31330,
8524,
2988,
12,
291,
2843,
826,
721,
1708,
9,
2728,
291,
14,
5682,
8524,
275,
14267,
8524,
267,
291,
14,
1430,
8524,
275,
1566,
8524,
2728,
291,
14,
826,
18203,
342,
267,
291,
14,
873,
8524,
3694,
342,
339,
22526,
272,
347,
4205,
18203,
8,
277,
304,
267,
408,
9051,
252,
25712,
234,
21018,
245,
26546,
235,
26398,
96,
624,
267,
291,
14,
30601,
8,
85,
7,
166,
97,
237,
17087,
103,
16716,
95,
24946,
358,
2728,
327,
9065,
107,
123,
27029,
26546,
235,
26398,
96,
267,
291,
14,
3887,
10167,
8524,
3694,
275,
5928,
14,
29116,
8,
85,
7,
166,
97,
237,
17797,
101,
29887,
30899,
246,
6587,
104,
8197,
108,
31001,
358,
2728,
291,
14,
14809,
4738,
5060,
8407,
275,
820,
77,
27806,
8,
277,
14,
5682,
8524,
14,
1648,
5060,
8407,
9,
267,
291,
14,
14809,
4738,
5060,
9721,
275,
820,
77,
27806,
8,
277,
14,
5682,
8524,
14,
1648,
5060,
9721,
9,
267,
291,
14,
14809,
4738,
2320,
8407,
275,
820,
77,
27806,
8,
277,
14,
5682,
8524,
14,
1648,
2320,
8407,
9,
267,
291,
14,
14809,
17529,
8407,
275,
820,
77,
27806,
8,
277,
14,
5682,
8524,
14,
21697,
8407,
9,
267,
291,
14,
14809,
18356,
4738,
8407,
275,
820,
77,
27806,
8,
277,
14,
5682,
8524,
14,
9818,
4738,
8407,
9,
2728,
5528,
9721,
4738,
5060,
2353,
275,
5928,
14,
29116,
8,
85,
7,
163,
117,
228,
30413,
119,
31870,
17797,
101,
14082,
95,
12211,
358,
267,
5528,
9721,
17529,
2353,
275,
5928,
14,
29116,
8,
85,
7,
163,
117,
228,
30413,
119,
17182,
120,
16888,
11112,
14082,
95,
12211,
358,
267,
5528,
8229,
7776,
275,
5928,
14,
29116,
8,
85,
7,
22244,
29846,
14082,
123,
27029,
358,
2728,
10354,
275,
5928,
14,
19890,
267,
6068,
275,
5928,
14,
49,
7900,
4798,
342,
267,
6068,
14,
9475,
8,
4314,
8,
85,
7,
18189,
99,
21927,
30729,
659,
378,
12,
378,
9,
267,
6068,
14,
9475,
8,
277,
14,
3887,
10167,
8524,
3694,
12,
378,
12,
413,
9,
267,
6068,
14,
9475,
8,
31330,
3049,
1062,
413,
12,
378,
12,
413,
12,
499,
9,
267,
6068,
14,
9475,
8,
4314,
8,
85,
7,
31870,
17797,
101,
22661,
17087,
239,
659,
499,
12,
378,
9,
267,
6068,
14,
9475,
8,
277,
14,
14809,
4738,
5060,
8407,
12,
499,
12,
413,
9,
267,
6068,
14,
9475,
8,
4314,
8,
85,
7,
31870,
17797,
101,
163,
117,
228,
30413,
119,
8454,
231,
19012,
241,
8454,
232,
659,
650,
12,
378,
9,
267,
6068,
14,
9475,
8,
277,
14,
14809,
4738,
5060,
9721,
12,
650,
12,
413,
9,
267,
6068,
14,
9475,
8,
31330,
3049,
1062,
841,
12,
378,
12,
413,
12,
499,
9,
267,
6068,
14,
9475,
8,
4314,
8,
85,
7,
15582,
25238,
243,
25712,
243,
10862,
247,
22661,
17087,
239,
659,
959,
12,
378,
9,
267,
6068,
14,
9475,
8,
277,
14,
14809,
4738,
2320,
8407,
12,
959,
12,
413,
9,
267,
6068,
14,
9475,
8,
31330,
3049,
1062,
1227,
12,
378,
12,
413,
12,
499,
9,
267,
6068,
14,
9475,
8,
4314,
8,
85,
7,
17182,
120,
16888,
11112,
22661,
17087,
239,
659,
1520,
12,
378,
9,
267,
6068,
14,
9475,
8,
277,
14,
14809,
17529,
8407,
12,
1520,
12,
413,
9,
267,
6068,
14,
9475,
8,
31330,
3049,
1062,
1695,
12,
378,
12,
413,
12,
499,
9,
267,
6068,
14,
9475,
8,
4314,
8,
85,
7,
163,
113,
8698,
233,
102,
14082,
96,
15582,
22661,
17087,
239,
659,
1749,
12,
378,
9,
267,
6068,
14,
9475,
8,
277,
14,
14809,
18356,
4738,
8407,
12,
1749,
12,
413,
9,
2728,
24126,
275,
5928,
14,
27088,
18536,
342,
267,
24126,
14,
9475,
8,
3887,
9721,
4738,
5060,
2353,
9,
267,
24126,
14,
9475,
8,
3887,
9721,
17529,
2353,
9,
267,
24126,
14,
525,
21537,
342,
267,
24126,
14,
9475,
8,
3887,
8229,
7776,
9,
2728,
20163,
275,
5928,
14,
25527,
18536,
342,
267,
20163,
14,
30571,
8,
3825,
9,
267,
20163,
14,
30571,
8,
21453,
9,
267,
291,
14,
409,
4798,
8,
19508,
9,
2728,
327,
9065,
124,
253,
24586,
32061,
15054,
23305,
12937,
267,
291,
14,
14809,
4738,
5060,
8407,
14,
585,
6970,
14,
2242,
8,
277,
14,
5682,
8524,
14,
409,
4738,
5060,
8407,
9,
267,
291,
14,
14809,
4738,
5060,
9721,
14,
585,
6970,
14,
2242,
8,
277,
14,
5682,
8524,
14,
409,
4738,
5060,
9721,
9,
267,
291,
14,
14809,
4738,
2320,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1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
kenshay/ImageScripter
|
ProgramData/SystemFiles/Python/Lib/site-packages/OpenGL/GL/APPLE/transform_hint.py
|
9
|
1674
|
'''OpenGL extension APPLE.transform_hint
This module customises the behaviour of the
OpenGL.raw.GL.APPLE.transform_hint to provide a more
Python-friendly API
Overview (from the spec)
The transform_hint extension provides a new target,
TRANSFORM_HINT_APPLE, for the Hint procedure. When the
transform hint is set to FASTEST the GL may choose to
implement certain state dependent algebraic simplifications
in the geometry transformation that affect the sub-pixel
precision of the transformed vertex coordinates.
For example, if two polygons are rendered with identical object
coordinates, different GL state settings, and the transform
hint set to FASTEST, there is no gaurantee that the resulting
window coordinates of the two polygons will be precisely
identical. Therefore, precise tests of the window coordinates,
such as a depth test setting of EQUAL, should not be used.
If the transform hint is set to NICEST or DONT_CARE, two polygons
with identical object coordinates will always be transformed
to identical window coordinates.
The official definition of this extension is available here:
http://www.opengl.org/registry/specs/APPLE/transform_hint.txt
'''
from OpenGL import platform, constant, arrays
from OpenGL import extensions, wrapper
import ctypes
from OpenGL.raw.GL import _types, _glgets
from OpenGL.raw.GL.APPLE.transform_hint import *
from OpenGL.raw.GL.APPLE.transform_hint import _EXTENSION_NAME
def glInitTransformHintAPPLE():
'''Return boolean indicating whether this extension is available'''
from OpenGL import extensions
return extensions.hasGLExtension( _EXTENSION_NAME )
### END AUTOGENERATED SECTION
|
gpl-3.0
|
[
2344,
4299,
2226,
3329,
19525,
906,
14,
4711,
63,
6479,
199,
199,
2765,
859,
3537,
1388,
314,
13942,
402,
314,
221,
199,
4299,
2226,
14,
1773,
14,
2226,
14,
31683,
14,
4711,
63,
6479,
370,
5647,
282,
1655,
221,
199,
4718,
13,
17317,
3261,
199,
199,
28077,
334,
504,
314,
3158,
9,
8299,
198,
1918,
5793,
63,
6479,
3329,
6571,
282,
892,
1347,
12,
199,
198,
30190,
63,
32456,
63,
31683,
12,
367,
314,
869,
442,
17782,
14,
221,
3979,
314,
199,
198,
4711,
8328,
365,
663,
370,
481,
11307,
1719,
314,
3563,
1443,
11496,
370,
9948,
198,
21463,
9842,
1174,
11410,
741,
27060,
17553,
3477,
83,
199,
198,
262,
314,
3400,
13315,
626,
12787,
314,
1007,
13,
8435,
199,
198,
6833,
402,
314,
14834,
12759,
8983,
14,
257,
8299,
198,
1858,
2893,
12,
340,
2877,
30658,
787,
8018,
543,
13130,
909,
199,
198,
12924,
12,
3365,
3563,
1174,
2202,
12,
436,
314,
5793,
199,
198,
6479,
663,
370,
481,
11307,
1719,
12,
2337,
365,
949,
16072,
300,
8949,
69,
626,
314,
9183,
9948,
198,
3806,
8983,
402,
314,
2877,
30658,
911,
506,
28334,
590,
199,
198,
14576,
14,
221,
21039,
12,
28334,
2295,
402,
314,
4353,
8983,
12,
9948,
198,
10180,
465,
282,
5818,
511,
4260,
402,
17152,
12,
1077,
440,
506,
1202,
14,
8299,
198,
3917,
314,
5793,
8328,
365,
663,
370,
31265,
1719,
503,
577,
5994,
63,
35,
8693,
12,
2877,
30658,
199,
198,
1045,
13130,
909,
8983,
911,
3544,
506,
14834,
199,
198,
475,
13130,
4353,
8983,
14,
199,
199,
1918,
25410,
5492,
402,
642,
3329,
365,
2808,
2348,
26,
199,
1014,
921,
1544,
14,
32477,
14,
1308,
15,
5189,
15,
7273,
15,
31683,
15,
4711,
63,
6479,
14,
2424,
199,
2344,
199,
504,
24374,
492,
4298,
12,
4413,
12,
6572,
199,
504,
24374,
492,
5478,
12,
4975,
199,
646,
5577,
199,
504,
24374,
14,
1773,
14,
2226,
492,
485,
1313,
12,
485,
3528,
24894,
199,
504,
24374,
14,
1773,
14,
2226,
14,
31683,
14,
4711,
63,
6479,
492,
627,
199,
504,
24374,
14,
1773,
14,
2226,
14,
31683,
14,
4711,
63,
6479,
492,
485,
15498,
63,
2339,
199,
199,
318,
6482,
9346,
6939,
20891,
31683,
837,
272,
1449,
1767,
5046,
9297,
3775,
642,
3329,
365,
2808,
2344,
272,
687,
24374,
492,
5478,
272,
372,
5478,
14,
1989,
12827,
88,
724,
438,
8,
485,
15498,
63,
2339,
776,
421,
199,
5680,
7729,
25420,
12795,
6989,
29074,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
4299,
2226,
3329,
19525,
906,
14,
4711,
63,
6479,
199,
199,
2765,
859,
3537,
1388,
314,
13942,
402,
314,
221,
199,
4299,
2226,
14,
1773,
14,
2226,
14,
31683,
14,
4711,
63,
6479,
370,
5647,
282,
1655,
221,
199,
4718,
13,
17317,
3261,
199,
199,
28077,
334,
504,
314,
3158,
9,
8299,
198,
1918,
5793,
63,
6479,
3329,
6571,
282,
892,
1347,
12,
199,
198,
30190,
63,
32456,
63,
31683,
12,
367,
314,
869,
442,
17782,
14,
221,
3979,
314,
199,
198,
4711,
8328,
365,
663,
370,
481,
11307,
1719,
314,
3563,
1443,
11496,
370,
9948,
198,
21463,
9842,
1174,
11410,
741,
27060,
17553,
3477,
83,
199,
198,
262,
314,
3400,
13315,
626,
12787,
314,
1007,
13,
8435,
199,
198,
6833,
402,
314,
14834,
12759,
8983,
14,
257,
8299,
198,
1858,
2893,
12,
340,
2877,
30658,
787,
8018,
543,
13130,
909,
199,
198,
12924,
12,
3365,
3563,
1174,
2202,
12,
436,
314,
5793,
199,
198,
6479,
663,
370,
481,
11307,
1719,
12,
2337,
365,
949,
16072,
300,
8949,
69,
626,
314,
9183,
9948,
198,
3806,
8983,
402,
314,
2877,
30658,
911,
506,
28334,
590,
199,
198,
14576,
14,
221,
21039,
12,
28334,
2295,
402,
314,
4353,
8983,
12,
9948,
198,
10180,
465,
282,
5818,
511,
4260,
402,
17152,
12,
1077,
440,
506,
1202,
14,
8299,
198,
3917,
314,
5793,
8328,
365,
663,
370,
31265,
1719,
503,
577,
5994,
63,
35,
8693,
12,
2877,
30658,
199,
198,
1045,
13130,
909,
8983,
911,
3544,
506,
14834,
199,
198,
475,
13130,
4353,
8983,
14,
199,
199,
1918,
25410,
5492,
402,
642,
3329,
365,
2808,
2348,
26,
199,
1014,
921,
1544,
14,
32477,
14,
1308,
15,
5189,
15,
7273,
15,
31683,
15,
4711,
63,
6479,
14,
2424,
199,
2344,
199,
504,
24374,
492,
4298,
12,
4413,
12,
6572,
199,
504,
24374,
492,
5478,
12,
4975,
199,
646,
5577,
199,
504,
24374,
14,
1773,
14,
2226,
492,
485,
1313,
12,
485,
3528,
24894,
199,
504,
24374,
14,
1773,
14,
2226,
14,
31683,
14,
4711,
63,
6479,
492,
627,
199,
504,
24374,
14,
1773,
14,
2226,
14,
31683,
14,
4711,
63,
6479,
492,
485,
15498,
63,
2339,
199,
199,
318,
6482,
9346,
6939,
20891,
31683,
837,
272,
1449,
1767,
5046,
9297,
3775,
642,
3329,
365,
2808,
2344,
272,
687,
24374,
492,
5478,
272,
372,
5478,
14,
1989,
12827,
88,
724,
438,
8,
485,
15498,
63,
2339,
776,
421,
199,
5680,
7729,
25420,
12795,
6989,
29074,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
luistorresm/odoo
|
addons/l10n_co/wizard/__init__.py
|
313
|
1165
|
# -*- encoding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) David Arnold (devCO).
# Author David Arnold (devCO), dar@devco.co
# Co-Authors Juan Pablo Aries (devCO), jpa@devco.co
# Hector Ivan Valencia Muñoz (TIX SAS)
# Nhomar Hernandez (Vauxoo)
# Humberto Ochoa (Vauxoo)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
|
agpl-3.0
|
[
3,
1882,
2644,
26,
2774,
13,
24,
1882,
199,
4605,
199,
3,
199,
3,
7653,
12,
3232,
5800,
8259,
9274,
199,
3,
1898,
334,
35,
9,
20232,
1952,
78,
1753,
334,
2374,
1439,
680,
199,
3,
6529,
263,
20232,
1952,
78,
1753,
334,
2374,
1439,
395,
366,
285,
32,
2374,
331,
14,
331,
199,
3,
1849,
13,
2817,
1384,
259,
1603,
7856,
510,
371,
320,
437,
1996,
334,
2374,
1439,
395,
1335,
387,
32,
2374,
331,
14,
331,
199,
3,
5185,
869,
2406,
473,
20662,
812,
20634,
16521,
28919,
22692,
26051,
334,
52,
3867,
26124,
9,
199,
3,
5185,
653,
526,
4584,
18769,
4304,
271,
90,
334,
54,
10962,
1534,
9,
199,
3,
5185,
869,
884,
475,
593,
2239,
65,
334,
54,
10962,
1534,
9,
199,
3,
199,
3,
961,
2240,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
652,
1334,
314,
2895,
402,
314,
1664,
4265,
1696,
1684,
844,
465,
199,
3,
3267,
701,
314,
2868,
2290,
2752,
12,
1902,
1015,
650,
402,
314,
199,
3,
844,
12,
503,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
961,
2240,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
1666,
314,
199,
3,
1664,
4265,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
4265,
1696,
1684,
844,
199,
3,
3180,
543,
642,
2240,
14,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
3,
199,
4605,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
1882,
2644,
26,
2774,
13,
24,
1882,
199,
4605,
199,
3,
199,
3,
7653,
12,
3232,
5800,
8259,
9274,
199,
3,
1898,
334,
35,
9,
20232,
1952,
78,
1753,
334,
2374,
1439,
680,
199,
3,
6529,
263,
20232,
1952,
78,
1753,
334,
2374,
1439,
395,
366,
285,
32,
2374,
331,
14,
331,
199,
3,
1849,
13,
2817,
1384,
259,
1603,
7856,
510,
371,
320,
437,
1996,
334,
2374,
1439,
395,
1335,
387,
32,
2374,
331,
14,
331,
199,
3,
5185,
869,
2406,
473,
20662,
812,
20634,
16521,
28919,
22692,
26051,
334,
52,
3867,
26124,
9,
199,
3,
5185,
653,
526,
4584,
18769,
4304,
271,
90,
334,
54,
10962,
1534,
9,
199,
3,
5185,
869,
884,
475,
593,
2239,
65,
334,
54,
10962,
1534,
9,
199,
3,
199,
3,
961,
2240,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
652,
1334,
314,
2895,
402,
314,
1664,
4265,
1696,
1684,
844,
465,
199,
3,
3267,
701,
314,
2868,
2290,
2752,
12,
1902,
1015,
650,
402,
314,
199,
3,
844,
12,
503,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
961,
2240,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
1666,
314,
199,
3,
1664,
4265,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
4265,
1696,
1684,
844,
199,
3,
3180,
543,
642,
2240,
14,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
3,
199,
4605,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
google/vogon
|
third_party/bottle/test/test_config.py
|
16
|
1357
|
import unittest
from bottle import ConfigDict
class TestConfDict(unittest.TestCase):
def test_write(self):
c = ConfigDict()
c['key'] = 'value'
self.assertEqual(c['key'], 'value')
self.assertTrue('key' in c)
c['key'] = 'value2'
self.assertEqual(c['key'], 'value2')
def test_update(self):
c = ConfigDict()
c['key'] = 'value'
c.update(key='value2', key2='value3')
self.assertEqual(c['key'], 'value2')
self.assertEqual(c['key2'], 'value3')
def test_namespaces(self):
c = ConfigDict()
c.update('a.b', key='value')
self.assertEqual(c['a.b.key'], 'value')
def test_meta(self):
c = ConfigDict()
c.meta_set('bool', 'filter', bool)
c.meta_set('int', 'filter', int)
c['bool'] = 'I am so true!'
c['int'] = '6'
self.assertTrue(c['bool'] is True)
self.assertEquals(c['int'], 6)
self.assertRaises(ValueError, lambda: c.update(int='not an int'))
def test_load_dict(self):
c = ConfigDict()
d = dict(a=dict(b=dict(foo=5, bar=6), baz=7))
c.load_dict(d)
self.assertEquals(c['a.b.foo'], 5)
self.assertEquals(c['a.b.bar'], 6)
self.assertEquals(c['a.baz'], 7)
if __name__ == '__main__': #pragma: no cover
unittest.main()
|
apache-2.0
|
[
646,
2882,
199,
504,
5888,
1118,
492,
4094,
2141,
199,
199,
533,
1379,
8930,
2141,
8,
2796,
14,
1746,
304,
272,
347,
511,
63,
952,
8,
277,
304,
267,
286,
275,
4094,
2141,
342,
267,
286,
459,
498,
418,
275,
283,
585,
7,
267,
291,
14,
629,
8,
67,
459,
498,
995,
283,
585,
358,
267,
291,
14,
1815,
360,
498,
7,
315,
286,
9,
267,
286,
459,
498,
418,
275,
283,
585,
18,
7,
267,
291,
14,
629,
8,
67,
459,
498,
995,
283,
585,
18,
358,
339,
347,
511,
63,
873,
8,
277,
304,
267,
286,
275,
4094,
2141,
342,
267,
286,
459,
498,
418,
275,
283,
585,
7,
267,
286,
14,
873,
8,
498,
534,
585,
18,
297,
790,
18,
534,
585,
19,
358,
267,
291,
14,
629,
8,
67,
459,
498,
995,
283,
585,
18,
358,
267,
291,
14,
629,
8,
67,
459,
498,
18,
995,
283,
585,
19,
358,
339,
347,
511,
63,
9247,
8,
277,
304,
267,
286,
275,
4094,
2141,
342,
267,
286,
14,
873,
360,
65,
14,
66,
297,
790,
534,
585,
358,
267,
291,
14,
629,
8,
67,
459,
65,
14,
66,
14,
498,
995,
283,
585,
358,
339,
347,
511,
63,
2024,
8,
277,
304,
267,
286,
275,
4094,
2141,
342,
267,
286,
14,
2024,
63,
409,
360,
2245,
297,
283,
1541,
297,
2155,
9,
267,
286,
14,
2024,
63,
409,
360,
442,
297,
283,
1541,
297,
1109,
9,
267,
286,
459,
2245,
418,
275,
283,
41,
8140,
880,
2549,
11213,
267,
286,
459,
442,
418,
221,
275,
283,
22,
7,
267,
291,
14,
1815,
8,
67,
459,
2245,
418,
365,
715,
9,
267,
291,
14,
2947,
8,
67,
459,
442,
995,
1227,
9,
267,
291,
14,
1855,
8,
3393,
12,
2400,
26,
286,
14,
873,
8,
442,
534,
1397,
376,
1109,
1333,
339,
347,
511,
63,
912,
63,
807,
8,
277,
304,
267,
286,
275,
4094,
2141,
342,
267,
366,
275,
1211,
8,
65,
29,
807,
8,
66,
29,
807,
8,
1421,
29,
21,
12,
4681,
29,
22,
395,
15507,
29,
23,
430,
267,
286,
14,
912,
63,
807,
8,
68,
9,
267,
291,
14,
2947,
8,
67,
459,
65,
14,
66,
14,
1421,
995,
959,
9,
267,
291,
14,
2947,
8,
67,
459,
65,
14,
66,
14,
1700,
995,
1227,
9,
267,
291,
14,
2947,
8,
67,
459,
65,
14,
6185,
995,
1520,
9,
272,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
327,
25852,
26,
949,
8486,
272,
2882,
14,
973,
342,
421,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
2882,
199,
504,
5888,
1118,
492,
4094,
2141,
199,
199,
533,
1379,
8930,
2141,
8,
2796,
14,
1746,
304,
272,
347,
511,
63,
952,
8,
277,
304,
267,
286,
275,
4094,
2141,
342,
267,
286,
459,
498,
418,
275,
283,
585,
7,
267,
291,
14,
629,
8,
67,
459,
498,
995,
283,
585,
358,
267,
291,
14,
1815,
360,
498,
7,
315,
286,
9,
267,
286,
459,
498,
418,
275,
283,
585,
18,
7,
267,
291,
14,
629,
8,
67,
459,
498,
995,
283,
585,
18,
358,
339,
347,
511,
63,
873,
8,
277,
304,
267,
286,
275,
4094,
2141,
342,
267,
286,
459,
498,
418,
275,
283,
585,
7,
267,
286,
14,
873,
8,
498,
534,
585,
18,
297,
790,
18,
534,
585,
19,
358,
267,
291,
14,
629,
8,
67,
459,
498,
995,
283,
585,
18,
358,
267,
291,
14,
629,
8,
67,
459,
498,
18,
995,
283,
585,
19,
358,
339,
347,
511,
63,
9247,
8,
277,
304,
267,
286,
275,
4094,
2141,
342,
267,
286,
14,
873,
360,
65,
14,
66,
297,
790,
534,
585,
358,
267,
291,
14,
629,
8,
67,
459,
65,
14,
66,
14,
498,
995,
283,
585,
358,
339,
347,
511,
63,
2024,
8,
277,
304,
267,
286,
275,
4094,
2141,
342,
267,
286,
14,
2024,
63,
409,
360,
2245,
297,
283,
1541,
297,
2155,
9,
267,
286,
14,
2024,
63,
409,
360,
442,
297,
283,
1541,
297,
1109,
9,
267,
286,
459,
2245,
418,
275,
283,
41,
8140,
880,
2549,
11213,
267,
286,
459,
442,
418,
221,
275,
283,
22,
7,
267,
291,
14,
1815,
8,
67,
459,
2245,
418,
365,
715,
9,
267,
291,
14,
2947,
8,
67,
459,
442,
995,
1227,
9,
267,
291,
14,
1855,
8,
3393,
12,
2400,
26,
286,
14,
873,
8,
442,
534,
1397,
376,
1109,
1333,
339,
347,
511,
63,
912,
63,
807,
8,
277,
304,
267,
286,
275,
4094,
2141,
342,
267,
366,
275,
1211,
8,
65,
29,
807,
8,
66,
29,
807,
8,
1421,
29,
21,
12,
4681,
29,
22,
395,
15507,
29,
23,
430,
267,
286,
14,
912,
63,
807,
8,
68,
9,
267,
291,
14,
2947,
8,
67,
459,
65,
14,
66,
14,
1421,
995,
959,
9,
267,
291,
14,
2947,
8,
67,
459,
65,
14,
66,
14,
1700,
995,
1227,
9,
267,
291,
14,
2947,
8,
67,
459,
65,
14,
6185,
995,
1520,
9,
272,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
327,
25852,
26,
949,
8486,
272,
2882,
14,
973,
342,
421,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
hlzz/dotfiles
|
graphics/VTK-7.0.0/ThirdParty/Twisted/twisted/application/strports.py
|
2
|
3242
|
# -*- test-case-name: twisted.test.test_strports -*-
# Copyright (c) Twisted Matrix Laboratories.
# See LICENSE for details.
"""
Construct listening port services from a simple string description.
@see: L{twisted.internet.endpoints.serverFromString}
@see: L{twisted.internet.endpoints.clientFromString}
"""
import warnings
from twisted.internet import endpoints
from twisted.python.deprecate import deprecatedModuleAttribute
from twisted.python.versions import Version
from twisted.application.internet import StreamServerEndpointService
def parse(description, factory, default='tcp'):
"""
This function is deprecated as of Twisted 10.2.
@see: L{twisted.internet.endpoints.server}
"""
return endpoints._parseServer(description, factory, default)
deprecatedModuleAttribute(
Version("Twisted", 10, 2, 0),
"in favor of twisted.internet.endpoints.serverFromString",
__name__, "parse")
_DEFAULT = object()
def service(description, factory, default=_DEFAULT, reactor=None):
"""
Return the service corresponding to a description.
@param description: The description of the listening port, in the syntax
described by L{twisted.internet.endpoints.server}.
@type description: C{str}
@param factory: The protocol factory which will build protocols for
connections to this service.
@type factory: L{twisted.internet.interfaces.IProtocolFactory}
@type default: C{str} or C{None}
@param default: Do not use this parameter. It has been deprecated since
Twisted 10.2.0.
@rtype: C{twisted.application.service.IService}
@return: the service corresponding to a description of a reliable
stream server.
@see: L{twisted.internet.endpoints.serverFromString}
"""
if reactor is None:
from twisted.internet import reactor
if default is _DEFAULT:
default = None
else:
message = "The 'default' parameter was deprecated in Twisted 10.2.0."
if default is not None:
message += (
" Use qualified endpoint descriptions; for example, "
"'tcp:%s'." % (description,))
warnings.warn(
message=message, category=DeprecationWarning, stacklevel=2)
svc = StreamServerEndpointService(
endpoints._serverFromStringLegacy(reactor, description, default),
factory)
svc._raiseSynchronously = True
return svc
def listen(description, factory, default=None):
"""Listen on a port corresponding to a description
@type description: C{str}
@type factory: L{twisted.internet.interfaces.IProtocolFactory}
@type default: C{str} or C{None}
@rtype: C{twisted.internet.interfaces.IListeningPort}
@return: the port corresponding to a description of a reliable
virtual circuit server.
See the documentation of the C{parse} function for description
of the semantics of the arguments.
"""
from twisted.internet import reactor
name, args, kw = parse(description, factory, default)
return getattr(reactor, 'listen'+name)(*args, **kw)
__all__ = ['parse', 'service', 'listen']
|
bsd-3-clause
|
[
3,
1882,
511,
13,
2546,
13,
354,
26,
7390,
14,
396,
14,
396,
63,
495,
5203,
1882,
202,
199,
3,
1898,
334,
67,
9,
17078,
8449,
26640,
14,
202,
199,
3,
1666,
5113,
367,
2436,
14,
2999,
199,
624,
202,
199,
11493,
22721,
1844,
8500,
687,
282,
3486,
1059,
1369,
14,
2999,
199,
32,
3239,
26,
491,
91,
12145,
14,
4901,
14,
14461,
14,
1000,
7671,
93,
202,
199,
32,
3239,
26,
491,
91,
12145,
14,
4901,
14,
14461,
14,
1258,
7671,
93,
202,
199,
624,
2999,
199,
646,
3598,
2999,
199,
504,
7390,
14,
4901,
492,
16173,
202,
199,
504,
7390,
14,
1548,
14,
27891,
492,
5906,
2377,
1646,
202,
199,
504,
7390,
14,
1548,
14,
6234,
492,
3394,
202,
199,
504,
7390,
14,
3578,
14,
4901,
492,
8271,
3120,
11442,
3167,
1223,
8065,
199,
318,
2198,
8,
1802,
12,
6434,
12,
849,
534,
8815,
735,
1128,
408,
1128,
961,
805,
365,
5906,
465,
402,
17078,
1616,
14,
18,
14,
2958,
768,
3239,
26,
491,
91,
12145,
14,
4901,
14,
14461,
14,
1000,
93,
1128,
408,
1128,
372,
16173,
423,
1122,
3120,
8,
1802,
12,
6434,
12,
849,
9,
2999,
199,
6667,
2377,
1646,
8,
1128,
3394,
480,
52,
5221,
401,
1616,
12,
499,
12,
378,
395,
1128,
298,
262,
17914,
402,
7390,
14,
4901,
14,
14461,
14,
1000,
7671,
401,
1128,
636,
354,
3108,
298,
1122,
531,
1223,
8065,
199,
63,
3472,
275,
909,
342,
2999,
199,
318,
2435,
8,
1802,
12,
6434,
12,
849,
3699,
3472,
12,
9655,
29,
403,
304,
1128,
408,
1128,
1432,
314,
2435,
5226,
370,
282,
1369,
14,
2958,
768,
635,
1369,
26,
710,
1369,
402,
314,
22721,
1844,
12,
315,
314,
6302,
1039,
11736,
701,
491,
91,
12145,
14,
4901,
14,
14461,
14,
1000,
5565,
2958,
768,
466,
1369,
26,
445,
91,
495,
93,
2958,
768,
635,
6434,
26,
710,
4113,
6434,
1314,
911,
1900,
19230,
367,
1039,
6947,
370,
642,
2435,
14,
2958,
768,
466,
6434,
26,
491,
91,
12145,
14,
4901,
14,
7436,
14,
41,
3658,
2927,
93,
2958,
768,
466,
849,
26,
445,
91,
495,
93,
503,
445,
91,
403,
93,
2958,
768,
635,
849,
26,
4226,
440,
675,
642,
2725,
14,
2779,
965,
2757,
5906,
3967,
1039,
17078,
1616,
14,
18,
14,
16,
14,
2958,
768,
4500,
26,
445,
91,
12145,
14,
3578,
14,
1364,
14,
1311,
281,
722,
93,
2958,
768,
1107,
26,
314,
2435,
5226,
370,
282,
1369,
402,
282,
32150,
1039,
2547,
1654,
14,
2958,
768,
3239,
26,
491,
91,
12145,
14,
4901,
14,
14461,
14,
1000,
7671,
93,
1128,
408,
1128,
340,
9655,
365,
488,
26,
1039,
687,
7390,
14,
4901,
492,
9655,
1128,
340,
849,
365,
485,
3472,
26,
1039,
849,
275,
488,
1128,
587,
26,
1039,
1245,
275,
298,
1918,
283,
885,
7,
2725,
1990,
5906,
315,
17078,
1616,
14,
18,
14,
16,
2122,
1039,
340,
849,
365,
440,
488,
26,
1675,
1245,
847,
334,
2628,
298,
221,
3645,
12313,
6037,
18714,
27,
367,
2893,
12,
298,
2628,
3546,
8815,
2689,
83,
16669,
450,
334,
1802,
4641,
1039,
3598,
14,
4050,
8,
1675,
1245,
29,
1188,
12,
4637,
29,
15561,
12,
13232,
29,
18,
9,
1128,
19257,
275,
8271,
3120,
11442,
3167,
8,
1039,
16173,
423,
1000,
7671,
22628,
8,
13544,
12,
1369,
12,
849,
395,
1039,
6434,
9,
1128,
19257,
423,
3730,
51,
9865,
590,
275,
715,
1128,
372,
19257,
1223,
8065,
199,
318,
6938,
8,
1802,
12,
6434,
12,
849,
29,
403,
304,
1128,
408,
8687,
641,
282,
1844,
5226,
370,
282,
1369,
2958,
768,
466,
1369,
26,
445,
91,
495,
93,
1128,
768,
466,
6434,
26,
491,
91,
12145,
14,
4901,
14,
7436,
14,
41,
3658,
2927,
93,
1128,
768,
466,
849,
26,
445,
91,
495,
93,
503,
445,
91,
403,
93,
1128,
768,
4500,
26,
445,
91,
12145,
14,
4901,
14,
7436,
14,
1193,
7938,
316,
4313,
93,
1128,
768,
1107,
26,
314,
1844,
5226,
370,
282,
1369,
402,
282,
32150,
1128,
5791,
20304,
1654,
14,
2958,
1666,
314,
3794,
402,
314,
445,
91,
1122,
93,
805,
367,
1369,
1128,
402,
314,
19002,
402,
314,
2368,
14,
1128,
408,
1128,
687,
7390,
14,
4901,
492,
9655,
1128,
536,
12,
1249,
12,
4775,
275,
2198,
8,
1802,
12,
6434,
12,
849,
9,
1128,
372,
2519,
8,
13544,
12,
283,
5859,
6828,
354,
25967,
589,
12,
1011,
829,
9,
1223,
8065,
199,
363,
452,
363,
275,
788,
1122,
297,
283,
1364,
297,
283,
5859,
418,
1223,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
1882,
511,
13,
2546,
13,
354,
26,
7390,
14,
396,
14,
396,
63,
495,
5203,
1882,
202,
199,
3,
1898,
334,
67,
9,
17078,
8449,
26640,
14,
202,
199,
3,
1666,
5113,
367,
2436,
14,
2999,
199,
624,
202,
199,
11493,
22721,
1844,
8500,
687,
282,
3486,
1059,
1369,
14,
2999,
199,
32,
3239,
26,
491,
91,
12145,
14,
4901,
14,
14461,
14,
1000,
7671,
93,
202,
199,
32,
3239,
26,
491,
91,
12145,
14,
4901,
14,
14461,
14,
1258,
7671,
93,
202,
199,
624,
2999,
199,
646,
3598,
2999,
199,
504,
7390,
14,
4901,
492,
16173,
202,
199,
504,
7390,
14,
1548,
14,
27891,
492,
5906,
2377,
1646,
202,
199,
504,
7390,
14,
1548,
14,
6234,
492,
3394,
202,
199,
504,
7390,
14,
3578,
14,
4901,
492,
8271,
3120,
11442,
3167,
1223,
8065,
199,
318,
2198,
8,
1802,
12,
6434,
12,
849,
534,
8815,
735,
1128,
408,
1128,
961,
805,
365,
5906,
465,
402,
17078,
1616,
14,
18,
14,
2958,
768,
3239,
26,
491,
91,
12145,
14,
4901,
14,
14461,
14,
1000,
93,
1128,
408,
1128,
372,
16173,
423,
1122,
3120,
8,
1802,
12,
6434,
12,
849,
9,
2999,
199,
6667,
2377,
1646,
8,
1128,
3394,
480,
52,
5221,
401,
1616,
12,
499,
12,
378,
395,
1128,
298,
262,
17914,
402,
7390,
14,
4901,
14,
14461,
14,
1000,
7671,
401,
1128,
636,
354,
3108,
298,
1122,
531,
1223,
8065,
199,
63,
3472,
275,
909,
342,
2999,
199,
318,
2435,
8,
1802,
12,
6434,
12,
849,
3699,
3472,
12,
9655,
29,
403,
304,
1128,
408,
1128,
1432,
314,
2435,
5226,
370,
282,
1369,
14,
2958,
768,
635,
1369,
26,
710,
1369,
402,
314,
22721,
1844,
12,
315,
314,
6302,
1039,
11736,
701,
491,
91,
12145,
14,
4901,
14,
14461,
14,
1000,
5565,
2958,
768,
466,
1369,
26,
445,
91,
495,
93,
2958,
768,
635,
6434,
26,
710,
4113,
6434,
1314,
911,
1900,
19230,
367,
1039,
6947,
370,
642,
2435,
14,
2958,
768,
466,
6434,
26,
491,
91,
12145,
14,
4901,
14,
7436,
14,
41,
3658,
2927,
93,
2958,
768,
466,
849,
26,
445,
91,
495,
93,
503,
445,
91,
403,
93,
2958,
768,
635,
849,
26,
4226,
440,
675,
642,
2725,
14,
2779,
965,
2757,
5906,
3967,
1039,
17078,
1616,
14,
18,
14,
16,
14,
2958,
768,
4500,
26,
445,
91,
12145,
14,
3578,
14,
1364,
14,
1311,
281,
722,
93,
2958,
768,
1107,
26,
314,
2435,
5226,
370,
282,
1369,
402,
282,
32150,
1039,
2547,
1654,
14,
2958,
768,
3239,
26,
491,
91,
12145,
14,
4901,
14,
14461,
14,
1000,
7671,
93,
1128,
408,
1128,
340,
9655,
365,
488,
26,
1039,
687,
7390,
14,
4901,
492,
9655,
1128,
340,
849,
365,
485,
3472,
26,
1039,
849,
275,
488,
1128,
587,
26,
1039,
1245,
275,
298,
1918,
283,
885,
7,
2725,
1990,
5906,
315,
17078,
1616,
14,
18,
14,
16,
2122,
1039,
340,
849,
365,
440,
488,
26,
1675,
1245,
847,
334,
2628,
298,
221,
3645,
12313,
6037,
18714,
27,
367,
2893,
12,
298,
2628,
3546,
8815,
2689,
83,
16669,
450,
334,
1802,
4641,
1039,
3598,
14,
4050,
8,
1675,
1245,
29,
1188,
12,
4637,
29,
15561,
12,
13232,
29,
18,
9,
1128,
19257,
275,
8271,
3120,
11442,
3167,
8,
1039,
16173,
423,
1000,
7671,
22628,
8,
13544,
12,
1369,
12,
849,
395,
1039,
6434,
9,
1128,
19257,
423,
3730,
51,
9865,
590,
275,
715,
1128,
372,
19257,
1223,
8065,
199,
318,
6938,
8,
1802,
12,
6434,
12,
849,
29,
403,
304,
1128,
408,
8687,
641,
282,
1844,
5226,
370,
282,
1369,
2958,
768,
466,
1369,
26,
445,
91,
495,
93,
1128,
768,
466,
6434,
26,
491,
91,
12145,
14,
4901,
14,
7436,
14,
41,
3658,
2927,
93,
1128,
768,
466,
849,
26,
445,
91,
495,
93,
503,
445,
91,
403,
93,
1128,
768,
4500,
26,
445,
91,
12145,
14,
4901,
14,
7436,
14,
1193,
7938,
316,
4313,
93,
1128,
768,
1107,
26,
314,
1844,
5226,
370,
282,
1369,
402,
282,
32150,
1128,
5791,
20304,
1654,
14,
2958,
1666,
314,
3794,
402,
314,
445,
91,
1122,
93,
805,
367,
1369,
1128,
402,
314,
19002,
402,
314,
2368,
14,
1128,
408,
1128,
687,
7390,
14,
4901,
492,
9655,
1128,
536,
12,
1249,
12,
4775,
275,
2198,
8,
1802,
12,
6434,
12,
849,
9,
1128,
372,
2519,
8,
13544,
12,
283,
5859,
6828,
354,
25967,
589,
12,
1011,
829,
9,
1223,
8065,
199,
363,
452,
363,
275,
788,
1122,
297,
283,
1364,
297,
283,
5859,
418,
1223,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
linjoahow/w17g
|
static/Brython3.1.3-20150514-095342/Lib/posix.py
|
603
|
20904
|
"""This module provides access to operating system functionality that is
standardized by the C Standard and the POSIX standard (a thinly
disguised Unix interface). Refer to the library manual and
corresponding Unix manual entries for more information on calls."""
import datetime
from browser import window
def _randint(a, b):
return int(window.Math.random()*(b-a+1)+a)
F_OK = 0
O_APPEND = 8
O_BINARY = 32768
O_CREAT = 256
O_EXCL = 1024
O_NOINHERIT = 128
O_RANDOM = 16
O_RDONLY = 0
O_RDWR = 2
O_SEQUENTIAL = 32
O_SHORT_LIVED = 4096
O_TEMPORARY = 64
O_TEXT = 16384
O_TRUNC = 512
O_WRONLY = 1
P_DETACH = 4
P_NOWAIT = 1
P_NOWAITO = 3
P_OVERLAY = 2
P_WAIT = 0
R_OK = 4
TMP_MAX = 32767
W_OK = 2
X_OK = 1
class __loader__:
pass
def _exit(*args,**kw):
"""_exit(status)
Exit to the system with specified status, without normal exit processing."""
pass
def _getdiskusage(*args,**kw):
"""_getdiskusage(path) -> (total, free)
Return disk usage statistics about the given path as (total, free) tuple."""
pass
def _getfileinformation(*args,**kw):
pass
def _getfinalpathname(*args,**kw):
pass
def _getfullpathname(*args,**kw):
pass
_have_functions = ['MS_WINDOWS']
def _isdir(*args,**kw):
"""Return true if the pathname refers to an existing directory."""
pass
def abort(*args,**kw):
"""abort() -> does not return!
Abort the interpreter immediately. This 'dumps core' or otherwise fails
in the hardest way possible on the hosting operating system."""
pass
def access(*args,**kw):
"""access(path, mode, *, dir_fd=None, effective_ids=False, follow_symlinks=True)
Use the real uid/gid to test for access to a path. Returns True if granted,
False otherwise.
If dir_fd is not None, it should be a file descriptor open to a directory,
and path should be relative; path will then be relative to that directory.
If effective_ids is True, access will use the effective uid/gid instead of
the real uid/gid.
If follow_symlinks is False, and the last element of the path is a symbolic
link, access will examine the symbolic link itself instead of the file the
link points to.
dir_fd, effective_ids, and follow_symlinks may not be implemented
on your platform. If they are unavailable, using them will raise a
NotImplementedError.
Note that most operations will use the effective uid/gid, therefore this
routine can be used in a suid/sgid environment to test if the invoking user
has the specified access to the path.
The mode argument can be F_OK to test existence, or the inclusive-OR
of R_OK, W_OK, and X_OK."""
pass
def chdir(*args,**kw):
"""chdir(path)
Change the current working directory to the specified path.
path may always be specified as a string.
On some platforms, path may also be specified as an open file descriptor.
If this functionality is unavailable, using it raises an exception."""
pass
def chmod(*args,**kw):
"""chmod(path, mode, *, dir_fd=None, follow_symlinks=True)
Change the access permissions of a file.
path may always be specified as a string.
On some platforms, path may also be specified as an open file descriptor.
If this functionality is unavailable, using it raises an exception.
If dir_fd is not None, it should be a file descriptor open to a directory,
and path should be relative; path will then be relative to that directory.
If follow_symlinks is False, and the last element of the path is a symbolic
link, chmod will modify the symbolic link itself instead of the file the
link points to.
It is an error to use dir_fd or follow_symlinks when specifying path as
an open file descriptor.
dir_fd and follow_symlinks may not be implemented on your platform.
If they are unavailable, using them will raise a NotImplementedError."""
pass
def close(*args,**kw):
"""close(fd)
Close a file descriptor (for low level IO)."""
pass
def closerange(*args,**kw):
"""closerange(fd_low, fd_high)
Closes all file descriptors in [fd_low, fd_high), ignoring errors."""
pass
def device_encoding(*args,**kw):
"""device_encoding(fd) -> str
Return a string describing the encoding of the device
if the output is a terminal; else return None."""
pass
def dup(*args,**kw):
"""dup(fd) -> fd2
Return a duplicate of a file descriptor."""
pass
def dup2(*args,**kw):
"""dup2(old_fd, new_fd)
Duplicate file descriptor."""
pass
environ = {'PYTHONUSERBASE': ' '}
error = OSError
def execv(*args,**kw):
"""execv(path, args)
Execute an executable path with arguments, replacing current process.
path: path of executable file
args: tuple or list of strings"""
pass
def execve(*args,**kw):
"""execve(path, args, env)
Execute a path with arguments and environment, replacing current process.
path: path of executable file
args: tuple or list of arguments
env: dictionary of strings mapping to strings
On some platforms, you may specify an open file descriptor for path;
execve will execute the program the file descriptor is open to.
If this functionality is unavailable, using it raises NotImplementedError."""
pass
def fstat(*args,**kw):
"""fstat(fd) -> stat result
Like stat(), but for an open file descriptor.
Equivalent to stat(fd=fd)."""
pass
def fsync(*args,**kw):
"""fsync(fildes)
force write of file with filedescriptor to disk."""
pass
def get_terminal_size(*args,**kw):
"""Return the size of the terminal window as (columns, lines).
The optional argument fd (default standard output) specifies
which file descriptor should be queried.
If the file descriptor is not connected to a terminal, an OSError
is thrown.
This function will only be defined if an implementation is
available for this system.
shutil.get_terminal_size is the high-level function which should
normally be used, os.get_terminal_size is the low-level implementation."""
pass
def getcwd(*args,**kw):
"""getcwd() -> path
Return a unicode string representing the current working directory."""
return __BRYTHON__.brython_path # XXX fix me
def getcwdb(*args,**kw):
"""getcwdb() -> path
Return a bytes string representing the current working directory."""
pass
def getlogin(*args,**kw):
"""getlogin() -> string
Return the actual login name."""
pass
def getpid(*args,**kw):
"""getpid() -> pid
Return the current process id"""
return 0
def getppid(*args,**kw):
"""getppid() -> ppid
Return the parent's process id. If the parent process has already exited,
Windows machines will still return its id; others systems will return the id
of the 'init' process (1)."""
pass
def isatty(*args,**kw):
"""isatty(fd) -> bool
Return True if the file descriptor 'fd' is an open file descriptor
connected to the slave end of a terminal."""
pass
def kill(*args,**kw):
"""kill(pid, sig)
Kill a process with a signal."""
pass
def link(*args,**kw):
"""link(src, dst, *, src_dir_fd=None, dst_dir_fd=None, follow_symlinks=True)
Create a hard link to a file.
If either src_dir_fd or dst_dir_fd is not None, it should be a file
descriptor open to a directory, and the respective path string (src or dst)
should be relative; the path will then be relative to that directory.
If follow_symlinks is False, and the last element of src is a symbolic
link, link will create a link to the symbolic link itself instead of the
file the link points to.
src_dir_fd, dst_dir_fd, and follow_symlinks may not be implemented on your
platform. If they are unavailable, using them will raise a
NotImplementedError."""
pass
def listdir(*args,**kw):
"""listdir(path='.') -> list_of_filenames
Return a list containing the names of the files in the directory.
The list is in arbitrary order. It does not include the special
entries '.' and '..' even if they are present in the directory.
path can be specified as either str or bytes. If path is bytes,
the filenames returned will also be bytes; in all other circumstances
the filenames returned will be str.
On some platforms, path may also be specified as an open file descriptor;
the file descriptor must refer to a directory.
If this functionality is unavailable, using it raises NotImplementedError."""
pass
def lseek(*args,**kw):
"""lseek(fd, pos, how) -> newpos
Set the current position of a file descriptor.
Return the new cursor position in bytes, starting from the beginning."""
pass
def lstat(*args,**kw):
"""lstat(path, *, dir_fd=None) -> stat result
Like stat(), but do not follow symbolic links.
Equivalent to stat(path, follow_symlinks=False)."""
return stat_result()
def mkdir(*args,**kw):
"""mkdir(path, mode=0o777, *, dir_fd=None)
Create a directory.
If dir_fd is not None, it should be a file descriptor open to a directory,
and path should be relative; path will then be relative to that directory.
dir_fd may not be implemented on your platform.
If it is unavailable, using it will raise a NotImplementedError.
The mode argument is ignored on Windows."""
pass
def open(*args,**kw):
"""open(path, flags, mode=0o777, *, dir_fd=None)
Open a file for low level IO. Returns a file handle (integer).
If dir_fd is not None, it should be a file descriptor open to a directory,
and path should be relative; path will then be relative to that directory.
dir_fd may not be implemented on your platform.
If it is unavailable, using it will raise a NotImplementedError."""
pass
def pipe(*args,**kw):
"""pipe() -> (read_end, write_end)
Create a pipe."""
pass
def putenv(*args,**kw):
"""putenv(key, value)
Change or add an environment variable."""
pass
def read(*args,**kw):
"""read(fd, buffersize) -> string
Read a file descriptor."""
pass
def readlink(*args,**kw):
"""readlink(path, *, dir_fd=None) -> path
Return a string representing the path to which the symbolic link points.
If dir_fd is not None, it should be a file descriptor open to a directory,
and path should be relative; path will then be relative to that directory.
dir_fd may not be implemented on your platform.
If it is unavailable, using it will raise a NotImplementedError."""
pass
def remove(*args,**kw):
"""remove(path, *, dir_fd=None)
Remove a file (same as unlink()).
If dir_fd is not None, it should be a file descriptor open to a directory,
and path should be relative; path will then be relative to that directory.
dir_fd may not be implemented on your platform.
If it is unavailable, using it will raise a NotImplementedError."""
pass
def rename(*args,**kw):
"""rename(src, dst, *, src_dir_fd=None, dst_dir_fd=None)
Rename a file or directory.
If either src_dir_fd or dst_dir_fd is not None, it should be a file
descriptor open to a directory, and the respective path string (src or dst)
should be relative; the path will then be relative to that directory.
src_dir_fd and dst_dir_fd, may not be implemented on your platform.
If they are unavailable, using them will raise a NotImplementedError."""
pass
def replace(*args,**kw):
"""replace(src, dst, *, src_dir_fd=None, dst_dir_fd=None)
Rename a file or directory, overwriting the destination.
If either src_dir_fd or dst_dir_fd is not None, it should be a file
descriptor open to a directory, and the respective path string (src or dst)
should be relative; the path will then be relative to that directory.
src_dir_fd and dst_dir_fd, may not be implemented on your platform.
If they are unavailable, using them will raise a NotImplementedError."""
pass
def rmdir(*args,**kw):
"""rmdir(path, *, dir_fd=None)
Remove a directory.
If dir_fd is not None, it should be a file descriptor open to a directory,
and path should be relative; path will then be relative to that directory.
dir_fd may not be implemented on your platform.
If it is unavailable, using it will raise a NotImplementedError."""
pass
def spawnv(*args,**kw):
"""spawnv(mode, path, args)
Execute the program 'path' in a new process.
mode: mode of process creation
path: path of executable file
args: tuple or list of strings"""
pass
def spawnve(*args,**kw):
"""spawnve(mode, path, args, env)
Execute the program 'path' in a new process.
mode: mode of process creation
path: path of executable file
args: tuple or list of arguments
env: dictionary of strings mapping to strings"""
pass
def startfile(*args,**kw):
"""startfile(filepath [, operation]) - Start a file with its associated application.
When "operation" is not specified or "open", this acts like
double-clicking the file in Explorer, or giving the file name as an
argument to the DOS "start" command: the file is opened with whatever
application (if any) its extension is associated.
When another "operation" is given, it specifies what should be done with
the file. A typical operation is "print".
startfile returns as soon as the associated application is launched.
There is no option to wait for the application to close, and no way
to retrieve the application's exit status.
The filepath is relative to the current directory. If you want to use
an absolute path, make sure the first character is not a slash ("/");
the underlying Win32 ShellExecute function doesn't work if it is."""
pass
def stat(*args,**kw):
"""stat(path, *, dir_fd=None, follow_symlinks=True) -> stat result
Perform a stat system call on the given path.
path may be specified as either a string or as an open file descriptor.
If dir_fd is not None, it should be a file descriptor open to a directory,
and path should be relative; path will then be relative to that directory.
dir_fd may not be supported on your platform; if it is unavailable, using
it will raise a NotImplementedError.
If follow_symlinks is False, and the last element of the path is a symbolic
link, stat will examine the symbolic link itself instead of the file the
link points to.
It is an error to use dir_fd or follow_symlinks when specifying path as
an open file descriptor."""
return stat_result()
def stat_float_times(*args,**kw):
"""stat_float_times([newval]) -> oldval
Determine whether os.[lf]stat represents time stamps as float objects.
If newval is True, future calls to stat() return floats, if it is False,
future calls return ints.
If newval is omitted, return the current setting.
"""
pass
class stat_result:
def __init__(self):
"""st_mode - protection bits,
st_ino - inode number,
st_dev - device,
st_nlink - number of hard links,
st_uid - user id of owner,
st_gid - group id of owner,
st_size - size of file, in bytes,
st_atime - time of most recent access expressed in seconds,
st_mtime - time of most recent content modification expressed in
seconds,
st_ctime - platform dependent; time of most recent metadata change on
Unix, or the time of creation on Windows, expressed in seconds
st_atime_ns - time of most recent access expressed in nanoseconds as an
integer,
st_mtime_ns - time of most recent content modification expressed in
nanoseconds as an integer,
st_ctime_ns - platform dependent; time of most recent metadata change
on Unix, or the time of creation on Windows, expressed in
nanoseconds as an integer """
# Brython : fake values
self.st_atime = datetime.datetime.now()
self.st_mtime = self.st_ctime = self.st_atime_ns = \
self.st_mtime_ns = self.st_ctime_ns = self.st_atime
self.st_uid = self.st_gid = self.st_ino = -1
self.st_mode = 0
self.st_size = 1
class statvfs_result:
pass
def strerror(*args,**kw):
"""strerror(code) -> string
Translate an error code to a message string."""
pass
def symlink(*args,**kw):
"""symlink(src, dst, target_is_directory=False, *, dir_fd=None)
Create a symbolic link pointing to src named dst.
target_is_directory is required on Windows if the target is to be
interpreted as a directory. (On Windows, symlink requires
Windows 6.0 or greater, and raises a NotImplementedError otherwise.)
target_is_directory is ignored on non-Windows platforms.
If dir_fd is not None, it should be a file descriptor open to a directory,
and path should be relative; path will then be relative to that directory.
dir_fd may not be implemented on your platform.
If it is unavailable, using it will raise a NotImplementedError."""
pass
def system(*args,**kw):
"""system(command) -> exit_status
Execute the command (a string) in a subshell."""
pass
class terminal_size:
pass
def times(*args,**kw):
"""times() -> times_result
Return an object containing floating point numbers indicating process
times. The object behaves like a named tuple with these fields:
(utime, stime, cutime, cstime, elapsed_time)"""
pass
class times_result:
pass
def umask(*args,**kw):
"""umask(new_mask) -> old_mask
Set the current numeric umask and return the previous umask."""
pass
class uname_result:
pass
def unlink(*args,**kw):
"""unlink(path, *, dir_fd=None)
Remove a file (same as remove()).
If dir_fd is not None, it should be a file descriptor open to a directory,
and path should be relative; path will then be relative to that directory.
dir_fd may not be implemented on your platform.
If it is unavailable, using it will raise a NotImplementedError."""
pass
def urandom(n):
"""urandom(n) -> str
Return n random bytes suitable for cryptographic use."""
randbytes= [_randint(0,255) for i in range(n)]
return bytes(randbytes)
def utime(*args,**kw):
"""utime(path, times=None, *, ns=None, dir_fd=None, follow_symlinks=True) Set the access and modified time of path.
path may always be specified as a string.
On some platforms, path may also be specified as an open file descriptor.
If this functionality is unavailable, using it raises an exception.
If times is not None, it must be a tuple (atime, mtime);
atime and mtime should be expressed as float seconds since the epoch.
If ns is not None, it must be a tuple (atime_ns, mtime_ns);
atime_ns and mtime_ns should be expressed as integer nanoseconds
since the epoch.
If both times and ns are None, utime uses the current time.
Specifying tuples for both times and ns is an error.
If dir_fd is not None, it should be a file descriptor open to a directory,
and path should be relative; path will then be relative to that directory.
If follow_symlinks is False, and the last element of the path is a symbolic
link, utime will modify the symbolic link itself instead of the file the
link points to.
It is an error to use dir_fd or follow_symlinks when specifying path
as an open file descriptor.
dir_fd and follow_symlinks may not be available on your platform.
If they are unavailable, using them will raise a NotImplementedError."""
pass
def waitpid(*args,**kw):
"""waitpid(pid, options) -> (pid, status << 8)
Wait for completion of a given process. options is ignored on Windows."""
pass
def write(*args,**kw):
"""write(fd, string) -> byteswritten
Write a string to a file descriptor."""
pass
## put WIFSIGNALED here. its needed by os module, and os module imports all
## functions in this module
def WIFSIGNALED(a):
return False
def WTERMSIG(status):
return 0
def WIFSIGNALED(status):
"Return True if the process exited due to a signal, otherwise return False"
return False
def WIFEXITED(status):
return False
def WEXITSTATUS(status):
pass
def WNOHANG():
return (0,0)
|
gpl-3.0
|
[
624,
2765,
859,
6571,
2879,
370,
17406,
2656,
9330,
626,
365,
199,
7935,
18980,
7068,
701,
314,
445,
9739,
436,
314,
18169,
4465,
334,
65,
30758,
590,
199,
328,
1226,
85,
9096,
13074,
3217,
680,
221,
21751,
370,
314,
3555,
8722,
436,
199,
989,
31137,
13074,
8722,
4811,
367,
1655,
2556,
641,
4882,
1041,
199,
199,
646,
2197,
199,
199,
504,
7042,
492,
4353,
199,
199,
318,
485,
8393,
8,
65,
12,
330,
304,
272,
372,
1109,
8,
3806,
14,
18568,
14,
2355,
342,
5830,
66,
13,
65,
11,
17,
6393,
65,
9,
1362,
199,
38,
63,
3593,
275,
378,
199,
199,
47,
63,
25248,
275,
1695,
199,
199,
47,
63,
13246,
275,
20939,
2333,
199,
199,
47,
63,
32120,
275,
7633,
199,
199,
47,
63,
29647,
275,
6619,
199,
199,
47,
63,
2826,
568,
3452,
649,
275,
7960,
199,
199,
47,
63,
27644,
10462,
275,
3193,
199,
199,
47,
63,
15543,
10452,
275,
378,
199,
199,
47,
63,
15543,
6524,
275,
499,
199,
199,
47,
63,
9020,
275,
4337,
199,
199,
47,
63,
13003,
63,
2673,
14112,
275,
17125,
199,
199,
47,
63,
12510,
726,
4392,
275,
5049,
199,
199,
47,
63,
3876,
275,
24619,
1349,
199,
199,
47,
63,
22346,
275,
10574,
199,
199,
47,
63,
6524,
10452,
275,
413,
199,
199,
48,
63,
36,
15808,
1244,
275,
841,
199,
199,
48,
63,
2826,
12458,
275,
413,
199,
199,
48,
63,
2826,
12458,
47,
275,
650,
199,
199,
48,
63,
14336,
16897,
275,
499,
199,
199,
48,
63,
12458,
275,
378,
199,
199,
50,
63,
3593,
275,
841,
199,
199,
17983,
63,
4283,
275,
20939,
1822,
199,
199,
55,
63,
3593,
275,
499,
199,
199,
56,
63,
3593,
275,
413,
199,
199,
533,
636,
3422,
10651,
272,
986,
199,
199,
318,
485,
2224,
2031,
589,
12663,
829,
304,
272,
408,
63,
2224,
8,
1205,
9,
14821,
18704,
370,
314,
2656,
543,
2013,
2004,
12,
1928,
3293,
4458,
6661,
1041,
272,
986,
199,
199,
318,
485,
362,
4032,
3807,
2031,
589,
12663,
829,
304,
272,
408,
63,
362,
4032,
3807,
8,
515,
9,
1035,
334,
2923,
12,
2867,
9,
14821,
1432,
4543,
4503,
11076,
3595,
314,
1627,
931,
465,
334,
2923,
12,
2867,
9,
2008,
1041,
272,
986,
199,
199,
318,
485,
23462,
11697,
2031,
589,
12663,
829,
304,
272,
986,
199,
199,
318,
485,
362,
5094,
12445,
2031,
589,
12663,
829,
304,
272,
986,
199,
199,
318,
485,
362,
2861,
12445,
2031,
589,
12663,
829,
304,
272,
986,
199,
199,
63,
7804,
63,
5777,
275,
788,
3053,
63,
20509,
418,
199,
199,
318,
485,
6027,
2031,
589,
12663,
829,
304,
272,
408,
1767,
2549,
340,
314,
11776,
15724,
370,
376,
3411,
2082,
1041,
272,
986,
199,
199,
318,
12004,
2031,
589,
12663,
829,
304,
272,
408,
13845,
342,
1035,
1630,
440,
372,
1,
14821,
31455,
314,
12693,
9939,
14,
221,
961,
283,
4180,
6170,
7,
503,
4257,
6918,
272,
315,
314,
12159,
2614,
4340,
3962,
641,
314,
1591,
316,
17406,
2656,
1041,
272,
986,
199,
199,
318,
2879,
2031,
589,
12663,
829,
304,
272,
408,
2732,
8,
515,
12,
818,
12,
9889,
2935,
63,
2592,
29,
403,
12,
15826,
63,
1580,
29,
797,
12,
2035,
63,
19522,
29,
549,
9,
14821,
3645,
314,
3363,
1747,
15,
8787,
370,
511,
367,
2879,
370,
282,
931,
14,
221,
1803,
715,
340,
10009,
12,
272,
756,
4257,
14,
2286,
982,
2935,
63,
2592,
365,
440,
488,
12,
652,
1077,
506,
282,
570,
5872,
1551,
370,
282,
2082,
12,
489,
436,
931,
1077,
506,
3847,
27,
931,
911,
2066,
506,
3847,
370,
626,
2082,
14,
272,
982,
15826,
63,
1580,
365,
715,
12,
2879,
911,
675,
314,
15826,
1747,
15,
8787,
3140,
402,
489,
314,
3363,
1747,
15,
8787,
14,
272,
982,
2035,
63,
19522,
365,
756,
12,
436,
314,
2061,
1819,
402,
314,
931,
365,
282,
13673,
489,
2142,
12,
2879,
911,
31758,
314,
13673,
2142,
6337,
3140,
402,
314,
570,
314,
489,
2142,
4501,
370,
14,
272,
2935,
63,
2592,
12,
15826,
63,
1580,
12,
436,
2035,
63,
19522,
1443,
440,
506,
6366,
489,
641,
2195,
4298,
14,
221,
982,
2985,
787,
18735,
12,
1808,
3062,
911,
746,
282,
489,
4279,
14,
2286,
3390,
626,
4750,
5331,
911,
675,
314,
15826,
1747,
15,
8787,
12,
16119,
642,
489,
12981,
883,
506,
1202,
315,
282,
308,
1535,
15,
1226,
344,
3734,
370,
511,
340,
314,
26750,
922,
489,
965,
314,
2013,
2879,
370,
314,
931,
14,
272,
710,
818,
1423,
883,
506,
481,
63,
3593,
370,
511,
23780,
12,
503,
314,
20728,
13,
726,
489,
402,
820,
63,
3593,
12,
644,
63,
3593,
12,
436,
1323,
63,
3593,
1041,
272,
986,
199,
199,
318,
13097,
2031,
589,
12663,
829,
304,
272,
408,
8563,
8,
515,
9,
14821,
7743,
314,
1453,
6449,
2082,
370,
314,
2013,
931,
14,
2286,
931,
1443,
3544,
506,
2013,
465,
282,
1059,
14,
272,
4068,
2005,
10677,
12,
931,
1443,
2597,
506,
2013,
465,
376,
1551,
570,
5872,
14,
489,
982,
642,
9330,
365,
18735,
12,
1808,
652,
6534,
376,
1919,
1041,
272,
986,
199,
199,
318,
30106,
2031,
589,
12663,
829,
304,
272,
408,
11693,
8,
515,
12,
818,
12,
9889,
2935,
63,
2592,
29,
403,
12,
2035,
63,
19522,
29,
549,
9,
14821,
7743,
314,
2879,
3443,
402,
282,
570,
14,
2286,
931,
1443,
3544,
506,
2013,
465,
282,
1059,
14,
272,
4068,
2005,
10677,
12,
931,
1443,
2597,
506,
2013,
465,
376,
1551,
570,
5872,
14,
489,
982,
642,
9330,
365,
18735,
12,
1808,
652,
6534,
376,
1919,
14,
272,
982,
2935,
63,
2592,
365,
440,
488,
12,
652,
1077,
506,
282,
570,
5872,
1551,
370,
282,
2082,
12,
489,
436,
931,
1077,
506,
3847,
27,
931,
911,
2066,
506,
3847,
370,
626,
2082,
14,
272,
982,
2035,
63,
19522,
365,
756,
12,
436,
314,
2061,
1819,
402,
314,
931,
365,
282,
13673,
489,
2142,
12,
30106,
911,
2811,
314,
13673,
2142,
6337,
3140,
402,
314,
570,
314,
489,
2142,
4501,
370,
14,
272,
2779,
365,
376,
1125,
370,
675,
2935,
63,
2592,
503,
2035,
63,
19522,
1380,
9176,
931,
465,
489,
376,
1551,
570,
5872,
14,
272,
2935,
63,
2592,
436,
2035,
63,
19522,
1443,
440,
506
] |
[
2765,
859,
6571,
2879,
370,
17406,
2656,
9330,
626,
365,
199,
7935,
18980,
7068,
701,
314,
445,
9739,
436,
314,
18169,
4465,
334,
65,
30758,
590,
199,
328,
1226,
85,
9096,
13074,
3217,
680,
221,
21751,
370,
314,
3555,
8722,
436,
199,
989,
31137,
13074,
8722,
4811,
367,
1655,
2556,
641,
4882,
1041,
199,
199,
646,
2197,
199,
199,
504,
7042,
492,
4353,
199,
199,
318,
485,
8393,
8,
65,
12,
330,
304,
272,
372,
1109,
8,
3806,
14,
18568,
14,
2355,
342,
5830,
66,
13,
65,
11,
17,
6393,
65,
9,
1362,
199,
38,
63,
3593,
275,
378,
199,
199,
47,
63,
25248,
275,
1695,
199,
199,
47,
63,
13246,
275,
20939,
2333,
199,
199,
47,
63,
32120,
275,
7633,
199,
199,
47,
63,
29647,
275,
6619,
199,
199,
47,
63,
2826,
568,
3452,
649,
275,
7960,
199,
199,
47,
63,
27644,
10462,
275,
3193,
199,
199,
47,
63,
15543,
10452,
275,
378,
199,
199,
47,
63,
15543,
6524,
275,
499,
199,
199,
47,
63,
9020,
275,
4337,
199,
199,
47,
63,
13003,
63,
2673,
14112,
275,
17125,
199,
199,
47,
63,
12510,
726,
4392,
275,
5049,
199,
199,
47,
63,
3876,
275,
24619,
1349,
199,
199,
47,
63,
22346,
275,
10574,
199,
199,
47,
63,
6524,
10452,
275,
413,
199,
199,
48,
63,
36,
15808,
1244,
275,
841,
199,
199,
48,
63,
2826,
12458,
275,
413,
199,
199,
48,
63,
2826,
12458,
47,
275,
650,
199,
199,
48,
63,
14336,
16897,
275,
499,
199,
199,
48,
63,
12458,
275,
378,
199,
199,
50,
63,
3593,
275,
841,
199,
199,
17983,
63,
4283,
275,
20939,
1822,
199,
199,
55,
63,
3593,
275,
499,
199,
199,
56,
63,
3593,
275,
413,
199,
199,
533,
636,
3422,
10651,
272,
986,
199,
199,
318,
485,
2224,
2031,
589,
12663,
829,
304,
272,
408,
63,
2224,
8,
1205,
9,
14821,
18704,
370,
314,
2656,
543,
2013,
2004,
12,
1928,
3293,
4458,
6661,
1041,
272,
986,
199,
199,
318,
485,
362,
4032,
3807,
2031,
589,
12663,
829,
304,
272,
408,
63,
362,
4032,
3807,
8,
515,
9,
1035,
334,
2923,
12,
2867,
9,
14821,
1432,
4543,
4503,
11076,
3595,
314,
1627,
931,
465,
334,
2923,
12,
2867,
9,
2008,
1041,
272,
986,
199,
199,
318,
485,
23462,
11697,
2031,
589,
12663,
829,
304,
272,
986,
199,
199,
318,
485,
362,
5094,
12445,
2031,
589,
12663,
829,
304,
272,
986,
199,
199,
318,
485,
362,
2861,
12445,
2031,
589,
12663,
829,
304,
272,
986,
199,
199,
63,
7804,
63,
5777,
275,
788,
3053,
63,
20509,
418,
199,
199,
318,
485,
6027,
2031,
589,
12663,
829,
304,
272,
408,
1767,
2549,
340,
314,
11776,
15724,
370,
376,
3411,
2082,
1041,
272,
986,
199,
199,
318,
12004,
2031,
589,
12663,
829,
304,
272,
408,
13845,
342,
1035,
1630,
440,
372,
1,
14821,
31455,
314,
12693,
9939,
14,
221,
961,
283,
4180,
6170,
7,
503,
4257,
6918,
272,
315,
314,
12159,
2614,
4340,
3962,
641,
314,
1591,
316,
17406,
2656,
1041,
272,
986,
199,
199,
318,
2879,
2031,
589,
12663,
829,
304,
272,
408,
2732,
8,
515,
12,
818,
12,
9889,
2935,
63,
2592,
29,
403,
12,
15826,
63,
1580,
29,
797,
12,
2035,
63,
19522,
29,
549,
9,
14821,
3645,
314,
3363,
1747,
15,
8787,
370,
511,
367,
2879,
370,
282,
931,
14,
221,
1803,
715,
340,
10009,
12,
272,
756,
4257,
14,
2286,
982,
2935,
63,
2592,
365,
440,
488,
12,
652,
1077,
506,
282,
570,
5872,
1551,
370,
282,
2082,
12,
489,
436,
931,
1077,
506,
3847,
27,
931,
911,
2066,
506,
3847,
370,
626,
2082,
14,
272,
982,
15826,
63,
1580,
365,
715,
12,
2879,
911,
675,
314,
15826,
1747,
15,
8787,
3140,
402,
489,
314,
3363,
1747,
15,
8787,
14,
272,
982,
2035,
63,
19522,
365,
756,
12,
436,
314,
2061,
1819,
402,
314,
931,
365,
282,
13673,
489,
2142,
12,
2879,
911,
31758,
314,
13673,
2142,
6337,
3140,
402,
314,
570,
314,
489,
2142,
4501,
370,
14,
272,
2935,
63,
2592,
12,
15826,
63,
1580,
12,
436,
2035,
63,
19522,
1443,
440,
506,
6366,
489,
641,
2195,
4298,
14,
221,
982,
2985,
787,
18735,
12,
1808,
3062,
911,
746,
282,
489,
4279,
14,
2286,
3390,
626,
4750,
5331,
911,
675,
314,
15826,
1747,
15,
8787,
12,
16119,
642,
489,
12981,
883,
506,
1202,
315,
282,
308,
1535,
15,
1226,
344,
3734,
370,
511,
340,
314,
26750,
922,
489,
965,
314,
2013,
2879,
370,
314,
931,
14,
272,
710,
818,
1423,
883,
506,
481,
63,
3593,
370,
511,
23780,
12,
503,
314,
20728,
13,
726,
489,
402,
820,
63,
3593,
12,
644,
63,
3593,
12,
436,
1323,
63,
3593,
1041,
272,
986,
199,
199,
318,
13097,
2031,
589,
12663,
829,
304,
272,
408,
8563,
8,
515,
9,
14821,
7743,
314,
1453,
6449,
2082,
370,
314,
2013,
931,
14,
2286,
931,
1443,
3544,
506,
2013,
465,
282,
1059,
14,
272,
4068,
2005,
10677,
12,
931,
1443,
2597,
506,
2013,
465,
376,
1551,
570,
5872,
14,
489,
982,
642,
9330,
365,
18735,
12,
1808,
652,
6534,
376,
1919,
1041,
272,
986,
199,
199,
318,
30106,
2031,
589,
12663,
829,
304,
272,
408,
11693,
8,
515,
12,
818,
12,
9889,
2935,
63,
2592,
29,
403,
12,
2035,
63,
19522,
29,
549,
9,
14821,
7743,
314,
2879,
3443,
402,
282,
570,
14,
2286,
931,
1443,
3544,
506,
2013,
465,
282,
1059,
14,
272,
4068,
2005,
10677,
12,
931,
1443,
2597,
506,
2013,
465,
376,
1551,
570,
5872,
14,
489,
982,
642,
9330,
365,
18735,
12,
1808,
652,
6534,
376,
1919,
14,
272,
982,
2935,
63,
2592,
365,
440,
488,
12,
652,
1077,
506,
282,
570,
5872,
1551,
370,
282,
2082,
12,
489,
436,
931,
1077,
506,
3847,
27,
931,
911,
2066,
506,
3847,
370,
626,
2082,
14,
272,
982,
2035,
63,
19522,
365,
756,
12,
436,
314,
2061,
1819,
402,
314,
931,
365,
282,
13673,
489,
2142,
12,
30106,
911,
2811,
314,
13673,
2142,
6337,
3140,
402,
314,
570,
314,
489,
2142,
4501,
370,
14,
272,
2779,
365,
376,
1125,
370,
675,
2935,
63,
2592,
503,
2035,
63,
19522,
1380,
9176,
931,
465,
489,
376,
1551,
570,
5872,
14,
272,
2935,
63,
2592,
436,
2035,
63,
19522,
1443,
440,
506,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
blitzmann/Pyfa
|
gui/builtinMarketBrowser/itemView.py
|
1
|
10783
|
import wx
from logbook import Logger
from eos.saveddata.module import Module
import gui.builtinMarketBrowser.pfSearchBox as SBox
from gui.builtinMarketBrowser.events import ItemSelected, MAX_RECENTLY_USED_MODULES, RECENTLY_USED_MODULES
from gui.contextMenu import ContextMenu
from gui.display import Display
from gui.utils.staticHelpers import DragDropHelper
from service.attribute import Attribute
from service.fit import Fit
from config import slotColourMap
pyfalog = Logger(__name__)
class ItemView(Display):
DEFAULT_COLS = ["Base Icon",
"Base Name",
"attr:power,,,True",
"attr:cpu,,,True"]
def __init__(self, parent, marketBrowser):
Display.__init__(self, parent)
pyfalog.debug("Initialize ItemView")
marketBrowser.Bind(wx.EVT_TREE_SEL_CHANGED, self.selectionMade)
self.unfilteredStore = set()
self.filteredStore = set()
self.recentlyUsedModules = set()
self.sMkt = marketBrowser.sMkt
self.searchMode = marketBrowser.searchMode
self.sFit = Fit.getInstance()
self.marketBrowser = marketBrowser
self.marketView = marketBrowser.marketView
# Set up timer for delaying search on every EVT_TEXT
self.searchTimer = wx.Timer(self)
self.Bind(wx.EVT_TIMER, self.scheduleSearch, self.searchTimer)
# Make sure our search actually does interesting stuff
self.marketBrowser.search.Bind(SBox.EVT_TEXT_ENTER, self.scheduleSearch)
self.marketBrowser.search.Bind(SBox.EVT_SEARCH_BTN, self.scheduleSearch)
self.marketBrowser.search.Bind(SBox.EVT_CANCEL_BTN, self.clearSearch)
self.marketBrowser.search.Bind(SBox.EVT_TEXT, self.delaySearch)
# Make sure WE do interesting stuff too
self.Bind(wx.EVT_CONTEXT_MENU, self.contextMenu)
self.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.itemActivated)
self.Bind(wx.EVT_LIST_BEGIN_DRAG, self.startDrag)
# Make reverse map, used by sorter
self.metaMap = self.makeReverseMetaMap()
# Fill up recently used modules set
pyfalog.debug("Fill up recently used modules set")
for itemID in self.sMkt.serviceMarketRecentlyUsedModules["pyfaMarketRecentlyUsedModules"]:
self.recentlyUsedModules.add(self.sMkt.getItem(itemID))
def delaySearch(self, evt):
sFit = Fit.getInstance()
self.searchTimer.Stop()
self.searchTimer.Start(sFit.serviceFittingOptions["marketSearchDelay"], True) # 150ms
def startDrag(self, event):
row = self.GetFirstSelected()
if row != -1:
data = wx.TextDataObject()
dataStr = "market:" + str(self.active[row].ID)
pyfalog.debug("Dragging from market: " + dataStr)
data.SetText(dataStr)
dropSource = wx.DropSource(self)
dropSource.SetData(data)
DragDropHelper.data = dataStr
dropSource.DoDragDrop()
def itemActivated(self, event=None):
# Check if something is selected, if so, spawn the menu for it
sel = self.GetFirstSelected()
if sel == -1:
return
if self.mainFrame.getActiveFit():
self.storeRecentlyUsedMarketItem(self.active[sel].ID)
self.recentlyUsedModules = set()
for itemID in self.sMkt.serviceMarketRecentlyUsedModules["pyfaMarketRecentlyUsedModules"]:
self.recentlyUsedModules.add(self.sMkt.getItem(itemID))
wx.PostEvent(self.mainFrame, ItemSelected(itemID=self.active[sel].ID))
def storeRecentlyUsedMarketItem(self, itemID):
if len(self.sMkt.serviceMarketRecentlyUsedModules["pyfaMarketRecentlyUsedModules"]) > MAX_RECENTLY_USED_MODULES:
self.sMkt.serviceMarketRecentlyUsedModules["pyfaMarketRecentlyUsedModules"].pop(0)
self.sMkt.serviceMarketRecentlyUsedModules["pyfaMarketRecentlyUsedModules"].append(itemID)
def selectionMade(self, event=None):
self.marketBrowser.searchMode = False
# Grab the threeview selection and check if it's fine
sel = self.marketView.GetSelection()
if sel.IsOk():
# Get data field of the selected item (which is a marketGroup ID if anything was selected)
seldata = self.marketView.GetItemData(sel)
if seldata is not None and seldata != RECENTLY_USED_MODULES:
# If market group treeview item doesn't have children (other market groups or dummies),
# then it should have items in it and we want to request them
if self.marketView.ItemHasChildren(sel) is False:
sMkt = self.sMkt
# Get current market group
mg = sMkt.getMarketGroup(seldata, eager=("items", "items.metaGroup"))
# Get all its items
items = sMkt.getItemsByMarketGroup(mg)
else:
items = set()
else:
# If method was called but selection wasn't actually made or we have a hit on recently used modules
if seldata == RECENTLY_USED_MODULES:
items = self.recentlyUsedModules
else:
items = set()
# Fill store
self.updateItemStore(items)
# Set toggle buttons / use search mode flag if recently used modules category is selected (in order to have all modules listed and not filtered)
if seldata is not RECENTLY_USED_MODULES:
self.setToggles()
else:
self.marketBrowser.searchMode = True
self.setToggles()
# Update filtered items
self.filterItemStore()
def updateItemStore(self, items):
self.unfilteredStore = items
def filterItemStore(self):
sMkt = self.sMkt
selectedMetas = set()
for btn in self.marketBrowser.metaButtons:
if btn.GetValue():
selectedMetas.update(sMkt.META_MAP[btn.metaName])
self.filteredStore = sMkt.filterItemsByMeta(self.unfilteredStore, selectedMetas)
self.update(list(self.filteredStore))
def setToggles(self):
metaIDs = set()
sMkt = self.sMkt
for item in self.unfilteredStore:
metaIDs.add(sMkt.getMetaGroupIdByItem(item))
for btn in self.marketBrowser.metaButtons:
btn.reset()
btnMetas = sMkt.META_MAP[btn.metaName]
if len(metaIDs.intersection(btnMetas)) > 0:
btn.setMetaAvailable(True)
else:
btn.setMetaAvailable(False)
def scheduleSearch(self, event=None):
self.searchTimer.Stop() # Cancel any pending timers
search = self.marketBrowser.search.GetLineText(0)
# Make sure we do not count wildcard as search symbol
realsearch = search.replace("*", "")
# Re-select market group if search query has zero length
if len(realsearch) == 0:
self.selectionMade()
return
self.marketBrowser.searchMode = True
self.sMkt.searchItems(search, self.populateSearch)
def clearSearch(self, event=None):
# Wipe item store and update everything to accomodate with it
# If clearSearch was generated by SearchCtrl's Cancel button, clear the content also
if event:
self.marketBrowser.search.Clear()
self.marketBrowser.searchMode = False
self.updateItemStore(set())
self.setToggles()
self.filterItemStore()
def populateSearch(self, items):
# If we're no longer searching, dump the results
if self.marketBrowser.searchMode is False:
return
self.updateItemStore(items)
self.setToggles()
self.filterItemStore()
def itemSort(self, item):
sMkt = self.sMkt
catname = sMkt.getCategoryByItem(item).name
try:
mktgrpid = sMkt.getMarketGroupByItem(item).ID
except AttributeError:
mktgrpid = -1
pyfalog.warning("unable to find market group for {}".format(item.name))
parentname = sMkt.getParentItemByItem(item).name
# Get position of market group
metagrpid = sMkt.getMetaGroupIdByItem(item)
metatab = self.metaMap.get(metagrpid)
metalvl = self.metalvls.get(item.ID, 0)
return catname, mktgrpid, parentname, metatab, metalvl, item.name
def contextMenu(self, event):
# Check if something is selected, if so, spawn the menu for it
sel = self.GetFirstSelected()
if sel == -1:
return
item = self.active[sel]
sMkt = self.sMkt
sourceContext = "marketItemGroup" if self.marketBrowser.searchMode is False else "marketItemMisc"
itemContext = sMkt.getCategoryByItem(item).name
menu = ContextMenu.getMenu((item,), (sourceContext, itemContext))
self.PopupMenu(menu)
def populate(self, items):
if len(items) > 0:
# Get dictionary with meta level attribute
sAttr = Attribute.getInstance()
attrs = sAttr.getAttributeInfo("metaLevel")
sMkt = self.sMkt
self.metalvls = sMkt.directAttrRequest(items, attrs)
# Clear selection
self.deselectItems()
# Perform sorting, using item's meta levels besides other stuff
items.sort(key=self.itemSort)
# Mark current item list as active
self.active = items
# Show them
Display.populate(self, items)
def refresh(self, items):
if len(items) > 1:
# Get dictionary with meta level attribute
sAttr = Attribute.getInstance()
attrs = sAttr.getAttributeInfo("metaLevel")
sMkt = self.sMkt
self.metalvls = sMkt.directAttrRequest(items, attrs)
# Re-sort stuff
items.sort(key=self.itemSort)
for i, item in enumerate(items[:9]):
# set shortcut info for first 9 modules
item.marketShortcut = i + 1
Display.refresh(self, items)
def makeReverseMetaMap(self):
"""
Form map which tells in which tab items of given metagroup are located
"""
revmap = {}
i = 0
for mgids in self.sMkt.META_MAP.values():
for mgid in mgids:
revmap[mgid] = i
i += 1
return revmap
def columnBackground(self, colItem, item):
if self.sFit.serviceFittingOptions["colorFitBySlot"]:
return slotColourMap.get(Module.calculateSlot(item)) or self.GetBackgroundColour()
else:
return self.GetBackgroundColour()
|
gpl-3.0
|
[
646,
4818,
199,
504,
943,
2706,
492,
15996,
199,
199,
504,
325,
736,
14,
8420,
576,
14,
578,
492,
5673,
199,
646,
11621,
14,
5351,
21667,
11930,
14,
9928,
5278,
3532,
465,
428,
3532,
199,
504,
11621,
14,
5351,
21667,
11930,
14,
4368,
492,
7020,
12461,
12,
9141,
63,
9481,
1309,
6084,
63,
8558,
63,
21194,
12,
19461,
1309,
6084,
63,
8558,
63,
21194,
199,
504,
11621,
14,
1100,
5977,
492,
9470,
5977,
199,
504,
11621,
14,
2918,
492,
12175,
199,
504,
11621,
14,
1208,
14,
1986,
4433,
83,
492,
577,
2527,
11070,
4433,
199,
504,
2435,
14,
3215,
492,
3882,
199,
504,
2435,
14,
3269,
492,
25971,
199,
504,
1101,
492,
9348,
15758,
2956,
199,
199,
647,
70,
2548,
275,
15996,
3460,
354,
3368,
421,
199,
533,
7020,
2768,
8,
7687,
304,
272,
6186,
63,
3978,
51,
275,
2097,
1563,
473,
388,
401,
490,
298,
1563,
2812,
401,
490,
298,
962,
26,
5652,
10573,
12,
549,
401,
490,
298,
962,
26,
3541,
10573,
12,
549,
937,
339,
347,
636,
826,
721,
277,
12,
1676,
12,
26584,
11930,
304,
267,
12175,
855,
826,
721,
277,
12,
1676,
9,
267,
1134,
70,
2548,
14,
1757,
480,
9345,
7020,
2768,
531,
267,
26584,
11930,
14,
8198,
8,
6323,
14,
12093,
63,
22841,
63,
899,
44,
63,
21488,
12,
291,
14,
5592,
26973,
9,
398,
291,
14,
324,
11142,
5502,
275,
663,
342,
267,
291,
14,
11142,
5502,
275,
663,
342,
267,
291,
14,
14951,
590,
9167,
17981,
275,
663,
342,
267,
291,
14,
83,
45,
5973,
275,
26584,
11930,
14,
83,
45,
5973,
267,
291,
14,
1733,
1385,
275,
26584,
11930,
14,
1733,
1385,
267,
291,
14,
83,
13776,
275,
25971,
14,
29964,
342,
398,
291,
14,
22270,
11930,
275,
26584,
11930,
267,
291,
14,
22270,
2768,
275,
26584,
11930,
14,
22270,
2768,
398,
327,
2494,
1536,
9715,
367,
7339,
316,
2754,
641,
4036,
662,
8156,
63,
3876,
267,
291,
14,
1733,
7929,
275,
4818,
14,
7929,
8,
277,
9,
267,
291,
14,
8198,
8,
6323,
14,
12093,
63,
29108,
12,
291,
14,
7211,
5278,
12,
291,
14,
1733,
7929,
9,
398,
327,
4155,
3238,
4154,
2754,
5965,
1630,
19604,
8292,
267,
291,
14,
22270,
11930,
14,
1733,
14,
8198,
8,
51,
3532,
14,
12093,
63,
3876,
63,
12533,
12,
291,
14,
7211,
5278,
9,
267,
291,
14,
22270,
11930,
14,
1733,
14,
8198,
8,
51,
3532,
14,
12093,
63,
15962,
63,
19162,
46,
12,
291,
14,
7211,
5278,
9,
267,
291,
14,
22270,
11930,
14,
1733,
14,
8198,
8,
51,
3532,
14,
12093,
63,
20707,
63,
19162,
46,
12,
291,
14,
3584,
5278,
9,
267,
291,
14,
22270,
11930,
14,
1733,
14,
8198,
8,
51,
3532,
14,
12093,
63,
3876,
12,
291,
14,
5814,
5278,
9,
398,
327,
4155,
3238,
644,
37,
886,
19604,
8292,
4634,
267,
291,
14,
8198,
8,
6323,
14,
12093,
63,
9059,
63,
18223,
12,
291,
14,
1100,
5977,
9,
267,
291,
14,
8198,
8,
6323,
14,
12093,
63,
4924,
63,
10439,
63,
20425,
6989,
12,
291,
14,
1053,
13767,
12529,
9,
267,
291,
14,
8198,
8,
6323,
14,
12093,
63,
4924,
63,
15947,
63,
4564,
1254,
12,
291,
14,
928,
20287,
9,
398,
327,
4155,
3837,
2341,
12,
1202,
701,
308,
3968,
267,
291,
14,
2024,
2956,
275,
291,
14,
1875,
14987,
3396,
2956,
342,
398,
327,
24797,
1536,
23568,
1202,
4621,
663,
267,
1134,
70,
2548,
14,
1757,
480,
12914,
1536,
23568,
1202,
4621,
663,
531,
267,
367,
1242,
998,
315,
291,
14,
83,
45,
5973,
14,
1364,
21667,
29574,
590,
9167,
17981,
905,
647,
667,
21667,
29574,
590,
9167,
17981,
6229,
288,
291,
14,
14951,
590,
9167,
17981,
14,
525,
8,
277,
14,
83,
45,
5973,
14,
362,
2081,
8,
1053,
998,
430,
339,
347,
7339,
5278,
8,
277,
12,
16330,
304,
267,
308,
13776,
275,
25971,
14,
29964,
342,
267,
291,
14,
1733,
7929,
14,
6293,
342,
267,
291,
14,
1733,
7929,
14,
3162,
8,
83,
13776,
14,
1364,
13776,
1337,
4558,
905,
22270,
5278,
10796,
2255,
715,
9,
221,
327,
14711,
706,
339,
347,
1343,
20287,
8,
277,
12,
1566,
304,
267,
1962,
275,
291,
14,
1002,
7147,
12461,
342,
398,
340,
1962,
1137,
446,
17,
26,
288,
666,
275,
4818,
14,
1872,
1451,
1692,
342,
288,
666,
2848,
275,
298,
22270,
5424,
435,
620,
8,
277,
14,
2682,
59,
1143,
1055,
998,
9,
288,
1134,
70,
2548,
14,
1757,
480,
20287,
1540,
687,
26584,
26,
298,
435,
666,
2848,
9,
953,
666,
14,
1084,
1872,
8,
576,
2848,
9,
288,
5978,
2980,
275,
4818,
14,
11070,
2980,
8,
277,
9,
288,
5978,
2980,
14,
1084,
1451,
8,
576,
9,
288,
577,
2527,
11070,
4433,
14,
576,
275,
666,
2848,
288,
5978,
2980,
14,
2585,
20287,
11070,
342,
339,
347,
1242,
13767,
12529,
8,
277,
12,
1566,
29,
403,
304,
267,
327,
2670,
340,
6020,
365,
4895,
12,
340,
880,
12,
15187,
314,
6269,
367,
652,
267,
13680,
275,
291,
14,
1002,
7147,
12461,
342,
267,
340,
13680,
508,
446,
17,
26,
288,
372,
398,
340,
291,
14,
973,
3160,
14,
362,
7472,
13776,
837,
953,
291,
14,
1617,
29574,
590,
9167,
21667,
2081,
8,
277,
14,
2682,
59,
5891,
1055,
998,
9,
288,
291,
14,
14951,
590,
9167,
17981,
275,
663,
342,
288,
367,
1242,
998,
315,
291,
14,
83,
45,
5973,
14,
1364,
21667,
29574,
590,
9167,
17981,
905,
647,
667,
21667,
29574,
590,
9167,
17981,
6229,
355,
291,
14,
14951,
590,
9167,
17981,
14,
525,
8,
277,
14,
83,
45,
5973,
14,
362,
2081,
8,
1053,
998,
430,
953,
4818,
14,
6564,
2390,
8,
277,
14,
973,
3160,
12,
7020,
12461,
8,
1053,
998,
29,
277,
14,
2682,
59,
5891,
1055,
998,
430,
339,
347,
3877,
29574,
590,
9167,
21667,
2081,
8,
277,
12,
1242,
998,
304,
267,
340,
822,
8,
277,
14,
83,
45,
5973,
14,
1364,
21667,
29574,
590,
9167,
17981,
905,
647,
667,
21667,
29574,
590,
9167,
17981,
3135,
690,
9141,
63,
9481,
1309,
6084,
63,
8558,
63,
21194,
26,
288,
291,
14,
83,
45,
5973,
14,
1364,
21667,
29574,
590,
9167,
17981,
905,
647,
667,
21667,
29574,
590,
9167,
17981,
4140,
1935,
8,
16,
9,
398,
291,
14,
83
] |
[
4818,
199,
504,
943,
2706,
492,
15996,
199,
199,
504,
325,
736,
14,
8420,
576,
14,
578,
492,
5673,
199,
646,
11621,
14,
5351,
21667,
11930,
14,
9928,
5278,
3532,
465,
428,
3532,
199,
504,
11621,
14,
5351,
21667,
11930,
14,
4368,
492,
7020,
12461,
12,
9141,
63,
9481,
1309,
6084,
63,
8558,
63,
21194,
12,
19461,
1309,
6084,
63,
8558,
63,
21194,
199,
504,
11621,
14,
1100,
5977,
492,
9470,
5977,
199,
504,
11621,
14,
2918,
492,
12175,
199,
504,
11621,
14,
1208,
14,
1986,
4433,
83,
492,
577,
2527,
11070,
4433,
199,
504,
2435,
14,
3215,
492,
3882,
199,
504,
2435,
14,
3269,
492,
25971,
199,
504,
1101,
492,
9348,
15758,
2956,
199,
199,
647,
70,
2548,
275,
15996,
3460,
354,
3368,
421,
199,
533,
7020,
2768,
8,
7687,
304,
272,
6186,
63,
3978,
51,
275,
2097,
1563,
473,
388,
401,
490,
298,
1563,
2812,
401,
490,
298,
962,
26,
5652,
10573,
12,
549,
401,
490,
298,
962,
26,
3541,
10573,
12,
549,
937,
339,
347,
636,
826,
721,
277,
12,
1676,
12,
26584,
11930,
304,
267,
12175,
855,
826,
721,
277,
12,
1676,
9,
267,
1134,
70,
2548,
14,
1757,
480,
9345,
7020,
2768,
531,
267,
26584,
11930,
14,
8198,
8,
6323,
14,
12093,
63,
22841,
63,
899,
44,
63,
21488,
12,
291,
14,
5592,
26973,
9,
398,
291,
14,
324,
11142,
5502,
275,
663,
342,
267,
291,
14,
11142,
5502,
275,
663,
342,
267,
291,
14,
14951,
590,
9167,
17981,
275,
663,
342,
267,
291,
14,
83,
45,
5973,
275,
26584,
11930,
14,
83,
45,
5973,
267,
291,
14,
1733,
1385,
275,
26584,
11930,
14,
1733,
1385,
267,
291,
14,
83,
13776,
275,
25971,
14,
29964,
342,
398,
291,
14,
22270,
11930,
275,
26584,
11930,
267,
291,
14,
22270,
2768,
275,
26584,
11930,
14,
22270,
2768,
398,
327,
2494,
1536,
9715,
367,
7339,
316,
2754,
641,
4036,
662,
8156,
63,
3876,
267,
291,
14,
1733,
7929,
275,
4818,
14,
7929,
8,
277,
9,
267,
291,
14,
8198,
8,
6323,
14,
12093,
63,
29108,
12,
291,
14,
7211,
5278,
12,
291,
14,
1733,
7929,
9,
398,
327,
4155,
3238,
4154,
2754,
5965,
1630,
19604,
8292,
267,
291,
14,
22270,
11930,
14,
1733,
14,
8198,
8,
51,
3532,
14,
12093,
63,
3876,
63,
12533,
12,
291,
14,
7211,
5278,
9,
267,
291,
14,
22270,
11930,
14,
1733,
14,
8198,
8,
51,
3532,
14,
12093,
63,
15962,
63,
19162,
46,
12,
291,
14,
7211,
5278,
9,
267,
291,
14,
22270,
11930,
14,
1733,
14,
8198,
8,
51,
3532,
14,
12093,
63,
20707,
63,
19162,
46,
12,
291,
14,
3584,
5278,
9,
267,
291,
14,
22270,
11930,
14,
1733,
14,
8198,
8,
51,
3532,
14,
12093,
63,
3876,
12,
291,
14,
5814,
5278,
9,
398,
327,
4155,
3238,
644,
37,
886,
19604,
8292,
4634,
267,
291,
14,
8198,
8,
6323,
14,
12093,
63,
9059,
63,
18223,
12,
291,
14,
1100,
5977,
9,
267,
291,
14,
8198,
8,
6323,
14,
12093,
63,
4924,
63,
10439,
63,
20425,
6989,
12,
291,
14,
1053,
13767,
12529,
9,
267,
291,
14,
8198,
8,
6323,
14,
12093,
63,
4924,
63,
15947,
63,
4564,
1254,
12,
291,
14,
928,
20287,
9,
398,
327,
4155,
3837,
2341,
12,
1202,
701,
308,
3968,
267,
291,
14,
2024,
2956,
275,
291,
14,
1875,
14987,
3396,
2956,
342,
398,
327,
24797,
1536,
23568,
1202,
4621,
663,
267,
1134,
70,
2548,
14,
1757,
480,
12914,
1536,
23568,
1202,
4621,
663,
531,
267,
367,
1242,
998,
315,
291,
14,
83,
45,
5973,
14,
1364,
21667,
29574,
590,
9167,
17981,
905,
647,
667,
21667,
29574,
590,
9167,
17981,
6229,
288,
291,
14,
14951,
590,
9167,
17981,
14,
525,
8,
277,
14,
83,
45,
5973,
14,
362,
2081,
8,
1053,
998,
430,
339,
347,
7339,
5278,
8,
277,
12,
16330,
304,
267,
308,
13776,
275,
25971,
14,
29964,
342,
267,
291,
14,
1733,
7929,
14,
6293,
342,
267,
291,
14,
1733,
7929,
14,
3162,
8,
83,
13776,
14,
1364,
13776,
1337,
4558,
905,
22270,
5278,
10796,
2255,
715,
9,
221,
327,
14711,
706,
339,
347,
1343,
20287,
8,
277,
12,
1566,
304,
267,
1962,
275,
291,
14,
1002,
7147,
12461,
342,
398,
340,
1962,
1137,
446,
17,
26,
288,
666,
275,
4818,
14,
1872,
1451,
1692,
342,
288,
666,
2848,
275,
298,
22270,
5424,
435,
620,
8,
277,
14,
2682,
59,
1143,
1055,
998,
9,
288,
1134,
70,
2548,
14,
1757,
480,
20287,
1540,
687,
26584,
26,
298,
435,
666,
2848,
9,
953,
666,
14,
1084,
1872,
8,
576,
2848,
9,
288,
5978,
2980,
275,
4818,
14,
11070,
2980,
8,
277,
9,
288,
5978,
2980,
14,
1084,
1451,
8,
576,
9,
288,
577,
2527,
11070,
4433,
14,
576,
275,
666,
2848,
288,
5978,
2980,
14,
2585,
20287,
11070,
342,
339,
347,
1242,
13767,
12529,
8,
277,
12,
1566,
29,
403,
304,
267,
327,
2670,
340,
6020,
365,
4895,
12,
340,
880,
12,
15187,
314,
6269,
367,
652,
267,
13680,
275,
291,
14,
1002,
7147,
12461,
342,
267,
340,
13680,
508,
446,
17,
26,
288,
372,
398,
340,
291,
14,
973,
3160,
14,
362,
7472,
13776,
837,
953,
291,
14,
1617,
29574,
590,
9167,
21667,
2081,
8,
277,
14,
2682,
59,
5891,
1055,
998,
9,
288,
291,
14,
14951,
590,
9167,
17981,
275,
663,
342,
288,
367,
1242,
998,
315,
291,
14,
83,
45,
5973,
14,
1364,
21667,
29574,
590,
9167,
17981,
905,
647,
667,
21667,
29574,
590,
9167,
17981,
6229,
355,
291,
14,
14951,
590,
9167,
17981,
14,
525,
8,
277,
14,
83,
45,
5973,
14,
362,
2081,
8,
1053,
998,
430,
953,
4818,
14,
6564,
2390,
8,
277,
14,
973,
3160,
12,
7020,
12461,
8,
1053,
998,
29,
277,
14,
2682,
59,
5891,
1055,
998,
430,
339,
347,
3877,
29574,
590,
9167,
21667,
2081,
8,
277,
12,
1242,
998,
304,
267,
340,
822,
8,
277,
14,
83,
45,
5973,
14,
1364,
21667,
29574,
590,
9167,
17981,
905,
647,
667,
21667,
29574,
590,
9167,
17981,
3135,
690,
9141,
63,
9481,
1309,
6084,
63,
8558,
63,
21194,
26,
288,
291,
14,
83,
45,
5973,
14,
1364,
21667,
29574,
590,
9167,
17981,
905,
647,
667,
21667,
29574,
590,
9167,
17981,
4140,
1935,
8,
16,
9,
398,
291,
14,
83,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
Shanec132006/Lab4
|
lib/jinja2/ext.py
|
603
|
25078
|
# -*- coding: utf-8 -*-
"""
jinja2.ext
~~~~~~~~~~
Jinja extensions allow to add custom tags similar to the way django custom
tags work. By default two example extensions exist: an i18n and a cache
extension.
:copyright: (c) 2010 by the Jinja Team.
:license: BSD.
"""
from jinja2 import nodes
from jinja2.defaults import BLOCK_START_STRING, \
BLOCK_END_STRING, VARIABLE_START_STRING, VARIABLE_END_STRING, \
COMMENT_START_STRING, COMMENT_END_STRING, LINE_STATEMENT_PREFIX, \
LINE_COMMENT_PREFIX, TRIM_BLOCKS, NEWLINE_SEQUENCE, \
KEEP_TRAILING_NEWLINE, LSTRIP_BLOCKS
from jinja2.environment import Environment
from jinja2.runtime import concat
from jinja2.exceptions import TemplateAssertionError, TemplateSyntaxError
from jinja2.utils import contextfunction, import_string, Markup
from jinja2._compat import next, with_metaclass, string_types, iteritems
# the only real useful gettext functions for a Jinja template. Note
# that ugettext must be assigned to gettext as Jinja doesn't support
# non unicode strings.
GETTEXT_FUNCTIONS = ('_', 'gettext', 'ngettext')
class ExtensionRegistry(type):
"""Gives the extension an unique identifier."""
def __new__(cls, name, bases, d):
rv = type.__new__(cls, name, bases, d)
rv.identifier = rv.__module__ + '.' + rv.__name__
return rv
class Extension(with_metaclass(ExtensionRegistry, object)):
"""Extensions can be used to add extra functionality to the Jinja template
system at the parser level. Custom extensions are bound to an environment
but may not store environment specific data on `self`. The reason for
this is that an extension can be bound to another environment (for
overlays) by creating a copy and reassigning the `environment` attribute.
As extensions are created by the environment they cannot accept any
arguments for configuration. One may want to work around that by using
a factory function, but that is not possible as extensions are identified
by their import name. The correct way to configure the extension is
storing the configuration values on the environment. Because this way the
environment ends up acting as central configuration storage the
attributes may clash which is why extensions have to ensure that the names
they choose for configuration are not too generic. ``prefix`` for example
is a terrible name, ``fragment_cache_prefix`` on the other hand is a good
name as includes the name of the extension (fragment cache).
"""
#: if this extension parses this is the list of tags it's listening to.
tags = set()
#: the priority of that extension. This is especially useful for
#: extensions that preprocess values. A lower value means higher
#: priority.
#:
#: .. versionadded:: 2.4
priority = 100
def __init__(self, environment):
self.environment = environment
def bind(self, environment):
"""Create a copy of this extension bound to another environment."""
rv = object.__new__(self.__class__)
rv.__dict__.update(self.__dict__)
rv.environment = environment
return rv
def preprocess(self, source, name, filename=None):
"""This method is called before the actual lexing and can be used to
preprocess the source. The `filename` is optional. The return value
must be the preprocessed source.
"""
return source
def filter_stream(self, stream):
"""It's passed a :class:`~jinja2.lexer.TokenStream` that can be used
to filter tokens returned. This method has to return an iterable of
:class:`~jinja2.lexer.Token`\s, but it doesn't have to return a
:class:`~jinja2.lexer.TokenStream`.
In the `ext` folder of the Jinja2 source distribution there is a file
called `inlinegettext.py` which implements a filter that utilizes this
method.
"""
return stream
def parse(self, parser):
"""If any of the :attr:`tags` matched this method is called with the
parser as first argument. The token the parser stream is pointing at
is the name token that matched. This method has to return one or a
list of multiple nodes.
"""
raise NotImplementedError()
def attr(self, name, lineno=None):
"""Return an attribute node for the current extension. This is useful
to pass constants on extensions to generated template code.
::
self.attr('_my_attribute', lineno=lineno)
"""
return nodes.ExtensionAttribute(self.identifier, name, lineno=lineno)
def call_method(self, name, args=None, kwargs=None, dyn_args=None,
dyn_kwargs=None, lineno=None):
"""Call a method of the extension. This is a shortcut for
:meth:`attr` + :class:`jinja2.nodes.Call`.
"""
if args is None:
args = []
if kwargs is None:
kwargs = []
return nodes.Call(self.attr(name, lineno=lineno), args, kwargs,
dyn_args, dyn_kwargs, lineno=lineno)
@contextfunction
def _gettext_alias(__context, *args, **kwargs):
return __context.call(__context.resolve('gettext'), *args, **kwargs)
def _make_new_gettext(func):
@contextfunction
def gettext(__context, __string, **variables):
rv = __context.call(func, __string)
if __context.eval_ctx.autoescape:
rv = Markup(rv)
return rv % variables
return gettext
def _make_new_ngettext(func):
@contextfunction
def ngettext(__context, __singular, __plural, __num, **variables):
variables.setdefault('num', __num)
rv = __context.call(func, __singular, __plural, __num)
if __context.eval_ctx.autoescape:
rv = Markup(rv)
return rv % variables
return ngettext
class InternationalizationExtension(Extension):
"""This extension adds gettext support to Jinja2."""
tags = set(['trans'])
# TODO: the i18n extension is currently reevaluating values in a few
# situations. Take this example:
# {% trans count=something() %}{{ count }} foo{% pluralize
# %}{{ count }} fooss{% endtrans %}
# something is called twice here. One time for the gettext value and
# the other time for the n-parameter of the ngettext function.
def __init__(self, environment):
Extension.__init__(self, environment)
environment.globals['_'] = _gettext_alias
environment.extend(
install_gettext_translations=self._install,
install_null_translations=self._install_null,
install_gettext_callables=self._install_callables,
uninstall_gettext_translations=self._uninstall,
extract_translations=self._extract,
newstyle_gettext=False
)
def _install(self, translations, newstyle=None):
gettext = getattr(translations, 'ugettext', None)
if gettext is None:
gettext = translations.gettext
ngettext = getattr(translations, 'ungettext', None)
if ngettext is None:
ngettext = translations.ngettext
self._install_callables(gettext, ngettext, newstyle)
def _install_null(self, newstyle=None):
self._install_callables(
lambda x: x,
lambda s, p, n: (n != 1 and (p,) or (s,))[0],
newstyle
)
def _install_callables(self, gettext, ngettext, newstyle=None):
if newstyle is not None:
self.environment.newstyle_gettext = newstyle
if self.environment.newstyle_gettext:
gettext = _make_new_gettext(gettext)
ngettext = _make_new_ngettext(ngettext)
self.environment.globals.update(
gettext=gettext,
ngettext=ngettext
)
def _uninstall(self, translations):
for key in 'gettext', 'ngettext':
self.environment.globals.pop(key, None)
def _extract(self, source, gettext_functions=GETTEXT_FUNCTIONS):
if isinstance(source, string_types):
source = self.environment.parse(source)
return extract_from_ast(source, gettext_functions)
def parse(self, parser):
"""Parse a translatable tag."""
lineno = next(parser.stream).lineno
num_called_num = False
# find all the variables referenced. Additionally a variable can be
# defined in the body of the trans block too, but this is checked at
# a later state.
plural_expr = None
plural_expr_assignment = None
variables = {}
while parser.stream.current.type != 'block_end':
if variables:
parser.stream.expect('comma')
# skip colon for python compatibility
if parser.stream.skip_if('colon'):
break
name = parser.stream.expect('name')
if name.value in variables:
parser.fail('translatable variable %r defined twice.' %
name.value, name.lineno,
exc=TemplateAssertionError)
# expressions
if parser.stream.current.type == 'assign':
next(parser.stream)
variables[name.value] = var = parser.parse_expression()
else:
variables[name.value] = var = nodes.Name(name.value, 'load')
if plural_expr is None:
if isinstance(var, nodes.Call):
plural_expr = nodes.Name('_trans', 'load')
variables[name.value] = plural_expr
plural_expr_assignment = nodes.Assign(
nodes.Name('_trans', 'store'), var)
else:
plural_expr = var
num_called_num = name.value == 'num'
parser.stream.expect('block_end')
plural = plural_names = None
have_plural = False
referenced = set()
# now parse until endtrans or pluralize
singular_names, singular = self._parse_block(parser, True)
if singular_names:
referenced.update(singular_names)
if plural_expr is None:
plural_expr = nodes.Name(singular_names[0], 'load')
num_called_num = singular_names[0] == 'num'
# if we have a pluralize block, we parse that too
if parser.stream.current.test('name:pluralize'):
have_plural = True
next(parser.stream)
if parser.stream.current.type != 'block_end':
name = parser.stream.expect('name')
if name.value not in variables:
parser.fail('unknown variable %r for pluralization' %
name.value, name.lineno,
exc=TemplateAssertionError)
plural_expr = variables[name.value]
num_called_num = name.value == 'num'
parser.stream.expect('block_end')
plural_names, plural = self._parse_block(parser, False)
next(parser.stream)
referenced.update(plural_names)
else:
next(parser.stream)
# register free names as simple name expressions
for var in referenced:
if var not in variables:
variables[var] = nodes.Name(var, 'load')
if not have_plural:
plural_expr = None
elif plural_expr is None:
parser.fail('pluralize without variables', lineno)
node = self._make_node(singular, plural, variables, plural_expr,
bool(referenced),
num_called_num and have_plural)
node.set_lineno(lineno)
if plural_expr_assignment is not None:
return [plural_expr_assignment, node]
else:
return node
def _parse_block(self, parser, allow_pluralize):
"""Parse until the next block tag with a given name."""
referenced = []
buf = []
while 1:
if parser.stream.current.type == 'data':
buf.append(parser.stream.current.value.replace('%', '%%'))
next(parser.stream)
elif parser.stream.current.type == 'variable_begin':
next(parser.stream)
name = parser.stream.expect('name').value
referenced.append(name)
buf.append('%%(%s)s' % name)
parser.stream.expect('variable_end')
elif parser.stream.current.type == 'block_begin':
next(parser.stream)
if parser.stream.current.test('name:endtrans'):
break
elif parser.stream.current.test('name:pluralize'):
if allow_pluralize:
break
parser.fail('a translatable section can have only one '
'pluralize section')
parser.fail('control structures in translatable sections are '
'not allowed')
elif parser.stream.eos:
parser.fail('unclosed translation block')
else:
assert False, 'internal parser error'
return referenced, concat(buf)
def _make_node(self, singular, plural, variables, plural_expr,
vars_referenced, num_called_num):
"""Generates a useful node from the data provided."""
# no variables referenced? no need to escape for old style
# gettext invocations only if there are vars.
if not vars_referenced and not self.environment.newstyle_gettext:
singular = singular.replace('%%', '%')
if plural:
plural = plural.replace('%%', '%')
# singular only:
if plural_expr is None:
gettext = nodes.Name('gettext', 'load')
node = nodes.Call(gettext, [nodes.Const(singular)],
[], None, None)
# singular and plural
else:
ngettext = nodes.Name('ngettext', 'load')
node = nodes.Call(ngettext, [
nodes.Const(singular),
nodes.Const(plural),
plural_expr
], [], None, None)
# in case newstyle gettext is used, the method is powerful
# enough to handle the variable expansion and autoescape
# handling itself
if self.environment.newstyle_gettext:
for key, value in iteritems(variables):
# the function adds that later anyways in case num was
# called num, so just skip it.
if num_called_num and key == 'num':
continue
node.kwargs.append(nodes.Keyword(key, value))
# otherwise do that here
else:
# mark the return value as safe if we are in an
# environment with autoescaping turned on
node = nodes.MarkSafeIfAutoescape(node)
if variables:
node = nodes.Mod(node, nodes.Dict([
nodes.Pair(nodes.Const(key), value)
for key, value in variables.items()
]))
return nodes.Output([node])
class ExprStmtExtension(Extension):
"""Adds a `do` tag to Jinja2 that works like the print statement just
that it doesn't print the return value.
"""
tags = set(['do'])
def parse(self, parser):
node = nodes.ExprStmt(lineno=next(parser.stream).lineno)
node.node = parser.parse_tuple()
return node
class LoopControlExtension(Extension):
"""Adds break and continue to the template engine."""
tags = set(['break', 'continue'])
def parse(self, parser):
token = next(parser.stream)
if token.value == 'break':
return nodes.Break(lineno=token.lineno)
return nodes.Continue(lineno=token.lineno)
class WithExtension(Extension):
"""Adds support for a django-like with block."""
tags = set(['with'])
def parse(self, parser):
node = nodes.Scope(lineno=next(parser.stream).lineno)
assignments = []
while parser.stream.current.type != 'block_end':
lineno = parser.stream.current.lineno
if assignments:
parser.stream.expect('comma')
target = parser.parse_assign_target()
parser.stream.expect('assign')
expr = parser.parse_expression()
assignments.append(nodes.Assign(target, expr, lineno=lineno))
node.body = assignments + \
list(parser.parse_statements(('name:endwith',),
drop_needle=True))
return node
class AutoEscapeExtension(Extension):
"""Changes auto escape rules for a scope."""
tags = set(['autoescape'])
def parse(self, parser):
node = nodes.ScopedEvalContextModifier(lineno=next(parser.stream).lineno)
node.options = [
nodes.Keyword('autoescape', parser.parse_expression())
]
node.body = parser.parse_statements(('name:endautoescape',),
drop_needle=True)
return nodes.Scope([node])
def extract_from_ast(node, gettext_functions=GETTEXT_FUNCTIONS,
babel_style=True):
"""Extract localizable strings from the given template node. Per
default this function returns matches in babel style that means non string
parameters as well as keyword arguments are returned as `None`. This
allows Babel to figure out what you really meant if you are using
gettext functions that allow keyword arguments for placeholder expansion.
If you don't want that behavior set the `babel_style` parameter to `False`
which causes only strings to be returned and parameters are always stored
in tuples. As a consequence invalid gettext calls (calls without a single
string parameter or string parameters after non-string parameters) are
skipped.
This example explains the behavior:
>>> from jinja2 import Environment
>>> env = Environment()
>>> node = env.parse('{{ (_("foo"), _(), ngettext("foo", "bar", 42)) }}')
>>> list(extract_from_ast(node))
[(1, '_', 'foo'), (1, '_', ()), (1, 'ngettext', ('foo', 'bar', None))]
>>> list(extract_from_ast(node, babel_style=False))
[(1, '_', ('foo',)), (1, 'ngettext', ('foo', 'bar'))]
For every string found this function yields a ``(lineno, function,
message)`` tuple, where:
* ``lineno`` is the number of the line on which the string was found,
* ``function`` is the name of the ``gettext`` function used (if the
string was extracted from embedded Python code), and
* ``message`` is the string itself (a ``unicode`` object, or a tuple
of ``unicode`` objects for functions with multiple string arguments).
This extraction function operates on the AST and is because of that unable
to extract any comments. For comment support you have to use the babel
extraction interface or extract comments yourself.
"""
for node in node.find_all(nodes.Call):
if not isinstance(node.node, nodes.Name) or \
node.node.name not in gettext_functions:
continue
strings = []
for arg in node.args:
if isinstance(arg, nodes.Const) and \
isinstance(arg.value, string_types):
strings.append(arg.value)
else:
strings.append(None)
for arg in node.kwargs:
strings.append(None)
if node.dyn_args is not None:
strings.append(None)
if node.dyn_kwargs is not None:
strings.append(None)
if not babel_style:
strings = tuple(x for x in strings if x is not None)
if not strings:
continue
else:
if len(strings) == 1:
strings = strings[0]
else:
strings = tuple(strings)
yield node.lineno, node.node.name, strings
class _CommentFinder(object):
"""Helper class to find comments in a token stream. Can only
find comments for gettext calls forwards. Once the comment
from line 4 is found, a comment for line 1 will not return a
usable value.
"""
def __init__(self, tokens, comment_tags):
self.tokens = tokens
self.comment_tags = comment_tags
self.offset = 0
self.last_lineno = 0
def find_backwards(self, offset):
try:
for _, token_type, token_value in \
reversed(self.tokens[self.offset:offset]):
if token_type in ('comment', 'linecomment'):
try:
prefix, comment = token_value.split(None, 1)
except ValueError:
continue
if prefix in self.comment_tags:
return [comment.rstrip()]
return []
finally:
self.offset = offset
def find_comments(self, lineno):
if not self.comment_tags or self.last_lineno > lineno:
return []
for idx, (token_lineno, _, _) in enumerate(self.tokens[self.offset:]):
if token_lineno > lineno:
return self.find_backwards(self.offset + idx)
return self.find_backwards(len(self.tokens))
def babel_extract(fileobj, keywords, comment_tags, options):
"""Babel extraction method for Jinja templates.
.. versionchanged:: 2.3
Basic support for translation comments was added. If `comment_tags`
is now set to a list of keywords for extraction, the extractor will
try to find the best preceeding comment that begins with one of the
keywords. For best results, make sure to not have more than one
gettext call in one line of code and the matching comment in the
same line or the line before.
.. versionchanged:: 2.5.1
The `newstyle_gettext` flag can be set to `True` to enable newstyle
gettext calls.
.. versionchanged:: 2.7
A `silent` option can now be provided. If set to `False` template
syntax errors are propagated instead of being ignored.
:param fileobj: the file-like object the messages should be extracted from
:param keywords: a list of keywords (i.e. function names) that should be
recognized as translation functions
:param comment_tags: a list of translator tags to search for and include
in the results.
:param options: a dictionary of additional options (optional)
:return: an iterator over ``(lineno, funcname, message, comments)`` tuples.
(comments will be empty currently)
"""
extensions = set()
for extension in options.get('extensions', '').split(','):
extension = extension.strip()
if not extension:
continue
extensions.add(import_string(extension))
if InternationalizationExtension not in extensions:
extensions.add(InternationalizationExtension)
def getbool(options, key, default=False):
return options.get(key, str(default)).lower() in \
('1', 'on', 'yes', 'true')
silent = getbool(options, 'silent', True)
environment = Environment(
options.get('block_start_string', BLOCK_START_STRING),
options.get('block_end_string', BLOCK_END_STRING),
options.get('variable_start_string', VARIABLE_START_STRING),
options.get('variable_end_string', VARIABLE_END_STRING),
options.get('comment_start_string', COMMENT_START_STRING),
options.get('comment_end_string', COMMENT_END_STRING),
options.get('line_statement_prefix') or LINE_STATEMENT_PREFIX,
options.get('line_comment_prefix') or LINE_COMMENT_PREFIX,
getbool(options, 'trim_blocks', TRIM_BLOCKS),
getbool(options, 'lstrip_blocks', LSTRIP_BLOCKS),
NEWLINE_SEQUENCE,
getbool(options, 'keep_trailing_newline', KEEP_TRAILING_NEWLINE),
frozenset(extensions),
cache_size=0,
auto_reload=False
)
if getbool(options, 'newstyle_gettext'):
environment.newstyle_gettext = True
source = fileobj.read().decode(options.get('encoding', 'utf-8'))
try:
node = environment.parse(source)
tokens = list(environment.lex(environment.preprocess(source)))
except TemplateSyntaxError as e:
if not silent:
raise
# skip templates with syntax errors
return
finder = _CommentFinder(tokens, comment_tags)
for lineno, func, message in extract_from_ast(node, keywords):
yield lineno, func, message, finder.find_comments(lineno)
#: nicer import names
i18n = InternationalizationExtension
do = ExprStmtExtension
loopcontrols = LoopControlExtension
with_ = WithExtension
autoescape = AutoEscapeExtension
|
apache-2.0
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
624,
272,
10321,
18,
14,
832,
272,
221,
4919,
1714,
339,
17300,
5478,
2040,
370,
1050,
3537,
3762,
8545,
370,
314,
4340,
1639,
3537,
272,
3762,
1736,
14,
221,
4885,
849,
2877,
2893,
5478,
2187,
26,
376,
284,
1085,
78,
436,
282,
2581,
272,
3329,
14,
339,
520,
7307,
26,
334,
67,
9,
7129,
701,
314,
17300,
11682,
14,
272,
520,
1682,
26,
6289,
14,
199,
624,
199,
504,
10321,
18,
492,
3380,
199,
504,
10321,
18,
14,
4322,
492,
8068,
63,
7363,
63,
5353,
12,
971,
1362,
8068,
63,
3902,
63,
5353,
12,
30098,
2617,
63,
7363,
63,
5353,
12,
30098,
2617,
63,
3902,
63,
5353,
12,
971,
1362,
25071,
63,
7363,
63,
5353,
12,
25071,
63,
3902,
63,
5353,
12,
13587,
63,
6689,
4479,
63,
6351,
12,
971,
1362,
13587,
63,
10973,
63,
6351,
12,
9074,
1469,
63,
8475,
51,
12,
18689,
6174,
63,
16585,
12,
971,
1362,
1804,
37,
6102,
63,
1766,
6593,
1206,
63,
28758,
12,
491,
31296,
63,
8475,
51,
199,
504,
10321,
18,
14,
5418,
492,
9711,
199,
504,
10321,
18,
14,
7726,
492,
17159,
199,
504,
10321,
18,
14,
3924,
492,
5458,
14844,
12,
17762,
199,
504,
10321,
18,
14,
1208,
492,
1067,
1593,
12,
492,
63,
875,
12,
17504,
199,
504,
10321,
18,
423,
5819,
492,
2163,
12,
543,
63,
6577,
12,
1059,
63,
1313,
12,
10849,
421,
199,
3,
314,
1454,
3363,
2997,
9796,
3423,
367,
282,
17300,
1978,
14,
221,
3390,
199,
3,
626,
10366,
1471,
506,
7943,
370,
9796,
465,
17300,
3181,
1133,
2291,
199,
3,
2222,
2649,
3326,
14,
199,
2970,
3876,
63,
29865,
275,
12331,
297,
283,
5152,
297,
283,
28234,
358,
421,
199,
533,
13282,
10899,
8,
466,
304,
272,
408,
39,
7602,
314,
3329,
376,
3747,
5148,
1041,
339,
347,
636,
1222,
721,
1886,
12,
536,
12,
9768,
12,
366,
304,
267,
4336,
275,
730,
855,
1222,
721,
1886,
12,
536,
12,
9768,
12,
366,
9,
267,
4336,
14,
5364,
275,
4336,
855,
578,
363,
435,
7815,
435,
4336,
855,
354,
363,
267,
372,
4336,
421,
199,
533,
13282,
8,
1045,
63,
6577,
8,
6382,
10899,
12,
909,
2298,
272,
408,
10597,
883,
506,
1202,
370,
1050,
2402,
9330,
370,
314,
17300,
1978,
272,
2656,
737,
314,
1798,
2166,
14,
221,
8388,
5478,
787,
3914,
370,
376,
3734,
272,
1325,
1443,
440,
3877,
3734,
2488,
666,
641,
658,
277,
2313,
221,
710,
4499,
367,
272,
642,
365,
626,
376,
3329,
883,
506,
3914,
370,
4573,
3734,
334,
509,
272,
1806,
9316,
9,
701,
6425,
282,
1331,
436,
295,
5038,
316,
314,
658,
5418,
64,
2225,
14,
339,
3709,
5478,
787,
2737,
701,
314,
3734,
2985,
3913,
4729,
1263,
272,
2368,
367,
2897,
14,
221,
7309,
1443,
2934,
370,
1736,
6818,
626,
701,
1808,
272,
282,
6434,
805,
12,
1325,
626,
365,
440,
3962,
465,
5478,
787,
15836,
272,
701,
3932,
492,
536,
14,
221,
710,
3211,
4340,
370,
7908,
314,
3329,
365,
272,
16915,
314,
2897,
1338,
641,
314,
3734,
14,
221,
13821,
642,
4340,
314,
272,
3734,
11187,
1536,
2454,
316,
465,
18796,
2897,
4887,
314,
272,
3004,
1443,
30109,
1314,
365,
10842,
5478,
1172,
370,
4868,
626,
314,
1561,
272,
2985,
11496,
367,
2897,
787,
440,
4634,
7809,
14,
221,
1124,
1861,
1040,
367,
2893,
272,
365,
282,
2044,
322,
830,
536,
12,
1124,
7677,
63,
1637,
63,
1861,
1040,
641,
314,
1163,
4926,
365,
282,
6954,
272,
536,
465,
6952,
314,
536,
402,
314,
3329,
334,
7677,
2581,
680,
272,
408,
339,
6079,
340,
642,
3329,
19953,
642,
365,
314,
769,
402,
3762,
652,
1159,
22721,
370,
14,
272,
3762,
275,
663,
342,
339,
6079,
314,
7464,
402,
626,
3329,
14,
221,
961,
365,
24002,
2997,
367,
272,
6079,
5478,
626,
23351,
1338,
14,
221,
437,
5117,
574,
4910,
10948,
272,
6079,
7464,
14,
272,
6079,
272,
6079,
2508,
7445,
447,
499,
14,
20,
272,
7464,
275,
2948,
339,
347,
636,
826,
721,
277,
12,
3734,
304,
267,
291,
14,
5418,
275,
3734,
339,
347,
5398,
8,
277,
12,
3734,
304,
267,
408,
2499,
282,
1331,
402,
642,
3329,
3914,
370,
4573,
3734,
1041,
267,
4336,
275,
909,
855,
1222,
721,
277,
855,
533,
3368,
267,
4336,
855,
807,
4343,
873,
8,
277,
855,
807,
3368,
267,
4336,
14,
5418,
275,
3734,
267,
372,
4336,
339,
347,
23351,
8,
277,
12,
1350,
12,
536,
12,
1788,
29,
403,
304,
267,
408,
2765,
1083,
365,
2797,
2544,
314,
3503,
7103,
316,
436,
883,
506,
1202,
370,
267,
23351,
314,
1350,
14,
221,
710,
658,
1501,
64,
365,
2716,
14,
221,
710,
372,
574,
267,
1471,
506,
314,
876,
7292,
1350,
14,
267,
408,
267,
372,
1350,
339,
347,
2457,
63,
1745,
8,
277,
12,
2547,
304,
267,
408,
7940,
1159,
3032,
282,
520,
533,
6054,
12264,
18,
14,
11729,
14,
3264,
3296,
64,
626,
883,
506,
1202,
267,
370,
2457,
4645,
2138,
14,
221,
961,
1083,
965,
370,
372,
376,
6076,
402,
267,
520,
533,
6054,
12264,
18,
14,
11729,
14,
3264,
25502,
83,
12,
1325,
652,
3181,
1133,
1172,
370,
372,
282,
267,
520,
533,
6054,
12264,
18,
14,
11729,
14,
3264,
3296,
2313,
398,
1010,
314,
658,
832,
64,
4922,
402,
314,
17300,
18,
1350,
4084,
2337,
365,
282,
570,
267,
2797,
658,
6460,
5152,
14,
647,
64,
1314,
9031,
282,
2457,
626,
7678,
19030,
397,
642,
267,
1083,
14,
267,
408,
267,
372,
2547,
339,
347,
2198,
8,
277,
12,
1798,
304,
267,
408,
3917,
1263,
402,
314,
520,
962,
1705,
2969,
64,
7838,
642,
1083,
365,
2797,
543,
314,
267,
1798,
465,
1642,
1423,
14,
221,
710,
1526,
314,
1798,
2547,
365,
20686,
737,
267,
365,
314,
536,
1526,
626,
7838,
14,
221,
961,
1083,
965,
370,
372,
1373,
503,
282,
267,
769,
402,
3663,
3380,
14,
267,
408,
267,
746,
4279,
342,
339,
347,
1921,
8,
277,
12,
536,
12,
5874,
29,
403,
304,
267,
408,
1767,
376,
2225,
1031,
367,
314,
1453,
3329,
14,
221,
961,
365,
2997,
267,
370,
986,
5262,
641,
5478,
370,
4046,
1978,
1233,
14,
398,
3800,
953,
291,
14,
962,
6412,
1662,
63,
3215,
297,
5874,
29
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
624,
272,
10321,
18,
14,
832,
272,
221,
4919,
1714,
339,
17300,
5478,
2040,
370,
1050,
3537,
3762,
8545,
370,
314,
4340,
1639,
3537,
272,
3762,
1736,
14,
221,
4885,
849,
2877,
2893,
5478,
2187,
26,
376,
284,
1085,
78,
436,
282,
2581,
272,
3329,
14,
339,
520,
7307,
26,
334,
67,
9,
7129,
701,
314,
17300,
11682,
14,
272,
520,
1682,
26,
6289,
14,
199,
624,
199,
504,
10321,
18,
492,
3380,
199,
504,
10321,
18,
14,
4322,
492,
8068,
63,
7363,
63,
5353,
12,
971,
1362,
8068,
63,
3902,
63,
5353,
12,
30098,
2617,
63,
7363,
63,
5353,
12,
30098,
2617,
63,
3902,
63,
5353,
12,
971,
1362,
25071,
63,
7363,
63,
5353,
12,
25071,
63,
3902,
63,
5353,
12,
13587,
63,
6689,
4479,
63,
6351,
12,
971,
1362,
13587,
63,
10973,
63,
6351,
12,
9074,
1469,
63,
8475,
51,
12,
18689,
6174,
63,
16585,
12,
971,
1362,
1804,
37,
6102,
63,
1766,
6593,
1206,
63,
28758,
12,
491,
31296,
63,
8475,
51,
199,
504,
10321,
18,
14,
5418,
492,
9711,
199,
504,
10321,
18,
14,
7726,
492,
17159,
199,
504,
10321,
18,
14,
3924,
492,
5458,
14844,
12,
17762,
199,
504,
10321,
18,
14,
1208,
492,
1067,
1593,
12,
492,
63,
875,
12,
17504,
199,
504,
10321,
18,
423,
5819,
492,
2163,
12,
543,
63,
6577,
12,
1059,
63,
1313,
12,
10849,
421,
199,
3,
314,
1454,
3363,
2997,
9796,
3423,
367,
282,
17300,
1978,
14,
221,
3390,
199,
3,
626,
10366,
1471,
506,
7943,
370,
9796,
465,
17300,
3181,
1133,
2291,
199,
3,
2222,
2649,
3326,
14,
199,
2970,
3876,
63,
29865,
275,
12331,
297,
283,
5152,
297,
283,
28234,
358,
421,
199,
533,
13282,
10899,
8,
466,
304,
272,
408,
39,
7602,
314,
3329,
376,
3747,
5148,
1041,
339,
347,
636,
1222,
721,
1886,
12,
536,
12,
9768,
12,
366,
304,
267,
4336,
275,
730,
855,
1222,
721,
1886,
12,
536,
12,
9768,
12,
366,
9,
267,
4336,
14,
5364,
275,
4336,
855,
578,
363,
435,
7815,
435,
4336,
855,
354,
363,
267,
372,
4336,
421,
199,
533,
13282,
8,
1045,
63,
6577,
8,
6382,
10899,
12,
909,
2298,
272,
408,
10597,
883,
506,
1202,
370,
1050,
2402,
9330,
370,
314,
17300,
1978,
272,
2656,
737,
314,
1798,
2166,
14,
221,
8388,
5478,
787,
3914,
370,
376,
3734,
272,
1325,
1443,
440,
3877,
3734,
2488,
666,
641,
658,
277,
2313,
221,
710,
4499,
367,
272,
642,
365,
626,
376,
3329,
883,
506,
3914,
370,
4573,
3734,
334,
509,
272,
1806,
9316,
9,
701,
6425,
282,
1331,
436,
295,
5038,
316,
314,
658,
5418,
64,
2225,
14,
339,
3709,
5478,
787,
2737,
701,
314,
3734,
2985,
3913,
4729,
1263,
272,
2368,
367,
2897,
14,
221,
7309,
1443,
2934,
370,
1736,
6818,
626,
701,
1808,
272,
282,
6434,
805,
12,
1325,
626,
365,
440,
3962,
465,
5478,
787,
15836,
272,
701,
3932,
492,
536,
14,
221,
710,
3211,
4340,
370,
7908,
314,
3329,
365,
272,
16915,
314,
2897,
1338,
641,
314,
3734,
14,
221,
13821,
642,
4340,
314,
272,
3734,
11187,
1536,
2454,
316,
465,
18796,
2897,
4887,
314,
272,
3004,
1443,
30109,
1314,
365,
10842,
5478,
1172,
370,
4868,
626,
314,
1561,
272,
2985,
11496,
367,
2897,
787,
440,
4634,
7809,
14,
221,
1124,
1861,
1040,
367,
2893,
272,
365,
282,
2044,
322,
830,
536,
12,
1124,
7677,
63,
1637,
63,
1861,
1040,
641,
314,
1163,
4926,
365,
282,
6954,
272,
536,
465,
6952,
314,
536,
402,
314,
3329,
334,
7677,
2581,
680,
272,
408,
339,
6079,
340,
642,
3329,
19953,
642,
365,
314,
769,
402,
3762,
652,
1159,
22721,
370,
14,
272,
3762,
275,
663,
342,
339,
6079,
314,
7464,
402,
626,
3329,
14,
221,
961,
365,
24002,
2997,
367,
272,
6079,
5478,
626,
23351,
1338,
14,
221,
437,
5117,
574,
4910,
10948,
272,
6079,
7464,
14,
272,
6079,
272,
6079,
2508,
7445,
447,
499,
14,
20,
272,
7464,
275,
2948,
339,
347,
636,
826,
721,
277,
12,
3734,
304,
267,
291,
14,
5418,
275,
3734,
339,
347,
5398,
8,
277,
12,
3734,
304,
267,
408,
2499,
282,
1331,
402,
642,
3329,
3914,
370,
4573,
3734,
1041,
267,
4336,
275,
909,
855,
1222,
721,
277,
855,
533,
3368,
267,
4336,
855,
807,
4343,
873,
8,
277,
855,
807,
3368,
267,
4336,
14,
5418,
275,
3734,
267,
372,
4336,
339,
347,
23351,
8,
277,
12,
1350,
12,
536,
12,
1788,
29,
403,
304,
267,
408,
2765,
1083,
365,
2797,
2544,
314,
3503,
7103,
316,
436,
883,
506,
1202,
370,
267,
23351,
314,
1350,
14,
221,
710,
658,
1501,
64,
365,
2716,
14,
221,
710,
372,
574,
267,
1471,
506,
314,
876,
7292,
1350,
14,
267,
408,
267,
372,
1350,
339,
347,
2457,
63,
1745,
8,
277,
12,
2547,
304,
267,
408,
7940,
1159,
3032,
282,
520,
533,
6054,
12264,
18,
14,
11729,
14,
3264,
3296,
64,
626,
883,
506,
1202,
267,
370,
2457,
4645,
2138,
14,
221,
961,
1083,
965,
370,
372,
376,
6076,
402,
267,
520,
533,
6054,
12264,
18,
14,
11729,
14,
3264,
25502,
83,
12,
1325,
652,
3181,
1133,
1172,
370,
372,
282,
267,
520,
533,
6054,
12264,
18,
14,
11729,
14,
3264,
3296,
2313,
398,
1010,
314,
658,
832,
64,
4922,
402,
314,
17300,
18,
1350,
4084,
2337,
365,
282,
570,
267,
2797,
658,
6460,
5152,
14,
647,
64,
1314,
9031,
282,
2457,
626,
7678,
19030,
397,
642,
267,
1083,
14,
267,
408,
267,
372,
2547,
339,
347,
2198,
8,
277,
12,
1798,
304,
267,
408,
3917,
1263,
402,
314,
520,
962,
1705,
2969,
64,
7838,
642,
1083,
365,
2797,
543,
314,
267,
1798,
465,
1642,
1423,
14,
221,
710,
1526,
314,
1798,
2547,
365,
20686,
737,
267,
365,
314,
536,
1526,
626,
7838,
14,
221,
961,
1083,
965,
370,
372,
1373,
503,
282,
267,
769,
402,
3663,
3380,
14,
267,
408,
267,
746,
4279,
342,
339,
347,
1921,
8,
277,
12,
536,
12,
5874,
29,
403,
304,
267,
408,
1767,
376,
2225,
1031,
367,
314,
1453,
3329,
14,
221,
961,
365,
2997,
267,
370,
986,
5262,
641,
5478,
370,
4046,
1978,
1233,
14,
398,
3800,
953,
291,
14,
962,
6412,
1662,
63,
3215,
297,
5874,
29,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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ftwidth=4 softtabstop=4
# Copyright 2010 United States Government as represented by the
# Administrator of the National Aeronautics and Space Administration.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from cinder import flags
FLAGS = flags.FLAGS
flags.DECLARE('iscsi_num_targets', 'cinder.volume.drivers.lvm')
flags.DECLARE('policy_file', 'cinder.policy')
flags.DECLARE('volume_driver', 'cinder.volume.manager')
flags.DECLARE('xiv_proxy', 'cinder.volume.drivers.xiv')
flags.DECLARE('backup_driver', 'cinder.backup.manager')
def_vol_type = 'fake_vol_type'
def set_defaults(conf):
conf.set_default('default_volume_type', def_vol_type)
conf.set_default('volume_driver',
'cinder.tests.fake_driver.FakeISCSIDriver')
conf.set_default('iscsi_helper', 'fake')
conf.set_default('connection_type', 'fake')
conf.set_default('fake_rabbit', True)
conf.set_default('rpc_backend', 'cinder.openstack.common.rpc.impl_fake')
conf.set_default('iscsi_num_targets', 8)
conf.set_default('verbose', True)
conf.set_default('connection', 'sqlite://', group='database')
conf.set_default('sqlite_synchronous', False)
conf.set_default('policy_file', 'cinder/tests/policy.json')
conf.set_default('xiv_proxy', 'cinder.tests.test_xiv.XIVFakeProxyDriver')
conf.set_default('backup_driver', 'cinder.tests.backup.fake_service')
|
apache-2.0
|
[
3,
6695,
26,
20849,
29,
20,
20105,
29,
20,
25966,
29,
20,
199,
199,
3,
1898,
7129,
1910,
5703,
24230,
598,
27639,
465,
11159,
701,
314,
199,
3,
30660,
402,
314,
20548,
437,
281,
265,
3844,
7769,
436,
19326,
9516,
4633,
14,
199,
3,
2900,
5924,
5702,
14,
199,
3,
199,
3,
259,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
1265,
1443,
199,
3,
259,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
2047,
1443,
3332,
199,
3,
259,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
260,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
259,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
259,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
2428,
199,
3,
259,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
1666,
314,
199,
3,
259,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
4204,
199,
3,
259,
1334,
314,
844,
14,
199,
199,
504,
13069,
492,
3285,
199,
199,
4831,
275,
3285,
14,
4831,
199,
199,
2469,
14,
27402,
8693,
360,
17139,
63,
1507,
63,
4684,
297,
283,
12372,
14,
2405,
14,
13337,
14,
31283,
358,
199,
2469,
14,
27402,
8693,
360,
3185,
63,
493,
297,
283,
12372,
14,
3185,
358,
199,
2469,
14,
27402,
8693,
360,
2405,
63,
3090,
297,
283,
12372,
14,
2405,
14,
2609,
358,
199,
2469,
14,
27402,
8693,
360,
25034,
63,
3280,
297,
283,
12372,
14,
2405,
14,
13337,
14,
25034,
358,
199,
2469,
14,
27402,
8693,
360,
5751,
63,
3090,
297,
283,
12372,
14,
5751,
14,
2609,
358,
199,
318,
63,
5650,
63,
466,
275,
283,
3183,
63,
5650,
63,
466,
7,
421,
199,
318,
663,
63,
4322,
8,
2190,
304,
272,
3743,
14,
409,
63,
885,
360,
885,
63,
2405,
63,
466,
297,
347,
63,
5650,
63,
466,
9,
272,
3743,
14,
409,
63,
885,
360,
2405,
63,
3090,
297,
2151,
283,
12372,
14,
2219,
14,
3183,
63,
3090,
14,
8249,
1311,
3298,
998,
2046,
358,
272,
3743,
14,
409,
63,
885,
360,
17139,
63,
3676,
297,
283,
3183,
358,
272,
3743,
14,
409,
63,
885,
360,
2105,
63,
466,
297,
283,
3183,
358,
272,
3743,
14,
409,
63,
885,
360,
3183,
63,
14411,
2075,
297,
715,
9,
272,
3743,
14,
409,
63,
885,
360,
4354,
63,
4620,
297,
283,
12372,
14,
8512,
14,
2330,
14,
4354,
14,
5472,
63,
3183,
358,
272,
3743,
14,
409,
63,
885,
360,
17139,
63,
1507,
63,
4684,
297,
1695,
9,
272,
3743,
14,
409,
63,
885,
360,
3832,
297,
715,
9,
272,
3743,
14,
409,
63,
885,
360,
2105,
297,
283,
10659,
921,
297,
1572,
534,
4659,
358,
272,
3743,
14,
409,
63,
885,
360,
10659,
63,
83,
9865,
297,
756,
9,
272,
3743,
14,
409,
63,
885,
360,
3185,
63,
493,
297,
283,
12372,
15,
2219,
15,
3185,
14,
1001,
358,
272,
3743,
14,
409,
63,
885,
360,
25034,
63,
3280,
297,
283,
12372,
14,
2219,
14,
396,
63,
25034,
14,
56,
6882,
8249,
4936,
6158,
358,
272,
3743,
14,
409,
63,
885,
360,
5751,
63,
3090,
297,
283,
12372,
14,
2219,
14,
5751,
14,
3183,
63,
1364,
358,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
6695,
26,
20849,
29,
20,
20105,
29,
20,
25966,
29,
20,
199,
199,
3,
1898,
7129,
1910,
5703,
24230,
598,
27639,
465,
11159,
701,
314,
199,
3,
30660,
402,
314,
20548,
437,
281,
265,
3844,
7769,
436,
19326,
9516,
4633,
14,
199,
3,
2900,
5924,
5702,
14,
199,
3,
199,
3,
259,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
1265,
1443,
199,
3,
259,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
2047,
1443,
3332,
199,
3,
259,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
260,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
259,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
259,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
2428,
199,
3,
259,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
1666,
314,
199,
3,
259,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
4204,
199,
3,
259,
1334,
314,
844,
14,
199,
199,
504,
13069,
492,
3285,
199,
199,
4831,
275,
3285,
14,
4831,
199,
199,
2469,
14,
27402,
8693,
360,
17139,
63,
1507,
63,
4684,
297,
283,
12372,
14,
2405,
14,
13337,
14,
31283,
358,
199,
2469,
14,
27402,
8693,
360,
3185,
63,
493,
297,
283,
12372,
14,
3185,
358,
199,
2469,
14,
27402,
8693,
360,
2405,
63,
3090,
297,
283,
12372,
14,
2405,
14,
2609,
358,
199,
2469,
14,
27402,
8693,
360,
25034,
63,
3280,
297,
283,
12372,
14,
2405,
14,
13337,
14,
25034,
358,
199,
2469,
14,
27402,
8693,
360,
5751,
63,
3090,
297,
283,
12372,
14,
5751,
14,
2609,
358,
199,
318,
63,
5650,
63,
466,
275,
283,
3183,
63,
5650,
63,
466,
7,
421,
199,
318,
663,
63,
4322,
8,
2190,
304,
272,
3743,
14,
409,
63,
885,
360,
885,
63,
2405,
63,
466,
297,
347,
63,
5650,
63,
466,
9,
272,
3743,
14,
409,
63,
885,
360,
2405,
63,
3090,
297,
2151,
283,
12372,
14,
2219,
14,
3183,
63,
3090,
14,
8249,
1311,
3298,
998,
2046,
358,
272,
3743,
14,
409,
63,
885,
360,
17139,
63,
3676,
297,
283,
3183,
358,
272,
3743,
14,
409,
63,
885,
360,
2105,
63,
466,
297,
283,
3183,
358,
272,
3743,
14,
409,
63,
885,
360,
3183,
63,
14411,
2075,
297,
715,
9,
272,
3743,
14,
409,
63,
885,
360,
4354,
63,
4620,
297,
283,
12372,
14,
8512,
14,
2330,
14,
4354,
14,
5472,
63,
3183,
358,
272,
3743,
14,
409,
63,
885,
360,
17139,
63,
1507,
63,
4684,
297,
1695,
9,
272,
3743,
14,
409,
63,
885,
360,
3832,
297,
715,
9,
272,
3743,
14,
409,
63,
885,
360,
2105,
297,
283,
10659,
921,
297,
1572,
534,
4659,
358,
272,
3743,
14,
409,
63,
885,
360,
10659,
63,
83,
9865,
297,
756,
9,
272,
3743,
14,
409,
63,
885,
360,
3185,
63,
493,
297,
283,
12372,
15,
2219,
15,
3185,
14,
1001,
358,
272,
3743,
14,
409,
63,
885,
360,
25034,
63,
3280,
297,
283,
12372,
14,
2219,
14,
396,
63,
25034,
14,
56,
6882,
8249,
4936,
6158,
358,
272,
3743,
14,
409,
63,
885,
360,
5751,
63,
3090,
297,
283,
12372,
14,
2219,
14,
5751,
14,
3183,
63,
1364,
358,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
drexly/tonginBlobStore
|
lib/django/core/checks/model_checks.py
|
525
|
2390
|
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import inspect
import types
from django.apps import apps
from django.core.checks import Error, Tags, register
@register(Tags.models)
def check_all_models(app_configs=None, **kwargs):
errors = []
for model in apps.get_models():
if app_configs is None or model._meta.app_config in app_configs:
if not inspect.ismethod(model.check):
errors.append(
Error(
"The '%s.check()' class method is "
"currently overridden by %r." % (
model.__name__, model.check),
hint=None,
obj=model,
id='models.E020'
)
)
else:
errors.extend(model.check(**kwargs))
return errors
@register(Tags.models, Tags.signals)
def check_model_signals(app_configs=None, **kwargs):
"""
Ensure lazily referenced model signals senders are installed.
"""
# Avoid circular import
from django.db import models
errors = []
for name in dir(models.signals):
obj = getattr(models.signals, name)
if isinstance(obj, models.signals.ModelSignal):
for reference, receivers in obj.unresolved_references.items():
for receiver, _, _ in receivers:
# The receiver is either a function or an instance of class
# defining a `__call__` method.
if isinstance(receiver, types.FunctionType):
description = "The '%s' function" % receiver.__name__
else:
description = "An instance of the '%s' class" % receiver.__class__.__name__
errors.append(
Error(
"%s was connected to the '%s' signal "
"with a lazy reference to the '%s' sender, "
"which has not been installed." % (
description, name, '.'.join(reference)
),
obj=receiver.__module__,
hint=None,
id='signals.E001'
)
)
return errors
|
bsd-3-clause
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
504,
636,
2443,
363,
492,
2649,
63,
5955,
199,
199,
646,
6485,
199,
646,
2943,
199,
199,
504,
1639,
14,
5181,
492,
8686,
199,
504,
1639,
14,
1018,
14,
8625,
492,
4520,
12,
25204,
12,
2274,
421,
199,
32,
2683,
8,
9440,
14,
992,
9,
199,
318,
1104,
63,
452,
63,
992,
8,
571,
63,
7532,
29,
403,
12,
1011,
958,
304,
272,
2552,
275,
942,
272,
367,
1402,
315,
8686,
14,
362,
63,
992,
837,
267,
340,
1145,
63,
7532,
365,
488,
503,
1402,
423,
2024,
14,
571,
63,
888,
315,
1145,
63,
7532,
26,
288,
340,
440,
6485,
14,
374,
765,
8,
1238,
14,
1074,
304,
355,
2552,
14,
740,
8,
490,
4520,
8,
717,
298,
1918,
1543,
83,
14,
1074,
11716,
1021,
1083,
365,
298,
717,
298,
19767,
10087,
701,
450,
82,
2122,
450,
334,
1169,
1402,
855,
354,
3108,
1402,
14,
1074,
395,
717,
8328,
29,
403,
12,
717,
1559,
29,
1238,
12,
717,
1305,
534,
992,
14,
37,
10173,
7,
490,
776,
355,
776,
288,
587,
26,
355,
2552,
14,
2880,
8,
1238,
14,
1074,
3682,
958,
430,
272,
372,
2552,
421,
199,
32,
2683,
8,
9440,
14,
992,
12,
25204,
14,
10458,
9,
199,
318,
1104,
63,
1238,
63,
10458,
8,
571,
63,
7532,
29,
403,
12,
1011,
958,
304,
272,
408,
272,
7523,
29667,
3444,
11812,
1402,
10166,
4334,
7735,
787,
4903,
14,
272,
408,
272,
327,
19503,
15032,
492,
272,
687,
1639,
14,
697,
492,
1709,
339,
2552,
275,
942,
272,
367,
536,
315,
2935,
8,
992,
14,
10458,
304,
267,
1559,
275,
2519,
8,
992,
14,
10458,
12,
536,
9,
267,
340,
1228,
8,
1113,
12,
1709,
14,
10458,
14,
1685,
11274,
304,
288,
367,
3659,
12,
13035,
83,
315,
1559,
14,
324,
13697,
63,
12635,
14,
1744,
837,
355,
367,
13035,
12,
5501,
485,
315,
13035,
83,
26,
490,
327,
710,
13035,
365,
1902,
282,
805,
503,
376,
1256,
402,
1021,
490,
327,
12669,
282,
26856,
1250,
29341,
1083,
14,
490,
340,
1228,
8,
10244,
12,
2943,
14,
26371,
304,
717,
1369,
275,
298,
1918,
1543,
83,
7,
805,
2,
450,
13035,
855,
354,
363,
490,
587,
26,
717,
1369,
275,
298,
2493,
1256,
402,
314,
1543,
83,
7,
1021,
2,
450,
13035,
855,
533,
4914,
354,
363,
490,
2552,
14,
740,
8,
717,
4520,
8,
1169,
2071,
83,
1990,
8539,
370,
314,
1543,
83,
7,
4673,
298,
1169,
298,
1045,
282,
9617,
3659,
370,
314,
1543,
83,
7,
8904,
12,
298,
1169,
298,
6777,
965,
440,
2757,
4903,
2122,
450,
334,
1816,
1369,
12,
536,
12,
15671,
904,
8,
4443,
9,
1169,
2318,
1169,
1559,
29,
10244,
855,
578,
3108,
1169,
8328,
29,
403,
12,
1169,
1305,
534,
10458,
14,
37,
4587,
7,
717,
776,
490,
776,
272,
372,
2552,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
504,
636,
2443,
363,
492,
2649,
63,
5955,
199,
199,
646,
6485,
199,
646,
2943,
199,
199,
504,
1639,
14,
5181,
492,
8686,
199,
504,
1639,
14,
1018,
14,
8625,
492,
4520,
12,
25204,
12,
2274,
421,
199,
32,
2683,
8,
9440,
14,
992,
9,
199,
318,
1104,
63,
452,
63,
992,
8,
571,
63,
7532,
29,
403,
12,
1011,
958,
304,
272,
2552,
275,
942,
272,
367,
1402,
315,
8686,
14,
362,
63,
992,
837,
267,
340,
1145,
63,
7532,
365,
488,
503,
1402,
423,
2024,
14,
571,
63,
888,
315,
1145,
63,
7532,
26,
288,
340,
440,
6485,
14,
374,
765,
8,
1238,
14,
1074,
304,
355,
2552,
14,
740,
8,
490,
4520,
8,
717,
298,
1918,
1543,
83,
14,
1074,
11716,
1021,
1083,
365,
298,
717,
298,
19767,
10087,
701,
450,
82,
2122,
450,
334,
1169,
1402,
855,
354,
3108,
1402,
14,
1074,
395,
717,
8328,
29,
403,
12,
717,
1559,
29,
1238,
12,
717,
1305,
534,
992,
14,
37,
10173,
7,
490,
776,
355,
776,
288,
587,
26,
355,
2552,
14,
2880,
8,
1238,
14,
1074,
3682,
958,
430,
272,
372,
2552,
421,
199,
32,
2683,
8,
9440,
14,
992,
12,
25204,
14,
10458,
9,
199,
318,
1104,
63,
1238,
63,
10458,
8,
571,
63,
7532,
29,
403,
12,
1011,
958,
304,
272,
408,
272,
7523,
29667,
3444,
11812,
1402,
10166,
4334,
7735,
787,
4903,
14,
272,
408,
272,
327,
19503,
15032,
492,
272,
687,
1639,
14,
697,
492,
1709,
339,
2552,
275,
942,
272,
367,
536,
315,
2935,
8,
992,
14,
10458,
304,
267,
1559,
275,
2519,
8,
992,
14,
10458,
12,
536,
9,
267,
340,
1228,
8,
1113,
12,
1709,
14,
10458,
14,
1685,
11274,
304,
288,
367,
3659,
12,
13035,
83,
315,
1559,
14,
324,
13697,
63,
12635,
14,
1744,
837,
355,
367,
13035,
12,
5501,
485,
315,
13035,
83,
26,
490,
327,
710,
13035,
365,
1902,
282,
805,
503,
376,
1256,
402,
1021,
490,
327,
12669,
282,
26856,
1250,
29341,
1083,
14,
490,
340,
1228,
8,
10244,
12,
2943,
14,
26371,
304,
717,
1369,
275,
298,
1918,
1543,
83,
7,
805,
2,
450,
13035,
855,
354,
363,
490,
587,
26,
717,
1369,
275,
298,
2493,
1256,
402,
314,
1543,
83,
7,
1021,
2,
450,
13035,
855,
533,
4914,
354,
363,
490,
2552,
14,
740,
8,
717,
4520,
8,
1169,
2071,
83,
1990,
8539,
370,
314,
1543,
83,
7,
4673,
298,
1169,
298,
1045,
282,
9617,
3659,
370,
314,
1543,
83,
7,
8904,
12,
298,
1169,
298,
6777,
965,
440,
2757,
4903,
2122,
450,
334,
1816,
1369,
12,
536,
12,
15671,
904,
8,
4443,
9,
1169,
2318,
1169,
1559,
29,
10244,
855,
578,
3108,
1169,
8328,
29,
403,
12,
1169,
1305,
534,
10458,
14,
37,
4587,
7,
717,
776,
490,
776,
272,
372,
2552,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
ultrabug/py3status
|
py3status/modules/clock.py
|
1
|
11062
|
"""
Display date and time.
This module allows one or more datetimes to be displayed.
All datetimes share the same format_time but can set their own timezones.
Timezones are defined in the `format` using the TZ name in squiggly brackets eg
`{GMT}`, `{Portugal}`, `{Europe/Paris}`, `{America/Argentina/Buenos_Aires}`.
ISO-3166 two letter country codes eg `{de}` can also be used but if more than
one timezone exists for the country eg `{us}` the first one will be selected.
`{Local}` can be used for the local settings of your computer.
Note: Timezones are case sensitive
A full list of timezones can be found at
https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
Configuration parameters:
block_hours: length of time period for all blocks in hours (default 12)
blocks: a string, where each character represents time period
from the start of a time period.
(default '🕛🕧🕐🕜🕑🕝🕒🕞🕓🕟🕔🕠🕕🕡🕖🕢🕗🕣🕘🕤🕙🕥🕚🕦')
button_change_format: button that switches format used setting to None
disables (default 1)
button_change_time_format: button that switches format_time used. Setting
to None disables (default 2)
button_reset: button that switches display to the first timezone. Setting
to None disables (default 3)
cycle: If more than one display then how many seconds between changing the
display (default 0)
format: defines the timezones displayed. This can be a single string or a
list. If a list is supplied then the formats can be cycled through
using `cycle` or by button click. (default '{Local}')
format_time: format to use for the time, strftime directives such as `%H`
can be used this can be either a string or to allow multiple formats as
a list. The one used can be changed by button click.
*(default ['[{name_unclear} ]%c', '[{name_unclear} ]%x %X',
'[{name_unclear} ]%a %H:%M', '[{name_unclear} ]{icon}'])*
locale: Override the system locale. Examples:
when set to 'fr_FR' %a on Tuesday is 'mar.'.
(default None)
round_to_nearest_block: defines how a block icon is chosen. Examples:
when set to True, '13:14' is '🕐', '13:16' is '🕜' and '13:31' is '🕜';
when set to False, '13:14' is '🕐', '13:16' is '🕐' and '13:31' is '🕜'.
(default True)
Format placeholders:
{icon} a character representing the time from `blocks`
{name} friendly timezone name eg `Buenos Aires`
{name_unclear} friendly timezone name eg `Buenos Aires` but is empty if
only one timezone is provided
{timezone} full timezone name eg `America/Argentina/Buenos_Aires`
{timezone_unclear} full timezone name eg `America/Argentina/Buenos_Aires`
but is empty if only one timezone is provided
Requires:
pytz: cross platform time zone library for python
tzlocal: tzinfo object for the local timezone
Examples:
```
# cycling through London, Warsaw, Tokyo
clock {
cycle = 30
format = ["{Europe/London}", "{Europe/Warsaw}", "{Asia/Tokyo}"]
format_time = "{name} %H:%M"
}
# Show the time and date in New York
clock {
format = "Big Apple {America/New_York}"
format_time = "%Y-%m-%d %H:%M:%S"
}
# wall clocks
clock {
format = "{Asia/Calcutta} {Africa/Nairobi} {Asia/Bangkok}"
format_time = "{name} {icon}"
}
```
@author tobes
@license BSD
SAMPLE OUTPUT
{'full_text': 'Sun 15 Jan 2017 23:27:17 GMT'}
london
{'full_text': 'Thursday Feb 23 1:42 AM London'}
"""
import locale
import re
import time
from datetime import datetime
import pytz
import tzlocal
CLOCK_BLOCKS = "🕛🕧🕐🕜🕑🕝🕒🕞🕓🕟🕔🕠🕕🕡🕖🕢🕗🕣🕘🕤🕙🕥🕚🕦"
class Py3status:
"""
"""
# available configuration parameters
block_hours = 12
blocks = CLOCK_BLOCKS
button_change_format = 1
button_change_time_format = 2
button_reset = 3
cycle = 0
format = "{Local}"
format_time = [
"[{name_unclear} ]%c",
"[{name_unclear} ]%x %X",
"[{name_unclear} ]%a %H:%M",
"[{name_unclear} ]{icon}",
]
locale = None
round_to_nearest_block = True
def post_config_hook(self):
if self.locale is not None:
locale.setlocale(locale.LC_TIME, self.locale)
# Multiple clocks are possible that can be cycled through
if not isinstance(self.format, list):
self.format = [self.format]
# if only one item we don't need to cycle
if len(self.format) == 1:
self.cycle = 0
# find any declared timezones eg {Europe/London}
self._fmts = set()
for fmt in self.format:
self._fmts.update(self.py3.get_placeholders_list(fmt))
self.multiple_tz = len(self._fmts) > 1
if not isinstance(self.format_time, list):
self.format_time = [self.format_time]
# workout how often in seconds we will need to do an update to keep the
# display fresh
self.time_deltas = []
for format in self.format_time:
format_time = re.sub(r"{([^}]*)}", "", format)
format_time = format_time.replace("%%", "")
if "%f" in format_time:
# microseconds
time_delta = 0
elif "%S" in format_time:
# seconds
time_delta = 1
elif "%s" in format_time:
# seconds since unix epoch start
time_delta = 1
elif "%T" in format_time:
# seconds included in "%H:%M:%S"
time_delta = 1
elif "%c" in format_time:
# Locale’s appropriate date and time representation
time_delta = 1
elif "%X" in format_time:
# Locale’s appropriate time representation
time_delta = 1
else:
time_delta = 60
self.time_deltas.append(time_delta)
# If we have saved details we use them.
saved_format = self.py3.storage_get("time_format")
if saved_format in self.format_time:
self.active_time_format = self.format_time.index(saved_format)
else:
self.active_time_format = 0
saved_timezone = self.py3.storage_get("timezone")
if saved_timezone in self.format:
self.active = self.format.index(saved_timezone)
else:
self.active = 0
# reset the cycle time
self._cycle_time = time.time() + self.cycle
def _get_timezone(self, tz):
"""
Find and return the time zone if possible
"""
# special Local timezone
if tz == "Local":
try:
return tzlocal.get_localzone()
except pytz.UnknownTimeZoneError:
return "?"
# we can use a country code to get tz
# FIXME this is broken for multi-timezone countries eg US
# for now we just grab the first one
if len(tz) == 2:
try:
zones = pytz.country_timezones(tz)
except KeyError:
return "?"
tz = zones[0]
# get the timezone
try:
zone = pytz.timezone(tz)
except pytz.UnknownTimeZoneError:
return "?"
return zone
def _change_active(self, diff):
self.active = (self.active + diff) % len(self.format)
# reset the cycle time
self._cycle_time = time.time() + self.cycle
# save the active format
timezone = self.format[self.active]
self.py3.storage_set("timezone", timezone)
def on_click(self, event):
"""
Switch the displayed module or pass the event on to the active module
"""
if event["button"] == self.button_reset:
self._change_active(0)
elif event["button"] == self.button_change_time_format:
self.active_time_format += 1
if self.active_time_format >= len(self.format_time):
self.active_time_format = 0
# save the active format_time
time_format = self.format_time[self.active_time_format]
self.py3.storage_set("time_format", time_format)
elif event["button"] == self.button_change_format:
self._change_active(1)
def clock(self):
# cycling
if self.cycle and time.time() >= self._cycle_time:
self._change_active(1)
self._cycle_time = time.time() + self.cycle
# update our times
times = {}
for name in self._fmts:
zone = self._get_timezone(name)
if zone == "?":
times[name] = "?"
else:
t = datetime.now(zone)
format_time = self.format_time[self.active_time_format]
icon = None
if self.py3.format_contains(format_time, "icon"):
# calculate the decimal hour
h = t.hour + t.minute / 60
if self.round_to_nearest_block:
h += self.block_hours / len(self.blocks) / 2
# make 12 hourly etc
h = h % self.block_hours
idx = int(h / self.block_hours * len(self.blocks))
icon = self.blocks[idx]
timezone = zone.zone
tzname = timezone.split("/")[-1].replace("_", " ")
if self.multiple_tz:
name_unclear = tzname
timezone_unclear = timezone
else:
name_unclear = ""
timezone_unclear = ""
format_time = self.py3.safe_format(
format_time,
dict(
icon=icon,
name=tzname,
name_unclear=name_unclear,
timezone=timezone,
timezone_unclear=timezone_unclear,
),
)
if self.py3.is_composite(format_time):
for item in format_time:
item["full_text"] = t.strftime(item["full_text"])
else:
format_time = t.strftime(format_time)
times[name] = format_time
# work out when we need to update
timeout = self.py3.time_in(sync_to=self.time_deltas[self.active_time_format])
# if cycling we need to make sure we update when they are needed
if self.cycle:
cycle_timeout = self._cycle_time
timeout = min(timeout, cycle_timeout)
return {
"full_text": self.py3.safe_format(self.format[self.active], times),
"cached_until": timeout,
}
if __name__ == "__main__":
"""
Run module in test mode.
"""
from py3status.module_test import module_test
module_test(Py3status)
|
bsd-3-clause
|
[
624,
199,
7687,
1434,
436,
900,
14,
199,
199,
2765,
859,
6127,
1373,
503,
1655,
29297,
370,
506,
9080,
14,
199,
2422,
29297,
8663,
314,
2011,
1475,
63,
521,
1325,
883,
663,
3932,
5705,
7137,
83,
14,
199,
1366,
13325,
787,
3247,
315,
314,
658,
908,
64,
1808,
314,
377,
58,
536,
315,
12345,
528,
20984,
21873,
11837,
199,
64,
91,
17274,
93,
3559,
658,
91,
4313,
1518,
279,
93,
3559,
658,
91,
15201,
15,
1262,
374,
93,
3559,
658,
91,
8841,
15,
6373,
484,
13765,
15,
1713,
287,
736,
63,
28960,
470,
93,
2313,
199,
199,
7336,
13,
19,
10642,
2877,
8082,
9023,
9479,
11837,
658,
91,
271,
23485,
883,
2597,
506,
1202,
1325,
340,
1655,
2419,
199,
368,
7137,
3495,
367,
314,
9023,
11837,
658,
91,
527,
23485,
314,
1642,
1373,
911,
506,
4895,
14,
199,
199,
64,
91,
5339,
23485,
883,
506,
1202,
367,
314,
2257,
2202,
402,
2195,
24189,
14,
199,
199,
7443,
26,
4703,
13325,
787,
1930,
18423,
199,
199,
33,
2615,
769,
402,
7137,
83,
883,
506,
1911,
737,
199,
2859,
921,
287,
14,
13961,
14,
1308,
15,
6797,
15,
1296,
63,
1618,
63,
3903,
63,
4659,
63,
521,
63,
13325,
199,
199,
5688,
2633,
26,
272,
1853,
63,
8419,
26,
2582,
402,
900,
6247,
367,
1006,
5664,
315,
10857,
334,
885,
3144,
9,
272,
5664,
26,
282,
1059,
12,
2382,
1924,
4528,
8469,
900,
6247,
267,
687,
314,
1343,
402,
282,
900,
6247,
14,
267,
334,
885,
283,
173,
254,
244,
250,
173,
254,
244,
101,
173,
254,
244,
239,
173,
254,
244,
251,
173,
254,
244,
240,
173,
254,
244,
252,
173,
254,
244,
241,
173,
254,
244,
253,
173,
254,
244,
242,
173,
254,
244,
254,
173,
254,
244,
243,
173,
254,
244,
255,
173,
254,
244,
244,
173,
254,
244,
95,
173,
254,
244,
245,
173,
254,
244,
96,
173,
254,
244,
246,
173,
254,
244,
97,
173,
254,
244,
247,
173,
254,
244,
98,
173,
254,
244,
248,
173,
254,
244,
99,
173,
254,
244,
249,
173,
254,
244,
100,
358,
272,
5528,
63,
1461,
63,
908,
26,
5528,
626,
24563,
1475,
1202,
4260,
370,
488,
267,
28421,
334,
885,
413,
9,
272,
5528,
63,
1461,
63,
521,
63,
908,
26,
5528,
626,
24563,
1475,
63,
521,
1202,
14,
13510,
267,
370,
488,
28421,
334,
885,
499,
9,
272,
5528,
63,
3958,
26,
5528,
626,
24563,
2929,
370,
314,
1642,
7137,
14,
13510,
267,
370,
488,
28421,
334,
885,
650,
9,
272,
8643,
26,
982,
1655,
2419,
1373,
2929,
2066,
4212,
5002,
4696,
3382,
13729,
314,
267,
2929,
334,
885,
378,
9,
272,
1475,
26,
7890,
314,
7137,
83,
9080,
14,
961,
883,
506,
282,
2849,
1059,
503,
282,
267,
769,
14,
221,
982,
282,
769,
365,
6841,
2066,
314,
6752,
883,
506,
6325,
67,
1146,
4012,
267,
1808,
658,
7612,
64,
503,
701,
5528,
8968,
14,
221,
334,
885,
5041,
5339,
12216,
272,
1475,
63,
521,
26,
1475,
370,
675,
367,
314,
900,
12,
14053,
13502,
4066,
465,
18633,
40,
64,
267,
883,
506,
1202,
642,
883,
506,
1902,
282,
1059,
503,
370,
2040,
3663,
6752,
465,
267,
282,
769,
14,
221,
710,
1373,
1202,
883,
506,
2896,
701,
5528,
8968,
14,
267,
26534,
885,
788,
59,
91,
354,
63,
1097,
4025,
93,
1622,
5,
67,
297,
6730,
91,
354,
63,
1097,
4025,
93,
1622,
5,
88,
450,
56,
297,
267,
6730,
91,
354,
63,
1097,
4025,
93,
1622,
5,
65,
450,
40,
2689,
45,
297,
6730,
91,
354,
63,
1097,
4025,
93,
1622,
91,
4677,
93,
1105,
10,
272,
5867,
26,
11041,
314,
2656,
5867,
14,
6058,
26,
267,
1380,
663,
370,
283,
4391,
63,
5372,
7,
450,
65,
641,
377,
10138,
2977,
365,
283,
4584,
17374,
267,
334,
885,
488,
9,
272,
6168,
63,
475,
63,
16615,
63,
1457,
26,
7890,
4212,
282,
1853,
7016,
365,
12414,
14,
6058,
26,
267,
1380,
663,
370,
715,
12,
221,
283,
969,
26,
1079,
7,
365,
283,
173,
254,
244,
239,
297,
283,
969,
26,
975,
7,
365,
283,
173,
254,
244,
251,
7,
436,
283,
969,
26,
2192,
7,
365,
283,
173,
254,
244,
251,
13619,
267,
1380,
663,
370,
756,
12,
283,
969,
26,
1079,
7,
365,
283,
173,
254,
244,
239,
297,
283,
969,
26,
975,
7,
365,
283,
173,
254,
244,
239,
7,
436,
283,
969,
26,
2192,
7,
365,
283,
173,
254,
244,
251,
1370,
267,
334,
885,
715,
9,
199,
199,
3484,
24987,
26,
272,
469,
4677,
93,
282,
4528,
6144,
314,
900,
687,
658,
4166,
64,
272,
469,
354,
93,
21428,
7137,
536,
11837,
658,
1713,
287,
736,
437,
73,
470,
64,
272,
469,
354,
63,
1097,
4025,
93,
21428,
7137,
536,
11837,
658,
1713,
287,
736,
437,
73,
470,
64,
1325,
365,
2701,
340,
267,
1454,
1373,
7137,
365,
2741,
272,
469,
7145,
93,
2615,
7137,
536,
11837,
658,
8841,
15,
6373,
484,
13765,
15,
1713,
287,
736,
63,
28960,
470,
64,
272,
469,
7145,
63,
1097,
4025,
93,
2615,
7137,
536,
11837,
658,
8841,
15,
6373,
484,
13765,
15,
1713,
287,
736,
63,
28960,
470,
64,
267,
1325,
365,
2701,
340,
1454,
1373,
7137,
365,
2741,
199,
199,
18153,
26,
272,
15444,
26,
8059,
4298,
900,
5718,
3555,
367,
2366,
272,
5823,
1832,
26,
10313,
909,
367,
314,
2257,
7137,
199,
199,
22787,
26,
199,
32323,
199,
3,
6325,
429,
316,
4012,
491,
7835,
265,
12,
644,
285,
2231,
87,
12,
377,
745,
16540,
199,
9597,
469,
272,
8643,
275,
4233,
272,
1475,
275,
2097,
91,
15201,
15,
44,
7835,
265,
10750,
5310,
15201,
15,
55,
285,
2231,
87,
10750,
5310,
13878,
15,
29117,
16540,
93,
937,
272,
1475,
63,
521,
275,
5310,
354,
93,
450,
40,
2689,
45,
2,
199,
93,
199,
199,
3,
12968,
314,
900,
436,
1434,
315,
7053,
1488,
4708,
199,
9597,
469,
2043,
1475,
275,
298,
7279,
21257,
469,
8841,
15,
4665,
63,
57,
4708,
7063,
2043,
1475,
63,
521,
275,
2071,
57,
3295,
77,
3295,
68,
450,
40,
2689,
45,
2689,
51,
2,
199,
93,
199,
199,
3,
19882,
12516,
83,
199,
9597,
469,
272,
1475,
275,
5310,
13878,
15,
6584,
5919,
502,
93,
469,
19289,
15,
46
] |
[
199,
7687,
1434,
436,
900,
14,
199,
199,
2765,
859,
6127,
1373,
503,
1655,
29297,
370,
506,
9080,
14,
199,
2422,
29297,
8663,
314,
2011,
1475,
63,
521,
1325,
883,
663,
3932,
5705,
7137,
83,
14,
199,
1366,
13325,
787,
3247,
315,
314,
658,
908,
64,
1808,
314,
377,
58,
536,
315,
12345,
528,
20984,
21873,
11837,
199,
64,
91,
17274,
93,
3559,
658,
91,
4313,
1518,
279,
93,
3559,
658,
91,
15201,
15,
1262,
374,
93,
3559,
658,
91,
8841,
15,
6373,
484,
13765,
15,
1713,
287,
736,
63,
28960,
470,
93,
2313,
199,
199,
7336,
13,
19,
10642,
2877,
8082,
9023,
9479,
11837,
658,
91,
271,
23485,
883,
2597,
506,
1202,
1325,
340,
1655,
2419,
199,
368,
7137,
3495,
367,
314,
9023,
11837,
658,
91,
527,
23485,
314,
1642,
1373,
911,
506,
4895,
14,
199,
199,
64,
91,
5339,
23485,
883,
506,
1202,
367,
314,
2257,
2202,
402,
2195,
24189,
14,
199,
199,
7443,
26,
4703,
13325,
787,
1930,
18423,
199,
199,
33,
2615,
769,
402,
7137,
83,
883,
506,
1911,
737,
199,
2859,
921,
287,
14,
13961,
14,
1308,
15,
6797,
15,
1296,
63,
1618,
63,
3903,
63,
4659,
63,
521,
63,
13325,
199,
199,
5688,
2633,
26,
272,
1853,
63,
8419,
26,
2582,
402,
900,
6247,
367,
1006,
5664,
315,
10857,
334,
885,
3144,
9,
272,
5664,
26,
282,
1059,
12,
2382,
1924,
4528,
8469,
900,
6247,
267,
687,
314,
1343,
402,
282,
900,
6247,
14,
267,
334,
885,
283,
173,
254,
244,
250,
173,
254,
244,
101,
173,
254,
244,
239,
173,
254,
244,
251,
173,
254,
244,
240,
173,
254,
244,
252,
173,
254,
244,
241,
173,
254,
244,
253,
173,
254,
244,
242,
173,
254,
244,
254,
173,
254,
244,
243,
173,
254,
244,
255,
173,
254,
244,
244,
173,
254,
244,
95,
173,
254,
244,
245,
173,
254,
244,
96,
173,
254,
244,
246,
173,
254,
244,
97,
173,
254,
244,
247,
173,
254,
244,
98,
173,
254,
244,
248,
173,
254,
244,
99,
173,
254,
244,
249,
173,
254,
244,
100,
358,
272,
5528,
63,
1461,
63,
908,
26,
5528,
626,
24563,
1475,
1202,
4260,
370,
488,
267,
28421,
334,
885,
413,
9,
272,
5528,
63,
1461,
63,
521,
63,
908,
26,
5528,
626,
24563,
1475,
63,
521,
1202,
14,
13510,
267,
370,
488,
28421,
334,
885,
499,
9,
272,
5528,
63,
3958,
26,
5528,
626,
24563,
2929,
370,
314,
1642,
7137,
14,
13510,
267,
370,
488,
28421,
334,
885,
650,
9,
272,
8643,
26,
982,
1655,
2419,
1373,
2929,
2066,
4212,
5002,
4696,
3382,
13729,
314,
267,
2929,
334,
885,
378,
9,
272,
1475,
26,
7890,
314,
7137,
83,
9080,
14,
961,
883,
506,
282,
2849,
1059,
503,
282,
267,
769,
14,
221,
982,
282,
769,
365,
6841,
2066,
314,
6752,
883,
506,
6325,
67,
1146,
4012,
267,
1808,
658,
7612,
64,
503,
701,
5528,
8968,
14,
221,
334,
885,
5041,
5339,
12216,
272,
1475,
63,
521,
26,
1475,
370,
675,
367,
314,
900,
12,
14053,
13502,
4066,
465,
18633,
40,
64,
267,
883,
506,
1202,
642,
883,
506,
1902,
282,
1059,
503,
370,
2040,
3663,
6752,
465,
267,
282,
769,
14,
221,
710,
1373,
1202,
883,
506,
2896,
701,
5528,
8968,
14,
267,
26534,
885,
788,
59,
91,
354,
63,
1097,
4025,
93,
1622,
5,
67,
297,
6730,
91,
354,
63,
1097,
4025,
93,
1622,
5,
88,
450,
56,
297,
267,
6730,
91,
354,
63,
1097,
4025,
93,
1622,
5,
65,
450,
40,
2689,
45,
297,
6730,
91,
354,
63,
1097,
4025,
93,
1622,
91,
4677,
93,
1105,
10,
272,
5867,
26,
11041,
314,
2656,
5867,
14,
6058,
26,
267,
1380,
663,
370,
283,
4391,
63,
5372,
7,
450,
65,
641,
377,
10138,
2977,
365,
283,
4584,
17374,
267,
334,
885,
488,
9,
272,
6168,
63,
475,
63,
16615,
63,
1457,
26,
7890,
4212,
282,
1853,
7016,
365,
12414,
14,
6058,
26,
267,
1380,
663,
370,
715,
12,
221,
283,
969,
26,
1079,
7,
365,
283,
173,
254,
244,
239,
297,
283,
969,
26,
975,
7,
365,
283,
173,
254,
244,
251,
7,
436,
283,
969,
26,
2192,
7,
365,
283,
173,
254,
244,
251,
13619,
267,
1380,
663,
370,
756,
12,
283,
969,
26,
1079,
7,
365,
283,
173,
254,
244,
239,
297,
283,
969,
26,
975,
7,
365,
283,
173,
254,
244,
239,
7,
436,
283,
969,
26,
2192,
7,
365,
283,
173,
254,
244,
251,
1370,
267,
334,
885,
715,
9,
199,
199,
3484,
24987,
26,
272,
469,
4677,
93,
282,
4528,
6144,
314,
900,
687,
658,
4166,
64,
272,
469,
354,
93,
21428,
7137,
536,
11837,
658,
1713,
287,
736,
437,
73,
470,
64,
272,
469,
354,
63,
1097,
4025,
93,
21428,
7137,
536,
11837,
658,
1713,
287,
736,
437,
73,
470,
64,
1325,
365,
2701,
340,
267,
1454,
1373,
7137,
365,
2741,
272,
469,
7145,
93,
2615,
7137,
536,
11837,
658,
8841,
15,
6373,
484,
13765,
15,
1713,
287,
736,
63,
28960,
470,
64,
272,
469,
7145,
63,
1097,
4025,
93,
2615,
7137,
536,
11837,
658,
8841,
15,
6373,
484,
13765,
15,
1713,
287,
736,
63,
28960,
470,
64,
267,
1325,
365,
2701,
340,
1454,
1373,
7137,
365,
2741,
199,
199,
18153,
26,
272,
15444,
26,
8059,
4298,
900,
5718,
3555,
367,
2366,
272,
5823,
1832,
26,
10313,
909,
367,
314,
2257,
7137,
199,
199,
22787,
26,
199,
32323,
199,
3,
6325,
429,
316,
4012,
491,
7835,
265,
12,
644,
285,
2231,
87,
12,
377,
745,
16540,
199,
9597,
469,
272,
8643,
275,
4233,
272,
1475,
275,
2097,
91,
15201,
15,
44,
7835,
265,
10750,
5310,
15201,
15,
55,
285,
2231,
87,
10750,
5310,
13878,
15,
29117,
16540,
93,
937,
272,
1475,
63,
521,
275,
5310,
354,
93,
450,
40,
2689,
45,
2,
199,
93,
199,
199,
3,
12968,
314,
900,
436,
1434,
315,
7053,
1488,
4708,
199,
9597,
469,
2043,
1475,
275,
298,
7279,
21257,
469,
8841,
15,
4665,
63,
57,
4708,
7063,
2043,
1475,
63,
521,
275,
2071,
57,
3295,
77,
3295,
68,
450,
40,
2689,
45,
2689,
51,
2,
199,
93,
199,
199,
3,
19882,
12516,
83,
199,
9597,
469,
272,
1475,
275,
5310,
13878,
15,
6584,
5919,
502,
93,
469,
19289,
15,
46,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
espenhgn/nest-simulator
|
pynest/examples/Potjans_2014/stimulus_params.py
|
19
|
2283
|
# -*- coding: utf-8 -*-
#
# stimulus_params.py
#
# This file is part of NEST.
#
# Copyright (C) 2004 The NEST Initiative
#
# NEST is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# NEST is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with NEST. If not, see <http://www.gnu.org/licenses/>.
""" PyNEST Microcircuit: Stimulus Parameters
-----------------------------------------------
A dictionary with parameters for an optional external transient stimulation.
Thalamic input and DC input can be switched on individually.
"""
import numpy as np
stim_dict = {
# optional thalamic input
# turn thalamic input on or off (True or False)
'thalamic_input': False,
# start of the thalamic input (in ms)
'th_start': 700.0,
# duration of the thalamic input (in ms)
'th_duration': 10.0,
# rate of the thalamic input (in spikes/s)
'th_rate': 120.0,
# number of thalamic neurons
'num_th_neurons': 902,
# connection probabilities of the thalamus to the different populations
# (same order as in 'populations' in 'net_dict')
'conn_probs_th':
np.array([0.0, 0.0, 0.0983, 0.0619, 0.0, 0.0, 0.0512, 0.0196]),
# mean amplitude of the thalamic postsynaptic potential (in mV),
# standard deviation will be taken from 'net_dict'
'PSP_th': 0.15,
# mean delay of the thalamic input (in ms)
'delay_th_mean': 1.5,
# relative standard deviation of the thalamic delay (in ms)
'delay_th_rel_std': 0.5,
# optional DC input
# turn DC input on or off (True or False)
'dc_input': False,
# start of the DC input (in ms)
'dc_start': 650.0,
# duration of the DC input (in ms)
'dc_dur': 100.0,
# amplitude of the DC input (in pA); final amplitude is population-specific
# and will be obtained by multiplication with 'K_ext'
'dc_amp': 0.3}
|
gpl-2.0
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
199,
3,
29965,
15909,
63,
1162,
14,
647,
199,
3,
199,
3,
961,
570,
365,
1777,
402,
28878,
14,
199,
3,
199,
3,
1898,
334,
35,
9,
8353,
710,
28878,
21412,
1905,
199,
3,
199,
3,
28878,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
652,
1334,
314,
2895,
402,
314,
1664,
1696,
1684,
844,
465,
3267,
701,
199,
3,
314,
2868,
2290,
2752,
12,
1902,
1015,
499,
402,
314,
844,
12,
503,
199,
3,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
28878,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
199,
3,
1664,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
1696,
1684,
844,
199,
3,
3180,
543,
28878,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
199,
624,
1611,
46,
1719,
27022,
18516,
26,
428,
2906,
15909,
3897,
199,
1444,
18964,
199,
199,
33,
2600,
543,
2633,
367,
376,
2716,
5957,
7115,
14928,
29965,
5332,
14,
199,
2719,
279,
455,
530,
1324,
436,
30592,
1324,
883,
506,
308,
28986,
641,
7814,
3163,
14,
199,
199,
624,
199,
199,
646,
2680,
465,
980,
199,
199,
31739,
63,
807,
275,
469,
272,
327,
2716,
294,
279,
455,
530,
1324,
272,
327,
7485,
294,
279,
455,
530,
1324,
641,
503,
2331,
334,
549,
503,
756,
9,
272,
283,
273,
279,
455,
530,
63,
1210,
356,
756,
12,
272,
327,
1343,
402,
314,
294,
279,
455,
530,
1324,
334,
262,
6605,
9,
272,
283,
273,
63,
928,
356,
30071,
14,
16,
12,
272,
327,
7373,
402,
314,
294,
279,
455,
530,
1324,
334,
262,
6605,
9,
272,
283,
273,
63,
5553,
356,
1616,
14,
16,
12,
272,
327,
6634,
402,
314,
294,
279,
455,
530,
1324,
334,
262,
19441,
9246,
15,
83,
9,
272,
283,
273,
63,
1866,
356,
13960,
14,
16,
12,
272,
327,
1329,
402,
294,
279,
455,
530,
1279,
32073,
272,
283,
1507,
63,
273,
63,
685,
32073,
356,
1749,
996,
12,
272,
327,
1950,
19555,
402,
314,
294,
279,
455,
527,
370,
314,
3365,
4560,
21429,
272,
327,
334,
7191,
1865,
465,
315,
283,
1935,
21429,
7,
315,
283,
846,
63,
807,
358,
272,
283,
1631,
63,
15349,
63,
273,
356,
267,
980,
14,
1144,
779,
16,
14,
16,
12,
378,
14,
16,
12,
378,
14,
1643,
2658,
12,
378,
14,
1690,
1167,
12,
378,
14,
16,
12,
378,
14,
16,
12,
378,
14,
1717,
713,
12,
378,
14,
26978,
2522,
272,
327,
4615,
30727,
402,
314,
294,
279,
455,
530,
2963,
9466,
439,
764,
12330,
334,
262,
333,
54,
395,
272,
327,
4465,
18458,
911,
506,
9394,
687,
283,
846,
63,
807,
7,
272,
283,
5067,
48,
63,
273,
356,
378,
14,
1046,
12,
272,
327,
4615,
7339,
402,
314,
294,
279,
455,
530,
1324,
334,
262,
6605,
9,
272,
283,
5814,
63,
273,
63,
3670,
356,
413,
14,
21,
12,
272,
327,
3847,
4465,
18458,
402,
314,
294,
279,
455,
530,
7339,
334,
262,
6605,
9,
272,
283,
5814,
63,
273,
63,
3369,
63,
1516,
356,
378,
14,
21,
12,
339,
327,
2716,
30592,
1324,
272,
327,
7485,
30592,
1324,
641,
503,
2331,
334,
549,
503,
756,
9,
272,
283,
3833,
63,
1210,
356,
756,
12,
272,
327,
1343,
402,
314,
30592,
1324,
334,
262,
6605,
9,
272,
283,
3833,
63,
928,
356,
1227,
1400,
14,
16,
12,
272,
327,
7373,
402,
314,
30592,
1324,
334,
262,
6605,
9,
272,
283,
3833,
63,
30695,
356,
2948,
14,
16,
12,
272,
327,
30727,
402,
314,
30592,
1324,
334,
262,
299,
33,
2736,
4242,
30727,
365,
16423,
13,
6100,
272,
327,
436,
911,
506,
15884,
701,
24638,
543,
283,
43,
63,
832,
7,
272,
283,
3833,
63,
5282,
356,
378,
14,
19,
93,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
199,
3,
29965,
15909,
63,
1162,
14,
647,
199,
3,
199,
3,
961,
570,
365,
1777,
402,
28878,
14,
199,
3,
199,
3,
1898,
334,
35,
9,
8353,
710,
28878,
21412,
1905,
199,
3,
199,
3,
28878,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
652,
1334,
314,
2895,
402,
314,
1664,
1696,
1684,
844,
465,
3267,
701,
199,
3,
314,
2868,
2290,
2752,
12,
1902,
1015,
499,
402,
314,
844,
12,
503,
199,
3,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
28878,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
199,
3,
1664,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
1696,
1684,
844,
199,
3,
3180,
543,
28878,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
199,
624,
1611,
46,
1719,
27022,
18516,
26,
428,
2906,
15909,
3897,
199,
1444,
18964,
199,
199,
33,
2600,
543,
2633,
367,
376,
2716,
5957,
7115,
14928,
29965,
5332,
14,
199,
2719,
279,
455,
530,
1324,
436,
30592,
1324,
883,
506,
308,
28986,
641,
7814,
3163,
14,
199,
199,
624,
199,
199,
646,
2680,
465,
980,
199,
199,
31739,
63,
807,
275,
469,
272,
327,
2716,
294,
279,
455,
530,
1324,
272,
327,
7485,
294,
279,
455,
530,
1324,
641,
503,
2331,
334,
549,
503,
756,
9,
272,
283,
273,
279,
455,
530,
63,
1210,
356,
756,
12,
272,
327,
1343,
402,
314,
294,
279,
455,
530,
1324,
334,
262,
6605,
9,
272,
283,
273,
63,
928,
356,
30071,
14,
16,
12,
272,
327,
7373,
402,
314,
294,
279,
455,
530,
1324,
334,
262,
6605,
9,
272,
283,
273,
63,
5553,
356,
1616,
14,
16,
12,
272,
327,
6634,
402,
314,
294,
279,
455,
530,
1324,
334,
262,
19441,
9246,
15,
83,
9,
272,
283,
273,
63,
1866,
356,
13960,
14,
16,
12,
272,
327,
1329,
402,
294,
279,
455,
530,
1279,
32073,
272,
283,
1507,
63,
273,
63,
685,
32073,
356,
1749,
996,
12,
272,
327,
1950,
19555,
402,
314,
294,
279,
455,
527,
370,
314,
3365,
4560,
21429,
272,
327,
334,
7191,
1865,
465,
315,
283,
1935,
21429,
7,
315,
283,
846,
63,
807,
358,
272,
283,
1631,
63,
15349,
63,
273,
356,
267,
980,
14,
1144,
779,
16,
14,
16,
12,
378,
14,
16,
12,
378,
14,
1643,
2658,
12,
378,
14,
1690,
1167,
12,
378,
14,
16,
12,
378,
14,
16,
12,
378,
14,
1717,
713,
12,
378,
14,
26978,
2522,
272,
327,
4615,
30727,
402,
314,
294,
279,
455,
530,
2963,
9466,
439,
764,
12330,
334,
262,
333,
54,
395,
272,
327,
4465,
18458,
911,
506,
9394,
687,
283,
846,
63,
807,
7,
272,
283,
5067,
48,
63,
273,
356,
378,
14,
1046,
12,
272,
327,
4615,
7339,
402,
314,
294,
279,
455,
530,
1324,
334,
262,
6605,
9,
272,
283,
5814,
63,
273,
63,
3670,
356,
413,
14,
21,
12,
272,
327,
3847,
4465,
18458,
402,
314,
294,
279,
455,
530,
7339,
334,
262,
6605,
9,
272,
283,
5814,
63,
273,
63,
3369,
63,
1516,
356,
378,
14,
21,
12,
339,
327,
2716,
30592,
1324,
272,
327,
7485,
30592,
1324,
641,
503,
2331,
334,
549,
503,
756,
9,
272,
283,
3833,
63,
1210,
356,
756,
12,
272,
327,
1343,
402,
314,
30592,
1324,
334,
262,
6605,
9,
272,
283,
3833,
63,
928,
356,
1227,
1400,
14,
16,
12,
272,
327,
7373,
402,
314,
30592,
1324,
334,
262,
6605,
9,
272,
283,
3833,
63,
30695,
356,
2948,
14,
16,
12,
272,
327,
30727,
402,
314,
30592,
1324,
334,
262,
299,
33,
2736,
4242,
30727,
365,
16423,
13,
6100,
272,
327,
436,
911,
506,
15884,
701,
24638,
543,
283,
43,
63,
832,
7,
272,
283,
3833,
63,
5282,
356,
378,
14,
19,
93,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
PulsePod/old-www-do-not-use
|
lib/python2.7/site-packages/werkzeug/utils.py
|
317
|
22676
|
# -*- coding: utf-8 -*-
"""
werkzeug.utils
~~~~~~~~~~~~~~
This module implements various utilities for WSGI applications. Most of
them are used by the request and response wrappers but especially for
middleware development it makes sense to use them without the wrappers.
:copyright: (c) 2013 by the Werkzeug Team, see AUTHORS for more details.
:license: BSD, see LICENSE for more details.
"""
import re
import os
import sys
import pkgutil
try:
from html.entities import name2codepoint
except ImportError:
from htmlentitydefs import name2codepoint
from werkzeug._compat import unichr, text_type, string_types, iteritems, \
reraise, PY2
from werkzeug._internal import _DictAccessorProperty, \
_parse_signature, _missing
_format_re = re.compile(r'\$(?:(%s)|\{(%s)\})' % (('[a-zA-Z_][a-zA-Z0-9_]*',) * 2))
_entity_re = re.compile(r'&([^;]+);')
_filename_ascii_strip_re = re.compile(r'[^A-Za-z0-9_.-]')
_windows_device_files = ('CON', 'AUX', 'COM1', 'COM2', 'COM3', 'COM4', 'LPT1',
'LPT2', 'LPT3', 'PRN', 'NUL')
class cached_property(object):
"""A decorator that converts a function into a lazy property. The
function wrapped is called the first time to retrieve the result
and then that calculated result is used the next time you access
the value::
class Foo(object):
@cached_property
def foo(self):
# calculate something important here
return 42
The class has to have a `__dict__` in order for this property to
work.
"""
# implementation detail: this property is implemented as non-data
# descriptor. non-data descriptors are only invoked if there is
# no entry with the same name in the instance's __dict__.
# this allows us to completely get rid of the access function call
# overhead. If one choses to invoke __get__ by hand the property
# will still work as expected because the lookup logic is replicated
# in __get__ for manual invocation.
def __init__(self, func, name=None, doc=None):
self.__name__ = name or func.__name__
self.__module__ = func.__module__
self.__doc__ = doc or func.__doc__
self.func = func
def __get__(self, obj, type=None):
if obj is None:
return self
value = obj.__dict__.get(self.__name__, _missing)
if value is _missing:
value = self.func(obj)
obj.__dict__[self.__name__] = value
return value
class environ_property(_DictAccessorProperty):
"""Maps request attributes to environment variables. This works not only
for the Werzeug request object, but also any other class with an
environ attribute:
>>> class Test(object):
... environ = {'key': 'value'}
... test = environ_property('key')
>>> var = Test()
>>> var.test
'value'
If you pass it a second value it's used as default if the key does not
exist, the third one can be a converter that takes a value and converts
it. If it raises :exc:`ValueError` or :exc:`TypeError` the default value
is used. If no default value is provided `None` is used.
Per default the property is read only. You have to explicitly enable it
by passing ``read_only=False`` to the constructor.
"""
read_only = True
def lookup(self, obj):
return obj.environ
class header_property(_DictAccessorProperty):
"""Like `environ_property` but for headers."""
def lookup(self, obj):
return obj.headers
class HTMLBuilder(object):
"""Helper object for HTML generation.
Per default there are two instances of that class. The `html` one, and
the `xhtml` one for those two dialects. The class uses keyword parameters
and positional parameters to generate small snippets of HTML.
Keyword parameters are converted to XML/SGML attributes, positional
arguments are used as children. Because Python accepts positional
arguments before keyword arguments it's a good idea to use a list with the
star-syntax for some children:
>>> html.p(class_='foo', *[html.a('foo', href='foo.html'), ' ',
... html.a('bar', href='bar.html')])
u'<p class="foo"><a href="foo.html">foo</a> <a href="bar.html">bar</a></p>'
This class works around some browser limitations and can not be used for
arbitrary SGML/XML generation. For that purpose lxml and similar
libraries exist.
Calling the builder escapes the string passed:
>>> html.p(html("<foo>"))
u'<p><foo></p>'
"""
_entity_re = re.compile(r'&([^;]+);')
_entities = name2codepoint.copy()
_entities['apos'] = 39
_empty_elements = set([
'area', 'base', 'basefont', 'br', 'col', 'command', 'embed', 'frame',
'hr', 'img', 'input', 'keygen', 'isindex', 'link', 'meta', 'param',
'source', 'wbr'
])
_boolean_attributes = set([
'selected', 'checked', 'compact', 'declare', 'defer', 'disabled',
'ismap', 'multiple', 'nohref', 'noresize', 'noshade', 'nowrap'
])
_plaintext_elements = set(['textarea'])
_c_like_cdata = set(['script', 'style'])
def __init__(self, dialect):
self._dialect = dialect
def __call__(self, s):
return escape(s)
def __getattr__(self, tag):
if tag[:2] == '__':
raise AttributeError(tag)
def proxy(*children, **arguments):
buffer = '<' + tag
for key, value in iteritems(arguments):
if value is None:
continue
if key[-1] == '_':
key = key[:-1]
if key in self._boolean_attributes:
if not value:
continue
if self._dialect == 'xhtml':
value = '="' + key + '"'
else:
value = ''
else:
value = '="' + escape(value) + '"'
buffer += ' ' + key + value
if not children and tag in self._empty_elements:
if self._dialect == 'xhtml':
buffer += ' />'
else:
buffer += '>'
return buffer
buffer += '>'
children_as_string = ''.join([text_type(x) for x in children
if x is not None])
if children_as_string:
if tag in self._plaintext_elements:
children_as_string = escape(children_as_string)
elif tag in self._c_like_cdata and self._dialect == 'xhtml':
children_as_string = '/*<![CDATA[*/' + \
children_as_string + '/*]]>*/'
buffer += children_as_string + '</' + tag + '>'
return buffer
return proxy
def __repr__(self):
return '<%s for %r>' % (
self.__class__.__name__,
self._dialect
)
html = HTMLBuilder('html')
xhtml = HTMLBuilder('xhtml')
def get_content_type(mimetype, charset):
"""Return the full content type string with charset for a mimetype.
If the mimetype represents text the charset will be appended as charset
parameter, otherwise the mimetype is returned unchanged.
:param mimetype: the mimetype to be used as content type.
:param charset: the charset to be appended in case it was a text mimetype.
:return: the content type.
"""
if mimetype.startswith('text/') or \
mimetype == 'application/xml' or \
(mimetype.startswith('application/') and
mimetype.endswith('+xml')):
mimetype += '; charset=' + charset
return mimetype
def format_string(string, context):
"""String-template format a string:
>>> format_string('$foo and ${foo}s', dict(foo=42))
'42 and 42s'
This does not do any attribute lookup etc. For more advanced string
formattings have a look at the `werkzeug.template` module.
:param string: the format string.
:param context: a dict with the variables to insert.
"""
def lookup_arg(match):
x = context[match.group(1) or match.group(2)]
if not isinstance(x, string_types):
x = type(string)(x)
return x
return _format_re.sub(lookup_arg, string)
def secure_filename(filename):
r"""Pass it a filename and it will return a secure version of it. This
filename can then safely be stored on a regular file system and passed
to :func:`os.path.join`. The filename returned is an ASCII only string
for maximum portability.
On windows system the function also makes sure that the file is not
named after one of the special device files.
>>> secure_filename("My cool movie.mov")
'My_cool_movie.mov'
>>> secure_filename("../../../etc/passwd")
'etc_passwd'
>>> secure_filename(u'i contain cool \xfcml\xe4uts.txt')
'i_contain_cool_umlauts.txt'
The function might return an empty filename. It's your responsibility
to ensure that the filename is unique and that you generate random
filename if the function returned an empty one.
.. versionadded:: 0.5
:param filename: the filename to secure
"""
if isinstance(filename, text_type):
from unicodedata import normalize
filename = normalize('NFKD', filename).encode('ascii', 'ignore')
if not PY2:
filename = filename.decode('ascii')
for sep in os.path.sep, os.path.altsep:
if sep:
filename = filename.replace(sep, ' ')
filename = str(_filename_ascii_strip_re.sub('', '_'.join(
filename.split()))).strip('._')
# on nt a couple of special files are present in each folder. We
# have to ensure that the target file is not such a filename. In
# this case we prepend an underline
if os.name == 'nt' and filename and \
filename.split('.')[0].upper() in _windows_device_files:
filename = '_' + filename
return filename
def escape(s, quote=None):
"""Replace special characters "&", "<", ">" and (") to HTML-safe sequences.
There is a special handling for `None` which escapes to an empty string.
.. versionchanged:: 0.9
`quote` is now implicitly on.
:param s: the string to escape.
:param quote: ignored.
"""
if s is None:
return ''
elif hasattr(s, '__html__'):
return text_type(s.__html__())
elif not isinstance(s, string_types):
s = text_type(s)
if quote is not None:
from warnings import warn
warn(DeprecationWarning('quote parameter is implicit now'), stacklevel=2)
s = s.replace('&', '&').replace('<', '<') \
.replace('>', '>').replace('"', """)
return s
def unescape(s):
"""The reverse function of `escape`. This unescapes all the HTML
entities, not only the XML entities inserted by `escape`.
:param s: the string to unescape.
"""
def handle_match(m):
name = m.group(1)
if name in HTMLBuilder._entities:
return unichr(HTMLBuilder._entities[name])
try:
if name[:2] in ('#x', '#X'):
return unichr(int(name[2:], 16))
elif name.startswith('#'):
return unichr(int(name[1:]))
except ValueError:
pass
return u''
return _entity_re.sub(handle_match, s)
def redirect(location, code=302):
"""Return a response object (a WSGI application) that, if called,
redirects the client to the target location. Supported codes are 301,
302, 303, 305, and 307. 300 is not supported because it's not a real
redirect and 304 because it's the answer for a request with a request
with defined If-Modified-Since headers.
.. versionadded:: 0.6
The location can now be a unicode string that is encoded using
the :func:`iri_to_uri` function.
:param location: the location the response should redirect to.
:param code: the redirect status code. defaults to 302.
"""
from werkzeug.wrappers import Response
display_location = escape(location)
if isinstance(location, text_type):
from werkzeug.urls import iri_to_uri
location = iri_to_uri(location)
response = Response(
'<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">\n'
'<title>Redirecting...</title>\n'
'<h1>Redirecting...</h1>\n'
'<p>You should be redirected automatically to target URL: '
'<a href="%s">%s</a>. If not click the link.' %
(escape(location), display_location), code, mimetype='text/html')
response.headers['Location'] = location
return response
def append_slash_redirect(environ, code=301):
"""Redirect to the same URL but with a slash appended. The behavior
of this function is undefined if the path ends with a slash already.
:param environ: the WSGI environment for the request that triggers
the redirect.
:param code: the status code for the redirect.
"""
new_path = environ['PATH_INFO'].strip('/') + '/'
query_string = environ.get('QUERY_STRING')
if query_string:
new_path += '?' + query_string
return redirect(new_path, code)
def import_string(import_name, silent=False):
"""Imports an object based on a string. This is useful if you want to
use import paths as endpoints or something similar. An import path can
be specified either in dotted notation (``xml.sax.saxutils.escape``)
or with a colon as object delimiter (``xml.sax.saxutils:escape``).
If `silent` is True the return value will be `None` if the import fails.
:param import_name: the dotted name for the object to import.
:param silent: if set to `True` import errors are ignored and
`None` is returned instead.
:return: imported object
"""
#XXX: py3 review needed
assert isinstance(import_name, string_types)
# force the import name to automatically convert to strings
import_name = str(import_name)
try:
if ':' in import_name:
module, obj = import_name.split(':', 1)
elif '.' in import_name:
module, obj = import_name.rsplit('.', 1)
else:
return __import__(import_name)
# __import__ is not able to handle unicode strings in the fromlist
# if the module is a package
if PY2 and isinstance(obj, unicode):
obj = obj.encode('utf-8')
try:
return getattr(__import__(module, None, None, [obj]), obj)
except (ImportError, AttributeError):
# support importing modules not yet set up by the parent module
# (or package for that matter)
modname = module + '.' + obj
__import__(modname)
return sys.modules[modname]
except ImportError as e:
if not silent:
reraise(
ImportStringError,
ImportStringError(import_name, e),
sys.exc_info()[2])
def find_modules(import_path, include_packages=False, recursive=False):
"""Find all the modules below a package. This can be useful to
automatically import all views / controllers so that their metaclasses /
function decorators have a chance to register themselves on the
application.
Packages are not returned unless `include_packages` is `True`. This can
also recursively list modules but in that case it will import all the
packages to get the correct load path of that module.
:param import_name: the dotted name for the package to find child modules.
:param include_packages: set to `True` if packages should be returned, too.
:param recursive: set to `True` if recursion should happen.
:return: generator
"""
module = import_string(import_path)
path = getattr(module, '__path__', None)
if path is None:
raise ValueError('%r is not a package' % import_path)
basename = module.__name__ + '.'
for importer, modname, ispkg in pkgutil.iter_modules(path):
modname = basename + modname
if ispkg:
if include_packages:
yield modname
if recursive:
for item in find_modules(modname, include_packages, True):
yield item
else:
yield modname
def validate_arguments(func, args, kwargs, drop_extra=True):
"""Check if the function accepts the arguments and keyword arguments.
Returns a new ``(args, kwargs)`` tuple that can safely be passed to
the function without causing a `TypeError` because the function signature
is incompatible. If `drop_extra` is set to `True` (which is the default)
any extra positional or keyword arguments are dropped automatically.
The exception raised provides three attributes:
`missing`
A set of argument names that the function expected but where
missing.
`extra`
A dict of keyword arguments that the function can not handle but
where provided.
`extra_positional`
A list of values that where given by positional argument but the
function cannot accept.
This can be useful for decorators that forward user submitted data to
a view function::
from werkzeug.utils import ArgumentValidationError, validate_arguments
def sanitize(f):
def proxy(request):
data = request.values.to_dict()
try:
args, kwargs = validate_arguments(f, (request,), data)
except ArgumentValidationError:
raise BadRequest('The browser failed to transmit all '
'the data expected.')
return f(*args, **kwargs)
return proxy
:param func: the function the validation is performed against.
:param args: a tuple of positional arguments.
:param kwargs: a dict of keyword arguments.
:param drop_extra: set to `False` if you don't want extra arguments
to be silently dropped.
:return: tuple in the form ``(args, kwargs)``.
"""
parser = _parse_signature(func)
args, kwargs, missing, extra, extra_positional = parser(args, kwargs)[:5]
if missing:
raise ArgumentValidationError(tuple(missing))
elif (extra or extra_positional) and not drop_extra:
raise ArgumentValidationError(None, extra, extra_positional)
return tuple(args), kwargs
def bind_arguments(func, args, kwargs):
"""Bind the arguments provided into a dict. When passed a function,
a tuple of arguments and a dict of keyword arguments `bind_arguments`
returns a dict of names as the function would see it. This can be useful
to implement a cache decorator that uses the function arguments to build
the cache key based on the values of the arguments.
:param func: the function the arguments should be bound for.
:param args: tuple of positional arguments.
:param kwargs: a dict of keyword arguments.
:return: a :class:`dict` of bound keyword arguments.
"""
args, kwargs, missing, extra, extra_positional, \
arg_spec, vararg_var, kwarg_var = _parse_signature(func)(args, kwargs)
values = {}
for (name, has_default, default), value in zip(arg_spec, args):
values[name] = value
if vararg_var is not None:
values[vararg_var] = tuple(extra_positional)
elif extra_positional:
raise TypeError('too many positional arguments')
if kwarg_var is not None:
multikw = set(extra) & set([x[0] for x in arg_spec])
if multikw:
raise TypeError('got multiple values for keyword argument ' +
repr(next(iter(multikw))))
values[kwarg_var] = extra
elif extra:
raise TypeError('got unexpected keyword argument ' +
repr(next(iter(extra))))
return values
class ArgumentValidationError(ValueError):
"""Raised if :func:`validate_arguments` fails to validate"""
def __init__(self, missing=None, extra=None, extra_positional=None):
self.missing = set(missing or ())
self.extra = extra or {}
self.extra_positional = extra_positional or []
ValueError.__init__(self, 'function arguments invalid. ('
'%d missing, %d additional)' % (
len(self.missing),
len(self.extra) + len(self.extra_positional)
))
class ImportStringError(ImportError):
"""Provides information about a failed :func:`import_string` attempt."""
#: String in dotted notation that failed to be imported.
import_name = None
#: Wrapped exception.
exception = None
def __init__(self, import_name, exception):
self.import_name = import_name
self.exception = exception
msg = (
'import_string() failed for %r. Possible reasons are:\n\n'
'- missing __init__.py in a package;\n'
'- package or module path not included in sys.path;\n'
'- duplicated package or module name taking precedence in '
'sys.path;\n'
'- missing module, class, function or variable;\n\n'
'Debugged import:\n\n%s\n\n'
'Original exception:\n\n%s: %s')
name = ''
tracked = []
for part in import_name.replace(':', '.').split('.'):
name += (name and '.') + part
imported = import_string(name, silent=True)
if imported:
tracked.append((name, getattr(imported, '__file__', None)))
else:
track = ['- %r found in %r.' % (n, i) for n, i in tracked]
track.append('- %r not found.' % name)
msg = msg % (import_name, '\n'.join(track),
exception.__class__.__name__, str(exception))
break
ImportError.__init__(self, msg)
def __repr__(self):
return '<%s(%r, %r)>' % (self.__class__.__name__, self.import_name,
self.exception)
# circular dependencies
from werkzeug.http import quote_header_value, unquote_header_value, \
cookie_date
# DEPRECATED
# these objects were previously in this module as well. we import
# them here for backwards compatibility with old pickles.
from werkzeug.datastructures import MultiDict, CombinedMultiDict, \
Headers, EnvironHeaders
from werkzeug.http import parse_cookie, dump_cookie
|
mit
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
624,
272,
10380,
14,
1208,
272,
32202,
1714,
339,
961,
859,
9031,
7750,
15841,
367,
9279,
13103,
14,
221,
17536,
402,
272,
3062,
787,
1202,
701,
314,
1056,
436,
1177,
17995,
1325,
24002,
367,
272,
10816,
16367,
652,
7704,
12249,
370,
675,
3062,
1928,
314,
17995,
14,
339,
520,
7307,
26,
334,
67,
9,
6171,
701,
314,
22798,
11682,
12,
1937,
10610,
367,
1655,
2436,
14,
272,
520,
1682,
26,
6289,
12,
1937,
5113,
367,
1655,
2436,
14,
199,
624,
199,
646,
295,
199,
646,
747,
199,
646,
984,
199,
646,
28728,
199,
893,
26,
272,
687,
3517,
14,
8327,
492,
536,
18,
19300,
199,
2590,
3545,
26,
272,
687,
30010,
552,
1701,
8710,
492,
536,
18,
19300,
199,
199,
504,
10380,
423,
5819,
492,
17742,
12,
1318,
63,
466,
12,
1059,
63,
1313,
12,
10849,
12,
971,
272,
24139,
12,
7843,
18,
199,
504,
10380,
423,
4672,
492,
485,
2141,
5742,
3697,
12,
971,
1362,
485,
1122,
63,
5233,
12,
485,
4752,
421,
199,
63,
908,
63,
264,
275,
295,
14,
2014,
8,
82,
1154,
4,
5169,
4042,
83,
9,
6113,
91,
4042,
83,
2862,
29668,
450,
334,
11894,
65,
13,
6353,
13,
58,
17900,
65,
13,
6353,
13,
58,
16,
13,
25,
15555,
9538,
627,
499,
430,
199,
63,
4502,
63,
264,
275,
295,
14,
2014,
8,
82,
21840,
7059,
27,
2807,
2736,
358,
199,
63,
1501,
63,
4371,
63,
1913,
63,
264,
275,
295,
14,
2014,
8,
82,
16122,
33,
13,
13163,
13,
90,
16,
13,
25,
3754,
13,
10374,
199,
63,
8258,
63,
1782,
63,
1725,
275,
661,
1864,
297,
283,
9331,
56,
297,
283,
11265,
17,
297,
283,
11265,
18,
297,
283,
11265,
19,
297,
283,
11265,
20,
297,
283,
44,
4189,
17,
297,
586,
283,
44,
4189,
18,
297,
283,
44,
4189,
19,
297,
283,
3311,
46,
297,
283,
46,
1293,
358,
421,
199,
533,
6328,
63,
1829,
8,
785,
304,
272,
408,
33,
7531,
626,
15373,
282,
805,
1901,
282,
9617,
3324,
14,
221,
710,
272,
805,
8072,
365,
2797,
314,
1642,
900,
370,
8044,
314,
754,
272,
436,
2066,
626,
12950,
754,
365,
1202,
314,
2163,
900,
1265,
2879,
272,
314,
574,
447,
398,
1021,
8024,
8,
785,
304,
953,
768,
5245,
63,
1829,
288,
347,
3925,
8,
277,
304,
355,
327,
8671,
6020,
11012,
2348,
355,
372,
5685,
339,
710,
1021,
965,
370,
1172,
282,
26856,
807,
29341,
315,
1865,
367,
642,
3324,
370,
272,
1736,
14,
272,
408,
339,
327,
4514,
10093,
26,
642,
3324,
365,
6366,
465,
2222,
13,
576,
272,
327,
5872,
14,
221,
2222,
13,
576,
15428,
787,
1454,
10302,
340,
2337,
365,
272,
327,
949,
2397,
543,
314,
2011,
536,
315,
314,
1256,
1159,
636,
807,
4343,
272,
327,
642,
6127,
2739,
370,
14793,
664,
16146,
402,
314,
2879,
805,
1240,
272,
327,
24075,
14,
221,
982,
1373,
2468,
874,
370,
12677,
636,
362,
363,
701,
4926,
314,
3324,
272,
327,
911,
5139,
1736,
465,
1420,
2952,
314,
4237,
9661,
365,
32436,
272,
327,
315,
636,
362,
363,
367,
8722,
19569,
14,
339,
347,
636,
826,
721,
277,
12,
2562,
12,
536,
29,
403,
12,
1382,
29,
403,
304,
267,
291,
855,
354,
363,
275,
536,
503,
2562,
855,
354,
363,
267,
291,
855,
578,
363,
275,
2562,
855,
578,
363,
267,
291,
855,
1301,
363,
275,
1382,
503,
2562,
855,
1301,
363,
267,
291,
14,
1532,
275,
2562,
339,
347,
636,
362,
721,
277,
12,
1559,
12,
730,
29,
403,
304,
267,
340,
1559,
365,
488,
26,
288,
372,
291,
267,
574,
275,
1559,
855,
807,
4343,
362,
8,
277,
855,
354,
3108,
485,
4752,
9,
267,
340,
574,
365,
485,
4752,
26,
288,
574,
275,
291,
14,
1532,
8,
1113,
9,
288,
1559,
855,
807,
12298,
277,
855,
354,
22705,
275,
574,
267,
372,
574,
421,
199,
533,
6160,
63,
1829,
1547,
2141,
5742,
3697,
304,
272,
408,
24995,
1056,
3004,
370,
3734,
2860,
14,
961,
5419,
440,
1454,
272,
367,
314,
644,
281,
7479,
1056,
909,
12,
1325,
2597,
1263,
1163,
1021,
543,
376,
272,
6160,
2225,
26,
339,
1306,
1021,
1379,
8,
785,
304,
272,
2263,
258,
6160,
275,
791,
498,
356,
283,
585,
936,
272,
2263,
258,
511,
275,
6160,
63,
1829,
360,
498,
358,
272,
1306,
2729,
275,
1379,
342,
272,
1306,
2729,
14,
396,
272,
283,
585,
7,
339,
982,
1265,
986,
652,
282,
3499,
574,
652,
1159,
1202,
465,
849,
340,
314,
790,
1630,
440,
272,
2187,
12,
314,
10919,
1373,
883,
506,
282,
11109,
626,
6181,
282,
574,
436,
15373,
272,
652,
14,
221,
982,
652,
6534,
520,
2804,
1705,
3393,
64,
503,
520,
2804,
1705,
4333,
64,
314,
849,
574,
272,
365,
1202,
14,
982,
949,
849,
574,
365,
2741,
658,
403,
64,
365,
1202,
14,
339,
3492,
849,
314,
3324,
365,
1586,
1454,
14,
221,
2047,
1172,
370,
7662,
4756,
652,
272,
701,
9476,
1124,
739,
63,
2118,
29,
797,
1040,
370,
314,
3787,
14,
272,
408,
339,
1586,
63,
2118,
275,
715,
339,
347,
4237,
8,
277,
12,
1559,
304,
267,
372,
1559,
14,
2314,
421,
199,
533,
1406,
63,
1829,
1547,
2141,
5742,
3697,
304,
272,
408,
12545,
658,
2314,
63,
1829,
64,
1325,
367,
2323,
1041,
339,
347,
4237,
8,
277,
12,
1559,
304,
267,
372,
1559,
14,
2139,
421,
199,
533,
4163,
6437,
8,
785,
304,
272,
408,
4433,
909,
367,
4163,
10152,
14,
339,
3492,
849,
2337,
787,
2877,
4454,
402,
626,
1021,
14,
221,
710,
658,
1360,
64,
1373,
12,
436,
272,
314,
658,
12909,
64,
1373,
367,
5204,
2877,
10982,
83,
14,
221,
710,
1021,
4440,
4252,
2633,
272,
436,
11333,
2633,
370,
3550,
7425,
19484,
402,
4163,
14,
339,
6431,
2633,
787,
6702,
370,
4692,
15,
4254,
1698,
3004,
12,
11333,
272,
2368,
787,
1202,
465,
4978,
14,
221,
13821,
2018,
11479,
11333,
272,
2368,
2544,
4252,
2368,
652,
1159,
282,
6954,
16819,
370,
675,
282,
769,
543,
314,
272,
14664,
13,
7093,
367,
2005,
4978,
26,
339,
1306,
3517,
14,
80,
8,
533,
7993,
1421,
297,
627,
59,
1360,
14,
65,
360,
1421,
297,
4369,
534,
1421,
14,
1360,
659,
283
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
624,
272,
10380,
14,
1208,
272,
32202,
1714,
339,
961,
859,
9031,
7750,
15841,
367,
9279,
13103,
14,
221,
17536,
402,
272,
3062,
787,
1202,
701,
314,
1056,
436,
1177,
17995,
1325,
24002,
367,
272,
10816,
16367,
652,
7704,
12249,
370,
675,
3062,
1928,
314,
17995,
14,
339,
520,
7307,
26,
334,
67,
9,
6171,
701,
314,
22798,
11682,
12,
1937,
10610,
367,
1655,
2436,
14,
272,
520,
1682,
26,
6289,
12,
1937,
5113,
367,
1655,
2436,
14,
199,
624,
199,
646,
295,
199,
646,
747,
199,
646,
984,
199,
646,
28728,
199,
893,
26,
272,
687,
3517,
14,
8327,
492,
536,
18,
19300,
199,
2590,
3545,
26,
272,
687,
30010,
552,
1701,
8710,
492,
536,
18,
19300,
199,
199,
504,
10380,
423,
5819,
492,
17742,
12,
1318,
63,
466,
12,
1059,
63,
1313,
12,
10849,
12,
971,
272,
24139,
12,
7843,
18,
199,
504,
10380,
423,
4672,
492,
485,
2141,
5742,
3697,
12,
971,
1362,
485,
1122,
63,
5233,
12,
485,
4752,
421,
199,
63,
908,
63,
264,
275,
295,
14,
2014,
8,
82,
1154,
4,
5169,
4042,
83,
9,
6113,
91,
4042,
83,
2862,
29668,
450,
334,
11894,
65,
13,
6353,
13,
58,
17900,
65,
13,
6353,
13,
58,
16,
13,
25,
15555,
9538,
627,
499,
430,
199,
63,
4502,
63,
264,
275,
295,
14,
2014,
8,
82,
21840,
7059,
27,
2807,
2736,
358,
199,
63,
1501,
63,
4371,
63,
1913,
63,
264,
275,
295,
14,
2014,
8,
82,
16122,
33,
13,
13163,
13,
90,
16,
13,
25,
3754,
13,
10374,
199,
63,
8258,
63,
1782,
63,
1725,
275,
661,
1864,
297,
283,
9331,
56,
297,
283,
11265,
17,
297,
283,
11265,
18,
297,
283,
11265,
19,
297,
283,
11265,
20,
297,
283,
44,
4189,
17,
297,
586,
283,
44,
4189,
18,
297,
283,
44,
4189,
19,
297,
283,
3311,
46,
297,
283,
46,
1293,
358,
421,
199,
533,
6328,
63,
1829,
8,
785,
304,
272,
408,
33,
7531,
626,
15373,
282,
805,
1901,
282,
9617,
3324,
14,
221,
710,
272,
805,
8072,
365,
2797,
314,
1642,
900,
370,
8044,
314,
754,
272,
436,
2066,
626,
12950,
754,
365,
1202,
314,
2163,
900,
1265,
2879,
272,
314,
574,
447,
398,
1021,
8024,
8,
785,
304,
953,
768,
5245,
63,
1829,
288,
347,
3925,
8,
277,
304,
355,
327,
8671,
6020,
11012,
2348,
355,
372,
5685,
339,
710,
1021,
965,
370,
1172,
282,
26856,
807,
29341,
315,
1865,
367,
642,
3324,
370,
272,
1736,
14,
272,
408,
339,
327,
4514,
10093,
26,
642,
3324,
365,
6366,
465,
2222,
13,
576,
272,
327,
5872,
14,
221,
2222,
13,
576,
15428,
787,
1454,
10302,
340,
2337,
365,
272,
327,
949,
2397,
543,
314,
2011,
536,
315,
314,
1256,
1159,
636,
807,
4343,
272,
327,
642,
6127,
2739,
370,
14793,
664,
16146,
402,
314,
2879,
805,
1240,
272,
327,
24075,
14,
221,
982,
1373,
2468,
874,
370,
12677,
636,
362,
363,
701,
4926,
314,
3324,
272,
327,
911,
5139,
1736,
465,
1420,
2952,
314,
4237,
9661,
365,
32436,
272,
327,
315,
636,
362,
363,
367,
8722,
19569,
14,
339,
347,
636,
826,
721,
277,
12,
2562,
12,
536,
29,
403,
12,
1382,
29,
403,
304,
267,
291,
855,
354,
363,
275,
536,
503,
2562,
855,
354,
363,
267,
291,
855,
578,
363,
275,
2562,
855,
578,
363,
267,
291,
855,
1301,
363,
275,
1382,
503,
2562,
855,
1301,
363,
267,
291,
14,
1532,
275,
2562,
339,
347,
636,
362,
721,
277,
12,
1559,
12,
730,
29,
403,
304,
267,
340,
1559,
365,
488,
26,
288,
372,
291,
267,
574,
275,
1559,
855,
807,
4343,
362,
8,
277,
855,
354,
3108,
485,
4752,
9,
267,
340,
574,
365,
485,
4752,
26,
288,
574,
275,
291,
14,
1532,
8,
1113,
9,
288,
1559,
855,
807,
12298,
277,
855,
354,
22705,
275,
574,
267,
372,
574,
421,
199,
533,
6160,
63,
1829,
1547,
2141,
5742,
3697,
304,
272,
408,
24995,
1056,
3004,
370,
3734,
2860,
14,
961,
5419,
440,
1454,
272,
367,
314,
644,
281,
7479,
1056,
909,
12,
1325,
2597,
1263,
1163,
1021,
543,
376,
272,
6160,
2225,
26,
339,
1306,
1021,
1379,
8,
785,
304,
272,
2263,
258,
6160,
275,
791,
498,
356,
283,
585,
936,
272,
2263,
258,
511,
275,
6160,
63,
1829,
360,
498,
358,
272,
1306,
2729,
275,
1379,
342,
272,
1306,
2729,
14,
396,
272,
283,
585,
7,
339,
982,
1265,
986,
652,
282,
3499,
574,
652,
1159,
1202,
465,
849,
340,
314,
790,
1630,
440,
272,
2187,
12,
314,
10919,
1373,
883,
506,
282,
11109,
626,
6181,
282,
574,
436,
15373,
272,
652,
14,
221,
982,
652,
6534,
520,
2804,
1705,
3393,
64,
503,
520,
2804,
1705,
4333,
64,
314,
849,
574,
272,
365,
1202,
14,
982,
949,
849,
574,
365,
2741,
658,
403,
64,
365,
1202,
14,
339,
3492,
849,
314,
3324,
365,
1586,
1454,
14,
221,
2047,
1172,
370,
7662,
4756,
652,
272,
701,
9476,
1124,
739,
63,
2118,
29,
797,
1040,
370,
314,
3787,
14,
272,
408,
339,
1586,
63,
2118,
275,
715,
339,
347,
4237,
8,
277,
12,
1559,
304,
267,
372,
1559,
14,
2314,
421,
199,
533,
1406,
63,
1829,
1547,
2141,
5742,
3697,
304,
272,
408,
12545,
658,
2314,
63,
1829,
64,
1325,
367,
2323,
1041,
339,
347,
4237,
8,
277,
12,
1559,
304,
267,
372,
1559,
14,
2139,
421,
199,
533,
4163,
6437,
8,
785,
304,
272,
408,
4433,
909,
367,
4163,
10152,
14,
339,
3492,
849,
2337,
787,
2877,
4454,
402,
626,
1021,
14,
221,
710,
658,
1360,
64,
1373,
12,
436,
272,
314,
658,
12909,
64,
1373,
367,
5204,
2877,
10982,
83,
14,
221,
710,
1021,
4440,
4252,
2633,
272,
436,
11333,
2633,
370,
3550,
7425,
19484,
402,
4163,
14,
339,
6431,
2633,
787,
6702,
370,
4692,
15,
4254,
1698,
3004,
12,
11333,
272,
2368,
787,
1202,
465,
4978,
14,
221,
13821,
2018,
11479,
11333,
272,
2368,
2544,
4252,
2368,
652,
1159,
282,
6954,
16819,
370,
675,
282,
769,
543,
314,
272,
14664,
13,
7093,
367,
2005,
4978,
26,
339,
1306,
3517,
14,
80,
8,
533,
7993,
1421,
297,
627,
59,
1360,
14,
65,
360,
1421,
297,
4369,
534,
1421,
14,
1360,
659,
283,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
repotvsupertuga/repo
|
plugin.video.jami/resources/lib/resolvers/videomega.py
|
7
|
2305
|
# -*- coding: utf-8 -*-
'''
Specto Add-on
Copyright (C) 2015 lambda
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
'''
import urlparse,re
from resources.lib.libraries import client
from resources.lib.libraries import control
from resources.lib.libraries import jsunpack
def resolve(url):
try:
url = urlparse.urlparse(url).query
url = urlparse.parse_qsl(url)[0][1]
url = 'http://videomega.tv/cdn.php?ref=%s' % url
#control.log("### VIDEOMEGA RES %s" % url)
result = client.request(url, mobile=True)
#control.log("### VIDEOMEGA RES %s" % result)
result = re.compile('eval.*?{}\)\)').findall(result)[-1]
#control.log("### VIDEOMEGA RES2 %s" % result)
result = jsunpack.unpack(result)
#control.log("### VIDEOMEGA RE3 %s" % result)
#"src", "http://abo.cdn.vizplay.org/m2/769a65801d8e8a110452f2b74d4082d1.mp4?st=-A2O2o2soMR81Niiag5EyA&hash=Dw8Kth5gh-nNyMRbWLZMKA"
url = re.compile('"src","(.*?)"').findall(result)[-1]
control.log("### VIDEOMEGA RE4 %s" % url)
return url
except:
return
def check(url):
try:
url = urlparse.urlparse(url).query
url = urlparse.parse_qsl(url)[0][1]
url = 'http://videomega.tv/cdn.php?ref=%s' % url
result = client.request(url, mobile=True)
result = re.compile('eval.*?{}\)\)').findall(result)[-1]
result = jsunpack.unpack(result)
url = re.compile('"src","(.*?)"').findall(result)[-1]
control.log("### VIDEOMEGA RE3 1111111111 %s" % url)
if url.startswith('http://N/D/m/'): return False
return True
except:
return False
|
gpl-2.0
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
199,
2344,
272,
428,
1764,
79,
2654,
13,
265,
272,
1898,
334,
35,
9,
6900,
2400,
339,
961,
2240,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
272,
652,
1334,
314,
2895,
402,
314,
1664,
1696,
1684,
844,
465,
3267,
701,
272,
314,
2868,
2290,
2752,
12,
1902,
1015,
650,
402,
314,
844,
12,
503,
272,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
339,
961,
2240,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
272,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
272,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
272,
1664,
1696,
1684,
844,
367,
1655,
2436,
14,
339,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
1696,
1684,
844,
272,
3180,
543,
642,
2240,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
2344,
421,
199,
646,
7097,
12,
264,
199,
504,
5944,
14,
773,
14,
10159,
492,
1890,
199,
504,
5944,
14,
773,
14,
10159,
492,
3304,
199,
504,
5944,
14,
773,
14,
10159,
492,
8586,
5301,
4388,
199,
318,
7512,
8,
633,
304,
272,
862,
26,
267,
1166,
275,
7097,
14,
10290,
8,
633,
680,
1131,
267,
1166,
275,
7097,
14,
1122,
63,
26714,
8,
633,
2788,
16,
1527,
17,
61,
267,
1166,
275,
283,
1014,
921,
5624,
23524,
14,
6993,
15,
23982,
14,
8624,
31,
1121,
2458,
83,
7,
450,
1166,
267,
327,
2785,
14,
793,
480,
5680,
812,
11259,
47,
31724,
12565,
450,
83,
2,
450,
1166,
9,
267,
754,
275,
1890,
14,
1069,
8,
633,
12,
21305,
29,
549,
9,
267,
327,
2785,
14,
793,
480,
5680,
812,
11259,
47,
31724,
12565,
450,
83,
2,
450,
754,
9,
267,
754,
275,
295,
14,
2014,
360,
2579,
6697,
2440,
13670,
9,
1959,
6452,
8,
1099,
15786,
17,
61,
267,
327,
2785,
14,
793,
480,
5680,
812,
11259,
47,
31724,
12565,
18,
450,
83,
2,
450,
754,
9,
267,
754,
275,
8586,
5301,
14,
5301,
8,
1099,
9,
267,
327,
2785,
14,
793,
480,
5680,
812,
11259,
47,
31724,
5363,
19,
450,
83,
2,
450,
754,
9,
267,
20383,
2164,
401,
298,
1014,
921,
13113,
14,
23982,
14,
17249,
2802,
14,
1308,
15,
77,
18,
15,
16165,
65,
28133,
614,
68,
24,
69,
24,
65,
6019,
24049,
70,
18,
66,
1342,
68,
20,
19171,
68,
17,
14,
311,
20,
31,
270,
4022,
33,
18,
47,
18,
79,
18,
1152,
22153,
2835,
46,
5908,
643,
21,
37,
89,
33,
6,
2227,
29,
36,
87,
24,
43,
273,
21,
3561,
13,
78,
22781,
22153,
66,
55,
44,
58,
18379,
33,
2,
267,
1166,
275,
295,
14,
2014,
14088,
2164,
2266,
17140,
2924,
1959,
6452,
8,
1099,
15786,
17,
61,
267,
3304,
14,
793,
480,
5680,
812,
11259,
47,
31724,
5363,
20,
450,
83,
2,
450,
1166,
9,
267,
372,
1166,
272,
871,
26,
267,
372,
199,
199,
318,
1104,
8,
633,
304,
272,
862,
26,
267,
1166,
275,
7097,
14,
10290,
8,
633,
680,
1131,
267,
1166,
275,
7097,
14,
1122,
63,
26714,
8,
633,
2788,
16,
1527,
17,
61,
267,
1166,
275,
283,
1014,
921,
5624,
23524,
14,
6993,
15,
23982,
14,
8624,
31,
1121,
2458,
83,
7,
450,
1166,
267,
754,
275,
1890,
14,
1069,
8,
633,
12,
21305,
29,
549,
9,
267,
754,
275,
295,
14,
2014,
360,
2579,
6697,
2440,
13670,
9,
1959,
6452,
8,
1099,
15786,
17,
61,
267,
754,
275,
8586,
5301,
14,
5301,
8,
1099,
9,
267,
1166,
275,
295,
14,
2014,
14088,
2164,
2266,
17140,
2924,
1959,
6452,
8,
1099,
15786,
17,
61,
267,
3304,
14,
793,
480,
5680,
812,
11259,
47,
31724,
5363,
19,
7861,
413,
6984,
845,
6673,
221,
450,
83,
2,
450,
1166,
9,
267,
340,
1166,
14,
2460,
360,
1014,
921,
46,
15,
36,
15,
77,
26985,
372,
756,
267,
372,
715,
272,
871,
26,
267,
372,
756,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
199,
2344,
272,
428,
1764,
79,
2654,
13,
265,
272,
1898,
334,
35,
9,
6900,
2400,
339,
961,
2240,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
272,
652,
1334,
314,
2895,
402,
314,
1664,
1696,
1684,
844,
465,
3267,
701,
272,
314,
2868,
2290,
2752,
12,
1902,
1015,
650,
402,
314,
844,
12,
503,
272,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
339,
961,
2240,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
272,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
272,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
272,
1664,
1696,
1684,
844,
367,
1655,
2436,
14,
339,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
1696,
1684,
844,
272,
3180,
543,
642,
2240,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
2344,
421,
199,
646,
7097,
12,
264,
199,
504,
5944,
14,
773,
14,
10159,
492,
1890,
199,
504,
5944,
14,
773,
14,
10159,
492,
3304,
199,
504,
5944,
14,
773,
14,
10159,
492,
8586,
5301,
4388,
199,
318,
7512,
8,
633,
304,
272,
862,
26,
267,
1166,
275,
7097,
14,
10290,
8,
633,
680,
1131,
267,
1166,
275,
7097,
14,
1122,
63,
26714,
8,
633,
2788,
16,
1527,
17,
61,
267,
1166,
275,
283,
1014,
921,
5624,
23524,
14,
6993,
15,
23982,
14,
8624,
31,
1121,
2458,
83,
7,
450,
1166,
267,
327,
2785,
14,
793,
480,
5680,
812,
11259,
47,
31724,
12565,
450,
83,
2,
450,
1166,
9,
267,
754,
275,
1890,
14,
1069,
8,
633,
12,
21305,
29,
549,
9,
267,
327,
2785,
14,
793,
480,
5680,
812,
11259,
47,
31724,
12565,
450,
83,
2,
450,
754,
9,
267,
754,
275,
295,
14,
2014,
360,
2579,
6697,
2440,
13670,
9,
1959,
6452,
8,
1099,
15786,
17,
61,
267,
327,
2785,
14,
793,
480,
5680,
812,
11259,
47,
31724,
12565,
18,
450,
83,
2,
450,
754,
9,
267,
754,
275,
8586,
5301,
14,
5301,
8,
1099,
9,
267,
327,
2785,
14,
793,
480,
5680,
812,
11259,
47,
31724,
5363,
19,
450,
83,
2,
450,
754,
9,
267,
20383,
2164,
401,
298,
1014,
921,
13113,
14,
23982,
14,
17249,
2802,
14,
1308,
15,
77,
18,
15,
16165,
65,
28133,
614,
68,
24,
69,
24,
65,
6019,
24049,
70,
18,
66,
1342,
68,
20,
19171,
68,
17,
14,
311,
20,
31,
270,
4022,
33,
18,
47,
18,
79,
18,
1152,
22153,
2835,
46,
5908,
643,
21,
37,
89,
33,
6,
2227,
29,
36,
87,
24,
43,
273,
21,
3561,
13,
78,
22781,
22153,
66,
55,
44,
58,
18379,
33,
2,
267,
1166,
275,
295,
14,
2014,
14088,
2164,
2266,
17140,
2924,
1959,
6452,
8,
1099,
15786,
17,
61,
267,
3304,
14,
793,
480,
5680,
812,
11259,
47,
31724,
5363,
20,
450,
83,
2,
450,
1166,
9,
267,
372,
1166,
272,
871,
26,
267,
372,
199,
199,
318,
1104,
8,
633,
304,
272,
862,
26,
267,
1166,
275,
7097,
14,
10290,
8,
633,
680,
1131,
267,
1166,
275,
7097,
14,
1122,
63,
26714,
8,
633,
2788,
16,
1527,
17,
61,
267,
1166,
275,
283,
1014,
921,
5624,
23524,
14,
6993,
15,
23982,
14,
8624,
31,
1121,
2458,
83,
7,
450,
1166,
267,
754,
275,
1890,
14,
1069,
8,
633,
12,
21305,
29,
549,
9,
267,
754,
275,
295,
14,
2014,
360,
2579,
6697,
2440,
13670,
9,
1959,
6452,
8,
1099,
15786,
17,
61,
267,
754,
275,
8586,
5301,
14,
5301,
8,
1099,
9,
267,
1166,
275,
295,
14,
2014,
14088,
2164,
2266,
17140,
2924,
1959,
6452,
8,
1099,
15786,
17,
61,
267,
3304,
14,
793,
480,
5680,
812,
11259,
47,
31724,
5363,
19,
7861,
413,
6984,
845,
6673,
221,
450,
83,
2,
450,
1166,
9,
267,
340,
1166,
14,
2460,
360,
1014,
921,
46,
15,
36,
15,
77,
26985,
372,
756,
267,
372,
715,
272,
871,
26,
267,
372,
756,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
andybarry/ardupilot
|
Tools/autotest/arduplane.py
|
2
|
10433
|
# fly ArduPlane in SIL
import util, pexpect, sys, time, math, shutil, os
from common import *
import mavutil, random
# get location of scripts
testdir=os.path.dirname(os.path.realpath(__file__))
HOME_LOCATION='-35.362938,149.165085,585,354'
WIND="0,180,0.2" # speed,direction,variance
homeloc = None
def takeoff(mavproxy, mav):
'''takeoff get to 30m altitude'''
mavproxy.send('switch 4\n')
wait_mode(mav, 'FBWA')
# some rudder to counteract the prop torque
mavproxy.send('rc 4 1700\n')
# some up elevator to keep the tail down
mavproxy.send('rc 2 1200\n')
# get it moving a bit first
mavproxy.send('rc 3 1300\n')
mav.recv_match(condition='VFR_HUD.groundspeed>6', blocking=True)
# a bit faster again, straighten rudder
mavproxy.send('rc 3 1600\n')
mavproxy.send('rc 4 1500\n')
mav.recv_match(condition='VFR_HUD.groundspeed>12', blocking=True)
# hit the gas harder now, and give it some more elevator
mavproxy.send('rc 2 1100\n')
mavproxy.send('rc 3 1800\n')
# gain a bit of altitude
if not wait_altitude(mav, homeloc.alt+30, homeloc.alt+60, timeout=30):
return False
# level off
mavproxy.send('rc 2 1500\n')
print("TAKEOFF COMPLETE")
return True
def fly_left_circuit(mavproxy, mav):
'''fly a left circuit, 200m on a side'''
mavproxy.send('switch 4\n')
wait_mode(mav, 'FBWA')
mavproxy.send('rc 3 2000\n')
if not wait_level_flight(mavproxy, mav):
return False
print("Flying left circuit")
# do 4 turns
for i in range(0,4):
# hard left
print("Starting turn %u" % i)
mavproxy.send('rc 1 1000\n')
if not wait_heading(mav, 270 - (90*i), accuracy=10):
return False
mavproxy.send('rc 1 1500\n')
print("Starting leg %u" % i)
if not wait_distance(mav, 100, accuracy=20):
return False
print("Circuit complete")
return True
def fly_RTL(mavproxy, mav):
'''fly to home'''
print("Flying home in RTL")
mavproxy.send('switch 2\n')
wait_mode(mav, 'RTL')
if not wait_location(mav, homeloc, accuracy=120,
target_altitude=homeloc.alt+100, height_accuracy=20,
timeout=90):
return False
print("RTL Complete")
return True
def fly_LOITER(mavproxy, mav, num_circles=4):
'''loiter where we are'''
print("Testing LOITER for %u turns" % num_circles)
mavproxy.send('switch 3\n')
mavproxy.send('loiter\n')
wait_mode(mav, 'LOITER')
while num_circles > 0:
if not wait_heading(mav, 0, accuracy=10, timeout=60):
return False
if not wait_heading(mav, 180, accuracy=10, timeout=60):
return False
num_circles -= 1
print("Loiter %u circles left" % num_circles)
print("Completed Loiter OK")
return True
def wait_level_flight(mavproxy, mav, accuracy=5, timeout=30):
'''wait for level flight'''
tstart = time.time()
print("Waiting for level flight")
while time.time() < tstart + timeout:
m = mav.recv_match(type='ATTITUDE', blocking=True)
roll = math.degrees(m.roll)
pitch = math.degrees(m.pitch)
print("Roll=%.1f Pitch=%.1f" % (roll, pitch))
if math.fabs(roll) <= accuracy and math.fabs(pitch) <= accuracy:
print("Attained level flight")
return True
print("Failed to attain level flight")
return False
def change_altitude(mavproxy, mav, altitude, accuracy=10):
'''get to a given altitude'''
mavproxy.send('switch 4\n')
wait_mode(mav, 'FBWA')
alt_error = mav.messages['VFR_HUD'].alt - altitude
if alt_error > 0:
mavproxy.send('rc 2 2000\n')
else:
mavproxy.send('rc 2 1000\n')
if not wait_altitude(mav, altitude-accuracy/2, altitude+accuracy/2):
return False
mavproxy.send('rc 2 1500\n')
print("Reached target altitude at %u" % mav.messages['VFR_HUD'].alt)
return wait_level_flight(mavproxy, mav)
def axial_left_roll(mavproxy, mav, count=1):
'''fly a left axial roll'''
# full throttle!
mavproxy.send('rc 3 2000\n')
if not change_altitude(mavproxy, mav, homeloc.alt+200):
return False
# fly the roll in manual
mavproxy.send('switch 6\n')
wait_mode(mav, 'MANUAL')
while count > 0:
print("Starting roll")
mavproxy.send('rc 1 1000\n')
if not wait_roll(mav, -150, accuracy=20):
return False
if not wait_roll(mav, 150, accuracy=20):
return False
if not wait_roll(mav, 0, accuracy=20):
return False
count -= 1
# back to FBWA
mavproxy.send('rc 1 1500\n')
mavproxy.send('switch 4\n')
wait_mode(mav, 'FBWA')
mavproxy.send('rc 3 1700\n')
return wait_level_flight(mavproxy, mav)
def inside_loop(mavproxy, mav, count=1):
'''fly a inside loop'''
# full throttle!
mavproxy.send('rc 3 2000\n')
if not change_altitude(mavproxy, mav, homeloc.alt+200):
return False
# fly the loop in manual
mavproxy.send('switch 6\n')
wait_mode(mav, 'MANUAL')
while count > 0:
print("Starting loop")
mavproxy.send('rc 2 1000\n')
if not wait_pitch(mav, -60, accuracy=20):
return False
if not wait_pitch(mav, 0, accuracy=20):
return False
count -= 1
# back to FBWA
mavproxy.send('rc 2 1500\n')
mavproxy.send('switch 4\n')
wait_mode(mav, 'FBWA')
mavproxy.send('rc 3 1700\n')
return wait_level_flight(mavproxy, mav)
def setup_rc(mavproxy):
'''setup RC override control'''
for chan in [1,2,4,5,6,7]:
mavproxy.send('rc %u 1500\n' % chan)
mavproxy.send('rc 3 1000\n')
mavproxy.send('rc 8 1800\n')
def fly_mission(mavproxy, mav, filename, height_accuracy=-1, target_altitude=None):
'''fly a mission from a file'''
global homeloc
print("Flying mission %s" % filename)
mavproxy.send('wp load %s\n' % filename)
mavproxy.expect('flight plan received')
mavproxy.send('wp list\n')
mavproxy.expect('Requesting [0-9]+ waypoints')
mavproxy.send('switch 1\n') # auto mode
wait_mode(mav, 'AUTO')
if not wait_waypoint(mav, 1, 7, max_dist=60):
return False
if not wait_groundspeed(mav, 0, 0.5, timeout=60):
return False
print("Mission OK")
return True
def fly_ArduPlane(viewerip=None):
'''fly ArduPlane in SIL
you can pass viewerip as an IP address to optionally send fg and
mavproxy packets too for local viewing of the flight in real time
'''
global homeloc
options = '--sitl=127.0.0.1:5501 --out=127.0.0.1:19550 --streamrate=10'
if viewerip:
options += " --out=%s:14550" % viewerip
sil = util.start_SIL('ArduPlane', wipe=True)
mavproxy = util.start_MAVProxy_SIL('ArduPlane', options=options)
mavproxy.expect('Received [0-9]+ parameters')
# setup test parameters
mavproxy.send('param set SYSID_THISMAV %u\n' % random.randint(100, 200))
mavproxy.send("param load %s/ArduPlane.parm\n" % testdir)
mavproxy.expect('Loaded [0-9]+ parameters')
# restart with new parms
util.pexpect_close(mavproxy)
util.pexpect_close(sil)
cmd = util.reltopdir("Tools/autotest/jsbsim/runsim.py")
cmd += " --home=%s --wind=%s" % (HOME_LOCATION, WIND)
if viewerip:
cmd += " --fgout=%s:5503" % viewerip
runsim = pexpect.spawn(cmd, logfile=sys.stdout, timeout=10)
runsim.delaybeforesend = 0
util.pexpect_autoclose(runsim)
runsim.expect('Simulator ready to fly')
sil = util.start_SIL('ArduPlane')
mavproxy = util.start_MAVProxy_SIL('ArduPlane', options=options)
mavproxy.expect('Logging to (\S+)')
logfile = mavproxy.match.group(1)
print("LOGFILE %s" % logfile)
buildlog = util.reltopdir("../buildlogs/ArduPlane-test.mavlog")
print("buildlog=%s" % buildlog)
if os.path.exists(buildlog):
os.unlink(buildlog)
os.link(logfile, buildlog)
mavproxy.expect('Received [0-9]+ parameters')
util.expect_setup_callback(mavproxy, expect_callback)
expect_list_clear()
expect_list_extend([runsim, sil, mavproxy])
print("Started simulator")
# get a mavlink connection going
try:
mav = mavutil.mavlink_connection('127.0.0.1:19550', robust_parsing=True)
except Exception, msg:
print("Failed to start mavlink connection on 127.0.0.1:19550" % msg)
raise
mav.message_hooks.append(message_hook)
mav.idle_hooks.append(idle_hook)
failed = False
e = 'None'
try:
print("Waiting for a heartbeat with mavlink protocol %s" % mav.WIRE_PROTOCOL_VERSION)
mav.wait_heartbeat()
print("Setting up RC parameters")
setup_rc(mavproxy)
print("Waiting for GPS fix")
mav.recv_match(condition='VFR_HUD.alt>10', blocking=True)
mav.wait_gps_fix()
while mav.location().alt < 10:
mav.wait_gps_fix()
homeloc = mav.location()
print("Home location: %s" % homeloc)
if not takeoff(mavproxy, mav):
print("Failed takeoff")
failed = True
if not fly_left_circuit(mavproxy, mav):
print("Failed left circuit")
failed = True
if not axial_left_roll(mavproxy, mav, 1):
print("Failed left roll")
failed = True
if not inside_loop(mavproxy, mav):
print("Failed inside loop")
failed = True
if not fly_RTL(mavproxy, mav):
print("Failed RTL")
failed = True
if not fly_LOITER(mavproxy, mav):
print("Failed LOITER")
failed = True
if not fly_mission(mavproxy, mav, os.path.join(testdir, "ap1.txt"), height_accuracy = 10,
target_altitude=homeloc.alt+100):
print("Failed mission")
failed = True
except pexpect.TIMEOUT, e:
print("Failed with timeout")
failed = True
mav.close()
util.pexpect_close(mavproxy)
util.pexpect_close(sil)
util.pexpect_close(runsim)
if os.path.exists('ArduPlane-valgrind.log'):
os.chmod('ArduPlane-valgrind.log', 0644)
shutil.copy("ArduPlane-valgrind.log", util.reltopdir("../buildlogs/ArduPlane-valgrind.log"))
if failed:
print("FAILED: %s" % e)
return False
return True
|
gpl-3.0
|
[
3,
23158,
1952,
2033,
23363,
315,
428,
1193,
199,
199,
646,
4884,
12,
28855,
12,
984,
12,
900,
12,
3473,
12,
5145,
12,
747,
199,
504,
2863,
492,
627,
199,
646,
11456,
1974,
12,
2196,
199,
199,
3,
664,
2909,
402,
10554,
199,
16634,
29,
736,
14,
515,
14,
3475,
8,
736,
14,
515,
14,
11091,
3460,
493,
8964,
421,
199,
9524,
63,
16575,
18274,
1276,
14,
1344,
1398,
1703,
12,
10721,
14,
975,
1400,
2426,
12,
15959,
12,
12967,
7,
199,
55,
3192,
628,
16,
12,
7663,
12,
16,
14,
18,
2,
327,
8112,
12,
6874,
12,
6221,
199,
199,
4219,
2102,
275,
488,
199,
199,
318,
5452,
1997,
8,
24195,
12,
11456,
304,
272,
1449,
11066,
1997,
664,
370,
4233,
77,
29534,
2344,
272,
19449,
14,
2254,
360,
5656,
841,
60,
78,
358,
272,
3618,
63,
632,
8,
10336,
12,
283,
8223,
9004,
358,
339,
327,
2005,
519,
1181,
424,
370,
4529,
266,
1957,
314,
5931,
11095,
544,
272,
19449,
14,
2254,
360,
1195,
841,
5557,
383,
60,
78,
358,
339,
327,
2005,
1536,
325,
6972,
707,
370,
4215,
314,
9483,
3224,
272,
19449,
14,
2254,
360,
1195,
499,
413,
1840,
60,
78,
358,
339,
327,
664,
652,
12876,
282,
4546,
1642,
272,
19449,
14,
2254,
360,
1195,
650,
4944,
383,
60,
78,
358,
272,
11456,
14,
7637,
63,
1431,
8,
5394,
534,
54,
5372,
63,
40,
3383,
14,
3928,
7625,
30,
22,
297,
14592,
29,
549,
9,
339,
327,
282,
4546,
12930,
4020,
12,
20370,
2056,
724,
519,
1181,
424,
272,
19449,
14,
2254,
360,
1195,
650,
3193,
383,
60,
78,
358,
272,
19449,
14,
2254,
360,
1195,
841,
24970,
60,
78,
358,
272,
11456,
14,
7637,
63,
1431,
8,
5394,
534,
54,
5372,
63,
40,
3383,
14,
3928,
7625,
30,
713,
297,
14592,
29,
549,
9,
339,
327,
9793,
314,
486,
305,
12159,
424,
3063,
12,
436,
8120,
652,
2005,
1655,
325,
6972,
707,
272,
19449,
14,
2254,
360,
1195,
499,
413,
1960,
60,
78,
358,
272,
19449,
14,
2254,
360,
1195,
650,
6155,
383,
60,
78,
358,
339,
327,
15334,
282,
4546,
402,
29534,
272,
340,
440,
3618,
63,
27539,
8,
10336,
12,
5629,
2102,
14,
4478,
11,
1216,
12,
5629,
2102,
14,
4478,
11,
2259,
12,
2653,
29,
1216,
304,
267,
372,
756,
339,
327,
2166,
2331,
272,
19449,
14,
2254,
360,
1195,
499,
24970,
60,
78,
358,
339,
870,
480,
6166,
2430,
7517,
5099,
3950,
5248,
531,
272,
372,
715,
199,
199,
318,
23158,
63,
3039,
63,
18516,
8,
24195,
12,
11456,
304,
272,
1449,
21600,
282,
3602,
20304,
12,
1926,
77,
641,
282,
5366,
2344,
272,
19449,
14,
2254,
360,
5656,
841,
60,
78,
358,
272,
3618,
63,
632,
8,
10336,
12,
283,
8223,
9004,
358,
272,
19449,
14,
2254,
360,
1195,
650,
12293,
60,
78,
358,
272,
340,
440,
3618,
63,
1896,
63,
28807,
8,
24195,
12,
11456,
304,
267,
372,
756,
339,
870,
480,
38,
6670,
3602,
20304,
531,
272,
327,
886,
841,
25449,
272,
367,
284,
315,
1425,
8,
16,
12,
20,
304,
267,
327,
7508,
3602,
267,
870,
480,
14139,
7485,
450,
85,
2,
450,
284,
9,
267,
19449,
14,
2254,
360,
1195,
413,
5198,
60,
78,
358,
267,
340,
440,
3618,
63,
13983,
8,
10336,
12,
27632,
446,
334,
2710,
10,
73,
395,
12862,
29,
709,
304,
288,
372,
756,
267,
19449,
14,
2254,
360,
1195,
413,
24970,
60,
78,
358,
267,
870,
480,
14139,
6768,
450,
85,
2,
450,
284,
9,
267,
340,
440,
3618,
63,
5590,
8,
10336,
12,
2948,
12,
12862,
29,
1165,
304,
288,
372,
756,
272,
870,
480,
35,
14221,
4890,
531,
272,
372,
715,
199,
199,
318,
23158,
63,
23259,
8,
24195,
12,
11456,
304,
272,
1449,
21600,
370,
5629,
2344,
272,
870,
480,
38,
6670,
5629,
315,
820,
7308,
531,
272,
19449,
14,
2254,
360,
5656,
499,
60,
78,
358,
272,
3618,
63,
632,
8,
10336,
12,
283,
23259,
358,
272,
340,
440,
3618,
63,
1985,
8,
10336,
12,
5629,
2102,
12,
12862,
29,
6708,
12,
586,
1347,
63,
27539,
29,
4219,
2102,
14,
4478,
11,
1960,
12,
4569,
63,
13374,
29,
1165,
12,
586,
2653,
29,
2710,
304,
267,
372,
756,
272,
870,
480,
23259,
28393,
531,
272,
372,
715,
199,
199,
318,
23158,
63,
1484,
11084,
8,
24195,
12,
11456,
12,
1967,
63,
6092,
2978,
29,
20,
304,
272,
1449,
320,
1661,
2382,
781,
787,
2344,
272,
870,
480,
9029,
3412,
11084,
367,
450,
85,
25449,
2,
450,
1967,
63,
6092,
2978,
9,
272,
19449,
14,
2254,
360,
5656,
650,
60,
78,
358,
272,
19449,
14,
2254,
360,
320,
1661,
60,
78,
358,
272,
3618,
63,
632,
8,
10336,
12,
283,
1484,
11084,
358,
272,
1830,
1967,
63,
6092,
2978,
690,
378,
26,
267,
340,
440,
3618,
63,
13983,
8,
10336,
12,
378,
12,
12862,
29,
709,
12,
2653,
29,
2259,
304,
288,
372,
756,
267,
340,
440,
3618,
63,
13983,
8,
10336,
12,
13576,
12,
12862,
29,
709,
12,
2653,
29,
2259,
304,
288,
372,
756,
267,
1967,
63,
6092,
2978,
4862,
413,
267,
870,
480,
2041,
1661,
450,
85,
17990,
83,
3602,
2,
450,
1967,
63,
6092,
2978,
9,
272,
870,
480,
19908,
3835,
1661,
9949,
531,
272,
372,
715,
421,
199,
318,
3618,
63,
1896,
63,
28807,
8,
24195,
12,
11456,
12,
12862,
29,
21,
12,
2653,
29,
1216,
304,
272,
1449,
2573,
367,
2166,
289,
4040,
2344,
272,
29921,
275,
900,
14,
521,
342,
272,
870,
480,
19189,
367,
2166,
289,
4040,
531,
272,
1830,
900,
14,
521,
342,
665,
29921,
435,
2653,
26,
267,
333,
275,
11456,
14,
7637,
63,
1431,
8,
466,
534,
11712,
28742,
297,
14592,
29,
549,
9,
267,
11848,
275,
3473,
14,
20251,
8,
77,
14,
2827,
9,
267,
20031,
275,
3473,
14,
20251,
8,
77,
14,
16966,
9,
267,
870,
480,
24363,
2458,
14,
17,
70,
510,
9414,
2458,
14,
17,
70,
2,
450,
334,
2827,
12,
20031,
430,
267,
340,
3473,
14,
70,
2101,
8,
2827,
9,
2695,
12862,
436,
3473,
14,
70,
2101,
8,
16966,
9,
2695,
12862,
26,
288,
870,
480,
1271,
877,
379,
2166,
289,
4040,
531,
288,
372,
715,
272,
870,
480,
4276,
370,
737,
877,
2166
] |
[
23158,
1952,
2033,
23363,
315,
428,
1193,
199,
199,
646,
4884,
12,
28855,
12,
984,
12,
900,
12,
3473,
12,
5145,
12,
747,
199,
504,
2863,
492,
627,
199,
646,
11456,
1974,
12,
2196,
199,
199,
3,
664,
2909,
402,
10554,
199,
16634,
29,
736,
14,
515,
14,
3475,
8,
736,
14,
515,
14,
11091,
3460,
493,
8964,
421,
199,
9524,
63,
16575,
18274,
1276,
14,
1344,
1398,
1703,
12,
10721,
14,
975,
1400,
2426,
12,
15959,
12,
12967,
7,
199,
55,
3192,
628,
16,
12,
7663,
12,
16,
14,
18,
2,
327,
8112,
12,
6874,
12,
6221,
199,
199,
4219,
2102,
275,
488,
199,
199,
318,
5452,
1997,
8,
24195,
12,
11456,
304,
272,
1449,
11066,
1997,
664,
370,
4233,
77,
29534,
2344,
272,
19449,
14,
2254,
360,
5656,
841,
60,
78,
358,
272,
3618,
63,
632,
8,
10336,
12,
283,
8223,
9004,
358,
339,
327,
2005,
519,
1181,
424,
370,
4529,
266,
1957,
314,
5931,
11095,
544,
272,
19449,
14,
2254,
360,
1195,
841,
5557,
383,
60,
78,
358,
339,
327,
2005,
1536,
325,
6972,
707,
370,
4215,
314,
9483,
3224,
272,
19449,
14,
2254,
360,
1195,
499,
413,
1840,
60,
78,
358,
339,
327,
664,
652,
12876,
282,
4546,
1642,
272,
19449,
14,
2254,
360,
1195,
650,
4944,
383,
60,
78,
358,
272,
11456,
14,
7637,
63,
1431,
8,
5394,
534,
54,
5372,
63,
40,
3383,
14,
3928,
7625,
30,
22,
297,
14592,
29,
549,
9,
339,
327,
282,
4546,
12930,
4020,
12,
20370,
2056,
724,
519,
1181,
424,
272,
19449,
14,
2254,
360,
1195,
650,
3193,
383,
60,
78,
358,
272,
19449,
14,
2254,
360,
1195,
841,
24970,
60,
78,
358,
272,
11456,
14,
7637,
63,
1431,
8,
5394,
534,
54,
5372,
63,
40,
3383,
14,
3928,
7625,
30,
713,
297,
14592,
29,
549,
9,
339,
327,
9793,
314,
486,
305,
12159,
424,
3063,
12,
436,
8120,
652,
2005,
1655,
325,
6972,
707,
272,
19449,
14,
2254,
360,
1195,
499,
413,
1960,
60,
78,
358,
272,
19449,
14,
2254,
360,
1195,
650,
6155,
383,
60,
78,
358,
339,
327,
15334,
282,
4546,
402,
29534,
272,
340,
440,
3618,
63,
27539,
8,
10336,
12,
5629,
2102,
14,
4478,
11,
1216,
12,
5629,
2102,
14,
4478,
11,
2259,
12,
2653,
29,
1216,
304,
267,
372,
756,
339,
327,
2166,
2331,
272,
19449,
14,
2254,
360,
1195,
499,
24970,
60,
78,
358,
339,
870,
480,
6166,
2430,
7517,
5099,
3950,
5248,
531,
272,
372,
715,
199,
199,
318,
23158,
63,
3039,
63,
18516,
8,
24195,
12,
11456,
304,
272,
1449,
21600,
282,
3602,
20304,
12,
1926,
77,
641,
282,
5366,
2344,
272,
19449,
14,
2254,
360,
5656,
841,
60,
78,
358,
272,
3618,
63,
632,
8,
10336,
12,
283,
8223,
9004,
358,
272,
19449,
14,
2254,
360,
1195,
650,
12293,
60,
78,
358,
272,
340,
440,
3618,
63,
1896,
63,
28807,
8,
24195,
12,
11456,
304,
267,
372,
756,
339,
870,
480,
38,
6670,
3602,
20304,
531,
272,
327,
886,
841,
25449,
272,
367,
284,
315,
1425,
8,
16,
12,
20,
304,
267,
327,
7508,
3602,
267,
870,
480,
14139,
7485,
450,
85,
2,
450,
284,
9,
267,
19449,
14,
2254,
360,
1195,
413,
5198,
60,
78,
358,
267,
340,
440,
3618,
63,
13983,
8,
10336,
12,
27632,
446,
334,
2710,
10,
73,
395,
12862,
29,
709,
304,
288,
372,
756,
267,
19449,
14,
2254,
360,
1195,
413,
24970,
60,
78,
358,
267,
870,
480,
14139,
6768,
450,
85,
2,
450,
284,
9,
267,
340,
440,
3618,
63,
5590,
8,
10336,
12,
2948,
12,
12862,
29,
1165,
304,
288,
372,
756,
272,
870,
480,
35,
14221,
4890,
531,
272,
372,
715,
199,
199,
318,
23158,
63,
23259,
8,
24195,
12,
11456,
304,
272,
1449,
21600,
370,
5629,
2344,
272,
870,
480,
38,
6670,
5629,
315,
820,
7308,
531,
272,
19449,
14,
2254,
360,
5656,
499,
60,
78,
358,
272,
3618,
63,
632,
8,
10336,
12,
283,
23259,
358,
272,
340,
440,
3618,
63,
1985,
8,
10336,
12,
5629,
2102,
12,
12862,
29,
6708,
12,
586,
1347,
63,
27539,
29,
4219,
2102,
14,
4478,
11,
1960,
12,
4569,
63,
13374,
29,
1165,
12,
586,
2653,
29,
2710,
304,
267,
372,
756,
272,
870,
480,
23259,
28393,
531,
272,
372,
715,
199,
199,
318,
23158,
63,
1484,
11084,
8,
24195,
12,
11456,
12,
1967,
63,
6092,
2978,
29,
20,
304,
272,
1449,
320,
1661,
2382,
781,
787,
2344,
272,
870,
480,
9029,
3412,
11084,
367,
450,
85,
25449,
2,
450,
1967,
63,
6092,
2978,
9,
272,
19449,
14,
2254,
360,
5656,
650,
60,
78,
358,
272,
19449,
14,
2254,
360,
320,
1661,
60,
78,
358,
272,
3618,
63,
632,
8,
10336,
12,
283,
1484,
11084,
358,
272,
1830,
1967,
63,
6092,
2978,
690,
378,
26,
267,
340,
440,
3618,
63,
13983,
8,
10336,
12,
378,
12,
12862,
29,
709,
12,
2653,
29,
2259,
304,
288,
372,
756,
267,
340,
440,
3618,
63,
13983,
8,
10336,
12,
13576,
12,
12862,
29,
709,
12,
2653,
29,
2259,
304,
288,
372,
756,
267,
1967,
63,
6092,
2978,
4862,
413,
267,
870,
480,
2041,
1661,
450,
85,
17990,
83,
3602,
2,
450,
1967,
63,
6092,
2978,
9,
272,
870,
480,
19908,
3835,
1661,
9949,
531,
272,
372,
715,
421,
199,
318,
3618,
63,
1896,
63,
28807,
8,
24195,
12,
11456,
12,
12862,
29,
21,
12,
2653,
29,
1216,
304,
272,
1449,
2573,
367,
2166,
289,
4040,
2344,
272,
29921,
275,
900,
14,
521,
342,
272,
870,
480,
19189,
367,
2166,
289,
4040,
531,
272,
1830,
900,
14,
521,
342,
665,
29921,
435,
2653,
26,
267,
333,
275,
11456,
14,
7637,
63,
1431,
8,
466,
534,
11712,
28742,
297,
14592,
29,
549,
9,
267,
11848,
275,
3473,
14,
20251,
8,
77,
14,
2827,
9,
267,
20031,
275,
3473,
14,
20251,
8,
77,
14,
16966,
9,
267,
870,
480,
24363,
2458,
14,
17,
70,
510,
9414,
2458,
14,
17,
70,
2,
450,
334,
2827,
12,
20031,
430,
267,
340,
3473,
14,
70,
2101,
8,
2827,
9,
2695,
12862,
436,
3473,
14,
70,
2101,
8,
16966,
9,
2695,
12862,
26,
288,
870,
480,
1271,
877,
379,
2166,
289,
4040,
531,
288,
372,
715,
272,
870,
480,
4276,
370,
737,
877,
2166,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
lazy404/libstoragemgmt
|
plugin/ontap/na.py
|
2
|
28471
|
# Copyright (C) 2012-2014 Red Hat, Inc.
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; If not, see <http://www.gnu.org/licenses/>.
#
# Author: tasleson
import urllib2
import socket
import sys
from xml.etree import ElementTree
import time
from binascii import hexlify
from _ssl import SSLError
from M2Crypto import RC4
from lsm.external.xmltodict import convert_xml_to_dict
from lsm import (ErrorNumber)
#Set to an appropriate directory and file to dump the raw response.
xml_debug = None
def netapp_filer_parse_response(resp):
if xml_debug:
out = open(xml_debug, "wb")
out.write(resp)
out.close()
return convert_xml_to_dict(ElementTree.fromstring(resp))
def param_value(val):
"""
Given a parameter to pass to filer, convert to XML
"""
rc = ""
if type(val) is dict or isinstance(val, dict):
for k, v in val.items():
rc += "<%s>%s</%s>" % (k, param_value(v), k)
elif type(val) is list or isinstance(val, list):
for i in val:
rc += param_value(i)
else:
rc = val
return rc
def netapp_filer(host, username, password, timeout, command, parameters=None,
ssl=False):
"""
Issue a command to the NetApp filer.
Note: Change to default ssl on before we ship a release version.
"""
proto = 'http'
if ssl:
proto = 'https'
url = "%s://%s/servlets/netapp.servlets.admin.XMLrequest_filer" % \
(proto, host)
req = urllib2.Request(url)
req.add_header('Content-Type', 'text/xml')
password_manager = urllib2.HTTPPasswordMgrWithDefaultRealm()
password_manager.add_password(None, url, username, password)
auth_manager = urllib2.HTTPBasicAuthHandler(password_manager)
opener = urllib2.build_opener(auth_manager)
urllib2.install_opener(opener)
#build the command and the arguments for it
p = ""
if parameters:
for k, v in parameters.items():
p += "<%s>%s</%s>" % (k, param_value(v), k)
payload = "<%s>\n%s\n</%s>" % (command, p, command)
data = """<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE netapp SYSTEM "file:/etc/netapp_filer.dtd">
<netapp xmlns="http://www.netapp.com/filer/admin" version="1.1">
%s
</netapp>
""" % payload
handler = None
rc = None
try:
handler = urllib2.urlopen(req, data, float(timeout))
if handler.getcode() == 200:
rc = netapp_filer_parse_response(handler.read())
except urllib2.HTTPError as he:
raise
except urllib2.URLError as ue:
if isinstance(ue.reason, socket.timeout):
raise FilerError(Filer.ETIMEOUT, "Connection timeout")
else:
raise
except socket.timeout:
raise FilerError(Filer.ETIMEOUT, "Connection timeout")
except SSLError as sse:
# The ssl library doesn't give a good way to find specific reason.
# We are doing a string contains which is not ideal, but other than
# throwing a generic error in this case there isn't much we can do
# to be more specific.
if "timed out" in str(sse).lower():
raise FilerError(Filer.ETIMEOUT, "Connection timeout (SSL)")
else:
raise FilerError(Filer.EUNKNOWN,
"SSL error occurred (%s)", str(sse))
finally:
if handler:
handler.close()
return rc
class FilerError(Exception):
"""
Class represents a NetApp bad return code
"""
IGROUP_NOT_CONTAIN_GIVEN_INIT = 9007
IGROUP_ALREADY_HAS_INIT = 9008
NO_SUCH_IGROUP = 9003
# Using the name from NetApp SDK netapp_errno.h
EVDISK_ERROR_VDISK_EXISTS = 9012 # LUN name already in use
EVDISK_ERROR_VDISK_EXPORTED = 9013 # LUN is currently mapped
EVDISK_ERROR_VDISK_NOT_ENABLED = 9014 # LUN is not online
EVDISK_ERROR_VDISK_NOT_DISABLED = 9015 # LUN is not offline
EVDISK_ERROR_NO_SUCH_LUNMAP = 9016 # LUN is already unmapped
EVDISK_ERROR_INITGROUP_MAPS_EXIST = 9029 # LUN maps for this initiator
# group exist
EVDISK_ERROR_SIZE_TOO_LARGE = 9034 # LUN size too large.
EVDISK_ERROR_NO_SUCH_VOLUME = 9036 # NetApp Volume not exists.
EVDISK_ERROR_SIZE_TOO_SMALL = 9041 # Specified too small a size
EVDISK_ERROR_SIZE_UNCHANGED = 9042 # requested size is the same.
EVDISK_ERROR_INITGROUP_HAS_VDISK = 9023 # Already masked
def __init__(self, errno, reason, *args, **kwargs):
Exception.__init__(self, *args, **kwargs)
self.errno = int(errno)
self.reason = reason
def to_list(v):
"""
The return values in hash form can either be a single hash item or a list
of hash items, this code handles both to make callers always get a list.
"""
rc = []
if v is not None:
if isinstance(v, list):
rc = v
else:
rc.append(v)
return rc
class Filer(object):
"""
Class to handle NetApp API calls.
Note: These are using lsm terminology.
"""
EUNKNOWN = 10 # Non-specific error
ENAVOL_NAME_DUPE = 17 # Volume name collision
ENOSPC = 28 # Out of space
ETIMEOUT = 60 # Time-out
EINVALID_ISCSI_NAME = 9006 # Invalid ISCSI IQN
EDUPE_VOLUME_PATH = 9012 # Duplicate volume name
ENO_SUCH_VOLUME = 9017 # lun not found
ESIZE_TOO_LARGE = 9034 # Specified too large a size
ENO_SUCH_FS = 9036 # FS not found
EVOLUME_TOO_SMALL = 9041 # Specified too small a size
EAPILICENSE = 13008 # Unlicensed API
EFSDOESNOTEXIST = 13040 # FS does not exist
EFSOFFLINE = 13042 # FS is offline.
EFSNAMEINVALID = 13044 # FS Name invalid
ENOSPACE = 13062 # Not enough space
ESERVICENOTLICENSED = 13902 # Not licensed
ECLONE_NAME_EXISTS = 14952 # Clone with same name exists
ECLONE_LICENSE_EXPIRED = 14955 # Not licensed
ECLONE_NOT_LICENSED = 14956 # Not licensed
(LSM_VOL_PREFIX, LSM_INIT_PREFIX) = ('lsm_lun_container', 'lsm_init_')
def _invoke(self, command, parameters=None):
rc = netapp_filer(self.host, self.username, self.password,
self.timeout, command, parameters, self.ssl)
t = rc['netapp']['results']['attrib']
if t['status'] != 'passed':
raise FilerError(t['errno'], t['reason'])
return rc['netapp']['results']
def __init__(self, host, username, password, timeout, ssl=True):
self.host = host
self.username = username
self.password = password
self.timeout = timeout
self.ssl = ssl
def system_info(self):
rc = self._invoke('system-get-info')
return rc['system-info']
def validate(self):
#TODO: Validate that everything we need to function is available?
self._invoke('system-api-list')
return None
def disks(self):
disks = self._invoke('disk-list-info')
return disks['disk-details']['disk-detail-info']
def aggregates(self, aggr_name=None):
"""
Return a list of aggregates
If aggr_name provided, return [na_aggr]
"""
if aggr_name:
pools = self._invoke('aggr-list-info', {'aggregate': aggr_name})
else:
pools = self._invoke('aggr-list-info')
tmp = pools['aggregates']['aggr-info']
return to_list(tmp)
def aggregate_volume_names(self, aggr_name):
"""
Return a list of volume names that are on an aggregate
"""
vol_names = []
rc = self._invoke('aggr-list-info', {'aggregate': aggr_name})
aggr = rc['aggregates']['aggr-info']
if aggr is not None and aggr['volumes'] is not None:
vols = aggr['volumes']['contained-volume-info']
vol_names = [e['name'] for e in to_list(vols)]
return vol_names
def lun_build_name(self, volume_name, file_name):
"""
Given a volume name and file return full path"
"""
return '/vol/%s/%s' % (volume_name, file_name)
def luns_get_specific(self, aggr, na_lun_name=None, na_volume_name=None):
"""
Return all logical units, or information about one or for all those
on a volume name.
"""
rc = []
if na_lun_name is not None:
luns = self._invoke('lun-list-info', {'path': na_lun_name})
elif na_volume_name is not None:
luns = self._invoke('lun-list-info',
{'volume-name': na_volume_name})
else:
luns = self._invoke('lun-list-info')
return to_list(luns['luns']['lun-info'])
def _get_aggr_info(self):
aggrs = self._invoke('aggr-list-info')
tmp = to_list(aggrs['aggregates']['aggr-info'])
return [x for x in tmp if x['volumes'] is not None]
def luns_get_all(self):
"""
Return all lun-info
"""
try:
return to_list(self._invoke('lun-list-info')['luns']['lun-info'])
except TypeError:
# No LUN found.
return []
def lun_min_size(self):
return self._invoke('lun-get-minsize', {'type': 'image'})['min-size']
def lun_create(self, full_path_name, size_bytes, flag_thin=False):
"""
Creates a lun
If flag_thin set to True, will set 'space-reservation-enabled' as
'false' which means "create a LUN without any space being reserved".
"""
params = {'path': full_path_name,
'size': size_bytes}
if flag_thin is True:
params['space-reservation-enabled'] = 'false'
self._invoke('lun-create-by-size', params)
def lun_delete(self, lun_path):
"""
Deletes a lun given a lun path
"""
self._invoke('lun-destroy', {'path': lun_path})
def lun_resize(self, lun_path, size_bytes):
"""
Re-sizes a lun
"""
self._invoke('lun-resize', {'path': lun_path, 'size': size_bytes,
'force': 'true'})
def volume_resize(self, na_vol_name, size_diff_kb):
"""
Given a NetApp volume name and a size change in kb, re-size the
NetApp volume.
"""
params = {'volume': na_vol_name}
if size_diff_kb > 0:
params['new-size'] = '+' + str(size_diff_kb) + 'k'
else:
params['new-size'] = str(size_diff_kb) + 'k'
self._invoke('volume-size', params)
return None
def volumes(self, volume_name=None):
"""
Return a list of NetApp volumes
"""
if not volume_name:
v = self._invoke('volume-list-info')
else:
v = self._invoke('volume-list-info', {'volume': volume_name})
t = v['volumes']['volume-info']
rc = to_list(t)
return rc
def volume_create(self, aggr_name, vol_name, size_in_bytes):
"""
Creates a volume given an aggr_name, volume name and size in bytes.
"""
params = {'containing-aggr-name': aggr_name,
'size': int(size_in_bytes * 1.30),
#There must be a better way to account for this
'volume': vol_name}
self._invoke('volume-create', params)
#Turn off scheduled snapshots
self._invoke('volume-set-option', {'volume': vol_name,
'option-name': 'nosnap',
'option-value': 'on', })
#Turn off auto export!
self.nfs_export_remove(['/vol/' + vol_name])
def volume_clone(self, src_volume, dest_volume, snapshot=None):
"""
Clones a volume given a source volume name, destination volume name
and optional backing snapshot.
"""
params = {'parent-volume': src_volume, 'volume': dest_volume}
if snapshot:
params['parent-snapshot'] = snapshot.name
self._invoke('volume-clone-create', params)
def volume_delete(self, vol_name):
"""
Deletes a volume and everything on it.
"""
online = False
try:
self._invoke('volume-offline', {'name': vol_name})
online = True
except FilerError as f_error:
if f_error.errno != Filer.EFSDOESNOTEXIST:
raise
try:
self._invoke('volume-destroy', {'name': vol_name})
except FilerError as f_error:
#If the volume was online, we will return it to same status
# Store the original exception information
exception_info = sys.exc_info()
if online:
try:
self._invoke('volume-online', {'name': vol_name})
except FilerError:
pass
raise exception_info[1], None, exception_info[2]
def volume_names(self):
"""
Return a list of volume names
"""
vols = self.volumes()
return [v['name'] for v in vols]
def clone(self, source_path, dest_path, backing_snapshot=None,
ranges=None):
"""
Creates a file clone
"""
params = {'source-path': source_path}
#You can have source == dest, but if you do you can only specify source
if source_path != dest_path:
params['destination-path'] = dest_path
if backing_snapshot:
raise FilerError(ErrorNumber.NO_SUPPORT,
"Support for backing luns not implemented "
"for this API version")
#params['snapshot-name']= backing_snapshot
if ranges:
block_ranges = []
for r in ranges:
values = {'block-count': r.block_count,
'destination-block-number': r.dest_block,
'source-block-number': r.src_block}
block_ranges.append({'block-range': values})
params['block-ranges'] = block_ranges
rc = self._invoke('clone-start', params)
c_id = rc['clone-id']
while True:
progress = self._invoke('clone-list-status',
{'clone-id': c_id})
# According to the spec the output is optional, if not present
# then we are done and good
if 'status' in progress:
progress = progress['status']['ops-info']
if progress['clone-state'] == 'failed':
self._invoke('clone-clear', {'clone-id': c_id})
raise FilerError(progress['error'], progress['reason'])
elif progress['clone-state'] == 'running' \
or progress['clone-state'] == 'fail exit':
# State needs to transition to failed before we can
# clear it!
time.sleep(0.2) # Don't hog cpu
elif progress['clone-state'] == 'completed':
return
else:
raise FilerError(ErrorNumber.NO_SUPPORT,
'Unexpected state=' +
progress['clone-state'])
else:
return
def lun_online(self, lun_path):
self._invoke('lun-online', {'path': lun_path})
def lun_offline(self, lun_path):
self._invoke('lun-offline', {'path': lun_path})
def igroups(self, group_name=None):
rc = []
if group_name:
g = self._invoke('igroup-list-info',
{'initiator-group-name': group_name})
else:
g = self._invoke('igroup-list-info')
if g['initiator-groups']:
rc = to_list(g['initiator-groups']['initiator-group-info'])
return rc
def igroup_create(self, name, igroup_type):
params = {'initiator-group-name': name,
'initiator-group-type': igroup_type}
self._invoke('igroup-create', params)
def igroup_delete(self, name):
self._invoke('igroup-destroy', {'initiator-group-name': name})
@staticmethod
def encode(password):
rc4 = RC4.RC4()
rc4.set_key("#u82fyi8S5\017pPemw")
return hexlify(rc4.update(password))
def iscsi_initiator_add_auth(self, initiator, user_name, password,
out_user, out_password):
pw = self.encode(password)
args = {'initiator': initiator}
if user_name and len(user_name) and password and len(password):
args.update({'user-name': user_name,
'password': pw, 'auth-type': "CHAP"})
if out_user and len(out_user) and \
out_password and len(out_password):
args.update({'outbound-user-name': out_user,
'outbound-password': out_password})
else:
args.update({'initiator': initiator, 'auth-type': "none"})
self._invoke('iscsi-initiator-add-auth', args)
def igroup_add_initiator(self, ig, initiator):
self._invoke('igroup-add',
{'initiator-group-name': ig, 'initiator': initiator})
def igroup_del_initiator(self, ig, initiator):
self._invoke('igroup-remove',
{'initiator-group-name': ig,
'initiator': initiator,
'force': 'true'})
def lun_map(self, igroup, lun_path):
self._invoke('lun-map', {'initiator-group': igroup, 'path': lun_path})
def lun_unmap(self, igroup, lun_path):
self._invoke(
'lun-unmap', {'initiator-group': igroup, 'path': lun_path})
def lun_map_list_info(self, lun_path):
initiator_groups = []
rc = self._invoke('lun-map-list-info', {'path': lun_path})
if rc['initiator-groups'] is not None:
igi = to_list(rc['initiator-groups'])
for i in igi:
group_name = i['initiator-group-info']['initiator-group-name']
initiator_groups.append(self.igroups(group_name)[0])
return initiator_groups
def lun_initiator_list_map_info(self, initiator_id, initiator_group_name):
"""
Given an initiator_id and initiator group name, return a list of
lun-info
"""
luns = []
rc = self._invoke('lun-initiator-list-map-info',
{'initiator': initiator_id})
if rc['lun-maps']:
lun_name_list = to_list(rc['lun-maps']['lun-map-info'])
#Get all the lun with information about aggr
all_luns = self.luns_get_all()
for l in lun_name_list:
if l['initiator-group'] == initiator_group_name:
for al in all_luns:
if al['path'] == l['path']:
luns.append(al)
return luns
def snapshots(self, volume_name):
rc = []
args = {'target-type': 'volume', 'target-name': volume_name}
ss = self._invoke('snapshot-list-info', args)
if ss['snapshots']:
rc = to_list(ss['snapshots']['snapshot-info'])
return rc
def snapshot_create(self, volume_name, snapshot_name):
self._invoke('snapshot-create', {'volume': volume_name,
'snapshot': snapshot_name})
return [v for v in self.snapshots(volume_name)
if v['name'] == snapshot_name][0]
def snapshot_file_restore_num(self):
"""
Returns the number of executing file restore snapshots.
"""
rc = self._invoke('snapshot-restore-file-info')
if 'sfsr-in-progress' in rc:
return int(rc['sfsr-in-progress'])
return 0
def snapshot_restore_volume(self, fs_name, snapshot_name):
"""
Restores all files on a volume
"""
params = {'snapshot': snapshot_name, 'volume': fs_name}
self._invoke('snapshot-restore-volume', params)
def snapshot_restore_file(self, snapshot_name, restore_path, restore_file):
"""
Restore a list of files
"""
params = {'snapshot': snapshot_name, 'path': restore_path}
if restore_file:
params['restore-path'] = restore_file
self._invoke('snapshot-restore-file', params)
def snapshot_delete(self, volume_name, snapshot_name):
self._invoke('snapshot-delete',
{'volume': volume_name, 'snapshot': snapshot_name})
def export_auth_types(self):
rc = self._invoke('nfs-get-supported-sec-flavors')
return [e['flavor'] for e in
to_list(rc['sec-flavor']['sec-flavor-info'])]
@staticmethod
def _build_list(pylist, list_name, elem_name):
"""
Given a python list, build the appropriate dict that contains the
list items so that it can be converted to xml to be sent on the wire.
"""
return [{list_name: {elem_name: l}} for l in pylist]
@staticmethod
def _build_export_fs_all():
return Filer._build_list(
['true'], 'exports-hostname-info', 'all-hosts')
@staticmethod
def _build_export_fs_list(hosts):
if hosts[0] == '*':
return Filer._build_export_fs_all()
else:
return Filer._build_list(hosts, 'exports-hostname-info', 'name')
def _build_export_rules(self, volume_path, export_path, ro_list, rw_list,
root_list, anonuid=None, sec_flavor=None):
"""
Common logic to build up the rules for nfs
"""
#One of the more complicated data structures to push down to the
#controller
rule = {'pathname': volume_path}
if volume_path != export_path:
rule['actual-pathname'] = volume_path
rule['pathname'] = export_path
rule['security-rules'] = {}
rule['security-rules']['security-rule-info'] = {}
r = rule['security-rules']['security-rule-info']
if len(ro_list):
r['read-only'] = Filer._build_export_fs_list(ro_list)
if len(rw_list):
r['read-write'] = Filer._build_export_fs_list(rw_list)
if len(root_list):
r['root'] = Filer._build_export_fs_list(root_list)
if anonuid:
uid = long(anonuid)
if uid != -1 and uid != 0xFFFFFFFFFFFFFFFF:
r['anon'] = str(uid)
if sec_flavor:
r['sec-flavor'] = Filer._build_list(
[sec_flavor], 'sec-flavor-info', 'flavor')
return rule
def nfs_export_fs2(self, volume_path, export_path, ro_list, rw_list,
root_list, anonuid=None, sec_flavor=None):
"""
NFS export a volume.
"""
rule = self._build_export_rules(
volume_path, export_path, ro_list, rw_list, root_list, anonuid,
sec_flavor)
params = {'persistent': 'true',
'rules': {'exports-rule-info-2': [rule]}, 'verbose': 'true'}
self._invoke('nfs-exportfs-append-rules-2', params)
def nfs_export_fs_modify2(self, volume_path, export_path, ro_list, rw_list,
root_list, anonuid=None, sec_flavor=None):
"""
Modifies an existing rule.
"""
rule = self._build_export_rules(
volume_path, export_path, ro_list, rw_list, root_list, anonuid,
sec_flavor)
params = {
'persistent': 'true', 'rule': {'exports-rule-info-2': [rule]}}
self._invoke('nfs-exportfs-modify-rule-2', params)
def nfs_export_remove(self, export_paths):
"""
Removes an existing export
"""
assert (type(export_paths) is list)
paths = Filer._build_list(export_paths, 'pathname-info', 'name')
self._invoke('nfs-exportfs-delete-rules',
{'pathnames': paths, 'persistent': 'true'})
def nfs_exports(self):
"""
Returns a list of exports (in hash form)
"""
rc = []
exports = self._invoke('nfs-exportfs-list-rules')
if 'rules' in exports and exports['rules']:
rc = to_list(exports['rules']['exports-rule-info'])
return rc
def volume_children(self, volume):
params = {'volume': volume}
rc = self._invoke('volume-list-info', params)
if 'clone-children' in rc['volumes']['volume-info']:
tmp = rc['volumes']['volume-info']['clone-children'][
'clone-child-info']
rc = [c['clone-child-name'] for c in to_list(tmp)]
else:
rc = None
return rc
def volume_split_clone(self, volume):
self._invoke('volume-clone-split-start', {'volume': volume})
def volume_split_status(self):
result = []
rc = self._invoke('volume-clone-split-status')
if 'clone-split-details' in rc:
tmp = rc['clone-split-details']['clone-split-detail-info']
result = [r['name'] for r in to_list(tmp)]
return result
def fcp_list(self):
fcp_list = []
try:
rc = self._invoke('fcp-adapter-list-info')
if 'fcp-config-adapters' in rc:
if 'fcp-config-adapter-info' in rc['fcp-config-adapters']:
fc_config = rc['fcp-config-adapters']
adapters = fc_config['fcp-config-adapter-info']
for f in adapters:
fcp_list.append(dict(addr=f['port-name'],
adapter=f['adapter']))
except FilerError as na:
if na.errno != Filer.EAPILICENSE:
raise
return fcp_list
def iscsi_node_name(self):
try:
rc = self._invoke('iscsi-node-get-name')
if 'node-name' in rc:
return rc['node-name']
except FilerError as na:
if na.errno != Filer.EAPILICENSE:
raise
return None
def interface_get_infos(self):
i_info = {}
rc = self._invoke('net-ifconfig-get')
if 'interface-config-info' in rc:
i_config = rc['interface-config-info']
if 'interface-config-info' in i_config:
tmp = to_list(i_config['interface-config-info'])
for i in tmp:
i_info[i['interface-name']] = i
return i_info
def iscsi_list(self):
i_list = []
# Get interface information
i_info = self.interface_get_infos()
try:
rc = self._invoke('iscsi-portal-list-info')
if 'iscsi-portal-list-entries' in rc:
portal_entries = rc['iscsi-portal-list-entries']
if 'iscsi-portal-list-entry-info' in portal_entries:
tmp = portal_entries['iscsi-portal-list-entry-info']
portals = to_list(tmp)
for p in portals:
mac = i_info[p['interface-name']]['mac-address']
i_list.append(dict(interface=p['interface-name'],
ip=p['ip-address'],
port=p['ip-port'],
mac=mac))
except FilerError as na:
if na.errno != Filer.EAPILICENSE:
raise
return i_list
if __name__ == '__main__':
try:
#TODO: Need some unit test code
pass
except FilerError as fe:
print 'Errno=', fe.errno, 'reason=', fe.reason
|
lgpl-2.1
|
[
3,
1898,
334,
35,
9,
6029,
13,
7280,
9572,
13002,
12,
3277,
14,
199,
3,
961,
3555,
365,
2867,
2032,
27,
1265,
883,
3604,
652,
436,
15,
269,
199,
3,
2811,
652,
1334,
314,
2895,
402,
314,
1664,
6401,
1696,
1684,
199,
3,
844,
465,
3267,
701,
314,
2868,
2290,
2752,
27,
1902,
199,
3,
1015,
499,
14,
17,
402,
314,
844,
12,
503,
1263,
2945,
1015,
14,
199,
3,
199,
3,
961,
3555,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
1664,
199,
3,
6401,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
6401,
1696,
1684,
199,
3,
844,
3180,
543,
642,
3555,
27,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
3,
199,
3,
6529,
26,
307,
305,
274,
834,
199,
199,
646,
4011,
18,
199,
646,
2838,
199,
646,
984,
199,
504,
2748,
14,
9464,
492,
13139,
199,
646,
900,
199,
504,
14755,
492,
6318,
8209,
199,
504,
485,
4266,
492,
7799,
547,
199,
199,
504,
603,
18,
17134,
492,
29256,
20,
199,
199,
504,
9100,
77,
14,
5159,
14,
1652,
475,
807,
492,
3957,
63,
1652,
63,
475,
63,
807,
199,
504,
9100,
77,
492,
334,
547,
3259,
9,
421,
199,
3,
1084,
370,
376,
5827,
2082,
436,
570,
370,
5461,
314,
3066,
1177,
14,
199,
1652,
63,
1757,
275,
488,
421,
199,
318,
15742,
63,
29292,
63,
1122,
63,
1310,
8,
4518,
304,
272,
340,
2748,
63,
1757,
26,
267,
734,
275,
1551,
8,
1652,
63,
1757,
12,
298,
6603,
531,
267,
734,
14,
952,
8,
4518,
9,
267,
734,
14,
1600,
342,
339,
372,
3957,
63,
1652,
63,
475,
63,
807,
8,
15325,
14,
13521,
8,
4518,
430,
421,
199,
318,
1215,
63,
585,
8,
637,
304,
272,
408,
272,
9138,
282,
2725,
370,
986,
370,
570,
82,
12,
3957,
370,
4692,
272,
408,
272,
4819,
275,
3087,
272,
340,
730,
8,
637,
9,
365,
1211,
503,
1228,
8,
637,
12,
1211,
304,
267,
367,
1022,
12,
373,
315,
1139,
14,
1744,
837,
288,
4819,
847,
23054,
83,
6598,
83,
26191,
83,
4335,
450,
334,
75,
12,
1215,
63,
585,
8,
86,
395,
1022,
9,
272,
916,
730,
8,
637,
9,
365,
769,
503,
1228,
8,
637,
12,
769,
304,
267,
367,
284,
315,
1139,
26,
288,
4819,
847,
1215,
63,
585,
8,
73,
9,
272,
587,
26,
267,
4819,
275,
1139,
272,
372,
4819,
421,
199,
318,
15742,
63,
29292,
8,
1102,
12,
3434,
12,
2505,
12,
2653,
12,
1414,
12,
2633,
29,
403,
12,
326,
6149,
29,
797,
304,
272,
408,
272,
13383,
282,
1414,
370,
314,
28076,
570,
82,
14,
272,
3390,
26,
7743,
370,
849,
6149,
641,
2544,
781,
15924,
282,
4683,
1015,
14,
272,
408,
272,
4104,
275,
283,
1014,
7,
272,
340,
6149,
26,
267,
4104,
275,
283,
2859,
7,
339,
1166,
275,
2071,
83,
13827,
83,
15,
7297,
16537,
15,
25830,
14,
7297,
16537,
14,
2113,
14,
4317,
1069,
63,
29292,
2,
450,
971,
881,
334,
2625,
12,
1591,
9,
339,
2648,
275,
4011,
18,
14,
2017,
8,
633,
9,
272,
2648,
14,
525,
63,
1291,
360,
2714,
13,
804,
297,
283,
505,
15,
1652,
358,
339,
2505,
63,
2609,
275,
4011,
18,
14,
2856,
6139,
20752,
3007,
2698,
27422,
342,
272,
2505,
63,
2609,
14,
525,
63,
2060,
8,
403,
12,
1166,
12,
3434,
12,
2505,
9,
272,
1790,
63,
2609,
275,
4011,
18,
14,
2856,
6845,
21547,
8,
2060,
63,
2609,
9,
339,
16088,
275,
4011,
18,
14,
1506,
63,
11637,
8,
1178,
63,
2609,
9,
272,
4011,
18,
14,
3174,
63,
11637,
8,
11637,
9,
339,
327,
1506,
314,
1414,
436,
314,
2368,
367,
652,
272,
299,
275,
3087,
339,
340,
2633,
26,
267,
367,
1022,
12,
373,
315,
2633,
14,
1744,
837,
288,
299,
847,
23054,
83,
6598,
83,
26191,
83,
4335,
450,
334,
75,
12,
1215,
63,
585,
8,
86,
395,
1022,
9,
339,
4886,
275,
23054,
83,
3072,
78,
5,
83,
60,
78,
26191,
83,
4335,
450,
334,
1531,
12,
299,
12,
1414,
9,
339,
666,
275,
31501,
1652,
1015,
628,
17,
14,
16,
2,
2644,
628,
6610,
13,
24,
24327,
199,
11230,
16556,
15742,
20859,
298,
493,
11254,
6839,
15,
25830,
63,
29292,
14,
15662,
1743,
199,
28,
25830,
9604,
628,
1014,
921,
1544,
14,
25830,
14,
957,
15,
29292,
15,
2113,
2,
1015,
628,
17,
14,
17,
1743,
199,
5,
83,
199,
1108,
25830,
30,
199,
624,
450,
4886,
339,
3016,
275,
488,
272,
4819,
275,
488,
272,
862,
26,
267,
3016,
275,
4011,
18,
14,
10890,
8,
2103,
12,
666,
12,
2069,
8,
2593,
430,
398,
340,
3016,
14,
362,
600,
342,
508,
1926,
26,
288,
4819,
275,
15742,
63,
29292,
63,
1122,
63,
1310,
8,
2232,
14,
739,
1012,
272,
871,
4011,
18,
14,
12815,
465,
946,
26,
267,
746,
272,
871,
4011,
18,
14,
31475,
465,
221,
310,
26,
267,
340,
1228,
8,
310,
14,
5764,
12,
2838,
14,
2593,
304,
288,
746,
481,
3566,
547,
8,
1173,
82,
14,
10931,
1877,
12,
298,
3225,
2653,
531,
267,
587,
26,
288,
746,
272,
871,
2838,
14,
2593,
26,
267,
746,
481,
3566,
547,
8,
1173,
82,
14,
10931,
1877,
12,
298,
3225,
2653,
531,
272,
871,
7799,
547,
465,
308,
261,
26,
267,
327,
710,
6149,
3555,
3181,
1133,
8120,
282,
6954,
4340,
370,
2342,
2488,
4499,
14,
267,
327,
2136,
787,
9689,
282,
1059,
3509,
1314,
365,
440,
28264,
12,
1325,
1163,
2419,
267,
327,
7978,
316,
282,
7809,
1125,
315,
642,
1930,
2337,
5712,
1133,
8298,
781,
883,
886,
267,
327,
370,
506,
1655,
2488,
14,
267,
340,
298,
26687,
734,
2,
315,
620,
8,
28780,
680,
2325,
837,
288,
746,
481,
3566,
547,
8,
1173,
82,
14,
10931,
1877,
12,
298,
3225,
2653,
334,
5413,
6320,
267,
587,
26,
288,
746,
481,
3566,
547,
8,
1173,
82,
14,
37,
11588,
12,
2490,
298,
5413,
1125,
8920,
4366,
83
] |
[
1898,
334,
35,
9,
6029,
13,
7280,
9572,
13002,
12,
3277,
14,
199,
3,
961,
3555,
365,
2867,
2032,
27,
1265,
883,
3604,
652,
436,
15,
269,
199,
3,
2811,
652,
1334,
314,
2895,
402,
314,
1664,
6401,
1696,
1684,
199,
3,
844,
465,
3267,
701,
314,
2868,
2290,
2752,
27,
1902,
199,
3,
1015,
499,
14,
17,
402,
314,
844,
12,
503,
1263,
2945,
1015,
14,
199,
3,
199,
3,
961,
3555,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
1664,
199,
3,
6401,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
6401,
1696,
1684,
199,
3,
844,
3180,
543,
642,
3555,
27,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
3,
199,
3,
6529,
26,
307,
305,
274,
834,
199,
199,
646,
4011,
18,
199,
646,
2838,
199,
646,
984,
199,
504,
2748,
14,
9464,
492,
13139,
199,
646,
900,
199,
504,
14755,
492,
6318,
8209,
199,
504,
485,
4266,
492,
7799,
547,
199,
199,
504,
603,
18,
17134,
492,
29256,
20,
199,
199,
504,
9100,
77,
14,
5159,
14,
1652,
475,
807,
492,
3957,
63,
1652,
63,
475,
63,
807,
199,
504,
9100,
77,
492,
334,
547,
3259,
9,
421,
199,
3,
1084,
370,
376,
5827,
2082,
436,
570,
370,
5461,
314,
3066,
1177,
14,
199,
1652,
63,
1757,
275,
488,
421,
199,
318,
15742,
63,
29292,
63,
1122,
63,
1310,
8,
4518,
304,
272,
340,
2748,
63,
1757,
26,
267,
734,
275,
1551,
8,
1652,
63,
1757,
12,
298,
6603,
531,
267,
734,
14,
952,
8,
4518,
9,
267,
734,
14,
1600,
342,
339,
372,
3957,
63,
1652,
63,
475,
63,
807,
8,
15325,
14,
13521,
8,
4518,
430,
421,
199,
318,
1215,
63,
585,
8,
637,
304,
272,
408,
272,
9138,
282,
2725,
370,
986,
370,
570,
82,
12,
3957,
370,
4692,
272,
408,
272,
4819,
275,
3087,
272,
340,
730,
8,
637,
9,
365,
1211,
503,
1228,
8,
637,
12,
1211,
304,
267,
367,
1022,
12,
373,
315,
1139,
14,
1744,
837,
288,
4819,
847,
23054,
83,
6598,
83,
26191,
83,
4335,
450,
334,
75,
12,
1215,
63,
585,
8,
86,
395,
1022,
9,
272,
916,
730,
8,
637,
9,
365,
769,
503,
1228,
8,
637,
12,
769,
304,
267,
367,
284,
315,
1139,
26,
288,
4819,
847,
1215,
63,
585,
8,
73,
9,
272,
587,
26,
267,
4819,
275,
1139,
272,
372,
4819,
421,
199,
318,
15742,
63,
29292,
8,
1102,
12,
3434,
12,
2505,
12,
2653,
12,
1414,
12,
2633,
29,
403,
12,
326,
6149,
29,
797,
304,
272,
408,
272,
13383,
282,
1414,
370,
314,
28076,
570,
82,
14,
272,
3390,
26,
7743,
370,
849,
6149,
641,
2544,
781,
15924,
282,
4683,
1015,
14,
272,
408,
272,
4104,
275,
283,
1014,
7,
272,
340,
6149,
26,
267,
4104,
275,
283,
2859,
7,
339,
1166,
275,
2071,
83,
13827,
83,
15,
7297,
16537,
15,
25830,
14,
7297,
16537,
14,
2113,
14,
4317,
1069,
63,
29292,
2,
450,
971,
881,
334,
2625,
12,
1591,
9,
339,
2648,
275,
4011,
18,
14,
2017,
8,
633,
9,
272,
2648,
14,
525,
63,
1291,
360,
2714,
13,
804,
297,
283,
505,
15,
1652,
358,
339,
2505,
63,
2609,
275,
4011,
18,
14,
2856,
6139,
20752,
3007,
2698,
27422,
342,
272,
2505,
63,
2609,
14,
525,
63,
2060,
8,
403,
12,
1166,
12,
3434,
12,
2505,
9,
272,
1790,
63,
2609,
275,
4011,
18,
14,
2856,
6845,
21547,
8,
2060,
63,
2609,
9,
339,
16088,
275,
4011,
18,
14,
1506,
63,
11637,
8,
1178,
63,
2609,
9,
272,
4011,
18,
14,
3174,
63,
11637,
8,
11637,
9,
339,
327,
1506,
314,
1414,
436,
314,
2368,
367,
652,
272,
299,
275,
3087,
339,
340,
2633,
26,
267,
367,
1022,
12,
373,
315,
2633,
14,
1744,
837,
288,
299,
847,
23054,
83,
6598,
83,
26191,
83,
4335,
450,
334,
75,
12,
1215,
63,
585,
8,
86,
395,
1022,
9,
339,
4886,
275,
23054,
83,
3072,
78,
5,
83,
60,
78,
26191,
83,
4335,
450,
334,
1531,
12,
299,
12,
1414,
9,
339,
666,
275,
31501,
1652,
1015,
628,
17,
14,
16,
2,
2644,
628,
6610,
13,
24,
24327,
199,
11230,
16556,
15742,
20859,
298,
493,
11254,
6839,
15,
25830,
63,
29292,
14,
15662,
1743,
199,
28,
25830,
9604,
628,
1014,
921,
1544,
14,
25830,
14,
957,
15,
29292,
15,
2113,
2,
1015,
628,
17,
14,
17,
1743,
199,
5,
83,
199,
1108,
25830,
30,
199,
624,
450,
4886,
339,
3016,
275,
488,
272,
4819,
275,
488,
272,
862,
26,
267,
3016,
275,
4011,
18,
14,
10890,
8,
2103,
12,
666,
12,
2069,
8,
2593,
430,
398,
340,
3016,
14,
362,
600,
342,
508,
1926,
26,
288,
4819,
275,
15742,
63,
29292,
63,
1122,
63,
1310,
8,
2232,
14,
739,
1012,
272,
871,
4011,
18,
14,
12815,
465,
946,
26,
267,
746,
272,
871,
4011,
18,
14,
31475,
465,
221,
310,
26,
267,
340,
1228,
8,
310,
14,
5764,
12,
2838,
14,
2593,
304,
288,
746,
481,
3566,
547,
8,
1173,
82,
14,
10931,
1877,
12,
298,
3225,
2653,
531,
267,
587,
26,
288,
746,
272,
871,
2838,
14,
2593,
26,
267,
746,
481,
3566,
547,
8,
1173,
82,
14,
10931,
1877,
12,
298,
3225,
2653,
531,
272,
871,
7799,
547,
465,
308,
261,
26,
267,
327,
710,
6149,
3555,
3181,
1133,
8120,
282,
6954,
4340,
370,
2342,
2488,
4499,
14,
267,
327,
2136,
787,
9689,
282,
1059,
3509,
1314,
365,
440,
28264,
12,
1325,
1163,
2419,
267,
327,
7978,
316,
282,
7809,
1125,
315,
642,
1930,
2337,
5712,
1133,
8298,
781,
883,
886,
267,
327,
370,
506,
1655,
2488,
14,
267,
340,
298,
26687,
734,
2,
315,
620,
8,
28780,
680,
2325,
837,
288,
746,
481,
3566,
547,
8,
1173,
82,
14,
10931,
1877,
12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1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
miconof/headphones
|
lib/yaml/composer.py
|
534
|
4921
|
__all__ = ['Composer', 'ComposerError']
from error import MarkedYAMLError
from events import *
from nodes import *
class ComposerError(MarkedYAMLError):
pass
class Composer(object):
def __init__(self):
self.anchors = {}
def check_node(self):
# Drop the STREAM-START event.
if self.check_event(StreamStartEvent):
self.get_event()
# If there are more documents available?
return not self.check_event(StreamEndEvent)
def get_node(self):
# Get the root node of the next document.
if not self.check_event(StreamEndEvent):
return self.compose_document()
def get_single_node(self):
# Drop the STREAM-START event.
self.get_event()
# Compose a document if the stream is not empty.
document = None
if not self.check_event(StreamEndEvent):
document = self.compose_document()
# Ensure that the stream contains no more documents.
if not self.check_event(StreamEndEvent):
event = self.get_event()
raise ComposerError("expected a single document in the stream",
document.start_mark, "but found another document",
event.start_mark)
# Drop the STREAM-END event.
self.get_event()
return document
def compose_document(self):
# Drop the DOCUMENT-START event.
self.get_event()
# Compose the root node.
node = self.compose_node(None, None)
# Drop the DOCUMENT-END event.
self.get_event()
self.anchors = {}
return node
def compose_node(self, parent, index):
if self.check_event(AliasEvent):
event = self.get_event()
anchor = event.anchor
if anchor not in self.anchors:
raise ComposerError(None, None, "found undefined alias %r"
% anchor.encode('utf-8'), event.start_mark)
return self.anchors[anchor]
event = self.peek_event()
anchor = event.anchor
if anchor is not None:
if anchor in self.anchors:
raise ComposerError("found duplicate anchor %r; first occurence"
% anchor.encode('utf-8'), self.anchors[anchor].start_mark,
"second occurence", event.start_mark)
self.descend_resolver(parent, index)
if self.check_event(ScalarEvent):
node = self.compose_scalar_node(anchor)
elif self.check_event(SequenceStartEvent):
node = self.compose_sequence_node(anchor)
elif self.check_event(MappingStartEvent):
node = self.compose_mapping_node(anchor)
self.ascend_resolver()
return node
def compose_scalar_node(self, anchor):
event = self.get_event()
tag = event.tag
if tag is None or tag == u'!':
tag = self.resolve(ScalarNode, event.value, event.implicit)
node = ScalarNode(tag, event.value,
event.start_mark, event.end_mark, style=event.style)
if anchor is not None:
self.anchors[anchor] = node
return node
def compose_sequence_node(self, anchor):
start_event = self.get_event()
tag = start_event.tag
if tag is None or tag == u'!':
tag = self.resolve(SequenceNode, None, start_event.implicit)
node = SequenceNode(tag, [],
start_event.start_mark, None,
flow_style=start_event.flow_style)
if anchor is not None:
self.anchors[anchor] = node
index = 0
while not self.check_event(SequenceEndEvent):
node.value.append(self.compose_node(node, index))
index += 1
end_event = self.get_event()
node.end_mark = end_event.end_mark
return node
def compose_mapping_node(self, anchor):
start_event = self.get_event()
tag = start_event.tag
if tag is None or tag == u'!':
tag = self.resolve(MappingNode, None, start_event.implicit)
node = MappingNode(tag, [],
start_event.start_mark, None,
flow_style=start_event.flow_style)
if anchor is not None:
self.anchors[anchor] = node
while not self.check_event(MappingEndEvent):
#key_event = self.peek_event()
item_key = self.compose_node(node, None)
#if item_key in node.value:
# raise ComposerError("while composing a mapping", start_event.start_mark,
# "found duplicate key", key_event.start_mark)
item_value = self.compose_node(node, item_key)
#node.value[item_key] = item_value
node.value.append((item_key, item_value))
end_event = self.get_event()
node.end_mark = end_event.end_mark
return node
|
gpl-3.0
|
[
199,
363,
452,
363,
275,
788,
32325,
297,
283,
32325,
547,
418,
199,
199,
504,
1125,
492,
7173,
379,
23103,
547,
199,
504,
4474,
492,
627,
199,
504,
3380,
492,
627,
199,
199,
533,
3599,
13041,
547,
8,
6470,
379,
23103,
547,
304,
272,
986,
199,
199,
533,
3599,
13041,
8,
785,
304,
339,
347,
636,
826,
721,
277,
304,
267,
291,
14,
25942,
275,
1052,
339,
347,
1104,
63,
932,
8,
277,
304,
267,
327,
18110,
314,
4384,
8909,
13,
7363,
1566,
14,
267,
340,
291,
14,
1074,
63,
1430,
8,
3296,
3162,
2390,
304,
288,
291,
14,
362,
63,
1430,
342,
398,
327,
982,
2337,
787,
1655,
8247,
2808,
31,
267,
372,
440,
291,
14,
1074,
63,
1430,
8,
3296,
3005,
2390,
9,
339,
347,
664,
63,
932,
8,
277,
304,
267,
327,
2372,
314,
1738,
1031,
402,
314,
2163,
2213,
14,
267,
340,
440,
291,
14,
1074,
63,
1430,
8,
3296,
3005,
2390,
304,
288,
372,
291,
14,
12607,
63,
3554,
342,
339,
347,
664,
63,
4780,
63,
932,
8,
277,
304,
267,
327,
18110,
314,
4384,
8909,
13,
7363,
1566,
14,
267,
291,
14,
362,
63,
1430,
342,
398,
327,
3599,
3362,
282,
2213,
340,
314,
2547,
365,
440,
2701,
14,
267,
2213,
275,
488,
267,
340,
440,
291,
14,
1074,
63,
1430,
8,
3296,
3005,
2390,
304,
288,
2213,
275,
291,
14,
12607,
63,
3554,
342,
398,
327,
7523,
626,
314,
2547,
3509,
949,
1655,
8247,
14,
267,
340,
440,
291,
14,
1074,
63,
1430,
8,
3296,
3005,
2390,
304,
288,
1566,
275,
291,
14,
362,
63,
1430,
342,
288,
746,
3599,
13041,
547,
480,
2062,
282,
2849,
2213,
315,
314,
2547,
401,
490,
2213,
14,
928,
63,
1657,
12,
298,
7911,
1911,
4573,
2213,
401,
490,
1566,
14,
928,
63,
1657,
9,
398,
327,
18110,
314,
4384,
8909,
13,
3902,
1566,
14,
267,
291,
14,
362,
63,
1430,
342,
398,
372,
2213,
339,
347,
23366,
63,
3554,
8,
277,
304,
267,
327,
18110,
314,
29970,
13,
7363,
1566,
14,
267,
291,
14,
362,
63,
1430,
342,
398,
327,
3599,
3362,
314,
1738,
1031,
14,
267,
1031,
275,
291,
14,
12607,
63,
932,
8,
403,
12,
488,
9,
398,
327,
18110,
314,
29970,
13,
3902,
1566,
14,
267,
291,
14,
362,
63,
1430,
342,
398,
291,
14,
25942,
275,
1052,
267,
372,
1031,
339,
347,
23366,
63,
932,
8,
277,
12,
1676,
12,
1478,
304,
267,
340,
291,
14,
1074,
63,
1430,
8,
14149,
2390,
304,
288,
1566,
275,
291,
14,
362,
63,
1430,
342,
288,
12514,
275,
1566,
14,
11498,
288,
340,
12514,
440,
315,
291,
14,
25942,
26,
355,
746,
3599,
13041,
547,
8,
403,
12,
488,
12,
298,
4214,
10942,
5162,
450,
82,
2,
717,
450,
12514,
14,
2143,
360,
1624,
13,
24,
659,
1566,
14,
928,
63,
1657,
9,
288,
372,
291,
14,
25942,
59,
11498,
61,
267,
1566,
275,
291,
14,
13164,
63,
1430,
342,
267,
12514,
275,
1566,
14,
11498,
267,
340,
12514,
365,
440,
488,
26,
288,
340,
12514,
315,
291,
14,
25942,
26,
355,
746,
3599,
13041,
547,
480,
4214,
9250,
12514,
450,
82,
27,
1642,
14706,
608,
21225,
2,
717,
450,
12514,
14,
2143,
360,
1624,
13,
24,
659,
291,
14,
25942,
59,
11498,
1055,
928,
63,
1657,
12,
717,
298,
4375,
14706,
608,
21225,
401,
1566,
14,
928,
63,
1657,
9,
267,
291,
14,
18180,
63,
7717,
8,
1708,
12,
1478,
9,
267,
340,
291,
14,
1074,
63,
1430,
8,
13090,
2390,
304,
288,
1031,
275,
291,
14,
12607,
63,
7033,
63,
932,
8,
11498,
9,
267,
916,
291,
14,
1074,
63,
1430,
8,
5826,
3162,
2390,
304,
288,
1031,
275,
291,
14,
12607,
63,
4041,
63,
932,
8,
11498,
9,
267,
916,
291,
14,
1074,
63,
1430,
8,
7674,
3162,
2390,
304,
288,
1031,
275,
291,
14,
12607,
63,
4745,
63,
932,
8,
11498,
9,
267,
291,
14,
10125,
500,
63,
7717,
342,
267,
372,
1031,
339,
347,
23366,
63,
7033,
63,
932,
8,
277,
12,
12514,
304,
267,
1566,
275,
291,
14,
362,
63,
1430,
342,
267,
1947,
275,
1566,
14,
1450,
267,
340,
1947,
365,
488,
503,
1947,
508,
399,
7,
27676,
288,
1947,
275,
291,
14,
6983,
8,
13090,
1716,
12,
1566,
14,
585,
12,
1566,
14,
11886,
9,
267,
1031,
275,
24289,
1716,
8,
1450,
12,
1566,
14,
585,
12,
355,
1566,
14,
928,
63,
1657,
12,
1566,
14,
500,
63,
1657,
12,
3449,
29,
1430,
14,
2487,
9,
267,
340,
12514,
365,
440,
488,
26,
288,
291,
14,
25942,
59,
11498,
61,
275,
1031,
267,
372,
1031,
339,
347,
23366,
63,
4041,
63,
932,
8,
277,
12,
12514,
304,
267,
1343,
63,
1430,
275,
291,
14,
362,
63,
1430,
342,
267,
1947,
275,
1343,
63,
1430,
14,
1450,
267,
340,
1947,
365,
488,
503,
1947,
508,
399,
7,
27676,
288,
1947,
275,
291,
14,
6983,
8,
5826,
1716,
12,
488,
12,
1343,
63,
1430,
14,
11886,
9,
267,
1031,
275,
10975,
1716,
8,
1450,
12,
990,
355,
1343,
63,
1430,
14,
928,
63,
1657,
12,
488,
12,
355,
6369,
63,
2487,
29,
928,
63,
1430,
14,
1659,
63,
2487,
9,
267,
340,
12514,
365,
440,
488,
26,
288,
291,
14,
25942,
59,
11498,
61,
275,
1031,
267,
1478,
275,
378,
267,
1830,
440,
291,
14,
1074,
63,
1430,
8,
5826,
3005,
2390,
304,
288,
1031,
14,
585,
14,
740,
8,
277,
14,
12607,
63,
932,
8,
932,
12,
1478,
430,
288,
1478,
847,
413,
267,
1284,
63,
1430,
275,
291,
14,
362,
63,
1430,
342,
267,
1031,
14,
500,
63,
1657,
275,
1284,
63,
1430,
14,
500,
63,
1657,
267,
372,
1031,
339,
347,
23366,
63,
4745,
63,
932,
8,
277,
12,
12514,
304,
267,
1343,
63,
1430,
275,
291,
14,
362,
63,
1430,
342,
267,
1947,
275,
1343,
63,
1430,
14,
1450,
267,
340,
1947,
365,
488,
503,
1947,
508,
399,
7,
27676,
288,
1947,
275,
291,
14,
6983,
8,
7674,
1716,
12,
488,
12,
1343,
63,
1430,
14,
11886,
9,
267,
1031,
275,
12340,
1716,
8,
1450,
12,
990,
355,
1343,
63,
1430,
14,
928,
63,
1657,
12,
488,
12,
355,
6369,
63,
2487,
29,
928,
63,
1430,
14,
1659,
63
] |
[
363,
452,
363,
275,
788,
32325,
297,
283,
32325,
547,
418,
199,
199,
504,
1125,
492,
7173,
379,
23103,
547,
199,
504,
4474,
492,
627,
199,
504,
3380,
492,
627,
199,
199,
533,
3599,
13041,
547,
8,
6470,
379,
23103,
547,
304,
272,
986,
199,
199,
533,
3599,
13041,
8,
785,
304,
339,
347,
636,
826,
721,
277,
304,
267,
291,
14,
25942,
275,
1052,
339,
347,
1104,
63,
932,
8,
277,
304,
267,
327,
18110,
314,
4384,
8909,
13,
7363,
1566,
14,
267,
340,
291,
14,
1074,
63,
1430,
8,
3296,
3162,
2390,
304,
288,
291,
14,
362,
63,
1430,
342,
398,
327,
982,
2337,
787,
1655,
8247,
2808,
31,
267,
372,
440,
291,
14,
1074,
63,
1430,
8,
3296,
3005,
2390,
9,
339,
347,
664,
63,
932,
8,
277,
304,
267,
327,
2372,
314,
1738,
1031,
402,
314,
2163,
2213,
14,
267,
340,
440,
291,
14,
1074,
63,
1430,
8,
3296,
3005,
2390,
304,
288,
372,
291,
14,
12607,
63,
3554,
342,
339,
347,
664,
63,
4780,
63,
932,
8,
277,
304,
267,
327,
18110,
314,
4384,
8909,
13,
7363,
1566,
14,
267,
291,
14,
362,
63,
1430,
342,
398,
327,
3599,
3362,
282,
2213,
340,
314,
2547,
365,
440,
2701,
14,
267,
2213,
275,
488,
267,
340,
440,
291,
14,
1074,
63,
1430,
8,
3296,
3005,
2390,
304,
288,
2213,
275,
291,
14,
12607,
63,
3554,
342,
398,
327,
7523,
626,
314,
2547,
3509,
949,
1655,
8247,
14,
267,
340,
440,
291,
14,
1074,
63,
1430,
8,
3296,
3005,
2390,
304,
288,
1566,
275,
291,
14,
362,
63,
1430,
342,
288,
746,
3599,
13041,
547,
480,
2062,
282,
2849,
2213,
315,
314,
2547,
401,
490,
2213,
14,
928,
63,
1657,
12,
298,
7911,
1911,
4573,
2213,
401,
490,
1566,
14,
928,
63,
1657,
9,
398,
327,
18110,
314,
4384,
8909,
13,
3902,
1566,
14,
267,
291,
14,
362,
63,
1430,
342,
398,
372,
2213,
339,
347,
23366,
63,
3554,
8,
277,
304,
267,
327,
18110,
314,
29970,
13,
7363,
1566,
14,
267,
291,
14,
362,
63,
1430,
342,
398,
327,
3599,
3362,
314,
1738,
1031,
14,
267,
1031,
275,
291,
14,
12607,
63,
932,
8,
403,
12,
488,
9,
398,
327,
18110,
314,
29970,
13,
3902,
1566,
14,
267,
291,
14,
362,
63,
1430,
342,
398,
291,
14,
25942,
275,
1052,
267,
372,
1031,
339,
347,
23366,
63,
932,
8,
277,
12,
1676,
12,
1478,
304,
267,
340,
291,
14,
1074,
63,
1430,
8,
14149,
2390,
304,
288,
1566,
275,
291,
14,
362,
63,
1430,
342,
288,
12514,
275,
1566,
14,
11498,
288,
340,
12514,
440,
315,
291,
14,
25942,
26,
355,
746,
3599,
13041,
547,
8,
403,
12,
488,
12,
298,
4214,
10942,
5162,
450,
82,
2,
717,
450,
12514,
14,
2143,
360,
1624,
13,
24,
659,
1566,
14,
928,
63,
1657,
9,
288,
372,
291,
14,
25942,
59,
11498,
61,
267,
1566,
275,
291,
14,
13164,
63,
1430,
342,
267,
12514,
275,
1566,
14,
11498,
267,
340,
12514,
365,
440,
488,
26,
288,
340,
12514,
315,
291,
14,
25942,
26,
355,
746,
3599,
13041,
547,
480,
4214,
9250,
12514,
450,
82,
27,
1642,
14706,
608,
21225,
2,
717,
450,
12514,
14,
2143,
360,
1624,
13,
24,
659,
291,
14,
25942,
59,
11498,
1055,
928,
63,
1657,
12,
717,
298,
4375,
14706,
608,
21225,
401,
1566,
14,
928,
63,
1657,
9,
267,
291,
14,
18180,
63,
7717,
8,
1708,
12,
1478,
9,
267,
340,
291,
14,
1074,
63,
1430,
8,
13090,
2390,
304,
288,
1031,
275,
291,
14,
12607,
63,
7033,
63,
932,
8,
11498,
9,
267,
916,
291,
14,
1074,
63,
1430,
8,
5826,
3162,
2390,
304,
288,
1031,
275,
291,
14,
12607,
63,
4041,
63,
932,
8,
11498,
9,
267,
916,
291,
14,
1074,
63,
1430,
8,
7674,
3162,
2390,
304,
288,
1031,
275,
291,
14,
12607,
63,
4745,
63,
932,
8,
11498,
9,
267,
291,
14,
10125,
500,
63,
7717,
342,
267,
372,
1031,
339,
347,
23366,
63,
7033,
63,
932,
8,
277,
12,
12514,
304,
267,
1566,
275,
291,
14,
362,
63,
1430,
342,
267,
1947,
275,
1566,
14,
1450,
267,
340,
1947,
365,
488,
503,
1947,
508,
399,
7,
27676,
288,
1947,
275,
291,
14,
6983,
8,
13090,
1716,
12,
1566,
14,
585,
12,
1566,
14,
11886,
9,
267,
1031,
275,
24289,
1716,
8,
1450,
12,
1566,
14,
585,
12,
355,
1566,
14,
928,
63,
1657,
12,
1566,
14,
500,
63,
1657,
12,
3449,
29,
1430,
14,
2487,
9,
267,
340,
12514,
365,
440,
488,
26,
288,
291,
14,
25942,
59,
11498,
61,
275,
1031,
267,
372,
1031,
339,
347,
23366,
63,
4041,
63,
932,
8,
277,
12,
12514,
304,
267,
1343,
63,
1430,
275,
291,
14,
362,
63,
1430,
342,
267,
1947,
275,
1343,
63,
1430,
14,
1450,
267,
340,
1947,
365,
488,
503,
1947,
508,
399,
7,
27676,
288,
1947,
275,
291,
14,
6983,
8,
5826,
1716,
12,
488,
12,
1343,
63,
1430,
14,
11886,
9,
267,
1031,
275,
10975,
1716,
8,
1450,
12,
990,
355,
1343,
63,
1430,
14,
928,
63,
1657,
12,
488,
12,
355,
6369,
63,
2487,
29,
928,
63,
1430,
14,
1659,
63,
2487,
9,
267,
340,
12514,
365,
440,
488,
26,
288,
291,
14,
25942,
59,
11498,
61,
275,
1031,
267,
1478,
275,
378,
267,
1830,
440,
291,
14,
1074,
63,
1430,
8,
5826,
3005,
2390,
304,
288,
1031,
14,
585,
14,
740,
8,
277,
14,
12607,
63,
932,
8,
932,
12,
1478,
430,
288,
1478,
847,
413,
267,
1284,
63,
1430,
275,
291,
14,
362,
63,
1430,
342,
267,
1031,
14,
500,
63,
1657,
275,
1284,
63,
1430,
14,
500,
63,
1657,
267,
372,
1031,
339,
347,
23366,
63,
4745,
63,
932,
8,
277,
12,
12514,
304,
267,
1343,
63,
1430,
275,
291,
14,
362,
63,
1430,
342,
267,
1947,
275,
1343,
63,
1430,
14,
1450,
267,
340,
1947,
365,
488,
503,
1947,
508,
399,
7,
27676,
288,
1947,
275,
291,
14,
6983,
8,
7674,
1716,
12,
488,
12,
1343,
63,
1430,
14,
11886,
9,
267,
1031,
275,
12340,
1716,
8,
1450,
12,
990,
355,
1343,
63,
1430,
14,
928,
63,
1657,
12,
488,
12,
355,
6369,
63,
2487,
29,
928,
63,
1430,
14,
1659,
63,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
ISTweak/android_kernel_toshiba_is11t
|
Documentation/networking/cxacru-cf.py
|
14668
|
1626
|
#!/usr/bin/env python
# Copyright 2009 Simon Arlott
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the Free
# Software Foundation; either version 2 of the License, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
# more details.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, write to the Free Software Foundation, Inc., 59
# Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
# Usage: cxacru-cf.py < cxacru-cf.bin
# Output: values string suitable for the sysfs adsl_config attribute
#
# Warning: cxacru-cf.bin with MD5 hash cdbac2689969d5ed5d4850f117702110
# contains mis-aligned values which will stop the modem from being able
# to make a connection. If the first and last two bytes are removed then
# the values become valid, but the modulation will be forced to ANSI
# T1.413 only which may not be appropriate.
#
# The original binary format is a packed list of le32 values.
import sys
import struct
i = 0
while True:
buf = sys.stdin.read(4)
if len(buf) == 0:
break
elif len(buf) != 4:
sys.stdout.write("\n")
sys.stderr.write("Error: read {0} not 4 bytes\n".format(len(buf)))
sys.exit(1)
if i > 0:
sys.stdout.write(" ")
sys.stdout.write("{0:x}={1}".format(i, struct.unpack("<I", buf)[0]))
i += 1
sys.stdout.write("\n")
|
gpl-2.0
|
[
3381,
2647,
15,
1393,
15,
1813,
2366,
199,
3,
1898,
8937,
10751,
265,
1952,
1653,
84,
199,
3,
199,
3,
961,
2240,
365,
2867,
2032,
27,
1265,
883,
3604,
652,
436,
15,
269,
2811,
652,
199,
3,
1334,
314,
2895,
402,
314,
1664,
1696,
1684,
844,
465,
3267,
701,
314,
2868,
199,
3,
2290,
2752,
27,
1902,
1015,
499,
402,
314,
844,
12,
503,
334,
292,
2195,
945,
9,
199,
3,
1263,
2945,
1015,
14,
199,
3,
199,
3,
961,
2240,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
1325,
2428,
199,
3,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
3169,
503,
199,
3,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
1664,
1696,
1684,
844,
367,
199,
3,
1655,
2436,
14,
199,
3,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
1696,
1684,
844,
3180,
543,
199,
3,
642,
2240,
27,
340,
440,
12,
2218,
370,
314,
2868,
2290,
2752,
12,
3277,
2020,
8155,
199,
3,
15630,
10902,
446,
14453,
13540,
12,
8226,
12,
4828,
221,
15673,
13,
13421,
12,
8217,
14,
199,
3,
199,
3,
11028,
26,
286,
10104,
6558,
13,
2177,
14,
647,
665,
286,
10104,
6558,
13,
2177,
14,
1393,
199,
3,
7242,
26,
1338,
1059,
11233,
367,
314,
984,
2319,
282,
795,
76,
63,
888,
2225,
199,
3,
199,
3,
15902,
26,
286,
10104,
6558,
13,
2177,
14,
1393,
543,
15830,
21,
2631,
286,
697,
645,
13731,
1020,
1876,
68,
21,
379,
21,
68,
2006,
1400,
70,
845,
1138,
996,
6019,
199,
3,
3509,
3201,
13,
19175,
1338,
1314,
911,
3631,
314,
818,
77,
687,
3769,
7688,
199,
3,
370,
1852,
282,
1950,
14,
982,
314,
1642,
436,
2061,
2877,
2783,
787,
4829,
2066,
199,
3,
314,
1338,
8649,
1686,
12,
1325,
314,
3413,
5332,
911,
506,
19565,
370,
25600,
199,
3,
377,
17,
14,
23663,
1454,
1314,
1443,
440,
506,
5827,
14,
199,
3,
199,
3,
710,
3379,
3366,
1475,
365,
282,
13170,
769,
402,
1026,
708,
1338,
14,
199,
199,
646,
984,
199,
646,
2702,
199,
199,
73,
275,
378,
199,
6710,
715,
26,
199,
198,
1436,
275,
984,
14,
6626,
14,
739,
8,
20,
9,
421,
198,
692,
822,
8,
1436,
9,
508,
378,
26,
507,
198,
4785,
199,
198,
4164,
822,
8,
1436,
9,
1137,
841,
26,
507,
198,
1274,
14,
2703,
14,
952,
4582,
78,
531,
507,
198,
1274,
14,
3083,
14,
952,
480,
547,
26,
1586,
469,
16,
93,
440,
841,
2783,
60,
78,
1674,
908,
8,
552,
8,
1436,
1724,
507,
198,
1274,
14,
2224,
8,
17,
9,
421,
198,
692,
284,
690,
378,
26,
507,
198,
1274,
14,
2703,
14,
952,
480,
6099,
199,
198,
1274,
14,
2703,
14,
952,
13076,
16,
26,
88,
93,
3126,
17,
5469,
908,
8,
73,
12,
2702,
14,
5301,
6757,
41,
401,
4123,
2788,
16,
2459,
199,
198,
73,
847,
413,
199,
199,
1274,
14,
2703,
14,
952,
4582,
78,
531,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
2647,
15,
1393,
15,
1813,
2366,
199,
3,
1898,
8937,
10751,
265,
1952,
1653,
84,
199,
3,
199,
3,
961,
2240,
365,
2867,
2032,
27,
1265,
883,
3604,
652,
436,
15,
269,
2811,
652,
199,
3,
1334,
314,
2895,
402,
314,
1664,
1696,
1684,
844,
465,
3267,
701,
314,
2868,
199,
3,
2290,
2752,
27,
1902,
1015,
499,
402,
314,
844,
12,
503,
334,
292,
2195,
945,
9,
199,
3,
1263,
2945,
1015,
14,
199,
3,
199,
3,
961,
2240,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
1325,
2428,
199,
3,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
3169,
503,
199,
3,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
1664,
1696,
1684,
844,
367,
199,
3,
1655,
2436,
14,
199,
3,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
1696,
1684,
844,
3180,
543,
199,
3,
642,
2240,
27,
340,
440,
12,
2218,
370,
314,
2868,
2290,
2752,
12,
3277,
2020,
8155,
199,
3,
15630,
10902,
446,
14453,
13540,
12,
8226,
12,
4828,
221,
15673,
13,
13421,
12,
8217,
14,
199,
3,
199,
3,
11028,
26,
286,
10104,
6558,
13,
2177,
14,
647,
665,
286,
10104,
6558,
13,
2177,
14,
1393,
199,
3,
7242,
26,
1338,
1059,
11233,
367,
314,
984,
2319,
282,
795,
76,
63,
888,
2225,
199,
3,
199,
3,
15902,
26,
286,
10104,
6558,
13,
2177,
14,
1393,
543,
15830,
21,
2631,
286,
697,
645,
13731,
1020,
1876,
68,
21,
379,
21,
68,
2006,
1400,
70,
845,
1138,
996,
6019,
199,
3,
3509,
3201,
13,
19175,
1338,
1314,
911,
3631,
314,
818,
77,
687,
3769,
7688,
199,
3,
370,
1852,
282,
1950,
14,
982,
314,
1642,
436,
2061,
2877,
2783,
787,
4829,
2066,
199,
3,
314,
1338,
8649,
1686,
12,
1325,
314,
3413,
5332,
911,
506,
19565,
370,
25600,
199,
3,
377,
17,
14,
23663,
1454,
1314,
1443,
440,
506,
5827,
14,
199,
3,
199,
3,
710,
3379,
3366,
1475,
365,
282,
13170,
769,
402,
1026,
708,
1338,
14,
199,
199,
646,
984,
199,
646,
2702,
199,
199,
73,
275,
378,
199,
6710,
715,
26,
199,
198,
1436,
275,
984,
14,
6626,
14,
739,
8,
20,
9,
421,
198,
692,
822,
8,
1436,
9,
508,
378,
26,
507,
198,
4785,
199,
198,
4164,
822,
8,
1436,
9,
1137,
841,
26,
507,
198,
1274,
14,
2703,
14,
952,
4582,
78,
531,
507,
198,
1274,
14,
3083,
14,
952,
480,
547,
26,
1586,
469,
16,
93,
440,
841,
2783,
60,
78,
1674,
908,
8,
552,
8,
1436,
1724,
507,
198,
1274,
14,
2224,
8,
17,
9,
421,
198,
692,
284,
690,
378,
26,
507,
198,
1274,
14,
2703,
14,
952,
480,
6099,
199,
198,
1274,
14,
2703,
14,
952,
13076,
16,
26,
88,
93,
3126,
17,
5469,
908,
8,
73,
12,
2702,
14,
5301,
6757,
41,
401,
4123,
2788,
16,
2459,
199,
198,
73,
847,
413,
199,
199,
1274,
14,
2703,
14,
952,
4582,
78,
531,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
curtisstpierre/django
|
tests/utils_tests/test_baseconv.py
|
326
|
1787
|
from unittest import TestCase
from django.utils.baseconv import (
BaseConverter, base2, base16, base36, base56, base62, base64,
)
from django.utils.six.moves import range
class TestBaseConv(TestCase):
def test_baseconv(self):
nums = [-10 ** 10, 10 ** 10] + list(range(-100, 100))
for converter in [base2, base16, base36, base56, base62, base64]:
for i in nums:
self.assertEqual(i, converter.decode(converter.encode(i)))
def test_base11(self):
base11 = BaseConverter('0123456789-', sign='$')
self.assertEqual(base11.encode(1234), '-22')
self.assertEqual(base11.decode('-22'), 1234)
self.assertEqual(base11.encode(-1234), '$-22')
self.assertEqual(base11.decode('$-22'), -1234)
def test_base20(self):
base20 = BaseConverter('0123456789abcdefghij')
self.assertEqual(base20.encode(1234), '31e')
self.assertEqual(base20.decode('31e'), 1234)
self.assertEqual(base20.encode(-1234), '-31e')
self.assertEqual(base20.decode('-31e'), -1234)
def test_base64(self):
self.assertEqual(base64.encode(1234), 'JI')
self.assertEqual(base64.decode('JI'), 1234)
self.assertEqual(base64.encode(-1234), '$JI')
self.assertEqual(base64.decode('$JI'), -1234)
def test_base7(self):
base7 = BaseConverter('cjdhel3', sign='g')
self.assertEqual(base7.encode(1234), 'hejd')
self.assertEqual(base7.decode('hejd'), 1234)
self.assertEqual(base7.encode(-1234), 'ghejd')
self.assertEqual(base7.decode('ghejd'), -1234)
def test_exception(self):
self.assertRaises(ValueError, BaseConverter, 'abc', sign='a')
self.assertIsInstance(BaseConverter('abc', sign='d'), BaseConverter)
|
bsd-3-clause
|
[
504,
2882,
492,
7640,
199,
199,
504,
1639,
14,
1208,
14,
1095,
5598,
492,
334,
272,
3523,
11907,
12,
1300,
18,
12,
1300,
975,
12,
1300,
1344,
12,
1300,
1367,
12,
1300,
2789,
12,
1300,
772,
12,
199,
9,
199,
504,
1639,
14,
1208,
14,
4174,
14,
4912,
492,
1425,
421,
199,
533,
1379,
1563,
11596,
8,
1746,
304,
339,
347,
511,
63,
1095,
5598,
8,
277,
304,
267,
24047,
275,
5243,
709,
1011,
1616,
12,
1616,
1011,
1616,
61,
435,
769,
8,
1842,
2801,
1960,
12,
2948,
430,
267,
367,
11109,
315,
359,
1095,
18,
12,
1300,
975,
12,
1300,
1344,
12,
1300,
1367,
12,
1300,
2789,
12,
1300,
772,
2189,
288,
367,
284,
315,
24047,
26,
355,
291,
14,
629,
8,
73,
12,
11109,
14,
2708,
8,
11256,
14,
2143,
8,
73,
1724,
339,
347,
511,
63,
1095,
845,
8,
277,
304,
267,
1300,
845,
275,
3523,
11907,
360,
11371,
14382,
2070,
534,
9988,
267,
291,
14,
629,
8,
1095,
845,
14,
2143,
8,
4321,
395,
2475,
1081,
358,
267,
291,
14,
629,
8,
1095,
845,
14,
2708,
3654,
1081,
659,
14763,
9,
267,
291,
14,
629,
8,
1095,
845,
14,
2143,
2801,
4321,
395,
4505,
13,
1081,
358,
267,
291,
14,
629,
8,
1095,
845,
14,
2708,
14676,
13,
1081,
659,
446,
4321,
9,
339,
347,
511,
63,
1095,
1165,
8,
277,
304,
267,
1300,
1165,
275,
3523,
11907,
360,
11371,
18677,
358,
267,
291,
14,
629,
8,
1095,
1165,
14,
2143,
8,
4321,
395,
283,
2192,
69,
358,
267,
291,
14,
629,
8,
1095,
1165,
14,
2708,
360,
2192,
69,
659,
14763,
9,
267,
291,
14,
629,
8,
1095,
1165,
14,
2143,
2801,
4321,
395,
2475,
2192,
69,
358,
267,
291,
14,
629,
8,
1095,
1165,
14,
2708,
3654,
2192,
69,
659,
446,
4321,
9,
339,
347,
511,
63,
1095,
772,
8,
277,
304,
267,
291,
14,
629,
8,
1095,
772,
14,
2143,
8,
4321,
395,
283,
32126,
358,
267,
291,
14,
629,
8,
1095,
772,
14,
2708,
360,
32126,
659,
14763,
9,
267,
291,
14,
629,
8,
1095,
772,
14,
2143,
2801,
4321,
395,
4505,
32126,
358,
267,
291,
14,
629,
8,
1095,
772,
14,
2708,
14676,
32126,
659,
446,
4321,
9,
339,
347,
511,
63,
1095,
23,
8,
277,
304,
267,
1300,
23,
275,
3523,
11907,
360,
24862,
7821,
352,
19,
297,
2070,
534,
71,
358,
267,
291,
14,
629,
8,
1095,
23,
14,
2143,
8,
4321,
395,
283,
426,
17694,
358,
267,
291,
14,
629,
8,
1095,
23,
14,
2708,
360,
426,
17694,
659,
14763,
9,
267,
291,
14,
629,
8,
1095,
23,
14,
2143,
2801,
4321,
395,
283,
71,
426,
17694,
358,
267,
291,
14,
629,
8,
1095,
23,
14,
2708,
360,
71,
426,
17694,
659,
446,
4321,
9,
339,
347,
511,
63,
1971,
8,
277,
304,
267,
291,
14,
1855,
8,
3393,
12,
3523,
11907,
12,
283,
3175,
297,
2070,
534,
65,
358,
267,
291,
14,
6926,
8,
1563,
11907,
360,
3175,
297,
2070,
534,
68,
659,
3523,
11907,
9,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
2882,
492,
7640,
199,
199,
504,
1639,
14,
1208,
14,
1095,
5598,
492,
334,
272,
3523,
11907,
12,
1300,
18,
12,
1300,
975,
12,
1300,
1344,
12,
1300,
1367,
12,
1300,
2789,
12,
1300,
772,
12,
199,
9,
199,
504,
1639,
14,
1208,
14,
4174,
14,
4912,
492,
1425,
421,
199,
533,
1379,
1563,
11596,
8,
1746,
304,
339,
347,
511,
63,
1095,
5598,
8,
277,
304,
267,
24047,
275,
5243,
709,
1011,
1616,
12,
1616,
1011,
1616,
61,
435,
769,
8,
1842,
2801,
1960,
12,
2948,
430,
267,
367,
11109,
315,
359,
1095,
18,
12,
1300,
975,
12,
1300,
1344,
12,
1300,
1367,
12,
1300,
2789,
12,
1300,
772,
2189,
288,
367,
284,
315,
24047,
26,
355,
291,
14,
629,
8,
73,
12,
11109,
14,
2708,
8,
11256,
14,
2143,
8,
73,
1724,
339,
347,
511,
63,
1095,
845,
8,
277,
304,
267,
1300,
845,
275,
3523,
11907,
360,
11371,
14382,
2070,
534,
9988,
267,
291,
14,
629,
8,
1095,
845,
14,
2143,
8,
4321,
395,
2475,
1081,
358,
267,
291,
14,
629,
8,
1095,
845,
14,
2708,
3654,
1081,
659,
14763,
9,
267,
291,
14,
629,
8,
1095,
845,
14,
2143,
2801,
4321,
395,
4505,
13,
1081,
358,
267,
291,
14,
629,
8,
1095,
845,
14,
2708,
14676,
13,
1081,
659,
446,
4321,
9,
339,
347,
511,
63,
1095,
1165,
8,
277,
304,
267,
1300,
1165,
275,
3523,
11907,
360,
11371,
18677,
358,
267,
291,
14,
629,
8,
1095,
1165,
14,
2143,
8,
4321,
395,
283,
2192,
69,
358,
267,
291,
14,
629,
8,
1095,
1165,
14,
2708,
360,
2192,
69,
659,
14763,
9,
267,
291,
14,
629,
8,
1095,
1165,
14,
2143,
2801,
4321,
395,
2475,
2192,
69,
358,
267,
291,
14,
629,
8,
1095,
1165,
14,
2708,
3654,
2192,
69,
659,
446,
4321,
9,
339,
347,
511,
63,
1095,
772,
8,
277,
304,
267,
291,
14,
629,
8,
1095,
772,
14,
2143,
8,
4321,
395,
283,
32126,
358,
267,
291,
14,
629,
8,
1095,
772,
14,
2708,
360,
32126,
659,
14763,
9,
267,
291,
14,
629,
8,
1095,
772,
14,
2143,
2801,
4321,
395,
4505,
32126,
358,
267,
291,
14,
629,
8,
1095,
772,
14,
2708,
14676,
32126,
659,
446,
4321,
9,
339,
347,
511,
63,
1095,
23,
8,
277,
304,
267,
1300,
23,
275,
3523,
11907,
360,
24862,
7821,
352,
19,
297,
2070,
534,
71,
358,
267,
291,
14,
629,
8,
1095,
23,
14,
2143,
8,
4321,
395,
283,
426,
17694,
358,
267,
291,
14,
629,
8,
1095,
23,
14,
2708,
360,
426,
17694,
659,
14763,
9,
267,
291,
14,
629,
8,
1095,
23,
14,
2143,
2801,
4321,
395,
283,
71,
426,
17694,
358,
267,
291,
14,
629,
8,
1095,
23,
14,
2708,
360,
71,
426,
17694,
659,
446,
4321,
9,
339,
347,
511,
63,
1971,
8,
277,
304,
267,
291,
14,
1855,
8,
3393,
12,
3523,
11907,
12,
283,
3175,
297,
2070,
534,
65,
358,
267,
291,
14,
6926,
8,
1563,
11907,
360,
3175,
297,
2070,
534,
68,
659,
3523,
11907,
9,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
40223137/w17w17
|
static/Brython3.1.0-20150301-090019/Lib/site-packages/pygame/surface.py
|
603
|
3844
|
from browser import document, html, window
from javascript import console, JSConstructor
from .rect import Rect
#import pygame.rect
canvas_ID=1
_canvas_id=None
class Surface:
def __init__(self, dim=[], depth=16, surf=None):
if surf is None:
self._depth=depth
self._canvas=html.CANVAS(width=dim[0], height=dim[1])
elif isinstance(surf, Surface):
self._canvas=surf.copy()
#self._width=surf.get_width()
#self._height=surf.get_height()
elif isinstance(surf, html.CANVAS):
self._canvas=surf
#self._width=surf.style.width
#self._height=surf.style.height
self._context=self._canvas.getContext('2d')
self._canvas.id='layer_%s' % canvas_ID
#setattr(self._canvas.style, 'z-index',canvas_ID)
#setattr(self._canvas.style, 'position', 'relative')
#setattr(self._canvas.style, 'left', '0px')
#setattr(self._canvas.style, 'top', '0px')
canvas_ID+=1
#document['pydiv'] <= self._canvas
def blit(self, source, dest, area=None, special_flags=0):
#if area is None and isinstance(source, str):
# _img = JSConstructor(window.Image)()
# _img.src = source
# def img_onload(*args):
# self._context.drawImage(_img, dest[0], dest[1])
# _img.onload=img_onload
# _img.width, _img.height
global _canvas_id
if _canvas_id is None:
try:
_canvas_id=document.get(selector='canvas')[0].getAttribute('id')
except:
pass
if self._canvas.id == _canvas_id:
self._canvas.width=self._canvas.width
if area is None:
#lets set area to the size of the source
if isinstance(source, Surface):
area=[(0, 0), (source.canvas.width, source.canvas.height)]
if isinstance(source, Surface):
_ctx=source.canvas.getContext('2d')
_subset=_ctx.getImageData(area[0][0],area[0][1], area[1][0], area[1][1])
# we want just a subset of the source image copied
self._context.putImageData(_subset, dest[0], dest[1])
#print(dest[0], dest[1], _subset.width, _subset.height)
return Rect(dest[0], dest[1], dest[0]+_subset.width, dest[1]+_subset.height)
def convert(self, surface=None):
## fix me...
return self
def copy(self):
_imgdata=self._context.toDataURL('image/png')
_canvas=html.CANVAS(width=self._canvas.width,height=self._canvas.height)
_ctx=_canvas.getContext('2d')
_ctx.drawImage(_imgdata, 0, 0)
return _canvas
def fill(self, color):
""" fill canvas with this color """
self._context.fillStyle="rgb(%s,%s,%s)" % color
#console.log(self._canvas.width, self._canvas.height, self._context.fillStyle)
self._context.fillRect(0,0,self._canvas.width,self._canvas.height)
#self._context.fill()
@property
def height(self):
return int(self._canvas.height)
@property
def width(self):
return int(self._canvas.width)
@property
def canvas(self):
return self._canvas
def scroll(self, dx=0, dy=0):
_imgdata=self._context.toDataURL('image/png')
self._context.drawImage(_imgdata, dx, dy)
def get_at(self, pos):
#returns rgb
return self._context.getImageData(pos[0], pos[1],1,1).data
def set_at(self, pos, color):
self._context.fillStyle='rgb(%s,%s,%s)' % color
self._context.fillRect(pos[0], pos[1], 1, 1)
def get_size(self):
return self._canvas.width, self._canvas.height
def get_width(self):
return self._canvas.width
def get_height(self):
return self._canvas.height
def get_rect(self, centerx=None, centery=None):
return Rect(0, 0, self._canvas.width, self._canvas.height)
def set_colorkey(self, key, val):
pass
|
gpl-3.0
|
[
504,
7042,
492,
2213,
12,
3517,
12,
4353,
199,
504,
18910,
492,
8559,
12,
18001,
11447,
199,
199,
504,
1275,
1201,
492,
21536,
199,
3,
646,
9193,
14,
1201,
199,
199,
7682,
63,
998,
29,
17,
199,
199,
63,
7682,
63,
344,
29,
403,
199,
199,
533,
29564,
26,
523,
347,
636,
826,
721,
277,
12,
8134,
6034,
5818,
29,
975,
12,
24802,
29,
403,
304,
489,
340,
24802,
365,
488,
26,
268,
291,
423,
4631,
29,
4631,
268,
291,
423,
7682,
29,
1360,
14,
18988,
54,
1179,
8,
2063,
29,
3572,
59,
16,
467,
4569,
29,
3572,
59,
17,
566,
489,
916,
1228,
8,
21579,
12,
29564,
304,
268,
291,
423,
7682,
29,
21579,
14,
1574,
342,
268,
327,
277,
423,
2063,
29,
21579,
14,
362,
63,
2063,
342,
268,
327,
277,
423,
3333,
29,
21579,
14,
362,
63,
3333,
342,
489,
916,
1228,
8,
21579,
12,
3517,
14,
18988,
54,
1179,
304,
268,
291,
423,
7682,
29,
21579,
268,
327,
277,
423,
2063,
29,
21579,
14,
2487,
14,
2063,
268,
327,
277,
423,
3333,
29,
21579,
14,
2487,
14,
3333,
2541,
291,
423,
1100,
29,
277,
423,
7682,
14,
32160,
360,
18,
68,
358,
489,
291,
423,
7682,
14,
344,
534,
1897,
4970,
83,
7,
450,
10218,
63,
998,
489,
327,
10202,
8,
277,
423,
7682,
14,
2487,
12,
283,
90,
13,
1080,
297,
7682,
63,
998,
9,
489,
327,
10202,
8,
277,
423,
7682,
14,
2487,
12,
283,
3124,
297,
283,
6188,
358,
489,
327,
10202,
8,
277,
423,
7682,
14,
2487,
12,
283,
3039,
297,
283,
16,
5326,
358,
489,
327,
10202,
8,
277,
423,
7682,
14,
2487,
12,
283,
2119,
297,
283,
16,
5326,
358,
489,
10218,
63,
998,
10365,
17,
2541,
327,
3554,
459,
647,
3015,
418,
2695,
291,
423,
7682,
819,
347,
330,
1051,
8,
277,
12,
1350,
12,
2053,
12,
9150,
29,
403,
12,
4539,
63,
2469,
29,
16,
304,
489,
327,
692,
9150,
365,
488,
436,
1228,
8,
1365,
12,
620,
304,
489,
327,
257,
485,
4060,
275,
18001,
11447,
8,
3806,
14,
3491,
16315,
489,
327,
257,
485,
4060,
14,
2164,
275,
1350,
2541,
327,
257,
347,
6050,
63,
265,
912,
2031,
589,
304,
489,
327,
755,
291,
423,
1100,
14,
5485,
3491,
1547,
4060,
12,
2053,
59,
16,
467,
2053,
59,
17,
566,
2541,
327,
257,
485,
4060,
14,
265,
912,
29,
4060,
63,
265,
912,
489,
327,
257,
485,
4060,
14,
2063,
12,
485,
4060,
14,
3333,
2541,
2288,
485,
7682,
63,
344,
2541,
340,
485,
7682,
63,
344,
365,
488,
26,
268,
862,
26,
1779,
485,
7682,
63,
344,
29,
3554,
14,
362,
8,
6662,
534,
7682,
5832,
16,
1055,
12956,
360,
344,
358,
268,
871,
26,
1779,
986,
2541,
340,
291,
423,
7682,
14,
344,
508,
485,
7682,
63,
344,
26,
268,
291,
423,
7682,
14,
2063,
29,
277,
423,
7682,
14,
2063,
32115,
340,
9150,
365,
488,
26,
288,
327,
16537,
663,
9150,
370,
314,
1568,
402,
314,
1350,
268,
340,
1228,
8,
1365,
12,
29564,
304,
288,
9150,
17497,
16,
12,
378,
395,
334,
1365,
14,
7682,
14,
2063,
12,
1350,
14,
7682,
14,
3333,
1874,
421,
489,
340,
1228,
8,
1365,
12,
29564,
304,
268,
485,
3799,
29,
1365,
14,
7682,
14,
32160,
360,
18,
68,
358,
268,
485,
9401,
3699,
3799,
14,
362,
3491,
1451,
8,
6789,
59,
16,
1527,
16,
467,
6789,
59,
16,
1527,
17,
467,
9150,
59,
17,
1527,
16,
467,
9150,
59,
17,
1527,
17,
566,
268,
327,
781,
2934,
2951,
282,
10026,
402,
314,
1350,
1834,
8876,
268,
291,
423,
1100,
14,
524,
3491,
1451,
1547,
9401,
12,
2053,
59,
16,
467,
2053,
59,
17,
566,
268,
327,
1361,
8,
2614,
59,
16,
467,
2053,
59,
17,
467,
485,
9401,
14,
2063,
12,
485,
9401,
14,
3333,
9,
268,
372,
21536,
8,
2614,
59,
16,
467,
2053,
59,
17,
467,
2053,
59,
16,
2807,
63,
9401,
14,
2063,
12,
2053,
59,
17,
2807,
63,
9401,
14,
3333,
9,
819,
347,
3957,
8,
277,
12,
13195,
29,
403,
304,
489,
925,
5325,
562,
1396,
489,
372,
291,
819,
347,
1331,
8,
277,
304,
489,
485,
4060,
576,
29,
277,
423,
1100,
14,
475,
1451,
2632,
360,
1569,
15,
4524,
358,
523,
489,
485,
7682,
29,
1360,
14,
18988,
54,
1179,
8,
2063,
29,
277,
423,
7682,
14,
2063,
12,
3333,
29,
277,
423,
7682,
14,
3333,
9,
489,
485,
3799,
3699,
7682,
14,
32160,
360,
18,
68,
358,
489,
485,
3799,
14,
5485,
3491,
1547,
4060,
576,
12,
378,
12,
378,
9,
2541,
372,
485,
7682,
1598,
523,
347,
5554,
8,
277,
12,
3164,
304,
489,
408,
5554,
10218,
543,
642,
3164,
408,
489,
291,
423,
1100,
14,
4498,
6609,
628,
10090,
4042,
83,
8719,
83,
8719,
83,
2924,
450,
3164,
489,
327,
6614,
14,
793,
8,
277,
423,
7682,
14,
2063,
12,
291,
423,
7682,
14,
3333,
12,
291,
423,
1100,
14,
4498,
6609,
9,
489,
291,
423,
1100,
14,
4498,
8252,
8,
16,
12,
16,
12,
277,
423,
7682,
14,
2063,
12,
277,
423,
7682,
14,
3333,
9,
489,
327,
277,
423,
1100,
14,
4498,
342,
819,
768,
1829,
523,
347,
4569,
8,
277,
304,
489,
372,
1109,
8,
277,
423,
7682,
14,
3333,
9,
819,
768,
1829,
523,
347,
3462,
8,
277,
304,
489,
372,
1109,
8,
277,
423,
7682,
14,
2063,
9,
819,
768,
1829,
523,
347,
10218,
8,
277,
304,
489,
372,
291,
423,
7682,
819,
347,
13704,
8,
277,
12,
11868,
29,
16,
12,
13119,
29,
16,
304,
489,
485,
4060,
576,
29,
277,
423,
1100,
14,
475,
1451,
2632,
360,
1569,
15,
4524,
358,
489,
291,
423,
1100,
14,
5485,
3491,
1547,
4060,
576,
12,
11868,
12,
13119,
9,
819,
347,
664,
63,
292,
8,
277,
12,
2086,
304,
489,
327,
5808,
15180,
489,
372,
291,
423,
1100,
14,
362,
3491,
1451,
8,
1712,
59,
16,
467,
2086,
59,
17,
467,
17,
12,
17,
680,
576,
819,
347,
663,
63,
292,
8,
277,
12,
2086,
12,
3164,
304,
489,
291,
423,
1100,
14,
4498,
6609,
534,
10090,
4042,
83,
8719,
83,
8719,
83,
3171,
450,
3164,
489,
291,
423,
1100,
14,
4498,
8252,
8,
1712
] |
[
7042,
492,
2213,
12,
3517,
12,
4353,
199,
504,
18910,
492,
8559,
12,
18001,
11447,
199,
199,
504,
1275,
1201,
492,
21536,
199,
3,
646,
9193,
14,
1201,
199,
199,
7682,
63,
998,
29,
17,
199,
199,
63,
7682,
63,
344,
29,
403,
199,
199,
533,
29564,
26,
523,
347,
636,
826,
721,
277,
12,
8134,
6034,
5818,
29,
975,
12,
24802,
29,
403,
304,
489,
340,
24802,
365,
488,
26,
268,
291,
423,
4631,
29,
4631,
268,
291,
423,
7682,
29,
1360,
14,
18988,
54,
1179,
8,
2063,
29,
3572,
59,
16,
467,
4569,
29,
3572,
59,
17,
566,
489,
916,
1228,
8,
21579,
12,
29564,
304,
268,
291,
423,
7682,
29,
21579,
14,
1574,
342,
268,
327,
277,
423,
2063,
29,
21579,
14,
362,
63,
2063,
342,
268,
327,
277,
423,
3333,
29,
21579,
14,
362,
63,
3333,
342,
489,
916,
1228,
8,
21579,
12,
3517,
14,
18988,
54,
1179,
304,
268,
291,
423,
7682,
29,
21579,
268,
327,
277,
423,
2063,
29,
21579,
14,
2487,
14,
2063,
268,
327,
277,
423,
3333,
29,
21579,
14,
2487,
14,
3333,
2541,
291,
423,
1100,
29,
277,
423,
7682,
14,
32160,
360,
18,
68,
358,
489,
291,
423,
7682,
14,
344,
534,
1897,
4970,
83,
7,
450,
10218,
63,
998,
489,
327,
10202,
8,
277,
423,
7682,
14,
2487,
12,
283,
90,
13,
1080,
297,
7682,
63,
998,
9,
489,
327,
10202,
8,
277,
423,
7682,
14,
2487,
12,
283,
3124,
297,
283,
6188,
358,
489,
327,
10202,
8,
277,
423,
7682,
14,
2487,
12,
283,
3039,
297,
283,
16,
5326,
358,
489,
327,
10202,
8,
277,
423,
7682,
14,
2487,
12,
283,
2119,
297,
283,
16,
5326,
358,
489,
10218,
63,
998,
10365,
17,
2541,
327,
3554,
459,
647,
3015,
418,
2695,
291,
423,
7682,
819,
347,
330,
1051,
8,
277,
12,
1350,
12,
2053,
12,
9150,
29,
403,
12,
4539,
63,
2469,
29,
16,
304,
489,
327,
692,
9150,
365,
488,
436,
1228,
8,
1365,
12,
620,
304,
489,
327,
257,
485,
4060,
275,
18001,
11447,
8,
3806,
14,
3491,
16315,
489,
327,
257,
485,
4060,
14,
2164,
275,
1350,
2541,
327,
257,
347,
6050,
63,
265,
912,
2031,
589,
304,
489,
327,
755,
291,
423,
1100,
14,
5485,
3491,
1547,
4060,
12,
2053,
59,
16,
467,
2053,
59,
17,
566,
2541,
327,
257,
485,
4060,
14,
265,
912,
29,
4060,
63,
265,
912,
489,
327,
257,
485,
4060,
14,
2063,
12,
485,
4060,
14,
3333,
2541,
2288,
485,
7682,
63,
344,
2541,
340,
485,
7682,
63,
344,
365,
488,
26,
268,
862,
26,
1779,
485,
7682,
63,
344,
29,
3554,
14,
362,
8,
6662,
534,
7682,
5832,
16,
1055,
12956,
360,
344,
358,
268,
871,
26,
1779,
986,
2541,
340,
291,
423,
7682,
14,
344,
508,
485,
7682,
63,
344,
26,
268,
291,
423,
7682,
14,
2063,
29,
277,
423,
7682,
14,
2063,
32115,
340,
9150,
365,
488,
26,
288,
327,
16537,
663,
9150,
370,
314,
1568,
402,
314,
1350,
268,
340,
1228,
8,
1365,
12,
29564,
304,
288,
9150,
17497,
16,
12,
378,
395,
334,
1365,
14,
7682,
14,
2063,
12,
1350,
14,
7682,
14,
3333,
1874,
421,
489,
340,
1228,
8,
1365,
12,
29564,
304,
268,
485,
3799,
29,
1365,
14,
7682,
14,
32160,
360,
18,
68,
358,
268,
485,
9401,
3699,
3799,
14,
362,
3491,
1451,
8,
6789,
59,
16,
1527,
16,
467,
6789,
59,
16,
1527,
17,
467,
9150,
59,
17,
1527,
16,
467,
9150,
59,
17,
1527,
17,
566,
268,
327,
781,
2934,
2951,
282,
10026,
402,
314,
1350,
1834,
8876,
268,
291,
423,
1100,
14,
524,
3491,
1451,
1547,
9401,
12,
2053,
59,
16,
467,
2053,
59,
17,
566,
268,
327,
1361,
8,
2614,
59,
16,
467,
2053,
59,
17,
467,
485,
9401,
14,
2063,
12,
485,
9401,
14,
3333,
9,
268,
372,
21536,
8,
2614,
59,
16,
467,
2053,
59,
17,
467,
2053,
59,
16,
2807,
63,
9401,
14,
2063,
12,
2053,
59,
17,
2807,
63,
9401,
14,
3333,
9,
819,
347,
3957,
8,
277,
12,
13195,
29,
403,
304,
489,
925,
5325,
562,
1396,
489,
372,
291,
819,
347,
1331,
8,
277,
304,
489,
485,
4060,
576,
29,
277,
423,
1100,
14,
475,
1451,
2632,
360,
1569,
15,
4524,
358,
523,
489,
485,
7682,
29,
1360,
14,
18988,
54,
1179,
8,
2063,
29,
277,
423,
7682,
14,
2063,
12,
3333,
29,
277,
423,
7682,
14,
3333,
9,
489,
485,
3799,
3699,
7682,
14,
32160,
360,
18,
68,
358,
489,
485,
3799,
14,
5485,
3491,
1547,
4060,
576,
12,
378,
12,
378,
9,
2541,
372,
485,
7682,
1598,
523,
347,
5554,
8,
277,
12,
3164,
304,
489,
408,
5554,
10218,
543,
642,
3164,
408,
489,
291,
423,
1100,
14,
4498,
6609,
628,
10090,
4042,
83,
8719,
83,
8719,
83,
2924,
450,
3164,
489,
327,
6614,
14,
793,
8,
277,
423,
7682,
14,
2063,
12,
291,
423,
7682,
14,
3333,
12,
291,
423,
1100,
14,
4498,
6609,
9,
489,
291,
423,
1100,
14,
4498,
8252,
8,
16,
12,
16,
12,
277,
423,
7682,
14,
2063,
12,
277,
423,
7682,
14,
3333,
9,
489,
327,
277,
423,
1100,
14,
4498,
342,
819,
768,
1829,
523,
347,
4569,
8,
277,
304,
489,
372,
1109,
8,
277,
423,
7682,
14,
3333,
9,
819,
768,
1829,
523,
347,
3462,
8,
277,
304,
489,
372,
1109,
8,
277,
423,
7682,
14,
2063,
9,
819,
768,
1829,
523,
347,
10218,
8,
277,
304,
489,
372,
291,
423,
7682,
819,
347,
13704,
8,
277,
12,
11868,
29,
16,
12,
13119,
29,
16,
304,
489,
485,
4060,
576,
29,
277,
423,
1100,
14,
475,
1451,
2632,
360,
1569,
15,
4524,
358,
489,
291,
423,
1100,
14,
5485,
3491,
1547,
4060,
576,
12,
11868,
12,
13119,
9,
819,
347,
664,
63,
292,
8,
277,
12,
2086,
304,
489,
327,
5808,
15180,
489,
372,
291,
423,
1100,
14,
362,
3491,
1451,
8,
1712,
59,
16,
467,
2086,
59,
17,
467,
17,
12,
17,
680,
576,
819,
347,
663,
63,
292,
8,
277,
12,
2086,
12,
3164,
304,
489,
291,
423,
1100,
14,
4498,
6609,
534,
10090,
4042,
83,
8719,
83,
8719,
83,
3171,
450,
3164,
489,
291,
423,
1100,
14,
4498,
8252,
8,
1712,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
Kilhog/odoo
|
openerp/addons/base/ir/ir_values.py
|
228
|
26238
|
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import pickle
from openerp import tools
from openerp.osv import osv, fields
from openerp.osv.orm import except_orm
EXCLUDED_FIELDS = set((
'report_sxw_content', 'report_rml_content', 'report_sxw', 'report_rml',
'report_sxw_content_data', 'report_rml_content_data', 'search_view', ))
#: Possible slots to bind an action to with :meth:`~.set_action`
ACTION_SLOTS = [
"client_action_multi", # sidebar wizard action
"client_print_multi", # sidebar report printing button
"client_action_relate", # sidebar related link
"tree_but_open", # double-click on item in tree view
"tree_but_action", # deprecated: same as tree_but_open
]
class ir_values(osv.osv):
"""Holds internal model-specific action bindings and user-defined default
field values. definitions. This is a legacy internal model, mixing
two different concepts, and will likely be updated or replaced in a
future version by cleaner, separate models. You should not depend
explicitly on it.
The purpose of each ``ir.values`` entry depends on its type, defined
by the ``key`` column:
* 'default': user-defined default values, used when creating new
records of this model:
* 'action': binding of an action to a particular *action slot* of
this model, making the action easily available in the user
interface for this model.
The ``key2`` column acts as a qualifier, further refining the type
of the entry. The possible values are:
* for 'default' entries: an optional condition restricting the
cases where this particular default value will be applicable,
or ``False`` for no condition
* for 'action' entries: the ``key2`` qualifier is one of the available
action slots, defining how this action can be invoked:
* ``'client_print_multi'`` for report printing actions that will
be available on views displaying items from this model
* ``'client_action_multi'`` for assistants (wizards) actions
that will be available in views displaying objects of this model
* ``'client_action_relate'`` for links towards related documents
that should be available in views displaying objects of this model
* ``'tree_but_open'`` for actions that will be triggered when
double-clicking an item from this model in a hierarchical tree view
Each entry is specific to a model (``model`` column), and for ``'actions'``
type, may even be made specific to a given record of that model when the
``res_id`` column contains a record ID (``False`` means it's global for
all records).
The content of the entry is defined by the ``value`` column, which may either
contain an arbitrary value, or a reference string defining the action that
should be executed.
.. rubric:: Usage: default values
The ``'default'`` entries are usually defined manually by the
users, and set by their UI clients calling :meth:`~.set_default`.
These default values are then automatically used by the
ORM every time a new record is about to be created, i.e. when
:meth:`~openerp.osv.osv.osv.default_get`
or :meth:`~openerp.osv.osv.osv.create` are called.
.. rubric:: Usage: action bindings
Business applications will usually bind their actions during
installation, and OpenERP UI clients will apply them as defined,
based on the list of actions included in the result of
:meth:`~openerp.osv.osv.osv.fields_view_get`,
or directly returned by explicit calls to :meth:`~.get_actions`.
"""
_name = 'ir.values'
def _value_unpickle(self, cursor, user, ids, name, arg, context=None):
res = {}
for record in self.browse(cursor, user, ids, context=context):
value = record[name[:-9]]
if record.key == 'default' and value:
# default values are pickled on the fly
try:
value = str(pickle.loads(value))
except Exception:
pass
res[record.id] = value
return res
def _value_pickle(self, cursor, user, id, name, value, arg, context=None):
if context is None:
context = {}
ctx = context.copy()
if self.CONCURRENCY_CHECK_FIELD in ctx:
del ctx[self.CONCURRENCY_CHECK_FIELD]
record = self.browse(cursor, user, id, context=context)
if record.key == 'default':
# default values are pickled on the fly
value = pickle.dumps(value)
self.write(cursor, user, id, {name[:-9]: value}, context=ctx)
def onchange_object_id(self, cr, uid, ids, object_id, context=None):
if not object_id: return {}
act = self.pool.get('ir.model').browse(cr, uid, object_id, context=context)
return {
'value': {'model': act.model}
}
def onchange_action_id(self, cr, uid, ids, action_id, context=None):
if not action_id: return {}
act = self.pool.get('ir.actions.actions').browse(cr, uid, action_id, context=context)
return {
'value': {'value_unpickle': act.type+','+str(act.id)}
}
_columns = {
'name': fields.char('Name', required=True),
'model': fields.char('Model Name', select=True, required=True,
help="Model to which this entry applies"),
# TODO: model_id and action_id should be read-write function fields
'model_id': fields.many2one('ir.model', 'Model (change only)', size=128,
help="Model to which this entry applies - "
"helper field for setting a model, will "
"automatically set the correct model name"),
'action_id': fields.many2one('ir.actions.actions', 'Action (change only)',
help="Action bound to this entry - "
"helper field for binding an action, will "
"automatically set the correct reference"),
'value': fields.text('Value', help="Default value (pickled) or reference to an action"),
'value_unpickle': fields.function(_value_unpickle, fnct_inv=_value_pickle,
type='text',
string='Default value or action reference'),
'key': fields.selection([('action','Action'),('default','Default')],
'Type', select=True, required=True,
help="- Action: an action attached to one slot of the given model\n"
"- Default: a default value for a model field"),
'key2' : fields.char('Qualifier', select=True,
help="For actions, one of the possible action slots: \n"
" - client_action_multi\n"
" - client_print_multi\n"
" - client_action_relate\n"
" - tree_but_open\n"
"For defaults, an optional condition"
,),
'res_id': fields.integer('Record ID', select=True,
help="Database identifier of the record to which this applies. "
"0 = for all records"),
'user_id': fields.many2one('res.users', 'User', ondelete='cascade', select=True,
help="If set, action binding only applies for this user."),
'company_id': fields.many2one('res.company', 'Company', ondelete='cascade', select=True,
help="If set, action binding only applies for this company")
}
_defaults = {
'key': 'action',
'key2': 'tree_but_open',
}
def _auto_init(self, cr, context=None):
super(ir_values, self)._auto_init(cr, context)
cr.execute('SELECT indexname FROM pg_indexes WHERE indexname = \'ir_values_key_model_key2_res_id_user_id_idx\'')
if not cr.fetchone():
cr.execute('CREATE INDEX ir_values_key_model_key2_res_id_user_id_idx ON ir_values (key, model, key2, res_id, user_id)')
def create(self, cr, uid, vals, context=None):
res = super(ir_values, self).create(cr, uid, vals, context=context)
self.get_defaults_dict.clear_cache(self)
return res
def write(self, cr, uid, ids, vals, context=None):
res = super(ir_values, self).write(cr, uid, ids, vals, context=context)
self.get_defaults_dict.clear_cache(self)
return res
def unlink(self, cr, uid, ids, context=None):
res = super(ir_values, self).unlink(cr, uid, ids, context=context)
self.get_defaults_dict.clear_cache(self)
return res
def set_default(self, cr, uid, model, field_name, value, for_all_users=True, company_id=False, condition=False):
"""Defines a default value for the given model and field_name. Any previous
default for the same scope (model, field_name, value, for_all_users, company_id, condition)
will be replaced and lost in the process.
Defaults can be later retrieved via :meth:`~.get_defaults`, which will return
the highest priority default for any given field. Defaults that are more specific
have a higher priority, in the following order (highest to lowest):
* specific to user and company
* specific to user only
* specific to company only
* global to everyone
:param string model: model name
:param string field_name: field name to which the default applies
:param value: the default field value to set
:type value: any serializable Python value
:param bool for_all_users: whether the default should apply to everybody or only
the user calling the method
:param int company_id: optional ID of the company to which the default should
apply. If omitted, the default will be global. If True
is passed, the current user's company will be used.
:param string condition: optional condition specification that can be used to
restrict the applicability of the default values
(e.g. based on another field's value). This is an
opaque string as far as the API is concerned, but client
stacks typically use single-field conditions in the
form ``'key=stringified_value'``.
(Currently, the condition is trimmed to 200 characters,
so values that share the same first 200 characters always
match)
:return: id of the newly created ir.values entry
"""
if isinstance(value, unicode):
value = value.encode('utf8')
if company_id is True:
# should be company-specific, need to get company id
user = self.pool.get('res.users').browse(cr, uid, uid)
company_id = user.company_id.id
# remove existing defaults for the same scope
search_criteria = [
('key', '=', 'default'),
('key2', '=', condition and condition[:200]),
('model', '=', model),
('name', '=', field_name),
('user_id', '=', False if for_all_users else uid),
('company_id','=', company_id)
]
self.unlink(cr, uid, self.search(cr, uid, search_criteria))
return self.create(cr, uid, {
'name': field_name,
'value': pickle.dumps(value),
'model': model,
'key': 'default',
'key2': condition and condition[:200],
'user_id': False if for_all_users else uid,
'company_id': company_id,
})
def get_default(self, cr, uid, model, field_name, for_all_users=True, company_id=False, condition=False):
""" Return the default value defined for model, field_name, users, company and condition.
Return ``None`` if no such default exists.
"""
search_criteria = [
('key', '=', 'default'),
('key2', '=', condition and condition[:200]),
('model', '=', model),
('name', '=', field_name),
('user_id', '=', False if for_all_users else uid),
('company_id','=', company_id)
]
defaults = self.browse(cr, uid, self.search(cr, uid, search_criteria))
return pickle.loads(defaults[0].value.encode('utf-8')) if defaults else None
def get_defaults(self, cr, uid, model, condition=False):
"""Returns any default values that are defined for the current model and user,
(and match ``condition``, if specified), previously registered via
:meth:`~.set_default`.
Defaults are global to a model, not field-specific, but an optional
``condition`` can be provided to restrict matching default values
to those that were defined for the same condition (usually based
on another field's value).
Default values also have priorities depending on whom they apply
to: only the highest priority value will be returned for any
field. See :meth:`~.set_default` for more details.
:param string model: model name
:param string condition: optional condition specification that can be used to
restrict the applicability of the default values
(e.g. based on another field's value). This is an
opaque string as far as the API is concerned, but client
stacks typically use single-field conditions in the
form ``'key=stringified_value'``.
(Currently, the condition is trimmed to 200 characters,
so values that share the same first 200 characters always
match)
:return: list of default values tuples of the form ``(id, field_name, value)``
(``id`` is the ID of the default entry, usually irrelevant)
"""
# use a direct SQL query for performance reasons,
# this is called very often
query = """SELECT v.id, v.name, v.value FROM ir_values v
LEFT JOIN res_users u ON (v.user_id = u.id)
WHERE v.key = %%s AND v.model = %%s
AND (v.user_id = %%s OR v.user_id IS NULL)
AND (v.company_id IS NULL OR
v.company_id =
(SELECT company_id from res_users where id = %%s)
)
%s
ORDER BY v.user_id, u.company_id"""
params = ('default', model, uid, uid)
if condition:
query %= 'AND v.key2 = %s'
params += (condition[:200],)
else:
query %= 'AND v.key2 is NULL'
cr.execute(query, params)
# keep only the highest priority default for each field
defaults = {}
for row in cr.dictfetchall():
defaults.setdefault(row['name'],
(row['id'], row['name'], pickle.loads(row['value'].encode('utf-8'))))
return defaults.values()
# use ormcache: this is called a lot by BaseModel.default_get()!
@tools.ormcache(skiparg=2)
def get_defaults_dict(self, cr, uid, model, condition=False):
""" Returns a dictionary mapping field names with their corresponding
default value. This method simply improves the returned value of
:meth:`~.get_defaults`.
"""
return dict((f, v) for i, f, v in self.get_defaults(cr, uid, model, condition))
def set_action(self, cr, uid, name, action_slot, model, action, res_id=False):
"""Binds an the given action to the given model's action slot - for later
retrieval via :meth:`~.get_actions`. Any existing binding of the same action
to the same slot is first removed, allowing an update of the action's name.
See the class description for more details about the various action
slots: :class:`~ir_values`.
:param string name: action label, usually displayed by UI client
:param string action_slot: the action slot to which the action should be
bound to - one of ``client_action_multi``,
``client_print_multi``, ``client_action_relate``,
``tree_but_open``.
:param string model: model name
:param string action: action reference, in the form ``'model,id'``
:param int res_id: optional record id - will bind the action only to a
specific record of the model, not all records.
:return: id of the newly created ir.values entry
"""
assert isinstance(action, basestring) and ',' in action, \
'Action definition must be an action reference, e.g. "ir.actions.act_window,42"'
assert action_slot in ACTION_SLOTS, \
'Action slot (%s) must be one of: %r' % (action_slot, ACTION_SLOTS)
# remove existing action definition of same slot and value
search_criteria = [
('key', '=', 'action'),
('key2', '=', action_slot),
('model', '=', model),
('res_id', '=', res_id or 0), # int field -> NULL == 0
('value', '=', action),
]
self.unlink(cr, uid, self.search(cr, uid, search_criteria))
return self.create(cr, uid, {
'key': 'action',
'key2': action_slot,
'model': model,
'res_id': res_id,
'name': name,
'value': action,
})
def get_actions(self, cr, uid, action_slot, model, res_id=False, context=None):
"""Retrieves the list of actions bound to the given model's action slot.
See the class description for more details about the various action
slots: :class:`~.ir_values`.
:param string action_slot: the action slot to which the actions should be
bound to - one of ``client_action_multi``,
``client_print_multi``, ``client_action_relate``,
``tree_but_open``.
:param string model: model name
:param int res_id: optional record id - will bind the action only to a
specific record of the model, not all records.
:return: list of action tuples of the form ``(id, name, action_def)``,
where ``id`` is the ID of the default entry, ``name`` is the
action label, and ``action_def`` is a dict containing the
action definition as obtained by calling
:meth:`~openerp.osv.osv.osv.read` on the action record.
"""
assert action_slot in ACTION_SLOTS, 'Illegal action slot value: %s' % action_slot
# use a direct SQL query for performance reasons,
# this is called very often
query = """SELECT v.id, v.name, v.value FROM ir_values v
WHERE v.key = %s AND v.key2 = %s
AND v.model = %s
AND (v.res_id = %s
OR v.res_id IS NULL
OR v.res_id = 0)
ORDER BY v.id"""
cr.execute(query, ('action', action_slot, model, res_id or None))
results = {}
for action in cr.dictfetchall():
if not action['value']:
continue # skip if undefined
action_model_name, action_id = action['value'].split(',')
if action_model_name not in self.pool:
continue # unknow model? skip it
action_model = self.pool[action_model_name]
fields = [field for field in action_model._fields if field not in EXCLUDED_FIELDS]
# FIXME: needs cleanup
try:
action_def = action_model.read(cr, uid, int(action_id), fields, context)
if action_def:
if action_model_name in ('ir.actions.report.xml', 'ir.actions.act_window'):
groups = action_def.get('groups_id')
if groups:
cr.execute('SELECT 1 FROM res_groups_users_rel WHERE gid IN %s AND uid=%s',
(tuple(groups), uid))
if not cr.fetchone():
if action['name'] == 'Menuitem':
raise osv.except_osv('Error!',
'You do not have the permission to perform this operation!!!')
continue
# keep only the first action registered for each action name
results[action['name']] = (action['id'], action['name'], action_def)
except except_orm:
continue
return sorted(results.values())
def _map_legacy_model_list(self, model_list, map_fn, merge_results=False):
"""Apply map_fn to the various models passed, according to
legacy way to specify models/records.
"""
assert isinstance(model_list, (list, tuple)), \
"model_list should be in the form [model,..] or [(model,res_id), ..]"
results = []
for model in model_list:
res_id = False
if isinstance(model, (list, tuple)):
model, res_id = model
result = map_fn(model, res_id)
# some of the functions return one result at a time (tuple or id)
# and some return a list of many of them - care for both
if merge_results:
results.extend(result)
else:
results.append(result)
return results
# Backards-compatibility adapter layer to retrofit into split API
def set(self, cr, uid, key, key2, name, models, value, replace=True, isobject=False, meta=False, preserve_user=False, company=False):
"""Deprecated legacy method to set default values and bind actions to models' action slots.
Now dispatches to the newer API methods according to the value of ``key``: :meth:`~.set_default`
(``key=='default'``) or :meth:`~.set_action` (``key == 'action'``).
:deprecated: As of v6.1, ``set_default()`` or ``set_action()`` should be used directly.
"""
assert key in ['default', 'action'], "ir.values entry keys must be in ['default','action']"
if key == 'default':
def do_set(model,res_id):
return self.set_default(cr, uid, model, field_name=name, value=value,
for_all_users=(not preserve_user), company_id=company,
condition=key2)
elif key == 'action':
def do_set(model,res_id):
return self.set_action(cr, uid, name, action_slot=key2, model=model, action=value, res_id=res_id)
return self._map_legacy_model_list(models, do_set)
def get(self, cr, uid, key, key2, models, meta=False, context=None, res_id_req=False, without_user=True, key2_req=True):
"""Deprecated legacy method to get the list of default values or actions bound to models' action slots.
Now dispatches to the newer API methods according to the value of ``key``: :meth:`~.get_defaults`
(``key=='default'``) or :meth:`~.get_actions` (``key == 'action'``)
:deprecated: As of v6.1, ``get_defaults()`` or ``get_actions()`` should be used directly.
"""
assert key in ['default', 'action'], "ir.values entry keys must be in ['default','action']"
if key == 'default':
def do_get(model,res_id):
return self.get_defaults(cr, uid, model, condition=key2)
elif key == 'action':
def do_get(model,res_id):
return self.get_actions(cr, uid, action_slot=key2, model=model, res_id=res_id, context=context)
return self._map_legacy_model_list(models, do_get, merge_results=True)
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
agpl-3.0
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
4605,
199,
3,
199,
3,
259,
7653,
12,
3232,
5800,
8259,
9274,
199,
3,
259,
1898,
334,
35,
9,
8353,
13,
8664,
11947,
12361,
8642,
1014,
921,
9864,
14,
1235,
10121,
199,
3,
199,
3,
259,
961,
2240,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
259,
652,
1334,
314,
2895,
402,
314,
1664,
4265,
1696,
1684,
844,
465,
199,
3,
259,
3267,
701,
314,
2868,
2290,
2752,
12,
1902,
1015,
650,
402,
314,
199,
3,
259,
844,
12,
503,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
259,
961,
2240,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
259,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
259,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
199,
3,
259,
1664,
4265,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
259,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
4265,
1696,
1684,
844,
199,
3,
259,
3180,
543,
642,
2240,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
3,
199,
4605,
199,
646,
5927,
199,
199,
504,
5166,
492,
7249,
199,
504,
5166,
14,
4795,
492,
9506,
12,
1504,
199,
504,
5166,
14,
4795,
14,
1025,
492,
871,
63,
1025,
199,
199,
29647,
53,
8280,
63,
12767,
275,
663,
1332,
272,
283,
3070,
63,
20851,
63,
1317,
297,
283,
3070,
63,
16300,
63,
1317,
297,
283,
3070,
63,
20851,
297,
283,
3070,
63,
16300,
297,
272,
283,
3070,
63,
20851,
63,
1317,
63,
576,
297,
283,
3070,
63,
16300,
63,
1317,
63,
576,
297,
283,
1733,
63,
1345,
297,
5082,
199,
199,
12573,
18558,
14319,
370,
5398,
376,
1595,
370,
543,
520,
5247,
18739,
409,
63,
1287,
64,
199,
10052,
63,
32328,
51,
275,
359,
355,
298,
1258,
63,
1287,
63,
3029,
401,
221,
327,
18437,
12262,
1595,
355,
298,
1258,
63,
1361,
63,
3029,
401,
257,
327,
18437,
3622,
16116,
5528,
355,
298,
1258,
63,
1287,
63,
17322,
401,
327,
18437,
4048,
2142,
355,
298,
2350,
63,
7911,
63,
1490,
401,
263,
327,
4270,
13,
4891,
641,
1242,
315,
3123,
2455,
355,
298,
2350,
63,
7911,
63,
1287,
401,
420,
327,
5906,
26,
2011,
465,
3123,
63,
7911,
63,
1490,
2049,
1622,
421,
199,
533,
8190,
63,
1459,
8,
4795,
14,
4795,
304,
272,
408,
40,
8250,
5007,
1402,
13,
6100,
1595,
17792,
436,
922,
13,
4037,
849,
2126,
901,
1338,
14,
10269,
14,
961,
365,
282,
12139,
5007,
1402,
12,
13667,
316,
2126,
2877,
3365,
19834,
83,
12,
436,
911,
12060,
506,
4588,
503,
8717,
315,
282,
2126,
6466,
1015,
701,
3633,
281,
12,
7396,
1709,
14,
2047,
1077,
440,
11687,
2126,
7662,
641,
652,
14,
10817,
710,
12016,
402,
1924,
1124,
723,
14,
1459,
1040,
2397,
8350,
641,
2399,
730,
12,
3247,
2126,
701,
314,
1124,
498,
1040,
2763,
26,
398,
627,
283,
885,
356,
922,
13,
4037,
849,
1338,
12,
1202,
1380,
6425,
892,
881,
5767,
402,
642,
1402,
26,
267,
627,
283,
1287,
356,
11696,
402,
376,
1595,
370,
282,
6770,
627,
1287,
9348,
10,
402,
881,
642,
1402,
12,
10663,
314,
1595,
16174,
2808,
315,
314,
922,
881,
3217,
367,
642,
1402,
14,
10817,
710,
1124,
498,
18,
1040,
2763,
17795,
465,
282,
6420,
9893,
12,
9848,
295,
2408,
316,
314,
730,
2126,
402,
314,
2397,
14,
710,
3962,
1338,
787,
26,
398,
627,
367,
283,
885,
7,
4811,
26,
376,
2716,
5558,
18152,
316,
314,
881,
5560,
2382,
642,
6770,
849,
574,
911,
506,
3964,
12,
881,
503,
1124,
797,
1040,
367,
949,
5558,
267,
627,
367,
283,
1287,
7,
4811,
26,
314,
1124,
498,
18,
1040,
6420,
9893,
365,
1373,
402,
314,
2808,
881,
1595,
14319,
12,
12669,
4212,
642,
1595,
883,
506,
10302,
26,
953,
627,
12692,
1258,
63,
1361,
63,
3029,
14700,
367,
3622,
16116,
5445,
626,
911,
1598,
506,
2808,
641,
6858,
20589,
2974,
687,
642,
1402,
288,
627,
12692,
1258,
63,
1287,
63,
3029,
14700,
367,
465,
11734,
2285,
334,
87,
565,
5596,
9,
5445,
1598,
626,
911,
506,
2808,
315,
6858,
20589,
2251,
402,
642,
1402,
288,
627,
12692,
1258,
63,
1287,
63,
17322,
14700,
367,
6220,
28354,
4048,
8247,
1598,
626,
1077,
506,
2808,
315,
6858,
20589,
2251,
402,
642,
1402,
288,
627,
12692,
2350,
63,
7911,
63,
1490,
14700,
367,
5445,
626,
911,
506,
15572,
1380,
1598,
4270,
13,
4891,
316,
376,
1242,
687,
642,
1402,
315,
282,
24787,
3123,
2455,
10817,
7048,
2397,
365,
2488,
370,
282,
1402,
15693,
1238,
1040,
2763,
395,
436,
367,
12692,
3723,
14700,
2126,
730,
12,
1443,
2755,
506,
6326,
2488,
370,
282,
1627,
2777,
402,
626,
1402,
1380,
314,
2126,
1124,
470,
63,
344,
1040,
2763,
3509,
282,
2777,
2870,
15693,
797,
1040,
4910,
652,
1159,
2288,
367,
2126,
1006,
5767,
680,
10817,
710,
1564,
402,
314,
2397,
365,
3247,
701,
314,
1124,
585,
1040,
2763,
12,
1314,
1443,
1902,
2126,
1395,
376,
9697,
574,
12,
503,
282,
3659,
1059,
12669,
314,
1595,
626,
2126,
1077,
506,
7934,
14,
10817,
2508,
519,
17147,
447,
11028,
26,
849,
1338,
267,
2126,
710,
12692,
885,
14700,
4811,
787,
9987,
3247,
10250,
701,
314,
2126,
4390,
12,
436,
663,
701,
3932,
14041,
13431,
6358,
520,
5247,
18739,
409,
63,
885,
2313,
2126,
5723,
849,
1338,
787,
2066,
5847,
1202,
701,
314,
2126,
23383,
4036,
900,
282,
892,
2777,
365,
3595,
370,
506,
2737,
12,
284,
14,
69,
14,
1380,
2126,
520,
5247,
6054,
11267,
14,
4795,
14,
4795,
14,
4795,
14,
885,
63,
362,
64,
2126,
503,
520,
5247,
6054,
11267,
14,
4795,
14,
4795,
14,
4795,
14,
981,
64,
787,
2797,
14,
10817,
2508,
519,
17147,
447,
11028,
26,
1595,
17792,
10817,
23813,
13103,
911,
9987,
5398,
3932,
5445,
5309,
2126,
12096,
12,
436,
7653,
14041,
13431,
911,
4838,
3062,
465,
3247,
12,
2126,
4079,
641,
314,
769,
402,
5445,
5120,
315,
314,
754,
402,
2126,
520,
5247,
6054,
11267,
14,
4795,
14,
4795,
14,
4795,
14,
955,
63,
1345,
63,
362,
3559,
2126,
503,
5370,
2138
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
4605,
199,
3,
199,
3,
259,
7653,
12,
3232,
5800,
8259,
9274,
199,
3,
259,
1898,
334,
35,
9,
8353,
13,
8664,
11947,
12361,
8642,
1014,
921,
9864,
14,
1235,
10121,
199,
3,
199,
3,
259,
961,
2240,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
259,
652,
1334,
314,
2895,
402,
314,
1664,
4265,
1696,
1684,
844,
465,
199,
3,
259,
3267,
701,
314,
2868,
2290,
2752,
12,
1902,
1015,
650,
402,
314,
199,
3,
259,
844,
12,
503,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
259,
961,
2240,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
259,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
259,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
199,
3,
259,
1664,
4265,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
259,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
4265,
1696,
1684,
844,
199,
3,
259,
3180,
543,
642,
2240,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
3,
199,
4605,
199,
646,
5927,
199,
199,
504,
5166,
492,
7249,
199,
504,
5166,
14,
4795,
492,
9506,
12,
1504,
199,
504,
5166,
14,
4795,
14,
1025,
492,
871,
63,
1025,
199,
199,
29647,
53,
8280,
63,
12767,
275,
663,
1332,
272,
283,
3070,
63,
20851,
63,
1317,
297,
283,
3070,
63,
16300,
63,
1317,
297,
283,
3070,
63,
20851,
297,
283,
3070,
63,
16300,
297,
272,
283,
3070,
63,
20851,
63,
1317,
63,
576,
297,
283,
3070,
63,
16300,
63,
1317,
63,
576,
297,
283,
1733,
63,
1345,
297,
5082,
199,
199,
12573,
18558,
14319,
370,
5398,
376,
1595,
370,
543,
520,
5247,
18739,
409,
63,
1287,
64,
199,
10052,
63,
32328,
51,
275,
359,
355,
298,
1258,
63,
1287,
63,
3029,
401,
221,
327,
18437,
12262,
1595,
355,
298,
1258,
63,
1361,
63,
3029,
401,
257,
327,
18437,
3622,
16116,
5528,
355,
298,
1258,
63,
1287,
63,
17322,
401,
327,
18437,
4048,
2142,
355,
298,
2350,
63,
7911,
63,
1490,
401,
263,
327,
4270,
13,
4891,
641,
1242,
315,
3123,
2455,
355,
298,
2350,
63,
7911,
63,
1287,
401,
420,
327,
5906,
26,
2011,
465,
3123,
63,
7911,
63,
1490,
2049,
1622,
421,
199,
533,
8190,
63,
1459,
8,
4795,
14,
4795,
304,
272,
408,
40,
8250,
5007,
1402,
13,
6100,
1595,
17792,
436,
922,
13,
4037,
849,
2126,
901,
1338,
14,
10269,
14,
961,
365,
282,
12139,
5007,
1402,
12,
13667,
316,
2126,
2877,
3365,
19834,
83,
12,
436,
911,
12060,
506,
4588,
503,
8717,
315,
282,
2126,
6466,
1015,
701,
3633,
281,
12,
7396,
1709,
14,
2047,
1077,
440,
11687,
2126,
7662,
641,
652,
14,
10817,
710,
12016,
402,
1924,
1124,
723,
14,
1459,
1040,
2397,
8350,
641,
2399,
730,
12,
3247,
2126,
701,
314,
1124,
498,
1040,
2763,
26,
398,
627,
283,
885,
356,
922,
13,
4037,
849,
1338,
12,
1202,
1380,
6425,
892,
881,
5767,
402,
642,
1402,
26,
267,
627,
283,
1287,
356,
11696,
402,
376,
1595,
370,
282,
6770,
627,
1287,
9348,
10,
402,
881,
642,
1402,
12,
10663,
314,
1595,
16174,
2808,
315,
314,
922,
881,
3217,
367,
642,
1402,
14,
10817,
710,
1124,
498,
18,
1040,
2763,
17795,
465,
282,
6420,
9893,
12,
9848,
295,
2408,
316,
314,
730,
2126,
402,
314,
2397,
14,
710,
3962,
1338,
787,
26,
398,
627,
367,
283,
885,
7,
4811,
26,
376,
2716,
5558,
18152,
316,
314,
881,
5560,
2382,
642,
6770,
849,
574,
911,
506,
3964,
12,
881,
503,
1124,
797,
1040,
367,
949,
5558,
267,
627,
367,
283,
1287,
7,
4811,
26,
314,
1124,
498,
18,
1040,
6420,
9893,
365,
1373,
402,
314,
2808,
881,
1595,
14319,
12,
12669,
4212,
642,
1595,
883,
506,
10302,
26,
953,
627,
12692,
1258,
63,
1361,
63,
3029,
14700,
367,
3622,
16116,
5445,
626,
911,
1598,
506,
2808,
641,
6858,
20589,
2974,
687,
642,
1402,
288,
627,
12692,
1258,
63,
1287,
63,
3029,
14700,
367,
465,
11734,
2285,
334,
87,
565,
5596,
9,
5445,
1598,
626,
911,
506,
2808,
315,
6858,
20589,
2251,
402,
642,
1402,
288,
627,
12692,
1258,
63,
1287,
63,
17322,
14700,
367,
6220,
28354,
4048,
8247,
1598,
626,
1077,
506,
2808,
315,
6858,
20589,
2251,
402,
642,
1402,
288,
627,
12692,
2350,
63,
7911,
63,
1490,
14700,
367,
5445,
626,
911,
506,
15572,
1380,
1598,
4270,
13,
4891,
316,
376,
1242,
687,
642,
1402,
315,
282,
24787,
3123,
2455,
10817,
7048,
2397,
365,
2488,
370,
282,
1402,
15693,
1238,
1040,
2763,
395,
436,
367,
12692,
3723,
14700,
2126,
730,
12,
1443,
2755,
506,
6326,
2488,
370,
282,
1627,
2777,
402,
626,
1402,
1380,
314,
2126,
1124,
470,
63,
344,
1040,
2763,
3509,
282,
2777,
2870,
15693,
797,
1040,
4910,
652,
1159,
2288,
367,
2126,
1006,
5767,
680,
10817,
710,
1564,
402,
314,
2397,
365,
3247,
701,
314,
1124,
585,
1040,
2763,
12,
1314,
1443,
1902,
2126,
1395,
376,
9697,
574,
12,
503,
282,
3659,
1059,
12669,
314,
1595,
626,
2126,
1077,
506,
7934,
14,
10817,
2508,
519,
17147,
447,
11028,
26,
849,
1338,
267,
2126,
710,
12692,
885,
14700,
4811,
787,
9987,
3247,
10250,
701,
314,
2126,
4390,
12,
436,
663,
701,
3932,
14041,
13431,
6358,
520,
5247,
18739,
409,
63,
885,
2313,
2126,
5723,
849,
1338,
787,
2066,
5847,
1202,
701,
314,
2126,
23383,
4036,
900,
282,
892,
2777,
365,
3595,
370,
506,
2737,
12,
284,
14,
69,
14,
1380,
2126,
520,
5247,
6054,
11267,
14,
4795,
14,
4795,
14,
4795,
14,
885,
63,
362,
64,
2126,
503,
520,
5247,
6054,
11267,
14,
4795,
14,
4795,
14,
4795,
14,
981,
64,
787,
2797,
14,
10817,
2508,
519,
17147,
447,
11028,
26,
1595,
17792,
10817,
23813,
13103,
911,
9987,
5398,
3932,
5445,
5309,
2126,
12096,
12,
436,
7653,
14041,
13431,
911,
4838,
3062,
465,
3247,
12,
2126,
4079,
641,
314,
769,
402,
5445,
5120,
315,
314,
754,
402,
2126,
520,
5247,
6054,
11267,
14,
4795,
14,
4795,
14,
4795,
14,
955,
63,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
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
pombredanne/xpython
|
proverb/proverb_test.py
|
10
|
2531
|
import unittest
from proverb import proverb
class ProverbTest(unittest.TestCase):
def test_a_single_consequence(self):
expected = 'For want of a nail the shoe was lost.\n'\
'And all for the want of a nail.'
self.assertEqual(expected, proverb(['nail', 'shoe']))
def test_short_list(self):
expected = 'For want of a nail the shoe was lost.\n'\
'For want of a shoe the horse was lost.\n'\
'And all for the want of a nail.'
self.assertEqual(expected, proverb(['nail', 'shoe', 'horse']))
def test_long_list(self):
expected = 'For want of a nail the shoe was lost.\n'\
'For want of a shoe the horse was lost.\n'\
'For want of a horse the rider was lost.\n'\
'And all for the want of a nail.'
self.assertEqual(expected, proverb(['nail', 'shoe', 'horse', 'rider']))
def test_new_itens(self):
expected = 'For want of a key the value was lost.\n'\
'And all for the want of a key.'
self.assertEqual(expected, proverb(['key', 'value']))
def test_whole_proverb(self):
expected = 'For want of a nail the shoe was lost.\n'\
'For want of a shoe the horse was lost.\n'\
'For want of a horse the rider was lost.\n'\
'For want of a rider the message was lost.\n'\
'For want of a message the battle was lost.\n'\
'For want of a battle the kingdom was lost.\n'\
'And all for the want of a nail.'
self.assertEqual(expected, proverb(['nail', 'shoe', 'horse', 'rider',
'message', 'battle', 'kingdom']))
def test_qualifier(self):
expected = 'For want of a nail the shoe was lost.\n'\
'For want of a shoe the horse was lost.\n'\
'For want of a horse the rider was lost.\n'\
'For want of a rider the message was lost.\n'\
'For want of a message the battle was lost.\n'\
'For want of a battle the kingdom was lost.\n'\
'And all for the want of a horseshoe nail.'
self.assertEqual(expected, proverb(['nail', 'shoe', 'horse', 'rider',
'message', 'battle', 'kingdom'],
qualifier='horseshoe'))
if __name__ == '__main__':
unittest.main()
|
mit
|
[
646,
2882,
199,
199,
504,
557,
17050,
492,
557,
17050,
421,
199,
533,
2165,
17050,
774,
8,
2796,
14,
1746,
304,
272,
347,
511,
63,
65,
63,
4780,
63,
388,
4041,
8,
277,
304,
267,
1420,
275,
283,
1858,
2934,
402,
282,
302,
1054,
314,
930,
69,
1990,
14669,
3134,
78,
1154,
673,
283,
3325,
1006,
367,
314,
2934,
402,
282,
302,
1054,
3530,
267,
291,
14,
629,
8,
2062,
12,
557,
17050,
2941,
5753,
297,
283,
13927,
69,
5156,
339,
347,
511,
63,
3612,
63,
513,
8,
277,
304,
267,
1420,
275,
283,
1858,
2934,
402,
282,
302,
1054,
314,
930,
69,
1990,
14669,
3134,
78,
1154,
673,
283,
1858,
2934,
402,
282,
930,
69,
314,
394,
9050,
1990,
14669,
3134,
78,
1154,
673,
283,
3325,
1006,
367,
314,
2934,
402,
282,
302,
1054,
3530,
267,
291,
14,
629,
8,
2062,
12,
557,
17050,
2941,
5753,
297,
283,
13927,
69,
297,
283,
28577,
5156,
339,
347,
511,
63,
2809,
63,
513,
8,
277,
304,
267,
1420,
275,
283,
1858,
2934,
402,
282,
302,
1054,
314,
930,
69,
1990,
14669,
3134,
78,
1154,
673,
283,
1858,
2934,
402,
282,
930,
69,
314,
394,
9050,
1990,
14669,
3134,
78,
1154,
673,
283,
1858,
2934,
402,
282,
394,
9050,
314,
8012,
424,
1990,
14669,
3134,
78,
1154,
673,
283,
3325,
1006,
367,
314,
2934,
402,
282,
302,
1054,
3530,
267,
291,
14,
629,
8,
2062,
12,
557,
17050,
2941,
5753,
297,
283,
13927,
69,
297,
283,
28577,
297,
283,
322,
424,
5156,
339,
347,
511,
63,
1222,
63,
1175,
561,
8,
277,
304,
267,
1420,
275,
283,
1858,
2934,
402,
282,
790,
314,
574,
1990,
14669,
3134,
78,
1154,
673,
283,
3325,
1006,
367,
314,
2934,
402,
282,
790,
3530,
267,
291,
14,
629,
8,
2062,
12,
557,
17050,
2941,
498,
297,
283,
585,
5156,
339,
347,
511,
63,
21224,
63,
496,
17050,
8,
277,
304,
267,
1420,
275,
283,
1858,
2934,
402,
282,
302,
1054,
314,
930,
69,
1990,
14669,
3134,
78,
1154,
673,
283,
1858,
2934,
402,
282,
930,
69,
314,
394,
9050,
1990,
14669,
3134,
78,
1154,
673,
283,
1858,
2934,
402,
282,
394,
9050,
314,
8012,
424,
1990,
14669,
3134,
78,
1154,
673,
283,
1858,
2934,
402,
282,
8012,
424,
314,
1245,
1990,
14669,
3134,
78,
1154,
673,
283,
1858,
2934,
402,
282,
1245,
314,
330,
29274,
1990,
14669,
3134,
78,
1154,
673,
283,
1858,
2934,
402,
282,
330,
29274,
314,
1022,
316,
4556,
1990,
14669,
3134,
78,
1154,
673,
283,
3325,
1006,
367,
314,
2934,
402,
282,
302,
1054,
3530,
267,
291,
14,
629,
8,
2062,
12,
557,
17050,
2941,
5753,
297,
283,
13927,
69,
297,
283,
28577,
297,
283,
322,
424,
297,
4490,
283,
1188,
297,
283,
29787,
297,
283,
17443,
4556,
5156,
339,
347,
511,
63,
27005,
8,
277,
304,
267,
1420,
275,
283,
1858,
2934,
402,
282,
302,
1054,
314,
930,
69,
1990,
14669,
3134,
78,
1154,
673,
283,
1858,
2934,
402,
282,
930,
69,
314,
394,
9050,
1990,
14669,
3134,
78,
1154,
673,
283,
1858,
2934,
402,
282,
394,
9050,
314,
8012,
424,
1990,
14669,
3134,
78,
1154,
673,
283,
1858,
2934,
402,
282,
8012,
424,
314,
1245,
1990,
14669,
3134,
78,
1154,
673,
283,
1858,
2934,
402,
282,
1245,
314,
330,
29274,
1990,
14669,
3134,
78,
1154,
673,
283,
1858,
2934,
402,
282,
330,
29274,
314,
1022,
316,
4556,
1990,
14669,
3134,
78,
1154,
673,
283,
3325,
1006,
367,
314,
2934,
402,
282,
394,
269,
874,
526,
69,
302,
1054,
3530,
267,
291,
14,
629,
8,
2062,
12,
557,
17050,
2941,
5753,
297,
283,
13927,
69,
297,
283,
28577,
297,
283,
322,
424,
297,
4490,
283,
1188,
297,
283,
29787,
297,
283,
17443,
4556,
995,
5644,
6420,
9893,
534,
23991,
874,
526,
69,
1333,
421,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
272,
2882,
14,
973,
342,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
2882,
199,
199,
504,
557,
17050,
492,
557,
17050,
421,
199,
533,
2165,
17050,
774,
8,
2796,
14,
1746,
304,
272,
347,
511,
63,
65,
63,
4780,
63,
388,
4041,
8,
277,
304,
267,
1420,
275,
283,
1858,
2934,
402,
282,
302,
1054,
314,
930,
69,
1990,
14669,
3134,
78,
1154,
673,
283,
3325,
1006,
367,
314,
2934,
402,
282,
302,
1054,
3530,
267,
291,
14,
629,
8,
2062,
12,
557,
17050,
2941,
5753,
297,
283,
13927,
69,
5156,
339,
347,
511,
63,
3612,
63,
513,
8,
277,
304,
267,
1420,
275,
283,
1858,
2934,
402,
282,
302,
1054,
314,
930,
69,
1990,
14669,
3134,
78,
1154,
673,
283,
1858,
2934,
402,
282,
930,
69,
314,
394,
9050,
1990,
14669,
3134,
78,
1154,
673,
283,
3325,
1006,
367,
314,
2934,
402,
282,
302,
1054,
3530,
267,
291,
14,
629,
8,
2062,
12,
557,
17050,
2941,
5753,
297,
283,
13927,
69,
297,
283,
28577,
5156,
339,
347,
511,
63,
2809,
63,
513,
8,
277,
304,
267,
1420,
275,
283,
1858,
2934,
402,
282,
302,
1054,
314,
930,
69,
1990,
14669,
3134,
78,
1154,
673,
283,
1858,
2934,
402,
282,
930,
69,
314,
394,
9050,
1990,
14669,
3134,
78,
1154,
673,
283,
1858,
2934,
402,
282,
394,
9050,
314,
8012,
424,
1990,
14669,
3134,
78,
1154,
673,
283,
3325,
1006,
367,
314,
2934,
402,
282,
302,
1054,
3530,
267,
291,
14,
629,
8,
2062,
12,
557,
17050,
2941,
5753,
297,
283,
13927,
69,
297,
283,
28577,
297,
283,
322,
424,
5156,
339,
347,
511,
63,
1222,
63,
1175,
561,
8,
277,
304,
267,
1420,
275,
283,
1858,
2934,
402,
282,
790,
314,
574,
1990,
14669,
3134,
78,
1154,
673,
283,
3325,
1006,
367,
314,
2934,
402,
282,
790,
3530,
267,
291,
14,
629,
8,
2062,
12,
557,
17050,
2941,
498,
297,
283,
585,
5156,
339,
347,
511,
63,
21224,
63,
496,
17050,
8,
277,
304,
267,
1420,
275,
283,
1858,
2934,
402,
282,
302,
1054,
314,
930,
69,
1990,
14669,
3134,
78,
1154,
673,
283,
1858,
2934,
402,
282,
930,
69,
314,
394,
9050,
1990,
14669,
3134,
78,
1154,
673,
283,
1858,
2934,
402,
282,
394,
9050,
314,
8012,
424,
1990,
14669,
3134,
78,
1154,
673,
283,
1858,
2934,
402,
282,
8012,
424,
314,
1245,
1990,
14669,
3134,
78,
1154,
673,
283,
1858,
2934,
402,
282,
1245,
314,
330,
29274,
1990,
14669,
3134,
78,
1154,
673,
283,
1858,
2934,
402,
282,
330,
29274,
314,
1022,
316,
4556,
1990,
14669,
3134,
78,
1154,
673,
283,
3325,
1006,
367,
314,
2934,
402,
282,
302,
1054,
3530,
267,
291,
14,
629,
8,
2062,
12,
557,
17050,
2941,
5753,
297,
283,
13927,
69,
297,
283,
28577,
297,
283,
322,
424,
297,
4490,
283,
1188,
297,
283,
29787,
297,
283,
17443,
4556,
5156,
339,
347,
511,
63,
27005,
8,
277,
304,
267,
1420,
275,
283,
1858,
2934,
402,
282,
302,
1054,
314,
930,
69,
1990,
14669,
3134,
78,
1154,
673,
283,
1858,
2934,
402,
282,
930,
69,
314,
394,
9050,
1990,
14669,
3134,
78,
1154,
673,
283,
1858,
2934,
402,
282,
394,
9050,
314,
8012,
424,
1990,
14669,
3134,
78,
1154,
673,
283,
1858,
2934,
402,
282,
8012,
424,
314,
1245,
1990,
14669,
3134,
78,
1154,
673,
283,
1858,
2934,
402,
282,
1245,
314,
330,
29274,
1990,
14669,
3134,
78,
1154,
673,
283,
1858,
2934,
402,
282,
330,
29274,
314,
1022,
316,
4556,
1990,
14669,
3134,
78,
1154,
673,
283,
3325,
1006,
367,
314,
2934,
402,
282,
394,
269,
874,
526,
69,
302,
1054,
3530,
267,
291,
14,
629,
8,
2062,
12,
557,
17050,
2941,
5753,
297,
283,
13927,
69,
297,
283,
28577,
297,
283,
322,
424,
297,
4490,
283,
1188,
297,
283,
29787,
297,
283,
17443,
4556,
995,
5644,
6420,
9893,
534,
23991,
874,
526,
69,
1333,
421,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
272,
2882,
14,
973,
342,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
grahamhayes/pdns
|
regression-tests.dnsdist/cookiesoption.py
|
2
|
1938
|
#!/usr/bin/env python2
import dns
import dns.edns
import dns.flags
import dns.message
import dns.query
class CookiesOption(dns.edns.Option):
"""Implementation of draft-ietf-dnsop-cookies-09.
"""
def __init__(self, client, server):
super(CookiesOption, self).__init__(10)
if len(client) != 8:
raise Exception('invalid client cookie length')
if server is not None and len(server) != 0 and (len(server) < 8 or len(server) > 32):
raise Exception('invalid server cookie length')
self.client = client
self.server = server
def to_wire(self, file):
"""Create EDNS packet as definied in draft-ietf-dnsop-cookies-09."""
file.write(self.client)
if self.server and len(self.server) > 0:
file.write(self.server)
def from_wire(cls, otype, wire, current, olen):
"""Read EDNS packet as defined in draft-ietf-dnsop-cookies-09.
Returns:
An instance of CookiesOption based on the EDNS packet
"""
data = wire[current:current + olen]
if len(data) != 8 and (len(data) < 16 or len(data) > 40):
raise Exception('Invalid EDNS Cookies option')
client = data[:8]
if len(data) > 8:
server = data[8:]
else:
server = None
return cls(client, server)
from_wire = classmethod(from_wire)
def __repr__(self):
return '%s(%s, %s)' % (
self.__class__.__name__,
self.client,
self.server
)
def __eq__(self, other):
if not isinstance(other, CookiesOption):
return False
if self.client != other.client:
return False
if self.server != other.server:
return False
return True
def __ne__(self, other):
return not self.__eq__(other)
dns.edns._type_to_class[0x000A] = CookiesOption
|
gpl-2.0
|
[
3381,
2647,
15,
1393,
15,
1813,
2366,
18,
199,
199,
646,
6715,
199,
646,
6715,
14,
379,
561,
199,
646,
6715,
14,
2469,
199,
646,
6715,
14,
1188,
199,
646,
6715,
14,
1131,
199,
199,
533,
1849,
5635,
2602,
8,
5797,
14,
379,
561,
14,
2602,
304,
272,
408,
7921,
402,
11872,
13,
15799,
13,
5797,
411,
13,
7792,
13,
1643,
14,
272,
408,
339,
347,
636,
826,
721,
277,
12,
1890,
12,
1654,
304,
267,
1613,
8,
967,
5635,
2602,
12,
291,
2843,
826,
721,
709,
9,
398,
340,
822,
8,
1258,
9,
1137,
1695,
26,
288,
746,
2186,
360,
3197,
1890,
5494,
2582,
358,
398,
340,
1654,
365,
440,
488,
436,
822,
8,
1000,
9,
1137,
378,
436,
334,
552,
8,
1000,
9,
665,
1695,
503,
822,
8,
1000,
9,
690,
4337,
304,
288,
746,
2186,
360,
3197,
1654,
5494,
2582,
358,
398,
291,
14,
1258,
275,
1890,
267,
291,
14,
1000,
275,
1654,
339,
347,
370,
63,
11239,
8,
277,
12,
570,
304,
267,
408,
2499,
662,
12323,
3644,
465,
347,
2730,
379,
315,
11872,
13,
15799,
13,
5797,
411,
13,
7792,
13,
1643,
1041,
398,
570,
14,
952,
8,
277,
14,
1258,
9,
267,
340,
291,
14,
1000,
436,
822,
8,
277,
14,
1000,
9,
690,
378,
26,
288,
570,
14,
952,
8,
277,
14,
1000,
9,
339,
347,
687,
63,
11239,
8,
1886,
12,
312,
466,
12,
11799,
12,
1453,
12,
312,
552,
304,
267,
408,
3284,
662,
12323,
3644,
465,
3247,
315,
11872,
13,
15799,
13,
5797,
411,
13,
7792,
13,
1643,
14,
398,
1803,
26,
288,
1626,
1256,
402,
1849,
5635,
2602,
4079,
641,
314,
662,
12323,
3644,
267,
408,
398,
666,
275,
11799,
59,
1818,
26,
1818,
435,
312,
552,
61,
267,
340,
822,
8,
576,
9,
1137,
1695,
436,
334,
552,
8,
576,
9,
665,
3193,
503,
822,
8,
576,
9,
690,
6335,
304,
288,
746,
2186,
360,
3364,
662,
12323,
1849,
5635,
945,
358,
398,
1890,
275,
666,
1491,
24,
61,
267,
340,
822,
8,
576,
9,
690,
1695,
26,
288,
1654,
275,
666,
59,
24,
2938,
267,
587,
26,
288,
1654,
275,
488,
398,
372,
843,
8,
1258,
12,
1654,
9,
339,
687,
63,
11239,
275,
18990,
8,
504,
63,
11239,
9,
339,
347,
636,
2722,
721,
277,
304,
267,
372,
1543,
83,
4042,
83,
12,
450,
83,
3171,
450,
334,
288,
291,
855,
533,
4914,
354,
3108,
288,
291,
14,
1258,
12,
288,
291,
14,
1000,
267,
776,
339,
347,
636,
4077,
721,
277,
12,
1163,
304,
267,
340,
440,
1228,
8,
1848,
12,
1849,
5635,
2602,
304,
288,
372,
756,
267,
340,
291,
14,
1258,
1137,
1163,
14,
1258,
26,
288,
372,
756,
267,
340,
291,
14,
1000,
1137,
1163,
14,
1000,
26,
288,
372,
756,
267,
372,
715,
339,
347,
636,
685,
721,
277,
12,
1163,
304,
267,
372,
440,
291,
855,
4077,
721,
1848,
9,
421,
199,
5797,
14,
379,
561,
423,
466,
63,
475,
63,
533,
59,
16,
88,
1493,
33,
61,
275,
1849,
5635,
2602,
421,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
2647,
15,
1393,
15,
1813,
2366,
18,
199,
199,
646,
6715,
199,
646,
6715,
14,
379,
561,
199,
646,
6715,
14,
2469,
199,
646,
6715,
14,
1188,
199,
646,
6715,
14,
1131,
199,
199,
533,
1849,
5635,
2602,
8,
5797,
14,
379,
561,
14,
2602,
304,
272,
408,
7921,
402,
11872,
13,
15799,
13,
5797,
411,
13,
7792,
13,
1643,
14,
272,
408,
339,
347,
636,
826,
721,
277,
12,
1890,
12,
1654,
304,
267,
1613,
8,
967,
5635,
2602,
12,
291,
2843,
826,
721,
709,
9,
398,
340,
822,
8,
1258,
9,
1137,
1695,
26,
288,
746,
2186,
360,
3197,
1890,
5494,
2582,
358,
398,
340,
1654,
365,
440,
488,
436,
822,
8,
1000,
9,
1137,
378,
436,
334,
552,
8,
1000,
9,
665,
1695,
503,
822,
8,
1000,
9,
690,
4337,
304,
288,
746,
2186,
360,
3197,
1654,
5494,
2582,
358,
398,
291,
14,
1258,
275,
1890,
267,
291,
14,
1000,
275,
1654,
339,
347,
370,
63,
11239,
8,
277,
12,
570,
304,
267,
408,
2499,
662,
12323,
3644,
465,
347,
2730,
379,
315,
11872,
13,
15799,
13,
5797,
411,
13,
7792,
13,
1643,
1041,
398,
570,
14,
952,
8,
277,
14,
1258,
9,
267,
340,
291,
14,
1000,
436,
822,
8,
277,
14,
1000,
9,
690,
378,
26,
288,
570,
14,
952,
8,
277,
14,
1000,
9,
339,
347,
687,
63,
11239,
8,
1886,
12,
312,
466,
12,
11799,
12,
1453,
12,
312,
552,
304,
267,
408,
3284,
662,
12323,
3644,
465,
3247,
315,
11872,
13,
15799,
13,
5797,
411,
13,
7792,
13,
1643,
14,
398,
1803,
26,
288,
1626,
1256,
402,
1849,
5635,
2602,
4079,
641,
314,
662,
12323,
3644,
267,
408,
398,
666,
275,
11799,
59,
1818,
26,
1818,
435,
312,
552,
61,
267,
340,
822,
8,
576,
9,
1137,
1695,
436,
334,
552,
8,
576,
9,
665,
3193,
503,
822,
8,
576,
9,
690,
6335,
304,
288,
746,
2186,
360,
3364,
662,
12323,
1849,
5635,
945,
358,
398,
1890,
275,
666,
1491,
24,
61,
267,
340,
822,
8,
576,
9,
690,
1695,
26,
288,
1654,
275,
666,
59,
24,
2938,
267,
587,
26,
288,
1654,
275,
488,
398,
372,
843,
8,
1258,
12,
1654,
9,
339,
687,
63,
11239,
275,
18990,
8,
504,
63,
11239,
9,
339,
347,
636,
2722,
721,
277,
304,
267,
372,
1543,
83,
4042,
83,
12,
450,
83,
3171,
450,
334,
288,
291,
855,
533,
4914,
354,
3108,
288,
291,
14,
1258,
12,
288,
291,
14,
1000,
267,
776,
339,
347,
636,
4077,
721,
277,
12,
1163,
304,
267,
340,
440,
1228,
8,
1848,
12,
1849,
5635,
2602,
304,
288,
372,
756,
267,
340,
291,
14,
1258,
1137,
1163,
14,
1258,
26,
288,
372,
756,
267,
340,
291,
14,
1000,
1137,
1163,
14,
1000,
26,
288,
372,
756,
267,
372,
715,
339,
347,
636,
685,
721,
277,
12,
1163,
304,
267,
372,
440,
291,
855,
4077,
721,
1848,
9,
421,
199,
5797,
14,
379,
561,
423,
466,
63,
475,
63,
533,
59,
16,
88,
1493,
33,
61,
275,
1849,
5635,
2602,
421,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32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
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
Superjom/cHasky
|
python/chasky/node_def_builder.py
|
1
|
2057
|
import sys
#from graph_def_builder import GraphDefBuilder
from core.framework.attr_value_pb2 import AttrValue
from core.framework.graph_pb2 import NodeDef
from attr_value_builder import AttrValueBuilder
class NodeDefBuilder(object):
def __init__(self, node=None):
self.node_def_ = node if node else NodeDef()
def Name(self, name):
'''
@name: str
'''
self.node_def_.name = name
return self
def SetIsSource(self, is_source):
'''
@is_source: bool
'''
self.node_def_.is_source = is_source
return self
def SetIsEnd(self, is_end):
'''
@is_end: bool
'''
self.node_def_.is_end = is_end
return self
def Func(self, x):
'''
'''
# TODO change signature to function
self.node_def_.signature = x
return self
def Attr(self, key, value, is_dtype=False):
'''
Add an attribute
@key: str
@attr_value: AttrValue
value of attribute
@is_dtype: whether is dtype
distinguish between real int and DataType
'''
attr = self.node_def_.attr[key]
print 'attr value', value
attr_builder = AttrValueBuilder(attr).Value(value, is_dtype)
return self
def Input(self, src_node_name, out_arg_name):
'''
Add an input
'''
signature = "{src_node_name}:{arg}".format(
src_node_name = src_node_name,
arg = out_arg_name,)
self.node_def_.input.append(signature)
return self
def Finalize(self):
#TODO add checks
#GraphDefBuilder.Instance().Node(self.node_def_)
return self.node_def_
if __name__ == '__main__':
node_def = NodeDefBuilder() \
.Name("node1") \
.SetIsSource(False) \
.Func("AddN") \
.Input("src_node1", "activation") \
.Input("src_node2", "activation") \
.Finalize()
print node_def
|
apache-2.0
|
[
646,
984,
199,
3,
504,
3343,
63,
318,
63,
5649,
492,
11513,
6172,
6437,
199,
504,
6170,
14,
4857,
14,
962,
63,
585,
63,
3317,
18,
492,
20516,
1110,
199,
504,
6170,
14,
4857,
14,
2180,
63,
3317,
18,
492,
5013,
6172,
199,
504,
1921,
63,
585,
63,
5649,
492,
20516,
1110,
6437,
199,
199,
533,
5013,
6172,
6437,
8,
785,
304,
272,
347,
636,
826,
721,
277,
12,
1031,
29,
403,
304,
267,
291,
14,
932,
63,
318,
63,
275,
1031,
340,
1031,
587,
5013,
6172,
342,
18407,
347,
2812,
8,
277,
12,
536,
304,
267,
1449,
267,
768,
354,
26,
620,
267,
1449,
267,
291,
14,
932,
63,
318,
3754,
354,
275,
536,
267,
372,
291,
339,
347,
2494,
1831,
2980,
8,
277,
12,
365,
63,
1365,
304,
267,
1449,
267,
768,
374,
63,
1365,
26,
2155,
267,
1449,
267,
291,
14,
932,
63,
318,
3754,
374,
63,
1365,
275,
365,
63,
1365,
267,
372,
291,
339,
347,
2494,
1831,
3005,
8,
277,
12,
365,
63,
500,
304,
267,
1449,
267,
768,
374,
63,
500,
26,
2155,
267,
1449,
267,
291,
14,
932,
63,
318,
3754,
374,
63,
500,
275,
365,
63,
500,
267,
372,
291,
339,
347,
28794,
8,
277,
12,
671,
304,
267,
1449,
267,
1449,
267,
327,
3254,
1570,
4955,
370,
805,
267,
291,
14,
932,
63,
318,
3754,
5233,
275,
671,
267,
372,
291,
339,
347,
20516,
8,
277,
12,
790,
12,
574,
12,
365,
63,
2271,
29,
797,
304,
267,
1449,
267,
2654,
376,
2225,
267,
768,
498,
26,
620,
267,
768,
962,
63,
585,
26,
20516,
1110,
288,
574,
402,
2225,
267,
768,
374,
63,
2271,
26,
3775,
365,
2152,
288,
22237,
3382,
3363,
1109,
436,
3918,
804,
267,
1449,
267,
1921,
275,
291,
14,
932,
63,
318,
3754,
962,
59,
498,
61,
267,
870,
283,
962,
574,
297,
574,
267,
1921,
63,
5649,
275,
20516,
1110,
6437,
8,
962,
680,
1110,
8,
585,
12,
365,
63,
2271,
9,
267,
372,
291,
339,
347,
6924,
8,
277,
12,
2928,
63,
932,
63,
354,
12,
734,
63,
1273,
63,
354,
304,
267,
1449,
267,
2654,
376,
1324,
267,
1449,
267,
4955,
275,
5310,
2164,
63,
932,
63,
354,
16495,
1273,
5469,
908,
8,
288,
2928,
63,
932,
63,
354,
275,
2928,
63,
932,
63,
354,
12,
288,
1680,
275,
734,
63,
1273,
63,
354,
4258,
267,
291,
14,
932,
63,
318,
3754,
1210,
14,
740,
8,
5233,
9,
267,
372,
291,
339,
347,
21789,
794,
8,
277,
304,
267,
327,
11768,
1050,
5920,
267,
327,
31725,
6437,
14,
3244,
1252,
1716,
8,
277,
14,
932,
63,
318,
4602,
267,
372,
291,
14,
932,
63,
318,
63,
199,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
272,
1031,
63,
318,
275,
5013,
6172,
6437,
342,
971,
2049,
1275,
985,
480,
932,
17,
531,
971,
2049,
1275,
1084,
1831,
2980,
8,
797,
9,
971,
2049,
1275,
7465,
480,
1123,
46,
531,
971,
2049,
1275,
3205,
480,
2164,
63,
932,
17,
401,
298,
12312,
531,
971,
2049,
1275,
3205,
480,
2164,
63,
932,
18,
401,
298,
12312,
531,
971,
2049,
1275,
12776,
794,
342,
272,
870,
1031,
63,
318,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
984,
199,
3,
504,
3343,
63,
318,
63,
5649,
492,
11513,
6172,
6437,
199,
504,
6170,
14,
4857,
14,
962,
63,
585,
63,
3317,
18,
492,
20516,
1110,
199,
504,
6170,
14,
4857,
14,
2180,
63,
3317,
18,
492,
5013,
6172,
199,
504,
1921,
63,
585,
63,
5649,
492,
20516,
1110,
6437,
199,
199,
533,
5013,
6172,
6437,
8,
785,
304,
272,
347,
636,
826,
721,
277,
12,
1031,
29,
403,
304,
267,
291,
14,
932,
63,
318,
63,
275,
1031,
340,
1031,
587,
5013,
6172,
342,
18407,
347,
2812,
8,
277,
12,
536,
304,
267,
1449,
267,
768,
354,
26,
620,
267,
1449,
267,
291,
14,
932,
63,
318,
3754,
354,
275,
536,
267,
372,
291,
339,
347,
2494,
1831,
2980,
8,
277,
12,
365,
63,
1365,
304,
267,
1449,
267,
768,
374,
63,
1365,
26,
2155,
267,
1449,
267,
291,
14,
932,
63,
318,
3754,
374,
63,
1365,
275,
365,
63,
1365,
267,
372,
291,
339,
347,
2494,
1831,
3005,
8,
277,
12,
365,
63,
500,
304,
267,
1449,
267,
768,
374,
63,
500,
26,
2155,
267,
1449,
267,
291,
14,
932,
63,
318,
3754,
374,
63,
500,
275,
365,
63,
500,
267,
372,
291,
339,
347,
28794,
8,
277,
12,
671,
304,
267,
1449,
267,
1449,
267,
327,
3254,
1570,
4955,
370,
805,
267,
291,
14,
932,
63,
318,
3754,
5233,
275,
671,
267,
372,
291,
339,
347,
20516,
8,
277,
12,
790,
12,
574,
12,
365,
63,
2271,
29,
797,
304,
267,
1449,
267,
2654,
376,
2225,
267,
768,
498,
26,
620,
267,
768,
962,
63,
585,
26,
20516,
1110,
288,
574,
402,
2225,
267,
768,
374,
63,
2271,
26,
3775,
365,
2152,
288,
22237,
3382,
3363,
1109,
436,
3918,
804,
267,
1449,
267,
1921,
275,
291,
14,
932,
63,
318,
3754,
962,
59,
498,
61,
267,
870,
283,
962,
574,
297,
574,
267,
1921,
63,
5649,
275,
20516,
1110,
6437,
8,
962,
680,
1110,
8,
585,
12,
365,
63,
2271,
9,
267,
372,
291,
339,
347,
6924,
8,
277,
12,
2928,
63,
932,
63,
354,
12,
734,
63,
1273,
63,
354,
304,
267,
1449,
267,
2654,
376,
1324,
267,
1449,
267,
4955,
275,
5310,
2164,
63,
932,
63,
354,
16495,
1273,
5469,
908,
8,
288,
2928,
63,
932,
63,
354,
275,
2928,
63,
932,
63,
354,
12,
288,
1680,
275,
734,
63,
1273,
63,
354,
4258,
267,
291,
14,
932,
63,
318,
3754,
1210,
14,
740,
8,
5233,
9,
267,
372,
291,
339,
347,
21789,
794,
8,
277,
304,
267,
327,
11768,
1050,
5920,
267,
327,
31725,
6437,
14,
3244,
1252,
1716,
8,
277,
14,
932,
63,
318,
4602,
267,
372,
291,
14,
932,
63,
318,
63,
199,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
272,
1031,
63,
318,
275,
5013,
6172,
6437,
342,
971,
2049,
1275,
985,
480,
932,
17,
531,
971,
2049,
1275,
1084,
1831,
2980,
8,
797,
9,
971,
2049,
1275,
7465,
480,
1123,
46,
531,
971,
2049,
1275,
3205,
480,
2164,
63,
932,
17,
401,
298,
12312,
531,
971,
2049,
1275,
3205,
480,
2164,
63,
932,
18,
401,
298,
12312,
531,
971,
2049,
1275,
12776,
794,
342,
272,
870,
1031,
63,
318,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
mop/LTPTextDetector
|
scripts/pw_analyze/svmdelme.py
|
1
|
5600
|
import numpy as np
from sklearn.cross_validation import cross_val_score, ShuffleSplit
from sklearn.svm import LinearSVC, SVC
from sklearn.grid_search import GridSearchCV
from sklearn.metrics import precision_recall_fscore_support
import matplotlib.pyplot as plt
data = np.genfromtxt('dists_cleaned.csv', delimiter=',')
#samples = np.bitwise_or(np.bitwise_and(data[:,0] == -1, data[:,1] <= 2), data[:,0]==1)
#data = data[samples,:]
#data = data[data[:,7]>=5,:]
pos = data[data[:,0]==1,:]
neg = data[data[:,0]==-1,:]
a = 0.33974138
b = 0.47850904
c = -0.56307525
xrg = np.linspace(0,5,100)
yrg = np.linspace(0,5,100)
X,Y = np.meshgrid(xrg,yrg)
Z = a * X + b * Y + c
print Z
plt.scatter(neg[:,3], neg[:,4], color='r')
plt.scatter(pos[:,3], pos[:,4], color='b')
plt.contour(X,Y,Z)
plt.xlabel('medians')
plt.ylabel('heights')
plt.show()
#data[data[:,0]==1,0] = 2
#data[data[:,0]==-1,0] = 1
#data[data[:,0]==2,0] = -1
#print data.shape
#data = data[data[:,1]>0,:]
#data = data[data[:,2]>0,:]
#print data.shape
cv = ShuffleSplit(data.shape[0], n_iter=10, random_state=4)
min_dists = [1,2,3,4,5,100]
c1_grid = np.logspace(0,2,10)
c2_grid = np.logspace(0,4,15)
class_weights = {1:5, -1:1}
beta = 1.0
#best_params = {}
#best_fscore = 0
#for d in min_dists:
# for C1 in c1_grid:
# for C2 in c2_grid:
# precisions = []
# recalls = []
# fscores = []
# accs = []
# for (train_idx, test_idx) in cv:
# X = data[train_idx,3:5]
# y = data[train_idx,0]
#
# svm1 = LinearSVC(random_state=42, C=C1, class_weight=class_weights)
# svm1.fit(X,y)
#
# X_simple = data[train_idx, 4]
# X_simple = X_simple.reshape((train_idx.shape[0], 1))
# svm2 = LinearSVC(random_state=42, C=C2, class_weight=class_weights)
# svm2.fit(X_simple, y)
#
# #ys = svm2.predict(data[test_idx, 4].reshape((test_idx.shape[0], 1)))
# #accs.append(svm2.score(data[test_idx, 4].reshape((test_idx.shape[0], 1)), data[test_idx,0]))
#
# ys = np.zeros((test_idx.shape[0],))
# for i,idx in enumerate(test_idx):
# if data[idx,-1] >= d:
# ys[i] = svm1.predict(data[idx, 3:5].reshape((1,2)))
# else:
# ys[i] = svm2.predict(data[idx, 4].reshape((1,1)))
#
# acc = np.sum(data[test_idx,0] == ys) / float(test_idx.shape[0])
# accs.append(acc)
# ps, rs, fs, ss = precision_recall_fscore_support(data[test_idx,0], ys, beta=beta)
# precisions.append(ps[1])
# recalls.append(rs[1])
# fscores.append(fs[1])
# print 'C1: %f, C2: %f, d: %f, prec: %f, recall: %f, f-score: %f, acc: %f' % (C1, C2, d, np.mean(precisions), np.mean(recalls), np.mean(fscores), np.mean(accs))
# if np.mean(fscores) > best_fscore:
# print '*'
# best_fscore = np.mean(fscores)
# best_params = {
# 'C1': C1,
# 'C2': C2,
# 'd': d
# }
#
#best_params = {}
#best_fscore = 0
#print data.shape
#for C1 in c1_grid:
# precisions = []
# recalls = []
# fscores = []
# accs = []
# for (train_idx, test_idx) in cv:
# X = data[train_idx,3:5]
# y = data[train_idx,0]
#
# svm1 = LinearSVC(random_state=4,C=C1, class_weight=class_weights)
# svm1.fit(X,y)
#
# ys = np.zeros((test_idx.shape[0],))
# for i,idx in enumerate(test_idx):
# ys[i] = svm1.predict(data[idx, 3:5].reshape((1,2)))
#
# acc = np.sum(data[test_idx,0] == ys) / float(test_idx.shape[0])
# accs.append(acc)
# ps, rs, fs, ss = precision_recall_fscore_support(data[test_idx,0], ys, beta=beta)
# precisions.append(ps[1])
# recalls.append(rs[1])
# fscores.append(fs[1])
# svm = LinearSVC(random_state=4,C=C1, class_weight=class_weights)
# svm.fit(data[:,3:5], data[:,0])
# print 'C1: %f, prec: %f, recall: %f, f-score: %f, acc: %f' % (C1, np.mean(precisions), np.mean(recalls), np.mean(fscores), np.mean(accs))
# print svm.coef_
# print svm.intercept_
# if np.mean(fscores) > best_fscore:
# print '*'
# best_fscore = np.mean(fscores)
# best_params = {
# 'C1': C1
# }
#print 'best:'
#print best_params
#svm = SVC(kernel='linear', C=best_params['C1'], class_weight=class_weights)
#svm.fit(data[:,1:3], data[:,0])
#print svm.coef_
#print svm.intercept_
#svm = SVC(kernel='linear', C=best_params['C1'], class_weight=class_weights)
#svm.fit(data[:,3:5], data[:,0])
#print svm.coef_
#print svm.intercept_
#svm = SVC()
#search = GridSearchCV(svm, {
# 'kernel': ('rbf',), 'C': [1,10,100,1000],
# 'gamma': [0.05, 0.1, 0.25, 0.128, 0.5, 1.0, 1.5],
# 'class_weight': ({1:1,-1:1},),
# }, cv=cv)
svm = LinearSVC()
search = GridSearchCV(svm, {
'C': np.logspace(0,4,15).tolist(),
'class_weight': (
{1:1,1:1},
{1:1,-1:2},
{1:1,-1:3},
{1:1,-1:4},
{-1:1,1:2},
{-1:1,1:3},
{-1:1,1:5},{1:4,-1:1},{1:5,-1:1})
}, cv=cv, refit=False)
search.fit(data[:,3:5], data[:,0],cv=cv)
print search
print search.best_score_
print search.best_params_
svm = LinearSVC(random_state=42,**search.best_params_)
svm.fit(data[:,1:3],data[:,0])
print svm.score(data[:,1:3],data[:,0])
print svm.coef_
print svm.intercept_
|
gpl-3.0
|
[
646,
2680,
465,
980,
199,
199,
504,
6357,
14,
7925,
63,
6136,
492,
8059,
63,
637,
63,
3397,
12,
5244,
6817,
8862,
199,
504,
6357,
14,
16820,
492,
12489,
17675,
12,
428,
9454,
199,
504,
6357,
14,
3825,
63,
1733,
492,
32570,
199,
504,
6357,
14,
6759,
492,
7151,
63,
19183,
63,
2319,
1018,
63,
4058,
199,
199,
646,
8027,
14,
13563,
465,
4488,
199,
199,
576,
275,
980,
14,
2268,
30439,
360,
18552,
63,
8275,
14,
4737,
297,
11172,
4009,
358,
199,
199,
3,
3356,
275,
980,
14,
28831,
63,
269,
8,
1590,
14,
28831,
63,
460,
8,
576,
3981,
16,
61,
508,
446,
17,
12,
666,
3981,
17,
61,
2695,
499,
395,
666,
3981,
16,
19219,
17,
9,
199,
3,
576,
275,
666,
59,
3356,
21063,
199,
3,
576,
275,
666,
59,
576,
3981,
23,
61,
8119,
21,
21063,
199,
1712,
275,
666,
59,
576,
3981,
16,
19219,
17,
21063,
199,
8705,
275,
666,
59,
576,
3981,
16,
19219,
13,
17,
21063,
421,
199,
65,
275,
378,
14,
11870,
1342,
8527,
257,
199,
66,
275,
378,
14,
31622,
6576,
966,
221,
199,
67,
275,
446,
16,
14,
1367,
1216,
2194,
821,
421,
199,
88,
12430,
275,
980,
14,
11649,
8,
16,
12,
21,
12,
1960,
9,
199,
89,
12430,
275,
980,
14,
11649,
8,
16,
12,
21,
12,
1960,
9,
199,
199,
56,
12,
57,
275,
980,
14,
6480,
3825,
8,
88,
12430,
12,
89,
12430,
9,
199,
58,
275,
282,
627,
1323,
435,
330,
627,
1488,
435,
286,
199,
1361,
3107,
199,
199,
6003,
14,
13512,
8,
8705,
3981,
19,
467,
14158,
3981,
20,
467,
3164,
534,
82,
358,
199,
6003,
14,
13512,
8,
1712,
3981,
19,
467,
2086,
3981,
20,
467,
3164,
534,
66,
358,
199,
6003,
14,
17798,
8,
56,
12,
57,
12,
58,
9,
199,
199,
6003,
14,
14168,
360,
3700,
796,
358,
199,
6003,
14,
13849,
360,
426,
2492,
358,
199,
6003,
14,
2384,
342,
199,
3,
576,
59,
576,
3981,
16,
19219,
17,
12,
16,
61,
275,
499,
199,
3,
576,
59,
576,
3981,
16,
19219,
13,
17,
12,
16,
61,
275,
413,
199,
3,
576,
59,
576,
3981,
16,
19219,
18,
12,
16,
61,
275,
446,
17,
199,
199,
3,
1361,
666,
14,
1392,
199,
3,
576,
275,
666,
59,
576,
3981,
17,
28474,
16,
21063,
199,
3,
576,
275,
666,
59,
576,
3981,
18,
28474,
16,
21063,
199,
3,
1361,
666,
14,
1392,
199,
5107,
275,
5244,
6817,
8862,
8,
576,
14,
1392,
59,
16,
467,
302,
63,
1661,
29,
709,
12,
2196,
63,
929,
29,
20,
9,
199,
199,
827,
63,
18552,
275,
359,
17,
12,
18,
12,
19,
12,
20,
12,
21,
12,
1960,
61,
199,
67,
17,
63,
3825,
275,
980,
14,
7270,
1142,
8,
16,
12,
18,
12,
709,
9,
199,
67,
18,
63,
3825,
275,
980,
14,
7270,
1142,
8,
16,
12,
20,
12,
1046,
9,
199,
533,
63,
4916,
275,
469,
17,
26,
21,
12,
446,
17,
26,
17,
93,
199,
5683,
275,
413,
14,
16,
421,
199,
3,
7010,
63,
1162,
275,
1052,
199,
3,
7010,
63,
2319,
1018,
275,
378,
199,
3,
509,
366,
315,
1748,
63,
18552,
26,
199,
3,
259,
367,
445,
17,
315,
286,
17,
63,
3825,
26,
199,
3,
263,
367,
445,
18,
315,
286,
18,
63,
3825,
26,
199,
3,
3322,
876,
559,
1356,
275,
942,
199,
3,
3322,
295,
5352,
275,
942,
199,
3,
3322,
289,
7107,
275,
942,
199,
3,
3322,
1066,
1259,
275,
942,
199,
3,
3322,
367,
334,
2834,
63,
2996,
12,
511,
63,
2996,
9,
315,
6277,
26,
199,
3,
4483,
1323,
275,
666,
59,
2834,
63,
2996,
12,
19,
26,
21,
61,
199,
3,
4483,
612,
275,
666,
59,
2834,
63,
2996,
12,
16,
61,
199,
3,
199,
3,
4483,
23044,
17,
275,
12489,
17675,
8,
2355,
63,
929,
29,
2260,
12,
445,
29,
35,
17,
12,
1021,
63,
3463,
29,
533,
63,
4916,
9,
199,
3,
4483,
23044,
17,
14,
3269,
8,
56,
12,
89,
9,
199,
3,
199,
3,
4483,
1323,
63,
4129,
275,
666,
59,
2834,
63,
2996,
12,
841,
61,
199,
3,
4483,
1323,
63,
4129,
275,
1323,
63,
4129,
14,
5217,
1332,
2834,
63,
2996,
14,
1392,
59,
16,
467,
413,
430,
199,
3,
4483,
23044,
18,
275,
12489,
17675,
8,
2355,
63,
929,
29,
2260,
12,
445,
29,
35,
18,
12,
1021,
63,
3463,
29,
533,
63,
4916,
9,
199,
3,
4483,
23044,
18,
14,
3269,
8,
56,
63,
4129,
12,
612,
9,
199,
3,
199,
3,
4483,
327,
588,
275,
23044,
18,
14,
6892,
8,
576,
59,
396,
63,
2996,
12,
841,
1055,
5217,
1332,
396,
63,
2996,
14,
1392,
59,
16,
467,
413,
1724,
199,
3,
4483,
327,
645,
1259,
14,
740,
8,
16820,
18,
14,
3397,
8,
576,
59,
396,
63,
2996,
12,
841,
1055,
5217,
1332,
396,
63,
2996,
14,
1392,
59,
16,
467,
413,
1826,
666,
59,
396,
63,
2996,
12,
16,
2459,
199,
3,
199,
3,
4483,
19205,
275,
980,
14,
4250,
1332,
396,
63,
2996,
14,
1392,
59,
16,
467,
430,
199,
3,
4483,
367,
284,
12,
2996,
315,
3874,
8,
396,
63,
2996,
304,
199,
3,
8540,
340,
666,
59,
2996,
3057,
17,
61,
2356,
366,
26,
199,
3,
12788,
19205,
59,
73,
61,
275,
23044,
17,
14,
6892,
8,
576,
59,
2996,
12,
650,
26,
21,
1055,
5217,
1332,
17,
12,
18,
1724,
199,
3,
8540,
587,
26,
199,
3,
12788,
19205,
59,
73,
61,
275,
23044,
18,
14,
6892,
8,
576,
59,
2996,
12,
841,
1055,
5217,
1332,
17,
12,
17,
1724,
199,
3,
463,
199,
3,
4483,
6907,
275,
980,
14,
1838,
8,
576,
59,
396,
63,
2996,
12,
16,
61,
508,
19205,
9,
1182,
2069,
8,
396,
63,
2996,
14,
1392,
59,
16,
566,
199,
3,
4483,
1066,
1259,
14,
740,
8,
5470,
9,
199,
3,
4483,
7347,
12,
10717,
12,
7449,
12,
10110,
275,
7151,
63,
19183,
63,
2319,
1018,
63,
4058,
8,
576,
59,
396,
63,
2996,
12,
16,
467,
19205,
12,
8201,
29,
5683,
9,
199,
3,
4483,
876,
559,
1356,
14,
740,
8,
1190,
59,
17,
566,
199,
3,
4483,
295,
5352,
14
] |
[
2680,
465,
980,
199,
199,
504,
6357,
14,
7925,
63,
6136,
492,
8059,
63,
637,
63,
3397,
12,
5244,
6817,
8862,
199,
504,
6357,
14,
16820,
492,
12489,
17675,
12,
428,
9454,
199,
504,
6357,
14,
3825,
63,
1733,
492,
32570,
199,
504,
6357,
14,
6759,
492,
7151,
63,
19183,
63,
2319,
1018,
63,
4058,
199,
199,
646,
8027,
14,
13563,
465,
4488,
199,
199,
576,
275,
980,
14,
2268,
30439,
360,
18552,
63,
8275,
14,
4737,
297,
11172,
4009,
358,
199,
199,
3,
3356,
275,
980,
14,
28831,
63,
269,
8,
1590,
14,
28831,
63,
460,
8,
576,
3981,
16,
61,
508,
446,
17,
12,
666,
3981,
17,
61,
2695,
499,
395,
666,
3981,
16,
19219,
17,
9,
199,
3,
576,
275,
666,
59,
3356,
21063,
199,
3,
576,
275,
666,
59,
576,
3981,
23,
61,
8119,
21,
21063,
199,
1712,
275,
666,
59,
576,
3981,
16,
19219,
17,
21063,
199,
8705,
275,
666,
59,
576,
3981,
16,
19219,
13,
17,
21063,
421,
199,
65,
275,
378,
14,
11870,
1342,
8527,
257,
199,
66,
275,
378,
14,
31622,
6576,
966,
221,
199,
67,
275,
446,
16,
14,
1367,
1216,
2194,
821,
421,
199,
88,
12430,
275,
980,
14,
11649,
8,
16,
12,
21,
12,
1960,
9,
199,
89,
12430,
275,
980,
14,
11649,
8,
16,
12,
21,
12,
1960,
9,
199,
199,
56,
12,
57,
275,
980,
14,
6480,
3825,
8,
88,
12430,
12,
89,
12430,
9,
199,
58,
275,
282,
627,
1323,
435,
330,
627,
1488,
435,
286,
199,
1361,
3107,
199,
199,
6003,
14,
13512,
8,
8705,
3981,
19,
467,
14158,
3981,
20,
467,
3164,
534,
82,
358,
199,
6003,
14,
13512,
8,
1712,
3981,
19,
467,
2086,
3981,
20,
467,
3164,
534,
66,
358,
199,
6003,
14,
17798,
8,
56,
12,
57,
12,
58,
9,
199,
199,
6003,
14,
14168,
360,
3700,
796,
358,
199,
6003,
14,
13849,
360,
426,
2492,
358,
199,
6003,
14,
2384,
342,
199,
3,
576,
59,
576,
3981,
16,
19219,
17,
12,
16,
61,
275,
499,
199,
3,
576,
59,
576,
3981,
16,
19219,
13,
17,
12,
16,
61,
275,
413,
199,
3,
576,
59,
576,
3981,
16,
19219,
18,
12,
16,
61,
275,
446,
17,
199,
199,
3,
1361,
666,
14,
1392,
199,
3,
576,
275,
666,
59,
576,
3981,
17,
28474,
16,
21063,
199,
3,
576,
275,
666,
59,
576,
3981,
18,
28474,
16,
21063,
199,
3,
1361,
666,
14,
1392,
199,
5107,
275,
5244,
6817,
8862,
8,
576,
14,
1392,
59,
16,
467,
302,
63,
1661,
29,
709,
12,
2196,
63,
929,
29,
20,
9,
199,
199,
827,
63,
18552,
275,
359,
17,
12,
18,
12,
19,
12,
20,
12,
21,
12,
1960,
61,
199,
67,
17,
63,
3825,
275,
980,
14,
7270,
1142,
8,
16,
12,
18,
12,
709,
9,
199,
67,
18,
63,
3825,
275,
980,
14,
7270,
1142,
8,
16,
12,
20,
12,
1046,
9,
199,
533,
63,
4916,
275,
469,
17,
26,
21,
12,
446,
17,
26,
17,
93,
199,
5683,
275,
413,
14,
16,
421,
199,
3,
7010,
63,
1162,
275,
1052,
199,
3,
7010,
63,
2319,
1018,
275,
378,
199,
3,
509,
366,
315,
1748,
63,
18552,
26,
199,
3,
259,
367,
445,
17,
315,
286,
17,
63,
3825,
26,
199,
3,
263,
367,
445,
18,
315,
286,
18,
63,
3825,
26,
199,
3,
3322,
876,
559,
1356,
275,
942,
199,
3,
3322,
295,
5352,
275,
942,
199,
3,
3322,
289,
7107,
275,
942,
199,
3,
3322,
1066,
1259,
275,
942,
199,
3,
3322,
367,
334,
2834,
63,
2996,
12,
511,
63,
2996,
9,
315,
6277,
26,
199,
3,
4483,
1323,
275,
666,
59,
2834,
63,
2996,
12,
19,
26,
21,
61,
199,
3,
4483,
612,
275,
666,
59,
2834,
63,
2996,
12,
16,
61,
199,
3,
199,
3,
4483,
23044,
17,
275,
12489,
17675,
8,
2355,
63,
929,
29,
2260,
12,
445,
29,
35,
17,
12,
1021,
63,
3463,
29,
533,
63,
4916,
9,
199,
3,
4483,
23044,
17,
14,
3269,
8,
56,
12,
89,
9,
199,
3,
199,
3,
4483,
1323,
63,
4129,
275,
666,
59,
2834,
63,
2996,
12,
841,
61,
199,
3,
4483,
1323,
63,
4129,
275,
1323,
63,
4129,
14,
5217,
1332,
2834,
63,
2996,
14,
1392,
59,
16,
467,
413,
430,
199,
3,
4483,
23044,
18,
275,
12489,
17675,
8,
2355,
63,
929,
29,
2260,
12,
445,
29,
35,
18,
12,
1021,
63,
3463,
29,
533,
63,
4916,
9,
199,
3,
4483,
23044,
18,
14,
3269,
8,
56,
63,
4129,
12,
612,
9,
199,
3,
199,
3,
4483,
327,
588,
275,
23044,
18,
14,
6892,
8,
576,
59,
396,
63,
2996,
12,
841,
1055,
5217,
1332,
396,
63,
2996,
14,
1392,
59,
16,
467,
413,
1724,
199,
3,
4483,
327,
645,
1259,
14,
740,
8,
16820,
18,
14,
3397,
8,
576,
59,
396,
63,
2996,
12,
841,
1055,
5217,
1332,
396,
63,
2996,
14,
1392,
59,
16,
467,
413,
1826,
666,
59,
396,
63,
2996,
12,
16,
2459,
199,
3,
199,
3,
4483,
19205,
275,
980,
14,
4250,
1332,
396,
63,
2996,
14,
1392,
59,
16,
467,
430,
199,
3,
4483,
367,
284,
12,
2996,
315,
3874,
8,
396,
63,
2996,
304,
199,
3,
8540,
340,
666,
59,
2996,
3057,
17,
61,
2356,
366,
26,
199,
3,
12788,
19205,
59,
73,
61,
275,
23044,
17,
14,
6892,
8,
576,
59,
2996,
12,
650,
26,
21,
1055,
5217,
1332,
17,
12,
18,
1724,
199,
3,
8540,
587,
26,
199,
3,
12788,
19205,
59,
73,
61,
275,
23044,
18,
14,
6892,
8,
576,
59,
2996,
12,
841,
1055,
5217,
1332,
17,
12,
17,
1724,
199,
3,
463,
199,
3,
4483,
6907,
275,
980,
14,
1838,
8,
576,
59,
396,
63,
2996,
12,
16,
61,
508,
19205,
9,
1182,
2069,
8,
396,
63,
2996,
14,
1392,
59,
16,
566,
199,
3,
4483,
1066,
1259,
14,
740,
8,
5470,
9,
199,
3,
4483,
7347,
12,
10717,
12,
7449,
12,
10110,
275,
7151,
63,
19183,
63,
2319,
1018,
63,
4058,
8,
576,
59,
396,
63,
2996,
12,
16,
467,
19205,
12,
8201,
29,
5683,
9,
199,
3,
4483,
876,
559,
1356,
14,
740,
8,
1190,
59,
17,
566,
199,
3,
4483,
295,
5352,
14,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
madphysicist/numpy
|
numpy/linalg/tests/test_linalg.py
|
2
|
74348
|
""" Test functions for linalg module
"""
import os
import sys
import itertools
import traceback
import textwrap
import subprocess
import pytest
import numpy as np
from numpy import array, single, double, csingle, cdouble, dot, identity, matmul
from numpy import multiply, atleast_2d, inf, asarray
from numpy import linalg
from numpy.linalg import matrix_power, norm, matrix_rank, multi_dot, LinAlgError
from numpy.linalg.linalg import _multi_dot_matrix_chain_order
from numpy.testing import (
assert_, assert_equal, assert_raises, assert_array_equal,
assert_almost_equal, assert_allclose, suppress_warnings,
assert_raises_regex, HAS_LAPACK64,
)
from numpy.testing._private.utils import requires_memory
def consistent_subclass(out, in_):
# For ndarray subclass input, our output should have the same subclass
# (non-ndarray input gets converted to ndarray).
return type(out) is (type(in_) if isinstance(in_, np.ndarray)
else np.ndarray)
old_assert_almost_equal = assert_almost_equal
def assert_almost_equal(a, b, single_decimal=6, double_decimal=12, **kw):
if asarray(a).dtype.type in (single, csingle):
decimal = single_decimal
else:
decimal = double_decimal
old_assert_almost_equal(a, b, decimal=decimal, **kw)
def get_real_dtype(dtype):
return {single: single, double: double,
csingle: single, cdouble: double}[dtype]
def get_complex_dtype(dtype):
return {single: csingle, double: cdouble,
csingle: csingle, cdouble: cdouble}[dtype]
def get_rtol(dtype):
# Choose a safe rtol
if dtype in (single, csingle):
return 1e-5
else:
return 1e-11
# used to categorize tests
all_tags = {
'square', 'nonsquare', 'hermitian', # mutually exclusive
'generalized', 'size-0', 'strided' # optional additions
}
class LinalgCase:
def __init__(self, name, a, b, tags=set()):
"""
A bundle of arguments to be passed to a test case, with an identifying
name, the operands a and b, and a set of tags to filter the tests
"""
assert_(isinstance(name, str))
self.name = name
self.a = a
self.b = b
self.tags = frozenset(tags) # prevent shared tags
def check(self, do):
"""
Run the function `do` on this test case, expanding arguments
"""
do(self.a, self.b, tags=self.tags)
def __repr__(self):
return f'<LinalgCase: {self.name}>'
def apply_tag(tag, cases):
"""
Add the given tag (a string) to each of the cases (a list of LinalgCase
objects)
"""
assert tag in all_tags, "Invalid tag"
for case in cases:
case.tags = case.tags | {tag}
return cases
#
# Base test cases
#
np.random.seed(1234)
CASES = []
# square test cases
CASES += apply_tag('square', [
LinalgCase("single",
array([[1., 2.], [3., 4.]], dtype=single),
array([2., 1.], dtype=single)),
LinalgCase("double",
array([[1., 2.], [3., 4.]], dtype=double),
array([2., 1.], dtype=double)),
LinalgCase("double_2",
array([[1., 2.], [3., 4.]], dtype=double),
array([[2., 1., 4.], [3., 4., 6.]], dtype=double)),
LinalgCase("csingle",
array([[1. + 2j, 2 + 3j], [3 + 4j, 4 + 5j]], dtype=csingle),
array([2. + 1j, 1. + 2j], dtype=csingle)),
LinalgCase("cdouble",
array([[1. + 2j, 2 + 3j], [3 + 4j, 4 + 5j]], dtype=cdouble),
array([2. + 1j, 1. + 2j], dtype=cdouble)),
LinalgCase("cdouble_2",
array([[1. + 2j, 2 + 3j], [3 + 4j, 4 + 5j]], dtype=cdouble),
array([[2. + 1j, 1. + 2j, 1 + 3j], [1 - 2j, 1 - 3j, 1 - 6j]], dtype=cdouble)),
LinalgCase("0x0",
np.empty((0, 0), dtype=double),
np.empty((0,), dtype=double),
tags={'size-0'}),
LinalgCase("8x8",
np.random.rand(8, 8),
np.random.rand(8)),
LinalgCase("1x1",
np.random.rand(1, 1),
np.random.rand(1)),
LinalgCase("nonarray",
[[1, 2], [3, 4]],
[2, 1]),
])
# non-square test-cases
CASES += apply_tag('nonsquare', [
LinalgCase("single_nsq_1",
array([[1., 2., 3.], [3., 4., 6.]], dtype=single),
array([2., 1.], dtype=single)),
LinalgCase("single_nsq_2",
array([[1., 2.], [3., 4.], [5., 6.]], dtype=single),
array([2., 1., 3.], dtype=single)),
LinalgCase("double_nsq_1",
array([[1., 2., 3.], [3., 4., 6.]], dtype=double),
array([2., 1.], dtype=double)),
LinalgCase("double_nsq_2",
array([[1., 2.], [3., 4.], [5., 6.]], dtype=double),
array([2., 1., 3.], dtype=double)),
LinalgCase("csingle_nsq_1",
array(
[[1. + 1j, 2. + 2j, 3. - 3j], [3. - 5j, 4. + 9j, 6. + 2j]], dtype=csingle),
array([2. + 1j, 1. + 2j], dtype=csingle)),
LinalgCase("csingle_nsq_2",
array(
[[1. + 1j, 2. + 2j], [3. - 3j, 4. - 9j], [5. - 4j, 6. + 8j]], dtype=csingle),
array([2. + 1j, 1. + 2j, 3. - 3j], dtype=csingle)),
LinalgCase("cdouble_nsq_1",
array(
[[1. + 1j, 2. + 2j, 3. - 3j], [3. - 5j, 4. + 9j, 6. + 2j]], dtype=cdouble),
array([2. + 1j, 1. + 2j], dtype=cdouble)),
LinalgCase("cdouble_nsq_2",
array(
[[1. + 1j, 2. + 2j], [3. - 3j, 4. - 9j], [5. - 4j, 6. + 8j]], dtype=cdouble),
array([2. + 1j, 1. + 2j, 3. - 3j], dtype=cdouble)),
LinalgCase("cdouble_nsq_1_2",
array(
[[1. + 1j, 2. + 2j, 3. - 3j], [3. - 5j, 4. + 9j, 6. + 2j]], dtype=cdouble),
array([[2. + 1j, 1. + 2j], [1 - 1j, 2 - 2j]], dtype=cdouble)),
LinalgCase("cdouble_nsq_2_2",
array(
[[1. + 1j, 2. + 2j], [3. - 3j, 4. - 9j], [5. - 4j, 6. + 8j]], dtype=cdouble),
array([[2. + 1j, 1. + 2j], [1 - 1j, 2 - 2j], [1 - 1j, 2 - 2j]], dtype=cdouble)),
LinalgCase("8x11",
np.random.rand(8, 11),
np.random.rand(8)),
LinalgCase("1x5",
np.random.rand(1, 5),
np.random.rand(1)),
LinalgCase("5x1",
np.random.rand(5, 1),
np.random.rand(5)),
LinalgCase("0x4",
np.random.rand(0, 4),
np.random.rand(0),
tags={'size-0'}),
LinalgCase("4x0",
np.random.rand(4, 0),
np.random.rand(4),
tags={'size-0'}),
])
# hermitian test-cases
CASES += apply_tag('hermitian', [
LinalgCase("hsingle",
array([[1., 2.], [2., 1.]], dtype=single),
None),
LinalgCase("hdouble",
array([[1., 2.], [2., 1.]], dtype=double),
None),
LinalgCase("hcsingle",
array([[1., 2 + 3j], [2 - 3j, 1]], dtype=csingle),
None),
LinalgCase("hcdouble",
array([[1., 2 + 3j], [2 - 3j, 1]], dtype=cdouble),
None),
LinalgCase("hempty",
np.empty((0, 0), dtype=double),
None,
tags={'size-0'}),
LinalgCase("hnonarray",
[[1, 2], [2, 1]],
None),
LinalgCase("matrix_b_only",
array([[1., 2.], [2., 1.]]),
None),
LinalgCase("hmatrix_1x1",
np.random.rand(1, 1),
None),
])
#
# Gufunc test cases
#
def _make_generalized_cases():
new_cases = []
for case in CASES:
if not isinstance(case.a, np.ndarray):
continue
a = np.array([case.a, 2 * case.a, 3 * case.a])
if case.b is None:
b = None
else:
b = np.array([case.b, 7 * case.b, 6 * case.b])
new_case = LinalgCase(case.name + "_tile3", a, b,
tags=case.tags | {'generalized'})
new_cases.append(new_case)
a = np.array([case.a] * 2 * 3).reshape((3, 2) + case.a.shape)
if case.b is None:
b = None
else:
b = np.array([case.b] * 2 * 3).reshape((3, 2) + case.b.shape)
new_case = LinalgCase(case.name + "_tile213", a, b,
tags=case.tags | {'generalized'})
new_cases.append(new_case)
return new_cases
CASES += _make_generalized_cases()
#
# Generate stride combination variations of the above
#
def _stride_comb_iter(x):
"""
Generate cartesian product of strides for all axes
"""
if not isinstance(x, np.ndarray):
yield x, "nop"
return
stride_set = [(1,)] * x.ndim
stride_set[-1] = (1, 3, -4)
if x.ndim > 1:
stride_set[-2] = (1, 3, -4)
if x.ndim > 2:
stride_set[-3] = (1, -4)
for repeats in itertools.product(*tuple(stride_set)):
new_shape = [abs(a * b) for a, b in zip(x.shape, repeats)]
slices = tuple([slice(None, None, repeat) for repeat in repeats])
# new array with different strides, but same data
xi = np.empty(new_shape, dtype=x.dtype)
xi.view(np.uint32).fill(0xdeadbeef)
xi = xi[slices]
xi[...] = x
xi = xi.view(x.__class__)
assert_(np.all(xi == x))
yield xi, "stride_" + "_".join(["%+d" % j for j in repeats])
# generate also zero strides if possible
if x.ndim >= 1 and x.shape[-1] == 1:
s = list(x.strides)
s[-1] = 0
xi = np.lib.stride_tricks.as_strided(x, strides=s)
yield xi, "stride_xxx_0"
if x.ndim >= 2 and x.shape[-2] == 1:
s = list(x.strides)
s[-2] = 0
xi = np.lib.stride_tricks.as_strided(x, strides=s)
yield xi, "stride_xxx_0_x"
if x.ndim >= 2 and x.shape[:-2] == (1, 1):
s = list(x.strides)
s[-1] = 0
s[-2] = 0
xi = np.lib.stride_tricks.as_strided(x, strides=s)
yield xi, "stride_xxx_0_0"
def _make_strided_cases():
new_cases = []
for case in CASES:
for a, a_label in _stride_comb_iter(case.a):
for b, b_label in _stride_comb_iter(case.b):
new_case = LinalgCase(case.name + "_" + a_label + "_" + b_label, a, b,
tags=case.tags | {'strided'})
new_cases.append(new_case)
return new_cases
CASES += _make_strided_cases()
#
# Test different routines against the above cases
#
class LinalgTestCase:
TEST_CASES = CASES
def check_cases(self, require=set(), exclude=set()):
"""
Run func on each of the cases with all of the tags in require, and none
of the tags in exclude
"""
for case in self.TEST_CASES:
# filter by require and exclude
if case.tags & require != require:
continue
if case.tags & exclude:
continue
try:
case.check(self.do)
except Exception:
msg = f'In test case: {case!r}\n\n'
msg += traceback.format_exc()
raise AssertionError(msg)
class LinalgSquareTestCase(LinalgTestCase):
def test_sq_cases(self):
self.check_cases(require={'square'},
exclude={'generalized', 'size-0'})
def test_empty_sq_cases(self):
self.check_cases(require={'square', 'size-0'},
exclude={'generalized'})
class LinalgNonsquareTestCase(LinalgTestCase):
def test_nonsq_cases(self):
self.check_cases(require={'nonsquare'},
exclude={'generalized', 'size-0'})
def test_empty_nonsq_cases(self):
self.check_cases(require={'nonsquare', 'size-0'},
exclude={'generalized'})
class HermitianTestCase(LinalgTestCase):
def test_herm_cases(self):
self.check_cases(require={'hermitian'},
exclude={'generalized', 'size-0'})
def test_empty_herm_cases(self):
self.check_cases(require={'hermitian', 'size-0'},
exclude={'generalized'})
class LinalgGeneralizedSquareTestCase(LinalgTestCase):
@pytest.mark.slow
def test_generalized_sq_cases(self):
self.check_cases(require={'generalized', 'square'},
exclude={'size-0'})
@pytest.mark.slow
def test_generalized_empty_sq_cases(self):
self.check_cases(require={'generalized', 'square', 'size-0'})
class LinalgGeneralizedNonsquareTestCase(LinalgTestCase):
@pytest.mark.slow
def test_generalized_nonsq_cases(self):
self.check_cases(require={'generalized', 'nonsquare'},
exclude={'size-0'})
@pytest.mark.slow
def test_generalized_empty_nonsq_cases(self):
self.check_cases(require={'generalized', 'nonsquare', 'size-0'})
class HermitianGeneralizedTestCase(LinalgTestCase):
@pytest.mark.slow
def test_generalized_herm_cases(self):
self.check_cases(require={'generalized', 'hermitian'},
exclude={'size-0'})
@pytest.mark.slow
def test_generalized_empty_herm_cases(self):
self.check_cases(require={'generalized', 'hermitian', 'size-0'},
exclude={'none'})
def dot_generalized(a, b):
a = asarray(a)
if a.ndim >= 3:
if a.ndim == b.ndim:
# matrix x matrix
new_shape = a.shape[:-1] + b.shape[-1:]
elif a.ndim == b.ndim + 1:
# matrix x vector
new_shape = a.shape[:-1]
else:
raise ValueError("Not implemented...")
r = np.empty(new_shape, dtype=np.common_type(a, b))
for c in itertools.product(*map(range, a.shape[:-2])):
r[c] = dot(a[c], b[c])
return r
else:
return dot(a, b)
def identity_like_generalized(a):
a = asarray(a)
if a.ndim >= 3:
r = np.empty(a.shape, dtype=a.dtype)
r[...] = identity(a.shape[-2])
return r
else:
return identity(a.shape[0])
class SolveCases(LinalgSquareTestCase, LinalgGeneralizedSquareTestCase):
# kept apart from TestSolve for use for testing with matrices.
def do(self, a, b, tags):
x = linalg.solve(a, b)
assert_almost_equal(b, dot_generalized(a, x))
assert_(consistent_subclass(x, b))
class TestSolve(SolveCases):
@pytest.mark.parametrize('dtype', [single, double, csingle, cdouble])
def test_types(self, dtype):
x = np.array([[1, 0.5], [0.5, 1]], dtype=dtype)
assert_equal(linalg.solve(x, x).dtype, dtype)
def test_0_size(self):
class ArraySubclass(np.ndarray):
pass
# Test system of 0x0 matrices
a = np.arange(8).reshape(2, 2, 2)
b = np.arange(6).reshape(1, 2, 3).view(ArraySubclass)
expected = linalg.solve(a, b)[:, 0:0, :]
result = linalg.solve(a[:, 0:0, 0:0], b[:, 0:0, :])
assert_array_equal(result, expected)
assert_(isinstance(result, ArraySubclass))
# Test errors for non-square and only b's dimension being 0
assert_raises(linalg.LinAlgError, linalg.solve, a[:, 0:0, 0:1], b)
assert_raises(ValueError, linalg.solve, a, b[:, 0:0, :])
# Test broadcasting error
b = np.arange(6).reshape(1, 3, 2) # broadcasting error
assert_raises(ValueError, linalg.solve, a, b)
assert_raises(ValueError, linalg.solve, a[0:0], b[0:0])
# Test zero "single equations" with 0x0 matrices.
b = np.arange(2).reshape(1, 2).view(ArraySubclass)
expected = linalg.solve(a, b)[:, 0:0]
result = linalg.solve(a[:, 0:0, 0:0], b[:, 0:0])
assert_array_equal(result, expected)
assert_(isinstance(result, ArraySubclass))
b = np.arange(3).reshape(1, 3)
assert_raises(ValueError, linalg.solve, a, b)
assert_raises(ValueError, linalg.solve, a[0:0], b[0:0])
assert_raises(ValueError, linalg.solve, a[:, 0:0, 0:0], b)
def test_0_size_k(self):
# test zero multiple equation (K=0) case.
class ArraySubclass(np.ndarray):
pass
a = np.arange(4).reshape(1, 2, 2)
b = np.arange(6).reshape(3, 2, 1).view(ArraySubclass)
expected = linalg.solve(a, b)[:, :, 0:0]
result = linalg.solve(a, b[:, :, 0:0])
assert_array_equal(result, expected)
assert_(isinstance(result, ArraySubclass))
# test both zero.
expected = linalg.solve(a, b)[:, 0:0, 0:0]
result = linalg.solve(a[:, 0:0, 0:0], b[:, 0:0, 0:0])
assert_array_equal(result, expected)
assert_(isinstance(result, ArraySubclass))
class InvCases(LinalgSquareTestCase, LinalgGeneralizedSquareTestCase):
def do(self, a, b, tags):
a_inv = linalg.inv(a)
assert_almost_equal(dot_generalized(a, a_inv),
identity_like_generalized(a))
assert_(consistent_subclass(a_inv, a))
class TestInv(InvCases):
@pytest.mark.parametrize('dtype', [single, double, csingle, cdouble])
def test_types(self, dtype):
x = np.array([[1, 0.5], [0.5, 1]], dtype=dtype)
assert_equal(linalg.inv(x).dtype, dtype)
def test_0_size(self):
# Check that all kinds of 0-sized arrays work
class ArraySubclass(np.ndarray):
pass
a = np.zeros((0, 1, 1), dtype=np.int_).view(ArraySubclass)
res = linalg.inv(a)
assert_(res.dtype.type is np.float64)
assert_equal(a.shape, res.shape)
assert_(isinstance(res, ArraySubclass))
a = np.zeros((0, 0), dtype=np.complex64).view(ArraySubclass)
res = linalg.inv(a)
assert_(res.dtype.type is np.complex64)
assert_equal(a.shape, res.shape)
assert_(isinstance(res, ArraySubclass))
class EigvalsCases(LinalgSquareTestCase, LinalgGeneralizedSquareTestCase):
def do(self, a, b, tags):
ev = linalg.eigvals(a)
evalues, evectors = linalg.eig(a)
assert_almost_equal(ev, evalues)
class TestEigvals(EigvalsCases):
@pytest.mark.parametrize('dtype', [single, double, csingle, cdouble])
def test_types(self, dtype):
x = np.array([[1, 0.5], [0.5, 1]], dtype=dtype)
assert_equal(linalg.eigvals(x).dtype, dtype)
x = np.array([[1, 0.5], [-1, 1]], dtype=dtype)
assert_equal(linalg.eigvals(x).dtype, get_complex_dtype(dtype))
def test_0_size(self):
# Check that all kinds of 0-sized arrays work
class ArraySubclass(np.ndarray):
pass
a = np.zeros((0, 1, 1), dtype=np.int_).view(ArraySubclass)
res = linalg.eigvals(a)
assert_(res.dtype.type is np.float64)
assert_equal((0, 1), res.shape)
# This is just for documentation, it might make sense to change:
assert_(isinstance(res, np.ndarray))
a = np.zeros((0, 0), dtype=np.complex64).view(ArraySubclass)
res = linalg.eigvals(a)
assert_(res.dtype.type is np.complex64)
assert_equal((0,), res.shape)
# This is just for documentation, it might make sense to change:
assert_(isinstance(res, np.ndarray))
class EigCases(LinalgSquareTestCase, LinalgGeneralizedSquareTestCase):
def do(self, a, b, tags):
evalues, evectors = linalg.eig(a)
assert_allclose(dot_generalized(a, evectors),
np.asarray(evectors) * np.asarray(evalues)[..., None, :],
rtol=get_rtol(evalues.dtype))
assert_(consistent_subclass(evectors, a))
class TestEig(EigCases):
@pytest.mark.parametrize('dtype', [single, double, csingle, cdouble])
def test_types(self, dtype):
x = np.array([[1, 0.5], [0.5, 1]], dtype=dtype)
w, v = np.linalg.eig(x)
assert_equal(w.dtype, dtype)
assert_equal(v.dtype, dtype)
x = np.array([[1, 0.5], [-1, 1]], dtype=dtype)
w, v = np.linalg.eig(x)
assert_equal(w.dtype, get_complex_dtype(dtype))
assert_equal(v.dtype, get_complex_dtype(dtype))
def test_0_size(self):
# Check that all kinds of 0-sized arrays work
class ArraySubclass(np.ndarray):
pass
a = np.zeros((0, 1, 1), dtype=np.int_).view(ArraySubclass)
res, res_v = linalg.eig(a)
assert_(res_v.dtype.type is np.float64)
assert_(res.dtype.type is np.float64)
assert_equal(a.shape, res_v.shape)
assert_equal((0, 1), res.shape)
# This is just for documentation, it might make sense to change:
assert_(isinstance(a, np.ndarray))
a = np.zeros((0, 0), dtype=np.complex64).view(ArraySubclass)
res, res_v = linalg.eig(a)
assert_(res_v.dtype.type is np.complex64)
assert_(res.dtype.type is np.complex64)
assert_equal(a.shape, res_v.shape)
assert_equal((0,), res.shape)
# This is just for documentation, it might make sense to change:
assert_(isinstance(a, np.ndarray))
class SVDBaseTests:
hermitian = False
@pytest.mark.parametrize('dtype', [single, double, csingle, cdouble])
def test_types(self, dtype):
x = np.array([[1, 0.5], [0.5, 1]], dtype=dtype)
u, s, vh = linalg.svd(x)
assert_equal(u.dtype, dtype)
assert_equal(s.dtype, get_real_dtype(dtype))
assert_equal(vh.dtype, dtype)
s = linalg.svd(x, compute_uv=False, hermitian=self.hermitian)
assert_equal(s.dtype, get_real_dtype(dtype))
class SVDCases(LinalgSquareTestCase, LinalgGeneralizedSquareTestCase):
def do(self, a, b, tags):
u, s, vt = linalg.svd(a, False)
assert_allclose(a, dot_generalized(np.asarray(u) * np.asarray(s)[..., None, :],
np.asarray(vt)),
rtol=get_rtol(u.dtype))
assert_(consistent_subclass(u, a))
assert_(consistent_subclass(vt, a))
class TestSVD(SVDCases, SVDBaseTests):
def test_empty_identity(self):
""" Empty input should put an identity matrix in u or vh """
x = np.empty((4, 0))
u, s, vh = linalg.svd(x, compute_uv=True, hermitian=self.hermitian)
assert_equal(u.shape, (4, 4))
assert_equal(vh.shape, (0, 0))
assert_equal(u, np.eye(4))
x = np.empty((0, 4))
u, s, vh = linalg.svd(x, compute_uv=True, hermitian=self.hermitian)
assert_equal(u.shape, (0, 0))
assert_equal(vh.shape, (4, 4))
assert_equal(vh, np.eye(4))
class SVDHermitianCases(HermitianTestCase, HermitianGeneralizedTestCase):
def do(self, a, b, tags):
u, s, vt = linalg.svd(a, False, hermitian=True)
assert_allclose(a, dot_generalized(np.asarray(u) * np.asarray(s)[..., None, :],
np.asarray(vt)),
rtol=get_rtol(u.dtype))
def hermitian(mat):
axes = list(range(mat.ndim))
axes[-1], axes[-2] = axes[-2], axes[-1]
return np.conj(np.transpose(mat, axes=axes))
assert_almost_equal(np.matmul(u, hermitian(u)), np.broadcast_to(np.eye(u.shape[-1]), u.shape))
assert_almost_equal(np.matmul(vt, hermitian(vt)), np.broadcast_to(np.eye(vt.shape[-1]), vt.shape))
assert_equal(np.sort(s)[..., ::-1], s)
assert_(consistent_subclass(u, a))
assert_(consistent_subclass(vt, a))
class TestSVDHermitian(SVDHermitianCases, SVDBaseTests):
hermitian = True
class CondCases(LinalgSquareTestCase, LinalgGeneralizedSquareTestCase):
# cond(x, p) for p in (None, 2, -2)
def do(self, a, b, tags):
c = asarray(a) # a might be a matrix
if 'size-0' in tags:
assert_raises(LinAlgError, linalg.cond, c)
return
# +-2 norms
s = linalg.svd(c, compute_uv=False)
assert_almost_equal(
linalg.cond(a), s[..., 0] / s[..., -1],
single_decimal=5, double_decimal=11)
assert_almost_equal(
linalg.cond(a, 2), s[..., 0] / s[..., -1],
single_decimal=5, double_decimal=11)
assert_almost_equal(
linalg.cond(a, -2), s[..., -1] / s[..., 0],
single_decimal=5, double_decimal=11)
# Other norms
cinv = np.linalg.inv(c)
assert_almost_equal(
linalg.cond(a, 1),
abs(c).sum(-2).max(-1) * abs(cinv).sum(-2).max(-1),
single_decimal=5, double_decimal=11)
assert_almost_equal(
linalg.cond(a, -1),
abs(c).sum(-2).min(-1) * abs(cinv).sum(-2).min(-1),
single_decimal=5, double_decimal=11)
assert_almost_equal(
linalg.cond(a, np.inf),
abs(c).sum(-1).max(-1) * abs(cinv).sum(-1).max(-1),
single_decimal=5, double_decimal=11)
assert_almost_equal(
linalg.cond(a, -np.inf),
abs(c).sum(-1).min(-1) * abs(cinv).sum(-1).min(-1),
single_decimal=5, double_decimal=11)
assert_almost_equal(
linalg.cond(a, 'fro'),
np.sqrt((abs(c)**2).sum(-1).sum(-1)
* (abs(cinv)**2).sum(-1).sum(-1)),
single_decimal=5, double_decimal=11)
class TestCond(CondCases):
def test_basic_nonsvd(self):
# Smoketest the non-svd norms
A = array([[1., 0, 1], [0, -2., 0], [0, 0, 3.]])
assert_almost_equal(linalg.cond(A, inf), 4)
assert_almost_equal(linalg.cond(A, -inf), 2/3)
assert_almost_equal(linalg.cond(A, 1), 4)
assert_almost_equal(linalg.cond(A, -1), 0.5)
assert_almost_equal(linalg.cond(A, 'fro'), np.sqrt(265 / 12))
def test_singular(self):
# Singular matrices have infinite condition number for
# positive norms, and negative norms shouldn't raise
# exceptions
As = [np.zeros((2, 2)), np.ones((2, 2))]
p_pos = [None, 1, 2, 'fro']
p_neg = [-1, -2]
for A, p in itertools.product(As, p_pos):
# Inversion may not hit exact infinity, so just check the
# number is large
assert_(linalg.cond(A, p) > 1e15)
for A, p in itertools.product(As, p_neg):
linalg.cond(A, p)
def test_nan(self):
# nans should be passed through, not converted to infs
ps = [None, 1, -1, 2, -2, 'fro']
p_pos = [None, 1, 2, 'fro']
A = np.ones((2, 2))
A[0,1] = np.nan
for p in ps:
c = linalg.cond(A, p)
assert_(isinstance(c, np.float_))
assert_(np.isnan(c))
A = np.ones((3, 2, 2))
A[1,0,1] = np.nan
for p in ps:
c = linalg.cond(A, p)
assert_(np.isnan(c[1]))
if p in p_pos:
assert_(c[0] > 1e15)
assert_(c[2] > 1e15)
else:
assert_(not np.isnan(c[0]))
assert_(not np.isnan(c[2]))
def test_stacked_singular(self):
# Check behavior when only some of the stacked matrices are
# singular
np.random.seed(1234)
A = np.random.rand(2, 2, 2, 2)
A[0,0] = 0
A[1,1] = 0
for p in (None, 1, 2, 'fro', -1, -2):
c = linalg.cond(A, p)
assert_equal(c[0,0], np.inf)
assert_equal(c[1,1], np.inf)
assert_(np.isfinite(c[0,1]))
assert_(np.isfinite(c[1,0]))
class PinvCases(LinalgSquareTestCase,
LinalgNonsquareTestCase,
LinalgGeneralizedSquareTestCase,
LinalgGeneralizedNonsquareTestCase):
def do(self, a, b, tags):
a_ginv = linalg.pinv(a)
# `a @ a_ginv == I` does not hold if a is singular
dot = dot_generalized
assert_almost_equal(dot(dot(a, a_ginv), a), a, single_decimal=5, double_decimal=11)
assert_(consistent_subclass(a_ginv, a))
class TestPinv(PinvCases):
pass
class PinvHermitianCases(HermitianTestCase, HermitianGeneralizedTestCase):
def do(self, a, b, tags):
a_ginv = linalg.pinv(a, hermitian=True)
# `a @ a_ginv == I` does not hold if a is singular
dot = dot_generalized
assert_almost_equal(dot(dot(a, a_ginv), a), a, single_decimal=5, double_decimal=11)
assert_(consistent_subclass(a_ginv, a))
class TestPinvHermitian(PinvHermitianCases):
pass
class DetCases(LinalgSquareTestCase, LinalgGeneralizedSquareTestCase):
def do(self, a, b, tags):
d = linalg.det(a)
(s, ld) = linalg.slogdet(a)
if asarray(a).dtype.type in (single, double):
ad = asarray(a).astype(double)
else:
ad = asarray(a).astype(cdouble)
ev = linalg.eigvals(ad)
assert_almost_equal(d, multiply.reduce(ev, axis=-1))
assert_almost_equal(s * np.exp(ld), multiply.reduce(ev, axis=-1))
s = np.atleast_1d(s)
ld = np.atleast_1d(ld)
m = (s != 0)
assert_almost_equal(np.abs(s[m]), 1)
assert_equal(ld[~m], -inf)
class TestDet(DetCases):
def test_zero(self):
assert_equal(linalg.det([[0.0]]), 0.0)
assert_equal(type(linalg.det([[0.0]])), double)
assert_equal(linalg.det([[0.0j]]), 0.0)
assert_equal(type(linalg.det([[0.0j]])), cdouble)
assert_equal(linalg.slogdet([[0.0]]), (0.0, -inf))
assert_equal(type(linalg.slogdet([[0.0]])[0]), double)
assert_equal(type(linalg.slogdet([[0.0]])[1]), double)
assert_equal(linalg.slogdet([[0.0j]]), (0.0j, -inf))
assert_equal(type(linalg.slogdet([[0.0j]])[0]), cdouble)
assert_equal(type(linalg.slogdet([[0.0j]])[1]), double)
@pytest.mark.parametrize('dtype', [single, double, csingle, cdouble])
def test_types(self, dtype):
x = np.array([[1, 0.5], [0.5, 1]], dtype=dtype)
assert_equal(np.linalg.det(x).dtype, dtype)
ph, s = np.linalg.slogdet(x)
assert_equal(s.dtype, get_real_dtype(dtype))
assert_equal(ph.dtype, dtype)
def test_0_size(self):
a = np.zeros((0, 0), dtype=np.complex64)
res = linalg.det(a)
assert_equal(res, 1.)
assert_(res.dtype.type is np.complex64)
res = linalg.slogdet(a)
assert_equal(res, (1, 0))
assert_(res[0].dtype.type is np.complex64)
assert_(res[1].dtype.type is np.float32)
a = np.zeros((0, 0), dtype=np.float64)
res = linalg.det(a)
assert_equal(res, 1.)
assert_(res.dtype.type is np.float64)
res = linalg.slogdet(a)
assert_equal(res, (1, 0))
assert_(res[0].dtype.type is np.float64)
assert_(res[1].dtype.type is np.float64)
class LstsqCases(LinalgSquareTestCase, LinalgNonsquareTestCase):
def do(self, a, b, tags):
arr = np.asarray(a)
m, n = arr.shape
u, s, vt = linalg.svd(a, False)
x, residuals, rank, sv = linalg.lstsq(a, b, rcond=-1)
if m == 0:
assert_((x == 0).all())
if m <= n:
assert_almost_equal(b, dot(a, x))
assert_equal(rank, m)
else:
assert_equal(rank, n)
assert_almost_equal(sv, sv.__array_wrap__(s))
if rank == n and m > n:
expect_resids = (
np.asarray(abs(np.dot(a, x) - b)) ** 2).sum(axis=0)
expect_resids = np.asarray(expect_resids)
if np.asarray(b).ndim == 1:
expect_resids.shape = (1,)
assert_equal(residuals.shape, expect_resids.shape)
else:
expect_resids = np.array([]).view(type(x))
assert_almost_equal(residuals, expect_resids)
assert_(np.issubdtype(residuals.dtype, np.floating))
assert_(consistent_subclass(x, b))
assert_(consistent_subclass(residuals, b))
class TestLstsq(LstsqCases):
def test_future_rcond(self):
a = np.array([[0., 1., 0., 1., 2., 0.],
[0., 2., 0., 0., 1., 0.],
[1., 0., 1., 0., 0., 4.],
[0., 0., 0., 2., 3., 0.]]).T
b = np.array([1, 0, 0, 0, 0, 0])
with suppress_warnings() as sup:
w = sup.record(FutureWarning, "`rcond` parameter will change")
x, residuals, rank, s = linalg.lstsq(a, b)
assert_(rank == 4)
x, residuals, rank, s = linalg.lstsq(a, b, rcond=-1)
assert_(rank == 4)
x, residuals, rank, s = linalg.lstsq(a, b, rcond=None)
assert_(rank == 3)
# Warning should be raised exactly once (first command)
assert_(len(w) == 1)
@pytest.mark.parametrize(["m", "n", "n_rhs"], [
(4, 2, 2),
(0, 4, 1),
(0, 4, 2),
(4, 0, 1),
(4, 0, 2),
(4, 2, 0),
(0, 0, 0)
])
def test_empty_a_b(self, m, n, n_rhs):
a = np.arange(m * n).reshape(m, n)
b = np.ones((m, n_rhs))
x, residuals, rank, s = linalg.lstsq(a, b, rcond=None)
if m == 0:
assert_((x == 0).all())
assert_equal(x.shape, (n, n_rhs))
assert_equal(residuals.shape, ((n_rhs,) if m > n else (0,)))
if m > n and n_rhs > 0:
# residuals are exactly the squared norms of b's columns
r = b - np.dot(a, x)
assert_almost_equal(residuals, (r * r).sum(axis=-2))
assert_equal(rank, min(m, n))
assert_equal(s.shape, (min(m, n),))
def test_incompatible_dims(self):
# use modified version of docstring example
x = np.array([0, 1, 2, 3])
y = np.array([-1, 0.2, 0.9, 2.1, 3.3])
A = np.vstack([x, np.ones(len(x))]).T
with assert_raises_regex(LinAlgError, "Incompatible dimensions"):
linalg.lstsq(A, y, rcond=None)
@pytest.mark.parametrize('dt', [np.dtype(c) for c in '?bBhHiIqQefdgFDGO'])
class TestMatrixPower:
rshft_0 = np.eye(4)
rshft_1 = rshft_0[[3, 0, 1, 2]]
rshft_2 = rshft_0[[2, 3, 0, 1]]
rshft_3 = rshft_0[[1, 2, 3, 0]]
rshft_all = [rshft_0, rshft_1, rshft_2, rshft_3]
noninv = array([[1, 0], [0, 0]])
stacked = np.block([[[rshft_0]]]*2)
#FIXME the 'e' dtype might work in future
dtnoinv = [object, np.dtype('e'), np.dtype('g'), np.dtype('G')]
def test_large_power(self, dt):
rshft = self.rshft_1.astype(dt)
assert_equal(
matrix_power(rshft, 2**100 + 2**10 + 2**5 + 0), self.rshft_0)
assert_equal(
matrix_power(rshft, 2**100 + 2**10 + 2**5 + 1), self.rshft_1)
assert_equal(
matrix_power(rshft, 2**100 + 2**10 + 2**5 + 2), self.rshft_2)
assert_equal(
matrix_power(rshft, 2**100 + 2**10 + 2**5 + 3), self.rshft_3)
def test_power_is_zero(self, dt):
def tz(M):
mz = matrix_power(M, 0)
assert_equal(mz, identity_like_generalized(M))
assert_equal(mz.dtype, M.dtype)
for mat in self.rshft_all:
tz(mat.astype(dt))
if dt != object:
tz(self.stacked.astype(dt))
def test_power_is_one(self, dt):
def tz(mat):
mz = matrix_power(mat, 1)
assert_equal(mz, mat)
assert_equal(mz.dtype, mat.dtype)
for mat in self.rshft_all:
tz(mat.astype(dt))
if dt != object:
tz(self.stacked.astype(dt))
def test_power_is_two(self, dt):
def tz(mat):
mz = matrix_power(mat, 2)
mmul = matmul if mat.dtype != object else dot
assert_equal(mz, mmul(mat, mat))
assert_equal(mz.dtype, mat.dtype)
for mat in self.rshft_all:
tz(mat.astype(dt))
if dt != object:
tz(self.stacked.astype(dt))
def test_power_is_minus_one(self, dt):
def tz(mat):
invmat = matrix_power(mat, -1)
mmul = matmul if mat.dtype != object else dot
assert_almost_equal(
mmul(invmat, mat), identity_like_generalized(mat))
for mat in self.rshft_all:
if dt not in self.dtnoinv:
tz(mat.astype(dt))
def test_exceptions_bad_power(self, dt):
mat = self.rshft_0.astype(dt)
assert_raises(TypeError, matrix_power, mat, 1.5)
assert_raises(TypeError, matrix_power, mat, [1])
def test_exceptions_non_square(self, dt):
assert_raises(LinAlgError, matrix_power, np.array([1], dt), 1)
assert_raises(LinAlgError, matrix_power, np.array([[1], [2]], dt), 1)
assert_raises(LinAlgError, matrix_power, np.ones((4, 3, 2), dt), 1)
def test_exceptions_not_invertible(self, dt):
if dt in self.dtnoinv:
return
mat = self.noninv.astype(dt)
assert_raises(LinAlgError, matrix_power, mat, -1)
class TestEigvalshCases(HermitianTestCase, HermitianGeneralizedTestCase):
def do(self, a, b, tags):
# note that eigenvalue arrays returned by eig must be sorted since
# their order isn't guaranteed.
ev = linalg.eigvalsh(a, 'L')
evalues, evectors = linalg.eig(a)
evalues.sort(axis=-1)
assert_allclose(ev, evalues, rtol=get_rtol(ev.dtype))
ev2 = linalg.eigvalsh(a, 'U')
assert_allclose(ev2, evalues, rtol=get_rtol(ev.dtype))
class TestEigvalsh:
@pytest.mark.parametrize('dtype', [single, double, csingle, cdouble])
def test_types(self, dtype):
x = np.array([[1, 0.5], [0.5, 1]], dtype=dtype)
w = np.linalg.eigvalsh(x)
assert_equal(w.dtype, get_real_dtype(dtype))
def test_invalid(self):
x = np.array([[1, 0.5], [0.5, 1]], dtype=np.float32)
assert_raises(ValueError, np.linalg.eigvalsh, x, UPLO="lrong")
assert_raises(ValueError, np.linalg.eigvalsh, x, "lower")
assert_raises(ValueError, np.linalg.eigvalsh, x, "upper")
def test_UPLO(self):
Klo = np.array([[0, 0], [1, 0]], dtype=np.double)
Kup = np.array([[0, 1], [0, 0]], dtype=np.double)
tgt = np.array([-1, 1], dtype=np.double)
rtol = get_rtol(np.double)
# Check default is 'L'
w = np.linalg.eigvalsh(Klo)
assert_allclose(w, tgt, rtol=rtol)
# Check 'L'
w = np.linalg.eigvalsh(Klo, UPLO='L')
assert_allclose(w, tgt, rtol=rtol)
# Check 'l'
w = np.linalg.eigvalsh(Klo, UPLO='l')
assert_allclose(w, tgt, rtol=rtol)
# Check 'U'
w = np.linalg.eigvalsh(Kup, UPLO='U')
assert_allclose(w, tgt, rtol=rtol)
# Check 'u'
w = np.linalg.eigvalsh(Kup, UPLO='u')
assert_allclose(w, tgt, rtol=rtol)
def test_0_size(self):
# Check that all kinds of 0-sized arrays work
class ArraySubclass(np.ndarray):
pass
a = np.zeros((0, 1, 1), dtype=np.int_).view(ArraySubclass)
res = linalg.eigvalsh(a)
assert_(res.dtype.type is np.float64)
assert_equal((0, 1), res.shape)
# This is just for documentation, it might make sense to change:
assert_(isinstance(res, np.ndarray))
a = np.zeros((0, 0), dtype=np.complex64).view(ArraySubclass)
res = linalg.eigvalsh(a)
assert_(res.dtype.type is np.float32)
assert_equal((0,), res.shape)
# This is just for documentation, it might make sense to change:
assert_(isinstance(res, np.ndarray))
class TestEighCases(HermitianTestCase, HermitianGeneralizedTestCase):
def do(self, a, b, tags):
# note that eigenvalue arrays returned by eig must be sorted since
# their order isn't guaranteed.
ev, evc = linalg.eigh(a)
evalues, evectors = linalg.eig(a)
evalues.sort(axis=-1)
assert_almost_equal(ev, evalues)
assert_allclose(dot_generalized(a, evc),
np.asarray(ev)[..., None, :] * np.asarray(evc),
rtol=get_rtol(ev.dtype))
ev2, evc2 = linalg.eigh(a, 'U')
assert_almost_equal(ev2, evalues)
assert_allclose(dot_generalized(a, evc2),
np.asarray(ev2)[..., None, :] * np.asarray(evc2),
rtol=get_rtol(ev.dtype), err_msg=repr(a))
class TestEigh:
@pytest.mark.parametrize('dtype', [single, double, csingle, cdouble])
def test_types(self, dtype):
x = np.array([[1, 0.5], [0.5, 1]], dtype=dtype)
w, v = np.linalg.eigh(x)
assert_equal(w.dtype, get_real_dtype(dtype))
assert_equal(v.dtype, dtype)
def test_invalid(self):
x = np.array([[1, 0.5], [0.5, 1]], dtype=np.float32)
assert_raises(ValueError, np.linalg.eigh, x, UPLO="lrong")
assert_raises(ValueError, np.linalg.eigh, x, "lower")
assert_raises(ValueError, np.linalg.eigh, x, "upper")
def test_UPLO(self):
Klo = np.array([[0, 0], [1, 0]], dtype=np.double)
Kup = np.array([[0, 1], [0, 0]], dtype=np.double)
tgt = np.array([-1, 1], dtype=np.double)
rtol = get_rtol(np.double)
# Check default is 'L'
w, v = np.linalg.eigh(Klo)
assert_allclose(w, tgt, rtol=rtol)
# Check 'L'
w, v = np.linalg.eigh(Klo, UPLO='L')
assert_allclose(w, tgt, rtol=rtol)
# Check 'l'
w, v = np.linalg.eigh(Klo, UPLO='l')
assert_allclose(w, tgt, rtol=rtol)
# Check 'U'
w, v = np.linalg.eigh(Kup, UPLO='U')
assert_allclose(w, tgt, rtol=rtol)
# Check 'u'
w, v = np.linalg.eigh(Kup, UPLO='u')
assert_allclose(w, tgt, rtol=rtol)
def test_0_size(self):
# Check that all kinds of 0-sized arrays work
class ArraySubclass(np.ndarray):
pass
a = np.zeros((0, 1, 1), dtype=np.int_).view(ArraySubclass)
res, res_v = linalg.eigh(a)
assert_(res_v.dtype.type is np.float64)
assert_(res.dtype.type is np.float64)
assert_equal(a.shape, res_v.shape)
assert_equal((0, 1), res.shape)
# This is just for documentation, it might make sense to change:
assert_(isinstance(a, np.ndarray))
a = np.zeros((0, 0), dtype=np.complex64).view(ArraySubclass)
res, res_v = linalg.eigh(a)
assert_(res_v.dtype.type is np.complex64)
assert_(res.dtype.type is np.float32)
assert_equal(a.shape, res_v.shape)
assert_equal((0,), res.shape)
# This is just for documentation, it might make sense to change:
assert_(isinstance(a, np.ndarray))
class _TestNormBase:
dt = None
dec = None
class _TestNormGeneral(_TestNormBase):
def test_empty(self):
assert_equal(norm([]), 0.0)
assert_equal(norm(array([], dtype=self.dt)), 0.0)
assert_equal(norm(atleast_2d(array([], dtype=self.dt))), 0.0)
def test_vector_return_type(self):
a = np.array([1, 0, 1])
exact_types = np.typecodes['AllInteger']
inexact_types = np.typecodes['AllFloat']
all_types = exact_types + inexact_types
for each_inexact_types in all_types:
at = a.astype(each_inexact_types)
an = norm(at, -np.inf)
assert_(issubclass(an.dtype.type, np.floating))
assert_almost_equal(an, 0.0)
with suppress_warnings() as sup:
sup.filter(RuntimeWarning, "divide by zero encountered")
an = norm(at, -1)
assert_(issubclass(an.dtype.type, np.floating))
assert_almost_equal(an, 0.0)
an = norm(at, 0)
assert_(issubclass(an.dtype.type, np.floating))
assert_almost_equal(an, 2)
an = norm(at, 1)
assert_(issubclass(an.dtype.type, np.floating))
assert_almost_equal(an, 2.0)
an = norm(at, 2)
assert_(issubclass(an.dtype.type, np.floating))
assert_almost_equal(an, an.dtype.type(2.0)**an.dtype.type(1.0/2.0))
an = norm(at, 4)
assert_(issubclass(an.dtype.type, np.floating))
assert_almost_equal(an, an.dtype.type(2.0)**an.dtype.type(1.0/4.0))
an = norm(at, np.inf)
assert_(issubclass(an.dtype.type, np.floating))
assert_almost_equal(an, 1.0)
def test_vector(self):
a = [1, 2, 3, 4]
b = [-1, -2, -3, -4]
c = [-1, 2, -3, 4]
def _test(v):
np.testing.assert_almost_equal(norm(v), 30 ** 0.5,
decimal=self.dec)
np.testing.assert_almost_equal(norm(v, inf), 4.0,
decimal=self.dec)
np.testing.assert_almost_equal(norm(v, -inf), 1.0,
decimal=self.dec)
np.testing.assert_almost_equal(norm(v, 1), 10.0,
decimal=self.dec)
np.testing.assert_almost_equal(norm(v, -1), 12.0 / 25,
decimal=self.dec)
np.testing.assert_almost_equal(norm(v, 2), 30 ** 0.5,
decimal=self.dec)
np.testing.assert_almost_equal(norm(v, -2), ((205. / 144) ** -0.5),
decimal=self.dec)
np.testing.assert_almost_equal(norm(v, 0), 4,
decimal=self.dec)
for v in (a, b, c,):
_test(v)
for v in (array(a, dtype=self.dt), array(b, dtype=self.dt),
array(c, dtype=self.dt)):
_test(v)
def test_axis(self):
# Vector norms.
# Compare the use of `axis` with computing the norm of each row
# or column separately.
A = array([[1, 2, 3], [4, 5, 6]], dtype=self.dt)
for order in [None, -1, 0, 1, 2, 3, np.Inf, -np.Inf]:
expected0 = [norm(A[:, k], ord=order) for k in range(A.shape[1])]
assert_almost_equal(norm(A, ord=order, axis=0), expected0)
expected1 = [norm(A[k, :], ord=order) for k in range(A.shape[0])]
assert_almost_equal(norm(A, ord=order, axis=1), expected1)
# Matrix norms.
B = np.arange(1, 25, dtype=self.dt).reshape(2, 3, 4)
nd = B.ndim
for order in [None, -2, 2, -1, 1, np.Inf, -np.Inf, 'fro']:
for axis in itertools.combinations(range(-nd, nd), 2):
row_axis, col_axis = axis
if row_axis < 0:
row_axis += nd
if col_axis < 0:
col_axis += nd
if row_axis == col_axis:
assert_raises(ValueError, norm, B, ord=order, axis=axis)
else:
n = norm(B, ord=order, axis=axis)
# The logic using k_index only works for nd = 3.
# This has to be changed if nd is increased.
k_index = nd - (row_axis + col_axis)
if row_axis < col_axis:
expected = [norm(B[:].take(k, axis=k_index), ord=order)
for k in range(B.shape[k_index])]
else:
expected = [norm(B[:].take(k, axis=k_index).T, ord=order)
for k in range(B.shape[k_index])]
assert_almost_equal(n, expected)
def test_keepdims(self):
A = np.arange(1, 25, dtype=self.dt).reshape(2, 3, 4)
allclose_err = 'order {0}, axis = {1}'
shape_err = 'Shape mismatch found {0}, expected {1}, order={2}, axis={3}'
# check the order=None, axis=None case
expected = norm(A, ord=None, axis=None)
found = norm(A, ord=None, axis=None, keepdims=True)
assert_allclose(np.squeeze(found), expected,
err_msg=allclose_err.format(None, None))
expected_shape = (1, 1, 1)
assert_(found.shape == expected_shape,
shape_err.format(found.shape, expected_shape, None, None))
# Vector norms.
for order in [None, -1, 0, 1, 2, 3, np.Inf, -np.Inf]:
for k in range(A.ndim):
expected = norm(A, ord=order, axis=k)
found = norm(A, ord=order, axis=k, keepdims=True)
assert_allclose(np.squeeze(found), expected,
err_msg=allclose_err.format(order, k))
expected_shape = list(A.shape)
expected_shape[k] = 1
expected_shape = tuple(expected_shape)
assert_(found.shape == expected_shape,
shape_err.format(found.shape, expected_shape, order, k))
# Matrix norms.
for order in [None, -2, 2, -1, 1, np.Inf, -np.Inf, 'fro', 'nuc']:
for k in itertools.permutations(range(A.ndim), 2):
expected = norm(A, ord=order, axis=k)
found = norm(A, ord=order, axis=k, keepdims=True)
assert_allclose(np.squeeze(found), expected,
err_msg=allclose_err.format(order, k))
expected_shape = list(A.shape)
expected_shape[k[0]] = 1
expected_shape[k[1]] = 1
expected_shape = tuple(expected_shape)
assert_(found.shape == expected_shape,
shape_err.format(found.shape, expected_shape, order, k))
class _TestNorm2D(_TestNormBase):
# Define the part for 2d arrays separately, so we can subclass this
# and run the tests using np.matrix in matrixlib.tests.test_matrix_linalg.
array = np.array
def test_matrix_empty(self):
assert_equal(norm(self.array([[]], dtype=self.dt)), 0.0)
def test_matrix_return_type(self):
a = self.array([[1, 0, 1], [0, 1, 1]])
exact_types = np.typecodes['AllInteger']
# float32, complex64, float64, complex128 types are the only types
# allowed by `linalg`, which performs the matrix operations used
# within `norm`.
inexact_types = 'fdFD'
all_types = exact_types + inexact_types
for each_inexact_types in all_types:
at = a.astype(each_inexact_types)
an = norm(at, -np.inf)
assert_(issubclass(an.dtype.type, np.floating))
assert_almost_equal(an, 2.0)
with suppress_warnings() as sup:
sup.filter(RuntimeWarning, "divide by zero encountered")
an = norm(at, -1)
assert_(issubclass(an.dtype.type, np.floating))
assert_almost_equal(an, 1.0)
an = norm(at, 1)
assert_(issubclass(an.dtype.type, np.floating))
assert_almost_equal(an, 2.0)
an = norm(at, 2)
assert_(issubclass(an.dtype.type, np.floating))
assert_almost_equal(an, 3.0**(1.0/2.0))
an = norm(at, -2)
assert_(issubclass(an.dtype.type, np.floating))
assert_almost_equal(an, 1.0)
an = norm(at, np.inf)
assert_(issubclass(an.dtype.type, np.floating))
assert_almost_equal(an, 2.0)
an = norm(at, 'fro')
assert_(issubclass(an.dtype.type, np.floating))
assert_almost_equal(an, 2.0)
an = norm(at, 'nuc')
assert_(issubclass(an.dtype.type, np.floating))
# Lower bar needed to support low precision floats.
# They end up being off by 1 in the 7th place.
np.testing.assert_almost_equal(an, 2.7320508075688772, decimal=6)
def test_matrix_2x2(self):
A = self.array([[1, 3], [5, 7]], dtype=self.dt)
assert_almost_equal(norm(A), 84 ** 0.5)
assert_almost_equal(norm(A, 'fro'), 84 ** 0.5)
assert_almost_equal(norm(A, 'nuc'), 10.0)
assert_almost_equal(norm(A, inf), 12.0)
assert_almost_equal(norm(A, -inf), 4.0)
assert_almost_equal(norm(A, 1), 10.0)
assert_almost_equal(norm(A, -1), 6.0)
assert_almost_equal(norm(A, 2), 9.1231056256176615)
assert_almost_equal(norm(A, -2), 0.87689437438234041)
assert_raises(ValueError, norm, A, 'nofro')
assert_raises(ValueError, norm, A, -3)
assert_raises(ValueError, norm, A, 0)
def test_matrix_3x3(self):
# This test has been added because the 2x2 example
# happened to have equal nuclear norm and induced 1-norm.
# The 1/10 scaling factor accommodates the absolute tolerance
# used in assert_almost_equal.
A = (1 / 10) * \
self.array([[1, 2, 3], [6, 0, 5], [3, 2, 1]], dtype=self.dt)
assert_almost_equal(norm(A), (1 / 10) * 89 ** 0.5)
assert_almost_equal(norm(A, 'fro'), (1 / 10) * 89 ** 0.5)
assert_almost_equal(norm(A, 'nuc'), 1.3366836911774836)
assert_almost_equal(norm(A, inf), 1.1)
assert_almost_equal(norm(A, -inf), 0.6)
assert_almost_equal(norm(A, 1), 1.0)
assert_almost_equal(norm(A, -1), 0.4)
assert_almost_equal(norm(A, 2), 0.88722940323461277)
assert_almost_equal(norm(A, -2), 0.19456584790481812)
def test_bad_args(self):
# Check that bad arguments raise the appropriate exceptions.
A = self.array([[1, 2, 3], [4, 5, 6]], dtype=self.dt)
B = np.arange(1, 25, dtype=self.dt).reshape(2, 3, 4)
# Using `axis=<integer>` or passing in a 1-D array implies vector
# norms are being computed, so also using `ord='fro'`
# or `ord='nuc'` or any other string raises a ValueError.
assert_raises(ValueError, norm, A, 'fro', 0)
assert_raises(ValueError, norm, A, 'nuc', 0)
assert_raises(ValueError, norm, [3, 4], 'fro', None)
assert_raises(ValueError, norm, [3, 4], 'nuc', None)
assert_raises(ValueError, norm, [3, 4], 'test', None)
# Similarly, norm should raise an exception when ord is any finite
# number other than 1, 2, -1 or -2 when computing matrix norms.
for order in [0, 3]:
assert_raises(ValueError, norm, A, order, None)
assert_raises(ValueError, norm, A, order, (0, 1))
assert_raises(ValueError, norm, B, order, (1, 2))
# Invalid axis
assert_raises(np.AxisError, norm, B, None, 3)
assert_raises(np.AxisError, norm, B, None, (2, 3))
assert_raises(ValueError, norm, B, None, (0, 1, 2))
class _TestNorm(_TestNorm2D, _TestNormGeneral):
pass
class TestNorm_NonSystematic:
def test_longdouble_norm(self):
# Non-regression test: p-norm of longdouble would previously raise
# UnboundLocalError.
x = np.arange(10, dtype=np.longdouble)
old_assert_almost_equal(norm(x, ord=3), 12.65, decimal=2)
def test_intmin(self):
# Non-regression test: p-norm of signed integer would previously do
# float cast and abs in the wrong order.
x = np.array([-2 ** 31], dtype=np.int32)
old_assert_almost_equal(norm(x, ord=3), 2 ** 31, decimal=5)
def test_complex_high_ord(self):
# gh-4156
d = np.empty((2,), dtype=np.clongdouble)
d[0] = 6 + 7j
d[1] = -6 + 7j
res = 11.615898132184
old_assert_almost_equal(np.linalg.norm(d, ord=3), res, decimal=10)
d = d.astype(np.complex128)
old_assert_almost_equal(np.linalg.norm(d, ord=3), res, decimal=9)
d = d.astype(np.complex64)
old_assert_almost_equal(np.linalg.norm(d, ord=3), res, decimal=5)
# Separate definitions so we can use them for matrix tests.
class _TestNormDoubleBase(_TestNormBase):
dt = np.double
dec = 12
class _TestNormSingleBase(_TestNormBase):
dt = np.float32
dec = 6
class _TestNormInt64Base(_TestNormBase):
dt = np.int64
dec = 12
class TestNormDouble(_TestNorm, _TestNormDoubleBase):
pass
class TestNormSingle(_TestNorm, _TestNormSingleBase):
pass
class TestNormInt64(_TestNorm, _TestNormInt64Base):
pass
class TestMatrixRank:
def test_matrix_rank(self):
# Full rank matrix
assert_equal(4, matrix_rank(np.eye(4)))
# rank deficient matrix
I = np.eye(4)
I[-1, -1] = 0.
assert_equal(matrix_rank(I), 3)
# All zeros - zero rank
assert_equal(matrix_rank(np.zeros((4, 4))), 0)
# 1 dimension - rank 1 unless all 0
assert_equal(matrix_rank([1, 0, 0, 0]), 1)
assert_equal(matrix_rank(np.zeros((4,))), 0)
# accepts array-like
assert_equal(matrix_rank([1]), 1)
# greater than 2 dimensions treated as stacked matrices
ms = np.array([I, np.eye(4), np.zeros((4,4))])
assert_equal(matrix_rank(ms), np.array([3, 4, 0]))
# works on scalar
assert_equal(matrix_rank(1), 1)
def test_symmetric_rank(self):
assert_equal(4, matrix_rank(np.eye(4), hermitian=True))
assert_equal(1, matrix_rank(np.ones((4, 4)), hermitian=True))
assert_equal(0, matrix_rank(np.zeros((4, 4)), hermitian=True))
# rank deficient matrix
I = np.eye(4)
I[-1, -1] = 0.
assert_equal(3, matrix_rank(I, hermitian=True))
# manually supplied tolerance
I[-1, -1] = 1e-8
assert_equal(4, matrix_rank(I, hermitian=True, tol=0.99e-8))
assert_equal(3, matrix_rank(I, hermitian=True, tol=1.01e-8))
def test_reduced_rank():
# Test matrices with reduced rank
rng = np.random.RandomState(20120714)
for i in range(100):
# Make a rank deficient matrix
X = rng.normal(size=(40, 10))
X[:, 0] = X[:, 1] + X[:, 2]
# Assert that matrix_rank detected deficiency
assert_equal(matrix_rank(X), 9)
X[:, 3] = X[:, 4] + X[:, 5]
assert_equal(matrix_rank(X), 8)
class TestQR:
# Define the array class here, so run this on matrices elsewhere.
array = np.array
def check_qr(self, a):
# This test expects the argument `a` to be an ndarray or
# a subclass of an ndarray of inexact type.
a_type = type(a)
a_dtype = a.dtype
m, n = a.shape
k = min(m, n)
# mode == 'complete'
q, r = linalg.qr(a, mode='complete')
assert_(q.dtype == a_dtype)
assert_(r.dtype == a_dtype)
assert_(isinstance(q, a_type))
assert_(isinstance(r, a_type))
assert_(q.shape == (m, m))
assert_(r.shape == (m, n))
assert_almost_equal(dot(q, r), a)
assert_almost_equal(dot(q.T.conj(), q), np.eye(m))
assert_almost_equal(np.triu(r), r)
# mode == 'reduced'
q1, r1 = linalg.qr(a, mode='reduced')
assert_(q1.dtype == a_dtype)
assert_(r1.dtype == a_dtype)
assert_(isinstance(q1, a_type))
assert_(isinstance(r1, a_type))
assert_(q1.shape == (m, k))
assert_(r1.shape == (k, n))
assert_almost_equal(dot(q1, r1), a)
assert_almost_equal(dot(q1.T.conj(), q1), np.eye(k))
assert_almost_equal(np.triu(r1), r1)
# mode == 'r'
r2 = linalg.qr(a, mode='r')
assert_(r2.dtype == a_dtype)
assert_(isinstance(r2, a_type))
assert_almost_equal(r2, r1)
@pytest.mark.parametrize(["m", "n"], [
(3, 0),
(0, 3),
(0, 0)
])
def test_qr_empty(self, m, n):
k = min(m, n)
a = np.empty((m, n))
self.check_qr(a)
h, tau = np.linalg.qr(a, mode='raw')
assert_equal(h.dtype, np.double)
assert_equal(tau.dtype, np.double)
assert_equal(h.shape, (n, m))
assert_equal(tau.shape, (k,))
def test_mode_raw(self):
# The factorization is not unique and varies between libraries,
# so it is not possible to check against known values. Functional
# testing is a possibility, but awaits the exposure of more
# of the functions in lapack_lite. Consequently, this test is
# very limited in scope. Note that the results are in FORTRAN
# order, hence the h arrays are transposed.
a = self.array([[1, 2], [3, 4], [5, 6]], dtype=np.double)
# Test double
h, tau = linalg.qr(a, mode='raw')
assert_(h.dtype == np.double)
assert_(tau.dtype == np.double)
assert_(h.shape == (2, 3))
assert_(tau.shape == (2,))
h, tau = linalg.qr(a.T, mode='raw')
assert_(h.dtype == np.double)
assert_(tau.dtype == np.double)
assert_(h.shape == (3, 2))
assert_(tau.shape == (2,))
def test_mode_all_but_economic(self):
a = self.array([[1, 2], [3, 4]])
b = self.array([[1, 2], [3, 4], [5, 6]])
for dt in "fd":
m1 = a.astype(dt)
m2 = b.astype(dt)
self.check_qr(m1)
self.check_qr(m2)
self.check_qr(m2.T)
for dt in "fd":
m1 = 1 + 1j * a.astype(dt)
m2 = 1 + 1j * b.astype(dt)
self.check_qr(m1)
self.check_qr(m2)
self.check_qr(m2.T)
class TestCholesky:
# TODO: are there no other tests for cholesky?
def test_basic_property(self):
# Check A = L L^H
shapes = [(1, 1), (2, 2), (3, 3), (50, 50), (3, 10, 10)]
dtypes = (np.float32, np.float64, np.complex64, np.complex128)
for shape, dtype in itertools.product(shapes, dtypes):
np.random.seed(1)
a = np.random.randn(*shape)
if np.issubdtype(dtype, np.complexfloating):
a = a + 1j*np.random.randn(*shape)
t = list(range(len(shape)))
t[-2:] = -1, -2
a = np.matmul(a.transpose(t).conj(), a)
a = np.asarray(a, dtype=dtype)
c = np.linalg.cholesky(a)
b = np.matmul(c, c.transpose(t).conj())
assert_allclose(b, a,
err_msg=f'{shape} {dtype}\n{a}\n{c}',
atol=500 * a.shape[0] * np.finfo(dtype).eps)
def test_0_size(self):
class ArraySubclass(np.ndarray):
pass
a = np.zeros((0, 1, 1), dtype=np.int_).view(ArraySubclass)
res = linalg.cholesky(a)
assert_equal(a.shape, res.shape)
assert_(res.dtype.type is np.float64)
# for documentation purpose:
assert_(isinstance(res, np.ndarray))
a = np.zeros((1, 0, 0), dtype=np.complex64).view(ArraySubclass)
res = linalg.cholesky(a)
assert_equal(a.shape, res.shape)
assert_(res.dtype.type is np.complex64)
assert_(isinstance(res, np.ndarray))
def test_byteorder_check():
# Byte order check should pass for native order
if sys.byteorder == 'little':
native = '<'
else:
native = '>'
for dtt in (np.float32, np.float64):
arr = np.eye(4, dtype=dtt)
n_arr = arr.newbyteorder(native)
sw_arr = arr.newbyteorder('S').byteswap()
assert_equal(arr.dtype.byteorder, '=')
for routine in (linalg.inv, linalg.det, linalg.pinv):
# Normal call
res = routine(arr)
# Native but not '='
assert_array_equal(res, routine(n_arr))
# Swapped
assert_array_equal(res, routine(sw_arr))
def test_generalized_raise_multiloop():
# It should raise an error even if the error doesn't occur in the
# last iteration of the ufunc inner loop
invertible = np.array([[1, 2], [3, 4]])
non_invertible = np.array([[1, 1], [1, 1]])
x = np.zeros([4, 4, 2, 2])[1::2]
x[...] = invertible
x[0, 0] = non_invertible
assert_raises(np.linalg.LinAlgError, np.linalg.inv, x)
def test_xerbla_override():
# Check that our xerbla has been successfully linked in. If it is not,
# the default xerbla routine is called, which prints a message to stdout
# and may, or may not, abort the process depending on the LAPACK package.
XERBLA_OK = 255
try:
pid = os.fork()
except (OSError, AttributeError):
# fork failed, or not running on POSIX
pytest.skip("Not POSIX or fork failed.")
if pid == 0:
# child; close i/o file handles
os.close(1)
os.close(0)
# Avoid producing core files.
import resource
resource.setrlimit(resource.RLIMIT_CORE, (0, 0))
# These calls may abort.
try:
np.linalg.lapack_lite.xerbla()
except ValueError:
pass
except Exception:
os._exit(os.EX_CONFIG)
try:
a = np.array([[1.]])
np.linalg.lapack_lite.dorgqr(
1, 1, 1, a,
0, # <- invalid value
a, a, 0, 0)
except ValueError as e:
if "DORGQR parameter number 5" in str(e):
# success, reuse error code to mark success as
# FORTRAN STOP returns as success.
os._exit(XERBLA_OK)
# Did not abort, but our xerbla was not linked in.
os._exit(os.EX_CONFIG)
else:
# parent
pid, status = os.wait()
if os.WEXITSTATUS(status) != XERBLA_OK:
pytest.skip('Numpy xerbla not linked in.')
@pytest.mark.slow
def test_sdot_bug_8577():
# Regression test that loading certain other libraries does not
# result to wrong results in float32 linear algebra.
#
# There's a bug gh-8577 on OSX that can trigger this, and perhaps
# there are also other situations in which it occurs.
#
# Do the check in a separate process.
bad_libs = ['PyQt5.QtWidgets', 'IPython']
template = textwrap.dedent("""
import sys
{before}
try:
import {bad_lib}
except ImportError:
sys.exit(0)
{after}
x = np.ones(2, dtype=np.float32)
sys.exit(0 if np.allclose(x.dot(x), 2.0) else 1)
""")
for bad_lib in bad_libs:
code = template.format(before="import numpy as np", after="",
bad_lib=bad_lib)
subprocess.check_call([sys.executable, "-c", code])
# Swapped import order
code = template.format(after="import numpy as np", before="",
bad_lib=bad_lib)
subprocess.check_call([sys.executable, "-c", code])
class TestMultiDot:
def test_basic_function_with_three_arguments(self):
# multi_dot with three arguments uses a fast hand coded algorithm to
# determine the optimal order. Therefore test it separately.
A = np.random.random((6, 2))
B = np.random.random((2, 6))
C = np.random.random((6, 2))
assert_almost_equal(multi_dot([A, B, C]), A.dot(B).dot(C))
assert_almost_equal(multi_dot([A, B, C]), np.dot(A, np.dot(B, C)))
def test_basic_function_with_two_arguments(self):
# separate code path with two arguments
A = np.random.random((6, 2))
B = np.random.random((2, 6))
assert_almost_equal(multi_dot([A, B]), A.dot(B))
assert_almost_equal(multi_dot([A, B]), np.dot(A, B))
def test_basic_function_with_dynamic_programing_optimization(self):
# multi_dot with four or more arguments uses the dynamic programing
# optimization and therefore deserve a separate
A = np.random.random((6, 2))
B = np.random.random((2, 6))
C = np.random.random((6, 2))
D = np.random.random((2, 1))
assert_almost_equal(multi_dot([A, B, C, D]), A.dot(B).dot(C).dot(D))
def test_vector_as_first_argument(self):
# The first argument can be 1-D
A1d = np.random.random(2) # 1-D
B = np.random.random((2, 6))
C = np.random.random((6, 2))
D = np.random.random((2, 2))
# the result should be 1-D
assert_equal(multi_dot([A1d, B, C, D]).shape, (2,))
def test_vector_as_last_argument(self):
# The last argument can be 1-D
A = np.random.random((6, 2))
B = np.random.random((2, 6))
C = np.random.random((6, 2))
D1d = np.random.random(2) # 1-D
# the result should be 1-D
assert_equal(multi_dot([A, B, C, D1d]).shape, (6,))
def test_vector_as_first_and_last_argument(self):
# The first and last arguments can be 1-D
A1d = np.random.random(2) # 1-D
B = np.random.random((2, 6))
C = np.random.random((6, 2))
D1d = np.random.random(2) # 1-D
# the result should be a scalar
assert_equal(multi_dot([A1d, B, C, D1d]).shape, ())
def test_three_arguments_and_out(self):
# multi_dot with three arguments uses a fast hand coded algorithm to
# determine the optimal order. Therefore test it separately.
A = np.random.random((6, 2))
B = np.random.random((2, 6))
C = np.random.random((6, 2))
out = np.zeros((6, 2))
ret = multi_dot([A, B, C], out=out)
assert out is ret
assert_almost_equal(out, A.dot(B).dot(C))
assert_almost_equal(out, np.dot(A, np.dot(B, C)))
def test_two_arguments_and_out(self):
# separate code path with two arguments
A = np.random.random((6, 2))
B = np.random.random((2, 6))
out = np.zeros((6, 6))
ret = multi_dot([A, B], out=out)
assert out is ret
assert_almost_equal(out, A.dot(B))
assert_almost_equal(out, np.dot(A, B))
def test_dynamic_programing_optimization_and_out(self):
# multi_dot with four or more arguments uses the dynamic programing
# optimization and therefore deserve a separate test
A = np.random.random((6, 2))
B = np.random.random((2, 6))
C = np.random.random((6, 2))
D = np.random.random((2, 1))
out = np.zeros((6, 1))
ret = multi_dot([A, B, C, D], out=out)
assert out is ret
assert_almost_equal(out, A.dot(B).dot(C).dot(D))
def test_dynamic_programming_logic(self):
# Test for the dynamic programming part
# This test is directly taken from Cormen page 376.
arrays = [np.random.random((30, 35)),
np.random.random((35, 15)),
np.random.random((15, 5)),
np.random.random((5, 10)),
np.random.random((10, 20)),
np.random.random((20, 25))]
m_expected = np.array([[0., 15750., 7875., 9375., 11875., 15125.],
[0., 0., 2625., 4375., 7125., 10500.],
[0., 0., 0., 750., 2500., 5375.],
[0., 0., 0., 0., 1000., 3500.],
[0., 0., 0., 0., 0., 5000.],
[0., 0., 0., 0., 0., 0.]])
s_expected = np.array([[0, 1, 1, 3, 3, 3],
[0, 0, 2, 3, 3, 3],
[0, 0, 0, 3, 3, 3],
[0, 0, 0, 0, 4, 5],
[0, 0, 0, 0, 0, 5],
[0, 0, 0, 0, 0, 0]], dtype=int)
s_expected -= 1 # Cormen uses 1-based index, python does not.
s, m = _multi_dot_matrix_chain_order(arrays, return_costs=True)
# Only the upper triangular part (without the diagonal) is interesting.
assert_almost_equal(np.triu(s[:-1, 1:]),
np.triu(s_expected[:-1, 1:]))
assert_almost_equal(np.triu(m), np.triu(m_expected))
def test_too_few_input_arrays(self):
assert_raises(ValueError, multi_dot, [])
assert_raises(ValueError, multi_dot, [np.random.random((3, 3))])
class TestTensorinv:
@pytest.mark.parametrize("arr, ind", [
(np.ones((4, 6, 8, 2)), 2),
(np.ones((3, 3, 2)), 1),
])
def test_non_square_handling(self, arr, ind):
with assert_raises(LinAlgError):
linalg.tensorinv(arr, ind=ind)
@pytest.mark.parametrize("shape, ind", [
# examples from docstring
((4, 6, 8, 3), 2),
((24, 8, 3), 1),
])
def test_tensorinv_shape(self, shape, ind):
a = np.eye(24)
a.shape = shape
ainv = linalg.tensorinv(a=a, ind=ind)
expected = a.shape[ind:] + a.shape[:ind]
actual = ainv.shape
assert_equal(actual, expected)
@pytest.mark.parametrize("ind", [
0, -2,
])
def test_tensorinv_ind_limit(self, ind):
a = np.eye(24)
a.shape = (4, 6, 8, 3)
with assert_raises(ValueError):
linalg.tensorinv(a=a, ind=ind)
def test_tensorinv_result(self):
# mimic a docstring example
a = np.eye(24)
a.shape = (24, 8, 3)
ainv = linalg.tensorinv(a, ind=1)
b = np.ones(24)
assert_allclose(np.tensordot(ainv, b, 1), np.linalg.tensorsolve(a, b))
def test_unsupported_commontype():
# linalg gracefully handles unsupported type
arr = np.array([[1, -2], [2, 5]], dtype='float16')
with assert_raises_regex(TypeError, "unsupported in linalg"):
linalg.cholesky(arr)
@pytest.mark.slow
@pytest.mark.xfail(not HAS_LAPACK64, run=False,
reason="Numpy not compiled with 64-bit BLAS/LAPACK")
@requires_memory(free_bytes=16e9)
def test_blas64_dot():
n = 2**32
a = np.zeros([1, n], dtype=np.float32)
b = np.ones([1, 1], dtype=np.float32)
a[0,-1] = 1
c = np.dot(b, a)
assert_equal(c[0,-1], 1)
@pytest.mark.xfail(not HAS_LAPACK64,
reason="Numpy not compiled with 64-bit BLAS/LAPACK")
def test_blas64_geqrf_lwork_smoketest():
# Smoke test LAPACK geqrf lwork call with 64-bit integers
dtype = np.float64
lapack_routine = np.linalg.lapack_lite.dgeqrf
m = 2**32 + 1
n = 2**32 + 1
lda = m
# Dummy arrays, not referenced by the lapack routine, so don't
# need to be of the right size
a = np.zeros([1, 1], dtype=dtype)
work = np.zeros([1], dtype=dtype)
tau = np.zeros([1], dtype=dtype)
# Size query
results = lapack_routine(m, n, a, lda, tau, work, -1, 0)
assert_equal(results['info'], 0)
assert_equal(results['m'], m)
assert_equal(results['n'], m)
# Should result to an integer of a reasonable size
lwork = int(work.item())
assert_(2**32 < lwork < 2**42)
|
bsd-3-clause
|
[
624,
1379,
3423,
367,
16727,
859,
199,
199,
624,
199,
646,
747,
199,
646,
984,
199,
646,
7975,
199,
646,
5190,
199,
646,
13390,
199,
646,
3873,
199,
646,
4613,
199,
199,
646,
2680,
465,
980,
199,
504,
2680,
492,
1625,
12,
2849,
12,
4270,
12,
286,
4780,
12,
286,
3157,
12,
6308,
12,
8503,
12,
2530,
3703,
199,
504,
2680,
492,
21699,
12,
737,
11790,
63,
18,
68,
12,
10739,
12,
24144,
199,
504,
2680,
492,
16727,
199,
504,
2680,
14,
10096,
492,
3634,
63,
5652,
12,
6316,
12,
3634,
63,
4648,
12,
3510,
63,
3287,
12,
29730,
28846,
547,
199,
504,
2680,
14,
10096,
14,
10096,
492,
485,
3029,
63,
3287,
63,
3642,
63,
4429,
63,
1648,
199,
504,
2680,
14,
4776,
492,
334,
272,
702,
3131,
702,
63,
1452,
12,
702,
63,
3536,
12,
702,
63,
1144,
63,
1452,
12,
272,
702,
63,
4398,
63,
1452,
12,
702,
63,
7520,
12,
15678,
63,
5451,
12,
272,
702,
63,
3536,
63,
3821,
12,
7509,
63,
44,
1282,
3099,
772,
12,
272,
776,
199,
504,
2680,
14,
4776,
423,
4239,
14,
1208,
492,
5074,
63,
4844,
421,
199,
318,
12137,
63,
6083,
8,
548,
12,
315,
7822,
272,
327,
2104,
6800,
5516,
1324,
12,
4154,
1072,
1077,
1172,
314,
2011,
5516,
272,
327,
334,
2865,
13,
8237,
1324,
7545,
6702,
370,
6800,
680,
272,
372,
730,
8,
548,
9,
365,
334,
466,
8,
262,
4602,
340,
1228,
8,
262,
3131,
980,
14,
8237,
9,
586,
587,
980,
14,
8237,
9,
421,
199,
1753,
63,
479,
63,
4398,
63,
1452,
275,
702,
63,
4398,
63,
1452,
421,
199,
318,
702,
63,
4398,
63,
1452,
8,
65,
12,
330,
12,
2849,
63,
6355,
29,
22,
12,
4270,
63,
6355,
29,
713,
12,
1011,
829,
304,
272,
340,
24144,
8,
65,
680,
2271,
14,
466,
315,
334,
4780,
12,
286,
4780,
304,
267,
6107,
275,
2849,
63,
6355,
272,
587,
26,
267,
6107,
275,
4270,
63,
6355,
272,
2269,
63,
479,
63,
4398,
63,
1452,
8,
65,
12,
330,
12,
6107,
29,
6355,
12,
1011,
829,
9,
421,
199,
318,
664,
63,
3093,
63,
2271,
8,
2271,
304,
272,
372,
469,
4780,
26,
2849,
12,
4270,
26,
4270,
12,
288,
286,
4780,
26,
2849,
12,
286,
3157,
26,
4270,
22857,
2271,
61,
421,
199,
318,
664,
63,
5254,
63,
2271,
8,
2271,
304,
272,
372,
469,
4780,
26,
286,
4780,
12,
4270,
26,
286,
3157,
12,
288,
286,
4780,
26,
286,
4780,
12,
286,
3157,
26,
286,
3157,
22857,
2271,
61,
421,
199,
318,
664,
63,
23565,
8,
2271,
304,
272,
327,
29826,
282,
5048,
10561,
272,
340,
2152,
315,
334,
4780,
12,
286,
4780,
304,
267,
372,
413,
69,
13,
21,
272,
587,
26,
267,
372,
413,
69,
13,
845,
421,
199,
3,
1202,
370,
7737,
269,
794,
2295,
199,
452,
63,
2969,
275,
469,
523,
283,
9646,
297,
283,
2865,
9646,
297,
283,
2523,
26649,
297,
221,
327,
16108,
13914,
523,
283,
10706,
1759,
297,
283,
890,
13,
16,
297,
283,
816,
770,
7,
327,
2716,
32113,
199,
93,
421,
199,
533,
491,
1582,
71,
1538,
26,
272,
347,
636,
826,
721,
277,
12,
536,
12,
282,
12,
330,
12,
3762,
29,
409,
5109,
267,
408,
267,
437,
8844,
402,
2368,
370,
506,
3032,
370,
282,
511,
1930,
12,
543,
376,
21119,
267,
536,
12,
314,
15163,
282,
436,
330,
12,
436,
282,
663,
402,
3762,
370,
2457,
314,
2295,
267,
408,
267,
702,
2531,
6074,
8,
354,
12,
620,
430,
267,
291,
14,
354,
275,
536,
267,
291,
14,
65,
275,
282,
267,
291,
14,
66,
275,
330,
267,
291,
14,
2969,
275,
9522,
8,
2969,
9,
221,
327,
7981,
5709,
3762,
339,
347,
1104,
8,
277,
12,
886,
304,
267,
408,
267,
3378,
314,
805,
658,
1117,
64,
641,
642,
511,
1930,
12,
6544,
316,
2368,
267,
408,
267,
886,
8,
277,
14,
65,
12,
291,
14,
66,
12,
3762,
29,
277,
14,
2969,
9,
339,
347,
636,
2722,
721,
277,
304,
267,
372,
289,
7601,
44,
1582,
71,
1538,
26,
469,
277,
14,
354,
93,
3524,
421,
199,
318,
4838,
63,
1450,
8,
1450,
12,
5560,
304,
272,
408,
272,
2654,
314,
1627,
1947,
334,
65,
1059,
9,
370,
1924,
402,
314,
5560,
334,
65,
769,
402,
491,
1582,
71,
1538,
272,
2251,
9,
272,
408,
272,
702,
1947,
315,
1006,
63,
2969,
12,
298,
3364,
1947,
2,
272,
367,
1930,
315,
5560,
26,
267,
1930,
14,
2969,
275,
1930,
14,
2969,
1204,
469,
1450,
93,
272,
372,
5560,
421,
199,
3,
199,
3,
3523,
511,
5560,
199,
3,
199,
199,
1590,
14,
2355,
14,
5176,
8,
4321,
9,
199,
199,
9777,
654,
275,
942,
199,
199,
3,
12386,
511,
5560,
199,
9777,
654,
847,
4838,
63,
1450,
360,
9646,
297,
359,
272,
491,
1582,
71,
1538,
480,
4780,
401,
2049,
1625,
4038,
17,
2020,
499,
8333,
359,
19,
2020,
841,
24245,
2152,
29,
4780,
395,
2049,
1625,
779,
18,
2020,
413,
8333,
2152,
29,
4780,
1826,
272,
491,
1582,
71,
1538,
480,
3157,
401,
2049,
1625,
4038,
17,
2020,
499,
8333,
359,
19,
2020,
841,
24245,
2152,
29,
3157,
395,
2049,
1625,
779,
18,
2020,
413,
8333,
2152,
29,
3157,
1826,
272,
491,
1582,
71,
1538,
480,
3157,
63,
18,
401,
2049,
1625,
4038,
17,
2020,
499,
8333,
359,
19,
2020,
841,
24245,
2152,
29,
3157,
395,
2049,
1625,
4038,
18,
2020,
413,
2020,
841,
8333,
359,
19,
2020,
841,
2020,
1227,
24245,
2152,
29,
3157,
1826,
272,
491,
1582,
71,
1538,
480,
67,
4780,
401,
2049,
1625,
4038,
17,
14,
435,
499,
74,
12,
499,
435,
650,
74,
467,
359,
19,
435,
841,
74,
12,
841,
435,
959,
74,
2365,
2152,
29,
67,
4780,
395,
2049,
1625,
779,
18,
14,
435,
413,
74,
12,
413,
14,
435,
499,
74,
467,
2152,
29,
67,
4780,
1826,
272,
491,
1582,
71,
1538,
480,
67,
3157,
401,
2049,
1625,
4038,
17,
14,
435,
499,
74,
12,
499,
435,
650,
74,
467,
359,
19,
435,
841,
74,
12,
841,
435,
959,
74,
2365,
2152,
29,
67,
3157,
395,
2049,
1625,
779,
18,
14,
435,
413,
74,
12,
413,
14,
435,
499,
74,
467
] |
[
1379,
3423,
367,
16727,
859,
199,
199,
624,
199,
646,
747,
199,
646,
984,
199,
646,
7975,
199,
646,
5190,
199,
646,
13390,
199,
646,
3873,
199,
646,
4613,
199,
199,
646,
2680,
465,
980,
199,
504,
2680,
492,
1625,
12,
2849,
12,
4270,
12,
286,
4780,
12,
286,
3157,
12,
6308,
12,
8503,
12,
2530,
3703,
199,
504,
2680,
492,
21699,
12,
737,
11790,
63,
18,
68,
12,
10739,
12,
24144,
199,
504,
2680,
492,
16727,
199,
504,
2680,
14,
10096,
492,
3634,
63,
5652,
12,
6316,
12,
3634,
63,
4648,
12,
3510,
63,
3287,
12,
29730,
28846,
547,
199,
504,
2680,
14,
10096,
14,
10096,
492,
485,
3029,
63,
3287,
63,
3642,
63,
4429,
63,
1648,
199,
504,
2680,
14,
4776,
492,
334,
272,
702,
3131,
702,
63,
1452,
12,
702,
63,
3536,
12,
702,
63,
1144,
63,
1452,
12,
272,
702,
63,
4398,
63,
1452,
12,
702,
63,
7520,
12,
15678,
63,
5451,
12,
272,
702,
63,
3536,
63,
3821,
12,
7509,
63,
44,
1282,
3099,
772,
12,
272,
776,
199,
504,
2680,
14,
4776,
423,
4239,
14,
1208,
492,
5074,
63,
4844,
421,
199,
318,
12137,
63,
6083,
8,
548,
12,
315,
7822,
272,
327,
2104,
6800,
5516,
1324,
12,
4154,
1072,
1077,
1172,
314,
2011,
5516,
272,
327,
334,
2865,
13,
8237,
1324,
7545,
6702,
370,
6800,
680,
272,
372,
730,
8,
548,
9,
365,
334,
466,
8,
262,
4602,
340,
1228,
8,
262,
3131,
980,
14,
8237,
9,
586,
587,
980,
14,
8237,
9,
421,
199,
1753,
63,
479,
63,
4398,
63,
1452,
275,
702,
63,
4398,
63,
1452,
421,
199,
318,
702,
63,
4398,
63,
1452,
8,
65,
12,
330,
12,
2849,
63,
6355,
29,
22,
12,
4270,
63,
6355,
29,
713,
12,
1011,
829,
304,
272,
340,
24144,
8,
65,
680,
2271,
14,
466,
315,
334,
4780,
12,
286,
4780,
304,
267,
6107,
275,
2849,
63,
6355,
272,
587,
26,
267,
6107,
275,
4270,
63,
6355,
272,
2269,
63,
479,
63,
4398,
63,
1452,
8,
65,
12,
330,
12,
6107,
29,
6355,
12,
1011,
829,
9,
421,
199,
318,
664,
63,
3093,
63,
2271,
8,
2271,
304,
272,
372,
469,
4780,
26,
2849,
12,
4270,
26,
4270,
12,
288,
286,
4780,
26,
2849,
12,
286,
3157,
26,
4270,
22857,
2271,
61,
421,
199,
318,
664,
63,
5254,
63,
2271,
8,
2271,
304,
272,
372,
469,
4780,
26,
286,
4780,
12,
4270,
26,
286,
3157,
12,
288,
286,
4780,
26,
286,
4780,
12,
286,
3157,
26,
286,
3157,
22857,
2271,
61,
421,
199,
318,
664,
63,
23565,
8,
2271,
304,
272,
327,
29826,
282,
5048,
10561,
272,
340,
2152,
315,
334,
4780,
12,
286,
4780,
304,
267,
372,
413,
69,
13,
21,
272,
587,
26,
267,
372,
413,
69,
13,
845,
421,
199,
3,
1202,
370,
7737,
269,
794,
2295,
199,
452,
63,
2969,
275,
469,
523,
283,
9646,
297,
283,
2865,
9646,
297,
283,
2523,
26649,
297,
221,
327,
16108,
13914,
523,
283,
10706,
1759,
297,
283,
890,
13,
16,
297,
283,
816,
770,
7,
327,
2716,
32113,
199,
93,
421,
199,
533,
491,
1582,
71,
1538,
26,
272,
347,
636,
826,
721,
277,
12,
536,
12,
282,
12,
330,
12,
3762,
29,
409,
5109,
267,
408,
267,
437,
8844,
402,
2368,
370,
506,
3032,
370,
282,
511,
1930,
12,
543,
376,
21119,
267,
536,
12,
314,
15163,
282,
436,
330,
12,
436,
282,
663,
402,
3762,
370,
2457,
314,
2295,
267,
408,
267,
702,
2531,
6074,
8,
354,
12,
620,
430,
267,
291,
14,
354,
275,
536,
267,
291,
14,
65,
275,
282,
267,
291,
14,
66,
275,
330,
267,
291,
14,
2969,
275,
9522,
8,
2969,
9,
221,
327,
7981,
5709,
3762,
339,
347,
1104,
8,
277,
12,
886,
304,
267,
408,
267,
3378,
314,
805,
658,
1117,
64,
641,
642,
511,
1930,
12,
6544,
316,
2368,
267,
408,
267,
886,
8,
277,
14,
65,
12,
291,
14,
66,
12,
3762,
29,
277,
14,
2969,
9,
339,
347,
636,
2722,
721,
277,
304,
267,
372,
289,
7601,
44,
1582,
71,
1538,
26,
469,
277,
14,
354,
93,
3524,
421,
199,
318,
4838,
63,
1450,
8,
1450,
12,
5560,
304,
272,
408,
272,
2654,
314,
1627,
1947,
334,
65,
1059,
9,
370,
1924,
402,
314,
5560,
334,
65,
769,
402,
491,
1582,
71,
1538,
272,
2251,
9,
272,
408,
272,
702,
1947,
315,
1006,
63,
2969,
12,
298,
3364,
1947,
2,
272,
367,
1930,
315,
5560,
26,
267,
1930,
14,
2969,
275,
1930,
14,
2969,
1204,
469,
1450,
93,
272,
372,
5560,
421,
199,
3,
199,
3,
3523,
511,
5560,
199,
3,
199,
199,
1590,
14,
2355,
14,
5176,
8,
4321,
9,
199,
199,
9777,
654,
275,
942,
199,
199,
3,
12386,
511,
5560,
199,
9777,
654,
847,
4838,
63,
1450,
360,
9646,
297,
359,
272,
491,
1582,
71,
1538,
480,
4780,
401,
2049,
1625,
4038,
17,
2020,
499,
8333,
359,
19,
2020,
841,
24245,
2152,
29,
4780,
395,
2049,
1625,
779,
18,
2020,
413,
8333,
2152,
29,
4780,
1826,
272,
491,
1582,
71,
1538,
480,
3157,
401,
2049,
1625,
4038,
17,
2020,
499,
8333,
359,
19,
2020,
841,
24245,
2152,
29,
3157,
395,
2049,
1625,
779,
18,
2020,
413,
8333,
2152,
29,
3157,
1826,
272,
491,
1582,
71,
1538,
480,
3157,
63,
18,
401,
2049,
1625,
4038,
17,
2020,
499,
8333,
359,
19,
2020,
841,
24245,
2152,
29,
3157,
395,
2049,
1625,
4038,
18,
2020,
413,
2020,
841,
8333,
359,
19,
2020,
841,
2020,
1227,
24245,
2152,
29,
3157,
1826,
272,
491,
1582,
71,
1538,
480,
67,
4780,
401,
2049,
1625,
4038,
17,
14,
435,
499,
74,
12,
499,
435,
650,
74,
467,
359,
19,
435,
841,
74,
12,
841,
435,
959,
74,
2365,
2152,
29,
67,
4780,
395,
2049,
1625,
779,
18,
14,
435,
413,
74,
12,
413,
14,
435,
499,
74,
467,
2152,
29,
67,
4780,
1826,
272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,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
mrchristine/spark-examples-dbc
|
src/main/python/pagerank.py
|
5
|
3067
|
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
"""
This is an example implementation of PageRank. For more conventional use,
Please refer to PageRank implementation provided by graphx
"""
from __future__ import print_function
import re
import sys
from operator import add
from pyspark.sql import SparkSession
def computeContribs(urls, rank):
"""Calculates URL contributions to the rank of other URLs."""
num_urls = len(urls)
for url in urls:
yield (url, rank / num_urls)
def parseNeighbors(urls):
"""Parses a urls pair string into urls pair."""
parts = re.split(r'\s+', urls)
return parts[0], parts[1]
if __name__ == "__main__":
if len(sys.argv) != 3:
print("Usage: pagerank <file> <iterations>", file=sys.stderr)
exit(-1)
print("""WARN: This is a naive implementation of PageRank and is
given as an example! Please refer to PageRank implementation provided by graphx""",
file=sys.stderr)
# Initialize the spark context.
spark = SparkSession\
.builder\
.appName("PythonPageRank")\
.getOrCreate()
# Loads in input file. It should be in format of:
# URL neighbor URL
# URL neighbor URL
# URL neighbor URL
# ...
lines = spark.read.text(sys.argv[1]).rdd.map(lambda r: r[0])
# Loads all URLs from input file and initialize their neighbors.
links = lines.map(lambda urls: parseNeighbors(urls)).distinct().groupByKey().cache()
# Loads all URLs with other URL(s) link to from input file and initialize ranks of them to one.
ranks = links.map(lambda url_neighbors: (url_neighbors[0], 1.0))
# Calculates and updates URL ranks continuously using PageRank algorithm.
for iteration in range(int(sys.argv[2])):
# Calculates URL contributions to the rank of other URLs.
contribs = links.join(ranks).flatMap(
lambda url_urls_rank: computeContribs(url_urls_rank[1][0], url_urls_rank[1][1]))
# Re-calculates URL ranks based on neighbor contributions.
ranks = contribs.reduceByKey(add).mapValues(lambda rank: rank * 0.85 + 0.15)
# Collects all URL ranks and dump them to console.
for (link, rank) in ranks.collect():
print("%s has rank: %s." % (link, rank))
spark.stop()
|
apache-2.0
|
[
3,
199,
3,
3909,
370,
314,
3668,
2290,
2752,
334,
14950,
9,
1334,
1373,
503,
1655,
199,
3,
11615,
4190,
14024,
14,
221,
1666,
314,
12840,
570,
1854,
543,
199,
3,
642,
1736,
367,
4722,
2556,
12602,
4248,
12715,
14,
199,
3,
710,
14857,
12378,
642,
570,
370,
2047,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
199,
3,
334,
1589,
298,
3761,
3547,
1265,
1443,
440,
675,
642,
570,
871,
315,
4151,
543,
199,
3,
314,
844,
14,
221,
2047,
1443,
3332,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
259,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
199,
3,
2428,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
199,
3,
1666,
314,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
199,
3,
4204,
1334,
314,
844,
14,
199,
3,
199,
199,
624,
199,
2765,
365,
376,
2893,
4514,
402,
10331,
19486,
14,
2104,
1655,
16129,
279,
675,
12,
199,
8254,
10618,
370,
10331,
19486,
4514,
2741,
701,
3343,
88,
199,
624,
199,
504,
636,
2443,
363,
492,
870,
63,
1593,
199,
199,
646,
295,
199,
646,
984,
199,
504,
4182,
492,
1050,
199,
199,
504,
15847,
14,
3009,
492,
13932,
4434,
421,
199,
318,
4526,
714,
19577,
8,
3603,
12,
6915,
304,
272,
408,
13862,
2335,
2851,
406,
26675,
370,
314,
6915,
402,
1163,
10867,
1041,
272,
1967,
63,
3603,
275,
822,
8,
3603,
9,
272,
367,
1166,
315,
8187,
26,
267,
1995,
334,
633,
12,
6915,
1182,
1967,
63,
3603,
9,
421,
199,
318,
2198,
20011,
8,
3603,
304,
272,
408,
23400,
282,
8187,
4092,
1059,
1901,
8187,
4092,
1041,
272,
4184,
275,
295,
14,
1294,
8,
82,
1154,
83,
7386,
8187,
9,
272,
372,
4184,
59,
16,
467,
4184,
59,
17,
61,
421,
199,
692,
636,
354,
363,
508,
4396,
973,
5727,
272,
340,
822,
8,
1274,
14,
3020,
9,
1137,
650,
26,
267,
870,
480,
7692,
26,
26581,
3580,
665,
493,
30,
665,
13570,
7166,
570,
29,
1274,
14,
3083,
9,
267,
4458,
2801,
17,
9,
339,
870,
4852,
17449,
26,
961,
365,
282,
19995,
4514,
402,
10331,
19486,
436,
365,
881,
1627,
465,
376,
2893,
1,
7754,
10618,
370,
10331,
19486,
4514,
2741,
701,
3343,
88,
7208,
881,
570,
29,
1274,
14,
3083,
9,
339,
327,
11578,
314,
15442,
1067,
14,
272,
15442,
275,
13932,
4434,
60,
267,
1275,
5649,
60,
267,
1275,
571,
985,
480,
4718,
3276,
19486,
27681,
267,
1275,
30457,
2499,
342,
339,
327,
30367,
315,
1324,
570,
14,
2779,
1077,
506,
315,
1475,
402,
26,
272,
327,
258,
2851,
260,
15503,
2851,
272,
327,
258,
2851,
260,
15503,
2851,
272,
327,
258,
2851,
260,
15503,
2851,
272,
327,
258,
2263,
272,
2385,
275,
15442,
14,
739,
14,
505,
8,
1274,
14,
3020,
59,
17,
6575,
20533,
14,
1130,
8,
2734,
519,
26,
519,
59,
16,
566,
339,
327,
30367,
1006,
10867,
687,
1324,
570,
436,
8265,
3932,
15845,
14,
272,
6220,
275,
2385,
14,
1130,
8,
2734,
8187,
26,
2198,
20011,
8,
3603,
4992,
12926,
1252,
923,
2175,
1197,
1252,
1637,
342,
339,
327,
30367,
1006,
10867,
543,
1163,
2851,
8,
83,
9,
2142,
370,
687,
1324,
570,
436,
8265,
6915,
83,
402,
3062,
370,
1373,
14,
272,
6915,
83,
275,
6220,
14,
1130,
8,
2734,
1166,
63,
11113,
26,
334,
633,
63,
11113,
59,
16,
467,
413,
14,
16,
430,
339,
327,
28562,
436,
7029,
2851,
6915,
83,
19922,
590,
1808,
10331,
19486,
5563,
14,
272,
367,
8494,
315,
1425,
8,
442,
8,
1274,
14,
3020,
59,
18,
18710,
267,
327,
28562,
2851,
406,
26675,
370,
314,
6915,
402,
1163,
10867,
14,
267,
406,
19577,
275,
6220,
14,
904,
8,
29473,
680,
7088,
2956,
8,
288,
2400,
1166,
63,
3603,
63,
4648,
26,
4526,
714,
19577,
8,
633,
63,
3603,
63,
4648,
59,
17,
1527,
16,
467,
1166,
63,
3603,
63,
4648,
59,
17,
1527,
17,
2459,
398,
327,
799,
13,
13494,
2335,
2851,
6915,
83,
4079,
641,
15503,
406,
26675,
14,
267,
6915,
83,
275,
406,
19577,
14,
5270,
2175,
1197,
8,
525,
680,
1130,
6550,
8,
2734,
6915,
26,
6915,
627,
378,
14,
2426,
435,
378,
14,
1046,
9,
339,
327,
19649,
83,
1006,
2851,
6915,
83,
436,
5461,
3062,
370,
8559,
14,
272,
367,
334,
1073,
12,
6915,
9,
315,
6915,
83,
14,
7112,
837,
267,
870,
3647,
83,
965,
6915,
26,
450,
83,
2122,
450,
334,
1073,
12,
6915,
430,
339,
15442,
14,
2379,
342,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
199,
3,
3909,
370,
314,
3668,
2290,
2752,
334,
14950,
9,
1334,
1373,
503,
1655,
199,
3,
11615,
4190,
14024,
14,
221,
1666,
314,
12840,
570,
1854,
543,
199,
3,
642,
1736,
367,
4722,
2556,
12602,
4248,
12715,
14,
199,
3,
710,
14857,
12378,
642,
570,
370,
2047,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
199,
3,
334,
1589,
298,
3761,
3547,
1265,
1443,
440,
675,
642,
570,
871,
315,
4151,
543,
199,
3,
314,
844,
14,
221,
2047,
1443,
3332,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
259,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
199,
3,
2428,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
199,
3,
1666,
314,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
199,
3,
4204,
1334,
314,
844,
14,
199,
3,
199,
199,
624,
199,
2765,
365,
376,
2893,
4514,
402,
10331,
19486,
14,
2104,
1655,
16129,
279,
675,
12,
199,
8254,
10618,
370,
10331,
19486,
4514,
2741,
701,
3343,
88,
199,
624,
199,
504,
636,
2443,
363,
492,
870,
63,
1593,
199,
199,
646,
295,
199,
646,
984,
199,
504,
4182,
492,
1050,
199,
199,
504,
15847,
14,
3009,
492,
13932,
4434,
421,
199,
318,
4526,
714,
19577,
8,
3603,
12,
6915,
304,
272,
408,
13862,
2335,
2851,
406,
26675,
370,
314,
6915,
402,
1163,
10867,
1041,
272,
1967,
63,
3603,
275,
822,
8,
3603,
9,
272,
367,
1166,
315,
8187,
26,
267,
1995,
334,
633,
12,
6915,
1182,
1967,
63,
3603,
9,
421,
199,
318,
2198,
20011,
8,
3603,
304,
272,
408,
23400,
282,
8187,
4092,
1059,
1901,
8187,
4092,
1041,
272,
4184,
275,
295,
14,
1294,
8,
82,
1154,
83,
7386,
8187,
9,
272,
372,
4184,
59,
16,
467,
4184,
59,
17,
61,
421,
199,
692,
636,
354,
363,
508,
4396,
973,
5727,
272,
340,
822,
8,
1274,
14,
3020,
9,
1137,
650,
26,
267,
870,
480,
7692,
26,
26581,
3580,
665,
493,
30,
665,
13570,
7166,
570,
29,
1274,
14,
3083,
9,
267,
4458,
2801,
17,
9,
339,
870,
4852,
17449,
26,
961,
365,
282,
19995,
4514,
402,
10331,
19486,
436,
365,
881,
1627,
465,
376,
2893,
1,
7754,
10618,
370,
10331,
19486,
4514,
2741,
701,
3343,
88,
7208,
881,
570,
29,
1274,
14,
3083,
9,
339,
327,
11578,
314,
15442,
1067,
14,
272,
15442,
275,
13932,
4434,
60,
267,
1275,
5649,
60,
267,
1275,
571,
985,
480,
4718,
3276,
19486,
27681,
267,
1275,
30457,
2499,
342,
339,
327,
30367,
315,
1324,
570,
14,
2779,
1077,
506,
315,
1475,
402,
26,
272,
327,
258,
2851,
260,
15503,
2851,
272,
327,
258,
2851,
260,
15503,
2851,
272,
327,
258,
2851,
260,
15503,
2851,
272,
327,
258,
2263,
272,
2385,
275,
15442,
14,
739,
14,
505,
8,
1274,
14,
3020,
59,
17,
6575,
20533,
14,
1130,
8,
2734,
519,
26,
519,
59,
16,
566,
339,
327,
30367,
1006,
10867,
687,
1324,
570,
436,
8265,
3932,
15845,
14,
272,
6220,
275,
2385,
14,
1130,
8,
2734,
8187,
26,
2198,
20011,
8,
3603,
4992,
12926,
1252,
923,
2175,
1197,
1252,
1637,
342,
339,
327,
30367,
1006,
10867,
543,
1163,
2851,
8,
83,
9,
2142,
370,
687,
1324,
570,
436,
8265,
6915,
83,
402,
3062,
370,
1373,
14,
272,
6915,
83,
275,
6220,
14,
1130,
8,
2734,
1166,
63,
11113,
26,
334,
633,
63,
11113,
59,
16,
467,
413,
14,
16,
430,
339,
327,
28562,
436,
7029,
2851,
6915,
83,
19922,
590,
1808,
10331,
19486,
5563,
14,
272,
367,
8494,
315,
1425,
8,
442,
8,
1274,
14,
3020,
59,
18,
18710,
267,
327,
28562,
2851,
406,
26675,
370,
314,
6915,
402,
1163,
10867,
14,
267,
406,
19577,
275,
6220,
14,
904,
8,
29473,
680,
7088,
2956,
8,
288,
2400,
1166,
63,
3603,
63,
4648,
26,
4526,
714,
19577,
8,
633,
63,
3603,
63,
4648,
59,
17,
1527,
16,
467,
1166,
63,
3603,
63,
4648,
59,
17,
1527,
17,
2459,
398,
327,
799,
13,
13494,
2335,
2851,
6915,
83,
4079,
641,
15503,
406,
26675,
14,
267,
6915,
83,
275,
406,
19577,
14,
5270,
2175,
1197,
8,
525,
680,
1130,
6550,
8,
2734,
6915,
26,
6915,
627,
378,
14,
2426,
435,
378,
14,
1046,
9,
339,
327,
19649,
83,
1006,
2851,
6915,
83,
436,
5461,
3062,
370,
8559,
14,
272,
367,
334,
1073,
12,
6915,
9,
315,
6915,
83,
14,
7112,
837,
267,
870,
3647,
83,
965,
6915,
26,
450,
83,
2122,
450,
334,
1073,
12,
6915,
430,
339,
15442,
14,
2379,
342,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
Ruide/angr-dev
|
angr/angr/state_plugins/unicorn_engine.py
|
1
|
53139
|
import os
import sys
import copy
import struct
import ctypes
import threading
import itertools
import pkg_resources
import logging
from ..sim_options import UNICORN_HANDLE_TRANSMIT_SYSCALL
l = logging.getLogger("angr.state_plugins.unicorn_engine")
try:
import unicorn
except ImportError:
l.warning("Unicorn is not installed. Support disabled.")
unicorn = None
import pyvex
import claripy
from .plugin import SimStatePlugin
from ..errors import SimValueError, SimUnicornUnsupport, SimSegfaultError, SimMemoryError
class MEM_PATCH(ctypes.Structure): # mem_update_t
pass
MEM_PATCH._fields_ = [
('address', ctypes.c_uint64),
('length', ctypes.c_uint64),
('next', ctypes.POINTER(MEM_PATCH))
]
class TRANSMIT_RECORD(ctypes.Structure): # transmit_record_t
pass
TRANSMIT_RECORD._fields_ = [
('data', ctypes.c_void_p),
('count', ctypes.c_uint32)
]
class STOP(object): # stop_t
STOP_NORMAL = 0
STOP_STOPPOINT = 1
STOP_SYMBOLIC_MEM = 2
STOP_SYMBOLIC_REG = 3
STOP_ERROR = 4
STOP_SYSCALL = 5
STOP_EXECNONE = 6
STOP_ZEROPAGE = 7
STOP_NOSTART = 8
STOP_SEGFAULT = 9
@staticmethod
def name_stop(num):
for item in dir(STOP):
if item.startswith('STOP_') and getattr(STOP, item) == num:
return item
#
# Memory mapping errors - only used internally
#
class MemoryMappingError(Exception):
pass
class AccessingZeroPageError(MemoryMappingError):
pass
class FetchingZeroPageError(MemoryMappingError):
pass
class SegfaultError(MemoryMappingError):
pass
class MixedPermissonsError(MemoryMappingError):
pass
#
# This annotation is added to constraints that Unicorn generates in aggressive concretization mode
#
class AggressiveConcretizationAnnotation(claripy.SimplificationAvoidanceAnnotation):
def __init__(self, addr):
claripy.SimplificationAvoidanceAnnotation.__init__(self)
self.unicorn_start_addr = addr
#
# Because Unicorn leaks like crazy, we use one Uc object per thread...
#
_unicounter = itertools.count()
class Uniwrapper(unicorn.Uc if unicorn is not None else object):
# pylint: disable=non-parent-init-called
def __init__(self, arch, cache_key):
l.debug("Creating unicorn state!")
self.arch = arch
self.cache_key = cache_key
self.wrapped_mapped = set()
self.wrapped_hooks = set()
self.id = None
unicorn.Uc.__init__(self, arch.uc_arch, arch.uc_mode)
def hook_add(self, htype, callback, user_data=None, begin=1, end=0, arg1=0):
h = unicorn.Uc.hook_add(self, htype, callback, user_data=user_data, begin=begin, end=end, arg1=arg1)
#l.debug("Hook: %s,%s -> %s", htype, callback.__name__, h)
self.wrapped_hooks.add(h)
return h
def hook_del(self, h):
#l.debug("Clearing hook %s", h)
h = unicorn.Uc.hook_del(self, h)
self.wrapped_hooks.discard(h)
return h
def mem_map(self, addr, size, perms=7):
#l.debug("Mapping %d bytes at %#x", size, addr)
m = unicorn.Uc.mem_map(self, addr, size, perms=perms)
self.wrapped_mapped.add((addr, size))
return m
def mem_unmap(self, addr, size):
#l.debug("Unmapping %d bytes at %#x", size, addr)
m = unicorn.Uc.mem_unmap(self, addr, size)
self.wrapped_mapped.discard((addr, size))
return m
def mem_reset(self):
#l.debug("Resetting memory.")
for addr,size in self.wrapped_mapped:
#l.debug("Unmapping %d bytes at %#x", size, addr)
unicorn.Uc.mem_unmap(self, addr, size)
self.wrapped_mapped.clear()
def hook_reset(self):
#l.debug("Resetting hooks.")
for h in self.wrapped_hooks:
#l.debug("Clearing hook %s", h)
unicorn.Uc.hook_del(self, h)
self.wrapped_hooks.clear()
def reset(self):
self.mem_reset()
#self.hook_reset()
#l.debug("Reset complete.")
_unicorn_tls = threading.local()
_unicorn_tls.uc = None
class _VexCacheInfo(ctypes.Structure):
_fields_ = [
("num_levels", ctypes.c_uint),
("num_caches", ctypes.c_uint),
("caches", ctypes.c_void_p),
("icaches_maintain_coherence", ctypes.c_bool),
]
class _VexArchInfo(ctypes.Structure):
_fields_ = [
("hwcaps", ctypes.c_uint),
("endness", ctypes.c_int),
("hwcache_info", _VexCacheInfo),
("ppc_icache_line_szB", ctypes.c_int),
("ppc_dcbz_szB", ctypes.c_uint),
("ppc_dcbzl_szB", ctypes.c_uint),
("arm64_dMinLine_lg2_szB", ctypes.c_uint),
("arm64_iMinLine_lg2_szB", ctypes.c_uint),
("x86_cr0", ctypes.c_uint),
]
def _load_native():
if sys.platform == 'darwin':
libfile = 'angr_native.dylib'
elif sys.platform in ('win32', 'cygwin'):
libfile = 'angr_native.dll'
else:
libfile = 'angr_native.so'
try:
angr_path = pkg_resources.resource_filename('angr', os.path.join('lib', libfile))
h = ctypes.CDLL(angr_path)
VexArch = ctypes.c_int
uc_err = ctypes.c_int
state_t = ctypes.c_void_p
stop_t = ctypes.c_int
uc_engine_t = ctypes.c_void_p
def _setup_prototype(handle, func, restype, *argtypes):
realname = 'simunicorn_' + func
_setup_prototype_explicit(handle, realname, restype, *argtypes)
setattr(handle, func, getattr(handle, realname))
def _setup_prototype_explicit(handle, func, restype, *argtypes):
getattr(handle, func).restype = restype
getattr(handle, func).argtypes = argtypes
#_setup_prototype_explicit(h, 'logSetLogLevel', None, ctypes.c_uint64)
_setup_prototype(h, 'alloc', state_t, uc_engine_t, ctypes.c_uint64)
_setup_prototype(h, 'dealloc', None, state_t)
_setup_prototype(h, 'hook', None, state_t)
_setup_prototype(h, 'unhook', None, state_t)
_setup_prototype(h, 'start', uc_err, state_t, ctypes.c_uint64, ctypes.c_uint64)
_setup_prototype(h, 'stop', None, state_t, stop_t)
_setup_prototype(h, 'sync', ctypes.POINTER(MEM_PATCH), state_t)
_setup_prototype(h, 'bbl_addrs', ctypes.POINTER(ctypes.c_uint64), state_t)
_setup_prototype(h, 'stack_pointers', ctypes.POINTER(ctypes.c_uint64), state_t)
_setup_prototype(h, 'bbl_addr_count', ctypes.c_uint64, state_t)
_setup_prototype(h, 'syscall_count', ctypes.c_uint64, state_t)
_setup_prototype(h, 'destroy', None, ctypes.POINTER(MEM_PATCH))
_setup_prototype(h, 'step', ctypes.c_uint64, state_t)
_setup_prototype(h, 'stop_reason', stop_t, state_t)
_setup_prototype(h, 'activate', None, state_t, ctypes.c_uint64, ctypes.c_uint64, ctypes.c_char_p)
_setup_prototype(h, 'set_stops', None, state_t, ctypes.c_uint64, ctypes.POINTER(ctypes.c_uint64))
_setup_prototype(h, 'cache_page', ctypes.c_bool, state_t, ctypes.c_uint64, ctypes.c_uint64, ctypes.c_char_p, ctypes.c_uint64)
_setup_prototype(h, 'uncache_page', None, state_t, ctypes.c_uint64)
_setup_prototype(h, 'enable_symbolic_reg_tracking', None, state_t, VexArch, _VexArchInfo)
_setup_prototype(h, 'disable_symbolic_reg_tracking', None, state_t)
_setup_prototype(h, 'symbolic_register_data', None, state_t, ctypes.c_uint64, ctypes.POINTER(ctypes.c_uint64))
_setup_prototype(h, 'get_symbolic_registers', ctypes.c_uint64, state_t, ctypes.POINTER(ctypes.c_uint64))
_setup_prototype(h, 'stopping_register', ctypes.c_uint64, state_t)
_setup_prototype(h, 'stopping_memory', ctypes.c_uint64, state_t)
_setup_prototype(h, 'is_interrupt_handled', ctypes.c_bool, state_t)
_setup_prototype(h, 'set_transmit_sysno', None, state_t, ctypes.c_uint32, ctypes.c_uint64)
_setup_prototype(h, 'process_transmit', ctypes.POINTER(TRANSMIT_RECORD), state_t, ctypes.c_uint32)
l.info('native plugin is enabled')
return h
except (OSError, AttributeError) as e:
e_type, value, traceback = sys.exc_info()
l.warning('failed loading "%s", unicorn support disabled (%s: %s)', libfile, e, value)
raise ImportError, ("Unable to import native SimUnicorn support.", e_type, value), traceback
try:
_UC_NATIVE = _load_native()
#_UC_NATIVE.logSetLogLevel(2)
except ImportError:
_UC_NATIVE = None
class Unicorn(SimStatePlugin):
'''
setup the unicorn engine for a state
'''
UC_CONFIG = {} # config cache for each arch
def __init__(
self,
syscall_hooks=None,
cache_key=None,
unicount=None,
symbolic_var_counts=None,
symbolic_inst_counts=None,
concretized_asts=None,
always_concretize=None,
never_concretize=None,
concretize_at=None,
concretization_threshold_memory=None,
concretization_threshold_registers=None,
concretization_threshold_instruction=None,
cooldown_symbolic_registers=100,
cooldown_symbolic_memory=100,
cooldown_nonunicorn_blocks=100,
max_steps=1000000,
):
"""
Initializes the Unicorn plugin for angr. This plugin handles communication with
UnicornEngine.
"""
SimStatePlugin.__init__(self)
self._syscall_pc = None
self.jumpkind = 'Ijk_Boring'
self.error = None
self.errno = 0
self.cache_key = hash(self) if cache_key is None else cache_key
# cooldowns to avoid thrashing in and out of unicorn
# the countdown vars are the CURRENT counter that is counting down
# when they hit zero execution will start
# the cooldown vars are the settings for what the countdown should start at
# the val is copied from cooldown to countdown on check fail
self.cooldown_nonunicorn_blocks = cooldown_nonunicorn_blocks
self.cooldown_symbolic_registers = cooldown_symbolic_registers
self.cooldown_symbolic_memory = cooldown_symbolic_memory
self.countdown_nonunicorn_blocks = 0
self.countdown_symbolic_registers = 0
self.countdown_symbolic_memory = 0
# the default step limit
self.max_steps = max_steps
self.steps = 0
self._mapped = 0
self._uncache_pages = []
# following variables are used in python level hook
# we cannot see native hooks from python
self.syscall_hooks = { } if syscall_hooks is None else syscall_hooks
# native state in libsimunicorn
self._uc_state = None
self.stop_reason = None
# this is the counter for the unicorn count
self._unicount = next(_unicounter) if unicount is None else unicount
#
# Selective concretization stuff
#
# this is the number of times specific symbolic variables have kicked us out of unicorn
self.symbolic_var_counts = { } if symbolic_var_counts is None else symbolic_var_counts
# this is the number of times we've been kept out of unicorn at given instructions
self.symbolic_inst_counts = { } if symbolic_inst_counts is None else symbolic_inst_counts
# these are threshold for the number of times that we tolerate being kept out of unicorn
# before we start concretizing
self.concretization_threshold_memory = concretization_threshold_memory
self.concretization_threshold_registers = concretization_threshold_registers
self.concretization_threshold_instruction = concretization_threshold_instruction
# these are sets of names of variables that should either always or never
# be concretized
self.always_concretize = set() if always_concretize is None else always_concretize
self.never_concretize = set() if never_concretize is None else never_concretize
self.concretize_at = set() if concretize_at is None else concretize_at
# this is a record of the ASTs for which we've added concretization constraints
self._concretized_asts = set() if concretized_asts is None else concretized_asts
# the address to use for concrete transmits
self.transmit_addr = None
def copy(self):
u = Unicorn(
syscall_hooks=dict(self.syscall_hooks),
cache_key=self.cache_key,
#unicount=self._unicount,
symbolic_var_counts = dict(self.symbolic_var_counts),
symbolic_inst_counts = dict(self.symbolic_inst_counts),
concretized_asts = set(self._concretized_asts),
always_concretize = set(self.always_concretize),
never_concretize = set(self.never_concretize),
concretize_at = set(self.concretize_at),
concretization_threshold_memory = self.concretization_threshold_memory,
concretization_threshold_registers = self.concretization_threshold_registers,
concretization_threshold_instruction = self.concretization_threshold_instruction,
cooldown_nonunicorn_blocks=self.cooldown_nonunicorn_blocks,
cooldown_symbolic_registers=self.cooldown_symbolic_registers,
cooldown_symbolic_memory=self.cooldown_symbolic_memory,
max_steps=self.max_steps,
)
u.countdown_nonunicorn_blocks = self.countdown_nonunicorn_blocks
u.countdown_symbolic_registers = self.countdown_symbolic_registers
u.countdown_symbolic_memory = self.countdown_symbolic_memory
u.transmit_addr = self.transmit_addr
u._uncache_pages = list(self._uncache_pages)
return u
def merge(self, others, merge_conditions, common_ancestor=None):
self.cooldown_nonunicorn_blocks = max(
self.cooldown_nonunicorn_blocks,
max(o.cooldown_nonunicorn_blocks for o in others)
)
self.cooldown_symbolic_registers = max(
self.cooldown_symbolic_registers,
max(o.cooldown_symbolic_registers for o in others)
)
self.cooldown_symbolic_memory = max(
self.cooldown_symbolic_memory,
max(o.cooldown_symbolic_memory for o in others)
)
self.countdown_nonunicorn_blocks = max(
self.countdown_nonunicorn_blocks,
max(o.countdown_nonunicorn_blocks for o in others)
)
self.countdown_symbolic_registers = max(
self.countdown_symbolic_registers,
max(o.countdown_symbolic_registers for o in others)
)
self.countdown_symbolic_memory = max(
self.countdown_symbolic_memory,
max(o.countdown_symbolic_memory for o in others)
)
# get a fresh unicount, just in case
self._unicount = next(_unicounter)
# keep these guys, since merging them sounds like a pain
#self.symbolic_var_counts
#self.symbolic_inst_counts
# these are threshold for the number of times that we tolerate being kept out of unicorn
# before we start concretizing
self.concretization_threshold_memory = min(
self.concretization_threshold_memory,
min(o.concretization_threshold_memory for o in others)
)
self.concretization_threshold_registers = min(
self.concretization_threshold_registers,
min(o.concretization_threshold_registers for o in others)
)
self.concretization_threshold_instruction = min(
self.concretization_threshold_instruction,
min(o.concretization_threshold_instruction for o in others)
)
# these are sets of names of variables that should either always or never
# be concretized
self.always_concretize.union(*[o.always_concretize for o in others])
self.never_concretize.union(*[o.never_concretize for o in others])
self.concretize_at.union(*[o.concretize_at for o in others])
# intersect these so that we know to add future constraints properly
self._concretized_asts.intersection(*[o._concretized_asts for o in others])
# I guess always lie to the static analysis?
return False
def __getstate__(self):
d = dict(self.__dict__)
del d['_uc_state']
del d['cache_key']
del d['_unicount']
return d
def __setstate__(self, s):
self.__dict__.update(s)
self._unicount = next(_unicounter)
self._uc_state = None
self.cache_key = hash(self)
_unicorn_tls.uc = None
def set_state(self, state):
SimStatePlugin.set_state(self, state)
if state.arch.name == "MIPS32":
self._unicount = next(_unicounter)
@property
def _reuse_unicorn(self):
return self.state.arch.name != "MIPS32"
@property
def uc(self):
new_id = next(_unicounter)
if (
not hasattr(_unicorn_tls, "uc") or
_unicorn_tls.uc is None or
_unicorn_tls.uc.arch != self.state.arch or
_unicorn_tls.uc.cache_key != self.cache_key
):
_unicorn_tls.uc = Uniwrapper(self.state.arch, self.cache_key)
elif _unicorn_tls.uc.id != self._unicount:
if not self._reuse_unicorn:
_unicorn_tls.uc = Uniwrapper(self.state.arch, self.cache_key)
else:
#l.debug("Reusing unicorn state!")
_unicorn_tls.uc.reset()
else:
#l.debug("Reusing unicorn state!")
pass
_unicorn_tls.uc.id = new_id
self._unicount = new_id
return _unicorn_tls.uc
@staticmethod
def delete_uc():
_unicorn_tls.uc = None
@property
def _uc_regs(self):
return self.state.arch.uc_regs
@property
def _uc_prefix(self):
return self.state.arch.uc_prefix
@property
def _uc_const(self):
return self.state.arch.uc_const
def _setup_unicorn(self):
if self.state.arch.uc_mode is None:
raise SimUnicornUnsupport("unsupported architecture %r" % self.state.arch)
def set_stops(self, stop_points):
_UC_NATIVE.set_stops(self._uc_state,
ctypes.c_uint64(len(stop_points)),
(ctypes.c_uint64 * len(stop_points))(*map(ctypes.c_uint64, stop_points))
)
def hook(self):
#l.debug('adding native hooks')
_UC_NATIVE.hook(self._uc_state) # prefer to use native hooks
self.uc.hook_add(unicorn.UC_HOOK_MEM_UNMAPPED, self._hook_mem_unmapped, None, 1, 0)
arch = self.state.arch.qemu_name
if arch == 'x86_64':
self.uc.hook_add(unicorn.UC_HOOK_INTR, self._hook_intr_x86, None, 1, 0)
self.uc.hook_add(unicorn.UC_HOOK_INSN, self._hook_syscall_x86_64, None, self._uc_const.UC_X86_INS_SYSCALL)
elif arch == 'i386':
self.uc.hook_add(unicorn.UC_HOOK_INTR, self._hook_intr_x86, None, 1, 0)
elif arch == 'mips':
self.uc.hook_add(unicorn.UC_HOOK_INTR, self._hook_intr_mips, None, 1, 0)
elif arch == 'mipsel':
self.uc.hook_add(unicorn.UC_HOOK_INTR, self._hook_intr_mips, None, 1, 0)
else:
raise SimUnicornUnsupport
def _hook_intr_mips(self, uc, intno, user_data):
if intno == 17: # EXCP_SYSCALL
sysno = uc.reg_read(self._uc_regs['v0'])
pc = uc.reg_read(self._uc_regs['pc'])
l.debug('hit sys_%d at %#x', sysno, pc)
self._syscall_pc = pc + 4
self._handle_syscall(uc, user_data)
else:
l.warning('unhandled interrupt %d', intno)
_UC_NATIVE.stop(self._uc_state, STOP.STOP_ERROR)
def _hook_intr_x86(self, uc, intno, user_data):
if _UC_NATIVE.is_interrupt_handled(self._uc_state):
return
if intno == 0x80:
if self.state.arch.bits == 32:
self._hook_syscall_i386(uc, user_data)
else:
self._hook_syscall_x86_64(uc, user_data)
else:
l.warning('unhandled interrupt %d', intno)
_UC_NATIVE.stop(self._uc_state, STOP.STOP_ERROR)
def _hook_syscall_x86_64(self, uc, user_data):
sysno = uc.reg_read(self._uc_regs['rax'])
pc = uc.reg_read(self._uc_regs['rip'])
l.debug('hit sys_%d at %#x', sysno, pc)
self._syscall_pc = pc + 2 # skip syscall instruction
self._handle_syscall(uc, user_data)
def _hook_syscall_i386(self, uc, user_data):
sysno = uc.reg_read(self._uc_regs['eax'])
pc = uc.reg_read(self._uc_regs['eip'])
l.debug('hit sys_%d at %#x', sysno, pc)
self._syscall_pc = pc + 2
if not self._quick_syscall(sysno):
self._handle_syscall(uc, user_data)
def _quick_syscall(self, sysno):
if sysno in self.syscall_hooks:
self.syscall_hooks[sysno](self.state)
return True
else:
return False
def _handle_syscall(self, uc, user_data): #pylint:disable=unused-argument
# unicorn does not support syscall, we should giveup emulation
# and send back to SimProcedure. (ignore is always False)
l.info('stop emulation')
self.jumpkind = 'Ijk_Sys_syscall'
_UC_NATIVE.stop(self._uc_state, STOP.STOP_SYSCALL)
def _concretize(self, d):
cd = self.state.se.eval_to_ast(d, 1)[0]
if hash(d) not in self._concretized_asts:
constraint = (d == cd).annotate(AggressiveConcretizationAnnotation(self.state.regs.ip))
self.state.add_constraints(constraint)
self._concretized_asts.add(hash(d))
return cd
def _symbolic_passthrough(self, d):
if not d.symbolic:
return d
elif options.UNICORN_AGGRESSIVE_CONCRETIZATION in self.state.options:
return self._concretize(d)
elif len(d.variables & self.never_concretize) > 0:
return d
elif d.variables.issubset(self.always_concretize):
return self._concretize(d)
elif self.state.se.eval(self.state.ip) in self.concretize_at:
return self._concretize(d)
else:
return d
def _report_symbolic_blocker(self, d, from_where):
if options.UNICORN_THRESHOLD_CONCRETIZATION in self.state.options:
if self.concretization_threshold_instruction is not None:
addr = self.state.se.eval(self.state.ip)
count = self.symbolic_inst_counts.get(addr, 0)
l.debug("... inst count for %s: %d", addr, count)
self.symbolic_inst_counts[addr] = count + 1
if count >= self.concretization_threshold_instruction:
self.concretize_at.add(addr)
threshold = (
self.concretization_threshold_memory if from_where == 'mem' else
self.concretization_threshold_registers
)
if threshold is None:
return
for v in d.variables:
old_count = self.symbolic_var_counts.get(v, 0)
l.debug("... %s: %d", v, old_count)
self.symbolic_var_counts[v] = old_count + 1
if old_count >= threshold:
self.always_concretize.add(v)
def _process_value(self, d, from_where):
"""
Pre-process an AST for insertion into unicorn.
:param d: the AST
:param from_where: the ID of the memory region it comes from ('mem' or 'reg')
:returns: the value to be inserted into Unicorn, or None
"""
if len(d.annotations):
l.debug("Blocking annotated AST.")
return None
elif not d.symbolic:
return d
else:
l.debug("Processing AST with variables %s.", d.variables)
dd = self._symbolic_passthrough(d)
if not dd.symbolic:
if d.symbolic:
l.debug("... concretized")
return dd
elif from_where == 'reg' and options.UNICORN_SYM_REGS_SUPPORT in self.state.options:
l.debug("... allowing symbolic register")
return dd
else:
l.debug("... denied")
return None
def _hook_mem_unmapped(self, uc, access, address, size, value, user_data, size_extension=True): #pylint:disable=unused-argument
"""
This callback is called when unicorn needs to access data that's not yet present in memory.
"""
# FIXME check angr hooks at `address`
if size_extension:
start = address & (0xfffffffffffff0000)
length = ((address + size + 0xffff) & (0xfffffffffffff0000)) - start
else:
start = address & (0xffffffffffffff000)
length = ((address + size + 0xfff) & (0xffffffffffffff000)) - start
if (start == 0 or ((start + length) & ((1 << self.state.arch.bits) - 1)) == 0) and options.UNICORN_ZEROPAGE_GUARD in self.state.options:
# sometimes it happens because of %fs is not correctly set
self.error = 'accessing zero page [%#x, %#x] (%#x)' % (address, address + length - 1, access)
l.warning(self.error)
# tell uc_state to rollback
_UC_NATIVE.stop(self._uc_state, STOP.STOP_ZEROPAGE)
return False
ret = False
try:
best_effort_read = size_extension
ret = self._hook_mem_unmapped_core(uc, access, start, length, best_effort_read=best_effort_read)
except AccessingZeroPageError:
# raised when STRICT_PAGE_ACCESS is enabled
if not size_extension:
_UC_NATIVE.stop(self._uc_state, STOP.STOP_SEGFAULT)
ret = False
except FetchingZeroPageError:
# raised when trying to execute code on an unmapped page
if not size_extension:
self.error = 'fetching empty page [%#x, %#x]' % (start, start + length - 1)
l.warning(self.error)
_UC_NATIVE.stop(self._uc_state, STOP.STOP_EXECNONE)
ret = False
except SimMemoryError:
if not size_extension:
raise
except SegfaultError:
if not size_extension:
_UC_NATIVE.stop(self._uc_state, STOP.STOP_SEGFAULT)
ret = False
except MixedPermissonsError:
if not size_extension:
# weird... it shouldn't be raised at all
l.error('MixedPermissionsError is raised when size-extension is disabled. Please report it.')
_UC_NATIVE.stop(self._uc_state, STOP.STOP_SEGFAULT)
ret = False
except unicorn.UcError as ex:
if not size_extension:
if ex.errno == 11:
# Mapping failed. Probably because of size extension... let's try to redo it without size extension
pass
else:
# just raise the exception
raise
finally:
if size_extension and not ret:
# retry without size-extension if size-extension was enabled
# any exception will not be caught
ret = self._hook_mem_unmapped(uc, access, address, size, value, user_data, size_extension=False)
return ret
def _hook_mem_unmapped_core(self, uc, access, start, length, best_effort_read=True):
PAGE_SIZE = 4096
addr = start
end_addr = start + length
perms = set()
missing_pages = [ ]
while addr < end_addr:
try:
perm = self.state.memory.permissions(addr)
if perm.symbolic:
perms.add(7)
elif options.ENABLE_NX not in self.state.options:
perms.add(perm.args[0] | 4)
else:
perms.add(perm.args[0])
except SimMemoryError as e:
if e.message == "page does not exist at given address": # FIXME: direct string comparison is bad
missing_pages.append(addr)
else:
raise
addr += PAGE_SIZE
if len(perms) == 0 and len(missing_pages) > 0:
# all pages are missing
if options.STRICT_PAGE_ACCESS in self.state.options:
raise AccessingZeroPageError()
elif access == unicorn.UC_MEM_FETCH_UNMAPPED:
raise FetchingZeroPageError()
else:
# initialize the memory page, but do not overwrite existing pages
self.state.memory.map_region(start, length, 3)
perm = 3
elif len(missing_pages) == 0 and len(perms) == 1:
# no page is missing, and all pages have the same permission
# great!
perm = list(perms)[0]
else:
# either pages have different permissions, or only some of the pages are missing
# give up
raise MixedPermissonsError()
try:
ret_on_segv = True if best_effort_read else False
items = self.state.memory.mem.load_objects(start, length, ret_on_segv=ret_on_segv)
except SimSegfaultError:
raise
if access == unicorn.UC_MEM_FETCH_UNMAPPED and len(items) == 0:
# we can not initialize an empty page then execute on it
raise FetchingZeroPageError()
data = bytearray(length)
taint = [ ] # this is a list to get around python's scoping craziness
def _taint(pos, chunk_size):
if not taint:
taint.append(ctypes.create_string_buffer(length))
offset = ctypes.cast(ctypes.addressof(taint[0]) + pos - start, ctypes.POINTER(ctypes.c_char))
ctypes.memset(offset, 0x2, chunk_size) # mark them as TAINT_SYMBOLIC
def _missing(pos, chunk_size, data=data):
if options.CGC_ZERO_FILL_UNCONSTRAINED_MEMORY not in self.state.options:
_taint(pos, chunk_size)
else:
data[pos-start:pos-start+chunk_size] = "\0"*chunk_size
# fill out the data in reverse
last_missing = start + length - 1
for mo_addr,mo in reversed(items):
if not mo.includes(last_missing):
#print "MISSING: %x, %d" % (mo.last_addr+1, last_missing-mo.last_addr)
_missing(mo.last_addr+1, last_missing-mo.last_addr)
last_missing = mo.last_addr
# investigate the chunk, taint if symbolic
chunk_size = last_missing - mo_addr + 1
chunk = mo.bytes_at(mo_addr, chunk_size)
d = self._process_value(chunk, 'mem')
if d is None:
#print "TAINT: %x, %d" % (mo_addr, chunk_size)
_taint(mo_addr, chunk_size)
else:
s = self.state.se.eval(d, cast_to=str)
data[mo_addr-start:mo_addr-start+chunk_size] = s
last_missing = mo_addr - 1
# handle missing bytes at the beginning
if last_missing != start - 1:
#print "MISSING START: %x, %d" % (start, last_missing - start + 1)
_missing(start, last_missing - start + 1)
# do the mapping
l.info('mmap [%#x, %#x], %d%s (because %d)', start, start + length - 1, perm, ' (symbolic)' if taint else '', access)
if not taint and not perm & 2:
# page is non-writable, handle it with native code
l.debug('caching non-writable page')
out = _UC_NATIVE.cache_page(self._uc_state, start, length, str(data), perm)
return out
else:
# if the memory range has already been mapped, or it somehow fails sanity checks, mem_map() may fail with
# a unicorn.UcError raised. THe exception will be caught outside.
uc.mem_map(start, length, perm)
uc.mem_write(start, str(data))
self._mapped += 1
_UC_NATIVE.activate(self._uc_state, start, length, taint[0] if taint else None)
return True
def uncache_page(self, addr):
self._uncache_pages.append(addr & ~0xfff)
def setup(self):
self._setup_unicorn()
self.set_regs()
# tricky: using unicorn handle form unicorn.Uc object
self._uc_state = _UC_NATIVE.alloc(self.uc._uch, self.cache_key)
if UNICORN_HANDLE_TRANSMIT_SYSCALL in self.state.options and self.state.has_plugin('cgc'):
if self.transmit_addr is None:
l.error("You haven't set the address for concrete transmits!!!!!!!!!!!")
self.transmit_addr = 0
_UC_NATIVE.set_transmit_sysno(self._uc_state, 2, self.transmit_addr)
def start(self, step=None):
self.jumpkind = 'Ijk_Boring'
self.countdown_nonunicorn_blocks = self.cooldown_nonunicorn_blocks
for addr in self._uncache_pages:
l.info("Un-caching writable page %#x", addr)
_UC_NATIVE.uncache_page(self._uc_state, addr)
self._uncache_pages = []
# should this be in setup?
if options.UNICORN_SYM_REGS_SUPPORT in self.state.options and \
options.UNICORN_AGGRESSIVE_CONCRETIZATION not in self.state.options:
archinfo = copy.deepcopy(self.state.arch.vex_archinfo)
archinfo['hwcache_info']['caches'] = 0
archinfo['hwcache_info'] = _VexCacheInfo(**archinfo['hwcache_info'])
_UC_NATIVE.enable_symbolic_reg_tracking(
self._uc_state,
getattr(pyvex.pvc, self.state.arch.vex_arch),
_VexArchInfo(**archinfo),
)
# TODO: refactor
# first, check to see if *any* registers are symbolic, so that we
# can optimize the case where there aren't any. (N.B.: "optimize"
# does not refer to constructing the set of symbolic register
# offsets, but rather to not having to lift each block etc.)
if not self._check_registers(report=False):
highest_reg_offset, reg_size = max(self.state.arch.registers.values())
symbolic_offsets = set(range(0, highest_reg_offset+reg_size))
items = self.state.registers.mem.load_objects(0, highest_reg_offset+reg_size)
for start,v in items:
end = v.last_addr + 1
vv = self._symbolic_passthrough(v.object)
if not vv.symbolic:
symbolic_offsets.difference_update(range(start, end))
else:
symbolic_offsets.difference_update(b for b,vb in enumerate(vv.chop(8), start) if not vb.symbolic)
# for register flagged systems, we should save off all CC regs together
if self.state.arch.name == 'X86' and symbolic_offsets & set(range(40, 56)):
symbolic_offsets.update(range(40, 56))
elif self.state.arch.name == 'AMD64' and symbolic_offsets & set(range(144, 176)):
symbolic_offsets.update(range(144, 176))
sym_regs_array = (ctypes.c_uint64 * len(symbolic_offsets))(*map(ctypes.c_uint64, symbolic_offsets))
_UC_NATIVE.symbolic_register_data(self._uc_state, len(symbolic_offsets), sym_regs_array)
else:
_UC_NATIVE.symbolic_register_data(self._uc_state, 0, None)
addr = self.state.se.eval(self.state.ip)
l.info('started emulation at %#x (%d steps)', addr, self.max_steps if step is None else step)
self.errno = _UC_NATIVE.start(self._uc_state, addr, self.max_steps if step is None else step)
def finish(self):
# do the superficial synchronization
self.get_regs()
self.steps = _UC_NATIVE.step(self._uc_state)
self.stop_reason = _UC_NATIVE.stop_reason(self._uc_state)
# figure out why we stopped
if self.stop_reason == STOP.STOP_SYMBOLIC_REG:
stopping_register = _UC_NATIVE.stopping_register(self._uc_state)
self._report_symbolic_blocker(self.state.registers.load(stopping_register, 1), 'reg')
elif self.stop_reason == STOP.STOP_SYMBOLIC_MEM:
stopping_memory = _UC_NATIVE.stopping_memory(self._uc_state)
self._report_symbolic_blocker(self.state.memory.load(stopping_memory, 1), 'mem')
addr = self.state.se.eval(self.state.ip)
l.info('finished emulation at %#x after %d steps: %s', addr, self.steps, STOP.name_stop(self.stop_reason))
# should this be in destroy?
_UC_NATIVE.disable_symbolic_reg_tracking(self._uc_state)
# syncronize memory contents - head is a linked list of memory updates
head = _UC_NATIVE.sync(self._uc_state)
p_update = head
while bool(p_update):
update = p_update.contents
address, length = update.address, update.length
s = str(self.uc.mem_read(address, length))
l.debug('...changed memory: [%#x, %#x] = %s', address, address + length, s.encode('hex'))
self.state.memory.store(address, s)
p_update = update.next
_UC_NATIVE.destroy(head) # free the linked list
# adjust the countdowns
#if self.steps >= 128:
# self.cooldown_symbolic_registers = 16
# self.cooldown_symbolic_memory = 16
# process the concrete transmits
i = 0
while True:
record = _UC_NATIVE.process_transmit(self._uc_state, i)
if not bool(record):
break
string = ctypes.string_at(record.contents.data, record.contents.count)
self.state.posix.write(1, string, record.contents.count)
i += 1
if self.stop_reason in (STOP.STOP_NORMAL, STOP.STOP_STOPPOINT, STOP.STOP_SYSCALL):
self.countdown_nonunicorn_blocks = 0
elif self.stop_reason == STOP.STOP_SYMBOLIC_REG:
#if self.steps < 128:
# self.cooldown_symbolic_registers = min(self.cooldown_symbolic_registers * 2, 256)
self.countdown_symbolic_registers = self.cooldown_symbolic_registers
elif self.stop_reason == STOP.STOP_SYMBOLIC_MEM:
#if self.steps < 128:
# self.cooldown_symbolic_memory = min(self.cooldown_symbolic_memory * 2, 256)
self.countdown_symbolic_memory = self.cooldown_symbolic_memory
else:
self.countdown_nonunicorn_blocks = self.cooldown_nonunicorn_blocks
# get the address list out of the state
bbl_addrs = _UC_NATIVE.bbl_addrs(self._uc_state)
self.state.history.recent_bbl_addrs = bbl_addrs[:self.steps]
# get the stack pointers
stack_pointers = _UC_NATIVE.stack_pointers(self._uc_state)
self.state.scratch.stack_pointer_list = stack_pointers[ : self.steps]
# syscall counts
self.state.history.recent_syscall_count = _UC_NATIVE.syscall_count(self._uc_state)
def destroy(self):
#l.debug("Unhooking.")
_UC_NATIVE.unhook(self._uc_state)
self.uc.hook_reset()
#l.debug('deallocting native state %#x', self._uc_state)
_UC_NATIVE.dealloc(self._uc_state)
self._uc_state = None
# there's something we're not properly resetting for syscalls, so
# we'll clear the state when they happen
if self.stop_reason not in (STOP.STOP_NORMAL, STOP.STOP_STOPPOINT, STOP.STOP_SYMBOLIC_MEM, STOP.STOP_SYMBOLIC_REG):
self.delete_uc()
#l.debug("Resetting the unicorn state.")
self.uc.reset()
def set_regs(self):
''' setting unicorn registers '''
uc = self.uc
if self.state.arch.qemu_name == 'x86_64':
fs = self.state.se.eval(self.state.regs.fs)
gs = self.state.se.eval(self.state.regs.gs)
self.write_msr(fs, 0xC0000100)
self.write_msr(gs, 0xC0000101)
flags = self._process_value(ccall._get_flags(self.state)[0], 'reg')
if flags is None:
raise SimValueError('symbolic eflags')
uc.reg_write(self._uc_const.UC_X86_REG_EFLAGS, self.state.se.eval(flags))
elif self.state.arch.qemu_name == 'i386':
flags = self._process_value(ccall._get_flags(self.state)[0], 'reg')
if flags is None:
raise SimValueError('symbolic eflags')
uc.reg_write(self._uc_const.UC_X86_REG_EFLAGS, self.state.se.eval(flags))
fs = self.state.se.eval(self.state.regs.fs) << 16
gs = self.state.se.eval(self.state.regs.gs) << 16
self.setup_gdt(fs, gs)
for r, c in self._uc_regs.iteritems():
if r in self.reg_blacklist:
continue
v = self._process_value(getattr(self.state.regs, r), 'reg')
if v is None:
raise SimValueError('setting a symbolic register')
# l.debug('setting $%s = %#x', r, self.state.se.eval(v))
uc.reg_write(c, self.state.se.eval(v))
if self.state.arch.name in ('X86', 'AMD64'):
# sync the fp clerical data
c3210 = self.state.se.eval(self.state.regs.fc3210)
top = self.state.se.eval(self.state.regs.ftop[2:0])
rm = self.state.se.eval(self.state.regs.fpround[1:0])
control = 0x037F | (rm << 10)
status = (top << 11) | c3210
uc.reg_write(unicorn.x86_const.UC_X86_REG_FPCW, control)
uc.reg_write(unicorn.x86_const.UC_X86_REG_FPSW, status)
# we gotta convert the 64-bit doubles values to 80-bit extended precision!
uc_offset = unicorn.x86_const.UC_X86_REG_FP0
vex_offset = self.state.arch.registers['fpu_regs'][0]
vex_tag_offset = self.state.arch.registers['fpu_tags'][0]
tag_word = 0
for _ in xrange(8):
tag = self.state.se.eval(self.state.registers.load(vex_tag_offset, size=1))
tag_word <<= 2
if tag == 0:
tag_word |= 3 # unicorn doesn't care about any value other than 3 for setting
else:
val = self._process_value(self.state.registers.load(vex_offset, size=8), 'reg')
if val is None:
raise SimValueError('setting a symbolic fp register')
val = self.state.se.eval(val)
sign = bool(val & 0x8000000000000000)
exponent = (val & 0x7FF0000000000000) >> 52
mantissa = val & 0x000FFFFFFFFFFFFF
if exponent not in (0, 0x7FF): # normal value
exponent = exponent - 1023 + 16383
mantissa <<= 11
mantissa |= 0x8000000000000000 # set integer part bit, implicit to double
elif exponent == 0: # zero or subnormal value
mantissa = 0
elif exponent == 0x7FF: # nan or infinity
exponent = 0x7FFF
if mantissa != 0:
mantissa = 0x8000000000000000
else:
mantissa = 0xFFFFFFFFFFFFFFFF
if sign:
exponent |= 0x8000
uc.reg_write(uc_offset, (exponent, mantissa))
uc_offset += 1
vex_offset += 8
vex_tag_offset += 1
uc.reg_write(unicorn.x86_const.UC_X86_REG_FPTAG, tag_word)
# this stuff is 100% copied from the unicorn regression tests
def setup_gdt(self, fs, gs, fs_size=0xFFFFFFFF, gs_size=0xFFFFFFFF):
GDT_ADDR = 0x1000
GDT_LIMIT = 0x1000
A_PRESENT = 0x80
A_DATA = 0x10
A_DATA_WRITABLE = 0x2
A_PRIV_0 = 0x0
A_DIR_CON_BIT = 0x4
F_PROT_32 = 0x4
S_GDT = 0x0
S_PRIV_0 = 0x0
uc = self.uc
uc.mem_map(GDT_ADDR, GDT_LIMIT)
normal_entry = self.create_gdt_entry(0, 0xFFFFFFFF, A_PRESENT | A_DATA | A_DATA_WRITABLE | A_PRIV_0 | A_DIR_CON_BIT, F_PROT_32)
stack_entry = self.create_gdt_entry(0, 0xFFFFFFFF, A_PRESENT | A_DATA | A_DATA_WRITABLE | A_PRIV_0, F_PROT_32)
fs_entry = self.create_gdt_entry(fs, fs_size, A_PRESENT | A_DATA | A_DATA_WRITABLE | A_PRIV_0 | A_DIR_CON_BIT, F_PROT_32)
gs_entry = self.create_gdt_entry(gs, gs_size, A_PRESENT | A_DATA | A_DATA_WRITABLE | A_PRIV_0 | A_DIR_CON_BIT, F_PROT_32)
uc.mem_write(GDT_ADDR + 8, normal_entry + stack_entry + fs_entry + gs_entry)
uc.reg_write(self._uc_const.UC_X86_REG_GDTR, (0, GDT_ADDR, GDT_LIMIT, 0x0))
selector = self.create_selector(1, S_GDT | S_PRIV_0)
uc.reg_write(self._uc_const.UC_X86_REG_CS, selector)
uc.reg_write(self._uc_const.UC_X86_REG_DS, selector)
uc.reg_write(self._uc_const.UC_X86_REG_ES, selector)
selector = self.create_selector(2, S_GDT | S_PRIV_0)
uc.reg_write(self._uc_const.UC_X86_REG_SS, selector)
selector = self.create_selector(3, S_GDT | S_PRIV_0)
uc.reg_write(self._uc_const.UC_X86_REG_FS, selector)
selector = self.create_selector(4, S_GDT | S_PRIV_0)
uc.reg_write(self._uc_const.UC_X86_REG_GS, selector)
uc.mem_unmap(GDT_ADDR, GDT_LIMIT)
@staticmethod
def create_selector(idx, flags):
to_ret = flags
to_ret |= idx << 3
return to_ret
@staticmethod
def create_gdt_entry(base, limit, access, flags):
to_ret = limit & 0xffff
to_ret |= (base & 0xffffff) << 16
to_ret |= (access & 0xff) << 40
to_ret |= ((limit >> 16) & 0xf) << 48
to_ret |= (flags & 0xff) << 52
to_ret |= ((base >> 24) & 0xff) << 56
return struct.pack('<Q', to_ret)
# do NOT call either of these functions in a callback, lmao
def read_msr(self, msr=0xC0000100):
setup_code = '\x0f\x32'
BASE = 0x100B000000
uc = self.uc
uc.mem_map(BASE, 0x1000)
uc.mem_write(BASE, setup_code)
uc.reg_write(self._uc_const.UC_X86_REG_RCX, msr)
uc.emu_start(BASE, BASE + len(setup_code))
uc.mem_unmap(BASE, 0x1000)
a = uc.reg_read(self._uc_const.UC_X86_REG_RAX)
d = uc.reg_read(self._uc_const.UC_X86_REG_RDX)
return (d << 32) + a
def write_msr(self, val, msr=0xC0000100):
setup_code = '\x0f\x30'
BASE = 0x100B000000
uc = self.uc
uc.mem_map(BASE, 0x1000)
uc.mem_write(BASE, setup_code)
uc.reg_write(self._uc_const.UC_X86_REG_RCX, msr)
uc.reg_write(self._uc_const.UC_X86_REG_RAX, val & 0xFFFFFFFF)
uc.reg_write(self._uc_const.UC_X86_REG_RDX, val >> 32)
uc.emu_start(BASE, BASE + len(setup_code))
uc.mem_unmap(BASE, 0x1000)
reg_blacklist = ('cs', 'ds', 'es', 'fs', 'gs', 'ss', 'mm0', 'mm1', 'mm2', 'mm3', 'mm4', 'mm5', 'mm6', 'mm7')
def get_regs(self):
''' loading registers from unicorn '''
# first, get the ignore list (in case of symbolic registers)
if options.UNICORN_SYM_REGS_SUPPORT in self.state.options:
highest_reg_offset, reg_size = max(self.state.arch.registers.values())
symbolic_list = (ctypes.c_uint64*(highest_reg_offset + reg_size))()
num_regs = _UC_NATIVE.get_symbolic_registers(self._uc_state, symbolic_list)
# we take the approach of saving off the symbolic regs and then writing them back
saved_registers = [ ]
cur_group = None
last = None
for i in sorted(symbolic_list[:num_regs]):
if cur_group is None:
cur_group = i
elif i != last + 1 or cur_group/self.state.arch.bytes != i/self.state.arch.bytes:
saved_registers.append((
cur_group, self.state.registers.load(cur_group, last-cur_group+1)
))
cur_group = i
last = i
if cur_group is not None:
saved_registers.append((
cur_group, self.state.registers.load(cur_group, last-cur_group+1)
))
# now we sync registers out of unicorn
for r, c in self._uc_regs.iteritems():
if r in self.reg_blacklist:
continue
v = self.uc.reg_read(c)
# l.debug('getting $%s = %#x', r, v)
setattr(self.state.regs, r, v)
# some architecture-specific register fixups
if self.state.arch.name in ('X86', 'AMD64'):
if self.jumpkind.startswith('Ijk_Sys'):
self.state.registers.store('ip_at_syscall', self.state.regs.ip - 2)
# update the eflags
self.state.regs.cc_dep1 = self.state.se.BVV(self.uc.reg_read(self._uc_const.UC_X86_REG_EFLAGS), self.state.arch.bits)
self.state.regs.cc_op = ccall.data[self.state.arch.name]['OpTypes']['G_CC_OP_COPY']
# sync the fp clerical data
status = self.uc.reg_read(unicorn.x86_const.UC_X86_REG_FPSW)
c3210 = status & 0x4700
top = (status & 0x3800) >> 11
control = self.uc.reg_read(unicorn.x86_const.UC_X86_REG_FPCW)
rm = (control & 0x0C00) >> 10
self.state.regs.fpround = rm
self.state.regs.fc3210 = c3210
self.state.regs.ftop = top
# sync the stx registers
# we gotta round the 80-bit extended precision values to 64-bit doubles!
uc_offset = unicorn.x86_const.UC_X86_REG_FP0
vex_offset = self.state.arch.registers['fpu_regs'][0]
vex_tag_offset = self.state.arch.registers['fpu_tags'][0] + 7
tag_word = self.uc.reg_read(unicorn.x86_const.UC_X86_REG_FPTAG)
for _ in xrange(8):
if tag_word & 3 == 3:
self.state.registers.store(vex_tag_offset, 0, size=1)
else:
self.state.registers.store(vex_tag_offset, 1, size=1)
mantissa, exponent = self.uc.reg_read(uc_offset)
sign = bool(exponent & 0x8000)
exponent = (exponent & 0x7FFF)
if exponent not in (0, 0x7FFF): # normal value
exponent = exponent - 16383 + 1023
if exponent <= 0: # underflow to zero
exponent = 0
mantissa = 0
elif exponent >= 0x7FF: # overflow to infinity
exponent = 0x7FF
mantissa = 0
elif exponent == 0: # zero or subnormal value
mantissa = 0
elif exponent == 0x7FFF: # nan or infinity
exponent = 0x7FF
if mantissa != 0:
mantissa = 0xFFFF
val = 0x8000000000000000 if sign else 0
val |= exponent << 52
val |= (mantissa >> 11) & 0xFFFFFFFFFFFFF
# the mantissa calculation is to convert from the 64-bit mantissa to 52-bit
# additionally, extended precision keeps around an high bit that we don't care about
# so 11-shift, not 12
self.state.registers.store(vex_offset, val, size=8)
uc_offset += 1
vex_offset += 8
tag_word >>= 2
vex_tag_offset -= 1
# now, we restore the symbolic registers
if options.UNICORN_SYM_REGS_SUPPORT in self.state.options:
for o,r in saved_registers:
self.state.registers.store(o, r)
def _check_registers(self, report=True):
''' check if this state might be used in unicorn (has no concrete register)'''
for r in self.state.arch.uc_regs.iterkeys():
v = getattr(self.state.regs, r)
processed_v = self._process_value(v, 'reg')
if processed_v is None or processed_v.symbolic:
#l.info('detected symbolic register %s', r)
if report:
self._report_symbolic_blocker(v, 'reg')
return False
if self.state.arch.vex_conditional_helpers:
flags = ccall._get_flags(self.state)[0]
processed_flags = self._process_value(flags, 'reg')
if processed_flags is None or processed_flags.symbolic:
#l.info("detected symbolic rflags/eflags")
if report:
self._report_symbolic_blocker(flags, 'reg')
return False
#l.debug('passed quick check')
return True
from ..engines.vex import ccall
from .. import sim_options as options
SimStatePlugin.register_default('unicorn', Unicorn)
|
bsd-2-clause
|
[
646,
747,
199,
646,
984,
199,
646,
1331,
199,
646,
2702,
199,
646,
5577,
199,
646,
5796,
199,
646,
7975,
199,
646,
5496,
63,
4435,
199,
199,
646,
2050,
199,
199,
504,
2508,
5206,
63,
1419,
492,
6778,
948,
32080,
63,
15885,
63,
17433,
4029,
649,
63,
4669,
5153,
1761,
199,
199,
76,
275,
2050,
14,
5572,
480,
621,
82,
14,
929,
63,
5265,
14,
29067,
63,
3908,
531,
199,
199,
893,
26,
272,
492,
625,
530,
6161,
199,
2590,
3545,
26,
272,
634,
14,
3764,
480,
1358,
530,
6161,
365,
440,
4903,
14,
12502,
6980,
2685,
272,
625,
530,
6161,
275,
488,
199,
199,
646,
1134,
26221,
199,
646,
824,
759,
647,
199,
504,
1275,
2718,
492,
10751,
2223,
5061,
199,
504,
2508,
2550,
492,
10751,
3393,
12,
10751,
1358,
530,
6161,
9251,
384,
719,
12,
10751,
19689,
1879,
547,
12,
10751,
8628,
547,
199,
199,
533,
31424,
63,
17073,
8,
9798,
14,
10766,
304,
327,
7573,
63,
873,
63,
84,
272,
986,
199,
199,
10293,
63,
17073,
423,
955,
63,
275,
359,
267,
661,
1562,
297,
5577,
14,
67,
63,
1635,
772,
395,
267,
661,
1267,
297,
5577,
14,
67,
63,
1635,
772,
395,
267,
661,
2184,
297,
5577,
14,
11260,
8,
10293,
63,
17073,
430,
272,
1622,
199,
199,
533,
18634,
4029,
649,
63,
15060,
8,
9798,
14,
10766,
304,
327,
27754,
63,
3059,
63,
84,
272,
986,
199,
199,
17433,
4029,
649,
63,
15060,
423,
955,
63,
275,
359,
267,
661,
576,
297,
5577,
14,
67,
63,
1647,
63,
80,
395,
267,
661,
835,
297,
5577,
14,
67,
63,
1635,
708,
9,
272,
1622,
199,
199,
533,
22348,
8,
785,
304,
327,
3631,
63,
84,
272,
22348,
63,
10765,
260,
275,
378,
272,
22348,
63,
11632,
7217,
420,
275,
413,
272,
22348,
63,
10527,
948,
63,
10293,
257,
275,
499,
272,
22348,
63,
10527,
948,
63,
5616,
257,
275,
650,
272,
22348,
63,
3170,
3515,
275,
841,
272,
22348,
63,
4669,
5153,
1761,
263,
275,
959,
272,
22348,
63,
10276,
9185,
755,
275,
1227,
272,
22348,
63,
58,
540,
1938,
2962,
755,
275,
1520,
272,
22348,
63,
2826,
7363,
263,
275,
1695,
272,
22348,
63,
21981,
2794,
755,
275,
1749,
339,
768,
4639,
272,
347,
536,
63,
2379,
8,
1507,
304,
267,
367,
1242,
315,
2935,
8,
11632,
304,
288,
340,
1242,
14,
2460,
360,
11632,
15452,
436,
2519,
8,
11632,
12,
1242,
9,
508,
1967,
26,
355,
372,
1242,
199,
199,
3,
199,
3,
15825,
4412,
2552,
446,
1454,
1202,
14448,
199,
3,
199,
199,
533,
15825,
7674,
547,
8,
1726,
304,
272,
986,
199,
199,
533,
11003,
316,
8681,
3276,
547,
8,
8628,
7674,
547,
304,
272,
986,
199,
199,
533,
16347,
316,
8681,
3276,
547,
8,
8628,
7674,
547,
304,
272,
986,
199,
199,
533,
3240,
71,
1879,
547,
8,
8628,
7674,
547,
304,
272,
986,
199,
199,
533,
21203,
2623,
1292,
834,
83,
547,
8,
8628,
7674,
547,
304,
272,
986,
199,
199,
3,
199,
3,
961,
11262,
365,
3483,
370,
9565,
626,
1910,
530,
6161,
12821,
315,
1839,
25787,
406,
1353,
280,
13362,
818,
199,
3,
199,
199,
533,
18693,
470,
3398,
714,
1353,
280,
13362,
16768,
8,
429,
759,
647,
14,
51,
3236,
317,
3477,
33,
1647,
554,
16768,
304,
272,
347,
636,
826,
721,
277,
12,
5552,
304,
267,
824,
759,
647,
14,
51,
3236,
317,
3477,
33,
1647,
554,
16768,
855,
826,
721,
277,
9,
267,
291,
14,
29067,
63,
928,
63,
2697,
275,
5552,
199,
199,
3,
199,
3,
13821,
1910,
530,
6161,
1026,
14631,
2839,
286,
30566,
12,
781,
675,
1373,
738,
67,
909,
1126,
2462,
1396,
199,
3,
199,
199,
63,
5411,
5337,
275,
7975,
14,
835,
342,
199,
199,
533,
1910,
73,
5029,
8,
29067,
14,
53,
67,
340,
625,
530,
6161,
365,
440,
488,
587,
909,
304,
272,
327,
4287,
26,
3507,
29,
2865,
13,
1708,
13,
826,
13,
3527,
272,
347,
636,
826,
721,
277,
12,
3819,
12,
2581,
63,
498,
304,
267,
634,
14,
1757,
480,
14380,
625,
530,
6161,
1174,
9124,
267,
291,
14,
1047,
275,
3819,
267,
291,
14,
1637,
63,
498,
275,
2581,
63,
498,
267,
291,
14,
9130,
63,
11663,
275,
663,
342,
267,
291,
14,
9130,
63,
7922,
275,
663,
342,
267,
291,
14,
344,
275,
488,
267,
625,
530,
6161,
14,
53,
67,
855,
826,
721,
277,
12,
3819,
14,
947,
63,
1047,
12,
3819,
14,
947,
63,
632,
9,
339,
347,
5759,
63,
525,
8,
277,
12,
394,
466,
12,
3233,
12,
922,
63,
576,
29,
403,
12,
5386,
29,
17,
12,
1284,
29,
16,
12,
1680,
17,
29,
16,
304,
267,
394,
275,
625,
530,
6161,
14,
53,
67,
14,
3664,
63,
525,
8,
277,
12,
394,
466,
12,
3233,
12,
922,
63,
576,
29,
751,
63,
576,
12,
5386,
29,
5037,
12,
1284,
29,
500,
12,
1680,
17,
29,
1273,
17,
9,
267,
327,
76,
14,
1757,
480,
8481,
26,
450,
83,
8719,
83,
1035,
450,
83,
401,
394,
466,
12,
3233,
855,
354,
3108,
394,
9,
267,
291,
14,
9130,
63,
7922,
14,
525,
8,
72,
9,
267,
372,
394,
339,
347,
5759,
63,
2264,
8,
277,
12,
394,
304,
267,
327,
76,
14,
1757,
480,
9721,
316,
5759,
450,
83,
401,
394,
9,
267,
394,
275,
625,
530,
6161,
14,
53,
67,
14,
3664,
63,
2264,
8,
277,
12,
394,
9,
267,
291,
14,
9130,
63,
7922,
14,
14394,
8,
72,
9,
267,
372,
394,
339,
347,
7573,
63,
1130,
8,
277,
12,
5552,
12,
1568,
12,
17340,
29,
23,
304,
267,
327,
76,
14,
1757,
480,
7674,
450,
68,
2783,
737,
450,
3,
88,
401,
1568,
12,
5552,
9,
267,
333,
275,
625,
530,
6161,
14,
53,
67,
14,
5286,
63,
1130,
8,
277,
12,
5552,
12,
1568,
12,
17340,
29,
12068,
9,
267,
291,
14,
9130,
63,
11663,
14,
525,
1332,
2697,
12,
1568,
430,
267,
372,
333,
339,
347,
7573,
63,
324,
1130,
8,
277,
12,
5552,
12,
1568,
304,
267,
327,
76,
14,
1757,
480,
1358,
4745,
450,
68,
2783,
737,
450,
3,
88,
401,
1568,
12,
5552,
9,
267,
333,
275,
625,
530,
6161,
14,
53,
67,
14,
5286
] |
[
747,
199,
646,
984,
199,
646,
1331,
199,
646,
2702,
199,
646,
5577,
199,
646,
5796,
199,
646,
7975,
199,
646,
5496,
63,
4435,
199,
199,
646,
2050,
199,
199,
504,
2508,
5206,
63,
1419,
492,
6778,
948,
32080,
63,
15885,
63,
17433,
4029,
649,
63,
4669,
5153,
1761,
199,
199,
76,
275,
2050,
14,
5572,
480,
621,
82,
14,
929,
63,
5265,
14,
29067,
63,
3908,
531,
199,
199,
893,
26,
272,
492,
625,
530,
6161,
199,
2590,
3545,
26,
272,
634,
14,
3764,
480,
1358,
530,
6161,
365,
440,
4903,
14,
12502,
6980,
2685,
272,
625,
530,
6161,
275,
488,
199,
199,
646,
1134,
26221,
199,
646,
824,
759,
647,
199,
504,
1275,
2718,
492,
10751,
2223,
5061,
199,
504,
2508,
2550,
492,
10751,
3393,
12,
10751,
1358,
530,
6161,
9251,
384,
719,
12,
10751,
19689,
1879,
547,
12,
10751,
8628,
547,
199,
199,
533,
31424,
63,
17073,
8,
9798,
14,
10766,
304,
327,
7573,
63,
873,
63,
84,
272,
986,
199,
199,
10293,
63,
17073,
423,
955,
63,
275,
359,
267,
661,
1562,
297,
5577,
14,
67,
63,
1635,
772,
395,
267,
661,
1267,
297,
5577,
14,
67,
63,
1635,
772,
395,
267,
661,
2184,
297,
5577,
14,
11260,
8,
10293,
63,
17073,
430,
272,
1622,
199,
199,
533,
18634,
4029,
649,
63,
15060,
8,
9798,
14,
10766,
304,
327,
27754,
63,
3059,
63,
84,
272,
986,
199,
199,
17433,
4029,
649,
63,
15060,
423,
955,
63,
275,
359,
267,
661,
576,
297,
5577,
14,
67,
63,
1647,
63,
80,
395,
267,
661,
835,
297,
5577,
14,
67,
63,
1635,
708,
9,
272,
1622,
199,
199,
533,
22348,
8,
785,
304,
327,
3631,
63,
84,
272,
22348,
63,
10765,
260,
275,
378,
272,
22348,
63,
11632,
7217,
420,
275,
413,
272,
22348,
63,
10527,
948,
63,
10293,
257,
275,
499,
272,
22348,
63,
10527,
948,
63,
5616,
257,
275,
650,
272,
22348,
63,
3170,
3515,
275,
841,
272,
22348,
63,
4669,
5153,
1761,
263,
275,
959,
272,
22348,
63,
10276,
9185,
755,
275,
1227,
272,
22348,
63,
58,
540,
1938,
2962,
755,
275,
1520,
272,
22348,
63,
2826,
7363,
263,
275,
1695,
272,
22348,
63,
21981,
2794,
755,
275,
1749,
339,
768,
4639,
272,
347,
536,
63,
2379,
8,
1507,
304,
267,
367,
1242,
315,
2935,
8,
11632,
304,
288,
340,
1242,
14,
2460,
360,
11632,
15452,
436,
2519,
8,
11632,
12,
1242,
9,
508,
1967,
26,
355,
372,
1242,
199,
199,
3,
199,
3,
15825,
4412,
2552,
446,
1454,
1202,
14448,
199,
3,
199,
199,
533,
15825,
7674,
547,
8,
1726,
304,
272,
986,
199,
199,
533,
11003,
316,
8681,
3276,
547,
8,
8628,
7674,
547,
304,
272,
986,
199,
199,
533,
16347,
316,
8681,
3276,
547,
8,
8628,
7674,
547,
304,
272,
986,
199,
199,
533,
3240,
71,
1879,
547,
8,
8628,
7674,
547,
304,
272,
986,
199,
199,
533,
21203,
2623,
1292,
834,
83,
547,
8,
8628,
7674,
547,
304,
272,
986,
199,
199,
3,
199,
3,
961,
11262,
365,
3483,
370,
9565,
626,
1910,
530,
6161,
12821,
315,
1839,
25787,
406,
1353,
280,
13362,
818,
199,
3,
199,
199,
533,
18693,
470,
3398,
714,
1353,
280,
13362,
16768,
8,
429,
759,
647,
14,
51,
3236,
317,
3477,
33,
1647,
554,
16768,
304,
272,
347,
636,
826,
721,
277,
12,
5552,
304,
267,
824,
759,
647,
14,
51,
3236,
317,
3477,
33,
1647,
554,
16768,
855,
826,
721,
277,
9,
267,
291,
14,
29067,
63,
928,
63,
2697,
275,
5552,
199,
199,
3,
199,
3,
13821,
1910,
530,
6161,
1026,
14631,
2839,
286,
30566,
12,
781,
675,
1373,
738,
67,
909,
1126,
2462,
1396,
199,
3,
199,
199,
63,
5411,
5337,
275,
7975,
14,
835,
342,
199,
199,
533,
1910,
73,
5029,
8,
29067,
14,
53,
67,
340,
625,
530,
6161,
365,
440,
488,
587,
909,
304,
272,
327,
4287,
26,
3507,
29,
2865,
13,
1708,
13,
826,
13,
3527,
272,
347,
636,
826,
721,
277,
12,
3819,
12,
2581,
63,
498,
304,
267,
634,
14,
1757,
480,
14380,
625,
530,
6161,
1174,
9124,
267,
291,
14,
1047,
275,
3819,
267,
291,
14,
1637,
63,
498,
275,
2581,
63,
498,
267,
291,
14,
9130,
63,
11663,
275,
663,
342,
267,
291,
14,
9130,
63,
7922,
275,
663,
342,
267,
291,
14,
344,
275,
488,
267,
625,
530,
6161,
14,
53,
67,
855,
826,
721,
277,
12,
3819,
14,
947,
63,
1047,
12,
3819,
14,
947,
63,
632,
9,
339,
347,
5759,
63,
525,
8,
277,
12,
394,
466,
12,
3233,
12,
922,
63,
576,
29,
403,
12,
5386,
29,
17,
12,
1284,
29,
16,
12,
1680,
17,
29,
16,
304,
267,
394,
275,
625,
530,
6161,
14,
53,
67,
14,
3664,
63,
525,
8,
277,
12,
394,
466,
12,
3233,
12,
922,
63,
576,
29,
751,
63,
576,
12,
5386,
29,
5037,
12,
1284,
29,
500,
12,
1680,
17,
29,
1273,
17,
9,
267,
327,
76,
14,
1757,
480,
8481,
26,
450,
83,
8719,
83,
1035,
450,
83,
401,
394,
466,
12,
3233,
855,
354,
3108,
394,
9,
267,
291,
14,
9130,
63,
7922,
14,
525,
8,
72,
9,
267,
372,
394,
339,
347,
5759,
63,
2264,
8,
277,
12,
394,
304,
267,
327,
76,
14,
1757,
480,
9721,
316,
5759,
450,
83,
401,
394,
9,
267,
394,
275,
625,
530,
6161,
14,
53,
67,
14,
3664,
63,
2264,
8,
277,
12,
394,
9,
267,
291,
14,
9130,
63,
7922,
14,
14394,
8,
72,
9,
267,
372,
394,
339,
347,
7573,
63,
1130,
8,
277,
12,
5552,
12,
1568,
12,
17340,
29,
23,
304,
267,
327,
76,
14,
1757,
480,
7674,
450,
68,
2783,
737,
450,
3,
88,
401,
1568,
12,
5552,
9,
267,
333,
275,
625,
530,
6161,
14,
53,
67,
14,
5286,
63,
1130,
8,
277,
12,
5552,
12,
1568,
12,
17340,
29,
12068,
9,
267,
291,
14,
9130,
63,
11663,
14,
525,
1332,
2697,
12,
1568,
430,
267,
372,
333,
339,
347,
7573,
63,
324,
1130,
8,
277,
12,
5552,
12,
1568,
304,
267,
327,
76,
14,
1757,
480,
1358,
4745,
450,
68,
2783,
737,
450,
3,
88,
401,
1568,
12,
5552,
9,
267,
333,
275,
625,
530,
6161,
14,
53,
67,
14,
5286,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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copyright (C) 2009 Luke Kenneth Casson Leighton <lkcl@lkcl.net>
#
# 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 pyjamas import DOM
from pyjamas import Factory
from Label import Label
from pyjamas.ui import Event
from pyjamas.ui import InnerHTML
class HTML(Label, InnerHTML):
def __init__(self, html=None, wordWrap=True, Element=None, **kwargs):
if not kwargs.has_key('StyleName'): kwargs['StyleName']="gwt-HTML"
if html: kwargs['HTML'] = html
kwargs['WordWrap'] = wordWrap
if Element is None:
Element = DOM.createDiv()
self.setElement(Element)
Label.__init__(self, **kwargs)
self.sinkEvents(Event.ONCLICK | Event.MOUSEEVENTS)
Factory.registerClass('pyjamas.ui.HTML', HTML)
|
apache-2.0
|
[
3,
1898,
8315,
1603,
14015,
32316,
10400,
436,
8417,
199,
3,
1898,
334,
35,
9,
8937,
30936,
415,
1804,
287,
685,
273,
445,
405,
265,
7005,
1070,
265,
665,
23333,
429,
32,
23333,
429,
14,
846,
30,
199,
3,
199,
3,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
199,
3,
1265,
1443,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
199,
3,
2047,
1443,
3332,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
258,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
199,
3,
2428,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
199,
3,
1666,
314,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
199,
3,
4204,
1334,
314,
844,
14,
199,
504,
1134,
16997,
305,
492,
14316,
199,
504,
1134,
16997,
305,
492,
23616,
199,
199,
504,
10354,
492,
10354,
199,
504,
1134,
16997,
305,
14,
1907,
492,
6763,
199,
504,
1134,
16997,
305,
14,
1907,
492,
19646,
4943,
199,
199,
533,
4163,
8,
4314,
12,
19646,
4943,
304,
339,
347,
636,
826,
721,
277,
12,
3517,
29,
403,
12,
4349,
15991,
29,
549,
12,
6566,
29,
403,
12,
1011,
958,
304,
267,
340,
440,
2074,
14,
1989,
63,
498,
360,
6609,
985,
735,
2074,
459,
6609,
985,
418,
628,
8392,
84,
13,
4943,
2,
267,
340,
3517,
26,
2074,
459,
4943,
418,
275,
3517,
267,
2074,
459,
10155,
15991,
418,
275,
4349,
15991,
267,
340,
6566,
365,
488,
26,
288,
6566,
275,
14316,
14,
981,
24305,
342,
267,
291,
14,
409,
2162,
8,
2162,
9,
267,
10354,
855,
826,
721,
277,
12,
1011,
958,
9,
267,
291,
14,
11279,
11770,
8,
2390,
14,
615,
1981,
13884,
1204,
6763,
14,
25571,
8193,
51,
9,
199,
199,
2927,
14,
2683,
2543,
360,
647,
16997,
305,
14,
1907,
14,
4943,
297,
4163,
9,
421,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
1898,
8315,
1603,
14015,
32316,
10400,
436,
8417,
199,
3,
1898,
334,
35,
9,
8937,
30936,
415,
1804,
287,
685,
273,
445,
405,
265,
7005,
1070,
265,
665,
23333,
429,
32,
23333,
429,
14,
846,
30,
199,
3,
199,
3,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
199,
3,
1265,
1443,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
199,
3,
2047,
1443,
3332,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
258,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
199,
3,
2428,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
199,
3,
1666,
314,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
199,
3,
4204,
1334,
314,
844,
14,
199,
504,
1134,
16997,
305,
492,
14316,
199,
504,
1134,
16997,
305,
492,
23616,
199,
199,
504,
10354,
492,
10354,
199,
504,
1134,
16997,
305,
14,
1907,
492,
6763,
199,
504,
1134,
16997,
305,
14,
1907,
492,
19646,
4943,
199,
199,
533,
4163,
8,
4314,
12,
19646,
4943,
304,
339,
347,
636,
826,
721,
277,
12,
3517,
29,
403,
12,
4349,
15991,
29,
549,
12,
6566,
29,
403,
12,
1011,
958,
304,
267,
340,
440,
2074,
14,
1989,
63,
498,
360,
6609,
985,
735,
2074,
459,
6609,
985,
418,
628,
8392,
84,
13,
4943,
2,
267,
340,
3517,
26,
2074,
459,
4943,
418,
275,
3517,
267,
2074,
459,
10155,
15991,
418,
275,
4349,
15991,
267,
340,
6566,
365,
488,
26,
288,
6566,
275,
14316,
14,
981,
24305,
342,
267,
291,
14,
409,
2162,
8,
2162,
9,
267,
10354,
855,
826,
721,
277,
12,
1011,
958,
9,
267,
291,
14,
11279,
11770,
8,
2390,
14,
615,
1981,
13884,
1204,
6763,
14,
25571,
8193,
51,
9,
199,
199,
2927,
14,
2683,
2543,
360,
647,
16997,
305,
14,
1907,
14,
4943,
297,
4163,
9,
421,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
jlcarmic/producthunt_simulator
|
venv/lib/python2.7/site-packages/scipy/optimize/_trustregion_dogleg.py
|
135
|
4449
|
"""Dog-leg trust-region optimization."""
from __future__ import division, print_function, absolute_import
import numpy as np
import scipy.linalg
from ._trustregion import (_minimize_trust_region, BaseQuadraticSubproblem)
__all__ = []
def _minimize_dogleg(fun, x0, args=(), jac=None, hess=None,
**trust_region_options):
"""
Minimization of scalar function of one or more variables using
the dog-leg trust-region algorithm.
Options
-------
initial_trust_radius : float
Initial trust-region radius.
max_trust_radius : float
Maximum value of the trust-region radius. No steps that are longer
than this value will be proposed.
eta : float
Trust region related acceptance stringency for proposed steps.
gtol : float
Gradient norm must be less than `gtol` before successful
termination.
"""
if jac is None:
raise ValueError('Jacobian is required for dogleg minimization')
if hess is None:
raise ValueError('Hessian is required for dogleg minimization')
return _minimize_trust_region(fun, x0, args=args, jac=jac, hess=hess,
subproblem=DoglegSubproblem,
**trust_region_options)
class DoglegSubproblem(BaseQuadraticSubproblem):
"""Quadratic subproblem solved by the dogleg method"""
def cauchy_point(self):
"""
The Cauchy point is minimal along the direction of steepest descent.
"""
if self._cauchy_point is None:
g = self.jac
Bg = self.hessp(g)
self._cauchy_point = -(np.dot(g, g) / np.dot(g, Bg)) * g
return self._cauchy_point
def newton_point(self):
"""
The Newton point is a global minimum of the approximate function.
"""
if self._newton_point is None:
g = self.jac
B = self.hess
cho_info = scipy.linalg.cho_factor(B)
self._newton_point = -scipy.linalg.cho_solve(cho_info, g)
return self._newton_point
def solve(self, trust_radius):
"""
Minimize a function using the dog-leg trust-region algorithm.
This algorithm requires function values and first and second derivatives.
It also performs a costly Hessian decomposition for most iterations,
and the Hessian is required to be positive definite.
Parameters
----------
trust_radius : float
We are allowed to wander only this far away from the origin.
Returns
-------
p : ndarray
The proposed step.
hits_boundary : bool
True if the proposed step is on the boundary of the trust region.
Notes
-----
The Hessian is required to be positive definite.
References
----------
.. [1] Jorge Nocedal and Stephen Wright,
Numerical Optimization, second edition,
Springer-Verlag, 2006, page 73.
"""
# Compute the Newton point.
# This is the optimum for the quadratic model function.
# If it is inside the trust radius then return this point.
p_best = self.newton_point()
if scipy.linalg.norm(p_best) < trust_radius:
hits_boundary = False
return p_best, hits_boundary
# Compute the Cauchy point.
# This is the predicted optimum along the direction of steepest descent.
p_u = self.cauchy_point()
# If the Cauchy point is outside the trust region,
# then return the point where the path intersects the boundary.
p_u_norm = scipy.linalg.norm(p_u)
if p_u_norm >= trust_radius:
p_boundary = p_u * (trust_radius / p_u_norm)
hits_boundary = True
return p_boundary, hits_boundary
# Compute the intersection of the trust region boundary
# and the line segment connecting the Cauchy and Newton points.
# This requires solving a quadratic equation.
# ||p_u + t*(p_best - p_u)||**2 == trust_radius**2
# Solve this for positive time t using the quadratic formula.
_, tb = self.get_boundaries_intersections(p_u, p_best - p_u,
trust_radius)
p_boundary = p_u + tb * (p_best - p_u)
hits_boundary = True
return p_boundary, hits_boundary
|
mit
|
[
624,
36,
974,
13,
4170,
16822,
13,
4551,
13712,
1041,
199,
504,
636,
2443,
363,
492,
4629,
12,
870,
63,
1593,
12,
3679,
63,
646,
199,
199,
646,
2680,
465,
980,
199,
646,
7026,
14,
10096,
199,
504,
13653,
15756,
4551,
492,
6110,
19333,
63,
15756,
63,
4551,
12,
3523,
23053,
19826,
2610,
6462,
9,
199,
199,
363,
452,
363,
275,
942,
421,
199,
318,
485,
19333,
63,
68,
1969,
71,
8,
7036,
12,
671,
16,
12,
1249,
16729,
21664,
29,
403,
12,
946,
385,
29,
403,
12,
2151,
1011,
15756,
63,
4551,
63,
1419,
304,
272,
408,
272,
10195,
1017,
2072,
402,
6917,
805,
402,
1373,
503,
1655,
2860,
1808,
272,
314,
23454,
13,
4170,
16822,
13,
4551,
5563,
14,
339,
8394,
272,
5514,
272,
2536,
63,
15756,
63,
8017,
520,
2069,
267,
6026,
16822,
13,
4551,
9362,
14,
272,
1390,
63,
15756,
63,
8017,
520,
2069,
267,
14212,
574,
402,
314,
16822,
13,
4551,
9362,
14,
3091,
7124,
626,
787,
8088,
267,
2419,
642,
574,
911,
506,
14075,
14,
272,
20356,
520,
2069,
267,
377,
19622,
4897,
4048,
4729,
554,
1059,
9501,
367,
14075,
7124,
14,
272,
486,
6896,
520,
2069,
267,
19603,
6316,
1471,
506,
6656,
2419,
658,
3308,
393,
64,
2544,
9512,
267,
23868,
14,
339,
408,
272,
340,
21664,
365,
488,
26,
267,
746,
1722,
360,
42,
22065,
365,
1415,
367,
886,
3845,
71,
18790,
2072,
358,
272,
340,
946,
385,
365,
488,
26,
267,
746,
1722,
360,
40,
21663,
365,
1415,
367,
886,
3845,
71,
18790,
2072,
358,
272,
372,
485,
19333,
63,
15756,
63,
4551,
8,
7036,
12,
671,
16,
12,
1249,
29,
589,
12,
21664,
29,
9299,
12,
946,
385,
29,
31421,
12,
3303,
1007,
6462,
29,
36,
1969,
71,
2610,
6462,
12,
3303,
1011,
15756,
63,
4551,
63,
1419,
9,
421,
199,
533,
577,
1969,
71,
2610,
6462,
8,
1563,
23053,
19826,
2610,
6462,
304,
272,
408,
23053,
19826,
1007,
6462,
308,
7064,
701,
314,
886,
3845,
71,
1083,
624,
339,
347,
1704,
30074,
63,
1403,
8,
277,
304,
267,
408,
267,
710,
8790,
30074,
2376,
365,
13460,
3180,
314,
7581,
402,
308,
15557,
321,
270,
31518,
14,
267,
408,
267,
340,
291,
423,
696,
30074,
63,
1403,
365,
488,
26,
288,
486,
275,
291,
14,
9299,
288,
699,
71,
275,
291,
14,
31421,
80,
8,
71,
9,
288,
291,
423,
696,
30074,
63,
1403,
275,
24953,
1590,
14,
3287,
8,
71,
12,
486,
9,
1182,
980,
14,
3287,
8,
71,
12,
699,
71,
430,
627,
486,
267,
372,
291,
423,
696,
30074,
63,
1403,
339,
347,
892,
1860,
63,
1403,
8,
277,
304,
267,
408,
267,
710,
7053,
1860,
2376,
365,
282,
2288,
7481,
402,
314,
19917,
805,
14,
267,
408,
267,
340,
291,
423,
1222,
1860,
63,
1403,
365,
488,
26,
288,
486,
275,
291,
14,
9299,
288,
699,
275,
291,
14,
31421,
288,
2468,
63,
815,
275,
7026,
14,
10096,
14,
2239,
63,
4778,
8,
34,
9,
288,
291,
423,
1222,
1860,
63,
1403,
275,
446,
14248,
14,
10096,
14,
2239,
63,
11356,
8,
2239,
63,
815,
12,
486,
9,
267,
372,
291,
423,
1222,
1860,
63,
1403,
339,
347,
14241,
8,
277,
12,
16822,
63,
8017,
304,
267,
408,
267,
10195,
11807,
282,
805,
1808,
314,
23454,
13,
4170,
16822,
13,
4551,
5563,
14,
398,
961,
5563,
5074,
805,
1338,
436,
1642,
436,
3499,
28059,
14,
267,
2779,
2597,
18628,
282,
7918,
590,
869,
21663,
22706,
367,
4750,
10615,
12,
267,
436,
314,
869,
21663,
365,
1415,
370,
506,
7317,
28088,
14,
398,
3897,
267,
4143,
267,
16822,
63,
8017,
520,
2069,
288,
2136,
787,
4370,
370,
336,
11438,
1454,
642,
12474,
13437,
687,
314,
6330,
14,
398,
1803,
267,
5514,
267,
299,
520,
6800,
288,
710,
14075,
3650,
14,
267,
19745,
63,
9891,
520,
2155,
288,
715,
340,
314,
14075,
3650,
365,
641,
314,
8424,
402,
314,
16822,
4897,
14,
398,
8144,
267,
9063,
267,
710,
869,
21663,
365,
1415,
370,
506,
7317,
28088,
14,
398,
14504,
267,
4143,
267,
2508,
359,
17,
61,
1603,
24591,
3091,
6867,
279,
436,
17854,
17579,
644,
1019,
12,
2049,
653,
27685,
19246,
2072,
12,
3499,
325,
1671,
12,
2049,
428,
2700,
7886,
13,
3673,
1823,
12,
8315,
12,
2034,
18525,
14,
267,
408,
398,
327,
8354,
314,
7053,
1860,
2376,
14,
267,
327,
961,
365,
314,
5323,
453,
367,
314,
16744,
19826,
1402,
805,
14,
267,
327,
982,
652,
365,
6272,
314,
16822,
9362,
2066,
372,
642,
2376,
14,
267,
299,
63,
7010,
275,
291,
14,
1222,
1860,
63,
1403,
342,
267,
340,
7026,
14,
10096,
14,
4791,
8,
80,
63,
7010,
9,
665,
16822,
63,
8017,
26,
288,
19745,
63,
9891,
275,
756,
288,
372,
299,
63,
7010,
12,
19745,
63,
9891,
398,
327,
8354,
314,
8790,
30074,
2376,
14,
267,
327,
961,
365,
314,
14746,
5323,
453,
3180,
314,
7581,
402,
308,
15557,
321,
270,
31518,
14,
267,
299,
63,
85,
275,
291,
14,
696,
30074,
63,
1403,
342,
398,
327,
982,
314,
8790,
30074,
2376,
365,
9682,
314,
16822,
4897,
12,
267,
327,
2066,
372,
314,
2376,
2382,
314,
931,
1640,
25353,
314,
8424,
14,
267,
299,
63,
85,
63,
4791,
275,
7026,
14,
10096,
14,
4791,
8,
80,
63,
85,
9,
267,
340,
299,
63,
85,
63,
4791,
2356,
16822,
63,
8017,
26,
288,
299,
63,
9891,
275,
299,
63,
85,
627,
334,
15756,
63,
8017,
1182,
299,
63,
85,
63,
4791,
9,
288,
19745,
63,
9891,
275,
715,
288,
372,
299,
63,
9891,
12,
19745,
63,
9891,
398,
327,
8354,
314,
16223,
402,
314,
16822,
4897,
8424,
267,
327,
436,
314,
1004,
8135,
18170,
314,
8790,
30074,
436,
7053,
1860,
4501,
14,
267,
327,
961,
5074,
8597,
4007,
282,
16744,
19826,
18649,
14,
267,
327,
12208,
80,
63,
85,
435,
307,
5830,
80,
63,
7010,
446,
299,
63,
85,
8636,
92,
538,
18,
508,
16822,
63,
8017,
538,
18,
267,
327,
428,
3344,
642,
367,
7317,
900,
307,
1808,
314,
16744,
19826,
15723,
14,
267,
5501,
7070,
275,
291,
14,
362,
63,
27505,
63,
1058,
7786,
8,
80,
63,
85,
12,
299,
63,
7010,
446,
299,
63,
85,
12,
8179,
16822,
63,
8017,
9,
267,
299,
63,
9891
] |
[
36,
974,
13,
4170,
16822,
13,
4551,
13712,
1041,
199,
504,
636,
2443,
363,
492,
4629,
12,
870,
63,
1593,
12,
3679,
63,
646,
199,
199,
646,
2680,
465,
980,
199,
646,
7026,
14,
10096,
199,
504,
13653,
15756,
4551,
492,
6110,
19333,
63,
15756,
63,
4551,
12,
3523,
23053,
19826,
2610,
6462,
9,
199,
199,
363,
452,
363,
275,
942,
421,
199,
318,
485,
19333,
63,
68,
1969,
71,
8,
7036,
12,
671,
16,
12,
1249,
16729,
21664,
29,
403,
12,
946,
385,
29,
403,
12,
2151,
1011,
15756,
63,
4551,
63,
1419,
304,
272,
408,
272,
10195,
1017,
2072,
402,
6917,
805,
402,
1373,
503,
1655,
2860,
1808,
272,
314,
23454,
13,
4170,
16822,
13,
4551,
5563,
14,
339,
8394,
272,
5514,
272,
2536,
63,
15756,
63,
8017,
520,
2069,
267,
6026,
16822,
13,
4551,
9362,
14,
272,
1390,
63,
15756,
63,
8017,
520,
2069,
267,
14212,
574,
402,
314,
16822,
13,
4551,
9362,
14,
3091,
7124,
626,
787,
8088,
267,
2419,
642,
574,
911,
506,
14075,
14,
272,
20356,
520,
2069,
267,
377,
19622,
4897,
4048,
4729,
554,
1059,
9501,
367,
14075,
7124,
14,
272,
486,
6896,
520,
2069,
267,
19603,
6316,
1471,
506,
6656,
2419,
658,
3308,
393,
64,
2544,
9512,
267,
23868,
14,
339,
408,
272,
340,
21664,
365,
488,
26,
267,
746,
1722,
360,
42,
22065,
365,
1415,
367,
886,
3845,
71,
18790,
2072,
358,
272,
340,
946,
385,
365,
488,
26,
267,
746,
1722,
360,
40,
21663,
365,
1415,
367,
886,
3845,
71,
18790,
2072,
358,
272,
372,
485,
19333,
63,
15756,
63,
4551,
8,
7036,
12,
671,
16,
12,
1249,
29,
589,
12,
21664,
29,
9299,
12,
946,
385,
29,
31421,
12,
3303,
1007,
6462,
29,
36,
1969,
71,
2610,
6462,
12,
3303,
1011,
15756,
63,
4551,
63,
1419,
9,
421,
199,
533,
577,
1969,
71,
2610,
6462,
8,
1563,
23053,
19826,
2610,
6462,
304,
272,
408,
23053,
19826,
1007,
6462,
308,
7064,
701,
314,
886,
3845,
71,
1083,
624,
339,
347,
1704,
30074,
63,
1403,
8,
277,
304,
267,
408,
267,
710,
8790,
30074,
2376,
365,
13460,
3180,
314,
7581,
402,
308,
15557,
321,
270,
31518,
14,
267,
408,
267,
340,
291,
423,
696,
30074,
63,
1403,
365,
488,
26,
288,
486,
275,
291,
14,
9299,
288,
699,
71,
275,
291,
14,
31421,
80,
8,
71,
9,
288,
291,
423,
696,
30074,
63,
1403,
275,
24953,
1590,
14,
3287,
8,
71,
12,
486,
9,
1182,
980,
14,
3287,
8,
71,
12,
699,
71,
430,
627,
486,
267,
372,
291,
423,
696,
30074,
63,
1403,
339,
347,
892,
1860,
63,
1403,
8,
277,
304,
267,
408,
267,
710,
7053,
1860,
2376,
365,
282,
2288,
7481,
402,
314,
19917,
805,
14,
267,
408,
267,
340,
291,
423,
1222,
1860,
63,
1403,
365,
488,
26,
288,
486,
275,
291,
14,
9299,
288,
699,
275,
291,
14,
31421,
288,
2468,
63,
815,
275,
7026,
14,
10096,
14,
2239,
63,
4778,
8,
34,
9,
288,
291,
423,
1222,
1860,
63,
1403,
275,
446,
14248,
14,
10096,
14,
2239,
63,
11356,
8,
2239,
63,
815,
12,
486,
9,
267,
372,
291,
423,
1222,
1860,
63,
1403,
339,
347,
14241,
8,
277,
12,
16822,
63,
8017,
304,
267,
408,
267,
10195,
11807,
282,
805,
1808,
314,
23454,
13,
4170,
16822,
13,
4551,
5563,
14,
398,
961,
5563,
5074,
805,
1338,
436,
1642,
436,
3499,
28059,
14,
267,
2779,
2597,
18628,
282,
7918,
590,
869,
21663,
22706,
367,
4750,
10615,
12,
267,
436,
314,
869,
21663,
365,
1415,
370,
506,
7317,
28088,
14,
398,
3897,
267,
4143,
267,
16822,
63,
8017,
520,
2069,
288,
2136,
787,
4370,
370,
336,
11438,
1454,
642,
12474,
13437,
687,
314,
6330,
14,
398,
1803,
267,
5514,
267,
299,
520,
6800,
288,
710,
14075,
3650,
14,
267,
19745,
63,
9891,
520,
2155,
288,
715,
340,
314,
14075,
3650,
365,
641,
314,
8424,
402,
314,
16822,
4897,
14,
398,
8144,
267,
9063,
267,
710,
869,
21663,
365,
1415,
370,
506,
7317,
28088,
14,
398,
14504,
267,
4143,
267,
2508,
359,
17,
61,
1603,
24591,
3091,
6867,
279,
436,
17854,
17579,
644,
1019,
12,
2049,
653,
27685,
19246,
2072,
12,
3499,
325,
1671,
12,
2049,
428,
2700,
7886,
13,
3673,
1823,
12,
8315,
12,
2034,
18525,
14,
267,
408,
398,
327,
8354,
314,
7053,
1860,
2376,
14,
267,
327,
961,
365,
314,
5323,
453,
367,
314,
16744,
19826,
1402,
805,
14,
267,
327,
982,
652,
365,
6272,
314,
16822,
9362,
2066,
372,
642,
2376,
14,
267,
299,
63,
7010,
275,
291,
14,
1222,
1860,
63,
1403,
342,
267,
340,
7026,
14,
10096,
14,
4791,
8,
80,
63,
7010,
9,
665,
16822,
63,
8017,
26,
288,
19745,
63,
9891,
275,
756,
288,
372,
299,
63,
7010,
12,
19745,
63,
9891,
398,
327,
8354,
314,
8790,
30074,
2376,
14,
267,
327,
961,
365,
314,
14746,
5323,
453,
3180,
314,
7581,
402,
308,
15557,
321,
270,
31518,
14,
267,
299,
63,
85,
275,
291,
14,
696,
30074,
63,
1403,
342,
398,
327,
982,
314,
8790,
30074,
2376,
365,
9682,
314,
16822,
4897,
12,
267,
327,
2066,
372,
314,
2376,
2382,
314,
931,
1640,
25353,
314,
8424,
14,
267,
299,
63,
85,
63,
4791,
275,
7026,
14,
10096,
14,
4791,
8,
80,
63,
85,
9,
267,
340,
299,
63,
85,
63,
4791,
2356,
16822,
63,
8017,
26,
288,
299,
63,
9891,
275,
299,
63,
85,
627,
334,
15756,
63,
8017,
1182,
299,
63,
85,
63,
4791,
9,
288,
19745,
63,
9891,
275,
715,
288,
372,
299,
63,
9891,
12,
19745,
63,
9891,
398,
327,
8354,
314,
16223,
402,
314,
16822,
4897,
8424,
267,
327,
436,
314,
1004,
8135,
18170,
314,
8790,
30074,
436,
7053,
1860,
4501,
14,
267,
327,
961,
5074,
8597,
4007,
282,
16744,
19826,
18649,
14,
267,
327,
12208,
80,
63,
85,
435,
307,
5830,
80,
63,
7010,
446,
299,
63,
85,
8636,
92,
538,
18,
508,
16822,
63,
8017,
538,
18,
267,
327,
428,
3344,
642,
367,
7317,
900,
307,
1808,
314,
16744,
19826,
15723,
14,
267,
5501,
7070,
275,
291,
14,
362,
63,
27505,
63,
1058,
7786,
8,
80,
63,
85,
12,
299,
63,
7010,
446,
299,
63,
85,
12,
8179,
16822,
63,
8017,
9,
267,
299,
63,
9891,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
Datera/python-sdk
|
utils/show_os_volumes.py
|
1
|
4523
|
#!/usr/bin/env python
from __future__ import (print_function, unicode_literals, division,
absolute_import)
"""
This script will output the Datera AppInstances that are being managed
by an OpenStack Cinder (or Glance) instance.
It does this by retrieving all the AppInstances on the Datera backend, then
comparing the UUIDs extracted from their names to the UUIDs of the Cinder
volumes under the current OpenStack instance designated by the presence of
a clouds.yaml file (or other openstacksdk compatible credentials, such as
environment variables).
Usage:
$ ./show_os_volumes.py
# For more than just the active Cinder project (requires admin-level creds)
$ ./show_os_volumes.py --all-projects-all-tenants
# For just the Datera Cinder Volume Driver cached images
$ ./show_os_volumes.py --only-cached-images
# For just the volumes created on the Datera backend by Cinder that do not
# have a corresponding Cinder volume entry
$ ./show_os_volumes.py --only-os-orphans
"""
import os
import re
import subprocess
import sys
import openstack
from dfs_sdk import scaffold
from dfs_sdk.scaffold import vprint
# Taken from this SO post :
# http://stackoverflow.com/a/18516125
# Using old-style string formatting because of the nature of the regex
# conflicting with new-style curly braces
UUID4_STR_RE = ("[a-f0-9]{8}-?[a-f0-9]{4}-?4[a-f0-9]{3}-?[89ab]"
"[a-f0-9]{3}-?[a-f0-9]{12}")
UUID4_RE = re.compile(UUID4_STR_RE)
verbose = False
def usage():
print("OS_USERNAME, OS_PASSWORD, OS_AUTH_URL and "
"OS_PROJECT_NAME must be set")
def exe(cmd):
vprint("Running cmd:", cmd)
return subprocess.check_output(cmd, shell=True)
def main(args):
api = scaffold.get_api()
conn = openstack.connect()
# Earlier versions of openstacksdk didn't let us filter by tenant
# So multi-project accumulation has to be done via openstackclient
if args.all_projects_all_tenants:
# Get all openstack volume UUIDs
ids = exe("openstack volume list --all-projects --format value | "
"awk '{print $1}'").split("\n")
# Filter Nones
vols = {vid for vid in ids if vid}
# Get all openstack projects
pids = exe("openstack project list --format value "
"| awk '{print $1}'").split("\n")
# Iterate through projects and accumulate image ids
imgids = []
for pid in [p for p in pids if p]:
try:
imgids.extend(
exe("openstack --os-project-id {} image list --format "
"value | awk '{{print $1}}'".format(pid)).split("\n"))
except subprocess.CalledProcessError:
pass
imgids = set(imgids)
vols = vols.union(
{imgid for imgid in imgids if imgid})
else:
vols = {str(vol.id) for vol in conn.block_storage.volumes()}
vols = vols.union(
{str(img.id) for img in conn.image.images()})
yes_os, non_os = set(), set()
ais = api.app_instances.list()
for ai in ais:
uid = UUID4_RE.search(ai['name'])
if not uid or uid.group() not in vols:
non_os.add(ai['name'])
else:
yes_os.add(ai['name'])
pdisplay = "all" if args.all_projects_all_tenants else os.getenv(
"OS_PROJECT_NAME")
if args.only_os_orphans:
for ai_name in sorted(non_os):
if ai_name.startswith("OS-"):
print(ai_name)
elif args.only_cached_images:
for ai_name in sorted(non_os):
ai = api.app_instances.get(ai_name)
if ai.metadata.get().get('type') == 'cached_image':
print(ai_name)
else:
print("OpenStack Project:", pdisplay)
print("Datera Tenant: ", scaffold.get_config()["tenant"])
print()
print("Datera OpenStack AIs")
print("--------------------")
for ai_name in sorted(yes_os):
print(ai_name)
print("\nDatera Non-OpenStack AIs")
print("------------------------")
for ai_name in sorted(non_os):
print(ai_name)
if __name__ == "__main__":
parser = scaffold.get_argparser()
parser.add_argument('--all-projects-all-tenants', action='store_true')
parser.add_argument('--only-os-orphans', action='store_true')
parser.add_argument('--only-cached-images', action='store_true')
args = parser.parse_args()
sys.exit(main(args))
|
apache-2.0
|
[
3381,
2647,
15,
1393,
15,
1813,
2366,
199,
199,
504,
636,
2443,
363,
492,
334,
1361,
63,
1593,
12,
2649,
63,
5955,
12,
4629,
12,
717,
3679,
63,
646,
9,
199,
199,
624,
199,
2765,
2884,
911,
1072,
314,
6148,
345,
4693,
18194,
626,
787,
3769,
12883,
199,
991,
376,
14260,
445,
5755,
334,
269,
598,
76,
554,
9,
1256,
14,
199,
199,
7940,
1630,
642,
701,
23812,
1006,
314,
4693,
18194,
641,
314,
6148,
345,
4865,
12,
2066,
199,
863,
9332,
314,
11134,
83,
12509,
687,
3932,
1561,
370,
314,
11134,
83,
402,
314,
445,
5755,
199,
8838,
1334,
314,
1453,
14260,
1256,
12899,
972,
701,
314,
20024,
402,
199,
65,
2463,
14577,
14,
5963,
570,
334,
269,
1163,
13869,
9277,
9025,
6235,
12,
4066,
465,
199,
5418,
2860,
680,
199,
199,
7692,
26,
272,
2672,
16605,
2384,
63,
736,
63,
8838,
14,
647,
339,
327,
2104,
1655,
2419,
2951,
314,
4702,
445,
5755,
2199,
334,
6537,
4628,
13,
1896,
20023,
9,
272,
2672,
16605,
2384,
63,
736,
63,
8838,
14,
647,
1553,
452,
13,
6776,
13,
452,
13,
25021,
339,
327,
2104,
2951,
314,
6148,
345,
445,
5755,
15018,
19447,
6328,
5935,
272,
2672,
16605,
2384,
63,
736,
63,
8838,
14,
647,
1553,
2118,
13,
5245,
13,
4782,
339,
327,
2104,
2951,
314,
12158,
2737,
641,
314,
6148,
345,
4865,
701,
445,
5755,
626,
886,
440,
272,
327,
1172,
282,
5226,
445,
5755,
3301,
2397,
272,
2672,
16605,
2384,
63,
736,
63,
8838,
14,
647,
1553,
2118,
13,
736,
13,
6847,
796,
199,
624,
199,
199,
646,
747,
199,
646,
295,
199,
646,
3873,
199,
646,
984,
199,
199,
646,
13869,
199,
199,
504,
366,
2319,
63,
9277,
492,
32388,
199,
504,
366,
2319,
63,
9277,
14,
27927,
492,
373,
1361,
199,
199,
3,
32316,
917,
687,
642,
3562,
2963,
520,
199,
3,
1455,
921,
23153,
14,
957,
15,
65,
15,
10233,
975,
6889,
199,
3,
11719,
2269,
13,
2487,
1059,
10803,
2952,
402,
314,
302,
1463,
402,
314,
5163,
199,
3,
28204,
543,
892,
13,
2487,
1094,
590,
27158,
199,
8757,
20,
63,
3027,
63,
907,
275,
1689,
59,
65,
13,
70,
16,
13,
25,
8194,
24,
17063,
26736,
65,
13,
70,
16,
13,
25,
8194,
20,
17063,
31,
20,
59,
65,
13,
70,
16,
13,
25,
8194,
19,
17063,
26736,
1407,
371,
8480,
355,
7369,
65,
13,
70,
16,
13,
25,
8194,
19,
17063,
26736,
65,
13,
70,
16,
13,
25,
8194,
713,
15412,
199,
8757,
20,
63,
907,
275,
295,
14,
2014,
8,
8757,
20,
63,
3027,
63,
907,
9,
199,
3832,
275,
756,
421,
199,
318,
4503,
837,
272,
870,
480,
3100,
63,
11958,
12,
4403,
63,
9032,
12,
4403,
63,
5580,
63,
2632,
436,
298,
881,
298,
3100,
63,
10797,
63,
2339,
1471,
506,
663,
531,
421,
199,
318,
14778,
8,
1760,
304,
272,
373,
1361,
480,
9602,
2088,
6783,
2088,
9,
272,
372,
3873,
14,
1074,
63,
1199,
8,
1760,
12,
5218,
29,
549,
9,
421,
199,
318,
2446,
8,
589,
304,
339,
2986,
275,
32388,
14,
362,
63,
1246,
342,
339,
2557,
275,
13869,
14,
2242,
342,
339,
327,
662,
285,
5697,
5459,
402,
13869,
9277,
9980,
1133,
4691,
2739,
2457,
701,
8261,
272,
327,
2002,
3510,
13,
1715,
11162,
5332,
965,
370,
506,
4224,
4799,
13869,
1258,
272,
340,
1249,
14,
452,
63,
6776,
63,
452,
63,
25021,
26,
267,
327,
2372,
1006,
13869,
3301,
11134,
83,
267,
2762,
275,
14778,
480,
8512,
3301,
769,
1553,
452,
13,
6776,
1553,
908,
574,
1204,
298,
2116,
298,
10084,
75,
5041,
1361,
2672,
17,
6834,
3471,
1294,
4582,
78,
531,
267,
327,
9388,
488,
83,
267,
373,
1446,
275,
469,
5017,
367,
27767,
315,
2762,
340,
27767,
93,
398,
327,
2372,
1006,
13869,
11336,
267,
25902,
275,
14778,
480,
8512,
2199,
769,
1553,
908,
574,
298,
673,
15733,
282,
14947,
5041,
1361,
2672,
17,
6834,
3471,
1294,
4582,
78,
531,
398,
327,
23989,
4012,
11336,
436,
30535,
1834,
2762,
267,
6050,
1580,
275,
942,
267,
367,
4422,
315,
359,
80,
367,
299,
315,
25902,
340,
299,
2189,
288,
862,
26,
355,
6050,
1580,
14,
2880,
8,
490,
14778,
480,
8512,
1553,
736,
13,
1715,
13,
344,
1052,
1834,
769,
1553,
908,
298,
717,
298,
585,
1204,
282,
14947,
11400,
1361,
2672,
17,
4863,
7,
1674,
908,
8,
3150,
4992,
1294,
4582,
78,
2237,
288,
871,
3873,
14,
24691,
26,
355,
986,
267,
6050,
1580,
275,
663,
8,
4060,
1580,
9,
267,
373,
1446,
275,
373,
1446,
14,
8888,
8,
355,
469,
4060,
344,
367,
6050,
344,
315,
6050,
1580,
340,
6050,
344,
1552,
339,
587,
26,
267,
373,
1446,
275,
469,
495,
8,
5650,
14,
344,
9,
367,
5236,
315,
2557,
14,
1457,
63,
3494,
14,
8838,
12737,
267,
373,
1446,
275,
373,
1446,
14,
8888,
8,
355,
469,
495,
8,
4060,
14,
344,
9,
367,
6050,
315,
2557,
14,
1569,
14,
4782,
22804,
339,
9456,
63,
736,
12,
2222,
63,
736,
275,
663,
1062,
663,
342,
272,
282,
374,
275,
2986,
14,
571,
63,
5990,
14,
513,
342,
272,
367,
15933,
315,
282,
374,
26,
267,
1747,
275,
11134,
20,
63,
907,
14,
1733,
8,
5789,
459,
354,
1105,
267,
340,
440,
1747,
503,
1747,
14,
923,
342,
440,
315,
373,
1446,
26,
288,
2222,
63,
736,
14,
525,
8,
5789,
459,
354,
1105,
267,
587,
26,
288,
9456,
63,
736,
14,
525,
8,
5789,
459,
354,
1105,
339,
299,
2918,
275,
298,
452,
2,
340,
1249,
14,
452,
63,
6776,
63,
452,
63,
25021,
587,
747,
14,
12959,
8,
267,
298,
3100,
63,
10797,
63,
2339,
531,
272,
340,
1249,
14,
2118,
63,
736,
63,
6847,
796,
26,
267,
367,
15933,
63,
354,
315,
3355,
8,
2865,
63,
736,
304,
288,
340,
15933,
63,
354,
14,
2460,
480,
3100,
13,
2349,
355,
870,
8,
5789,
63,
354,
9,
272,
916,
1249,
14,
2118,
63,
5245,
63,
4782,
26,
267,
367,
15933,
63,
354,
315,
3355,
8,
2865,
63,
736,
304,
288,
15933,
275,
2986,
14,
571,
63,
5990,
14,
362,
8,
5789,
63,
354,
9,
288,
340,
15933,
14,
2343,
14,
362,
1252,
362,
360,
466,
358,
508,
283,
5245,
63,
1569,
356,
355
] |
[
2647,
15,
1393,
15,
1813,
2366,
199,
199,
504,
636,
2443,
363,
492,
334,
1361,
63,
1593,
12,
2649,
63,
5955,
12,
4629,
12,
717,
3679,
63,
646,
9,
199,
199,
624,
199,
2765,
2884,
911,
1072,
314,
6148,
345,
4693,
18194,
626,
787,
3769,
12883,
199,
991,
376,
14260,
445,
5755,
334,
269,
598,
76,
554,
9,
1256,
14,
199,
199,
7940,
1630,
642,
701,
23812,
1006,
314,
4693,
18194,
641,
314,
6148,
345,
4865,
12,
2066,
199,
863,
9332,
314,
11134,
83,
12509,
687,
3932,
1561,
370,
314,
11134,
83,
402,
314,
445,
5755,
199,
8838,
1334,
314,
1453,
14260,
1256,
12899,
972,
701,
314,
20024,
402,
199,
65,
2463,
14577,
14,
5963,
570,
334,
269,
1163,
13869,
9277,
9025,
6235,
12,
4066,
465,
199,
5418,
2860,
680,
199,
199,
7692,
26,
272,
2672,
16605,
2384,
63,
736,
63,
8838,
14,
647,
339,
327,
2104,
1655,
2419,
2951,
314,
4702,
445,
5755,
2199,
334,
6537,
4628,
13,
1896,
20023,
9,
272,
2672,
16605,
2384,
63,
736,
63,
8838,
14,
647,
1553,
452,
13,
6776,
13,
452,
13,
25021,
339,
327,
2104,
2951,
314,
6148,
345,
445,
5755,
15018,
19447,
6328,
5935,
272,
2672,
16605,
2384,
63,
736,
63,
8838,
14,
647,
1553,
2118,
13,
5245,
13,
4782,
339,
327,
2104,
2951,
314,
12158,
2737,
641,
314,
6148,
345,
4865,
701,
445,
5755,
626,
886,
440,
272,
327,
1172,
282,
5226,
445,
5755,
3301,
2397,
272,
2672,
16605,
2384,
63,
736,
63,
8838,
14,
647,
1553,
2118,
13,
736,
13,
6847,
796,
199,
624,
199,
199,
646,
747,
199,
646,
295,
199,
646,
3873,
199,
646,
984,
199,
199,
646,
13869,
199,
199,
504,
366,
2319,
63,
9277,
492,
32388,
199,
504,
366,
2319,
63,
9277,
14,
27927,
492,
373,
1361,
199,
199,
3,
32316,
917,
687,
642,
3562,
2963,
520,
199,
3,
1455,
921,
23153,
14,
957,
15,
65,
15,
10233,
975,
6889,
199,
3,
11719,
2269,
13,
2487,
1059,
10803,
2952,
402,
314,
302,
1463,
402,
314,
5163,
199,
3,
28204,
543,
892,
13,
2487,
1094,
590,
27158,
199,
8757,
20,
63,
3027,
63,
907,
275,
1689,
59,
65,
13,
70,
16,
13,
25,
8194,
24,
17063,
26736,
65,
13,
70,
16,
13,
25,
8194,
20,
17063,
31,
20,
59,
65,
13,
70,
16,
13,
25,
8194,
19,
17063,
26736,
1407,
371,
8480,
355,
7369,
65,
13,
70,
16,
13,
25,
8194,
19,
17063,
26736,
65,
13,
70,
16,
13,
25,
8194,
713,
15412,
199,
8757,
20,
63,
907,
275,
295,
14,
2014,
8,
8757,
20,
63,
3027,
63,
907,
9,
199,
3832,
275,
756,
421,
199,
318,
4503,
837,
272,
870,
480,
3100,
63,
11958,
12,
4403,
63,
9032,
12,
4403,
63,
5580,
63,
2632,
436,
298,
881,
298,
3100,
63,
10797,
63,
2339,
1471,
506,
663,
531,
421,
199,
318,
14778,
8,
1760,
304,
272,
373,
1361,
480,
9602,
2088,
6783,
2088,
9,
272,
372,
3873,
14,
1074,
63,
1199,
8,
1760,
12,
5218,
29,
549,
9,
421,
199,
318,
2446,
8,
589,
304,
339,
2986,
275,
32388,
14,
362,
63,
1246,
342,
339,
2557,
275,
13869,
14,
2242,
342,
339,
327,
662,
285,
5697,
5459,
402,
13869,
9277,
9980,
1133,
4691,
2739,
2457,
701,
8261,
272,
327,
2002,
3510,
13,
1715,
11162,
5332,
965,
370,
506,
4224,
4799,
13869,
1258,
272,
340,
1249,
14,
452,
63,
6776,
63,
452,
63,
25021,
26,
267,
327,
2372,
1006,
13869,
3301,
11134,
83,
267,
2762,
275,
14778,
480,
8512,
3301,
769,
1553,
452,
13,
6776,
1553,
908,
574,
1204,
298,
2116,
298,
10084,
75,
5041,
1361,
2672,
17,
6834,
3471,
1294,
4582,
78,
531,
267,
327,
9388,
488,
83,
267,
373,
1446,
275,
469,
5017,
367,
27767,
315,
2762,
340,
27767,
93,
398,
327,
2372,
1006,
13869,
11336,
267,
25902,
275,
14778,
480,
8512,
2199,
769,
1553,
908,
574,
298,
673,
15733,
282,
14947,
5041,
1361,
2672,
17,
6834,
3471,
1294,
4582,
78,
531,
398,
327,
23989,
4012,
11336,
436,
30535,
1834,
2762,
267,
6050,
1580,
275,
942,
267,
367,
4422,
315,
359,
80,
367,
299,
315,
25902,
340,
299,
2189,
288,
862,
26,
355,
6050,
1580,
14,
2880,
8,
490,
14778,
480,
8512,
1553,
736,
13,
1715,
13,
344,
1052,
1834,
769,
1553,
908,
298,
717,
298,
585,
1204,
282,
14947,
11400,
1361,
2672,
17,
4863,
7,
1674,
908,
8,
3150,
4992,
1294,
4582,
78,
2237,
288,
871,
3873,
14,
24691,
26,
355,
986,
267,
6050,
1580,
275,
663,
8,
4060,
1580,
9,
267,
373,
1446,
275,
373,
1446,
14,
8888,
8,
355,
469,
4060,
344,
367,
6050,
344,
315,
6050,
1580,
340,
6050,
344,
1552,
339,
587,
26,
267,
373,
1446,
275,
469,
495,
8,
5650,
14,
344,
9,
367,
5236,
315,
2557,
14,
1457,
63,
3494,
14,
8838,
12737,
267,
373,
1446,
275,
373,
1446,
14,
8888,
8,
355,
469,
495,
8,
4060,
14,
344,
9,
367,
6050,
315,
2557,
14,
1569,
14,
4782,
22804,
339,
9456,
63,
736,
12,
2222,
63,
736,
275,
663,
1062,
663,
342,
272,
282,
374,
275,
2986,
14,
571,
63,
5990,
14,
513,
342,
272,
367,
15933,
315,
282,
374,
26,
267,
1747,
275,
11134,
20,
63,
907,
14,
1733,
8,
5789,
459,
354,
1105,
267,
340,
440,
1747,
503,
1747,
14,
923,
342,
440,
315,
373,
1446,
26,
288,
2222,
63,
736,
14,
525,
8,
5789,
459,
354,
1105,
267,
587,
26,
288,
9456,
63,
736,
14,
525,
8,
5789,
459,
354,
1105,
339,
299,
2918,
275,
298,
452,
2,
340,
1249,
14,
452,
63,
6776,
63,
452,
63,
25021,
587,
747,
14,
12959,
8,
267,
298,
3100,
63,
10797,
63,
2339,
531,
272,
340,
1249,
14,
2118,
63,
736,
63,
6847,
796,
26,
267,
367,
15933,
63,
354,
315,
3355,
8,
2865,
63,
736,
304,
288,
340,
15933,
63,
354,
14,
2460,
480,
3100,
13,
2349,
355,
870,
8,
5789,
63,
354,
9,
272,
916,
1249,
14,
2118,
63,
5245,
63,
4782,
26,
267,
367,
15933,
63,
354,
315,
3355,
8,
2865,
63,
736,
304,
288,
15933,
275,
2986,
14,
571,
63,
5990,
14,
362,
8,
5789,
63,
354,
9,
288,
340,
15933,
14,
2343,
14,
362,
1252,
362,
360,
466,
358,
508,
283,
5245,
63,
1569,
356,
355,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
donald-pinckney/EM-Simulator
|
EM Sim/EM Sim/py_lib/distutils/command/check.py
|
75
|
5232
|
"""distutils.command.check
Implements the Distutils 'check' command.
"""
__revision__ = "$Id$"
from distutils.core import Command
from distutils.errors import DistutilsSetupError
try:
# docutils is installed
from docutils.utils import Reporter
from docutils.parsers.rst import Parser
from docutils import frontend
from docutils import nodes
from StringIO import StringIO
class SilentReporter(Reporter):
def __init__(self, source, report_level, halt_level, stream=None,
debug=0, encoding='ascii', error_handler='replace'):
self.messages = []
Reporter.__init__(self, source, report_level, halt_level, stream,
debug, encoding, error_handler)
def system_message(self, level, message, *children, **kwargs):
self.messages.append((level, message, children, kwargs))
HAS_DOCUTILS = True
except ImportError:
# docutils is not installed
HAS_DOCUTILS = False
class check(Command):
"""This command checks the meta-data of the package.
"""
description = ("perform some checks on the package")
user_options = [('metadata', 'm', 'Verify meta-data'),
('restructuredtext', 'r',
('Checks if long string meta-data syntax '
'are reStructuredText-compliant')),
('strict', 's',
'Will exit with an error if a check fails')]
boolean_options = ['metadata', 'restructuredtext', 'strict']
def initialize_options(self):
"""Sets default values for options."""
self.restructuredtext = 0
self.metadata = 1
self.strict = 0
self._warnings = 0
def finalize_options(self):
pass
def warn(self, msg):
"""Counts the number of warnings that occurs."""
self._warnings += 1
return Command.warn(self, msg)
def run(self):
"""Runs the command."""
# perform the various tests
if self.metadata:
self.check_metadata()
if self.restructuredtext:
if HAS_DOCUTILS:
self.check_restructuredtext()
elif self.strict:
raise DistutilsSetupError('The docutils package is needed.')
# let's raise an error in strict mode, if we have at least
# one warning
if self.strict and self._warnings > 0:
raise DistutilsSetupError('Please correct your package.')
def check_metadata(self):
"""Ensures that all required elements of meta-data are supplied.
name, version, URL, (author and author_email) or
(maintainer and maintainer_email)).
Warns if any are missing.
"""
metadata = self.distribution.metadata
missing = []
for attr in ('name', 'version', 'url'):
if not (hasattr(metadata, attr) and getattr(metadata, attr)):
missing.append(attr)
if missing:
self.warn("missing required meta-data: %s" % ', '.join(missing))
if metadata.author:
if not metadata.author_email:
self.warn("missing meta-data: if 'author' supplied, " +
"'author_email' must be supplied too")
elif metadata.maintainer:
if not metadata.maintainer_email:
self.warn("missing meta-data: if 'maintainer' supplied, " +
"'maintainer_email' must be supplied too")
else:
self.warn("missing meta-data: either (author and author_email) " +
"or (maintainer and maintainer_email) " +
"must be supplied")
def check_restructuredtext(self):
"""Checks if the long string fields are reST-compliant."""
data = self.distribution.get_long_description()
for warning in self._check_rst_data(data):
line = warning[-1].get('line')
if line is None:
warning = warning[1]
else:
warning = '%s (line %s)' % (warning[1], line)
self.warn(warning)
def _check_rst_data(self, data):
"""Returns warnings when the provided data doesn't compile."""
source_path = StringIO()
parser = Parser()
settings = frontend.OptionParser().get_default_values()
settings.tab_width = 4
settings.pep_references = None
settings.rfc_references = None
reporter = SilentReporter(source_path,
settings.report_level,
settings.halt_level,
stream=settings.warning_stream,
debug=settings.debug,
encoding=settings.error_encoding,
error_handler=settings.error_encoding_error_handler)
document = nodes.document(settings, reporter, source=source_path)
document.note_source(source_path, -1)
try:
parser.parse(data, document)
except AttributeError:
reporter.messages.append((-1, 'Could not finish the parsing.',
'', {}))
return reporter.messages
|
apache-2.0
|
[
624,
13350,
14,
1531,
14,
1074,
199,
199,
29452,
314,
12577,
283,
1074,
7,
1414,
14,
199,
624,
199,
363,
5792,
363,
275,
7880,
1304,
17351,
199,
199,
504,
7065,
14,
1018,
492,
5817,
199,
504,
7065,
14,
2550,
492,
12577,
30221,
199,
199,
893,
26,
272,
327,
18382,
365,
4903,
272,
687,
18382,
14,
1208,
492,
23786,
272,
687,
18382,
14,
11531,
14,
8332,
492,
10191,
272,
687,
18382,
492,
22523,
272,
687,
18382,
492,
3380,
272,
687,
5228,
492,
5228,
339,
1021,
428,
441,
343,
15891,
8,
15891,
304,
398,
347,
636,
826,
721,
277,
12,
1350,
12,
3622,
63,
1896,
12,
394,
4478,
63,
1896,
12,
2547,
29,
403,
12,
2151,
3105,
29,
16,
12,
2644,
534,
4371,
297,
1125,
63,
2232,
534,
1814,
735,
288,
291,
14,
3431,
275,
942,
288,
23786,
855,
826,
721,
277,
12,
1350,
12,
3622,
63,
1896,
12,
394,
4478,
63,
1896,
12,
2547,
12,
2892,
3105,
12,
2644,
12,
1125,
63,
2232,
9,
398,
347,
2656,
63,
1188,
8,
277,
12,
2166,
12,
1245,
12,
627,
3223,
12,
1011,
958,
304,
288,
291,
14,
3431,
14,
740,
1332,
1896,
12,
1245,
12,
4978,
12,
2074,
430,
339,
7509,
63,
16618,
29076,
51,
275,
715,
199,
2590,
3545,
26,
272,
327,
18382,
365,
440,
4903,
272,
7509,
63,
16618,
29076,
51,
275,
756,
199,
199,
533,
1104,
8,
3110,
304,
272,
408,
2765,
1414,
5920,
314,
3404,
13,
576,
402,
314,
2559,
14,
272,
408,
272,
1369,
275,
1689,
15795,
2005,
5920,
641,
314,
2559,
531,
272,
922,
63,
1419,
275,
4274,
2343,
297,
283,
77,
297,
283,
7496,
3404,
13,
576,
659,
490,
661,
26854,
297,
283,
82,
297,
2151,
661,
11834,
340,
1846,
1059,
3404,
13,
576,
6302,
283,
1993,
283,
1530,
295,
27486,
1872,
13,
863,
22676,
3855,
490,
661,
4768,
297,
283,
83,
297,
2151,
283,
20326,
4458,
543,
376,
1125,
340,
282,
1104,
6918,
5440,
339,
5046,
63,
1419,
275,
788,
2343,
297,
283,
26854,
297,
283,
4768,
418,
339,
347,
8265,
63,
1419,
8,
277,
304,
267,
408,
9899,
849,
1338,
367,
1511,
1041,
267,
291,
14,
26854,
275,
378,
267,
291,
14,
2343,
275,
413,
267,
291,
14,
4768,
275,
378,
267,
291,
423,
5451,
275,
378,
339,
347,
17284,
63,
1419,
8,
277,
304,
267,
986,
339,
347,
7987,
8,
277,
12,
1499,
304,
267,
408,
23209,
314,
1329,
402,
3598,
626,
11058,
1041,
267,
291,
423,
5451,
847,
413,
267,
372,
5817,
14,
4050,
8,
277,
12,
1499,
9,
339,
347,
1255,
8,
277,
304,
267,
408,
16291,
314,
1414,
1041,
267,
327,
5147,
314,
7750,
2295,
267,
340,
291,
14,
2343,
26,
288,
291,
14,
1074,
63,
2343,
342,
267,
340,
291,
14,
26854,
26,
288,
340,
7509,
63,
16618,
29076,
51,
26,
355,
291,
14,
1074,
63,
26854,
342,
288,
916,
291,
14,
4768,
26,
355,
746,
12577,
30221,
360,
1918,
18382,
2559,
365,
4346,
2659,
398,
327,
4691,
1159,
746,
376,
1125,
315,
7478,
818,
12,
340,
781,
1172,
737,
5210,
267,
327,
1373,
5721,
267,
340,
291,
14,
4768,
436,
291,
423,
5451,
690,
378,
26,
288,
746,
12577,
30221,
360,
8254,
3211,
2195,
2559,
2659,
339,
347,
1104,
63,
2343,
8,
277,
304,
267,
408,
37,
561,
1482,
626,
1006,
1415,
4008,
402,
3404,
13,
576,
787,
6841,
14,
398,
536,
12,
1015,
12,
2851,
12,
334,
2502,
436,
4132,
63,
2123,
9,
503,
267,
334,
26665,
436,
11075,
281,
63,
2123,
4992,
398,
644,
22476,
340,
1263,
787,
4124,
14,
267,
408,
267,
3341,
275,
291,
14,
4972,
14,
2343,
398,
4124,
275,
942,
267,
367,
1921,
315,
661,
354,
297,
283,
1023,
297,
283,
633,
735,
288,
340,
440,
334,
11161,
8,
2343,
12,
1921,
9,
436,
2519,
8,
2343,
12,
1921,
2298,
355,
4124,
14,
740,
8,
962,
9,
398,
340,
4124,
26,
288,
291,
14,
4050,
480,
4752,
1415,
3404,
13,
576,
26,
450,
83,
2,
221,
450,
1656,
1987,
904,
8,
4752,
430,
267,
340,
3341,
14,
2502,
26,
288,
340,
440,
3341,
14,
2502,
63,
2123,
26,
355,
291,
14,
4050,
480,
4752,
3404,
13,
576,
26,
340,
283,
2502,
7,
6841,
12,
298,
435,
2079,
3546,
2502,
63,
2123,
7,
1471,
506,
6841,
4634,
531,
267,
916,
3341,
14,
26665,
26,
288,
340,
440,
3341,
14,
26665,
63,
2123,
26,
355,
291,
14,
4050,
480,
4752,
3404,
13,
576,
26,
340,
283,
26665,
7,
6841,
12,
298,
435,
2079,
3546,
26665,
63,
2123,
7,
1471,
506,
6841,
4634,
531,
267,
587,
26,
288,
291,
14,
4050,
480,
4752,
3404,
13,
576,
26,
1902,
334,
2502,
436,
4132,
63,
2123,
9,
298,
435,
1993,
298,
269,
334,
26665,
436,
11075,
281,
63,
2123,
9,
298,
435,
1993,
298,
7790,
506,
6841,
531,
339,
347,
1104,
63,
26854,
8,
277,
304,
267,
408,
11834,
340,
314,
1846,
1059,
1504,
787,
20883,
13,
863,
22676,
1041,
267,
666,
275,
291,
14,
4972,
14,
362,
63,
2809,
63,
1802,
342,
267,
367,
5721,
315,
291,
423,
1074,
63,
8332,
63,
576,
8,
576,
304,
288,
1004,
275,
5721,
1988,
17,
1055,
362,
360,
604,
358,
288,
340,
1004,
365,
488,
26,
355,
5721,
275,
5721,
59,
17,
61,
288,
587,
26,
355,
5721,
275,
1543,
83,
334,
604,
450,
83,
3171,
450,
334,
3764,
59,
17,
467,
1004,
9,
288,
291,
14,
4050,
8,
3764,
9,
339,
347,
485,
1074,
63,
8332,
63,
576,
8,
277,
12,
666,
304,
267,
408,
3407,
3598,
1380,
314,
2741,
666,
3181,
1133,
6555,
1041,
267,
1350,
63,
515,
275,
5228,
342,
267,
1798,
275,
10191,
342,
267,
2202,
275,
22523,
14,
14553,
1252,
362,
63,
885,
63,
1459,
342,
267,
2202,
14,
2902,
63,
2063,
275,
841,
267,
2202,
14,
12636,
63,
12635,
275,
488,
267,
2202,
14,
8973,
63,
12635,
275,
488,
267,
17663,
275,
428,
441,
343,
15891,
8,
1365,
63,
515,
12,
2079,
2202,
14,
3070,
63,
1896,
12,
2079,
2202,
14,
72,
4478,
63,
1896,
12,
2079,
2547,
29,
1751,
14,
3764,
63,
1745,
12,
2079,
3105,
29,
1751,
14,
1757,
12,
2079,
2644,
29,
1751,
14,
705,
63,
2991,
12,
2079,
1125,
63,
2232,
29,
1751
] |
[
13350,
14,
1531,
14,
1074,
199,
199,
29452,
314,
12577,
283,
1074,
7,
1414,
14,
199,
624,
199,
363,
5792,
363,
275,
7880,
1304,
17351,
199,
199,
504,
7065,
14,
1018,
492,
5817,
199,
504,
7065,
14,
2550,
492,
12577,
30221,
199,
199,
893,
26,
272,
327,
18382,
365,
4903,
272,
687,
18382,
14,
1208,
492,
23786,
272,
687,
18382,
14,
11531,
14,
8332,
492,
10191,
272,
687,
18382,
492,
22523,
272,
687,
18382,
492,
3380,
272,
687,
5228,
492,
5228,
339,
1021,
428,
441,
343,
15891,
8,
15891,
304,
398,
347,
636,
826,
721,
277,
12,
1350,
12,
3622,
63,
1896,
12,
394,
4478,
63,
1896,
12,
2547,
29,
403,
12,
2151,
3105,
29,
16,
12,
2644,
534,
4371,
297,
1125,
63,
2232,
534,
1814,
735,
288,
291,
14,
3431,
275,
942,
288,
23786,
855,
826,
721,
277,
12,
1350,
12,
3622,
63,
1896,
12,
394,
4478,
63,
1896,
12,
2547,
12,
2892,
3105,
12,
2644,
12,
1125,
63,
2232,
9,
398,
347,
2656,
63,
1188,
8,
277,
12,
2166,
12,
1245,
12,
627,
3223,
12,
1011,
958,
304,
288,
291,
14,
3431,
14,
740,
1332,
1896,
12,
1245,
12,
4978,
12,
2074,
430,
339,
7509,
63,
16618,
29076,
51,
275,
715,
199,
2590,
3545,
26,
272,
327,
18382,
365,
440,
4903,
272,
7509,
63,
16618,
29076,
51,
275,
756,
199,
199,
533,
1104,
8,
3110,
304,
272,
408,
2765,
1414,
5920,
314,
3404,
13,
576,
402,
314,
2559,
14,
272,
408,
272,
1369,
275,
1689,
15795,
2005,
5920,
641,
314,
2559,
531,
272,
922,
63,
1419,
275,
4274,
2343,
297,
283,
77,
297,
283,
7496,
3404,
13,
576,
659,
490,
661,
26854,
297,
283,
82,
297,
2151,
661,
11834,
340,
1846,
1059,
3404,
13,
576,
6302,
283,
1993,
283,
1530,
295,
27486,
1872,
13,
863,
22676,
3855,
490,
661,
4768,
297,
283,
83,
297,
2151,
283,
20326,
4458,
543,
376,
1125,
340,
282,
1104,
6918,
5440,
339,
5046,
63,
1419,
275,
788,
2343,
297,
283,
26854,
297,
283,
4768,
418,
339,
347,
8265,
63,
1419,
8,
277,
304,
267,
408,
9899,
849,
1338,
367,
1511,
1041,
267,
291,
14,
26854,
275,
378,
267,
291,
14,
2343,
275,
413,
267,
291,
14,
4768,
275,
378,
267,
291,
423,
5451,
275,
378,
339,
347,
17284,
63,
1419,
8,
277,
304,
267,
986,
339,
347,
7987,
8,
277,
12,
1499,
304,
267,
408,
23209,
314,
1329,
402,
3598,
626,
11058,
1041,
267,
291,
423,
5451,
847,
413,
267,
372,
5817,
14,
4050,
8,
277,
12,
1499,
9,
339,
347,
1255,
8,
277,
304,
267,
408,
16291,
314,
1414,
1041,
267,
327,
5147,
314,
7750,
2295,
267,
340,
291,
14,
2343,
26,
288,
291,
14,
1074,
63,
2343,
342,
267,
340,
291,
14,
26854,
26,
288,
340,
7509,
63,
16618,
29076,
51,
26,
355,
291,
14,
1074,
63,
26854,
342,
288,
916,
291,
14,
4768,
26,
355,
746,
12577,
30221,
360,
1918,
18382,
2559,
365,
4346,
2659,
398,
327,
4691,
1159,
746,
376,
1125,
315,
7478,
818,
12,
340,
781,
1172,
737,
5210,
267,
327,
1373,
5721,
267,
340,
291,
14,
4768,
436,
291,
423,
5451,
690,
378,
26,
288,
746,
12577,
30221,
360,
8254,
3211,
2195,
2559,
2659,
339,
347,
1104,
63,
2343,
8,
277,
304,
267,
408,
37,
561,
1482,
626,
1006,
1415,
4008,
402,
3404,
13,
576,
787,
6841,
14,
398,
536,
12,
1015,
12,
2851,
12,
334,
2502,
436,
4132,
63,
2123,
9,
503,
267,
334,
26665,
436,
11075,
281,
63,
2123,
4992,
398,
644,
22476,
340,
1263,
787,
4124,
14,
267,
408,
267,
3341,
275,
291,
14,
4972,
14,
2343,
398,
4124,
275,
942,
267,
367,
1921,
315,
661,
354,
297,
283,
1023,
297,
283,
633,
735,
288,
340,
440,
334,
11161,
8,
2343,
12,
1921,
9,
436,
2519,
8,
2343,
12,
1921,
2298,
355,
4124,
14,
740,
8,
962,
9,
398,
340,
4124,
26,
288,
291,
14,
4050,
480,
4752,
1415,
3404,
13,
576,
26,
450,
83,
2,
221,
450,
1656,
1987,
904,
8,
4752,
430,
267,
340,
3341,
14,
2502,
26,
288,
340,
440,
3341,
14,
2502,
63,
2123,
26,
355,
291,
14,
4050,
480,
4752,
3404,
13,
576,
26,
340,
283,
2502,
7,
6841,
12,
298,
435,
2079,
3546,
2502,
63,
2123,
7,
1471,
506,
6841,
4634,
531,
267,
916,
3341,
14,
26665,
26,
288,
340,
440,
3341,
14,
26665,
63,
2123,
26,
355,
291,
14,
4050,
480,
4752,
3404,
13,
576,
26,
340,
283,
26665,
7,
6841,
12,
298,
435,
2079,
3546,
26665,
63,
2123,
7,
1471,
506,
6841,
4634,
531,
267,
587,
26,
288,
291,
14,
4050,
480,
4752,
3404,
13,
576,
26,
1902,
334,
2502,
436,
4132,
63,
2123,
9,
298,
435,
1993,
298,
269,
334,
26665,
436,
11075,
281,
63,
2123,
9,
298,
435,
1993,
298,
7790,
506,
6841,
531,
339,
347,
1104,
63,
26854,
8,
277,
304,
267,
408,
11834,
340,
314,
1846,
1059,
1504,
787,
20883,
13,
863,
22676,
1041,
267,
666,
275,
291,
14,
4972,
14,
362,
63,
2809,
63,
1802,
342,
267,
367,
5721,
315,
291,
423,
1074,
63,
8332,
63,
576,
8,
576,
304,
288,
1004,
275,
5721,
1988,
17,
1055,
362,
360,
604,
358,
288,
340,
1004,
365,
488,
26,
355,
5721,
275,
5721,
59,
17,
61,
288,
587,
26,
355,
5721,
275,
1543,
83,
334,
604,
450,
83,
3171,
450,
334,
3764,
59,
17,
467,
1004,
9,
288,
291,
14,
4050,
8,
3764,
9,
339,
347,
485,
1074,
63,
8332,
63,
576,
8,
277,
12,
666,
304,
267,
408,
3407,
3598,
1380,
314,
2741,
666,
3181,
1133,
6555,
1041,
267,
1350,
63,
515,
275,
5228,
342,
267,
1798,
275,
10191,
342,
267,
2202,
275,
22523,
14,
14553,
1252,
362,
63,
885,
63,
1459,
342,
267,
2202,
14,
2902,
63,
2063,
275,
841,
267,
2202,
14,
12636,
63,
12635,
275,
488,
267,
2202,
14,
8973,
63,
12635,
275,
488,
267,
17663,
275,
428,
441,
343,
15891,
8,
1365,
63,
515,
12,
2079,
2202,
14,
3070,
63,
1896,
12,
2079,
2202,
14,
72,
4478,
63,
1896,
12,
2079,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1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
ubuntustudio-kernel/ubuntu-raring-lowlatency
|
tools/perf/python/twatch.py
|
7370
|
1334
|
#! /usr/bin/python
# -*- python -*-
# -*- coding: utf-8 -*-
# twatch - Experimental use of the perf python interface
# Copyright (C) 2011 Arnaldo Carvalho de Melo <acme@redhat.com>
#
# This application is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; version 2.
#
# This application is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
import perf
def main():
cpus = perf.cpu_map()
threads = perf.thread_map()
evsel = perf.evsel(task = 1, comm = 1, mmap = 0,
wakeup_events = 1, watermark = 1,
sample_id_all = 1,
sample_type = perf.SAMPLE_PERIOD | perf.SAMPLE_TID | perf.SAMPLE_CPU | perf.SAMPLE_TID)
evsel.open(cpus = cpus, threads = threads);
evlist = perf.evlist(cpus, threads)
evlist.add(evsel)
evlist.mmap()
while True:
evlist.poll(timeout = -1)
for cpu in cpus:
event = evlist.read_on_cpu(cpu)
if not event:
continue
print "cpu: %2d, pid: %4d, tid: %4d" % (event.sample_cpu,
event.sample_pid,
event.sample_tid),
print event
if __name__ == '__main__':
main()
|
gpl-2.0
|
[
3168,
1182,
2647,
15,
1393,
15,
1548,
199,
3,
1882,
2366,
1882,
199,
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
257,
307,
6821,
446,
23997,
279,
675,
402,
314,
8582,
2366,
3217,
199,
3,
257,
1898,
334,
35,
9,
7760,
1952,
78,
279,
1117,
14243,
637,
526,
477,
3194,
320,
665,
18107,
32,
17164,
14,
957,
30,
199,
3,
199,
3,
257,
961,
4223,
365,
2867,
2032,
27,
1265,
883,
3604,
652,
436,
15,
269,
199,
3,
257,
2811,
652,
1334,
314,
2895,
402,
314,
1664,
1696,
1684,
844,
199,
3,
257,
465,
3267,
701,
314,
2868,
2290,
2752,
27,
1015,
499,
14,
199,
3,
199,
3,
257,
961,
4223,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
257,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
257,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
1664,
199,
3,
257,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
199,
646,
8582,
199,
199,
318,
2446,
837,
199,
198,
8896,
275,
8582,
14,
3541,
63,
1130,
342,
199,
198,
6962,
275,
8582,
14,
2671,
63,
1130,
342,
199,
198,
6857,
5891,
275,
8582,
14,
6857,
5891,
8,
1765,
275,
413,
12,
1923,
275,
413,
12,
21991,
275,
378,
12,
1585,
257,
21560,
384,
63,
4368,
275,
413,
12,
22834,
1657,
275,
413,
12,
1585,
257,
2690,
63,
344,
63,
452,
275,
413,
12,
1585,
257,
2690,
63,
466,
275,
8582,
14,
15827,
63,
27081,
1204,
8582,
14,
15827,
63,
52,
998,
1204,
8582,
14,
15827,
63,
11011,
1204,
8582,
14,
15827,
63,
52,
998,
9,
199,
198,
6857,
5891,
14,
1490,
8,
8896,
275,
24174,
12,
7183,
275,
7183,
2736,
199,
198,
6857,
513,
275,
8582,
14,
6857,
513,
8,
8896,
12,
7183,
9,
199,
198,
6857,
513,
14,
525,
8,
6857,
5891,
9,
199,
198,
6857,
513,
14,
20671,
342,
199,
198,
6710,
715,
26,
507,
198,
6857,
513,
14,
6843,
8,
2593,
275,
446,
17,
9,
507,
198,
509,
5033,
315,
24174,
26,
686,
198,
1430,
275,
8145,
513,
14,
739,
63,
265,
63,
3541,
8,
3541,
9,
686,
198,
692,
440,
1566,
26,
1585,
198,
6958,
686,
198,
1361,
298,
3541,
26,
450,
18,
68,
12,
4422,
26,
450,
20,
68,
12,
11559,
26,
450,
20,
68,
2,
450,
334,
1430,
14,
3271,
63,
3541,
12,
11674,
198,
1430,
14,
3271,
63,
3150,
12,
11674,
198,
1430,
14,
3271,
63,
5700,
395,
686,
198,
1361,
1566,
199,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
272,
2446,
342,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
1182,
2647,
15,
1393,
15,
1548,
199,
3,
1882,
2366,
1882,
199,
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
257,
307,
6821,
446,
23997,
279,
675,
402,
314,
8582,
2366,
3217,
199,
3,
257,
1898,
334,
35,
9,
7760,
1952,
78,
279,
1117,
14243,
637,
526,
477,
3194,
320,
665,
18107,
32,
17164,
14,
957,
30,
199,
3,
199,
3,
257,
961,
4223,
365,
2867,
2032,
27,
1265,
883,
3604,
652,
436,
15,
269,
199,
3,
257,
2811,
652,
1334,
314,
2895,
402,
314,
1664,
1696,
1684,
844,
199,
3,
257,
465,
3267,
701,
314,
2868,
2290,
2752,
27,
1015,
499,
14,
199,
3,
199,
3,
257,
961,
4223,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
257,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
257,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
1664,
199,
3,
257,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
199,
646,
8582,
199,
199,
318,
2446,
837,
199,
198,
8896,
275,
8582,
14,
3541,
63,
1130,
342,
199,
198,
6962,
275,
8582,
14,
2671,
63,
1130,
342,
199,
198,
6857,
5891,
275,
8582,
14,
6857,
5891,
8,
1765,
275,
413,
12,
1923,
275,
413,
12,
21991,
275,
378,
12,
1585,
257,
21560,
384,
63,
4368,
275,
413,
12,
22834,
1657,
275,
413,
12,
1585,
257,
2690,
63,
344,
63,
452,
275,
413,
12,
1585,
257,
2690,
63,
466,
275,
8582,
14,
15827,
63,
27081,
1204,
8582,
14,
15827,
63,
52,
998,
1204,
8582,
14,
15827,
63,
11011,
1204,
8582,
14,
15827,
63,
52,
998,
9,
199,
198,
6857,
5891,
14,
1490,
8,
8896,
275,
24174,
12,
7183,
275,
7183,
2736,
199,
198,
6857,
513,
275,
8582,
14,
6857,
513,
8,
8896,
12,
7183,
9,
199,
198,
6857,
513,
14,
525,
8,
6857,
5891,
9,
199,
198,
6857,
513,
14,
20671,
342,
199,
198,
6710,
715,
26,
507,
198,
6857,
513,
14,
6843,
8,
2593,
275,
446,
17,
9,
507,
198,
509,
5033,
315,
24174,
26,
686,
198,
1430,
275,
8145,
513,
14,
739,
63,
265,
63,
3541,
8,
3541,
9,
686,
198,
692,
440,
1566,
26,
1585,
198,
6958,
686,
198,
1361,
298,
3541,
26,
450,
18,
68,
12,
4422,
26,
450,
20,
68,
12,
11559,
26,
450,
20,
68,
2,
450,
334,
1430,
14,
3271,
63,
3541,
12,
11674,
198,
1430,
14,
3271,
63,
3150,
12,
11674,
198,
1430,
14,
3271,
63,
5700,
395,
686,
198,
1361,
1566,
199,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
272,
2446,
342,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
SheffieldML/GPy
|
GPy/models/gp_coregionalized_regression.py
|
1
|
1940
|
# Copyright (c) 2012 - 2014 the GPy Austhors (see AUTHORS.txt)
# Licensed under the BSD 3-clause license (see LICENSE.txt)
import numpy as np
from ..core import GP
from .. import likelihoods
from .. import kern
from .. import util
class GPCoregionalizedRegression(GP):
"""
Gaussian Process model for heteroscedastic multioutput regression
This is a thin wrapper around the models.GP class, with a set of sensible defaults
:param X_list: list of input observations corresponding to each output
:type X_list: list of numpy arrays
:param Y_list: list of observed values related to the different noise models
:type Y_list: list of numpy arrays
:param kernel: a GPy kernel ** Coregionalized, defaults to RBF ** Coregionalized
:type kernel: None | GPy.kernel defaults
:likelihoods_list: a list of likelihoods, defaults to list of Gaussian likelihoods
:type likelihoods_list: None | a list GPy.likelihoods
:param name: model name
:type name: string
:param W_rank: number tuples of the corregionalization parameters 'W' (see coregionalize kernel documentation)
:type W_rank: integer
:param kernel_name: name of the kernel
:type kernel_name: string
"""
def __init__(self, X_list, Y_list, kernel=None, likelihoods_list=None, name='GPCR',W_rank=1,kernel_name='coreg'):
#Input and Output
X,Y,self.output_index = util.multioutput.build_XY(X_list,Y_list)
Ny = len(Y_list)
#Kernel
if kernel is None:
kernel = kern.RBF(X.shape[1]-1)
kernel = util.multioutput.ICM(input_dim=X.shape[1]-1, num_outputs=Ny, kernel=kernel, W_rank=W_rank,name=kernel_name)
#Likelihood
likelihood = util.multioutput.build_likelihood(Y_list,self.output_index,likelihoods_list)
super(GPCoregionalizedRegression, self).__init__(X,Y,kernel,likelihood, Y_metadata={'output_index':self.output_index})
|
bsd-3-clause
|
[
3,
1898,
334,
67,
9,
6029,
446,
6927,
314,
598,
2713,
437,
833,
72,
1384,
334,
3239,
10610,
14,
2424,
9,
199,
3,
3909,
1334,
314,
6289,
650,
13,
8501,
4190,
334,
3239,
5113,
14,
2424,
9,
199,
199,
646,
2680,
465,
980,
199,
504,
2508,
1018,
492,
17346,
199,
504,
2508,
492,
22046,
83,
199,
504,
2508,
492,
4303,
78,
199,
504,
2508,
492,
4884,
199,
199,
533,
598,
4222,
720,
71,
1636,
279,
1759,
13013,
8,
8225,
304,
272,
408,
272,
17131,
7132,
1402,
367,
946,
266,
4796,
301,
983,
11108,
3510,
1199,
10864,
339,
961,
365,
282,
30758,
4975,
6818,
314,
1709,
14,
8225,
1021,
12,
543,
282,
663,
402,
27962,
4243,
339,
520,
635,
1323,
63,
513,
26,
769,
402,
1324,
19739,
5226,
370,
1924,
1072,
272,
520,
466,
1323,
63,
513,
26,
769,
402,
2680,
6572,
272,
520,
635,
1488,
63,
513,
26,
769,
402,
20802,
1338,
4048,
370,
314,
3365,
11145,
1709,
272,
520,
466,
1488,
63,
513,
26,
769,
402,
2680,
6572,
272,
520,
635,
5114,
26,
282,
598,
2713,
5114,
1011,
11672,
71,
1636,
279,
1759,
12,
4243,
370,
820,
12659,
1011,
11672,
71,
1636,
279,
1759,
272,
520,
466,
5114,
26,
488,
1204,
598,
2713,
14,
4989,
4243,
272,
520,
20704,
83,
63,
513,
26,
282,
769,
402,
22046,
83,
12,
4243,
370,
769,
402,
17131,
22046,
83,
272,
520,
466,
22046,
83,
63,
513,
26,
488,
1204,
282,
769,
598,
2713,
14,
20704,
83,
272,
520,
635,
536,
26,
1402,
536,
272,
520,
466,
536,
26,
1059,
272,
520,
635,
644,
63,
4648,
26,
1329,
6346,
402,
314,
1970,
4551,
279,
2072,
2633,
283,
55,
7,
334,
3239,
512,
4551,
279,
794,
5114,
3794,
9,
272,
520,
466,
644,
63,
4648,
26,
3000,
272,
520,
635,
5114,
63,
354,
26,
536,
402,
314,
5114,
272,
520,
466,
5114,
63,
354,
26,
1059,
272,
408,
272,
347,
636,
826,
721,
277,
12,
1323,
63,
513,
12,
1488,
63,
513,
12,
5114,
29,
403,
12,
22046,
83,
63,
513,
29,
403,
12,
536,
534,
8225,
2944,
297,
55,
63,
4648,
29,
17,
12,
4989,
63,
354,
534,
1018,
71,
735,
398,
327,
3205,
436,
7242,
267,
1323,
12,
57,
12,
277,
14,
1199,
63,
1080,
275,
4884,
14,
3029,
1199,
14,
1506,
63,
8195,
8,
56,
63,
513,
12,
57,
63,
513,
9,
267,
653,
89,
275,
822,
8,
57,
63,
513,
9,
398,
327,
14127,
267,
340,
5114,
365,
488,
26,
288,
5114,
275,
4303,
78,
14,
50,
12659,
8,
56,
14,
1392,
59,
17,
11285,
17,
9,
7846,
5114,
275,
4884,
14,
3029,
1199,
14,
948,
45,
8,
1210,
63,
3572,
29,
56,
14,
1392,
59,
17,
11285,
17,
12,
1967,
63,
4467,
29,
22781,
12,
5114,
29,
4989,
12,
644,
63,
4648,
29,
55,
63,
4648,
12,
354,
29,
4989,
63,
354,
9,
398,
327,
12545,
12761,
267,
22046,
275,
4884,
14,
3029,
1199,
14,
1506,
63,
20704,
8,
57,
63,
513,
12,
277,
14,
1199,
63,
1080,
12,
20704,
83,
63,
513,
9,
398,
1613,
8,
39,
4222,
720,
71,
1636,
279,
1759,
13013,
12,
291,
2843,
826,
721,
56,
12,
57,
12,
4989,
12,
20704,
12,
1488,
63,
2343,
3713,
1199,
63,
1080,
356,
277,
14,
1199,
63,
1080,
1552,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
1898,
334,
67,
9,
6029,
446,
6927,
314,
598,
2713,
437,
833,
72,
1384,
334,
3239,
10610,
14,
2424,
9,
199,
3,
3909,
1334,
314,
6289,
650,
13,
8501,
4190,
334,
3239,
5113,
14,
2424,
9,
199,
199,
646,
2680,
465,
980,
199,
504,
2508,
1018,
492,
17346,
199,
504,
2508,
492,
22046,
83,
199,
504,
2508,
492,
4303,
78,
199,
504,
2508,
492,
4884,
199,
199,
533,
598,
4222,
720,
71,
1636,
279,
1759,
13013,
8,
8225,
304,
272,
408,
272,
17131,
7132,
1402,
367,
946,
266,
4796,
301,
983,
11108,
3510,
1199,
10864,
339,
961,
365,
282,
30758,
4975,
6818,
314,
1709,
14,
8225,
1021,
12,
543,
282,
663,
402,
27962,
4243,
339,
520,
635,
1323,
63,
513,
26,
769,
402,
1324,
19739,
5226,
370,
1924,
1072,
272,
520,
466,
1323,
63,
513,
26,
769,
402,
2680,
6572,
272,
520,
635,
1488,
63,
513,
26,
769,
402,
20802,
1338,
4048,
370,
314,
3365,
11145,
1709,
272,
520,
466,
1488,
63,
513,
26,
769,
402,
2680,
6572,
272,
520,
635,
5114,
26,
282,
598,
2713,
5114,
1011,
11672,
71,
1636,
279,
1759,
12,
4243,
370,
820,
12659,
1011,
11672,
71,
1636,
279,
1759,
272,
520,
466,
5114,
26,
488,
1204,
598,
2713,
14,
4989,
4243,
272,
520,
20704,
83,
63,
513,
26,
282,
769,
402,
22046,
83,
12,
4243,
370,
769,
402,
17131,
22046,
83,
272,
520,
466,
22046,
83,
63,
513,
26,
488,
1204,
282,
769,
598,
2713,
14,
20704,
83,
272,
520,
635,
536,
26,
1402,
536,
272,
520,
466,
536,
26,
1059,
272,
520,
635,
644,
63,
4648,
26,
1329,
6346,
402,
314,
1970,
4551,
279,
2072,
2633,
283,
55,
7,
334,
3239,
512,
4551,
279,
794,
5114,
3794,
9,
272,
520,
466,
644,
63,
4648,
26,
3000,
272,
520,
635,
5114,
63,
354,
26,
536,
402,
314,
5114,
272,
520,
466,
5114,
63,
354,
26,
1059,
272,
408,
272,
347,
636,
826,
721,
277,
12,
1323,
63,
513,
12,
1488,
63,
513,
12,
5114,
29,
403,
12,
22046,
83,
63,
513,
29,
403,
12,
536,
534,
8225,
2944,
297,
55,
63,
4648,
29,
17,
12,
4989,
63,
354,
534,
1018,
71,
735,
398,
327,
3205,
436,
7242,
267,
1323,
12,
57,
12,
277,
14,
1199,
63,
1080,
275,
4884,
14,
3029,
1199,
14,
1506,
63,
8195,
8,
56,
63,
513,
12,
57,
63,
513,
9,
267,
653,
89,
275,
822,
8,
57,
63,
513,
9,
398,
327,
14127,
267,
340,
5114,
365,
488,
26,
288,
5114,
275,
4303,
78,
14,
50,
12659,
8,
56,
14,
1392,
59,
17,
11285,
17,
9,
7846,
5114,
275,
4884,
14,
3029,
1199,
14,
948,
45,
8,
1210,
63,
3572,
29,
56,
14,
1392,
59,
17,
11285,
17,
12,
1967,
63,
4467,
29,
22781,
12,
5114,
29,
4989,
12,
644,
63,
4648,
29,
55,
63,
4648,
12,
354,
29,
4989,
63,
354,
9,
398,
327,
12545,
12761,
267,
22046,
275,
4884,
14,
3029,
1199,
14,
1506,
63,
20704,
8,
57,
63,
513,
12,
277,
14,
1199,
63,
1080,
12,
20704,
83,
63,
513,
9,
398,
1613,
8,
39,
4222,
720,
71,
1636,
279,
1759,
13013,
12,
291,
2843,
826,
721,
56,
12,
57,
12,
4989,
12,
20704,
12,
1488,
63,
2343,
3713,
1199,
63,
1080,
356,
277,
14,
1199,
63,
1080,
1552,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
fayf/pyload
|
module/gui/CoreConfigParser.py
|
41
|
5711
|
# -*- coding: utf-8 -*-
from __future__ import with_statement
from os.path import exists
from os.path import join
CONF_VERSION = 1
########################################################################
class ConfigParser:
#----------------------------------------------------------------------
def __init__(self, configdir):
"""Constructor"""
self.configdir = configdir
self.config = {}
if self.checkVersion():
self.readConfig()
#----------------------------------------------------------------------
def checkVersion(self):
if not exists(join(self.configdir, "pyload.conf")):
return False
f = open(join(self.configdir, "pyload.conf"), "rb")
v = f.readline()
f.close()
v = v[v.find(":")+1:].strip()
if int(v) < CONF_VERSION:
return False
return True
#----------------------------------------------------------------------
def readConfig(self):
"""reads the config file"""
self.config = self.parseConfig(join(self.configdir, "pyload.conf"))
#----------------------------------------------------------------------
def parseConfig(self, config):
"""parses a given configfile"""
f = open(config)
config = f.read()
config = config.split("\n")[1:]
conf = {}
section, option, value, typ, desc = "","","","",""
listmode = False
for line in config:
line = line.rpartition("#") # removes comments
if line[1]:
line = line[0]
else:
line = line[2]
line = line.strip()
try:
if line == "":
continue
elif line.endswith(":"):
section, none, desc = line[:-1].partition('-')
section = section.strip()
desc = desc.replace('"', "").strip()
conf[section] = { "desc" : desc }
else:
if listmode:
if line.endswith("]"):
listmode = False
line = line.replace("]","")
value += [self.cast(typ, x.strip()) for x in line.split(",") if x]
if not listmode:
conf[section][option] = { "desc" : desc,
"type" : typ,
"value" : value}
else:
content, none, value = line.partition("=")
content, none, desc = content.partition(":")
desc = desc.replace('"', "").strip()
typ, option = content.split()
value = value.strip()
if value.startswith("["):
if value.endswith("]"):
listmode = False
value = value[:-1]
else:
listmode = True
value = [self.cast(typ, x.strip()) for x in value[1:].split(",") if x]
else:
value = self.cast(typ, value)
if not listmode:
conf[section][option] = { "desc" : desc,
"type" : typ,
"value" : value}
except:
pass
f.close()
return conf
#----------------------------------------------------------------------
def cast(self, typ, value):
"""cast value to given format"""
if type(value) not in (str, unicode):
return value
if typ == "int":
return int(value)
elif typ == "bool":
return True if value.lower() in ("1","true", "on", "an","yes") else False
else:
return value
#----------------------------------------------------------------------
def get(self, section, option):
"""get value"""
return self.config[section][option]["value"]
#----------------------------------------------------------------------
def __getitem__(self, section):
"""provides dictonary like access: c['section']['option']"""
return Section(self, section)
########################################################################
class Section:
"""provides dictionary like access for configparser"""
#----------------------------------------------------------------------
def __init__(self, parser, section):
"""Constructor"""
self.parser = parser
self.section = section
#----------------------------------------------------------------------
def __getitem__(self, item):
"""getitem"""
return self.parser.get(self.section, item)
|
gpl-3.0
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
199,
504,
636,
2443,
363,
492,
543,
63,
6242,
199,
504,
747,
14,
515,
492,
3495,
199,
504,
747,
14,
515,
492,
4263,
421,
199,
3103,
63,
4612,
275,
413,
199,
199,
3949,
199,
533,
14196,
26,
339,
22526,
272,
347,
636,
826,
721,
277,
12,
1101,
694,
304,
267,
408,
11447,
624,
267,
291,
14,
888,
694,
275,
1101,
694,
267,
291,
14,
888,
275,
1052,
2728,
340,
291,
14,
1074,
3353,
837,
288,
291,
14,
739,
2028,
342,
2286,
22526,
272,
347,
1104,
3353,
8,
277,
304,
2728,
340,
440,
3495,
8,
904,
8,
277,
14,
888,
694,
12,
298,
647,
912,
14,
2190,
14150,
288,
372,
756,
267,
289,
275,
1551,
8,
904,
8,
277,
14,
888,
694,
12,
298,
647,
912,
14,
2190,
1288,
298,
4848,
531,
267,
373,
275,
289,
14,
6407,
342,
267,
289,
14,
1600,
342,
267,
373,
275,
373,
59,
86,
14,
1623,
20063,
11,
17,
11455,
1913,
342,
2728,
340,
1109,
8,
86,
9,
665,
6392,
63,
4612,
26,
288,
372,
756,
2728,
372,
715,
258,
5493,
22526,
272,
347,
1586,
2028,
8,
277,
304,
267,
408,
15656,
314,
1101,
570,
624,
2728,
291,
14,
888,
275,
291,
14,
1122,
2028,
8,
904,
8,
277,
14,
888,
694,
12,
298,
647,
912,
14,
2190,
2237,
268,
5493,
22526,
272,
347,
2198,
2028,
8,
277,
12,
1101,
304,
267,
408,
462,
874,
282,
1627,
1101,
493,
624,
2728,
289,
275,
1551,
8,
888,
9,
2728,
1101,
275,
289,
14,
739,
342,
398,
1101,
275,
1101,
14,
1294,
4582,
78,
9981,
17,
2938,
2728,
3743,
275,
1052,
2728,
3420,
12,
945,
12,
574,
12,
6211,
12,
4328,
275,
4873,
5151,
5151,
5151,
341,
2728,
769,
632,
275,
756,
2728,
367,
1004,
315,
1101,
26,
7846,
1004,
275,
1004,
14,
25817,
10064,
531,
327,
14185,
6786,
7846,
340,
1004,
59,
17,
2189,
355,
1004,
275,
1004,
59,
16,
61,
288,
587,
26,
355,
1004,
275,
1004,
59,
18,
61,
7846,
1004,
275,
1004,
14,
1913,
342,
3777,
7846,
862,
26,
1467,
355,
340,
1004,
508,
10812,
490,
1980,
355,
916,
1004,
14,
4130,
20308,
2349,
490,
3420,
12,
7179,
12,
4328,
275,
1004,
4439,
17,
1055,
5312,
21950,
490,
3420,
275,
3420,
14,
1913,
342,
490,
4328,
275,
4328,
14,
1814,
20630,
25354,
1913,
342,
490,
3743,
59,
2792,
61,
275,
469,
298,
3257,
2,
520,
4328,
789,
355,
587,
26,
490,
340,
769,
632,
26,
586,
717,
340,
1004,
14,
4130,
480,
61,
2349,
1169,
769,
632,
275,
756,
1169,
1004,
275,
1004,
14,
1814,
480,
11472,
7230,
2490,
717,
574,
847,
359,
277,
14,
2931,
8,
9749,
12,
671,
14,
1913,
1012,
367,
671,
315,
1004,
14,
1294,
20324,
340,
671,
61,
586,
717,
340,
440,
769,
632,
26,
1169,
3743,
59,
2792,
1527,
1422,
61,
275,
469,
298,
3257,
2,
520,
4328,
12,
10028,
298,
466,
2,
520,
6211,
12,
10028,
298,
585,
2,
520,
574,
93,
221,
586,
586,
490,
587,
26,
717,
1564,
12,
7179,
12,
574,
275,
1004,
14,
5312,
480,
23758,
586,
717,
1564,
12,
7179,
12,
4328,
275,
1564,
14,
5312,
20063,
586,
717,
4328,
275,
4328,
14,
1814,
20630,
25354,
1913,
342,
1362,
717,
6211,
12,
945,
275,
1564,
14,
1294,
342,
1740,
717,
574,
275,
574,
14,
1913,
342,
586,
717,
340,
574,
14,
2460,
480,
905,
304,
1169,
340,
574,
14,
4130,
480,
61,
2349,
17907,
1816,
769,
632,
275,
756,
1816,
574,
275,
574,
4439,
17,
61,
1169,
587,
26,
1816,
769,
632,
275,
715,
2574,
1169,
574,
275,
359,
277,
14,
2931,
8,
9749,
12,
671,
14,
1913,
1012,
367,
671,
315,
574,
59,
17,
11455,
1294,
20324,
340,
671,
61,
717,
587,
26,
1169,
574,
275,
291,
14,
2931,
8,
9749,
12,
574,
9,
586,
717,
340,
440,
769,
632,
26,
1169,
3743,
59,
2792,
1527,
1422,
61,
275,
469,
298,
3257,
2,
520,
4328,
12,
10028,
298,
466,
2,
520,
6211,
12,
10028,
298,
585,
2,
520,
574,
93,
24850,
871,
26,
355,
986,
2151,
586,
267,
289,
14,
1600,
342,
267,
372,
3743,
5493,
22526,
272,
347,
9106,
8,
277,
12,
6211,
12,
574,
304,
267,
408,
2931,
574,
370,
1627,
1475,
624,
267,
340,
730,
8,
585,
9,
440,
315,
334,
495,
12,
2649,
304,
288,
372,
574,
2728,
340,
6211,
508,
298,
442,
582,
288,
372,
1109,
8,
585,
9,
267,
916,
6211,
508,
298,
2245,
582,
288,
372,
715,
340,
574,
14,
2325,
342,
315,
1689,
17,
2266,
2052,
401,
298,
265,
401,
298,
290,
2266,
5066,
531,
587,
756,
267,
587,
26,
288,
372,
574,
5493,
22526,
272,
347,
664,
8,
277,
12,
3420,
12,
945,
304,
267,
408,
362,
574,
624,
267,
372,
291,
14,
888,
59,
2792,
1527,
1422,
7541,
585,
937,
2286,
22526,
272,
347,
636,
6095,
721,
277,
12,
3420,
304,
267,
408,
20121,
1211,
265,
695,
2839,
2879,
26,
286,
459,
2792,
2545,
1422,
418,
624,
267,
372,
15247,
8,
277,
12,
3420,
9,
199,
199,
3949,
199,
533,
15247,
26,
272,
408,
20121,
2600,
2839,
2879,
367,
21230,
624,
339,
22526,
272,
347,
636,
826,
721,
277,
12,
1798,
12,
3420,
304,
267,
408,
11447,
624,
267,
291,
14,
2087,
275,
1798,
267,
291,
14,
2792,
275,
3420,
5493,
22526,
272,
347,
636,
6095,
721,
277,
12,
1242,
304,
267,
408,
6095,
624,
267,
372,
291,
14,
2087,
14,
362,
8,
277,
14,
2792,
12,
1242,
9,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
199,
504,
636,
2443,
363,
492,
543,
63,
6242,
199,
504,
747,
14,
515,
492,
3495,
199,
504,
747,
14,
515,
492,
4263,
421,
199,
3103,
63,
4612,
275,
413,
199,
199,
3949,
199,
533,
14196,
26,
339,
22526,
272,
347,
636,
826,
721,
277,
12,
1101,
694,
304,
267,
408,
11447,
624,
267,
291,
14,
888,
694,
275,
1101,
694,
267,
291,
14,
888,
275,
1052,
2728,
340,
291,
14,
1074,
3353,
837,
288,
291,
14,
739,
2028,
342,
2286,
22526,
272,
347,
1104,
3353,
8,
277,
304,
2728,
340,
440,
3495,
8,
904,
8,
277,
14,
888,
694,
12,
298,
647,
912,
14,
2190,
14150,
288,
372,
756,
267,
289,
275,
1551,
8,
904,
8,
277,
14,
888,
694,
12,
298,
647,
912,
14,
2190,
1288,
298,
4848,
531,
267,
373,
275,
289,
14,
6407,
342,
267,
289,
14,
1600,
342,
267,
373,
275,
373,
59,
86,
14,
1623,
20063,
11,
17,
11455,
1913,
342,
2728,
340,
1109,
8,
86,
9,
665,
6392,
63,
4612,
26,
288,
372,
756,
2728,
372,
715,
258,
5493,
22526,
272,
347,
1586,
2028,
8,
277,
304,
267,
408,
15656,
314,
1101,
570,
624,
2728,
291,
14,
888,
275,
291,
14,
1122,
2028,
8,
904,
8,
277,
14,
888,
694,
12,
298,
647,
912,
14,
2190,
2237,
268,
5493,
22526,
272,
347,
2198,
2028,
8,
277,
12,
1101,
304,
267,
408,
462,
874,
282,
1627,
1101,
493,
624,
2728,
289,
275,
1551,
8,
888,
9,
2728,
1101,
275,
289,
14,
739,
342,
398,
1101,
275,
1101,
14,
1294,
4582,
78,
9981,
17,
2938,
2728,
3743,
275,
1052,
2728,
3420,
12,
945,
12,
574,
12,
6211,
12,
4328,
275,
4873,
5151,
5151,
5151,
341,
2728,
769,
632,
275,
756,
2728,
367,
1004,
315,
1101,
26,
7846,
1004,
275,
1004,
14,
25817,
10064,
531,
327,
14185,
6786,
7846,
340,
1004,
59,
17,
2189,
355,
1004,
275,
1004,
59,
16,
61,
288,
587,
26,
355,
1004,
275,
1004,
59,
18,
61,
7846,
1004,
275,
1004,
14,
1913,
342,
3777,
7846,
862,
26,
1467,
355,
340,
1004,
508,
10812,
490,
1980,
355,
916,
1004,
14,
4130,
20308,
2349,
490,
3420,
12,
7179,
12,
4328,
275,
1004,
4439,
17,
1055,
5312,
21950,
490,
3420,
275,
3420,
14,
1913,
342,
490,
4328,
275,
4328,
14,
1814,
20630,
25354,
1913,
342,
490,
3743,
59,
2792,
61,
275,
469,
298,
3257,
2,
520,
4328,
789,
355,
587,
26,
490,
340,
769,
632,
26,
586,
717,
340,
1004,
14,
4130,
480,
61,
2349,
1169,
769,
632,
275,
756,
1169,
1004,
275,
1004,
14,
1814,
480,
11472,
7230,
2490,
717,
574,
847,
359,
277,
14,
2931,
8,
9749,
12,
671,
14,
1913,
1012,
367,
671,
315,
1004,
14,
1294,
20324,
340,
671,
61,
586,
717,
340,
440,
769,
632,
26,
1169,
3743,
59,
2792,
1527,
1422,
61,
275,
469,
298,
3257,
2,
520,
4328,
12,
10028,
298,
466,
2,
520,
6211,
12,
10028,
298,
585,
2,
520,
574,
93,
221,
586,
586,
490,
587,
26,
717,
1564,
12,
7179,
12,
574,
275,
1004,
14,
5312,
480,
23758,
586,
717,
1564,
12,
7179,
12,
4328,
275,
1564,
14,
5312,
20063,
586,
717,
4328,
275,
4328,
14,
1814,
20630,
25354,
1913,
342,
1362,
717,
6211,
12,
945,
275,
1564,
14,
1294,
342,
1740,
717,
574,
275,
574,
14,
1913,
342,
586,
717,
340,
574,
14,
2460,
480,
905,
304,
1169,
340,
574,
14,
4130,
480,
61,
2349,
17907,
1816,
769,
632,
275,
756,
1816,
574,
275,
574,
4439,
17,
61,
1169,
587,
26,
1816,
769,
632,
275,
715,
2574,
1169,
574,
275,
359,
277,
14,
2931,
8,
9749,
12,
671,
14,
1913,
1012,
367,
671,
315,
574,
59,
17,
11455,
1294,
20324,
340,
671,
61,
717,
587,
26,
1169,
574,
275,
291,
14,
2931,
8,
9749,
12,
574,
9,
586,
717,
340,
440,
769,
632,
26,
1169,
3743,
59,
2792,
1527,
1422,
61,
275,
469,
298,
3257,
2,
520,
4328,
12,
10028,
298,
466,
2,
520,
6211,
12,
10028,
298,
585,
2,
520,
574,
93,
24850,
871,
26,
355,
986,
2151,
586,
267,
289,
14,
1600,
342,
267,
372,
3743,
5493,
22526,
272,
347,
9106,
8,
277,
12,
6211,
12,
574,
304,
267,
408,
2931,
574,
370,
1627,
1475,
624,
267,
340,
730,
8,
585,
9,
440,
315,
334,
495,
12,
2649,
304,
288,
372,
574,
2728,
340,
6211,
508,
298,
442,
582,
288,
372,
1109,
8,
585,
9,
267,
916,
6211,
508,
298,
2245,
582,
288,
372,
715,
340,
574,
14,
2325,
342,
315,
1689,
17,
2266,
2052,
401,
298,
265,
401,
298,
290,
2266,
5066,
531,
587,
756,
267,
587,
26,
288,
372,
574,
5493,
22526,
272,
347,
664,
8,
277,
12,
3420,
12,
945,
304,
267,
408,
362,
574,
624,
267,
372,
291,
14,
888,
59,
2792,
1527,
1422,
7541,
585,
937,
2286,
22526,
272,
347,
636,
6095,
721,
277,
12,
3420,
304,
267,
408,
20121,
1211,
265,
695,
2839,
2879,
26,
286,
459,
2792,
2545,
1422,
418,
624,
267,
372,
15247,
8,
277,
12,
3420,
9,
199,
199,
3949,
199,
533,
15247,
26,
272,
408,
20121,
2600,
2839,
2879,
367,
21230,
624,
339,
22526,
272,
347,
636,
826,
721,
277,
12,
1798,
12,
3420,
304,
267,
408,
11447,
624,
267,
291,
14,
2087,
275,
1798,
267,
291,
14,
2792,
275,
3420,
5493,
22526,
272,
347,
636,
6095,
721,
277,
12,
1242,
304,
267,
408,
6095,
624,
267,
372,
291,
14,
2087,
14,
362,
8,
277,
14,
2792,
12,
1242,
9,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
ychen820/microblog
|
y/google-cloud-sdk/platform/google_appengine/lib/grizzled/grizzled/test/misc/TestReadOnly.py
|
19
|
1623
|
#!/usr/bin/python2.4
# $Id: 5a432ced2c81b94f1e4793cbec98258787f6bc92 $
"""
Tester.
"""
# ---------------------------------------------------------------------------
# Imports
# ---------------------------------------------------------------------------
import google3
from grizzled.misc import ReadOnly, ReadOnlyObjectError
# ---------------------------------------------------------------------------
# Exports
# ---------------------------------------------------------------------------
# ---------------------------------------------------------------------------
# Classes
# ---------------------------------------------------------------------------
class Something(object):
def __init__(self, a=1, b=2):
self.a = a
self.b = b
class TestReadOnly(object):
def setUp(self):
self.something = Something(10, 20)
assert self.something.a == 10
assert self.something.b == 20
self.something.a += 1
assert self.something.a == 11
self.r = ReadOnly(self.something)
def testClassAttr(self):
assert self.r.__class__ is Something
def testIsinstance(self):
assert isinstance(self.r, Something)
def testReadOnlyAccess1(self):
try:
self.r.a += 1
assert False, 'Expected a ReadOnlyObjectError'
except ReadOnlyObjectError, ex:
print 'Got expected %s' % ex
def testReadOnlyAccess2(self):
try:
self.r.a = 200
assert False, 'Expected a ReadOnlyObjectError'
except ReadOnlyObjectError, ex:
print 'Got expected %s' % ex
|
bsd-3-clause
|
[
3381,
2647,
15,
1393,
15,
1548,
18,
14,
20,
199,
3,
2672,
1304,
26,
959,
65,
10657,
6867,
18,
67,
2835,
66,
2635,
70,
17,
69,
14847,
19,
2894,
825,
2905,
821,
1555,
1555,
70,
22,
3776,
2942,
2672,
199,
199,
624,
199,
22403,
14,
199,
624,
199,
199,
3,
5620,
13715,
199,
3,
24339,
199,
3,
5620,
13715,
199,
199,
646,
6233,
19,
199,
504,
27591,
4348,
1146,
14,
9923,
492,
5574,
5903,
12,
5574,
5903,
1692,
547,
199,
199,
3,
5620,
13715,
199,
3,
1316,
5203,
199,
3,
5620,
13715,
199,
199,
3,
5620,
13715,
199,
3,
27939,
199,
3,
5620,
13715,
199,
199,
533,
27173,
8,
785,
304,
272,
347,
636,
826,
721,
277,
12,
282,
29,
17,
12,
330,
29,
18,
304,
267,
291,
14,
65,
275,
282,
267,
291,
14,
66,
275,
330,
199,
199,
533,
1379,
22210,
8,
785,
304,
339,
347,
3613,
8,
277,
304,
267,
291,
14,
10297,
275,
27173,
8,
709,
12,
3388,
9,
267,
702,
291,
14,
10297,
14,
65,
508,
1616,
267,
702,
291,
14,
10297,
14,
66,
508,
3388,
398,
291,
14,
10297,
14,
65,
847,
413,
267,
702,
291,
14,
10297,
14,
65,
508,
4119,
398,
291,
14,
82,
275,
5574,
5903,
8,
277,
14,
10297,
9,
339,
347,
511,
2543,
7144,
8,
277,
304,
267,
702,
291,
14,
82,
855,
533,
363,
365,
27173,
339,
347,
511,
1831,
842,
8,
277,
304,
267,
702,
1228,
8,
277,
14,
82,
12,
27173,
9,
339,
347,
511,
22210,
3946,
17,
8,
277,
304,
267,
862,
26,
288,
291,
14,
82,
14,
65,
847,
413,
288,
702,
756,
12,
283,
6964,
282,
5574,
5903,
1692,
547,
7,
267,
871,
5574,
5903,
1692,
547,
12,
444,
26,
288,
870,
283,
13662,
1420,
450,
83,
7,
450,
444,
339,
347,
511,
22210,
3946,
18,
8,
277,
304,
267,
862,
26,
288,
291,
14,
82,
14,
65,
275,
1926,
288,
702,
756,
12,
283,
6964,
282,
5574,
5903,
1692,
547,
7,
267,
871,
5574,
5903,
1692,
547,
12,
444,
26,
288,
870,
283,
13662,
1420,
450,
83,
7,
450,
444,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
2647,
15,
1393,
15,
1548,
18,
14,
20,
199,
3,
2672,
1304,
26,
959,
65,
10657,
6867,
18,
67,
2835,
66,
2635,
70,
17,
69,
14847,
19,
2894,
825,
2905,
821,
1555,
1555,
70,
22,
3776,
2942,
2672,
199,
199,
624,
199,
22403,
14,
199,
624,
199,
199,
3,
5620,
13715,
199,
3,
24339,
199,
3,
5620,
13715,
199,
199,
646,
6233,
19,
199,
504,
27591,
4348,
1146,
14,
9923,
492,
5574,
5903,
12,
5574,
5903,
1692,
547,
199,
199,
3,
5620,
13715,
199,
3,
1316,
5203,
199,
3,
5620,
13715,
199,
199,
3,
5620,
13715,
199,
3,
27939,
199,
3,
5620,
13715,
199,
199,
533,
27173,
8,
785,
304,
272,
347,
636,
826,
721,
277,
12,
282,
29,
17,
12,
330,
29,
18,
304,
267,
291,
14,
65,
275,
282,
267,
291,
14,
66,
275,
330,
199,
199,
533,
1379,
22210,
8,
785,
304,
339,
347,
3613,
8,
277,
304,
267,
291,
14,
10297,
275,
27173,
8,
709,
12,
3388,
9,
267,
702,
291,
14,
10297,
14,
65,
508,
1616,
267,
702,
291,
14,
10297,
14,
66,
508,
3388,
398,
291,
14,
10297,
14,
65,
847,
413,
267,
702,
291,
14,
10297,
14,
65,
508,
4119,
398,
291,
14,
82,
275,
5574,
5903,
8,
277,
14,
10297,
9,
339,
347,
511,
2543,
7144,
8,
277,
304,
267,
702,
291,
14,
82,
855,
533,
363,
365,
27173,
339,
347,
511,
1831,
842,
8,
277,
304,
267,
702,
1228,
8,
277,
14,
82,
12,
27173,
9,
339,
347,
511,
22210,
3946,
17,
8,
277,
304,
267,
862,
26,
288,
291,
14,
82,
14,
65,
847,
413,
288,
702,
756,
12,
283,
6964,
282,
5574,
5903,
1692,
547,
7,
267,
871,
5574,
5903,
1692,
547,
12,
444,
26,
288,
870,
283,
13662,
1420,
450,
83,
7,
450,
444,
339,
347,
511,
22210,
3946,
18,
8,
277,
304,
267,
862,
26,
288,
291,
14,
82,
14,
65,
275,
1926,
288,
702,
756,
12,
283,
6964,
282,
5574,
5903,
1692,
547,
7,
267,
871,
5574,
5903,
1692,
547,
12,
444,
26,
288,
870,
283,
13662,
1420,
450,
83,
7,
450,
444,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
mcflugen/topoflow
|
topoflow/components/HIS_base.py
|
2
|
36501
|
## Copyright (c) 2010-2013, Scott D. Peckham
## July 2010 (created)
#-----------------------------------------------------------------------
# Notes: This file defines a "base class" for HIS Data components
# that retrieve HIS data from a web service using suds.
#-----------------------------------------------------------------------
#
# class HIS_component
#
# get_attribute()
# get_input_var_names()
# get_output_var_names()
# get_var_name()
# get_var_units()
# ------------------------
# set_constants()
# import_suds() ##########
# initialize()
# update()
# finalize()
# set_computed_input_vars()
# ---------------------------
# check_input_types()
# initialize_computed_vars()
# -------------------------
# open_input_files()
# read_input_files()
# close_input_files()
# ------------------------
# update_outfile_names()
# open_output_files()
# write_output_files()
# close_output_files()
# save_grids()
# save_pixel_values()
#-----------------------------------------------------------------------
import numpy as np
import os
import socket # (to get hostname)
import suds.client
import sys
import urllib
# import urllib2
from topoflow.utils import BMI_base
from topoflow.utils import model_input
from topoflow.utils import model_output
#-----------------------------------------------------------------------
class HIS_component(BMI_base.BMI_component):
_att_map = {
'model_name': 'Data_HIS',
'version': '3.1',
'author_name': 'Scott D. Peckham',
'grid_type': 'none',
'time_step_type': 'fixed',
'step_method': 'none', # (or 'explicit' ??)
#---------------------------------------------------
'comp_name': 'DataHIS',
'model_family': 'TopoFlow',
'cfg_template_file': 'Data_HIS.cfg.in',
'cfg_extension': '_data_his.cfg',
'cmt_var_prefix': '/DataHIS/Input/Var/',
'gui_xml_file': '/home/csdms/cca/topoflow/3.1/src/share/cmt/gui/Data_HIS.xml',
'dialog_title': 'Data: HIS Query Parameters',
'time_units': 'seconds' }
#--------------------------------------------------------
# These must be determined dynamically, based on query.
# Start with empty lists and dictionaries.
#--------------------------------------------------------
_input_var_names = []
### Possible examples: ['Q', 'T_air', 'P']
_output_var_names = []
_var_name_map = {}
_var_units_map = {}
#------------------------------------------------
# Return NumPy string arrays vs. Python lists ?
#------------------------------------------------
## _input_var_names = np.array( _input_var_names )
## _output_var_names = np.array( _output_var_names )
#-------------------------------------------------------------------
def get_attribute(self, att_name):
try:
return self._att_map[ att_name.lower() ]
except:
print '###################################################'
print ' ERROR: Could not find attribute: ' + att_name
print '###################################################'
print ' '
# get_attribute()
#-------------------------------------------------------------------
def get_input_var_names(self):
#--------------------------------------------------------
# Note: These are currently variables needed from other
# components vs. those read from files or GUI.
#--------------------------------------------------------
return self._input_var_names
# get_input_var_names()
#-------------------------------------------------------------------
def get_output_var_names(self):
return self._output_var_names
# get_output_var_names()
#-------------------------------------------------------------------
def get_var_name(self, long_var_name):
return self._var_name_map[ long_var_name ]
# get_var_name()
#-------------------------------------------------------------------
def get_var_units(self, long_var_name):
return self._var_units_map[ long_var_name ]
# get_var_units()
#-------------------------------------------------------------------
## def get_var_type(self, long_var_name):
##
## #---------------------------------------
## # So far, all vars have type "double",
## # but use the one in BMI_base instead.
## #---------------------------------------
## return 'float64'
##
## # get_var_type()
#-------------------------------------------------------------------
def set_constants(self):
#------------------------
# Define some constants
#--------------------------------------------------------------
# Note: When running on one of our cluster's compute nodes,
# vs. on the head node (beach.colorado.edu), we get
# the following error message:
#
# "Unexpected Python exception:
# <urlopen error [Errno -3]
# Temporary failure in name resolution>
#--------------------------------------------------------------
URL = "http://water.sdsc.edu/hiscentral/webservices/hiscentral.asmx?WSDL" # (same msg)
self.HIS_Central_URL = URL
#----------------------------------------------
# URL for National Elevation Dataset (NED) ??
#----------------------------------------------
# URL2 = "http://extract.cr.usgs.gov/axis2/services/DownloadService?wsdl"
# URL3 = "http://gisdata.usgs.gov/XMLWebServices2/Elevation_Service.asmx"
# info ="http://imselev.cr.usgs.gov/WMS_Capabilities/USGS_EDC_Elev_NED/capabilities_1_3_0.xml"
#----------------------------------------------------------
# Create a Python dictionary with proxies. The compute
# nodes on our cluster don't have direct access so need
# to specify the head node as proxy (beach.colorado.edu).
#----------------------------------------------------------
# Well-known TCP/IP port numbers:
# HTTP: 80 (or sometimes 8080, 7080, 9080)
# HTTPS: 443
# FTP-Control: 21
# FTP-Data: 20
# SSH: 22
# Telnet: 23
# We can get this number on localhost with:
# socket.getservbyname('http', 'tcp') # (service by name)
# Or the other way around:
# socket.getservbyport(8080) # (-> 'webcache' on beach)
#--------------------------------------------------------------
# Not used now. Proxy is now set as environment variable
# "http_proxy="http://128.138.77.51", but still needs to
# be set for everyone.
#--------------------------------------------------------------
## self.proxies = {'http':'http://128.138.77.51',
## 'https':'https://128.138.77.51',
## 'ftp':'ftp://128.138.77.51'}
self.proxies = {'http':'http://128.138.77.51:80',
'https':'https://128.138.77.51:443',
'ftp':'ftp://128.138.77.51:21'}
#------------------------------------------
# Get the hostname (head or compute node)
#------------------------------------------
self.hostname = socket.gethostname()
#-----------------------------
# Option to run a diagnostic
#-----------------------------
## if (self.DEBUG):
## print 'Trying to open HIS Central URL directly...'
## try:
## HIS_URL = urllib.urlopen( self.HIS_Central_URL,
## proxies=self.proxies )
## # HIS_URL = urllib2.urlopen( self.HIS_Central_URL,
## # proxies=self.proxies )
## print HIS_URL
## print 'SUCCESS: Opened URL with urllib.urlopen().'
## except:
## print 'FAILURE: Could not open URL with urllib.urlopen().'
## print ' '
# set_constants()
#-------------------------------------------------------------------
def import_suds(self):
python_version = sys.version[:5] # (e.g. 2.6.2)
# python_version = sys.version[:3] # (e.g. 2.6)
try:
import suds
print 'Imported suds version: ' + suds.__version__
print 'Python version: ' + python_version
print 'Hostname or node: ' + self.hostname
print ' '
return True
except:
print ' '
print 'SORRY, Cannot access HIS web service because'
print 'the "suds.client" package cannot be imported.'
print ' '
## if (python_version != '2.6'):
## print 'Note that "suds" is only installed for'
## print 'Python version 2.6 on "beach".'
## print 'The current Python version is:', python_version
## print ' '
return False
# import_suds()
#-------------------------------------------------------------------
def initialize(self, cfg_file=None, mode="nondriver",
SILENT=False):
if not(SILENT):
print ' '
print 'Data-HIS component: Initializing...'
self.status = 'initializing' # (OpenMI 2.0 convention)
self.mode = mode
self.cfg_file = cfg_file
#-----------------------------------------------
# Load component parameters from a config file
#-----------------------------------------------
self.set_constants()
self.initialize_config_vars()
self.read_grid_info()
# self.initialize_basin_vars()
self.initialize_time_vars()
self.dt = 1.0 # (Needed for final report.)
self.n_steps = 1 # (Need for BMI_base.update_time().)
#----------------------------------
# Has component been turned off ?
#----------------------------------
if (self.comp_status == 'Disabled'):
if not(SILENT):
print 'HIS Data component: Disabled.'
self.T_air = np.float64(0) ####################################
self.P = np.float64(0)
self.DONE = True
self.status = 'initialized' # (OpenMI 2.0 convention)
return
else:
self.DONE = False ########
#---------------------------------------------
# Open input files needed to initialize vars
#---------------------------------------------
# self.open_input_files()
# self.read_input_files()
# self.check_input_types()
# self.initialize_computed_vars()
#--------------------------------------
# Import suds and print version, etc.
#--------------------------------------
result = self.import_suds()
#-------------------------------
# These are not used currently
#-------------------------------
# import xml.etree.ElementTree as ET
# import os, fnmatch
# import datetime as DT
self.open_output_files()
self.status = 'initialized' # (OpenMI 2.0 convention)
# initialize()
#-------------------------------------------------------------------
## def update(self, dt=-1.0, time_seconds=None):
def update(self, dt=-1.0):
if (self.comp_status == 'Disabled'): return
self.status = 'updating' # (OpenMI 2.0 convention)
#----------------------------------------
# Retrieve data values from web service
#----------------------------------------
xmin = str(self.west_edge_lon)
xmax = str(self.east_edge_lon)
ymax = str(self.north_edge_lat)
ymin = str(self.south_edge_lat)
networkIDs = ''
print 'Attempting to retrieve data from HIS Central...'
print ' HIS_Central_URL =', self.HIS_Central_URL
print ' Data keyword =', self.data_keyword
## print ' xmin, xmax =', xmin, ',', xmax
## print ' ymin, ymax =', ymin, ',', ymax
## print ' start_date =', self.start_date
## print ' stop_date =', self.stop_date
#----------------------------------------------------------------------
# (7/19/10) This works on both head and compute nodes now, after
# reconfiguring the system (UnixOps) and adding the environment
# variable "http_proxy" to ".bash_profile".
#----------------------------------------------------------------------
client = suds.client.Client( self.HIS_Central_URL )
# proxy = self.proxies ######
#----------------------------------------------------------------------
# client = suds.client.Client( self.HIS_Central_URL )
# ERROR: Unexpected Python exception: <urlopen error [Errno -3]
# Temporary failure in name resolution>
#----------------------------------------------------------------------
# client = suds.client.Client( self.HIS_Central_URL, proxy=proxy )
# ERROR: Unexpected Python exception: HTTP Error 404: Not Found
#----------------------------------------------------------------------
# client = suds.client.Client( self.HIS_Central_URL, service=proxy )
# ERROR: Unexpected Python exception:
# "service" must be: (<type 'int'>, <type 'basestring'>
#----------------------------------------------------------------------
# from suds.transport.http import HttpAuthenticated
# tran = HttpAuthenticated(proxy=proxy)
# client = suds.client.Client( self.HIS_Central_URL, transport=tran )
# ERROR: Unexpected Python exception: HTTP Error 404: Not Found
#----------------------------------------------------------------------
# from suds.transport.http import HttpTransport
# tran = HttpTransport( proxy=proxy )
# client = suds.client.Client( self.HIS_Central_URL, transport=tran )
# ERROR: Unexpected Python exception: HTTP Error 404: Not Found
#----------------------------------------------------------------------
# from suds.transport import HttpTransport
# tran = HttpTransport( proxy=proxy )
# client = suds.client.Client( self.HIS_Central_URL, transport=tran )
# ERROR: Unexpected Python exception: cannot import name HttpTransport
#----------------------------------------------------------------------
# client = suds.client.Client( url='' )
# client.set_options( url=self.HIS_Central_URL, proxy=proxy )
# ERROR: Unexpected Python exception: unknown url type:
#----------------------------------------------------------------------
# client = suds.client.Client( url='http' )
# client.set_options( url=self.HIS_Central_URL, proxy=proxy )
# ERROR: Unexpected Python exception: unknown url type: http
#----------------------------------------------------------------------
# client = suds.client.Client( url='http://' )
# client.set_options( url=self.HIS_Central_URL, proxy=proxy )
# ERROR: Unexpected Python exception: <urlopen error no host given>
#----------------------------------------------------------------------
# client = suds.client.Client( url=self.HIS_Central_URL )
# client.set_options( url=self.HIS_Central_URL, proxy=proxy )
# ERROR: Unexpected Python exception: <urlopen error [Errno -3]
# Temporary failure in name resolution>
#----------------------------------------------------------------------
# client = suds.client.Client( url=self.HIS_Central_URL )
# client.set_options( url=self.HIS_Central_URL, proxy=proxy )
# ERROR: Unexpected Python exception: <urlopen error [Errno -3]
# Temporary failure in name resolution>
#----------------------------------------------------------------------
# client = suds.client.Client( url="http://localhost" )
# client.set_options( url=self.HIS_Central_URL, proxy=proxy )
# ERROR: Unexpected Python exception: <urlopen error [Errno 111]
# Connection refused>
#----------------------------------------------------------------------
# client = suds.client.Client( url="http://127.0.0.1" )
# client.set_options( url=self.HIS_Central_URL, proxy=proxy )
# ERROR: Unexpected Python exception: <urlopen error [Errno 111]
# Connection refused>
#----------------------------------------------------------------------
# from suds.transport.http import HttpTransport
# tran = HttpTransport()
# import urllib2
# opener = urllib2.build_opener( proxy )
# tran.urlopener = opener
# client = suds.client.Client( self.HIS_Central_URL, transport=tran )
# ERROR: Unexpected Python exception:
# expected BaseHandler instance, got <type 'dict'>
#----------------------------------------------------------------------
# from suds.transport.http import HttpTransport
# tran = HttpTransport()
# import urllib2
# proxy_han = urllib2.ProxyHandler( proxies=proxy )
# opener = urllib2.build_opener( proxy_han )
# tran.urlopener = opener
# client = suds.client.Client( self.HIS_Central_URL, transport=tran )
# ERROR: Unexpected Python exception:
# expected BaseHandler instance, got <type 'dict'>
#----------------------------------------------------------------------
# from suds.transport.http import HttpTransport
# tran = HttpTransport()
# import urllib2
# proxy_han = urllib2.ProxyHandler( self.proxies )
# opener = urllib2.build_opener( proxy_han )
# tran.urlopener = opener
# client = suds.client.Client( self.HIS_Central_URL, transport=tran )
# ERROR: Unexpected Python exception:
# expected BaseHandler instance, got <type 'dict'>
#----------------------------------------------------------------------
# print client #########
#######################
## print 'Calling client.add_prefix() method...'
## client.add_prefix( 'hiscentral.asmx' ) #####
## print 'Created client object. ########'
response = client.service.GetSeriesCatalogForBox2(xmin, xmax, ymin, ymax, \
self.data_keyword, networkIDs, \
self.start_date, self.stop_date)
rep_len = len(response)
if (rep_len == 0):
print '-------------------------------------------'
print 'SORRY, Your query returned no matches.'
print ' You may want to try:'
print ' (1) Changing the keyword.'
print ' (2) Expanding the bounding box.'
print ' (3) Expanding the range of dates.'
print '-------------------------------------------'
print ' '
self.DONE = True
return
# print 'len(response) =', rep_len
series_array = response[0]
n_series = len( series_array )
print 'Number of time series retrieved =', n_series
print 'Max allowed number of series =', self.max_n_series
print ' '
#------------------------------------------------
# Return if n_series > max_n_series. (10/25/11)
#------------------------------------------------
if (n_series > self.max_n_series):
print '###############################################'
print ' ABORTING: n_series > max_n_series.'
print ' n_series =', n_series
print ' max_n_series =', self.max_n_series
print '###############################################'
print ' '
return
#-----------------------------------
# Check the data for nodata/NaN ??
#-----------------------------------
#------------------------------------------
# Read next infil vars from input files ?
#------------------------------------------
# if (self.time_index > 0):
# self.read_input_files()
#-------------------------------------------
# Extract data values for each time series
#-------------------------------------------
## print 'Writing time series to local files...'
series_num = 0
# print 'Processing array of time series...'
for series in series_array:
series_num += 1
print '========================================================='
print 'Working on series', series_num, 'of', n_series
try:
client = suds.client.Client( series.ServURL )
values_obj = client.service.GetValuesObject(series.location, series.VarCode, \
self.start_date, self.stop_date)
values = values_obj.timeSeries.values
n_values = values._count
SKIP = False
if (n_values < 1):
print 'Skipping series: n_values =', n_values, ' ( < 1 )'
print ' '
SKIP = True
if (n_values > self.max_n_values):
print 'Skipping series: n_values =', n_values
print ' but max_n_values =', self.max_n_values
print ' '
SKIP = True
#------------------------------------------------------
# Get actual time series values and date-time strings
#------------------------------------------------------
if not(SKIP):
#-------------------------------------
# Is there a faster way than this ??
#-------------------------------------
vals = np.asarray([np.float(val.value) for val in values.value])
dts = np.asarray([val._dateTime for val in values.value])
#-----------------------------------------------
# Write the data values to a text file here ??
#-----------------------------------------------
## if (self.DEBUG):
if (True):
print 'series ID =', series_num
print 'size(series) =', np.size(vals)
print 'min(series) =', vals.min()
print 'max(series) =', vals.max()
print 'series.Sitename =', series.Sitename
print 'series.location =', series.location
print 'series.VarName =', series.VarName
print 'series.VarCode =', series.VarCode
print 'series.ValueCount =', series.ValueCount
print 'series.datatype =', series.datatype
print 'series.valuetype =', series.valuetype
print 'series.timeunits =', series.timeunits
# print 'len(series) =', len(series) # (always 18)
# print 'type(values_obj) =', type(values_obj) # ("instance")
# print 'type(values) =', type(values) # ("instance")
print ' '
except:
print 'ERROR: Skipping time series.'
print ' '
#----------------------------------------------
# Write user-specified data to output files ?
#----------------------------------------------
# Components use own self.time_sec by default.
#-----------------------------------------------
#self.write_output_files()
## self.write_output_files( time_seconds )
#-----------------------------
# Update internal clock
# after write_output_files()
#-----------------------------
self.update_time( dt )
self.status = 'updated' # (OpenMI 2.0 convention)
#-----------------------------------
# Only allow one call to update ??
#-----------------------------------
self.DONE = True
# update()
#-------------------------------------------------------------------
def finalize(self):
self.status = 'finalizing' # (OpenMI 2.0 convention)
## self.close_input_files() ## TopoFlow input "data streams"
self.close_output_files()
self.status = 'finalized' # (OpenMI 2.0 convention)
# self.print_final_report(comp_name='HIS Data component')
#---------------------------
# Release all of the ports
#----------------------------------------
# Make this call in "finalize()" method
# of the component's CCA Imple file
#----------------------------------------
# self.release_cca_ports( port_names, d_services )
# finalize()
#-------------------------------------------------------------------
def set_computed_input_vars(self):
#-----------------------------------------------
# Convert start_month & stop_month from string
# to integer. January should be 1.
#-----------------------------------------------
month_list = ['January', 'February', 'March', 'April',
'May', 'June', 'July', 'August', 'September',
'October', 'November', 'December']
self.start_month = month_list.index( self.start_month ) + 1
self.stop_month = month_list.index( self.stop_month ) + 1
#-----------------------------------------------
# Construct the query start date and stop date
#-----------------------------------------------
self.start_date = str(self.start_year) + '-' + \
str(self.start_month).zfill(2) + '-' + \
str(self.start_day).zfill(2)
self.stop_date = str(self.stop_year) + '-' + \
str(self.stop_month).zfill(2) + '-' + \
str(self.stop_day).zfill(2)
#--------------------------------------------------------
# Define these here, so all components can use the same
# output file functions, like "open_output_files()".
#--------------------------------------------------------
## self.SAVE_Q0_GRIDS = False
## self.SAVE_ZW_GRIDS = False
#--------------------------------------------
# Can maybe remove this when GUI info file
# has the "save cubes" part put back in.
#--------------------------------------------
## self.q_cs_file = ''
## self.p_cs_file = ''
#---------------------------------------------------------
# Make sure that all "save_dts" are larger or equal to
# the specified process dt. There is no point in saving
# results more often than they change.
# Issue a message to this effect if any are smaller ??
#---------------------------------------------------------
## self.save_grid_dt = np.maximum(self.save_grid_dt, self.dt)
## self.save_pixels_dt = np.maximum(self.save_pixels_dt, self.dt)
## self.save_profile_dt = np.maximum(self.save_profile_dt, self.dt)
## self.save_cube_dt = np.maximum(self.save_cube_dt, self.dt)
# set_computed_input_vars()
#-------------------------------------------------------------------
def check_input_types(self):
#------------------------------------------------------
# Notes: Usually this will be overridden by a given
# method of computing ET. But this one should
# work for Green-Ampt and Smith-Parlange.
#------------------------------------------------------
## are_scalars = np.array([
## self.mp.is_scalar('P'),
## self.sp.is_scalar('SM'),
## self.gp.is_scalar('h_table'),
## #------------------------------
## self.is_scalar('Ks'),
## self.is_scalar('Ki'),
## self.is_scalar('qs'),
## self.is_scalar('qi'),
## self.is_scalar('G'),
## self.is_scalar('gam') ])
##
## self.ALL_SCALARS = np.all(are_scalars)
self.ALL_SCALARS = True # (HIS only works with time series)
# check_input_types()
#-------------------------------------------------------------------
def initialize_computed_vars(self):
pass
# initialize_computed_vars()
#-------------------------------------------------------------------
def open_input_files(self):
pass
## self.Ks_unit = [] # (empty lists to hold file objects)
##
## for k in xrange(self.n_layers):
## self.Ks_unit.append( model_input.open_file(self.Ks_type[k], self.Ks_file[k]) )
# open_input_files()
#-------------------------------------------------------------------
def read_input_files(self):
if (self.DEBUG):
print 'Calling read_input_files()...'
pass
## rti = self.rti
##
## #-------------------------------------------------------
## # All grids are assumed to have data type of Float32.
## #-------------------------------------------------------
## # This method works for Green-Ampt and Smith-Parlange
## # but must be overridden for Richards 1D.
## #-------------------------------------------------------
## # NB! Green-Ampt and Smith-Parlange currently only
## # support ONE layer (n_layers == 1).
## #-------------------------------------------------------
## for k in xrange(self.n_layers):
## Ks = model_input.read_next(self.Ks_unit[k], self.Ks_type[k], rti)
## if (Ks is not None): self.Ks[k] = Ks
# read_input_files()
#-------------------------------------------------------------------
def close_input_files(self):
pass
## for k in xrange(self.n_layers):
## if (self.Ks_type[k] != 'Scalar'): self.Ks_unit[k].close()
# close_input_files()
#-------------------------------------------------------------------
def update_outfile_names(self):
pass
#-------------------------------------------------
# Notes: Append out_directory to outfile names.
#-------------------------------------------------
## self.v0_gs_file = (self.out_directory + self.v0_gs_file)
## #-------------------------------------------------------------
## self.v0_ts_file = (self.out_directory + self.v0_ts_file)
# update_outfile_names()
#-------------------------------------------------------------------
def open_output_files(self):
#-------------------------------------------------
# Notes: v0 = infiltration rate at surface
#-------------------------------------------------
model_output.check_netcdf()
self.update_outfile_names()
## #--------------------------------------
## # Open new files to write grid stacks
## #--------------------------------------
## if (self.SAVE_V0_GRIDS):
## model_output.open_new_gs_file( self, self.v0_gs_file, self.rti,
## var_name='v0',
## long_name='infiltration_rate_at_surface',
## units_name='m/s')
##
## #--------------------------------------
## # Open new files to write time series
## #--------------------------------------
## IDs = self.outlet_IDs
## if (self.SAVE_V0_PIXELS):
## model_output.open_new_ts_file( self, self.v0_ts_file, IDs,
## var_name='v0',
## long_name='infiltration_rate_at_surface',
## units_name='m/s')
# open_output_files()
#-------------------------------------------------------------------
def write_output_files(self, time_seconds=None):
#---------------------------------------------------------
# Notes: This function was written to use only model
# time (maybe from a caller) in seconds, and
# the save_grid_dt and save_pixels_dt parameters
# read by read_cfg_file().
#
# read_cfg_file() makes sure that all of
# the "save_dts" are larger than or equal to the
# process dt.
#---------------------------------------------------------
if (self.DEBUG):
print 'Calling write_output_files()...'
#-----------------------------------------
# Allows time to be passed from a caller
#-----------------------------------------
if (time_seconds is None):
time_seconds = self.time_sec
model_time = int(time_seconds)
#----------------------------------------
# Save computed values at sampled times
#----------------------------------------
if (model_time % int(self.save_grid_dt) == 0):
self.save_grids()
if (model_time % int(self.save_pixels_dt) == 0):
self.save_pixel_values()
# write_output_files()
#-------------------------------------------------------------------
def close_output_files(self):
pass
## if (self.SAVE_V0_GRIDS): model_output.close_gs_file( self, 'v0')
##
## if (self.SAVE_V0_PIXELS): model_output.close_ts_file( self, 'v0')
# close_output_files()
#-------------------------------------------------------------------
def save_grids(self):
#-----------------------------------
# Save grid stack to a netCDF file
#---------------------------------------------
# Note that add_grid() methods will convert
# var from scalar to grid now, if necessary.
#---------------------------------------------
if (self.DEBUG):
print 'Calling save_grids()...'
## if (self.SAVE_V0_GRIDS):
## model_output.add_grid( self, self.IN, 'v0', self.time_min )
# save_grids()
#-------------------------------------------------------------------
def save_pixel_values(self):
if (self.DEBUG):
print 'Calling save_pixel_values()...'
## IDs = self.outlet_IDs
## time = self.time_min ########
##
## #--------------------------------------------
## # Save a subsequence of IN var pixel values
## #--------------------------------------------
## if (self.SAVE_V0_PIXELS):
## model_output.add_values_at_IDs( self, time, self.IN, 'v0', IDs )
# save_pixel_values()
#-------------------------------------------------------------------
|
mit
|
[
199,
309,
1898,
334,
67,
9,
7129,
13,
6965,
12,
428,
331,
6215,
577,
14,
11379,
346,
10670,
199,
309,
1603,
21797,
7129,
334,
3966,
9,
199,
199,
7656,
12797,
199,
3,
221,
8144,
26,
221,
961,
570,
7890,
282,
298,
1095,
1021,
2,
367,
869,
1311,
3918,
7323,
199,
3,
3515,
626,
8044,
869,
1311,
666,
687,
282,
3330,
2435,
1808,
30713,
14,
199,
7656,
12797,
199,
3,
199,
3,
221,
1021,
869,
1311,
63,
3173,
199,
3,
199,
3,
420,
664,
63,
3215,
342,
199,
3,
420,
664,
63,
1210,
63,
1391,
63,
1247,
342,
221,
199,
3,
420,
664,
63,
1199,
63,
1391,
63,
1247,
342,
199,
3,
420,
664,
63,
1391,
63,
354,
342,
199,
3,
420,
664,
63,
1391,
63,
5260,
342,
199,
3,
420,
10652,
518,
199,
3,
420,
663,
63,
5559,
342,
199,
3,
420,
492,
63,
9648,
795,
342,
3777,
21937,
309,
199,
3,
420,
8265,
342,
199,
3,
420,
1678,
342,
199,
3,
420,
17284,
342,
199,
3,
420,
663,
63,
14378,
63,
1210,
63,
2936,
342,
199,
3,
420,
10652,
13715,
199,
3,
420,
1104,
63,
1210,
63,
1313,
342,
199,
3,
420,
8265,
63,
14378,
63,
2936,
342,
199,
3,
420,
10652,
9960,
199,
3,
420,
1551,
63,
1210,
63,
1725,
342,
199,
3,
420,
1586,
63,
1210,
63,
1725,
342,
199,
3,
420,
4002,
63,
1210,
63,
1725,
342,
199,
3,
420,
10652,
518,
199,
3,
420,
1678,
63,
4984,
63,
1247,
342,
199,
3,
420,
1551,
63,
1199,
63,
1725,
342,
199,
3,
420,
2218,
63,
1199,
63,
1725,
342,
199,
3,
420,
4002,
63,
1199,
63,
1725,
342,
199,
3,
420,
3354,
63,
7928,
795,
342,
199,
3,
420,
3354,
63,
8435,
63,
1459,
342,
199,
199,
7656,
12797,
199,
199,
646,
2680,
465,
980,
199,
199,
646,
747,
199,
646,
2838,
3515,
327,
334,
475,
664,
6246,
9,
199,
646,
30713,
14,
1258,
199,
646,
984,
199,
646,
4011,
199,
3,
492,
4011,
18,
199,
199,
504,
11111,
1659,
14,
1208,
492,
699,
10709,
63,
1095,
199,
504,
11111,
1659,
14,
1208,
492,
1402,
63,
1210,
199,
504,
11111,
1659,
14,
1208,
492,
1402,
63,
1199,
199,
199,
7656,
12797,
199,
533,
869,
1311,
63,
3173,
8,
34,
10709,
63,
1095,
14,
34,
10709,
63,
3173,
304,
339,
485,
6796,
63,
1130,
275,
469,
267,
283,
1238,
63,
354,
356,
260,
283,
1451,
63,
40,
1311,
297,
267,
283,
1023,
356,
3322,
283,
19,
14,
17,
297,
267,
283,
2502,
63,
354,
356,
263,
283,
51,
331,
6215,
577,
14,
11379,
346,
10670,
297,
267,
283,
3825,
63,
466,
356,
3515,
283,
3592,
297,
267,
283,
521,
63,
2926,
63,
466,
356,
258,
283,
5964,
297,
267,
283,
2926,
63,
765,
356,
263,
283,
3592,
297,
221,
327,
334,
269,
283,
10306,
7,
5805,
17076,
267,
27721,
2595,
267,
283,
863,
63,
354,
356,
3515,
283,
1451,
40,
1311,
297,
263,
267,
283,
1238,
63,
6606,
356,
755,
283,
6105,
79,
5060,
297,
267,
283,
4128,
63,
1160,
63,
493,
356,
221,
283,
1451,
63,
40,
1311,
14,
4128,
14,
262,
297,
267,
283,
4128,
63,
3435,
356,
420,
2513,
576,
63,
866,
14,
4128,
297,
267,
283,
67,
2037,
63,
1391,
63,
1861,
356,
258,
1994,
1451,
40,
1311,
15,
3205,
15,
5894,
3678,
267,
283,
5885,
63,
1652,
63,
493,
356,
755,
1994,
4219,
15,
29060,
706,
15,
30031,
15,
2119,
1618,
674,
15,
19,
14,
17,
15,
2164,
15,
6251,
15,
67,
2037,
15,
5885,
15,
1451,
63,
40,
1311,
14,
1652,
297,
267,
283,
7196,
63,
1213,
356,
755,
283,
1451,
26,
869,
1311,
8133,
3897,
297,
267,
283,
521,
63,
5260,
356,
260,
283,
4515,
7,
789,
339,
27721,
518,
272,
327,
5723,
1471,
506,
12037,
18774,
12,
4079,
641,
1827,
14,
272,
327,
7707,
543,
2701,
5548,
436,
11196,
14,
272,
27721,
518,
272,
485,
1210,
63,
1391,
63,
1247,
275,
942,
339,
6754,
18558,
7251,
26,
221,
788,
49,
297,
283,
52,
63,
8387,
297,
283,
48,
418,
272,
485,
1199,
63,
1391,
63,
1247,
275,
942,
339,
485,
1391,
63,
354,
63,
1130,
275,
1052,
339,
485,
1391,
63,
5260,
63,
1130,
275,
1052,
339,
27721,
14821,
327,
1432,
20602,
1059,
6572,
8118,
14,
2018,
5548,
5805,
272,
27721,
272,
925,
485,
1210,
63,
1391,
63,
1247,
221,
275,
980,
14,
1144,
8,
485,
1210,
63,
1391,
63,
1247,
776,
272,
925,
485,
1199,
63,
1391,
63,
1247,
275,
980,
14,
1144,
8,
485,
1199,
63,
1391,
63,
1247,
776,
339,
14309,
2595,
272,
347,
664,
63,
3215,
8,
277,
12,
15115,
63,
354,
304,
398,
862,
26,
288,
372,
291,
423,
6796,
63,
1130,
59,
15115,
63,
354,
14,
2325,
342,
1622,
267,
871,
26,
288,
870,
283,
22529,
5680,
7,
288,
870,
283,
12539,
26,
18615,
440,
2342,
2225,
26,
283,
435,
15115,
63,
354,
288,
870,
283,
22529,
5680,
7,
288,
870,
283,
283,
339,
327,
257,
664,
63,
3215,
342,
272,
14309,
2595,
272,
347,
664,
63,
1210,
63,
1391,
63,
1247,
8,
277,
304,
398,
27721,
518,
267,
327,
3390,
26,
5723,
787,
5544,
2860,
4346,
687,
1163,
267,
327,
755,
7323,
8118,
14,
5204,
1586,
687,
1584,
503,
17160,
14,
267,
27721,
518,
259,
267,
372,
291,
423,
1210,
63,
1391,
63,
1247,
2286,
327,
257,
664,
63,
1210,
63,
1391,
63,
1247,
342,
272,
14309,
2595,
272,
347,
664,
63,
1199,
63,
1391,
63,
1247,
8,
277,
304,
523,
267,
372,
291,
423,
1199,
63,
1391,
63,
1247,
2286,
327,
257,
664,
63,
1199,
63,
1391,
63,
1247,
342,
272,
14309,
2595,
272,
347,
664,
63,
1391,
63,
354,
8,
277,
12,
1846,
63,
1391,
63,
354,
304,
10631,
372,
291,
423,
1391,
63,
354,
63,
1130,
59,
1846,
63,
1391,
63,
354,
1622,
339,
327,
257,
664,
63,
1391,
63,
354,
342,
272,
14309,
2595,
272,
347,
664,
63,
1391,
63,
5260,
8,
277,
12,
1846,
63,
1391,
63,
354,
304,
398,
372,
291,
423,
1391,
63,
5260,
63,
1130,
59,
1846,
63,
1391,
63,
354,
1622,
272,
272,
327,
257,
664,
63,
1391,
63,
5260,
342,
272,
14309,
2595,
199,
309,
259
] |
[
309,
1898,
334,
67,
9,
7129,
13,
6965,
12,
428,
331,
6215,
577,
14,
11379,
346,
10670,
199,
309,
1603,
21797,
7129,
334,
3966,
9,
199,
199,
7656,
12797,
199,
3,
221,
8144,
26,
221,
961,
570,
7890,
282,
298,
1095,
1021,
2,
367,
869,
1311,
3918,
7323,
199,
3,
3515,
626,
8044,
869,
1311,
666,
687,
282,
3330,
2435,
1808,
30713,
14,
199,
7656,
12797,
199,
3,
199,
3,
221,
1021,
869,
1311,
63,
3173,
199,
3,
199,
3,
420,
664,
63,
3215,
342,
199,
3,
420,
664,
63,
1210,
63,
1391,
63,
1247,
342,
221,
199,
3,
420,
664,
63,
1199,
63,
1391,
63,
1247,
342,
199,
3,
420,
664,
63,
1391,
63,
354,
342,
199,
3,
420,
664,
63,
1391,
63,
5260,
342,
199,
3,
420,
10652,
518,
199,
3,
420,
663,
63,
5559,
342,
199,
3,
420,
492,
63,
9648,
795,
342,
3777,
21937,
309,
199,
3,
420,
8265,
342,
199,
3,
420,
1678,
342,
199,
3,
420,
17284,
342,
199,
3,
420,
663,
63,
14378,
63,
1210,
63,
2936,
342,
199,
3,
420,
10652,
13715,
199,
3,
420,
1104,
63,
1210,
63,
1313,
342,
199,
3,
420,
8265,
63,
14378,
63,
2936,
342,
199,
3,
420,
10652,
9960,
199,
3,
420,
1551,
63,
1210,
63,
1725,
342,
199,
3,
420,
1586,
63,
1210,
63,
1725,
342,
199,
3,
420,
4002,
63,
1210,
63,
1725,
342,
199,
3,
420,
10652,
518,
199,
3,
420,
1678,
63,
4984,
63,
1247,
342,
199,
3,
420,
1551,
63,
1199,
63,
1725,
342,
199,
3,
420,
2218,
63,
1199,
63,
1725,
342,
199,
3,
420,
4002,
63,
1199,
63,
1725,
342,
199,
3,
420,
3354,
63,
7928,
795,
342,
199,
3,
420,
3354,
63,
8435,
63,
1459,
342,
199,
199,
7656,
12797,
199,
199,
646,
2680,
465,
980,
199,
199,
646,
747,
199,
646,
2838,
3515,
327,
334,
475,
664,
6246,
9,
199,
646,
30713,
14,
1258,
199,
646,
984,
199,
646,
4011,
199,
3,
492,
4011,
18,
199,
199,
504,
11111,
1659,
14,
1208,
492,
699,
10709,
63,
1095,
199,
504,
11111,
1659,
14,
1208,
492,
1402,
63,
1210,
199,
504,
11111,
1659,
14,
1208,
492,
1402,
63,
1199,
199,
199,
7656,
12797,
199,
533,
869,
1311,
63,
3173,
8,
34,
10709,
63,
1095,
14,
34,
10709,
63,
3173,
304,
339,
485,
6796,
63,
1130,
275,
469,
267,
283,
1238,
63,
354,
356,
260,
283,
1451,
63,
40,
1311,
297,
267,
283,
1023,
356,
3322,
283,
19,
14,
17,
297,
267,
283,
2502,
63,
354,
356,
263,
283,
51,
331,
6215,
577,
14,
11379,
346,
10670,
297,
267,
283,
3825,
63,
466,
356,
3515,
283,
3592,
297,
267,
283,
521,
63,
2926,
63,
466,
356,
258,
283,
5964,
297,
267,
283,
2926,
63,
765,
356,
263,
283,
3592,
297,
221,
327,
334,
269,
283,
10306,
7,
5805,
17076,
267,
27721,
2595,
267,
283,
863,
63,
354,
356,
3515,
283,
1451,
40,
1311,
297,
263,
267,
283,
1238,
63,
6606,
356,
755,
283,
6105,
79,
5060,
297,
267,
283,
4128,
63,
1160,
63,
493,
356,
221,
283,
1451,
63,
40,
1311,
14,
4128,
14,
262,
297,
267,
283,
4128,
63,
3435,
356,
420,
2513,
576,
63,
866,
14,
4128,
297,
267,
283,
67,
2037,
63,
1391,
63,
1861,
356,
258,
1994,
1451,
40,
1311,
15,
3205,
15,
5894,
3678,
267,
283,
5885,
63,
1652,
63,
493,
356,
755,
1994,
4219,
15,
29060,
706,
15,
30031,
15,
2119,
1618,
674,
15,
19,
14,
17,
15,
2164,
15,
6251,
15,
67,
2037,
15,
5885,
15,
1451,
63,
40,
1311,
14,
1652,
297,
267,
283,
7196,
63,
1213,
356,
755,
283,
1451,
26,
869,
1311,
8133,
3897,
297,
267,
283,
521,
63,
5260,
356,
260,
283,
4515,
7,
789,
339,
27721,
518,
272,
327,
5723,
1471,
506,
12037,
18774,
12,
4079,
641,
1827,
14,
272,
327,
7707,
543,
2701,
5548,
436,
11196,
14,
272,
27721,
518,
272,
485,
1210,
63,
1391,
63,
1247,
275,
942,
339,
6754,
18558,
7251,
26,
221,
788,
49,
297,
283,
52,
63,
8387,
297,
283,
48,
418,
272,
485,
1199,
63,
1391,
63,
1247,
275,
942,
339,
485,
1391,
63,
354,
63,
1130,
275,
1052,
339,
485,
1391,
63,
5260,
63,
1130,
275,
1052,
339,
27721,
14821,
327,
1432,
20602,
1059,
6572,
8118,
14,
2018,
5548,
5805,
272,
27721,
272,
925,
485,
1210,
63,
1391,
63,
1247,
221,
275,
980,
14,
1144,
8,
485,
1210,
63,
1391,
63,
1247,
776,
272,
925,
485,
1199,
63,
1391,
63,
1247,
275,
980,
14,
1144,
8,
485,
1199,
63,
1391,
63,
1247,
776,
339,
14309,
2595,
272,
347,
664,
63,
3215,
8,
277,
12,
15115,
63,
354,
304,
398,
862,
26,
288,
372,
291,
423,
6796,
63,
1130,
59,
15115,
63,
354,
14,
2325,
342,
1622,
267,
871,
26,
288,
870,
283,
22529,
5680,
7,
288,
870,
283,
12539,
26,
18615,
440,
2342,
2225,
26,
283,
435,
15115,
63,
354,
288,
870,
283,
22529,
5680,
7,
288,
870,
283,
283,
339,
327,
257,
664,
63,
3215,
342,
272,
14309,
2595,
272,
347,
664,
63,
1210,
63,
1391,
63,
1247,
8,
277,
304,
398,
27721,
518,
267,
327,
3390,
26,
5723,
787,
5544,
2860,
4346,
687,
1163,
267,
327,
755,
7323,
8118,
14,
5204,
1586,
687,
1584,
503,
17160,
14,
267,
27721,
518,
259,
267,
372,
291,
423,
1210,
63,
1391,
63,
1247,
2286,
327,
257,
664,
63,
1210,
63,
1391,
63,
1247,
342,
272,
14309,
2595,
272,
347,
664,
63,
1199,
63,
1391,
63,
1247,
8,
277,
304,
523,
267,
372,
291,
423,
1199,
63,
1391,
63,
1247,
2286,
327,
257,
664,
63,
1199,
63,
1391,
63,
1247,
342,
272,
14309,
2595,
272,
347,
664,
63,
1391,
63,
354,
8,
277,
12,
1846,
63,
1391,
63,
354,
304,
10631,
372,
291,
423,
1391,
63,
354,
63,
1130,
59,
1846,
63,
1391,
63,
354,
1622,
339,
327,
257,
664,
63,
1391,
63,
354,
342,
272,
14309,
2595,
272,
347,
664,
63,
1391,
63,
5260,
8,
277,
12,
1846,
63,
1391,
63,
354,
304,
398,
372,
291,
423,
1391,
63,
5260,
63,
1130,
59,
1846,
63,
1391,
63,
354,
1622,
272,
272,
327,
257,
664,
63,
1391,
63,
5260,
342,
272,
14309,
2595,
199,
309,
259,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
mzdaniel/oh-mainline
|
vendor/packages/Django/django/contrib/localflavor/it/forms.py
|
273
|
3027
|
"""
IT-specific Form helpers
"""
from django.core.validators import EMPTY_VALUES
from django.forms import ValidationError
from django.forms.fields import Field, RegexField, Select
from django.utils.translation import ugettext_lazy as _
from django.utils.encoding import smart_unicode
from django.contrib.localflavor.it.util import ssn_check_digit, vat_number_check_digit
import re
class ITZipCodeField(RegexField):
default_error_messages = {
'invalid': _('Enter a valid zip code.'),
}
def __init__(self, *args, **kwargs):
super(ITZipCodeField, self).__init__(r'^\d{5}$',
max_length=None, min_length=None, *args, **kwargs)
class ITRegionSelect(Select):
"""
A Select widget that uses a list of IT regions as its choices.
"""
def __init__(self, attrs=None):
from it_region import REGION_CHOICES
super(ITRegionSelect, self).__init__(attrs, choices=REGION_CHOICES)
class ITProvinceSelect(Select):
"""
A Select widget that uses a list of IT provinces as its choices.
"""
def __init__(self, attrs=None):
from it_province import PROVINCE_CHOICES
super(ITProvinceSelect, self).__init__(attrs, choices=PROVINCE_CHOICES)
class ITSocialSecurityNumberField(RegexField):
"""
A form field that validates Italian Social Security numbers (codice fiscale).
For reference see http://www.agenziaentrate.it/ and search for
'Informazioni sulla codificazione delle persone fisiche'.
"""
default_error_messages = {
'invalid': _(u'Enter a valid Social Security number.'),
}
def __init__(self, *args, **kwargs):
super(ITSocialSecurityNumberField, self).__init__(r'^\w{3}\s*\w{3}\s*\w{5}\s*\w{5}$',
max_length=None, min_length=None, *args, **kwargs)
def clean(self, value):
value = super(ITSocialSecurityNumberField, self).clean(value)
if value in EMPTY_VALUES:
return u''
value = re.sub('\s', u'', value).upper()
try:
check_digit = ssn_check_digit(value)
except ValueError:
raise ValidationError(self.error_messages['invalid'])
if not value[15] == check_digit:
raise ValidationError(self.error_messages['invalid'])
return value
class ITVatNumberField(Field):
"""
A form field that validates Italian VAT numbers (partita IVA).
"""
default_error_messages = {
'invalid': _(u'Enter a valid VAT number.'),
}
def clean(self, value):
value = super(ITVatNumberField, self).clean(value)
if value in EMPTY_VALUES:
return u''
try:
vat_number = int(value)
except ValueError:
raise ValidationError(self.error_messages['invalid'])
vat_number = str(vat_number).zfill(11)
check_digit = vat_number_check_digit(vat_number[0:10])
if not vat_number[10] == check_digit:
raise ValidationError(self.error_messages['invalid'])
return smart_unicode(vat_number)
|
agpl-3.0
|
[
624,
199,
649,
13,
6100,
8204,
10897,
199,
624,
199,
199,
504,
1639,
14,
1018,
14,
11346,
492,
16589,
63,
15514,
199,
504,
1639,
14,
3351,
492,
8505,
199,
504,
1639,
14,
3351,
14,
955,
492,
5024,
12,
12939,
792,
12,
9496,
199,
504,
1639,
14,
1208,
14,
6893,
492,
10366,
63,
6395,
465,
485,
199,
504,
1639,
14,
1208,
14,
2991,
492,
11179,
63,
2975,
199,
504,
1639,
14,
2828,
14,
320,
696,
276,
4271,
14,
390,
14,
1974,
492,
308,
5167,
63,
1074,
63,
8573,
12,
373,
292,
63,
1955,
63,
1074,
63,
8573,
199,
646,
295,
199,
199,
533,
473,
52,
8674,
3034,
792,
8,
5103,
792,
304,
272,
849,
63,
705,
63,
3431,
275,
469,
267,
283,
3197,
356,
4018,
8468,
282,
1686,
3482,
1233,
8038,
272,
789,
272,
347,
636,
826,
721,
277,
12,
627,
589,
12,
1011,
958,
304,
267,
1613,
8,
649,
8674,
3034,
792,
12,
291,
2843,
826,
721,
82,
15542,
68,
91,
21,
19204,
267,
1390,
63,
1267,
29,
403,
12,
1748,
63,
1267,
29,
403,
12,
627,
589,
12,
1011,
958,
9,
199,
199,
533,
473,
52,
10708,
5446,
8,
5446,
304,
272,
408,
272,
437,
9496,
3938,
626,
4440,
282,
769,
402,
473,
52,
16150,
465,
2399,
3415,
14,
272,
408,
272,
347,
636,
826,
721,
277,
12,
3290,
29,
403,
304,
267,
687,
652,
63,
4551,
492,
14142,
1075,
63,
16236,
267,
1613,
8,
649,
10708,
5446,
12,
291,
2843,
826,
721,
3288,
12,
3415,
29,
23030,
63,
16236,
9,
199,
199,
533,
473,
52,
919,
86,
2855,
5446,
8,
5446,
304,
272,
408,
272,
437,
9496,
3938,
626,
4440,
282,
769,
402,
473,
52,
557,
11908,
823,
465,
2399,
3415,
14,
272,
408,
272,
347,
636,
826,
721,
277,
12,
3290,
29,
403,
304,
267,
687,
652,
63,
20397,
2855,
492,
3611,
54,
568,
2089,
63,
16236,
267,
1613,
8,
649,
919,
86,
2855,
5446,
12,
291,
2843,
826,
721,
3288,
12,
3415,
29,
2514,
54,
568,
2089,
63,
16236,
9,
199,
199,
533,
473,
9730,
28748,
7676,
3259,
792,
8,
5103,
792,
304,
272,
408,
272,
437,
1824,
901,
626,
29280,
2779,
25861,
2002,
7180,
13863,
5579,
334,
331,
328,
301,
289,
374,
2357,
680,
272,
2104,
3659,
1937,
1455,
921,
1544,
14,
24758,
90,
4674,
18626,
323,
14,
390,
15,
436,
2754,
367,
272,
283,
607,
10928,
90,
1636,
73,
308,
348,
416,
512,
328,
329,
696,
16079,
368,
2150,
274,
1126,
83,
368,
5883,
338,
595,
1370,
272,
408,
272,
849,
63,
705,
63,
3431,
275,
469,
267,
283,
3197,
356,
12561,
85,
7,
8468,
282,
1686,
2002,
7180,
13863,
1329,
8038,
272,
789,
339,
347,
636,
826,
721,
277,
12,
627,
589,
12,
1011,
958,
304,
267,
1613,
8,
5930,
28748,
7676,
3259,
792,
12,
291,
2843,
826,
721,
82,
15542,
87,
91,
19,
4988,
83,
7590,
87,
91,
19,
4988,
83,
7590,
87,
91,
21,
4988,
83,
7590,
87,
91,
21,
19204,
267,
1390,
63,
1267,
29,
403,
12,
1748,
63,
1267,
29,
403,
12,
627,
589,
12,
1011,
958,
9,
339,
347,
3633,
8,
277,
12,
574,
304,
267,
574,
275,
1613,
8,
5930,
28748,
7676,
3259,
792,
12,
291,
680,
3118,
8,
585,
9,
267,
340,
574,
315,
16589,
63,
15514,
26,
288,
372,
399,
891,
267,
574,
275,
295,
14,
954,
2258,
83,
297,
399,
6448,
574,
680,
4142,
342,
267,
862,
26,
288,
1104,
63,
8573,
275,
308,
5167,
63,
1074,
63,
8573,
8,
585,
9,
267,
871,
1722,
26,
288,
746,
8505,
8,
277,
14,
705,
63,
3431,
459,
3197,
1105,
267,
340,
440,
574,
59,
1046,
61,
508,
1104,
63,
8573,
26,
288,
746,
8505,
8,
277,
14,
705,
63,
3431,
459,
3197,
1105,
267,
372,
574,
199,
199,
533,
473,
12764,
292,
3259,
792,
8,
792,
304,
272,
408,
272,
437,
1824,
901,
626,
29280,
2779,
25861,
812,
619,
5579,
334,
23512,
502,
473,
15162,
680,
272,
408,
272,
849,
63,
705,
63,
3431,
275,
469,
267,
283,
3197,
356,
12561,
85,
7,
8468,
282,
1686,
812,
619,
1329,
8038,
272,
789,
339,
347,
3633,
8,
277,
12,
574,
304,
267,
574,
275,
1613,
8,
649,
54,
292,
3259,
792,
12,
291,
680,
3118,
8,
585,
9,
267,
340,
574,
315,
16589,
63,
15514,
26,
288,
372,
399,
891,
267,
862,
26,
288,
373,
292,
63,
1955,
275,
1109,
8,
585,
9,
267,
871,
1722,
26,
288,
746,
8505,
8,
277,
14,
705,
63,
3431,
459,
3197,
1105,
267,
373,
292,
63,
1955,
275,
620,
8,
16305,
63,
1955,
680,
26626,
8,
845,
9,
267,
1104,
63,
8573,
275,
373,
292,
63,
1955,
63,
1074,
63,
8573,
8,
16305,
63,
1955,
59,
16,
26,
709,
566,
267,
340,
440,
373,
292,
63,
1955,
59,
709,
61,
508,
1104,
63,
8573,
26,
288,
746,
8505,
8,
277,
14,
705,
63,
3431,
459,
3197,
1105,
267,
372,
11179,
63,
2975,
8,
16305,
63,
1955,
9,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
199,
649,
13,
6100,
8204,
10897,
199,
624,
199,
199,
504,
1639,
14,
1018,
14,
11346,
492,
16589,
63,
15514,
199,
504,
1639,
14,
3351,
492,
8505,
199,
504,
1639,
14,
3351,
14,
955,
492,
5024,
12,
12939,
792,
12,
9496,
199,
504,
1639,
14,
1208,
14,
6893,
492,
10366,
63,
6395,
465,
485,
199,
504,
1639,
14,
1208,
14,
2991,
492,
11179,
63,
2975,
199,
504,
1639,
14,
2828,
14,
320,
696,
276,
4271,
14,
390,
14,
1974,
492,
308,
5167,
63,
1074,
63,
8573,
12,
373,
292,
63,
1955,
63,
1074,
63,
8573,
199,
646,
295,
199,
199,
533,
473,
52,
8674,
3034,
792,
8,
5103,
792,
304,
272,
849,
63,
705,
63,
3431,
275,
469,
267,
283,
3197,
356,
4018,
8468,
282,
1686,
3482,
1233,
8038,
272,
789,
272,
347,
636,
826,
721,
277,
12,
627,
589,
12,
1011,
958,
304,
267,
1613,
8,
649,
8674,
3034,
792,
12,
291,
2843,
826,
721,
82,
15542,
68,
91,
21,
19204,
267,
1390,
63,
1267,
29,
403,
12,
1748,
63,
1267,
29,
403,
12,
627,
589,
12,
1011,
958,
9,
199,
199,
533,
473,
52,
10708,
5446,
8,
5446,
304,
272,
408,
272,
437,
9496,
3938,
626,
4440,
282,
769,
402,
473,
52,
16150,
465,
2399,
3415,
14,
272,
408,
272,
347,
636,
826,
721,
277,
12,
3290,
29,
403,
304,
267,
687,
652,
63,
4551,
492,
14142,
1075,
63,
16236,
267,
1613,
8,
649,
10708,
5446,
12,
291,
2843,
826,
721,
3288,
12,
3415,
29,
23030,
63,
16236,
9,
199,
199,
533,
473,
52,
919,
86,
2855,
5446,
8,
5446,
304,
272,
408,
272,
437,
9496,
3938,
626,
4440,
282,
769,
402,
473,
52,
557,
11908,
823,
465,
2399,
3415,
14,
272,
408,
272,
347,
636,
826,
721,
277,
12,
3290,
29,
403,
304,
267,
687,
652,
63,
20397,
2855,
492,
3611,
54,
568,
2089,
63,
16236,
267,
1613,
8,
649,
919,
86,
2855,
5446,
12,
291,
2843,
826,
721,
3288,
12,
3415,
29,
2514,
54,
568,
2089,
63,
16236,
9,
199,
199,
533,
473,
9730,
28748,
7676,
3259,
792,
8,
5103,
792,
304,
272,
408,
272,
437,
1824,
901,
626,
29280,
2779,
25861,
2002,
7180,
13863,
5579,
334,
331,
328,
301,
289,
374,
2357,
680,
272,
2104,
3659,
1937,
1455,
921,
1544,
14,
24758,
90,
4674,
18626,
323,
14,
390,
15,
436,
2754,
367,
272,
283,
607,
10928,
90,
1636,
73,
308,
348,
416,
512,
328,
329,
696,
16079,
368,
2150,
274,
1126,
83,
368,
5883,
338,
595,
1370,
272,
408,
272,
849,
63,
705,
63,
3431,
275,
469,
267,
283,
3197,
356,
12561,
85,
7,
8468,
282,
1686,
2002,
7180,
13863,
1329,
8038,
272,
789,
339,
347,
636,
826,
721,
277,
12,
627,
589,
12,
1011,
958,
304,
267,
1613,
8,
5930,
28748,
7676,
3259,
792,
12,
291,
2843,
826,
721,
82,
15542,
87,
91,
19,
4988,
83,
7590,
87,
91,
19,
4988,
83,
7590,
87,
91,
21,
4988,
83,
7590,
87,
91,
21,
19204,
267,
1390,
63,
1267,
29,
403,
12,
1748,
63,
1267,
29,
403,
12,
627,
589,
12,
1011,
958,
9,
339,
347,
3633,
8,
277,
12,
574,
304,
267,
574,
275,
1613,
8,
5930,
28748,
7676,
3259,
792,
12,
291,
680,
3118,
8,
585,
9,
267,
340,
574,
315,
16589,
63,
15514,
26,
288,
372,
399,
891,
267,
574,
275,
295,
14,
954,
2258,
83,
297,
399,
6448,
574,
680,
4142,
342,
267,
862,
26,
288,
1104,
63,
8573,
275,
308,
5167,
63,
1074,
63,
8573,
8,
585,
9,
267,
871,
1722,
26,
288,
746,
8505,
8,
277,
14,
705,
63,
3431,
459,
3197,
1105,
267,
340,
440,
574,
59,
1046,
61,
508,
1104,
63,
8573,
26,
288,
746,
8505,
8,
277,
14,
705,
63,
3431,
459,
3197,
1105,
267,
372,
574,
199,
199,
533,
473,
12764,
292,
3259,
792,
8,
792,
304,
272,
408,
272,
437,
1824,
901,
626,
29280,
2779,
25861,
812,
619,
5579,
334,
23512,
502,
473,
15162,
680,
272,
408,
272,
849,
63,
705,
63,
3431,
275,
469,
267,
283,
3197,
356,
12561,
85,
7,
8468,
282,
1686,
812,
619,
1329,
8038,
272,
789,
339,
347,
3633,
8,
277,
12,
574,
304,
267,
574,
275,
1613,
8,
649,
54,
292,
3259,
792,
12,
291,
680,
3118,
8,
585,
9,
267,
340,
574,
315,
16589,
63,
15514,
26,
288,
372,
399,
891,
267,
862,
26,
288,
373,
292,
63,
1955,
275,
1109,
8,
585,
9,
267,
871,
1722,
26,
288,
746,
8505,
8,
277,
14,
705,
63,
3431,
459,
3197,
1105,
267,
373,
292,
63,
1955,
275,
620,
8,
16305,
63,
1955,
680,
26626,
8,
845,
9,
267,
1104,
63,
8573,
275,
373,
292,
63,
1955,
63,
1074,
63,
8573,
8,
16305,
63,
1955,
59,
16,
26,
709,
566,
267,
340,
440,
373,
292,
63,
1955,
59,
709,
61,
508,
1104,
63,
8573,
26,
288,
746,
8505,
8,
277,
14,
705,
63,
3431,
459,
3197,
1105,
267,
372,
11179,
63,
2975,
8,
16305,
63,
1955,
9,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
bac/horizon
|
openstack_dashboard/dashboards/admin/hypervisors/compute/tests.py
|
27
|
11116
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from django.core.urlresolvers import reverse
from django import http
from mox3.mox import IsA # noqa
from openstack_dashboard import api
from openstack_dashboard.test import helpers as test
class EvacuateHostViewTest(test.BaseAdminViewTests):
@test.create_stubs({api.nova: ('hypervisor_list',
'hypervisor_stats',
'service_list')})
def test_index(self):
hypervisor = self.hypervisors.list().pop().hypervisor_hostname
services = [service for service in self.services.list()
if service.binary == 'nova-compute']
api.nova.service_list(IsA(http.HttpRequest),
binary='nova-compute').AndReturn(services)
self.mox.ReplayAll()
url = reverse('horizon:admin:hypervisors:compute:evacuate_host',
args=[hypervisor])
res = self.client.get(url)
self.assertTemplateUsed(res,
'admin/hypervisors/compute/evacuate_host.html')
@test.create_stubs({api.nova: ('hypervisor_list',
'hypervisor_stats',
'service_list',
'evacuate_host')})
def test_successful_post(self):
hypervisor = self.hypervisors.list().pop().hypervisor_hostname
services = [service for service in self.services.list()
if service.binary == 'nova-compute']
api.nova.service_list(IsA(http.HttpRequest),
binary='nova-compute').AndReturn(services)
api.nova.evacuate_host(IsA(http.HttpRequest),
services[1].host,
services[0].host,
False).AndReturn(True)
self.mox.ReplayAll()
url = reverse('horizon:admin:hypervisors:compute:evacuate_host',
args=[hypervisor])
form_data = {'current_host': services[1].host,
'target_host': services[0].host,
'on_shared_storage': False}
res = self.client.post(url, form_data)
dest_url = reverse('horizon:admin:hypervisors:index')
self.assertNoFormErrors(res)
self.assertMessageCount(success=1)
self.assertRedirectsNoFollow(res, dest_url)
@test.create_stubs({api.nova: ('hypervisor_list',
'hypervisor_stats',
'service_list',
'evacuate_host')})
def test_failing_nova_call_post(self):
hypervisor = self.hypervisors.list().pop().hypervisor_hostname
services = [service for service in self.services.list()
if service.binary == 'nova-compute']
api.nova.service_list(IsA(http.HttpRequest),
binary='nova-compute').AndReturn(services)
api.nova.evacuate_host(IsA(http.HttpRequest),
services[1].host,
services[0].host,
False).AndRaise(self.exceptions.nova)
self.mox.ReplayAll()
url = reverse('horizon:admin:hypervisors:compute:evacuate_host',
args=[hypervisor])
form_data = {'current_host': services[1].host,
'target_host': services[0].host,
'on_shared_storage': False}
res = self.client.post(url, form_data)
dest_url = reverse('horizon:admin:hypervisors:index')
self.assertMessageCount(error=1)
self.assertRedirectsNoFollow(res, dest_url)
class MigrateHostViewTest(test.BaseAdminViewTests):
def test_index(self):
disabled_services = [service for service in self.services.list()
if service.binary == 'nova-compute'
and service.status == 'disabled']
disabled_service = disabled_services[0]
self.mox.ReplayAll()
url = reverse('horizon:admin:hypervisors:compute:migrate_host',
args=[disabled_service.host])
res = self.client.get(url)
self.assertNoMessages()
self.assertTemplateUsed(res,
'admin/hypervisors/compute/migrate_host.html')
@test.create_stubs({api.nova: ('migrate_host',)})
def test_maintenance_host_cold_migration_succeed(self):
disabled_services = [service for service in self.services.list()
if service.binary == 'nova-compute'
and service.status == 'disabled']
disabled_service = disabled_services[0]
api.nova.migrate_host(
IsA(http.HttpRequest),
disabled_service.host,
live_migrate=False,
disk_over_commit=False,
block_migration=False
).AndReturn(True)
self.mox.ReplayAll()
url = reverse('horizon:admin:hypervisors:compute:migrate_host',
args=[disabled_service.host])
form_data = {'current_host': disabled_service.host,
'migrate_type': 'cold_migrate',
'disk_over_commit': False,
'block_migration': False}
res = self.client.post(url, form_data)
dest_url = reverse('horizon:admin:hypervisors:index')
self.assertNoFormErrors(res)
self.assertMessageCount(success=1)
self.assertRedirectsNoFollow(res, dest_url)
@test.create_stubs({api.nova: ('migrate_host',)})
def test_maintenance_host_live_migration_succeed(self):
disabled_services = [service for service in self.services.list()
if service.binary == 'nova-compute'
and service.status == 'disabled']
disabled_service = disabled_services[0]
api.nova.migrate_host(
IsA(http.HttpRequest),
disabled_service.host,
live_migrate=True,
disk_over_commit=False,
block_migration=True
).AndReturn(True)
self.mox.ReplayAll()
url = reverse('horizon:admin:hypervisors:compute:migrate_host',
args=[disabled_service.host])
form_data = {'current_host': disabled_service.host,
'migrate_type': 'live_migrate',
'disk_over_commit': False,
'block_migration': True}
res = self.client.post(url, form_data)
dest_url = reverse('horizon:admin:hypervisors:index')
self.assertNoFormErrors(res)
self.assertMessageCount(success=1)
self.assertRedirectsNoFollow(res, dest_url)
@test.create_stubs({api.nova: ('migrate_host',)})
def test_maintenance_host_migration_fails(self):
disabled_services = [service for service in self.services.list()
if service.binary == 'nova-compute'
and service.status == 'disabled']
disabled_service = disabled_services[0]
api.nova.migrate_host(
IsA(http.HttpRequest),
disabled_service.host,
live_migrate=True,
disk_over_commit=False,
block_migration=True
).AndRaise(self.exceptions.nova)
self.mox.ReplayAll()
url = reverse('horizon:admin:hypervisors:compute:migrate_host',
args=[disabled_service.host])
form_data = {'current_host': disabled_service.host,
'migrate_type': 'live_migrate',
'disk_over_commit': False,
'block_migration': True}
res = self.client.post(url, form_data)
dest_url = reverse('horizon:admin:hypervisors:index')
self.assertMessageCount(error=1)
self.assertRedirectsNoFollow(res, dest_url)
class DisableServiceViewTest(test.BaseAdminViewTests):
@test.create_stubs({api.nova: ('hypervisor_list',
'hypervisor_stats')})
def test_index(self):
hypervisor = self.hypervisors.list().pop().hypervisor_hostname
self.mox.ReplayAll()
url = reverse('horizon:admin:hypervisors:compute:disable_service',
args=[hypervisor])
res = self.client.get(url)
template = 'admin/hypervisors/compute/disable_service.html'
self.assertTemplateUsed(res, template)
@test.create_stubs({api.nova: ('hypervisor_list',
'hypervisor_stats',
'service_disable')})
def test_successful_post(self):
hypervisor = self.hypervisors.list().pop().hypervisor_hostname
services = [service for service in self.services.list()
if service.binary == 'nova-compute']
api.nova.service_disable(IsA(http.HttpRequest),
services[0].host,
'nova-compute',
reason='test disable').AndReturn(True)
self.mox.ReplayAll()
url = reverse('horizon:admin:hypervisors:compute:disable_service',
args=[hypervisor])
form_data = {'host': services[0].host,
'reason': 'test disable'}
res = self.client.post(url, form_data)
dest_url = reverse('horizon:admin:hypervisors:index')
self.assertNoFormErrors(res)
self.assertMessageCount(success=1)
self.assertRedirectsNoFollow(res, dest_url)
@test.create_stubs({api.nova: ('hypervisor_list',
'hypervisor_stats',
'service_disable')})
def test_failing_nova_call_post(self):
hypervisor = self.hypervisors.list().pop().hypervisor_hostname
services = [service for service in self.services.list()
if service.binary == 'nova-compute']
api.nova.service_disable(
IsA(http.HttpRequest), services[0].host, 'nova-compute',
reason='test disable').AndRaise(self.exceptions.nova)
self.mox.ReplayAll()
url = reverse('horizon:admin:hypervisors:compute:disable_service',
args=[hypervisor])
form_data = {'host': services[0].host,
'reason': 'test disable'}
res = self.client.post(url, form_data)
dest_url = reverse('horizon:admin:hypervisors:index')
self.assertMessageCount(error=1)
self.assertRedirectsNoFollow(res, dest_url)
|
apache-2.0
|
[
3,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
1265,
1443,
199,
3,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
2047,
1443,
3332,
199,
3,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
258,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
2428,
199,
3,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
1666,
314,
199,
3,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
4204,
199,
3,
1334,
314,
844,
14,
199,
199,
504,
1639,
14,
1018,
14,
16522,
492,
3837,
199,
504,
1639,
492,
1455,
199,
504,
18610,
19,
14,
6625,
492,
29719,
221,
327,
8151,
199,
199,
504,
13869,
63,
9743,
492,
2986,
199,
504,
13869,
63,
9743,
14,
396,
492,
10897,
465,
511,
421,
199,
533,
662,
15367,
4767,
4965,
2768,
774,
8,
396,
14,
1563,
4880,
2768,
2925,
304,
272,
768,
396,
14,
981,
63,
8957,
2561,
1246,
14,
6765,
26,
661,
18237,
63,
513,
297,
3521,
283,
18237,
63,
3200,
297,
3521,
283,
1364,
63,
513,
22220,
272,
347,
511,
63,
1080,
8,
277,
304,
267,
21724,
275,
291,
14,
9547,
27215,
14,
513,
1252,
1935,
1252,
18237,
63,
4269,
267,
8500,
275,
359,
1364,
367,
2435,
315,
291,
14,
5950,
14,
513,
342,
490,
340,
2435,
14,
3008,
508,
283,
6765,
13,
3357,
418,
267,
2986,
14,
6765,
14,
1364,
63,
513,
8,
14104,
8,
1014,
14,
10441,
395,
2892,
3366,
534,
6765,
13,
3357,
1959,
8572,
8,
5950,
9,
398,
291,
14,
6625,
14,
12982,
342,
398,
1166,
275,
3837,
360,
16561,
26,
2113,
26,
9547,
27215,
26,
3357,
26,
6857,
645,
4767,
63,
1102,
297,
1993,
1249,
1524,
18237,
566,
267,
522,
275,
291,
14,
1258,
14,
362,
8,
633,
9,
267,
291,
14,
19661,
8,
470,
12,
1816,
283,
2113,
15,
9547,
27215,
15,
3357,
15,
6857,
645,
4767,
63,
1102,
14,
1360,
358,
339,
768,
396,
14,
981,
63,
8957,
2561,
1246,
14,
6765,
26,
661,
18237,
63,
513,
297,
3521,
283,
18237,
63,
3200,
297,
3521,
283,
1364,
63,
513,
297,
3521,
283,
6857,
645,
4767,
63,
1102,
22220,
272,
347,
511,
63,
18157,
63,
1932,
8,
277,
304,
267,
21724,
275,
291,
14,
9547,
27215,
14,
513,
1252,
1935,
1252,
18237,
63,
4269,
267,
8500,
275,
359,
1364,
367,
2435,
315,
291,
14,
5950,
14,
513,
342,
490,
340,
2435,
14,
3008,
508,
283,
6765,
13,
3357,
418,
398,
2986,
14,
6765,
14,
1364,
63,
513,
8,
14104,
8,
1014,
14,
10441,
395,
2892,
3366,
534,
6765,
13,
3357,
1959,
8572,
8,
5950,
9,
267,
2986,
14,
6765,
14,
6857,
645,
4767,
63,
1102,
8,
14104,
8,
1014,
14,
10441,
395,
3044,
8500,
59,
17,
1055,
1102,
12,
3044,
8500,
59,
16,
1055,
1102,
12,
3044,
756,
680,
8572,
8,
549,
9,
267,
291,
14,
6625,
14,
12982,
342,
398,
1166,
275,
3837,
360,
16561,
26,
2113,
26,
9547,
27215,
26,
3357,
26,
6857,
645,
4767,
63,
1102,
297,
1993,
1249,
1524,
18237,
566,
398,
1824,
63,
576,
275,
791,
1818,
63,
1102,
356,
8500,
59,
17,
1055,
1102,
12,
2151,
283,
1375,
63,
1102,
356,
8500,
59,
16,
1055,
1102,
12,
2151,
283,
265,
63,
5555,
63,
3494,
356,
756,
93,
398,
522,
275,
291,
14,
1258,
14,
1932,
8,
633,
12,
1824,
63,
576,
9,
267,
2053,
63,
633,
275,
3837,
360,
16561,
26,
2113,
26,
9547,
27215,
26,
1080,
358,
267,
291,
14,
22389,
2821,
9298,
8,
470,
9,
267,
291,
14,
479,
2209,
2353,
8,
3742,
29,
17,
9,
267,
291,
14,
17466,
1944,
18696,
8,
470,
12,
2053,
63,
633,
9,
339,
768,
396,
14,
981,
63,
8957,
2561,
1246,
14,
6765,
26,
661,
18237,
63,
513,
297,
3521,
283,
18237,
63,
3200,
297,
3521,
283,
1364,
63,
513,
297,
3521,
283,
6857,
645,
4767,
63,
1102,
22220,
272,
347,
511,
63,
25299,
63,
6765,
63,
1250,
63,
1932,
8,
277,
304,
267,
21724,
275,
291,
14,
9547,
27215,
14,
513,
1252,
1935,
1252,
18237,
63,
4269,
267,
8500,
275,
359,
1364,
367,
2435,
315,
291,
14,
5950,
14,
513,
342,
490,
340,
2435,
14,
3008,
508,
283,
6765,
13,
3357,
418,
398,
2986,
14,
6765,
14,
1364,
63,
513,
8,
14104,
8,
1014,
14,
10441,
395,
2892,
3366,
534,
6765,
13,
3357,
1959,
8572,
8,
5950,
9,
267,
2986,
14,
6765,
14,
6857,
645,
4767,
63,
1102,
8,
14104,
8,
1014,
14,
10441,
395,
3044,
8500,
59,
17,
1055,
1102,
12,
3044,
8500,
59,
16,
1055,
1102,
12,
3044,
756,
680,
3325,
18111,
8,
277,
14,
3924,
14,
6765,
9,
267,
291,
14,
6625,
14,
12982,
342,
398,
1166,
275,
3837,
360,
16561,
26,
2113,
26,
9547,
27215,
26,
3357,
26,
6857,
645,
4767,
63,
1102,
297,
1993,
1249,
1524,
18237,
566,
398,
1824,
63,
576,
275,
791,
1818,
63,
1102,
356,
8500,
59,
17,
1055,
1102,
12,
2151,
283,
1375,
63,
1102,
356,
8500,
59,
16,
1055,
1102,
12,
2151,
283,
265,
63,
5555,
63,
3494,
356,
756,
93,
398,
522,
275,
291,
14,
1258,
14,
1932,
8,
633,
12,
1824,
63,
576,
9,
267,
2053,
63,
633,
275,
3837,
360,
16561,
26,
2113,
26,
9547,
27215,
26,
1080,
358,
267,
291,
14,
479,
2209,
2353,
8,
705,
29,
17,
9,
267,
291,
14,
17466,
1944,
18696,
8,
470,
12,
2053,
63,
633,
9,
421,
199,
533,
28195,
1866,
4965,
2768,
774,
8,
396,
14,
1563,
4880,
2768,
2925,
304,
272,
347,
511,
63,
1080,
8,
277,
304,
267,
6980,
63,
5950,
275,
359,
1364,
367,
2435,
315,
291,
14,
5950,
14,
513,
342,
2490,
340,
2435,
14,
3008,
508,
283,
6765,
13,
3357,
7,
2490,
436,
2435,
14,
1205,
508,
283,
7011,
418,
267,
6980,
63,
1364,
275,
6980,
63,
5950,
59,
16,
61,
267,
291,
14,
6625,
14,
12982,
342,
267,
1166,
275,
3837,
360,
16561,
26,
2113,
26,
9547,
27215,
26,
3357,
26,
8462,
63
] |
[
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
1265,
1443,
199,
3,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
2047,
1443,
3332,
199,
3,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
258,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
2428,
199,
3,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
1666,
314,
199,
3,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
4204,
199,
3,
1334,
314,
844,
14,
199,
199,
504,
1639,
14,
1018,
14,
16522,
492,
3837,
199,
504,
1639,
492,
1455,
199,
504,
18610,
19,
14,
6625,
492,
29719,
221,
327,
8151,
199,
199,
504,
13869,
63,
9743,
492,
2986,
199,
504,
13869,
63,
9743,
14,
396,
492,
10897,
465,
511,
421,
199,
533,
662,
15367,
4767,
4965,
2768,
774,
8,
396,
14,
1563,
4880,
2768,
2925,
304,
272,
768,
396,
14,
981,
63,
8957,
2561,
1246,
14,
6765,
26,
661,
18237,
63,
513,
297,
3521,
283,
18237,
63,
3200,
297,
3521,
283,
1364,
63,
513,
22220,
272,
347,
511,
63,
1080,
8,
277,
304,
267,
21724,
275,
291,
14,
9547,
27215,
14,
513,
1252,
1935,
1252,
18237,
63,
4269,
267,
8500,
275,
359,
1364,
367,
2435,
315,
291,
14,
5950,
14,
513,
342,
490,
340,
2435,
14,
3008,
508,
283,
6765,
13,
3357,
418,
267,
2986,
14,
6765,
14,
1364,
63,
513,
8,
14104,
8,
1014,
14,
10441,
395,
2892,
3366,
534,
6765,
13,
3357,
1959,
8572,
8,
5950,
9,
398,
291,
14,
6625,
14,
12982,
342,
398,
1166,
275,
3837,
360,
16561,
26,
2113,
26,
9547,
27215,
26,
3357,
26,
6857,
645,
4767,
63,
1102,
297,
1993,
1249,
1524,
18237,
566,
267,
522,
275,
291,
14,
1258,
14,
362,
8,
633,
9,
267,
291,
14,
19661,
8,
470,
12,
1816,
283,
2113,
15,
9547,
27215,
15,
3357,
15,
6857,
645,
4767,
63,
1102,
14,
1360,
358,
339,
768,
396,
14,
981,
63,
8957,
2561,
1246,
14,
6765,
26,
661,
18237,
63,
513,
297,
3521,
283,
18237,
63,
3200,
297,
3521,
283,
1364,
63,
513,
297,
3521,
283,
6857,
645,
4767,
63,
1102,
22220,
272,
347,
511,
63,
18157,
63,
1932,
8,
277,
304,
267,
21724,
275,
291,
14,
9547,
27215,
14,
513,
1252,
1935,
1252,
18237,
63,
4269,
267,
8500,
275,
359,
1364,
367,
2435,
315,
291,
14,
5950,
14,
513,
342,
490,
340,
2435,
14,
3008,
508,
283,
6765,
13,
3357,
418,
398,
2986,
14,
6765,
14,
1364,
63,
513,
8,
14104,
8,
1014,
14,
10441,
395,
2892,
3366,
534,
6765,
13,
3357,
1959,
8572,
8,
5950,
9,
267,
2986,
14,
6765,
14,
6857,
645,
4767,
63,
1102,
8,
14104,
8,
1014,
14,
10441,
395,
3044,
8500,
59,
17,
1055,
1102,
12,
3044,
8500,
59,
16,
1055,
1102,
12,
3044,
756,
680,
8572,
8,
549,
9,
267,
291,
14,
6625,
14,
12982,
342,
398,
1166,
275,
3837,
360,
16561,
26,
2113,
26,
9547,
27215,
26,
3357,
26,
6857,
645,
4767,
63,
1102,
297,
1993,
1249,
1524,
18237,
566,
398,
1824,
63,
576,
275,
791,
1818,
63,
1102,
356,
8500,
59,
17,
1055,
1102,
12,
2151,
283,
1375,
63,
1102,
356,
8500,
59,
16,
1055,
1102,
12,
2151,
283,
265,
63,
5555,
63,
3494,
356,
756,
93,
398,
522,
275,
291,
14,
1258,
14,
1932,
8,
633,
12,
1824,
63,
576,
9,
267,
2053,
63,
633,
275,
3837,
360,
16561,
26,
2113,
26,
9547,
27215,
26,
1080,
358,
267,
291,
14,
22389,
2821,
9298,
8,
470,
9,
267,
291,
14,
479,
2209,
2353,
8,
3742,
29,
17,
9,
267,
291,
14,
17466,
1944,
18696,
8,
470,
12,
2053,
63,
633,
9,
339,
768,
396,
14,
981,
63,
8957,
2561,
1246,
14,
6765,
26,
661,
18237,
63,
513,
297,
3521,
283,
18237,
63,
3200,
297,
3521,
283,
1364,
63,
513,
297,
3521,
283,
6857,
645,
4767,
63,
1102,
22220,
272,
347,
511,
63,
25299,
63,
6765,
63,
1250,
63,
1932,
8,
277,
304,
267,
21724,
275,
291,
14,
9547,
27215,
14,
513,
1252,
1935,
1252,
18237,
63,
4269,
267,
8500,
275,
359,
1364,
367,
2435,
315,
291,
14,
5950,
14,
513,
342,
490,
340,
2435,
14,
3008,
508,
283,
6765,
13,
3357,
418,
398,
2986,
14,
6765,
14,
1364,
63,
513,
8,
14104,
8,
1014,
14,
10441,
395,
2892,
3366,
534,
6765,
13,
3357,
1959,
8572,
8,
5950,
9,
267,
2986,
14,
6765,
14,
6857,
645,
4767,
63,
1102,
8,
14104,
8,
1014,
14,
10441,
395,
3044,
8500,
59,
17,
1055,
1102,
12,
3044,
8500,
59,
16,
1055,
1102,
12,
3044,
756,
680,
3325,
18111,
8,
277,
14,
3924,
14,
6765,
9,
267,
291,
14,
6625,
14,
12982,
342,
398,
1166,
275,
3837,
360,
16561,
26,
2113,
26,
9547,
27215,
26,
3357,
26,
6857,
645,
4767,
63,
1102,
297,
1993,
1249,
1524,
18237,
566,
398,
1824,
63,
576,
275,
791,
1818,
63,
1102,
356,
8500,
59,
17,
1055,
1102,
12,
2151,
283,
1375,
63,
1102,
356,
8500,
59,
16,
1055,
1102,
12,
2151,
283,
265,
63,
5555,
63,
3494,
356,
756,
93,
398,
522,
275,
291,
14,
1258,
14,
1932,
8,
633,
12,
1824,
63,
576,
9,
267,
2053,
63,
633,
275,
3837,
360,
16561,
26,
2113,
26,
9547,
27215,
26,
1080,
358,
267,
291,
14,
479,
2209,
2353,
8,
705,
29,
17,
9,
267,
291,
14,
17466,
1944,
18696,
8,
470,
12,
2053,
63,
633,
9,
421,
199,
533,
28195,
1866,
4965,
2768,
774,
8,
396,
14,
1563,
4880,
2768,
2925,
304,
272,
347,
511,
63,
1080,
8,
277,
304,
267,
6980,
63,
5950,
275,
359,
1364,
367,
2435,
315,
291,
14,
5950,
14,
513,
342,
2490,
340,
2435,
14,
3008,
508,
283,
6765,
13,
3357,
7,
2490,
436,
2435,
14,
1205,
508,
283,
7011,
418,
267,
6980,
63,
1364,
275,
6980,
63,
5950,
59,
16,
61,
267,
291,
14,
6625,
14,
12982,
342,
267,
1166,
275,
3837,
360,
16561,
26,
2113,
26,
9547,
27215,
26,
3357,
26,
8462,
63,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
mediafactory/tryton_core_daemon
|
trytond/backend/fields.py
|
1
|
4187
|
#This file is part of Tryton. The COPYRIGHT file at the top level of
#this repository contains the full copyright notices and license terms.
import datetime
from decimal import Decimal
try:
import hashlib
except ImportError:
hashlib = None
import sha
class Field(object):
@staticmethod
def sql_format(value):
return value
@staticmethod
def sql_type(field):
raise NotImplementedError
class Boolean(Field):
@staticmethod
def sql_format(value):
return value
class Integer(Field):
pass
class BigInteger(Integer):
pass
class Char(Field):
@staticmethod
def sql_format(value):
if value is None:
return None
elif isinstance(value, str):
return unicode(value, 'utf-8')
assert isinstance(value, unicode)
return value
class Sha(Field):
@staticmethod
def sql_format(value):
if value is not None:
if isinstance(value, unicode):
value = value.encode('utf-8')
if hashlib:
value = hashlib.sha1(value).hexdigest()
else:
value = sha.new(value).hexdigest()
return Char.sql_format(value)
class Text(Char):
pass
class Float(Field):
pass
class Numeric(Float):
@staticmethod
def sql_format(value):
if value is None:
return value
if isinstance(value, (int, long)):
value = Decimal(str(value))
assert isinstance(value, Decimal)
return value
class Date(Field):
@staticmethod
def sql_format(value):
if not value:
return None
if isinstance(value, basestring):
year, month, day = map(int, value.split("-", 2))
return datetime.date(year, month, day)
assert(isinstance(value, datetime.date))
# Allow datetime with min time for XML-RPC
# datetime must be tested separately because datetime is a
# subclass of date
assert(not isinstance(value, datetime.datetime)
or value.time() == datetime.time())
return value
class DateTime(Field):
@staticmethod
def sql_format(value):
if not value:
return None
if isinstance(value, basestring):
datepart, timepart = value.split(" ")
year, month, day = map(int, datepart.split("-", 2))
hours, minutes, seconds = map(int, timepart.split(":"))
return datetime.datetime(year, month, day, hours, minutes, seconds)
assert(isinstance(value, datetime.datetime))
return value.replace(microsecond=0)
class Timestamp(Field):
@staticmethod
def sql_format(value):
if not value:
return None
if isinstance(value, basestring):
datepart, timepart = value.split(" ")
year, month, day = map(int, datepart.split("-", 2))
timepart_full = timepart.split(".", 1)
hours, minutes, seconds = map(int, timepart_full[0].split(":"))
if len(timepart_full) == 2:
microseconds = int(timepart_full[1])
else:
microseconds = 0
return datetime.datetime(year, month, day, hours, minutes, seconds,
microseconds)
assert(isinstance(value, datetime.datetime))
return value
class Time(Field):
@staticmethod
def sql_format(value):
if not value:
return None
if isinstance(value, basestring):
hours, minutes, seconds = map(int, value.split(":"))
return datetime.time(hours, minutes, seconds)
assert(isinstance(value, datetime.time))
return value.replace(microsecond=0)
class Binary(Field):
@staticmethod
def sql_format(value):
return value or None
class Selection(Char):
pass
class Reference(Char):
pass
class Many2One(Field):
@staticmethod
def sql_format(value):
return value and int(value) or None
class One2Many(Field):
pass
class Many2Many(Field):
pass
class Function(Field):
pass
class Property(Function):
pass
|
gpl-3.0
|
[
3,
2765,
570,
365,
1777,
402,
7649,
1860,
14,
221,
710,
5877,
570,
737,
314,
2746,
2166,
402,
199,
3,
3749,
7611,
3509,
314,
2615,
4248,
949,
7724,
436,
4190,
2895,
14,
199,
646,
2197,
199,
504,
6107,
492,
6345,
199,
893,
26,
272,
492,
8337,
199,
2590,
3545,
26,
272,
8337,
275,
488,
272,
492,
7793,
421,
199,
533,
5024,
8,
785,
304,
339,
768,
4639,
272,
347,
3875,
63,
908,
8,
585,
304,
267,
372,
574,
339,
768,
4639,
272,
347,
3875,
63,
466,
8,
698,
304,
267,
746,
4279,
421,
199,
533,
9411,
8,
792,
304,
339,
768,
4639,
272,
347,
3875,
63,
908,
8,
585,
304,
267,
372,
574,
421,
199,
533,
7225,
8,
792,
304,
272,
986,
421,
199,
533,
13123,
2674,
8,
2674,
304,
272,
986,
421,
199,
533,
6659,
8,
792,
304,
339,
768,
4639,
272,
347,
3875,
63,
908,
8,
585,
304,
267,
340,
574,
365,
488,
26,
288,
372,
488,
267,
916,
1228,
8,
585,
12,
620,
304,
288,
372,
2649,
8,
585,
12,
283,
1624,
13,
24,
358,
267,
702,
1228,
8,
585,
12,
2649,
9,
267,
372,
574,
421,
199,
533,
428,
2411,
8,
792,
304,
339,
768,
4639,
272,
347,
3875,
63,
908,
8,
585,
304,
267,
340,
574,
365,
440,
488,
26,
288,
340,
1228,
8,
585,
12,
2649,
304,
355,
574,
275,
574,
14,
2143,
360,
1624,
13,
24,
358,
288,
340,
8337,
26,
355,
574,
275,
8337,
14,
4835,
17,
8,
585,
680,
11453,
342,
288,
587,
26,
355,
574,
275,
7793,
14,
1222,
8,
585,
680,
11453,
342,
267,
372,
6659,
14,
3009,
63,
908,
8,
585,
9,
421,
199,
533,
4516,
8,
1610,
304,
272,
986,
421,
199,
533,
11140,
8,
792,
304,
272,
986,
421,
199,
533,
19378,
8,
5136,
304,
339,
768,
4639,
272,
347,
3875,
63,
908,
8,
585,
304,
267,
340,
574,
365,
488,
26,
288,
372,
574,
267,
340,
1228,
8,
585,
12,
334,
442,
12,
1846,
2298,
288,
574,
275,
6345,
8,
495,
8,
585,
430,
267,
702,
1228,
8,
585,
12,
6345,
9,
267,
372,
574,
421,
199,
533,
6148,
8,
792,
304,
339,
768,
4639,
272,
347,
3875,
63,
908,
8,
585,
304,
267,
340,
440,
574,
26,
288,
372,
488,
267,
340,
1228,
8,
585,
12,
7116,
304,
288,
5361,
12,
5794,
12,
5382,
275,
2341,
8,
442,
12,
574,
14,
1294,
6096,
401,
499,
430,
288,
372,
2197,
14,
602,
8,
3403,
12,
5794,
12,
5382,
9,
398,
702,
8,
6074,
8,
585,
12,
2197,
14,
602,
430,
267,
327,
9812,
2197,
543,
1748,
900,
367,
4692,
13,
8171,
267,
327,
2197,
1471,
506,
12470,
18159,
2952,
2197,
365,
282,
267,
327,
5516,
402,
1434,
267,
702,
8,
1397,
1228,
8,
585,
12,
2197,
14,
2083,
9,
355,
503,
574,
14,
521,
342,
508,
2197,
14,
521,
1012,
267,
372,
574,
421,
199,
533,
13686,
8,
792,
304,
339,
768,
4639,
272,
347,
3875,
63,
908,
8,
585,
304,
267,
340,
440,
574,
26,
288,
372,
488,
267,
340,
1228,
8,
585,
12,
7116,
304,
288,
1434,
2064,
12,
900,
2064,
275,
574,
14,
1294,
480,
6099,
288,
5361,
12,
5794,
12,
5382,
275,
2341,
8,
442,
12,
1434,
2064,
14,
1294,
6096,
401,
499,
430,
288,
10857,
12,
9395,
12,
4696,
275,
2341,
8,
442,
12,
900,
2064,
14,
1294,
20308,
2237,
288,
372,
2197,
14,
2083,
8,
3403,
12,
5794,
12,
5382,
12,
10857,
12,
9395,
12,
4696,
9,
267,
702,
8,
6074,
8,
585,
12,
2197,
14,
2083,
430,
267,
372,
574,
14,
1814,
8,
16627,
29,
16,
9,
421,
199,
533,
18267,
8,
792,
304,
339,
768,
4639,
272,
347,
3875,
63,
908,
8,
585,
304,
267,
340,
440,
574,
26,
288,
372,
488,
267,
340,
1228,
8,
585,
12,
7116,
304,
288,
1434,
2064,
12,
900,
2064,
275,
574,
14,
1294,
480,
6099,
288,
5361,
12,
5794,
12,
5382,
275,
2341,
8,
442,
12,
1434,
2064,
14,
1294,
6096,
401,
499,
430,
288,
900,
2064,
63,
2861,
275,
900,
2064,
14,
1294,
30381,
413,
9,
288,
10857,
12,
9395,
12,
4696,
275,
2341,
8,
442,
12,
900,
2064,
63,
2861,
59,
16,
1055,
1294,
20308,
2237,
288,
340,
822,
8,
521,
2064,
63,
2861,
9,
508,
499,
26,
355,
21574,
275,
1109,
8,
521,
2064,
63,
2861,
59,
17,
566,
288,
587,
26,
355,
21574,
275,
378,
288,
372,
2197,
14,
2083,
8,
3403,
12,
5794,
12,
5382,
12,
10857,
12,
9395,
12,
4696,
12,
490,
21574,
9,
267,
702,
8,
6074,
8,
585,
12,
2197,
14,
2083,
430,
267,
372,
574,
421,
199,
533,
4703,
8,
792,
304,
339,
768,
4639,
272,
347,
3875,
63,
908,
8,
585,
304,
267,
340,
440,
574,
26,
288,
372,
488,
267,
340,
1228,
8,
585,
12,
7116,
304,
288,
10857,
12,
9395,
12,
4696,
275,
2341,
8,
442,
12,
574,
14,
1294,
20308,
2237,
288,
372,
2197,
14,
521,
8,
8419,
12,
9395,
12,
4696,
9,
267,
702,
8,
6074,
8,
585,
12,
2197,
14,
521,
430,
267,
372,
574,
14,
1814,
8,
16627,
29,
16,
9,
421,
199,
533,
14161,
8,
792,
304,
339,
768,
4639,
272,
347,
3875,
63,
908,
8,
585,
304,
267,
372,
574,
503,
488,
421,
199,
533,
3240,
1486,
8,
1610,
304,
272,
986,
421,
199,
533,
10944,
8,
1610,
304,
272,
986,
421,
199,
533,
15517,
18,
4395,
8,
792,
304,
339,
768,
4639,
272,
347,
3875,
63,
908,
8,
585,
304,
267,
372,
574,
436,
1109,
8,
585,
9,
503,
488,
421,
199,
533,
7309,
18,
4089,
8,
792,
304,
272,
986,
421,
199,
533,
15517,
18,
4089,
8,
792,
304,
272,
986,
421,
199,
533,
6801,
8,
792,
304,
272,
986,
421,
199,
533,
16158,
8,
3481,
304,
272,
986,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
2765,
570,
365,
1777,
402,
7649,
1860,
14,
221,
710,
5877,
570,
737,
314,
2746,
2166,
402,
199,
3,
3749,
7611,
3509,
314,
2615,
4248,
949,
7724,
436,
4190,
2895,
14,
199,
646,
2197,
199,
504,
6107,
492,
6345,
199,
893,
26,
272,
492,
8337,
199,
2590,
3545,
26,
272,
8337,
275,
488,
272,
492,
7793,
421,
199,
533,
5024,
8,
785,
304,
339,
768,
4639,
272,
347,
3875,
63,
908,
8,
585,
304,
267,
372,
574,
339,
768,
4639,
272,
347,
3875,
63,
466,
8,
698,
304,
267,
746,
4279,
421,
199,
533,
9411,
8,
792,
304,
339,
768,
4639,
272,
347,
3875,
63,
908,
8,
585,
304,
267,
372,
574,
421,
199,
533,
7225,
8,
792,
304,
272,
986,
421,
199,
533,
13123,
2674,
8,
2674,
304,
272,
986,
421,
199,
533,
6659,
8,
792,
304,
339,
768,
4639,
272,
347,
3875,
63,
908,
8,
585,
304,
267,
340,
574,
365,
488,
26,
288,
372,
488,
267,
916,
1228,
8,
585,
12,
620,
304,
288,
372,
2649,
8,
585,
12,
283,
1624,
13,
24,
358,
267,
702,
1228,
8,
585,
12,
2649,
9,
267,
372,
574,
421,
199,
533,
428,
2411,
8,
792,
304,
339,
768,
4639,
272,
347,
3875,
63,
908,
8,
585,
304,
267,
340,
574,
365,
440,
488,
26,
288,
340,
1228,
8,
585,
12,
2649,
304,
355,
574,
275,
574,
14,
2143,
360,
1624,
13,
24,
358,
288,
340,
8337,
26,
355,
574,
275,
8337,
14,
4835,
17,
8,
585,
680,
11453,
342,
288,
587,
26,
355,
574,
275,
7793,
14,
1222,
8,
585,
680,
11453,
342,
267,
372,
6659,
14,
3009,
63,
908,
8,
585,
9,
421,
199,
533,
4516,
8,
1610,
304,
272,
986,
421,
199,
533,
11140,
8,
792,
304,
272,
986,
421,
199,
533,
19378,
8,
5136,
304,
339,
768,
4639,
272,
347,
3875,
63,
908,
8,
585,
304,
267,
340,
574,
365,
488,
26,
288,
372,
574,
267,
340,
1228,
8,
585,
12,
334,
442,
12,
1846,
2298,
288,
574,
275,
6345,
8,
495,
8,
585,
430,
267,
702,
1228,
8,
585,
12,
6345,
9,
267,
372,
574,
421,
199,
533,
6148,
8,
792,
304,
339,
768,
4639,
272,
347,
3875,
63,
908,
8,
585,
304,
267,
340,
440,
574,
26,
288,
372,
488,
267,
340,
1228,
8,
585,
12,
7116,
304,
288,
5361,
12,
5794,
12,
5382,
275,
2341,
8,
442,
12,
574,
14,
1294,
6096,
401,
499,
430,
288,
372,
2197,
14,
602,
8,
3403,
12,
5794,
12,
5382,
9,
398,
702,
8,
6074,
8,
585,
12,
2197,
14,
602,
430,
267,
327,
9812,
2197,
543,
1748,
900,
367,
4692,
13,
8171,
267,
327,
2197,
1471,
506,
12470,
18159,
2952,
2197,
365,
282,
267,
327,
5516,
402,
1434,
267,
702,
8,
1397,
1228,
8,
585,
12,
2197,
14,
2083,
9,
355,
503,
574,
14,
521,
342,
508,
2197,
14,
521,
1012,
267,
372,
574,
421,
199,
533,
13686,
8,
792,
304,
339,
768,
4639,
272,
347,
3875,
63,
908,
8,
585,
304,
267,
340,
440,
574,
26,
288,
372,
488,
267,
340,
1228,
8,
585,
12,
7116,
304,
288,
1434,
2064,
12,
900,
2064,
275,
574,
14,
1294,
480,
6099,
288,
5361,
12,
5794,
12,
5382,
275,
2341,
8,
442,
12,
1434,
2064,
14,
1294,
6096,
401,
499,
430,
288,
10857,
12,
9395,
12,
4696,
275,
2341,
8,
442,
12,
900,
2064,
14,
1294,
20308,
2237,
288,
372,
2197,
14,
2083,
8,
3403,
12,
5794,
12,
5382,
12,
10857,
12,
9395,
12,
4696,
9,
267,
702,
8,
6074,
8,
585,
12,
2197,
14,
2083,
430,
267,
372,
574,
14,
1814,
8,
16627,
29,
16,
9,
421,
199,
533,
18267,
8,
792,
304,
339,
768,
4639,
272,
347,
3875,
63,
908,
8,
585,
304,
267,
340,
440,
574,
26,
288,
372,
488,
267,
340,
1228,
8,
585,
12,
7116,
304,
288,
1434,
2064,
12,
900,
2064,
275,
574,
14,
1294,
480,
6099,
288,
5361,
12,
5794,
12,
5382,
275,
2341,
8,
442,
12,
1434,
2064,
14,
1294,
6096,
401,
499,
430,
288,
900,
2064,
63,
2861,
275,
900,
2064,
14,
1294,
30381,
413,
9,
288,
10857,
12,
9395,
12,
4696,
275,
2341,
8,
442,
12,
900,
2064,
63,
2861,
59,
16,
1055,
1294,
20308,
2237,
288,
340,
822,
8,
521,
2064,
63,
2861,
9,
508,
499,
26,
355,
21574,
275,
1109,
8,
521,
2064,
63,
2861,
59,
17,
566,
288,
587,
26,
355,
21574,
275,
378,
288,
372,
2197,
14,
2083,
8,
3403,
12,
5794,
12,
5382,
12,
10857,
12,
9395,
12,
4696,
12,
490,
21574,
9,
267,
702,
8,
6074,
8,
585,
12,
2197,
14,
2083,
430,
267,
372,
574,
421,
199,
533,
4703,
8,
792,
304,
339,
768,
4639,
272,
347,
3875,
63,
908,
8,
585,
304,
267,
340,
440,
574,
26,
288,
372,
488,
267,
340,
1228,
8,
585,
12,
7116,
304,
288,
10857,
12,
9395,
12,
4696,
275,
2341,
8,
442,
12,
574,
14,
1294,
20308,
2237,
288,
372,
2197,
14,
521,
8,
8419,
12,
9395,
12,
4696,
9,
267,
702,
8,
6074,
8,
585,
12,
2197,
14,
521,
430,
267,
372,
574,
14,
1814,
8,
16627,
29,
16,
9,
421,
199,
533,
14161,
8,
792,
304,
339,
768,
4639,
272,
347,
3875,
63,
908,
8,
585,
304,
267,
372,
574,
503,
488,
421,
199,
533,
3240,
1486,
8,
1610,
304,
272,
986,
421,
199,
533,
10944,
8,
1610,
304,
272,
986,
421,
199,
533,
15517,
18,
4395,
8,
792,
304,
339,
768,
4639,
272,
347,
3875,
63,
908,
8,
585,
304,
267,
372,
574,
436,
1109,
8,
585,
9,
503,
488,
421,
199,
533,
7309,
18,
4089,
8,
792,
304,
272,
986,
421,
199,
533,
15517,
18,
4089,
8,
792,
304,
272,
986,
421,
199,
533,
6801,
8,
792,
304,
272,
986,
421,
199,
533,
16158,
8,
3481,
304,
272,
986,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
microdee/IronHydra
|
src/IronHydra/Lib/stat.py
|
179
|
1718
|
"""Constants/functions for interpreting results of os.stat() and os.lstat().
Suggested usage: from stat import *
"""
# Indices for stat struct members in the tuple returned by os.stat()
ST_MODE = 0
ST_INO = 1
ST_DEV = 2
ST_NLINK = 3
ST_UID = 4
ST_GID = 5
ST_SIZE = 6
ST_ATIME = 7
ST_MTIME = 8
ST_CTIME = 9
# Extract bits from the mode
def S_IMODE(mode):
return mode & 07777
def S_IFMT(mode):
return mode & 0170000
# Constants used as S_IFMT() for various file types
# (not all are implemented on all systems)
S_IFDIR = 0040000
S_IFCHR = 0020000
S_IFBLK = 0060000
S_IFREG = 0100000
S_IFIFO = 0010000
S_IFLNK = 0120000
S_IFSOCK = 0140000
# Functions to test for each file type
def S_ISDIR(mode):
return S_IFMT(mode) == S_IFDIR
def S_ISCHR(mode):
return S_IFMT(mode) == S_IFCHR
def S_ISBLK(mode):
return S_IFMT(mode) == S_IFBLK
def S_ISREG(mode):
return S_IFMT(mode) == S_IFREG
def S_ISFIFO(mode):
return S_IFMT(mode) == S_IFIFO
def S_ISLNK(mode):
return S_IFMT(mode) == S_IFLNK
def S_ISSOCK(mode):
return S_IFMT(mode) == S_IFSOCK
# Names for permission bits
S_ISUID = 04000
S_ISGID = 02000
S_ENFMT = S_ISGID
S_ISVTX = 01000
S_IREAD = 00400
S_IWRITE = 00200
S_IEXEC = 00100
S_IRWXU = 00700
S_IRUSR = 00400
S_IWUSR = 00200
S_IXUSR = 00100
S_IRWXG = 00070
S_IRGRP = 00040
S_IWGRP = 00020
S_IXGRP = 00010
S_IRWXO = 00007
S_IROTH = 00004
S_IWOTH = 00002
S_IXOTH = 00001
# Names for file flags
UF_NODUMP = 0x00000001
UF_IMMUTABLE = 0x00000002
UF_APPEND = 0x00000004
UF_OPAQUE = 0x00000008
UF_NOUNLINK = 0x00000010
SF_ARCHIVED = 0x00010000
SF_IMMUTABLE = 0x00020000
SF_APPEND = 0x00040000
SF_NOUNLINK = 0x00100000
SF_SNAPSHOT = 0x00200000
|
mit
|
[
624,
22185,
15,
5777,
367,
6421,
1337,
2058,
402,
747,
14,
3736,
342,
436,
747,
14,
26956,
1252,
199,
199,
51,
17417,
4503,
26,
687,
5672,
492,
627,
199,
624,
199,
199,
3,
1010,
12503,
367,
5672,
2702,
7556,
315,
314,
2008,
2138,
701,
747,
14,
3736,
342,
199,
199,
840,
63,
6963,
221,
275,
378,
199,
840,
63,
568,
47,
257,
275,
413,
199,
840,
63,
13260,
257,
275,
499,
199,
840,
63,
46,
7916,
275,
650,
199,
840,
63,
6685,
257,
275,
841,
199,
840,
63,
39,
998,
257,
275,
959,
199,
840,
63,
4305,
221,
275,
1227,
199,
840,
63,
619,
3465,
275,
1520,
199,
840,
63,
45,
4961,
275,
1695,
199,
840,
63,
1028,
3465,
275,
1749,
199,
199,
3,
12892,
5821,
687,
314,
818,
199,
199,
318,
428,
63,
1469,
9125,
8,
632,
304,
272,
372,
818,
1253,
378,
16713,
199,
199,
318,
428,
63,
4656,
5747,
8,
632,
304,
272,
372,
818,
1253,
378,
1196,
993,
199,
199,
3,
22296,
1202,
465,
428,
63,
4656,
5747,
342,
367,
7750,
570,
2943,
199,
3,
334,
1397,
1006,
787,
6366,
641,
1006,
10460,
9,
199,
199,
51,
63,
4656,
3022,
221,
275,
378,
966,
993,
199,
51,
63,
4656,
1244,
50,
221,
275,
378,
996,
993,
199,
51,
63,
4656,
7847,
43,
221,
275,
378,
1690,
993,
199,
51,
63,
4656,
5616,
221,
275,
378,
15274,
199,
51,
63,
11100,
3230,
221,
275,
378,
614,
993,
199,
51,
63,
41,
3143,
22780,
221,
275,
378,
713,
993,
199,
51,
63,
4656,
9469,
275,
378,
1079,
993,
199,
199,
3,
17471,
370,
511,
367,
1924,
570,
730,
199,
199,
318,
428,
63,
1311,
3022,
8,
632,
304,
272,
372,
428,
63,
4656,
5747,
8,
632,
9,
508,
428,
63,
4656,
3022,
199,
199,
318,
428,
63,
1311,
1244,
50,
8,
632,
304,
272,
372,
428,
63,
4656,
5747,
8,
632,
9,
508,
428,
63,
4656,
1244,
50,
199,
199,
318,
428,
63,
1311,
7847,
43,
8,
632,
304,
272,
372,
428,
63,
4656,
5747,
8,
632,
9,
508,
428,
63,
4656,
7847,
43,
199,
199,
318,
428,
63,
1311,
5616,
8,
632,
304,
272,
372,
428,
63,
4656,
5747,
8,
632,
9,
508,
428,
63,
4656,
5616,
199,
199,
318,
428,
63,
1311,
20925,
8,
632,
304,
272,
372,
428,
63,
4656,
5747,
8,
632,
9,
508,
428,
63,
11100,
3230,
199,
199,
318,
428,
63,
1311,
44,
22780,
8,
632,
304,
272,
372,
428,
63,
4656,
5747,
8,
632,
9,
508,
428,
63,
41,
3143,
22780,
199,
199,
318,
428,
63,
1311,
9469,
8,
632,
304,
272,
372,
428,
63,
4656,
5747,
8,
632,
9,
508,
428,
63,
4656,
9469,
199,
199,
3,
23923,
367,
4983,
5821,
199,
199,
51,
63,
1311,
6685,
275,
378,
23641,
199,
51,
63,
1311,
39,
998,
275,
378,
8269,
199,
51,
63,
742,
22831,
275,
428,
63,
1311,
39,
998,
199,
51,
63,
1311,
8156,
56,
275,
378,
5279,
199,
51,
63,
41,
5670,
275,
378,
27130,
199,
51,
63,
41,
10387,
275,
378,
24215,
199,
51,
63,
41,
10276,
275,
378,
16569,
199,
51,
63,
3927,
16783,
53,
275,
378,
1780,
383,
199,
51,
63,
3927,
22592,
275,
378,
27130,
199,
51,
63,
22275,
22592,
275,
378,
24215,
199,
51,
63,
3867,
22592,
275,
378,
16569,
199,
51,
63,
3927,
16783,
39,
275,
21551,
2760,
199,
51,
63,
3927,
3975,
48,
275,
21551,
2167,
199,
51,
63,
22275,
3975,
48,
275,
378,
20734,
199,
51,
63,
3867,
3975,
48,
275,
378,
17657,
199,
51,
63,
3927,
16783,
47,
275,
378,
22530,
199,
51,
63,
41,
1092,
2080,
275,
378,
16643,
199,
51,
63,
22275,
22949,
275,
378,
9425,
199,
51,
63,
3867,
22949,
275,
378,
4183,
199,
199,
3,
23923,
367,
570,
3285,
199,
199,
27363,
63,
2826,
26406,
259,
275,
378,
88,
23848,
199,
27363,
63,
1469,
25890,
2617,
275,
378,
88,
32764,
199,
27363,
63,
25248,
259,
275,
378,
88,
3273,
966,
199,
27363,
63,
1938,
33,
10526,
259,
275,
378,
88,
9084,
24,
199,
27363,
63,
2826,
1734,
7916,
221,
275,
378,
88,
3273,
709,
199,
13107,
63,
7762,
30487,
221,
275,
378,
88,
4183,
993,
199,
13107,
63,
1469,
25890,
2617,
275,
378,
88,
9425,
993,
199,
13107,
63,
25248,
259,
275,
378,
88,
16643,
993,
199,
13107,
63,
2826,
1734,
7916,
221,
275,
378,
88,
4587,
5345,
199,
13107,
63,
30728,
221,
275,
378,
88,
7432,
5345,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
22185,
15,
5777,
367,
6421,
1337,
2058,
402,
747,
14,
3736,
342,
436,
747,
14,
26956,
1252,
199,
199,
51,
17417,
4503,
26,
687,
5672,
492,
627,
199,
624,
199,
199,
3,
1010,
12503,
367,
5672,
2702,
7556,
315,
314,
2008,
2138,
701,
747,
14,
3736,
342,
199,
199,
840,
63,
6963,
221,
275,
378,
199,
840,
63,
568,
47,
257,
275,
413,
199,
840,
63,
13260,
257,
275,
499,
199,
840,
63,
46,
7916,
275,
650,
199,
840,
63,
6685,
257,
275,
841,
199,
840,
63,
39,
998,
257,
275,
959,
199,
840,
63,
4305,
221,
275,
1227,
199,
840,
63,
619,
3465,
275,
1520,
199,
840,
63,
45,
4961,
275,
1695,
199,
840,
63,
1028,
3465,
275,
1749,
199,
199,
3,
12892,
5821,
687,
314,
818,
199,
199,
318,
428,
63,
1469,
9125,
8,
632,
304,
272,
372,
818,
1253,
378,
16713,
199,
199,
318,
428,
63,
4656,
5747,
8,
632,
304,
272,
372,
818,
1253,
378,
1196,
993,
199,
199,
3,
22296,
1202,
465,
428,
63,
4656,
5747,
342,
367,
7750,
570,
2943,
199,
3,
334,
1397,
1006,
787,
6366,
641,
1006,
10460,
9,
199,
199,
51,
63,
4656,
3022,
221,
275,
378,
966,
993,
199,
51,
63,
4656,
1244,
50,
221,
275,
378,
996,
993,
199,
51,
63,
4656,
7847,
43,
221,
275,
378,
1690,
993,
199,
51,
63,
4656,
5616,
221,
275,
378,
15274,
199,
51,
63,
11100,
3230,
221,
275,
378,
614,
993,
199,
51,
63,
41,
3143,
22780,
221,
275,
378,
713,
993,
199,
51,
63,
4656,
9469,
275,
378,
1079,
993,
199,
199,
3,
17471,
370,
511,
367,
1924,
570,
730,
199,
199,
318,
428,
63,
1311,
3022,
8,
632,
304,
272,
372,
428,
63,
4656,
5747,
8,
632,
9,
508,
428,
63,
4656,
3022,
199,
199,
318,
428,
63,
1311,
1244,
50,
8,
632,
304,
272,
372,
428,
63,
4656,
5747,
8,
632,
9,
508,
428,
63,
4656,
1244,
50,
199,
199,
318,
428,
63,
1311,
7847,
43,
8,
632,
304,
272,
372,
428,
63,
4656,
5747,
8,
632,
9,
508,
428,
63,
4656,
7847,
43,
199,
199,
318,
428,
63,
1311,
5616,
8,
632,
304,
272,
372,
428,
63,
4656,
5747,
8,
632,
9,
508,
428,
63,
4656,
5616,
199,
199,
318,
428,
63,
1311,
20925,
8,
632,
304,
272,
372,
428,
63,
4656,
5747,
8,
632,
9,
508,
428,
63,
11100,
3230,
199,
199,
318,
428,
63,
1311,
44,
22780,
8,
632,
304,
272,
372,
428,
63,
4656,
5747,
8,
632,
9,
508,
428,
63,
41,
3143,
22780,
199,
199,
318,
428,
63,
1311,
9469,
8,
632,
304,
272,
372,
428,
63,
4656,
5747,
8,
632,
9,
508,
428,
63,
4656,
9469,
199,
199,
3,
23923,
367,
4983,
5821,
199,
199,
51,
63,
1311,
6685,
275,
378,
23641,
199,
51,
63,
1311,
39,
998,
275,
378,
8269,
199,
51,
63,
742,
22831,
275,
428,
63,
1311,
39,
998,
199,
51,
63,
1311,
8156,
56,
275,
378,
5279,
199,
51,
63,
41,
5670,
275,
378,
27130,
199,
51,
63,
41,
10387,
275,
378,
24215,
199,
51,
63,
41,
10276,
275,
378,
16569,
199,
51,
63,
3927,
16783,
53,
275,
378,
1780,
383,
199,
51,
63,
3927,
22592,
275,
378,
27130,
199,
51,
63,
22275,
22592,
275,
378,
24215,
199,
51,
63,
3867,
22592,
275,
378,
16569,
199,
51,
63,
3927,
16783,
39,
275,
21551,
2760,
199,
51,
63,
3927,
3975,
48,
275,
21551,
2167,
199,
51,
63,
22275,
3975,
48,
275,
378,
20734,
199,
51,
63,
3867,
3975,
48,
275,
378,
17657,
199,
51,
63,
3927,
16783,
47,
275,
378,
22530,
199,
51,
63,
41,
1092,
2080,
275,
378,
16643,
199,
51,
63,
22275,
22949,
275,
378,
9425,
199,
51,
63,
3867,
22949,
275,
378,
4183,
199,
199,
3,
23923,
367,
570,
3285,
199,
199,
27363,
63,
2826,
26406,
259,
275,
378,
88,
23848,
199,
27363,
63,
1469,
25890,
2617,
275,
378,
88,
32764,
199,
27363,
63,
25248,
259,
275,
378,
88,
3273,
966,
199,
27363,
63,
1938,
33,
10526,
259,
275,
378,
88,
9084,
24,
199,
27363,
63,
2826,
1734,
7916,
221,
275,
378,
88,
3273,
709,
199,
13107,
63,
7762,
30487,
221,
275,
378,
88,
4183,
993,
199,
13107,
63,
1469,
25890,
2617,
275,
378,
88,
9425,
993,
199,
13107,
63,
25248,
259,
275,
378,
88,
16643,
993,
199,
13107,
63,
2826,
1734,
7916,
221,
275,
378,
88,
4587,
5345,
199,
13107,
63,
30728,
221,
275,
378,
88,
7432,
5345,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
Mrs-X/Darknet
|
test/functional/rpc_budget.py
|
4
|
5119
|
#!/usr/bin/env python3
# Copyright (c) 2019 The PIVX developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test RPC commands for budget proposal creation, submission, and verification."""
from test_framework.test_framework import PivxTestFramework
from test_framework.util import *
class BudgetProposalTest(PivxTestFramework):
def set_test_params(self):
self.num_nodes = 1
def run_test(self):
budgetcycleblocks = 144
nextsuperblock = self.nodes[0].getnextsuperblock()
address = self.nodes[0].getnewaddress()
scheme = 'http://'
url = 'test.com/url-with-length-of-57-characters-will-pass-00001'
longurl = 'test.com/url-with-length-of-58-characters-will-not-pass-01'
name = 'proposalwith20chars0'
longname = 'proposalwith21chars01'
numcycles = 2
cycleamount = 100
self.log.info("Test with long name")
assert_raises_rpc_error(-8, "Invalid proposal name, limit of 20 characters.", self.nodes[0].preparebudget,
longname, scheme + url, numcycles, nextsuperblock, address, cycleamount)
self.log.info("Test with long URL")
assert_raises_rpc_error(-8, "Invalid URL: 65 exceeds limit of 64 characters.", self.nodes[0].preparebudget,
name, scheme + longurl, numcycles, nextsuperblock, address, cycleamount)
self.log.info("Test with invalid (0) cycles")
assert_raises_rpc_error(-8, "Invalid payment count, must be more than zero.", self.nodes[0].preparebudget,
name, scheme + url, 0, nextsuperblock, address, cycleamount)
self.log.info("Test with invalid block start")
assert_raises_rpc_error(-8, "Invalid block start", self.nodes[0].preparebudget,
name, scheme + url, numcycles, nextsuperblock - 12, address, cycleamount)
assert_raises_rpc_error(-8, "Invalid block start", self.nodes[0].preparebudget,
name, scheme + url, numcycles, nextsuperblock - budgetcycleblocks, address, cycleamount)
self.log.info("Test with invalid PIVX address")
assert_raises_rpc_error(-5, "Invalid PIVX address", self.nodes[0].preparebudget,
name, scheme + url, numcycles, nextsuperblock, "DBREvBPNQguwuC4YMoCG5FoH1sA2YntvZm", cycleamount)
self.log.info("Test with too low amount")
assert_raises_rpc_error(-8, "Invalid amount - Payment of 9.00 is less than minimum 10 PIV allowed", self.nodes[0].preparebudget,
name, scheme + url, numcycles, nextsuperblock, address, 9)
self.log.info("Test with too high amount")
assert_raises_rpc_error(-8, "Invalid amount - Payment of 648001.00 more than max of 648000.00", self.nodes[0].preparebudget,
name, scheme + url, numcycles, nextsuperblock, address, 648001)
self.log.info("Test without URL scheme")
scheme = ''
assert_raises_rpc_error(-8, "Invalid URL, check scheme (e.g. https://)", self.nodes[0].preparebudget, name, scheme + url, 1, nextsuperblock, address, 100)
self.log.info('Test with invalid URL scheme: ftp://')
scheme = 'ftp://'
assert_raises_rpc_error(-8, "Invalid URL, check scheme (e.g. https://)", self.nodes[0].preparebudget, name, scheme + url, 1, nextsuperblock, address, 100)
self.log.info("Test with invalid double character scheme: hhttps://")
scheme = 'hhttps://'
url = 'test.com'
assert_raises_rpc_error(-8, "Invalid URL, check scheme (e.g. https://)", self.nodes[0].preparebudget, name, scheme + url, 1, nextsuperblock, address, 100)
self.log.info("Test with valid scheme: http://")
name = 'testvalid1'
scheme = 'http://'
feehashret = self.nodes[0].preparebudget(name, scheme + url, numcycles, nextsuperblock, address, cycleamount)
txinfo = self.nodes[0].gettransaction(feehashret)
assert_equal(txinfo['amount'], -50.00)
self.log.info("Generate 7 blocks to confirm fee transaction")
self.nodes[0].generate(7)
self.log.info("Submit the budget proposal")
submitret = self.nodes[0].submitbudget(name, scheme + url, numcycles, nextsuperblock, address, cycleamount, feehashret)
self.log.info("Ensure that the budget proposal details are correct")
budgetinfo = self.nodes[0].getbudgetinfo(name)[0]
assert_equal(budgetinfo["Name"], name)
assert_equal(budgetinfo["URL"], scheme + url)
assert_equal(budgetinfo["Hash"], submitret)
assert_equal(budgetinfo["FeeHash"], feehashret)
assert_equal(budgetinfo["BlockStart"], nextsuperblock)
assert_equal(budgetinfo["PaymentAddress"], address)
assert_equal(budgetinfo["MonthlyPayment"], cycleamount)
assert_equal(budgetinfo["TotalPayment"], cycleamount * numcycles)
if __name__ == '__main__':
BudgetProposalTest().main()
|
mit
|
[
3381,
2647,
15,
1393,
15,
1813,
2366,
19,
199,
3,
1898,
334,
67,
9,
20312,
710,
510,
6882,
56,
19782,
199,
3,
17484,
1334,
314,
10697,
2032,
4190,
12,
1937,
314,
23073,
199,
3,
570,
9685,
503,
1455,
921,
1544,
14,
16374,
14,
1308,
15,
2383,
15,
1147,
13,
1682,
14,
8624,
14,
199,
624,
774,
11785,
3718,
367,
1032,
14080,
28315,
7143,
12,
13071,
12,
436,
14786,
1041,
199,
199,
504,
511,
63,
4857,
14,
396,
63,
4857,
492,
510,
1003,
88,
26203,
199,
504,
511,
63,
4857,
14,
1974,
492,
627,
421,
199,
533,
699,
1181,
362,
919,
14506,
774,
8,
48,
1003,
88,
26203,
304,
272,
347,
663,
63,
396,
63,
1162,
8,
277,
304,
267,
291,
14,
1507,
63,
2415,
275,
413,
339,
347,
1255,
63,
396,
8,
277,
304,
267,
1032,
14080,
7612,
4166,
275,
21771,
267,
2163,
4792,
1457,
275,
291,
14,
2415,
59,
16,
1055,
362,
2184,
4792,
1457,
342,
267,
2287,
275,
291,
14,
2415,
59,
16,
1055,
21102,
342,
267,
5687,
275,
283,
1014,
22399,
267,
1166,
275,
283,
396,
14,
957,
15,
633,
13,
1045,
13,
1267,
13,
1618,
13,
1641,
13,
16516,
13,
14117,
13,
1529,
13,
22417,
7,
267,
1846,
633,
275,
283,
396,
14,
957,
15,
633,
13,
1045,
13,
1267,
13,
1618,
13,
2010,
13,
16516,
13,
14117,
13,
1397,
13,
1529,
13,
614,
7,
267,
536,
275,
283,
25700,
1045,
1165,
6574,
16,
7,
267,
1846,
354,
275,
283,
25700,
1045,
2025,
6574,
614,
7,
267,
1967,
23356,
275,
499,
267,
8643,
4606,
275,
2948,
398,
291,
14,
793,
14,
815,
480,
774,
543,
1846,
536,
531,
267,
702,
63,
3536,
63,
4354,
63,
705,
2801,
24,
12,
298,
3364,
28315,
536,
12,
2304,
402,
3388,
4110,
4765,
291,
14,
2415,
59,
16,
1055,
6726,
16501,
12,
1816,
1846,
354,
12,
5687,
435,
1166,
12,
1967,
23356,
12,
2163,
4792,
1457,
12,
2287,
12,
8643,
4606,
9,
398,
291,
14,
793,
14,
815,
480,
774,
543,
1846,
2851,
531,
267,
702,
63,
3536,
63,
4354,
63,
705,
2801,
24,
12,
298,
3364,
2851,
26,
11738,
22338,
2304,
402,
5049,
4110,
4765,
291,
14,
2415,
59,
16,
1055,
6726,
16501,
12,
1816,
536,
12,
5687,
435,
1846,
633,
12,
1967,
23356,
12,
2163,
4792,
1457,
12,
2287,
12,
8643,
4606,
9,
398,
291,
14,
793,
14,
815,
480,
774,
543,
3866,
334,
16,
9,
19001,
531,
267,
702,
63,
3536,
63,
4354,
63,
705,
2801,
24,
12,
298,
3364,
11628,
2338,
12,
1471,
506,
1655,
2419,
4697,
4765,
291,
14,
2415,
59,
16,
1055,
6726,
16501,
12,
1816,
536,
12,
5687,
435,
1166,
12,
378,
12,
2163,
4792,
1457,
12,
2287,
12,
8643,
4606,
9,
398,
291,
14,
793,
14,
815,
480,
774,
543,
3866,
1853,
1343,
531,
267,
702,
63,
3536,
63,
4354,
63,
705,
2801,
24,
12,
298,
3364,
1853,
1343,
401,
291,
14,
2415,
59,
16,
1055,
6726,
16501,
12,
1816,
536,
12,
5687,
435,
1166,
12,
1967,
23356,
12,
2163,
4792,
1457,
446,
3144,
12,
2287,
12,
8643,
4606,
9,
267,
702,
63,
3536,
63,
4354,
63,
705,
2801,
24,
12,
298,
3364,
1853,
1343,
401,
291,
14,
2415,
59,
16,
1055,
6726,
16501,
12,
1816,
536,
12,
5687,
435,
1166,
12,
1967,
23356,
12,
2163,
4792,
1457,
446,
1032,
14080,
7612,
4166,
12,
2287,
12,
8643,
4606,
9,
398,
291,
14,
793,
14,
815,
480,
774,
543,
3866,
510,
6882,
56,
2287,
531,
267,
702,
63,
3536,
63,
4354,
63,
705,
2801,
21,
12,
298,
3364,
510,
6882,
56,
2287,
401,
291,
14,
2415,
59,
16,
1055,
6726,
16501,
12,
1816,
536,
12,
5687,
435,
1166,
12,
1967,
23356,
12,
2163,
4792,
1457,
12,
298,
2846,
907,
86,
34,
9060,
49,
6051,
87,
85,
35,
20,
57,
3716,
4064,
21,
15563,
40,
17,
83,
33,
18,
57,
343,
86,
26467,
401,
8643,
4606,
9,
398,
291,
14,
793,
14,
815,
480,
774,
543,
4634,
6465,
5982,
531,
267,
702,
63,
3536,
63,
4354,
63,
705,
2801,
24,
12,
298,
3364,
5982,
446,
25523,
402,
1749,
14,
383,
365,
6656,
2419,
7481,
1616,
510,
6882,
4370,
401,
291,
14,
2415,
59,
16,
1055,
6726,
16501,
12,
1816,
536,
12,
5687,
435,
1166,
12,
1967,
23356,
12,
2163,
4792,
1457,
12,
2287,
12,
1749,
9,
398,
291,
14,
793,
14,
815,
480,
774,
543,
4634,
4721,
5982,
531,
267,
702,
63,
3536,
63,
4354,
63,
705,
2801,
24,
12,
298,
3364,
5982,
446,
25523,
402,
5049,
24,
4587,
14,
383,
1655,
2419,
1390,
402,
5049,
15214,
14,
383,
401,
291,
14,
2415,
59,
16,
1055,
6726,
16501,
12,
1816,
536,
12,
5687,
435,
1166,
12,
1967,
23356,
12,
2163,
4792,
1457,
12,
2287,
12,
5049,
24,
4587,
9,
7318,
291,
14,
793,
14,
815,
480,
774,
1928,
2851,
5687,
531,
267,
5687,
275,
2125,
267,
702,
63,
3536,
63,
4354,
63,
705,
2801,
24,
12,
298,
3364,
2851,
12,
1104,
5687,
334,
69,
14,
71,
14,
4178,
921,
4186,
291,
14,
2415,
59,
16,
1055,
6726,
16501,
12,
536,
12,
5687,
435,
1166,
12,
413,
12,
2163,
4792,
1457,
12,
2287,
12,
2948,
9,
398,
291,
14,
793,
14,
815,
360,
774,
543,
3866,
2851,
5687,
26,
14904,
921,
358,
267,
5687,
275,
283,
8915,
22399,
267,
702,
63,
3536,
63,
4354,
63,
705,
2801,
24,
12,
298,
3364,
2851,
12,
1104,
5687,
334,
69,
14,
71,
14,
4178,
921,
4186,
291,
14,
2415,
59,
16,
1055,
6726,
16501,
12,
536,
12,
5687,
435,
1166,
12,
413,
12,
2163,
4792,
1457,
12,
2287,
12,
2948,
9,
398,
291,
14,
793,
14,
815,
480,
774,
543,
3866,
4270,
4528,
5687,
26,
394,
2859,
921,
531,
267,
5687,
275,
283,
72,
2859,
22399,
267,
1166,
275,
283,
396,
14,
957,
7,
267,
702,
63,
3536,
63,
4354,
63,
705,
2801,
24,
12,
298,
3364,
2851,
12,
1104,
5687,
334,
69,
14,
71,
14,
4178,
921,
4186,
291,
14,
2415,
59,
16,
1055,
6726,
16501,
12,
536,
12,
5687,
435,
1166,
12,
413,
12,
2163,
4792,
1457,
12,
2287,
12,
2948,
9,
398,
291,
14,
793,
14,
815,
480,
774,
543,
1686,
5687,
26,
1455,
921,
531,
267,
536,
275
] |
[
2647,
15,
1393,
15,
1813,
2366,
19,
199,
3,
1898,
334,
67,
9,
20312,
710,
510,
6882,
56,
19782,
199,
3,
17484,
1334,
314,
10697,
2032,
4190,
12,
1937,
314,
23073,
199,
3,
570,
9685,
503,
1455,
921,
1544,
14,
16374,
14,
1308,
15,
2383,
15,
1147,
13,
1682,
14,
8624,
14,
199,
624,
774,
11785,
3718,
367,
1032,
14080,
28315,
7143,
12,
13071,
12,
436,
14786,
1041,
199,
199,
504,
511,
63,
4857,
14,
396,
63,
4857,
492,
510,
1003,
88,
26203,
199,
504,
511,
63,
4857,
14,
1974,
492,
627,
421,
199,
533,
699,
1181,
362,
919,
14506,
774,
8,
48,
1003,
88,
26203,
304,
272,
347,
663,
63,
396,
63,
1162,
8,
277,
304,
267,
291,
14,
1507,
63,
2415,
275,
413,
339,
347,
1255,
63,
396,
8,
277,
304,
267,
1032,
14080,
7612,
4166,
275,
21771,
267,
2163,
4792,
1457,
275,
291,
14,
2415,
59,
16,
1055,
362,
2184,
4792,
1457,
342,
267,
2287,
275,
291,
14,
2415,
59,
16,
1055,
21102,
342,
267,
5687,
275,
283,
1014,
22399,
267,
1166,
275,
283,
396,
14,
957,
15,
633,
13,
1045,
13,
1267,
13,
1618,
13,
1641,
13,
16516,
13,
14117,
13,
1529,
13,
22417,
7,
267,
1846,
633,
275,
283,
396,
14,
957,
15,
633,
13,
1045,
13,
1267,
13,
1618,
13,
2010,
13,
16516,
13,
14117,
13,
1397,
13,
1529,
13,
614,
7,
267,
536,
275,
283,
25700,
1045,
1165,
6574,
16,
7,
267,
1846,
354,
275,
283,
25700,
1045,
2025,
6574,
614,
7,
267,
1967,
23356,
275,
499,
267,
8643,
4606,
275,
2948,
398,
291,
14,
793,
14,
815,
480,
774,
543,
1846,
536,
531,
267,
702,
63,
3536,
63,
4354,
63,
705,
2801,
24,
12,
298,
3364,
28315,
536,
12,
2304,
402,
3388,
4110,
4765,
291,
14,
2415,
59,
16,
1055,
6726,
16501,
12,
1816,
1846,
354,
12,
5687,
435,
1166,
12,
1967,
23356,
12,
2163,
4792,
1457,
12,
2287,
12,
8643,
4606,
9,
398,
291,
14,
793,
14,
815,
480,
774,
543,
1846,
2851,
531,
267,
702,
63,
3536,
63,
4354,
63,
705,
2801,
24,
12,
298,
3364,
2851,
26,
11738,
22338,
2304,
402,
5049,
4110,
4765,
291,
14,
2415,
59,
16,
1055,
6726,
16501,
12,
1816,
536,
12,
5687,
435,
1846,
633,
12,
1967,
23356,
12,
2163,
4792,
1457,
12,
2287,
12,
8643,
4606,
9,
398,
291,
14,
793,
14,
815,
480,
774,
543,
3866,
334,
16,
9,
19001,
531,
267,
702,
63,
3536,
63,
4354,
63,
705,
2801,
24,
12,
298,
3364,
11628,
2338,
12,
1471,
506,
1655,
2419,
4697,
4765,
291,
14,
2415,
59,
16,
1055,
6726,
16501,
12,
1816,
536,
12,
5687,
435,
1166,
12,
378,
12,
2163,
4792,
1457,
12,
2287,
12,
8643,
4606,
9,
398,
291,
14,
793,
14,
815,
480,
774,
543,
3866,
1853,
1343,
531,
267,
702,
63,
3536,
63,
4354,
63,
705,
2801,
24,
12,
298,
3364,
1853,
1343,
401,
291,
14,
2415,
59,
16,
1055,
6726,
16501,
12,
1816,
536,
12,
5687,
435,
1166,
12,
1967,
23356,
12,
2163,
4792,
1457,
446,
3144,
12,
2287,
12,
8643,
4606,
9,
267,
702,
63,
3536,
63,
4354,
63,
705,
2801,
24,
12,
298,
3364,
1853,
1343,
401,
291,
14,
2415,
59,
16,
1055,
6726,
16501,
12,
1816,
536,
12,
5687,
435,
1166,
12,
1967,
23356,
12,
2163,
4792,
1457,
446,
1032,
14080,
7612,
4166,
12,
2287,
12,
8643,
4606,
9,
398,
291,
14,
793,
14,
815,
480,
774,
543,
3866,
510,
6882,
56,
2287,
531,
267,
702,
63,
3536,
63,
4354,
63,
705,
2801,
21,
12,
298,
3364,
510,
6882,
56,
2287,
401,
291,
14,
2415,
59,
16,
1055,
6726,
16501,
12,
1816,
536,
12,
5687,
435,
1166,
12,
1967,
23356,
12,
2163,
4792,
1457,
12,
298,
2846,
907,
86,
34,
9060,
49,
6051,
87,
85,
35,
20,
57,
3716,
4064,
21,
15563,
40,
17,
83,
33,
18,
57,
343,
86,
26467,
401,
8643,
4606,
9,
398,
291,
14,
793,
14,
815,
480,
774,
543,
4634,
6465,
5982,
531,
267,
702,
63,
3536,
63,
4354,
63,
705,
2801,
24,
12,
298,
3364,
5982,
446,
25523,
402,
1749,
14,
383,
365,
6656,
2419,
7481,
1616,
510,
6882,
4370,
401,
291,
14,
2415,
59,
16,
1055,
6726,
16501,
12,
1816,
536,
12,
5687,
435,
1166,
12,
1967,
23356,
12,
2163,
4792,
1457,
12,
2287,
12,
1749,
9,
398,
291,
14,
793,
14,
815,
480,
774,
543,
4634,
4721,
5982,
531,
267,
702,
63,
3536,
63,
4354,
63,
705,
2801,
24,
12,
298,
3364,
5982,
446,
25523,
402,
5049,
24,
4587,
14,
383,
1655,
2419,
1390,
402,
5049,
15214,
14,
383,
401,
291,
14,
2415,
59,
16,
1055,
6726,
16501,
12,
1816,
536,
12,
5687,
435,
1166,
12,
1967,
23356,
12,
2163,
4792,
1457,
12,
2287,
12,
5049,
24,
4587,
9,
7318,
291,
14,
793,
14,
815,
480,
774,
1928,
2851,
5687,
531,
267,
5687,
275,
2125,
267,
702,
63,
3536,
63,
4354,
63,
705,
2801,
24,
12,
298,
3364,
2851,
12,
1104,
5687,
334,
69,
14,
71,
14,
4178,
921,
4186,
291,
14,
2415,
59,
16,
1055,
6726,
16501,
12,
536,
12,
5687,
435,
1166,
12,
413,
12,
2163,
4792,
1457,
12,
2287,
12,
2948,
9,
398,
291,
14,
793,
14,
815,
360,
774,
543,
3866,
2851,
5687,
26,
14904,
921,
358,
267,
5687,
275,
283,
8915,
22399,
267,
702,
63,
3536,
63,
4354,
63,
705,
2801,
24,
12,
298,
3364,
2851,
12,
1104,
5687,
334,
69,
14,
71,
14,
4178,
921,
4186,
291,
14,
2415,
59,
16,
1055,
6726,
16501,
12,
536,
12,
5687,
435,
1166,
12,
413,
12,
2163,
4792,
1457,
12,
2287,
12,
2948,
9,
398,
291,
14,
793,
14,
815,
480,
774,
543,
3866,
4270,
4528,
5687,
26,
394,
2859,
921,
531,
267,
5687,
275,
283,
72,
2859,
22399,
267,
1166,
275,
283,
396,
14,
957,
7,
267,
702,
63,
3536,
63,
4354,
63,
705,
2801,
24,
12,
298,
3364,
2851,
12,
1104,
5687,
334,
69,
14,
71,
14,
4178,
921,
4186,
291,
14,
2415,
59,
16,
1055,
6726,
16501,
12,
536,
12,
5687,
435,
1166,
12,
413,
12,
2163,
4792,
1457,
12,
2287,
12,
2948,
9,
398,
291,
14,
793,
14,
815,
480,
774,
543,
1686,
5687,
26,
1455,
921,
531,
267,
536,
275,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
SoftwareMaven/django
|
django/contrib/sessions/backends/signed_cookies.py
|
383
|
2895
|
from django.conf import settings
from django.contrib.sessions.backends.base import SessionBase
from django.core import signing
class SessionStore(SessionBase):
def load(self):
"""
We load the data from the key itself instead of fetching from
some external data store. Opposite of _get_session_key(),
raises BadSignature if signature fails.
"""
try:
return signing.loads(self.session_key,
serializer=self.serializer,
# This doesn't handle non-default expiry dates, see #19201
max_age=settings.SESSION_COOKIE_AGE,
salt='django.contrib.sessions.backends.signed_cookies')
except Exception:
# BadSignature, ValueError, or unpickling exceptions. If any of
# these happen, reset the session.
self.create()
return {}
def create(self):
"""
To create a new key, we simply make sure that the modified flag is set
so that the cookie is set on the client for the current request.
"""
self.modified = True
def save(self, must_create=False):
"""
To save, we get the session key as a securely signed string and then
set the modified flag so that the cookie is set on the client for the
current request.
"""
self._session_key = self._get_session_key()
self.modified = True
def exists(self, session_key=None):
"""
This method makes sense when you're talking to a shared resource, but
it doesn't matter when you're storing the information in the client's
cookie.
"""
return False
def delete(self, session_key=None):
"""
To delete, we clear the session key and the underlying data structure
and set the modified flag so that the cookie is set on the client for
the current request.
"""
self._session_key = ''
self._session_cache = {}
self.modified = True
def cycle_key(self):
"""
Keeps the same data but with a new key. To do this, we just have to
call ``save()`` and it will automatically save a cookie with a new key
at the end of the request.
"""
self.save()
def _get_session_key(self):
"""
Most session backends don't need to override this method, but we do,
because instead of generating a random string, we want to actually
generate a secure url-safe Base64-encoded string of data as our
session key.
"""
session_cache = getattr(self, '_session_cache', {})
return signing.dumps(session_cache, compress=True,
salt='django.contrib.sessions.backends.signed_cookies',
serializer=self.serializer)
@classmethod
def clear_expired(cls):
pass
|
bsd-3-clause
|
[
504,
1639,
14,
2190,
492,
2202,
199,
504,
1639,
14,
2828,
14,
11676,
14,
7765,
14,
1095,
492,
8596,
1563,
199,
504,
1639,
14,
1018,
492,
18057,
421,
199,
533,
8596,
5502,
8,
4434,
1563,
304,
339,
347,
2248,
8,
277,
304,
267,
408,
267,
2136,
2248,
314,
666,
687,
314,
790,
6337,
3140,
402,
21239,
687,
267,
2005,
5957,
666,
3877,
14,
9319,
23898,
402,
485,
362,
63,
1730,
63,
498,
1062,
267,
6534,
8857,
10014,
340,
4955,
6918,
14,
267,
408,
267,
862,
26,
288,
372,
18057,
14,
3640,
8,
277,
14,
1730,
63,
498,
12,
355,
9146,
29,
277,
14,
8349,
12,
355,
327,
961,
3181,
1133,
2429,
2222,
13,
885,
23402,
10831,
12,
1937,
327,
1167,
1797,
355,
1390,
63,
474,
29,
1751,
14,
12763,
63,
13665,
63,
2962,
12,
355,
10105,
534,
1176,
14,
2828,
14,
11676,
14,
7765,
14,
1737,
63,
7792,
358,
267,
871,
2186,
26,
288,
327,
8857,
10014,
12,
1722,
12,
503,
625,
24773,
4967,
14,
982,
1263,
402,
288,
327,
3520,
5992,
12,
5305,
314,
2351,
14,
288,
291,
14,
981,
342,
267,
372,
1052,
339,
347,
1218,
8,
277,
304,
267,
408,
267,
4005,
1218,
282,
892,
790,
12,
781,
9329,
1852,
3238,
626,
314,
6042,
3305,
365,
663,
267,
880,
626,
314,
5494,
365,
663,
641,
314,
1890,
367,
314,
1453,
1056,
14,
267,
408,
267,
291,
14,
5540,
275,
715,
339,
347,
3354,
8,
277,
12,
1471,
63,
981,
29,
797,
304,
267,
408,
267,
4005,
3354,
12,
781,
664,
314,
2351,
790,
465,
282,
11153,
590,
10514,
1059,
436,
2066,
267,
663,
314,
6042,
3305,
880,
626,
314,
5494,
365,
663,
641,
314,
1890,
367,
314,
267,
1453,
1056,
14,
267,
408,
267,
291,
423,
1730,
63,
498,
275,
291,
423,
362,
63,
1730,
63,
498,
342,
267,
291,
14,
5540,
275,
715,
339,
347,
3495,
8,
277,
12,
2351,
63,
498,
29,
403,
304,
267,
408,
267,
961,
1083,
7704,
12249,
1380,
1265,
3984,
22811,
316,
370,
282,
5709,
2073,
12,
1325,
267,
652,
3181,
1133,
17247,
1380,
1265,
3984,
16915,
314,
2556,
315,
314,
1890,
1159,
267,
5494,
14,
267,
408,
267,
372,
756,
339,
347,
3145,
8,
277,
12,
2351,
63,
498,
29,
403,
304,
267,
408,
267,
4005,
3145,
12,
781,
5436,
314,
2351,
790,
436,
314,
8793,
666,
5523,
267,
436,
663,
314,
6042,
3305,
880,
626,
314,
5494,
365,
663,
641,
314,
1890,
367,
267,
314,
1453,
1056,
14,
267,
408,
267,
291,
423,
1730,
63,
498,
275,
2125,
267,
291,
423,
1730,
63,
1637,
275,
1052,
267,
291,
14,
5540,
275,
715,
339,
347,
8643,
63,
498,
8,
277,
304,
267,
408,
267,
1804,
1024,
1190,
314,
2011,
666,
1325,
543,
282,
892,
790,
14,
221,
4005,
886,
642,
12,
781,
2951,
1172,
370,
267,
1240,
1124,
2117,
8497,
436,
652,
911,
5847,
3354,
282,
5494,
543,
282,
892,
790,
267,
737,
314,
1284,
402,
314,
1056,
14,
267,
408,
267,
291,
14,
2117,
342,
339,
347,
485,
362,
63,
1730,
63,
498,
8,
277,
304,
267,
408,
267,
17536,
2351,
14745,
2793,
1133,
1929,
370,
4278,
642,
1083,
12,
1325,
781,
886,
12,
267,
2952,
3140,
402,
12999,
282,
2196,
1059,
12,
781,
2934,
370,
5965,
267,
3550,
282,
11153,
1166,
13,
3489,
3523,
772,
13,
8167,
1059,
402,
666,
465,
4154,
267,
2351,
790,
14,
267,
408,
267,
2351,
63,
1637,
275,
2519,
8,
277,
12,
2513,
1730,
63,
1637,
297,
5009,
267,
372,
18057,
14,
4180,
8,
1730,
63,
1637,
12,
11029,
29,
549,
12,
288,
10105,
534,
1176,
14,
2828,
14,
11676,
14,
7765,
14,
1737,
63,
7792,
297,
288,
9146,
29,
277,
14,
8349,
9,
339,
768,
3744,
272,
347,
5436,
63,
16340,
8,
1886,
304,
267,
986,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
1639,
14,
2190,
492,
2202,
199,
504,
1639,
14,
2828,
14,
11676,
14,
7765,
14,
1095,
492,
8596,
1563,
199,
504,
1639,
14,
1018,
492,
18057,
421,
199,
533,
8596,
5502,
8,
4434,
1563,
304,
339,
347,
2248,
8,
277,
304,
267,
408,
267,
2136,
2248,
314,
666,
687,
314,
790,
6337,
3140,
402,
21239,
687,
267,
2005,
5957,
666,
3877,
14,
9319,
23898,
402,
485,
362,
63,
1730,
63,
498,
1062,
267,
6534,
8857,
10014,
340,
4955,
6918,
14,
267,
408,
267,
862,
26,
288,
372,
18057,
14,
3640,
8,
277,
14,
1730,
63,
498,
12,
355,
9146,
29,
277,
14,
8349,
12,
355,
327,
961,
3181,
1133,
2429,
2222,
13,
885,
23402,
10831,
12,
1937,
327,
1167,
1797,
355,
1390,
63,
474,
29,
1751,
14,
12763,
63,
13665,
63,
2962,
12,
355,
10105,
534,
1176,
14,
2828,
14,
11676,
14,
7765,
14,
1737,
63,
7792,
358,
267,
871,
2186,
26,
288,
327,
8857,
10014,
12,
1722,
12,
503,
625,
24773,
4967,
14,
982,
1263,
402,
288,
327,
3520,
5992,
12,
5305,
314,
2351,
14,
288,
291,
14,
981,
342,
267,
372,
1052,
339,
347,
1218,
8,
277,
304,
267,
408,
267,
4005,
1218,
282,
892,
790,
12,
781,
9329,
1852,
3238,
626,
314,
6042,
3305,
365,
663,
267,
880,
626,
314,
5494,
365,
663,
641,
314,
1890,
367,
314,
1453,
1056,
14,
267,
408,
267,
291,
14,
5540,
275,
715,
339,
347,
3354,
8,
277,
12,
1471,
63,
981,
29,
797,
304,
267,
408,
267,
4005,
3354,
12,
781,
664,
314,
2351,
790,
465,
282,
11153,
590,
10514,
1059,
436,
2066,
267,
663,
314,
6042,
3305,
880,
626,
314,
5494,
365,
663,
641,
314,
1890,
367,
314,
267,
1453,
1056,
14,
267,
408,
267,
291,
423,
1730,
63,
498,
275,
291,
423,
362,
63,
1730,
63,
498,
342,
267,
291,
14,
5540,
275,
715,
339,
347,
3495,
8,
277,
12,
2351,
63,
498,
29,
403,
304,
267,
408,
267,
961,
1083,
7704,
12249,
1380,
1265,
3984,
22811,
316,
370,
282,
5709,
2073,
12,
1325,
267,
652,
3181,
1133,
17247,
1380,
1265,
3984,
16915,
314,
2556,
315,
314,
1890,
1159,
267,
5494,
14,
267,
408,
267,
372,
756,
339,
347,
3145,
8,
277,
12,
2351,
63,
498,
29,
403,
304,
267,
408,
267,
4005,
3145,
12,
781,
5436,
314,
2351,
790,
436,
314,
8793,
666,
5523,
267,
436,
663,
314,
6042,
3305,
880,
626,
314,
5494,
365,
663,
641,
314,
1890,
367,
267,
314,
1453,
1056,
14,
267,
408,
267,
291,
423,
1730,
63,
498,
275,
2125,
267,
291,
423,
1730,
63,
1637,
275,
1052,
267,
291,
14,
5540,
275,
715,
339,
347,
8643,
63,
498,
8,
277,
304,
267,
408,
267,
1804,
1024,
1190,
314,
2011,
666,
1325,
543,
282,
892,
790,
14,
221,
4005,
886,
642,
12,
781,
2951,
1172,
370,
267,
1240,
1124,
2117,
8497,
436,
652,
911,
5847,
3354,
282,
5494,
543,
282,
892,
790,
267,
737,
314,
1284,
402,
314,
1056,
14,
267,
408,
267,
291,
14,
2117,
342,
339,
347,
485,
362,
63,
1730,
63,
498,
8,
277,
304,
267,
408,
267,
17536,
2351,
14745,
2793,
1133,
1929,
370,
4278,
642,
1083,
12,
1325,
781,
886,
12,
267,
2952,
3140,
402,
12999,
282,
2196,
1059,
12,
781,
2934,
370,
5965,
267,
3550,
282,
11153,
1166,
13,
3489,
3523,
772,
13,
8167,
1059,
402,
666,
465,
4154,
267,
2351,
790,
14,
267,
408,
267,
2351,
63,
1637,
275,
2519,
8,
277,
12,
2513,
1730,
63,
1637,
297,
5009,
267,
372,
18057,
14,
4180,
8,
1730,
63,
1637,
12,
11029,
29,
549,
12,
288,
10105,
534,
1176,
14,
2828,
14,
11676,
14,
7765,
14,
1737,
63,
7792,
297,
288,
9146,
29,
277,
14,
8349,
9,
339,
768,
3744,
272,
347,
5436,
63,
16340,
8,
1886,
304,
267,
986,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
couchbase/healthchecker
|
Cheetah/TemplateCmdLineIface.py
|
15
|
3311
|
# $Id: TemplateCmdLineIface.py,v 1.13 2006/01/10 20:34:35 tavis_rudd Exp $
"""Provides a command line interface to compiled Cheetah template modules.
Meta-Data
================================================================================
Author: Tavis Rudd <tavis@damnsimple.com>
Version: $Revision: 1.13 $
Start Date: 2001/12/06
Last Revision Date: $Date: 2006/01/10 20:34:35 $
"""
__author__ = "Tavis Rudd <tavis@damnsimple.com>"
__revision__ = "$Revision: 1.13 $"[11:-2]
import sys
import os
import getopt
import os.path
try:
from cPickle import load
except ImportError:
from pickle import load
from Cheetah.Version import Version
class Error(Exception):
pass
class CmdLineIface:
"""A command line interface to compiled Cheetah template modules."""
def __init__(self, templateObj,
scriptName=os.path.basename(sys.argv[0]),
cmdLineArgs=sys.argv[1:]):
self._template = templateObj
self._scriptName = scriptName
self._cmdLineArgs = cmdLineArgs
def run(self):
"""The main program controller."""
self._processCmdLineArgs()
print(self._template)
def _processCmdLineArgs(self):
try:
self._opts, self._args = getopt.getopt(
self._cmdLineArgs, 'h', ['help',
'env',
'pickle=',
])
except getopt.GetoptError, v:
# print help information and exit:
print(v)
print(self.usage())
sys.exit(2)
for o, a in self._opts:
if o in ('-h', '--help'):
print(self.usage())
sys.exit()
if o == '--env':
self._template.searchList().insert(0, os.environ)
if o == '--pickle':
if a == '-':
unpickled = load(sys.stdin)
self._template.searchList().insert(0, unpickled)
else:
f = open(a)
unpickled = load(f)
f.close()
self._template.searchList().insert(0, unpickled)
def usage(self):
return """Cheetah %(Version)s template module command-line interface
Usage
-----
%(scriptName)s [OPTION]
Options
-------
-h, --help Print this help information
--env Use shell ENVIRONMENT variables to fill the
$placeholders in the template.
--pickle <file> Use a variables from a dictionary stored in Python
pickle file to fill $placeholders in the template.
If <file> is - stdin is used:
'%(scriptName)s --pickle -'
Description
-----------
This interface allows you to execute a Cheetah template from the command line
and collect the output. It can prepend the shell ENVIRONMENT or a pickled
Python dictionary to the template's $placeholder searchList, overriding the
defaults for the $placeholders.
""" % {'scriptName': self._scriptName,
'Version': Version,
}
# vim: shiftwidth=4 tabstop=4 expandtab
|
apache-2.0
|
[
3,
2672,
1304,
26,
5458,
7874,
3049,
30606,
14,
647,
12,
86,
413,
14,
969,
8315,
15,
614,
15,
709,
3388,
26,
1082,
26,
1276,
307,
1214,
374,
63,
6558,
617,
7910,
2672,
199,
199,
624,
17473,
282,
1414,
1004,
3217,
370,
10311,
445,
426,
1841,
72,
1978,
4621,
14,
199,
199,
3396,
13,
1451,
199,
5695,
1280,
199,
5949,
26,
377,
1214,
374,
820,
8615,
665,
502,
5068,
32,
68,
455,
78,
4129,
14,
957,
30,
199,
3353,
26,
2672,
12714,
26,
413,
14,
969,
2672,
199,
3162,
6148,
26,
12521,
15,
713,
15,
1690,
199,
6090,
27095,
6148,
26,
2672,
2506,
26,
8315,
15,
614,
15,
709,
3388,
26,
1082,
26,
1276,
2672,
199,
624,
199,
363,
2502,
363,
275,
298,
52,
1214,
374,
820,
8615,
665,
502,
5068,
32,
68,
455,
78,
4129,
14,
957,
4335,
199,
363,
5792,
363,
275,
7880,
12714,
26,
413,
14,
969,
2672,
22774,
845,
6809,
18,
61,
199,
199,
646,
984,
199,
646,
747,
199,
646,
12733,
199,
646,
747,
14,
515,
199,
893,
26,
272,
687,
17572,
492,
2248,
199,
2590,
3545,
26,
272,
687,
5927,
492,
2248,
199,
199,
504,
445,
426,
1841,
72,
14,
3353,
492,
3394,
199,
199,
533,
4520,
8,
1726,
304,
272,
986,
199,
199,
533,
26005,
3049,
30606,
26,
272,
408,
33,
1414,
1004,
3217,
370,
10311,
445,
426,
1841,
72,
1978,
4621,
1041,
339,
347,
636,
826,
721,
277,
12,
1978,
5665,
12,
326,
2884,
985,
29,
736,
14,
515,
14,
4846,
8,
1274,
14,
3020,
59,
16,
2522,
326,
2088,
3049,
6213,
29,
1274,
14,
3020,
59,
17,
28847,
398,
291,
423,
1160,
275,
1978,
5665,
267,
291,
423,
1579,
985,
275,
2884,
985,
267,
291,
423,
1760,
3049,
6213,
275,
2088,
3049,
6213,
339,
347,
1255,
8,
277,
304,
267,
408,
1918,
2446,
2240,
7614,
1041,
2728,
291,
423,
1412,
7874,
3049,
6213,
342,
267,
870,
8,
277,
423,
1160,
9,
5493,
347,
485,
1412,
7874,
3049,
6213,
8,
277,
304,
267,
862,
26,
288,
291,
423,
3291,
12,
291,
423,
589,
275,
12733,
14,
18907,
8,
355,
291,
423,
1760,
3049,
6213,
12,
283,
72,
297,
788,
3437,
297,
4490,
283,
1813,
297,
4490,
283,
8092,
4009,
4490,
4794,
398,
871,
12733,
14,
1002,
29368,
12,
373,
26,
288,
327,
870,
1720,
2556,
436,
4458,
26,
288,
870,
8,
86,
9,
288,
870,
8,
277,
14,
3807,
1012,
288,
984,
14,
2224,
8,
18,
9,
2728,
367,
312,
12,
282,
315,
291,
423,
3291,
26,
288,
340,
312,
315,
12291,
72,
297,
2850,
3437,
735,
355,
870,
8,
277,
14,
3807,
1012,
355,
984,
14,
2224,
342,
288,
340,
312,
508,
2850,
1813,
356,
355,
291,
423,
1160,
14,
1733,
1296,
1252,
3176,
8,
16,
12,
747,
14,
2314,
9,
288,
340,
312,
508,
2850,
8092,
356,
355,
340,
282,
508,
20905,
490,
625,
20428,
275,
2248,
8,
1274,
14,
6626,
9,
490,
291,
423,
1160,
14,
1733,
1296,
1252,
3176,
8,
16,
12,
625,
20428,
9,
355,
587,
26,
490,
289,
275,
1551,
8,
65,
9,
490,
625,
20428,
275,
2248,
8,
70,
9,
490,
289,
14,
1600,
342,
490,
291,
423,
1160,
14,
1733,
1296,
1252,
3176,
8,
16,
12,
625,
20428,
9,
339,
347,
4503,
8,
277,
304,
267,
372,
408,
20335,
1841,
72,
2818,
3353,
9,
83,
1978,
859,
1414,
13,
604,
3217,
199,
199,
7692,
199,
9858,
523,
2818,
1579,
985,
9,
83,
359,
13352,
61,
199,
199,
4558,
199,
12797,
523,
446,
72,
12,
1553,
3437,
463,
9101,
642,
1720,
2556,
12244,
1553,
1813,
10473,
3645,
5218,
5070,
13679,
615,
4479,
2860,
370,
5554,
314,
2490,
2672,
22100,
315,
314,
1978,
14,
2892,
523,
1553,
8092,
665,
493,
30,
3322,
3645,
282,
2860,
687,
282,
2600,
5489,
315,
2018,
2490,
5927,
570,
370,
5554,
2672,
22100,
315,
314,
1978,
14,
2490,
982,
665,
493,
30,
365,
446,
9009,
365,
1202,
26,
221,
2490,
9487,
1579,
985,
9,
83,
1553,
8092,
446,
7,
199,
199,
5831,
199,
13715,
199,
199,
2765,
3217,
6127,
1265,
370,
5341,
282,
445,
426,
1841,
72,
1978,
687,
314,
1414,
1004,
199,
460,
8775,
314,
1072,
14,
221,
2779,
883,
18213,
314,
5218,
5070,
13679,
615,
4479,
503,
282,
18731,
199,
4718,
2600,
370,
314,
1978,
1159,
2672,
6199,
2754,
1296,
12,
18972,
314,
199,
4322,
367,
314,
2672,
22100,
14,
199,
199,
624,
450,
791,
1579,
985,
356,
291,
423,
1579,
985,
12,
2126,
283,
3353,
356,
3394,
12,
2126,
789,
199,
199,
3,
6695,
26,
20105,
29,
20,
20849,
29,
20,
26414,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
2672,
1304,
26,
5458,
7874,
3049,
30606,
14,
647,
12,
86,
413,
14,
969,
8315,
15,
614,
15,
709,
3388,
26,
1082,
26,
1276,
307,
1214,
374,
63,
6558,
617,
7910,
2672,
199,
199,
624,
17473,
282,
1414,
1004,
3217,
370,
10311,
445,
426,
1841,
72,
1978,
4621,
14,
199,
199,
3396,
13,
1451,
199,
5695,
1280,
199,
5949,
26,
377,
1214,
374,
820,
8615,
665,
502,
5068,
32,
68,
455,
78,
4129,
14,
957,
30,
199,
3353,
26,
2672,
12714,
26,
413,
14,
969,
2672,
199,
3162,
6148,
26,
12521,
15,
713,
15,
1690,
199,
6090,
27095,
6148,
26,
2672,
2506,
26,
8315,
15,
614,
15,
709,
3388,
26,
1082,
26,
1276,
2672,
199,
624,
199,
363,
2502,
363,
275,
298,
52,
1214,
374,
820,
8615,
665,
502,
5068,
32,
68,
455,
78,
4129,
14,
957,
4335,
199,
363,
5792,
363,
275,
7880,
12714,
26,
413,
14,
969,
2672,
22774,
845,
6809,
18,
61,
199,
199,
646,
984,
199,
646,
747,
199,
646,
12733,
199,
646,
747,
14,
515,
199,
893,
26,
272,
687,
17572,
492,
2248,
199,
2590,
3545,
26,
272,
687,
5927,
492,
2248,
199,
199,
504,
445,
426,
1841,
72,
14,
3353,
492,
3394,
199,
199,
533,
4520,
8,
1726,
304,
272,
986,
199,
199,
533,
26005,
3049,
30606,
26,
272,
408,
33,
1414,
1004,
3217,
370,
10311,
445,
426,
1841,
72,
1978,
4621,
1041,
339,
347,
636,
826,
721,
277,
12,
1978,
5665,
12,
326,
2884,
985,
29,
736,
14,
515,
14,
4846,
8,
1274,
14,
3020,
59,
16,
2522,
326,
2088,
3049,
6213,
29,
1274,
14,
3020,
59,
17,
28847,
398,
291,
423,
1160,
275,
1978,
5665,
267,
291,
423,
1579,
985,
275,
2884,
985,
267,
291,
423,
1760,
3049,
6213,
275,
2088,
3049,
6213,
339,
347,
1255,
8,
277,
304,
267,
408,
1918,
2446,
2240,
7614,
1041,
2728,
291,
423,
1412,
7874,
3049,
6213,
342,
267,
870,
8,
277,
423,
1160,
9,
5493,
347,
485,
1412,
7874,
3049,
6213,
8,
277,
304,
267,
862,
26,
288,
291,
423,
3291,
12,
291,
423,
589,
275,
12733,
14,
18907,
8,
355,
291,
423,
1760,
3049,
6213,
12,
283,
72,
297,
788,
3437,
297,
4490,
283,
1813,
297,
4490,
283,
8092,
4009,
4490,
4794,
398,
871,
12733,
14,
1002,
29368,
12,
373,
26,
288,
327,
870,
1720,
2556,
436,
4458,
26,
288,
870,
8,
86,
9,
288,
870,
8,
277,
14,
3807,
1012,
288,
984,
14,
2224,
8,
18,
9,
2728,
367,
312,
12,
282,
315,
291,
423,
3291,
26,
288,
340,
312,
315,
12291,
72,
297,
2850,
3437,
735,
355,
870,
8,
277,
14,
3807,
1012,
355,
984,
14,
2224,
342,
288,
340,
312,
508,
2850,
1813,
356,
355,
291,
423,
1160,
14,
1733,
1296,
1252,
3176,
8,
16,
12,
747,
14,
2314,
9,
288,
340,
312,
508,
2850,
8092,
356,
355,
340,
282,
508,
20905,
490,
625,
20428,
275,
2248,
8,
1274,
14,
6626,
9,
490,
291,
423,
1160,
14,
1733,
1296,
1252,
3176,
8,
16,
12,
625,
20428,
9,
355,
587,
26,
490,
289,
275,
1551,
8,
65,
9,
490,
625,
20428,
275,
2248,
8,
70,
9,
490,
289,
14,
1600,
342,
490,
291,
423,
1160,
14,
1733,
1296,
1252,
3176,
8,
16,
12,
625,
20428,
9,
339,
347,
4503,
8,
277,
304,
267,
372,
408,
20335,
1841,
72,
2818,
3353,
9,
83,
1978,
859,
1414,
13,
604,
3217,
199,
199,
7692,
199,
9858,
523,
2818,
1579,
985,
9,
83,
359,
13352,
61,
199,
199,
4558,
199,
12797,
523,
446,
72,
12,
1553,
3437,
463,
9101,
642,
1720,
2556,
12244,
1553,
1813,
10473,
3645,
5218,
5070,
13679,
615,
4479,
2860,
370,
5554,
314,
2490,
2672,
22100,
315,
314,
1978,
14,
2892,
523,
1553,
8092,
665,
493,
30,
3322,
3645,
282,
2860,
687,
282,
2600,
5489,
315,
2018,
2490,
5927,
570,
370,
5554,
2672,
22100,
315,
314,
1978,
14,
2490,
982,
665,
493,
30,
365,
446,
9009,
365,
1202,
26,
221,
2490,
9487,
1579,
985,
9,
83,
1553,
8092,
446,
7,
199,
199,
5831,
199,
13715,
199,
199,
2765,
3217,
6127,
1265,
370,
5341,
282,
445,
426,
1841,
72,
1978,
687,
314,
1414,
1004,
199,
460,
8775,
314,
1072,
14,
221,
2779,
883,
18213,
314,
5218,
5070,
13679,
615,
4479,
503,
282,
18731,
199,
4718,
2600,
370,
314,
1978,
1159,
2672,
6199,
2754,
1296,
12,
18972,
314,
199,
4322,
367,
314,
2672,
22100,
14,
199,
199,
624,
450,
791,
1579,
985,
356,
291,
423,
1579,
985,
12,
2126,
283,
3353,
356,
3394,
12,
2126,
789,
199,
199,
3,
6695,
26,
20105,
29,
20,
20849,
29,
20,
26414,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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of charge, to any person obtaining a
# copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish, dis-
# tribute, sublicense, and/or sell copies of the Software, and to permit
# persons to whom the Software is furnished to do so, subject to the fol-
# lowing conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
# ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
# SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.
#
from boto.regioninfo import RegionInfo, get_regions
from boto.regioninfo import connect
def regions():
"""
Get all available regions for the AWS Elastic Transcoder service.
:rtype: list
:return: A list of :class:`boto.regioninfo.RegionInfo`
"""
from boto.elastictranscoder.layer1 import ElasticTranscoderConnection
return get_regions(
'elastictranscoder',
connection_cls=ElasticTranscoderConnection
)
def connect_to_region(region_name, **kw_params):
from boto.elastictranscoder.layer1 import ElasticTranscoderConnection
return connect('elastictranscoder', region_name,
connection_cls=ElasticTranscoderConnection, **kw_params)
|
gpl-3.0
|
[
3,
1898,
334,
67,
9,
6171,
14347,
14,
957,
12,
3277,
14,
503,
2399,
29172,
2335,
14,
199,
3,
2900,
5924,
5702,
199,
3,
199,
3,
8779,
365,
11882,
10009,
12,
2867,
402,
11204,
12,
370,
1263,
4954,
12408,
282,
199,
3,
1331,
402,
642,
2032,
436,
4568,
3794,
1584,
334,
1589,
199,
3,
298,
10337,
1288,
370,
7962,
315,
314,
2290,
1928,
10588,
12,
5893,
199,
3,
1928,
12305,
314,
4481,
370,
675,
12,
1331,
12,
2811,
12,
5389,
12,
2780,
12,
2153,
13,
199,
3,
28420,
12,
13473,
12,
436,
15,
269,
12743,
6866,
402,
314,
2290,
12,
436,
370,
11291,
199,
3,
12103,
370,
12676,
314,
2290,
365,
13985,
370,
886,
880,
12,
5420,
370,
314,
1699,
13,
199,
3,
28486,
3704,
26,
199,
3,
199,
3,
710,
3432,
4248,
4245,
436,
642,
4983,
4245,
10989,
506,
5120,
199,
3,
315,
1006,
6866,
503,
13393,
12468,
402,
314,
2290,
14,
199,
3,
199,
3,
2334,
4141,
2281,
7049,
298,
1179,
2281,
401,
2428,
3408,
1634,
1821,
3826,
12,
7168,
199,
3,
1549,
5292,
12,
6931,
5400,
2845,
5471,
2296,
2334,
2990,
1634,
28471,
13,
199,
3,
28463,
12,
3092,
2381,
437,
3115,
3104,
2401,
13229,
14,
1621,
4825,
6461,
199,
3,
7000,
2334,
17632,
6262,
7024,
2381,
1821,
13140,
12,
6736,
1549,
5010,
5603,
12,
199,
3,
7061,
1621,
1261,
9612,
1634,
7066,
12,
7056,
1549,
7334,
12,
7043,
4442,
12,
199,
3,
5738,
1634,
1549,
1621,
11287,
1663,
2334,
4141,
1549,
2334,
4815,
1549,
5010,
13198,
199,
3,
1621,
2334,
4141,
14,
199,
3,
199,
504,
6055,
14,
4551,
815,
492,
22240,
2354,
12,
664,
63,
11963,
199,
504,
6055,
14,
4551,
815,
492,
4907,
421,
199,
318,
16150,
837,
272,
408,
272,
2372,
1006,
2808,
16150,
367,
314,
10168,
19509,
6266,
2693,
2435,
14,
339,
520,
4500,
26,
769,
272,
520,
1107,
26,
437,
769,
402,
520,
533,
1705,
10914,
14,
4551,
815,
14,
10708,
2354,
64,
272,
408,
272,
687,
6055,
14,
352,
1810,
73,
319,
1320,
2693,
14,
1897,
17,
492,
19509,
3188,
2693,
3225,
272,
372,
664,
63,
11963,
8,
267,
283,
352,
1810,
73,
319,
1320,
2693,
297,
267,
1950,
63,
1886,
29,
27822,
3188,
2693,
3225,
272,
776,
421,
199,
318,
4907,
63,
475,
63,
4551,
8,
4551,
63,
354,
12,
1011,
829,
63,
1162,
304,
272,
687,
6055,
14,
352,
1810,
73,
319,
1320,
2693,
14,
1897,
17,
492,
19509,
3188,
2693,
3225,
272,
372,
4907,
360,
352,
1810,
73,
319,
1320,
2693,
297,
4897,
63,
354,
12,
673,
1950,
63,
1886,
29,
27822,
3188,
2693,
3225,
12,
1011,
829,
63,
1162,
9,
421,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
1898,
334,
67,
9,
6171,
14347,
14,
957,
12,
3277,
14,
503,
2399,
29172,
2335,
14,
199,
3,
2900,
5924,
5702,
199,
3,
199,
3,
8779,
365,
11882,
10009,
12,
2867,
402,
11204,
12,
370,
1263,
4954,
12408,
282,
199,
3,
1331,
402,
642,
2032,
436,
4568,
3794,
1584,
334,
1589,
199,
3,
298,
10337,
1288,
370,
7962,
315,
314,
2290,
1928,
10588,
12,
5893,
199,
3,
1928,
12305,
314,
4481,
370,
675,
12,
1331,
12,
2811,
12,
5389,
12,
2780,
12,
2153,
13,
199,
3,
28420,
12,
13473,
12,
436,
15,
269,
12743,
6866,
402,
314,
2290,
12,
436,
370,
11291,
199,
3,
12103,
370,
12676,
314,
2290,
365,
13985,
370,
886,
880,
12,
5420,
370,
314,
1699,
13,
199,
3,
28486,
3704,
26,
199,
3,
199,
3,
710,
3432,
4248,
4245,
436,
642,
4983,
4245,
10989,
506,
5120,
199,
3,
315,
1006,
6866,
503,
13393,
12468,
402,
314,
2290,
14,
199,
3,
199,
3,
2334,
4141,
2281,
7049,
298,
1179,
2281,
401,
2428,
3408,
1634,
1821,
3826,
12,
7168,
199,
3,
1549,
5292,
12,
6931,
5400,
2845,
5471,
2296,
2334,
2990,
1634,
28471,
13,
199,
3,
28463,
12,
3092,
2381,
437,
3115,
3104,
2401,
13229,
14,
1621,
4825,
6461,
199,
3,
7000,
2334,
17632,
6262,
7024,
2381,
1821,
13140,
12,
6736,
1549,
5010,
5603,
12,
199,
3,
7061,
1621,
1261,
9612,
1634,
7066,
12,
7056,
1549,
7334,
12,
7043,
4442,
12,
199,
3,
5738,
1634,
1549,
1621,
11287,
1663,
2334,
4141,
1549,
2334,
4815,
1549,
5010,
13198,
199,
3,
1621,
2334,
4141,
14,
199,
3,
199,
504,
6055,
14,
4551,
815,
492,
22240,
2354,
12,
664,
63,
11963,
199,
504,
6055,
14,
4551,
815,
492,
4907,
421,
199,
318,
16150,
837,
272,
408,
272,
2372,
1006,
2808,
16150,
367,
314,
10168,
19509,
6266,
2693,
2435,
14,
339,
520,
4500,
26,
769,
272,
520,
1107,
26,
437,
769,
402,
520,
533,
1705,
10914,
14,
4551,
815,
14,
10708,
2354,
64,
272,
408,
272,
687,
6055,
14,
352,
1810,
73,
319,
1320,
2693,
14,
1897,
17,
492,
19509,
3188,
2693,
3225,
272,
372,
664,
63,
11963,
8,
267,
283,
352,
1810,
73,
319,
1320,
2693,
297,
267,
1950,
63,
1886,
29,
27822,
3188,
2693,
3225,
272,
776,
421,
199,
318,
4907,
63,
475,
63,
4551,
8,
4551,
63,
354,
12,
1011,
829,
63,
1162,
304,
272,
687,
6055,
14,
352,
1810,
73,
319,
1320,
2693,
14,
1897,
17,
492,
19509,
3188,
2693,
3225,
272,
372,
4907,
360,
352,
1810,
73,
319,
1320,
2693,
297,
4897,
63,
354,
12,
673,
1950,
63,
1886,
29,
27822,
3188,
2693,
3225,
12,
1011,
829,
63,
1162,
9,
421,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
yfdyh000/olympia
|
apps/bandwagon/cron.py
|
11
|
5510
|
from datetime import date, timedelta
import itertools
from django.db import connection, transaction
from django.db.models import Count
import commonware.log
from celery.task.sets import TaskSet
import amo
from amo.celery import task
from amo.utils import chunked, slugify
from bandwagon.models import (Collection, SyncedCollection, CollectionVote,
CollectionWatcher)
import cronjobs
task_log = commonware.log.getLogger('z.task')
@cronjobs.register
def update_collections_subscribers():
"""Update collections subscribers totals."""
d = (CollectionWatcher.objects.values('collection_id')
.annotate(count=Count('collection'))
.extra(where=['DATE(created)=%s'], params=[date.today()]))
ts = [_update_collections_subscribers.subtask(args=[chunk])
for chunk in chunked(d, 1000)]
TaskSet(ts).apply_async()
@task(rate_limit='15/m')
def _update_collections_subscribers(data, **kw):
task_log.info("[%s@%s] Updating collections' subscribers totals." % (
len(data), _update_collections_subscribers.rate_limit))
cursor = connection.cursor()
today = date.today()
for var in data:
q = """REPLACE INTO
stats_collections(`date`, `name`, `collection_id`, `count`)
VALUES
(%s, %s, %s, %s)"""
p = [today, 'new_subscribers', var['collection_id'], var['count']]
cursor.execute(q, p)
transaction.commit_unless_managed()
@cronjobs.register
def update_collections_votes():
"""Update collection's votes."""
up = (CollectionVote.objects.values('collection_id')
.annotate(count=Count('collection'))
.filter(vote=1)
.extra(where=['DATE(created)=%s'], params=[date.today()]))
down = (CollectionVote.objects.values('collection_id')
.annotate(count=Count('collection'))
.filter(vote=-1)
.extra(where=['DATE(created)=%s'], params=[date.today()]))
ts = [_update_collections_votes.subtask(args=[chunk, 'new_votes_up'])
for chunk in chunked(up, 1000)]
TaskSet(ts).apply_async()
ts = [_update_collections_votes.subtask(args=[chunk, 'new_votes_down'])
for chunk in chunked(down, 1000)]
TaskSet(ts).apply_async()
@task(rate_limit='15/m')
def _update_collections_votes(data, stat, **kw):
task_log.info("[%s@%s] Updating collections' votes totals." % (
len(data), _update_collections_votes.rate_limit))
cursor = connection.cursor()
for var in data:
q = ('REPLACE INTO stats_collections(`date`, `name`, '
'`collection_id`, `count`) VALUES (%s, %s, %s, %s)')
p = [date.today(), stat,
var['collection_id'], var['count']]
cursor.execute(q, p)
transaction.commit_unless_managed()
# TODO: remove this once zamboni enforces slugs.
@cronjobs.register
def collections_add_slugs():
"""Give slugs to any slugless collections."""
# Don't touch the modified date.
Collection._meta.get_field('modified').auto_now = False
q = Collection.objects.filter(slug=None)
ids = q.values_list('id', flat=True)
task_log.info('%s collections without names' % len(ids))
max_length = Collection._meta.get_field('slug').max_length
cnt = itertools.count()
# Chunk it so we don't do huge queries.
for chunk in chunked(ids, 300):
for c in q.no_cache().filter(id__in=chunk):
c.slug = c.nickname or slugify(c.name)[:max_length]
if not c.slug:
c.slug = 'collection'
c.save(force_update=True)
task_log.info(u'%s. %s => %s' % (next(cnt), c.name, c.slug))
@cronjobs.register
def cleanup_synced_collections():
_cleanup_synced_collections.delay()
@task(rate_limit='1/m')
@transaction.commit_on_success
def _cleanup_synced_collections(**kw):
task_log.info("[300@%s] Dropping synced collections." % (
_cleanup_synced_collections.rate_limit))
thirty_days = date.today() - timedelta(days=30)
ids = (SyncedCollection.objects.filter(created__lte=thirty_days)
.values_list('id', flat=True))[:300]
for chunk in chunked(ids, 100):
SyncedCollection.objects.filter(id__in=chunk).delete()
if ids:
_cleanup_synced_collections.delay()
@cronjobs.register
def drop_collection_recs():
_drop_collection_recs.delay()
@task(rate_limit='1/m')
@transaction.commit_on_success
def _drop_collection_recs(**kw):
task_log.info("[300@%s] Dropping recommended collections." % (
_drop_collection_recs.rate_limit))
# Get the first 300 collections and delete them in smaller chunks.
types = amo.COLLECTION_SYNCHRONIZED, amo.COLLECTION_RECOMMENDED
ids = (Collection.objects.filter(type__in=types, author__isnull=True)
.values_list('id', flat=True))[:300]
for chunk in chunked(ids, 100):
Collection.objects.filter(id__in=chunk).delete()
# Go again if we found something to delete.
if ids:
_drop_collection_recs.delay()
@cronjobs.register
def reindex_collections(index=None):
from . import tasks
ids = (Collection.objects.exclude(type=amo.COLLECTION_SYNCHRONIZED)
.values_list('id', flat=True))
taskset = [tasks.index_collections.subtask(args=[chunk],
kwargs=dict(index=index))
for chunk in chunked(sorted(list(ids)), 150)]
TaskSet(taskset).apply_async()
|
bsd-3-clause
|
[
504,
2197,
492,
1434,
12,
6871,
199,
646,
7975,
199,
199,
504,
1639,
14,
697,
492,
1950,
12,
6008,
199,
504,
1639,
14,
697,
14,
992,
492,
14826,
199,
199,
646,
2863,
1068,
14,
793,
199,
504,
22748,
14,
1765,
14,
2193,
492,
8495,
1084,
199,
199,
646,
30235,
199,
504,
30235,
14,
23593,
492,
2120,
199,
504,
30235,
14,
1208,
492,
22180,
12,
29864,
199,
504,
10981,
30412,
265,
14,
992,
492,
334,
7768,
12,
29988,
6867,
7768,
12,
18003,
54,
1583,
12,
2892,
18003,
13978,
281,
9,
199,
646,
19818,
6920,
199,
199,
1765,
63,
793,
275,
2863,
1068,
14,
793,
14,
5572,
360,
90,
14,
1765,
358,
421,
199,
32,
14829,
6920,
14,
2683,
199,
318,
1678,
63,
7882,
63,
24962,
837,
272,
408,
4152,
5055,
22148,
83,
23576,
1041,
339,
366,
275,
334,
7768,
13978,
281,
14,
1462,
14,
1459,
360,
3627,
63,
344,
358,
268,
1275,
10898,
8,
835,
29,
2353,
360,
3627,
1333,
268,
1275,
2911,
8,
4509,
2968,
5390,
8,
3966,
9,
2458,
83,
995,
1862,
1524,
602,
14,
8136,
342,
2459,
339,
6714,
275,
15500,
873,
63,
7882,
63,
24962,
14,
31719,
8,
589,
1524,
4604,
566,
881,
367,
3728,
315,
22180,
8,
68,
12,
5198,
1874,
272,
8495,
1084,
8,
1086,
680,
4998,
63,
4146,
342,
421,
199,
32,
1765,
8,
1866,
63,
3097,
534,
1046,
15,
77,
358,
199,
318,
485,
873,
63,
7882,
63,
24962,
8,
576,
12,
1011,
829,
304,
272,
2120,
63,
793,
14,
815,
480,
9722,
83,
19437,
83,
61,
4949,
9239,
5055,
7,
22148,
83,
23576,
2122,
450,
334,
2116,
822,
8,
576,
395,
485,
873,
63,
7882,
63,
24962,
14,
1866,
63,
3097,
430,
272,
3920,
275,
1950,
14,
3937,
342,
272,
11168,
275,
1434,
14,
8136,
342,
272,
367,
2729,
315,
666,
26,
267,
1894,
275,
408,
27010,
12872,
490,
5020,
63,
7882,
8,
64,
602,
3559,
658,
354,
3559,
658,
3627,
63,
344,
3559,
658,
835,
10522,
355,
13992,
490,
4366,
83,
12,
450,
83,
12,
450,
83,
12,
450,
83,
9471,
267,
299,
275,
359,
8136,
12,
283,
1222,
63,
24962,
297,
2729,
459,
3627,
63,
344,
995,
2729,
459,
835,
6538,
267,
3920,
14,
2526,
8,
81,
12,
299,
9,
272,
6008,
14,
3543,
63,
18447,
63,
11122,
342,
421,
199,
32,
14829,
6920,
14,
2683,
199,
318,
1678,
63,
7882,
63,
16660,
837,
272,
408,
4152,
3245,
1159,
373,
6510,
1041,
339,
1536,
275,
334,
7768,
54,
1583,
14,
1462,
14,
1459,
360,
3627,
63,
344,
358,
881,
1275,
10898,
8,
835,
29,
2353,
360,
3627,
1333,
881,
1275,
1541,
8,
14317,
29,
17,
9,
881,
1275,
2911,
8,
4509,
2968,
5390,
8,
3966,
9,
2458,
83,
995,
1862,
1524,
602,
14,
8136,
342,
2459,
339,
3224,
275,
334,
7768,
54,
1583,
14,
1462,
14,
1459,
360,
3627,
63,
344,
358,
288,
1275,
10898,
8,
835,
29,
2353,
360,
3627,
1333,
288,
1275,
1541,
8,
14317,
4022,
17,
9,
288,
1275,
2911,
8,
4509,
2968,
5390,
8,
3966,
9,
2458,
83,
995,
1862,
1524,
602,
14,
8136,
342,
2459,
339,
6714,
275,
15500,
873,
63,
7882,
63,
16660,
14,
31719,
8,
589,
1524,
4604,
12,
283,
1222,
63,
16660,
63,
384,
1105,
881,
367,
3728,
315,
22180,
8,
384,
12,
5198,
1874,
272,
8495,
1084,
8,
1086,
680,
4998,
63,
4146,
342,
339,
6714,
275,
15500,
873,
63,
7882,
63,
16660,
14,
31719,
8,
589,
1524,
4604,
12,
283,
1222,
63,
16660,
63,
2110,
1105,
881,
367,
3728,
315,
22180,
8,
2110,
12,
5198,
1874,
272,
8495,
1084,
8,
1086,
680,
4998,
63,
4146,
342,
421,
199,
32,
1765,
8,
1866,
63,
3097,
534,
1046,
15,
77,
358,
199,
318,
485,
873,
63,
7882,
63,
16660,
8,
576,
12,
5672,
12,
1011,
829,
304,
272,
2120,
63,
793,
14,
815,
480,
9722,
83,
19437,
83,
61,
4949,
9239,
5055,
7,
373,
6510,
23576,
2122,
450,
334,
2116,
822,
8,
576,
395,
485,
873,
63,
7882,
63,
16660,
14,
1866,
63,
3097,
430,
272,
3920,
275,
1950,
14,
3937,
342,
272,
367,
2729,
315,
666,
26,
267,
1894,
275,
661,
27010,
12872,
5020,
63,
7882,
8,
64,
602,
3559,
658,
354,
3559,
283,
1467,
26144,
3627,
63,
344,
3559,
658,
835,
10522,
13992,
4366,
83,
12,
450,
83,
12,
450,
83,
12,
450,
83,
5942,
267,
299,
275,
359,
602,
14,
8136,
1062,
5672,
12,
1467,
2729,
459,
3627,
63,
344,
995,
2729,
459,
835,
6538,
267,
3920,
14,
2526,
8,
81,
12,
299,
9,
272,
6008,
14,
3543,
63,
18447,
63,
11122,
342,
421,
199,
3,
3254,
26,
2813,
642,
5403,
1315,
11020,
265,
73,
655,
509,
823,
5340,
85,
458,
14,
199,
32,
14829,
6920,
14,
2683,
199,
318,
5055,
63,
525,
63,
2482,
85,
458,
837,
272,
408,
39,
1912,
5340,
85,
458,
370,
1263,
8889,
2003,
5055,
1041,
272,
327,
7529,
1133,
12943,
314,
6042,
1434,
14,
272,
18003,
423,
2024,
14,
362,
63,
698,
360,
5540,
1959,
2495,
63,
2131,
275,
756,
272,
1894,
275,
18003,
14,
1462,
14,
1541,
8,
5464,
29,
403,
9,
272,
2762,
275,
1894,
14,
1459,
63,
513,
360,
344,
297,
6829,
29,
549,
9,
272,
2120,
63,
793,
14,
815,
3508,
83,
5055,
1928,
1561,
7,
450,
822,
8,
1580,
430,
272,
1390,
63,
1267,
275,
18003,
423,
2024,
14,
362,
63,
698,
360,
5464,
1959,
988,
63,
1267,
272,
12703,
275,
7975,
14,
835,
342,
272,
327,
25246,
652,
880,
781,
2793,
1133,
886,
27791,
9212,
14,
272,
367,
3728,
315,
22180,
8,
1580,
12,
9601,
304,
267,
367,
286,
315,
1894,
14,
889,
63,
1637,
1252,
1541,
8,
344,
363,
262,
29,
4604,
304,
288,
286,
14,
5464,
275,
286,
14,
18544,
503,
29864,
8,
67,
14,
354,
18562,
988,
63,
1267,
61,
288,
340,
440,
286,
14,
5464,
26,
355,
286,
14,
5464,
275,
283,
3627,
7,
288,
286,
14,
2117,
8,
3990,
63,
873,
29,
549,
9,
288,
2120,
63,
793,
14,
815,
8,
85,
5956,
83,
14,
450,
83,
9265,
450,
83,
7,
450,
334,
2184,
8,
6507,
395,
286,
14,
354,
12,
286,
14,
5464,
430,
421,
199,
32,
14829,
6920,
14,
2683,
199,
318,
9058,
63
] |
[
2197,
492,
1434,
12,
6871,
199,
646,
7975,
199,
199,
504,
1639,
14,
697,
492,
1950,
12,
6008,
199,
504,
1639,
14,
697,
14,
992,
492,
14826,
199,
199,
646,
2863,
1068,
14,
793,
199,
504,
22748,
14,
1765,
14,
2193,
492,
8495,
1084,
199,
199,
646,
30235,
199,
504,
30235,
14,
23593,
492,
2120,
199,
504,
30235,
14,
1208,
492,
22180,
12,
29864,
199,
504,
10981,
30412,
265,
14,
992,
492,
334,
7768,
12,
29988,
6867,
7768,
12,
18003,
54,
1583,
12,
2892,
18003,
13978,
281,
9,
199,
646,
19818,
6920,
199,
199,
1765,
63,
793,
275,
2863,
1068,
14,
793,
14,
5572,
360,
90,
14,
1765,
358,
421,
199,
32,
14829,
6920,
14,
2683,
199,
318,
1678,
63,
7882,
63,
24962,
837,
272,
408,
4152,
5055,
22148,
83,
23576,
1041,
339,
366,
275,
334,
7768,
13978,
281,
14,
1462,
14,
1459,
360,
3627,
63,
344,
358,
268,
1275,
10898,
8,
835,
29,
2353,
360,
3627,
1333,
268,
1275,
2911,
8,
4509,
2968,
5390,
8,
3966,
9,
2458,
83,
995,
1862,
1524,
602,
14,
8136,
342,
2459,
339,
6714,
275,
15500,
873,
63,
7882,
63,
24962,
14,
31719,
8,
589,
1524,
4604,
566,
881,
367,
3728,
315,
22180,
8,
68,
12,
5198,
1874,
272,
8495,
1084,
8,
1086,
680,
4998,
63,
4146,
342,
421,
199,
32,
1765,
8,
1866,
63,
3097,
534,
1046,
15,
77,
358,
199,
318,
485,
873,
63,
7882,
63,
24962,
8,
576,
12,
1011,
829,
304,
272,
2120,
63,
793,
14,
815,
480,
9722,
83,
19437,
83,
61,
4949,
9239,
5055,
7,
22148,
83,
23576,
2122,
450,
334,
2116,
822,
8,
576,
395,
485,
873,
63,
7882,
63,
24962,
14,
1866,
63,
3097,
430,
272,
3920,
275,
1950,
14,
3937,
342,
272,
11168,
275,
1434,
14,
8136,
342,
272,
367,
2729,
315,
666,
26,
267,
1894,
275,
408,
27010,
12872,
490,
5020,
63,
7882,
8,
64,
602,
3559,
658,
354,
3559,
658,
3627,
63,
344,
3559,
658,
835,
10522,
355,
13992,
490,
4366,
83,
12,
450,
83,
12,
450,
83,
12,
450,
83,
9471,
267,
299,
275,
359,
8136,
12,
283,
1222,
63,
24962,
297,
2729,
459,
3627,
63,
344,
995,
2729,
459,
835,
6538,
267,
3920,
14,
2526,
8,
81,
12,
299,
9,
272,
6008,
14,
3543,
63,
18447,
63,
11122,
342,
421,
199,
32,
14829,
6920,
14,
2683,
199,
318,
1678,
63,
7882,
63,
16660,
837,
272,
408,
4152,
3245,
1159,
373,
6510,
1041,
339,
1536,
275,
334,
7768,
54,
1583,
14,
1462,
14,
1459,
360,
3627,
63,
344,
358,
881,
1275,
10898,
8,
835,
29,
2353,
360,
3627,
1333,
881,
1275,
1541,
8,
14317,
29,
17,
9,
881,
1275,
2911,
8,
4509,
2968,
5390,
8,
3966,
9,
2458,
83,
995,
1862,
1524,
602,
14,
8136,
342,
2459,
339,
3224,
275,
334,
7768,
54,
1583,
14,
1462,
14,
1459,
360,
3627,
63,
344,
358,
288,
1275,
10898,
8,
835,
29,
2353,
360,
3627,
1333,
288,
1275,
1541,
8,
14317,
4022,
17,
9,
288,
1275,
2911,
8,
4509,
2968,
5390,
8,
3966,
9,
2458,
83,
995,
1862,
1524,
602,
14,
8136,
342,
2459,
339,
6714,
275,
15500,
873,
63,
7882,
63,
16660,
14,
31719,
8,
589,
1524,
4604,
12,
283,
1222,
63,
16660,
63,
384,
1105,
881,
367,
3728,
315,
22180,
8,
384,
12,
5198,
1874,
272,
8495,
1084,
8,
1086,
680,
4998,
63,
4146,
342,
339,
6714,
275,
15500,
873,
63,
7882,
63,
16660,
14,
31719,
8,
589,
1524,
4604,
12,
283,
1222,
63,
16660,
63,
2110,
1105,
881,
367,
3728,
315,
22180,
8,
2110,
12,
5198,
1874,
272,
8495,
1084,
8,
1086,
680,
4998,
63,
4146,
342,
421,
199,
32,
1765,
8,
1866,
63,
3097,
534,
1046,
15,
77,
358,
199,
318,
485,
873,
63,
7882,
63,
16660,
8,
576,
12,
5672,
12,
1011,
829,
304,
272,
2120,
63,
793,
14,
815,
480,
9722,
83,
19437,
83,
61,
4949,
9239,
5055,
7,
373,
6510,
23576,
2122,
450,
334,
2116,
822,
8,
576,
395,
485,
873,
63,
7882,
63,
16660,
14,
1866,
63,
3097,
430,
272,
3920,
275,
1950,
14,
3937,
342,
272,
367,
2729,
315,
666,
26,
267,
1894,
275,
661,
27010,
12872,
5020,
63,
7882,
8,
64,
602,
3559,
658,
354,
3559,
283,
1467,
26144,
3627,
63,
344,
3559,
658,
835,
10522,
13992,
4366,
83,
12,
450,
83,
12,
450,
83,
12,
450,
83,
5942,
267,
299,
275,
359,
602,
14,
8136,
1062,
5672,
12,
1467,
2729,
459,
3627,
63,
344,
995,
2729,
459,
835,
6538,
267,
3920,
14,
2526,
8,
81,
12,
299,
9,
272,
6008,
14,
3543,
63,
18447,
63,
11122,
342,
421,
199,
3,
3254,
26,
2813,
642,
5403,
1315,
11020,
265,
73,
655,
509,
823,
5340,
85,
458,
14,
199,
32,
14829,
6920,
14,
2683,
199,
318,
5055,
63,
525,
63,
2482,
85,
458,
837,
272,
408,
39,
1912,
5340,
85,
458,
370,
1263,
8889,
2003,
5055,
1041,
272,
327,
7529,
1133,
12943,
314,
6042,
1434,
14,
272,
18003,
423,
2024,
14,
362,
63,
698,
360,
5540,
1959,
2495,
63,
2131,
275,
756,
272,
1894,
275,
18003,
14,
1462,
14,
1541,
8,
5464,
29,
403,
9,
272,
2762,
275,
1894,
14,
1459,
63,
513,
360,
344,
297,
6829,
29,
549,
9,
272,
2120,
63,
793,
14,
815,
3508,
83,
5055,
1928,
1561,
7,
450,
822,
8,
1580,
430,
272,
1390,
63,
1267,
275,
18003,
423,
2024,
14,
362,
63,
698,
360,
5464,
1959,
988,
63,
1267,
272,
12703,
275,
7975,
14,
835,
342,
272,
327,
25246,
652,
880,
781,
2793,
1133,
886,
27791,
9212,
14,
272,
367,
3728,
315,
22180,
8,
1580,
12,
9601,
304,
267,
367,
286,
315,
1894,
14,
889,
63,
1637,
1252,
1541,
8,
344,
363,
262,
29,
4604,
304,
288,
286,
14,
5464,
275,
286,
14,
18544,
503,
29864,
8,
67,
14,
354,
18562,
988,
63,
1267,
61,
288,
340,
440,
286,
14,
5464,
26,
355,
286,
14,
5464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
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
wikimedia/operations-debs-python-diamond
|
src/collectors/haproxy/test/testhaproxy.py
|
34
|
2055
|
#!/usr/bin/python
# coding=utf-8
################################################################################
from test import CollectorTestCase
from test import get_collector_config
from test import unittest
from mock import Mock
from mock import patch
from diamond.collector import Collector
from haproxy import HAProxyCollector
################################################################################
class TestHAProxyCollector(CollectorTestCase):
def setUp(self):
config = get_collector_config('HAProxyCollector', {
'interval': 10,
})
self.collector = HAProxyCollector(config, None)
def test_import(self):
self.assertTrue(HAProxyCollector)
@patch.object(Collector, 'publish')
def test_should_work_with_real_data(self, publish_mock):
self.collector.config['ignore_servers'] = False
patch_urlopen = patch('urllib2.urlopen',
Mock(return_value=self.getFixture('stats.csv')))
patch_urlopen.start()
self.collector.collect()
patch_urlopen.stop()
metrics = self.getPickledResults('real_data.pkl')
self.setDocExample(collector=self.collector.__class__.__name__,
metrics=metrics,
defaultpath=self.collector.config['path'])
self.assertPublishedMany(publish_mock, metrics)
@patch.object(Collector, 'publish')
def test_should_work_with_real_data_and_ignore_servers(self, publish_mock):
self.collector.config['ignore_servers'] = True
patch_urlopen = patch('urllib2.urlopen',
Mock(return_value=self.getFixture('stats.csv')))
patch_urlopen.start()
self.collector.collect()
patch_urlopen.stop()
metrics = self.getPickledResults('real_data_ignore_servers.pkl')
self.assertPublishedMany(publish_mock, metrics)
################################################################################
if __name__ == "__main__":
unittest.main()
|
mit
|
[
3381,
2647,
15,
1393,
15,
1548,
199,
3,
2803,
29,
1624,
13,
24,
199,
13289,
199,
199,
504,
511,
492,
3626,
3283,
1746,
199,
504,
511,
492,
664,
63,
10946,
63,
888,
199,
504,
511,
492,
2882,
199,
504,
1683,
492,
4420,
199,
504,
1683,
492,
3371,
199,
199,
504,
487,
24940,
14,
10946,
492,
3626,
3283,
199,
504,
394,
30204,
1702,
492,
16100,
4936,
12852,
199,
199,
13289,
421,
199,
533,
1379,
6294,
4936,
12852,
8,
12852,
1746,
304,
272,
347,
3613,
8,
277,
304,
267,
1101,
275,
664,
63,
10946,
63,
888,
360,
6294,
4936,
12852,
297,
469,
288,
283,
4284,
356,
1616,
12,
267,
3828,
398,
291,
14,
10946,
275,
16100,
4936,
12852,
8,
888,
12,
488,
9,
339,
347,
511,
63,
646,
8,
277,
304,
267,
291,
14,
1815,
8,
6294,
4936,
12852,
9,
339,
768,
2068,
14,
785,
8,
12852,
12,
283,
4763,
358,
272,
347,
511,
63,
5626,
63,
800,
63,
1045,
63,
3093,
63,
576,
8,
277,
12,
2780,
63,
1805,
304,
267,
291,
14,
10946,
14,
888,
459,
4247,
63,
5871,
418,
275,
756,
398,
3371,
63,
10890,
275,
3371,
360,
4078,
18,
14,
10890,
297,
2892,
4420,
8,
1107,
63,
585,
29,
277,
14,
362,
12812,
360,
3200,
14,
4737,
7058,
398,
3371,
63,
10890,
14,
928,
342,
267,
291,
14,
10946,
14,
7112,
342,
267,
3371,
63,
10890,
14,
2379,
342,
398,
7186,
275,
291,
14,
362,
8587,
1146,
6579,
360,
3093,
63,
576,
14,
23947,
358,
398,
291,
14,
409,
3768,
9846,
8,
10946,
29,
277,
14,
10946,
855,
533,
4914,
354,
3108,
2574,
7186,
29,
6759,
12,
2574,
849,
515,
29,
277,
14,
10946,
14,
888,
459,
515,
1105,
267,
291,
14,
479,
27862,
4089,
8,
4763,
63,
1805,
12,
7186,
9,
339,
768,
2068,
14,
785,
8,
12852,
12,
283,
4763,
358,
272,
347,
511,
63,
5626,
63,
800,
63,
1045,
63,
3093,
63,
576,
63,
460,
63,
4247,
63,
5871,
8,
277,
12,
2780,
63,
1805,
304,
267,
291,
14,
10946,
14,
888,
459,
4247,
63,
5871,
418,
275,
715,
398,
3371,
63,
10890,
275,
3371,
360,
4078,
18,
14,
10890,
297,
2892,
4420,
8,
1107,
63,
585,
29,
277,
14,
362,
12812,
360,
3200,
14,
4737,
7058,
398,
3371,
63,
10890,
14,
928,
342,
267,
291,
14,
10946,
14,
7112,
342,
267,
3371,
63,
10890,
14,
2379,
342,
398,
7186,
275,
291,
14,
362,
8587,
1146,
6579,
360,
3093,
63,
576,
63,
4247,
63,
5871,
14,
23947,
358,
398,
291,
14,
479,
27862,
4089,
8,
4763,
63,
1805,
12,
7186,
9,
199,
199,
13289,
199,
692,
636,
354,
363,
508,
4396,
973,
5727,
272,
2882,
14,
973,
342,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
2647,
15,
1393,
15,
1548,
199,
3,
2803,
29,
1624,
13,
24,
199,
13289,
199,
199,
504,
511,
492,
3626,
3283,
1746,
199,
504,
511,
492,
664,
63,
10946,
63,
888,
199,
504,
511,
492,
2882,
199,
504,
1683,
492,
4420,
199,
504,
1683,
492,
3371,
199,
199,
504,
487,
24940,
14,
10946,
492,
3626,
3283,
199,
504,
394,
30204,
1702,
492,
16100,
4936,
12852,
199,
199,
13289,
421,
199,
533,
1379,
6294,
4936,
12852,
8,
12852,
1746,
304,
272,
347,
3613,
8,
277,
304,
267,
1101,
275,
664,
63,
10946,
63,
888,
360,
6294,
4936,
12852,
297,
469,
288,
283,
4284,
356,
1616,
12,
267,
3828,
398,
291,
14,
10946,
275,
16100,
4936,
12852,
8,
888,
12,
488,
9,
339,
347,
511,
63,
646,
8,
277,
304,
267,
291,
14,
1815,
8,
6294,
4936,
12852,
9,
339,
768,
2068,
14,
785,
8,
12852,
12,
283,
4763,
358,
272,
347,
511,
63,
5626,
63,
800,
63,
1045,
63,
3093,
63,
576,
8,
277,
12,
2780,
63,
1805,
304,
267,
291,
14,
10946,
14,
888,
459,
4247,
63,
5871,
418,
275,
756,
398,
3371,
63,
10890,
275,
3371,
360,
4078,
18,
14,
10890,
297,
2892,
4420,
8,
1107,
63,
585,
29,
277,
14,
362,
12812,
360,
3200,
14,
4737,
7058,
398,
3371,
63,
10890,
14,
928,
342,
267,
291,
14,
10946,
14,
7112,
342,
267,
3371,
63,
10890,
14,
2379,
342,
398,
7186,
275,
291,
14,
362,
8587,
1146,
6579,
360,
3093,
63,
576,
14,
23947,
358,
398,
291,
14,
409,
3768,
9846,
8,
10946,
29,
277,
14,
10946,
855,
533,
4914,
354,
3108,
2574,
7186,
29,
6759,
12,
2574,
849,
515,
29,
277,
14,
10946,
14,
888,
459,
515,
1105,
267,
291,
14,
479,
27862,
4089,
8,
4763,
63,
1805,
12,
7186,
9,
339,
768,
2068,
14,
785,
8,
12852,
12,
283,
4763,
358,
272,
347,
511,
63,
5626,
63,
800,
63,
1045,
63,
3093,
63,
576,
63,
460,
63,
4247,
63,
5871,
8,
277,
12,
2780,
63,
1805,
304,
267,
291,
14,
10946,
14,
888,
459,
4247,
63,
5871,
418,
275,
715,
398,
3371,
63,
10890,
275,
3371,
360,
4078,
18,
14,
10890,
297,
2892,
4420,
8,
1107,
63,
585,
29,
277,
14,
362,
12812,
360,
3200,
14,
4737,
7058,
398,
3371,
63,
10890,
14,
928,
342,
267,
291,
14,
10946,
14,
7112,
342,
267,
3371,
63,
10890,
14,
2379,
342,
398,
7186,
275,
291,
14,
362,
8587,
1146,
6579,
360,
3093,
63,
576,
63,
4247,
63,
5871,
14,
23947,
358,
398,
291,
14,
479,
27862,
4089,
8,
4763,
63,
1805,
12,
7186,
9,
199,
199,
13289,
199,
692,
636,
354,
363,
508,
4396,
973,
5727,
272,
2882,
14,
973,
342,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
kungfulon/pacman-search
|
submission_autograder.py
|
6
|
9390
|
# submission_autograder.py
# ------------------------
# Licensing Information: You are free to use or extend these projects for
# educational purposes provided that (1) you do not distribute or publish
# solutions, (2) you retain this notice, and (3) you provide clear
# attribution to UC Berkeley, including a link to http://ai.berkeley.edu.
#
# Attribution Information: The Pacman AI projects were developed at UC Berkeley.
# The core projects and autograders were primarily created by John DeNero
# (denero@cs.berkeley.edu) and Dan Klein (klein@cs.berkeley.edu).
# Student side autograding was added by Brad Miller, Nick Hay, and
# Pieter Abbeel (pabbeel@cs.berkeley.edu).
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import print_function
from codecs import open
"""
CS 188 Local Submission Autograder
Written by the CS 188 Staff
==============================================================================
_____ _ _
/ ____| | | |
| (___ | |_ ___ _ __ | |
\___ \| __/ _ \| '_ \| |
____) | || (_) | |_) |_|
|_____/ \__\___/| .__/(_)
| |
|_|
Modifying or tampering with this file is a violation of course policy.
If you're having trouble running the autograder, please contact the staff.
==============================================================================
"""
import bz2, base64
exec(bz2.decompress(base64.b64decode('QlpoOTFBWSZTWc9TWUgAOk1fgHAQfv///3////7////6YBzcOfaRd5kYNx69uwK9tTYSVnbNW8BesDoYHp6AHocjo0PR0oZSvTJUFbVqqg63TRKD2u44O2bAA94SSE0CGTJo0mRknpT2hlR5CNPKep5QHq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w8ScsRhNfP0CEgRlVVwP5JWI6elKouvISoLO0JbC9LA+O3gISBE7BeTSYdXeeaOFclJOUKuk5Aq2gqCFSU0SaIZ0tc3KR81K6zyEJAhhUaB28ETL/dVDNPxMT/sQkCIUkbi9pPioSqKx0SHewXhK3tZxw7HfgOZfT3cs1EnX5U+S8vPzd+7cL9XvE3kMMXD/4u5IpwoSGeprKQA==')))
|
mit
|
[
3,
13071,
63,
2495,
17556,
14,
647,
199,
3,
10652,
518,
199,
3,
491,
530,
25843,
17064,
26,
221,
2047,
787,
2867,
370,
675,
503,
12247,
3520,
11336,
367,
199,
3,
3988,
947,
6279,
12901,
2741,
626,
334,
17,
9,
1265,
886,
440,
11207,
503,
2780,
199,
3,
24886,
12,
334,
18,
9,
1265,
8074,
642,
4245,
12,
436,
334,
19,
9,
1265,
5647,
5436,
199,
3,
737,
15980,
370,
738,
35,
23207,
415,
15515,
12,
5893,
282,
2142,
370,
1455,
921,
5789,
14,
605,
415,
15515,
14,
8654,
14,
199,
3,
221,
199,
3,
2854,
15980,
17064,
26,
710,
510,
645,
1237,
437,
41,
11336,
4898,
477,
27813,
737,
738,
35,
23207,
415,
15515,
14,
199,
3,
710,
6170,
11336,
436,
2599,
926,
7735,
4898,
1979,
30468,
2737,
701,
17815,
1487,
46,
3478,
199,
3,
334,
848,
3478,
32,
1259,
14,
605,
415,
15515,
14,
8654,
9,
436,
24747,
1804,
274,
262,
334,
23572,
262,
32,
1259,
14,
605,
415,
15515,
14,
8654,
680,
199,
3,
17246,
5366,
2599,
16050,
1990,
3483,
701,
699,
9525,
603,
19576,
12,
653,
2000,
869,
1187,
12,
436,
199,
3,
510,
1873,
351,
8351,
1235,
352,
334,
80,
371,
1235,
352,
32,
1259,
14,
605,
415,
15515,
14,
8654,
680,
421,
199,
3381,
2647,
15,
1393,
15,
1813,
2366,
199,
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
199,
504,
636,
2443,
363,
492,
870,
63,
1593,
199,
504,
6010,
492,
1551,
199,
199,
624,
199,
3298,
413,
1299,
10111,
4804,
2250,
9195,
17556,
199,
32329,
701,
314,
17447,
413,
1299,
25910,
199,
199,
5695,
17224,
2043,
636,
8989,
485,
4519,
485,
16421,
1182,
636,
363,
92,
1204,
3322,
1204,
1204,
199,
1204,
334,
8989,
1204,
1204,
63,
31111,
221,
485,
636,
1204,
1204,
523,
971,
8989,
971,
92,
636,
15,
485,
971,
92,
2513,
971,
92,
1204,
523,
636,
3368,
1204,
12208,
334,
4602,
1204,
1204,
4602,
1204,
63,
92,
199,
1204,
4741,
63,
15,
971,
363,
60,
8989,
15,
92,
221,
855,
15,
1547,
9,
326,
1204,
1204,
755,
326,
1204,
63,
92,
755,
199,
199,
18357,
316,
503,
3052,
311,
15663,
543,
642,
570,
365,
282,
1321,
10410,
402,
2518,
4592,
14,
199,
3917,
1265,
3984,
9445,
29616,
3879,
314,
2599,
17556,
12,
8749,
8966,
314,
12622,
14,
199,
5695,
17224,
199,
624,
199,
646,
15055,
18,
12,
1300,
772,
199,
1628,
8,
10582,
18,
14,
14954,
8,
1095,
772,
14,
66,
772,
2708,
360,
49,
76,
555,
1387,
8223,
5035,
58,
16491,
67,
25,
16491,
53,
14993,
11622,
17,
9681,
6294,
49,
13692,
501,
15,
19,
868,
23,
868,
22,
57,
34,
26698,
47,
667,
50,
68,
21,
75,
30644,
88,
1876,
29638,
43,
25,
84,
2099,
4985,
4994,
23471,
24,
34,
397,
2585,
57,
40,
80,
22,
20755,
679,
743,
16,
3311,
16,
79,
26697,
86,
52,
42,
27363,
66,
54,
16672,
71,
2766,
1766,
13368,
18,
85,
1602,
47,
18,
66,
2276,
2635,
24932,
16,
31517,
5691,
16,
77,
50,
75,
1590,
52,
18,
15544,
50,
21,
12874,
48,
1136,
80,
21,
27088,
81,
40,
7096,
8884,
33,
65,
1554,
52,
19229,
49,
775,
53,
89,
596,
15263,
49,
15,
6849,
17,
45,
2099,
2160,
53,
89,
40,
81,
5902,
17,
34,
22,
71,
31723,
1038,
31105,
41,
74,
42,
22,
71,
25,
30545,
5691,
65,
1217,
79,
46,
6151,
33,
1493,
31064,
46,
1976,
75,
37,
72,
528,
90,
53,
74,
16,
74,
17,
40,
81,
69,
13361,
79,
6151,
20805,
2276,
1282,
53,
615,
11888,
12259,
77,
50,
555,
16,
89,
28000,
3635,
33,
879,
33,
65,
33,
16,
89,
26917,
42,
75,
2944,
23559,
7730,
7730,
33,
596,
75,
88,
20958,
17,
31506,
18,
71,
17774,
22,
8199,
40,
7096,
1156,
77,
17,
8225,
58,
16,
34,
25,
87,
11,
67,
1914,
70,
11592,
74,
39,
70,
57,
87,
411,
15,
16,
76,
17,
76,
52,
23,
17395,
25527,
78,
24,
1086,
15969,
1618,
11,
65,
54,
9500,
49,
16567,
2684,
15,
18,
55,
1534,
476,
76,
41,
88,
57,
41,
24278,
18,
31025,
1355,
85,
1046,
57,
1786,
40,
14876,
11,
6341,
78,
81,
14595,
49,
22,
15,
21,
79,
26467,
11,
46,
18,
37,
24,
55,
2279,
54,
8392,
39,
27511,
42,
15,
26074,
5192,
45,
1230,
57,
71,
18974,
55,
42,
12674,
45,
17,
90,
28893,
35,
743,
71,
2760,
75,
22760,
19824,
22,
11754,
53,
22,
371,
42,
18,
21090,
23,
85,
19,
573,
1427,
26880,
85,
22,
77,
56,
23,
24388,
11,
76,
3129,
66,
42,
78,
40,
21,
56,
920,
709,
46,
20,
66,
14634,
3888,
1644,
49,
42,
6849,
75,
17,
50,
15,
52,
25,
54,
16,
70,
44,
20692,
17,
86,
34,
20,
85,
44,
3210,
36,
9290,
18,
51,
1282,
14323,
72,
54,
71,
44,
8223,
24600,
71,
16944,
75,
28063,
18759,
43,
80,
46,
20777,
74,
57,
4213,
66,
39,
17,
66,
23,
67,
15,
80,
56,
16,
82,
58,
5812,
16764,
825,
15,
78,
34,
16,
51,
20,
15140,
85,
56,
9909,
2890,
43,
11412,
21568,
56,
11,
66,
23,
86,
16,
11821,
10213,
2148,
49,
19,
84,
2161,
4564,
72,
42,
6215,
74,
4361,
3263,
79,
24,
2591,
29173,
87,
20,
39,
41,
1721,
43,
26183,
57,
527,
21,
433,
975,
30251,
3143,
31254,
1236,
52,
7530,
20329,
48,
58,
81,
86,
1387,
350,
56,
8804,
6741,
13057,
85,
16,
89,
301,
12674,
76,
17578,
6524,
54,
75,
47,
11,
28841,
1167,
619,
5782,
52,
81,
16608,
5487,
54,
55,
49,
18,
2191,
9500,
79,
38,
25,
27678,
17,
15,
90,
74,
19,
1938,
23406,
81,
43,
76,
6332,
13361,
23,
34,
90,
56,
1518,
1153,
86,
16,
34,
27764,
1194,
78,
37,
77,
50,
16,
88,
10836,
16,
1286,
54,
66,
56,
6495,
1734,
15,
66,
21733,
24,
38,
21,
89,
55,
88,
81,
28267,
331,
49,
18934,
2439,
55,
301,
39,
23,
54,
19,
33,
1710,
49,
42,
17,
69,
17,
18504,
73,
2483,
19360,
33,
1081,
69,
52,
67,
57,
54,
1165,
65,
2483,
79,
280,
3298,
12917,
3624,
58,
50,
17740,
15,
40,
12156,
90,
85,
348,
54,
78,
45,
1590,
78,
6164,
1480,
34,
6215,
84,
21942,
9290,
58,
85
] |
[
13071,
63,
2495,
17556,
14,
647,
199,
3,
10652,
518,
199,
3,
491,
530,
25843,
17064,
26,
221,
2047,
787,
2867,
370,
675,
503,
12247,
3520,
11336,
367,
199,
3,
3988,
947,
6279,
12901,
2741,
626,
334,
17,
9,
1265,
886,
440,
11207,
503,
2780,
199,
3,
24886,
12,
334,
18,
9,
1265,
8074,
642,
4245,
12,
436,
334,
19,
9,
1265,
5647,
5436,
199,
3,
737,
15980,
370,
738,
35,
23207,
415,
15515,
12,
5893,
282,
2142,
370,
1455,
921,
5789,
14,
605,
415,
15515,
14,
8654,
14,
199,
3,
221,
199,
3,
2854,
15980,
17064,
26,
710,
510,
645,
1237,
437,
41,
11336,
4898,
477,
27813,
737,
738,
35,
23207,
415,
15515,
14,
199,
3,
710,
6170,
11336,
436,
2599,
926,
7735,
4898,
1979,
30468,
2737,
701,
17815,
1487,
46,
3478,
199,
3,
334,
848,
3478,
32,
1259,
14,
605,
415,
15515,
14,
8654,
9,
436,
24747,
1804,
274,
262,
334,
23572,
262,
32,
1259,
14,
605,
415,
15515,
14,
8654,
680,
199,
3,
17246,
5366,
2599,
16050,
1990,
3483,
701,
699,
9525,
603,
19576,
12,
653,
2000,
869,
1187,
12,
436,
199,
3,
510,
1873,
351,
8351,
1235,
352,
334,
80,
371,
1235,
352,
32,
1259,
14,
605,
415,
15515,
14,
8654,
680,
421,
199,
3381,
2647,
15,
1393,
15,
1813,
2366,
199,
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
199,
504,
636,
2443,
363,
492,
870,
63,
1593,
199,
504,
6010,
492,
1551,
199,
199,
624,
199,
3298,
413,
1299,
10111,
4804,
2250,
9195,
17556,
199,
32329,
701,
314,
17447,
413,
1299,
25910,
199,
199,
5695,
17224,
2043,
636,
8989,
485,
4519,
485,
16421,
1182,
636,
363,
92,
1204,
3322,
1204,
1204,
199,
1204,
334,
8989,
1204,
1204,
63,
31111,
221,
485,
636,
1204,
1204,
523,
971,
8989,
971,
92,
636,
15,
485,
971,
92,
2513,
971,
92,
1204,
523,
636,
3368,
1204,
12208,
334,
4602,
1204,
1204,
4602,
1204,
63,
92,
199,
1204,
4741,
63,
15,
971,
363,
60,
8989,
15,
92,
221,
855,
15,
1547,
9,
326,
1204,
1204,
755,
326,
1204,
63,
92,
755,
199,
199,
18357,
316,
503,
3052,
311,
15663,
543,
642,
570,
365,
282,
1321,
10410,
402,
2518,
4592,
14,
199,
3917,
1265,
3984,
9445,
29616,
3879,
314,
2599,
17556,
12,
8749,
8966,
314,
12622,
14,
199,
5695,
17224,
199,
624,
199,
646,
15055,
18,
12,
1300,
772,
199,
1628,
8,
10582,
18,
14,
14954,
8,
1095,
772,
14,
66,
772,
2708,
360,
49,
76,
555,
1387,
8223,
5035,
58,
16491,
67,
25,
16491,
53,
14993,
11622,
17,
9681,
6294,
49,
13692,
501,
15,
19,
868,
23,
868,
22,
57,
34,
26698,
47,
667,
50,
68,
21,
75,
30644,
88,
1876,
29638,
43,
25,
84,
2099,
4985,
4994,
23471,
24,
34,
397,
2585,
57,
40,
80,
22,
20755,
679,
743,
16,
3311,
16,
79,
26697,
86,
52,
42,
27363,
66,
54,
16672,
71,
2766,
1766,
13368,
18,
85,
1602,
47,
18,
66,
2276,
2635,
24932,
16,
31517,
5691,
16,
77,
50,
75,
1590,
52,
18,
15544,
50,
21,
12874,
48,
1136,
80,
21,
27088,
81,
40,
7096,
8884,
33,
65,
1554,
52,
19229,
49,
775,
53,
89,
596,
15263,
49,
15,
6849,
17,
45,
2099,
2160,
53,
89,
40,
81,
5902,
17,
34,
22,
71,
31723,
1038,
31105,
41,
74,
42,
22,
71,
25,
30545,
5691,
65,
1217,
79,
46,
6151,
33,
1493,
31064,
46,
1976,
75,
37,
72,
528,
90,
53,
74,
16,
74,
17,
40,
81,
69,
13361,
79,
6151,
20805,
2276,
1282,
53,
615,
11888,
12259,
77,
50,
555,
16,
89,
28000,
3635,
33,
879,
33,
65,
33,
16,
89,
26917,
42,
75,
2944,
23559,
7730,
7730,
33,
596,
75,
88,
20958,
17,
31506,
18,
71,
17774,
22,
8199,
40,
7096,
1156,
77,
17,
8225,
58,
16,
34,
25,
87,
11,
67,
1914,
70,
11592,
74,
39,
70,
57,
87,
411,
15,
16,
76,
17,
76,
52,
23,
17395,
25527,
78,
24,
1086,
15969,
1618,
11,
65,
54,
9500,
49,
16567,
2684,
15,
18,
55,
1534,
476,
76,
41,
88,
57,
41,
24278,
18,
31025,
1355,
85,
1046,
57,
1786,
40,
14876,
11,
6341,
78,
81,
14595,
49,
22,
15,
21,
79,
26467,
11,
46,
18,
37,
24,
55,
2279,
54,
8392,
39,
27511,
42,
15,
26074,
5192,
45,
1230,
57,
71,
18974,
55,
42,
12674,
45,
17,
90,
28893,
35,
743,
71,
2760,
75,
22760,
19824,
22,
11754,
53,
22,
371,
42,
18,
21090,
23,
85,
19,
573,
1427,
26880,
85,
22,
77,
56,
23,
24388,
11,
76,
3129,
66,
42,
78,
40,
21,
56,
920,
709,
46,
20,
66,
14634,
3888,
1644,
49,
42,
6849,
75,
17,
50,
15,
52,
25,
54,
16,
70,
44,
20692,
17,
86,
34,
20,
85,
44,
3210,
36,
9290,
18,
51,
1282,
14323,
72,
54,
71,
44,
8223,
24600,
71,
16944,
75,
28063,
18759,
43,
80,
46,
20777,
74,
57,
4213,
66,
39,
17,
66,
23,
67,
15,
80,
56,
16,
82,
58,
5812,
16764,
825,
15,
78,
34,
16,
51,
20,
15140,
85,
56,
9909,
2890,
43,
11412,
21568,
56,
11,
66,
23,
86,
16,
11821,
10213,
2148,
49,
19,
84,
2161,
4564,
72,
42,
6215,
74,
4361,
3263,
79,
24,
2591,
29173,
87,
20,
39,
41,
1721,
43,
26183,
57,
527,
21,
433,
975,
30251,
3143,
31254,
1236,
52,
7530,
20329,
48,
58,
81,
86,
1387,
350,
56,
8804,
6741,
13057,
85,
16,
89,
301,
12674,
76,
17578,
6524,
54,
75,
47,
11,
28841,
1167,
619,
5782,
52,
81,
16608,
5487,
54,
55,
49,
18,
2191,
9500,
79,
38,
25,
27678,
17,
15,
90,
74,
19,
1938,
23406,
81,
43,
76,
6332,
13361,
23,
34,
90,
56,
1518,
1153,
86,
16,
34,
27764,
1194,
78,
37,
77,
50,
16,
88,
10836,
16,
1286,
54,
66,
56,
6495,
1734,
15,
66,
21733,
24,
38,
21,
89,
55,
88,
81,
28267,
331,
49,
18934,
2439,
55,
301,
39,
23,
54,
19,
33,
1710,
49,
42,
17,
69,
17,
18504,
73,
2483,
19360,
33,
1081,
69,
52,
67,
57,
54,
1165,
65,
2483,
79,
280,
3298,
12917,
3624,
58,
50,
17740,
15,
40,
12156,
90,
85,
348,
54,
78,
45,
1590,
78,
6164,
1480,
34,
6215,
84,
21942,
9290,
58,
85,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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/bin/env python2.6
# coding: utf-8
#
# Software License Agreement (GPLv2 License)
#
# Copyright (c) 2012 TheCorpora SL
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2 of
# the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301, USA.
#
# Authors: Miguel Angel Julian <miguel.julian@openqbo.com>;
# Daniel Cuadrado <daniel.cuadrado@openqbo.com>;
# Arturo Bajuelos <arturo@openqbo.com>;
# Sergio Merino <s.merino@openqbo.com>;
import cherrypy
import os
import glob
from mako.template import Template
from tabsClass import TabClass
import rospy
import subprocess
import os
import signal
import roslib; roslib.load_manifest('qbo_webi')
from qbo_video_record.srv import *
class RecorderManager(TabClass):
def __init__(self,language):
self.language = language
self.htmlTemplate = Template(filename='recorder/templates/recorderTemplate.html')
self.jsTemplate = Template(filename='recorder/templates/recorderTemplate.js')
self.processname = 'qbo_video_record'
self.videosDir=roslib.packages.get_pkg_dir("qbo_webi")+"/src/recorder/videos/";
def get_videos(self):
videoFiles=[]
for fname in glob.glob(self.videosDir+"*.ogv"):
splitdir=fname.split("/")
videoFiles.append(splitdir[10])
videoFiles.sort()
return videoFiles
@cherrypy.expose
def video_list_html(self):
videos=self.get_videos()
index=0
html='<ol id="selectable" class="ui-selectable">'
test=""
for video in videos:
#html=html+'<li id="element'+str(index)+'" class="ui-widget-content ui-selectee" name="/recorder/videos/'+video+'" > <table style="width:100%;"><tr> <td style="width: 15px;" > </td> <td style="width: 215px;"> <p style="width:215px; margin:0; word-wrap:break-word; overflow: hidden;height: 20px;line-height: 20px; ">'+video+' </p> </td> <td onClick="deleteVideo(\''+video+'\');"> <div style="float:right;width:16px;height:16px;" class="BasuraIcon" ></div> </td> </tr> </table> </li>'
html=html+'<li class="ui-state-default" onclick="playVideo(\'/recorder/videos/'+video+'\')" id="'+video+'"> <table style="width:100%;"><tr> <td style="width: 15px;" > </td> <td style="width: 215px;"> <p style="width:215px; margin:0; word-wrap:break-word; overflow: hidden;height: 20px;line-height: 20px; ">'+video+' </p> </td> <td> <div onclick="deleteVideo(\''+video+'\')" style="float:right;" class="ui-icon ui-icon-trash delete-buttons" ></div> </td> </tr> </table> </li> '
index=index+1
html=html+"</ol>"+test
return html
@cherrypy.expose
def status(self):
rospy.wait_for_service('/qbo_video_record/status')
try:
status = rospy.ServiceProxy('/qbo_video_record/status', StatusRecord)
resStatus = status()
except rospy.ServiceException, e:
print "Service call failed: %s"%e
return str(resStatus.status)
@cherrypy.expose
def record(self):
status=self.status()
if (status=="0"):
rospy.wait_for_service('/qbo_video_record/start')
start=rospy.ServiceProxy('/qbo_video_record/start', StartRecord)
start("/stereo/left/image_raw",self.videosDir)
return "1"
else:
rospy.wait_for_service('/qbo_video_record/stop')
stop=rospy.ServiceProxy('/qbo_video_record/stop', StopRecord)
stop()
return "0"
@cherrypy.expose
def deleteVideo(self, videoName):
print "-------------------"
os.remove(self.videosDir+videoName)
print "--------------2"
return self.video_list_html()
@cherrypy.expose
def recorderJs(self, **params):
return self.jsTemplate.render(language=self.language)
@cherrypy.expose
def index(self):
return self.htmlTemplate.render(language=self.language)
|
lgpl-2.1
|
[
3381,
2647,
15,
1393,
15,
1813,
2366,
18,
14,
22,
199,
3,
2803,
26,
2774,
13,
24,
199,
3,
199,
3,
2290,
844,
28629,
334,
28863,
18,
844,
9,
199,
3,
199,
3,
1898,
334,
67,
9,
6029,
710,
8380,
7314,
65,
428,
44,
199,
3,
199,
3,
961,
2240,
365,
2867,
2032,
27,
1265,
883,
3604,
652,
436,
15,
269,
221,
199,
3,
2811,
652,
1334,
314,
2895,
402,
314,
1664,
1696,
1684,
844,
465,
221,
199,
3,
3267,
701,
314,
2868,
2290,
2752,
27,
1902,
1015,
499,
402,
199,
3,
314,
844,
12,
503,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
961,
2240,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
221,
199,
3,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
199,
3,
1666,
314,
1664,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
1696,
1684,
844,
221,
199,
3,
3180,
543,
642,
2240,
27,
340,
440,
12,
2218,
370,
314,
2868,
2290,
221,
199,
3,
2752,
12,
3277,
2020,
8026,
11236,
14259,
12,
12066,
11844,
12,
8226,
12,
221,
199,
3,
4828,
11315,
13,
10067,
12,
8217,
14,
199,
3,
199,
3,
6642,
26,
28195,
13086,
1626,
24920,
1603,
28325,
665,
4071,
13086,
14,
74,
28325,
32,
1490,
81,
656,
14,
957,
30,
27,
199,
3,
3515,
24747,
14769,
445,
8346,
345,
1117,
665,
24863,
14769,
14,
67,
8346,
345,
1117,
32,
1490,
81,
656,
14,
957,
30,
27,
199,
3,
3515,
1952,
84,
9129,
699,
9091,
310,
11560,
665,
580,
9129,
32,
1490,
81,
656,
14,
957,
30,
27,
221,
199,
3,
3515,
3739,
71,
2308,
18880,
10175,
665,
83,
14,
2626,
10175,
32,
1490,
81,
656,
14,
957,
30,
27,
199,
199,
646,
13397,
199,
646,
747,
199,
646,
5739,
199,
504,
26834,
14,
1160,
492,
5458,
199,
504,
12187,
2543,
492,
23159,
2543,
199,
646,
21848,
199,
646,
3873,
199,
646,
747,
199,
646,
4673,
199,
646,
882,
83,
773,
27,
882,
83,
773,
14,
912,
63,
6418,
360,
81,
656,
63,
2520,
73,
358,
199,
504,
1894,
656,
63,
3722,
63,
3059,
14,
15165,
492,
627,
199,
199,
533,
799,
16940,
2988,
8,
7690,
2543,
304,
2286,
347,
636,
826,
721,
277,
12,
3671,
304,
267,
291,
14,
3671,
275,
2637,
267,
291,
14,
1360,
4231,
275,
5458,
8,
1501,
534,
27733,
15,
5876,
15,
27733,
4231,
14,
1360,
358,
267,
291,
14,
3596,
4231,
275,
5458,
8,
1501,
534,
27733,
15,
5876,
15,
27733,
4231,
14,
3596,
358,
267,
291,
14,
1412,
354,
275,
283,
81,
656,
63,
3722,
63,
3059,
7,
267,
291,
14,
11418,
3567,
29,
4796,
773,
14,
5154,
14,
362,
63,
4600,
63,
694,
480,
81,
656,
63,
2520,
73,
531,
24792,
2164,
15,
27733,
15,
11418,
6687,
27,
339,
347,
664,
63,
11418,
8,
277,
304,
267,
3991,
5535,
9811,
267,
367,
6748,
315,
5739,
14,
6463,
8,
277,
14,
11418,
3567,
5207,
4856,
974,
86,
2349,
288,
3715,
694,
29,
5252,
14,
1294,
19031,
288,
3991,
5535,
14,
740,
8,
1294,
694,
59,
709,
566,
267,
3991,
5535,
14,
3191,
342,
267,
372,
3991,
5535,
339,
768,
23438,
14,
20586,
272,
347,
3991,
63,
513,
63,
1360,
8,
277,
304,
267,
22010,
29,
277,
14,
362,
63,
11418,
342,
267,
1478,
29,
16,
267,
3517,
15829,
393,
1305,
628,
18837,
2,
1021,
628,
1907,
13,
18837,
15603,
267,
511,
9287,
267,
367,
3991,
315,
22010,
26,
288,
327,
1360,
29,
1360,
4786,
28,
317,
1305,
628,
2108,
6828,
495,
8,
1080,
6393,
4065,
1021,
628,
1907,
13,
3440,
13,
1317,
8574,
13,
261,
10251,
15557,
2,
536,
9555,
27733,
15,
11418,
19047,
3722,
11,
4065,
690,
258,
665,
1224,
3449,
628,
2063,
26,
1960,
5,
27,
8186,
454,
30,
221,
665,
2076,
3449,
628,
2063,
26,
4114,
5326,
9426,
690,
3068,
2076,
30,
665,
2076,
3449,
628,
2063,
26,
28436,
5326,
31328,
665,
80,
3449,
628,
2063,
26,
7842,
5326,
27,
11042,
26,
16,
27,
4349,
13,
3823,
26,
4785,
13,
1027,
27,
15784,
26,
8752,
27,
3333,
26,
3388,
5326,
27,
604,
13,
3333,
26,
3388,
5326,
27,
221,
298,
3524,
11,
3722,
4786,
3068,
80,
30,
257,
3068,
2076,
30,
665,
2076,
641,
12040,
628,
1807,
9166,
2961,
891,
11,
3722,
19192,
11339,
1743,
221,
665,
3015,
3449,
628,
1609,
26,
1019,
27,
2063,
26,
975,
5326,
27,
3333,
26,
975,
5326,
9426,
1021,
628,
34,
305,
12417,
8954,
2,
690,
1108,
3015,
30,
257,
3068,
2076,
30,
259,
3068,
454,
30,
3515,
3068,
1224,
30,
258,
3068,
317,
3524,
22919,
3517,
29,
1360,
4786,
28,
317,
1021,
628,
1907,
13,
929,
13,
885,
2,
31156,
628,
2802,
9166,
2961,
9807,
27733,
15,
11418,
19047,
3722,
19192,
19124,
1305,
628,
6828,
3722,
4786,
1743,
221,
665,
1224,
3449,
628,
2063,
26,
1960,
5,
27,
8186,
454,
30,
221,
665,
2076,
3449,
628,
2063,
26,
4114,
5326,
9426,
690,
3068,
2076,
30,
665,
2076,
3449,
628,
2063,
26,
28436,
5326,
31328,
665,
80,
3449,
628,
2063,
26,
7842,
5326,
27,
11042,
26,
16,
27,
4349,
13,
3823,
26,
4785,
13,
1027,
27,
15784,
26,
8752,
27,
3333,
26,
3388,
5326,
27,
604,
13,
3333,
26,
3388,
5326,
27,
221,
298,
3524,
11,
3722,
4786,
3068,
80,
30,
257,
3068,
2076,
30,
665,
2076,
30,
665,
3015,
31156,
628,
1807,
9166,
2961,
891,
11,
3722,
19192,
19124,
3449,
628,
1609,
26,
1019,
9426,
1021,
628,
1907,
13,
4677,
8574,
13,
4677,
13,
28272,
3145,
13,
15687,
2,
690,
1108,
3015,
30,
257,
3068,
2076,
30,
259,
3068,
454,
30,
3515,
3068,
1224,
30,
3777,
3068,
317,
30,
283,
953,
1478,
29,
1080,
11,
17,
398,
3517,
29,
1360,
5207,
1108,
393,
4335,
11,
396,
4960,
372,
3517,
339,
768,
23438,
14,
20586,
272,
347,
2004,
8,
277,
304,
267,
21848,
14,
2573,
63,
509,
63,
1364,
2336,
81,
656,
63,
3722,
63,
3059,
15,
1205,
358,
267,
862,
26,
288,
2004,
275,
21848,
14,
3167,
4936,
2336,
81,
656,
63,
3722,
63,
3059,
15
] |
[
2647,
15,
1393,
15,
1813,
2366,
18,
14,
22,
199,
3,
2803,
26,
2774,
13,
24,
199,
3,
199,
3,
2290,
844,
28629,
334,
28863,
18,
844,
9,
199,
3,
199,
3,
1898,
334,
67,
9,
6029,
710,
8380,
7314,
65,
428,
44,
199,
3,
199,
3,
961,
2240,
365,
2867,
2032,
27,
1265,
883,
3604,
652,
436,
15,
269,
221,
199,
3,
2811,
652,
1334,
314,
2895,
402,
314,
1664,
1696,
1684,
844,
465,
221,
199,
3,
3267,
701,
314,
2868,
2290,
2752,
27,
1902,
1015,
499,
402,
199,
3,
314,
844,
12,
503,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
961,
2240,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
221,
199,
3,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
199,
3,
1666,
314,
1664,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
1696,
1684,
844,
221,
199,
3,
3180,
543,
642,
2240,
27,
340,
440,
12,
2218,
370,
314,
2868,
2290,
221,
199,
3,
2752,
12,
3277,
2020,
8026,
11236,
14259,
12,
12066,
11844,
12,
8226,
12,
221,
199,
3,
4828,
11315,
13,
10067,
12,
8217,
14,
199,
3,
199,
3,
6642,
26,
28195,
13086,
1626,
24920,
1603,
28325,
665,
4071,
13086,
14,
74,
28325,
32,
1490,
81,
656,
14,
957,
30,
27,
199,
3,
3515,
24747,
14769,
445,
8346,
345,
1117,
665,
24863,
14769,
14,
67,
8346,
345,
1117,
32,
1490,
81,
656,
14,
957,
30,
27,
199,
3,
3515,
1952,
84,
9129,
699,
9091,
310,
11560,
665,
580,
9129,
32,
1490,
81,
656,
14,
957,
30,
27,
221,
199,
3,
3515,
3739,
71,
2308,
18880,
10175,
665,
83,
14,
2626,
10175,
32,
1490,
81,
656,
14,
957,
30,
27,
199,
199,
646,
13397,
199,
646,
747,
199,
646,
5739,
199,
504,
26834,
14,
1160,
492,
5458,
199,
504,
12187,
2543,
492,
23159,
2543,
199,
646,
21848,
199,
646,
3873,
199,
646,
747,
199,
646,
4673,
199,
646,
882,
83,
773,
27,
882,
83,
773,
14,
912,
63,
6418,
360,
81,
656,
63,
2520,
73,
358,
199,
504,
1894,
656,
63,
3722,
63,
3059,
14,
15165,
492,
627,
199,
199,
533,
799,
16940,
2988,
8,
7690,
2543,
304,
2286,
347,
636,
826,
721,
277,
12,
3671,
304,
267,
291,
14,
3671,
275,
2637,
267,
291,
14,
1360,
4231,
275,
5458,
8,
1501,
534,
27733,
15,
5876,
15,
27733,
4231,
14,
1360,
358,
267,
291,
14,
3596,
4231,
275,
5458,
8,
1501,
534,
27733,
15,
5876,
15,
27733,
4231,
14,
3596,
358,
267,
291,
14,
1412,
354,
275,
283,
81,
656,
63,
3722,
63,
3059,
7,
267,
291,
14,
11418,
3567,
29,
4796,
773,
14,
5154,
14,
362,
63,
4600,
63,
694,
480,
81,
656,
63,
2520,
73,
531,
24792,
2164,
15,
27733,
15,
11418,
6687,
27,
339,
347,
664,
63,
11418,
8,
277,
304,
267,
3991,
5535,
9811,
267,
367,
6748,
315,
5739,
14,
6463,
8,
277,
14,
11418,
3567,
5207,
4856,
974,
86,
2349,
288,
3715,
694,
29,
5252,
14,
1294,
19031,
288,
3991,
5535,
14,
740,
8,
1294,
694,
59,
709,
566,
267,
3991,
5535,
14,
3191,
342,
267,
372,
3991,
5535,
339,
768,
23438,
14,
20586,
272,
347,
3991,
63,
513,
63,
1360,
8,
277,
304,
267,
22010,
29,
277,
14,
362,
63,
11418,
342,
267,
1478,
29,
16,
267,
3517,
15829,
393,
1305,
628,
18837,
2,
1021,
628,
1907,
13,
18837,
15603,
267,
511,
9287,
267,
367,
3991,
315,
22010,
26,
288,
327,
1360,
29,
1360,
4786,
28,
317,
1305,
628,
2108,
6828,
495,
8,
1080,
6393,
4065,
1021,
628,
1907,
13,
3440,
13,
1317,
8574,
13,
261,
10251,
15557,
2,
536,
9555,
27733,
15,
11418,
19047,
3722,
11,
4065,
690,
258,
665,
1224,
3449,
628,
2063,
26,
1960,
5,
27,
8186,
454,
30,
221,
665,
2076,
3449,
628,
2063,
26,
4114,
5326,
9426,
690,
3068,
2076,
30,
665,
2076,
3449,
628,
2063,
26,
28436,
5326,
31328,
665,
80,
3449,
628,
2063,
26,
7842,
5326,
27,
11042,
26,
16,
27,
4349,
13,
3823,
26,
4785,
13,
1027,
27,
15784,
26,
8752,
27,
3333,
26,
3388,
5326,
27,
604,
13,
3333,
26,
3388,
5326,
27,
221,
298,
3524,
11,
3722,
4786,
3068,
80,
30,
257,
3068,
2076,
30,
665,
2076,
641,
12040,
628,
1807,
9166,
2961,
891,
11,
3722,
19192,
11339,
1743,
221,
665,
3015,
3449,
628,
1609,
26,
1019,
27,
2063,
26,
975,
5326,
27,
3333,
26,
975,
5326,
9426,
1021,
628,
34,
305,
12417,
8954,
2,
690,
1108,
3015,
30,
257,
3068,
2076,
30,
259,
3068,
454,
30,
3515,
3068,
1224,
30,
258,
3068,
317,
3524,
22919,
3517,
29,
1360,
4786,
28,
317,
1021,
628,
1907,
13,
929,
13,
885,
2,
31156,
628,
2802,
9166,
2961,
9807,
27733,
15,
11418,
19047,
3722,
19192,
19124,
1305,
628,
6828,
3722,
4786,
1743,
221,
665,
1224,
3449,
628,
2063,
26,
1960,
5,
27,
8186,
454,
30,
221,
665,
2076,
3449,
628,
2063,
26,
4114,
5326,
9426,
690,
3068,
2076,
30,
665,
2076,
3449,
628,
2063,
26,
28436,
5326,
31328,
665,
80,
3449,
628,
2063,
26,
7842,
5326,
27,
11042,
26,
16,
27,
4349,
13,
3823,
26,
4785,
13,
1027,
27,
15784,
26,
8752,
27,
3333,
26,
3388,
5326,
27,
604,
13,
3333,
26,
3388,
5326,
27,
221,
298,
3524,
11,
3722,
4786,
3068,
80,
30,
257,
3068,
2076,
30,
665,
2076,
30,
665,
3015,
31156,
628,
1807,
9166,
2961,
891,
11,
3722,
19192,
19124,
3449,
628,
1609,
26,
1019,
9426,
1021,
628,
1907,
13,
4677,
8574,
13,
4677,
13,
28272,
3145,
13,
15687,
2,
690,
1108,
3015,
30,
257,
3068,
2076,
30,
259,
3068,
454,
30,
3515,
3068,
1224,
30,
3777,
3068,
317,
30,
283,
953,
1478,
29,
1080,
11,
17,
398,
3517,
29,
1360,
5207,
1108,
393,
4335,
11,
396,
4960,
372,
3517,
339,
768,
23438,
14,
20586,
272,
347,
2004,
8,
277,
304,
267,
21848,
14,
2573,
63,
509,
63,
1364,
2336,
81,
656,
63,
3722,
63,
3059,
15,
1205,
358,
267,
862,
26,
288,
2004,
275,
21848,
14,
3167,
4936,
2336,
81,
656,
63,
3722,
63,
3059,
15,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
atacai/server-tools
|
users_ldap_mail/users_ldap_model.py
|
51
|
2783
|
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# This module copyright (C) 2013 Daniel Reis
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from openerp.osv import fields, orm
import logging
_log = logging.getLogger(__name__)
class CompanyLDAP(orm.Model):
_inherit = 'res.company.ldap'
_columns = {
'name_attribute': fields.char(
'Name Attribute', size=64,
help="By default 'cn' is used. "
"For ActiveDirectory you might use 'displayName' instead."),
'mail_attribute': fields.char(
'E-mail attribute', size=64,
help="LDAP attribute to use to retrieve em-mail address."),
}
_defaults = {
'name_attribute': 'cn',
'mail_attribute': 'mail',
}
def get_ldap_dicts(self, cr, ids=None):
"""
Copy of auth_ldap's funtion, changing only the SQL, so that it returns
all fields in the table.
"""
if ids:
id_clause = 'AND id IN (%s)'
args = [tuple(ids)]
else:
id_clause = ''
args = []
cr.execute("""
SELECT *
FROM res_company_ldap
WHERE ldap_server != '' """ + id_clause + """ ORDER BY sequence
""", args)
return cr.dictfetchall()
def map_ldap_attributes(self, cr, uid, conf, login, ldap_entry):
values = super(CompanyLDAP, self).map_ldap_attributes(
cr, uid, conf, login, ldap_entry)
mapping = [
('name', 'name_attribute'),
('email', 'mail_attribute'),
]
for value_key, conf_name in mapping:
try:
if conf[conf_name]:
values[value_key] = ldap_entry[1][conf[conf_name]][0]
except KeyError:
_log.warning('No LDAP attribute "%s" found for login "%s"' % (
conf.get(conf_name), values.get('login')))
return values
|
agpl-3.0
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
4605,
199,
3,
199,
3,
259,
7653,
12,
3232,
5800,
8259,
9274,
199,
3,
259,
961,
859,
4248,
334,
35,
9,
6171,
24747,
14769,
799,
374,
199,
3,
199,
3,
259,
961,
2240,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
259,
652,
1334,
314,
2895,
402,
314,
1664,
4265,
1696,
1684,
844,
465,
199,
3,
259,
3267,
701,
314,
2868,
2290,
2752,
12,
1902,
1015,
650,
402,
314,
199,
3,
259,
844,
12,
503,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
259,
961,
2240,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
259,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
259,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
199,
3,
259,
1664,
4265,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
259,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
4265,
1696,
1684,
844,
199,
3,
259,
3180,
543,
642,
2240,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
3,
199,
4605,
199,
199,
504,
5166,
14,
4795,
492,
1504,
12,
9813,
199,
199,
646,
2050,
199,
63,
793,
275,
2050,
14,
5572,
3460,
354,
3368,
421,
199,
533,
15878,
19534,
8,
1025,
14,
1685,
304,
272,
485,
6486,
275,
283,
470,
14,
4627,
14,
9642,
7,
272,
485,
3406,
275,
469,
267,
283,
354,
63,
3215,
356,
1504,
14,
1560,
8,
288,
283,
985,
3882,
297,
1568,
29,
772,
12,
288,
1720,
628,
2175,
849,
283,
6413,
7,
365,
1202,
14,
298,
326,
298,
1858,
23241,
6231,
1265,
5594,
675,
283,
2918,
985,
7,
3140,
7651,
267,
283,
1198,
63,
3215,
356,
1504,
14,
1560,
8,
288,
283,
37,
13,
1198,
2225,
297,
1568,
29,
772,
12,
288,
1720,
628,
19534,
2225,
370,
675,
370,
8044,
18564,
13,
1198,
2287,
7651,
272,
789,
339,
485,
4322,
275,
469,
267,
283,
354,
63,
3215,
356,
283,
6413,
297,
267,
283,
1198,
63,
3215,
356,
283,
1198,
297,
272,
789,
339,
347,
664,
63,
9642,
63,
7892,
8,
277,
12,
2467,
12,
2762,
29,
403,
304,
267,
408,
267,
11247,
402,
1790,
63,
9642,
1159,
9627,
296,
12,
13729,
1454,
314,
5385,
12,
880,
626,
652,
2529,
267,
1006,
1504,
315,
314,
1817,
14,
267,
408,
267,
340,
2762,
26,
288,
1305,
63,
8501,
275,
283,
3649,
1305,
1621,
4366,
83,
3171,
288,
1249,
275,
359,
2960,
8,
1580,
1874,
267,
587,
26,
288,
1305,
63,
8501,
275,
2125,
288,
1249,
275,
942,
267,
2467,
14,
2526,
4852,
288,
10468,
627,
288,
4442,
522,
63,
4627,
63,
9642,
288,
6038,
13727,
63,
1000,
1137,
2125,
408,
435,
1305,
63,
8501,
435,
408,
16044,
6515,
3414,
267,
10327,
1249,
9,
267,
372,
2467,
14,
807,
10174,
342,
339,
347,
2341,
63,
9642,
63,
2987,
8,
277,
12,
2467,
12,
1747,
12,
3743,
12,
4676,
12,
13727,
63,
2373,
304,
267,
1338,
275,
1613,
8,
16063,
19534,
12,
291,
680,
1130,
63,
9642,
63,
2987,
8,
288,
2467,
12,
1747,
12,
3743,
12,
4676,
12,
13727,
63,
2373,
9,
267,
4412,
275,
359,
288,
661,
354,
297,
283,
354,
63,
3215,
659,
288,
661,
2123,
297,
283,
1198,
63,
3215,
659,
267,
1622,
267,
367,
574,
63,
498,
12,
3743,
63,
354,
315,
4412,
26,
288,
862,
26,
355,
340,
3743,
59,
2190,
63,
354,
2189,
490,
1338,
59,
585,
63,
498,
61,
275,
13727,
63,
2373,
59,
17,
1527,
2190,
59,
2190,
63,
354,
22235,
16,
61,
288,
871,
4067,
26,
355,
485,
793,
14,
3764,
360,
1944,
20717,
2225,
2071,
83,
2,
1911,
367,
4676,
221,
2071,
83,
4507,
450,
334,
490,
3743,
14,
362,
8,
2190,
63,
354,
395,
1338,
14,
362,
360,
2886,
7058,
267,
372,
1338,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
4605,
199,
3,
199,
3,
259,
7653,
12,
3232,
5800,
8259,
9274,
199,
3,
259,
961,
859,
4248,
334,
35,
9,
6171,
24747,
14769,
799,
374,
199,
3,
199,
3,
259,
961,
2240,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
259,
652,
1334,
314,
2895,
402,
314,
1664,
4265,
1696,
1684,
844,
465,
199,
3,
259,
3267,
701,
314,
2868,
2290,
2752,
12,
1902,
1015,
650,
402,
314,
199,
3,
259,
844,
12,
503,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
259,
961,
2240,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
259,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
259,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
199,
3,
259,
1664,
4265,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
259,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
4265,
1696,
1684,
844,
199,
3,
259,
3180,
543,
642,
2240,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
3,
199,
4605,
199,
199,
504,
5166,
14,
4795,
492,
1504,
12,
9813,
199,
199,
646,
2050,
199,
63,
793,
275,
2050,
14,
5572,
3460,
354,
3368,
421,
199,
533,
15878,
19534,
8,
1025,
14,
1685,
304,
272,
485,
6486,
275,
283,
470,
14,
4627,
14,
9642,
7,
272,
485,
3406,
275,
469,
267,
283,
354,
63,
3215,
356,
1504,
14,
1560,
8,
288,
283,
985,
3882,
297,
1568,
29,
772,
12,
288,
1720,
628,
2175,
849,
283,
6413,
7,
365,
1202,
14,
298,
326,
298,
1858,
23241,
6231,
1265,
5594,
675,
283,
2918,
985,
7,
3140,
7651,
267,
283,
1198,
63,
3215,
356,
1504,
14,
1560,
8,
288,
283,
37,
13,
1198,
2225,
297,
1568,
29,
772,
12,
288,
1720,
628,
19534,
2225,
370,
675,
370,
8044,
18564,
13,
1198,
2287,
7651,
272,
789,
339,
485,
4322,
275,
469,
267,
283,
354,
63,
3215,
356,
283,
6413,
297,
267,
283,
1198,
63,
3215,
356,
283,
1198,
297,
272,
789,
339,
347,
664,
63,
9642,
63,
7892,
8,
277,
12,
2467,
12,
2762,
29,
403,
304,
267,
408,
267,
11247,
402,
1790,
63,
9642,
1159,
9627,
296,
12,
13729,
1454,
314,
5385,
12,
880,
626,
652,
2529,
267,
1006,
1504,
315,
314,
1817,
14,
267,
408,
267,
340,
2762,
26,
288,
1305,
63,
8501,
275,
283,
3649,
1305,
1621,
4366,
83,
3171,
288,
1249,
275,
359,
2960,
8,
1580,
1874,
267,
587,
26,
288,
1305,
63,
8501,
275,
2125,
288,
1249,
275,
942,
267,
2467,
14,
2526,
4852,
288,
10468,
627,
288,
4442,
522,
63,
4627,
63,
9642,
288,
6038,
13727,
63,
1000,
1137,
2125,
408,
435,
1305,
63,
8501,
435,
408,
16044,
6515,
3414,
267,
10327,
1249,
9,
267,
372,
2467,
14,
807,
10174,
342,
339,
347,
2341,
63,
9642,
63,
2987,
8,
277,
12,
2467,
12,
1747,
12,
3743,
12,
4676,
12,
13727,
63,
2373,
304,
267,
1338,
275,
1613,
8,
16063,
19534,
12,
291,
680,
1130,
63,
9642,
63,
2987,
8,
288,
2467,
12,
1747,
12,
3743,
12,
4676,
12,
13727,
63,
2373,
9,
267,
4412,
275,
359,
288,
661,
354,
297,
283,
354,
63,
3215,
659,
288,
661,
2123,
297,
283,
1198,
63,
3215,
659,
267,
1622,
267,
367,
574,
63,
498,
12,
3743,
63,
354,
315,
4412,
26,
288,
862,
26,
355,
340,
3743,
59,
2190,
63,
354,
2189,
490,
1338,
59,
585,
63,
498,
61,
275,
13727,
63,
2373,
59,
17,
1527,
2190,
59,
2190,
63,
354,
22235,
16,
61,
288,
871,
4067,
26,
355,
485,
793,
14,
3764,
360,
1944,
20717,
2225,
2071,
83,
2,
1911,
367,
4676,
221,
2071,
83,
4507,
450,
334,
490,
3743,
14,
362,
8,
2190,
63,
354,
395,
1338,
14,
362,
360,
2886,
7058,
267,
372,
1338,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
hi35xx/hi3518e-buildroot
|
linux/linux-3.0.y/tools/perf/scripts/python/Perf-Trace-Util/lib/Perf/Trace/Util.py
|
12527
|
1935
|
# Util.py - Python extension for perf script, miscellaneous utility code
#
# Copyright (C) 2010 by Tom Zanussi <tzanussi@gmail.com>
#
# This software may be distributed under the terms of the GNU General
# Public License ("GPL") version 2 as published by the Free Software
# Foundation.
import errno, os
FUTEX_WAIT = 0
FUTEX_WAKE = 1
FUTEX_PRIVATE_FLAG = 128
FUTEX_CLOCK_REALTIME = 256
FUTEX_CMD_MASK = ~(FUTEX_PRIVATE_FLAG | FUTEX_CLOCK_REALTIME)
NSECS_PER_SEC = 1000000000
def avg(total, n):
return total / n
def nsecs(secs, nsecs):
return secs * NSECS_PER_SEC + nsecs
def nsecs_secs(nsecs):
return nsecs / NSECS_PER_SEC
def nsecs_nsecs(nsecs):
return nsecs % NSECS_PER_SEC
def nsecs_str(nsecs):
str = "%5u.%09u" % (nsecs_secs(nsecs), nsecs_nsecs(nsecs)),
return str
def add_stats(dict, key, value):
if not dict.has_key(key):
dict[key] = (value, value, value, 1)
else:
min, max, avg, count = dict[key]
if value < min:
min = value
if value > max:
max = value
avg = (avg + value) / 2
dict[key] = (min, max, avg, count + 1)
def clear_term():
print("\x1b[H\x1b[2J")
audit_package_warned = False
try:
import audit
machine_to_id = {
'x86_64': audit.MACH_86_64,
'alpha' : audit.MACH_ALPHA,
'ia64' : audit.MACH_IA64,
'ppc' : audit.MACH_PPC,
'ppc64' : audit.MACH_PPC64,
's390' : audit.MACH_S390,
's390x' : audit.MACH_S390X,
'i386' : audit.MACH_X86,
'i586' : audit.MACH_X86,
'i686' : audit.MACH_X86,
}
try:
machine_to_id['armeb'] = audit.MACH_ARMEB
except:
pass
machine_id = machine_to_id[os.uname()[4]]
except:
if not audit_package_warned:
audit_package_warned = True
print "Install the audit-libs-python package to get syscall names"
def syscall_name(id):
try:
return audit.audit_syscall_to_name(id, machine_id)
except:
return str(id)
def strerror(nr):
try:
return errno.errorcode[abs(nr)]
except:
return "Unknown %d errno" % nr
|
gpl-2.0
|
[
3,
21248,
14,
647,
446,
2018,
3329,
367,
8582,
2884,
12,
3201,
19549,
11420,
1233,
199,
3,
199,
3,
1898,
334,
35,
9,
7129,
701,
21644,
29385,
665,
29453,
32,
6799,
14,
957,
30,
199,
3,
199,
3,
961,
2032,
1443,
506,
1854,
1334,
314,
2895,
402,
314,
1664,
1696,
199,
3,
1684,
844,
1689,
12006,
531,
1015,
499,
465,
3267,
701,
314,
2868,
2290,
199,
3,
2752,
14,
199,
199,
646,
7554,
12,
747,
199,
199,
31179,
63,
12458,
275,
378,
199,
31179,
63,
9004,
2430,
275,
413,
199,
31179,
63,
18748,
63,
3719,
275,
7960,
199,
31179,
63,
30690,
63,
15508,
4961,
275,
7633,
199,
31179,
63,
9744,
63,
12880,
275,
6146,
8,
31179,
63,
18748,
63,
3719,
1204,
481,
934,
1438,
63,
30690,
63,
15508,
4961,
9,
199,
199,
46,
28466,
63,
4227,
63,
15048,
259,
275,
413,
25464,
199,
199,
318,
12402,
8,
2923,
12,
302,
304,
272,
372,
3141,
1182,
302,
199,
199,
318,
13781,
8,
4855,
12,
13781,
304,
272,
372,
20091,
627,
653,
28466,
63,
4227,
63,
15048,
435,
13781,
199,
199,
318,
13781,
63,
4855,
8,
9618,
304,
272,
372,
13781,
1182,
653,
28466,
63,
4227,
63,
15048,
199,
199,
318,
13781,
63,
9618,
8,
9618,
304,
272,
372,
13781,
450,
653,
28466,
63,
4227,
63,
15048,
199,
199,
318,
13781,
63,
495,
8,
9618,
304,
272,
620,
275,
2071,
21,
85,
4111,
1643,
85,
2,
450,
334,
9618,
63,
4855,
8,
9618,
395,
13781,
63,
9618,
8,
9618,
1826,
272,
372,
620,
199,
199,
318,
1050,
63,
3200,
8,
807,
12,
790,
12,
574,
304,
199,
198,
692,
440,
1211,
14,
1989,
63,
498,
8,
498,
304,
507,
198,
807,
59,
498,
61,
275,
334,
585,
12,
574,
12,
574,
12,
413,
9,
199,
198,
2836,
26,
507,
198,
827,
12,
1390,
12,
12402,
12,
2338,
275,
1211,
59,
498,
61,
507,
198,
692,
574,
665,
1748,
26,
686,
198,
827,
275,
574,
507,
198,
692,
574,
690,
1390,
26,
686,
198,
988,
275,
574,
507,
198,
8595,
275,
334,
8595,
435,
574,
9,
1182,
499,
507,
198,
807,
59,
498,
61,
275,
334,
827,
12,
1390,
12,
12402,
12,
2338,
435,
413,
9,
199,
199,
318,
5436,
63,
5125,
837,
272,
870,
4582,
88,
17,
66,
59,
40,
60,
88,
17,
66,
59,
18,
42,
531,
199,
199,
14274,
63,
2491,
63,
4050,
379,
275,
756,
199,
199,
893,
26,
199,
198,
646,
13968,
199,
198,
6744,
63,
475,
63,
344,
275,
469,
507,
198,
7,
88,
1184,
63,
772,
356,
13968,
14,
13802,
63,
1184,
63,
772,
12,
507,
198,
7,
4468,
7,
198,
26,
13968,
14,
13802,
63,
18554,
12,
507,
198,
7,
4674,
772,
7,
198,
26,
13968,
14,
13802,
63,
13033,
772,
12,
507,
198,
7,
20638,
7,
198,
26,
13968,
14,
13802,
63,
48,
4222,
12,
507,
198,
7,
20638,
772,
7,
198,
26,
13968,
14,
13802,
63,
48,
4222,
772,
12,
507,
198,
1159,
12302,
7,
198,
26,
13968,
14,
13802,
63,
51,
12302,
12,
507,
198,
1159,
12302,
88,
7,
198,
26,
13968,
14,
13802,
63,
51,
12302,
56,
12,
507,
198,
7,
73,
8040,
7,
198,
26,
13968,
14,
13802,
63,
56,
1184,
12,
507,
198,
7,
73,
26888,
7,
198,
26,
13968,
14,
13802,
63,
56,
1184,
12,
507,
198,
7,
73,
10253,
7,
198,
26,
13968,
14,
13802,
63,
56,
1184,
12,
199,
198,
93,
199,
198,
893,
26,
507,
198,
6744,
63,
475,
63,
344,
459,
285,
278,
66,
418,
275,
13968,
14,
13802,
63,
689,
3635,
34,
199,
198,
2590,
26,
507,
198,
1529,
199,
198,
6744,
63,
344,
275,
6844,
63,
475,
63,
344,
59,
736,
14,
16040,
3430,
20,
2677,
199,
2590,
26,
199,
198,
692,
440,
13968,
63,
2491,
63,
4050,
379,
26,
507,
198,
14274,
63,
2491,
63,
4050,
379,
275,
715,
507,
198,
1361,
298,
8154,
314,
13968,
13,
8450,
13,
1548,
2559,
370,
664,
18901,
1561,
2,
199,
199,
318,
18901,
63,
354,
8,
344,
304,
199,
198,
893,
26,
507,
198,
1107,
13968,
14,
14274,
63,
19444,
63,
475,
63,
354,
8,
344,
12,
6844,
63,
344,
9,
199,
198,
2590,
26,
507,
198,
1107,
620,
8,
344,
9,
199,
199,
318,
410,
17844,
8,
7865,
304,
199,
198,
893,
26,
507,
198,
1107,
7554,
14,
28857,
59,
2101,
8,
7865,
1874,
199,
198,
2590,
26,
507,
198,
1107,
298,
5912,
450,
68,
7554,
2,
450,
14762,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
21248,
14,
647,
446,
2018,
3329,
367,
8582,
2884,
12,
3201,
19549,
11420,
1233,
199,
3,
199,
3,
1898,
334,
35,
9,
7129,
701,
21644,
29385,
665,
29453,
32,
6799,
14,
957,
30,
199,
3,
199,
3,
961,
2032,
1443,
506,
1854,
1334,
314,
2895,
402,
314,
1664,
1696,
199,
3,
1684,
844,
1689,
12006,
531,
1015,
499,
465,
3267,
701,
314,
2868,
2290,
199,
3,
2752,
14,
199,
199,
646,
7554,
12,
747,
199,
199,
31179,
63,
12458,
275,
378,
199,
31179,
63,
9004,
2430,
275,
413,
199,
31179,
63,
18748,
63,
3719,
275,
7960,
199,
31179,
63,
30690,
63,
15508,
4961,
275,
7633,
199,
31179,
63,
9744,
63,
12880,
275,
6146,
8,
31179,
63,
18748,
63,
3719,
1204,
481,
934,
1438,
63,
30690,
63,
15508,
4961,
9,
199,
199,
46,
28466,
63,
4227,
63,
15048,
259,
275,
413,
25464,
199,
199,
318,
12402,
8,
2923,
12,
302,
304,
272,
372,
3141,
1182,
302,
199,
199,
318,
13781,
8,
4855,
12,
13781,
304,
272,
372,
20091,
627,
653,
28466,
63,
4227,
63,
15048,
435,
13781,
199,
199,
318,
13781,
63,
4855,
8,
9618,
304,
272,
372,
13781,
1182,
653,
28466,
63,
4227,
63,
15048,
199,
199,
318,
13781,
63,
9618,
8,
9618,
304,
272,
372,
13781,
450,
653,
28466,
63,
4227,
63,
15048,
199,
199,
318,
13781,
63,
495,
8,
9618,
304,
272,
620,
275,
2071,
21,
85,
4111,
1643,
85,
2,
450,
334,
9618,
63,
4855,
8,
9618,
395,
13781,
63,
9618,
8,
9618,
1826,
272,
372,
620,
199,
199,
318,
1050,
63,
3200,
8,
807,
12,
790,
12,
574,
304,
199,
198,
692,
440,
1211,
14,
1989,
63,
498,
8,
498,
304,
507,
198,
807,
59,
498,
61,
275,
334,
585,
12,
574,
12,
574,
12,
413,
9,
199,
198,
2836,
26,
507,
198,
827,
12,
1390,
12,
12402,
12,
2338,
275,
1211,
59,
498,
61,
507,
198,
692,
574,
665,
1748,
26,
686,
198,
827,
275,
574,
507,
198,
692,
574,
690,
1390,
26,
686,
198,
988,
275,
574,
507,
198,
8595,
275,
334,
8595,
435,
574,
9,
1182,
499,
507,
198,
807,
59,
498,
61,
275,
334,
827,
12,
1390,
12,
12402,
12,
2338,
435,
413,
9,
199,
199,
318,
5436,
63,
5125,
837,
272,
870,
4582,
88,
17,
66,
59,
40,
60,
88,
17,
66,
59,
18,
42,
531,
199,
199,
14274,
63,
2491,
63,
4050,
379,
275,
756,
199,
199,
893,
26,
199,
198,
646,
13968,
199,
198,
6744,
63,
475,
63,
344,
275,
469,
507,
198,
7,
88,
1184,
63,
772,
356,
13968,
14,
13802,
63,
1184,
63,
772,
12,
507,
198,
7,
4468,
7,
198,
26,
13968,
14,
13802,
63,
18554,
12,
507,
198,
7,
4674,
772,
7,
198,
26,
13968,
14,
13802,
63,
13033,
772,
12,
507,
198,
7,
20638,
7,
198,
26,
13968,
14,
13802,
63,
48,
4222,
12,
507,
198,
7,
20638,
772,
7,
198,
26,
13968,
14,
13802,
63,
48,
4222,
772,
12,
507,
198,
1159,
12302,
7,
198,
26,
13968,
14,
13802,
63,
51,
12302,
12,
507,
198,
1159,
12302,
88,
7,
198,
26,
13968,
14,
13802,
63,
51,
12302,
56,
12,
507,
198,
7,
73,
8040,
7,
198,
26,
13968,
14,
13802,
63,
56,
1184,
12,
507,
198,
7,
73,
26888,
7,
198,
26,
13968,
14,
13802,
63,
56,
1184,
12,
507,
198,
7,
73,
10253,
7,
198,
26,
13968,
14,
13802,
63,
56,
1184,
12,
199,
198,
93,
199,
198,
893,
26,
507,
198,
6744,
63,
475,
63,
344,
459,
285,
278,
66,
418,
275,
13968,
14,
13802,
63,
689,
3635,
34,
199,
198,
2590,
26,
507,
198,
1529,
199,
198,
6744,
63,
344,
275,
6844,
63,
475,
63,
344,
59,
736,
14,
16040,
3430,
20,
2677,
199,
2590,
26,
199,
198,
692,
440,
13968,
63,
2491,
63,
4050,
379,
26,
507,
198,
14274,
63,
2491,
63,
4050,
379,
275,
715,
507,
198,
1361,
298,
8154,
314,
13968,
13,
8450,
13,
1548,
2559,
370,
664,
18901,
1561,
2,
199,
199,
318,
18901,
63,
354,
8,
344,
304,
199,
198,
893,
26,
507,
198,
1107,
13968,
14,
14274,
63,
19444,
63,
475,
63,
354,
8,
344,
12,
6844,
63,
344,
9,
199,
198,
2590,
26,
507,
198,
1107,
620,
8,
344,
9,
199,
199,
318,
410,
17844,
8,
7865,
304,
199,
198,
893,
26,
507,
198,
1107,
7554,
14,
28857,
59,
2101,
8,
7865,
1874,
199,
198,
2590,
26,
507,
198,
1107,
298,
5912,
450,
68,
7554,
2,
450,
14762,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
Balannen/LSMASOMM
|
atom3/Formalisms/CD_classDiagramsV3/graph_CD_Inheritance3.py
|
1
|
3661
|
"""
__graph_CD_Inheritance3.py___________________________________________________________
Automatically generated LINK for entity CD_Inheritance3
DO NOT MODIFY DIRECTLY
_____________________________________________________________________________________
"""
from graphLink import *
from stickylink import *
from widthXfillXdecoration import *
class graph_CD_Inheritance3(graphLink):
def __init__(self, xc, yc, semObject = None ):
self.semObject = semObject
self.semanticObject = semObject
from linkEditor import *
self.le=linkEditor(self,self.semObject, "CD_Inheritance3")
self.le.FirstLink= stickylink()
self.le.FirstLink.arrow=ATOM3Boolean()
self.le.FirstLink.arrow.setValue((' ', 0))
self.le.FirstLink.arrow.config = 0
self.le.FirstLink.arrowShape1=ATOM3Integer(8)
self.le.FirstLink.arrowShape2=ATOM3Integer(10)
self.le.FirstLink.arrowShape3=ATOM3Integer(3)
self.le.FirstLink.decoration=ATOM3Appearance()
self.le.FirstLink.decoration.setValue( ('CD_Inheritance3_1stLink', self.le.FirstLink))
self.le.FirstSegment= widthXfillXdecoration()
self.le.FirstSegment.width=ATOM3Integer(2)
self.le.FirstSegment.fill=ATOM3String('black')
self.le.FirstSegment.stipple=ATOM3String('')
self.le.FirstSegment.arrow=ATOM3Boolean()
self.le.FirstSegment.arrow.setValue((' ', 0))
self.le.FirstSegment.arrow.config = 0
self.le.FirstSegment.arrowShape1=ATOM3Integer(8)
self.le.FirstSegment.arrowShape2=ATOM3Integer(10)
self.le.FirstSegment.arrowShape3=ATOM3Integer(3)
self.le.FirstSegment.decoration=ATOM3Appearance()
self.le.FirstSegment.decoration.setValue( ('CD_Inheritance3_1stSegment', self.le.FirstSegment))
self.le.FirstSegment.decoration_Position=ATOM3Enum(['Up', 'Down', 'Middle', 'No decoration'],3,0)
self.le.Center=ATOM3Appearance()
self.le.Center.setValue( ('CD_Inheritance3_Center', self.le))
self.le.SecondSegment= widthXfillXdecoration()
self.le.SecondSegment.width=ATOM3Integer(2)
self.le.SecondSegment.fill=ATOM3String('black')
self.le.SecondSegment.stipple=ATOM3String('')
self.le.SecondSegment.arrow=ATOM3Boolean()
self.le.SecondSegment.arrow.setValue((' ', 0))
self.le.SecondSegment.arrow.config = 0
self.le.SecondSegment.arrowShape1=ATOM3Integer(8)
self.le.SecondSegment.arrowShape2=ATOM3Integer(10)
self.le.SecondSegment.arrowShape3=ATOM3Integer(3)
self.le.SecondSegment.decoration=ATOM3Appearance()
self.le.SecondSegment.decoration.setValue( ('CD_Inheritance3_2ndSegment', self.le.SecondSegment))
self.le.SecondSegment.decoration_Position=ATOM3Enum(['Up', 'Down', 'Middle', 'No decoration'],3,0)
self.le.SecondLink= stickylink()
self.le.SecondLink.arrow=ATOM3Boolean()
self.le.SecondLink.arrow.setValue((' ', 0))
self.le.SecondLink.arrow.config = 0
self.le.SecondLink.arrowShape1=ATOM3Integer(8)
self.le.SecondLink.arrowShape2=ATOM3Integer(10)
self.le.SecondLink.arrowShape3=ATOM3Integer(3)
self.le.SecondLink.decoration=ATOM3Appearance()
self.le.SecondLink.decoration.setValue( ('CD_Inheritance3_2ndLink', self.le.SecondLink))
self.le.FirstLink.decoration.semObject=self.semObject
self.le.FirstSegment.decoration.semObject=self.semObject
self.le.Center.semObject=self.semObject
self.le.SecondSegment.decoration.semObject=self.semObject
self.le.SecondLink.decoration.semObject=self.semObject
graphLink.__init__(self, xc, yc, self.le,semObject)
|
gpl-3.0
|
[
624,
202,
199,
363,
2180,
63,
7695,
63,
23542,
554,
19,
14,
647,
22794,
13088,
7785,
8989,
2999,
199,
3358,
17174,
4046,
19774,
367,
4642,
445,
36,
63,
23542,
554,
19,
202,
199,
1649,
2845,
10362,
1914,
18114,
8703,
6084,
202,
199,
22794,
22794,
13088,
4741,
63,
202,
199,
624,
202,
199,
504,
3343,
3834,
492,
627,
202,
199,
504,
17870,
1073,
492,
627,
202,
199,
504,
3462,
56,
4498,
56,
6518,
425,
492,
627,
202,
199,
533,
3343,
63,
7695,
63,
23542,
554,
19,
8,
2180,
3834,
304,
10060,
257,
347,
636,
826,
721,
277,
12,
20399,
12,
612,
67,
12,
26298,
1692,
275,
488,
3461,
8608,
291,
14,
21678,
1692,
275,
26298,
1692,
8608,
291,
14,
261,
23127,
1692,
275,
26298,
1692,
8608,
687,
2142,
10423,
492,
627,
8608,
291,
14,
274,
29,
1073,
10423,
8,
277,
12,
277,
14,
21678,
1692,
12,
298,
7695,
63,
23542,
554,
19,
531,
8608,
291,
14,
274,
14,
7147,
3834,
29,
17870,
1073,
342,
8608,
291,
14,
274,
14,
7147,
3834,
14,
7691,
29,
22479,
19,
4082,
342,
8608,
291,
14,
274,
14,
7147,
3834,
14,
7691,
14,
14733,
4725,
1656,
378,
430,
8608,
291,
14,
274,
14,
7147,
3834,
14,
7691,
14,
888,
275,
378,
8608,
291,
14,
274,
14,
7147,
3834,
14,
7691,
7238,
17,
29,
22479,
19,
2674,
8,
24,
9,
8608,
291,
14,
274,
14,
7147,
3834,
14,
7691,
7238,
18,
29,
22479,
19,
2674,
8,
709,
9,
8608,
291,
14,
274,
14,
7147,
3834,
14,
7691,
7238,
19,
29,
22479,
19,
2674,
8,
19,
9,
8608,
291,
14,
274,
14,
7147,
3834,
14,
6518,
425,
29,
22479,
19,
13117,
16343,
554,
342,
8608,
291,
14,
274,
14,
7147,
3834,
14,
6518,
425,
14,
14733,
8,
661,
7695,
63,
23542,
554,
19,
63,
17,
270,
3834,
297,
291,
14,
274,
14,
7147,
3834,
430,
8608,
291,
14,
274,
14,
7147,
12520,
29,
3462,
56,
4498,
56,
6518,
425,
342,
8608,
291,
14,
274,
14,
7147,
12520,
14,
2063,
29,
22479,
19,
2674,
8,
18,
9,
8608,
291,
14,
274,
14,
7147,
12520,
14,
4498,
29,
22479,
19,
1558,
360,
8399,
358,
8608,
291,
14,
274,
14,
7147,
12520,
14,
270,
711,
11045,
29,
22479,
19,
1558,
8355,
8608,
291,
14,
274,
14,
7147,
12520,
14,
7691,
29,
22479,
19,
4082,
342,
8608,
291,
14,
274,
14,
7147,
12520,
14,
7691,
14,
14733,
4725,
1656,
378,
430,
8608,
291,
14,
274,
14,
7147,
12520,
14,
7691,
14,
888,
275,
378,
8608,
291,
14,
274,
14,
7147,
12520,
14,
7691,
7238,
17,
29,
22479,
19,
2674,
8,
24,
9,
8608,
291,
14,
274,
14,
7147,
12520,
14,
7691,
7238,
18,
29,
22479,
19,
2674,
8,
709,
9,
8608,
291,
14,
274,
14,
7147,
12520,
14,
7691,
7238,
19,
29,
22479,
19,
2674,
8,
19,
9,
8608,
291,
14,
274,
14,
7147,
12520,
14,
6518,
425,
29,
22479,
19,
13117,
16343,
554,
342,
8608,
291,
14,
274,
14,
7147,
12520,
14,
6518,
425,
14,
14733,
8,
661,
7695,
63,
23542,
554,
19,
63,
17,
270,
12520,
297,
291,
14,
274,
14,
7147,
12520,
430,
8608,
291,
14,
274,
14,
7147,
12520,
14,
6518,
425,
63,
5625,
29,
22479,
19,
5081,
2941,
1721,
297,
283,
3514,
297,
283,
30734,
297,
283,
1944,
5509,
425,
995,
19,
12,
16,
9,
8608,
291,
14,
274,
14,
13551,
29,
22479,
19,
13117,
16343,
554,
342,
8608,
291,
14,
274,
14,
13551,
14,
14733,
8,
661,
7695,
63,
23542,
554,
19,
63,
13551,
297,
291,
14,
274,
430,
8608,
291,
14,
274,
14,
11906,
12520,
29,
3462,
56,
4498,
56,
6518,
425,
342,
8608,
291,
14,
274,
14,
11906,
12520,
14,
2063,
29,
22479,
19,
2674,
8,
18,
9,
8608,
291,
14,
274,
14,
11906,
12520,
14,
4498,
29,
22479,
19,
1558,
360,
8399,
358,
8608,
291,
14,
274,
14,
11906,
12520,
14,
270,
711,
11045,
29,
22479,
19,
1558,
8355,
8608,
291,
14,
274,
14,
11906,
12520,
14,
7691,
29,
22479,
19,
4082,
342,
8608,
291,
14,
274,
14,
11906,
12520,
14,
7691,
14,
14733,
4725,
1656,
378,
430,
8608,
291,
14,
274,
14,
11906,
12520,
14,
7691,
14,
888,
275,
378,
8608,
291,
14,
274,
14,
11906,
12520,
14,
7691,
7238,
17,
29,
22479,
19,
2674,
8,
24,
9,
8608,
291,
14,
274,
14,
11906,
12520,
14,
7691,
7238,
18,
29,
22479,
19,
2674,
8,
709,
9,
8608,
291,
14,
274,
14,
11906,
12520,
14,
7691,
7238,
19,
29,
22479,
19,
2674,
8,
19,
9,
8608,
291,
14,
274,
14,
11906,
12520,
14,
6518,
425,
29,
22479,
19,
13117,
16343,
554,
342,
8608,
291,
14,
274,
14,
11906,
12520,
14,
6518,
425,
14,
14733,
8,
661,
7695,
63,
23542,
554,
19,
63,
18,
977,
12520,
297,
291,
14,
274,
14,
11906,
12520,
430,
8608,
291,
14,
274,
14,
11906,
12520,
14,
6518,
425,
63,
5625,
29,
22479,
19,
5081,
2941,
1721,
297,
283,
3514,
297,
283,
30734,
297,
283,
1944,
5509,
425,
995,
19,
12,
16,
9,
8608,
291,
14,
274,
14,
11906,
3834,
29,
17870,
1073,
342,
8608,
291,
14,
274,
14,
11906,
3834,
14,
7691,
29,
22479,
19,
4082,
342,
8608,
291,
14,
274,
14,
11906,
3834,
14,
7691,
14,
14733,
4725,
1656,
378,
430,
8608,
291,
14,
274,
14,
11906,
3834,
14,
7691,
14,
888,
275,
378,
8608,
291,
14,
274,
14,
11906,
3834,
14,
7691,
7238,
17,
29,
22479,
19,
2674,
8,
24,
9,
8608,
291,
14,
274,
14,
11906,
3834,
14,
7691,
7238,
18,
29,
22479,
19,
2674,
8,
709,
9,
8608,
291,
14,
274,
14,
11906,
3834,
14,
7691,
7238,
19,
29,
22479,
19,
2674,
8,
19,
9,
8608,
291,
14,
274,
14,
11906,
3834,
14,
6518,
425,
29,
22479,
19,
13117,
16343,
554,
342,
8608,
291,
14,
274,
14,
11906,
3834,
14,
6518,
425,
14,
14733,
8,
661,
7695,
63,
23542,
554,
19,
63,
18,
977,
3834,
297,
291,
14,
274,
14,
11906,
3834,
430,
8608,
291,
14,
274,
14,
7147,
3834,
14,
6518,
425,
14,
21678,
1692,
29,
277,
14,
21678,
1692,
8608,
291,
14,
274,
14,
7147,
12520,
14,
6518,
425,
14,
21678,
1692,
29,
277,
14,
21678,
1692,
8608,
291,
14,
274,
14,
13551,
14,
21678,
1692
] |
[
202,
199,
363,
2180,
63,
7695,
63,
23542,
554,
19,
14,
647,
22794,
13088,
7785,
8989,
2999,
199,
3358,
17174,
4046,
19774,
367,
4642,
445,
36,
63,
23542,
554,
19,
202,
199,
1649,
2845,
10362,
1914,
18114,
8703,
6084,
202,
199,
22794,
22794,
13088,
4741,
63,
202,
199,
624,
202,
199,
504,
3343,
3834,
492,
627,
202,
199,
504,
17870,
1073,
492,
627,
202,
199,
504,
3462,
56,
4498,
56,
6518,
425,
492,
627,
202,
199,
533,
3343,
63,
7695,
63,
23542,
554,
19,
8,
2180,
3834,
304,
10060,
257,
347,
636,
826,
721,
277,
12,
20399,
12,
612,
67,
12,
26298,
1692,
275,
488,
3461,
8608,
291,
14,
21678,
1692,
275,
26298,
1692,
8608,
291,
14,
261,
23127,
1692,
275,
26298,
1692,
8608,
687,
2142,
10423,
492,
627,
8608,
291,
14,
274,
29,
1073,
10423,
8,
277,
12,
277,
14,
21678,
1692,
12,
298,
7695,
63,
23542,
554,
19,
531,
8608,
291,
14,
274,
14,
7147,
3834,
29,
17870,
1073,
342,
8608,
291,
14,
274,
14,
7147,
3834,
14,
7691,
29,
22479,
19,
4082,
342,
8608,
291,
14,
274,
14,
7147,
3834,
14,
7691,
14,
14733,
4725,
1656,
378,
430,
8608,
291,
14,
274,
14,
7147,
3834,
14,
7691,
14,
888,
275,
378,
8608,
291,
14,
274,
14,
7147,
3834,
14,
7691,
7238,
17,
29,
22479,
19,
2674,
8,
24,
9,
8608,
291,
14,
274,
14,
7147,
3834,
14,
7691,
7238,
18,
29,
22479,
19,
2674,
8,
709,
9,
8608,
291,
14,
274,
14,
7147,
3834,
14,
7691,
7238,
19,
29,
22479,
19,
2674,
8,
19,
9,
8608,
291,
14,
274,
14,
7147,
3834,
14,
6518,
425,
29,
22479,
19,
13117,
16343,
554,
342,
8608,
291,
14,
274,
14,
7147,
3834,
14,
6518,
425,
14,
14733,
8,
661,
7695,
63,
23542,
554,
19,
63,
17,
270,
3834,
297,
291,
14,
274,
14,
7147,
3834,
430,
8608,
291,
14,
274,
14,
7147,
12520,
29,
3462,
56,
4498,
56,
6518,
425,
342,
8608,
291,
14,
274,
14,
7147,
12520,
14,
2063,
29,
22479,
19,
2674,
8,
18,
9,
8608,
291,
14,
274,
14,
7147,
12520,
14,
4498,
29,
22479,
19,
1558,
360,
8399,
358,
8608,
291,
14,
274,
14,
7147,
12520,
14,
270,
711,
11045,
29,
22479,
19,
1558,
8355,
8608,
291,
14,
274,
14,
7147,
12520,
14,
7691,
29,
22479,
19,
4082,
342,
8608,
291,
14,
274,
14,
7147,
12520,
14,
7691,
14,
14733,
4725,
1656,
378,
430,
8608,
291,
14,
274,
14,
7147,
12520,
14,
7691,
14,
888,
275,
378,
8608,
291,
14,
274,
14,
7147,
12520,
14,
7691,
7238,
17,
29,
22479,
19,
2674,
8,
24,
9,
8608,
291,
14,
274,
14,
7147,
12520,
14,
7691,
7238,
18,
29,
22479,
19,
2674,
8,
709,
9,
8608,
291,
14,
274,
14,
7147,
12520,
14,
7691,
7238,
19,
29,
22479,
19,
2674,
8,
19,
9,
8608,
291,
14,
274,
14,
7147,
12520,
14,
6518,
425,
29,
22479,
19,
13117,
16343,
554,
342,
8608,
291,
14,
274,
14,
7147,
12520,
14,
6518,
425,
14,
14733,
8,
661,
7695,
63,
23542,
554,
19,
63,
17,
270,
12520,
297,
291,
14,
274,
14,
7147,
12520,
430,
8608,
291,
14,
274,
14,
7147,
12520,
14,
6518,
425,
63,
5625,
29,
22479,
19,
5081,
2941,
1721,
297,
283,
3514,
297,
283,
30734,
297,
283,
1944,
5509,
425,
995,
19,
12,
16,
9,
8608,
291,
14,
274,
14,
13551,
29,
22479,
19,
13117,
16343,
554,
342,
8608,
291,
14,
274,
14,
13551,
14,
14733,
8,
661,
7695,
63,
23542,
554,
19,
63,
13551,
297,
291,
14,
274,
430,
8608,
291,
14,
274,
14,
11906,
12520,
29,
3462,
56,
4498,
56,
6518,
425,
342,
8608,
291,
14,
274,
14,
11906,
12520,
14,
2063,
29,
22479,
19,
2674,
8,
18,
9,
8608,
291,
14,
274,
14,
11906,
12520,
14,
4498,
29,
22479,
19,
1558,
360,
8399,
358,
8608,
291,
14,
274,
14,
11906,
12520,
14,
270,
711,
11045,
29,
22479,
19,
1558,
8355,
8608,
291,
14,
274,
14,
11906,
12520,
14,
7691,
29,
22479,
19,
4082,
342,
8608,
291,
14,
274,
14,
11906,
12520,
14,
7691,
14,
14733,
4725,
1656,
378,
430,
8608,
291,
14,
274,
14,
11906,
12520,
14,
7691,
14,
888,
275,
378,
8608,
291,
14,
274,
14,
11906,
12520,
14,
7691,
7238,
17,
29,
22479,
19,
2674,
8,
24,
9,
8608,
291,
14,
274,
14,
11906,
12520,
14,
7691,
7238,
18,
29,
22479,
19,
2674,
8,
709,
9,
8608,
291,
14,
274,
14,
11906,
12520,
14,
7691,
7238,
19,
29,
22479,
19,
2674,
8,
19,
9,
8608,
291,
14,
274,
14,
11906,
12520,
14,
6518,
425,
29,
22479,
19,
13117,
16343,
554,
342,
8608,
291,
14,
274,
14,
11906,
12520,
14,
6518,
425,
14,
14733,
8,
661,
7695,
63,
23542,
554,
19,
63,
18,
977,
12520,
297,
291,
14,
274,
14,
11906,
12520,
430,
8608,
291,
14,
274,
14,
11906,
12520,
14,
6518,
425,
63,
5625,
29,
22479,
19,
5081,
2941,
1721,
297,
283,
3514,
297,
283,
30734,
297,
283,
1944,
5509,
425,
995,
19,
12,
16,
9,
8608,
291,
14,
274,
14,
11906,
3834,
29,
17870,
1073,
342,
8608,
291,
14,
274,
14,
11906,
3834,
14,
7691,
29,
22479,
19,
4082,
342,
8608,
291,
14,
274,
14,
11906,
3834,
14,
7691,
14,
14733,
4725,
1656,
378,
430,
8608,
291,
14,
274,
14,
11906,
3834,
14,
7691,
14,
888,
275,
378,
8608,
291,
14,
274,
14,
11906,
3834,
14,
7691,
7238,
17,
29,
22479,
19,
2674,
8,
24,
9,
8608,
291,
14,
274,
14,
11906,
3834,
14,
7691,
7238,
18,
29,
22479,
19,
2674,
8,
709,
9,
8608,
291,
14,
274,
14,
11906,
3834,
14,
7691,
7238,
19,
29,
22479,
19,
2674,
8,
19,
9,
8608,
291,
14,
274,
14,
11906,
3834,
14,
6518,
425,
29,
22479,
19,
13117,
16343,
554,
342,
8608,
291,
14,
274,
14,
11906,
3834,
14,
6518,
425,
14,
14733,
8,
661,
7695,
63,
23542,
554,
19,
63,
18,
977,
3834,
297,
291,
14,
274,
14,
11906,
3834,
430,
8608,
291,
14,
274,
14,
7147,
3834,
14,
6518,
425,
14,
21678,
1692,
29,
277,
14,
21678,
1692,
8608,
291,
14,
274,
14,
7147,
12520,
14,
6518,
425,
14,
21678,
1692,
29,
277,
14,
21678,
1692,
8608,
291,
14,
274,
14,
13551,
14,
21678,
1692,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
apocquet/django
|
tests/template_tests/test_unicode.py
|
347
|
1431
|
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from unittest import TestCase
from django.template import Context, Engine
from django.template.base import TemplateEncodingError
from django.utils import six
from django.utils.safestring import SafeData
class UnicodeTests(TestCase):
def test_template(self):
# Templates can be created from unicode strings.
engine = Engine()
t1 = engine.from_string('ŠĐĆŽćžšđ {{ var }}')
# Templates can also be created from bytestrings. These are assumed to
# be encoded using UTF-8.
s = b'\xc5\xa0\xc4\x90\xc4\x86\xc5\xbd\xc4\x87\xc5\xbe\xc5\xa1\xc4\x91 {{ var }}'
t2 = engine.from_string(s)
with self.assertRaises(TemplateEncodingError):
engine.from_string(b'\x80\xc5\xc0')
# Contexts can be constructed from unicode or UTF-8 bytestrings.
Context({b"var": b"foo"})
Context({"var": b"foo"})
c3 = Context({b"var": "Đđ"})
Context({"var": b"\xc4\x90\xc4\x91"})
# Since both templates and all four contexts represent the same thing,
# they all render the same (and are returned as unicode objects and
# "safe" objects as well, for auto-escaping purposes).
self.assertEqual(t1.render(c3), t2.render(c3))
self.assertIsInstance(t1.render(c3), six.text_type)
self.assertIsInstance(t1.render(c3), SafeData)
|
bsd-3-clause
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
504,
636,
2443,
363,
492,
2649,
63,
5955,
199,
199,
504,
2882,
492,
7640,
199,
199,
504,
1639,
14,
1160,
492,
9470,
12,
12580,
199,
504,
1639,
14,
1160,
14,
1095,
492,
5458,
7630,
547,
199,
504,
1639,
14,
1208,
492,
3816,
199,
504,
1639,
14,
1208,
14,
28389,
492,
14969,
1451,
421,
199,
533,
6140,
2925,
8,
1746,
304,
272,
347,
511,
63,
1160,
8,
277,
304,
267,
327,
31273,
883,
506,
2737,
687,
2649,
3326,
14,
267,
6869,
275,
12580,
342,
267,
307,
17,
275,
6869,
14,
504,
63,
875,
360,
130,
255,
129,
239,
129,
229,
130,
122,
129,
230,
29529,
27273,
129,
240,
8448,
2729,
28404,
267,
327,
31273,
883,
2597,
506,
2737,
687,
18792,
25182,
14,
5723,
787,
10826,
370,
267,
327,
506,
5737,
1808,
9094,
13,
24,
14,
267,
308,
275,
330,
1154,
1812,
21,
60,
1800,
16,
60,
1812,
20,
60,
88,
2710,
60,
1812,
20,
60,
88,
1184,
60,
1812,
21,
60,
9826,
60,
1812,
20,
60,
88,
1555,
60,
1812,
21,
60,
9957,
60,
1812,
21,
60,
1800,
17,
60,
1812,
20,
60,
88,
3328,
8448,
2729,
16339,
267,
307,
18,
275,
6869,
14,
504,
63,
875,
8,
83,
9,
267,
543,
291,
14,
1855,
8,
4231,
7630,
547,
304,
288,
6869,
14,
504,
63,
875,
8,
66,
1154,
88,
1257,
60,
1812,
21,
60,
1812,
16,
358,
398,
327,
9470,
83,
883,
506,
14701,
687,
2649,
503,
9094,
13,
24,
18792,
25182,
14,
267,
9470,
2561,
66,
2,
1391,
582,
330,
2,
1421,
5984,
267,
9470,
6333,
1391,
582,
330,
2,
1421,
5984,
267,
286,
19,
275,
9470,
2561,
66,
2,
1391,
582,
298,
129,
239,
129,
240,
5984,
267,
9470,
6333,
1391,
582,
330,
3212,
1812,
20,
60,
88,
2710,
60,
1812,
20,
60,
88,
3328,
5984,
398,
327,
9336,
3865,
7009,
436,
1006,
11648,
18191,
2954,
314,
2011,
8377,
12,
267,
327,
2985,
1006,
3795,
314,
2011,
334,
460,
787,
2138,
465,
2649,
2251,
436,
267,
327,
298,
3489,
2,
2251,
465,
5521,
12,
367,
2599,
13,
26306,
12901,
680,
267,
291,
14,
629,
8,
84,
17,
14,
3352,
8,
67,
19,
395,
307,
18,
14,
3352,
8,
67,
19,
430,
267,
291,
14,
6926,
8,
84,
17,
14,
3352,
8,
67,
19,
395,
3816,
14,
505,
63,
466,
9,
267,
291,
14,
6926,
8,
84,
17,
14,
3352,
8,
67,
19,
395,
14969,
1451,
9,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
504,
636,
2443,
363,
492,
2649,
63,
5955,
199,
199,
504,
2882,
492,
7640,
199,
199,
504,
1639,
14,
1160,
492,
9470,
12,
12580,
199,
504,
1639,
14,
1160,
14,
1095,
492,
5458,
7630,
547,
199,
504,
1639,
14,
1208,
492,
3816,
199,
504,
1639,
14,
1208,
14,
28389,
492,
14969,
1451,
421,
199,
533,
6140,
2925,
8,
1746,
304,
272,
347,
511,
63,
1160,
8,
277,
304,
267,
327,
31273,
883,
506,
2737,
687,
2649,
3326,
14,
267,
6869,
275,
12580,
342,
267,
307,
17,
275,
6869,
14,
504,
63,
875,
360,
130,
255,
129,
239,
129,
229,
130,
122,
129,
230,
29529,
27273,
129,
240,
8448,
2729,
28404,
267,
327,
31273,
883,
2597,
506,
2737,
687,
18792,
25182,
14,
5723,
787,
10826,
370,
267,
327,
506,
5737,
1808,
9094,
13,
24,
14,
267,
308,
275,
330,
1154,
1812,
21,
60,
1800,
16,
60,
1812,
20,
60,
88,
2710,
60,
1812,
20,
60,
88,
1184,
60,
1812,
21,
60,
9826,
60,
1812,
20,
60,
88,
1555,
60,
1812,
21,
60,
9957,
60,
1812,
21,
60,
1800,
17,
60,
1812,
20,
60,
88,
3328,
8448,
2729,
16339,
267,
307,
18,
275,
6869,
14,
504,
63,
875,
8,
83,
9,
267,
543,
291,
14,
1855,
8,
4231,
7630,
547,
304,
288,
6869,
14,
504,
63,
875,
8,
66,
1154,
88,
1257,
60,
1812,
21,
60,
1812,
16,
358,
398,
327,
9470,
83,
883,
506,
14701,
687,
2649,
503,
9094,
13,
24,
18792,
25182,
14,
267,
9470,
2561,
66,
2,
1391,
582,
330,
2,
1421,
5984,
267,
9470,
6333,
1391,
582,
330,
2,
1421,
5984,
267,
286,
19,
275,
9470,
2561,
66,
2,
1391,
582,
298,
129,
239,
129,
240,
5984,
267,
9470,
6333,
1391,
582,
330,
3212,
1812,
20,
60,
88,
2710,
60,
1812,
20,
60,
88,
3328,
5984,
398,
327,
9336,
3865,
7009,
436,
1006,
11648,
18191,
2954,
314,
2011,
8377,
12,
267,
327,
2985,
1006,
3795,
314,
2011,
334,
460,
787,
2138,
465,
2649,
2251,
436,
267,
327,
298,
3489,
2,
2251,
465,
5521,
12,
367,
2599,
13,
26306,
12901,
680,
267,
291,
14,
629,
8,
84,
17,
14,
3352,
8,
67,
19,
395,
307,
18,
14,
3352,
8,
67,
19,
430,
267,
291,
14,
6926,
8,
84,
17,
14,
3352,
8,
67,
19,
395,
3816,
14,
505,
63,
466,
9,
267,
291,
14,
6926,
8,
84,
17,
14,
3352,
8,
67,
19,
395,
14969,
1451,
9,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
skevy/django
|
tests/regressiontests/forms/localflavor/generic.py
|
89
|
4326
|
import datetime
from django.contrib.localflavor.generic.forms import DateField, DateTimeField
from utils import LocalFlavorTestCase
class GenericLocalFlavorTests(LocalFlavorTestCase):
def test_GenericDateField(self):
error_invalid = [u'Enter a valid date.']
valid = {
datetime.date(2006, 10, 25): datetime.date(2006, 10, 25),
datetime.datetime(2006, 10, 25, 14, 30): datetime.date(2006, 10, 25),
datetime.datetime(2006, 10, 25, 14, 30, 59): datetime.date(2006, 10, 25),
datetime.datetime(2006, 10, 25, 14, 30, 59, 200): datetime.date(2006, 10, 25),
'2006-10-25': datetime.date(2006, 10, 25),
'25/10/2006': datetime.date(2006, 10, 25),
'25/10/06': datetime.date(2006, 10, 25),
'Oct 25 2006': datetime.date(2006, 10, 25),
'October 25 2006': datetime.date(2006, 10, 25),
'October 25, 2006': datetime.date(2006, 10, 25),
'25 October 2006': datetime.date(2006, 10, 25),
'25 October, 2006': datetime.date(2006, 10, 25),
}
invalid = {
'2006-4-31': error_invalid,
'200a-10-25': error_invalid,
'10/25/06': error_invalid,
}
self.assertFieldOutput(DateField, valid, invalid, empty_value=None)
# DateField with optional input_formats parameter
valid = {
datetime.date(2006, 10, 25): datetime.date(2006, 10, 25),
datetime.datetime(2006, 10, 25, 14, 30): datetime.date(2006, 10, 25),
'2006 10 25': datetime.date(2006, 10, 25),
}
invalid = {
'2006-10-25': error_invalid,
'25/10/2006': error_invalid,
'25/10/06': error_invalid,
}
kwargs = {'input_formats':['%Y %m %d'],}
self.assertFieldOutput(DateField,
valid, invalid, field_kwargs=kwargs, empty_value=None
)
def test_GenericDateTimeField(self):
error_invalid = [u'Enter a valid date/time.']
valid = {
datetime.date(2006, 10, 25): datetime.datetime(2006, 10, 25, 0, 0),
datetime.datetime(2006, 10, 25, 14, 30): datetime.datetime(2006, 10, 25, 14, 30),
datetime.datetime(2006, 10, 25, 14, 30, 59): datetime.datetime(2006, 10, 25, 14, 30, 59),
datetime.datetime(2006, 10, 25, 14, 30, 59, 200): datetime.datetime(2006, 10, 25, 14, 30, 59, 200),
'2006-10-25 14:30:45': datetime.datetime(2006, 10, 25, 14, 30, 45),
'2006-10-25 14:30:00': datetime.datetime(2006, 10, 25, 14, 30),
'2006-10-25 14:30': datetime.datetime(2006, 10, 25, 14, 30),
'2006-10-25': datetime.datetime(2006, 10, 25, 0, 0),
'25/10/2006 14:30:45': datetime.datetime(2006, 10, 25, 14, 30, 45),
'25/10/2006 14:30:00': datetime.datetime(2006, 10, 25, 14, 30),
'25/10/2006 14:30': datetime.datetime(2006, 10, 25, 14, 30),
'25/10/2006': datetime.datetime(2006, 10, 25, 0, 0),
'25/10/06 14:30:45': datetime.datetime(2006, 10, 25, 14, 30, 45),
'25/10/06 14:30:00': datetime.datetime(2006, 10, 25, 14, 30),
'25/10/06 14:30': datetime.datetime(2006, 10, 25, 14, 30),
'25/10/06': datetime.datetime(2006, 10, 25, 0, 0),
}
invalid = {
'hello': error_invalid,
'2006-10-25 4:30 p.m.': error_invalid,
}
self.assertFieldOutput(DateTimeField, valid, invalid, empty_value=None)
# DateTimeField with optional input_formats paramter
valid = {
datetime.date(2006, 10, 25): datetime.datetime(2006, 10, 25, 0, 0),
datetime.datetime(2006, 10, 25, 14, 30): datetime.datetime(2006, 10, 25, 14, 30),
datetime.datetime(2006, 10, 25, 14, 30, 59): datetime.datetime(2006, 10, 25, 14, 30, 59),
datetime.datetime(2006, 10, 25, 14, 30, 59, 200): datetime.datetime(2006, 10, 25, 14, 30, 59, 200),
'2006 10 25 2:30 PM': datetime.datetime(2006, 10, 25, 14, 30),
}
invalid = {
'2006-10-25 14:30:45': error_invalid,
}
kwargs = {'input_formats':['%Y %m %d %I:%M %p'],}
self.assertFieldOutput(DateTimeField,
valid, invalid, field_kwargs=kwargs, empty_value=None
)
|
bsd-3-clause
|
[
646,
2197,
199,
199,
504,
1639,
14,
2828,
14,
320,
696,
276,
4271,
14,
6767,
14,
3351,
492,
30997,
12,
31637,
199,
199,
504,
3778,
492,
10111,
16739,
1746,
421,
199,
533,
8307,
5339,
16739,
2925,
8,
5339,
16739,
1746,
304,
272,
347,
511,
63,
9417,
14071,
8,
277,
304,
267,
1125,
63,
3197,
275,
359,
85,
7,
8468,
282,
1686,
1434,
14,
418,
267,
1686,
275,
469,
288,
2197,
14,
602,
8,
7968,
12,
1616,
12,
5661,
304,
2197,
14,
602,
8,
7968,
12,
1616,
12,
5661,
395,
288,
2197,
14,
2083,
8,
7968,
12,
1616,
12,
5661,
12,
4329,
12,
4233,
304,
2197,
14,
602,
8,
7968,
12,
1616,
12,
5661,
395,
288,
2197,
14,
2083,
8,
7968,
12,
1616,
12,
5661,
12,
4329,
12,
4233,
12,
8155,
304,
2197,
14,
602,
8,
7968,
12,
1616,
12,
5661,
395,
288,
2197,
14,
2083,
8,
7968,
12,
1616,
12,
5661,
12,
4329,
12,
4233,
12,
8155,
12,
1926,
304,
2197,
14,
602,
8,
7968,
12,
1616,
12,
5661,
395,
288,
283,
7968,
13,
709,
13,
821,
356,
2197,
14,
602,
8,
7968,
12,
1616,
12,
5661,
395,
288,
283,
821,
15,
709,
15,
7968,
356,
2197,
14,
602,
8,
7968,
12,
1616,
12,
5661,
395,
288,
283,
821,
15,
709,
15,
1690,
356,
2197,
14,
602,
8,
7968,
12,
1616,
12,
5661,
395,
288,
283,
17584,
5661,
8315,
356,
2197,
14,
602,
8,
7968,
12,
1616,
12,
5661,
395,
288,
283,
17584,
22459,
5661,
8315,
356,
2197,
14,
602,
8,
7968,
12,
1616,
12,
5661,
395,
288,
283,
17584,
22459,
5661,
12,
8315,
356,
2197,
14,
602,
8,
7968,
12,
1616,
12,
5661,
395,
288,
283,
821,
18365,
22459,
8315,
356,
2197,
14,
602,
8,
7968,
12,
1616,
12,
5661,
395,
288,
283,
821,
18365,
22459,
12,
8315,
356,
2197,
14,
602,
8,
7968,
12,
1616,
12,
5661,
395,
267,
789,
267,
3866,
275,
469,
288,
283,
7968,
13,
20,
13,
2192,
356,
1125,
63,
3197,
12,
288,
283,
1840,
65,
13,
709,
13,
821,
356,
1125,
63,
3197,
12,
288,
283,
709,
15,
821,
15,
1690,
356,
1125,
63,
3197,
12,
267,
789,
267,
291,
14,
479,
792,
2959,
8,
14071,
12,
1686,
12,
3866,
12,
2701,
63,
585,
29,
403,
9,
398,
327,
30997,
543,
2716,
1324,
63,
6321,
2725,
267,
1686,
275,
469,
288,
2197,
14,
602,
8,
7968,
12,
1616,
12,
5661,
304,
2197,
14,
602,
8,
7968,
12,
1616,
12,
5661,
395,
288,
2197,
14,
2083,
8,
7968,
12,
1616,
12,
5661,
12,
4329,
12,
4233,
304,
2197,
14,
602,
8,
7968,
12,
1616,
12,
5661,
395,
288,
283,
7968,
1616,
5661,
356,
2197,
14,
602,
8,
7968,
12,
1616,
12,
5661,
395,
267,
789,
267,
3866,
275,
469,
288,
283,
7968,
13,
709,
13,
821,
356,
1125,
63,
3197,
12,
288,
283,
821,
15,
709,
15,
7968,
356,
1125,
63,
3197,
12,
288,
283,
821,
15,
709,
15,
1690,
356,
1125,
63,
3197,
12,
267,
789,
267,
2074,
275,
791,
1210,
63,
6321,
356,
13890,
57,
450,
77,
450,
68,
995,
93,
267,
291,
14,
479,
792,
2959,
8,
14071,
12,
288,
1686,
12,
3866,
12,
901,
63,
958,
29,
958,
12,
2701,
63,
585,
29,
403,
267,
776,
339,
347,
511,
63,
9417,
4626,
8,
277,
304,
267,
1125,
63,
3197,
275,
359,
85,
7,
8468,
282,
1686,
1434,
15,
521,
14,
418,
267,
1686,
275,
469,
288,
2197,
14,
602,
8,
7968,
12,
1616,
12,
5661,
304,
2197,
14,
2083,
8,
7968,
12,
1616,
12,
5661,
12,
378,
12,
378,
395,
288,
2197,
14,
2083,
8,
7968,
12,
1616,
12,
5661,
12,
4329,
12,
4233,
304,
2197,
14,
2083,
8,
7968,
12,
1616,
12,
5661,
12,
4329,
12,
4233,
395,
288,
2197,
14,
2083,
8,
7968,
12,
1616,
12,
5661,
12,
4329,
12,
4233,
12,
8155,
304,
2197,
14,
2083,
8,
7968,
12,
1616,
12,
5661,
12,
4329,
12,
4233,
12,
8155,
395,
288,
2197,
14,
2083,
8,
7968,
12,
1616,
12,
5661,
12,
4329,
12,
4233,
12,
8155,
12,
1926,
304,
2197,
14,
2083,
8,
7968,
12,
1616,
12,
5661,
12,
4329,
12,
4233,
12,
8155,
12,
1926,
395,
288,
283,
7968,
13,
709,
13,
821,
4329,
26,
1216,
26,
2322,
356,
2197,
14,
2083,
8,
7968,
12,
1616,
12,
5661,
12,
4329,
12,
4233,
12,
10416,
395,
288,
283,
7968,
13,
709,
13,
821,
4329,
26,
1216,
26,
383,
356,
2197,
14,
2083,
8,
7968,
12,
1616,
12,
5661,
12,
4329,
12,
4233,
395,
288,
283,
7968,
13,
709,
13,
821,
4329,
26,
1216,
356,
2197,
14,
2083,
8,
7968,
12,
1616,
12,
5661,
12,
4329,
12,
4233,
395,
288,
283,
7968,
13,
709,
13,
821,
356,
2197,
14,
2083,
8,
7968,
12,
1616,
12,
5661,
12,
378,
12,
378,
395,
288,
283,
821,
15,
709,
15,
7968,
4329,
26,
1216,
26,
2322,
356,
2197,
14,
2083,
8,
7968,
12,
1616,
12,
5661,
12,
4329,
12,
4233,
12,
10416,
395,
288,
283,
821,
15,
709,
15,
7968,
4329,
26,
1216,
26,
383,
356,
2197,
14,
2083,
8,
7968,
12,
1616,
12,
5661,
12,
4329,
12,
4233,
395,
288,
283,
821,
15,
709,
15,
7968,
4329,
26,
1216,
356,
2197,
14,
2083,
8,
7968,
12,
1616,
12,
5661,
12,
4329,
12,
4233,
395,
288,
283,
821,
15,
709,
15,
7968,
356,
2197,
14,
2083,
8,
7968,
12,
1616,
12,
5661,
12,
378,
12,
378,
395,
288,
283,
821,
15,
709,
15,
1690,
4329,
26,
1216,
26,
2322,
356,
2197,
14,
2083,
8,
7968,
12,
1616,
12,
5661,
12,
4329,
12,
4233,
12,
10416,
395,
288,
283,
821,
15,
709,
15,
1690,
4329,
26,
1216,
26,
383,
356,
2197,
14,
2083,
8,
7968,
12,
1616,
12,
5661,
12,
4329,
12,
4233,
395,
288,
283,
821,
15,
709,
15,
1690,
4329,
26,
1216,
356,
2197,
14,
2083,
8,
7968,
12,
1616,
12,
5661,
12,
4329,
12,
4233,
395,
288,
283,
821,
15,
709,
15,
1690,
356,
2197,
14,
2083,
8,
7968,
12,
1616,
12,
5661,
12,
378,
12,
378,
395,
267,
789,
267,
3866,
275,
469,
288,
283,
5006,
356,
1125,
63,
3197,
12,
288,
283,
7968,
13,
709,
13,
821,
841,
26,
1216,
299,
14
] |
[
2197,
199,
199,
504,
1639,
14,
2828,
14,
320,
696,
276,
4271,
14,
6767,
14,
3351,
492,
30997,
12,
31637,
199,
199,
504,
3778,
492,
10111,
16739,
1746,
421,
199,
533,
8307,
5339,
16739,
2925,
8,
5339,
16739,
1746,
304,
272,
347,
511,
63,
9417,
14071,
8,
277,
304,
267,
1125,
63,
3197,
275,
359,
85,
7,
8468,
282,
1686,
1434,
14,
418,
267,
1686,
275,
469,
288,
2197,
14,
602,
8,
7968,
12,
1616,
12,
5661,
304,
2197,
14,
602,
8,
7968,
12,
1616,
12,
5661,
395,
288,
2197,
14,
2083,
8,
7968,
12,
1616,
12,
5661,
12,
4329,
12,
4233,
304,
2197,
14,
602,
8,
7968,
12,
1616,
12,
5661,
395,
288,
2197,
14,
2083,
8,
7968,
12,
1616,
12,
5661,
12,
4329,
12,
4233,
12,
8155,
304,
2197,
14,
602,
8,
7968,
12,
1616,
12,
5661,
395,
288,
2197,
14,
2083,
8,
7968,
12,
1616,
12,
5661,
12,
4329,
12,
4233,
12,
8155,
12,
1926,
304,
2197,
14,
602,
8,
7968,
12,
1616,
12,
5661,
395,
288,
283,
7968,
13,
709,
13,
821,
356,
2197,
14,
602,
8,
7968,
12,
1616,
12,
5661,
395,
288,
283,
821,
15,
709,
15,
7968,
356,
2197,
14,
602,
8,
7968,
12,
1616,
12,
5661,
395,
288,
283,
821,
15,
709,
15,
1690,
356,
2197,
14,
602,
8,
7968,
12,
1616,
12,
5661,
395,
288,
283,
17584,
5661,
8315,
356,
2197,
14,
602,
8,
7968,
12,
1616,
12,
5661,
395,
288,
283,
17584,
22459,
5661,
8315,
356,
2197,
14,
602,
8,
7968,
12,
1616,
12,
5661,
395,
288,
283,
17584,
22459,
5661,
12,
8315,
356,
2197,
14,
602,
8,
7968,
12,
1616,
12,
5661,
395,
288,
283,
821,
18365,
22459,
8315,
356,
2197,
14,
602,
8,
7968,
12,
1616,
12,
5661,
395,
288,
283,
821,
18365,
22459,
12,
8315,
356,
2197,
14,
602,
8,
7968,
12,
1616,
12,
5661,
395,
267,
789,
267,
3866,
275,
469,
288,
283,
7968,
13,
20,
13,
2192,
356,
1125,
63,
3197,
12,
288,
283,
1840,
65,
13,
709,
13,
821,
356,
1125,
63,
3197,
12,
288,
283,
709,
15,
821,
15,
1690,
356,
1125,
63,
3197,
12,
267,
789,
267,
291,
14,
479,
792,
2959,
8,
14071,
12,
1686,
12,
3866,
12,
2701,
63,
585,
29,
403,
9,
398,
327,
30997,
543,
2716,
1324,
63,
6321,
2725,
267,
1686,
275,
469,
288,
2197,
14,
602,
8,
7968,
12,
1616,
12,
5661,
304,
2197,
14,
602,
8,
7968,
12,
1616,
12,
5661,
395,
288,
2197,
14,
2083,
8,
7968,
12,
1616,
12,
5661,
12,
4329,
12,
4233,
304,
2197,
14,
602,
8,
7968,
12,
1616,
12,
5661,
395,
288,
283,
7968,
1616,
5661,
356,
2197,
14,
602,
8,
7968,
12,
1616,
12,
5661,
395,
267,
789,
267,
3866,
275,
469,
288,
283,
7968,
13,
709,
13,
821,
356,
1125,
63,
3197,
12,
288,
283,
821,
15,
709,
15,
7968,
356,
1125,
63,
3197,
12,
288,
283,
821,
15,
709,
15,
1690,
356,
1125,
63,
3197,
12,
267,
789,
267,
2074,
275,
791,
1210,
63,
6321,
356,
13890,
57,
450,
77,
450,
68,
995,
93,
267,
291,
14,
479,
792,
2959,
8,
14071,
12,
288,
1686,
12,
3866,
12,
901,
63,
958,
29,
958,
12,
2701,
63,
585,
29,
403,
267,
776,
339,
347,
511,
63,
9417,
4626,
8,
277,
304,
267,
1125,
63,
3197,
275,
359,
85,
7,
8468,
282,
1686,
1434,
15,
521,
14,
418,
267,
1686,
275,
469,
288,
2197,
14,
602,
8,
7968,
12,
1616,
12,
5661,
304,
2197,
14,
2083,
8,
7968,
12,
1616,
12,
5661,
12,
378,
12,
378,
395,
288,
2197,
14,
2083,
8,
7968,
12,
1616,
12,
5661,
12,
4329,
12,
4233,
304,
2197,
14,
2083,
8,
7968,
12,
1616,
12,
5661,
12,
4329,
12,
4233,
395,
288,
2197,
14,
2083,
8,
7968,
12,
1616,
12,
5661,
12,
4329,
12,
4233,
12,
8155,
304,
2197,
14,
2083,
8,
7968,
12,
1616,
12,
5661,
12,
4329,
12,
4233,
12,
8155,
395,
288,
2197,
14,
2083,
8,
7968,
12,
1616,
12,
5661,
12,
4329,
12,
4233,
12,
8155,
12,
1926,
304,
2197,
14,
2083,
8,
7968,
12,
1616,
12,
5661,
12,
4329,
12,
4233,
12,
8155,
12,
1926,
395,
288,
283,
7968,
13,
709,
13,
821,
4329,
26,
1216,
26,
2322,
356,
2197,
14,
2083,
8,
7968,
12,
1616,
12,
5661,
12,
4329,
12,
4233,
12,
10416,
395,
288,
283,
7968,
13,
709,
13,
821,
4329,
26,
1216,
26,
383,
356,
2197,
14,
2083,
8,
7968,
12,
1616,
12,
5661,
12,
4329,
12,
4233,
395,
288,
283,
7968,
13,
709,
13,
821,
4329,
26,
1216,
356,
2197,
14,
2083,
8,
7968,
12,
1616,
12,
5661,
12,
4329,
12,
4233,
395,
288,
283,
7968,
13,
709,
13,
821,
356,
2197,
14,
2083,
8,
7968,
12,
1616,
12,
5661,
12,
378,
12,
378,
395,
288,
283,
821,
15,
709,
15,
7968,
4329,
26,
1216,
26,
2322,
356,
2197,
14,
2083,
8,
7968,
12,
1616,
12,
5661,
12,
4329,
12,
4233,
12,
10416,
395,
288,
283,
821,
15,
709,
15,
7968,
4329,
26,
1216,
26,
383,
356,
2197,
14,
2083,
8,
7968,
12,
1616,
12,
5661,
12,
4329,
12,
4233,
395,
288,
283,
821,
15,
709,
15,
7968,
4329,
26,
1216,
356,
2197,
14,
2083,
8,
7968,
12,
1616,
12,
5661,
12,
4329,
12,
4233,
395,
288,
283,
821,
15,
709,
15,
7968,
356,
2197,
14,
2083,
8,
7968,
12,
1616,
12,
5661,
12,
378,
12,
378,
395,
288,
283,
821,
15,
709,
15,
1690,
4329,
26,
1216,
26,
2322,
356,
2197,
14,
2083,
8,
7968,
12,
1616,
12,
5661,
12,
4329,
12,
4233,
12,
10416,
395,
288,
283,
821,
15,
709,
15,
1690,
4329,
26,
1216,
26,
383,
356,
2197,
14,
2083,
8,
7968,
12,
1616,
12,
5661,
12,
4329,
12,
4233,
395,
288,
283,
821,
15,
709,
15,
1690,
4329,
26,
1216,
356,
2197,
14,
2083,
8,
7968,
12,
1616,
12,
5661,
12,
4329,
12,
4233,
395,
288,
283,
821,
15,
709,
15,
1690,
356,
2197,
14,
2083,
8,
7968,
12,
1616,
12,
5661,
12,
378,
12,
378,
395,
267,
789,
267,
3866,
275,
469,
288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,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
adedayo/intellij-community
|
python/helpers/pydev/pydev_runfiles.py
|
52
|
30194
|
from __future__ import nested_scopes
import fnmatch
import os.path
from pydev_runfiles_coverage import StartCoverageSupport
from pydevd_constants import * #@UnusedWildImport
import re
import time
#=======================================================================================================================
# Configuration
#=======================================================================================================================
class Configuration:
def __init__(
self,
files_or_dirs='',
verbosity=2,
include_tests=None,
tests=None,
port=None,
files_to_tests=None,
jobs=1,
split_jobs='tests',
coverage_output_dir=None,
coverage_include=None,
coverage_output_file=None,
exclude_files=None,
exclude_tests=None,
include_files=None,
django=False,
):
self.files_or_dirs = files_or_dirs
self.verbosity = verbosity
self.include_tests = include_tests
self.tests = tests
self.port = port
self.files_to_tests = files_to_tests
self.jobs = jobs
self.split_jobs = split_jobs
self.django = django
if include_tests:
assert isinstance(include_tests, (list, tuple))
if exclude_files:
assert isinstance(exclude_files, (list, tuple))
if exclude_tests:
assert isinstance(exclude_tests, (list, tuple))
self.exclude_files = exclude_files
self.include_files = include_files
self.exclude_tests = exclude_tests
self.coverage_output_dir = coverage_output_dir
self.coverage_include = coverage_include
self.coverage_output_file = coverage_output_file
def __str__(self):
return '''Configuration
- files_or_dirs: %s
- verbosity: %s
- tests: %s
- port: %s
- files_to_tests: %s
- jobs: %s
- split_jobs: %s
- include_files: %s
- include_tests: %s
- exclude_files: %s
- exclude_tests: %s
- coverage_output_dir: %s
- coverage_include_dir: %s
- coverage_output_file: %s
- django: %s
''' % (
self.files_or_dirs,
self.verbosity,
self.tests,
self.port,
self.files_to_tests,
self.jobs,
self.split_jobs,
self.include_files,
self.include_tests,
self.exclude_files,
self.exclude_tests,
self.coverage_output_dir,
self.coverage_include,
self.coverage_output_file,
self.django,
)
#=======================================================================================================================
# parse_cmdline
#=======================================================================================================================
def parse_cmdline(argv=None):
"""
Parses command line and returns test directories, verbosity, test filter and test suites
usage:
runfiles.py -v|--verbosity <level> -t|--tests <Test.test1,Test2> dirs|files
Multiprocessing options:
jobs=number (with the number of jobs to be used to run the tests)
split_jobs='module'|'tests'
if == module, a given job will always receive all the tests from a module
if == tests, the tests will be split independently of their originating module (default)
--exclude_files = comma-separated list of patterns with files to exclude (fnmatch style)
--include_files = comma-separated list of patterns with files to include (fnmatch style)
--exclude_tests = comma-separated list of patterns with test names to exclude (fnmatch style)
Note: if --tests is given, --exclude_files, --include_files and --exclude_tests are ignored!
"""
if argv is None:
argv = sys.argv
verbosity = 2
include_tests = None
tests = None
port = None
jobs = 1
split_jobs = 'tests'
files_to_tests = {}
coverage_output_dir = None
coverage_include = None
exclude_files = None
exclude_tests = None
include_files = None
django = False
from _pydev_getopt import gnu_getopt
optlist, dirs = gnu_getopt(
argv[1:], "",
[
"verbosity=",
"tests=",
"port=",
"config_file=",
"jobs=",
"split_jobs=",
"include_tests=",
"include_files=",
"exclude_files=",
"exclude_tests=",
"coverage_output_dir=",
"coverage_include=",
"django="
]
)
for opt, value in optlist:
if opt in ("-v", "--verbosity"):
verbosity = value
elif opt in ("-p", "--port"):
port = int(value)
elif opt in ("-j", "--jobs"):
jobs = int(value)
elif opt in ("-s", "--split_jobs"):
split_jobs = value
if split_jobs not in ('module', 'tests'):
raise AssertionError('Expected split to be either "module" or "tests". Was :%s' % (split_jobs,))
elif opt in ("-d", "--coverage_output_dir",):
coverage_output_dir = value.strip()
elif opt in ("-i", "--coverage_include",):
coverage_include = value.strip()
elif opt in ("-I", "--include_tests"):
include_tests = value.split(',')
elif opt in ("-E", "--exclude_files"):
exclude_files = value.split(',')
elif opt in ("-F", "--include_files"):
include_files = value.split(',')
elif opt in ("-e", "--exclude_tests"):
exclude_tests = value.split(',')
elif opt in ("-t", "--tests"):
tests = value.split(',')
elif opt in ("--django",):
django = value.strip() in ['true', 'True', '1']
elif opt in ("-c", "--config_file"):
config_file = value.strip()
if os.path.exists(config_file):
f = open(config_file, 'rU')
try:
config_file_contents = f.read()
finally:
f.close()
if config_file_contents:
config_file_contents = config_file_contents.strip()
if config_file_contents:
for line in config_file_contents.splitlines():
file_and_test = line.split('|')
if len(file_and_test) == 2:
file, test = file_and_test
if DictContains(files_to_tests, file):
files_to_tests[file].append(test)
else:
files_to_tests[file] = [test]
else:
sys.stderr.write('Could not find config file: %s\n' % (config_file,))
if type([]) != type(dirs):
dirs = [dirs]
ret_dirs = []
for d in dirs:
if '|' in d:
#paths may come from the ide separated by |
ret_dirs.extend(d.split('|'))
else:
ret_dirs.append(d)
verbosity = int(verbosity)
if tests:
if verbosity > 4:
sys.stdout.write('--tests provided. Ignoring --exclude_files, --exclude_tests and --include_files\n')
exclude_files = exclude_tests = include_files = None
config = Configuration(
ret_dirs,
verbosity,
include_tests,
tests,
port,
files_to_tests,
jobs,
split_jobs,
coverage_output_dir,
coverage_include,
exclude_files=exclude_files,
exclude_tests=exclude_tests,
include_files=include_files,
django=django,
)
if verbosity > 5:
sys.stdout.write(str(config) + '\n')
return config
#=======================================================================================================================
# PydevTestRunner
#=======================================================================================================================
class PydevTestRunner(object):
""" finds and runs a file or directory of files as a unit test """
__py_extensions = ["*.py", "*.pyw"]
__exclude_files = ["__init__.*"]
#Just to check that only this attributes will be written to this file
__slots__ = [
'verbosity', #Always used
'files_to_tests', #If this one is given, the ones below are not used
'files_or_dirs', #Files or directories received in the command line
'include_tests', #The filter used to collect the tests
'tests', #Strings with the tests to be run
'jobs', #Integer with the number of jobs that should be used to run the test cases
'split_jobs', #String with 'tests' or 'module' (how should the jobs be split)
'configuration',
'coverage',
]
def __init__(self, configuration):
self.verbosity = configuration.verbosity
self.jobs = configuration.jobs
self.split_jobs = configuration.split_jobs
files_to_tests = configuration.files_to_tests
if files_to_tests:
self.files_to_tests = files_to_tests
self.files_or_dirs = list(files_to_tests.keys())
self.tests = None
else:
self.files_to_tests = {}
self.files_or_dirs = configuration.files_or_dirs
self.tests = configuration.tests
self.configuration = configuration
self.__adjust_path()
def __adjust_path(self):
""" add the current file or directory to the python path """
path_to_append = None
for n in xrange(len(self.files_or_dirs)):
dir_name = self.__unixify(self.files_or_dirs[n])
if os.path.isdir(dir_name):
if not dir_name.endswith("/"):
self.files_or_dirs[n] = dir_name + "/"
path_to_append = os.path.normpath(dir_name)
elif os.path.isfile(dir_name):
path_to_append = os.path.dirname(dir_name)
else:
if not os.path.exists(dir_name):
block_line = '*' * 120
sys.stderr.write('\n%s\n* PyDev test runner error: %s does not exist.\n%s\n' % (block_line, dir_name, block_line))
return
msg = ("unknown type. \n%s\nshould be file or a directory.\n" % (dir_name))
raise RuntimeError(msg)
if path_to_append is not None:
#Add it as the last one (so, first things are resolved against the default dirs and
#if none resolves, then we try a relative import).
sys.path.append(path_to_append)
def __is_valid_py_file(self, fname):
""" tests that a particular file contains the proper file extension
and is not in the list of files to exclude """
is_valid_fname = 0
for invalid_fname in self.__class__.__exclude_files:
is_valid_fname += int(not fnmatch.fnmatch(fname, invalid_fname))
if_valid_ext = 0
for ext in self.__class__.__py_extensions:
if_valid_ext += int(fnmatch.fnmatch(fname, ext))
return is_valid_fname > 0 and if_valid_ext > 0
def __unixify(self, s):
""" stupid windows. converts the backslash to forwardslash for consistency """
return os.path.normpath(s).replace(os.sep, "/")
def __importify(self, s, dir=False):
""" turns directory separators into dots and removes the ".py*" extension
so the string can be used as import statement """
if not dir:
dirname, fname = os.path.split(s)
if fname.count('.') > 1:
#if there's a file named xxx.xx.py, it is not a valid module, so, let's not load it...
return
imp_stmt_pieces = [dirname.replace("\\", "/").replace("/", "."), os.path.splitext(fname)[0]]
if len(imp_stmt_pieces[0]) == 0:
imp_stmt_pieces = imp_stmt_pieces[1:]
return ".".join(imp_stmt_pieces)
else: #handle dir
return s.replace("\\", "/").replace("/", ".")
def __add_files(self, pyfiles, root, files):
""" if files match, appends them to pyfiles. used by os.path.walk fcn """
for fname in files:
if self.__is_valid_py_file(fname):
name_without_base_dir = self.__unixify(os.path.join(root, fname))
pyfiles.append(name_without_base_dir)
def find_import_files(self):
""" return a list of files to import """
if self.files_to_tests:
pyfiles = self.files_to_tests.keys()
else:
pyfiles = []
for base_dir in self.files_or_dirs:
if os.path.isdir(base_dir):
if hasattr(os, 'walk'):
for root, dirs, files in os.walk(base_dir):
#Note: handling directories that should be excluded from the search because
#they don't have __init__.py
exclude = {}
for d in dirs:
for init in ['__init__.py', '__init__.pyo', '__init__.pyc', '__init__.pyw']:
if os.path.exists(os.path.join(root, d, init).replace('\\', '/')):
break
else:
exclude[d] = 1
if exclude:
new = []
for d in dirs:
if d not in exclude:
new.append(d)
dirs[:] = new
self.__add_files(pyfiles, root, files)
else:
# jython2.1 is too old for os.walk!
os.path.walk(base_dir, self.__add_files, pyfiles)
elif os.path.isfile(base_dir):
pyfiles.append(base_dir)
if self.configuration.exclude_files or self.configuration.include_files:
ret = []
for f in pyfiles:
add = True
basename = os.path.basename(f)
if self.configuration.include_files:
add = False
for pat in self.configuration.include_files:
if fnmatch.fnmatchcase(basename, pat):
add = True
break
if not add:
if self.verbosity > 3:
sys.stdout.write('Skipped file: %s (did not match any include_files pattern: %s)\n' % (f, self.configuration.include_files))
elif self.configuration.exclude_files:
for pat in self.configuration.exclude_files:
if fnmatch.fnmatchcase(basename, pat):
if self.verbosity > 3:
sys.stdout.write('Skipped file: %s (matched exclude_files pattern: %s)\n' % (f, pat))
elif self.verbosity > 2:
sys.stdout.write('Skipped file: %s\n' % (f,))
add = False
break
if add:
if self.verbosity > 3:
sys.stdout.write('Adding file: %s for test discovery.\n' % (f,))
ret.append(f)
pyfiles = ret
return pyfiles
def __get_module_from_str(self, modname, print_exception, pyfile):
""" Import the module in the given import path.
* Returns the "final" module, so importing "coilib40.subject.visu"
returns the "visu" module, not the "coilib40" as returned by __import__ """
try:
mod = __import__(modname)
for part in modname.split('.')[1:]:
mod = getattr(mod, part)
return mod
except:
if print_exception:
import pydev_runfiles_xml_rpc
import pydevd_io
buf_err = pydevd_io.StartRedirect(keep_original_redirection=True, std='stderr')
buf_out = pydevd_io.StartRedirect(keep_original_redirection=True, std='stdout')
try:
import traceback;traceback.print_exc()
sys.stderr.write('ERROR: Module: %s could not be imported (file: %s).\n' % (modname, pyfile))
finally:
pydevd_io.EndRedirect('stderr')
pydevd_io.EndRedirect('stdout')
pydev_runfiles_xml_rpc.notifyTest(
'error', buf_out.getvalue(), buf_err.getvalue(), pyfile, modname, 0)
return None
def find_modules_from_files(self, pyfiles):
""" returns a list of modules given a list of files """
#let's make sure that the paths we want are in the pythonpath...
imports = [(s, self.__importify(s)) for s in pyfiles]
system_paths = []
for s in sys.path:
system_paths.append(self.__importify(s, True))
ret = []
for pyfile, imp in imports:
if imp is None:
continue #can happen if a file is not a valid module
choices = []
for s in system_paths:
if imp.startswith(s):
add = imp[len(s) + 1:]
if add:
choices.append(add)
#sys.stdout.write(' ' + add + ' ')
if not choices:
sys.stdout.write('PYTHONPATH not found for file: %s\n' % imp)
else:
for i, import_str in enumerate(choices):
print_exception = i == len(choices) - 1
mod = self.__get_module_from_str(import_str, print_exception, pyfile)
if mod is not None:
ret.append((pyfile, mod, import_str))
break
return ret
#===================================================================================================================
# GetTestCaseNames
#===================================================================================================================
class GetTestCaseNames:
"""Yes, we need a class for that (cannot use outer context on jython 2.1)"""
def __init__(self, accepted_classes, accepted_methods):
self.accepted_classes = accepted_classes
self.accepted_methods = accepted_methods
def __call__(self, testCaseClass):
"""Return a sorted sequence of method names found within testCaseClass"""
testFnNames = []
className = testCaseClass.__name__
if DictContains(self.accepted_classes, className):
for attrname in dir(testCaseClass):
#If a class is chosen, we select all the 'test' methods'
if attrname.startswith('test') and hasattr(getattr(testCaseClass, attrname), '__call__'):
testFnNames.append(attrname)
else:
for attrname in dir(testCaseClass):
#If we have the class+method name, we must do a full check and have an exact match.
if DictContains(self.accepted_methods, className + '.' + attrname):
if hasattr(getattr(testCaseClass, attrname), '__call__'):
testFnNames.append(attrname)
#sorted() is not available in jython 2.1
testFnNames.sort()
return testFnNames
def _decorate_test_suite(self, suite, pyfile, module_name):
import unittest
if isinstance(suite, unittest.TestSuite):
add = False
suite.__pydev_pyfile__ = pyfile
suite.__pydev_module_name__ = module_name
for t in suite._tests:
t.__pydev_pyfile__ = pyfile
t.__pydev_module_name__ = module_name
if self._decorate_test_suite(t, pyfile, module_name):
add = True
return add
elif isinstance(suite, unittest.TestCase):
return True
else:
return False
def find_tests_from_modules(self, file_and_modules_and_module_name):
""" returns the unittests given a list of modules """
#Use our own suite!
import pydev_runfiles_unittest
import unittest
unittest.TestLoader.suiteClass = pydev_runfiles_unittest.PydevTestSuite
loader = unittest.TestLoader()
ret = []
if self.files_to_tests:
for pyfile, m, module_name in file_and_modules_and_module_name:
accepted_classes = {}
accepted_methods = {}
tests = self.files_to_tests[pyfile]
for t in tests:
accepted_methods[t] = t
loader.getTestCaseNames = self.GetTestCaseNames(accepted_classes, accepted_methods)
suite = loader.loadTestsFromModule(m)
if self._decorate_test_suite(suite, pyfile, module_name):
ret.append(suite)
return ret
if self.tests:
accepted_classes = {}
accepted_methods = {}
for t in self.tests:
splitted = t.split('.')
if len(splitted) == 1:
accepted_classes[t] = t
elif len(splitted) == 2:
accepted_methods[t] = t
loader.getTestCaseNames = self.GetTestCaseNames(accepted_classes, accepted_methods)
for pyfile, m, module_name in file_and_modules_and_module_name:
suite = loader.loadTestsFromModule(m)
if self._decorate_test_suite(suite, pyfile, module_name):
ret.append(suite)
return ret
def filter_tests(self, test_objs, internal_call=False):
""" based on a filter name, only return those tests that have
the test case names that match """
import unittest
if not internal_call:
if not self.configuration.include_tests and not self.tests and not self.configuration.exclude_tests:
#No need to filter if we have nothing to filter!
return test_objs
if self.verbosity > 1:
if self.configuration.include_tests:
sys.stdout.write('Tests to include: %s\n' % (self.configuration.include_tests,))
if self.tests:
sys.stdout.write('Tests to run: %s\n' % (self.tests,))
if self.configuration.exclude_tests:
sys.stdout.write('Tests to exclude: %s\n' % (self.configuration.exclude_tests,))
test_suite = []
for test_obj in test_objs:
if isinstance(test_obj, unittest.TestSuite):
#Note: keep the suites as they are and just 'fix' the tests (so, don't use the iter_tests).
if test_obj._tests:
test_obj._tests = self.filter_tests(test_obj._tests, True)
if test_obj._tests: #Only add the suite if we still have tests there.
test_suite.append(test_obj)
elif isinstance(test_obj, unittest.TestCase):
try:
testMethodName = test_obj._TestCase__testMethodName
except AttributeError:
#changed in python 2.5
testMethodName = test_obj._testMethodName
add = True
if self.configuration.exclude_tests:
for pat in self.configuration.exclude_tests:
if fnmatch.fnmatchcase(testMethodName, pat):
if self.verbosity > 3:
sys.stdout.write('Skipped test: %s (matched exclude_tests pattern: %s)\n' % (testMethodName, pat))
elif self.verbosity > 2:
sys.stdout.write('Skipped test: %s\n' % (testMethodName,))
add = False
break
if add:
if self.__match_tests(self.tests, test_obj, testMethodName):
include = True
if self.configuration.include_tests:
include = False
for pat in self.configuration.include_tests:
if fnmatch.fnmatchcase(testMethodName, pat):
include = True
break
if include:
test_suite.append(test_obj)
else:
if self.verbosity > 3:
sys.stdout.write('Skipped test: %s (did not match any include_tests pattern %s)\n' % (self.configuration.include_tests,))
return test_suite
def iter_tests(self, test_objs):
#Note: not using yield because of Jython 2.1.
import unittest
tests = []
for test_obj in test_objs:
if isinstance(test_obj, unittest.TestSuite):
tests.extend(self.iter_tests(test_obj._tests))
elif isinstance(test_obj, unittest.TestCase):
tests.append(test_obj)
return tests
def list_test_names(self, test_objs):
names = []
for tc in self.iter_tests(test_objs):
try:
testMethodName = tc._TestCase__testMethodName
except AttributeError:
#changed in python 2.5
testMethodName = tc._testMethodName
names.append(testMethodName)
return names
def __match_tests(self, tests, test_case, test_method_name):
if not tests:
return 1
for t in tests:
class_and_method = t.split('.')
if len(class_and_method) == 1:
#only class name
if class_and_method[0] == test_case.__class__.__name__:
return 1
elif len(class_and_method) == 2:
if class_and_method[0] == test_case.__class__.__name__ and class_and_method[1] == test_method_name:
return 1
return 0
def __match(self, filter_list, name):
""" returns whether a test name matches the test filter """
if filter_list is None:
return 1
for f in filter_list:
if re.match(f, name):
return 1
return 0
def run_tests(self, handle_coverage=True):
""" runs all tests """
sys.stdout.write("Finding files... ")
files = self.find_import_files()
if self.verbosity > 3:
sys.stdout.write('%s ... done.\n' % (self.files_or_dirs))
else:
sys.stdout.write('done.\n')
sys.stdout.write("Importing test modules ... ")
if handle_coverage:
coverage_files, coverage = StartCoverageSupport(self.configuration)
file_and_modules_and_module_name = self.find_modules_from_files(files)
sys.stdout.write("done.\n")
all_tests = self.find_tests_from_modules(file_and_modules_and_module_name)
all_tests = self.filter_tests(all_tests)
import pydev_runfiles_unittest
test_suite = pydev_runfiles_unittest.PydevTestSuite(all_tests)
import pydev_runfiles_xml_rpc
pydev_runfiles_xml_rpc.notifyTestsCollected(test_suite.countTestCases())
start_time = time.time()
def run_tests():
executed_in_parallel = False
if self.jobs > 1:
import pydev_runfiles_parallel
#What may happen is that the number of jobs needed is lower than the number of jobs requested
#(e.g.: 2 jobs were requested for running 1 test) -- in which case ExecuteTestsInParallel will
#return False and won't run any tests.
executed_in_parallel = pydev_runfiles_parallel.ExecuteTestsInParallel(
all_tests, self.jobs, self.split_jobs, self.verbosity, coverage_files, self.configuration.coverage_include)
if not executed_in_parallel:
#If in coverage, we don't need to pass anything here (coverage is already enabled for this execution).
runner = pydev_runfiles_unittest.PydevTextTestRunner(stream=sys.stdout, descriptions=1, verbosity=self.verbosity)
sys.stdout.write('\n')
runner.run(test_suite)
if self.configuration.django:
MyDjangoTestSuiteRunner(run_tests).run_tests([])
else:
run_tests()
if handle_coverage:
coverage.stop()
coverage.save()
total_time = 'Finished in: %.2f secs.' % (time.time() - start_time,)
pydev_runfiles_xml_rpc.notifyTestRunFinished(total_time)
try:
from django.test.simple import DjangoTestSuiteRunner
except:
class DjangoTestSuiteRunner:
def __init__(self):
pass
def run_tests(self, *args, **kwargs):
raise AssertionError("Unable to run suite with DjangoTestSuiteRunner because it couldn't be imported.")
class MyDjangoTestSuiteRunner(DjangoTestSuiteRunner):
def __init__(self, on_run_suite):
DjangoTestSuiteRunner.__init__(self)
self.on_run_suite = on_run_suite
def build_suite(self, *args, **kwargs):
pass
def suite_result(self, *args, **kwargs):
pass
def run_suite(self, *args, **kwargs):
self.on_run_suite()
#=======================================================================================================================
# main
#=======================================================================================================================
def main(configuration):
PydevTestRunner(configuration).run_tests()
|
apache-2.0
|
[
504,
636,
2443,
363,
492,
6032,
63,
14129,
199,
199,
646,
15951,
199,
646,
747,
14,
515,
199,
504,
29240,
63,
1065,
1725,
63,
10828,
492,
7707,
27444,
11532,
199,
504,
29240,
68,
63,
5559,
492,
627,
9213,
20782,
55,
668,
6295,
199,
646,
295,
199,
646,
900,
421,
199,
14813,
12813,
18673,
199,
3,
11595,
199,
14813,
12813,
18673,
199,
533,
11595,
26,
339,
347,
636,
826,
721,
267,
291,
12,
267,
1584,
63,
269,
63,
3220,
4581,
267,
8661,
29,
18,
12,
267,
2387,
63,
2219,
29,
403,
12,
267,
2295,
29,
403,
12,
267,
1844,
29,
403,
12,
267,
1584,
63,
475,
63,
2219,
29,
403,
12,
267,
9643,
29,
17,
12,
267,
3715,
63,
6920,
534,
2219,
297,
267,
11745,
63,
1199,
63,
694,
29,
403,
12,
267,
11745,
63,
2613,
29,
403,
12,
267,
11745,
63,
1199,
63,
493,
29,
403,
12,
267,
5760,
63,
1725,
29,
403,
12,
267,
5760,
63,
2219,
29,
403,
12,
267,
2387,
63,
1725,
29,
403,
12,
267,
1639,
29,
797,
12,
267,
3461,
267,
291,
14,
1725,
63,
269,
63,
3220,
275,
1584,
63,
269,
63,
3220,
267,
291,
14,
9833,
275,
8661,
267,
291,
14,
2613,
63,
2219,
275,
2387,
63,
2219,
267,
291,
14,
2219,
275,
2295,
267,
291,
14,
719,
275,
1844,
267,
291,
14,
1725,
63,
475,
63,
2219,
275,
1584,
63,
475,
63,
2219,
267,
291,
14,
6920,
275,
9643,
267,
291,
14,
1294,
63,
6920,
275,
3715,
63,
6920,
267,
291,
14,
1176,
275,
1639,
398,
340,
2387,
63,
2219,
26,
288,
702,
1228,
8,
2613,
63,
2219,
12,
334,
513,
12,
2008,
430,
398,
340,
5760,
63,
1725,
26,
288,
702,
1228,
8,
5473,
63,
1725,
12,
334,
513,
12,
2008,
430,
398,
340,
5760,
63,
2219,
26,
288,
702,
1228,
8,
5473,
63,
2219,
12,
334,
513,
12,
2008,
430,
398,
291,
14,
5473,
63,
1725,
275,
5760,
63,
1725,
267,
291,
14,
2613,
63,
1725,
275,
2387,
63,
1725,
267,
291,
14,
5473,
63,
2219,
275,
5760,
63,
2219,
398,
291,
14,
10828,
63,
1199,
63,
694,
275,
11745,
63,
1199,
63,
694,
267,
291,
14,
10828,
63,
2613,
275,
11745,
63,
2613,
267,
291,
14,
10828,
63,
1199,
63,
493,
275,
11745,
63,
1199,
63,
493,
339,
347,
636,
495,
721,
277,
304,
267,
372,
1449,
5688,
199,
446,
1584,
63,
269,
63,
3220,
26,
450,
83,
199,
446,
8661,
26,
450,
83,
199,
446,
2295,
26,
450,
83,
199,
446,
1844,
26,
450,
83,
199,
446,
1584,
63,
475,
63,
2219,
26,
450,
83,
199,
446,
9643,
26,
450,
83,
199,
446,
3715,
63,
6920,
26,
450,
83,
421,
446,
2387,
63,
1725,
26,
450,
83,
199,
446,
2387,
63,
2219,
26,
450,
83,
421,
446,
5760,
63,
1725,
26,
450,
83,
199,
446,
5760,
63,
2219,
26,
450,
83,
421,
446,
11745,
63,
1199,
63,
694,
26,
450,
83,
199,
446,
11745,
63,
2613,
63,
694,
26,
450,
83,
199,
446,
11745,
63,
1199,
63,
493,
26,
450,
83,
421,
446,
1639,
26,
450,
83,
199,
2344,
450,
334,
267,
291,
14,
1725,
63,
269,
63,
3220,
12,
267,
291,
14,
9833,
12,
267,
291,
14,
2219,
12,
267,
291,
14,
719,
12,
267,
291,
14,
1725,
63,
475,
63,
2219,
12,
267,
291,
14,
6920,
12,
267,
291,
14,
1294,
63,
6920,
12,
398,
291,
14,
2613,
63,
1725,
12,
267,
291,
14,
2613,
63,
2219,
12,
398,
291,
14,
5473,
63,
1725,
12,
267,
291,
14,
5473,
63,
2219,
12,
398,
291,
14,
10828,
63,
1199,
63,
694,
12,
267,
291,
14,
10828,
63,
2613,
12,
267,
291,
14,
10828,
63,
1199,
63,
493,
12,
398,
291,
14,
1176,
12,
272,
776,
421,
199,
14813,
12813,
18673,
199,
3,
2198,
63,
15612,
199,
14813,
12813,
18673,
199,
318,
2198,
63,
15612,
8,
3020,
29,
403,
304,
272,
408,
272,
29968,
1414,
1004,
436,
2529,
511,
6602,
12,
8661,
12,
511,
2457,
436,
511,
24203,
339,
4503,
26,
267,
1255,
1725,
14,
647,
221,
446,
86,
92,
306,
9833,
665,
1896,
30,
221,
446,
84,
92,
306,
2219,
665,
774,
14,
396,
17,
12,
774,
18,
30,
221,
7606,
92,
1725,
339,
6879,
6338,
1511,
26,
272,
9643,
29,
1955,
334,
1045,
314,
1329,
402,
9643,
370,
506,
1202,
370,
1255,
314,
2295,
9,
272,
3715,
63,
6920,
534,
578,
26972,
2219,
7,
267,
340,
508,
859,
12,
282,
1627,
3906,
911,
3544,
9128,
1006,
314,
2295,
687,
282,
859,
267,
340,
508,
2295,
12,
314,
2295,
911,
506,
3715,
30426,
402,
3932,
6330,
1958,
859,
334,
885,
9,
339,
1553,
5473,
63,
1725,
221,
275,
10029,
13,
12794,
769,
402,
7970,
543,
1584,
370,
5760,
334,
15359,
3449,
9,
272,
1553,
2613,
63,
1725,
275,
10029,
13,
12794,
769,
402,
7970,
543,
1584,
370,
2387,
334,
15359,
3449,
9,
272,
1553,
5473,
63,
2219,
275,
10029,
13,
12794,
769,
402,
7970,
543,
511,
1561,
370,
5760,
334,
15359,
3449,
9,
339,
3390,
26,
340,
1553,
2219,
365,
1627,
12,
1553,
5473,
63,
1725,
12,
1553,
2613,
63,
1725,
436,
1553,
5473,
63,
2219,
787,
5525,
1,
272,
408,
272,
340,
9238,
365,
488,
26,
267,
9238,
275,
984,
14,
3020,
339,
8661,
275,
499,
272,
2387,
63,
2219,
275,
488,
272,
2295,
275,
488,
272,
1844,
275,
488,
272,
9643,
275,
413,
272,
3715,
63,
6920,
275,
283,
2219,
7,
272,
1584,
63,
475,
63,
2219,
275,
1052,
272,
11745,
63,
1199,
63,
694,
275,
488,
272,
11745,
63,
2613,
275,
488,
272,
5760,
63,
1725,
275,
488,
272,
5760,
63,
2219,
275,
488,
272,
2387,
63,
1725,
275,
488,
272,
1639,
275,
756,
339,
687,
485,
23996,
63,
18907,
492,
486,
4850,
63,
18907,
272,
2450,
513,
12,
7606,
275,
486,
4850,
63,
18907,
8,
267,
9238,
59,
17,
8429,
4873,
267,
359,
288,
298,
9833,
11107,
288,
298,
2219,
11107,
953,
298,
719,
11107,
288,
298,
888,
63,
493,
11107,
953,
298,
6920,
11107,
288,
298,
1294,
63,
6920,
11107,
953,
298,
2613,
63,
2219,
11107,
288,
298,
2613,
63,
1725,
11107,
953,
298,
5473,
63,
1725,
11107,
288,
298,
5473,
63,
2219,
11107,
953,
298
] |
[
636,
2443,
363,
492,
6032,
63,
14129,
199,
199,
646,
15951,
199,
646,
747,
14,
515,
199,
504,
29240,
63,
1065,
1725,
63,
10828,
492,
7707,
27444,
11532,
199,
504,
29240,
68,
63,
5559,
492,
627,
9213,
20782,
55,
668,
6295,
199,
646,
295,
199,
646,
900,
421,
199,
14813,
12813,
18673,
199,
3,
11595,
199,
14813,
12813,
18673,
199,
533,
11595,
26,
339,
347,
636,
826,
721,
267,
291,
12,
267,
1584,
63,
269,
63,
3220,
4581,
267,
8661,
29,
18,
12,
267,
2387,
63,
2219,
29,
403,
12,
267,
2295,
29,
403,
12,
267,
1844,
29,
403,
12,
267,
1584,
63,
475,
63,
2219,
29,
403,
12,
267,
9643,
29,
17,
12,
267,
3715,
63,
6920,
534,
2219,
297,
267,
11745,
63,
1199,
63,
694,
29,
403,
12,
267,
11745,
63,
2613,
29,
403,
12,
267,
11745,
63,
1199,
63,
493,
29,
403,
12,
267,
5760,
63,
1725,
29,
403,
12,
267,
5760,
63,
2219,
29,
403,
12,
267,
2387,
63,
1725,
29,
403,
12,
267,
1639,
29,
797,
12,
267,
3461,
267,
291,
14,
1725,
63,
269,
63,
3220,
275,
1584,
63,
269,
63,
3220,
267,
291,
14,
9833,
275,
8661,
267,
291,
14,
2613,
63,
2219,
275,
2387,
63,
2219,
267,
291,
14,
2219,
275,
2295,
267,
291,
14,
719,
275,
1844,
267,
291,
14,
1725,
63,
475,
63,
2219,
275,
1584,
63,
475,
63,
2219,
267,
291,
14,
6920,
275,
9643,
267,
291,
14,
1294,
63,
6920,
275,
3715,
63,
6920,
267,
291,
14,
1176,
275,
1639,
398,
340,
2387,
63,
2219,
26,
288,
702,
1228,
8,
2613,
63,
2219,
12,
334,
513,
12,
2008,
430,
398,
340,
5760,
63,
1725,
26,
288,
702,
1228,
8,
5473,
63,
1725,
12,
334,
513,
12,
2008,
430,
398,
340,
5760,
63,
2219,
26,
288,
702,
1228,
8,
5473,
63,
2219,
12,
334,
513,
12,
2008,
430,
398,
291,
14,
5473,
63,
1725,
275,
5760,
63,
1725,
267,
291,
14,
2613,
63,
1725,
275,
2387,
63,
1725,
267,
291,
14,
5473,
63,
2219,
275,
5760,
63,
2219,
398,
291,
14,
10828,
63,
1199,
63,
694,
275,
11745,
63,
1199,
63,
694,
267,
291,
14,
10828,
63,
2613,
275,
11745,
63,
2613,
267,
291,
14,
10828,
63,
1199,
63,
493,
275,
11745,
63,
1199,
63,
493,
339,
347,
636,
495,
721,
277,
304,
267,
372,
1449,
5688,
199,
446,
1584,
63,
269,
63,
3220,
26,
450,
83,
199,
446,
8661,
26,
450,
83,
199,
446,
2295,
26,
450,
83,
199,
446,
1844,
26,
450,
83,
199,
446,
1584,
63,
475,
63,
2219,
26,
450,
83,
199,
446,
9643,
26,
450,
83,
199,
446,
3715,
63,
6920,
26,
450,
83,
421,
446,
2387,
63,
1725,
26,
450,
83,
199,
446,
2387,
63,
2219,
26,
450,
83,
421,
446,
5760,
63,
1725,
26,
450,
83,
199,
446,
5760,
63,
2219,
26,
450,
83,
421,
446,
11745,
63,
1199,
63,
694,
26,
450,
83,
199,
446,
11745,
63,
2613,
63,
694,
26,
450,
83,
199,
446,
11745,
63,
1199,
63,
493,
26,
450,
83,
421,
446,
1639,
26,
450,
83,
199,
2344,
450,
334,
267,
291,
14,
1725,
63,
269,
63,
3220,
12,
267,
291,
14,
9833,
12,
267,
291,
14,
2219,
12,
267,
291,
14,
719,
12,
267,
291,
14,
1725,
63,
475,
63,
2219,
12,
267,
291,
14,
6920,
12,
267,
291,
14,
1294,
63,
6920,
12,
398,
291,
14,
2613,
63,
1725,
12,
267,
291,
14,
2613,
63,
2219,
12,
398,
291,
14,
5473,
63,
1725,
12,
267,
291,
14,
5473,
63,
2219,
12,
398,
291,
14,
10828,
63,
1199,
63,
694,
12,
267,
291,
14,
10828,
63,
2613,
12,
267,
291,
14,
10828,
63,
1199,
63,
493,
12,
398,
291,
14,
1176,
12,
272,
776,
421,
199,
14813,
12813,
18673,
199,
3,
2198,
63,
15612,
199,
14813,
12813,
18673,
199,
318,
2198,
63,
15612,
8,
3020,
29,
403,
304,
272,
408,
272,
29968,
1414,
1004,
436,
2529,
511,
6602,
12,
8661,
12,
511,
2457,
436,
511,
24203,
339,
4503,
26,
267,
1255,
1725,
14,
647,
221,
446,
86,
92,
306,
9833,
665,
1896,
30,
221,
446,
84,
92,
306,
2219,
665,
774,
14,
396,
17,
12,
774,
18,
30,
221,
7606,
92,
1725,
339,
6879,
6338,
1511,
26,
272,
9643,
29,
1955,
334,
1045,
314,
1329,
402,
9643,
370,
506,
1202,
370,
1255,
314,
2295,
9,
272,
3715,
63,
6920,
534,
578,
26972,
2219,
7,
267,
340,
508,
859,
12,
282,
1627,
3906,
911,
3544,
9128,
1006,
314,
2295,
687,
282,
859,
267,
340,
508,
2295,
12,
314,
2295,
911,
506,
3715,
30426,
402,
3932,
6330,
1958,
859,
334,
885,
9,
339,
1553,
5473,
63,
1725,
221,
275,
10029,
13,
12794,
769,
402,
7970,
543,
1584,
370,
5760,
334,
15359,
3449,
9,
272,
1553,
2613,
63,
1725,
275,
10029,
13,
12794,
769,
402,
7970,
543,
1584,
370,
2387,
334,
15359,
3449,
9,
272,
1553,
5473,
63,
2219,
275,
10029,
13,
12794,
769,
402,
7970,
543,
511,
1561,
370,
5760,
334,
15359,
3449,
9,
339,
3390,
26,
340,
1553,
2219,
365,
1627,
12,
1553,
5473,
63,
1725,
12,
1553,
2613,
63,
1725,
436,
1553,
5473,
63,
2219,
787,
5525,
1,
272,
408,
272,
340,
9238,
365,
488,
26,
267,
9238,
275,
984,
14,
3020,
339,
8661,
275,
499,
272,
2387,
63,
2219,
275,
488,
272,
2295,
275,
488,
272,
1844,
275,
488,
272,
9643,
275,
413,
272,
3715,
63,
6920,
275,
283,
2219,
7,
272,
1584,
63,
475,
63,
2219,
275,
1052,
272,
11745,
63,
1199,
63,
694,
275,
488,
272,
11745,
63,
2613,
275,
488,
272,
5760,
63,
1725,
275,
488,
272,
5760,
63,
2219,
275,
488,
272,
2387,
63,
1725,
275,
488,
272,
1639,
275,
756,
339,
687,
485,
23996,
63,
18907,
492,
486,
4850,
63,
18907,
272,
2450,
513,
12,
7606,
275,
486,
4850,
63,
18907,
8,
267,
9238,
59,
17,
8429,
4873,
267,
359,
288,
298,
9833,
11107,
288,
298,
2219,
11107,
953,
298,
719,
11107,
288,
298,
888,
63,
493,
11107,
953,
298,
6920,
11107,
288,
298,
1294,
63,
6920,
11107,
953,
298,
2613,
63,
2219,
11107,
288,
298,
2613,
63,
1725,
11107,
953,
298,
5473,
63,
1725,
11107,
288,
298,
5473,
63,
2219,
11107,
953,
298,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
leppa/home-assistant
|
homeassistant/components/ambient_station/binary_sensor.py
|
5
|
2345
|
"""Support for Ambient Weather Station binary sensors."""
import logging
from homeassistant.components.binary_sensor import BinarySensorDevice
from homeassistant.const import ATTR_NAME
from . import (
SENSOR_TYPES,
TYPE_BATT1,
TYPE_BATT2,
TYPE_BATT3,
TYPE_BATT4,
TYPE_BATT5,
TYPE_BATT6,
TYPE_BATT7,
TYPE_BATT8,
TYPE_BATT9,
TYPE_BATT10,
TYPE_BATTOUT,
AmbientWeatherEntity,
)
from .const import ATTR_LAST_DATA, DATA_CLIENT, DOMAIN, TYPE_BINARY_SENSOR
_LOGGER = logging.getLogger(__name__)
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
"""Set up Ambient PWS binary sensors based on the old way."""
pass
async def async_setup_entry(hass, entry, async_add_entities):
"""Set up Ambient PWS binary sensors based on a config entry."""
ambient = hass.data[DOMAIN][DATA_CLIENT][entry.entry_id]
binary_sensor_list = []
for mac_address, station in ambient.stations.items():
for condition in ambient.monitored_conditions:
name, _, kind, device_class = SENSOR_TYPES[condition]
if kind == TYPE_BINARY_SENSOR:
binary_sensor_list.append(
AmbientWeatherBinarySensor(
ambient,
mac_address,
station[ATTR_NAME],
condition,
name,
device_class,
)
)
async_add_entities(binary_sensor_list, True)
class AmbientWeatherBinarySensor(AmbientWeatherEntity, BinarySensorDevice):
"""Define an Ambient binary sensor."""
@property
def is_on(self):
"""Return the status of the sensor."""
if self._sensor_type in (
TYPE_BATT1,
TYPE_BATT10,
TYPE_BATT2,
TYPE_BATT3,
TYPE_BATT4,
TYPE_BATT5,
TYPE_BATT6,
TYPE_BATT7,
TYPE_BATT8,
TYPE_BATT9,
TYPE_BATTOUT,
):
return self._state == 0
return self._state == 1
async def async_update(self):
"""Fetch new state data for the entity."""
self._state = self._ambient.stations[self._mac_address][ATTR_LAST_DATA].get(
self._sensor_type
)
|
apache-2.0
|
[
624,
11532,
367,
437,
887,
6792,
2136,
7404,
1933,
425,
3366,
19678,
1041,
199,
646,
2050,
199,
199,
504,
8846,
14,
4608,
14,
3008,
63,
8956,
492,
14161,
10160,
2510,
199,
504,
8846,
14,
1297,
492,
10762,
63,
2339,
199,
199,
504,
1275,
492,
334,
272,
428,
17850,
63,
7893,
12,
272,
11511,
63,
34,
11712,
17,
12,
272,
11511,
63,
34,
11712,
18,
12,
272,
11511,
63,
34,
11712,
19,
12,
272,
11511,
63,
34,
11712,
20,
12,
272,
11511,
63,
34,
11712,
21,
12,
272,
11511,
63,
34,
11712,
22,
12,
272,
11511,
63,
34,
11712,
23,
12,
272,
11511,
63,
34,
11712,
24,
12,
272,
11511,
63,
34,
11712,
25,
12,
272,
11511,
63,
34,
11712,
709,
12,
272,
11511,
63,
34,
11712,
1877,
12,
272,
437,
887,
6792,
55,
4489,
728,
7302,
12,
199,
9,
199,
504,
1275,
1297,
492,
10762,
63,
16901,
63,
3998,
12,
7126,
63,
9901,
12,
15265,
12,
11511,
63,
13246,
63,
24151,
199,
199,
63,
10186,
275,
2050,
14,
5572,
3460,
354,
3368,
421,
199,
4146,
347,
5316,
63,
2758,
63,
3246,
8,
5387,
12,
1101,
12,
5316,
63,
525,
63,
8327,
12,
13172,
63,
815,
29,
403,
304,
272,
408,
1084,
1536,
437,
887,
6792,
510,
5035,
3366,
19678,
4079,
641,
314,
2269,
4340,
1041,
272,
986,
421,
199,
4146,
347,
5316,
63,
2758,
63,
2373,
8,
5387,
12,
2397,
12,
5316,
63,
525,
63,
8327,
304,
272,
408,
1084,
1536,
437,
887,
6792,
510,
5035,
3366,
19678,
4079,
641,
282,
1101,
2397,
1041,
272,
16353,
6792,
275,
6298,
14,
576,
59,
7378,
1527,
3998,
63,
9901,
1527,
2373,
14,
2373,
63,
344,
61,
339,
3366,
63,
8956,
63,
513,
275,
942,
272,
367,
4497,
63,
1562,
12,
16518,
315,
16353,
6792,
14,
270,
1298,
14,
1744,
837,
267,
367,
5558,
315,
16353,
6792,
14,
2106,
17043,
63,
9855,
26,
288,
536,
12,
5501,
4928,
12,
2243,
63,
533,
275,
428,
17850,
63,
7893,
59,
5394,
61,
288,
340,
4928,
508,
11511,
63,
13246,
63,
24151,
26,
355,
3366,
63,
8956,
63,
513,
14,
740,
8,
490,
437,
887,
6792,
55,
4489,
728,
6636,
10160,
8,
717,
16353,
6792,
12,
717,
4497,
63,
1562,
12,
717,
16518,
59,
5280,
63,
2339,
467,
717,
5558,
12,
717,
536,
12,
717,
2243,
63,
533,
12,
490,
776,
355,
776,
339,
5316,
63,
525,
63,
8327,
8,
3008,
63,
8956,
63,
513,
12,
715,
9,
421,
199,
533,
437,
887,
6792,
55,
4489,
728,
6636,
10160,
8,
29209,
6792,
55,
4489,
728,
7302,
12,
14161,
10160,
2510,
304,
272,
408,
16213,
376,
437,
887,
6792,
3366,
8778,
1041,
339,
768,
1829,
272,
347,
365,
63,
265,
8,
277,
304,
267,
408,
1767,
314,
2004,
402,
314,
8778,
1041,
267,
340,
291,
423,
8956,
63,
466,
315,
334,
288,
11511,
63,
34,
11712,
17,
12,
288,
11511,
63,
34,
11712,
709,
12,
288,
11511,
63,
34,
11712,
18,
12,
288,
11511,
63,
34,
11712,
19,
12,
288,
11511,
63,
34,
11712,
20,
12,
288,
11511,
63,
34,
11712,
21,
12,
288,
11511,
63,
34,
11712,
22,
12,
288,
11511,
63,
34,
11712,
23,
12,
288,
11511,
63,
34,
11712,
24,
12,
288,
11511,
63,
34,
11712,
25,
12,
288,
11511,
63,
34,
11712,
1877,
12,
267,
3461,
288,
372,
291,
423,
929,
508,
378,
398,
372,
291,
423,
929,
508,
413,
339,
5316,
347,
5316,
63,
873,
8,
277,
304,
267,
408,
11135,
892,
1174,
666,
367,
314,
4642,
1041,
267,
291,
423,
929,
275,
291,
423,
455,
4492,
484,
14,
270,
1298,
59,
277,
423,
3088,
63,
1562,
1527,
5280,
63,
16901,
63,
3998,
1055,
362,
8,
288,
291,
423,
8956,
63,
466,
267,
776,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
11532,
367,
437,
887,
6792,
2136,
7404,
1933,
425,
3366,
19678,
1041,
199,
646,
2050,
199,
199,
504,
8846,
14,
4608,
14,
3008,
63,
8956,
492,
14161,
10160,
2510,
199,
504,
8846,
14,
1297,
492,
10762,
63,
2339,
199,
199,
504,
1275,
492,
334,
272,
428,
17850,
63,
7893,
12,
272,
11511,
63,
34,
11712,
17,
12,
272,
11511,
63,
34,
11712,
18,
12,
272,
11511,
63,
34,
11712,
19,
12,
272,
11511,
63,
34,
11712,
20,
12,
272,
11511,
63,
34,
11712,
21,
12,
272,
11511,
63,
34,
11712,
22,
12,
272,
11511,
63,
34,
11712,
23,
12,
272,
11511,
63,
34,
11712,
24,
12,
272,
11511,
63,
34,
11712,
25,
12,
272,
11511,
63,
34,
11712,
709,
12,
272,
11511,
63,
34,
11712,
1877,
12,
272,
437,
887,
6792,
55,
4489,
728,
7302,
12,
199,
9,
199,
504,
1275,
1297,
492,
10762,
63,
16901,
63,
3998,
12,
7126,
63,
9901,
12,
15265,
12,
11511,
63,
13246,
63,
24151,
199,
199,
63,
10186,
275,
2050,
14,
5572,
3460,
354,
3368,
421,
199,
4146,
347,
5316,
63,
2758,
63,
3246,
8,
5387,
12,
1101,
12,
5316,
63,
525,
63,
8327,
12,
13172,
63,
815,
29,
403,
304,
272,
408,
1084,
1536,
437,
887,
6792,
510,
5035,
3366,
19678,
4079,
641,
314,
2269,
4340,
1041,
272,
986,
421,
199,
4146,
347,
5316,
63,
2758,
63,
2373,
8,
5387,
12,
2397,
12,
5316,
63,
525,
63,
8327,
304,
272,
408,
1084,
1536,
437,
887,
6792,
510,
5035,
3366,
19678,
4079,
641,
282,
1101,
2397,
1041,
272,
16353,
6792,
275,
6298,
14,
576,
59,
7378,
1527,
3998,
63,
9901,
1527,
2373,
14,
2373,
63,
344,
61,
339,
3366,
63,
8956,
63,
513,
275,
942,
272,
367,
4497,
63,
1562,
12,
16518,
315,
16353,
6792,
14,
270,
1298,
14,
1744,
837,
267,
367,
5558,
315,
16353,
6792,
14,
2106,
17043,
63,
9855,
26,
288,
536,
12,
5501,
4928,
12,
2243,
63,
533,
275,
428,
17850,
63,
7893,
59,
5394,
61,
288,
340,
4928,
508,
11511,
63,
13246,
63,
24151,
26,
355,
3366,
63,
8956,
63,
513,
14,
740,
8,
490,
437,
887,
6792,
55,
4489,
728,
6636,
10160,
8,
717,
16353,
6792,
12,
717,
4497,
63,
1562,
12,
717,
16518,
59,
5280,
63,
2339,
467,
717,
5558,
12,
717,
536,
12,
717,
2243,
63,
533,
12,
490,
776,
355,
776,
339,
5316,
63,
525,
63,
8327,
8,
3008,
63,
8956,
63,
513,
12,
715,
9,
421,
199,
533,
437,
887,
6792,
55,
4489,
728,
6636,
10160,
8,
29209,
6792,
55,
4489,
728,
7302,
12,
14161,
10160,
2510,
304,
272,
408,
16213,
376,
437,
887,
6792,
3366,
8778,
1041,
339,
768,
1829,
272,
347,
365,
63,
265,
8,
277,
304,
267,
408,
1767,
314,
2004,
402,
314,
8778,
1041,
267,
340,
291,
423,
8956,
63,
466,
315,
334,
288,
11511,
63,
34,
11712,
17,
12,
288,
11511,
63,
34,
11712,
709,
12,
288,
11511,
63,
34,
11712,
18,
12,
288,
11511,
63,
34,
11712,
19,
12,
288,
11511,
63,
34,
11712,
20,
12,
288,
11511,
63,
34,
11712,
21,
12,
288,
11511,
63,
34,
11712,
22,
12,
288,
11511,
63,
34,
11712,
23,
12,
288,
11511,
63,
34,
11712,
24,
12,
288,
11511,
63,
34,
11712,
25,
12,
288,
11511,
63,
34,
11712,
1877,
12,
267,
3461,
288,
372,
291,
423,
929,
508,
378,
398,
372,
291,
423,
929,
508,
413,
339,
5316,
347,
5316,
63,
873,
8,
277,
304,
267,
408,
11135,
892,
1174,
666,
367,
314,
4642,
1041,
267,
291,
423,
929,
275,
291,
423,
455,
4492,
484,
14,
270,
1298,
59,
277,
423,
3088,
63,
1562,
1527,
5280,
63,
16901,
63,
3998,
1055,
362,
8,
288,
291,
423,
8956,
63,
466,
267,
776,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1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/account/account_invoice.py
|
12
|
78556
|
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import itertools
from lxml import etree
from openerp import models, fields, api, _
from openerp.exceptions import except_orm, Warning, RedirectWarning
import openerp.addons.decimal_precision as dp
# mapping invoice type to journal type
TYPE2JOURNAL = {
'out_invoice': 'sale',
'in_invoice': 'purchase',
'out_refund': 'sale_refund',
'in_refund': 'purchase_refund',
}
# mapping invoice type to refund type
TYPE2REFUND = {
'out_invoice': 'out_refund', # Customer Invoice
'in_invoice': 'in_refund', # Supplier Invoice
'out_refund': 'out_invoice', # Customer Refund
'in_refund': 'in_invoice', # Supplier Refund
}
MAGIC_COLUMNS = ('id', 'create_uid', 'create_date', 'write_uid', 'write_date')
class account_invoice(models.Model):
_name = "account.invoice"
_inherit = ['mail.thread']
_description = "Invoice"
_order = "number desc, id desc"
_track = {
'type': {
},
'state': {
'account.mt_invoice_paid': lambda self, cr, uid, obj, ctx=None: obj.state == 'paid' and obj.type in ('out_invoice', 'out_refund'),
'account.mt_invoice_validated': lambda self, cr, uid, obj, ctx=None: obj.state == 'open' and obj.type in ('out_invoice', 'out_refund'),
},
}
@api.one
@api.depends('invoice_line.price_subtotal', 'tax_line.amount')
def _compute_amount(self):
self.amount_untaxed = sum(line.price_subtotal for line in self.invoice_line)
self.amount_tax = sum(line.amount for line in self.tax_line)
self.amount_total = self.amount_untaxed + self.amount_tax
@api.model
def _default_journal(self):
inv_type = self._context.get('type', 'out_invoice')
inv_types = inv_type if isinstance(inv_type, list) else [inv_type]
company_id = self._context.get('company_id', self.env.user.company_id.id)
domain = [
('type', 'in', filter(None, map(TYPE2JOURNAL.get, inv_types))),
('company_id', '=', company_id),
]
return self.env['account.journal'].search(domain, limit=1)
@api.model
def _default_currency(self):
journal = self._default_journal()
return journal.currency or journal.company_id.currency_id
@api.model
@api.returns('account.analytic.journal')
def _get_journal_analytic(self, inv_type):
""" Return the analytic journal corresponding to the given invoice type. """
journal_type = TYPE2JOURNAL.get(inv_type, 'sale')
journal = self.env['account.analytic.journal'].search([('type', '=', journal_type)], limit=1)
if not journal:
raise except_orm(_('No Analytic Journal!'),
_("You must define an analytic journal of type '%s'!") % (journal_type,))
return journal
@api.one
@api.depends('account_id', 'move_id.line_id.account_id', 'move_id.line_id.reconcile_id')
def _compute_reconciled(self):
self.reconciled = self.test_paid()
if not self.reconciled and self.state == 'paid':
self.signal_workflow('open_test')
@api.model
def _get_reference_type(self):
return [('none', _('Free Reference'))]
@api.one
@api.depends(
'state', 'currency_id', 'invoice_line.price_subtotal',
'move_id.line_id.account_id.type',
'move_id.line_id.amount_residual',
'move_id.line_id.amount_residual_currency',
'move_id.line_id.currency_id',
'move_id.line_id.reconcile_partial_id.line_partial_ids.invoice.type',
)
def _compute_residual(self):
nb_inv_in_partial_rec = max_invoice_id = 0
self.residual = 0.0
for line in self.move_id.line_id:
if line.account_id.type in ('receivable', 'payable'):
if line.currency_id == self.currency_id:
self.residual += line.amount_residual_currency
else:
# ahem, shouldn't we use line.currency_id here?
from_currency = line.company_id.currency_id.with_context(date=line.date)
self.residual += from_currency.compute(line.amount_residual, self.currency_id)
# we check if the invoice is partially reconciled and if there
# are other invoices involved in this partial reconciliation
for pline in line.reconcile_partial_id.line_partial_ids:
if pline.invoice and self.type == pline.invoice.type:
nb_inv_in_partial_rec += 1
# store the max invoice id as for this invoice we will
# make a balance instead of a simple division
max_invoice_id = max(max_invoice_id, pline.invoice.id)
if nb_inv_in_partial_rec:
# if there are several invoices in a partial reconciliation, we
# split the residual by the number of invoices to have a sum of
# residual amounts that matches the partner balance
new_value = self.currency_id.round(self.residual / nb_inv_in_partial_rec)
if self.id == max_invoice_id:
# if it's the last the invoice of the bunch of invoices
# partially reconciled together, we make a balance to avoid
# rounding errors
self.residual = self.residual - ((nb_inv_in_partial_rec - 1) * new_value)
else:
self.residual = new_value
# prevent the residual amount on the invoice to be less than 0
self.residual = max(self.residual, 0.0)
@api.one
@api.depends(
'move_id.line_id.account_id',
'move_id.line_id.reconcile_id.line_id',
'move_id.line_id.reconcile_partial_id.line_partial_ids',
)
def _compute_move_lines(self):
# Give Journal Items related to the payment reconciled to this invoice.
# Return partial and total payments related to the selected invoice.
self.move_lines = self.env['account.move.line']
if not self.move_id:
return
data_lines = self.move_id.line_id.filtered(lambda l: l.account_id == self.account_id)
partial_lines = self.env['account.move.line']
for data_line in data_lines:
if data_line.reconcile_id:
lines = data_line.reconcile_id.line_id
elif data_line.reconcile_partial_id:
lines = data_line.reconcile_partial_id.line_partial_ids
else:
lines = self.env['account_move_line']
partial_lines += data_line
self.move_lines = lines - partial_lines
@api.one
@api.depends(
'move_id.line_id.reconcile_id.line_id',
'move_id.line_id.reconcile_partial_id.line_partial_ids',
)
def _compute_payments(self):
partial_lines = lines = self.env['account.move.line']
for line in self.move_id.line_id:
if line.reconcile_id:
lines |= line.reconcile_id.line_id
elif line.reconcile_partial_id:
lines |= line.reconcile_partial_id.line_partial_ids
partial_lines += line
self.payment_ids = (lines - partial_lines).sorted()
name = fields.Char(string='Reference/Description', index=True,
readonly=True, states={'draft': [('readonly', False)]})
origin = fields.Char(string='Source Document',
help="Reference of the document that produced this invoice.",
readonly=True, states={'draft': [('readonly', False)]})
supplier_invoice_number = fields.Char(string='Supplier Invoice Number',
help="The reference of this invoice as provided by the supplier.",
readonly=True, states={'draft': [('readonly', False)]})
type = fields.Selection([
('out_invoice','Customer Invoice'),
('in_invoice','Supplier Invoice'),
('out_refund','Customer Refund'),
('in_refund','Supplier Refund'),
], string='Type', readonly=True, index=True, change_default=True,
default=lambda self: self._context.get('type', 'out_invoice'),
track_visibility='always')
number = fields.Char(related='move_id.name', store=True, readonly=True, copy=False)
internal_number = fields.Char(string='Invoice Number', readonly=True,
default=False, copy=False,
help="Unique number of the invoice, computed automatically when the invoice is created.")
reference = fields.Char(string='Invoice Reference',
help="The partner reference of this invoice.")
reference_type = fields.Selection('_get_reference_type', string='Payment Reference',
required=True, readonly=True, states={'draft': [('readonly', False)]},
default='none')
comment = fields.Text('Additional Information')
state = fields.Selection([
('draft','Draft'),
('proforma','Pro-forma'),
('proforma2','Pro-forma'),
('open','Open'),
('paid','Paid'),
('cancel','Cancelled'),
], string='Status', index=True, readonly=True, default='draft',
track_visibility='onchange', copy=False,
help=" * The 'Draft' status is used when a user is encoding a new and unconfirmed Invoice.\n"
" * The 'Pro-forma' when invoice is in Pro-forma status,invoice does not have an invoice number.\n"
" * The 'Open' status is used when user create invoice,a invoice number is generated.Its in open status till user does not pay invoice.\n"
" * The 'Paid' status is set automatically when the invoice is paid. Its related journal entries may or may not be reconciled.\n"
" * The 'Cancelled' status is used when user cancel invoice.")
sent = fields.Boolean(readonly=True, default=False, copy=False,
help="It indicates that the invoice has been sent.")
date_invoice = fields.Date(string='Invoice Date',
readonly=True, states={'draft': [('readonly', False)]}, index=True,
help="Keep empty to use the current date", copy=False)
date_due = fields.Date(string='Due Date',
readonly=True, states={'draft': [('readonly', False)]}, index=True, copy=False,
help="If you use payment terms, the due date will be computed automatically at the generation "
"of accounting entries. The payment term may compute several due dates, for example 50% "
"now and 50% in one month, but if you want to force a due date, make sure that the payment "
"term is not set on the invoice. If you keep the payment term and the due date empty, it "
"means direct payment.")
partner_id = fields.Many2one('res.partner', string='Partner', change_default=True,
required=True, readonly=True, states={'draft': [('readonly', False)]},
track_visibility='always')
payment_term = fields.Many2one('account.payment.term', string='Payment Terms',
readonly=True, states={'draft': [('readonly', False)]},
help="If you use payment terms, the due date will be computed automatically at the generation "
"of accounting entries. If you keep the payment term and the due date empty, it means direct payment. "
"The payment term may compute several due dates, for example 50% now, 50% in one month.")
period_id = fields.Many2one('account.period', string='Force Period',
domain=[('state', '!=', 'done')], copy=False,
help="Keep empty to use the period of the validation(invoice) date.",
readonly=True, states={'draft': [('readonly', False)]})
account_id = fields.Many2one('account.account', string='Account',
required=True, readonly=True, states={'draft': [('readonly', False)]},
help="The partner account used for this invoice.")
invoice_line = fields.One2many('account.invoice.line', 'invoice_id', string='Invoice Lines',
readonly=True, states={'draft': [('readonly', False)]}, copy=True)
tax_line = fields.One2many('account.invoice.tax', 'invoice_id', string='Tax Lines',
readonly=True, states={'draft': [('readonly', False)]}, copy=True)
move_id = fields.Many2one('account.move', string='Journal Entry',
readonly=True, index=True, ondelete='restrict', copy=False,
help="Link to the automatically generated Journal Items.")
amount_untaxed = fields.Float(string='Subtotal', digits=dp.get_precision('Account'),
store=True, readonly=True, compute='_compute_amount', track_visibility='always')
amount_tax = fields.Float(string='Tax', digits=dp.get_precision('Account'),
store=True, readonly=True, compute='_compute_amount')
amount_total = fields.Float(string='Total', digits=dp.get_precision('Account'),
store=True, readonly=True, compute='_compute_amount')
currency_id = fields.Many2one('res.currency', string='Currency',
required=True, readonly=True, states={'draft': [('readonly', False)]},
default=_default_currency, track_visibility='always')
journal_id = fields.Many2one('account.journal', string='Journal',
required=True, readonly=True, states={'draft': [('readonly', False)]},
default=_default_journal,
domain="[('type', 'in', {'out_invoice': ['sale'], 'out_refund': ['sale_refund'], 'in_refund': ['purchase_refund'], 'in_invoice': ['purchase']}.get(type, [])), ('company_id', '=', company_id)]")
company_id = fields.Many2one('res.company', string='Company', change_default=True,
required=True, readonly=True, states={'draft': [('readonly', False)]},
default=lambda self: self.env['res.company']._company_default_get('account.invoice'))
check_total = fields.Float(string='Verification Total', digits=dp.get_precision('Account'),
readonly=True, states={'draft': [('readonly', False)]}, default=0.0)
reconciled = fields.Boolean(string='Paid/Reconciled',
store=True, readonly=True, compute='_compute_reconciled',
help="It indicates that the invoice has been paid and the journal entry of the invoice has been reconciled with one or several journal entries of payment.")
partner_bank_id = fields.Many2one('res.partner.bank', string='Bank Account',
help='Bank Account Number to which the invoice will be paid. A Company bank account if this is a Customer Invoice or Supplier Refund, otherwise a Partner bank account number.',
readonly=True, states={'draft': [('readonly', False)]})
move_lines = fields.Many2many('account.move.line', string='Entry Lines',
compute='_compute_move_lines')
residual = fields.Float(string='Balance', digits=dp.get_precision('Account'),
compute='_compute_residual', store=True,
help="Remaining amount due.")
payment_ids = fields.Many2many('account.move.line', string='Payments',
compute='_compute_payments')
move_name = fields.Char(string='Journal Entry', readonly=True,
states={'draft': [('readonly', False)]}, copy=False)
user_id = fields.Many2one('res.users', string='Salesperson', track_visibility='onchange',
readonly=True, states={'draft': [('readonly', False)]},
default=lambda self: self.env.user)
fiscal_position = fields.Many2one('account.fiscal.position', string='Fiscal Position',
readonly=True, states={'draft': [('readonly', False)]})
commercial_partner_id = fields.Many2one('res.partner', string='Commercial Entity',
related='partner_id.commercial_partner_id', store=True, readonly=True,
help="The commercial entity that will be used on Journal Entries for this invoice")
_sql_constraints = [
('number_uniq', 'unique(number, company_id, journal_id, type)',
'Invoice Number must be unique per Company!'),
]
@api.model
def fields_view_get(self, view_id=None, view_type=False, toolbar=False, submenu=False):
context = self._context
if context.get('active_model') == 'res.partner' and context.get('active_ids'):
partner = self.env['res.partner'].browse(context['active_ids'])[0]
if not view_type:
view_id = self.env['ir.ui.view'].search([('name', '=', 'account.invoice.tree')]).id
view_type = 'tree'
elif view_type == 'form':
if partner.supplier and not partner.customer:
view_id = self.env['ir.ui.view'].search([('name', '=', 'account.invoice.supplier.form')]).id
elif partner.customer and not partner.supplier:
view_id = self.env['ir.ui.view'].search([('name', '=', 'account.invoice.form')]).id
res = super(account_invoice, self).fields_view_get(view_id=view_id, view_type=view_type, toolbar=toolbar, submenu=submenu)
# adapt selection of field journal_id
for field in res['fields']:
if field == 'journal_id' and type:
journal_select = self.env['account.journal']._name_search('', [('type', '=', type)], name_get_uid=1)
res['fields'][field]['selection'] = journal_select
doc = etree.XML(res['arch'])
if context.get('type'):
for node in doc.xpath("//field[@name='partner_bank_id']"):
if context['type'] == 'in_refund':
node.set('domain', "[('partner_id.ref_companies', 'in', [company_id])]")
elif context['type'] == 'out_refund':
node.set('domain', "[('partner_id', '=', partner_id)]")
if view_type == 'search':
if context.get('type') in ('out_invoice', 'out_refund'):
for node in doc.xpath("//group[@name='extended filter']"):
doc.remove(node)
if view_type == 'tree':
partner_string = _('Customer')
if context.get('type') in ('in_invoice', 'in_refund'):
partner_string = _('Supplier')
for node in doc.xpath("//field[@name='reference']"):
node.set('invisible', '0')
for node in doc.xpath("//field[@name='partner_id']"):
node.set('string', partner_string)
res['arch'] = etree.tostring(doc)
return res
@api.multi
def invoice_print(self):
""" Print the invoice and mark it as sent, so that we can see more
easily the next step of the workflow
"""
assert len(self) == 1, 'This option should only be used for a single id at a time.'
self.sent = True
return self.env['report'].get_action(self, 'account.report_invoice')
@api.multi
def action_invoice_sent(self):
""" Open a window to compose an email, with the edi invoice template
message loaded by default
"""
assert len(self) == 1, 'This option should only be used for a single id at a time.'
template = self.env.ref('account.email_template_edi_invoice', False)
compose_form = self.env.ref('mail.email_compose_message_wizard_form', False)
ctx = dict(
default_model='account.invoice',
default_res_id=self.id,
default_use_template=bool(template),
default_template_id=template.id,
default_composition_mode='comment',
mark_invoice_as_sent=True,
)
return {
'name': _('Compose Email'),
'type': 'ir.actions.act_window',
'view_type': 'form',
'view_mode': 'form',
'res_model': 'mail.compose.message',
'views': [(compose_form.id, 'form')],
'view_id': compose_form.id,
'target': 'new',
'context': ctx,
}
@api.multi
def confirm_paid(self):
return self.write({'state': 'paid'})
@api.multi
def unlink(self):
for invoice in self:
if invoice.state not in ('draft', 'cancel'):
raise Warning(_('You cannot delete an invoice which is not draft or cancelled. You should refund it instead.'))
elif invoice.internal_number:
raise Warning(_('You cannot delete an invoice after it has been validated (and received a number). You can set it back to "Draft" state and modify its content, then re-confirm it.'))
return super(account_invoice, self).unlink()
@api.multi
def onchange_partner_id(self, type, partner_id, date_invoice=False,
payment_term=False, partner_bank_id=False, company_id=False):
account_id = False
payment_term_id = False
fiscal_position = False
bank_id = False
if partner_id:
p = self.env['res.partner'].browse(partner_id)
rec_account = p.property_account_receivable
pay_account = p.property_account_payable
if company_id:
if p.property_account_receivable.company_id and \
p.property_account_receivable.company_id.id != company_id and \
p.property_account_payable.company_id and \
p.property_account_payable.company_id.id != company_id:
prop = self.env['ir.property']
rec_dom = [('name', '=', 'property_account_receivable'), ('company_id', '=', company_id)]
pay_dom = [('name', '=', 'property_account_payable'), ('company_id', '=', company_id)]
res_dom = [('res_id', '=', 'res.partner,%s' % partner_id)]
rec_prop = prop.search(rec_dom + res_dom) or prop.search(rec_dom)
pay_prop = prop.search(pay_dom + res_dom) or prop.search(pay_dom)
rec_account = rec_prop.get_by_record(rec_prop)
pay_account = pay_prop.get_by_record(pay_prop)
if not rec_account and not pay_account:
action = self.env.ref('account.action_account_config')
msg = _('Cannot find a chart of accounts for this company, You should configure it. \nPlease go to Account Configuration.')
raise RedirectWarning(msg, action.id, _('Go to the configuration panel'))
if type in ('out_invoice', 'out_refund'):
account_id = rec_account.id
payment_term_id = p.property_payment_term.id
else:
account_id = pay_account.id
payment_term_id = p.property_supplier_payment_term.id
fiscal_position = p.property_account_position.id
bank_id = p.bank_ids.id
result = {'value': {
'account_id': account_id,
'payment_term': payment_term_id,
'fiscal_position': fiscal_position,
}}
if type in ('in_invoice', 'in_refund'):
result['value']['partner_bank_id'] = bank_id
if payment_term != payment_term_id:
if payment_term_id:
to_update = self.onchange_payment_term_date_invoice(payment_term_id, date_invoice)
result['value'].update(to_update.get('value', {}))
else:
result['value']['date_due'] = False
if partner_bank_id != bank_id:
to_update = self.onchange_partner_bank(bank_id)
result['value'].update(to_update.get('value', {}))
return result
@api.multi
def onchange_journal_id(self, journal_id=False):
if journal_id:
journal = self.env['account.journal'].browse(journal_id)
return {
'value': {
'currency_id': journal.currency.id or journal.company_id.currency_id.id,
'company_id': journal.company_id.id,
}
}
return {}
@api.multi
def onchange_payment_term_date_invoice(self, payment_term_id, date_invoice):
if not date_invoice:
date_invoice = fields.Date.today()
if not payment_term_id:
# To make sure the invoice due date should contain due date which is
# entered by user when there is no payment term defined
return {'value': {'date_due': self.date_due or date_invoice}}
pterm = self.env['account.payment.term'].browse(payment_term_id)
pterm_list = pterm.compute(value=1, date_ref=date_invoice)[0]
if pterm_list:
return {'value': {'date_due': max(line[0] for line in pterm_list)}}
else:
raise except_orm(_('Insufficient Data!'),
_('The payment term of supplier does not have a payment term line.'))
@api.multi
def onchange_invoice_line(self, lines):
return {}
@api.multi
def onchange_partner_bank(self, partner_bank_id=False):
return {'value': {}}
@api.multi
def onchange_company_id(self, company_id, part_id, type, invoice_line, currency_id):
# TODO: add the missing context parameter when forward-porting in trunk
# so we can remove this hack!
self = self.with_context(self.env['res.users'].context_get())
values = {}
domain = {}
if company_id and part_id and type:
p = self.env['res.partner'].browse(part_id)
if p.property_account_payable and p.property_account_receivable and \
p.property_account_payable.company_id.id != company_id and \
p.property_account_receivable.company_id.id != company_id:
prop = self.env['ir.property']
rec_dom = [('name', '=', 'property_account_receivable'), ('company_id', '=', company_id)]
pay_dom = [('name', '=', 'property_account_payable'), ('company_id', '=', company_id)]
res_dom = [('res_id', '=', 'res.partner,%s' % part_id)]
rec_prop = prop.search(rec_dom + res_dom) or prop.search(rec_dom)
pay_prop = prop.search(pay_dom + res_dom) or prop.search(pay_dom)
rec_account = rec_prop.get_by_record(rec_prop)
pay_account = pay_prop.get_by_record(pay_prop)
if not rec_account and not pay_account:
action = self.env.ref('account.action_account_config')
msg = _('Cannot find a chart of accounts for this company, You should configure it. \nPlease go to Account Configuration.')
raise RedirectWarning(msg, action.id, _('Go to the configuration panel'))
if type in ('out_invoice', 'out_refund'):
acc_id = rec_account.id
else:
acc_id = pay_account.id
values= {'account_id': acc_id}
if self:
if company_id:
for line in self.invoice_line:
if not line.account_id:
continue
if line.account_id.company_id.id == company_id:
continue
accounts = self.env['account.account'].search([('name', '=', line.account_id.name), ('company_id', '=', company_id)])
if not accounts:
action = self.env.ref('account.action_account_config')
msg = _('Cannot find a chart of accounts for this company, You should configure it. \nPlease go to Account Configuration.')
raise RedirectWarning(msg, action.id, _('Go to the configuration panel'))
line.write({'account_id': accounts[-1].id})
else:
for line_cmd in invoice_line or []:
if len(line_cmd) >= 3 and isinstance(line_cmd[2], dict):
line = self.env['account.account'].browse(line_cmd[2]['account_id'])
if line.company_id.id != company_id:
raise except_orm(
_('Configuration Error!'),
_("Invoice line account's company and invoice's company does not match.")
)
if company_id and type:
journal_type = TYPE2JOURNAL[type]
journals = self.env['account.journal'].search([('type', '=', journal_type), ('company_id', '=', company_id)])
if journals:
values['journal_id'] = journals[0].id
journal_defaults = self.env['ir.values'].get_defaults_dict('account.invoice', 'type=%s' % type)
if 'journal_id' in journal_defaults:
values['journal_id'] = journal_defaults['journal_id']
if not values.get('journal_id'):
field_desc = journals.fields_get(['journal_id'])
type_label = next(t for t, label in field_desc['journal_id']['selection'] if t == journal_type)
action = self.env.ref('account.action_account_journal_form')
msg = _('Cannot find any account journal of type "%s" for this company, You should create one.\n Please go to Journal Configuration') % type_label
raise RedirectWarning(msg, action.id, _('Go to the configuration panel'))
domain = {'journal_id': [('id', 'in', journals.ids)]}
return {'value': values, 'domain': domain}
@api.multi
def action_cancel_draft(self):
# go from canceled state to draft state
self.write({'state': 'draft'})
self.delete_workflow()
self.create_workflow()
return True
@api.one
@api.returns('ir.ui.view')
def get_formview_id(self):
""" Update form view id of action to open the invoice """
if self.type == 'in_invoice':
return self.env.ref('account.invoice_supplier_form')
else:
return self.env.ref('account.invoice_form')
@api.multi
def move_line_id_payment_get(self):
# return the move line ids with the same account as the invoice self
if not self.id:
return []
query = """ SELECT l.id
FROM account_move_line l, account_invoice i
WHERE i.id = %s AND l.move_id = i.move_id AND l.account_id = i.account_id
"""
self._cr.execute(query, (self.id,))
return [row[0] for row in self._cr.fetchall()]
@api.multi
def test_paid(self):
# check whether all corresponding account move lines are reconciled
line_ids = self.move_line_id_payment_get()
if not line_ids:
return False
query = "SELECT reconcile_id FROM account_move_line WHERE id IN %s"
self._cr.execute(query, (tuple(line_ids),))
return all(row[0] for row in self._cr.fetchall())
@api.multi
def button_reset_taxes(self):
account_invoice_tax = self.env['account.invoice.tax']
ctx = dict(self._context)
for invoice in self:
self._cr.execute("DELETE FROM account_invoice_tax WHERE invoice_id=%s AND manual is False", (invoice.id,))
self.invalidate_cache()
partner = invoice.partner_id
if partner.lang:
ctx['lang'] = partner.lang
for taxe in account_invoice_tax.compute(invoice).values():
account_invoice_tax.create(taxe)
# dummy write on self to trigger recomputations
return self.with_context(ctx).write({'invoice_line': []})
@api.multi
def button_compute(self, set_total=False):
self.button_reset_taxes()
for invoice in self:
if set_total:
invoice.check_total = invoice.amount_total
return True
@staticmethod
def _convert_ref(ref):
return (ref or '').replace('/','')
@api.multi
def _get_analytic_lines(self):
""" Return a list of dict for creating analytic lines for self[0] """
company_currency = self.company_id.currency_id
sign = 1 if self.type in ('out_invoice', 'in_refund') else -1
iml = self.env['account.invoice.line'].move_line_get(self.id)
for il in iml:
if il['account_analytic_id']:
if self.type in ('in_invoice', 'in_refund'):
ref = self.reference
else:
ref = self._convert_ref(self.number)
if not self.journal_id.analytic_journal_id:
raise except_orm(_('No Analytic Journal!'),
_("You have to define an analytic journal on the '%s' journal!") % (self.journal_id.name,))
currency = self.currency_id.with_context(date=self.date_invoice)
il['analytic_lines'] = [(0,0, {
'name': il['name'],
'date': self.date_invoice,
'account_id': il['account_analytic_id'],
'unit_amount': il['quantity'],
'amount': currency.compute(il['price'], company_currency) * sign,
'product_id': il['product_id'],
'product_uom_id': il['uos_id'],
'general_account_id': il['account_id'],
'journal_id': self.journal_id.analytic_journal_id.id,
'ref': ref,
})]
return iml
@api.multi
def action_date_assign(self):
for inv in self:
res = inv.onchange_payment_term_date_invoice(inv.payment_term.id, inv.date_invoice)
if res and res.get('value'):
inv.write(res['value'])
return True
@api.multi
def finalize_invoice_move_lines(self, move_lines):
""" finalize_invoice_move_lines(move_lines) -> move_lines
Hook method to be overridden in additional modules to verify and
possibly alter the move lines to be created by an invoice, for
special cases.
:param move_lines: list of dictionaries with the account.move.lines (as for create())
:return: the (possibly updated) final move_lines to create for this invoice
"""
return move_lines
@api.multi
def check_tax_lines(self, compute_taxes):
account_invoice_tax = self.env['account.invoice.tax']
company_currency = self.company_id.currency_id
if not self.tax_line:
for tax in compute_taxes.values():
account_invoice_tax.create(tax)
else:
tax_key = []
for tax in self.tax_line:
if tax.manual:
continue
key = (tax.tax_code_id.id, tax.base_code_id.id, tax.account_id.id)
tax_key.append(key)
if key not in compute_taxes:
raise except_orm(_('Warning!'), _('Global taxes defined, but they are not in invoice lines !'))
base = compute_taxes[key]['base']
if abs(base - tax.base) > company_currency.rounding:
raise except_orm(_('Warning!'), _('Tax base different!\nClick on compute to update the tax base.'))
for key in compute_taxes:
if key not in tax_key:
raise except_orm(_('Warning!'), _('Taxes are missing!\nClick on compute button.'))
@api.multi
def compute_invoice_totals(self, company_currency, ref, invoice_move_lines):
total = 0
total_currency = 0
for line in invoice_move_lines:
if self.currency_id != company_currency:
currency = self.currency_id.with_context(date=self.date_invoice or fields.Date.today())
line['currency_id'] = currency.id
line['amount_currency'] = line['price']
line['price'] = currency.compute(line['price'], company_currency)
else:
line['currency_id'] = False
line['amount_currency'] = False
line['ref'] = ref
if self.type in ('out_invoice','in_refund'):
total += line['price']
total_currency += line['amount_currency'] or line['price']
line['price'] = - line['price']
else:
total -= line['price']
total_currency -= line['amount_currency'] or line['price']
return total, total_currency, invoice_move_lines
def inv_line_characteristic_hashcode(self, invoice_line):
"""Overridable hashcode generation for invoice lines. Lines having the same hashcode
will be grouped together if the journal has the 'group line' option. Of course a module
can add fields to invoice lines that would need to be tested too before merging lines
or not."""
return "%s-%s-%s-%s-%s" % (
invoice_line['account_id'],
invoice_line.get('tax_code_id', 'False'),
invoice_line.get('product_id', 'False'),
invoice_line.get('analytic_account_id', 'False'),
invoice_line.get('date_maturity', 'False'),
)
def group_lines(self, iml, line):
"""Merge account move lines (and hence analytic lines) if invoice line hashcodes are equals"""
if self.journal_id.group_invoice_lines:
line2 = {}
for x, y, l in line:
tmp = self.inv_line_characteristic_hashcode(l)
if tmp in line2:
am = line2[tmp]['debit'] - line2[tmp]['credit'] + (l['debit'] - l['credit'])
line2[tmp]['debit'] = (am > 0) and am or 0.0
line2[tmp]['credit'] = (am < 0) and -am or 0.0
line2[tmp]['tax_amount'] += l['tax_amount']
line2[tmp]['analytic_lines'] += l['analytic_lines']
else:
line2[tmp] = l
line = []
for key, val in line2.items():
line.append((0,0,val))
return line
@api.multi
def action_move_create(self):
""" Creates invoice related analytics and financial move lines """
account_invoice_tax = self.env['account.invoice.tax']
account_move = self.env['account.move']
for inv in self:
if not inv.journal_id.sequence_id:
raise except_orm(_('Error!'), _('Please define sequence on the journal related to this invoice.'))
if not inv.invoice_line:
raise except_orm(_('No Invoice Lines!'), _('Please create some invoice lines.'))
if inv.move_id:
continue
ctx = dict(self._context, lang=inv.partner_id.lang)
if not inv.date_invoice:
inv.with_context(ctx).write({'date_invoice': fields.Date.context_today(self)})
date_invoice = inv.date_invoice
company_currency = inv.company_id.currency_id
# create the analytical lines, one move line per invoice line
iml = inv._get_analytic_lines()
# check if taxes are all computed
compute_taxes = account_invoice_tax.compute(inv)
inv.check_tax_lines(compute_taxes)
# I disabled the check_total feature
group_check_total = self.env.ref('account.group_supplier_inv_check_total')
if self.env.user in group_check_total.users:
if inv.type in ('in_invoice', 'in_refund') and abs(inv.check_total - inv.amount_total) >= (inv.currency_id.rounding / 2.0):
raise except_orm(_('Bad Total!'), _('Please verify the price of the invoice!\nThe encoded total does not match the computed total.'))
if inv.payment_term:
total_fixed = total_percent = 0
for line in inv.payment_term.line_ids:
if line.value == 'fixed':
total_fixed += line.value_amount
if line.value == 'procent':
total_percent += line.value_amount
total_fixed = (total_fixed * 100) / (inv.amount_total or 1.0)
if (total_fixed + total_percent) > 100:
raise except_orm(_('Error!'), _("Cannot create the invoice.\nThe related payment term is probably misconfigured as it gives a computed amount greater than the total invoiced amount. In order to avoid rounding issues, the latest line of your payment term must be of type 'balance'."))
# one move line per tax line
iml += account_invoice_tax.move_line_get(inv.id)
if inv.type in ('in_invoice', 'in_refund'):
ref = inv.reference
else:
ref = self._convert_ref(inv.number)
diff_currency = inv.currency_id != company_currency
# create one move line for the total and possibly adjust the other lines amount
total, total_currency, iml = inv.with_context(ctx).compute_invoice_totals(company_currency, ref, iml)
name = inv.name or inv.supplier_invoice_number or '/'
totlines = []
if inv.payment_term:
totlines = inv.with_context(ctx).payment_term.compute(total, date_invoice)[0]
if totlines:
res_amount_currency = total_currency
ctx['date'] = date_invoice
for i, t in enumerate(totlines):
if inv.currency_id != company_currency:
amount_currency = company_currency.with_context(ctx).compute(t[1], inv.currency_id)
else:
amount_currency = False
# last line: add the diff
res_amount_currency -= amount_currency or 0
if i + 1 == len(totlines):
amount_currency += res_amount_currency
iml.append({
'type': 'dest',
'name': name,
'price': t[1],
'account_id': inv.account_id.id,
'date_maturity': t[0],
'amount_currency': diff_currency and amount_currency,
'currency_id': diff_currency and inv.currency_id.id,
'ref': ref,
})
else:
iml.append({
'type': 'dest',
'name': name,
'price': total,
'account_id': inv.account_id.id,
'date_maturity': inv.date_due,
'amount_currency': diff_currency and total_currency,
'currency_id': diff_currency and inv.currency_id.id,
'ref': ref
})
date = date_invoice
part = self.env['res.partner']._find_accounting_partner(inv.partner_id)
line = [(0, 0, self.line_get_convert(l, part.id, date)) for l in iml]
line = inv.group_lines(iml, line)
journal = inv.journal_id.with_context(ctx)
if journal.centralisation:
raise except_orm(_('User Error!'),
_('You cannot create an invoice on a centralized journal. Uncheck the centralized counterpart box in the related journal from the configuration menu.'))
line = inv.finalize_invoice_move_lines(line)
move_vals = {
'ref': inv.reference or inv.name,
'line_id': line,
'journal_id': journal.id,
'date': date,
'narration': inv.comment,
'company_id': inv.company_id.id,
}
ctx['company_id'] = inv.company_id.id
period = inv.period_id
if not period:
period = period.with_context(ctx).find(date_invoice)[:1]
if period:
move_vals['period_id'] = period.id
for i in line:
i[2]['period_id'] = period.id
ctx['invoice'] = inv
move = account_move.with_context(ctx).create(move_vals)
# make the invoice point to that move
vals = {
'move_id': move.id,
'period_id': period.id,
'move_name': move.name,
}
inv.with_context(ctx).write(vals)
# Pass invoice in context in method post: used if you want to get the same
# account move reference when creating the same invoice after a cancelled one:
move.post()
self._log_event()
return True
@api.multi
def invoice_validate(self):
return self.write({'state': 'open'})
@api.model
def line_get_convert(self, line, part, date):
return {
'date_maturity': line.get('date_maturity', False),
'partner_id': part,
'name': line['name'][:64],
'date': date,
'debit': line['price']>0 and line['price'],
'credit': line['price']<0 and -line['price'],
'account_id': line['account_id'],
'analytic_lines': line.get('analytic_lines', []),
'amount_currency': line['price']>0 and abs(line.get('amount_currency', False)) or -abs(line.get('amount_currency', False)),
'currency_id': line.get('currency_id', False),
'tax_code_id': line.get('tax_code_id', False),
'tax_amount': line.get('tax_amount', False),
'ref': line.get('ref', False),
'quantity': line.get('quantity',1.00),
'product_id': line.get('product_id', False),
'product_uom_id': line.get('uos_id', False),
'analytic_account_id': line.get('account_analytic_id', False),
}
@api.multi
def action_number(self):
#TODO: not correct fix but required a fresh values before reading it.
self.write({})
for inv in self:
self.write({'internal_number': inv.number})
if inv.type in ('in_invoice', 'in_refund'):
if not inv.reference:
ref = self._convert_ref(inv.number)
else:
ref = inv.reference
else:
ref = self._convert_ref(inv.number)
self._cr.execute(""" UPDATE account_move SET ref=%s
WHERE id=%s AND (ref IS NULL OR ref = '')""",
(ref, inv.move_id.id))
self._cr.execute(""" UPDATE account_move_line SET ref=%s
WHERE move_id=%s AND (ref IS NULL OR ref = '')""",
(ref, inv.move_id.id))
self._cr.execute(""" UPDATE account_analytic_line SET ref=%s
FROM account_move_line
WHERE account_move_line.move_id = %s AND
account_analytic_line.move_id = account_move_line.id""",
(ref, inv.move_id.id))
self.invalidate_cache()
return True
@api.multi
def action_cancel(self):
moves = self.env['account.move']
for inv in self:
if inv.move_id:
moves += inv.move_id
if inv.payment_ids:
for move_line in inv.payment_ids:
if move_line.reconcile_partial_id.line_partial_ids:
raise except_orm(_('Error!'), _('You cannot cancel an invoice which is partially paid. You need to unreconcile related payment entries first.'))
# First, set the invoices as cancelled and detach the move ids
self.write({'state': 'cancel', 'move_id': False})
if moves:
# second, invalidate the move(s)
moves.button_cancel()
# delete the move this invoice was pointing to
# Note that the corresponding move_lines and move_reconciles
# will be automatically deleted too
moves.unlink()
self._log_event(-1.0, 'Cancel Invoice')
return True
###################
@api.multi
def _log_event(self, factor=1.0, name='Open Invoice'):
#TODO: implement messages system
return True
@api.multi
def name_get(self):
TYPES = {
'out_invoice': _('Invoice'),
'in_invoice': _('Supplier Invoice'),
'out_refund': _('Refund'),
'in_refund': _('Supplier Refund'),
}
result = []
for inv in self:
result.append((inv.id, "%s %s" % (inv.number or TYPES[inv.type], inv.name or '')))
return result
@api.model
def name_search(self, name, args=None, operator='ilike', limit=100):
args = args or []
recs = self.browse()
if name:
recs = self.search([('number', '=', name)] + args, limit=limit)
if not recs:
recs = self.search([('name', operator, name)] + args, limit=limit)
return recs.name_get()
@api.model
def _refund_cleanup_lines(self, lines):
""" Convert records to dict of values suitable for one2many line creation
:param recordset lines: records to convert
:return: list of command tuple for one2many line creation [(0, 0, dict of valueis), ...]
"""
result = []
for line in lines:
values = {}
for name, field in line._fields.iteritems():
if name in MAGIC_COLUMNS:
continue
elif field.type == 'many2one':
values[name] = line[name].id
elif field.type not in ['many2many', 'one2many']:
values[name] = line[name]
elif name == 'invoice_line_tax_id':
values[name] = [(6, 0, line[name].ids)]
result.append((0, 0, values))
return result
@api.model
def _prepare_refund(self, invoice, date=None, period_id=None, description=None, journal_id=None):
""" Prepare the dict of values to create the new refund from the invoice.
This method may be overridden to implement custom
refund generation (making sure to call super() to establish
a clean extension chain).
:param record invoice: invoice to refund
:param string date: refund creation date from the wizard
:param integer period_id: force account.period from the wizard
:param string description: description of the refund from the wizard
:param integer journal_id: account.journal from the wizard
:return: dict of value to create() the refund
"""
values = {}
for field in ['name', 'reference', 'comment', 'date_due', 'partner_id', 'company_id',
'account_id', 'currency_id', 'payment_term', 'user_id', 'fiscal_position']:
if invoice._fields[field].type == 'many2one':
values[field] = invoice[field].id
else:
values[field] = invoice[field] or False
values['invoice_line'] = self._refund_cleanup_lines(invoice.invoice_line)
tax_lines = filter(lambda l: l.manual, invoice.tax_line)
values['tax_line'] = self._refund_cleanup_lines(tax_lines)
if journal_id:
journal = self.env['account.journal'].browse(journal_id)
elif invoice['type'] == 'in_invoice':
journal = self.env['account.journal'].search([('type', '=', 'purchase_refund')], limit=1)
else:
journal = self.env['account.journal'].search([('type', '=', 'sale_refund')], limit=1)
values['journal_id'] = journal.id
values['type'] = TYPE2REFUND[invoice['type']]
values['date_invoice'] = date or fields.Date.today()
values['state'] = 'draft'
values['number'] = False
if period_id:
values['period_id'] = period_id
if description:
values['name'] = description
return values
@api.multi
@api.returns('self')
def refund(self, date=None, period_id=None, description=None, journal_id=None):
new_invoices = self.browse()
for invoice in self:
# create the new invoice
values = self._prepare_refund(invoice, date=date, period_id=period_id,
description=description, journal_id=journal_id)
new_invoices += self.create(values)
return new_invoices
@api.v8
def pay_and_reconcile(self, pay_amount, pay_account_id, period_id, pay_journal_id,
writeoff_acc_id, writeoff_period_id, writeoff_journal_id, name=''):
# TODO check if we can use different period for payment and the writeoff line
assert len(self)==1, "Can only pay one invoice at a time."
# Take the seq as name for move
SIGN = {'out_invoice': -1, 'in_invoice': 1, 'out_refund': 1, 'in_refund': -1}
direction = SIGN[self.type]
# take the chosen date
date = self._context.get('date_p') or fields.Date.today()
# Take the amount in currency and the currency of the payment
if self._context.get('amount_currency') and self._context.get('currency_id'):
amount_currency = self._context['amount_currency']
currency_id = self._context['currency_id']
else:
amount_currency = False
currency_id = False
pay_journal = self.env['account.journal'].browse(pay_journal_id)
if self.type in ('in_invoice', 'in_refund'):
ref = self.reference
else:
ref = self._convert_ref(self.number)
partner = self.partner_id._find_accounting_partner(self.partner_id)
name = name or self.invoice_line.name or self.number
# Pay attention to the sign for both debit/credit AND amount_currency
l1 = {
'name': name,
'debit': direction * pay_amount > 0 and direction * pay_amount,
'credit': direction * pay_amount < 0 and -direction * pay_amount,
'account_id': self.account_id.id,
'partner_id': partner.id,
'ref': ref,
'date': date,
'currency_id': currency_id,
'amount_currency': direction * (amount_currency or 0.0),
'company_id': self.company_id.id,
}
l2 = {
'name': name,
'debit': direction * pay_amount < 0 and -direction * pay_amount,
'credit': direction * pay_amount > 0 and direction * pay_amount,
'account_id': pay_account_id,
'partner_id': partner.id,
'ref': ref,
'date': date,
'currency_id': currency_id,
'amount_currency': -direction * (amount_currency or 0.0),
'company_id': self.company_id.id,
}
move = self.env['account.move'].create({
'ref': ref,
'line_id': [(0, 0, l1), (0, 0, l2)],
'journal_id': pay_journal_id,
'period_id': period_id,
'date': date,
})
move_ids = (move | self.move_id).ids
self._cr.execute("SELECT id FROM account_move_line WHERE move_id IN %s",
(tuple(move_ids),))
lines = self.env['account.move.line'].browse([r[0] for r in self._cr.fetchall()])
lines2rec = lines.browse()
total = 0.0
for line in itertools.chain(lines, self.payment_ids):
if line.account_id == self.account_id:
lines2rec += line
total += (line.debit or 0.0) - (line.credit or 0.0)
inv_id, name = self.name_get()[0]
if not round(total, self.env['decimal.precision'].precision_get('Account')) or writeoff_acc_id:
lines2rec.reconcile('manual', writeoff_acc_id, writeoff_period_id, writeoff_journal_id)
else:
code = self.currency_id.symbol
# TODO: use currency's formatting function
msg = _("Invoice partially paid: %s%s of %s%s (%s%s remaining).") % \
(pay_amount, code, self.amount_total, code, total, code)
self.message_post(body=msg)
lines2rec.reconcile_partial('manual')
# Update the stored value (fields.function), so we write to trigger recompute
return self.write({})
@api.v7
def pay_and_reconcile(self, cr, uid, ids, pay_amount, pay_account_id, period_id, pay_journal_id,
writeoff_acc_id, writeoff_period_id, writeoff_journal_id, context=None, name=''):
recs = self.browse(cr, uid, ids, context)
return recs.pay_and_reconcile(pay_amount, pay_account_id, period_id, pay_journal_id,
writeoff_acc_id, writeoff_period_id, writeoff_journal_id, name=name)
class account_invoice_line(models.Model):
_name = "account.invoice.line"
_description = "Invoice Line"
_order = "invoice_id,sequence,id"
@api.one
@api.depends('price_unit', 'discount', 'invoice_line_tax_id', 'quantity',
'product_id', 'invoice_id.partner_id', 'invoice_id.currency_id')
def _compute_price(self):
price = self.price_unit * (1 - (self.discount or 0.0) / 100.0)
taxes = self.invoice_line_tax_id.compute_all(price, self.quantity, product=self.product_id, partner=self.invoice_id.partner_id)
self.price_subtotal = taxes['total']
if self.invoice_id:
self.price_subtotal = self.invoice_id.currency_id.round(self.price_subtotal)
@api.model
def _default_price_unit(self):
if not self._context.get('check_total'):
return 0
total = self._context['check_total']
for l in self._context.get('invoice_line', []):
if isinstance(l, (list, tuple)) and len(l) >= 3 and l[2]:
vals = l[2]
price = vals.get('price_unit', 0) * (1 - vals.get('discount', 0) / 100.0)
total = total - (price * vals.get('quantity'))
taxes = vals.get('invoice_line_tax_id')
if taxes and len(taxes[0]) >= 3 and taxes[0][2]:
taxes = self.env['account.tax'].browse(taxes[0][2])
tax_res = taxes.compute_all(price, vals.get('quantity'),
product=vals.get('product_id'), partner=self._context.get('partner_id'))
for tax in tax_res['taxes']:
total = total - tax['amount']
return total
@api.model
def _default_account(self):
# XXX this gets the default account for the user's company,
# it should get the default account for the invoice's company
# however, the invoice's company does not reach this point
if self._context.get('type') in ('out_invoice', 'out_refund'):
return self.env['ir.property'].get('property_account_income_categ', 'product.category')
else:
return self.env['ir.property'].get('property_account_expense_categ', 'product.category')
name = fields.Text(string='Description', required=True)
origin = fields.Char(string='Source Document',
help="Reference of the document that produced this invoice.")
sequence = fields.Integer(string='Sequence', default=10,
help="Gives the sequence of this line when displaying the invoice.")
invoice_id = fields.Many2one('account.invoice', string='Invoice Reference',
ondelete='cascade', index=True)
uos_id = fields.Many2one('product.uom', string='Unit of Measure',
ondelete='set null', index=True)
product_id = fields.Many2one('product.product', string='Product',
ondelete='set null', index=True)
account_id = fields.Many2one('account.account', string='Account',
required=True, domain=[('type', 'not in', ['view', 'closed'])],
default=_default_account,
help="The income or expense account related to the selected product.")
price_unit = fields.Float(string='Unit Price', required=True,
digits= dp.get_precision('Product Price'),
default=_default_price_unit)
price_subtotal = fields.Float(string='Amount', digits= dp.get_precision('Account'),
store=True, readonly=True, compute='_compute_price')
quantity = fields.Float(string='Quantity', digits= dp.get_precision('Product Unit of Measure'),
required=True, default=1)
discount = fields.Float(string='Discount (%)', digits= dp.get_precision('Discount'),
default=0.0)
invoice_line_tax_id = fields.Many2many('account.tax',
'account_invoice_line_tax', 'invoice_line_id', 'tax_id',
string='Taxes', domain=[('parent_id', '=', False)])
account_analytic_id = fields.Many2one('account.analytic.account',
string='Analytic Account')
company_id = fields.Many2one('res.company', string='Company',
related='invoice_id.company_id', store=True, readonly=True)
partner_id = fields.Many2one('res.partner', string='Partner',
related='invoice_id.partner_id', store=True, readonly=True)
@api.model
def fields_view_get(self, view_id=None, view_type='form', toolbar=False, submenu=False):
res = super(account_invoice_line, self).fields_view_get(
view_id=view_id, view_type=view_type, toolbar=toolbar, submenu=submenu)
if self._context.get('type'):
doc = etree.XML(res['arch'])
for node in doc.xpath("//field[@name='product_id']"):
if self._context['type'] in ('in_invoice', 'in_refund'):
node.set('domain', "[('purchase_ok', '=', True)]")
else:
node.set('domain', "[('sale_ok', '=', True)]")
res['arch'] = etree.tostring(doc)
return res
@api.multi
def product_id_change(self, product, uom_id, qty=0, name='', type='out_invoice',
partner_id=False, fposition_id=False, price_unit=False, currency_id=False,
context=None, company_id=None):
context = context or {}
company_id = company_id if company_id is not None else context.get('company_id', False)
self = self.with_context(company_id=company_id, force_company=company_id)
if not partner_id:
raise except_orm(_('No Partner Defined!'), _("You must first select a partner!"))
if not product:
if type in ('in_invoice', 'in_refund'):
return {'value': {}, 'domain': {'product_uom': []}}
else:
return {'value': {'price_unit': 0.0}, 'domain': {'product_uom': []}}
values = {}
part = self.env['res.partner'].browse(partner_id)
fpos = self.env['account.fiscal.position'].browse(fposition_id)
if part.lang:
self = self.with_context(lang=part.lang)
product = self.env['product.product'].browse(product)
values['name'] = product.partner_ref
if type in ('out_invoice', 'out_refund'):
account = product.property_account_income or product.categ_id.property_account_income_categ
else:
account = product.property_account_expense or product.categ_id.property_account_expense_categ
account = fpos.map_account(account)
if account:
values['account_id'] = account.id
if type in ('out_invoice', 'out_refund'):
taxes = product.taxes_id or account.tax_ids
if product.description_sale:
values['name'] += '\n' + product.description_sale
else:
taxes = product.supplier_taxes_id or account.tax_ids
if product.description_purchase:
values['name'] += '\n' + product.description_purchase
taxes = fpos.map_tax(taxes)
values['invoice_line_tax_id'] = taxes.ids
if type in ('in_invoice', 'in_refund'):
values['price_unit'] = price_unit or product.standard_price
else:
values['price_unit'] = product.list_price
values['uos_id'] = uom_id or product.uom_id.id
domain = {'uos_id': [('category_id', '=', product.uom_id.category_id.id)]}
company = self.env['res.company'].browse(company_id)
currency = self.env['res.currency'].browse(currency_id)
if company and currency:
if company.currency_id != currency:
if type in ('in_invoice', 'in_refund'):
values['price_unit'] = product.standard_price
values['price_unit'] = values['price_unit'] * currency.rate
if values['uos_id'] and values['uos_id'] != product.uom_id.id:
values['price_unit'] = self.env['product.uom']._compute_price(
product.uom_id.id, values['price_unit'], values['uos_id'])
return {'value': values, 'domain': domain}
@api.multi
def uos_id_change(self, product, uom, qty=0, name='', type='out_invoice', partner_id=False,
fposition_id=False, price_unit=False, currency_id=False, context=None, company_id=None):
context = context or {}
company_id = company_id if company_id != None else context.get('company_id', False)
self = self.with_context(company_id=company_id)
result = self.product_id_change(
product, uom, qty, name, type, partner_id, fposition_id, price_unit,
currency_id, context=context, company_id=company_id,
)
warning = {}
if not uom:
result['value']['price_unit'] = 0.0
if product and uom:
prod = self.env['product.product'].browse(product)
prod_uom = self.env['product.uom'].browse(uom)
if prod.uom_id.category_id != prod_uom.category_id:
warning = {
'title': _('Warning!'),
'message': _('The selected unit of measure is not compatible with the unit of measure of the product.'),
}
result['value']['uos_id'] = prod.uom_id.id
if warning:
result['warning'] = warning
return result
@api.model
def move_line_get(self, invoice_id):
inv = self.env['account.invoice'].browse(invoice_id)
currency = inv.currency_id.with_context(date=inv.date_invoice)
company_currency = inv.company_id.currency_id
res = []
for line in inv.invoice_line:
mres = self.move_line_get_item(line)
if not mres:
continue
res.append(mres)
tax_code_found = False
taxes = line.invoice_line_tax_id.compute_all(
(line.price_unit * (1.0 - (line.discount or 0.0) / 100.0)),
line.quantity, line.product_id, inv.partner_id)['taxes']
for tax in taxes:
if inv.type in ('out_invoice', 'in_invoice'):
tax_code_id = tax['base_code_id']
tax_amount = line.price_subtotal * tax['base_sign']
else:
tax_code_id = tax['ref_base_code_id']
tax_amount = line.price_subtotal * tax['ref_base_sign']
if tax_code_found:
if not tax_code_id:
continue
res.append(dict(mres))
res[-1]['price'] = 0.0
res[-1]['account_analytic_id'] = False
elif not tax_code_id:
continue
tax_code_found = True
res[-1]['tax_code_id'] = tax_code_id
res[-1]['tax_amount'] = currency.compute(tax_amount, company_currency)
return res
@api.model
def move_line_get_item(self, line):
return {
'type': 'src',
'name': line.name.split('\n')[0][:64],
'price_unit': line.price_unit,
'quantity': line.quantity,
'price': line.price_subtotal,
'account_id': line.account_id.id,
'product_id': line.product_id.id,
'uos_id': line.uos_id.id,
'account_analytic_id': line.account_analytic_id.id,
'taxes': line.invoice_line_tax_id,
}
#
# Set the tax field according to the account and the fiscal position
#
@api.multi
def onchange_account_id(self, product_id, partner_id, inv_type, fposition_id, account_id):
if not account_id:
return {}
unique_tax_ids = []
account = self.env['account.account'].browse(account_id)
if not product_id:
fpos = self.env['account.fiscal.position'].browse(fposition_id)
unique_tax_ids = fpos.map_tax(account.tax_ids).ids
else:
product_change_result = self.product_id_change(product_id, False, type=inv_type,
partner_id=partner_id, fposition_id=fposition_id, company_id=account.company_id.id)
if 'invoice_line_tax_id' in product_change_result.get('value', {}):
unique_tax_ids = product_change_result['value']['invoice_line_tax_id']
return {'value': {'invoice_line_tax_id': unique_tax_ids}}
class account_invoice_tax(models.Model):
_name = "account.invoice.tax"
_description = "Invoice Tax"
_order = 'sequence'
@api.one
@api.depends('base', 'base_amount', 'amount', 'tax_amount')
def _compute_factors(self):
self.factor_base = self.base_amount / self.base if self.base else 1.0
self.factor_tax = self.tax_amount / self.amount if self.amount else 1.0
invoice_id = fields.Many2one('account.invoice', string='Invoice Line',
ondelete='cascade', index=True)
name = fields.Char(string='Tax Description',
required=True)
account_id = fields.Many2one('account.account', string='Tax Account',
required=True, domain=[('type', 'not in', ['view', 'income', 'closed'])])
account_analytic_id = fields.Many2one('account.analytic.account', string='Analytic account')
base = fields.Float(string='Base', digits=dp.get_precision('Account'))
amount = fields.Float(string='Amount', digits=dp.get_precision('Account'))
manual = fields.Boolean(string='Manual', default=True)
sequence = fields.Integer(string='Sequence',
help="Gives the sequence order when displaying a list of invoice tax.")
base_code_id = fields.Many2one('account.tax.code', string='Base Code',
help="The account basis of the tax declaration.")
base_amount = fields.Float(string='Base Code Amount', digits=dp.get_precision('Account'),
default=0.0)
tax_code_id = fields.Many2one('account.tax.code', string='Tax Code',
help="The tax basis of the tax declaration.")
tax_amount = fields.Float(string='Tax Code Amount', digits=dp.get_precision('Account'),
default=0.0)
company_id = fields.Many2one('res.company', string='Company',
related='account_id.company_id', store=True, readonly=True)
factor_base = fields.Float(string='Multipication factor for Base code',
compute='_compute_factors')
factor_tax = fields.Float(string='Multipication factor Tax code',
compute='_compute_factors')
@api.multi
def base_change(self, base, currency_id=False, company_id=False, date_invoice=False):
factor = self.factor_base if self else 1
company = self.env['res.company'].browse(company_id)
if currency_id and company.currency_id:
currency = self.env['res.currency'].browse(currency_id)
currency = currency.with_context(date=date_invoice or fields.Date.today())
base = currency.compute(base * factor, company.currency_id, round=False)
return {'value': {'base_amount': base}}
@api.multi
def amount_change(self, amount, currency_id=False, company_id=False, date_invoice=False):
factor = self.factor_tax if self else 1
company = self.env['res.company'].browse(company_id)
if currency_id and company.currency_id:
currency = self.env['res.currency'].browse(currency_id)
currency = currency.with_context(date=date_invoice or fields.Date.today())
amount = currency.compute(amount * factor, company.currency_id, round=False)
return {'value': {'tax_amount': amount}}
@api.v8
def compute(self, invoice):
tax_grouped = {}
currency = invoice.currency_id.with_context(date=invoice.date_invoice or fields.Date.today())
company_currency = invoice.company_id.currency_id
for line in invoice.invoice_line:
taxes = line.invoice_line_tax_id.compute_all(
(line.price_unit * (1 - (line.discount or 0.0) / 100.0)),
line.quantity, line.product_id, invoice.partner_id)['taxes']
for tax in taxes:
val = {
'invoice_id': invoice.id,
'name': tax['name'],
'amount': tax['amount'],
'manual': False,
'sequence': tax['sequence'],
'base': currency.round(tax['price_unit'] * line['quantity']),
}
if invoice.type in ('out_invoice','in_invoice'):
val['base_code_id'] = tax['base_code_id']
val['tax_code_id'] = tax['tax_code_id']
val['base_amount'] = currency.compute(val['base'] * tax['base_sign'], company_currency, round=False)
val['tax_amount'] = currency.compute(val['amount'] * tax['tax_sign'], company_currency, round=False)
val['account_id'] = tax['account_collected_id'] or line.account_id.id
val['account_analytic_id'] = tax['account_analytic_collected_id']
else:
val['base_code_id'] = tax['ref_base_code_id']
val['tax_code_id'] = tax['ref_tax_code_id']
val['base_amount'] = currency.compute(val['base'] * tax['ref_base_sign'], company_currency, round=False)
val['tax_amount'] = currency.compute(val['amount'] * tax['ref_tax_sign'], company_currency, round=False)
val['account_id'] = tax['account_paid_id'] or line.account_id.id
val['account_analytic_id'] = tax['account_analytic_paid_id']
# If the taxes generate moves on the same financial account as the invoice line
# and no default analytic account is defined at the tax level, propagate the
# analytic account from the invoice line to the tax line. This is necessary
# in situations were (part of) the taxes cannot be reclaimed,
# to ensure the tax move is allocated to the proper analytic account.
if not val.get('account_analytic_id') and line.account_analytic_id and val['account_id'] == line.account_id.id:
val['account_analytic_id'] = line.account_analytic_id.id
key = (val['tax_code_id'], val['base_code_id'], val['account_id'])
if not key in tax_grouped:
tax_grouped[key] = val
else:
tax_grouped[key]['base'] += val['base']
tax_grouped[key]['amount'] += val['amount']
tax_grouped[key]['base_amount'] += val['base_amount']
tax_grouped[key]['tax_amount'] += val['tax_amount']
for t in tax_grouped.values():
t['base'] = currency.round(t['base'])
t['amount'] = currency.round(t['amount'])
t['base_amount'] = currency.round(t['base_amount'])
t['tax_amount'] = currency.round(t['tax_amount'])
return tax_grouped
@api.v7
def compute(self, cr, uid, invoice_id, context=None):
recs = self.browse(cr, uid, [], context)
invoice = recs.env['account.invoice'].browse(invoice_id)
return recs.compute(invoice)
@api.model
def move_line_get(self, invoice_id):
res = []
self._cr.execute(
'SELECT * FROM account_invoice_tax WHERE invoice_id = %s',
(invoice_id,)
)
for row in self._cr.dictfetchall():
if not (row['amount'] or row['tax_code_id'] or row['tax_amount']):
continue
res.append({
'type': 'tax',
'name': row['name'],
'price_unit': row['amount'],
'quantity': 1,
'price': row['amount'] or 0.0,
'account_id': row['account_id'],
'tax_code_id': row['tax_code_id'],
'tax_amount': row['tax_amount'],
'account_analytic_id': row['account_analytic_id'],
})
return res
class res_partner(models.Model):
# Inherits partner and adds invoice information in the partner form
_inherit = 'res.partner'
invoice_ids = fields.One2many('account.invoice', 'partner_id', string='Invoices',
readonly=True)
def _find_accounting_partner(self, partner):
'''
Find the partner for which the accounting entries will be created
'''
return partner.commercial_partner_id
class mail_compose_message(models.Model):
_inherit = 'mail.compose.message'
@api.multi
def send_mail(self):
context = self._context
if context.get('default_model') == 'account.invoice' and \
context.get('default_res_id') and context.get('mark_invoice_as_sent'):
invoice = self.env['account.invoice'].browse(context['default_res_id'])
invoice = invoice.with_context(mail_post_autofollow=True)
invoice.write({'sent': True})
invoice.message_post(body=_("Invoice sent"))
return super(mail_compose_message, self).send_mail()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
agpl-3.0
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
4605,
199,
3,
199,
3,
259,
7653,
12,
3232,
5800,
8259,
9274,
199,
3,
259,
1898,
334,
35,
9,
8353,
13,
6542,
11947,
12361,
8642,
1014,
921,
9864,
14,
1235,
10121,
199,
3,
199,
3,
259,
961,
2240,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
259,
652,
1334,
314,
2895,
402,
314,
1664,
4265,
1696,
1684,
844,
465,
199,
3,
259,
3267,
701,
314,
2868,
2290,
2752,
12,
1902,
1015,
650,
402,
314,
199,
3,
259,
844,
12,
503,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
259,
961,
2240,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
259,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
259,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
199,
3,
259,
1664,
4265,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
259,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
4265,
1696,
1684,
844,
199,
3,
259,
3180,
543,
642,
2240,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
3,
199,
4605,
199,
199,
646,
7975,
199,
504,
14490,
492,
7559,
199,
199,
504,
5166,
492,
1709,
12,
1504,
12,
2986,
12,
485,
199,
504,
5166,
14,
3924,
492,
871,
63,
1025,
12,
15902,
12,
18532,
3849,
199,
646,
5166,
14,
10788,
14,
6355,
63,
6833,
465,
12392,
199,
199,
3,
4412,
8485,
730,
370,
9605,
730,
199,
2711,
18,
15465,
7648,
748,
275,
469,
272,
283,
548,
63,
5404,
356,
283,
8515,
297,
272,
283,
262,
63,
5404,
356,
283,
9533,
297,
272,
283,
548,
63,
18440,
356,
283,
8515,
63,
18440,
297,
272,
283,
262,
63,
18440,
356,
283,
9533,
63,
18440,
297,
199,
93,
199,
199,
3,
4412,
8485,
730,
370,
32219,
730,
199,
2711,
18,
8279,
6131,
275,
469,
272,
283,
548,
63,
5404,
356,
283,
548,
63,
18440,
297,
263,
327,
22397,
19868,
272,
283,
262,
63,
5404,
356,
283,
262,
63,
18440,
297,
3515,
327,
29083,
5697,
19868,
272,
283,
548,
63,
18440,
356,
283,
548,
63,
5404,
297,
263,
327,
22397,
15397,
725,
272,
283,
262,
63,
18440,
356,
283,
262,
63,
5404,
297,
3515,
327,
29083,
5697,
15397,
725,
199,
93,
199,
199,
19973,
63,
28427,
275,
661,
344,
297,
283,
981,
63,
1535,
297,
283,
981,
63,
602,
297,
283,
952,
63,
1535,
297,
283,
952,
63,
602,
358,
421,
199,
533,
2933,
63,
5404,
8,
992,
14,
1685,
304,
272,
485,
354,
275,
298,
2048,
14,
5404,
2,
272,
485,
6486,
275,
788,
1198,
14,
2671,
418,
272,
485,
1802,
275,
298,
21092,
2,
272,
485,
1648,
275,
298,
1955,
4328,
12,
1305,
4328,
2,
272,
485,
3885,
275,
469,
267,
283,
466,
356,
469,
267,
1660,
267,
283,
929,
356,
469,
288,
283,
2048,
14,
2037,
63,
5404,
63,
16555,
356,
2400,
291,
12,
2467,
12,
1747,
12,
1559,
12,
4027,
29,
403,
26,
1559,
14,
929,
508,
283,
16555,
7,
436,
1559,
14,
466,
315,
661,
548,
63,
5404,
297,
283,
548,
63,
18440,
659,
288,
283,
2048,
14,
2037,
63,
5404,
63,
24372,
356,
2400,
291,
12,
2467,
12,
1747,
12,
1559,
12,
4027,
29,
403,
26,
1559,
14,
929,
508,
283,
1490,
7,
436,
1559,
14,
466,
315,
661,
548,
63,
5404,
297,
283,
548,
63,
18440,
659,
267,
1660,
272,
789,
339,
768,
1246,
14,
368,
272,
768,
1246,
14,
8912,
360,
5404,
63,
604,
14,
4777,
63,
954,
2923,
297,
283,
5530,
63,
604,
14,
4606,
358,
272,
347,
485,
3357,
63,
4606,
8,
277,
304,
267,
291,
14,
4606,
63,
324,
5530,
379,
275,
3089,
8,
604,
14,
4777,
63,
954,
2923,
367,
1004,
315,
291,
14,
5404,
63,
604,
9,
267,
291,
14,
4606,
63,
5530,
275,
3089,
8,
604,
14,
4606,
367,
1004,
315,
291,
14,
5530,
63,
604,
9,
267,
291,
14,
4606,
63,
2923,
275,
291,
14,
4606,
63,
324,
5530,
379,
435,
291,
14,
4606,
63,
5530,
339,
768,
1246,
14,
1238,
272,
347,
485,
885,
63,
7067,
8,
277,
304,
267,
4572,
63,
466,
275,
291,
423,
1100,
14,
362,
360,
466,
297,
283,
548,
63,
5404,
358,
267,
4572,
63,
1313,
275,
4572,
63,
466,
340,
1228,
8,
5350,
63,
466,
12,
769,
9,
587,
359,
5350,
63,
466,
61,
267,
7233,
63,
344,
275,
291,
423,
1100,
14,
362,
360,
4627,
63,
344,
297,
291,
14,
1813,
14,
751,
14,
4627,
63,
344,
14,
344,
9,
267,
2881,
275,
359,
288,
661,
466,
297,
283,
262,
297,
2457,
8,
403,
12,
2341,
8,
2711,
18,
15465,
7648,
748,
14,
362,
12,
4572,
63,
1313,
11508,
288,
661,
4627,
63,
344,
297,
6291,
7233,
63,
344,
395,
267,
1622,
267,
372,
291,
14,
1813,
459,
2048,
14,
7067,
2278,
1733,
8,
2261,
12,
2304,
29,
17,
9,
339,
768,
1246,
14,
1238,
272,
347,
485,
885,
63,
4968,
8,
277,
304,
267,
9605,
275,
291,
423,
885,
63,
7067,
342,
267,
372,
9605,
14,
4968,
503,
9605,
14,
4627,
63,
344,
14,
4968,
63,
344,
339,
768,
1246,
14,
1238,
272,
768,
1246,
14,
5808,
360,
2048,
14,
9782,
14,
7067,
358,
272,
347,
485,
362,
63,
7067,
63,
9782,
8,
277,
12,
4572,
63,
466,
304,
267,
408,
1432,
314,
20705,
9605,
5226,
370,
314,
1627,
8485,
730,
14,
408,
267,
9605,
63,
466,
275,
11511,
18,
15465,
7648,
748,
14,
362,
8,
5350,
63,
466,
12,
283,
8515,
358,
267,
9605,
275,
291,
14,
1813,
459,
2048,
14,
9782,
14,
7067,
2278,
1733,
8318,
466,
297,
6291,
9605,
63,
466,
4360,
2304,
29,
17,
9,
267,
340,
440,
9605,
26,
288,
746,
871,
63,
1025,
6723,
1944,
14279,
764,
22142,
15659,
355,
3824,
5556,
1471,
5627,
376,
20705,
9605,
402,
730,
1543,
83,
7,
9124,
450,
334,
7067,
63,
466,
4641,
267,
372,
9605,
339,
768,
1246,
14,
368,
272,
768,
1246,
14,
8912,
360,
2048,
63,
344,
297,
283,
1185,
63,
344,
14,
604,
63,
344,
14,
2048,
63,
344,
297
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
4605,
199,
3,
199,
3,
259,
7653,
12,
3232,
5800,
8259,
9274,
199,
3,
259,
1898,
334,
35,
9,
8353,
13,
6542,
11947,
12361,
8642,
1014,
921,
9864,
14,
1235,
10121,
199,
3,
199,
3,
259,
961,
2240,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
259,
652,
1334,
314,
2895,
402,
314,
1664,
4265,
1696,
1684,
844,
465,
199,
3,
259,
3267,
701,
314,
2868,
2290,
2752,
12,
1902,
1015,
650,
402,
314,
199,
3,
259,
844,
12,
503,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
259,
961,
2240,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
259,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
259,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
199,
3,
259,
1664,
4265,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
259,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
4265,
1696,
1684,
844,
199,
3,
259,
3180,
543,
642,
2240,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
3,
199,
4605,
199,
199,
646,
7975,
199,
504,
14490,
492,
7559,
199,
199,
504,
5166,
492,
1709,
12,
1504,
12,
2986,
12,
485,
199,
504,
5166,
14,
3924,
492,
871,
63,
1025,
12,
15902,
12,
18532,
3849,
199,
646,
5166,
14,
10788,
14,
6355,
63,
6833,
465,
12392,
199,
199,
3,
4412,
8485,
730,
370,
9605,
730,
199,
2711,
18,
15465,
7648,
748,
275,
469,
272,
283,
548,
63,
5404,
356,
283,
8515,
297,
272,
283,
262,
63,
5404,
356,
283,
9533,
297,
272,
283,
548,
63,
18440,
356,
283,
8515,
63,
18440,
297,
272,
283,
262,
63,
18440,
356,
283,
9533,
63,
18440,
297,
199,
93,
199,
199,
3,
4412,
8485,
730,
370,
32219,
730,
199,
2711,
18,
8279,
6131,
275,
469,
272,
283,
548,
63,
5404,
356,
283,
548,
63,
18440,
297,
263,
327,
22397,
19868,
272,
283,
262,
63,
5404,
356,
283,
262,
63,
18440,
297,
3515,
327,
29083,
5697,
19868,
272,
283,
548,
63,
18440,
356,
283,
548,
63,
5404,
297,
263,
327,
22397,
15397,
725,
272,
283,
262,
63,
18440,
356,
283,
262,
63,
5404,
297,
3515,
327,
29083,
5697,
15397,
725,
199,
93,
199,
199,
19973,
63,
28427,
275,
661,
344,
297,
283,
981,
63,
1535,
297,
283,
981,
63,
602,
297,
283,
952,
63,
1535,
297,
283,
952,
63,
602,
358,
421,
199,
533,
2933,
63,
5404,
8,
992,
14,
1685,
304,
272,
485,
354,
275,
298,
2048,
14,
5404,
2,
272,
485,
6486,
275,
788,
1198,
14,
2671,
418,
272,
485,
1802,
275,
298,
21092,
2,
272,
485,
1648,
275,
298,
1955,
4328,
12,
1305,
4328,
2,
272,
485,
3885,
275,
469,
267,
283,
466,
356,
469,
267,
1660,
267,
283,
929,
356,
469,
288,
283,
2048,
14,
2037,
63,
5404,
63,
16555,
356,
2400,
291,
12,
2467,
12,
1747,
12,
1559,
12,
4027,
29,
403,
26,
1559,
14,
929,
508,
283,
16555,
7,
436,
1559,
14,
466,
315,
661,
548,
63,
5404,
297,
283,
548,
63,
18440,
659,
288,
283,
2048,
14,
2037,
63,
5404,
63,
24372,
356,
2400,
291,
12,
2467,
12,
1747,
12,
1559,
12,
4027,
29,
403,
26,
1559,
14,
929,
508,
283,
1490,
7,
436,
1559,
14,
466,
315,
661,
548,
63,
5404,
297,
283,
548,
63,
18440,
659,
267,
1660,
272,
789,
339,
768,
1246,
14,
368,
272,
768,
1246,
14,
8912,
360,
5404,
63,
604,
14,
4777,
63,
954,
2923,
297,
283,
5530,
63,
604,
14,
4606,
358,
272,
347,
485,
3357,
63,
4606,
8,
277,
304,
267,
291,
14,
4606,
63,
324,
5530,
379,
275,
3089,
8,
604,
14,
4777,
63,
954,
2923,
367,
1004,
315,
291,
14,
5404,
63,
604,
9,
267,
291,
14,
4606,
63,
5530,
275,
3089,
8,
604,
14,
4606,
367,
1004,
315,
291,
14,
5530,
63,
604,
9,
267,
291,
14,
4606,
63,
2923,
275,
291,
14,
4606,
63,
324,
5530,
379,
435,
291,
14,
4606,
63,
5530,
339,
768,
1246,
14,
1238,
272,
347,
485,
885,
63,
7067,
8,
277,
304,
267,
4572,
63,
466,
275,
291,
423,
1100,
14,
362,
360,
466,
297,
283,
548,
63,
5404,
358,
267,
4572,
63,
1313,
275,
4572,
63,
466,
340,
1228,
8,
5350,
63,
466,
12,
769,
9,
587,
359,
5350,
63,
466,
61,
267,
7233,
63,
344,
275,
291,
423,
1100,
14,
362,
360,
4627,
63,
344,
297,
291,
14,
1813,
14,
751,
14,
4627,
63,
344,
14,
344,
9,
267,
2881,
275,
359,
288,
661,
466,
297,
283,
262,
297,
2457,
8,
403,
12,
2341,
8,
2711,
18,
15465,
7648,
748,
14,
362,
12,
4572,
63,
1313,
11508,
288,
661,
4627,
63,
344,
297,
6291,
7233,
63,
344,
395,
267,
1622,
267,
372,
291,
14,
1813,
459,
2048,
14,
7067,
2278,
1733,
8,
2261,
12,
2304,
29,
17,
9,
339,
768,
1246,
14,
1238,
272,
347,
485,
885,
63,
4968,
8,
277,
304,
267,
9605,
275,
291,
423,
885,
63,
7067,
342,
267,
372,
9605,
14,
4968,
503,
9605,
14,
4627,
63,
344,
14,
4968,
63,
344,
339,
768,
1246,
14,
1238,
272,
768,
1246,
14,
5808,
360,
2048,
14,
9782,
14,
7067,
358,
272,
347,
485,
362,
63,
7067,
63,
9782,
8,
277,
12,
4572,
63,
466,
304,
267,
408,
1432,
314,
20705,
9605,
5226,
370,
314,
1627,
8485,
730,
14,
408,
267,
9605,
63,
466,
275,
11511,
18,
15465,
7648,
748,
14,
362,
8,
5350,
63,
466,
12,
283,
8515,
358,
267,
9605,
275,
291,
14,
1813,
459,
2048,
14,
9782,
14,
7067,
2278,
1733,
8318,
466,
297,
6291,
9605,
63,
466,
4360,
2304,
29,
17,
9,
267,
340,
440,
9605,
26,
288,
746,
871,
63,
1025,
6723,
1944,
14279,
764,
22142,
15659,
355,
3824,
5556,
1471,
5627,
376,
20705,
9605,
402,
730,
1543,
83,
7,
9124,
450,
334,
7067,
63,
466,
4641,
267,
372,
9605,
339,
768,
1246,
14,
368,
272,
768,
1246,
14,
8912,
360,
2048,
63,
344,
297,
283,
1185,
63,
344,
14,
604,
63,
344,
14,
2048,
63,
344,
297,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
Ptival/PeaCoq
|
ucsd/analysis/plot.py
|
1
|
9691
|
#!/usr/bin/env python2
from __future__ import print_function
import csv, sys, os.path
from datetime import datetime
from boomslang import *
def usage():
print('Usage: plot.py data.csv')
class Entry:
def __init__(self, usr, ver, stm, ctm, cmd, pay):
self.username = usr
self.version = ver
self.serverT = stm
self.clientT = ctm
self.command = cmd
self.payload = pay
def __repr__(self):
return '''
Entry( username: %s
, version: %s
, serverT: %s
, clientT: %s
, command: %s
, payload: "%s"
)''' % ( self.username
, self.version
, self.serverT
, self.clientT
, self.command
, self.payload
)
def __str__(self):
return self.repr()
def main():
if len(sys.argv) < 2:
usage()
sys.exit(1)
path = sys.argv[1]
if not os.path.isfile(path):
print('Error: "%s" does not exist.' % path, file=sys.stderr)
sys.exit(1)
with open(path, 'rb') as f:
log = []
for row in csv.reader(f):
usr = row[0]
ver = row[1]
stm = datetime.strptime(row[2], '%Y-%m-%d-%H-%M-%S-%f')
try:
ctm = datetime.strptime(row[3], '%Y-%m-%d-%H-%M-%S-%f')
except:
ctm = None
cmd = row[4]
pay = row[5]
log.append(Entry(usr, ver, stm, ctm, cmd, pay))
# these buckets will be used in some functions
userBuckets = {}
for l in log:
if not l.username in userBuckets:
userBuckets[l.username] = []
userBuckets[l.username].append(l)
commandsPerDay(log)
clicksPerUser(userBuckets)
qedsPerUser(userBuckets)
nbCommands(userBuckets)
nbLefts(userBuckets)
def commandsPerDay(log):
cmdSum = {}
for l in log:
d = l.serverT.strftime('%y-%m-%d')
if not (d in cmdSum):
cmdSum[d] = 0
cmdSum[d] += 1
plot = Plot()
line = Line()
line.xValues = []
line.yValues = []
labs = []
n = 1
for d in sorted(cmdSum.keys()):
line.xValues.append(n)
line.yValues.append(cmdSum[d])
labs.append(d)
n += 1
if len(labs) > 10:
labpos = [(i * n) / 10 for i in range(10)]
else:
labpos = range(len(labs))
line.xTickLabels = [labs[i] for i in labpos]
line.xTickLabelPoints = labpos
line.xTickLabelProperties = {
"color" : "blue",
"rotation" : 30,
"fontsize" : 9
}
plot.yLabel = "Total Commands"
plot.add(line)
plot.setDimensions(9,6)
plot.save("cmds-by-day.png")
# I will use these buckets multiple times
def clicksPerUser(userBuckets):
clicks = {}
for bucket in userBuckets:
for l in userBuckets[bucket]:
if l.command == "CLICK":
if not (l.username in clicks):
clicks[l.username] = 0
clicks[l.username] += 1
plot = Plot()
bar = Bar()
bar.xValues = []
bar.yValues = []
labs = []
n = 1
for d in sorted(clicks.keys()):
user = d[:5]
bar.xValues.append(n)
bar.yValues.append(clicks[d])
labs.append(user)
n += 1
bar.xTickLabels = labs
bar.xTickLabelProperties = {
"color" : "blue",
"rotation" : 30,
"fontsize" : 9
}
plot.yLabel = "Clicks per user"
plot.add(bar)
plot.setDimensions(9,6)
plot.save("clicks-per-user.png")
def qedsPerUser(userBuckets):
qeds = {}
for bucket in userBuckets:
for l in userBuckets[bucket]:
if l.command == "QED":
if not (l.username in qeds):
qeds[l.username] = 0
qeds[l.username] += 1
plot = Plot()
bar = Bar()
bar.xValues = []
bar.yValues = []
labs = []
n = 1
for d in sorted(qeds.keys()):
user = d[:5]
bar.xValues.append(n)
bar.yValues.append(qeds[d])
labs.append(user)
n += 1
bar.xTickLabels = labs
bar.xTickLabelProperties = {
"color" : "blue",
"rotation" : 30,
"fontsize" : 9
}
plot.yLabel = "QEDs per user"
plot.add(bar)
plot.setDimensions(9,6)
plot.save("qeds-per-user.png")
def nbCommands(userBuckets):
counts = {}
for bucket in userBuckets:
counter = 0
counting = False
for l in userBuckets[bucket]:
if counting:
if l.command == "EXITPROOFTREE" or l.command == "LOAD" or l.command == "NEWSESSION" or l.command == "USERIDENTIFIED" or l.command == "REWIND":
if not counter in counts:
counts[counter] = 0
counts[counter] += 1
counting = False
elif l.command == "QUERY":
continue
else:
counter += 1
else:
if l.command == "AUTOENTERPROOFTREE":
counting = True
counter = 0
else:
continue
bucketSize = 50
bucketCounts = {}
del counts[0]
for count in counts:
bucketIndex = (count - 1) / bucketSize
if bucketIndex not in bucketCounts:
bucketCounts[bucketIndex] = 0
bucketCounts[bucketIndex] += counts[count]
plot = Plot()
bar = Bar()
bar.xValues = []
bar.yValues = []
labs = []
n = 1
for d in bucketCounts.keys():
bar.xValues.append(n)
bar.yValues.append(bucketCounts[d])
rangeEnd = ((d + 1) * bucketSize)
labs.append(str(rangeEnd))
n += 1
bar.xTickLabels = labs
bar.xTickLabelProperties = {
"color" : "blue",
"rotation" : 30,
"fontsize" : 9
}
plot.xLabel = "Approximate number of actions"
plot.add(bar)
plot.setDimensions(9,6)
plot.save("actions-per-proof.png")
def nbLefts(userBuckets):
counts = {}
for bucket in userBuckets:
counter = 0
counting = False
for l in userBuckets[bucket]:
if counting:
if l.command == "EXITPROOFTREE" or l.command == "LOAD" or l.command == "NEWSESSION" or l.command == "USERIDENTIFIED" or l.command == "REWIND":
if not counter in counts:
counts[counter] = 0
counts[counter] += 1
counting = False
elif l.command == "LEFT":
counter += 1
else:
continue
else:
if l.command == "AUTOENTERPROOFTREE":
counting = True
counter = 0
else:
continue
plot = Plot()
bar = Bar()
bar.xValues = []
bar.yValues = []
labs = []
n = 1
for d in sorted(counts.keys()):
bar.xValues.append(n)
bar.yValues.append(counts[d])
labs.append(str(d))
n += 1
bar.xTickLabels = labs
bar.xTickLabelProperties = {
"color" : "blue",
"rotation" : 90,
"fontsize" : 9
}
plot.xLabel = "Number of lefts"
plot.add(bar)
plot.setDimensions(9,6)
plot.save("lefts-per-proof.png")
if __name__ == '__main__':
main()
x = '''
# commands per day
plot = Plot()
line = Line()
tlabs = []
line.xValues = []
line.yValues = []
n = 1
for e in log:
tlabs.append(e.clientT)
line.xValues.append(n)
line.yValues.append(int(row[1]))
n += 1
tpts = [(i * n) / 10 for i in range(10)]
line.xTickLabels = [tlabs[i] for i in tpts]
line.xTickLabelPoints = tpts
line.xTickLabelProperties = {
"color" : "blue",
"rotation" : 30,
"fontsize" : 9
}
plot.yLabel = "Diff Size"
plot.add(line)
plot.setDimensions(9,6)
plot.save("time-diffs.png")
# commands per day
plot = Plot()
line = Line()
tlabs = []
line.xValues = []
line.yValues = []
with open('counts.csv', 'rb') as f:
n = 1
for row in csv.reader(f):
tlabs.append(row[0])
line.xValues.append(n)
line.yValues.append(int(row[1]))
n += 1
tpts = [(i * n) / 10 for i in range(10)]
line.xTickLabels = [tlabs[i] for i in tpts]
line.xTickLabelPoints = tpts
line.xTickLabelProperties = {
"color" : "blue",
"rotation" : 30,
"fontsize" : 9
}
plot.yLabel = "Diff Size"
plot.add(line)
plot.setDimensions(9,6)
plot.save("time-diffs.png")
# day
plot = Plot()
bar = Bar()
day = [ 0 for i in range(7)]
nday = [ 0 for i in range(7)]
with open('counts.csv', 'rb') as f:
for row in csv.reader(f):
d = time.strptime(row[0], "%Y-%m-%d %H:%M:%S")
day[d.tm_wday] += int(row[1])
nday[d.tm_wday] += 1
bar.xValues = range(7)
bar.yValues = [float(day[i]) / float(nday[i]) for i in range(7)]
bar.xTickLabels = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"]
bar.color = "green"
bar.xTickLabelProperties = {
"color" : "blue",
"fontsize" : 12
}
plot.xLimits = (-1, 7)
plot.yLabel = "Avg Diff Size"
plot.add(bar)
plot.setDimensions(9,4)
plot.save("day-diffs.png")
# hour
plot = Plot()
bar = Bar()
hour = [0 for i in range(24)]
nhour = [0 for i in range(24)]
with open('counts.csv', 'rb') as f:
for row in csv.reader(f):
d = time.strptime(row[0], "%Y-%m-%d %H:%M:%S")
hour[d.tm_hour] += int(row[1])
nhour[d.tm_hour] += 1
bar.xValues = range(24)
bar.yValues = [float(hour[i]) / float(nhour[i]) if nhour[i] != 0 else 0 for i in range(24)]
bar.xTickLabelPoints = [0, 3, 6, 9, 12, 15, 18, 21]
bar.xTickLabels = ["12am", "3am", "6am", "9am", "12pm", "3pm", "6pm", "9pm"]
bar.color = "red"
bar.xTickLabelProperties = {
"color" : "blue",
"fontsize" : 12
}
plot.xLimits = (-1, 24)
plot.yLabel = "Avg Diff Size"
plot.add(bar)
plot.setDimensions(9,4)
'''
|
mit
|
[
3381,
2647,
15,
1393,
15,
1813,
2366,
18,
199,
504,
636,
2443,
363,
492,
870,
63,
1593,
199,
199,
646,
7392,
12,
984,
12,
747,
14,
515,
199,
504,
2197,
492,
2197,
199,
504,
1234,
676,
2482,
621,
492,
627,
199,
199,
318,
4503,
837,
272,
870,
360,
7692,
26,
5137,
14,
647,
666,
14,
4737,
358,
199,
199,
533,
11855,
26,
272,
347,
636,
826,
721,
277,
12,
30464,
12,
809,
12,
410,
77,
12,
286,
7574,
12,
2088,
12,
8633,
304,
267,
291,
14,
2473,
275,
30464,
267,
291,
14,
1023,
275,
809,
267,
291,
14,
1000,
52,
275,
410,
77,
267,
291,
14,
1258,
52,
275,
286,
7574,
267,
291,
14,
1531,
275,
2088,
267,
291,
14,
4749,
275,
8633,
339,
347,
636,
2722,
721,
277,
304,
267,
372,
1449,
199,
3900,
8,
3434,
26,
450,
83,
1362,
2360,
1015,
26,
450,
83,
1362,
2360,
1654,
52,
26,
450,
83,
1362,
2360,
1890,
52,
26,
450,
83,
1362,
2360,
1414,
26,
450,
83,
1362,
2360,
4886,
26,
2071,
83,
2,
1362,
776,
2344,
450,
334,
291,
14,
2473,
288,
2360,
291,
14,
1023,
288,
2360,
291,
14,
1000,
52,
288,
2360,
291,
14,
1258,
52,
288,
2360,
291,
14,
1531,
288,
2360,
291,
14,
4749,
288,
776,
339,
347,
636,
495,
721,
277,
304,
267,
372,
291,
14,
2722,
342,
199,
199,
318,
2446,
837,
272,
340,
822,
8,
1274,
14,
3020,
9,
665,
499,
26,
267,
4503,
342,
267,
984,
14,
2224,
8,
17,
9,
339,
931,
275,
984,
14,
3020,
59,
17,
61,
272,
340,
440,
747,
14,
515,
14,
6292,
8,
515,
304,
267,
870,
360,
547,
26,
2071,
83,
2,
1630,
440,
2187,
3530,
450,
931,
12,
570,
29,
1274,
14,
3083,
9,
267,
984,
14,
2224,
8,
17,
9,
339,
543,
1551,
8,
515,
12,
283,
4848,
358,
465,
289,
26,
267,
943,
275,
942,
267,
367,
1962,
315,
7392,
14,
5503,
8,
70,
304,
288,
30464,
275,
1962,
59,
16,
61,
288,
809,
275,
1962,
59,
17,
61,
288,
410,
77,
275,
2197,
14,
9866,
8,
1143,
59,
18,
467,
1543,
57,
3295,
77,
3295,
68,
3295,
40,
3295,
45,
3295,
51,
3295,
70,
358,
288,
862,
26,
355,
286,
7574,
275,
2197,
14,
9866,
8,
1143,
59,
19,
467,
1543,
57,
3295,
77,
3295,
68,
3295,
40,
3295,
45,
3295,
51,
3295,
70,
358,
288,
871,
26,
355,
286,
7574,
275,
488,
288,
2088,
275,
1962,
59,
20,
61,
288,
8633,
275,
1962,
59,
21,
61,
288,
943,
14,
740,
8,
3900,
8,
2647,
12,
809,
12,
410,
77,
12,
286,
7574,
12,
2088,
12,
8633,
430,
339,
327,
3520,
18655,
911,
506,
1202,
315,
2005,
3423,
339,
922,
12311,
83,
275,
1052,
272,
367,
634,
315,
943,
26,
489,
340,
440,
634,
14,
2473,
315,
922,
12311,
83,
26,
267,
922,
12311,
83,
59,
76,
14,
2473,
61,
275,
942,
489,
922,
12311,
83,
59,
76,
14,
2473,
1055,
740,
8,
76,
9,
339,
3718,
2623,
12631,
8,
793,
9,
272,
5053,
5618,
2623,
1899,
8,
751,
12311,
83,
9,
272,
1894,
5923,
2623,
1899,
8,
751,
12311,
83,
9,
272,
8526,
14680,
8,
751,
12311,
83,
9,
272,
8526,
8185,
83,
8,
751,
12311,
83,
9,
421,
199,
318,
3718,
2623,
12631,
8,
793,
304,
339,
2088,
6959,
275,
1052,
272,
367,
634,
315,
943,
26,
267,
366,
275,
634,
14,
1000,
52,
14,
6205,
3508,
89,
3295,
77,
3295,
68,
358,
267,
340,
440,
334,
68,
315,
2088,
6959,
304,
288,
2088,
6959,
59,
68,
61,
275,
378,
267,
2088,
6959,
59,
68,
61,
847,
413,
339,
5137,
275,
14794,
342,
272,
1004,
275,
7030,
342,
272,
1004,
14,
88,
6550,
275,
942,
272,
1004,
14,
89,
6550,
275,
942,
272,
634,
2101,
275,
942,
339,
302,
275,
413,
272,
367,
366,
315,
3355,
8,
1760,
6959,
14,
1612,
5109,
267,
1004,
14,
88,
6550,
14,
740,
8,
78,
9,
267,
1004,
14,
89,
6550,
14,
740,
8,
1760,
6959,
59,
68,
566,
267,
634,
2101,
14,
740,
8,
68,
9,
267,
302,
847,
413,
339,
340,
822,
8,
76,
2101,
9,
690,
1616,
26,
267,
19888,
1712,
275,
3842,
73,
627,
302,
9,
1182,
1616,
367,
284,
315,
1425,
8,
709,
1874,
272,
587,
26,
267,
19888,
1712,
275,
1425,
8,
552,
8,
76,
2101,
430,
272,
1004,
14,
88,
11763,
14016,
275,
359,
76,
2101,
59,
73,
61,
367,
284,
315,
19888,
1712,
61,
272,
1004,
14,
88,
11763,
4314,
10225,
275,
19888,
1712,
339,
1004,
14,
88,
11763,
4314,
8516,
275,
469,
267,
298,
2326,
2,
520,
298,
6304,
401,
267,
298,
15362,
2,
520,
4233,
12,
267,
298,
22124,
2,
520,
1749,
272,
789,
272,
5137,
14,
89,
4314,
275,
298,
7316,
5817,
83,
2,
272,
5137,
14,
525,
8,
604,
9,
272,
5137,
14,
409,
23370,
8,
25,
12,
22,
9,
272,
5137,
14,
2117,
480,
12975,
13,
991,
13,
2977,
14,
4524,
531,
339,
327,
473,
911,
675,
3520,
18655,
3663,
5431,
421,
199,
318,
5053,
5618,
2623,
1899,
8,
751,
12311,
83,
304,
339,
5053,
5618,
275,
1052,
272,
367,
5315,
315,
922,
12311,
83,
26,
489,
367,
634,
315,
922,
12311,
83,
59,
4623,
2189,
267,
340,
634,
14,
1531,
508,
298,
1981,
13884,
582,
881,
340,
440,
334,
76,
14,
2473,
315,
5053,
5618,
304,
288,
5053,
5618,
59,
76,
14,
2473,
61,
275,
378,
881,
5053,
5618,
59,
76,
14,
2473,
61,
847,
413,
339,
5137,
275,
14794,
342,
272,
4681,
275,
12377,
342,
272,
4681,
14,
88,
6550,
275,
942,
272,
4681,
14,
89,
6550,
275,
942,
272,
634,
2101,
275,
942,
339,
302,
275,
413,
272,
367,
366,
315,
3355,
8,
4891,
83,
14,
1612,
5109,
267,
922,
275,
366,
1491,
21,
61,
267,
4681,
14,
88,
6550,
14,
740,
8,
78,
9,
267,
4681,
14,
89,
6550,
14,
740,
8,
4891,
83,
59,
68,
566,
267,
634,
2101,
14,
740,
8,
751,
9,
267,
302,
847,
413,
339,
4681,
14,
88,
11763,
14016,
275,
634,
2101,
339,
4681,
14,
88,
11763,
4314,
8516,
275,
469,
267,
298,
2326,
2,
520,
298,
6304,
401,
267,
298,
15362,
2,
520
] |
[
2647,
15,
1393,
15,
1813,
2366,
18,
199,
504,
636,
2443,
363,
492,
870,
63,
1593,
199,
199,
646,
7392,
12,
984,
12,
747,
14,
515,
199,
504,
2197,
492,
2197,
199,
504,
1234,
676,
2482,
621,
492,
627,
199,
199,
318,
4503,
837,
272,
870,
360,
7692,
26,
5137,
14,
647,
666,
14,
4737,
358,
199,
199,
533,
11855,
26,
272,
347,
636,
826,
721,
277,
12,
30464,
12,
809,
12,
410,
77,
12,
286,
7574,
12,
2088,
12,
8633,
304,
267,
291,
14,
2473,
275,
30464,
267,
291,
14,
1023,
275,
809,
267,
291,
14,
1000,
52,
275,
410,
77,
267,
291,
14,
1258,
52,
275,
286,
7574,
267,
291,
14,
1531,
275,
2088,
267,
291,
14,
4749,
275,
8633,
339,
347,
636,
2722,
721,
277,
304,
267,
372,
1449,
199,
3900,
8,
3434,
26,
450,
83,
1362,
2360,
1015,
26,
450,
83,
1362,
2360,
1654,
52,
26,
450,
83,
1362,
2360,
1890,
52,
26,
450,
83,
1362,
2360,
1414,
26,
450,
83,
1362,
2360,
4886,
26,
2071,
83,
2,
1362,
776,
2344,
450,
334,
291,
14,
2473,
288,
2360,
291,
14,
1023,
288,
2360,
291,
14,
1000,
52,
288,
2360,
291,
14,
1258,
52,
288,
2360,
291,
14,
1531,
288,
2360,
291,
14,
4749,
288,
776,
339,
347,
636,
495,
721,
277,
304,
267,
372,
291,
14,
2722,
342,
199,
199,
318,
2446,
837,
272,
340,
822,
8,
1274,
14,
3020,
9,
665,
499,
26,
267,
4503,
342,
267,
984,
14,
2224,
8,
17,
9,
339,
931,
275,
984,
14,
3020,
59,
17,
61,
272,
340,
440,
747,
14,
515,
14,
6292,
8,
515,
304,
267,
870,
360,
547,
26,
2071,
83,
2,
1630,
440,
2187,
3530,
450,
931,
12,
570,
29,
1274,
14,
3083,
9,
267,
984,
14,
2224,
8,
17,
9,
339,
543,
1551,
8,
515,
12,
283,
4848,
358,
465,
289,
26,
267,
943,
275,
942,
267,
367,
1962,
315,
7392,
14,
5503,
8,
70,
304,
288,
30464,
275,
1962,
59,
16,
61,
288,
809,
275,
1962,
59,
17,
61,
288,
410,
77,
275,
2197,
14,
9866,
8,
1143,
59,
18,
467,
1543,
57,
3295,
77,
3295,
68,
3295,
40,
3295,
45,
3295,
51,
3295,
70,
358,
288,
862,
26,
355,
286,
7574,
275,
2197,
14,
9866,
8,
1143,
59,
19,
467,
1543,
57,
3295,
77,
3295,
68,
3295,
40,
3295,
45,
3295,
51,
3295,
70,
358,
288,
871,
26,
355,
286,
7574,
275,
488,
288,
2088,
275,
1962,
59,
20,
61,
288,
8633,
275,
1962,
59,
21,
61,
288,
943,
14,
740,
8,
3900,
8,
2647,
12,
809,
12,
410,
77,
12,
286,
7574,
12,
2088,
12,
8633,
430,
339,
327,
3520,
18655,
911,
506,
1202,
315,
2005,
3423,
339,
922,
12311,
83,
275,
1052,
272,
367,
634,
315,
943,
26,
489,
340,
440,
634,
14,
2473,
315,
922,
12311,
83,
26,
267,
922,
12311,
83,
59,
76,
14,
2473,
61,
275,
942,
489,
922,
12311,
83,
59,
76,
14,
2473,
1055,
740,
8,
76,
9,
339,
3718,
2623,
12631,
8,
793,
9,
272,
5053,
5618,
2623,
1899,
8,
751,
12311,
83,
9,
272,
1894,
5923,
2623,
1899,
8,
751,
12311,
83,
9,
272,
8526,
14680,
8,
751,
12311,
83,
9,
272,
8526,
8185,
83,
8,
751,
12311,
83,
9,
421,
199,
318,
3718,
2623,
12631,
8,
793,
304,
339,
2088,
6959,
275,
1052,
272,
367,
634,
315,
943,
26,
267,
366,
275,
634,
14,
1000,
52,
14,
6205,
3508,
89,
3295,
77,
3295,
68,
358,
267,
340,
440,
334,
68,
315,
2088,
6959,
304,
288,
2088,
6959,
59,
68,
61,
275,
378,
267,
2088,
6959,
59,
68,
61,
847,
413,
339,
5137,
275,
14794,
342,
272,
1004,
275,
7030,
342,
272,
1004,
14,
88,
6550,
275,
942,
272,
1004,
14,
89,
6550,
275,
942,
272,
634,
2101,
275,
942,
339,
302,
275,
413,
272,
367,
366,
315,
3355,
8,
1760,
6959,
14,
1612,
5109,
267,
1004,
14,
88,
6550,
14,
740,
8,
78,
9,
267,
1004,
14,
89,
6550,
14,
740,
8,
1760,
6959,
59,
68,
566,
267,
634,
2101,
14,
740,
8,
68,
9,
267,
302,
847,
413,
339,
340,
822,
8,
76,
2101,
9,
690,
1616,
26,
267,
19888,
1712,
275,
3842,
73,
627,
302,
9,
1182,
1616,
367,
284,
315,
1425,
8,
709,
1874,
272,
587,
26,
267,
19888,
1712,
275,
1425,
8,
552,
8,
76,
2101,
430,
272,
1004,
14,
88,
11763,
14016,
275,
359,
76,
2101,
59,
73,
61,
367,
284,
315,
19888,
1712,
61,
272,
1004,
14,
88,
11763,
4314,
10225,
275,
19888,
1712,
339,
1004,
14,
88,
11763,
4314,
8516,
275,
469,
267,
298,
2326,
2,
520,
298,
6304,
401,
267,
298,
15362,
2,
520,
4233,
12,
267,
298,
22124,
2,
520,
1749,
272,
789,
272,
5137,
14,
89,
4314,
275,
298,
7316,
5817,
83,
2,
272,
5137,
14,
525,
8,
604,
9,
272,
5137,
14,
409,
23370,
8,
25,
12,
22,
9,
272,
5137,
14,
2117,
480,
12975,
13,
991,
13,
2977,
14,
4524,
531,
339,
327,
473,
911,
675,
3520,
18655,
3663,
5431,
421,
199,
318,
5053,
5618,
2623,
1899,
8,
751,
12311,
83,
304,
339,
5053,
5618,
275,
1052,
272,
367,
5315,
315,
922,
12311,
83,
26,
489,
367,
634,
315,
922,
12311,
83,
59,
4623,
2189,
267,
340,
634,
14,
1531,
508,
298,
1981,
13884,
582,
881,
340,
440,
334,
76,
14,
2473,
315,
5053,
5618,
304,
288,
5053,
5618,
59,
76,
14,
2473,
61,
275,
378,
881,
5053,
5618,
59,
76,
14,
2473,
61,
847,
413,
339,
5137,
275,
14794,
342,
272,
4681,
275,
12377,
342,
272,
4681,
14,
88,
6550,
275,
942,
272,
4681,
14,
89,
6550,
275,
942,
272,
634,
2101,
275,
942,
339,
302,
275,
413,
272,
367,
366,
315,
3355,
8,
4891,
83,
14,
1612,
5109,
267,
922,
275,
366,
1491,
21,
61,
267,
4681,
14,
88,
6550,
14,
740,
8,
78,
9,
267,
4681,
14,
89,
6550,
14,
740,
8,
4891,
83,
59,
68,
566,
267,
634,
2101,
14,
740,
8,
751,
9,
267,
302,
847,
413,
339,
4681,
14,
88,
11763,
14016,
275,
634,
2101,
339,
4681,
14,
88,
11763,
4314,
8516,
275,
469,
267,
298,
2326,
2,
520,
298,
6304,
401,
267,
298,
15362,
2,
520,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
richardcs/ansible
|
lib/ansible/utils/module_docs_fragments/manageiq.py
|
59
|
1378
|
# (c) 2017, Daniel Korn <korndaniel1@gmail.com>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
class ModuleDocFragment(object):
# Standard ManageIQ documentation fragment
DOCUMENTATION = """
options:
manageiq_connection:
required: true
description:
- ManageIQ connection configuration information.
suboptions:
url:
required: true
description:
- ManageIQ environment url. C(MIQ_URL) env var if set. otherwise, it is required to pass it.
username:
description:
- ManageIQ username. C(MIQ_USERNAME) env var if set. otherwise, required if no token is passed in.
password:
description:
- ManageIQ password. C(MIQ_PASSWORD) env var if set. otherwise, required if no token is passed in.
token:
description:
- ManageIQ token. C(MIQ_TOKEN) env var if set. otherwise, required if no username or password is passed in.
verify_ssl:
description:
- Whether SSL certificates should be verified for HTTPS requests. defaults to True.
default: true
ca_bundle_path:
description:
- The path to a CA bundle file or directory with certificates. defaults to None.
requirements:
- 'manageiq-client U(https://github.com/ManageIQ/manageiq-api-client-python/)'
"""
|
gpl-3.0
|
[
3,
334,
67,
9,
9708,
12,
24747,
14769,
1804,
6161,
665,
75,
269,
977,
290,
14769,
17,
32,
6799,
14,
957,
30,
199,
3,
1664,
1696,
1684,
844,
373,
19,
14,
16,
11,
334,
3239,
9685,
503,
4178,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
15,
11692,
13,
19,
14,
16,
14,
2424,
9,
421,
199,
533,
5673,
3768,
11080,
8,
785,
304,
339,
327,
9739,
14944,
23559,
3794,
7956,
272,
29970,
2594,
275,
408,
199,
1419,
26,
523,
9635,
9962,
63,
2105,
26,
272,
1415,
26,
2549,
272,
1369,
26,
489,
446,
14944,
23559,
1950,
2897,
2556,
14,
272,
26265,
26,
489,
1166,
26,
267,
1415,
26,
2549,
267,
1369,
26,
881,
446,
14944,
23559,
3734,
1166,
14,
445,
8,
10709,
49,
63,
2632,
9,
2589,
2729,
340,
663,
14,
4257,
12,
652,
365,
1415,
370,
986,
652,
14,
489,
3434,
26,
267,
1369,
26,
881,
446,
14944,
23559,
3434,
14,
445,
8,
10709,
49,
63,
11958,
9,
2589,
2729,
340,
663,
14,
4257,
12,
1415,
340,
949,
1526,
365,
3032,
315,
14,
489,
2505,
26,
267,
1369,
26,
881,
446,
14944,
23559,
2505,
14,
445,
8,
10709,
49,
63,
9032,
9,
2589,
2729,
340,
663,
14,
4257,
12,
1415,
340,
949,
1526,
365,
3032,
315,
14,
489,
1526,
26,
267,
1369,
26,
881,
446,
14944,
23559,
1526,
14,
445,
8,
10709,
49,
63,
8803,
9,
2589,
2729,
340,
663,
14,
4257,
12,
1415,
340,
949,
3434,
503,
2505,
365,
3032,
315,
14,
489,
4911,
63,
4266,
26,
267,
1369,
26,
881,
446,
7480,
7799,
14512,
1077,
506,
16317,
367,
14147,
4145,
14,
4243,
370,
715,
14,
267,
849,
26,
2549,
489,
1704,
63,
6469,
63,
515,
26,
267,
1369,
26,
881,
446,
710,
931,
370,
282,
7240,
8844,
570,
503,
2082,
543,
14512,
14,
4243,
370,
488,
14,
199,
199,
7538,
26,
523,
446,
283,
9053,
9962,
13,
1258,
738,
8,
2859,
921,
5031,
14,
957,
15,
20588,
23559,
15,
9053,
9962,
13,
1246,
13,
1258,
13,
1548,
15,
3171,
199,
624,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
334,
67,
9,
9708,
12,
24747,
14769,
1804,
6161,
665,
75,
269,
977,
290,
14769,
17,
32,
6799,
14,
957,
30,
199,
3,
1664,
1696,
1684,
844,
373,
19,
14,
16,
11,
334,
3239,
9685,
503,
4178,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
15,
11692,
13,
19,
14,
16,
14,
2424,
9,
421,
199,
533,
5673,
3768,
11080,
8,
785,
304,
339,
327,
9739,
14944,
23559,
3794,
7956,
272,
29970,
2594,
275,
408,
199,
1419,
26,
523,
9635,
9962,
63,
2105,
26,
272,
1415,
26,
2549,
272,
1369,
26,
489,
446,
14944,
23559,
1950,
2897,
2556,
14,
272,
26265,
26,
489,
1166,
26,
267,
1415,
26,
2549,
267,
1369,
26,
881,
446,
14944,
23559,
3734,
1166,
14,
445,
8,
10709,
49,
63,
2632,
9,
2589,
2729,
340,
663,
14,
4257,
12,
652,
365,
1415,
370,
986,
652,
14,
489,
3434,
26,
267,
1369,
26,
881,
446,
14944,
23559,
3434,
14,
445,
8,
10709,
49,
63,
11958,
9,
2589,
2729,
340,
663,
14,
4257,
12,
1415,
340,
949,
1526,
365,
3032,
315,
14,
489,
2505,
26,
267,
1369,
26,
881,
446,
14944,
23559,
2505,
14,
445,
8,
10709,
49,
63,
9032,
9,
2589,
2729,
340,
663,
14,
4257,
12,
1415,
340,
949,
1526,
365,
3032,
315,
14,
489,
1526,
26,
267,
1369,
26,
881,
446,
14944,
23559,
1526,
14,
445,
8,
10709,
49,
63,
8803,
9,
2589,
2729,
340,
663,
14,
4257,
12,
1415,
340,
949,
3434,
503,
2505,
365,
3032,
315,
14,
489,
4911,
63,
4266,
26,
267,
1369,
26,
881,
446,
7480,
7799,
14512,
1077,
506,
16317,
367,
14147,
4145,
14,
4243,
370,
715,
14,
267,
849,
26,
2549,
489,
1704,
63,
6469,
63,
515,
26,
267,
1369,
26,
881,
446,
710,
931,
370,
282,
7240,
8844,
570,
503,
2082,
543,
14512,
14,
4243,
370,
488,
14,
199,
199,
7538,
26,
523,
446,
283,
9053,
9962,
13,
1258,
738,
8,
2859,
921,
5031,
14,
957,
15,
20588,
23559,
15,
9053,
9962,
13,
1246,
13,
1258,
13,
1548,
15,
3171,
199,
624,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
Julian/home-assistant
|
homeassistant/components/recorder.py
|
1
|
15356
|
"""
homeassistant.components.recorder
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Component that records all events and state changes. Allows other components
to query this database.
For more details about this component, please refer to the documentation at
https://home-assistant.io/components/recorder/
"""
from contextlib import closing
import json
import logging
import queue
import sqlite3
import threading
from datetime import date, datetime
import homeassistant.util.dt as dt_util
from homeassistant.const import (
EVENT_HOMEASSISTANT_START, EVENT_HOMEASSISTANT_STOP, EVENT_STATE_CHANGED,
EVENT_TIME_CHANGED, MATCH_ALL)
from homeassistant.core import Event, EventOrigin, State
from homeassistant.remote import JSONEncoder
DOMAIN = "recorder"
DB_FILE = 'home-assistant.db'
RETURN_ROWCOUNT = "rowcount"
RETURN_LASTROWID = "lastrowid"
RETURN_ONE_ROW = "one_row"
_INSTANCE = None
_LOGGER = logging.getLogger(__name__)
def query(sql_query, arguments=None):
""" Query the database. """
_verify_instance()
return _INSTANCE.query(sql_query, arguments)
def query_states(state_query, arguments=None):
""" Query the database and return a list of states. """
return [
row for row in
(row_to_state(row) for row in query(state_query, arguments))
if row is not None]
def query_events(event_query, arguments=None):
""" Query the database and return a list of states. """
return [
row for row in
(row_to_event(row) for row in query(event_query, arguments))
if row is not None]
def row_to_state(row):
""" Convert a database row to a state. """
try:
return State(
row[1], row[2], json.loads(row[3]),
dt_util.utc_from_timestamp(row[4]),
dt_util.utc_from_timestamp(row[5]))
except ValueError:
# When json.loads fails
_LOGGER.exception("Error converting row to state: %s", row)
return None
def row_to_event(row):
""" Convert a databse row to an event. """
try:
return Event(row[1], json.loads(row[2]), EventOrigin(row[3]),
dt_util.utc_from_timestamp(row[5]))
except ValueError:
# When json.loads fails
_LOGGER.exception("Error converting row to event: %s", row)
return None
def run_information(point_in_time=None):
"""
Returns information about current run or the run that covers point_in_time.
"""
_verify_instance()
if point_in_time is None or point_in_time > _INSTANCE.recording_start:
return RecorderRun()
run = _INSTANCE.query(
"SELECT * FROM recorder_runs WHERE start<? AND END>?",
(point_in_time, point_in_time), return_value=RETURN_ONE_ROW)
return RecorderRun(run) if run else None
def setup(hass, config):
""" Setup the recorder. """
# pylint: disable=global-statement
global _INSTANCE
_INSTANCE = Recorder(hass)
return True
class RecorderRun(object):
""" Represents a recorder run. """
def __init__(self, row=None):
self.end = None
if row is None:
self.start = _INSTANCE.recording_start
self.closed_incorrect = False
else:
self.start = dt_util.utc_from_timestamp(row[1])
if row[2] is not None:
self.end = dt_util.utc_from_timestamp(row[2])
self.closed_incorrect = bool(row[3])
def entity_ids(self, point_in_time=None):
"""
Return the entity ids that existed in this run.
Specify point_in_time if you want to know which existed at that point
in time inside the run.
"""
where = self.where_after_start_run
where_data = []
if point_in_time is not None or self.end is not None:
where += "AND created < ? "
where_data.append(point_in_time or self.end)
return [row[0] for row in query(
"SELECT entity_id FROM states WHERE {}"
"GROUP BY entity_id".format(where), where_data)]
@property
def where_after_start_run(self):
"""
Returns SQL WHERE clause to select rows created after the start of the
run.
"""
return "created >= {} ".format(_adapt_datetime(self.start))
@property
def where_limit_to_run(self):
""" Return a SQL WHERE clause to limit results to this run. """
where = self.where_after_start_run
if self.end is not None:
where += "AND created < {} ".format(_adapt_datetime(self.end))
return where
class Recorder(threading.Thread):
""" Threaded recorder class """
def __init__(self, hass):
threading.Thread.__init__(self)
self.hass = hass
self.conn = None
self.queue = queue.Queue()
self.quit_object = object()
self.lock = threading.Lock()
self.recording_start = dt_util.utcnow()
self.utc_offset = dt_util.now().utcoffset().total_seconds()
def start_recording(event):
""" Start recording. """
self.start()
hass.bus.listen_once(EVENT_HOMEASSISTANT_START, start_recording)
hass.bus.listen_once(EVENT_HOMEASSISTANT_STOP, self.shutdown)
hass.bus.listen(MATCH_ALL, self.event_listener)
def run(self):
""" Start processing events to save. """
with self._make_connection():
self._setup_connection()
self._setup_run()
while True:
event = self.queue.get()
if event == self.quit_object:
self._close_run()
self.conn.close()
self.queue.task_done()
return
elif event.event_type == EVENT_TIME_CHANGED:
self.queue.task_done()
continue
event_id = self.record_event(event)
if event.event_type == EVENT_STATE_CHANGED:
self.record_state(
event.data['entity_id'], event.data.get('new_state'),
event_id)
self.queue.task_done()
def event_listener(self, event):
"""
Listens for new events on the EventBus and puts them in the process
queue.
"""
self.queue.put(event)
def shutdown(self, event):
""" Tells the recorder to shut down. """
self.queue.put(self.quit_object)
self.block_till_done()
def record_state(self, entity_id, state, event_id):
""" Save a state to the database. """
now = dt_util.utcnow()
# State got deleted
if state is None:
state_state = ''
state_domain = ''
state_attr = '{}'
last_changed = last_updated = now
else:
state_domain = state.domain
state_state = state.state
state_attr = json.dumps(dict(state.attributes))
last_changed = state.last_changed
last_updated = state.last_updated
info = (
entity_id, state_domain, state_state, state_attr,
last_changed, last_updated,
now, self.utc_offset, event_id)
self.query(
"""
INSERT INTO states (
entity_id, domain, state, attributes, last_changed, last_updated,
created, utc_offset, event_id)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
""",
info)
def record_event(self, event):
""" Save an event to the database. """
info = (
event.event_type, json.dumps(event.data, cls=JSONEncoder),
str(event.origin), dt_util.utcnow(), event.time_fired,
self.utc_offset
)
return self.query(
"INSERT INTO events ("
"event_type, event_data, origin, created, time_fired, utc_offset"
") VALUES (?, ?, ?, ?, ?, ?)", info, RETURN_LASTROWID)
def query(self, sql_query, data=None, return_value=None):
""" Query the database. """
try:
with self.conn, self.lock:
_LOGGER.debug("Running query %s", sql_query)
cur = self.conn.cursor()
if data is not None:
cur.execute(sql_query, data)
else:
cur.execute(sql_query)
if return_value == RETURN_ROWCOUNT:
return cur.rowcount
elif return_value == RETURN_LASTROWID:
return cur.lastrowid
elif return_value == RETURN_ONE_ROW:
return cur.fetchone()
else:
return cur.fetchall()
except (sqlite3.IntegrityError, sqlite3.OperationalError,
sqlite3.ProgrammingError):
_LOGGER.exception(
"Error querying the database using: %s", sql_query)
return []
def block_till_done(self):
""" Blocks till all events processed. """
self.queue.join()
def _make_connection(self):
db_path = self.hass.config.path(DB_FILE)
conn = self.conn = sqlite3.connect(db_path, check_same_thread=False)
conn.row_factory = sqlite3.Row
return closing(conn)
def _setup_connection(self):
""" Ensure database is ready to fly. """
# Have datetime objects be saved as integers
sqlite3.register_adapter(date, _adapt_datetime)
sqlite3.register_adapter(datetime, _adapt_datetime)
# Validate we are on the correct schema or that we have to migrate
cur = self.conn.cursor()
def save_migration(migration_id):
""" Save and commit a migration to the database. """
cur.execute('INSERT INTO schema_version VALUES (?, ?)',
(migration_id, dt_util.utcnow()))
self.conn.commit()
_LOGGER.info("Database migrated to version %d", migration_id)
try:
cur.execute('SELECT max(migration_id) FROM schema_version;')
migration_id = cur.fetchone()[0] or 0
except sqlite3.OperationalError:
# The table does not exist
cur.execute('CREATE TABLE schema_version ('
'migration_id integer primary key, performed integer)')
migration_id = 0
if migration_id < 1:
cur.execute("""
CREATE TABLE recorder_runs (
run_id integer primary key,
start integer,
end integer,
closed_incorrect integer default 0,
created integer)
""")
cur.execute("""
CREATE TABLE events (
event_id integer primary key,
event_type text,
event_data text,
origin text,
created integer)
""")
cur.execute(
'CREATE INDEX events__event_type ON events(event_type)')
cur.execute("""
CREATE TABLE states (
state_id integer primary key,
entity_id text,
state text,
attributes text,
last_changed integer,
last_updated integer,
created integer)
""")
cur.execute('CREATE INDEX states__entity_id ON states(entity_id)')
save_migration(1)
if migration_id < 2:
cur.execute("""
ALTER TABLE events
ADD COLUMN time_fired integer
""")
cur.execute('UPDATE events SET time_fired=created')
save_migration(2)
if migration_id < 3:
utc_offset = self.utc_offset
cur.execute("""
ALTER TABLE recorder_runs
ADD COLUMN utc_offset integer
""")
cur.execute("""
ALTER TABLE events
ADD COLUMN utc_offset integer
""")
cur.execute("""
ALTER TABLE states
ADD COLUMN utc_offset integer
""")
cur.execute("UPDATE recorder_runs SET utc_offset=?", [utc_offset])
cur.execute("UPDATE events SET utc_offset=?", [utc_offset])
cur.execute("UPDATE states SET utc_offset=?", [utc_offset])
save_migration(3)
if migration_id < 4:
# We had a bug where we did not save utc offset for recorder runs
cur.execute(
"""UPDATE recorder_runs SET utc_offset=?
WHERE utc_offset IS NULL""", [self.utc_offset])
cur.execute("""
ALTER TABLE states
ADD COLUMN event_id integer
""")
save_migration(4)
if migration_id < 5:
# Add domain so that thermostat graphs look right
try:
cur.execute("""
ALTER TABLE states
ADD COLUMN domain text
""")
except sqlite3.OperationalError:
# We had a bug in this migration for a while on dev
# Without this, dev-users will have to throw away their db
pass
# TravisCI has Python compiled against an old version of SQLite3
# which misses the instr method.
self.conn.create_function(
"instr", 2,
lambda string, substring: string.find(substring) + 1)
# populate domain with defaults
cur.execute("""
UPDATE states
set domain=substr(entity_id, 0, instr(entity_id, '.'))
""")
# add indexes we are going to use a lot on selects
cur.execute("""
CREATE INDEX states__state_changes ON
states (last_changed, last_updated, entity_id)""")
cur.execute("""
CREATE INDEX states__significant_changes ON
states (domain, last_updated, entity_id)""")
save_migration(5)
def _setup_run(self):
""" Log the start of the current run. """
if self.query("""UPDATE recorder_runs SET end=?, closed_incorrect=1
WHERE end IS NULL""", (self.recording_start, ),
return_value=RETURN_ROWCOUNT):
_LOGGER.warning("Found unfinished sessions")
self.query(
"""INSERT INTO recorder_runs (start, created, utc_offset)
VALUES (?, ?, ?)""",
(self.recording_start, dt_util.utcnow(), self.utc_offset))
def _close_run(self):
""" Save end time for current run. """
self.query(
"UPDATE recorder_runs SET end=? WHERE start=?",
(dt_util.utcnow(), self.recording_start))
def _adapt_datetime(datetimestamp):
""" Turn a datetime into an integer for in the DB. """
dt = dt_util.as_utc(datetimestamp.replace(microsecond=0))
return (dt - datetime(1970, 1, 1, tzinfo=dt_util.UTC)).total_seconds()
def _verify_instance():
""" Throws error if recorder not initialized. """
if _INSTANCE is None:
raise RuntimeError("Recorder not initialized.")
|
mit
|
[
624,
199,
22799,
14,
4608,
14,
27733,
199,
30642,
94,
199,
7004,
626,
5767,
1006,
4474,
436,
1174,
4493,
14,
22819,
1163,
7323,
199,
475,
1827,
642,
3050,
14,
199,
199,
1858,
1655,
2436,
3595,
642,
3931,
12,
8749,
10618,
370,
314,
3794,
737,
199,
2859,
921,
4219,
13,
7310,
14,
2308,
15,
4608,
15,
27733,
15,
199,
624,
199,
504,
15502,
492,
11261,
199,
646,
2022,
199,
646,
2050,
199,
646,
4126,
199,
646,
11723,
19,
199,
646,
5796,
199,
504,
2197,
492,
1434,
12,
2197,
199,
199,
646,
8846,
14,
1974,
14,
3583,
465,
4487,
63,
1974,
199,
504,
8846,
14,
1297,
492,
334,
272,
6461,
63,
9524,
16435,
840,
1441,
63,
7363,
12,
6461,
63,
9524,
16435,
840,
1441,
63,
11632,
12,
6461,
63,
6689,
63,
21488,
12,
272,
6461,
63,
4961,
63,
21488,
12,
603,
8078,
63,
1761,
9,
199,
504,
8846,
14,
1018,
492,
6763,
12,
6763,
12834,
12,
8511,
199,
504,
8846,
14,
3846,
492,
4840,
6679,
199,
199,
7378,
275,
298,
27733,
2,
199,
199,
2846,
63,
3817,
275,
283,
4219,
13,
7310,
14,
697,
7,
199,
199,
9677,
63,
11415,
8760,
275,
298,
24007,
2,
199,
9677,
63,
16901,
1092,
9845,
275,
298,
2019,
29450,
2,
199,
9677,
63,
4817,
63,
11415,
275,
298,
368,
63,
1143,
2,
199,
199,
63,
18235,
275,
488,
199,
63,
10186,
275,
2050,
14,
5572,
3460,
354,
3368,
421,
199,
318,
1827,
8,
3009,
63,
1131,
12,
2368,
29,
403,
304,
272,
408,
8133,
314,
3050,
14,
408,
272,
485,
4712,
63,
842,
342,
339,
372,
485,
18235,
14,
1131,
8,
3009,
63,
1131,
12,
2368,
9,
421,
199,
318,
1827,
63,
4981,
8,
929,
63,
1131,
12,
2368,
29,
403,
304,
272,
408,
8133,
314,
3050,
436,
372,
282,
769,
402,
6363,
14,
408,
272,
372,
359,
267,
1962,
367,
1962,
315,
267,
334,
1143,
63,
475,
63,
929,
8,
1143,
9,
367,
1962,
315,
1827,
8,
929,
63,
1131,
12,
2368,
430,
267,
340,
1962,
365,
440,
488,
61,
421,
199,
318,
1827,
63,
4368,
8,
1430,
63,
1131,
12,
2368,
29,
403,
304,
272,
408,
8133,
314,
3050,
436,
372,
282,
769,
402,
6363,
14,
408,
272,
372,
359,
267,
1962,
367,
1962,
315,
267,
334,
1143,
63,
475,
63,
1430,
8,
1143,
9,
367,
1962,
315,
1827,
8,
1430,
63,
1131,
12,
2368,
430,
267,
340,
1962,
365,
440,
488,
61,
421,
199,
318,
1962,
63,
475,
63,
929,
8,
1143,
304,
272,
408,
7905,
282,
3050,
1962,
370,
282,
1174,
14,
408,
272,
862,
26,
267,
372,
8511,
8,
288,
1962,
59,
17,
467,
1962,
59,
18,
467,
2022,
14,
3640,
8,
1143,
59,
19,
2522,
288,
4487,
63,
1974,
14,
5834,
63,
504,
63,
3954,
8,
1143,
59,
20,
2522,
288,
4487,
63,
1974,
14,
5834,
63,
504,
63,
3954,
8,
1143,
59,
21,
2459,
272,
871,
1722,
26,
267,
327,
3979,
2022,
14,
3640,
6918,
267,
485,
10186,
14,
1971,
480,
547,
13806,
1962,
370,
1174,
26,
450,
83,
401,
1962,
9,
267,
372,
488,
421,
199,
318,
1962,
63,
475,
63,
1430,
8,
1143,
304,
272,
408,
7905,
282,
366,
1936,
261,
1962,
370,
376,
1566,
14,
408,
272,
862,
26,
267,
372,
6763,
8,
1143,
59,
17,
467,
2022,
14,
3640,
8,
1143,
59,
18,
2522,
6763,
12834,
8,
1143,
59,
19,
2522,
2151,
4487,
63,
1974,
14,
5834,
63,
504,
63,
3954,
8,
1143,
59,
21,
2459,
272,
871,
1722,
26,
267,
327,
3979,
2022,
14,
3640,
6918,
267,
485,
10186,
14,
1971,
480,
547,
13806,
1962,
370,
1566,
26,
450,
83,
401,
1962,
9,
267,
372,
488,
421,
199,
318,
1255,
63,
11697,
8,
1403,
63,
262,
63,
521,
29,
403,
304,
272,
408,
272,
1803,
2556,
3595,
1453,
1255,
503,
314,
1255,
626,
25858,
2376,
63,
262,
63,
521,
14,
272,
408,
272,
485,
4712,
63,
842,
342,
339,
340,
2376,
63,
262,
63,
521,
365,
488,
503,
2376,
63,
262,
63,
521,
690,
485,
18235,
14,
24616,
63,
928,
26,
267,
372,
799,
16940,
2540,
342,
339,
1255,
275,
485,
18235,
14,
1131,
8,
267,
298,
4859,
627,
4442,
295,
16940,
63,
10802,
6038,
1343,
28,
31,
2401,
7729,
30,
15583,
267,
334,
1403,
63,
262,
63,
521,
12,
2376,
63,
262,
63,
521,
395,
372,
63,
585,
29,
9677,
63,
4817,
63,
11415,
9,
339,
372,
799,
16940,
2540,
8,
1065,
9,
340,
1255,
587,
488,
421,
199,
318,
3272,
8,
5387,
12,
1101,
304,
272,
408,
12439,
314,
295,
16940,
14,
408,
272,
327,
4287,
26,
3507,
29,
2966,
13,
6242,
272,
2288,
485,
18235,
339,
485,
18235,
275,
799,
16940,
8,
5387,
9,
339,
372,
715,
421,
199,
533,
799,
16940,
2540,
8,
785,
304,
272,
408,
21591,
282,
295,
16940,
1255,
14,
408,
272,
347,
636,
826,
721,
277,
12,
1962,
29,
403,
304,
267,
291,
14,
500,
275,
488,
398,
340,
1962,
365,
488,
26,
288,
291,
14,
928,
275,
485,
18235,
14,
24616,
63,
928,
288,
291,
14,
5938,
63,
15448,
275,
756,
267,
587,
26,
288,
291,
14,
928,
275,
4487,
63,
1974,
14,
5834,
63,
504,
63,
3954,
8,
1143,
59,
17,
566,
953,
340,
1962,
59,
18,
61,
365,
440,
488,
26,
355,
291,
14,
500,
275,
4487,
63,
1974,
14,
5834,
63,
504,
63,
3954,
8,
1143,
59,
18,
566,
953,
291,
14,
5938,
63,
15448,
275,
2155,
8,
1143,
59,
19,
566,
339,
347,
4642,
63,
1580,
8,
277,
12,
2376,
63,
262,
63,
521,
29,
403,
304,
267,
408,
267,
1432,
314,
4642,
2762,
626,
30482,
315,
642,
1255,
14,
267,
13327,
2376,
63,
262,
63,
521,
340,
1265,
2934,
370,
5715,
1314,
30482,
737,
626,
2376,
267,
315,
900,
6272,
314,
1255,
14,
267,
408,
267,
2382,
275,
291,
14,
4509,
63,
4399,
63,
928,
63,
1065,
267,
2382,
63,
576,
275,
942,
398,
340,
2376,
63,
262,
63,
521,
365,
440,
488,
503,
291,
14,
500,
365,
440,
488,
26,
288,
2382,
847,
298,
3649,
2737,
665,
5805,
298,
288,
2382,
63,
576,
14,
740,
8,
1403,
63,
262,
63,
521,
503,
291,
14,
500,
9,
398,
372,
359,
1143,
59,
16,
61
] |
[
199,
22799,
14,
4608,
14,
27733,
199,
30642,
94,
199,
7004,
626,
5767,
1006,
4474,
436,
1174,
4493,
14,
22819,
1163,
7323,
199,
475,
1827,
642,
3050,
14,
199,
199,
1858,
1655,
2436,
3595,
642,
3931,
12,
8749,
10618,
370,
314,
3794,
737,
199,
2859,
921,
4219,
13,
7310,
14,
2308,
15,
4608,
15,
27733,
15,
199,
624,
199,
504,
15502,
492,
11261,
199,
646,
2022,
199,
646,
2050,
199,
646,
4126,
199,
646,
11723,
19,
199,
646,
5796,
199,
504,
2197,
492,
1434,
12,
2197,
199,
199,
646,
8846,
14,
1974,
14,
3583,
465,
4487,
63,
1974,
199,
504,
8846,
14,
1297,
492,
334,
272,
6461,
63,
9524,
16435,
840,
1441,
63,
7363,
12,
6461,
63,
9524,
16435,
840,
1441,
63,
11632,
12,
6461,
63,
6689,
63,
21488,
12,
272,
6461,
63,
4961,
63,
21488,
12,
603,
8078,
63,
1761,
9,
199,
504,
8846,
14,
1018,
492,
6763,
12,
6763,
12834,
12,
8511,
199,
504,
8846,
14,
3846,
492,
4840,
6679,
199,
199,
7378,
275,
298,
27733,
2,
199,
199,
2846,
63,
3817,
275,
283,
4219,
13,
7310,
14,
697,
7,
199,
199,
9677,
63,
11415,
8760,
275,
298,
24007,
2,
199,
9677,
63,
16901,
1092,
9845,
275,
298,
2019,
29450,
2,
199,
9677,
63,
4817,
63,
11415,
275,
298,
368,
63,
1143,
2,
199,
199,
63,
18235,
275,
488,
199,
63,
10186,
275,
2050,
14,
5572,
3460,
354,
3368,
421,
199,
318,
1827,
8,
3009,
63,
1131,
12,
2368,
29,
403,
304,
272,
408,
8133,
314,
3050,
14,
408,
272,
485,
4712,
63,
842,
342,
339,
372,
485,
18235,
14,
1131,
8,
3009,
63,
1131,
12,
2368,
9,
421,
199,
318,
1827,
63,
4981,
8,
929,
63,
1131,
12,
2368,
29,
403,
304,
272,
408,
8133,
314,
3050,
436,
372,
282,
769,
402,
6363,
14,
408,
272,
372,
359,
267,
1962,
367,
1962,
315,
267,
334,
1143,
63,
475,
63,
929,
8,
1143,
9,
367,
1962,
315,
1827,
8,
929,
63,
1131,
12,
2368,
430,
267,
340,
1962,
365,
440,
488,
61,
421,
199,
318,
1827,
63,
4368,
8,
1430,
63,
1131,
12,
2368,
29,
403,
304,
272,
408,
8133,
314,
3050,
436,
372,
282,
769,
402,
6363,
14,
408,
272,
372,
359,
267,
1962,
367,
1962,
315,
267,
334,
1143,
63,
475,
63,
1430,
8,
1143,
9,
367,
1962,
315,
1827,
8,
1430,
63,
1131,
12,
2368,
430,
267,
340,
1962,
365,
440,
488,
61,
421,
199,
318,
1962,
63,
475,
63,
929,
8,
1143,
304,
272,
408,
7905,
282,
3050,
1962,
370,
282,
1174,
14,
408,
272,
862,
26,
267,
372,
8511,
8,
288,
1962,
59,
17,
467,
1962,
59,
18,
467,
2022,
14,
3640,
8,
1143,
59,
19,
2522,
288,
4487,
63,
1974,
14,
5834,
63,
504,
63,
3954,
8,
1143,
59,
20,
2522,
288,
4487,
63,
1974,
14,
5834,
63,
504,
63,
3954,
8,
1143,
59,
21,
2459,
272,
871,
1722,
26,
267,
327,
3979,
2022,
14,
3640,
6918,
267,
485,
10186,
14,
1971,
480,
547,
13806,
1962,
370,
1174,
26,
450,
83,
401,
1962,
9,
267,
372,
488,
421,
199,
318,
1962,
63,
475,
63,
1430,
8,
1143,
304,
272,
408,
7905,
282,
366,
1936,
261,
1962,
370,
376,
1566,
14,
408,
272,
862,
26,
267,
372,
6763,
8,
1143,
59,
17,
467,
2022,
14,
3640,
8,
1143,
59,
18,
2522,
6763,
12834,
8,
1143,
59,
19,
2522,
2151,
4487,
63,
1974,
14,
5834,
63,
504,
63,
3954,
8,
1143,
59,
21,
2459,
272,
871,
1722,
26,
267,
327,
3979,
2022,
14,
3640,
6918,
267,
485,
10186,
14,
1971,
480,
547,
13806,
1962,
370,
1566,
26,
450,
83,
401,
1962,
9,
267,
372,
488,
421,
199,
318,
1255,
63,
11697,
8,
1403,
63,
262,
63,
521,
29,
403,
304,
272,
408,
272,
1803,
2556,
3595,
1453,
1255,
503,
314,
1255,
626,
25858,
2376,
63,
262,
63,
521,
14,
272,
408,
272,
485,
4712,
63,
842,
342,
339,
340,
2376,
63,
262,
63,
521,
365,
488,
503,
2376,
63,
262,
63,
521,
690,
485,
18235,
14,
24616,
63,
928,
26,
267,
372,
799,
16940,
2540,
342,
339,
1255,
275,
485,
18235,
14,
1131,
8,
267,
298,
4859,
627,
4442,
295,
16940,
63,
10802,
6038,
1343,
28,
31,
2401,
7729,
30,
15583,
267,
334,
1403,
63,
262,
63,
521,
12,
2376,
63,
262,
63,
521,
395,
372,
63,
585,
29,
9677,
63,
4817,
63,
11415,
9,
339,
372,
799,
16940,
2540,
8,
1065,
9,
340,
1255,
587,
488,
421,
199,
318,
3272,
8,
5387,
12,
1101,
304,
272,
408,
12439,
314,
295,
16940,
14,
408,
272,
327,
4287,
26,
3507,
29,
2966,
13,
6242,
272,
2288,
485,
18235,
339,
485,
18235,
275,
799,
16940,
8,
5387,
9,
339,
372,
715,
421,
199,
533,
799,
16940,
2540,
8,
785,
304,
272,
408,
21591,
282,
295,
16940,
1255,
14,
408,
272,
347,
636,
826,
721,
277,
12,
1962,
29,
403,
304,
267,
291,
14,
500,
275,
488,
398,
340,
1962,
365,
488,
26,
288,
291,
14,
928,
275,
485,
18235,
14,
24616,
63,
928,
288,
291,
14,
5938,
63,
15448,
275,
756,
267,
587,
26,
288,
291,
14,
928,
275,
4487,
63,
1974,
14,
5834,
63,
504,
63,
3954,
8,
1143,
59,
17,
566,
953,
340,
1962,
59,
18,
61,
365,
440,
488,
26,
355,
291,
14,
500,
275,
4487,
63,
1974,
14,
5834,
63,
504,
63,
3954,
8,
1143,
59,
18,
566,
953,
291,
14,
5938,
63,
15448,
275,
2155,
8,
1143,
59,
19,
566,
339,
347,
4642,
63,
1580,
8,
277,
12,
2376,
63,
262,
63,
521,
29,
403,
304,
267,
408,
267,
1432,
314,
4642,
2762,
626,
30482,
315,
642,
1255,
14,
267,
13327,
2376,
63,
262,
63,
521,
340,
1265,
2934,
370,
5715,
1314,
30482,
737,
626,
2376,
267,
315,
900,
6272,
314,
1255,
14,
267,
408,
267,
2382,
275,
291,
14,
4509,
63,
4399,
63,
928,
63,
1065,
267,
2382,
63,
576,
275,
942,
398,
340,
2376,
63,
262,
63,
521,
365,
440,
488,
503,
291,
14,
500,
365,
440,
488,
26,
288,
2382,
847,
298,
3649,
2737,
665,
5805,
298,
288,
2382,
63,
576,
14,
740,
8,
1403,
63,
262,
63,
521,
503,
291,
14,
500,
9,
398,
372,
359,
1143,
59,
16,
61,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
gseismic/vnpy
|
vn.lts/vnltstd/test/lts_data_type.py
|
167
|
86932
|
# encoding: UTF-8
defineDict = {}
typedefDict = {}
#//////////////////////////////////////////////////////////////////////
#@company shanghai liber information Technology Co.,Ltd
#@file SecurityFtdcUserApiDataType.h
#@brief 定义业务数据类型
#//////////////////////////////////////////////////////////////////////
#//////////////////////////////////////////////////////////////////////
#TFtdcErrorIDType是一个错误代码类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcErrorIDType"] = "int"
#//////////////////////////////////////////////////////////////////////
#TFtdcErrorMsgType是一个错误信息类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcErrorMsgType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcExchangeIDType是一个交易所代码类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcExchangeIDType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcExchangeNameType是一个交易所名称类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcExchangeNameType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcExchangePropertyType是一个交易所属性类型
#//////////////////////////////////////////////////////////////////////
#正常
defineDict["SECURITY_FTDC_EXP_Normal"] = '0'
#根据成交生成报单
defineDict["SECURITY_FTDC_EXP_GenOrderByTrade"] = '1'
typedefDict["TSecurityFtdcExchangePropertyType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcExchangeConnectStatusType是一个交易所连接状态类型
#//////////////////////////////////////////////////////////////////////
#没有任何连接
defineDict["SECURITY_FTDC_ECS_NoConnection"] = '1'
#已经发出合约查询请求
defineDict["SECURITY_FTDC_ECS_QryInstrumentSent"] = '2'
#已经获取信息
defineDict["SECURITY_FTDC_ECS_GotInformation"] = '9'
typedefDict["TSecurityFtdcExchangeConnectStatusType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcDateType是一个日期类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcDateType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcTimeType是一个时间类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcTimeType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcInstrumentIDType是一个合约代码类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcInstrumentIDType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcProductNameType是一个产品名称类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcProductNameType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcProductClassType是一个产品类型类型
#//////////////////////////////////////////////////////////////////////
#期货
defineDict["SECURITY_FTDC_PC_Futures"] = '1'
#期权
defineDict["SECURITY_FTDC_PC_Options"] = '2'
#组合
defineDict["SECURITY_FTDC_PC_Combination"] = '3'
#即期
defineDict["SECURITY_FTDC_PC_Spot"] = '4'
#期转现
defineDict["SECURITY_FTDC_PC_EFP"] = '5'
#证券A股
defineDict["SECURITY_FTDC_PC_StockA"] = '6'
#证券B股
defineDict["SECURITY_FTDC_PC_StockB"] = '7'
#ETF
defineDict["SECURITY_FTDC_PC_ETF"] = '8'
#ETF申赎
defineDict["SECURITY_FTDC_PC_ETFPurRed"] = '9'
typedefDict["TSecurityFtdcProductClassType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcVolumeMultipleType是一个合约数量乘数类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcVolumeMultipleType"] = "int"
#//////////////////////////////////////////////////////////////////////
#TFtdcPriceType是一个价格类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcPriceType"] = "float"
#//////////////////////////////////////////////////////////////////////
#TFtdcVolumeType是一个数量类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcVolumeType"] = "int"
#//////////////////////////////////////////////////////////////////////
#TFtdcPositionTypeType是一个持仓类型类型
#//////////////////////////////////////////////////////////////////////
#净持仓
defineDict["SECURITY_FTDC_PT_Net"] = '1'
#综合持仓
defineDict["SECURITY_FTDC_PT_Gross"] = '2'
typedefDict["TSecurityFtdcPositionTypeType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcPositionDateTypeType是一个持仓日期类型类型
#//////////////////////////////////////////////////////////////////////
#使用历史持仓
defineDict["SECURITY_FTDC_PDT_UseHistory"] = '1'
#不使用历史持仓
defineDict["SECURITY_FTDC_PDT_NoUseHistory"] = '2'
typedefDict["TSecurityFtdcPositionDateTypeType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcExchangeInstIDType是一个合约在交易所的代码类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcExchangeInstIDType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcYearType是一个年份类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcYearType"] = "int"
#//////////////////////////////////////////////////////////////////////
#TFtdcMonthType是一个月份类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcMonthType"] = "int"
#//////////////////////////////////////////////////////////////////////
#TFtdcInstLifePhaseType是一个合约生命周期状态类型
#//////////////////////////////////////////////////////////////////////
#未上市
defineDict["SECURITY_FTDC_IP_NotStart"] = '0'
#上市
defineDict["SECURITY_FTDC_IP_Started"] = '1'
#停牌
defineDict["SECURITY_FTDC_IP_Pause"] = '2'
#到期
defineDict["SECURITY_FTDC_IP_Expired"] = '3'
typedefDict["TSecurityFtdcInstLifePhaseType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcBoolType是一个布尔型类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcBoolType"] = "int"
#//////////////////////////////////////////////////////////////////////
#TFtdcRightModelIDType是一个股票权限模版代码类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcRightModelIDType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcRightModelNameType是一个股票权限模版名称类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcRightModelNameType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcPosTradeTypeType是一个持仓交易类型类型
#//////////////////////////////////////////////////////////////////////
#今日新增持仓能卖出
defineDict["SECURITY_FTDC_PTT_CanSelTodayPos"] = '1'
#今日新增持仓不能卖出
defineDict["SECURITY_FTDC_PTT_CannotSellTodayPos"] = '2'
typedefDict["TSecurityFtdcPosTradeTypeType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcTraderIDType是一个交易所交易员代码类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcTraderIDType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcParticipantIDType是一个会员代码类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcParticipantIDType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcPasswordType是一个密码类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcPasswordType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcBrokerIDType是一个经纪公司代码类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcBrokerIDType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcOrderLocalIDType是一个本地报单编号类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcOrderLocalIDType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcBrokerAbbrType是一个经纪公司简称类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcBrokerAbbrType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcBrokerNameType是一个经纪公司名称类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcBrokerNameType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcInvestorIDType是一个投资者代码类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcInvestorIDType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcPartyNameType是一个参与人名称类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcPartyNameType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcIdCardTypeType是一个证件类型类型
#//////////////////////////////////////////////////////////////////////
#组织机构代码
defineDict["SECURITY_FTDC_ICT_EID"] = '0'
#身份证
defineDict["SECURITY_FTDC_ICT_IDCard"] = '1'
#军官证
defineDict["SECURITY_FTDC_ICT_OfficerIDCard"] = '2'
#警官证
defineDict["SECURITY_FTDC_ICT_PoliceIDCard"] = '3'
#士兵证
defineDict["SECURITY_FTDC_ICT_SoldierIDCard"] = '4'
#户口簿
defineDict["SECURITY_FTDC_ICT_HouseholdRegister"] = '5'
#护照
defineDict["SECURITY_FTDC_ICT_Passport"] = '6'
#台胞证
defineDict["SECURITY_FTDC_ICT_TaiwanCompatriotIDCard"] = '7'
#回乡证
defineDict["SECURITY_FTDC_ICT_HomeComingCard"] = '8'
#营业执照号
defineDict["SECURITY_FTDC_ICT_LicenseNo"] = '9'
#税务登记号
defineDict["SECURITY_FTDC_ICT_TaxNo"] = 'A'
#其他证件
defineDict["SECURITY_FTDC_ICT_OtherCard"] = 'x'
typedefDict["TSecurityFtdcIdCardTypeType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcIdentifiedCardNoType是一个证件号码类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcIdentifiedCardNoType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcClientIDType是一个交易编码类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcClientIDType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcAccountIDType是一个投资者帐号类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcAccountIDType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcClientTypeType是一个交易编码类型类型
#//////////////////////////////////////////////////////////////////////
#普通
defineDict["SECURITY_FTDC_CLT_Normal"] = '1'
#信用交易
defineDict["SECURITY_FTDC_CLT_Credit"] = '2'
#衍生品账户
defineDict["SECURITY_FTDC_CLT_Derive"] = '3'
#其他类型
defineDict["SECURITY_FTDC_CLT_Other"] = '4'
typedefDict["TSecurityFtdcClientTypeType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcInvestorGroupNameType是一个投资者分组名称类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcInvestorGroupNameType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcUserIDType是一个用户代码类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcUserIDType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcUserNameType是一个用户名称类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcUserNameType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcFunctionCodeType是一个功能代码类型
#//////////////////////////////////////////////////////////////////////
#强制用户登出
defineDict["SECURITY_FTDC_FC_ForceUserLogout"] = '2'
#变更管理用户口令
defineDict["SECURITY_FTDC_FC_UserPasswordUpdate"] = '3'
#变更经纪公司口令
defineDict["SECURITY_FTDC_FC_BrokerPasswordUpdate"] = '4'
#变更投资者口令
defineDict["SECURITY_FTDC_FC_InvestorPasswordUpdate"] = '5'
#报单插入
defineDict["SECURITY_FTDC_FC_OrderInsert"] = '6'
#报单操作
defineDict["SECURITY_FTDC_FC_OrderAction"] = '7'
#同步系统数据
defineDict["SECURITY_FTDC_FC_SyncSystemData"] = '8'
#同步经纪公司数据
defineDict["SECURITY_FTDC_FC_SyncBrokerData"] = '9'
#超级查询
defineDict["SECURITY_FTDC_FC_SuperQuery"] = 'B'
#报单插入
defineDict["SECURITY_FTDC_FC_ParkedOrderInsert"] = 'C'
#报单操作
defineDict["SECURITY_FTDC_FC_ParkedOrderAction"] = 'D'
#同步动态令牌
defineDict["SECURITY_FTDC_FC_SyncOTP"] = 'E'
#未知单操作
defineDict["SECURITY_FTDC_FC_UnkownOrderAction"] = 'F'
#转托管
defineDict["SECURITY_FTDC_FC_DepositoryTransfer"] = 'G'
#余券划转
defineDict["SECURITY_FTDC_FC_ExcessStockTransfer"] = 'H'
typedefDict["TSecurityFtdcFunctionCodeType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcUserTypeType是一个用户类型类型
#//////////////////////////////////////////////////////////////////////
#投资者
defineDict["SECURITY_FTDC_UT_Investor"] = '0'
#操作员
defineDict["SECURITY_FTDC_UT_Operator"] = '1'
#管理员
defineDict["SECURITY_FTDC_UT_SuperUser"] = '2'
typedefDict["TSecurityFtdcUserTypeType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcBrokerFunctionCodeType是一个经纪公司功能代码类型
#//////////////////////////////////////////////////////////////////////
#强制用户登出
defineDict["SECURITY_FTDC_BFC_ForceUserLogout"] = '1'
#变更用户口令
defineDict["SECURITY_FTDC_BFC_UserPasswordUpdate"] = '2'
#同步经纪公司数据
defineDict["SECURITY_FTDC_BFC_SyncBrokerData"] = '3'
#报单插入
defineDict["SECURITY_FTDC_BFC_OrderInsert"] = '5'
#报单操作
defineDict["SECURITY_FTDC_BFC_OrderAction"] = '6'
#全部查询
defineDict["SECURITY_FTDC_BFC_AllQuery"] = '7'
#未知单操作
defineDict["SECURITY_FTDC_BFC_UnkownOrderAction"] = '8'
#转托管
defineDict["SECURITY_FTDC_BFC_DepositoryTransfer"] = '9'
#余券划转
defineDict["SECURITY_FTDC_BFC_ExcessStockTransfer"] = 'A'
#资金内转
defineDict["SECURITY_FTDC_BFC_FundInterTransfer"] = 'B'
#系统功能:登入/登出/修改密码等
defineDict["SECURITY_FTDC_BFC_log"] = 'a'
#基本查询:查询基础数据,如合约,交易所等常量
defineDict["SECURITY_FTDC_BFC_BaseQry"] = 'b'
#交易查询:如查成交,委托
defineDict["SECURITY_FTDC_BFC_TradeQry"] = 'c'
#交易功能:报单,撤单
defineDict["SECURITY_FTDC_BFC_Trade"] = 'd'
#转账
defineDict["SECURITY_FTDC_BFC_Virement"] = 'e'
#查询/管理:查询会话,踢人等
defineDict["SECURITY_FTDC_BFC_Session"] = 'g'
#同步动态令牌
defineDict["SECURITY_FTDC_BFC_SyncOTP"] = 'E'
typedefDict["TSecurityFtdcBrokerFunctionCodeType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcCurrencyCodeType是一个币种类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcCurrencyCodeType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcMoneyType是一个资金类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcMoneyType"] = "float"
#//////////////////////////////////////////////////////////////////////
#TFtdcRatioType是一个比率类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcRatioType"] = "float"
#//////////////////////////////////////////////////////////////////////
#TFtdcAccountTypeType是一个账户类型类型
#//////////////////////////////////////////////////////////////////////
#普通账户
defineDict["SECURITY_FTDC_AcT_Normal"] = '1'
#信用账户
defineDict["SECURITY_FTDC_AcT_Credit"] = '2'
#衍生品账户
defineDict["SECURITY_FTDC_AcT_Derive"] = '3'
#其他类型
defineDict["SECURITY_FTDC_AcT_Other"] = '4'
typedefDict["TSecurityFtdcAccountTypeType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcDepartmentRangeType是一个投资者范围类型
#//////////////////////////////////////////////////////////////////////
#所有
defineDict["SECURITY_FTDC_DR_All"] = '1'
#组织架构
defineDict["SECURITY_FTDC_DR_Group"] = '2'
#单一投资者
defineDict["SECURITY_FTDC_DR_Single"] = '3'
typedefDict["TSecurityFtdcDepartmentRangeType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcUserRightTypeType是一个客户权限类型类型
#//////////////////////////////////////////////////////////////////////
#登录
defineDict["SECURITY_FTDC_URT_Logon"] = '1'
#银期转帐
defineDict["SECURITY_FTDC_URT_Transfer"] = '2'
#邮寄结算单
defineDict["SECURITY_FTDC_URT_EMail"] = '3'
#传真结算单
defineDict["SECURITY_FTDC_URT_Fax"] = '4'
#条件单
defineDict["SECURITY_FTDC_URT_ConditionOrder"] = '5'
typedefDict["TSecurityFtdcUserRightTypeType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcProductInfoType是一个产品信息类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcProductInfoType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcAuthCodeType是一个客户端认证码类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcAuthCodeType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcLargeVolumeType是一个大额数量类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcLargeVolumeType"] = "float"
#//////////////////////////////////////////////////////////////////////
#TFtdcMillisecType是一个时间(毫秒)类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcMillisecType"] = "int"
#//////////////////////////////////////////////////////////////////////
#TFtdcHedgeFlagType是一个投机套保标志类型
#//////////////////////////////////////////////////////////////////////
#投机
defineDict["SECURITY_FTDC_HF_Speculation"] = '1'
#套保
defineDict["SECURITY_FTDC_HF_Hedge"] = '3'
typedefDict["TSecurityFtdcHedgeFlagType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcDirectionType是一个买卖方向类型
#//////////////////////////////////////////////////////////////////////
#买
defineDict["SECURITY_FTDC_D_Buy"] = '0'
#卖
defineDict["SECURITY_FTDC_D_Sell"] = '1'
#ETF申购
defineDict["SECURITY_FTDC_D_ETFPur"] = '2'
#ETF赎回
defineDict["SECURITY_FTDC_D_ETFRed"] = '3'
#现金替代,只用作回报
defineDict["SECURITY_FTDC_D_CashIn"] = '4'
#债券入库
defineDict["SECURITY_FTDC_D_PledgeBondIn"] = '5'
#债券出库
defineDict["SECURITY_FTDC_D_PledgeBondOut"] = '6'
#配股
defineDict["SECURITY_FTDC_D_Rationed"] = '7'
#转托管
defineDict["SECURITY_FTDC_D_DepositoryTransfer"] = '8'
#信用账户配股
defineDict["SECURITY_FTDC_D_CreditRationed"] = '9'
#担保品买入
defineDict["SECURITY_FTDC_D_BuyCollateral"] = 'A'
#担保品卖出
defineDict["SECURITY_FTDC_D_SellCollateral"] = 'B'
#担保品转入
defineDict["SECURITY_FTDC_D_CollateralTransferIn"] = 'C'
#担保品转出
defineDict["SECURITY_FTDC_D_CollateralTransferOut"] = 'D'
#融资买入
defineDict["SECURITY_FTDC_D_MarginTrade"] = 'E'
#融券卖出
defineDict["SECURITY_FTDC_D_ShortSell"] = 'F'
#卖券还款
defineDict["SECURITY_FTDC_D_RepayMargin"] = 'G'
#买券还券
defineDict["SECURITY_FTDC_D_RepayStock"] = 'H'
#直接还款
defineDict["SECURITY_FTDC_D_DirectRepayMargin"] = 'I'
#直接还券
defineDict["SECURITY_FTDC_D_DirectRepayStock"] = 'J'
#余券划转
defineDict["SECURITY_FTDC_D_ExcessStockTransfer"] = 'K'
#OF申购
defineDict["SECURITY_FTDC_D_OFPur"] = 'L'
#OF赎回
defineDict["SECURITY_FTDC_D_OFRed"] = 'M'
#SF拆分
defineDict["SECURITY_FTDC_D_SFSplit"] = 'N'
#SF合并
defineDict["SECURITY_FTDC_D_SFMerge"] = 'O'
#备兑
defineDict["SECURITY_FTDC_D_Covered"] = 'P'
#证券冻结(开)/解冻(平)
defineDict["SECURITY_FTDC_D_Freeze"] = 'Q'
#行权
defineDict["SECURITY_FTDC_D_Execute"] = 'R'
typedefDict["TSecurityFtdcDirectionType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcTradeIDType是一个成交编号类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcTradeIDType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcTradeTypeType是一个成交类型类型
#//////////////////////////////////////////////////////////////////////
#普通成交
defineDict["SECURITY_FTDC_TRDT_Common"] = '0'
#期权执行
defineDict["SECURITY_FTDC_TRDT_OptionsExecution"] = '1'
#OTC成交
defineDict["SECURITY_FTDC_TRDT_OTC"] = '2'
#期转现衍生成交
defineDict["SECURITY_FTDC_TRDT_EFPDerived"] = '3'
#组合衍生成交
defineDict["SECURITY_FTDC_TRDT_CombinationDerived"] = '4'
#ETF申购
defineDict["SECURITY_FTDC_TRDT_EFTPurchase"] = '5'
#ETF赎回
defineDict["SECURITY_FTDC_TRDT_EFTRedem"] = '6'
typedefDict["TSecurityFtdcTradeTypeType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcCreationredemptionStatusType是一个基金当天申购赎回状态类型
#//////////////////////////////////////////////////////////////////////
#不允许申购赎回
defineDict["SECURITY_FTDC_CDS_Forbidden"] = '0'
#表示允许申购和赎回
defineDict["SECURITY_FTDC_CDS_Allow"] = '1'
#允许申购、不允许赎回
defineDict["SECURITY_FTDC_CDS_OnlyPurchase"] = '2'
#不允许申购、允许赎回
defineDict["SECURITY_FTDC_CDS_OnlyRedeem"] = '3'
typedefDict["TSecurityFtdcCreationredemptionStatusType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcETFCurrenceReplaceStatusType是一个ETF现金替代标志类型
#//////////////////////////////////////////////////////////////////////
#禁止现金替代
defineDict["SECURITY_FTDC_ETFCRS_Forbidden"] = '0'
#可以现金替代
defineDict["SECURITY_FTDC_ETFCRS_Allow"] = '1'
#必须现金替代
defineDict["SECURITY_FTDC_ETFCRS_Force"] = '2'
typedefDict["TSecurityFtdcETFCurrenceReplaceStatusType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcInterestType是一个利息类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcInterestType"] = "float"
#//////////////////////////////////////////////////////////////////////
#TFtdcRepurchaseMaxTimesType是一个正回购放大倍数类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcRepurchaseMaxTimesType"] = "float"
#//////////////////////////////////////////////////////////////////////
#TFtdcCapitalStockTypeType是一个股本类型类型
#//////////////////////////////////////////////////////////////////////
#总通股本
defineDict["SECURITY_FTDC_CPTSTOCK_TOTALSTOCK"] = '1'
#流通股本
defineDict["SECURITY_FTDC_CPTSTOCK_CIRCULATION"] = '2'
typedefDict["TSecurityFtdcCapitalStockTypeType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcMarginPriceTypeType是一个保证金价格类型类型
#//////////////////////////////////////////////////////////////////////
#昨结算价
defineDict["SECURITY_FTDC_MPT_PreSettlementPrice"] = '1'
#最新价
defineDict["SECURITY_FTDC_MPT_SettlementPrice"] = '2'
#成交均价
defineDict["SECURITY_FTDC_MPT_AveragePrice"] = '3'
#开仓价
defineDict["SECURITY_FTDC_MPT_OpenPrice"] = '4'
typedefDict["TSecurityFtdcMarginPriceTypeType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcAlgorithmType是一个盈亏算法类型
#//////////////////////////////////////////////////////////////////////
#浮盈浮亏都计算
defineDict["SECURITY_FTDC_AG_All"] = '1'
#浮盈不计,浮亏计
defineDict["SECURITY_FTDC_AG_OnlyLost"] = '2'
#浮盈计,浮亏不计
defineDict["SECURITY_FTDC_AG_OnlyGain"] = '3'
#浮盈浮亏都不计算
defineDict["SECURITY_FTDC_AG_None"] = '4'
typedefDict["TSecurityFtdcAlgorithmType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcIncludeCloseProfitType是一个是否包含平仓盈利类型
#//////////////////////////////////////////////////////////////////////
#包含平仓盈利
defineDict["SECURITY_FTDC_ICP_Include"] = '0'
#不包含平仓盈利
defineDict["SECURITY_FTDC_ICP_NotInclude"] = '2'
typedefDict["TSecurityFtdcIncludeCloseProfitType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcAllWithoutTradeType是一个是否受可提比例限制类型
#//////////////////////////////////////////////////////////////////////
#不受可提比例限制
defineDict["SECURITY_FTDC_AWT_Enable"] = '0'
#受可提比例限制
defineDict["SECURITY_FTDC_AWT_Disable"] = '2'
#无仓不受可提比例限制
defineDict["SECURITY_FTDC_AWT_NoHoldEnable"] = '3'
typedefDict["TSecurityFtdcAllWithoutTradeType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcHandlePositionAlgoIDType是一个持仓处理算法编号类型
#//////////////////////////////////////////////////////////////////////
#基本
defineDict["SECURITY_FTDC_HPA_Base"] = '1'
#非交易
defineDict["SECURITY_FTDC_HPA_NoneTrade"] = '4'
#证券
defineDict["SECURITY_FTDC_HPA_Stock"] = '5'
typedefDict["TSecurityFtdcHandlePositionAlgoIDType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcTradeParamIDType是一个交易系统参数代码类型
#//////////////////////////////////////////////////////////////////////
#系统加密算法
defineDict["SECURITY_FTDC_TPID_EncryptionStandard"] = 'E'
#用户最大会话数
defineDict["SECURITY_FTDC_TPID_SingleUserSessionMaxNum"] = 'S'
#最大连续登录失败数
defineDict["SECURITY_FTDC_TPID_LoginFailMaxNum"] = 'L'
#是否强制认证
defineDict["SECURITY_FTDC_TPID_IsAuthForce"] = 'A'
#是否生成用户事件
defineDict["SECURITY_FTDC_TPID_GenUserEvent"] = 'G'
#起始报单本地编号
defineDict["SECURITY_FTDC_TPID_StartOrderLocalID"] = 'O'
#融资融券买券还券算法
defineDict["SECURITY_FTDC_TPID_RepayStockAlgo"] = 'R'
#衍生品账户资金提取线
defineDict["SECURITY_FTDC_TPID_DeriveWithdrawRatio"] = 'D'
typedefDict["TSecurityFtdcTradeParamIDType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcSettlementParamValueType是一个参数代码值类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcSettlementParamValueType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcMemoType是一个备注类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcMemoType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcPriorityType是一个优先级类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcPriorityType"] = "int"
#//////////////////////////////////////////////////////////////////////
#TFtdcOrderRefType是一个报单引用类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcOrderRefType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcMarketIDType是一个市场代码类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcMarketIDType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcMacAddressType是一个Mac地址类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcMacAddressType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcInstrumentNameType是一个合约名称类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcInstrumentNameType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcOrderSysIDType是一个报单编号类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcOrderSysIDType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcIPAddressType是一个IP地址类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcIPAddressType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcIPPortType是一个IP端口类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcIPPortType"] = "int"
#//////////////////////////////////////////////////////////////////////
#TFtdcProtocolInfoType是一个协议信息类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcProtocolInfoType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcDepositSeqNoType是一个出入金流水号类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcDepositSeqNoType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcSystemNameType是一个系统名称类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcSystemNameType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcInvestorRangeType是一个投资者范围类型
#//////////////////////////////////////////////////////////////////////
#所有
defineDict["SECURITY_FTDC_IR_All"] = '1'
#投资者组
defineDict["SECURITY_FTDC_IR_Group"] = '2'
#单一投资者
defineDict["SECURITY_FTDC_IR_Single"] = '3'
typedefDict["TSecurityFtdcInvestorRangeType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcDataSyncStatusType是一个数据同步状态类型
#//////////////////////////////////////////////////////////////////////
#未同步
defineDict["SECURITY_FTDC_DS_Asynchronous"] = '1'
#同步中
defineDict["SECURITY_FTDC_DS_Synchronizing"] = '2'
#已同步
defineDict["SECURITY_FTDC_DS_Synchronized"] = '3'
typedefDict["TSecurityFtdcDataSyncStatusType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcTraderConnectStatusType是一个交易所交易员连接状态类型
#//////////////////////////////////////////////////////////////////////
#没有任何连接
defineDict["SECURITY_FTDC_TCS_NotConnected"] = '1'
#已经连接
defineDict["SECURITY_FTDC_TCS_Connected"] = '2'
#已经发出合约查询请求
defineDict["SECURITY_FTDC_TCS_QryInstrumentSent"] = '3'
#订阅私有流
defineDict["SECURITY_FTDC_TCS_SubPrivateFlow"] = '4'
typedefDict["TSecurityFtdcTraderConnectStatusType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcOrderActionStatusType是一个报单操作状态类型
#//////////////////////////////////////////////////////////////////////
#已经提交
defineDict["SECURITY_FTDC_OAS_Submitted"] = 'a'
#已经接受
defineDict["SECURITY_FTDC_OAS_Accepted"] = 'b'
#已经被拒绝
defineDict["SECURITY_FTDC_OAS_Rejected"] = 'c'
typedefDict["TSecurityFtdcOrderActionStatusType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcOrderStatusType是一个报单状态类型
#//////////////////////////////////////////////////////////////////////
#全部成交
defineDict["SECURITY_FTDC_OST_AllTraded"] = '0'
#部分成交还在队列中
defineDict["SECURITY_FTDC_OST_PartTradedQueueing"] = '1'
#部分成交不在队列中
defineDict["SECURITY_FTDC_OST_PartTradedNotQueueing"] = '2'
#未成交还在队列中
defineDict["SECURITY_FTDC_OST_NoTradeQueueing"] = '3'
#未成交不在队列中
defineDict["SECURITY_FTDC_OST_NoTradeNotQueueing"] = '4'
#撤单
defineDict["SECURITY_FTDC_OST_Canceled"] = '5'
#未知
defineDict["SECURITY_FTDC_OST_Unknown"] = 'a'
#尚未触发
defineDict["SECURITY_FTDC_OST_NotTouched"] = 'b'
#已触发
defineDict["SECURITY_FTDC_OST_Touched"] = 'c'
typedefDict["TSecurityFtdcOrderStatusType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcOrderSubmitStatusType是一个报单提交状态类型
#//////////////////////////////////////////////////////////////////////
#已经提交
defineDict["SECURITY_FTDC_OSS_InsertSubmitted"] = '0'
#撤单已经提交
defineDict["SECURITY_FTDC_OSS_CancelSubmitted"] = '1'
#修改已经提交
defineDict["SECURITY_FTDC_OSS_ModifySubmitted"] = '2'
#已经接受
defineDict["SECURITY_FTDC_OSS_Accepted"] = '3'
#报单已经被拒绝
defineDict["SECURITY_FTDC_OSS_InsertRejected"] = '4'
#撤单已经被拒绝
defineDict["SECURITY_FTDC_OSS_CancelRejected"] = '5'
#改单已经被拒绝
defineDict["SECURITY_FTDC_OSS_ModifyRejected"] = '6'
typedefDict["TSecurityFtdcOrderSubmitStatusType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcPositionDateType是一个持仓日期类型
#//////////////////////////////////////////////////////////////////////
#今日持仓
defineDict["SECURITY_FTDC_PSD_Today"] = '1'
#历史持仓
defineDict["SECURITY_FTDC_PSD_History"] = '2'
typedefDict["TSecurityFtdcPositionDateType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcTradingRoleType是一个交易角色类型
#//////////////////////////////////////////////////////////////////////
#代理
defineDict["SECURITY_FTDC_ER_Broker"] = '1'
#自营
defineDict["SECURITY_FTDC_ER_Host"] = '2'
#做市商
defineDict["SECURITY_FTDC_ER_Maker"] = '3'
typedefDict["TSecurityFtdcTradingRoleType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcPosiDirectionType是一个持仓多空方向类型
#//////////////////////////////////////////////////////////////////////
#净
defineDict["SECURITY_FTDC_PD_Net"] = '1'
#多头
defineDict["SECURITY_FTDC_PD_Long"] = '2'
#空头
defineDict["SECURITY_FTDC_PD_Short"] = '3'
#备兑
defineDict["SECURITY_FTDC_PD_Covered"] = '4'
typedefDict["TSecurityFtdcPosiDirectionType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcOrderPriceTypeType是一个报单价格条件类型
#//////////////////////////////////////////////////////////////////////
#即时成交剩余撤销市价单
defineDict["SECURITY_FTDC_OPT_AnyPrice"] = '1'
#限价
defineDict["SECURITY_FTDC_OPT_LimitPrice"] = '2'
#最优五档即时成交剩余撤销市价单
defineDict["SECURITY_FTDC_OPT_BestPrice"] = '3'
#最优五档即时成交剩余转限价市价单
defineDict["SECURITY_FTDC_OPT_BestLimitPrice"] = '4'
#全部成交或撤销市价单
defineDict["SECURITY_FTDC_OPT_AllPrice"] = '5'
#本方最优价格市价单
defineDict["SECURITY_FTDC_OPT_ForwardBestPrice"] = '6'
#对方最优价格市价单
defineDict["SECURITY_FTDC_OPT_ReverseBestPrice"] = '7'
#即时成交剩余转限价市价单
defineDict["SECURITY_FTDC_OPT_Any2LimitPrice"] = '8'
#全部成交或撤销限价单
defineDict["SECURITY_FTDC_OPT_AllLimitPrice"] = '9'
#激活A股网络密码服务代码
defineDict["SECURITY_FTDC_OPT_ActiveANetPassSvrCode"] = 'G'
#注销A股网络密码服务代码
defineDict["SECURITY_FTDC_OPT_InactiveANetPassSvrCode"] = 'H'
#激活B股网络密码服务代码
defineDict["SECURITY_FTDC_OPT_ActiveBNetPassSvrCode"] = 'I'
#注销B股网络密码服务代码
defineDict["SECURITY_FTDC_OPT_InactiveBNetPassSvrCode"] = 'J'
#回购注销
defineDict["SECURITY_FTDC_OPT_Repurchase"] = 'K'
#指定撤销
defineDict["SECURITY_FTDC_OPT_DesignatedCancel"] = 'L'
#指定登记
defineDict["SECURITY_FTDC_OPT_Designated"] = 'M'
#证券参与申购
defineDict["SECURITY_FTDC_OPT_SubscribingShares"] = 'N'
#证券参与配股
defineDict["SECURITY_FTDC_OPT_Split"] = 'O'
#要约收购登记
defineDict["SECURITY_FTDC_OPT_TenderOffer"] = 'P'
#要约收购撤销
defineDict["SECURITY_FTDC_OPT_TenderOfferCancel"] = 'Q'
#证券投票
defineDict["SECURITY_FTDC_OPT_Ballot"] = 'R'
#可转债转换登记
defineDict["SECURITY_FTDC_OPT_ConvertibleBondsConvet"] = 'S'
#可转债回售登记
defineDict["SECURITY_FTDC_OPT_ConvertibleBondsRepurchase"] = 'T'
#权证行权
defineDict["SECURITY_FTDC_OPT_Exercise"] = 'U'
#开放式基金申购
defineDict["SECURITY_FTDC_OPT_PurchasingFunds"] = 'V'
#开放式基金赎回
defineDict["SECURITY_FTDC_OPT_RedemingFunds"] = 'W'
#开放式基金认购
defineDict["SECURITY_FTDC_OPT_SubscribingFunds"] = 'X'
#开放式基金转托管转出
defineDict["SECURITY_FTDC_OPT_LOFIssue"] = 'Y'
#开放式基金设置分红方式
defineDict["SECURITY_FTDC_OPT_LOFSetBonusType"] = 'Z'
#开放式基金转换为其他基金
defineDict["SECURITY_FTDC_OPT_LOFConvert"] = 'a'
#债券入库
defineDict["SECURITY_FTDC_OPT_DebentureStockIn"] = 'b'
#债券出库
defineDict["SECURITY_FTDC_OPT_DebentureStockOut"] = 'c'
#ETF申购
defineDict["SECURITY_FTDC_OPT_PurchasesETF"] = 'd'
#ETF赎回
defineDict["SECURITY_FTDC_OPT_RedeemETF"] = 'e'
typedefDict["TSecurityFtdcOrderPriceTypeType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcOffsetFlagType是一个开平标志类型
#//////////////////////////////////////////////////////////////////////
#开仓
defineDict["SECURITY_FTDC_OF_Open"] = '0'
#平仓
defineDict["SECURITY_FTDC_OF_Close"] = '1'
#强平
defineDict["SECURITY_FTDC_OF_ForceClose"] = '2'
#平今
defineDict["SECURITY_FTDC_OF_CloseToday"] = '3'
#平昨
defineDict["SECURITY_FTDC_OF_CloseYesterday"] = '4'
#强减
defineDict["SECURITY_FTDC_OF_ForceOff"] = '5'
#本地强平
defineDict["SECURITY_FTDC_OF_LocalForceClose"] = '6'
typedefDict["TSecurityFtdcOffsetFlagType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcForceCloseReasonType是一个强平原因类型
#//////////////////////////////////////////////////////////////////////
#非强平
defineDict["SECURITY_FTDC_FCC_NotForceClose"] = '0'
#资金不足
defineDict["SECURITY_FTDC_FCC_LackDeposit"] = '1'
#客户超仓
defineDict["SECURITY_FTDC_FCC_ClientOverPositionLimit"] = '2'
#会员超仓
defineDict["SECURITY_FTDC_FCC_MemberOverPositionLimit"] = '3'
#持仓非整数倍
defineDict["SECURITY_FTDC_FCC_NotMultiple"] = '4'
#违规
defineDict["SECURITY_FTDC_FCC_Violation"] = '5'
#其它
defineDict["SECURITY_FTDC_FCC_Other"] = '6'
#自然人临近交割
defineDict["SECURITY_FTDC_FCC_PersonDeliv"] = '7'
typedefDict["TSecurityFtdcForceCloseReasonType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcOrderTypeType是一个报单类型类型
#//////////////////////////////////////////////////////////////////////
#正常
defineDict["SECURITY_FTDC_ORDT_Normal"] = '0'
#报价衍生
defineDict["SECURITY_FTDC_ORDT_DeriveFromQuote"] = '1'
#组合衍生
defineDict["SECURITY_FTDC_ORDT_DeriveFromCombination"] = '2'
#组合报单
defineDict["SECURITY_FTDC_ORDT_Combination"] = '3'
#条件单
defineDict["SECURITY_FTDC_ORDT_ConditionalOrder"] = '4'
#互换单
defineDict["SECURITY_FTDC_ORDT_Swap"] = '5'
typedefDict["TSecurityFtdcOrderTypeType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcTimeConditionType是一个有效期类型类型
#//////////////////////////////////////////////////////////////////////
#立即完成,否则撤销
defineDict["SECURITY_FTDC_TC_IOC"] = '1'
#本节有效
defineDict["SECURITY_FTDC_TC_GFS"] = '2'
#当日有效
defineDict["SECURITY_FTDC_TC_GFD"] = '3'
#指定日期前有效
defineDict["SECURITY_FTDC_TC_GTD"] = '4'
#撤销前有效
defineDict["SECURITY_FTDC_TC_GTC"] = '5'
#集合竞价有效
defineDict["SECURITY_FTDC_TC_GFA"] = '6'
typedefDict["TSecurityFtdcTimeConditionType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcVolumeConditionType是一个成交量类型类型
#//////////////////////////////////////////////////////////////////////
#任何数量
defineDict["SECURITY_FTDC_VC_AV"] = '1'
#最小数量
defineDict["SECURITY_FTDC_VC_MV"] = '2'
#全部数量
defineDict["SECURITY_FTDC_VC_CV"] = '3'
typedefDict["TSecurityFtdcVolumeConditionType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcContingentConditionType是一个触发条件类型
#//////////////////////////////////////////////////////////////////////
#立即
defineDict["SECURITY_FTDC_CC_Immediately"] = '1'
#止损
defineDict["SECURITY_FTDC_CC_Touch"] = '2'
#止赢
defineDict["SECURITY_FTDC_CC_TouchProfit"] = '3'
#预埋单
defineDict["SECURITY_FTDC_CC_ParkedOrder"] = '4'
#最新价大于条件价
defineDict["SECURITY_FTDC_CC_LastPriceGreaterThanStopPrice"] = '5'
#最新价大于等于条件价
defineDict["SECURITY_FTDC_CC_LastPriceGreaterEqualStopPrice"] = '6'
#最新价小于条件价
defineDict["SECURITY_FTDC_CC_LastPriceLesserThanStopPrice"] = '7'
#最新价小于等于条件价
defineDict["SECURITY_FTDC_CC_LastPriceLesserEqualStopPrice"] = '8'
#卖一价大于条件价
defineDict["SECURITY_FTDC_CC_AskPriceGreaterThanStopPrice"] = '9'
#卖一价大于等于条件价
defineDict["SECURITY_FTDC_CC_AskPriceGreaterEqualStopPrice"] = 'A'
#卖一价小于条件价
defineDict["SECURITY_FTDC_CC_AskPriceLesserThanStopPrice"] = 'B'
#卖一价小于等于条件价
defineDict["SECURITY_FTDC_CC_AskPriceLesserEqualStopPrice"] = 'C'
#买一价大于条件价
defineDict["SECURITY_FTDC_CC_BidPriceGreaterThanStopPrice"] = 'D'
#买一价大于等于条件价
defineDict["SECURITY_FTDC_CC_BidPriceGreaterEqualStopPrice"] = 'E'
#买一价小于条件价
defineDict["SECURITY_FTDC_CC_BidPriceLesserThanStopPrice"] = 'F'
#买一价小于等于条件价
defineDict["SECURITY_FTDC_CC_BidPriceLesserEqualStopPrice"] = 'H'
typedefDict["TSecurityFtdcContingentConditionType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcActionFlagType是一个操作标志类型
#//////////////////////////////////////////////////////////////////////
#删除
defineDict["SECURITY_FTDC_AF_Delete"] = '0'
#修改
defineDict["SECURITY_FTDC_AF_Modify"] = '3'
typedefDict["TSecurityFtdcActionFlagType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcTradingRightType是一个交易权限类型
#//////////////////////////////////////////////////////////////////////
#可以交易
defineDict["SECURITY_FTDC_TR_Allow"] = '0'
#不能交易
defineDict["SECURITY_FTDC_TR_Forbidden"] = '2'
typedefDict["TSecurityFtdcTradingRightType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcOrderSourceType是一个报单来源类型
#//////////////////////////////////////////////////////////////////////
#来自参与者
defineDict["SECURITY_FTDC_OSRC_Participant"] = '0'
#来自管理员
defineDict["SECURITY_FTDC_OSRC_Administrator"] = '1'
typedefDict["TSecurityFtdcOrderSourceType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcPriceSourceType是一个成交价来源类型
#//////////////////////////////////////////////////////////////////////
#前成交价
defineDict["SECURITY_FTDC_PSRC_LastPrice"] = '0'
#买委托价
defineDict["SECURITY_FTDC_PSRC_Buy"] = '1'
#卖委托价
defineDict["SECURITY_FTDC_PSRC_Sell"] = '2'
typedefDict["TSecurityFtdcPriceSourceType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcOrderActionRefType是一个报单操作引用类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcOrderActionRefType"] = "int"
#//////////////////////////////////////////////////////////////////////
#TFtdcFrontIDType是一个前置编号类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcFrontIDType"] = "int"
#//////////////////////////////////////////////////////////////////////
#TFtdcSessionIDType是一个会话编号类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcSessionIDType"] = "int"
#//////////////////////////////////////////////////////////////////////
#TFtdcInstallIDType是一个安装编号类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcInstallIDType"] = "int"
#//////////////////////////////////////////////////////////////////////
#TFtdcSequenceNoType是一个序号类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcSequenceNoType"] = "int"
#//////////////////////////////////////////////////////////////////////
#TFtdcRequestIDType是一个请求编号类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcRequestIDType"] = "int"
#//////////////////////////////////////////////////////////////////////
#TFtdcCombOffsetFlagType是一个组合开平标志类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcCombOffsetFlagType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcCombHedgeFlagType是一个组合投机套保标志类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcCombHedgeFlagType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcSequenceSeriesType是一个序列系列号类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcSequenceSeriesType"] = "int"
#//////////////////////////////////////////////////////////////////////
#TFtdcCommPhaseNoType是一个通讯时段编号类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcCommPhaseNoType"] = "int"
#//////////////////////////////////////////////////////////////////////
#TFtdcUserEventTypeType是一个用户事件类型类型
#//////////////////////////////////////////////////////////////////////
#登录
defineDict["SECURITY_FTDC_UET_Login"] = '1'
#登出
defineDict["SECURITY_FTDC_UET_Logout"] = '2'
#交易成功
defineDict["SECURITY_FTDC_UET_Trading"] = '3'
#交易失败
defineDict["SECURITY_FTDC_UET_TradingError"] = '4'
#修改密码
defineDict["SECURITY_FTDC_UET_UpdatePassword"] = '5'
#客户端认证
defineDict["SECURITY_FTDC_UET_Authenticate"] = '6'
#其他
defineDict["SECURITY_FTDC_UET_Other"] = '9'
typedefDict["TSecurityFtdcUserEventTypeType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcUserEventInfoType是一个用户事件信息类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcUserEventInfoType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcOTPTypeType是一个动态令牌类型类型
#//////////////////////////////////////////////////////////////////////
#无动态令牌
defineDict["SECURITY_FTDC_OTP_NONE"] = '0'
#时间令牌
defineDict["SECURITY_FTDC_OTP_TOTP"] = '1'
typedefDict["TSecurityFtdcOTPTypeType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcTradeSourceType是一个成交来源类型
#//////////////////////////////////////////////////////////////////////
#来自交易所普通回报
defineDict["SECURITY_FTDC_TSRC_NORMAL"] = '0'
#来自查询
defineDict["SECURITY_FTDC_TSRC_QUERY"] = '1'
typedefDict["TSecurityFtdcTradeSourceType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcBranchIDType是一个营业部编号类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcBranchIDType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcStockPriceType是一个证券交易价格类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcStockPriceType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcRightModelIDType是一个股票权限模版代码类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcRightModelIDType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcSerialNumberType是一个序列号类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcSerialNumberType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcInstrumentRangeType是一个股票权限分类类型
#//////////////////////////////////////////////////////////////////////
#所有
defineDict["SECURITY_FTDC_INR_All"] = '1'
#产品
defineDict["SECURITY_FTDC_INR_Product"] = '2'
#股票权限模版
defineDict["SECURITY_FTDC_INR_Model"] = '3'
#股票
defineDict["SECURITY_FTDC_INR_Stock"] = '4'
#市场
defineDict["SECURITY_FTDC_INR_Market"] = '5'
typedefDict["TSecurityFtdcInstrumentRangeType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcBusinessUnitType是一个业务单元类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcBusinessUnitType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcOTPVendorsIDType是一个动态令牌提供商类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcOTPVendorsIDType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcLastDriftType是一个上次OTP漂移值类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcLastDriftType"] = "int"
#//////////////////////////////////////////////////////////////////////
#TFtdcLastSuccessType是一个上次OTP成功值类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcLastSuccessType"] = "int"
#//////////////////////////////////////////////////////////////////////
#TFtdcAuthKeyType是一个令牌密钥类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcAuthKeyType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcUserSessionHashType是一个用户会话Hash值类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcUserSessionHashType"] = "int"
#//////////////////////////////////////////////////////////////////////
#TFtdcStockTradeTypeType是一个证券交易类型类型
#//////////////////////////////////////////////////////////////////////
#可交易证券
defineDict["SECURITY_FTDC_STT_Stock"] = '0'
#买入网络密码服务
defineDict["SECURITY_FTDC_STT_BuyNetService"] = '1'
#回购注销
defineDict["SECURITY_FTDC_STT_CancelRepurchase"] = '2'
#指定撤销
defineDict["SECURITY_FTDC_STT_CancelRegister"] = '3'
#指定登记
defineDict["SECURITY_FTDC_STT_Register"] = '4'
#买入发行申购
defineDict["SECURITY_FTDC_STT_PurchaseIssue"] = '5'
#卖出配股
defineDict["SECURITY_FTDC_STT_Allotment"] = '6'
#卖出要约收购
defineDict["SECURITY_FTDC_STT_SellTender"] = '7'
#买入要约收购
defineDict["SECURITY_FTDC_STT_BuyTender"] = '8'
#网上投票
defineDict["SECURITY_FTDC_STT_NetVote"] = '9'
#卖出可转债回售
defineDict["SECURITY_FTDC_STT_SellConvertibleBonds"] = 'a'
#权证行权代码
defineDict["SECURITY_FTDC_STT_OptionExecute"] = 'b'
#开放式基金申购
defineDict["SECURITY_FTDC_STT_PurchaseOF"] = 'c'
#开放式基金赎回
defineDict["SECURITY_FTDC_STT_RedeemOF"] = 'd'
#开放式基金认购
defineDict["SECURITY_FTDC_STT_SubscribeOF"] = 'e'
#开放式基金转托管转出
defineDict["SECURITY_FTDC_STT_OFCustodianTranfer"] = 'f'
#开放式基金分红设置
defineDict["SECURITY_FTDC_STT_OFDividendConfig"] = 'g'
#开放式基金转成其他基金
defineDict["SECURITY_FTDC_STT_OFTransfer"] = 'h'
#债券入库
defineDict["SECURITY_FTDC_STT_BondsIn"] = 'i'
#债券出库
defineDict["SECURITY_FTDC_STT_BondsOut"] = 'j'
#EFT申购
defineDict["SECURITY_FTDC_STT_PurchaseETF"] = 'k'
#EFT赎回
defineDict["SECURITY_FTDC_STT_RedeemETF"] = 'l'
#可转债回售登记
defineDict["SECURITY_FTDC_STT_ConvertibleRegister"] = 'm'
typedefDict["TSecurityFtdcStockTradeTypeType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcHandleTradingAccountAlgoIDType是一个资金处理算法编号类型
#//////////////////////////////////////////////////////////////////////
#基本
defineDict["SECURITY_FTDC_HTAA_Base"] = '1'
typedefDict["TSecurityFtdcHandleTradingAccountAlgoIDType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcStockWthType是一个股票使用流水号类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcStockWthType"] = "int"
#//////////////////////////////////////////////////////////////////////
#TFtdcStockSeqType是一个股票使用流水号类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcStockSeqType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcWTFSType是一个委托方式类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcWTFSType"] = "int"
#//////////////////////////////////////////////////////////////////////
#TFtdcWTLBType是一个委托类别类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcWTLBType"] = "int"
#//////////////////////////////////////////////////////////////////////
#TFtdcWTRQType是一个委托日期类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcWTRQType"] = "int"
#//////////////////////////////////////////////////////////////////////
#TFtdcINTEGERType是一个一般整型类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcINTEGERType"] = "int"
#//////////////////////////////////////////////////////////////////////
#TFtdcINT3Type是一个三位数整型类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcINT3Type"] = "int"
#//////////////////////////////////////////////////////////////////////
#TFtdcINT6Type是一个六位数整型类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcINT6Type"] = "int"
#//////////////////////////////////////////////////////////////////////
#TFtdcINT12Type是一个十二位数整型类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcINT12Type"] = "int"
#//////////////////////////////////////////////////////////////////////
#TFtdcCHAR1Type是一个一字节CHAR类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcCHAR1Type"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcCHAR2Type是一个二字节CHAR类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcCHAR2Type"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcCHAR3Type是一个三字节CHAR类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcCHAR3Type"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcCHAR4Type是一个四字节CHAR类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcCHAR4Type"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcCHAR5Type是一个五字节CHAR类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcCHAR5Type"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcCHAR6Type是一个六字节CHAR类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcCHAR6Type"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcCHAR8Type是一个八字节CHAR类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcCHAR8Type"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcCHAR10Type是一个十字节CHAR类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcCHAR10Type"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcCHAR11Type是一个十一字节CHAR类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcCHAR11Type"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcCHAR12Type是一个十二字节CHAR类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcCHAR12Type"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcCHAR13Type是一个十三字节CHAR类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcCHAR13Type"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcCHAR14Type是一个十四字节CHAR类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcCHAR14Type"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcCHAR16Type是一个十六字节CHAR类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcCHAR16Type"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcCHAR19Type是一个十九字节CHAR类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcCHAR19Type"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcCHAR20Type是一个二十字节CHAR类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcCHAR20Type"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcCHAR21Type是一个二十一字节CHAR类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcCHAR21Type"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcCHAR23Type是一个二十三字节CHAR类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcCHAR23Type"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcCHAR30Type是一个三十字节CHAR类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcCHAR30Type"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcCHAR32Type是一个三十二字节CHAR类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcCHAR32Type"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcCHAR50Type是一个五十字节CHAR类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcCHAR50Type"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcCHAR64Type是一个六十四字节CHAR类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcCHAR64Type"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcCHAR65Type是一个六十五字节CHAR类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcCHAR65Type"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcVCHAR4Type是一个四字节VCHAR类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcVCHAR4Type"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcVCHAR6Type是一个六字节VCHAR类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcVCHAR6Type"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcVCHAR8Type是一个八字节VCHAR类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcVCHAR8Type"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcVCHAR10Type是一个十字节VCHAR类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcVCHAR10Type"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcVCHAR12Type是一个十二字节VCHAR类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcVCHAR12Type"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcVCHAR16Type是一个十六字节VCHAR类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcVCHAR16Type"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcVCHAR20Type是一个二十字节VCHAR类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcVCHAR20Type"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcVCHAR30Type是一个三十字节VCHAR类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcVCHAR30Type"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcVCHAR50Type是一个五十字节VCHAR类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcVCHAR50Type"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcVCHAR60Type是一个六十字节VCHAR类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcVCHAR60Type"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcVCHAR65Type是一个六十五字节VCHAR类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcVCHAR65Type"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcVCHAR80Type是一个八十字节VCHAR类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcVCHAR80Type"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcVCHAR84Type是一个八十四字节VCHAR类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcVCHAR84Type"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcVCHAR255Type是一个二五五字节VCHAR类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcVCHAR255Type"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcVCHAR1024Type是一个一零二四字节VCHAR类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcVCHAR1024Type"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcREAL8P3Type是一个八点三实型类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcREAL8P3Type"] = "float"
#//////////////////////////////////////////////////////////////////////
#TFtdcREAL9P3Type是一个九点三实型类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcREAL9P3Type"] = "float"
#//////////////////////////////////////////////////////////////////////
#TFtdcREAL9P6Type是一个九点六实型类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcREAL9P6Type"] = "float"
#//////////////////////////////////////////////////////////////////////
#TFtdcREAL10P4Type是一个十点四实型类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcREAL10P4Type"] = "float"
#//////////////////////////////////////////////////////////////////////
#TFtdcREAL16P2Type是一个十六点二实型类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcREAL16P2Type"] = "float"
#//////////////////////////////////////////////////////////////////////
#TFtdcREAL16P8Type是一个十六点八实型类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcREAL16P8Type"] = "float"
#//////////////////////////////////////////////////////////////////////
#TFtdcREAL22P2Type是一个二十二点二实型类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcREAL22P2Type"] = "float"
#//////////////////////////////////////////////////////////////////////
#TFtdcCommandNoType是一个DB命令序号类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcCommandNoType"] = "int"
#//////////////////////////////////////////////////////////////////////
#TFtdcCommandTypeType是一个DB命令类型类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcCommandTypeType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcSettlementGroupIDType是一个结算组代码类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcSettlementGroupIDType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcFieldNameType是一个字段名类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcFieldNameType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcFieldContentType是一个字段内容类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcFieldContentType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcBankIDType是一个银行代码类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcBankIDType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcBankNameType是一个银行名称类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcBankNameType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcBankBrchIDType是一个银行分中心代码类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcBankBrchIDType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcLiberSerialType是一个Liber系统流水号类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcLiberSerialType"] = "int"
#//////////////////////////////////////////////////////////////////////
#TFtdcRoleIDType是一个角色编号类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcRoleIDType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcRoleNameType是一个角色名称类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcRoleNameType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcDescriptionType是一个描述类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcDescriptionType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcFunctionIDType是一个功能代码类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcFunctionIDType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcBillNoType是一个票据号类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcBillNoType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcFundIOTypeType是一个出入金类型类型
#//////////////////////////////////////////////////////////////////////
#出入金
defineDict["SECURITY_FTDC_FIOT_FundIO"] = '1'
#银期转帐
defineDict["SECURITY_FTDC_FIOT_Transfer"] = '2'
typedefDict["TSecurityFtdcFundIOTypeType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcFundTypeType是一个资金类型类型
#//////////////////////////////////////////////////////////////////////
#银行存款
defineDict["SECURITY_FTDC_FT_Deposite"] = '1'
#分项资金
defineDict["SECURITY_FTDC_FT_ItemFund"] = '2'
#公司调整
defineDict["SECURITY_FTDC_FT_Company"] = '3'
typedefDict["TSecurityFtdcFundTypeType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcFundDirectionType是一个出入金方向类型
#//////////////////////////////////////////////////////////////////////
#入金
defineDict["SECURITY_FTDC_FD_In"] = '1'
#出金
defineDict["SECURITY_FTDC_FD_Out"] = '2'
typedefDict["TSecurityFtdcFundDirectionType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcBankFlagType是一个银行统一标识类型类型
#//////////////////////////////////////////////////////////////////////
#工商银行
defineDict["SECURITY_FTDC_BF_ICBC"] = '1'
#农业银行
defineDict["SECURITY_FTDC_BF_ABC"] = '2'
#中国银行
defineDict["SECURITY_FTDC_BF_BC"] = '3'
#建设银行
defineDict["SECURITY_FTDC_BF_CBC"] = '4'
#交通银行
defineDict["SECURITY_FTDC_BF_BOC"] = '5'
#其他银行
defineDict["SECURITY_FTDC_BF_Other"] = 'Z'
typedefDict["TSecurityFtdcBankFlagType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcOperationMemoType是一个操作摘要类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcOperationMemoType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcFundStatusType是一个资金状态类型
#//////////////////////////////////////////////////////////////////////
#已录入
defineDict["SECURITY_FTDC_FS_Record"] = '1'
#已复核
defineDict["SECURITY_FTDC_FS_Check"] = '2'
#已冲销
defineDict["SECURITY_FTDC_FS_Charge"] = '3'
typedefDict["TSecurityFtdcFundStatusType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcFundProjectIDType是一个资金项目编号类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcFundProjectIDType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcOperatorIDType是一个操作员代码类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcOperatorIDType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcCounterIDType是一个计数器代码类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcCounterIDType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcFunctionNameType是一个功能名称类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcFunctionNameType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcTradeCodeType是一个交易代码类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcTradeCodeType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcBrokerBranchIDType是一个经纪公司分支机构代码类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcBrokerBranchIDType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcTradeDateType是一个交易日期类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcTradeDateType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcTradeTimeType是一个交易时间类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcTradeTimeType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcBankSerialType是一个银行流水号类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcBankSerialType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcSerialType是一个流水号类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcSerialType"] = "int"
#//////////////////////////////////////////////////////////////////////
#TFtdcLastFragmentType是一个最后分片标志类型
#//////////////////////////////////////////////////////////////////////
#是最后分片
defineDict["SECURITY_FTDC_LF_Yes"] = '0'
#不是最后分片
defineDict["SECURITY_FTDC_LF_No"] = '1'
typedefDict["TSecurityFtdcLastFragmentType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcIndividualNameType是一个个人姓名类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcIndividualNameType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcCustTypeType是一个客户类型类型
#//////////////////////////////////////////////////////////////////////
#自然人
defineDict["SECURITY_FTDC_CUSTT_Person"] = '0'
#机构户
defineDict["SECURITY_FTDC_CUSTT_Institution"] = '1'
typedefDict["TSecurityFtdcCustTypeType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcBankAccountType是一个银行账户类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcBankAccountType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcYesNoIndicatorType是一个是或否标识类型
#//////////////////////////////////////////////////////////////////////
#是
defineDict["SECURITY_FTDC_YNI_Yes"] = '0'
#否
defineDict["SECURITY_FTDC_YNI_No"] = '1'
typedefDict["TSecurityFtdcYesNoIndicatorType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcTradeAmountType是一个交易金额(元)类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcTradeAmountType"] = "float"
#//////////////////////////////////////////////////////////////////////
#TFtdcCustFeeType是一个应收客户费用(元)类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcCustFeeType"] = "float"
#//////////////////////////////////////////////////////////////////////
#TFtdcBrokerFeeType是一个应收经纪公司费用(元)类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcBrokerFeeType"] = "float"
#//////////////////////////////////////////////////////////////////////
#TFtdcFeePayFlagType是一个费用支付标志类型
#//////////////////////////////////////////////////////////////////////
#由受益方支付费用
defineDict["SECURITY_FTDC_FPF_BEN"] = '0'
#由发送方支付费用
defineDict["SECURITY_FTDC_FPF_OUR"] = '1'
#由发送方支付发起的费用,受益方支付接受的费用
defineDict["SECURITY_FTDC_FPF_SHA"] = '2'
typedefDict["TSecurityFtdcFeePayFlagType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcAddInfoType是一个附加信息类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcAddInfoType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcDigestType是一个摘要类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcDigestType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcBankAccTypeType是一个银行帐号类型类型
#//////////////////////////////////////////////////////////////////////
#银行存折
defineDict["SECURITY_FTDC_BAT_BankBook"] = '1'
#储蓄卡
defineDict["SECURITY_FTDC_BAT_SavingCard"] = '2'
#信用卡
defineDict["SECURITY_FTDC_BAT_CreditCard"] = '3'
typedefDict["TSecurityFtdcBankAccTypeType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcDeviceIDType是一个渠道标志类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcDeviceIDType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcPwdFlagType是一个密码核对标志类型
#//////////////////////////////////////////////////////////////////////
#不核对
defineDict["SECURITY_FTDC_BPWDF_NoCheck"] = '0'
#明文核对
defineDict["SECURITY_FTDC_BPWDF_BlankCheck"] = '1'
#密文核对
defineDict["SECURITY_FTDC_BPWDF_EncryptCheck"] = '2'
typedefDict["TSecurityFtdcPwdFlagType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcBankCodingForBrokerType是一个银行对经纪公司的编码类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcBankCodingForBrokerType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcOperNoType是一个交易柜员类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcOperNoType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcTIDType是一个交易ID类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcTIDType"] = "int"
#//////////////////////////////////////////////////////////////////////
#TFtdcTransferStatusType是一个转账交易状态类型
#//////////////////////////////////////////////////////////////////////
#正常
defineDict["SECURITY_FTDC_TRFS_Normal"] = '0'
#被冲正
defineDict["SECURITY_FTDC_TRFS_Repealed"] = '1'
typedefDict["TSecurityFtdcTransferStatusType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcPlateSerialType是一个平台流水号类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcPlateSerialType"] = "int"
#//////////////////////////////////////////////////////////////////////
#TFtdcAvailabilityFlagType是一个有效标志类型
#//////////////////////////////////////////////////////////////////////
#未确认
defineDict["SECURITY_FTDC_AVAF_Invalid"] = '0'
#有效
defineDict["SECURITY_FTDC_AVAF_Valid"] = '1'
#冲正
defineDict["SECURITY_FTDC_AVAF_Repeal"] = '2'
typedefDict["TSecurityFtdcAvailabilityFlagType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcOperatorCodeType是一个操作员类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcOperatorCodeType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcRepayStockAlgoType是一个买券还券算法类型
#//////////////////////////////////////////////////////////////////////
#默认算法
defineDict["SECURITY_FTDC_RSA_Original"] = '0'
#按还券比例计算
defineDict["SECURITY_FTDC_RSA_Ratio"] = '1'
#Min[1,2]
defineDict["SECURITY_FTDC_RSA_Min"] = '2'
typedefDict["TSecurityFtdcRepayStockAlgoType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcTradeSpanType是一个交易时间段类型类型
#//////////////////////////////////////////////////////////////////////
#普通业务
defineDict["SECURITY_FTDC_TS_Common"] = '1'
#个股期权
defineDict["SECURITY_FTDC_TS_Options"] = '2'
typedefDict["TSecurityFtdcTradeSpanType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcSettleSystemTypeType是一个所属结算系统类型类型
#//////////////////////////////////////////////////////////////////////
#顶点系统
defineDict["SECURITY_FTDC_SST_Aboss"] = '1'
#恒生系统
defineDict["SECURITY_FTDC_SST_HS"] = '2'
typedefDict["TSecurityFtdcSettleSystemTypeType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcLogLevelType是一个日志级别类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcLogLevelType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcProcessNameType是一个存储过程名称类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcProcessNameType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcTemplateIDType是一个模板代码类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcTemplateIDType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcTradeIndexType是一个成交序号类型
#//////////////////////////////////////////////////////////////////////
typedefDict["TSecurityFtdcTradeIndexType"] = "int"
#//////////////////////////////////////////////////////////////////////
#TFtdcSplitMergeStatusType是一个基金当天拆分合并状态类型
#//////////////////////////////////////////////////////////////////////
#表示允许拆分和合并
defineDict["SECURITY_FTDC_SMS_Allow"] = '0'
#允许拆分、不允许合并
defineDict["SECURITY_FTDC_SMS_OnlySplit"] = '1'
#不允许拆分、允许合并
defineDict["SECURITY_FTDC_SMS_OnlyMerge"] = '2'
#不允许拆分和合并
defineDict["SECURITY_FTDC_SMS_Forbidden"] = '3'
typedefDict["TSecurityFtdcSplitMergeStatusType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcFundInterTransferTypeType是一个资金内转类型类型
#//////////////////////////////////////////////////////////////////////
#转入
defineDict["SECURITY_FTDC_FITT_TransferIn"] = '0'
#转出
defineDict["SECURITY_FTDC_FITT_TransferOut"] = '1'
typedefDict["TSecurityFtdcFundInterTransferTypeType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcInstrumentTypeType是一个合约类型类型
#//////////////////////////////////////////////////////////////////////
#普通
defineDict["SECURITY_FTDC_IT_Normal"] = '0'
#看涨期权
defineDict["SECURITY_FTDC_IT_CallOptions"] = '1'
#看跌期权
defineDict["SECURITY_FTDC_IT_PutOptions"] = '2'
typedefDict["TSecurityFtdcInstrumentTypeType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcInvestorLevelType是一个投资者期权交易等级类型
#//////////////////////////////////////////////////////////////////////
#一级
defineDict["SECURITY_FTDC_IL_Level_1"] = '0'
#二级
defineDict["SECURITY_FTDC_IL_Level_2"] = '1'
#三级
defineDict["SECURITY_FTDC_IL_Level_3"] = '2'
typedefDict["TSecurityFtdcInvestorLevelType"] = "string"
#//////////////////////////////////////////////////////////////////////
#TFtdcCloseDirectionType是一个平仓方向类型
#//////////////////////////////////////////////////////////////////////
#买平仓
defineDict["SECURITY_FTDC_CD_CloseBuy"] = '!'
#卖平仓
defineDict["SECURITY_FTDC_CD_CloseSell"] = '@'
#备兑平仓
defineDict["SECURITY_FTDC_CD_CloseCover"] = '#'
typedefDict["TSecurityFtdcCloseDirectionType"] = "string"
|
mit
|
[
3,
2644,
26,
9094,
13,
24,
199,
199,
9830,
275,
1052,
199,
12729,
275,
1052,
199,
199,
8426,
199,
17577,
4627,
1033,
621,
17945,
1212,
605,
2556,
21580,
1849,
2020,
44,
2076,
199,
17577,
493,
13863,
4974,
1899,
7394,
23516,
14,
72,
199,
17577,
19127,
7094,
107,
249,
17837,
232,
4344,
249,
30521,
22730,
10278,
199,
8426,
4388,
199,
8426,
199,
3,
13034,
547,
998,
13077,
32064,
10635,
10278,
199,
8426,
199,
12729,
905,
27887,
547,
998,
804,
937,
275,
298,
442,
2,
199,
199,
8426,
199,
3,
13034,
547,
6173,
13077,
32064,
27328,
10278,
199,
8426,
199,
12729,
905,
27887,
547,
6173,
804,
937,
275,
298,
875,
2,
199,
199,
8426,
199,
3,
13034,
13188,
998,
13077,
22202,
10635,
10278,
199,
8426,
199,
12729,
905,
27887,
13188,
998,
804,
937,
275,
298,
875,
2,
199,
199,
8426,
199,
3,
13034,
13188,
985,
13077,
22202,
21434,
19012,
109,
10278,
199,
8426,
199,
12729,
905,
27887,
13188,
985,
804,
937,
275,
298,
875,
2,
199,
199,
8426,
199,
3,
13034,
13188,
3697,
13077,
22202,
27289,
253,
17182,
101,
10278,
199,
8426,
199,
3,
17627,
97,
15280,
117,
199,
9830,
905,
13554,
63,
8797,
63,
11992,
63,
6241,
937,
275,
283,
16,
7,
199,
3,
13750,
118,
20466,
16888,
11112,
29319,
16888,
27908,
199,
9830,
905,
13554,
63,
8797,
63,
11992,
63,
8168,
4738,
2175,
17529,
937,
275,
283,
17,
7,
199,
199,
12729,
905,
27887,
13188,
3697,
804,
937,
275,
298,
875,
2,
199,
199,
8426,
199,
3,
13034,
13188,
8631,
3694,
13077,
22202,
13201,
253,
24586,
30729,
10278,
199,
8426,
199,
3,
163,
111,
95,
20916,
5498,
120,
11046,
244,
13201,
253,
24586,
199,
9830,
905,
13554,
63,
8797,
63,
37,
3298,
63,
1944,
3225,
937,
275,
283,
17,
7,
199,
3,
28913,
20134,
26835,
22914,
24778,
25421,
25977,
32281,
199,
9830,
905,
13554,
63,
8797,
63,
37,
3298,
63,
18697,
14915,
17367,
937,
275,
283,
18,
7,
199,
3,
28913,
20134,
165,
237,
116,
22924,
27328,
199,
9830,
905,
13554,
63,
8797,
63,
37,
3298,
63,
13662,
4935,
937,
275,
283,
25,
7,
199,
199,
12729,
905,
27887,
13188,
8631,
3694,
804,
937,
275,
298,
875,
2,
199,
199,
8426,
199,
3,
13034,
2506,
13077,
31502,
10278,
199,
8426,
199,
12729,
905,
27887,
2506,
804,
937,
275,
298,
875,
2,
199,
199,
8426,
199,
3,
13034,
1366,
13077,
27381,
10278,
199,
8426,
199,
12729,
905,
27887,
1366,
804,
937,
275,
298,
875,
2,
199,
199,
8426,
199,
3,
13034,
14915,
998,
13077,
24778,
10635,
10278,
199,
8426,
199,
12729,
905,
27887,
14915,
998,
804,
937,
275,
298,
875,
2,
199,
199,
8426,
199,
3,
13034,
5884,
985,
13077,
6923,
101,
32531,
21434,
19012,
109,
10278,
199,
8426,
199,
12729,
905,
27887,
5884,
985,
804,
937,
275,
298,
875,
2,
199,
199,
8426,
199,
3,
13034,
5884,
2543,
13077,
6923,
101,
32531,
10278,
10278,
199,
8426,
199,
3,
31350,
199,
9830,
905,
13554,
63,
8797,
63,
4222,
63,
38,
16249,
937,
275,
283,
17,
7,
199,
3,
14152,
31038,
199,
9830,
905,
13554,
63,
8797,
63,
4222,
63,
4558,
937,
275,
283,
18,
7,
199,
3,
32061,
16803,
199,
9830,
905,
13554,
63,
8797,
63,
4222,
63,
17039,
425,
937,
275,
283,
19,
7,
199,
3,
10450,
112,
14152,
199,
9830,
905,
13554,
63,
8797,
63,
4222,
63,
5058,
357,
937,
275,
283,
20,
7,
199,
3,
14152,
30229,
23434,
109,
199,
9830,
905,
13554,
63,
8797,
63,
4222,
63,
14153,
48,
937,
275,
283,
21,
7,
199,
3,
20886,
9051,
117,
33,
165,
225,
95,
199,
9830,
905,
13554,
63,
8797,
63,
4222,
63,
17103,
33,
937,
275,
283,
22,
7,
199,
3,
20886,
9051,
117,
34,
165,
225,
95,
199,
9830,
905,
13554,
63,
8797,
63,
4222,
63,
17103,
34,
937,
275,
283,
23,
7,
199,
3,
775,
38,
199,
9830,
905,
13554,
63,
8797,
63,
4222,
63,
775,
38,
937,
275,
283,
24,
7,
199,
3,
775,
38,
8383,
112,
14096,
237,
199,
9830,
905,
13554,
63,
8797,
63,
4222,
63,
775,
38,
14959,
10858,
937,
275,
283,
25,
7,
199,
199,
12729,
905,
27887,
5884,
31165,
937,
275,
298,
875,
2,
199,
199,
8426,
199,
3,
13034,
6464,
8433,
13077,
24778,
12211,
22485,
17837,
247,
12211,
10278,
199,
8426,
199,
12729,
905,
27887,
6464,
8433,
804,
937,
275,
298,
442,
2,
199,
199,
8426,
199,
3,
13034,
11826,
13077,
18608,
13750,
121,
10278,
199,
8426,
199,
12729,
905,
27887,
11826,
804,
937,
275,
298,
1609,
2,
199,
199,
8426,
199,
3,
13034,
6464,
13077,
12211,
22485,
10278,
199,
8426,
199,
12729,
905,
27887,
6464,
804,
937,
275,
298,
442,
2,
199,
199,
8426,
199,
3,
13034,
5625,
804,
13077,
32743,
24079,
10278,
10278,
199,
8426,
199,
3,
15977,
223,
32743,
24079,
199,
9830,
905,
13554,
63,
8797,
63,
4189,
63,
2480,
937,
275,
283,
17,
7,
199,
3,
9360,
121,
16803,
32743,
24079,
199,
9830,
905,
13554,
63,
8797,
63,
4189,
63,
39,
3685,
937,
275,
283,
18,
7,
199,
199,
12729,
905,
27887,
5625,
804,
804,
937,
275,
298,
875,
2,
199,
199,
8426,
199,
3,
13034,
5625,
2506,
804,
13077,
32743,
24079,
31502,
10278,
10278,
199,
8426,
199,
3,
30026,
29708,
229,
6075,
111,
32743,
24079,
199,
9830,
905,
13554,
63,
8797,
63,
48,
7438,
63,
6119,
12114,
937,
275,
283,
17,
7,
199,
3,
19594,
30026,
29708,
229,
6075,
111,
32743,
24079,
199,
9830,
905,
13554,
63,
8797,
63,
48,
7438,
63,
1944,
6119,
12114,
937,
275,
283,
18,
7,
199,
199,
12729,
905,
27887,
5625,
2506,
804,
804,
937,
275,
298,
875,
2,
199,
199,
8426,
199,
3,
13034,
13188,
10083,
998,
13077,
24778,
21448,
22202,
8106,
10635,
10278,
199,
8426,
199,
12729,
905,
27887,
13188,
10083,
998,
804,
937,
275,
298,
875,
2,
199,
199,
8426,
199,
3,
13034,
15731,
13077,
16322,
113,
5498,
122,
10278,
199,
8426,
199,
12729,
905,
27887,
15731,
804,
937,
275,
298,
442,
2,
199,
199,
8426,
199,
3,
13034,
14306,
13077,
31452,
5498,
122,
10278,
199,
8426,
199,
12729,
905,
27887,
14306,
804,
937,
275,
298,
442,
2,
199,
199,
8426,
199,
3,
13034,
10083,
22637,
10521,
13077,
24778,
29319,
19580,
122,
19580,
102,
14152,
30729,
10278,
199,
8426
] |
[
2644,
26,
9094,
13,
24,
199,
199,
9830,
275,
1052,
199,
12729,
275,
1052,
199,
199,
8426,
199,
17577,
4627,
1033,
621,
17945,
1212,
605,
2556,
21580,
1849,
2020,
44,
2076,
199,
17577,
493,
13863,
4974,
1899,
7394,
23516,
14,
72,
199,
17577,
19127,
7094,
107,
249,
17837,
232,
4344,
249,
30521,
22730,
10278,
199,
8426,
4388,
199,
8426,
199,
3,
13034,
547,
998,
13077,
32064,
10635,
10278,
199,
8426,
199,
12729,
905,
27887,
547,
998,
804,
937,
275,
298,
442,
2,
199,
199,
8426,
199,
3,
13034,
547,
6173,
13077,
32064,
27328,
10278,
199,
8426,
199,
12729,
905,
27887,
547,
6173,
804,
937,
275,
298,
875,
2,
199,
199,
8426,
199,
3,
13034,
13188,
998,
13077,
22202,
10635,
10278,
199,
8426,
199,
12729,
905,
27887,
13188,
998,
804,
937,
275,
298,
875,
2,
199,
199,
8426,
199,
3,
13034,
13188,
985,
13077,
22202,
21434,
19012,
109,
10278,
199,
8426,
199,
12729,
905,
27887,
13188,
985,
804,
937,
275,
298,
875,
2,
199,
199,
8426,
199,
3,
13034,
13188,
3697,
13077,
22202,
27289,
253,
17182,
101,
10278,
199,
8426,
199,
3,
17627,
97,
15280,
117,
199,
9830,
905,
13554,
63,
8797,
63,
11992,
63,
6241,
937,
275,
283,
16,
7,
199,
3,
13750,
118,
20466,
16888,
11112,
29319,
16888,
27908,
199,
9830,
905,
13554,
63,
8797,
63,
11992,
63,
8168,
4738,
2175,
17529,
937,
275,
283,
17,
7,
199,
199,
12729,
905,
27887,
13188,
3697,
804,
937,
275,
298,
875,
2,
199,
199,
8426,
199,
3,
13034,
13188,
8631,
3694,
13077,
22202,
13201,
253,
24586,
30729,
10278,
199,
8426,
199,
3,
163,
111,
95,
20916,
5498,
120,
11046,
244,
13201,
253,
24586,
199,
9830,
905,
13554,
63,
8797,
63,
37,
3298,
63,
1944,
3225,
937,
275,
283,
17,
7,
199,
3,
28913,
20134,
26835,
22914,
24778,
25421,
25977,
32281,
199,
9830,
905,
13554,
63,
8797,
63,
37,
3298,
63,
18697,
14915,
17367,
937,
275,
283,
18,
7,
199,
3,
28913,
20134,
165,
237,
116,
22924,
27328,
199,
9830,
905,
13554,
63,
8797,
63,
37,
3298,
63,
13662,
4935,
937,
275,
283,
25,
7,
199,
199,
12729,
905,
27887,
13188,
8631,
3694,
804,
937,
275,
298,
875,
2,
199,
199,
8426,
199,
3,
13034,
2506,
13077,
31502,
10278,
199,
8426,
199,
12729,
905,
27887,
2506,
804,
937,
275,
298,
875,
2,
199,
199,
8426,
199,
3,
13034,
1366,
13077,
27381,
10278,
199,
8426,
199,
12729,
905,
27887,
1366,
804,
937,
275,
298,
875,
2,
199,
199,
8426,
199,
3,
13034,
14915,
998,
13077,
24778,
10635,
10278,
199,
8426,
199,
12729,
905,
27887,
14915,
998,
804,
937,
275,
298,
875,
2,
199,
199,
8426,
199,
3,
13034,
5884,
985,
13077,
6923,
101,
32531,
21434,
19012,
109,
10278,
199,
8426,
199,
12729,
905,
27887,
5884,
985,
804,
937,
275,
298,
875,
2,
199,
199,
8426,
199,
3,
13034,
5884,
2543,
13077,
6923,
101,
32531,
10278,
10278,
199,
8426,
199,
3,
31350,
199,
9830,
905,
13554,
63,
8797,
63,
4222,
63,
38,
16249,
937,
275,
283,
17,
7,
199,
3,
14152,
31038,
199,
9830,
905,
13554,
63,
8797,
63,
4222,
63,
4558,
937,
275,
283,
18,
7,
199,
3,
32061,
16803,
199,
9830,
905,
13554,
63,
8797,
63,
4222,
63,
17039,
425,
937,
275,
283,
19,
7,
199,
3,
10450,
112,
14152,
199,
9830,
905,
13554,
63,
8797,
63,
4222,
63,
5058,
357,
937,
275,
283,
20,
7,
199,
3,
14152,
30229,
23434,
109,
199,
9830,
905,
13554,
63,
8797,
63,
4222,
63,
14153,
48,
937,
275,
283,
21,
7,
199,
3,
20886,
9051,
117,
33,
165,
225,
95,
199,
9830,
905,
13554,
63,
8797,
63,
4222,
63,
17103,
33,
937,
275,
283,
22,
7,
199,
3,
20886,
9051,
117,
34,
165,
225,
95,
199,
9830,
905,
13554,
63,
8797,
63,
4222,
63,
17103,
34,
937,
275,
283,
23,
7,
199,
3,
775,
38,
199,
9830,
905,
13554,
63,
8797,
63,
4222,
63,
775,
38,
937,
275,
283,
24,
7,
199,
3,
775,
38,
8383,
112,
14096,
237,
199,
9830,
905,
13554,
63,
8797,
63,
4222,
63,
775,
38,
14959,
10858,
937,
275,
283,
25,
7,
199,
199,
12729,
905,
27887,
5884,
31165,
937,
275,
298,
875,
2,
199,
199,
8426,
199,
3,
13034,
6464,
8433,
13077,
24778,
12211,
22485,
17837,
247,
12211,
10278,
199,
8426,
199,
12729,
905,
27887,
6464,
8433,
804,
937,
275,
298,
442,
2,
199,
199,
8426,
199,
3,
13034,
11826,
13077,
18608,
13750,
121,
10278,
199,
8426,
199,
12729,
905,
27887,
11826,
804,
937,
275,
298,
1609,
2,
199,
199,
8426,
199,
3,
13034,
6464,
13077,
12211,
22485,
10278,
199,
8426,
199,
12729,
905,
27887,
6464,
804,
937,
275,
298,
442,
2,
199,
199,
8426,
199,
3,
13034,
5625,
804,
13077,
32743,
24079,
10278,
10278,
199,
8426,
199,
3,
15977,
223,
32743,
24079,
199,
9830,
905,
13554,
63,
8797,
63,
4189,
63,
2480,
937,
275,
283,
17,
7,
199,
3,
9360,
121,
16803,
32743,
24079,
199,
9830,
905,
13554,
63,
8797,
63,
4189,
63,
39,
3685,
937,
275,
283,
18,
7,
199,
199,
12729,
905,
27887,
5625,
804,
804,
937,
275,
298,
875,
2,
199,
199,
8426,
199,
3,
13034,
5625,
2506,
804,
13077,
32743,
24079,
31502,
10278,
10278,
199,
8426,
199,
3,
30026,
29708,
229,
6075,
111,
32743,
24079,
199,
9830,
905,
13554,
63,
8797,
63,
48,
7438,
63,
6119,
12114,
937,
275,
283,
17,
7,
199,
3,
19594,
30026,
29708,
229,
6075,
111,
32743,
24079,
199,
9830,
905,
13554,
63,
8797,
63,
48,
7438,
63,
1944,
6119,
12114,
937,
275,
283,
18,
7,
199,
199,
12729,
905,
27887,
5625,
2506,
804,
804,
937,
275,
298,
875,
2,
199,
199,
8426,
199,
3,
13034,
13188,
10083,
998,
13077,
24778,
21448,
22202,
8106,
10635,
10278,
199,
8426,
199,
12729,
905,
27887,
13188,
10083,
998,
804,
937,
275,
298,
875,
2,
199,
199,
8426,
199,
3,
13034,
15731,
13077,
16322,
113,
5498,
122,
10278,
199,
8426,
199,
12729,
905,
27887,
15731,
804,
937,
275,
298,
442,
2,
199,
199,
8426,
199,
3,
13034,
14306,
13077,
31452,
5498,
122,
10278,
199,
8426,
199,
12729,
905,
27887,
14306,
804,
937,
275,
298,
442,
2,
199,
199,
8426,
199,
3,
13034,
10083,
22637,
10521,
13077,
24778,
29319,
19580,
122,
19580,
102,
14152,
30729,
10278,
199,
8426,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
elky/django
|
django/contrib/contenttypes/forms.py
|
21
|
3557
|
from django.contrib.contenttypes.models import ContentType
from django.db import models
from django.forms import ModelForm, modelformset_factory
from django.forms.models import BaseModelFormSet
class BaseGenericInlineFormSet(BaseModelFormSet):
"""
A formset for generic inline objects to a parent.
"""
def __init__(self, data=None, files=None, instance=None, save_as_new=None,
prefix=None, queryset=None, **kwargs):
opts = self.model._meta
self.instance = instance
self.rel_name = (
opts.app_label + '-' + opts.model_name + '-' +
self.ct_field.name + '-' + self.ct_fk_field.name
)
if self.instance is None or self.instance.pk is None:
qs = self.model._default_manager.none()
else:
if queryset is None:
queryset = self.model._default_manager
qs = queryset.filter(**{
self.ct_field.name: ContentType.objects.get_for_model(
self.instance, for_concrete_model=self.for_concrete_model),
self.ct_fk_field.name: self.instance.pk,
})
super().__init__(queryset=qs, data=data, files=files, prefix=prefix, **kwargs)
@classmethod
def get_default_prefix(cls):
opts = cls.model._meta
return (
opts.app_label + '-' + opts.model_name + '-' +
cls.ct_field.name + '-' + cls.ct_fk_field.name
)
def save_new(self, form, commit=True):
setattr(form.instance, self.ct_field.get_attname(), ContentType.objects.get_for_model(self.instance).pk)
setattr(form.instance, self.ct_fk_field.get_attname(), self.instance.pk)
return form.save(commit=commit)
def generic_inlineformset_factory(model, form=ModelForm,
formset=BaseGenericInlineFormSet,
ct_field="content_type", fk_field="object_id",
fields=None, exclude=None,
extra=3, can_order=False, can_delete=True,
max_num=None, formfield_callback=None,
validate_max=False, for_concrete_model=True,
min_num=None, validate_min=False):
"""
Return a ``GenericInlineFormSet`` for the given kwargs.
You must provide ``ct_field`` and ``fk_field`` if they are different from
the defaults ``content_type`` and ``object_id`` respectively.
"""
opts = model._meta
# if there is no field called `ct_field` let the exception propagate
ct_field = opts.get_field(ct_field)
if not isinstance(ct_field, models.ForeignKey) or ct_field.remote_field.model != ContentType:
raise Exception("fk_name '%s' is not a ForeignKey to ContentType" % ct_field)
fk_field = opts.get_field(fk_field) # let the exception propagate
if exclude is not None:
exclude = list(exclude)
exclude.extend([ct_field.name, fk_field.name])
else:
exclude = [ct_field.name, fk_field.name]
FormSet = modelformset_factory(
model, form=form, formfield_callback=formfield_callback,
formset=formset, extra=extra, can_delete=can_delete,
can_order=can_order, fields=fields, exclude=exclude, max_num=max_num,
validate_max=validate_max, min_num=min_num, validate_min=validate_min,
)
FormSet.ct_field = ct_field
FormSet.ct_fk_field = fk_field
FormSet.for_concrete_model = for_concrete_model
return FormSet
|
bsd-3-clause
|
[
504,
1639,
14,
2828,
14,
10778,
14,
992,
492,
14501,
199,
504,
1639,
14,
697,
492,
1709,
199,
504,
1639,
14,
3351,
492,
28455,
12,
29312,
409,
63,
3702,
199,
504,
1639,
14,
3351,
14,
992,
492,
3523,
1685,
14736,
421,
199,
533,
3523,
9417,
10307,
14736,
8,
27687,
14736,
304,
272,
408,
272,
437,
11068,
367,
7809,
8308,
2251,
370,
282,
1676,
14,
272,
408,
339,
347,
636,
826,
721,
277,
12,
666,
29,
403,
12,
1584,
29,
403,
12,
1256,
29,
403,
12,
3354,
63,
305,
63,
1222,
29,
403,
12,
326,
2403,
29,
403,
12,
7594,
29,
403,
12,
1011,
958,
304,
267,
3999,
275,
291,
14,
1238,
423,
2024,
267,
291,
14,
842,
275,
1256,
267,
291,
14,
3369,
63,
354,
275,
334,
288,
3999,
14,
571,
63,
1302,
435,
10791,
435,
3999,
14,
1238,
63,
354,
435,
10791,
435,
288,
291,
14,
319,
63,
698,
14,
354,
435,
10791,
435,
291,
14,
319,
63,
9010,
63,
698,
14,
354,
267,
776,
267,
340,
291,
14,
842,
365,
488,
503,
291,
14,
842,
14,
2051,
365,
488,
26,
288,
6377,
275,
291,
14,
1238,
423,
885,
63,
2609,
14,
3592,
342,
267,
587,
26,
288,
340,
7594,
365,
488,
26,
355,
7594,
275,
291,
14,
1238,
423,
885,
63,
2609,
288,
6377,
275,
7594,
14,
1541,
25679,
355,
291,
14,
319,
63,
698,
14,
354,
26,
14501,
14,
1462,
14,
362,
63,
509,
63,
1238,
8,
490,
291,
14,
842,
12,
367,
63,
13455,
63,
1238,
29,
277,
14,
509,
63,
13455,
63,
1238,
395,
355,
291,
14,
319,
63,
9010,
63,
698,
14,
354,
26,
291,
14,
842,
14,
2051,
12,
288,
3828,
267,
1613,
11027,
826,
721,
7924,
29,
6177,
12,
666,
29,
576,
12,
1584,
29,
1725,
12,
2403,
29,
1861,
12,
1011,
958,
9,
339,
768,
3744,
272,
347,
664,
63,
885,
63,
1861,
8,
1886,
304,
267,
3999,
275,
843,
14,
1238,
423,
2024,
267,
372,
334,
288,
3999,
14,
571,
63,
1302,
435,
10791,
435,
3999,
14,
1238,
63,
354,
435,
10791,
435,
288,
843,
14,
319,
63,
698,
14,
354,
435,
10791,
435,
843,
14,
319,
63,
9010,
63,
698,
14,
354,
267,
776,
339,
347,
3354,
63,
1222,
8,
277,
12,
1824,
12,
5532,
29,
549,
304,
267,
5371,
8,
964,
14,
842,
12,
291,
14,
319,
63,
698,
14,
362,
63,
13651,
1062,
14501,
14,
1462,
14,
362,
63,
509,
63,
1238,
8,
277,
14,
842,
680,
2051,
9,
267,
5371,
8,
964,
14,
842,
12,
291,
14,
319,
63,
9010,
63,
698,
14,
362,
63,
13651,
1062,
291,
14,
842,
14,
2051,
9,
267,
372,
1824,
14,
2117,
8,
3543,
29,
3543,
9,
421,
199,
318,
7809,
63,
6460,
10724,
63,
3702,
8,
1238,
12,
1824,
29,
15937,
12,
3303,
11068,
29,
1563,
9417,
10307,
14736,
12,
3303,
9428,
63,
698,
628,
1317,
63,
466,
401,
14830,
63,
698,
628,
785,
63,
344,
401,
3303,
1504,
29,
403,
12,
5760,
29,
403,
12,
3303,
2402,
29,
19,
12,
883,
63,
1648,
29,
797,
12,
883,
63,
1807,
29,
549,
12,
3303,
1390,
63,
1507,
29,
403,
12,
21388,
63,
3058,
29,
403,
12,
3303,
4107,
63,
988,
29,
797,
12,
367,
63,
13455,
63,
1238,
29,
549,
12,
3303,
1748,
63,
1507,
29,
403,
12,
4107,
63,
827,
29,
797,
304,
272,
408,
272,
1432,
282,
1124,
9417,
10307,
14736,
1040,
367,
314,
1627,
2074,
14,
339,
2047,
1471,
5647,
1124,
319,
63,
698,
1040,
436,
1124,
9010,
63,
698,
1040,
340,
2985,
787,
3365,
687,
272,
314,
4243,
1124,
1317,
63,
466,
1040,
436,
1124,
785,
63,
344,
1040,
17342,
14,
272,
408,
272,
3999,
275,
1402,
423,
2024,
272,
327,
340,
2337,
365,
949,
901,
2797,
658,
319,
63,
698,
64,
4691,
314,
1919,
19843,
272,
9428,
63,
698,
275,
3999,
14,
362,
63,
698,
8,
319,
63,
698,
9,
272,
340,
440,
1228,
8,
319,
63,
698,
12,
1709,
14,
3190,
9,
503,
9428,
63,
698,
14,
3846,
63,
698,
14,
1238,
1137,
14501,
26,
267,
746,
2186,
480,
9010,
63,
354,
1543,
83,
7,
365,
440,
282,
12718,
370,
14501,
2,
450,
9428,
63,
698,
9,
272,
14830,
63,
698,
275,
3999,
14,
362,
63,
698,
8,
9010,
63,
698,
9,
221,
327,
4691,
314,
1919,
19843,
272,
340,
5760,
365,
440,
488,
26,
267,
5760,
275,
769,
8,
5473,
9,
267,
5760,
14,
2880,
779,
319,
63,
698,
14,
354,
12,
14830,
63,
698,
14,
354,
566,
272,
587,
26,
267,
5760,
275,
359,
319,
63,
698,
14,
354,
12,
14830,
63,
698,
14,
354,
61,
272,
25260,
275,
29312,
409,
63,
3702,
8,
267,
1402,
12,
1824,
29,
964,
12,
21388,
63,
3058,
29,
20015,
63,
3058,
12,
267,
11068,
29,
10724,
12,
2402,
29,
2911,
12,
883,
63,
1807,
29,
2425,
63,
1807,
12,
267,
883,
63,
1648,
29,
2425,
63,
1648,
12,
1504,
29,
955,
12,
5760,
29,
5473,
12,
1390,
63,
1507,
29,
988,
63,
1507,
12,
267,
4107,
63,
988,
29,
3502,
63,
988,
12,
1748,
63,
1507,
29,
827,
63,
1507,
12,
4107,
63,
827,
29,
3502,
63,
827,
12,
272,
776,
272,
25260,
14,
319,
63,
698,
275,
9428,
63,
698,
272,
25260,
14,
319,
63,
9010,
63,
698,
275,
14830,
63,
698,
272,
25260,
14,
509,
63,
13455,
63,
1238,
275,
367,
63,
13455,
63,
1238,
272,
372,
25260,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
1639,
14,
2828,
14,
10778,
14,
992,
492,
14501,
199,
504,
1639,
14,
697,
492,
1709,
199,
504,
1639,
14,
3351,
492,
28455,
12,
29312,
409,
63,
3702,
199,
504,
1639,
14,
3351,
14,
992,
492,
3523,
1685,
14736,
421,
199,
533,
3523,
9417,
10307,
14736,
8,
27687,
14736,
304,
272,
408,
272,
437,
11068,
367,
7809,
8308,
2251,
370,
282,
1676,
14,
272,
408,
339,
347,
636,
826,
721,
277,
12,
666,
29,
403,
12,
1584,
29,
403,
12,
1256,
29,
403,
12,
3354,
63,
305,
63,
1222,
29,
403,
12,
326,
2403,
29,
403,
12,
7594,
29,
403,
12,
1011,
958,
304,
267,
3999,
275,
291,
14,
1238,
423,
2024,
267,
291,
14,
842,
275,
1256,
267,
291,
14,
3369,
63,
354,
275,
334,
288,
3999,
14,
571,
63,
1302,
435,
10791,
435,
3999,
14,
1238,
63,
354,
435,
10791,
435,
288,
291,
14,
319,
63,
698,
14,
354,
435,
10791,
435,
291,
14,
319,
63,
9010,
63,
698,
14,
354,
267,
776,
267,
340,
291,
14,
842,
365,
488,
503,
291,
14,
842,
14,
2051,
365,
488,
26,
288,
6377,
275,
291,
14,
1238,
423,
885,
63,
2609,
14,
3592,
342,
267,
587,
26,
288,
340,
7594,
365,
488,
26,
355,
7594,
275,
291,
14,
1238,
423,
885,
63,
2609,
288,
6377,
275,
7594,
14,
1541,
25679,
355,
291,
14,
319,
63,
698,
14,
354,
26,
14501,
14,
1462,
14,
362,
63,
509,
63,
1238,
8,
490,
291,
14,
842,
12,
367,
63,
13455,
63,
1238,
29,
277,
14,
509,
63,
13455,
63,
1238,
395,
355,
291,
14,
319,
63,
9010,
63,
698,
14,
354,
26,
291,
14,
842,
14,
2051,
12,
288,
3828,
267,
1613,
11027,
826,
721,
7924,
29,
6177,
12,
666,
29,
576,
12,
1584,
29,
1725,
12,
2403,
29,
1861,
12,
1011,
958,
9,
339,
768,
3744,
272,
347,
664,
63,
885,
63,
1861,
8,
1886,
304,
267,
3999,
275,
843,
14,
1238,
423,
2024,
267,
372,
334,
288,
3999,
14,
571,
63,
1302,
435,
10791,
435,
3999,
14,
1238,
63,
354,
435,
10791,
435,
288,
843,
14,
319,
63,
698,
14,
354,
435,
10791,
435,
843,
14,
319,
63,
9010,
63,
698,
14,
354,
267,
776,
339,
347,
3354,
63,
1222,
8,
277,
12,
1824,
12,
5532,
29,
549,
304,
267,
5371,
8,
964,
14,
842,
12,
291,
14,
319,
63,
698,
14,
362,
63,
13651,
1062,
14501,
14,
1462,
14,
362,
63,
509,
63,
1238,
8,
277,
14,
842,
680,
2051,
9,
267,
5371,
8,
964,
14,
842,
12,
291,
14,
319,
63,
9010,
63,
698,
14,
362,
63,
13651,
1062,
291,
14,
842,
14,
2051,
9,
267,
372,
1824,
14,
2117,
8,
3543,
29,
3543,
9,
421,
199,
318,
7809,
63,
6460,
10724,
63,
3702,
8,
1238,
12,
1824,
29,
15937,
12,
3303,
11068,
29,
1563,
9417,
10307,
14736,
12,
3303,
9428,
63,
698,
628,
1317,
63,
466,
401,
14830,
63,
698,
628,
785,
63,
344,
401,
3303,
1504,
29,
403,
12,
5760,
29,
403,
12,
3303,
2402,
29,
19,
12,
883,
63,
1648,
29,
797,
12,
883,
63,
1807,
29,
549,
12,
3303,
1390,
63,
1507,
29,
403,
12,
21388,
63,
3058,
29,
403,
12,
3303,
4107,
63,
988,
29,
797,
12,
367,
63,
13455,
63,
1238,
29,
549,
12,
3303,
1748,
63,
1507,
29,
403,
12,
4107,
63,
827,
29,
797,
304,
272,
408,
272,
1432,
282,
1124,
9417,
10307,
14736,
1040,
367,
314,
1627,
2074,
14,
339,
2047,
1471,
5647,
1124,
319,
63,
698,
1040,
436,
1124,
9010,
63,
698,
1040,
340,
2985,
787,
3365,
687,
272,
314,
4243,
1124,
1317,
63,
466,
1040,
436,
1124,
785,
63,
344,
1040,
17342,
14,
272,
408,
272,
3999,
275,
1402,
423,
2024,
272,
327,
340,
2337,
365,
949,
901,
2797,
658,
319,
63,
698,
64,
4691,
314,
1919,
19843,
272,
9428,
63,
698,
275,
3999,
14,
362,
63,
698,
8,
319,
63,
698,
9,
272,
340,
440,
1228,
8,
319,
63,
698,
12,
1709,
14,
3190,
9,
503,
9428,
63,
698,
14,
3846,
63,
698,
14,
1238,
1137,
14501,
26,
267,
746,
2186,
480,
9010,
63,
354,
1543,
83,
7,
365,
440,
282,
12718,
370,
14501,
2,
450,
9428,
63,
698,
9,
272,
14830,
63,
698,
275,
3999,
14,
362,
63,
698,
8,
9010,
63,
698,
9,
221,
327,
4691,
314,
1919,
19843,
272,
340,
5760,
365,
440,
488,
26,
267,
5760,
275,
769,
8,
5473,
9,
267,
5760,
14,
2880,
779,
319,
63,
698,
14,
354,
12,
14830,
63,
698,
14,
354,
566,
272,
587,
26,
267,
5760,
275,
359,
319,
63,
698,
14,
354,
12,
14830,
63,
698,
14,
354,
61,
272,
25260,
275,
29312,
409,
63,
3702,
8,
267,
1402,
12,
1824,
29,
964,
12,
21388,
63,
3058,
29,
20015,
63,
3058,
12,
267,
11068,
29,
10724,
12,
2402,
29,
2911,
12,
883,
63,
1807,
29,
2425,
63,
1807,
12,
267,
883,
63,
1648,
29,
2425,
63,
1648,
12,
1504,
29,
955,
12,
5760,
29,
5473,
12,
1390,
63,
1507,
29,
988,
63,
1507,
12,
267,
4107,
63,
988,
29,
3502,
63,
988,
12,
1748,
63,
1507,
29,
827,
63,
1507,
12,
4107,
63,
827,
29,
3502,
63,
827,
12,
272,
776,
272,
25260,
14,
319,
63,
698,
275,
9428,
63,
698,
272,
25260,
14,
319,
63,
9010,
63,
698,
275,
14830,
63,
698,
272,
25260,
14,
509,
63,
13455,
63,
1238,
275,
367,
63,
13455,
63,
1238,
272,
372,
25260,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
meraki-analytics/merakicommons
|
tests/test_cache.py
|
2
|
2104
|
import pytest
from merakicommons.cache import lazy_property, Cache
TEST_VALUE_1 = "TEST VALUE_1"
TEST_VALUE_2 = "TEST_VALUE_2"
VALUE_COUNT = 100
class LazyProperty(object):
def __init__(self, value) -> None:
self.property_calls = 0
self.value = value
@lazy_property
def property(self) -> str:
self.property_calls += 1
return self.value
def test_lazy_property_type():
assert type(LazyProperty.property) is property
def test_lazy_property_value():
x = LazyProperty(TEST_VALUE_1)
y = LazyProperty(TEST_VALUE_2)
for _ in range(VALUE_COUNT):
value = x.property
assert type(value) is type(TEST_VALUE_1)
assert value == TEST_VALUE_1
value = y.property
assert type(value) is type(TEST_VALUE_2)
assert value == TEST_VALUE_2
def test_lazy_property_loading():
x = LazyProperty(TEST_VALUE_1)
y = LazyProperty(TEST_VALUE_2)
assert x.property_calls == 0
assert y.property_calls == 0
for _ in range(VALUE_COUNT):
x.property
y.property
assert x.property_calls == 1
assert y.property_calls == 1
#########
# Cache #
#########
def test_cache_simple():
x = Cache()
assert not x.contains(int, "test")
assert not x.contains(int, 1)
x.put(int, "test", 1)
assert x.contains(int, "test")
assert not x.contains(int, 1)
# x[1] = "test"
x.put(str, 1, "test")
assert x.contains(int, "test")
assert x.contains(str, 1)
assert x.get(str, 1) == "test"
assert x.get(int, "test") == 1
with pytest.raises(KeyError):
x.get(int, 2)
def test_cache_delete():
x = Cache()
x.put(int, "test", 1)
assert x.contains(int, "test")
assert x.get(int, "test") == 1
x.put(str, 1, "test")
assert x.contains(str, 1)
assert x.get(str, 1) == "test"
x.delete(int, "test")
assert not x.contains(int, "test")
with pytest.raises(KeyError):
x.get(int, "test")
x.delete(str, 1)
assert not x.contains(str, 1)
with pytest.raises(KeyError):
x.get(str, 1)
|
mit
|
[
646,
4613,
199,
199,
504,
23477,
2330,
83,
14,
1637,
492,
9617,
63,
1829,
12,
11977,
199,
199,
2864,
63,
7041,
63,
17,
275,
298,
2864,
21170,
63,
17,
2,
199,
2864,
63,
7041,
63,
18,
275,
298,
2864,
63,
7041,
63,
18,
2,
199,
7041,
63,
8760,
275,
2948,
421,
199,
533,
22373,
3697,
8,
785,
304,
272,
347,
636,
826,
721,
277,
12,
574,
9,
1035,
488,
26,
267,
291,
14,
1829,
63,
5352,
275,
378,
267,
291,
14,
585,
275,
574,
339,
768,
6395,
63,
1829,
272,
347,
3324,
8,
277,
9,
1035,
620,
26,
267,
291,
14,
1829,
63,
5352,
847,
413,
267,
372,
291,
14,
585,
421,
199,
318,
511,
63,
6395,
63,
1829,
63,
466,
837,
272,
702,
730,
8,
14269,
3697,
14,
1829,
9,
365,
3324,
421,
199,
318,
511,
63,
6395,
63,
1829,
63,
585,
837,
272,
671,
275,
22373,
3697,
8,
2864,
63,
7041,
63,
17,
9,
272,
612,
275,
22373,
3697,
8,
2864,
63,
7041,
63,
18,
9,
272,
367,
485,
315,
1425,
8,
7041,
63,
8760,
304,
267,
574,
275,
671,
14,
1829,
267,
702,
730,
8,
585,
9,
365,
730,
8,
2864,
63,
7041,
63,
17,
9,
267,
702,
574,
508,
7393,
63,
7041,
63,
17,
398,
574,
275,
612,
14,
1829,
267,
702,
730,
8,
585,
9,
365,
730,
8,
2864,
63,
7041,
63,
18,
9,
267,
702,
574,
508,
7393,
63,
7041,
63,
18,
421,
199,
318,
511,
63,
6395,
63,
1829,
63,
8786,
837,
272,
671,
275,
22373,
3697,
8,
2864,
63,
7041,
63,
17,
9,
272,
612,
275,
22373,
3697,
8,
2864,
63,
7041,
63,
18,
9,
272,
702,
671,
14,
1829,
63,
5352,
508,
378,
272,
702,
612,
14,
1829,
63,
5352,
508,
378,
272,
367,
485,
315,
1425,
8,
7041,
63,
8760,
304,
267,
671,
14,
1829,
267,
612,
14,
1829,
267,
702,
671,
14,
1829,
63,
5352,
508,
413,
267,
702,
612,
14,
1829,
63,
5352,
508,
413,
421,
199,
516,
3,
199,
3,
11977,
327,
199,
516,
3,
199,
199,
318,
511,
63,
1637,
63,
4129,
837,
272,
671,
275,
11977,
342,
272,
702,
440,
671,
14,
6134,
8,
442,
12,
298,
396,
531,
272,
702,
440,
671,
14,
6134,
8,
442,
12,
413,
9,
339,
671,
14,
524,
8,
442,
12,
298,
396,
401,
413,
9,
272,
702,
671,
14,
6134,
8,
442,
12,
298,
396,
531,
272,
702,
440,
671,
14,
6134,
8,
442,
12,
413,
9,
339,
327,
671,
59,
17,
61,
275,
298,
396,
2,
272,
671,
14,
524,
8,
495,
12,
413,
12,
298,
396,
531,
272,
702,
671,
14,
6134,
8,
442,
12,
298,
396,
531,
272,
702,
671,
14,
6134,
8,
495,
12,
413,
9,
339,
702,
671,
14,
362,
8,
495,
12,
413,
9,
508,
298,
396,
2,
272,
702,
671,
14,
362,
8,
442,
12,
298,
396,
531,
508,
413,
339,
543,
4613,
14,
3536,
8,
10230,
304,
267,
671,
14,
362,
8,
442,
12,
499,
9,
421,
199,
318,
511,
63,
1637,
63,
1807,
837,
272,
671,
275,
11977,
342,
339,
671,
14,
524,
8,
442,
12,
298,
396,
401,
413,
9,
272,
702,
671,
14,
6134,
8,
442,
12,
298,
396,
531,
272,
702,
671,
14,
362,
8,
442,
12,
298,
396,
531,
508,
413,
339,
671,
14,
524,
8,
495,
12,
413,
12,
298,
396,
531,
272,
702,
671,
14,
6134,
8,
495,
12,
413,
9,
272,
702,
671,
14,
362,
8,
495,
12,
413,
9,
508,
298,
396,
2,
339,
671,
14,
1807,
8,
442,
12,
298,
396,
531,
272,
702,
440,
671,
14,
6134,
8,
442,
12,
298,
396,
531,
272,
543,
4613,
14,
3536,
8,
10230,
304,
267,
671,
14,
362,
8,
442,
12,
298,
396,
531,
339,
671,
14,
1807,
8,
495,
12,
413,
9,
272,
702,
440,
671,
14,
6134,
8,
495,
12,
413,
9,
272,
543,
4613,
14,
3536,
8,
10230,
304,
267,
671,
14,
362,
8,
495,
12,
413,
9,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
4613,
199,
199,
504,
23477,
2330,
83,
14,
1637,
492,
9617,
63,
1829,
12,
11977,
199,
199,
2864,
63,
7041,
63,
17,
275,
298,
2864,
21170,
63,
17,
2,
199,
2864,
63,
7041,
63,
18,
275,
298,
2864,
63,
7041,
63,
18,
2,
199,
7041,
63,
8760,
275,
2948,
421,
199,
533,
22373,
3697,
8,
785,
304,
272,
347,
636,
826,
721,
277,
12,
574,
9,
1035,
488,
26,
267,
291,
14,
1829,
63,
5352,
275,
378,
267,
291,
14,
585,
275,
574,
339,
768,
6395,
63,
1829,
272,
347,
3324,
8,
277,
9,
1035,
620,
26,
267,
291,
14,
1829,
63,
5352,
847,
413,
267,
372,
291,
14,
585,
421,
199,
318,
511,
63,
6395,
63,
1829,
63,
466,
837,
272,
702,
730,
8,
14269,
3697,
14,
1829,
9,
365,
3324,
421,
199,
318,
511,
63,
6395,
63,
1829,
63,
585,
837,
272,
671,
275,
22373,
3697,
8,
2864,
63,
7041,
63,
17,
9,
272,
612,
275,
22373,
3697,
8,
2864,
63,
7041,
63,
18,
9,
272,
367,
485,
315,
1425,
8,
7041,
63,
8760,
304,
267,
574,
275,
671,
14,
1829,
267,
702,
730,
8,
585,
9,
365,
730,
8,
2864,
63,
7041,
63,
17,
9,
267,
702,
574,
508,
7393,
63,
7041,
63,
17,
398,
574,
275,
612,
14,
1829,
267,
702,
730,
8,
585,
9,
365,
730,
8,
2864,
63,
7041,
63,
18,
9,
267,
702,
574,
508,
7393,
63,
7041,
63,
18,
421,
199,
318,
511,
63,
6395,
63,
1829,
63,
8786,
837,
272,
671,
275,
22373,
3697,
8,
2864,
63,
7041,
63,
17,
9,
272,
612,
275,
22373,
3697,
8,
2864,
63,
7041,
63,
18,
9,
272,
702,
671,
14,
1829,
63,
5352,
508,
378,
272,
702,
612,
14,
1829,
63,
5352,
508,
378,
272,
367,
485,
315,
1425,
8,
7041,
63,
8760,
304,
267,
671,
14,
1829,
267,
612,
14,
1829,
267,
702,
671,
14,
1829,
63,
5352,
508,
413,
267,
702,
612,
14,
1829,
63,
5352,
508,
413,
421,
199,
516,
3,
199,
3,
11977,
327,
199,
516,
3,
199,
199,
318,
511,
63,
1637,
63,
4129,
837,
272,
671,
275,
11977,
342,
272,
702,
440,
671,
14,
6134,
8,
442,
12,
298,
396,
531,
272,
702,
440,
671,
14,
6134,
8,
442,
12,
413,
9,
339,
671,
14,
524,
8,
442,
12,
298,
396,
401,
413,
9,
272,
702,
671,
14,
6134,
8,
442,
12,
298,
396,
531,
272,
702,
440,
671,
14,
6134,
8,
442,
12,
413,
9,
339,
327,
671,
59,
17,
61,
275,
298,
396,
2,
272,
671,
14,
524,
8,
495,
12,
413,
12,
298,
396,
531,
272,
702,
671,
14,
6134,
8,
442,
12,
298,
396,
531,
272,
702,
671,
14,
6134,
8,
495,
12,
413,
9,
339,
702,
671,
14,
362,
8,
495,
12,
413,
9,
508,
298,
396,
2,
272,
702,
671,
14,
362,
8,
442,
12,
298,
396,
531,
508,
413,
339,
543,
4613,
14,
3536,
8,
10230,
304,
267,
671,
14,
362,
8,
442,
12,
499,
9,
421,
199,
318,
511,
63,
1637,
63,
1807,
837,
272,
671,
275,
11977,
342,
339,
671,
14,
524,
8,
442,
12,
298,
396,
401,
413,
9,
272,
702,
671,
14,
6134,
8,
442,
12,
298,
396,
531,
272,
702,
671,
14,
362,
8,
442,
12,
298,
396,
531,
508,
413,
339,
671,
14,
524,
8,
495,
12,
413,
12,
298,
396,
531,
272,
702,
671,
14,
6134,
8,
495,
12,
413,
9,
272,
702,
671,
14,
362,
8,
495,
12,
413,
9,
508,
298,
396,
2,
339,
671,
14,
1807,
8,
442,
12,
298,
396,
531,
272,
702,
440,
671,
14,
6134,
8,
442,
12,
298,
396,
531,
272,
543,
4613,
14,
3536,
8,
10230,
304,
267,
671,
14,
362,
8,
442,
12,
298,
396,
531,
339,
671,
14,
1807,
8,
495,
12,
413,
9,
272,
702,
440,
671,
14,
6134,
8,
495,
12,
413,
9,
272,
543,
4613,
14,
3536,
8,
10230,
304,
267,
671,
14,
362,
8,
495,
12,
413,
9,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
JetBrains/intellij-community
|
platform/platform-resources/src/launcher.py
|
10
|
4104
|
#!/usr/bin/env $PYTHON$
# Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
import os
import socket
import struct
import sys
import traceback
# See com.intellij.idea.SocketLock for the server side of this interface.
RUN_PATH = u'$RUN_PATH$'
CONFIG_PATH = u'$CONFIG_PATH$'
SYSTEM_PATH = u'$SYSTEM_PATH$'
def print_usage(cmd):
print(('Usage:\n' +
' {0} -h | -? | --help\n' +
' {0} [project_dir] [-w|--wait]\n' +
' {0} [-l|--line line] [project_dir|--temp-project] [-w|--wait] file[:line]\n' +
' {0} diff <left> <right>\n' +
' {0} merge <local> <remote> [base] <merged>').format(cmd))
def write_to_sock(sock, data):
if sys.version_info[0] >= 3:
data = data.encode('utf-8')
sock.send(struct.pack('>h', len(data)) + data)
def read_from_sock(sock):
length = struct.unpack('>h', sock.recv(2))[0]
return sock.recv(length).decode('utf-8')
def read_sequence_from_sock(sock):
result = []
while True:
try:
data = read_from_sock(sock)
if data == '---':
break
result.append(data)
except (socket.error, IOError) as e:
print("I/O error({0}): {1} ({2})".format(e.errno, e.strerror, e))
traceback.print_exception(*sys.exc_info())
break
return result
def process_args(argv):
args = []
skip_next = False
for i, arg in enumerate(argv[1:]):
if arg == '-h' or arg == '-?' or arg == '--help':
print_usage(argv[0])
exit(0)
elif i == 0 and (arg == 'diff' or arg == 'merge' or arg == '--temp-project'):
args.append(arg)
elif arg == '-l' or arg == '--line':
args.append(arg)
skip_next = True
elif arg == '-w' or arg == '--wait':
args.append('--wait')
elif arg == '-p' or arg == '--project':
args.append(arg)
elif arg == '-e' or arg == '--edit':
args.append(arg)
elif skip_next:
args.append(arg)
skip_next = False
else:
path = arg
if ':' in arg:
file_path, line_number = arg.rsplit(':', 1)
if line_number.isdigit():
args.append('-l')
args.append(line_number)
path = file_path
args.append(os.path.abspath(path))
return args
def try_activate_instance(args):
port_path = os.path.join(CONFIG_PATH, 'port')
token_path = os.path.join(SYSTEM_PATH, 'token')
if not (os.path.exists(port_path) and os.path.exists(token_path)):
return False
try:
with open(port_path) as pf:
port = int(pf.read())
with open(token_path) as tf:
token = tf.read()
except ValueError:
return False
s = socket.socket()
s.settimeout(1.0)
try:
s.connect(('127.0.0.1', port))
except (socket.error, IOError):
return False
paths = read_sequence_from_sock(s)
found = CONFIG_PATH in paths or os.path.realpath(CONFIG_PATH) in paths
if found:
write_to_sock(s, 'activate ' + token + '\0' + os.getcwd() + '\0' + '\0'.join(args))
s.settimeout(None)
response = read_sequence_from_sock(s)
if len(response) < 2 or response[0] != 'ok':
print('bad response: ' + str(response))
exit(1)
if len(response) > 2:
print(response[2])
exit(int(response[1]))
return False
def start_new_instance(args):
if sys.platform == 'darwin':
if len(args) > 0:
args.insert(0, '--args')
if '--wait' in args:
args.insert(0, '-W')
os.execv('/usr/bin/open', ['open', '-na', RUN_PATH] + args)
else:
bin_file = os.path.split(RUN_PATH)[1]
os.execv(RUN_PATH, [bin_file] + args)
ide_args = process_args(sys.argv)
if not try_activate_instance(ide_args):
start_new_instance(ide_args)
|
apache-2.0
|
[
3381,
2647,
15,
1393,
15,
1813,
2672,
11720,
4,
199,
3,
221,
1898,
12293,
13,
13934,
1603,
386,
17171,
3617,
308,
14,
82,
14,
79,
14,
3645,
402,
642,
1350,
1233,
365,
10413,
701,
314,
3668,
499,
14,
16,
4190,
626,
883,
506,
1911,
315,
314,
5113,
570,
14,
199,
199,
646,
747,
199,
646,
2838,
199,
646,
2702,
199,
646,
984,
199,
646,
5190,
199,
199,
3,
1666,
2414,
14,
5707,
13876,
74,
14,
2655,
65,
14,
3869,
6432,
367,
314,
1654,
5366,
402,
642,
3217,
14,
199,
199,
9390,
63,
3243,
275,
399,
7,
4,
9390,
63,
3243,
12913,
199,
5569,
63,
3243,
275,
399,
7,
4,
5569,
63,
3243,
12913,
199,
12711,
63,
3243,
275,
399,
7,
4,
12711,
63,
3243,
12913,
421,
199,
318,
870,
63,
3807,
8,
1760,
304,
272,
870,
4725,
7692,
3427,
78,
7,
435,
1779,
283,
221,
469,
16,
93,
446,
72,
1204,
446,
31,
1204,
1553,
3437,
60,
78,
7,
435,
1779,
283,
221,
469,
16,
93,
359,
1715,
63,
694,
61,
5243,
87,
92,
306,
2573,
7272,
78,
7,
435,
1779,
283,
221,
469,
16,
93,
5243,
76,
92,
306,
604,
1004,
61,
359,
1715,
63,
694,
92,
306,
808,
13,
1715,
61,
5243,
87,
92,
306,
2573,
61,
570,
1491,
604,
7272,
78,
7,
435,
1779,
283,
221,
469,
16,
93,
3915,
665,
3039,
30,
665,
1019,
3072,
78,
7,
435,
1779,
283,
221,
469,
16,
93,
5389,
665,
1832,
30,
665,
3846,
30,
359,
1095,
61,
665,
15269,
30,
1959,
908,
8,
1760,
430,
421,
199,
318,
2218,
63,
475,
63,
5096,
8,
5096,
12,
666,
304,
272,
340,
984,
14,
1023,
63,
815,
59,
16,
61,
2356,
650,
26,
267,
666,
275,
666,
14,
2143,
360,
1624,
13,
24,
358,
272,
6771,
14,
2254,
8,
1820,
14,
1389,
16099,
72,
297,
822,
8,
576,
430,
435,
666,
9,
421,
199,
318,
1586,
63,
504,
63,
5096,
8,
5096,
304,
272,
2582,
275,
2702,
14,
5301,
16099,
72,
297,
6771,
14,
7637,
8,
18,
11515,
16,
61,
272,
372,
6771,
14,
7637,
8,
1267,
680,
2708,
360,
1624,
13,
24,
358,
421,
199,
318,
1586,
63,
4041,
63,
504,
63,
5096,
8,
5096,
304,
272,
754,
275,
942,
272,
1830,
715,
26,
267,
862,
26,
288,
666,
275,
1586,
63,
504,
63,
5096,
8,
5096,
9,
288,
340,
666,
508,
283,
2595,
356,
355,
2059,
288,
754,
14,
740,
8,
576,
9,
267,
871,
334,
3450,
14,
705,
12,
5925,
9,
465,
325,
26,
288,
870,
480,
41,
15,
47,
1125,
2561,
16,
22558,
469,
17,
93,
11459,
18,
25974,
908,
8,
69,
14,
7931,
12,
325,
14,
20395,
12,
325,
430,
288,
5190,
14,
1361,
63,
1971,
2031,
1274,
14,
2804,
63,
815,
1012,
288,
2059,
272,
372,
754,
421,
199,
318,
2112,
63,
589,
8,
3020,
304,
272,
1249,
275,
942,
339,
3372,
63,
2184,
275,
756,
272,
367,
284,
12,
1680,
315,
3874,
8,
3020,
59,
17,
28847,
267,
340,
1680,
508,
2475,
72,
7,
503,
1680,
508,
2475,
14069,
503,
1680,
508,
2850,
3437,
356,
288,
870,
63,
3807,
8,
3020,
59,
16,
566,
288,
4458,
8,
16,
9,
267,
916,
284,
508,
378,
436,
334,
1273,
508,
283,
3028,
7,
503,
1680,
508,
283,
5628,
7,
503,
1680,
508,
2850,
808,
13,
1715,
735,
288,
1249,
14,
740,
8,
1273,
9,
267,
916,
1680,
508,
2475,
76,
7,
503,
1680,
508,
2850,
604,
356,
288,
1249,
14,
740,
8,
1273,
9,
288,
3372,
63,
2184,
275,
715,
267,
916,
1680,
508,
2475,
87,
7,
503,
1680,
508,
2850,
2573,
356,
288,
1249,
14,
740,
4517,
2573,
358,
267,
916,
1680,
508,
2475,
80,
7,
503,
1680,
508,
2850,
1715,
356,
288,
1249,
14,
740,
8,
1273,
9,
267,
916,
1680,
508,
2475,
69,
7,
503,
1680,
508,
2850,
3773,
356,
288,
1249,
14,
740,
8,
1273,
9,
267,
916,
3372,
63,
2184,
26,
288,
1249,
14,
740,
8,
1273,
9,
288,
3372,
63,
2184,
275,
756,
267,
587,
26,
288,
931,
275,
1680,
288,
340,
10871,
315,
1680,
26,
355,
570,
63,
515,
12,
1004,
63,
1955,
275,
1680,
14,
13490,
16451,
413,
9,
355,
340,
1004,
63,
1955,
14,
13896,
837,
490,
1249,
14,
740,
3654,
76,
358,
490,
1249,
14,
740,
8,
604,
63,
1955,
9,
490,
931,
275,
570,
63,
515,
288,
1249,
14,
740,
8,
736,
14,
515,
14,
4832,
8,
515,
430,
339,
372,
1249,
421,
199,
318,
862,
63,
8222,
63,
842,
8,
589,
304,
272,
1844,
63,
515,
275,
747,
14,
515,
14,
904,
8,
5569,
63,
3243,
12,
283,
719,
358,
272,
1526,
63,
515,
275,
747,
14,
515,
14,
904,
8,
12711,
63,
3243,
12,
283,
1418,
358,
272,
340,
440,
334,
736,
14,
515,
14,
2444,
8,
719,
63,
515,
9,
436,
747,
14,
515,
14,
2444,
8,
1418,
63,
515,
2298,
267,
372,
756,
339,
862,
26,
267,
543,
1551,
8,
719,
63,
515,
9,
465,
18258,
26,
288,
1844,
275,
1109,
8,
9928,
14,
739,
1012,
267,
543,
1551,
8,
1418,
63,
515,
9,
465,
2833,
26,
288,
1526,
275,
2833,
14,
739,
342,
272,
871,
1722,
26,
267,
372,
756,
339,
308,
275,
2838,
14,
3450,
342,
272,
308,
14,
24630,
8,
17,
14,
16,
9,
272,
862,
26,
267,
308,
14,
2242,
4725,
4195,
14,
16,
14,
16,
14,
17,
297,
1844,
430,
272,
871,
334,
3450,
14,
705,
12,
5925,
304,
267,
372,
756,
339,
3792,
275,
1586,
63,
4041,
63,
504,
63,
5096,
8,
83,
9,
272,
1911,
275,
15869,
63,
3243,
315,
3792,
503,
747,
14,
515,
14,
11091,
8,
5569,
63,
3243,
9,
315,
3792,
339,
340,
1911,
26,
267,
2218,
63,
475,
63,
5096,
8,
83,
12,
283,
8222,
283,
435,
1526,
435,
1557,
16,
7,
435,
747,
14,
9458,
342,
435,
1557,
16,
7,
435,
1557,
16,
1370,
904,
8,
589,
430,
398,
308,
14,
24630,
8,
403,
9,
267,
1177,
275,
1586,
63,
4041,
63,
504,
63,
5096,
8,
83,
9,
267,
340,
822,
8,
1310,
9,
665,
499,
503,
1177,
59,
16,
61,
1137,
283,
745,
356,
288,
870,
360,
4087,
1177,
26,
283,
435
] |
[
2647,
15,
1393,
15,
1813,
2672,
11720,
4,
199,
3,
221,
1898,
12293,
13,
13934,
1603,
386,
17171,
3617,
308,
14,
82,
14,
79,
14,
3645,
402,
642,
1350,
1233,
365,
10413,
701,
314,
3668,
499,
14,
16,
4190,
626,
883,
506,
1911,
315,
314,
5113,
570,
14,
199,
199,
646,
747,
199,
646,
2838,
199,
646,
2702,
199,
646,
984,
199,
646,
5190,
199,
199,
3,
1666,
2414,
14,
5707,
13876,
74,
14,
2655,
65,
14,
3869,
6432,
367,
314,
1654,
5366,
402,
642,
3217,
14,
199,
199,
9390,
63,
3243,
275,
399,
7,
4,
9390,
63,
3243,
12913,
199,
5569,
63,
3243,
275,
399,
7,
4,
5569,
63,
3243,
12913,
199,
12711,
63,
3243,
275,
399,
7,
4,
12711,
63,
3243,
12913,
421,
199,
318,
870,
63,
3807,
8,
1760,
304,
272,
870,
4725,
7692,
3427,
78,
7,
435,
1779,
283,
221,
469,
16,
93,
446,
72,
1204,
446,
31,
1204,
1553,
3437,
60,
78,
7,
435,
1779,
283,
221,
469,
16,
93,
359,
1715,
63,
694,
61,
5243,
87,
92,
306,
2573,
7272,
78,
7,
435,
1779,
283,
221,
469,
16,
93,
5243,
76,
92,
306,
604,
1004,
61,
359,
1715,
63,
694,
92,
306,
808,
13,
1715,
61,
5243,
87,
92,
306,
2573,
61,
570,
1491,
604,
7272,
78,
7,
435,
1779,
283,
221,
469,
16,
93,
3915,
665,
3039,
30,
665,
1019,
3072,
78,
7,
435,
1779,
283,
221,
469,
16,
93,
5389,
665,
1832,
30,
665,
3846,
30,
359,
1095,
61,
665,
15269,
30,
1959,
908,
8,
1760,
430,
421,
199,
318,
2218,
63,
475,
63,
5096,
8,
5096,
12,
666,
304,
272,
340,
984,
14,
1023,
63,
815,
59,
16,
61,
2356,
650,
26,
267,
666,
275,
666,
14,
2143,
360,
1624,
13,
24,
358,
272,
6771,
14,
2254,
8,
1820,
14,
1389,
16099,
72,
297,
822,
8,
576,
430,
435,
666,
9,
421,
199,
318,
1586,
63,
504,
63,
5096,
8,
5096,
304,
272,
2582,
275,
2702,
14,
5301,
16099,
72,
297,
6771,
14,
7637,
8,
18,
11515,
16,
61,
272,
372,
6771,
14,
7637,
8,
1267,
680,
2708,
360,
1624,
13,
24,
358,
421,
199,
318,
1586,
63,
4041,
63,
504,
63,
5096,
8,
5096,
304,
272,
754,
275,
942,
272,
1830,
715,
26,
267,
862,
26,
288,
666,
275,
1586,
63,
504,
63,
5096,
8,
5096,
9,
288,
340,
666,
508,
283,
2595,
356,
355,
2059,
288,
754,
14,
740,
8,
576,
9,
267,
871,
334,
3450,
14,
705,
12,
5925,
9,
465,
325,
26,
288,
870,
480,
41,
15,
47,
1125,
2561,
16,
22558,
469,
17,
93,
11459,
18,
25974,
908,
8,
69,
14,
7931,
12,
325,
14,
20395,
12,
325,
430,
288,
5190,
14,
1361,
63,
1971,
2031,
1274,
14,
2804,
63,
815,
1012,
288,
2059,
272,
372,
754,
421,
199,
318,
2112,
63,
589,
8,
3020,
304,
272,
1249,
275,
942,
339,
3372,
63,
2184,
275,
756,
272,
367,
284,
12,
1680,
315,
3874,
8,
3020,
59,
17,
28847,
267,
340,
1680,
508,
2475,
72,
7,
503,
1680,
508,
2475,
14069,
503,
1680,
508,
2850,
3437,
356,
288,
870,
63,
3807,
8,
3020,
59,
16,
566,
288,
4458,
8,
16,
9,
267,
916,
284,
508,
378,
436,
334,
1273,
508,
283,
3028,
7,
503,
1680,
508,
283,
5628,
7,
503,
1680,
508,
2850,
808,
13,
1715,
735,
288,
1249,
14,
740,
8,
1273,
9,
267,
916,
1680,
508,
2475,
76,
7,
503,
1680,
508,
2850,
604,
356,
288,
1249,
14,
740,
8,
1273,
9,
288,
3372,
63,
2184,
275,
715,
267,
916,
1680,
508,
2475,
87,
7,
503,
1680,
508,
2850,
2573,
356,
288,
1249,
14,
740,
4517,
2573,
358,
267,
916,
1680,
508,
2475,
80,
7,
503,
1680,
508,
2850,
1715,
356,
288,
1249,
14,
740,
8,
1273,
9,
267,
916,
1680,
508,
2475,
69,
7,
503,
1680,
508,
2850,
3773,
356,
288,
1249,
14,
740,
8,
1273,
9,
267,
916,
3372,
63,
2184,
26,
288,
1249,
14,
740,
8,
1273,
9,
288,
3372,
63,
2184,
275,
756,
267,
587,
26,
288,
931,
275,
1680,
288,
340,
10871,
315,
1680,
26,
355,
570,
63,
515,
12,
1004,
63,
1955,
275,
1680,
14,
13490,
16451,
413,
9,
355,
340,
1004,
63,
1955,
14,
13896,
837,
490,
1249,
14,
740,
3654,
76,
358,
490,
1249,
14,
740,
8,
604,
63,
1955,
9,
490,
931,
275,
570,
63,
515,
288,
1249,
14,
740,
8,
736,
14,
515,
14,
4832,
8,
515,
430,
339,
372,
1249,
421,
199,
318,
862,
63,
8222,
63,
842,
8,
589,
304,
272,
1844,
63,
515,
275,
747,
14,
515,
14,
904,
8,
5569,
63,
3243,
12,
283,
719,
358,
272,
1526,
63,
515,
275,
747,
14,
515,
14,
904,
8,
12711,
63,
3243,
12,
283,
1418,
358,
272,
340,
440,
334,
736,
14,
515,
14,
2444,
8,
719,
63,
515,
9,
436,
747,
14,
515,
14,
2444,
8,
1418,
63,
515,
2298,
267,
372,
756,
339,
862,
26,
267,
543,
1551,
8,
719,
63,
515,
9,
465,
18258,
26,
288,
1844,
275,
1109,
8,
9928,
14,
739,
1012,
267,
543,
1551,
8,
1418,
63,
515,
9,
465,
2833,
26,
288,
1526,
275,
2833,
14,
739,
342,
272,
871,
1722,
26,
267,
372,
756,
339,
308,
275,
2838,
14,
3450,
342,
272,
308,
14,
24630,
8,
17,
14,
16,
9,
272,
862,
26,
267,
308,
14,
2242,
4725,
4195,
14,
16,
14,
16,
14,
17,
297,
1844,
430,
272,
871,
334,
3450,
14,
705,
12,
5925,
304,
267,
372,
756,
339,
3792,
275,
1586,
63,
4041,
63,
504,
63,
5096,
8,
83,
9,
272,
1911,
275,
15869,
63,
3243,
315,
3792,
503,
747,
14,
515,
14,
11091,
8,
5569,
63,
3243,
9,
315,
3792,
339,
340,
1911,
26,
267,
2218,
63,
475,
63,
5096,
8,
83,
12,
283,
8222,
283,
435,
1526,
435,
1557,
16,
7,
435,
747,
14,
9458,
342,
435,
1557,
16,
7,
435,
1557,
16,
1370,
904,
8,
589,
430,
398,
308,
14,
24630,
8,
403,
9,
267,
1177,
275,
1586,
63,
4041,
63,
504,
63,
5096,
8,
83,
9,
267,
340,
822,
8,
1310,
9,
665,
499,
503,
1177,
59,
16,
61,
1137,
283,
745,
356,
288,
870,
360,
4087,
1177,
26,
283,
435,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
abhilashnta/edx-platform
|
openedx/core/djangoapps/credit/migrations/0001_initial.py
|
85
|
8897
|
# -*- coding: utf-8 -*-
from south.utils import datetime_utils as datetime
from south.db import db
from south.v2 import SchemaMigration
from django.db import models
class Migration(SchemaMigration):
def forwards(self, orm):
# Adding model 'CreditCourse'
db.create_table('credit_creditcourse', (
('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
('course_key', self.gf('xmodule_django.models.CourseKeyField')(unique=True, max_length=255, db_index=True)),
('enabled', self.gf('django.db.models.fields.BooleanField')(default=False)),
))
db.send_create_signal('credit', ['CreditCourse'])
# Adding model 'CreditProvider'
db.create_table('credit_creditprovider', (
('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
('created', self.gf('model_utils.fields.AutoCreatedField')(default=datetime.datetime.now)),
('modified', self.gf('model_utils.fields.AutoLastModifiedField')(default=datetime.datetime.now)),
('provider_id', self.gf('django.db.models.fields.CharField')(unique=True, max_length=255, db_index=True)),
('display_name', self.gf('django.db.models.fields.CharField')(max_length=255)),
))
db.send_create_signal('credit', ['CreditProvider'])
# Adding model 'CreditRequirement'
db.create_table('credit_creditrequirement', (
('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
('created', self.gf('model_utils.fields.AutoCreatedField')(default=datetime.datetime.now)),
('modified', self.gf('model_utils.fields.AutoLastModifiedField')(default=datetime.datetime.now)),
('course', self.gf('django.db.models.fields.related.ForeignKey')(related_name='credit_requirements', to=orm['credit.CreditCourse'])),
('namespace', self.gf('django.db.models.fields.CharField')(max_length=255)),
('name', self.gf('django.db.models.fields.CharField')(max_length=255)),
('configuration', self.gf('jsonfield.fields.JSONField')()),
('active', self.gf('django.db.models.fields.BooleanField')(default=True)),
))
db.send_create_signal('credit', ['CreditRequirement'])
# Adding unique constraint on 'CreditRequirement', fields ['namespace', 'name', 'course']
db.create_unique('credit_creditrequirement', ['namespace', 'name', 'course_id'])
# Adding model 'CreditRequirementStatus'
db.create_table('credit_creditrequirementstatus', (
('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
('created', self.gf('model_utils.fields.AutoCreatedField')(default=datetime.datetime.now)),
('modified', self.gf('model_utils.fields.AutoLastModifiedField')(default=datetime.datetime.now)),
('username', self.gf('django.db.models.fields.CharField')(max_length=255, db_index=True)),
('requirement', self.gf('django.db.models.fields.related.ForeignKey')(related_name='statuses', to=orm['credit.CreditRequirement'])),
('status', self.gf('django.db.models.fields.CharField')(max_length=32)),
))
db.send_create_signal('credit', ['CreditRequirementStatus'])
# Adding model 'CreditEligibility'
db.create_table('credit_crediteligibility', (
('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
('created', self.gf('model_utils.fields.AutoCreatedField')(default=datetime.datetime.now)),
('modified', self.gf('model_utils.fields.AutoLastModifiedField')(default=datetime.datetime.now)),
('username', self.gf('django.db.models.fields.CharField')(max_length=255, db_index=True)),
('course', self.gf('django.db.models.fields.related.ForeignKey')(related_name='eligibilities', to=orm['credit.CreditCourse'])),
('provider', self.gf('django.db.models.fields.related.ForeignKey')(related_name='eligibilities', to=orm['credit.CreditProvider'])),
))
db.send_create_signal('credit', ['CreditEligibility'])
# Adding unique constraint on 'CreditEligibility', fields ['username', 'course']
db.create_unique('credit_crediteligibility', ['username', 'course_id'])
def backwards(self, orm):
# Removing unique constraint on 'CreditEligibility', fields ['username', 'course']
db.delete_unique('credit_crediteligibility', ['username', 'course_id'])
# Removing unique constraint on 'CreditRequirement', fields ['namespace', 'name', 'course']
db.delete_unique('credit_creditrequirement', ['namespace', 'name', 'course_id'])
# Deleting model 'CreditCourse'
db.delete_table('credit_creditcourse')
# Deleting model 'CreditProvider'
db.delete_table('credit_creditprovider')
# Deleting model 'CreditRequirement'
db.delete_table('credit_creditrequirement')
# Deleting model 'CreditRequirementStatus'
db.delete_table('credit_creditrequirementstatus')
# Deleting model 'CreditEligibility'
db.delete_table('credit_crediteligibility')
models = {
'credit.creditcourse': {
'Meta': {'object_name': 'CreditCourse'},
'course_key': ('xmodule_django.models.CourseKeyField', [], {'unique': 'True', 'max_length': '255', 'db_index': 'True'}),
'enabled': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'})
},
'credit.crediteligibility': {
'Meta': {'unique_together': "(('username', 'course'),)", 'object_name': 'CreditEligibility'},
'course': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'eligibilities'", 'to': "orm['credit.CreditCourse']"}),
'created': ('model_utils.fields.AutoCreatedField', [], {'default': 'datetime.datetime.now'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'modified': ('model_utils.fields.AutoLastModifiedField', [], {'default': 'datetime.datetime.now'}),
'provider': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'eligibilities'", 'to': "orm['credit.CreditProvider']"}),
'username': ('django.db.models.fields.CharField', [], {'max_length': '255', 'db_index': 'True'})
},
'credit.creditprovider': {
'Meta': {'object_name': 'CreditProvider'},
'created': ('model_utils.fields.AutoCreatedField', [], {'default': 'datetime.datetime.now'}),
'display_name': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'modified': ('model_utils.fields.AutoLastModifiedField', [], {'default': 'datetime.datetime.now'}),
'provider_id': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255', 'db_index': 'True'})
},
'credit.creditrequirement': {
'Meta': {'unique_together': "(('namespace', 'name', 'course'),)", 'object_name': 'CreditRequirement'},
'active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
'configuration': ('jsonfield.fields.JSONField', [], {}),
'course': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'credit_requirements'", 'to': "orm['credit.CreditCourse']"}),
'created': ('model_utils.fields.AutoCreatedField', [], {'default': 'datetime.datetime.now'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'modified': ('model_utils.fields.AutoLastModifiedField', [], {'default': 'datetime.datetime.now'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
'namespace': ('django.db.models.fields.CharField', [], {'max_length': '255'})
},
'credit.creditrequirementstatus': {
'Meta': {'object_name': 'CreditRequirementStatus'},
'created': ('model_utils.fields.AutoCreatedField', [], {'default': 'datetime.datetime.now'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'modified': ('model_utils.fields.AutoLastModifiedField', [], {'default': 'datetime.datetime.now'}),
'requirement': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'statuses'", 'to': "orm['credit.CreditRequirement']"}),
'status': ('django.db.models.fields.CharField', [], {'max_length': '32'}),
'username': ('django.db.models.fields.CharField', [], {'max_length': '255', 'db_index': 'True'})
}
}
complete_apps = ['credit']
|
agpl-3.0
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
504,
12919,
14,
1208,
492,
2197,
63,
1208,
465,
2197,
199,
504,
12919,
14,
697,
492,
1592,
199,
504,
12919,
14,
86,
18,
492,
24765,
199,
504,
1639,
14,
697,
492,
1709,
421,
199,
533,
12090,
8,
24822,
304,
339,
347,
17465,
8,
277,
12,
9813,
304,
267,
327,
12934,
1402,
283,
27228,
6979,
7,
267,
1592,
14,
981,
63,
1224,
360,
9365,
63,
9365,
1972,
297,
334,
288,
661,
344,
297,
291,
14,
7102,
360,
1176,
14,
697,
14,
992,
14,
955,
14,
4378,
7533,
3327,
63,
498,
29,
549,
1826,
288,
661,
1972,
63,
498,
297,
291,
14,
7102,
360,
14293,
63,
1176,
14,
992,
14,
18806,
792,
7533,
3235,
29,
549,
12,
1390,
63,
1267,
29,
2299,
12,
1592,
63,
1080,
29,
549,
1826,
288,
661,
3827,
297,
291,
14,
7102,
360,
1176,
14,
697,
14,
992,
14,
955,
14,
5036,
7533,
885,
29,
797,
1826,
267,
5082,
267,
1592,
14,
2254,
63,
981,
63,
4653,
360,
9365,
297,
788,
27228,
6979,
1105,
398,
327,
12934,
1402,
283,
27228,
6663,
7,
267,
1592,
14,
981,
63,
1224,
360,
9365,
63,
9365,
3780,
297,
334,
288,
661,
344,
297,
291,
14,
7102,
360,
1176,
14,
697,
14,
992,
14,
955,
14,
4378,
7533,
3327,
63,
498,
29,
549,
1826,
288,
661,
3966,
297,
291,
14,
7102,
360,
1238,
63,
1208,
14,
955,
14,
3358,
10502,
792,
7533,
885,
29,
2083,
14,
2083,
14,
2131,
1826,
288,
661,
5540,
297,
291,
14,
7102,
360,
1238,
63,
1208,
14,
955,
14,
3358,
6090,
11911,
792,
7533,
885,
29,
2083,
14,
2083,
14,
2131,
1826,
288,
661,
3780,
63,
344,
297,
291,
14,
7102,
360,
1176,
14,
697,
14,
992,
14,
955,
14,
2183,
7533,
3235,
29,
549,
12,
1390,
63,
1267,
29,
2299,
12,
1592,
63,
1080,
29,
549,
1826,
288,
661,
2918,
63,
354,
297,
291,
14,
7102,
360,
1176,
14,
697,
14,
992,
14,
955,
14,
2183,
7533,
988,
63,
1267,
29,
2299,
1826,
267,
5082,
267,
1592,
14,
2254,
63,
981,
63,
4653,
360,
9365,
297,
788,
27228,
6663,
1105,
398,
327,
12934,
1402,
283,
27228,
17947,
7,
267,
1592,
14,
981,
63,
1224,
360,
9365,
63,
9365,
12434,
297,
334,
288,
661,
344,
297,
291,
14,
7102,
360,
1176,
14,
697,
14,
992,
14,
955,
14,
4378,
7533,
3327,
63,
498,
29,
549,
1826,
288,
661,
3966,
297,
291,
14,
7102,
360,
1238,
63,
1208,
14,
955,
14,
3358,
10502,
792,
7533,
885,
29,
2083,
14,
2083,
14,
2131,
1826,
288,
661,
5540,
297,
291,
14,
7102,
360,
1238,
63,
1208,
14,
955,
14,
3358,
6090,
11911,
792,
7533,
885,
29,
2083,
14,
2083,
14,
2131,
1826,
288,
661,
1972,
297,
291,
14,
7102,
360,
1176,
14,
697,
14,
992,
14,
955,
14,
2407,
14,
3190,
7533,
2407,
63,
354,
534,
9365,
63,
7538,
297,
370,
29,
1025,
459,
9365,
14,
27228,
6979,
16607,
288,
661,
3251,
297,
291,
14,
7102,
360,
1176,
14,
697,
14,
992,
14,
955,
14,
2183,
7533,
988,
63,
1267,
29,
2299,
1826,
288,
661,
354,
297,
291,
14,
7102,
360,
1176,
14,
697,
14,
992,
14,
955,
14,
2183,
7533,
988,
63,
1267,
29,
2299,
1826,
288,
661,
4758,
297,
291,
14,
7102,
360,
1001,
698,
14,
955,
14,
30796,
358,
4000,
288,
661,
2682,
297,
291,
14,
7102,
360,
1176,
14,
697,
14,
992,
14,
955,
14,
5036,
7533,
885,
29,
549,
1826,
267,
5082,
267,
1592,
14,
2254,
63,
981,
63,
4653,
360,
9365,
297,
788,
27228,
17947,
1105,
398,
327,
12934,
3747,
5828,
641,
283,
27228,
17947,
297,
1504,
788,
3251,
297,
283,
354,
297,
283,
1972,
418,
267,
1592,
14,
981,
63,
3235,
360,
9365,
63,
9365,
12434,
297,
788,
3251,
297,
283,
354,
297,
283,
1972,
63,
344,
1105,
398,
327,
12934,
1402,
283,
27228,
17947,
3694,
7,
267,
1592,
14,
981,
63,
1224,
360,
9365,
63,
9365,
12434,
1205,
297,
334,
288,
661,
344,
297,
291,
14,
7102,
360,
1176,
14,
697,
14,
992,
14,
955,
14,
4378,
7533,
3327,
63,
498,
29,
549,
1826,
288,
661,
3966,
297,
291,
14,
7102,
360,
1238,
63,
1208,
14,
955,
14,
3358,
10502,
792,
7533,
885,
29,
2083,
14,
2083,
14,
2131,
1826,
288,
661,
5540,
297,
291,
14,
7102,
360,
1238,
63,
1208,
14,
955,
14,
3358,
6090,
11911,
792,
7533,
885,
29,
2083,
14,
2083,
14,
2131,
1826,
288,
661,
2473,
297,
291,
14,
7102,
360,
1176,
14,
697,
14,
992,
14,
955,
14,
2183,
7533,
988,
63,
1267,
29,
2299,
12,
1592,
63,
1080,
29,
549,
1826,
288,
661,
12434,
297,
291,
14,
7102,
360,
1176,
14,
697,
14,
992,
14,
955,
14,
2407,
14,
3190,
7533,
2407,
63,
354,
534,
17084,
297,
370,
29,
1025,
459,
9365,
14,
27228,
17947,
16607,
288,
661,
1205,
297,
291,
14,
7102,
360,
1176,
14,
697,
14,
992,
14,
955,
14,
2183,
7533,
988,
63,
1267,
29,
708,
1826,
267,
5082,
267,
1592,
14,
2254,
63,
981,
63,
4653,
360,
9365,
297,
788,
27228,
17947,
3694,
1105,
398,
327,
12934,
1402,
283,
27228,
37,
17506,
29524,
7,
267,
1592,
14,
981,
63,
1224,
360,
9365,
63,
1353,
328,
266,
17506,
29524,
297,
334,
288,
661,
344,
297,
291,
14,
7102,
360,
1176,
14,
697,
14,
992,
14,
955,
14,
4378,
7533,
3327,
63,
498,
29,
549,
1826,
288,
661,
3966,
297,
291,
14,
7102,
360,
1238,
63,
1208,
14,
955,
14,
3358,
10502,
792,
7533,
885,
29,
2083,
14,
2083,
14,
2131,
1826,
288,
661,
5540,
297,
291,
14,
7102,
360,
1238,
63,
1208,
14,
955,
14,
3358,
6090,
11911,
792,
7533,
885,
29,
2083,
14,
2083,
14,
2131,
1826,
288,
661,
2473,
297,
291,
14,
7102,
360,
1176,
14,
697,
14,
992,
14,
955,
14,
2183,
7533,
988,
63,
1267,
29,
2299,
12,
1592,
63,
1080,
29,
549,
1826,
288,
661,
1972,
297,
291,
14,
7102,
360,
1176,
14,
697,
14,
992,
14,
955,
14,
2407,
14,
3190,
7533,
2407,
63,
354,
534,
69,
17506,
1892,
5462,
297,
370,
29,
1025,
459,
9365,
14,
27228,
6979,
16607,
288,
661,
3780,
297,
291,
14,
7102,
360,
1176,
14,
697,
14,
992
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
504,
12919,
14,
1208,
492,
2197,
63,
1208,
465,
2197,
199,
504,
12919,
14,
697,
492,
1592,
199,
504,
12919,
14,
86,
18,
492,
24765,
199,
504,
1639,
14,
697,
492,
1709,
421,
199,
533,
12090,
8,
24822,
304,
339,
347,
17465,
8,
277,
12,
9813,
304,
267,
327,
12934,
1402,
283,
27228,
6979,
7,
267,
1592,
14,
981,
63,
1224,
360,
9365,
63,
9365,
1972,
297,
334,
288,
661,
344,
297,
291,
14,
7102,
360,
1176,
14,
697,
14,
992,
14,
955,
14,
4378,
7533,
3327,
63,
498,
29,
549,
1826,
288,
661,
1972,
63,
498,
297,
291,
14,
7102,
360,
14293,
63,
1176,
14,
992,
14,
18806,
792,
7533,
3235,
29,
549,
12,
1390,
63,
1267,
29,
2299,
12,
1592,
63,
1080,
29,
549,
1826,
288,
661,
3827,
297,
291,
14,
7102,
360,
1176,
14,
697,
14,
992,
14,
955,
14,
5036,
7533,
885,
29,
797,
1826,
267,
5082,
267,
1592,
14,
2254,
63,
981,
63,
4653,
360,
9365,
297,
788,
27228,
6979,
1105,
398,
327,
12934,
1402,
283,
27228,
6663,
7,
267,
1592,
14,
981,
63,
1224,
360,
9365,
63,
9365,
3780,
297,
334,
288,
661,
344,
297,
291,
14,
7102,
360,
1176,
14,
697,
14,
992,
14,
955,
14,
4378,
7533,
3327,
63,
498,
29,
549,
1826,
288,
661,
3966,
297,
291,
14,
7102,
360,
1238,
63,
1208,
14,
955,
14,
3358,
10502,
792,
7533,
885,
29,
2083,
14,
2083,
14,
2131,
1826,
288,
661,
5540,
297,
291,
14,
7102,
360,
1238,
63,
1208,
14,
955,
14,
3358,
6090,
11911,
792,
7533,
885,
29,
2083,
14,
2083,
14,
2131,
1826,
288,
661,
3780,
63,
344,
297,
291,
14,
7102,
360,
1176,
14,
697,
14,
992,
14,
955,
14,
2183,
7533,
3235,
29,
549,
12,
1390,
63,
1267,
29,
2299,
12,
1592,
63,
1080,
29,
549,
1826,
288,
661,
2918,
63,
354,
297,
291,
14,
7102,
360,
1176,
14,
697,
14,
992,
14,
955,
14,
2183,
7533,
988,
63,
1267,
29,
2299,
1826,
267,
5082,
267,
1592,
14,
2254,
63,
981,
63,
4653,
360,
9365,
297,
788,
27228,
6663,
1105,
398,
327,
12934,
1402,
283,
27228,
17947,
7,
267,
1592,
14,
981,
63,
1224,
360,
9365,
63,
9365,
12434,
297,
334,
288,
661,
344,
297,
291,
14,
7102,
360,
1176,
14,
697,
14,
992,
14,
955,
14,
4378,
7533,
3327,
63,
498,
29,
549,
1826,
288,
661,
3966,
297,
291,
14,
7102,
360,
1238,
63,
1208,
14,
955,
14,
3358,
10502,
792,
7533,
885,
29,
2083,
14,
2083,
14,
2131,
1826,
288,
661,
5540,
297,
291,
14,
7102,
360,
1238,
63,
1208,
14,
955,
14,
3358,
6090,
11911,
792,
7533,
885,
29,
2083,
14,
2083,
14,
2131,
1826,
288,
661,
1972,
297,
291,
14,
7102,
360,
1176,
14,
697,
14,
992,
14,
955,
14,
2407,
14,
3190,
7533,
2407,
63,
354,
534,
9365,
63,
7538,
297,
370,
29,
1025,
459,
9365,
14,
27228,
6979,
16607,
288,
661,
3251,
297,
291,
14,
7102,
360,
1176,
14,
697,
14,
992,
14,
955,
14,
2183,
7533,
988,
63,
1267,
29,
2299,
1826,
288,
661,
354,
297,
291,
14,
7102,
360,
1176,
14,
697,
14,
992,
14,
955,
14,
2183,
7533,
988,
63,
1267,
29,
2299,
1826,
288,
661,
4758,
297,
291,
14,
7102,
360,
1001,
698,
14,
955,
14,
30796,
358,
4000,
288,
661,
2682,
297,
291,
14,
7102,
360,
1176,
14,
697,
14,
992,
14,
955,
14,
5036,
7533,
885,
29,
549,
1826,
267,
5082,
267,
1592,
14,
2254,
63,
981,
63,
4653,
360,
9365,
297,
788,
27228,
17947,
1105,
398,
327,
12934,
3747,
5828,
641,
283,
27228,
17947,
297,
1504,
788,
3251,
297,
283,
354,
297,
283,
1972,
418,
267,
1592,
14,
981,
63,
3235,
360,
9365,
63,
9365,
12434,
297,
788,
3251,
297,
283,
354,
297,
283,
1972,
63,
344,
1105,
398,
327,
12934,
1402,
283,
27228,
17947,
3694,
7,
267,
1592,
14,
981,
63,
1224,
360,
9365,
63,
9365,
12434,
1205,
297,
334,
288,
661,
344,
297,
291,
14,
7102,
360,
1176,
14,
697,
14,
992,
14,
955,
14,
4378,
7533,
3327,
63,
498,
29,
549,
1826,
288,
661,
3966,
297,
291,
14,
7102,
360,
1238,
63,
1208,
14,
955,
14,
3358,
10502,
792,
7533,
885,
29,
2083,
14,
2083,
14,
2131,
1826,
288,
661,
5540,
297,
291,
14,
7102,
360,
1238,
63,
1208,
14,
955,
14,
3358,
6090,
11911,
792,
7533,
885,
29,
2083,
14,
2083,
14,
2131,
1826,
288,
661,
2473,
297,
291,
14,
7102,
360,
1176,
14,
697,
14,
992,
14,
955,
14,
2183,
7533,
988,
63,
1267,
29,
2299,
12,
1592,
63,
1080,
29,
549,
1826,
288,
661,
12434,
297,
291,
14,
7102,
360,
1176,
14,
697,
14,
992,
14,
955,
14,
2407,
14,
3190,
7533,
2407,
63,
354,
534,
17084,
297,
370,
29,
1025,
459,
9365,
14,
27228,
17947,
16607,
288,
661,
1205,
297,
291,
14,
7102,
360,
1176,
14,
697,
14,
992,
14,
955,
14,
2183,
7533,
988,
63,
1267,
29,
708,
1826,
267,
5082,
267,
1592,
14,
2254,
63,
981,
63,
4653,
360,
9365,
297,
788,
27228,
17947,
3694,
1105,
398,
327,
12934,
1402,
283,
27228,
37,
17506,
29524,
7,
267,
1592,
14,
981,
63,
1224,
360,
9365,
63,
1353,
328,
266,
17506,
29524,
297,
334,
288,
661,
344,
297,
291,
14,
7102,
360,
1176,
14,
697,
14,
992,
14,
955,
14,
4378,
7533,
3327,
63,
498,
29,
549,
1826,
288,
661,
3966,
297,
291,
14,
7102,
360,
1238,
63,
1208,
14,
955,
14,
3358,
10502,
792,
7533,
885,
29,
2083,
14,
2083,
14,
2131,
1826,
288,
661,
5540,
297,
291,
14,
7102,
360,
1238,
63,
1208,
14,
955,
14,
3358,
6090,
11911,
792,
7533,
885,
29,
2083,
14,
2083,
14,
2131,
1826,
288,
661,
2473,
297,
291,
14,
7102,
360,
1176,
14,
697,
14,
992,
14,
955,
14,
2183,
7533,
988,
63,
1267,
29,
2299,
12,
1592,
63,
1080,
29,
549,
1826,
288,
661,
1972,
297,
291,
14,
7102,
360,
1176,
14,
697,
14,
992,
14,
955,
14,
2407,
14,
3190,
7533,
2407,
63,
354,
534,
69,
17506,
1892,
5462,
297,
370,
29,
1025,
459,
9365,
14,
27228,
6979,
16607,
288,
661,
3780,
297,
291,
14,
7102,
360,
1176,
14,
697,
14,
992,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
ProfessorX/Config
|
.PyCharm30/system/python_stubs/-1247972723/gtk/_gtk/ToolButton.py
|
1
|
9124
|
# encoding: utf-8
# module gtk._gtk
# from /usr/lib/python2.7/dist-packages/gtk-2.0/gtk/_gtk.so
# by generator 1.135
# no doc
# imports
import atk as __atk
import gio as __gio
import gobject as __gobject
import gobject._gobject as __gobject__gobject
from ToolItem import ToolItem
class ToolButton(ToolItem):
"""
Object GtkToolButton
Signals from GtkToolButton:
clicked ()
Properties from GtkToolButton:
label -> gchararray: Label
Text to show in the item.
use-underline -> gboolean: Use underline
If set, an underline in the label property indicates that the next character should be used for the mnemonic accelerator key in the overflow menu
label-widget -> GtkWidget: Label widget
Widget to use as the item label
stock-id -> gchararray: Stock Id
The stock icon displayed on the item
icon-name -> gchararray: Icon name
The name of the themed icon displayed on the item
icon-widget -> GtkWidget: Icon widget
Icon widget to display in the item
Signals from GtkToolItem:
create-menu-proxy () -> gboolean
toolbar-reconfigured ()
set-tooltip (GtkTooltips, gchararray, gchararray) -> gboolean
Properties from GtkToolItem:
visible-horizontal -> gboolean: Visible when horizontal
Whether the toolbar item is visible when the toolbar is in a horizontal orientation.
visible-vertical -> gboolean: Visible when vertical
Whether the toolbar item is visible when the toolbar is in a vertical orientation.
is-important -> gboolean: Is important
Whether the toolbar item is considered important. When TRUE, toolbar buttons show text in GTK_TOOLBAR_BOTH_HORIZ mode
Signals from GtkContainer:
add (GtkWidget)
remove (GtkWidget)
check-resize ()
set-focus-child (GtkWidget)
Properties from GtkContainer:
border-width -> guint: Border width
The width of the empty border outside the containers children
resize-mode -> GtkResizeMode: Resize mode
Specify how resize events are handled
child -> GtkWidget: Child
Can be used to add a new child to the container
Signals from GtkWidget:
composited-changed ()
show ()
hide ()
map ()
unmap ()
realize ()
unrealize ()
size-request (GtkRequisition)
size-allocate (GdkRectangle)
state-changed (GtkStateType)
parent-set (GtkWidget)
hierarchy-changed (GtkWidget)
style-set (GtkStyle)
direction-changed (GtkTextDirection)
grab-notify (gboolean)
child-notify (GParam)
mnemonic-activate (gboolean) -> gboolean
grab-focus ()
focus (GtkDirectionType) -> gboolean
move-focus (GtkDirectionType)
event (GdkEvent) -> gboolean
event-after (GdkEvent)
button-press-event (GdkEvent) -> gboolean
button-release-event (GdkEvent) -> gboolean
scroll-event (GdkEvent) -> gboolean
motion-notify-event (GdkEvent) -> gboolean
keynav-failed (GtkDirectionType) -> gboolean
delete-event (GdkEvent) -> gboolean
destroy-event (GdkEvent) -> gboolean
expose-event (GdkEvent) -> gboolean
key-press-event (GdkEvent) -> gboolean
key-release-event (GdkEvent) -> gboolean
enter-notify-event (GdkEvent) -> gboolean
leave-notify-event (GdkEvent) -> gboolean
configure-event (GdkEvent) -> gboolean
focus-in-event (GdkEvent) -> gboolean
focus-out-event (GdkEvent) -> gboolean
map-event (GdkEvent) -> gboolean
unmap-event (GdkEvent) -> gboolean
property-notify-event (GdkEvent) -> gboolean
selection-clear-event (GdkEvent) -> gboolean
selection-request-event (GdkEvent) -> gboolean
selection-notify-event (GdkEvent) -> gboolean
selection-received (GtkSelectionData, guint)
selection-get (GtkSelectionData, guint, guint)
proximity-in-event (GdkEvent) -> gboolean
proximity-out-event (GdkEvent) -> gboolean
drag-leave (GdkDragContext, guint)
drag-begin (GdkDragContext)
drag-end (GdkDragContext)
drag-data-delete (GdkDragContext)
drag-failed (GdkDragContext, GtkDragResult) -> gboolean
drag-motion (GdkDragContext, gint, gint, guint) -> gboolean
drag-drop (GdkDragContext, gint, gint, guint) -> gboolean
drag-data-get (GdkDragContext, GtkSelectionData, guint, guint)
drag-data-received (GdkDragContext, gint, gint, GtkSelectionData, guint, guint)
visibility-notify-event (GdkEvent) -> gboolean
client-event (GdkEvent) -> gboolean
no-expose-event (GdkEvent) -> gboolean
window-state-event (GdkEvent) -> gboolean
damage-event (GdkEvent) -> gboolean
grab-broken-event (GdkEvent) -> gboolean
query-tooltip (gint, gint, gboolean, GtkTooltip) -> gboolean
popup-menu () -> gboolean
show-help (GtkWidgetHelpType) -> gboolean
accel-closures-changed ()
screen-changed (GdkScreen)
can-activate-accel (guint) -> gboolean
Properties from GtkWidget:
name -> gchararray: Widget name
The name of the widget
parent -> GtkContainer: Parent widget
The parent widget of this widget. Must be a Container widget
width-request -> gint: Width request
Override for width request of the widget, or -1 if natural request should be used
height-request -> gint: Height request
Override for height request of the widget, or -1 if natural request should be used
visible -> gboolean: Visible
Whether the widget is visible
sensitive -> gboolean: Sensitive
Whether the widget responds to input
app-paintable -> gboolean: Application paintable
Whether the application will paint directly on the widget
can-focus -> gboolean: Can focus
Whether the widget can accept the input focus
has-focus -> gboolean: Has focus
Whether the widget has the input focus
is-focus -> gboolean: Is focus
Whether the widget is the focus widget within the toplevel
can-default -> gboolean: Can default
Whether the widget can be the default widget
has-default -> gboolean: Has default
Whether the widget is the default widget
receives-default -> gboolean: Receives default
If TRUE, the widget will receive the default action when it is focused
composite-child -> gboolean: Composite child
Whether the widget is part of a composite widget
style -> GtkStyle: Style
The style of the widget, which contains information about how it will look (colors etc)
events -> GdkEventMask: Events
The event mask that decides what kind of GdkEvents this widget gets
extension-events -> GdkExtensionMode: Extension events
The mask that decides what kind of extension events this widget gets
no-show-all -> gboolean: No show all
Whether gtk_widget_show_all() should not affect this widget
has-tooltip -> gboolean: Has tooltip
Whether this widget has a tooltip
tooltip-markup -> gchararray: Tooltip markup
The contents of the tooltip for this widget
tooltip-text -> gchararray: Tooltip Text
The contents of the tooltip for this widget
window -> GdkWindow: Window
The widget's window if it is realized
double-buffered -> gboolean: Double Buffered
Whether or not the widget is double buffered
Signals from GtkObject:
destroy ()
Properties from GtkObject:
user-data -> gpointer: User Data
Anonymous User Data Pointer
Signals from GObject:
notify (GParam)
"""
@classmethod
def do_clicked(cls, *args, **kwargs): # real signature unknown
pass
def get_icon_name(self, *args, **kwargs): # real signature unknown
pass
def get_icon_widget(self, *args, **kwargs): # real signature unknown
pass
def get_label(self, *args, **kwargs): # real signature unknown
pass
def get_label_widget(self, *args, **kwargs): # real signature unknown
pass
def get_stock_id(self, *args, **kwargs): # real signature unknown
pass
def get_use_underline(self, *args, **kwargs): # real signature unknown
pass
def set_icon_name(self, *args, **kwargs): # real signature unknown
pass
def set_icon_widget(self, *args, **kwargs): # real signature unknown
pass
def set_label(self, *args, **kwargs): # real signature unknown
pass
def set_label_widget(self, *args, **kwargs): # real signature unknown
pass
def set_stock_id(self, *args, **kwargs): # real signature unknown
pass
def set_use_underline(self, *args, **kwargs): # real signature unknown
pass
def __init__(self, *args, **kwargs): # real signature unknown
pass
def __iter__(self): # real signature unknown; restored from __doc__
""" x.__iter__() <==> iter(x) """
pass
__gtype__ = None # (!) real value is ''
|
gpl-2.0
|
[
3,
2644,
26,
2774,
13,
24,
199,
3,
859,
8116,
423,
12275,
199,
3,
687,
1182,
2647,
15,
773,
15,
1548,
18,
14,
23,
15,
2686,
13,
5154,
15,
12275,
13,
18,
14,
16,
15,
12275,
15607,
12275,
14,
1152,
199,
3,
701,
4306,
413,
14,
8312,
199,
3,
949,
1382,
199,
199,
3,
8925,
199,
646,
737,
75,
465,
636,
292,
75,
199,
646,
486,
2308,
465,
636,
71,
2308,
199,
646,
25595,
465,
636,
71,
785,
199,
646,
25595,
423,
71,
785,
465,
636,
71,
785,
363,
71,
785,
421,
199,
504,
15650,
2081,
492,
15650,
2081,
199,
199,
533,
15650,
4259,
8,
5157,
2081,
304,
272,
408,
272,
6935,
11424,
5157,
4259,
2286,
6632,
2551,
687,
11424,
5157,
4259,
26,
489,
28614,
6248,
2286,
19329,
687,
11424,
5157,
4259,
26,
489,
1768,
1035,
486,
1560,
1144,
26,
10354,
267,
4516,
370,
2498,
315,
314,
1242,
14,
489,
675,
13,
24396,
1035,
486,
4871,
26,
3645,
25735,
267,
982,
663,
12,
376,
25735,
315,
314,
1768,
3324,
9126,
626,
314,
2163,
4528,
1077,
506,
1202,
367,
314,
18250,
16082,
1066,
27139,
790,
315,
314,
15784,
6269,
489,
1768,
13,
3440,
1035,
11424,
3339,
26,
10354,
3938,
267,
16905,
370,
675,
465,
314,
1242,
1768,
489,
10952,
13,
344,
1035,
486,
1560,
1144,
26,
28406,
15418,
267,
710,
10952,
7016,
9080,
641,
314,
1242,
489,
7016,
13,
354,
1035,
486,
1560,
1144,
26,
473,
388,
536,
267,
710,
536,
402,
314,
314,
3594,
7016,
9080,
641,
314,
1242,
489,
7016,
13,
3440,
1035,
11424,
3339,
26,
473,
388,
3938,
267,
473,
388,
3938,
370,
2929,
315,
314,
1242,
2286,
6632,
2551,
687,
11424,
5157,
2081,
26,
489,
1218,
13,
4470,
13,
3280,
6248,
1035,
486,
4871,
489,
22483,
13,
264,
11786,
6248,
489,
663,
13,
22972,
334,
18891,
5157,
25842,
12,
486,
1560,
1144,
12,
486,
1560,
1144,
9,
1035,
486,
4871,
2286,
19329,
687,
11424,
5157,
2081,
26,
489,
8917,
13,
11392,
1035,
486,
4871,
26,
6561,
1164,
1380,
17528,
267,
7480,
314,
22483,
1242,
365,
8917,
1380,
314,
22483,
365,
315,
282,
17528,
16774,
14,
489,
8917,
13,
7870,
1035,
486,
4871,
26,
6561,
1164,
1380,
13763,
267,
7480,
314,
22483,
1242,
365,
8917,
1380,
314,
22483,
365,
315,
282,
13763,
16774,
14,
489,
365,
13,
19559,
1035,
486,
4871,
26,
6596,
11012,
267,
7480,
314,
22483,
1242,
365,
8652,
11012,
14,
3979,
9074,
4187,
12,
22483,
15766,
2498,
1318,
315,
598,
15263,
63,
9731,
13895,
63,
28784,
63,
40,
7123,
818,
2286,
6632,
2551,
687,
11424,
4076,
26,
489,
1050,
334,
18891,
3339,
9,
489,
2813,
334,
18891,
3339,
9,
489,
1104,
13,
8709,
6248,
489,
663,
13,
12283,
13,
1739,
334,
18891,
3339,
9,
2286,
19329,
687,
11424,
4076,
26,
489,
9162,
13,
2063,
1035,
486,
1635,
26,
699,
1648,
3462,
267,
710,
3462,
402,
314,
2701,
9162,
9682,
314,
15333,
4978,
489,
15210,
13,
632,
1035,
11424,
24559,
1385,
26,
799,
890,
818,
267,
13327,
4212,
15210,
4474,
787,
8860,
489,
1982,
1035,
11424,
3339,
26,
12988,
267,
6855,
506,
1202,
370,
1050,
282,
892,
1982,
370,
314,
3970,
2286,
6632,
2551,
687,
11424,
3339,
26,
489,
11395,
11669,
13,
2489,
6248,
489,
2498,
6248,
489,
13714,
6248,
489,
2341,
6248,
489,
625,
1130,
6248,
489,
3363,
794,
6248,
489,
625,
3093,
794,
6248,
489,
1568,
13,
1069,
334,
18891,
497,
21523,
9,
489,
1568,
13,
12991,
334,
39,
6341,
18127,
9,
489,
1174,
13,
2489,
334,
18891,
2223,
804,
9,
489,
1676,
13,
409,
334,
18891,
3339,
9,
489,
14446,
13,
2489,
334,
18891,
3339,
9,
489,
3449,
13,
409,
334,
18891,
6609,
9,
489,
7581,
13,
2489,
334,
18891,
1872,
17015,
9,
489,
18200,
13,
6814,
334,
71,
4871,
9,
489,
1982,
13,
6814,
334,
39,
4098,
9,
489,
18250,
16082,
13,
8222,
334,
71,
4871,
9,
1035,
486,
4871,
489,
18200,
13,
12283,
6248,
489,
16470,
334,
18891,
17015,
804,
9,
1035,
486,
4871,
489,
4057,
13,
12283,
334,
18891,
17015,
804,
9,
489,
1566,
334,
39,
6341,
2390,
9,
1035,
486,
4871,
489,
1566,
13,
4399,
334,
39,
6341,
2390,
9,
489,
5528,
13,
2915,
13,
1430,
334,
39,
6341,
2390,
9,
1035,
486,
4871,
489,
5528,
13,
3221,
13,
1430,
334,
39,
6341,
2390,
9,
1035,
486,
4871,
489,
13704,
13,
1430,
334,
39,
6341,
2390,
9,
1035,
486,
4871,
489,
25134,
13,
6814,
13,
1430,
334,
39,
6341,
2390,
9,
1035,
486,
4871,
489,
790,
10927,
13,
4892,
334,
18891,
17015,
804,
9,
1035,
486,
4871,
489,
3145,
13,
1430,
334,
39,
6341,
2390,
9,
1035,
486,
4871,
489,
11972,
13,
1430,
334,
39,
6341,
2390,
9,
1035,
486,
4871,
489,
23705,
13,
1430,
334,
39,
6341,
2390,
9,
1035,
486,
4871,
489,
790,
13,
2915,
13,
1430,
334,
39,
6341,
2390,
9,
1035,
486,
4871,
489,
790,
13,
3221,
13,
1430,
334,
39,
6341,
2390,
9,
1035,
486,
4871,
489,
9509,
13,
6814,
13,
1430,
334,
39,
6341,
2390,
9,
1035,
486,
4871,
489,
10137,
13,
6814,
13,
1430,
334,
39,
6341,
2390,
9,
1035,
486,
4871,
489,
7908,
13,
1430,
334,
39,
6341,
2390,
9,
1035,
486,
4871,
489,
16470,
13,
262,
13,
1430,
334,
39,
6341,
2390,
9,
1035,
486,
4871,
489,
16470,
13,
548,
13,
1430,
334,
39,
6341,
2390,
9,
1035,
486,
4871,
489,
2341,
13,
1430,
334,
39,
6341,
2390,
9,
1035,
486,
4871,
489,
625,
1130,
13,
1430,
334,
39,
6341,
2390,
9,
1035,
486,
4871,
489,
3324,
13,
6814,
13,
1430,
334,
39,
6341,
2390,
9,
1035,
486,
4871,
489,
7267,
13,
3584,
13,
1430,
334,
39,
6341,
2390,
9,
1035,
486,
4871,
489,
7267,
13,
1069,
13,
1430,
334,
39,
6341,
2390,
9,
1035,
486,
4871,
489,
7267,
13,
6814,
13,
1430,
334,
39,
6341,
2390,
9,
1035,
486,
4871,
489,
7267,
13,
9226,
334,
18891,
7713,
1451,
12,
486,
1635,
9,
489,
7267,
13,
362,
334,
18891,
7713,
1451,
12,
486,
1635,
12,
486,
1635,
9,
489,
10645,
1017,
1209,
13,
262,
13,
1430,
334,
39,
6341,
2390,
9,
1035,
486,
4871,
489,
10645,
1017,
1209,
13,
548,
13,
1430,
334,
39,
6341,
2390,
9,
1035,
486,
4871,
489,
18981,
13,
12422
] |
[
2644,
26,
2774,
13,
24,
199,
3,
859,
8116,
423,
12275,
199,
3,
687,
1182,
2647,
15,
773,
15,
1548,
18,
14,
23,
15,
2686,
13,
5154,
15,
12275,
13,
18,
14,
16,
15,
12275,
15607,
12275,
14,
1152,
199,
3,
701,
4306,
413,
14,
8312,
199,
3,
949,
1382,
199,
199,
3,
8925,
199,
646,
737,
75,
465,
636,
292,
75,
199,
646,
486,
2308,
465,
636,
71,
2308,
199,
646,
25595,
465,
636,
71,
785,
199,
646,
25595,
423,
71,
785,
465,
636,
71,
785,
363,
71,
785,
421,
199,
504,
15650,
2081,
492,
15650,
2081,
199,
199,
533,
15650,
4259,
8,
5157,
2081,
304,
272,
408,
272,
6935,
11424,
5157,
4259,
2286,
6632,
2551,
687,
11424,
5157,
4259,
26,
489,
28614,
6248,
2286,
19329,
687,
11424,
5157,
4259,
26,
489,
1768,
1035,
486,
1560,
1144,
26,
10354,
267,
4516,
370,
2498,
315,
314,
1242,
14,
489,
675,
13,
24396,
1035,
486,
4871,
26,
3645,
25735,
267,
982,
663,
12,
376,
25735,
315,
314,
1768,
3324,
9126,
626,
314,
2163,
4528,
1077,
506,
1202,
367,
314,
18250,
16082,
1066,
27139,
790,
315,
314,
15784,
6269,
489,
1768,
13,
3440,
1035,
11424,
3339,
26,
10354,
3938,
267,
16905,
370,
675,
465,
314,
1242,
1768,
489,
10952,
13,
344,
1035,
486,
1560,
1144,
26,
28406,
15418,
267,
710,
10952,
7016,
9080,
641,
314,
1242,
489,
7016,
13,
354,
1035,
486,
1560,
1144,
26,
473,
388,
536,
267,
710,
536,
402,
314,
314,
3594,
7016,
9080,
641,
314,
1242,
489,
7016,
13,
3440,
1035,
11424,
3339,
26,
473,
388,
3938,
267,
473,
388,
3938,
370,
2929,
315,
314,
1242,
2286,
6632,
2551,
687,
11424,
5157,
2081,
26,
489,
1218,
13,
4470,
13,
3280,
6248,
1035,
486,
4871,
489,
22483,
13,
264,
11786,
6248,
489,
663,
13,
22972,
334,
18891,
5157,
25842,
12,
486,
1560,
1144,
12,
486,
1560,
1144,
9,
1035,
486,
4871,
2286,
19329,
687,
11424,
5157,
2081,
26,
489,
8917,
13,
11392,
1035,
486,
4871,
26,
6561,
1164,
1380,
17528,
267,
7480,
314,
22483,
1242,
365,
8917,
1380,
314,
22483,
365,
315,
282,
17528,
16774,
14,
489,
8917,
13,
7870,
1035,
486,
4871,
26,
6561,
1164,
1380,
13763,
267,
7480,
314,
22483,
1242,
365,
8917,
1380,
314,
22483,
365,
315,
282,
13763,
16774,
14,
489,
365,
13,
19559,
1035,
486,
4871,
26,
6596,
11012,
267,
7480,
314,
22483,
1242,
365,
8652,
11012,
14,
3979,
9074,
4187,
12,
22483,
15766,
2498,
1318,
315,
598,
15263,
63,
9731,
13895,
63,
28784,
63,
40,
7123,
818,
2286,
6632,
2551,
687,
11424,
4076,
26,
489,
1050,
334,
18891,
3339,
9,
489,
2813,
334,
18891,
3339,
9,
489,
1104,
13,
8709,
6248,
489,
663,
13,
12283,
13,
1739,
334,
18891,
3339,
9,
2286,
19329,
687,
11424,
4076,
26,
489,
9162,
13,
2063,
1035,
486,
1635,
26,
699,
1648,
3462,
267,
710,
3462,
402,
314,
2701,
9162,
9682,
314,
15333,
4978,
489,
15210,
13,
632,
1035,
11424,
24559,
1385,
26,
799,
890,
818,
267,
13327,
4212,
15210,
4474,
787,
8860,
489,
1982,
1035,
11424,
3339,
26,
12988,
267,
6855,
506,
1202,
370,
1050,
282,
892,
1982,
370,
314,
3970,
2286,
6632,
2551,
687,
11424,
3339,
26,
489,
11395,
11669,
13,
2489,
6248,
489,
2498,
6248,
489,
13714,
6248,
489,
2341,
6248,
489,
625,
1130,
6248,
489,
3363,
794,
6248,
489,
625,
3093,
794,
6248,
489,
1568,
13,
1069,
334,
18891,
497,
21523,
9,
489,
1568,
13,
12991,
334,
39,
6341,
18127,
9,
489,
1174,
13,
2489,
334,
18891,
2223,
804,
9,
489,
1676,
13,
409,
334,
18891,
3339,
9,
489,
14446,
13,
2489,
334,
18891,
3339,
9,
489,
3449,
13,
409,
334,
18891,
6609,
9,
489,
7581,
13,
2489,
334,
18891,
1872,
17015,
9,
489,
18200,
13,
6814,
334,
71,
4871,
9,
489,
1982,
13,
6814,
334,
39,
4098,
9,
489,
18250,
16082,
13,
8222,
334,
71,
4871,
9,
1035,
486,
4871,
489,
18200,
13,
12283,
6248,
489,
16470,
334,
18891,
17015,
804,
9,
1035,
486,
4871,
489,
4057,
13,
12283,
334,
18891,
17015,
804,
9,
489,
1566,
334,
39,
6341,
2390,
9,
1035,
486,
4871,
489,
1566,
13,
4399,
334,
39,
6341,
2390,
9,
489,
5528,
13,
2915,
13,
1430,
334,
39,
6341,
2390,
9,
1035,
486,
4871,
489,
5528,
13,
3221,
13,
1430,
334,
39,
6341,
2390,
9,
1035,
486,
4871,
489,
13704,
13,
1430,
334,
39,
6341,
2390,
9,
1035,
486,
4871,
489,
25134,
13,
6814,
13,
1430,
334,
39,
6341,
2390,
9,
1035,
486,
4871,
489,
790,
10927,
13,
4892,
334,
18891,
17015,
804,
9,
1035,
486,
4871,
489,
3145,
13,
1430,
334,
39,
6341,
2390,
9,
1035,
486,
4871,
489,
11972,
13,
1430,
334,
39,
6341,
2390,
9,
1035,
486,
4871,
489,
23705,
13,
1430,
334,
39,
6341,
2390,
9,
1035,
486,
4871,
489,
790,
13,
2915,
13,
1430,
334,
39,
6341,
2390,
9,
1035,
486,
4871,
489,
790,
13,
3221,
13,
1430,
334,
39,
6341,
2390,
9,
1035,
486,
4871,
489,
9509,
13,
6814,
13,
1430,
334,
39,
6341,
2390,
9,
1035,
486,
4871,
489,
10137,
13,
6814,
13,
1430,
334,
39,
6341,
2390,
9,
1035,
486,
4871,
489,
7908,
13,
1430,
334,
39,
6341,
2390,
9,
1035,
486,
4871,
489,
16470,
13,
262,
13,
1430,
334,
39,
6341,
2390,
9,
1035,
486,
4871,
489,
16470,
13,
548,
13,
1430,
334,
39,
6341,
2390,
9,
1035,
486,
4871,
489,
2341,
13,
1430,
334,
39,
6341,
2390,
9,
1035,
486,
4871,
489,
625,
1130,
13,
1430,
334,
39,
6341,
2390,
9,
1035,
486,
4871,
489,
3324,
13,
6814,
13,
1430,
334,
39,
6341,
2390,
9,
1035,
486,
4871,
489,
7267,
13,
3584,
13,
1430,
334,
39,
6341,
2390,
9,
1035,
486,
4871,
489,
7267,
13,
1069,
13,
1430,
334,
39,
6341,
2390,
9,
1035,
486,
4871,
489,
7267,
13,
6814,
13,
1430,
334,
39,
6341,
2390,
9,
1035,
486,
4871,
489,
7267,
13,
9226,
334,
18891,
7713,
1451,
12,
486,
1635,
9,
489,
7267,
13,
362,
334,
18891,
7713,
1451,
12,
486,
1635,
12,
486,
1635,
9,
489,
10645,
1017,
1209,
13,
262,
13,
1430,
334,
39,
6341,
2390,
9,
1035,
486,
4871,
489,
10645,
1017,
1209,
13,
548,
13,
1430,
334,
39,
6341,
2390,
9,
1035,
486,
4871,
489,
18981,
13,
12422,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
jourdy345/pmtk3
|
python/conf.py
|
7
|
8205
|
# -*- coding: utf-8 -*-
#
# pmtk3-python documentation build configuration file, created by
# sphinx-quickstart on Thu Feb 27 20:20:05 2014.
#
# This file is execfile()d with the current directory set to its
# containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#
# All configuration values have a default; values that are commented out
# serve to show the default.
import sys
import os
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#sys.path.insert(0, os.path.abspath('.'))
# -- General configuration ------------------------------------------------
# If your documentation needs a minimal Sphinx version, state it here.
#needs_sphinx = '1.0'
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = []
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
# The suffix of source filenames.
source_suffix = '.rst'
# The encoding of source files.
#source_encoding = 'utf-8-sig'
# The master toctree document.
master_doc = 'index'
# General information about the project.
project = u'pmtk3-python'
copyright = u'2014, pmtk3-developers'
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = '0.1'
# The full version, including alpha/beta/rc tags.
release = '0.1'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#language = None
# There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used:
#today = ''
# Else, today_fmt is used as the format for a strftime call.
#today_fmt = '%B %d, %Y'
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
exclude_patterns = ['_build']
# The reST default role (used for this markup: `text`) to use for all
# documents.
#default_role = None
# If true, '()' will be appended to :func: etc. cross-reference text.
#add_function_parentheses = True
# If true, the current module name will be prepended to all description
# unit titles (such as .. function::).
#add_module_names = True
# If true, sectionauthor and moduleauthor directives will be shown in the
# output. They are ignored by default.
#show_authors = False
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
# A list of ignored prefixes for module index sorting.
#modindex_common_prefix = []
# If true, keep warnings as "system message" paragraphs in the built documents.
#keep_warnings = False
# -- Options for HTML output ----------------------------------------------
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
html_theme = 'default'
# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
#html_theme_options = {}
# Add any paths that contain custom themes here, relative to this directory.
#html_theme_path = []
# The name for this set of Sphinx documents. If None, it defaults to
# "<project> v<release> documentation".
#html_title = None
# A shorter title for the navigation bar. Default is the same as html_title.
#html_short_title = None
# The name of an image file (relative to this directory) to place at the top
# of the sidebar.
#html_logo = None
# The name of an image file (within the static path) to use as favicon of the
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
# pixels large.
#html_favicon = None
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
# Add any extra paths that contain custom files (such as robots.txt or
# .htaccess) here, relative to this directory. These files are copied
# directly to the root of the documentation.
#html_extra_path = []
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
# using the given strftime format.
#html_last_updated_fmt = '%b %d, %Y'
# If true, SmartyPants will be used to convert quotes and dashes to
# typographically correct entities.
#html_use_smartypants = True
# Custom sidebar templates, maps document names to template names.
#html_sidebars = {}
# Additional templates that should be rendered to pages, maps page names to
# template names.
#html_additional_pages = {}
# If false, no module index is generated.
#html_domain_indices = True
# If false, no index is generated.
#html_use_index = True
# If true, the index is split into individual pages for each letter.
#html_split_index = False
# If true, links to the reST sources are added to the pages.
#html_show_sourcelink = True
# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
#html_show_sphinx = True
# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
#html_show_copyright = True
# If true, an OpenSearch description file will be output, and all pages will
# contain a <link> tag referring to it. The value of this option must be the
# base URL from which the finished HTML is served.
#html_use_opensearch = ''
# This is the file name suffix for HTML files (e.g. ".xhtml").
#html_file_suffix = None
# Output file base name for HTML help builder.
htmlhelp_basename = 'pmtk3-pythondoc'
# -- Options for LaTeX output ---------------------------------------------
latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
#'papersize': 'letterpaper',
# The font size ('10pt', '11pt' or '12pt').
#'pointsize': '10pt',
# Additional stuff for the LaTeX preamble.
#'preamble': '',
}
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
('index', 'pmtk3-python.tex', u'pmtk3-python Documentation',
u'pmtk3-developers', 'manual'),
]
# The name of an image file (relative to this directory) to place at the top of
# the title page.
#latex_logo = None
# For "manual" documents, if this is true, then toplevel headings are parts,
# not chapters.
#latex_use_parts = False
# If true, show page references after internal links.
#latex_show_pagerefs = False
# If true, show URL addresses after external links.
#latex_show_urls = False
# Documents to append as an appendix to all manuals.
#latex_appendices = []
# If false, no module index is generated.
#latex_domain_indices = True
# -- Options for manual page output ---------------------------------------
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
('index', 'pmtk3-python', u'pmtk3-python Documentation',
[u'pmtk3-developers'], 1)
]
# If true, show URL addresses after external links.
#man_show_urls = False
# -- Options for Texinfo output -------------------------------------------
# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
('index', 'pmtk3-python', u'pmtk3-python Documentation',
u'pmtk3-developers', 'pmtk3-python', 'One line description of project.',
'Miscellaneous'),
]
# Documents to append as an appendix to all manuals.
#texinfo_appendices = []
# If false, no module index is generated.
#texinfo_domain_indices = True
# How to display URL addresses: 'footnote', 'no', or 'inline'.
#texinfo_show_urls = 'footnote'
# If true, do not generate a @detailmenu in the "Top" node's menu.
#texinfo_no_detailmenu = False
|
mit
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
199,
3,
30961,
75,
19,
13,
1548,
3794,
1900,
2897,
570,
12,
2737,
701,
199,
3,
15882,
13,
28957,
641,
3868,
85,
21141,
8087,
3388,
26,
1165,
26,
1717,
6927,
14,
199,
3,
199,
3,
961,
570,
365,
22711,
342,
68,
543,
314,
1453,
2082,
663,
370,
2399,
199,
3,
3035,
2935,
14,
199,
3,
199,
3,
3390,
626,
440,
1006,
3962,
2897,
1338,
787,
3451,
315,
642,
199,
3,
18392,
570,
14,
199,
3,
199,
3,
2900,
2897,
1338,
1172,
282,
849,
27,
1338,
626,
787,
21804,
734,
199,
3,
14062,
370,
2498,
314,
849,
14,
199,
199,
646,
984,
199,
646,
747,
199,
199,
3,
982,
5478,
334,
269,
4621,
370,
2213,
543,
29973,
9,
787,
315,
4573,
2082,
12,
199,
3,
1050,
3520,
6602,
370,
984,
14,
515,
2348,
14,
982,
314,
2082,
365,
3847,
370,
314,
199,
3,
3794,
1738,
12,
675,
747,
14,
515,
14,
4832,
370,
1852,
652,
3679,
12,
2839,
9164,
2348,
14,
199,
3,
1274,
14,
515,
14,
3176,
8,
16,
12,
747,
14,
515,
14,
4832,
24535,
199,
199,
3,
1553,
1696,
2897,
9527,
199,
199,
3,
982,
2195,
3794,
4839,
282,
13460,
10229,
1015,
12,
1174,
652,
2348,
14,
199,
3,
10065,
63,
8008,
275,
283,
17,
14,
16,
7,
199,
199,
3,
2654,
1263,
10229,
3329,
859,
1561,
2348,
12,
465,
3326,
14,
9322,
883,
506,
199,
3,
5478,
17262,
543,
10229,
334,
4579,
283,
8008,
14,
832,
24915,
503,
2195,
3537,
199,
3,
7869,
14,
199,
5359,
275,
942,
199,
199,
3,
2654,
1263,
3792,
626,
1395,
7009,
2348,
12,
3847,
370,
642,
2082,
14,
199,
5876,
63,
515,
275,
4044,
5876,
418,
199,
199,
3,
710,
4739,
402,
1350,
6203,
14,
199,
1365,
63,
4511,
275,
1987,
8332,
7,
199,
199,
3,
710,
2644,
402,
1350,
1584,
14,
199,
3,
1365,
63,
2991,
275,
283,
1624,
13,
24,
13,
4093,
7,
199,
199,
3,
710,
5288,
28310,
2213,
14,
199,
4133,
63,
1301,
275,
283,
1080,
7,
199,
199,
3,
1696,
2556,
3595,
314,
2199,
14,
199,
1715,
275,
399,
7,
80,
2037,
75,
19,
13,
1548,
7,
199,
7307,
275,
399,
7,
7280,
12,
30961,
75,
19,
13,
23826,
7,
199,
199,
3,
710,
1015,
2256,
367,
314,
2199,
1265,
3984,
29904,
12,
17795,
465,
8343,
367,
199,
3,
1204,
1023,
92,
436,
1204,
3221,
18712,
2597,
1202,
315,
7750,
1163,
9825,
23088,
314,
199,
3,
6137,
8247,
14,
199,
3,
199,
3,
710,
3974,
1323,
14,
57,
1015,
14,
199,
1023,
275,
283,
16,
14,
17,
7,
199,
3,
710,
2615,
1015,
12,
5893,
5131,
15,
5683,
15,
1195,
3762,
14,
199,
3221,
275,
283,
16,
14,
17,
7,
199,
199,
3,
710,
2637,
367,
1564,
18392,
701,
10229,
14,
21751,
370,
3794,
199,
3,
367,
282,
769,
402,
3748,
10815,
14,
199,
3,
3671,
275,
488,
199,
199,
3,
6006,
787,
2877,
1511,
367,
15810,
1204,
8136,
25004,
1902,
12,
1265,
663,
11168,
370,
2005,
199,
3,
2222,
13,
3910,
574,
12,
2066,
652,
365,
1202,
26,
199,
3,
8136,
275,
2125,
199,
3,
19524,
12,
11168,
63,
5045,
365,
1202,
465,
314,
1475,
367,
282,
14053,
1240,
14,
199,
3,
8136,
63,
5045,
275,
1543,
34,
450,
68,
12,
450,
57,
7,
199,
199,
3,
3820,
402,
7970,
12,
3847,
370,
1350,
2082,
12,
626,
1336,
1584,
436,
199,
3,
6602,
370,
3686,
1380,
10023,
367,
1350,
1584,
14,
199,
5473,
63,
7435,
275,
4044,
1506,
418,
199,
199,
3,
710,
20883,
849,
4719,
334,
2972,
367,
642,
9189,
26,
658,
505,
10522,
370,
675,
367,
1006,
199,
3,
8247,
14,
199,
3,
885,
63,
3756,
275,
488,
199,
199,
3,
982,
2549,
12,
26380,
911,
506,
11544,
370,
520,
1532,
26,
5423,
14,
8059,
13,
4443,
1318,
14,
199,
3,
525,
63,
1593,
63,
25510,
275,
715,
199,
199,
3,
982,
2549,
12,
314,
1453,
859,
536,
911,
506,
20247,
370,
1006,
1369,
199,
3,
4137,
16194,
334,
10180,
465,
2508,
805,
32469,
199,
3,
525,
63,
578,
63,
1247,
275,
715,
199,
199,
3,
982,
2549,
12,
3420,
2502,
436,
28966,
13502,
911,
506,
9164,
315,
314,
199,
3,
1072,
14,
9322,
787,
5525,
701,
849,
14,
199,
3,
2384,
63,
8149,
275,
756,
199,
199,
3,
710,
536,
402,
314,
14493,
334,
7093,
22437,
9,
3449,
370,
675,
14,
199,
12173,
63,
2487,
275,
283,
8008,
7,
199,
199,
3,
437,
769,
402,
5525,
13158,
367,
859,
1478,
13351,
14,
199,
3,
27555,
63,
2330,
63,
1861,
275,
942,
199,
199,
3,
982,
2549,
12,
4215,
3598,
465,
298,
2253,
1245,
2,
26603,
315,
314,
6137,
8247,
14,
199,
3,
3250,
63,
5451,
275,
756,
421,
199,
3,
1553,
8394,
367,
4163,
1072,
11016,
10965,
199,
199,
3,
710,
8879,
370,
675,
367,
4163,
436,
4163,
15456,
6497,
14,
221,
1666,
314,
3794,
367,
199,
3,
282,
769,
402,
6762,
17915,
14,
199,
1360,
63,
7915,
275,
283,
885,
7,
199,
199,
3,
23978,
1511,
787,
8879,
13,
6100,
436,
17551,
314,
3648,
436,
23109,
402,
282,
8879,
199,
3,
9848,
14,
221,
2104,
282,
769,
402,
1511,
2808,
367,
1924,
8879,
12,
1937,
314,
199,
3,
3794,
14,
199,
3,
1360,
63,
7915,
63,
1419,
275,
1052,
199,
199,
3,
2654,
1263,
3792,
626,
1395,
3537,
17915,
2348,
12,
3847,
370,
642,
2082,
14,
199,
3,
1360,
63,
7915,
63,
515,
275,
942,
199,
199,
3,
710,
536,
367,
642,
663,
402,
10229,
8247,
14,
221,
982,
488,
12,
652,
4243,
370,
199,
3,
3886,
1715,
30,
373,
28,
3221,
30,
3794,
1674,
199,
3,
1360,
63,
1213,
275,
488,
199,
199,
3,
437,
18299,
2538,
367,
314,
19191,
4681,
14,
221,
3758,
365,
314,
2011,
465,
3517,
63,
1213,
14,
199,
3,
1360,
63,
3612,
63,
1213,
275,
488,
199,
199,
3,
710,
536,
402,
376,
1834,
570,
334,
6188,
370,
642,
2082,
9,
370,
4192,
737,
314,
2746,
199,
3,
402,
314,
18437,
14,
199,
3,
1360,
63,
9733,
275,
488,
199,
199,
3,
710,
536,
402,
376,
1834,
570,
334,
12541,
314,
2955,
931,
9,
370,
675,
465,
29139,
402
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
199,
3,
30961,
75,
19,
13,
1548,
3794,
1900,
2897,
570,
12,
2737,
701,
199,
3,
15882,
13,
28957,
641,
3868,
85,
21141,
8087,
3388,
26,
1165,
26,
1717,
6927,
14,
199,
3,
199,
3,
961,
570,
365,
22711,
342,
68,
543,
314,
1453,
2082,
663,
370,
2399,
199,
3,
3035,
2935,
14,
199,
3,
199,
3,
3390,
626,
440,
1006,
3962,
2897,
1338,
787,
3451,
315,
642,
199,
3,
18392,
570,
14,
199,
3,
199,
3,
2900,
2897,
1338,
1172,
282,
849,
27,
1338,
626,
787,
21804,
734,
199,
3,
14062,
370,
2498,
314,
849,
14,
199,
199,
646,
984,
199,
646,
747,
199,
199,
3,
982,
5478,
334,
269,
4621,
370,
2213,
543,
29973,
9,
787,
315,
4573,
2082,
12,
199,
3,
1050,
3520,
6602,
370,
984,
14,
515,
2348,
14,
982,
314,
2082,
365,
3847,
370,
314,
199,
3,
3794,
1738,
12,
675,
747,
14,
515,
14,
4832,
370,
1852,
652,
3679,
12,
2839,
9164,
2348,
14,
199,
3,
1274,
14,
515,
14,
3176,
8,
16,
12,
747,
14,
515,
14,
4832,
24535,
199,
199,
3,
1553,
1696,
2897,
9527,
199,
199,
3,
982,
2195,
3794,
4839,
282,
13460,
10229,
1015,
12,
1174,
652,
2348,
14,
199,
3,
10065,
63,
8008,
275,
283,
17,
14,
16,
7,
199,
199,
3,
2654,
1263,
10229,
3329,
859,
1561,
2348,
12,
465,
3326,
14,
9322,
883,
506,
199,
3,
5478,
17262,
543,
10229,
334,
4579,
283,
8008,
14,
832,
24915,
503,
2195,
3537,
199,
3,
7869,
14,
199,
5359,
275,
942,
199,
199,
3,
2654,
1263,
3792,
626,
1395,
7009,
2348,
12,
3847,
370,
642,
2082,
14,
199,
5876,
63,
515,
275,
4044,
5876,
418,
199,
199,
3,
710,
4739,
402,
1350,
6203,
14,
199,
1365,
63,
4511,
275,
1987,
8332,
7,
199,
199,
3,
710,
2644,
402,
1350,
1584,
14,
199,
3,
1365,
63,
2991,
275,
283,
1624,
13,
24,
13,
4093,
7,
199,
199,
3,
710,
5288,
28310,
2213,
14,
199,
4133,
63,
1301,
275,
283,
1080,
7,
199,
199,
3,
1696,
2556,
3595,
314,
2199,
14,
199,
1715,
275,
399,
7,
80,
2037,
75,
19,
13,
1548,
7,
199,
7307,
275,
399,
7,
7280,
12,
30961,
75,
19,
13,
23826,
7,
199,
199,
3,
710,
1015,
2256,
367,
314,
2199,
1265,
3984,
29904,
12,
17795,
465,
8343,
367,
199,
3,
1204,
1023,
92,
436,
1204,
3221,
18712,
2597,
1202,
315,
7750,
1163,
9825,
23088,
314,
199,
3,
6137,
8247,
14,
199,
3,
199,
3,
710,
3974,
1323,
14,
57,
1015,
14,
199,
1023,
275,
283,
16,
14,
17,
7,
199,
3,
710,
2615,
1015,
12,
5893,
5131,
15,
5683,
15,
1195,
3762,
14,
199,
3221,
275,
283,
16,
14,
17,
7,
199,
199,
3,
710,
2637,
367,
1564,
18392,
701,
10229,
14,
21751,
370,
3794,
199,
3,
367,
282,
769,
402,
3748,
10815,
14,
199,
3,
3671,
275,
488,
199,
199,
3,
6006,
787,
2877,
1511,
367,
15810,
1204,
8136,
25004,
1902,
12,
1265,
663,
11168,
370,
2005,
199,
3,
2222,
13,
3910,
574,
12,
2066,
652,
365,
1202,
26,
199,
3,
8136,
275,
2125,
199,
3,
19524,
12,
11168,
63,
5045,
365,
1202,
465,
314,
1475,
367,
282,
14053,
1240,
14,
199,
3,
8136,
63,
5045,
275,
1543,
34,
450,
68,
12,
450,
57,
7,
199,
199,
3,
3820,
402,
7970,
12,
3847,
370,
1350,
2082,
12,
626,
1336,
1584,
436,
199,
3,
6602,
370,
3686,
1380,
10023,
367,
1350,
1584,
14,
199,
5473,
63,
7435,
275,
4044,
1506,
418,
199,
199,
3,
710,
20883,
849,
4719,
334,
2972,
367,
642,
9189,
26,
658,
505,
10522,
370,
675,
367,
1006,
199,
3,
8247,
14,
199,
3,
885,
63,
3756,
275,
488,
199,
199,
3,
982,
2549,
12,
26380,
911,
506,
11544,
370,
520,
1532,
26,
5423,
14,
8059,
13,
4443,
1318,
14,
199,
3,
525,
63,
1593,
63,
25510,
275,
715,
199,
199,
3,
982,
2549,
12,
314,
1453,
859,
536,
911,
506,
20247,
370,
1006,
1369,
199,
3,
4137,
16194,
334,
10180,
465,
2508,
805,
32469,
199,
3,
525,
63,
578,
63,
1247,
275,
715,
199,
199,
3,
982,
2549,
12,
3420,
2502,
436,
28966,
13502,
911,
506,
9164,
315,
314,
199,
3,
1072,
14,
9322,
787,
5525,
701,
849,
14,
199,
3,
2384,
63,
8149,
275,
756,
199,
199,
3,
710,
536,
402,
314,
14493,
334,
7093,
22437,
9,
3449,
370,
675,
14,
199,
12173,
63,
2487,
275,
283,
8008,
7,
199,
199,
3,
437,
769,
402,
5525,
13158,
367,
859,
1478,
13351,
14,
199,
3,
27555,
63,
2330,
63,
1861,
275,
942,
199,
199,
3,
982,
2549,
12,
4215,
3598,
465,
298,
2253,
1245,
2,
26603,
315,
314,
6137,
8247,
14,
199,
3,
3250,
63,
5451,
275,
756,
421,
199,
3,
1553,
8394,
367,
4163,
1072,
11016,
10965,
199,
199,
3,
710,
8879,
370,
675,
367,
4163,
436,
4163,
15456,
6497,
14,
221,
1666,
314,
3794,
367,
199,
3,
282,
769,
402,
6762,
17915,
14,
199,
1360,
63,
7915,
275,
283,
885,
7,
199,
199,
3,
23978,
1511,
787,
8879,
13,
6100,
436,
17551,
314,
3648,
436,
23109,
402,
282,
8879,
199,
3,
9848,
14,
221,
2104,
282,
769,
402,
1511,
2808,
367,
1924,
8879,
12,
1937,
314,
199,
3,
3794,
14,
199,
3,
1360,
63,
7915,
63,
1419,
275,
1052,
199,
199,
3,
2654,
1263,
3792,
626,
1395,
3537,
17915,
2348,
12,
3847,
370,
642,
2082,
14,
199,
3,
1360,
63,
7915,
63,
515,
275,
942,
199,
199,
3,
710,
536,
367,
642,
663,
402,
10229,
8247,
14,
221,
982,
488,
12,
652,
4243,
370,
199,
3,
3886,
1715,
30,
373,
28,
3221,
30,
3794,
1674,
199,
3,
1360,
63,
1213,
275,
488,
199,
199,
3,
437,
18299,
2538,
367,
314,
19191,
4681,
14,
221,
3758,
365,
314,
2011,
465,
3517,
63,
1213,
14,
199,
3,
1360,
63,
3612,
63,
1213,
275,
488,
199,
199,
3,
710,
536,
402,
376,
1834,
570,
334,
6188,
370,
642,
2082,
9,
370,
4192,
737,
314,
2746,
199,
3,
402,
314,
18437,
14,
199,
3,
1360,
63,
9733,
275,
488,
199,
199,
3,
710,
536,
402,
376,
1834,
570,
334,
12541,
314,
2955,
931,
9,
370,
675,
465,
29139,
402,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
sivaprakashniet/push_pull
|
p2p/lib/python2.7/site-packages/compressor/parser/default_htmlparser.py
|
1
|
3213
|
import sys
from django.utils import six
from django.utils.encoding import smart_text
from compressor.exceptions import ParserError
from compressor.parser import ParserBase
# Starting in Python 3.2, the HTMLParser constructor takes a 'strict'
# argument which default to True (which we don't want).
# In Python 3.3, it defaults to False.
# In Python 3.4, passing it at all raises a deprecation warning.
# So we only pass it for 3.2.
# In Python 3.4, it also takes a 'convert_charrefs' argument
# which raises a warning if we don't pass it.
major, minor, release = sys.version_info[:3]
CONSTRUCTOR_TAKES_STRICT = major == 3 and minor == 2
CONSTRUCTOR_TAKES_CONVERT_CHARREFS = major == 3 and minor >= 4
HTML_PARSER_ARGS = {}
if CONSTRUCTOR_TAKES_STRICT:
HTML_PARSER_ARGS['strict'] = False
if CONSTRUCTOR_TAKES_CONVERT_CHARREFS:
HTML_PARSER_ARGS['convert_charrefs'] = False
class DefaultHtmlParser(ParserBase, six.moves.html_parser.HTMLParser):
def __init__(self, content):
six.moves.html_parser.HTMLParser.__init__(self, **HTML_PARSER_ARGS)
self.content = content
self._css_elems = []
self._js_elems = []
self._current_tag = None
try:
self.feed(self.content)
self.close()
except Exception as err:
lineno = err.lineno
line = self.content.splitlines()[lineno]
raise ParserError("Error while initializing HtmlParser: %s (line: %s)" % (err, repr(line)))
def handle_starttag(self, tag, attrs):
tag = tag.lower()
if tag in ('style', 'script'):
if tag == 'style':
tags = self._css_elems
elif tag == 'script':
tags = self._js_elems
tags.append({
'tag': tag,
'attrs': attrs,
'attrs_dict': dict(attrs),
'text': ''
})
self._current_tag = tag
elif tag == 'link':
self._css_elems.append({
'tag': tag,
'attrs': attrs,
'attrs_dict': dict(attrs),
'text': None
})
def handle_endtag(self, tag):
if self._current_tag and self._current_tag == tag.lower():
self._current_tag = None
def handle_data(self, data):
if self._current_tag == 'style':
self._css_elems[-1]['text'] = data
elif self._current_tag == 'script':
self._js_elems[-1]['text'] = data
def css_elems(self):
return self._css_elems
def js_elems(self):
return self._js_elems
def elem_name(self, elem):
return elem['tag']
def elem_attribs(self, elem):
return elem['attrs_dict']
def elem_content(self, elem):
return smart_text(elem['text'])
def elem_str(self, elem):
tag = {}
tag.update(elem)
tag['attrs'] = ''
if len(elem['attrs']):
tag['attrs'] = ' %s' % ' '.join(['%s="%s"' % (name, value) for name, value in elem['attrs']])
if elem['tag'] == 'link':
return '<%(tag)s%(attrs)s />' % tag
else:
return '<%(tag)s%(attrs)s>%(text)s</%(tag)s>' % tag
|
bsd-3-clause
|
[
646,
984,
199,
199,
504,
1639,
14,
1208,
492,
3816,
199,
504,
1639,
14,
1208,
14,
2991,
492,
11179,
63,
505,
199,
199,
504,
11029,
269,
14,
3924,
492,
10191,
547,
199,
504,
11029,
269,
14,
2087,
492,
10191,
1563,
421,
199,
3,
24175,
315,
2018,
650,
14,
18,
12,
314,
24581,
3787,
6181,
282,
283,
4768,
7,
199,
3,
1423,
1314,
849,
370,
715,
334,
6777,
781,
2793,
1133,
2934,
680,
199,
3,
1010,
2018,
650,
14,
19,
12,
652,
4243,
370,
756,
14,
199,
3,
1010,
2018,
650,
14,
20,
12,
9476,
652,
737,
1006,
6534,
282,
17831,
5721,
14,
199,
3,
2002,
781,
1454,
986,
652,
367,
650,
14,
18,
14,
199,
3,
1010,
2018,
650,
14,
20,
12,
652,
2597,
6181,
282,
283,
3916,
63,
1560,
7655,
7,
1423,
199,
3,
1314,
6534,
282,
5721,
340,
781,
2793,
1133,
986,
652,
14,
199,
8452,
12,
12612,
12,
4683,
275,
984,
14,
1023,
63,
815,
1491,
19,
61,
199,
1864,
8893,
726,
63,
6166,
43,
654,
63,
3027,
6196,
275,
12160,
508,
650,
436,
12612,
508,
499,
199,
1864,
8893,
726,
63,
6166,
43,
654,
63,
1864,
8851,
63,
5901,
907,
7079,
275,
12160,
508,
650,
436,
12612,
2356,
841,
199,
4943,
63,
26078,
63,
13990,
275,
1052,
199,
692,
1868,
8893,
726,
63,
6166,
43,
654,
63,
3027,
6196,
26,
272,
4163,
63,
26078,
63,
13990,
459,
4768,
418,
275,
756,
199,
692,
1868,
8893,
726,
63,
6166,
43,
654,
63,
1864,
8851,
63,
5901,
907,
7079,
26,
272,
4163,
63,
26078,
63,
13990,
459,
3916,
63,
1560,
7655,
418,
275,
756,
421,
199,
533,
3758,
12957,
2842,
8,
2842,
1563,
12,
3816,
14,
4912,
14,
1360,
63,
2087,
14,
27375,
304,
272,
347,
636,
826,
721,
277,
12,
1564,
304,
267,
3816,
14,
4912,
14,
1360,
63,
2087,
14,
27375,
855,
826,
721,
277,
12,
1011,
4943,
63,
26078,
63,
13990,
9,
267,
291,
14,
1317,
275,
1564,
267,
291,
423,
3919,
63,
17482,
275,
942,
267,
291,
423,
3596,
63,
17482,
275,
942,
267,
291,
423,
1818,
63,
1450,
275,
488,
267,
862,
26,
288,
291,
14,
3871,
8,
277,
14,
1317,
9,
288,
291,
14,
1600,
342,
267,
871,
2186,
465,
2329,
26,
288,
5874,
275,
2329,
14,
3469,
288,
1004,
275,
291,
14,
1317,
14,
7644,
3430,
3469,
61,
288,
746,
10191,
547,
480,
547,
1830,
29141,
20880,
2842,
26,
450,
83,
334,
604,
26,
450,
83,
2924,
450,
334,
1508,
12,
4700,
8,
604,
1724,
339,
347,
2429,
63,
15234,
8,
277,
12,
1947,
12,
3290,
304,
267,
1947,
275,
1947,
14,
2325,
342,
267,
340,
1947,
315,
661,
2487,
297,
283,
1579,
735,
288,
340,
1947,
508,
283,
2487,
356,
355,
3762,
275,
291,
423,
3919,
63,
17482,
288,
916,
1947,
508,
283,
1579,
356,
355,
3762,
275,
291,
423,
3596,
63,
17482,
288,
3762,
14,
740,
2561,
355,
283,
1450,
356,
1947,
12,
355,
283,
3288,
356,
3290,
12,
355,
283,
3288,
63,
807,
356,
1211,
8,
3288,
395,
355,
283,
505,
356,
2125,
288,
3828,
288,
291,
423,
1818,
63,
1450,
275,
1947,
267,
916,
1947,
508,
283,
1073,
356,
288,
291,
423,
3919,
63,
17482,
14,
740,
2561,
355,
283,
1450,
356,
1947,
12,
355,
283,
3288,
356,
3290,
12,
355,
283,
3288,
63,
807,
356,
1211,
8,
3288,
395,
355,
283,
505,
356,
488,
288,
3828,
339,
347,
2429,
63,
25765,
8,
277,
12,
1947,
304,
267,
340,
291,
423,
1818,
63,
1450,
436,
291,
423,
1818,
63,
1450,
508,
1947,
14,
2325,
837,
288,
291,
423,
1818,
63,
1450,
275,
488,
339,
347,
2429,
63,
576,
8,
277,
12,
666,
304,
267,
340,
291,
423,
1818,
63,
1450,
508,
283,
2487,
356,
288,
291,
423,
3919,
63,
17482,
1988,
17,
2733,
505,
418,
275,
666,
267,
916,
291,
423,
1818,
63,
1450,
508,
283,
1579,
356,
288,
291,
423,
3596,
63,
17482,
1988,
17,
2733,
505,
418,
275,
666,
339,
347,
11431,
63,
17482,
8,
277,
304,
267,
372,
291,
423,
3919,
63,
17482,
339,
347,
8586,
63,
17482,
8,
277,
304,
267,
372,
291,
423,
3596,
63,
17482,
339,
347,
6193,
63,
354,
8,
277,
12,
6193,
304,
267,
372,
6193,
459,
1450,
418,
339,
347,
6193,
63,
30674,
8,
277,
12,
6193,
304,
267,
372,
6193,
459,
3288,
63,
807,
418,
339,
347,
6193,
63,
1317,
8,
277,
12,
6193,
304,
267,
372,
11179,
63,
505,
8,
6086,
459,
505,
1105,
339,
347,
6193,
63,
495,
8,
277,
12,
6193,
304,
267,
1947,
275,
1052,
267,
1947,
14,
873,
8,
6086,
9,
267,
1947,
459,
3288,
418,
275,
2125,
267,
340,
822,
8,
6086,
459,
3288,
9090,
288,
1947,
459,
3288,
418,
275,
283,
450,
83,
7,
450,
283,
1987,
904,
26861,
83,
5961,
83,
4507,
450,
334,
354,
12,
574,
9,
367,
536,
12,
574,
315,
6193,
459,
3288,
12121,
267,
340,
6193,
459,
1450,
418,
508,
283,
1073,
356,
288,
372,
2650,
2840,
1450,
9,
83,
2840,
3288,
9,
83,
22294,
450,
1947,
267,
587,
26,
288,
372,
2650,
2840,
1450,
9,
83,
2840,
3288,
9,
83,
19418,
505,
9,
83,
1108,
2840,
1450,
9,
83,
3524,
450,
1947,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
984,
199,
199,
504,
1639,
14,
1208,
492,
3816,
199,
504,
1639,
14,
1208,
14,
2991,
492,
11179,
63,
505,
199,
199,
504,
11029,
269,
14,
3924,
492,
10191,
547,
199,
504,
11029,
269,
14,
2087,
492,
10191,
1563,
421,
199,
3,
24175,
315,
2018,
650,
14,
18,
12,
314,
24581,
3787,
6181,
282,
283,
4768,
7,
199,
3,
1423,
1314,
849,
370,
715,
334,
6777,
781,
2793,
1133,
2934,
680,
199,
3,
1010,
2018,
650,
14,
19,
12,
652,
4243,
370,
756,
14,
199,
3,
1010,
2018,
650,
14,
20,
12,
9476,
652,
737,
1006,
6534,
282,
17831,
5721,
14,
199,
3,
2002,
781,
1454,
986,
652,
367,
650,
14,
18,
14,
199,
3,
1010,
2018,
650,
14,
20,
12,
652,
2597,
6181,
282,
283,
3916,
63,
1560,
7655,
7,
1423,
199,
3,
1314,
6534,
282,
5721,
340,
781,
2793,
1133,
986,
652,
14,
199,
8452,
12,
12612,
12,
4683,
275,
984,
14,
1023,
63,
815,
1491,
19,
61,
199,
1864,
8893,
726,
63,
6166,
43,
654,
63,
3027,
6196,
275,
12160,
508,
650,
436,
12612,
508,
499,
199,
1864,
8893,
726,
63,
6166,
43,
654,
63,
1864,
8851,
63,
5901,
907,
7079,
275,
12160,
508,
650,
436,
12612,
2356,
841,
199,
4943,
63,
26078,
63,
13990,
275,
1052,
199,
692,
1868,
8893,
726,
63,
6166,
43,
654,
63,
3027,
6196,
26,
272,
4163,
63,
26078,
63,
13990,
459,
4768,
418,
275,
756,
199,
692,
1868,
8893,
726,
63,
6166,
43,
654,
63,
1864,
8851,
63,
5901,
907,
7079,
26,
272,
4163,
63,
26078,
63,
13990,
459,
3916,
63,
1560,
7655,
418,
275,
756,
421,
199,
533,
3758,
12957,
2842,
8,
2842,
1563,
12,
3816,
14,
4912,
14,
1360,
63,
2087,
14,
27375,
304,
272,
347,
636,
826,
721,
277,
12,
1564,
304,
267,
3816,
14,
4912,
14,
1360,
63,
2087,
14,
27375,
855,
826,
721,
277,
12,
1011,
4943,
63,
26078,
63,
13990,
9,
267,
291,
14,
1317,
275,
1564,
267,
291,
423,
3919,
63,
17482,
275,
942,
267,
291,
423,
3596,
63,
17482,
275,
942,
267,
291,
423,
1818,
63,
1450,
275,
488,
267,
862,
26,
288,
291,
14,
3871,
8,
277,
14,
1317,
9,
288,
291,
14,
1600,
342,
267,
871,
2186,
465,
2329,
26,
288,
5874,
275,
2329,
14,
3469,
288,
1004,
275,
291,
14,
1317,
14,
7644,
3430,
3469,
61,
288,
746,
10191,
547,
480,
547,
1830,
29141,
20880,
2842,
26,
450,
83,
334,
604,
26,
450,
83,
2924,
450,
334,
1508,
12,
4700,
8,
604,
1724,
339,
347,
2429,
63,
15234,
8,
277,
12,
1947,
12,
3290,
304,
267,
1947,
275,
1947,
14,
2325,
342,
267,
340,
1947,
315,
661,
2487,
297,
283,
1579,
735,
288,
340,
1947,
508,
283,
2487,
356,
355,
3762,
275,
291,
423,
3919,
63,
17482,
288,
916,
1947,
508,
283,
1579,
356,
355,
3762,
275,
291,
423,
3596,
63,
17482,
288,
3762,
14,
740,
2561,
355,
283,
1450,
356,
1947,
12,
355,
283,
3288,
356,
3290,
12,
355,
283,
3288,
63,
807,
356,
1211,
8,
3288,
395,
355,
283,
505,
356,
2125,
288,
3828,
288,
291,
423,
1818,
63,
1450,
275,
1947,
267,
916,
1947,
508,
283,
1073,
356,
288,
291,
423,
3919,
63,
17482,
14,
740,
2561,
355,
283,
1450,
356,
1947,
12,
355,
283,
3288,
356,
3290,
12,
355,
283,
3288,
63,
807,
356,
1211,
8,
3288,
395,
355,
283,
505,
356,
488,
288,
3828,
339,
347,
2429,
63,
25765,
8,
277,
12,
1947,
304,
267,
340,
291,
423,
1818,
63,
1450,
436,
291,
423,
1818,
63,
1450,
508,
1947,
14,
2325,
837,
288,
291,
423,
1818,
63,
1450,
275,
488,
339,
347,
2429,
63,
576,
8,
277,
12,
666,
304,
267,
340,
291,
423,
1818,
63,
1450,
508,
283,
2487,
356,
288,
291,
423,
3919,
63,
17482,
1988,
17,
2733,
505,
418,
275,
666,
267,
916,
291,
423,
1818,
63,
1450,
508,
283,
1579,
356,
288,
291,
423,
3596,
63,
17482,
1988,
17,
2733,
505,
418,
275,
666,
339,
347,
11431,
63,
17482,
8,
277,
304,
267,
372,
291,
423,
3919,
63,
17482,
339,
347,
8586,
63,
17482,
8,
277,
304,
267,
372,
291,
423,
3596,
63,
17482,
339,
347,
6193,
63,
354,
8,
277,
12,
6193,
304,
267,
372,
6193,
459,
1450,
418,
339,
347,
6193,
63,
30674,
8,
277,
12,
6193,
304,
267,
372,
6193,
459,
3288,
63,
807,
418,
339,
347,
6193,
63,
1317,
8,
277,
12,
6193,
304,
267,
372,
11179,
63,
505,
8,
6086,
459,
505,
1105,
339,
347,
6193,
63,
495,
8,
277,
12,
6193,
304,
267,
1947,
275,
1052,
267,
1947,
14,
873,
8,
6086,
9,
267,
1947,
459,
3288,
418,
275,
2125,
267,
340,
822,
8,
6086,
459,
3288,
9090,
288,
1947,
459,
3288,
418,
275,
283,
450,
83,
7,
450,
283,
1987,
904,
26861,
83,
5961,
83,
4507,
450,
334,
354,
12,
574,
9,
367,
536,
12,
574,
315,
6193,
459,
3288,
12121,
267,
340,
6193,
459,
1450,
418,
508,
283,
1073,
356,
288,
372,
2650,
2840,
1450,
9,
83,
2840,
3288,
9,
83,
22294,
450,
1947,
267,
587,
26,
288,
372,
2650,
2840,
1450,
9,
83,
2840,
3288,
9,
83,
19418,
505,
9,
83,
1108,
2840,
1450,
9,
83,
3524,
450,
1947,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
louietsai/python-for-android
|
python3-alpha/python3-src/Lib/sqlite3/test/factory.py
|
46
|
7816
|
#-*- coding: ISO-8859-1 -*-
# pysqlite2/test/factory.py: tests for the various factories in pysqlite
#
# Copyright (C) 2005-2007 Gerhard Häring <gh@ghaering.de>
#
# This file is part of pysqlite.
#
# This software is provided 'as-is', without any express or implied
# warranty. In no event will the authors be held liable for any damages
# arising from the use of this software.
#
# Permission is granted to anyone to use this software for any purpose,
# including commercial applications, and to alter it and redistribute it
# freely, subject to the following restrictions:
#
# 1. The origin of this software must not be misrepresented; you must not
# claim that you wrote the original software. If you use this software
# in a product, an acknowledgment in the product documentation would be
# appreciated but is not required.
# 2. Altered source versions must be plainly marked as such, and must not be
# misrepresented as being the original software.
# 3. This notice may not be removed or altered from any source distribution.
import unittest
import sqlite3 as sqlite
class MyConnection(sqlite.Connection):
def __init__(self, *args, **kwargs):
sqlite.Connection.__init__(self, *args, **kwargs)
def dict_factory(cursor, row):
d = {}
for idx, col in enumerate(cursor.description):
d[col[0]] = row[idx]
return d
class MyCursor(sqlite.Cursor):
def __init__(self, *args, **kwargs):
sqlite.Cursor.__init__(self, *args, **kwargs)
self.row_factory = dict_factory
class ConnectionFactoryTests(unittest.TestCase):
def setUp(self):
self.con = sqlite.connect(":memory:", factory=MyConnection)
def tearDown(self):
self.con.close()
def CheckIsInstance(self):
self.assertTrue(isinstance(self.con,
MyConnection),
"connection is not instance of MyConnection")
class CursorFactoryTests(unittest.TestCase):
def setUp(self):
self.con = sqlite.connect(":memory:")
def tearDown(self):
self.con.close()
def CheckIsInstance(self):
cur = self.con.cursor(factory=MyCursor)
self.assertTrue(isinstance(cur,
MyCursor),
"cursor is not instance of MyCursor")
class RowFactoryTestsBackwardsCompat(unittest.TestCase):
def setUp(self):
self.con = sqlite.connect(":memory:")
def CheckIsProducedByFactory(self):
cur = self.con.cursor(factory=MyCursor)
cur.execute("select 4+5 as foo")
row = cur.fetchone()
self.assertTrue(isinstance(row,
dict),
"row is not instance of dict")
cur.close()
def tearDown(self):
self.con.close()
class RowFactoryTests(unittest.TestCase):
def setUp(self):
self.con = sqlite.connect(":memory:")
def CheckCustomFactory(self):
self.con.row_factory = lambda cur, row: list(row)
row = self.con.execute("select 1, 2").fetchone()
self.assertTrue(isinstance(row,
list),
"row is not instance of list")
def CheckSqliteRowIndex(self):
self.con.row_factory = sqlite.Row
row = self.con.execute("select 1 as a, 2 as b").fetchone()
self.assertTrue(isinstance(row,
sqlite.Row),
"row is not instance of sqlite.Row")
col1, col2 = row["a"], row["b"]
self.assertTrue(col1 == 1, "by name: wrong result for column 'a'")
self.assertTrue(col2 == 2, "by name: wrong result for column 'a'")
col1, col2 = row["A"], row["B"]
self.assertTrue(col1 == 1, "by name: wrong result for column 'A'")
self.assertTrue(col2 == 2, "by name: wrong result for column 'B'")
col1, col2 = row[0], row[1]
self.assertTrue(col1 == 1, "by index: wrong result for column 0")
self.assertTrue(col2 == 2, "by index: wrong result for column 1")
def CheckSqliteRowIter(self):
"""Checks if the row object is iterable"""
self.con.row_factory = sqlite.Row
row = self.con.execute("select 1 as a, 2 as b").fetchone()
for col in row:
pass
def CheckSqliteRowAsTuple(self):
"""Checks if the row object can be converted to a tuple"""
self.con.row_factory = sqlite.Row
row = self.con.execute("select 1 as a, 2 as b").fetchone()
t = tuple(row)
def CheckSqliteRowAsDict(self):
"""Checks if the row object can be correctly converted to a dictionary"""
self.con.row_factory = sqlite.Row
row = self.con.execute("select 1 as a, 2 as b").fetchone()
d = dict(row)
self.assertEqual(d["a"], row["a"])
self.assertEqual(d["b"], row["b"])
def CheckSqliteRowHashCmp(self):
"""Checks if the row object compares and hashes correctly"""
self.con.row_factory = sqlite.Row
row_1 = self.con.execute("select 1 as a, 2 as b").fetchone()
row_2 = self.con.execute("select 1 as a, 2 as b").fetchone()
row_3 = self.con.execute("select 1 as a, 3 as b").fetchone()
self.assertTrue(row_1 == row_1)
self.assertTrue(row_1 == row_2)
self.assertTrue(row_2 != row_3)
self.assertFalse(row_1 != row_1)
self.assertFalse(row_1 != row_2)
self.assertFalse(row_2 == row_3)
self.assertEqual(row_1, row_2)
self.assertEqual(hash(row_1), hash(row_2))
self.assertNotEqual(row_1, row_3)
self.assertNotEqual(hash(row_1), hash(row_3))
def tearDown(self):
self.con.close()
class TextFactoryTests(unittest.TestCase):
def setUp(self):
self.con = sqlite.connect(":memory:")
def CheckUnicode(self):
austria = "Österreich"
row = self.con.execute("select ?", (austria,)).fetchone()
self.assertTrue(type(row[0]) == str, "type of row[0] must be unicode")
def CheckString(self):
self.con.text_factory = bytes
austria = "Österreich"
row = self.con.execute("select ?", (austria,)).fetchone()
self.assertTrue(type(row[0]) == bytes, "type of row[0] must be bytes")
self.assertTrue(row[0] == austria.encode("utf-8"), "column must equal original data in UTF-8")
def CheckCustom(self):
self.con.text_factory = lambda x: str(x, "utf-8", "ignore")
austria = "Österreich"
row = self.con.execute("select ?", (austria,)).fetchone()
self.assertTrue(type(row[0]) == str, "type of row[0] must be unicode")
self.assertTrue(row[0].endswith("reich"), "column must contain original data")
def CheckOptimizedUnicode(self):
self.con.text_factory = sqlite.OptimizedUnicode
austria = "Österreich"
germany = "Deutchland"
a_row = self.con.execute("select ?", (austria,)).fetchone()
d_row = self.con.execute("select ?", (germany,)).fetchone()
self.assertTrue(type(a_row[0]) == str, "type of non-ASCII row must be str")
self.assertTrue(type(d_row[0]) == str, "type of ASCII-only row must be str")
def tearDown(self):
self.con.close()
def suite():
connection_suite = unittest.makeSuite(ConnectionFactoryTests, "Check")
cursor_suite = unittest.makeSuite(CursorFactoryTests, "Check")
row_suite_compat = unittest.makeSuite(RowFactoryTestsBackwardsCompat, "Check")
row_suite = unittest.makeSuite(RowFactoryTests, "Check")
text_suite = unittest.makeSuite(TextFactoryTests, "Check")
return unittest.TestSuite((connection_suite, cursor_suite, row_suite_compat, row_suite, text_suite))
def test():
runner = unittest.TextTestRunner()
runner.run(suite())
if __name__ == "__main__":
test()
|
apache-2.0
|
[
3,
13,
1837,
2803,
26,
9055,
13,
4830,
13,
17,
1882,
199,
3,
10382,
29498,
18,
15,
396,
15,
3702,
14,
647,
26,
2295,
367,
314,
7750,
22115,
315,
10382,
29498,
199,
3,
199,
3,
1898,
334,
35,
9,
11811,
13,
9488,
22261,
8726,
869,
13733,
5985,
665,
3561,
32,
71,
2411,
15663,
14,
271,
30,
199,
3,
199,
3,
961,
570,
365,
1777,
402,
10382,
29498,
14,
199,
3,
199,
3,
961,
2032,
365,
2741,
283,
305,
13,
374,
297,
1928,
1263,
4056,
503,
2478,
199,
3,
3750,
14,
221,
1010,
949,
1566,
911,
314,
11462,
506,
23608,
1212,
461,
367,
1263,
12927,
960,
83,
199,
3,
14554,
1044,
687,
314,
675,
402,
642,
2032,
14,
199,
3,
199,
3,
8779,
365,
10009,
370,
29165,
370,
675,
642,
2032,
367,
1263,
12016,
12,
199,
3,
5893,
2414,
23012,
13103,
12,
436,
370,
17355,
652,
436,
3604,
652,
199,
3,
20673,
7742,
12,
5420,
370,
314,
2569,
24488,
26,
199,
3,
199,
3,
413,
14,
710,
6330,
402,
642,
2032,
1471,
440,
506,
3201,
264,
10317,
27,
1265,
1471,
440,
199,
3,
259,
22498,
626,
1265,
336,
22665,
314,
3379,
2032,
14,
982,
1265,
675,
642,
2032,
199,
3,
259,
315,
282,
3336,
12,
376,
19807,
28609,
4740,
315,
314,
3336,
3794,
3955,
506,
199,
3,
259,
2771,
20940,
972,
1325,
365,
440,
1415,
14,
199,
3,
499,
14,
4580,
3014,
1350,
5459,
1471,
506,
8971,
590,
11584,
465,
4066,
12,
436,
1471,
440,
506,
199,
3,
259,
3201,
264,
10317,
465,
3769,
314,
3379,
2032,
14,
199,
3,
650,
14,
961,
4245,
1443,
440,
506,
4829,
503,
29815,
687,
1263,
1350,
4084,
14,
199,
199,
646,
2882,
199,
646,
11723,
19,
465,
11723,
199,
199,
533,
4932,
3225,
8,
10659,
14,
3225,
304,
272,
347,
636,
826,
721,
277,
12,
627,
589,
12,
1011,
958,
304,
267,
11723,
14,
3225,
855,
826,
721,
277,
12,
627,
589,
12,
1011,
958,
9,
199,
199,
318,
1211,
63,
3702,
8,
3937,
12,
1962,
304,
272,
366,
275,
1052,
272,
367,
4280,
12,
1048,
315,
3874,
8,
3937,
14,
1802,
304,
267,
366,
59,
761,
59,
16,
2677,
275,
1962,
59,
2996,
61,
272,
372,
366,
199,
199,
533,
4932,
8993,
8,
10659,
14,
8993,
304,
272,
347,
636,
826,
721,
277,
12,
627,
589,
12,
1011,
958,
304,
267,
11723,
14,
8993,
855,
826,
721,
277,
12,
627,
589,
12,
1011,
958,
9,
267,
291,
14,
1143,
63,
3702,
275,
1211,
63,
3702,
199,
199,
533,
8113,
2927,
2925,
8,
2796,
14,
1746,
304,
272,
347,
3613,
8,
277,
304,
267,
291,
14,
388,
275,
11723,
14,
2242,
20308,
4844,
6783,
6434,
29,
5713,
3225,
9,
339,
347,
6766,
8,
277,
304,
267,
291,
14,
388,
14,
1600,
342,
339,
347,
2670,
1831,
3244,
8,
277,
304,
267,
291,
14,
1815,
8,
6074,
8,
277,
14,
388,
12,
3521,
4932,
3225,
395,
717,
298,
2105,
365,
440,
1256,
402,
4932,
3225,
531,
199,
199,
533,
20385,
2927,
2925,
8,
2796,
14,
1746,
304,
272,
347,
3613,
8,
277,
304,
267,
291,
14,
388,
275,
11723,
14,
2242,
20308,
4844,
9107,
339,
347,
6766,
8,
277,
304,
267,
291,
14,
388,
14,
1600,
342,
339,
347,
2670,
1831,
3244,
8,
277,
304,
267,
1094,
275,
291,
14,
388,
14,
3937,
8,
3702,
29,
5713,
8993,
9,
267,
291,
14,
1815,
8,
6074,
8,
895,
12,
3521,
4932,
8993,
395,
717,
298,
3937,
365,
440,
1256,
402,
4932,
8993,
531,
199,
199,
533,
15231,
2927,
2925,
4540,
4751,
2404,
292,
8,
2796,
14,
1746,
304,
272,
347,
3613,
8,
277,
304,
267,
291,
14,
388,
275,
11723,
14,
2242,
20308,
4844,
9107,
339,
347,
2670,
1831,
919,
16584,
2175,
2927,
8,
277,
304,
267,
1094,
275,
291,
14,
388,
14,
3937,
8,
3702,
29,
5713,
8993,
9,
267,
1094,
14,
2526,
480,
2416,
841,
11,
21,
465,
3925,
531,
267,
1962,
275,
1094,
14,
11591,
342,
267,
291,
14,
1815,
8,
6074,
8,
1143,
12,
3521,
1211,
395,
717,
298,
1143,
365,
440,
1256,
402,
1211,
531,
267,
1094,
14,
1600,
342,
339,
347,
6766,
8,
277,
304,
267,
291,
14,
388,
14,
1600,
342,
199,
199,
533,
15231,
2927,
2925,
8,
2796,
14,
1746,
304,
272,
347,
3613,
8,
277,
304,
267,
291,
14,
388,
275,
11723,
14,
2242,
20308,
4844,
9107,
339,
347,
2670,
7223,
2927,
8,
277,
304,
267,
291,
14,
388,
14,
1143,
63,
3702,
275,
2400,
1094,
12,
1962,
26,
769,
8,
1143,
9,
267,
1962,
275,
291,
14,
388,
14,
2526,
480,
2416,
413,
12,
499,
3471,
11591,
342,
267,
291,
14,
1815,
8,
6074,
8,
1143,
12,
3521,
769,
395,
717,
298,
1143,
365,
440,
1256,
402,
769,
531,
339,
347,
2670,
24614,
5333,
5810,
2681,
8,
277,
304,
267,
291,
14,
388,
14,
1143,
63,
3702,
275,
11723,
14,
5810,
267,
1962,
275,
291,
14,
388,
14,
2526,
480,
2416,
413,
465,
282,
12,
499,
465,
330,
3471,
11591,
342,
267,
291,
14,
1815,
8,
6074,
8,
1143,
12,
3521,
11723,
14,
5810,
395,
717,
298,
1143,
365,
440,
1256,
402,
11723,
14,
5810,
531,
398,
1048,
17,
12,
1048,
18,
275,
1962,
905,
65,
2255,
1962,
905,
66,
937,
267,
291,
14,
1815,
8,
761,
17,
508,
413,
12,
298,
991,
536,
26,
6835,
754,
367,
2763,
283,
65,
9859,
267,
291,
14,
1815,
8,
761,
18,
508,
499,
12,
298,
991,
536,
26,
6835,
754,
367,
2763,
283,
65,
9859,
398,
1048,
17,
12,
1048,
18,
275,
1962,
905,
33,
2255,
1962,
905,
34,
937,
267,
291,
14,
1815,
8,
761,
17,
508,
413,
12,
298,
991,
536,
26,
6835,
754,
367,
2763,
283,
33,
9859,
267,
291,
14,
1815,
8,
761,
18,
508,
499,
12,
298,
991,
536,
26,
6835,
754,
367,
2763,
283,
34,
9859,
398,
1048,
17,
12,
1048,
18,
275,
1962,
59,
16,
467,
1962,
59,
17,
61,
267,
291,
14,
1815,
8,
761,
17,
508,
413,
12,
298,
991,
1478,
26,
6835,
754,
367,
2763,
378,
531,
267,
291,
14,
1815,
8,
761,
18,
508,
499,
12,
298,
991,
1478,
26,
6835,
754,
367,
2763,
413,
531,
339,
347,
2670,
24614,
5333
] |
[
13,
1837,
2803,
26,
9055,
13,
4830,
13,
17,
1882,
199,
3,
10382,
29498,
18,
15,
396,
15,
3702,
14,
647,
26,
2295,
367,
314,
7750,
22115,
315,
10382,
29498,
199,
3,
199,
3,
1898,
334,
35,
9,
11811,
13,
9488,
22261,
8726,
869,
13733,
5985,
665,
3561,
32,
71,
2411,
15663,
14,
271,
30,
199,
3,
199,
3,
961,
570,
365,
1777,
402,
10382,
29498,
14,
199,
3,
199,
3,
961,
2032,
365,
2741,
283,
305,
13,
374,
297,
1928,
1263,
4056,
503,
2478,
199,
3,
3750,
14,
221,
1010,
949,
1566,
911,
314,
11462,
506,
23608,
1212,
461,
367,
1263,
12927,
960,
83,
199,
3,
14554,
1044,
687,
314,
675,
402,
642,
2032,
14,
199,
3,
199,
3,
8779,
365,
10009,
370,
29165,
370,
675,
642,
2032,
367,
1263,
12016,
12,
199,
3,
5893,
2414,
23012,
13103,
12,
436,
370,
17355,
652,
436,
3604,
652,
199,
3,
20673,
7742,
12,
5420,
370,
314,
2569,
24488,
26,
199,
3,
199,
3,
413,
14,
710,
6330,
402,
642,
2032,
1471,
440,
506,
3201,
264,
10317,
27,
1265,
1471,
440,
199,
3,
259,
22498,
626,
1265,
336,
22665,
314,
3379,
2032,
14,
982,
1265,
675,
642,
2032,
199,
3,
259,
315,
282,
3336,
12,
376,
19807,
28609,
4740,
315,
314,
3336,
3794,
3955,
506,
199,
3,
259,
2771,
20940,
972,
1325,
365,
440,
1415,
14,
199,
3,
499,
14,
4580,
3014,
1350,
5459,
1471,
506,
8971,
590,
11584,
465,
4066,
12,
436,
1471,
440,
506,
199,
3,
259,
3201,
264,
10317,
465,
3769,
314,
3379,
2032,
14,
199,
3,
650,
14,
961,
4245,
1443,
440,
506,
4829,
503,
29815,
687,
1263,
1350,
4084,
14,
199,
199,
646,
2882,
199,
646,
11723,
19,
465,
11723,
199,
199,
533,
4932,
3225,
8,
10659,
14,
3225,
304,
272,
347,
636,
826,
721,
277,
12,
627,
589,
12,
1011,
958,
304,
267,
11723,
14,
3225,
855,
826,
721,
277,
12,
627,
589,
12,
1011,
958,
9,
199,
199,
318,
1211,
63,
3702,
8,
3937,
12,
1962,
304,
272,
366,
275,
1052,
272,
367,
4280,
12,
1048,
315,
3874,
8,
3937,
14,
1802,
304,
267,
366,
59,
761,
59,
16,
2677,
275,
1962,
59,
2996,
61,
272,
372,
366,
199,
199,
533,
4932,
8993,
8,
10659,
14,
8993,
304,
272,
347,
636,
826,
721,
277,
12,
627,
589,
12,
1011,
958,
304,
267,
11723,
14,
8993,
855,
826,
721,
277,
12,
627,
589,
12,
1011,
958,
9,
267,
291,
14,
1143,
63,
3702,
275,
1211,
63,
3702,
199,
199,
533,
8113,
2927,
2925,
8,
2796,
14,
1746,
304,
272,
347,
3613,
8,
277,
304,
267,
291,
14,
388,
275,
11723,
14,
2242,
20308,
4844,
6783,
6434,
29,
5713,
3225,
9,
339,
347,
6766,
8,
277,
304,
267,
291,
14,
388,
14,
1600,
342,
339,
347,
2670,
1831,
3244,
8,
277,
304,
267,
291,
14,
1815,
8,
6074,
8,
277,
14,
388,
12,
3521,
4932,
3225,
395,
717,
298,
2105,
365,
440,
1256,
402,
4932,
3225,
531,
199,
199,
533,
20385,
2927,
2925,
8,
2796,
14,
1746,
304,
272,
347,
3613,
8,
277,
304,
267,
291,
14,
388,
275,
11723,
14,
2242,
20308,
4844,
9107,
339,
347,
6766,
8,
277,
304,
267,
291,
14,
388,
14,
1600,
342,
339,
347,
2670,
1831,
3244,
8,
277,
304,
267,
1094,
275,
291,
14,
388,
14,
3937,
8,
3702,
29,
5713,
8993,
9,
267,
291,
14,
1815,
8,
6074,
8,
895,
12,
3521,
4932,
8993,
395,
717,
298,
3937,
365,
440,
1256,
402,
4932,
8993,
531,
199,
199,
533,
15231,
2927,
2925,
4540,
4751,
2404,
292,
8,
2796,
14,
1746,
304,
272,
347,
3613,
8,
277,
304,
267,
291,
14,
388,
275,
11723,
14,
2242,
20308,
4844,
9107,
339,
347,
2670,
1831,
919,
16584,
2175,
2927,
8,
277,
304,
267,
1094,
275,
291,
14,
388,
14,
3937,
8,
3702,
29,
5713,
8993,
9,
267,
1094,
14,
2526,
480,
2416,
841,
11,
21,
465,
3925,
531,
267,
1962,
275,
1094,
14,
11591,
342,
267,
291,
14,
1815,
8,
6074,
8,
1143,
12,
3521,
1211,
395,
717,
298,
1143,
365,
440,
1256,
402,
1211,
531,
267,
1094,
14,
1600,
342,
339,
347,
6766,
8,
277,
304,
267,
291,
14,
388,
14,
1600,
342,
199,
199,
533,
15231,
2927,
2925,
8,
2796,
14,
1746,
304,
272,
347,
3613,
8,
277,
304,
267,
291,
14,
388,
275,
11723,
14,
2242,
20308,
4844,
9107,
339,
347,
2670,
7223,
2927,
8,
277,
304,
267,
291,
14,
388,
14,
1143,
63,
3702,
275,
2400,
1094,
12,
1962,
26,
769,
8,
1143,
9,
267,
1962,
275,
291,
14,
388,
14,
2526,
480,
2416,
413,
12,
499,
3471,
11591,
342,
267,
291,
14,
1815,
8,
6074,
8,
1143,
12,
3521,
769,
395,
717,
298,
1143,
365,
440,
1256,
402,
769,
531,
339,
347,
2670,
24614,
5333,
5810,
2681,
8,
277,
304,
267,
291,
14,
388,
14,
1143,
63,
3702,
275,
11723,
14,
5810,
267,
1962,
275,
291,
14,
388,
14,
2526,
480,
2416,
413,
465,
282,
12,
499,
465,
330,
3471,
11591,
342,
267,
291,
14,
1815,
8,
6074,
8,
1143,
12,
3521,
11723,
14,
5810,
395,
717,
298,
1143,
365,
440,
1256,
402,
11723,
14,
5810,
531,
398,
1048,
17,
12,
1048,
18,
275,
1962,
905,
65,
2255,
1962,
905,
66,
937,
267,
291,
14,
1815,
8,
761,
17,
508,
413,
12,
298,
991,
536,
26,
6835,
754,
367,
2763,
283,
65,
9859,
267,
291,
14,
1815,
8,
761,
18,
508,
499,
12,
298,
991,
536,
26,
6835,
754,
367,
2763,
283,
65,
9859,
398,
1048,
17,
12,
1048,
18,
275,
1962,
905,
33,
2255,
1962,
905,
34,
937,
267,
291,
14,
1815,
8,
761,
17,
508,
413,
12,
298,
991,
536,
26,
6835,
754,
367,
2763,
283,
33,
9859,
267,
291,
14,
1815,
8,
761,
18,
508,
499,
12,
298,
991,
536,
26,
6835,
754,
367,
2763,
283,
34,
9859,
398,
1048,
17,
12,
1048,
18,
275,
1962,
59,
16,
467,
1962,
59,
17,
61,
267,
291,
14,
1815,
8,
761,
17,
508,
413,
12,
298,
991,
1478,
26,
6835,
754,
367,
2763,
378,
531,
267,
291,
14,
1815,
8,
761,
18,
508,
499,
12,
298,
991,
1478,
26,
6835,
754,
367,
2763,
413,
531,
339,
347,
2670,
24614,
5333,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
devs1991/test_edx_docmode
|
venv/lib/python2.7/site-packages/sympy/tensor/tests/test_indexed.py
|
8
|
5183
|
from sympy.core import symbols, Integer, Symbol, Tuple, oo
from sympy.tensor.indexed import IndexException
from sympy.utilities.pytest import raises
# import test:
from sympy import IndexedBase, Idx, Indexed
def test_Idx_construction():
i, a, b = symbols('i a b', integer=True)
assert Idx(i) != Idx(i, 1)
assert Idx(i, a) == Idx(i, (0, a - 1))
assert Idx(i, oo) == Idx(i, (0, oo))
x = symbols('x')
raises(TypeError, "Idx(x)")
raises(TypeError, "Idx(0.5)")
raises(TypeError, "Idx(i, x)")
raises(TypeError, "Idx(i, 0.5)")
raises(TypeError, "Idx(i, (x, 5))")
raises(TypeError, "Idx(i, (2, x))")
raises(TypeError, "Idx(i, (2, 3.5))")
def test_Idx_properties():
i, a, b = symbols('i a b', integer=True)
assert Idx(i).is_integer
def test_Idx_bounds():
i, a, b = symbols('i a b', integer=True)
assert Idx(i).lower == None
assert Idx(i).upper == None
assert Idx(i, a).lower == 0
assert Idx(i, a).upper == a - 1
assert Idx(i, 5).lower == 0
assert Idx(i, 5).upper == 4
assert Idx(i, oo).lower == 0
assert Idx(i, oo).upper == oo
assert Idx(i, (a, b)).lower == a
assert Idx(i, (a, b)).upper == b
assert Idx(i, (1, 5)).lower == 1
assert Idx(i, (1, 5)).upper == 5
assert Idx(i, (-oo, oo)).lower == -oo
assert Idx(i, (-oo, oo)).upper == oo
def test_Idx_fixed_bounds():
i, a, b = symbols('i a b', integer=True)
assert Idx(2).lower == None
assert Idx(2).upper == None
assert Idx(2, a).lower == 0
assert Idx(2, a).upper == a - 1
assert Idx(2, 5).lower == 0
assert Idx(2, 5).upper == 4
assert Idx(2, oo).lower == 0
assert Idx(2, oo).upper == oo
assert Idx(2, (a, b)).lower == a
assert Idx(2, (a, b)).upper == b
assert Idx(2, (1, 5)).lower == 1
assert Idx(2, (1, 5)).upper == 5
assert Idx(2, (-oo, oo)).lower == -oo
assert Idx(2, (-oo, oo)).upper == oo
def test_Idx_func_args():
i, a, b = symbols('i a b', integer=True)
ii = Idx(i)
assert ii.func(*ii.args) == ii
ii = Idx(i, a)
assert ii.func(*ii.args) == ii
ii = Idx(i, (a, b))
assert ii.func(*ii.args) == ii
def test_Idx_subs():
i, a, b = symbols('i a b', integer=True)
assert Idx(i, a).subs(a, b) == Idx(i, b)
assert Idx(i, a).subs(i, b) == Idx(b, a)
assert Idx(i).subs(i,2) == Idx(2)
assert Idx(i, a).subs(a, 2) == Idx(i, 2)
assert Idx(i, (a, b)).subs(i, 2) == Idx(2, (a, b))
def test_IndexedBase_sugar():
i, j = symbols('i j', integer=True)
a = symbols('a')
A1 = Indexed(a, i, j)
A2 = IndexedBase(a)
assert A1 == A2[i, j]
assert A1 == A2[(i, j)]
assert A1 == A2[[i, j]]
assert A1 == A2[Tuple(i, j)]
def test_IndexedBase_subs():
i, j, k = symbols('i j k', integer=True)
a, b = symbols('a b')
A = IndexedBase(a)
B = IndexedBase(b)
assert A[i] == B[i].subs(b, a)
def test_IndexedBase_shape():
i, j, m, n = symbols('i j m n', integer=True)
a = IndexedBase('a', shape=(m, m))
b = IndexedBase('a', shape=(m, n))
assert b.shape == Tuple(m, n)
assert a[i, j] != b[i, j]
assert a[i, j] == b[i, j].subs(n, m)
assert b.func(*b.args) == b
assert b[i, j].func(*b[i, j].args) == b[i, j]
raises(IndexException, 'b[i]')
raises(IndexException, 'b[i, i, j]')
def test_Indexed_constructor():
i, j = symbols('i j', integer=True)
A = Indexed('A', i, j)
assert A == Indexed(Symbol('A'), i, j)
assert A == Indexed(IndexedBase('A'), i, j)
raises(TypeError, 'Indexed(A, i, j)')
raises(IndexException, 'Indexed("A")')
def test_Indexed_func_args():
i, j = symbols('i j', integer=True)
a = symbols('a')
A = Indexed(a, i, j)
assert A == A.func(*A.args)
def test_Indexed_subs():
i, j, k = symbols('i j k', integer=True)
a, b = symbols('a b')
A = IndexedBase(a)
B = IndexedBase(b)
assert A[i, j] == B[i, j].subs(b, a)
assert A[i, j] == A[i, k].subs(k, j)
def test_Indexed_properties():
i, j = symbols('i j', integer=True)
A = Indexed('A', i, j)
assert A.rank == 2
assert A.indices == (i, j)
assert A.base == IndexedBase('A')
assert A.ranges == [None, None]
raises(IndexException, 'A.shape')
n, m = symbols('n m', integer=True)
assert Indexed('A', Idx(i, m), Idx(j, n)).ranges == [Tuple(0, m - 1), Tuple(0, n - 1)]
assert Indexed('A', Idx(i, m), Idx(j, n)).shape == Tuple(m, n)
raises(IndexException, 'Indexed("A", Idx(i, m), Idx(j)).shape')
def test_Indexed_shape_precedence():
i, j = symbols('i j', integer=True)
o, p = symbols('o p', integer=True)
n, m = symbols('n m', integer=True)
a = IndexedBase('a', shape=(o, p))
assert a.shape == Tuple(o, p)
assert Indexed(a, Idx(i, m), Idx(j, n)).ranges == [Tuple(0, m - 1), Tuple(0, n - 1)]
assert Indexed(a, Idx(i, m), Idx(j, n)).shape == Tuple(o, p)
assert Indexed(a, Idx(i, m), Idx(j)).ranges == [Tuple(0, m - 1), Tuple(None, None)]
assert Indexed(a, Idx(i, m), Idx(j)).shape == Tuple(o, p)
def test_complex_indices():
i, j = symbols('i j', integer=True)
A = Indexed('A', i, i + j)
assert A.rank == 2
assert A.indices == (i, i + j)
|
agpl-3.0
|
[
504,
5840,
14,
1018,
492,
6698,
12,
7225,
12,
10080,
12,
11634,
12,
16390,
199,
504,
5840,
14,
3128,
14,
16821,
492,
5499,
1726,
199,
504,
5840,
14,
16355,
14,
4462,
492,
6534,
199,
199,
3,
492,
511,
26,
199,
504,
5840,
492,
26437,
1563,
12,
473,
8373,
12,
26437,
199,
199,
318,
511,
63,
12215,
63,
12708,
837,
272,
284,
12,
282,
12,
330,
275,
6698,
360,
73,
282,
330,
297,
3000,
29,
549,
9,
272,
702,
473,
8373,
8,
73,
9,
1137,
473,
8373,
8,
73,
12,
413,
9,
272,
702,
473,
8373,
8,
73,
12,
282,
9,
508,
473,
8373,
8,
73,
12,
334,
16,
12,
282,
446,
413,
430,
272,
702,
473,
8373,
8,
73,
12,
16390,
9,
508,
473,
8373,
8,
73,
12,
334,
16,
12,
16390,
430,
339,
671,
275,
6698,
360,
88,
358,
272,
6534,
8,
4333,
12,
298,
12215,
8,
88,
6320,
272,
6534,
8,
4333,
12,
298,
12215,
8,
16,
14,
21,
6320,
272,
6534,
8,
4333,
12,
298,
12215,
8,
73,
12,
671,
6320,
272,
6534,
8,
4333,
12,
298,
12215,
8,
73,
12,
378,
14,
21,
6320,
272,
6534,
8,
4333,
12,
298,
12215,
8,
73,
12,
334,
88,
12,
959,
430,
531,
272,
6534,
8,
4333,
12,
298,
12215,
8,
73,
12,
334,
18,
12,
671,
430,
531,
272,
6534,
8,
4333,
12,
298,
12215,
8,
73,
12,
334,
18,
12,
650,
14,
21,
430,
531,
199,
199,
318,
511,
63,
12215,
63,
3282,
837,
272,
284,
12,
282,
12,
330,
275,
6698,
360,
73,
282,
330,
297,
3000,
29,
549,
9,
272,
702,
473,
8373,
8,
73,
680,
374,
63,
4115,
199,
199,
318,
511,
63,
12215,
63,
9632,
837,
272,
284,
12,
282,
12,
330,
275,
6698,
360,
73,
282,
330,
297,
3000,
29,
549,
9,
272,
702,
473,
8373,
8,
73,
680,
2325,
508,
488,
272,
702,
473,
8373,
8,
73,
680,
4142,
508,
488,
272,
702,
473,
8373,
8,
73,
12,
282,
680,
2325,
508,
378,
272,
702,
473,
8373,
8,
73,
12,
282,
680,
4142,
508,
282,
446,
413,
272,
702,
473,
8373,
8,
73,
12,
959,
680,
2325,
508,
378,
272,
702,
473,
8373,
8,
73,
12,
959,
680,
4142,
508,
841,
272,
702,
473,
8373,
8,
73,
12,
16390,
680,
2325,
508,
378,
272,
702,
473,
8373,
8,
73,
12,
16390,
680,
4142,
508,
16390,
272,
702,
473,
8373,
8,
73,
12,
334,
65,
12,
330,
4992,
2325,
508,
282,
272,
702,
473,
8373,
8,
73,
12,
334,
65,
12,
330,
4992,
4142,
508,
330,
272,
702,
473,
8373,
8,
73,
12,
334,
17,
12,
959,
4992,
2325,
508,
413,
272,
702,
473,
8373,
8,
73,
12,
334,
17,
12,
959,
4992,
4142,
508,
959,
272,
702,
473,
8373,
8,
73,
12,
5868,
1534,
12,
16390,
4992,
2325,
508,
446,
1534,
272,
702,
473,
8373,
8,
73,
12,
5868,
1534,
12,
16390,
4992,
4142,
508,
16390,
199,
199,
318,
511,
63,
12215,
63,
5964,
63,
9632,
837,
272,
284,
12,
282,
12,
330,
275,
6698,
360,
73,
282,
330,
297,
3000,
29,
549,
9,
272,
702,
473,
8373,
8,
18,
680,
2325,
508,
488,
272,
702,
473,
8373,
8,
18,
680,
4142,
508,
488,
272,
702,
473,
8373,
8,
18,
12,
282,
680,
2325,
508,
378,
272,
702,
473,
8373,
8,
18,
12,
282,
680,
4142,
508,
282,
446,
413,
272,
702,
473,
8373,
8,
18,
12,
959,
680,
2325,
508,
378,
272,
702,
473,
8373,
8,
18,
12,
959,
680,
4142,
508,
841,
272,
702,
473,
8373,
8,
18,
12,
16390,
680,
2325,
508,
378,
272,
702,
473,
8373,
8,
18,
12,
16390,
680,
4142,
508,
16390,
272,
702,
473,
8373,
8,
18,
12,
334,
65,
12,
330,
4992,
2325,
508,
282,
272,
702,
473,
8373,
8,
18,
12,
334,
65,
12,
330,
4992,
4142,
508,
330,
272,
702,
473,
8373,
8,
18,
12,
334,
17,
12,
959,
4992,
2325,
508,
413,
272,
702,
473,
8373,
8,
18,
12,
334,
17,
12,
959,
4992,
4142,
508,
959,
272,
702,
473,
8373,
8,
18,
12,
5868,
1534,
12,
16390,
4992,
2325,
508,
446,
1534,
272,
702,
473,
8373,
8,
18,
12,
5868,
1534,
12,
16390,
4992,
4142,
508,
16390,
199,
199,
318,
511,
63,
12215,
63,
1532,
63,
589,
837,
272,
284,
12,
282,
12,
330,
275,
6698,
360,
73,
282,
330,
297,
3000,
29,
549,
9,
272,
15393,
275,
473,
8373,
8,
73,
9,
272,
702,
15393,
14,
1532,
2031,
5908,
14,
589,
9,
508,
15393,
272,
15393,
275,
473,
8373,
8,
73,
12,
282,
9,
272,
702,
15393,
14,
1532,
2031,
5908,
14,
589,
9,
508,
15393,
272,
15393,
275,
473,
8373,
8,
73,
12,
334,
65,
12,
330,
430,
272,
702,
15393,
14,
1532,
2031,
5908,
14,
589,
9,
508,
15393,
199,
199,
318,
511,
63,
12215,
63,
9841,
837,
272,
284,
12,
282,
12,
330,
275,
6698,
360,
73,
282,
330,
297,
3000,
29,
549,
9,
272,
702,
473,
8373,
8,
73,
12,
282,
680,
9841,
8,
65,
12,
330,
9,
508,
473,
8373,
8,
73,
12,
330,
9,
272,
702,
473,
8373,
8,
73,
12,
282,
680,
9841,
8,
73,
12,
330,
9,
508,
473,
8373,
8,
66,
12,
282,
9,
339,
702,
473,
8373,
8,
73,
680,
9841,
8,
73,
12,
18,
9,
508,
473,
8373,
8,
18,
9,
272,
702,
473,
8373,
8,
73,
12,
282,
680,
9841,
8,
65,
12,
499,
9,
508,
473,
8373,
8,
73,
12,
499,
9,
272,
702,
473,
8373,
8,
73,
12,
334,
65,
12,
330,
4992,
9841,
8,
73,
12,
499,
9,
508,
473,
8373,
8,
18,
12,
334,
65,
12,
330,
430,
199,
199,
318,
511,
63,
19067,
1563,
63,
83,
21922,
837,
272,
284,
12,
1335,
275,
6698,
360,
73,
1335,
297,
3000,
29,
549,
9,
272,
282,
275,
6698,
360,
65,
358,
272,
437,
17,
275,
26437,
8,
65,
12,
284,
12,
1335,
9,
272,
437,
18,
275,
26437,
1563,
8,
65,
9,
272,
702,
437,
17,
508,
437,
18,
59,
73,
12,
1335,
61,
272,
702,
437,
17,
508,
437,
18,
7528,
73,
12,
1335,
1874,
272,
702,
437,
17,
508,
437,
18,
9046,
73,
12,
1335
] |
[
5840,
14,
1018,
492,
6698,
12,
7225,
12,
10080,
12,
11634,
12,
16390,
199,
504,
5840,
14,
3128,
14,
16821,
492,
5499,
1726,
199,
504,
5840,
14,
16355,
14,
4462,
492,
6534,
199,
199,
3,
492,
511,
26,
199,
504,
5840,
492,
26437,
1563,
12,
473,
8373,
12,
26437,
199,
199,
318,
511,
63,
12215,
63,
12708,
837,
272,
284,
12,
282,
12,
330,
275,
6698,
360,
73,
282,
330,
297,
3000,
29,
549,
9,
272,
702,
473,
8373,
8,
73,
9,
1137,
473,
8373,
8,
73,
12,
413,
9,
272,
702,
473,
8373,
8,
73,
12,
282,
9,
508,
473,
8373,
8,
73,
12,
334,
16,
12,
282,
446,
413,
430,
272,
702,
473,
8373,
8,
73,
12,
16390,
9,
508,
473,
8373,
8,
73,
12,
334,
16,
12,
16390,
430,
339,
671,
275,
6698,
360,
88,
358,
272,
6534,
8,
4333,
12,
298,
12215,
8,
88,
6320,
272,
6534,
8,
4333,
12,
298,
12215,
8,
16,
14,
21,
6320,
272,
6534,
8,
4333,
12,
298,
12215,
8,
73,
12,
671,
6320,
272,
6534,
8,
4333,
12,
298,
12215,
8,
73,
12,
378,
14,
21,
6320,
272,
6534,
8,
4333,
12,
298,
12215,
8,
73,
12,
334,
88,
12,
959,
430,
531,
272,
6534,
8,
4333,
12,
298,
12215,
8,
73,
12,
334,
18,
12,
671,
430,
531,
272,
6534,
8,
4333,
12,
298,
12215,
8,
73,
12,
334,
18,
12,
650,
14,
21,
430,
531,
199,
199,
318,
511,
63,
12215,
63,
3282,
837,
272,
284,
12,
282,
12,
330,
275,
6698,
360,
73,
282,
330,
297,
3000,
29,
549,
9,
272,
702,
473,
8373,
8,
73,
680,
374,
63,
4115,
199,
199,
318,
511,
63,
12215,
63,
9632,
837,
272,
284,
12,
282,
12,
330,
275,
6698,
360,
73,
282,
330,
297,
3000,
29,
549,
9,
272,
702,
473,
8373,
8,
73,
680,
2325,
508,
488,
272,
702,
473,
8373,
8,
73,
680,
4142,
508,
488,
272,
702,
473,
8373,
8,
73,
12,
282,
680,
2325,
508,
378,
272,
702,
473,
8373,
8,
73,
12,
282,
680,
4142,
508,
282,
446,
413,
272,
702,
473,
8373,
8,
73,
12,
959,
680,
2325,
508,
378,
272,
702,
473,
8373,
8,
73,
12,
959,
680,
4142,
508,
841,
272,
702,
473,
8373,
8,
73,
12,
16390,
680,
2325,
508,
378,
272,
702,
473,
8373,
8,
73,
12,
16390,
680,
4142,
508,
16390,
272,
702,
473,
8373,
8,
73,
12,
334,
65,
12,
330,
4992,
2325,
508,
282,
272,
702,
473,
8373,
8,
73,
12,
334,
65,
12,
330,
4992,
4142,
508,
330,
272,
702,
473,
8373,
8,
73,
12,
334,
17,
12,
959,
4992,
2325,
508,
413,
272,
702,
473,
8373,
8,
73,
12,
334,
17,
12,
959,
4992,
4142,
508,
959,
272,
702,
473,
8373,
8,
73,
12,
5868,
1534,
12,
16390,
4992,
2325,
508,
446,
1534,
272,
702,
473,
8373,
8,
73,
12,
5868,
1534,
12,
16390,
4992,
4142,
508,
16390,
199,
199,
318,
511,
63,
12215,
63,
5964,
63,
9632,
837,
272,
284,
12,
282,
12,
330,
275,
6698,
360,
73,
282,
330,
297,
3000,
29,
549,
9,
272,
702,
473,
8373,
8,
18,
680,
2325,
508,
488,
272,
702,
473,
8373,
8,
18,
680,
4142,
508,
488,
272,
702,
473,
8373,
8,
18,
12,
282,
680,
2325,
508,
378,
272,
702,
473,
8373,
8,
18,
12,
282,
680,
4142,
508,
282,
446,
413,
272,
702,
473,
8373,
8,
18,
12,
959,
680,
2325,
508,
378,
272,
702,
473,
8373,
8,
18,
12,
959,
680,
4142,
508,
841,
272,
702,
473,
8373,
8,
18,
12,
16390,
680,
2325,
508,
378,
272,
702,
473,
8373,
8,
18,
12,
16390,
680,
4142,
508,
16390,
272,
702,
473,
8373,
8,
18,
12,
334,
65,
12,
330,
4992,
2325,
508,
282,
272,
702,
473,
8373,
8,
18,
12,
334,
65,
12,
330,
4992,
4142,
508,
330,
272,
702,
473,
8373,
8,
18,
12,
334,
17,
12,
959,
4992,
2325,
508,
413,
272,
702,
473,
8373,
8,
18,
12,
334,
17,
12,
959,
4992,
4142,
508,
959,
272,
702,
473,
8373,
8,
18,
12,
5868,
1534,
12,
16390,
4992,
2325,
508,
446,
1534,
272,
702,
473,
8373,
8,
18,
12,
5868,
1534,
12,
16390,
4992,
4142,
508,
16390,
199,
199,
318,
511,
63,
12215,
63,
1532,
63,
589,
837,
272,
284,
12,
282,
12,
330,
275,
6698,
360,
73,
282,
330,
297,
3000,
29,
549,
9,
272,
15393,
275,
473,
8373,
8,
73,
9,
272,
702,
15393,
14,
1532,
2031,
5908,
14,
589,
9,
508,
15393,
272,
15393,
275,
473,
8373,
8,
73,
12,
282,
9,
272,
702,
15393,
14,
1532,
2031,
5908,
14,
589,
9,
508,
15393,
272,
15393,
275,
473,
8373,
8,
73,
12,
334,
65,
12,
330,
430,
272,
702,
15393,
14,
1532,
2031,
5908,
14,
589,
9,
508,
15393,
199,
199,
318,
511,
63,
12215,
63,
9841,
837,
272,
284,
12,
282,
12,
330,
275,
6698,
360,
73,
282,
330,
297,
3000,
29,
549,
9,
272,
702,
473,
8373,
8,
73,
12,
282,
680,
9841,
8,
65,
12,
330,
9,
508,
473,
8373,
8,
73,
12,
330,
9,
272,
702,
473,
8373,
8,
73,
12,
282,
680,
9841,
8,
73,
12,
330,
9,
508,
473,
8373,
8,
66,
12,
282,
9,
339,
702,
473,
8373,
8,
73,
680,
9841,
8,
73,
12,
18,
9,
508,
473,
8373,
8,
18,
9,
272,
702,
473,
8373,
8,
73,
12,
282,
680,
9841,
8,
65,
12,
499,
9,
508,
473,
8373,
8,
73,
12,
499,
9,
272,
702,
473,
8373,
8,
73,
12,
334,
65,
12,
330,
4992,
9841,
8,
73,
12,
499,
9,
508,
473,
8373,
8,
18,
12,
334,
65,
12,
330,
430,
199,
199,
318,
511,
63,
19067,
1563,
63,
83,
21922,
837,
272,
284,
12,
1335,
275,
6698,
360,
73,
1335,
297,
3000,
29,
549,
9,
272,
282,
275,
6698,
360,
65,
358,
272,
437,
17,
275,
26437,
8,
65,
12,
284,
12,
1335,
9,
272,
437,
18,
275,
26437,
1563,
8,
65,
9,
272,
702,
437,
17,
508,
437,
18,
59,
73,
12,
1335,
61,
272,
702,
437,
17,
508,
437,
18,
7528,
73,
12,
1335,
1874,
272,
702,
437,
17,
508,
437,
18,
9046,
73,
12,
1335,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
kubeup/archon
|
vendor/github.com/google/certificate-transparency/python/ct/cert_analysis/algorithm.py
|
23
|
4326
|
import calendar
import time
from ct.crypto import cert
from ct.crypto.asn1 import oid
from ct.cert_analysis.observation import Observation
class AlgorithmObservation(Observation):
def __init__(self, description, *args, **kwargs):
super(AlgorithmObservation, self).__init__(
"Signature algorithm: " + description, *args, **kwargs)
class AlgorithmMismatch(AlgorithmObservation):
def __init__(self, details):
super(AlgorithmMismatch, self).__init__(
"signature algorithm identifier in Certificate is different ",
details=details)
class SHA1Observation(AlgorithmObservation):
def _format_details(self):
# Times are in UTC, so use "UTC" instead of %Z (which gives local TZ)
return time.strftime("%Y-%m-%dT%H:%M:%SUTC", self.details)
class RsaSHA1(SHA1Observation):
def __init__(self, details):
super(RsaSHA1, self).__init__(
"uses sha-1WithRSAEncryption after 1 Jan 2017", details=details)
class DsaSHA1(SHA1Observation):
def __init__(self, details):
super(DsaSHA1, self).__init__("uses id-dsa-with-SHA1 after 1 Jan 2017",
details=details)
class EcdsaSHA1(SHA1Observation):
def __init__(self, details):
super(EcdsaSHA1, self).__init__("uses ecdsa-with-SHA1 after 1 Jan 2017",
details=details)
class CheckSignatureAlgorithmsMismatch(object):
@staticmethod
def check(certificate):
"""Checks if signatureAlgorithm matches signature.
Returns:
array containing AlgorithmMismatch or nothing
"""
signature = certificate.signature()
signature_algorithm = certificate.signature_algorithm()
if signature != signature_algorithm:
return [AlgorithmMismatch((signature, signature_algorithm))]
def check_sha1_after_2017(not_after, algorithm):
invalid_after = time.strptime("2017-01-01T00:00:00UTC",
"%Y-%m-%dT%H:%M:%S%Z")
if calendar.timegm(not_after) - calendar.timegm(invalid_after) >= 0:
if algorithm == oid.SHA1_WITH_RSA_ENCRYPTION:
return RsaSHA1(not_after)
elif algorithm == oid.ID_DSA_WITH_SHA1:
return DsaSHA1(not_after)
elif algorithm == oid.ECDSA_WITH_SHA1:
return EcdsaSHA1(not_after)
# naming of this object and the next is quite awkward, because one refers to
# certificate->tbsCertificate->signatureAlgorithm
# and the next class refers to
# certificate->signatureAlgorithm
class CheckTbsCertificateAlgorithmSHA1Ater2017(object):
@staticmethod
def check(certificate):
"""Checks if certificate is valid after 1 January 2017 and it is using
SHA1 in tbsCertificate->signatureAlgorithm.
Returns:
array containing SHA1 observation or empty array
"""
signature_algorithm = certificate.signature_algorithm()
# Check for sha-1 ending after 1 January 2017
try:
not_after = certificate.not_after()
check = check_sha1_after_2017(not_after,
signature_algorithm["algorithm"])
if check:
check.reason = "TbsCertificate"
return [check]
# if something goes wrong it should be caught by using validity checks
# (CheckValidityCorrupt) not algorithm checks.
except cert.CertificateError:
pass
class CheckCertificateAlgorithmSHA1After2017(object):
@staticmethod
def check(certificate):
"""Checks if certificate is valid after 1 January 2017 and it is using
SHA1 in signatureAlgorithm.
Returns:
array containing SHA1 observation or empty array
"""
signature = certificate.signature()
# Check for sha-1 ending after 1 January 2017
try:
not_after = certificate.not_after()
check = check_sha1_after_2017(not_after,
signature["algorithm"])
if check:
check.reason = "Certificate"
return [check]
# if not_after raises it should be caught using validity checks
# not algorithm checks.
except cert.CertificateError:
pass
|
apache-2.0
|
[
646,
11234,
199,
646,
900,
199,
199,
504,
9428,
14,
10316,
492,
6250,
199,
504,
9428,
14,
10316,
14,
6228,
17,
492,
20109,
199,
504,
9428,
14,
4736,
63,
10466,
14,
24299,
492,
17985,
8213,
199,
199,
533,
23823,
11394,
8213,
8,
11394,
8213,
304,
272,
347,
636,
826,
721,
277,
12,
1369,
12,
627,
589,
12,
1011,
958,
304,
267,
1613,
8,
11570,
11394,
8213,
12,
291,
2843,
826,
721,
355,
298,
10014,
5563,
26,
298,
435,
1369,
12,
627,
589,
12,
1011,
958,
9,
421,
199,
533,
23823,
23055,
8,
11570,
11394,
8213,
304,
272,
347,
636,
826,
721,
277,
12,
2436,
304,
267,
1613,
8,
11570,
23055,
12,
291,
2843,
826,
721,
355,
298,
5233,
5563,
5148,
315,
12904,
365,
3365,
3872,
355,
2436,
29,
5087,
9,
421,
199,
533,
12002,
17,
11394,
8213,
8,
11570,
11394,
8213,
304,
272,
347,
485,
908,
63,
5087,
8,
277,
304,
267,
327,
4703,
83,
787,
315,
12174,
12,
880,
675,
298,
11288,
2,
3140,
402,
450,
58,
334,
6777,
10557,
2257,
377,
58,
9,
267,
372,
900,
14,
6205,
3647,
57,
3295,
77,
3295,
19772,
5,
40,
2689,
45,
2689,
51,
11288,
401,
291,
14,
5087,
9,
421,
199,
533,
820,
2231,
8461,
17,
8,
8461,
17,
11394,
8213,
304,
272,
347,
636,
826,
721,
277,
12,
2436,
304,
267,
1613,
8,
50,
2231,
8461,
17,
12,
291,
2843,
826,
721,
355,
298,
5589,
7793,
13,
17,
3007,
12115,
25687,
2410,
413,
17474,
9708,
401,
2436,
29,
5087,
9,
421,
199,
533,
577,
2231,
8461,
17,
8,
8461,
17,
11394,
8213,
304,
272,
347,
636,
826,
721,
277,
12,
2436,
304,
267,
1613,
8,
36,
2231,
8461,
17,
12,
291,
2843,
826,
29093,
5589,
1305,
13,
24760,
13,
1045,
13,
8461,
17,
2410,
413,
17474,
9708,
401,
4228,
2436,
29,
5087,
9,
421,
199,
533,
662,
67,
24760,
8461,
17,
8,
8461,
17,
11394,
8213,
304,
272,
347,
636,
826,
721,
277,
12,
2436,
304,
267,
1613,
8,
30478,
24760,
8461,
17,
12,
291,
2843,
826,
29093,
5589,
7062,
24760,
13,
1045,
13,
8461,
17,
2410,
413,
17474,
9708,
401,
3147,
2436,
29,
5087,
9,
421,
199,
533,
2670,
10014,
2439,
12719,
23055,
8,
785,
304,
272,
768,
4639,
272,
347,
1104,
8,
6999,
304,
267,
408,
11834,
340,
4955,
11570,
4450,
4955,
14,
398,
1803,
26,
288,
1625,
3035,
23823,
23055,
503,
6548,
267,
408,
267,
4955,
275,
5897,
14,
5233,
342,
267,
4955,
63,
8833,
275,
5897,
14,
5233,
63,
8833,
342,
267,
340,
4955,
1137,
4955,
63,
8833,
26,
288,
372,
359,
11570,
23055,
1332,
5233,
12,
4955,
63,
8833,
10524,
421,
199,
318,
1104,
63,
4835,
17,
63,
4399,
63,
10680,
8,
1397,
63,
4399,
12,
5563,
304,
272,
3866,
63,
4399,
275,
900,
14,
9866,
480,
10680,
13,
614,
13,
614,
52,
383,
26,
383,
26,
383,
11288,
401,
3303,
2071,
57,
3295,
77,
3295,
19772,
5,
40,
2689,
45,
2689,
51,
5,
58,
531,
272,
340,
11234,
14,
521,
13844,
8,
1397,
63,
4399,
9,
446,
11234,
14,
521,
13844,
8,
3197,
63,
4399,
9,
2356,
378,
26,
267,
340,
5563,
508,
20109,
14,
8461,
17,
63,
9139,
63,
12115,
63,
742,
19079,
1075,
26,
288,
372,
820,
2231,
8461,
17,
8,
1397,
63,
4399,
9,
267,
916,
5563,
508,
20109,
14,
998,
63,
23007,
63,
9139,
63,
8461,
17,
26,
288,
372,
577,
2231,
8461,
17,
8,
1397,
63,
4399,
9,
267,
916,
5563,
508,
20109,
14,
4220,
23007,
63,
9139,
63,
8461,
17,
26,
288,
372,
662,
67,
24760,
8461,
17,
8,
1397,
63,
4399,
9,
421,
199,
3,
19720,
402,
642,
909,
436,
314,
2163,
365,
18794,
26936,
829,
1005,
12,
2952,
1373,
15724,
370,
199,
3,
5897,
5118,
84,
1533,
11414,
5118,
5233,
11570,
199,
3,
436,
314,
2163,
1021,
15724,
370,
199,
3,
5897,
5118,
5233,
11570,
199,
533,
2670,
52,
1533,
11414,
11570,
8461,
17,
33,
351,
10680,
8,
785,
304,
272,
768,
4639,
272,
347,
1104,
8,
6999,
304,
267,
408,
11834,
340,
5897,
365,
1686,
2410,
413,
17474,
20527,
9708,
436,
652,
365,
1808,
267,
12002,
17,
315,
307,
1533,
11414,
5118,
5233,
11570,
14,
398,
1803,
26,
288,
1625,
3035,
12002,
17,
20038,
503,
2701,
1625,
267,
408,
267,
4955,
63,
8833,
275,
5897,
14,
5233,
63,
8833,
342,
267,
327,
2670,
367,
7793,
13,
17,
13401,
2410,
413,
17474,
20527,
9708,
267,
862,
26,
288,
440,
63,
4399,
275,
5897,
14,
1397,
63,
4399,
342,
288,
1104,
275,
1104,
63,
4835,
17,
63,
4399,
63,
10680,
8,
1397,
63,
4399,
12,
2151,
4955,
63,
8833,
905,
8833,
3135,
288,
340,
1104,
26,
355,
1104,
14,
5764,
275,
298,
52,
1533,
11414,
2,
355,
372,
359,
1074,
61,
267,
327,
340,
6020,
13538,
6835,
652,
1077,
506,
15604,
701,
1808,
25667,
5920,
267,
327,
334,
1799,
7562,
12783,
8380,
6987,
9,
440,
5563,
5920,
14,
267,
871,
6250,
14,
11414,
547,
26,
288,
986,
421,
199,
533,
2670,
11414,
11570,
8461,
17,
10881,
10680,
8,
785,
304,
272,
768,
4639,
272,
347,
1104,
8,
6999,
304,
267,
408,
11834,
340,
5897,
365,
1686,
2410,
413,
17474,
20527,
9708,
436,
652,
365,
1808,
267,
12002,
17,
315,
4955,
11570,
14,
398,
1803,
26,
288,
1625,
3035,
12002,
17,
20038,
503,
2701,
1625,
267,
408,
267,
4955,
275,
5897,
14,
5233,
342,
267,
327,
2670,
367,
7793,
13,
17,
13401,
2410,
413,
17474,
20527,
9708,
267,
862,
26,
288,
440,
63,
4399,
275,
5897,
14,
1397,
63,
4399,
342,
288,
1104,
275,
1104,
63,
4835,
17,
63,
4399,
63,
10680,
8,
1397,
63,
4399,
12,
639,
4955,
905,
8833,
3135,
288,
340,
1104,
26,
355,
1104,
14,
5764,
275,
298,
11414,
2,
355,
372,
359,
1074,
61,
267,
327,
340,
440,
63,
4399,
6534,
652,
1077,
506,
15604,
1808,
25667,
5920,
267,
327,
440,
5563,
5920,
14,
267,
871,
6250,
14,
11414,
547,
26,
288,
986,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
11234,
199,
646,
900,
199,
199,
504,
9428,
14,
10316,
492,
6250,
199,
504,
9428,
14,
10316,
14,
6228,
17,
492,
20109,
199,
504,
9428,
14,
4736,
63,
10466,
14,
24299,
492,
17985,
8213,
199,
199,
533,
23823,
11394,
8213,
8,
11394,
8213,
304,
272,
347,
636,
826,
721,
277,
12,
1369,
12,
627,
589,
12,
1011,
958,
304,
267,
1613,
8,
11570,
11394,
8213,
12,
291,
2843,
826,
721,
355,
298,
10014,
5563,
26,
298,
435,
1369,
12,
627,
589,
12,
1011,
958,
9,
421,
199,
533,
23823,
23055,
8,
11570,
11394,
8213,
304,
272,
347,
636,
826,
721,
277,
12,
2436,
304,
267,
1613,
8,
11570,
23055,
12,
291,
2843,
826,
721,
355,
298,
5233,
5563,
5148,
315,
12904,
365,
3365,
3872,
355,
2436,
29,
5087,
9,
421,
199,
533,
12002,
17,
11394,
8213,
8,
11570,
11394,
8213,
304,
272,
347,
485,
908,
63,
5087,
8,
277,
304,
267,
327,
4703,
83,
787,
315,
12174,
12,
880,
675,
298,
11288,
2,
3140,
402,
450,
58,
334,
6777,
10557,
2257,
377,
58,
9,
267,
372,
900,
14,
6205,
3647,
57,
3295,
77,
3295,
19772,
5,
40,
2689,
45,
2689,
51,
11288,
401,
291,
14,
5087,
9,
421,
199,
533,
820,
2231,
8461,
17,
8,
8461,
17,
11394,
8213,
304,
272,
347,
636,
826,
721,
277,
12,
2436,
304,
267,
1613,
8,
50,
2231,
8461,
17,
12,
291,
2843,
826,
721,
355,
298,
5589,
7793,
13,
17,
3007,
12115,
25687,
2410,
413,
17474,
9708,
401,
2436,
29,
5087,
9,
421,
199,
533,
577,
2231,
8461,
17,
8,
8461,
17,
11394,
8213,
304,
272,
347,
636,
826,
721,
277,
12,
2436,
304,
267,
1613,
8,
36,
2231,
8461,
17,
12,
291,
2843,
826,
29093,
5589,
1305,
13,
24760,
13,
1045,
13,
8461,
17,
2410,
413,
17474,
9708,
401,
4228,
2436,
29,
5087,
9,
421,
199,
533,
662,
67,
24760,
8461,
17,
8,
8461,
17,
11394,
8213,
304,
272,
347,
636,
826,
721,
277,
12,
2436,
304,
267,
1613,
8,
30478,
24760,
8461,
17,
12,
291,
2843,
826,
29093,
5589,
7062,
24760,
13,
1045,
13,
8461,
17,
2410,
413,
17474,
9708,
401,
3147,
2436,
29,
5087,
9,
421,
199,
533,
2670,
10014,
2439,
12719,
23055,
8,
785,
304,
272,
768,
4639,
272,
347,
1104,
8,
6999,
304,
267,
408,
11834,
340,
4955,
11570,
4450,
4955,
14,
398,
1803,
26,
288,
1625,
3035,
23823,
23055,
503,
6548,
267,
408,
267,
4955,
275,
5897,
14,
5233,
342,
267,
4955,
63,
8833,
275,
5897,
14,
5233,
63,
8833,
342,
267,
340,
4955,
1137,
4955,
63,
8833,
26,
288,
372,
359,
11570,
23055,
1332,
5233,
12,
4955,
63,
8833,
10524,
421,
199,
318,
1104,
63,
4835,
17,
63,
4399,
63,
10680,
8,
1397,
63,
4399,
12,
5563,
304,
272,
3866,
63,
4399,
275,
900,
14,
9866,
480,
10680,
13,
614,
13,
614,
52,
383,
26,
383,
26,
383,
11288,
401,
3303,
2071,
57,
3295,
77,
3295,
19772,
5,
40,
2689,
45,
2689,
51,
5,
58,
531,
272,
340,
11234,
14,
521,
13844,
8,
1397,
63,
4399,
9,
446,
11234,
14,
521,
13844,
8,
3197,
63,
4399,
9,
2356,
378,
26,
267,
340,
5563,
508,
20109,
14,
8461,
17,
63,
9139,
63,
12115,
63,
742,
19079,
1075,
26,
288,
372,
820,
2231,
8461,
17,
8,
1397,
63,
4399,
9,
267,
916,
5563,
508,
20109,
14,
998,
63,
23007,
63,
9139,
63,
8461,
17,
26,
288,
372,
577,
2231,
8461,
17,
8,
1397,
63,
4399,
9,
267,
916,
5563,
508,
20109,
14,
4220,
23007,
63,
9139,
63,
8461,
17,
26,
288,
372,
662,
67,
24760,
8461,
17,
8,
1397,
63,
4399,
9,
421,
199,
3,
19720,
402,
642,
909,
436,
314,
2163,
365,
18794,
26936,
829,
1005,
12,
2952,
1373,
15724,
370,
199,
3,
5897,
5118,
84,
1533,
11414,
5118,
5233,
11570,
199,
3,
436,
314,
2163,
1021,
15724,
370,
199,
3,
5897,
5118,
5233,
11570,
199,
533,
2670,
52,
1533,
11414,
11570,
8461,
17,
33,
351,
10680,
8,
785,
304,
272,
768,
4639,
272,
347,
1104,
8,
6999,
304,
267,
408,
11834,
340,
5897,
365,
1686,
2410,
413,
17474,
20527,
9708,
436,
652,
365,
1808,
267,
12002,
17,
315,
307,
1533,
11414,
5118,
5233,
11570,
14,
398,
1803,
26,
288,
1625,
3035,
12002,
17,
20038,
503,
2701,
1625,
267,
408,
267,
4955,
63,
8833,
275,
5897,
14,
5233,
63,
8833,
342,
267,
327,
2670,
367,
7793,
13,
17,
13401,
2410,
413,
17474,
20527,
9708,
267,
862,
26,
288,
440,
63,
4399,
275,
5897,
14,
1397,
63,
4399,
342,
288,
1104,
275,
1104,
63,
4835,
17,
63,
4399,
63,
10680,
8,
1397,
63,
4399,
12,
2151,
4955,
63,
8833,
905,
8833,
3135,
288,
340,
1104,
26,
355,
1104,
14,
5764,
275,
298,
52,
1533,
11414,
2,
355,
372,
359,
1074,
61,
267,
327,
340,
6020,
13538,
6835,
652,
1077,
506,
15604,
701,
1808,
25667,
5920,
267,
327,
334,
1799,
7562,
12783,
8380,
6987,
9,
440,
5563,
5920,
14,
267,
871,
6250,
14,
11414,
547,
26,
288,
986,
421,
199,
533,
2670,
11414,
11570,
8461,
17,
10881,
10680,
8,
785,
304,
272,
768,
4639,
272,
347,
1104,
8,
6999,
304,
267,
408,
11834,
340,
5897,
365,
1686,
2410,
413,
17474,
20527,
9708,
436,
652,
365,
1808,
267,
12002,
17,
315,
4955,
11570,
14,
398,
1803,
26,
288,
1625,
3035,
12002,
17,
20038,
503,
2701,
1625,
267,
408,
267,
4955,
275,
5897,
14,
5233,
342,
267,
327,
2670,
367,
7793,
13,
17,
13401,
2410,
413,
17474,
20527,
9708,
267,
862,
26,
288,
440,
63,
4399,
275,
5897,
14,
1397,
63,
4399,
342,
288,
1104,
275,
1104,
63,
4835,
17,
63,
4399,
63,
10680,
8,
1397,
63,
4399,
12,
639,
4955,
905,
8833,
3135,
288,
340,
1104,
26,
355,
1104,
14,
5764,
275,
298,
11414,
2,
355,
372,
359,
1074,
61,
267,
327,
340,
440,
63,
4399,
6534,
652,
1077,
506,
15604,
1808,
25667,
5920,
267,
327,
440,
5563,
5920,
14,
267,
871,
6250,
14,
11414,
547,
26,
288,
986,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
emptymalei/statisticalphysics
|
exts/convert.py
|
7
|
1219
|
from textwrap import fill
import re
s = open("appendix.tex").read()
def repl1(obj):
eq = obj.group(1)
eq = eq.replace("\n", " ")
eq = fill(eq, 100000)
return "\n.. math::\n\n %s\n" % eq
def repl6(obj):
eq = obj.group(1)
eq = eq.replace("\n", " ")
eq = fill(eq, 100000)
return "\n.. math::\n :nowrap:\n\n %s\n" % eq
def repl4(obj):
eq = obj.group(1)
label = obj.group(2)
eq = eq.replace("\n", " ")
eq = fill(eq, 100000)
return "\n.. math::\n :label:%s\n\n %s\n" % (label, eq)
def repl2(obj):
title = obj.group(1)
return "%s\n%s\n" % (title, "="*len(title))
def repl3(obj):
title = obj.group(1)
return "%s\n%s\n" % (title, "-"*len(title))
s = re.sub("(?ms)\$\$(.+?)\$\$", repl1, s)
s = re.sub(r"(?ms)\\begin{equation\*}(.+?)\\end{equation\*}", repl1, s)
s = re.sub(r"(?ms)(\\begin{eqnarray\*}.+?\\end{eqnarray\*})", repl6, s)
s = re.sub(r"(?ms)\\begin{equation}(.+?)\\label{(.+?)}(\s+)\\end{equation}", repl4, s)
s = re.sub(r"\\chapter{(.+)}", repl2, s)
s = re.sub(r"\\section{(.+)}", repl3, s)
s = re.sub(r"(?ms)\\left\((\\mat{.+?})\\right\)", r"\1", s)
s = re.sub(r"\(\\ref{(.+?)}\)", r":eq:`\1`", s)
open("appendix.rst", "w").write(s)
|
mit
|
[
504,
13390,
492,
5554,
199,
646,
295,
199,
83,
275,
1551,
480,
5435,
19299,
14,
3858,
3471,
739,
342,
199,
318,
20265,
17,
8,
1113,
304,
272,
3850,
275,
1559,
14,
923,
8,
17,
9,
272,
3850,
275,
3850,
14,
1814,
4582,
78,
401,
298,
6099,
272,
3850,
275,
5554,
8,
4077,
12,
25761,
9,
272,
372,
1867,
78,
703,
3473,
447,
60,
78,
60,
78,
259,
450,
83,
60,
78,
2,
450,
3850,
199,
318,
20265,
22,
8,
1113,
304,
272,
3850,
275,
1559,
14,
923,
8,
17,
9,
272,
3850,
275,
3850,
14,
1814,
4582,
78,
401,
298,
6099,
272,
3850,
275,
5554,
8,
4077,
12,
25761,
9,
272,
372,
1867,
78,
703,
3473,
447,
60,
78,
259,
520,
2131,
1330,
3427,
78,
60,
78,
259,
450,
83,
60,
78,
2,
450,
3850,
199,
318,
20265,
20,
8,
1113,
304,
272,
3850,
275,
1559,
14,
923,
8,
17,
9,
272,
1768,
275,
1559,
14,
923,
8,
18,
9,
272,
3850,
275,
3850,
14,
1814,
4582,
78,
401,
298,
6099,
272,
3850,
275,
5554,
8,
4077,
12,
25761,
9,
272,
372,
1867,
78,
703,
3473,
447,
60,
78,
259,
520,
1302,
2689,
83,
60,
78,
60,
78,
259,
450,
83,
60,
78,
2,
450,
334,
1302,
12,
3850,
9,
199,
318,
20265,
18,
8,
1113,
304,
272,
2538,
275,
1559,
14,
923,
8,
17,
9,
272,
372,
2071,
83,
60,
78,
5,
83,
60,
78,
2,
450,
334,
1213,
12,
22250,
10,
552,
8,
1213,
430,
199,
318,
20265,
19,
8,
1113,
304,
272,
2538,
275,
1559,
14,
923,
8,
17,
9,
272,
372,
2071,
83,
60,
78,
5,
83,
60,
78,
2,
450,
334,
1213,
12,
17155,
10,
552,
8,
1213,
430,
199,
83,
275,
295,
14,
954,
480,
2229,
706,
2862,
16827,
6629,
11198,
2862,
16827,
11918,
20265,
17,
12,
308,
9,
199,
83,
275,
295,
14,
954,
8,
82,
24726,
706,
22532,
5037,
91,
27247,
60,
10,
22999,
11198,
22532,
500,
91,
27247,
60,
10,
10750,
20265,
17,
12,
308,
9,
199,
83,
275,
295,
14,
954,
8,
82,
24726,
706,
5130,
1103,
5037,
91,
4077,
78,
1144,
60,
10,
5565,
23778,
1103,
500,
91,
4077,
78,
1144,
60,
10,
1552,
401,
20265,
22,
12,
308,
9,
199,
83,
275,
295,
14,
954,
8,
82,
24726,
706,
22532,
5037,
91,
27247,
22999,
11198,
22532,
1302,
91,
28149,
6769,
2961,
83,
8771,
1103,
500,
91,
27247,
10750,
20265,
20,
12,
308,
9,
199,
83,
275,
295,
14,
954,
8,
82,
22996,
11316,
91,
8,
6977,
6769,
401,
20265,
18,
12,
308,
9,
199,
83,
275,
295,
14,
954,
8,
82,
22996,
2792,
91,
8,
6977,
6769,
401,
20265,
19,
12,
308,
9,
199,
83,
275,
295,
14,
954,
8,
82,
24726,
706,
22532,
3039,
60,
1332,
1103,
569,
91,
11198,
1552,
1103,
1019,
60,
4186,
519,
3212,
17,
401,
308,
9,
199,
83,
275,
295,
14,
954,
8,
82,
3212,
27910,
1121,
91,
28149,
9,
4988,
4186,
519,
582,
4077,
1705,
60,
17,
64,
401,
308,
9,
199,
1490,
480,
5435,
19299,
14,
8332,
401,
298,
87,
3471,
952,
8,
83,
9,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
13390,
492,
5554,
199,
646,
295,
199,
83,
275,
1551,
480,
5435,
19299,
14,
3858,
3471,
739,
342,
199,
318,
20265,
17,
8,
1113,
304,
272,
3850,
275,
1559,
14,
923,
8,
17,
9,
272,
3850,
275,
3850,
14,
1814,
4582,
78,
401,
298,
6099,
272,
3850,
275,
5554,
8,
4077,
12,
25761,
9,
272,
372,
1867,
78,
703,
3473,
447,
60,
78,
60,
78,
259,
450,
83,
60,
78,
2,
450,
3850,
199,
318,
20265,
22,
8,
1113,
304,
272,
3850,
275,
1559,
14,
923,
8,
17,
9,
272,
3850,
275,
3850,
14,
1814,
4582,
78,
401,
298,
6099,
272,
3850,
275,
5554,
8,
4077,
12,
25761,
9,
272,
372,
1867,
78,
703,
3473,
447,
60,
78,
259,
520,
2131,
1330,
3427,
78,
60,
78,
259,
450,
83,
60,
78,
2,
450,
3850,
199,
318,
20265,
20,
8,
1113,
304,
272,
3850,
275,
1559,
14,
923,
8,
17,
9,
272,
1768,
275,
1559,
14,
923,
8,
18,
9,
272,
3850,
275,
3850,
14,
1814,
4582,
78,
401,
298,
6099,
272,
3850,
275,
5554,
8,
4077,
12,
25761,
9,
272,
372,
1867,
78,
703,
3473,
447,
60,
78,
259,
520,
1302,
2689,
83,
60,
78,
60,
78,
259,
450,
83,
60,
78,
2,
450,
334,
1302,
12,
3850,
9,
199,
318,
20265,
18,
8,
1113,
304,
272,
2538,
275,
1559,
14,
923,
8,
17,
9,
272,
372,
2071,
83,
60,
78,
5,
83,
60,
78,
2,
450,
334,
1213,
12,
22250,
10,
552,
8,
1213,
430,
199,
318,
20265,
19,
8,
1113,
304,
272,
2538,
275,
1559,
14,
923,
8,
17,
9,
272,
372,
2071,
83,
60,
78,
5,
83,
60,
78,
2,
450,
334,
1213,
12,
17155,
10,
552,
8,
1213,
430,
199,
83,
275,
295,
14,
954,
480,
2229,
706,
2862,
16827,
6629,
11198,
2862,
16827,
11918,
20265,
17,
12,
308,
9,
199,
83,
275,
295,
14,
954,
8,
82,
24726,
706,
22532,
5037,
91,
27247,
60,
10,
22999,
11198,
22532,
500,
91,
27247,
60,
10,
10750,
20265,
17,
12,
308,
9,
199,
83,
275,
295,
14,
954,
8,
82,
24726,
706,
5130,
1103,
5037,
91,
4077,
78,
1144,
60,
10,
5565,
23778,
1103,
500,
91,
4077,
78,
1144,
60,
10,
1552,
401,
20265,
22,
12,
308,
9,
199,
83,
275,
295,
14,
954,
8,
82,
24726,
706,
22532,
5037,
91,
27247,
22999,
11198,
22532,
1302,
91,
28149,
6769,
2961,
83,
8771,
1103,
500,
91,
27247,
10750,
20265,
20,
12,
308,
9,
199,
83,
275,
295,
14,
954,
8,
82,
22996,
11316,
91,
8,
6977,
6769,
401,
20265,
18,
12,
308,
9,
199,
83,
275,
295,
14,
954,
8,
82,
22996,
2792,
91,
8,
6977,
6769,
401,
20265,
19,
12,
308,
9,
199,
83,
275,
295,
14,
954,
8,
82,
24726,
706,
22532,
3039,
60,
1332,
1103,
569,
91,
11198,
1552,
1103,
1019,
60,
4186,
519,
3212,
17,
401,
308,
9,
199,
83,
275,
295,
14,
954,
8,
82,
3212,
27910,
1121,
91,
28149,
9,
4988,
4186,
519,
582,
4077,
1705,
60,
17,
64,
401,
308,
9,
199,
1490,
480,
5435,
19299,
14,
8332,
401,
298,
87,
3471,
952,
8,
83,
9,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
magopian/olympia
|
apps/compat/cron.py
|
15
|
5678
|
import logging
from collections import defaultdict
from django.db.models import Count, Max
import cronjobs
import amo
import amo.search
import amo.utils
from addons.models import Addon
from search.utils import floor_version
from stats.models import UpdateCount
from versions.compare import version_int as vint
from lib.es.utils import get_indices
from .models import AppCompat, CompatReport, CompatTotals
log = logging.getLogger('z.compat')
@cronjobs.register
def compatibility_report(index=None):
docs = defaultdict(dict)
indices = get_indices(index)
# Gather all the data for the index.
for app in amo.APP_USAGE:
versions = [c for c in amo.COMPAT if c['app'] == app.id]
log.info(u'Making compat report for %s.' % app.pretty)
latest = UpdateCount.objects.aggregate(d=Max('date'))['d']
qs = UpdateCount.objects.filter(addon__appsupport__app=app.id,
addon__disabled_by_user=False,
addon__status__in=amo.VALID_STATUSES,
addon___current_version__isnull=False,
date=latest)
updates = dict(qs.values_list('addon', 'count'))
for chunk in amo.utils.chunked(updates.items(), 50):
chunk = dict(chunk)
for addon in Addon.objects.filter(id__in=chunk):
doc = docs[addon.id]
doc.update(id=addon.id, slug=addon.slug, guid=addon.guid,
binary=addon.binary_components,
name=unicode(addon.name), created=addon.created,
current_version=addon.current_version.version,
current_version_id=addon.current_version.pk)
doc['count'] = chunk[addon.id]
doc.setdefault('top_95',
defaultdict(lambda: defaultdict(dict)))
doc.setdefault('top_95_all', {})
doc.setdefault('usage', {})[app.id] = updates[addon.id]
doc.setdefault('works', {}).setdefault(app.id, {})
# Populate with default counts for all app versions.
for ver in versions:
doc['works'][app.id][vint(ver['main'])] = {
'success': 0,
'failure': 0,
'total': 0,
'failure_ratio': 0.0,
}
# Group reports by `major`.`minor` app version.
reports = (CompatReport.objects
.filter(guid=addon.guid, app_guid=app.guid)
.values_list('app_version', 'works_properly')
.annotate(Count('id')))
for ver, works_properly, cnt in reports:
ver = vint(floor_version(ver))
major = [v['main'] for v in versions
if vint(v['previous']) < ver <= vint(v['main'])]
if major:
w = doc['works'][app.id][vint(major[0])]
# Tally number of success and failure reports.
w['success' if works_properly else 'failure'] += cnt
w['total'] += cnt
# Calculate % of incompatibility reports.
w['failure_ratio'] = w['failure'] / float(w['total'])
if app not in addon.compatible_apps:
continue
compat = addon.compatible_apps[app]
d = {'min': compat.min.version_int,
'max': compat.max.version_int}
doc.setdefault('support', {})[app.id] = d
doc.setdefault('max_version', {})[app.id] = compat.max.version
total = sum(updates.values())
# Remember the total so we can show % of usage later.
compat_total, created = CompatTotals.objects.safer_get_or_create(
app=app.id,
defaults={'total': total})
if not created:
compat_total.update(total=total)
# Figure out which add-ons are in the top 95% for this app.
running_total = 0
for addon, count in sorted(updates.items(), key=lambda x: x[1],
reverse=True):
running_total += count
docs[addon]['top_95_all'][app.id] = running_total < (.95 * total)
# Mark the top 95% of add-ons compatible with the previous version for each
# app + version combo.
for compat in amo.COMPAT:
app, ver = compat['app'], vint(compat['previous'])
# Find all the docs that have a max_version compatible with ver.
supported = [compat_doc for compat_doc in docs.values()
if (app in compat_doc.get('support', {})
and compat_doc['support'][app]['max'] >= ver)]
# Sort by count so we can get the top 95% most-used add-ons.
supported = sorted(supported, key=lambda d: d['count'], reverse=True)
total = sum(doc['count'] for doc in supported)
# Figure out which add-ons are in the top 95% for this app + version.
running_total = 0
for doc in supported:
running_total += doc['count']
doc['top_95'][app][ver] = running_total < (.95 * total)
# Send it all to the index.
for chunk in amo.utils.chunked(docs.values(), 150):
for doc in chunk:
for index in indices:
AppCompat.index(doc, id=doc['id'], refresh=False, index=index)
es = amo.search.get_es()
es.indices.refresh()
|
bsd-3-clause
|
[
646,
2050,
199,
504,
5055,
492,
10018,
199,
199,
504,
1639,
14,
697,
14,
992,
492,
14826,
12,
8228,
199,
199,
646,
19818,
6920,
199,
199,
646,
30235,
199,
646,
30235,
14,
1733,
199,
646,
30235,
14,
1208,
199,
504,
21293,
14,
992,
492,
29366,
199,
504,
2754,
14,
1208,
492,
19841,
63,
1023,
199,
504,
5020,
14,
992,
492,
6162,
2353,
199,
504,
5459,
14,
5785,
492,
1015,
63,
442,
465,
373,
442,
199,
504,
1973,
14,
397,
14,
1208,
492,
664,
63,
4108,
199,
199,
504,
1275,
992,
492,
4693,
2404,
292,
12,
3599,
292,
7457,
12,
3599,
292,
7316,
83,
199,
199,
793,
275,
2050,
14,
5572,
360,
90,
14,
5819,
358,
421,
199,
32,
14829,
6920,
14,
2683,
199,
318,
7163,
63,
3070,
8,
1080,
29,
403,
304,
272,
9149,
275,
10018,
8,
807,
9,
272,
4918,
275,
664,
63,
4108,
8,
1080,
9,
339,
327,
19634,
1006,
314,
666,
367,
314,
1478,
14,
272,
367,
1145,
315,
30235,
14,
7121,
63,
20274,
26,
267,
5459,
275,
359,
67,
367,
286,
315,
30235,
14,
29720,
340,
286,
459,
571,
418,
508,
1145,
14,
344,
61,
398,
943,
14,
815,
8,
85,
7,
45,
11124,
8434,
3622,
367,
450,
83,
3530,
450,
1145,
14,
9118,
9,
267,
8839,
275,
6162,
2353,
14,
1462,
14,
7516,
8,
68,
29,
4261,
360,
602,
1333,
459,
68,
418,
267,
6377,
275,
6162,
2353,
14,
1462,
14,
1541,
8,
9291,
363,
571,
4058,
363,
571,
29,
571,
14,
344,
12,
3147,
13553,
363,
7011,
63,
991,
63,
751,
29,
797,
12,
3147,
13553,
363,
1205,
363,
262,
29,
4393,
14,
5600,
63,
6305,
654,
12,
3147,
13553,
8989,
1818,
63,
1023,
363,
15114,
29,
797,
12,
3147,
1434,
29,
7410,
9,
398,
7029,
275,
1211,
8,
6177,
14,
1459,
63,
513,
360,
9291,
297,
283,
835,
1333,
267,
367,
3728,
315,
30235,
14,
1208,
14,
19955,
8,
7618,
14,
1744,
1062,
5238,
304,
288,
3728,
275,
1211,
8,
4604,
9,
288,
367,
13553,
315,
29366,
14,
1462,
14,
1541,
8,
344,
363,
262,
29,
4604,
304,
355,
1382,
275,
9149,
59,
9291,
14,
344,
61,
355,
1382,
14,
873,
8,
344,
29,
9291,
14,
344,
12,
8889,
29,
9291,
14,
5464,
12,
15593,
29,
9291,
14,
9473,
12,
2574,
3366,
29,
9291,
14,
3008,
63,
4608,
12,
2574,
536,
29,
2975,
8,
9291,
14,
354,
395,
2737,
29,
9291,
14,
3966,
12,
2574,
1453,
63,
1023,
29,
9291,
14,
1818,
63,
1023,
14,
1023,
12,
2574,
1453,
63,
1023,
63,
344,
29,
9291,
14,
1818,
63,
1023,
14,
2051,
9,
355,
1382,
459,
835,
418,
275,
3728,
59,
9291,
14,
344,
61,
355,
1382,
14,
5486,
360,
2119,
63,
2720,
297,
3044,
10018,
8,
2734,
26,
10018,
8,
807,
1724,
355,
1382,
14,
5486,
360,
2119,
63,
2720,
63,
452,
297,
5009,
355,
1382,
14,
5486,
360,
3807,
297,
1052,
2788,
571,
14,
344,
61,
275,
7029,
59,
9291,
14,
344,
61,
355,
1382,
14,
5486,
360,
12243,
297,
13056,
5486,
8,
571,
14,
344,
12,
5009,
2234,
327,
31731,
543,
849,
8242,
367,
1006,
1145,
5459,
14,
355,
367,
809,
315,
5459,
26,
490,
1382,
459,
12243,
3488,
571,
14,
344,
1527,
86,
442,
8,
422,
459,
973,
24437,
275,
469,
717,
283,
3742,
356,
378,
12,
717,
283,
5328,
356,
378,
12,
717,
283,
2923,
356,
378,
12,
717,
283,
5328,
63,
6884,
356,
378,
14,
16,
12,
490,
789,
2234,
327,
5611,
13924,
701,
658,
8452,
2313,
64,
11067,
64,
1145,
1015,
14,
355,
13924,
275,
334,
2404,
292,
7457,
14,
1462,
2574,
1275,
1541,
8,
9473,
29,
9291,
14,
9473,
12,
1145,
63,
9473,
29,
571,
14,
9473,
9,
2574,
1275,
1459,
63,
513,
360,
571,
63,
1023,
297,
283,
12243,
63,
28314,
590,
358,
2574,
1275,
10898,
8,
2353,
360,
344,
7058,
355,
367,
809,
12,
5419,
63,
28314,
590,
12,
12703,
315,
13924,
26,
490,
809,
275,
373,
442,
8,
11289,
63,
1023,
8,
422,
430,
490,
12160,
275,
359,
86,
459,
973,
418,
367,
373,
315,
5459,
2490,
340,
373,
442,
8,
86,
459,
6352,
1105,
665,
809,
2695,
373,
442,
8,
86,
459,
973,
24437,
490,
340,
12160,
26,
717,
336,
275,
1382,
459,
12243,
3488,
571,
14,
344,
1527,
86,
442,
8,
8452,
59,
16,
12457,
717,
327,
377,
1183,
1329,
402,
3182,
436,
5988,
13924,
14,
717,
336,
459,
3742,
7,
340,
5419,
63,
28314,
590,
587,
283,
5328,
418,
847,
12703,
717,
336,
459,
2923,
418,
847,
12703,
717,
327,
12707,
450,
402,
315,
15390,
13924,
14,
717,
336,
459,
5328,
63,
6884,
418,
275,
336,
459,
5328,
418,
1182,
2069,
8,
87,
459,
2923,
1105,
2234,
340,
1145,
440,
315,
13553,
14,
6490,
63,
5181,
26,
490,
1980,
355,
8434,
275,
13553,
14,
6490,
63,
5181,
59,
571,
61,
355,
366,
275,
791,
827,
356,
8434,
14,
827,
14,
1023,
63,
442,
12,
2151,
283,
988,
356,
8434,
14,
988,
14,
1023,
63,
442,
93,
355,
1382,
14,
5486,
360,
4058,
297,
1052,
2788,
571,
14,
344,
61,
275,
366,
355,
1382,
14,
5486,
360,
988,
63,
1023,
297,
1052,
2788,
571,
14,
344,
61,
275,
8434,
14,
988,
14,
1023,
398,
3141,
275,
3089,
8,
7618,
14,
1459,
1012,
267,
327,
31859,
314,
3141,
880,
781,
883,
2498,
450,
402,
4503,
2945,
14,
267,
8434,
63,
2923,
12,
2737,
275,
3599,
292,
7316,
83,
14,
1462,
14,
2231,
2412,
63,
362,
63,
269,
63,
981,
8,
288,
1145,
29,
571,
14,
344,
12,
288,
4243,
3713,
2923,
356,
3141,
1552,
267,
340,
440,
2737,
26,
288,
8434,
63,
2923,
14,
873,
8,
2923,
29,
2923,
9,
398,
327,
16266,
734,
1314,
1050,
13,
4654,
787,
315,
314,
2746,
16102,
5,
367,
642,
1145,
14,
267,
3879,
63,
2923,
275,
378,
267,
367,
13553,
12,
2338,
315,
3355,
8,
7618,
14,
1744,
1062,
790,
29,
2734,
671,
26,
671,
59,
17,
467,
3521,
3837,
29,
549,
304,
288,
3879,
63,
2923,
847,
2338,
288,
9149,
59,
9291,
2733,
2119,
63,
2720,
63,
452,
3488,
571,
14,
344,
61,
275,
3879,
63,
2923,
665,
17048,
2720,
627,
3141,
9,
339,
327,
7173,
314,
2746
] |
[
2050,
199,
504,
5055,
492,
10018,
199,
199,
504,
1639,
14,
697,
14,
992,
492,
14826,
12,
8228,
199,
199,
646,
19818,
6920,
199,
199,
646,
30235,
199,
646,
30235,
14,
1733,
199,
646,
30235,
14,
1208,
199,
504,
21293,
14,
992,
492,
29366,
199,
504,
2754,
14,
1208,
492,
19841,
63,
1023,
199,
504,
5020,
14,
992,
492,
6162,
2353,
199,
504,
5459,
14,
5785,
492,
1015,
63,
442,
465,
373,
442,
199,
504,
1973,
14,
397,
14,
1208,
492,
664,
63,
4108,
199,
199,
504,
1275,
992,
492,
4693,
2404,
292,
12,
3599,
292,
7457,
12,
3599,
292,
7316,
83,
199,
199,
793,
275,
2050,
14,
5572,
360,
90,
14,
5819,
358,
421,
199,
32,
14829,
6920,
14,
2683,
199,
318,
7163,
63,
3070,
8,
1080,
29,
403,
304,
272,
9149,
275,
10018,
8,
807,
9,
272,
4918,
275,
664,
63,
4108,
8,
1080,
9,
339,
327,
19634,
1006,
314,
666,
367,
314,
1478,
14,
272,
367,
1145,
315,
30235,
14,
7121,
63,
20274,
26,
267,
5459,
275,
359,
67,
367,
286,
315,
30235,
14,
29720,
340,
286,
459,
571,
418,
508,
1145,
14,
344,
61,
398,
943,
14,
815,
8,
85,
7,
45,
11124,
8434,
3622,
367,
450,
83,
3530,
450,
1145,
14,
9118,
9,
267,
8839,
275,
6162,
2353,
14,
1462,
14,
7516,
8,
68,
29,
4261,
360,
602,
1333,
459,
68,
418,
267,
6377,
275,
6162,
2353,
14,
1462,
14,
1541,
8,
9291,
363,
571,
4058,
363,
571,
29,
571,
14,
344,
12,
3147,
13553,
363,
7011,
63,
991,
63,
751,
29,
797,
12,
3147,
13553,
363,
1205,
363,
262,
29,
4393,
14,
5600,
63,
6305,
654,
12,
3147,
13553,
8989,
1818,
63,
1023,
363,
15114,
29,
797,
12,
3147,
1434,
29,
7410,
9,
398,
7029,
275,
1211,
8,
6177,
14,
1459,
63,
513,
360,
9291,
297,
283,
835,
1333,
267,
367,
3728,
315,
30235,
14,
1208,
14,
19955,
8,
7618,
14,
1744,
1062,
5238,
304,
288,
3728,
275,
1211,
8,
4604,
9,
288,
367,
13553,
315,
29366,
14,
1462,
14,
1541,
8,
344,
363,
262,
29,
4604,
304,
355,
1382,
275,
9149,
59,
9291,
14,
344,
61,
355,
1382,
14,
873,
8,
344,
29,
9291,
14,
344,
12,
8889,
29,
9291,
14,
5464,
12,
15593,
29,
9291,
14,
9473,
12,
2574,
3366,
29,
9291,
14,
3008,
63,
4608,
12,
2574,
536,
29,
2975,
8,
9291,
14,
354,
395,
2737,
29,
9291,
14,
3966,
12,
2574,
1453,
63,
1023,
29,
9291,
14,
1818,
63,
1023,
14,
1023,
12,
2574,
1453,
63,
1023,
63,
344,
29,
9291,
14,
1818,
63,
1023,
14,
2051,
9,
355,
1382,
459,
835,
418,
275,
3728,
59,
9291,
14,
344,
61,
355,
1382,
14,
5486,
360,
2119,
63,
2720,
297,
3044,
10018,
8,
2734,
26,
10018,
8,
807,
1724,
355,
1382,
14,
5486,
360,
2119,
63,
2720,
63,
452,
297,
5009,
355,
1382,
14,
5486,
360,
3807,
297,
1052,
2788,
571,
14,
344,
61,
275,
7029,
59,
9291,
14,
344,
61,
355,
1382,
14,
5486,
360,
12243,
297,
13056,
5486,
8,
571,
14,
344,
12,
5009,
2234,
327,
31731,
543,
849,
8242,
367,
1006,
1145,
5459,
14,
355,
367,
809,
315,
5459,
26,
490,
1382,
459,
12243,
3488,
571,
14,
344,
1527,
86,
442,
8,
422,
459,
973,
24437,
275,
469,
717,
283,
3742,
356,
378,
12,
717,
283,
5328,
356,
378,
12,
717,
283,
2923,
356,
378,
12,
717,
283,
5328,
63,
6884,
356,
378,
14,
16,
12,
490,
789,
2234,
327,
5611,
13924,
701,
658,
8452,
2313,
64,
11067,
64,
1145,
1015,
14,
355,
13924,
275,
334,
2404,
292,
7457,
14,
1462,
2574,
1275,
1541,
8,
9473,
29,
9291,
14,
9473,
12,
1145,
63,
9473,
29,
571,
14,
9473,
9,
2574,
1275,
1459,
63,
513,
360,
571,
63,
1023,
297,
283,
12243,
63,
28314,
590,
358,
2574,
1275,
10898,
8,
2353,
360,
344,
7058,
355,
367,
809,
12,
5419,
63,
28314,
590,
12,
12703,
315,
13924,
26,
490,
809,
275,
373,
442,
8,
11289,
63,
1023,
8,
422,
430,
490,
12160,
275,
359,
86,
459,
973,
418,
367,
373,
315,
5459,
2490,
340,
373,
442,
8,
86,
459,
6352,
1105,
665,
809,
2695,
373,
442,
8,
86,
459,
973,
24437,
490,
340,
12160,
26,
717,
336,
275,
1382,
459,
12243,
3488,
571,
14,
344,
1527,
86,
442,
8,
8452,
59,
16,
12457,
717,
327,
377,
1183,
1329,
402,
3182,
436,
5988,
13924,
14,
717,
336,
459,
3742,
7,
340,
5419,
63,
28314,
590,
587,
283,
5328,
418,
847,
12703,
717,
336,
459,
2923,
418,
847,
12703,
717,
327,
12707,
450,
402,
315,
15390,
13924,
14,
717,
336,
459,
5328,
63,
6884,
418,
275,
336,
459,
5328,
418,
1182,
2069,
8,
87,
459,
2923,
1105,
2234,
340,
1145,
440,
315,
13553,
14,
6490,
63,
5181,
26,
490,
1980,
355,
8434,
275,
13553,
14,
6490,
63,
5181,
59,
571,
61,
355,
366,
275,
791,
827,
356,
8434,
14,
827,
14,
1023,
63,
442,
12,
2151,
283,
988,
356,
8434,
14,
988,
14,
1023,
63,
442,
93,
355,
1382,
14,
5486,
360,
4058,
297,
1052,
2788,
571,
14,
344,
61,
275,
366,
355,
1382,
14,
5486,
360,
988,
63,
1023,
297,
1052,
2788,
571,
14,
344,
61,
275,
8434,
14,
988,
14,
1023,
398,
3141,
275,
3089,
8,
7618,
14,
1459,
1012,
267,
327,
31859,
314,
3141,
880,
781,
883,
2498,
450,
402,
4503,
2945,
14,
267,
8434,
63,
2923,
12,
2737,
275,
3599,
292,
7316,
83,
14,
1462,
14,
2231,
2412,
63,
362,
63,
269,
63,
981,
8,
288,
1145,
29,
571,
14,
344,
12,
288,
4243,
3713,
2923,
356,
3141,
1552,
267,
340,
440,
2737,
26,
288,
8434,
63,
2923,
14,
873,
8,
2923,
29,
2923,
9,
398,
327,
16266,
734,
1314,
1050,
13,
4654,
787,
315,
314,
2746,
16102,
5,
367,
642,
1145,
14,
267,
3879,
63,
2923,
275,
378,
267,
367,
13553,
12,
2338,
315,
3355,
8,
7618,
14,
1744,
1062,
790,
29,
2734,
671,
26,
671,
59,
17,
467,
3521,
3837,
29,
549,
304,
288,
3879,
63,
2923,
847,
2338,
288,
9149,
59,
9291,
2733,
2119,
63,
2720,
63,
452,
3488,
571,
14,
344,
61,
275,
3879,
63,
2923,
665,
17048,
2720,
627,
3141,
9,
339,
327,
7173,
314,
2746,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
ntucllab/libact
|
libact/query_strategies/tests/test_uncertainty_sampling.py
|
1
|
3010
|
import unittest
import numpy as np
from numpy.testing import assert_array_equal
from libact.base.dataset import Dataset
from libact.models import LogisticRegression, SVM, Perceptron
from libact.query_strategies import UncertaintySampling, QUIRE
from libact.labelers import IdealLabeler
def init_toyexample(X, y):
trn_ds = Dataset(X, np.concatenate([y[:6], [None] * 4]))
return trn_ds
def run_qs(trn_ds, lbr, model, qs, quota):
qseq = []
for _ in range(quota):
ask_id, score = qs.make_query(return_score=True)
X, _ = zip(*trn_ds.data)
lbl = lbr.label(X[ask_id])
trn_ds.update(ask_id, lbl)
qseq.append(ask_id)
return np.array(qseq)
class UncertaintySamplingTestCase(unittest.TestCase):
def setUp(self):
self.X = [[-2, -1], [-1, -1], [-1, -2], [1, 1], [1, 2], [2, 1], [0, 1],
[0, -2], [1.5, 1.5], [-2, -2]]
self.y = [-1, -1, -1, 1, 1, 1, -1, -1, 1, 1]
self.quota = 4
self.fully_labeled_trn_ds = Dataset(self.X, self.y)
self.lbr = IdealLabeler(self.fully_labeled_trn_ds)
def test_uncertainty_lc(self):
trn_ds = init_toyexample(self.X, self.y)
qs = UncertaintySampling(
trn_ds, method='lc',
model=LogisticRegression(solver='liblinear', multi_class="ovr"))
model = LogisticRegression(solver='liblinear', multi_class="ovr")
qseq = run_qs(trn_ds, self.lbr, model, qs, self.quota)
assert_array_equal(qseq, np.array([6, 7, 8, 9]))
def test_uncertainty_sm(self):
trn_ds = init_toyexample(self.X, self.y)
qs = UncertaintySampling(
trn_ds, method='sm',
model=LogisticRegression(solver='liblinear', multi_class="ovr"))
model = LogisticRegression(solver='liblinear', multi_class="ovr")
qseq = run_qs(trn_ds, self.lbr, model, qs, self.quota)
assert_array_equal(qseq, np.array([6, 7, 8, 9]))
def test_uncertainty_entropy(self):
trn_ds = init_toyexample(self.X, self.y)
qs = UncertaintySampling(
trn_ds, method='entropy',
model=LogisticRegression(solver='liblinear', multi_class="ovr"))
model = LogisticRegression(solver='liblinear', multi_class="ovr")
qseq = run_qs(trn_ds, self.lbr, model, qs, self.quota)
assert_array_equal(qseq, np.array([6, 7, 8, 9]))
def test_uncertainty_entropy_exceptions(self):
trn_ds = init_toyexample(self.X, self.y)
with self.assertRaises(TypeError):
qs = UncertaintySampling(trn_ds, method='entropy', model=SVM())
with self.assertRaises(TypeError):
qs = UncertaintySampling(
trn_ds, method='entropy', model=Perceptron())
with self.assertRaises(TypeError):
qs = UncertaintySampling(
trn_ds, method='not_exist',
model=LogisticRegression(solver='liblinear', multi_class="ovr"))
if __name__ == '__main__':
unittest.main()
|
bsd-2-clause
|
[
646,
2882,
199,
199,
646,
2680,
465,
980,
199,
504,
2680,
14,
4776,
492,
702,
63,
1144,
63,
1452,
199,
199,
504,
1973,
2442,
14,
1095,
14,
5214,
492,
20284,
199,
504,
1973,
2442,
14,
992,
492,
27903,
12,
428,
6849,
12,
3492,
301,
4695,
265,
199,
504,
1973,
2442,
14,
1131,
63,
20694,
1500,
492,
1910,
20226,
369,
12226,
8922,
12,
1413,
6379,
907,
199,
504,
1973,
2442,
14,
19879,
29099,
492,
473,
21245,
44,
7570,
1435,
421,
199,
318,
4205,
63,
19126,
2694,
8,
56,
12,
612,
304,
272,
5651,
78,
63,
795,
275,
20284,
8,
56,
12,
980,
14,
13433,
779,
89,
1491,
22,
467,
359,
403,
61,
627,
841,
2459,
272,
372,
5651,
78,
63,
795,
421,
199,
318,
1255,
63,
6177,
8,
454,
78,
63,
795,
12,
634,
3289,
12,
1402,
12,
6377,
12,
12132,
304,
272,
1894,
3610,
275,
942,
272,
367,
485,
315,
1425,
8,
8848,
304,
267,
7198,
63,
344,
12,
5396,
275,
6377,
14,
1875,
63,
1131,
8,
1107,
63,
3397,
29,
549,
9,
267,
1323,
12,
485,
275,
3482,
2031,
454,
78,
63,
795,
14,
576,
9,
267,
32375,
275,
634,
3289,
14,
1302,
8,
56,
59,
813,
63,
344,
566,
267,
5651,
78,
63,
795,
14,
873,
8,
813,
63,
344,
12,
32375,
9,
267,
1894,
3610,
14,
740,
8,
813,
63,
344,
9,
272,
372,
980,
14,
1144,
8,
81,
3610,
9,
421,
199,
533,
1910,
20226,
369,
12226,
8922,
1746,
8,
2796,
14,
1746,
304,
339,
347,
3613,
8,
277,
304,
267,
291,
14,
56,
275,
27291,
18,
12,
446,
17,
467,
5243,
17,
12,
446,
17,
467,
5243,
17,
12,
446,
18,
467,
359,
17,
12,
413,
467,
359,
17,
12,
499,
467,
359,
18,
12,
413,
467,
359,
16,
12,
413,
467,
2116,
359,
16,
12,
446,
18,
467,
359,
17,
14,
21,
12,
413,
14,
21,
467,
5243,
18,
12,
446,
18,
2677,
267,
291,
14,
89,
275,
5243,
17,
12,
446,
17,
12,
446,
17,
12,
413,
12,
413,
12,
413,
12,
446,
17,
12,
446,
17,
12,
413,
12,
413,
61,
267,
291,
14,
8848,
275,
841,
267,
291,
14,
5836,
63,
21242,
63,
454,
78,
63,
795,
275,
20284,
8,
277,
14,
56,
12,
291,
14,
89,
9,
267,
291,
14,
76,
3289,
275,
473,
21245,
44,
7570,
1435,
8,
277,
14,
5836,
63,
21242,
63,
454,
78,
63,
795,
9,
339,
347,
511,
63,
31794,
877,
369,
63,
10181,
8,
277,
304,
267,
5651,
78,
63,
795,
275,
4205,
63,
19126,
2694,
8,
277,
14,
56,
12,
291,
14,
89,
9,
267,
6377,
275,
1910,
20226,
369,
12226,
8922,
8,
288,
5651,
78,
63,
795,
12,
1083,
534,
10181,
297,
288,
1402,
29,
2445,
23032,
8,
11263,
534,
773,
6676,
297,
3510,
63,
533,
628,
8822,
82,
2237,
267,
1402,
275,
27903,
8,
11263,
534,
773,
6676,
297,
3510,
63,
533,
628,
8822,
82,
531,
267,
1894,
3610,
275,
1255,
63,
6177,
8,
454,
78,
63,
795,
12,
291,
14,
76,
3289,
12,
1402,
12,
6377,
12,
291,
14,
8848,
9,
267,
702,
63,
1144,
63,
1452,
8,
81,
3610,
12,
980,
14,
1144,
779,
22,
12,
1520,
12,
1695,
12,
1749,
2459,
339,
347,
511,
63,
31794,
877,
369,
63,
3300,
8,
277,
304,
267,
5651,
78,
63,
795,
275,
4205,
63,
19126,
2694,
8,
277,
14,
56,
12,
291,
14,
89,
9,
267,
6377,
275,
1910,
20226,
369,
12226,
8922,
8,
288,
5651,
78,
63,
795,
12,
1083,
534,
3300,
297,
288,
1402,
29,
2445,
23032,
8,
11263,
534,
773,
6676,
297,
3510,
63,
533,
628,
8822,
82,
2237,
267,
1402,
275,
27903,
8,
11263,
534,
773,
6676,
297,
3510,
63,
533,
628,
8822,
82,
531,
267,
1894,
3610,
275,
1255,
63,
6177,
8,
454,
78,
63,
795,
12,
291,
14,
76,
3289,
12,
1402,
12,
6377,
12,
291,
14,
8848,
9,
267,
702,
63,
1144,
63,
1452,
8,
81,
3610,
12,
980,
14,
1144,
779,
22,
12,
1520,
12,
1695,
12,
1749,
2459,
339,
347,
511,
63,
31794,
877,
369,
63,
10435,
8,
277,
304,
267,
5651,
78,
63,
795,
275,
4205,
63,
19126,
2694,
8,
277,
14,
56,
12,
291,
14,
89,
9,
267,
6377,
275,
1910,
20226,
369,
12226,
8922,
8,
288,
5651,
78,
63,
795,
12,
1083,
534,
10435,
297,
288,
1402,
29,
2445,
23032,
8,
11263,
534,
773,
6676,
297,
3510,
63,
533,
628,
8822,
82,
2237,
267,
1402,
275,
27903,
8,
11263,
534,
773,
6676,
297,
3510,
63,
533,
628,
8822,
82,
531,
267,
1894,
3610,
275,
1255,
63,
6177,
8,
454,
78,
63,
795,
12,
291,
14,
76,
3289,
12,
1402,
12,
6377,
12,
291,
14,
8848,
9,
267,
702,
63,
1144,
63,
1452,
8,
81,
3610,
12,
980,
14,
1144,
779,
22,
12,
1520,
12,
1695,
12,
1749,
2459,
339,
347,
511,
63,
31794,
877,
369,
63,
10435,
63,
3924,
8,
277,
304,
267,
5651,
78,
63,
795,
275,
4205,
63,
19126,
2694,
8,
277,
14,
56,
12,
291,
14,
89,
9,
398,
543,
291,
14,
1855,
8,
4333,
304,
288,
6377,
275,
1910,
20226,
369,
12226,
8922,
8,
454,
78,
63,
795,
12,
1083,
534,
10435,
297,
1402,
29,
29389,
1012,
398,
543,
291,
14,
1855,
8,
4333,
304,
288,
6377,
275,
1910,
20226,
369,
12226,
8922,
8,
490,
5651,
78,
63,
795,
12,
1083,
534,
10435,
297,
1402,
29,
2623,
301,
4695,
265,
1012,
398,
543,
291,
14,
1855,
8,
4333,
304,
288,
6377,
275,
1910,
20226,
369,
12226,
8922,
8,
490,
5651,
78,
63,
795,
12,
1083,
534,
1397,
63,
4494,
297,
490,
1402,
29,
2445,
23032,
8,
11263,
534,
773,
6676,
297,
3510,
63,
533,
628,
8822,
82,
2237,
421,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
272,
2882,
14,
973,
342,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
2882,
199,
199,
646,
2680,
465,
980,
199,
504,
2680,
14,
4776,
492,
702,
63,
1144,
63,
1452,
199,
199,
504,
1973,
2442,
14,
1095,
14,
5214,
492,
20284,
199,
504,
1973,
2442,
14,
992,
492,
27903,
12,
428,
6849,
12,
3492,
301,
4695,
265,
199,
504,
1973,
2442,
14,
1131,
63,
20694,
1500,
492,
1910,
20226,
369,
12226,
8922,
12,
1413,
6379,
907,
199,
504,
1973,
2442,
14,
19879,
29099,
492,
473,
21245,
44,
7570,
1435,
421,
199,
318,
4205,
63,
19126,
2694,
8,
56,
12,
612,
304,
272,
5651,
78,
63,
795,
275,
20284,
8,
56,
12,
980,
14,
13433,
779,
89,
1491,
22,
467,
359,
403,
61,
627,
841,
2459,
272,
372,
5651,
78,
63,
795,
421,
199,
318,
1255,
63,
6177,
8,
454,
78,
63,
795,
12,
634,
3289,
12,
1402,
12,
6377,
12,
12132,
304,
272,
1894,
3610,
275,
942,
272,
367,
485,
315,
1425,
8,
8848,
304,
267,
7198,
63,
344,
12,
5396,
275,
6377,
14,
1875,
63,
1131,
8,
1107,
63,
3397,
29,
549,
9,
267,
1323,
12,
485,
275,
3482,
2031,
454,
78,
63,
795,
14,
576,
9,
267,
32375,
275,
634,
3289,
14,
1302,
8,
56,
59,
813,
63,
344,
566,
267,
5651,
78,
63,
795,
14,
873,
8,
813,
63,
344,
12,
32375,
9,
267,
1894,
3610,
14,
740,
8,
813,
63,
344,
9,
272,
372,
980,
14,
1144,
8,
81,
3610,
9,
421,
199,
533,
1910,
20226,
369,
12226,
8922,
1746,
8,
2796,
14,
1746,
304,
339,
347,
3613,
8,
277,
304,
267,
291,
14,
56,
275,
27291,
18,
12,
446,
17,
467,
5243,
17,
12,
446,
17,
467,
5243,
17,
12,
446,
18,
467,
359,
17,
12,
413,
467,
359,
17,
12,
499,
467,
359,
18,
12,
413,
467,
359,
16,
12,
413,
467,
2116,
359,
16,
12,
446,
18,
467,
359,
17,
14,
21,
12,
413,
14,
21,
467,
5243,
18,
12,
446,
18,
2677,
267,
291,
14,
89,
275,
5243,
17,
12,
446,
17,
12,
446,
17,
12,
413,
12,
413,
12,
413,
12,
446,
17,
12,
446,
17,
12,
413,
12,
413,
61,
267,
291,
14,
8848,
275,
841,
267,
291,
14,
5836,
63,
21242,
63,
454,
78,
63,
795,
275,
20284,
8,
277,
14,
56,
12,
291,
14,
89,
9,
267,
291,
14,
76,
3289,
275,
473,
21245,
44,
7570,
1435,
8,
277,
14,
5836,
63,
21242,
63,
454,
78,
63,
795,
9,
339,
347,
511,
63,
31794,
877,
369,
63,
10181,
8,
277,
304,
267,
5651,
78,
63,
795,
275,
4205,
63,
19126,
2694,
8,
277,
14,
56,
12,
291,
14,
89,
9,
267,
6377,
275,
1910,
20226,
369,
12226,
8922,
8,
288,
5651,
78,
63,
795,
12,
1083,
534,
10181,
297,
288,
1402,
29,
2445,
23032,
8,
11263,
534,
773,
6676,
297,
3510,
63,
533,
628,
8822,
82,
2237,
267,
1402,
275,
27903,
8,
11263,
534,
773,
6676,
297,
3510,
63,
533,
628,
8822,
82,
531,
267,
1894,
3610,
275,
1255,
63,
6177,
8,
454,
78,
63,
795,
12,
291,
14,
76,
3289,
12,
1402,
12,
6377,
12,
291,
14,
8848,
9,
267,
702,
63,
1144,
63,
1452,
8,
81,
3610,
12,
980,
14,
1144,
779,
22,
12,
1520,
12,
1695,
12,
1749,
2459,
339,
347,
511,
63,
31794,
877,
369,
63,
3300,
8,
277,
304,
267,
5651,
78,
63,
795,
275,
4205,
63,
19126,
2694,
8,
277,
14,
56,
12,
291,
14,
89,
9,
267,
6377,
275,
1910,
20226,
369,
12226,
8922,
8,
288,
5651,
78,
63,
795,
12,
1083,
534,
3300,
297,
288,
1402,
29,
2445,
23032,
8,
11263,
534,
773,
6676,
297,
3510,
63,
533,
628,
8822,
82,
2237,
267,
1402,
275,
27903,
8,
11263,
534,
773,
6676,
297,
3510,
63,
533,
628,
8822,
82,
531,
267,
1894,
3610,
275,
1255,
63,
6177,
8,
454,
78,
63,
795,
12,
291,
14,
76,
3289,
12,
1402,
12,
6377,
12,
291,
14,
8848,
9,
267,
702,
63,
1144,
63,
1452,
8,
81,
3610,
12,
980,
14,
1144,
779,
22,
12,
1520,
12,
1695,
12,
1749,
2459,
339,
347,
511,
63,
31794,
877,
369,
63,
10435,
8,
277,
304,
267,
5651,
78,
63,
795,
275,
4205,
63,
19126,
2694,
8,
277,
14,
56,
12,
291,
14,
89,
9,
267,
6377,
275,
1910,
20226,
369,
12226,
8922,
8,
288,
5651,
78,
63,
795,
12,
1083,
534,
10435,
297,
288,
1402,
29,
2445,
23032,
8,
11263,
534,
773,
6676,
297,
3510,
63,
533,
628,
8822,
82,
2237,
267,
1402,
275,
27903,
8,
11263,
534,
773,
6676,
297,
3510,
63,
533,
628,
8822,
82,
531,
267,
1894,
3610,
275,
1255,
63,
6177,
8,
454,
78,
63,
795,
12,
291,
14,
76,
3289,
12,
1402,
12,
6377,
12,
291,
14,
8848,
9,
267,
702,
63,
1144,
63,
1452,
8,
81,
3610,
12,
980,
14,
1144,
779,
22,
12,
1520,
12,
1695,
12,
1749,
2459,
339,
347,
511,
63,
31794,
877,
369,
63,
10435,
63,
3924,
8,
277,
304,
267,
5651,
78,
63,
795,
275,
4205,
63,
19126,
2694,
8,
277,
14,
56,
12,
291,
14,
89,
9,
398,
543,
291,
14,
1855,
8,
4333,
304,
288,
6377,
275,
1910,
20226,
369,
12226,
8922,
8,
454,
78,
63,
795,
12,
1083,
534,
10435,
297,
1402,
29,
29389,
1012,
398,
543,
291,
14,
1855,
8,
4333,
304,
288,
6377,
275,
1910,
20226,
369,
12226,
8922,
8,
490,
5651,
78,
63,
795,
12,
1083,
534,
10435,
297,
1402,
29,
2623,
301,
4695,
265,
1012,
398,
543,
291,
14,
1855,
8,
4333,
304,
288,
6377,
275,
1910,
20226,
369,
12226,
8922,
8,
490,
5651,
78,
63,
795,
12,
1083,
534,
1397,
63,
4494,
297,
490,
1402,
29,
2445,
23032,
8,
11263,
534,
773,
6676,
297,
3510,
63,
533,
628,
8822,
82,
2237,
421,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
272,
2882,
14,
973,
342,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
verifiedpixel/superdesk
|
server/macros/abstract_populator_test.py
|
8
|
2029
|
# -*- coding: utf-8; -*-
#
# This file is part of Superdesk.
#
# Copyright 2013, 2014 Sourcefabric z.u. and contributors.
#
# For the full copyright and license information, please see the
# AUTHORS and LICENSE files distributed with this source code, or
# at https://www.sourcefabric.org/superdesk/license
import unittest
from macros.abstract_populator import populate
class AbstractPopulatorTestCase(unittest.TestCase):
def setUp(self):
self.body = ("Fountain of Time, or simply Time, is a sculpture by Lorado Taft, "
"measuring 126 feet 10 inches (38.66 m) in length, situated at the "
"western edge of the Midway Plaisance within Washington Park in "
"Chicago, Illinois, in the United States. This location is in the "
"Washington Park community area on Chicago's South Side. Inspired "
"by Henry Austin Dobson's poem, \"Paradox of Time\", and with its "
"100 figures passing before Father Time, the work was created as a "
"monument to the first 100 years of peace between the United States "
"and Great Britain, resulting from the Treaty of Ghent in 1814. "
"Although the fountain's water began running in 1920, the sculpture "
"was not dedicated to the city until 1922. The sculpture is a "
"contributing structure to the Washington Park United States "
"Registered Historic District, which is a National Register of "
"Historic Places listing.")
def test_populate(self):
item = {'body_html': self.body}
item = populate(item)
self.assertEqual(item['abstract'], 'Fountain of Time, or simply Time, is a sculpture by Lorado Taft,')
def test_populate_without_body(self):
item = {}
item = populate(item)
self.assertEqual(item['abstract'], 'No body found to use for abstract...')
|
agpl-3.0
|
[
3,
1882,
2803,
26,
2774,
13,
24,
27,
1882,
199,
3,
199,
3,
961,
570,
365,
1777,
402,
17897,
10368,
14,
199,
3,
199,
3,
1898,
6171,
12,
6927,
5800,
4991,
1315,
14,
85,
14,
436,
8417,
14,
199,
3,
199,
3,
2104,
314,
2615,
4248,
436,
4190,
2556,
12,
8749,
1937,
314,
199,
3,
10610,
436,
5113,
1584,
1854,
543,
642,
1350,
1233,
12,
503,
199,
3,
737,
4178,
921,
1544,
14,
1365,
4991,
14,
1308,
15,
4792,
10368,
15,
1682,
421,
199,
646,
2882,
199,
504,
16954,
14,
6198,
63,
1935,
6109,
492,
13904,
421,
199,
533,
11836,
9606,
6109,
1746,
8,
2796,
14,
1746,
304,
339,
347,
3613,
8,
277,
304,
267,
291,
14,
2030,
275,
1689,
15563,
324,
877,
402,
4703,
12,
503,
9329,
4703,
12,
365,
282,
308,
3119,
541,
608,
701,
491,
269,
5129,
32316,
856,
12,
298,
2151,
298,
19116,
4039,
21572,
1964,
386,
1616,
315,
12253,
334,
1703,
14,
1272,
333,
9,
315,
2582,
12,
13867,
23130,
737,
314,
298,
2151,
298,
87,
397,
1203,
6275,
402,
314,
603,
344,
3316,
510,
416,
374,
554,
4453,
644,
1119,
31673,
510,
1096,
315,
298,
2151,
298,
28796,
12,
473,
76,
472,
79,
374,
12,
315,
314,
1910,
5703,
24230,
14,
961,
2909,
365,
315,
314,
298,
2151,
298,
55,
1119,
31673,
510,
1096,
23633,
9150,
641,
2799,
25751,
1159,
23150,
428,
2655,
14,
12062,
1038,
581,
298,
2151,
298,
991,
20855,
651,
437,
833,
262,
577,
2873,
834,
1159,
1115,
5633,
12,
8441,
1262,
5129,
88,
402,
4703,
20756,
436,
543,
2399,
298,
2151,
298,
1960,
6085,
1482,
9476,
2544,
481,
7404,
4703,
12,
314,
1736,
1990,
2737,
465,
282,
298,
2151,
298,
2106,
760,
370,
314,
1642,
2948,
17399,
402,
299,
4489,
301,
3382,
314,
1910,
5703,
24230,
298,
2151,
298,
460,
598,
8319,
699,
322,
877,
12,
9183,
687,
314,
377,
8319,
89,
402,
598,
72,
484,
315,
6155,
1079,
14,
298,
2151,
298,
2439,
15401,
314,
7090,
324,
877,
1159,
22834,
506,
24975,
3879,
315,
5851,
1165,
12,
314,
308,
3119,
541,
608,
298,
2151,
298,
10274,
440,
29711,
370,
314,
14492,
5133,
5851,
1081,
14,
710,
308,
3119,
541,
608,
365,
282,
298,
2151,
298,
2828,
4655,
5523,
370,
314,
644,
1119,
31673,
510,
1096,
1910,
5703,
24230,
298,
2151,
298,
20341,
869,
631,
269,
530,
577,
5230,
319,
12,
1314,
365,
282,
20548,
11828,
402,
298,
2151,
298,
27785,
269,
530,
510,
5862,
13778,
2685,
339,
347,
511,
63,
13817,
8,
277,
304,
267,
1242,
275,
791,
2030,
63,
1360,
356,
291,
14,
2030,
93,
267,
1242,
275,
13904,
8,
1053,
9,
267,
291,
14,
629,
8,
1053,
459,
6198,
995,
283,
15563,
324,
877,
402,
4703,
12,
503,
9329,
4703,
12,
365,
282,
308,
3119,
541,
608,
701,
491,
269,
5129,
32316,
856,
12,
358,
339,
347,
511,
63,
13817,
63,
7395,
63,
2030,
8,
277,
304,
267,
1242,
275,
1052,
267,
1242,
275,
13904,
8,
1053,
9,
267,
291,
14,
629,
8,
1053,
459,
6198,
995,
283,
1944,
2396,
1911,
370,
675,
367,
9006,
15103,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
1882,
2803,
26,
2774,
13,
24,
27,
1882,
199,
3,
199,
3,
961,
570,
365,
1777,
402,
17897,
10368,
14,
199,
3,
199,
3,
1898,
6171,
12,
6927,
5800,
4991,
1315,
14,
85,
14,
436,
8417,
14,
199,
3,
199,
3,
2104,
314,
2615,
4248,
436,
4190,
2556,
12,
8749,
1937,
314,
199,
3,
10610,
436,
5113,
1584,
1854,
543,
642,
1350,
1233,
12,
503,
199,
3,
737,
4178,
921,
1544,
14,
1365,
4991,
14,
1308,
15,
4792,
10368,
15,
1682,
421,
199,
646,
2882,
199,
504,
16954,
14,
6198,
63,
1935,
6109,
492,
13904,
421,
199,
533,
11836,
9606,
6109,
1746,
8,
2796,
14,
1746,
304,
339,
347,
3613,
8,
277,
304,
267,
291,
14,
2030,
275,
1689,
15563,
324,
877,
402,
4703,
12,
503,
9329,
4703,
12,
365,
282,
308,
3119,
541,
608,
701,
491,
269,
5129,
32316,
856,
12,
298,
2151,
298,
19116,
4039,
21572,
1964,
386,
1616,
315,
12253,
334,
1703,
14,
1272,
333,
9,
315,
2582,
12,
13867,
23130,
737,
314,
298,
2151,
298,
87,
397,
1203,
6275,
402,
314,
603,
344,
3316,
510,
416,
374,
554,
4453,
644,
1119,
31673,
510,
1096,
315,
298,
2151,
298,
28796,
12,
473,
76,
472,
79,
374,
12,
315,
314,
1910,
5703,
24230,
14,
961,
2909,
365,
315,
314,
298,
2151,
298,
55,
1119,
31673,
510,
1096,
23633,
9150,
641,
2799,
25751,
1159,
23150,
428,
2655,
14,
12062,
1038,
581,
298,
2151,
298,
991,
20855,
651,
437,
833,
262,
577,
2873,
834,
1159,
1115,
5633,
12,
8441,
1262,
5129,
88,
402,
4703,
20756,
436,
543,
2399,
298,
2151,
298,
1960,
6085,
1482,
9476,
2544,
481,
7404,
4703,
12,
314,
1736,
1990,
2737,
465,
282,
298,
2151,
298,
2106,
760,
370,
314,
1642,
2948,
17399,
402,
299,
4489,
301,
3382,
314,
1910,
5703,
24230,
298,
2151,
298,
460,
598,
8319,
699,
322,
877,
12,
9183,
687,
314,
377,
8319,
89,
402,
598,
72,
484,
315,
6155,
1079,
14,
298,
2151,
298,
2439,
15401,
314,
7090,
324,
877,
1159,
22834,
506,
24975,
3879,
315,
5851,
1165,
12,
314,
308,
3119,
541,
608,
298,
2151,
298,
10274,
440,
29711,
370,
314,
14492,
5133,
5851,
1081,
14,
710,
308,
3119,
541,
608,
365,
282,
298,
2151,
298,
2828,
4655,
5523,
370,
314,
644,
1119,
31673,
510,
1096,
1910,
5703,
24230,
298,
2151,
298,
20341,
869,
631,
269,
530,
577,
5230,
319,
12,
1314,
365,
282,
20548,
11828,
402,
298,
2151,
298,
27785,
269,
530,
510,
5862,
13778,
2685,
339,
347,
511,
63,
13817,
8,
277,
304,
267,
1242,
275,
791,
2030,
63,
1360,
356,
291,
14,
2030,
93,
267,
1242,
275,
13904,
8,
1053,
9,
267,
291,
14,
629,
8,
1053,
459,
6198,
995,
283,
15563,
324,
877,
402,
4703,
12,
503,
9329,
4703,
12,
365,
282,
308,
3119,
541,
608,
701,
491,
269,
5129,
32316,
856,
12,
358,
339,
347,
511,
63,
13817,
63,
7395,
63,
2030,
8,
277,
304,
267,
1242,
275,
1052,
267,
1242,
275,
13904,
8,
1053,
9,
267,
291,
14,
629,
8,
1053,
459,
6198,
995,
283,
1944,
2396,
1911,
370,
675,
367,
9006,
15103,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
codeofdusk/ProjectMagenta
|
src/url_shortener/__main__.py
|
3
|
1263
|
from functools import wraps
import shorteners
def service_selecter (func):
@wraps(func)
def wrapper (*args, **kwargs):
tmp = dict(kwargs)
if 'service' in tmp:
del(tmp['service'])
kwargs['service'] = find_service(kwargs['service'], **tmp) or default_service()
else:
kwargs['service'] = default_service()
return func(*args, **kwargs)
return wrapper
@service_selecter
def shorten (url, service=None, **kwargs):
return service(**kwargs).shorten(url)
@service_selecter
def unshorten (url, service=None, **kwargs):
return service(**kwargs).unshorten(url)
def default_service ():
return shorteners.TinyurlShortener
def find_service (service, **kwargs):
for i in shorteners.__all__:
obj = getattr(shorteners, i)(**kwargs)
if obj.name.lower() == service.lower():
return getattr(shorteners, i)
def list_services ():
return [getattr(shorteners, i)().name for i in shorteners.__all__]
def unshorten_any (url):
"""Unshortens an URL using any available unshortener. Check to see if unshortened URL was created by a shortener (nested) and unshorten if so."""
unshortened_url = shorteners.URLShortener().unshorten(url)
# None is returned if URL not unshortened
if unshortened_url:
return unshorten_any(unshortened_url)
return url
|
gpl-2.0
|
[
504,
9143,
492,
14018,
199,
646,
25123,
1192,
421,
199,
318,
2435,
63,
261,
10251,
351,
334,
1532,
304,
199,
768,
13582,
8,
1532,
9,
199,
347,
4975,
19943,
589,
12,
1011,
958,
304,
523,
3529,
275,
1211,
8,
958,
9,
523,
340,
283,
1364,
7,
315,
3529,
26,
2043,
2150,
8,
2791,
459,
1364,
1105,
2043,
2074,
459,
1364,
418,
275,
2342,
63,
1364,
8,
958,
459,
1364,
995,
1011,
2791,
9,
503,
849,
63,
1364,
342,
523,
587,
26,
2043,
2074,
459,
1364,
418,
275,
849,
63,
1364,
342,
523,
372,
2562,
2031,
589,
12,
1011,
958,
9,
199,
372,
4975,
199,
199,
32,
1364,
63,
261,
10251,
351,
199,
318,
25123,
334,
633,
12,
2435,
29,
403,
12,
1011,
958,
304,
199,
372,
2435,
3682,
958,
680,
30686,
8,
633,
9,
421,
199,
32,
1364,
63,
261,
10251,
351,
199,
318,
625,
30686,
334,
633,
12,
2435,
29,
403,
12,
1011,
958,
304,
199,
372,
2435,
3682,
958,
680,
324,
30686,
8,
633,
9,
421,
199,
318,
849,
63,
1364,
23390,
199,
372,
25123,
1192,
14,
52,
8952,
633,
2662,
269,
724,
281,
199,
199,
318,
2342,
63,
1364,
334,
1364,
12,
1011,
958,
304,
199,
367,
284,
315,
25123,
1192,
855,
452,
10651,
523,
1559,
275,
2519,
8,
30686,
1192,
12,
284,
9,
3682,
958,
9,
523,
340,
1559,
14,
354,
14,
2325,
342,
508,
2435,
14,
2325,
837,
2043,
372,
2519,
8,
30686,
1192,
12,
284,
9,
199,
199,
318,
769,
63,
5950,
23390,
199,
372,
359,
5675,
8,
30686,
1192,
12,
284,
9,
1252,
354,
367,
284,
315,
25123,
1192,
855,
452,
22705,
199,
199,
318,
625,
30686,
63,
1629,
334,
633,
304,
199,
408,
9251,
23991,
32461,
376,
2851,
1808,
1263,
2808,
625,
30686,
281,
14,
2670,
370,
1937,
340,
625,
30686,
379,
2851,
1990,
2737,
701,
282,
25123,
281,
334,
6376,
9,
436,
625,
30686,
340,
880,
1041,
199,
625,
30686,
379,
63,
633,
275,
25123,
1192,
14,
2632,
2662,
269,
724,
281,
1252,
324,
30686,
8,
633,
9,
199,
327,
488,
365,
2138,
340,
2851,
440,
625,
30686,
379,
199,
340,
625,
30686,
379,
63,
633,
26,
523,
372,
625,
30686,
63,
1629,
8,
324,
30686,
379,
63,
633,
9,
199,
372,
1166,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
9143,
492,
14018,
199,
646,
25123,
1192,
421,
199,
318,
2435,
63,
261,
10251,
351,
334,
1532,
304,
199,
768,
13582,
8,
1532,
9,
199,
347,
4975,
19943,
589,
12,
1011,
958,
304,
523,
3529,
275,
1211,
8,
958,
9,
523,
340,
283,
1364,
7,
315,
3529,
26,
2043,
2150,
8,
2791,
459,
1364,
1105,
2043,
2074,
459,
1364,
418,
275,
2342,
63,
1364,
8,
958,
459,
1364,
995,
1011,
2791,
9,
503,
849,
63,
1364,
342,
523,
587,
26,
2043,
2074,
459,
1364,
418,
275,
849,
63,
1364,
342,
523,
372,
2562,
2031,
589,
12,
1011,
958,
9,
199,
372,
4975,
199,
199,
32,
1364,
63,
261,
10251,
351,
199,
318,
25123,
334,
633,
12,
2435,
29,
403,
12,
1011,
958,
304,
199,
372,
2435,
3682,
958,
680,
30686,
8,
633,
9,
421,
199,
32,
1364,
63,
261,
10251,
351,
199,
318,
625,
30686,
334,
633,
12,
2435,
29,
403,
12,
1011,
958,
304,
199,
372,
2435,
3682,
958,
680,
324,
30686,
8,
633,
9,
421,
199,
318,
849,
63,
1364,
23390,
199,
372,
25123,
1192,
14,
52,
8952,
633,
2662,
269,
724,
281,
199,
199,
318,
2342,
63,
1364,
334,
1364,
12,
1011,
958,
304,
199,
367,
284,
315,
25123,
1192,
855,
452,
10651,
523,
1559,
275,
2519,
8,
30686,
1192,
12,
284,
9,
3682,
958,
9,
523,
340,
1559,
14,
354,
14,
2325,
342,
508,
2435,
14,
2325,
837,
2043,
372,
2519,
8,
30686,
1192,
12,
284,
9,
199,
199,
318,
769,
63,
5950,
23390,
199,
372,
359,
5675,
8,
30686,
1192,
12,
284,
9,
1252,
354,
367,
284,
315,
25123,
1192,
855,
452,
22705,
199,
199,
318,
625,
30686,
63,
1629,
334,
633,
304,
199,
408,
9251,
23991,
32461,
376,
2851,
1808,
1263,
2808,
625,
30686,
281,
14,
2670,
370,
1937,
340,
625,
30686,
379,
2851,
1990,
2737,
701,
282,
25123,
281,
334,
6376,
9,
436,
625,
30686,
340,
880,
1041,
199,
625,
30686,
379,
63,
633,
275,
25123,
1192,
14,
2632,
2662,
269,
724,
281,
1252,
324,
30686,
8,
633,
9,
199,
327,
488,
365,
2138,
340,
2851,
440,
625,
30686,
379,
199,
340,
625,
30686,
379,
63,
633,
26,
523,
372,
625,
30686,
63,
1629,
8,
324,
30686,
379,
63,
633,
9,
199,
372,
1166,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
michaelBenin/django-oscar
|
tests/functional/customer/order_status_tests.py
|
7
|
1230
|
import httplib
from django.core.urlresolvers import reverse
from oscar.test.factories import create_order
from oscar.test.testcases import WebTestCase
class TestAnAnonymousUser(WebTestCase):
def test_gets_a_404_when_requesting_an_unknown_order(self):
path = reverse('customer:anon-order', kwargs={'order_number': 1000,
'hash': '1231231232'})
response = self.app.get(path, status="*")
self.assertEqual(httplib.NOT_FOUND, response.status_code)
def test_can_see_order_status(self):
order = create_order()
path = reverse('customer:anon-order',
kwargs={'order_number': order.number,
'hash': order.verification_hash()})
response = self.app.get(path)
self.assertEqual(httplib.OK, response.status_code)
def test_gets_404_when_using_incorrect_hash(self):
order = create_order()
path = reverse('customer:anon-order',
kwargs={'order_number': order.number,
'hash': 'bad'})
response = self.app.get(path, status="*")
self.assertEqual(httplib.NOT_FOUND, response.status_code)
|
bsd-3-clause
|
[
646,
8809,
199,
199,
504,
1639,
14,
1018,
14,
16522,
492,
3837,
199,
199,
504,
312,
22707,
14,
396,
14,
15406,
492,
1218,
63,
1648,
199,
504,
312,
22707,
14,
396,
14,
396,
9403,
492,
6001,
1746,
421,
199,
533,
1379,
2493,
23902,
1899,
8,
5926,
1746,
304,
339,
347,
511,
63,
24894,
63,
65,
63,
5188,
63,
6526,
63,
1069,
316,
63,
290,
63,
5187,
63,
1648,
8,
277,
304,
267,
931,
275,
3837,
360,
10178,
26,
21009,
13,
1648,
297,
2074,
3713,
1648,
63,
1955,
356,
5198,
12,
10028,
283,
2227,
356,
283,
4288,
4288,
713,
708,
3071,
267,
1177,
275,
291,
14,
571,
14,
362,
8,
515,
12,
2004,
32103,
531,
267,
291,
14,
629,
8,
12942,
14,
4609,
63,
13945,
12,
1177,
14,
1205,
63,
600,
9,
339,
347,
511,
63,
2425,
63,
3239,
63,
1648,
63,
1205,
8,
277,
304,
267,
1865,
275,
1218,
63,
1648,
342,
267,
931,
275,
3837,
360,
10178,
26,
21009,
13,
1648,
297,
2432,
2074,
3713,
1648,
63,
1955,
356,
1865,
14,
1955,
12,
3044,
283,
2227,
356,
1865,
14,
16257,
63,
2227,
22804,
267,
1177,
275,
291,
14,
571,
14,
362,
8,
515,
9,
267,
291,
14,
629,
8,
12942,
14,
3593,
12,
1177,
14,
1205,
63,
600,
9,
339,
347,
511,
63,
24894,
63,
5188,
63,
6526,
63,
4941,
63,
15448,
63,
2227,
8,
277,
304,
267,
1865,
275,
1218,
63,
1648,
342,
267,
931,
275,
3837,
360,
10178,
26,
21009,
13,
1648,
297,
2432,
2074,
3713,
1648,
63,
1955,
356,
1865,
14,
1955,
12,
3044,
283,
2227,
356,
283,
4087,
3071,
267,
1177,
275,
291,
14,
571,
14,
362,
8,
515,
12,
2004,
32103,
531,
267,
291,
14,
629,
8,
12942,
14,
4609,
63,
13945,
12,
1177,
14,
1205,
63,
600,
9,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
8809,
199,
199,
504,
1639,
14,
1018,
14,
16522,
492,
3837,
199,
199,
504,
312,
22707,
14,
396,
14,
15406,
492,
1218,
63,
1648,
199,
504,
312,
22707,
14,
396,
14,
396,
9403,
492,
6001,
1746,
421,
199,
533,
1379,
2493,
23902,
1899,
8,
5926,
1746,
304,
339,
347,
511,
63,
24894,
63,
65,
63,
5188,
63,
6526,
63,
1069,
316,
63,
290,
63,
5187,
63,
1648,
8,
277,
304,
267,
931,
275,
3837,
360,
10178,
26,
21009,
13,
1648,
297,
2074,
3713,
1648,
63,
1955,
356,
5198,
12,
10028,
283,
2227,
356,
283,
4288,
4288,
713,
708,
3071,
267,
1177,
275,
291,
14,
571,
14,
362,
8,
515,
12,
2004,
32103,
531,
267,
291,
14,
629,
8,
12942,
14,
4609,
63,
13945,
12,
1177,
14,
1205,
63,
600,
9,
339,
347,
511,
63,
2425,
63,
3239,
63,
1648,
63,
1205,
8,
277,
304,
267,
1865,
275,
1218,
63,
1648,
342,
267,
931,
275,
3837,
360,
10178,
26,
21009,
13,
1648,
297,
2432,
2074,
3713,
1648,
63,
1955,
356,
1865,
14,
1955,
12,
3044,
283,
2227,
356,
1865,
14,
16257,
63,
2227,
22804,
267,
1177,
275,
291,
14,
571,
14,
362,
8,
515,
9,
267,
291,
14,
629,
8,
12942,
14,
3593,
12,
1177,
14,
1205,
63,
600,
9,
339,
347,
511,
63,
24894,
63,
5188,
63,
6526,
63,
4941,
63,
15448,
63,
2227,
8,
277,
304,
267,
1865,
275,
1218,
63,
1648,
342,
267,
931,
275,
3837,
360,
10178,
26,
21009,
13,
1648,
297,
2432,
2074,
3713,
1648,
63,
1955,
356,
1865,
14,
1955,
12,
3044,
283,
2227,
356,
283,
4087,
3071,
267,
1177,
275,
291,
14,
571,
14,
362,
8,
515,
12,
2004,
32103,
531,
267,
291,
14,
629,
8,
12942,
14,
4609,
63,
13945,
12,
1177,
14,
1205,
63,
600,
9,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
mchrzanowski/ProjectEuler
|
src/python/Problem031.py
|
1
|
1985
|
'''
Created on Jan 13, 2012
@author: mchrzanowski
'''
from time import time
import numpy as np
LIMIT = 300
COINS = (1, 2, 5, 10, 20, 50, 100, 200)
# O(LIMIT * |COINS|)
def dp():
M = np.zeros((LIMIT + 1, len(COINS) + 1), dtype=np.int)
# base cases.
for i in xrange(1, LIMIT + 1):
M[i, 1] = 1 # there's 1 way to produce n with only the first coin.
for c in xrange(1, len(COINS) + 1):
M[1, c] = 1 # there's 1 way to produce $1.
M[0, c] = 1 # number matches the coin.
for c in xrange(2, len(COINS) + 1):
for n in xrange(2, LIMIT + 1):
# adding a new coin still means we can produce n using
# coins 1,...c-1 the exact same way
M[n, c] = M[n, c - 1]
# can we produce it using this new coin?
if n - COINS[c - 1] >= 0:
M[n, c] += M[n - COINS[c - 1], c]
return M[LIMIT, len(COINS)]
# O(LIMIT ^ |COINS|)
def bruteForce():
i = 0
for a in xrange(0, LIMIT + 1, COINS[-1]):
for b in xrange(0, LIMIT + 1 - a, COINS[-2]):
for c in xrange(0, LIMIT + 1 - a - b, COINS[-3]):
for d in xrange(0, LIMIT + 1 - a - b - c, COINS[-4]):
for e in xrange(0, LIMIT + 1 - a - b - c - d, COINS[-5]):
for f in xrange(0, LIMIT + 1 - a - b - c - d - e, COINS[-6]):
for g in xrange(0, LIMIT + 1 - a - b - c - d - e - f, COINS[-7]):
for h in xrange(0, LIMIT + 1 - a - b - c - d - e - f - g, COINS[-8]):
if a + b + c + d + e + f + g + h is LIMIT:
i += 1
return i
def _run(func, name):
begin = time()
possibilities = func()
end = time()
print 'Answer: %s' % possibilities
print "%s Runtime: %s secs." % (name, end - begin)
def main():
_run(dp, "DP")
_run(bruteForce, "Bruce Force")
if __name__ == '__main__':
main()
|
mit
|
[
2344,
199,
10502,
641,
17474,
4944,
12,
6029,
199,
199,
32,
2502,
26,
333,
10194,
90,
290,
19844,
199,
2344,
199,
199,
504,
900,
492,
900,
199,
646,
2680,
465,
980,
199,
199,
13387,
275,
9601,
199,
1439,
10789,
275,
334,
17,
12,
499,
12,
959,
12,
1616,
12,
3388,
12,
5238,
12,
2948,
12,
1926,
9,
199,
199,
3,
593,
8,
13387,
627,
1204,
1439,
10789,
92,
9,
199,
318,
12392,
837,
272,
603,
275,
980,
14,
4250,
1332,
13387,
435,
413,
12,
822,
8,
1439,
10789,
9,
435,
413,
395,
2152,
29,
1590,
14,
442,
9,
339,
327,
1300,
5560,
14,
272,
367,
284,
315,
4945,
8,
17,
12,
5138,
435,
413,
304,
267,
603,
59,
73,
12,
413,
61,
275,
413,
221,
327,
2337,
1159,
413,
4340,
370,
7389,
302,
543,
1454,
314,
1642,
21914,
14,
339,
367,
286,
315,
4945,
8,
17,
12,
822,
8,
1439,
10789,
9,
435,
413,
304,
267,
603,
59,
17,
12,
286,
61,
275,
413,
221,
327,
2337,
1159,
413,
4340,
370,
7389,
2672,
17,
14,
267,
603,
59,
16,
12,
286,
61,
275,
413,
221,
327,
1329,
4450,
314,
21914,
14,
339,
367,
286,
315,
4945,
8,
18,
12,
822,
8,
1439,
10789,
9,
435,
413,
304,
267,
367,
302,
315,
4945,
8,
18,
12,
5138,
435,
413,
304,
288,
327,
7791,
282,
892,
21914,
5139,
4910,
781,
883,
7389,
302,
1808,
288,
327,
512,
3617,
413,
12,
1396,
67,
13,
17,
314,
5835,
2011,
4340,
288,
603,
59,
78,
12,
286,
61,
275,
603,
59,
78,
12,
286,
446,
413,
61,
288,
327,
883,
781,
7389,
652,
1808,
642,
892,
21914,
31,
288,
340,
302,
446,
5099,
10789,
59,
67,
446,
413,
61,
2356,
378,
26,
355,
603,
59,
78,
12,
286,
61,
847,
603,
59,
78,
446,
5099,
10789,
59,
67,
446,
413,
467,
286,
61,
339,
372,
603,
59,
13387,
12,
822,
8,
1439,
10789,
1874,
199,
199,
3,
593,
8,
13387,
7167,
1204,
1439,
10789,
92,
9,
199,
318,
11665,
938,
13606,
837,
272,
284,
275,
378,
272,
367,
282,
315,
4945,
8,
16,
12,
5138,
435,
413,
12,
5099,
10789,
1988,
17,
4682,
267,
367,
330,
315,
4945,
8,
16,
12,
5138,
435,
413,
446,
282,
12,
5099,
10789,
1988,
18,
4682,
288,
367,
286,
315,
4945,
8,
16,
12,
5138,
435,
413,
446,
282,
446,
330,
12,
5099,
10789,
1988,
19,
4682,
355,
367,
366,
315,
4945,
8,
16,
12,
5138,
435,
413,
446,
282,
446,
330,
446,
286,
12,
5099,
10789,
1988,
20,
4682,
490,
367,
325,
315,
4945,
8,
16,
12,
5138,
435,
413,
446,
282,
446,
330,
446,
286,
446,
366,
12,
5099,
10789,
1988,
21,
4682,
717,
367,
289,
315,
4945,
8,
16,
12,
5138,
435,
413,
446,
282,
446,
330,
446,
286,
446,
366,
446,
325,
12,
5099,
10789,
1988,
22,
4682,
1169,
367,
486,
315,
4945,
8,
16,
12,
5138,
435,
413,
446,
282,
446,
330,
446,
286,
446,
366,
446,
325,
446,
289,
12,
5099,
10789,
1988,
23,
4682,
1816,
367,
394,
315,
4945,
8,
16,
12,
5138,
435,
413,
446,
282,
446,
330,
446,
286,
446,
366,
446,
325,
446,
289,
446,
486,
12,
5099,
10789,
1988,
24,
4682,
2511,
340,
282,
435,
330,
435,
286,
435,
366,
435,
325,
435,
289,
435,
486,
435,
394,
365,
5138,
26,
3147,
284,
847,
413,
339,
372,
284,
199,
199,
318,
485,
1065,
8,
1532,
12,
536,
304,
272,
5386,
275,
900,
342,
272,
2086,
23422,
275,
2562,
342,
272,
1284,
275,
900,
342,
272,
870,
283,
19104,
26,
450,
83,
7,
450,
2086,
23422,
272,
870,
2071,
83,
19103,
26,
450,
83,
20091,
2122,
450,
334,
354,
12,
1284,
446,
5386,
9,
199,
199,
318,
2446,
837,
272,
485,
1065,
8,
5780,
12,
298,
11741,
531,
272,
485,
1065,
8,
3289,
938,
13606,
12,
298,
12771,
3683,
18771,
531,
199,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
272,
2446,
342,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
199,
10502,
641,
17474,
4944,
12,
6029,
199,
199,
32,
2502,
26,
333,
10194,
90,
290,
19844,
199,
2344,
199,
199,
504,
900,
492,
900,
199,
646,
2680,
465,
980,
199,
199,
13387,
275,
9601,
199,
1439,
10789,
275,
334,
17,
12,
499,
12,
959,
12,
1616,
12,
3388,
12,
5238,
12,
2948,
12,
1926,
9,
199,
199,
3,
593,
8,
13387,
627,
1204,
1439,
10789,
92,
9,
199,
318,
12392,
837,
272,
603,
275,
980,
14,
4250,
1332,
13387,
435,
413,
12,
822,
8,
1439,
10789,
9,
435,
413,
395,
2152,
29,
1590,
14,
442,
9,
339,
327,
1300,
5560,
14,
272,
367,
284,
315,
4945,
8,
17,
12,
5138,
435,
413,
304,
267,
603,
59,
73,
12,
413,
61,
275,
413,
221,
327,
2337,
1159,
413,
4340,
370,
7389,
302,
543,
1454,
314,
1642,
21914,
14,
339,
367,
286,
315,
4945,
8,
17,
12,
822,
8,
1439,
10789,
9,
435,
413,
304,
267,
603,
59,
17,
12,
286,
61,
275,
413,
221,
327,
2337,
1159,
413,
4340,
370,
7389,
2672,
17,
14,
267,
603,
59,
16,
12,
286,
61,
275,
413,
221,
327,
1329,
4450,
314,
21914,
14,
339,
367,
286,
315,
4945,
8,
18,
12,
822,
8,
1439,
10789,
9,
435,
413,
304,
267,
367,
302,
315,
4945,
8,
18,
12,
5138,
435,
413,
304,
288,
327,
7791,
282,
892,
21914,
5139,
4910,
781,
883,
7389,
302,
1808,
288,
327,
512,
3617,
413,
12,
1396,
67,
13,
17,
314,
5835,
2011,
4340,
288,
603,
59,
78,
12,
286,
61,
275,
603,
59,
78,
12,
286,
446,
413,
61,
288,
327,
883,
781,
7389,
652,
1808,
642,
892,
21914,
31,
288,
340,
302,
446,
5099,
10789,
59,
67,
446,
413,
61,
2356,
378,
26,
355,
603,
59,
78,
12,
286,
61,
847,
603,
59,
78,
446,
5099,
10789,
59,
67,
446,
413,
467,
286,
61,
339,
372,
603,
59,
13387,
12,
822,
8,
1439,
10789,
1874,
199,
199,
3,
593,
8,
13387,
7167,
1204,
1439,
10789,
92,
9,
199,
318,
11665,
938,
13606,
837,
272,
284,
275,
378,
272,
367,
282,
315,
4945,
8,
16,
12,
5138,
435,
413,
12,
5099,
10789,
1988,
17,
4682,
267,
367,
330,
315,
4945,
8,
16,
12,
5138,
435,
413,
446,
282,
12,
5099,
10789,
1988,
18,
4682,
288,
367,
286,
315,
4945,
8,
16,
12,
5138,
435,
413,
446,
282,
446,
330,
12,
5099,
10789,
1988,
19,
4682,
355,
367,
366,
315,
4945,
8,
16,
12,
5138,
435,
413,
446,
282,
446,
330,
446,
286,
12,
5099,
10789,
1988,
20,
4682,
490,
367,
325,
315,
4945,
8,
16,
12,
5138,
435,
413,
446,
282,
446,
330,
446,
286,
446,
366,
12,
5099,
10789,
1988,
21,
4682,
717,
367,
289,
315,
4945,
8,
16,
12,
5138,
435,
413,
446,
282,
446,
330,
446,
286,
446,
366,
446,
325,
12,
5099,
10789,
1988,
22,
4682,
1169,
367,
486,
315,
4945,
8,
16,
12,
5138,
435,
413,
446,
282,
446,
330,
446,
286,
446,
366,
446,
325,
446,
289,
12,
5099,
10789,
1988,
23,
4682,
1816,
367,
394,
315,
4945,
8,
16,
12,
5138,
435,
413,
446,
282,
446,
330,
446,
286,
446,
366,
446,
325,
446,
289,
446,
486,
12,
5099,
10789,
1988,
24,
4682,
2511,
340,
282,
435,
330,
435,
286,
435,
366,
435,
325,
435,
289,
435,
486,
435,
394,
365,
5138,
26,
3147,
284,
847,
413,
339,
372,
284,
199,
199,
318,
485,
1065,
8,
1532,
12,
536,
304,
272,
5386,
275,
900,
342,
272,
2086,
23422,
275,
2562,
342,
272,
1284,
275,
900,
342,
272,
870,
283,
19104,
26,
450,
83,
7,
450,
2086,
23422,
272,
870,
2071,
83,
19103,
26,
450,
83,
20091,
2122,
450,
334,
354,
12,
1284,
446,
5386,
9,
199,
199,
318,
2446,
837,
272,
485,
1065,
8,
5780,
12,
298,
11741,
531,
272,
485,
1065,
8,
3289,
938,
13606,
12,
298,
12771,
3683,
18771,
531,
199,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
272,
2446,
342,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
shepdelacreme/ansible
|
lib/ansible/modules/cloud/rackspace/rax_scaling_group.py
|
65
|
14430
|
#!/usr/bin/python
# Copyright: Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import absolute_import, division, print_function
__metaclass__ = type
ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ['preview'],
'supported_by': 'community'}
DOCUMENTATION = '''
---
module: rax_scaling_group
short_description: Manipulate Rackspace Cloud Autoscale Groups
description:
- Manipulate Rackspace Cloud Autoscale Groups
version_added: 1.7
options:
config_drive:
description:
- Attach read-only configuration drive to server as label config-2
type: bool
default: 'no'
version_added: 1.8
cooldown:
description:
- The period of time, in seconds, that must pass before any scaling can
occur after the previous scaling. Must be an integer between 0 and
86400 (24 hrs).
disk_config:
description:
- Disk partitioning strategy
choices:
- auto
- manual
default: auto
files:
description:
- 'Files to insert into the instance. Hash of C(remotepath: localpath)'
flavor:
description:
- flavor to use for the instance
required: true
image:
description:
- image to use for the instance. Can be an C(id), C(human_id) or C(name)
required: true
key_name:
description:
- key pair to use on the instance
loadbalancers:
description:
- List of load balancer C(id) and C(port) hashes
max_entities:
description:
- The maximum number of entities that are allowed in the scaling group.
Must be an integer between 0 and 1000.
required: true
meta:
description:
- A hash of metadata to associate with the instance
min_entities:
description:
- The minimum number of entities that are allowed in the scaling group.
Must be an integer between 0 and 1000.
required: true
name:
description:
- Name to give the scaling group
required: true
networks:
description:
- The network to attach to the instances. If specified, you must include
ALL networks including the public and private interfaces. Can be C(id)
or C(label).
default:
- public
- private
server_name:
description:
- The base name for servers created by Autoscale
required: true
state:
description:
- Indicate desired state of the resource
choices:
- present
- absent
default: present
user_data:
description:
- Data to be uploaded to the servers config drive. This option implies
I(config_drive). Can be a file path or a string
version_added: 1.8
wait:
description:
- wait for the scaling group to finish provisioning the minimum amount of
servers
type: bool
default: 'no'
wait_timeout:
description:
- how long before wait gives up, in seconds
default: 300
author: "Matt Martz (@sivel)"
extends_documentation_fragment:
- rackspace
- rackspace.openstack
'''
EXAMPLES = '''
---
- hosts: localhost
gather_facts: false
connection: local
tasks:
- rax_scaling_group:
credentials: ~/.raxpub
region: ORD
cooldown: 300
flavor: performance1-1
image: bb02b1a3-bc77-4d17-ab5b-421d89850fca
min_entities: 5
max_entities: 10
name: ASG Test
server_name: asgtest
loadbalancers:
- id: 228385
port: 80
register: asg
'''
import base64
import json
import os
import time
try:
import pyrax
HAS_PYRAX = True
except ImportError:
HAS_PYRAX = False
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.rax import (rax_argument_spec, rax_find_image, rax_find_network,
rax_required_together, rax_to_dict, setup_rax_module)
from ansible.module_utils.six import string_types
def rax_asg(module, cooldown=300, disk_config=None, files=None, flavor=None,
image=None, key_name=None, loadbalancers=None, meta=None,
min_entities=0, max_entities=0, name=None, networks=None,
server_name=None, state='present', user_data=None,
config_drive=False, wait=True, wait_timeout=300):
files = {} if files is None else files
loadbalancers = [] if loadbalancers is None else loadbalancers
meta = {} if meta is None else meta
networks = [] if networks is None else networks
changed = False
au = pyrax.autoscale
if not au:
module.fail_json(msg='Failed to instantiate clients. This '
'typically indicates an invalid region or an '
'incorrectly capitalized region name.')
if user_data:
config_drive = True
if user_data and os.path.isfile(user_data):
try:
f = open(user_data)
user_data = f.read()
f.close()
except Exception as e:
module.fail_json(msg='Failed to load %s' % user_data)
if state == 'present':
# Normalize and ensure all metadata values are strings
if meta:
for k, v in meta.items():
if isinstance(v, list):
meta[k] = ','.join(['%s' % i for i in v])
elif isinstance(v, dict):
meta[k] = json.dumps(v)
elif not isinstance(v, string_types):
meta[k] = '%s' % v
if image:
image = rax_find_image(module, pyrax, image)
nics = []
if networks:
for network in networks:
nics.extend(rax_find_network(module, pyrax, network))
for nic in nics:
# pyrax is currently returning net-id, but we need uuid
# this check makes this forward compatible for a time when
# pyrax uses uuid instead
if nic.get('net-id'):
nic.update(uuid=nic['net-id'])
del nic['net-id']
# Handle the file contents
personality = []
if files:
for rpath in files.keys():
lpath = os.path.expanduser(files[rpath])
try:
f = open(lpath, 'r')
personality.append({
'path': rpath,
'contents': f.read()
})
f.close()
except Exception as e:
module.fail_json(msg='Failed to load %s' % lpath)
lbs = []
if loadbalancers:
for lb in loadbalancers:
try:
lb_id = int(lb.get('id'))
except (ValueError, TypeError):
module.fail_json(msg='Load balancer ID is not an integer: '
'%s' % lb.get('id'))
try:
port = int(lb.get('port'))
except (ValueError, TypeError):
module.fail_json(msg='Load balancer port is not an '
'integer: %s' % lb.get('port'))
if not lb_id or not port:
continue
lbs.append((lb_id, port))
try:
sg = au.find(name=name)
except pyrax.exceptions.NoUniqueMatch as e:
module.fail_json(msg='%s' % e.message)
except pyrax.exceptions.NotFound:
try:
sg = au.create(name, cooldown=cooldown,
min_entities=min_entities,
max_entities=max_entities,
launch_config_type='launch_server',
server_name=server_name, image=image,
flavor=flavor, disk_config=disk_config,
metadata=meta, personality=personality,
networks=nics, load_balancers=lbs,
key_name=key_name, config_drive=config_drive,
user_data=user_data)
changed = True
except Exception as e:
module.fail_json(msg='%s' % e.message)
if not changed:
# Scaling Group Updates
group_args = {}
if cooldown != sg.cooldown:
group_args['cooldown'] = cooldown
if min_entities != sg.min_entities:
group_args['min_entities'] = min_entities
if max_entities != sg.max_entities:
group_args['max_entities'] = max_entities
if group_args:
changed = True
sg.update(**group_args)
# Launch Configuration Updates
lc = sg.get_launch_config()
lc_args = {}
if server_name != lc.get('name'):
lc_args['server_name'] = server_name
if image != lc.get('image'):
lc_args['image'] = image
if flavor != lc.get('flavor'):
lc_args['flavor'] = flavor
disk_config = disk_config or 'AUTO'
if ((disk_config or lc.get('disk_config')) and
disk_config != lc.get('disk_config', 'AUTO')):
lc_args['disk_config'] = disk_config
if (meta or lc.get('meta')) and meta != lc.get('metadata'):
lc_args['metadata'] = meta
test_personality = []
for p in personality:
test_personality.append({
'path': p['path'],
'contents': base64.b64encode(p['contents'])
})
if ((test_personality or lc.get('personality')) and
test_personality != lc.get('personality')):
lc_args['personality'] = personality
if nics != lc.get('networks'):
lc_args['networks'] = nics
if lbs != lc.get('load_balancers'):
# Work around for https://github.com/rackspace/pyrax/pull/393
lc_args['load_balancers'] = sg.manager._resolve_lbs(lbs)
if key_name != lc.get('key_name'):
lc_args['key_name'] = key_name
if config_drive != lc.get('config_drive', False):
lc_args['config_drive'] = config_drive
if (user_data and
base64.b64encode(user_data) != lc.get('user_data')):
lc_args['user_data'] = user_data
if lc_args:
# Work around for https://github.com/rackspace/pyrax/pull/389
if 'flavor' not in lc_args:
lc_args['flavor'] = lc.get('flavor')
changed = True
sg.update_launch_config(**lc_args)
sg.get()
if wait:
end_time = time.time() + wait_timeout
infinite = wait_timeout == 0
while infinite or time.time() < end_time:
state = sg.get_state()
if state["pending_capacity"] == 0:
break
time.sleep(5)
module.exit_json(changed=changed, autoscale_group=rax_to_dict(sg))
else:
try:
sg = au.find(name=name)
sg.delete()
changed = True
except pyrax.exceptions.NotFound as e:
sg = {}
except Exception as e:
module.fail_json(msg='%s' % e.message)
module.exit_json(changed=changed, autoscale_group=rax_to_dict(sg))
def main():
argument_spec = rax_argument_spec()
argument_spec.update(
dict(
config_drive=dict(default=False, type='bool'),
cooldown=dict(type='int', default=300),
disk_config=dict(choices=['auto', 'manual']),
files=dict(type='dict', default={}),
flavor=dict(required=True),
image=dict(required=True),
key_name=dict(),
loadbalancers=dict(type='list'),
meta=dict(type='dict', default={}),
min_entities=dict(type='int', required=True),
max_entities=dict(type='int', required=True),
name=dict(required=True),
networks=dict(type='list', default=['public', 'private']),
server_name=dict(required=True),
state=dict(default='present', choices=['present', 'absent']),
user_data=dict(no_log=True),
wait=dict(default=False, type='bool'),
wait_timeout=dict(default=300),
)
)
module = AnsibleModule(
argument_spec=argument_spec,
required_together=rax_required_together(),
)
if not HAS_PYRAX:
module.fail_json(msg='pyrax is required for this module')
config_drive = module.params.get('config_drive')
cooldown = module.params.get('cooldown')
disk_config = module.params.get('disk_config')
if disk_config:
disk_config = disk_config.upper()
files = module.params.get('files')
flavor = module.params.get('flavor')
image = module.params.get('image')
key_name = module.params.get('key_name')
loadbalancers = module.params.get('loadbalancers')
meta = module.params.get('meta')
min_entities = module.params.get('min_entities')
max_entities = module.params.get('max_entities')
name = module.params.get('name')
networks = module.params.get('networks')
server_name = module.params.get('server_name')
state = module.params.get('state')
user_data = module.params.get('user_data')
if not 0 <= min_entities <= 1000 or not 0 <= max_entities <= 1000:
module.fail_json(msg='min_entities and max_entities must be an '
'integer between 0 and 1000')
if not 0 <= cooldown <= 86400:
module.fail_json(msg='cooldown must be an integer between 0 and 86400')
setup_rax_module(module, pyrax)
rax_asg(module, cooldown=cooldown, disk_config=disk_config,
files=files, flavor=flavor, image=image, meta=meta,
key_name=key_name, loadbalancers=loadbalancers,
min_entities=min_entities, max_entities=max_entities,
name=name, networks=networks, server_name=server_name,
state=state, config_drive=config_drive, user_data=user_data)
if __name__ == '__main__':
main()
|
gpl-3.0
|
[
3381,
2647,
15,
1393,
15,
1548,
199,
3,
1898,
26,
2622,
7290,
199,
3,
1664,
1696,
1684,
844,
373,
19,
14,
16,
11,
334,
3239,
9685,
503,
4178,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
15,
11692,
13,
19,
14,
16,
14,
2424,
9,
199,
199,
504,
636,
2443,
363,
492,
3679,
63,
646,
12,
4629,
12,
870,
63,
1593,
199,
363,
6577,
363,
275,
730,
421,
199,
8490,
63,
8314,
275,
791,
2343,
63,
1023,
356,
283,
17,
14,
17,
297,
490,
283,
1205,
356,
788,
7780,
995,
490,
283,
4946,
63,
991,
356,
283,
9387,
936,
421,
199,
8948,
275,
1449,
199,
2595,
199,
578,
26,
16937,
63,
12153,
63,
923,
199,
3612,
63,
1802,
26,
4688,
711,
5434,
32679,
8142,
9195,
3467,
25031,
199,
1802,
26,
272,
446,
4688,
711,
5434,
32679,
8142,
9195,
3467,
25031,
199,
1023,
63,
3270,
26,
413,
14,
23,
199,
1419,
26,
523,
1101,
63,
9541,
26,
272,
1369,
26,
489,
446,
21328,
1586,
13,
2118,
2897,
12912,
370,
1654,
465,
1768,
1101,
13,
18,
272,
730,
26,
2155,
272,
849,
26,
283,
889,
7,
272,
1015,
63,
3270,
26,
413,
14,
24,
523,
512,
27898,
26,
272,
1369,
26,
489,
446,
710,
6247,
402,
900,
12,
315,
4696,
12,
626,
1471,
986,
2544,
1263,
13690,
883,
267,
4781,
2410,
314,
4136,
13690,
14,
9498,
506,
376,
3000,
3382,
378,
436,
267,
31200,
334,
1194,
394,
2393,
680,
523,
4543,
63,
888,
26,
272,
1369,
26,
489,
446,
26287,
6484,
316,
10054,
272,
3415,
26,
489,
446,
2599,
489,
446,
8722,
272,
849,
26,
2599,
523,
1584,
26,
272,
1369,
26,
489,
446,
283,
5535,
370,
5518,
1901,
314,
1256,
14,
16101,
402,
445,
8,
3846,
515,
26,
2257,
515,
3171,
523,
8541,
26,
272,
1369,
26,
489,
446,
8541,
370,
675,
367,
314,
1256,
272,
1415,
26,
2549,
523,
1834,
26,
272,
1369,
26,
489,
446,
1834,
370,
675,
367,
314,
1256,
14,
6855,
506,
376,
445,
8,
344,
395,
445,
8,
14864,
63,
344,
9,
503,
445,
8,
354,
9,
272,
1415,
26,
2549,
523,
790,
63,
354,
26,
272,
1369,
26,
489,
446,
790,
4092,
370,
675,
641,
314,
1256,
523,
2248,
29674,
26,
272,
1369,
26,
489,
446,
3820,
402,
2248,
17005,
445,
8,
344,
9,
436,
445,
8,
719,
9,
14647,
523,
1390,
63,
8327,
26,
272,
1369,
26,
489,
446,
710,
5696,
1329,
402,
9045,
626,
787,
4370,
315,
314,
13690,
1572,
14,
267,
9498,
506,
376,
3000,
3382,
378,
436,
5198,
14,
272,
1415,
26,
2549,
523,
3404,
26,
272,
1369,
26,
489,
446,
437,
2631,
402,
3341,
370,
20133,
543,
314,
1256,
523,
1748,
63,
8327,
26,
272,
1369,
26,
489,
446,
710,
7481,
1329,
402,
9045,
626,
787,
4370,
315,
314,
13690,
1572,
14,
267,
9498,
506,
376,
3000,
3382,
378,
436,
5198,
14,
272,
1415,
26,
2549,
523,
536,
26,
272,
1369,
26,
489,
446,
2812,
370,
8120,
314,
13690,
1572,
272,
1415,
26,
2549,
523,
11759,
26,
272,
1369,
26,
489,
446,
710,
2784,
370,
6554,
370,
314,
4454,
14,
982,
2013,
12,
1265,
1471,
2387,
267,
11727,
11759,
5893,
314,
4575,
436,
5726,
8386,
14,
6855,
506,
445,
8,
344,
9,
267,
503,
445,
8,
1302,
680,
272,
849,
26,
489,
446,
4575,
489,
446,
5726,
523,
1654,
63,
354,
26,
272,
1369,
26,
489,
446,
710,
1300,
536,
367,
8037,
2737,
701,
9195,
3467,
272,
1415,
26,
2549,
523,
1174,
26,
272,
1369,
26,
489,
446,
1010,
10188,
6387,
1174,
402,
314,
2073,
272,
3415,
26,
489,
446,
3451,
489,
446,
9552,
272,
849,
26,
3451,
523,
922,
63,
576,
26,
272,
1369,
26,
489,
446,
3918,
370,
506,
14238,
370,
314,
8037,
1101,
12912,
14,
961,
945,
22660,
267,
473,
8,
888,
63,
9541,
680,
6855,
506,
282,
570,
931,
503,
282,
1059,
272,
1015,
63,
3270,
26,
413,
14,
24,
523,
3618,
26,
272,
1369,
26,
489,
446,
3618,
367,
314,
13690,
1572,
370,
9578,
20118,
314,
7481,
5982,
402,
267,
8037,
272,
730,
26,
2155,
272,
849,
26,
283,
889,
7,
523,
3618,
63,
2593,
26,
272,
1369,
26,
489,
446,
4212,
1846,
2544,
3618,
10557,
1536,
12,
315,
4696,
272,
849,
26,
9601,
199,
2502,
26,
298,
45,
6796,
603,
28124,
8593,
338,
1090,
2924,
199,
11036,
63,
9970,
63,
7677,
26,
523,
446,
660,
346,
2638,
523,
446,
660,
346,
2638,
14,
8512,
199,
2344,
199,
199,
8918,
275,
1449,
199,
2595,
199,
13,
7057,
26,
11667,
523,
13082,
63,
5047,
26,
3055,
523,
1950,
26,
2257,
523,
6527,
26,
272,
446,
16937,
63,
12153,
63,
923,
26,
267,
6235,
26,
25975,
14495,
5645,
267,
4897,
26,
30502,
267,
512,
27898,
26,
9601,
267,
8541,
26,
10238,
17,
13,
17,
267,
1834,
26,
14027,
996,
66,
17,
65,
19,
13,
3776,
1138,
13,
20,
68,
1196,
13,
371,
21,
66,
13,
20,
2025,
68,
13176,
1400,
70,
696,
267,
1748,
63,
8327,
26,
959,
267,
1390,
63,
8327,
26,
1616,
267,
536,
26,
437,
4254,
1379,
267,
1654,
63,
354,
26,
465,
8385,
267,
2248,
29674,
26,
288,
446,
1305,
26,
499,
1651,
13846,
1598,
1844,
26,
5939,
489,
2274,
26,
465,
71,
199,
2344,
199,
199,
646,
1300,
772,
199,
646,
2022,
199,
646,
747,
199,
646,
900,
199,
199,
893,
26,
272,
492,
23944,
272,
7509,
63,
4521,
2847,
56,
275,
715,
199,
2590,
3545,
26,
272,
7509,
63,
4521,
2847,
56,
275,
756,
199,
199,
504,
3242,
14,
578,
63,
1208,
14,
4316,
492,
6953,
199,
504,
3242,
14,
578,
63,
1208,
14,
14495,
492,
334,
14495,
63,
2094,
63,
1650,
12,
16937,
63,
1623,
63,
1569,
12,
16937,
63,
1623,
63,
1200,
12,
4228,
16937,
63,
2427,
63,
6314,
12,
16937,
63,
475,
63,
807,
12,
3272,
63,
14495,
63,
578,
9,
199,
504,
3242,
14,
578,
63,
1208,
14,
4174,
492,
1059,
63,
1313,
421,
199,
318,
16937,
63,
305,
71,
8,
578,
12,
512,
27898,
29,
5863,
12,
4543,
63,
888,
29,
403,
12,
1584,
29,
403,
12,
8541,
29,
403,
12,
288,
1834,
29,
403,
12,
790,
63,
354,
29,
403,
12,
2248,
29674,
29,
403,
12,
3404,
29,
403
] |
[
2647,
15,
1393,
15,
1548,
199,
3,
1898,
26,
2622,
7290,
199,
3,
1664,
1696,
1684,
844,
373,
19,
14,
16,
11,
334,
3239,
9685,
503,
4178,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
15,
11692,
13,
19,
14,
16,
14,
2424,
9,
199,
199,
504,
636,
2443,
363,
492,
3679,
63,
646,
12,
4629,
12,
870,
63,
1593,
199,
363,
6577,
363,
275,
730,
421,
199,
8490,
63,
8314,
275,
791,
2343,
63,
1023,
356,
283,
17,
14,
17,
297,
490,
283,
1205,
356,
788,
7780,
995,
490,
283,
4946,
63,
991,
356,
283,
9387,
936,
421,
199,
8948,
275,
1449,
199,
2595,
199,
578,
26,
16937,
63,
12153,
63,
923,
199,
3612,
63,
1802,
26,
4688,
711,
5434,
32679,
8142,
9195,
3467,
25031,
199,
1802,
26,
272,
446,
4688,
711,
5434,
32679,
8142,
9195,
3467,
25031,
199,
1023,
63,
3270,
26,
413,
14,
23,
199,
1419,
26,
523,
1101,
63,
9541,
26,
272,
1369,
26,
489,
446,
21328,
1586,
13,
2118,
2897,
12912,
370,
1654,
465,
1768,
1101,
13,
18,
272,
730,
26,
2155,
272,
849,
26,
283,
889,
7,
272,
1015,
63,
3270,
26,
413,
14,
24,
523,
512,
27898,
26,
272,
1369,
26,
489,
446,
710,
6247,
402,
900,
12,
315,
4696,
12,
626,
1471,
986,
2544,
1263,
13690,
883,
267,
4781,
2410,
314,
4136,
13690,
14,
9498,
506,
376,
3000,
3382,
378,
436,
267,
31200,
334,
1194,
394,
2393,
680,
523,
4543,
63,
888,
26,
272,
1369,
26,
489,
446,
26287,
6484,
316,
10054,
272,
3415,
26,
489,
446,
2599,
489,
446,
8722,
272,
849,
26,
2599,
523,
1584,
26,
272,
1369,
26,
489,
446,
283,
5535,
370,
5518,
1901,
314,
1256,
14,
16101,
402,
445,
8,
3846,
515,
26,
2257,
515,
3171,
523,
8541,
26,
272,
1369,
26,
489,
446,
8541,
370,
675,
367,
314,
1256,
272,
1415,
26,
2549,
523,
1834,
26,
272,
1369,
26,
489,
446,
1834,
370,
675,
367,
314,
1256,
14,
6855,
506,
376,
445,
8,
344,
395,
445,
8,
14864,
63,
344,
9,
503,
445,
8,
354,
9,
272,
1415,
26,
2549,
523,
790,
63,
354,
26,
272,
1369,
26,
489,
446,
790,
4092,
370,
675,
641,
314,
1256,
523,
2248,
29674,
26,
272,
1369,
26,
489,
446,
3820,
402,
2248,
17005,
445,
8,
344,
9,
436,
445,
8,
719,
9,
14647,
523,
1390,
63,
8327,
26,
272,
1369,
26,
489,
446,
710,
5696,
1329,
402,
9045,
626,
787,
4370,
315,
314,
13690,
1572,
14,
267,
9498,
506,
376,
3000,
3382,
378,
436,
5198,
14,
272,
1415,
26,
2549,
523,
3404,
26,
272,
1369,
26,
489,
446,
437,
2631,
402,
3341,
370,
20133,
543,
314,
1256,
523,
1748,
63,
8327,
26,
272,
1369,
26,
489,
446,
710,
7481,
1329,
402,
9045,
626,
787,
4370,
315,
314,
13690,
1572,
14,
267,
9498,
506,
376,
3000,
3382,
378,
436,
5198,
14,
272,
1415,
26,
2549,
523,
536,
26,
272,
1369,
26,
489,
446,
2812,
370,
8120,
314,
13690,
1572,
272,
1415,
26,
2549,
523,
11759,
26,
272,
1369,
26,
489,
446,
710,
2784,
370,
6554,
370,
314,
4454,
14,
982,
2013,
12,
1265,
1471,
2387,
267,
11727,
11759,
5893,
314,
4575,
436,
5726,
8386,
14,
6855,
506,
445,
8,
344,
9,
267,
503,
445,
8,
1302,
680,
272,
849,
26,
489,
446,
4575,
489,
446,
5726,
523,
1654,
63,
354,
26,
272,
1369,
26,
489,
446,
710,
1300,
536,
367,
8037,
2737,
701,
9195,
3467,
272,
1415,
26,
2549,
523,
1174,
26,
272,
1369,
26,
489,
446,
1010,
10188,
6387,
1174,
402,
314,
2073,
272,
3415,
26,
489,
446,
3451,
489,
446,
9552,
272,
849,
26,
3451,
523,
922,
63,
576,
26,
272,
1369,
26,
489,
446,
3918,
370,
506,
14238,
370,
314,
8037,
1101,
12912,
14,
961,
945,
22660,
267,
473,
8,
888,
63,
9541,
680,
6855,
506,
282,
570,
931,
503,
282,
1059,
272,
1015,
63,
3270,
26,
413,
14,
24,
523,
3618,
26,
272,
1369,
26,
489,
446,
3618,
367,
314,
13690,
1572,
370,
9578,
20118,
314,
7481,
5982,
402,
267,
8037,
272,
730,
26,
2155,
272,
849,
26,
283,
889,
7,
523,
3618,
63,
2593,
26,
272,
1369,
26,
489,
446,
4212,
1846,
2544,
3618,
10557,
1536,
12,
315,
4696,
272,
849,
26,
9601,
199,
2502,
26,
298,
45,
6796,
603,
28124,
8593,
338,
1090,
2924,
199,
11036,
63,
9970,
63,
7677,
26,
523,
446,
660,
346,
2638,
523,
446,
660,
346,
2638,
14,
8512,
199,
2344,
199,
199,
8918,
275,
1449,
199,
2595,
199,
13,
7057,
26,
11667,
523,
13082,
63,
5047,
26,
3055,
523,
1950,
26,
2257,
523,
6527,
26,
272,
446,
16937,
63,
12153,
63,
923,
26,
267,
6235,
26,
25975,
14495,
5645,
267,
4897,
26,
30502,
267,
512,
27898,
26,
9601,
267,
8541,
26,
10238,
17,
13,
17,
267,
1834,
26,
14027,
996,
66,
17,
65,
19,
13,
3776,
1138,
13,
20,
68,
1196,
13,
371,
21,
66,
13,
20,
2025,
68,
13176,
1400,
70,
696,
267,
1748,
63,
8327,
26,
959,
267,
1390,
63,
8327,
26,
1616,
267,
536,
26,
437,
4254,
1379,
267,
1654,
63,
354,
26,
465,
8385,
267,
2248,
29674,
26,
288,
446,
1305,
26,
499,
1651,
13846,
1598,
1844,
26,
5939,
489,
2274,
26,
465,
71,
199,
2344,
199,
199,
646,
1300,
772,
199,
646,
2022,
199,
646,
747,
199,
646,
900,
199,
199,
893,
26,
272,
492,
23944,
272,
7509,
63,
4521,
2847,
56,
275,
715,
199,
2590,
3545,
26,
272,
7509,
63,
4521,
2847,
56,
275,
756,
199,
199,
504,
3242,
14,
578,
63,
1208,
14,
4316,
492,
6953,
199,
504,
3242,
14,
578,
63,
1208,
14,
14495,
492,
334,
14495,
63,
2094,
63,
1650,
12,
16937,
63,
1623,
63,
1569,
12,
16937,
63,
1623,
63,
1200,
12,
4228,
16937,
63,
2427,
63,
6314,
12,
16937,
63,
475,
63,
807,
12,
3272,
63,
14495,
63,
578,
9,
199,
504,
3242,
14,
578,
63,
1208,
14,
4174,
492,
1059,
63,
1313,
421,
199,
318,
16937,
63,
305,
71,
8,
578,
12,
512,
27898,
29,
5863,
12,
4543,
63,
888,
29,
403,
12,
1584,
29,
403,
12,
8541,
29,
403,
12,
288,
1834,
29,
403,
12,
790,
63,
354,
29,
403,
12,
2248,
29674,
29,
403,
12,
3404,
29,
403,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
wow2006/ycmd
|
cpp/ycm/tests/gmock/gtest/test/gtest_throw_on_failure_test.py
|
2917
|
5766
|
#!/usr/bin/env python
#
# Copyright 2009, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following disclaimer
# in the documentation and/or other materials provided with the
# distribution.
# * Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
"""Tests Google Test's throw-on-failure mode with exceptions disabled.
This script invokes gtest_throw_on_failure_test_ (a program written with
Google Test) with different environments and command line flags.
"""
__author__ = 'wan@google.com (Zhanyong Wan)'
import os
import gtest_test_utils
# Constants.
# The command line flag for enabling/disabling the throw-on-failure mode.
THROW_ON_FAILURE = 'gtest_throw_on_failure'
# Path to the gtest_throw_on_failure_test_ program, compiled with
# exceptions disabled.
EXE_PATH = gtest_test_utils.GetTestExecutablePath(
'gtest_throw_on_failure_test_')
# Utilities.
def SetEnvVar(env_var, value):
"""Sets an environment variable to a given value; unsets it when the
given value is None.
"""
env_var = env_var.upper()
if value is not None:
os.environ[env_var] = value
elif env_var in os.environ:
del os.environ[env_var]
def Run(command):
"""Runs a command; returns True/False if its exit code is/isn't 0."""
print 'Running "%s". . .' % ' '.join(command)
p = gtest_test_utils.Subprocess(command)
return p.exited and p.exit_code == 0
# The tests. TODO(wan@google.com): refactor the class to share common
# logic with code in gtest_break_on_failure_unittest.py.
class ThrowOnFailureTest(gtest_test_utils.TestCase):
"""Tests the throw-on-failure mode."""
def RunAndVerify(self, env_var_value, flag_value, should_fail):
"""Runs gtest_throw_on_failure_test_ and verifies that it does
(or does not) exit with a non-zero code.
Args:
env_var_value: value of the GTEST_BREAK_ON_FAILURE environment
variable; None if the variable should be unset.
flag_value: value of the --gtest_break_on_failure flag;
None if the flag should not be present.
should_fail: True iff the program is expected to fail.
"""
SetEnvVar(THROW_ON_FAILURE, env_var_value)
if env_var_value is None:
env_var_value_msg = ' is not set'
else:
env_var_value_msg = '=' + env_var_value
if flag_value is None:
flag = ''
elif flag_value == '0':
flag = '--%s=0' % THROW_ON_FAILURE
else:
flag = '--%s' % THROW_ON_FAILURE
command = [EXE_PATH]
if flag:
command.append(flag)
if should_fail:
should_or_not = 'should'
else:
should_or_not = 'should not'
failed = not Run(command)
SetEnvVar(THROW_ON_FAILURE, None)
msg = ('when %s%s, an assertion failure in "%s" %s cause a non-zero '
'exit code.' %
(THROW_ON_FAILURE, env_var_value_msg, ' '.join(command),
should_or_not))
self.assert_(failed == should_fail, msg)
def testDefaultBehavior(self):
"""Tests the behavior of the default mode."""
self.RunAndVerify(env_var_value=None, flag_value=None, should_fail=False)
def testThrowOnFailureEnvVar(self):
"""Tests using the GTEST_THROW_ON_FAILURE environment variable."""
self.RunAndVerify(env_var_value='0',
flag_value=None,
should_fail=False)
self.RunAndVerify(env_var_value='1',
flag_value=None,
should_fail=True)
def testThrowOnFailureFlag(self):
"""Tests using the --gtest_throw_on_failure flag."""
self.RunAndVerify(env_var_value=None,
flag_value='0',
should_fail=False)
self.RunAndVerify(env_var_value=None,
flag_value='1',
should_fail=True)
def testThrowOnFailureFlagOverridesEnvVar(self):
"""Tests that --gtest_throw_on_failure overrides GTEST_THROW_ON_FAILURE."""
self.RunAndVerify(env_var_value='0',
flag_value='0',
should_fail=False)
self.RunAndVerify(env_var_value='0',
flag_value='1',
should_fail=True)
self.RunAndVerify(env_var_value='1',
flag_value='0',
should_fail=False)
self.RunAndVerify(env_var_value='1',
flag_value='1',
should_fail=True)
if __name__ == '__main__':
gtest_test_utils.Main()
|
gpl-3.0
|
[
3381,
2647,
15,
1393,
15,
1813,
2366,
199,
3,
199,
3,
1898,
8937,
12,
4475,
3277,
14,
199,
3,
2900,
4481,
4644,
14,
199,
3,
199,
3,
10114,
436,
675,
315,
1350,
436,
3366,
4513,
12,
543,
503,
1928,
199,
3,
7100,
12,
787,
8211,
2741,
626,
314,
2569,
3704,
787,
199,
3,
7647,
26,
199,
3,
199,
3,
258,
627,
6823,
402,
1350,
1233,
1471,
8074,
314,
3432,
4248,
199,
3,
4245,
12,
642,
769,
402,
3704,
436,
314,
2569,
6450,
14,
199,
3,
258,
627,
6823,
315,
3366,
1824,
1471,
9172,
314,
3432,
199,
3,
4248,
4245,
12,
642,
769,
402,
3704,
436,
314,
2569,
6450,
199,
3,
315,
314,
3794,
436,
15,
269,
1163,
8418,
2741,
543,
314,
199,
3,
4084,
14,
199,
3,
258,
627,
11443,
314,
536,
402,
4475,
3277,
14,
6590,
314,
1561,
402,
2399,
199,
3,
8417,
1443,
506,
1202,
370,
10692,
503,
10016,
7585,
7131,
687,
199,
3,
642,
2032,
1928,
2488,
6791,
5313,
4983,
14,
199,
3,
199,
3,
5749,
4141,
2281,
7049,
6515,
2334,
5877,
8164,
2401,
6483,
199,
3,
298,
1179,
2281,
2,
2401,
1821,
7168,
1549,
5292,
2990,
12,
6931,
12,
5400,
2845,
199,
3,
5471,
2296,
12,
2334,
5292,
2990,
1634,
3169,
2401,
3092,
2381,
199,
3,
437,
3115,
3104,
9315,
9706,
14,
1621,
4825,
6461,
7000,
2334,
5877,
199,
3,
11489,
1549,
6483,
6262,
7024,
2381,
1821,
8703,
12,
9168,
12,
9716,
12,
199,
3,
8820,
12,
9836,
12,
1549,
9110,
6736,
334,
6446,
12,
5400,
2845,
199,
3,
5471,
2296,
12,
9838,
1634,
9103,
9764,
1549,
9714,
27,
9102,
1634,
4815,
12,
199,
3,
7126,
12,
1549,
9206,
27,
1549,
9748,
9831,
9,
9802,
9817,
2401,
5258,
1821,
199,
3,
9815,
1634,
5603,
12,
7061,
1621,
7066,
12,
9644,
5603,
12,
1549,
7056,
199,
3,
334,
6446,
9254,
1549,
7334,
9,
7043,
1621,
1821,
9683,
5738,
1634,
2334,
4815,
199,
3,
1634,
5749,
4141,
12,
9704,
8036,
9691,
1634,
2334,
9726,
1634,
9712,
9784,
14,
199,
199,
624,
2925,
4475,
1379,
1159,
7978,
13,
265,
13,
5328,
818,
543,
4967,
6980,
14,
199,
199,
2765,
2884,
29761,
9088,
63,
11964,
63,
265,
63,
5328,
63,
396,
63,
334,
65,
2240,
5313,
543,
199,
13266,
1379,
9,
543,
3365,
22196,
436,
1414,
1004,
3285,
14,
199,
624,
199,
199,
363,
2502,
363,
275,
283,
20444,
32,
3098,
14,
957,
334,
12674,
1629,
951,
644,
290,
3171,
199,
199,
646,
747,
199,
646,
9088,
63,
396,
63,
1208,
421,
199,
3,
22296,
14,
199,
199,
3,
710,
1414,
1004,
3305,
367,
29310,
15,
2297,
14744,
314,
7978,
13,
265,
13,
5328,
818,
14,
199,
2080,
11415,
63,
615,
63,
13989,
275,
283,
8385,
63,
11964,
63,
265,
63,
5328,
7,
199,
199,
3,
6912,
370,
314,
9088,
63,
11964,
63,
265,
63,
5328,
63,
396,
63,
2240,
12,
10311,
543,
199,
3,
4967,
6980,
14,
199,
23017,
63,
3243,
275,
9088,
63,
396,
63,
1208,
14,
28967,
27602,
8,
272,
283,
8385,
63,
11964,
63,
265,
63,
5328,
63,
396,
15452,
421,
199,
3,
738,
17933,
14,
421,
199,
318,
30306,
8,
1813,
63,
1391,
12,
574,
304,
523,
408,
9899,
376,
3734,
1750,
370,
282,
1627,
574,
27,
625,
2193,
652,
1380,
314,
523,
1627,
574,
365,
488,
14,
523,
408,
819,
2589,
63,
1391,
275,
2589,
63,
1391,
14,
4142,
342,
523,
340,
574,
365,
440,
488,
26,
272,
747,
14,
2314,
59,
1813,
63,
1391,
61,
275,
574,
523,
916,
2589,
63,
1391,
315,
747,
14,
2314,
26,
272,
2150,
747,
14,
2314,
59,
1813,
63,
1391,
61,
421,
199,
318,
3378,
8,
1531,
304,
523,
408,
16291,
282,
1414,
27,
2529,
715,
15,
797,
340,
2399,
4458,
1233,
365,
15,
374,
78,
1133,
378,
1041,
819,
870,
283,
9602,
2071,
83,
1674,
1275,
1275,
7,
450,
283,
1987,
904,
8,
1531,
9,
523,
299,
275,
9088,
63,
396,
63,
1208,
14,
22299,
8,
1531,
9,
523,
372,
299,
14,
32290,
436,
299,
14,
2224,
63,
600,
508,
378,
421,
199,
3,
710,
2295,
14,
221,
3254,
8,
20444,
32,
3098,
14,
957,
304,
24200,
314,
1021,
370,
8663,
2863,
199,
3,
9661,
543,
1233,
315,
9088,
63,
4785,
63,
265,
63,
5328,
63,
2796,
14,
647,
14,
199,
533,
3868,
1143,
3314,
6782,
774,
8,
8385,
63,
396,
63,
1208,
14,
1746,
304,
523,
408,
2925,
314,
7978,
13,
265,
13,
5328,
818,
1041,
819,
347,
3378,
14222,
8,
277,
12,
2589,
63,
1391,
63,
585,
12,
3305,
63,
585,
12,
1077,
63,
1633,
304,
272,
408,
16291,
9088,
63,
11964,
63,
265,
63,
5328,
63,
396,
63,
436,
22694,
626,
652,
1630,
272,
334,
269,
1630,
440,
9,
4458,
543,
282,
2222,
13,
4262,
1233,
14,
339,
3033,
26,
489,
2589,
63,
1391,
63,
585,
26,
259,
574,
402,
314,
18652,
63,
14731,
63,
615,
63,
13989,
3734,
717,
1750,
27,
488,
340,
314,
1750,
1077,
506,
15376,
14,
489,
3305,
63,
585,
26,
755,
574,
402,
314,
1553,
8385,
63,
4785,
63,
265,
63,
5328,
3305,
27,
717,
488,
340,
314,
3305,
1077,
440,
506,
3451,
14,
489,
1077,
63,
1633,
26,
420,
715,
17963,
314,
2240,
365,
1420,
370,
2449,
14,
272,
408,
339,
30306,
8,
2080,
11415,
63,
615,
63,
13989,
12,
2589,
63,
1391,
63,
585,
9,
339,
340,
2589,
63,
1391,
63,
585,
365,
488,
26,
489,
2589,
63,
1391,
63,
585,
63,
1328,
275,
283,
365,
440,
663,
7,
272,
587,
26,
489,
2589,
63,
1391,
63,
585,
63,
1328,
275,
14051,
435,
2589,
63,
1391,
63,
585,
339,
340,
3305,
63,
585,
365,
488,
26,
489,
3305,
275,
2125,
272,
916,
3305,
63,
585,
508,
283,
16,
356,
489,
3305,
275,
2850,
5,
83,
29,
16,
7,
450,
4221,
11415,
63,
615,
63,
13989,
272,
587,
26,
489,
3305,
275,
2850,
5,
83,
7,
450,
4221,
11415,
63,
615,
63,
13989,
339,
1414,
275,
359,
23017,
63,
3243,
61,
272,
340,
3305,
26,
489,
1414,
14,
740,
8,
4173,
9,
339,
340,
1077,
63,
1633,
26,
489,
1077,
63,
269,
63,
1397,
275,
283,
5626,
7,
272,
587,
26,
489,
1077,
63,
269,
63,
1397,
275,
283,
5626,
440
] |
[
2647,
15,
1393,
15,
1813,
2366,
199,
3,
199,
3,
1898,
8937,
12,
4475,
3277,
14,
199,
3,
2900,
4481,
4644,
14,
199,
3,
199,
3,
10114,
436,
675,
315,
1350,
436,
3366,
4513,
12,
543,
503,
1928,
199,
3,
7100,
12,
787,
8211,
2741,
626,
314,
2569,
3704,
787,
199,
3,
7647,
26,
199,
3,
199,
3,
258,
627,
6823,
402,
1350,
1233,
1471,
8074,
314,
3432,
4248,
199,
3,
4245,
12,
642,
769,
402,
3704,
436,
314,
2569,
6450,
14,
199,
3,
258,
627,
6823,
315,
3366,
1824,
1471,
9172,
314,
3432,
199,
3,
4248,
4245,
12,
642,
769,
402,
3704,
436,
314,
2569,
6450,
199,
3,
315,
314,
3794,
436,
15,
269,
1163,
8418,
2741,
543,
314,
199,
3,
4084,
14,
199,
3,
258,
627,
11443,
314,
536,
402,
4475,
3277,
14,
6590,
314,
1561,
402,
2399,
199,
3,
8417,
1443,
506,
1202,
370,
10692,
503,
10016,
7585,
7131,
687,
199,
3,
642,
2032,
1928,
2488,
6791,
5313,
4983,
14,
199,
3,
199,
3,
5749,
4141,
2281,
7049,
6515,
2334,
5877,
8164,
2401,
6483,
199,
3,
298,
1179,
2281,
2,
2401,
1821,
7168,
1549,
5292,
2990,
12,
6931,
12,
5400,
2845,
199,
3,
5471,
2296,
12,
2334,
5292,
2990,
1634,
3169,
2401,
3092,
2381,
199,
3,
437,
3115,
3104,
9315,
9706,
14,
1621,
4825,
6461,
7000,
2334,
5877,
199,
3,
11489,
1549,
6483,
6262,
7024,
2381,
1821,
8703,
12,
9168,
12,
9716,
12,
199,
3,
8820,
12,
9836,
12,
1549,
9110,
6736,
334,
6446,
12,
5400,
2845,
199,
3,
5471,
2296,
12,
9838,
1634,
9103,
9764,
1549,
9714,
27,
9102,
1634,
4815,
12,
199,
3,
7126,
12,
1549,
9206,
27,
1549,
9748,
9831,
9,
9802,
9817,
2401,
5258,
1821,
199,
3,
9815,
1634,
5603,
12,
7061,
1621,
7066,
12,
9644,
5603,
12,
1549,
7056,
199,
3,
334,
6446,
9254,
1549,
7334,
9,
7043,
1621,
1821,
9683,
5738,
1634,
2334,
4815,
199,
3,
1634,
5749,
4141,
12,
9704,
8036,
9691,
1634,
2334,
9726,
1634,
9712,
9784,
14,
199,
199,
624,
2925,
4475,
1379,
1159,
7978,
13,
265,
13,
5328,
818,
543,
4967,
6980,
14,
199,
199,
2765,
2884,
29761,
9088,
63,
11964,
63,
265,
63,
5328,
63,
396,
63,
334,
65,
2240,
5313,
543,
199,
13266,
1379,
9,
543,
3365,
22196,
436,
1414,
1004,
3285,
14,
199,
624,
199,
199,
363,
2502,
363,
275,
283,
20444,
32,
3098,
14,
957,
334,
12674,
1629,
951,
644,
290,
3171,
199,
199,
646,
747,
199,
646,
9088,
63,
396,
63,
1208,
421,
199,
3,
22296,
14,
199,
199,
3,
710,
1414,
1004,
3305,
367,
29310,
15,
2297,
14744,
314,
7978,
13,
265,
13,
5328,
818,
14,
199,
2080,
11415,
63,
615,
63,
13989,
275,
283,
8385,
63,
11964,
63,
265,
63,
5328,
7,
199,
199,
3,
6912,
370,
314,
9088,
63,
11964,
63,
265,
63,
5328,
63,
396,
63,
2240,
12,
10311,
543,
199,
3,
4967,
6980,
14,
199,
23017,
63,
3243,
275,
9088,
63,
396,
63,
1208,
14,
28967,
27602,
8,
272,
283,
8385,
63,
11964,
63,
265,
63,
5328,
63,
396,
15452,
421,
199,
3,
738,
17933,
14,
421,
199,
318,
30306,
8,
1813,
63,
1391,
12,
574,
304,
523,
408,
9899,
376,
3734,
1750,
370,
282,
1627,
574,
27,
625,
2193,
652,
1380,
314,
523,
1627,
574,
365,
488,
14,
523,
408,
819,
2589,
63,
1391,
275,
2589,
63,
1391,
14,
4142,
342,
523,
340,
574,
365,
440,
488,
26,
272,
747,
14,
2314,
59,
1813,
63,
1391,
61,
275,
574,
523,
916,
2589,
63,
1391,
315,
747,
14,
2314,
26,
272,
2150,
747,
14,
2314,
59,
1813,
63,
1391,
61,
421,
199,
318,
3378,
8,
1531,
304,
523,
408,
16291,
282,
1414,
27,
2529,
715,
15,
797,
340,
2399,
4458,
1233,
365,
15,
374,
78,
1133,
378,
1041,
819,
870,
283,
9602,
2071,
83,
1674,
1275,
1275,
7,
450,
283,
1987,
904,
8,
1531,
9,
523,
299,
275,
9088,
63,
396,
63,
1208,
14,
22299,
8,
1531,
9,
523,
372,
299,
14,
32290,
436,
299,
14,
2224,
63,
600,
508,
378,
421,
199,
3,
710,
2295,
14,
221,
3254,
8,
20444,
32,
3098,
14,
957,
304,
24200,
314,
1021,
370,
8663,
2863,
199,
3,
9661,
543,
1233,
315,
9088,
63,
4785,
63,
265,
63,
5328,
63,
2796,
14,
647,
14,
199,
533,
3868,
1143,
3314,
6782,
774,
8,
8385,
63,
396,
63,
1208,
14,
1746,
304,
523,
408,
2925,
314,
7978,
13,
265,
13,
5328,
818,
1041,
819,
347,
3378,
14222,
8,
277,
12,
2589,
63,
1391,
63,
585,
12,
3305,
63,
585,
12,
1077,
63,
1633,
304,
272,
408,
16291,
9088,
63,
11964,
63,
265,
63,
5328,
63,
396,
63,
436,
22694,
626,
652,
1630,
272,
334,
269,
1630,
440,
9,
4458,
543,
282,
2222,
13,
4262,
1233,
14,
339,
3033,
26,
489,
2589,
63,
1391,
63,
585,
26,
259,
574,
402,
314,
18652,
63,
14731,
63,
615,
63,
13989,
3734,
717,
1750,
27,
488,
340,
314,
1750,
1077,
506,
15376,
14,
489,
3305,
63,
585,
26,
755,
574,
402,
314,
1553,
8385,
63,
4785,
63,
265,
63,
5328,
3305,
27,
717,
488,
340,
314,
3305,
1077,
440,
506,
3451,
14,
489,
1077,
63,
1633,
26,
420,
715,
17963,
314,
2240,
365,
1420,
370,
2449,
14,
272,
408,
339,
30306,
8,
2080,
11415,
63,
615,
63,
13989,
12,
2589,
63,
1391,
63,
585,
9,
339,
340,
2589,
63,
1391,
63,
585,
365,
488,
26,
489,
2589,
63,
1391,
63,
585,
63,
1328,
275,
283,
365,
440,
663,
7,
272,
587,
26,
489,
2589,
63,
1391,
63,
585,
63,
1328,
275,
14051,
435,
2589,
63,
1391,
63,
585,
339,
340,
3305,
63,
585,
365,
488,
26,
489,
3305,
275,
2125,
272,
916,
3305,
63,
585,
508,
283,
16,
356,
489,
3305,
275,
2850,
5,
83,
29,
16,
7,
450,
4221,
11415,
63,
615,
63,
13989,
272,
587,
26,
489,
3305,
275,
2850,
5,
83,
7,
450,
4221,
11415,
63,
615,
63,
13989,
339,
1414,
275,
359,
23017,
63,
3243,
61,
272,
340,
3305,
26,
489,
1414,
14,
740,
8,
4173,
9,
339,
340,
1077,
63,
1633,
26,
489,
1077,
63,
269,
63,
1397,
275,
283,
5626,
7,
272,
587,
26,
489,
1077,
63,
269,
63,
1397,
275,
283,
5626,
440,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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SupervisedModelTrainer
import healthcareai.datasets as hcai_datasets
import sys
from io import StringIO
class TestTrainerDecorator(unittest.TestCase):
"""Tests for the training decorator.
We will compare a decorated linear regression and a undecorated linear regression output. They should not be
the same.
"""
def setUp(self):
df = hcai_datasets.load_diabetes()
# Drop columns that won't help machine learning
columns_to_remove = ['PatientID']
df.drop(columns_to_remove, axis=1, inplace=True)
self.regression_trainer = SupervisedModelTrainer(df,
'SystolicBPNBR',
'regression',
grain_column='PatientEncounterID',
impute=True,
verbose=False)
def undecorated_lr(self):
return self._advanced_trainer.linear_regression(randomized_search=False)
self.regression_trainer.undecorated_lr = undecorated_lr.__get__(self.regression_trainer,
self.regression_trainer.__class__)
def test_decorator(self):
out = StringIO()
sys.stdout = out
self.regression_trainer.linear_regression()
decorated_output = out.getvalue().strip()
out = StringIO()
sys.stdout = out
self.regression_trainer.undecorated_lr()
undecorated_output = out.getvalue().strip()
assert decorated_output != undecorated_output
|
mit
|
[
646,
2882,
199,
504,
13822,
28654,
5789,
14,
4792,
17311,
63,
1238,
63,
2834,
281,
492,
17897,
17311,
1685,
2437,
16187,
199,
646,
13822,
28654,
5789,
14,
12281,
465,
394,
696,
73,
63,
12281,
199,
646,
984,
199,
504,
5890,
492,
5228,
421,
199,
533,
1379,
2437,
16187,
14946,
8,
2796,
14,
1746,
304,
339,
408,
2925,
367,
314,
6093,
7531,
14,
339,
2136,
911,
6540,
282,
16225,
7798,
10864,
436,
282,
625,
29299,
7798,
10864,
1072,
14,
9322,
1077,
440,
506,
272,
314,
2011,
14,
339,
408,
339,
347,
3613,
8,
277,
304,
267,
4051,
275,
394,
696,
73,
63,
12281,
14,
912,
63,
328,
26290,
342,
398,
327,
18110,
4362,
626,
7859,
1133,
1720,
6844,
9328,
267,
4362,
63,
475,
63,
2168,
275,
788,
48,
31078,
998,
418,
267,
4051,
14,
4824,
8,
3406,
63,
475,
63,
2168,
12,
3114,
29,
17,
12,
16304,
29,
549,
9,
398,
291,
14,
12513,
63,
2834,
281,
275,
17897,
17311,
1685,
2437,
16187,
8,
1587,
12,
12740,
283,
4323,
14308,
606,
34,
9060,
7184,
297,
12740,
283,
12513,
297,
12740,
1999,
262,
63,
2301,
534,
48,
31078,
1327,
5337,
998,
297,
12740,
1742,
938,
29,
549,
12,
12740,
3376,
29,
797,
9,
398,
347,
625,
29299,
63,
7493,
8,
277,
304,
288,
372,
291,
423,
14652,
63,
2834,
281,
14,
6676,
63,
12513,
8,
2355,
1759,
63,
1733,
29,
797,
9,
398,
291,
14,
12513,
63,
2834,
281,
14,
324,
29299,
63,
7493,
275,
625,
29299,
63,
7493,
855,
362,
721,
277,
14,
12513,
63,
2834,
281,
12,
6684,
263,
291,
14,
12513,
63,
2834,
281,
855,
533,
3368,
339,
347,
511,
63,
11547,
8,
277,
304,
267,
734,
275,
5228,
342,
267,
984,
14,
2703,
275,
734,
267,
291,
14,
12513,
63,
2834,
281,
14,
6676,
63,
12513,
342,
267,
16225,
63,
1199,
275,
734,
14,
7150,
1252,
1913,
342,
398,
734,
275,
5228,
342,
267,
984,
14,
2703,
275,
734,
267,
291,
14,
12513,
63,
2834,
281,
14,
324,
29299,
63,
7493,
342,
267,
625,
29299,
63,
1199,
275,
734,
14,
7150,
1252,
1913,
342,
398,
702,
16225,
63,
1199,
1137,
625,
29299,
63,
1199,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
2882,
199,
504,
13822,
28654,
5789,
14,
4792,
17311,
63,
1238,
63,
2834,
281,
492,
17897,
17311,
1685,
2437,
16187,
199,
646,
13822,
28654,
5789,
14,
12281,
465,
394,
696,
73,
63,
12281,
199,
646,
984,
199,
504,
5890,
492,
5228,
421,
199,
533,
1379,
2437,
16187,
14946,
8,
2796,
14,
1746,
304,
339,
408,
2925,
367,
314,
6093,
7531,
14,
339,
2136,
911,
6540,
282,
16225,
7798,
10864,
436,
282,
625,
29299,
7798,
10864,
1072,
14,
9322,
1077,
440,
506,
272,
314,
2011,
14,
339,
408,
339,
347,
3613,
8,
277,
304,
267,
4051,
275,
394,
696,
73,
63,
12281,
14,
912,
63,
328,
26290,
342,
398,
327,
18110,
4362,
626,
7859,
1133,
1720,
6844,
9328,
267,
4362,
63,
475,
63,
2168,
275,
788,
48,
31078,
998,
418,
267,
4051,
14,
4824,
8,
3406,
63,
475,
63,
2168,
12,
3114,
29,
17,
12,
16304,
29,
549,
9,
398,
291,
14,
12513,
63,
2834,
281,
275,
17897,
17311,
1685,
2437,
16187,
8,
1587,
12,
12740,
283,
4323,
14308,
606,
34,
9060,
7184,
297,
12740,
283,
12513,
297,
12740,
1999,
262,
63,
2301,
534,
48,
31078,
1327,
5337,
998,
297,
12740,
1742,
938,
29,
549,
12,
12740,
3376,
29,
797,
9,
398,
347,
625,
29299,
63,
7493,
8,
277,
304,
288,
372,
291,
423,
14652,
63,
2834,
281,
14,
6676,
63,
12513,
8,
2355,
1759,
63,
1733,
29,
797,
9,
398,
291,
14,
12513,
63,
2834,
281,
14,
324,
29299,
63,
7493,
275,
625,
29299,
63,
7493,
855,
362,
721,
277,
14,
12513,
63,
2834,
281,
12,
6684,
263,
291,
14,
12513,
63,
2834,
281,
855,
533,
3368,
339,
347,
511,
63,
11547,
8,
277,
304,
267,
734,
275,
5228,
342,
267,
984,
14,
2703,
275,
734,
267,
291,
14,
12513,
63,
2834,
281,
14,
6676,
63,
12513,
342,
267,
16225,
63,
1199,
275,
734,
14,
7150,
1252,
1913,
342,
398,
734,
275,
5228,
342,
267,
984,
14,
2703,
275,
734,
267,
291,
14,
12513,
63,
2834,
281,
14,
324,
29299,
63,
7493,
342,
267,
625,
29299,
63,
1199,
275,
734,
14,
7150,
1252,
1913,
342,
398,
702,
16225,
63,
1199,
1137,
625,
29299,
63,
1199,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768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0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
umitproject/tease-o-matic
|
django/contrib/comments/forms.py
|
245
|
8730
|
import time
import datetime
from django import forms
from django.forms.util import ErrorDict
from django.conf import settings
from django.contrib.contenttypes.models import ContentType
from models import Comment
from django.utils.crypto import salted_hmac, constant_time_compare
from django.utils.encoding import force_unicode
from django.utils.hashcompat import sha_constructor
from django.utils.text import get_text_list
from django.utils.translation import ungettext, ugettext_lazy as _
COMMENT_MAX_LENGTH = getattr(settings,'COMMENT_MAX_LENGTH', 3000)
class CommentSecurityForm(forms.Form):
"""
Handles the security aspects (anti-spoofing) for comment forms.
"""
content_type = forms.CharField(widget=forms.HiddenInput)
object_pk = forms.CharField(widget=forms.HiddenInput)
timestamp = forms.IntegerField(widget=forms.HiddenInput)
security_hash = forms.CharField(min_length=40, max_length=40, widget=forms.HiddenInput)
def __init__(self, target_object, data=None, initial=None):
self.target_object = target_object
if initial is None:
initial = {}
initial.update(self.generate_security_data())
super(CommentSecurityForm, self).__init__(data=data, initial=initial)
def security_errors(self):
"""Return just those errors associated with security"""
errors = ErrorDict()
for f in ["honeypot", "timestamp", "security_hash"]:
if f in self.errors:
errors[f] = self.errors[f]
return errors
def clean_security_hash(self):
"""Check the security hash."""
security_hash_dict = {
'content_type' : self.data.get("content_type", ""),
'object_pk' : self.data.get("object_pk", ""),
'timestamp' : self.data.get("timestamp", ""),
}
expected_hash = self.generate_security_hash(**security_hash_dict)
actual_hash = self.cleaned_data["security_hash"]
if not constant_time_compare(expected_hash, actual_hash):
# Fallback to Django 1.2 method for compatibility
# PendingDeprecationWarning <- here to remind us to remove this
# fallback in Django 1.5
expected_hash_old = self._generate_security_hash_old(**security_hash_dict)
if not constant_time_compare(expected_hash_old, actual_hash):
raise forms.ValidationError("Security hash check failed.")
return actual_hash
def clean_timestamp(self):
"""Make sure the timestamp isn't too far (> 2 hours) in the past."""
ts = self.cleaned_data["timestamp"]
if time.time() - ts > (2 * 60 * 60):
raise forms.ValidationError("Timestamp check failed")
return ts
def generate_security_data(self):
"""Generate a dict of security data for "initial" data."""
timestamp = int(time.time())
security_dict = {
'content_type' : str(self.target_object._meta),
'object_pk' : str(self.target_object._get_pk_val()),
'timestamp' : str(timestamp),
'security_hash' : self.initial_security_hash(timestamp),
}
return security_dict
def initial_security_hash(self, timestamp):
"""
Generate the initial security hash from self.content_object
and a (unix) timestamp.
"""
initial_security_dict = {
'content_type' : str(self.target_object._meta),
'object_pk' : str(self.target_object._get_pk_val()),
'timestamp' : str(timestamp),
}
return self.generate_security_hash(**initial_security_dict)
def generate_security_hash(self, content_type, object_pk, timestamp):
"""
Generate a HMAC security hash from the provided info.
"""
info = (content_type, object_pk, timestamp)
key_salt = "django.contrib.forms.CommentSecurityForm"
value = "-".join(info)
return salted_hmac(key_salt, value).hexdigest()
def _generate_security_hash_old(self, content_type, object_pk, timestamp):
"""Generate a (SHA1) security hash from the provided info."""
# Django 1.2 compatibility
info = (content_type, object_pk, timestamp, settings.SECRET_KEY)
return sha_constructor("".join(info)).hexdigest()
class CommentDetailsForm(CommentSecurityForm):
"""
Handles the specific details of the comment (name, comment, etc.).
"""
name = forms.CharField(label=_("Name"), max_length=50)
email = forms.EmailField(label=_("Email address"))
url = forms.URLField(label=_("URL"), required=False)
comment = forms.CharField(label=_('Comment'), widget=forms.Textarea,
max_length=COMMENT_MAX_LENGTH)
def get_comment_object(self):
"""
Return a new (unsaved) comment object based on the information in this
form. Assumes that the form is already validated and will throw a
ValueError if not.
Does not set any of the fields that would come from a Request object
(i.e. ``user`` or ``ip_address``).
"""
if not self.is_valid():
raise ValueError("get_comment_object may only be called on valid forms")
CommentModel = self.get_comment_model()
new = CommentModel(**self.get_comment_create_data())
new = self.check_for_duplicate_comment(new)
return new
def get_comment_model(self):
"""
Get the comment model to create with this form. Subclasses in custom
comment apps should override this, get_comment_create_data, and perhaps
check_for_duplicate_comment to provide custom comment models.
"""
return Comment
def get_comment_create_data(self):
"""
Returns the dict of data to be used to create a comment. Subclasses in
custom comment apps that override get_comment_model can override this
method to add extra fields onto a custom comment model.
"""
return dict(
content_type = ContentType.objects.get_for_model(self.target_object),
object_pk = force_unicode(self.target_object._get_pk_val()),
user_name = self.cleaned_data["name"],
user_email = self.cleaned_data["email"],
user_url = self.cleaned_data["url"],
comment = self.cleaned_data["comment"],
submit_date = datetime.datetime.now(),
site_id = settings.SITE_ID,
is_public = True,
is_removed = False,
)
def check_for_duplicate_comment(self, new):
"""
Check that a submitted comment isn't a duplicate. This might be caused
by someone posting a comment twice. If it is a dup, silently return the *previous* comment.
"""
possible_duplicates = self.get_comment_model()._default_manager.using(
self.target_object._state.db
).filter(
content_type = new.content_type,
object_pk = new.object_pk,
user_name = new.user_name,
user_email = new.user_email,
user_url = new.user_url,
)
for old in possible_duplicates:
if old.submit_date.date() == new.submit_date.date() and old.comment == new.comment:
return old
return new
def clean_comment(self):
"""
If COMMENTS_ALLOW_PROFANITIES is False, check that the comment doesn't
contain anything in PROFANITIES_LIST.
"""
comment = self.cleaned_data["comment"]
if settings.COMMENTS_ALLOW_PROFANITIES == False:
bad_words = [w for w in settings.PROFANITIES_LIST if w in comment.lower()]
if bad_words:
plural = len(bad_words) > 1
raise forms.ValidationError(ungettext(
"Watch your mouth! The word %s is not allowed here.",
"Watch your mouth! The words %s are not allowed here.", plural) % \
get_text_list(['"%s%s%s"' % (i[0], '-'*(len(i)-2), i[-1]) for i in bad_words], 'and'))
return comment
class CommentForm(CommentDetailsForm):
honeypot = forms.CharField(required=False,
label=_('If you enter anything in this field '\
'your comment will be treated as spam'))
def clean_honeypot(self):
"""Check that nothing's been entered into the honeypot."""
value = self.cleaned_data["honeypot"]
if value:
raise forms.ValidationError(self.fields["honeypot"].label)
return value
|
bsd-3-clause
|
[
646,
900,
199,
646,
2197,
199,
199,
504,
1639,
492,
4513,
199,
504,
1639,
14,
3351,
14,
1974,
492,
4520,
2141,
199,
504,
1639,
14,
2190,
492,
2202,
199,
504,
1639,
14,
2828,
14,
10778,
14,
992,
492,
14501,
199,
504,
1709,
492,
6819,
199,
504,
1639,
14,
1208,
14,
10316,
492,
18641,
471,
63,
18537,
12,
4413,
63,
521,
63,
5785,
199,
504,
1639,
14,
1208,
14,
2991,
492,
3542,
63,
2975,
199,
504,
1639,
14,
1208,
14,
2227,
5819,
492,
7793,
63,
1880,
199,
504,
1639,
14,
1208,
14,
505,
492,
664,
63,
505,
63,
513,
199,
504,
1639,
14,
1208,
14,
6893,
492,
26843,
12,
10366,
63,
6395,
465,
485,
199,
199,
10973,
63,
4283,
63,
9127,
275,
2519,
8,
1751,
2584,
10973,
63,
4283,
63,
9127,
297,
29664,
9,
199,
199,
533,
6819,
7676,
2821,
8,
3351,
14,
2821,
304,
272,
408,
272,
23873,
314,
6391,
17435,
83,
334,
4466,
13,
22522,
1618,
316,
9,
367,
3721,
4513,
14,
272,
408,
272,
1564,
63,
466,
221,
275,
4513,
14,
2183,
8,
3440,
29,
3351,
14,
25419,
9,
272,
909,
63,
2051,
258,
275,
4513,
14,
2183,
8,
3440,
29,
3351,
14,
25419,
9,
272,
4913,
258,
275,
4513,
14,
3901,
8,
3440,
29,
3351,
14,
25419,
9,
272,
6391,
63,
2227,
275,
4513,
14,
2183,
8,
827,
63,
1267,
29,
2167,
12,
1390,
63,
1267,
29,
2167,
12,
3938,
29,
3351,
14,
25419,
9,
339,
347,
636,
826,
721,
277,
12,
1347,
63,
785,
12,
666,
29,
403,
12,
2536,
29,
403,
304,
267,
291,
14,
1375,
63,
785,
275,
1347,
63,
785,
267,
340,
2536,
365,
488,
26,
288,
2536,
275,
1052,
267,
2536,
14,
873,
8,
277,
14,
4208,
63,
4416,
63,
576,
1012,
267,
1613,
8,
7488,
7676,
2821,
12,
291,
2843,
826,
721,
576,
29,
576,
12,
2536,
29,
2747,
9,
339,
347,
6391,
63,
2550,
8,
277,
304,
267,
408,
1767,
2951,
5204,
2552,
4568,
543,
6391,
624,
267,
2552,
275,
4520,
2141,
342,
267,
367,
289,
315,
2097,
72,
368,
2279,
357,
401,
298,
3954,
401,
298,
4416,
63,
2227,
6229,
288,
340,
289,
315,
291,
14,
2550,
26,
355,
2552,
59,
70,
61,
275,
291,
14,
2550,
59,
70,
61,
267,
372,
2552,
339,
347,
3633,
63,
4416,
63,
2227,
8,
277,
304,
267,
408,
1799,
314,
6391,
2631,
1041,
267,
6391,
63,
2227,
63,
807,
275,
469,
288,
283,
1317,
63,
466,
7,
520,
291,
14,
576,
14,
362,
480,
1317,
63,
466,
401,
16241,
288,
283,
785,
63,
2051,
7,
520,
291,
14,
576,
14,
362,
480,
785,
63,
2051,
401,
16241,
288,
283,
3954,
7,
520,
291,
14,
576,
14,
362,
480,
3954,
401,
16241,
267,
789,
267,
1420,
63,
2227,
275,
291,
14,
4208,
63,
4416,
63,
2227,
3682,
4416,
63,
2227,
63,
807,
9,
267,
3503,
63,
2227,
275,
291,
14,
8275,
63,
576,
905,
4416,
63,
2227,
937,
267,
340,
440,
4413,
63,
521,
63,
5785,
8,
2062,
63,
2227,
12,
3503,
63,
2227,
304,
288,
327,
481,
5421,
370,
5634,
413,
14,
18,
1083,
367,
7163,
288,
327,
29216,
15561,
25549,
2348,
370,
18798,
688,
2739,
370,
2813,
642,
288,
327,
9567,
315,
5634,
413,
14,
21,
288,
1420,
63,
2227,
63,
1753,
275,
291,
423,
4208,
63,
4416,
63,
2227,
63,
1753,
3682,
4416,
63,
2227,
63,
807,
9,
288,
340,
440,
4413,
63,
521,
63,
5785,
8,
2062,
63,
2227,
63,
1753,
12,
3503,
63,
2227,
304,
355,
746,
4513,
14,
8172,
480,
7676,
2631,
1104,
3405,
2685,
267,
372,
3503,
63,
2227,
339,
347,
3633,
63,
3954,
8,
277,
304,
267,
408,
5483,
3238,
314,
4913,
5712,
1133,
4634,
12474,
334,
30,
499,
10857,
9,
315,
314,
13541,
1041,
267,
6714,
275,
291,
14,
8275,
63,
576,
905,
3954,
937,
267,
340,
900,
14,
521,
342,
446,
6714,
690,
334,
18,
627,
5212,
627,
5212,
304,
288,
746,
4513,
14,
8172,
480,
10239,
1104,
3405,
531,
267,
372,
6714,
339,
347,
3550,
63,
4416,
63,
576,
8,
277,
304,
267,
408,
6864,
282,
1211,
402,
6391,
666,
367,
298,
2747,
2,
666,
1041,
267,
4913,
275,
1109,
8,
521,
14,
521,
1012,
267,
6391,
63,
807,
275,
257,
469,
288,
283,
1317,
63,
466,
7,
221,
520,
620,
8,
277,
14,
1375,
63,
785,
423,
2024,
395,
288,
283,
785,
63,
2051,
7,
258,
520,
620,
8,
277,
14,
1375,
63,
785,
423,
362,
63,
2051,
63,
637,
4000,
288,
283,
3954,
7,
258,
520,
620,
8,
3954,
395,
288,
283,
4416,
63,
2227,
7,
520,
291,
14,
2747,
63,
4416,
63,
2227,
8,
3954,
395,
267,
789,
267,
372,
6391,
63,
807,
339,
347,
2536,
63,
4416,
63,
2227,
8,
277,
12,
4913,
304,
267,
408,
267,
7958,
314,
2536,
6391,
2631,
687,
291,
14,
1317,
63,
785,
267,
436,
282,
334,
11864,
9,
4913,
14,
267,
408,
398,
2536,
63,
4416,
63,
807,
275,
469,
288,
283,
1317,
63,
466,
7,
520,
620,
8,
277,
14,
1375,
63,
785,
423,
2024,
395,
288,
283,
785,
63,
2051,
7,
520,
620,
8,
277,
14,
1375,
63,
785,
423,
362,
63,
2051,
63,
637,
4000,
288,
283,
3954,
7,
520,
620,
8,
3954,
395,
881,
789,
267,
372,
291,
14,
4208,
63,
4416,
63,
2227,
3682,
2747,
63,
4416,
63,
807,
9,
339,
347,
3550,
63,
4416,
63,
2227,
8,
277,
12,
1564,
63,
466,
12,
909,
63,
2051,
12,
4913,
304,
267,
408,
267,
7958,
282,
29817,
6391,
2631,
687,
314,
2741,
2256,
14,
267,
408,
267,
2256,
275,
334,
1317,
63,
466,
12,
909,
63,
2051,
12,
4913,
9,
267,
790,
63,
12597,
275,
298,
1176,
14,
2828,
14,
3351,
14,
7488,
7676,
2821,
2,
267,
574,
275,
3905,
1674,
904,
8,
815,
9,
267,
372,
18641,
471,
63,
18537,
8,
498,
63,
12597,
12,
574,
680,
11453,
342,
339,
347,
485,
4208,
63,
4416,
63,
2227,
63,
1753,
8,
277,
12,
1564,
63,
466,
12,
909,
63,
2051,
12,
4913,
304,
267,
408,
6864,
282,
334,
8461,
17,
9,
6391,
2631,
687,
314,
2741,
2256,
1041,
267,
327,
5634,
413,
14,
18,
7163,
267,
2256,
275,
334,
1317,
63,
466
] |
[
900,
199,
646,
2197,
199,
199,
504,
1639,
492,
4513,
199,
504,
1639,
14,
3351,
14,
1974,
492,
4520,
2141,
199,
504,
1639,
14,
2190,
492,
2202,
199,
504,
1639,
14,
2828,
14,
10778,
14,
992,
492,
14501,
199,
504,
1709,
492,
6819,
199,
504,
1639,
14,
1208,
14,
10316,
492,
18641,
471,
63,
18537,
12,
4413,
63,
521,
63,
5785,
199,
504,
1639,
14,
1208,
14,
2991,
492,
3542,
63,
2975,
199,
504,
1639,
14,
1208,
14,
2227,
5819,
492,
7793,
63,
1880,
199,
504,
1639,
14,
1208,
14,
505,
492,
664,
63,
505,
63,
513,
199,
504,
1639,
14,
1208,
14,
6893,
492,
26843,
12,
10366,
63,
6395,
465,
485,
199,
199,
10973,
63,
4283,
63,
9127,
275,
2519,
8,
1751,
2584,
10973,
63,
4283,
63,
9127,
297,
29664,
9,
199,
199,
533,
6819,
7676,
2821,
8,
3351,
14,
2821,
304,
272,
408,
272,
23873,
314,
6391,
17435,
83,
334,
4466,
13,
22522,
1618,
316,
9,
367,
3721,
4513,
14,
272,
408,
272,
1564,
63,
466,
221,
275,
4513,
14,
2183,
8,
3440,
29,
3351,
14,
25419,
9,
272,
909,
63,
2051,
258,
275,
4513,
14,
2183,
8,
3440,
29,
3351,
14,
25419,
9,
272,
4913,
258,
275,
4513,
14,
3901,
8,
3440,
29,
3351,
14,
25419,
9,
272,
6391,
63,
2227,
275,
4513,
14,
2183,
8,
827,
63,
1267,
29,
2167,
12,
1390,
63,
1267,
29,
2167,
12,
3938,
29,
3351,
14,
25419,
9,
339,
347,
636,
826,
721,
277,
12,
1347,
63,
785,
12,
666,
29,
403,
12,
2536,
29,
403,
304,
267,
291,
14,
1375,
63,
785,
275,
1347,
63,
785,
267,
340,
2536,
365,
488,
26,
288,
2536,
275,
1052,
267,
2536,
14,
873,
8,
277,
14,
4208,
63,
4416,
63,
576,
1012,
267,
1613,
8,
7488,
7676,
2821,
12,
291,
2843,
826,
721,
576,
29,
576,
12,
2536,
29,
2747,
9,
339,
347,
6391,
63,
2550,
8,
277,
304,
267,
408,
1767,
2951,
5204,
2552,
4568,
543,
6391,
624,
267,
2552,
275,
4520,
2141,
342,
267,
367,
289,
315,
2097,
72,
368,
2279,
357,
401,
298,
3954,
401,
298,
4416,
63,
2227,
6229,
288,
340,
289,
315,
291,
14,
2550,
26,
355,
2552,
59,
70,
61,
275,
291,
14,
2550,
59,
70,
61,
267,
372,
2552,
339,
347,
3633,
63,
4416,
63,
2227,
8,
277,
304,
267,
408,
1799,
314,
6391,
2631,
1041,
267,
6391,
63,
2227,
63,
807,
275,
469,
288,
283,
1317,
63,
466,
7,
520,
291,
14,
576,
14,
362,
480,
1317,
63,
466,
401,
16241,
288,
283,
785,
63,
2051,
7,
520,
291,
14,
576,
14,
362,
480,
785,
63,
2051,
401,
16241,
288,
283,
3954,
7,
520,
291,
14,
576,
14,
362,
480,
3954,
401,
16241,
267,
789,
267,
1420,
63,
2227,
275,
291,
14,
4208,
63,
4416,
63,
2227,
3682,
4416,
63,
2227,
63,
807,
9,
267,
3503,
63,
2227,
275,
291,
14,
8275,
63,
576,
905,
4416,
63,
2227,
937,
267,
340,
440,
4413,
63,
521,
63,
5785,
8,
2062,
63,
2227,
12,
3503,
63,
2227,
304,
288,
327,
481,
5421,
370,
5634,
413,
14,
18,
1083,
367,
7163,
288,
327,
29216,
15561,
25549,
2348,
370,
18798,
688,
2739,
370,
2813,
642,
288,
327,
9567,
315,
5634,
413,
14,
21,
288,
1420,
63,
2227,
63,
1753,
275,
291,
423,
4208,
63,
4416,
63,
2227,
63,
1753,
3682,
4416,
63,
2227,
63,
807,
9,
288,
340,
440,
4413,
63,
521,
63,
5785,
8,
2062,
63,
2227,
63,
1753,
12,
3503,
63,
2227,
304,
355,
746,
4513,
14,
8172,
480,
7676,
2631,
1104,
3405,
2685,
267,
372,
3503,
63,
2227,
339,
347,
3633,
63,
3954,
8,
277,
304,
267,
408,
5483,
3238,
314,
4913,
5712,
1133,
4634,
12474,
334,
30,
499,
10857,
9,
315,
314,
13541,
1041,
267,
6714,
275,
291,
14,
8275,
63,
576,
905,
3954,
937,
267,
340,
900,
14,
521,
342,
446,
6714,
690,
334,
18,
627,
5212,
627,
5212,
304,
288,
746,
4513,
14,
8172,
480,
10239,
1104,
3405,
531,
267,
372,
6714,
339,
347,
3550,
63,
4416,
63,
576,
8,
277,
304,
267,
408,
6864,
282,
1211,
402,
6391,
666,
367,
298,
2747,
2,
666,
1041,
267,
4913,
275,
1109,
8,
521,
14,
521,
1012,
267,
6391,
63,
807,
275,
257,
469,
288,
283,
1317,
63,
466,
7,
221,
520,
620,
8,
277,
14,
1375,
63,
785,
423,
2024,
395,
288,
283,
785,
63,
2051,
7,
258,
520,
620,
8,
277,
14,
1375,
63,
785,
423,
362,
63,
2051,
63,
637,
4000,
288,
283,
3954,
7,
258,
520,
620,
8,
3954,
395,
288,
283,
4416,
63,
2227,
7,
520,
291,
14,
2747,
63,
4416,
63,
2227,
8,
3954,
395,
267,
789,
267,
372,
6391,
63,
807,
339,
347,
2536,
63,
4416,
63,
2227,
8,
277,
12,
4913,
304,
267,
408,
267,
7958,
314,
2536,
6391,
2631,
687,
291,
14,
1317,
63,
785,
267,
436,
282,
334,
11864,
9,
4913,
14,
267,
408,
398,
2536,
63,
4416,
63,
807,
275,
469,
288,
283,
1317,
63,
466,
7,
520,
620,
8,
277,
14,
1375,
63,
785,
423,
2024,
395,
288,
283,
785,
63,
2051,
7,
520,
620,
8,
277,
14,
1375,
63,
785,
423,
362,
63,
2051,
63,
637,
4000,
288,
283,
3954,
7,
520,
620,
8,
3954,
395,
881,
789,
267,
372,
291,
14,
4208,
63,
4416,
63,
2227,
3682,
2747,
63,
4416,
63,
807,
9,
339,
347,
3550,
63,
4416,
63,
2227,
8,
277,
12,
1564,
63,
466,
12,
909,
63,
2051,
12,
4913,
304,
267,
408,
267,
7958,
282,
29817,
6391,
2631,
687,
314,
2741,
2256,
14,
267,
408,
267,
2256,
275,
334,
1317,
63,
466,
12,
909,
63,
2051,
12,
4913,
9,
267,
790,
63,
12597,
275,
298,
1176,
14,
2828,
14,
3351,
14,
7488,
7676,
2821,
2,
267,
574,
275,
3905,
1674,
904,
8,
815,
9,
267,
372,
18641,
471,
63,
18537,
8,
498,
63,
12597,
12,
574,
680,
11453,
342,
339,
347,
485,
4208,
63,
4416,
63,
2227,
63,
1753,
8,
277,
12,
1564,
63,
466,
12,
909,
63,
2051,
12,
4913,
304,
267,
408,
6864,
282,
334,
8461,
17,
9,
6391,
2631,
687,
314,
2741,
2256,
1041,
267,
327,
5634,
413,
14,
18,
7163,
267,
2256,
275,
334,
1317,
63,
466,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
ikaee/bfr-attendant
|
facerecognitionlibrary/jni-build/jni/include/tensorflow/models/rnn/ptb/reader.py
|
24
|
3992
|
# Copyright 2015 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
"""Utilities for parsing PTB text files."""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import collections
import os
import tensorflow as tf
def _read_words(filename):
with tf.gfile.GFile(filename, "r") as f:
return f.read().decode("utf-8").replace("\n", "<eos>").split()
def _build_vocab(filename):
data = _read_words(filename)
counter = collections.Counter(data)
count_pairs = sorted(counter.items(), key=lambda x: (-x[1], x[0]))
words, _ = list(zip(*count_pairs))
word_to_id = dict(zip(words, range(len(words))))
return word_to_id
def _file_to_word_ids(filename, word_to_id):
data = _read_words(filename)
return [word_to_id[word] for word in data if word in word_to_id]
def ptb_raw_data(data_path=None):
"""Load PTB raw data from data directory "data_path".
Reads PTB text files, converts strings to integer ids,
and performs mini-batching of the inputs.
The PTB dataset comes from Tomas Mikolov's webpage:
http://www.fit.vutbr.cz/~imikolov/rnnlm/simple-examples.tgz
Args:
data_path: string path to the directory where simple-examples.tgz has
been extracted.
Returns:
tuple (train_data, valid_data, test_data, vocabulary)
where each of the data objects can be passed to PTBIterator.
"""
train_path = os.path.join(data_path, "ptb.train.txt")
valid_path = os.path.join(data_path, "ptb.valid.txt")
test_path = os.path.join(data_path, "ptb.test.txt")
word_to_id = _build_vocab(train_path)
train_data = _file_to_word_ids(train_path, word_to_id)
valid_data = _file_to_word_ids(valid_path, word_to_id)
test_data = _file_to_word_ids(test_path, word_to_id)
vocabulary = len(word_to_id)
return train_data, valid_data, test_data, vocabulary
def ptb_producer(raw_data, batch_size, num_steps, name=None):
"""Iterate on the raw PTB data.
This chunks up raw_data into batches of examples and returns Tensors that
are drawn from these batches.
Args:
raw_data: one of the raw data outputs from ptb_raw_data.
batch_size: int, the batch size.
num_steps: int, the number of unrolls.
name: the name of this operation (optional).
Returns:
A pair of Tensors, each shaped [batch_size, num_steps]. The second element
of the tuple is the same data time-shifted to the right by one.
Raises:
tf.errors.InvalidArgumentError: if batch_size or num_steps are too high.
"""
with tf.name_scope(name, "PTBProducer", [raw_data, batch_size, num_steps]):
raw_data = tf.convert_to_tensor(raw_data, name="raw_data", dtype=tf.int32)
data_len = tf.size(raw_data)
batch_len = data_len // batch_size
data = tf.reshape(raw_data[0 : batch_size * batch_len],
[batch_size, batch_len])
epoch_size = (batch_len - 1) // num_steps
assertion = tf.assert_positive(
epoch_size,
message="epoch_size == 0, decrease batch_size or num_steps")
with tf.control_dependencies([assertion]):
epoch_size = tf.identity(epoch_size, name="epoch_size")
i = tf.train.range_input_producer(epoch_size, shuffle=False).dequeue()
x = tf.slice(data, [0, i * num_steps], [batch_size, num_steps])
y = tf.slice(data, [0, i * num_steps + 1], [batch_size, num_steps])
return x, y
|
apache-2.0
|
[
3,
1898,
6900,
710,
9134,
6642,
14,
2900,
5924,
5702,
14,
199,
3,
199,
3,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
199,
3,
1265,
1443,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
199,
3,
2047,
1443,
3332,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
258,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
199,
3,
2428,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
199,
3,
1666,
314,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
199,
3,
4204,
1334,
314,
844,
14,
199,
3,
11148,
421,
199,
624,
22905,
367,
6057,
510,
20098,
1318,
1584,
1041,
199,
504,
636,
2443,
363,
492,
3679,
63,
646,
199,
504,
636,
2443,
363,
492,
4629,
199,
504,
636,
2443,
363,
492,
870,
63,
1593,
199,
199,
646,
5055,
199,
646,
747,
199,
199,
646,
3228,
465,
2833,
421,
199,
318,
485,
739,
63,
3148,
8,
1501,
304,
523,
543,
2833,
14,
30325,
14,
39,
1173,
8,
1501,
12,
298,
82,
531,
465,
289,
26,
272,
372,
289,
14,
739,
1252,
2708,
480,
1624,
13,
24,
3471,
1814,
4582,
78,
401,
3886,
24909,
30,
3471,
1294,
342,
421,
199,
318,
485,
1506,
63,
9953,
8,
1501,
304,
523,
666,
275,
485,
739,
63,
3148,
8,
1501,
9,
819,
7055,
275,
5055,
14,
11348,
8,
576,
9,
523,
2338,
63,
7322,
275,
3355,
8,
5337,
14,
1744,
1062,
790,
29,
2734,
671,
26,
5868,
88,
59,
17,
467,
671,
59,
16,
2459,
819,
5932,
12,
485,
275,
769,
8,
3065,
2031,
835,
63,
7322,
430,
523,
4349,
63,
475,
63,
344,
275,
1211,
8,
3065,
8,
3148,
12,
1425,
8,
552,
8,
3148,
7845,
819,
372,
4349,
63,
475,
63,
344,
421,
199,
318,
485,
493,
63,
475,
63,
1027,
63,
1580,
8,
1501,
12,
4349,
63,
475,
63,
344,
304,
523,
666,
275,
485,
739,
63,
3148,
8,
1501,
9,
523,
372,
359,
1027,
63,
475,
63,
344,
59,
1027,
61,
367,
4349,
315,
666,
340,
4349,
315,
4349,
63,
475,
63,
344,
61,
421,
199,
318,
299,
5842,
63,
1773,
63,
576,
8,
576,
63,
515,
29,
403,
304,
523,
408,
6200,
510,
20098,
3066,
666,
687,
666,
2082,
298,
576,
63,
515,
1674,
819,
26129,
510,
20098,
1318,
1584,
12,
15373,
3326,
370,
3000,
2762,
12,
523,
436,
18628,
20536,
13,
2912,
316,
402,
314,
4153,
14,
819,
710,
510,
20098,
4789,
12477,
687,
21644,
305,
603,
16625,
32555,
1159,
9248,
26,
819,
1455,
921,
1544,
14,
3269,
14,
86,
337,
3289,
14,
16823,
22500,
1017,
16625,
32555,
15,
12845,
14344,
15,
4129,
13,
8589,
14,
27220,
819,
3033,
26,
272,
666,
63,
515,
26,
1059,
931,
370,
314,
2082,
2382,
3486,
13,
8589,
14,
27220,
965,
489,
2757,
12509,
14,
819,
1803,
26,
272,
2008,
334,
2834,
63,
576,
12,
1686,
63,
576,
12,
511,
63,
576,
12,
17515,
9,
272,
2382,
1924,
402,
314,
666,
2251,
883,
506,
3032,
370,
510,
20098,
3585,
14,
523,
408,
819,
3560,
63,
515,
275,
747,
14,
515,
14,
904,
8,
576,
63,
515,
12,
298,
541,
66,
14,
2834,
14,
2424,
531,
523,
1686,
63,
515,
275,
747,
14,
515,
14,
904,
8,
576,
63,
515,
12,
298,
541,
66,
14,
1078,
14,
2424,
531,
523,
511,
63,
515,
275,
747,
14,
515,
14,
904,
8,
576,
63,
515,
12,
298,
541,
66,
14,
396,
14,
2424,
531,
819,
4349,
63,
475,
63,
344,
275,
485,
1506,
63,
9953,
8,
2834,
63,
515,
9,
523,
3560,
63,
576,
275,
485,
493,
63,
475,
63,
1027,
63,
1580,
8,
2834,
63,
515,
12,
4349,
63,
475,
63,
344,
9,
523,
1686,
63,
576,
275,
485,
493,
63,
475,
63,
1027,
63,
1580,
8,
1078,
63,
515,
12,
4349,
63,
475,
63,
344,
9,
523,
511,
63,
576,
275,
485,
493,
63,
475,
63,
1027,
63,
1580,
8,
396,
63,
515,
12,
4349,
63,
475,
63,
344,
9,
523,
17515,
275,
822,
8,
1027,
63,
475,
63,
344,
9,
523,
372,
3560,
63,
576,
12,
1686,
63,
576,
12,
511,
63,
576,
12,
17515,
421,
199,
318,
299,
5842,
63,
16376,
8,
1773,
63,
576,
12,
3522,
63,
890,
12,
1967,
63,
5895,
12,
536,
29,
403,
304,
523,
408,
3315,
323,
641,
314,
3066,
510,
20098,
666,
14,
819,
961,
8291,
1536,
3066,
63,
576,
1901,
19593,
402,
7251,
436,
2529,
28373,
626,
523,
787,
19341,
687,
3520,
19593,
14,
819,
3033,
26,
272,
3066,
63,
576,
26,
1373,
402,
314,
3066,
666,
4704,
687,
299,
5842,
63,
1773,
63,
576,
14,
272,
3522,
63,
890,
26,
1109,
12,
314,
3522,
1568,
14,
272,
1967,
63,
5895,
26,
1109,
12,
314,
1329,
402,
625,
8459,
478,
14,
272,
536,
26,
314,
536,
402,
642,
3439,
334,
4144,
680,
819,
1803,
26,
272,
437,
4092,
402,
28373,
12,
1924,
2215,
68,
359,
2912,
63,
890,
12,
1967,
63,
5895,
1055,
710,
3499,
1819,
272,
402,
314,
2008,
365,
314,
2011,
666,
900,
13,
26063,
471,
370,
314,
2451,
701,
1373,
14,
819,
6218,
26,
272,
2833,
14,
2550,
14,
32116,
26,
340,
3522,
63,
890,
503,
1967,
63,
5895,
787,
4634,
4721,
14,
523,
408,
523,
543,
2833,
14,
354,
63,
2645,
8,
354,
12,
298,
4189,
34,
15532,
401,
359,
1773,
63,
576,
12,
3522,
63,
890,
12,
1967,
63,
5895,
4682,
272,
3066,
63,
576,
275,
2833,
14,
3916,
63,
475,
63,
3128,
8,
1773,
63,
576,
12,
536,
628,
1773,
63,
576,
401,
2152,
29,
3249,
14,
442,
708,
9,
339,
666,
63,
552,
275,
2833,
14,
890,
8,
1773,
63,
576,
9,
272,
3522,
63,
552,
275,
666,
63,
552,
5001,
3522,
63,
890,
272,
666,
275,
2833,
14,
5217,
8,
1773,
63,
576,
59,
16,
520,
3522,
63,
890,
627,
3522,
63,
552,
467,
1993,
359,
2912,
63,
890,
12,
3522,
63,
552,
566
] |
[
1898,
6900,
710,
9134,
6642,
14,
2900,
5924,
5702,
14,
199,
3,
199,
3,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
199,
3,
1265,
1443,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
199,
3,
2047,
1443,
3332,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
258,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
199,
3,
2428,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
199,
3,
1666,
314,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
199,
3,
4204,
1334,
314,
844,
14,
199,
3,
11148,
421,
199,
624,
22905,
367,
6057,
510,
20098,
1318,
1584,
1041,
199,
504,
636,
2443,
363,
492,
3679,
63,
646,
199,
504,
636,
2443,
363,
492,
4629,
199,
504,
636,
2443,
363,
492,
870,
63,
1593,
199,
199,
646,
5055,
199,
646,
747,
199,
199,
646,
3228,
465,
2833,
421,
199,
318,
485,
739,
63,
3148,
8,
1501,
304,
523,
543,
2833,
14,
30325,
14,
39,
1173,
8,
1501,
12,
298,
82,
531,
465,
289,
26,
272,
372,
289,
14,
739,
1252,
2708,
480,
1624,
13,
24,
3471,
1814,
4582,
78,
401,
3886,
24909,
30,
3471,
1294,
342,
421,
199,
318,
485,
1506,
63,
9953,
8,
1501,
304,
523,
666,
275,
485,
739,
63,
3148,
8,
1501,
9,
819,
7055,
275,
5055,
14,
11348,
8,
576,
9,
523,
2338,
63,
7322,
275,
3355,
8,
5337,
14,
1744,
1062,
790,
29,
2734,
671,
26,
5868,
88,
59,
17,
467,
671,
59,
16,
2459,
819,
5932,
12,
485,
275,
769,
8,
3065,
2031,
835,
63,
7322,
430,
523,
4349,
63,
475,
63,
344,
275,
1211,
8,
3065,
8,
3148,
12,
1425,
8,
552,
8,
3148,
7845,
819,
372,
4349,
63,
475,
63,
344,
421,
199,
318,
485,
493,
63,
475,
63,
1027,
63,
1580,
8,
1501,
12,
4349,
63,
475,
63,
344,
304,
523,
666,
275,
485,
739,
63,
3148,
8,
1501,
9,
523,
372,
359,
1027,
63,
475,
63,
344,
59,
1027,
61,
367,
4349,
315,
666,
340,
4349,
315,
4349,
63,
475,
63,
344,
61,
421,
199,
318,
299,
5842,
63,
1773,
63,
576,
8,
576,
63,
515,
29,
403,
304,
523,
408,
6200,
510,
20098,
3066,
666,
687,
666,
2082,
298,
576,
63,
515,
1674,
819,
26129,
510,
20098,
1318,
1584,
12,
15373,
3326,
370,
3000,
2762,
12,
523,
436,
18628,
20536,
13,
2912,
316,
402,
314,
4153,
14,
819,
710,
510,
20098,
4789,
12477,
687,
21644,
305,
603,
16625,
32555,
1159,
9248,
26,
819,
1455,
921,
1544,
14,
3269,
14,
86,
337,
3289,
14,
16823,
22500,
1017,
16625,
32555,
15,
12845,
14344,
15,
4129,
13,
8589,
14,
27220,
819,
3033,
26,
272,
666,
63,
515,
26,
1059,
931,
370,
314,
2082,
2382,
3486,
13,
8589,
14,
27220,
965,
489,
2757,
12509,
14,
819,
1803,
26,
272,
2008,
334,
2834,
63,
576,
12,
1686,
63,
576,
12,
511,
63,
576,
12,
17515,
9,
272,
2382,
1924,
402,
314,
666,
2251,
883,
506,
3032,
370,
510,
20098,
3585,
14,
523,
408,
819,
3560,
63,
515,
275,
747,
14,
515,
14,
904,
8,
576,
63,
515,
12,
298,
541,
66,
14,
2834,
14,
2424,
531,
523,
1686,
63,
515,
275,
747,
14,
515,
14,
904,
8,
576,
63,
515,
12,
298,
541,
66,
14,
1078,
14,
2424,
531,
523,
511,
63,
515,
275,
747,
14,
515,
14,
904,
8,
576,
63,
515,
12,
298,
541,
66,
14,
396,
14,
2424,
531,
819,
4349,
63,
475,
63,
344,
275,
485,
1506,
63,
9953,
8,
2834,
63,
515,
9,
523,
3560,
63,
576,
275,
485,
493,
63,
475,
63,
1027,
63,
1580,
8,
2834,
63,
515,
12,
4349,
63,
475,
63,
344,
9,
523,
1686,
63,
576,
275,
485,
493,
63,
475,
63,
1027,
63,
1580,
8,
1078,
63,
515,
12,
4349,
63,
475,
63,
344,
9,
523,
511,
63,
576,
275,
485,
493,
63,
475,
63,
1027,
63,
1580,
8,
396,
63,
515,
12,
4349,
63,
475,
63,
344,
9,
523,
17515,
275,
822,
8,
1027,
63,
475,
63,
344,
9,
523,
372,
3560,
63,
576,
12,
1686,
63,
576,
12,
511,
63,
576,
12,
17515,
421,
199,
318,
299,
5842,
63,
16376,
8,
1773,
63,
576,
12,
3522,
63,
890,
12,
1967,
63,
5895,
12,
536,
29,
403,
304,
523,
408,
3315,
323,
641,
314,
3066,
510,
20098,
666,
14,
819,
961,
8291,
1536,
3066,
63,
576,
1901,
19593,
402,
7251,
436,
2529,
28373,
626,
523,
787,
19341,
687,
3520,
19593,
14,
819,
3033,
26,
272,
3066,
63,
576,
26,
1373,
402,
314,
3066,
666,
4704,
687,
299,
5842,
63,
1773,
63,
576,
14,
272,
3522,
63,
890,
26,
1109,
12,
314,
3522,
1568,
14,
272,
1967,
63,
5895,
26,
1109,
12,
314,
1329,
402,
625,
8459,
478,
14,
272,
536,
26,
314,
536,
402,
642,
3439,
334,
4144,
680,
819,
1803,
26,
272,
437,
4092,
402,
28373,
12,
1924,
2215,
68,
359,
2912,
63,
890,
12,
1967,
63,
5895,
1055,
710,
3499,
1819,
272,
402,
314,
2008,
365,
314,
2011,
666,
900,
13,
26063,
471,
370,
314,
2451,
701,
1373,
14,
819,
6218,
26,
272,
2833,
14,
2550,
14,
32116,
26,
340,
3522,
63,
890,
503,
1967,
63,
5895,
787,
4634,
4721,
14,
523,
408,
523,
543,
2833,
14,
354,
63,
2645,
8,
354,
12,
298,
4189,
34,
15532,
401,
359,
1773,
63,
576,
12,
3522,
63,
890,
12,
1967,
63,
5895,
4682,
272,
3066,
63,
576,
275,
2833,
14,
3916,
63,
475,
63,
3128,
8,
1773,
63,
576,
12,
536,
628,
1773,
63,
576,
401,
2152,
29,
3249,
14,
442,
708,
9,
339,
666,
63,
552,
275,
2833,
14,
890,
8,
1773,
63,
576,
9,
272,
3522,
63,
552,
275,
666,
63,
552,
5001,
3522,
63,
890,
272,
666,
275,
2833,
14,
5217,
8,
1773,
63,
576,
59,
16,
520,
3522,
63,
890,
627,
3522,
63,
552,
467,
1993,
359,
2912,
63,
890,
12,
3522,
63,
552,
566,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
vorasagar7/sp17-i524
|
project/S17-IR-P001/code/ansible/ansible-node/files/visualization/FinalScript.py
|
4
|
15339
|
#Import the necessary methods from tweepy library
from tweepy.streaming import StreamListener
from tweepy import OAuthHandler
from tweepy import Stream
import json
import pandas as pd
from textblob import TextBlob
from time import strptime
import numpy as np
import re
import time
import zipcode
import sys, errno
from nltk.corpus import stopwords
from itertools import combinations
from collections import Counter
import matplotlib.pyplot as plt
from wordcloud import WordCloud
import nltk
nltk.download('stopwords')
runCount=0
#Variables that contains the user credentials to access Twitter API
access_token = ""
access_token_secret = ""
consumer_key = ""
consumer_secret = ""
tweets_data = []
stop = stopwords.words('english') + ['and']
emoticons_str = r"""
(?:
[:=;] # Eyes
[oO\-]? # Nose (optional)
[D\)\]\(\]/\\OpP] # Mouth
)"""
regex_str = [
emoticons_str,
r'<[^>]+>', # HTML tags
r'(?:@[\w_]+)', # @-mentions
r"(?:\#+[\w_]+[\w\'_\-]*[\w_]+)", # hash-tags
r'http[s]?://(?:[a-z]|[0-9]|[$-_@.&+]|[!*\(\),]|(?:%[0-9a-f][0-9a-f]))+', # URLs
r'(?:(?:\d+,?)+(?:\.?\d+)?)', # numbers
r"(?:[a-z][a-z'\-_]+[a-z])", # words with - and '
r'(?:[\w_]+)', # other words
r'(?:\S)' # anything else
]
tokens_re = re.compile(r'('+'|'.join(regex_str)+')', re.VERBOSE | re.IGNORECASE)
emoticon_re = re.compile(r'^'+emoticons_str+'$', re.VERBOSE | re.IGNORECASE)
Count=0
stop = stopwords.words('english')
def create_dataframe(tweets_data):
tweets = pd.DataFrame(index=range(len(tweets_data)),
columns=['text','created_at','location','state','sentiment','sentiment_cat','country_code','hour'])
for i in range(len(tweets_data)):
try:
tweets['text'][i] = tweets_data[i]['text']
except:
tweets['text'][i] = ""
try:
tweets['location'][i]=tweets_data[i]['user']['location']
except:
tweets['location'][i]='NA'
try:
tweets['country_code'][i]=tweets_data[i]['place']['country_code']
except:
tweets['country_code'][i]=''
try:
lon=tweets_data[i]['place']['bounding_box']['coordinates'][0][0][0]
except:
lon='NA'
try:
lat=tweets_data[i]['place']['bounding_box']['coordinates'][0][0][1]
except:
lat='NA'
#print (lat,lon)
try:
tweets['created_at'][i]=tweets_data[i]['created_at']
except:
tweets['created_at'][i]='NA'
try:
tweets['hour'][i]=tweets['created_at'][i][11:13]
except:
tweets['hour'][i]='NA'
try:
stateFromData=tweets['location'][i].split(',')[1]
except:
stateFromData=''
if len(stateFromData)==2:
tweets['state'][i]=stateFromData
else:
if lat!='NA':
radius=10
incre=10
zips=zipcode.isinradius((lat,lon),radius)
while len(zips)==0:
radius=radius+incre
zips=zipcode.isinradius((lat,lon),radius)
incre=incre+10
myzip = zipcode.isequal(str(zips[0].zip))
tweets['state'][i]=myzip.state
else:
tweets['state'][i]='NA'
blob = TextBlob(tweets['text'][i])
try:
sentence=blob.sentences[0]
tweets['sentiment'][i]=float(sentence.sentiment.polarity)
except:
tweets['sentiment'][i]=0
if tweets['sentiment'][i] < 0:
tweets['sentiment_cat'][i] = 'Neg'
else:
if tweets['sentiment'][i] > 0:
tweets['sentiment_cat'][i] = 'Pos'
else:
tweets['sentiment_cat'][i] = 'Neu'
print (tweets.head())
return tweets
def state_senti(newFolder,usStateSentiOld,tweetsFinal):
output2=pd.DataFrame({'value' : tweetsFinal.groupby( [ "State","sentiment_cat"] ).size()}).reset_index()
outData=pd.pivot_table(output2,values='value', index=['State'], columns=['sentiment_cat'], aggfunc=np.sum)
outData=outData.fillna(0)
outData['State']=outData.index
#outData.reset_index()
print (outData.columns.values)
outData = pd.merge(usStateSentiOld, outData, how='left', left_on='State', right_on = 'State')
outData=outData.fillna(0)
outData['Pos']=outData['Pos_x']+outData['Pos_y']
del outData['Pos_x']
del outData['Pos_y']
outData['Neg']=outData['Neg_x']+outData['Neg_y']
del outData['Neg_x']
del outData['Neg_y']
outData['Neu']=outData['Neu_x']+outData['Neu_y']
del outData['Neu_x']
del outData['Neu_y']
outData.to_csv(newFolder+"usStates-SentiCount.csv",index=False)
#-------------------------------------------
try:
outData['sum']=outData[['Neg', 'Neu', 'Pos']].sum(axis=1)
outData['max']=outData['maxFinal']=outData[['Neg', 'Neu', 'Pos']].idxmax(axis=1)
except:
outData['sum']=outData[['Neu', 'Pos']].sum(axis=1)
outData['max']=outData['maxFinal']=outData[[ 'Neu', 'Pos']].idxmax(axis=1)
#-------------------------------------------
for i in range(len(outData)):
if outData['max'][i] =="Pos":
outData['maxFinal'][i] = '1'
else:
if outData['max'][i] =="Neu":
outData['maxFinal'][i] = '-1'
else:
outData['maxFinal'][i] = '2'
del outData['max']
d="var data =[\n"
for i in range(len(outData)):
row=outData.ix[i]
#print (row)
d += "[\'"+row['State']+"\',"+",".join([str(i) for i in row[:5]])+"],\n"
return d+']'
def create_timechart(newFolder,oldtimedata,tweets):
td1 = pd.DataFrame({'value' : tweets.groupby( [ "created_at"] ).size()}).reset_index()
td1['created_at'] = td1['created_at'].astype('str')
mask = (td1['created_at'].str.len() > 2)
td1=td1.loc[mask]
timedata = td1[td1.created_at != 'NA']
timedata=oldtimedata.append(timedata, ignore_index=True)
timedata.to_csv(newFolder+"timeseries.csv",index=False)
data1 ={}
data = ["var data=["]
for i in range(0,len(timedata)):
year = timedata['created_at'][i][-4:]
if (timedata['created_at'][i][4:7] == 'Jan'):
mon = '1'
else:
if (timedata['created_at'][i][4:7] == 'Feb'):
mon = '2'
else:
if (timedata['created_at'][i][4:7] == 'Mar'):
mon = '3'
else:
if (timedata['created_at'][i][4:7] == 'Apr'):
mon = '4'
else:
if (timedata['created_at'][i][4:7] == 'May'):
mon = '5'
else:
if (timedata['created_at'][i][4:7] == 'Jun'):
mon = '6'
else:
if (timedata['created_at'][i][4:7] == 'Jul'):
mon = '7'
else:
if (timedata['created_at'][i][4:7] == 'Aug'):
mon = '8'
else:
if (timedata['created_at'][i][4:7] == 'Sep'):
mon = '9'
else:
if (timedata['created_at'][i][4:7] == 'Oct'):
mon = '10'
else:
if (timedata['created_at'][i][4:7] == 'Nov'):
mon = '11'
else:
mon = '12'
date = timedata['created_at'][i][7:10]
hour = timedata['created_at'][i][10:13]
minu = timedata['created_at'][i][14:16]
sec = timedata['created_at'][i][17:20]
value = timedata['value'][i]
data1 = ("[Date.UTC("+str(year)+","+str(mon)+","+str(date)+","+str(hour)+","+str(minu)+","+str(sec)+"),"+str(value)+"]")
if (len(timedata)):
data.append
data.append(data1)
data = ",\n".join(data)+"\n]"
data = data.replace("[,","[")
return data
def tokenize(s):
tokens=tokens_re.findall(s)
return [ x for x in tokens if 'http' not in x and len(x)>1 and x.lower() not in stop]
def preprocess(s, lowercase=True):
tokens = tokenize(s)
if lowercase:
tokens = [token if emoticon_re.search(token) else token.lower() for token in tokens]
return tokens
def collect_pairs(lines):
pair_counter = Counter()
for line in lines:
unique_tokens = sorted(set(line)) # exclude duplicates in same line and sort to ensure one word is always before other
combos = combinations(unique_tokens, 2)
pair_counter += Counter(combos)
return pair_counter
#Co-occurrence:
def co_occur(tweets):
t2 = []
t1 =tweets['text']
for t in range(len(t1)):
t2.append(preprocess(t1[t]))
pairs = collect_pairs(t2)
top_pairs = pairs.most_common(200)
nodes={}
links=["\"links\":["]
count =0
len_top=len(top_pairs)
nptp = np.array(top_pairs)
maxtp = np.max(nptp[:,1])
for p in range(len(top_pairs)):
for i in range(2):
if top_pairs[p][0][i] not in nodes:
nodes[top_pairs[p][0][i]] = count
count+=1
link="{ \"source\":"+str(nodes[top_pairs[p][0][0]])+",\"target\":"+str(nodes[top_pairs[p][0][1]])+",\"value\":"+str(round(top_pairs[p][1]*10/maxtp))+"}"
links.append(link)
links=",\n".join(links)+"\n]"
links=links.replace("[,","[")
nodes = sorted(nodes.items(), key=lambda x: x[1])
nodes1=["\"nodes\":["]
for p in range(len(nodes)):
nodes1.append("{ \"name\":\""+nodes[p][0]+"\",\"group\":"+"0}")
nodes1=",\n".join(nodes1)+"\n]"
nodes1=nodes1.replace("[,","[")
return nodes1,links
def heatworldgrid(newFolder,worldOld,tweets):
contdata=pd.read_csv("continents.txt")
contdat=contdata.fillna("NA")
tweets['sentiment']=tweets['sentiment'].apply(pd.to_numeric)
#print (tweets.dtypes)
Countryhour=pd.DataFrame({'sentiment' : tweets.groupby( ["country_code","hour"] )['sentiment'].mean()}).reset_index()
final=pd.merge(Countryhour, contdata, how='left',left_on="country_code",right_on="country")
print (final.columns.values)
del final['country']
#del final['Unnamed: 0']
del final['country_code']
Conthour=pd.DataFrame({'sentiment' : final.groupby( ["continent","hour"] )['sentiment'].mean()}).reset_index()
Conthour = pd.merge(worldOld, Conthour, how='left', left_on=["continent","hour"] , right_on = ["continent","hour"] )
Conthour=Conthour.fillna(0)
Conthour['sentiment']=(Conthour['sentiment_x']*1000000+Conthour['sentiment_y']*10000)/(1010000)
del Conthour['sentiment_x']
del Conthour['sentiment_y']
Conthour.to_csv(newFolder+"Continent-hour-senti.csv",index=False)
minVal=min(Conthour['sentiment'])
maxVal=max(Conthour['sentiment'])
outputStr=""
uniqueCont= list(np.unique(Conthour['continent']))
outputStr+="var continent =["+",".join(["'"+i+"'" for i in uniqueCont])+"];\n"
numCont=len(uniqueCont)
numHour=24
outputStr+="var hour =["+",".join(["'"+str(i)+"'" for i in range(numHour)])+"];\n"
outMatrix=np.zeros(shape=(numCont,numHour))
outputStr+="var data=["
datastr=[]
for i in range(len(Conthour)):
continent=Conthour['continent'][i]
hour=Conthour['hour'][i]
contIndex=uniqueCont.index(continent)
outMatrix[contIndex][int(hour)]=Conthour['sentiment'][i]
for i in range(numCont):
for j in range(numHour):
datastr.append("["+str(j)+","+str(i)+","+str(int(outMatrix[i][j]))+"]")
outputStr+=",".join(datastr)+"]; var minval = "+str(minVal)+";\n var maxval = "+str(maxVal)+";"
return outputStr
def createwordcloud(tweets):
# Read the whole text.
#text = open(path.join(d, 'constitution.txt')).read()
textpos = tweets[tweets.sentiment_cat == 'Pos']
textneg = tweets[tweets.sentiment_cat == 'Neg']
postweets=""
for i in textpos.index.values:
postweets+=textpos['text'][i]+" "
negtweets=""
for i in textneg.index.values:
negtweets+=textneg['text'][i]+" "
textp = preprocess(postweets)
textp=" ".join(textp)
textn = preprocess(negtweets)
textn=" ".join(textn)
wordcloudp = WordCloud( stopwords=stop,background_color='white',width=1200,height=1000).generate(textp)
wordcloudn = WordCloud( stopwords=stop,background_color='white', width=1200,height=1000).generate(textn)
image1 = wordcloudp.to_image()
image2= wordcloudn.to_image()
image1.save("wordcloup.png")
image2.save("wordcloudn.png")
def analyze(tweets_data):
oldFolder="Data\\"
outputFolder="OutputJS\\"
newFolder="NewData\\"
#Dataframe is created from the list of json tweets, sentiment is also calculated
tweets=create_dataframe(tweets_data)
statedata=pd.read_csv(oldFolder+"states.csv")
tweetsFinal=pd.merge(tweets, statedata, how='left',left_on="state",right_on="Abbreviation")
#UsStatewise Tweets
usStateOld=pd.read_csv(oldFolder+"usStatesCount.csv")
usState=pd.DataFrame({'value' : tweetsFinal.groupby( [ "State"] ).size()}).reset_index()
usState_new = pd.merge(usStateOld, usState, how='left', left_on='State', right_on = 'State')
usState_new=usState_new.fillna(0)
usState_new['value']=usState_new['value_x']+usState_new['value_y']
del usState_new['value_x']
del usState_new['value_y']
usState_new.to_csv(newFolder+"usStatesCount.csv",index=False)
print (usState_new.head())
usStateJson=usState_new.to_json(orient = "records")
usStateJsonfinalOutput=usStateJson[33:len(usStateJson)-1].upper().replace("\"STATE\"","ucName").replace("\"VALUE\"","value")
with open('Final\\US_heat_count\\data.js', 'w') as outfile:
outfile.write(usStateJsonfinalOutput)
#UsStatewise Sentiment
usStateSentiOld=pd.read_csv(oldFolder+"usStates-SentiCount.csv")
statesentiout=state_senti(newFolder,usStateSentiOld,tweetsFinal)
with open('Final\\map-pies\\data.js', 'w') as outfile:
outfile.write(statesentiout)
#TimeSeries Chart
timeOld=pd.read_csv(oldFolder+"timeseries.csv")
timedata=create_timechart(newFolder,timeOld,tweets)
with open('Final\\dynamic-master-detail\\time_series.js', 'w') as outfile:
outfile.write(timedata)
#Co-occur Chart
nodes1,links=co_occur(tweets)
with open(outputFolder+'cooccur_word-1.json', 'w') as outfile:
outfile.write("{\n"+nodes1+",\n"+links+"}\n")
#Heat World Grid
worldOld=pd.read_csv(oldFolder+"Continent-hour-senti.csv")
heatjson=heatworldgrid(newFolder,worldOld,tweets)
with open('Final\\heatmap\\heatchart_data-1.js', 'w') as outfile:
outfile.write(heatjson)
#WordCloud
createwordcloud(tweets)
#This is a basic listener that just prints received tweets to stdout.
class StdOutListener(StreamListener):
def on_data(self, data):
global Count,tweets_data
Count+=1
#TweetCount+=1
if Count%1000==0:
print ("Analyze data started")
x=time.time()
analyze(tweets_data)
print ("Analyze data Completed in ", time.time()-x)
sys.exit(errno.EACCES)
tweets_data=[]
Count=0
tweet = json.loads(data)
tweets_data.append(tweet)
return True
def on_error(self, status):
print (status)
if __name__ == '__main__':
#This handles Twitter authetification and the connection to Twitter Streaming API
l = StdOutListener()
auth = OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
stream = Stream(auth, l)
#This line filter Twitter Streams to capture data by the keywords: 'python', 'javascript', 'ruby'
stream.filter(languages=["en"],track=['a', 'e', 'i','o','u','#'])
|
apache-2.0
|
[
3,
6295,
314,
5784,
3102,
687,
8900,
1024,
647,
3555,
199,
504,
8900,
1024,
647,
14,
12076,
492,
8271,
10464,
199,
504,
8900,
1024,
647,
492,
11715,
2461,
199,
504,
8900,
1024,
647,
492,
8271,
199,
646,
2022,
199,
646,
10634,
465,
6454,
199,
504,
1318,
6582,
492,
4516,
16799,
199,
504,
900,
492,
620,
9367,
199,
646,
2680,
465,
980,
199,
646,
295,
199,
646,
900,
199,
646,
3482,
600,
199,
646,
984,
12,
7554,
199,
504,
24706,
14,
16780,
492,
3631,
3148,
199,
504,
7975,
492,
15821,
199,
504,
5055,
492,
14427,
199,
646,
8027,
14,
13563,
465,
4488,
199,
504,
4349,
4091,
492,
14644,
9089,
199,
646,
24706,
199,
7530,
2663,
14,
4249,
360,
2379,
3148,
358,
199,
199,
1065,
2353,
29,
16,
199,
3,
11458,
626,
3509,
314,
922,
6235,
370,
2879,
19259,
3261,
221,
199,
2732,
63,
1418,
275,
3087,
199,
2732,
63,
1418,
63,
4731,
275,
3087,
199,
8542,
63,
498,
275,
3087,
199,
8542,
63,
4731,
275,
3087,
199,
199,
84,
18588,
63,
576,
275,
942,
199,
199,
2379,
275,
3631,
3148,
14,
3148,
360,
17872,
358,
435,
788,
460,
418,
199,
69,
573,
280,
8704,
63,
495,
275,
519,
624,
199,
198,
5169,
507,
198,
1491,
29,
27,
61,
327,
662,
5066,
507,
198,
59,
79,
47,
16185,
11843,
327,
3091,
261,
334,
4144,
9,
507,
198,
59,
36,
13670,
7272,
2961,
12978,
1103,
4619,
48,
61,
327,
3930,
762,
199,
198,
9471,
523,
199,
3821,
63,
495,
275,
359,
199,
198,
69,
573,
280,
8704,
63,
495,
12,
199,
198,
82,
7601,
25524,
4206,
327,
4163,
3762,
199,
198,
82,
20459,
32,
7023,
87,
22155,
3196,
327,
768,
13,
1410,
852,
199,
198,
82,
2,
15840,
3,
11,
7023,
87,
22155,
7023,
87,
3985,
63,
16185,
3672,
7023,
87,
22155,
4186,
327,
2631,
13,
2969,
199,
198,
82,
7,
1014,
59,
83,
11843,
921,
25060,
65,
13,
90,
32673,
16,
13,
25,
32673,
4,
13,
63,
32,
14,
6,
5282,
27,
11,
32673,
1,
7590,
2961,
395,
11752,
2229,
2689,
59,
16,
13,
25,
65,
13,
70,
1527,
16,
13,
25,
65,
13,
70,
2459,
7386,
327,
10867,
523,
199,
198,
82,
20459,
15840,
68,
28061,
31,
6393,
15840,
14,
8995,
68,
19544,
3196,
327,
5579,
199,
198,
82,
2,
25060,
65,
13,
90,
1527,
65,
13,
90,
1154,
13,
22155,
59,
65,
13,
90,
566,
401,
327,
5932,
543,
446,
436,
283,
199,
198,
82,
20459,
7023,
87,
22155,
3196,
327,
1163,
5932,
199,
198,
82,
10120,
3427,
51,
3171,
327,
7003,
587,
199,
61,
507,
199,
4504,
63,
264,
275,
295,
14,
2014,
8,
82,
7,
360,
4786,
92,
1370,
904,
8,
3821,
63,
495,
6393,
358,
297,
295,
14,
16075,
1204,
295,
14,
15434,
9,
199,
69,
573,
280,
388,
63,
264,
275,
295,
14,
2014,
8,
82,
4289,
6828,
69,
573,
280,
8704,
63,
495,
4786,
4268,
295,
14,
16075,
1204,
295,
14,
15434,
9,
199,
2353,
29,
16,
199,
2379,
275,
3631,
3148,
14,
3148,
360,
17872,
358,
199,
199,
318,
1218,
63,
23878,
8,
84,
18588,
63,
576,
304,
199,
198,
84,
18588,
275,
6454,
14,
9205,
8,
1080,
29,
1842,
8,
552,
8,
84,
18588,
63,
576,
1826,
9948,
198,
3406,
2968,
505,
1673,
3966,
63,
292,
1673,
1985,
1673,
929,
1673,
2464,
280,
434,
1673,
2464,
280,
434,
63,
3385,
1673,
6063,
63,
600,
1673,
5180,
1105,
8299,
198,
509,
284,
315,
1425,
8,
552,
8,
84,
18588,
63,
576,
2298,
507,
198,
893,
26,
686,
198,
84,
18588,
459,
505,
3488,
73,
61,
275,
307,
18588,
63,
576,
59,
73,
2733,
505,
418,
507,
198,
2590,
26,
686,
198,
84,
18588,
459,
505,
3488,
73,
61,
275,
3087,
507,
198,
893,
26,
686,
198,
84,
18588,
459,
1985,
3488,
73,
10404,
84,
18588,
63,
576,
59,
73,
2733,
751,
2545,
1985,
418,
507,
198,
2590,
26,
686,
198,
84,
18588,
459,
1985,
3488,
73,
61,
534,
7170,
7,
507,
198,
893,
26,
686,
198,
84,
18588,
459,
6063,
63,
600,
3488,
73,
10404,
84,
18588,
63,
576,
59,
73,
2733,
2778,
2545,
6063,
63,
600,
418,
507,
198,
2590,
26,
686,
198,
84,
18588,
459,
6063,
63,
600,
3488,
73,
61,
19070,
507,
198,
893,
26,
686,
198,
5298,
29,
84,
18588,
63,
576,
59,
73,
2733,
2778,
2545,
24511,
63,
1977,
2545,
12924,
3488,
16,
1527,
16,
1527,
16,
61,
507,
198,
2590,
26,
686,
198,
5298,
534,
7170,
7,
507,
198,
893,
26,
686,
198,
4452,
29,
84,
18588,
63,
576,
59,
73,
2733,
2778,
2545,
24511,
63,
1977,
2545,
12924,
3488,
16,
1527,
16,
1527,
17,
61,
507,
198,
2590,
26,
686,
198,
4452,
534,
7170,
7,
507,
198,
3,
1361,
334,
4452,
12,
5298,
9,
507,
198,
893,
26,
686,
198,
84,
18588,
459,
3966,
63,
292,
3488,
73,
10404,
84,
18588,
63,
576,
59,
73,
2733,
3966,
63,
292,
418,
507,
198,
2590,
26,
686,
198,
84,
18588,
459,
3966,
63,
292,
3488,
73,
61,
534,
7170,
7,
507,
198,
893,
26,
686,
198,
84,
18588,
459,
5180,
3488,
73,
10404,
84,
18588,
459,
3966,
63,
292,
3488,
73,
1527,
845,
26,
969,
61,
507,
198,
2590,
26,
686,
198,
84,
18588,
459,
5180,
3488,
73,
61,
534,
7170,
7,
507,
198,
893,
26,
686,
198,
929,
2532,
1451,
29,
84,
18588,
459,
1985,
3488,
73,
1055,
1294,
5102,
5832,
17,
61,
507,
198,
2590,
26,
686,
198,
929,
2532,
1451,
19070,
507,
198,
692,
822,
8,
929,
2532,
1451,
12694,
18,
26,
686,
198,
84,
18588,
459,
929,
3488,
73,
10404,
929,
2532,
1451,
507,
198,
2836,
26,
686,
198,
692,
8396,
27909,
7170,
356,
1585,
198,
8017,
29,
709,
1585,
198,
262,
1353,
29,
709,
1585,
198,
3065,
83,
29,
3065,
600,
14,
25184,
8017,
1332,
4452,
12,
5298,
395,
8017,
9,
1585,
198,
6710,
822,
8,
3065,
83,
12694,
16,
26,
1871,
198,
8017,
29,
8017,
11,
262,
1353,
1871,
198,
3065,
83,
29,
3065,
600,
14,
25184,
8017,
1332,
4452,
12,
5298,
395,
8017,
9,
1871,
198,
262,
1353,
29,
262,
1353,
11,
709,
1585,
198,
1662,
3065,
275,
3482,
600,
14,
572,
537,
8,
495,
8
] |
[
6295,
314,
5784,
3102,
687,
8900,
1024,
647,
3555,
199,
504,
8900,
1024,
647,
14,
12076,
492,
8271,
10464,
199,
504,
8900,
1024,
647,
492,
11715,
2461,
199,
504,
8900,
1024,
647,
492,
8271,
199,
646,
2022,
199,
646,
10634,
465,
6454,
199,
504,
1318,
6582,
492,
4516,
16799,
199,
504,
900,
492,
620,
9367,
199,
646,
2680,
465,
980,
199,
646,
295,
199,
646,
900,
199,
646,
3482,
600,
199,
646,
984,
12,
7554,
199,
504,
24706,
14,
16780,
492,
3631,
3148,
199,
504,
7975,
492,
15821,
199,
504,
5055,
492,
14427,
199,
646,
8027,
14,
13563,
465,
4488,
199,
504,
4349,
4091,
492,
14644,
9089,
199,
646,
24706,
199,
7530,
2663,
14,
4249,
360,
2379,
3148,
358,
199,
199,
1065,
2353,
29,
16,
199,
3,
11458,
626,
3509,
314,
922,
6235,
370,
2879,
19259,
3261,
221,
199,
2732,
63,
1418,
275,
3087,
199,
2732,
63,
1418,
63,
4731,
275,
3087,
199,
8542,
63,
498,
275,
3087,
199,
8542,
63,
4731,
275,
3087,
199,
199,
84,
18588,
63,
576,
275,
942,
199,
199,
2379,
275,
3631,
3148,
14,
3148,
360,
17872,
358,
435,
788,
460,
418,
199,
69,
573,
280,
8704,
63,
495,
275,
519,
624,
199,
198,
5169,
507,
198,
1491,
29,
27,
61,
327,
662,
5066,
507,
198,
59,
79,
47,
16185,
11843,
327,
3091,
261,
334,
4144,
9,
507,
198,
59,
36,
13670,
7272,
2961,
12978,
1103,
4619,
48,
61,
327,
3930,
762,
199,
198,
9471,
523,
199,
3821,
63,
495,
275,
359,
199,
198,
69,
573,
280,
8704,
63,
495,
12,
199,
198,
82,
7601,
25524,
4206,
327,
4163,
3762,
199,
198,
82,
20459,
32,
7023,
87,
22155,
3196,
327,
768,
13,
1410,
852,
199,
198,
82,
2,
15840,
3,
11,
7023,
87,
22155,
7023,
87,
3985,
63,
16185,
3672,
7023,
87,
22155,
4186,
327,
2631,
13,
2969,
199,
198,
82,
7,
1014,
59,
83,
11843,
921,
25060,
65,
13,
90,
32673,
16,
13,
25,
32673,
4,
13,
63,
32,
14,
6,
5282,
27,
11,
32673,
1,
7590,
2961,
395,
11752,
2229,
2689,
59,
16,
13,
25,
65,
13,
70,
1527,
16,
13,
25,
65,
13,
70,
2459,
7386,
327,
10867,
523,
199,
198,
82,
20459,
15840,
68,
28061,
31,
6393,
15840,
14,
8995,
68,
19544,
3196,
327,
5579,
199,
198,
82,
2,
25060,
65,
13,
90,
1527,
65,
13,
90,
1154,
13,
22155,
59,
65,
13,
90,
566,
401,
327,
5932,
543,
446,
436,
283,
199,
198,
82,
20459,
7023,
87,
22155,
3196,
327,
1163,
5932,
199,
198,
82,
10120,
3427,
51,
3171,
327,
7003,
587,
199,
61,
507,
199,
4504,
63,
264,
275,
295,
14,
2014,
8,
82,
7,
360,
4786,
92,
1370,
904,
8,
3821,
63,
495,
6393,
358,
297,
295,
14,
16075,
1204,
295,
14,
15434,
9,
199,
69,
573,
280,
388,
63,
264,
275,
295,
14,
2014,
8,
82,
4289,
6828,
69,
573,
280,
8704,
63,
495,
4786,
4268,
295,
14,
16075,
1204,
295,
14,
15434,
9,
199,
2353,
29,
16,
199,
2379,
275,
3631,
3148,
14,
3148,
360,
17872,
358,
199,
199,
318,
1218,
63,
23878,
8,
84,
18588,
63,
576,
304,
199,
198,
84,
18588,
275,
6454,
14,
9205,
8,
1080,
29,
1842,
8,
552,
8,
84,
18588,
63,
576,
1826,
9948,
198,
3406,
2968,
505,
1673,
3966,
63,
292,
1673,
1985,
1673,
929,
1673,
2464,
280,
434,
1673,
2464,
280,
434,
63,
3385,
1673,
6063,
63,
600,
1673,
5180,
1105,
8299,
198,
509,
284,
315,
1425,
8,
552,
8,
84,
18588,
63,
576,
2298,
507,
198,
893,
26,
686,
198,
84,
18588,
459,
505,
3488,
73,
61,
275,
307,
18588,
63,
576,
59,
73,
2733,
505,
418,
507,
198,
2590,
26,
686,
198,
84,
18588,
459,
505,
3488,
73,
61,
275,
3087,
507,
198,
893,
26,
686,
198,
84,
18588,
459,
1985,
3488,
73,
10404,
84,
18588,
63,
576,
59,
73,
2733,
751,
2545,
1985,
418,
507,
198,
2590,
26,
686,
198,
84,
18588,
459,
1985,
3488,
73,
61,
534,
7170,
7,
507,
198,
893,
26,
686,
198,
84,
18588,
459,
6063,
63,
600,
3488,
73,
10404,
84,
18588,
63,
576,
59,
73,
2733,
2778,
2545,
6063,
63,
600,
418,
507,
198,
2590,
26,
686,
198,
84,
18588,
459,
6063,
63,
600,
3488,
73,
61,
19070,
507,
198,
893,
26,
686,
198,
5298,
29,
84,
18588,
63,
576,
59,
73,
2733,
2778,
2545,
24511,
63,
1977,
2545,
12924,
3488,
16,
1527,
16,
1527,
16,
61,
507,
198,
2590,
26,
686,
198,
5298,
534,
7170,
7,
507,
198,
893,
26,
686,
198,
4452,
29,
84,
18588,
63,
576,
59,
73,
2733,
2778,
2545,
24511,
63,
1977,
2545,
12924,
3488,
16,
1527,
16,
1527,
17,
61,
507,
198,
2590,
26,
686,
198,
4452,
534,
7170,
7,
507,
198,
3,
1361,
334,
4452,
12,
5298,
9,
507,
198,
893,
26,
686,
198,
84,
18588,
459,
3966,
63,
292,
3488,
73,
10404,
84,
18588,
63,
576,
59,
73,
2733,
3966,
63,
292,
418,
507,
198,
2590,
26,
686,
198,
84,
18588,
459,
3966,
63,
292,
3488,
73,
61,
534,
7170,
7,
507,
198,
893,
26,
686,
198,
84,
18588,
459,
5180,
3488,
73,
10404,
84,
18588,
459,
3966,
63,
292,
3488,
73,
1527,
845,
26,
969,
61,
507,
198,
2590,
26,
686,
198,
84,
18588,
459,
5180,
3488,
73,
61,
534,
7170,
7,
507,
198,
893,
26,
686,
198,
929,
2532,
1451,
29,
84,
18588,
459,
1985,
3488,
73,
1055,
1294,
5102,
5832,
17,
61,
507,
198,
2590,
26,
686,
198,
929,
2532,
1451,
19070,
507,
198,
692,
822,
8,
929,
2532,
1451,
12694,
18,
26,
686,
198,
84,
18588,
459,
929,
3488,
73,
10404,
929,
2532,
1451,
507,
198,
2836,
26,
686,
198,
692,
8396,
27909,
7170,
356,
1585,
198,
8017,
29,
709,
1585,
198,
262,
1353,
29,
709,
1585,
198,
3065,
83,
29,
3065,
600,
14,
25184,
8017,
1332,
4452,
12,
5298,
395,
8017,
9,
1585,
198,
6710,
822,
8,
3065,
83,
12694,
16,
26,
1871,
198,
8017,
29,
8017,
11,
262,
1353,
1871,
198,
3065,
83,
29,
3065,
600,
14,
25184,
8017,
1332,
4452,
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
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
nemami/synbioinformatica
|
markdown/inlinepatterns.py
|
107
|
12185
|
"""
INLINE PATTERNS
=============================================================================
Inline patterns such as *emphasis* are handled by means of auxiliary
objects, one per pattern. Pattern objects must be instances of classes
that extend markdown.Pattern. Each pattern object uses a single regular
expression and needs support the following methods:
pattern.getCompiledRegExp() # returns a regular expression
pattern.handleMatch(m) # takes a match object and returns
# an ElementTree element or just plain text
All of python markdown's built-in patterns subclass from Pattern,
but you can add additional patterns that don't.
Also note that all the regular expressions used by inline must
capture the whole block. For this reason, they all start with
'^(.*)' and end with '(.*)!'. In case with built-in expression
Pattern takes care of adding the "^(.*)" and "(.*)!".
Finally, the order in which regular expressions are applied is very
important - e.g. if we first replace http://.../ links with <a> tags
and _then_ try to replace inline html, we would end up with a mess.
So, we apply the expressions in the following order:
* escape and backticks have to go before everything else, so
that we can preempt any markdown patterns by escaping them.
* then we handle auto-links (must be done before inline html)
* then we handle inline HTML. At this point we will simply
replace all inline HTML strings with a placeholder and add
the actual HTML to a hash.
* then inline images (must be done before links)
* then bracketed links, first regular then reference-style
* finally we apply strong and emphasis
"""
import markdown
import re
from urlparse import urlparse, urlunparse
import sys
if sys.version >= "3.0":
from html import entities as htmlentitydefs
else:
import htmlentitydefs
"""
The actual regular expressions for patterns
-----------------------------------------------------------------------------
"""
NOBRACKET = r'[^\]\[]*'
BRK = ( r'\[('
+ (NOBRACKET + r'(\[')*6
+ (NOBRACKET+ r'\])*')*6
+ NOBRACKET + r')\]' )
NOIMG = r'(?<!\!)'
BACKTICK_RE = r'(?<!\\)(`+)(.+?)(?<!`)\2(?!`)' # `e=f()` or ``e=f("`")``
ESCAPE_RE = r'\\(.)' # \<
EMPHASIS_RE = r'(\*)([^\*]+)\2' # *emphasis*
STRONG_RE = r'(\*{2}|_{2})(.+?)\2' # **strong**
STRONG_EM_RE = r'(\*{3}|_{3})(.+?)\2' # ***strong***
if markdown.SMART_EMPHASIS:
EMPHASIS_2_RE = r'(?<!\w)(_)(\S.+?)\2(?!\w)' # _emphasis_
else:
EMPHASIS_2_RE = r'(_)(.+?)\2' # _emphasis_
LINK_RE = NOIMG + BRK + \
r'''\(\s*(<.*?>|((?:(?:\(.*?\))|[^\(\)]))*?)\s*((['"])(.*?)\12)?\)'''
# [text](url) or [text](<url>)
IMAGE_LINK_RE = r'\!' + BRK + r'\s*\((<.*?>|([^\)]*))\)'
#  or 
REFERENCE_RE = NOIMG + BRK+ r'\s*\[([^\]]*)\]' # [Google][3]
IMAGE_REFERENCE_RE = r'\!' + BRK + '\s*\[([^\]]*)\]' # ![alt text][2]
NOT_STRONG_RE = r'((^| )(\*|_)( |$))' # stand-alone * or _
AUTOLINK_RE = r'<((?:f|ht)tps?://[^>]*)>' # <http://www.123.com>
AUTOMAIL_RE = r'<([^> \!]*@[^> ]*)>' # <me@example.com>
HTML_RE = r'(\<([a-zA-Z/][^\>]*?|\!--.*?--)\>)' # <...>
ENTITY_RE = r'(&[\#a-zA-Z0-9]*;)' # &
LINE_BREAK_RE = r' \n' # two spaces at end of line
LINE_BREAK_2_RE = r' $' # two spaces at end of text
def dequote(string):
"""Remove quotes from around a string."""
if ( ( string.startswith('"') and string.endswith('"'))
or (string.startswith("'") and string.endswith("'")) ):
return string[1:-1]
else:
return string
ATTR_RE = re.compile("\{@([^\}]*)=([^\}]*)}") # {@id=123}
def handleAttributes(text, parent):
"""Set values of an element based on attribute definitions ({@id=123})."""
def attributeCallback(match):
parent.set(match.group(1), match.group(2).replace('\n', ' '))
return ATTR_RE.sub(attributeCallback, text)
"""
The pattern classes
-----------------------------------------------------------------------------
"""
class Pattern:
"""Base class that inline patterns subclass. """
def __init__ (self, pattern, markdown_instance=None):
"""
Create an instant of an inline pattern.
Keyword arguments:
* pattern: A regular expression that matches a pattern
"""
self.pattern = pattern
self.compiled_re = re.compile("^(.*?)%s(.*?)$" % pattern, re.DOTALL)
# Api for Markdown to pass safe_mode into instance
self.safe_mode = False
if markdown_instance:
self.markdown = markdown_instance
def getCompiledRegExp (self):
""" Return a compiled regular expression. """
return self.compiled_re
def handleMatch(self, m):
"""Return a ElementTree element from the given match.
Subclasses should override this method.
Keyword arguments:
* m: A re match object containing a match of the pattern.
"""
pass
def type(self):
""" Return class name, to define pattern type """
return self.__class__.__name__
BasePattern = Pattern # for backward compatibility
class SimpleTextPattern (Pattern):
""" Return a simple text of group(2) of a Pattern. """
def handleMatch(self, m):
text = m.group(2)
if text == markdown.INLINE_PLACEHOLDER_PREFIX:
return None
return text
class SimpleTagPattern (Pattern):
"""
Return element of type `tag` with a text attribute of group(3)
of a Pattern.
"""
def __init__ (self, pattern, tag):
Pattern.__init__(self, pattern)
self.tag = tag
def handleMatch(self, m):
el = markdown.etree.Element(self.tag)
el.text = m.group(3)
return el
class SubstituteTagPattern (SimpleTagPattern):
""" Return a eLement of type `tag` with no children. """
def handleMatch (self, m):
return markdown.etree.Element(self.tag)
class BacktickPattern (Pattern):
""" Return a `<code>` element containing the matching text. """
def __init__ (self, pattern):
Pattern.__init__(self, pattern)
self.tag = "code"
def handleMatch(self, m):
el = markdown.etree.Element(self.tag)
el.text = markdown.AtomicString(m.group(3).strip())
return el
class DoubleTagPattern (SimpleTagPattern):
"""Return a ElementTree element nested in tag2 nested in tag1.
Useful for strong emphasis etc.
"""
def handleMatch(self, m):
tag1, tag2 = self.tag.split(",")
el1 = markdown.etree.Element(tag1)
el2 = markdown.etree.SubElement(el1, tag2)
el2.text = m.group(3)
return el1
class HtmlPattern (Pattern):
""" Store raw inline html and return a placeholder. """
def handleMatch (self, m):
rawhtml = m.group(2)
inline = True
place_holder = self.markdown.htmlStash.store(rawhtml)
return place_holder
class LinkPattern (Pattern):
""" Return a link element from the given match. """
def handleMatch(self, m):
el = markdown.etree.Element("a")
el.text = m.group(2)
title = m.group(11)
href = m.group(9)
if href:
if href[0] == "<":
href = href[1:-1]
el.set("href", self.sanitize_url(href.strip()))
else:
el.set("href", "")
if title:
title = dequote(title) #.replace('"', """)
el.set("title", title)
return el
def sanitize_url(self, url):
"""
Sanitize a url against xss attacks in "safe_mode".
Rather than specifically blacklisting `javascript:alert("XSS")` and all
its aliases (see <http://ha.ckers.org/xss.html>), we whitelist known
safe url formats. Most urls contain a network location, however some
are known not to (i.e.: mailto links). Script urls do not contain a
location. Additionally, for `javascript:...`, the scheme would be
"javascript" but some aliases will appear to `urlparse()` to have no
scheme. On top of that relative links (i.e.: "foo/bar.html") have no
scheme. Therefore we must check "path", "parameters", "query" and
"fragment" for any literal colons. We don't check "scheme" for colons
because it *should* never have any and "netloc" must allow the form:
`username:password@host:port`.
"""
locless_schemes = ['', 'mailto', 'news']
scheme, netloc, path, params, query, fragment = url = urlparse(url)
safe_url = False
if netloc != '' or scheme in locless_schemes:
safe_url = True
for part in url[2:]:
if ":" in part:
safe_url = False
if self.markdown.safeMode and not safe_url:
return ''
else:
return urlunparse(url)
class ImagePattern(LinkPattern):
""" Return a img element from the given match. """
def handleMatch(self, m):
el = markdown.etree.Element("img")
src_parts = m.group(9).split()
if src_parts:
src = src_parts[0]
if src[0] == "<" and src[-1] == ">":
src = src[1:-1]
el.set('src', self.sanitize_url(src))
else:
el.set('src', "")
if len(src_parts) > 1:
el.set('title', dequote(" ".join(src_parts[1:])))
if markdown.ENABLE_ATTRIBUTES:
truealt = handleAttributes(m.group(2), el)
else:
truealt = m.group(2)
el.set('alt', truealt)
return el
class ReferencePattern(LinkPattern):
""" Match to a stored reference and return link element. """
def handleMatch(self, m):
if m.group(9):
id = m.group(9).lower()
else:
# if we got something like "[Google][]"
# we'll use "google" as the id
id = m.group(2).lower()
if not id in self.markdown.references: # ignore undefined refs
return None
href, title = self.markdown.references[id]
text = m.group(2)
return self.makeTag(href, title, text)
def makeTag(self, href, title, text):
el = markdown.etree.Element('a')
el.set('href', self.sanitize_url(href))
if title:
el.set('title', title)
el.text = text
return el
class ImageReferencePattern (ReferencePattern):
""" Match to a stored reference and return img element. """
def makeTag(self, href, title, text):
el = markdown.etree.Element("img")
el.set("src", self.sanitize_url(href))
if title:
el.set("title", title)
el.set("alt", text)
return el
class AutolinkPattern (Pattern):
""" Return a link Element given an autolink (`<http://example/com>`). """
def handleMatch(self, m):
el = markdown.etree.Element("a")
el.set('href', m.group(2))
el.text = markdown.AtomicString(m.group(2))
return el
class AutomailPattern (Pattern):
"""
Return a mailto link Element given an automail link (`<foo@example.com>`).
"""
def handleMatch(self, m):
el = markdown.etree.Element('a')
email = m.group(2)
if email.startswith("mailto:"):
email = email[len("mailto:"):]
def codepoint2name(code):
"""Return entity definition by code, or the code if not defined."""
entity = htmlentitydefs.codepoint2name.get(code)
if entity:
return "%s%s;" % (markdown.AMP_SUBSTITUTE, entity)
else:
return "%s#%d;" % (markdown.AMP_SUBSTITUTE, code)
letters = [codepoint2name(ord(letter)) for letter in email]
el.text = markdown.AtomicString(''.join(letters))
mailto = "mailto:" + email
mailto = "".join([markdown.AMP_SUBSTITUTE + '#%d;' %
ord(letter) for letter in mailto])
el.set('href', mailto)
return el
|
bsd-2-clause
|
[
624,
199,
568,
6174,
31467,
1157,
2709,
199,
5695,
9152,
199,
199,
10307,
7970,
4066,
465,
627,
28907,
10,
787,
8860,
701,
4910,
402,
31407,
199,
1462,
12,
1373,
1126,
3851,
14,
221,
27019,
2251,
1471,
506,
4454,
402,
3992,
199,
9099,
12247,
18502,
14,
9959,
14,
221,
7048,
3851,
909,
4440,
282,
2849,
5578,
199,
5599,
436,
4839,
2291,
314,
2569,
3102,
26,
339,
3851,
14,
362,
32521,
2872,
4527,
342,
327,
2529,
282,
5578,
3965,
339,
3851,
14,
2479,
4486,
8,
77,
9,
327,
6181,
282,
1336,
909,
436,
2529,
2574,
327,
376,
13139,
1819,
503,
2951,
8971,
1318,
199,
199,
2422,
402,
2366,
18502,
1159,
6137,
13,
262,
7970,
5516,
687,
27019,
12,
199,
7911,
1265,
883,
1050,
4722,
7970,
626,
2793,
1133,
14,
199,
199,
31892,
5317,
626,
1006,
314,
5578,
8455,
1202,
701,
8308,
1471,
199,
12685,
314,
8852,
1853,
14,
221,
2104,
642,
4499,
12,
2985,
1006,
1343,
543,
199,
4289,
19276,
3171,
436,
1284,
543,
8189,
12432,
1,
1370,
221,
1010,
1930,
543,
6137,
13,
262,
3965,
199,
9959,
6181,
10296,
402,
7791,
314,
18129,
19276,
2924,
436,
7340,
12432,
1,
1674,
199,
199,
8694,
1183,
12,
314,
1865,
315,
1314,
5578,
8455,
787,
6781,
365,
7437,
199,
19559,
446,
325,
14,
71,
14,
340,
781,
1642,
3350,
1455,
921,
1396,
15,
6220,
543,
665,
65,
30,
3762,
199,
460,
485,
12726,
63,
862,
370,
3350,
8308,
3517,
12,
781,
3955,
1284,
1536,
543,
282,
15634,
14,
199,
5158,
12,
781,
4838,
314,
8455,
315,
314,
2569,
1865,
26,
199,
199,
10,
4772,
436,
1771,
10406,
1172,
370,
2621,
2544,
8137,
587,
12,
880,
523,
626,
781,
883,
299,
850,
4787,
1263,
18502,
7970,
701,
21375,
3062,
14,
199,
199,
10,
2066,
781,
2429,
2599,
13,
4614,
334,
7790,
506,
4224,
2544,
8308,
3517,
9,
199,
199,
10,
2066,
781,
2429,
8308,
4163,
14,
221,
2854,
642,
2376,
781,
911,
9329,
523,
3350,
1006,
8308,
4163,
3326,
543,
282,
10069,
436,
1050,
523,
314,
3503,
4163,
370,
282,
2631,
14,
199,
199,
10,
2066,
8308,
5935,
334,
7790,
506,
4224,
2544,
6220,
9,
199,
199,
10,
2066,
330,
8085,
69,
471,
6220,
12,
1642,
5578,
2066,
3659,
13,
2487,
199,
199,
10,
3753,
781,
4838,
16925,
436,
9052,
24059,
199,
624,
199,
199,
646,
18502,
199,
646,
295,
199,
504,
7097,
492,
7097,
12,
30111,
199,
646,
984,
199,
692,
984,
14,
1023,
2356,
298,
19,
14,
16,
582,
272,
687,
3517,
492,
9045,
465,
30010,
552,
1701,
8710,
199,
2836,
26,
272,
492,
30010,
552,
1701,
8710,
199,
199,
624,
199,
1918,
3503,
5578,
8455,
367,
7970,
199,
3606,
8684,
199,
624,
199,
199,
2826,
25950,
275,
519,
29538,
7272,
59,
3672,
7,
199,
7184,
43,
275,
334,
519,
1154,
19412,
267,
435,
334,
2826,
25950,
435,
519,
13445,
59,
358,
10,
22,
267,
435,
334,
2826,
25950,
11,
519,
1154,
566,
13418,
10,
22,
267,
435,
4825,
25950,
435,
519,
24431,
6616,
776,
199,
2826,
26246,
275,
519,
10120,
11230,
60,
1,
3171,
199,
199,
7111,
52,
13884,
63,
907,
275,
519,
10120,
11230,
1103,
5130,
64,
29653,
11198,
18168,
11230,
64,
2862,
18,
26313,
64,
3171,
327,
658,
69,
29,
70,
11995,
503,
1124,
69,
29,
70,
480,
22446,
1040,
199,
28879,
63,
907,
275,
519,
8124,
13417,
3171,
17907,
327,
971,
28,
199,
37,
1658,
13533,
1311,
63,
907,
275,
519,
13445,
13278,
21690,
10,
18096,
18,
7,
8540,
327,
627,
28907,
10,
199,
3027,
7770,
63,
907,
275,
519,
13445,
10,
91,
18,
22441,
7348,
18,
1552,
28149,
2862,
18,
7,
10473,
327,
1011,
9370,
538,
199,
3027,
7770,
63,
2769,
63,
907,
275,
519,
13445,
10,
91,
19,
22441,
7348,
19,
1552,
28149,
2862,
18,
7,
3322,
327,
19688,
9370,
9153,
199,
199,
692,
18502,
14,
4029,
2294,
63,
37,
1658,
13533,
1311,
26,
272,
662,
1658,
13533,
1311,
63,
18,
63,
907,
275,
519,
10120,
11230,
60,
87,
9,
1547,
10127,
51,
11198,
2862,
18,
2229,
12525,
87,
3171,
263,
327,
485,
28907,
63,
199,
2836,
26,
272,
662,
1658,
13533,
1311,
63,
18,
63,
907,
275,
519,
7,
1547,
5130,
11198,
2862,
18,
7,
463,
327,
485,
28907,
63,
199,
199,
7916,
63,
907,
275,
4825,
26246,
435,
11713,
43,
435,
971,
199,
82,
891,
1154,
2961,
83,
5830,
28,
6697,
21521,
17304,
26,
15840,
17140,
60,
430,
92,
16045,
2961,
19563,
15279,
2862,
83,
10,
1332,
459,
3135,
17140,
2862,
713,
5547,
31736,
2344,
199,
3,
359,
505,
8738,
633,
9,
503,
359,
505,
8738,
28,
633,
18956,
199,
199,
9438,
63,
7916,
63,
907,
275,
519,
1154,
11213,
435,
11713,
43,
435,
519,
1154,
83,
7590,
1332,
28,
6697,
21521,
21690,
1874,
10,
25105,
3171,
199,
3,
8546,
59,
4478,
2424,
8738,
1014,
921,
88,
14,
957,
24793,
503,
8546,
59,
4478,
2424,
8738,
28,
1014,
921,
88,
14,
957,
3133,
9,
199,
31177,
63,
907,
275,
4825,
26246,
435,
11713,
43,
11,
519,
1154,
83,
7590,
59,
21690,
2677,
10,
2862,
6616,
3698,
327,
359,
13266,
1527,
19,
61,
199,
9438,
63,
31177,
63,
907,
275,
519,
1154,
11213,
435,
11713,
43,
435,
1557,
83,
7590,
59,
21690,
2677,
10,
2862,
6616,
327,
8546,
59,
4478,
1318,
1527,
18,
61,
199,
4609,
63,
3027,
7770,
63,
907,
275,
519,
7,
1332,
62,
92,
776,
2961,
10,
92,
4602,
8,
1204,
4,
23089,
12788,
327,
10584,
13,
10636,
627,
503,
485,
199,
10774,
2228,
12394,
63,
907,
275,
519,
7601,
17304,
26,
70,
92,
517,
9,
30543,
14144,
17478,
23849,
3524,
263,
327,
665,
1014,
921,
1544,
14,
4288,
14,
957,
30,
199,
13883,
8175,
63,
907,
275,
519,
7601,
7059,
30,
971,
1,
3672,
32,
17478,
1622,
13278,
3524,
5185,
327,
665,
278,
32,
2694,
14,
957,
30,
199,
199,
4943,
63,
907,
275,
519,
13445,
28,
779,
65,
13,
6353,
13,
58,
15,
1527,
12773,
30,
3672,
31,
6113,
17722,
6697,
306,
2862,
30,
3171,
5185,
327,
665,
1396,
30,
199,
13630,
63,
907,
275,
519,
6774,
6,
7023,
3,
65,
13,
6353,
13,
58,
16,
13,
25,
3672,
27,
3171,
5185,
327,
1253,
5282,
27,
199,
6174,
63,
14731,
63,
907,
275,
519,
7
] |
[
199,
568,
6174,
31467,
1157,
2709,
199,
5695,
9152,
199,
199,
10307,
7970,
4066,
465,
627,
28907,
10,
787,
8860,
701,
4910,
402,
31407,
199,
1462,
12,
1373,
1126,
3851,
14,
221,
27019,
2251,
1471,
506,
4454,
402,
3992,
199,
9099,
12247,
18502,
14,
9959,
14,
221,
7048,
3851,
909,
4440,
282,
2849,
5578,
199,
5599,
436,
4839,
2291,
314,
2569,
3102,
26,
339,
3851,
14,
362,
32521,
2872,
4527,
342,
327,
2529,
282,
5578,
3965,
339,
3851,
14,
2479,
4486,
8,
77,
9,
327,
6181,
282,
1336,
909,
436,
2529,
2574,
327,
376,
13139,
1819,
503,
2951,
8971,
1318,
199,
199,
2422,
402,
2366,
18502,
1159,
6137,
13,
262,
7970,
5516,
687,
27019,
12,
199,
7911,
1265,
883,
1050,
4722,
7970,
626,
2793,
1133,
14,
199,
199,
31892,
5317,
626,
1006,
314,
5578,
8455,
1202,
701,
8308,
1471,
199,
12685,
314,
8852,
1853,
14,
221,
2104,
642,
4499,
12,
2985,
1006,
1343,
543,
199,
4289,
19276,
3171,
436,
1284,
543,
8189,
12432,
1,
1370,
221,
1010,
1930,
543,
6137,
13,
262,
3965,
199,
9959,
6181,
10296,
402,
7791,
314,
18129,
19276,
2924,
436,
7340,
12432,
1,
1674,
199,
199,
8694,
1183,
12,
314,
1865,
315,
1314,
5578,
8455,
787,
6781,
365,
7437,
199,
19559,
446,
325,
14,
71,
14,
340,
781,
1642,
3350,
1455,
921,
1396,
15,
6220,
543,
665,
65,
30,
3762,
199,
460,
485,
12726,
63,
862,
370,
3350,
8308,
3517,
12,
781,
3955,
1284,
1536,
543,
282,
15634,
14,
199,
5158,
12,
781,
4838,
314,
8455,
315,
314,
2569,
1865,
26,
199,
199,
10,
4772,
436,
1771,
10406,
1172,
370,
2621,
2544,
8137,
587,
12,
880,
523,
626,
781,
883,
299,
850,
4787,
1263,
18502,
7970,
701,
21375,
3062,
14,
199,
199,
10,
2066,
781,
2429,
2599,
13,
4614,
334,
7790,
506,
4224,
2544,
8308,
3517,
9,
199,
199,
10,
2066,
781,
2429,
8308,
4163,
14,
221,
2854,
642,
2376,
781,
911,
9329,
523,
3350,
1006,
8308,
4163,
3326,
543,
282,
10069,
436,
1050,
523,
314,
3503,
4163,
370,
282,
2631,
14,
199,
199,
10,
2066,
8308,
5935,
334,
7790,
506,
4224,
2544,
6220,
9,
199,
199,
10,
2066,
330,
8085,
69,
471,
6220,
12,
1642,
5578,
2066,
3659,
13,
2487,
199,
199,
10,
3753,
781,
4838,
16925,
436,
9052,
24059,
199,
624,
199,
199,
646,
18502,
199,
646,
295,
199,
504,
7097,
492,
7097,
12,
30111,
199,
646,
984,
199,
692,
984,
14,
1023,
2356,
298,
19,
14,
16,
582,
272,
687,
3517,
492,
9045,
465,
30010,
552,
1701,
8710,
199,
2836,
26,
272,
492,
30010,
552,
1701,
8710,
199,
199,
624,
199,
1918,
3503,
5578,
8455,
367,
7970,
199,
3606,
8684,
199,
624,
199,
199,
2826,
25950,
275,
519,
29538,
7272,
59,
3672,
7,
199,
7184,
43,
275,
334,
519,
1154,
19412,
267,
435,
334,
2826,
25950,
435,
519,
13445,
59,
358,
10,
22,
267,
435,
334,
2826,
25950,
11,
519,
1154,
566,
13418,
10,
22,
267,
435,
4825,
25950,
435,
519,
24431,
6616,
776,
199,
2826,
26246,
275,
519,
10120,
11230,
60,
1,
3171,
199,
199,
7111,
52,
13884,
63,
907,
275,
519,
10120,
11230,
1103,
5130,
64,
29653,
11198,
18168,
11230,
64,
2862,
18,
26313,
64,
3171,
327,
658,
69,
29,
70,
11995,
503,
1124,
69,
29,
70,
480,
22446,
1040,
199,
28879,
63,
907,
275,
519,
8124,
13417,
3171,
17907,
327,
971,
28,
199,
37,
1658,
13533,
1311,
63,
907,
275,
519,
13445,
13278,
21690,
10,
18096,
18,
7,
8540,
327,
627,
28907,
10,
199,
3027,
7770,
63,
907,
275,
519,
13445,
10,
91,
18,
22441,
7348,
18,
1552,
28149,
2862,
18,
7,
10473,
327,
1011,
9370,
538,
199,
3027,
7770,
63,
2769,
63,
907,
275,
519,
13445,
10,
91,
19,
22441,
7348,
19,
1552,
28149,
2862,
18,
7,
3322,
327,
19688,
9370,
9153,
199,
199,
692,
18502,
14,
4029,
2294,
63,
37,
1658,
13533,
1311,
26,
272,
662,
1658,
13533,
1311,
63,
18,
63,
907,
275,
519,
10120,
11230,
60,
87,
9,
1547,
10127,
51,
11198,
2862,
18,
2229,
12525,
87,
3171,
263,
327,
485,
28907,
63,
199,
2836,
26,
272,
662,
1658,
13533,
1311,
63,
18,
63,
907,
275,
519,
7,
1547,
5130,
11198,
2862,
18,
7,
463,
327,
485,
28907,
63,
199,
199,
7916,
63,
907,
275,
4825,
26246,
435,
11713,
43,
435,
971,
199,
82,
891,
1154,
2961,
83,
5830,
28,
6697,
21521,
17304,
26,
15840,
17140,
60,
430,
92,
16045,
2961,
19563,
15279,
2862,
83,
10,
1332,
459,
3135,
17140,
2862,
713,
5547,
31736,
2344,
199,
3,
359,
505,
8738,
633,
9,
503,
359,
505,
8738,
28,
633,
18956,
199,
199,
9438,
63,
7916,
63,
907,
275,
519,
1154,
11213,
435,
11713,
43,
435,
519,
1154,
83,
7590,
1332,
28,
6697,
21521,
21690,
1874,
10,
25105,
3171,
199,
3,
8546,
59,
4478,
2424,
8738,
1014,
921,
88,
14,
957,
24793,
503,
8546,
59,
4478,
2424,
8738,
28,
1014,
921,
88,
14,
957,
3133,
9,
199,
31177,
63,
907,
275,
4825,
26246,
435,
11713,
43,
11,
519,
1154,
83,
7590,
59,
21690,
2677,
10,
2862,
6616,
3698,
327,
359,
13266,
1527,
19,
61,
199,
9438,
63,
31177,
63,
907,
275,
519,
1154,
11213,
435,
11713,
43,
435,
1557,
83,
7590,
59,
21690,
2677,
10,
2862,
6616,
327,
8546,
59,
4478,
1318,
1527,
18,
61,
199,
4609,
63,
3027,
7770,
63,
907,
275,
519,
7,
1332,
62,
92,
776,
2961,
10,
92,
4602,
8,
1204,
4,
23089,
12788,
327,
10584,
13,
10636,
627,
503,
485,
199,
10774,
2228,
12394,
63,
907,
275,
519,
7601,
17304,
26,
70,
92,
517,
9,
30543,
14144,
17478,
23849,
3524,
263,
327,
665,
1014,
921,
1544,
14,
4288,
14,
957,
30,
199,
13883,
8175,
63,
907,
275,
519,
7601,
7059,
30,
971,
1,
3672,
32,
17478,
1622,
13278,
3524,
5185,
327,
665,
278,
32,
2694,
14,
957,
30,
199,
199,
4943,
63,
907,
275,
519,
13445,
28,
779,
65,
13,
6353,
13,
58,
15,
1527,
12773,
30,
3672,
31,
6113,
17722,
6697,
306,
2862,
30,
3171,
5185,
327,
665,
1396,
30,
199,
13630,
63,
907,
275,
519,
6774,
6,
7023,
3,
65,
13,
6353,
13,
58,
16,
13,
25,
3672,
27,
3171,
5185,
327,
1253,
5282,
27,
199,
6174,
63,
14731,
63,
907,
275,
519,
7,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
googlefonts/glyphsLib
|
tests/util_test.py
|
1
|
1437
|
#
# Copyright 2016 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import unittest
from glyphsLib.util import bin_to_int_list, int_list_to_bin
class UtilTest(unittest.TestCase):
def test_bin_to_int_list(self):
self.assertEqual([], bin_to_int_list(0))
self.assertEqual([0], bin_to_int_list(1))
self.assertEqual([1], bin_to_int_list(2))
self.assertEqual([0, 1], bin_to_int_list(3))
self.assertEqual([2], bin_to_int_list(4))
self.assertEqual([7, 30], bin_to_int_list((1 << 7) + (1 << 30)))
def test_int_list_to_bin(self):
self.assertEqual(int_list_to_bin([]), 0)
self.assertEqual(int_list_to_bin([0]), 1)
self.assertEqual(int_list_to_bin([1]), 2)
self.assertEqual(int_list_to_bin([0, 1]), 3)
self.assertEqual(int_list_to_bin([2]), 4)
self.assertEqual(int_list_to_bin([7, 30]), (1 << 7) + (1 << 30))
|
apache-2.0
|
[
3,
199,
3,
1898,
7800,
4475,
3277,
14,
2900,
5924,
5702,
14,
199,
3,
199,
3,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
199,
3,
1265,
1443,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
199,
3,
2047,
1443,
3332,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
258,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
199,
3,
2428,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
199,
3,
1666,
314,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
199,
3,
4204,
1334,
314,
844,
14,
421,
199,
646,
2882,
199,
199,
504,
24222,
4728,
14,
1974,
492,
2517,
63,
475,
63,
442,
63,
513,
12,
1109,
63,
513,
63,
475,
63,
1393,
421,
199,
533,
21248,
774,
8,
2796,
14,
1746,
304,
272,
347,
511,
63,
1393,
63,
475,
63,
442,
63,
513,
8,
277,
304,
267,
291,
14,
629,
8798,
2517,
63,
475,
63,
442,
63,
513,
8,
16,
430,
267,
291,
14,
629,
779,
16,
467,
2517,
63,
475,
63,
442,
63,
513,
8,
17,
430,
267,
291,
14,
629,
779,
17,
467,
2517,
63,
475,
63,
442,
63,
513,
8,
18,
430,
267,
291,
14,
629,
779,
16,
12,
413,
467,
2517,
63,
475,
63,
442,
63,
513,
8,
19,
430,
267,
291,
14,
629,
779,
18,
467,
2517,
63,
475,
63,
442,
63,
513,
8,
20,
430,
267,
291,
14,
629,
779,
23,
12,
4233,
467,
2517,
63,
475,
63,
442,
63,
513,
1332,
17,
5213,
1520,
9,
435,
334,
17,
5213,
4233,
1724,
339,
347,
511,
63,
442,
63,
513,
63,
475,
63,
1393,
8,
277,
304,
267,
291,
14,
629,
8,
442,
63,
513,
63,
475,
63,
1393,
25550,
378,
9,
267,
291,
14,
629,
8,
442,
63,
513,
63,
475,
63,
1393,
779,
16,
2522,
413,
9,
267,
291,
14,
629,
8,
442,
63,
513,
63,
475,
63,
1393,
779,
17,
2522,
499,
9,
267,
291,
14,
629,
8,
442,
63,
513,
63,
475,
63,
1393,
779,
16,
12,
413,
2522,
650,
9,
267,
291,
14,
629,
8,
442,
63,
513,
63,
475,
63,
1393,
779,
18,
2522,
841,
9,
267,
291,
14,
629,
8,
442,
63,
513,
63,
475,
63,
1393,
779,
23,
12,
4233,
2522,
334,
17,
5213,
1520,
9,
435,
334,
17,
5213,
4233,
430,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
199,
3,
1898,
7800,
4475,
3277,
14,
2900,
5924,
5702,
14,
199,
3,
199,
3,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
199,
3,
1265,
1443,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
199,
3,
2047,
1443,
3332,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
258,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
199,
3,
2428,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
199,
3,
1666,
314,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
199,
3,
4204,
1334,
314,
844,
14,
421,
199,
646,
2882,
199,
199,
504,
24222,
4728,
14,
1974,
492,
2517,
63,
475,
63,
442,
63,
513,
12,
1109,
63,
513,
63,
475,
63,
1393,
421,
199,
533,
21248,
774,
8,
2796,
14,
1746,
304,
272,
347,
511,
63,
1393,
63,
475,
63,
442,
63,
513,
8,
277,
304,
267,
291,
14,
629,
8798,
2517,
63,
475,
63,
442,
63,
513,
8,
16,
430,
267,
291,
14,
629,
779,
16,
467,
2517,
63,
475,
63,
442,
63,
513,
8,
17,
430,
267,
291,
14,
629,
779,
17,
467,
2517,
63,
475,
63,
442,
63,
513,
8,
18,
430,
267,
291,
14,
629,
779,
16,
12,
413,
467,
2517,
63,
475,
63,
442,
63,
513,
8,
19,
430,
267,
291,
14,
629,
779,
18,
467,
2517,
63,
475,
63,
442,
63,
513,
8,
20,
430,
267,
291,
14,
629,
779,
23,
12,
4233,
467,
2517,
63,
475,
63,
442,
63,
513,
1332,
17,
5213,
1520,
9,
435,
334,
17,
5213,
4233,
1724,
339,
347,
511,
63,
442,
63,
513,
63,
475,
63,
1393,
8,
277,
304,
267,
291,
14,
629,
8,
442,
63,
513,
63,
475,
63,
1393,
25550,
378,
9,
267,
291,
14,
629,
8,
442,
63,
513,
63,
475,
63,
1393,
779,
16,
2522,
413,
9,
267,
291,
14,
629,
8,
442,
63,
513,
63,
475,
63,
1393,
779,
17,
2522,
499,
9,
267,
291,
14,
629,
8,
442,
63,
513,
63,
475,
63,
1393,
779,
16,
12,
413,
2522,
650,
9,
267,
291,
14,
629,
8,
442,
63,
513,
63,
475,
63,
1393,
779,
18,
2522,
841,
9,
267,
291,
14,
629,
8,
442,
63,
513,
63,
475,
63,
1393,
779,
23,
12,
4233,
2522,
334,
17,
5213,
1520,
9,
435,
334,
17,
5213,
4233,
430,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
ebukoz/thrive
|
erpnext/communication/doctype/call_log/call_log.py
|
5
|
3216
|
# -*- coding: utf-8 -*-
# Copyright (c) 2019, Frappe Technologies Pvt. Ltd. and contributors
# For license information, please see license.txt
from __future__ import unicode_literals
import frappe
from frappe import _
from frappe.model.document import Document
from erpnext.crm.doctype.utils import get_scheduled_employees_for_popup, strip_number
from frappe.contacts.doctype.contact.contact import get_contact_with_phone_number
from erpnext.crm.doctype.lead.lead import get_lead_with_phone_number
class CallLog(Document):
def before_insert(self):
number = strip_number(self.get('from'))
self.contact = get_contact_with_phone_number(number)
self.lead = get_lead_with_phone_number(number)
def after_insert(self):
self.trigger_call_popup()
def on_update(self):
doc_before_save = self.get_doc_before_save()
if not doc_before_save: return
if doc_before_save.status in ['Ringing'] and self.status in ['Missed', 'Completed']:
frappe.publish_realtime('call_{id}_disconnected'.format(id=self.id), self)
elif doc_before_save.to != self.to:
self.trigger_call_popup()
def trigger_call_popup(self):
scheduled_employees = get_scheduled_employees_for_popup(self.medium)
employee_emails = get_employees_with_number(self.to)
# check if employees with matched number are scheduled to receive popup
emails = set(scheduled_employees).intersection(employee_emails)
# # if no employee found with matching phone number then show popup to scheduled employees
# emails = emails or scheduled_employees if employee_emails
for email in emails:
frappe.publish_realtime('show_call_popup', self, user=email)
@frappe.whitelist()
def add_call_summary(call_log, summary):
doc = frappe.get_doc('Call Log', call_log)
doc.add_comment('Comment', frappe.bold(_('Call Summary')) + '<br><br>' + summary)
def get_employees_with_number(number):
number = strip_number(number)
if not number: return []
employee_emails = frappe.cache().hget('employees_with_number', number)
if employee_emails: return employee_emails
employees = frappe.get_all('Employee', filters={
'cell_number': ['like', '%{}%'.format(number)],
'user_id': ['!=', '']
}, fields=['user_id'])
employee_emails = [employee.user_id for employee in employees]
frappe.cache().hset('employees_with_number', number, employee_emails)
return employee_emails
def set_caller_information(doc, state):
'''Called from hooks on creation of Lead or Contact'''
if doc.doctype not in ['Lead', 'Contact']: return
numbers = [doc.get('phone'), doc.get('mobile_no')]
# contact for Contact and lead for Lead
fieldname = doc.doctype.lower()
# contact_name or lead_name
display_name_field = '{}_name'.format(fieldname)
# Contact now has all the nos saved in child table
if doc.doctype == 'Contact':
numbers = [d.phone for d in doc.phone_nos]
for number in numbers:
number = strip_number(number)
if not number: continue
filters = frappe._dict({
'from': ['like', '%{}'.format(number)],
fieldname: ''
})
logs = frappe.get_all('Call Log', filters=filters)
for log in logs:
frappe.db.set_value('Call Log', log.name, {
fieldname: doc.name,
display_name_field: doc.get_title()
}, update_modified=False)
|
gpl-3.0
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
1898,
334,
67,
9,
20312,
12,
481,
5034,
19215,
29053,
14,
12126,
14,
436,
8417,
199,
3,
2104,
4190,
2556,
12,
8749,
1937,
4190,
14,
2424,
199,
199,
504,
636,
2443,
363,
492,
2649,
63,
5955,
199,
646,
6950,
199,
504,
6950,
492,
485,
199,
504,
6950,
14,
1238,
14,
3554,
492,
7543,
199,
504,
29106,
14,
15213,
14,
6356,
14,
1208,
492,
664,
63,
19274,
63,
24561,
63,
509,
63,
16020,
12,
6202,
63,
1955,
199,
504,
6950,
14,
18147,
14,
6356,
14,
7811,
14,
7811,
492,
664,
63,
7811,
63,
1045,
63,
9339,
63,
1955,
199,
504,
29106,
14,
15213,
14,
6356,
14,
13799,
14,
13799,
492,
664,
63,
13799,
63,
1045,
63,
9339,
63,
1955,
199,
199,
533,
6523,
2445,
8,
5564,
304,
199,
198,
318,
2544,
63,
3176,
8,
277,
304,
507,
198,
1955,
275,
6202,
63,
1955,
8,
277,
14,
362,
360,
504,
1333,
507,
198,
277,
14,
7811,
275,
664,
63,
7811,
63,
1045,
63,
9339,
63,
1955,
8,
1955,
9,
507,
198,
277,
14,
13799,
275,
664,
63,
13799,
63,
1045,
63,
9339,
63,
1955,
8,
1955,
9,
421,
198,
318,
2410,
63,
3176,
8,
277,
304,
507,
198,
277,
14,
7631,
63,
1250,
63,
16020,
342,
421,
198,
318,
641,
63,
873,
8,
277,
304,
507,
198,
1301,
63,
5182,
63,
2117,
275,
291,
14,
362,
63,
1301,
63,
5182,
63,
2117,
342,
507,
198,
692,
440,
1382,
63,
5182,
63,
2117,
26,
372,
507,
198,
692,
1382,
63,
5182,
63,
2117,
14,
1205,
315,
788,
15420,
316,
418,
436,
291,
14,
1205,
315,
788,
5829,
939,
297,
283,
19908,
2565,
686,
198,
9098,
14,
4763,
63,
3093,
521,
360,
1250,
7348,
344,
12585,
27476,
1370,
908,
8,
344,
29,
277,
14,
344,
395,
291,
9,
507,
198,
4164,
1382,
63,
5182,
63,
2117,
14,
475,
1137,
291,
14,
475,
26,
686,
198,
277,
14,
7631,
63,
1250,
63,
16020,
342,
421,
198,
318,
6804,
63,
1250,
63,
16020,
8,
277,
304,
507,
198,
19274,
63,
24561,
275,
664,
63,
19274,
63,
24561,
63,
509,
63,
16020,
8,
277,
14,
14345,
9,
507,
198,
10103,
63,
14170,
275,
664,
63,
24561,
63,
1045,
63,
1955,
8,
277,
14,
475,
9,
2742,
198,
3,
1104,
340,
9052,
18149,
543,
7838,
1329,
787,
18416,
370,
9128,
22365,
507,
198,
14170,
275,
663,
8,
19274,
63,
24561,
680,
12569,
8,
10103,
63,
14170,
9,
2742,
198,
3,
327,
340,
949,
15778,
1911,
543,
4877,
14617,
1329,
2066,
2498,
22365,
370,
18416,
9052,
18149,
507,
198,
3,
14931,
275,
14931,
503,
18416,
63,
24561,
340,
15778,
63,
14170,
2742,
198,
509,
3031,
315,
14931,
26,
686,
198,
9098,
14,
4763,
63,
3093,
521,
360,
2384,
63,
1250,
63,
16020,
297,
291,
12,
922,
29,
2123,
9,
199,
199,
32,
9098,
14,
14189,
342,
199,
318,
1050,
63,
1250,
63,
4705,
8,
1250,
63,
793,
12,
6212,
304,
199,
198,
1301,
275,
6950,
14,
362,
63,
1301,
360,
2176,
5297,
297,
1240,
63,
793,
9,
199,
198,
1301,
14,
525,
63,
3349,
360,
7488,
297,
6950,
14,
9771,
6723,
2176,
22486,
1333,
435,
2650,
3289,
2535,
3289,
3524,
435,
6212,
9,
199,
199,
318,
664,
63,
24561,
63,
1045,
63,
1955,
8,
1955,
304,
199,
198,
1955,
275,
6202,
63,
1955,
8,
1955,
9,
199,
198,
692,
440,
1329,
26,
372,
942,
421,
198,
10103,
63,
14170,
275,
6950,
14,
1637,
1252,
72,
362,
360,
24561,
63,
1045,
63,
1955,
297,
1329,
9,
199,
198,
692,
15778,
63,
14170,
26,
372,
15778,
63,
14170,
421,
198,
24561,
275,
6950,
14,
362,
63,
452,
360,
22635,
297,
4766,
3126,
507,
198,
7,
3890,
63,
1955,
356,
788,
2930,
297,
1543,
2440,
5,
1370,
908,
8,
1955,
4360,
507,
198,
7,
751,
63,
344,
356,
788,
1111,
297,
28696,
199,
198,
1386,
1504,
2968,
751,
63,
344,
1105,
421,
198,
10103,
63,
14170,
275,
359,
10103,
14,
751,
63,
344,
367,
15778,
315,
9052,
18149,
61,
199,
198,
9098,
14,
1637,
1252,
72,
409,
360,
24561,
63,
1045,
63,
1955,
297,
1329,
12,
15778,
63,
14170,
9,
421,
198,
1107,
15778,
63,
14170,
199,
199,
318,
663,
63,
11219,
63,
11697,
8,
1301,
12,
1174,
304,
199,
198,
2344,
10474,
687,
12604,
641,
7143,
402,
7005,
350,
503,
18684,
2344,
199,
198,
692,
1382,
14,
6356,
440,
315,
788,
29006,
297,
283,
14499,
2565,
372,
421,
198,
10548,
275,
359,
1301,
14,
362,
360,
9339,
659,
1382,
14,
362,
360,
11375,
63,
889,
5440,
199,
198,
3,
8966,
367,
18684,
436,
12690,
367,
7005,
350,
199,
198,
13646,
275,
1382,
14,
6356,
14,
2325,
342,
421,
198,
3,
8966,
63,
354,
503,
12690,
63,
354,
199,
198,
2918,
63,
354,
63,
698,
275,
9005,
63,
354,
1370,
908,
8,
13646,
9,
421,
198,
3,
18684,
3063,
965,
1006,
314,
302,
736,
6290,
315,
1982,
1817,
199,
198,
692,
1382,
14,
6356,
508,
283,
14499,
356,
507,
198,
10548,
275,
359,
68,
14,
9339,
367,
366,
315,
1382,
14,
9339,
63,
12712,
61,
421,
198,
509,
1329,
315,
5579,
26,
507,
198,
1955,
275,
6202,
63,
1955,
8,
1955,
9,
507,
198,
692,
440,
1329,
26,
1980,
2742,
198,
4273,
275,
6950,
423,
807,
2561,
686,
198,
7,
504,
356,
788,
2930,
297,
1543,
11123,
908,
8,
1955,
4360,
686,
198,
13646,
26,
2125,
507,
198,
1552,
2742,
198,
7270,
275,
6950,
14,
362,
63,
452,
360,
2176,
5297,
297,
4766,
29,
4273,
9,
2742,
198,
509,
943,
315,
9610,
26,
686,
198,
9098,
14,
697,
14,
409,
63,
585,
360,
2176,
5297,
297,
943,
14,
354,
12,
469,
1585,
198,
13646,
26,
1382,
14,
354,
12,
1585,
198,
2918,
63,
354,
63,
698,
26,
1382,
14,
362,
63,
1213,
342,
686,
198,
1386,
1678,
63,
5540,
29,
797,
9,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
1898,
334,
67,
9,
20312,
12,
481,
5034,
19215,
29053,
14,
12126,
14,
436,
8417,
199,
3,
2104,
4190,
2556,
12,
8749,
1937,
4190,
14,
2424,
199,
199,
504,
636,
2443,
363,
492,
2649,
63,
5955,
199,
646,
6950,
199,
504,
6950,
492,
485,
199,
504,
6950,
14,
1238,
14,
3554,
492,
7543,
199,
504,
29106,
14,
15213,
14,
6356,
14,
1208,
492,
664,
63,
19274,
63,
24561,
63,
509,
63,
16020,
12,
6202,
63,
1955,
199,
504,
6950,
14,
18147,
14,
6356,
14,
7811,
14,
7811,
492,
664,
63,
7811,
63,
1045,
63,
9339,
63,
1955,
199,
504,
29106,
14,
15213,
14,
6356,
14,
13799,
14,
13799,
492,
664,
63,
13799,
63,
1045,
63,
9339,
63,
1955,
199,
199,
533,
6523,
2445,
8,
5564,
304,
199,
198,
318,
2544,
63,
3176,
8,
277,
304,
507,
198,
1955,
275,
6202,
63,
1955,
8,
277,
14,
362,
360,
504,
1333,
507,
198,
277,
14,
7811,
275,
664,
63,
7811,
63,
1045,
63,
9339,
63,
1955,
8,
1955,
9,
507,
198,
277,
14,
13799,
275,
664,
63,
13799,
63,
1045,
63,
9339,
63,
1955,
8,
1955,
9,
421,
198,
318,
2410,
63,
3176,
8,
277,
304,
507,
198,
277,
14,
7631,
63,
1250,
63,
16020,
342,
421,
198,
318,
641,
63,
873,
8,
277,
304,
507,
198,
1301,
63,
5182,
63,
2117,
275,
291,
14,
362,
63,
1301,
63,
5182,
63,
2117,
342,
507,
198,
692,
440,
1382,
63,
5182,
63,
2117,
26,
372,
507,
198,
692,
1382,
63,
5182,
63,
2117,
14,
1205,
315,
788,
15420,
316,
418,
436,
291,
14,
1205,
315,
788,
5829,
939,
297,
283,
19908,
2565,
686,
198,
9098,
14,
4763,
63,
3093,
521,
360,
1250,
7348,
344,
12585,
27476,
1370,
908,
8,
344,
29,
277,
14,
344,
395,
291,
9,
507,
198,
4164,
1382,
63,
5182,
63,
2117,
14,
475,
1137,
291,
14,
475,
26,
686,
198,
277,
14,
7631,
63,
1250,
63,
16020,
342,
421,
198,
318,
6804,
63,
1250,
63,
16020,
8,
277,
304,
507,
198,
19274,
63,
24561,
275,
664,
63,
19274,
63,
24561,
63,
509,
63,
16020,
8,
277,
14,
14345,
9,
507,
198,
10103,
63,
14170,
275,
664,
63,
24561,
63,
1045,
63,
1955,
8,
277,
14,
475,
9,
2742,
198,
3,
1104,
340,
9052,
18149,
543,
7838,
1329,
787,
18416,
370,
9128,
22365,
507,
198,
14170,
275,
663,
8,
19274,
63,
24561,
680,
12569,
8,
10103,
63,
14170,
9,
2742,
198,
3,
327,
340,
949,
15778,
1911,
543,
4877,
14617,
1329,
2066,
2498,
22365,
370,
18416,
9052,
18149,
507,
198,
3,
14931,
275,
14931,
503,
18416,
63,
24561,
340,
15778,
63,
14170,
2742,
198,
509,
3031,
315,
14931,
26,
686,
198,
9098,
14,
4763,
63,
3093,
521,
360,
2384,
63,
1250,
63,
16020,
297,
291,
12,
922,
29,
2123,
9,
199,
199,
32,
9098,
14,
14189,
342,
199,
318,
1050,
63,
1250,
63,
4705,
8,
1250,
63,
793,
12,
6212,
304,
199,
198,
1301,
275,
6950,
14,
362,
63,
1301,
360,
2176,
5297,
297,
1240,
63,
793,
9,
199,
198,
1301,
14,
525,
63,
3349,
360,
7488,
297,
6950,
14,
9771,
6723,
2176,
22486,
1333,
435,
2650,
3289,
2535,
3289,
3524,
435,
6212,
9,
199,
199,
318,
664,
63,
24561,
63,
1045,
63,
1955,
8,
1955,
304,
199,
198,
1955,
275,
6202,
63,
1955,
8,
1955,
9,
199,
198,
692,
440,
1329,
26,
372,
942,
421,
198,
10103,
63,
14170,
275,
6950,
14,
1637,
1252,
72,
362,
360,
24561,
63,
1045,
63,
1955,
297,
1329,
9,
199,
198,
692,
15778,
63,
14170,
26,
372,
15778,
63,
14170,
421,
198,
24561,
275,
6950,
14,
362,
63,
452,
360,
22635,
297,
4766,
3126,
507,
198,
7,
3890,
63,
1955,
356,
788,
2930,
297,
1543,
2440,
5,
1370,
908,
8,
1955,
4360,
507,
198,
7,
751,
63,
344,
356,
788,
1111,
297,
28696,
199,
198,
1386,
1504,
2968,
751,
63,
344,
1105,
421,
198,
10103,
63,
14170,
275,
359,
10103,
14,
751,
63,
344,
367,
15778,
315,
9052,
18149,
61,
199,
198,
9098,
14,
1637,
1252,
72,
409,
360,
24561,
63,
1045,
63,
1955,
297,
1329,
12,
15778,
63,
14170,
9,
421,
198,
1107,
15778,
63,
14170,
199,
199,
318,
663,
63,
11219,
63,
11697,
8,
1301,
12,
1174,
304,
199,
198,
2344,
10474,
687,
12604,
641,
7143,
402,
7005,
350,
503,
18684,
2344,
199,
198,
692,
1382,
14,
6356,
440,
315,
788,
29006,
297,
283,
14499,
2565,
372,
421,
198,
10548,
275,
359,
1301,
14,
362,
360,
9339,
659,
1382,
14,
362,
360,
11375,
63,
889,
5440,
199,
198,
3,
8966,
367,
18684,
436,
12690,
367,
7005,
350,
199,
198,
13646,
275,
1382,
14,
6356,
14,
2325,
342,
421,
198,
3,
8966,
63,
354,
503,
12690,
63,
354,
199,
198,
2918,
63,
354,
63,
698,
275,
9005,
63,
354,
1370,
908,
8,
13646,
9,
421,
198,
3,
18684,
3063,
965,
1006,
314,
302,
736,
6290,
315,
1982,
1817,
199,
198,
692,
1382,
14,
6356,
508,
283,
14499,
356,
507,
198,
10548,
275,
359,
68,
14,
9339,
367,
366,
315,
1382,
14,
9339,
63,
12712,
61,
421,
198,
509,
1329,
315,
5579,
26,
507,
198,
1955,
275,
6202,
63,
1955,
8,
1955,
9,
507,
198,
692,
440,
1329,
26,
1980,
2742,
198,
4273,
275,
6950,
423,
807,
2561,
686,
198,
7,
504,
356,
788,
2930,
297,
1543,
11123,
908,
8,
1955,
4360,
686,
198,
13646,
26,
2125,
507,
198,
1552,
2742,
198,
7270,
275,
6950,
14,
362,
63,
452,
360,
2176,
5297,
297,
4766,
29,
4273,
9,
2742,
198,
509,
943,
315,
9610,
26,
686,
198,
9098,
14,
697,
14,
409,
63,
585,
360,
2176,
5297,
297,
943,
14,
354,
12,
469,
1585,
198,
13646,
26,
1382,
14,
354,
12,
1585,
198,
2918,
63,
354,
63,
698,
26,
1382,
14,
362,
63,
1213,
342,
686,
198,
1386,
1678,
63,
5540,
29,
797,
9,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
mancoast/CPythonPyc_test
|
cpython/274_test_md5.py
|
194
|
1790
|
# Testing md5 module
import warnings
warnings.filterwarnings("ignore", "the md5 module is deprecated.*",
DeprecationWarning)
import unittest
from md5 import md5
from test import test_support
def hexstr(s):
import string
h = string.hexdigits
r = ''
for c in s:
i = ord(c)
r = r + h[(i >> 4) & 0xF] + h[i & 0xF]
return r
class MD5_Test(unittest.TestCase):
def md5test(self, s, expected):
self.assertEqual(hexstr(md5(s).digest()), expected)
self.assertEqual(md5(s).hexdigest(), expected)
def test_basics(self):
eq = self.md5test
eq('', 'd41d8cd98f00b204e9800998ecf8427e')
eq('a', '0cc175b9c0f1b6a831c399e269772661')
eq('abc', '900150983cd24fb0d6963f7d28e17f72')
eq('message digest', 'f96b697d7cb7938d525a2f31aaf161d0')
eq('abcdefghijklmnopqrstuvwxyz', 'c3fcd3d76192e4007dfb496cca67e13b')
eq('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789',
'd174ab98d277d9f5a5611c2c9f419d9f')
eq('12345678901234567890123456789012345678901234567890123456789012345678901234567890',
'57edf4a22be3c955ac49da2e2107b67a')
def test_hexdigest(self):
# hexdigest is new with Python 2.0
m = md5('testing the hexdigest method')
h = m.hexdigest()
self.assertEqual(hexstr(m.digest()), h)
def test_large_update(self):
aas = 'a' * 64
bees = 'b' * 64
cees = 'c' * 64
m1 = md5()
m1.update(aas)
m1.update(bees)
m1.update(cees)
m2 = md5()
m2.update(aas + bees + cees)
self.assertEqual(m1.digest(), m2.digest())
def test_main():
test_support.run_unittest(MD5_Test)
if __name__ == '__main__':
test_main()
|
gpl-3.0
|
[
3,
11940,
6128,
21,
859,
199,
646,
3598,
199,
5451,
14,
23945,
480,
4247,
401,
298,
1589,
6128,
21,
859,
365,
5906,
2795,
401,
717,
13413,
9,
199,
199,
646,
2882,
199,
504,
6128,
21,
492,
6128,
21,
199,
504,
511,
492,
511,
63,
4058,
199,
199,
318,
6318,
495,
8,
83,
304,
272,
492,
1059,
272,
394,
275,
1059,
14,
4097,
7022,
272,
519,
275,
2125,
272,
367,
286,
315,
308,
26,
267,
284,
275,
6206,
8,
67,
9,
267,
519,
275,
519,
435,
394,
7528,
73,
4331,
841,
9,
1253,
378,
6287,
61,
435,
394,
59,
73,
1253,
378,
6287,
61,
272,
372,
519,
199,
199,
533,
15830,
21,
63,
774,
8,
2796,
14,
1746,
304,
339,
347,
6128,
21,
396,
8,
277,
12,
308,
12,
1420,
304,
267,
291,
14,
629,
8,
4097,
495,
8,
1064,
21,
8,
83,
680,
5671,
4000,
1420,
9,
267,
291,
14,
629,
8,
1064,
21,
8,
83,
680,
11453,
1062,
1420,
9,
339,
347,
511,
63,
4316,
83,
8,
277,
304,
267,
3850,
275,
291,
14,
1064,
21,
396,
267,
3850,
8594,
283,
68,
2953,
68,
24,
2866,
2905,
70,
383,
66,
6686,
69,
2905,
383,
13830,
32430,
1349,
1465,
69,
358,
267,
3850,
360,
65,
297,
283,
16,
2055,
10848,
66,
25,
67,
16,
70,
17,
66,
22,
65,
24,
2192,
67,
10936,
69,
12442,
1138,
9969,
17,
358,
267,
3850,
360,
3175,
297,
283,
17518,
1046,
1643,
2658,
2866,
1194,
4675,
16,
68,
1876,
2766,
70,
23,
68,
1651,
69,
1196,
70,
2819,
358,
267,
3850,
360,
1188,
10017,
297,
283,
70,
2534,
66,
19301,
68,
23,
2894,
1965,
1703,
68,
24334,
65,
18,
70,
2192,
31498,
12285,
68,
16,
358,
267,
3850,
360,
23459,
297,
283,
67,
19,
29873,
19,
68,
2114,
5756,
69,
5303,
23,
1587,
66,
18105,
30031,
1822,
69,
969,
66,
358,
267,
3850,
360,
28114,
23459,
11371,
297,
1779,
283,
68,
9892,
371,
2905,
68,
9963,
68,
25,
70,
21,
65,
1367,
845,
67,
18,
67,
25,
70,
25230,
68,
25,
70,
358,
267,
3850,
360,
11272,
25588,
25588,
25588,
11371,
16,
297,
1779,
283,
1641,
27680,
20,
65,
1081,
1235,
19,
67,
32601,
645,
1887,
983,
18,
69,
18,
7555,
66,
1822,
65,
358,
339,
347,
511,
63,
11453,
8,
277,
304,
267,
327,
6318,
5671,
365,
892,
543,
2018,
499,
14,
16,
267,
333,
275,
6128,
21,
360,
4776,
314,
6318,
5671,
1083,
358,
267,
394,
275,
333,
14,
11453,
342,
267,
291,
14,
629,
8,
4097,
495,
8,
77,
14,
5671,
4000,
394,
9,
339,
347,
511,
63,
9629,
63,
873,
8,
277,
304,
267,
282,
305,
275,
283,
65,
7,
627,
5049,
267,
506,
397,
275,
283,
66,
7,
627,
5049,
267,
10142,
397,
275,
283,
67,
7,
627,
5049,
398,
333,
17,
275,
6128,
21,
342,
267,
333,
17,
14,
873,
8,
65,
305,
9,
267,
333,
17,
14,
873,
8,
1235,
397,
9,
267,
333,
17,
14,
873,
8,
301,
397,
9,
398,
333,
18,
275,
6128,
21,
342,
267,
333,
18,
14,
873,
8,
65,
305,
435,
506,
397,
435,
10142,
397,
9,
267,
291,
14,
629,
8,
77,
17,
14,
5671,
1062,
333,
18,
14,
5671,
1012,
199,
199,
318,
511,
63,
973,
837,
272,
511,
63,
4058,
14,
1065,
63,
2796,
8,
5127,
21,
63,
774,
9,
199,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
272,
511,
63,
973,
342,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
11940,
6128,
21,
859,
199,
646,
3598,
199,
5451,
14,
23945,
480,
4247,
401,
298,
1589,
6128,
21,
859,
365,
5906,
2795,
401,
717,
13413,
9,
199,
199,
646,
2882,
199,
504,
6128,
21,
492,
6128,
21,
199,
504,
511,
492,
511,
63,
4058,
199,
199,
318,
6318,
495,
8,
83,
304,
272,
492,
1059,
272,
394,
275,
1059,
14,
4097,
7022,
272,
519,
275,
2125,
272,
367,
286,
315,
308,
26,
267,
284,
275,
6206,
8,
67,
9,
267,
519,
275,
519,
435,
394,
7528,
73,
4331,
841,
9,
1253,
378,
6287,
61,
435,
394,
59,
73,
1253,
378,
6287,
61,
272,
372,
519,
199,
199,
533,
15830,
21,
63,
774,
8,
2796,
14,
1746,
304,
339,
347,
6128,
21,
396,
8,
277,
12,
308,
12,
1420,
304,
267,
291,
14,
629,
8,
4097,
495,
8,
1064,
21,
8,
83,
680,
5671,
4000,
1420,
9,
267,
291,
14,
629,
8,
1064,
21,
8,
83,
680,
11453,
1062,
1420,
9,
339,
347,
511,
63,
4316,
83,
8,
277,
304,
267,
3850,
275,
291,
14,
1064,
21,
396,
267,
3850,
8594,
283,
68,
2953,
68,
24,
2866,
2905,
70,
383,
66,
6686,
69,
2905,
383,
13830,
32430,
1349,
1465,
69,
358,
267,
3850,
360,
65,
297,
283,
16,
2055,
10848,
66,
25,
67,
16,
70,
17,
66,
22,
65,
24,
2192,
67,
10936,
69,
12442,
1138,
9969,
17,
358,
267,
3850,
360,
3175,
297,
283,
17518,
1046,
1643,
2658,
2866,
1194,
4675,
16,
68,
1876,
2766,
70,
23,
68,
1651,
69,
1196,
70,
2819,
358,
267,
3850,
360,
1188,
10017,
297,
283,
70,
2534,
66,
19301,
68,
23,
2894,
1965,
1703,
68,
24334,
65,
18,
70,
2192,
31498,
12285,
68,
16,
358,
267,
3850,
360,
23459,
297,
283,
67,
19,
29873,
19,
68,
2114,
5756,
69,
5303,
23,
1587,
66,
18105,
30031,
1822,
69,
969,
66,
358,
267,
3850,
360,
28114,
23459,
11371,
297,
1779,
283,
68,
9892,
371,
2905,
68,
9963,
68,
25,
70,
21,
65,
1367,
845,
67,
18,
67,
25,
70,
25230,
68,
25,
70,
358,
267,
3850,
360,
11272,
25588,
25588,
25588,
11371,
16,
297,
1779,
283,
1641,
27680,
20,
65,
1081,
1235,
19,
67,
32601,
645,
1887,
983,
18,
69,
18,
7555,
66,
1822,
65,
358,
339,
347,
511,
63,
11453,
8,
277,
304,
267,
327,
6318,
5671,
365,
892,
543,
2018,
499,
14,
16,
267,
333,
275,
6128,
21,
360,
4776,
314,
6318,
5671,
1083,
358,
267,
394,
275,
333,
14,
11453,
342,
267,
291,
14,
629,
8,
4097,
495,
8,
77,
14,
5671,
4000,
394,
9,
339,
347,
511,
63,
9629,
63,
873,
8,
277,
304,
267,
282,
305,
275,
283,
65,
7,
627,
5049,
267,
506,
397,
275,
283,
66,
7,
627,
5049,
267,
10142,
397,
275,
283,
67,
7,
627,
5049,
398,
333,
17,
275,
6128,
21,
342,
267,
333,
17,
14,
873,
8,
65,
305,
9,
267,
333,
17,
14,
873,
8,
1235,
397,
9,
267,
333,
17,
14,
873,
8,
301,
397,
9,
398,
333,
18,
275,
6128,
21,
342,
267,
333,
18,
14,
873,
8,
65,
305,
435,
506,
397,
435,
10142,
397,
9,
267,
291,
14,
629,
8,
77,
17,
14,
5671,
1062,
333,
18,
14,
5671,
1012,
199,
199,
318,
511,
63,
973,
837,
272,
511,
63,
4058,
14,
1065,
63,
2796,
8,
5127,
21,
63,
774,
9,
199,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
272,
511,
63,
973,
342,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
repotvsupertuga/repo
|
plugin.video.sportsmix/requests/packages/urllib3/poolmanager.py
|
678
|
9406
|
import logging
try: # Python 3
from urllib.parse import urljoin
except ImportError:
from urlparse import urljoin
from ._collections import RecentlyUsedContainer
from .connectionpool import HTTPConnectionPool, HTTPSConnectionPool
from .connectionpool import port_by_scheme
from .exceptions import LocationValueError, MaxRetryError
from .request import RequestMethods
from .util.url import parse_url
from .util.retry import Retry
__all__ = ['PoolManager', 'ProxyManager', 'proxy_from_url']
pool_classes_by_scheme = {
'http': HTTPConnectionPool,
'https': HTTPSConnectionPool,
}
log = logging.getLogger(__name__)
SSL_KEYWORDS = ('key_file', 'cert_file', 'cert_reqs', 'ca_certs',
'ssl_version')
class PoolManager(RequestMethods):
"""
Allows for arbitrary requests while transparently keeping track of
necessary connection pools for you.
:param num_pools:
Number of connection pools to cache before discarding the least
recently used pool.
:param headers:
Headers to include with all requests, unless other headers are given
explicitly.
:param \**connection_pool_kw:
Additional parameters are used to create fresh
:class:`urllib3.connectionpool.ConnectionPool` instances.
Example::
>>> manager = PoolManager(num_pools=2)
>>> r = manager.request('GET', 'http://google.com/')
>>> r = manager.request('GET', 'http://google.com/mail')
>>> r = manager.request('GET', 'http://yahoo.com/')
>>> len(manager.pools)
2
"""
proxy = None
def __init__(self, num_pools=10, headers=None, **connection_pool_kw):
RequestMethods.__init__(self, headers)
self.connection_pool_kw = connection_pool_kw
self.pools = RecentlyUsedContainer(num_pools,
dispose_func=lambda p: p.close())
def __enter__(self):
return self
def __exit__(self, exc_type, exc_val, exc_tb):
self.clear()
# Return False to re-raise any potential exceptions
return False
def _new_pool(self, scheme, host, port):
"""
Create a new :class:`ConnectionPool` based on host, port and scheme.
This method is used to actually create the connection pools handed out
by :meth:`connection_from_url` and companion methods. It is intended
to be overridden for customization.
"""
pool_cls = pool_classes_by_scheme[scheme]
kwargs = self.connection_pool_kw
if scheme == 'http':
kwargs = self.connection_pool_kw.copy()
for kw in SSL_KEYWORDS:
kwargs.pop(kw, None)
return pool_cls(host, port, **kwargs)
def clear(self):
"""
Empty our store of pools and direct them all to close.
This will not affect in-flight connections, but they will not be
re-used after completion.
"""
self.pools.clear()
def connection_from_host(self, host, port=None, scheme='http'):
"""
Get a :class:`ConnectionPool` based on the host, port, and scheme.
If ``port`` isn't given, it will be derived from the ``scheme`` using
``urllib3.connectionpool.port_by_scheme``.
"""
if not host:
raise LocationValueError("No host specified.")
scheme = scheme or 'http'
port = port or port_by_scheme.get(scheme, 80)
pool_key = (scheme, host, port)
with self.pools.lock:
# If the scheme, host, or port doesn't match existing open
# connections, open a new ConnectionPool.
pool = self.pools.get(pool_key)
if pool:
return pool
# Make a fresh ConnectionPool of the desired type
pool = self._new_pool(scheme, host, port)
self.pools[pool_key] = pool
return pool
def connection_from_url(self, url):
"""
Similar to :func:`urllib3.connectionpool.connection_from_url` but
doesn't pass any additional parameters to the
:class:`urllib3.connectionpool.ConnectionPool` constructor.
Additional parameters are taken from the :class:`.PoolManager`
constructor.
"""
u = parse_url(url)
return self.connection_from_host(u.host, port=u.port, scheme=u.scheme)
def urlopen(self, method, url, redirect=True, **kw):
"""
Same as :meth:`urllib3.connectionpool.HTTPConnectionPool.urlopen`
with custom cross-host redirect logic and only sends the request-uri
portion of the ``url``.
The given ``url`` parameter must be absolute, such that an appropriate
:class:`urllib3.connectionpool.ConnectionPool` can be chosen for it.
"""
u = parse_url(url)
conn = self.connection_from_host(u.host, port=u.port, scheme=u.scheme)
kw['assert_same_host'] = False
kw['redirect'] = False
if 'headers' not in kw:
kw['headers'] = self.headers
if self.proxy is not None and u.scheme == "http":
response = conn.urlopen(method, url, **kw)
else:
response = conn.urlopen(method, u.request_uri, **kw)
redirect_location = redirect and response.get_redirect_location()
if not redirect_location:
return response
# Support relative URLs for redirecting.
redirect_location = urljoin(url, redirect_location)
# RFC 7231, Section 6.4.4
if response.status == 303:
method = 'GET'
retries = kw.get('retries')
if not isinstance(retries, Retry):
retries = Retry.from_int(retries, redirect=redirect)
try:
retries = retries.increment(method, url, response=response, _pool=conn)
except MaxRetryError:
if retries.raise_on_redirect:
raise
return response
kw['retries'] = retries
kw['redirect'] = redirect
log.info("Redirecting %s -> %s" % (url, redirect_location))
return self.urlopen(method, redirect_location, **kw)
class ProxyManager(PoolManager):
"""
Behaves just like :class:`PoolManager`, but sends all requests through
the defined proxy, using the CONNECT method for HTTPS URLs.
:param proxy_url:
The URL of the proxy to be used.
:param proxy_headers:
A dictionary contaning headers that will be sent to the proxy. In case
of HTTP they are being sent with each request, while in the
HTTPS/CONNECT case they are sent only once. Could be used for proxy
authentication.
Example:
>>> proxy = urllib3.ProxyManager('http://localhost:3128/')
>>> r1 = proxy.request('GET', 'http://google.com/')
>>> r2 = proxy.request('GET', 'http://httpbin.org/')
>>> len(proxy.pools)
1
>>> r3 = proxy.request('GET', 'https://httpbin.org/')
>>> r4 = proxy.request('GET', 'https://twitter.com/')
>>> len(proxy.pools)
3
"""
def __init__(self, proxy_url, num_pools=10, headers=None,
proxy_headers=None, **connection_pool_kw):
if isinstance(proxy_url, HTTPConnectionPool):
proxy_url = '%s://%s:%i' % (proxy_url.scheme, proxy_url.host,
proxy_url.port)
proxy = parse_url(proxy_url)
if not proxy.port:
port = port_by_scheme.get(proxy.scheme, 80)
proxy = proxy._replace(port=port)
assert proxy.scheme in ("http", "https"), \
'Not supported proxy scheme %s' % proxy.scheme
self.proxy = proxy
self.proxy_headers = proxy_headers or {}
connection_pool_kw['_proxy'] = self.proxy
connection_pool_kw['_proxy_headers'] = self.proxy_headers
super(ProxyManager, self).__init__(
num_pools, headers, **connection_pool_kw)
def connection_from_host(self, host, port=None, scheme='http'):
if scheme == "https":
return super(ProxyManager, self).connection_from_host(
host, port, scheme)
return super(ProxyManager, self).connection_from_host(
self.proxy.host, self.proxy.port, self.proxy.scheme)
def _set_proxy_headers(self, url, headers=None):
"""
Sets headers needed by proxies: specifically, the Accept and Host
headers. Only sets headers not provided by the user.
"""
headers_ = {'Accept': '*/*'}
netloc = parse_url(url).netloc
if netloc:
headers_['Host'] = netloc
if headers:
headers_.update(headers)
return headers_
def urlopen(self, method, url, redirect=True, **kw):
"Same as HTTP(S)ConnectionPool.urlopen, ``url`` must be absolute."
u = parse_url(url)
if u.scheme == "http":
# For proxied HTTPS requests, httplib sets the necessary headers
# on the CONNECT to the proxy. For HTTP, we'll definitely
# need to set 'Host' at the very least.
headers = kw.get('headers', self.headers)
kw['headers'] = self._set_proxy_headers(url, headers)
return super(ProxyManager, self).urlopen(method, url, redirect=redirect, **kw)
def proxy_from_url(url, **kw):
return ProxyManager(proxy_url=url, **kw)
|
gpl-2.0
|
[
646,
2050,
199,
199,
893,
26,
221,
327,
2018,
650,
272,
687,
4011,
14,
1122,
492,
20818,
199,
2590,
3545,
26,
272,
687,
7097,
492,
20818,
199,
199,
504,
13653,
7882,
492,
799,
2946,
590,
9167,
4076,
199,
504,
1275,
2105,
2293,
492,
3101,
23929,
12,
14147,
23929,
199,
504,
1275,
2105,
2293,
492,
1844,
63,
991,
63,
5512,
199,
504,
1275,
3924,
492,
12625,
3393,
12,
8228,
12989,
547,
199,
504,
1275,
1069,
492,
4784,
10385,
199,
504,
1275,
1974,
14,
633,
492,
2198,
63,
633,
199,
504,
1275,
1974,
14,
7154,
492,
20506,
421,
199,
363,
452,
363,
275,
788,
5453,
2988,
297,
283,
4936,
2988,
297,
283,
3280,
63,
504,
63,
633,
418,
421,
199,
2293,
63,
2888,
63,
991,
63,
5512,
275,
469,
272,
283,
1014,
356,
3101,
23929,
12,
272,
283,
2859,
356,
14147,
23929,
12,
199,
93,
199,
199,
793,
275,
2050,
14,
5572,
3460,
354,
3368,
199,
199,
5413,
63,
32187,
275,
661,
498,
63,
493,
297,
283,
4736,
63,
493,
297,
283,
4736,
63,
12720,
297,
283,
696,
63,
8356,
297,
355,
283,
4266,
63,
1023,
358,
421,
199,
533,
15553,
2988,
8,
2017,
10385,
304,
272,
408,
272,
22819,
367,
9697,
4145,
1830,
17265,
590,
22181,
4426,
402,
272,
5784,
1950,
20092,
367,
1265,
14,
339,
520,
635,
1967,
63,
12406,
26,
267,
4860,
402,
1950,
20092,
370,
2581,
2544,
16895,
316,
314,
5210,
267,
23568,
1202,
4203,
14,
339,
520,
635,
2323,
26,
267,
21391,
370,
2387,
543,
1006,
4145,
12,
7444,
1163,
2323,
787,
1627,
267,
7662,
14,
339,
520,
635,
971,
538,
2105,
63,
2293,
63,
829,
26,
267,
10961,
2633,
787,
1202,
370,
1218,
17480,
267,
520,
533,
1705,
4078,
19,
14,
2105,
2293,
14,
23929,
64,
4454,
14,
339,
5679,
447,
398,
1306,
5256,
275,
15553,
2988,
8,
1507,
63,
12406,
29,
18,
9,
267,
1306,
519,
275,
5256,
14,
1069,
360,
2970,
297,
283,
1014,
921,
3098,
14,
957,
6217,
267,
1306,
519,
275,
5256,
14,
1069,
360,
2970,
297,
283,
1014,
921,
3098,
14,
957,
15,
1198,
358,
267,
1306,
519,
275,
5256,
14,
1069,
360,
2970,
297,
283,
1014,
921,
27231,
14,
957,
6217,
267,
1306,
822,
8,
2609,
14,
12406,
9,
267,
499,
339,
408,
339,
4566,
275,
488,
339,
347,
636,
826,
721,
277,
12,
1967,
63,
12406,
29,
709,
12,
2323,
29,
403,
12,
1011,
2105,
63,
2293,
63,
829,
304,
267,
4784,
10385,
855,
826,
721,
277,
12,
2323,
9,
267,
291,
14,
2105,
63,
2293,
63,
829,
275,
1950,
63,
2293,
63,
829,
267,
291,
14,
12406,
275,
799,
2946,
590,
9167,
4076,
8,
1507,
63,
12406,
12,
5644,
2153,
4070,
63,
1532,
29,
2734,
299,
26,
299,
14,
1600,
1012,
339,
347,
636,
4200,
721,
277,
304,
267,
372,
291,
339,
347,
636,
2224,
721,
277,
12,
3178,
63,
466,
12,
3178,
63,
637,
12,
3178,
63,
5842,
304,
267,
291,
14,
3584,
342,
267,
327,
1432,
756,
370,
295,
13,
3730,
1263,
12330,
4967,
267,
372,
756,
339,
347,
485,
1222,
63,
2293,
8,
277,
12,
5687,
12,
1591,
12,
1844,
304,
267,
408,
267,
2790,
282,
892,
520,
533,
1705,
23929,
64,
4079,
641,
1591,
12,
1844,
436,
5687,
14,
398,
961,
1083,
365,
1202,
370,
5965,
1218,
314,
1950,
20092,
394,
7028,
734,
267,
701,
520,
5247,
1705,
2105,
63,
504,
63,
633,
64,
436,
1013,
32012,
3102,
14,
2779,
365,
11619,
267,
370,
506,
10087,
367,
32715,
14,
267,
408,
267,
4203,
63,
1886,
275,
4203,
63,
2888,
63,
991,
63,
5512,
59,
5512,
61,
267,
2074,
275,
291,
14,
2105,
63,
2293,
63,
829,
267,
340,
5687,
508,
283,
1014,
356,
288,
2074,
275,
291,
14,
2105,
63,
2293,
63,
829,
14,
1574,
342,
288,
367,
4775,
315,
7799,
63,
32187,
26,
355,
2074,
14,
1935,
8,
829,
12,
488,
9,
398,
372,
4203,
63,
1886,
8,
1102,
12,
1844,
12,
1011,
958,
9,
339,
347,
5436,
8,
277,
304,
267,
408,
267,
9630,
4154,
3877,
402,
20092,
436,
4125,
3062,
1006,
370,
4002,
14,
398,
961,
911,
440,
12787,
315,
13,
28807,
6947,
12,
1325,
2985,
911,
440,
506,
267,
295,
13,
2972,
2410,
13659,
14,
267,
408,
267,
291,
14,
12406,
14,
3584,
342,
339,
347,
1950,
63,
504,
63,
1102,
8,
277,
12,
1591,
12,
1844,
29,
403,
12,
5687,
534,
1014,
735,
267,
408,
267,
2372,
282,
520,
533,
1705,
23929,
64,
4079,
641,
314,
1591,
12,
1844,
12,
436,
5687,
14,
398,
982,
1124,
719,
1040,
5712,
1133,
1627,
12,
652,
911,
506,
7131,
687,
314,
1124,
5512,
1040,
1808,
267,
1124,
4078,
19,
14,
2105,
2293,
14,
719,
63,
991,
63,
5512,
4345,
267,
408,
398,
340,
440,
1591,
26,
288,
746,
12625,
3393,
480,
1944,
1591,
2013,
2685,
398,
5687,
275,
5687,
503,
283,
1014,
7,
267,
1844,
275,
1844,
503,
1844,
63,
991,
63,
5512,
14,
362,
8,
5512,
12,
5939,
9,
267,
4203,
63,
498,
275,
334,
5512,
12,
1591,
12,
1844,
9,
398,
543,
291,
14,
12406,
14,
831,
26,
288,
327,
982,
314,
5687,
12,
1591,
12,
503,
1844,
3181,
1133,
1336,
3411,
1551,
288,
327,
6947,
12,
1551,
282,
892,
8113,
5453,
14,
288,
4203,
275,
291,
14,
12406,
14,
362,
8,
2293,
63,
498,
9,
288,
340,
4203,
26,
355,
372,
4203,
953,
327,
4155,
282,
17480,
8113,
5453,
402,
314,
6387,
730,
288,
4203,
275,
291,
423,
1222,
63,
2293,
8,
5512,
12,
1591,
12,
1844,
9,
288,
291,
14,
12406,
59,
2293,
63,
498,
61,
275,
4203,
398,
372,
4203,
339,
347,
1950,
63,
504,
63,
633,
8,
277,
12,
1166,
304,
267,
408,
267,
20046,
370,
520,
1532,
1705,
4078,
19,
14,
2105,
2293,
14,
2105,
63,
504,
63,
633,
64,
1325,
267,
3181,
1133,
986,
1263,
4722,
2633,
370,
314,
267,
520,
533,
1705,
4078,
19,
14,
2105,
2293,
14,
23929,
64,
3787,
14,
398,
10961,
2633,
787,
9394,
687,
314,
520,
533,
5026,
5453,
2988,
64,
267,
3787,
14,
267,
408,
267,
399,
275,
2198,
63,
633,
8,
633,
9,
267,
372,
291,
14,
2105,
63,
504,
63,
1102,
8,
85,
14,
1102,
12,
1844,
29,
85,
14
] |
[
2050,
199,
199,
893,
26,
221,
327,
2018,
650,
272,
687,
4011,
14,
1122,
492,
20818,
199,
2590,
3545,
26,
272,
687,
7097,
492,
20818,
199,
199,
504,
13653,
7882,
492,
799,
2946,
590,
9167,
4076,
199,
504,
1275,
2105,
2293,
492,
3101,
23929,
12,
14147,
23929,
199,
504,
1275,
2105,
2293,
492,
1844,
63,
991,
63,
5512,
199,
504,
1275,
3924,
492,
12625,
3393,
12,
8228,
12989,
547,
199,
504,
1275,
1069,
492,
4784,
10385,
199,
504,
1275,
1974,
14,
633,
492,
2198,
63,
633,
199,
504,
1275,
1974,
14,
7154,
492,
20506,
421,
199,
363,
452,
363,
275,
788,
5453,
2988,
297,
283,
4936,
2988,
297,
283,
3280,
63,
504,
63,
633,
418,
421,
199,
2293,
63,
2888,
63,
991,
63,
5512,
275,
469,
272,
283,
1014,
356,
3101,
23929,
12,
272,
283,
2859,
356,
14147,
23929,
12,
199,
93,
199,
199,
793,
275,
2050,
14,
5572,
3460,
354,
3368,
199,
199,
5413,
63,
32187,
275,
661,
498,
63,
493,
297,
283,
4736,
63,
493,
297,
283,
4736,
63,
12720,
297,
283,
696,
63,
8356,
297,
355,
283,
4266,
63,
1023,
358,
421,
199,
533,
15553,
2988,
8,
2017,
10385,
304,
272,
408,
272,
22819,
367,
9697,
4145,
1830,
17265,
590,
22181,
4426,
402,
272,
5784,
1950,
20092,
367,
1265,
14,
339,
520,
635,
1967,
63,
12406,
26,
267,
4860,
402,
1950,
20092,
370,
2581,
2544,
16895,
316,
314,
5210,
267,
23568,
1202,
4203,
14,
339,
520,
635,
2323,
26,
267,
21391,
370,
2387,
543,
1006,
4145,
12,
7444,
1163,
2323,
787,
1627,
267,
7662,
14,
339,
520,
635,
971,
538,
2105,
63,
2293,
63,
829,
26,
267,
10961,
2633,
787,
1202,
370,
1218,
17480,
267,
520,
533,
1705,
4078,
19,
14,
2105,
2293,
14,
23929,
64,
4454,
14,
339,
5679,
447,
398,
1306,
5256,
275,
15553,
2988,
8,
1507,
63,
12406,
29,
18,
9,
267,
1306,
519,
275,
5256,
14,
1069,
360,
2970,
297,
283,
1014,
921,
3098,
14,
957,
6217,
267,
1306,
519,
275,
5256,
14,
1069,
360,
2970,
297,
283,
1014,
921,
3098,
14,
957,
15,
1198,
358,
267,
1306,
519,
275,
5256,
14,
1069,
360,
2970,
297,
283,
1014,
921,
27231,
14,
957,
6217,
267,
1306,
822,
8,
2609,
14,
12406,
9,
267,
499,
339,
408,
339,
4566,
275,
488,
339,
347,
636,
826,
721,
277,
12,
1967,
63,
12406,
29,
709,
12,
2323,
29,
403,
12,
1011,
2105,
63,
2293,
63,
829,
304,
267,
4784,
10385,
855,
826,
721,
277,
12,
2323,
9,
267,
291,
14,
2105,
63,
2293,
63,
829,
275,
1950,
63,
2293,
63,
829,
267,
291,
14,
12406,
275,
799,
2946,
590,
9167,
4076,
8,
1507,
63,
12406,
12,
5644,
2153,
4070,
63,
1532,
29,
2734,
299,
26,
299,
14,
1600,
1012,
339,
347,
636,
4200,
721,
277,
304,
267,
372,
291,
339,
347,
636,
2224,
721,
277,
12,
3178,
63,
466,
12,
3178,
63,
637,
12,
3178,
63,
5842,
304,
267,
291,
14,
3584,
342,
267,
327,
1432,
756,
370,
295,
13,
3730,
1263,
12330,
4967,
267,
372,
756,
339,
347,
485,
1222,
63,
2293,
8,
277,
12,
5687,
12,
1591,
12,
1844,
304,
267,
408,
267,
2790,
282,
892,
520,
533,
1705,
23929,
64,
4079,
641,
1591,
12,
1844,
436,
5687,
14,
398,
961,
1083,
365,
1202,
370,
5965,
1218,
314,
1950,
20092,
394,
7028,
734,
267,
701,
520,
5247,
1705,
2105,
63,
504,
63,
633,
64,
436,
1013,
32012,
3102,
14,
2779,
365,
11619,
267,
370,
506,
10087,
367,
32715,
14,
267,
408,
267,
4203,
63,
1886,
275,
4203,
63,
2888,
63,
991,
63,
5512,
59,
5512,
61,
267,
2074,
275,
291,
14,
2105,
63,
2293,
63,
829,
267,
340,
5687,
508,
283,
1014,
356,
288,
2074,
275,
291,
14,
2105,
63,
2293,
63,
829,
14,
1574,
342,
288,
367,
4775,
315,
7799,
63,
32187,
26,
355,
2074,
14,
1935,
8,
829,
12,
488,
9,
398,
372,
4203,
63,
1886,
8,
1102,
12,
1844,
12,
1011,
958,
9,
339,
347,
5436,
8,
277,
304,
267,
408,
267,
9630,
4154,
3877,
402,
20092,
436,
4125,
3062,
1006,
370,
4002,
14,
398,
961,
911,
440,
12787,
315,
13,
28807,
6947,
12,
1325,
2985,
911,
440,
506,
267,
295,
13,
2972,
2410,
13659,
14,
267,
408,
267,
291,
14,
12406,
14,
3584,
342,
339,
347,
1950,
63,
504,
63,
1102,
8,
277,
12,
1591,
12,
1844,
29,
403,
12,
5687,
534,
1014,
735,
267,
408,
267,
2372,
282,
520,
533,
1705,
23929,
64,
4079,
641,
314,
1591,
12,
1844,
12,
436,
5687,
14,
398,
982,
1124,
719,
1040,
5712,
1133,
1627,
12,
652,
911,
506,
7131,
687,
314,
1124,
5512,
1040,
1808,
267,
1124,
4078,
19,
14,
2105,
2293,
14,
719,
63,
991,
63,
5512,
4345,
267,
408,
398,
340,
440,
1591,
26,
288,
746,
12625,
3393,
480,
1944,
1591,
2013,
2685,
398,
5687,
275,
5687,
503,
283,
1014,
7,
267,
1844,
275,
1844,
503,
1844,
63,
991,
63,
5512,
14,
362,
8,
5512,
12,
5939,
9,
267,
4203,
63,
498,
275,
334,
5512,
12,
1591,
12,
1844,
9,
398,
543,
291,
14,
12406,
14,
831,
26,
288,
327,
982,
314,
5687,
12,
1591,
12,
503,
1844,
3181,
1133,
1336,
3411,
1551,
288,
327,
6947,
12,
1551,
282,
892,
8113,
5453,
14,
288,
4203,
275,
291,
14,
12406,
14,
362,
8,
2293,
63,
498,
9,
288,
340,
4203,
26,
355,
372,
4203,
953,
327,
4155,
282,
17480,
8113,
5453,
402,
314,
6387,
730,
288,
4203,
275,
291,
423,
1222,
63,
2293,
8,
5512,
12,
1591,
12,
1844,
9,
288,
291,
14,
12406,
59,
2293,
63,
498,
61,
275,
4203,
398,
372,
4203,
339,
347,
1950,
63,
504,
63,
633,
8,
277,
12,
1166,
304,
267,
408,
267,
20046,
370,
520,
1532,
1705,
4078,
19,
14,
2105,
2293,
14,
2105,
63,
504,
63,
633,
64,
1325,
267,
3181,
1133,
986,
1263,
4722,
2633,
370,
314,
267,
520,
533,
1705,
4078,
19,
14,
2105,
2293,
14,
23929,
64,
3787,
14,
398,
10961,
2633,
787,
9394,
687,
314,
520,
533,
5026,
5453,
2988,
64,
267,
3787,
14,
267,
408,
267,
399,
275,
2198,
63,
633,
8,
633,
9,
267,
372,
291,
14,
2105,
63,
504,
63,
1102,
8,
85,
14,
1102,
12,
1844,
29,
85,
14,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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