sequence
stringlengths 492
15.9k
| code
stringlengths 75
8.58k
|
---|---|
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:get_dummy_dynamic_run; 3, parameters; 3, 4; 3, 5; 4, identifier:nsamples; 5, dictionary_splat_pattern; 5, 6; 6, identifier:kwargs; 7, block; 7, 8; 7, 18; 7, 28; 7, 38; 7, 48; 7, 58; 7, 71; 7, 94; 7, 114; 7, 125; 7, 148; 7, 171; 7, 182; 7, 193; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:seed; 11, call; 11, 12; 11, 15; 12, attribute; 12, 13; 12, 14; 13, identifier:kwargs; 14, identifier:pop; 15, argument_list; 15, 16; 15, 17; 16, string:'seed'; 17, False; 18, expression_statement; 18, 19; 19, assignment; 19, 20; 19, 21; 20, identifier:ndim; 21, call; 21, 22; 21, 25; 22, attribute; 22, 23; 22, 24; 23, identifier:kwargs; 24, identifier:pop; 25, argument_list; 25, 26; 25, 27; 26, string:'ndim'; 27, integer:2; 28, expression_statement; 28, 29; 29, assignment; 29, 30; 29, 31; 30, identifier:nthread_init; 31, call; 31, 32; 31, 35; 32, attribute; 32, 33; 32, 34; 33, identifier:kwargs; 34, identifier:pop; 35, argument_list; 35, 36; 35, 37; 36, string:'nthread_init'; 37, integer:2; 38, expression_statement; 38, 39; 39, assignment; 39, 40; 39, 41; 40, identifier:nthread_dyn; 41, call; 41, 42; 41, 45; 42, attribute; 42, 43; 42, 44; 43, identifier:kwargs; 44, identifier:pop; 45, argument_list; 45, 46; 45, 47; 46, string:'nthread_dyn'; 47, integer:3; 48, expression_statement; 48, 49; 49, assignment; 49, 50; 49, 51; 50, identifier:logl_range; 51, call; 51, 52; 51, 55; 52, attribute; 52, 53; 52, 54; 53, identifier:kwargs; 54, identifier:pop; 55, argument_list; 55, 56; 55, 57; 56, string:'logl_range'; 57, integer:1; 58, if_statement; 58, 59; 58, 60; 59, identifier:kwargs; 60, block; 60, 61; 61, raise_statement; 61, 62; 62, call; 62, 63; 62, 64; 63, identifier:TypeError; 64, argument_list; 64, 65; 65, call; 65, 66; 65, 69; 66, attribute; 66, 67; 66, 68; 67, string:'Unexpected **kwargs: {0}'; 68, identifier:format; 69, argument_list; 69, 70; 70, identifier:kwargs; 71, expression_statement; 71, 72; 72, assignment; 72, 73; 72, 74; 73, identifier:init; 74, call; 74, 75; 74, 76; 75, identifier:get_dummy_run; 76, argument_list; 76, 77; 76, 78; 76, 79; 76, 82; 76, 85; 76, 91; 77, identifier:nthread_init; 78, identifier:nsamples; 79, keyword_argument; 79, 80; 79, 81; 80, identifier:ndim; 81, identifier:ndim; 82, keyword_argument; 82, 83; 82, 84; 83, identifier:seed; 84, identifier:seed; 85, keyword_argument; 85, 86; 85, 87; 86, identifier:logl_start; 87, unary_operator:-; 87, 88; 88, attribute; 88, 89; 88, 90; 89, identifier:np; 90, identifier:inf; 91, keyword_argument; 91, 92; 91, 93; 92, identifier:logl_range; 93, identifier:logl_range; 94, expression_statement; 94, 95; 95, assignment; 95, 96; 95, 97; 96, identifier:dyn_starts; 97, call; 97, 98; 97, 99; 98, identifier:list; 99, argument_list; 99, 100; 100, call; 100, 101; 100, 106; 101, attribute; 101, 102; 101, 105; 102, attribute; 102, 103; 102, 104; 103, identifier:np; 104, identifier:random; 105, identifier:choice; 106, argument_list; 106, 107; 106, 110; 106, 111; 107, subscript; 107, 108; 107, 109; 108, identifier:init; 109, string:'logl'; 110, identifier:nthread_dyn; 111, keyword_argument; 111, 112; 111, 113; 112, identifier:replace; 113, True; 114, expression_statement; 114, 115; 115, assignment; 115, 116; 115, 117; 116, identifier:threads; 117, call; 117, 118; 117, 123; 118, attribute; 118, 119; 118, 122; 119, attribute; 119, 120; 119, 121; 120, identifier:nestcheck; 121, identifier:ns_run_utils; 122, identifier:get_run_threads; 123, argument_list; 123, 124; 124, identifier:init; 125, expression_statement; 125, 126; 126, augmented_assignment:+=; 126, 127; 126, 128; 127, identifier:threads; 128, list_comprehension; 128, 129; 128, 145; 129, call; 129, 130; 129, 131; 130, identifier:get_dummy_thread; 131, argument_list; 131, 132; 131, 133; 131, 136; 131, 139; 131, 142; 132, identifier:nsamples; 133, keyword_argument; 133, 134; 133, 135; 134, identifier:ndim; 135, identifier:ndim; 136, keyword_argument; 136, 137; 136, 138; 137, identifier:seed; 138, False; 139, keyword_argument; 139, 140; 139, 141; 140, identifier:logl_start; 141, identifier:start; 142, keyword_argument; 142, 143; 142, 144; 143, identifier:logl_range; 144, identifier:logl_range; 145, for_in_clause; 145, 146; 145, 147; 146, identifier:start; 147, identifier:dyn_starts; 148, for_statement; 148, 149; 148, 152; 148, 156; 149, pattern_list; 149, 150; 149, 151; 150, identifier:i; 151, identifier:_; 152, call; 152, 153; 152, 154; 153, identifier:enumerate; 154, argument_list; 154, 155; 155, identifier:threads; 156, block; 156, 157; 157, expression_statement; 157, 158; 158, assignment; 158, 159; 158, 164; 159, subscript; 159, 160; 159, 163; 160, subscript; 160, 161; 160, 162; 161, identifier:threads; 162, identifier:i; 163, string:'thread_labels'; 164, call; 164, 165; 164, 168; 165, attribute; 165, 166; 165, 167; 166, identifier:np; 167, identifier:full; 168, argument_list; 168, 169; 168, 170; 169, identifier:nsamples; 170, identifier:i; 171, expression_statement; 171, 172; 172, assignment; 172, 173; 172, 174; 173, identifier:run; 174, call; 174, 175; 174, 180; 175, attribute; 175, 176; 175, 179; 176, attribute; 176, 177; 176, 178; 177, identifier:nestcheck; 178, identifier:ns_run_utils; 179, identifier:combine_threads; 180, argument_list; 180, 181; 181, identifier:threads; 182, expression_statement; 182, 183; 183, assignment; 183, 184; 183, 185; 184, identifier:samples; 185, call; 185, 186; 185, 191; 186, attribute; 186, 187; 186, 190; 187, attribute; 187, 188; 187, 189; 188, identifier:nestcheck; 189, identifier:write_polychord_output; 190, identifier:run_dead_birth_array; 191, argument_list; 191, 192; 192, identifier:run; 193, return_statement; 193, 194; 194, call; 194, 195; 194, 200; 195, attribute; 195, 196; 195, 199; 196, attribute; 196, 197; 196, 198; 197, identifier:nestcheck; 198, identifier:data_processing; 199, identifier:process_samples_array; 200, argument_list; 200, 201; 201, identifier:samples | def get_dummy_dynamic_run(nsamples, **kwargs):
seed = kwargs.pop('seed', False)
ndim = kwargs.pop('ndim', 2)
nthread_init = kwargs.pop('nthread_init', 2)
nthread_dyn = kwargs.pop('nthread_dyn', 3)
logl_range = kwargs.pop('logl_range', 1)
if kwargs:
raise TypeError('Unexpected **kwargs: {0}'.format(kwargs))
init = get_dummy_run(nthread_init, nsamples, ndim=ndim, seed=seed,
logl_start=-np.inf, logl_range=logl_range)
dyn_starts = list(np.random.choice(
init['logl'], nthread_dyn, replace=True))
threads = nestcheck.ns_run_utils.get_run_threads(init)
threads += [get_dummy_thread(
nsamples, ndim=ndim, seed=False, logl_start=start,
logl_range=logl_range) for start in dyn_starts]
for i, _ in enumerate(threads):
threads[i]['thread_labels'] = np.full(nsamples, i)
run = nestcheck.ns_run_utils.combine_threads(threads)
samples = nestcheck.write_polychord_output.run_dead_birth_array(run)
return nestcheck.data_processing.process_samples_array(samples) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:get_dates_for_project; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:project; 6, block; 6, 7; 6, 18; 6, 22; 6, 88; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:file_re; 10, call; 10, 11; 10, 14; 11, attribute; 11, 12; 11, 13; 12, identifier:re; 13, identifier:compile; 14, argument_list; 14, 15; 15, binary_operator:%; 15, 16; 15, 17; 16, string:r'^%s_([0-9]{8})\.json$'; 17, identifier:project; 18, expression_statement; 18, 19; 19, assignment; 19, 20; 19, 21; 20, identifier:all_dates; 21, list:[]; 22, for_statement; 22, 23; 22, 24; 22, 32; 23, identifier:f; 24, call; 24, 25; 24, 28; 25, attribute; 25, 26; 25, 27; 26, identifier:os; 27, identifier:listdir; 28, argument_list; 28, 29; 29, attribute; 29, 30; 29, 31; 30, identifier:self; 31, identifier:cache_path; 32, block; 32, 33; 32, 55; 32, 64; 32, 70; 33, if_statement; 33, 34; 33, 53; 34, not_operator; 34, 35; 35, call; 35, 36; 35, 41; 36, attribute; 36, 37; 36, 40; 37, attribute; 37, 38; 37, 39; 38, identifier:os; 39, identifier:path; 40, identifier:isfile; 41, argument_list; 41, 42; 42, call; 42, 43; 42, 48; 43, attribute; 43, 44; 43, 47; 44, attribute; 44, 45; 44, 46; 45, identifier:os; 46, identifier:path; 47, identifier:join; 48, argument_list; 48, 49; 48, 52; 49, attribute; 49, 50; 49, 51; 50, identifier:self; 51, identifier:cache_path; 52, identifier:f; 53, block; 53, 54; 54, continue_statement; 55, expression_statement; 55, 56; 56, assignment; 56, 57; 56, 58; 57, identifier:m; 58, call; 58, 59; 58, 62; 59, attribute; 59, 60; 59, 61; 60, identifier:file_re; 61, identifier:match; 62, argument_list; 62, 63; 63, identifier:f; 64, if_statement; 64, 65; 64, 68; 65, comparison_operator:is; 65, 66; 65, 67; 66, identifier:m; 67, None; 68, block; 68, 69; 69, continue_statement; 70, expression_statement; 70, 71; 71, call; 71, 72; 71, 75; 72, attribute; 72, 73; 72, 74; 73, identifier:all_dates; 74, identifier:append; 75, argument_list; 75, 76; 76, call; 76, 77; 76, 80; 77, attribute; 77, 78; 77, 79; 78, identifier:datetime; 79, identifier:strptime; 80, argument_list; 80, 81; 80, 87; 81, call; 81, 82; 81, 85; 82, attribute; 82, 83; 82, 84; 83, identifier:m; 84, identifier:group; 85, argument_list; 85, 86; 86, integer:1; 87, string:'%Y%m%d'; 88, return_statement; 88, 89; 89, call; 89, 90; 89, 91; 90, identifier:sorted; 91, argument_list; 91, 92; 92, identifier:all_dates | def get_dates_for_project(self, project):
file_re = re.compile(r'^%s_([0-9]{8})\.json$' % project)
all_dates = []
for f in os.listdir(self.cache_path):
if not os.path.isfile(os.path.join(self.cache_path, f)):
continue
m = file_re.match(f)
if m is None:
continue
all_dates.append(datetime.strptime(m.group(1), '%Y%m%d'))
return sorted(all_dates) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:insort_event_right; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 4, identifier:self; 5, identifier:event; 6, default_parameter; 6, 7; 6, 8; 7, identifier:lo; 8, integer:0; 9, default_parameter; 9, 10; 9, 11; 10, identifier:hi; 11, None; 12, block; 12, 13; 12, 23; 12, 37; 12, 76; 13, if_statement; 13, 14; 13, 17; 14, comparison_operator:<; 14, 15; 14, 16; 15, identifier:lo; 16, integer:0; 17, block; 17, 18; 18, raise_statement; 18, 19; 19, call; 19, 20; 19, 21; 20, identifier:ValueError; 21, argument_list; 21, 22; 22, string:'lo must be non-negative'; 23, if_statement; 23, 24; 23, 27; 24, comparison_operator:is; 24, 25; 24, 26; 25, identifier:hi; 26, None; 27, block; 27, 28; 28, expression_statement; 28, 29; 29, assignment; 29, 30; 29, 31; 30, identifier:hi; 31, call; 31, 32; 31, 33; 32, identifier:len; 33, argument_list; 33, 34; 34, attribute; 34, 35; 34, 36; 35, identifier:self; 36, identifier:queue; 37, while_statement; 37, 38; 37, 41; 38, comparison_operator:<; 38, 39; 38, 40; 39, identifier:lo; 40, identifier:hi; 41, block; 41, 42; 41, 51; 42, expression_statement; 42, 43; 43, assignment; 43, 44; 43, 45; 44, identifier:mid; 45, binary_operator://; 45, 46; 45, 50; 46, parenthesized_expression; 46, 47; 47, binary_operator:+; 47, 48; 47, 49; 48, identifier:lo; 49, identifier:hi; 50, integer:2; 51, if_statement; 51, 52; 51, 63; 51, 68; 52, comparison_operator:<; 52, 53; 52, 56; 53, subscript; 53, 54; 53, 55; 54, identifier:event; 55, integer:0; 56, subscript; 56, 57; 56, 62; 57, subscript; 57, 58; 57, 61; 58, attribute; 58, 59; 58, 60; 59, identifier:self; 60, identifier:queue; 61, identifier:mid; 62, integer:0; 63, block; 63, 64; 64, expression_statement; 64, 65; 65, assignment; 65, 66; 65, 67; 66, identifier:hi; 67, identifier:mid; 68, else_clause; 68, 69; 69, block; 69, 70; 70, expression_statement; 70, 71; 71, assignment; 71, 72; 71, 73; 72, identifier:lo; 73, binary_operator:+; 73, 74; 73, 75; 74, identifier:mid; 75, integer:1; 76, expression_statement; 76, 77; 77, call; 77, 78; 77, 83; 78, attribute; 78, 79; 78, 82; 79, attribute; 79, 80; 79, 81; 80, identifier:self; 81, identifier:queue; 82, identifier:insert; 83, argument_list; 83, 84; 83, 85; 84, identifier:lo; 85, identifier:event | def insort_event_right(self, event, lo=0, hi=None):
if lo < 0:
raise ValueError('lo must be non-negative')
if hi is None:
hi = len(self.queue)
while lo < hi:
mid = (lo + hi) // 2
if event[0] < self.queue[mid][0]:
hi = mid
else:
lo = mid + 1
self.queue.insert(lo, event) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:getMd5Checksum; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 27; 5, 44; 5, 57; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:references; 9, call; 9, 10; 9, 11; 10, identifier:sorted; 11, argument_list; 11, 12; 11, 17; 12, call; 12, 13; 12, 16; 13, attribute; 13, 14; 13, 15; 14, identifier:self; 15, identifier:getReferences; 16, argument_list; 17, keyword_argument; 17, 18; 17, 19; 18, identifier:key; 19, lambda; 19, 20; 19, 22; 20, lambda_parameters; 20, 21; 21, identifier:ref; 22, call; 22, 23; 22, 26; 23, attribute; 23, 24; 23, 25; 24, identifier:ref; 25, identifier:getMd5Checksum; 26, argument_list; 27, expression_statement; 27, 28; 28, assignment; 28, 29; 28, 30; 29, identifier:checksums; 30, call; 30, 31; 30, 34; 31, attribute; 31, 32; 31, 33; 32, string:''; 33, identifier:join; 34, argument_list; 34, 35; 35, list_comprehension; 35, 36; 35, 41; 36, call; 36, 37; 36, 40; 37, attribute; 37, 38; 37, 39; 38, identifier:ref; 39, identifier:getMd5Checksum; 40, argument_list; 41, for_in_clause; 41, 42; 41, 43; 42, identifier:ref; 43, identifier:references; 44, expression_statement; 44, 45; 45, assignment; 45, 46; 45, 47; 46, identifier:md5checksum; 47, call; 47, 48; 47, 56; 48, attribute; 48, 49; 48, 55; 49, call; 49, 50; 49, 53; 50, attribute; 50, 51; 50, 52; 51, identifier:hashlib; 52, identifier:md5; 53, argument_list; 53, 54; 54, identifier:checksums; 55, identifier:hexdigest; 56, argument_list; 57, return_statement; 57, 58; 58, identifier:md5checksum | def getMd5Checksum(self):
references = sorted(
self.getReferences(),
key=lambda ref: ref.getMd5Checksum())
checksums = ''.join([ref.getMd5Checksum() for ref in references])
md5checksum = hashlib.md5(checksums).hexdigest()
return md5checksum |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 13; 2, function_name:knn_impute_few_observed; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 10; 4, identifier:X; 5, identifier:missing_mask; 6, identifier:k; 7, default_parameter; 7, 8; 7, 9; 8, identifier:verbose; 9, False; 10, default_parameter; 10, 11; 10, 12; 11, identifier:print_interval; 12, integer:100; 13, block; 13, 14; 13, 22; 13, 30; 13, 42; 13, 47; 13, 58; 13, 73; 13, 85; 13, 91; 13, 97; 13, 108; 13, 126; 13, 132; 13, 281; 14, expression_statement; 14, 15; 15, assignment; 15, 16; 15, 17; 16, identifier:start_t; 17, call; 17, 18; 17, 21; 18, attribute; 18, 19; 18, 20; 19, identifier:time; 20, identifier:time; 21, argument_list; 22, expression_statement; 22, 23; 23, assignment; 23, 24; 23, 27; 24, pattern_list; 24, 25; 24, 26; 25, identifier:n_rows; 26, identifier:n_cols; 27, attribute; 27, 28; 27, 29; 28, identifier:X; 29, identifier:shape; 30, expression_statement; 30, 31; 31, assignment; 31, 32; 31, 33; 32, identifier:missing_mask_column_major; 33, call; 33, 34; 33, 37; 34, attribute; 34, 35; 34, 36; 35, identifier:np; 36, identifier:asarray; 37, argument_list; 37, 38; 37, 39; 38, identifier:missing_mask; 39, keyword_argument; 39, 40; 39, 41; 40, identifier:order; 41, string:"F"; 42, expression_statement; 42, 43; 43, assignment; 43, 44; 43, 45; 44, identifier:observed_mask_column_major; 45, unary_operator:~; 45, 46; 46, identifier:missing_mask_column_major; 47, expression_statement; 47, 48; 48, assignment; 48, 49; 48, 50; 49, identifier:X_column_major; 50, call; 50, 51; 50, 54; 51, attribute; 51, 52; 51, 53; 52, identifier:X; 53, identifier:copy; 54, argument_list; 54, 55; 55, keyword_argument; 55, 56; 55, 57; 56, identifier:order; 57, string:"F"; 58, expression_statement; 58, 59; 59, assignment; 59, 60; 59, 64; 59, 65; 60, pattern_list; 60, 61; 60, 62; 60, 63; 61, identifier:X_row_major; 62, identifier:D; 63, identifier:effective_infinity; 64, line_continuation:\; 65, call; 65, 66; 65, 67; 66, identifier:knn_initialize; 67, argument_list; 67, 68; 67, 69; 67, 70; 68, identifier:X; 69, identifier:missing_mask; 70, keyword_argument; 70, 71; 70, 72; 71, identifier:verbose; 72, identifier:verbose; 73, expression_statement; 73, 74; 74, assignment; 74, 75; 74, 76; 75, identifier:D_sorted; 76, call; 76, 77; 76, 80; 77, attribute; 77, 78; 77, 79; 78, identifier:np; 79, identifier:argsort; 80, argument_list; 80, 81; 80, 82; 81, identifier:D; 82, keyword_argument; 82, 83; 82, 84; 83, identifier:axis; 84, integer:1; 85, expression_statement; 85, 86; 86, assignment; 86, 87; 86, 88; 87, identifier:inv_D; 88, binary_operator:/; 88, 89; 88, 90; 89, float:1.0; 90, identifier:D; 91, expression_statement; 91, 92; 92, assignment; 92, 93; 92, 94; 93, identifier:D_valid_mask; 94, comparison_operator:<; 94, 95; 94, 96; 95, identifier:D; 96, identifier:effective_infinity; 97, expression_statement; 97, 98; 98, assignment; 98, 99; 98, 100; 99, identifier:valid_distances_per_row; 100, call; 100, 101; 100, 104; 101, attribute; 101, 102; 101, 103; 102, identifier:D_valid_mask; 103, identifier:sum; 104, argument_list; 104, 105; 105, keyword_argument; 105, 106; 105, 107; 106, identifier:axis; 107, integer:1; 108, expression_statement; 108, 109; 109, assignment; 109, 110; 109, 111; 110, identifier:D_sorted; 111, list_comprehension; 111, 112; 111, 118; 112, subscript; 112, 113; 112, 114; 112, 115; 113, identifier:D_sorted; 114, identifier:i; 115, slice; 115, 116; 115, 117; 116, colon; 117, identifier:count; 118, for_in_clause; 118, 119; 118, 122; 119, pattern_list; 119, 120; 119, 121; 120, identifier:i; 121, identifier:count; 122, call; 122, 123; 122, 124; 123, identifier:enumerate; 124, argument_list; 124, 125; 125, identifier:valid_distances_per_row; 126, expression_statement; 126, 127; 127, assignment; 127, 128; 127, 129; 128, identifier:dot; 129, attribute; 129, 130; 129, 131; 130, identifier:np; 131, identifier:dot; 132, for_statement; 132, 133; 132, 134; 132, 138; 133, identifier:i; 134, call; 134, 135; 134, 136; 135, identifier:range; 136, argument_list; 136, 137; 137, identifier:n_rows; 138, block; 138, 139; 138, 147; 138, 158; 138, 166; 138, 197; 138, 203; 139, expression_statement; 139, 140; 140, assignment; 140, 141; 140, 142; 141, identifier:missing_row; 142, subscript; 142, 143; 142, 144; 142, 145; 143, identifier:missing_mask; 144, identifier:i; 145, slice; 145, 146; 146, colon; 147, expression_statement; 147, 148; 148, assignment; 148, 149; 148, 150; 149, identifier:missing_indices; 150, subscript; 150, 151; 150, 157; 151, call; 151, 152; 151, 155; 152, attribute; 152, 153; 152, 154; 153, identifier:np; 154, identifier:where; 155, argument_list; 155, 156; 156, identifier:missing_row; 157, integer:0; 158, expression_statement; 158, 159; 159, assignment; 159, 160; 159, 161; 160, identifier:row_weights; 161, subscript; 161, 162; 161, 163; 161, 164; 162, identifier:inv_D; 163, identifier:i; 164, slice; 164, 165; 165, colon; 166, if_statement; 166, 167; 166, 174; 167, boolean_operator:and; 167, 168; 167, 169; 168, identifier:verbose; 169, comparison_operator:==; 169, 170; 169, 173; 170, binary_operator:%; 170, 171; 170, 172; 171, identifier:i; 172, identifier:print_interval; 173, integer:0; 174, block; 174, 175; 175, expression_statement; 175, 176; 176, call; 176, 177; 176, 178; 177, identifier:print; 178, argument_list; 178, 179; 179, binary_operator:%; 179, 180; 179, 181; 180, string:"Imputing row %d/%d with %d missing, elapsed time: %0.3f"; 181, tuple; 181, 182; 181, 185; 181, 186; 181, 190; 182, binary_operator:+; 182, 183; 182, 184; 183, identifier:i; 184, integer:1; 185, identifier:n_rows; 186, call; 186, 187; 186, 188; 187, identifier:len; 188, argument_list; 188, 189; 189, identifier:missing_indices; 190, binary_operator:-; 190, 191; 190, 196; 191, call; 191, 192; 191, 195; 192, attribute; 192, 193; 192, 194; 193, identifier:time; 194, identifier:time; 195, argument_list; 196, identifier:start_t; 197, expression_statement; 197, 198; 198, assignment; 198, 199; 198, 200; 199, identifier:candidate_neighbor_indices; 200, subscript; 200, 201; 200, 202; 201, identifier:D_sorted; 202, identifier:i; 203, for_statement; 203, 204; 203, 205; 203, 206; 204, identifier:j; 205, identifier:missing_indices; 206, block; 206, 207; 206, 215; 206, 221; 206, 227; 206, 235; 206, 241; 206, 249; 207, expression_statement; 207, 208; 208, assignment; 208, 209; 208, 210; 209, identifier:observed; 210, subscript; 210, 211; 210, 212; 210, 214; 211, identifier:observed_mask_column_major; 212, slice; 212, 213; 213, colon; 214, identifier:j; 215, expression_statement; 215, 216; 216, assignment; 216, 217; 216, 218; 217, identifier:sorted_observed; 218, subscript; 218, 219; 218, 220; 219, identifier:observed; 220, identifier:candidate_neighbor_indices; 221, expression_statement; 221, 222; 222, assignment; 222, 223; 222, 224; 223, identifier:observed_neighbor_indices; 224, subscript; 224, 225; 224, 226; 225, identifier:candidate_neighbor_indices; 226, identifier:sorted_observed; 227, expression_statement; 227, 228; 228, assignment; 228, 229; 228, 230; 229, identifier:k_nearest_indices; 230, subscript; 230, 231; 230, 232; 231, identifier:observed_neighbor_indices; 232, slice; 232, 233; 232, 234; 233, colon; 234, identifier:k; 235, expression_statement; 235, 236; 236, assignment; 236, 237; 236, 238; 237, identifier:weights; 238, subscript; 238, 239; 238, 240; 239, identifier:row_weights; 240, identifier:k_nearest_indices; 241, expression_statement; 241, 242; 242, assignment; 242, 243; 242, 244; 243, identifier:weight_sum; 244, call; 244, 245; 244, 248; 245, attribute; 245, 246; 245, 247; 246, identifier:weights; 247, identifier:sum; 248, argument_list; 249, if_statement; 249, 250; 249, 253; 250, comparison_operator:>; 250, 251; 250, 252; 251, identifier:weight_sum; 252, integer:0; 253, block; 253, 254; 253, 262; 253, 268; 254, expression_statement; 254, 255; 255, assignment; 255, 256; 255, 257; 256, identifier:column; 257, subscript; 257, 258; 257, 259; 257, 261; 258, identifier:X_column_major; 259, slice; 259, 260; 260, colon; 261, identifier:j; 262, expression_statement; 262, 263; 263, assignment; 263, 264; 263, 265; 264, identifier:values; 265, subscript; 265, 266; 265, 267; 266, identifier:column; 267, identifier:k_nearest_indices; 268, expression_statement; 268, 269; 269, assignment; 269, 270; 269, 274; 270, subscript; 270, 271; 270, 272; 270, 273; 271, identifier:X_row_major; 272, identifier:i; 273, identifier:j; 274, binary_operator:/; 274, 275; 274, 280; 275, call; 275, 276; 275, 277; 276, identifier:dot; 277, argument_list; 277, 278; 277, 279; 278, identifier:values; 279, identifier:weights; 280, identifier:weight_sum; 281, return_statement; 281, 282; 282, identifier:X_row_major | def knn_impute_few_observed(
X, missing_mask, k, verbose=False, print_interval=100):
start_t = time.time()
n_rows, n_cols = X.shape
missing_mask_column_major = np.asarray(missing_mask, order="F")
observed_mask_column_major = ~missing_mask_column_major
X_column_major = X.copy(order="F")
X_row_major, D, effective_infinity = \
knn_initialize(X, missing_mask, verbose=verbose)
D_sorted = np.argsort(D, axis=1)
inv_D = 1.0 / D
D_valid_mask = D < effective_infinity
valid_distances_per_row = D_valid_mask.sum(axis=1)
D_sorted = [
D_sorted[i, :count]
for i, count in enumerate(valid_distances_per_row)
]
dot = np.dot
for i in range(n_rows):
missing_row = missing_mask[i, :]
missing_indices = np.where(missing_row)[0]
row_weights = inv_D[i, :]
if verbose and i % print_interval == 0:
print(
"Imputing row %d/%d with %d missing, elapsed time: %0.3f" % (
i + 1,
n_rows,
len(missing_indices),
time.time() - start_t))
candidate_neighbor_indices = D_sorted[i]
for j in missing_indices:
observed = observed_mask_column_major[:, j]
sorted_observed = observed[candidate_neighbor_indices]
observed_neighbor_indices = candidate_neighbor_indices[sorted_observed]
k_nearest_indices = observed_neighbor_indices[:k]
weights = row_weights[k_nearest_indices]
weight_sum = weights.sum()
if weight_sum > 0:
column = X_column_major[:, j]
values = column[k_nearest_indices]
X_row_major[i, j] = dot(values, weights) / weight_sum
return X_row_major |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:_sort_converters; 3, parameters; 3, 4; 3, 5; 4, identifier:cls; 5, default_parameter; 5, 6; 5, 7; 6, identifier:app_ready; 7, False; 8, block; 8, 9; 8, 11; 8, 21; 9, expression_statement; 9, 10; 10, string:'''Sorts the converter functions'''; 11, expression_statement; 11, 12; 12, assignment; 12, 13; 12, 16; 13, attribute; 13, 14; 13, 15; 14, identifier:cls; 15, identifier:_sorting_enabled; 16, boolean_operator:or; 16, 17; 16, 20; 17, attribute; 17, 18; 17, 19; 18, identifier:cls; 19, identifier:_sorting_enabled; 20, identifier:app_ready; 21, if_statement; 21, 22; 21, 25; 22, attribute; 22, 23; 22, 24; 23, identifier:cls; 24, identifier:_sorting_enabled; 25, block; 25, 26; 25, 38; 26, for_statement; 26, 27; 26, 28; 26, 31; 27, identifier:converter; 28, attribute; 28, 29; 28, 30; 29, identifier:cls; 30, identifier:converters; 31, block; 31, 32; 32, expression_statement; 32, 33; 33, call; 33, 34; 33, 37; 34, attribute; 34, 35; 34, 36; 35, identifier:converter; 36, identifier:prepare_sort_key; 37, argument_list; 38, expression_statement; 38, 39; 39, call; 39, 40; 39, 45; 40, attribute; 40, 41; 40, 44; 41, attribute; 41, 42; 41, 43; 42, identifier:cls; 43, identifier:converters; 44, identifier:sort; 45, argument_list; 45, 46; 46, keyword_argument; 46, 47; 46, 48; 47, identifier:key; 48, call; 48, 49; 48, 50; 49, identifier:attrgetter; 50, argument_list; 50, 51; 51, string:'sort_key' | def _sort_converters(cls, app_ready=False):
'''Sorts the converter functions'''
cls._sorting_enabled = cls._sorting_enabled or app_ready
if cls._sorting_enabled:
for converter in cls.converters:
converter.prepare_sort_key()
cls.converters.sort(key=attrgetter('sort_key')) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:prepare_sort_key; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 80; 6, expression_statement; 6, 7; 7, string:'''
Triggered by view_function._sort_converters when our sort key should be created.
This can't be called in the constructor because Django models might not be ready yet.
'''; 8, if_statement; 8, 9; 8, 16; 9, call; 9, 10; 9, 11; 10, identifier:isinstance; 11, argument_list; 11, 12; 11, 15; 12, attribute; 12, 13; 12, 14; 13, identifier:self; 14, identifier:convert_type; 15, identifier:str; 16, block; 16, 17; 16, 47; 17, try_statement; 17, 18; 17, 32; 18, block; 18, 19; 19, expression_statement; 19, 20; 20, assignment; 20, 21; 20, 24; 21, pattern_list; 21, 22; 21, 23; 22, identifier:app_name; 23, identifier:model_name; 24, call; 24, 25; 24, 30; 25, attribute; 25, 26; 25, 29; 26, attribute; 26, 27; 26, 28; 27, identifier:self; 28, identifier:convert_type; 29, identifier:split; 30, argument_list; 30, 31; 31, string:'.'; 32, except_clause; 32, 33; 32, 34; 33, identifier:ValueError; 34, block; 34, 35; 35, raise_statement; 35, 36; 36, call; 36, 37; 36, 38; 37, identifier:ImproperlyConfigured; 38, argument_list; 38, 39; 39, call; 39, 40; 39, 43; 40, attribute; 40, 41; 40, 42; 41, string:'"{}" is not a valid converter type. String-based converter types must be specified in "app.Model" format.'; 42, identifier:format; 43, argument_list; 43, 44; 44, attribute; 44, 45; 44, 46; 45, identifier:self; 46, identifier:convert_type; 47, try_statement; 47, 48; 47, 61; 48, block; 48, 49; 49, expression_statement; 49, 50; 50, assignment; 50, 51; 50, 54; 51, attribute; 51, 52; 51, 53; 52, identifier:self; 53, identifier:convert_type; 54, call; 54, 55; 54, 58; 55, attribute; 55, 56; 55, 57; 56, identifier:apps; 57, identifier:get_model; 58, argument_list; 58, 59; 58, 60; 59, identifier:app_name; 60, identifier:model_name; 61, except_clause; 61, 62; 61, 66; 62, as_pattern; 62, 63; 62, 64; 63, identifier:LookupError; 64, as_pattern_target; 64, 65; 65, identifier:e; 66, block; 66, 67; 67, raise_statement; 67, 68; 68, call; 68, 69; 68, 70; 69, identifier:ImproperlyConfigured; 70, argument_list; 70, 71; 71, call; 71, 72; 71, 75; 72, attribute; 72, 73; 72, 74; 73, string:'"{}" is not a valid model name. {}'; 74, identifier:format; 75, argument_list; 75, 76; 75, 79; 76, attribute; 76, 77; 76, 78; 77, identifier:self; 78, identifier:convert_type; 79, identifier:e; 80, expression_statement; 80, 81; 81, assignment; 81, 82; 81, 85; 82, attribute; 82, 83; 82, 84; 83, identifier:self; 84, identifier:sort_key; 85, tuple; 85, 86; 85, 100; 86, binary_operator:*; 86, 87; 86, 89; 87, unary_operator:-; 87, 88; 88, integer:1; 89, call; 89, 90; 89, 91; 90, identifier:len; 91, argument_list; 91, 92; 92, call; 92, 93; 92, 96; 93, attribute; 93, 94; 93, 95; 94, identifier:inspect; 95, identifier:getmro; 96, argument_list; 96, 97; 97, attribute; 97, 98; 97, 99; 98, identifier:self; 99, identifier:convert_type; 100, binary_operator:*; 100, 101; 100, 103; 101, unary_operator:-; 101, 102; 102, integer:1; 103, attribute; 103, 104; 103, 105; 104, identifier:self; 105, identifier:source_order | def prepare_sort_key(self):
'''
Triggered by view_function._sort_converters when our sort key should be created.
This can't be called in the constructor because Django models might not be ready yet.
'''
if isinstance(self.convert_type, str):
try:
app_name, model_name = self.convert_type.split('.')
except ValueError:
raise ImproperlyConfigured('"{}" is not a valid converter type. String-based converter types must be specified in "app.Model" format.'.format(self.convert_type))
try:
self.convert_type = apps.get_model(app_name, model_name)
except LookupError as e:
raise ImproperlyConfigured('"{}" is not a valid model name. {}'.format(self.convert_type, e))
self.sort_key = ( -1 * len(inspect.getmro(self.convert_type)), -1 * self.source_order ) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:sort_key_for_numeric_suffixes; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:path; 5, default_parameter; 5, 6; 5, 7; 6, identifier:sep; 7, string:'.'; 8, default_parameter; 8, 9; 8, 10; 9, identifier:suffix_index; 10, unary_operator:-; 10, 11; 11, integer:2; 12, block; 12, 13; 12, 22; 12, 57; 13, expression_statement; 13, 14; 14, assignment; 14, 15; 14, 16; 15, identifier:chunks; 16, call; 16, 17; 16, 20; 17, attribute; 17, 18; 17, 19; 18, identifier:path; 19, identifier:split; 20, argument_list; 20, 21; 21, identifier:sep; 22, if_statement; 22, 23; 22, 30; 23, call; 23, 24; 23, 29; 24, attribute; 24, 25; 24, 28; 25, subscript; 25, 26; 25, 27; 26, identifier:chunks; 27, identifier:suffix_index; 28, identifier:isdigit; 29, argument_list; 30, block; 30, 31; 31, return_statement; 31, 32; 32, expression_list; 32, 33; 32, 51; 33, call; 33, 34; 33, 37; 34, attribute; 34, 35; 34, 36; 35, identifier:sep; 36, identifier:join; 37, argument_list; 37, 38; 38, binary_operator:+; 38, 39; 38, 44; 39, subscript; 39, 40; 39, 41; 40, identifier:chunks; 41, slice; 41, 42; 41, 43; 42, colon; 43, identifier:suffix_index; 44, subscript; 44, 45; 44, 46; 45, identifier:chunks; 46, slice; 46, 47; 46, 50; 47, binary_operator:+; 47, 48; 47, 49; 48, identifier:suffix_index; 49, integer:1; 50, colon; 51, call; 51, 52; 51, 53; 52, identifier:int; 53, argument_list; 53, 54; 54, subscript; 54, 55; 54, 56; 55, identifier:chunks; 56, identifier:suffix_index; 57, return_statement; 57, 58; 58, expression_list; 58, 59; 58, 60; 59, identifier:path; 60, integer:0 | def sort_key_for_numeric_suffixes(path, sep='.', suffix_index=-2):
chunks = path.split(sep)
if chunks[suffix_index].isdigit():
return sep.join(chunks[:suffix_index] + chunks[suffix_index+1:]), int(chunks[suffix_index])
return path, 0 |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_get_query; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:cursor; 6, block; 6, 7; 6, 9; 6, 27; 6, 45; 6, 56; 7, expression_statement; 7, 8; 8, string:'''
Query tempalte for source Solr, sorts by id by default.
'''; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 11, identifier:query; 12, dictionary; 12, 13; 12, 16; 12, 19; 12, 24; 13, pair; 13, 14; 13, 15; 14, string:'q'; 15, string:'*:*'; 16, pair; 16, 17; 16, 18; 17, string:'sort'; 18, string:'id desc'; 19, pair; 19, 20; 19, 21; 20, string:'rows'; 21, attribute; 21, 22; 21, 23; 22, identifier:self; 23, identifier:_rows; 24, pair; 24, 25; 24, 26; 25, string:'cursorMark'; 26, identifier:cursor; 27, if_statement; 27, 28; 27, 31; 28, attribute; 28, 29; 28, 30; 29, identifier:self; 30, identifier:_date_field; 31, block; 31, 32; 32, expression_statement; 32, 33; 33, assignment; 33, 34; 33, 37; 34, subscript; 34, 35; 34, 36; 35, identifier:query; 36, string:'sort'; 37, call; 37, 38; 37, 41; 38, attribute; 38, 39; 38, 40; 39, string:"{} asc, id desc"; 40, identifier:format; 41, argument_list; 41, 42; 42, attribute; 42, 43; 42, 44; 43, identifier:self; 44, identifier:_date_field; 45, if_statement; 45, 46; 45, 49; 46, attribute; 46, 47; 46, 48; 47, identifier:self; 48, identifier:_per_shard; 49, block; 49, 50; 50, expression_statement; 50, 51; 51, assignment; 51, 52; 51, 55; 52, subscript; 52, 53; 52, 54; 53, identifier:query; 54, string:'distrib'; 55, string:'false'; 56, return_statement; 56, 57; 57, identifier:query | def _get_query(self, cursor):
'''
Query tempalte for source Solr, sorts by id by default.
'''
query = {'q':'*:*',
'sort':'id desc',
'rows':self._rows,
'cursorMark':cursor}
if self._date_field:
query['sort'] = "{} asc, id desc".format(self._date_field)
if self._per_shard:
query['distrib'] = 'false'
return query |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:url_params; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:request; 5, default_parameter; 5, 6; 5, 7; 6, identifier:except_params; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:as_is; 10, False; 11, block; 11, 12; 11, 20; 11, 24; 11, 68; 11, 102; 12, if_statement; 12, 13; 12, 17; 13, not_operator; 13, 14; 14, attribute; 14, 15; 14, 16; 15, identifier:request; 16, identifier:GET; 17, block; 17, 18; 18, return_statement; 18, 19; 19, string:''; 20, expression_statement; 20, 21; 21, assignment; 21, 22; 21, 23; 22, identifier:params; 23, list:[]; 24, for_statement; 24, 25; 24, 28; 24, 35; 25, pattern_list; 25, 26; 25, 27; 26, identifier:key; 27, identifier:value; 28, call; 28, 29; 28, 34; 29, attribute; 29, 30; 29, 33; 30, attribute; 30, 31; 30, 32; 31, identifier:request; 32, identifier:GET; 33, identifier:items; 34, argument_list; 35, block; 35, 36; 36, if_statement; 36, 37; 36, 42; 37, boolean_operator:and; 37, 38; 37, 39; 38, identifier:except_params; 39, comparison_operator:not; 39, 40; 39, 41; 40, identifier:key; 41, identifier:except_params; 42, block; 42, 43; 43, for_statement; 43, 44; 43, 45; 43, 53; 44, identifier:v; 45, call; 45, 46; 45, 51; 46, attribute; 46, 47; 46, 50; 47, attribute; 47, 48; 47, 49; 48, identifier:request; 49, identifier:GET; 50, identifier:getlist; 51, argument_list; 51, 52; 52, identifier:key; 53, block; 53, 54; 54, expression_statement; 54, 55; 55, call; 55, 56; 55, 59; 56, attribute; 56, 57; 56, 58; 57, identifier:params; 58, identifier:append; 59, argument_list; 59, 60; 60, binary_operator:%; 60, 61; 60, 62; 61, string:'%s=%s'; 62, tuple; 62, 63; 62, 64; 63, identifier:key; 64, call; 64, 65; 64, 66; 65, identifier:urlquote; 66, argument_list; 66, 67; 67, identifier:v; 68, if_statement; 68, 69; 68, 70; 68, 82; 69, identifier:as_is; 70, block; 70, 71; 71, expression_statement; 71, 72; 72, assignment; 72, 73; 72, 74; 73, identifier:str_params; 74, binary_operator:+; 74, 75; 74, 76; 75, string:'?'; 76, call; 76, 77; 76, 80; 77, attribute; 77, 78; 77, 79; 78, string:'&'; 79, identifier:join; 80, argument_list; 80, 81; 81, identifier:params; 82, else_clause; 82, 83; 83, block; 83, 84; 83, 95; 84, expression_statement; 84, 85; 85, assignment; 85, 86; 85, 87; 86, identifier:str_params; 87, binary_operator:+; 87, 88; 87, 89; 88, string:'?'; 89, call; 89, 90; 89, 93; 90, attribute; 90, 91; 90, 92; 91, string:'&'; 92, identifier:join; 93, argument_list; 93, 94; 94, identifier:params; 95, expression_statement; 95, 96; 96, assignment; 96, 97; 96, 98; 97, identifier:str_params; 98, call; 98, 99; 98, 100; 99, identifier:urlquote; 100, argument_list; 100, 101; 101, identifier:str_params; 102, return_statement; 102, 103; 103, call; 103, 104; 103, 105; 104, identifier:mark_safe; 105, argument_list; 105, 106; 106, identifier:str_params | def url_params(request, except_params=None, as_is=False):
if not request.GET:
return ''
params = []
for key, value in request.GET.items():
if except_params and key not in except_params:
for v in request.GET.getlist(key):
params.append('%s=%s' % (key, urlquote(v)))
if as_is:
str_params = '?' + '&'.join(params)
else:
str_params = '?' + '&'.join(params)
str_params = urlquote(str_params)
return mark_safe(str_params) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:compose; 3, parameters; 3, 4; 4, list_splat_pattern; 4, 5; 5, identifier:funcs; 6, block; 6, 7; 7, if_statement; 7, 8; 7, 14; 7, 38; 7, 73; 7, 86; 7, 98; 8, comparison_operator:==; 8, 9; 8, 13; 9, call; 9, 10; 9, 11; 10, identifier:len; 11, argument_list; 11, 12; 12, identifier:funcs; 13, integer:2; 14, block; 14, 15; 14, 21; 15, expression_statement; 15, 16; 16, assignment; 16, 17; 16, 20; 17, pattern_list; 17, 18; 17, 19; 18, identifier:f0; 19, identifier:f1; 20, identifier:funcs; 21, return_statement; 21, 22; 22, lambda; 22, 23; 22, 28; 23, lambda_parameters; 23, 24; 23, 26; 24, list_splat_pattern; 24, 25; 25, identifier:a; 26, dictionary_splat_pattern; 26, 27; 27, identifier:kw; 28, call; 28, 29; 28, 30; 29, identifier:f0; 30, argument_list; 30, 31; 31, call; 31, 32; 31, 33; 32, identifier:f1; 33, argument_list; 33, 34; 33, 36; 34, list_splat; 34, 35; 35, identifier:a; 36, dictionary_splat; 36, 37; 37, identifier:kw; 38, elif_clause; 38, 39; 38, 45; 39, comparison_operator:==; 39, 40; 39, 44; 40, call; 40, 41; 40, 42; 41, identifier:len; 42, argument_list; 42, 43; 43, identifier:funcs; 44, integer:3; 45, block; 45, 46; 45, 53; 46, expression_statement; 46, 47; 47, assignment; 47, 48; 47, 52; 48, pattern_list; 48, 49; 48, 50; 48, 51; 49, identifier:f0; 50, identifier:f1; 51, identifier:f2; 52, identifier:funcs; 53, return_statement; 53, 54; 54, lambda; 54, 55; 54, 60; 55, lambda_parameters; 55, 56; 55, 58; 56, list_splat_pattern; 56, 57; 57, identifier:a; 58, dictionary_splat_pattern; 58, 59; 59, identifier:kw; 60, call; 60, 61; 60, 62; 61, identifier:f0; 62, argument_list; 62, 63; 63, call; 63, 64; 63, 65; 64, identifier:f1; 65, argument_list; 65, 66; 66, call; 66, 67; 66, 68; 67, identifier:f2; 68, argument_list; 68, 69; 68, 71; 69, list_splat; 69, 70; 70, identifier:a; 71, dictionary_splat; 71, 72; 72, identifier:kw; 73, elif_clause; 73, 74; 73, 80; 74, comparison_operator:==; 74, 75; 74, 79; 75, call; 75, 76; 75, 77; 76, identifier:len; 77, argument_list; 77, 78; 78, identifier:funcs; 79, integer:0; 80, block; 80, 81; 81, return_statement; 81, 82; 82, lambda; 82, 83; 82, 85; 83, lambda_parameters; 83, 84; 84, identifier:x; 85, identifier:x; 86, elif_clause; 86, 87; 86, 93; 87, comparison_operator:==; 87, 88; 87, 92; 88, call; 88, 89; 88, 90; 89, identifier:len; 90, argument_list; 90, 91; 91, identifier:funcs; 92, integer:1; 93, block; 93, 94; 94, return_statement; 94, 95; 95, subscript; 95, 96; 95, 97; 96, identifier:funcs; 97, integer:0; 98, else_clause; 98, 99; 99, block; 99, 100; 99, 141; 100, function_definition; 100, 101; 100, 102; 100, 107; 101, function_name:composed; 102, parameters; 102, 103; 102, 105; 103, list_splat_pattern; 103, 104; 104, identifier:args; 105, dictionary_splat_pattern; 105, 106; 106, identifier:kwargs; 107, block; 107, 108; 107, 121; 107, 139; 108, expression_statement; 108, 109; 109, assignment; 109, 110; 109, 111; 110, identifier:y; 111, call; 111, 112; 111, 116; 112, subscript; 112, 113; 112, 114; 113, identifier:funcs; 114, unary_operator:-; 114, 115; 115, integer:1; 116, argument_list; 116, 117; 116, 119; 117, list_splat; 117, 118; 118, identifier:args; 119, dictionary_splat; 119, 120; 120, identifier:kwargs; 121, for_statement; 121, 122; 121, 123; 121, 131; 122, identifier:f; 123, subscript; 123, 124; 123, 125; 124, identifier:funcs; 125, slice; 125, 126; 125, 127; 125, 128; 125, 129; 126, colon; 127, integer:0; 128, colon; 129, unary_operator:-; 129, 130; 130, integer:1; 131, block; 131, 132; 132, expression_statement; 132, 133; 133, assignment; 133, 134; 133, 135; 134, identifier:y; 135, call; 135, 136; 135, 137; 136, identifier:f; 137, argument_list; 137, 138; 138, identifier:y; 139, return_statement; 139, 140; 140, identifier:y; 141, return_statement; 141, 142; 142, identifier:composed | def compose(*funcs):
if len(funcs) == 2: f0,f1=funcs; return lambda *a,**kw: f0(f1(*a,**kw))
elif len(funcs) == 3: f0,f1,f2=funcs; return lambda *a,**kw: f0(f1(f2(*a,**kw)))
elif len(funcs) == 0: return lambda x:x
elif len(funcs) == 1: return funcs[0]
else:
def composed(*args,**kwargs):
y = funcs[-1](*args,**kwargs)
for f in funcs[:0:-1]: y = f(y)
return y
return composed |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_sort_lines; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 11; 8, attribute; 8, 9; 8, 10; 9, identifier:self; 10, identifier:_valid_lines; 11, call; 11, 12; 11, 13; 12, identifier:sorted; 13, argument_list; 13, 14; 13, 17; 14, attribute; 14, 15; 14, 16; 15, identifier:self; 16, identifier:_valid_lines; 17, keyword_argument; 17, 18; 17, 19; 18, identifier:key; 19, lambda; 19, 20; 19, 22; 20, lambda_parameters; 20, 21; 21, identifier:line; 22, attribute; 22, 23; 22, 24; 23, identifier:line; 24, identifier:accept_date | def _sort_lines(self):
self._valid_lines = sorted(
self._valid_lines,
key=lambda line: line.accept_date,
) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:_sort_and_trim; 3, parameters; 3, 4; 3, 5; 4, identifier:data; 5, default_parameter; 5, 6; 5, 7; 6, identifier:reverse; 7, False; 8, block; 8, 9; 8, 13; 8, 21; 8, 39; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 11, identifier:threshold; 12, integer:10; 13, expression_statement; 13, 14; 14, assignment; 14, 15; 14, 16; 15, identifier:data_list; 16, call; 16, 17; 16, 20; 17, attribute; 17, 18; 17, 19; 18, identifier:data; 19, identifier:items; 20, argument_list; 21, expression_statement; 21, 22; 22, assignment; 22, 23; 22, 24; 23, identifier:data_list; 24, call; 24, 25; 24, 26; 25, identifier:sorted; 26, argument_list; 26, 27; 26, 28; 26, 36; 27, identifier:data_list; 28, keyword_argument; 28, 29; 28, 30; 29, identifier:key; 30, lambda; 30, 31; 30, 33; 31, lambda_parameters; 31, 32; 32, identifier:data_info; 33, subscript; 33, 34; 33, 35; 34, identifier:data_info; 35, integer:1; 36, keyword_argument; 36, 37; 36, 38; 37, identifier:reverse; 38, identifier:reverse; 39, return_statement; 39, 40; 40, subscript; 40, 41; 40, 42; 41, identifier:data_list; 42, slice; 42, 43; 42, 44; 43, colon; 44, identifier:threshold | def _sort_and_trim(data, reverse=False):
threshold = 10
data_list = data.items()
data_list = sorted(
data_list,
key=lambda data_info: data_info[1],
reverse=reverse,
)
return data_list[:threshold] |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:get_queryset; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 20; 5, 29; 5, 38; 6, expression_statement; 6, 7; 7, string:'''Apply Datatables sort and search criterion to QuerySet'''; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:qs; 11, call; 11, 12; 11, 19; 12, attribute; 12, 13; 12, 18; 13, call; 13, 14; 13, 15; 14, identifier:super; 15, argument_list; 15, 16; 15, 17; 16, identifier:DatatablesView; 17, identifier:self; 18, identifier:get_queryset; 19, argument_list; 20, expression_statement; 20, 21; 21, assignment; 21, 22; 21, 23; 22, identifier:qs; 23, call; 23, 24; 23, 27; 24, attribute; 24, 25; 24, 26; 25, identifier:self; 26, identifier:global_search; 27, argument_list; 27, 28; 28, identifier:qs; 29, expression_statement; 29, 30; 30, assignment; 30, 31; 30, 32; 31, identifier:qs; 32, call; 32, 33; 32, 36; 33, attribute; 33, 34; 33, 35; 34, identifier:self; 35, identifier:column_search; 36, argument_list; 36, 37; 37, identifier:qs; 38, return_statement; 38, 39; 39, call; 39, 40; 39, 43; 40, attribute; 40, 41; 40, 42; 41, identifier:qs; 42, identifier:order_by; 43, argument_list; 43, 44; 44, list_splat; 44, 45; 45, call; 45, 46; 45, 49; 46, attribute; 46, 47; 46, 48; 47, identifier:self; 48, identifier:get_orders; 49, argument_list | def get_queryset(self):
'''Apply Datatables sort and search criterion to QuerySet'''
qs = super(DatatablesView, self).get_queryset()
qs = self.global_search(qs)
qs = self.column_search(qs)
return qs.order_by(*self.get_orders()) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:rangify; 3, parameters; 3, 4; 4, identifier:number_list; 5, block; 5, 6; 5, 12; 5, 16; 5, 24; 5, 57; 5, 66; 6, if_statement; 6, 7; 6, 9; 7, not_operator; 7, 8; 8, identifier:number_list; 9, block; 9, 10; 10, return_statement; 10, 11; 11, identifier:number_list; 12, expression_statement; 12, 13; 13, assignment; 13, 14; 13, 15; 14, identifier:ranges; 15, list:[]; 16, expression_statement; 16, 17; 17, assignment; 17, 18; 17, 19; 18, identifier:range_start; 19, assignment; 19, 20; 19, 21; 20, identifier:prev_num; 21, subscript; 21, 22; 21, 23; 22, identifier:number_list; 23, integer:0; 24, for_statement; 24, 25; 24, 26; 24, 31; 25, identifier:num; 26, subscript; 26, 27; 26, 28; 27, identifier:number_list; 28, slice; 28, 29; 28, 30; 29, integer:1; 30, colon; 31, block; 31, 32; 31, 53; 32, if_statement; 32, 33; 32, 39; 33, comparison_operator:!=; 33, 34; 33, 35; 34, identifier:num; 35, parenthesized_expression; 35, 36; 36, binary_operator:+; 36, 37; 36, 38; 37, identifier:prev_num; 38, integer:1; 39, block; 39, 40; 39, 49; 40, expression_statement; 40, 41; 41, call; 41, 42; 41, 45; 42, attribute; 42, 43; 42, 44; 43, identifier:ranges; 44, identifier:append; 45, argument_list; 45, 46; 46, tuple; 46, 47; 46, 48; 47, identifier:range_start; 48, identifier:prev_num; 49, expression_statement; 49, 50; 50, assignment; 50, 51; 50, 52; 51, identifier:range_start; 52, identifier:num; 53, expression_statement; 53, 54; 54, assignment; 54, 55; 54, 56; 55, identifier:prev_num; 56, identifier:num; 57, expression_statement; 57, 58; 58, call; 58, 59; 58, 62; 59, attribute; 59, 60; 59, 61; 60, identifier:ranges; 61, identifier:append; 62, argument_list; 62, 63; 63, tuple; 63, 64; 63, 65; 64, identifier:range_start; 65, identifier:prev_num; 66, return_statement; 66, 67; 67, identifier:ranges | def rangify(number_list):
if not number_list:
return number_list
ranges = []
range_start = prev_num = number_list[0]
for num in number_list[1:]:
if num != (prev_num + 1):
ranges.append((range_start, prev_num))
range_start = num
prev_num = num
ranges.append((range_start, prev_num))
return ranges |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 13; 2, function_name:get_solver; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:name; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:refresh; 10, False; 11, dictionary_splat_pattern; 11, 12; 12, identifier:filters; 13, block; 13, 14; 13, 22; 13, 35; 13, 49; 14, expression_statement; 14, 15; 15, call; 15, 16; 15, 19; 16, attribute; 16, 17; 16, 18; 17, identifier:_LOGGER; 18, identifier:debug; 19, argument_list; 19, 20; 19, 21; 20, string:"Requested a solver that best matches feature filters=%r"; 21, identifier:filters; 22, if_statement; 22, 23; 22, 26; 23, comparison_operator:is; 23, 24; 23, 25; 24, identifier:name; 25, None; 26, block; 26, 27; 27, expression_statement; 27, 28; 28, call; 28, 29; 28, 32; 29, attribute; 29, 30; 29, 31; 30, identifier:filters; 31, identifier:setdefault; 32, argument_list; 32, 33; 32, 34; 33, string:'name'; 34, identifier:name; 35, if_statement; 35, 36; 35, 42; 36, boolean_operator:and; 36, 37; 36, 39; 37, not_operator; 37, 38; 38, identifier:filters; 39, attribute; 39, 40; 39, 41; 40, identifier:self; 41, identifier:default_solver; 42, block; 42, 43; 43, expression_statement; 43, 44; 44, assignment; 44, 45; 44, 46; 45, identifier:filters; 46, attribute; 46, 47; 46, 48; 47, identifier:self; 48, identifier:default_solver; 49, try_statement; 49, 50; 49, 72; 50, block; 50, 51; 50, 59; 51, expression_statement; 51, 52; 52, call; 52, 53; 52, 56; 53, attribute; 53, 54; 53, 55; 54, identifier:_LOGGER; 55, identifier:debug; 56, argument_list; 56, 57; 56, 58; 57, string:"Fetching solvers according to filters=%r"; 58, identifier:filters; 59, return_statement; 59, 60; 60, subscript; 60, 61; 60, 71; 61, call; 61, 62; 61, 65; 62, attribute; 62, 63; 62, 64; 63, identifier:self; 64, identifier:get_solvers; 65, argument_list; 65, 66; 65, 69; 66, keyword_argument; 66, 67; 66, 68; 67, identifier:refresh; 68, identifier:refresh; 69, dictionary_splat; 69, 70; 70, identifier:filters; 71, integer:0; 72, except_clause; 72, 73; 72, 74; 73, identifier:IndexError; 74, block; 74, 75; 75, raise_statement; 75, 76; 76, call; 76, 77; 76, 78; 77, identifier:SolverNotFoundError; 78, argument_list; 78, 79; 79, string:"Solver with the requested features not available" | def get_solver(self, name=None, refresh=False, **filters):
_LOGGER.debug("Requested a solver that best matches feature filters=%r", filters)
if name is not None:
filters.setdefault('name', name)
if not filters and self.default_solver:
filters = self.default_solver
try:
_LOGGER.debug("Fetching solvers according to filters=%r", filters)
return self.get_solvers(refresh=refresh, **filters)[0]
except IndexError:
raise SolverNotFoundError("Solver with the requested features not available") |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:find_germanet_xml_files; 3, parameters; 3, 4; 4, identifier:xml_path; 5, block; 5, 6; 5, 8; 5, 28; 5, 55; 5, 70; 5, 79; 5, 102; 5, 117; 5, 153; 5, 180; 5, 195; 5, 204; 5, 230; 5, 245; 5, 254; 5, 263; 6, expression_statement; 6, 7; 7, string:'''
Globs the XML files contained in the given directory and sorts
them into sections for import into the MongoDB database.
Arguments:
- `xml_path`: the path to the directory containing the GermaNet
XML files
'''; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:xml_files; 11, call; 11, 12; 11, 13; 12, identifier:sorted; 13, argument_list; 13, 14; 14, call; 14, 15; 14, 18; 15, attribute; 15, 16; 15, 17; 16, identifier:glob; 17, identifier:glob; 18, argument_list; 18, 19; 19, call; 19, 20; 19, 25; 20, attribute; 20, 21; 20, 24; 21, attribute; 21, 22; 21, 23; 22, identifier:os; 23, identifier:path; 24, identifier:join; 25, argument_list; 25, 26; 25, 27; 26, identifier:xml_path; 27, string:'*.xml'; 28, expression_statement; 28, 29; 29, assignment; 29, 30; 29, 31; 30, identifier:lex_files; 31, list_comprehension; 31, 32; 31, 33; 31, 36; 32, identifier:xml_file; 33, for_in_clause; 33, 34; 33, 35; 34, identifier:xml_file; 35, identifier:xml_files; 36, if_clause; 36, 37; 37, call; 37, 38; 37, 41; 38, attribute; 38, 39; 38, 40; 39, identifier:re; 40, identifier:match; 41, argument_list; 41, 42; 41, 43; 42, string:r'(adj|nomen|verben)\.'; 43, call; 43, 44; 43, 54; 44, attribute; 44, 45; 44, 53; 45, call; 45, 46; 45, 51; 46, attribute; 46, 47; 46, 50; 47, attribute; 47, 48; 47, 49; 48, identifier:os; 49, identifier:path; 50, identifier:basename; 51, argument_list; 51, 52; 52, identifier:xml_file; 53, identifier:lower; 54, argument_list; 55, expression_statement; 55, 56; 56, assignment; 56, 57; 56, 58; 57, identifier:xml_files; 58, call; 58, 59; 58, 60; 59, identifier:sorted; 60, argument_list; 60, 61; 61, binary_operator:-; 61, 62; 61, 66; 62, call; 62, 63; 62, 64; 63, identifier:set; 64, argument_list; 64, 65; 65, identifier:xml_files; 66, call; 66, 67; 66, 68; 67, identifier:set; 68, argument_list; 68, 69; 69, identifier:lex_files; 70, if_statement; 70, 71; 70, 73; 71, not_operator; 71, 72; 72, identifier:lex_files; 73, block; 73, 74; 74, expression_statement; 74, 75; 75, call; 75, 76; 75, 77; 76, identifier:print; 77, argument_list; 77, 78; 78, string:'ERROR: cannot find lexical information files'; 79, expression_statement; 79, 80; 80, assignment; 80, 81; 80, 82; 81, identifier:gn_rels_file; 82, list_comprehension; 82, 83; 82, 84; 82, 87; 83, identifier:xml_file; 84, for_in_clause; 84, 85; 84, 86; 85, identifier:xml_file; 86, identifier:xml_files; 87, if_clause; 87, 88; 88, comparison_operator:==; 88, 89; 88, 101; 89, call; 89, 90; 89, 100; 90, attribute; 90, 91; 90, 99; 91, call; 91, 92; 91, 97; 92, attribute; 92, 93; 92, 96; 93, attribute; 93, 94; 93, 95; 94, identifier:os; 95, identifier:path; 96, identifier:basename; 97, argument_list; 97, 98; 98, identifier:xml_file; 99, identifier:lower; 100, argument_list; 101, string:'gn_relations.xml'; 102, expression_statement; 102, 103; 103, assignment; 103, 104; 103, 105; 104, identifier:xml_files; 105, call; 105, 106; 105, 107; 106, identifier:sorted; 107, argument_list; 107, 108; 108, binary_operator:-; 108, 109; 108, 113; 109, call; 109, 110; 109, 111; 110, identifier:set; 111, argument_list; 111, 112; 112, identifier:xml_files; 113, call; 113, 114; 113, 115; 114, identifier:set; 115, argument_list; 115, 116; 116, identifier:gn_rels_file; 117, if_statement; 117, 118; 117, 120; 117, 130; 118, not_operator; 118, 119; 119, identifier:gn_rels_file; 120, block; 120, 121; 120, 126; 121, expression_statement; 121, 122; 122, call; 122, 123; 122, 124; 123, identifier:print; 124, argument_list; 124, 125; 125, string:'ERROR: cannot find relations file gn_relations.xml'; 126, expression_statement; 126, 127; 127, assignment; 127, 128; 127, 129; 128, identifier:gn_rels_file; 129, None; 130, else_clause; 130, 131; 131, block; 131, 132; 131, 147; 132, if_statement; 132, 133; 132, 139; 133, comparison_operator:<; 133, 134; 133, 135; 134, integer:1; 135, call; 135, 136; 135, 137; 136, identifier:len; 137, argument_list; 137, 138; 138, identifier:gn_rels_file; 139, block; 139, 140; 140, expression_statement; 140, 141; 141, call; 141, 142; 141, 143; 142, identifier:print; 143, argument_list; 143, 144; 144, concatenated_string; 144, 145; 144, 146; 145, string:'WARNING: more than one relations file gn_relations.xml, '; 146, string:'taking first match'; 147, expression_statement; 147, 148; 148, assignment; 148, 149; 148, 150; 149, identifier:gn_rels_file; 150, subscript; 150, 151; 150, 152; 151, identifier:gn_rels_file; 152, integer:0; 153, expression_statement; 153, 154; 154, assignment; 154, 155; 154, 156; 155, identifier:wiktionary_files; 156, list_comprehension; 156, 157; 156, 158; 156, 161; 157, identifier:xml_file; 158, for_in_clause; 158, 159; 158, 160; 159, identifier:xml_file; 160, identifier:xml_files; 161, if_clause; 161, 162; 162, call; 162, 163; 162, 166; 163, attribute; 163, 164; 163, 165; 164, identifier:re; 165, identifier:match; 166, argument_list; 166, 167; 166, 168; 167, string:r'wiktionaryparaphrases-'; 168, call; 168, 169; 168, 179; 169, attribute; 169, 170; 169, 178; 170, call; 170, 171; 170, 176; 171, attribute; 171, 172; 171, 175; 172, attribute; 172, 173; 172, 174; 173, identifier:os; 174, identifier:path; 175, identifier:basename; 176, argument_list; 176, 177; 177, identifier:xml_file; 178, identifier:lower; 179, argument_list; 180, expression_statement; 180, 181; 181, assignment; 181, 182; 181, 183; 182, identifier:xml_files; 183, call; 183, 184; 183, 185; 184, identifier:sorted; 185, argument_list; 185, 186; 186, binary_operator:-; 186, 187; 186, 191; 187, call; 187, 188; 187, 189; 188, identifier:set; 189, argument_list; 189, 190; 190, identifier:xml_files; 191, call; 191, 192; 191, 193; 192, identifier:set; 193, argument_list; 193, 194; 194, identifier:wiktionary_files; 195, if_statement; 195, 196; 195, 198; 196, not_operator; 196, 197; 197, identifier:wiktionary_files; 198, block; 198, 199; 199, expression_statement; 199, 200; 200, call; 200, 201; 200, 202; 201, identifier:print; 202, argument_list; 202, 203; 203, string:'WARNING: cannot find wiktionary paraphrase files'; 204, expression_statement; 204, 205; 205, assignment; 205, 206; 205, 207; 206, identifier:ili_files; 207, list_comprehension; 207, 208; 207, 209; 207, 212; 208, identifier:xml_file; 209, for_in_clause; 209, 210; 209, 211; 210, identifier:xml_file; 211, identifier:xml_files; 212, if_clause; 212, 213; 213, call; 213, 214; 213, 228; 214, attribute; 214, 215; 214, 227; 215, call; 215, 216; 215, 226; 216, attribute; 216, 217; 216, 225; 217, call; 217, 218; 217, 223; 218, attribute; 218, 219; 218, 222; 219, attribute; 219, 220; 219, 221; 220, identifier:os; 221, identifier:path; 222, identifier:basename; 223, argument_list; 223, 224; 224, identifier:xml_file; 225, identifier:lower; 226, argument_list; 227, identifier:startswith; 228, argument_list; 228, 229; 229, string:'interlingualindex'; 230, expression_statement; 230, 231; 231, assignment; 231, 232; 231, 233; 232, identifier:xml_files; 233, call; 233, 234; 233, 235; 234, identifier:sorted; 235, argument_list; 235, 236; 236, binary_operator:-; 236, 237; 236, 241; 237, call; 237, 238; 237, 239; 238, identifier:set; 239, argument_list; 239, 240; 240, identifier:xml_files; 241, call; 241, 242; 241, 243; 242, identifier:set; 243, argument_list; 243, 244; 244, identifier:ili_files; 245, if_statement; 245, 246; 245, 248; 246, not_operator; 246, 247; 247, identifier:ili_files; 248, block; 248, 249; 249, expression_statement; 249, 250; 250, call; 250, 251; 250, 252; 251, identifier:print; 252, argument_list; 252, 253; 253, string:'WARNING: cannot find interlingual index file'; 254, if_statement; 254, 255; 254, 256; 255, identifier:xml_files; 256, block; 256, 257; 257, expression_statement; 257, 258; 258, call; 258, 259; 258, 260; 259, identifier:print; 260, argument_list; 260, 261; 260, 262; 261, string:'WARNING: unrecognised xml files:'; 262, identifier:xml_files; 263, return_statement; 263, 264; 264, expression_list; 264, 265; 264, 266; 264, 267; 264, 268; 265, identifier:lex_files; 266, identifier:gn_rels_file; 267, identifier:wiktionary_files; 268, identifier:ili_files | def find_germanet_xml_files(xml_path):
'''
Globs the XML files contained in the given directory and sorts
them into sections for import into the MongoDB database.
Arguments:
- `xml_path`: the path to the directory containing the GermaNet
XML files
'''
xml_files = sorted(glob.glob(os.path.join(xml_path, '*.xml')))
lex_files = [xml_file for xml_file in xml_files if
re.match(r'(adj|nomen|verben)\.',
os.path.basename(xml_file).lower())]
xml_files = sorted(set(xml_files) - set(lex_files))
if not lex_files:
print('ERROR: cannot find lexical information files')
gn_rels_file = [xml_file for xml_file in xml_files if
os.path.basename(xml_file).lower() == 'gn_relations.xml']
xml_files = sorted(set(xml_files) - set(gn_rels_file))
if not gn_rels_file:
print('ERROR: cannot find relations file gn_relations.xml')
gn_rels_file = None
else:
if 1 < len(gn_rels_file):
print ('WARNING: more than one relations file gn_relations.xml, '
'taking first match')
gn_rels_file = gn_rels_file[0]
wiktionary_files = [xml_file for xml_file in xml_files if
re.match(r'wiktionaryparaphrases-',
os.path.basename(xml_file).lower())]
xml_files = sorted(set(xml_files) - set(wiktionary_files))
if not wiktionary_files:
print('WARNING: cannot find wiktionary paraphrase files')
ili_files = [xml_file for xml_file in xml_files if
os.path.basename(xml_file).lower().startswith(
'interlingualindex')]
xml_files = sorted(set(xml_files) - set(ili_files))
if not ili_files:
print('WARNING: cannot find interlingual index file')
if xml_files:
print('WARNING: unrecognised xml files:', xml_files)
return lex_files, gn_rels_file, wiktionary_files, ili_files |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 31; 2, function_name:iter_org_issues; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 3, 18; 3, 21; 3, 24; 3, 28; 4, identifier:self; 5, identifier:name; 6, default_parameter; 6, 7; 6, 8; 7, identifier:filter; 8, string:''; 9, default_parameter; 9, 10; 9, 11; 10, identifier:state; 11, string:''; 12, default_parameter; 12, 13; 12, 14; 13, identifier:labels; 14, string:''; 15, default_parameter; 15, 16; 15, 17; 16, identifier:sort; 17, string:''; 18, default_parameter; 18, 19; 18, 20; 19, identifier:direction; 20, string:''; 21, default_parameter; 21, 22; 21, 23; 22, identifier:since; 23, None; 24, default_parameter; 24, 25; 24, 26; 25, identifier:number; 26, unary_operator:-; 26, 27; 27, integer:1; 28, default_parameter; 28, 29; 28, 30; 29, identifier:etag; 30, None; 31, block; 31, 32; 31, 43; 31, 55; 32, expression_statement; 32, 33; 33, assignment; 33, 34; 33, 35; 34, identifier:url; 35, call; 35, 36; 35, 39; 36, attribute; 36, 37; 36, 38; 37, identifier:self; 38, identifier:_build_url; 39, argument_list; 39, 40; 39, 41; 39, 42; 40, string:'orgs'; 41, identifier:name; 42, string:'issues'; 43, expression_statement; 43, 44; 44, assignment; 44, 45; 44, 46; 45, identifier:params; 46, call; 46, 47; 46, 48; 47, identifier:issue_params; 48, argument_list; 48, 49; 48, 50; 48, 51; 48, 52; 48, 53; 48, 54; 49, identifier:filter; 50, identifier:state; 51, identifier:labels; 52, identifier:sort; 53, identifier:direction; 54, identifier:since; 55, return_statement; 55, 56; 56, call; 56, 57; 56, 60; 57, attribute; 57, 58; 57, 59; 58, identifier:self; 59, identifier:_iter; 60, argument_list; 60, 61; 60, 65; 60, 66; 60, 67; 60, 68; 61, call; 61, 62; 61, 63; 62, identifier:int; 63, argument_list; 63, 64; 64, identifier:number; 65, identifier:url; 66, identifier:Issue; 67, identifier:params; 68, identifier:etag | def iter_org_issues(self, name, filter='', state='', labels='', sort='',
direction='', since=None, number=-1, etag=None):
url = self._build_url('orgs', name, 'issues')
params = issue_params(filter, state, labels, sort, direction, since)
return self._iter(int(number), url, Issue, params, etag) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 21; 2, function_name:iter_repos; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 18; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:type; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:sort; 10, None; 11, default_parameter; 11, 12; 11, 13; 12, identifier:direction; 13, None; 14, default_parameter; 14, 15; 14, 16; 15, identifier:number; 16, unary_operator:-; 16, 17; 17, integer:1; 18, default_parameter; 18, 19; 18, 20; 19, identifier:etag; 20, None; 21, block; 21, 22; 21, 32; 21, 36; 21, 55; 21, 73; 21, 89; 22, expression_statement; 22, 23; 23, assignment; 23, 24; 23, 25; 24, identifier:url; 25, call; 25, 26; 25, 29; 26, attribute; 26, 27; 26, 28; 27, identifier:self; 28, identifier:_build_url; 29, argument_list; 29, 30; 29, 31; 30, string:'user'; 31, string:'repos'; 32, expression_statement; 32, 33; 33, assignment; 33, 34; 33, 35; 34, identifier:params; 35, dictionary; 36, if_statement; 36, 37; 36, 45; 37, comparison_operator:in; 37, 38; 37, 39; 38, identifier:type; 39, tuple; 39, 40; 39, 41; 39, 42; 39, 43; 39, 44; 40, string:'all'; 41, string:'owner'; 42, string:'public'; 43, string:'private'; 44, string:'member'; 45, block; 45, 46; 46, expression_statement; 46, 47; 47, call; 47, 48; 47, 51; 48, attribute; 48, 49; 48, 50; 49, identifier:params; 50, identifier:update; 51, argument_list; 51, 52; 52, keyword_argument; 52, 53; 52, 54; 53, identifier:type; 54, identifier:type; 55, if_statement; 55, 56; 55, 63; 56, comparison_operator:in; 56, 57; 56, 58; 57, identifier:sort; 58, tuple; 58, 59; 58, 60; 58, 61; 58, 62; 59, string:'created'; 60, string:'updated'; 61, string:'pushed'; 62, string:'full_name'; 63, block; 63, 64; 64, expression_statement; 64, 65; 65, call; 65, 66; 65, 69; 66, attribute; 66, 67; 66, 68; 67, identifier:params; 68, identifier:update; 69, argument_list; 69, 70; 70, keyword_argument; 70, 71; 70, 72; 71, identifier:sort; 72, identifier:sort; 73, if_statement; 73, 74; 73, 79; 74, comparison_operator:in; 74, 75; 74, 76; 75, identifier:direction; 76, tuple; 76, 77; 76, 78; 77, string:'asc'; 78, string:'desc'; 79, block; 79, 80; 80, expression_statement; 80, 81; 81, call; 81, 82; 81, 85; 82, attribute; 82, 83; 82, 84; 83, identifier:params; 84, identifier:update; 85, argument_list; 85, 86; 86, keyword_argument; 86, 87; 86, 88; 87, identifier:direction; 88, identifier:direction; 89, return_statement; 89, 90; 90, call; 90, 91; 90, 94; 91, attribute; 91, 92; 91, 93; 92, identifier:self; 93, identifier:_iter; 94, argument_list; 94, 95; 94, 99; 94, 100; 94, 101; 94, 102; 95, call; 95, 96; 95, 97; 96, identifier:int; 97, argument_list; 97, 98; 98, identifier:number; 99, identifier:url; 100, identifier:Repository; 101, identifier:params; 102, identifier:etag | def iter_repos(self, type=None, sort=None, direction=None, number=-1,
etag=None):
url = self._build_url('user', 'repos')
params = {}
if type in ('all', 'owner', 'public', 'private', 'member'):
params.update(type=type)
if sort in ('created', 'updated', 'pushed', 'full_name'):
params.update(sort=sort)
if direction in ('asc', 'desc'):
params.update(direction=direction)
return self._iter(int(number), url, Repository, params, etag) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 21; 2, function_name:iter_starred; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 18; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:login; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:sort; 10, None; 11, default_parameter; 11, 12; 11, 13; 12, identifier:direction; 13, None; 14, default_parameter; 14, 15; 14, 16; 15, identifier:number; 16, unary_operator:-; 16, 17; 17, integer:1; 18, default_parameter; 18, 19; 18, 20; 19, identifier:etag; 20, None; 21, block; 21, 22; 21, 38; 21, 48; 21, 55; 21, 65; 22, if_statement; 22, 23; 22, 24; 23, identifier:login; 24, block; 24, 25; 25, return_statement; 25, 26; 26, call; 26, 27; 26, 35; 27, attribute; 27, 28; 27, 34; 28, call; 28, 29; 28, 32; 29, attribute; 29, 30; 29, 31; 30, identifier:self; 31, identifier:user; 32, argument_list; 32, 33; 33, identifier:login; 34, identifier:iter_starred; 35, argument_list; 35, 36; 35, 37; 36, identifier:sort; 37, identifier:direction; 38, expression_statement; 38, 39; 39, assignment; 39, 40; 39, 41; 40, identifier:params; 41, dictionary; 41, 42; 41, 45; 42, pair; 42, 43; 42, 44; 43, string:'sort'; 44, identifier:sort; 45, pair; 45, 46; 45, 47; 46, string:'direction'; 47, identifier:direction; 48, expression_statement; 48, 49; 49, call; 49, 50; 49, 53; 50, attribute; 50, 51; 50, 52; 51, identifier:self; 52, identifier:_remove_none; 53, argument_list; 53, 54; 54, identifier:params; 55, expression_statement; 55, 56; 56, assignment; 56, 57; 56, 58; 57, identifier:url; 58, call; 58, 59; 58, 62; 59, attribute; 59, 60; 59, 61; 60, identifier:self; 61, identifier:_build_url; 62, argument_list; 62, 63; 62, 64; 63, string:'user'; 64, string:'starred'; 65, return_statement; 65, 66; 66, call; 66, 67; 66, 70; 67, attribute; 67, 68; 67, 69; 68, identifier:self; 69, identifier:_iter; 70, argument_list; 70, 71; 70, 75; 70, 76; 70, 77; 70, 78; 71, call; 71, 72; 71, 73; 72, identifier:int; 73, argument_list; 73, 74; 74, identifier:number; 75, identifier:url; 76, identifier:Repository; 77, identifier:params; 78, identifier:etag | def iter_starred(self, login=None, sort=None, direction=None, number=-1,
etag=None):
if login:
return self.user(login).iter_starred(sort, direction)
params = {'sort': sort, 'direction': direction}
self._remove_none(params)
url = self._build_url('user', 'starred')
return self._iter(int(number), url, Repository, params, etag) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 25; 2, function_name:search_code; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 3, 18; 3, 22; 4, identifier:self; 5, identifier:query; 6, default_parameter; 6, 7; 6, 8; 7, identifier:sort; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:order; 11, None; 12, default_parameter; 12, 13; 12, 14; 13, identifier:per_page; 14, None; 15, default_parameter; 15, 16; 15, 17; 16, identifier:text_match; 17, False; 18, default_parameter; 18, 19; 18, 20; 19, identifier:number; 20, unary_operator:-; 20, 21; 21, integer:1; 22, default_parameter; 22, 23; 22, 24; 23, identifier:etag; 24, None; 25, block; 25, 26; 25, 33; 25, 37; 25, 48; 25, 63; 25, 73; 25, 83; 26, expression_statement; 26, 27; 27, assignment; 27, 28; 27, 29; 28, identifier:params; 29, dictionary; 29, 30; 30, pair; 30, 31; 30, 32; 31, string:'q'; 32, identifier:query; 33, expression_statement; 33, 34; 34, assignment; 34, 35; 34, 36; 35, identifier:headers; 36, dictionary; 37, if_statement; 37, 38; 37, 41; 38, comparison_operator:==; 38, 39; 38, 40; 39, identifier:sort; 40, string:'indexed'; 41, block; 41, 42; 42, expression_statement; 42, 43; 43, assignment; 43, 44; 43, 47; 44, subscript; 44, 45; 44, 46; 45, identifier:params; 46, string:'sort'; 47, identifier:sort; 48, if_statement; 48, 49; 48, 56; 49, boolean_operator:and; 49, 50; 49, 51; 50, identifier:sort; 51, comparison_operator:in; 51, 52; 51, 53; 52, identifier:order; 53, tuple; 53, 54; 53, 55; 54, string:'asc'; 55, string:'desc'; 56, block; 56, 57; 57, expression_statement; 57, 58; 58, assignment; 58, 59; 58, 62; 59, subscript; 59, 60; 59, 61; 60, identifier:params; 61, string:'order'; 62, identifier:order; 63, if_statement; 63, 64; 63, 65; 64, identifier:text_match; 65, block; 65, 66; 66, expression_statement; 66, 67; 67, assignment; 67, 68; 67, 69; 68, identifier:headers; 69, dictionary; 69, 70; 70, pair; 70, 71; 70, 72; 71, string:'Accept'; 72, string:'application/vnd.github.v3.full.text-match+json'; 73, expression_statement; 73, 74; 74, assignment; 74, 75; 74, 76; 75, identifier:url; 76, call; 76, 77; 76, 80; 77, attribute; 77, 78; 77, 79; 78, identifier:self; 79, identifier:_build_url; 80, argument_list; 80, 81; 80, 82; 81, string:'search'; 82, string:'code'; 83, return_statement; 83, 84; 84, call; 84, 85; 84, 86; 85, identifier:SearchIterator; 86, argument_list; 86, 87; 86, 88; 86, 89; 86, 90; 86, 91; 86, 92; 86, 93; 87, identifier:number; 88, identifier:url; 89, identifier:CodeSearchResult; 90, identifier:self; 91, identifier:params; 92, identifier:etag; 93, identifier:headers | def search_code(self, query, sort=None, order=None, per_page=None,
text_match=False, number=-1, etag=None):
params = {'q': query}
headers = {}
if sort == 'indexed':
params['sort'] = sort
if sort and order in ('asc', 'desc'):
params['order'] = order
if text_match:
headers = {
'Accept': 'application/vnd.github.v3.full.text-match+json'
}
url = self._build_url('search', 'code')
return SearchIterator(number, url, CodeSearchResult, self, params,
etag, headers) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 25; 2, function_name:search_issues; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 3, 18; 3, 22; 4, identifier:self; 5, identifier:query; 6, default_parameter; 6, 7; 6, 8; 7, identifier:sort; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:order; 11, None; 12, default_parameter; 12, 13; 12, 14; 13, identifier:per_page; 14, None; 15, default_parameter; 15, 16; 15, 17; 16, identifier:text_match; 17, False; 18, default_parameter; 18, 19; 18, 20; 19, identifier:number; 20, unary_operator:-; 20, 21; 21, integer:1; 22, default_parameter; 22, 23; 22, 24; 23, identifier:etag; 24, None; 25, block; 25, 26; 25, 33; 25, 37; 25, 51; 25, 64; 25, 74; 25, 84; 26, expression_statement; 26, 27; 27, assignment; 27, 28; 27, 29; 28, identifier:params; 29, dictionary; 29, 30; 30, pair; 30, 31; 30, 32; 31, string:'q'; 32, identifier:query; 33, expression_statement; 33, 34; 34, assignment; 34, 35; 34, 36; 35, identifier:headers; 36, dictionary; 37, if_statement; 37, 38; 37, 44; 38, comparison_operator:in; 38, 39; 38, 40; 39, identifier:sort; 40, tuple; 40, 41; 40, 42; 40, 43; 41, string:'comments'; 42, string:'created'; 43, string:'updated'; 44, block; 44, 45; 45, expression_statement; 45, 46; 46, assignment; 46, 47; 46, 50; 47, subscript; 47, 48; 47, 49; 48, identifier:params; 49, string:'sort'; 50, identifier:sort; 51, if_statement; 51, 52; 51, 57; 52, comparison_operator:in; 52, 53; 52, 54; 53, identifier:order; 54, tuple; 54, 55; 54, 56; 55, string:'asc'; 56, string:'desc'; 57, block; 57, 58; 58, expression_statement; 58, 59; 59, assignment; 59, 60; 59, 63; 60, subscript; 60, 61; 60, 62; 61, identifier:params; 62, string:'order'; 63, identifier:order; 64, if_statement; 64, 65; 64, 66; 65, identifier:text_match; 66, block; 66, 67; 67, expression_statement; 67, 68; 68, assignment; 68, 69; 68, 70; 69, identifier:headers; 70, dictionary; 70, 71; 71, pair; 71, 72; 71, 73; 72, string:'Accept'; 73, string:'application/vnd.github.v3.full.text-match+json'; 74, expression_statement; 74, 75; 75, assignment; 75, 76; 75, 77; 76, identifier:url; 77, call; 77, 78; 77, 81; 78, attribute; 78, 79; 78, 80; 79, identifier:self; 80, identifier:_build_url; 81, argument_list; 81, 82; 81, 83; 82, string:'search'; 83, string:'issues'; 84, return_statement; 84, 85; 85, call; 85, 86; 85, 87; 86, identifier:SearchIterator; 87, argument_list; 87, 88; 87, 89; 87, 90; 87, 91; 87, 92; 87, 93; 87, 94; 88, identifier:number; 89, identifier:url; 90, identifier:IssueSearchResult; 91, identifier:self; 92, identifier:params; 93, identifier:etag; 94, identifier:headers | def search_issues(self, query, sort=None, order=None, per_page=None,
text_match=False, number=-1, etag=None):
params = {'q': query}
headers = {}
if sort in ('comments', 'created', 'updated'):
params['sort'] = sort
if order in ('asc', 'desc'):
params['order'] = order
if text_match:
headers = {
'Accept': 'application/vnd.github.v3.full.text-match+json'
}
url = self._build_url('search', 'issues')
return SearchIterator(number, url, IssueSearchResult, self, params,
etag, headers) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 25; 2, function_name:search_users; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 3, 18; 3, 22; 4, identifier:self; 5, identifier:query; 6, default_parameter; 6, 7; 6, 8; 7, identifier:sort; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:order; 11, None; 12, default_parameter; 12, 13; 12, 14; 13, identifier:per_page; 14, None; 15, default_parameter; 15, 16; 15, 17; 16, identifier:text_match; 17, False; 18, default_parameter; 18, 19; 18, 20; 19, identifier:number; 20, unary_operator:-; 20, 21; 21, integer:1; 22, default_parameter; 22, 23; 22, 24; 23, identifier:etag; 24, None; 25, block; 25, 26; 25, 33; 25, 37; 25, 51; 25, 64; 25, 74; 25, 84; 26, expression_statement; 26, 27; 27, assignment; 27, 28; 27, 29; 28, identifier:params; 29, dictionary; 29, 30; 30, pair; 30, 31; 30, 32; 31, string:'q'; 32, identifier:query; 33, expression_statement; 33, 34; 34, assignment; 34, 35; 34, 36; 35, identifier:headers; 36, dictionary; 37, if_statement; 37, 38; 37, 44; 38, comparison_operator:in; 38, 39; 38, 40; 39, identifier:sort; 40, tuple; 40, 41; 40, 42; 40, 43; 41, string:'followers'; 42, string:'repositories'; 43, string:'joined'; 44, block; 44, 45; 45, expression_statement; 45, 46; 46, assignment; 46, 47; 46, 50; 47, subscript; 47, 48; 47, 49; 48, identifier:params; 49, string:'sort'; 50, identifier:sort; 51, if_statement; 51, 52; 51, 57; 52, comparison_operator:in; 52, 53; 52, 54; 53, identifier:order; 54, tuple; 54, 55; 54, 56; 55, string:'asc'; 56, string:'desc'; 57, block; 57, 58; 58, expression_statement; 58, 59; 59, assignment; 59, 60; 59, 63; 60, subscript; 60, 61; 60, 62; 61, identifier:params; 62, string:'order'; 63, identifier:order; 64, if_statement; 64, 65; 64, 66; 65, identifier:text_match; 66, block; 66, 67; 67, expression_statement; 67, 68; 68, assignment; 68, 69; 68, 70; 69, identifier:headers; 70, dictionary; 70, 71; 71, pair; 71, 72; 71, 73; 72, string:'Accept'; 73, string:'application/vnd.github.v3.full.text-match+json'; 74, expression_statement; 74, 75; 75, assignment; 75, 76; 75, 77; 76, identifier:url; 77, call; 77, 78; 77, 81; 78, attribute; 78, 79; 78, 80; 79, identifier:self; 80, identifier:_build_url; 81, argument_list; 81, 82; 81, 83; 82, string:'search'; 83, string:'users'; 84, return_statement; 84, 85; 85, call; 85, 86; 85, 87; 86, identifier:SearchIterator; 87, argument_list; 87, 88; 87, 89; 87, 90; 87, 91; 87, 92; 87, 93; 87, 94; 88, identifier:number; 89, identifier:url; 90, identifier:UserSearchResult; 91, identifier:self; 92, identifier:params; 93, identifier:etag; 94, identifier:headers | def search_users(self, query, sort=None, order=None, per_page=None,
text_match=False, number=-1, etag=None):
params = {'q': query}
headers = {}
if sort in ('followers', 'repositories', 'joined'):
params['sort'] = sort
if order in ('asc', 'desc'):
params['order'] = order
if text_match:
headers = {
'Accept': 'application/vnd.github.v3.full.text-match+json'
}
url = self._build_url('search', 'users')
return SearchIterator(number, url, UserSearchResult, self, params,
etag, headers) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 18; 2, function_name:iter_starred; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 15; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:sort; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:direction; 10, None; 11, default_parameter; 11, 12; 11, 13; 12, identifier:number; 13, unary_operator:-; 13, 14; 14, integer:1; 15, default_parameter; 15, 16; 15, 17; 16, identifier:etag; 17, None; 18, block; 18, 19; 18, 26; 18, 36; 18, 43; 18, 59; 19, import_from_statement; 19, 20; 19, 24; 20, relative_import; 20, 21; 20, 22; 21, import_prefix; 22, dotted_name; 22, 23; 23, identifier:repos; 24, dotted_name; 24, 25; 25, identifier:Repository; 26, expression_statement; 26, 27; 27, assignment; 27, 28; 27, 29; 28, identifier:params; 29, dictionary; 29, 30; 29, 33; 30, pair; 30, 31; 30, 32; 31, string:'sort'; 32, identifier:sort; 33, pair; 33, 34; 33, 35; 34, string:'direction'; 35, identifier:direction; 36, expression_statement; 36, 37; 37, call; 37, 38; 37, 41; 38, attribute; 38, 39; 38, 40; 39, identifier:self; 40, identifier:_remove_none; 41, argument_list; 41, 42; 42, identifier:params; 43, expression_statement; 43, 44; 44, assignment; 44, 45; 44, 46; 45, identifier:url; 46, call; 46, 47; 46, 52; 47, attribute; 47, 48; 47, 51; 48, attribute; 48, 49; 48, 50; 49, identifier:self; 50, identifier:starred_urlt; 51, identifier:expand; 52, argument_list; 52, 53; 52, 56; 53, keyword_argument; 53, 54; 53, 55; 54, identifier:owner; 55, None; 56, keyword_argument; 56, 57; 56, 58; 57, identifier:repo; 58, None; 59, return_statement; 59, 60; 60, call; 60, 61; 60, 64; 61, attribute; 61, 62; 61, 63; 62, identifier:self; 63, identifier:_iter; 64, argument_list; 64, 65; 64, 69; 64, 70; 64, 71; 64, 72; 65, call; 65, 66; 65, 67; 66, identifier:int; 67, argument_list; 67, 68; 68, identifier:number; 69, identifier:url; 70, identifier:Repository; 71, identifier:params; 72, identifier:etag | def iter_starred(self, sort=None, direction=None, number=-1, etag=None):
from .repos import Repository
params = {'sort': sort, 'direction': direction}
self._remove_none(params)
url = self.starred_urlt.expand(owner=None, repo=None)
return self._iter(int(number), url, Repository, params, etag) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 15; 2, function_name:iter_forks; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 12; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:sort; 7, string:''; 8, default_parameter; 8, 9; 8, 10; 9, identifier:number; 10, unary_operator:-; 10, 11; 11, integer:1; 12, default_parameter; 12, 13; 12, 14; 13, identifier:etag; 14, None; 15, block; 15, 16; 15, 30; 15, 34; 15, 49; 16, expression_statement; 16, 17; 17, assignment; 17, 18; 17, 19; 18, identifier:url; 19, call; 19, 20; 19, 23; 20, attribute; 20, 21; 20, 22; 21, identifier:self; 22, identifier:_build_url; 23, argument_list; 23, 24; 23, 25; 24, string:'forks'; 25, keyword_argument; 25, 26; 25, 27; 26, identifier:base_url; 27, attribute; 27, 28; 27, 29; 28, identifier:self; 29, identifier:_api; 30, expression_statement; 30, 31; 31, assignment; 31, 32; 31, 33; 32, identifier:params; 33, dictionary; 34, if_statement; 34, 35; 34, 41; 35, comparison_operator:in; 35, 36; 35, 37; 36, identifier:sort; 37, tuple; 37, 38; 37, 39; 37, 40; 38, string:'newest'; 39, string:'oldest'; 40, string:'watchers'; 41, block; 41, 42; 42, expression_statement; 42, 43; 43, assignment; 43, 44; 43, 45; 44, identifier:params; 45, dictionary; 45, 46; 46, pair; 46, 47; 46, 48; 47, string:'sort'; 48, identifier:sort; 49, return_statement; 49, 50; 50, call; 50, 51; 50, 54; 51, attribute; 51, 52; 51, 53; 52, identifier:self; 53, identifier:_iter; 54, argument_list; 54, 55; 54, 59; 54, 60; 54, 61; 54, 62; 55, call; 55, 56; 55, 57; 56, identifier:int; 57, argument_list; 57, 58; 58, identifier:number; 59, identifier:url; 60, identifier:Repository; 61, identifier:params; 62, identifier:etag | def iter_forks(self, sort='', number=-1, etag=None):
url = self._build_url('forks', base_url=self._api)
params = {}
if sort in ('newest', 'oldest', 'watchers'):
params = {'sort': sort}
return self._iter(int(number), url, Repository, params, etag) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 36; 2, function_name:iter_issues; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 3, 23; 3, 26; 3, 29; 3, 33; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:milestone; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:state; 10, None; 11, default_parameter; 11, 12; 11, 13; 12, identifier:assignee; 13, None; 14, default_parameter; 14, 15; 14, 16; 15, identifier:mentioned; 16, None; 17, default_parameter; 17, 18; 17, 19; 18, identifier:labels; 19, None; 20, default_parameter; 20, 21; 20, 22; 21, identifier:sort; 22, None; 23, default_parameter; 23, 24; 23, 25; 24, identifier:direction; 25, None; 26, default_parameter; 26, 27; 26, 28; 27, identifier:since; 28, None; 29, default_parameter; 29, 30; 29, 31; 30, identifier:number; 31, unary_operator:-; 31, 32; 32, integer:1; 33, default_parameter; 33, 34; 33, 35; 34, identifier:etag; 35, None; 36, block; 36, 37; 36, 51; 36, 61; 36, 80; 36, 87; 36, 102; 37, expression_statement; 37, 38; 38, assignment; 38, 39; 38, 40; 39, identifier:url; 40, call; 40, 41; 40, 44; 41, attribute; 41, 42; 41, 43; 42, identifier:self; 43, identifier:_build_url; 44, argument_list; 44, 45; 44, 46; 45, string:'issues'; 46, keyword_argument; 46, 47; 46, 48; 47, identifier:base_url; 48, attribute; 48, 49; 48, 50; 49, identifier:self; 50, identifier:_api; 51, expression_statement; 51, 52; 52, assignment; 52, 53; 52, 54; 53, identifier:params; 54, dictionary; 54, 55; 54, 58; 55, pair; 55, 56; 55, 57; 56, string:'assignee'; 57, identifier:assignee; 58, pair; 58, 59; 58, 60; 59, string:'mentioned'; 60, identifier:mentioned; 61, if_statement; 61, 62; 61, 73; 62, boolean_operator:or; 62, 63; 62, 68; 63, comparison_operator:in; 63, 64; 63, 65; 64, identifier:milestone; 65, tuple; 65, 66; 65, 67; 66, string:'*'; 67, string:'none'; 68, call; 68, 69; 68, 70; 69, identifier:isinstance; 70, argument_list; 70, 71; 70, 72; 71, identifier:milestone; 72, identifier:int; 73, block; 73, 74; 74, expression_statement; 74, 75; 75, assignment; 75, 76; 75, 79; 76, subscript; 76, 77; 76, 78; 77, identifier:params; 78, string:'milestone'; 79, identifier:milestone; 80, expression_statement; 80, 81; 81, call; 81, 82; 81, 85; 82, attribute; 82, 83; 82, 84; 83, identifier:self; 84, identifier:_remove_none; 85, argument_list; 85, 86; 86, identifier:params; 87, expression_statement; 87, 88; 88, call; 88, 89; 88, 92; 89, attribute; 89, 90; 89, 91; 90, identifier:params; 91, identifier:update; 92, argument_list; 92, 93; 93, call; 93, 94; 93, 95; 94, identifier:issue_params; 95, argument_list; 95, 96; 95, 97; 95, 98; 95, 99; 95, 100; 95, 101; 96, None; 97, identifier:state; 98, identifier:labels; 99, identifier:sort; 100, identifier:direction; 101, identifier:since; 102, return_statement; 102, 103; 103, call; 103, 104; 103, 107; 104, attribute; 104, 105; 104, 106; 105, identifier:self; 106, identifier:_iter; 107, argument_list; 107, 108; 107, 112; 107, 113; 107, 114; 107, 115; 108, call; 108, 109; 108, 110; 109, identifier:int; 110, argument_list; 110, 111; 111, identifier:number; 112, identifier:url; 113, identifier:Issue; 114, identifier:params; 115, identifier:etag | def iter_issues(self,
milestone=None,
state=None,
assignee=None,
mentioned=None,
labels=None,
sort=None,
direction=None,
since=None,
number=-1,
etag=None):
url = self._build_url('issues', base_url=self._api)
params = {'assignee': assignee, 'mentioned': mentioned}
if milestone in ('*', 'none') or isinstance(milestone, int):
params['milestone'] = milestone
self._remove_none(params)
params.update(
issue_params(None, state, labels, sort, direction,
since)
)
return self._iter(int(number), url, Issue, params, etag) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 21; 2, function_name:iter_milestones; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 18; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:state; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:sort; 10, None; 11, default_parameter; 11, 12; 11, 13; 12, identifier:direction; 13, None; 14, default_parameter; 14, 15; 14, 16; 15, identifier:number; 16, unary_operator:-; 16, 17; 17, integer:1; 18, default_parameter; 18, 19; 18, 20; 19, identifier:etag; 20, None; 21, block; 21, 22; 21, 36; 21, 55; 21, 68; 21, 97; 21, 105; 22, expression_statement; 22, 23; 23, assignment; 23, 24; 23, 25; 24, identifier:url; 25, call; 25, 26; 25, 29; 26, attribute; 26, 27; 26, 28; 27, identifier:self; 28, identifier:_build_url; 29, argument_list; 29, 30; 29, 31; 30, string:'milestones'; 31, keyword_argument; 31, 32; 31, 33; 32, identifier:base_url; 33, attribute; 33, 34; 33, 35; 34, identifier:self; 35, identifier:_api; 36, expression_statement; 36, 37; 37, assignment; 37, 38; 37, 39; 38, identifier:accepted; 39, dictionary; 39, 40; 39, 45; 39, 50; 40, pair; 40, 41; 40, 42; 41, string:'state'; 42, tuple; 42, 43; 42, 44; 43, string:'open'; 44, string:'closed'; 45, pair; 45, 46; 45, 47; 46, string:'sort'; 47, tuple; 47, 48; 47, 49; 48, string:'due_date'; 49, string:'completeness'; 50, pair; 50, 51; 50, 52; 51, string:'direction'; 52, tuple; 52, 53; 52, 54; 53, string:'asc'; 54, string:'desc'; 55, expression_statement; 55, 56; 56, assignment; 56, 57; 56, 58; 57, identifier:params; 58, dictionary; 58, 59; 58, 62; 58, 65; 59, pair; 59, 60; 59, 61; 60, string:'state'; 61, identifier:state; 62, pair; 62, 63; 62, 64; 63, string:'sort'; 64, identifier:sort; 65, pair; 65, 66; 65, 67; 66, string:'direction'; 67, identifier:direction; 68, for_statement; 68, 69; 68, 72; 68, 80; 69, tuple_pattern; 69, 70; 69, 71; 70, identifier:k; 71, identifier:v; 72, call; 72, 73; 72, 74; 73, identifier:list; 74, argument_list; 74, 75; 75, call; 75, 76; 75, 79; 76, attribute; 76, 77; 76, 78; 77, identifier:params; 78, identifier:items; 79, argument_list; 80, block; 80, 81; 81, if_statement; 81, 82; 81, 92; 82, not_operator; 82, 83; 83, parenthesized_expression; 83, 84; 84, boolean_operator:and; 84, 85; 84, 86; 85, identifier:v; 86, parenthesized_expression; 86, 87; 87, comparison_operator:in; 87, 88; 87, 89; 88, identifier:v; 89, subscript; 89, 90; 89, 91; 90, identifier:accepted; 91, identifier:k; 92, block; 92, 93; 93, delete_statement; 93, 94; 94, subscript; 94, 95; 94, 96; 95, identifier:params; 96, identifier:k; 97, if_statement; 97, 98; 97, 100; 98, not_operator; 98, 99; 99, identifier:params; 100, block; 100, 101; 101, expression_statement; 101, 102; 102, assignment; 102, 103; 102, 104; 103, identifier:params; 104, None; 105, return_statement; 105, 106; 106, call; 106, 107; 106, 110; 107, attribute; 107, 108; 107, 109; 108, identifier:self; 109, identifier:_iter; 110, argument_list; 110, 111; 110, 115; 110, 116; 110, 117; 110, 118; 111, call; 111, 112; 111, 113; 112, identifier:int; 113, argument_list; 113, 114; 114, identifier:number; 115, identifier:url; 116, identifier:Milestone; 117, identifier:params; 118, identifier:etag | def iter_milestones(self, state=None, sort=None, direction=None,
number=-1, etag=None):
url = self._build_url('milestones', base_url=self._api)
accepted = {'state': ('open', 'closed'),
'sort': ('due_date', 'completeness'),
'direction': ('asc', 'desc')}
params = {'state': state, 'sort': sort, 'direction': direction}
for (k, v) in list(params.items()):
if not (v and (v in accepted[k])):
del params[k]
if not params:
params = None
return self._iter(int(number), url, Milestone, params, etag) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 27; 2, function_name:iter_pulls; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 3, 24; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:state; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:head; 10, None; 11, default_parameter; 11, 12; 11, 13; 12, identifier:base; 13, None; 14, default_parameter; 14, 15; 14, 16; 15, identifier:sort; 16, string:'created'; 17, default_parameter; 17, 18; 17, 19; 18, identifier:direction; 19, string:'desc'; 20, default_parameter; 20, 21; 20, 22; 21, identifier:number; 22, unary_operator:-; 22, 23; 23, integer:1; 24, default_parameter; 24, 25; 24, 26; 25, identifier:etag; 26, None; 27, block; 27, 28; 27, 42; 27, 46; 27, 70; 27, 88; 27, 95; 28, expression_statement; 28, 29; 29, assignment; 29, 30; 29, 31; 30, identifier:url; 31, call; 31, 32; 31, 35; 32, attribute; 32, 33; 32, 34; 33, identifier:self; 34, identifier:_build_url; 35, argument_list; 35, 36; 35, 37; 36, string:'pulls'; 37, keyword_argument; 37, 38; 37, 39; 38, identifier:base_url; 39, attribute; 39, 40; 39, 41; 40, identifier:self; 41, identifier:_api; 42, expression_statement; 42, 43; 43, assignment; 43, 44; 43, 45; 44, identifier:params; 45, dictionary; 46, if_statement; 46, 47; 46, 59; 47, boolean_operator:and; 47, 48; 47, 49; 48, identifier:state; 49, comparison_operator:in; 49, 50; 49, 55; 50, call; 50, 51; 50, 54; 51, attribute; 51, 52; 51, 53; 52, identifier:state; 53, identifier:lower; 54, argument_list; 55, tuple; 55, 56; 55, 57; 55, 58; 56, string:'all'; 57, string:'open'; 58, string:'closed'; 59, block; 59, 60; 60, expression_statement; 60, 61; 61, assignment; 61, 62; 61, 65; 62, subscript; 62, 63; 62, 64; 63, identifier:params; 64, string:'state'; 65, call; 65, 66; 65, 69; 66, attribute; 66, 67; 66, 68; 67, identifier:state; 68, identifier:lower; 69, argument_list; 70, expression_statement; 70, 71; 71, call; 71, 72; 71, 75; 72, attribute; 72, 73; 72, 74; 73, identifier:params; 74, identifier:update; 75, argument_list; 75, 76; 75, 79; 75, 82; 75, 85; 76, keyword_argument; 76, 77; 76, 78; 77, identifier:head; 78, identifier:head; 79, keyword_argument; 79, 80; 79, 81; 80, identifier:base; 81, identifier:base; 82, keyword_argument; 82, 83; 82, 84; 83, identifier:sort; 84, identifier:sort; 85, keyword_argument; 85, 86; 85, 87; 86, identifier:direction; 87, identifier:direction; 88, expression_statement; 88, 89; 89, call; 89, 90; 89, 93; 90, attribute; 90, 91; 90, 92; 91, identifier:self; 92, identifier:_remove_none; 93, argument_list; 93, 94; 94, identifier:params; 95, return_statement; 95, 96; 96, call; 96, 97; 96, 100; 97, attribute; 97, 98; 97, 99; 98, identifier:self; 99, identifier:_iter; 100, argument_list; 100, 101; 100, 105; 100, 106; 100, 107; 100, 108; 101, call; 101, 102; 101, 103; 102, identifier:int; 103, argument_list; 103, 104; 104, identifier:number; 105, identifier:url; 106, identifier:PullRequest; 107, identifier:params; 108, identifier:etag | def iter_pulls(self, state=None, head=None, base=None, sort='created',
direction='desc', number=-1, etag=None):
url = self._build_url('pulls', base_url=self._api)
params = {}
if state and state.lower() in ('all', 'open', 'closed'):
params['state'] = state.lower()
params.update(head=head, base=base, sort=sort, direction=direction)
self._remove_none(params)
return self._iter(int(number), url, PullRequest, params, etag) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 21; 2, function_name:iter_user_repos; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 18; 4, identifier:login; 5, default_parameter; 5, 6; 5, 7; 6, identifier:type; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:sort; 10, None; 11, default_parameter; 11, 12; 11, 13; 12, identifier:direction; 13, None; 14, default_parameter; 14, 15; 14, 16; 15, identifier:number; 16, unary_operator:-; 16, 17; 17, integer:1; 18, default_parameter; 18, 19; 18, 20; 19, identifier:etag; 20, None; 21, block; 21, 22; 21, 37; 22, if_statement; 22, 23; 22, 24; 23, identifier:login; 24, block; 24, 25; 25, return_statement; 25, 26; 26, call; 26, 27; 26, 30; 27, attribute; 27, 28; 27, 29; 28, identifier:gh; 29, identifier:iter_user_repos; 30, argument_list; 30, 31; 30, 32; 30, 33; 30, 34; 30, 35; 30, 36; 31, identifier:login; 32, identifier:type; 33, identifier:sort; 34, identifier:direction; 35, identifier:number; 36, identifier:etag; 37, return_statement; 37, 38; 38, call; 38, 39; 38, 40; 39, identifier:iter; 40, argument_list; 40, 41; 41, list:[] | def iter_user_repos(login, type=None, sort=None, direction=None, number=-1,
etag=None):
if login:
return gh.iter_user_repos(login, type, sort, direction, number, etag)
return iter([]) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:sort_descendants; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:attr; 7, string:"name"; 8, block; 8, 9; 8, 23; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 11, identifier:node2content; 12, call; 12, 13; 12, 16; 13, attribute; 13, 14; 13, 15; 14, identifier:self; 15, identifier:get_cached_content; 16, argument_list; 16, 17; 16, 20; 17, keyword_argument; 17, 18; 17, 19; 18, identifier:store_attr; 19, identifier:attr; 20, keyword_argument; 20, 21; 20, 22; 21, identifier:container_type; 22, identifier:list; 23, for_statement; 23, 24; 23, 25; 23, 30; 24, identifier:n; 25, call; 25, 26; 25, 29; 26, attribute; 26, 27; 26, 28; 27, identifier:self; 28, identifier:traverse; 29, argument_list; 30, block; 30, 31; 31, if_statement; 31, 32; 31, 38; 32, not_operator; 32, 33; 33, call; 33, 34; 33, 37; 34, attribute; 34, 35; 34, 36; 35, identifier:n; 36, identifier:is_leaf; 37, argument_list; 38, block; 38, 39; 39, expression_statement; 39, 40; 40, call; 40, 41; 40, 46; 41, attribute; 41, 42; 41, 45; 42, attribute; 42, 43; 42, 44; 43, identifier:n; 44, identifier:children; 45, identifier:sort; 46, argument_list; 46, 47; 47, keyword_argument; 47, 48; 47, 49; 48, identifier:key; 49, lambda; 49, 50; 49, 52; 50, lambda_parameters; 50, 51; 51, identifier:x; 52, call; 52, 53; 52, 54; 53, identifier:str; 54, argument_list; 54, 55; 55, call; 55, 56; 55, 57; 56, identifier:sorted; 57, argument_list; 57, 58; 58, subscript; 58, 59; 58, 60; 59, identifier:node2content; 60, identifier:x | def sort_descendants(self, attr="name"):
node2content = self.get_cached_content(store_attr=attr, container_type=list)
for n in self.traverse():
if not n.is_leaf():
n.children.sort(key=lambda x: str(sorted(node2content[x]))) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:collect_backups; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:location; 6, block; 6, 7; 6, 11; 6, 18; 6, 26; 6, 32; 6, 192; 6, 207; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:backups; 10, list:[]; 11, expression_statement; 11, 12; 12, assignment; 12, 13; 12, 14; 13, identifier:location; 14, call; 14, 15; 14, 16; 15, identifier:coerce_location; 16, argument_list; 16, 17; 17, identifier:location; 18, expression_statement; 18, 19; 19, call; 19, 20; 19, 23; 20, attribute; 20, 21; 20, 22; 21, identifier:logger; 22, identifier:info; 23, argument_list; 23, 24; 23, 25; 24, string:"Scanning %s for backups .."; 25, identifier:location; 26, expression_statement; 26, 27; 27, call; 27, 28; 27, 31; 28, attribute; 28, 29; 28, 30; 29, identifier:location; 30, identifier:ensure_readable; 31, argument_list; 32, for_statement; 32, 33; 32, 34; 32, 47; 33, identifier:entry; 34, call; 34, 35; 34, 36; 35, identifier:natsort; 36, argument_list; 36, 37; 37, call; 37, 38; 37, 43; 38, attribute; 38, 39; 38, 42; 39, attribute; 39, 40; 39, 41; 40, identifier:location; 41, identifier:context; 42, identifier:list_entries; 43, argument_list; 43, 44; 44, attribute; 44, 45; 44, 46; 45, identifier:location; 46, identifier:directory; 47, block; 47, 48; 47, 57; 48, expression_statement; 48, 49; 49, assignment; 49, 50; 49, 51; 50, identifier:match; 51, call; 51, 52; 51, 55; 52, attribute; 52, 53; 52, 54; 53, identifier:TIMESTAMP_PATTERN; 54, identifier:search; 55, argument_list; 55, 56; 56, identifier:entry; 57, if_statement; 57, 58; 57, 59; 57, 182; 58, identifier:match; 59, block; 59, 60; 60, if_statement; 60, 61; 60, 80; 60, 89; 60, 119; 61, boolean_operator:and; 61, 62; 61, 65; 62, attribute; 62, 63; 62, 64; 63, identifier:self; 64, identifier:exclude_list; 65, call; 65, 66; 65, 67; 66, identifier:any; 67, generator_expression; 67, 68; 67, 75; 68, call; 68, 69; 68, 72; 69, attribute; 69, 70; 69, 71; 70, identifier:fnmatch; 71, identifier:fnmatch; 72, argument_list; 72, 73; 72, 74; 73, identifier:entry; 74, identifier:p; 75, for_in_clause; 75, 76; 75, 77; 76, identifier:p; 77, attribute; 77, 78; 77, 79; 78, identifier:self; 79, identifier:exclude_list; 80, block; 80, 81; 81, expression_statement; 81, 82; 82, call; 82, 83; 82, 86; 83, attribute; 83, 84; 83, 85; 84, identifier:logger; 85, identifier:verbose; 86, argument_list; 86, 87; 86, 88; 87, string:"Excluded %s (it matched the exclude list)."; 88, identifier:entry; 89, elif_clause; 89, 90; 89, 110; 90, boolean_operator:and; 90, 91; 90, 94; 91, attribute; 91, 92; 91, 93; 92, identifier:self; 93, identifier:include_list; 94, not_operator; 94, 95; 95, call; 95, 96; 95, 97; 96, identifier:any; 97, generator_expression; 97, 98; 97, 105; 98, call; 98, 99; 98, 102; 99, attribute; 99, 100; 99, 101; 100, identifier:fnmatch; 101, identifier:fnmatch; 102, argument_list; 102, 103; 102, 104; 103, identifier:entry; 104, identifier:p; 105, for_in_clause; 105, 106; 105, 107; 106, identifier:p; 107, attribute; 107, 108; 107, 109; 108, identifier:self; 109, identifier:include_list; 110, block; 110, 111; 111, expression_statement; 111, 112; 112, call; 112, 113; 112, 116; 113, attribute; 113, 114; 113, 115; 114, identifier:logger; 115, identifier:verbose; 116, argument_list; 116, 117; 116, 118; 117, string:"Excluded %s (it didn't match the include list)."; 118, identifier:entry; 119, else_clause; 119, 120; 120, block; 120, 121; 121, try_statement; 121, 122; 121, 167; 122, block; 122, 123; 123, expression_statement; 123, 124; 124, call; 124, 125; 124, 128; 125, attribute; 125, 126; 125, 127; 126, identifier:backups; 127, identifier:append; 128, argument_list; 128, 129; 129, call; 129, 130; 129, 131; 130, identifier:Backup; 131, argument_list; 131, 132; 131, 145; 132, keyword_argument; 132, 133; 132, 134; 133, identifier:pathname; 134, call; 134, 135; 134, 140; 135, attribute; 135, 136; 135, 139; 136, attribute; 136, 137; 136, 138; 137, identifier:os; 138, identifier:path; 139, identifier:join; 140, argument_list; 140, 141; 140, 144; 141, attribute; 141, 142; 141, 143; 142, identifier:location; 143, identifier:directory; 144, identifier:entry; 145, keyword_argument; 145, 146; 145, 147; 146, identifier:timestamp; 147, call; 147, 148; 147, 151; 148, attribute; 148, 149; 148, 150; 149, identifier:datetime; 150, identifier:datetime; 151, argument_list; 151, 152; 152, list_splat; 152, 153; 153, generator_expression; 153, 154; 153, 159; 154, call; 154, 155; 154, 156; 155, identifier:int; 156, argument_list; 156, 157; 156, 158; 157, identifier:group; 158, integer:10; 159, for_in_clause; 159, 160; 159, 161; 160, identifier:group; 161, call; 161, 162; 161, 165; 162, attribute; 162, 163; 162, 164; 163, identifier:match; 164, identifier:groups; 165, argument_list; 165, 166; 166, string:'0'; 167, except_clause; 167, 168; 167, 172; 168, as_pattern; 168, 169; 168, 170; 169, identifier:ValueError; 170, as_pattern_target; 170, 171; 171, identifier:e; 172, block; 172, 173; 173, expression_statement; 173, 174; 174, call; 174, 175; 174, 178; 175, attribute; 175, 176; 175, 177; 176, identifier:logger; 177, identifier:notice; 178, argument_list; 178, 179; 178, 180; 178, 181; 179, string:"Ignoring %s due to invalid date (%s)."; 180, identifier:entry; 181, identifier:e; 182, else_clause; 182, 183; 183, block; 183, 184; 184, expression_statement; 184, 185; 185, call; 185, 186; 185, 189; 186, attribute; 186, 187; 186, 188; 187, identifier:logger; 188, identifier:debug; 189, argument_list; 189, 190; 189, 191; 190, string:"Failed to match time stamp in filename: %s"; 191, identifier:entry; 192, if_statement; 192, 193; 192, 194; 193, identifier:backups; 194, block; 194, 195; 195, expression_statement; 195, 196; 196, call; 196, 197; 196, 200; 197, attribute; 197, 198; 197, 199; 198, identifier:logger; 199, identifier:info; 200, argument_list; 200, 201; 200, 202; 200, 206; 201, string:"Found %i timestamped backups in %s."; 202, call; 202, 203; 202, 204; 203, identifier:len; 204, argument_list; 204, 205; 205, identifier:backups; 206, identifier:location; 207, return_statement; 207, 208; 208, call; 208, 209; 208, 210; 209, identifier:sorted; 210, argument_list; 210, 211; 211, identifier:backups | def collect_backups(self, location):
backups = []
location = coerce_location(location)
logger.info("Scanning %s for backups ..", location)
location.ensure_readable()
for entry in natsort(location.context.list_entries(location.directory)):
match = TIMESTAMP_PATTERN.search(entry)
if match:
if self.exclude_list and any(fnmatch.fnmatch(entry, p) for p in self.exclude_list):
logger.verbose("Excluded %s (it matched the exclude list).", entry)
elif self.include_list and not any(fnmatch.fnmatch(entry, p) for p in self.include_list):
logger.verbose("Excluded %s (it didn't match the include list).", entry)
else:
try:
backups.append(Backup(
pathname=os.path.join(location.directory, entry),
timestamp=datetime.datetime(*(int(group, 10) for group in match.groups('0'))),
))
except ValueError as e:
logger.notice("Ignoring %s due to invalid date (%s).", entry, e)
else:
logger.debug("Failed to match time stamp in filename: %s", entry)
if backups:
logger.info("Found %i timestamped backups in %s.", len(backups), location)
return sorted(backups) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:prepare_bam; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 11; 4, identifier:job; 5, identifier:uuid; 6, identifier:url; 7, identifier:config; 8, default_parameter; 8, 9; 8, 10; 9, identifier:paired_url; 10, None; 11, default_parameter; 11, 12; 11, 13; 12, identifier:rg_line; 13, None; 14, block; 14, 15; 14, 99; 14, 156; 14, 173; 14, 190; 14, 197; 14, 204; 14, 365; 15, if_statement; 15, 16; 15, 19; 15, 40; 15, 87; 16, attribute; 16, 17; 16, 18; 17, identifier:config; 18, identifier:run_bwa; 19, block; 19, 20; 20, expression_statement; 20, 21; 21, assignment; 21, 22; 21, 23; 22, identifier:get_bam; 23, call; 23, 24; 23, 39; 24, attribute; 24, 25; 24, 38; 25, call; 25, 26; 25, 29; 26, attribute; 26, 27; 26, 28; 27, identifier:job; 28, identifier:wrapJobFn; 29, argument_list; 29, 30; 29, 31; 29, 32; 29, 33; 29, 34; 29, 35; 30, identifier:setup_and_run_bwakit; 31, identifier:uuid; 32, identifier:url; 33, identifier:rg_line; 34, identifier:config; 35, keyword_argument; 35, 36; 35, 37; 36, identifier:paired_url; 37, identifier:paired_url; 38, identifier:encapsulate; 39, argument_list; 40, elif_clause; 40, 41; 40, 48; 41, comparison_operator:in; 41, 42; 41, 43; 42, string:'.bam'; 43, call; 43, 44; 43, 47; 44, attribute; 44, 45; 44, 46; 45, identifier:url; 46, identifier:lower; 47, argument_list; 48, block; 48, 49; 48, 60; 49, expression_statement; 49, 50; 50, call; 50, 51; 50, 56; 51, attribute; 51, 52; 51, 55; 52, attribute; 52, 53; 52, 54; 53, identifier:job; 54, identifier:fileStore; 55, identifier:logToMaster; 56, argument_list; 56, 57; 57, binary_operator:%; 57, 58; 57, 59; 58, string:"Downloading BAM: %s"; 59, identifier:uuid; 60, expression_statement; 60, 61; 61, assignment; 61, 62; 61, 63; 62, identifier:get_bam; 63, call; 63, 64; 63, 86; 64, attribute; 64, 65; 64, 85; 65, call; 65, 66; 65, 69; 66, attribute; 66, 67; 66, 68; 67, identifier:job; 68, identifier:wrapJobFn; 69, argument_list; 69, 70; 69, 71; 69, 72; 69, 75; 69, 80; 70, identifier:download_url_job; 71, identifier:url; 72, keyword_argument; 72, 73; 72, 74; 73, identifier:name; 74, string:'toil.bam'; 75, keyword_argument; 75, 76; 75, 77; 76, identifier:s3_key_path; 77, attribute; 77, 78; 77, 79; 78, identifier:config; 79, identifier:ssec; 80, keyword_argument; 80, 81; 80, 82; 81, identifier:disk; 82, attribute; 82, 83; 82, 84; 83, identifier:config; 84, identifier:file_size; 85, identifier:encapsulate; 86, argument_list; 87, else_clause; 87, 88; 88, block; 88, 89; 89, raise_statement; 89, 90; 90, call; 90, 91; 90, 92; 91, identifier:ValueError; 92, argument_list; 92, 93; 93, binary_operator:%; 93, 94; 93, 98; 94, concatenated_string; 94, 95; 94, 96; 94, 97; 95, string:'Could not generate BAM file for %s\n'; 96, string:'Provide a FASTQ URL and set run-bwa or '; 97, string:'provide a BAM URL that includes .bam extension.'; 98, identifier:uuid; 99, if_statement; 99, 100; 99, 108; 99, 113; 100, boolean_operator:and; 100, 101; 100, 104; 101, attribute; 101, 102; 101, 103; 102, identifier:config; 103, identifier:sorted; 104, not_operator; 104, 105; 105, attribute; 105, 106; 105, 107; 106, identifier:config; 107, identifier:run_bwa; 108, block; 108, 109; 109, expression_statement; 109, 110; 110, assignment; 110, 111; 110, 112; 111, identifier:sorted_bam; 112, identifier:get_bam; 113, else_clause; 113, 114; 114, block; 114, 115; 114, 134; 115, expression_statement; 115, 116; 116, assignment; 116, 117; 116, 118; 117, identifier:sorted_bam_disk; 118, call; 118, 119; 118, 120; 119, identifier:PromisedRequirement; 120, argument_list; 120, 121; 120, 129; 121, lambda; 121, 122; 121, 124; 122, lambda_parameters; 122, 123; 123, identifier:bam; 124, binary_operator:*; 124, 125; 124, 126; 125, integer:3; 126, attribute; 126, 127; 126, 128; 127, identifier:bam; 128, identifier:size; 129, call; 129, 130; 129, 133; 130, attribute; 130, 131; 130, 132; 131, identifier:get_bam; 132, identifier:rv; 133, argument_list; 134, expression_statement; 134, 135; 135, assignment; 135, 136; 135, 137; 136, identifier:sorted_bam; 137, call; 137, 138; 137, 141; 138, attribute; 138, 139; 138, 140; 139, identifier:get_bam; 140, identifier:addChildJobFn; 141, argument_list; 141, 142; 141, 143; 141, 148; 141, 153; 142, identifier:run_samtools_sort; 143, call; 143, 144; 143, 147; 144, attribute; 144, 145; 144, 146; 145, identifier:get_bam; 146, identifier:rv; 147, argument_list; 148, keyword_argument; 148, 149; 148, 150; 149, identifier:cores; 150, attribute; 150, 151; 150, 152; 151, identifier:config; 152, identifier:cores; 153, keyword_argument; 153, 154; 153, 155; 154, identifier:disk; 155, identifier:sorted_bam_disk; 156, expression_statement; 156, 157; 157, assignment; 157, 158; 157, 159; 158, identifier:index_bam_disk; 159, call; 159, 160; 159, 161; 160, identifier:PromisedRequirement; 161, argument_list; 161, 162; 161, 168; 162, lambda; 162, 163; 162, 165; 163, lambda_parameters; 163, 164; 164, identifier:bam; 165, attribute; 165, 166; 165, 167; 166, identifier:bam; 167, identifier:size; 168, call; 168, 169; 168, 172; 169, attribute; 169, 170; 169, 171; 170, identifier:sorted_bam; 171, identifier:rv; 172, argument_list; 173, expression_statement; 173, 174; 174, assignment; 174, 175; 174, 176; 175, identifier:index_bam; 176, call; 176, 177; 176, 180; 177, attribute; 177, 178; 177, 179; 178, identifier:job; 179, identifier:wrapJobFn; 180, argument_list; 180, 181; 180, 182; 180, 187; 181, identifier:run_samtools_index; 182, call; 182, 183; 182, 186; 183, attribute; 183, 184; 183, 185; 184, identifier:sorted_bam; 185, identifier:rv; 186, argument_list; 187, keyword_argument; 187, 188; 187, 189; 188, identifier:disk; 189, identifier:index_bam_disk; 190, expression_statement; 190, 191; 191, call; 191, 192; 191, 195; 192, attribute; 192, 193; 192, 194; 193, identifier:job; 194, identifier:addChild; 195, argument_list; 195, 196; 196, identifier:get_bam; 197, expression_statement; 197, 198; 198, call; 198, 199; 198, 202; 199, attribute; 199, 200; 199, 201; 200, identifier:sorted_bam; 201, identifier:addChild; 202, argument_list; 202, 203; 203, identifier:index_bam; 204, if_statement; 204, 205; 204, 208; 204, 347; 205, attribute; 205, 206; 205, 207; 206, identifier:config; 207, identifier:preprocess; 208, block; 208, 209; 208, 260; 208, 267; 208, 274; 208, 283; 208, 292; 208, 306; 208, 318; 208, 340; 209, expression_statement; 209, 210; 210, assignment; 210, 211; 210, 212; 211, identifier:preprocess; 212, call; 212, 213; 212, 259; 213, attribute; 213, 214; 213, 258; 214, call; 214, 215; 214, 218; 215, attribute; 215, 216; 215, 217; 216, identifier:job; 217, identifier:wrapJobFn; 218, argument_list; 218, 219; 218, 220; 218, 225; 218, 230; 218, 233; 218, 236; 218, 239; 218, 242; 218, 245; 218, 248; 218, 253; 219, identifier:run_gatk_preprocessing; 220, call; 220, 221; 220, 224; 221, attribute; 221, 222; 221, 223; 222, identifier:sorted_bam; 223, identifier:rv; 224, argument_list; 225, call; 225, 226; 225, 229; 226, attribute; 226, 227; 226, 228; 227, identifier:index_bam; 228, identifier:rv; 229, argument_list; 230, attribute; 230, 231; 230, 232; 231, identifier:config; 232, identifier:genome_fasta; 233, attribute; 233, 234; 233, 235; 234, identifier:config; 235, identifier:genome_dict; 236, attribute; 236, 237; 236, 238; 237, identifier:config; 238, identifier:genome_fai; 239, attribute; 239, 240; 239, 241; 240, identifier:config; 241, identifier:g1k_indel; 242, attribute; 242, 243; 242, 244; 243, identifier:config; 244, identifier:mills; 245, attribute; 245, 246; 245, 247; 246, identifier:config; 247, identifier:dbsnp; 248, keyword_argument; 248, 249; 248, 250; 249, identifier:memory; 250, attribute; 250, 251; 250, 252; 251, identifier:config; 252, identifier:xmx; 253, keyword_argument; 253, 254; 253, 255; 254, identifier:cores; 255, attribute; 255, 256; 255, 257; 256, identifier:config; 257, identifier:cores; 258, identifier:encapsulate; 259, argument_list; 260, expression_statement; 260, 261; 261, call; 261, 262; 261, 265; 262, attribute; 262, 263; 262, 264; 263, identifier:sorted_bam; 264, identifier:addChild; 265, argument_list; 265, 266; 266, identifier:preprocess; 267, expression_statement; 267, 268; 268, call; 268, 269; 268, 272; 269, attribute; 269, 270; 269, 271; 270, identifier:index_bam; 271, identifier:addChild; 272, argument_list; 272, 273; 273, identifier:preprocess; 274, expression_statement; 274, 275; 275, assignment; 275, 276; 275, 277; 276, identifier:output_bam_promise; 277, call; 277, 278; 277, 281; 278, attribute; 278, 279; 278, 280; 279, identifier:preprocess; 280, identifier:rv; 281, argument_list; 281, 282; 282, integer:0; 283, expression_statement; 283, 284; 284, assignment; 284, 285; 284, 286; 285, identifier:output_bai_promise; 286, call; 286, 287; 286, 290; 287, attribute; 287, 288; 287, 289; 288, identifier:preprocess; 289, identifier:rv; 290, argument_list; 290, 291; 291, integer:1; 292, expression_statement; 292, 293; 293, assignment; 293, 294; 293, 295; 294, identifier:output_dir; 295, call; 295, 296; 295, 301; 296, attribute; 296, 297; 296, 300; 297, attribute; 297, 298; 297, 299; 298, identifier:os; 299, identifier:path; 300, identifier:join; 301, argument_list; 301, 302; 301, 305; 302, attribute; 302, 303; 302, 304; 303, identifier:config; 304, identifier:output_dir; 305, identifier:uuid; 306, expression_statement; 306, 307; 307, assignment; 307, 308; 307, 309; 308, identifier:filename; 309, call; 309, 310; 309, 313; 310, attribute; 310, 311; 310, 312; 311, string:'{}.preprocessed{}.bam'; 312, identifier:format; 313, argument_list; 313, 314; 313, 315; 314, identifier:uuid; 315, attribute; 315, 316; 315, 317; 316, identifier:config; 317, identifier:suffix; 318, expression_statement; 318, 319; 319, assignment; 319, 320; 319, 321; 320, identifier:output_bam; 321, call; 321, 322; 321, 325; 322, attribute; 322, 323; 322, 324; 323, identifier:job; 324, identifier:wrapJobFn; 325, argument_list; 325, 326; 325, 327; 325, 328; 325, 334; 325, 335; 326, identifier:output_file_job; 327, identifier:filename; 328, call; 328, 329; 328, 332; 329, attribute; 329, 330; 329, 331; 330, identifier:preprocess; 331, identifier:rv; 332, argument_list; 332, 333; 333, integer:0; 334, identifier:output_dir; 335, keyword_argument; 335, 336; 335, 337; 336, identifier:s3_key_path; 337, attribute; 337, 338; 337, 339; 338, identifier:config; 339, identifier:ssec; 340, expression_statement; 340, 341; 341, call; 341, 342; 341, 345; 342, attribute; 342, 343; 342, 344; 343, identifier:preprocess; 344, identifier:addChild; 345, argument_list; 345, 346; 346, identifier:output_bam; 347, else_clause; 347, 348; 348, block; 348, 349; 348, 357; 349, expression_statement; 349, 350; 350, assignment; 350, 351; 350, 352; 351, identifier:output_bam_promise; 352, call; 352, 353; 352, 356; 353, attribute; 353, 354; 353, 355; 354, identifier:sorted_bam; 355, identifier:rv; 356, argument_list; 357, expression_statement; 357, 358; 358, assignment; 358, 359; 358, 360; 359, identifier:output_bai_promise; 360, call; 360, 361; 360, 364; 361, attribute; 361, 362; 361, 363; 362, identifier:index_bam; 363, identifier:rv; 364, argument_list; 365, return_statement; 365, 366; 366, expression_list; 366, 367; 366, 368; 367, identifier:output_bam_promise; 368, identifier:output_bai_promise | def prepare_bam(job, uuid, url, config, paired_url=None, rg_line=None):
if config.run_bwa:
get_bam = job.wrapJobFn(setup_and_run_bwakit,
uuid,
url,
rg_line,
config,
paired_url=paired_url).encapsulate()
elif '.bam' in url.lower():
job.fileStore.logToMaster("Downloading BAM: %s" % uuid)
get_bam = job.wrapJobFn(download_url_job,
url,
name='toil.bam',
s3_key_path=config.ssec,
disk=config.file_size).encapsulate()
else:
raise ValueError('Could not generate BAM file for %s\n'
'Provide a FASTQ URL and set run-bwa or '
'provide a BAM URL that includes .bam extension.' % uuid)
if config.sorted and not config.run_bwa:
sorted_bam = get_bam
else:
sorted_bam_disk = PromisedRequirement(lambda bam: 3 * bam.size, get_bam.rv())
sorted_bam = get_bam.addChildJobFn(run_samtools_sort,
get_bam.rv(),
cores=config.cores,
disk=sorted_bam_disk)
index_bam_disk = PromisedRequirement(lambda bam: bam.size, sorted_bam.rv())
index_bam = job.wrapJobFn(run_samtools_index, sorted_bam.rv(), disk=index_bam_disk)
job.addChild(get_bam)
sorted_bam.addChild(index_bam)
if config.preprocess:
preprocess = job.wrapJobFn(run_gatk_preprocessing,
sorted_bam.rv(),
index_bam.rv(),
config.genome_fasta,
config.genome_dict,
config.genome_fai,
config.g1k_indel,
config.mills,
config.dbsnp,
memory=config.xmx,
cores=config.cores).encapsulate()
sorted_bam.addChild(preprocess)
index_bam.addChild(preprocess)
output_bam_promise = preprocess.rv(0)
output_bai_promise = preprocess.rv(1)
output_dir = os.path.join(config.output_dir, uuid)
filename = '{}.preprocessed{}.bam'.format(uuid, config.suffix)
output_bam = job.wrapJobFn(output_file_job,
filename,
preprocess.rv(0),
output_dir,
s3_key_path=config.ssec)
preprocess.addChild(output_bam)
else:
output_bam_promise = sorted_bam.rv()
output_bai_promise = index_bam.rv()
return output_bam_promise, output_bai_promise |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:alignment; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:job; 5, identifier:ids; 6, identifier:input_args; 7, identifier:sample; 8, block; 8, 9; 8, 15; 8, 25; 8, 31; 8, 37; 8, 45; 8, 59; 8, 78; 8, 92; 8, 137; 8, 168; 8, 202; 8, 236; 8, 259; 8, 283; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 14; 11, pattern_list; 11, 12; 11, 13; 12, identifier:uuid; 13, identifier:urls; 14, identifier:sample; 15, expression_statement; 15, 16; 16, assignment; 16, 17; 16, 18; 17, identifier:work_dir; 18, call; 18, 19; 18, 24; 19, attribute; 19, 20; 19, 23; 20, attribute; 20, 21; 20, 22; 21, identifier:job; 22, identifier:fileStore; 23, identifier:getLocalTempDir; 24, argument_list; 25, expression_statement; 25, 26; 26, assignment; 26, 27; 26, 28; 27, identifier:output_dir; 28, subscript; 28, 29; 28, 30; 29, identifier:input_args; 30, string:'output_dir'; 31, expression_statement; 31, 32; 32, assignment; 32, 33; 32, 34; 33, identifier:key_path; 34, subscript; 34, 35; 34, 36; 35, identifier:input_args; 36, string:'ssec'; 37, expression_statement; 37, 38; 38, assignment; 38, 39; 38, 40; 39, identifier:cores; 40, call; 40, 41; 40, 44; 41, attribute; 41, 42; 41, 43; 42, identifier:multiprocessing; 43, identifier:cpu_count; 44, argument_list; 45, expression_statement; 45, 46; 46, call; 46, 47; 46, 48; 47, identifier:return_input_paths; 48, argument_list; 48, 49; 48, 50; 48, 51; 48, 52; 48, 53; 48, 54; 48, 55; 48, 56; 48, 57; 48, 58; 49, identifier:job; 50, identifier:work_dir; 51, identifier:ids; 52, string:'ref.fa'; 53, string:'ref.fa.amb'; 54, string:'ref.fa.ann'; 55, string:'ref.fa.bwt'; 56, string:'ref.fa.pac'; 57, string:'ref.fa.sa'; 58, string:'ref.fa.fai'; 59, for_statement; 59, 60; 59, 61; 59, 62; 60, identifier:url; 61, identifier:urls; 62, block; 62, 63; 63, expression_statement; 63, 64; 64, call; 64, 65; 64, 66; 65, identifier:download_encrypted_file; 66, argument_list; 66, 67; 66, 68; 66, 69; 66, 70; 67, identifier:work_dir; 68, identifier:url; 69, identifier:key_path; 70, call; 70, 71; 70, 76; 71, attribute; 71, 72; 71, 75; 72, attribute; 72, 73; 72, 74; 73, identifier:os; 74, identifier:path; 75, identifier:basename; 76, argument_list; 76, 77; 77, identifier:url; 78, expression_statement; 78, 79; 79, assignment; 79, 80; 79, 81; 80, identifier:docker_cmd; 81, list:['docker', 'run', '--rm', '-v', '{}:/data'.format(work_dir)]; 81, 82; 81, 83; 81, 84; 81, 85; 81, 86; 82, string:'docker'; 83, string:'run'; 84, string:'--rm'; 85, string:'-v'; 86, call; 86, 87; 86, 90; 87, attribute; 87, 88; 87, 89; 88, string:'{}:/data'; 89, identifier:format; 90, argument_list; 90, 91; 91, identifier:work_dir; 92, expression_statement; 92, 93; 93, assignment; 93, 94; 93, 95; 94, identifier:bwa_command; 95, binary_operator:+; 95, 96; 95, 117; 96, list:["jvivian/bwa",
"mem",
"-R", "@RG\tID:{0}\tPL:Illumina\tSM:{0}\tLB:KapaHyper".format(uuid),
"-T", str(0),
"-t", str(cores),
"/data/ref.fa"]; 96, 97; 96, 98; 96, 99; 96, 100; 96, 106; 96, 107; 96, 111; 96, 112; 96, 116; 97, string:"jvivian/bwa"; 98, string:"mem"; 99, string:"-R"; 100, call; 100, 101; 100, 104; 101, attribute; 101, 102; 101, 103; 102, string:"@RG\tID:{0}\tPL:Illumina\tSM:{0}\tLB:KapaHyper"; 103, identifier:format; 104, argument_list; 104, 105; 105, identifier:uuid; 106, string:"-T"; 107, call; 107, 108; 107, 109; 108, identifier:str; 109, argument_list; 109, 110; 110, integer:0; 111, string:"-t"; 112, call; 112, 113; 112, 114; 113, identifier:str; 114, argument_list; 114, 115; 115, identifier:cores; 116, string:"/data/ref.fa"; 117, list_comprehension; 117, 118; 117, 134; 118, call; 118, 119; 118, 124; 119, attribute; 119, 120; 119, 123; 120, attribute; 120, 121; 120, 122; 121, identifier:os; 122, identifier:path; 123, identifier:join; 124, argument_list; 124, 125; 124, 126; 125, string:'/data/'; 126, call; 126, 127; 126, 132; 127, attribute; 127, 128; 127, 131; 128, attribute; 128, 129; 128, 130; 129, identifier:os; 130, identifier:path; 131, identifier:basename; 132, argument_list; 132, 133; 133, identifier:x; 134, for_in_clause; 134, 135; 134, 136; 135, identifier:x; 136, identifier:urls; 137, expression_statement; 137, 138; 138, assignment; 138, 139; 138, 140; 139, identifier:bamsort_command; 140, list:["jeltje/biobambam",
"/usr/local/bin/bamsort",
"inputformat=sam",
"level=1",
"inputthreads={}".format(cores),
"outputthreads={}".format(cores),
"calmdnm=1",
"calmdnmrecompindetonly=1",
"calmdnmreference=/data/ref.fa",
"I=/data/{}".format(uuid + '.sam')]; 140, 141; 140, 142; 140, 143; 140, 144; 140, 145; 140, 151; 140, 157; 140, 158; 140, 159; 140, 160; 141, string:"jeltje/biobambam"; 142, string:"/usr/local/bin/bamsort"; 143, string:"inputformat=sam"; 144, string:"level=1"; 145, call; 145, 146; 145, 149; 146, attribute; 146, 147; 146, 148; 147, string:"inputthreads={}"; 148, identifier:format; 149, argument_list; 149, 150; 150, identifier:cores; 151, call; 151, 152; 151, 155; 152, attribute; 152, 153; 152, 154; 153, string:"outputthreads={}"; 154, identifier:format; 155, argument_list; 155, 156; 156, identifier:cores; 157, string:"calmdnm=1"; 158, string:"calmdnmrecompindetonly=1"; 159, string:"calmdnmreference=/data/ref.fa"; 160, call; 160, 161; 160, 164; 161, attribute; 161, 162; 161, 163; 162, string:"I=/data/{}"; 163, identifier:format; 164, argument_list; 164, 165; 165, binary_operator:+; 165, 166; 165, 167; 166, identifier:uuid; 167, string:'.sam'; 168, with_statement; 168, 169; 168, 189; 169, with_clause; 169, 170; 170, with_item; 170, 171; 171, as_pattern; 171, 172; 171, 187; 172, call; 172, 173; 172, 174; 173, identifier:open; 174, argument_list; 174, 175; 174, 186; 175, call; 175, 176; 175, 181; 176, attribute; 176, 177; 176, 180; 177, attribute; 177, 178; 177, 179; 178, identifier:os; 179, identifier:path; 180, identifier:join; 181, argument_list; 181, 182; 181, 183; 182, identifier:work_dir; 183, binary_operator:+; 183, 184; 183, 185; 184, identifier:uuid; 185, string:'.sam'; 186, string:'w'; 187, as_pattern_target; 187, 188; 188, identifier:f_out; 189, block; 189, 190; 190, expression_statement; 190, 191; 191, call; 191, 192; 191, 195; 192, attribute; 192, 193; 192, 194; 193, identifier:subprocess; 194, identifier:check_call; 195, argument_list; 195, 196; 195, 199; 196, binary_operator:+; 196, 197; 196, 198; 197, identifier:docker_cmd; 198, identifier:bwa_command; 199, keyword_argument; 199, 200; 199, 201; 200, identifier:stdout; 201, identifier:f_out; 202, with_statement; 202, 203; 202, 223; 203, with_clause; 203, 204; 204, with_item; 204, 205; 205, as_pattern; 205, 206; 205, 221; 206, call; 206, 207; 206, 208; 207, identifier:open; 208, argument_list; 208, 209; 208, 220; 209, call; 209, 210; 209, 215; 210, attribute; 210, 211; 210, 214; 211, attribute; 211, 212; 211, 213; 212, identifier:os; 213, identifier:path; 214, identifier:join; 215, argument_list; 215, 216; 215, 217; 216, identifier:work_dir; 217, binary_operator:+; 217, 218; 217, 219; 218, identifier:uuid; 219, string:'.bam'; 220, string:'w'; 221, as_pattern_target; 221, 222; 222, identifier:f_out; 223, block; 223, 224; 224, expression_statement; 224, 225; 225, call; 225, 226; 225, 229; 226, attribute; 226, 227; 226, 228; 227, identifier:subprocess; 228, identifier:check_call; 229, argument_list; 229, 230; 229, 233; 230, binary_operator:+; 230, 231; 230, 232; 231, identifier:docker_cmd; 232, identifier:bamsort_command; 233, keyword_argument; 233, 234; 233, 235; 234, identifier:stdout; 235, identifier:f_out; 236, expression_statement; 236, 237; 237, assignment; 237, 238; 237, 241; 238, subscript; 238, 239; 238, 240; 239, identifier:ids; 240, string:'bam'; 241, call; 241, 242; 241, 247; 242, attribute; 242, 243; 242, 246; 243, attribute; 243, 244; 243, 245; 244, identifier:job; 245, identifier:fileStore; 246, identifier:writeGlobalFile; 247, argument_list; 247, 248; 248, call; 248, 249; 248, 254; 249, attribute; 249, 250; 249, 253; 250, attribute; 250, 251; 250, 252; 251, identifier:os; 252, identifier:path; 253, identifier:join; 254, argument_list; 254, 255; 254, 256; 255, identifier:work_dir; 256, binary_operator:+; 256, 257; 256, 258; 257, identifier:uuid; 258, string:'.bam'; 259, if_statement; 259, 260; 259, 263; 260, subscript; 260, 261; 260, 262; 261, identifier:input_args; 262, string:'s3_dir'; 263, block; 263, 264; 264, expression_statement; 264, 265; 265, call; 265, 266; 265, 269; 266, attribute; 266, 267; 266, 268; 267, identifier:job; 268, identifier:addChildJobFn; 269, argument_list; 269, 270; 269, 271; 269, 272; 269, 273; 269, 274; 269, 277; 269, 280; 270, identifier:upload_bam_to_s3; 271, identifier:ids; 272, identifier:input_args; 273, identifier:sample; 274, keyword_argument; 274, 275; 274, 276; 275, identifier:cores; 276, integer:32; 277, keyword_argument; 277, 278; 277, 279; 278, identifier:memory; 279, string:'20 G'; 280, keyword_argument; 280, 281; 280, 282; 281, identifier:disk; 282, string:'30 G'; 283, if_statement; 283, 284; 283, 287; 284, subscript; 284, 285; 284, 286; 285, identifier:input_args; 286, string:'output_dir'; 287, block; 287, 288; 288, expression_statement; 288, 289; 289, call; 289, 290; 289, 291; 290, identifier:move_to_output_dir; 291, argument_list; 291, 292; 291, 293; 291, 294; 291, 297; 292, identifier:work_dir; 293, identifier:output_dir; 294, keyword_argument; 294, 295; 294, 296; 295, identifier:uuid; 296, None; 297, keyword_argument; 297, 298; 297, 299; 298, identifier:files; 299, list:[uuid + '.bam']; 299, 300; 300, binary_operator:+; 300, 301; 300, 302; 301, identifier:uuid; 302, string:'.bam' | def alignment(job, ids, input_args, sample):
uuid, urls = sample
work_dir = job.fileStore.getLocalTempDir()
output_dir = input_args['output_dir']
key_path = input_args['ssec']
cores = multiprocessing.cpu_count()
return_input_paths(job, work_dir, ids, 'ref.fa', 'ref.fa.amb', 'ref.fa.ann',
'ref.fa.bwt', 'ref.fa.pac', 'ref.fa.sa', 'ref.fa.fai')
for url in urls:
download_encrypted_file(work_dir, url, key_path, os.path.basename(url))
docker_cmd = ['docker', 'run', '--rm', '-v', '{}:/data'.format(work_dir)]
bwa_command = ["jvivian/bwa",
"mem",
"-R", "@RG\tID:{0}\tPL:Illumina\tSM:{0}\tLB:KapaHyper".format(uuid),
"-T", str(0),
"-t", str(cores),
"/data/ref.fa"] + [os.path.join('/data/', os.path.basename(x)) for x in urls]
bamsort_command = ["jeltje/biobambam",
"/usr/local/bin/bamsort",
"inputformat=sam",
"level=1",
"inputthreads={}".format(cores),
"outputthreads={}".format(cores),
"calmdnm=1",
"calmdnmrecompindetonly=1",
"calmdnmreference=/data/ref.fa",
"I=/data/{}".format(uuid + '.sam')]
with open(os.path.join(work_dir, uuid + '.sam'), 'w') as f_out:
subprocess.check_call(docker_cmd + bwa_command, stdout=f_out)
with open(os.path.join(work_dir, uuid + '.bam'), 'w') as f_out:
subprocess.check_call(docker_cmd + bamsort_command, stdout=f_out)
ids['bam'] = job.fileStore.writeGlobalFile(os.path.join(work_dir, uuid + '.bam'))
if input_args['s3_dir']:
job.addChildJobFn(upload_bam_to_s3, ids, input_args, sample, cores=32, memory='20 G', disk='30 G')
if input_args['output_dir']:
move_to_output_dir(work_dir, output_dir, uuid=None, files=[uuid + '.bam']) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:bamsort_and_index; 3, parameters; 3, 4; 3, 5; 4, identifier:job; 5, identifier:job_vars; 6, block; 6, 7; 6, 13; 6, 23; 6, 29; 6, 39; 6, 51; 6, 64; 6, 73; 6, 89; 6, 105; 6, 118; 6, 139; 6, 156; 6, 173; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 12; 9, pattern_list; 9, 10; 9, 11; 10, identifier:input_args; 11, identifier:ids; 12, identifier:job_vars; 13, expression_statement; 13, 14; 14, assignment; 14, 15; 14, 16; 15, identifier:work_dir; 16, call; 16, 17; 16, 22; 17, attribute; 17, 18; 17, 21; 18, attribute; 18, 19; 18, 20; 19, identifier:job; 20, identifier:fileStore; 21, identifier:getLocalTempDir; 22, argument_list; 23, expression_statement; 23, 24; 24, assignment; 24, 25; 24, 26; 25, identifier:sudo; 26, subscript; 26, 27; 26, 28; 27, identifier:input_args; 28, string:'sudo'; 29, expression_statement; 29, 30; 30, assignment; 30, 31; 30, 32; 31, identifier:rg_alignments; 32, call; 32, 33; 32, 34; 33, identifier:return_input_paths; 34, argument_list; 34, 35; 34, 36; 34, 37; 34, 38; 35, identifier:job; 36, identifier:work_dir; 37, identifier:ids; 38, string:'rg_alignments.bam'; 39, expression_statement; 39, 40; 40, assignment; 40, 41; 40, 42; 41, identifier:output; 42, call; 42, 43; 42, 48; 43, attribute; 43, 44; 43, 47; 44, attribute; 44, 45; 44, 46; 45, identifier:os; 46, identifier:path; 47, identifier:join; 48, argument_list; 48, 49; 48, 50; 49, identifier:work_dir; 50, string:'sorted.bam'; 51, expression_statement; 51, 52; 52, assignment; 52, 53; 52, 54; 53, identifier:cmd1; 54, list:['sort', docker_path(rg_alignments), docker_path('sorted')]; 54, 55; 54, 56; 54, 60; 55, string:'sort'; 56, call; 56, 57; 56, 58; 57, identifier:docker_path; 58, argument_list; 58, 59; 59, identifier:rg_alignments; 60, call; 60, 61; 60, 62; 61, identifier:docker_path; 62, argument_list; 62, 63; 63, string:'sorted'; 64, expression_statement; 64, 65; 65, assignment; 65, 66; 65, 67; 66, identifier:cmd2; 67, list:['index', docker_path(output)]; 67, 68; 67, 69; 68, string:'index'; 69, call; 69, 70; 69, 71; 70, identifier:docker_path; 71, argument_list; 71, 72; 72, identifier:output; 73, expression_statement; 73, 74; 74, call; 74, 75; 74, 76; 75, identifier:docker_call; 76, argument_list; 76, 77; 76, 80; 76, 83; 76, 86; 77, keyword_argument; 77, 78; 77, 79; 78, identifier:tool; 79, string:'quay.io/ucsc_cgl/samtools:0.1.19--dd5ac549b95eb3e5d166a5e310417ef13651994e'; 80, keyword_argument; 80, 81; 80, 82; 81, identifier:tool_parameters; 82, identifier:cmd1; 83, keyword_argument; 83, 84; 83, 85; 84, identifier:work_dir; 85, identifier:work_dir; 86, keyword_argument; 86, 87; 86, 88; 87, identifier:sudo; 88, identifier:sudo; 89, expression_statement; 89, 90; 90, call; 90, 91; 90, 92; 91, identifier:docker_call; 92, argument_list; 92, 93; 92, 96; 92, 99; 92, 102; 93, keyword_argument; 93, 94; 93, 95; 94, identifier:tool; 95, string:'quay.io/ucsc_cgl/samtools:0.1.19--dd5ac549b95eb3e5d166a5e310417ef13651994e'; 96, keyword_argument; 96, 97; 96, 98; 97, identifier:tool_parameters; 98, identifier:cmd2; 99, keyword_argument; 99, 100; 99, 101; 100, identifier:work_dir; 101, identifier:work_dir; 102, keyword_argument; 102, 103; 102, 104; 103, identifier:sudo; 104, identifier:sudo; 105, expression_statement; 105, 106; 106, assignment; 106, 107; 106, 110; 107, subscript; 107, 108; 107, 109; 108, identifier:ids; 109, string:'sorted.bam'; 110, call; 110, 111; 110, 116; 111, attribute; 111, 112; 111, 115; 112, attribute; 112, 113; 112, 114; 113, identifier:job; 114, identifier:fileStore; 115, identifier:writeGlobalFile; 116, argument_list; 116, 117; 117, identifier:output; 118, expression_statement; 118, 119; 119, assignment; 119, 120; 119, 123; 120, subscript; 120, 121; 120, 122; 121, identifier:ids; 122, string:'sorted.bam.bai'; 123, call; 123, 124; 123, 129; 124, attribute; 124, 125; 124, 128; 125, attribute; 125, 126; 125, 127; 126, identifier:job; 127, identifier:fileStore; 128, identifier:writeGlobalFile; 129, argument_list; 129, 130; 130, call; 130, 131; 130, 136; 131, attribute; 131, 132; 131, 135; 132, attribute; 132, 133; 132, 134; 133, identifier:os; 134, identifier:path; 135, identifier:join; 136, argument_list; 136, 137; 136, 138; 137, identifier:work_dir; 138, string:'sorted.bam.bai'; 139, expression_statement; 139, 140; 140, assignment; 140, 141; 140, 142; 141, identifier:output_ids; 142, call; 142, 143; 142, 155; 143, attribute; 143, 144; 143, 154; 144, call; 144, 145; 144, 148; 145, attribute; 145, 146; 145, 147; 146, identifier:job; 147, identifier:addChildJobFn; 148, argument_list; 148, 149; 148, 150; 148, 151; 149, identifier:sort_bam_by_reference; 150, identifier:job_vars; 151, keyword_argument; 151, 152; 151, 153; 152, identifier:disk; 153, string:'50 G'; 154, identifier:rv; 155, argument_list; 156, expression_statement; 156, 157; 157, assignment; 157, 158; 157, 159; 158, identifier:rseq_id; 159, call; 159, 160; 159, 172; 160, attribute; 160, 161; 160, 171; 161, call; 161, 162; 161, 165; 162, attribute; 162, 163; 162, 164; 163, identifier:job; 164, identifier:addChildJobFn; 165, argument_list; 165, 166; 165, 167; 165, 168; 166, identifier:rseq_qc; 167, identifier:job_vars; 168, keyword_argument; 168, 169; 168, 170; 169, identifier:disk; 170, string:'20 G'; 171, identifier:rv; 172, argument_list; 173, return_statement; 173, 174; 174, expression_list; 174, 175; 174, 176; 175, identifier:rseq_id; 176, identifier:output_ids | def bamsort_and_index(job, job_vars):
input_args, ids = job_vars
work_dir = job.fileStore.getLocalTempDir()
sudo = input_args['sudo']
rg_alignments = return_input_paths(job, work_dir, ids, 'rg_alignments.bam')
output = os.path.join(work_dir, 'sorted.bam')
cmd1 = ['sort', docker_path(rg_alignments), docker_path('sorted')]
cmd2 = ['index', docker_path(output)]
docker_call(tool='quay.io/ucsc_cgl/samtools:0.1.19--dd5ac549b95eb3e5d166a5e310417ef13651994e',
tool_parameters=cmd1, work_dir=work_dir, sudo=sudo)
docker_call(tool='quay.io/ucsc_cgl/samtools:0.1.19--dd5ac549b95eb3e5d166a5e310417ef13651994e',
tool_parameters=cmd2, work_dir=work_dir, sudo=sudo)
ids['sorted.bam'] = job.fileStore.writeGlobalFile(output)
ids['sorted.bam.bai'] = job.fileStore.writeGlobalFile(os.path.join(work_dir, 'sorted.bam.bai'))
output_ids = job.addChildJobFn(sort_bam_by_reference, job_vars, disk='50 G').rv()
rseq_id = job.addChildJobFn(rseq_qc, job_vars, disk='20 G').rv()
return rseq_id, output_ids |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:sort_bam_by_reference; 3, parameters; 3, 4; 3, 5; 4, identifier:job; 5, identifier:job_vars; 6, block; 6, 7; 6, 13; 6, 23; 6, 36; 6, 48; 6, 52; 6, 72; 6, 113; 6, 119; 6, 177; 6, 195; 6, 205; 6, 212; 6, 225; 6, 245; 6, 262; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 12; 9, pattern_list; 9, 10; 9, 11; 10, identifier:input_args; 11, identifier:ids; 12, identifier:job_vars; 13, expression_statement; 13, 14; 14, assignment; 14, 15; 14, 16; 15, identifier:work_dir; 16, call; 16, 17; 16, 22; 17, attribute; 17, 18; 17, 21; 18, attribute; 18, 19; 18, 20; 19, identifier:job; 20, identifier:fileStore; 21, identifier:getLocalTempDir; 22, argument_list; 23, expression_statement; 23, 24; 24, assignment; 24, 25; 24, 28; 25, pattern_list; 25, 26; 25, 27; 26, identifier:sorted_bam; 27, identifier:sorted_bai; 28, call; 28, 29; 28, 30; 29, identifier:return_input_paths; 30, argument_list; 30, 31; 30, 32; 30, 33; 30, 34; 30, 35; 31, identifier:job; 32, identifier:work_dir; 33, identifier:ids; 34, string:'sorted.bam'; 35, string:'sorted.bam.bai'; 36, expression_statement; 36, 37; 37, assignment; 37, 38; 37, 39; 38, identifier:output; 39, call; 39, 40; 39, 45; 40, attribute; 40, 41; 40, 44; 41, attribute; 41, 42; 41, 43; 42, identifier:os; 43, identifier:path; 44, identifier:join; 45, argument_list; 45, 46; 45, 47; 46, identifier:work_dir; 47, string:'sort_by_ref.bam'; 48, expression_statement; 48, 49; 49, assignment; 49, 50; 49, 51; 50, identifier:ref_seqs; 51, list:[]; 52, expression_statement; 52, 53; 53, assignment; 53, 54; 53, 55; 54, identifier:handle; 55, attribute; 55, 56; 55, 71; 56, call; 56, 57; 56, 60; 57, attribute; 57, 58; 57, 59; 58, identifier:subprocess; 59, identifier:Popen; 60, argument_list; 60, 61; 60, 66; 61, list:["samtools", "view", "-H", sorted_bam]; 61, 62; 61, 63; 61, 64; 61, 65; 62, string:"samtools"; 63, string:"view"; 64, string:"-H"; 65, identifier:sorted_bam; 66, keyword_argument; 66, 67; 66, 68; 67, identifier:stdout; 68, attribute; 68, 69; 68, 70; 69, identifier:subprocess; 70, identifier:PIPE; 71, identifier:stdout; 72, for_statement; 72, 73; 72, 74; 72, 75; 73, identifier:line; 74, identifier:handle; 75, block; 75, 76; 76, if_statement; 76, 77; 76, 83; 77, call; 77, 78; 77, 81; 78, attribute; 78, 79; 78, 80; 79, identifier:line; 80, identifier:startswith; 81, argument_list; 81, 82; 82, string:"@SQ"; 83, block; 83, 84; 83, 93; 83, 106; 84, expression_statement; 84, 85; 85, assignment; 85, 86; 85, 87; 86, identifier:tmp; 87, call; 87, 88; 87, 91; 88, attribute; 88, 89; 88, 90; 89, identifier:line; 90, identifier:split; 91, argument_list; 91, 92; 92, string:"\t"; 93, expression_statement; 93, 94; 94, assignment; 94, 95; 94, 96; 95, identifier:chrom; 96, subscript; 96, 97; 96, 105; 97, call; 97, 98; 97, 103; 98, attribute; 98, 99; 98, 102; 99, subscript; 99, 100; 99, 101; 100, identifier:tmp; 101, integer:1; 102, identifier:split; 103, argument_list; 103, 104; 104, string:":"; 105, integer:1; 106, expression_statement; 106, 107; 107, call; 107, 108; 107, 111; 108, attribute; 108, 109; 108, 110; 109, identifier:ref_seqs; 110, identifier:append; 111, argument_list; 111, 112; 112, identifier:chrom; 113, expression_statement; 113, 114; 114, call; 114, 115; 114, 118; 115, attribute; 115, 116; 115, 117; 116, identifier:handle; 117, identifier:close; 118, argument_list; 119, for_statement; 119, 120; 119, 121; 119, 122; 120, identifier:chrom; 121, identifier:ref_seqs; 122, block; 122, 123; 122, 132; 122, 151; 122, 165; 123, expression_statement; 123, 124; 124, assignment; 124, 125; 124, 126; 125, identifier:cmd_view; 126, list:["samtools", "view", "-b", sorted_bam, chrom]; 126, 127; 126, 128; 126, 129; 126, 130; 126, 131; 127, string:"samtools"; 128, string:"view"; 129, string:"-b"; 130, identifier:sorted_bam; 131, identifier:chrom; 132, expression_statement; 132, 133; 133, assignment; 133, 134; 133, 135; 134, identifier:cmd_sort; 135, list:["samtools", "sort", "-m", "3000000000", "-n", "-", os.path.join(work_dir, chrom)]; 135, 136; 135, 137; 135, 138; 135, 139; 135, 140; 135, 141; 135, 142; 136, string:"samtools"; 137, string:"sort"; 138, string:"-m"; 139, string:"3000000000"; 140, string:"-n"; 141, string:"-"; 142, call; 142, 143; 142, 148; 143, attribute; 143, 144; 143, 147; 144, attribute; 144, 145; 144, 146; 145, identifier:os; 146, identifier:path; 147, identifier:join; 148, argument_list; 148, 149; 148, 150; 149, identifier:work_dir; 150, identifier:chrom; 151, expression_statement; 151, 152; 152, assignment; 152, 153; 152, 154; 153, identifier:p1; 154, call; 154, 155; 154, 158; 155, attribute; 155, 156; 155, 157; 156, identifier:subprocess; 157, identifier:Popen; 158, argument_list; 158, 159; 158, 160; 159, identifier:cmd_view; 160, keyword_argument; 160, 161; 160, 162; 161, identifier:stdout; 162, attribute; 162, 163; 162, 164; 163, identifier:subprocess; 164, identifier:PIPE; 165, expression_statement; 165, 166; 166, call; 166, 167; 166, 170; 167, attribute; 167, 168; 167, 169; 168, identifier:subprocess; 169, identifier:check_call; 170, argument_list; 170, 171; 170, 172; 171, identifier:cmd_sort; 172, keyword_argument; 172, 173; 172, 174; 173, identifier:stdin; 174, attribute; 174, 175; 174, 176; 175, identifier:p1; 176, identifier:stdout; 177, expression_statement; 177, 178; 178, assignment; 178, 179; 178, 180; 179, identifier:sorted_files; 180, list_comprehension; 180, 181; 180, 192; 181, binary_operator:+; 181, 182; 181, 191; 182, call; 182, 183; 182, 188; 183, attribute; 183, 184; 183, 187; 184, attribute; 184, 185; 184, 186; 185, identifier:os; 186, identifier:path; 187, identifier:join; 188, argument_list; 188, 189; 188, 190; 189, identifier:work_dir; 190, identifier:chrom; 191, string:'.bam'; 192, for_in_clause; 192, 193; 192, 194; 193, identifier:chrom; 194, identifier:ref_seqs; 195, expression_statement; 195, 196; 196, assignment; 196, 197; 196, 198; 197, identifier:cmd; 198, binary_operator:+; 198, 199; 198, 204; 199, list:["samtools", "cat", "-o", output]; 199, 200; 199, 201; 199, 202; 199, 203; 200, string:"samtools"; 201, string:"cat"; 202, string:"-o"; 203, identifier:output; 204, identifier:sorted_files; 205, expression_statement; 205, 206; 206, call; 206, 207; 206, 210; 207, attribute; 207, 208; 207, 209; 208, identifier:subprocess; 209, identifier:check_call; 210, argument_list; 210, 211; 211, identifier:cmd; 212, expression_statement; 212, 213; 213, assignment; 213, 214; 213, 217; 214, subscript; 214, 215; 214, 216; 215, identifier:ids; 216, string:'sort_by_ref.bam'; 217, call; 217, 218; 217, 223; 218, attribute; 218, 219; 218, 222; 219, attribute; 219, 220; 219, 221; 220, identifier:job; 221, identifier:fileStore; 222, identifier:writeGlobalFile; 223, argument_list; 223, 224; 224, identifier:output; 225, expression_statement; 225, 226; 226, assignment; 226, 227; 226, 228; 227, identifier:rsem_id; 228, call; 228, 229; 228, 244; 229, attribute; 229, 230; 229, 243; 230, call; 230, 231; 230, 234; 231, attribute; 231, 232; 231, 233; 232, identifier:job; 233, identifier:addChildJobFn; 234, argument_list; 234, 235; 234, 236; 234, 237; 234, 240; 235, identifier:transcriptome; 236, identifier:job_vars; 237, keyword_argument; 237, 238; 237, 239; 238, identifier:disk; 239, string:'30 G'; 240, keyword_argument; 240, 241; 240, 242; 241, identifier:memory; 242, string:'30 G'; 243, identifier:rv; 244, argument_list; 245, expression_statement; 245, 246; 246, assignment; 246, 247; 246, 248; 247, identifier:exon_id; 248, call; 248, 249; 248, 261; 249, attribute; 249, 250; 249, 260; 250, call; 250, 251; 250, 254; 251, attribute; 251, 252; 251, 253; 252, identifier:job; 253, identifier:addChildJobFn; 254, argument_list; 254, 255; 254, 256; 254, 257; 255, identifier:exon_count; 256, identifier:job_vars; 257, keyword_argument; 257, 258; 257, 259; 258, identifier:disk; 259, string:'30 G'; 260, identifier:rv; 261, argument_list; 262, return_statement; 262, 263; 263, expression_list; 263, 264; 263, 265; 264, identifier:exon_id; 265, identifier:rsem_id | def sort_bam_by_reference(job, job_vars):
input_args, ids = job_vars
work_dir = job.fileStore.getLocalTempDir()
sorted_bam, sorted_bai = return_input_paths(job, work_dir, ids, 'sorted.bam', 'sorted.bam.bai')
output = os.path.join(work_dir, 'sort_by_ref.bam')
ref_seqs = []
handle = subprocess.Popen(["samtools", "view", "-H", sorted_bam], stdout=subprocess.PIPE).stdout
for line in handle:
if line.startswith("@SQ"):
tmp = line.split("\t")
chrom = tmp[1].split(":")[1]
ref_seqs.append(chrom)
handle.close()
for chrom in ref_seqs:
cmd_view = ["samtools", "view", "-b", sorted_bam, chrom]
cmd_sort = ["samtools", "sort", "-m", "3000000000", "-n", "-", os.path.join(work_dir, chrom)]
p1 = subprocess.Popen(cmd_view, stdout=subprocess.PIPE)
subprocess.check_call(cmd_sort, stdin=p1.stdout)
sorted_files = [os.path.join(work_dir, chrom) + '.bam' for chrom in ref_seqs]
cmd = ["samtools", "cat", "-o", output] + sorted_files
subprocess.check_call(cmd)
ids['sort_by_ref.bam'] = job.fileStore.writeGlobalFile(output)
rsem_id = job.addChildJobFn(transcriptome, job_vars, disk='30 G', memory='30 G').rv()
exon_id = job.addChildJobFn(exon_count, job_vars, disk='30 G').rv()
return exon_id, rsem_id |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 4; 2, function_name:main; 3, parameters; 4, block; 4, 5; 4, 11; 4, 20; 4, 28; 4, 121; 5, expression_statement; 5, 6; 6, assignment; 6, 7; 6, 8; 7, identifier:parser; 8, call; 8, 9; 8, 10; 9, identifier:build_parser; 10, argument_list; 11, expression_statement; 11, 12; 12, call; 12, 13; 12, 18; 13, attribute; 13, 14; 13, 17; 14, attribute; 14, 15; 14, 16; 15, identifier:Job; 16, identifier:Runner; 17, identifier:addToilOptions; 18, argument_list; 18, 19; 19, identifier:parser; 20, expression_statement; 20, 21; 21, assignment; 21, 22; 21, 23; 22, identifier:args; 23, call; 23, 24; 23, 27; 24, attribute; 24, 25; 24, 26; 25, identifier:parser; 26, identifier:parse_args; 27, argument_list; 28, expression_statement; 28, 29; 29, assignment; 29, 30; 29, 31; 30, identifier:inputs; 31, dictionary; 31, 32; 31, 37; 31, 42; 31, 47; 31, 52; 31, 57; 31, 62; 31, 67; 31, 72; 31, 77; 31, 82; 31, 87; 31, 92; 31, 97; 31, 102; 31, 107; 31, 112; 31, 115; 31, 118; 32, pair; 32, 33; 32, 34; 33, string:'config'; 34, attribute; 34, 35; 34, 36; 35, identifier:args; 36, identifier:config; 37, pair; 37, 38; 37, 39; 38, string:'config_fastq'; 39, attribute; 39, 40; 39, 41; 40, identifier:args; 41, identifier:config_fastq; 42, pair; 42, 43; 42, 44; 43, string:'input'; 44, attribute; 44, 45; 44, 46; 45, identifier:args; 46, identifier:input; 47, pair; 47, 48; 47, 49; 48, string:'unc.bed'; 49, attribute; 49, 50; 49, 51; 50, identifier:args; 51, identifier:unc; 52, pair; 52, 53; 52, 54; 53, string:'hg19.transcripts.fa'; 54, attribute; 54, 55; 54, 56; 55, identifier:args; 56, identifier:fasta; 57, pair; 57, 58; 57, 59; 58, string:'composite_exons.bed'; 59, attribute; 59, 60; 59, 61; 60, identifier:args; 61, identifier:composite_exons; 62, pair; 62, 63; 62, 64; 63, string:'normalize.pl'; 64, attribute; 64, 65; 64, 66; 65, identifier:args; 66, identifier:normalize; 67, pair; 67, 68; 67, 69; 68, string:'output_dir'; 69, attribute; 69, 70; 69, 71; 70, identifier:args; 71, identifier:output_dir; 72, pair; 72, 73; 72, 74; 73, string:'rsem_ref.zip'; 74, attribute; 74, 75; 74, 76; 75, identifier:args; 76, identifier:rsem_ref; 77, pair; 77, 78; 77, 79; 78, string:'chromosomes.zip'; 79, attribute; 79, 80; 79, 81; 80, identifier:args; 81, identifier:chromosomes; 82, pair; 82, 83; 82, 84; 83, string:'ebwt.zip'; 84, attribute; 84, 85; 84, 86; 85, identifier:args; 86, identifier:ebwt; 87, pair; 87, 88; 87, 89; 88, string:'ssec'; 89, attribute; 89, 90; 89, 91; 90, identifier:args; 91, identifier:ssec; 92, pair; 92, 93; 92, 94; 93, string:'s3_dir'; 94, attribute; 94, 95; 94, 96; 95, identifier:args; 96, identifier:s3_dir; 97, pair; 97, 98; 97, 99; 98, string:'sudo'; 99, attribute; 99, 100; 99, 101; 100, identifier:args; 101, identifier:sudo; 102, pair; 102, 103; 102, 104; 103, string:'single_end_reads'; 104, attribute; 104, 105; 104, 106; 105, identifier:args; 106, identifier:single_end_reads; 107, pair; 107, 108; 107, 109; 108, string:'upload_bam_to_s3'; 109, attribute; 109, 110; 109, 111; 110, identifier:args; 111, identifier:upload_bam_to_s3; 112, pair; 112, 113; 112, 114; 113, string:'uuid'; 114, None; 115, pair; 115, 116; 115, 117; 116, string:'sample.tar'; 117, None; 118, pair; 118, 119; 118, 120; 119, string:'cpu_count'; 120, None; 121, expression_statement; 121, 122; 122, call; 122, 123; 122, 128; 123, attribute; 123, 124; 123, 127; 124, attribute; 124, 125; 124, 126; 125, identifier:Job; 126, identifier:Runner; 127, identifier:startToil; 128, argument_list; 128, 129; 128, 136; 129, call; 129, 130; 129, 133; 130, attribute; 130, 131; 130, 132; 131, identifier:Job; 132, identifier:wrapJobFn; 133, argument_list; 133, 134; 133, 135; 134, identifier:download_shared_files; 135, identifier:inputs; 136, identifier:args | def main():
parser = build_parser()
Job.Runner.addToilOptions(parser)
args = parser.parse_args()
inputs = {'config': args.config,
'config_fastq': args.config_fastq,
'input': args.input,
'unc.bed': args.unc,
'hg19.transcripts.fa': args.fasta,
'composite_exons.bed': args.composite_exons,
'normalize.pl': args.normalize,
'output_dir': args.output_dir,
'rsem_ref.zip': args.rsem_ref,
'chromosomes.zip': args.chromosomes,
'ebwt.zip': args.ebwt,
'ssec': args.ssec,
's3_dir': args.s3_dir,
'sudo': args.sudo,
'single_end_reads': args.single_end_reads,
'upload_bam_to_s3': args.upload_bam_to_s3,
'uuid': None,
'sample.tar': None,
'cpu_count': None}
Job.Runner.startToil(Job.wrapJobFn(download_shared_files, inputs), args) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:fourier_series; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:pars; 6, identifier:x; 7, identifier:order; 8, block; 8, 9; 8, 15; 8, 77; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 11, identifier:sum; 12, subscript; 12, 13; 12, 14; 13, identifier:pars; 14, integer:0; 15, for_statement; 15, 16; 15, 17; 15, 21; 16, identifier:i; 17, call; 17, 18; 17, 19; 18, identifier:range; 19, argument_list; 19, 20; 20, identifier:order; 21, block; 21, 22; 22, expression_statement; 22, 23; 23, augmented_assignment:+=; 23, 24; 23, 25; 24, identifier:sum; 25, binary_operator:+; 25, 26; 25, 51; 25, 52; 26, binary_operator:*; 26, 27; 26, 34; 27, subscript; 27, 28; 27, 29; 28, identifier:pars; 29, binary_operator:+; 29, 30; 29, 33; 30, binary_operator:*; 30, 31; 30, 32; 31, identifier:i; 32, integer:2; 33, integer:1; 34, call; 34, 35; 34, 38; 35, attribute; 35, 36; 35, 37; 36, identifier:np; 37, identifier:sin; 38, argument_list; 38, 39; 39, binary_operator:*; 39, 40; 39, 50; 40, binary_operator:*; 40, 41; 40, 46; 41, binary_operator:*; 41, 42; 41, 43; 42, integer:2; 43, attribute; 43, 44; 43, 45; 44, identifier:np; 45, identifier:pi; 46, parenthesized_expression; 46, 47; 47, binary_operator:+; 47, 48; 47, 49; 48, identifier:i; 49, integer:1; 50, identifier:x; 51, line_continuation:\; 52, binary_operator:*; 52, 53; 52, 60; 53, subscript; 53, 54; 53, 55; 54, identifier:pars; 55, binary_operator:+; 55, 56; 55, 59; 56, binary_operator:*; 56, 57; 56, 58; 57, identifier:i; 58, integer:2; 59, integer:2; 60, call; 60, 61; 60, 64; 61, attribute; 61, 62; 61, 63; 62, identifier:np; 63, identifier:cos; 64, argument_list; 64, 65; 65, binary_operator:*; 65, 66; 65, 76; 66, binary_operator:*; 66, 67; 66, 72; 67, binary_operator:*; 67, 68; 67, 69; 68, integer:2; 69, attribute; 69, 70; 69, 71; 70, identifier:np; 71, identifier:pi; 72, parenthesized_expression; 72, 73; 73, binary_operator:+; 73, 74; 73, 75; 74, identifier:i; 75, integer:1; 76, identifier:x; 77, return_statement; 77, 78; 78, identifier:sum | def fourier_series(self, pars, x, order):
sum = pars[0]
for i in range(order):
sum += pars[i * 2 + 1] * np.sin(2 * np.pi * (i + 1) * x) \
+ pars[i * 2 + 2] * np.cos(2 * np.pi * (i + 1) * x)
return sum |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:slope_percentile; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:date; 6, identifier:mag; 7, block; 7, 8; 7, 27; 7, 46; 7, 57; 7, 63; 7, 69; 7, 75; 7, 85; 7, 95; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:date_diff; 11, binary_operator:-; 11, 12; 11, 17; 12, subscript; 12, 13; 12, 14; 13, identifier:date; 14, slice; 14, 15; 14, 16; 15, integer:1; 16, colon; 17, subscript; 17, 18; 17, 19; 18, identifier:date; 19, slice; 19, 20; 19, 21; 20, colon; 21, binary_operator:-; 21, 22; 21, 26; 22, call; 22, 23; 22, 24; 23, identifier:len; 24, argument_list; 24, 25; 25, identifier:date; 26, integer:1; 27, expression_statement; 27, 28; 28, assignment; 28, 29; 28, 30; 29, identifier:mag_diff; 30, binary_operator:-; 30, 31; 30, 36; 31, subscript; 31, 32; 31, 33; 32, identifier:mag; 33, slice; 33, 34; 33, 35; 34, integer:1; 35, colon; 36, subscript; 36, 37; 36, 38; 37, identifier:mag; 38, slice; 38, 39; 38, 40; 39, colon; 40, binary_operator:-; 40, 41; 40, 45; 41, call; 41, 42; 41, 43; 42, identifier:len; 43, argument_list; 43, 44; 44, identifier:mag; 45, integer:1; 46, expression_statement; 46, 47; 47, assignment; 47, 48; 47, 49; 48, identifier:index; 49, call; 49, 50; 49, 53; 50, attribute; 50, 51; 50, 52; 51, identifier:np; 52, identifier:where; 53, argument_list; 53, 54; 54, comparison_operator:!=; 54, 55; 54, 56; 55, identifier:mag_diff; 56, float:0.; 57, expression_statement; 57, 58; 58, assignment; 58, 59; 58, 60; 59, identifier:date_diff; 60, subscript; 60, 61; 60, 62; 61, identifier:date_diff; 62, identifier:index; 63, expression_statement; 63, 64; 64, assignment; 64, 65; 64, 66; 65, identifier:mag_diff; 66, subscript; 66, 67; 66, 68; 67, identifier:mag_diff; 68, identifier:index; 69, expression_statement; 69, 70; 70, assignment; 70, 71; 70, 72; 71, identifier:slope; 72, binary_operator:/; 72, 73; 72, 74; 73, identifier:date_diff; 74, identifier:mag_diff; 75, expression_statement; 75, 76; 76, assignment; 76, 77; 76, 78; 77, identifier:percentile_10; 78, call; 78, 79; 78, 82; 79, attribute; 79, 80; 79, 81; 80, identifier:np; 81, identifier:percentile; 82, argument_list; 82, 83; 82, 84; 83, identifier:slope; 84, float:10.; 85, expression_statement; 85, 86; 86, assignment; 86, 87; 86, 88; 87, identifier:percentile_90; 88, call; 88, 89; 88, 92; 89, attribute; 89, 90; 89, 91; 90, identifier:np; 91, identifier:percentile; 92, argument_list; 92, 93; 92, 94; 93, identifier:slope; 94, float:90.; 95, return_statement; 95, 96; 96, expression_list; 96, 97; 96, 98; 97, identifier:percentile_10; 98, identifier:percentile_90 | def slope_percentile(self, date, mag):
date_diff = date[1:] - date[:len(date) - 1]
mag_diff = mag[1:] - mag[:len(mag) - 1]
index = np.where(mag_diff != 0.)
date_diff = date_diff[index]
mag_diff = mag_diff[index]
slope = date_diff / mag_diff
percentile_10 = np.percentile(slope, 10.)
percentile_90 = np.percentile(slope, 90.)
return percentile_10, percentile_90 |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:number_aware_alphabetical_cmp; 3, parameters; 3, 4; 3, 5; 4, identifier:str1; 5, identifier:str2; 6, block; 6, 7; 6, 55; 6, 65; 6, 75; 6, 89; 6, 93; 6, 125; 6, 152; 7, function_definition; 7, 8; 7, 9; 7, 11; 8, function_name:flatten_tokens; 9, parameters; 9, 10; 10, identifier:tokens; 11, block; 11, 12; 11, 16; 11, 53; 12, expression_statement; 12, 13; 13, assignment; 13, 14; 13, 15; 14, identifier:l; 15, list:[]; 16, for_statement; 16, 17; 16, 18; 16, 19; 17, identifier:token; 18, identifier:tokens; 19, block; 19, 20; 20, if_statement; 20, 21; 20, 26; 20, 38; 21, call; 21, 22; 21, 23; 22, identifier:isinstance; 23, argument_list; 23, 24; 23, 25; 24, identifier:token; 25, identifier:str; 26, block; 26, 27; 27, for_statement; 27, 28; 27, 29; 27, 30; 28, identifier:char; 29, identifier:token; 30, block; 30, 31; 31, expression_statement; 31, 32; 32, call; 32, 33; 32, 36; 33, attribute; 33, 34; 33, 35; 34, identifier:l; 35, identifier:append; 36, argument_list; 36, 37; 37, identifier:char; 38, else_clause; 38, 39; 39, block; 39, 40; 39, 46; 40, assert_statement; 40, 41; 41, call; 41, 42; 41, 43; 42, identifier:isinstance; 43, argument_list; 43, 44; 43, 45; 44, identifier:token; 45, identifier:float; 46, expression_statement; 46, 47; 47, call; 47, 48; 47, 51; 48, attribute; 48, 49; 48, 50; 49, identifier:l; 50, identifier:append; 51, argument_list; 51, 52; 52, identifier:token; 53, return_statement; 53, 54; 54, identifier:l; 55, expression_statement; 55, 56; 56, assignment; 56, 57; 56, 58; 57, identifier:seq1; 58, call; 58, 59; 58, 60; 59, identifier:flatten_tokens; 60, argument_list; 60, 61; 61, call; 61, 62; 61, 63; 62, identifier:tokenize_by_number; 63, argument_list; 63, 64; 64, identifier:str1; 65, expression_statement; 65, 66; 66, assignment; 66, 67; 66, 68; 67, identifier:seq2; 68, call; 68, 69; 68, 70; 69, identifier:flatten_tokens; 70, argument_list; 70, 71; 71, call; 71, 72; 71, 73; 72, identifier:tokenize_by_number; 73, argument_list; 73, 74; 74, identifier:str2; 75, expression_statement; 75, 76; 76, assignment; 76, 77; 76, 78; 77, identifier:l; 78, call; 78, 79; 78, 80; 79, identifier:min; 80, argument_list; 80, 81; 80, 85; 81, call; 81, 82; 81, 83; 82, identifier:len; 83, argument_list; 83, 84; 84, identifier:seq1; 85, call; 85, 86; 85, 87; 86, identifier:len; 87, argument_list; 87, 88; 88, identifier:seq2; 89, expression_statement; 89, 90; 90, assignment; 90, 91; 90, 92; 91, identifier:i; 92, integer:0; 93, while_statement; 93, 94; 93, 97; 94, comparison_operator:<; 94, 95; 94, 96; 95, identifier:i; 96, identifier:l; 97, block; 97, 98; 97, 121; 98, if_statement; 98, 99; 98, 106; 98, 110; 99, comparison_operator:<; 99, 100; 99, 103; 100, subscript; 100, 101; 100, 102; 101, identifier:seq1; 102, identifier:i; 103, subscript; 103, 104; 103, 105; 104, identifier:seq2; 105, identifier:i; 106, block; 106, 107; 107, return_statement; 107, 108; 108, unary_operator:-; 108, 109; 109, integer:1; 110, elif_clause; 110, 111; 110, 118; 111, comparison_operator:>; 111, 112; 111, 115; 112, subscript; 112, 113; 112, 114; 113, identifier:seq1; 114, identifier:i; 115, subscript; 115, 116; 115, 117; 116, identifier:seq2; 117, identifier:i; 118, block; 118, 119; 119, return_statement; 119, 120; 120, integer:1; 121, expression_statement; 121, 122; 122, augmented_assignment:+=; 122, 123; 122, 124; 123, identifier:i; 124, integer:1; 125, if_statement; 125, 126; 125, 135; 125, 139; 126, comparison_operator:<; 126, 127; 126, 131; 127, call; 127, 128; 127, 129; 128, identifier:len; 129, argument_list; 129, 130; 130, identifier:seq1; 131, call; 131, 132; 131, 133; 132, identifier:len; 133, argument_list; 133, 134; 134, identifier:seq2; 135, block; 135, 136; 136, return_statement; 136, 137; 137, unary_operator:-; 137, 138; 138, integer:1; 139, elif_clause; 139, 140; 139, 149; 140, comparison_operator:>; 140, 141; 140, 145; 141, call; 141, 142; 141, 143; 142, identifier:len; 143, argument_list; 143, 144; 144, identifier:seq1; 145, call; 145, 146; 145, 147; 146, identifier:len; 147, argument_list; 147, 148; 148, identifier:seq2; 149, block; 149, 150; 150, return_statement; 150, 151; 151, integer:1; 152, return_statement; 152, 153; 153, integer:0 | def number_aware_alphabetical_cmp(str1, str2):
def flatten_tokens(tokens):
l = []
for token in tokens:
if isinstance(token, str):
for char in token:
l.append(char)
else:
assert isinstance(token, float)
l.append(token)
return l
seq1 = flatten_tokens(tokenize_by_number(str1))
seq2 = flatten_tokens(tokenize_by_number(str2))
l = min(len(seq1),len(seq2))
i = 0
while i < l:
if seq1[i] < seq2[i]:
return -1
elif seq1[i] > seq2[i]:
return 1
i += 1
if len(seq1) < len(seq2):
return -1
elif len(seq1) > len(seq2):
return 1
return 0 |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:sort_members; 3, parameters; 3, 4; 3, 5; 4, identifier:tup; 5, identifier:names; 6, block; 6, 7; 6, 30; 6, 53; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 12; 9, pattern_list; 9, 10; 9, 11; 10, identifier:scalars; 11, identifier:tuples; 12, call; 12, 13; 12, 14; 13, identifier:partition; 14, argument_list; 14, 15; 14, 29; 15, lambda; 15, 16; 15, 18; 16, lambda_parameters; 16, 17; 17, identifier:x; 18, not_operator; 18, 19; 19, call; 19, 20; 19, 21; 20, identifier:is_tuple_node; 21, argument_list; 21, 22; 22, attribute; 22, 23; 22, 28; 23, subscript; 23, 24; 23, 27; 24, attribute; 24, 25; 24, 26; 25, identifier:tup; 26, identifier:member; 27, identifier:x; 28, identifier:value; 29, identifier:names; 30, expression_statement; 30, 31; 31, assignment; 31, 32; 31, 35; 32, pattern_list; 32, 33; 32, 34; 33, identifier:unbound; 34, identifier:bound; 35, call; 35, 36; 35, 37; 36, identifier:partition; 37, argument_list; 37, 38; 37, 52; 38, lambda; 38, 39; 38, 41; 39, lambda_parameters; 39, 40; 40, identifier:x; 41, call; 41, 42; 41, 51; 42, attribute; 42, 43; 42, 50; 43, attribute; 43, 44; 43, 49; 44, subscript; 44, 45; 44, 48; 45, attribute; 45, 46; 45, 47; 46, identifier:tup; 47, identifier:member; 48, identifier:x; 49, identifier:value; 50, identifier:is_unbound; 51, argument_list; 52, identifier:scalars; 53, return_statement; 53, 54; 54, expression_list; 54, 55; 54, 64; 55, binary_operator:+; 55, 56; 55, 60; 56, call; 56, 57; 56, 58; 57, identifier:usorted; 58, argument_list; 58, 59; 59, identifier:unbound; 60, call; 60, 61; 60, 62; 61, identifier:usorted; 62, argument_list; 62, 63; 63, identifier:bound; 64, call; 64, 65; 64, 66; 65, identifier:usorted; 66, argument_list; 66, 67; 67, identifier:tuples | def sort_members(tup, names):
scalars, tuples = partition(lambda x: not is_tuple_node(tup.member[x].value), names)
unbound, bound = partition(lambda x: tup.member[x].value.is_unbound(), scalars)
return usorted(unbound) + usorted(bound), usorted(tuples) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:sort_schemas; 3, parameters; 3, 4; 4, identifier:schemas; 5, block; 5, 6; 5, 60; 6, function_definition; 6, 7; 6, 8; 6, 10; 7, function_name:keyfun; 8, parameters; 8, 9; 9, identifier:v; 10, block; 10, 11; 10, 24; 11, expression_statement; 11, 12; 12, assignment; 12, 13; 12, 14; 13, identifier:x; 14, call; 14, 15; 14, 23; 15, attribute; 15, 16; 15, 22; 16, call; 16, 17; 16, 20; 17, attribute; 17, 18; 17, 19; 18, identifier:SQL_SCHEMA_REGEXP; 19, identifier:match; 20, argument_list; 20, 21; 21, identifier:v; 22, identifier:groups; 23, argument_list; 24, return_statement; 24, 25; 25, tuple; 25, 26; 25, 32; 25, 35; 25, 46; 25, 54; 26, call; 26, 27; 26, 28; 27, identifier:int; 28, argument_list; 28, 29; 29, subscript; 29, 30; 29, 31; 30, identifier:x; 31, integer:0; 32, subscript; 32, 33; 32, 34; 33, identifier:x; 34, integer:1; 35, conditional_expression:if; 35, 36; 35, 42; 35, 45; 36, call; 36, 37; 36, 38; 37, identifier:int; 38, argument_list; 38, 39; 39, subscript; 39, 40; 39, 41; 40, identifier:x; 41, integer:2; 42, subscript; 42, 43; 42, 44; 43, identifier:x; 44, integer:2; 45, None; 46, conditional_expression:if; 46, 47; 46, 50; 46, 53; 47, subscript; 47, 48; 47, 49; 48, identifier:x; 49, integer:3; 50, subscript; 50, 51; 50, 52; 51, identifier:x; 52, integer:3; 53, string:'zzz'; 54, call; 54, 55; 54, 56; 55, identifier:int; 56, argument_list; 56, 57; 57, subscript; 57, 58; 57, 59; 58, identifier:x; 59, integer:4; 60, return_statement; 60, 61; 61, call; 61, 62; 61, 63; 62, identifier:sorted; 63, argument_list; 63, 64; 63, 65; 64, identifier:schemas; 65, keyword_argument; 65, 66; 65, 67; 66, identifier:key; 67, identifier:keyfun | def sort_schemas(schemas):
def keyfun(v):
x = SQL_SCHEMA_REGEXP.match(v).groups()
return (int(x[0]), x[1], int(x[2]) if x[2] else None,
x[3] if x[3] else 'zzz', int(x[4]))
return sorted(schemas, key=keyfun) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:sort_nodes; 3, parameters; 3, 4; 3, 5; 4, identifier:dom; 5, identifier:cmp_func; 6, block; 6, 7; 6, 13; 7, expression_statement; 7, 8; 8, call; 8, 9; 8, 12; 9, attribute; 9, 10; 9, 11; 10, identifier:dom; 11, identifier:normalize; 12, argument_list; 13, for_statement; 13, 14; 13, 15; 13, 25; 14, identifier:node; 15, call; 15, 16; 15, 17; 16, identifier:list; 17, argument_list; 17, 18; 18, call; 18, 19; 18, 20; 19, identifier:walk_dom; 20, argument_list; 20, 21; 20, 22; 21, identifier:dom; 22, keyword_argument; 22, 23; 22, 24; 23, identifier:elements_only; 24, True; 25, block; 25, 26; 25, 32; 26, expression_statement; 26, 27; 27, assignment; 27, 28; 27, 29; 28, identifier:prev_sib; 29, attribute; 29, 30; 29, 31; 30, identifier:node; 31, identifier:previousSibling; 32, while_statement; 32, 33; 32, 42; 33, boolean_operator:and; 33, 34; 33, 35; 34, identifier:prev_sib; 35, comparison_operator:==; 35, 36; 35, 41; 36, call; 36, 37; 36, 38; 37, identifier:cmp_func; 38, argument_list; 38, 39; 38, 40; 39, identifier:prev_sib; 40, identifier:node; 41, integer:1; 42, block; 42, 43; 42, 53; 43, expression_statement; 43, 44; 44, call; 44, 45; 44, 50; 45, attribute; 45, 46; 45, 49; 46, attribute; 46, 47; 46, 48; 47, identifier:node; 48, identifier:parentNode; 49, identifier:insertBefore; 50, argument_list; 50, 51; 50, 52; 51, identifier:node; 52, identifier:prev_sib; 53, expression_statement; 53, 54; 54, assignment; 54, 55; 54, 56; 55, identifier:prev_sib; 56, attribute; 56, 57; 56, 58; 57, identifier:node; 58, identifier:previousSibling | def sort_nodes(dom, cmp_func):
dom.normalize()
for node in list(walk_dom(dom, elements_only=True)):
prev_sib = node.previousSibling
while prev_sib and cmp_func(prev_sib, node) == 1:
node.parentNode.insertBefore(node, prev_sib)
prev_sib = node.previousSibling |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 1, 7; 2, function_name:currentdir; 3, parameters; 3, 4; 4, identifier:self; 5, type; 5, 6; 6, identifier:str; 7, block; 7, 8; 7, 99; 8, if_statement; 8, 9; 8, 14; 9, comparison_operator:is; 9, 10; 9, 13; 10, attribute; 10, 11; 10, 12; 11, identifier:self; 12, identifier:_currentdir; 13, None; 14, block; 14, 15; 14, 23; 15, expression_statement; 15, 16; 16, assignment; 16, 17; 16, 18; 17, identifier:directories; 18, attribute; 18, 19; 18, 22; 19, attribute; 19, 20; 19, 21; 20, identifier:self; 21, identifier:availabledirs; 22, identifier:folders; 23, if_statement; 23, 24; 23, 30; 23, 39; 23, 54; 24, comparison_operator:==; 24, 25; 24, 29; 25, call; 25, 26; 25, 27; 26, identifier:len; 27, argument_list; 27, 28; 28, identifier:directories; 29, integer:1; 30, block; 30, 31; 31, expression_statement; 31, 32; 32, assignment; 32, 33; 32, 36; 33, attribute; 33, 34; 33, 35; 34, identifier:self; 35, identifier:currentdir; 36, subscript; 36, 37; 36, 38; 37, identifier:directories; 38, integer:0; 39, elif_clause; 39, 40; 39, 45; 40, comparison_operator:in; 40, 41; 40, 44; 41, attribute; 41, 42; 41, 43; 42, identifier:self; 43, identifier:DEFAULTDIR; 44, identifier:directories; 45, block; 45, 46; 46, expression_statement; 46, 47; 47, assignment; 47, 48; 47, 51; 48, attribute; 48, 49; 48, 50; 49, identifier:self; 50, identifier:currentdir; 51, attribute; 51, 52; 51, 53; 52, identifier:self; 53, identifier:DEFAULTDIR; 54, else_clause; 54, 55; 55, block; 55, 56; 55, 65; 55, 76; 55, 91; 56, expression_statement; 56, 57; 57, assignment; 57, 58; 57, 59; 58, identifier:prefix; 59, parenthesized_expression; 59, 60; 60, concatenated_string; 60, 61; 60, 62; 60, 63; 60, 64; 61, string:f'The current working directory of the '; 62, string:f'{objecttools.classname(self)} object '; 63, string:f'has not been defined manually and cannot '; 64, string:f'be determined automatically:'; 65, if_statement; 65, 66; 65, 68; 66, not_operator; 66, 67; 67, identifier:directories; 68, block; 68, 69; 69, raise_statement; 69, 70; 70, call; 70, 71; 70, 72; 71, identifier:RuntimeError; 72, argument_list; 72, 73; 73, concatenated_string; 73, 74; 73, 75; 74, string:f'{prefix} `{objecttools.repr_(self.basepath)}` '; 75, string:f'does not contain any available directories.'; 76, if_statement; 76, 77; 76, 82; 77, comparison_operator:is; 77, 78; 77, 81; 78, attribute; 78, 79; 78, 80; 79, identifier:self; 80, identifier:DEFAULTDIR; 81, None; 82, block; 82, 83; 83, raise_statement; 83, 84; 84, call; 84, 85; 84, 86; 85, identifier:RuntimeError; 86, argument_list; 86, 87; 87, concatenated_string; 87, 88; 87, 89; 87, 90; 88, string:f'{prefix} `{objecttools.repr_(self.basepath)}` '; 89, string:f'does contain multiple available directories '; 90, string:f'({objecttools.enumeration(directories)}).'; 91, raise_statement; 91, 92; 92, call; 92, 93; 92, 94; 93, identifier:RuntimeError; 94, argument_list; 94, 95; 95, concatenated_string; 95, 96; 95, 97; 95, 98; 96, string:f'{prefix} The default directory ({self.DEFAULTDIR}) '; 97, string:f'is not among the available directories '; 98, string:f'({objecttools.enumeration(directories)}).'; 99, return_statement; 99, 100; 100, attribute; 100, 101; 100, 102; 101, identifier:self; 102, identifier:_currentdir | def currentdir(self) -> str:
if self._currentdir is None:
directories = self.availabledirs.folders
if len(directories) == 1:
self.currentdir = directories[0]
elif self.DEFAULTDIR in directories:
self.currentdir = self.DEFAULTDIR
else:
prefix = (f'The current working directory of the '
f'{objecttools.classname(self)} object '
f'has not been defined manually and cannot '
f'be determined automatically:')
if not directories:
raise RuntimeError(
f'{prefix} `{objecttools.repr_(self.basepath)}` '
f'does not contain any available directories.')
if self.DEFAULTDIR is None:
raise RuntimeError(
f'{prefix} `{objecttools.repr_(self.basepath)}` '
f'does contain multiple available directories '
f'({objecttools.enumeration(directories)}).')
raise RuntimeError(
f'{prefix} The default directory ({self.DEFAULTDIR}) '
f'is not among the available directories '
f'({objecttools.enumeration(directories)}).')
return self._currentdir |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 1, 7; 2, function_name:zip_currentdir; 3, parameters; 3, 4; 4, identifier:self; 5, type; 5, 6; 6, None; 7, block; 7, 8; 7, 48; 8, with_statement; 8, 9; 8, 21; 9, with_clause; 9, 10; 10, with_item; 10, 11; 11, as_pattern; 11, 12; 11, 19; 12, call; 12, 13; 12, 16; 13, attribute; 13, 14; 13, 15; 14, identifier:zipfile; 15, identifier:ZipFile; 16, argument_list; 16, 17; 16, 18; 17, string:f'{self.currentpath}.zip'; 18, string:'w'; 19, as_pattern_target; 19, 20; 20, identifier:zipfile_; 21, block; 21, 22; 22, for_statement; 22, 23; 22, 26; 22, 35; 23, pattern_list; 23, 24; 23, 25; 24, identifier:filepath; 25, identifier:filename; 26, call; 26, 27; 26, 28; 27, identifier:zip; 28, argument_list; 28, 29; 28, 32; 29, attribute; 29, 30; 29, 31; 30, identifier:self; 31, identifier:filepaths; 32, attribute; 32, 33; 32, 34; 33, identifier:self; 34, identifier:filenames; 35, block; 35, 36; 36, expression_statement; 36, 37; 37, call; 37, 38; 37, 41; 38, attribute; 38, 39; 38, 40; 39, identifier:zipfile_; 40, identifier:write; 41, argument_list; 41, 42; 41, 45; 42, keyword_argument; 42, 43; 42, 44; 43, identifier:filename; 44, identifier:filepath; 45, keyword_argument; 45, 46; 45, 47; 46, identifier:arcname; 47, identifier:filename; 48, delete_statement; 48, 49; 49, attribute; 49, 50; 49, 51; 50, identifier:self; 51, identifier:currentdir | def zip_currentdir(self) -> None:
with zipfile.ZipFile(f'{self.currentpath}.zip', 'w') as zipfile_:
for filepath, filename in zip(self.filepaths, self.filenames):
zipfile_.write(filename=filepath, arcname=filename)
del self.currentdir |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 1, 11; 2, function_name:keywords; 3, parameters; 3, 4; 4, identifier:self; 5, type; 5, 6; 6, generic_type; 6, 7; 6, 8; 7, identifier:Set; 8, type_parameter; 8, 9; 9, type; 9, 10; 10, identifier:str; 11, block; 11, 12; 12, return_statement; 12, 13; 13, call; 13, 14; 13, 15; 14, identifier:set; 15, generator_expression; 15, 16; 15, 17; 15, 20; 15, 25; 16, identifier:keyword; 17, for_in_clause; 17, 18; 17, 19; 18, identifier:device; 19, identifier:self; 20, for_in_clause; 20, 21; 20, 22; 21, identifier:keyword; 22, attribute; 22, 23; 22, 24; 23, identifier:device; 24, identifier:keywords; 25, if_clause; 25, 26; 26, comparison_operator:not; 26, 27; 26, 28; 27, identifier:keyword; 28, attribute; 28, 29; 28, 30; 29, identifier:self; 30, identifier:_shadowed_keywords | def keywords(self) -> Set[str]:
return set(keyword for device in self
for keyword in device.keywords if
keyword not in self._shadowed_keywords) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 1, 11; 2, function_name:variables; 3, parameters; 3, 4; 4, identifier:self; 5, type; 5, 6; 6, generic_type; 6, 7; 6, 8; 7, identifier:Set; 8, type_parameter; 8, 9; 9, type; 9, 10; 10, identifier:str; 11, block; 11, 12; 11, 24; 11, 39; 12, expression_statement; 12, 13; 13, assignment; 13, 14; 13, 15; 13, 21; 14, identifier:variables; 15, type; 15, 16; 16, generic_type; 16, 17; 16, 18; 17, identifier:Set; 18, type_parameter; 18, 19; 19, type; 19, 20; 20, identifier:str; 21, call; 21, 22; 21, 23; 22, identifier:set; 23, argument_list; 24, for_statement; 24, 25; 24, 26; 24, 29; 25, identifier:connection; 26, attribute; 26, 27; 26, 28; 27, identifier:self; 28, identifier:__connections; 29, block; 29, 30; 30, expression_statement; 30, 31; 31, call; 31, 32; 31, 35; 32, attribute; 32, 33; 32, 34; 33, identifier:variables; 34, identifier:update; 35, argument_list; 35, 36; 36, attribute; 36, 37; 36, 38; 37, identifier:connection; 38, identifier:variables; 39, return_statement; 39, 40; 40, identifier:variables | def variables(self) -> Set[str]:
variables: Set[str] = set()
for connection in self.__connections:
variables.update(connection.variables)
return variables |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 1, 23; 2, function_name:model2subs2seqs; 3, parameters; 3, 4; 4, identifier:self; 5, type; 5, 6; 6, generic_type; 6, 7; 6, 8; 7, identifier:Dict; 8, type_parameter; 8, 9; 8, 11; 9, type; 9, 10; 10, identifier:str; 11, type; 11, 12; 12, generic_type; 12, 13; 12, 14; 13, identifier:Dict; 14, type_parameter; 14, 15; 14, 17; 15, type; 15, 16; 16, identifier:str; 17, type; 17, 18; 18, generic_type; 18, 19; 18, 20; 19, identifier:List; 20, type_parameter; 20, 21; 21, type; 21, 22; 22, identifier:str; 23, block; 23, 24; 23, 39; 23, 100; 24, expression_statement; 24, 25; 25, assignment; 25, 26; 25, 27; 26, identifier:model2subs2seqs; 27, call; 27, 28; 27, 31; 28, attribute; 28, 29; 28, 30; 29, identifier:collections; 30, identifier:defaultdict; 31, argument_list; 31, 32; 32, lambda; 32, 33; 33, call; 33, 34; 33, 37; 34, attribute; 34, 35; 34, 36; 35, identifier:collections; 36, identifier:defaultdict; 37, argument_list; 37, 38; 38, identifier:list; 39, for_statement; 39, 40; 39, 41; 39, 47; 40, identifier:model; 41, call; 41, 42; 41, 45; 42, attribute; 42, 43; 42, 44; 43, identifier:self; 44, identifier:find; 45, argument_list; 45, 46; 46, string:'sequences'; 47, block; 47, 48; 47, 57; 47, 63; 48, expression_statement; 48, 49; 49, assignment; 49, 50; 49, 51; 50, identifier:model_name; 51, call; 51, 52; 51, 53; 52, identifier:strip; 53, argument_list; 53, 54; 54, attribute; 54, 55; 54, 56; 55, identifier:model; 56, identifier:tag; 57, if_statement; 57, 58; 57, 61; 58, comparison_operator:==; 58, 59; 58, 60; 59, identifier:model_name; 60, string:'node'; 61, block; 61, 62; 62, continue_statement; 63, for_statement; 63, 64; 63, 65; 63, 66; 64, identifier:group; 65, identifier:model; 66, block; 66, 67; 66, 76; 67, expression_statement; 67, 68; 68, assignment; 68, 69; 68, 70; 69, identifier:group_name; 70, call; 70, 71; 70, 72; 71, identifier:strip; 72, argument_list; 72, 73; 73, attribute; 73, 74; 73, 75; 74, identifier:group; 75, identifier:tag; 76, for_statement; 76, 77; 76, 78; 76, 79; 77, identifier:sequence; 78, identifier:group; 79, block; 79, 80; 79, 89; 80, expression_statement; 80, 81; 81, assignment; 81, 82; 81, 83; 82, identifier:seq_name; 83, call; 83, 84; 83, 85; 84, identifier:strip; 85, argument_list; 85, 86; 86, attribute; 86, 87; 86, 88; 87, identifier:sequence; 88, identifier:tag; 89, expression_statement; 89, 90; 90, call; 90, 91; 90, 98; 91, attribute; 91, 92; 91, 97; 92, subscript; 92, 93; 92, 96; 93, subscript; 93, 94; 93, 95; 94, identifier:model2subs2seqs; 95, identifier:model_name; 96, identifier:group_name; 97, identifier:append; 98, argument_list; 98, 99; 99, identifier:seq_name; 100, return_statement; 100, 101; 101, identifier:model2subs2seqs | def model2subs2seqs(self) -> Dict[str, Dict[str, List[str]]]:
model2subs2seqs = collections.defaultdict(
lambda: collections.defaultdict(list))
for model in self.find('sequences'):
model_name = strip(model.tag)
if model_name == 'node':
continue
for group in model:
group_name = strip(group.tag)
for sequence in group:
seq_name = strip(sequence.tag)
model2subs2seqs[model_name][group_name].append(seq_name)
return model2subs2seqs |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 1, 17; 2, function_name:subs2seqs; 3, parameters; 3, 4; 4, identifier:self; 5, type; 5, 6; 6, generic_type; 6, 7; 6, 8; 7, identifier:Dict; 8, type_parameter; 8, 9; 8, 11; 9, type; 9, 10; 10, identifier:str; 11, type; 11, 12; 12, generic_type; 12, 13; 12, 14; 13, identifier:List; 14, type_parameter; 14, 15; 15, type; 15, 16; 16, identifier:str; 17, block; 17, 18; 17, 27; 17, 40; 17, 63; 18, expression_statement; 18, 19; 19, assignment; 19, 20; 19, 21; 20, identifier:subs2seqs; 21, call; 21, 22; 21, 25; 22, attribute; 22, 23; 22, 24; 23, identifier:collections; 24, identifier:defaultdict; 25, argument_list; 25, 26; 26, identifier:list; 27, expression_statement; 27, 28; 28, assignment; 28, 29; 28, 30; 29, identifier:nodes; 30, call; 30, 31; 30, 32; 31, identifier:find; 32, argument_list; 32, 33; 32, 39; 33, call; 33, 34; 33, 37; 34, attribute; 34, 35; 34, 36; 35, identifier:self; 36, identifier:find; 37, argument_list; 37, 38; 38, string:'sequences'; 39, string:'node'; 40, if_statement; 40, 41; 40, 44; 41, comparison_operator:is; 41, 42; 41, 43; 42, identifier:nodes; 43, None; 44, block; 44, 45; 45, for_statement; 45, 46; 45, 47; 45, 48; 46, identifier:seq; 47, identifier:nodes; 48, block; 48, 49; 49, expression_statement; 49, 50; 50, call; 50, 51; 50, 56; 51, attribute; 51, 52; 51, 55; 52, subscript; 52, 53; 52, 54; 53, identifier:subs2seqs; 54, string:'node'; 55, identifier:append; 56, argument_list; 56, 57; 57, call; 57, 58; 57, 59; 58, identifier:strip; 59, argument_list; 59, 60; 60, attribute; 60, 61; 60, 62; 61, identifier:seq; 62, identifier:tag; 63, return_statement; 63, 64; 64, identifier:subs2seqs | def subs2seqs(self) -> Dict[str, List[str]]:
subs2seqs = collections.defaultdict(list)
nodes = find(self.find('sequences'), 'node')
if nodes is not None:
for seq in nodes:
subs2seqs['node'].append(strip(seq.tag))
return subs2seqs |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 4; 1, 10; 2, function_name:get_modelnames; 3, parameters; 4, type; 4, 5; 5, generic_type; 5, 6; 5, 7; 6, identifier:List; 7, type_parameter; 7, 8; 8, type; 8, 9; 9, identifier:str; 10, block; 10, 11; 11, return_statement; 11, 12; 12, call; 12, 13; 12, 14; 13, identifier:sorted; 14, generator_expression; 14, 15; 14, 26; 14, 38; 15, call; 15, 16; 15, 17; 16, identifier:str; 17, argument_list; 17, 18; 18, subscript; 18, 19; 18, 25; 19, call; 19, 20; 19, 23; 20, attribute; 20, 21; 20, 22; 21, identifier:fn; 22, identifier:split; 23, argument_list; 23, 24; 24, string:'.'; 25, integer:0; 26, for_in_clause; 26, 27; 26, 28; 27, identifier:fn; 28, call; 28, 29; 28, 32; 29, attribute; 29, 30; 29, 31; 30, identifier:os; 31, identifier:listdir; 32, argument_list; 32, 33; 33, subscript; 33, 34; 33, 37; 34, attribute; 34, 35; 34, 36; 35, identifier:models; 36, identifier:__path__; 37, integer:0; 38, if_clause; 38, 39; 39, parenthesized_expression; 39, 40; 40, boolean_operator:and; 40, 41; 40, 47; 41, call; 41, 42; 41, 45; 42, attribute; 42, 43; 42, 44; 43, identifier:fn; 44, identifier:endswith; 45, argument_list; 45, 46; 46, string:'.py'; 47, parenthesized_expression; 47, 48; 48, comparison_operator:!=; 48, 49; 48, 50; 49, identifier:fn; 50, string:'__init__.py' | def get_modelnames() -> List[str]:
return sorted(str(fn.split('.')[0])
for fn in os.listdir(models.__path__[0])
if (fn.endswith('.py') and (fn != '__init__.py'))) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 1, 15; 2, function_name:toys; 3, parameters; 3, 4; 4, identifier:self; 5, type; 5, 6; 6, generic_type; 6, 7; 6, 8; 7, identifier:Tuple; 8, type_parameter; 8, 9; 8, 13; 9, type; 9, 10; 10, attribute; 10, 11; 10, 12; 11, identifier:timetools; 12, identifier:TOY; 13, type; 13, 14; 14, ellipsis:...; 15, block; 15, 16; 16, return_statement; 16, 17; 17, call; 17, 18; 17, 19; 18, identifier:tuple; 19, generator_expression; 19, 20; 19, 21; 20, identifier:toy; 21, for_in_clause; 21, 22; 21, 25; 22, tuple_pattern; 22, 23; 22, 24; 23, identifier:toy; 24, identifier:_; 25, identifier:self | def toys(self) -> Tuple[timetools.TOY, ...]:
return tuple(toy for (toy, _) in self) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 1, 8; 2, function_name:collect_variables; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:selections; 6, type; 6, 7; 7, None; 8, block; 8, 9; 9, expression_statement; 9, 10; 10, call; 10, 11; 10, 14; 11, attribute; 11, 12; 11, 13; 12, identifier:self; 13, identifier:insert_variables; 14, argument_list; 14, 15; 14, 18; 14, 21; 15, attribute; 15, 16; 15, 17; 16, identifier:self; 17, identifier:device2target; 18, attribute; 18, 19; 18, 20; 19, identifier:self; 20, identifier:targetspecs; 21, identifier:selections | def collect_variables(self, selections) -> None:
self.insert_variables(self.device2target, self.targetspecs, selections) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 1, 8; 2, function_name:collect_variables; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:selections; 6, type; 6, 7; 7, None; 8, block; 8, 9; 8, 18; 9, expression_statement; 9, 10; 10, call; 10, 11; 10, 16; 11, attribute; 11, 12; 11, 15; 12, call; 12, 13; 12, 14; 13, identifier:super; 14, argument_list; 15, identifier:collect_variables; 16, argument_list; 16, 17; 17, identifier:selections; 18, expression_statement; 18, 19; 19, call; 19, 20; 19, 23; 20, attribute; 20, 21; 20, 22; 21, identifier:self; 22, identifier:insert_variables; 23, argument_list; 23, 24; 23, 27; 23, 30; 24, attribute; 24, 25; 24, 26; 25, identifier:self; 26, identifier:device2base; 27, attribute; 27, 28; 27, 29; 28, identifier:self; 29, identifier:basespecs; 30, identifier:selections | def collect_variables(self, selections) -> None:
super().collect_variables(selections)
self.insert_variables(self.device2base, self.basespecs, selections) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:save_controls; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:parameterstep; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:simulationstep; 10, None; 11, default_parameter; 11, 12; 11, 13; 12, identifier:auxfiler; 13, None; 14, block; 14, 15; 15, expression_statement; 15, 16; 16, call; 16, 17; 16, 22; 17, attribute; 17, 18; 17, 21; 18, attribute; 18, 19; 18, 20; 19, identifier:self; 20, identifier:elements; 21, identifier:save_controls; 22, argument_list; 22, 23; 22, 26; 22, 29; 23, keyword_argument; 23, 24; 23, 25; 24, identifier:parameterstep; 25, identifier:parameterstep; 26, keyword_argument; 26, 27; 26, 28; 27, identifier:simulationstep; 28, identifier:simulationstep; 29, keyword_argument; 29, 30; 29, 31; 30, identifier:auxfiler; 31, identifier:auxfiler | def save_controls(self, parameterstep=None, simulationstep=None,
auxfiler=None):
self.elements.save_controls(parameterstep=parameterstep,
simulationstep=simulationstep,
auxfiler=auxfiler) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:variables; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 13; 5, 28; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:variables; 9, call; 9, 10; 9, 11; 10, identifier:set; 11, argument_list; 11, 12; 12, list:[]; 13, for_statement; 13, 14; 13, 15; 13, 18; 14, identifier:node; 15, attribute; 15, 16; 15, 17; 16, identifier:self; 17, identifier:nodes; 18, block; 18, 19; 19, expression_statement; 19, 20; 20, call; 20, 21; 20, 24; 21, attribute; 21, 22; 21, 23; 22, identifier:variables; 23, identifier:add; 24, argument_list; 24, 25; 25, attribute; 25, 26; 25, 27; 26, identifier:node; 27, identifier:variable; 28, return_statement; 28, 29; 29, call; 29, 30; 29, 31; 30, identifier:sorted; 31, argument_list; 31, 32; 32, identifier:variables | def variables(self):
variables = set([])
for node in self.nodes:
variables.add(node.variable)
return sorted(variables) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 1, 15; 2, function_name:sort_timeplaceentries; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:timeentry; 6, identifier:placeentry; 7, type; 7, 8; 8, generic_type; 8, 9; 8, 10; 9, identifier:Tuple; 10, type_parameter; 10, 11; 10, 13; 11, type; 11, 12; 12, identifier:Any; 13, type; 13, 14; 14, identifier:Any; 15, block; 15, 16; 15, 25; 16, if_statement; 16, 17; 16, 20; 17, attribute; 17, 18; 17, 19; 18, identifier:self; 19, identifier:_timeaxis; 20, block; 20, 21; 21, return_statement; 21, 22; 22, expression_list; 22, 23; 22, 24; 23, identifier:placeentry; 24, identifier:timeentry; 25, return_statement; 25, 26; 26, expression_list; 26, 27; 26, 28; 27, identifier:timeentry; 28, identifier:placeentry | def sort_timeplaceentries(self, timeentry, placeentry) -> Tuple[Any, Any]:
if self._timeaxis:
return placeentry, timeentry
return timeentry, placeentry |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 4; 1, 16; 2, function_name:prepare_io_example_1; 3, parameters; 4, type; 4, 5; 5, generic_type; 5, 6; 5, 7; 6, identifier:Tuple; 7, type_parameter; 7, 8; 7, 12; 8, type; 8, 9; 9, attribute; 9, 10; 9, 11; 10, identifier:devicetools; 11, identifier:Nodes; 12, type; 12, 13; 13, attribute; 13, 14; 13, 15; 14, identifier:devicetools; 15, identifier:Elements; 16, block; 16, 17; 16, 22; 16, 28; 16, 35; 16, 45; 16, 92; 16, 103; 16, 116; 16, 123; 16, 133; 16, 141; 16, 151; 16, 161; 16, 171; 16, 180; 16, 188; 16, 197; 16, 206; 16, 215; 16, 222; 16, 268; 16, 306; 16, 367; 16, 370; 16, 374; 16, 418; 16, 434; 17, import_from_statement; 17, 18; 17, 20; 18, dotted_name; 18, 19; 19, identifier:hydpy; 20, dotted_name; 20, 21; 21, identifier:TestIO; 22, expression_statement; 22, 23; 23, call; 23, 24; 23, 27; 24, attribute; 24, 25; 24, 26; 25, identifier:TestIO; 26, identifier:clear; 27, argument_list; 28, import_from_statement; 28, 29; 28, 33; 29, dotted_name; 29, 30; 29, 31; 29, 32; 30, identifier:hydpy; 31, identifier:core; 32, identifier:filetools; 33, dotted_name; 33, 34; 34, identifier:SequenceManager; 35, expression_statement; 35, 36; 36, assignment; 36, 37; 36, 42; 37, attribute; 37, 38; 37, 41; 38, attribute; 38, 39; 38, 40; 39, identifier:hydpy; 40, identifier:pub; 41, identifier:sequencemanager; 42, call; 42, 43; 42, 44; 43, identifier:SequenceManager; 44, argument_list; 45, with_statement; 45, 46; 45, 51; 46, with_clause; 46, 47; 47, with_item; 47, 48; 48, call; 48, 49; 48, 50; 49, identifier:TestIO; 50, argument_list; 51, block; 51, 52; 51, 62; 51, 72; 51, 82; 52, expression_statement; 52, 53; 53, assignment; 53, 54; 53, 61; 54, attribute; 54, 55; 54, 60; 55, attribute; 55, 56; 55, 59; 56, attribute; 56, 57; 56, 58; 57, identifier:hydpy; 58, identifier:pub; 59, identifier:sequencemanager; 60, identifier:inputdirpath; 61, string:'inputpath'; 62, expression_statement; 62, 63; 63, assignment; 63, 64; 63, 71; 64, attribute; 64, 65; 64, 70; 65, attribute; 65, 66; 65, 69; 66, attribute; 66, 67; 66, 68; 67, identifier:hydpy; 68, identifier:pub; 69, identifier:sequencemanager; 70, identifier:fluxdirpath; 71, string:'outputpath'; 72, expression_statement; 72, 73; 73, assignment; 73, 74; 73, 81; 74, attribute; 74, 75; 74, 80; 75, attribute; 75, 76; 75, 79; 76, attribute; 76, 77; 76, 78; 77, identifier:hydpy; 78, identifier:pub; 79, identifier:sequencemanager; 80, identifier:statedirpath; 81, string:'outputpath'; 82, expression_statement; 82, 83; 83, assignment; 83, 84; 83, 91; 84, attribute; 84, 85; 84, 90; 85, attribute; 85, 86; 85, 89; 86, attribute; 86, 87; 86, 88; 87, identifier:hydpy; 88, identifier:pub; 89, identifier:sequencemanager; 90, identifier:nodedirpath; 91, string:'nodepath'; 92, expression_statement; 92, 93; 93, assignment; 93, 94; 93, 99; 94, attribute; 94, 95; 94, 98; 95, attribute; 95, 96; 95, 97; 96, identifier:hydpy; 97, identifier:pub; 98, identifier:timegrids; 99, expression_list; 99, 100; 99, 101; 99, 102; 100, string:'2000-01-01'; 101, string:'2000-01-05'; 102, string:'1d'; 103, import_from_statement; 103, 104; 103, 106; 103, 108; 103, 110; 103, 112; 103, 114; 104, dotted_name; 104, 105; 105, identifier:hydpy; 106, dotted_name; 106, 107; 107, identifier:Node; 108, dotted_name; 108, 109; 109, identifier:Nodes; 110, dotted_name; 110, 111; 111, identifier:Element; 112, dotted_name; 112, 113; 113, identifier:Elements; 114, dotted_name; 114, 115; 115, identifier:prepare_model; 116, expression_statement; 116, 117; 117, assignment; 117, 118; 117, 119; 118, identifier:node1; 119, call; 119, 120; 119, 121; 120, identifier:Node; 121, argument_list; 121, 122; 122, string:'node1'; 123, expression_statement; 123, 124; 124, assignment; 124, 125; 124, 126; 125, identifier:node2; 126, call; 126, 127; 126, 128; 127, identifier:Node; 128, argument_list; 128, 129; 128, 130; 129, string:'node2'; 130, keyword_argument; 130, 131; 130, 132; 131, identifier:variable; 132, string:'T'; 133, expression_statement; 133, 134; 134, assignment; 134, 135; 134, 136; 135, identifier:nodes; 136, call; 136, 137; 136, 138; 137, identifier:Nodes; 138, argument_list; 138, 139; 138, 140; 139, identifier:node1; 140, identifier:node2; 141, expression_statement; 141, 142; 142, assignment; 142, 143; 142, 144; 143, identifier:element1; 144, call; 144, 145; 144, 146; 145, identifier:Element; 146, argument_list; 146, 147; 146, 148; 147, string:'element1'; 148, keyword_argument; 148, 149; 148, 150; 149, identifier:outlets; 150, identifier:node1; 151, expression_statement; 151, 152; 152, assignment; 152, 153; 152, 154; 153, identifier:element2; 154, call; 154, 155; 154, 156; 155, identifier:Element; 156, argument_list; 156, 157; 156, 158; 157, string:'element2'; 158, keyword_argument; 158, 159; 158, 160; 159, identifier:outlets; 160, identifier:node1; 161, expression_statement; 161, 162; 162, assignment; 162, 163; 162, 164; 163, identifier:element3; 164, call; 164, 165; 164, 166; 165, identifier:Element; 166, argument_list; 166, 167; 166, 168; 167, string:'element3'; 168, keyword_argument; 168, 169; 168, 170; 169, identifier:outlets; 170, identifier:node1; 171, expression_statement; 171, 172; 172, assignment; 172, 173; 172, 174; 173, identifier:elements; 174, call; 174, 175; 174, 176; 175, identifier:Elements; 176, argument_list; 176, 177; 176, 178; 176, 179; 177, identifier:element1; 178, identifier:element2; 179, identifier:element3; 180, import_from_statement; 180, 181; 180, 184; 180, 186; 181, dotted_name; 181, 182; 181, 183; 182, identifier:hydpy; 183, identifier:models; 184, dotted_name; 184, 185; 185, identifier:lland_v1; 186, dotted_name; 186, 187; 187, identifier:lland_v2; 188, expression_statement; 188, 189; 189, assignment; 189, 190; 189, 193; 190, attribute; 190, 191; 190, 192; 191, identifier:element1; 192, identifier:model; 193, call; 193, 194; 193, 195; 194, identifier:prepare_model; 195, argument_list; 195, 196; 196, identifier:lland_v1; 197, expression_statement; 197, 198; 198, assignment; 198, 199; 198, 202; 199, attribute; 199, 200; 199, 201; 200, identifier:element2; 201, identifier:model; 202, call; 202, 203; 202, 204; 203, identifier:prepare_model; 204, argument_list; 204, 205; 205, identifier:lland_v1; 206, expression_statement; 206, 207; 207, assignment; 207, 208; 207, 211; 208, attribute; 208, 209; 208, 210; 209, identifier:element3; 210, identifier:model; 211, call; 211, 212; 211, 213; 212, identifier:prepare_model; 213, argument_list; 213, 214; 214, identifier:lland_v2; 215, import_from_statement; 215, 216; 215, 220; 216, dotted_name; 216, 217; 216, 218; 216, 219; 217, identifier:hydpy; 218, identifier:models; 219, identifier:lland; 220, dotted_name; 220, 221; 221, identifier:ACKER; 222, for_statement; 222, 223; 222, 226; 222, 230; 223, pattern_list; 223, 224; 223, 225; 224, identifier:idx; 225, identifier:element; 226, call; 226, 227; 226, 228; 227, identifier:enumerate; 228, argument_list; 228, 229; 229, identifier:elements; 230, block; 230, 231; 230, 239; 230, 250; 230, 259; 231, expression_statement; 231, 232; 232, assignment; 232, 233; 232, 234; 233, identifier:parameters; 234, attribute; 234, 235; 234, 238; 235, attribute; 235, 236; 235, 237; 236, identifier:element; 237, identifier:model; 238, identifier:parameters; 239, expression_statement; 239, 240; 240, call; 240, 241; 240, 246; 241, attribute; 241, 242; 241, 245; 242, attribute; 242, 243; 242, 244; 243, identifier:parameters; 244, identifier:control; 245, identifier:nhru; 246, argument_list; 246, 247; 247, binary_operator:+; 247, 248; 247, 249; 248, identifier:idx; 249, integer:1; 250, expression_statement; 250, 251; 251, call; 251, 252; 251, 257; 252, attribute; 252, 253; 252, 256; 253, attribute; 253, 254; 253, 255; 254, identifier:parameters; 255, identifier:control; 256, identifier:lnk; 257, argument_list; 257, 258; 258, identifier:ACKER; 259, expression_statement; 259, 260; 260, call; 260, 261; 260, 266; 261, attribute; 261, 262; 261, 265; 262, attribute; 262, 263; 262, 264; 263, identifier:parameters; 264, identifier:derived; 265, identifier:absfhru; 266, argument_list; 266, 267; 267, float:10.0; 268, with_statement; 268, 269; 268, 281; 269, with_clause; 269, 270; 270, with_item; 270, 271; 271, call; 271, 272; 271, 279; 272, attribute; 272, 273; 272, 278; 273, attribute; 273, 274; 273, 277; 274, attribute; 274, 275; 274, 276; 275, identifier:hydpy; 276, identifier:pub; 277, identifier:options; 278, identifier:printprogress; 279, argument_list; 279, 280; 280, False; 281, block; 281, 282; 281, 288; 281, 294; 281, 300; 282, expression_statement; 282, 283; 283, call; 283, 284; 283, 287; 284, attribute; 284, 285; 284, 286; 285, identifier:nodes; 286, identifier:prepare_simseries; 287, argument_list; 288, expression_statement; 288, 289; 289, call; 289, 290; 289, 293; 290, attribute; 290, 291; 290, 292; 291, identifier:elements; 292, identifier:prepare_inputseries; 293, argument_list; 294, expression_statement; 294, 295; 295, call; 295, 296; 295, 299; 296, attribute; 296, 297; 296, 298; 297, identifier:elements; 298, identifier:prepare_fluxseries; 299, argument_list; 300, expression_statement; 300, 301; 301, call; 301, 302; 301, 305; 302, attribute; 302, 303; 302, 304; 303, identifier:elements; 304, identifier:prepare_stateseries; 305, argument_list; 306, function_definition; 306, 307; 306, 308; 306, 311; 307, function_name:init_values; 308, parameters; 308, 309; 308, 310; 309, identifier:seq; 310, identifier:value1_; 311, block; 311, 312; 311, 327; 311, 340; 311, 353; 311, 365; 312, expression_statement; 312, 313; 313, assignment; 313, 314; 313, 315; 314, identifier:value2_; 315, binary_operator:+; 315, 316; 315, 317; 316, identifier:value1_; 317, call; 317, 318; 317, 319; 318, identifier:len; 319, argument_list; 319, 320; 320, call; 320, 321; 320, 326; 321, attribute; 321, 322; 321, 325; 322, attribute; 322, 323; 322, 324; 323, identifier:seq; 324, identifier:series; 325, identifier:flatten; 326, argument_list; 327, expression_statement; 327, 328; 328, assignment; 328, 329; 328, 330; 329, identifier:values_; 330, call; 330, 331; 330, 334; 331, attribute; 331, 332; 331, 333; 332, identifier:numpy; 333, identifier:arange; 334, argument_list; 334, 335; 334, 336; 334, 337; 335, identifier:value1_; 336, identifier:value2_; 337, keyword_argument; 337, 338; 337, 339; 338, identifier:dtype; 339, identifier:float; 340, expression_statement; 340, 341; 341, assignment; 341, 342; 341, 345; 342, attribute; 342, 343; 342, 344; 343, identifier:seq; 344, identifier:testarray; 345, call; 345, 346; 345, 349; 346, attribute; 346, 347; 346, 348; 347, identifier:values_; 348, identifier:reshape; 349, argument_list; 349, 350; 350, attribute; 350, 351; 350, 352; 351, identifier:seq; 352, identifier:seriesshape; 353, expression_statement; 353, 354; 354, assignment; 354, 355; 354, 358; 355, attribute; 355, 356; 355, 357; 356, identifier:seq; 357, identifier:series; 358, call; 358, 359; 358, 364; 359, attribute; 359, 360; 359, 363; 360, attribute; 360, 361; 360, 362; 361, identifier:seq; 362, identifier:testarray; 363, identifier:copy; 364, argument_list; 365, return_statement; 365, 366; 366, identifier:value2_; 367, import_statement; 367, 368; 368, dotted_name; 368, 369; 369, identifier:numpy; 370, expression_statement; 370, 371; 371, assignment; 371, 372; 371, 373; 372, identifier:value1; 373, integer:0; 374, for_statement; 374, 375; 374, 378; 374, 389; 375, pattern_list; 375, 376; 375, 377; 376, identifier:subname; 377, identifier:seqname; 378, call; 378, 379; 378, 380; 379, identifier:zip; 380, argument_list; 380, 381; 380, 385; 381, list:['inputs', 'fluxes', 'states']; 381, 382; 381, 383; 381, 384; 382, string:'inputs'; 383, string:'fluxes'; 384, string:'states'; 385, list:['nied', 'nkor', 'bowa']; 385, 386; 385, 387; 385, 388; 386, string:'nied'; 387, string:'nkor'; 388, string:'bowa'; 389, block; 389, 390; 390, for_statement; 390, 391; 390, 392; 390, 393; 391, identifier:element; 392, identifier:elements; 393, block; 393, 394; 393, 406; 394, expression_statement; 394, 395; 395, assignment; 395, 396; 395, 397; 396, identifier:subseqs; 397, call; 397, 398; 397, 399; 398, identifier:getattr; 399, argument_list; 399, 400; 399, 405; 400, attribute; 400, 401; 400, 404; 401, attribute; 401, 402; 401, 403; 402, identifier:element; 403, identifier:model; 404, identifier:sequences; 405, identifier:subname; 406, expression_statement; 406, 407; 407, assignment; 407, 408; 407, 409; 408, identifier:value1; 409, call; 409, 410; 409, 411; 410, identifier:init_values; 411, argument_list; 411, 412; 411, 417; 412, call; 412, 413; 412, 414; 413, identifier:getattr; 414, argument_list; 414, 415; 414, 416; 415, identifier:subseqs; 416, identifier:seqname; 417, identifier:value1; 418, for_statement; 418, 419; 418, 420; 418, 421; 419, identifier:node; 420, identifier:nodes; 421, block; 421, 422; 422, expression_statement; 422, 423; 423, assignment; 423, 424; 423, 425; 424, identifier:value1; 425, call; 425, 426; 425, 427; 426, identifier:init_values; 427, argument_list; 427, 428; 427, 433; 428, attribute; 428, 429; 428, 432; 429, attribute; 429, 430; 429, 431; 430, identifier:node; 431, identifier:sequences; 432, identifier:sim; 433, identifier:value1; 434, return_statement; 434, 435; 435, expression_list; 435, 436; 435, 437; 436, identifier:nodes; 437, identifier:elements | def prepare_io_example_1() -> Tuple[devicetools.Nodes, devicetools.Elements]:
from hydpy import TestIO
TestIO.clear()
from hydpy.core.filetools import SequenceManager
hydpy.pub.sequencemanager = SequenceManager()
with TestIO():
hydpy.pub.sequencemanager.inputdirpath = 'inputpath'
hydpy.pub.sequencemanager.fluxdirpath = 'outputpath'
hydpy.pub.sequencemanager.statedirpath = 'outputpath'
hydpy.pub.sequencemanager.nodedirpath = 'nodepath'
hydpy.pub.timegrids = '2000-01-01', '2000-01-05', '1d'
from hydpy import Node, Nodes, Element, Elements, prepare_model
node1 = Node('node1')
node2 = Node('node2', variable='T')
nodes = Nodes(node1, node2)
element1 = Element('element1', outlets=node1)
element2 = Element('element2', outlets=node1)
element3 = Element('element3', outlets=node1)
elements = Elements(element1, element2, element3)
from hydpy.models import lland_v1, lland_v2
element1.model = prepare_model(lland_v1)
element2.model = prepare_model(lland_v1)
element3.model = prepare_model(lland_v2)
from hydpy.models.lland import ACKER
for idx, element in enumerate(elements):
parameters = element.model.parameters
parameters.control.nhru(idx+1)
parameters.control.lnk(ACKER)
parameters.derived.absfhru(10.0)
with hydpy.pub.options.printprogress(False):
nodes.prepare_simseries()
elements.prepare_inputseries()
elements.prepare_fluxseries()
elements.prepare_stateseries()
def init_values(seq, value1_):
value2_ = value1_ + len(seq.series.flatten())
values_ = numpy.arange(value1_, value2_, dtype=float)
seq.testarray = values_.reshape(seq.seriesshape)
seq.series = seq.testarray.copy()
return value2_
import numpy
value1 = 0
for subname, seqname in zip(['inputs', 'fluxes', 'states'],
['nied', 'nkor', 'bowa']):
for element in elements:
subseqs = getattr(element.model.sequences, subname)
value1 = init_values(getattr(subseqs, seqname), value1)
for node in nodes:
value1 = init_values(node.sequences.sim, value1)
return nodes, elements |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 29; 2, function_name:comparison_table; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 3, 23; 3, 26; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:caption; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:label; 10, string:"tab:model_comp"; 11, default_parameter; 11, 12; 11, 13; 12, identifier:hlines; 13, True; 14, default_parameter; 14, 15; 14, 16; 15, identifier:aic; 16, True; 17, default_parameter; 17, 18; 17, 19; 18, identifier:bic; 19, True; 20, default_parameter; 20, 21; 20, 22; 21, identifier:dic; 22, True; 23, default_parameter; 23, 24; 23, 25; 24, identifier:sort; 25, string:"bic"; 26, default_parameter; 26, 27; 26, 28; 27, identifier:descending; 28, True; 29, block; 29, 30; 29, 38; 29, 46; 29, 54; 29, 63; 29, 72; 29, 80; 29, 84; 29, 100; 29, 109; 29, 113; 29, 117; 29, 124; 29, 149; 29, 158; 29, 187; 29, 216; 29, 245; 29, 281; 29, 298; 29, 314; 29, 324; 29, 334; 29, 343; 29, 352; 29, 365; 29, 418; 29, 427; 30, if_statement; 30, 31; 30, 34; 31, comparison_operator:==; 31, 32; 31, 33; 32, identifier:sort; 33, string:"bic"; 34, block; 34, 35; 35, assert_statement; 35, 36; 35, 37; 36, identifier:bic; 37, string:"You cannot sort by BIC if you turn it off"; 38, if_statement; 38, 39; 38, 42; 39, comparison_operator:==; 39, 40; 39, 41; 40, identifier:sort; 41, string:"aic"; 42, block; 42, 43; 43, assert_statement; 43, 44; 43, 45; 44, identifier:aic; 45, string:"You cannot sort by AIC if you turn it off"; 46, if_statement; 46, 47; 46, 50; 47, comparison_operator:==; 47, 48; 47, 49; 48, identifier:sort; 49, string:"dic"; 50, block; 50, 51; 51, assert_statement; 51, 52; 51, 53; 52, identifier:dic; 53, string:"You cannot sort by DIC if you turn it off"; 54, if_statement; 54, 55; 54, 58; 55, comparison_operator:is; 55, 56; 55, 57; 56, identifier:caption; 57, None; 58, block; 58, 59; 59, expression_statement; 59, 60; 60, assignment; 60, 61; 60, 62; 61, identifier:caption; 62, string:""; 63, if_statement; 63, 64; 63, 67; 64, comparison_operator:is; 64, 65; 64, 66; 65, identifier:label; 66, None; 67, block; 67, 68; 68, expression_statement; 68, 69; 69, assignment; 69, 70; 69, 71; 70, identifier:label; 71, string:""; 72, expression_statement; 72, 73; 73, assignment; 73, 74; 73, 75; 74, identifier:base_string; 75, call; 75, 76; 75, 77; 76, identifier:get_latex_table_frame; 77, argument_list; 77, 78; 77, 79; 78, identifier:caption; 79, identifier:label; 80, expression_statement; 80, 81; 81, assignment; 81, 82; 81, 83; 82, identifier:end_text; 83, string:" \\\\ \n"; 84, expression_statement; 84, 85; 85, assignment; 85, 86; 85, 87; 86, identifier:num_cols; 87, binary_operator:+; 87, 88; 87, 95; 88, binary_operator:+; 88, 89; 88, 90; 89, integer:1; 90, parenthesized_expression; 90, 91; 91, conditional_expression:if; 91, 92; 91, 93; 91, 94; 92, integer:1; 93, identifier:aic; 94, integer:0; 95, parenthesized_expression; 95, 96; 96, conditional_expression:if; 96, 97; 96, 98; 96, 99; 97, integer:1; 98, identifier:bic; 99, integer:0; 100, expression_statement; 100, 101; 101, assignment; 101, 102; 101, 103; 102, identifier:column_text; 103, binary_operator:*; 103, 104; 103, 105; 104, string:"c"; 105, parenthesized_expression; 105, 106; 106, binary_operator:+; 106, 107; 106, 108; 107, identifier:num_cols; 108, integer:1; 109, expression_statement; 109, 110; 110, assignment; 110, 111; 110, 112; 111, identifier:center_text; 112, string:""; 113, expression_statement; 113, 114; 114, assignment; 114, 115; 114, 116; 115, identifier:hline_text; 116, string:"\\hline\n"; 117, if_statement; 117, 118; 117, 119; 118, identifier:hlines; 119, block; 119, 120; 120, expression_statement; 120, 121; 121, augmented_assignment:+=; 121, 122; 121, 123; 122, identifier:center_text; 123, identifier:hline_text; 124, expression_statement; 124, 125; 125, augmented_assignment:+=; 125, 126; 125, 127; 126, identifier:center_text; 127, binary_operator:+; 127, 128; 127, 148; 128, binary_operator:+; 128, 129; 128, 142; 128, 143; 129, binary_operator:+; 129, 130; 129, 137; 130, binary_operator:+; 130, 131; 130, 132; 131, string:"\tModel"; 132, parenthesized_expression; 132, 133; 133, conditional_expression:if; 133, 134; 133, 135; 133, 136; 134, string:" & AIC"; 135, identifier:aic; 136, string:""; 137, parenthesized_expression; 137, 138; 138, conditional_expression:if; 138, 139; 138, 140; 138, 141; 139, string:" & BIC "; 140, identifier:bic; 141, string:""; 142, line_continuation:\; 143, parenthesized_expression; 143, 144; 144, conditional_expression:if; 144, 145; 144, 146; 144, 147; 145, string:" & DIC "; 146, identifier:dic; 147, string:""; 148, identifier:end_text; 149, if_statement; 149, 150; 149, 151; 150, identifier:hlines; 151, block; 151, 152; 152, expression_statement; 152, 153; 153, augmented_assignment:+=; 153, 154; 153, 155; 154, identifier:center_text; 155, binary_operator:+; 155, 156; 155, 157; 156, string:"\t"; 157, identifier:hline_text; 158, if_statement; 158, 159; 158, 160; 158, 169; 159, identifier:aic; 160, block; 160, 161; 161, expression_statement; 161, 162; 162, assignment; 162, 163; 162, 164; 163, identifier:aics; 164, call; 164, 165; 164, 168; 165, attribute; 165, 166; 165, 167; 166, identifier:self; 167, identifier:aic; 168, argument_list; 169, else_clause; 169, 170; 170, block; 170, 171; 171, expression_statement; 171, 172; 172, assignment; 172, 173; 172, 174; 173, identifier:aics; 174, call; 174, 175; 174, 178; 175, attribute; 175, 176; 175, 177; 176, identifier:np; 177, identifier:zeros; 178, argument_list; 178, 179; 179, call; 179, 180; 179, 181; 180, identifier:len; 181, argument_list; 181, 182; 182, attribute; 182, 183; 182, 186; 183, attribute; 183, 184; 183, 185; 184, identifier:self; 185, identifier:parent; 186, identifier:chains; 187, if_statement; 187, 188; 187, 189; 187, 198; 188, identifier:bic; 189, block; 189, 190; 190, expression_statement; 190, 191; 191, assignment; 191, 192; 191, 193; 192, identifier:bics; 193, call; 193, 194; 193, 197; 194, attribute; 194, 195; 194, 196; 195, identifier:self; 196, identifier:bic; 197, argument_list; 198, else_clause; 198, 199; 199, block; 199, 200; 200, expression_statement; 200, 201; 201, assignment; 201, 202; 201, 203; 202, identifier:bics; 203, call; 203, 204; 203, 207; 204, attribute; 204, 205; 204, 206; 205, identifier:np; 206, identifier:zeros; 207, argument_list; 207, 208; 208, call; 208, 209; 208, 210; 209, identifier:len; 210, argument_list; 210, 211; 211, attribute; 211, 212; 211, 215; 212, attribute; 212, 213; 212, 214; 213, identifier:self; 214, identifier:parent; 215, identifier:chains; 216, if_statement; 216, 217; 216, 218; 216, 227; 217, identifier:dic; 218, block; 218, 219; 219, expression_statement; 219, 220; 220, assignment; 220, 221; 220, 222; 221, identifier:dics; 222, call; 222, 223; 222, 226; 223, attribute; 223, 224; 223, 225; 224, identifier:self; 225, identifier:dic; 226, argument_list; 227, else_clause; 227, 228; 228, block; 228, 229; 229, expression_statement; 229, 230; 230, assignment; 230, 231; 230, 232; 231, identifier:dics; 232, call; 232, 233; 232, 236; 233, attribute; 233, 234; 233, 235; 234, identifier:np; 235, identifier:zeros; 236, argument_list; 236, 237; 237, call; 237, 238; 237, 239; 238, identifier:len; 239, argument_list; 239, 240; 240, attribute; 240, 241; 240, 244; 241, attribute; 241, 242; 241, 243; 242, identifier:self; 243, identifier:parent; 244, identifier:chains; 245, if_statement; 245, 246; 245, 249; 245, 254; 245, 263; 245, 272; 246, comparison_operator:==; 246, 247; 246, 248; 247, identifier:sort; 248, string:"bic"; 249, block; 249, 250; 250, expression_statement; 250, 251; 251, assignment; 251, 252; 251, 253; 252, identifier:to_sort; 253, identifier:bics; 254, elif_clause; 254, 255; 254, 258; 255, comparison_operator:==; 255, 256; 255, 257; 256, identifier:sort; 257, string:"aic"; 258, block; 258, 259; 259, expression_statement; 259, 260; 260, assignment; 260, 261; 260, 262; 261, identifier:to_sort; 262, identifier:aics; 263, elif_clause; 263, 264; 263, 267; 264, comparison_operator:==; 264, 265; 264, 266; 265, identifier:sort; 266, string:"dic"; 267, block; 267, 268; 268, expression_statement; 268, 269; 269, assignment; 269, 270; 269, 271; 270, identifier:to_sort; 271, identifier:dics; 272, else_clause; 272, 273; 273, block; 273, 274; 274, raise_statement; 274, 275; 275, call; 275, 276; 275, 277; 276, identifier:ValueError; 277, argument_list; 277, 278; 278, binary_operator:%; 278, 279; 278, 280; 279, string:"sort %s not recognised, must be dic, aic or dic"; 280, identifier:sort; 281, expression_statement; 281, 282; 282, assignment; 282, 283; 282, 284; 283, identifier:good; 284, list_comprehension; 284, 285; 284, 286; 284, 294; 285, identifier:i; 286, for_in_clause; 286, 287; 286, 290; 287, pattern_list; 287, 288; 287, 289; 288, identifier:i; 289, identifier:t; 290, call; 290, 291; 290, 292; 291, identifier:enumerate; 292, argument_list; 292, 293; 293, identifier:to_sort; 294, if_clause; 294, 295; 295, comparison_operator:is; 295, 296; 295, 297; 296, identifier:t; 297, None; 298, expression_statement; 298, 299; 299, assignment; 299, 300; 299, 301; 300, identifier:names; 301, list_comprehension; 301, 302; 301, 311; 302, attribute; 302, 303; 302, 310; 303, subscript; 303, 304; 303, 309; 304, attribute; 304, 305; 304, 308; 305, attribute; 305, 306; 305, 307; 306, identifier:self; 307, identifier:parent; 308, identifier:chains; 309, identifier:g; 310, identifier:name; 311, for_in_clause; 311, 312; 311, 313; 312, identifier:g; 313, identifier:good; 314, expression_statement; 314, 315; 315, assignment; 315, 316; 315, 317; 316, identifier:aics; 317, list_comprehension; 317, 318; 317, 321; 318, subscript; 318, 319; 318, 320; 319, identifier:aics; 320, identifier:g; 321, for_in_clause; 321, 322; 321, 323; 322, identifier:g; 323, identifier:good; 324, expression_statement; 324, 325; 325, assignment; 325, 326; 325, 327; 326, identifier:bics; 327, list_comprehension; 327, 328; 327, 331; 328, subscript; 328, 329; 328, 330; 329, identifier:bics; 330, identifier:g; 331, for_in_clause; 331, 332; 331, 333; 332, identifier:g; 333, identifier:good; 334, expression_statement; 334, 335; 335, assignment; 335, 336; 335, 337; 336, identifier:to_sort; 337, conditional_expression:if; 337, 338; 337, 339; 337, 342; 338, identifier:bics; 339, comparison_operator:==; 339, 340; 339, 341; 340, identifier:sort; 341, string:"bic"; 342, identifier:aics; 343, expression_statement; 343, 344; 344, assignment; 344, 345; 344, 346; 345, identifier:indexes; 346, call; 346, 347; 346, 350; 347, attribute; 347, 348; 347, 349; 348, identifier:np; 349, identifier:argsort; 350, argument_list; 350, 351; 351, identifier:to_sort; 352, if_statement; 352, 353; 352, 354; 353, identifier:descending; 354, block; 354, 355; 355, expression_statement; 355, 356; 356, assignment; 356, 357; 356, 358; 357, identifier:indexes; 358, subscript; 358, 359; 358, 360; 359, identifier:indexes; 360, slice; 360, 361; 360, 362; 360, 363; 361, colon; 362, colon; 363, unary_operator:-; 363, 364; 364, integer:1; 365, for_statement; 365, 366; 365, 367; 365, 368; 366, identifier:i; 367, identifier:indexes; 368, block; 368, 369; 368, 377; 368, 388; 368, 399; 368, 410; 368, 414; 369, expression_statement; 369, 370; 370, assignment; 370, 371; 370, 372; 371, identifier:line; 372, binary_operator:+; 372, 373; 372, 374; 373, string:"\t"; 374, subscript; 374, 375; 374, 376; 375, identifier:names; 376, identifier:i; 377, if_statement; 377, 378; 377, 379; 378, identifier:aic; 379, block; 379, 380; 380, expression_statement; 380, 381; 381, augmented_assignment:+=; 381, 382; 381, 383; 382, identifier:line; 383, binary_operator:%; 383, 384; 383, 385; 384, string:" & %5.1f "; 385, subscript; 385, 386; 385, 387; 386, identifier:aics; 387, identifier:i; 388, if_statement; 388, 389; 388, 390; 389, identifier:bic; 390, block; 390, 391; 391, expression_statement; 391, 392; 392, augmented_assignment:+=; 392, 393; 392, 394; 393, identifier:line; 394, binary_operator:%; 394, 395; 394, 396; 395, string:" & %5.1f "; 396, subscript; 396, 397; 396, 398; 397, identifier:bics; 398, identifier:i; 399, if_statement; 399, 400; 399, 401; 400, identifier:dic; 401, block; 401, 402; 402, expression_statement; 402, 403; 403, augmented_assignment:+=; 403, 404; 403, 405; 404, identifier:line; 405, binary_operator:%; 405, 406; 405, 407; 406, string:" & %5.1f "; 407, subscript; 407, 408; 407, 409; 408, identifier:dics; 409, identifier:i; 410, expression_statement; 410, 411; 411, augmented_assignment:+=; 411, 412; 411, 413; 412, identifier:line; 413, identifier:end_text; 414, expression_statement; 414, 415; 415, augmented_assignment:+=; 415, 416; 415, 417; 416, identifier:center_text; 417, identifier:line; 418, if_statement; 418, 419; 418, 420; 419, identifier:hlines; 420, block; 420, 421; 421, expression_statement; 421, 422; 422, augmented_assignment:+=; 422, 423; 422, 424; 423, identifier:center_text; 424, binary_operator:+; 424, 425; 424, 426; 425, string:"\t"; 426, identifier:hline_text; 427, return_statement; 427, 428; 428, binary_operator:%; 428, 429; 428, 430; 429, identifier:base_string; 430, tuple; 430, 431; 430, 432; 431, identifier:column_text; 432, identifier:center_text | def comparison_table(self, caption=None, label="tab:model_comp", hlines=True,
aic=True, bic=True, dic=True, sort="bic", descending=True):
if sort == "bic":
assert bic, "You cannot sort by BIC if you turn it off"
if sort == "aic":
assert aic, "You cannot sort by AIC if you turn it off"
if sort == "dic":
assert dic, "You cannot sort by DIC if you turn it off"
if caption is None:
caption = ""
if label is None:
label = ""
base_string = get_latex_table_frame(caption, label)
end_text = " \\\\ \n"
num_cols = 1 + (1 if aic else 0) + (1 if bic else 0)
column_text = "c" * (num_cols + 1)
center_text = ""
hline_text = "\\hline\n"
if hlines:
center_text += hline_text
center_text += "\tModel" + (" & AIC" if aic else "") + (" & BIC " if bic else "") \
+ (" & DIC " if dic else "") + end_text
if hlines:
center_text += "\t" + hline_text
if aic:
aics = self.aic()
else:
aics = np.zeros(len(self.parent.chains))
if bic:
bics = self.bic()
else:
bics = np.zeros(len(self.parent.chains))
if dic:
dics = self.dic()
else:
dics = np.zeros(len(self.parent.chains))
if sort == "bic":
to_sort = bics
elif sort == "aic":
to_sort = aics
elif sort == "dic":
to_sort = dics
else:
raise ValueError("sort %s not recognised, must be dic, aic or dic" % sort)
good = [i for i, t in enumerate(to_sort) if t is not None]
names = [self.parent.chains[g].name for g in good]
aics = [aics[g] for g in good]
bics = [bics[g] for g in good]
to_sort = bics if sort == "bic" else aics
indexes = np.argsort(to_sort)
if descending:
indexes = indexes[::-1]
for i in indexes:
line = "\t" + names[i]
if aic:
line += " & %5.1f " % aics[i]
if bic:
line += " & %5.1f " % bics[i]
if dic:
line += " & %5.1f " % dics[i]
line += end_text
center_text += line
if hlines:
center_text += "\t" + hline_text
return base_string % (column_text, center_text) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_initDevClasses; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 12; 5, 18; 5, 24; 5, 28; 5, 32; 5, 45; 5, 153; 5, 165; 5, 177; 5, 181; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 11; 8, attribute; 8, 9; 8, 10; 9, identifier:self; 10, identifier:_devClassTree; 11, dictionary; 12, expression_statement; 12, 13; 13, assignment; 13, 14; 13, 17; 14, attribute; 14, 15; 14, 16; 15, identifier:self; 16, identifier:_partitionTree; 17, dictionary; 18, expression_statement; 18, 19; 19, assignment; 19, 20; 19, 23; 20, attribute; 20, 21; 20, 22; 21, identifier:self; 22, identifier:_mapDevType; 23, dictionary; 24, expression_statement; 24, 25; 25, assignment; 25, 26; 25, 27; 26, identifier:basedevs; 27, list:[]; 28, expression_statement; 28, 29; 29, assignment; 29, 30; 29, 31; 30, identifier:otherdevs; 31, list:[]; 32, if_statement; 32, 33; 32, 38; 33, comparison_operator:is; 33, 34; 33, 37; 34, attribute; 34, 35; 34, 36; 35, identifier:self; 36, identifier:_mapMajorDevclass; 37, None; 38, block; 38, 39; 39, expression_statement; 39, 40; 40, call; 40, 41; 40, 44; 41, attribute; 41, 42; 41, 43; 42, identifier:self; 43, identifier:_initBlockMajorMap; 44, argument_list; 45, for_statement; 45, 46; 45, 47; 45, 50; 46, identifier:dev; 47, attribute; 47, 48; 47, 49; 48, identifier:self; 49, identifier:_diskStats; 50, block; 50, 51; 50, 59; 50, 72; 51, expression_statement; 51, 52; 52, assignment; 52, 53; 52, 54; 53, identifier:stats; 54, subscript; 54, 55; 54, 58; 55, attribute; 55, 56; 55, 57; 56, identifier:self; 57, identifier:_diskStats; 58, identifier:dev; 59, expression_statement; 59, 60; 60, assignment; 60, 61; 60, 62; 61, identifier:devclass; 62, call; 62, 63; 62, 68; 63, attribute; 63, 64; 63, 67; 64, attribute; 64, 65; 64, 66; 65, identifier:self; 66, identifier:_mapMajorDevclass; 67, identifier:get; 68, argument_list; 68, 69; 69, subscript; 69, 70; 69, 71; 70, identifier:stats; 71, string:'major'; 72, if_statement; 72, 73; 72, 76; 73, comparison_operator:is; 73, 74; 73, 75; 74, identifier:devclass; 75, None; 76, block; 76, 77; 76, 89; 77, expression_statement; 77, 78; 78, assignment; 78, 79; 78, 80; 79, identifier:devdir; 80, call; 80, 81; 80, 86; 81, attribute; 81, 82; 81, 85; 82, attribute; 82, 83; 82, 84; 83, identifier:os; 84, identifier:path; 85, identifier:join; 86, argument_list; 86, 87; 86, 88; 87, identifier:sysfsBlockdevDir; 88, identifier:dev; 89, if_statement; 89, 90; 89, 98; 89, 144; 90, call; 90, 91; 90, 96; 91, attribute; 91, 92; 91, 95; 92, attribute; 92, 93; 92, 94; 93, identifier:os; 94, identifier:path; 95, identifier:isdir; 96, argument_list; 96, 97; 97, identifier:devdir; 98, block; 98, 99; 98, 118; 98, 129; 98, 137; 99, if_statement; 99, 100; 99, 109; 100, not_operator; 100, 101; 101, call; 101, 102; 101, 107; 102, attribute; 102, 103; 102, 106; 103, attribute; 103, 104; 103, 105; 104, identifier:self; 105, identifier:_devClassTree; 106, identifier:has_key; 107, argument_list; 107, 108; 108, identifier:devclass; 109, block; 109, 110; 110, expression_statement; 110, 111; 111, assignment; 111, 112; 111, 117; 112, subscript; 112, 113; 112, 116; 113, attribute; 113, 114; 113, 115; 114, identifier:self; 115, identifier:_devClassTree; 116, identifier:devclass; 117, list:[]; 118, expression_statement; 118, 119; 119, call; 119, 120; 119, 127; 120, attribute; 120, 121; 120, 126; 121, subscript; 121, 122; 121, 125; 122, attribute; 122, 123; 122, 124; 123, identifier:self; 124, identifier:_devClassTree; 125, identifier:devclass; 126, identifier:append; 127, argument_list; 127, 128; 128, identifier:dev; 129, expression_statement; 129, 130; 130, assignment; 130, 131; 130, 136; 131, subscript; 131, 132; 131, 135; 132, attribute; 132, 133; 132, 134; 133, identifier:self; 134, identifier:_mapDevType; 135, identifier:dev; 136, identifier:devclass; 137, expression_statement; 137, 138; 138, call; 138, 139; 138, 142; 139, attribute; 139, 140; 139, 141; 140, identifier:basedevs; 141, identifier:append; 142, argument_list; 142, 143; 143, identifier:dev; 144, else_clause; 144, 145; 145, block; 145, 146; 146, expression_statement; 146, 147; 147, call; 147, 148; 147, 151; 148, attribute; 148, 149; 148, 150; 149, identifier:otherdevs; 150, identifier:append; 151, argument_list; 151, 152; 152, identifier:dev; 153, expression_statement; 153, 154; 154, call; 154, 155; 154, 158; 155, attribute; 155, 156; 155, 157; 156, identifier:basedevs; 157, identifier:sort; 158, argument_list; 158, 159; 158, 162; 159, keyword_argument; 159, 160; 159, 161; 160, identifier:key; 161, identifier:len; 162, keyword_argument; 162, 163; 162, 164; 163, identifier:reverse; 164, True; 165, expression_statement; 165, 166; 166, call; 166, 167; 166, 170; 167, attribute; 167, 168; 167, 169; 168, identifier:otherdevs; 169, identifier:sort; 170, argument_list; 170, 171; 170, 174; 171, keyword_argument; 171, 172; 171, 173; 172, identifier:key; 173, identifier:len; 174, keyword_argument; 174, 175; 174, 176; 175, identifier:reverse; 176, True; 177, expression_statement; 177, 178; 178, assignment; 178, 179; 178, 180; 179, identifier:idx; 180, integer:0; 181, for_statement; 181, 182; 181, 183; 181, 184; 182, identifier:partdev; 183, identifier:otherdevs; 184, block; 184, 185; 184, 199; 185, while_statement; 185, 186; 185, 194; 186, comparison_operator:>; 186, 187; 186, 193; 187, call; 187, 188; 187, 189; 188, identifier:len; 189, argument_list; 189, 190; 190, subscript; 190, 191; 190, 192; 191, identifier:basedevs; 192, identifier:idx; 193, identifier:partdev; 194, block; 194, 195; 195, expression_statement; 195, 196; 196, augmented_assignment:+=; 196, 197; 196, 198; 197, identifier:idx; 198, integer:1; 199, for_statement; 199, 200; 199, 201; 199, 206; 200, identifier:dev; 201, subscript; 201, 202; 201, 203; 202, identifier:basedevs; 203, slice; 203, 204; 203, 205; 204, identifier:idx; 205, colon; 206, block; 206, 207; 207, if_statement; 207, 208; 207, 217; 208, call; 208, 209; 208, 212; 209, attribute; 209, 210; 209, 211; 210, identifier:re; 211, identifier:match; 212, argument_list; 212, 213; 212, 216; 213, binary_operator:%; 213, 214; 213, 215; 214, string:"%s(\d+|p\d+)$"; 215, identifier:dev; 216, identifier:partdev; 217, block; 217, 218; 217, 237; 217, 248; 218, if_statement; 218, 219; 218, 228; 219, not_operator; 219, 220; 220, call; 220, 221; 220, 226; 221, attribute; 221, 222; 221, 225; 222, attribute; 222, 223; 222, 224; 223, identifier:self; 224, identifier:_partitionTree; 225, identifier:has_key; 226, argument_list; 226, 227; 227, identifier:dev; 228, block; 228, 229; 229, expression_statement; 229, 230; 230, assignment; 230, 231; 230, 236; 231, subscript; 231, 232; 231, 235; 232, attribute; 232, 233; 232, 234; 233, identifier:self; 234, identifier:_partitionTree; 235, identifier:dev; 236, list:[]; 237, expression_statement; 237, 238; 238, call; 238, 239; 238, 246; 239, attribute; 239, 240; 239, 245; 240, subscript; 240, 241; 240, 244; 241, attribute; 241, 242; 241, 243; 242, identifier:self; 243, identifier:_partitionTree; 244, identifier:dev; 245, identifier:append; 246, argument_list; 246, 247; 247, identifier:partdev; 248, expression_statement; 248, 249; 249, assignment; 249, 250; 249, 255; 250, subscript; 250, 251; 250, 254; 251, attribute; 251, 252; 251, 253; 252, identifier:self; 253, identifier:_mapDevType; 254, identifier:partdev; 255, string:'part' | def _initDevClasses(self):
self._devClassTree = {}
self._partitionTree = {}
self._mapDevType = {}
basedevs = []
otherdevs = []
if self._mapMajorDevclass is None:
self._initBlockMajorMap()
for dev in self._diskStats:
stats = self._diskStats[dev]
devclass = self._mapMajorDevclass.get(stats['major'])
if devclass is not None:
devdir = os.path.join(sysfsBlockdevDir, dev)
if os.path.isdir(devdir):
if not self._devClassTree.has_key(devclass):
self._devClassTree[devclass] = []
self._devClassTree[devclass].append(dev)
self._mapDevType[dev] = devclass
basedevs.append(dev)
else:
otherdevs.append(dev)
basedevs.sort(key=len, reverse=True)
otherdevs.sort(key=len, reverse=True)
idx = 0
for partdev in otherdevs:
while len(basedevs[idx]) > partdev:
idx += 1
for dev in basedevs[idx:]:
if re.match("%s(\d+|p\d+)$" % dev, partdev):
if not self._partitionTree.has_key(dev):
self._partitionTree[dev] = []
self._partitionTree[dev].append(partdev)
self._mapDevType[partdev] = 'part' |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:zdiffstore; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:dest; 6, identifier:keys; 7, default_parameter; 7, 8; 7, 9; 8, identifier:withscores; 9, False; 10, block; 10, 11; 10, 13; 10, 23; 10, 30; 11, expression_statement; 11, 12; 12, string:'''Compute the difference of multiple sorted.
The difference of sets specified by ``keys`` into a new sorted set
in ``dest``.
'''; 13, expression_statement; 13, 14; 14, assignment; 14, 15; 14, 16; 15, identifier:keys; 16, binary_operator:+; 16, 17; 16, 19; 17, tuple; 17, 18; 18, identifier:dest; 19, call; 19, 20; 19, 21; 20, identifier:tuple; 21, argument_list; 21, 22; 22, identifier:keys; 23, expression_statement; 23, 24; 24, assignment; 24, 25; 24, 26; 25, identifier:wscores; 26, conditional_expression:if; 26, 27; 26, 28; 26, 29; 27, string:'withscores'; 28, identifier:withscores; 29, string:''; 30, return_statement; 30, 31; 31, call; 31, 32; 31, 35; 32, attribute; 32, 33; 32, 34; 33, identifier:self; 34, identifier:execute_script; 35, argument_list; 35, 36; 35, 37; 35, 38; 35, 39; 36, string:'zdiffstore'; 37, identifier:keys; 38, identifier:wscores; 39, keyword_argument; 39, 40; 39, 41; 40, identifier:withscores; 41, identifier:withscores | def zdiffstore(self, dest, keys, withscores=False):
'''Compute the difference of multiple sorted.
The difference of sets specified by ``keys`` into a new sorted set
in ``dest``.
'''
keys = (dest,) + tuple(keys)
wscores = 'withscores' if withscores else ''
return self.execute_script('zdiffstore', keys, wscores,
withscores=withscores) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 19; 2, function_name:places_within_radius; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:place; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:latitude; 10, None; 11, default_parameter; 11, 12; 11, 13; 12, identifier:longitude; 13, None; 14, default_parameter; 14, 15; 14, 16; 15, identifier:radius; 16, integer:0; 17, dictionary_splat_pattern; 17, 18; 18, identifier:kwargs; 19, block; 19, 20; 19, 26; 19, 32; 19, 38; 19, 46; 19, 56; 19, 119; 19, 123; 19, 166; 20, expression_statement; 20, 21; 21, assignment; 21, 22; 21, 25; 22, subscript; 22, 23; 22, 24; 23, identifier:kwargs; 24, string:'withdist'; 25, True; 26, expression_statement; 26, 27; 27, assignment; 27, 28; 27, 31; 28, subscript; 28, 29; 28, 30; 29, identifier:kwargs; 30, string:'withcoord'; 31, True; 32, expression_statement; 32, 33; 33, assignment; 33, 34; 33, 37; 34, subscript; 34, 35; 34, 36; 35, identifier:kwargs; 36, string:'withhash'; 37, False; 38, expression_statement; 38, 39; 39, call; 39, 40; 39, 43; 40, attribute; 40, 41; 40, 42; 41, identifier:kwargs; 42, identifier:setdefault; 43, argument_list; 43, 44; 43, 45; 44, string:'sort'; 45, string:'ASC'; 46, expression_statement; 46, 47; 47, assignment; 47, 48; 47, 49; 48, identifier:unit; 49, call; 49, 50; 49, 53; 50, attribute; 50, 51; 50, 52; 51, identifier:kwargs; 52, identifier:setdefault; 53, argument_list; 53, 54; 53, 55; 54, string:'unit'; 55, string:'km'; 56, if_statement; 56, 57; 56, 60; 56, 83; 56, 112; 57, comparison_operator:is; 57, 58; 57, 59; 58, identifier:place; 59, None; 60, block; 60, 61; 61, expression_statement; 61, 62; 62, assignment; 62, 63; 62, 64; 63, identifier:response; 64, call; 64, 65; 64, 70; 65, attribute; 65, 66; 65, 69; 66, attribute; 66, 67; 66, 68; 67, identifier:self; 68, identifier:redis; 69, identifier:georadiusbymember; 70, argument_list; 70, 71; 70, 74; 70, 80; 70, 81; 71, attribute; 71, 72; 71, 73; 72, identifier:self; 73, identifier:key; 74, call; 74, 75; 74, 78; 75, attribute; 75, 76; 75, 77; 76, identifier:self; 77, identifier:_pickle; 78, argument_list; 78, 79; 79, identifier:place; 80, identifier:radius; 81, dictionary_splat; 81, 82; 82, identifier:kwargs; 83, elif_clause; 83, 84; 83, 93; 84, boolean_operator:and; 84, 85; 84, 89; 85, parenthesized_expression; 85, 86; 86, comparison_operator:is; 86, 87; 86, 88; 87, identifier:latitude; 88, None; 89, parenthesized_expression; 89, 90; 90, comparison_operator:is; 90, 91; 90, 92; 91, identifier:longitude; 92, None; 93, block; 93, 94; 94, expression_statement; 94, 95; 95, assignment; 95, 96; 95, 97; 96, identifier:response; 97, call; 97, 98; 97, 103; 98, attribute; 98, 99; 98, 102; 99, attribute; 99, 100; 99, 101; 100, identifier:self; 101, identifier:redis; 102, identifier:georadius; 103, argument_list; 103, 104; 103, 107; 103, 108; 103, 109; 103, 110; 104, attribute; 104, 105; 104, 106; 105, identifier:self; 106, identifier:key; 107, identifier:longitude; 108, identifier:latitude; 109, identifier:radius; 110, dictionary_splat; 110, 111; 111, identifier:kwargs; 112, else_clause; 112, 113; 113, block; 113, 114; 114, raise_statement; 114, 115; 115, call; 115, 116; 115, 117; 116, identifier:ValueError; 117, argument_list; 117, 118; 118, string:'Must specify place, or both latitude and longitude'; 119, expression_statement; 119, 120; 120, assignment; 120, 121; 120, 122; 121, identifier:ret; 122, list:[]; 123, for_statement; 123, 124; 123, 125; 123, 126; 124, identifier:item; 125, identifier:response; 126, block; 126, 127; 127, expression_statement; 127, 128; 128, call; 128, 129; 128, 132; 129, attribute; 129, 130; 129, 131; 130, identifier:ret; 131, identifier:append; 132, argument_list; 132, 133; 133, dictionary; 133, 134; 133, 144; 133, 149; 133, 152; 133, 159; 134, pair; 134, 135; 134, 136; 135, string:'place'; 136, call; 136, 137; 136, 140; 137, attribute; 137, 138; 137, 139; 138, identifier:self; 139, identifier:_unpickle; 140, argument_list; 140, 141; 141, subscript; 141, 142; 141, 143; 142, identifier:item; 143, integer:0; 144, pair; 144, 145; 144, 146; 145, string:'distance'; 146, subscript; 146, 147; 146, 148; 147, identifier:item; 148, integer:1; 149, pair; 149, 150; 149, 151; 150, string:'unit'; 151, identifier:unit; 152, pair; 152, 153; 152, 154; 153, string:'latitude'; 154, subscript; 154, 155; 154, 158; 155, subscript; 155, 156; 155, 157; 156, identifier:item; 157, integer:2; 158, integer:1; 159, pair; 159, 160; 159, 161; 160, string:'longitude'; 161, subscript; 161, 162; 161, 165; 162, subscript; 162, 163; 162, 164; 163, identifier:item; 164, integer:2; 165, integer:0; 166, return_statement; 166, 167; 167, identifier:ret | def places_within_radius(
self, place=None, latitude=None, longitude=None, radius=0, **kwargs
):
kwargs['withdist'] = True
kwargs['withcoord'] = True
kwargs['withhash'] = False
kwargs.setdefault('sort', 'ASC')
unit = kwargs.setdefault('unit', 'km')
if place is not None:
response = self.redis.georadiusbymember(
self.key, self._pickle(place), radius, **kwargs
)
elif (latitude is not None) and (longitude is not None):
response = self.redis.georadius(
self.key, longitude, latitude, radius, **kwargs
)
else:
raise ValueError(
'Must specify place, or both latitude and longitude'
)
ret = []
for item in response:
ret.append(
{
'place': self._unpickle(item[0]),
'distance': item[1],
'unit': unit,
'latitude': item[2][1],
'longitude': item[2][0],
}
)
return ret |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:naturalize_person; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:string; 6, block; 6, 7; 6, 20; 6, 34; 6, 44; 6, 48; 6, 52; 6, 56; 6, 60; 6, 69; 6, 103; 6, 165; 6, 178; 6, 187; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:suffixes; 10, list:[
'Jr', 'Jr.', 'Sr', 'Sr.',
'I', 'II', 'III', 'IV', 'V',
]; 10, 11; 10, 12; 10, 13; 10, 14; 10, 15; 10, 16; 10, 17; 10, 18; 10, 19; 11, string:'Jr'; 12, string:'Jr.'; 13, string:'Sr'; 14, string:'Sr.'; 15, string:'I'; 16, string:'II'; 17, string:'III'; 18, string:'IV'; 19, string:'V'; 20, expression_statement; 20, 21; 21, assignment; 21, 22; 21, 23; 22, identifier:suffixes; 23, binary_operator:+; 23, 24; 23, 25; 24, identifier:suffixes; 25, list_comprehension; 25, 26; 25, 31; 26, call; 26, 27; 26, 30; 27, attribute; 27, 28; 27, 29; 28, identifier:s; 29, identifier:lower; 30, argument_list; 31, for_in_clause; 31, 32; 31, 33; 32, identifier:s; 33, identifier:suffixes; 34, expression_statement; 34, 35; 35, assignment; 35, 36; 35, 37; 36, identifier:particles; 37, list:[
'Le', 'La',
'Von', 'Van',
'Du', 'De',
]; 37, 38; 37, 39; 37, 40; 37, 41; 37, 42; 37, 43; 38, string:'Le'; 39, string:'La'; 40, string:'Von'; 41, string:'Van'; 42, string:'Du'; 43, string:'De'; 44, expression_statement; 44, 45; 45, assignment; 45, 46; 45, 47; 46, identifier:surname; 47, string:''; 48, expression_statement; 48, 49; 49, assignment; 49, 50; 49, 51; 50, identifier:names; 51, string:''; 52, expression_statement; 52, 53; 53, assignment; 53, 54; 53, 55; 54, identifier:suffix; 55, string:''; 56, expression_statement; 56, 57; 57, assignment; 57, 58; 57, 59; 58, identifier:sort_string; 59, identifier:string; 60, expression_statement; 60, 61; 61, assignment; 61, 62; 61, 63; 62, identifier:parts; 63, call; 63, 64; 63, 67; 64, attribute; 64, 65; 64, 66; 65, identifier:string; 66, identifier:split; 67, argument_list; 67, 68; 68, string:' '; 69, if_statement; 69, 70; 69, 76; 70, comparison_operator:in; 70, 71; 70, 75; 71, subscript; 71, 72; 71, 73; 72, identifier:parts; 73, unary_operator:-; 73, 74; 74, integer:1; 75, identifier:suffixes; 76, block; 76, 77; 76, 84; 76, 94; 77, expression_statement; 77, 78; 78, assignment; 78, 79; 78, 80; 79, identifier:suffix; 80, subscript; 80, 81; 80, 82; 81, identifier:parts; 82, unary_operator:-; 82, 83; 83, integer:1; 84, expression_statement; 84, 85; 85, assignment; 85, 86; 85, 87; 86, identifier:parts; 87, subscript; 87, 88; 87, 89; 88, identifier:parts; 89, slice; 89, 90; 89, 91; 89, 92; 90, integer:0; 91, colon; 92, unary_operator:-; 92, 93; 93, integer:1; 94, expression_statement; 94, 95; 95, assignment; 95, 96; 95, 97; 96, identifier:sort_string; 97, call; 97, 98; 97, 101; 98, attribute; 98, 99; 98, 100; 99, string:' '; 100, identifier:join; 101, argument_list; 101, 102; 102, identifier:parts; 103, if_statement; 103, 104; 103, 110; 104, comparison_operator:>; 104, 105; 104, 109; 105, call; 105, 106; 105, 107; 106, identifier:len; 107, argument_list; 107, 108; 108, identifier:parts; 109, integer:1; 110, block; 110, 111; 110, 142; 111, if_statement; 111, 112; 111, 118; 112, comparison_operator:in; 112, 113; 112, 117; 113, subscript; 113, 114; 113, 115; 114, identifier:parts; 115, unary_operator:-; 115, 116; 116, integer:2; 117, identifier:particles; 118, block; 118, 119; 119, expression_statement; 119, 120; 120, assignment; 120, 121; 120, 122; 121, identifier:parts; 122, binary_operator:+; 122, 123; 122, 130; 123, subscript; 123, 124; 123, 125; 124, identifier:parts; 125, slice; 125, 126; 125, 127; 125, 128; 126, integer:0; 127, colon; 128, unary_operator:-; 128, 129; 129, integer:2; 130, list:[ ' '.join(parts[-2:]) ]; 130, 131; 131, call; 131, 132; 131, 135; 132, attribute; 132, 133; 132, 134; 133, string:' '; 134, identifier:join; 135, argument_list; 135, 136; 136, subscript; 136, 137; 136, 138; 137, identifier:parts; 138, slice; 138, 139; 138, 141; 139, unary_operator:-; 139, 140; 140, integer:2; 141, colon; 142, expression_statement; 142, 143; 143, assignment; 143, 144; 143, 145; 144, identifier:sort_string; 145, call; 145, 146; 145, 149; 146, attribute; 146, 147; 146, 148; 147, string:'{}, {}'; 148, identifier:format; 149, argument_list; 149, 150; 149, 154; 150, subscript; 150, 151; 150, 152; 151, identifier:parts; 152, unary_operator:-; 152, 153; 153, integer:1; 154, call; 154, 155; 154, 158; 155, attribute; 155, 156; 155, 157; 156, string:' '; 157, identifier:join; 158, argument_list; 158, 159; 159, subscript; 159, 160; 159, 161; 160, identifier:parts; 161, slice; 161, 162; 161, 163; 162, colon; 163, unary_operator:-; 163, 164; 164, integer:1; 165, if_statement; 165, 166; 165, 167; 166, identifier:suffix; 167, block; 167, 168; 168, expression_statement; 168, 169; 169, assignment; 169, 170; 169, 171; 170, identifier:sort_string; 171, call; 171, 172; 171, 175; 172, attribute; 172, 173; 172, 174; 173, string:'{} {}'; 174, identifier:format; 175, argument_list; 175, 176; 175, 177; 176, identifier:sort_string; 177, identifier:suffix; 178, expression_statement; 178, 179; 179, assignment; 179, 180; 179, 181; 180, identifier:sort_string; 181, call; 181, 182; 181, 185; 182, attribute; 182, 183; 182, 184; 183, identifier:self; 184, identifier:_naturalize_numbers; 185, argument_list; 185, 186; 186, identifier:sort_string; 187, return_statement; 187, 188; 188, identifier:sort_string | def naturalize_person(self, string):
suffixes = [
'Jr', 'Jr.', 'Sr', 'Sr.',
'I', 'II', 'III', 'IV', 'V',
]
suffixes = suffixes + [s.lower() for s in suffixes]
particles = [
'Le', 'La',
'Von', 'Van',
'Du', 'De',
]
surname = ''
names = ''
suffix = ''
sort_string = string
parts = string.split(' ')
if parts[-1] in suffixes:
suffix = parts[-1]
parts = parts[0:-1]
sort_string = ' '.join(parts)
if len(parts) > 1:
if parts[-2] in particles:
parts = parts[0:-2] + [ ' '.join(parts[-2:]) ]
sort_string = '{}, {}'.format(parts[-1], ' '.join(parts[:-1]))
if suffix:
sort_string = '{} {}'.format(sort_string, suffix)
sort_string = self._naturalize_numbers(sort_string)
return sort_string |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:get_countries; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 36; 5, 40; 5, 66; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:qs; 9, call; 9, 10; 9, 34; 10, attribute; 10, 11; 10, 32; 10, 33; 11, call; 11, 12; 11, 31; 12, attribute; 12, 13; 12, 29; 12, 30; 13, call; 13, 14; 13, 25; 14, attribute; 14, 15; 14, 23; 14, 24; 15, call; 15, 16; 15, 21; 16, attribute; 16, 17; 16, 20; 17, attribute; 17, 18; 17, 19; 18, identifier:Venue; 19, identifier:objects; 20, identifier:values; 21, argument_list; 21, 22; 22, string:'country'; 23, line_continuation:\; 24, identifier:exclude; 25, argument_list; 25, 26; 26, keyword_argument; 26, 27; 26, 28; 27, identifier:country; 28, string:''; 29, line_continuation:\; 30, identifier:distinct; 31, argument_list; 32, line_continuation:\; 33, identifier:order_by; 34, argument_list; 34, 35; 35, string:'country'; 36, expression_statement; 36, 37; 37, assignment; 37, 38; 37, 39; 38, identifier:countries; 39, list:[]; 40, for_statement; 40, 41; 40, 42; 40, 43; 41, identifier:c; 42, identifier:qs; 43, block; 43, 44; 44, expression_statement; 44, 45; 45, call; 45, 46; 45, 49; 46, attribute; 46, 47; 46, 48; 47, identifier:countries; 48, identifier:append; 49, argument_list; 49, 50; 50, dictionary; 50, 51; 50, 56; 51, pair; 51, 52; 51, 53; 52, string:'code'; 53, subscript; 53, 54; 53, 55; 54, identifier:c; 55, string:'country'; 56, pair; 56, 57; 56, 58; 57, string:'name'; 58, call; 58, 59; 58, 62; 59, attribute; 59, 60; 59, 61; 60, identifier:Venue; 61, identifier:get_country_name; 62, argument_list; 62, 63; 63, subscript; 63, 64; 63, 65; 64, identifier:c; 65, string:'country'; 66, return_statement; 66, 67; 67, call; 67, 68; 67, 69; 68, identifier:sorted; 69, argument_list; 69, 70; 69, 71; 70, identifier:countries; 71, keyword_argument; 71, 72; 71, 73; 72, identifier:key; 73, lambda; 73, 74; 73, 76; 74, lambda_parameters; 74, 75; 75, identifier:k; 76, subscript; 76, 77; 76, 78; 77, identifier:k; 78, string:'name' | def get_countries(self):
qs = Venue.objects.values('country') \
.exclude(country='') \
.distinct() \
.order_by('country')
countries = []
for c in qs:
countries.append({
'code': c['country'],
'name': Venue.get_country_name(c['country'])
})
return sorted(countries, key=lambda k: k['name']) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 13; 2, function_name:fit; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 10; 4, identifier:self; 5, identifier:t; 6, identifier:y; 7, default_parameter; 7, 8; 7, 9; 8, identifier:dy; 9, integer:1; 10, default_parameter; 10, 11; 10, 12; 11, identifier:presorted; 12, False; 13, block; 13, 14; 13, 35; 13, 50; 14, expression_statement; 14, 15; 15, assignment; 15, 16; 15, 26; 16, pattern_list; 16, 17; 16, 20; 16, 23; 17, attribute; 17, 18; 17, 19; 18, identifier:self; 19, identifier:t; 20, attribute; 20, 21; 20, 22; 21, identifier:self; 22, identifier:y; 23, attribute; 23, 24; 23, 25; 24, identifier:self; 25, identifier:dy; 26, call; 26, 27; 26, 30; 27, attribute; 27, 28; 27, 29; 28, identifier:self; 29, identifier:_validate_inputs; 30, argument_list; 30, 31; 30, 32; 30, 33; 30, 34; 31, identifier:t; 32, identifier:y; 33, identifier:dy; 34, identifier:presorted; 35, expression_statement; 35, 36; 36, call; 36, 37; 36, 40; 37, attribute; 37, 38; 37, 39; 38, identifier:self; 39, identifier:_fit; 40, argument_list; 40, 41; 40, 44; 40, 47; 41, attribute; 41, 42; 41, 43; 42, identifier:self; 43, identifier:t; 44, attribute; 44, 45; 44, 46; 45, identifier:self; 46, identifier:y; 47, attribute; 47, 48; 47, 49; 48, identifier:self; 49, identifier:dy; 50, return_statement; 50, 51; 51, identifier:self | def fit(self, t, y, dy=1, presorted=False):
self.t, self.y, self.dy = self._validate_inputs(t, y, dy, presorted)
self._fit(self.t, self.y, self.dy)
return self |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:validate_inputs; 3, parameters; 3, 4; 3, 6; 4, list_splat_pattern; 4, 5; 5, identifier:arrays; 6, dictionary_splat_pattern; 6, 7; 7, identifier:kwargs; 8, block; 8, 9; 8, 19; 8, 29; 8, 46; 8, 60; 8, 103; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 11, identifier:arrays; 12, call; 12, 13; 12, 16; 13, attribute; 13, 14; 13, 15; 14, identifier:np; 15, identifier:broadcast_arrays; 16, argument_list; 16, 17; 17, list_splat; 17, 18; 18, identifier:arrays; 19, expression_statement; 19, 20; 20, assignment; 20, 21; 20, 22; 21, identifier:sort_by; 22, call; 22, 23; 22, 26; 23, attribute; 23, 24; 23, 25; 24, identifier:kwargs; 25, identifier:pop; 26, argument_list; 26, 27; 26, 28; 27, string:'sort_by'; 28, None; 29, if_statement; 29, 30; 29, 31; 30, identifier:kwargs; 31, block; 31, 32; 32, raise_statement; 32, 33; 33, call; 33, 34; 33, 35; 34, identifier:ValueError; 35, argument_list; 35, 36; 36, call; 36, 37; 36, 40; 37, attribute; 37, 38; 37, 39; 38, string:"unrecognized arguments: {0}"; 39, identifier:format; 40, argument_list; 40, 41; 41, call; 41, 42; 41, 45; 42, attribute; 42, 43; 42, 44; 43, identifier:kwargs; 44, identifier:keys; 45, argument_list; 46, if_statement; 46, 47; 46, 54; 47, comparison_operator:!=; 47, 48; 47, 53; 48, attribute; 48, 49; 48, 52; 49, subscript; 49, 50; 49, 51; 50, identifier:arrays; 51, integer:0; 52, identifier:ndim; 53, integer:1; 54, block; 54, 55; 55, raise_statement; 55, 56; 56, call; 56, 57; 56, 58; 57, identifier:ValueError; 58, argument_list; 58, 59; 59, string:"Input arrays should be one-dimensional."; 60, if_statement; 60, 61; 60, 64; 61, comparison_operator:is; 61, 62; 61, 63; 62, identifier:sort_by; 63, None; 64, block; 64, 65; 64, 74; 64, 90; 65, expression_statement; 65, 66; 66, assignment; 66, 67; 66, 68; 67, identifier:isort; 68, call; 68, 69; 68, 72; 69, attribute; 69, 70; 69, 71; 70, identifier:np; 71, identifier:argsort; 72, argument_list; 72, 73; 73, identifier:sort_by; 74, if_statement; 74, 75; 74, 84; 75, comparison_operator:!=; 75, 76; 75, 79; 76, attribute; 76, 77; 76, 78; 77, identifier:isort; 78, identifier:shape; 79, attribute; 79, 80; 79, 83; 80, subscript; 80, 81; 80, 82; 81, identifier:arrays; 82, integer:0; 83, identifier:shape; 84, block; 84, 85; 85, raise_statement; 85, 86; 86, call; 86, 87; 86, 88; 87, identifier:ValueError; 88, argument_list; 88, 89; 89, string:"sort shape must equal array shape."; 90, expression_statement; 90, 91; 91, assignment; 91, 92; 91, 93; 92, identifier:arrays; 93, call; 93, 94; 93, 95; 94, identifier:tuple; 95, argument_list; 95, 96; 96, list_comprehension; 96, 97; 96, 100; 97, subscript; 97, 98; 97, 99; 98, identifier:a; 99, identifier:isort; 100, for_in_clause; 100, 101; 100, 102; 101, identifier:a; 102, identifier:arrays; 103, return_statement; 103, 104; 104, identifier:arrays | def validate_inputs(*arrays, **kwargs):
arrays = np.broadcast_arrays(*arrays)
sort_by = kwargs.pop('sort_by', None)
if kwargs:
raise ValueError("unrecognized arguments: {0}".format(kwargs.keys()))
if arrays[0].ndim != 1:
raise ValueError("Input arrays should be one-dimensional.")
if sort_by is not None:
isort = np.argsort(sort_by)
if isort.shape != arrays[0].shape:
raise ValueError("sort shape must equal array shape.")
arrays = tuple([a[isort] for a in arrays])
return arrays |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:multinterp; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:x; 5, identifier:y; 6, identifier:xquery; 7, default_parameter; 7, 8; 7, 9; 8, identifier:slow; 9, False; 10, block; 10, 11; 10, 27; 10, 33; 10, 39; 10, 51; 10, 70; 11, expression_statement; 11, 12; 12, assignment; 12, 13; 12, 17; 13, pattern_list; 13, 14; 13, 15; 13, 16; 14, identifier:x; 15, identifier:y; 16, identifier:xquery; 17, call; 17, 18; 17, 19; 18, identifier:map; 19, argument_list; 19, 20; 19, 23; 20, attribute; 20, 21; 20, 22; 21, identifier:np; 22, identifier:asarray; 23, tuple; 23, 24; 23, 25; 23, 26; 24, identifier:x; 25, identifier:y; 26, identifier:xquery; 27, assert_statement; 27, 28; 28, comparison_operator:==; 28, 29; 28, 32; 29, attribute; 29, 30; 29, 31; 30, identifier:x; 31, identifier:ndim; 32, integer:1; 33, assert_statement; 33, 34; 34, comparison_operator:==; 34, 35; 34, 38; 35, attribute; 35, 36; 35, 37; 36, identifier:xquery; 37, identifier:ndim; 38, integer:1; 39, assert_statement; 39, 40; 40, comparison_operator:==; 40, 41; 40, 44; 41, attribute; 41, 42; 41, 43; 42, identifier:y; 43, identifier:shape; 44, binary_operator:+; 44, 45; 44, 48; 45, attribute; 45, 46; 45, 47; 46, identifier:x; 47, identifier:shape; 48, attribute; 48, 49; 48, 50; 49, identifier:xquery; 50, identifier:shape; 51, expression_statement; 51, 52; 52, assignment; 52, 53; 52, 54; 53, identifier:xquery; 54, call; 54, 55; 54, 58; 55, attribute; 55, 56; 55, 57; 56, identifier:np; 57, identifier:clip; 58, argument_list; 58, 59; 58, 60; 58, 65; 59, identifier:xquery; 60, call; 60, 61; 60, 64; 61, attribute; 61, 62; 61, 63; 62, identifier:x; 63, identifier:min; 64, argument_list; 65, call; 65, 66; 65, 69; 66, attribute; 66, 67; 66, 68; 67, identifier:x; 68, identifier:max; 69, argument_list; 70, if_statement; 70, 71; 70, 72; 70, 105; 70, 188; 71, identifier:slow; 72, block; 72, 73; 72, 79; 73, import_from_statement; 73, 74; 73, 77; 74, dotted_name; 74, 75; 74, 76; 75, identifier:scipy; 76, identifier:interpolate; 77, dotted_name; 77, 78; 78, identifier:interp1d; 79, return_statement; 79, 80; 80, call; 80, 81; 80, 84; 81, attribute; 81, 82; 81, 83; 82, identifier:np; 83, identifier:array; 84, argument_list; 84, 85; 85, list_comprehension; 85, 86; 85, 94; 86, call; 86, 87; 86, 92; 87, call; 87, 88; 87, 89; 88, identifier:interp1d; 89, argument_list; 89, 90; 89, 91; 90, identifier:x; 91, identifier:y; 92, argument_list; 92, 93; 93, identifier:xq; 94, for_in_clause; 94, 95; 94, 98; 95, pattern_list; 95, 96; 95, 97; 96, identifier:xq; 97, identifier:y; 98, call; 98, 99; 98, 100; 99, identifier:zip; 100, argument_list; 100, 101; 100, 102; 101, identifier:xquery; 102, attribute; 102, 103; 102, 104; 103, identifier:y; 104, identifier:T; 105, elif_clause; 105, 106; 105, 112; 106, comparison_operator:==; 106, 107; 106, 111; 107, call; 107, 108; 107, 109; 108, identifier:len; 109, argument_list; 109, 110; 110, identifier:x; 111, integer:3; 112, block; 112, 113; 112, 144; 112, 175; 113, expression_statement; 113, 114; 114, assignment; 114, 115; 114, 116; 115, identifier:yq_lower; 116, binary_operator:+; 116, 117; 116, 120; 117, subscript; 117, 118; 117, 119; 118, identifier:y; 119, integer:0; 120, binary_operator:/; 120, 121; 120, 136; 121, binary_operator:*; 121, 122; 121, 128; 122, parenthesized_expression; 122, 123; 123, binary_operator:-; 123, 124; 123, 125; 124, identifier:xquery; 125, subscript; 125, 126; 125, 127; 126, identifier:x; 127, integer:0; 128, parenthesized_expression; 128, 129; 129, binary_operator:-; 129, 130; 129, 133; 130, subscript; 130, 131; 130, 132; 131, identifier:y; 132, integer:1; 133, subscript; 133, 134; 133, 135; 134, identifier:y; 135, integer:0; 136, parenthesized_expression; 136, 137; 137, binary_operator:-; 137, 138; 137, 141; 138, subscript; 138, 139; 138, 140; 139, identifier:x; 140, integer:1; 141, subscript; 141, 142; 141, 143; 142, identifier:x; 143, integer:0; 144, expression_statement; 144, 145; 145, assignment; 145, 146; 145, 147; 146, identifier:yq_upper; 147, binary_operator:+; 147, 148; 147, 151; 148, subscript; 148, 149; 148, 150; 149, identifier:y; 150, integer:1; 151, binary_operator:/; 151, 152; 151, 167; 152, binary_operator:*; 152, 153; 152, 159; 153, parenthesized_expression; 153, 154; 154, binary_operator:-; 154, 155; 154, 156; 155, identifier:xquery; 156, subscript; 156, 157; 156, 158; 157, identifier:x; 158, integer:1; 159, parenthesized_expression; 159, 160; 160, binary_operator:-; 160, 161; 160, 164; 161, subscript; 161, 162; 161, 163; 162, identifier:y; 163, integer:2; 164, subscript; 164, 165; 164, 166; 165, identifier:y; 166, integer:1; 167, parenthesized_expression; 167, 168; 168, binary_operator:-; 168, 169; 168, 172; 169, subscript; 169, 170; 169, 171; 170, identifier:x; 171, integer:2; 172, subscript; 172, 173; 172, 174; 173, identifier:x; 174, integer:1; 175, return_statement; 175, 176; 176, call; 176, 177; 176, 180; 177, attribute; 177, 178; 177, 179; 178, identifier:np; 179, identifier:where; 180, argument_list; 180, 181; 180, 186; 180, 187; 181, comparison_operator:<; 181, 182; 181, 183; 182, identifier:xquery; 183, subscript; 183, 184; 183, 185; 184, identifier:x; 185, integer:1; 186, identifier:yq_lower; 187, identifier:yq_upper; 188, else_clause; 188, 189; 189, block; 189, 190; 189, 217; 189, 229; 190, expression_statement; 190, 191; 191, assignment; 191, 192; 191, 193; 192, identifier:i; 193, call; 193, 194; 193, 197; 194, attribute; 194, 195; 194, 196; 195, identifier:np; 196, identifier:clip; 197, argument_list; 197, 198; 197, 210; 197, 211; 198, binary_operator:-; 198, 199; 198, 209; 199, call; 199, 200; 199, 203; 200, attribute; 200, 201; 200, 202; 201, identifier:np; 202, identifier:searchsorted; 203, argument_list; 203, 204; 203, 205; 203, 206; 204, identifier:x; 205, identifier:xquery; 206, keyword_argument; 206, 207; 206, 208; 207, identifier:side; 208, string:'right'; 209, integer:1; 210, integer:0; 211, binary_operator:-; 211, 212; 211, 216; 212, call; 212, 213; 212, 214; 213, identifier:len; 214, argument_list; 214, 215; 215, identifier:x; 216, integer:2; 217, expression_statement; 217, 218; 218, assignment; 218, 219; 218, 220; 219, identifier:j; 220, call; 220, 221; 220, 224; 221, attribute; 221, 222; 221, 223; 222, identifier:np; 223, identifier:arange; 224, argument_list; 224, 225; 225, call; 225, 226; 225, 227; 226, identifier:len; 227, argument_list; 227, 228; 228, identifier:xquery; 229, return_statement; 229, 230; 230, binary_operator:+; 230, 231; 230, 235; 231, subscript; 231, 232; 231, 233; 231, 234; 232, identifier:y; 233, identifier:i; 234, identifier:j; 235, parenthesized_expression; 235, 236; 236, binary_operator:/; 236, 237; 236, 256; 237, binary_operator:*; 237, 238; 237, 244; 238, parenthesized_expression; 238, 239; 239, binary_operator:-; 239, 240; 239, 241; 240, identifier:xquery; 241, subscript; 241, 242; 241, 243; 242, identifier:x; 243, identifier:i; 244, parenthesized_expression; 244, 245; 245, binary_operator:-; 245, 246; 245, 252; 246, subscript; 246, 247; 246, 248; 246, 251; 247, identifier:y; 248, binary_operator:+; 248, 249; 248, 250; 249, identifier:i; 250, integer:1; 251, identifier:j; 252, subscript; 252, 253; 252, 254; 252, 255; 253, identifier:y; 254, identifier:i; 255, identifier:j; 256, parenthesized_expression; 256, 257; 257, binary_operator:-; 257, 258; 257, 263; 258, subscript; 258, 259; 258, 260; 259, identifier:x; 260, binary_operator:+; 260, 261; 260, 262; 261, identifier:i; 262, integer:1; 263, subscript; 263, 264; 263, 265; 264, identifier:x; 265, identifier:i | def multinterp(x, y, xquery, slow=False):
x, y, xquery = map(np.asarray, (x, y, xquery))
assert x.ndim == 1
assert xquery.ndim == 1
assert y.shape == x.shape + xquery.shape
xquery = np.clip(xquery, x.min(), x.max())
if slow:
from scipy.interpolate import interp1d
return np.array([interp1d(x, y)(xq) for xq, y in zip(xquery, y.T)])
elif len(x) == 3:
yq_lower = y[0] + (xquery - x[0]) * (y[1] - y[0]) / (x[1] - x[0])
yq_upper = y[1] + (xquery - x[1]) * (y[2] - y[1]) / (x[2] - x[1])
return np.where(xquery < x[1], yq_lower, yq_upper)
else:
i = np.clip(np.searchsorted(x, xquery, side='right') - 1,
0, len(x) - 2)
j = np.arange(len(xquery))
return y[i, j] + ((xquery - x[i]) *
(y[i + 1, j] - y[i, j]) / (x[i + 1] - x[i])) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:check_valid_time_and_sort; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 4, identifier:df; 5, identifier:timescol; 6, default_parameter; 6, 7; 6, 8; 7, identifier:days; 8, integer:5; 9, default_parameter; 9, 10; 9, 11; 10, identifier:warning; 11, True; 12, block; 12, 13; 12, 34; 13, expression_statement; 13, 14; 14, assignment; 14, 15; 14, 16; 15, identifier:timediff; 16, attribute; 16, 17; 16, 33; 17, parenthesized_expression; 17, 18; 18, binary_operator:-; 18, 19; 18, 26; 19, call; 19, 20; 19, 25; 20, attribute; 20, 21; 20, 24; 21, subscript; 21, 22; 21, 23; 22, identifier:df; 23, identifier:timescol; 24, identifier:max; 25, argument_list; 26, call; 26, 27; 26, 32; 27, attribute; 27, 28; 27, 31; 28, subscript; 28, 29; 28, 30; 29, identifier:df; 30, identifier:timescol; 31, identifier:min; 32, argument_list; 33, identifier:days; 34, if_statement; 34, 35; 34, 38; 34, 57; 35, comparison_operator:<; 35, 36; 35, 37; 36, identifier:timediff; 37, identifier:days; 38, block; 38, 39; 39, return_statement; 39, 40; 40, call; 40, 41; 40, 56; 41, attribute; 41, 42; 41, 55; 42, call; 42, 43; 42, 51; 43, attribute; 43, 44; 43, 50; 44, call; 44, 45; 44, 48; 45, attribute; 45, 46; 45, 47; 46, identifier:df; 47, identifier:sort_values; 48, argument_list; 48, 49; 49, identifier:timescol; 50, identifier:reset_index; 51, argument_list; 51, 52; 52, keyword_argument; 52, 53; 52, 54; 53, identifier:drop; 54, True; 55, identifier:reset_index; 56, argument_list; 57, else_clause; 57, 58; 58, block; 58, 59; 58, 124; 59, if_statement; 59, 60; 59, 61; 60, identifier:warning; 61, block; 61, 62; 61, 79; 61, 88; 61, 105; 62, expression_statement; 62, 63; 63, call; 63, 64; 63, 69; 64, attribute; 64, 65; 64, 68; 65, attribute; 65, 66; 65, 67; 66, identifier:sys; 67, identifier:stderr; 68, identifier:write; 69, argument_list; 69, 70; 70, call; 70, 71; 70, 74; 71, attribute; 71, 72; 71, 73; 72, string:"\nWarning: data generated is from more than {} days.\n"; 73, identifier:format; 74, argument_list; 74, 75; 75, call; 75, 76; 75, 77; 76, identifier:str; 77, argument_list; 77, 78; 78, identifier:days; 79, expression_statement; 79, 80; 80, call; 80, 81; 80, 86; 81, attribute; 81, 82; 81, 85; 82, attribute; 82, 83; 82, 84; 83, identifier:sys; 84, identifier:stderr; 85, identifier:write; 86, argument_list; 86, 87; 87, string:"Likely this indicates you are combining multiple runs.\n"; 88, expression_statement; 88, 89; 89, call; 89, 90; 89, 95; 90, attribute; 90, 91; 90, 94; 91, attribute; 91, 92; 91, 93; 92, identifier:sys; 93, identifier:stderr; 94, identifier:write; 95, argument_list; 95, 96; 96, call; 96, 97; 96, 100; 97, attribute; 97, 98; 97, 99; 98, string:"Plots based on time are invalid and therefore truncated to first {} days.\n\n"; 99, identifier:format; 100, argument_list; 100, 101; 101, call; 101, 102; 101, 103; 102, identifier:str; 103, argument_list; 103, 104; 104, identifier:days; 105, expression_statement; 105, 106; 106, call; 106, 107; 106, 110; 107, attribute; 107, 108; 107, 109; 108, identifier:logging; 109, identifier:warning; 110, argument_list; 110, 111; 111, call; 111, 112; 111, 115; 112, attribute; 112, 113; 112, 114; 113, string:"Time plots truncated to first {} days: invalid timespan: {} days"; 114, identifier:format; 115, argument_list; 115, 116; 115, 120; 116, call; 116, 117; 116, 118; 117, identifier:str; 118, argument_list; 118, 119; 119, identifier:days; 120, call; 120, 121; 120, 122; 121, identifier:str; 122, argument_list; 122, 123; 123, identifier:timediff; 124, return_statement; 124, 125; 125, call; 125, 126; 125, 155; 126, attribute; 126, 127; 126, 153; 126, 154; 127, call; 127, 128; 127, 149; 128, attribute; 128, 129; 128, 147; 128, 148; 129, call; 129, 130; 129, 145; 130, attribute; 130, 131; 130, 143; 130, 144; 131, subscript; 131, 132; 131, 133; 132, identifier:df; 133, comparison_operator:<; 133, 134; 133, 137; 134, subscript; 134, 135; 134, 136; 135, identifier:df; 136, identifier:timescol; 137, call; 137, 138; 137, 139; 138, identifier:timedelta; 139, argument_list; 139, 140; 140, keyword_argument; 140, 141; 140, 142; 141, identifier:days; 142, identifier:days; 143, line_continuation:\; 144, identifier:sort_values; 145, argument_list; 145, 146; 146, identifier:timescol; 147, line_continuation:\; 148, identifier:reset_index; 149, argument_list; 149, 150; 150, keyword_argument; 150, 151; 150, 152; 151, identifier:drop; 152, True; 153, line_continuation:\; 154, identifier:reset_index; 155, argument_list | def check_valid_time_and_sort(df, timescol, days=5, warning=True):
timediff = (df[timescol].max() - df[timescol].min()).days
if timediff < days:
return df.sort_values(timescol).reset_index(drop=True).reset_index()
else:
if warning:
sys.stderr.write(
"\nWarning: data generated is from more than {} days.\n".format(str(days)))
sys.stderr.write("Likely this indicates you are combining multiple runs.\n")
sys.stderr.write(
"Plots based on time are invalid and therefore truncated to first {} days.\n\n"
.format(str(days)))
logging.warning("Time plots truncated to first {} days: invalid timespan: {} days"
.format(str(days), str(timediff)))
return df[df[timescol] < timedelta(days=days)] \
.sort_values(timescol) \
.reset_index(drop=True) \
.reset_index() |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 18; 2, function_name:list_anime_series; 3, parameters; 3, 4; 3, 5; 3, 10; 3, 15; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:sort; 7, attribute; 7, 8; 7, 9; 8, identifier:META; 9, identifier:SORT_ALPHA; 10, default_parameter; 10, 11; 10, 12; 11, identifier:limit; 12, attribute; 12, 13; 12, 14; 13, identifier:META; 14, identifier:MAX_SERIES; 15, default_parameter; 15, 16; 15, 17; 16, identifier:offset; 17, integer:0; 18, block; 18, 19; 18, 43; 19, expression_statement; 19, 20; 20, assignment; 20, 21; 20, 22; 21, identifier:result; 22, call; 22, 23; 22, 28; 23, attribute; 23, 24; 23, 27; 24, attribute; 24, 25; 24, 26; 25, identifier:self; 26, identifier:_android_api; 27, identifier:list_series; 28, argument_list; 28, 29; 28, 34; 28, 37; 28, 40; 29, keyword_argument; 29, 30; 29, 31; 30, identifier:media_type; 31, attribute; 31, 32; 31, 33; 32, identifier:ANDROID; 33, identifier:MEDIA_TYPE_ANIME; 34, keyword_argument; 34, 35; 34, 36; 35, identifier:filter; 36, identifier:sort; 37, keyword_argument; 37, 38; 37, 39; 38, identifier:limit; 39, identifier:limit; 40, keyword_argument; 40, 41; 40, 42; 41, identifier:offset; 42, identifier:offset; 43, return_statement; 43, 44; 44, identifier:result | def list_anime_series(self, sort=META.SORT_ALPHA, limit=META.MAX_SERIES, offset=0):
result = self._android_api.list_series(
media_type=ANDROID.MEDIA_TYPE_ANIME,
filter=sort,
limit=limit,
offset=offset)
return result |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 18; 2, function_name:list_drama_series; 3, parameters; 3, 4; 3, 5; 3, 10; 3, 15; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:sort; 7, attribute; 7, 8; 7, 9; 8, identifier:META; 9, identifier:SORT_ALPHA; 10, default_parameter; 10, 11; 10, 12; 11, identifier:limit; 12, attribute; 12, 13; 12, 14; 13, identifier:META; 14, identifier:MAX_SERIES; 15, default_parameter; 15, 16; 15, 17; 16, identifier:offset; 17, integer:0; 18, block; 18, 19; 18, 43; 19, expression_statement; 19, 20; 20, assignment; 20, 21; 20, 22; 21, identifier:result; 22, call; 22, 23; 22, 28; 23, attribute; 23, 24; 23, 27; 24, attribute; 24, 25; 24, 26; 25, identifier:self; 26, identifier:_android_api; 27, identifier:list_series; 28, argument_list; 28, 29; 28, 34; 28, 37; 28, 40; 29, keyword_argument; 29, 30; 29, 31; 30, identifier:media_type; 31, attribute; 31, 32; 31, 33; 32, identifier:ANDROID; 33, identifier:MEDIA_TYPE_DRAMA; 34, keyword_argument; 34, 35; 34, 36; 35, identifier:filter; 36, identifier:sort; 37, keyword_argument; 37, 38; 37, 39; 38, identifier:limit; 39, identifier:limit; 40, keyword_argument; 40, 41; 40, 42; 41, identifier:offset; 42, identifier:offset; 43, return_statement; 43, 44; 44, identifier:result | def list_drama_series(self, sort=META.SORT_ALPHA, limit=META.MAX_SERIES, offset=0):
result = self._android_api.list_series(
media_type=ANDROID.MEDIA_TYPE_DRAMA,
filter=sort,
limit=limit,
offset=offset)
return result |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 19; 2, function_name:list_media; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 11; 3, 16; 4, identifier:self; 5, identifier:series; 6, default_parameter; 6, 7; 6, 8; 7, identifier:sort; 8, attribute; 8, 9; 8, 10; 9, identifier:META; 10, identifier:SORT_DESC; 11, default_parameter; 11, 12; 11, 13; 12, identifier:limit; 13, attribute; 13, 14; 13, 15; 14, identifier:META; 15, identifier:MAX_MEDIA; 16, default_parameter; 16, 17; 16, 18; 17, identifier:offset; 18, integer:0; 19, block; 19, 20; 19, 33; 19, 45; 19, 57; 20, expression_statement; 20, 21; 21, assignment; 21, 22; 21, 23; 22, identifier:params; 23, dictionary; 23, 24; 23, 27; 23, 30; 24, pair; 24, 25; 24, 26; 25, string:'sort'; 26, identifier:sort; 27, pair; 27, 28; 27, 29; 28, string:'offset'; 29, identifier:offset; 30, pair; 30, 31; 30, 32; 31, string:'limit'; 32, identifier:limit; 33, expression_statement; 33, 34; 34, call; 34, 35; 34, 38; 35, attribute; 35, 36; 35, 37; 36, identifier:params; 37, identifier:update; 38, argument_list; 38, 39; 39, call; 39, 40; 39, 43; 40, attribute; 40, 41; 40, 42; 41, identifier:self; 42, identifier:_get_series_query_dict; 43, argument_list; 43, 44; 44, identifier:series; 45, expression_statement; 45, 46; 46, assignment; 46, 47; 46, 48; 47, identifier:result; 48, call; 48, 49; 48, 54; 49, attribute; 49, 50; 49, 53; 50, attribute; 50, 51; 50, 52; 51, identifier:self; 52, identifier:_android_api; 53, identifier:list_media; 54, argument_list; 54, 55; 55, dictionary_splat; 55, 56; 56, identifier:params; 57, return_statement; 57, 58; 58, identifier:result | def list_media(self, series, sort=META.SORT_DESC, limit=META.MAX_MEDIA, offset=0):
params = {
'sort': sort,
'offset': offset,
'limit': limit,
}
params.update(self._get_series_query_dict(series))
result = self._android_api.list_media(**params)
return result |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:solve_sort; 3, parameters; 3, 4; 3, 5; 4, identifier:expr; 5, identifier:vars; 6, block; 6, 7; 6, 24; 6, 30; 6, 50; 6, 62; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:lhs_values; 10, call; 10, 11; 10, 14; 11, attribute; 11, 12; 11, 13; 12, identifier:repeated; 13, identifier:getvalues; 14, argument_list; 14, 15; 15, subscript; 15, 16; 15, 23; 16, call; 16, 17; 16, 18; 17, identifier:__solve_for_repeated; 18, argument_list; 18, 19; 18, 22; 19, attribute; 19, 20; 19, 21; 20, identifier:expr; 21, identifier:lhs; 22, identifier:vars; 23, integer:0; 24, expression_statement; 24, 25; 25, assignment; 25, 26; 25, 27; 26, identifier:sort_expression; 27, attribute; 27, 28; 27, 29; 28, identifier:expr; 29, identifier:rhs; 30, function_definition; 30, 31; 30, 32; 30, 34; 31, function_name:_key_func; 32, parameters; 32, 33; 33, identifier:x; 34, block; 34, 35; 35, return_statement; 35, 36; 36, attribute; 36, 37; 36, 49; 37, call; 37, 38; 37, 39; 38, identifier:solve; 39, argument_list; 39, 40; 39, 41; 40, identifier:sort_expression; 41, call; 41, 42; 41, 43; 42, identifier:__nest_scope; 43, argument_list; 43, 44; 43, 47; 43, 48; 44, attribute; 44, 45; 44, 46; 45, identifier:expr; 46, identifier:lhs; 47, identifier:vars; 48, identifier:x; 49, identifier:value; 50, expression_statement; 50, 51; 51, assignment; 51, 52; 51, 53; 52, identifier:results; 53, call; 53, 54; 53, 57; 54, attribute; 54, 55; 54, 56; 55, identifier:ordered; 56, identifier:ordered; 57, argument_list; 57, 58; 57, 59; 58, identifier:lhs_values; 59, keyword_argument; 59, 60; 59, 61; 60, identifier:key_func; 61, identifier:_key_func; 62, return_statement; 62, 63; 63, call; 63, 64; 63, 65; 64, identifier:Result; 65, argument_list; 65, 66; 65, 73; 66, call; 66, 67; 66, 70; 67, attribute; 67, 68; 67, 69; 68, identifier:repeated; 69, identifier:meld; 70, argument_list; 70, 71; 71, list_splat; 71, 72; 72, identifier:results; 73, tuple | def solve_sort(expr, vars):
lhs_values = repeated.getvalues(__solve_for_repeated(expr.lhs, vars)[0])
sort_expression = expr.rhs
def _key_func(x):
return solve(sort_expression, __nest_scope(expr.lhs, vars, x)).value
results = ordered.ordered(lhs_values, key_func=_key_func)
return Result(repeated.meld(*results), ()) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:expression; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:previous_precedence; 7, integer:0; 8, block; 8, 9; 8, 17; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 11, identifier:lhs; 12, call; 12, 13; 12, 16; 13, attribute; 13, 14; 13, 15; 14, identifier:self; 15, identifier:atom; 16, argument_list; 17, return_statement; 17, 18; 18, call; 18, 19; 18, 22; 19, attribute; 19, 20; 19, 21; 20, identifier:self; 21, identifier:operator; 22, argument_list; 22, 23; 22, 24; 23, identifier:lhs; 24, identifier:previous_precedence | def expression(self, previous_precedence=0):
lhs = self.atom()
return self.operator(lhs, previous_precedence) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:application; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:func; 6, block; 6, 7; 6, 17; 6, 53; 6, 62; 6, 85; 6, 96; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:start; 10, attribute; 10, 11; 10, 16; 11, attribute; 11, 12; 11, 15; 12, attribute; 12, 13; 12, 14; 13, identifier:self; 14, identifier:tokens; 15, identifier:matched; 16, identifier:start; 17, if_statement; 17, 18; 17, 28; 18, call; 18, 19; 18, 24; 19, attribute; 19, 20; 19, 23; 20, attribute; 20, 21; 20, 22; 21, identifier:self; 22, identifier:tokens; 23, identifier:accept; 24, argument_list; 24, 25; 25, attribute; 25, 26; 25, 27; 26, identifier:common_grammar; 27, identifier:rparen; 28, block; 28, 29; 29, return_statement; 29, 30; 30, call; 30, 31; 30, 34; 31, attribute; 31, 32; 31, 33; 32, identifier:ast; 33, identifier:Apply; 34, argument_list; 34, 35; 34, 36; 34, 39; 34, 48; 35, identifier:func; 36, keyword_argument; 36, 37; 36, 38; 37, identifier:start; 38, identifier:start; 39, keyword_argument; 39, 40; 39, 41; 40, identifier:end; 41, attribute; 41, 42; 41, 47; 42, attribute; 42, 43; 42, 46; 43, attribute; 43, 44; 43, 45; 44, identifier:self; 45, identifier:tokens; 46, identifier:matched; 47, identifier:end; 48, keyword_argument; 48, 49; 48, 50; 49, identifier:source; 50, attribute; 50, 51; 50, 52; 51, identifier:self; 52, identifier:original; 53, expression_statement; 53, 54; 54, assignment; 54, 55; 54, 56; 55, identifier:arguments; 56, list:[self.expression()]; 56, 57; 57, call; 57, 58; 57, 61; 58, attribute; 58, 59; 58, 60; 59, identifier:self; 60, identifier:expression; 61, argument_list; 62, while_statement; 62, 63; 62, 73; 63, call; 63, 64; 63, 69; 64, attribute; 64, 65; 64, 68; 65, attribute; 65, 66; 65, 67; 66, identifier:self; 67, identifier:tokens; 68, identifier:accept; 69, argument_list; 69, 70; 70, attribute; 70, 71; 70, 72; 71, identifier:common_grammar; 72, identifier:comma; 73, block; 73, 74; 74, expression_statement; 74, 75; 75, call; 75, 76; 75, 79; 76, attribute; 76, 77; 76, 78; 77, identifier:arguments; 78, identifier:append; 79, argument_list; 79, 80; 80, call; 80, 81; 80, 84; 81, attribute; 81, 82; 81, 83; 82, identifier:self; 83, identifier:expression; 84, argument_list; 85, expression_statement; 85, 86; 86, call; 86, 87; 86, 92; 87, attribute; 87, 88; 87, 91; 88, attribute; 88, 89; 88, 90; 89, identifier:self; 90, identifier:tokens; 91, identifier:expect; 92, argument_list; 92, 93; 93, attribute; 93, 94; 93, 95; 94, identifier:common_grammar; 95, identifier:rparen; 96, return_statement; 96, 97; 97, call; 97, 98; 97, 101; 98, attribute; 98, 99; 98, 100; 99, identifier:ast; 100, identifier:Apply; 101, argument_list; 101, 102; 101, 103; 101, 105; 101, 108; 101, 117; 102, identifier:func; 103, list_splat; 103, 104; 104, identifier:arguments; 105, keyword_argument; 105, 106; 105, 107; 106, identifier:start; 107, identifier:start; 108, keyword_argument; 108, 109; 108, 110; 109, identifier:end; 110, attribute; 110, 111; 110, 116; 111, attribute; 111, 112; 111, 115; 112, attribute; 112, 113; 112, 114; 113, identifier:self; 114, identifier:tokens; 115, identifier:matched; 116, identifier:end; 117, keyword_argument; 117, 118; 117, 119; 118, identifier:source; 119, attribute; 119, 120; 119, 121; 120, identifier:self; 121, identifier:original | def application(self, func):
start = self.tokens.matched.start
if self.tokens.accept(common_grammar.rparen):
return ast.Apply(func, start=start, end=self.tokens.matched.end,
source=self.original)
arguments = [self.expression()]
while self.tokens.accept(common_grammar.comma):
arguments.append(self.expression())
self.tokens.expect(common_grammar.rparen)
return ast.Apply(func, *arguments, start=start,
end=self.tokens.matched.end, source=self.original) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:value_eq; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:other; 6, block; 6, 7; 6, 20; 6, 34; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:self_sorted; 10, call; 10, 11; 10, 14; 11, attribute; 11, 12; 11, 13; 12, identifier:ordered; 13, identifier:ordered; 14, argument_list; 14, 15; 15, call; 15, 16; 15, 19; 16, attribute; 16, 17; 16, 18; 17, identifier:self; 18, identifier:getvalues; 19, argument_list; 20, expression_statement; 20, 21; 21, assignment; 21, 22; 21, 23; 22, identifier:other_sorted; 23, call; 23, 24; 23, 27; 24, attribute; 24, 25; 24, 26; 25, identifier:ordered; 26, identifier:ordered; 27, argument_list; 27, 28; 28, call; 28, 29; 28, 32; 29, attribute; 29, 30; 29, 31; 30, identifier:repeated; 31, identifier:getvalues; 32, argument_list; 32, 33; 33, identifier:other; 34, return_statement; 34, 35; 35, comparison_operator:==; 35, 36; 35, 37; 36, identifier:self_sorted; 37, identifier:other_sorted | def value_eq(self, other):
self_sorted = ordered.ordered(self.getvalues())
other_sorted = ordered.ordered(repeated.getvalues(other))
return self_sorted == other_sorted |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:merge; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:a_intervals; 5, identifier:b_intervals; 6, identifier:op; 7, block; 7, 8; 7, 20; 7, 32; 7, 48; 7, 53; 7, 58; 7, 62; 7, 66; 7, 70; 7, 82; 7, 177; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:a_endpoints; 11, call; 11, 12; 11, 19; 12, attribute; 12, 13; 12, 18; 13, call; 13, 14; 13, 17; 14, attribute; 14, 15; 14, 16; 15, identifier:a_intervals; 16, identifier:flatten; 17, argument_list; 18, identifier:tolist; 19, argument_list; 20, expression_statement; 20, 21; 21, assignment; 21, 22; 21, 23; 22, identifier:b_endpoints; 23, call; 23, 24; 23, 31; 24, attribute; 24, 25; 24, 30; 25, call; 25, 26; 25, 29; 26, attribute; 26, 27; 26, 28; 27, identifier:b_intervals; 28, identifier:flatten; 29, argument_list; 30, identifier:tolist; 31, argument_list; 32, expression_statement; 32, 33; 33, assignment; 33, 34; 33, 35; 34, identifier:sentinel; 35, binary_operator:+; 35, 36; 35, 47; 36, call; 36, 37; 36, 38; 37, identifier:max; 38, argument_list; 38, 39; 38, 43; 39, subscript; 39, 40; 39, 41; 40, identifier:a_endpoints; 41, unary_operator:-; 41, 42; 42, integer:1; 43, subscript; 43, 44; 43, 45; 44, identifier:b_endpoints; 45, unary_operator:-; 45, 46; 46, integer:1; 47, integer:1; 48, expression_statement; 48, 49; 49, augmented_assignment:+=; 49, 50; 49, 51; 50, identifier:a_endpoints; 51, list:[sentinel]; 51, 52; 52, identifier:sentinel; 53, expression_statement; 53, 54; 54, augmented_assignment:+=; 54, 55; 54, 56; 55, identifier:b_endpoints; 56, list:[sentinel]; 56, 57; 57, identifier:sentinel; 58, expression_statement; 58, 59; 59, assignment; 59, 60; 59, 61; 60, identifier:a_index; 61, integer:0; 62, expression_statement; 62, 63; 63, assignment; 63, 64; 63, 65; 64, identifier:b_index; 65, integer:0; 66, expression_statement; 66, 67; 67, assignment; 67, 68; 67, 69; 68, identifier:res; 69, list:[]; 70, expression_statement; 70, 71; 71, assignment; 71, 72; 71, 73; 72, identifier:scan; 73, call; 73, 74; 73, 75; 74, identifier:min; 75, argument_list; 75, 76; 75, 79; 76, subscript; 76, 77; 76, 78; 77, identifier:a_endpoints; 78, integer:0; 79, subscript; 79, 80; 79, 81; 80, identifier:b_endpoints; 81, integer:0; 82, while_statement; 82, 83; 82, 86; 83, comparison_operator:<; 83, 84; 83, 85; 84, identifier:scan; 85, identifier:sentinel; 86, block; 86, 87; 86, 103; 86, 119; 86, 127; 86, 143; 86, 154; 86, 165; 87, expression_statement; 87, 88; 88, assignment; 88, 89; 88, 90; 89, identifier:in_a; 90, not_operator; 90, 91; 91, parenthesized_expression; 91, 92; 92, binary_operator:^; 92, 93; 92, 99; 93, parenthesized_expression; 93, 94; 94, comparison_operator:<; 94, 95; 94, 96; 95, identifier:scan; 96, subscript; 96, 97; 96, 98; 97, identifier:a_endpoints; 98, identifier:a_index; 99, parenthesized_expression; 99, 100; 100, binary_operator:%; 100, 101; 100, 102; 101, identifier:a_index; 102, integer:2; 103, expression_statement; 103, 104; 104, assignment; 104, 105; 104, 106; 105, identifier:in_b; 106, not_operator; 106, 107; 107, parenthesized_expression; 107, 108; 108, binary_operator:^; 108, 109; 108, 115; 109, parenthesized_expression; 109, 110; 110, comparison_operator:<; 110, 111; 110, 112; 111, identifier:scan; 112, subscript; 112, 113; 112, 114; 113, identifier:b_endpoints; 114, identifier:b_index; 115, parenthesized_expression; 115, 116; 116, binary_operator:%; 116, 117; 116, 118; 117, identifier:b_index; 118, integer:2; 119, expression_statement; 119, 120; 120, assignment; 120, 121; 120, 122; 121, identifier:in_res; 122, call; 122, 123; 122, 124; 123, identifier:op; 124, argument_list; 124, 125; 124, 126; 125, identifier:in_a; 126, identifier:in_b; 127, if_statement; 127, 128; 127, 137; 128, binary_operator:^; 128, 129; 128, 130; 129, identifier:in_res; 130, parenthesized_expression; 130, 131; 131, binary_operator:%; 131, 132; 131, 136; 132, call; 132, 133; 132, 134; 133, identifier:len; 134, argument_list; 134, 135; 135, identifier:res; 136, integer:2; 137, block; 137, 138; 138, expression_statement; 138, 139; 139, augmented_assignment:+=; 139, 140; 139, 141; 140, identifier:res; 141, list:[scan]; 141, 142; 142, identifier:scan; 143, if_statement; 143, 144; 143, 149; 144, comparison_operator:==; 144, 145; 144, 146; 145, identifier:scan; 146, subscript; 146, 147; 146, 148; 147, identifier:a_endpoints; 148, identifier:a_index; 149, block; 149, 150; 150, expression_statement; 150, 151; 151, augmented_assignment:+=; 151, 152; 151, 153; 152, identifier:a_index; 153, integer:1; 154, if_statement; 154, 155; 154, 160; 155, comparison_operator:==; 155, 156; 155, 157; 156, identifier:scan; 157, subscript; 157, 158; 157, 159; 158, identifier:b_endpoints; 159, identifier:b_index; 160, block; 160, 161; 161, expression_statement; 161, 162; 162, augmented_assignment:+=; 162, 163; 162, 164; 163, identifier:b_index; 164, integer:1; 165, expression_statement; 165, 166; 166, assignment; 166, 167; 166, 168; 167, identifier:scan; 168, call; 168, 169; 168, 170; 169, identifier:min; 170, argument_list; 170, 171; 170, 174; 171, subscript; 171, 172; 171, 173; 172, identifier:a_endpoints; 173, identifier:a_index; 174, subscript; 174, 175; 174, 176; 175, identifier:b_endpoints; 176, identifier:b_index; 177, return_statement; 177, 178; 178, call; 178, 179; 178, 187; 179, attribute; 179, 180; 179, 186; 180, call; 180, 181; 180, 184; 181, attribute; 181, 182; 181, 183; 182, identifier:np; 183, identifier:asarray; 184, argument_list; 184, 185; 185, identifier:res; 186, identifier:reshape; 187, argument_list; 187, 188; 188, tuple; 188, 189; 188, 191; 189, unary_operator:-; 189, 190; 190, integer:1; 191, integer:2 | def merge(a_intervals, b_intervals, op):
a_endpoints = a_intervals.flatten().tolist()
b_endpoints = b_intervals.flatten().tolist()
sentinel = max(a_endpoints[-1], b_endpoints[-1]) + 1
a_endpoints += [sentinel]
b_endpoints += [sentinel]
a_index = 0
b_index = 0
res = []
scan = min(a_endpoints[0], b_endpoints[0])
while scan < sentinel:
in_a = not ((scan < a_endpoints[a_index]) ^ (a_index % 2))
in_b = not ((scan < b_endpoints[b_index]) ^ (b_index % 2))
in_res = op(in_a, in_b)
if in_res ^ (len(res) % 2):
res += [scan]
if scan == a_endpoints[a_index]:
a_index += 1
if scan == b_endpoints[b_index]:
b_index += 1
scan = min(a_endpoints[a_index], b_endpoints[b_index])
return np.asarray(res).reshape((-1, 2)) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:check_bam; 3, parameters; 3, 4; 3, 5; 4, identifier:bam; 5, default_parameter; 5, 6; 5, 7; 6, identifier:samtype; 7, string:"bam"; 8, block; 8, 9; 8, 16; 8, 26; 8, 58; 8, 89; 8, 143; 9, expression_statement; 9, 10; 10, call; 10, 11; 10, 14; 11, attribute; 11, 12; 11, 13; 12, identifier:ut; 13, identifier:check_existance; 14, argument_list; 14, 15; 15, identifier:bam; 16, expression_statement; 16, 17; 17, assignment; 17, 18; 17, 19; 18, identifier:samfile; 19, call; 19, 20; 19, 23; 20, attribute; 20, 21; 20, 22; 21, identifier:pysam; 22, identifier:AlignmentFile; 23, argument_list; 23, 24; 23, 25; 24, identifier:bam; 25, string:"rb"; 26, if_statement; 26, 27; 26, 33; 27, not_operator; 27, 28; 28, call; 28, 29; 28, 32; 29, attribute; 29, 30; 29, 31; 30, identifier:samfile; 31, identifier:has_index; 32, argument_list; 33, block; 33, 34; 33, 41; 33, 51; 34, expression_statement; 34, 35; 35, call; 35, 36; 35, 39; 36, attribute; 36, 37; 36, 38; 37, identifier:pysam; 38, identifier:index; 39, argument_list; 39, 40; 40, identifier:bam; 41, expression_statement; 41, 42; 42, assignment; 42, 43; 42, 44; 43, identifier:samfile; 44, call; 44, 45; 44, 48; 45, attribute; 45, 46; 45, 47; 46, identifier:pysam; 47, identifier:AlignmentFile; 48, argument_list; 48, 49; 48, 50; 49, identifier:bam; 50, string:"rb"; 51, expression_statement; 51, 52; 52, call; 52, 53; 52, 56; 53, attribute; 53, 54; 53, 55; 54, identifier:logging; 55, identifier:info; 56, argument_list; 56, 57; 57, string:"Nanoget: No index for bam file could be found, created index."; 58, if_statement; 58, 59; 58, 69; 59, not_operator; 59, 60; 60, comparison_operator:==; 60, 61; 60, 68; 61, subscript; 61, 62; 61, 67; 62, subscript; 62, 63; 62, 66; 63, attribute; 63, 64; 63, 65; 64, identifier:samfile; 65, identifier:header; 66, string:'HD'; 67, string:'SO'; 68, string:'coordinate'; 69, block; 69, 70; 69, 82; 70, expression_statement; 70, 71; 71, call; 71, 72; 71, 75; 72, attribute; 72, 73; 72, 74; 73, identifier:logging; 74, identifier:error; 75, argument_list; 75, 76; 76, call; 76, 77; 76, 80; 77, attribute; 77, 78; 77, 79; 78, string:"Nanoget: Bam file {} not sorted by coordinate!."; 79, identifier:format; 80, argument_list; 80, 81; 81, identifier:bam; 82, expression_statement; 82, 83; 83, call; 83, 84; 83, 87; 84, attribute; 84, 85; 84, 86; 85, identifier:sys; 86, identifier:exit; 87, argument_list; 87, 88; 88, string:"Please use a bam file sorted by coordinate."; 89, if_statement; 89, 90; 89, 93; 90, comparison_operator:==; 90, 91; 90, 92; 91, identifier:samtype; 92, string:"bam"; 93, block; 93, 94; 93, 112; 94, expression_statement; 94, 95; 95, call; 95, 96; 95, 99; 96, attribute; 96, 97; 96, 98; 97, identifier:logging; 98, identifier:info; 99, argument_list; 99, 100; 100, call; 100, 101; 100, 104; 101, attribute; 101, 102; 101, 103; 102, string:"Nanoget: Bam file {} contains {} mapped and {} unmapped reads."; 103, identifier:format; 104, argument_list; 104, 105; 104, 106; 104, 109; 105, identifier:bam; 106, attribute; 106, 107; 106, 108; 107, identifier:samfile; 108, identifier:mapped; 109, attribute; 109, 110; 109, 111; 110, identifier:samfile; 111, identifier:unmapped; 112, if_statement; 112, 113; 112, 118; 113, comparison_operator:==; 113, 114; 113, 117; 114, attribute; 114, 115; 114, 116; 115, identifier:samfile; 116, identifier:mapped; 117, integer:0; 118, block; 118, 119; 118, 131; 119, expression_statement; 119, 120; 120, call; 120, 121; 120, 124; 121, attribute; 121, 122; 121, 123; 122, identifier:logging; 123, identifier:error; 124, argument_list; 124, 125; 125, call; 125, 126; 125, 129; 126, attribute; 126, 127; 126, 128; 127, string:"Nanoget: Bam file {} does not contain aligned reads."; 128, identifier:format; 129, argument_list; 129, 130; 130, identifier:bam; 131, expression_statement; 131, 132; 132, call; 132, 133; 132, 136; 133, attribute; 133, 134; 133, 135; 134, identifier:sys; 135, identifier:exit; 136, argument_list; 136, 137; 137, call; 137, 138; 137, 141; 138, attribute; 138, 139; 138, 140; 139, string:"FATAL: not a single read was mapped in bam file {}"; 140, identifier:format; 141, argument_list; 141, 142; 142, identifier:bam; 143, return_statement; 143, 144; 144, identifier:samfile | def check_bam(bam, samtype="bam"):
ut.check_existance(bam)
samfile = pysam.AlignmentFile(bam, "rb")
if not samfile.has_index():
pysam.index(bam)
samfile = pysam.AlignmentFile(bam, "rb")
logging.info("Nanoget: No index for bam file could be found, created index.")
if not samfile.header['HD']['SO'] == 'coordinate':
logging.error("Nanoget: Bam file {} not sorted by coordinate!.".format(bam))
sys.exit("Please use a bam file sorted by coordinate.")
if samtype == "bam":
logging.info("Nanoget: Bam file {} contains {} mapped and {} unmapped reads.".format(
bam, samfile.mapped, samfile.unmapped))
if samfile.mapped == 0:
logging.error("Nanoget: Bam file {} does not contain aligned reads.".format(bam))
sys.exit("FATAL: not a single read was mapped in bam file {}".format(bam))
return samfile |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 21; 2, function_name:get_input; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 3, 18; 4, identifier:source; 5, identifier:files; 6, default_parameter; 6, 7; 6, 8; 7, identifier:threads; 8, integer:4; 9, default_parameter; 9, 10; 9, 11; 10, identifier:readtype; 11, string:"1D"; 12, default_parameter; 12, 13; 12, 14; 13, identifier:combine; 14, string:"simple"; 15, default_parameter; 15, 16; 15, 17; 16, identifier:names; 17, None; 18, default_parameter; 18, 19; 18, 20; 19, identifier:barcoded; 20, False; 21, block; 21, 22; 21, 66; 21, 77; 21, 83; 21, 143; 21, 174; 21, 181; 21, 196; 22, expression_statement; 22, 23; 23, assignment; 23, 24; 23, 25; 24, identifier:proc_functions; 25, dictionary; 25, 26; 25, 31; 25, 36; 25, 41; 25, 46; 25, 51; 25, 56; 25, 61; 26, pair; 26, 27; 26, 28; 27, string:'fastq'; 28, attribute; 28, 29; 28, 30; 29, identifier:ex; 30, identifier:process_fastq_plain; 31, pair; 31, 32; 31, 33; 32, string:'fasta'; 33, attribute; 33, 34; 33, 35; 34, identifier:ex; 35, identifier:process_fasta; 36, pair; 36, 37; 36, 38; 37, string:'bam'; 38, attribute; 38, 39; 38, 40; 39, identifier:ex; 40, identifier:process_bam; 41, pair; 41, 42; 41, 43; 42, string:'summary'; 43, attribute; 43, 44; 43, 45; 44, identifier:ex; 45, identifier:process_summary; 46, pair; 46, 47; 46, 48; 47, string:'fastq_rich'; 48, attribute; 48, 49; 48, 50; 49, identifier:ex; 50, identifier:process_fastq_rich; 51, pair; 51, 52; 51, 53; 52, string:'fastq_minimal'; 53, attribute; 53, 54; 53, 55; 54, identifier:ex; 55, identifier:process_fastq_minimal; 56, pair; 56, 57; 56, 58; 57, string:'cram'; 58, attribute; 58, 59; 58, 60; 59, identifier:ex; 60, identifier:process_cram; 61, pair; 61, 62; 61, 63; 62, string:'ubam'; 63, attribute; 63, 64; 63, 65; 64, identifier:ex; 65, identifier:process_ubam; 66, expression_statement; 66, 67; 67, assignment; 67, 68; 67, 69; 68, identifier:filethreads; 69, call; 69, 70; 69, 71; 70, identifier:min; 71, argument_list; 71, 72; 71, 76; 72, call; 72, 73; 72, 74; 73, identifier:len; 74, argument_list; 74, 75; 75, identifier:files; 76, identifier:threads; 77, expression_statement; 77, 78; 78, assignment; 78, 79; 78, 80; 79, identifier:threadsleft; 80, binary_operator:-; 80, 81; 80, 82; 81, identifier:threads; 82, identifier:filethreads; 83, with_statement; 83, 84; 83, 97; 84, with_clause; 84, 85; 85, with_item; 85, 86; 86, as_pattern; 86, 87; 86, 95; 87, call; 87, 88; 87, 91; 88, attribute; 88, 89; 88, 90; 89, identifier:cfutures; 90, identifier:ProcessPoolExecutor; 91, argument_list; 91, 92; 92, keyword_argument; 92, 93; 92, 94; 93, identifier:max_workers; 94, identifier:filethreads; 95, as_pattern_target; 95, 96; 96, identifier:executor; 97, block; 97, 98; 97, 116; 98, expression_statement; 98, 99; 99, assignment; 99, 100; 99, 101; 100, identifier:extration_function; 101, call; 101, 102; 101, 103; 102, identifier:partial; 103, argument_list; 103, 104; 103, 107; 103, 110; 103, 113; 104, subscript; 104, 105; 104, 106; 105, identifier:proc_functions; 106, identifier:source; 107, keyword_argument; 107, 108; 107, 109; 108, identifier:threads; 109, identifier:threadsleft; 110, keyword_argument; 110, 111; 110, 112; 111, identifier:readtype; 112, identifier:readtype; 113, keyword_argument; 113, 114; 113, 115; 114, identifier:barcoded; 115, identifier:barcoded; 116, expression_statement; 116, 117; 117, assignment; 117, 118; 117, 119; 118, identifier:datadf; 119, call; 119, 120; 119, 121; 120, identifier:combine_dfs; 121, argument_list; 121, 122; 121, 135; 121, 140; 122, keyword_argument; 122, 123; 122, 124; 123, identifier:dfs; 124, list_comprehension; 124, 125; 124, 126; 125, identifier:out; 126, for_in_clause; 126, 127; 126, 128; 127, identifier:out; 128, call; 128, 129; 128, 132; 129, attribute; 129, 130; 129, 131; 130, identifier:executor; 131, identifier:map; 132, argument_list; 132, 133; 132, 134; 133, identifier:extration_function; 134, identifier:files; 135, keyword_argument; 135, 136; 135, 137; 136, identifier:names; 137, boolean_operator:or; 137, 138; 137, 139; 138, identifier:names; 139, identifier:files; 140, keyword_argument; 140, 141; 140, 142; 141, identifier:method; 142, identifier:combine; 143, if_statement; 143, 144; 143, 160; 144, boolean_operator:and; 144, 145; 144, 148; 145, comparison_operator:in; 145, 146; 145, 147; 146, string:"readIDs"; 147, identifier:datadf; 148, call; 148, 149; 148, 159; 149, attribute; 149, 150; 149, 158; 150, call; 150, 151; 150, 154; 151, attribute; 151, 152; 151, 153; 152, identifier:pd; 153, identifier:isna; 154, argument_list; 154, 155; 155, subscript; 155, 156; 155, 157; 156, identifier:datadf; 157, string:"readIDs"; 158, identifier:any; 159, argument_list; 160, block; 160, 161; 161, expression_statement; 161, 162; 162, call; 162, 163; 162, 166; 163, attribute; 163, 164; 163, 165; 164, identifier:datadf; 165, identifier:drop; 166, argument_list; 166, 167; 166, 168; 166, 171; 167, string:"readIDs"; 168, keyword_argument; 168, 169; 168, 170; 169, identifier:axis; 170, string:'columns'; 171, keyword_argument; 171, 172; 171, 173; 172, identifier:inplace; 173, True; 174, expression_statement; 174, 175; 175, assignment; 175, 176; 175, 177; 176, identifier:datadf; 177, call; 177, 178; 177, 179; 178, identifier:calculate_start_time; 179, argument_list; 179, 180; 180, identifier:datadf; 181, expression_statement; 181, 182; 182, call; 182, 183; 182, 186; 183, attribute; 183, 184; 183, 185; 184, identifier:logging; 185, identifier:info; 186, argument_list; 186, 187; 187, call; 187, 188; 187, 191; 188, attribute; 188, 189; 188, 190; 189, string:"Nanoget: Gathered all metrics of {} reads"; 190, identifier:format; 191, argument_list; 191, 192; 192, call; 192, 193; 192, 194; 193, identifier:len; 194, argument_list; 194, 195; 195, identifier:datadf; 196, if_statement; 196, 197; 196, 203; 196, 226; 197, comparison_operator:==; 197, 198; 197, 202; 198, call; 198, 199; 198, 200; 199, identifier:len; 200, argument_list; 200, 201; 201, identifier:datadf; 202, integer:0; 203, block; 203, 204; 203, 219; 204, expression_statement; 204, 205; 205, call; 205, 206; 205, 209; 206, attribute; 206, 207; 206, 208; 207, identifier:logging; 208, identifier:critical; 209, argument_list; 209, 210; 210, call; 210, 211; 210, 214; 211, attribute; 211, 212; 211, 213; 212, string:"Nanoget: no reads retrieved."; 213, identifier:format; 214, argument_list; 214, 215; 215, call; 215, 216; 215, 217; 216, identifier:len; 217, argument_list; 217, 218; 218, identifier:datadf; 219, expression_statement; 219, 220; 220, call; 220, 221; 220, 224; 221, attribute; 221, 222; 221, 223; 222, identifier:sys; 223, identifier:exit; 224, argument_list; 224, 225; 225, string:"Fatal: No reads found in input."; 226, else_clause; 226, 227; 227, block; 227, 228; 228, return_statement; 228, 229; 229, identifier:datadf | def get_input(source, files, threads=4, readtype="1D",
combine="simple", names=None, barcoded=False):
proc_functions = {
'fastq': ex.process_fastq_plain,
'fasta': ex.process_fasta,
'bam': ex.process_bam,
'summary': ex.process_summary,
'fastq_rich': ex.process_fastq_rich,
'fastq_minimal': ex.process_fastq_minimal,
'cram': ex.process_cram,
'ubam': ex.process_ubam, }
filethreads = min(len(files), threads)
threadsleft = threads - filethreads
with cfutures.ProcessPoolExecutor(max_workers=filethreads) as executor:
extration_function = partial(proc_functions[source],
threads=threadsleft,
readtype=readtype,
barcoded=barcoded)
datadf = combine_dfs(
dfs=[out for out in executor.map(extration_function, files)],
names=names or files,
method=combine)
if "readIDs" in datadf and pd.isna(datadf["readIDs"]).any():
datadf.drop("readIDs", axis='columns', inplace=True)
datadf = calculate_start_time(datadf)
logging.info("Nanoget: Gathered all metrics of {} reads".format(len(datadf)))
if len(datadf) == 0:
logging.critical("Nanoget: no reads retrieved.".format(len(datadf)))
sys.exit("Fatal: No reads found in input.")
else:
return datadf |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:validate_wavelengths; 3, parameters; 3, 4; 4, identifier:wavelengths; 5, block; 5, 6; 5, 36; 5, 49; 5, 58; 5, 87; 5, 96; 5, 145; 6, if_statement; 6, 7; 6, 14; 6, 30; 7, call; 7, 8; 7, 9; 8, identifier:isinstance; 9, argument_list; 9, 10; 9, 11; 10, identifier:wavelengths; 11, attribute; 11, 12; 11, 13; 12, identifier:u; 13, identifier:Quantity; 14, block; 14, 15; 14, 24; 15, expression_statement; 15, 16; 16, call; 16, 17; 16, 20; 17, attribute; 17, 18; 17, 19; 18, identifier:units; 19, identifier:validate_wave_unit; 20, argument_list; 20, 21; 21, attribute; 21, 22; 21, 23; 22, identifier:wavelengths; 23, identifier:unit; 24, expression_statement; 24, 25; 25, assignment; 25, 26; 25, 27; 26, identifier:wave; 27, attribute; 27, 28; 27, 29; 28, identifier:wavelengths; 29, identifier:value; 30, else_clause; 30, 31; 31, block; 31, 32; 32, expression_statement; 32, 33; 33, assignment; 33, 34; 33, 35; 34, identifier:wave; 35, identifier:wavelengths; 36, if_statement; 36, 37; 36, 43; 37, call; 37, 38; 37, 41; 38, attribute; 38, 39; 38, 40; 39, identifier:np; 40, identifier:isscalar; 41, argument_list; 41, 42; 42, identifier:wave; 43, block; 43, 44; 44, expression_statement; 44, 45; 45, assignment; 45, 46; 45, 47; 46, identifier:wave; 47, list:[wave]; 47, 48; 48, identifier:wave; 49, expression_statement; 49, 50; 50, assignment; 50, 51; 50, 52; 51, identifier:wave; 52, call; 52, 53; 52, 56; 53, attribute; 53, 54; 53, 55; 54, identifier:np; 55, identifier:asarray; 56, argument_list; 56, 57; 57, identifier:wave; 58, if_statement; 58, 59; 58, 67; 59, call; 59, 60; 59, 63; 60, attribute; 60, 61; 60, 62; 61, identifier:np; 62, identifier:any; 63, argument_list; 63, 64; 64, comparison_operator:<=; 64, 65; 64, 66; 65, identifier:wave; 66, integer:0; 67, block; 67, 68; 68, raise_statement; 68, 69; 69, call; 69, 70; 69, 73; 70, attribute; 70, 71; 70, 72; 71, identifier:exceptions; 72, identifier:ZeroWavelength; 73, argument_list; 73, 74; 73, 75; 74, string:'Negative or zero wavelength occurs in wavelength array'; 75, keyword_argument; 75, 76; 75, 77; 76, identifier:rows; 77, subscript; 77, 78; 77, 86; 78, call; 78, 79; 78, 82; 79, attribute; 79, 80; 79, 81; 80, identifier:np; 81, identifier:where; 82, argument_list; 82, 83; 83, comparison_operator:<=; 83, 84; 83, 85; 84, identifier:wave; 85, integer:0; 86, integer:0; 87, expression_statement; 87, 88; 88, assignment; 88, 89; 88, 90; 89, identifier:sorted_wave; 90, call; 90, 91; 90, 94; 91, attribute; 91, 92; 91, 93; 92, identifier:np; 93, identifier:sort; 94, argument_list; 94, 95; 95, identifier:wave; 96, if_statement; 96, 97; 96, 106; 97, not_operator; 97, 98; 98, call; 98, 99; 98, 102; 99, attribute; 99, 100; 99, 101; 100, identifier:np; 101, identifier:alltrue; 102, argument_list; 102, 103; 103, comparison_operator:==; 103, 104; 103, 105; 104, identifier:sorted_wave; 105, identifier:wave; 106, block; 106, 107; 107, if_statement; 107, 108; 107, 122; 107, 124; 108, call; 108, 109; 108, 112; 109, attribute; 109, 110; 109, 111; 110, identifier:np; 111, identifier:alltrue; 112, argument_list; 112, 113; 113, comparison_operator:==; 113, 114; 113, 121; 114, subscript; 114, 115; 114, 116; 115, identifier:sorted_wave; 116, slice; 116, 117; 116, 118; 116, 119; 117, colon; 118, colon; 119, unary_operator:-; 119, 120; 120, integer:1; 121, identifier:wave; 122, block; 122, 123; 123, pass_statement; 124, else_clause; 124, 125; 125, block; 125, 126; 126, raise_statement; 126, 127; 127, call; 127, 128; 127, 131; 128, attribute; 128, 129; 128, 130; 129, identifier:exceptions; 130, identifier:UnsortedWavelength; 131, argument_list; 131, 132; 131, 133; 132, string:'Wavelength array is not monotonic'; 133, keyword_argument; 133, 134; 133, 135; 134, identifier:rows; 135, subscript; 135, 136; 135, 144; 136, call; 136, 137; 136, 140; 137, attribute; 137, 138; 137, 139; 138, identifier:np; 139, identifier:where; 140, argument_list; 140, 141; 141, comparison_operator:!=; 141, 142; 141, 143; 142, identifier:sorted_wave; 143, identifier:wave; 144, integer:0; 145, if_statement; 145, 146; 145, 151; 146, comparison_operator:>; 146, 147; 146, 150; 147, attribute; 147, 148; 147, 149; 148, identifier:wave; 149, identifier:size; 150, integer:1; 151, block; 151, 152; 151, 167; 152, expression_statement; 152, 153; 153, assignment; 153, 154; 153, 155; 154, identifier:dw; 155, binary_operator:-; 155, 156; 155, 161; 156, subscript; 156, 157; 156, 158; 157, identifier:sorted_wave; 158, slice; 158, 159; 158, 160; 159, integer:1; 160, colon; 161, subscript; 161, 162; 161, 163; 162, identifier:sorted_wave; 163, slice; 163, 164; 163, 165; 164, colon; 165, unary_operator:-; 165, 166; 166, integer:1; 167, if_statement; 167, 168; 167, 176; 168, call; 168, 169; 168, 172; 169, attribute; 169, 170; 169, 171; 170, identifier:np; 171, identifier:any; 172, argument_list; 172, 173; 173, comparison_operator:==; 173, 174; 173, 175; 174, identifier:dw; 175, integer:0; 176, block; 176, 177; 177, raise_statement; 177, 178; 178, call; 178, 179; 178, 182; 179, attribute; 179, 180; 179, 181; 180, identifier:exceptions; 181, identifier:DuplicateWavelength; 182, argument_list; 182, 183; 182, 184; 183, string:'Wavelength array contains duplicate entries'; 184, keyword_argument; 184, 185; 184, 186; 185, identifier:rows; 186, subscript; 186, 187; 186, 195; 187, call; 187, 188; 187, 191; 188, attribute; 188, 189; 188, 190; 189, identifier:np; 190, identifier:where; 191, argument_list; 191, 192; 192, comparison_operator:==; 192, 193; 192, 194; 193, identifier:dw; 194, integer:0; 195, integer:0 | def validate_wavelengths(wavelengths):
if isinstance(wavelengths, u.Quantity):
units.validate_wave_unit(wavelengths.unit)
wave = wavelengths.value
else:
wave = wavelengths
if np.isscalar(wave):
wave = [wave]
wave = np.asarray(wave)
if np.any(wave <= 0):
raise exceptions.ZeroWavelength(
'Negative or zero wavelength occurs in wavelength array',
rows=np.where(wave <= 0)[0])
sorted_wave = np.sort(wave)
if not np.alltrue(sorted_wave == wave):
if np.alltrue(sorted_wave[::-1] == wave):
pass
else:
raise exceptions.UnsortedWavelength(
'Wavelength array is not monotonic',
rows=np.where(sorted_wave != wave)[0])
if wave.size > 1:
dw = sorted_wave[1:] - sorted_wave[:-1]
if np.any(dw == 0):
raise exceptions.DuplicateWavelength(
'Wavelength array contains duplicate entries',
rows=np.where(dw == 0)[0]) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:heapify; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:key; 7, identifier:__marker; 8, block; 8, 9; 9, if_statement; 9, 10; 9, 15; 9, 44; 10, comparison_operator:is; 10, 11; 10, 12; 11, identifier:key; 12, attribute; 12, 13; 12, 14; 13, identifier:self; 14, identifier:__marker; 15, block; 15, 16; 15, 25; 16, expression_statement; 16, 17; 17, assignment; 17, 18; 17, 19; 18, identifier:n; 19, call; 19, 20; 19, 21; 20, identifier:len; 21, argument_list; 21, 22; 22, attribute; 22, 23; 22, 24; 23, identifier:self; 24, identifier:_heap; 25, for_statement; 25, 26; 25, 27; 25, 36; 26, identifier:pos; 27, call; 27, 28; 27, 29; 28, identifier:reversed; 29, argument_list; 29, 30; 30, call; 30, 31; 30, 32; 31, identifier:range; 32, argument_list; 32, 33; 33, binary_operator://; 33, 34; 33, 35; 34, identifier:n; 35, integer:2; 36, block; 36, 37; 37, expression_statement; 37, 38; 38, call; 38, 39; 38, 42; 39, attribute; 39, 40; 39, 41; 40, identifier:self; 41, identifier:_sink; 42, argument_list; 42, 43; 43, identifier:pos; 44, else_clause; 44, 45; 45, block; 45, 46; 45, 64; 46, try_statement; 46, 47; 46, 56; 47, block; 47, 48; 48, expression_statement; 48, 49; 49, assignment; 49, 50; 49, 51; 50, identifier:pos; 51, subscript; 51, 52; 51, 55; 52, attribute; 52, 53; 52, 54; 53, identifier:self; 54, identifier:_position; 55, identifier:key; 56, except_clause; 56, 57; 56, 58; 57, identifier:KeyError; 58, block; 58, 59; 59, raise_statement; 59, 60; 60, call; 60, 61; 60, 62; 61, identifier:KeyError; 62, argument_list; 62, 63; 63, identifier:key; 64, expression_statement; 64, 65; 65, call; 65, 66; 65, 69; 66, attribute; 66, 67; 66, 68; 67, identifier:self; 68, identifier:_reheapify; 69, argument_list; 69, 70; 70, identifier:pos | def heapify(self, key=__marker):
if key is self.__marker:
n = len(self._heap)
for pos in reversed(range(n//2)):
self._sink(pos)
else:
try:
pos = self._position[key]
except KeyError:
raise KeyError(key)
self._reheapify(pos) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 29; 1, 31; 2, function_name:__update_display_items_model; 3, parameters; 3, 4; 3, 5; 3, 11; 3, 21; 4, identifier:self; 5, typed_parameter; 5, 6; 5, 7; 6, identifier:display_items_model; 7, type; 7, 8; 8, attribute; 8, 9; 8, 10; 9, identifier:ListModel; 10, identifier:FilteredListModel; 11, typed_parameter; 11, 12; 11, 13; 12, identifier:data_group; 13, type; 13, 14; 14, subscript; 14, 15; 14, 18; 15, attribute; 15, 16; 15, 17; 16, identifier:typing; 17, identifier:Optional; 18, attribute; 18, 19; 18, 20; 19, identifier:DataGroup; 20, identifier:DataGroup; 21, typed_parameter; 21, 22; 21, 23; 22, identifier:filter_id; 23, type; 23, 24; 24, subscript; 24, 25; 24, 28; 25, attribute; 25, 26; 25, 27; 26, identifier:typing; 27, identifier:Optional; 28, identifier:str; 29, type; 29, 30; 30, None; 31, block; 31, 32; 32, with_statement; 32, 33; 32, 40; 33, with_clause; 33, 34; 34, with_item; 34, 35; 35, call; 35, 36; 35, 39; 36, attribute; 36, 37; 36, 38; 37, identifier:display_items_model; 38, identifier:changes; 39, argument_list; 40, block; 40, 41; 41, if_statement; 41, 42; 41, 45; 41, 75; 41, 124; 41, 169; 41, 213; 42, comparison_operator:is; 42, 43; 42, 44; 43, identifier:data_group; 44, None; 45, block; 45, 46; 45, 52; 45, 63; 45, 69; 46, expression_statement; 46, 47; 47, assignment; 47, 48; 47, 51; 48, attribute; 48, 49; 48, 50; 49, identifier:display_items_model; 50, identifier:container; 51, identifier:data_group; 52, expression_statement; 52, 53; 53, assignment; 53, 54; 53, 57; 54, attribute; 54, 55; 54, 56; 55, identifier:display_items_model; 56, identifier:filter; 57, call; 57, 58; 57, 61; 58, attribute; 58, 59; 58, 60; 59, identifier:ListModel; 60, identifier:Filter; 61, argument_list; 61, 62; 62, True; 63, expression_statement; 63, 64; 64, assignment; 64, 65; 64, 68; 65, attribute; 65, 66; 65, 67; 66, identifier:display_items_model; 67, identifier:sort_key; 68, None; 69, expression_statement; 69, 70; 70, assignment; 70, 71; 70, 74; 71, attribute; 71, 72; 71, 73; 72, identifier:display_items_model; 73, identifier:filter_id; 74, None; 75, elif_clause; 75, 76; 75, 79; 76, comparison_operator:==; 76, 77; 76, 78; 77, identifier:filter_id; 78, string:"latest-session"; 79, block; 79, 80; 79, 88; 79, 104; 79, 112; 79, 118; 80, expression_statement; 80, 81; 81, assignment; 81, 82; 81, 85; 82, attribute; 82, 83; 82, 84; 83, identifier:display_items_model; 84, identifier:container; 85, attribute; 85, 86; 85, 87; 86, identifier:self; 87, identifier:document_model; 88, expression_statement; 88, 89; 89, assignment; 89, 90; 89, 93; 90, attribute; 90, 91; 90, 92; 91, identifier:display_items_model; 92, identifier:filter; 93, call; 93, 94; 93, 97; 94, attribute; 94, 95; 94, 96; 95, identifier:ListModel; 96, identifier:EqFilter; 97, argument_list; 97, 98; 97, 99; 98, string:"session_id"; 99, attribute; 99, 100; 99, 103; 100, attribute; 100, 101; 100, 102; 101, identifier:self; 102, identifier:document_model; 103, identifier:session_id; 104, expression_statement; 104, 105; 105, assignment; 105, 106; 105, 109; 106, attribute; 106, 107; 106, 108; 107, identifier:display_items_model; 108, identifier:sort_key; 109, attribute; 109, 110; 109, 111; 110, identifier:DataItem; 111, identifier:sort_by_date_key; 112, expression_statement; 112, 113; 113, assignment; 113, 114; 113, 117; 114, attribute; 114, 115; 114, 116; 115, identifier:display_items_model; 116, identifier:sort_reverse; 117, True; 118, expression_statement; 118, 119; 119, assignment; 119, 120; 119, 123; 120, attribute; 120, 121; 120, 122; 121, identifier:display_items_model; 122, identifier:filter_id; 123, identifier:filter_id; 124, elif_clause; 124, 125; 124, 128; 125, comparison_operator:==; 125, 126; 125, 127; 126, identifier:filter_id; 127, string:"temporary"; 128, block; 128, 129; 128, 137; 128, 149; 128, 157; 128, 163; 129, expression_statement; 129, 130; 130, assignment; 130, 131; 130, 134; 131, attribute; 131, 132; 131, 133; 132, identifier:display_items_model; 133, identifier:container; 134, attribute; 134, 135; 134, 136; 135, identifier:self; 136, identifier:document_model; 137, expression_statement; 137, 138; 138, assignment; 138, 139; 138, 142; 139, attribute; 139, 140; 139, 141; 140, identifier:display_items_model; 141, identifier:filter; 142, call; 142, 143; 142, 146; 143, attribute; 143, 144; 143, 145; 144, identifier:ListModel; 145, identifier:NotEqFilter; 146, argument_list; 146, 147; 146, 148; 147, string:"category"; 148, string:"persistent"; 149, expression_statement; 149, 150; 150, assignment; 150, 151; 150, 154; 151, attribute; 151, 152; 151, 153; 152, identifier:display_items_model; 153, identifier:sort_key; 154, attribute; 154, 155; 154, 156; 155, identifier:DataItem; 156, identifier:sort_by_date_key; 157, expression_statement; 157, 158; 158, assignment; 158, 159; 158, 162; 159, attribute; 159, 160; 159, 161; 160, identifier:display_items_model; 161, identifier:sort_reverse; 162, True; 163, expression_statement; 163, 164; 164, assignment; 164, 165; 164, 168; 165, attribute; 165, 166; 165, 167; 166, identifier:display_items_model; 167, identifier:filter_id; 168, identifier:filter_id; 169, elif_clause; 169, 170; 169, 173; 170, comparison_operator:==; 170, 171; 170, 172; 171, identifier:filter_id; 172, string:"none"; 173, block; 173, 174; 173, 182; 173, 193; 173, 201; 173, 207; 174, expression_statement; 174, 175; 175, assignment; 175, 176; 175, 179; 176, attribute; 176, 177; 176, 178; 177, identifier:display_items_model; 178, identifier:container; 179, attribute; 179, 180; 179, 181; 180, identifier:self; 181, identifier:document_model; 182, expression_statement; 182, 183; 183, assignment; 183, 184; 183, 187; 184, attribute; 184, 185; 184, 186; 185, identifier:display_items_model; 186, identifier:filter; 187, call; 187, 188; 187, 191; 188, attribute; 188, 189; 188, 190; 189, identifier:ListModel; 190, identifier:Filter; 191, argument_list; 191, 192; 192, False; 193, expression_statement; 193, 194; 194, assignment; 194, 195; 194, 198; 195, attribute; 195, 196; 195, 197; 196, identifier:display_items_model; 197, identifier:sort_key; 198, attribute; 198, 199; 198, 200; 199, identifier:DataItem; 200, identifier:sort_by_date_key; 201, expression_statement; 201, 202; 202, assignment; 202, 203; 202, 206; 203, attribute; 203, 204; 203, 205; 204, identifier:display_items_model; 205, identifier:sort_reverse; 206, True; 207, expression_statement; 207, 208; 208, assignment; 208, 209; 208, 212; 209, attribute; 209, 210; 209, 211; 210, identifier:display_items_model; 211, identifier:filter_id; 212, identifier:filter_id; 213, else_clause; 213, 214; 214, block; 214, 215; 214, 223; 214, 235; 214, 243; 214, 249; 215, expression_statement; 215, 216; 216, assignment; 216, 217; 216, 220; 217, attribute; 217, 218; 217, 219; 218, identifier:display_items_model; 219, identifier:container; 220, attribute; 220, 221; 220, 222; 221, identifier:self; 222, identifier:document_model; 223, expression_statement; 223, 224; 224, assignment; 224, 225; 224, 228; 225, attribute; 225, 226; 225, 227; 226, identifier:display_items_model; 227, identifier:filter; 228, call; 228, 229; 228, 232; 229, attribute; 229, 230; 229, 231; 230, identifier:ListModel; 231, identifier:EqFilter; 232, argument_list; 232, 233; 232, 234; 233, string:"category"; 234, string:"persistent"; 235, expression_statement; 235, 236; 236, assignment; 236, 237; 236, 240; 237, attribute; 237, 238; 237, 239; 238, identifier:display_items_model; 239, identifier:sort_key; 240, attribute; 240, 241; 240, 242; 241, identifier:DataItem; 242, identifier:sort_by_date_key; 243, expression_statement; 243, 244; 244, assignment; 244, 245; 244, 248; 245, attribute; 245, 246; 245, 247; 246, identifier:display_items_model; 247, identifier:sort_reverse; 248, True; 249, expression_statement; 249, 250; 250, assignment; 250, 251; 250, 254; 251, attribute; 251, 252; 251, 253; 252, identifier:display_items_model; 253, identifier:filter_id; 254, None | def __update_display_items_model(self, display_items_model: ListModel.FilteredListModel, data_group: typing.Optional[DataGroup.DataGroup], filter_id: typing.Optional[str]) -> None:
with display_items_model.changes():
if data_group is not None:
display_items_model.container = data_group
display_items_model.filter = ListModel.Filter(True)
display_items_model.sort_key = None
display_items_model.filter_id = None
elif filter_id == "latest-session":
display_items_model.container = self.document_model
display_items_model.filter = ListModel.EqFilter("session_id", self.document_model.session_id)
display_items_model.sort_key = DataItem.sort_by_date_key
display_items_model.sort_reverse = True
display_items_model.filter_id = filter_id
elif filter_id == "temporary":
display_items_model.container = self.document_model
display_items_model.filter = ListModel.NotEqFilter("category", "persistent")
display_items_model.sort_key = DataItem.sort_by_date_key
display_items_model.sort_reverse = True
display_items_model.filter_id = filter_id
elif filter_id == "none":
display_items_model.container = self.document_model
display_items_model.filter = ListModel.Filter(False)
display_items_model.sort_key = DataItem.sort_by_date_key
display_items_model.sort_reverse = True
display_items_model.filter_id = filter_id
else:
display_items_model.container = self.document_model
display_items_model.filter = ListModel.EqFilter("category", "persistent")
display_items_model.sort_key = DataItem.sort_by_date_key
display_items_model.sort_reverse = True
display_items_model.filter_id = None |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:sort_by_date_key; 3, parameters; 3, 4; 4, identifier:data_item; 5, block; 5, 6; 6, return_statement; 6, 7; 7, expression_list; 7, 8; 7, 25; 7, 28; 8, conditional_expression:if; 8, 9; 8, 19; 8, 22; 9, binary_operator:+; 9, 10; 9, 13; 10, attribute; 10, 11; 10, 12; 11, identifier:data_item; 12, identifier:title; 13, call; 13, 14; 13, 15; 14, identifier:str; 15, argument_list; 15, 16; 16, attribute; 16, 17; 16, 18; 17, identifier:data_item; 18, identifier:uuid; 19, attribute; 19, 20; 19, 21; 20, identifier:data_item; 21, identifier:is_live; 22, call; 22, 23; 22, 24; 23, identifier:str; 24, argument_list; 25, attribute; 25, 26; 25, 27; 26, identifier:data_item; 27, identifier:date_for_sorting; 28, call; 28, 29; 28, 30; 29, identifier:str; 30, argument_list; 30, 31; 31, attribute; 31, 32; 31, 33; 32, identifier:data_item; 33, identifier:uuid | def sort_by_date_key(data_item):
return data_item.title + str(data_item.uuid) if data_item.is_live else str(), data_item.date_for_sorting, str(data_item.uuid) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 19; 2, function_name:open_mfbpchdataset; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 4, identifier:paths; 5, default_parameter; 5, 6; 5, 7; 6, identifier:concat_dim; 7, string:'time'; 8, default_parameter; 8, 9; 8, 10; 9, identifier:compat; 10, string:'no_conflicts'; 11, default_parameter; 11, 12; 11, 13; 12, identifier:preprocess; 13, None; 14, default_parameter; 14, 15; 14, 16; 15, identifier:lock; 16, None; 17, dictionary_splat_pattern; 17, 18; 18, identifier:kwargs; 19, block; 19, 20; 19, 27; 19, 37; 19, 46; 19, 52; 19, 69; 19, 78; 19, 91; 19, 101; 19, 117; 19, 132; 19, 141; 19, 151; 19, 157; 19, 166; 19, 182; 20, import_from_statement; 20, 21; 20, 25; 21, dotted_name; 21, 22; 21, 23; 21, 24; 22, identifier:xarray; 23, identifier:backends; 24, identifier:api; 25, dotted_name; 25, 26; 26, identifier:_MultiFileCloser; 27, expression_statement; 27, 28; 28, assignment; 28, 29; 28, 30; 29, identifier:dask; 30, call; 30, 31; 30, 34; 31, attribute; 31, 32; 31, 33; 32, identifier:kwargs; 33, identifier:pop; 34, argument_list; 34, 35; 34, 36; 35, string:'dask'; 36, False; 37, if_statement; 37, 38; 37, 40; 38, not_operator; 38, 39; 39, identifier:dask; 40, block; 40, 41; 41, raise_statement; 41, 42; 42, call; 42, 43; 42, 44; 43, identifier:ValueError; 44, argument_list; 44, 45; 45, string:"Reading multiple files without dask is not supported"; 46, expression_statement; 46, 47; 47, assignment; 47, 48; 47, 51; 48, subscript; 48, 49; 48, 50; 49, identifier:kwargs; 50, string:'dask'; 51, True; 52, if_statement; 52, 53; 52, 58; 53, call; 53, 54; 53, 55; 54, identifier:isinstance; 55, argument_list; 55, 56; 55, 57; 56, identifier:paths; 57, identifier:basestring; 58, block; 58, 59; 59, expression_statement; 59, 60; 60, assignment; 60, 61; 60, 62; 61, identifier:paths; 62, call; 62, 63; 62, 64; 63, identifier:sorted; 64, argument_list; 64, 65; 65, call; 65, 66; 65, 67; 66, identifier:glob; 67, argument_list; 67, 68; 68, identifier:paths; 69, if_statement; 69, 70; 69, 72; 70, not_operator; 70, 71; 71, identifier:paths; 72, block; 72, 73; 73, raise_statement; 73, 74; 74, call; 74, 75; 74, 76; 75, identifier:IOError; 76, argument_list; 76, 77; 77, string:"No paths to files were passed into open_mfbpchdataset"; 78, expression_statement; 78, 79; 79, assignment; 79, 80; 79, 81; 80, identifier:datasets; 81, list_comprehension; 81, 82; 81, 88; 82, call; 82, 83; 82, 84; 83, identifier:open_bpchdataset; 84, argument_list; 84, 85; 84, 86; 85, identifier:filename; 86, dictionary_splat; 86, 87; 87, identifier:kwargs; 88, for_in_clause; 88, 89; 88, 90; 89, identifier:filename; 90, identifier:paths; 91, expression_statement; 91, 92; 92, assignment; 92, 93; 92, 94; 93, identifier:bpch_objs; 94, list_comprehension; 94, 95; 94, 98; 95, attribute; 95, 96; 95, 97; 96, identifier:ds; 97, identifier:_file_obj; 98, for_in_clause; 98, 99; 98, 100; 99, identifier:ds; 100, identifier:datasets; 101, if_statement; 101, 102; 101, 105; 102, comparison_operator:is; 102, 103; 102, 104; 103, identifier:preprocess; 104, None; 105, block; 105, 106; 106, expression_statement; 106, 107; 107, assignment; 107, 108; 107, 109; 108, identifier:datasets; 109, list_comprehension; 109, 110; 109, 114; 110, call; 110, 111; 110, 112; 111, identifier:preprocess; 112, argument_list; 112, 113; 113, identifier:ds; 114, for_in_clause; 114, 115; 114, 116; 115, identifier:ds; 116, identifier:datasets; 117, expression_statement; 117, 118; 118, assignment; 118, 119; 118, 120; 119, identifier:combined; 120, call; 120, 121; 120, 124; 121, attribute; 121, 122; 121, 123; 122, identifier:xr; 123, identifier:auto_combine; 124, argument_list; 124, 125; 124, 126; 124, 129; 125, identifier:datasets; 126, keyword_argument; 126, 127; 126, 128; 127, identifier:compat; 128, identifier:compat; 129, keyword_argument; 129, 130; 129, 131; 130, identifier:concat_dim; 131, identifier:concat_dim; 132, expression_statement; 132, 133; 133, assignment; 133, 134; 133, 137; 134, attribute; 134, 135; 134, 136; 135, identifier:combined; 136, identifier:_file_obj; 137, call; 137, 138; 137, 139; 138, identifier:_MultiFileCloser; 139, argument_list; 139, 140; 140, identifier:bpch_objs; 141, expression_statement; 141, 142; 142, assignment; 142, 143; 142, 146; 143, attribute; 143, 144; 143, 145; 144, identifier:combined; 145, identifier:attrs; 146, attribute; 146, 147; 146, 150; 147, subscript; 147, 148; 147, 149; 148, identifier:datasets; 149, integer:0; 150, identifier:attrs; 151, expression_statement; 151, 152; 152, assignment; 152, 153; 152, 154; 153, identifier:ts; 154, call; 154, 155; 154, 156; 155, identifier:get_timestamp; 156, argument_list; 157, expression_statement; 157, 158; 158, assignment; 158, 159; 158, 160; 159, identifier:fns_str; 160, call; 160, 161; 160, 164; 161, attribute; 161, 162; 161, 163; 162, string:" "; 163, identifier:join; 164, argument_list; 164, 165; 165, identifier:paths; 166, expression_statement; 166, 167; 167, assignment; 167, 168; 167, 173; 168, subscript; 168, 169; 168, 172; 169, attribute; 169, 170; 169, 171; 170, identifier:combined; 171, identifier:attrs; 172, string:'history'; 173, parenthesized_expression; 173, 174; 174, call; 174, 175; 174, 178; 175, attribute; 175, 176; 175, 177; 176, string:"{}: Processed/loaded by xbpch-{} from {}"; 177, identifier:format; 178, argument_list; 178, 179; 178, 180; 178, 181; 179, identifier:ts; 180, identifier:ver; 181, identifier:fns_str; 182, return_statement; 182, 183; 183, identifier:combined | def open_mfbpchdataset(paths, concat_dim='time', compat='no_conflicts',
preprocess=None, lock=None, **kwargs):
from xarray.backends.api import _MultiFileCloser
dask = kwargs.pop('dask', False)
if not dask:
raise ValueError("Reading multiple files without dask is not supported")
kwargs['dask'] = True
if isinstance(paths, basestring):
paths = sorted(glob(paths))
if not paths:
raise IOError("No paths to files were passed into open_mfbpchdataset")
datasets = [open_bpchdataset(filename, **kwargs)
for filename in paths]
bpch_objs = [ds._file_obj for ds in datasets]
if preprocess is not None:
datasets = [preprocess(ds) for ds in datasets]
combined = xr.auto_combine(datasets, compat=compat, concat_dim=concat_dim)
combined._file_obj = _MultiFileCloser(bpch_objs)
combined.attrs = datasets[0].attrs
ts = get_timestamp()
fns_str = " ".join(paths)
combined.attrs['history'] = (
"{}: Processed/loaded by xbpch-{} from {}"
.format(ts, ver, fns_str)
)
return combined |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_get_archive_filelist; 3, parameters; 3, 4; 4, identifier:filename; 5, block; 5, 6; 5, 10; 5, 88; 5, 100; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:names; 9, list:[]; 10, if_statement; 10, 11; 10, 17; 10, 42; 10, 74; 11, call; 11, 12; 11, 15; 12, attribute; 12, 13; 12, 14; 13, identifier:tarfile; 14, identifier:is_tarfile; 15, argument_list; 15, 16; 16, identifier:filename; 17, block; 17, 18; 18, with_statement; 18, 19; 18, 30; 19, with_clause; 19, 20; 20, with_item; 20, 21; 21, as_pattern; 21, 22; 21, 28; 22, call; 22, 23; 22, 26; 23, attribute; 23, 24; 23, 25; 24, identifier:tarfile; 25, identifier:open; 26, argument_list; 26, 27; 27, identifier:filename; 28, as_pattern_target; 28, 29; 29, identifier:tar_file; 30, block; 30, 31; 31, expression_statement; 31, 32; 32, assignment; 32, 33; 32, 34; 33, identifier:names; 34, call; 34, 35; 34, 36; 35, identifier:sorted; 36, argument_list; 36, 37; 37, call; 37, 38; 37, 41; 38, attribute; 38, 39; 38, 40; 39, identifier:tar_file; 40, identifier:getnames; 41, argument_list; 42, elif_clause; 42, 43; 42, 49; 43, call; 43, 44; 43, 47; 44, attribute; 44, 45; 44, 46; 45, identifier:zipfile; 46, identifier:is_zipfile; 47, argument_list; 47, 48; 48, identifier:filename; 49, block; 49, 50; 50, with_statement; 50, 51; 50, 62; 51, with_clause; 51, 52; 52, with_item; 52, 53; 53, as_pattern; 53, 54; 53, 60; 54, call; 54, 55; 54, 58; 55, attribute; 55, 56; 55, 57; 56, identifier:zipfile; 57, identifier:ZipFile; 58, argument_list; 58, 59; 59, identifier:filename; 60, as_pattern_target; 60, 61; 61, identifier:zip_file; 62, block; 62, 63; 63, expression_statement; 63, 64; 64, assignment; 64, 65; 64, 66; 65, identifier:names; 66, call; 66, 67; 66, 68; 67, identifier:sorted; 68, argument_list; 68, 69; 69, call; 69, 70; 69, 73; 70, attribute; 70, 71; 70, 72; 71, identifier:zip_file; 72, identifier:namelist; 73, argument_list; 74, else_clause; 74, 75; 75, block; 75, 76; 76, raise_statement; 76, 77; 77, call; 77, 78; 77, 79; 78, identifier:ValueError; 79, argument_list; 79, 80; 80, call; 80, 81; 80, 86; 81, attribute; 81, 82; 81, 85; 82, concatenated_string; 82, 83; 82, 84; 83, string:"Can not get filenames from '{!s}'. "; 84, string:"Not a tar or zip file"; 85, identifier:format; 86, argument_list; 86, 87; 87, identifier:filename; 88, if_statement; 88, 89; 88, 92; 89, comparison_operator:in; 89, 90; 89, 91; 90, string:"./"; 91, identifier:names; 92, block; 92, 93; 93, expression_statement; 93, 94; 94, call; 94, 95; 94, 98; 95, attribute; 95, 96; 95, 97; 96, identifier:names; 97, identifier:remove; 98, argument_list; 98, 99; 99, string:"./"; 100, return_statement; 100, 101; 101, identifier:names | def _get_archive_filelist(filename):
names = []
if tarfile.is_tarfile(filename):
with tarfile.open(filename) as tar_file:
names = sorted(tar_file.getnames())
elif zipfile.is_zipfile(filename):
with zipfile.ZipFile(filename) as zip_file:
names = sorted(zip_file.namelist())
else:
raise ValueError("Can not get filenames from '{!s}'. "
"Not a tar or zip file".format(filename))
if "./" in names:
names.remove("./")
return names |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:pbar_strings; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:files; 5, default_parameter; 5, 6; 5, 7; 6, identifier:desc; 7, string:''; 8, dictionary_splat_pattern; 8, 9; 9, identifier:kwargs; 10, block; 10, 11; 11, return_statement; 11, 12; 12, call; 12, 13; 12, 14; 13, identifier:tqdm; 14, argument_list; 14, 15; 14, 29; 14, 51; 14, 54; 15, call; 15, 16; 15, 17; 16, identifier:sorted; 17, argument_list; 17, 18; 17, 19; 18, identifier:files; 19, keyword_argument; 19, 20; 19, 21; 20, identifier:key; 21, lambda; 21, 22; 21, 24; 22, lambda_parameters; 22, 23; 23, identifier:s; 24, call; 24, 25; 24, 28; 25, attribute; 25, 26; 25, 27; 26, identifier:s; 27, identifier:lower; 28, argument_list; 29, keyword_argument; 29, 30; 29, 31; 30, identifier:desc; 31, parenthesized_expression; 31, 32; 32, binary_operator:+; 32, 33; 32, 50; 33, binary_operator:+; 33, 34; 33, 49; 34, binary_operator:+; 34, 35; 34, 36; 35, string:'<'; 36, call; 36, 37; 36, 38; 37, identifier:str; 38, argument_list; 38, 39; 39, call; 39, 40; 39, 47; 40, attribute; 40, 41; 40, 46; 41, call; 41, 42; 41, 45; 42, attribute; 42, 43; 42, 44; 43, identifier:datetime; 44, identifier:now; 45, argument_list; 46, identifier:strftime; 47, argument_list; 47, 48; 48, string:"%Y-%m-%d %H:%M:%S"; 49, string:'> '; 50, identifier:desc; 51, keyword_argument; 51, 52; 51, 53; 52, identifier:dynamic_ncols; 53, True; 54, dictionary_splat; 54, 55; 55, identifier:kwargs | def pbar_strings(files, desc='', **kwargs):
return tqdm(
sorted(files, key=lambda s: s.lower()),
desc=('<' + str(datetime.now().strftime("%Y-%m-%d %H:%M:%S")) + '> ' +
desc),
dynamic_ncols=True,
**kwargs) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:sort_func; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:key; 6, block; 6, 7; 6, 18; 6, 29; 6, 40; 7, if_statement; 7, 8; 7, 15; 8, comparison_operator:==; 8, 9; 8, 10; 9, identifier:key; 10, attribute; 10, 11; 10, 14; 11, attribute; 11, 12; 11, 13; 12, identifier:self; 13, identifier:_KEYS; 14, identifier:TIME; 15, block; 15, 16; 16, return_statement; 16, 17; 17, string:'aaa'; 18, if_statement; 18, 19; 18, 26; 19, comparison_operator:==; 19, 20; 19, 21; 20, identifier:key; 21, attribute; 21, 22; 21, 25; 22, attribute; 22, 23; 22, 24; 23, identifier:self; 24, identifier:_KEYS; 25, identifier:DATA; 26, block; 26, 27; 27, return_statement; 27, 28; 28, string:'zzy'; 29, if_statement; 29, 30; 29, 37; 30, comparison_operator:==; 30, 31; 30, 32; 31, identifier:key; 32, attribute; 32, 33; 32, 36; 33, attribute; 33, 34; 33, 35; 34, identifier:self; 35, identifier:_KEYS; 36, identifier:SOURCE; 37, block; 37, 38; 38, return_statement; 38, 39; 39, string:'zzz'; 40, return_statement; 40, 41; 41, identifier:key | def sort_func(self, key):
if key == self._KEYS.TIME:
return 'aaa'
if key == self._KEYS.DATA:
return 'zzy'
if key == self._KEYS.SOURCE:
return 'zzz'
return key |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:sort_func; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:key; 6, block; 6, 7; 6, 18; 6, 29; 7, if_statement; 7, 8; 7, 15; 8, comparison_operator:==; 8, 9; 8, 10; 9, identifier:key; 10, attribute; 10, 11; 10, 14; 11, attribute; 11, 12; 11, 13; 12, identifier:self; 13, identifier:_KEYS; 14, identifier:VALUE; 15, block; 15, 16; 16, return_statement; 16, 17; 17, string:'aaa'; 18, if_statement; 18, 19; 18, 26; 19, comparison_operator:==; 19, 20; 19, 21; 20, identifier:key; 21, attribute; 21, 22; 21, 25; 22, attribute; 22, 23; 22, 24; 23, identifier:self; 24, identifier:_KEYS; 25, identifier:SOURCE; 26, block; 26, 27; 27, return_statement; 27, 28; 28, string:'zzz'; 29, return_statement; 29, 30; 30, identifier:key | def sort_func(self, key):
if key == self._KEYS.VALUE:
return 'aaa'
if key == self._KEYS.SOURCE:
return 'zzz'
return key |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:sort_func; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:key; 6, block; 6, 7; 6, 18; 6, 29; 6, 40; 6, 51; 6, 62; 6, 73; 6, 84; 7, if_statement; 7, 8; 7, 15; 8, comparison_operator:==; 8, 9; 8, 10; 9, identifier:key; 10, attribute; 10, 11; 10, 14; 11, attribute; 11, 12; 11, 13; 12, identifier:self; 13, identifier:_KEYS; 14, identifier:SCHEMA; 15, block; 15, 16; 16, return_statement; 16, 17; 17, string:'aaa'; 18, if_statement; 18, 19; 18, 26; 19, comparison_operator:==; 19, 20; 19, 21; 20, identifier:key; 21, attribute; 21, 22; 21, 25; 22, attribute; 22, 23; 22, 24; 23, identifier:self; 24, identifier:_KEYS; 25, identifier:NAME; 26, block; 26, 27; 27, return_statement; 27, 28; 28, string:'aab'; 29, if_statement; 29, 30; 29, 37; 30, comparison_operator:==; 30, 31; 30, 32; 31, identifier:key; 32, attribute; 32, 33; 32, 36; 33, attribute; 33, 34; 33, 35; 34, identifier:self; 35, identifier:_KEYS; 36, identifier:SOURCES; 37, block; 37, 38; 38, return_statement; 38, 39; 39, string:'aac'; 40, if_statement; 40, 41; 40, 48; 41, comparison_operator:==; 41, 42; 41, 43; 42, identifier:key; 43, attribute; 43, 44; 43, 47; 44, attribute; 44, 45; 44, 46; 45, identifier:self; 46, identifier:_KEYS; 47, identifier:ALIAS; 48, block; 48, 49; 49, return_statement; 49, 50; 50, string:'aad'; 51, if_statement; 51, 52; 51, 59; 52, comparison_operator:==; 52, 53; 52, 54; 53, identifier:key; 54, attribute; 54, 55; 54, 58; 55, attribute; 55, 56; 55, 57; 56, identifier:self; 57, identifier:_KEYS; 58, identifier:MODELS; 59, block; 59, 60; 60, return_statement; 60, 61; 61, string:'aae'; 62, if_statement; 62, 63; 62, 70; 63, comparison_operator:==; 63, 64; 63, 65; 64, identifier:key; 65, attribute; 65, 66; 65, 69; 66, attribute; 66, 67; 66, 68; 67, identifier:self; 68, identifier:_KEYS; 69, identifier:PHOTOMETRY; 70, block; 70, 71; 71, return_statement; 71, 72; 72, string:'zzy'; 73, if_statement; 73, 74; 73, 81; 74, comparison_operator:==; 74, 75; 74, 76; 75, identifier:key; 76, attribute; 76, 77; 76, 80; 77, attribute; 77, 78; 77, 79; 78, identifier:self; 79, identifier:_KEYS; 80, identifier:SPECTRA; 81, block; 81, 82; 82, return_statement; 82, 83; 83, string:'zzz'; 84, return_statement; 84, 85; 85, identifier:key | def sort_func(self, key):
if key == self._KEYS.SCHEMA:
return 'aaa'
if key == self._KEYS.NAME:
return 'aab'
if key == self._KEYS.SOURCES:
return 'aac'
if key == self._KEYS.ALIAS:
return 'aad'
if key == self._KEYS.MODELS:
return 'aae'
if key == self._KEYS.PHOTOMETRY:
return 'zzy'
if key == self._KEYS.SPECTRA:
return 'zzz'
return key |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:sort_func; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:key; 6, block; 6, 7; 6, 18; 6, 29; 6, 40; 7, if_statement; 7, 8; 7, 15; 8, comparison_operator:==; 8, 9; 8, 10; 9, identifier:key; 10, attribute; 10, 11; 10, 14; 11, attribute; 11, 12; 11, 13; 12, identifier:self; 13, identifier:_KEYS; 14, identifier:TIME; 15, block; 15, 16; 16, return_statement; 16, 17; 17, string:'aaa'; 18, if_statement; 18, 19; 18, 26; 19, comparison_operator:==; 19, 20; 19, 21; 20, identifier:key; 21, attribute; 21, 22; 21, 25; 22, attribute; 22, 23; 22, 24; 23, identifier:self; 24, identifier:_KEYS; 25, identifier:MODEL; 26, block; 26, 27; 27, return_statement; 27, 28; 28, string:'zzy'; 29, if_statement; 29, 30; 29, 37; 30, comparison_operator:==; 30, 31; 30, 32; 31, identifier:key; 32, attribute; 32, 33; 32, 36; 33, attribute; 33, 34; 33, 35; 34, identifier:self; 35, identifier:_KEYS; 36, identifier:SOURCE; 37, block; 37, 38; 38, return_statement; 38, 39; 39, string:'zzz'; 40, return_statement; 40, 41; 41, identifier:key | def sort_func(self, key):
if key == self._KEYS.TIME:
return 'aaa'
if key == self._KEYS.MODEL:
return 'zzy'
if key == self._KEYS.SOURCE:
return 'zzz'
return key |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:TypeFactory; 3, parameters; 3, 4; 4, identifier:type_; 5, block; 5, 6; 5, 21; 5, 40; 6, if_statement; 6, 7; 6, 18; 7, boolean_operator:and; 7, 8; 7, 13; 8, call; 8, 9; 8, 10; 9, identifier:isinstance; 10, argument_list; 10, 11; 10, 12; 11, identifier:type_; 12, identifier:type; 13, call; 13, 14; 13, 15; 14, identifier:issubclass; 15, argument_list; 15, 16; 15, 17; 16, identifier:type_; 17, identifier:Type; 18, block; 18, 19; 19, return_statement; 19, 20; 20, identifier:type_; 21, for_statement; 21, 22; 21, 23; 21, 24; 22, identifier:x; 23, identifier:__types__; 24, block; 24, 25; 25, if_statement; 25, 26; 25, 32; 26, call; 26, 27; 26, 30; 27, attribute; 27, 28; 27, 29; 28, identifier:x; 29, identifier:represents; 30, argument_list; 30, 31; 31, identifier:type_; 32, block; 32, 33; 33, return_statement; 33, 34; 34, call; 34, 35; 34, 38; 35, attribute; 35, 36; 35, 37; 36, identifier:x; 37, identifier:get; 38, argument_list; 38, 39; 39, identifier:type_; 40, raise_statement; 40, 41; 41, call; 41, 42; 41, 43; 42, identifier:UnknownType; 43, argument_list; 43, 44; 44, identifier:type_ | def TypeFactory(type_):
if isinstance(type_, type) and issubclass(type_, Type):
return type_
for x in __types__:
if x.represents(type_):
return x.get(type_)
raise UnknownType(type_) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:get_sorted_dependencies; 3, parameters; 3, 4; 4, identifier:service_model; 5, block; 5, 6; 5, 21; 5, 33; 5, 60; 5, 77; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:app_models; 9, call; 9, 10; 9, 11; 10, identifier:list; 11, argument_list; 11, 12; 12, call; 12, 13; 12, 20; 13, attribute; 13, 14; 13, 19; 14, attribute; 14, 15; 14, 18; 15, attribute; 15, 16; 15, 17; 16, identifier:service_model; 17, identifier:_meta; 18, identifier:app_config; 19, identifier:get_models; 20, argument_list; 21, expression_statement; 21, 22; 22, assignment; 22, 23; 22, 24; 23, identifier:dependencies; 24, dictionary_comprehension; 24, 25; 24, 30; 25, pair; 25, 26; 25, 27; 26, identifier:model; 27, call; 27, 28; 27, 29; 28, identifier:set; 29, argument_list; 30, for_in_clause; 30, 31; 30, 32; 31, identifier:model; 32, identifier:app_models; 33, expression_statement; 33, 34; 34, assignment; 34, 35; 34, 36; 35, identifier:relations; 36, generator_expression; 36, 37; 36, 38; 36, 41; 36, 48; 37, identifier:relation; 38, for_in_clause; 38, 39; 38, 40; 39, identifier:model; 40, identifier:app_models; 41, for_in_clause; 41, 42; 41, 43; 42, identifier:relation; 43, attribute; 43, 44; 43, 47; 44, attribute; 44, 45; 44, 46; 45, identifier:model; 46, identifier:_meta; 47, identifier:related_objects; 48, if_clause; 48, 49; 49, comparison_operator:in; 49, 50; 49, 53; 50, attribute; 50, 51; 50, 52; 51, identifier:relation; 52, identifier:on_delete; 53, tuple; 53, 54; 53, 57; 54, attribute; 54, 55; 54, 56; 55, identifier:models; 56, identifier:PROTECT; 57, attribute; 57, 58; 57, 59; 58, identifier:models; 59, identifier:CASCADE; 60, for_statement; 60, 61; 60, 62; 60, 63; 61, identifier:rel; 62, identifier:relations; 63, block; 63, 64; 64, expression_statement; 64, 65; 65, call; 65, 66; 65, 73; 66, attribute; 66, 67; 66, 72; 67, subscript; 67, 68; 67, 69; 68, identifier:dependencies; 69, attribute; 69, 70; 69, 71; 70, identifier:rel; 71, identifier:model; 72, identifier:add; 73, argument_list; 73, 74; 74, attribute; 74, 75; 74, 76; 75, identifier:rel; 76, identifier:related_model; 77, return_statement; 77, 78; 78, call; 78, 79; 78, 80; 79, identifier:stable_topological_sort; 80, argument_list; 80, 81; 80, 82; 81, identifier:app_models; 82, identifier:dependencies | def get_sorted_dependencies(service_model):
app_models = list(service_model._meta.app_config.get_models())
dependencies = {model: set() for model in app_models}
relations = (
relation
for model in app_models
for relation in model._meta.related_objects
if relation.on_delete in (models.PROTECT, models.CASCADE)
)
for rel in relations:
dependencies[rel.model].add(rel.related_model)
return stable_topological_sort(app_models, dependencies) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:format_time_and_value_to_segment_list; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, identifier:time_and_value_list; 5, identifier:segments_count; 6, identifier:start_timestamp; 7, identifier:end_timestamp; 8, default_parameter; 8, 9; 8, 10; 9, identifier:average; 10, False; 11, block; 11, 12; 11, 16; 11, 25; 11, 104; 12, expression_statement; 12, 13; 13, assignment; 13, 14; 13, 15; 14, identifier:segment_list; 15, list:[]; 16, expression_statement; 16, 17; 17, assignment; 17, 18; 17, 19; 18, identifier:time_step; 19, binary_operator:/; 19, 20; 19, 24; 20, parenthesized_expression; 20, 21; 21, binary_operator:-; 21, 22; 21, 23; 22, identifier:end_timestamp; 23, identifier:start_timestamp; 24, identifier:segments_count; 25, for_statement; 25, 26; 25, 27; 25, 31; 26, identifier:i; 27, call; 27, 28; 27, 29; 28, identifier:range; 29, argument_list; 29, 30; 30, identifier:segments_count; 31, block; 31, 32; 31, 40; 31, 46; 31, 64; 31, 71; 31, 88; 32, expression_statement; 32, 33; 33, assignment; 33, 34; 33, 35; 34, identifier:segment_start_timestamp; 35, binary_operator:+; 35, 36; 35, 37; 36, identifier:start_timestamp; 37, binary_operator:*; 37, 38; 37, 39; 38, identifier:time_step; 39, identifier:i; 40, expression_statement; 40, 41; 41, assignment; 41, 42; 41, 43; 42, identifier:segment_end_timestamp; 43, binary_operator:+; 43, 44; 43, 45; 44, identifier:segment_start_timestamp; 45, identifier:time_step; 46, expression_statement; 46, 47; 47, assignment; 47, 48; 47, 49; 48, identifier:value_list; 49, list_comprehension; 49, 50; 49, 51; 49, 56; 50, identifier:value; 51, for_in_clause; 51, 52; 51, 55; 52, pattern_list; 52, 53; 52, 54; 53, identifier:time; 54, identifier:value; 55, identifier:time_and_value_list; 56, if_clause; 56, 57; 57, boolean_operator:and; 57, 58; 57, 61; 58, comparison_operator:>=; 58, 59; 58, 60; 59, identifier:time; 60, identifier:segment_start_timestamp; 61, comparison_operator:<; 61, 62; 61, 63; 62, identifier:time; 63, identifier:segment_end_timestamp; 64, expression_statement; 64, 65; 65, assignment; 65, 66; 65, 67; 66, identifier:segment_value; 67, call; 67, 68; 67, 69; 68, identifier:sum; 69, argument_list; 69, 70; 70, identifier:value_list; 71, if_statement; 71, 72; 71, 80; 72, boolean_operator:and; 72, 73; 72, 74; 73, identifier:average; 74, comparison_operator:!=; 74, 75; 74, 79; 75, call; 75, 76; 75, 77; 76, identifier:len; 77, argument_list; 77, 78; 78, identifier:value_list; 79, integer:0; 80, block; 80, 81; 81, expression_statement; 81, 82; 82, augmented_assignment:/=; 82, 83; 82, 84; 83, identifier:segment_value; 84, call; 84, 85; 84, 86; 85, identifier:len; 86, argument_list; 86, 87; 87, identifier:value_list; 88, expression_statement; 88, 89; 89, call; 89, 90; 89, 93; 90, attribute; 90, 91; 90, 92; 91, identifier:segment_list; 92, identifier:append; 93, argument_list; 93, 94; 94, dictionary; 94, 95; 94, 98; 94, 101; 95, pair; 95, 96; 95, 97; 96, string:'from'; 97, identifier:segment_start_timestamp; 98, pair; 98, 99; 98, 100; 99, string:'to'; 100, identifier:segment_end_timestamp; 101, pair; 101, 102; 101, 103; 102, string:'value'; 103, identifier:segment_value; 104, return_statement; 104, 105; 105, identifier:segment_list | def format_time_and_value_to_segment_list(time_and_value_list, segments_count, start_timestamp,
end_timestamp, average=False):
segment_list = []
time_step = (end_timestamp - start_timestamp) / segments_count
for i in range(segments_count):
segment_start_timestamp = start_timestamp + time_step * i
segment_end_timestamp = segment_start_timestamp + time_step
value_list = [
value for time, value in time_and_value_list
if time >= segment_start_timestamp and time < segment_end_timestamp]
segment_value = sum(value_list)
if average and len(value_list) != 0:
segment_value /= len(value_list)
segment_list.append({
'from': segment_start_timestamp,
'to': segment_end_timestamp,
'value': segment_value,
})
return segment_list |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:get_api_root_view; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:api_urls; 7, None; 8, block; 8, 9; 8, 15; 8, 25; 8, 47; 8, 154; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 11, identifier:api_root_dict; 12, call; 12, 13; 12, 14; 13, identifier:OrderedDict; 14, argument_list; 15, expression_statement; 15, 16; 16, assignment; 16, 17; 16, 18; 17, identifier:list_name; 18, attribute; 18, 19; 18, 24; 19, subscript; 19, 20; 19, 23; 20, attribute; 20, 21; 20, 22; 21, identifier:self; 22, identifier:routes; 23, integer:0; 24, identifier:name; 25, for_statement; 25, 26; 25, 30; 25, 33; 26, pattern_list; 26, 27; 26, 28; 26, 29; 27, identifier:prefix; 28, identifier:viewset; 29, identifier:basename; 30, attribute; 30, 31; 30, 32; 31, identifier:self; 32, identifier:registry; 33, block; 33, 34; 34, expression_statement; 34, 35; 35, assignment; 35, 36; 35, 39; 36, subscript; 36, 37; 36, 38; 37, identifier:api_root_dict; 38, identifier:prefix; 39, call; 39, 40; 39, 43; 40, attribute; 40, 41; 40, 42; 41, identifier:list_name; 42, identifier:format; 43, argument_list; 43, 44; 44, keyword_argument; 44, 45; 44, 46; 45, identifier:basename; 46, identifier:basename; 47, class_definition; 47, 48; 47, 49; 47, 53; 48, identifier:APIRootView; 49, argument_list; 49, 50; 50, attribute; 50, 51; 50, 52; 51, identifier:views; 52, identifier:APIView; 53, block; 53, 54; 53, 58; 53, 62; 54, expression_statement; 54, 55; 55, assignment; 55, 56; 55, 57; 56, identifier:_ignore_model_permissions; 57, True; 58, expression_statement; 58, 59; 59, assignment; 59, 60; 59, 61; 60, identifier:exclude_from_schema; 61, True; 62, function_definition; 62, 63; 62, 64; 62, 71; 63, function_name:get; 64, parameters; 64, 65; 64, 66; 64, 67; 64, 69; 65, identifier:self; 66, identifier:request; 67, list_splat_pattern; 67, 68; 68, identifier:args; 69, dictionary_splat_pattern; 69, 70; 70, identifier:kwargs; 71, block; 71, 72; 71, 78; 71, 86; 71, 149; 72, expression_statement; 72, 73; 73, assignment; 73, 74; 73, 75; 74, identifier:ret; 75, call; 75, 76; 75, 77; 76, identifier:OrderedDict; 77, argument_list; 78, expression_statement; 78, 79; 79, assignment; 79, 80; 79, 81; 80, identifier:namespace; 81, attribute; 81, 82; 81, 85; 82, attribute; 82, 83; 82, 84; 83, identifier:request; 84, identifier:resolver_match; 85, identifier:namespace; 86, for_statement; 86, 87; 86, 90; 86, 104; 87, pattern_list; 87, 88; 87, 89; 88, identifier:key; 89, identifier:url_name; 90, call; 90, 91; 90, 92; 91, identifier:sorted; 92, argument_list; 92, 93; 92, 98; 93, call; 93, 94; 93, 97; 94, attribute; 94, 95; 94, 96; 95, identifier:api_root_dict; 96, identifier:items; 97, argument_list; 98, keyword_argument; 98, 99; 98, 100; 99, identifier:key; 100, call; 100, 101; 100, 102; 101, identifier:itemgetter; 102, argument_list; 102, 103; 103, integer:0; 104, block; 104, 105; 104, 116; 105, if_statement; 105, 106; 105, 107; 106, identifier:namespace; 107, block; 107, 108; 108, expression_statement; 108, 109; 109, assignment; 109, 110; 109, 111; 110, identifier:url_name; 111, binary_operator:+; 111, 112; 111, 115; 112, binary_operator:+; 112, 113; 112, 114; 113, identifier:namespace; 114, string:':'; 115, identifier:url_name; 116, try_statement; 116, 117; 116, 145; 117, block; 117, 118; 118, expression_statement; 118, 119; 119, assignment; 119, 120; 119, 123; 120, subscript; 120, 121; 120, 122; 121, identifier:ret; 122, identifier:key; 123, call; 123, 124; 123, 125; 124, identifier:reverse; 125, argument_list; 125, 126; 125, 127; 125, 130; 125, 133; 125, 136; 126, identifier:url_name; 127, keyword_argument; 127, 128; 127, 129; 128, identifier:args; 129, identifier:args; 130, keyword_argument; 130, 131; 130, 132; 131, identifier:kwargs; 132, identifier:kwargs; 133, keyword_argument; 133, 134; 133, 135; 134, identifier:request; 135, identifier:request; 136, keyword_argument; 136, 137; 136, 138; 137, identifier:format; 138, call; 138, 139; 138, 142; 139, attribute; 139, 140; 139, 141; 140, identifier:kwargs; 141, identifier:get; 142, argument_list; 142, 143; 142, 144; 143, string:'format'; 144, None; 145, except_clause; 145, 146; 145, 147; 146, identifier:NoReverseMatch; 147, block; 147, 148; 148, continue_statement; 149, return_statement; 149, 150; 150, call; 150, 151; 150, 152; 151, identifier:Response; 152, argument_list; 152, 153; 153, identifier:ret; 154, return_statement; 154, 155; 155, call; 155, 156; 155, 159; 156, attribute; 156, 157; 156, 158; 157, identifier:APIRootView; 158, identifier:as_view; 159, argument_list | def get_api_root_view(self, api_urls=None):
api_root_dict = OrderedDict()
list_name = self.routes[0].name
for prefix, viewset, basename in self.registry:
api_root_dict[prefix] = list_name.format(basename=basename)
class APIRootView(views.APIView):
_ignore_model_permissions = True
exclude_from_schema = True
def get(self, request, *args, **kwargs):
ret = OrderedDict()
namespace = request.resolver_match.namespace
for key, url_name in sorted(api_root_dict.items(), key=itemgetter(0)):
if namespace:
url_name = namespace + ':' + url_name
try:
ret[key] = reverse(
url_name,
args=args,
kwargs=kwargs,
request=request,
format=kwargs.get('format', None)
)
except NoReverseMatch:
continue
return Response(ret)
return APIRootView.as_view() |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:get_default_base_name; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:viewset; 6, block; 6, 7; 6, 16; 6, 41; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:queryset; 10, call; 10, 11; 10, 12; 11, identifier:getattr; 12, argument_list; 12, 13; 12, 14; 12, 15; 13, identifier:viewset; 14, string:'queryset'; 15, None; 16, if_statement; 16, 17; 16, 20; 17, comparison_operator:is; 17, 18; 17, 19; 18, identifier:queryset; 19, None; 20, block; 20, 21; 20, 32; 21, expression_statement; 21, 22; 22, assignment; 22, 23; 22, 24; 23, identifier:get_url_name; 24, call; 24, 25; 24, 26; 25, identifier:getattr; 26, argument_list; 26, 27; 26, 30; 26, 31; 27, attribute; 27, 28; 27, 29; 28, identifier:queryset; 29, identifier:model; 30, string:'get_url_name'; 31, None; 32, if_statement; 32, 33; 32, 36; 33, comparison_operator:is; 33, 34; 33, 35; 34, identifier:get_url_name; 35, None; 36, block; 36, 37; 37, return_statement; 37, 38; 38, call; 38, 39; 38, 40; 39, identifier:get_url_name; 40, argument_list; 41, return_statement; 41, 42; 42, call; 42, 43; 42, 50; 43, attribute; 43, 44; 43, 49; 44, call; 44, 45; 44, 46; 45, identifier:super; 46, argument_list; 46, 47; 46, 48; 47, identifier:SortedDefaultRouter; 48, identifier:self; 49, identifier:get_default_base_name; 50, argument_list; 50, 51; 51, identifier:viewset | def get_default_base_name(self, viewset):
queryset = getattr(viewset, 'queryset', None)
if queryset is not None:
get_url_name = getattr(queryset.model, 'get_url_name', None)
if get_url_name is not None:
return get_url_name()
return super(SortedDefaultRouter, self).get_default_base_name(viewset) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:sort_dict; 3, parameters; 3, 4; 3, 5; 4, identifier:d; 5, default_parameter; 5, 6; 5, 7; 6, identifier:desc; 7, True; 8, block; 8, 9; 8, 31; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 11, identifier:sort; 12, call; 12, 13; 12, 14; 13, identifier:sorted; 14, argument_list; 14, 15; 14, 20; 14, 28; 15, call; 15, 16; 15, 19; 16, attribute; 16, 17; 16, 18; 17, identifier:d; 18, identifier:items; 19, argument_list; 20, keyword_argument; 20, 21; 20, 22; 21, identifier:key; 22, lambda; 22, 23; 22, 25; 23, lambda_parameters; 23, 24; 24, identifier:x; 25, subscript; 25, 26; 25, 27; 26, identifier:x; 27, integer:1; 28, keyword_argument; 28, 29; 28, 30; 29, identifier:reverse; 30, identifier:desc; 31, return_statement; 31, 32; 32, call; 32, 33; 32, 34; 33, identifier:OrderedDict; 34, argument_list; 34, 35; 35, identifier:sort | def sort_dict(d, desc=True):
sort = sorted(d.items(), key=lambda x: x[1], reverse=desc)
return OrderedDict(sort) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 23; 2, function_name:_tupleCompare; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 17; 3, 20; 4, identifier:tuple1; 5, identifier:ineq; 6, identifier:tuple2; 7, default_parameter; 7, 8; 7, 9; 8, identifier:eq; 9, lambda; 9, 10; 9, 13; 10, lambda_parameters; 10, 11; 10, 12; 11, identifier:a; 12, identifier:b; 13, parenthesized_expression; 13, 14; 14, comparison_operator:==; 14, 15; 14, 16; 15, identifier:a; 16, identifier:b; 17, default_parameter; 17, 18; 17, 19; 18, identifier:ander; 19, identifier:AND; 20, default_parameter; 20, 21; 20, 22; 21, identifier:orer; 22, identifier:OR; 23, block; 23, 24; 23, 28; 23, 87; 24, expression_statement; 24, 25; 25, assignment; 25, 26; 25, 27; 26, identifier:orholder; 27, list:[]; 28, for_statement; 28, 29; 28, 30; 28, 37; 29, identifier:limit; 30, call; 30, 31; 30, 32; 31, identifier:range; 32, argument_list; 32, 33; 33, call; 33, 34; 33, 35; 34, identifier:len; 35, argument_list; 35, 36; 36, identifier:tuple1; 37, block; 37, 38; 37, 60; 37, 72; 38, expression_statement; 38, 39; 39, assignment; 39, 40; 39, 41; 40, identifier:eqconstraint; 41, list_comprehension; 41, 42; 41, 47; 42, call; 42, 43; 42, 44; 43, identifier:eq; 44, argument_list; 44, 45; 44, 46; 45, identifier:elem1; 46, identifier:elem2; 47, for_in_clause; 47, 48; 47, 51; 48, pattern_list; 48, 49; 48, 50; 49, identifier:elem1; 50, identifier:elem2; 51, subscript; 51, 52; 51, 57; 52, call; 52, 53; 52, 54; 53, identifier:zip; 54, argument_list; 54, 55; 54, 56; 55, identifier:tuple1; 56, identifier:tuple2; 57, slice; 57, 58; 57, 59; 58, colon; 59, identifier:limit; 60, expression_statement; 60, 61; 61, assignment; 61, 62; 61, 63; 62, identifier:ineqconstraint; 63, call; 63, 64; 63, 65; 64, identifier:ineq; 65, argument_list; 65, 66; 65, 69; 66, subscript; 66, 67; 66, 68; 67, identifier:tuple1; 68, identifier:limit; 69, subscript; 69, 70; 69, 71; 70, identifier:tuple2; 71, identifier:limit; 72, expression_statement; 72, 73; 73, call; 73, 74; 73, 77; 74, attribute; 74, 75; 74, 76; 75, identifier:orholder; 76, identifier:append; 77, argument_list; 77, 78; 78, call; 78, 79; 78, 80; 79, identifier:ander; 80, argument_list; 80, 81; 81, list_splat; 81, 82; 82, parenthesized_expression; 82, 83; 83, binary_operator:+; 83, 84; 83, 85; 84, identifier:eqconstraint; 85, list:[ineqconstraint]; 85, 86; 86, identifier:ineqconstraint; 87, return_statement; 87, 88; 88, call; 88, 89; 88, 90; 89, identifier:orer; 90, argument_list; 90, 91; 91, list_splat; 91, 92; 92, identifier:orholder | def _tupleCompare(tuple1, ineq, tuple2,
eq=lambda a,b: (a==b),
ander=AND,
orer=OR):
orholder = []
for limit in range(len(tuple1)):
eqconstraint = [
eq(elem1, elem2) for elem1, elem2 in zip(tuple1, tuple2)[:limit]]
ineqconstraint = ineq(tuple1[limit], tuple2[limit])
orholder.append(ander(*(eqconstraint + [ineqconstraint])))
return orer(*orholder) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:get_datasets; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:query; 7, string:'*:*'; 8, dictionary_splat_pattern; 8, 9; 9, identifier:kwargs; 10, block; 10, 11; 11, return_statement; 11, 12; 12, call; 12, 13; 12, 22; 13, attribute; 13, 14; 13, 21; 14, attribute; 14, 15; 14, 20; 15, attribute; 15, 16; 15, 19; 16, attribute; 16, 17; 16, 18; 17, identifier:hdx; 18, identifier:data; 19, identifier:dataset; 20, identifier:Dataset; 21, identifier:search_in_hdx; 22, argument_list; 22, 23; 22, 26; 22, 31; 22, 40; 23, keyword_argument; 23, 24; 23, 25; 24, identifier:query; 25, identifier:query; 26, keyword_argument; 26, 27; 26, 28; 27, identifier:configuration; 28, attribute; 28, 29; 28, 30; 29, identifier:self; 30, identifier:configuration; 31, keyword_argument; 31, 32; 31, 33; 32, identifier:fq; 33, binary_operator:%; 33, 34; 33, 35; 34, string:'organization:%s'; 35, subscript; 35, 36; 35, 39; 36, attribute; 36, 37; 36, 38; 37, identifier:self; 38, identifier:data; 39, string:'name'; 40, dictionary_splat; 40, 41; 41, identifier:kwargs | def get_datasets(self, query='*:*', **kwargs):
return hdx.data.dataset.Dataset.search_in_hdx(query=query,
configuration=self.configuration,
fq='organization:%s' % self.data['name'], **kwargs) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:get_all_organization_names; 3, parameters; 3, 4; 3, 7; 4, default_parameter; 4, 5; 4, 6; 5, identifier:configuration; 6, None; 7, dictionary_splat_pattern; 7, 8; 8, identifier:kwargs; 9, block; 9, 10; 9, 19; 9, 25; 10, expression_statement; 10, 11; 11, assignment; 11, 12; 11, 13; 12, identifier:organization; 13, call; 13, 14; 13, 15; 14, identifier:Organization; 15, argument_list; 15, 16; 16, keyword_argument; 16, 17; 16, 18; 17, identifier:configuration; 18, identifier:configuration; 19, expression_statement; 19, 20; 20, assignment; 20, 21; 20, 24; 21, subscript; 21, 22; 21, 23; 22, identifier:organization; 23, string:'id'; 24, string:'all organizations'; 25, return_statement; 25, 26; 26, call; 26, 27; 26, 30; 27, attribute; 27, 28; 27, 29; 28, identifier:organization; 29, identifier:_write_to_hdx; 30, argument_list; 30, 31; 30, 32; 30, 33; 31, string:'list'; 32, identifier:kwargs; 33, string:'id' | def get_all_organization_names(configuration=None, **kwargs):
organization = Organization(configuration=configuration)
organization['id'] = 'all organizations'
return organization._write_to_hdx('list', kwargs, 'id') |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 16; 2, function_name:search_in_hdx; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 4, identifier:cls; 5, default_parameter; 5, 6; 5, 7; 6, identifier:query; 7, string:'*:*'; 8, default_parameter; 8, 9; 8, 10; 9, identifier:configuration; 10, None; 11, default_parameter; 11, 12; 11, 13; 12, identifier:page_size; 13, integer:1000; 14, dictionary_splat_pattern; 14, 15; 15, identifier:kwargs; 16, block; 16, 17; 16, 26; 16, 38; 16, 48; 16, 52; 16, 56; 16, 300; 16, 316; 17, expression_statement; 17, 18; 18, assignment; 18, 19; 18, 20; 19, identifier:dataset; 20, call; 20, 21; 20, 22; 21, identifier:Dataset; 22, argument_list; 22, 23; 23, keyword_argument; 23, 24; 23, 25; 24, identifier:configuration; 25, identifier:configuration; 26, expression_statement; 26, 27; 27, assignment; 27, 28; 27, 29; 28, identifier:total_rows; 29, call; 29, 30; 29, 33; 30, attribute; 30, 31; 30, 32; 31, identifier:kwargs; 32, identifier:get; 33, argument_list; 33, 34; 33, 35; 34, string:'rows'; 35, attribute; 35, 36; 35, 37; 36, identifier:cls; 37, identifier:max_int; 38, expression_statement; 38, 39; 39, assignment; 39, 40; 39, 41; 40, identifier:start; 41, call; 41, 42; 41, 45; 42, attribute; 42, 43; 42, 44; 43, identifier:kwargs; 44, identifier:get; 45, argument_list; 45, 46; 45, 47; 46, string:'start'; 47, integer:0; 48, expression_statement; 48, 49; 49, assignment; 49, 50; 49, 51; 50, identifier:all_datasets; 51, None; 52, expression_statement; 52, 53; 53, assignment; 53, 54; 53, 55; 54, identifier:attempts; 55, integer:0; 56, while_statement; 56, 57; 56, 66; 57, boolean_operator:and; 57, 58; 57, 63; 58, comparison_operator:<; 58, 59; 58, 60; 59, identifier:attempts; 60, attribute; 60, 61; 60, 62; 61, identifier:cls; 62, identifier:max_attempts; 63, comparison_operator:is; 63, 64; 63, 65; 64, identifier:all_datasets; 65, None; 66, block; 66, 67; 66, 73; 66, 79; 66, 248; 67, expression_statement; 67, 68; 68, assignment; 68, 69; 68, 70; 69, identifier:all_datasets; 70, call; 70, 71; 70, 72; 71, identifier:list; 72, argument_list; 73, expression_statement; 73, 74; 74, assignment; 74, 75; 74, 76; 75, identifier:counts; 76, call; 76, 77; 76, 78; 77, identifier:set; 78, argument_list; 79, for_statement; 79, 80; 79, 81; 79, 89; 80, identifier:page; 81, call; 81, 82; 81, 83; 82, identifier:range; 83, argument_list; 83, 84; 84, binary_operator:+; 84, 85; 84, 88; 85, binary_operator://; 85, 86; 85, 87; 86, identifier:total_rows; 87, identifier:page_size; 88, integer:1; 89, block; 89, 90; 89, 96; 89, 104; 89, 110; 89, 118; 89, 124; 89, 146; 89, 152; 90, expression_statement; 90, 91; 91, assignment; 91, 92; 91, 93; 92, identifier:pagetimespagesize; 93, binary_operator:*; 93, 94; 93, 95; 94, identifier:page; 95, identifier:page_size; 96, expression_statement; 96, 97; 97, assignment; 97, 98; 97, 101; 98, subscript; 98, 99; 98, 100; 99, identifier:kwargs; 100, string:'start'; 101, binary_operator:+; 101, 102; 101, 103; 102, identifier:start; 103, identifier:pagetimespagesize; 104, expression_statement; 104, 105; 105, assignment; 105, 106; 105, 107; 106, identifier:rows_left; 107, binary_operator:-; 107, 108; 107, 109; 108, identifier:total_rows; 109, identifier:pagetimespagesize; 110, expression_statement; 110, 111; 111, assignment; 111, 112; 111, 113; 112, identifier:rows; 113, call; 113, 114; 113, 115; 114, identifier:min; 115, argument_list; 115, 116; 115, 117; 116, identifier:rows_left; 117, identifier:page_size; 118, expression_statement; 118, 119; 119, assignment; 119, 120; 119, 123; 120, subscript; 120, 121; 120, 122; 121, identifier:kwargs; 122, string:'rows'; 123, identifier:rows; 124, expression_statement; 124, 125; 125, assignment; 125, 126; 125, 129; 126, pattern_list; 126, 127; 126, 128; 127, identifier:_; 128, identifier:result; 129, call; 129, 130; 129, 133; 130, attribute; 130, 131; 130, 132; 131, identifier:dataset; 132, identifier:_read_from_hdx; 133, argument_list; 133, 134; 133, 135; 133, 136; 133, 137; 133, 144; 134, string:'dataset'; 135, identifier:query; 136, string:'q'; 137, subscript; 137, 138; 137, 143; 138, call; 138, 139; 138, 142; 139, attribute; 139, 140; 139, 141; 140, identifier:Dataset; 141, identifier:actions; 142, argument_list; 143, string:'search'; 144, dictionary_splat; 144, 145; 145, identifier:kwargs; 146, expression_statement; 146, 147; 147, assignment; 147, 148; 147, 149; 148, identifier:datasets; 149, call; 149, 150; 149, 151; 150, identifier:list; 151, argument_list; 152, if_statement; 152, 153; 152, 154; 152, 239; 153, identifier:result; 154, block; 154, 155; 154, 165; 155, expression_statement; 155, 156; 156, assignment; 156, 157; 156, 158; 157, identifier:count; 158, call; 158, 159; 158, 162; 159, attribute; 159, 160; 159, 161; 160, identifier:result; 161, identifier:get; 162, argument_list; 162, 163; 162, 164; 163, string:'count'; 164, None; 165, if_statement; 165, 166; 165, 167; 165, 236; 166, identifier:count; 167, block; 167, 168; 167, 175; 167, 184; 167, 226; 167, 230; 168, expression_statement; 168, 169; 169, call; 169, 170; 169, 173; 170, attribute; 170, 171; 170, 172; 171, identifier:counts; 172, identifier:add; 173, argument_list; 173, 174; 174, identifier:count; 175, expression_statement; 175, 176; 176, assignment; 176, 177; 176, 178; 177, identifier:no_results; 178, call; 178, 179; 178, 180; 179, identifier:len; 180, argument_list; 180, 181; 181, subscript; 181, 182; 181, 183; 182, identifier:result; 183, string:'results'; 184, for_statement; 184, 185; 184, 186; 184, 189; 185, identifier:datasetdict; 186, subscript; 186, 187; 186, 188; 187, identifier:result; 188, string:'results'; 189, block; 189, 190; 189, 199; 189, 207; 189, 213; 189, 219; 190, expression_statement; 190, 191; 191, assignment; 191, 192; 191, 193; 192, identifier:dataset; 193, call; 193, 194; 193, 195; 194, identifier:Dataset; 195, argument_list; 195, 196; 196, keyword_argument; 196, 197; 196, 198; 197, identifier:configuration; 198, identifier:configuration; 199, expression_statement; 199, 200; 200, assignment; 200, 201; 200, 204; 201, attribute; 201, 202; 201, 203; 202, identifier:dataset; 203, identifier:old_data; 204, call; 204, 205; 204, 206; 205, identifier:dict; 206, argument_list; 207, expression_statement; 207, 208; 208, assignment; 208, 209; 208, 212; 209, attribute; 209, 210; 209, 211; 210, identifier:dataset; 211, identifier:data; 212, identifier:datasetdict; 213, expression_statement; 213, 214; 214, call; 214, 215; 214, 218; 215, attribute; 215, 216; 215, 217; 216, identifier:dataset; 217, identifier:_dataset_create_resources; 218, argument_list; 219, expression_statement; 219, 220; 220, call; 220, 221; 220, 224; 221, attribute; 221, 222; 221, 223; 222, identifier:datasets; 223, identifier:append; 224, argument_list; 224, 225; 225, identifier:dataset; 226, expression_statement; 226, 227; 227, augmented_assignment:+=; 227, 228; 227, 229; 228, identifier:all_datasets; 229, identifier:datasets; 230, if_statement; 230, 231; 230, 234; 231, comparison_operator:<; 231, 232; 231, 233; 232, identifier:no_results; 233, identifier:rows; 234, block; 234, 235; 235, break_statement; 236, else_clause; 236, 237; 237, block; 237, 238; 238, break_statement; 239, else_clause; 239, 240; 240, block; 240, 241; 241, expression_statement; 241, 242; 242, call; 242, 243; 242, 246; 243, attribute; 243, 244; 243, 245; 244, identifier:logger; 245, identifier:debug; 246, argument_list; 246, 247; 247, identifier:result; 248, if_statement; 248, 249; 248, 257; 248, 266; 249, boolean_operator:and; 249, 250; 249, 251; 250, identifier:all_datasets; 251, comparison_operator:!=; 251, 252; 251, 256; 252, call; 252, 253; 252, 254; 253, identifier:len; 254, argument_list; 254, 255; 255, identifier:counts; 256, integer:1; 257, block; 257, 258; 257, 262; 258, expression_statement; 258, 259; 259, assignment; 259, 260; 259, 261; 260, identifier:all_datasets; 261, None; 262, expression_statement; 262, 263; 263, augmented_assignment:+=; 263, 264; 263, 265; 264, identifier:attempts; 265, integer:1; 266, else_clause; 266, 267; 267, block; 267, 268; 267, 278; 268, expression_statement; 268, 269; 269, assignment; 269, 270; 269, 271; 270, identifier:ids; 271, list_comprehension; 271, 272; 271, 275; 272, subscript; 272, 273; 272, 274; 273, identifier:dataset; 274, string:'id'; 275, for_in_clause; 275, 276; 275, 277; 276, identifier:dataset; 277, identifier:all_datasets; 278, if_statement; 278, 279; 278, 291; 279, comparison_operator:!=; 279, 280; 279, 284; 280, call; 280, 281; 280, 282; 281, identifier:len; 282, argument_list; 282, 283; 283, identifier:ids; 284, call; 284, 285; 284, 286; 285, identifier:len; 286, argument_list; 286, 287; 287, call; 287, 288; 287, 289; 288, identifier:set; 289, argument_list; 289, 290; 290, identifier:ids; 291, block; 291, 292; 291, 296; 292, expression_statement; 292, 293; 293, assignment; 293, 294; 293, 295; 294, identifier:all_datasets; 295, None; 296, expression_statement; 296, 297; 297, augmented_assignment:+=; 297, 298; 297, 299; 298, identifier:attempts; 299, integer:1; 300, if_statement; 300, 301; 300, 310; 301, boolean_operator:and; 301, 302; 301, 307; 302, comparison_operator:==; 302, 303; 302, 304; 303, identifier:attempts; 304, attribute; 304, 305; 304, 306; 305, identifier:cls; 306, identifier:max_attempts; 307, comparison_operator:is; 307, 308; 307, 309; 308, identifier:all_datasets; 309, None; 310, block; 310, 311; 311, raise_statement; 311, 312; 312, call; 312, 313; 312, 314; 313, identifier:HDXError; 314, argument_list; 314, 315; 315, string:'Maximum attempts reached for searching for datasets!'; 316, return_statement; 316, 317; 317, identifier:all_datasets | def search_in_hdx(cls, query='*:*', configuration=None, page_size=1000, **kwargs):
dataset = Dataset(configuration=configuration)
total_rows = kwargs.get('rows', cls.max_int)
start = kwargs.get('start', 0)
all_datasets = None
attempts = 0
while attempts < cls.max_attempts and all_datasets is None:
all_datasets = list()
counts = set()
for page in range(total_rows // page_size + 1):
pagetimespagesize = page * page_size
kwargs['start'] = start + pagetimespagesize
rows_left = total_rows - pagetimespagesize
rows = min(rows_left, page_size)
kwargs['rows'] = rows
_, result = dataset._read_from_hdx('dataset', query, 'q', Dataset.actions()['search'], **kwargs)
datasets = list()
if result:
count = result.get('count', None)
if count:
counts.add(count)
no_results = len(result['results'])
for datasetdict in result['results']:
dataset = Dataset(configuration=configuration)
dataset.old_data = dict()
dataset.data = datasetdict
dataset._dataset_create_resources()
datasets.append(dataset)
all_datasets += datasets
if no_results < rows:
break
else:
break
else:
logger.debug(result)
if all_datasets and len(counts) != 1:
all_datasets = None
attempts += 1
else:
ids = [dataset['id'] for dataset in all_datasets]
if len(ids) != len(set(ids)):
all_datasets = None
attempts += 1
if attempts == cls.max_attempts and all_datasets is None:
raise HDXError('Maximum attempts reached for searching for datasets!')
return all_datasets |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 18; 1, 22; 2, function_name:sort_dict; 3, parameters; 3, 4; 3, 8; 3, 13; 4, typed_parameter; 4, 5; 4, 6; 5, identifier:d; 6, type; 6, 7; 7, identifier:dict; 8, typed_default_parameter; 8, 9; 8, 10; 8, 12; 9, identifier:by; 10, type; 10, 11; 11, identifier:str; 12, string:'key'; 13, typed_default_parameter; 13, 14; 13, 15; 13, 17; 14, identifier:allow_duplicates; 15, type; 15, 16; 16, identifier:bool; 17, True; 18, type; 18, 19; 19, attribute; 19, 20; 19, 21; 20, identifier:collections; 21, identifier:OrderedDict; 22, block; 22, 23; 22, 93; 23, if_statement; 23, 24; 23, 27; 23, 32; 23, 86; 24, comparison_operator:==; 24, 25; 24, 26; 25, identifier:by; 26, string:'key'; 27, block; 27, 28; 28, expression_statement; 28, 29; 29, assignment; 29, 30; 29, 31; 30, identifier:i; 31, integer:0; 32, elif_clause; 32, 33; 32, 36; 33, comparison_operator:==; 33, 34; 33, 35; 34, identifier:by; 35, string:'value'; 36, block; 36, 37; 36, 48; 36, 82; 37, expression_statement; 37, 38; 38, assignment; 38, 39; 38, 40; 39, identifier:values; 40, call; 40, 41; 40, 42; 41, identifier:list; 42, argument_list; 42, 43; 43, call; 43, 44; 43, 47; 44, attribute; 44, 45; 44, 46; 45, identifier:d; 46, identifier:values; 47, argument_list; 48, if_statement; 48, 49; 48, 64; 49, boolean_operator:and; 49, 50; 49, 62; 50, comparison_operator:!=; 50, 51; 50, 55; 51, call; 51, 52; 51, 53; 52, identifier:len; 53, argument_list; 53, 54; 54, identifier:values; 55, call; 55, 56; 55, 57; 56, identifier:len; 57, argument_list; 57, 58; 58, call; 58, 59; 58, 60; 59, identifier:set; 60, argument_list; 60, 61; 61, identifier:values; 62, not_operator; 62, 63; 63, identifier:allow_duplicates; 64, block; 64, 65; 64, 72; 65, expression_statement; 65, 66; 66, assignment; 66, 67; 66, 68; 67, identifier:duplicates; 68, call; 68, 69; 68, 70; 69, identifier:find_duplicates; 70, argument_list; 70, 71; 71, identifier:values; 72, raise_statement; 72, 73; 73, call; 73, 74; 73, 75; 74, identifier:ValueError; 75, argument_list; 75, 76; 76, call; 76, 77; 76, 80; 77, attribute; 77, 78; 77, 79; 78, string:"There are duplicates in the values: {}"; 79, identifier:format; 80, argument_list; 80, 81; 81, identifier:duplicates; 82, expression_statement; 82, 83; 83, assignment; 83, 84; 83, 85; 84, identifier:i; 85, integer:1; 86, else_clause; 86, 87; 87, block; 87, 88; 88, raise_statement; 88, 89; 89, call; 89, 90; 89, 91; 90, identifier:ValueError; 91, argument_list; 91, 92; 92, string:"by can be 'key' or 'value'."; 93, return_statement; 93, 94; 94, call; 94, 95; 94, 98; 95, attribute; 95, 96; 95, 97; 96, identifier:collections; 97, identifier:OrderedDict; 98, argument_list; 98, 99; 99, call; 99, 100; 99, 101; 100, identifier:sorted; 101, argument_list; 101, 102; 101, 107; 102, call; 102, 103; 102, 106; 103, attribute; 103, 104; 103, 105; 104, identifier:d; 105, identifier:items; 106, argument_list; 107, keyword_argument; 107, 108; 107, 109; 108, identifier:key; 109, lambda; 109, 110; 109, 112; 110, lambda_parameters; 110, 111; 111, identifier:t; 112, subscript; 112, 113; 112, 114; 113, identifier:t; 114, identifier:i | def sort_dict(d: dict, by: str = 'key',
allow_duplicates: bool = True) -> collections.OrderedDict:
if by == 'key':
i = 0
elif by == 'value':
values = list(d.values())
if len(values) != len(set(values)) and not allow_duplicates:
duplicates = find_duplicates(values)
raise ValueError("There are duplicates in the values: {}".format(duplicates))
i = 1
else:
raise ValueError("by can be 'key' or 'value'.")
return collections.OrderedDict(sorted(d.items(), key=lambda t: t[i])) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:get_all_users; 3, parameters; 3, 4; 3, 7; 4, default_parameter; 4, 5; 4, 6; 5, identifier:configuration; 6, None; 7, dictionary_splat_pattern; 7, 8; 8, identifier:kwargs; 9, block; 9, 10; 9, 19; 9, 25; 9, 36; 9, 42; 9, 75; 10, expression_statement; 10, 11; 11, assignment; 11, 12; 11, 13; 12, identifier:user; 13, call; 13, 14; 13, 15; 14, identifier:User; 15, argument_list; 15, 16; 16, keyword_argument; 16, 17; 16, 18; 17, identifier:configuration; 18, identifier:configuration; 19, expression_statement; 19, 20; 20, assignment; 20, 21; 20, 24; 21, subscript; 21, 22; 21, 23; 22, identifier:user; 23, string:'id'; 24, string:'all users'; 25, expression_statement; 25, 26; 26, assignment; 26, 27; 26, 28; 27, identifier:result; 28, call; 28, 29; 28, 32; 29, attribute; 29, 30; 29, 31; 30, identifier:user; 31, identifier:_write_to_hdx; 32, argument_list; 32, 33; 32, 34; 32, 35; 33, string:'list'; 34, identifier:kwargs; 35, string:'id'; 36, expression_statement; 36, 37; 37, assignment; 37, 38; 37, 39; 38, identifier:users; 39, call; 39, 40; 39, 41; 40, identifier:list; 41, argument_list; 42, if_statement; 42, 43; 42, 44; 42, 66; 43, identifier:result; 44, block; 44, 45; 45, for_statement; 45, 46; 45, 47; 45, 48; 46, identifier:userdict; 47, identifier:result; 48, block; 48, 49; 48, 59; 49, expression_statement; 49, 50; 50, assignment; 50, 51; 50, 52; 51, identifier:user; 52, call; 52, 53; 52, 54; 53, identifier:User; 54, argument_list; 54, 55; 54, 56; 55, identifier:userdict; 56, keyword_argument; 56, 57; 56, 58; 57, identifier:configuration; 58, identifier:configuration; 59, expression_statement; 59, 60; 60, call; 60, 61; 60, 64; 61, attribute; 61, 62; 61, 63; 62, identifier:users; 63, identifier:append; 64, argument_list; 64, 65; 65, identifier:user; 66, else_clause; 66, 67; 67, block; 67, 68; 68, expression_statement; 68, 69; 69, call; 69, 70; 69, 73; 70, attribute; 70, 71; 70, 72; 71, identifier:logger; 72, identifier:debug; 73, argument_list; 73, 74; 74, identifier:result; 75, return_statement; 75, 76; 76, identifier:users | def get_all_users(configuration=None, **kwargs):
user = User(configuration=configuration)
user['id'] = 'all users'
result = user._write_to_hdx('list', kwargs, 'id')
users = list()
if result:
for userdict in result:
user = User(userdict, configuration=configuration)
users.append(user)
else:
logger.debug(result)
return users |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:fromkeys; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:cls; 5, identifier:iterable; 6, default_parameter; 6, 7; 6, 8; 7, identifier:value; 8, None; 9, block; 9, 10; 9, 28; 10, if_statement; 10, 11; 10, 16; 11, not_operator; 11, 12; 12, call; 12, 13; 12, 14; 13, identifier:callable; 14, argument_list; 14, 15; 15, identifier:value; 16, block; 16, 17; 17, return_statement; 17, 18; 18, call; 18, 19; 18, 20; 19, identifier:cls; 20, argument_list; 20, 21; 21, call; 21, 22; 21, 25; 22, attribute; 22, 23; 22, 24; 23, identifier:dict; 24, identifier:fromkeys; 25, argument_list; 25, 26; 25, 27; 26, identifier:iterable; 27, identifier:value; 28, return_statement; 28, 29; 29, call; 29, 30; 29, 31; 30, identifier:cls; 31, generator_expression; 31, 32; 31, 38; 32, tuple; 32, 33; 32, 34; 33, identifier:key; 34, call; 34, 35; 34, 36; 35, identifier:value; 36, argument_list; 36, 37; 37, identifier:key; 38, for_in_clause; 38, 39; 38, 40; 39, identifier:key; 40, identifier:iterable | def fromkeys(cls, iterable, value=None):
if not callable(value):
return cls(dict.fromkeys(iterable, value))
return cls((key, value(key)) for key in iterable) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.