content
stringlengths 1
1.04M
| input_ids
sequencelengths 1
774k
| ratio_char_token
float64 0.38
22.9
| token_count
int64 1
774k
|
---|---|---|---|
from unittest import TestCase
| [
6738,
555,
715,
395,
1330,
6208,
20448,
628
] | 3.875 | 8 |
greeting_message = '''
Hi John,
We have received your purchase request successfully. We'll email you when after the package is dispatched.
Thanks,
Support Team
'''
print(greeting_message)
| [
70,
2871,
278,
62,
20500,
796,
705,
7061,
198,
198,
17250,
1757,
11,
198,
198,
1135,
423,
2722,
534,
5001,
2581,
7675,
13,
775,
1183,
3053,
345,
618,
706,
262,
5301,
318,
26562,
13,
198,
198,
9690,
11,
198,
15514,
4816,
198,
198,
7061,
6,
198,
198,
4798,
7,
70,
2871,
278,
62,
20500,
8,
198
] | 3.446429 | 56 |
import numpy as np
import pandas as pd
from sklearn.model_selection import KFold, train_test_split, GroupShuffleSplit
def split_test(df, test_method='fo', test_size=.2):
"""
method of splitting data into training data and test data
Parameters
----------
df : pd.DataFrame raw data waiting for test set splitting
test_method : str, way to split test set
'fo': split by ratio
'tfo': split by ratio with timestamp
'tloo': leave one out with timestamp
'loo': leave one out
'ufo': split by ratio in user level
'utfo': time-aware split by ratio in user level
test_size : float, size of test set
Returns
-------
train_set : pd.DataFrame training dataset
test_set : pd.DataFrame test dataset
"""
train_set, test_set = pd.DataFrame(), pd.DataFrame()
if test_method == 'ufo':
# driver_ids = df['user']
# _, driver_indices = np.unique(np.array(driver_ids), return_inverse=True)
# gss = GroupShuffleSplit(n_splits=1, test_size=test_size, random_state=2020)
# for train_idx, test_idx in gss.split(df, groups=driver_indices):
# train_set, test_set = df.loc[train_idx, :].copy(), df.loc[test_idx, :].copy()
test_idx = df.groupby('user').apply(
lambda x: x.sample(frac=test_size).index
).explode().values
train_set = df[~df.index.isin(test_idx)]
test_set = df.iloc[test_idx]
elif test_method == 'utfo':
df = df.sort_values(['user', 'timestamp']).reset_index(drop=True)
test_index = df.groupby('user').apply(time_split).explode().values
test_set = df.loc[test_index, :]
train_set = df[~df.index.isin(test_index)]
elif test_method == 'tfo':
# df = df.sample(frac=1)
df = df.sort_values(['timestamp']).reset_index(drop=True)
split_idx = int(np.ceil(len(df) * (1 - test_size)))
train_set, test_set = df.iloc[:split_idx, :].copy(), df.iloc[split_idx:, :].copy()
elif test_method == 'fo':
train_set, test_set = train_test_split(df, test_size=test_size, random_state=2019)
elif test_method == 'tloo':
# df = df.sample(frac=1)
df = df.sort_values(['timestamp']).reset_index(drop=True)
df['rank_latest'] = df.groupby(['user'])['timestamp'].rank(method='first', ascending=False)
train_set, test_set = df[df['rank_latest'] > 1].copy(), df[df['rank_latest'] == 1].copy()
del train_set['rank_latest'], test_set['rank_latest']
elif test_method == 'loo':
# # slow method
# test_set = df.groupby(['user']).apply(pd.DataFrame.sample, n=1).reset_index(drop=True)
# test_key = test_set[['user', 'item']].copy()
# train_set = df.set_index(['user', 'item']).drop(pd.MultiIndex.from_frame(test_key)).reset_index().copy()
# # quick method
test_index = df.groupby(['user']).apply(lambda grp: np.random.choice(grp.index))
test_set = df.loc[test_index, :].copy()
train_set = df[~df.index.isin(test_index)].copy()
else:
raise ValueError('Invalid data_split value, expect: loo, fo, tloo, tfo')
train_set, test_set = train_set.reset_index(drop=True), test_set.reset_index(drop=True)
return train_set, test_set
def split_validation(train_set, val_method='fo', fold_num=1, val_size=.1):
"""
method of split data into training data and validation data.
(Currently, this method returns list of train & validation set, but I'll change
it to index list or generator in future so as to save memory space) TODO
Parameters
----------
train_set : pd.DataFrame train set waiting for split validation
val_method : str, way to split validation
'cv': combine with fold_num => fold_num-CV
'fo': combine with fold_num & val_size => fold_num-Split by ratio(9:1)
'tfo': Split by ratio with timestamp, combine with val_size => 1-Split by ratio(9:1)
'tloo': Leave one out with timestamp => 1-Leave one out
'loo': combine with fold_num => fold_num-Leave one out
'ufo': split by ratio in user level with K-fold
'utfo': time-aware split by ratio in user level
fold_num : int, the number of folder need to be validated, only work when val_method is 'cv', 'loo', or 'fo'
val_size: float, the size of validation dataset
Returns
-------
train_set_list : List, list of generated training datasets
val_set_list : List, list of generated validation datasets
cnt : cnt: int, the number of train-validation pair
"""
if val_method in ['tloo', 'tfo', 'utfo']:
cnt = 1
elif val_method in ['cv', 'loo', 'fo', 'ufo']:
cnt = fold_num
else:
raise ValueError('Invalid val_method value, expect: cv, loo, tloo, tfo')
train_set_list, val_set_list = [], []
if val_method == 'ufo':
driver_ids = train_set['user']
_, driver_indices = np.unique(np.array(driver_ids), return_inverse=True)
gss = GroupShuffleSplit(n_splits=fold_num, test_size=val_size, random_state=2020)
for train_idx, val_idx in gss.split(train_set, groups=driver_indices):
train_set_list.append(train_set.loc[train_idx, :])
val_set_list.append(train_set.loc[val_idx, :])
if val_method == 'utfo':
train_set = train_set.sort_values(['user', 'timestamp']).reset_index(drop=True)
val_index = train_set.groupby('user').apply(time_split).explode().values
val_set = train_set.loc[val_index, :]
train_set = train_set[~train_set.index.isin(val_index)]
train_set_list.append(train_set)
val_set_list.append(val_set)
if val_method == 'cv':
kf = KFold(n_splits=fold_num, shuffle=False, random_state=2019)
for train_index, val_index in kf.split(train_set):
train_set_list.append(train_set.loc[train_index, :])
val_set_list.append(train_set.loc[val_index, :])
if val_method == 'fo':
for _ in range(fold_num):
train, validation = train_test_split(train_set, test_size=val_size)
train_set_list.append(train)
val_set_list.append(validation)
elif val_method == 'tfo':
# train_set = train_set.sample(frac=1)
train_set = train_set.sort_values(['timestamp']).reset_index(drop=True)
split_idx = int(np.ceil(len(train_set) * (1 - val_size)))
train_set_list.append(train_set.iloc[:split_idx, :])
val_set_list.append(train_set.iloc[split_idx:, :])
elif val_method == 'loo':
for _ in range(fold_num):
val_index = train_set.groupby(['user']).apply(lambda grp: np.random.choice(grp.index))
val_set = train_set.loc[val_index, :].reset_index(drop=True).copy()
sub_train_set = train_set[~train_set.index.isin(val_index)].reset_index(drop=True).copy()
train_set_list.append(sub_train_set)
val_set_list.append(val_set)
elif val_method == 'tloo':
# train_set = train_set.sample(frac=1)
train_set = train_set.sort_values(['timestamp']).reset_index(drop=True)
train_set['rank_latest'] = train_set.groupby(['user'])['timestamp'].rank(method='first', ascending=False)
new_train_set = train_set[train_set['rank_latest'] > 1].copy()
val_set = train_set[train_set['rank_latest'] == 1].copy()
del new_train_set['rank_latest'], val_set['rank_latest']
train_set_list.append(new_train_set)
val_set_list.append(val_set)
return train_set_list, val_set_list, cnt
| [
11748,
299,
32152,
355,
45941,
198,
11748,
19798,
292,
355,
279,
67,
198,
198,
6738,
1341,
35720,
13,
19849,
62,
49283,
1330,
509,
37,
727,
11,
4512,
62,
9288,
62,
35312,
11,
4912,
2484,
18137,
41205,
198,
198,
4299,
6626,
62,
9288,
7,
7568,
11,
1332,
62,
24396,
11639,
6513,
3256,
1332,
62,
7857,
28,
13,
17,
2599,
198,
220,
220,
220,
37227,
198,
220,
220,
220,
2446,
286,
26021,
1366,
656,
3047,
1366,
290,
1332,
1366,
198,
220,
220,
220,
40117,
198,
220,
220,
220,
24200,
438,
198,
220,
220,
220,
47764,
1058,
279,
67,
13,
6601,
19778,
8246,
1366,
4953,
329,
1332,
900,
26021,
198,
220,
220,
220,
1332,
62,
24396,
1058,
965,
11,
835,
284,
6626,
1332,
900,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
705,
6513,
10354,
6626,
416,
8064,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
705,
83,
6513,
10354,
6626,
416,
8064,
351,
41033,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
705,
28781,
2238,
10354,
2666,
530,
503,
351,
41033,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
705,
29680,
10354,
2666,
530,
503,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
705,
3046,
78,
10354,
6626,
416,
8064,
287,
2836,
1241,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
705,
315,
6513,
10354,
640,
12,
9685,
6626,
416,
8064,
287,
2836,
1241,
198,
220,
220,
220,
1332,
62,
7857,
1058,
12178,
11,
2546,
286,
1332,
900,
628,
220,
220,
220,
16409,
198,
220,
220,
220,
35656,
198,
220,
220,
220,
4512,
62,
2617,
1058,
279,
67,
13,
6601,
19778,
3047,
27039,
198,
220,
220,
220,
1332,
62,
2617,
1058,
279,
67,
13,
6601,
19778,
1332,
27039,
628,
220,
220,
220,
37227,
628,
220,
220,
220,
4512,
62,
2617,
11,
1332,
62,
2617,
796,
279,
67,
13,
6601,
19778,
22784,
279,
67,
13,
6601,
19778,
3419,
198,
220,
220,
220,
611,
1332,
62,
24396,
6624,
705,
3046,
78,
10354,
198,
220,
220,
220,
220,
220,
220,
220,
1303,
4639,
62,
2340,
796,
47764,
17816,
7220,
20520,
198,
220,
220,
220,
220,
220,
220,
220,
1303,
4808,
11,
4639,
62,
521,
1063,
796,
45941,
13,
34642,
7,
37659,
13,
18747,
7,
26230,
62,
2340,
828,
1441,
62,
259,
4399,
28,
17821,
8,
198,
220,
220,
220,
220,
220,
220,
220,
1303,
308,
824,
796,
4912,
2484,
18137,
41205,
7,
77,
62,
22018,
896,
28,
16,
11,
1332,
62,
7857,
28,
9288,
62,
7857,
11,
4738,
62,
5219,
28,
42334,
8,
198,
220,
220,
220,
220,
220,
220,
220,
1303,
329,
4512,
62,
312,
87,
11,
1332,
62,
312,
87,
287,
308,
824,
13,
35312,
7,
7568,
11,
2628,
28,
26230,
62,
521,
1063,
2599,
198,
220,
220,
220,
220,
220,
220,
220,
1303,
220,
220,
220,
220,
4512,
62,
2617,
11,
1332,
62,
2617,
796,
47764,
13,
17946,
58,
27432,
62,
312,
87,
11,
1058,
4083,
30073,
22784,
47764,
13,
17946,
58,
9288,
62,
312,
87,
11,
1058,
4083,
30073,
3419,
198,
220,
220,
220,
220,
220,
220,
220,
1332,
62,
312,
87,
796,
47764,
13,
8094,
1525,
10786,
7220,
27691,
39014,
7,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
37456,
2124,
25,
2124,
13,
39873,
7,
31944,
28,
9288,
62,
7857,
737,
9630,
198,
220,
220,
220,
220,
220,
220,
220,
6739,
20676,
1098,
22446,
27160,
198,
220,
220,
220,
220,
220,
220,
220,
4512,
62,
2617,
796,
47764,
58,
93,
7568,
13,
9630,
13,
45763,
7,
9288,
62,
312,
87,
15437,
198,
220,
220,
220,
220,
220,
220,
220,
1332,
62,
2617,
796,
47764,
13,
346,
420,
58,
9288,
62,
312,
87,
60,
628,
220,
220,
220,
1288,
361,
1332,
62,
24396,
6624,
705,
315,
6513,
10354,
198,
220,
220,
220,
220,
220,
220,
220,
47764,
796,
47764,
13,
30619,
62,
27160,
7,
17816,
7220,
3256,
705,
16514,
27823,
20520,
737,
42503,
62,
9630,
7,
14781,
28,
17821,
8,
628,
220,
220,
220,
220,
220,
220,
220,
1332,
62,
9630,
796,
47764,
13,
8094,
1525,
10786,
7220,
27691,
39014,
7,
2435,
62,
35312,
737,
20676,
1098,
22446,
27160,
198,
220,
220,
220,
220,
220,
220,
220,
1332,
62,
2617,
796,
47764,
13,
17946,
58,
9288,
62,
9630,
11,
1058,
60,
198,
220,
220,
220,
220,
220,
220,
220,
4512,
62,
2617,
796,
47764,
58,
93,
7568,
13,
9630,
13,
45763,
7,
9288,
62,
9630,
15437,
628,
220,
220,
220,
1288,
361,
1332,
62,
24396,
6624,
705,
83,
6513,
10354,
198,
220,
220,
220,
220,
220,
220,
220,
1303,
47764,
796,
47764,
13,
39873,
7,
31944,
28,
16,
8,
198,
220,
220,
220,
220,
220,
220,
220,
47764,
796,
47764,
13,
30619,
62,
27160,
7,
17816,
16514,
27823,
20520,
737,
42503,
62,
9630,
7,
14781,
28,
17821,
8,
198,
220,
220,
220,
220,
220,
220,
220,
6626,
62,
312,
87,
796,
493,
7,
37659,
13,
344,
346,
7,
11925,
7,
7568,
8,
1635,
357,
16,
532,
1332,
62,
7857,
22305,
198,
220,
220,
220,
220,
220,
220,
220,
4512,
62,
2617,
11,
1332,
62,
2617,
796,
47764,
13,
346,
420,
58,
25,
35312,
62,
312,
87,
11,
1058,
4083,
30073,
22784,
47764,
13,
346,
420,
58,
35312,
62,
312,
87,
45299,
1058,
4083,
30073,
3419,
628,
220,
220,
220,
1288,
361,
1332,
62,
24396,
6624,
705,
6513,
10354,
198,
220,
220,
220,
220,
220,
220,
220,
4512,
62,
2617,
11,
1332,
62,
2617,
796,
4512,
62,
9288,
62,
35312,
7,
7568,
11,
1332,
62,
7857,
28,
9288,
62,
7857,
11,
4738,
62,
5219,
28,
23344,
8,
628,
220,
220,
220,
1288,
361,
1332,
62,
24396,
6624,
705,
28781,
2238,
10354,
198,
220,
220,
220,
220,
220,
220,
220,
1303,
47764,
796,
47764,
13,
39873,
7,
31944,
28,
16,
8,
198,
220,
220,
220,
220,
220,
220,
220,
47764,
796,
47764,
13,
30619,
62,
27160,
7,
17816,
16514,
27823,
20520,
737,
42503,
62,
9630,
7,
14781,
28,
17821,
8,
198,
220,
220,
220,
220,
220,
220,
220,
47764,
17816,
43027,
62,
42861,
20520,
796,
47764,
13,
8094,
1525,
7,
17816,
7220,
6,
12962,
17816,
16514,
27823,
6,
4083,
43027,
7,
24396,
11639,
11085,
3256,
41988,
28,
25101,
8,
198,
220,
220,
220,
220,
220,
220,
220,
4512,
62,
2617,
11,
1332,
62,
2617,
796,
47764,
58,
7568,
17816,
43027,
62,
42861,
20520,
1875,
352,
4083,
30073,
22784,
47764,
58,
7568,
17816,
43027,
62,
42861,
20520,
6624,
352,
4083,
30073,
3419,
198,
220,
220,
220,
220,
220,
220,
220,
1619,
4512,
62,
2617,
17816,
43027,
62,
42861,
6,
4357,
1332,
62,
2617,
17816,
43027,
62,
42861,
20520,
628,
220,
220,
220,
1288,
361,
1332,
62,
24396,
6624,
705,
29680,
10354,
198,
220,
220,
220,
220,
220,
220,
220,
1303,
1303,
3105,
2446,
198,
220,
220,
220,
220,
220,
220,
220,
1303,
1332,
62,
2617,
796,
47764,
13,
8094,
1525,
7,
17816,
7220,
20520,
737,
39014,
7,
30094,
13,
6601,
19778,
13,
39873,
11,
299,
28,
16,
737,
42503,
62,
9630,
7,
14781,
28,
17821,
8,
198,
220,
220,
220,
220,
220,
220,
220,
1303,
1332,
62,
2539,
796,
1332,
62,
2617,
58,
17816,
7220,
3256,
705,
9186,
20520,
4083,
30073,
3419,
198,
220,
220,
220,
220,
220,
220,
220,
1303,
4512,
62,
2617,
796,
47764,
13,
2617,
62,
9630,
7,
17816,
7220,
3256,
705,
9186,
20520,
737,
14781,
7,
30094,
13,
29800,
15732,
13,
6738,
62,
14535,
7,
9288,
62,
2539,
29720,
42503,
62,
9630,
22446,
30073,
3419,
628,
220,
220,
220,
220,
220,
220,
220,
1303,
1303,
2068,
2446,
198,
220,
220,
220,
220,
220,
220,
220,
1332,
62,
9630,
796,
47764,
13,
8094,
1525,
7,
17816,
7220,
20520,
737,
39014,
7,
50033,
1036,
79,
25,
45941,
13,
25120,
13,
25541,
7,
2164,
79,
13,
9630,
4008,
198,
220,
220,
220,
220,
220,
220,
220,
1332,
62,
2617,
796,
47764,
13,
17946,
58,
9288,
62,
9630,
11,
1058,
4083,
30073,
3419,
198,
220,
220,
220,
220,
220,
220,
220,
4512,
62,
2617,
796,
47764,
58,
93,
7568,
13,
9630,
13,
45763,
7,
9288,
62,
9630,
25295,
30073,
3419,
628,
220,
220,
220,
2073,
25,
198,
220,
220,
220,
220,
220,
220,
220,
5298,
11052,
12331,
10786,
44651,
1366,
62,
35312,
1988,
11,
1607,
25,
300,
2238,
11,
11511,
11,
256,
29680,
11,
256,
6513,
11537,
628,
220,
220,
220,
4512,
62,
2617,
11,
1332,
62,
2617,
796,
4512,
62,
2617,
13,
42503,
62,
9630,
7,
14781,
28,
17821,
828,
1332,
62,
2617,
13,
42503,
62,
9630,
7,
14781,
28,
17821,
8,
628,
220,
220,
220,
1441,
4512,
62,
2617,
11,
1332,
62,
2617,
628,
198,
4299,
6626,
62,
12102,
341,
7,
27432,
62,
2617,
11,
1188,
62,
24396,
11639,
6513,
3256,
5591,
62,
22510,
28,
16,
11,
1188,
62,
7857,
28,
13,
16,
2599,
198,
220,
220,
220,
37227,
198,
220,
220,
220,
2446,
286,
6626,
1366,
656,
3047,
1366,
290,
21201,
1366,
13,
198,
220,
220,
220,
357,
21327,
11,
428,
2446,
5860,
1351,
286,
4512,
1222,
21201,
900,
11,
475,
314,
1183,
1487,
220,
198,
220,
220,
220,
340,
284,
6376,
1351,
393,
17301,
287,
2003,
523,
355,
284,
3613,
4088,
2272,
8,
16926,
46,
628,
220,
220,
220,
40117,
198,
220,
220,
220,
24200,
438,
198,
220,
220,
220,
4512,
62,
2617,
1058,
279,
67,
13,
6601,
19778,
4512,
900,
4953,
329,
6626,
21201,
198,
220,
220,
220,
1188,
62,
24396,
1058,
965,
11,
835,
284,
6626,
21201,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
705,
33967,
10354,
12082,
351,
5591,
62,
22510,
5218,
5591,
62,
22510,
12,
33538,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
705,
6513,
10354,
12082,
351,
5591,
62,
22510,
1222,
1188,
62,
7857,
5218,
5591,
62,
22510,
12,
41205,
416,
8064,
7,
24,
25,
16,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
705,
83,
6513,
10354,
27758,
416,
8064,
351,
41033,
11,
12082,
351,
1188,
62,
7857,
5218,
352,
12,
41205,
416,
8064,
7,
24,
25,
16,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
705,
28781,
2238,
10354,
17446,
530,
503,
351,
41033,
5218,
352,
12,
35087,
530,
503,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
705,
29680,
10354,
12082,
351,
5591,
62,
22510,
5218,
5591,
62,
22510,
12,
35087,
530,
503,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
705,
3046,
78,
10354,
6626,
416,
8064,
287,
2836,
1241,
351,
509,
12,
11379,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
705,
315,
6513,
10354,
640,
12,
9685,
6626,
416,
8064,
287,
2836,
1241,
198,
220,
220,
220,
5591,
62,
22510,
1058,
493,
11,
262,
1271,
286,
9483,
761,
284,
307,
31031,
11,
691,
670,
618,
1188,
62,
24396,
318,
705,
33967,
3256,
705,
29680,
3256,
393,
705,
6513,
6,
198,
220,
220,
220,
1188,
62,
7857,
25,
12178,
11,
262,
2546,
286,
21201,
27039,
628,
220,
220,
220,
16409,
198,
220,
220,
220,
35656,
198,
220,
220,
220,
4512,
62,
2617,
62,
4868,
1058,
7343,
11,
1351,
286,
7560,
3047,
40522,
198,
220,
220,
220,
1188,
62,
2617,
62,
4868,
1058,
7343,
11,
1351,
286,
7560,
21201,
40522,
198,
220,
220,
220,
269,
429,
1058,
269,
429,
25,
493,
11,
262,
1271,
286,
4512,
12,
12102,
341,
5166,
628,
220,
220,
220,
37227,
198,
220,
220,
220,
611,
1188,
62,
24396,
287,
37250,
28781,
2238,
3256,
705,
83,
6513,
3256,
705,
315,
6513,
6,
5974,
198,
220,
220,
220,
220,
220,
220,
220,
269,
429,
796,
352,
198,
220,
220,
220,
1288,
361,
1188,
62,
24396,
287,
37250,
33967,
3256,
705,
29680,
3256,
705,
6513,
3256,
705,
3046,
78,
6,
5974,
198,
220,
220,
220,
220,
220,
220,
220,
269,
429,
796,
5591,
62,
22510,
198,
220,
220,
220,
2073,
25,
198,
220,
220,
220,
220,
220,
220,
220,
5298,
11052,
12331,
10786,
44651,
1188,
62,
24396,
1988,
11,
1607,
25,
269,
85,
11,
300,
2238,
11,
256,
29680,
11,
256,
6513,
11537,
198,
220,
220,
220,
220,
198,
220,
220,
220,
4512,
62,
2617,
62,
4868,
11,
1188,
62,
2617,
62,
4868,
796,
685,
4357,
17635,
198,
220,
220,
220,
611,
1188,
62,
24396,
6624,
705,
3046,
78,
10354,
198,
220,
220,
220,
220,
220,
220,
220,
4639,
62,
2340,
796,
4512,
62,
2617,
17816,
7220,
20520,
198,
220,
220,
220,
220,
220,
220,
220,
4808,
11,
4639,
62,
521,
1063,
796,
45941,
13,
34642,
7,
37659,
13,
18747,
7,
26230,
62,
2340,
828,
1441,
62,
259,
4399,
28,
17821,
8,
198,
220,
220,
220,
220,
220,
220,
220,
308,
824,
796,
4912,
2484,
18137,
41205,
7,
77,
62,
22018,
896,
28,
11379,
62,
22510,
11,
1332,
62,
7857,
28,
2100,
62,
7857,
11,
4738,
62,
5219,
28,
42334,
8,
198,
220,
220,
220,
220,
220,
220,
220,
329,
4512,
62,
312,
87,
11,
1188,
62,
312,
87,
287,
308,
824,
13,
35312,
7,
27432,
62,
2617,
11,
2628,
28,
26230,
62,
521,
1063,
2599,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
4512,
62,
2617,
62,
4868,
13,
33295,
7,
27432,
62,
2617,
13,
17946,
58,
27432,
62,
312,
87,
11,
1058,
12962,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1188,
62,
2617,
62,
4868,
13,
33295,
7,
27432,
62,
2617,
13,
17946,
58,
2100,
62,
312,
87,
11,
1058,
12962,
198,
220,
220,
220,
611,
1188,
62,
24396,
6624,
705,
315,
6513,
10354,
198,
220,
220,
220,
220,
220,
220,
220,
4512,
62,
2617,
796,
4512,
62,
2617,
13,
30619,
62,
27160,
7,
17816,
7220,
3256,
705,
16514,
27823,
20520,
737,
42503,
62,
9630,
7,
14781,
28,
17821,
8,
198,
220,
220,
220,
220,
220,
220,
220,
1188,
62,
9630,
796,
4512,
62,
2617,
13,
8094,
1525,
10786,
7220,
27691,
39014,
7,
2435,
62,
35312,
737,
20676,
1098,
22446,
27160,
198,
220,
220,
220,
220,
220,
220,
220,
1188,
62,
2617,
796,
4512,
62,
2617,
13,
17946,
58,
2100,
62,
9630,
11,
1058,
60,
198,
220,
220,
220,
220,
220,
220,
220,
4512,
62,
2617,
796,
4512,
62,
2617,
58,
93,
27432,
62,
2617,
13,
9630,
13,
45763,
7,
2100,
62,
9630,
15437,
198,
220,
220,
220,
220,
220,
220,
220,
4512,
62,
2617,
62,
4868,
13,
33295,
7,
27432,
62,
2617,
8,
198,
220,
220,
220,
220,
220,
220,
220,
1188,
62,
2617,
62,
4868,
13,
33295,
7,
2100,
62,
2617,
8,
198,
220,
220,
220,
611,
1188,
62,
24396,
6624,
705,
33967,
10354,
198,
220,
220,
220,
220,
220,
220,
220,
479,
69,
796,
509,
37,
727,
7,
77,
62,
22018,
896,
28,
11379,
62,
22510,
11,
36273,
28,
25101,
11,
4738,
62,
5219,
28,
23344,
8,
198,
220,
220,
220,
220,
220,
220,
220,
329,
4512,
62,
9630,
11,
1188,
62,
9630,
287,
479,
69,
13,
35312,
7,
27432,
62,
2617,
2599,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
4512,
62,
2617,
62,
4868,
13,
33295,
7,
27432,
62,
2617,
13,
17946,
58,
27432,
62,
9630,
11,
1058,
12962,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1188,
62,
2617,
62,
4868,
13,
33295,
7,
27432,
62,
2617,
13,
17946,
58,
2100,
62,
9630,
11,
1058,
12962,
198,
220,
220,
220,
611,
1188,
62,
24396,
6624,
705,
6513,
10354,
198,
220,
220,
220,
220,
220,
220,
220,
329,
4808,
287,
2837,
7,
11379,
62,
22510,
2599,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
4512,
11,
21201,
796,
4512,
62,
9288,
62,
35312,
7,
27432,
62,
2617,
11,
1332,
62,
7857,
28,
2100,
62,
7857,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
4512,
62,
2617,
62,
4868,
13,
33295,
7,
27432,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1188,
62,
2617,
62,
4868,
13,
33295,
7,
12102,
341,
8,
198,
220,
220,
220,
1288,
361,
1188,
62,
24396,
6624,
705,
83,
6513,
10354,
198,
220,
220,
220,
220,
220,
220,
220,
1303,
4512,
62,
2617,
796,
4512,
62,
2617,
13,
39873,
7,
31944,
28,
16,
8,
198,
220,
220,
220,
220,
220,
220,
220,
4512,
62,
2617,
796,
4512,
62,
2617,
13,
30619,
62,
27160,
7,
17816,
16514,
27823,
20520,
737,
42503,
62,
9630,
7,
14781,
28,
17821,
8,
198,
220,
220,
220,
220,
220,
220,
220,
6626,
62,
312,
87,
796,
493,
7,
37659,
13,
344,
346,
7,
11925,
7,
27432,
62,
2617,
8,
1635,
357,
16,
532,
1188,
62,
7857,
22305,
198,
220,
220,
220,
220,
220,
220,
220,
4512,
62,
2617,
62,
4868,
13,
33295,
7,
27432,
62,
2617,
13,
346,
420,
58,
25,
35312,
62,
312,
87,
11,
1058,
12962,
198,
220,
220,
220,
220,
220,
220,
220,
1188,
62,
2617,
62,
4868,
13,
33295,
7,
27432,
62,
2617,
13,
346,
420,
58,
35312,
62,
312,
87,
45299,
1058,
12962,
198,
220,
220,
220,
1288,
361,
1188,
62,
24396,
6624,
705,
29680,
10354,
198,
220,
220,
220,
220,
220,
220,
220,
329,
4808,
287,
2837,
7,
11379,
62,
22510,
2599,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1188,
62,
9630,
796,
4512,
62,
2617,
13,
8094,
1525,
7,
17816,
7220,
20520,
737,
39014,
7,
50033,
1036,
79,
25,
45941,
13,
25120,
13,
25541,
7,
2164,
79,
13,
9630,
4008,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1188,
62,
2617,
796,
4512,
62,
2617,
13,
17946,
58,
2100,
62,
9630,
11,
1058,
4083,
42503,
62,
9630,
7,
14781,
28,
17821,
737,
30073,
3419,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
850,
62,
27432,
62,
2617,
796,
4512,
62,
2617,
58,
93,
27432,
62,
2617,
13,
9630,
13,
45763,
7,
2100,
62,
9630,
25295,
42503,
62,
9630,
7,
14781,
28,
17821,
737,
30073,
3419,
628,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
4512,
62,
2617,
62,
4868,
13,
33295,
7,
7266,
62,
27432,
62,
2617,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1188,
62,
2617,
62,
4868,
13,
33295,
7,
2100,
62,
2617,
8,
198,
220,
220,
220,
1288,
361,
1188,
62,
24396,
6624,
705,
28781,
2238,
10354,
198,
220,
220,
220,
220,
220,
220,
220,
1303,
4512,
62,
2617,
796,
4512,
62,
2617,
13,
39873,
7,
31944,
28,
16,
8,
198,
220,
220,
220,
220,
220,
220,
220,
4512,
62,
2617,
796,
4512,
62,
2617,
13,
30619,
62,
27160,
7,
17816,
16514,
27823,
20520,
737,
42503,
62,
9630,
7,
14781,
28,
17821,
8,
628,
220,
220,
220,
220,
220,
220,
220,
4512,
62,
2617,
17816,
43027,
62,
42861,
20520,
796,
4512,
62,
2617,
13,
8094,
1525,
7,
17816,
7220,
6,
12962,
17816,
16514,
27823,
6,
4083,
43027,
7,
24396,
11639,
11085,
3256,
41988,
28,
25101,
8,
198,
220,
220,
220,
220,
220,
220,
220,
649,
62,
27432,
62,
2617,
796,
4512,
62,
2617,
58,
27432,
62,
2617,
17816,
43027,
62,
42861,
20520,
1875,
352,
4083,
30073,
3419,
198,
220,
220,
220,
220,
220,
220,
220,
1188,
62,
2617,
796,
4512,
62,
2617,
58,
27432,
62,
2617,
17816,
43027,
62,
42861,
20520,
6624,
352,
4083,
30073,
3419,
198,
220,
220,
220,
220,
220,
220,
220,
1619,
649,
62,
27432,
62,
2617,
17816,
43027,
62,
42861,
6,
4357,
1188,
62,
2617,
17816,
43027,
62,
42861,
20520,
628,
220,
220,
220,
220,
220,
220,
220,
4512,
62,
2617,
62,
4868,
13,
33295,
7,
3605,
62,
27432,
62,
2617,
8,
198,
220,
220,
220,
220,
220,
220,
220,
1188,
62,
2617,
62,
4868,
13,
33295,
7,
2100,
62,
2617,
8,
628,
220,
220,
220,
1441,
4512,
62,
2617,
62,
4868,
11,
1188,
62,
2617,
62,
4868,
11,
269,
429,
628
] | 2.282301 | 3,390 |
import requests
import os
from collections import defaultdict
import pandas as pd
from io import StringIO
from nearest_dict import NearestDict
from utils import load_stats_endpoint
if __name__ == '__main__':
EthereumStats(verbose=True, update=True) | [
11748,
7007,
198,
11748,
28686,
198,
6738,
17268,
1330,
4277,
11600,
198,
11748,
19798,
292,
355,
279,
67,
198,
6738,
33245,
1330,
10903,
9399,
198,
6738,
16936,
62,
11600,
1330,
3169,
12423,
35,
713,
198,
6738,
3384,
4487,
1330,
3440,
62,
34242,
62,
437,
4122,
198,
198,
361,
11593,
3672,
834,
6624,
705,
834,
12417,
834,
10354,
198,
220,
220,
220,
20313,
29668,
7,
19011,
577,
28,
17821,
11,
4296,
28,
17821,
8
] | 3.465753 | 73 |
# coding: utf-8
from enum import Enum
from six import string_types, iteritems
from bitmovin_api_sdk.common.poscheck import poscheck_model
| [
2,
19617,
25,
3384,
69,
12,
23,
198,
198,
6738,
33829,
1330,
2039,
388,
198,
6738,
2237,
1330,
4731,
62,
19199,
11,
11629,
23814,
198,
6738,
1643,
76,
709,
259,
62,
15042,
62,
21282,
74,
13,
11321,
13,
1930,
9122,
1330,
1426,
9122,
62,
19849,
628
] | 3.043478 | 46 |
# alias to keep the 'bytecode' variable free
import bytecode as _bytecode
from bytecode.instr import UNSET, Label, SetLineno, Instr
| [
2,
16144,
284,
1394,
262,
705,
26327,
8189,
6,
7885,
1479,
198,
11748,
18022,
8189,
355,
4808,
26327,
8189,
198,
6738,
18022,
8189,
13,
259,
2536,
1330,
4725,
28480,
11,
36052,
11,
5345,
14993,
23397,
11,
27901,
628,
628
] | 3.461538 | 39 |
#!/usr/bin/env python
# encoding: utf-8
"""
db.py
Created by José Sánchez-Gallego on 25 Oct 2015.
Licensed under a 3-clause BSD license.
Revision history:
25 Oct 2015 J. Sánchez-Gallego
Initial version
"""
from __future__ import division, print_function
from SDSSconnect import DatabaseConnection
from Totoro import config
def getConfigurationProfiles():
"""Returns a dictionary with all currently configured DB profiles."""
profiles = {}
for kk in config:
if 'dbConnection' in kk and kk != 'dbConnection':
profileName = config[kk]['name'].lower()
profiles[profileName] = config[kk]
if 'password' not in profiles[profileName]:
profiles[profileName]['password'] = ''
return profiles
def getConnection(profile=None):
"""Returns a connection.
If `profile=None`, the default connection is returned."""
# To avoid circular import errors
from Totoro.utils.utils import checkOpenSession
configProfiles = getConfigurationProfiles()
if len(DatabaseConnection.listConnections()) > 0 and profile is None:
return DatabaseConnection.getDefaultConnection()
elif len(DatabaseConnection.listConnections()) == 0 and profile is None:
# Creates the default DB connection
databaseConnectionString = (
'postgresql+psycopg2://{user}:{password}@{host}:{port}/{database}'
.format(**config['dbConnection']))
dbConn = DatabaseConnection(
databaseConnectionString=databaseConnectionString,
new=True,
name=config['dbConnection']['name'],
default=True)
checkOpenSession()
return dbConn
else:
if profile.lower() in DatabaseConnection.listConnections():
return DatabaseConnection.getConnection(profile.lower())
else:
if profile.lower() in configProfiles:
databaseConnectionString = ('postgresql+psycopg2://{user}:{password}@'
'{host}:{port}/{database}'
.format(**configProfiles[profile.lower()]))
dbConn = DatabaseConnection(
databaseConnectionString=databaseConnectionString,
new=True,
name=profile.lower())
checkOpenSession()
return dbConn
else:
raise ValueError('profile {0} does not exist'.format(profile))
def getConnectionFull(profile=None):
"""Returns a connection, its session, plateDB and mangaDB."""
dbConn = getConnection(profile=profile)
return dbConn, dbConn.Session, dbConn.plateDB, dbConn.mangaDB
def setDefaulProfile(profile):
"""Sets a profile as default."""
if len(DatabaseConnection.listConnections()) > 0:
if DatabaseConnection.getDefaultConnectionName() == 'profile':
return
if profile not in getConfigurationProfiles():
raise ValueError('profile {0} does not exist'.format(profile))
if profile in DatabaseConnection.listConnections():
DatabaseConnection.setDefaultConnection(profile)
else:
db = getConnection(profile=profile)
db.setDefaultConnection(profile)
| [
2,
48443,
14629,
14,
8800,
14,
24330,
21015,
198,
2,
21004,
25,
3384,
69,
12,
23,
198,
37811,
198,
198,
9945,
13,
9078,
198,
198,
41972,
416,
36997,
311,
21162,
2395,
89,
12,
26552,
1455,
78,
319,
1679,
2556,
1853,
13,
198,
26656,
15385,
739,
257,
513,
12,
565,
682,
347,
10305,
5964,
13,
198,
198,
18009,
1166,
2106,
25,
198,
220,
220,
220,
1679,
2556,
1853,
449,
13,
311,
21162,
2395,
89,
12,
26552,
1455,
78,
198,
220,
220,
220,
220,
220,
20768,
2196,
198,
198,
37811,
198,
198,
6738,
11593,
37443,
834,
1330,
7297,
11,
3601,
62,
8818,
198,
198,
6738,
311,
5258,
50,
8443,
1330,
24047,
32048,
198,
6738,
20323,
16522,
1330,
4566,
628,
198,
4299,
651,
38149,
15404,
2915,
33529,
198,
220,
220,
220,
37227,
35561,
257,
22155,
351,
477,
3058,
17839,
20137,
16545,
526,
15931,
628,
220,
220,
220,
16545,
796,
23884,
198,
220,
220,
220,
329,
479,
74,
287,
4566,
25,
198,
220,
220,
220,
220,
220,
220,
220,
611,
705,
9945,
32048,
6,
287,
479,
74,
290,
479,
74,
14512,
705,
9945,
32048,
10354,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
7034,
5376,
796,
4566,
58,
28747,
7131,
6,
3672,
6,
4083,
21037,
3419,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
16545,
58,
13317,
5376,
60,
796,
4566,
58,
28747,
60,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
611,
705,
28712,
6,
407,
287,
16545,
58,
13317,
5376,
5974,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
16545,
58,
13317,
5376,
7131,
6,
28712,
20520,
796,
10148,
628,
220,
220,
220,
1441,
16545,
628,
198,
4299,
651,
32048,
7,
13317,
28,
14202,
2599,
198,
220,
220,
220,
37227,
35561,
257,
4637,
13,
628,
220,
220,
220,
1002,
4600,
13317,
28,
14202,
47671,
262,
4277,
4637,
318,
4504,
526,
15931,
628,
220,
220,
220,
1303,
1675,
3368,
18620,
1330,
8563,
198,
220,
220,
220,
422,
20323,
16522,
13,
26791,
13,
26791,
1330,
2198,
11505,
36044,
628,
220,
220,
220,
4566,
15404,
2915,
796,
651,
38149,
15404,
2915,
3419,
628,
220,
220,
220,
611,
18896,
7,
38105,
32048,
13,
4868,
13313,
507,
28955,
1875,
657,
290,
7034,
318,
6045,
25,
198,
220,
220,
220,
220,
220,
220,
220,
1441,
24047,
32048,
13,
1136,
19463,
32048,
3419,
198,
220,
220,
220,
1288,
361,
18896,
7,
38105,
32048,
13,
4868,
13313,
507,
28955,
6624,
657,
290,
7034,
318,
6045,
25,
198,
220,
220,
220,
220,
220,
220,
220,
1303,
7921,
274,
262,
4277,
20137,
4637,
198,
220,
220,
220,
220,
220,
220,
220,
6831,
32048,
10100,
796,
357,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
705,
7353,
34239,
13976,
10,
13764,
22163,
70,
17,
1378,
90,
7220,
92,
29164,
28712,
92,
31,
90,
4774,
92,
29164,
634,
92,
14,
90,
48806,
92,
6,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
764,
18982,
7,
1174,
11250,
17816,
9945,
32048,
20520,
4008,
198,
220,
220,
220,
220,
220,
220,
220,
20613,
37321,
796,
24047,
32048,
7,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
6831,
32048,
10100,
28,
48806,
32048,
10100,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
649,
28,
17821,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1438,
28,
11250,
17816,
9945,
32048,
6,
7131,
6,
3672,
6,
4357,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
4277,
28,
17821,
8,
198,
220,
220,
220,
220,
220,
220,
220,
2198,
11505,
36044,
3419,
198,
220,
220,
220,
220,
220,
220,
220,
1441,
20613,
37321,
198,
220,
220,
220,
2073,
25,
198,
220,
220,
220,
220,
220,
220,
220,
611,
7034,
13,
21037,
3419,
287,
24047,
32048,
13,
4868,
13313,
507,
33529,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1441,
24047,
32048,
13,
1136,
32048,
7,
13317,
13,
21037,
28955,
198,
220,
220,
220,
220,
220,
220,
220,
2073,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
611,
7034,
13,
21037,
3419,
287,
4566,
15404,
2915,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
6831,
32048,
10100,
796,
19203,
7353,
34239,
13976,
10,
13764,
22163,
70,
17,
1378,
90,
7220,
92,
29164,
28712,
92,
31,
6,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
705,
90,
4774,
92,
29164,
634,
92,
14,
90,
48806,
92,
6,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
764,
18982,
7,
1174,
11250,
15404,
2915,
58,
13317,
13,
21037,
3419,
60,
4008,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
20613,
37321,
796,
24047,
32048,
7,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
6831,
32048,
10100,
28,
48806,
32048,
10100,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
649,
28,
17821,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1438,
28,
13317,
13,
21037,
28955,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2198,
11505,
36044,
3419,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1441,
20613,
37321,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2073,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
5298,
11052,
12331,
10786,
13317,
1391,
15,
92,
857,
407,
2152,
4458,
18982,
7,
13317,
4008,
628,
198,
4299,
651,
32048,
13295,
7,
13317,
28,
14202,
2599,
198,
220,
220,
220,
37227,
35561,
257,
4637,
11,
663,
6246,
11,
7480,
11012,
290,
15911,
11012,
526,
15931,
628,
220,
220,
220,
20613,
37321,
796,
651,
32048,
7,
13317,
28,
13317,
8,
198,
220,
220,
220,
1441,
20613,
37321,
11,
20613,
37321,
13,
36044,
11,
20613,
37321,
13,
6816,
11012,
11,
20613,
37321,
13,
76,
16484,
11012,
628,
198,
4299,
900,
7469,
2518,
37046,
7,
13317,
2599,
198,
220,
220,
220,
37227,
50,
1039,
257,
7034,
355,
4277,
526,
15931,
628,
220,
220,
220,
611,
18896,
7,
38105,
32048,
13,
4868,
13313,
507,
28955,
1875,
657,
25,
198,
220,
220,
220,
220,
220,
220,
220,
611,
24047,
32048,
13,
1136,
19463,
32048,
5376,
3419,
6624,
705,
13317,
10354,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1441,
628,
220,
220,
220,
611,
7034,
407,
287,
651,
38149,
15404,
2915,
33529,
198,
220,
220,
220,
220,
220,
220,
220,
5298,
11052,
12331,
10786,
13317,
1391,
15,
92,
857,
407,
2152,
4458,
18982,
7,
13317,
4008,
628,
220,
220,
220,
611,
7034,
287,
24047,
32048,
13,
4868,
13313,
507,
33529,
198,
220,
220,
220,
220,
220,
220,
220,
24047,
32048,
13,
2617,
19463,
32048,
7,
13317,
8,
198,
220,
220,
220,
2073,
25,
198,
220,
220,
220,
220,
220,
220,
220,
20613,
796,
651,
32048,
7,
13317,
28,
13317,
8,
198,
220,
220,
220,
220,
220,
220,
220,
20613,
13,
2617,
19463,
32048,
7,
13317,
8,
198
] | 2.541505 | 1,289 |
# Modifique as funções que form criadas no desafio 107 para que elas aceitem um parâmetro a mais,
# informando se o valor retornado por elas vai ser ou não formatado pela função moeda(), desenvolvida no desafio 108.
import moeda
#Programa Principal
valor = float(input('Digite o preço:R$ '))
print(f' A aumentando 10% de {moeda.moeda(valor)} é igual à: {moeda.aumentar(valor, formatado=True)}')# isso são parametros do pacote de moedas.
print(f' Diminuindo 10% de {moeda.moeda(valor)} é igual à: {moeda.diminuir(valor, True)}')
print(f' O dobro de {moeda.moeda(valor)} é igual à: R${moeda.dobro(valor, True)}')
print(f' A metade de {moeda.moeda(valor)}: é {moeda.metade(valor, True)}')
| [
2,
3401,
361,
2350,
355,
1257,
16175,
127,
113,
274,
8358,
1296,
269,
21244,
292,
645,
748,
1878,
952,
16226,
31215,
8358,
1288,
292,
31506,
9186,
23781,
1582,
22940,
4164,
305,
257,
285,
15152,
11,
201,
198,
2,
220,
4175,
25440,
384,
267,
1188,
273,
1005,
1211,
4533,
16964,
1288,
292,
410,
1872,
1055,
267,
84,
299,
28749,
5794,
4533,
279,
10304,
1257,
16175,
28749,
6941,
18082,
22784,
748,
268,
10396,
85,
3755,
645,
748,
1878,
952,
15495,
13,
201,
198,
11748,
6941,
18082,
201,
198,
201,
198,
2,
15167,
64,
32641,
201,
198,
2100,
273,
796,
12178,
7,
15414,
10786,
19511,
578,
267,
662,
16175,
78,
25,
49,
3,
705,
4008,
201,
198,
4798,
7,
69,
6,
317,
257,
1713,
25440,
838,
4,
220,
390,
1391,
5908,
18082,
13,
5908,
18082,
7,
2100,
273,
38165,
38251,
45329,
723,
28141,
25,
1391,
5908,
18082,
13,
64,
1713,
283,
7,
2100,
273,
11,
5794,
4533,
28,
17821,
38165,
11537,
2,
318,
568,
264,
28749,
5772,
316,
4951,
466,
23503,
1258,
390,
6941,
276,
292,
13,
201,
198,
4798,
7,
69,
6,
14048,
259,
84,
521,
78,
838,
4,
220,
390,
1391,
5908,
18082,
13,
5908,
18082,
7,
2100,
273,
38165,
38251,
45329,
723,
28141,
25,
1391,
5908,
18082,
13,
27740,
259,
84,
343,
7,
2100,
273,
11,
6407,
38165,
11537,
201,
198,
4798,
7,
69,
6,
440,
466,
7957,
390,
1391,
5908,
18082,
13,
5908,
18082,
7,
2100,
273,
38165,
38251,
45329,
723,
28141,
25,
371,
38892,
5908,
18082,
13,
67,
672,
305,
7,
2100,
273,
11,
6407,
38165,
11537,
201,
198,
4798,
7,
69,
6,
317,
1138,
671,
390,
1391,
5908,
18082,
13,
5908,
18082,
7,
2100,
273,
38165,
25,
38251,
1391,
5908,
18082,
13,
4164,
671,
7,
2100,
273,
11,
6407,
38165,
11537,
201,
198
] | 2.364865 | 296 |
import treq
from mk2.events import EventPriority, ServerEvent, ServerStarted, ServerStopped, ServerStopping, ServerStarting
from mk2.plugins import Plugin
from mk2.shared import decode_if_bytes
class WebhookObject(dict):
""" Custom dict object that represents a discord webhook object """
def add_embed(self, title, fields=[]):
""" Creates an embed object with the specified title and optional list of fields"""
self.embeds.append({"title": title, "fields": fields})
def add_embed_field(self, title, name, value, inline=False):
""" Adds a field to the embed matching the title given """
for embed in self.embeds:
if embed["title"] == title:
embed["fields"].append({"name": name, "value": value, "inline": inline})
break
| [
11748,
2054,
80,
198,
198,
6738,
33480,
17,
13,
31534,
1330,
8558,
22442,
414,
11,
9652,
9237,
11,
9652,
10434,
276,
11,
9652,
1273,
38333,
11,
9652,
1273,
33307,
11,
9652,
22851,
198,
6738,
33480,
17,
13,
37390,
1330,
42636,
198,
6738,
33480,
17,
13,
28710,
1330,
36899,
62,
361,
62,
33661,
628,
198,
4871,
5313,
25480,
10267,
7,
11600,
2599,
198,
220,
220,
220,
37227,
8562,
8633,
2134,
326,
6870,
257,
36446,
3992,
25480,
2134,
37227,
198,
220,
220,
220,
220,
198,
220,
220,
220,
825,
751,
62,
20521,
7,
944,
11,
3670,
11,
7032,
28,
21737,
2599,
198,
220,
220,
220,
220,
220,
220,
220,
37227,
7921,
274,
281,
11525,
2134,
351,
262,
7368,
3670,
290,
11902,
1351,
286,
7032,
37811,
198,
220,
220,
220,
220,
220,
220,
220,
2116,
13,
20521,
82,
13,
33295,
7,
4895,
7839,
1298,
3670,
11,
366,
25747,
1298,
7032,
30072,
198,
220,
220,
220,
220,
198,
220,
220,
220,
825,
751,
62,
20521,
62,
3245,
7,
944,
11,
3670,
11,
1438,
11,
1988,
11,
26098,
28,
25101,
2599,
198,
220,
220,
220,
220,
220,
220,
220,
37227,
34333,
257,
2214,
284,
262,
11525,
12336,
262,
3670,
1813,
37227,
198,
220,
220,
220,
220,
220,
220,
220,
329,
11525,
287,
2116,
13,
20521,
82,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
611,
11525,
14692,
7839,
8973,
6624,
3670,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
11525,
14692,
25747,
1,
4083,
33295,
7,
4895,
3672,
1298,
1438,
11,
366,
8367,
1298,
1988,
11,
366,
45145,
1298,
26098,
30072,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2270,
198,
220,
220,
220,
220,
198
] | 2.819113 | 293 |
# -*- coding: utf-8 -*-
""" Analysis tools
"""
import sciplot
import numpy as np
import matplotlib.pyplot as plt
from .functions import _hist_init
def plot_flatness(sig, tag, bins=None, ax=None, xrange=None, percent_step=5):
""" Plotting differences of sig distribution in percentiles of tag distribution
Args:
sig:
tag:
bins:
ax:
xrange:
percent_step:
Returns:
"""
if ax is None:
fix, ax = plt.subplots()
xaxis = _hist_init(sig, bins=bins, xrange=xrange)
colormap = plt.get_cmap('magma')
orig, x = np.histogram(sig, bins=xaxis, range=xrange, normed=True, )
bin_center = ((x + np.roll(x, 1)) / 2)[1:]
tmp = orig/orig
ax.plot(bin_center, tmp, color='black', lw=1)
for quantil in np.arange(5, 100, percent_step):
cut = np.percentile(tag, quantil)
sel = tag >= cut
y, x = np.histogram(sig[sel], bins=x, range=xrange, normed=True, )
y /= orig
ax.fill_between(bin_center, tmp, y, color=colormap(quantil/100.0))
tmp = y
def ratio(y1, y2, y1_err=None, y2_err= None):
""" calculate the ratio between two histograms y1/y2
Args:
y1: y values of first histogram
y2: y values of second histogram
y1_err: (optional) error of first
y2_err: (optional) error of second
Returns:
ratio, ratio_error
"""
assert len(y1) == len(y2), "y1 and y2 length does not match"
y1e = np.sqrt(y1) if y1_err is None else y1_err
y2e = np.sqrt(y2) if y2_err is None else y2_err
r = y1/y2
re = np.sqrt((y1/(1.0*y2*y2))*(y1/(1.0*y2*y2))*y2e*y2e+(1/(1.0*y2))*(1/(1.0*y2))*y1e*y1e)
return r, re
def data_mc_ratio(data, mc, label_data='Data', label_mc="MC",
y_label=None, figsize=None, ratio_range=(0, 2),
*args, **kwarg):
""" Plot a comparison between two sets of data
Args:
data:
mc:
label_data:
label_mc:
y_label:
figsize:
ratio_range:
*args:
**kwarg:
Returns:
"""
f, axes = plt.subplots(2, 1, gridspec_kw={"height_ratios": [3, 1]}, sharex=True, figsize=figsize)
ax0 = axes[0]
hm = sciplot.hist(mc, lw=2, ax=ax0, label=label_mc, *args, **kwarg)
hd = sciplot.errorhist(data, ax=ax0, label=label_data, color='black')
ax0.legend()
ax1 = axes[1]
ry, rye = ratio(hd[0], hm[0])
sciplot.errorbar(hd[1], ry, rye, ax=ax1, color='grey')
ax1.axhline(1, color='grey', lw=0.5, ls='--')
f.subplots_adjust(hspace=0.1)
ax1.set_ylim(*ratio_range)
sciplot.xlim()
if y_label is not None:
ax0.set_ylabel(y_label)
ax1.set_ylabel("Ratio")
ax1.yaxis.set_label_coords(-0.08, 0.5)
ax0.yaxis.set_label_coords(-0.08, 0.5)
| [
2,
532,
9,
12,
19617,
25,
3384,
69,
12,
23,
532,
9,
12,
198,
37811,
14691,
4899,
198,
198,
37811,
198,
11748,
20681,
29487,
198,
11748,
299,
32152,
355,
45941,
198,
11748,
2603,
29487,
8019,
13,
9078,
29487,
355,
458,
83,
198,
6738,
764,
12543,
2733,
1330,
4808,
10034,
62,
15003,
628,
198,
4299,
7110,
62,
38568,
1108,
7,
82,
328,
11,
7621,
11,
41701,
28,
14202,
11,
7877,
28,
14202,
11,
2124,
9521,
28,
14202,
11,
1411,
62,
9662,
28,
20,
2599,
198,
220,
220,
220,
37227,
28114,
889,
5400,
286,
43237,
6082,
287,
1411,
2915,
286,
7621,
6082,
628,
220,
220,
220,
943,
14542,
25,
198,
220,
220,
220,
220,
220,
220,
220,
43237,
25,
198,
220,
220,
220,
220,
220,
220,
220,
7621,
25,
198,
220,
220,
220,
220,
220,
220,
220,
41701,
25,
198,
220,
220,
220,
220,
220,
220,
220,
7877,
25,
198,
220,
220,
220,
220,
220,
220,
220,
2124,
9521,
25,
198,
220,
220,
220,
220,
220,
220,
220,
1411,
62,
9662,
25,
628,
220,
220,
220,
16409,
25,
628,
220,
220,
220,
37227,
628,
220,
220,
220,
611,
7877,
318,
6045,
25,
198,
220,
220,
220,
220,
220,
220,
220,
4259,
11,
7877,
796,
458,
83,
13,
7266,
489,
1747,
3419,
628,
220,
220,
220,
2124,
22704,
796,
4808,
10034,
62,
15003,
7,
82,
328,
11,
41701,
28,
65,
1040,
11,
2124,
9521,
28,
87,
9521,
8,
628,
220,
220,
220,
951,
579,
499,
796,
458,
83,
13,
1136,
62,
66,
8899,
10786,
19726,
2611,
11537,
198,
220,
220,
220,
1796,
11,
2124,
796,
45941,
13,
10034,
21857,
7,
82,
328,
11,
41701,
28,
87,
22704,
11,
2837,
28,
87,
9521,
11,
2593,
276,
28,
17821,
11,
1267,
198,
220,
220,
220,
9874,
62,
16159,
796,
14808,
87,
1343,
45941,
13,
2487,
7,
87,
11,
352,
4008,
1220,
362,
38381,
16,
47715,
198,
220,
220,
220,
45218,
796,
1796,
14,
11612,
198,
220,
220,
220,
7877,
13,
29487,
7,
8800,
62,
16159,
11,
45218,
11,
3124,
11639,
13424,
3256,
300,
86,
28,
16,
8,
198,
220,
220,
220,
329,
5554,
346,
287,
45941,
13,
283,
858,
7,
20,
11,
1802,
11,
1411,
62,
9662,
2599,
198,
220,
220,
220,
220,
220,
220,
220,
2005,
796,
45941,
13,
25067,
576,
7,
12985,
11,
5554,
346,
8,
198,
220,
220,
220,
220,
220,
220,
220,
384,
75,
796,
7621,
18189,
2005,
198,
220,
220,
220,
220,
220,
220,
220,
331,
11,
2124,
796,
45941,
13,
10034,
21857,
7,
82,
328,
58,
741,
4357,
41701,
28,
87,
11,
2837,
28,
87,
9521,
11,
2593,
276,
28,
17821,
11,
1267,
198,
220,
220,
220,
220,
220,
220,
220,
331,
1220,
28,
1796,
198,
220,
220,
220,
220,
220,
220,
220,
7877,
13,
20797,
62,
23395,
7,
8800,
62,
16159,
11,
45218,
11,
331,
11,
3124,
28,
4033,
579,
499,
7,
40972,
346,
14,
3064,
13,
15,
4008,
198,
220,
220,
220,
220,
220,
220,
220,
45218,
796,
331,
628,
198,
198,
4299,
8064,
7,
88,
16,
11,
331,
17,
11,
331,
16,
62,
8056,
28,
14202,
11,
331,
17,
62,
8056,
28,
6045,
2599,
198,
220,
220,
220,
37227,
15284,
262,
8064,
1022,
734,
1554,
26836,
331,
16,
14,
88,
17,
628,
220,
220,
220,
943,
14542,
25,
198,
220,
220,
220,
220,
220,
220,
220,
331,
16,
25,
331,
3815,
286,
717,
1554,
21857,
198,
220,
220,
220,
220,
220,
220,
220,
331,
17,
25,
331,
3815,
286,
1218,
1554,
21857,
198,
220,
220,
220,
220,
220,
220,
220,
331,
16,
62,
8056,
25,
357,
25968,
8,
4049,
286,
717,
198,
220,
220,
220,
220,
220,
220,
220,
331,
17,
62,
8056,
25,
357,
25968,
8,
4049,
286,
1218,
628,
220,
220,
220,
16409,
25,
198,
220,
220,
220,
220,
220,
220,
220,
8064,
11,
8064,
62,
18224,
628,
220,
220,
220,
37227,
198,
220,
220,
220,
6818,
18896,
7,
88,
16,
8,
6624,
18896,
7,
88,
17,
828,
366,
88,
16,
290,
331,
17,
4129,
857,
407,
2872,
1,
198,
220,
220,
220,
331,
16,
68,
796,
45941,
13,
31166,
17034,
7,
88,
16,
8,
611,
331,
16,
62,
8056,
318,
6045,
2073,
331,
16,
62,
8056,
198,
220,
220,
220,
331,
17,
68,
796,
45941,
13,
31166,
17034,
7,
88,
17,
8,
611,
331,
17,
62,
8056,
318,
6045,
2073,
331,
17,
62,
8056,
198,
220,
220,
220,
374,
796,
331,
16,
14,
88,
17,
198,
220,
220,
220,
302,
796,
45941,
13,
31166,
17034,
19510,
88,
16,
29006,
16,
13,
15,
9,
88,
17,
9,
88,
17,
4008,
9,
7,
88,
16,
29006,
16,
13,
15,
9,
88,
17,
9,
88,
17,
4008,
9,
88,
17,
68,
9,
88,
17,
68,
33747,
16,
29006,
16,
13,
15,
9,
88,
17,
4008,
9,
7,
16,
29006,
16,
13,
15,
9,
88,
17,
4008,
9,
88,
16,
68,
9,
88,
16,
68,
8,
198,
220,
220,
220,
1441,
374,
11,
302,
628,
198,
4299,
1366,
62,
23209,
62,
10366,
952,
7,
7890,
11,
36650,
11,
6167,
62,
7890,
11639,
6601,
3256,
6167,
62,
23209,
2625,
9655,
1600,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
331,
62,
18242,
28,
14202,
11,
2336,
7857,
28,
14202,
11,
8064,
62,
9521,
16193,
15,
11,
362,
828,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1635,
22046,
11,
12429,
46265,
853,
2599,
198,
220,
220,
220,
37227,
28114,
257,
7208,
1022,
734,
5621,
286,
1366,
628,
220,
220,
220,
943,
14542,
25,
198,
220,
220,
220,
220,
220,
220,
220,
1366,
25,
198,
220,
220,
220,
220,
220,
220,
220,
36650,
25,
198,
220,
220,
220,
220,
220,
220,
220,
6167,
62,
7890,
25,
198,
220,
220,
220,
220,
220,
220,
220,
6167,
62,
23209,
25,
198,
220,
220,
220,
220,
220,
220,
220,
331,
62,
18242,
25,
198,
220,
220,
220,
220,
220,
220,
220,
2336,
7857,
25,
198,
220,
220,
220,
220,
220,
220,
220,
8064,
62,
9521,
25,
198,
220,
220,
220,
220,
220,
220,
220,
1635,
22046,
25,
198,
220,
220,
220,
220,
220,
220,
220,
12429,
46265,
853,
25,
628,
220,
220,
220,
16409,
25,
628,
220,
220,
220,
37227,
198,
220,
220,
220,
277,
11,
34197,
796,
458,
83,
13,
7266,
489,
1747,
7,
17,
11,
352,
11,
50000,
43106,
62,
46265,
28,
4895,
17015,
62,
10366,
4267,
1298,
685,
18,
11,
352,
60,
5512,
2648,
87,
28,
17821,
11,
2336,
7857,
28,
5647,
7857,
8,
198,
220,
220,
220,
7877,
15,
796,
34197,
58,
15,
60,
628,
220,
220,
220,
289,
76,
796,
20681,
29487,
13,
10034,
7,
23209,
11,
300,
86,
28,
17,
11,
7877,
28,
897,
15,
11,
6167,
28,
18242,
62,
23209,
11,
1635,
22046,
11,
12429,
46265,
853,
8,
198,
220,
220,
220,
289,
67,
796,
20681,
29487,
13,
18224,
10034,
7,
7890,
11,
7877,
28,
897,
15,
11,
6167,
28,
18242,
62,
7890,
11,
3124,
11639,
13424,
11537,
198,
220,
220,
220,
7877,
15,
13,
1455,
437,
3419,
628,
220,
220,
220,
7877,
16,
796,
34197,
58,
16,
60,
198,
220,
220,
220,
374,
88,
11,
47553,
796,
8064,
7,
31298,
58,
15,
4357,
289,
76,
58,
15,
12962,
198,
220,
220,
220,
20681,
29487,
13,
18224,
5657,
7,
31298,
58,
16,
4357,
374,
88,
11,
47553,
11,
7877,
28,
897,
16,
11,
3124,
11639,
49502,
11537,
198,
220,
220,
220,
7877,
16,
13,
897,
71,
1370,
7,
16,
11,
3124,
11639,
49502,
3256,
300,
86,
28,
15,
13,
20,
11,
43979,
11639,
438,
11537,
198,
220,
220,
220,
277,
13,
7266,
489,
1747,
62,
23032,
7,
71,
13200,
28,
15,
13,
16,
8,
628,
220,
220,
220,
7877,
16,
13,
2617,
62,
88,
2475,
46491,
10366,
952,
62,
9521,
8,
198,
220,
220,
220,
20681,
29487,
13,
87,
2475,
3419,
198,
220,
220,
220,
611,
331,
62,
18242,
318,
407,
6045,
25,
198,
220,
220,
220,
220,
220,
220,
220,
7877,
15,
13,
2617,
62,
2645,
9608,
7,
88,
62,
18242,
8,
198,
220,
220,
220,
220,
220,
220,
220,
7877,
16,
13,
2617,
62,
2645,
9608,
7203,
29665,
952,
4943,
198,
220,
220,
220,
220,
220,
220,
220,
7877,
16,
13,
88,
22704,
13,
2617,
62,
18242,
62,
1073,
3669,
32590,
15,
13,
2919,
11,
657,
13,
20,
8,
198,
220,
220,
220,
220,
220,
220,
220,
7877,
15,
13,
88,
22704,
13,
2617,
62,
18242,
62,
1073,
3669,
32590,
15,
13,
2919,
11,
657,
13,
20,
8,
198
] | 1.991525 | 1,416 |
import string
import random
from set1.Aes_cipher import *
from set2.PkcsPadding import pkcs7_pad_check
from set1.Xor import xorPlain
KEY = ''.join([chr(random.randint(0,255)) for i in range(16)])
IV = ''.join([chr(random.randint(0,255)) for i in range(16)])
if __name__ == '__main__':
# replace d with ; and second d with =
enc = format_string('dadmindtrue')
print 'Before:', is_admin(str(enc))
# https://upload.wikimedia.org/wikipedia/commons/thumb/2/2a/CBC_decryption.svg/601px-CBC_decryption.svg.png
# we know that 'comment1=cooking%20MCs;userdata='+user_input+';comment2=%20like%20a%20pound%20of%20bacon'
# is being encrypted so split it into block of 16 and determine in which block our input falls into.
# Take the previous encrypted block xor with the plain input to get the output of the AES cipher of the current block
# then xor it with the desired output and make the previous block equal to that
# in my case it was 2nd block
enc2 = enc[0:16] + getBitFlippedBlock(enc[16:32], 'dadmindtrue;comm', ';admin=true;comm') + enc[32:]
print 'After:', is_admin(str(enc2))
| [
11748,
4731,
198,
11748,
4738,
198,
6738,
900,
16,
13,
32,
274,
62,
66,
10803,
1330,
1635,
198,
6738,
900,
17,
13,
47,
74,
6359,
47,
26872,
1330,
279,
74,
6359,
22,
62,
15636,
62,
9122,
198,
6738,
900,
16,
13,
55,
273,
1330,
2124,
273,
3646,
391,
198,
198,
20373,
796,
705,
4458,
22179,
26933,
354,
81,
7,
25120,
13,
25192,
600,
7,
15,
11,
13381,
4008,
329,
1312,
287,
2837,
7,
1433,
8,
12962,
198,
3824,
796,
705,
4458,
22179,
26933,
354,
81,
7,
25120,
13,
25192,
600,
7,
15,
11,
13381,
4008,
329,
1312,
287,
2837,
7,
1433,
8,
12962,
628,
628,
198,
198,
361,
11593,
3672,
834,
6624,
705,
834,
12417,
834,
10354,
198,
220,
220,
220,
1303,
6330,
288,
351,
2162,
290,
1218,
288,
351,
796,
198,
220,
220,
220,
2207,
796,
5794,
62,
8841,
10786,
47984,
10155,
7942,
11537,
198,
220,
220,
220,
3601,
705,
8421,
25,
3256,
318,
62,
28482,
7,
2536,
7,
12685,
4008,
628,
220,
220,
220,
1303,
3740,
1378,
25850,
13,
20763,
20626,
13,
2398,
14,
31266,
14,
9503,
684,
14,
400,
2178,
14,
17,
14,
17,
64,
14,
29208,
62,
12501,
13168,
13,
21370,
70,
14,
41706,
8416,
12,
29208,
62,
12501,
13168,
13,
21370,
70,
13,
11134,
198,
220,
220,
220,
1303,
356,
760,
326,
705,
23893,
16,
28,
27916,
278,
4,
1238,
9655,
82,
26,
7220,
7890,
11639,
10,
7220,
62,
15414,
10,
17020,
23893,
17,
28,
4,
1238,
2339,
4,
1238,
64,
4,
1238,
19568,
4,
1238,
1659,
4,
1238,
65,
7807,
6,
198,
220,
220,
220,
1303,
318,
852,
19365,
523,
6626,
340,
656,
2512,
286,
1467,
290,
5004,
287,
543,
2512,
674,
5128,
8953,
656,
13,
198,
220,
220,
220,
1303,
7214,
262,
2180,
19365,
2512,
2124,
273,
351,
262,
8631,
5128,
284,
651,
262,
5072,
286,
262,
34329,
38012,
286,
262,
1459,
2512,
198,
220,
220,
220,
1303,
788,
2124,
273,
340,
351,
262,
10348,
5072,
290,
787,
262,
2180,
2512,
4961,
284,
326,
628,
220,
220,
220,
1303,
287,
616,
1339,
340,
373,
362,
358,
2512,
198,
220,
220,
220,
2207,
17,
796,
2207,
58,
15,
25,
1433,
60,
1343,
651,
13128,
7414,
3949,
12235,
7,
12685,
58,
1433,
25,
2624,
4357,
705,
47984,
10155,
7942,
26,
9503,
3256,
705,
26,
28482,
28,
7942,
26,
9503,
11537,
1343,
2207,
58,
2624,
47715,
198,
220,
220,
220,
3601,
705,
3260,
25,
3256,
318,
62,
28482,
7,
2536,
7,
12685,
17,
4008,
198
] | 2.755501 | 409 |
import torch
import torch.nn as nn
import torch.nn.functional as F
from networks.layers import NoisyLinear
from networks.network_bodies import SimpleBody, AtariBody
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
########Recurrent Architectures#########
########Actor Critic Architectures#########
| [
11748,
28034,
198,
11748,
28034,
13,
20471,
355,
299,
77,
198,
11748,
28034,
13,
20471,
13,
45124,
355,
376,
198,
198,
6738,
7686,
13,
75,
6962,
1330,
1400,
13560,
14993,
451,
198,
6738,
7686,
13,
27349,
62,
65,
5042,
1330,
17427,
25842,
11,
35884,
25842,
198,
25202,
796,
28034,
13,
25202,
7203,
66,
15339,
1,
611,
28034,
13,
66,
15339,
13,
271,
62,
15182,
3419,
2073,
366,
36166,
4943,
628,
628,
628,
628,
198,
198,
7804,
6690,
6657,
17340,
942,
7804,
2,
628,
198,
7804,
40277,
10056,
291,
17340,
942,
7804,
2,
198
] | 3.569892 | 93 |
import sys
from PyQt5 import QtGui, QtWidgets
from PyQt5.QtCore import QRect
from PyQt5.QtWidgets import QApplication, QFileDialog
from Shadow import ShadowTools as ST
from orangewidget import gui
from oasys.widgets import gui as oasysgui, widget
from oasys.util.oasys_util import EmittingStream
from orangecontrib.wofry.util.wofry_objects import WofryData
from orangecontrib.wofry.widgets.gui.python_script import PythonScript
if __name__ == "__main__":
import sys
from PyQt5.QtWidgets import QApplication
a = QApplication(sys.argv)
ow = OWWOInfo()
ow.show()
a.exec_()
ow.saveSettings() | [
11748,
25064,
198,
198,
6738,
9485,
48,
83,
20,
1330,
33734,
8205,
72,
11,
33734,
54,
312,
11407,
198,
6738,
9485,
48,
83,
20,
13,
48,
83,
14055,
1330,
42137,
478,
198,
6738,
9485,
48,
83,
20,
13,
48,
83,
54,
312,
11407,
1330,
1195,
23416,
11,
1195,
8979,
44204,
198,
6738,
8843,
1330,
8843,
33637,
355,
3563,
198,
6738,
393,
648,
413,
17484,
1330,
11774,
198,
6738,
267,
292,
893,
13,
28029,
11407,
1330,
11774,
355,
267,
292,
893,
48317,
11,
26295,
198,
6738,
267,
292,
893,
13,
22602,
13,
78,
292,
893,
62,
22602,
1330,
2295,
2535,
12124,
198,
198,
6738,
10912,
3642,
822,
13,
86,
1659,
563,
13,
22602,
13,
86,
1659,
563,
62,
48205,
1330,
370,
1659,
563,
6601,
198,
6738,
10912,
3642,
822,
13,
86,
1659,
563,
13,
28029,
11407,
13,
48317,
13,
29412,
62,
12048,
1330,
11361,
7391,
628,
198,
361,
11593,
3672,
834,
6624,
366,
834,
12417,
834,
1298,
198,
220,
220,
220,
1330,
25064,
198,
220,
220,
220,
422,
9485,
48,
83,
20,
13,
48,
83,
54,
312,
11407,
1330,
1195,
23416,
628,
220,
220,
220,
257,
796,
1195,
23416,
7,
17597,
13,
853,
85,
8,
198,
220,
220,
220,
12334,
796,
440,
17947,
46,
12360,
3419,
628,
198,
220,
220,
220,
12334,
13,
12860,
3419,
198,
220,
220,
220,
257,
13,
18558,
62,
3419,
198,
220,
220,
220,
12334,
13,
21928,
26232,
3419
] | 2.681034 | 232 |
import os
basePath = './install_root'
RLGlue_Files = []
pythonTemplateFileName='uninstall-rlglue-template.py'
pythonUninstallFileName='uninstall-resources/uninstall-rlglue.py'
for root, dirs, files in os.walk(basePath):
for f in files:
if f.endswith('.h') or f.endswith('.dylib') or f.endswith('a'):
thisName=os.path.join(root, f)
nameWithoutBase=thisName[len(basePath):]
RLGlue_Files.append(nameWithoutBase)
subs={}
subs['RLGLUE_FILE_REPLACE_HERE']=str(RLGlue_Files)
f = file(pythonTemplateFileName)
newlines = []
for line in f:
for key,value in subs.iteritems():
if key in line:
line=line.replace(key,value)
newlines.append(line)
outfile = file(pythonUninstallFileName, 'w')
outfile.writelines(newlines) | [
11748,
28686,
198,
8692,
15235,
796,
705,
19571,
17350,
62,
15763,
6,
198,
7836,
9861,
518,
62,
25876,
796,
17635,
198,
198,
29412,
30800,
8979,
5376,
11639,
403,
17350,
12,
45895,
4743,
518,
12,
28243,
13,
9078,
6,
198,
29412,
3118,
17350,
8979,
5376,
11639,
403,
17350,
12,
37540,
14,
403,
17350,
12,
45895,
4743,
518,
13,
9078,
6,
198,
198,
1640,
6808,
11,
288,
17062,
11,
3696,
287,
28686,
13,
11152,
7,
8692,
15235,
2599,
198,
197,
1640,
277,
287,
3696,
25,
198,
197,
197,
361,
277,
13,
437,
2032,
342,
7,
4458,
71,
11537,
393,
277,
13,
437,
2032,
342,
7,
4458,
31739,
11537,
393,
277,
13,
437,
2032,
342,
10786,
64,
6,
2599,
198,
197,
197,
197,
5661,
5376,
28,
418,
13,
6978,
13,
22179,
7,
15763,
11,
277,
8,
198,
197,
197,
197,
3672,
16249,
14881,
28,
5661,
5376,
58,
11925,
7,
8692,
15235,
2599,
60,
198,
197,
197,
197,
7836,
9861,
518,
62,
25876,
13,
33295,
7,
3672,
16249,
14881,
8,
198,
198,
7266,
82,
34758,
92,
198,
7266,
82,
17816,
7836,
8763,
8924,
62,
25664,
62,
2200,
6489,
11598,
62,
39,
9338,
20520,
28,
2536,
7,
7836,
9861,
518,
62,
25876,
8,
198,
69,
796,
2393,
7,
29412,
30800,
8979,
5376,
8,
198,
3605,
6615,
796,
17635,
198,
1640,
1627,
287,
277,
25,
198,
197,
1640,
1994,
11,
8367,
287,
6352,
13,
2676,
23814,
33529,
198,
197,
197,
361,
1994,
287,
1627,
25,
198,
197,
197,
197,
1370,
28,
1370,
13,
33491,
7,
2539,
11,
8367,
8,
198,
197,
3605,
6615,
13,
33295,
7,
1370,
8,
198,
198,
448,
7753,
796,
2393,
7,
29412,
3118,
17350,
8979,
5376,
11,
705,
86,
11537,
198,
448,
7753,
13,
8933,
20655,
7,
3605,
6615,
8
] | 2.527778 | 288 |
# Krishan Patel
# Bank Account Class
"""Chaper 14: Objects
From Hello World! Computer Programming for Kids and Beginners
Copyright Warren and Carter Sande, 2009-2013
"""
# Chapter 14 - Try it out
class BankAccount:
"""Creates a bank account"""
def display_balance(self):
"""Displays the balance of the bank account"""
print("Balance:", self.balance)
def deposit(self, money_deposit):
"""Makes a deposit into bank account (adds more money to balance)"""
self.balance += money_deposit
def withdraw(self, money_withdraw):
"""Withdraws money from bank account (reduces balance)"""
self.balance -= money_withdraw
class InterestAccount(BankAccount):
"""Type of bank account that earns interest"""
def add_interest(self, rate):
"""Adds interest to bank account"""
interest = self.balance*rate
self.deposit(interest)
# Testing out BankAccount class
print("----------Testing BankAccount----------")
bankAccount = BankAccount("Krishan Patel", 123456)
print(bankAccount)
print()
bankAccount.display_balance()
print()
bankAccount.deposit(34.52)
print(bankAccount)
print()
bankAccount.withdraw(12.25)
print(bankAccount)
print()
bankAccount.withdraw(30.18)
print(bankAccount)
print()
# Testing out InterestAccount class
print("----------Testing InterestAccount----------")
interestAccount = InterestAccount("Krishan Patel", 234567)
print(interestAccount)
print()
interestAccount.display_balance()
print()
interestAccount.deposit(34.52)
print(interestAccount)
print()
interestAccount.add_interest(0.11)
print(interestAccount)
| [
2,
31372,
272,
33110,
198,
2,
5018,
10781,
5016,
198,
198,
37811,
1925,
2136,
1478,
25,
35832,
198,
4863,
18435,
2159,
0,
13851,
30297,
329,
17476,
290,
16623,
2741,
198,
15269,
11328,
290,
10831,
3837,
68,
11,
3717,
12,
6390,
198,
37811,
198,
198,
2,
7006,
1478,
532,
9993,
340,
503,
198,
4871,
5018,
30116,
25,
198,
220,
220,
220,
37227,
16719,
274,
257,
3331,
1848,
37811,
628,
220,
220,
220,
825,
3359,
62,
20427,
7,
944,
2599,
198,
220,
220,
220,
220,
220,
220,
220,
37227,
7279,
26024,
262,
5236,
286,
262,
3331,
1848,
37811,
198,
220,
220,
220,
220,
220,
220,
220,
3601,
7203,
45866,
25,
1600,
2116,
13,
20427,
8,
628,
220,
220,
220,
825,
14667,
7,
944,
11,
1637,
62,
10378,
7434,
2599,
198,
220,
220,
220,
220,
220,
220,
220,
37227,
44,
1124,
257,
14667,
656,
3331,
1848,
357,
2860,
82,
517,
1637,
284,
5236,
8,
37811,
198,
220,
220,
220,
220,
220,
220,
220,
2116,
13,
20427,
15853,
1637,
62,
10378,
7434,
628,
220,
220,
220,
825,
8399,
7,
944,
11,
1637,
62,
4480,
19334,
2599,
198,
220,
220,
220,
220,
220,
220,
220,
37227,
3152,
19334,
82,
1637,
422,
3331,
1848,
357,
445,
26873,
5236,
8,
37811,
198,
220,
220,
220,
220,
220,
220,
220,
2116,
13,
20427,
48185,
1637,
62,
4480,
19334,
198,
198,
4871,
12033,
30116,
7,
28650,
30116,
2599,
198,
220,
220,
220,
37227,
6030,
286,
3331,
1848,
326,
29339,
1393,
37811,
198,
220,
220,
220,
825,
751,
62,
9446,
7,
944,
11,
2494,
2599,
198,
220,
220,
220,
220,
220,
220,
220,
37227,
46245,
1393,
284,
3331,
1848,
37811,
198,
220,
220,
220,
220,
220,
220,
220,
1393,
796,
2116,
13,
20427,
9,
4873,
198,
220,
220,
220,
220,
220,
220,
220,
2116,
13,
10378,
7434,
7,
9446,
8,
198,
198,
2,
23983,
503,
5018,
30116,
1398,
198,
4798,
7203,
35937,
44154,
5018,
30116,
35937,
4943,
198,
17796,
30116,
796,
5018,
30116,
7203,
42,
37518,
272,
33110,
1600,
17031,
29228,
8,
198,
4798,
7,
17796,
30116,
8,
198,
4798,
3419,
198,
198,
17796,
30116,
13,
13812,
62,
20427,
3419,
198,
4798,
3419,
198,
198,
17796,
30116,
13,
10378,
7434,
7,
2682,
13,
4309,
8,
198,
4798,
7,
17796,
30116,
8,
198,
4798,
3419,
198,
198,
17796,
30116,
13,
4480,
19334,
7,
1065,
13,
1495,
8,
198,
4798,
7,
17796,
30116,
8,
198,
4798,
3419,
198,
198,
17796,
30116,
13,
4480,
19334,
7,
1270,
13,
1507,
8,
198,
4798,
7,
17796,
30116,
8,
198,
4798,
3419,
198,
198,
2,
23983,
503,
12033,
30116,
1398,
198,
4798,
7203,
35937,
44154,
12033,
30116,
35937,
4943,
198,
9446,
30116,
796,
12033,
30116,
7203,
42,
37518,
272,
33110,
1600,
2242,
2231,
3134,
8,
198,
4798,
7,
9446,
30116,
8,
198,
4798,
3419,
198,
198,
9446,
30116,
13,
13812,
62,
20427,
3419,
198,
4798,
3419,
198,
198,
9446,
30116,
13,
10378,
7434,
7,
2682,
13,
4309,
8,
198,
4798,
7,
9446,
30116,
8,
198,
4798,
3419,
198,
198,
9446,
30116,
13,
2860,
62,
9446,
7,
15,
13,
1157,
8,
198,
4798,
7,
9446,
30116,
8,
198
] | 3.174168 | 511 |
import platform
import textwrap
import termios
import struct
import fcntl
import sys
from accessories import (
as_subprocess,
TestTerminal,
many_columns,
all_terms,
)
import pytest
def test_SequenceWrapper_invalid_width():
"""Test exception thrown from invalid width"""
WIDTH = -3
@as_subprocess
child()
def test_SequenceWrapper_drop_whitespace_subsequent_indent():
"""Test that text wrapping matches internal extra options."""
WIDTH = 10
@as_subprocess
child()
@pytest.mark.skipif(platform.python_implementation() == 'PyPy',
reason='PyPy fails TIOCSWINSZ')
def test_SequenceWrapper(all_terms, many_columns):
"""Test that text wrapping accounts for sequences correctly."""
@as_subprocess
child(kind=all_terms, lines=25, cols=many_columns)
def test_SequenceWrapper_27(all_terms):
"""Test that text wrapping accounts for sequences correctly."""
WIDTH = 27
@as_subprocess
child(kind=all_terms)
| [
11748,
3859,
198,
11748,
2420,
37150,
198,
11748,
3381,
4267,
198,
11748,
2878,
198,
11748,
277,
66,
429,
75,
198,
11748,
25064,
198,
198,
6738,
18199,
1330,
357,
198,
220,
220,
220,
355,
62,
7266,
14681,
11,
198,
220,
220,
220,
6208,
44798,
282,
11,
198,
220,
220,
220,
867,
62,
28665,
82,
11,
198,
220,
220,
220,
477,
62,
38707,
11,
198,
8,
198,
198,
11748,
12972,
9288,
628,
198,
4299,
1332,
62,
44015,
594,
36918,
2848,
62,
259,
12102,
62,
10394,
33529,
198,
220,
220,
220,
37227,
14402,
6631,
8754,
422,
12515,
9647,
37811,
198,
220,
220,
220,
370,
2389,
4221,
796,
532,
18,
628,
220,
220,
220,
2488,
292,
62,
7266,
14681,
628,
220,
220,
220,
1200,
3419,
628,
198,
4299,
1332,
62,
44015,
594,
36918,
2848,
62,
14781,
62,
1929,
2737,
10223,
62,
7266,
44399,
62,
521,
298,
33529,
198,
220,
220,
220,
37227,
14402,
326,
2420,
27074,
7466,
5387,
3131,
3689,
526,
15931,
198,
220,
220,
220,
370,
2389,
4221,
796,
838,
628,
220,
220,
220,
2488,
292,
62,
7266,
14681,
628,
220,
220,
220,
1200,
3419,
628,
198,
31,
9078,
9288,
13,
4102,
13,
48267,
361,
7,
24254,
13,
29412,
62,
320,
32851,
3419,
6624,
705,
20519,
20519,
3256,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1738,
11639,
20519,
20519,
10143,
31598,
4503,
17887,
20913,
57,
11537,
198,
4299,
1332,
62,
44015,
594,
36918,
2848,
7,
439,
62,
38707,
11,
867,
62,
28665,
82,
2599,
198,
220,
220,
220,
37227,
14402,
326,
2420,
27074,
5504,
329,
16311,
9380,
526,
15931,
198,
220,
220,
220,
2488,
292,
62,
7266,
14681,
628,
220,
220,
220,
1200,
7,
11031,
28,
439,
62,
38707,
11,
3951,
28,
1495,
11,
951,
82,
28,
21834,
62,
28665,
82,
8,
628,
198,
4299,
1332,
62,
44015,
594,
36918,
2848,
62,
1983,
7,
439,
62,
38707,
2599,
198,
220,
220,
220,
37227,
14402,
326,
2420,
27074,
5504,
329,
16311,
9380,
526,
15931,
198,
220,
220,
220,
370,
2389,
4221,
796,
2681,
628,
220,
220,
220,
2488,
292,
62,
7266,
14681,
628,
220,
220,
220,
1200,
7,
11031,
28,
439,
62,
38707,
8,
198
] | 2.758242 | 364 |
from logging import getLogger
from os import system
from discord.ext import commands
import discord
from src.constants import Colours
from src.exts.utils.converter import acute_remover
log = getLogger(__name__)
class Commands(commands.Cog):
"""A couple of simple commands."""
@commands.command(name="hello", aliases=("hey", "hlo", "test"))
@commands.is_owner()
@commands.command(name="eval", aliases=("e", ))
@commands.is_owner()
@commands.command(name="cmd", aliases=("os", "shell", "bash", ))
@commands.command(name='devil', aliases=("mr_devil",))
| [
6738,
18931,
1330,
651,
11187,
1362,
198,
6738,
28686,
1330,
1080,
198,
198,
6738,
36446,
13,
2302,
1330,
9729,
198,
11748,
36446,
198,
198,
6738,
12351,
13,
9979,
1187,
1330,
1623,
4662,
198,
6738,
12351,
13,
2302,
82,
13,
26791,
13,
1102,
332,
353,
1330,
14352,
62,
2787,
2502,
628,
198,
6404,
796,
651,
11187,
1362,
7,
834,
3672,
834,
8,
628,
198,
4871,
49505,
7,
9503,
1746,
13,
34,
519,
2599,
198,
220,
220,
220,
37227,
32,
3155,
286,
2829,
9729,
526,
15931,
628,
220,
220,
220,
2488,
9503,
1746,
13,
21812,
7,
3672,
2625,
31373,
1600,
47217,
28,
7203,
20342,
1600,
366,
71,
5439,
1600,
366,
9288,
48774,
628,
220,
220,
220,
2488,
9503,
1746,
13,
271,
62,
18403,
3419,
198,
220,
220,
220,
2488,
9503,
1746,
13,
21812,
7,
3672,
2625,
18206,
1600,
47217,
28,
7203,
68,
1600,
15306,
628,
220,
220,
220,
2488,
9503,
1746,
13,
271,
62,
18403,
3419,
198,
220,
220,
220,
2488,
9503,
1746,
13,
21812,
7,
3672,
2625,
28758,
1600,
47217,
28,
7203,
418,
1600,
366,
29149,
1600,
366,
41757,
1600,
15306,
628,
220,
220,
220,
2488,
9503,
1746,
13,
21812,
7,
3672,
11639,
7959,
346,
3256,
47217,
28,
7203,
43395,
62,
7959,
346,
1600,
4008,
628
] | 2.873171 | 205 |
#나누어 떨어지는 숫자 배열
'''
채점을 시작합니다.
정확성 테스트
테스트 1 〉 통과 (0.02ms, 10.2MB)
테스트 2 〉 통과 (0.01ms, 10.3MB)
테스트 3 〉 통과 (0.02ms, 10.2MB)
테스트 4 〉 통과 (0.02ms, 10.2MB)
테스트 5 〉 통과 (0.01ms, 10.1MB)
테스트 6 〉 통과 (3.22ms, 13.4MB)
테스트 7 〉 통과 (0.27ms, 10.3MB)
테스트 8 〉 통과 (0.00ms, 10.2MB)
테스트 9 〉 통과 (0.19ms, 10.2MB)
테스트 10 〉 통과 (0.13ms, 10.2MB)
테스트 11 〉 통과 (0.06ms, 10.2MB)
테스트 12 〉 통과 (0.06ms, 10.1MB)
테스트 13 〉 통과 (0.44ms, 10.3MB)
테스트 14 〉 통과 (0.28ms, 10.3MB)
테스트 15 〉 통과 (0.14ms, 10.3MB)
테스트 16 〉 통과 (0.04ms, 10.2MB)
채점 결과
정확성: 100.0
합계: 100.0 / 100.0
''' | [
2,
167,
224,
246,
167,
230,
226,
168,
244,
112,
31619,
244,
101,
168,
244,
112,
168,
100,
222,
167,
232,
242,
23821,
230,
104,
168,
252,
238,
31619,
108,
108,
168,
245,
112,
628,
198,
7061,
6,
198,
168,
109,
226,
168,
254,
238,
35975,
226,
23821,
233,
250,
168,
252,
239,
47991,
102,
46695,
230,
46695,
97,
13,
198,
168,
254,
243,
169,
247,
243,
168,
226,
109,
220,
220,
169,
227,
234,
168,
232,
97,
169,
232,
116,
198,
169,
227,
234,
168,
232,
97,
169,
232,
116,
352,
220,
5099,
231,
197,
169,
228,
113,
166,
111,
120,
357,
15,
13,
2999,
907,
11,
838,
13,
17,
10744,
8,
198,
169,
227,
234,
168,
232,
97,
169,
232,
116,
362,
220,
5099,
231,
197,
169,
228,
113,
166,
111,
120,
357,
15,
13,
486,
907,
11,
838,
13,
18,
10744,
8,
198,
169,
227,
234,
168,
232,
97,
169,
232,
116,
513,
220,
5099,
231,
197,
169,
228,
113,
166,
111,
120,
357,
15,
13,
2999,
907,
11,
838,
13,
17,
10744,
8,
198,
169,
227,
234,
168,
232,
97,
169,
232,
116,
604,
220,
5099,
231,
197,
169,
228,
113,
166,
111,
120,
357,
15,
13,
2999,
907,
11,
838,
13,
17,
10744,
8,
198,
169,
227,
234,
168,
232,
97,
169,
232,
116,
642,
220,
5099,
231,
197,
169,
228,
113,
166,
111,
120,
357,
15,
13,
486,
907,
11,
838,
13,
16,
10744,
8,
198,
169,
227,
234,
168,
232,
97,
169,
232,
116,
718,
220,
5099,
231,
197,
169,
228,
113,
166,
111,
120,
357,
18,
13,
1828,
907,
11,
1511,
13,
19,
10744,
8,
198,
169,
227,
234,
168,
232,
97,
169,
232,
116,
767,
220,
5099,
231,
197,
169,
228,
113,
166,
111,
120,
357,
15,
13,
1983,
907,
11,
838,
13,
18,
10744,
8,
198,
169,
227,
234,
168,
232,
97,
169,
232,
116,
807,
220,
5099,
231,
197,
169,
228,
113,
166,
111,
120,
357,
15,
13,
405,
907,
11,
838,
13,
17,
10744,
8,
198,
169,
227,
234,
168,
232,
97,
169,
232,
116,
860,
220,
5099,
231,
197,
169,
228,
113,
166,
111,
120,
357,
15,
13,
1129,
907,
11,
838,
13,
17,
10744,
8,
198,
169,
227,
234,
168,
232,
97,
169,
232,
116,
838,
220,
5099,
231,
197,
169,
228,
113,
166,
111,
120,
357,
15,
13,
1485,
907,
11,
838,
13,
17,
10744,
8,
198,
169,
227,
234,
168,
232,
97,
169,
232,
116,
1367,
220,
5099,
231,
197,
169,
228,
113,
166,
111,
120,
357,
15,
13,
3312,
907,
11,
838,
13,
17,
10744,
8,
198,
169,
227,
234,
168,
232,
97,
169,
232,
116,
1105,
220,
5099,
231,
197,
169,
228,
113,
166,
111,
120,
357,
15,
13,
3312,
907,
11,
838,
13,
16,
10744,
8,
198,
169,
227,
234,
168,
232,
97,
169,
232,
116,
1511,
220,
5099,
231,
197,
169,
228,
113,
166,
111,
120,
357,
15,
13,
2598,
907,
11,
838,
13,
18,
10744,
8,
198,
169,
227,
234,
168,
232,
97,
169,
232,
116,
1478,
220,
5099,
231,
197,
169,
228,
113,
166,
111,
120,
357,
15,
13,
2078,
907,
11,
838,
13,
18,
10744,
8,
198,
169,
227,
234,
168,
232,
97,
169,
232,
116,
1315,
220,
5099,
231,
197,
169,
228,
113,
166,
111,
120,
357,
15,
13,
1415,
907,
11,
838,
13,
18,
10744,
8,
198,
169,
227,
234,
168,
232,
97,
169,
232,
116,
1467,
220,
5099,
231,
197,
169,
228,
113,
166,
111,
120,
357,
15,
13,
3023,
907,
11,
838,
13,
17,
10744,
8,
198,
168,
109,
226,
168,
254,
238,
220,
166,
110,
108,
166,
111,
120,
198,
168,
254,
243,
169,
247,
243,
168,
226,
109,
25,
1802,
13,
15,
198,
47991,
102,
166,
111,
226,
25,
1802,
13,
15,
1220,
1802,
13,
15,
198,
7061,
6
] | 0.838558 | 638 |
# -*- coding: utf-8 -*-
"""
Class for the ogs FUNCTION file.
.. currentmodule:: ogs5py.fileclasses.fct
File Class
^^^^^^^^^^
.. autosummary::
FCT
----
"""
from ogs5py.fileclasses.fct.core import FCT
__all__ = ["FCT"]
| [
2,
532,
9,
12,
19617,
25,
3384,
69,
12,
23,
532,
9,
12,
198,
37811,
198,
9487,
329,
262,
267,
14542,
29397,
4177,
2849,
2393,
13,
198,
198,
492,
1459,
21412,
3712,
267,
14542,
20,
9078,
13,
7753,
37724,
13,
69,
310,
198,
198,
8979,
5016,
198,
39397,
39397,
18237,
198,
198,
492,
44619,
388,
6874,
3712,
198,
220,
220,
376,
4177,
198,
198,
650,
198,
37811,
198,
6738,
267,
14542,
20,
9078,
13,
7753,
37724,
13,
69,
310,
13,
7295,
1330,
376,
4177,
198,
198,
834,
439,
834,
796,
14631,
37,
4177,
8973,
198
] | 2.368421 | 95 |
#! /usr/bin/env python
# -*- coding: UTF-8 -*-
#
# Copyright (c) 2014, Dionach Ltd. All rights reserved. See LICENSE file.
#
# PANhunt: search directories and sub directories for documents with PANs
# By BB
import os
import sys
import re
import argparse
import time
import hashlib
import platform
import colorama
import configparser
import filehunt
import psutil
from pathlib import Path
home = str(Path.home())
if sys.version_info[0] >= 3:
unicode = str
app_version = '1.2.2'
# defaults
defaults = {
'search_dir': home,
'output_file': u'panhunt_%s.txt' % time.strftime("%Y-%m-%d-%H%M%S"),
'excluded_directories_string': u'C:\\Windows,C:\\Program Files,C:\\Program Files (x86)',
'text_extensions_string': u'.doc,.xls,.xml,.txt,.csv,.log,.tmp,.bak,.rtf,.csv,.htm,.html,.js,.css,.md',
'zip_extensions_string': u'.docx,.xlsx,.zip',
'special_extensions_string': u'.msg',
'mail_extensions_string': u'.pst',
'other_extensions_string': u'.ost,.accdb,.mdb', # checks for existence of files that can't be checked automatically
'excluded_pans_string': '',
'config_file': u'panhunt.ini'
}
search_dir = defaults['search_dir']
output_file = defaults['output_file']
excluded_directories_string = defaults['excluded_directories_string']
text_extensions_string = defaults['text_extensions_string']
zip_extensions_string = defaults['zip_extensions_string']
special_extensions_string = defaults['special_extensions_string']
mail_extensions_string = defaults['mail_extensions_string']
other_extensions_string = defaults['other_extensions_string']
excluded_pans_string = defaults['excluded_pans_string']
config_file = defaults['config_file']
excluded_directories = None
excluded_pans = []
search_extensions = {}
pan_regexs = {'Mastercard': re.compile('(?:\D|^)(5[1-5][0-9]{2}(?:\ |\-|)[0-9]{4}(?:\ |\-|)[0-9]{4}(?:\ |\-|)[0-9]{4})(?:\D|$)'),
'Visa': re.compile('(?:\D|^)(4[0-9]{3}(?:\ |\-|)[0-9]{4}(?:\ |\-|)[0-9]{4}(?:\ |\-|)[0-9]{4})(?:\D|$)'),
'AMEX': re.compile('(?:\D|^)((?:34|37)[0-9]{2}(?:\ |\-|)[0-9]{6}(?:\ |\-|)[0-9]{5})(?:\D|$)')}
###################################################################################################################################
# ____ _
# / ___| | __ _ ___ ___ ___ ___
# | | | |/ _` / __/ __|/ _ \/ __|
# | |___| | (_| \__ \__ \ __/\__ \
# \____|_|\__,_|___/___/\___||___/
#
###################################################################################################################################
class PANFile(filehunt.AFile):
""" PANFile: class for a file that can check itself for PANs"""
def check_text_regexs(self, text, regexs, sub_path):
"""Uses regular expressions to check for PANs in text"""
for brand, regex in regexs.items():
pans = regex.findall(text.decode('utf-8', 'replace'))
if pans:
for pan in pans:
if PAN.is_valid_luhn_checksum(pan) and not PAN.is_excluded(pan):
self.matches.append(PAN(self.path, sub_path, brand, pan))
class PAN:
"""PAN: A class for recording PANs, their brand and where they were found"""
@staticmethod
@staticmethod
###################################################################################################################################
# __ __ _ _ _____ _ _
# | \/ | ___ __| |_ _| | ___ | ___| _ _ __ ___| |_(_) ___ _ __ ___
# | |\/| |/ _ \ / _` | | | | |/ _ \ | |_ | | | | '_ \ / __| __| |/ _ \| '_ \/ __|
# | | | | (_) | (_| | |_| | | __/ | _|| |_| | | | | (__| |_| | (_) | | | \__ \
# |_| |_|\___/ \__,_|\__,_|_|\___| |_| \__,_|_| |_|\___|\__|_|\___/|_| |_|___/
#
###################################################################################################################################
###################################################################################################################################
# __ __ _
# | \/ | __ _(_)_ __
# | |\/| |/ _` | | '_ \
# | | | | (_| | | | | |
# |_| |_|\__,_|_|_| |_|
#
###################################################################################################################################
if __name__ == "__main__":
colorama.init()
# Command Line Arguments
arg_parser = argparse.ArgumentParser(prog='panhunt', description='PAN Hunt v%s: search directories and sub directories for documents containing PANs.' % (app_version), formatter_class=argparse.ArgumentDefaultsHelpFormatter)
arg_parser.add_argument('-s', dest='search', default=search_dir, help='base directory to search in')
arg_parser.add_argument('-x', dest='exclude', default=excluded_directories_string, help='directories to exclude from the search')
arg_parser.add_argument('-t', dest='textfiles', default=text_extensions_string, help='text file extensions to search')
arg_parser.add_argument('-z', dest='zipfiles', default=zip_extensions_string, help='zip file extensions to search')
arg_parser.add_argument('-e', dest='specialfiles', default=special_extensions_string, help='special file extensions to search')
arg_parser.add_argument('-m', dest='mailfiles', default=mail_extensions_string, help='email file extensions to search')
arg_parser.add_argument('-l', dest='otherfiles', default=other_extensions_string, help='other file extensions to list')
arg_parser.add_argument('-o', dest='outfile', default=output_file, help='output file name for PAN report')
arg_parser.add_argument('-u', dest='unmask', action='store_true', default=False, help='unmask PANs in output')
arg_parser.add_argument('-C', dest='config', default=config_file, help='configuration file to use')
arg_parser.add_argument('-X', dest='excludepan', default=excluded_pans_string, help='PAN to exclude from search')
arg_parser.add_argument('-c', dest='checkfilehash', help=argparse.SUPPRESS) # hidden argument
arg_parser.add_argument('-N', dest='nice', action='store_false', default=True, help='reduce priority and scheduling class')
args = arg_parser.parse_args()
if args.checkfilehash:
check_file_hash(args.checkfilehash)
sys.exit()
search_dir = unicode(args.search)
output_file = unicode(args.outfile)
excluded_directories_string = unicode(args.exclude)
text_extensions_string = unicode(args.textfiles)
zip_extensions_string = unicode(args.zipfiles)
special_extensions_string = unicode(args.specialfiles)
mail_extensions_string = unicode(args.mailfiles)
other_extensions_string = unicode(args.otherfiles)
mask_pans = not args.unmask
excluded_pans_string = unicode(args.excludepan)
config_file = unicode(args.config)
load_config_file()
set_global_parameters()
if args.nice:
p = psutil.Process(os.getpid())
if sys.platform == 'win32':
p.nice(psutil.BELOW_NORMAL_PRIORITY_CLASS)
else:
p.nice(10)
total_files_searched, pans_found, all_files = hunt_pans()
# report findings
output_report(search_dir, excluded_directories_string, all_files, total_files_searched, pans_found, output_file, mask_pans)
| [
2,
0,
1220,
14629,
14,
8800,
14,
24330,
21015,
198,
2,
532,
9,
12,
19617,
25,
41002,
12,
23,
532,
9,
12,
198,
2,
198,
2,
15069,
357,
66,
8,
1946,
11,
29628,
620,
12052,
13,
1439,
2489,
10395,
13,
4091,
38559,
24290,
2393,
13,
198,
2,
198,
2,
40468,
35060,
25,
2989,
29196,
290,
850,
29196,
329,
4963,
351,
40468,
82,
198,
2,
2750,
12597,
198,
198,
11748,
28686,
198,
11748,
25064,
198,
11748,
302,
198,
11748,
1822,
29572,
198,
11748,
640,
198,
11748,
12234,
8019,
198,
11748,
3859,
198,
11748,
3124,
1689,
198,
11748,
4566,
48610,
198,
11748,
2393,
35060,
198,
11748,
26692,
22602,
198,
198,
6738,
3108,
8019,
1330,
10644,
198,
11195,
796,
965,
7,
15235,
13,
11195,
28955,
198,
198,
361,
25064,
13,
9641,
62,
10951,
58,
15,
60,
18189,
513,
25,
198,
220,
220,
220,
28000,
1098,
796,
965,
198,
198,
1324,
62,
9641,
796,
705,
16,
13,
17,
13,
17,
6,
198,
198,
2,
26235,
198,
12286,
82,
796,
1391,
198,
220,
220,
220,
705,
12947,
62,
15908,
10354,
1363,
11,
198,
220,
220,
220,
705,
22915,
62,
7753,
10354,
334,
6,
6839,
35060,
62,
4,
82,
13,
14116,
6,
4064,
640,
13,
2536,
31387,
7203,
4,
56,
12,
4,
76,
12,
4,
67,
12,
4,
39,
4,
44,
4,
50,
12340,
198,
220,
220,
220,
705,
1069,
10341,
62,
12942,
1749,
62,
8841,
10354,
334,
6,
34,
25,
6852,
11209,
11,
34,
25,
6852,
15167,
13283,
11,
34,
25,
6852,
15167,
13283,
357,
87,
4521,
8,
3256,
198,
220,
220,
220,
705,
5239,
62,
2302,
5736,
62,
8841,
10354,
334,
4458,
15390,
38508,
87,
7278,
38508,
19875,
38508,
14116,
38508,
40664,
38508,
6404,
38508,
22065,
38508,
65,
461,
38508,
17034,
69,
38508,
40664,
38508,
19211,
38508,
6494,
38508,
8457,
38508,
25471,
38508,
9132,
3256,
198,
220,
220,
220,
705,
13344,
62,
2302,
5736,
62,
8841,
10354,
334,
4458,
15390,
87,
38508,
87,
7278,
87,
38508,
13344,
3256,
198,
220,
220,
220,
705,
20887,
62,
2302,
5736,
62,
8841,
10354,
334,
4458,
19662,
3256,
198,
220,
220,
220,
705,
4529,
62,
2302,
5736,
62,
8841,
10354,
334,
4458,
79,
301,
3256,
198,
220,
220,
220,
705,
847,
62,
2302,
5736,
62,
8841,
10354,
334,
4458,
455,
38508,
4134,
9945,
38508,
9132,
65,
3256,
220,
1303,
8794,
329,
6224,
286,
3696,
326,
460,
470,
307,
10667,
6338,
198,
220,
220,
220,
705,
1069,
10341,
62,
79,
504,
62,
8841,
10354,
705,
3256,
198,
220,
220,
220,
705,
11250,
62,
7753,
10354,
334,
6,
6839,
35060,
13,
5362,
6,
198,
92,
198,
12947,
62,
15908,
796,
26235,
17816,
12947,
62,
15908,
20520,
198,
22915,
62,
7753,
796,
26235,
17816,
22915,
62,
7753,
20520,
198,
1069,
10341,
62,
12942,
1749,
62,
8841,
796,
26235,
17816,
1069,
10341,
62,
12942,
1749,
62,
8841,
20520,
198,
5239,
62,
2302,
5736,
62,
8841,
796,
26235,
17816,
5239,
62,
2302,
5736,
62,
8841,
20520,
198,
13344,
62,
2302,
5736,
62,
8841,
796,
26235,
17816,
13344,
62,
2302,
5736,
62,
8841,
20520,
198,
20887,
62,
2302,
5736,
62,
8841,
796,
26235,
17816,
20887,
62,
2302,
5736,
62,
8841,
20520,
198,
4529,
62,
2302,
5736,
62,
8841,
796,
26235,
17816,
4529,
62,
2302,
5736,
62,
8841,
20520,
198,
847,
62,
2302,
5736,
62,
8841,
796,
26235,
17816,
847,
62,
2302,
5736,
62,
8841,
20520,
198,
1069,
10341,
62,
79,
504,
62,
8841,
796,
26235,
17816,
1069,
10341,
62,
79,
504,
62,
8841,
20520,
198,
11250,
62,
7753,
796,
26235,
17816,
11250,
62,
7753,
20520,
198,
198,
1069,
10341,
62,
12942,
1749,
796,
6045,
198,
1069,
10341,
62,
79,
504,
796,
17635,
198,
12947,
62,
2302,
5736,
796,
23884,
198,
198,
6839,
62,
260,
25636,
82,
796,
1391,
6,
18254,
9517,
10354,
302,
13,
5589,
576,
10786,
7,
30,
7479,
35,
91,
61,
5769,
20,
58,
16,
12,
20,
7131,
15,
12,
24,
60,
90,
17,
92,
7,
30,
7479,
930,
59,
22831,
38381,
15,
12,
24,
60,
90,
19,
92,
7,
30,
7479,
930,
59,
22831,
38381,
15,
12,
24,
60,
90,
19,
92,
7,
30,
7479,
930,
59,
22831,
38381,
15,
12,
24,
60,
90,
19,
92,
5769,
30,
7479,
35,
91,
3,
33047,
828,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
705,
53,
9160,
10354,
302,
13,
5589,
576,
10786,
7,
30,
7479,
35,
91,
61,
5769,
19,
58,
15,
12,
24,
60,
90,
18,
92,
7,
30,
7479,
930,
59,
22831,
38381,
15,
12,
24,
60,
90,
19,
92,
7,
30,
7479,
930,
59,
22831,
38381,
15,
12,
24,
60,
90,
19,
92,
7,
30,
7479,
930,
59,
22831,
38381,
15,
12,
24,
60,
90,
19,
92,
5769,
30,
7479,
35,
91,
3,
33047,
828,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
705,
2390,
6369,
10354,
302,
13,
5589,
576,
10786,
7,
30,
7479,
35,
91,
61,
5769,
7,
27514,
2682,
91,
2718,
38381,
15,
12,
24,
60,
90,
17,
92,
7,
30,
7479,
930,
59,
22831,
38381,
15,
12,
24,
60,
90,
21,
92,
7,
30,
7479,
930,
59,
22831,
38381,
15,
12,
24,
60,
90,
20,
92,
5769,
30,
7479,
35,
91,
3,
8,
11537,
92,
628,
198,
29113,
29113,
29113,
29113,
21017,
198,
2,
220,
220,
220,
1427,
4808,
198,
2,
220,
1220,
46444,
91,
930,
11593,
4808,
46444,
46444,
220,
46444,
220,
46444,
198,
2,
930,
930,
220,
220,
930,
930,
14,
4808,
63,
1220,
11593,
14,
11593,
91,
14,
4808,
3467,
14,
11593,
91,
198,
2,
930,
930,
17569,
91,
930,
44104,
91,
3467,
834,
3467,
834,
3467,
220,
11593,
14,
59,
834,
3467,
198,
2,
220,
3467,
1427,
91,
62,
91,
59,
834,
11,
62,
91,
17569,
14,
17569,
14,
59,
17569,
15886,
17569,
14,
198,
2,
198,
29113,
29113,
29113,
29113,
21017,
628,
198,
4871,
40468,
8979,
7,
7753,
35060,
13,
8579,
576,
2599,
198,
220,
220,
220,
37227,
40468,
8979,
25,
1398,
329,
257,
2393,
326,
460,
2198,
2346,
329,
40468,
82,
37811,
628,
220,
220,
220,
825,
2198,
62,
5239,
62,
260,
25636,
82,
7,
944,
11,
2420,
11,
40364,
82,
11,
850,
62,
6978,
2599,
198,
220,
220,
220,
220,
220,
220,
220,
37227,
5842,
274,
3218,
14700,
284,
2198,
329,
40468,
82,
287,
2420,
37811,
628,
220,
220,
220,
220,
220,
220,
220,
329,
4508,
11,
40364,
287,
40364,
82,
13,
23814,
33529,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
36209,
796,
40364,
13,
19796,
439,
7,
5239,
13,
12501,
1098,
10786,
40477,
12,
23,
3256,
705,
33491,
6,
4008,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
611,
36209,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
329,
3425,
287,
36209,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
611,
40468,
13,
271,
62,
12102,
62,
2290,
21116,
62,
42116,
388,
7,
6839,
8,
290,
407,
40468,
13,
271,
62,
1069,
10341,
7,
6839,
2599,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2116,
13,
6759,
2052,
13,
33295,
7,
47,
1565,
7,
944,
13,
6978,
11,
850,
62,
6978,
11,
4508,
11,
3425,
4008,
628,
198,
4871,
40468,
25,
198,
220,
220,
220,
37227,
47,
1565,
25,
317,
1398,
329,
8296,
40468,
82,
11,
511,
4508,
290,
810,
484,
547,
1043,
37811,
628,
220,
220,
220,
2488,
12708,
24396,
628,
220,
220,
220,
2488,
12708,
24396,
628,
198,
29113,
29113,
29113,
29113,
21017,
198,
2,
220,
11593,
220,
11593,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
4808,
220,
220,
220,
220,
220,
220,
4808,
220,
220,
220,
220,
220,
220,
220,
220,
29343,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
4808,
220,
220,
4808,
198,
2,
930,
220,
3467,
14,
220,
930,
46444,
220,
220,
11593,
91,
930,
62,
220,
220,
4808,
91,
930,
46444,
220,
930,
220,
46444,
91,
220,
220,
4808,
4808,
11593,
220,
220,
46444,
91,
930,
62,
28264,
8,
46444,
220,
4808,
11593,
220,
46444,
198,
2,
930,
930,
11139,
91,
930,
14,
4808,
3467,
1220,
4808,
63,
930,
930,
930,
930,
930,
14,
4808,
3467,
930,
930,
62,
930,
930,
930,
930,
705,
62,
3467,
1220,
11593,
91,
11593,
91,
930,
14,
4808,
3467,
91,
705,
62,
3467,
14,
11593,
91,
198,
2,
930,
930,
220,
930,
930,
44104,
8,
930,
44104,
91,
930,
930,
62,
91,
930,
930,
220,
11593,
14,
930,
220,
4808,
15886,
930,
62,
91,
930,
930,
930,
930,
357,
834,
91,
930,
62,
91,
930,
44104,
8,
930,
930,
930,
3467,
834,
3467,
198,
2,
930,
62,
91,
220,
930,
62,
91,
59,
17569,
14,
3467,
834,
11,
62,
91,
59,
834,
11,
62,
91,
62,
91,
59,
17569,
91,
930,
62,
91,
220,
220,
3467,
834,
11,
62,
91,
62,
91,
930,
62,
91,
59,
17569,
91,
59,
834,
91,
62,
91,
59,
17569,
14,
91,
62,
91,
930,
62,
91,
17569,
14,
198,
2,
198,
29113,
29113,
29113,
29113,
21017,
628,
628,
628,
628,
198,
198,
29113,
29113,
29113,
29113,
21017,
198,
2,
220,
11593,
220,
11593,
220,
220,
220,
220,
220,
220,
4808,
198,
2,
930,
220,
3467,
14,
220,
930,
11593,
4808,
28264,
8,
62,
11593,
198,
2,
930,
930,
11139,
91,
930,
14,
4808,
63,
930,
930,
705,
62,
3467,
198,
2,
930,
930,
220,
930,
930,
44104,
91,
930,
930,
930,
930,
930,
198,
2,
930,
62,
91,
220,
930,
62,
91,
59,
834,
11,
62,
91,
62,
91,
62,
91,
930,
62,
91,
198,
2,
198,
29113,
29113,
29113,
29113,
21017,
628,
198,
361,
11593,
3672,
834,
6624,
366,
834,
12417,
834,
1298,
628,
220,
220,
220,
3124,
1689,
13,
15003,
3419,
628,
220,
220,
220,
1303,
9455,
6910,
20559,
2886,
198,
220,
220,
220,
1822,
62,
48610,
796,
1822,
29572,
13,
28100,
1713,
46677,
7,
1676,
70,
11639,
6839,
35060,
3256,
6764,
11639,
47,
1565,
12937,
410,
4,
82,
25,
2989,
29196,
290,
850,
29196,
329,
4963,
7268,
40468,
82,
2637,
4064,
357,
1324,
62,
9641,
828,
1296,
1436,
62,
4871,
28,
853,
29572,
13,
28100,
1713,
7469,
13185,
22087,
8479,
1436,
8,
198,
220,
220,
220,
1822,
62,
48610,
13,
2860,
62,
49140,
10786,
12,
82,
3256,
2244,
11639,
12947,
3256,
4277,
28,
12947,
62,
15908,
11,
1037,
11639,
8692,
8619,
284,
2989,
287,
11537,
198,
220,
220,
220,
1822,
62,
48610,
13,
2860,
62,
49140,
10786,
12,
87,
3256,
2244,
11639,
1069,
9152,
3256,
4277,
28,
1069,
10341,
62,
12942,
1749,
62,
8841,
11,
1037,
11639,
12942,
1749,
284,
19607,
422,
262,
2989,
11537,
198,
220,
220,
220,
1822,
62,
48610,
13,
2860,
62,
49140,
10786,
12,
83,
3256,
2244,
11639,
5239,
16624,
3256,
4277,
28,
5239,
62,
2302,
5736,
62,
8841,
11,
1037,
11639,
5239,
2393,
18366,
284,
2989,
11537,
198,
220,
220,
220,
1822,
62,
48610,
13,
2860,
62,
49140,
10786,
12,
89,
3256,
2244,
11639,
13344,
16624,
3256,
4277,
28,
13344,
62,
2302,
5736,
62,
8841,
11,
1037,
11639,
13344,
2393,
18366,
284,
2989,
11537,
198,
220,
220,
220,
1822,
62,
48610,
13,
2860,
62,
49140,
10786,
12,
68,
3256,
2244,
11639,
20887,
16624,
3256,
4277,
28,
20887,
62,
2302,
5736,
62,
8841,
11,
1037,
11639,
20887,
2393,
18366,
284,
2989,
11537,
198,
220,
220,
220,
1822,
62,
48610,
13,
2860,
62,
49140,
10786,
12,
76,
3256,
2244,
11639,
4529,
16624,
3256,
4277,
28,
4529,
62,
2302,
5736,
62,
8841,
11,
1037,
11639,
12888,
2393,
18366,
284,
2989,
11537,
198,
220,
220,
220,
1822,
62,
48610,
13,
2860,
62,
49140,
10786,
12,
75,
3256,
2244,
11639,
847,
16624,
3256,
4277,
28,
847,
62,
2302,
5736,
62,
8841,
11,
1037,
11639,
847,
2393,
18366,
284,
1351,
11537,
198,
220,
220,
220,
1822,
62,
48610,
13,
2860,
62,
49140,
10786,
12,
78,
3256,
2244,
11639,
448,
7753,
3256,
4277,
28,
22915,
62,
7753,
11,
1037,
11639,
22915,
2393,
1438,
329,
40468,
989,
11537,
198,
220,
220,
220,
1822,
62,
48610,
13,
2860,
62,
49140,
10786,
12,
84,
3256,
2244,
11639,
403,
27932,
3256,
2223,
11639,
8095,
62,
7942,
3256,
4277,
28,
25101,
11,
1037,
11639,
403,
27932,
40468,
82,
287,
5072,
11537,
198,
220,
220,
220,
1822,
62,
48610,
13,
2860,
62,
49140,
10786,
12,
34,
3256,
2244,
11639,
11250,
3256,
4277,
28,
11250,
62,
7753,
11,
1037,
11639,
11250,
3924,
2393,
284,
779,
11537,
198,
220,
220,
220,
1822,
62,
48610,
13,
2860,
62,
49140,
10786,
12,
55,
3256,
2244,
11639,
1069,
758,
538,
272,
3256,
4277,
28,
1069,
10341,
62,
79,
504,
62,
8841,
11,
1037,
11639,
47,
1565,
284,
19607,
422,
2989,
11537,
198,
220,
220,
220,
1822,
62,
48610,
13,
2860,
62,
49140,
10786,
12,
66,
3256,
2244,
11639,
9122,
7753,
17831,
3256,
1037,
28,
853,
29572,
13,
40331,
32761,
8,
220,
1303,
7104,
4578,
198,
220,
220,
220,
1822,
62,
48610,
13,
2860,
62,
49140,
10786,
12,
45,
3256,
2244,
11639,
44460,
3256,
2223,
11639,
8095,
62,
9562,
3256,
4277,
28,
17821,
11,
1037,
11639,
445,
7234,
8475,
290,
26925,
1398,
11537,
628,
220,
220,
220,
26498,
796,
1822,
62,
48610,
13,
29572,
62,
22046,
3419,
628,
220,
220,
220,
611,
26498,
13,
9122,
7753,
17831,
25,
198,
220,
220,
220,
220,
220,
220,
220,
2198,
62,
7753,
62,
17831,
7,
22046,
13,
9122,
7753,
17831,
8,
198,
220,
220,
220,
220,
220,
220,
220,
25064,
13,
37023,
3419,
628,
220,
220,
220,
2989,
62,
15908,
796,
28000,
1098,
7,
22046,
13,
12947,
8,
198,
220,
220,
220,
5072,
62,
7753,
796,
28000,
1098,
7,
22046,
13,
448,
7753,
8,
198,
220,
220,
220,
15009,
62,
12942,
1749,
62,
8841,
796,
28000,
1098,
7,
22046,
13,
1069,
9152,
8,
198,
220,
220,
220,
2420,
62,
2302,
5736,
62,
8841,
796,
28000,
1098,
7,
22046,
13,
5239,
16624,
8,
198,
220,
220,
220,
19974,
62,
2302,
5736,
62,
8841,
796,
28000,
1098,
7,
22046,
13,
13344,
16624,
8,
198,
220,
220,
220,
2041,
62,
2302,
5736,
62,
8841,
796,
28000,
1098,
7,
22046,
13,
20887,
16624,
8,
198,
220,
220,
220,
6920,
62,
2302,
5736,
62,
8841,
796,
28000,
1098,
7,
22046,
13,
4529,
16624,
8,
198,
220,
220,
220,
584,
62,
2302,
5736,
62,
8841,
796,
28000,
1098,
7,
22046,
13,
847,
16624,
8,
198,
220,
220,
220,
9335,
62,
79,
504,
796,
407,
26498,
13,
403,
27932,
198,
220,
220,
220,
15009,
62,
79,
504,
62,
8841,
796,
28000,
1098,
7,
22046,
13,
1069,
758,
538,
272,
8,
198,
220,
220,
220,
4566,
62,
7753,
796,
28000,
1098,
7,
22046,
13,
11250,
8,
198,
220,
220,
220,
3440,
62,
11250,
62,
7753,
3419,
628,
220,
220,
220,
900,
62,
20541,
62,
17143,
7307,
3419,
628,
220,
220,
220,
611,
26498,
13,
44460,
25,
198,
220,
220,
220,
220,
220,
220,
220,
279,
796,
26692,
22602,
13,
18709,
7,
418,
13,
1136,
35317,
28955,
198,
220,
220,
220,
220,
220,
220,
220,
611,
25064,
13,
24254,
6624,
705,
5404,
2624,
10354,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
279,
13,
44460,
7,
862,
22602,
13,
33,
3698,
3913,
62,
35510,
42126,
62,
4805,
41254,
9050,
62,
31631,
8,
198,
220,
220,
220,
220,
220,
220,
220,
2073,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
279,
13,
44460,
7,
940,
8,
628,
220,
220,
220,
2472,
62,
16624,
62,
325,
283,
1740,
11,
36209,
62,
9275,
11,
477,
62,
16624,
796,
12601,
62,
79,
504,
3419,
628,
220,
220,
220,
1303,
989,
6373,
198,
220,
220,
220,
5072,
62,
13116,
7,
12947,
62,
15908,
11,
15009,
62,
12942,
1749,
62,
8841,
11,
477,
62,
16624,
11,
2472,
62,
16624,
62,
325,
283,
1740,
11,
36209,
62,
9275,
11,
5072,
62,
7753,
11,
9335,
62,
79,
504,
8,
198
] | 2.723019 | 2,650 |
self.description = "server failover after 404"
self.require_capability("curl")
p1 = pmpkg('pkg')
self.addpkg2db('sync', p1)
url_broke = self.add_simple_http_server({
'/{}'.format(p1.filename()): {
'code': 404,
'body': 'a',
}
})
url_good = self.add_simple_http_server({
'/{}'.format(p1.filename()): p1.makepkg_bytes(),
})
self.db['sync'].option['Server'] = [ url_broke, url_good ]
self.db['sync'].syncdir = False
self.cachepkgs = False
self.args = '-S pkg'
self.addrule("PACMAN_RETCODE=0")
self.addrule("PKG_EXIST=pkg")
| [
944,
13,
11213,
796,
366,
15388,
2038,
2502,
706,
32320,
1,
198,
944,
13,
46115,
62,
11128,
1799,
7203,
66,
6371,
4943,
198,
198,
79,
16,
796,
279,
3149,
10025,
10786,
35339,
11537,
198,
944,
13,
2860,
35339,
17,
9945,
10786,
27261,
3256,
279,
16,
8,
198,
198,
6371,
62,
7957,
365,
796,
2116,
13,
2860,
62,
36439,
62,
4023,
62,
15388,
15090,
198,
220,
220,
220,
31051,
90,
92,
4458,
18982,
7,
79,
16,
13,
34345,
3419,
2599,
1391,
198,
220,
220,
220,
220,
220,
220,
220,
705,
8189,
10354,
32320,
11,
198,
220,
220,
220,
220,
220,
220,
220,
705,
2618,
10354,
705,
64,
3256,
198,
220,
220,
220,
1782,
198,
30072,
198,
6371,
62,
11274,
796,
2116,
13,
2860,
62,
36439,
62,
4023,
62,
15388,
15090,
198,
220,
220,
220,
31051,
90,
92,
4458,
18982,
7,
79,
16,
13,
34345,
3419,
2599,
279,
16,
13,
15883,
35339,
62,
33661,
22784,
198,
30072,
198,
198,
944,
13,
9945,
17816,
27261,
6,
4083,
18076,
17816,
10697,
20520,
796,
685,
19016,
62,
7957,
365,
11,
19016,
62,
11274,
2361,
198,
944,
13,
9945,
17816,
27261,
6,
4083,
28869,
10210,
343,
796,
10352,
198,
944,
13,
23870,
35339,
82,
796,
10352,
198,
198,
944,
13,
22046,
796,
705,
12,
50,
279,
10025,
6,
198,
198,
944,
13,
2860,
25135,
7203,
44938,
10725,
62,
2200,
4825,
16820,
28,
15,
4943,
198,
944,
13,
2860,
25135,
7203,
40492,
38,
62,
6369,
8808,
28,
35339,
4943,
198
] | 2.271605 | 243 |
from bidict import bidict
| [
6738,
8406,
713,
1330,
8406,
713,
628
] | 3.857143 | 7 |
/home/wai/anaconda3/lib/python3.6/hmac.py | [
14,
11195,
14,
86,
1872,
14,
272,
330,
13533,
18,
14,
8019,
14,
29412,
18,
13,
21,
14,
71,
20285,
13,
9078
] | 1.863636 | 22 |
"""
# ==================================
# AUTHOR : Yan Li, Qiong Wang
# CREATE DATE : 02.10.2020
# Contact : [email protected]
# ==================================
# Change History: None
# ==================================
"""
########## Import python libs ##########
import os
########## Import third-party libs ##########
import numpy as np
import cv2
########## light field camera/micro-lens array IDs ##########
########## light field scene path list ##########
########## load light field images ##########
########## load light field data ##########
########## prepare preds data ##########
########## get prediction data ##########
| [
37811,
201,
198,
2,
46111,
28,
201,
198,
2,
44746,
1058,
10642,
7455,
11,
1195,
295,
70,
15233,
201,
198,
2,
29244,
6158,
360,
6158,
1058,
7816,
13,
940,
13,
42334,
201,
198,
2,
14039,
1058,
7649,
4121,
87,
666,
1129,
31,
14816,
13,
785,
201,
198,
2,
46111,
28,
201,
198,
2,
9794,
7443,
25,
6045,
201,
198,
2,
46111,
28,
201,
198,
37811,
201,
198,
7804,
2235,
17267,
21015,
9195,
82,
1303,
7804,
2,
201,
198,
11748,
28686,
201,
198,
201,
198,
7804,
2235,
17267,
2368,
12,
10608,
9195,
82,
1303,
7804,
2,
201,
198,
11748,
299,
32152,
355,
45941,
201,
198,
11748,
269,
85,
17,
201,
198,
201,
198,
201,
198,
201,
198,
7804,
2235,
1657,
2214,
4676,
14,
24055,
12,
75,
641,
7177,
32373,
1303,
7804,
2,
201,
198,
201,
198,
7804,
2235,
1657,
2214,
3715,
3108,
1351,
1303,
7804,
2,
201,
198,
201,
198,
7804,
2235,
3440,
1657,
2214,
4263,
1303,
7804,
2,
201,
198,
201,
198,
7804,
2235,
3440,
1657,
2214,
1366,
1303,
7804,
2,
201,
198,
201,
198,
7804,
2235,
8335,
2747,
82,
1366,
1303,
7804,
2,
201,
198,
201,
198,
7804,
2235,
651,
17724,
1366,
1303,
7804,
2,
201,
198
] | 3.449495 | 198 |
from typing import Optional
from .base import Base, Condition, DayTime, PhenomCondition, PrecipitationType, Season, WindDir
| [
6738,
19720,
1330,
32233,
198,
198,
6738,
764,
8692,
1330,
7308,
11,
24295,
11,
3596,
7575,
11,
34828,
296,
48362,
11,
28737,
541,
3780,
6030,
11,
7369,
11,
3086,
35277,
628
] | 4.064516 | 31 |
with open("README.md", "r") as fh:
long_description = fh.read()
from setuptools import setup, find_packages
setup(
name='lcd-controller2',
version='',
packages=find_packages('src'),
package_dir={'': 'src'},
url='',
license='',
author='Lukas Brennauer, Samuel Kroiss',
author_email='',
description=long_description,
install_requires=[
'setuptools',
],
)
| [
4480,
1280,
7203,
15675,
11682,
13,
9132,
1600,
366,
81,
4943,
355,
277,
71,
25,
198,
220,
220,
220,
890,
62,
11213,
796,
277,
71,
13,
961,
3419,
628,
198,
6738,
900,
37623,
10141,
1330,
9058,
11,
1064,
62,
43789,
198,
198,
40406,
7,
198,
220,
220,
220,
1438,
11639,
75,
10210,
12,
36500,
17,
3256,
198,
220,
220,
220,
2196,
11639,
3256,
198,
220,
220,
220,
10392,
28,
19796,
62,
43789,
10786,
10677,
33809,
198,
220,
220,
220,
5301,
62,
15908,
34758,
7061,
25,
705,
10677,
6,
5512,
198,
220,
220,
220,
19016,
11639,
3256,
198,
220,
220,
220,
5964,
11639,
3256,
198,
220,
220,
220,
1772,
11639,
43,
2724,
292,
20465,
77,
16261,
11,
17100,
30088,
747,
3256,
198,
220,
220,
220,
1772,
62,
12888,
11639,
3256,
198,
220,
220,
220,
6764,
28,
6511,
62,
11213,
11,
198,
220,
220,
220,
2721,
62,
47911,
41888,
198,
220,
220,
220,
220,
220,
220,
220,
705,
2617,
37623,
10141,
3256,
198,
220,
220,
220,
16589,
198,
8,
198
] | 2.452381 | 168 |
# -*- coding: utf-8 -*-
"""
Created on Mon Feb 24 01:14:06 2020
Github: https://github.com/tjczec01
@author: Travis J Czechorski
E-mail: [email protected]
"""
import sympy as sp
from sympy import diff, Matrix, symbols, Add, Mul, Pow, Symbol, Integer, latex, exp, simplify
from sympy.matrices.dense import matrix2numpy
import matplotlib as mpl
import matplotlib.pyplot as plt
from IPython.display import display, Latex
from tkinter import Tk, ttk, IntVar, StringVar, N, W, E, S, Checkbutton, Label, Entry, Button
from tkinter.ttk import Combobox
import pickle
import os
import subprocess
from shutil import which
import warnings
__all__ = ["gui", "symbolgen", "kJtoJ", "create_pdf"]
warnings.filterwarnings("ignore") # ,category=matplotlib.cbook.mplDeprecation
plt.rcParams['text.usetex'] = True
plt.rcParams['axes.grid'] = False
plt.rcParams['text.latex.preamble'] = [r'\usepackage{mathtools}', r'\usepackage{bm}']
# Generates all necessary lists and values.
# chemical_names, number_of_reactions, Initial_reactions, Equation_list, indvdf, filepath, kvalues, ea_values, r_gas = gui.fullgui() # Generates all necessary lists and values.
# Calculates the jacobian and all other desired functions
# for key, value in locals().items():
# if callable(value) and value.__module__ == __name__:
# l.append(key)
# C_Symbols, KKS, EAS, reacts, prods, equations, slat, dlat, chem, chemD, chemw, rhs, rhsf, jac, jacnumpy, Jacmath, JacSimple, lm, latexmatrix, jacsy, jacnumpysy, jacmathsy, jacsimplesy, lmsy, latexmatrixsy = symbolgen.fullgen(chemical_names, number_of_reactions, Initial_reactions, Equation_list, indvdf, filepath, kvalues, ea_values, r_gas, chemical_names)
| [
2,
532,
9,
12,
19617,
25,
3384,
69,
12,
23,
532,
9,
12,
201,
198,
37811,
201,
198,
41972,
319,
2892,
3158,
1987,
5534,
25,
1415,
25,
3312,
12131,
201,
198,
201,
198,
38,
10060,
25,
3740,
1378,
12567,
13,
785,
14,
83,
73,
26691,
721,
486,
201,
198,
201,
198,
31,
9800,
25,
19804,
449,
16639,
669,
4106,
201,
198,
201,
198,
36,
12,
4529,
25,
256,
73,
26691,
721,
486,
31,
14816,
13,
785,
201,
198,
201,
198,
37811,
201,
198,
201,
198,
11748,
10558,
88,
355,
599,
201,
198,
6738,
10558,
88,
1330,
814,
11,
24936,
11,
14354,
11,
3060,
11,
17996,
11,
14120,
11,
38357,
11,
34142,
11,
47038,
11,
1033,
11,
30276,
201,
198,
6738,
10558,
88,
13,
6759,
45977,
13,
67,
1072,
1330,
17593,
17,
77,
32152,
201,
198,
11748,
2603,
29487,
8019,
355,
285,
489,
201,
198,
11748,
2603,
29487,
8019,
13,
9078,
29487,
355,
458,
83,
201,
198,
6738,
6101,
7535,
13,
13812,
1330,
3359,
11,
18319,
87,
201,
198,
6738,
256,
74,
3849,
1330,
309,
74,
11,
256,
30488,
11,
2558,
19852,
11,
10903,
19852,
11,
399,
11,
370,
11,
412,
11,
311,
11,
6822,
16539,
11,
36052,
11,
21617,
11,
20969,
201,
198,
6738,
256,
74,
3849,
13,
926,
74,
1330,
14336,
672,
1140,
201,
198,
11748,
2298,
293,
201,
198,
11748,
28686,
201,
198,
11748,
850,
14681,
201,
198,
6738,
4423,
346,
1330,
543,
201,
198,
11748,
14601,
201,
198,
201,
198,
834,
439,
834,
796,
14631,
48317,
1600,
366,
1837,
23650,
5235,
1600,
366,
74,
41,
1462,
41,
1600,
366,
17953,
62,
12315,
8973,
201,
198,
201,
198,
40539,
654,
13,
24455,
40539,
654,
7203,
46430,
4943,
220,
1303,
837,
22872,
28,
6759,
29487,
8019,
13,
66,
2070,
13,
76,
489,
12156,
8344,
341,
201,
198,
489,
83,
13,
6015,
10044,
4105,
17816,
5239,
13,
385,
316,
1069,
20520,
796,
6407,
201,
198,
489,
83,
13,
6015,
10044,
4105,
17816,
897,
274,
13,
25928,
20520,
796,
10352,
201,
198,
489,
83,
13,
6015,
10044,
4105,
17816,
5239,
13,
17660,
87,
13,
79,
1476,
903,
20520,
796,
685,
81,
6,
59,
1904,
26495,
90,
11018,
31391,
92,
3256,
374,
6,
59,
1904,
26495,
90,
20475,
92,
20520,
201,
198,
201,
198,
201,
198,
201,
198,
201,
198,
201,
198,
2,
2980,
689,
477,
3306,
8341,
290,
3815,
13,
201,
198,
201,
198,
201,
198,
2,
5931,
62,
14933,
11,
1271,
62,
1659,
62,
260,
4658,
11,
20768,
62,
260,
4658,
11,
7889,
341,
62,
4868,
11,
773,
85,
7568,
11,
2393,
6978,
11,
479,
27160,
11,
304,
64,
62,
27160,
11,
374,
62,
22649,
796,
11774,
13,
12853,
48317,
3419,
220,
1303,
2980,
689,
477,
3306,
8341,
290,
3815,
13,
201,
198,
201,
198,
2,
27131,
689,
262,
474,
330,
672,
666,
290,
477,
584,
10348,
5499,
201,
198,
201,
198,
2,
329,
1994,
11,
1988,
287,
17205,
22446,
23814,
33529,
201,
198,
2,
220,
220,
220,
220,
611,
869,
540,
7,
8367,
8,
290,
1988,
13,
834,
21412,
834,
6624,
11593,
3672,
834,
25,
201,
198,
2,
220,
220,
220,
220,
220,
220,
220,
220,
300,
13,
33295,
7,
2539,
8,
201,
198,
2,
327,
62,
13940,
2022,
10220,
11,
509,
27015,
11,
412,
1921,
11,
30174,
11,
386,
9310,
11,
27490,
11,
1017,
265,
11,
288,
15460,
11,
4607,
11,
4607,
35,
11,
4607,
86,
11,
9529,
82,
11,
9529,
28202,
11,
474,
330,
11,
474,
330,
77,
32152,
11,
8445,
11018,
11,
8445,
26437,
11,
300,
76,
11,
47038,
6759,
8609,
11,
474,
330,
1837,
11,
474,
330,
77,
931,
893,
88,
11,
474,
330,
11018,
1837,
11,
474,
330,
14323,
2374,
88,
11,
300,
907,
88,
11,
47038,
6759,
8609,
1837,
796,
6194,
5235,
13,
12853,
5235,
7,
31379,
62,
14933,
11,
1271,
62,
1659,
62,
260,
4658,
11,
20768,
62,
260,
4658,
11,
7889,
341,
62,
4868,
11,
773,
85,
7568,
11,
2393,
6978,
11,
479,
27160,
11,
304,
64,
62,
27160,
11,
374,
62,
22649,
11,
5931,
62,
14933,
8,
201,
198
] | 2.602392 | 669 |
import json
import multiprocessing as mp
import os
import pkgutil
import shutil
import subprocess
import tarfile
import tempfile
from random import randint
from typing import Tuple, cast
import pytest
import requests
from ethereum.base_types import Uint
from ethereum.crypto import keccak256
from ethereum.ethash import (
EPOCH_SIZE,
HASH_BYTES,
MIX_BYTES,
cache_size,
dataset_size,
epoch,
generate_cache,
generate_dataset_item,
generate_seed,
)
from ethereum.utils.numeric import is_prime
@pytest.mark.parametrize(
"block_number, expected_epoch",
[
(Uint(0), Uint(0)),
(Uint(29999), Uint(0)),
(Uint(30000), Uint(1)),
],
)
#
# Geth DAG related functionalities for fuzz testing
#
def test_dataset_generation_random_epoch(tmpdir: str) -> None:
"""
Generate a random epoch and obtain the DAG for that epoch from geth.
Then ensure the following 2 test scenarios:
1. The first 100 dataset indices are same when the python
implementation is compared with the DAG dataset.
2. Randomly take 500 indices between
[101, `dataset size in words` - 1] and ensure that the values are
same between python implementation and DAG dataset.
"""
download_geth(tmpdir)
epoch_number = Uint(randint(0, 100))
block_number = epoch_number * EPOCH_SIZE + randint(0, EPOCH_SIZE - 1)
generate_dag_via_geth(f"{tmpdir}/geth", block_number, f"{tmpdir}/.ethash")
seed = generate_seed(block_number)
dag_dataset = fetch_dag_data(f"{tmpdir}/.ethash", seed)
cache = generate_cache(block_number)
dataset_size_bytes = dataset_size(block_number)
dataset_size_words = dataset_size_bytes // HASH_BYTES
assert len(dag_dataset) == dataset_size_words
assert generate_dataset_item(cache, Uint(0)) == dag_dataset[0]
for i in range(100):
assert generate_dataset_item(cache, Uint(i)) == dag_dataset[i]
# Then for this dataset randomly take 5000 indices and check the
# data obtained from our implementation with geth DAG
for _ in range(500):
index = Uint(randint(101, dataset_size_words - 1))
dataset_item = generate_dataset_item(cache, index)
assert dataset_item == dag_dataset[index], index
# Manually forcing the dataset out of the memory incase the gc
# doesn't kick in immediately
del dag_dataset
| [
11748,
33918,
198,
11748,
18540,
305,
919,
278,
355,
29034,
198,
11748,
28686,
198,
11748,
279,
10025,
22602,
198,
11748,
4423,
346,
198,
11748,
850,
14681,
198,
11748,
13422,
7753,
198,
11748,
20218,
7753,
198,
6738,
4738,
1330,
43720,
600,
198,
6738,
19720,
1330,
309,
29291,
11,
3350,
198,
198,
11748,
12972,
9288,
198,
11748,
7007,
198,
198,
6738,
304,
17733,
13,
8692,
62,
19199,
1330,
471,
600,
198,
6738,
304,
17733,
13,
29609,
78,
1330,
885,
535,
461,
11645,
198,
6738,
304,
17733,
13,
2788,
1077,
1330,
357,
198,
220,
220,
220,
14724,
46,
3398,
62,
33489,
11,
198,
220,
220,
220,
367,
11211,
62,
17513,
51,
1546,
11,
198,
220,
220,
220,
337,
10426,
62,
17513,
51,
1546,
11,
198,
220,
220,
220,
12940,
62,
7857,
11,
198,
220,
220,
220,
27039,
62,
7857,
11,
198,
220,
220,
220,
36835,
11,
198,
220,
220,
220,
7716,
62,
23870,
11,
198,
220,
220,
220,
7716,
62,
19608,
292,
316,
62,
9186,
11,
198,
220,
220,
220,
7716,
62,
28826,
11,
198,
8,
198,
6738,
304,
17733,
13,
26791,
13,
77,
39223,
1330,
318,
62,
35505,
628,
198,
31,
9078,
9288,
13,
4102,
13,
17143,
316,
380,
2736,
7,
198,
220,
220,
220,
366,
9967,
62,
17618,
11,
2938,
62,
538,
5374,
1600,
198,
220,
220,
220,
685,
198,
220,
220,
220,
220,
220,
220,
220,
357,
52,
600,
7,
15,
828,
471,
600,
7,
15,
36911,
198,
220,
220,
220,
220,
220,
220,
220,
357,
52,
600,
7,
1959,
17032,
828,
471,
600,
7,
15,
36911,
198,
220,
220,
220,
220,
220,
220,
220,
357,
52,
600,
7,
18,
2388,
828,
471,
600,
7,
16,
36911,
198,
220,
220,
220,
16589,
198,
8,
628,
628,
628,
628,
628,
198,
198,
2,
198,
2,
402,
2788,
360,
4760,
3519,
10345,
871,
329,
26080,
4856,
198,
2,
628,
628,
198,
198,
4299,
1332,
62,
19608,
292,
316,
62,
20158,
62,
25120,
62,
538,
5374,
7,
22065,
15908,
25,
965,
8,
4613,
6045,
25,
198,
220,
220,
220,
37227,
198,
220,
220,
220,
2980,
378,
257,
4738,
36835,
290,
7330,
262,
360,
4760,
329,
326,
36835,
422,
651,
71,
13,
198,
220,
220,
220,
3244,
4155,
262,
1708,
362,
1332,
13858,
25,
198,
220,
220,
220,
220,
220,
220,
220,
352,
13,
383,
717,
1802,
27039,
36525,
389,
976,
618,
262,
21015,
198,
220,
220,
220,
220,
220,
220,
220,
7822,
318,
3688,
351,
262,
360,
4760,
27039,
13,
198,
220,
220,
220,
220,
220,
220,
220,
362,
13,
14534,
306,
1011,
5323,
36525,
1022,
198,
220,
220,
220,
220,
220,
220,
220,
685,
8784,
11,
4600,
19608,
292,
316,
2546,
287,
2456,
63,
532,
352,
60,
290,
4155,
326,
262,
3815,
389,
198,
220,
220,
220,
220,
220,
220,
220,
976,
1022,
21015,
7822,
290,
360,
4760,
27039,
13,
198,
220,
220,
220,
37227,
198,
220,
220,
220,
4321,
62,
1136,
71,
7,
22065,
15908,
8,
628,
220,
220,
220,
36835,
62,
17618,
796,
471,
600,
7,
25192,
600,
7,
15,
11,
1802,
4008,
198,
220,
220,
220,
2512,
62,
17618,
796,
36835,
62,
17618,
1635,
14724,
46,
3398,
62,
33489,
1343,
43720,
600,
7,
15,
11,
14724,
46,
3398,
62,
33489,
532,
352,
8,
198,
220,
220,
220,
7716,
62,
67,
363,
62,
8869,
62,
1136,
71,
7,
69,
1,
90,
22065,
15908,
92,
14,
1136,
71,
1600,
2512,
62,
17618,
11,
277,
1,
90,
22065,
15908,
92,
11757,
2788,
1077,
4943,
198,
220,
220,
220,
9403,
796,
7716,
62,
28826,
7,
9967,
62,
17618,
8,
198,
220,
220,
220,
48924,
62,
19608,
292,
316,
796,
21207,
62,
67,
363,
62,
7890,
7,
69,
1,
90,
22065,
15908,
92,
11757,
2788,
1077,
1600,
9403,
8,
628,
220,
220,
220,
12940,
796,
7716,
62,
23870,
7,
9967,
62,
17618,
8,
198,
220,
220,
220,
27039,
62,
7857,
62,
33661,
796,
27039,
62,
7857,
7,
9967,
62,
17618,
8,
198,
220,
220,
220,
27039,
62,
7857,
62,
10879,
796,
27039,
62,
7857,
62,
33661,
3373,
367,
11211,
62,
17513,
51,
1546,
628,
220,
220,
220,
6818,
18896,
7,
67,
363,
62,
19608,
292,
316,
8,
6624,
27039,
62,
7857,
62,
10879,
628,
220,
220,
220,
6818,
7716,
62,
19608,
292,
316,
62,
9186,
7,
23870,
11,
471,
600,
7,
15,
4008,
6624,
48924,
62,
19608,
292,
316,
58,
15,
60,
628,
220,
220,
220,
329,
1312,
287,
2837,
7,
3064,
2599,
198,
220,
220,
220,
220,
220,
220,
220,
6818,
7716,
62,
19608,
292,
316,
62,
9186,
7,
23870,
11,
471,
600,
7,
72,
4008,
6624,
48924,
62,
19608,
292,
316,
58,
72,
60,
628,
220,
220,
220,
1303,
3244,
329,
428,
27039,
15456,
1011,
23336,
36525,
290,
2198,
262,
198,
220,
220,
220,
1303,
1366,
6492,
422,
674,
7822,
351,
651,
71,
360,
4760,
198,
220,
220,
220,
329,
4808,
287,
2837,
7,
4059,
2599,
198,
220,
220,
220,
220,
220,
220,
220,
6376,
796,
471,
600,
7,
25192,
600,
7,
8784,
11,
27039,
62,
7857,
62,
10879,
532,
352,
4008,
198,
220,
220,
220,
220,
220,
220,
220,
27039,
62,
9186,
796,
7716,
62,
19608,
292,
316,
62,
9186,
7,
23870,
11,
6376,
8,
198,
220,
220,
220,
220,
220,
220,
220,
6818,
27039,
62,
9186,
6624,
48924,
62,
19608,
292,
316,
58,
9630,
4357,
6376,
628,
220,
220,
220,
1303,
1869,
935,
10833,
262,
27039,
503,
286,
262,
4088,
753,
589,
262,
308,
66,
198,
220,
220,
220,
1303,
1595,
470,
4829,
287,
3393,
198,
220,
220,
220,
1619,
48924,
62,
19608,
292,
316,
198
] | 2.632096 | 916 |
__author__ = 'thorn'
import logging
import sys
LOGGER = logging.getLogger()
| [
834,
9800,
834,
796,
705,
400,
1211,
6,
198,
11748,
18931,
198,
11748,
25064,
198,
198,
25294,
30373,
796,
18931,
13,
1136,
11187,
1362,
3419,
198
] | 2.961538 | 26 |
import json
import logging
from os import environ as env
import requests
from dotenv import load_dotenv
# Get environment
load_dotenv()
DATASERVICE_PUBLISHER_HOST_URL = env.get("DATASERVICE_PUBLISHER_HOST_URL")
ADMIN_USERNAME = env.get("ADMIN_USERNAME", "admin")
ADMIN_PASSWORD = env.get("ADMIN_PASSWORD")
INPUT_FILE = env.get("INPUT_FILE")
def login() -> str:
"""Logs in to get an access_token."""
url = f"{DATASERVICE_PUBLISHER_HOST_URL}/login"
try:
headers = {"Content-Type": "application/json"}
data = dict(username=ADMIN_USERNAME, password=ADMIN_PASSWORD)
response = requests.post(url, json=data, headers=headers)
if response.status_code == 200:
data = response.json()
token = data["access_token"]
print(f"Successful login. Token >{token}<")
return token
else:
logging.error(f"Unsuccessful login : {response.status_code}")
return None
except Exception as e:
logging.error("Got exception", e)
return None
def delete_catalog(access_token, catalog) -> bool:
"""Tries to delete the catalog."""
headers = {
"Authorization": f"Bearer {access_token}",
}
url = catalog["identifier"]
response = requests.delete(url, headers=headers)
if response.status_code == 204:
print(f"Deleted catalog {url}")
return True
elif response.status_code == 404:
print(f"Catalog {url} does not exist. Safe to proceed")
return True
else:
logging.error(f"Unsuccessful, status_code: {response.status_code}")
# msg = json.loads(response.content)["msg"]
# logging.error(f"Unsuccessful, msg : {msg}")
logging.error(response.content)
return False
def load_catalog(access_token, catalog) -> bool:
"""Loads the catalog and returns True if successful."""
url = f"{DATASERVICE_PUBLISHER_HOST_URL}/catalogs"
headers = {
"Content-Type": "application/json",
"Authorization": f"Bearer {access_token}",
}
response = requests.post(url, json=catalog, headers=headers)
if response.status_code == 200:
print(
f"loaded from file {json_file.name}",
)
return True
else:
logging.error(f"Unsuccessful, status_code: {response.status_code}")
# msg = json.loads(response.content)["msg"]
# logging.error(f"Unsuccessful, msg : {msg}")
logging.error(response.content)
return False
if __name__ == "__main__":
access_token = login()
if access_token:
with open(INPUT_FILE) as json_file:
catalog = json.load(json_file)
delete_catalog(access_token, catalog)
result = load_catalog(access_token, catalog)
if result:
print(f"Successfully loaded content of {INPUT_FILE}.")
| [
11748,
33918,
198,
11748,
18931,
198,
6738,
28686,
1330,
551,
2268,
355,
17365,
198,
11748,
7007,
198,
198,
6738,
16605,
24330,
1330,
3440,
62,
26518,
24330,
198,
198,
2,
3497,
2858,
198,
2220,
62,
26518,
24330,
3419,
198,
35,
1404,
1921,
1137,
27389,
62,
5105,
9148,
1797,
16879,
62,
39,
10892,
62,
21886,
796,
17365,
13,
1136,
7203,
35,
1404,
1921,
1137,
27389,
62,
5105,
9148,
1797,
16879,
62,
39,
10892,
62,
21886,
4943,
198,
2885,
23678,
62,
29904,
20608,
796,
17365,
13,
1136,
7203,
2885,
23678,
62,
29904,
20608,
1600,
366,
28482,
4943,
198,
2885,
23678,
62,
47924,
54,
12532,
796,
17365,
13,
1136,
7203,
2885,
23678,
62,
47924,
54,
12532,
4943,
198,
1268,
30076,
62,
25664,
796,
17365,
13,
1136,
7203,
1268,
30076,
62,
25664,
4943,
628,
198,
4299,
17594,
3419,
4613,
965,
25,
198,
220,
220,
220,
37227,
11187,
82,
287,
284,
651,
281,
1895,
62,
30001,
526,
15931,
198,
220,
220,
220,
19016,
796,
277,
1,
90,
35,
1404,
1921,
1137,
27389,
62,
5105,
9148,
1797,
16879,
62,
39,
10892,
62,
21886,
92,
14,
38235,
1,
198,
220,
220,
220,
1949,
25,
198,
220,
220,
220,
220,
220,
220,
220,
24697,
796,
19779,
19746,
12,
6030,
1298,
366,
31438,
14,
17752,
20662,
198,
220,
220,
220,
220,
220,
220,
220,
1366,
796,
8633,
7,
29460,
28,
2885,
23678,
62,
29904,
20608,
11,
9206,
28,
2885,
23678,
62,
47924,
54,
12532,
8,
628,
220,
220,
220,
220,
220,
220,
220,
2882,
796,
7007,
13,
7353,
7,
6371,
11,
33918,
28,
7890,
11,
24697,
28,
50145,
8,
198,
220,
220,
220,
220,
220,
220,
220,
611,
2882,
13,
13376,
62,
8189,
6624,
939,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1366,
796,
2882,
13,
17752,
3419,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
11241,
796,
1366,
14692,
15526,
62,
30001,
8973,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
3601,
7,
69,
1,
33244,
913,
17594,
13,
29130,
1875,
90,
30001,
92,
27,
4943,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1441,
11241,
198,
220,
220,
220,
220,
220,
220,
220,
2073,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
18931,
13,
18224,
7,
69,
1,
3118,
17212,
17594,
1058,
1391,
26209,
13,
13376,
62,
8189,
92,
4943,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1441,
6045,
198,
220,
220,
220,
2845,
35528,
355,
304,
25,
198,
220,
220,
220,
220,
220,
220,
220,
18931,
13,
18224,
7203,
30074,
6631,
1600,
304,
8,
198,
220,
220,
220,
1441,
6045,
628,
198,
4299,
12233,
62,
9246,
11794,
7,
15526,
62,
30001,
11,
18388,
8,
4613,
20512,
25,
198,
220,
220,
220,
37227,
51,
1678,
284,
12233,
262,
18388,
526,
15931,
198,
220,
220,
220,
24697,
796,
1391,
198,
220,
220,
220,
220,
220,
220,
220,
366,
13838,
1634,
1298,
277,
1,
3856,
11258,
1391,
15526,
62,
30001,
92,
1600,
198,
220,
220,
220,
1782,
628,
220,
220,
220,
19016,
796,
18388,
14692,
738,
7483,
8973,
198,
220,
220,
220,
2882,
796,
7007,
13,
33678,
7,
6371,
11,
24697,
28,
50145,
8,
198,
220,
220,
220,
611,
2882,
13,
13376,
62,
8189,
6624,
26956,
25,
198,
220,
220,
220,
220,
220,
220,
220,
3601,
7,
69,
1,
5005,
33342,
18388,
1391,
6371,
92,
4943,
198,
220,
220,
220,
220,
220,
220,
220,
1441,
6407,
198,
220,
220,
220,
1288,
361,
2882,
13,
13376,
62,
8189,
6624,
32320,
25,
198,
220,
220,
220,
220,
220,
220,
220,
3601,
7,
69,
1,
49015,
1391,
6371,
92,
857,
407,
2152,
13,
19978,
284,
5120,
4943,
198,
220,
220,
220,
220,
220,
220,
220,
1441,
6407,
198,
220,
220,
220,
2073,
25,
198,
220,
220,
220,
220,
220,
220,
220,
18931,
13,
18224,
7,
69,
1,
3118,
17212,
11,
3722,
62,
8189,
25,
1391,
26209,
13,
13376,
62,
8189,
92,
4943,
198,
220,
220,
220,
220,
220,
220,
220,
1303,
31456,
796,
33918,
13,
46030,
7,
26209,
13,
11299,
8,
14692,
19662,
8973,
198,
220,
220,
220,
220,
220,
220,
220,
1303,
18931,
13,
18224,
7,
69,
1,
3118,
17212,
11,
31456,
1058,
1391,
19662,
92,
4943,
198,
220,
220,
220,
220,
220,
220,
220,
18931,
13,
18224,
7,
26209,
13,
11299,
8,
198,
220,
220,
220,
1441,
10352,
628,
198,
4299,
3440,
62,
9246,
11794,
7,
15526,
62,
30001,
11,
18388,
8,
4613,
20512,
25,
198,
220,
220,
220,
37227,
8912,
82,
262,
18388,
290,
5860,
6407,
611,
4388,
526,
15931,
198,
220,
220,
220,
19016,
796,
277,
1,
90,
35,
1404,
1921,
1137,
27389,
62,
5105,
9148,
1797,
16879,
62,
39,
10892,
62,
21886,
92,
14,
9246,
11794,
82,
1,
198,
220,
220,
220,
24697,
796,
1391,
198,
220,
220,
220,
220,
220,
220,
220,
366,
19746,
12,
6030,
1298,
366,
31438,
14,
17752,
1600,
198,
220,
220,
220,
220,
220,
220,
220,
366,
13838,
1634,
1298,
277,
1,
3856,
11258,
1391,
15526,
62,
30001,
92,
1600,
198,
220,
220,
220,
1782,
628,
220,
220,
220,
2882,
796,
7007,
13,
7353,
7,
6371,
11,
33918,
28,
9246,
11794,
11,
24697,
28,
50145,
8,
198,
220,
220,
220,
611,
2882,
13,
13376,
62,
8189,
6624,
939,
25,
198,
220,
220,
220,
220,
220,
220,
220,
3601,
7,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
277,
1,
14578,
422,
2393,
1391,
17752,
62,
7753,
13,
3672,
92,
1600,
198,
220,
220,
220,
220,
220,
220,
220,
1267,
198,
220,
220,
220,
220,
220,
220,
220,
1441,
6407,
198,
220,
220,
220,
2073,
25,
198,
220,
220,
220,
220,
220,
220,
220,
18931,
13,
18224,
7,
69,
1,
3118,
17212,
11,
3722,
62,
8189,
25,
1391,
26209,
13,
13376,
62,
8189,
92,
4943,
198,
220,
220,
220,
220,
220,
220,
220,
1303,
31456,
796,
33918,
13,
46030,
7,
26209,
13,
11299,
8,
14692,
19662,
8973,
198,
220,
220,
220,
220,
220,
220,
220,
1303,
18931,
13,
18224,
7,
69,
1,
3118,
17212,
11,
31456,
1058,
1391,
19662,
92,
4943,
198,
220,
220,
220,
220,
220,
220,
220,
18931,
13,
18224,
7,
26209,
13,
11299,
8,
198,
220,
220,
220,
1441,
10352,
628,
198,
361,
11593,
3672,
834,
6624,
366,
834,
12417,
834,
1298,
198,
220,
220,
220,
1895,
62,
30001,
796,
17594,
3419,
198,
220,
220,
220,
611,
1895,
62,
30001,
25,
198,
220,
220,
220,
220,
220,
220,
220,
351,
1280,
7,
1268,
30076,
62,
25664,
8,
355,
33918,
62,
7753,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
18388,
796,
33918,
13,
2220,
7,
17752,
62,
7753,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
12233,
62,
9246,
11794,
7,
15526,
62,
30001,
11,
18388,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1255,
796,
3440,
62,
9246,
11794,
7,
15526,
62,
30001,
11,
18388,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
611,
1255,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
3601,
7,
69,
1,
33244,
2759,
9639,
2695,
286,
1391,
1268,
30076,
62,
25664,
92,
19570,
198
] | 2.386345 | 1,201 |
# Import our libraries
# Import pandas and numpy
import pandas as pd
import numpy as np
import pickle
import matplotlib.pyplot as plt
# Helper function to split our data
from sklearn.model_selection import train_test_split
# Import our Logistic Regression model
from sklearn.linear_model import LogisticRegression
# Import helper functions to evaluate our model
from sklearn.metrics import accuracy_score, precision_score, recall_score, confusion_matrix, f1_score, roc_auc_score
# Import z-score helper function
import scipy.stats as stats
from IPython.display import Image
# Import helper functipn for hyper-parameter tuning
from sklearn.model_selection import GridSearchCV
# Import Decision Tree
# from sklearn.tree import DecisionTreeClassifier
# Import Random Forest
from sklearn.ensemble import RandomForestClassifier
# Import metrics to score our model
from sklearn import metrics
# LOAD IN AND CLEAN UP THE DATA BEFORE MERGING
# Load in the first stroke dataset
df = pd.read_csv('https://raw.githubusercontent.com/shenalt/tissera_yasser_DS_project/main/healthcare-dataset-stroke-data.csv')
# Drop the id column
df.drop(columns=['id'], inplace=True)
# Fill the bmi null values in df
df['bmi'] = df.bmi.fillna(df.bmi.mean())
# Remove entries with gender Other from df
df = df[df['gender'] != 'Other']
# Normalize our numerical features to ensure they have equal weight when I build my classifiers
# Create a new column for normalized age
df['age_norm']=(df['age']-df['age'].min())/(df['age'].max()-df['age'].min())
# Create a new column for normalized avg glucose level
df['avg_glucose_level_norm']=(df['avg_glucose_level']-df['avg_glucose_level'].min())/(df['avg_glucose_level'].max()-df['avg_glucose_level'].min())
# Create a new column for normalized bmi
df['bmi_norm']=(df['bmi']-df['bmi'].min())/(df['bmi'].max()-df['bmi'].min())
# Load in the second stroke dataset
df2 = pd.read_csv('https://raw.githubusercontent.com/shenalt/tissera_yasser_DS_project/main/train_strokes.csv')
# Drop the id column
df2.drop(columns=['id'], inplace=True)
# Fill the bmi null values in df2
df2['bmi'] = df2.bmi.fillna(df2.bmi.mean())
# Create a new category for the smoking null values
df2['smoking_status'] = df2['smoking_status'].fillna('not known')
# Remove entries with gender Other from df2
df2 = df2[df2['gender'] != 'Other']
# Normalize our numerical features to ensure they have equal weight when I build my classifiers
# Create a new column for normalized age
df2['age_norm']=(df2['age']-df2['age'].min())/(df2['age'].max()-df2['age'].min())
# Create a new column for normalized avg glucose level
df2['avg_glucose_level_norm']=(df2['avg_glucose_level']-df2['avg_glucose_level'].min())/(df2['avg_glucose_level'].max()-df2['avg_glucose_level'].min())
# Create a new column for normalized bmi
df2['bmi_norm']=(df2['bmi']-df2['bmi'].min())/(df2['bmi'].max()-df2['bmi'].min())
# Merge the two df's
df_master = df.merge(df2, how='outer')
# EXTRACT ALL STROKE ENTRIES AND ISOLATE 1000 RANDOM NON-STROKE ENTRIES INTO A DF
# Create a df from dataset with just the stroke entries
s_df = df_master.loc[df_master['stroke'] == 1]
# Remove age outliers from s_df
s_df = s_df.loc[s_df['age'] >= 45]
# Create a df from the dataset with the no stroke entries
n_df = df_master.sample(n=1100, random_state=30)
n_df = n_df.loc[n_df['stroke'] == 0]
# Merge them
df_final = s_df.merge(n_df, how='outer')
# FEATURE ENGINEERING TIME
# Convert certain features into numerical values
df_final = pd.get_dummies(df_final, columns=['gender', 'Residence_type', 'smoking_status', 'ever_married', 'work_type'])
# Begin to train our model
selected_features = ['age', 'bmi', 'avg_glucose_level', 'hypertension', 'heart_disease']
X = df_final[selected_features]
y = df_final['stroke']
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=30)
# RANDOM FOREST CLASSIFIER
# Init our Random Forest Classifier Model
#model = RandomForestClassifier()
params = {
'n_estimators' : [10, 50, 100],
'criterion' : ['gini', 'entropy'],
'max_depth': [5, 10, 100, None],
'min_samples_split': [2, 10, 100],
'max_features': ['auto', 'sqrt', 'log2']
}
grid_search_cv = GridSearchCV(
estimator=RandomForestClassifier(),
param_grid=params,
scoring='accuracy' )
# fit all combination of trees.
grid_search_cv.fit(X_train, y_train)
# the highest accuracy-score.
model = grid_search_cv.best_estimator_
# Fit our model
model.fit(X_train, y_train)
# Save our model using pickle
pickle.dump(model, open('models/rfc.pkl', 'wb') )
| [
2,
17267,
674,
12782,
198,
198,
2,
17267,
19798,
292,
290,
299,
32152,
220,
198,
11748,
19798,
292,
355,
279,
67,
198,
11748,
299,
32152,
355,
45941,
198,
198,
11748,
2298,
293,
198,
198,
11748,
2603,
29487,
8019,
13,
9078,
29487,
355,
458,
83,
198,
198,
2,
5053,
525,
2163,
284,
6626,
674,
1366,
220,
198,
6738,
1341,
35720,
13,
19849,
62,
49283,
1330,
4512,
62,
9288,
62,
35312,
220,
198,
198,
2,
17267,
674,
5972,
2569,
3310,
2234,
2746,
220,
198,
6738,
1341,
35720,
13,
29127,
62,
19849,
1330,
5972,
2569,
8081,
2234,
198,
198,
2,
17267,
31904,
5499,
284,
13446,
674,
2746,
220,
198,
6738,
1341,
35720,
13,
4164,
10466,
1330,
9922,
62,
26675,
11,
15440,
62,
26675,
11,
10014,
62,
26675,
11,
10802,
62,
6759,
8609,
11,
277,
16,
62,
26675,
11,
686,
66,
62,
14272,
62,
26675,
198,
198,
2,
17267,
1976,
12,
26675,
31904,
2163,
198,
11748,
629,
541,
88,
13,
34242,
355,
9756,
198,
198,
6738,
6101,
7535,
13,
13812,
1330,
7412,
198,
198,
2,
17267,
31904,
1257,
310,
541,
77,
329,
8718,
12,
17143,
2357,
24549,
220,
198,
6738,
1341,
35720,
13,
19849,
62,
49283,
1330,
24846,
18243,
33538,
198,
198,
2,
17267,
26423,
12200,
198,
2,
422,
1341,
35720,
13,
21048,
1330,
26423,
27660,
9487,
7483,
198,
198,
2,
17267,
14534,
9115,
220,
198,
6738,
1341,
35720,
13,
1072,
11306,
1330,
14534,
34605,
9487,
7483,
198,
198,
2,
17267,
20731,
284,
4776,
674,
2746,
220,
198,
6738,
1341,
35720,
1330,
20731,
198,
198,
2,
17579,
2885,
3268,
5357,
30301,
1565,
15958,
3336,
42865,
38331,
34482,
38,
2751,
198,
2,
8778,
287,
262,
717,
14000,
27039,
198,
7568,
796,
279,
67,
13,
961,
62,
40664,
10786,
5450,
1378,
1831,
13,
12567,
43667,
13,
785,
14,
82,
831,
2501,
14,
83,
747,
8607,
62,
88,
24929,
62,
5258,
62,
16302,
14,
12417,
14,
13948,
6651,
12,
19608,
292,
316,
12,
30757,
12,
7890,
13,
40664,
11537,
198,
198,
2,
14258,
262,
4686,
5721,
198,
7568,
13,
14781,
7,
28665,
82,
28,
17816,
312,
6,
4357,
287,
5372,
28,
17821,
8,
198,
198,
2,
27845,
262,
275,
11632,
9242,
3815,
287,
47764,
198,
7568,
17816,
65,
11632,
20520,
796,
47764,
13,
65,
11632,
13,
20797,
2616,
7,
7568,
13,
65,
11632,
13,
32604,
28955,
198,
198,
2,
17220,
12784,
351,
5279,
3819,
422,
47764,
220,
198,
7568,
796,
47764,
58,
7568,
17816,
8388,
20520,
14512,
705,
6395,
20520,
198,
198,
2,
14435,
1096,
674,
29052,
3033,
284,
4155,
484,
423,
4961,
3463,
618,
314,
1382,
616,
1398,
13350,
198,
2,
13610,
257,
649,
5721,
329,
39279,
2479,
198,
7568,
17816,
496,
62,
27237,
20520,
16193,
7568,
17816,
496,
20520,
12,
7568,
17816,
496,
6,
4083,
1084,
3419,
20679,
7,
7568,
17816,
496,
6,
4083,
9806,
3419,
12,
7568,
17816,
496,
6,
4083,
1084,
28955,
198,
198,
2,
13610,
257,
649,
5721,
329,
39279,
42781,
15701,
1241,
198,
7568,
17816,
615,
70,
62,
4743,
1229,
577,
62,
5715,
62,
27237,
20520,
16193,
7568,
17816,
615,
70,
62,
4743,
1229,
577,
62,
5715,
20520,
12,
7568,
17816,
615,
70,
62,
4743,
1229,
577,
62,
5715,
6,
4083,
1084,
3419,
20679,
7,
7568,
17816,
615,
70,
62,
4743,
1229,
577,
62,
5715,
6,
4083,
9806,
3419,
12,
7568,
17816,
615,
70,
62,
4743,
1229,
577,
62,
5715,
6,
4083,
1084,
28955,
198,
198,
2,
13610,
257,
649,
5721,
329,
39279,
275,
11632,
198,
7568,
17816,
65,
11632,
62,
27237,
20520,
16193,
7568,
17816,
65,
11632,
20520,
12,
7568,
17816,
65,
11632,
6,
4083,
1084,
3419,
20679,
7,
7568,
17816,
65,
11632,
6,
4083,
9806,
3419,
12,
7568,
17816,
65,
11632,
6,
4083,
1084,
28955,
198,
198,
2,
8778,
287,
262,
1218,
14000,
27039,
198,
7568,
17,
796,
279,
67,
13,
961,
62,
40664,
10786,
5450,
1378,
1831,
13,
12567,
43667,
13,
785,
14,
82,
831,
2501,
14,
83,
747,
8607,
62,
88,
24929,
62,
5258,
62,
16302,
14,
12417,
14,
27432,
62,
20661,
5209,
13,
40664,
11537,
198,
198,
2,
14258,
262,
4686,
5721,
198,
7568,
17,
13,
14781,
7,
28665,
82,
28,
17816,
312,
6,
4357,
287,
5372,
28,
17821,
8,
198,
198,
2,
27845,
262,
275,
11632,
9242,
3815,
287,
47764,
17,
198,
7568,
17,
17816,
65,
11632,
20520,
796,
47764,
17,
13,
65,
11632,
13,
20797,
2616,
7,
7568,
17,
13,
65,
11632,
13,
32604,
28955,
198,
198,
2,
13610,
257,
649,
6536,
329,
262,
9216,
9242,
3815,
198,
7568,
17,
17816,
48783,
62,
13376,
20520,
796,
47764,
17,
17816,
48783,
62,
13376,
6,
4083,
20797,
2616,
10786,
1662,
1900,
11537,
198,
198,
2,
17220,
12784,
351,
5279,
3819,
422,
47764,
17,
198,
7568,
17,
796,
47764,
17,
58,
7568,
17,
17816,
8388,
20520,
14512,
705,
6395,
20520,
198,
198,
2,
14435,
1096,
674,
29052,
3033,
284,
4155,
484,
423,
4961,
3463,
618,
314,
1382,
616,
1398,
13350,
198,
2,
13610,
257,
649,
5721,
329,
39279,
2479,
198,
7568,
17,
17816,
496,
62,
27237,
20520,
16193,
7568,
17,
17816,
496,
20520,
12,
7568,
17,
17816,
496,
6,
4083,
1084,
3419,
20679,
7,
7568,
17,
17816,
496,
6,
4083,
9806,
3419,
12,
7568,
17,
17816,
496,
6,
4083,
1084,
28955,
198,
198,
2,
13610,
257,
649,
5721,
329,
39279,
42781,
15701,
1241,
198,
7568,
17,
17816,
615,
70,
62,
4743,
1229,
577,
62,
5715,
62,
27237,
20520,
16193,
7568,
17,
17816,
615,
70,
62,
4743,
1229,
577,
62,
5715,
20520,
12,
7568,
17,
17816,
615,
70,
62,
4743,
1229,
577,
62,
5715,
6,
4083,
1084,
3419,
20679,
7,
7568,
17,
17816,
615,
70,
62,
4743,
1229,
577,
62,
5715,
6,
4083,
9806,
3419,
12,
7568,
17,
17816,
615,
70,
62,
4743,
1229,
577,
62,
5715,
6,
4083,
1084,
28955,
198,
198,
2,
13610,
257,
649,
5721,
329,
39279,
275,
11632,
198,
7568,
17,
17816,
65,
11632,
62,
27237,
20520,
16193,
7568,
17,
17816,
65,
11632,
20520,
12,
7568,
17,
17816,
65,
11632,
6,
4083,
1084,
3419,
20679,
7,
7568,
17,
17816,
65,
11632,
6,
4083,
9806,
3419,
12,
7568,
17,
17816,
65,
11632,
6,
4083,
1084,
28955,
198,
198,
2,
39407,
262,
734,
47764,
338,
198,
7568,
62,
9866,
796,
47764,
13,
647,
469,
7,
7568,
17,
11,
703,
11639,
39605,
11537,
220,
628,
198,
2,
7788,
5446,
10659,
11096,
3563,
13252,
7336,
12964,
5446,
11015,
5357,
3180,
3535,
6158,
8576,
46920,
2662,
44521,
12,
2257,
13252,
7336,
12964,
5446,
11015,
39319,
317,
36323,
198,
2,
13610,
257,
47764,
422,
27039,
351,
655,
262,
14000,
12784,
220,
198,
82,
62,
7568,
796,
47764,
62,
9866,
13,
17946,
58,
7568,
62,
9866,
17816,
30757,
20520,
6624,
352,
60,
198,
198,
2,
17220,
2479,
41528,
3183,
422,
264,
62,
7568,
198,
82,
62,
7568,
796,
264,
62,
7568,
13,
17946,
58,
82,
62,
7568,
17816,
496,
20520,
18189,
4153,
60,
198,
198,
2,
13610,
257,
47764,
422,
262,
27039,
351,
262,
645,
14000,
12784,
220,
198,
77,
62,
7568,
796,
47764,
62,
9866,
13,
39873,
7,
77,
28,
42060,
11,
4738,
62,
5219,
28,
1270,
8,
198,
77,
62,
7568,
796,
299,
62,
7568,
13,
17946,
58,
77,
62,
7568,
17816,
30757,
20520,
6624,
657,
60,
220,
198,
198,
2,
39407,
606,
198,
7568,
62,
20311,
796,
264,
62,
7568,
13,
647,
469,
7,
77,
62,
7568,
11,
703,
11639,
39605,
11537,
198,
198,
2,
18630,
40086,
36924,
8881,
1137,
2751,
20460,
198,
2,
38240,
1728,
3033,
656,
29052,
3815,
198,
7568,
62,
20311,
796,
279,
67,
13,
1136,
62,
67,
39578,
7,
7568,
62,
20311,
11,
15180,
28,
17816,
8388,
3256,
705,
4965,
1704,
62,
4906,
3256,
705,
48783,
62,
13376,
3256,
705,
964,
62,
30526,
3256,
705,
1818,
62,
4906,
6,
12962,
198,
198,
2,
16623,
284,
4512,
674,
2746,
198,
34213,
62,
40890,
796,
37250,
496,
3256,
705,
65,
11632,
3256,
705,
615,
70,
62,
4743,
1229,
577,
62,
5715,
3256,
705,
12114,
11766,
3004,
3256,
705,
11499,
62,
67,
786,
589,
20520,
198,
198,
55,
796,
47764,
62,
20311,
58,
34213,
62,
40890,
60,
198,
198,
88,
796,
47764,
62,
20311,
17816,
30757,
20520,
198,
198,
55,
62,
27432,
11,
1395,
62,
9288,
11,
331,
62,
27432,
11,
331,
62,
9288,
796,
4512,
62,
9288,
62,
35312,
7,
55,
11,
331,
11,
1332,
62,
7857,
28,
15,
13,
17,
11,
4738,
62,
5219,
28,
1270,
8,
628,
1303,
46920,
2662,
7473,
6465,
42715,
5064,
38311,
198,
1303,
44707,
674,
14534,
9115,
5016,
7483,
9104,
220,
198,
2,
19849,
796,
14534,
34605,
9487,
7483,
3419,
198,
198,
37266,
796,
1391,
198,
220,
220,
220,
705,
77,
62,
395,
320,
2024,
6,
1058,
685,
940,
11,
2026,
11,
1802,
4357,
198,
220,
220,
220,
705,
22213,
28019,
6,
1058,
37250,
1655,
72,
3256,
705,
298,
28338,
6,
4357,
198,
220,
220,
220,
705,
9806,
62,
18053,
10354,
685,
20,
11,
838,
11,
1802,
11,
6045,
4357,
220,
198,
220,
220,
220,
705,
1084,
62,
82,
12629,
62,
35312,
10354,
685,
17,
11,
838,
11,
1802,
4357,
198,
220,
220,
220,
705,
9806,
62,
40890,
10354,
37250,
23736,
3256,
705,
31166,
17034,
3256,
705,
6404,
17,
20520,
198,
92,
198,
198,
25928,
62,
12947,
62,
33967,
796,
24846,
18243,
33538,
7,
220,
198,
220,
220,
220,
3959,
1352,
28,
29531,
34605,
9487,
7483,
22784,
220,
198,
220,
220,
220,
5772,
62,
25928,
28,
37266,
11,
198,
220,
220,
220,
9689,
11639,
4134,
23843,
6,
1267,
198,
198,
2,
4197,
477,
6087,
286,
7150,
13,
220,
198,
25928,
62,
12947,
62,
33967,
13,
11147,
7,
55,
62,
27432,
11,
331,
62,
27432,
8,
198,
198,
2,
220,
262,
4511,
9922,
12,
26675,
13,
220,
198,
19849,
796,
10706,
62,
12947,
62,
33967,
13,
13466,
62,
395,
320,
1352,
62,
198,
198,
2,
25048,
674,
2746,
220,
198,
19849,
13,
11147,
7,
55,
62,
27432,
11,
331,
62,
27432,
8,
198,
198,
2,
12793,
674,
2746,
1262,
2298,
293,
198,
27729,
293,
13,
39455,
7,
19849,
11,
1280,
10786,
27530,
14,
81,
16072,
13,
79,
41582,
3256,
705,
39346,
11537,
1267,
198
] | 2.784029 | 1,653 |
import contextlib
from multiprocessing import connection
import os
import queue
import threading
from porcupine import dirs
_ADDRESS_FILE = os.path.join(dirs.cachedir, 'ipc_address.txt')
# the addresses contain random junk so they are very unlikely to
# conflict with each other
# example addresses: r'\\.\pipe\pyc-1412-1-7hyryfd_',
# '/tmp/pymp-_lk54sed/listener-4o8n1xrc',
def send(objects):
"""Send objects from an iterable to a process running session().
Raise ConnectionRefusedError if session() is not running.
"""
raise ConnectionRefusedError
# reading the address file, connecting to a windows named pipe and
# connecting to an AF_UNIX socket all raise FileNotFoundError :D
try:
with open(_ADDRESS_FILE, 'r') as file:
address = file.read().strip()
client = connection.Client(address)
except FileNotFoundError:
raise ConnectionRefusedError("session() is not running") from None
with client:
for message in objects:
client.send(message)
def _listener2queue(listener, object_queue):
"""Accept connections. Receive and queue objects."""
while True:
try:
client = listener.accept()
except OSError:
# it's closed
break
with client:
while True:
try:
object_queue.put(client.recv())
except EOFError:
break
@contextlib.contextmanager
def session():
"""Context manager that listens for send().
Use this as a context manager:
# the queue will contain objects from send()
with session() as message_queue:
# start something that processes items in the queue and run
# the application
"""
message_queue = queue.Queue()
with connection.Listener() as listener:
with open(_ADDRESS_FILE, 'w') as file:
print(listener.address, file=file)
thread = threading.Thread(target=_listener2queue,
args=[listener, message_queue], daemon=True)
thread.start()
yield message_queue
if __name__ == '__main__':
# simple test
try:
send([1, 2, 3])
print("a server is running, a message was sent to it")
except ConnectionRefusedError:
print("a server is not running, let's become the server...")
with session() as message_queue:
while True:
print(message_queue.get())
| [
11748,
4732,
8019,
198,
6738,
18540,
305,
919,
278,
1330,
4637,
198,
11748,
28686,
198,
11748,
16834,
198,
11748,
4704,
278,
198,
198,
6738,
16964,
25244,
500,
1330,
288,
17062,
198,
198,
62,
2885,
7707,
7597,
62,
25664,
796,
28686,
13,
6978,
13,
22179,
7,
15908,
82,
13,
66,
2317,
343,
11,
705,
541,
66,
62,
21975,
13,
14116,
11537,
628,
198,
2,
262,
9405,
3994,
4738,
18556,
523,
484,
389,
845,
7485,
284,
198,
2,
5358,
351,
1123,
584,
198,
2,
1672,
9405,
25,
374,
6,
6852,
13,
59,
34360,
59,
9078,
66,
12,
1415,
1065,
12,
16,
12,
22,
12114,
563,
16344,
62,
3256,
198,
2,
31051,
22065,
14,
9078,
3149,
12,
62,
75,
74,
4051,
36622,
14,
4868,
877,
12,
19,
78,
23,
77,
16,
87,
6015,
3256,
198,
4299,
3758,
7,
48205,
2599,
198,
220,
220,
220,
37227,
25206,
5563,
422,
281,
11629,
540,
284,
257,
1429,
2491,
6246,
22446,
628,
220,
220,
220,
35123,
26923,
8134,
1484,
12331,
611,
6246,
3419,
318,
407,
2491,
13,
198,
220,
220,
220,
37227,
198,
220,
220,
220,
5298,
26923,
8134,
1484,
12331,
198,
220,
220,
220,
1303,
3555,
262,
2209,
2393,
11,
14320,
284,
257,
9168,
3706,
12656,
290,
198,
220,
220,
220,
1303,
14320,
284,
281,
12341,
62,
4944,
10426,
17802,
477,
5298,
9220,
3673,
21077,
12331,
1058,
35,
198,
220,
220,
220,
1949,
25,
198,
220,
220,
220,
220,
220,
220,
220,
351,
1280,
28264,
2885,
7707,
7597,
62,
25664,
11,
705,
81,
11537,
355,
2393,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2209,
796,
2393,
13,
961,
22446,
36311,
3419,
198,
220,
220,
220,
220,
220,
220,
220,
5456,
796,
4637,
13,
11792,
7,
21975,
8,
198,
220,
220,
220,
2845,
9220,
3673,
21077,
12331,
25,
198,
220,
220,
220,
220,
220,
220,
220,
5298,
26923,
8134,
1484,
12331,
7203,
29891,
3419,
318,
407,
2491,
4943,
422,
6045,
628,
220,
220,
220,
351,
5456,
25,
198,
220,
220,
220,
220,
220,
220,
220,
329,
3275,
287,
5563,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
5456,
13,
21280,
7,
20500,
8,
628,
198,
4299,
4808,
4868,
877,
17,
36560,
7,
4868,
877,
11,
2134,
62,
36560,
2599,
198,
220,
220,
220,
37227,
38855,
8787,
13,
797,
15164,
290,
16834,
5563,
526,
15931,
198,
220,
220,
220,
981,
6407,
25,
198,
220,
220,
220,
220,
220,
220,
220,
1949,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
5456,
796,
24783,
13,
13635,
3419,
198,
220,
220,
220,
220,
220,
220,
220,
2845,
440,
5188,
81,
1472,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1303,
340,
338,
4838,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2270,
628,
220,
220,
220,
220,
220,
220,
220,
351,
5456,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
981,
6407,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1949,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2134,
62,
36560,
13,
1996,
7,
16366,
13,
8344,
85,
28955,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2845,
412,
19238,
12331,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2270,
628,
198,
31,
22866,
8019,
13,
22866,
37153,
198,
4299,
6246,
33529,
198,
220,
220,
220,
37227,
21947,
4706,
326,
35019,
329,
3758,
22446,
628,
220,
220,
220,
5765,
428,
355,
257,
4732,
4706,
25,
628,
220,
220,
220,
220,
220,
220,
220,
1303,
262,
16834,
481,
3994,
5563,
422,
3758,
3419,
198,
220,
220,
220,
220,
220,
220,
220,
351,
6246,
3419,
355,
3275,
62,
36560,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1303,
923,
1223,
326,
7767,
3709,
287,
262,
16834,
290,
1057,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1303,
262,
3586,
198,
220,
220,
220,
37227,
198,
220,
220,
220,
3275,
62,
36560,
796,
16834,
13,
34991,
3419,
198,
220,
220,
220,
351,
4637,
13,
33252,
3419,
355,
24783,
25,
198,
220,
220,
220,
220,
220,
220,
220,
351,
1280,
28264,
2885,
7707,
7597,
62,
25664,
11,
705,
86,
11537,
355,
2393,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
3601,
7,
4868,
877,
13,
21975,
11,
2393,
28,
7753,
8,
198,
220,
220,
220,
220,
220,
220,
220,
4704,
796,
4704,
278,
13,
16818,
7,
16793,
28,
62,
4868,
877,
17,
36560,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
26498,
41888,
4868,
877,
11,
3275,
62,
36560,
4357,
33386,
28,
17821,
8,
198,
220,
220,
220,
220,
220,
220,
220,
4704,
13,
9688,
3419,
198,
220,
220,
220,
220,
220,
220,
220,
7800,
3275,
62,
36560,
628,
198,
361,
11593,
3672,
834,
6624,
705,
834,
12417,
834,
10354,
198,
220,
220,
220,
1303,
2829,
1332,
198,
220,
220,
220,
1949,
25,
198,
220,
220,
220,
220,
220,
220,
220,
3758,
26933,
16,
11,
362,
11,
513,
12962,
198,
220,
220,
220,
220,
220,
220,
220,
3601,
7203,
64,
4382,
318,
2491,
11,
257,
3275,
373,
1908,
284,
340,
4943,
198,
220,
220,
220,
2845,
26923,
8134,
1484,
12331,
25,
198,
220,
220,
220,
220,
220,
220,
220,
3601,
7203,
64,
4382,
318,
407,
2491,
11,
1309,
338,
1716,
262,
4382,
9313,
8,
198,
220,
220,
220,
220,
220,
220,
220,
351,
6246,
3419,
355,
3275,
62,
36560,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
981,
6407,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
3601,
7,
20500,
62,
36560,
13,
1136,
28955,
198
] | 2.482178 | 1,010 |
# -*- coding: utf-8 -*-
from Physics import eps_0, mu_0
from math import pi, sqrt
resistivity = {'copper': 1.7e-8, 'aluminum': 2.8e-8, 'iron': 1e-7,
'steel-electrical': 4.6e-7, 'steel-stainless': 6.9e-7,
'gold': 2.44e-8, 'silver': 1.68e-8,
'graphite-min': 2.5e-6, 'graphite-max': 5e-6}
permeability = {'steel-electrical': 5e-3, 'steel-stainless': 1000*mu_0,
'steel-carbon': 8.75e-4, 'copper': mu_0,
'aluminum': mu_0}
permittivity = {'metal': eps_0}
def skin_depth(omega, rho, mu=mu_0, eps=eps_0):
"""
Depth of the current layer in a conductor subject to AC fields::
J = J exp(-d/delta)
S
where J is the surface current density and delta is the skin depth::
S
Resistivity is defined so that the resistance of a bulk conductor is::
rho
R = --- L
A
where A is the cross-sectional area and L is the length.
@param omega : angular frequency (rad/s)
@type omega : float
@param mu : magnetic permeability (H/m)
@type mu : float
@param eps : electric permittivity (F/m)
@type eps : float
@param rho : resistivity (ohm-m)
@type rho : float
@return: m (float)
"""
return 1/omega/sqrt( (mu*eps/2) * (sqrt(1+(1/(rho*omega*eps))**2) -1) )
def skin_resistance(freq, rho, diam):
"""
Resistance in a 1-m thin wire.
A metal wire is assumed.
@param freq : Hz
@type freq : float
@param rho : material resistivity, ohm-m
@type rho : float
@param diam : diameter, m
@type diam : float
@return: ohm/m
"""
omega = 2*pi*freq
delta = skin_depth(omega, rho)
return rho/(pi*(diam-delta)*delta)
| [
2,
532,
9,
12,
19617,
25,
3384,
69,
12,
23,
532,
9,
12,
198,
6738,
23123,
1330,
304,
862,
62,
15,
11,
38779,
62,
15,
198,
6738,
10688,
1330,
31028,
11,
19862,
17034,
198,
198,
35119,
3458,
796,
1391,
6,
1073,
2848,
10354,
352,
13,
22,
68,
12,
23,
11,
705,
282,
13074,
10354,
362,
13,
23,
68,
12,
23,
11,
705,
1934,
10354,
352,
68,
12,
22,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
705,
44822,
12,
9509,
8143,
10354,
604,
13,
21,
68,
12,
22,
11,
705,
44822,
12,
301,
391,
1203,
10354,
718,
13,
24,
68,
12,
22,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
705,
24267,
10354,
362,
13,
2598,
68,
12,
23,
11,
705,
40503,
10354,
352,
13,
3104,
68,
12,
23,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
705,
34960,
578,
12,
1084,
10354,
362,
13,
20,
68,
12,
21,
11,
705,
34960,
578,
12,
9806,
10354,
642,
68,
12,
21,
92,
198,
198,
525,
1326,
1799,
796,
1391,
6,
44822,
12,
9509,
8143,
10354,
642,
68,
12,
18,
11,
705,
44822,
12,
301,
391,
1203,
10354,
8576,
9,
30300,
62,
15,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
705,
44822,
12,
29255,
10354,
807,
13,
2425,
68,
12,
19,
11,
705,
1073,
2848,
10354,
38779,
62,
15,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
705,
282,
13074,
10354,
38779,
62,
15,
92,
198,
198,
16321,
715,
3458,
796,
1391,
6,
28469,
10354,
304,
862,
62,
15,
92,
198,
198,
4299,
4168,
62,
18053,
7,
462,
4908,
11,
374,
8873,
11,
38779,
28,
30300,
62,
15,
11,
304,
862,
28,
25386,
62,
15,
2599,
198,
220,
37227,
198,
220,
36350,
286,
262,
1459,
7679,
287,
257,
39206,
2426,
284,
7125,
7032,
3712,
198,
220,
220,
449,
796,
449,
220,
1033,
32590,
67,
14,
67,
12514,
8,
198,
220,
220,
220,
220,
220,
220,
220,
311,
198,
220,
220,
220,
198,
220,
810,
449,
220,
318,
262,
4417,
1459,
12109,
290,
25979,
318,
262,
4168,
6795,
3712,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
311,
198,
220,
220,
198,
220,
36136,
3458,
318,
5447,
523,
326,
262,
6625,
286,
257,
11963,
39206,
318,
3712,
198,
220,
220,
198,
220,
220,
220,
220,
220,
220,
374,
8873,
198,
220,
220,
371,
796,
11420,
406,
198,
220,
220,
220,
220,
220,
220,
220,
317,
198,
220,
220,
198,
220,
810,
317,
318,
262,
3272,
12,
44330,
1989,
290,
406,
318,
262,
4129,
13,
198,
220,
220,
198,
220,
2488,
17143,
37615,
1058,
32558,
8373,
357,
6335,
14,
82,
8,
198,
220,
2488,
4906,
220,
37615,
1058,
12178,
198,
220,
220,
198,
220,
2488,
17143,
38779,
1058,
14091,
29298,
1799,
357,
39,
14,
76,
8,
198,
220,
2488,
4906,
220,
38779,
1058,
12178,
198,
220,
220,
198,
220,
2488,
17143,
304,
862,
1058,
5186,
9943,
715,
3458,
357,
37,
14,
76,
8,
198,
220,
2488,
4906,
220,
304,
862,
1058,
12178,
198,
220,
220,
198,
220,
2488,
17143,
374,
8873,
1058,
4180,
3458,
357,
34028,
12,
76,
8,
198,
220,
2488,
4906,
220,
374,
8873,
1058,
12178,
198,
220,
220,
198,
220,
2488,
7783,
25,
285,
357,
22468,
8,
198,
220,
37227,
198,
220,
1441,
352,
14,
462,
4908,
14,
31166,
17034,
7,
357,
30300,
9,
25386,
14,
17,
8,
1635,
357,
31166,
17034,
7,
16,
33747,
16,
29006,
81,
8873,
9,
462,
4908,
9,
25386,
4008,
1174,
17,
8,
532,
16,
8,
1267,
198,
198,
4299,
4168,
62,
411,
9311,
7,
19503,
80,
11,
374,
8873,
11,
48428,
2599,
198,
220,
37227,
198,
220,
17363,
287,
257,
352,
12,
76,
7888,
6503,
13,
198,
220,
220,
198,
220,
317,
6147,
6503,
318,
9672,
13,
198,
220,
220,
198,
220,
2488,
17143,
2030,
80,
1058,
26109,
198,
220,
2488,
4906,
220,
2030,
80,
1058,
12178,
198,
220,
220,
198,
220,
2488,
17143,
374,
8873,
1058,
2587,
4180,
3458,
11,
11752,
76,
12,
76,
198,
220,
2488,
4906,
220,
374,
8873,
1058,
12178,
198,
220,
220,
198,
220,
2488,
17143,
48428,
1058,
14753,
11,
285,
198,
220,
2488,
4906,
220,
48428,
1058,
12178,
198,
220,
220,
198,
220,
2488,
7783,
25,
11752,
76,
14,
76,
198,
220,
37227,
198,
220,
37615,
796,
362,
9,
14415,
9,
19503,
80,
198,
220,
25979,
796,
4168,
62,
18053,
7,
462,
4908,
11,
374,
8873,
8,
198,
220,
1441,
374,
8873,
29006,
14415,
9,
7,
67,
1789,
12,
67,
12514,
27493,
67,
12514,
8,
198
] | 2.173913 | 782 |
#!/usr/bin/env python3
import random
from mytcputils import *
from mytcp import Servidor
foi_aceita = False
rede = CamadaRede()
dst_port = random.randint(10, 1023)
servidor = Servidor(rede, dst_port)
servidor.registrar_monitor_de_conexoes_aceitas(conexao_aceita)
src_port = random.randint(1024, 0xffff)
seq_no = random.randint(0, 0xffff)
src_addr, dst_addr = '10.0.0.%d'%random.randint(1, 10), '10.0.0.%d'%random.randint(11, 20)
assert rede.fila == []
rede.callback(src_addr, dst_addr, fix_checksum(make_header(src_port, dst_port, seq_no, 0, FLAGS_SYN), src_addr, dst_addr))
assert foi_aceita, 'O monitor de conexões aceitas deveria ter sido chamado'
assert len(rede.fila) == 1
segmento, dst_addr2 = rede.fila[0]
assert fix_checksum(segmento, src_addr, dst_addr) == segmento
src_port2, dst_port2, seq_no2, ack_no2, flags2, _, _, _ = read_header(segmento)
assert 4*(flags2>>12) == len(segmento), 'O SYN+ACK não deveria ter payload'
assert dst_addr2 == src_addr
assert src_port2 == dst_port
assert dst_port2 == src_port
assert ack_no2 == seq_no + 1
assert flags2 & (FLAGS_SYN|FLAGS_ACK) == (FLAGS_SYN|FLAGS_ACK)
assert flags2 & (FLAGS_FIN|FLAGS_RST) == 0
rede.fila.clear()
src_port3 = src_port
while src_port3 == src_port:
src_port3 = random.randint(1024, 0xffff)
rede.callback(src_addr, dst_addr, fix_checksum(make_header(src_port3, dst_port, seq_no, 0, FLAGS_SYN), src_addr, dst_addr))
assert len(rede.fila) == 1
segmento, dst_addr4 = rede.fila[0]
assert fix_checksum(segmento, src_addr, dst_addr) == segmento
src_port4, dst_port4, seq_no4, ack_no4, flags4, _, _, _ = read_header(segmento)
assert 4*(flags4>>12) == len(segmento), 'O SYN+ACK não deveria ter payload'
assert dst_addr4 == src_addr
assert src_port4 == dst_port
assert dst_port4 == src_port3
assert ack_no4 == seq_no + 1
assert seq_no4 != seq_no2, 'O primeiro número de sequência usado em uma conexão deveria ser aleatório'
assert flags4 & (FLAGS_SYN|FLAGS_ACK) == (FLAGS_SYN|FLAGS_ACK)
assert flags4 & (FLAGS_FIN|FLAGS_RST) == 0
| [
2,
48443,
14629,
14,
8800,
14,
24330,
21015,
18,
198,
11748,
4738,
198,
6738,
616,
23047,
1996,
4487,
1330,
1635,
198,
6738,
616,
83,
13155,
1330,
3116,
312,
273,
198,
198,
6513,
72,
62,
558,
5350,
796,
10352,
198,
198,
445,
68,
796,
7298,
4763,
7738,
68,
3419,
198,
67,
301,
62,
634,
796,
4738,
13,
25192,
600,
7,
940,
11,
838,
1954,
8,
198,
3168,
312,
273,
796,
3116,
312,
273,
7,
445,
68,
11,
29636,
62,
634,
8,
198,
3168,
312,
273,
13,
2301,
396,
20040,
62,
41143,
62,
2934,
62,
49180,
87,
3028,
62,
558,
21416,
7,
49180,
87,
5488,
62,
558,
5350,
8,
198,
198,
10677,
62,
634,
796,
4738,
13,
25192,
600,
7,
35500,
11,
657,
87,
12927,
8,
198,
41068,
62,
3919,
796,
4738,
13,
25192,
600,
7,
15,
11,
657,
87,
12927,
8,
198,
10677,
62,
29851,
11,
29636,
62,
29851,
796,
705,
940,
13,
15,
13,
15,
13,
4,
67,
6,
4,
25120,
13,
25192,
600,
7,
16,
11,
838,
828,
705,
940,
13,
15,
13,
15,
13,
4,
67,
6,
4,
25120,
13,
25192,
600,
7,
1157,
11,
1160,
8,
198,
30493,
21459,
13,
69,
10102,
6624,
17635,
198,
445,
68,
13,
47423,
7,
10677,
62,
29851,
11,
29636,
62,
29851,
11,
4259,
62,
42116,
388,
7,
15883,
62,
25677,
7,
10677,
62,
634,
11,
29636,
62,
634,
11,
33756,
62,
3919,
11,
657,
11,
9977,
4760,
50,
62,
23060,
45,
828,
12351,
62,
29851,
11,
29636,
62,
29851,
4008,
198,
30493,
11511,
72,
62,
558,
5350,
11,
705,
46,
5671,
390,
369,
1069,
127,
113,
274,
31506,
21416,
390,
332,
544,
1059,
9785,
78,
442,
321,
4533,
6,
198,
30493,
18896,
7,
445,
68,
13,
69,
10102,
8,
6624,
352,
198,
325,
5154,
78,
11,
29636,
62,
29851,
17,
796,
21459,
13,
69,
10102,
58,
15,
60,
198,
30493,
4259,
62,
42116,
388,
7,
325,
5154,
78,
11,
12351,
62,
29851,
11,
29636,
62,
29851,
8,
6624,
10618,
78,
198,
10677,
62,
634,
17,
11,
29636,
62,
634,
17,
11,
33756,
62,
3919,
17,
11,
257,
694,
62,
3919,
17,
11,
9701,
17,
11,
4808,
11,
4808,
11,
4808,
796,
1100,
62,
25677,
7,
325,
5154,
78,
8,
198,
30493,
604,
9,
7,
33152,
17,
4211,
1065,
8,
6624,
18896,
7,
325,
5154,
78,
828,
705,
46,
19704,
45,
10,
8120,
299,
28749,
390,
332,
544,
1059,
21437,
6,
198,
30493,
29636,
62,
29851,
17,
6624,
12351,
62,
29851,
198,
30493,
12351,
62,
634,
17,
6624,
29636,
62,
634,
198,
30493,
29636,
62,
634,
17,
6624,
12351,
62,
634,
198,
30493,
257,
694,
62,
3919,
17,
6624,
33756,
62,
3919,
1343,
352,
198,
30493,
9701,
17,
1222,
357,
38948,
50,
62,
23060,
45,
91,
38948,
50,
62,
8120,
8,
6624,
357,
38948,
50,
62,
23060,
45,
91,
38948,
50,
62,
8120,
8,
198,
30493,
9701,
17,
1222,
357,
38948,
50,
62,
20032,
91,
38948,
50,
62,
49,
2257,
8,
6624,
657,
198,
198,
445,
68,
13,
69,
10102,
13,
20063,
3419,
198,
10677,
62,
634,
18,
796,
12351,
62,
634,
198,
4514,
12351,
62,
634,
18,
6624,
12351,
62,
634,
25,
198,
220,
220,
220,
12351,
62,
634,
18,
796,
4738,
13,
25192,
600,
7,
35500,
11,
657,
87,
12927,
8,
198,
445,
68,
13,
47423,
7,
10677,
62,
29851,
11,
29636,
62,
29851,
11,
4259,
62,
42116,
388,
7,
15883,
62,
25677,
7,
10677,
62,
634,
18,
11,
29636,
62,
634,
11,
33756,
62,
3919,
11,
657,
11,
9977,
4760,
50,
62,
23060,
45,
828,
12351,
62,
29851,
11,
29636,
62,
29851,
4008,
198,
30493,
18896,
7,
445,
68,
13,
69,
10102,
8,
6624,
352,
198,
325,
5154,
78,
11,
29636,
62,
29851,
19,
796,
21459,
13,
69,
10102,
58,
15,
60,
198,
30493,
4259,
62,
42116,
388,
7,
325,
5154,
78,
11,
12351,
62,
29851,
11,
29636,
62,
29851,
8,
6624,
10618,
78,
198,
10677,
62,
634,
19,
11,
29636,
62,
634,
19,
11,
33756,
62,
3919,
19,
11,
257,
694,
62,
3919,
19,
11,
9701,
19,
11,
4808,
11,
4808,
11,
4808,
796,
1100,
62,
25677,
7,
325,
5154,
78,
8,
198,
30493,
604,
9,
7,
33152,
19,
4211,
1065,
8,
6624,
18896,
7,
325,
5154,
78,
828,
705,
46,
19704,
45,
10,
8120,
299,
28749,
390,
332,
544,
1059,
21437,
6,
198,
30493,
29636,
62,
29851,
19,
6624,
12351,
62,
29851,
198,
30493,
12351,
62,
634,
19,
6624,
29636,
62,
634,
198,
30493,
29636,
62,
634,
19,
6624,
12351,
62,
634,
18,
198,
30493,
257,
694,
62,
3919,
19,
6624,
33756,
62,
3919,
1343,
352,
198,
30493,
33756,
62,
3919,
19,
14512,
33756,
62,
3919,
17,
11,
705,
46,
6994,
7058,
299,
21356,
647,
78,
390,
4726,
25792,
10782,
544,
514,
4533,
795,
334,
2611,
369,
1069,
28749,
390,
332,
544,
1055,
31341,
265,
10205,
27250,
6,
198,
30493,
9701,
19,
1222,
357,
38948,
50,
62,
23060,
45,
91,
38948,
50,
62,
8120,
8,
6624,
357,
38948,
50,
62,
23060,
45,
91,
38948,
50,
62,
8120,
8,
198,
30493,
9701,
19,
1222,
357,
38948,
50,
62,
20032,
91,
38948,
50,
62,
49,
2257,
8,
6624,
657,
198
] | 2.350176 | 851 |
"""Video stream client for Raspberry Pi-powered dash cam."""
import signal
import sys
from pathlib import Path
from typing import Any, Optional
import arrow
import cv2
from loguru import logger
from vidgear.gears import VideoGear, WriteGear
from minigugl import annotation, config
from minigugl.log import setup_logging
if config.settings.enable_gps:
from minigugl import location # noqa: WPS433
setup_logging(
log_level=config.settings.log_level,
log_format=config.settings.log_format,
)
opencv_options = {
'CAP_PROP_FRAME_WIDTH': config.settings.video_width,
'CAP_PROP_FRAME_HEIGHT': config.settings.video_height,
'CAP_PROP_FPS': config.settings.video_framerate,
}
stream = VideoGear(
source=config.settings.video_source,
**opencv_options,
).start()
# https://trac.ffmpeg.org/wiki/Encode/H.264
# https://www.ffmpeg.org/ffmpeg-all.html#Codec-Options
ffmpeg_options = {
'-c:v': config.settings.video_codec,
'-map': 0, # map all streams from the first input to output
'-segment_time': config.settings.video_segment_length_sec,
'-g': config.settings.video_framerate, # group of picture (GOP) size = fps
'-sc_threshold': 0, # disable scene detection
'-force_key_frames': 'expr:gte(t,n_forced*{0})'.format(
# force key frame every x seconds
config.settings.video_segment_length_sec,
),
# use `-clones` for `-f` parameter since WriteGear internally applies
# critical '-f rawvideo' parameter to every FFmpeg pipeline
'-clones': ['-f', 'segment'], # enable segment muxer
'-input_framerate': config.settings.video_framerate,
'-r': config.settings.video_framerate, # output framerate
'-pix_fmt': 'yuv420p', # for output to work in QuickTime
'-reset_timestamps': 1, # reset timestamps at beginning of each segment
'-strftime': 1, # expand the segment filename with localtime
}
if config.settings.video_codec == 'libx264':
ffmpeg_options.update({
'-crf': 22, # constant rate factor, decides quality
'-preset': 'fast', # preset for encoding speed/compression ratio
'-tune': 'zerolatency', # fast encoding and low-latency streaming
})
Path(config.settings.output_dir).mkdir(parents=True, exist_ok=True)
writer = WriteGear(
# Example: video_2021-04-14_20-15-30.mp4
# April 14th, 2021, at 8:15:30pm
output_filename=str(
Path(
config.settings.output_dir,
) / 'video_%Y-%m-%d_%H-%M-%S.mp4', # noqa: WPS323
),
logging=True,
**ffmpeg_options,
)
def _signal_handler(signalnum: int, _: Any) -> None:
"""Handle signal from user interruption (e.g. CTRL+C).
Logs an error message and exits with non-zero exit code. Args are ignored.
Args:
signalnum: Recevied signal number.
"""
logger.info('Received signal: {0}', signal.Signals(signalnum).name)
# safely close video stream & writer
stream.stop()
writer.close()
sys.exit(0)
# Register handler for (keyboard) interrupts
signal.signal(signal.SIGINT, _signal_handler)
signal.signal(signal.SIGTERM, _signal_handler)
if __name__ == '__main__':
if config.settings.enable_gps:
gps_coordinates = location.start_gps_thread()
while True:
frame = stream.read() # read frames from stream
# check for frame if None-type
if frame is None:
break
# explicit conversion of color space because of
# https://github.com/opencv/opencv/issues/18120
img = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
# add text annotations: timestamp and optionally GPS coordinates
img = _add_text_annotations(
img,
bottom_left=arrow.now().format(arrow.FORMAT_RFC2822),
bottom_right=(
str(gps_coordinates)
if config.settings.enable_gps
else None
),
)
# conversion back to original color space
img = cv2.cvtColor(img, cv2.COLOR_RGB2BGR)
writer.write(img)
| [
37811,
10798,
4269,
5456,
329,
24244,
13993,
12,
12293,
14470,
12172,
526,
15931,
198,
11748,
6737,
198,
11748,
25064,
198,
6738,
3108,
8019,
1330,
10644,
198,
6738,
19720,
1330,
4377,
11,
32233,
198,
198,
11748,
15452,
198,
11748,
269,
85,
17,
198,
6738,
2604,
14717,
1330,
49706,
198,
6738,
410,
312,
31763,
13,
70,
4127,
1330,
7623,
38141,
11,
19430,
38141,
198,
198,
6738,
949,
328,
1018,
75,
1330,
23025,
11,
4566,
198,
6738,
949,
328,
1018,
75,
13,
6404,
1330,
9058,
62,
6404,
2667,
198,
198,
361,
4566,
13,
33692,
13,
21633,
62,
70,
862,
25,
198,
220,
220,
220,
422,
949,
328,
1018,
75,
1330,
4067,
220,
1303,
645,
20402,
25,
370,
3705,
42117,
198,
198,
40406,
62,
6404,
2667,
7,
198,
220,
220,
220,
2604,
62,
5715,
28,
11250,
13,
33692,
13,
6404,
62,
5715,
11,
198,
220,
220,
220,
2604,
62,
18982,
28,
11250,
13,
33692,
13,
6404,
62,
18982,
11,
198,
8,
198,
198,
9654,
33967,
62,
25811,
796,
1391,
198,
220,
220,
220,
705,
33177,
62,
4805,
3185,
62,
10913,
10067,
62,
54,
2389,
4221,
10354,
4566,
13,
33692,
13,
15588,
62,
10394,
11,
198,
220,
220,
220,
705,
33177,
62,
4805,
3185,
62,
10913,
10067,
62,
13909,
9947,
10354,
4566,
13,
33692,
13,
15588,
62,
17015,
11,
198,
220,
220,
220,
705,
33177,
62,
4805,
3185,
62,
37,
3705,
10354,
4566,
13,
33692,
13,
15588,
62,
19298,
21620,
11,
198,
92,
198,
5532,
796,
7623,
38141,
7,
198,
220,
220,
220,
2723,
28,
11250,
13,
33692,
13,
15588,
62,
10459,
11,
198,
220,
220,
220,
12429,
9654,
33967,
62,
25811,
11,
198,
737,
9688,
3419,
198,
198,
2,
3740,
1378,
2213,
330,
13,
487,
43913,
13,
2398,
14,
15466,
14,
4834,
8189,
14,
39,
13,
18897,
198,
2,
3740,
1378,
2503,
13,
487,
43913,
13,
2398,
14,
487,
43913,
12,
439,
13,
6494,
2,
43806,
721,
12,
29046,
198,
487,
43913,
62,
25811,
796,
1391,
198,
220,
220,
220,
705,
12,
66,
25,
85,
10354,
4566,
13,
33692,
13,
15588,
62,
19815,
721,
11,
198,
220,
220,
220,
705,
12,
8899,
10354,
657,
11,
220,
1303,
3975,
477,
15190,
422,
262,
717,
5128,
284,
5072,
198,
220,
220,
220,
705,
12,
325,
5154,
62,
2435,
10354,
4566,
13,
33692,
13,
15588,
62,
325,
5154,
62,
13664,
62,
2363,
11,
198,
220,
220,
220,
705,
12,
70,
10354,
4566,
13,
33692,
13,
15588,
62,
19298,
21620,
11,
220,
1303,
1448,
286,
4286,
357,
44962,
8,
2546,
796,
32977,
198,
220,
220,
220,
705,
12,
1416,
62,
400,
10126,
10354,
657,
11,
220,
1303,
15560,
3715,
13326,
198,
220,
220,
220,
705,
12,
3174,
62,
2539,
62,
37805,
10354,
705,
31937,
25,
70,
660,
7,
83,
11,
77,
62,
12072,
9,
90,
15,
30072,
4458,
18982,
7,
198,
220,
220,
220,
220,
220,
220,
220,
1303,
2700,
1994,
5739,
790,
2124,
4201,
198,
220,
220,
220,
220,
220,
220,
220,
4566,
13,
33692,
13,
15588,
62,
325,
5154,
62,
13664,
62,
2363,
11,
198,
220,
220,
220,
10612,
198,
220,
220,
220,
1303,
779,
4600,
12,
565,
1952,
63,
329,
4600,
12,
69,
63,
11507,
1201,
19430,
38141,
20947,
8991,
198,
220,
220,
220,
1303,
4688,
705,
12,
69,
8246,
15588,
6,
11507,
284,
790,
18402,
43913,
11523,
198,
220,
220,
220,
705,
12,
565,
1952,
10354,
685,
29001,
69,
3256,
705,
325,
5154,
6,
4357,
220,
1303,
7139,
10618,
285,
2821,
263,
198,
220,
220,
220,
705,
12,
15414,
62,
19298,
21620,
10354,
4566,
13,
33692,
13,
15588,
62,
19298,
21620,
11,
198,
220,
220,
220,
705,
12,
81,
10354,
4566,
13,
33692,
13,
15588,
62,
19298,
21620,
11,
220,
1303,
5072,
5346,
21620,
198,
220,
220,
220,
705,
12,
79,
844,
62,
69,
16762,
10354,
705,
88,
14795,
27211,
79,
3256,
220,
1303,
329,
5072,
284,
670,
287,
12029,
7575,
198,
220,
220,
220,
705,
12,
42503,
62,
16514,
395,
9430,
10354,
352,
11,
220,
1303,
13259,
4628,
395,
9430,
379,
3726,
286,
1123,
10618,
198,
220,
220,
220,
705,
12,
2536,
31387,
10354,
352,
11,
220,
1303,
4292,
262,
10618,
29472,
351,
1957,
2435,
198,
92,
198,
361,
4566,
13,
33692,
13,
15588,
62,
19815,
721,
6624,
705,
8019,
87,
18897,
10354,
198,
220,
220,
220,
31246,
43913,
62,
25811,
13,
19119,
15090,
198,
220,
220,
220,
220,
220,
220,
220,
705,
12,
6098,
69,
10354,
2534,
11,
220,
1303,
6937,
2494,
5766,
11,
13267,
3081,
198,
220,
220,
220,
220,
220,
220,
220,
705,
12,
18302,
316,
10354,
705,
7217,
3256,
220,
1303,
38266,
329,
21004,
2866,
14,
5589,
2234,
8064,
198,
220,
220,
220,
220,
220,
220,
220,
705,
12,
83,
1726,
10354,
705,
9107,
349,
265,
1387,
3256,
220,
1303,
3049,
21004,
290,
1877,
12,
15460,
1387,
11305,
198,
220,
220,
220,
32092,
198,
15235,
7,
11250,
13,
33692,
13,
22915,
62,
15908,
737,
28015,
15908,
7,
23743,
28,
17821,
11,
2152,
62,
482,
28,
17821,
8,
198,
16002,
796,
19430,
38141,
7,
198,
220,
220,
220,
1303,
17934,
25,
2008,
62,
1238,
2481,
12,
3023,
12,
1415,
62,
1238,
12,
1314,
12,
1270,
13,
3149,
19,
198,
220,
220,
220,
1303,
3035,
1478,
400,
11,
33448,
11,
379,
807,
25,
1314,
25,
1270,
4426,
198,
220,
220,
220,
5072,
62,
34345,
28,
2536,
7,
198,
220,
220,
220,
220,
220,
220,
220,
10644,
7,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
4566,
13,
33692,
13,
22915,
62,
15908,
11,
198,
220,
220,
220,
220,
220,
220,
220,
1267,
1220,
705,
15588,
62,
4,
56,
12,
4,
76,
12,
4,
67,
62,
4,
39,
12,
4,
44,
12,
4,
50,
13,
3149,
19,
3256,
220,
1303,
645,
20402,
25,
370,
3705,
32637,
198,
220,
220,
220,
10612,
198,
220,
220,
220,
18931,
28,
17821,
11,
198,
220,
220,
220,
12429,
487,
43913,
62,
25811,
11,
198,
8,
628,
198,
4299,
4808,
12683,
282,
62,
30281,
7,
12683,
282,
22510,
25,
493,
11,
4808,
25,
4377,
8,
4613,
6045,
25,
198,
220,
220,
220,
37227,
37508,
6737,
422,
2836,
41728,
357,
68,
13,
70,
13,
45249,
10,
34,
737,
628,
220,
220,
220,
5972,
82,
281,
4049,
3275,
290,
30151,
351,
1729,
12,
22570,
8420,
2438,
13,
943,
14542,
389,
9514,
13,
628,
220,
220,
220,
943,
14542,
25,
198,
220,
220,
220,
220,
220,
220,
220,
6737,
22510,
25,
19520,
85,
798,
6737,
1271,
13,
198,
220,
220,
220,
37227,
198,
220,
220,
220,
49706,
13,
10951,
10786,
3041,
6471,
6737,
25,
1391,
15,
92,
3256,
6737,
13,
11712,
874,
7,
12683,
282,
22510,
737,
3672,
8,
198,
220,
220,
220,
1303,
11512,
1969,
2008,
4269,
1222,
6260,
198,
220,
220,
220,
4269,
13,
11338,
3419,
198,
220,
220,
220,
6260,
13,
19836,
3419,
198,
220,
220,
220,
25064,
13,
37023,
7,
15,
8,
628,
198,
2,
17296,
21360,
329,
357,
2539,
3526,
8,
48237,
198,
12683,
282,
13,
12683,
282,
7,
12683,
282,
13,
50,
3528,
12394,
11,
4808,
12683,
282,
62,
30281,
8,
198,
12683,
282,
13,
12683,
282,
7,
12683,
282,
13,
50,
3528,
5781,
44,
11,
4808,
12683,
282,
62,
30281,
8,
628,
198,
198,
361,
11593,
3672,
834,
6624,
705,
834,
12417,
834,
10354,
198,
220,
220,
220,
611,
4566,
13,
33692,
13,
21633,
62,
70,
862,
25,
198,
220,
220,
220,
220,
220,
220,
220,
308,
862,
62,
37652,
17540,
796,
4067,
13,
9688,
62,
70,
862,
62,
16663,
3419,
628,
220,
220,
220,
981,
6407,
25,
198,
220,
220,
220,
220,
220,
220,
220,
5739,
796,
4269,
13,
961,
3419,
220,
1303,
1100,
13431,
422,
4269,
628,
220,
220,
220,
220,
220,
220,
220,
1303,
2198,
329,
5739,
611,
6045,
12,
4906,
198,
220,
220,
220,
220,
220,
220,
220,
611,
5739,
318,
6045,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2270,
628,
220,
220,
220,
220,
220,
220,
220,
1303,
7952,
11315,
286,
3124,
2272,
780,
286,
198,
220,
220,
220,
220,
220,
220,
220,
1303,
3740,
1378,
12567,
13,
785,
14,
9654,
33967,
14,
9654,
33967,
14,
37165,
14,
1507,
10232,
198,
220,
220,
220,
220,
220,
220,
220,
33705,
796,
269,
85,
17,
13,
33967,
83,
10258,
7,
14535,
11,
269,
85,
17,
13,
46786,
62,
33,
10761,
17,
36982,
8,
628,
220,
220,
220,
220,
220,
220,
220,
1303,
751,
2420,
37647,
25,
41033,
290,
42976,
15472,
22715,
198,
220,
220,
220,
220,
220,
220,
220,
33705,
796,
4808,
2860,
62,
5239,
62,
34574,
602,
7,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
33705,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
4220,
62,
9464,
28,
6018,
13,
2197,
22446,
18982,
7,
6018,
13,
21389,
1404,
62,
41150,
2078,
1828,
828,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
4220,
62,
3506,
16193,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
965,
7,
70,
862,
62,
37652,
17540,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
611,
4566,
13,
33692,
13,
21633,
62,
70,
862,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2073,
6045,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
10612,
198,
220,
220,
220,
220,
220,
220,
220,
1267,
628,
220,
220,
220,
220,
220,
220,
220,
1303,
11315,
736,
284,
2656,
3124,
2272,
198,
220,
220,
220,
220,
220,
220,
220,
33705,
796,
269,
85,
17,
13,
33967,
83,
10258,
7,
9600,
11,
269,
85,
17,
13,
46786,
62,
36982,
17,
33,
10761,
8,
628,
220,
220,
220,
220,
220,
220,
220,
6260,
13,
13564,
7,
9600,
8,
198
] | 2.485802 | 1,620 |
from sanic import response, Sanic
import asyncio
import timeit
# MaryJane is an mjpeg server - it works by fetching *the same* jpeg image over and over from a ram drive
# MIT license
# copyright 2021 Andrew Stuart [email protected]
app = Sanic(__name__)
@app.route('/maryjane/')
if __name__ == '__main__':
try:
app.run(host="0.0.0.0", port=8080)
except KeyboardInterrupt:
print("Received KeyboardInterrupt, exiting")
| [
6738,
5336,
291,
1330,
2882,
11,
2986,
291,
198,
11748,
30351,
952,
198,
11748,
640,
270,
198,
198,
2,
5335,
41083,
318,
281,
285,
73,
22071,
4382,
532,
340,
2499,
416,
21207,
278,
1635,
1169,
976,
9,
474,
22071,
2939,
625,
290,
625,
422,
257,
15770,
3708,
198,
2,
17168,
5964,
198,
2,
6634,
33448,
6858,
22559,
290,
1809,
13,
301,
19986,
31,
16668,
19815,
364,
13,
785,
13,
559,
198,
198,
1324,
796,
2986,
291,
7,
834,
3672,
834,
8,
198,
198,
31,
1324,
13,
38629,
10786,
14,
6874,
73,
1531,
14,
11537,
198,
198,
361,
11593,
3672,
834,
6624,
705,
834,
12417,
834,
10354,
198,
220,
220,
220,
1949,
25,
198,
220,
220,
220,
220,
220,
220,
220,
598,
13,
5143,
7,
4774,
2625,
15,
13,
15,
13,
15,
13,
15,
1600,
2493,
28,
1795,
1795,
8,
198,
220,
220,
220,
2845,
31973,
9492,
3622,
25,
198,
220,
220,
220,
220,
220,
220,
220,
3601,
7203,
3041,
6471,
31973,
9492,
3622,
11,
33895,
4943,
198
] | 2.754491 | 167 |
GET_PACKAGE_ADT_XML='''<?xml version="1.0" encoding="utf-8"?>
<pak:package xmlns:pak="http://www.sap.com/adt/packages" xmlns:adtcore="http://www.sap.com/adt/core" adtcore:masterLanguage="EN" adtcore:name="$IAMTHEKING" adtcore:type="DEVC/K" adtcore:changedAt="2019-01-29T23:00:00Z" adtcore:version="active" adtcore:createdAt="2019-01-29T23:00:00Z" adtcore:changedBy="DEVELOPER" adtcore:description="This is a package" adtcore:descriptionTextLimit="60" adtcore:language="EN">
<atom:link xmlns:atom="http://www.w3.org/2005/Atom" href="/sap/bc/adt/vit/wb/object_type/devck/object_name/%24IAMTHEKING" rel="self" type="application/vnd.sap.sapgui" title="Representation in SAP Gui"/>
<atom:link xmlns:atom="http://www.w3.org/2005/Atom" href="/sap/bc/adt/packages/valuehelps/applicationcomponents" rel="applicationcomponents" type="application/vnd.sap.adt.nameditems.v1+xml" title="Application Components Value Help"/>
<atom:link xmlns:atom="http://www.w3.org/2005/Atom" href="/sap/bc/adt/packages/valuehelps/softwarecomponents" rel="softwarecomponents" type="application/vnd.sap.adt.nameditems.v1+xml" title="Software Components Value Help"/>
<atom:link xmlns:atom="http://www.w3.org/2005/Atom" href="/sap/bc/adt/packages/valuehelps/transportlayers" rel="transportlayers" type="application/vnd.sap.adt.nameditems.v1+xml" title="Transport Layers Value Help"/>
<atom:link xmlns:atom="http://www.w3.org/2005/Atom" href="/sap/bc/adt/packages/valuehelps/translationrelevances" rel="translationrelevances" type="application/vnd.sap.adt.nameditems.v1+xml" title="Transport Relevances Value Help"/>
<pak:attributes pak:packageType="development" pak:isPackageTypeEditable="false" pak:isAddingObjectsAllowed="false" pak:isAddingObjectsAllowedEditable="true" pak:isEncapsulated="false" pak:isEncapsulationEditable="false" pak:recordChanges="false" pak:isRecordChangesEditable="false" pak:isSwitchVisible="false"/>
<pak:superPackage/>
<pak:applicationComponent pak:name="-" pak:description="No application component assigned" pak:isVisible="true" pak:isEditable="false"/>
<pak:transport>
<pak:softwareComponent pak:name="LOCAL" pak:description="" pak:isVisible="true" pak:isEditable="false"/>
<pak:transportLayer pak:name="" pak:description="" pak:isVisible="false" pak:isEditable="false"/>
</pak:transport>
<pak:useAccesses pak:isVisible="false"/>
<pak:packageInterfaces pak:isVisible="false"/>
<pak:subPackages>
<pak:packageRef adtcore:uri="/sap/bc/adt/packages/%24iamtheking_doc" adtcore:type="DEVC/K" adtcore:name="$IAMTHEKING_DOC" adtcore:description="Documentation stuff"/>
<pak:packageRef adtcore:uri="/sap/bc/adt/packages/%24iamtheking_src" adtcore:type="DEVC/K" adtcore:name="$IAMTHEKING_SRC" adtcore:description="Production source codes"/>
<pak:packageRef adtcore:uri="/sap/bc/adt/packages/%24iamtheking_tests" adtcore:type="DEVC/K" adtcore:name="$IAMTHEKING_TESTS" adtcore:description="Package with Tests"/>
</pak:subPackages>
</pak:package>
'''
GET_PACKAGE_ADT_XML_NOT_FOUND='''<?xml version="1.0" encoding="utf-8"?>
<exc:exception xmlns:exc="http://www.sap.com/abapxml/types/communicationframework">
<namespace id="com.sap.adt"/>
<type id="ExceptionResourceNotFound"/>
<message lang="EN">Error while importing object PKG_NAME from the database.</message>
<localizedMessage lang="EN">Error while importing object PKG_NAME from the database.</localizedMessage>
<properties/>
</exc:exception>
'''.replace('\n', '').replace('\r', '')
| [
18851,
62,
47,
8120,
11879,
62,
2885,
51,
62,
55,
5805,
28,
7061,
6,
47934,
19875,
2196,
2625,
16,
13,
15,
1,
21004,
2625,
40477,
12,
23,
13984,
29,
198,
27,
41091,
25,
26495,
35555,
5907,
25,
41091,
2625,
4023,
1378,
2503,
13,
82,
499,
13,
785,
14,
324,
83,
14,
43789,
1,
35555,
5907,
25,
324,
83,
7295,
2625,
4023,
1378,
2503,
13,
82,
499,
13,
785,
14,
324,
83,
14,
7295,
1,
512,
83,
7295,
25,
9866,
32065,
2625,
1677,
1,
512,
83,
7295,
25,
3672,
2625,
3,
40,
2390,
10970,
37286,
1,
512,
83,
7295,
25,
4906,
2625,
7206,
15922,
14,
42,
1,
512,
83,
7295,
25,
40985,
2953,
2625,
23344,
12,
486,
12,
1959,
51,
1954,
25,
405,
25,
405,
57,
1,
512,
83,
7295,
25,
9641,
2625,
5275,
1,
512,
83,
7295,
25,
25598,
2953,
2625,
23344,
12,
486,
12,
1959,
51,
1954,
25,
405,
25,
405,
57,
1,
512,
83,
7295,
25,
40985,
3886,
2625,
7206,
18697,
31054,
1,
512,
83,
7295,
25,
11213,
2625,
1212,
318,
257,
5301,
1,
512,
83,
7295,
25,
11213,
8206,
39184,
2625,
1899,
1,
512,
83,
7295,
25,
16129,
2625,
1677,
5320,
198,
220,
1279,
37696,
25,
8726,
35555,
5907,
25,
37696,
2625,
4023,
1378,
2503,
13,
86,
18,
13,
2398,
14,
14315,
14,
2953,
296,
1,
13291,
35922,
82,
499,
14,
15630,
14,
324,
83,
14,
85,
270,
14,
39346,
14,
15252,
62,
4906,
14,
7959,
694,
14,
15252,
62,
3672,
14,
4,
1731,
40,
2390,
10970,
37286,
1,
823,
2625,
944,
1,
2099,
2625,
31438,
14,
85,
358,
13,
82,
499,
13,
82,
499,
48317,
1,
3670,
2625,
40171,
341,
287,
48323,
1962,
72,
26700,
198,
220,
1279,
37696,
25,
8726,
35555,
5907,
25,
37696,
2625,
4023,
1378,
2503,
13,
86,
18,
13,
2398,
14,
14315,
14,
2953,
296,
1,
13291,
35922,
82,
499,
14,
15630,
14,
324,
83,
14,
43789,
14,
8367,
35194,
14,
31438,
5589,
3906,
1,
823,
2625,
31438,
5589,
3906,
1,
2099,
2625,
31438,
14,
85,
358,
13,
82,
499,
13,
324,
83,
13,
13190,
23814,
13,
85,
16,
10,
19875,
1,
3670,
2625,
23416,
36109,
11052,
10478,
26700,
198,
220,
1279,
37696,
25,
8726,
35555,
5907,
25,
37696,
2625,
4023,
1378,
2503,
13,
86,
18,
13,
2398,
14,
14315,
14,
2953,
296,
1,
13291,
35922,
82,
499,
14,
15630,
14,
324,
83,
14,
43789,
14,
8367,
35194,
14,
43776,
5589,
3906,
1,
823,
2625,
43776,
5589,
3906,
1,
2099,
2625,
31438,
14,
85,
358,
13,
82,
499,
13,
324,
83,
13,
13190,
23814,
13,
85,
16,
10,
19875,
1,
3670,
2625,
25423,
36109,
11052,
10478,
26700,
198,
220,
1279,
37696,
25,
8726,
35555,
5907,
25,
37696,
2625,
4023,
1378,
2503,
13,
86,
18,
13,
2398,
14,
14315,
14,
2953,
296,
1,
13291,
35922,
82,
499,
14,
15630,
14,
324,
83,
14,
43789,
14,
8367,
35194,
14,
7645,
634,
75,
6962,
1,
823,
2625,
7645,
634,
75,
6962,
1,
2099,
2625,
31438,
14,
85,
358,
13,
82,
499,
13,
324,
83,
13,
13190,
23814,
13,
85,
16,
10,
19875,
1,
3670,
2625,
8291,
634,
406,
6962,
11052,
10478,
26700,
198,
220,
1279,
37696,
25,
8726,
35555,
5907,
25,
37696,
2625,
4023,
1378,
2503,
13,
86,
18,
13,
2398,
14,
14315,
14,
2953,
296,
1,
13291,
35922,
82,
499,
14,
15630,
14,
324,
83,
14,
43789,
14,
8367,
35194,
14,
41519,
260,
2768,
1817,
1,
823,
2625,
41519,
260,
2768,
1817,
1,
2099,
2625,
31438,
14,
85,
358,
13,
82,
499,
13,
324,
83,
13,
13190,
23814,
13,
85,
16,
10,
19875,
1,
3670,
2625,
8291,
634,
797,
2768,
1817,
11052,
10478,
26700,
198,
220,
1279,
41091,
25,
1078,
7657,
279,
461,
25,
26495,
6030,
2625,
31267,
1,
279,
461,
25,
271,
27813,
6030,
7407,
4674,
2625,
9562,
1,
279,
461,
25,
271,
32901,
10267,
82,
3237,
6972,
2625,
9562,
1,
279,
461,
25,
271,
32901,
10267,
82,
3237,
6972,
7407,
4674,
2625,
7942,
1,
279,
461,
25,
271,
27195,
1686,
4817,
2625,
9562,
1,
279,
461,
25,
271,
27195,
1686,
1741,
7407,
4674,
2625,
9562,
1,
279,
461,
25,
22105,
29238,
2625,
9562,
1,
279,
461,
25,
271,
23739,
29238,
7407,
4674,
2625,
9562,
1,
279,
461,
25,
271,
38978,
53,
12843,
2625,
9562,
26700,
198,
220,
1279,
41091,
25,
16668,
27813,
15913,
198,
220,
1279,
41091,
25,
31438,
21950,
279,
461,
25,
3672,
2625,
21215,
279,
461,
25,
11213,
2625,
2949,
3586,
7515,
8686,
1,
279,
461,
25,
271,
53,
12843,
2625,
7942,
1,
279,
461,
25,
271,
7407,
4674,
2625,
9562,
26700,
198,
220,
1279,
41091,
25,
7645,
634,
29,
198,
220,
220,
220,
1279,
41091,
25,
43776,
21950,
279,
461,
25,
3672,
2625,
29701,
1847,
1,
279,
461,
25,
11213,
33151,
279,
461,
25,
271,
53,
12843,
2625,
7942,
1,
279,
461,
25,
271,
7407,
4674,
2625,
9562,
26700,
198,
220,
220,
220,
1279,
41091,
25,
7645,
634,
49925,
279,
461,
25,
3672,
33151,
279,
461,
25,
11213,
33151,
279,
461,
25,
271,
53,
12843,
2625,
9562,
1,
279,
461,
25,
271,
7407,
4674,
2625,
9562,
26700,
198,
220,
7359,
41091,
25,
7645,
634,
29,
198,
220,
1279,
41091,
25,
1904,
15457,
274,
279,
461,
25,
271,
53,
12843,
2625,
9562,
26700,
198,
220,
1279,
41091,
25,
26495,
9492,
32186,
279,
461,
25,
271,
53,
12843,
2625,
9562,
26700,
198,
220,
1279,
41091,
25,
7266,
11869,
1095,
29,
198,
220,
220,
220,
1279,
41091,
25,
26495,
8134,
512,
83,
7295,
25,
9900,
35922,
82,
499,
14,
15630,
14,
324,
83,
14,
43789,
14,
4,
1731,
1789,
1169,
3364,
62,
15390,
1,
512,
83,
7295,
25,
4906,
2625,
7206,
15922,
14,
42,
1,
512,
83,
7295,
25,
3672,
2625,
3,
40,
2390,
10970,
37286,
62,
38715,
1,
512,
83,
7295,
25,
11213,
2625,
24941,
341,
3404,
26700,
198,
220,
220,
220,
1279,
41091,
25,
26495,
8134,
512,
83,
7295,
25,
9900,
35922,
82,
499,
14,
15630,
14,
324,
83,
14,
43789,
14,
4,
1731,
1789,
1169,
3364,
62,
10677,
1,
512,
83,
7295,
25,
4906,
2625,
7206,
15922,
14,
42,
1,
512,
83,
7295,
25,
3672,
2625,
3,
40,
2390,
10970,
37286,
62,
50,
7397,
1,
512,
83,
7295,
25,
11213,
2625,
35027,
2723,
12416,
26700,
198,
220,
220,
220,
1279,
41091,
25,
26495,
8134,
512,
83,
7295,
25,
9900,
35922,
82,
499,
14,
15630,
14,
324,
83,
14,
43789,
14,
4,
1731,
1789,
1169,
3364,
62,
41989,
1,
512,
83,
7295,
25,
4906,
2625,
7206,
15922,
14,
42,
1,
512,
83,
7295,
25,
3672,
2625,
3,
40,
2390,
10970,
37286,
62,
51,
1546,
4694,
1,
512,
83,
7295,
25,
11213,
2625,
27813,
351,
30307,
26700,
198,
220,
7359,
41091,
25,
7266,
11869,
1095,
29,
198,
3556,
41091,
25,
26495,
29,
198,
7061,
6,
198,
198,
18851,
62,
47,
8120,
11879,
62,
2885,
51,
62,
55,
5805,
62,
11929,
62,
37,
15919,
28,
7061,
6,
47934,
19875,
2196,
2625,
16,
13,
15,
1,
21004,
2625,
40477,
12,
23,
13984,
29,
198,
27,
41194,
25,
1069,
4516,
35555,
5907,
25,
41194,
2625,
4023,
1378,
2503,
13,
82,
499,
13,
785,
14,
397,
499,
19875,
14,
19199,
14,
32560,
30604,
5320,
198,
220,
1279,
14933,
10223,
4686,
2625,
785,
13,
82,
499,
13,
324,
83,
26700,
198,
220,
1279,
4906,
4686,
2625,
16922,
26198,
3673,
21077,
26700,
198,
220,
1279,
20500,
42392,
2625,
1677,
5320,
12331,
981,
33332,
2134,
29673,
38,
62,
20608,
422,
262,
6831,
25970,
20500,
29,
198,
220,
1279,
12001,
1143,
12837,
42392,
2625,
1677,
5320,
12331,
981,
33332,
2134,
29673,
38,
62,
20608,
422,
262,
6831,
25970,
12001,
1143,
12837,
29,
198,
220,
1279,
48310,
15913,
198,
3556,
41194,
25,
1069,
4516,
29,
198,
7061,
4458,
33491,
10786,
59,
77,
3256,
10148,
737,
33491,
10786,
59,
81,
3256,
10148,
8,
198
] | 2.714731 | 1,283 |
#################################################################
# Code written by Edward Choi ([email protected])
# For bug report, please contact author using the email address
#################################################################
import sys, random
import numpy as np
import cPickle as pickle
from collections import OrderedDict
import argparse
import theano
import theano.tensor as T
from theano import config
from theano.sandbox.rng_mrg import MRG_RandomStreams as RandomStreams
if __name__ == '__main__':
parser = argparse.ArgumentParser()
args = parse_arguments(parser)
hiddenDimSize = [int(strDim) for strDim in args.hidden_dim_size[1:-1].split(',')]
if args.predict_time and args.time_file == '':
print 'Cannot predict time duration without time file'
sys.exit()
train_doctorAI(
seqFile=args.seq_file,
inputDimSize=args.n_input_codes,
labelFile=args.label_file,
numClass=args.n_output_codes,
outFile=args.out_file,
timeFile=args.time_file,
predictTime=args.predict_time,
tradeoff=args.tradeoff,
useLogTime=args.use_log_time,
embFile=args.embed_file,
embSize=args.embed_size,
embFineTune=args.embed_finetune,
hiddenDimSize=hiddenDimSize,
batchSize=args.batch_size,
max_epochs=args.n_epochs,
L2_output=args.L2_softmax,
L2_time=args.L2_time,
dropout_rate=args.dropout_rate,
logEps=args.log_eps,
verbose=args.verbose
)
| [
29113,
29113,
2,
198,
2,
6127,
3194,
416,
10443,
42198,
357,
3149,
2078,
6052,
31,
10494,
354,
13,
15532,
8,
198,
2,
1114,
5434,
989,
11,
3387,
2800,
1772,
1262,
262,
3053,
2209,
198,
29113,
29113,
2,
198,
198,
11748,
25064,
11,
4738,
198,
11748,
299,
32152,
355,
45941,
198,
11748,
269,
31686,
293,
355,
2298,
293,
198,
6738,
17268,
1330,
14230,
1068,
35,
713,
198,
11748,
1822,
29572,
198,
198,
11748,
262,
5733,
198,
11748,
262,
5733,
13,
83,
22854,
355,
309,
198,
6738,
262,
5733,
1330,
4566,
198,
6738,
262,
5733,
13,
38142,
3524,
13,
81,
782,
62,
76,
41345,
1330,
17242,
38,
62,
29531,
12124,
82,
355,
14534,
12124,
82,
198,
198,
361,
11593,
3672,
834,
6624,
705,
834,
12417,
834,
10354,
198,
197,
48610,
796,
1822,
29572,
13,
28100,
1713,
46677,
3419,
198,
197,
22046,
796,
21136,
62,
853,
2886,
7,
48610,
8,
198,
197,
30342,
29271,
10699,
796,
685,
600,
7,
2536,
29271,
8,
329,
965,
29271,
287,
26498,
13,
30342,
62,
27740,
62,
7857,
58,
16,
21912,
16,
4083,
35312,
7,
3256,
11537,
60,
628,
197,
361,
26498,
13,
79,
17407,
62,
2435,
290,
26498,
13,
2435,
62,
7753,
6624,
10148,
25,
198,
197,
197,
4798,
705,
34,
34574,
4331,
640,
9478,
1231,
640,
2393,
6,
198,
197,
197,
17597,
13,
37023,
3419,
628,
197,
27432,
62,
35580,
20185,
7,
198,
197,
197,
41068,
8979,
28,
22046,
13,
41068,
62,
7753,
11,
220,
198,
197,
197,
15414,
29271,
10699,
28,
22046,
13,
77,
62,
15414,
62,
40148,
11,
220,
198,
197,
197,
18242,
8979,
28,
22046,
13,
18242,
62,
7753,
11,
220,
198,
197,
197,
22510,
9487,
28,
22046,
13,
77,
62,
22915,
62,
40148,
11,
220,
198,
197,
197,
448,
8979,
28,
22046,
13,
448,
62,
7753,
11,
220,
198,
197,
197,
2435,
8979,
28,
22046,
13,
2435,
62,
7753,
11,
220,
198,
197,
197,
79,
17407,
7575,
28,
22046,
13,
79,
17407,
62,
2435,
11,
198,
197,
197,
25351,
2364,
28,
22046,
13,
25351,
2364,
11,
198,
197,
197,
1904,
11187,
7575,
28,
22046,
13,
1904,
62,
6404,
62,
2435,
11,
198,
197,
197,
24419,
8979,
28,
22046,
13,
20521,
62,
7753,
11,
220,
198,
197,
197,
24419,
10699,
28,
22046,
13,
20521,
62,
7857,
11,
220,
198,
197,
197,
24419,
34389,
51,
1726,
28,
22046,
13,
20521,
62,
15643,
316,
1726,
11,
220,
198,
197,
197,
30342,
29271,
10699,
28,
30342,
29271,
10699,
11,
198,
197,
197,
43501,
10699,
28,
22046,
13,
43501,
62,
7857,
11,
220,
198,
197,
197,
9806,
62,
538,
5374,
82,
28,
22046,
13,
77,
62,
538,
5374,
82,
11,
220,
198,
197,
197,
43,
17,
62,
22915,
28,
22046,
13,
43,
17,
62,
4215,
9806,
11,
220,
198,
197,
197,
43,
17,
62,
2435,
28,
22046,
13,
43,
17,
62,
2435,
11,
220,
198,
197,
197,
14781,
448,
62,
4873,
28,
22046,
13,
14781,
448,
62,
4873,
11,
220,
198,
197,
197,
6404,
36,
862,
28,
22046,
13,
6404,
62,
25386,
11,
220,
198,
197,
197,
19011,
577,
28,
22046,
13,
19011,
577,
198,
197,
8,
198
] | 2.753425 | 511 |
#! /usr/bin/env python
#
# This file is part of pySerial - Cross platform serial port support for Python
# (C) 2001-2015 Chris Liechti <[email protected]>
#
# SPDX-License-Identifier: BSD-3-Clause
"""\
Some tests for the serial module.
Part of pyserial (http://pyserial.sf.net) (C)2001-2009 [email protected]
Intended to be run on different platforms, to ensure portability of
the code.
This modules contains test for the interaction between Serial and the io
library. This only works on Python 2.6+ that introduced the io library.
For all these tests a simple hardware is required.
Loopback HW adapter:
Shortcut these pin pairs:
TX <-> RX
RTS <-> CTS
DTR <-> DSR
On a 9 pole DSUB these are the pins (2-3) (4-6) (7-8)
"""
import unittest
import sys
if __name__ == '__main__' and sys.version_info < (2, 6):
sys.stderr.write("""\
==============================================================================
WARNING: this test is intended for Python 2.6 and newer where the io library
is available. This seems to be an older version of Python running.
Continuing anyway...
==============================================================================
""")
import io
import serial
# trick to make that this test run under 2.6 and 3.x without modification.
# problem is, io library on 2.6 does NOT accept type 'str' and 3.x doesn't
# like u'nicode' strings with the prefix and it is not providing an unicode
# function ('str' is now what 'unicode' used to be)
if sys.version_info >= (3, 0):
# on which port should the tests be performed:
PORT = 0
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
if __name__ == '__main__':
import sys
sys.stdout.write(__doc__)
if len(sys.argv) > 1:
PORT = sys.argv[1]
sys.stdout.write("Testing port: %r\n" % PORT)
sys.argv[1:] = ['-v']
# When this module is executed from the command-line, it runs all its tests
unittest.main()
| [
2,
0,
1220,
14629,
14,
8800,
14,
24330,
21015,
198,
2,
198,
2,
770,
2393,
318,
636,
286,
12972,
32634,
532,
6372,
3859,
11389,
2493,
1104,
329,
11361,
198,
2,
357,
34,
8,
5878,
12,
4626,
5180,
12060,
354,
20259,
1279,
565,
494,
354,
20259,
31,
70,
36802,
13,
3262,
29,
198,
2,
198,
2,
30628,
55,
12,
34156,
12,
33234,
7483,
25,
220,
220,
220,
347,
10305,
12,
18,
12,
2601,
682,
198,
37811,
59,
198,
4366,
5254,
329,
262,
11389,
8265,
13,
198,
7841,
286,
279,
893,
48499,
357,
4023,
1378,
79,
893,
48499,
13,
28202,
13,
3262,
8,
220,
357,
34,
8,
14585,
12,
10531,
537,
494,
354,
20259,
31,
70,
36802,
13,
3262,
198,
198,
5317,
1631,
284,
307,
1057,
319,
1180,
9554,
11,
284,
4155,
2493,
1799,
286,
198,
1169,
2438,
13,
198,
198,
1212,
13103,
4909,
1332,
329,
262,
10375,
1022,
23283,
290,
262,
33245,
198,
32016,
13,
770,
691,
2499,
319,
11361,
362,
13,
21,
10,
326,
5495,
262,
33245,
5888,
13,
198,
198,
1890,
477,
777,
5254,
257,
2829,
6890,
318,
2672,
13,
198,
39516,
1891,
44884,
21302,
25,
198,
16438,
8968,
777,
6757,
14729,
25,
198,
15326,
220,
1279,
3784,
24202,
198,
371,
4694,
1279,
3784,
327,
4694,
198,
360,
5446,
1279,
3784,
360,
12562,
198,
198,
2202,
257,
860,
16825,
17400,
10526,
777,
389,
262,
20567,
357,
17,
12,
18,
8,
357,
19,
12,
21,
8,
357,
22,
12,
23,
8,
198,
37811,
198,
198,
11748,
555,
715,
395,
198,
11748,
25064,
198,
198,
361,
11593,
3672,
834,
6624,
705,
834,
12417,
834,
6,
220,
290,
25064,
13,
9641,
62,
10951,
1279,
357,
17,
11,
718,
2599,
198,
220,
220,
220,
25064,
13,
301,
1082,
81,
13,
13564,
7203,
15931,
59,
198,
23926,
25609,
855,
198,
31502,
25,
428,
1332,
318,
5292,
329,
11361,
362,
13,
21,
290,
15064,
810,
262,
33245,
5888,
198,
271,
1695,
13,
770,
2331,
284,
307,
281,
4697,
2196,
286,
11361,
2491,
13,
198,
17875,
4250,
6949,
986,
198,
23926,
25609,
855,
198,
15931,
4943,
198,
198,
11748,
33245,
198,
11748,
11389,
198,
198,
2,
6908,
284,
787,
326,
428,
1332,
1057,
739,
362,
13,
21,
290,
513,
13,
87,
1231,
17613,
13,
198,
2,
1917,
318,
11,
33245,
5888,
319,
362,
13,
21,
857,
5626,
2453,
2099,
705,
2536,
6,
290,
513,
13,
87,
1595,
470,
198,
2,
588,
334,
6,
6988,
1098,
6,
13042,
351,
262,
21231,
290,
340,
318,
407,
4955,
281,
28000,
1098,
198,
2,
2163,
19203,
2536,
6,
318,
783,
644,
705,
46903,
1098,
6,
973,
284,
307,
8,
198,
361,
25064,
13,
9641,
62,
10951,
18189,
357,
18,
11,
657,
2599,
628,
198,
2,
319,
543,
2493,
815,
262,
5254,
307,
6157,
25,
198,
15490,
796,
657,
198,
198,
2,
532,
532,
532,
532,
532,
532,
532,
532,
532,
532,
532,
532,
532,
532,
532,
532,
532,
532,
532,
532,
532,
532,
532,
532,
532,
532,
532,
532,
532,
532,
532,
532,
532,
532,
532,
532,
532,
532,
532,
198,
361,
11593,
3672,
834,
6624,
705,
834,
12417,
834,
10354,
198,
220,
220,
220,
1330,
25064,
198,
220,
220,
220,
25064,
13,
19282,
448,
13,
13564,
7,
834,
15390,
834,
8,
198,
220,
220,
220,
611,
18896,
7,
17597,
13,
853,
85,
8,
1875,
352,
25,
198,
220,
220,
220,
220,
220,
220,
220,
350,
9863,
796,
25064,
13,
853,
85,
58,
16,
60,
198,
220,
220,
220,
25064,
13,
19282,
448,
13,
13564,
7203,
44154,
2493,
25,
4064,
81,
59,
77,
1,
4064,
350,
9863,
8,
198,
220,
220,
220,
25064,
13,
853,
85,
58,
16,
47715,
796,
685,
29001,
85,
20520,
198,
220,
220,
220,
1303,
1649,
428,
8265,
318,
10945,
422,
262,
3141,
12,
1370,
11,
340,
4539,
477,
663,
5254,
198,
220,
220,
220,
555,
715,
395,
13,
12417,
3419,
198
] | 3.062893 | 636 |
from django.shortcuts import render
from django.shortcuts import redirect
from django.contrib.auth.decorators import login_required
from django.http import JsonResponse
from django.core import serializers
# Create your views here.
from django.http import HttpResponse
from django.template import loader
from django.views.generic import ListView
from models import *
@login_required(login_url="/settings/")
| [
6738,
42625,
14208,
13,
19509,
23779,
1330,
8543,
198,
6738,
42625,
14208,
13,
19509,
23779,
1330,
18941,
198,
6738,
42625,
14208,
13,
3642,
822,
13,
18439,
13,
12501,
273,
2024,
1330,
17594,
62,
35827,
198,
6738,
42625,
14208,
13,
4023,
1330,
449,
1559,
31077,
198,
6738,
42625,
14208,
13,
7295,
1330,
11389,
11341,
198,
2,
13610,
534,
5009,
994,
13,
198,
6738,
42625,
14208,
13,
4023,
1330,
367,
29281,
31077,
198,
6738,
42625,
14208,
13,
28243,
1330,
40213,
198,
6738,
42625,
14208,
13,
33571,
13,
41357,
1330,
7343,
7680,
198,
6738,
4981,
1330,
1635,
198,
198,
31,
38235,
62,
35827,
7,
38235,
62,
6371,
35922,
33692,
14,
4943,
628
] | 3.743119 | 109 |
with open("tinder_api/utils/token.txt", "r") as f:
tinder_token = f.read()
# it is best for you to write in the token to save yourself the file I/O
# especially if you have python byte code off
#tinder_token = ""
headers = {
'app_version': '6.9.4',
'platform': 'ios',
'content-type': 'application/json',
'User-agent': 'Tinder/7.5.3 (iPohone; iOS 10.3.2; Scale/2.00)',
'X-Auth-Token': 'enter_auth_token',
}
host = 'https://api.gotinder.com'
if __name__ == '__main__':
pass
| [
4480,
1280,
7203,
83,
5540,
62,
15042,
14,
26791,
14,
30001,
13,
14116,
1600,
366,
81,
4943,
355,
277,
25,
198,
220,
220,
220,
256,
5540,
62,
30001,
796,
277,
13,
961,
3419,
198,
198,
2,
340,
318,
1266,
329,
345,
284,
3551,
287,
262,
11241,
284,
3613,
3511,
262,
2393,
314,
14,
46,
198,
2,
2592,
611,
345,
423,
21015,
18022,
2438,
572,
198,
2,
83,
5540,
62,
30001,
796,
13538,
198,
198,
50145,
796,
1391,
198,
220,
220,
220,
705,
1324,
62,
9641,
10354,
705,
21,
13,
24,
13,
19,
3256,
198,
220,
220,
220,
705,
24254,
10354,
705,
4267,
3256,
198,
220,
220,
220,
705,
11299,
12,
4906,
10354,
705,
31438,
14,
17752,
3256,
198,
220,
220,
220,
705,
12982,
12,
25781,
10354,
705,
51,
5540,
14,
22,
13,
20,
13,
18,
357,
72,
47,
1219,
505,
26,
8969,
838,
13,
18,
13,
17,
26,
21589,
14,
17,
13,
405,
8,
3256,
198,
220,
220,
220,
705,
55,
12,
30515,
12,
30642,
10354,
705,
9255,
62,
18439,
62,
30001,
3256,
198,
92,
198,
198,
4774,
796,
705,
5450,
1378,
15042,
13,
23442,
5540,
13,
785,
6,
198,
198,
361,
11593,
3672,
834,
6624,
705,
834,
12417,
834,
10354,
198,
220,
220,
220,
1208,
198
] | 2.434783 | 207 |
from ..remote import RemoteModel
from infoblox_netmri.utils.utils import check_api_availability
class IssueListDeviceRemote(RemoteModel):
"""
This table list out the entries of issues in the device.
| ``IssueTimestamp:`` The date and time this issue list device record was collected or calculated.
| ``attribute type:`` datetime
| ``DeviceID:`` The internal NetMRI identifier for the device from which issue list device information was collected.
| ``attribute type:`` number
| ``DataSourceID:`` The internal NetMRI identifier for the collector NetMRI that collected this data record.
| ``attribute type:`` number
| ``Count:`` The total number of issues in the list device captured within NetMRI.
| ``attribute type:`` number
| ``Adds:`` Added a new type of issue in the list device.
| ``attribute type:`` string
| ``Deletes:`` Remove an issue from the list device.
| ``attribute type:`` string
| ``Same:`` Maintain the issues as in the list device.
| ``attribute type:`` string
| ``Suppressed:`` A flag indicating whether this issue is suppressed or not.
| ``attribute type:`` string
| ``FirstSeen:`` The timestamp of when NetMRI first discovered this interface.
| ``attribute type:`` string
| ``Timestamp:`` The date and time this record was collected or calculated.
| ``attribute type:`` datetime
| ``EndTime:`` The date and time the record was last modified in NetMRI.
| ``attribute type:`` datetime
| ``TotalCount:`` The total number of issues occured in each device.
| ``attribute type:`` number
| ``Component:`` The issue component (Devices, Configuration, VLANs, etc.).
| ``attribute type:`` string
| ``SeverityID:`` The issue severity ID (1 = Error, 2 = Warning, 3 = Info). Useful for sorting.
| ``attribute type:`` number
| ``SeverityName:`` The severity name in the issue list device.
| ``attribute type:`` string
| ``Correctness:`` The correctness contribution for this issue.
| ``attribute type:`` string
| ``Stability:`` The stability contribution for this issue.
| ``attribute type:`` string
| ``Status:`` A status of the issues in the device.
| ``attribute type:`` string
"""
properties = ("IssueTimestamp",
"DeviceID",
"DataSourceID",
"Count",
"Adds",
"Deletes",
"Same",
"Suppressed",
"FirstSeen",
"Timestamp",
"EndTime",
"TotalCount",
"Component",
"SeverityID",
"SeverityName",
"Correctness",
"Stability",
"Status",
)
@property
@check_api_availability
def data_source(self):
"""
The collector NetMRI that collected this data record.
``attribute type:`` model
"""
return self.broker.data_source(**{"DeviceID": self.DeviceID})
| [
6738,
11485,
47960,
1330,
21520,
17633,
198,
6738,
1167,
45292,
1140,
62,
3262,
76,
380,
13,
26791,
13,
26791,
1330,
2198,
62,
15042,
62,
47274,
628,
198,
4871,
18232,
8053,
24728,
36510,
7,
36510,
17633,
2599,
198,
220,
220,
220,
37227,
198,
220,
220,
220,
770,
3084,
1351,
503,
262,
12784,
286,
2428,
287,
262,
3335,
13,
628,
198,
220,
220,
220,
930,
220,
7559,
45147,
14967,
27823,
25,
15506,
383,
3128,
290,
640,
428,
2071,
1351,
3335,
1700,
373,
7723,
393,
10488,
13,
198,
220,
220,
220,
930,
220,
7559,
42348,
2099,
25,
15506,
4818,
8079,
628,
220,
220,
220,
930,
220,
7559,
24728,
2389,
25,
15506,
383,
5387,
3433,
40952,
27421,
329,
262,
3335,
422,
543,
2071,
1351,
3335,
1321,
373,
7723,
13,
198,
220,
220,
220,
930,
220,
7559,
42348,
2099,
25,
15506,
1271,
628,
220,
220,
220,
930,
220,
7559,
6601,
7416,
2389,
25,
15506,
383,
5387,
3433,
40952,
27421,
329,
262,
22967,
3433,
40952,
326,
7723,
428,
1366,
1700,
13,
198,
220,
220,
220,
930,
220,
7559,
42348,
2099,
25,
15506,
1271,
628,
198,
220,
220,
220,
930,
220,
7559,
12332,
25,
15506,
383,
2472,
1271,
286,
2428,
287,
262,
1351,
3335,
7907,
1626,
3433,
40952,
13,
198,
220,
220,
220,
930,
220,
7559,
42348,
2099,
25,
15506,
1271,
628,
220,
220,
220,
930,
220,
7559,
46245,
25,
15506,
10687,
257,
649,
2099,
286,
2071,
287,
262,
1351,
3335,
13,
198,
220,
220,
220,
930,
220,
7559,
42348,
2099,
25,
15506,
4731,
628,
220,
220,
220,
930,
220,
7559,
5005,
40676,
25,
15506,
17220,
281,
2071,
422,
262,
1351,
3335,
13,
198,
220,
220,
220,
930,
220,
7559,
42348,
2099,
25,
15506,
4731,
628,
220,
220,
220,
930,
220,
7559,
30556,
25,
15506,
337,
32725,
262,
2428,
355,
287,
262,
1351,
3335,
13,
198,
220,
220,
220,
930,
220,
7559,
42348,
2099,
25,
15506,
4731,
628,
220,
220,
220,
930,
220,
7559,
15979,
2790,
25,
15506,
220,
317,
6056,
12739,
1771,
428,
2071,
318,
25822,
393,
407,
13,
198,
220,
220,
220,
930,
220,
7559,
42348,
2099,
25,
15506,
4731,
628,
220,
220,
220,
930,
220,
7559,
5962,
4653,
268,
25,
15506,
383,
41033,
286,
618,
3433,
40952,
717,
5071,
428,
7071,
13,
198,
220,
220,
220,
930,
220,
7559,
42348,
2099,
25,
15506,
4731,
628,
220,
220,
220,
930,
220,
7559,
14967,
27823,
25,
15506,
383,
3128,
290,
640,
428,
1700,
373,
7723,
393,
10488,
13,
198,
220,
220,
220,
930,
220,
7559,
42348,
2099,
25,
15506,
4818,
8079,
628,
220,
220,
220,
930,
220,
7559,
12915,
7575,
25,
15506,
383,
3128,
290,
640,
262,
1700,
373,
938,
9518,
287,
3433,
40952,
13,
198,
220,
220,
220,
930,
220,
7559,
42348,
2099,
25,
15506,
4818,
8079,
628,
220,
220,
220,
930,
220,
7559,
14957,
12332,
25,
15506,
383,
2472,
1271,
286,
2428,
1609,
1522,
287,
1123,
3335,
13,
198,
220,
220,
220,
930,
220,
7559,
42348,
2099,
25,
15506,
1271,
628,
220,
220,
220,
930,
220,
7559,
21950,
25,
15506,
383,
2071,
7515,
357,
13603,
1063,
11,
28373,
11,
569,
25697,
82,
11,
3503,
15729,
198,
220,
220,
220,
930,
220,
7559,
42348,
2099,
25,
15506,
4731,
628,
220,
220,
220,
930,
220,
7559,
50,
964,
414,
2389,
25,
15506,
383,
2071,
19440,
4522,
357,
16,
796,
13047,
11,
362,
796,
15932,
11,
513,
796,
14151,
737,
49511,
329,
29407,
13,
198,
220,
220,
220,
930,
220,
7559,
42348,
2099,
25,
15506,
1271,
628,
220,
220,
220,
930,
220,
7559,
50,
964,
414,
5376,
25,
15506,
383,
19440,
1438,
287,
262,
2071,
1351,
3335,
13,
198,
220,
220,
220,
930,
220,
7559,
42348,
2099,
25,
15506,
4731,
628,
220,
220,
220,
930,
220,
7559,
42779,
1108,
25,
15506,
383,
29409,
10156,
329,
428,
2071,
13,
198,
220,
220,
220,
930,
220,
7559,
42348,
2099,
25,
15506,
4731,
628,
220,
220,
220,
930,
220,
7559,
1273,
1799,
25,
15506,
383,
10159,
10156,
329,
428,
2071,
13,
198,
220,
220,
220,
930,
220,
7559,
42348,
2099,
25,
15506,
4731,
628,
220,
220,
220,
930,
220,
7559,
19580,
25,
15506,
317,
3722,
286,
262,
2428,
287,
262,
3335,
13,
198,
220,
220,
220,
930,
220,
7559,
42348,
2099,
25,
15506,
4731,
628,
220,
220,
220,
37227,
628,
220,
220,
220,
6608,
796,
5855,
45147,
14967,
27823,
1600,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
24728,
2389,
1600,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
6601,
7416,
2389,
1600,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
12332,
1600,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
46245,
1600,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
5005,
40676,
1600,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
30556,
1600,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
15979,
2790,
1600,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
5962,
4653,
268,
1600,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
14967,
27823,
1600,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
12915,
7575,
1600,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
14957,
12332,
1600,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
21950,
1600,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
50,
964,
414,
2389,
1600,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
50,
964,
414,
5376,
1600,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
42779,
1108,
1600,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
1273,
1799,
1600,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
19580,
1600,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1267,
628,
220,
220,
220,
2488,
26745,
198,
220,
220,
220,
2488,
9122,
62,
15042,
62,
47274,
198,
220,
220,
220,
825,
1366,
62,
10459,
7,
944,
2599,
198,
220,
220,
220,
220,
220,
220,
220,
37227,
198,
220,
220,
220,
220,
220,
220,
220,
383,
22967,
3433,
40952,
326,
7723,
428,
1366,
1700,
13,
198,
220,
220,
220,
220,
220,
220,
220,
7559,
42348,
2099,
25,
15506,
2746,
198,
220,
220,
220,
220,
220,
220,
220,
37227,
198,
220,
220,
220,
220,
220,
220,
220,
1441,
2116,
13,
7957,
6122,
13,
7890,
62,
10459,
7,
1174,
4895,
24728,
2389,
1298,
2116,
13,
24728,
2389,
30072,
198
] | 2.595868 | 1,210 |
"""
"""
from revibe.exceptions import RevibeException
# -----------------------------------------------------------------------------
| [
37811,
198,
37811,
198,
198,
6738,
2710,
32438,
13,
1069,
11755,
1330,
5416,
32438,
16922,
198,
198,
2,
16529,
32501,
198
] | 6.47619 | 21 |
"""
Automatically shutdown windows after a user defined time period
"""
import subprocess
from time import sleep
print("")
print("Auto Shutdown Windows")
print("=====================")
print("")
seconds = float(raw_input("Specify time in minutes: ")) * 60.0
print("")
print(">>> Computer will force shutdown automatically in %s minutes") %(seconds/60.0)
sleep(seconds)
subprocess.call(["shutdown", "/s", "/f"])
| [
37811,
198,
38062,
4142,
18325,
9168,
706,
257,
2836,
5447,
640,
2278,
198,
37811,
198,
198,
11748,
850,
14681,
198,
6738,
640,
1330,
3993,
198,
198,
4798,
7203,
4943,
198,
4798,
7203,
27722,
40411,
3964,
4943,
198,
4798,
7203,
4770,
1421,
2625,
8,
198,
4798,
7203,
4943,
198,
43012,
796,
12178,
7,
1831,
62,
15414,
7203,
22882,
1958,
640,
287,
2431,
25,
366,
4008,
1635,
3126,
13,
15,
198,
4798,
7203,
4943,
198,
4798,
7203,
33409,
13851,
481,
2700,
18325,
6338,
287,
4064,
82,
2431,
4943,
4064,
7,
43012,
14,
1899,
13,
15,
8,
198,
42832,
7,
43012,
8,
198,
7266,
14681,
13,
13345,
7,
14692,
49625,
2902,
1600,
12813,
82,
1600,
12813,
69,
8973,
8,
198
] | 3.529915 | 117 |
"""
744. Find Smallest Letter Greater Than Target
Input:
letters = ["c", "f", "j"]
target = "a"
Output: "c"
Input:
letters = ["c", "f", "j"]
target = "c"
Output: "f"
Input:
letters = ["c", "f", "j"]
target = "d"
Output: "f"
Input:
letters = ["c", "f", "j"]
target = "g"
Output: "j"
Input:
letters = ["c", "f", "j"]
target = "j"
Output: "c"
Input:
letters = ["c", "f", "j"]
target = "k"
Output: "c"
"""
| [
37811,
201,
198,
22,
2598,
13,
9938,
10452,
395,
18121,
18169,
17924,
12744,
201,
198,
201,
198,
20560,
25,
201,
198,
15653,
796,
14631,
66,
1600,
366,
69,
1600,
366,
73,
8973,
201,
198,
16793,
796,
366,
64,
1,
201,
198,
26410,
25,
366,
66,
1,
201,
198,
201,
198,
20560,
25,
201,
198,
15653,
796,
14631,
66,
1600,
366,
69,
1600,
366,
73,
8973,
201,
198,
16793,
796,
366,
66,
1,
201,
198,
26410,
25,
366,
69,
1,
201,
198,
201,
198,
20560,
25,
201,
198,
15653,
796,
14631,
66,
1600,
366,
69,
1600,
366,
73,
8973,
201,
198,
16793,
796,
366,
67,
1,
201,
198,
26410,
25,
366,
69,
1,
201,
198,
201,
198,
20560,
25,
201,
198,
15653,
796,
14631,
66,
1600,
366,
69,
1600,
366,
73,
8973,
201,
198,
16793,
796,
366,
70,
1,
201,
198,
26410,
25,
366,
73,
1,
201,
198,
201,
198,
20560,
25,
201,
198,
15653,
796,
14631,
66,
1600,
366,
69,
1600,
366,
73,
8973,
201,
198,
16793,
796,
366,
73,
1,
201,
198,
26410,
25,
366,
66,
1,
201,
198,
201,
198,
20560,
25,
201,
198,
15653,
796,
14631,
66,
1600,
366,
69,
1600,
366,
73,
8973,
201,
198,
16793,
796,
366,
74,
1,
201,
198,
26410,
25,
366,
66,
1,
201,
198,
201,
198,
37811,
201
] | 2.036866 | 217 |
# -*- coding: utf-8 -*-
import nuke
import edgeNode
SantoshMenu.addCommand("edgeNode/Jump to First", "edgeNode.jump_to_edge_node('top')")
SantoshMenu.addCommand("edgeNode/Jump to Last", "edgeNode.jump_to_edge_node('bottom')")
SantoshMenu.addCommand("edgeNode/View First", "edgeNode.view_edge_node('top')")
SantoshMenu.addCommand("edgeNode/View Last", "edgeNode.view_edge_node('bottom')") | [
2,
532,
9,
12,
19617,
25,
3384,
69,
12,
23,
532,
9,
12,
198,
11748,
299,
4649,
198,
11748,
5743,
19667,
198,
198,
50,
415,
3768,
23381,
13,
2860,
21575,
7203,
14907,
19667,
14,
36046,
284,
3274,
1600,
366,
14907,
19667,
13,
43327,
62,
1462,
62,
14907,
62,
17440,
10786,
4852,
11537,
4943,
198,
50,
415,
3768,
23381,
13,
2860,
21575,
7203,
14907,
19667,
14,
36046,
284,
4586,
1600,
366,
14907,
19667,
13,
43327,
62,
1462,
62,
14907,
62,
17440,
10786,
22487,
11537,
4943,
198,
50,
415,
3768,
23381,
13,
2860,
21575,
7203,
14907,
19667,
14,
7680,
3274,
1600,
366,
14907,
19667,
13,
1177,
62,
14907,
62,
17440,
10786,
4852,
11537,
4943,
198,
50,
415,
3768,
23381,
13,
2860,
21575,
7203,
14907,
19667,
14,
7680,
4586,
1600,
366,
14907,
19667,
13,
1177,
62,
14907,
62,
17440,
10786,
22487,
11537,
4943
] | 2.771429 | 140 |
#Python 3
#Usage: python3 UDPClient3.py localhost 12000
#coding: utf-8
from socket import *
import sys
# The argument of client
servername = sys.argv[1]
serverPort = sys.argv[2]
udpPort = sys.argv[3]
serverPort = int(serverPort)
clientSocket = socket(AF_INET, SOCK_STREAM)
clientSocket.connect((servername, serverPort))
ifloged = authenticate()
while ifloged:
print("Welcome to TOOM!")
allcommand = input("Enter one of the following commands (MSG, DLT, EDT, RDM, ATU, OUT, UPD):")
command = allcommand[0:3]
if command == 'MSG':
if allcommand == 'MSG':
print("Error! Need message after MSG command\n")
else:
clientSocket.sendall('MSG'.encode('utf-8'))
msg(allcommand[4::])
elif command == 'DLT':
# We need to check the usage of DLT
if allcommand == 'DLT':
print("Error! Need seq number and timestamp after DLT command\n")
else:
clientSocket.sendall('DLT'.encode('utf-8'))
info = allcommand[4::]
lists = info.split()
if len(lists) <= 2:
print("Error! Need seq number and timestamp after DLT command\n")
else:
clientSocket.sendall(info.encode('utf-8'))
recev = clientSocket.recv(2048).decode('utf-8')
dlt(recev)
elif command == 'EDT':
if allcommand == 'EDT':
print("Error! Need seq number, timestamp, and modified message after EDT command\n")
else:
clientSocket.sendall('EDT'.encode('utf-8'))
info = allcommand[4::]
lists = info.split()
if len(lists) <= 2:
print("Error! Need seq number, timestamp, and modified message after EDT command\n")
else:
clientSocket.sendall(info.encode('utf-8'))
recev = clientSocket.recv(2048).decode('utf-8')
edt(recev)
elif command == 'RDM':
if allcommand == 'RDM':
print("Error! Need timestamp after EDT command\n")
else:
clientSocket.sendall('RDM'.encode('utf-8'))
info = allcommand[4::]
clientSocket.sendall(info.encode('utf-8'))
recev = clientSocket.recv(2048).decode('utf-8')
print(recev)
elif command == 'ATU':
if allcommand == command:
clientSocket.sendall('ATU'.encode('utf-8'))
print('The active user list returned: \n')
info = clientSocket.recv(2048).decode('utf-8')
print(info)
else:
print("Error! ATU command does not take any argument.\n")
elif command == 'UPD':
pass
elif command == 'OUT':
if allcommand == command:
clientSocket.sendall('OUT'.encode('utf-8'))
info = clientSocket.recv(2048).encode('utf-8')
print("Thank you for using. You have logged out.\n")
break
else:
print("Error! OUT command does not take any argument.\n")
else:
print("This command is invalid. Please try again with either one of MSG, DLT, EDT, RDM, ATU, OUT and UPD\n")
clientSocket.close() | [
2,
37906,
513,
201,
198,
2,
28350,
25,
21015,
18,
36428,
11792,
18,
13,
9078,
1957,
4774,
1105,
830,
201,
198,
2,
66,
7656,
25,
3384,
69,
12,
23,
201,
198,
6738,
17802,
1330,
1635,
201,
198,
11748,
25064,
201,
198,
201,
198,
2,
383,
4578,
286,
5456,
201,
198,
2655,
933,
480,
796,
25064,
13,
853,
85,
58,
16,
60,
201,
198,
15388,
13924,
796,
25064,
13,
853,
85,
58,
17,
60,
201,
198,
463,
79,
13924,
796,
25064,
13,
853,
85,
58,
18,
60,
201,
198,
15388,
13924,
796,
493,
7,
15388,
13924,
8,
201,
198,
201,
198,
16366,
39105,
796,
17802,
7,
8579,
62,
1268,
2767,
11,
311,
11290,
62,
2257,
32235,
8,
201,
198,
16366,
39105,
13,
8443,
19510,
2655,
933,
480,
11,
4382,
13924,
4008,
201,
198,
201,
198,
361,
6404,
276,
796,
8323,
5344,
3419,
201,
198,
4514,
611,
6404,
276,
25,
201,
198,
220,
220,
220,
3601,
7203,
14618,
284,
5390,
2662,
2474,
8,
201,
198,
220,
220,
220,
477,
21812,
796,
5128,
7203,
17469,
530,
286,
262,
1708,
9729,
357,
5653,
38,
11,
23641,
51,
11,
15693,
11,
371,
23127,
11,
5161,
52,
11,
16289,
11,
471,
5760,
2599,
4943,
201,
198,
220,
220,
220,
3141,
796,
477,
21812,
58,
15,
25,
18,
60,
201,
198,
220,
220,
220,
611,
3141,
6624,
705,
5653,
38,
10354,
201,
198,
220,
220,
220,
220,
220,
220,
220,
611,
477,
21812,
6624,
705,
5653,
38,
10354,
201,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
3601,
7203,
12331,
0,
10664,
3275,
706,
49064,
3141,
59,
77,
4943,
201,
198,
220,
220,
220,
220,
220,
220,
220,
2073,
25,
201,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
5456,
39105,
13,
21280,
439,
10786,
5653,
38,
4458,
268,
8189,
10786,
40477,
12,
23,
6,
4008,
201,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
31456,
7,
439,
21812,
58,
19,
3712,
12962,
201,
198,
220,
220,
220,
1288,
361,
3141,
6624,
705,
19260,
51,
10354,
201,
198,
220,
220,
220,
220,
220,
220,
220,
1303,
775,
761,
284,
2198,
262,
8748,
286,
23641,
51,
201,
198,
220,
220,
220,
220,
220,
220,
220,
611,
477,
21812,
6624,
705,
19260,
51,
10354,
201,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
3601,
7203,
12331,
0,
10664,
33756,
1271,
290,
41033,
706,
23641,
51,
3141,
59,
77,
4943,
201,
198,
220,
220,
220,
220,
220,
220,
220,
2073,
25,
201,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
5456,
39105,
13,
21280,
439,
10786,
19260,
51,
4458,
268,
8189,
10786,
40477,
12,
23,
6,
4008,
201,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
7508,
796,
477,
21812,
58,
19,
3712,
60,
201,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
8341,
796,
7508,
13,
35312,
3419,
201,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
611,
18896,
7,
20713,
8,
19841,
362,
25,
201,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
3601,
7203,
12331,
0,
10664,
33756,
1271,
290,
41033,
706,
23641,
51,
3141,
59,
77,
4943,
201,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2073,
25,
201,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
5456,
39105,
13,
21280,
439,
7,
10951,
13,
268,
8189,
10786,
40477,
12,
23,
6,
4008,
201,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1407,
85,
796,
5456,
39105,
13,
8344,
85,
7,
1238,
2780,
737,
12501,
1098,
10786,
40477,
12,
23,
11537,
201,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
288,
2528,
7,
260,
344,
85,
8,
201,
198,
201,
198,
220,
220,
220,
1288,
361,
3141,
6624,
705,
1961,
51,
10354,
201,
198,
220,
220,
220,
220,
220,
220,
220,
611,
477,
21812,
6624,
705,
1961,
51,
10354,
201,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
3601,
7203,
12331,
0,
10664,
33756,
1271,
11,
41033,
11,
290,
9518,
3275,
706,
15693,
3141,
59,
77,
4943,
201,
198,
220,
220,
220,
220,
220,
220,
220,
2073,
25,
201,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
5456,
39105,
13,
21280,
439,
10786,
1961,
51,
4458,
268,
8189,
10786,
40477,
12,
23,
6,
4008,
201,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
7508,
796,
477,
21812,
58,
19,
3712,
60,
201,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
8341,
796,
7508,
13,
35312,
3419,
201,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
611,
18896,
7,
20713,
8,
19841,
362,
25,
201,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
3601,
7203,
12331,
0,
10664,
33756,
1271,
11,
41033,
11,
290,
9518,
3275,
706,
15693,
3141,
59,
77,
4943,
201,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2073,
25,
201,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
5456,
39105,
13,
21280,
439,
7,
10951,
13,
268,
8189,
10786,
40477,
12,
23,
6,
4008,
201,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1407,
85,
796,
5456,
39105,
13,
8344,
85,
7,
1238,
2780,
737,
12501,
1098,
10786,
40477,
12,
23,
11537,
201,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1225,
83,
7,
260,
344,
85,
8,
201,
198,
220,
220,
220,
1288,
361,
3141,
6624,
705,
49,
23127,
10354,
201,
198,
220,
220,
220,
220,
220,
220,
220,
611,
477,
21812,
6624,
705,
49,
23127,
10354,
201,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
3601,
7203,
12331,
0,
10664,
41033,
706,
15693,
3141,
59,
77,
4943,
201,
198,
220,
220,
220,
220,
220,
220,
220,
2073,
25,
201,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
5456,
39105,
13,
21280,
439,
10786,
49,
23127,
4458,
268,
8189,
10786,
40477,
12,
23,
6,
4008,
201,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
7508,
796,
477,
21812,
58,
19,
3712,
60,
201,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
5456,
39105,
13,
21280,
439,
7,
10951,
13,
268,
8189,
10786,
40477,
12,
23,
6,
4008,
201,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1407,
85,
796,
5456,
39105,
13,
8344,
85,
7,
1238,
2780,
737,
12501,
1098,
10786,
40477,
12,
23,
11537,
201,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
3601,
7,
260,
344,
85,
8,
201,
198,
220,
220,
220,
1288,
361,
3141,
6624,
705,
1404,
52,
10354,
201,
198,
220,
220,
220,
220,
220,
220,
220,
611,
477,
21812,
6624,
3141,
25,
201,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
5456,
39105,
13,
21280,
439,
10786,
1404,
52,
4458,
268,
8189,
10786,
40477,
12,
23,
6,
4008,
201,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
3601,
10786,
464,
4075,
2836,
1351,
4504,
25,
3467,
77,
11537,
201,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
7508,
796,
5456,
39105,
13,
8344,
85,
7,
1238,
2780,
737,
12501,
1098,
10786,
40477,
12,
23,
11537,
201,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
3601,
7,
10951,
8,
201,
198,
220,
220,
220,
220,
220,
220,
220,
2073,
25,
201,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
3601,
7203,
12331,
0,
5161,
52,
3141,
857,
407,
1011,
597,
4578,
13,
59,
77,
4943,
201,
198,
220,
220,
220,
1288,
361,
3141,
6624,
705,
52,
5760,
10354,
201,
198,
220,
220,
220,
220,
220,
220,
220,
1208,
201,
198,
220,
220,
220,
1288,
361,
3141,
6624,
705,
12425,
10354,
201,
198,
220,
220,
220,
220,
220,
220,
220,
611,
477,
21812,
6624,
3141,
25,
201,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
5456,
39105,
13,
21280,
439,
10786,
12425,
4458,
268,
8189,
10786,
40477,
12,
23,
6,
4008,
201,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
7508,
796,
5456,
39105,
13,
8344,
85,
7,
1238,
2780,
737,
268,
8189,
10786,
40477,
12,
23,
11537,
201,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
3601,
7203,
10449,
345,
329,
1262,
13,
921,
423,
18832,
503,
13,
59,
77,
4943,
201,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2270,
201,
198,
220,
220,
220,
220,
220,
220,
220,
2073,
25,
201,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
3601,
7203,
12331,
0,
16289,
3141,
857,
407,
1011,
597,
4578,
13,
59,
77,
4943,
201,
198,
201,
198,
201,
198,
220,
220,
220,
2073,
25,
201,
198,
220,
220,
220,
220,
220,
220,
220,
3601,
7203,
1212,
3141,
318,
12515,
13,
4222,
1949,
757,
351,
2035,
530,
286,
49064,
11,
23641,
51,
11,
15693,
11,
371,
23127,
11,
5161,
52,
11,
16289,
290,
471,
5760,
59,
77,
4943,
201,
198,
201,
198,
201,
198,
201,
198,
16366,
39105,
13,
19836,
3419
] | 2.063763 | 1,584 |
from django.utils.translation import ugettext_lazy as _
import horizon
horizon.register(Techbk_Head)
| [
6738,
42625,
14208,
13,
26791,
13,
41519,
1330,
334,
1136,
5239,
62,
75,
12582,
355,
4808,
198,
198,
11748,
17810,
628,
198,
198,
17899,
8637,
13,
30238,
7,
17760,
65,
74,
62,
13847,
8,
198
] | 3 | 35 |
from django import forms
from django.utils.encoding import force_text
from orchestra.admin.utils import admin_link
from orchestra.forms.widgets import SpanWidget
| [
6738,
42625,
14208,
1330,
5107,
198,
6738,
42625,
14208,
13,
26791,
13,
12685,
7656,
1330,
2700,
62,
5239,
198,
198,
6738,
40095,
13,
28482,
13,
26791,
1330,
13169,
62,
8726,
198,
6738,
40095,
13,
23914,
13,
28029,
11407,
1330,
49101,
38300,
628,
628
] | 3.860465 | 43 |
import os
import argparse
import time
import torch.nn.functional as F
import torch.nn.parallel
import torch.optim
from sklearn.metrics import confusion_matrix, accuracy_score
import seaborn as sns
import matplotlib.pyplot as plt
import pandas as pd
from dataset import TBNDataSet
from DA_model import TBN
from transforms import *
import pickle
import save_csv as sc
#label 正解ラベル
if __name__ == '__main__':
main()
| [
11748,
28686,
198,
11748,
1822,
29572,
198,
11748,
640,
198,
198,
11748,
28034,
13,
20471,
13,
45124,
355,
376,
198,
11748,
28034,
13,
20471,
13,
1845,
29363,
198,
11748,
28034,
13,
40085,
198,
6738,
1341,
35720,
13,
4164,
10466,
1330,
10802,
62,
6759,
8609,
11,
9922,
62,
26675,
198,
11748,
384,
397,
1211,
355,
3013,
82,
198,
11748,
2603,
29487,
8019,
13,
9078,
29487,
355,
458,
83,
198,
11748,
19798,
292,
355,
279,
67,
198,
198,
6738,
27039,
1330,
309,
15766,
6601,
7248,
198,
6738,
17051,
62,
19849,
1330,
309,
15766,
198,
6738,
31408,
1330,
1635,
198,
11748,
2298,
293,
198,
11748,
3613,
62,
40664,
355,
629,
628,
198,
198,
2,
18242,
10545,
255,
96,
164,
100,
96,
9263,
35604,
9202,
628,
198,
198,
361,
11593,
3672,
834,
6624,
705,
834,
12417,
834,
10354,
198,
220,
220,
220,
1388,
3419,
198
] | 3.014184 | 141 |
import pytest
import napari_morphodynamics
import napari_morphodynamics.napari_gui
from morphodynamics.data import synth
import numpy as np
import h5py
import napari_morphodynamics
@pytest.fixture(scope="session")
def dataset(tmp_path_factory):
"""Create a dataset for testing."""
new_path = tmp_path_factory.mktemp("dataset")
im, sigs = synth.generate_dataset(height=100, width=100, steps=40, step_reverse=20,
displacement=0.5, radius=10, shifts=[3,7])
for ind, s in enumerate([im]+sigs):
h5_name = new_path.joinpath(f'synth_ch{ind+1}.h5')
with h5py.File(h5_name, "w") as f_out:
dset = f_out.create_dataset("volume", data=s, chunks=True, compression="gzip", compression_opts=1)
return new_path
@pytest.fixture
def test_data_exist(dataset):
"""Test that the data exists."""
assert dataset.joinpath("synth_ch1.h5").is_file()
assert dataset.joinpath("synth_ch2.h5").is_file()
assert dataset.joinpath("synth_ch3.h5").is_file()
def test_set_dataset(mywidget, dataset):
"""Test that the dataset is updated."""
mywidget.file_list.update_from_path(dataset)
channels = [mywidget.segm_channel.item(i).text() for i in range(mywidget.segm_channel.count())]
for i in range(3):
assert f'synth_ch{i+1}.h5' in channels
assert mywidget.param.data_folder == dataset | [
11748,
12972,
9288,
198,
11748,
25422,
2743,
62,
24503,
44124,
198,
11748,
25422,
2743,
62,
24503,
44124,
13,
77,
499,
2743,
62,
48317,
198,
6738,
17488,
44124,
13,
7890,
1330,
33549,
198,
11748,
299,
32152,
355,
45941,
198,
11748,
289,
20,
9078,
198,
198,
11748,
25422,
2743,
62,
24503,
44124,
198,
198,
31,
9078,
9288,
13,
69,
9602,
7,
29982,
2625,
29891,
4943,
198,
4299,
27039,
7,
22065,
62,
6978,
62,
69,
9548,
2599,
198,
220,
220,
220,
37227,
16447,
257,
27039,
329,
4856,
526,
15931,
628,
220,
220,
220,
649,
62,
6978,
796,
45218,
62,
6978,
62,
69,
9548,
13,
28015,
29510,
7203,
19608,
292,
316,
4943,
198,
220,
220,
220,
545,
11,
264,
9235,
796,
33549,
13,
8612,
378,
62,
19608,
292,
316,
7,
17015,
28,
3064,
11,
9647,
28,
3064,
11,
4831,
28,
1821,
11,
2239,
62,
50188,
28,
1238,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
29358,
28,
15,
13,
20,
11,
16874,
28,
940,
11,
15381,
41888,
18,
11,
22,
12962,
628,
220,
220,
220,
329,
773,
11,
264,
287,
27056,
378,
26933,
320,
48688,
82,
9235,
2599,
198,
220,
220,
220,
220,
220,
220,
220,
289,
20,
62,
3672,
796,
649,
62,
6978,
13,
22179,
6978,
7,
69,
338,
2047,
400,
62,
354,
90,
521,
10,
16,
27422,
71,
20,
11537,
198,
220,
220,
220,
220,
220,
220,
220,
351,
289,
20,
9078,
13,
8979,
7,
71,
20,
62,
3672,
11,
366,
86,
4943,
355,
277,
62,
448,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
288,
2617,
796,
277,
62,
448,
13,
17953,
62,
19608,
292,
316,
7203,
29048,
1600,
1366,
28,
82,
11,
22716,
28,
17821,
11,
19794,
2625,
70,
13344,
1600,
19794,
62,
404,
912,
28,
16,
8,
628,
220,
220,
220,
1441,
649,
62,
6978,
198,
198,
31,
9078,
9288,
13,
69,
9602,
198,
198,
4299,
1332,
62,
7890,
62,
38476,
7,
19608,
292,
316,
2599,
198,
220,
220,
220,
37227,
14402,
326,
262,
1366,
7160,
526,
15931,
198,
220,
220,
220,
6818,
27039,
13,
22179,
6978,
7203,
28869,
400,
62,
354,
16,
13,
71,
20,
11074,
271,
62,
7753,
3419,
198,
220,
220,
220,
6818,
27039,
13,
22179,
6978,
7203,
28869,
400,
62,
354,
17,
13,
71,
20,
11074,
271,
62,
7753,
3419,
198,
220,
220,
220,
6818,
27039,
13,
22179,
6978,
7203,
28869,
400,
62,
354,
18,
13,
71,
20,
11074,
271,
62,
7753,
3419,
198,
198,
4299,
1332,
62,
2617,
62,
19608,
292,
316,
7,
1820,
42655,
11,
27039,
2599,
198,
220,
220,
220,
37227,
14402,
326,
262,
27039,
318,
6153,
526,
15931,
628,
220,
220,
220,
616,
42655,
13,
7753,
62,
4868,
13,
19119,
62,
6738,
62,
6978,
7,
19608,
292,
316,
8,
198,
220,
220,
220,
9619,
796,
685,
1820,
42655,
13,
325,
39870,
62,
17620,
13,
9186,
7,
72,
737,
5239,
3419,
329,
1312,
287,
2837,
7,
1820,
42655,
13,
325,
39870,
62,
17620,
13,
9127,
3419,
15437,
198,
220,
220,
220,
329,
1312,
287,
2837,
7,
18,
2599,
198,
220,
220,
220,
220,
220,
220,
220,
6818,
277,
338,
2047,
400,
62,
354,
90,
72,
10,
16,
27422,
71,
20,
6,
287,
9619,
628,
220,
220,
220,
6818,
616,
42655,
13,
17143,
13,
7890,
62,
43551,
6624,
27039
] | 2.43662 | 568 |
import numpy as np
from enthought.mayavi import mlab
import Image
if __name__ == '__main__':
import dipy.core.qball as qball
from dipy.io.bvectxt import read_bvec_file
filename='/Users/bagrata/HARDI/E1322S8I1.nii.gz'
grad_table_filename='/Users/bagrata/HARDI/E1322S8I1.bvec'
from nipy import load_image, save_image
grad_table, b_values = read_bvec_file(grad_table_filename)
img = load_image(filename)
print 'input dimensions: '
print img.ndim
print 'image size: '
print img.shape
print 'image affine: '
print img.affine
print 'images has pixels with size: '
print np.dot(img.affine, np.eye(img.ndim+1)).diagonal()[0:3]
data = np.asarray(img)
theta, phi = np.mgrid[0:2*np.pi:64*1j, 0:np.pi:32*1j]
odf_i = qball.ODF(data[188:192,188:192,22:24,:],4,grad_table,b_values)
disp_odf(odf_i[0:1,0:2,0:2])
| [
11748,
299,
32152,
355,
45941,
198,
6738,
920,
71,
2917,
13,
11261,
15820,
1330,
285,
23912,
198,
11748,
7412,
198,
198,
361,
11593,
3672,
834,
6624,
705,
834,
12417,
834,
10354,
198,
220,
220,
220,
1330,
19550,
88,
13,
7295,
13,
80,
1894,
355,
10662,
1894,
198,
220,
220,
220,
422,
19550,
88,
13,
952,
13,
65,
303,
310,
742,
1330,
1100,
62,
65,
35138,
62,
7753,
198,
220,
220,
220,
29472,
11639,
14,
14490,
14,
21454,
81,
1045,
14,
39,
9795,
40,
14,
36,
1485,
1828,
50,
23,
40,
16,
13,
77,
4178,
13,
34586,
6,
198,
220,
220,
220,
3915,
62,
11487,
62,
34345,
11639,
14,
14490,
14,
21454,
81,
1045,
14,
39,
9795,
40,
14,
36,
1485,
1828,
50,
23,
40,
16,
13,
65,
35138,
6,
198,
220,
220,
220,
422,
299,
541,
88,
1330,
3440,
62,
9060,
11,
3613,
62,
9060,
628,
220,
220,
220,
3915,
62,
11487,
11,
275,
62,
27160,
796,
1100,
62,
65,
35138,
62,
7753,
7,
9744,
62,
11487,
62,
34345,
8,
198,
220,
220,
220,
33705,
796,
3440,
62,
9060,
7,
34345,
8,
198,
220,
220,
220,
3601,
705,
15414,
15225,
25,
705,
198,
220,
220,
220,
3601,
33705,
13,
358,
320,
198,
220,
220,
220,
3601,
705,
9060,
2546,
25,
705,
198,
220,
220,
220,
3601,
33705,
13,
43358,
198,
220,
220,
220,
3601,
705,
9060,
1527,
500,
25,
705,
198,
220,
220,
220,
3601,
33705,
13,
2001,
500,
198,
220,
220,
220,
3601,
705,
17566,
468,
17848,
351,
2546,
25,
705,
198,
220,
220,
220,
3601,
45941,
13,
26518,
7,
9600,
13,
2001,
500,
11,
45941,
13,
25379,
7,
9600,
13,
358,
320,
10,
16,
29720,
10989,
27923,
3419,
58,
15,
25,
18,
60,
198,
220,
220,
220,
1366,
796,
45941,
13,
292,
18747,
7,
9600,
8,
628,
220,
220,
220,
262,
8326,
11,
872,
72,
796,
45941,
13,
76,
25928,
58,
15,
25,
17,
9,
37659,
13,
14415,
25,
2414,
9,
16,
73,
11,
657,
25,
37659,
13,
14415,
25,
2624,
9,
16,
73,
60,
198,
220,
220,
220,
267,
7568,
62,
72,
796,
10662,
1894,
13,
3727,
37,
7,
7890,
58,
20356,
25,
17477,
11,
20356,
25,
17477,
11,
1828,
25,
1731,
11,
25,
4357,
19,
11,
9744,
62,
11487,
11,
65,
62,
27160,
8,
198,
220,
220,
220,
4596,
62,
375,
69,
7,
375,
69,
62,
72,
58,
15,
25,
16,
11,
15,
25,
17,
11,
15,
25,
17,
12962,
628
] | 2.162963 | 405 |
import re
reg_ex = re.compile(r"^[a-z][a-z]*[a-z]$")
no_reg_ex = re.compile(r".*[0-9].*")
mc_reg_ex = re.compile(r".*[A-Z].*[A-Z].*")
def containsNumber(text):
"""包含数字."""
return no_reg_ex.match(text)
def containsMultiCapital(text):
"""包含多个大写字母."""
return mc_reg_ex.match(text)
def can_spellcheck(w: str):
"""检查是否需要进行拼写检查."""
# return not ((not reg_ex.match(w)) or containsMultiCapital(w) or containsNumber
if reg_ex.match(w):
return True
else:
return False
| [
11748,
302,
198,
198,
2301,
62,
1069,
796,
302,
13,
5589,
576,
7,
81,
1,
61,
58,
64,
12,
89,
7131,
64,
12,
89,
60,
9,
58,
64,
12,
89,
60,
3,
4943,
198,
3919,
62,
2301,
62,
1069,
796,
302,
13,
5589,
576,
7,
81,
1911,
9,
58,
15,
12,
24,
4083,
9,
4943,
198,
23209,
62,
2301,
62,
1069,
796,
302,
13,
5589,
576,
7,
81,
1911,
9,
58,
32,
12,
57,
4083,
9,
58,
32,
12,
57,
4083,
9,
4943,
628,
198,
4299,
4909,
15057,
7,
5239,
2599,
198,
220,
220,
220,
37227,
44293,
227,
28938,
104,
46763,
108,
27764,
245,
526,
15931,
198,
220,
220,
220,
1441,
645,
62,
2301,
62,
1069,
13,
15699,
7,
5239,
8,
628,
198,
4299,
4909,
29800,
39315,
7,
5239,
2599,
198,
220,
220,
220,
37227,
44293,
227,
28938,
104,
13783,
248,
10310,
103,
32014,
37863,
247,
27764,
245,
162,
107,
235,
526,
15931,
198,
220,
220,
220,
1441,
36650,
62,
2301,
62,
1069,
13,
15699,
7,
5239,
8,
628,
198,
4299,
460,
62,
46143,
9122,
7,
86,
25,
965,
2599,
198,
220,
220,
220,
37227,
162,
96,
222,
162,
253,
98,
42468,
28938,
99,
165,
250,
222,
17358,
223,
32573,
249,
26193,
234,
162,
233,
120,
37863,
247,
162,
96,
222,
162,
253,
98,
526,
15931,
198,
220,
220,
220,
1303,
1441,
407,
14808,
1662,
842,
62,
1069,
13,
15699,
7,
86,
4008,
393,
4909,
29800,
39315,
7,
86,
8,
393,
4909,
15057,
198,
220,
220,
220,
611,
842,
62,
1069,
13,
15699,
7,
86,
2599,
198,
220,
220,
220,
220,
220,
220,
220,
1441,
6407,
198,
220,
220,
220,
2073,
25,
198,
220,
220,
220,
220,
220,
220,
220,
1441,
10352,
198
] | 1.812721 | 283 |
from pandas.core.algorithms import isin
import pytest
from ncmw.utils import get_models
import numpy as np
from pandas import DataFrame
from ncmw.community.community_models import (
BagOfReactionsModel,
ShuttleCommunityModel,
create_stoichiometry_matrix,
)
MODELS = get_models("models")
COMMUNITY_MODELS = [BagOfReactionsModel, ShuttleCommunityModel]
@pytest.mark.slow
@pytest.mark.parametrize("community", COMMUNITY_MODELS)
@pytest.mark.parametrize("model", MODELS)
| [
6738,
19798,
292,
13,
7295,
13,
282,
7727,
907,
1330,
318,
259,
201,
198,
11748,
12972,
9288,
201,
198,
201,
198,
201,
198,
6738,
299,
11215,
86,
13,
26791,
1330,
651,
62,
27530,
201,
198,
11748,
299,
32152,
355,
45941,
201,
198,
6738,
19798,
292,
1330,
6060,
19778,
201,
198,
201,
198,
6738,
299,
11215,
86,
13,
28158,
13,
28158,
62,
27530,
1330,
357,
201,
198,
220,
220,
220,
20127,
5189,
3041,
4658,
17633,
11,
201,
198,
220,
220,
220,
35143,
20012,
17633,
11,
201,
198,
220,
220,
220,
2251,
62,
301,
78,
16590,
15748,
62,
6759,
8609,
11,
201,
198,
8,
201,
198,
201,
198,
33365,
37142,
796,
651,
62,
27530,
7203,
27530,
4943,
201,
198,
9858,
44,
4944,
9050,
62,
33365,
37142,
796,
685,
33,
363,
5189,
3041,
4658,
17633,
11,
35143,
20012,
17633,
60,
201,
198,
201,
198,
201,
198,
31,
9078,
9288,
13,
4102,
13,
38246,
201,
198,
31,
9078,
9288,
13,
4102,
13,
17143,
316,
380,
2736,
7203,
28158,
1600,
48811,
9050,
62,
33365,
37142,
8,
201,
198,
201,
198,
201,
198,
31,
9078,
9288,
13,
4102,
13,
17143,
316,
380,
2736,
7203,
19849,
1600,
19164,
37142,
8,
201,
198
] | 2.615385 | 195 |
# -*- coding: utf-8 -*-
"""
Automatically detect rotation and line spacing of an image of text using
Radon transform
If image is rotated by the inverse of the output, the lines will be
horizontal (though they may be upside-down depending on the original image)
It doesn't work with black borders
Courtesy: https://gist.github.com/endolith/334196bac1cac45a4893#
"""
from __future__ import division, print_function
import warnings
warnings.filterwarnings("ignore")
import sys
from PIL import Image
from skimage.transform import radon
from numpy import asarray, mean, array, sqrt, mean
try:
# More accurate peak finding from
# https://gist.github.com/endolith/255291#file-parabolic-py
from parabolic import parabolic
except ImportError:
from numpy import argmax
if __name__ == "__main__":
main() | [
2,
532,
9,
12,
19617,
25,
3384,
69,
12,
23,
532,
9,
12,
198,
37811,
198,
38062,
4142,
4886,
13179,
290,
1627,
31050,
286,
281,
2939,
286,
2420,
1262,
198,
15546,
261,
6121,
198,
1532,
2939,
318,
38375,
416,
262,
34062,
286,
262,
5072,
11,
262,
3951,
481,
307,
198,
17899,
38342,
357,
2016,
484,
743,
307,
17196,
12,
2902,
6906,
319,
262,
2656,
2939,
8,
198,
1026,
1595,
470,
670,
351,
2042,
11637,
198,
198,
31825,
25,
3740,
1378,
70,
396,
13,
12567,
13,
785,
14,
437,
21446,
14,
31380,
25272,
65,
330,
16,
66,
330,
2231,
64,
2780,
6052,
2,
198,
37811,
198,
198,
6738,
11593,
37443,
834,
1330,
7297,
11,
3601,
62,
8818,
198,
11748,
14601,
198,
40539,
654,
13,
24455,
40539,
654,
7203,
46430,
4943,
198,
11748,
25064,
198,
6738,
350,
4146,
1330,
7412,
198,
6738,
1341,
9060,
13,
35636,
1330,
2511,
261,
198,
6738,
299,
32152,
1330,
355,
18747,
11,
1612,
11,
7177,
11,
19862,
17034,
11,
1612,
198,
28311,
25,
198,
220,
220,
220,
1303,
3125,
7187,
9103,
4917,
422,
198,
220,
220,
220,
1303,
3740,
1378,
70,
396,
13,
12567,
13,
785,
14,
437,
21446,
14,
13381,
33551,
2,
7753,
12,
1845,
29304,
12,
9078,
198,
220,
220,
220,
422,
1582,
29304,
1330,
1582,
29304,
198,
16341,
17267,
12331,
25,
198,
220,
220,
220,
422,
299,
32152,
1330,
1822,
9806,
198,
198,
361,
11593,
3672,
834,
6624,
366,
834,
12417,
834,
1298,
198,
220,
220,
220,
1388,
3419
] | 3.326531 | 245 |
from yapapi.runner import Engine, Task, vm
from yapapi.runner.ctx import WorkContext
from yapapi.log import log_summary, log_event_repr
from datetime import timedelta
import json
import uuid
from core import TranscodingData, TranscodingTask, GolemParameters, SubtaskFinishedEvent
# image hash of the geomandel docker image uploaded to golem
# _IMAGE_LINK = "896909125d8dc19918dc73fe7540ca45cfe87f434ed37f51edb20a4e"
# geomandel image
# _IMAGE_LINK = "47cd0f045333d837304d61f74266a1bcd49ad3cb0690a10f08d37bf4"
# ubuntu ffmpeg
_IMAGE_LINK = "febcd478b3e00b3d40a6d2a69a4932eedcc4440a1fe7658fbb626264"
class YagnaContext:
"""Holds information about the docker image and constraints for all the tasks to be executed in this context."""
def __create_engine(self):
"""Creates yagna engine"""
return Engine(
package=self.package,
max_workers=self.max_workers,
budget=self.budget,
timeout=timedelta(minutes=25),
subnet_tag=self.subnet_tag,
# By passing `event_emitter=log_summary()` we enable summary logging.
# See the documentation of the `yapapi.log` module on how to set
# the level of detail and format of the logged information.
event_emitter=log_summary(log_event_repr),
)
async def execute(self, tasks: [Task], worker_function, on_task_complete):
"""Executes a set of tasks on a preconfigured docker image.
Parameters
----------
tasks : [Task]
Yagna tasks
worker_function : (ctx: WorkContext, tasks) -> [Work]
Function returning a sequence of instructions for each of the provided tasks.
on_task_complete : (task: Task) -> None
Callback executed when a task has been processed.
"""
async with self.__create_engine() as engine:
async for task in engine.map(worker_function, tasks):
on_task_complete(task)
# docker image path to JSON file with task parameters
_TASK_INPUT_REMOTE_PATH = "/golem/work/input"
# minimal provider node memory constraint, not configurable
_MINIMAL_MEMORY = 0.5
# minimal provider node storage constraint, not configurable
_MINIMAL_STORAGE = 2.0
class TranscodingEngine:
"""Converts geomandel subtasks to yagna subtasks and sends them to Yagna Engine"""
@staticmethod
async def instance(golem_parameters: GolemParameters):
"""Creates an instance of TranscodingEngine. Static factory."""
repository = ImageRepository()
# retrieve the image link to ffmpeg docker image together with constraints
package = await repository.get_image(_MINIMAL_MEMORY, _MINIMAL_STORAGE)
# prepares the yagna engine
yagna = YagnaContext(package, golem_parameters.max_workers, golem_parameters.budget, golem_parameters.subnet_tag)
# wraps it in transcoding layer
return TranscodingEngine(yagna)
async def execute(self, tasks: [TranscodingData]):
"""Translates subtasks into Yagna format and executes them."""
wrapped_tasks = self.__wrap_in_yagna_task(tasks)
await self.yagna.execute(wrapped_tasks, self.__transcode_remote, self.__log_completion)
async def __transcode_remote(self, ctx: WorkContext, tasks: [TranscodingTask]):
"""Creates a set of instructions for each subtask"""
async for task in tasks:
remote_output_path: str = f"/golem/work/output.{task.data.extension}"
# Send input video to remote node
ctx.send_file(task.data.input, _TASK_INPUT_REMOTE_PATH)
# Execute ffmpeg command.
ctx.run("/usr/bin/ffmpeg", "-i", _TASK_INPUT_REMOTE_PATH, remote_output_path)
# Download the output file.
ctx.download_file(remote_output_path, task.data.output)
# Return a sequence of commands to be executed when remote node agrees to process a task.
yield ctx.commit()
task.accept_task()
def __wrap_in_yagna_task(self, data: []):
"""Converts any task data sequence to Yagna wrapper"""
for item in data:
yield Task(data=item)
| [
6738,
331,
499,
15042,
13,
16737,
1330,
7117,
11,
15941,
11,
45887,
198,
6738,
331,
499,
15042,
13,
16737,
13,
49464,
1330,
5521,
21947,
198,
6738,
331,
499,
15042,
13,
6404,
1330,
2604,
62,
49736,
11,
2604,
62,
15596,
62,
260,
1050,
198,
6738,
4818,
8079,
1330,
28805,
12514,
198,
11748,
33918,
198,
11748,
334,
27112,
198,
198,
6738,
4755,
1330,
3602,
66,
7656,
6601,
11,
3602,
66,
7656,
25714,
11,
27167,
48944,
11,
3834,
35943,
18467,
1348,
9237,
198,
198,
2,
2939,
12234,
286,
262,
4903,
296,
33134,
36253,
2939,
19144,
284,
467,
10671,
198,
2,
4808,
3955,
11879,
62,
43,
17248,
796,
366,
4531,
3388,
2931,
11623,
67,
23,
17896,
19104,
1507,
17896,
4790,
5036,
2425,
1821,
6888,
2231,
66,
5036,
5774,
69,
47101,
276,
2718,
69,
4349,
276,
65,
1238,
64,
19,
68,
1,
198,
2,
4903,
296,
33134,
2939,
198,
2,
4808,
3955,
11879,
62,
43,
17248,
796,
366,
2857,
10210,
15,
69,
40350,
20370,
67,
23,
2718,
21288,
67,
5333,
69,
4524,
25540,
64,
16,
65,
10210,
2920,
324,
18,
21101,
3312,
3829,
64,
940,
69,
2919,
67,
2718,
19881,
19,
1,
198,
2,
20967,
11157,
31246,
43913,
198,
62,
3955,
11879,
62,
43,
17248,
796,
366,
69,
1765,
10210,
29059,
65,
18,
68,
405,
65,
18,
67,
1821,
64,
21,
67,
17,
64,
3388,
64,
2920,
2624,
2308,
535,
2598,
1821,
64,
16,
5036,
29143,
23,
69,
11848,
45191,
18897,
1,
628,
198,
198,
4871,
575,
48669,
21947,
25,
198,
220,
220,
220,
37227,
39,
10119,
1321,
546,
262,
36253,
2939,
290,
17778,
329,
477,
262,
8861,
284,
307,
10945,
287,
428,
4732,
526,
15931,
628,
220,
220,
220,
825,
11593,
17953,
62,
18392,
7,
944,
2599,
198,
220,
220,
220,
220,
220,
220,
220,
37227,
16719,
274,
331,
48669,
3113,
37811,
198,
220,
220,
220,
220,
220,
220,
220,
1441,
7117,
7,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
5301,
28,
944,
13,
26495,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
3509,
62,
22896,
28,
944,
13,
9806,
62,
22896,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
4466,
28,
944,
13,
37315,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
26827,
28,
16514,
276,
12514,
7,
1084,
1769,
28,
1495,
828,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
850,
3262,
62,
12985,
28,
944,
13,
7266,
3262,
62,
12985,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1303,
2750,
6427,
4600,
15596,
62,
368,
1967,
28,
6404,
62,
49736,
3419,
63,
356,
7139,
10638,
18931,
13,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1303,
4091,
262,
10314,
286,
262,
4600,
88,
499,
15042,
13,
6404,
63,
8265,
319,
703,
284,
900,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1303,
262,
1241,
286,
3703,
290,
5794,
286,
262,
18832,
1321,
13,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1785,
62,
368,
1967,
28,
6404,
62,
49736,
7,
6404,
62,
15596,
62,
260,
1050,
828,
198,
220,
220,
220,
220,
220,
220,
220,
1267,
220,
220,
220,
628,
220,
220,
220,
30351,
825,
12260,
7,
944,
11,
8861,
25,
685,
25714,
4357,
8383,
62,
8818,
11,
319,
62,
35943,
62,
20751,
2599,
198,
220,
220,
220,
220,
220,
220,
220,
37227,
23002,
1769,
257,
900,
286,
8861,
319,
257,
662,
11250,
1522,
36253,
2939,
13,
198,
220,
220,
220,
220,
220,
220,
220,
220,
198,
220,
220,
220,
220,
220,
220,
220,
40117,
198,
220,
220,
220,
220,
220,
220,
220,
24200,
438,
198,
220,
220,
220,
220,
220,
220,
220,
8861,
1058,
685,
25714,
60,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
575,
48669,
8861,
198,
220,
220,
220,
220,
220,
220,
220,
8383,
62,
8818,
1058,
357,
49464,
25,
5521,
21947,
11,
8861,
8,
4613,
685,
12468,
60,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
15553,
8024,
257,
8379,
286,
7729,
329,
1123,
286,
262,
2810,
8861,
13,
198,
220,
220,
220,
220,
220,
220,
220,
319,
62,
35943,
62,
20751,
1058,
357,
35943,
25,
15941,
8,
4613,
6045,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
4889,
1891,
10945,
618,
257,
4876,
468,
587,
13686,
13,
198,
220,
220,
220,
220,
220,
220,
220,
37227,
198,
220,
220,
220,
220,
220,
220,
220,
30351,
351,
2116,
13,
834,
17953,
62,
18392,
3419,
355,
3113,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
30351,
329,
4876,
287,
3113,
13,
8899,
7,
28816,
62,
8818,
11,
8861,
2599,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
319,
62,
35943,
62,
20751,
7,
35943,
8,
628,
198,
2,
36253,
2939,
3108,
284,
19449,
2393,
351,
4876,
10007,
198,
62,
51,
1921,
42,
62,
1268,
30076,
62,
40726,
23051,
62,
34219,
796,
12813,
2188,
10671,
14,
1818,
14,
15414,
1,
198,
198,
2,
10926,
10131,
10139,
4088,
32315,
11,
407,
4566,
11970,
198,
62,
23678,
3955,
1847,
62,
44,
3620,
15513,
796,
657,
13,
20,
198,
2,
10926,
10131,
10139,
6143,
32315,
11,
407,
4566,
11970,
198,
62,
23678,
3955,
1847,
62,
2257,
1581,
11879,
796,
362,
13,
15,
628,
198,
4871,
3602,
66,
7656,
13798,
25,
198,
220,
220,
220,
37227,
3103,
24040,
4903,
296,
33134,
13284,
6791,
284,
331,
48669,
13284,
6791,
290,
12800,
606,
284,
575,
48669,
7117,
37811,
628,
220,
220,
220,
2488,
12708,
24396,
198,
220,
220,
220,
30351,
825,
4554,
7,
2188,
10671,
62,
17143,
7307,
25,
27167,
48944,
2599,
198,
220,
220,
220,
220,
220,
220,
220,
37227,
16719,
274,
281,
4554,
286,
3602,
66,
7656,
13798,
13,
36125,
8860,
526,
15931,
198,
220,
220,
220,
220,
220,
220,
220,
16099,
796,
7412,
6207,
13264,
3419,
198,
220,
220,
220,
220,
220,
220,
220,
1303,
19818,
262,
2939,
2792,
284,
31246,
43913,
36253,
2939,
1978,
351,
17778,
198,
220,
220,
220,
220,
220,
220,
220,
5301,
796,
25507,
16099,
13,
1136,
62,
9060,
28264,
23678,
3955,
1847,
62,
44,
3620,
15513,
11,
4808,
23678,
3955,
1847,
62,
2257,
1581,
11879,
8,
198,
220,
220,
220,
220,
220,
220,
220,
1303,
25978,
262,
331,
48669,
3113,
198,
220,
220,
220,
220,
220,
220,
220,
331,
48669,
796,
575,
48669,
21947,
7,
26495,
11,
467,
10671,
62,
17143,
7307,
13,
9806,
62,
22896,
11,
467,
10671,
62,
17143,
7307,
13,
37315,
11,
467,
10671,
62,
17143,
7307,
13,
7266,
3262,
62,
12985,
8,
198,
220,
220,
220,
220,
220,
220,
220,
1303,
27521,
340,
287,
23589,
7656,
7679,
198,
220,
220,
220,
220,
220,
220,
220,
1441,
3602,
66,
7656,
13798,
7,
88,
48669,
8,
628,
220,
220,
220,
30351,
825,
12260,
7,
944,
11,
8861,
25,
685,
8291,
66,
7656,
6601,
60,
2599,
198,
220,
220,
220,
220,
220,
220,
220,
37227,
8291,
75,
689,
13284,
6791,
656,
575,
48669,
5794,
290,
42985,
606,
526,
15931,
198,
220,
220,
220,
220,
220,
220,
220,
12908,
62,
83,
6791,
796,
2116,
13,
834,
37150,
62,
259,
62,
88,
48669,
62,
35943,
7,
83,
6791,
8,
198,
220,
220,
220,
220,
220,
220,
220,
25507,
2116,
13,
88,
48669,
13,
41049,
7,
29988,
1496,
62,
83,
6791,
11,
2116,
13,
834,
7645,
8189,
62,
47960,
11,
2116,
13,
834,
6404,
62,
785,
24547,
8,
628,
220,
220,
220,
30351,
825,
11593,
7645,
8189,
62,
47960,
7,
944,
11,
269,
17602,
25,
5521,
21947,
11,
8861,
25,
685,
8291,
66,
7656,
25714,
60,
2599,
198,
220,
220,
220,
220,
220,
220,
220,
37227,
16719,
274,
257,
900,
286,
7729,
329,
1123,
13284,
2093,
37811,
198,
220,
220,
220,
220,
220,
220,
220,
30351,
329,
4876,
287,
8861,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
6569,
62,
22915,
62,
6978,
25,
965,
796,
277,
1,
14,
2188,
10671,
14,
1818,
14,
22915,
13,
90,
35943,
13,
7890,
13,
2302,
3004,
36786,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1303,
16290,
5128,
2008,
284,
6569,
10139,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
269,
17602,
13,
21280,
62,
7753,
7,
35943,
13,
7890,
13,
15414,
11,
4808,
51,
1921,
42,
62,
1268,
30076,
62,
40726,
23051,
62,
34219,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1303,
8393,
1133,
31246,
43913,
3141,
13,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
269,
17602,
13,
5143,
7203,
14,
14629,
14,
8800,
14,
487,
43913,
1600,
27444,
72,
1600,
4808,
51,
1921,
42,
62,
1268,
30076,
62,
40726,
23051,
62,
34219,
11,
6569,
62,
22915,
62,
6978,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1303,
10472,
262,
5072,
2393,
13,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
269,
17602,
13,
15002,
62,
7753,
7,
47960,
62,
22915,
62,
6978,
11,
4876,
13,
7890,
13,
22915,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1303,
8229,
257,
8379,
286,
9729,
284,
307,
10945,
618,
6569,
10139,
14386,
284,
1429,
257,
4876,
13,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
7800,
269,
17602,
13,
41509,
3419,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
4876,
13,
13635,
62,
35943,
3419,
628,
220,
220,
220,
825,
11593,
37150,
62,
259,
62,
88,
48669,
62,
35943,
7,
944,
11,
1366,
25,
17635,
2599,
198,
220,
220,
220,
220,
220,
220,
220,
37227,
3103,
24040,
597,
4876,
1366,
8379,
284,
575,
48669,
29908,
37811,
198,
220,
220,
220,
220,
220,
220,
220,
329,
2378,
287,
1366,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
7800,
15941,
7,
7890,
28,
9186,
8,
198
] | 2.526823 | 1,659 |
#!/usr/bin/env python3
"""
Take a polyglot from mitra,
generate a OFB ciphertext which decrypts correctly under two different keys.
iv = dec(c0 ^ p0)
"""
import binascii
import os
import argparse
import re
from Crypto.Cipher import AES
from Crypto.Util.number import long_to_bytes,bytes_to_long
from Crypto.Util.number import long_to_bytes as l2b
from Crypto.Util.number import bytes_to_long as b2l
BLOCKLEN = 16
pad16 = lambda s: s + b"\0" * (16-len(s))
b2a = lambda b: repr(b)[2:-1]
dir_path = os.path.dirname(os.path.realpath(__file__))
ivsfn = os.path.join(dir_path, "ivs.txt")
with open(ivsfn, "r") as f:
iv_data = f.readlines()
IVS = {}
for l in iv_data:
if l.count("#") > 0:
l = l[:l.find("#")]
l = l.strip()
if l == "":
continue
l = re.split(r'\s+', l)
if len(l) != 6:
continue
iv,types,header1, header2, key1, key2 = l
if len(header1) != len(header2):
continue
if len(key1) != len(key2):
continue
header1 = binascii.unhexlify(header1)
header2 = binascii.unhexlify(header2)
key1 = binascii.unhexlify(key1)
key2 = binascii.unhexlify(key2)
iv = binascii.unhexlify(iv)
xor_hdr = xor(header1, header2)
IVS[(xor_hdr, key1, key2)] = iv
if __name__=='__main__':
parser = argparse.ArgumentParser(description="Turn a non-overlapping polyglot into a dual AES-OFB ciphertext.")
parser.add_argument('polyglot',
help="input polyglot - requires special naming like 'P(10-5c).png.rar'.")
parser.add_argument('output',
help="generated file.")
parser.add_argument('-i', '--iv', default=b"0",
help="nonce - default: 0.")
parser.add_argument('-k', '--keys', nargs=2, default=[b"Now?", b"L4t3r!!!"],
help="encryption keys - default: Now? / L4t3r!!!.")
args = parser.parse_args()
fnmix = args.polyglot
fnpoc = args.output
key1, key2 = args.keys
iv = args.iv
iv = pad16(unhextry(iv))
key1 = pad16(unhextry(key1))
key2 = pad16(unhextry(key2))
with open(fnmix, "rb") as file:
dIn = file.read()
dIn = pad(dIn, BLOCKLEN) # the padding will break with formats not supporting appended data
assert not key1 == key2
# fnmix should come from Mitra and
# has a naming convention like "P(14-89)-ID3v2[Zip].4d01e2fb.mp3.zip"
swaps = [int(i, 16) for i in fnmix[fnmix.find("(") + 1:fnmix.find(")")].split("-")]
exts = fnmix[-9:].split(".")[-2:]
if fnmix.startswith("O") and \
"{" in fnmix and \
"}" in fnmix:
print("Overlap file found")
iv = BruteIv(fnmix)
print("IV: %s" % b2a(binascii.hexlify(iv)))
assert len(dIn) % 16 == 0
bCount = len(dIn) // 16
ks1 = getKS(key1, iv, bCount)
ks2 = getKS(key2, iv, bCount)
dCrypt1 = xor(dIn, ks1[:len(dIn)])
dCrypt2 = xor(dIn, ks2[:len(dIn)])
dOut = mix(dCrypt1, dCrypt2, swaps)
print("key 1:", b2a(key1.strip(b"\0")))
print("key 2:", b2a(key2.strip(b"\0")))
ctxt = dOut
output = "\n".join([
"key1: %s" % b2a(binascii.hexlify(key1)),
"key2: %s" % b2a(binascii.hexlify(key2)),
"iv: %s" % b2a(binascii.hexlify(iv)),
"ciphertext: %s" % b2a(binascii.hexlify(ctxt)),
"exts: %s" % " ".join(exts),
"origin: %s" % fnmix,
])
with open(fnpoc, "wb") as fpoc:
fpoc.write(output.encode())
fpoc.close()
| [
2,
48443,
14629,
14,
8800,
14,
24330,
21015,
18,
198,
198,
37811,
198,
12322,
257,
7514,
4743,
313,
422,
10255,
430,
11,
198,
8612,
378,
257,
3963,
33,
38012,
5239,
543,
42797,
82,
9380,
739,
734,
1180,
8251,
13,
198,
198,
452,
796,
875,
7,
66,
15,
10563,
279,
15,
8,
198,
37811,
198,
198,
11748,
9874,
292,
979,
72,
198,
11748,
28686,
198,
11748,
1822,
29572,
198,
11748,
302,
198,
6738,
36579,
13,
34,
10803,
1330,
34329,
198,
6738,
36579,
13,
18274,
346,
13,
17618,
1330,
890,
62,
1462,
62,
33661,
11,
33661,
62,
1462,
62,
6511,
198,
6738,
36579,
13,
18274,
346,
13,
17618,
1330,
890,
62,
1462,
62,
33661,
355,
300,
17,
65,
198,
6738,
36579,
13,
18274,
346,
13,
17618,
1330,
9881,
62,
1462,
62,
6511,
355,
275,
17,
75,
628,
198,
9148,
11290,
43,
1677,
796,
1467,
198,
198,
15636,
1433,
796,
37456,
264,
25,
264,
1343,
275,
1,
59,
15,
1,
1635,
357,
1433,
12,
11925,
7,
82,
4008,
198,
65,
17,
64,
796,
37456,
275,
25,
41575,
7,
65,
38381,
17,
21912,
16,
60,
628,
628,
628,
198,
198,
15908,
62,
6978,
796,
28686,
13,
6978,
13,
15908,
3672,
7,
418,
13,
6978,
13,
5305,
6978,
7,
834,
7753,
834,
4008,
198,
452,
82,
22184,
796,
28686,
13,
6978,
13,
22179,
7,
15908,
62,
6978,
11,
366,
452,
82,
13,
14116,
4943,
198,
4480,
1280,
7,
452,
82,
22184,
11,
366,
81,
4943,
355,
277,
25,
198,
197,
452,
62,
7890,
796,
277,
13,
961,
6615,
3419,
198,
3824,
50,
796,
23884,
198,
1640,
300,
287,
21628,
62,
7890,
25,
198,
197,
361,
300,
13,
9127,
7203,
2,
4943,
1875,
657,
25,
198,
197,
197,
75,
796,
300,
58,
25,
75,
13,
19796,
7203,
2,
4943,
60,
198,
197,
75,
796,
300,
13,
36311,
3419,
198,
197,
361,
300,
6624,
366,
1298,
198,
197,
197,
43043,
198,
197,
75,
796,
302,
13,
35312,
7,
81,
6,
59,
82,
10,
3256,
300,
8,
198,
197,
361,
18896,
7,
75,
8,
14512,
718,
25,
198,
197,
197,
43043,
198,
197,
452,
11,
19199,
11,
25677,
16,
11,
13639,
17,
11,
1994,
16,
11,
1994,
17,
796,
300,
198,
197,
361,
18896,
7,
25677,
16,
8,
14512,
18896,
7,
25677,
17,
2599,
198,
197,
197,
43043,
198,
197,
361,
18896,
7,
2539,
16,
8,
14512,
18896,
7,
2539,
17,
2599,
198,
197,
197,
43043,
198,
197,
25677,
16,
796,
9874,
292,
979,
72,
13,
403,
33095,
75,
1958,
7,
25677,
16,
8,
198,
197,
25677,
17,
796,
9874,
292,
979,
72,
13,
403,
33095,
75,
1958,
7,
25677,
17,
8,
198,
197,
2539,
16,
796,
9874,
292,
979,
72,
13,
403,
33095,
75,
1958,
7,
2539,
16,
8,
198,
197,
2539,
17,
796,
9874,
292,
979,
72,
13,
403,
33095,
75,
1958,
7,
2539,
17,
8,
198,
197,
452,
796,
9874,
292,
979,
72,
13,
403,
33095,
75,
1958,
7,
452,
8,
198,
197,
87,
273,
62,
71,
7109,
796,
2124,
273,
7,
25677,
16,
11,
13639,
17,
8,
198,
197,
3824,
50,
58,
7,
87,
273,
62,
71,
7109,
11,
1994,
16,
11,
1994,
17,
15437,
796,
21628,
628,
198,
361,
11593,
3672,
834,
855,
6,
834,
12417,
834,
10354,
198,
197,
48610,
796,
1822,
29572,
13,
28100,
1713,
46677,
7,
11213,
2625,
17278,
257,
1729,
12,
2502,
75,
5912,
7514,
4743,
313,
656,
257,
10668,
34329,
12,
19238,
33,
38012,
5239,
19570,
198,
197,
48610,
13,
2860,
62,
49140,
10786,
35428,
4743,
313,
3256,
198,
197,
197,
16794,
2625,
15414,
7514,
4743,
313,
532,
4433,
2041,
19264,
588,
705,
47,
7,
940,
12,
20,
66,
737,
11134,
13,
20040,
6,
19570,
198,
197,
48610,
13,
2860,
62,
49140,
10786,
22915,
3256,
198,
197,
197,
16794,
2625,
27568,
2393,
19570,
198,
197,
48610,
13,
2860,
62,
49140,
10786,
12,
72,
3256,
705,
438,
452,
3256,
4277,
28,
65,
1,
15,
1600,
198,
197,
197,
16794,
2625,
13159,
344,
532,
4277,
25,
657,
19570,
198,
197,
48610,
13,
2860,
62,
49140,
10786,
12,
74,
3256,
705,
438,
13083,
3256,
299,
22046,
28,
17,
11,
4277,
41888,
65,
1,
3844,
35379,
275,
1,
43,
19,
83,
18,
81,
3228,
2474,
4357,
198,
197,
197,
16794,
2625,
12685,
13168,
8251,
532,
4277,
25,
2735,
30,
1220,
406,
19,
83,
18,
81,
10185,
19570,
628,
197,
22046,
796,
30751,
13,
29572,
62,
22046,
3419,
628,
197,
22184,
19816,
796,
26498,
13,
35428,
4743,
313,
198,
197,
22184,
79,
420,
796,
26498,
13,
22915,
198,
197,
2539,
16,
11,
1994,
17,
796,
26498,
13,
13083,
198,
197,
452,
796,
26498,
13,
452,
628,
197,
452,
796,
14841,
1433,
7,
403,
258,
742,
563,
7,
452,
4008,
198,
197,
2539,
16,
796,
14841,
1433,
7,
403,
258,
742,
563,
7,
2539,
16,
4008,
198,
197,
2539,
17,
796,
14841,
1433,
7,
403,
258,
742,
563,
7,
2539,
17,
4008,
628,
197,
4480,
1280,
7,
22184,
19816,
11,
366,
26145,
4943,
355,
2393,
25,
198,
197,
197,
67,
818,
796,
2393,
13,
961,
3419,
198,
197,
67,
818,
796,
14841,
7,
67,
818,
11,
9878,
11290,
43,
1677,
8,
1303,
262,
24511,
481,
2270,
351,
17519,
407,
6493,
598,
1631,
1366,
628,
197,
30493,
407,
1994,
16,
6624,
1994,
17,
628,
198,
197,
2,
24714,
19816,
815,
1282,
422,
11707,
430,
290,
198,
197,
2,
468,
257,
19264,
9831,
588,
366,
47,
7,
1415,
12,
4531,
13219,
2389,
18,
85,
17,
58,
41729,
4083,
19,
67,
486,
68,
17,
21855,
13,
3149,
18,
13,
13344,
1,
198,
197,
2032,
1686,
796,
685,
600,
7,
72,
11,
1467,
8,
329,
1312,
287,
24714,
19816,
58,
22184,
19816,
13,
19796,
7203,
7,
4943,
1343,
352,
25,
22184,
19816,
13,
19796,
7,
4943,
4943,
4083,
35312,
7203,
12,
4943,
60,
198,
197,
2302,
82,
796,
24714,
19816,
58,
12,
24,
25,
4083,
35312,
7203,
19570,
58,
12,
17,
47715,
198,
197,
628,
628,
197,
361,
24714,
19816,
13,
9688,
2032,
342,
7203,
46,
4943,
290,
3467,
198,
197,
197,
1,
4895,
287,
24714,
19816,
290,
3467,
198,
197,
197,
20662,
1,
287,
24714,
19816,
25,
198,
197,
197,
4798,
7203,
5886,
37796,
2393,
1043,
4943,
198,
197,
197,
452,
796,
1709,
1133,
45766,
7,
22184,
19816,
8,
198,
197,
197,
4798,
7203,
3824,
25,
4064,
82,
1,
4064,
275,
17,
64,
7,
8800,
292,
979,
72,
13,
33095,
75,
1958,
7,
452,
22305,
628,
198,
197,
30493,
18896,
7,
67,
818,
8,
4064,
1467,
6624,
657,
198,
197,
65,
12332,
796,
18896,
7,
67,
818,
8,
3373,
1467,
628,
197,
591,
16,
796,
651,
27015,
7,
2539,
16,
11,
21628,
11,
275,
12332,
8,
198,
197,
591,
17,
796,
651,
27015,
7,
2539,
17,
11,
21628,
11,
275,
12332,
8,
628,
197,
67,
23919,
16,
796,
2124,
273,
7,
67,
818,
11,
479,
82,
16,
58,
25,
11925,
7,
67,
818,
8,
12962,
198,
197,
67,
23919,
17,
796,
2124,
273,
7,
67,
818,
11,
479,
82,
17,
58,
25,
11925,
7,
67,
818,
8,
12962,
198,
197,
67,
7975,
796,
5022,
7,
67,
23919,
16,
11,
288,
23919,
17,
11,
43997,
8,
628,
197,
4798,
7203,
2539,
352,
25,
1600,
275,
17,
64,
7,
2539,
16,
13,
36311,
7,
65,
1,
59,
15,
1,
22305,
198,
197,
4798,
7203,
2539,
362,
25,
1600,
275,
17,
64,
7,
2539,
17,
13,
36311,
7,
65,
1,
59,
15,
1,
22305,
628,
197,
310,
742,
796,
288,
7975,
628,
197,
22915,
796,
37082,
77,
1911,
22179,
26933,
198,
197,
197,
197,
1,
2539,
16,
25,
4064,
82,
1,
4064,
275,
17,
64,
7,
8800,
292,
979,
72,
13,
33095,
75,
1958,
7,
2539,
16,
36911,
198,
197,
197,
197,
1,
2539,
17,
25,
4064,
82,
1,
4064,
275,
17,
64,
7,
8800,
292,
979,
72,
13,
33095,
75,
1958,
7,
2539,
17,
36911,
198,
197,
197,
197,
1,
452,
25,
4064,
82,
1,
4064,
275,
17,
64,
7,
8800,
292,
979,
72,
13,
33095,
75,
1958,
7,
452,
36911,
198,
197,
197,
197,
1,
66,
10803,
5239,
25,
4064,
82,
1,
4064,
275,
17,
64,
7,
8800,
292,
979,
72,
13,
33095,
75,
1958,
7,
310,
742,
36911,
198,
197,
197,
220,
366,
2302,
82,
25,
4064,
82,
1,
4064,
366,
27071,
22179,
7,
2302,
82,
828,
198,
197,
197,
220,
366,
47103,
25,
4064,
82,
1,
4064,
24714,
19816,
11,
198,
197,
197,
12962,
198,
197,
4480,
1280,
7,
22184,
79,
420,
11,
366,
39346,
4943,
355,
277,
79,
420,
25,
198,
197,
197,
46428,
420,
13,
13564,
7,
22915,
13,
268,
8189,
28955,
198,
197,
197,
46428,
420,
13,
19836,
3419,
198
] | 2.199019 | 1,427 |
from __future__ import annotations
import inspect
import threading
import weakref
from types import MethodType
from typing import (
Any,
Callable,
Generic,
Iterator,
List,
MutableSet,
Optional,
Type,
TypeVar,
cast,
)
__all__ = ["EventIterator", "Event"]
_TResult = TypeVar("_TResult")
_TCallable = TypeVar("_TCallable", bound=Callable[..., Any])
_TEvent = TypeVar("_TEvent")
| [
6738,
11593,
37443,
834,
1330,
37647,
198,
198,
11748,
10104,
198,
11748,
4704,
278,
198,
11748,
4939,
5420,
198,
6738,
3858,
1330,
11789,
6030,
198,
6738,
19720,
1330,
357,
198,
220,
220,
220,
4377,
11,
198,
220,
220,
220,
4889,
540,
11,
198,
220,
220,
220,
42044,
11,
198,
220,
220,
220,
40806,
1352,
11,
198,
220,
220,
220,
7343,
11,
198,
220,
220,
220,
13859,
540,
7248,
11,
198,
220,
220,
220,
32233,
11,
198,
220,
220,
220,
5994,
11,
198,
220,
220,
220,
5994,
19852,
11,
198,
220,
220,
220,
3350,
11,
198,
8,
198,
198,
834,
439,
834,
796,
14631,
9237,
37787,
1600,
366,
9237,
8973,
198,
198,
62,
51,
23004,
796,
5994,
19852,
7203,
62,
51,
23004,
4943,
198,
62,
4825,
439,
540,
796,
5994,
19852,
7203,
62,
4825,
439,
540,
1600,
5421,
28,
14134,
540,
58,
986,
11,
4377,
12962,
628,
628,
198,
198,
62,
51,
9237,
796,
5994,
19852,
7203,
62,
51,
9237,
4943,
628,
628
] | 2.62963 | 162 |
from typing import Dict, Any
import tensorflow as tf
from tensorflow.keras.utils import plot_model
from kashgari_local.abc_feature_model import ABCClassificationModel
from kashgari.layers import L
| [
6738,
19720,
1330,
360,
713,
11,
4377,
198,
198,
11748,
11192,
273,
11125,
355,
48700,
198,
6738,
11192,
273,
11125,
13,
6122,
292,
13,
26791,
1330,
7110,
62,
19849,
198,
6738,
479,
1077,
70,
2743,
62,
12001,
13,
39305,
62,
30053,
62,
19849,
1330,
9738,
9487,
2649,
17633,
198,
6738,
479,
1077,
70,
2743,
13,
75,
6962,
1330,
406,
628
] | 3.316667 | 60 |
""" Stiny - A home automation assistant """
import os
import posixpath
import calendar
import datetime
import json
import logging
import requests
from collections import defaultdict
from pyramid.authentication import AuthTktAuthenticationPolicy
from pyramid.authorization import ACLAuthorizationPolicy
from pyramid.config import Configurator
from pyramid.httpexceptions import exception_response
from pyramid.renderers import JSON, render, render_to_response
from pyramid.settings import asbool, aslist
from pyramid_beaker import session_factory_from_settings
from twilio.util import RequestValidator
from .gutil import Calendar, normalize_email
LOG = logging.getLogger(__name__)
def to_json(value):
""" A json filter for jinja2 """
return render('json', value)
json_renderer = JSON() # pylint: disable=C0103
json_renderer.add_adapter(datetime.datetime, lambda obj, r:
1000 * calendar.timegm(obj.utctimetuple()))
json_renderer.add_adapter(datetime.date,
lambda obj, _: obj.isoformat())
json_renderer.add_adapter(defaultdict,
lambda obj, _: dict(obj))
json_renderer.add_adapter(Exception,
lambda e, _: str(e))
def _error(request, error, message='Unknown error', status_code=500):
"""
Construct an error response
Parameters
----------
error : str
Identifying error key
message : str, optional
Human-readable error message
status_code : int, optional
HTTP return code (default 500)
"""
data = {
'error': error,
'msg': message,
}
LOG.error("%s: %s", error, message)
request.response.status_code = status_code
return render_to_response('json', data, request, response=request.response)
def _raise_error(request, error, message='Unknown error', status_code=500):
"""
Raise an error response.
Use this when you need to return an error to the client from inside of
nested function calls.
Parameters
----------
error : str
Identifying error key
message : str, optional
Human-readable error message
status_code : int, optional
HTTP return code (default 500)
"""
err = exception_response(status_code, detail=message)
err.error = error
raise err
def _auth_callback(userid, request):
""" Get permissions for a user with an email. """
n_userid = normalize_email(userid)
perms = []
# If permissions are declared in the config.ini file, just use those.
setting = request.registry.settings.get('auth.' + n_userid)
if setting is not None:
principals = aslist(setting)
else:
principals = []
if request.cal.is_guest(n_userid):
principals.append('unlock')
perms.extend(principals)
return perms
def includeme(config):
""" Set up and configure the app """
settings = config.get_settings()
config.include('pyramid_beaker')
config.include('pyramid_duh')
config.include('pyramid_webpack')
config.include('stiny.route')
config.add_renderer('json', json_renderer)
# Jinja2 configuration
settings['jinja2.filters'] = {
'static_url': 'pyramid_jinja2.filters:static_url_filter',
'json': to_json,
}
settings['jinja2.directories'] = ['stiny:templates']
settings['jinja2.extensions'] = ['pyramid_webpack.jinja2ext:WebpackExtension']
config.include('pyramid_jinja2')
config.commit()
# Beaker configuration
settings.setdefault('session.type', 'cookie')
settings.setdefault('session.httponly', 'true')
config.set_session_factory(session_factory_from_settings(settings))
config.set_default_csrf_options(require_csrf=True, token=None)
# Set admins from environment variable for local development
if 'STINY_ADMINS' in os.environ:
for email in aslist(os.environ['STINY_ADMINS']):
email = normalize_email(email)
settings['auth.' + email] = 'admin'
# Set guests from environment variable for local development
if 'STINY_GUESTS' in os.environ:
for email in aslist(os.environ['STINY_GUESTS']):
email = normalize_email(email)
settings['auth.' + email] = 'unlock'
# Special request methods
config.add_request_method(_error, name='error')
config.add_request_method(_raise_error, name='raise_error')
config.add_request_method(lambda r, *a, **k: r.route_url('root', *a, **k),
name='rooturl')
config.add_request_method(lambda r, u: _auth_callback(u, r),
name='user_principals')
config.add_request_method(lambda r: r.registry.settings.get('google.client_id'),
name='google_client_id', reify=True)
config.registry.phone_access = aslist(settings.get('phone_access', []))
config.add_static_view(name='static', path='stiny:static',
cache_max_age=10 * 365 * 24 * 60 * 60)
# Auth
config.set_authorization_policy(ACLAuthorizationPolicy())
config.set_authentication_policy(AuthTktAuthenticationPolicy(
secret=settings['authtkt.secret'],
cookie_name=settings.get('auth.cookie_name', 'auth_tkt'),
secure=asbool(settings.get('auth.secure', False)),
timeout=int(settings.get('auth.timeout', 60 * 60 * 24 * 30)),
reissue_time=int(settings.get('auth.reissue_time', 60 * 60 * 24 * 15)),
max_age=int(settings.get('auth.max_age', 60 * 60 * 24 * 30)),
http_only=asbool(settings.get('auth.http_only', True)),
hashalg='sha512',
callback=_auth_callback,
))
config.set_default_permission('default')
# Calendar
config.registry.GOOGLE_WEB_CLIENT_ID = settings.setdefault(
'google.client_id',
os.environ.get('STINY_DEV_CLIENT_GOOGLE_CLIENT_ID'))
server_client_id = settings.get('google.server_client_id')
if server_client_id is None:
server_client_id = os.environ['STINY_SERVER_GOOGLE_CLIENT_ID']
config.registry.GOOGLE_CLIENT_ID = server_client_id
client_secret = settings.get('google.server_client_secret')
if client_secret is None:
client_secret = os.environ['STINY_SERVER_GOOGLE_CLIENT_SECRET']
cal_id = settings.get('google.calendar_id')
if cal_id is None:
cal_id = os.environ['STINY_CAL_ID']
cal = Calendar(server_client_id, client_secret, calendar_id=cal_id)
config.registry.calendar = cal
config.add_request_method(lambda r: r.registry.calendar, 'cal', reify=True)
twilio_token = settings.get('twilio.auth_token')
if twilio_token is None:
twilio_token = os.environ['STINY_TWILIO_AUTH_TOKEN']
config.registry.twilio_validator = RequestValidator(twilio_token)
config.add_request_method(_validate_twilio, name='validate_twilio')
config.add_request_method(_call_worker, name='call_worker')
config.scan()
def main(config, **settings):
""" This function returns a Pyramid WSGI application.
"""
config = Configurator(settings=settings)
config.include('stiny')
return config.make_wsgi_app()
| [
37811,
520,
3541,
532,
317,
1363,
22771,
8796,
37227,
198,
11748,
28686,
198,
11748,
1426,
844,
6978,
198,
198,
11748,
11845,
198,
11748,
4818,
8079,
198,
11748,
33918,
198,
11748,
18931,
198,
11748,
7007,
198,
6738,
17268,
1330,
4277,
11600,
198,
6738,
27944,
13,
41299,
3299,
1330,
26828,
51,
21841,
47649,
3299,
36727,
198,
6738,
27944,
13,
9800,
1634,
1330,
17382,
13838,
1634,
36727,
198,
6738,
27944,
13,
11250,
1330,
17056,
333,
1352,
198,
6738,
27944,
13,
2804,
24900,
11755,
1330,
6631,
62,
26209,
198,
6738,
27944,
13,
10920,
19288,
1330,
19449,
11,
8543,
11,
8543,
62,
1462,
62,
26209,
198,
6738,
27944,
13,
33692,
1330,
355,
30388,
11,
355,
4868,
198,
6738,
27944,
62,
1350,
3110,
1330,
6246,
62,
69,
9548,
62,
6738,
62,
33692,
198,
6738,
665,
346,
952,
13,
22602,
1330,
19390,
47139,
1352,
198,
198,
6738,
764,
70,
22602,
1330,
26506,
11,
3487,
1096,
62,
12888,
628,
198,
25294,
796,
18931,
13,
1136,
11187,
1362,
7,
834,
3672,
834,
8,
628,
198,
4299,
284,
62,
17752,
7,
8367,
2599,
198,
220,
220,
220,
37227,
317,
33918,
8106,
329,
474,
259,
6592,
17,
37227,
198,
220,
220,
220,
1441,
8543,
10786,
17752,
3256,
1988,
8,
198,
198,
17752,
62,
10920,
11882,
796,
19449,
3419,
220,
1303,
279,
2645,
600,
25,
15560,
28,
34,
486,
3070,
198,
17752,
62,
10920,
11882,
13,
2860,
62,
324,
3429,
7,
19608,
8079,
13,
19608,
8079,
11,
37456,
26181,
11,
374,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
8576,
1635,
11845,
13,
2435,
39870,
7,
26801,
13,
315,
310,
38813,
29291,
3419,
4008,
198,
17752,
62,
10920,
11882,
13,
2860,
62,
324,
3429,
7,
19608,
8079,
13,
4475,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
37456,
26181,
11,
4808,
25,
26181,
13,
26786,
18982,
28955,
198,
17752,
62,
10920,
11882,
13,
2860,
62,
324,
3429,
7,
12286,
11600,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
37456,
26181,
11,
4808,
25,
8633,
7,
26801,
4008,
198,
17752,
62,
10920,
11882,
13,
2860,
62,
324,
3429,
7,
16922,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
37456,
304,
11,
4808,
25,
965,
7,
68,
4008,
628,
198,
4299,
4808,
18224,
7,
25927,
11,
4049,
11,
3275,
11639,
20035,
4049,
3256,
3722,
62,
8189,
28,
4059,
2599,
198,
220,
220,
220,
37227,
198,
220,
220,
220,
28407,
281,
4049,
2882,
628,
220,
220,
220,
40117,
198,
220,
220,
220,
24200,
438,
198,
220,
220,
220,
4049,
1058,
965,
198,
220,
220,
220,
220,
220,
220,
220,
11440,
4035,
4049,
1994,
198,
220,
220,
220,
3275,
1058,
965,
11,
11902,
198,
220,
220,
220,
220,
220,
220,
220,
5524,
12,
46155,
4049,
3275,
198,
220,
220,
220,
3722,
62,
8189,
1058,
493,
11,
11902,
198,
220,
220,
220,
220,
220,
220,
220,
14626,
1441,
2438,
357,
12286,
5323,
8,
628,
220,
220,
220,
37227,
198,
220,
220,
220,
1366,
796,
1391,
198,
220,
220,
220,
220,
220,
220,
220,
705,
18224,
10354,
4049,
11,
198,
220,
220,
220,
220,
220,
220,
220,
705,
19662,
10354,
3275,
11,
198,
220,
220,
220,
1782,
198,
220,
220,
220,
41605,
13,
18224,
7203,
4,
82,
25,
4064,
82,
1600,
4049,
11,
3275,
8,
198,
220,
220,
220,
2581,
13,
26209,
13,
13376,
62,
8189,
796,
3722,
62,
8189,
198,
220,
220,
220,
1441,
8543,
62,
1462,
62,
26209,
10786,
17752,
3256,
1366,
11,
2581,
11,
2882,
28,
25927,
13,
26209,
8,
628,
198,
4299,
4808,
40225,
62,
18224,
7,
25927,
11,
4049,
11,
3275,
11639,
20035,
4049,
3256,
3722,
62,
8189,
28,
4059,
2599,
198,
220,
220,
220,
37227,
198,
220,
220,
220,
35123,
281,
4049,
2882,
13,
628,
220,
220,
220,
5765,
428,
618,
345,
761,
284,
1441,
281,
4049,
284,
262,
5456,
422,
2641,
286,
198,
220,
220,
220,
28376,
2163,
3848,
13,
628,
220,
220,
220,
40117,
198,
220,
220,
220,
24200,
438,
198,
220,
220,
220,
4049,
1058,
965,
198,
220,
220,
220,
220,
220,
220,
220,
11440,
4035,
4049,
1994,
198,
220,
220,
220,
3275,
1058,
965,
11,
11902,
198,
220,
220,
220,
220,
220,
220,
220,
5524,
12,
46155,
4049,
3275,
198,
220,
220,
220,
3722,
62,
8189,
1058,
493,
11,
11902,
198,
220,
220,
220,
220,
220,
220,
220,
14626,
1441,
2438,
357,
12286,
5323,
8,
628,
220,
220,
220,
37227,
198,
220,
220,
220,
11454,
796,
6631,
62,
26209,
7,
13376,
62,
8189,
11,
3703,
28,
20500,
8,
198,
220,
220,
220,
11454,
13,
18224,
796,
4049,
198,
220,
220,
220,
5298,
11454,
628,
198,
4299,
4808,
18439,
62,
47423,
7,
7220,
312,
11,
2581,
2599,
198,
220,
220,
220,
37227,
3497,
21627,
329,
257,
2836,
351,
281,
3053,
13,
37227,
198,
220,
220,
220,
299,
62,
7220,
312,
796,
3487,
1096,
62,
12888,
7,
7220,
312,
8,
198,
220,
220,
220,
583,
907,
796,
17635,
198,
220,
220,
220,
1303,
1002,
21627,
389,
6875,
287,
262,
4566,
13,
5362,
2393,
11,
655,
779,
883,
13,
198,
220,
220,
220,
4634,
796,
2581,
13,
2301,
4592,
13,
33692,
13,
1136,
10786,
18439,
2637,
1343,
299,
62,
7220,
312,
8,
198,
220,
220,
220,
611,
4634,
318,
407,
6045,
25,
198,
220,
220,
220,
220,
220,
220,
220,
44998,
796,
355,
4868,
7,
33990,
8,
198,
220,
220,
220,
2073,
25,
198,
220,
220,
220,
220,
220,
220,
220,
44998,
796,
17635,
198,
220,
220,
220,
220,
220,
220,
220,
611,
2581,
13,
9948,
13,
271,
62,
5162,
395,
7,
77,
62,
7220,
312,
2599,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
44998,
13,
33295,
10786,
403,
5354,
11537,
628,
220,
220,
220,
583,
907,
13,
2302,
437,
7,
1050,
1939,
541,
874,
8,
198,
220,
220,
220,
1441,
583,
907,
628,
628,
198,
4299,
846,
34755,
7,
11250,
2599,
198,
220,
220,
220,
37227,
5345,
510,
290,
17425,
262,
598,
37227,
198,
220,
220,
220,
6460,
796,
4566,
13,
1136,
62,
33692,
3419,
198,
220,
220,
220,
4566,
13,
17256,
10786,
9078,
20255,
62,
1350,
3110,
11537,
198,
220,
220,
220,
4566,
13,
17256,
10786,
9078,
20255,
62,
646,
71,
11537,
198,
220,
220,
220,
4566,
13,
17256,
10786,
9078,
20255,
62,
12384,
8002,
11537,
198,
220,
220,
220,
4566,
13,
17256,
10786,
301,
3541,
13,
38629,
11537,
198,
220,
220,
220,
4566,
13,
2860,
62,
10920,
11882,
10786,
17752,
3256,
33918,
62,
10920,
11882,
8,
628,
220,
220,
220,
1303,
17297,
6592,
17,
8398,
198,
220,
220,
220,
6460,
17816,
18594,
6592,
17,
13,
10379,
1010,
20520,
796,
1391,
198,
220,
220,
220,
220,
220,
220,
220,
705,
12708,
62,
6371,
10354,
705,
9078,
20255,
62,
18594,
6592,
17,
13,
10379,
1010,
25,
12708,
62,
6371,
62,
24455,
3256,
198,
220,
220,
220,
220,
220,
220,
220,
705,
17752,
10354,
284,
62,
17752,
11,
198,
220,
220,
220,
1782,
198,
220,
220,
220,
6460,
17816,
18594,
6592,
17,
13,
12942,
1749,
20520,
796,
37250,
301,
3541,
25,
11498,
17041,
20520,
198,
220,
220,
220,
6460,
17816,
18594,
6592,
17,
13,
2302,
5736,
20520,
796,
37250,
9078,
20255,
62,
12384,
8002,
13,
18594,
6592,
17,
2302,
25,
13908,
8002,
11627,
3004,
20520,
198,
220,
220,
220,
4566,
13,
17256,
10786,
9078,
20255,
62,
18594,
6592,
17,
11537,
198,
220,
220,
220,
4566,
13,
41509,
3419,
628,
220,
220,
220,
1303,
1355,
3110,
8398,
198,
220,
220,
220,
6460,
13,
2617,
12286,
10786,
29891,
13,
4906,
3256,
705,
44453,
11537,
198,
220,
220,
220,
6460,
13,
2617,
12286,
10786,
29891,
13,
4023,
8807,
3256,
705,
7942,
11537,
198,
220,
220,
220,
4566,
13,
2617,
62,
29891,
62,
69,
9548,
7,
29891,
62,
69,
9548,
62,
6738,
62,
33692,
7,
33692,
4008,
198,
220,
220,
220,
4566,
13,
2617,
62,
12286,
62,
6359,
41871,
62,
25811,
7,
46115,
62,
6359,
41871,
28,
17821,
11,
11241,
28,
14202,
8,
628,
220,
220,
220,
1303,
5345,
44563,
422,
2858,
7885,
329,
1957,
2478,
198,
220,
220,
220,
611,
705,
2257,
1268,
56,
62,
2885,
44,
20913,
6,
287,
28686,
13,
268,
2268,
25,
198,
220,
220,
220,
220,
220,
220,
220,
329,
3053,
287,
355,
4868,
7,
418,
13,
268,
2268,
17816,
2257,
1268,
56,
62,
2885,
44,
20913,
20520,
2599,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
3053,
796,
3487,
1096,
62,
12888,
7,
12888,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
6460,
17816,
18439,
2637,
1343,
3053,
60,
796,
705,
28482,
6,
628,
220,
220,
220,
1303,
5345,
10650,
422,
2858,
7885,
329,
1957,
2478,
198,
220,
220,
220,
611,
705,
2257,
1268,
56,
62,
38,
35409,
4694,
6,
287,
28686,
13,
268,
2268,
25,
198,
220,
220,
220,
220,
220,
220,
220,
329,
3053,
287,
355,
4868,
7,
418,
13,
268,
2268,
17816,
2257,
1268,
56,
62,
38,
35409,
4694,
20520,
2599,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
3053,
796,
3487,
1096,
62,
12888,
7,
12888,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
6460,
17816,
18439,
2637,
1343,
3053,
60,
796,
705,
403,
5354,
6,
628,
220,
220,
220,
1303,
6093,
2581,
5050,
198,
220,
220,
220,
4566,
13,
2860,
62,
25927,
62,
24396,
28264,
18224,
11,
1438,
11639,
18224,
11537,
198,
220,
220,
220,
4566,
13,
2860,
62,
25927,
62,
24396,
28264,
40225,
62,
18224,
11,
1438,
11639,
40225,
62,
18224,
11537,
198,
220,
220,
220,
4566,
13,
2860,
62,
25927,
62,
24396,
7,
50033,
374,
11,
1635,
64,
11,
12429,
74,
25,
374,
13,
38629,
62,
6371,
10786,
15763,
3256,
1635,
64,
11,
12429,
74,
828,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1438,
11639,
15763,
6371,
11537,
198,
220,
220,
220,
4566,
13,
2860,
62,
25927,
62,
24396,
7,
50033,
374,
11,
334,
25,
4808,
18439,
62,
47423,
7,
84,
11,
374,
828,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1438,
11639,
7220,
62,
1050,
1939,
541,
874,
11537,
198,
220,
220,
220,
4566,
13,
2860,
62,
25927,
62,
24396,
7,
50033,
374,
25,
374,
13,
2301,
4592,
13,
33692,
13,
1136,
10786,
13297,
13,
16366,
62,
312,
33809,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1438,
11639,
13297,
62,
16366,
62,
312,
3256,
302,
1958,
28,
17821,
8,
628,
220,
220,
220,
4566,
13,
2301,
4592,
13,
4862,
62,
15526,
796,
355,
4868,
7,
33692,
13,
1136,
10786,
4862,
62,
15526,
3256,
17635,
4008,
628,
220,
220,
220,
4566,
13,
2860,
62,
12708,
62,
1177,
7,
3672,
11639,
12708,
3256,
3108,
11639,
301,
3541,
25,
12708,
3256,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
12940,
62,
9806,
62,
496,
28,
940,
1635,
21268,
1635,
1987,
1635,
3126,
1635,
3126,
8,
628,
220,
220,
220,
1303,
26828,
198,
220,
220,
220,
4566,
13,
2617,
62,
9800,
1634,
62,
30586,
7,
2246,
13534,
1457,
1634,
36727,
28955,
198,
220,
220,
220,
4566,
13,
2617,
62,
41299,
3299,
62,
30586,
7,
30515,
51,
21841,
47649,
3299,
36727,
7,
198,
220,
220,
220,
220,
220,
220,
220,
3200,
28,
33692,
17816,
18439,
83,
21841,
13,
21078,
6,
4357,
198,
220,
220,
220,
220,
220,
220,
220,
19751,
62,
3672,
28,
33692,
13,
1136,
10786,
18439,
13,
44453,
62,
3672,
3256,
705,
18439,
62,
83,
21841,
33809,
198,
220,
220,
220,
220,
220,
220,
220,
5713,
28,
292,
30388,
7,
33692,
13,
1136,
10786,
18439,
13,
22390,
3256,
10352,
36911,
198,
220,
220,
220,
220,
220,
220,
220,
26827,
28,
600,
7,
33692,
13,
1136,
10786,
18439,
13,
48678,
3256,
3126,
1635,
3126,
1635,
1987,
1635,
1542,
36911,
198,
220,
220,
220,
220,
220,
220,
220,
302,
21949,
62,
2435,
28,
600,
7,
33692,
13,
1136,
10786,
18439,
13,
260,
21949,
62,
2435,
3256,
3126,
1635,
3126,
1635,
1987,
1635,
1315,
36911,
198,
220,
220,
220,
220,
220,
220,
220,
3509,
62,
496,
28,
600,
7,
33692,
13,
1136,
10786,
18439,
13,
9806,
62,
496,
3256,
3126,
1635,
3126,
1635,
1987,
1635,
1542,
36911,
198,
220,
220,
220,
220,
220,
220,
220,
2638,
62,
8807,
28,
292,
30388,
7,
33692,
13,
1136,
10786,
18439,
13,
4023,
62,
8807,
3256,
6407,
36911,
198,
220,
220,
220,
220,
220,
220,
220,
12234,
14016,
11639,
26270,
25836,
3256,
198,
220,
220,
220,
220,
220,
220,
220,
23838,
28,
62,
18439,
62,
47423,
11,
198,
220,
220,
220,
15306,
198,
220,
220,
220,
4566,
13,
2617,
62,
12286,
62,
525,
3411,
10786,
12286,
11537,
628,
220,
220,
220,
1303,
26506,
198,
220,
220,
220,
4566,
13,
2301,
4592,
13,
38,
6684,
38,
2538,
62,
8845,
33,
62,
5097,
28495,
62,
2389,
796,
6460,
13,
2617,
12286,
7,
198,
220,
220,
220,
220,
220,
220,
220,
705,
13297,
13,
16366,
62,
312,
3256,
198,
220,
220,
220,
220,
220,
220,
220,
28686,
13,
268,
2268,
13,
1136,
10786,
2257,
1268,
56,
62,
39345,
62,
5097,
28495,
62,
38,
6684,
38,
2538,
62,
5097,
28495,
62,
2389,
6,
4008,
198,
220,
220,
220,
4382,
62,
16366,
62,
312,
796,
6460,
13,
1136,
10786,
13297,
13,
15388,
62,
16366,
62,
312,
11537,
198,
220,
220,
220,
611,
4382,
62,
16366,
62,
312,
318,
6045,
25,
198,
220,
220,
220,
220,
220,
220,
220,
4382,
62,
16366,
62,
312,
796,
28686,
13,
268,
2268,
17816,
2257,
1268,
56,
62,
35009,
5959,
62,
38,
6684,
38,
2538,
62,
5097,
28495,
62,
2389,
20520,
198,
220,
220,
220,
4566,
13,
2301,
4592,
13,
38,
6684,
38,
2538,
62,
5097,
28495,
62,
2389,
796,
4382,
62,
16366,
62,
312,
198,
220,
220,
220,
5456,
62,
21078,
796,
6460,
13,
1136,
10786,
13297,
13,
15388,
62,
16366,
62,
21078,
11537,
198,
220,
220,
220,
611,
5456,
62,
21078,
318,
6045,
25,
198,
220,
220,
220,
220,
220,
220,
220,
5456,
62,
21078,
796,
28686,
13,
268,
2268,
17816,
2257,
1268,
56,
62,
35009,
5959,
62,
38,
6684,
38,
2538,
62,
5097,
28495,
62,
23683,
26087,
20520,
198,
220,
220,
220,
2386,
62,
312,
796,
6460,
13,
1136,
10786,
13297,
13,
9948,
9239,
62,
312,
11537,
198,
220,
220,
220,
611,
2386,
62,
312,
318,
6045,
25,
198,
220,
220,
220,
220,
220,
220,
220,
2386,
62,
312,
796,
28686,
13,
268,
2268,
17816,
2257,
1268,
56,
62,
34,
1847,
62,
2389,
20520,
198,
220,
220,
220,
2386,
796,
26506,
7,
15388,
62,
16366,
62,
312,
11,
5456,
62,
21078,
11,
11845,
62,
312,
28,
9948,
62,
312,
8,
198,
220,
220,
220,
4566,
13,
2301,
4592,
13,
9948,
9239,
796,
2386,
198,
220,
220,
220,
4566,
13,
2860,
62,
25927,
62,
24396,
7,
50033,
374,
25,
374,
13,
2301,
4592,
13,
9948,
9239,
11,
705,
9948,
3256,
302,
1958,
28,
17821,
8,
628,
220,
220,
220,
665,
346,
952,
62,
30001,
796,
6460,
13,
1136,
10786,
4246,
346,
952,
13,
18439,
62,
30001,
11537,
198,
220,
220,
220,
611,
665,
346,
952,
62,
30001,
318,
6045,
25,
198,
220,
220,
220,
220,
220,
220,
220,
665,
346,
952,
62,
30001,
796,
28686,
13,
268,
2268,
17816,
2257,
1268,
56,
62,
34551,
4146,
9399,
62,
32,
24318,
62,
10468,
43959,
20520,
198,
220,
220,
220,
4566,
13,
2301,
4592,
13,
4246,
346,
952,
62,
12102,
1352,
796,
19390,
47139,
1352,
7,
4246,
346,
952,
62,
30001,
8,
198,
220,
220,
220,
4566,
13,
2860,
62,
25927,
62,
24396,
28264,
12102,
378,
62,
4246,
346,
952,
11,
1438,
11639,
12102,
378,
62,
4246,
346,
952,
11537,
628,
220,
220,
220,
4566,
13,
2860,
62,
25927,
62,
24396,
28264,
13345,
62,
28816,
11,
1438,
11639,
13345,
62,
28816,
11537,
628,
220,
220,
220,
4566,
13,
35836,
3419,
628,
198,
4299,
1388,
7,
11250,
11,
12429,
33692,
2599,
198,
220,
220,
220,
37227,
770,
2163,
5860,
257,
41450,
25290,
18878,
3586,
13,
198,
220,
220,
220,
37227,
198,
220,
220,
220,
4566,
796,
17056,
333,
1352,
7,
33692,
28,
33692,
8,
198,
220,
220,
220,
4566,
13,
17256,
10786,
301,
3541,
11537,
198,
220,
220,
220,
1441,
4566,
13,
15883,
62,
18504,
12397,
62,
1324,
3419,
198
] | 2.552425 | 2,804 |
"""
Creates a URL to search jobs on specific filters.
"""
from typing import Dict, Union
import config
experience = {
'No': 'noExperience',
'1-3': 'between1And3',
'3-6': 'between3And6',
'More 6': 'moreThan6'
}
areas = {
'Moscow': '1',
'StPetersburg': '2',
'Krasnodar': '53'
}
| [
37811,
198,
16719,
274,
257,
10289,
284,
2989,
3946,
319,
2176,
16628,
13,
198,
37811,
198,
198,
6738,
19720,
1330,
360,
713,
11,
4479,
198,
198,
11748,
4566,
198,
198,
23100,
1240,
796,
1391,
198,
220,
220,
220,
705,
2949,
10354,
705,
3919,
44901,
3256,
198,
220,
220,
220,
705,
16,
12,
18,
10354,
705,
23395,
16,
1870,
18,
3256,
198,
220,
220,
220,
705,
18,
12,
21,
10354,
705,
23395,
18,
1870,
21,
3256,
198,
220,
220,
220,
705,
5167,
718,
10354,
705,
3549,
817,
272,
21,
6,
198,
92,
198,
198,
533,
292,
796,
1391,
198,
220,
220,
220,
705,
49757,
10354,
705,
16,
3256,
198,
220,
220,
220,
705,
1273,
47,
7307,
7423,
10354,
705,
17,
3256,
198,
220,
220,
220,
705,
42,
8847,
77,
375,
283,
10354,
705,
4310,
6,
198,
92,
628
] | 2.255474 | 137 |
from beaker.cache import cache_region as Cache, region_invalidate as Invalidate
from Houdini.Handlers import Handlers, XT
from Houdini.Handlers.Play.Moderation import cheatBan
from Houdini.Data.Penguin import Inventory
cardStarterDeckId = 821
fireBoosterDeckId = 8006
waterBoosterDeckId = 8010
boosterDecks = {
cardStarterDeckId: [1, 6, 9, 14, 17, 20, 22, 23, 26, 73, 89, 81],
fireBoosterDeckId: [3, 18, 216, 222, 229, 303, 304, 314, 319, 250, 352],
waterBoosterDeckId: [202, 204, 305, 15, 13, 312, 218, 220, 29, 90]
}
@Handlers.Handle(XT.BuyInventory)
@Handlers.Handle(XT.GetInventory)
@Handlers.Throttle(-1)
@Cache('houdini', 'pins')
@Cache('houdini', 'awards')
@Handlers.Handle(XT.GetPlayerPins)
@Handlers.Throttle()
@Handlers.Handle(XT.GetPlayerAwards)
@Handlers.Throttle() | [
6738,
307,
3110,
13,
23870,
1330,
12940,
62,
36996,
355,
34088,
11,
3814,
62,
259,
12102,
378,
355,
17665,
378,
198,
198,
6738,
367,
2778,
5362,
13,
12885,
8116,
1330,
7157,
8116,
11,
44235,
198,
6738,
367,
2778,
5362,
13,
12885,
8116,
13,
11002,
13,
5841,
263,
341,
1330,
22705,
30457,
198,
6738,
367,
2778,
5362,
13,
6601,
13,
47,
13561,
259,
1330,
35772,
198,
198,
9517,
1273,
2571,
5005,
694,
7390,
796,
807,
2481,
198,
6495,
16635,
6197,
5005,
694,
7390,
796,
10460,
21,
198,
7050,
16635,
6197,
5005,
694,
7390,
796,
807,
20943,
198,
198,
2127,
6197,
10707,
591,
796,
1391,
198,
220,
220,
220,
2657,
1273,
2571,
5005,
694,
7390,
25,
685,
16,
11,
718,
11,
860,
11,
1478,
11,
1596,
11,
1160,
11,
2534,
11,
2242,
11,
2608,
11,
8854,
11,
9919,
11,
9773,
4357,
198,
220,
220,
220,
2046,
16635,
6197,
5005,
694,
7390,
25,
685,
18,
11,
1248,
11,
26881,
11,
27795,
11,
31064,
11,
30727,
11,
31672,
11,
34085,
11,
40385,
11,
8646,
11,
44063,
4357,
198,
220,
220,
220,
1660,
16635,
6197,
5005,
694,
7390,
25,
685,
19004,
11,
26956,
11,
32747,
11,
1315,
11,
1511,
11,
34465,
11,
29217,
11,
15629,
11,
2808,
11,
4101,
60,
198,
92,
198,
198,
31,
12885,
8116,
13,
37508,
7,
25010,
13,
14518,
818,
17158,
8,
198,
198,
31,
12885,
8116,
13,
37508,
7,
25010,
13,
3855,
818,
17158,
8,
198,
31,
12885,
8116,
13,
817,
305,
23296,
32590,
16,
8,
628,
198,
31,
30562,
10786,
71,
2778,
5362,
3256,
705,
49556,
11537,
628,
198,
31,
30562,
10786,
71,
2778,
5362,
3256,
705,
707,
1371,
11537,
628,
198,
31,
12885,
8116,
13,
37508,
7,
25010,
13,
3855,
14140,
47,
1040,
8,
198,
31,
12885,
8116,
13,
817,
305,
23296,
3419,
628,
198,
31,
12885,
8116,
13,
37508,
7,
25010,
13,
3855,
14140,
32,
2017,
8,
198,
31,
12885,
8116,
13,
817,
305,
23296,
3419
] | 2.514107 | 319 |
from flask import Flask, request, render_template, redirect, url_for, flash, abort, send_from_directory
from flask_bootstrap import Bootstrap
from flask_ckeditor import CKEditor
from datetime import date
from werkzeug.security import generate_password_hash, check_password_hash
from flask_sqlalchemy import SQLAlchemy
from sqlalchemy.orm import relationship
from flask_login import UserMixin, login_user, LoginManager, current_user, logout_user
from forms import SettingsForm, CreatePostForm, RegisterForm, LoginForm, CommentForm
from flask_gravatar import Gravatar
from functools import wraps
import os
import requests
from errors import *
from wallpapers import WALLPAPERS
from dotenv import load_dotenv
from PyPDF2 import PdfFileMerger, PdfFileReader
import os
import requests
from random import choice
import json
from flask_weasyprint import HTML, render_pdf, CSS
from time import sleep
load_dotenv()
# ==================================================================================================================== #
HASHING_METHOD = "pbkdf2:sha256"
SALT_TIMES = 8
APP_SECRET_KEY = os.environ.get("APP_SECRET_KEY")
DATABASE_URL = os.environ.get("DATABASE_URL", "sqlite:///blog.db")
NEWS_API_KEY = os.environ.get("NEWS_API_KEY")
ENDPOINT = "http://newsapi.org/v2/top-headlines"
DEFAULT_BG = "https://images.unsplash.com/photo-1464802686167-b939a6910659?crop=entropy&cs=srgb&fm=jpg&ixid" \
"=MnwyMTQyMTB8MHwxfHNlYXJjaHwxfHxzcGFjZXxlbnwwfDB8fHwxNjE1ODQzNjk2&ixlib=rb-1.2.1&q=85"
wallpapers = [wallpaper["urls"]["regular"] for wallpaper in WALLPAPERS[:50]]
# ==================================================================================================================== #
app = Flask(__name__)
app.config['SECRET_KEY'] = APP_SECRET_KEY
ckeditor = CKEditor(app)
Bootstrap(app)
# ==================================================================================================================== #
# CONNECT TO DB
app.config['SQLALCHEMY_DATABASE_URI'] = DATABASE_URL
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
db = SQLAlchemy(app)
# ==================================================================================================================== #
gravatar = Gravatar(app,
size=100,
rating='g',
default='retro',
force_default=False,
force_lower=False,
use_ssl=False,
base_url=None)
# ==================================================================================================================== #
login_manager = LoginManager()
login_manager.init_app(app)
# ==================================================================================================================== #
# Functions
# ==================================================================================================================== #
# CONFIGURE TABLES
# ==================================================================================================================== #
@login_manager.user_loader
# db.create_all()
# ==================================================================================================================== #
@app.route('/register', methods=["GET", "POST"])
@app.route('/login', methods=["GET", "POST"])
@app.route('/logout')
@app.route("/delete_user/<user_id>", methods=["POST", "GET"])
@app.route("/user-settings/<int:user_id>", methods=["POST", "GET"])
@app.route("/transfer_to_settings")
@app.route("/setwallpaper/<int:wallpaper_number>")
@app.route("/magazine", methods=["GET", "POST"])
# ==================================================================================================================== #
# Home page
featured_posts = get_top_news()
@app.route("/")
@app.route("/refresh-news")
@app.route("/flash-news")
# ==================================================================================================================== #
@app.route('/blog')
@app.route("/blog/post/<int:post_id>", methods=["GET", "POST"])
@app.route("/blog/new-post", methods=["POST", "GET"])
@admin_only
# ==================================================================================================================== #
# ==================================================================================================================== #
# ==================================================================================================================== #
# Admin Panel #
# ==================================================================================================================== #
# ==================================================================================================================== #
# ==================================================================================================================== #
@app.route("/admin_panel")
@admin_only
@app.route("/acess/<acess_type>/<action>/<user_id>")
@admin_only
@app.route("/edit-post/<int:post_id>", methods=["GET", "POST"])
@admin_only
@app.route("/delete/<int:post_id>")
@admin_only
# ==================================================================================================================== #
# ==================================================================================================================== #
# ==================================================================================================================== #
# ==================================================================================================================== #
# ==================================================================================================================== #
# ==================================================================================================================== #
# ==================================================================================================================== #
# Not found pages
@app.errorhandler(404)
@app.errorhandler(403)
@app.errorhandler(500)
# ==================================================================================================================== #
if __name__ == "__main__":
app.run(debug=True)
| [
6738,
42903,
1330,
46947,
11,
2581,
11,
8543,
62,
28243,
11,
18941,
11,
19016,
62,
1640,
11,
7644,
11,
15614,
11,
3758,
62,
6738,
62,
34945,
201,
198,
6738,
42903,
62,
18769,
26418,
1330,
18892,
26418,
201,
198,
6738,
42903,
62,
694,
35352,
1330,
327,
7336,
67,
2072,
201,
198,
6738,
4818,
8079,
1330,
3128,
201,
198,
6738,
266,
9587,
2736,
1018,
13,
12961,
1330,
7716,
62,
28712,
62,
17831,
11,
2198,
62,
28712,
62,
17831,
201,
198,
6738,
42903,
62,
25410,
282,
26599,
1330,
16363,
2348,
26599,
201,
198,
6738,
44161,
282,
26599,
13,
579,
1330,
2776,
201,
198,
6738,
42903,
62,
38235,
1330,
11787,
35608,
259,
11,
17594,
62,
7220,
11,
23093,
13511,
11,
1459,
62,
7220,
11,
2604,
448,
62,
7220,
201,
198,
6738,
5107,
1330,
16163,
8479,
11,
13610,
6307,
8479,
11,
17296,
8479,
11,
23093,
8479,
11,
18957,
8479,
201,
198,
6738,
42903,
62,
70,
4108,
9459,
1330,
32599,
9459,
201,
198,
6738,
1257,
310,
10141,
1330,
27521,
201,
198,
11748,
28686,
201,
198,
11748,
7007,
201,
198,
6738,
8563,
1330,
1635,
201,
198,
6738,
3355,
40491,
1330,
370,
7036,
47,
2969,
4877,
201,
198,
6738,
16605,
24330,
1330,
3440,
62,
26518,
24330,
201,
198,
6738,
9485,
20456,
17,
1330,
350,
7568,
8979,
13102,
1362,
11,
350,
7568,
8979,
33634,
201,
198,
11748,
28686,
201,
198,
11748,
7007,
201,
198,
6738,
4738,
1330,
3572,
201,
198,
11748,
33918,
201,
198,
6738,
42903,
62,
732,
4107,
4798,
1330,
11532,
11,
8543,
62,
12315,
11,
17391,
201,
198,
6738,
640,
1330,
3993,
201,
198,
201,
198,
2220,
62,
26518,
24330,
3419,
201,
198,
201,
198,
2,
38093,
10052,
4770,
18604,
1303,
201,
198,
39,
11211,
2751,
62,
49273,
796,
366,
40842,
74,
7568,
17,
25,
26270,
11645,
1,
201,
198,
50,
31429,
62,
51,
3955,
1546,
796,
807,
201,
198,
201,
198,
24805,
62,
23683,
26087,
62,
20373,
796,
28686,
13,
268,
2268,
13,
1136,
7203,
24805,
62,
23683,
26087,
62,
20373,
4943,
201,
198,
35,
1404,
6242,
11159,
62,
21886,
796,
28686,
13,
268,
2268,
13,
1136,
7203,
35,
1404,
6242,
11159,
62,
21886,
1600,
366,
25410,
578,
1378,
14,
14036,
13,
9945,
4943,
201,
198,
49597,
62,
17614,
62,
20373,
796,
28686,
13,
268,
2268,
13,
1136,
7203,
49597,
62,
17614,
62,
20373,
4943,
201,
198,
1677,
6322,
46,
12394,
796,
366,
4023,
1378,
10827,
15042,
13,
2398,
14,
85,
17,
14,
4852,
12,
2256,
6615,
1,
201,
198,
7206,
38865,
62,
40469,
796,
366,
5450,
1378,
17566,
13,
13271,
489,
1077,
13,
785,
14,
23074,
12,
1415,
2414,
1795,
2075,
4521,
21940,
12,
65,
24,
2670,
64,
3388,
940,
36445,
30,
31476,
28,
298,
28338,
5,
6359,
28,
27891,
22296,
5,
38353,
28,
9479,
5,
844,
312,
1,
3467,
201,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
28,
44,
77,
21768,
13752,
48,
88,
13752,
33,
23,
36208,
86,
26152,
39,
45,
75,
56,
55,
41,
6592,
39,
86,
26152,
39,
87,
89,
66,
21713,
73,
40692,
87,
75,
9374,
1383,
69,
11012,
23,
69,
39,
49345,
45,
73,
36,
16,
3727,
48,
89,
45,
73,
74,
17,
5,
844,
8019,
28,
26145,
12,
16,
13,
17,
13,
16,
5,
80,
28,
5332,
1,
201,
198,
201,
198,
11930,
40491,
796,
685,
11930,
20189,
14692,
6371,
82,
1,
7131,
1,
16338,
8973,
329,
39328,
287,
370,
7036,
47,
2969,
4877,
58,
25,
1120,
11907,
201,
198,
2,
38093,
10052,
4770,
18604,
1303,
201,
198,
1324,
796,
46947,
7,
834,
3672,
834,
8,
201,
198,
1324,
13,
11250,
17816,
23683,
26087,
62,
20373,
20520,
796,
43504,
62,
23683,
26087,
62,
20373,
201,
198,
694,
35352,
796,
327,
7336,
67,
2072,
7,
1324,
8,
201,
198,
36476,
26418,
7,
1324,
8,
201,
198,
2,
38093,
10052,
4770,
18604,
1303,
201,
198,
2,
7102,
48842,
5390,
20137,
201,
198,
1324,
13,
11250,
17816,
17861,
1847,
3398,
3620,
56,
62,
35,
1404,
6242,
11159,
62,
47269,
20520,
796,
360,
1404,
6242,
11159,
62,
21886,
201,
198,
1324,
13,
11250,
17816,
17861,
1847,
3398,
3620,
56,
62,
5446,
8120,
62,
33365,
30643,
18421,
20520,
796,
10352,
201,
198,
9945,
796,
16363,
2348,
26599,
7,
1324,
8,
201,
198,
2,
38093,
10052,
4770,
18604,
1303,
201,
198,
201,
198,
70,
4108,
9459,
796,
32599,
9459,
7,
1324,
11,
201,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2546,
28,
3064,
11,
201,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
7955,
11639,
70,
3256,
201,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
4277,
11639,
1186,
305,
3256,
201,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2700,
62,
12286,
28,
25101,
11,
201,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2700,
62,
21037,
28,
25101,
11,
201,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
779,
62,
45163,
28,
25101,
11,
201,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2779,
62,
6371,
28,
14202,
8,
201,
198,
201,
198,
2,
38093,
10052,
4770,
18604,
1303,
201,
198,
201,
198,
201,
198,
38235,
62,
37153,
796,
23093,
13511,
3419,
201,
198,
38235,
62,
37153,
13,
15003,
62,
1324,
7,
1324,
8,
201,
198,
201,
198,
201,
198,
2,
38093,
10052,
4770,
18604,
1303,
201,
198,
2,
40480,
201,
198,
201,
198,
201,
198,
201,
198,
201,
198,
201,
198,
2,
38093,
10052,
4770,
18604,
1303,
201,
198,
2,
25626,
11335,
309,
6242,
28378,
201,
198,
201,
198,
201,
198,
201,
198,
201,
198,
201,
198,
2,
38093,
10052,
4770,
18604,
1303,
201,
198,
201,
198,
201,
198,
31,
38235,
62,
37153,
13,
7220,
62,
29356,
201,
198,
201,
198,
201,
198,
2,
20613,
13,
17953,
62,
439,
3419,
201,
198,
201,
198,
201,
198,
2,
38093,
10052,
4770,
18604,
1303,
201,
198,
201,
198,
201,
198,
31,
1324,
13,
38629,
10786,
14,
30238,
3256,
5050,
28,
14692,
18851,
1600,
366,
32782,
8973,
8,
201,
198,
201,
198,
201,
198,
31,
1324,
13,
38629,
10786,
14,
38235,
3256,
5050,
28,
14692,
18851,
1600,
366,
32782,
8973,
8,
201,
198,
201,
198,
201,
198,
31,
1324,
13,
38629,
10786,
14,
6404,
448,
11537,
201,
198,
201,
198,
201,
198,
31,
1324,
13,
38629,
7203,
14,
33678,
62,
7220,
14,
27,
7220,
62,
312,
29,
1600,
5050,
28,
14692,
32782,
1600,
366,
18851,
8973,
8,
201,
198,
201,
198,
201,
198,
31,
1324,
13,
38629,
7203,
14,
7220,
12,
33692,
14,
27,
600,
25,
7220,
62,
312,
29,
1600,
5050,
28,
14692,
32782,
1600,
366,
18851,
8973,
8,
201,
198,
201,
198,
201,
198,
31,
1324,
13,
38629,
7203,
14,
39437,
62,
1462,
62,
33692,
4943,
201,
198,
201,
198,
201,
198,
31,
1324,
13,
38629,
7203,
14,
2617,
11930,
20189,
14,
27,
600,
25,
11930,
20189,
62,
17618,
29,
4943,
201,
198,
201,
198,
201,
198,
31,
1324,
13,
38629,
7203,
14,
19726,
4994,
1600,
5050,
28,
14692,
18851,
1600,
366,
32782,
8973,
8,
201,
198,
201,
198,
201,
198,
2,
38093,
10052,
4770,
18604,
1303,
201,
198,
201,
198,
2,
5995,
2443,
201,
198,
69,
20980,
62,
24875,
796,
651,
62,
4852,
62,
10827,
3419,
201,
198,
201,
198,
201,
198,
31,
1324,
13,
38629,
7203,
14,
4943,
201,
198,
201,
198,
201,
198,
31,
1324,
13,
38629,
7203,
14,
5420,
3447,
12,
10827,
4943,
201,
198,
201,
198,
201,
198,
31,
1324,
13,
38629,
7203,
14,
34167,
12,
10827,
4943,
201,
198,
201,
198,
201,
198,
2,
38093,
10052,
4770,
18604,
1303,
201,
198,
201,
198,
31,
1324,
13,
38629,
10786,
14,
14036,
11537,
201,
198,
201,
198,
201,
198,
31,
1324,
13,
38629,
7203,
14,
14036,
14,
7353,
14,
27,
600,
25,
7353,
62,
312,
29,
1600,
5050,
28,
14692,
18851,
1600,
366,
32782,
8973,
8,
201,
198,
201,
198,
201,
198,
31,
1324,
13,
38629,
7203,
14,
14036,
14,
3605,
12,
7353,
1600,
5050,
28,
14692,
32782,
1600,
366,
18851,
8973,
8,
201,
198,
31,
28482,
62,
8807,
201,
198,
201,
198,
201,
198,
2,
38093,
10052,
4770,
18604,
1303,
201,
198,
2,
38093,
10052,
4770,
18604,
1303,
201,
198,
2,
38093,
10052,
4770,
18604,
1303,
201,
198,
2,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
32053,
18810,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1303,
201,
198,
2,
38093,
10052,
4770,
18604,
1303,
201,
198,
2,
38093,
10052,
4770,
18604,
1303,
201,
198,
2,
38093,
10052,
4770,
18604,
1303,
201,
198,
31,
1324,
13,
38629,
7203,
14,
28482,
62,
35330,
4943,
201,
198,
31,
28482,
62,
8807,
201,
198,
201,
198,
201,
198,
31,
1324,
13,
38629,
7203,
14,
330,
408,
14,
27,
330,
408,
62,
4906,
29,
14,
27,
2673,
29,
14,
27,
7220,
62,
312,
29,
4943,
201,
198,
31,
28482,
62,
8807,
201,
198,
201,
198,
201,
198,
31,
1324,
13,
38629,
7203,
14,
19312,
12,
7353,
14,
27,
600,
25,
7353,
62,
312,
29,
1600,
5050,
28,
14692,
18851,
1600,
366,
32782,
8973,
8,
201,
198,
31,
28482,
62,
8807,
201,
198,
201,
198,
201,
198,
31,
1324,
13,
38629,
7203,
14,
33678,
14,
27,
600,
25,
7353,
62,
312,
29,
4943,
201,
198,
31,
28482,
62,
8807,
201,
198,
201,
198,
201,
198,
2,
38093,
10052,
4770,
18604,
1303,
201,
198,
2,
38093,
10052,
4770,
18604,
1303,
201,
198,
2,
38093,
10052,
4770,
18604,
1303,
201,
198,
2,
38093,
10052,
4770,
18604,
1303,
201,
198,
2,
38093,
10052,
4770,
18604,
1303,
201,
198,
2,
38093,
10052,
4770,
18604,
1303,
201,
198,
2,
38093,
10052,
4770,
18604,
1303,
201,
198,
201,
198,
2,
1892,
1043,
5468,
201,
198,
31,
1324,
13,
18224,
30281,
7,
26429,
8,
201,
198,
201,
198,
201,
198,
31,
1324,
13,
18224,
30281,
7,
31552,
8,
201,
198,
201,
198,
201,
198,
31,
1324,
13,
18224,
30281,
7,
4059,
8,
201,
198,
201,
198,
201,
198,
2,
38093,
10052,
4770,
18604,
1303,
201,
198,
361,
11593,
3672,
834,
6624,
366,
834,
12417,
834,
1298,
201,
198,
220,
220,
220,
598,
13,
5143,
7,
24442,
28,
17821,
8,
201,
198
] | 3.58114 | 1,824 |
import os
import yaml
folders = []
files = []
for entry in os.scandir('./lambda_functions/source/'):
if entry.is_dir():
if "asset." not in entry.path:
print("WARN: Skipping path...")
else:
folders.append(entry.path)
templateStream = open('./templates/AwsBiotechBlueprint.template.yml', 'r')
templateData = yaml.safe_load(templateStream)
taskcatConfigStream = open('./.taskcat.yml', 'r')
taskcatConfig = yaml.safe_load(taskcatConfigStream)
for assetFolder in folders:
assetFolderComponents = assetFolder.split('asset.')
assetId = assetFolderComponents[1]
for parameter in templateData['Parameters']:
if assetId in parameter:
if 'S3Bucket' in parameter:
templateData['Parameters'][parameter]['Default'] = "aws-quickstart"
taskcatConfig['tests']['default']['parameters'][parameter] = '$[taskcat_autobucket]'
templateData['Conditions'][f'UsingDefaultQuickstartBucket{assetId}'] = {
"Fn::Equals" : [{"Ref" : parameter}, "aws-quickstart"]
}
if 'VersionKey' in parameter:
templateData['Parameters'][parameter]['Default'] = f"quickstart-aws-biotech-blueprint-cdk/lambda_functions/packages/asset{assetId}/||lambda.zip"
taskcatConfig['tests']['default']['parameters'][parameter] = f"quickstart-aws-biotech-blueprint-cdk/lambda_functions/packages/asset{assetId}/||lambda.zip"
if 'ArtifactHash' in parameter:
templateData['Parameters'][parameter]['Default'] = assetId
taskcatConfig['tests']['default']['parameters'][parameter] = assetId
for resource in templateData['Resources']:
resourceType = templateData['Resources'][resource]['Type']
if resourceType == 'AWS::Lambda::Function':
if "S3Bucket" in templateData['Resources'][resource]['Properties']['Code']:
if assetId in templateData['Resources'][resource]['Properties']['Code']['S3Bucket']['Ref']:
bucketParamName = templateData['Resources'][resource]['Properties']['Code']['S3Bucket']['Ref']
templateData['Resources'][resource]['Properties']['Code']['S3Bucket'] = {
"Fn::If": [f'UsingDefaultQuickstartBucket{assetId}', { "Fn::Join" : ['-', [ {"Ref": bucketParamName} , {"Ref": 'AWS::Region'} ] ] } , {"Ref": bucketParamName}]
}
os.replace(assetFolder, f"./lambda_functions/source/asset{assetId}")
with open('./templates/AwsBiotechBlueprint.template.quickstart.yml', 'w') as yaml_file:
yaml_file.write( yaml.dump(templateData, default_flow_style=False))
with open('./.taskcat.yml', 'w') as yaml_file:
yaml_file.write( yaml.dump(taskcatConfig, default_flow_style=False)) | [
11748,
28686,
198,
11748,
331,
43695,
220,
198,
198,
11379,
364,
796,
17635,
198,
16624,
796,
17635,
198,
1640,
5726,
287,
28686,
13,
1416,
392,
343,
7,
4458,
14,
50033,
62,
12543,
2733,
14,
10459,
14,
6,
2599,
198,
220,
220,
220,
611,
5726,
13,
271,
62,
15908,
33529,
628,
220,
220,
220,
220,
220,
220,
220,
611,
366,
562,
316,
526,
407,
287,
5726,
13,
6978,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
3601,
7203,
37771,
25,
3661,
4501,
3108,
9313,
8,
198,
220,
220,
220,
220,
220,
220,
220,
2073,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
24512,
13,
33295,
7,
13000,
13,
6978,
8,
198,
198,
28243,
12124,
796,
1280,
7,
4458,
14,
11498,
17041,
14,
32,
18504,
23286,
32469,
14573,
4798,
13,
28243,
13,
88,
4029,
3256,
705,
81,
11537,
198,
28243,
6601,
796,
331,
43695,
13,
21230,
62,
2220,
7,
28243,
12124,
8,
198,
198,
35943,
9246,
16934,
12124,
796,
1280,
7,
4458,
11757,
35943,
9246,
13,
88,
4029,
3256,
705,
81,
11537,
198,
35943,
9246,
16934,
796,
331,
43695,
13,
21230,
62,
2220,
7,
35943,
9246,
16934,
12124,
8,
628,
198,
1640,
11171,
41092,
287,
24512,
25,
198,
220,
220,
220,
220,
198,
220,
220,
220,
11171,
41092,
7293,
3906,
796,
11171,
41092,
13,
35312,
10786,
562,
316,
2637,
8,
198,
220,
220,
220,
220,
198,
220,
220,
220,
11171,
7390,
796,
11171,
41092,
7293,
3906,
58,
16,
60,
198,
220,
220,
220,
220,
628,
220,
220,
220,
329,
11507,
287,
11055,
6601,
17816,
48944,
6,
5974,
198,
220,
220,
220,
220,
220,
220,
220,
611,
11171,
7390,
287,
11507,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
611,
705,
50,
18,
33,
38811,
6,
287,
11507,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
11055,
6601,
17816,
48944,
6,
7131,
17143,
2357,
7131,
6,
19463,
20520,
796,
366,
8356,
12,
24209,
9688,
1,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
4876,
9246,
16934,
17816,
41989,
6,
7131,
6,
12286,
6,
7131,
6,
17143,
7307,
6,
7131,
17143,
2357,
60,
796,
705,
3,
58,
35943,
9246,
62,
2306,
672,
38811,
49946,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
11055,
6601,
17816,
25559,
1756,
6,
7131,
69,
6,
12814,
19463,
21063,
9688,
33,
38811,
90,
562,
316,
7390,
92,
20520,
796,
1391,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
37,
77,
3712,
23588,
874,
1,
1058,
685,
4895,
8134,
1,
1058,
11507,
5512,
366,
8356,
12,
24209,
9688,
8973,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1782,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
611,
705,
14815,
9218,
6,
287,
11507,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
11055,
6601,
17816,
48944,
6,
7131,
17143,
2357,
7131,
6,
19463,
20520,
796,
277,
1,
24209,
9688,
12,
8356,
12,
8482,
32469,
12,
17585,
4798,
12,
10210,
74,
14,
50033,
62,
12543,
2733,
14,
43789,
14,
562,
316,
90,
562,
316,
7390,
92,
14,
15886,
50033,
13,
13344,
1,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
4876,
9246,
16934,
17816,
41989,
6,
7131,
6,
12286,
6,
7131,
6,
17143,
7307,
6,
7131,
17143,
2357,
60,
796,
277,
1,
24209,
9688,
12,
8356,
12,
8482,
32469,
12,
17585,
4798,
12,
10210,
74,
14,
50033,
62,
12543,
2733,
14,
43789,
14,
562,
316,
90,
562,
316,
7390,
92,
14,
15886,
50033,
13,
13344,
1,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
611,
705,
8001,
29660,
26257,
6,
287,
11507,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
11055,
6601,
17816,
48944,
6,
7131,
17143,
2357,
7131,
6,
19463,
20520,
796,
11171,
7390,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
4876,
9246,
16934,
17816,
41989,
6,
7131,
6,
12286,
6,
7131,
6,
17143,
7307,
6,
7131,
17143,
2357,
60,
796,
11171,
7390,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
198,
220,
220,
220,
220,
198,
220,
220,
220,
329,
8271,
287,
11055,
6601,
17816,
33236,
6,
5974,
198,
220,
220,
220,
220,
220,
220,
220,
8271,
6030,
796,
11055,
6601,
17816,
33236,
6,
7131,
31092,
7131,
6,
6030,
20520,
198,
220,
220,
220,
220,
220,
220,
220,
611,
8271,
6030,
6624,
705,
12298,
50,
3712,
43,
4131,
6814,
3712,
22203,
10354,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
611,
366,
50,
18,
33,
38811,
1,
287,
11055,
6601,
17816,
33236,
6,
7131,
31092,
7131,
6,
2964,
18200,
6,
7131,
6,
10669,
6,
5974,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
611,
11171,
7390,
287,
11055,
6601,
17816,
33236,
6,
7131,
31092,
7131,
6,
2964,
18200,
6,
7131,
6,
10669,
6,
7131,
6,
50,
18,
33,
38811,
6,
7131,
6,
8134,
6,
5974,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
19236,
22973,
5376,
796,
11055,
6601,
17816,
33236,
6,
7131,
31092,
7131,
6,
2964,
18200,
6,
7131,
6,
10669,
6,
7131,
6,
50,
18,
33,
38811,
6,
7131,
6,
8134,
20520,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
11055,
6601,
17816,
33236,
6,
7131,
31092,
7131,
6,
2964,
18200,
6,
7131,
6,
10669,
6,
7131,
6,
50,
18,
33,
38811,
20520,
796,
1391,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
37,
77,
3712,
1532,
1298,
685,
69,
6,
12814,
19463,
21063,
9688,
33,
38811,
90,
562,
316,
7390,
92,
3256,
1391,
366,
37,
77,
3712,
18234,
1,
1058,
685,
29001,
3256,
685,
19779,
8134,
1298,
19236,
22973,
5376,
92,
837,
19779,
8134,
1298,
705,
12298,
50,
3712,
47371,
6,
92,
2361,
2361,
1782,
837,
19779,
8134,
1298,
19236,
22973,
5376,
92,
60,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1782,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
628,
220,
220,
220,
198,
220,
220,
220,
220,
198,
220,
220,
220,
28686,
13,
33491,
7,
562,
316,
41092,
11,
277,
1911,
14,
50033,
62,
12543,
2733,
14,
10459,
14,
562,
316,
90,
562,
316,
7390,
92,
4943,
628,
220,
220,
220,
220,
198,
4480,
1280,
7,
4458,
14,
11498,
17041,
14,
32,
18504,
23286,
32469,
14573,
4798,
13,
28243,
13,
24209,
9688,
13,
88,
4029,
3256,
705,
86,
11537,
355,
331,
43695,
62,
7753,
25,
198,
220,
220,
220,
331,
43695,
62,
7753,
13,
13564,
7,
331,
43695,
13,
39455,
7,
28243,
6601,
11,
4277,
62,
11125,
62,
7635,
28,
25101,
4008,
198,
220,
220,
220,
220,
198,
198,
4480,
1280,
7,
4458,
11757,
35943,
9246,
13,
88,
4029,
3256,
705,
86,
11537,
355,
331,
43695,
62,
7753,
25,
198,
220,
220,
220,
331,
43695,
62,
7753,
13,
13564,
7,
331,
43695,
13,
39455,
7,
35943,
9246,
16934,
11,
4277,
62,
11125,
62,
7635,
28,
25101,
4008
] | 2.156764 | 1,397 |
import os
import uuid
from azure.storage.blob import BlobServiceClient
| [
198,
11748,
28686,
198,
11748,
334,
27112,
198,
198,
6738,
35560,
495,
13,
35350,
13,
2436,
672,
1330,
1086,
672,
16177,
11792,
198
] | 3.173913 | 23 |
from .cnmf import napari_experimental_provide_dock_widget | [
6738,
764,
66,
21533,
69,
1330,
25422,
2743,
62,
23100,
9134,
62,
15234,
485,
62,
67,
735,
62,
42655
] | 3 | 19 |
# -*- coding: utf-8 -*-
"""
Created on Thu Jul 16 08:39:36 2020
@author: abhi0
"""
| [
2,
532,
9,
12,
19617,
25,
3384,
69,
12,
23,
532,
9,
12,
201,
198,
37811,
201,
198,
41972,
319,
26223,
5979,
1467,
8487,
25,
2670,
25,
2623,
12131,
201,
198,
201,
198,
31,
9800,
25,
450,
5303,
15,
201,
198,
37811,
201
] | 2.069767 | 43 |
# web_app/__init__.py
from flask import Flask
import os
from dotenv import load_dotenv
from web_app.routes.home_routes import home_routes
from web_app.routes.stats_routes import stats_routes
if __name__ == "__main__":
my_app = create_app()
my_app.run(debug=True)
| [
2,
3992,
62,
1324,
14,
834,
15003,
834,
13,
9078,
198,
6738,
42903,
1330,
46947,
198,
11748,
28686,
198,
6738,
16605,
24330,
1330,
3440,
62,
26518,
24330,
198,
198,
6738,
3992,
62,
1324,
13,
81,
448,
274,
13,
11195,
62,
81,
448,
274,
1330,
1363,
62,
81,
448,
274,
198,
6738,
3992,
62,
1324,
13,
81,
448,
274,
13,
34242,
62,
81,
448,
274,
1330,
9756,
62,
81,
448,
274,
628,
198,
198,
361,
11593,
3672,
834,
6624,
366,
834,
12417,
834,
1298,
198,
220,
220,
220,
616,
62,
1324,
796,
2251,
62,
1324,
3419,
198,
220,
220,
220,
616,
62,
1324,
13,
5143,
7,
24442,
28,
17821,
8,
198
] | 2.5 | 110 |
import numpy as np
import tensorflow as tf
from PIL import Image
import glob
import os
# import tensorflow.contrib.slim as slim
import tensorflow.keras as keras
def get_feature_extracting_model(input_tensor=None,input_shape=(480,640,3),model_name='resnet50',layer_index=[6,38,80,142,174]):
"""
input_shape : the input size of the image
model_name : which backbone model to be used for feature extraction
layer_names : the names of the layer from which the outputs are to be returned
Return: keras model with outputs of the given layers for the given model
**Note** : Currently only works for resnet, and layer_names provided should be valid, for resnet50 the
results from the last layer of each block are returned
"""
if model_name=='resnet50':
model_i = keras.applications.ResNet50(include_top=False,weights='imagenet',input_tensor=input_tensor,input_shape=input_shape,pooling=None)
else:
print("Currently only support for resnet50")
return
C = []
for i in layer_index:
C.append(model_i.get_layer(model_i.layers[i].name).output)
# model = keras.models.Model(inputs = model_i.input,outputs=C)
return C | [
11748,
299,
32152,
355,
45941,
198,
11748,
11192,
273,
11125,
355,
48700,
198,
6738,
350,
4146,
1330,
7412,
198,
11748,
15095,
198,
11748,
28686,
198,
2,
1330,
11192,
273,
11125,
13,
3642,
822,
13,
82,
2475,
355,
18862,
198,
11748,
11192,
273,
11125,
13,
6122,
292,
355,
41927,
292,
198,
198,
4299,
651,
62,
30053,
62,
2302,
974,
278,
62,
19849,
7,
15414,
62,
83,
22854,
28,
14202,
11,
15414,
62,
43358,
16193,
22148,
11,
31102,
11,
18,
828,
19849,
62,
3672,
11639,
411,
3262,
1120,
3256,
29289,
62,
9630,
41888,
21,
11,
2548,
11,
1795,
11,
23726,
11,
22985,
60,
2599,
198,
220,
220,
220,
37227,
198,
220,
220,
220,
5128,
62,
43358,
1058,
262,
5128,
2546,
286,
262,
2939,
220,
198,
220,
220,
220,
2746,
62,
3672,
1058,
543,
32774,
2746,
284,
307,
973,
329,
3895,
22236,
198,
220,
220,
220,
7679,
62,
14933,
1058,
262,
3891,
286,
262,
7679,
422,
543,
262,
23862,
389,
284,
307,
4504,
198,
220,
220,
220,
8229,
25,
41927,
292,
2746,
351,
23862,
286,
262,
1813,
11685,
329,
262,
1813,
2746,
198,
220,
220,
220,
12429,
6425,
1174,
1058,
16888,
691,
2499,
329,
581,
3262,
11,
290,
7679,
62,
14933,
2810,
815,
307,
4938,
11,
329,
581,
3262,
1120,
262,
220,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2482,
422,
262,
938,
7679,
286,
1123,
2512,
389,
4504,
198,
220,
220,
220,
37227,
198,
220,
220,
220,
611,
2746,
62,
3672,
855,
6,
411,
3262,
1120,
10354,
198,
220,
220,
220,
220,
220,
220,
220,
2746,
62,
72,
796,
41927,
292,
13,
1324,
677,
602,
13,
4965,
7934,
1120,
7,
17256,
62,
4852,
28,
25101,
11,
43775,
11639,
320,
11286,
316,
3256,
15414,
62,
83,
22854,
28,
15414,
62,
83,
22854,
11,
15414,
62,
43358,
28,
15414,
62,
43358,
11,
7742,
278,
28,
14202,
8,
198,
220,
220,
220,
2073,
25,
198,
220,
220,
220,
220,
220,
220,
220,
3601,
7203,
21327,
691,
1104,
329,
581,
3262,
1120,
4943,
198,
220,
220,
220,
220,
220,
220,
220,
1441,
198,
220,
220,
220,
327,
796,
17635,
198,
220,
220,
220,
329,
1312,
287,
7679,
62,
9630,
25,
198,
220,
220,
220,
220,
220,
220,
220,
327,
13,
33295,
7,
19849,
62,
72,
13,
1136,
62,
29289,
7,
19849,
62,
72,
13,
75,
6962,
58,
72,
4083,
3672,
737,
22915,
8,
198,
220,
220,
220,
1303,
2746,
796,
41927,
292,
13,
27530,
13,
17633,
7,
15414,
82,
796,
2746,
62,
72,
13,
15414,
11,
22915,
82,
28,
34,
8,
198,
220,
220,
220,
1441,
327
] | 2.804196 | 429 |
#!/usr/bin/env python
# Copyright (c) 2011 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Android system-wide tracing utility.
This is a tool for capturing a trace that includes data from both userland and
the kernel. It creates an HTML file for visualizing the trace.
"""
import errno, optparse, os, select, subprocess, sys, time, zlib, signal
import re
import tempfile
import math
import json
from regression import *
#from simple import *
#from simple1 import * # for testing this tester per se
"""
test configuration
"""
config_tput_min = 100
config_tput_max = 50000
config_tput_resolution = 100
config_output_timeout_sec = 10 # can be floating pt
config_max_runtime_sec = 60 # give up
"""
default args
"""
#config_default_cores = [4, 12, 32, 56]
config_default_records = 1000 * 1000 # records per epoch
'''
global vars
'''
the_output_dir = ""
"""
test cases
"""
"""
{
"name" : "grep",
"exec" : "./test-grep.bin",
#"cores" : [4, 12, 32, 56],
"cores" : [56],
"records" : 1000,
"record_size" : 2000,
"target_ms" : 1000,
"input_file" : "/ssd/1g.txt",
# --- optional --- #
"tput_hint" : 4000,
},
"""
"""
app_list = [
"test-grep",
"test-wc",
"test-wingrep",
"test-join",
"test-join-2",
"networklatency",
"test-distinct",
"test-tweet"
]
"""
"""
sample line:
dump markers: >>>>>>>>>>>>>>>>>>>>>>>>>>>>total 7 ms
# return: delay in ms
"""
"""
sample line (for backward compatibility; future sources should have same name):
unbounded-inmem 19.07 19.07 19.53 19.53
[unbounded] 20.35 20.35 2604.17 2604.17
[netsource] 31.79 31.79 813.80 813.80
return: tput in krec/s (floating)
"""
# stateless
# @delays: a list of all historical delays
# return:
DECIDE_FAIL = 1 # failed. abort.
DECIDE_CONT = 2 # should continue
DECIDE_OK = 3 # target_delay is met
#DECIDE_DUNNO = 4 # can't decide yet
DECIDE_EXCEPTION = 5 # what happened?
decide_descs = ["", "fail", "cont", "ok", "dunno", "exception"]
# XXX catch c-c signal to ensure all test programs killed XXX
is_stop = False
'''
return (status, tput)
tput is floating pt. <0 if none achieved
'''
# @core == -1 if unspecified on cmdline
# return: actual_tput
# XXX only support one core now. but that's fine
if __name__ == '__main__':
signal.signal(signal.SIGINT, stop_test_handler)
the_output_dir = tempfile.mkdtemp()
# results will be inserted in place into @all_tests
''' check & print all test info '''
test_names = {}
# detect duplicate test names
for test in all_tests:
if test_names.has_key(test["name"]):
print >> sys.stderr, "abort: duplicate test names:", test["name"];
sys.exit(1)
test_names[test["name"]] = 1 # remember to check duplicates
if test.has_key("softdelay_maxbad_ms") and test["softdelay_maxbad_ms"] < test["target_ms"]:
print >> sys.stderr, "abort: config err: [%s] softdelay maxbad ms < target ms" %test["name"]
sys.exit(-1)
''' print menu '''
print "========================================"
print "select tests to run (enter to run all)"
for i, test in enumerate(all_tests):
print i, test["name"];
try:
choice = int(raw_input('Enter your input:'))
print "Okay ... Will run test", all_tests[choice]["name"]
all_tests = [all_tests[choice]]
except ValueError:
print "Okay ... Will run all tests."
for test in all_tests:
atput = launch_one_test(test)
if atput < 0:
print "%s exception: can't get the tput." %test["name"]
test["actual_tput"] = -1 # is this okay?
else:
test["actual_tput"] = atput
print "%s completes: actual tput %d krec/s target_delay %d ms" %(test["name"], atput, test["target_ms"])
print "========================================"
print "%20s %10s %10s %10s %6s %15s" %("test", "target_ms", "tput/krecs", "base/krecs", "improve%", "elapsed/sec")
for test in all_tests:
tput_inc = -999.99
tput_inc_str = "--"
tput_baseline_str = "--"
if test.has_key("disable") and test["disable"]:
#if not test.has_key("elapsed_sec"): # test never executed?
print "%10s -- skipped -- " %(test["name"])
continue
if test.has_key("tput_baseline"):
tput_inc = 100.0 * (test["actual_tput"] - test["tput_baseline"]) / test["tput_baseline"]
tput_inc_str = "%.2f" %(tput_inc)
tput_baseline_str = "%d" %(test["tput_baseline"])
#print "baseline is", test["tput_baseline"]
print "%20s %10d %10d %10s %6s %15.2f" \
%(test["name"], test["target_ms"], test["actual_tput"], tput_baseline_str, tput_inc_str, test["elapsed_sec"])
print "========================================"
print "diff=-999 means no baseline provided"
print "all done. check result dir:\n ls ", the_output_dir
| [
2,
48443,
14629,
14,
8800,
14,
24330,
21015,
198,
198,
2,
15069,
357,
66,
8,
2813,
383,
18255,
1505,
46665,
13,
1439,
2489,
10395,
13,
198,
2,
5765,
286,
428,
2723,
2438,
318,
21825,
416,
257,
347,
10305,
12,
7635,
5964,
326,
460,
307,
198,
2,
1043,
287,
262,
38559,
24290,
2393,
13,
198,
198,
37811,
25934,
1080,
12,
4421,
35328,
10361,
13,
198,
198,
1212,
318,
257,
2891,
329,
21430,
257,
12854,
326,
3407,
1366,
422,
1111,
2836,
1044,
290,
198,
1169,
9720,
13,
197,
1026,
8075,
281,
11532,
2393,
329,
5874,
2890,
262,
12854,
13,
198,
37811,
198,
198,
11748,
11454,
3919,
11,
2172,
29572,
11,
28686,
11,
2922,
11,
850,
14681,
11,
25064,
11,
640,
11,
1976,
8019,
11,
6737,
198,
11748,
302,
198,
11748,
20218,
7753,
198,
11748,
10688,
198,
11748,
33918,
198,
198,
6738,
20683,
1330,
1635,
198,
2,
6738,
2829,
1330,
1635,
198,
2,
6738,
2829,
16,
1330,
1635,
197,
197,
2,
329,
4856,
428,
256,
7834,
583,
384,
198,
198,
37811,
198,
9288,
8398,
198,
37811,
198,
11250,
62,
83,
1996,
62,
1084,
796,
1802,
198,
11250,
62,
83,
1996,
62,
9806,
796,
642,
2388,
198,
11250,
62,
83,
1996,
62,
29268,
796,
1802,
198,
11250,
62,
22915,
62,
48678,
62,
2363,
796,
838,
220,
1303,
460,
307,
12462,
42975,
198,
11250,
62,
9806,
62,
43282,
62,
2363,
796,
3126,
220,
197,
2,
1577,
510,
220,
198,
198,
37811,
198,
12286,
26498,
198,
37811,
198,
2,
11250,
62,
12286,
62,
66,
2850,
796,
685,
19,
11,
1105,
11,
3933,
11,
7265,
60,
198,
11250,
62,
12286,
62,
8344,
3669,
796,
8576,
1635,
8576,
197,
2,
4406,
583,
36835,
198,
198,
7061,
6,
198,
20541,
410,
945,
198,
7061,
6,
198,
1169,
62,
22915,
62,
15908,
796,
13538,
198,
198,
37811,
198,
9288,
2663,
198,
37811,
198,
198,
37811,
198,
197,
90,
198,
197,
197,
1,
3672,
1,
1058,
366,
70,
7856,
1600,
198,
197,
197,
1,
18558,
1,
1058,
366,
19571,
9288,
12,
70,
7856,
13,
8800,
1600,
220,
198,
197,
197,
2,
1,
66,
2850,
1,
1058,
685,
19,
11,
1105,
11,
3933,
11,
7265,
4357,
198,
197,
197,
1,
66,
2850,
1,
1058,
685,
3980,
4357,
198,
197,
197,
1,
8344,
3669,
1,
1058,
8576,
11,
198,
197,
197,
1,
22105,
62,
7857,
1,
1058,
4751,
11,
198,
197,
197,
1,
16793,
62,
907,
1,
1058,
8576,
11,
198,
197,
197,
1,
15414,
62,
7753,
1,
1058,
12813,
824,
67,
14,
16,
70,
13,
14116,
1600,
198,
197,
197,
2,
11420,
11902,
11420,
1303,
198,
197,
197,
1,
83,
1996,
62,
71,
600,
1,
1058,
30123,
11,
220,
198,
197,
5512,
198,
37811,
198,
198,
37811,
198,
1324,
62,
4868,
796,
685,
198,
197,
197,
1,
9288,
12,
70,
7856,
1600,
220,
198,
197,
197,
1,
9288,
12,
86,
66,
1600,
198,
197,
197,
1,
9288,
12,
5469,
7856,
1600,
198,
197,
197,
1,
9288,
12,
22179,
1600,
198,
197,
197,
1,
9288,
12,
22179,
12,
17,
1600,
198,
197,
197,
1,
27349,
15460,
1387,
1600,
198,
197,
197,
1,
9288,
12,
17080,
4612,
1600,
198,
197,
197,
1,
9288,
12,
83,
7277,
1,
198,
197,
197,
60,
198,
37811,
198,
198,
37811,
198,
39873,
1627,
25,
198,
39455,
19736,
25,
13163,
33717,
33717,
33717,
29,
23350,
767,
13845,
198,
2,
1441,
25,
5711,
287,
13845,
198,
37811,
198,
198,
37811,
198,
39873,
1627,
357,
1640,
19528,
17764,
26,
2003,
4237,
815,
423,
976,
1438,
2599,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
22619,
6302,
12,
259,
11883,
220,
220,
220,
220,
678,
13,
2998,
220,
220,
220,
220,
678,
13,
2998,
220,
220,
220,
220,
678,
13,
4310,
220,
220,
220,
220,
678,
13,
4310,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
685,
403,
65,
6302,
60,
220,
220,
220,
220,
1160,
13,
2327,
220,
220,
220,
220,
1160,
13,
2327,
220,
220,
21148,
19,
13,
1558,
220,
220,
21148,
19,
13,
1558,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
685,
45938,
1668,
60,
220,
220,
220,
220,
3261,
13,
3720,
220,
220,
220,
220,
3261,
13,
3720,
220,
220,
220,
807,
1485,
13,
1795,
220,
220,
220,
807,
1485,
13,
1795,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
198,
7783,
25,
256,
1996,
287,
479,
8344,
14,
82,
357,
48679,
803,
8,
198,
37811,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
198,
198,
2,
1181,
1203,
220,
198,
2,
2488,
12381,
592,
25,
257,
1351,
286,
477,
6754,
16119,
198,
2,
1441,
25,
220,
198,
198,
41374,
14114,
62,
7708,
4146,
220,
197,
28,
352,
197,
197,
2,
4054,
13,
15614,
13,
198,
41374,
14114,
62,
37815,
220,
197,
28,
362,
197,
197,
2,
815,
2555,
198,
41374,
14114,
62,
11380,
220,
197,
28,
513,
197,
197,
2,
2496,
62,
40850,
318,
1138,
198,
2,
41374,
14114,
62,
35,
4944,
15285,
220,
197,
28,
604,
197,
197,
2,
460,
470,
5409,
1865,
198,
41374,
14114,
62,
6369,
42006,
2849,
220,
197,
28,
642,
197,
197,
2,
644,
3022,
30,
198,
198,
12501,
485,
62,
20147,
82,
796,
14631,
1600,
366,
32165,
1600,
366,
3642,
1600,
366,
482,
1600,
366,
67,
403,
3919,
1600,
366,
1069,
4516,
8973,
198,
198,
2,
27713,
4929,
269,
12,
66,
6737,
284,
4155,
477,
1332,
4056,
2923,
27713,
198,
198,
271,
62,
11338,
796,
10352,
198,
198,
7061,
6,
198,
7783,
357,
13376,
11,
256,
1996,
8,
198,
83,
1996,
318,
12462,
42975,
13,
1279,
15,
611,
4844,
8793,
198,
7061,
6,
198,
198,
2,
2488,
7295,
6624,
532,
16,
611,
29547,
319,
23991,
1370,
198,
198,
2,
1441,
25,
4036,
62,
83,
1996,
198,
2,
27713,
691,
1104,
530,
4755,
783,
13,
475,
326,
338,
3734,
198,
197,
198,
197,
197,
198,
361,
11593,
3672,
834,
6624,
705,
834,
12417,
834,
10354,
198,
197,
12683,
282,
13,
12683,
282,
7,
12683,
282,
13,
50,
3528,
12394,
11,
2245,
62,
9288,
62,
30281,
8,
198,
197,
198,
197,
1169,
62,
22915,
62,
15908,
796,
20218,
7753,
13,
28015,
67,
29510,
3419,
198,
197,
198,
197,
2,
2482,
481,
307,
18846,
287,
1295,
656,
2488,
439,
62,
41989,
198,
197,
198,
197,
7061,
6,
2198,
1222,
3601,
477,
1332,
7508,
705,
7061,
198,
197,
9288,
62,
14933,
796,
23884,
198,
197,
2,
4886,
23418,
1332,
3891,
220,
198,
197,
1640,
1332,
287,
477,
62,
41989,
25,
198,
197,
197,
361,
1332,
62,
14933,
13,
10134,
62,
2539,
7,
9288,
14692,
3672,
8973,
2599,
198,
197,
197,
197,
4798,
9609,
25064,
13,
301,
1082,
81,
11,
366,
397,
419,
25,
23418,
1332,
3891,
25,
1600,
1332,
14692,
3672,
8973,
26,
198,
197,
197,
197,
17597,
13,
37023,
7,
16,
8,
198,
197,
197,
9288,
62,
14933,
58,
9288,
14692,
3672,
8973,
60,
796,
352,
220,
1303,
3505,
284,
2198,
14184,
16856,
198,
197,
198,
197,
197,
361,
1332,
13,
10134,
62,
2539,
7203,
4215,
40850,
62,
9806,
14774,
62,
907,
4943,
290,
1332,
14692,
4215,
40850,
62,
9806,
14774,
62,
907,
8973,
1279,
1332,
14692,
16793,
62,
907,
1,
5974,
198,
197,
197,
197,
4798,
9609,
25064,
13,
301,
1082,
81,
11,
366,
397,
419,
25,
4566,
11454,
25,
685,
4,
82,
60,
2705,
40850,
3509,
14774,
13845,
1279,
2496,
13845,
1,
4064,
9288,
14692,
3672,
8973,
198,
197,
197,
197,
17597,
13,
37023,
32590,
16,
8,
628,
197,
7061,
6,
3601,
6859,
705,
7061,
198,
197,
4798,
366,
10052,
2559,
1,
198,
197,
4798,
366,
19738,
5254,
284,
1057,
357,
9255,
284,
1057,
477,
16725,
198,
197,
1640,
1312,
11,
1332,
287,
27056,
378,
7,
439,
62,
41989,
2599,
198,
197,
197,
4798,
1312,
11,
1332,
14692,
3672,
8973,
26,
198,
197,
28311,
25,
198,
197,
197,
25541,
796,
493,
7,
1831,
62,
15414,
10786,
17469,
534,
5128,
32105,
4008,
198,
197,
197,
4798,
366,
16454,
2644,
2561,
1057,
1332,
1600,
477,
62,
41989,
58,
25541,
7131,
1,
3672,
8973,
198,
197,
197,
439,
62,
41989,
796,
685,
439,
62,
41989,
58,
25541,
11907,
198,
197,
16341,
11052,
12331,
25,
198,
197,
197,
4798,
366,
16454,
2644,
2561,
1057,
477,
5254,
526,
628,
197,
1640,
1332,
287,
477,
62,
41989,
25,
198,
197,
197,
265,
1996,
796,
4219,
62,
505,
62,
9288,
7,
9288,
8,
198,
197,
197,
361,
379,
1996,
1279,
657,
25,
198,
197,
197,
197,
4798,
36521,
82,
6631,
25,
460,
470,
651,
262,
256,
1996,
526,
4064,
9288,
14692,
3672,
8973,
198,
197,
197,
197,
9288,
14692,
50039,
62,
83,
1996,
8973,
796,
532,
16,
220,
1303,
318,
428,
8788,
30,
198,
197,
197,
17772,
25,
198,
197,
197,
197,
9288,
14692,
50039,
62,
83,
1996,
8973,
796,
379,
1996,
198,
197,
197,
197,
4798,
36521,
82,
32543,
25,
4036,
256,
1996,
4064,
67,
479,
8344,
14,
82,
2496,
62,
40850,
4064,
67,
13845,
1,
4064,
7,
9288,
14692,
3672,
33116,
379,
1996,
11,
1332,
14692,
16793,
62,
907,
8973,
8,
198,
197,
198,
197,
4798,
366,
10052,
2559,
1,
198,
197,
4798,
36521,
1238,
82,
4064,
940,
82,
4064,
940,
82,
4064,
940,
82,
4064,
21,
82,
4064,
1314,
82,
1,
4064,
7203,
9288,
1600,
366,
16793,
62,
907,
1600,
366,
83,
1996,
14,
74,
260,
6359,
1600,
366,
8692,
14,
74,
260,
6359,
1600,
366,
49453,
4,
1600,
366,
417,
28361,
14,
2363,
4943,
197,
198,
197,
1640,
1332,
287,
477,
62,
41989,
25,
198,
197,
197,
83,
1996,
62,
1939,
796,
532,
17032,
13,
2079,
198,
197,
197,
83,
1996,
62,
1939,
62,
2536,
796,
366,
438,
1,
198,
197,
197,
83,
1996,
62,
12093,
4470,
62,
2536,
796,
366,
438,
1,
198,
197,
197,
198,
197,
197,
361,
1332,
13,
10134,
62,
2539,
7203,
40223,
4943,
290,
1332,
14692,
40223,
1,
5974,
198,
197,
197,
2,
361,
407,
1332,
13,
10134,
62,
2539,
7203,
417,
28361,
62,
2363,
1,
2599,
1303,
1332,
1239,
10945,
30,
198,
197,
197,
197,
4798,
36521,
940,
82,
1377,
26684,
1377,
366,
4064,
7,
9288,
14692,
3672,
8973,
8,
198,
197,
197,
197,
43043,
198,
197,
197,
361,
1332,
13,
10134,
62,
2539,
7203,
83,
1996,
62,
12093,
4470,
1,
2599,
198,
197,
197,
197,
83,
1996,
62,
1939,
796,
1802,
13,
15,
1635,
357,
9288,
14692,
50039,
62,
83,
1996,
8973,
532,
1332,
14692,
83,
1996,
62,
12093,
4470,
8973,
8,
1220,
1332,
14692,
83,
1996,
62,
12093,
4470,
8973,
198,
197,
197,
197,
83,
1996,
62,
1939,
62,
2536,
796,
366,
7225,
17,
69,
1,
4064,
7,
83,
1996,
62,
1939,
8,
198,
197,
197,
197,
83,
1996,
62,
12093,
4470,
62,
2536,
796,
36521,
67,
1,
4064,
7,
9288,
14692,
83,
1996,
62,
12093,
4470,
8973,
8,
198,
197,
197,
197,
2,
4798,
366,
12093,
4470,
318,
1600,
1332,
14692,
83,
1996,
62,
12093,
4470,
8973,
198,
197,
197,
197,
198,
197,
197,
4798,
36521,
1238,
82,
4064,
940,
67,
4064,
940,
67,
4064,
940,
82,
4064,
21,
82,
4064,
1314,
13,
17,
69,
1,
220,
3467,
198,
197,
197,
197,
197,
4,
7,
9288,
14692,
3672,
33116,
1332,
14692,
16793,
62,
907,
33116,
1332,
14692,
50039,
62,
83,
1996,
33116,
256,
1996,
62,
12093,
4470,
62,
2536,
11,
256,
1996,
62,
1939,
62,
2536,
11,
1332,
14692,
417,
28361,
62,
2363,
8973,
8,
198,
197,
4798,
366,
10052,
2559,
1,
198,
197,
4798,
366,
26069,
10779,
17032,
1724,
645,
14805,
2810,
1,
198,
197,
198,
197,
4798,
366,
439,
1760,
13,
2198,
1255,
26672,
7479,
77,
43979,
33172,
262,
62,
22915,
62,
15908,
628,
198
] | 2.516883 | 1,925 |
import numpy as np # linear algebra
import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)
import matplotlib.pyplot as plt
from sklearn.feature_extraction.text import TfidfVectorizer, CountVectorizer
from sklearn.decomposition import TruncatedSVD
from sklearn import preprocessing, model_selection, metrics
import lightgbm as lgb
import gc
train_df = pd.read_csv('../input/train.csv', parse_dates=["activation_date"])
test_df = pd.read_csv('../input/test.csv', parse_dates=["activation_date"])
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
import seaborn as sns
import random
#x = train_df.copy()#[['price', 'deal_probability', 'image_top_1']]
train_df = genFeatures(train_df)
test_df = genFeatures(test_df)
groupCols = ['region', 'city', 'parent_category_name',
'category_name', 'user_type']
X = train_df[groupCols + ['deal_probability']].groupby(groupCols, as_index=False).agg([len,np.mean])
X.columns = ['_'.join(col).strip() for col in X.columns.values]
X['Group_weight1'] = (X.deal_probability_mean + 1e-6) * np.log1p(X.deal_probability_len)
X.drop(['deal_probability_mean', 'deal_probability_len'], axis = 1, inplace = True)
X.reset_index(inplace = True)
train_df = train_df.merge(X, on = groupCols, how = 'left')
test_df = test_df.merge(X, on = groupCols, how = 'left')
catCols = ['region', 'city', 'parent_category_name',
'category_name', 'param_1', 'param_2', 'param_3', 'user_type']
dftrainnum = train_df[list(set(train_df.columns)-set(catCols+['user_id']))]
dftestnum = test_df[list(set(test_df.columns)-set(catCols+['user_id']))]
train, test,= = catEncode(train_df[catCols].copy(), test_df[catCols].copy(), train_df.deal_probability.values, nbag = 10, nfold = 20, minCount = 1)
train_df = pd.concat((dftrainnum, train), axis =1)
test_df = pd.concat((dftestnum, test), axis =1)
del(dftrainnum, train); gc.collect()
del(dftestnum, test); gc.collect()
| [
11748,
299,
32152,
355,
45941,
1303,
14174,
37139,
198,
11748,
19798,
292,
355,
279,
67,
1303,
1366,
7587,
11,
44189,
2393,
314,
14,
46,
357,
68,
13,
70,
13,
279,
67,
13,
961,
62,
40664,
8,
198,
11748,
2603,
29487,
8019,
13,
9078,
29487,
355,
458,
83,
198,
198,
6738,
1341,
35720,
13,
30053,
62,
2302,
7861,
13,
5239,
1330,
309,
69,
312,
69,
38469,
7509,
11,
2764,
38469,
7509,
198,
6738,
1341,
35720,
13,
12501,
296,
9150,
1330,
833,
19524,
515,
50,
8898,
198,
6738,
1341,
35720,
1330,
662,
36948,
11,
2746,
62,
49283,
11,
20731,
198,
11748,
1657,
70,
20475,
355,
300,
22296,
198,
11748,
308,
66,
198,
198,
27432,
62,
7568,
796,
279,
67,
13,
961,
62,
40664,
10786,
40720,
15414,
14,
27432,
13,
40664,
3256,
220,
21136,
62,
19581,
28,
14692,
48545,
62,
4475,
8973,
8,
198,
9288,
62,
7568,
796,
279,
67,
13,
961,
62,
40664,
10786,
40720,
15414,
14,
9288,
13,
40664,
3256,
220,
21136,
62,
19581,
28,
14692,
48545,
62,
4475,
8973,
8,
198,
198,
11748,
2603,
29487,
8019,
13,
9078,
29487,
355,
458,
83,
198,
11748,
19798,
292,
355,
279,
67,
198,
11748,
299,
32152,
355,
45941,
220,
198,
11748,
384,
397,
1211,
355,
3013,
82,
198,
11748,
4738,
220,
198,
198,
2,
87,
796,
4512,
62,
7568,
13,
30073,
3419,
2,
58,
17816,
20888,
3256,
705,
31769,
62,
1676,
65,
1799,
3256,
705,
9060,
62,
4852,
62,
16,
6,
11907,
198,
220,
220,
220,
220,
198,
27432,
62,
7568,
796,
2429,
23595,
7,
27432,
62,
7568,
8,
198,
9288,
62,
7568,
796,
2429,
23595,
7,
9288,
62,
7568,
8,
198,
198,
8094,
5216,
82,
796,
37250,
36996,
3256,
705,
19205,
3256,
705,
8000,
62,
22872,
62,
3672,
3256,
198,
220,
220,
220,
220,
220,
220,
705,
22872,
62,
3672,
3256,
705,
7220,
62,
4906,
20520,
198,
55,
796,
4512,
62,
7568,
58,
8094,
5216,
82,
1343,
37250,
31769,
62,
1676,
65,
1799,
20520,
4083,
8094,
1525,
7,
8094,
5216,
82,
11,
355,
62,
9630,
28,
25101,
737,
9460,
26933,
11925,
11,
37659,
13,
32604,
12962,
198,
55,
13,
28665,
82,
796,
37250,
62,
4458,
22179,
7,
4033,
737,
36311,
3419,
329,
951,
287,
1395,
13,
28665,
82,
13,
27160,
60,
198,
55,
17816,
13247,
62,
6551,
16,
20520,
796,
357,
55,
13,
31769,
62,
1676,
65,
1799,
62,
32604,
1343,
352,
68,
12,
21,
8,
1635,
45941,
13,
6404,
16,
79,
7,
55,
13,
31769,
62,
1676,
65,
1799,
62,
11925,
8,
220,
198,
55,
13,
14781,
7,
17816,
31769,
62,
1676,
65,
1799,
62,
32604,
3256,
705,
31769,
62,
1676,
65,
1799,
62,
11925,
6,
4357,
16488,
796,
352,
11,
287,
5372,
796,
6407,
8,
198,
55,
13,
42503,
62,
9630,
7,
259,
5372,
796,
6407,
8,
198,
27432,
62,
7568,
796,
4512,
62,
7568,
13,
647,
469,
7,
55,
11,
319,
796,
1448,
5216,
82,
11,
703,
796,
705,
9464,
11537,
198,
9288,
62,
7568,
796,
1332,
62,
7568,
13,
647,
469,
7,
55,
11,
319,
796,
1448,
5216,
82,
11,
703,
796,
705,
9464,
11537,
628,
198,
9246,
5216,
82,
796,
37250,
36996,
3256,
705,
19205,
3256,
705,
8000,
62,
22872,
62,
3672,
3256,
198,
220,
220,
220,
220,
220,
220,
705,
22872,
62,
3672,
3256,
705,
17143,
62,
16,
3256,
705,
17143,
62,
17,
3256,
705,
17143,
62,
18,
3256,
705,
7220,
62,
4906,
20520,
198,
198,
67,
701,
3201,
22510,
796,
4512,
62,
7568,
58,
4868,
7,
2617,
7,
27432,
62,
7568,
13,
28665,
82,
13219,
2617,
7,
9246,
5216,
82,
10,
17816,
7220,
62,
312,
20520,
4008,
60,
198,
67,
701,
395,
22510,
796,
1332,
62,
7568,
58,
4868,
7,
2617,
7,
9288,
62,
7568,
13,
28665,
82,
13219,
2617,
7,
9246,
5216,
82,
10,
17816,
7220,
62,
312,
20520,
4008,
60,
198,
198,
27432,
11,
1332,
11,
28,
796,
3797,
4834,
8189,
7,
27432,
62,
7568,
58,
9246,
5216,
82,
4083,
30073,
22784,
1332,
62,
7568,
58,
9246,
5216,
82,
4083,
30073,
22784,
4512,
62,
7568,
13,
31769,
62,
1676,
65,
1799,
13,
27160,
11,
299,
21454,
796,
838,
11,
299,
11379,
796,
1160,
11,
949,
12332,
796,
352,
8,
198,
198,
27432,
62,
7568,
796,
279,
67,
13,
1102,
9246,
19510,
67,
701,
3201,
22510,
11,
4512,
828,
16488,
796,
16,
8,
198,
9288,
62,
7568,
796,
279,
67,
13,
1102,
9246,
19510,
67,
701,
395,
22510,
11,
1332,
828,
16488,
796,
16,
8,
198,
198,
12381,
7,
67,
701,
3201,
22510,
11,
4512,
1776,
308,
66,
13,
33327,
3419,
198,
12381,
7,
67,
701,
395,
22510,
11,
1332,
1776,
308,
66,
13,
33327,
3419,
628,
628,
198
] | 2.537255 | 765 |
# spec for webdriver processors
class WebDriverProcessor(object):
"""Allows outside users to have the final say on things like capabilities
that are used to instantiate WebDriver.
"""
def process_capabilities(self, capabilities):
"""Process capabilities passed in and return the final dict.
:type capabilities: dict
:rtype: dict
"""
pass
| [
2,
1020,
329,
3992,
26230,
20399,
198,
198,
4871,
5313,
32103,
18709,
273,
7,
15252,
2599,
198,
220,
220,
220,
37227,
34934,
2354,
2985,
284,
423,
262,
2457,
910,
319,
1243,
588,
9889,
198,
220,
220,
220,
326,
389,
973,
284,
9113,
9386,
5313,
32103,
13,
198,
220,
220,
220,
37227,
628,
220,
220,
220,
825,
1429,
62,
11128,
5738,
7,
944,
11,
9889,
2599,
198,
220,
220,
220,
220,
220,
220,
220,
37227,
18709,
9889,
3804,
287,
290,
1441,
262,
2457,
8633,
13,
198,
220,
220,
220,
220,
220,
220,
220,
1058,
4906,
9889,
25,
8633,
198,
220,
220,
220,
220,
220,
220,
220,
1058,
81,
4906,
25,
8633,
198,
220,
220,
220,
220,
220,
220,
220,
37227,
198,
220,
220,
220,
220,
220,
220,
220,
1208,
198
] | 3.069767 | 129 |
constants.physical_constants["atomic unit of electric field"] | [
9979,
1187,
13,
42854,
62,
9979,
1187,
14692,
47116,
4326,
286,
5186,
2214,
8973
] | 4.357143 | 14 |
# -*- coding: utf-8 -*-
from django.shortcuts import render_to_response
from django.http import HttpResponseServerError
from django.template import RequestContext
from freechess.models import ChessGame
from dateutil.relativedelta import relativedelta
import datetime
| [
2,
532,
9,
12,
19617,
25,
3384,
69,
12,
23,
532,
9,
12,
198,
6738,
42625,
14208,
13,
19509,
23779,
1330,
8543,
62,
1462,
62,
26209,
198,
6738,
42625,
14208,
13,
4023,
1330,
367,
29281,
31077,
10697,
12331,
198,
6738,
42625,
14208,
13,
28243,
1330,
19390,
21947,
198,
6738,
1479,
2395,
824,
13,
27530,
1330,
25774,
8777,
198,
6738,
3128,
22602,
13,
2411,
265,
1572,
12514,
1330,
48993,
1572,
12514,
198,
11748,
4818,
8079,
628
] | 3.573333 | 75 |
# Copyright 2018 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import datetime
import hashlib
from cli_tools.flakiness_cli import api
from cli_tools.flakiness_cli import frames
def GetBuilders():
"""Get the builders data frame and keep a cached copy."""
return frames.GetWithCache(
'builders.pkl', make_frame, expires_after=datetime.timedelta(hours=12))
def GetTestResults(master, builder, test_type):
"""Get a test results data frame and keep a cached copy."""
basename = hashlib.md5('/'.join([master, builder, test_type])).hexdigest()
return frames.GetWithCache(
basename + '.pkl', make_frame, expires_after=datetime.timedelta(hours=3))
| [
2,
15069,
2864,
383,
18255,
1505,
46665,
13,
1439,
2489,
10395,
13,
198,
2,
5765,
286,
428,
2723,
2438,
318,
21825,
416,
257,
347,
10305,
12,
7635,
5964,
326,
460,
307,
198,
2,
1043,
287,
262,
38559,
24290,
2393,
13,
198,
198,
11748,
4818,
8079,
198,
11748,
12234,
8019,
198,
198,
6738,
537,
72,
62,
31391,
13,
2704,
461,
1272,
62,
44506,
1330,
40391,
198,
6738,
537,
72,
62,
31391,
13,
2704,
461,
1272,
62,
44506,
1330,
13431,
628,
198,
4299,
3497,
15580,
364,
33529,
198,
220,
37227,
3855,
262,
31606,
1366,
5739,
290,
1394,
257,
39986,
4866,
526,
15931,
628,
220,
1441,
13431,
13,
3855,
3152,
30562,
7,
198,
220,
220,
220,
220,
220,
705,
50034,
13,
79,
41582,
3256,
787,
62,
14535,
11,
27396,
62,
8499,
28,
19608,
8079,
13,
16514,
276,
12514,
7,
24425,
28,
1065,
4008,
628,
198,
4299,
3497,
14402,
25468,
7,
9866,
11,
27098,
11,
1332,
62,
4906,
2599,
198,
220,
37227,
3855,
257,
1332,
2482,
1366,
5739,
290,
1394,
257,
39986,
4866,
526,
15931,
628,
220,
1615,
12453,
796,
12234,
8019,
13,
9132,
20,
10786,
14,
4458,
22179,
26933,
9866,
11,
27098,
11,
1332,
62,
4906,
12962,
737,
33095,
12894,
395,
3419,
198,
220,
1441,
13431,
13,
3855,
3152,
30562,
7,
198,
220,
220,
220,
220,
220,
1615,
12453,
1343,
45302,
79,
41582,
3256,
787,
62,
14535,
11,
27396,
62,
8499,
28,
19608,
8079,
13,
16514,
276,
12514,
7,
24425,
28,
18,
4008,
198
] | 3.186722 | 241 |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import json
from alipay.aop.api.response.AlipayResponse import AlipayResponse
from alipay.aop.api.domain.RpaCrawlerTaskVO import RpaCrawlerTaskVO
| [
2,
48443,
14629,
14,
8800,
14,
24330,
21015,
198,
2,
532,
9,
12,
19617,
25,
3384,
69,
12,
23,
532,
9,
12,
198,
11748,
33918,
198,
198,
6738,
435,
541,
323,
13,
64,
404,
13,
15042,
13,
26209,
13,
2348,
541,
323,
31077,
1330,
978,
541,
323,
31077,
198,
6738,
435,
541,
323,
13,
64,
404,
13,
15042,
13,
27830,
13,
49,
8957,
34,
39464,
25714,
29516,
1330,
371,
8957,
34,
39464,
25714,
29516,
628
] | 2.586667 | 75 |
# Copyright 2016 The Chromium Authors. All rights reserved.
# Use of this source code is govered by a BSD-style
# license that can be found in the LICENSE file or at
# https://developers.google.com/open-source/licenses/bsd
"""This file exists so that code in gRPC *_pb2.py files is importable.
The protoc compiler for gRPC .proto files produces Python code which contains
two separate code-paths. One codepath just requires importing grpc.py; the
other uses the beta interface. Since we are relying on the former codepath,
this file doesn't need to contain any actual implementation. It just needs
to contain the symbols that the _pb2.py file expects to find when it imports
the module.
"""
| [
2,
15069,
1584,
383,
18255,
1505,
46665,
13,
1439,
2489,
10395,
13,
198,
2,
5765,
286,
428,
2723,
2438,
318,
467,
21917,
416,
257,
347,
10305,
12,
7635,
198,
2,
5964,
326,
460,
307,
1043,
287,
262,
38559,
24290,
2393,
393,
379,
198,
2,
3740,
1378,
16244,
364,
13,
13297,
13,
785,
14,
9654,
12,
10459,
14,
677,
4541,
14,
1443,
67,
198,
198,
37811,
1212,
2393,
7160,
523,
326,
2438,
287,
308,
49,
5662,
1635,
62,
40842,
17,
13,
9078,
3696,
318,
1330,
540,
13,
198,
198,
464,
1237,
420,
17050,
329,
308,
49,
5662,
764,
1676,
1462,
3696,
11073,
11361,
2438,
543,
4909,
198,
11545,
4553,
2438,
12,
6978,
82,
13,
1881,
14873,
538,
776,
655,
4433,
33332,
1036,
14751,
13,
9078,
26,
262,
198,
847,
3544,
262,
12159,
7071,
13,
4619,
356,
389,
17965,
319,
262,
1966,
14873,
538,
776,
11,
198,
5661,
2393,
1595,
470,
761,
284,
3994,
597,
4036,
7822,
13,
632,
655,
2476,
198,
1462,
3994,
262,
14354,
326,
262,
4808,
40842,
17,
13,
9078,
2393,
13423,
284,
1064,
618,
340,
17944,
198,
1169,
8265,
13,
198,
37811,
628,
628
] | 3.741935 | 186 |
import requests
import argparse
import colorama
import os
import csv
import pandas as pd
from bs4 import BeautifulSoup as soup
if __name__ == '__main__':
colorama.init()
url = 'https://github.com'
parser = argparse.ArgumentParser(formatter_class=argparse.RawTextHelpFormatter,
description="Views Public Repositories of Users")
parser.add_argument('-c', '--clone', nargs='+',
metavar='CLONE', action='store',
help="Clones and Views Public Repositories from the user/s. (e.g -c KungPaoChick uname2 uname3)")
parser.add_argument('-u', '--username',
nargs='+', metavar='USERNAMES',
action='store',
help="Views Public Repositories from the user/s. (e.g -u KungPaoChick uname2 uname3)")
args = parser.parse_args()
if args.clone or args.username:
for name in args.username or args.clone:
if not os.path.exists(name):
os.mkdir(name)
conn(name, url)
| [
11748,
7007,
198,
11748,
1822,
29572,
198,
11748,
3124,
1689,
198,
11748,
28686,
198,
11748,
269,
21370,
198,
11748,
19798,
292,
355,
279,
67,
198,
6738,
275,
82,
19,
1330,
23762,
50,
10486,
355,
17141,
628,
628,
628,
198,
361,
11593,
3672,
834,
6624,
705,
834,
12417,
834,
10354,
198,
220,
220,
220,
3124,
1689,
13,
15003,
3419,
198,
220,
220,
220,
19016,
796,
705,
5450,
1378,
12567,
13,
785,
6,
198,
220,
220,
220,
30751,
796,
1822,
29572,
13,
28100,
1713,
46677,
7,
687,
1436,
62,
4871,
28,
853,
29572,
13,
27369,
8206,
22087,
8479,
1436,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
6764,
2625,
7680,
82,
5094,
1432,
35061,
286,
18987,
4943,
628,
220,
220,
220,
30751,
13,
2860,
62,
49140,
10786,
12,
66,
3256,
705,
438,
21018,
3256,
299,
22046,
11639,
10,
3256,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1138,
615,
283,
11639,
5097,
11651,
3256,
2223,
11639,
8095,
3256,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1037,
2625,
2601,
1952,
290,
29978,
5094,
1432,
35061,
422,
262,
2836,
14,
82,
13,
357,
68,
13,
70,
532,
66,
44753,
47,
5488,
1925,
624,
555,
480,
17,
555,
480,
18,
8,
4943,
628,
220,
220,
220,
30751,
13,
2860,
62,
49140,
10786,
12,
84,
3256,
705,
438,
29460,
3256,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
299,
22046,
11639,
10,
3256,
1138,
615,
283,
11639,
2937,
28778,
29559,
3256,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
2223,
11639,
8095,
3256,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1037,
2625,
7680,
82,
5094,
1432,
35061,
422,
262,
2836,
14,
82,
13,
357,
68,
13,
70,
532,
84,
44753,
47,
5488,
1925,
624,
555,
480,
17,
555,
480,
18,
8,
4943,
628,
220,
220,
220,
26498,
796,
30751,
13,
29572,
62,
22046,
3419,
198,
220,
220,
220,
611,
26498,
13,
21018,
393,
26498,
13,
29460,
25,
198,
220,
220,
220,
220,
220,
220,
220,
329,
1438,
287,
26498,
13,
29460,
393,
26498,
13,
21018,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
611,
407,
28686,
13,
6978,
13,
1069,
1023,
7,
3672,
2599,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
28686,
13,
28015,
15908,
7,
3672,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
48260,
7,
3672,
11,
19016,
8,
628
] | 2.138067 | 507 |
import pytest
from vakt.rules.string import PairsEqual, StringPairsEqualRule
@pytest.mark.parametrize('against, result', [
([[]], False),
([], True),
("not-list", False),
([['a']], False),
([['a', 'a']], True),
([['й', 'й']], True),
([[1, '1']], False),
([['1', 1]], False),
([[1, 1]], False),
([[1.0, 1.0]], False),
([['a', 'b']], False),
([['a', 'b', 'c']], False),
([['a', 'a'], ['b', 'b']], True),
([['a', 'a'], ['b', 'c']], False),
])
| [
11748,
12972,
9288,
198,
198,
6738,
410,
461,
83,
13,
38785,
13,
8841,
1330,
350,
3468,
36,
13255,
11,
10903,
47,
3468,
36,
13255,
31929,
628,
198,
31,
9078,
9288,
13,
4102,
13,
17143,
316,
380,
2736,
10786,
32826,
11,
1255,
3256,
685,
198,
220,
220,
220,
29565,
21737,
4357,
10352,
828,
198,
220,
220,
220,
29565,
4357,
6407,
828,
198,
220,
220,
220,
5855,
1662,
12,
4868,
1600,
10352,
828,
198,
220,
220,
220,
29565,
17816,
64,
20520,
4357,
10352,
828,
198,
220,
220,
220,
29565,
17816,
64,
3256,
705,
64,
20520,
4357,
6407,
828,
198,
220,
220,
220,
29565,
17816,
140,
117,
3256,
705,
140,
117,
20520,
4357,
6407,
828,
198,
220,
220,
220,
29565,
58,
16,
11,
705,
16,
20520,
4357,
10352,
828,
198,
220,
220,
220,
29565,
17816,
16,
3256,
352,
60,
4357,
10352,
828,
198,
220,
220,
220,
29565,
58,
16,
11,
352,
60,
4357,
10352,
828,
198,
220,
220,
220,
29565,
58,
16,
13,
15,
11,
352,
13,
15,
60,
4357,
10352,
828,
198,
220,
220,
220,
29565,
17816,
64,
3256,
705,
65,
20520,
4357,
10352,
828,
198,
220,
220,
220,
29565,
17816,
64,
3256,
705,
65,
3256,
705,
66,
20520,
4357,
10352,
828,
198,
220,
220,
220,
29565,
17816,
64,
3256,
705,
64,
6,
4357,
37250,
65,
3256,
705,
65,
20520,
4357,
6407,
828,
198,
220,
220,
220,
29565,
17816,
64,
3256,
705,
64,
6,
4357,
37250,
65,
3256,
705,
66,
20520,
4357,
10352,
828,
198,
12962,
198
] | 2.036735 | 245 |
from functools import reduce
from pathlib import Path
from code_scanner.enums import FileType
from code_scanner.file_info import FileInfo
from code_scanner.filter_utils import IFileFilter
| [
6738,
1257,
310,
10141,
1330,
4646,
198,
6738,
3108,
8019,
1330,
10644,
198,
6738,
2438,
62,
35836,
1008,
13,
268,
5700,
1330,
9220,
6030,
198,
6738,
2438,
62,
35836,
1008,
13,
7753,
62,
10951,
1330,
9220,
12360,
198,
6738,
2438,
62,
35836,
1008,
13,
24455,
62,
26791,
1330,
314,
8979,
22417,
628,
628,
198
] | 3.555556 | 54 |
# Generated by Django 3.2.8 on 2021-11-11 09:19
from django.db import migrations, models
import django.db.models.deletion
| [
2,
2980,
515,
416,
37770,
513,
13,
17,
13,
23,
319,
33448,
12,
1157,
12,
1157,
7769,
25,
1129,
198,
198,
6738,
42625,
14208,
13,
9945,
1330,
15720,
602,
11,
4981,
198,
11748,
42625,
14208,
13,
9945,
13,
27530,
13,
2934,
1616,
295,
628
] | 2.818182 | 44 |
import time
import numpy as np
import solver
board = np.array([
[0,0,0,0,9,0,8,2,3],
[0,8,0,0,3,2,0,7,5],
[3,0,2,5,8,0,4,9,0],
[0,2,7,0,0,0,0,0,4],
[0,9,0,2,1,4,0,8,0],
[4,0,0,0,0,0,2,0,0],
[0,4,0,0,7,1,0,0,2],
[2,0,0,9,4,0,0,5,0],
[0,0,6,0,2,5,0,4,0]
])
b = solver.SudokuSolver(board)
t1 = time.time()
b.solve()
t2 = time.time() - t1
assert b.valid_board()
print(f"Time: {t2} seconds")
print(f"Steps: {b.num_steps}")
print(b.board)
| [
11748,
640,
198,
198,
11748,
299,
32152,
355,
45941,
198,
198,
11748,
1540,
332,
628,
198,
3526,
796,
45941,
13,
18747,
26933,
198,
220,
220,
220,
685,
15,
11,
15,
11,
15,
11,
15,
11,
24,
11,
15,
11,
23,
11,
17,
11,
18,
4357,
198,
220,
220,
220,
685,
15,
11,
23,
11,
15,
11,
15,
11,
18,
11,
17,
11,
15,
11,
22,
11,
20,
4357,
198,
220,
220,
220,
685,
18,
11,
15,
11,
17,
11,
20,
11,
23,
11,
15,
11,
19,
11,
24,
11,
15,
4357,
198,
220,
220,
220,
685,
15,
11,
17,
11,
22,
11,
15,
11,
15,
11,
15,
11,
15,
11,
15,
11,
19,
4357,
198,
220,
220,
220,
685,
15,
11,
24,
11,
15,
11,
17,
11,
16,
11,
19,
11,
15,
11,
23,
11,
15,
4357,
198,
220,
220,
220,
685,
19,
11,
15,
11,
15,
11,
15,
11,
15,
11,
15,
11,
17,
11,
15,
11,
15,
4357,
198,
220,
220,
220,
685,
15,
11,
19,
11,
15,
11,
15,
11,
22,
11,
16,
11,
15,
11,
15,
11,
17,
4357,
198,
220,
220,
220,
685,
17,
11,
15,
11,
15,
11,
24,
11,
19,
11,
15,
11,
15,
11,
20,
11,
15,
4357,
198,
220,
220,
220,
685,
15,
11,
15,
11,
21,
11,
15,
11,
17,
11,
20,
11,
15,
11,
19,
11,
15,
60,
198,
12962,
198,
198,
65,
796,
1540,
332,
13,
50,
463,
11601,
50,
14375,
7,
3526,
8,
198,
198,
83,
16,
796,
640,
13,
2435,
3419,
198,
198,
65,
13,
82,
6442,
3419,
198,
198,
83,
17,
796,
640,
13,
2435,
3419,
532,
256,
16,
198,
198,
30493,
275,
13,
12102,
62,
3526,
3419,
198,
198,
4798,
7,
69,
1,
7575,
25,
1391,
83,
17,
92,
4201,
4943,
198,
4798,
7,
69,
1,
8600,
82,
25,
1391,
65,
13,
22510,
62,
20214,
92,
4943,
198,
4798,
7,
65,
13,
3526,
8,
198
] | 1.492212 | 321 |
#!/usr/bin/env python
# Root topic
rootTopic = "truck1"
# Broker configuration
mqttBroker = "192.168.1.126"
mqttPort = "1883"
mqttUser = " "
mqttPasswd = " "
# Components configuration
componentDic = {
"imuClass": "Imu",
"proximityClass": "ProximitySensor",
"motorClass": "Motor",
"cameraClass": "Camera"}
componentsSamplingIntevalInSeconds = {
"imuClass": 0.1,
"proximityClass": 0.4,
"motorClass": 10.0,
"cameraClass": 100.0}
| [
2,
48443,
14629,
14,
8800,
14,
24330,
21015,
198,
198,
2,
20410,
7243,
198,
15763,
33221,
796,
366,
83,
30915,
16,
1,
198,
198,
2,
2806,
6122,
8398,
198,
76,
80,
926,
15783,
6122,
796,
366,
17477,
13,
14656,
13,
16,
13,
19420,
1,
198,
76,
80,
926,
13924,
796,
366,
1507,
5999,
1,
198,
198,
76,
80,
926,
12982,
796,
366,
366,
198,
76,
80,
926,
14478,
16993,
796,
366,
366,
198,
198,
2,
36109,
8398,
198,
42895,
35,
291,
796,
1391,
198,
220,
220,
220,
366,
320,
84,
9487,
1298,
366,
3546,
84,
1600,
198,
220,
220,
220,
366,
1676,
87,
18853,
9487,
1298,
366,
2964,
87,
18853,
47864,
1600,
198,
220,
220,
220,
366,
76,
20965,
9487,
1298,
366,
34919,
1600,
198,
220,
220,
220,
366,
25695,
9487,
1298,
366,
35632,
20662,
198,
198,
5589,
3906,
16305,
11347,
5317,
18206,
818,
12211,
82,
796,
1391,
198,
220,
220,
220,
366,
320,
84,
9487,
1298,
657,
13,
16,
11,
198,
220,
220,
220,
366,
1676,
87,
18853,
9487,
1298,
657,
13,
19,
11,
198,
220,
220,
220,
366,
76,
20965,
9487,
1298,
838,
13,
15,
11,
198,
220,
220,
220,
366,
25695,
9487,
1298,
1802,
13,
15,
92,
198
] | 2.308458 | 201 |
import time
import RPi.GPIO as gpio
pin = 33
pin_wheel = 35
while True:
print 'go straight '
gpio.setmode(gpio.BOARD)
gpio.setup(pin, gpio.OUT)
gpio.setup(pin_wheel, gpio.OUT)
gpio.output(pin_wheel, gpio.HIGH)
p = gpio.PWM(pin, 400)
p.start(0)
dc = 10
for i in range(40):
dc += 2
print 'dc:', dc
p.ChangeDutyCycle(dc)
time.sleep(0.3);
p.stop()
gpio.cleanup()
print 'done'
| [
11748,
640,
198,
198,
11748,
25812,
72,
13,
16960,
9399,
355,
27809,
952,
198,
198,
11635,
796,
4747,
198,
11635,
62,
22001,
796,
3439,
198,
4514,
6407,
25,
198,
220,
220,
220,
3601,
705,
2188,
3892,
705,
198,
220,
220,
220,
27809,
952,
13,
2617,
14171,
7,
31197,
952,
13,
8202,
9795,
8,
198,
220,
220,
220,
27809,
952,
13,
40406,
7,
11635,
11,
27809,
952,
13,
12425,
8,
198,
220,
220,
220,
27809,
952,
13,
40406,
7,
11635,
62,
22001,
11,
27809,
952,
13,
12425,
8,
198,
220,
220,
220,
27809,
952,
13,
22915,
7,
11635,
62,
22001,
11,
27809,
952,
13,
39,
18060,
8,
198,
220,
220,
220,
279,
796,
27809,
952,
13,
47,
22117,
7,
11635,
11,
7337,
8,
198,
220,
220,
220,
279,
13,
9688,
7,
15,
8,
198,
220,
220,
220,
30736,
796,
838,
198,
220,
220,
220,
329,
1312,
287,
2837,
7,
1821,
2599,
198,
220,
220,
220,
220,
220,
220,
220,
30736,
15853,
362,
198,
220,
220,
220,
220,
220,
220,
220,
3601,
705,
17896,
25,
3256,
30736,
198,
220,
220,
220,
220,
220,
220,
220,
279,
13,
19400,
35,
3935,
20418,
2375,
7,
17896,
8,
198,
220,
220,
220,
220,
220,
220,
220,
640,
13,
42832,
7,
15,
13,
18,
1776,
198,
220,
220,
220,
279,
13,
11338,
3419,
198,
220,
220,
220,
27809,
952,
13,
27773,
929,
3419,
198,
220,
220,
220,
3601,
705,
28060,
6,
198
] | 1.923729 | 236 |
# Bài tập 2. Sử dụng thư viện pandas đọc vào file Iris.csv được biến bộ nhớ df.
# 2a. Hiển thị df.
# 2b. Chuyển cột nhãn y Species thành dạng dữ liệu mã hóa OHE. Hiển thị dữ liệu được mã hóa.
# 2c. Tạo ra cột vector đầu vào x, và cột nhãn vector đầu ra y của df. Hiển thị x và y.
# G:
import pandas as pd
# 2a
df = pd.read_csv("../data/Iris.csv")
print(df)
# 2b
one_hot_encoded_data = pd.get_dummies(df, columns=['Species'])
print(one_hot_encoded_data)
# 2c
x = df[['SepalWidthCm', 'SepalLengthCm', 'PetalLengthCm', 'PetalWidthCm']]
print(x)
y = one_hot_encoded_data[['Species_Iris-setosa', 'Species_Iris-versicolor', 'Species_Iris-virginica']]
print(y)
| [
2,
347,
24247,
72,
256,
157,
118,
255,
79,
362,
13,
311,
157,
119,
255,
288,
157,
119,
98,
782,
294,
130,
108,
25357,
157,
119,
229,
77,
19798,
292,
34754,
239,
157,
119,
235,
66,
410,
24247,
78,
2393,
34230,
13,
40664,
34754,
239,
130,
108,
157,
119,
96,
66,
3182,
157,
118,
123,
77,
275,
157,
119,
247,
299,
71,
157,
119,
249,
47764,
13,
198,
2,
362,
64,
13,
15902,
157,
119,
225,
77,
294,
157,
119,
233,
47764,
13,
198,
2,
362,
65,
13,
609,
4669,
157,
119,
225,
77,
269,
157,
119,
247,
83,
299,
71,
26102,
77,
331,
28540,
294,
24247,
77,
71,
288,
157,
118,
94,
782,
288,
157,
119,
107,
7649,
157,
119,
229,
84,
285,
26102,
289,
10205,
64,
440,
13909,
13,
15902,
157,
119,
225,
77,
294,
157,
119,
233,
288,
157,
119,
107,
7649,
157,
119,
229,
84,
34754,
239,
130,
108,
157,
119,
96,
66,
285,
26102,
289,
10205,
64,
13,
198,
2,
362,
66,
13,
309,
157,
118,
94,
78,
2179,
269,
157,
119,
247,
83,
15879,
34754,
239,
157,
118,
100,
84,
410,
24247,
78,
2124,
11,
410,
24247,
269,
157,
119,
247,
83,
299,
71,
26102,
77,
15879,
34754,
239,
157,
118,
100,
84,
2179,
331,
269,
157,
119,
100,
64,
47764,
13,
15902,
157,
119,
225,
77,
294,
157,
119,
233,
2124,
410,
24247,
331,
13,
198,
2,
402,
25,
198,
11748,
19798,
292,
355,
279,
67,
198,
198,
2,
362,
64,
198,
7568,
796,
279,
67,
13,
961,
62,
40664,
7203,
40720,
7890,
14,
40,
2442,
13,
40664,
4943,
198,
4798,
7,
7568,
8,
198,
2,
362,
65,
198,
505,
62,
8940,
62,
12685,
9043,
62,
7890,
796,
279,
67,
13,
1136,
62,
67,
39578,
7,
7568,
11,
15180,
28,
17816,
5248,
3171,
6,
12962,
198,
4798,
7,
505,
62,
8940,
62,
12685,
9043,
62,
7890,
8,
198,
2,
362,
66,
198,
87,
796,
47764,
58,
17816,
19117,
282,
30916,
34,
76,
3256,
705,
19117,
282,
24539,
34,
76,
3256,
705,
25803,
282,
24539,
34,
76,
3256,
705,
25803,
282,
30916,
34,
76,
6,
11907,
198,
4798,
7,
87,
8,
198,
88,
796,
530,
62,
8940,
62,
12685,
9043,
62,
7890,
58,
17816,
5248,
3171,
62,
40,
2442,
12,
2617,
8546,
3256,
705,
5248,
3171,
62,
40,
2442,
12,
690,
27045,
273,
3256,
705,
5248,
3171,
62,
40,
2442,
12,
85,
4672,
3970,
6,
11907,
198,
4798,
7,
88,
8,
198
] | 1.605392 | 408 |
import pathlib
from functools import reduce
from typing import List, Tuple
if __name__ == "__main__":
main()
| [
11748,
3108,
8019,
198,
6738,
1257,
310,
10141,
1330,
4646,
198,
6738,
19720,
1330,
7343,
11,
309,
29291,
628,
628,
628,
628,
198,
361,
11593,
3672,
834,
6624,
366,
834,
12417,
834,
1298,
198,
220,
220,
220,
1388,
3419,
198
] | 3.025 | 40 |
# Start of file
import bpy
bpy.context.scene.render.engine = 'CYCLES'
bpy.context.scene.render.resolution_x = 320
bpy.context.scene.render.resolution_y = 208
bpy.context.scene.render.resolution_percentage = 100
bpy.context.scene.render.image_settings.file_format = 'BMP'
bpy.context.scene.render.tile_x = 16
bpy.context.scene.render.tile_y = 16
bpy.context.scene.render.use_persistent_data = True
bpy.context.scene.cycles.use_progressive_refine = True
bpy.context.scene.render.use_save_buffers = True
bpy.context.scene.render.use_border = True
bpy.context.scene.cycles.device = 'CPU'
bpy.context.scene.cycles.max_bounces = 2
bpy.context.scene.cycles.min_bounces = 0
bpy.context.scene.cycles.diffuse_bounces = 0
bpy.context.scene.cycles.glossy_bounces = 0
bpy.context.scene.cycles.transmission_bounces = 2
bpy.context.scene.cycles.transparent_max_bounces = 0
bpy.context.scene.cycles.transparent_min_bounces = 0
bpy.context.scene.cycles.caustics_reflective = False
bpy.context.scene.cycles.caustics_refractive = False
bpy.context.scene.cycles.use_square_samples = True
bpy.context.scene.cycles.samples = 4
bpy.context.scene.cycles.debug_use_spatial_splits = True
bpy.context.scene.world.cycles.max_bounces = 1
bpy.context.object.data.cycles.is_portal = True
bpy.context.scene.cycles.debug_use_hair_bvh = False
bpy.data.scenes['Scene'].render.filepath = './0.bmp'
bpy.ops.object.delete(use_global=False)
bpy.ops.mesh.primitive_monkey_add()
bpy.ops.transform.translate(value=(0.0,1.0,1.0))
bpy.ops.object.shade_smooth()
bpy.ops.mesh.primitive_plane_add()
bpy.ops.transform.resize(value=(8.0,8.0,8.0))
bpy.data.objects['Lamp'].select = True
bpy.context.scene.objects.active = bpy.data.objects['Lamp']
bpy.data.lamps['Lamp'].type = "SUN"
bpy.data.lamps['Lamp'].use_nodes = True
bpy.data.lamps['Lamp'].node_tree.nodes['Emission'].inputs['Strength'].default_value = 5
bpy.data.lamps['Lamp'].node_tree.nodes["Emission"].inputs["Color"].default_value = (1.0,0.80,0.50,1.0)
bpy.data.objects['Suzanne'].select = True
bpy.context.scene.objects.active = bpy.data.objects['Suzanne']
bpy.data.materials.new('Glass')
bpy.data.materials['Glass'].use_nodes = True
bpy.data.materials['Glass'].node_tree.nodes.new(type="ShaderNodeBsdfGlass")
inp = bpy.data.materials['Glass'].node_tree.nodes["Material Output"].inputs["Surface"]
outp = bpy.data.materials['Glass'].node_tree.nodes["Glass BSDF"].outputs["BSDF"]
bpy.data.materials['Glass'].node_tree.links.new(inp,outp)
bpy.data.objects['Suzanne'].active_material = bpy.data.materials['Glass']
bpy.data.materials['Glass'].node_tree.nodes["Glass BSDF"].inputs["Color"].default_value = (1.0,0.80,0.50,1.0)
bpy.ops.mesh.primitive_monkey_add()
bpy.ops.transform.translate(value=(3.0,1.0,1.0))
bpy.ops.object.shade_smooth()
bpy.data.materials.new('Glossy')
bpy.data.materials['Glossy'].use_nodes = True
bpy.data.materials['Glossy'].node_tree.nodes.new(type="ShaderNodeBsdfGlossy")
inp = bpy.data.materials['Glossy'].node_tree.nodes["Material Output"].inputs["Surface"]
outp = bpy.data.materials['Glossy'].node_tree.nodes["Glossy BSDF"].outputs["BSDF"]
bpy.data.materials['Glossy'].node_tree.links.new(inp,outp)
bpy.data.objects['Suzanne.001'].active_material = bpy.data.materials['Glossy']
bpy.data.objects['Plane'].active_material = bpy.data.materials['Glossy']
bpy.data.materials['Glossy'].node_tree.nodes["Glossy BSDF"].inputs["Color"].default_value = (1.0,0.80,0.50,1.0)
bpy.ops.mesh.primitive_monkey_add()
bpy.ops.transform.translate(value=(-3.0,1.0,1.0))
bpy.ops.object.shade_smooth()
bpy.data.materials.new('Deffuse')
bpy.data.materials['Deffuse'].use_nodes = True
bpy.data.materials['Deffuse'].node_tree.nodes.new(type="ShaderNodeBsdfDiffuse")
inp = bpy.data.materials['Deffuse'].node_tree.nodes["Material Output"].inputs["Surface"]
outp = bpy.data.materials['Deffuse'].node_tree.nodes["Diffuse BSDF"].outputs["BSDF"]
bpy.data.materials['Deffuse'].node_tree.links.new(inp,outp)
bpy.data.objects['Suzanne.002'].active_material = bpy.data.materials['Deffuse']
bpy.data.materials['Deffuse'].node_tree.nodes["Diffuse BSDF"].inputs["Color"].default_value = (1.0,0.80,0.50,1.0)
bpy.ops.render.render(use_viewport = True, write_still=True)
# End of file
| [
2,
7253,
286,
2393,
198,
11748,
275,
9078,
198,
65,
9078,
13,
22866,
13,
29734,
13,
13287,
13,
18392,
796,
705,
34,
56,
5097,
1546,
6,
198,
65,
9078,
13,
22866,
13,
29734,
13,
13287,
13,
29268,
62,
87,
796,
20959,
198,
65,
9078,
13,
22866,
13,
29734,
13,
13287,
13,
29268,
62,
88,
796,
27121,
198,
65,
9078,
13,
22866,
13,
29734,
13,
13287,
13,
29268,
62,
25067,
496,
796,
1802,
198,
65,
9078,
13,
22866,
13,
29734,
13,
13287,
13,
9060,
62,
33692,
13,
7753,
62,
18982,
796,
705,
33,
7378,
6,
198,
65,
9078,
13,
22866,
13,
29734,
13,
13287,
13,
40927,
62,
87,
796,
1467,
198,
65,
9078,
13,
22866,
13,
29734,
13,
13287,
13,
40927,
62,
88,
796,
1467,
198,
65,
9078,
13,
22866,
13,
29734,
13,
13287,
13,
1904,
62,
19276,
7609,
62,
7890,
796,
6407,
198,
65,
9078,
13,
22866,
13,
29734,
13,
32503,
13,
1904,
62,
1676,
19741,
62,
5420,
500,
796,
6407,
198,
65,
9078,
13,
22866,
13,
29734,
13,
13287,
13,
1904,
62,
21928,
62,
36873,
364,
796,
6407,
198,
65,
9078,
13,
22866,
13,
29734,
13,
13287,
13,
1904,
62,
20192,
796,
6407,
198,
65,
9078,
13,
22866,
13,
29734,
13,
32503,
13,
25202,
796,
705,
36037,
6,
198,
65,
9078,
13,
22866,
13,
29734,
13,
32503,
13,
9806,
62,
65,
45982,
796,
362,
198,
65,
9078,
13,
22866,
13,
29734,
13,
32503,
13,
1084,
62,
65,
45982,
796,
657,
198,
65,
9078,
13,
22866,
13,
29734,
13,
32503,
13,
26069,
1904,
62,
65,
45982,
796,
657,
198,
65,
9078,
13,
22866,
13,
29734,
13,
32503,
13,
4743,
793,
88,
62,
65,
45982,
796,
657,
198,
65,
9078,
13,
22866,
13,
29734,
13,
32503,
13,
7645,
3411,
62,
65,
45982,
796,
362,
198,
65,
9078,
13,
22866,
13,
29734,
13,
32503,
13,
7645,
8000,
62,
9806,
62,
65,
45982,
796,
657,
198,
65,
9078,
13,
22866,
13,
29734,
13,
32503,
13,
7645,
8000,
62,
1084,
62,
65,
45982,
796,
657,
198,
65,
9078,
13,
22866,
13,
29734,
13,
32503,
13,
6888,
436,
873,
62,
35051,
425,
796,
10352,
198,
65,
9078,
13,
22866,
13,
29734,
13,
32503,
13,
6888,
436,
873,
62,
5420,
35587,
796,
10352,
198,
65,
9078,
13,
22866,
13,
29734,
13,
32503,
13,
1904,
62,
23415,
62,
82,
12629,
796,
6407,
198,
65,
9078,
13,
22866,
13,
29734,
13,
32503,
13,
82,
12629,
796,
604,
198,
65,
9078,
13,
22866,
13,
29734,
13,
32503,
13,
24442,
62,
1904,
62,
2777,
34961,
62,
22018,
896,
796,
6407,
198,
65,
9078,
13,
22866,
13,
29734,
13,
6894,
13,
32503,
13,
9806,
62,
65,
45982,
796,
352,
198,
65,
9078,
13,
22866,
13,
15252,
13,
7890,
13,
32503,
13,
271,
62,
634,
282,
796,
6407,
198,
65,
9078,
13,
22866,
13,
29734,
13,
32503,
13,
24442,
62,
1904,
62,
27108,
62,
65,
85,
71,
796,
10352,
198,
65,
9078,
13,
7890,
13,
28123,
17816,
36542,
6,
4083,
13287,
13,
7753,
6978,
796,
705,
19571,
15,
13,
65,
3149,
6,
198,
65,
9078,
13,
2840,
13,
15252,
13,
33678,
7,
1904,
62,
20541,
28,
25101,
8,
198,
65,
9078,
13,
2840,
13,
76,
5069,
13,
19795,
1800,
62,
49572,
62,
2860,
3419,
198,
65,
9078,
13,
2840,
13,
35636,
13,
7645,
17660,
7,
8367,
16193,
15,
13,
15,
11,
16,
13,
15,
11,
16,
13,
15,
4008,
198,
65,
9078,
13,
2840,
13,
15252,
13,
1477,
671,
62,
5796,
5226,
3419,
198,
65,
9078,
13,
2840,
13,
76,
5069,
13,
19795,
1800,
62,
14382,
62,
2860,
3419,
198,
65,
9078,
13,
2840,
13,
35636,
13,
411,
1096,
7,
8367,
16193,
23,
13,
15,
11,
23,
13,
15,
11,
23,
13,
15,
4008,
198,
65,
9078,
13,
7890,
13,
48205,
17816,
43,
696,
6,
4083,
19738,
796,
6407,
198,
65,
9078,
13,
22866,
13,
29734,
13,
48205,
13,
5275,
796,
275,
9078,
13,
7890,
13,
48205,
17816,
43,
696,
20520,
198,
65,
9078,
13,
7890,
13,
75,
9430,
17816,
43,
696,
6,
4083,
4906,
796,
366,
50,
4944,
1,
198,
65,
9078,
13,
7890,
13,
75,
9430,
17816,
43,
696,
6,
4083,
1904,
62,
77,
4147,
796,
6407,
198,
65,
9078,
13,
7890,
13,
75,
9430,
17816,
43,
696,
6,
4083,
17440,
62,
21048,
13,
77,
4147,
17816,
36,
3411,
6,
4083,
15414,
82,
17816,
45027,
6,
4083,
12286,
62,
8367,
796,
642,
198,
65,
9078,
13,
7890,
13,
75,
9430,
17816,
43,
696,
6,
4083,
17440,
62,
21048,
13,
77,
4147,
14692,
36,
3411,
1,
4083,
15414,
82,
14692,
10258,
1,
4083,
12286,
62,
8367,
796,
357,
16,
13,
15,
11,
15,
13,
1795,
11,
15,
13,
1120,
11,
16,
13,
15,
8,
198,
65,
9078,
13,
7890,
13,
48205,
17816,
5606,
38395,
6,
4083,
19738,
796,
6407,
198,
65,
9078,
13,
22866,
13,
29734,
13,
48205,
13,
5275,
796,
275,
9078,
13,
7890,
13,
48205,
17816,
5606,
38395,
20520,
198,
65,
9078,
13,
7890,
13,
33665,
82,
13,
3605,
10786,
47698,
11537,
198,
65,
9078,
13,
7890,
13,
33665,
82,
17816,
47698,
6,
4083,
1904,
62,
77,
4147,
796,
6407,
198,
65,
9078,
13,
7890,
13,
33665,
82,
17816,
47698,
6,
4083,
17440,
62,
21048,
13,
77,
4147,
13,
3605,
7,
4906,
2625,
2484,
5067,
19667,
37000,
7568,
47698,
4943,
198,
259,
79,
796,
275,
9078,
13,
7890,
13,
33665,
82,
17816,
47698,
6,
4083,
17440,
62,
21048,
13,
77,
4147,
14692,
17518,
25235,
1,
4083,
15414,
82,
14692,
14214,
2550,
8973,
198,
448,
79,
796,
275,
9078,
13,
7890,
13,
33665,
82,
17816,
47698,
6,
4083,
17440,
62,
21048,
13,
77,
4147,
14692,
47698,
24218,
8068,
1,
4083,
22915,
82,
14692,
4462,
8068,
8973,
198,
65,
9078,
13,
7890,
13,
33665,
82,
17816,
47698,
6,
4083,
17440,
62,
21048,
13,
28751,
13,
3605,
7,
259,
79,
11,
448,
79,
8,
198,
65,
9078,
13,
7890,
13,
48205,
17816,
5606,
38395,
6,
4083,
5275,
62,
33665,
796,
275,
9078,
13,
7890,
13,
33665,
82,
17816,
47698,
20520,
198,
65,
9078,
13,
7890,
13,
33665,
82,
17816,
47698,
6,
4083,
17440,
62,
21048,
13,
77,
4147,
14692,
47698,
24218,
8068,
1,
4083,
15414,
82,
14692,
10258,
1,
4083,
12286,
62,
8367,
796,
357,
16,
13,
15,
11,
15,
13,
1795,
11,
15,
13,
1120,
11,
16,
13,
15,
8,
198,
65,
9078,
13,
2840,
13,
76,
5069,
13,
19795,
1800,
62,
49572,
62,
2860,
3419,
198,
65,
9078,
13,
2840,
13,
35636,
13,
7645,
17660,
7,
8367,
16193,
18,
13,
15,
11,
16,
13,
15,
11,
16,
13,
15,
4008,
198,
65,
9078,
13,
2840,
13,
15252,
13,
1477,
671,
62,
5796,
5226,
3419,
198,
65,
9078,
13,
7890,
13,
33665,
82,
13,
3605,
10786,
9861,
793,
88,
11537,
198,
65,
9078,
13,
7890,
13,
33665,
82,
17816,
9861,
793,
88,
6,
4083,
1904,
62,
77,
4147,
796,
6407,
198,
65,
9078,
13,
7890,
13,
33665,
82,
17816,
9861,
793,
88,
6,
4083,
17440,
62,
21048,
13,
77,
4147,
13,
3605,
7,
4906,
2625,
2484,
5067,
19667,
37000,
7568,
9861,
793,
88,
4943,
198,
259,
79,
796,
275,
9078,
13,
7890,
13,
33665,
82,
17816,
9861,
793,
88,
6,
4083,
17440,
62,
21048,
13,
77,
4147,
14692,
17518,
25235,
1,
4083,
15414,
82,
14692,
14214,
2550,
8973,
198,
448,
79,
796,
275,
9078,
13,
7890,
13,
33665,
82,
17816,
9861,
793,
88,
6,
4083,
17440,
62,
21048,
13,
77,
4147,
14692,
9861,
793,
88,
24218,
8068,
1,
4083,
22915,
82,
14692,
4462,
8068,
8973,
198,
65,
9078,
13,
7890,
13,
33665,
82,
17816,
9861,
793,
88,
6,
4083,
17440,
62,
21048,
13,
28751,
13,
3605,
7,
259,
79,
11,
448,
79,
8,
198,
65,
9078,
13,
7890,
13,
48205,
17816,
5606,
38395,
13,
8298,
6,
4083,
5275,
62,
33665,
796,
275,
9078,
13,
7890,
13,
33665,
82,
17816,
9861,
793,
88,
20520,
198,
65,
9078,
13,
7890,
13,
48205,
17816,
3646,
1531,
6,
4083,
5275,
62,
33665,
796,
275,
9078,
13,
7890,
13,
33665,
82,
17816,
9861,
793,
88,
20520,
198,
65,
9078,
13,
7890,
13,
33665,
82,
17816,
9861,
793,
88,
6,
4083,
17440,
62,
21048,
13,
77,
4147,
14692,
9861,
793,
88,
24218,
8068,
1,
4083,
15414,
82,
14692,
10258,
1,
4083,
12286,
62,
8367,
796,
357,
16,
13,
15,
11,
15,
13,
1795,
11,
15,
13,
1120,
11,
16,
13,
15,
8,
198,
65,
9078,
13,
2840,
13,
76,
5069,
13,
19795,
1800,
62,
49572,
62,
2860,
3419,
198,
65,
9078,
13,
2840,
13,
35636,
13,
7645,
17660,
7,
8367,
16193,
12,
18,
13,
15,
11,
16,
13,
15,
11,
16,
13,
15,
4008,
198,
65,
9078,
13,
2840,
13,
15252,
13,
1477,
671,
62,
5796,
5226,
3419,
198,
65,
9078,
13,
7890,
13,
33665,
82,
13,
3605,
10786,
5005,
487,
1904,
11537,
198,
65,
9078,
13,
7890,
13,
33665,
82,
17816,
5005,
487,
1904,
6,
4083,
1904,
62,
77,
4147,
796,
6407,
198,
65,
9078,
13,
7890,
13,
33665,
82,
17816,
5005,
487,
1904,
6,
4083,
17440,
62,
21048,
13,
77,
4147,
13,
3605,
7,
4906,
2625,
2484,
5067,
19667,
37000,
7568,
28813,
1904,
4943,
198,
259,
79,
796,
275,
9078,
13,
7890,
13,
33665,
82,
17816,
5005,
487,
1904,
6,
4083,
17440,
62,
21048,
13,
77,
4147,
14692,
17518,
25235,
1,
4083,
15414,
82,
14692,
14214,
2550,
8973,
198,
448,
79,
796,
275,
9078,
13,
7890,
13,
33665,
82,
17816,
5005,
487,
1904,
6,
4083,
17440,
62,
21048,
13,
77,
4147,
14692,
28813,
1904,
24218,
8068,
1,
4083,
22915,
82,
14692,
4462,
8068,
8973,
198,
65,
9078,
13,
7890,
13,
33665,
82,
17816,
5005,
487,
1904,
6,
4083,
17440,
62,
21048,
13,
28751,
13,
3605,
7,
259,
79,
11,
448,
79,
8,
198,
65,
9078,
13,
7890,
13,
48205,
17816,
5606,
38395,
13,
21601,
6,
4083,
5275,
62,
33665,
796,
275,
9078,
13,
7890,
13,
33665,
82,
17816,
5005,
487,
1904,
20520,
198,
65,
9078,
13,
7890,
13,
33665,
82,
17816,
5005,
487,
1904,
6,
4083,
17440,
62,
21048,
13,
77,
4147,
14692,
28813,
1904,
24218,
8068,
1,
4083,
15414,
82,
14692,
10258,
1,
4083,
12286,
62,
8367,
796,
357,
16,
13,
15,
11,
15,
13,
1795,
11,
15,
13,
1120,
11,
16,
13,
15,
8,
198,
65,
9078,
13,
2840,
13,
13287,
13,
13287,
7,
1904,
62,
1177,
634,
796,
6407,
11,
3551,
62,
24219,
28,
17821,
8,
198,
2,
5268,
286,
2393,
628
] | 2.44386 | 1,710 |
import os
from kivy.uix.image import Image
print("Warning: this module will be removed in future")
ASSET_PATH = os.path.dirname(__file__)
SIZE_MOD = 32
tiles = {
'grass': lambda **kwargs: tile_factory("grass.png", **kwargs),
'settlement': lambda **kwargs: tile_factory("settlement.png", **kwargs),
'forest': lambda **kwargs: tile_factory("forest.png", **kwargs),
'hill': lambda **kwargs: tile_factory("hill.png", **kwargs),
'mountain': lambda **kwargs: tile_factory("mountain.png", **kwargs),
'wood_bridge': lambda **kwargs: tile_factory("wood_bridge.png", **kwargs),
'river': lambda **kwargs: tile_factory("river.png", **kwargs),
}
Troop = lambda pos, **kwargs: Image(
source=os.path.join(ASSET_PATH, "troop.png"),
size_hint=(None, None),
size=(SIZE_MOD, SIZE_MOD),
pos=(pos[0] * SIZE_MOD, pos[1] * SIZE_MOD,),
**kwargs
)
Target = lambda pos, **kwargs: Image(
source=os.path.join(ASSET_PATH, "target.png"),
size_hint=(None, None),
size=(SIZE_MOD, SIZE_MOD),
pos=(pos[0] * SIZE_MOD, pos[1] * SIZE_MOD,),
color=[1, 1, 1, 1],
**kwargs
)
| [
198,
198,
11748,
28686,
198,
198,
6738,
479,
452,
88,
13,
84,
844,
13,
9060,
1330,
7412,
628,
198,
4798,
7203,
20361,
25,
428,
8265,
481,
307,
4615,
287,
2003,
4943,
628,
198,
10705,
2767,
62,
34219,
796,
28686,
13,
6978,
13,
15908,
3672,
7,
834,
7753,
834,
8,
198,
33489,
62,
33365,
796,
3933,
628,
198,
198,
83,
2915,
796,
1391,
198,
220,
220,
220,
705,
29815,
10354,
37456,
12429,
46265,
22046,
25,
17763,
62,
69,
9548,
7203,
29815,
13,
11134,
1600,
12429,
46265,
22046,
828,
198,
220,
220,
220,
705,
17744,
1732,
10354,
37456,
12429,
46265,
22046,
25,
17763,
62,
69,
9548,
7203,
17744,
1732,
13,
11134,
1600,
12429,
46265,
22046,
828,
198,
220,
220,
220,
705,
29623,
10354,
37456,
12429,
46265,
22046,
25,
17763,
62,
69,
9548,
7203,
29623,
13,
11134,
1600,
12429,
46265,
22046,
828,
198,
220,
220,
220,
705,
12639,
10354,
37456,
12429,
46265,
22046,
25,
17763,
62,
69,
9548,
7203,
12639,
13,
11134,
1600,
12429,
46265,
22046,
828,
198,
220,
220,
220,
705,
14948,
391,
10354,
37456,
12429,
46265,
22046,
25,
17763,
62,
69,
9548,
7203,
14948,
391,
13,
11134,
1600,
12429,
46265,
22046,
828,
198,
220,
220,
220,
705,
3822,
62,
9458,
10354,
37456,
12429,
46265,
22046,
25,
17763,
62,
69,
9548,
7203,
3822,
62,
9458,
13,
11134,
1600,
12429,
46265,
22046,
828,
198,
220,
220,
220,
705,
38291,
10354,
37456,
12429,
46265,
22046,
25,
17763,
62,
69,
9548,
7203,
38291,
13,
11134,
1600,
12429,
46265,
22046,
828,
198,
92,
198,
44095,
404,
796,
37456,
1426,
11,
12429,
46265,
22046,
25,
7412,
7,
198,
220,
220,
220,
2723,
28,
418,
13,
6978,
13,
22179,
7,
10705,
2767,
62,
34219,
11,
366,
23528,
404,
13,
11134,
12340,
198,
220,
220,
220,
2546,
62,
71,
600,
16193,
14202,
11,
6045,
828,
198,
220,
220,
220,
2546,
16193,
33489,
62,
33365,
11,
311,
35400,
62,
33365,
828,
198,
220,
220,
220,
1426,
16193,
1930,
58,
15,
60,
1635,
311,
35400,
62,
33365,
11,
1426,
58,
16,
60,
1635,
311,
35400,
62,
33365,
11,
828,
198,
220,
220,
220,
12429,
46265,
22046,
198,
8,
198,
21745,
796,
37456,
1426,
11,
12429,
46265,
22046,
25,
7412,
7,
198,
220,
220,
220,
2723,
28,
418,
13,
6978,
13,
22179,
7,
10705,
2767,
62,
34219,
11,
366,
16793,
13,
11134,
12340,
198,
220,
220,
220,
2546,
62,
71,
600,
16193,
14202,
11,
6045,
828,
198,
220,
220,
220,
2546,
16193,
33489,
62,
33365,
11,
311,
35400,
62,
33365,
828,
198,
220,
220,
220,
1426,
16193,
1930,
58,
15,
60,
1635,
311,
35400,
62,
33365,
11,
1426,
58,
16,
60,
1635,
311,
35400,
62,
33365,
11,
828,
198,
220,
220,
220,
3124,
41888,
16,
11,
352,
11,
352,
11,
352,
4357,
198,
220,
220,
220,
12429,
46265,
22046,
198,
8,
198
] | 2.428261 | 460 |
"""Sanity check."""
import os
import sys
from pathlib import Path
from time import sleep
import requests
from subprocess import Popen
import portalocker
from logzero import logger
# start the server if not already started
lockfile = f'{Path(__file__).parent.parent / "deepl_fastapi" / "deepl_server.py.portalocker.lock"}'
logger.info("lockfile: %s", lockfile)
file = open(lockfile, "r+")
try:
portalocker.lock(file, portalocker.LOCK_EX | portalocker.LOCK_NB)
locked = False
portalocker.unlock(file)
except Exception:
locked = True
logger.debug("locked: %s", locked)
if not locked:
cwd = Path(__file__).absolute().parent.as_posix()
executable = f"{sys.executable}"
if os.name in ["posix"]: # linux and friends
cmd = f"nohup python -m deepl_fastapi.run_uvicorn > {cwd}" "/server.out 2>&1 &"
Popen(cmd, shell=True)
logger.info(
"fastapi server running in background, output logged to: %s/server.out",
cwd,
)
else:
try:
Popen(f"{executable} -m deepl_fastapi.run_uvicorn", shell=True)
logger.info(
"\n\t [%s] fastapi server running in background\n",
"deepl_fastapi.run_uvicorn",
)
except Exception as exc:
logger.debug(exc)
# wait for server to come up
sleep(20)
| [
37811,
15017,
414,
2198,
526,
15931,
198,
11748,
28686,
198,
11748,
25064,
198,
6738,
3108,
8019,
1330,
10644,
198,
6738,
640,
1330,
3993,
198,
198,
11748,
7007,
198,
6738,
850,
14681,
1330,
8099,
268,
198,
11748,
17898,
12721,
198,
6738,
2604,
22570,
1330,
49706,
198,
198,
2,
923,
262,
4382,
611,
407,
1541,
2067,
198,
198,
5354,
7753,
796,
277,
6,
90,
15235,
7,
834,
7753,
834,
737,
8000,
13,
8000,
1220,
366,
67,
1453,
489,
62,
7217,
15042,
1,
1220,
366,
67,
1453,
489,
62,
15388,
13,
9078,
13,
634,
282,
12721,
13,
5354,
20662,
6,
198,
6404,
1362,
13,
10951,
7203,
5354,
7753,
25,
4064,
82,
1600,
5793,
7753,
8,
198,
7753,
796,
1280,
7,
5354,
7753,
11,
366,
81,
10,
4943,
198,
28311,
25,
198,
220,
220,
220,
17898,
12721,
13,
5354,
7,
7753,
11,
17898,
12721,
13,
36840,
62,
6369,
930,
17898,
12721,
13,
36840,
62,
32819,
8,
198,
220,
220,
220,
8970,
796,
10352,
198,
220,
220,
220,
17898,
12721,
13,
403,
5354,
7,
7753,
8,
198,
16341,
35528,
25,
198,
220,
220,
220,
8970,
796,
6407,
198,
198,
6404,
1362,
13,
24442,
7203,
24162,
25,
4064,
82,
1600,
8970,
8,
198,
361,
407,
8970,
25,
198,
220,
220,
220,
269,
16993,
796,
10644,
7,
834,
7753,
834,
737,
48546,
22446,
8000,
13,
292,
62,
1930,
844,
3419,
198,
220,
220,
220,
28883,
796,
277,
1,
90,
17597,
13,
18558,
18187,
36786,
198,
220,
220,
220,
611,
28686,
13,
3672,
287,
14631,
1930,
844,
1,
5974,
220,
1303,
32639,
290,
2460,
198,
220,
220,
220,
220,
220,
220,
220,
23991,
796,
277,
1,
77,
1219,
929,
21015,
532,
76,
390,
68,
489,
62,
7217,
15042,
13,
5143,
62,
14795,
291,
1211,
1875,
1391,
66,
16993,
36786,
12813,
15388,
13,
448,
362,
29,
5,
16,
1222,
1,
198,
220,
220,
220,
220,
220,
220,
220,
8099,
268,
7,
28758,
11,
7582,
28,
17821,
8,
198,
220,
220,
220,
220,
220,
220,
220,
49706,
13,
10951,
7,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
7217,
15042,
4382,
2491,
287,
4469,
11,
5072,
18832,
284,
25,
4064,
82,
14,
15388,
13,
448,
1600,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
269,
16993,
11,
198,
220,
220,
220,
220,
220,
220,
220,
1267,
198,
220,
220,
220,
2073,
25,
198,
220,
220,
220,
220,
220,
220,
220,
1949,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
8099,
268,
7,
69,
1,
90,
18558,
18187,
92,
532,
76,
390,
68,
489,
62,
7217,
15042,
13,
5143,
62,
14795,
291,
1211,
1600,
7582,
28,
17821,
8,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
49706,
13,
10951,
7,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
37082,
77,
59,
83,
685,
4,
82,
60,
3049,
15042,
4382,
2491,
287,
4469,
59,
77,
1600,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
67,
1453,
489,
62,
7217,
15042,
13,
5143,
62,
14795,
291,
1211,
1600,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1267,
198,
220,
220,
220,
220,
220,
220,
220,
2845,
35528,
355,
2859,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
49706,
13,
24442,
7,
41194,
8,
628,
220,
220,
220,
1303,
4043,
329,
4382,
284,
1282,
510,
198,
220,
220,
220,
3993,
7,
1238,
8,
628
] | 2.32363 | 584 |
import logging
import numpy as np
| [
11748,
18931,
198,
198,
11748,
299,
32152,
355,
45941,
628
] | 3.6 | 10 |
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.utils import timezone
import plotly.offline as plotly
import plotly.graph_objs as go
from core.utils import duration_parts
from reports import utils
def sleep_totals(instances):
"""
Create a graph showing total time sleeping for each day.
:param instances: a QuerySet of Sleep instances.
:returns: a tuple of the the graph's html and javascript.
"""
totals = {}
for instance in instances:
start = timezone.localtime(instance.start)
end = timezone.localtime(instance.end)
if start.date() not in totals.keys():
totals[start.date()] = timezone.timedelta(seconds=0)
if end.date() not in totals.keys():
totals[end.date()] = timezone.timedelta(seconds=0)
# Account for dates crossing midnight.
if start.date() != end.date():
totals[start.date()] += end.replace(
year=start.year, month=start.month, day=start.day,
hour=23, minute=59, second=59) - start
totals[end.date()] += end - start.replace(
year=end.year, month=end.month, day=end.day, hour=0, minute=0,
second=0)
else:
totals[start.date()] += instance.duration
trace = go.Bar(
name='Total sleep',
x=list(totals.keys()),
y=[td.seconds/3600 for td in totals.values()],
hoverinfo='text',
textposition='outside',
text=[_duration_string_short(td) for td in totals.values()]
)
layout_args = utils.default_graph_layout_options()
layout_args['barmode'] = 'stack'
layout_args['title'] = '<b>Sleep Totals</b>'
layout_args['xaxis']['title'] = 'Date'
layout_args['xaxis']['rangeselector'] = utils.rangeselector_date()
layout_args['yaxis']['title'] = 'Hours of sleep'
fig = go.Figure({
'data': [trace],
'layout': go.Layout(**layout_args)
})
output = plotly.plot(fig, output_type='div', include_plotlyjs=False)
return utils.split_graph_output(output)
def _duration_string_short(duration):
"""
Format a "short" duration string without seconds precision. This is
intended to fit better in smaller spaces on a graph.
:returns: a string of the form XhXm.
"""
h, m, s = duration_parts(duration)
return '{}h{}m'.format(h, m)
| [
2,
532,
9,
12,
19617,
25,
3384,
69,
12,
23,
532,
9,
12,
198,
6738,
11593,
37443,
834,
1330,
28000,
1098,
62,
17201,
874,
198,
198,
6738,
42625,
14208,
13,
26791,
1330,
640,
11340,
198,
198,
11748,
7110,
306,
13,
2364,
1370,
355,
7110,
306,
198,
11748,
7110,
306,
13,
34960,
62,
672,
8457,
355,
467,
198,
198,
6738,
4755,
13,
26791,
1330,
9478,
62,
42632,
198,
198,
6738,
3136,
1330,
3384,
4487,
628,
198,
4299,
3993,
62,
83,
313,
874,
7,
8625,
1817,
2599,
198,
220,
220,
220,
37227,
198,
220,
220,
220,
13610,
257,
4823,
4478,
2472,
640,
11029,
329,
1123,
1110,
13,
198,
220,
220,
220,
1058,
17143,
10245,
25,
257,
43301,
7248,
286,
17376,
10245,
13,
198,
220,
220,
220,
1058,
7783,
82,
25,
257,
46545,
286,
262,
262,
4823,
338,
27711,
290,
44575,
13,
198,
220,
220,
220,
37227,
198,
220,
220,
220,
26310,
796,
23884,
198,
220,
220,
220,
329,
4554,
287,
10245,
25,
198,
220,
220,
220,
220,
220,
220,
220,
923,
796,
640,
11340,
13,
12001,
2435,
7,
39098,
13,
9688,
8,
198,
220,
220,
220,
220,
220,
220,
220,
886,
796,
640,
11340,
13,
12001,
2435,
7,
39098,
13,
437,
8,
198,
220,
220,
220,
220,
220,
220,
220,
611,
923,
13,
4475,
3419,
407,
287,
26310,
13,
13083,
33529,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
26310,
58,
9688,
13,
4475,
3419,
60,
796,
640,
11340,
13,
16514,
276,
12514,
7,
43012,
28,
15,
8,
198,
220,
220,
220,
220,
220,
220,
220,
611,
886,
13,
4475,
3419,
407,
287,
26310,
13,
13083,
33529,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
26310,
58,
437,
13,
4475,
3419,
60,
796,
640,
11340,
13,
16514,
276,
12514,
7,
43012,
28,
15,
8,
628,
220,
220,
220,
220,
220,
220,
220,
1303,
10781,
329,
9667,
12538,
15896,
13,
198,
220,
220,
220,
220,
220,
220,
220,
611,
923,
13,
4475,
3419,
14512,
886,
13,
4475,
33529,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
26310,
58,
9688,
13,
4475,
3419,
60,
15853,
886,
13,
33491,
7,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
614,
28,
9688,
13,
1941,
11,
1227,
28,
9688,
13,
8424,
11,
1110,
28,
9688,
13,
820,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1711,
28,
1954,
11,
5664,
28,
3270,
11,
1218,
28,
3270,
8,
532,
923,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
26310,
58,
437,
13,
4475,
3419,
60,
15853,
886,
532,
923,
13,
33491,
7,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
614,
28,
437,
13,
1941,
11,
1227,
28,
437,
13,
8424,
11,
1110,
28,
437,
13,
820,
11,
1711,
28,
15,
11,
5664,
28,
15,
11,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1218,
28,
15,
8,
198,
220,
220,
220,
220,
220,
220,
220,
2073,
25,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
26310,
58,
9688,
13,
4475,
3419,
60,
15853,
4554,
13,
32257,
628,
220,
220,
220,
12854,
796,
467,
13,
10374,
7,
198,
220,
220,
220,
220,
220,
220,
220,
1438,
11639,
14957,
3993,
3256,
198,
220,
220,
220,
220,
220,
220,
220,
2124,
28,
4868,
7,
83,
313,
874,
13,
13083,
3419,
828,
198,
220,
220,
220,
220,
220,
220,
220,
331,
41888,
8671,
13,
43012,
14,
2623,
405,
329,
41560,
287,
26310,
13,
27160,
3419,
4357,
198,
220,
220,
220,
220,
220,
220,
220,
20599,
10951,
11639,
5239,
3256,
198,
220,
220,
220,
220,
220,
220,
220,
2420,
9150,
11639,
43435,
3256,
198,
220,
220,
220,
220,
220,
220,
220,
2420,
28,
29795,
32257,
62,
8841,
62,
19509,
7,
8671,
8,
329,
41560,
287,
26310,
13,
27160,
3419,
60,
198,
220,
220,
220,
1267,
628,
220,
220,
220,
12461,
62,
22046,
796,
3384,
4487,
13,
12286,
62,
34960,
62,
39786,
62,
25811,
3419,
198,
220,
220,
220,
12461,
62,
22046,
17816,
65,
1670,
1098,
20520,
796,
705,
25558,
6,
198,
220,
220,
220,
12461,
62,
22046,
17816,
7839,
20520,
796,
705,
27,
65,
29,
40555,
20323,
874,
3556,
65,
29,
6,
198,
220,
220,
220,
12461,
62,
22046,
17816,
87,
22704,
6,
7131,
6,
7839,
20520,
796,
705,
10430,
6,
198,
220,
220,
220,
12461,
62,
22046,
17816,
87,
22704,
6,
7131,
6,
36985,
2771,
801,
273,
20520,
796,
3384,
4487,
13,
36985,
2771,
801,
273,
62,
4475,
3419,
198,
220,
220,
220,
12461,
62,
22046,
17816,
88,
22704,
6,
7131,
6,
7839,
20520,
796,
705,
39792,
286,
3993,
6,
628,
220,
220,
220,
2336,
796,
467,
13,
11337,
15090,
198,
220,
220,
220,
220,
220,
220,
220,
705,
7890,
10354,
685,
40546,
4357,
198,
220,
220,
220,
220,
220,
220,
220,
705,
39786,
10354,
467,
13,
32517,
7,
1174,
39786,
62,
22046,
8,
198,
220,
220,
220,
32092,
198,
220,
220,
220,
5072,
796,
7110,
306,
13,
29487,
7,
5647,
11,
5072,
62,
4906,
11639,
7146,
3256,
2291,
62,
29487,
306,
8457,
28,
25101,
8,
198,
220,
220,
220,
1441,
3384,
4487,
13,
35312,
62,
34960,
62,
22915,
7,
22915,
8,
628,
198,
4299,
4808,
32257,
62,
8841,
62,
19509,
7,
32257,
2599,
198,
220,
220,
220,
37227,
198,
220,
220,
220,
18980,
257,
366,
19509,
1,
9478,
4731,
1231,
4201,
15440,
13,
770,
318,
198,
220,
220,
220,
5292,
284,
4197,
1365,
287,
4833,
9029,
319,
257,
4823,
13,
198,
220,
220,
220,
1058,
7783,
82,
25,
257,
4731,
286,
262,
1296,
1395,
71,
55,
76,
13,
198,
220,
220,
220,
37227,
198,
220,
220,
220,
289,
11,
285,
11,
264,
796,
9478,
62,
42632,
7,
32257,
8,
198,
220,
220,
220,
1441,
705,
90,
92,
71,
90,
92,
76,
4458,
18982,
7,
71,
11,
285,
8,
198
] | 2.409274 | 992 |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import unittest
from ovm.exceptions import OVMError
from ovm.drivers.driver_loader import DriverLoader
from ovm.drivers.storage.lvm import LvmDriver
from ovm.drivers.storage.file import FileDriver
from ovm.drivers.network.bridge import BridgeDriver
| [
2,
48443,
14629,
14,
8800,
14,
24330,
21015,
18,
198,
2,
532,
9,
12,
19617,
25,
3384,
69,
12,
23,
532,
9,
12,
198,
198,
11748,
555,
715,
395,
198,
198,
6738,
267,
14761,
13,
1069,
11755,
1330,
440,
15996,
12331,
198,
6738,
267,
14761,
13,
36702,
13,
26230,
62,
29356,
1330,
12434,
17401,
198,
6738,
267,
14761,
13,
36702,
13,
35350,
13,
6780,
76,
1330,
406,
14761,
32103,
198,
6738,
267,
14761,
13,
36702,
13,
35350,
13,
7753,
1330,
9220,
32103,
198,
6738,
267,
14761,
13,
36702,
13,
27349,
13,
9458,
1330,
10290,
32103,
628
] | 3.114583 | 96 |
from parameterized import parameterized
from api.proquest.identifier import ProQuestIdentifierParser
from core.model import Identifier
| [
6738,
11507,
1143,
1330,
11507,
1143,
198,
198,
6738,
40391,
13,
1676,
6138,
13,
738,
7483,
1330,
1041,
12166,
33234,
7483,
46677,
198,
6738,
4755,
13,
19849,
1330,
11440,
7483,
628
] | 4.419355 | 31 |
import functools
import operator
from enum import Enum
from itertools import combinations
from typing import Any, Sequence, Tuple
import geopandas as gpd
import numpy as np
import pygeos
import shapely.geometry as sg
IntArray = np.ndarray
FloatArray = np.ndarray
coord_dtype = np.dtype([("x", np.float64), ("y", np.float64)])
def overlap_shortlist(features: gpd.GeoSeries) -> Tuple[IntArray, IntArray]:
"""
Create a shortlist of polygons or linestrings indices to check against each
other using their bounding boxes.
"""
bounds = features.bounds
index_a, index_b = (
np.array(index) for index in zip(*combinations(features.index, 2))
)
df_a = bounds.loc[index_a]
df_b = bounds.loc[index_b]
# Convert to dict to get rid of clashing index.
a = {k: df_a[k].values for k in df_a}
b = {k: df_b[k].values for k in df_b}
# Touching does not count as overlap here.
overlap = (
(a["maxx"] >= b["minx"])
& (b["maxx"] >= a["minx"])
& (a["maxy"] >= b["miny"])
& (b["maxy"] >= a["miny"])
)
return index_a[overlap], index_b[overlap]
def check_features(features: gpd.GeoSeries, feature_type) -> None:
"""
Features should:
* be simple: no self-intersection
* not intersect with other features
"""
# Note: make sure to call geopandas functions rather than shapely or pygeos
# where possible. Otherwise, either conversion is required, or duplicate
# implementations, one with shapely and one with pygeos.
# Check valid
are_simple = features.is_simple
n_complex = (~are_simple).sum()
if n_complex > 0:
raise ValueError(
f"{n_complex} cases of complex {feature_type} detected: these "
" features contain self intersections"
)
if len(features) <= 1:
return
check_intersection(features, feature_type)
return
def check_linestrings(
linestrings: gpd.GeoSeries,
polygons: gpd.GeoSeries,
) -> None:
"""
Check whether linestrings are fully contained in a single polygon.
"""
check_features(linestrings, "linestring")
intersects = gpd.GeoDataFrame(geometry=linestrings).sjoin(
df=gpd.GeoDataFrame(geometry=polygons),
predicate="within",
)
n_diff = len(linestrings) - len(intersects)
if n_diff != 0:
raise ValueError(
"The same linestring detected in multiple polygons or "
"linestring detected outside of any polygon; "
"a linestring must be fully contained by a single polygon."
)
return
def check_points(
points: gpd.GeoSeries,
polygons: gpd.GeoSeries,
) -> None:
"""
Check whether points are contained by a polygon.
"""
within = gpd.GeoDataFrame(geometry=points).sjoin(
df=gpd.GeoDataFrame(geometry=polygons),
predicate="within",
)
n_outside = len(points) - len(within)
if n_outside != 0:
raise ValueError(f"{n_outside} points detected outside of a polygon")
return
| [
11748,
1257,
310,
10141,
198,
11748,
10088,
198,
6738,
33829,
1330,
2039,
388,
198,
6738,
340,
861,
10141,
1330,
17790,
198,
6738,
19720,
1330,
4377,
11,
45835,
11,
309,
29291,
198,
198,
11748,
30324,
392,
292,
355,
27809,
67,
198,
11748,
299,
32152,
355,
45941,
198,
11748,
12972,
469,
418,
198,
11748,
5485,
306,
13,
469,
15748,
355,
264,
70,
198,
198,
5317,
19182,
796,
45941,
13,
358,
18747,
198,
43879,
19182,
796,
45941,
13,
358,
18747,
198,
37652,
62,
67,
4906,
796,
45941,
13,
67,
4906,
26933,
7203,
87,
1600,
45941,
13,
22468,
2414,
828,
5855,
88,
1600,
45941,
13,
22468,
2414,
8,
12962,
628,
628,
628,
198,
198,
4299,
21721,
62,
19509,
4868,
7,
40890,
25,
27809,
67,
13,
10082,
78,
27996,
8,
4613,
309,
29291,
58,
5317,
19182,
11,
2558,
19182,
5974,
198,
220,
220,
220,
37227,
198,
220,
220,
220,
13610,
257,
1790,
4868,
286,
25052,
684,
393,
9493,
395,
33173,
36525,
284,
2198,
1028,
1123,
198,
220,
220,
220,
584,
1262,
511,
5421,
278,
10559,
13,
198,
220,
220,
220,
37227,
198,
220,
220,
220,
22303,
796,
3033,
13,
65,
3733,
198,
220,
220,
220,
6376,
62,
64,
11,
6376,
62,
65,
796,
357,
198,
220,
220,
220,
220,
220,
220,
220,
45941,
13,
18747,
7,
9630,
8,
329,
6376,
287,
19974,
46491,
24011,
7352,
7,
40890,
13,
9630,
11,
362,
4008,
198,
220,
220,
220,
1267,
198,
220,
220,
220,
47764,
62,
64,
796,
22303,
13,
17946,
58,
9630,
62,
64,
60,
198,
220,
220,
220,
47764,
62,
65,
796,
22303,
13,
17946,
58,
9630,
62,
65,
60,
198,
220,
220,
220,
1303,
38240,
284,
8633,
284,
651,
5755,
286,
537,
2140,
6376,
13,
198,
220,
220,
220,
257,
796,
1391,
74,
25,
47764,
62,
64,
58,
74,
4083,
27160,
329,
479,
287,
47764,
62,
64,
92,
198,
220,
220,
220,
275,
796,
1391,
74,
25,
47764,
62,
65,
58,
74,
4083,
27160,
329,
479,
287,
47764,
62,
65,
92,
198,
220,
220,
220,
1303,
15957,
278,
857,
407,
954,
355,
21721,
994,
13,
198,
220,
220,
220,
21721,
796,
357,
198,
220,
220,
220,
220,
220,
220,
220,
357,
64,
14692,
9806,
87,
8973,
18189,
275,
14692,
1084,
87,
8973,
8,
198,
220,
220,
220,
220,
220,
220,
220,
1222,
357,
65,
14692,
9806,
87,
8973,
18189,
257,
14692,
1084,
87,
8973,
8,
198,
220,
220,
220,
220,
220,
220,
220,
1222,
357,
64,
14692,
76,
6969,
8973,
18189,
275,
14692,
1084,
88,
8973,
8,
198,
220,
220,
220,
220,
220,
220,
220,
1222,
357,
65,
14692,
76,
6969,
8973,
18189,
257,
14692,
1084,
88,
8973,
8,
198,
220,
220,
220,
1267,
198,
220,
220,
220,
1441,
6376,
62,
64,
58,
2502,
37796,
4357,
6376,
62,
65,
58,
2502,
37796,
60,
628,
628,
198,
4299,
2198,
62,
40890,
7,
40890,
25,
27809,
67,
13,
10082,
78,
27996,
11,
3895,
62,
4906,
8,
4613,
6045,
25,
198,
220,
220,
220,
37227,
198,
220,
220,
220,
17571,
815,
25,
628,
220,
220,
220,
220,
220,
220,
220,
1635,
307,
2829,
25,
645,
2116,
12,
3849,
5458,
198,
220,
220,
220,
220,
220,
220,
220,
1635,
407,
36177,
351,
584,
3033,
628,
220,
220,
220,
37227,
198,
220,
220,
220,
1303,
5740,
25,
787,
1654,
284,
869,
30324,
392,
292,
5499,
2138,
621,
5485,
306,
393,
12972,
469,
418,
198,
220,
220,
220,
1303,
810,
1744,
13,
15323,
11,
2035,
11315,
318,
2672,
11,
393,
23418,
198,
220,
220,
220,
1303,
25504,
11,
530,
351,
5485,
306,
290,
530,
351,
12972,
469,
418,
13,
628,
220,
220,
220,
1303,
6822,
4938,
198,
220,
220,
220,
389,
62,
36439,
796,
3033,
13,
271,
62,
36439,
198,
220,
220,
220,
299,
62,
41887,
796,
31034,
533,
62,
36439,
737,
16345,
3419,
198,
220,
220,
220,
611,
299,
62,
41887,
1875,
657,
25,
198,
220,
220,
220,
220,
220,
220,
220,
5298,
11052,
12331,
7,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
277,
1,
90,
77,
62,
41887,
92,
2663,
286,
3716,
1391,
30053,
62,
4906,
92,
12326,
25,
777,
366,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
3033,
3994,
2116,
42085,
1,
198,
220,
220,
220,
220,
220,
220,
220,
1267,
628,
220,
220,
220,
611,
18896,
7,
40890,
8,
19841,
352,
25,
198,
220,
220,
220,
220,
220,
220,
220,
1441,
628,
220,
220,
220,
2198,
62,
3849,
5458,
7,
40890,
11,
3895,
62,
4906,
8,
198,
220,
220,
220,
1441,
628,
198,
198,
4299,
2198,
62,
2815,
395,
33173,
7,
198,
220,
220,
220,
9493,
395,
33173,
25,
27809,
67,
13,
10082,
78,
27996,
11,
198,
220,
220,
220,
25052,
684,
25,
27809,
67,
13,
10082,
78,
27996,
11,
198,
8,
4613,
6045,
25,
198,
220,
220,
220,
37227,
198,
220,
220,
220,
6822,
1771,
9493,
395,
33173,
389,
3938,
7763,
287,
257,
2060,
7514,
14520,
13,
198,
220,
220,
220,
37227,
198,
220,
220,
220,
2198,
62,
40890,
7,
2815,
395,
33173,
11,
366,
2815,
395,
1806,
4943,
628,
220,
220,
220,
36177,
82,
796,
27809,
67,
13,
10082,
78,
6601,
19778,
7,
469,
15748,
28,
2815,
395,
33173,
737,
82,
22179,
7,
198,
220,
220,
220,
220,
220,
220,
220,
47764,
28,
70,
30094,
13,
10082,
78,
6601,
19778,
7,
469,
15748,
28,
35428,
70,
684,
828,
198,
220,
220,
220,
220,
220,
220,
220,
44010,
2625,
33479,
1600,
198,
220,
220,
220,
1267,
198,
220,
220,
220,
299,
62,
26069,
796,
18896,
7,
2815,
395,
33173,
8,
532,
18896,
7,
3849,
8831,
82,
8,
198,
220,
220,
220,
611,
299,
62,
26069,
14512,
657,
25,
198,
220,
220,
220,
220,
220,
220,
220,
5298,
11052,
12331,
7,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
464,
976,
9493,
395,
1806,
12326,
287,
3294,
25052,
684,
393,
366,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
2815,
395,
1806,
12326,
2354,
286,
597,
7514,
14520,
26,
366,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
366,
64,
9493,
395,
1806,
1276,
307,
3938,
7763,
416,
257,
2060,
7514,
14520,
526,
198,
220,
220,
220,
220,
220,
220,
220,
1267,
628,
220,
220,
220,
1441,
628,
198,
4299,
2198,
62,
13033,
7,
198,
220,
220,
220,
2173,
25,
27809,
67,
13,
10082,
78,
27996,
11,
198,
220,
220,
220,
25052,
684,
25,
27809,
67,
13,
10082,
78,
27996,
11,
198,
8,
4613,
6045,
25,
198,
220,
220,
220,
37227,
198,
220,
220,
220,
6822,
1771,
2173,
389,
7763,
416,
257,
7514,
14520,
13,
198,
220,
220,
220,
37227,
198,
220,
220,
220,
1626,
796,
27809,
67,
13,
10082,
78,
6601,
19778,
7,
469,
15748,
28,
13033,
737,
82,
22179,
7,
198,
220,
220,
220,
220,
220,
220,
220,
47764,
28,
70,
30094,
13,
10082,
78,
6601,
19778,
7,
469,
15748,
28,
35428,
70,
684,
828,
198,
220,
220,
220,
220,
220,
220,
220,
44010,
2625,
33479,
1600,
198,
220,
220,
220,
1267,
198,
220,
220,
220,
299,
62,
43435,
796,
18896,
7,
13033,
8,
532,
18896,
7,
33479,
8,
198,
220,
220,
220,
611,
299,
62,
43435,
14512,
657,
25,
198,
220,
220,
220,
220,
220,
220,
220,
5298,
11052,
12331,
7,
69,
1,
90,
77,
62,
43435,
92,
2173,
12326,
2354,
286,
257,
7514,
14520,
4943,
198,
220,
220,
220,
1441,
628,
628
] | 2.504085 | 1,224 |
import time
import DFL168A
SuccessFresh=False
| [
11748,
640,
201,
198,
11748,
360,
3697,
14656,
32,
201,
198,
33244,
35857,
28,
25101,
201
] | 3 | 16 |
import numpy as np
import logging
import cv2
import os
from torch.utils.data import Dataset
| [
11748,
299,
32152,
355,
45941,
198,
11748,
18931,
198,
11748,
269,
85,
17,
198,
11748,
28686,
198,
198,
6738,
28034,
13,
26791,
13,
7890,
1330,
16092,
292,
316,
628
] | 3.241379 | 29 |
#######################################
# Copyright 2019 PMP SA. #
# SPDX-License-Identifier: Apache-2.0 #
#######################################
import os
import pytest
from rpackutils.config import Config
| [
29113,
4242,
21017,
198,
2,
15069,
13130,
3122,
47,
14719,
13,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1303,
198,
2,
30628,
55,
12,
34156,
12,
33234,
7483,
25,
24843,
12,
17,
13,
15,
1303,
198,
29113,
4242,
21017,
198,
198,
11748,
28686,
198,
11748,
12972,
9288,
198,
6738,
374,
8002,
26791,
13,
11250,
1330,
17056,
628
] | 3.539683 | 63 |
import pandas as pd
import numpy as nm
import sqlite3
from scipy.sparse.linalg import svds
from sqlalchemy import create_engine
engine=create_engine("postgres://postgres:25736534@localhost:5432/postgres")
print(user_row_number)
sorted_user_predictions = predictions_df.iloc[user_row_number].sort_values(ascending=False)
user_data = original_ratings_df[original_ratings_df.account_id == (userID)]
user_full = (user_data.merge(movies_df, how = 'left', left_on = 'movie_id', right_on = 'movie_id').
sort_values(['rating'], ascending=False))
recommendations = (movies_df[~movies_df['movie_id'].isin(user_full['movie_id'])].
merge(pd.DataFrame(sorted_user_predictions).reset_index(), how = 'left',
left_on = 'movie_id',
right_on = 'movie_id').
rename(columns = {user_row_number: 'Predictions'}).
sort_values('Predictions', ascending = False).
iloc[:num_recommendations, :-1]
)
return recommendations
| [
11748,
19798,
292,
355,
279,
67,
198,
11748,
299,
32152,
355,
28642,
198,
11748,
44161,
578,
18,
198,
6738,
629,
541,
88,
13,
82,
29572,
13,
75,
1292,
70,
1330,
38487,
9310,
198,
6738,
44161,
282,
26599,
1330,
2251,
62,
18392,
198,
18392,
28,
17953,
62,
18392,
7203,
7353,
34239,
1378,
7353,
34239,
25,
28676,
24760,
2682,
31,
36750,
25,
4051,
2624,
14,
7353,
34239,
4943,
198,
220,
220,
220,
3601,
7,
7220,
62,
808,
62,
17618,
8,
198,
197,
82,
9741,
62,
7220,
62,
28764,
9278,
796,
16277,
62,
7568,
13,
346,
420,
58,
7220,
62,
808,
62,
17618,
4083,
30619,
62,
27160,
7,
3372,
1571,
28,
25101,
8,
198,
197,
7220,
62,
7890,
796,
2656,
62,
10366,
654,
62,
7568,
58,
14986,
62,
10366,
654,
62,
7568,
13,
23317,
62,
312,
6624,
357,
7220,
2389,
15437,
198,
197,
7220,
62,
12853,
796,
357,
7220,
62,
7890,
13,
647,
469,
7,
76,
20526,
62,
7568,
11,
703,
796,
705,
9464,
3256,
1364,
62,
261,
796,
705,
41364,
62,
312,
3256,
826,
62,
261,
796,
705,
41364,
62,
312,
27691,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
3297,
62,
27160,
7,
17816,
8821,
6,
4357,
41988,
28,
25101,
4008,
198,
197,
47335,
437,
602,
796,
357,
76,
20526,
62,
7568,
58,
93,
76,
20526,
62,
7568,
17816,
41364,
62,
312,
6,
4083,
45763,
7,
7220,
62,
12853,
17816,
41364,
62,
312,
6,
12962,
4083,
198,
220,
220,
220,
220,
220,
220,
220,
220,
20121,
7,
30094,
13,
6601,
19778,
7,
82,
9741,
62,
7220,
62,
28764,
9278,
737,
42503,
62,
9630,
22784,
703,
796,
705,
9464,
3256,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1364,
62,
261,
796,
705,
41364,
62,
312,
3256,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
826,
62,
261,
796,
705,
41364,
62,
312,
27691,
198,
220,
220,
220,
220,
220,
220,
220,
220,
36265,
7,
28665,
82,
796,
1391,
7220,
62,
808,
62,
17618,
25,
705,
39156,
9278,
6,
92,
737,
198,
220,
220,
220,
220,
220,
220,
220,
220,
3297,
62,
27160,
10786,
39156,
9278,
3256,
41988,
796,
10352,
737,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
4229,
420,
58,
25,
22510,
62,
47335,
437,
602,
11,
1058,
12,
16,
60,
198,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
220,
1267,
198,
197,
7783,
10763,
628,
198
] | 2.328054 | 442 |
# uncompyle6 version 3.7.4
# Python bytecode 3.7 (3394)
# Decompiled from: Python 3.7.9 (tags/v3.7.9:13c94747c7, Aug 17 2020, 18:58:18) [MSC v.1900 64 bit (AMD64)]
# Embedded file name: T:\InGame\Gameplay\Scripts\Server\gsi_handlers\buff_handlers.py
# Compiled at: 2014-05-30 02:11:42
# Size of source mod 2**32: 4843 bytes
from gsi_handlers.gameplay_archiver import GameplayArchiver
from sims4.gsi.schema import GsiGridSchema, GsiFieldVisualizers
import services
from protocolbuffers import Sims_pb2
sim_buff_log_schema = GsiGridSchema(label='Buffs Log', sim_specific=True)
sim_buff_log_schema.add_field('buff_id', label='Buff ID', type=(GsiFieldVisualizers.INT), width=0.5)
sim_buff_log_schema.add_field('buff_name', label='Name', width=2)
sim_buff_log_schema.add_field('equipped', label='Equip', width=1)
sim_buff_log_schema.add_field('buff_reason', label='Reason', width=1)
sim_buff_log_schema.add_field('timeout', label='Timeout', width=2)
sim_buff_log_schema.add_field('rate', label='Rate', width=2)
sim_buff_log_schema.add_field('is_mood_buff', label='Is Mood Buff', width=2)
sim_buff_log_schema.add_field('progress_arrow', label='Progress Arrow', width=2)
sim_buff_log_schema.add_field('commodity_guid', label='Commodity Guid', type=(GsiFieldVisualizers.INT), hidden=True)
sim_buff_log_schema.add_field('transition_into_buff_id', label='Next Buff ID', type=(GsiFieldVisualizers.INT), hidden=True)
sim_buff_log_archiver = GameplayArchiver('sim_buff_log', sim_buff_log_schema)
sim_mood_log_schema = GsiGridSchema(label='Mood Log', sim_specific=True)
sim_mood_log_schema.add_field('mood_id', label='Mood ID', type=(GsiFieldVisualizers.INT), width=0.5)
sim_mood_log_schema.add_field('mood_name', label='Name', width=2)
sim_mood_log_schema.add_field('mood_intensity', label='Intensity', width=2)
with sim_mood_log_schema.add_has_many('active_buffs', GsiGridSchema, label='Buffs at update') as (sub_schema):
sub_schema.add_field('buff_id', label='Buff ID')
sub_schema.add_field('buff_name', label='Buff name')
sub_schema.add_field('buff_mood', label='Buff Mood')
sub_schema.add_field('buff_mood_override', label='Mood Override (current)')
sub_schema.add_field('buff_mood_override_pending', label='Mood Override (pending)')
sim_mood_log_archiver = GameplayArchiver('sim_mood_log', sim_mood_log_schema) | [
2,
34318,
2349,
21,
2196,
513,
13,
22,
13,
19,
198,
2,
11361,
18022,
8189,
513,
13,
22,
357,
2091,
5824,
8,
198,
2,
4280,
3361,
3902,
422,
25,
11361,
513,
13,
22,
13,
24,
357,
31499,
14,
85,
18,
13,
22,
13,
24,
25,
1485,
66,
24,
2857,
2857,
66,
22,
11,
2447,
1596,
12131,
11,
1248,
25,
3365,
25,
1507,
8,
685,
5653,
34,
410,
13,
48104,
5598,
1643,
357,
28075,
2414,
15437,
198,
2,
13302,
47238,
2393,
1438,
25,
309,
7479,
818,
8777,
59,
43241,
59,
7391,
82,
59,
10697,
59,
70,
13396,
62,
4993,
8116,
59,
36873,
62,
4993,
8116,
13,
9078,
198,
2,
3082,
3902,
379,
25,
1946,
12,
2713,
12,
1270,
7816,
25,
1157,
25,
3682,
198,
2,
12849,
286,
2723,
953,
362,
1174,
2624,
25,
4764,
3559,
9881,
198,
6738,
308,
13396,
62,
4993,
8116,
13,
6057,
1759,
62,
998,
1428,
1330,
3776,
1759,
19895,
1428,
198,
6738,
985,
82,
19,
13,
70,
13396,
13,
15952,
2611,
1330,
402,
13396,
41339,
27054,
2611,
11,
402,
13396,
15878,
36259,
11341,
198,
11748,
2594,
198,
6738,
8435,
36873,
364,
1330,
25343,
62,
40842,
17,
198,
14323,
62,
36873,
62,
6404,
62,
15952,
2611,
796,
402,
13396,
41339,
27054,
2611,
7,
18242,
11639,
33,
18058,
5972,
3256,
985,
62,
11423,
28,
17821,
8,
198,
14323,
62,
36873,
62,
6404,
62,
15952,
2611,
13,
2860,
62,
3245,
10786,
36873,
62,
312,
3256,
6167,
11639,
36474,
4522,
3256,
2099,
16193,
38,
13396,
15878,
36259,
11341,
13,
12394,
828,
9647,
28,
15,
13,
20,
8,
198,
14323,
62,
36873,
62,
6404,
62,
15952,
2611,
13,
2860,
62,
3245,
10786,
36873,
62,
3672,
3256,
6167,
11639,
5376,
3256,
9647,
28,
17,
8,
198,
14323,
62,
36873,
62,
6404,
62,
15952,
2611,
13,
2860,
62,
3245,
10786,
40617,
3256,
6167,
11639,
23588,
541,
3256,
9647,
28,
16,
8,
198,
14323,
62,
36873,
62,
6404,
62,
15952,
2611,
13,
2860,
62,
3245,
10786,
36873,
62,
41181,
3256,
6167,
11639,
45008,
3256,
9647,
28,
16,
8,
198,
14323,
62,
36873,
62,
6404,
62,
15952,
2611,
13,
2860,
62,
3245,
10786,
48678,
3256,
6167,
11639,
48031,
3256,
9647,
28,
17,
8,
198,
14323,
62,
36873,
62,
6404,
62,
15952,
2611,
13,
2860,
62,
3245,
10786,
4873,
3256,
6167,
11639,
32184,
3256,
9647,
28,
17,
8,
198,
14323,
62,
36873,
62,
6404,
62,
15952,
2611,
13,
2860,
62,
3245,
10786,
271,
62,
76,
702,
62,
36873,
3256,
6167,
11639,
3792,
25723,
8792,
3256,
9647,
28,
17,
8,
198,
14323,
62,
36873,
62,
6404,
62,
15952,
2611,
13,
2860,
62,
3245,
10786,
33723,
62,
6018,
3256,
6167,
11639,
32577,
19408,
3256,
9647,
28,
17,
8,
198,
14323,
62,
36873,
62,
6404,
62,
15952,
2611,
13,
2860,
62,
3245,
10786,
785,
4666,
414,
62,
5162,
312,
3256,
6167,
11639,
6935,
375,
414,
37026,
3256,
2099,
16193,
38,
13396,
15878,
36259,
11341,
13,
12394,
828,
7104,
28,
17821,
8,
198,
14323,
62,
36873,
62,
6404,
62,
15952,
2611,
13,
2860,
62,
3245,
10786,
7645,
653,
62,
20424,
62,
36873,
62,
312,
3256,
6167,
11639,
10019,
8792,
4522,
3256,
2099,
16193,
38,
13396,
15878,
36259,
11341,
13,
12394,
828,
7104,
28,
17821,
8,
198,
14323,
62,
36873,
62,
6404,
62,
998,
1428,
796,
3776,
1759,
19895,
1428,
10786,
14323,
62,
36873,
62,
6404,
3256,
985,
62,
36873,
62,
6404,
62,
15952,
2611,
8,
628,
198,
14323,
62,
76,
702,
62,
6404,
62,
15952,
2611,
796,
402,
13396,
41339,
27054,
2611,
7,
18242,
11639,
44,
702,
5972,
3256,
985,
62,
11423,
28,
17821,
8,
198,
14323,
62,
76,
702,
62,
6404,
62,
15952,
2611,
13,
2860,
62,
3245,
10786,
76,
702,
62,
312,
3256,
6167,
11639,
44,
702,
4522,
3256,
2099,
16193,
38,
13396,
15878,
36259,
11341,
13,
12394,
828,
9647,
28,
15,
13,
20,
8,
198,
14323,
62,
76,
702,
62,
6404,
62,
15952,
2611,
13,
2860,
62,
3245,
10786,
76,
702,
62,
3672,
3256,
6167,
11639,
5376,
3256,
9647,
28,
17,
8,
198,
14323,
62,
76,
702,
62,
6404,
62,
15952,
2611,
13,
2860,
62,
3245,
10786,
76,
702,
62,
47799,
3256,
6167,
11639,
5317,
6377,
3256,
9647,
28,
17,
8,
198,
4480,
985,
62,
76,
702,
62,
6404,
62,
15952,
2611,
13,
2860,
62,
10134,
62,
21834,
10786,
5275,
62,
65,
18058,
3256,
402,
13396,
41339,
27054,
2611,
11,
6167,
11639,
33,
18058,
379,
4296,
11537,
355,
357,
7266,
62,
15952,
2611,
2599,
198,
220,
220,
220,
850,
62,
15952,
2611,
13,
2860,
62,
3245,
10786,
36873,
62,
312,
3256,
6167,
11639,
36474,
4522,
11537,
198,
220,
220,
220,
850,
62,
15952,
2611,
13,
2860,
62,
3245,
10786,
36873,
62,
3672,
3256,
6167,
11639,
36474,
1438,
11537,
198,
220,
220,
220,
850,
62,
15952,
2611,
13,
2860,
62,
3245,
10786,
36873,
62,
76,
702,
3256,
6167,
11639,
36474,
25723,
11537,
198,
220,
220,
220,
850,
62,
15952,
2611,
13,
2860,
62,
3245,
10786,
36873,
62,
76,
702,
62,
2502,
13154,
3256,
6167,
11639,
44,
702,
3827,
13154,
357,
14421,
8,
11537,
198,
220,
220,
220,
850,
62,
15952,
2611,
13,
2860,
62,
3245,
10786,
36873,
62,
76,
702,
62,
2502,
13154,
62,
79,
1571,
3256,
6167,
11639,
44,
702,
3827,
13154,
357,
79,
1571,
8,
11537,
198,
14323,
62,
76,
702,
62,
6404,
62,
998,
1428,
796,
3776,
1759,
19895,
1428,
10786,
14323,
62,
76,
702,
62,
6404,
3256,
985,
62,
76,
702,
62,
6404,
62,
15952,
2611,
8
] | 2.605381 | 892 |
keyboard.send_keys("<shift>+<right>") | [
2539,
3526,
13,
21280,
62,
13083,
7203,
27,
30846,
29,
10,
27,
3506,
29,
4943
] | 2.466667 | 15 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.